November 07, 2016

Reddit Data Mining with Python: Are Canadians Really Sorry?

Internationally, Canadians have a reputation for being a sorry lot. In fact, we've even passed a law called "The Apology Act" stating that saying "sorry" does not count as an admission of guilt. A very sensible law indeed.

Is this stereotype true?

We're going to test it in this tutorial, by counting the frequency of apologies in a number of Canadian subreddits. We will do this using python, and a module called praw which provides an interface to the Reddit API.

Then we will generalize the python program to allow us to search any subreddit for any set of words using command line arguments.

The final program can be found here, and an intro to python can be found here.

Setup


The first step is to make sure you have python 3 or higher, and the praw module. If you have python 3, praw can be installed simply by running the following command your shell or command prompt:

$>python -m pip install praw

November 05, 2016

Turbo Press - The Aeropress Pour Over

Most of the projects on this site are created with a cup of coffee immediately in reach, and my favourite way to make coffee is with an Aeropress. This device is sort of a hybrid between French Press, and Espresso. It was also created by Aerobie, inventor of the world famous SuperDisc Frisbee!

There are already hundreds of recipes online, many with a cult like following. Checkout some of the winning recipes from the World Aeropress Competitions, featuring advanced techniques like "the turbulent wiggle". 

After hundreds of experiments of my own, I've abandoned the inverted method for what I call the Turbo Press. This is my favourite way to extract a large cup of coffee with a full bold flavour. 

The Turbo Press

  1. Get a medium to large cup, with a volume of roughly 1.5 Aeropress chambers. 

  2. Fire up the kettle, and freshly grind your beans for a paper filter. In step 8, you should have to push down with the force of an enraged child. If it's too easy, grind finer.

  3. Wet a paper filter and place it in the Aeropress over your cup. Fill with one heaping Aeropress scoop, and  turbulently wiggle your Aeropress so the grinds are flat.

  4. Heaping scoop, fine-ish grind.

November 02, 2016

Simple Python Twitter Bot

Twitter Bots


Twitter has some amazing bot personalities; from celebrity impersonators, to genuinely useful automated announcements. It is also probably the first place anyone was exposed to bots and interacted with them. Some of my favourites are BIGBEN and CaptainMarkov. It is also very easy to make a simple bot, especially if you're familiar with python.

In this post, I'm going to walk you through the creation of Mirror_Bot_1000. Mirror_bot_1000 reads tweets when its username is mentioned, and then makes its own tweet with the mirror image.

It's a great example for the simple interactions with Twitter's API because it requires you to read a message, post a message, and keep track of where you left off. If you want to make your bot more complicated, you just have to modify the decision-making behind the tweets.

The entirety of the code in this example can be found on github here. An intro to python can be found here.

Account Setup


October 30, 2016

Astrophotography Manual Barn Door Tracker

Motivation

After seeing some beautiful photos of the milky way, I wanted to step up my astrophotography game a little bit. In astrophotography, you are limited to shutter speed = 500 / (focal length) before your stars get blurry from the earth's rotation. To get better photos of the night sky, you can use what is called a tracker which allows you to take much longer exposures.

They are also quite expensive, and not particularly complicated. So I decided to try making one myself. The goal was to make it simple, and cheap. In the end, the total was less than $50, and the results have been quite successful.

It was so simple to build in fact, you probably don't even need a guide once you understand the key concepts. So I'll start with the basics of how and why it works, followed by a breakdown of how I built it.

Here is the final product:



and some results:


2.5 minute Milky Way exposure

October 29, 2016

Vice City: Python Automated Sports Betting

Automated Sports Betting


Everyone knows gambling is a great way to make money (/s). I myself formed this conclusion after hearing bookies will sometimes pay out before an event even happens, which planted a betting strategy in my mind that required a bot. This very successfully and slowly lost me my $50 investment, but I had a lot of fun making it, so I thought I would share the project.

If you use this guide, please don't be stupid. Basically nobody comes out on top in the sports betting world. It's not going to be you! So maybe have some fun testing out theories, or let a robot lose money on your favourite sports team, but be prepared to lose any money you deposit in your Pinnacle account.

This is my first tutorial, so if you use this project I'd love to hear how it goes. If you manage to make a lot of money, a donation to Wikipedia would be appreciated.

Now let's get down to the coding. Taking a look at the official API documentation  at this point would be wise as well. All the source code referenced can be found at my github here, along with any future bug fixes. An intro to python can be found here.

In my bot, there are three essential stages.

1. Gather information. (Balance, Odds)
2. Check Criteria. (Find desirable bets)
3. Place bet.

June 15, 2015

April 24, 2013

WRT54GL TomatoUSB Overlock Private Internet Access VPN

I got a VPN service through "Private Internet Access" and wanted to setup a router to connect to this. I did a lot of googling for similar problems, so I thought I'd make a quick post with the relevant keywords to help anyone else in the world trying this.

TomatoUSB firmware lets you use VPN for Private Internet Access, whereas the ddwrt "MEGA" can't be used due to insufficient memory on the router. To update the firmware, first install regular Tomato through the update firmware option in the linksys interface. Then through the Tomato firmware interface, go to Administration -> Upgrade and upgrade to this firmware (v2.4 VPN).

Follow the instructions from PIA for creating VPN tunnel, and check your speed.

I was getting really poor speeds when the VPN was connected, which I decided after some troubleshooting was due to the processor in the router being unable to keep up (determined through online consensus). I did some more reading, and apparently the WRT54GL can be overclocked with virtually no risk.

This is really easy to do. In the Tomato interface, go to Tools -> System and enter the following text:

nvram set clkfreq=250,125
nvram commit
reboot nvram

and click "Execute".

Once the router has rebooted, you can confirm the overclock was successful using the following command:

nvram show | egrep "clkfreq|debug_clkfix"

If this says "250,125" then you're off to the races. This roughly doubled my connection speed, but only because the processor in the router was throttling performance. If you get the same or similar connection speeds with and without VPN, this will do nothing for you!

Also, if you break things it's your own dumb fault! Good luck!

November 18, 2009

Stars and Links

This is an archived blog post from 2009, and was possibly my first attempt at astrophotography. 

On Nov. 17th there was a really cool meteor shower, so me and a bunch of friends woke up at 3 am to watch them. To get better viewing we drove out of Kingston, hoping to find a place that was dark and comfortable. At our first possible stop, the dark field beside us turned out to be very grassy, and there was even a fallen part of the fence to let us in. As I was the leader, and the field was ideal, It made me look like a pretty good random spot finder, but I confess it was really just some awesome coincidences!

I brought my camera and ran it took pictures constantly with a 15s shutter speed, sequence mode, and a bunch of elastics to hold the button down. It didn't turn out all that well, but I did catch a picture of a shooting star! It's the faint white streak... Much cooler in RL.



I've also found some rather amusing internet tidbits recently, and I've decided to share them:

http://youmakemetouchyourhandsforstupidreasons.ytmnd.com/

http://probablybadnews.com/


-Ben