February 12, 2018

How States Voted in 2016 Compared to Their Contribution to the US GDP

The other day, I got into a spat with someone on Facebook who swore up and down that the American populace votes in accordance with their economic interest, but when I asked for proof, they pointed to state-by-state growth rates. They've since blocked me, but I was able to generate a plot to prove they do not.

January 15, 2018

Why Democrats will win in 2018

There's a latent reason why 2018 (or any other midterm election ending in an 8) is more likely to result in changes in Congress than any other. The United States Census happens every 10 years -- here's the 2010 data and the future home of the 2020 data. The results from these surveys are used by states to redraw their Congressional districts to their liking. Hence, whichever party controls a given state the year of the census bears a strong correlation to the party of their house delegation for the next few election cycles. But this correlation tapers off as you get closer to the next census, because people will move around, but the numbers are unknown until the next census. I cannot figure out why none of the media outlets highlights this point.

July 14, 2017

Where exactly is Javier

On my way to LA, I received a text from a friend, that they wanted to meet for lunch at Toscana in Century City. Not being familiar with the Los Angeles area, I ended up writing a python script that would pop up the area around the location in OSM. I wanted a higher quality user-interface while keeping the script console-capable, so I could run it remotely. As the only terminal-based library distributed with python is Curses, I looked into using this and came up with this:

February 10, 2017

How to Upgrade the System Ruby on Macintosh

Apple releases software updates pretty regularly. It usually ships older versions of software. I need to run the latest version of ruby. I go through the following steps to upgrade it to the latest version:

  1. Install rbenv by checking it out using git clone https://github.com/rbenv/rbenv.git ~/.rbenv
  2. Append $HOME/.rbenv/bin to your path
  3. Refresh your shell session
  4. Remove the preexisting ruby versions -- yes, all of them -- from ~/.rbenv/versions, rm -Rf ~/.rbenv/versions/*
  5. Install the latest ruby version to ~/.rbenv/versions/
  6. Overwrite the files in /usr with symlinks pointing to ~/.rbenv/versions/<latest-ruby-version> -- find .rbenv/versions/<latest-ruby-version>/ -depth 1 -exec ln -sf {} /usr \;
  7. set the default ruby version globally to your newly rbenv-installed version. And you're now done... Have fun and make rubies

November 11, 2016

How to Import your Lyft Receipts into Excel

The Python code above goes into your IMAP-over-SSL inbox, gets Lyft receipts, parses them and puts out a report that can then be imported into Excel, R, or any other program that can read comma-separated values. I use this to classify my lyft usage as business or personal -- I can claim the business expense as part of my tax refund.

October 18, 2016

How to Build the Perfect System on a USB Key

I was travelling earlier today and had a third of the day as downtime. But instead of the usual, twiddling of thumbs, chatting my neighbour up, etc. I focused inward. I've been wanting to upgrade my USB key to a newer version, and in doing so, automate the process. So I got started, I found the NetBSD sources I needed (I know I wanted to use OpenBSD, but that's for a future piece). The advantage of NetBSD is that its build system supports cross-compilation -- important for build speed -- and the base system takes less than 1 gig -- important for a flash drive. I set up a speedy ec2 instance for the build, using the Ubuntu trusty image and put the below script into /etc/rc.local, which checks out the latest NetBSD 7-STABLE source code, builds the amd64 port's live image, which needs to be put onto a USB key. Future enhancements are going to be to autoinstall the packages that we want on the system, but for now... if you should want a key of your own and aren't comfortable with this sort of hackery, you can send me $25 to cover the acquisition cost and shipping. E-mail your address and the packages you want installed to me and, a few weeks later, the stork will deliver you a live, USB-based NetBSD installation. Stick it in your machine, tell the BIOS to boot from it and you'll be set for life. I'll add the script to automatically set up the ec2 instance for true one click builds, if I get enough inquiries.

Finally, if you should have any suggestions, feel free to leave them in the comments.

October 1, 2016

How to See Your Downvoted Comments on Reddit

The above python script lets you see a report of a comment's permalink and its score if the score is below 1. A demo from a random reddit account follows:

% python ./bin/redditScores.py -u meh613
https://www.reddit.com/r/asktrp/comments/53w05p/signs_a_woman_is_cheating/: 0
https://www.reddit.com/r/asktrp/comments/530p3r/how_do_i_play_this/: 0
https://www.reddit.com/r/dating_advice/comments/52ksoa/ladies_on_a_dating_site_how_do_you_tell_the/: -1
https://www.reddit.com/r/socialskills/comments/51fsak/my_social_life_is_great_but_my_love_life_is/: -3

September 1, 2016

How to write a Task Timer in Java

I just wrote myself a simple Java alarm clock. Takes a parameter denoting the number of hours and displays an error alert (below) when the time has been reached. This is to prevent my spending too much time going down rabbit holes. I'm releasing this in the public domain such that someone might find it useful.