Mixed Async code in Sync Python: Disappointingly Simple

python programming
One thing I love about Python’s practical approach to type annotations and enforcement is that it’s gradual: you can rapidly code a large ball of mud and get it working, then refine it to make it safer with typing later on. Chalk this up as another good idea (possibly by accident) for Python: you can do the same with async. At work, someone lamented that threads aren’t quite safe but they needed to do multiple http requests in parallel.
Read more...

Modern Python: New Features, Better Code

python programming
I wrote a blog post that is now on my employer’s engineering blog. I used my normal Markdown/Hugo/Github flow to author and edit it, so if you want to see the revision history it’s right here.

The Anime Watcher: Another Game

golang programming games games-by-jason
I wrote another game game for a Weekend Game Jam with an Anime theme. A short bit of interactive fiction. It’s Webassembly using ebitengine. Play The Anime Watcher on itch.io

A Case for Match

python
The Python 3.10 release includes the new match statement, which superficially looks like the case/switch statements in other languages but semantically is closer to pattern matching in Haskell or Rust. Like the walrus operator*, I struggled to find a use case for this and it seemed like a feature that was added just because the language is 30+ years old and all the good new functionality is taken. However, I found a pretty good case for it that used to be a lot more work: duck-typey arguments that make default case rules easy but enable more complex functionality as needed.
Read more...

Python as a Language is Inescabably Coupled with its Implementation Part 2: The Tracer

python
I was recently discussing some dumb Python tricks at work with some colleagues and showed them this old Gist I wrote, which in modern times I would rewrite to look like this: import functools import inspect import sys @functools.lru_cache def getlines(filename): with open(filename, "r") as file_handle: return tuple(file_handle) @functools.lru_cache def getline(filename, line_number): return getlines(filename)[line_number - 1] def tracefunction(frame, event, arg): if event == "line": info = inspect.getframeinfo(frame) fname, lineno, fn = info.
Read more...

Trump Run: A Game

golang programming games games-by-jason
I wrote a game inspired by a tweet a coworker shared on a work Slack channel a few weeks back. It’s Webassembly using ebitengine. Play Trump Run on itch.io

Little Guys! A Puzzle Game Without Enough Levels

golang programming games games-by-jason
I wrote another small puzzle game for a Weekend Game Jam with the theme Colors. It’s Webassembly using ebitengine. Play Little Guys (A Puzzle Game) on itch.io

Async programming: understanding it from fundamentals

programming python javascript
This was inspired by a short chat I had with a coworker, trying to give a simple, 15 minute explanation of something that took me a decade to wrap my head around due to poor teaching resources online. Async programming in modern “industrial” languages is shrouded in magic, abstractions, and years of atrocious decisions (looking at you, Javascript/Python). Most tutorials start out with “just mark your function async and await it and use these magic incantations and you’re good to go!
Read more...

Modern Python: Features I Haven't Used But Plan To

python programming
Python has continued to progress and introduce new features and modules. In this post I’ll cover features I haven’t used much (or at all) and how I plan on using or not using them. Walrus Operator I’ve been aware of this for a few years. I’ve found about 3 times where I’ve found it appropriate to use. It’s nice but not a huge change to the way I code. Generally in the pattern
Read more...

Modern Python has Changed How I Code

python programming
I can’t understate the importance of how much the following have changed and improved the way I write Python and have confidence in its correctness: Continuous Integration Black Dataclasses Mypy Type Hints Continuous Integration This isn’t particularly new to me (or the industry), but a good CI workflow that runs tests and linting on every commit pushed to the repo tracker gives confidence that the code is clean to merge into the main branch.
Read more...

Python as a Language is Inescabably Coupled with its Implementation Part 1: LET'S DO DUMB SHIT WITH THE GC

python
There is a convenient but untrue fiction about Python that the language specification is somehow cleanroom and CPython is actually “just an implementation.” This has always been false, and harmful at best. Look at __dict__. Near every Python object has a dictionary that fuels and consumes it. All your dotted getters are mere passthroughs for dot __getitem__ers. Another fun thing is the leaking of implementation details in Bad Ways. Here’s something you can do but should not do, lest I find out where you live and poop in your mailbox:
Read more...

__all__ is a Sacred Space and you Murderous Goblins are all Profaning it

python
Let me spell something out for you trickster-meanies: # HELLO I AM thingy.py __all__ = [X, Y, Z] X = True Y = True Z = True Reasonable, right? >>> from thingy import * Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/scheirer/thingy.py", line 1, in <module> __all__ = [X, Y, Z] NameError: name 'X' is not defined Python is older than my son (who is 3) and yet you abuse it.
Read more...

ZPL-O-Rama Part 5: Postscript

software hardware web programming zpl-o-rama
End product Please disregard the poor camera placement or the labels, it has since been fixed. Thinking Back, It Was All So Simple Now we have the system up and running, let’s talk random obstacles and next steps. This is something of an epilogue to the saga, as it’s a list of small things that accrued while working on the project. Networks are slow and the dual tier service thing is bad, actually I initially chose to run a service on the Nginx server that then called to a service running on the RPi.
Read more...

ZPL-O-Rama Part 4: The Hardware

hardware web programming zpl-o-rama
Hardware The RPi The Raspberry Pi is a (I think) Pi 3 with Wifi I found in the garage with a cheap clear acrylic case. It might have been a RetroPie rig in a prior life? Or one I was “gonna get around to” doing something with and finally did? Then for this project I bought a Raspberry Pi camera and a small acrylic case for it, too. The Printer The printer is a hefty boi, a Zebra something or other.
Read more...

ZPL-O-Rama Part 3: Software

software web programming zpl-o-rama
Running the software Frontend server The frontend has three responsibilities: Display information Perform access control (don’t let strangers on the internet print out jobs) Forward appropriate calls to the backend I’m using Go’s base templates for dynamic content, the Echo framework for the webapp endpoints, and plain old bare bones modern javascripto for the scripting stuff with no polyfills, no build environments, no minifiers, and boy does it feel good.
Read more...

ZPL-O-Rama Part 2: Concepts and Architecture

software hardware web programming zpl-o-rama
Problem Space To automate the process of printing and reporting back a ZPL payload, we need: A way to get the ZPL from the user A way to send the ZPL to a printer A way to take a picture A way to send it back to the user A way to get the ZPL from the user A web service makes sense here. We want an API or a frontend (or both) to send the ZPL along and check its printing status.
Read more...

ZPL-O-Rama Part 1: A personal/work project (Introduction)

software hardware web programming zpl-o-rama
Introduction In my spare time on weekends in between errands and mornings before everyone wakes up, I’ve been working on a little project I’ve been having a lot of fun with: ZPL-O-Rama. The Problem A large part of my employer’s line of business is creating shipping labels, and a large number of those aren’t simply printed images, but printed on very high volume, heavy duty, industrial grade printers using a proprietary language called ZPL.
Read more...

The Shanling Q1 Media Player

hardware music
Introduction A while ago I was bored with the Mechanical Keyboard rabbit hole and started looking into other, equally strange rabbit holes to dive into. At around the same time I hit my iPod Classic’s 160GB limit. I’m not yet ready to hack it up to have bigger storage: I plan to keep it in working “original” condition as it may find a better home in the future with some collector who is better at soldering than I.
Read more...

SFTP is still around and that's OK

programming internet
So it’s 2021 and about the entirety of my job is integrating third party systems with internal ones, which then reach out to other third-party services. A lot of stuff uses SFTP still. In this day and age anything not on HTTP seems barbaric, but SFTP does have its advantages. SFTP is format agnostic This goes for HTTP as well, but you need to correctly set headers, and there’s a constant, incessant push for change for change’s sake.
Read more...

You Don't Need to Make That Temporary File, Dude

python programming
This was initially a blog post I wrote on my employer’s internal system, but it’s interestingly useful and it doesn’t contain any trade secrets so I figure I’ll share. A common pattern that seems obvious when you need to shuttle data around in file form is to use a temporary file against the filesystem using the tempfile module. You very seldom ACTUALLY need to do this. The BytesIO class follows the exact same protocol, the file protocol, so any API that accepts a “file-like object” will accept an in-memory piece of information in addition to a file on disk.
Read more...

Trying out Rectangle

mac
I’ve been using the Rectangle window manager for mac for the last couple of weeks and it’s been the most helpful thing since Mission Control (and setting up a hot corner to activate it). I’ve tried to use full tiling managers before but I’ve found it difficult because 1) Irregularly sized window totally mess up the flow, 2) I am so used to the WIMP paradigm, including moving windows around so I have only been semi-functional with and 3) really weird shortcuts I have to memorize.
Read more...

The 2020s and the Post-Office World

work life
I moved to the Bay Area 6 years ago after stubbornly refusing to for over a decade before because I wanted to be in the middle of the world of software. 2020 made some of that luster wear off. Our office closed at the end of March, 2020, for what was scheduled to be 2 months, which eventually stretched out into over 6 months, until finally we were told to clean off our desks by Thanksgiving as we were permanently remote.
Read more...

Pinebook Pro: The Tinkering Laptop

hardware pinebook
As the parent of an almost three year old, I don’t get much time to myself, and I’ve given up on video games that don’t have playtimes under 15 minutes (that discounts anything with load times or cutscenes). In my spare time I have to find other things to do that are low impact and can be cut into small amounts of time. I’ve taken to watching a lot of retrocomputing stuff on YouTube, which has inspired me to tinker with old software and resource constrained devices.
Read more...

My Dingus Chromebook still works

hardware chromebook
So I bought that dang Chromebook over three years ago at this point and it keeps chugging on. Google has continued to ship OS updates (which I only notice as weird, arbitrary UI changes) and I can still use it to code but its main purpose now is its new life: ChromeOS runs Android apps pretty well, so I put an SD card full of movies on it and play them via VLC for my kid.
Read more...

Five Years in the Bay Area

life
February 8th marks the fifth anniversary of me moving to the Bay Area to work for tech startups. In restrospect it’s been a great experience despite it being the Bay Area. Culture Living in the Inland Empire, I was an hour away from LA and all that culture, but I never bothered doing it. Living 5 miles outside of San Francisco has mean the City is a constant part of my life: restaurants, concerts, museums, lots of things I could have theoretically done more of in SoCal but never bothered to.
Read more...

Own Your Infrastructure

programming hardware work
I’ve been sharecropping on Amazon’s server farms since I moved to the Bay Area 5 years ago. That is, every startup I’ve worked for has utilized AWS (and sometimes GCP or Azure in addition). This started out great for my career because I have not built a server machine from parts out since I was in college and I could use all my developer muscles to be operations person. However, when you’re on-call, you no longer own your uptime.
Read more...

Hello, World

life
I should probably start blogging again.

Python Meetup Talk - 2019-10-09

python work
I gave a short (~10) minute talk on preparing to move to microservices at the Python meetup in San Francisco. The main points: We all start out with a monolith The monolith never fully goes away That’s fine Scope out a new project to make your first microservice Pull out a relatively isolated piece of code in the monolith to make your next microservice

Jumpbear: the Global Warming Bear

programming games games-by-jason
I wrote a handful of different things on my paternity leave, but one of the more interesting ones was this small TIC-80 game where you play a bear. Play Jumpbear: The Global Warming Bear on itch.io

Turn a Chromebook into the ULTIMATE GOLANG/PYTHON DEVELOPER MACHINE

chromebook hardware programming
This is a recycled post from my tumblr weblog Ha ha ha just lying the real title should be Turning a Piece of Shit Chromebook into a Good Enough Development Machine Because You’re Unemployed and Feel Like An Ass Trying to Justify Spending $2000 on a God Damned Macbook so You Wound Up Buying a Chromebook Instead Anyway, I’m unemployed because of reasons and figured there were better things to do with the credit limit on my credit card than spend $2000 on a Macbook, so I bought one of the highest rated Chromebooks at my “willing to pay this much” price point: the Chromebook C100P.
Read more...

What I Like About My New Job

work life
This is a recycled post from my tumblr weblog. I’ve since had three other jobs, but a lot of what I like still rings true 5 years later in 2020. Please note I am contractually prohibited from saying what I don’t like about most of my prior employers so don’t expect any negative posts. I’ve gone from developer at a large software corporation in the suburbs of Southern California to being a developer at a startup in SoMa in San Francisco.
Read more...

Stupid simple API reference for bottle.py web services

bottle.py python
I have a stupid json-only REST API I implemented in bottle.py. This introspects the default app, gives a dumb readout that should act as an adequate reference for discovery: @bottle.route('/') def index(): bottle.response.content_type = 'text/plain' return ("=== API REFERENCE ===\n" + "\n".join(x['rule'] for x in bottle.app().routes))

C++ is not so bad

c++ programming
For as much shit as I like to talk about C++, I sure can get a lot done quite efficiently in it. I read an interview with Bjarne a while back and he said C++’s most important feature was destructors. After thinking about it, yeah, they are pretty awesome and I’ve been using the with statement for the same tightly scoped data lifetime in Python.

I don’t really use OSX anymore

programming mac
I have two desktop systems, side-by-side: an Intel Mac Mini and an Intel 21" iMac. The Mini runs Leopard and the iMac runs Ubuntu Karmic Koala, and I find myself completely satisfied with the Linux desktop, and switch back to OSX as an auxiliary rather than as my primary. I started on Debian back in 1999. I wanted to get into Linux, but both Red Hat and SuSE were a little hard to get going for beginners, and the packages supplied were always a weird grab bag of old and new.
Read more...
1 of 1