Skip to content

Instantly share code, notes, and snippets.

View justinperkins's full-sized avatar
🥶

Justin Perkins justinperkins

🥶
View GitHub Profile
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites you only want to give yourself
# access to during certain times of day.
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#
# In this case, I can visit hacker news only over the lunch hour,
require 'hpricot'
require 'open-uri'
class AmazonMp3Music
ASSOCIATE_ID = 'enjoybeing-20'
AMAZON_INJECTED_STRINGS = [' (Amazon Exclusive)', ' [Explicit]']
attr_accessor :asin, :artist, :album, :album_image, :referral_url, :processed
def initialize(url)
@url = url
# Use builtin Image Events app in Mac OS X to resize images with Ruby
# Usage:
# require 'image_resizer'
# class Foo
# include ImageResizer
# def some_method
# resize('/absolute/path/to/an/image.jpg')
# resize('/absolute/path/to/an/image.jpg', :target_width => 500)
# end
# end
#!/usr/bin/env ruby
require 'rubygems'
=begin
TimeTracker is a simple way to track time on tasks
Start tracking time: ./time_tracker.rb -s some-task-name
Stop tracking time: ./time_tracker.rb -f
View recorded time for a task: ./time_tracker.rb -h some-task-name
#!/usr/bin/env ruby
#######################
# description:
# sends an email to one or more people on a certain day of the week, which rotates every week
# an email is sent on monday to advise your recipients which day of the week the taco day falls on
# then on the day of the taco day, a brief email will be sent to remind people once again
# use cron to schedule this script to be invoked on weekdays at whatever time you want the email to be sent
# here is an example: 0 11 * * 1-5 ~/bin/taco-mailer.rb
#######################
tt http://trac/cgi-bin/trac.cgi/ticket/%s Jump To Trac Ticket
tc http://trac/cgi-bin/trac.cgi/changeset/%s Jump To Trac Commit
tp http://trac/cgi-bin/trac.cgi/browser/%s Jump To Trac Path
am http://www.allmusic.com/cg/amg.dll?SQL=%s&OPT1=1&Submit=Go&P=amg Search AllMusic
movies http://www.google.com/movies?sc=1&near=%s&rl=1 Google Movies
@justinperkins
justinperkins / cookie.js
Created September 7, 2012 19:33 — forked from ChillyBwoy/cookie.js
Cookie functions for underscore.js
@justinperkins
justinperkins / gist:3909887
Created October 18, 2012 04:40
Backbone.js + Rails: Add Auth Token to Sync
// Adapted from: https://gist.github.com/1251730
// I like this technique better: https://gist.github.com/3960219
$(function(){
var paramName = $("meta[name='csrf-param']").attr('content');
var paramValue = $("meta[name='csrf-token']").attr('content');
Backbone.sync = _.wrap(Backbone.sync, function(originalSync, method, model, success, error){
if (method == 'create' || method == 'update' || method == 'delete') {
// grab the token from the meta tag rails embeds
class Event
def initialize
@callbacks = {}
end
def on(event, &block)
@callbacks[event] ||= []
@callbacks[event] << block
end
require 'test_helper'
class ServiceTest < ActiveSupport::TestCase
def setup
super
@klass = Class.new do
include Service