The thread formerly known as "Weekend Coding"


Yahoo Pipes was laughable, but at least it let me pipe an rss feed through grep. No output rss for ifttt.


I think this sort of thing could be a decent use case for a raspberry pi if you’re a programmer.

Little dinky stuff that doesn’t really merit having a server to itself. Cron jobs. Checking for new drivers. Twitter bots. Send yourself notifications.

If you have a spare digital ocean droplet sitting around, that’s probably easier and more robust, but how many pis end up just collecting dust?


So I noticed there was a new nvidia driver yesterday, but the account never tweeted. I went to check on it, and running the script manually totally worked. Somehow the crontab was blank! WTF. I definitely set it.

Also, I just noticed a bug I fixed was unfixed. It’s like the last five minutes of work I did on this got undone. Welp, I redid them.


The last time I had a crontab entry missing, it was because I stupidly edited it while I was sudo’d to a different user.

So, it still worked, but it ran from a different user, surprising and angering me.


I checked that. Also, even if it was a different user, this would still work. It doesn’t matter what user executes a python script that requires no special local permissions. Might be related to that Linode outage.


The bot worked!


He am play gods:


Some people buy Zachtronics games and some people make their own.


I had a problem. I solved it with regex. I now have two problems.


This is amazingly impressive… but why?

Is this some kind of senior thesis style academic nonsense? Why on earth did he need a regex that matches every possible permutation of addition…

Now that I think about it, I wonder how it handles the Fibonacci sequence. Aaaaand it breaks the second you add the fourth number in the series.


I consider this to be a coding exercise akin to trying to program in Brainfuck or entering the International Obfuscated C Code Contest.


Fun fact, my capstone for my CS degree was a glorified extension of Brainfuck. I mean, I wrote it from scratch as all of us were required to do but I basically made a language that could increment and decrement the pointer. Then wrote a few commonly used methods like tostring and print and push and pop and that was enough to call a capstone.


Looks like I need to write a python script to delete everything but my top 1000 flickr photos.

Beginning January 8, 2019, Free accounts will be limited to 1,000 photos and videos. If you need unlimited storage, you’ll need to upgrade to Flickr Pro.

**Free members with more than 1,000 photos or videos uploaded to Flickr will no longer be able to upload new content after Tuesday, January 8, 2019 unless they upgrade to Pro. After February 5, 2019, free accounts that contain over 1,000 photos or videos will have content deleted – starting from oldest to newest date uploaded – to meet the new limit. Members may always choose to download content over the limit at any time prior to these date


I have Flickr Pro and this is 100% good news all around.


“Things I learned after X years of python”, 2018 edition: bare raise.

If no expressions are present, raise re-raises the last exception that was active in the current scope.


I did not know this.


Bare except doesn’t seem as preposterous with that in play! Consider something like this:

    log('Your shit is fucked up. Shooting/slicing commencing')


Yeah, I think that’s the general use case. When you don’t want to prevent the exception from being raised, you just want to do something before you let go.


Like tear down a test environment (which may include stopping test equipment like, say, a Bluetooth sniffer), mark a test run with an “ERROR” outcome, and upload the result to a server.


A digital camera will write all kinds of handy metadata to every photo. This includes things like shutter speed, aperture, date and time the photo was taken, make and model of the camera, the lens, and a shitton more useful info. Even GPS data goes in there, so you know where the photo was taken. This info actually does get used in apps like Lightroom. It is super duper useful for organizing and searching photos. The date is really the most useful.

So you go out and get yourself a film camera. Then you scan in all the negatives. No data. Now what? You gotta type all that shit in, that’s what. It sucks ass.

There’s a really basic iOS app called Film Rolls.

It’s just a simple database. It lets you record this meta data in the field. You just have to develop the habit of opening the app and adding a frame every time you take a photo. You still have to enter things manually, but it’s very easy. Even uses your phone to get the GPS coordinates.

Ok, so now I want to get this meta data from the app and apply it to the actual scanned jpgs. They do not provide a tool for this. What they do provide is the ability to use iTunes to extra an xml file with the data in it. That’s it. To make matters worse, the data is in a format that is very very far away from the Exif spec.

By the way, the Exif spec is very archaic. For example, you can’t store GPS coordinates as a pair of signed floats. You have to store them as two unsigned sets of degrees minutes and seconds, plus N/S E/W indicators for hemisphere. For example.

The Empire State Building is at 40.748428399999995, -73.98565461987332.

In Exif you have to specify in four separate fields

((40, 1), (44 , 1), (543402, 10000))
((73,1), (59, 1), (83574, 10000))

Oh yeah, did I mention you can’t put any decimals or floats. All those tuples are (numerator, denominator).

(40, 1) = 40
(83574, 10000) = 8.3574

Anyway, I threw together a hasty Python CLI program to take the XML file and apply it as exif to all the jpgs in a specified directory.

I didn’t put the effort in to make the code good. I just made it fast and made it work. I think I even lazily hardcoded the location of the xml file, and didn’t undo that.