Monday, November 28, 2011

Random Video Game Name Generator with Ruby

I've been working with a LOT of Javascript lately. And when I say "working with," what I mean is "finding scripts that will do what I want them to do and modifying as necessary." Wait, isn't this supposed to be a Ruby on Rails blog? What happened!?

I got back to work on my random video game name generator tonight. I basically wanted to style it a bit and find a way so that it would generate a new phrase whenever the page is reloaded and then provide a link to reload the page. Pretty easy to do with a Javascript code, but I'm not a huge fan of reloading the entire thing just to reload this bit of text. Probably a better way to handle this, right? Maybe an Ajax call? What do you guys suggest? This works but I don't like the look of it, I guess.

Anyway, here's a link to the app on Heroku:

Random Video Game Name Generator

I wanted to accomplish a few things with this project. First off, build a random name generator with Ruby, and then figure out how you run that code on the web. This was largely a matter of learning Sinatra, and when I say "learning," I mean reading a tutorial and talking to @jqr about it for a few minutes. Sinatra is like SO easy.

I've got plans for how I could expand it (don't I always? Other coders have this problem too, right?) such as allowing users to save names they especially like, then enter a short description of what the game would be like. Viewers could also look at games that had been saved, perhaps vote on them, look at most popular games, etc, etc.

I think it's getting easier for me to think about WHAT applications COULD do, now that I know a bit more about HOW they're built. That makes sense, right?

Sunday, November 27, 2011

More work on Skyrim Stories

Today I finished up Skyrim Stories. If you'll recall, last time I posted about this project, I was looking for a way to strip out #skyrimstories from the posted tweets as well as a way to make the usernames into links to that poster's Twitter account.

My friend Matt sent me to W3 Schools to learn how to use string replace with Javascript. Took me a minute to figure out how this worked until I realized I needed to call a string replace method on the strings BEFORE they were collected into an array.

I was able to use Twitter Anywhere to make usernames into links. Plus it's got a slick hover card feature with a +Follow button. This API is easy to understand and did exactly what I wanted done plus a few extra things.

For the most part I think I'm done with this project now. I might tweak it a bit here and there, but I think it's pretty solid for what it does. And it's time for me to get back into some Ruby work, anyway.