dinosaurs eat everybody

for all your Dave Schwantes related needs

Does Anyone Still Use RSS?

Since the death of Google Reader I feel like I’ve seen people use RSS less and less, but a quick informal survey of friends showed that some people still use it for some things so maybe this blog should have a feed, right?.

I was interested in how hard it would be to add RSS to this weird Jekyll/Sinatra hybrid I have running and had a few minutes tonight so I decided to give it a shot. It turned out to not be bad. I just followed this quick tutoral and found a nice template here and 90% of the work was done (basically I just add another template to my Jekyll project and a few lines in my config and an xml file gets generated along with everything else when I run jekyll build.

The only custom part was adding a few lines to my Jekyll handler method in my main Sinatra app to suppress the layout template and render the RSS file as XML:

if file_path.include? "rss.xml"
  content_type 'text/xml'
  erb contents, :layout => false
else 
  erb contents
end

Now you can subscribe to this blog via RSS is you so desire!

Thing A Week 4 - Bird Watcher

This week might count as a partial failure plus I’m getting the post up pretty late, so that’s probably not good either.

Once again I tackled a project for the wedding. I want to build a system that listens to Twitter and Instagram for photos that are tagged #daveandeileen then pulls them in and displays them somewhere at the wedding. This week I decided to finish up the Twitter listener.

This listener is basically just a small Sinatra app that uses TweetStream to listen for tagged tweets and then if it matches the criteria (has image and is properly tagged) it stores info about the tweet into a database. This same database will eventually hold Instagram (this was the whole reason I signed up for Instragram) data and then I’ll need to write a nice front end that pulls the photo data out and displays the pictures in some nice way.

I call this week a partial failure because I got the app working locally, but ran into some trouble getting it deployed properly. I am not a great sys admin, but I’m learning a few things. This is also the first time I’ve set up a database on my VPS. I’ve really been spoiled by always working with databases through a nice visual interface so doing some Postgres work while sshed into my server felt like pulling teeth. I was just running into some issues pretty late on Sunday night so I ended up admitting defeat and went to bed. You can check out the code for this project on Github.

This next week (the week we are currently experiencing right now) is pretty busy. We’re trying to finish up a bunch of other big wedding things (stuff that doesn’t involve coding) and my parents are in town this weekend, so I know I’m going to be limited for “thing a week” time. I would like to use this week to finish off the deployment for Bird Watcher. I feel bad about letting a project spread over two weeks but I think it’s best for my schedule and this project.

Thing A Week 3 - Save The Date Comic

Sorry, but this week you can’t see the full final product of my Thing A Week. I used this last week to write and draw a comic that we might use as part of our Save The Date cards (if you didn’t know already, I’m getting married soon) so I want to keep the final comic unpublished until we send those out.

This Thing A Week was pretty straight forward: write and draw a comic. This is something I’ve done many times before. The main challenge was getting it good enough to print on cards and mail to friends and family. It just feels like because this is for the wedding, I should set the bar heigher than I would for a web comic. I’m always worried about my art not being good enough, so this comic was a bit stressful at times.

The layout wasn’t too complicated but some of the poses and body positions were just a little odd for me and it took a bit to get them right. Like most comics I spent some time planning out the pannels and doing some quick sketches of a few poses before starting on the actual comic. I also decided to work at a larger scale, using 8.5 x 14 paper. This is always nice because I feel like I can work on details a lot better at this size.

I suppose there’s not much more to say about this project. I’m a bit torn on what to work on next week, it’s currently between writing a song that uses my new bass pedal, working on a programming project for the wedding, or starting to work on a new idea for Big CoreUs.

Thing A Week 2 - Bass Overdrive Pedal

Success!

This week I built a bass overdrive pedal. I had received a kit for this pedal for Xmas (as well as an arm for holding circuit boards while soldering, which may be the nerdiest gift I’ve ever received) and I was excited to finally have time to work on it. Last year I built a Tube Screamer overdrive clone from a kit, so I’ve had a little experience building pedals from kits already.

The choice of a bass overdrive pedal was motivated a bit by listening to some newer Ben Folds. He has some great songs on his new record that are really carried by piano and gruff sounding bass. Now that I have this new pedal, one of my upcoming Thing A Week things will hopefully be a song written in that style.

This build was a bit more complicated than the last pedal I built, but I didn’t have any major problems with it. It took a while to solder all the little components onto the board but I actually found it to be very relaxing. It takes a lot of focus but it isn’t really mentally taxing. Soldering was a nice way to unwind after work this week. The biggest addition I made to this build was the choice to paint the enclosure. I had never painted metal before so I had to learn a bit about that (it’s not that complicated). It really just involved sanding the enclosure, priming it, then adding a few layers of indoor/outdoor spray paint. I picked a nice ugly yellow, which ended up looking really cool with the black nobs. I had originally planned to label the nobs and draw some sort of design, but I just didn’t find anything I like so I kept it totally clean, which ended up being a nice look.

The tone of the pedal itself it pretty cool. It has treble and bass levels as well as a blend control which lets you blend the drive and clean tones nicely. I did a quick recording so you can hear what it sounds like. I started with a clean bass sound for comparison then turned on the overdrive.

It felt good to finish a Thing A Week project, I was a little worried about the viability of this project after falling short the first week. Next week I will probably try to do something artistic, maybe comic related.

Thing A Week 1 - Professor Rex VonScience Saves The World (an HTML5/JavaScript game)

So, the first Thing A Week project was kind of a failure.

My goal was to build my first HTML5/JavaScript based game. I started out by picking a JS game framework suggested by my buddy Bryan. I ended up using Crafty and getting started with this tutorial. It was really good and by the end I had a top down adventure game thing that looked very Zelda-like.

From there I sat down and did a bit of planning to figure out what sort of game I wanted to make. This is where I may have gotten a bit ambitious. I decided to make a top down adventure game (similar to the one in the tutorial) about a T-rex/scientist who must fight off mammals and time travelers to gather parts to build a spaceship and blow up the asteroid that will cause the mass extinction of all dinosaurs. I planned out 4 stages, each with new mobs and planned to hand draw all the sprite fames.

Perhaps I was in a bit over my head, having never built a game before.

In the end, I was able to create a rather buggy game where you can move around a dark green square in a forest (made of light green squares) and go after gray squares (the parts!) while avoiding some brown squares (probably a rodent of some kind?). I wouldn’t really call it a game, but I suppose I know a lot more about game building with JavaScript than I did last week. I did really like the idea for the game, especially the name “Professor Rex VonScience” and I got to draw several dinosaurs wearing a lab coat and a bow tie, so it wasn’t a total loss.

If you’d like to “play” the “game” you can take a look here: Professor Rex VonScience Saves The World and the code is available on my Github.

So, now that I’ve already had an unsuccessful Thing A Week week, I need to figure out how to deal with failure in the project. I’d like to keep working on this game but I’d also like to avoid sticking with the same project several weeks in a row, particularly this early. Perhaps in an upcoming week I’ll pick a subset of this game as my project and work from there now that I have a better idea about the kind of work it takes to make a game. I’m also not sure if I’m ready to set next week’s project yet. I’m leaning towards building a bass distortion pedal, though.

Thing A Week

I like New Years resolutions. Sure they’re kind of cheesy and I always tend to make similar resolutions each year (run more, get better at guitar, write more music, update Mount Saint Awesome more regularly, etc.) but I still enjoy the excuse to take stock and think about things I want to be doing.

A lot of what I want to be doing is making things and in order to stay focused on that I’m going to steal an idea from the brilliant Jonathan Coulton (of Code Monkey fame!) and try to do A Thing A Week. While Jonathan did this entirely with songs I’m going to branch out to include almost anything that I can create within the 1 week time frame. This might involve building a guitar pedal or brewing a beer or making some art or creating a small web app or piece of software or even… writing and recording a song. I have a bit of experience with this schedule from the early days of Mount Saint Awesome. Back when I first started the comic I was VERY dedicated to posting a comic every Monday and I stuck with that schedule for over a year. It really helped me improve as a cartoonist. Here is the first comic I posted and here is one of the later plot based comic I posted (this was less than 1 year of comics, but still a noticeable difference.)

The first thing I’m going to try is building an HTML5/JavaScript game. I’ve been doing web development for a long time now but I’ve never built a game and it seems like a good excuse to play with some new HTML5 stuff, plus I’d really like to get more serious about JavaScript. If all goes to plan I will have a game to show off here next Monday!

Chess With a Child

Lately I’ve been getting more and more into playing chess. I had played a bit with my dad when I was a little kid but hadn’t really thought about it much since. Then a year or so ago I started playing online chess with some friends at work. I was REALLY bad and lost constantly. Since then I’ve been studying and playing a lot more and I think I’m getting better and I’ve really been enjoying the process. If you’re interested in playing me, I play as dschwantes on chess.com.

But this post isn’t really about me learning chess. It’s more about a game I played a few weeks ago.

I had convinced Eileen to go play chess in a coffee shop with me one Sunday evening. We were just going to play a very friendly, open game because she doesn’t really play and last time we played she got really mad that I beat her (and refused to play chess with me ever again). We were sitting at a table next to a family with two young children, maybe 4 and 6 years old and as we started our game, the older child kept craning his head over to our table. Eventually his willpower failed him and he just came straight over and sat next to Eileen, asked what she was doing, and started suggesting moves.

His parents came over to apologize (and retrieve their stray child) and the father explained that he had started to introduce his son to chess a little while ago. Eileen and I were just having a friendly game so we ended up inviting the kid to play “on Eileen’s team” and his parents helped them pick moves too. It was a completely casual game with everybody helping to look for the best moves for both sides and none of us (adults included) were particularly strong players.

The kid couldn’t sit still for 30 seconds and spent the whole game wiggling around and leaning on Eileen and looking at the board from different angles but the game kept his attention, which was really impressive. It wasn’t the game I had planned on playing but I think we all had a lot of fun. It felt good to help entertain a kid with something productive and it was just a genuinely enjoyable encounter with some random, nice strangers in a coffee shop.

In My Head, Behind The Music

I just finished writing and recording a fun keyboard-heavy powerpop song called In My Head and in an act of self indulgence I’d like spend a blog post going over some of what into the song. (Pro tip: You can scroll down and start playing the song while you read the rest of this!)

With this song I wanted to just write something straightforward and not get hung up on trying to write anything super technical. I ended up with a simple intro - verse - chorus - verse -chorus - bridge - chorus structure and I tried my best to not overthink the lyrics (more on those later). By not getting bogged down worrying if my basics were interesting enough I was able to get a solid chord progression and structure down and then build off of it.

recording

The song started with just guitar recorded over a click track. Rather than trying to set up and mic an amp I ran my guitar through my homemade overdrive pedal and then a clean amp model in Garageband. Once I had my basic structure down I went in to write drum parts. I wrote the drum part by hand placing events on the piano roll set to a drumset sound. I’m sure there are better ways to do this, but it worked for this song and I like the freedom I get by beind able to hand pick every hit in a beat.

I stressed out about my bass tone a bit during this recording session. Usually I need to run my bass through an amp and mic it to get anything remotely usable, but I wanted to get some parts down imediately and plugging in wasn’t an option at 11pm. I plugged directly into my recording interface (an M-Audio Fast Track Pro) and then just put one of the fuzzy Garageband bass effects on the tracks and the sound was actually ok so I ended up keeping it.

From there it was time to play with keyboards! The paino parts are all pretty simple, mainly just to add some depth and tone to the song. I had a lot of fun writing some cool little counter-melodies on the synth. I’ve always had a soft spot for bands like Zolf the Rock and Roll Destoyer and Motion City Soundtrack so I really enjoyed being able to write some really poppy synth driven stuff.

lyrics

And now lyrics. Like I said, this song was an exercise in not overthinking things. I just sort of wrote the first things that came to mind so this song ended up overtly being a generic pop sound with vauge romantic sentements. That said, the ideas for the lyrics came from watching Doctor Horrible’s Sing-a-long Blog and from spending a weekend home alone when Eileen was out of town.

chorus

Well I can’t get you out of my head
I dream about you when I go to bed
I can’t get you off of my mind
And I don’t mind
I can’t get you out of my head
I keep replaying every word you said
I’d like to give you some of my time
If you don’t mind

The deep insight here is that I had a bunch of songs from Doctor Horrible stuck in my head for a long time. They’re really good! You should seriously watch it. That’s honestly the extent of the depth of that chorus, I just kind of took the theme of having something stuck in your head and presented it in a general enough way to make for a good, hopefully catchy, pop chorus.

verse 1

Well I’ve been spending too much time
Home alone on my couch drinking too much wine
Watching TV and waiting for
You to come here and walk right through my door

verse 2

Now I don’t eat and I barely sleep
I don’t know how much longer I can keep
Walking through these empty rooms
Before I pick up my phone and call you

I wrote a lot of the music for this song over a weekend when Eileen was out of town so when I was looking for lyrical ideas for the verse I decided to just use the theme of being home alone and again present it in a vague way to make it sound like semi-romantic pop. I did take some liberties with the concepts. For example, there was no wine consumed that weekend but it’s harder to find good words that rhyme with whiskey. I did watch copious amounts of TV, mostly The Guild, and I don’t really do a good job of feeding myself or going to bed at a reasonable time when I am left home alone, so there is some truth to these words. I wasn’t as happy with the vocals I got when recording the verses. I just couldn’t seem to get a tone I was totally happy with, but I don’t think it’s too distracting.

the song

I’m really proud of how this song turned out. I had a lot of fun with the style and its always rewarding to hear a completed project that has some complextiy to it. If you don’t want to travel all the way over to Soundcloud to hear the song, you can listen to it RIGHT HERE!

Darwinning, My Ruby Gem for Genetic Algorithms

Well, this writeup is a bit late. I wanted to write about Darwinning right after I launched it but here we are.

So, what is Darwinning?

Darwinning is a Ruby Gem built to help people write genetic algorithms. I got into genetic algorithms while taking a machine learning course during my masters and I’ve had a casual interest in them ever since. I even wrote a comic about them! I have also been enjoying Ruby lately, so I wanted to learn how to build a Gem. This project was started to satisfy both of those interests.

I also played with the Ruby unit testing framework, RSpec, for the first time with this project. The test coverage for Darwinning isn’t great, but at least it’s a start.

So, how do I use Darwinning?

Darwinning is totally available via RubyGems so you can install it the same way you would install almost any Gem:

gem install darwinning

Once it’s installed you can make use of the Population, Organism, and Gene classes to build your own genetic algorithm based programs.

Here’s an dumb example of how you might use Darwinning to solve a pointless problem:

Let’s say for some reason you need a set of 3 number that add up to 15. This is a strange problem to have, but let’s solve it anyway.

class Triple < Darwinning::Organism

  @name = "Triple"
  @genes = [
      Darwinning::Gene.new("first digit", (0..9)),
      Darwinning::Gene.new("second digit", (0..9)),
      Darwinning::Gene.new("third digit", (0..9))
    ]

  def fitness
    # Try to get the sum of the 3 digits to add up to 15
    (genotypes.inject{ |sum, x| sum + x } - 15).abs
  end
end 

p = Darwinning::Population.new(Triple, 10, 0, 0.1, 100)
p.evolve!

p.best_member.nice_print # prints the member representing the solution

This code declares an organism class that inherits from Darwinning’s Organism parent class to represent solutions. Then we create a population of these solution organisms and evolve the population until a solution meets the fitness threshold or the generation limit is met.

So, what else can I do with it?

If any of this sounds remotely interesting to you, please check out the project on Github. I’m always happy to take good pull requests if other people want to contribute. I haven’t been very active lately because I’ve been spending a lot of time on this website and my wedding website, but I do keep an eye on the project.

Sinatra + Jekyll + Prose

Welcome to the new Dinosaurs Eat Everybody blog! The old site/blog was an interesting mess of custom PHP and some custom build hooks into a Word Press blog and though it worked pretty well but I was tired of maintaining stuff in PHP so when my old hosting was about to expire I decided to move to a VPS and build something new. The result is what you see before you today.

This new site is built mainly on Sinatra with Jekyll mixed in for some blogging functionality. I didn’t really need any sort of content management system for most of the site so there is no database behind it and I’m using flat files (mostly just handwritten JSON) for anything that seems dynamic.

The interesting part was adding a Jekyll blog to an existing Sinatra site. Jekyll is super easy to set up on its own but I didn’t want it to run the whole site. I wanted to be able to serve dynamic pages if I wanted. With some help from this blog post it was actually pretty easy to get things up and running. That post is a bit out of date but still very helpful.

To add Jekyll to Sinatra I first just created a new Jekyll site in a seperate directory and copied it over into a jekyll_blog/ folder in the root of my Sinatra project. I then removed the .gitignore, the default.html layout and the whole css/ directory (after moving the Pygments syntax.css into my main stylesheet directory) from the new Jekyll directory. I also adjusted the _post.html layout to not have a layout of its own by just removing all the YAML Front-matter from the file. This is because I want Sinatra to handle the layouts for everything.

The real meat of this is a custom function in the /blog route:

get '/blog/?*' do
	jekyll_blog(request.path)
end

def jekyll_blog(path)
  @page_title = "blog"

  file_path = File.join(File.dirname(__FILE__), 'jekyll_blog/_site',  path.gsub('/blog',''))
  file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i 

  if File.exist?(file_path)
    file = File.open(file_path, "rb")
    contents = file.read
    file.close

    erb contents
  end
end

This just calls the jekyll_blog(path) function whenever you go to a page that starts with /blog/ and that just pulls the html content of either the post or the Jekyll index.html and puts into the <%= yield %> in my Sinatra erb layout.

This is a pretty simplistic solution and I want to add better 404 checking and a way to pull the post title out for use in the page title, but it gets the job done by pulling out the content of the post html file generated by Jekyll and putting it into the content container of Sinatra. Now all my layouts are handled by the same file and all my CSS comes from the same source.

While I like the idea of being able to write my blog posts in Markdown and from whatever editor I want I also wanted to have some sort of web based editor for my posts so I’m trying Prose. Prose is basically a web based editor for Github files (which is where all the content for this site resides anyways. It lets me go in and create new posts through a pretty nice looking Markdown editor with preview. It also helps with syntax and media uploading (though I haven’t tried that yet). I’ve included a _prose.rb config file that sends me right to the _posts/ directory of this project when I’m working on it:

prose:
  rooturl: 'jekyll_blog/_posts'
  media: 'public/images/blog_media'

I think that the transiton from a really polished, very user friendly system like Word Press to something more technical like Jekyll will be interesting. I feel like I still need to work some kinks out of the system and I’m still not totally won over by Prose but it has been really fun to set this up. I’d also like to add comments through Disqus soon. Hopefully now I’ll make this work worthwhile and actually write a few blog posts every now and then.