coding and things

The Yipit API and Whenever Gem

| Comments

Last week Alex and I presented Platt101 at our NYC on Rails Meetup, at the Flatiron School. Platt101 let's a user write reviews about restaurants they have been to and renders those restaurants on a Google Map. The restaurants are based on the 101 best according to New York Magazine. The restaurants a user has been to render in a different color than restaurants a user hasn't had the pleasure of dining. A fellow student (h/t Anthony) suggested we impliment a GroupOn link in our restaurant list in order for a user to provide the user incentive to go dine at given restaurants.

We decided to use the Yipit API in order to aggregate all discount incentives from numerous discount sites such as GroupOn. We accessed the Yipit API via the Yipit gem for Ruby on Rails, created by Gangster. Aside from our client session running a few times, the gem provided for all of our data parsing needs. The Yelp API we used to seed our database with relevant restaurant information included phone numbers. We searched the phone numbers in our database against phone numbers on Yipit in order to find deals for the given restaurants on our list. This functionality is provided with a rake task. Here is the code:

The rake task provides us the ability to use the Whenever gem in order to run the rake task everyday. This way our database in reseeded with new data about restaurant deals on a daily basis. The Whenever gem was easy to impliment.

This code is automatically added to your config > schedule.rb when you run whenever . in terminal. You can customize Whenever to run whenever you want.

Now, this all works well in development, but Platt101 is deployed on Heroku. In production, we needed to reset up the Whenever gem. This is also easy to accomplish on Heroku. Use Heroku Scheduler in order to run a chron job in production. They do make you use input your credit card info, which is whack, but it says free... we shall see.

Platt101 can be found here.


| Comments


Learning how Airplay works: it allows wireless streaming of audio, video and photos.

My original idea was to rip the music information going onto the Flatiron AirPlay, then automatically tweet this information via Twitter. I liked this idea because we play so much cool and unfamiliar music. It would be great to keep track of what is playing. Over time, I opened a myriad of tabs and discovered many interesting API's. These include a few API's which mirror AirPlay on a laptop (AirParrot. and AirServer.). Also, many music API's were discovered. These include Echonest, Soundcloud and many others.

The original idea went down in flames when I learned how difficult it is to hack the AirPlay. This blog post illustrated how this hacker tried to gain access to the AirPlay from WiFi packets via KisMAC, a derivative of WireShark. Also, there are problems jailbreaking the DRM encryption. The idea is possible, but a crazy task. Idea aborted...

GitHub Play deserves some special recognition. It allows the GitHub offices to wirelessly create playlists synchronously in all of their offices around the globe. The next iteration of our goal was to get the GitHub Play to work locally. You can clone it at the link above. However, GitHub Play relies on an old version of iTunes which includes iTunes DJ. Also, Play ran on Ruby 1.8.7, and the dependencies were a mess. So, our group threw this idea of out the window.

GitHub Play

Our groups next iteration is to simplify the GitHub Play. Currently we are setting up a server where people can upload their mp3's. Directions to create your own streaming music player in Ruby can be found here. The goal of this project is to eventually create a service where a group of people can all upload their songs onto a server and they will be played in sequence on a playlist. For example, if you are at a party, everyone can put songs on a playlist, so that no one person will have complete control of the music. We also want to implement a Reddit-esque leaderboard so people on the server can upvote/downvote songs. If a song gets too many downvotes, it will be erased from the playlist.

Adventures in Code

| Comments

One can run into some cataclysmic errors trying to setup and deploy an Octopress account. Personally, I kept raking new themes from Github to my Octopress account and finally, my blog broke. In order to keep the same url, I deleted my Github repository and recreated an Octopress account.

Things I learned


$ subl .

This saves so much time. The code snipped will open the entire current directory in your terminal.

Now, things are going well and I begin to play with some HTML, CSS and JS code. I stumbled upon this gold nugget. Sweet animated clouds here.

...and a tutorial to recreate animated clouds by the author here.

It was loads of fun messing with the CSS and JS source code and I manipulated the code into this:

Awesome! I created this a massive randomly generated semi-transparent smiley face. Now, how do I implement this information to Octopress? The CSS ans JS code is hard core and I do not understand how works very well. What do I do now?

Bonsai JS is a Javascript graphics library with step-by-step tutorials on how to implement all sorts of useful code such as rendering shapes, gradients and animation. It also has a built in editor to play with said code. With the editor and tutorials I can quickly learned how to do code graphics with JS. An example of what can be created with Bonsai is below.

Sweet. Thanks to my fellow Flatiron students who helped me along the way!

Git Commandments

| Comments

Don’t change master.

$ git pull ––rebase

-to pull from the master and then create new branch

-now you have an up to date branch to code your magic

$ git status

-run after you change things in your branch

-shows you what changed

$ git add .

$ git commit -m “Your message”

$ git co master

-checkout master before your merge

$ git pull ––rebase

-ensure that there haven’t been any changes before you merge to master branch

$ git merge -m “Your message”

$ git push

-data now updated on git!