Jeffkillian.com initially started as a Geocities website when I was in 6th grade. Over the years, it has slowly evolved into a place where I can practice and become familiar with web development as it progresses. I started out coding with Microsoft Frontpage, then moved to Dreamweaver. Initially, there was very little coding, and it was all WYSIWYG. However, as I learned more, I could make it more interactive.


I incorporate drawings and blog posts to keep those that are interested updated. Through the evolution of the website, I was forced to learn HTML, PHP, CSS, XML, jQuery, javascript, and the handling of MySQL Databases. I've put online some code samples.
CLOSE
Subject:
Message:

SUBMIT
Creating a Python Script to Email Pictures of Ryan Gosling Each Morning
I've a friend who's a big fan of a couple of celebrities (Ryan Gosling, Chris Hemsworth, and Silja Norendal). He'd been throwing out the idea of making a program which would email him a picture of one of them every morning.  He'd asked me how to do it and I did a bit of research and came up with a quick estimate. I knew it would be a python script, and I knew it would have to use a cron job of some sort (I'd never worked with cron jobs but had an interest in them). A cron job is a way you can program a certain file or program to run repeatedly every so often. I'd made something similar (Mara's fake twitter account) a while back, but instead of using cron, I'd just scheduled a task on my computer. The downside of this is that if my computer was not on, the program would not run. You run a cron job on a server (which I have for this website), and by using a cron job I would be able to have it run regardless of whether or not my personal PC was on.

I was sitting at a bar with this friend, and after a few drinks he started asking questions like "how many hours would it take" and "what would you charge per hour". We threw the estimate around and it ended up being $120 to get this done completely. We shook on it right there, with five witnesses. However, I knew this friend was always up for a bet, so I offered him the chance to double or nothing it, meaning I'd either do it for free or he'd pay me $240 to do it. He accepted. We flipped a coin, and, as he often does, he came out on top and I did it for free. To be honest I'm glad that happened, as I would have felt bad accepting $240 for this. Plus, I tend to put a lot more effort into something if I'm doing it for myself rather than doing it for somebody else. Because this was now just on me, I was much more inclined to take a bit of extra time and make sure it's solid. The following is a breakdown of what I did, and how I got it working.

Automatically Sending an Email with a Python Script Using a CronJob:

I broke it down into the following parts
Pull a random image of one of the celebrities:
This one was a bit easy. Initially we were envisioning it would be a random image pulled off of google images every day. However, we settled that we could have 20 images of each person (60 total). Therefore, he'd start seeing repeats on day 61. This made it a lot easier to code, and still has enough variation that he'd not get bored. I found 20 pictures of each celebrity online, and saved them to my server, labelling them accordingly (ryan_1, ryan_2, etc) so that it would be easy to programmatically retrieve the names.
I retrieved the names using the following lines in python:

dayOfYear = datetime.now().timetuple().tm_yday #which day of the year it is:0-364
prefixes = ['silje','ryan','chris'] #all files are named silje_2,ryan_5,chris_1, ranging from 0-19.
prefix=prefixes[dayOfYear%3] #get the day of the year, mod 3. This will give us a number which indicates whether we show silje, ryan, or chris today
picToUse=((dayOfYear)/3)%20 #get which picture we want (0-19). Divide by three because this rounds down if it's not a whole number.
filename=prefix+"_"+str(picToUse)+'.jpg' #create the filename "aka silje_4.jpg"

Send an email:
I had done this before with Mara's twitter program, so it was possible, and not that difficult. However, I ended up using something completely different, as somebody had already done a lot of the hard work (see website link in next section). I was able to create a new gmail account just for this which I use to send the emails.

Attach the image so that it would appear in the body of the email:
My first instinct was to use straight html to just display the image using an tab. However, this resulted in an emailing containing the html tag (instead of the image). A google search lead me to this website, which had the basics for embedding an image in an email with python. I did a copy/paste and modified what I needed to, and had that solved.

Schedule a server to run this python script using a cron job:
This was the most frustrating part (though it shouldn't have been). I decided that I'd send it at 4:30am Monday-Friday.  Even after googling, there were  a couple of syntax issues that prevented me from getting the python script to work. Eventually I got the following to work:
30 2  * * 1-5 /usr/bin/python /path/from/home/to/my/script.py To explain the cron settings in detail, you can check out this helpful page.
30: This will run 30 minutes past every hour it is specified to run.
2: This should only run on hour 2 (2am) of every day specified. Though I wanted the email to send at 4:30 am (after he went to bed but before he woke up), I realized the server exists in a different timezone than I do; 2AM there is 4AM here.
1-5: Run on the first through fifth day of each week (M-F)
I then had to specify the path to the program that should run the script, and the path to the script.

I added in a couple more additions. Mainly, I made a giant list of different possible subjects for the email, and select one at random each day as a little bonus.
That's about it. Each M-F he now gets an email. He's also mentioned it to some others, who requested to get the emails as well. As of now there are 7 or 8 people getting emails.

It was a a fun project, and a neat way to learn about cron jobs. The source python file I created can be found here.
Italy Part 2

It's taken some time but I present the final Italy video, in all its 17 minutes of glory.

Italy

I still have about 170 videos to go through and edit to make the final Italy video, but I'm hoping to get that done in a somewhat timely manner. Until then, have this highlight reel of Abby.

Elevators

I found a link on reddit to a video of a man trapped in an elevator for 41 hours.

In the comments there was a link to a story in the New Yorker about the guy and elevators in general which  ended up being pretty interesting.

From that story, I also learned about a proposed skyscraper described by Frank Lloyd Wright that would have been a mile high.
Space Station Reboost

I like how amused the astronauts are when the space station starts to accelerate away from them.

Word:Nutate

Nutation is a rocking, swaying, or nodding motion in the axis of rotation of a largely axially symmetric object.

You can see it used in action below when Conan brings in an MIT professor to try to spin his wedding ring for as long as possible.

Gravity Visualized

I thought this was a really cool way to visualize many of the aspects of gravity.

Snap-Happy Thanksgiving!
November, 2013

I've been kept busy with work. However, I did get a notice that somebody was trying to inject sql code into this site, which was as good of an excuse as any to pop open Dreamweaver and take a look at preventing this from happening in the future. Although I do validate all of the PHP that gets passed in there was one way in particular that I wasn't aware existed. They were able to run 1000000 iterations of 100000 iterations of a request for the current date. There was no point to it, except to fool around and see what they could get away with. After realizing this was going on/tracking down where it was coming from, I fixed the issue and all is well.

I've been sending a lot of snapchats recently, and I'm hoping to create a way where I can upload my screenshots from my phone into new blog posts without much hassle. If you start seeing snapchats here that means it's working

Future posts that I want to write about but will most likely never get the time:
Running a marathon.
Creating a scrolling display from an arduino

Angular Momentum

"None of this is intuitive"

Want more? Check the blog archives
Untitled Document