Articles in the Programming category

  1. Python Packaging, the easy way

    This is an absolutely fantastic post on Hacker NEws, so much so I threw away the post I was working on for this exact same topic. All credit to the original author, I just formatted it.

    Packaging, the easy way

    Because I'm not on a blog, I can't go too …

  2. Python Tricks Roundup 2

    I subscribed to Dan Bader's mailing lists in January so you don't have to (you should though, it's decent). Here's the second set of tricks I got from it so far.

    Get the name of an object's class as a string:

    class MyClass: pass
    obj = MyClass()
    obj.__class__.__name__
    # 'MyClass …
  3. Python Tricks Roundup

    I subscribed to Dan Bader's mailing lists in January so you don't have to (you should though, it's decent). Here's the tricks I got from it so far.

    Python 3 has a std lib module for working with IP addresses:

    import ipaddress
    ipaddress.ip_address('192.168.1.2')
    # IPv4Address('192 …
  4. Notes on Functional Programming in Python

    Lambda Expressions

    Lambda expressions are simply small anonymous functions. I could go in to more detail, but I'd be hard pressed to beat Dan Bader's explanation linked at the end. Basically, you want to use them when you need a single expression that won't be needed elsewhere in your code …

  5. Notes on "Python's Class Development Toolkit"

    Adapted from a Jupyter notebook, these are my notes of the the Raymond Hettinger PyCon talk "Python's Class Development Toolkit", linked at the end.

    Include a Module DocString for your module

    '''Circuituous, LLC --
       An Advanced Circle Analytics Company
    '''
    

    Document your class and methods

    class Circle:
        'An advanced circle analytic toolkit …
  6. SoA and AoS, with Examples

    Structure of arrays (SoA) and Array of structures (AoS) are ways of structuring data to minimize CPU cache misses, speeding up data access and taking better advantage of processing power, especially in parallel programming. After minimizing the amount of data you are reading, writing, and copying, this is the next …

  7. Understanding Pointers, Functions, and Memory

    Pointers are a very powerful programming tool, but wholly unnecessary in the majority of programming. I've never had an issue understanding the basic idea, but I've never quite understood when and how to use them. I know what a hammer can do, and I know why it's important, but what …

  8. Composition in Python

    I'm a big fan of composition over inheritance in OOP, the only issue is that it's a bit harder to wrap your head around than basic inheritance. For a quick reminder, composition is simply aggregating objects together by making objects attributes of other objects. If an object has-a different object …

  9. Underscore in Python

    The underscore in Python has implicit (by convention) and explicit (enforced by the interpreter) meanings. While there might be more uses that I don't know of, I'll explain the five I do know.

    • Implicit
      • Single Leading Underscore: _var
      • Single Trailing Underscore: var_
      • Single Underscore: _
    • Explicit
      • Double Leading Underscore: __var …
  10. Python Decorators

    Decorators in Python were confusing when I first came across them, but the concept is simple enough and very powerful. Note that Python decorators are not to be confused with the design pattern of the same name. In Python, everything is an object and functions are first class citizens. Those …

  11. Python Learning List

    Recently a colleague asked me for Python recommendations and resources for learning. This is a tough question since the answer is different for everyone, but in general these are the resources I think are best or have helped me.

    Tools

    It's easy to get caught up learning new tools, frameworks …

  12. Python with Statement

    with, and by extension context managers, are one of the things about Python that I've used but never really understood. At my current job it's used quite frequently for an API I have to access, and I'm also trying to square where it fits in relation to decorators, so it's …

  13. Interfaces

    This is something I wrote up very quickly to help me better understand Interfaces in C#, particularly why you would use them instead of abstract classes. This isn't specific to C#.

    So, what's the point of Interfaces? It's not just a work around for not having multiple inheritance in C …

  14. Modern Strings in Python

    I'll be honest, when I first read about f-strings (aka formatted string literals) coming to Python, I was not impressed. The syntax looked pretty bad and it was creating yet another way to do the same thing, which goes against the Zen of Python. After going over it a bit …

  15. Reversing Strings in Python and PowerShell

    Reversing a string is super easy in Python and a little more complicated in PowerShell. Both of them have multiple ways to do it, all basically similar. The only trade-offs appear to be obvious: do you care about the overhead of a function call, line count, verbosity, etc. Personally, I'd …

  16. PowerShell Background Jobs

    PowerShell background jobs are a simple and powerful tool and can be used with almost any Powershell or regular cmd commands. The most important cmdlets for using background jobs are Start-Job, Get-Job, and Remove-Job. Jobs have to be removed after completion or they will remain in a completed state.

    Start-Job …
  17. Formatting Output in PowerShell

    There's five useful commands when it comes to controlling your output in PowerShell (in my experience): Out-File, Export-Csv, Format-Table aka ft, Format-List aka fl, and Out-Null. These are all pretty self explanatory. Out-File saves your output to a regular text file (and does not translate it from a PowerShell object …

  18. Help, Your PowerShell Command Isn't Working!

    This is a living document where I try to help common issues running the PowerShell commands and scripts I post.

    The term <cmdlet> is not recognized as the name of a cmdlet... etc.
    

    This can be caused by two issues, either you have not imported the appropriate module (i.e …

  19. PowerShell Remoting

    When it comes to remoting in PowerShell, there's two main options: Invoke-Command (good) and Enter-PSSession (bad, but necessary sometimes). The difference is that Invoke-Command will do as the name says, invoke the command for you and return the output. Enter-PSSession will change the context of your PowerShell to that of …

  20. Delta Time in Godot

    The Godot docs don't cover delta in any great detail and maybe they shouldn't, but understanding delta time is important in game programming since it helps your game gain framerate independence. If you don't already know, tying game logic and physics to framerate is easy but gives you undesired behavior …