Articles in the programming category

  1. [Git] Per Repo SSH Identity

    Posted on in programming

    For work, I need a personal GitHub account in addition to my Enterprise Managed User (EMU) account. After updating my SSH keys the other day, I realized I had inadvertently locked myself out of using my personal account on my work laptop.

    Here's what that looked like:

    $ git pull
    ERROR …
  2. Quick Codemods with sed

    Posted on in programming

    I had a few different changes last week (in two different repos) that required one-line changes in lots of files.

    Quick note here that I'm using GNU sed. If you're on a Mac, you can use GNU sed, too (via Homebrew, for example).

    Example 1: Change Status

    In this first …

  3. [Python] Popular Search Terms

    Posted on in programming

    I thought it would be neat to keep an eye on the popular google search terms related to Python.

    The list below uses JavaScript from Google Trends. You can use the kebab menu icon to choose between "Top" and "Rising" search phrases.

  4. Two Column for Loop in bash

    Posted on in programming

    I had this interesting question the other day. Someone had a file with two columns of data in it. They wanted to assign each column to a different variable and then take action using those two variables. Here's the example I wrote for them:

    IFS=$'\n';
    for LINE in $(cat …
  5. [Python] Socket Timeouts in urllib2

    Posted on in Programming

    Things have changed quite a lot since this post was originally written in 2016. Currently, I would recommend switching over to making asynchronous calls via aiohttp.

    One of my scripts that makes an API call has been failing silently lately. It appears that the connection is timing out, but I …

  6. UnicodeDecodeError: 'ascii' codec can't decode byte

    Posted on in Programming

    Although I was getting this output in relation to one of my Jinja2 templates, it really isn't a Jinja2 problem.

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 69: ordinal not in range(128)
    

    The bit of code here should be doing nothing more than printing a float …

  7. [Python] Empty String?

    Posted on in Programming

    I've mentioned before that empty strings in Python are false. This leads to a common if not string paradigm. Unfortunately, this can be problematic. Check out this snippet:

    >>> string = ""
    >>> if not string:
    ...  print("empty")
    ... 
    empty
    

    That pretty much worked out just as we imagined. The empty string returned False and …

Slaptijack's Koding Kraken