Articles in the programming category

  1. Type Checking in Python

    Posted on in programming

    What is type checking?

    Type checking is a process of verifying that the types of variables, expressions, and statements in a program are consistent with the expected types. Type checking can be performed statically, at compile time, or dynamically, at runtime.

    Benefits of type checking in Python

    There are many …

  2. [Git] remote.origin.prune vs fetch.prune

    Posted on in programming

    What is the difference between git config remote.origin.prune true and git config fetch.prune true?

    When you fetch from a remote repository, Git creates a remote-tracking branch for each branch in the remote repository. These remote-tracking branches are used to keep track of the state of the remote …

  3. Bazel vs Buck

    Posted on in programming

    Bazel and Buck are two popular build systems used by large software companies. Both systems offer a number of features that make them well-suited for building large, complex codebases, including:

    • Multi-language support: Both Bazel and Buck support a wide range of programming languages, including Java, C++, Python, and Go.
    • High-level …
  4. The Benefits of Using GitHub Copilot

    Posted on in programming

    GitHub Copilot is a powerful AI-powered code completion tool that can help you write better code faster. It uses OpenAI Codex, a massive dataset of code and natural language, to understand the context of your code and suggest relevant code snippets and entire functions.

    Here are some of the benefits …

  5. Hermeticity - So Hot Right Now

    Posted on in programming

    Hermeticity in software builds refers to the practice of creating software packages that are self-contained, with all necessary dependencies and resources included within the package. In other words, a hermetic build can be installed and run on any system, without requiring additional configuration or installations. This practice is becoming increasingly …

  6. [Python] Patching platform.uname in Tests

    Posted on in programming

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    from unittest import IsolatedAsyncioTestCase
    from unittest.mock import create_autospec, patch
    
    from foo import is_foo, is_bar, platform
    
    class FooTestCase(IsolatedAsyncioTestCase):
        @patch(
            "platform.uname",
            return_value=create_autospec(
                platform.uname_result, system="Linux", node="BAR"
            ),
        )
        def test_wrapper_is_foo(self, m_uname …
  7. Git Remote Moved?

    Posted on in programming

    There are lots of reasons why your Git repository remotes might move. I recently dealt with a migration to GitHub. You can always just clone the repository again and go about your business, but I had several local branches I wanted to keep working on.

    There's lots of ways to …

  8. [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 …
  9. 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 …

  10. [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.

  11. 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 …
  12. [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 …

  13. 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 …

Slaptijack's Koding Kraken