Skip to content

Instantly share code, notes, and snippets.

@jrgifford
Created March 31, 2012 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrgifford/96bd45f3ce0190e0f768 to your computer and use it in GitHub Desktop.
Save jrgifford/96bd45f3ce0190e0f768 to your computer and use it in GitHub Desktop.
Hackish SE notifications

##Note: This requires ruby 1.9.x, Mac OS X ships with 1.8.7. So unless you're really big into it, this won't work.

This one is a little hackish, and I'm going to (eventually, someday) make it a little not so hackish. I promise.

First, install and sign up for [Boxcar][1], if you haven't already. (and if you haven't, I highly recommend it! Works very nicely for notifications of all sorts - Twitter, email, Facebook, etc.)

Next, you'll need to head over here and do two things:

  1. Change your user ID to whatever yours is. To find out what it is, take a look at the number in your profile URL: Mine is http://apple.stackexchange.com/users/1739/jrg, so my user ID is 1739.

  2. Get an access token. Head over to here and request one like below:

![enter image description here][2]

And then after you've gotten an access token, you can copy it and then paste it into the part where it says "FILL_ME_IN".

Now, you need to install two libraries - serel, and boxcar_api.

Run sudo gem install serel boxcar_api and then wait until they are installed.

Next, copy and paste this file into notify_me.rb (or whatever you want to call it). I'm going to assume its in ~/bin. Before you save, change the "your_email@domain.com" part to whatever you used to sign up for boxcar.

Now, lets go and hop into cron.

Run crontab -e in a terminal, which will edit your crontab.

It should ask you which editor you want to use, I suggest using nano unless you know vim or emacs really well.

I'm going to assume you aren't that busy on the site, so we'll have it run every two hours.

Paste the following into the bottom of your crontab:

0 */2 * * * ~/bin/notify_me.rb

And then you should be good to go.

Enjoy, and if you find bugs, feel free to send me an email:

james@jamesrgifford.com

Eventually, someday, somehow, I'll move this into its own proper project, rather than a crazy hax [1]: http://boxcar.io/ [2]: http://i.stack.imgur.com/jvVXy.png

#!/usr/bin/ruby
require 'serel'
require 'boxcar_api'
provider = BoxcarAPI::Provider.new('c1dQjjKHm0pXIrGQmWEb', 'Oo7gJ18sYVVQOAMzoDahzAmYxo8dfqDJ31cUKdJQ')
Serel::Base.config(:askubuntu, 'kivg66mlKu6WoI05Z5GRwA((')
#you can leave the :askubuntu part alone, it bother anything
token = Serel::AccessToken.new('FILL_ME_IN')
@foobar = token.inbox.request.first
@new_notification = @foobar.item_type
@new_notification_site = @foobar.title
provider.notify("your_email@domain.com", "New " + @new_notification + " on " + @new_notification_site )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment