This adds integers using bit-wise operations. I tried to provide a lot of print statements so that you could see what’s going on with each step.
Monthly Archives: July 2018
Jenk’s Natural Breaks Optimization
A co-worker was interested in segmenting a list of data points, and I went down a rabbit hole on one dimensional segmentation. I found an article on the Jenk’s natural breaks optimization on Wikipedia. I found another article that had some examples. This is used to bin data points so that clusters are always binned together. There is an iterative method that takes unordered data, but this implementation just sorts the data before binning.
Writing an Interpreter in Python with PLY
For a while I’ve wanted to work on a typed spreadsheet application. This weekend I started working on an interpreter for it using David Beazley’s PLY. So far, this is able to store data and type information in cells in a data store, and perform operations using numbers or references to cells. It also supports limited type checking.
Use Alias in Bash Script
A few weeks ago, I had trouble accessing aliases in bash scripts. It turns out that aliases are not expanded in scripts, only when the shell i interactive. However, we can get around this by using shopt
to expand_aliases
at the top o our script.
#!/bin/bash shopt -s expand_aliases ...