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.

July 14, 2016

How to Get Reddit's Karma Metadata

Karma refers to scoring comments on Reddit and the service does not sort the scores by date, just the comments themselves. The script above runs through and grabs all of your comments, keeps their scores and shows those comments whose scores have changed in the past 24 hours (86400 seconds). I do hope you find this useful and I look forward to your suggestions as to how to enhance it further.

June 28, 2016

How to Track Your Spending

In the last hour, I wrote a script to mine my email, collect the messages from paypal, lyft, and the Google Play Store and report the total spend. The script is pasted below, followed by a sample run:
% python3.5 receipts.py -p [password]
$ 151.73
Next step is to support that other large payment processor on the Internet, along with any other suggestions users have.