February 6, 2016

How to Set your Desktop Background to NASAs APOD in Python

The script above sets the Macintosh OS X desktop background picture to NASA's latest picture of the day as sourced from (you guessed it) units.

February 4, 2016

How (not) to Migrate Servers

Sometime yesterday afternoon, I started getting a reports of 404s on the units server. I couldn't look into this till this morning, but it turns out that the host it was on decided to commit ritual seppuku and wipe itself out. Fortunately, the code is backed up, but the config.py file is listed in .gitignore, which is where all my api keys were. I've trimmed a few services that weren't working and probably never will. Most of it is now up and running on a new box. If anything's broken, please let me know.

January 31, 2016

How to Track Expenses

My bank gives me email on every transaction. Because I use nmh for archiving mail, I can parse the messages to determine how much I've spent. The script above collects the reports from the mh folder I use for receipts and sums the amounts up, finally spitting out a locale-aware total amount in the inbox. And in 41 lines of python. Excellent... Future improvements include ripping out the access to messages and just fetching the amounts directly through Yodlee or similar. Watch this space.

How to hear the Web

In addition to slicing and dicing Facebook into JSON, units now generates mp3s from text. So, go on, make the web sing!

January 30, 2016

How to Retrieve Files from Dropbox Using Units

I just added a feature to units by which one can retrieve Dropbox files and display them on screen. Going back to the last entry announcing support for it, just give a path to a file and it will be retrieved.

January 29, 2016

How to Access Cloud Services as JSON

Today, there was a commit to units that I'm especially proud of; one that adds dropbox support. Now, in and of itself, this isn't very interesting, but I would like to make units the premiere web service for putting together cloud solutions across platforms -- Box.Net support is coming next week, followed by Google Drive and Microsoft OneDrive.

January 24, 2016

How to Convert Blog feeds to iCal

Units can turn any RSS/ATOM feed into a calendar that one can subscribe to using a calendar. Why would one want this? Oftentimes, ( find people publish their schedules as RSS and I need to use them in my mobile's calendar application and now I can and so can you. Free data from silos. It's been written once, now use it anywhere.

January 18, 2016

How to Scrape r/dailyprogrammer

I greatly enjoy brainteasers. Thus, I follow the dailyprogrammer subreddit and do most of their challenges. The task is to mine and categorize the challenges. Formatting according to the spec is an exercise left to the reader, this will just get the posts into groups that isolate the necessary parts. The code above is a function that accomplishes the narrow task of isolating the date, the level, and the title of the challenge from the subreddit's rss feed utilising feedparser.

January 16, 2016

How to Strip Attachments from Email

The perl code above strips attachments and other things that mailers (and people) often add to email without thinking. Future ways I'd like to enhance this are to strip HTML if there's no plaintext part. It integrates well with procmail, my prefered mail filtering solution and nmh. Enjoy and please leave further suggestions as comments.

January 5, 2016

How to View Tor Service Hostnames on a Machine

My favourite way to get around ISPs not letting me run my own services for myself is to use tor. However, tor assigns me a random hostname, which for the world of me, I cannot remember. Therefore, I've written a script to tell me which services are available on a certain server and their onion hosts. It is available below:

This is a bash script. Bash has a set of builtin commands, among them is getopts, which is used to GET OPTionS; in other words, parse arguments. Tor runs chrooted on this server where my normal user doesn't have access, so I must use sudo to change to the tor user (alternatively, one could setuid the script to the tor user). If the 'h' argument is given, the second argument is the directory under the tor directory which is checked for the hostname, and echoed to standard output. Without the 'h' argument, a list of hosts is discerned from the control directory. The awk script parses the last field of the path, after skipping the first line, which is the control directory itself. Sample run below:

December 19, 2015

How to Generate QR Code Images for Words

I just added an endpoint to generate a QR code for the data parameter and put it on imgUR. I've also put the source code on bitbucket. Enjoy!