Skip to content

Instantly share code, notes, and snippets.

View rbenv-install-system-wide.sh
#
# Run as root
# $ bash <(curl -s https://gist.github.com/4567317)
#
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl \
libssl-dev \
@fermion
fermion / bootstrap_pagination_helper.rb
Created Nov 5, 2012 — forked from oparrish/bootstrap_pagination_helper.rb
Link renderer to be used with will_paginate to render links to work with Twitter Bootstrap
View bootstrap_pagination_helper.rb
module BootstrapPaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def page_number(page)
unless page == current_page
link(page, page, :rel => rel_value(page))
else
link(page, "#", :class => 'active')
end
@fermion
fermion / example.rb
Created Oct 26, 2012 — forked from erikeldridge/example.rb
A utility for signing an url using OAuth in a way that's convenient for debugging
View example.rb
require 'oauth_util.rb'
require 'net/http'
o = OauthUtil.new
o.consumer_key = '<smugmug key>';
o.consumer_secret = '<smugmug secret>';
url = 'http://api.smugmug.com/services/oauth/getRequestToken.mg';
@fermion
fermion / model.js.coffee
Created Oct 24, 2012 — forked from gf3/model.js.coffee
Backbone Model Instance Sharing
View model.js.coffee
@instance_store = {}
class App.Model extends Backbone.Model
cache_enabled: false
cache_key: "id"
constructor: (attr) ->
@on "destroy", @_removeFromStore
View reports_controller.rb
class ReportsController < ApplicationController
def index
# get all daily feeds
@feeds = Feed.where(:feed_type => 'daily')
@late_daily_feeds = []
@feeds.each do |d|
daily_state = FeedStatus.where({:feed_id => d.id, :target_date => Date.today.to_s}).exists? ? "green" : "red"
daily_time = FeedStatus.where({:feed_id => d.id}).order("updated_at").last
@late_daily_feeds << {:feed_name => d.feed_name, :state => daily_state, :received => daily_time }
end
View hacky.rb
# Hacky random image thumbnailer.
# by Peter Sobot, April 21, 2012
# Based heavily on code by Michael Macias
# (https://gist.github.com/a54cd41137b678935c91)
require 'rmagick'
images = Dir.glob(ARGV[0] ? ARGV[0]
: '-default-input-paths-')
output_dir = (ARGV[1] ? ARGV[1]
@fermion
fermion / Gemfile
Created Apr 4, 2012 — forked from ylluminate/Gemfile
Example BrowserCMS Gemfile for Heroku
View Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.9'
gem 'heroku'#, "~> 2.20" # shouldn't need this, but I've had to force Heroku version before.
gem 'rubyzip'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'thin', '1.3.1' # Heroku Cedar has added this as a requirement, otherwise it WILL use webrick & of course we don't want that.
@fermion
fermion / apns.rb
Created Mar 2, 2012 — forked from scotttam/apns.rb
Sends an Apple Push Notification with Ruby
View apns.rb
require "rubygems"
require "yajl"
require "openssl"
require "socket"
# device_token = '39cac56f 986a0e66 3c4fd4f4 68df5598 024d2ca3 8b9f307c 741c180e 9fc30c62'
# device_token = device_token.gsub(" ", "")
# the_byte_token = [device_token].pack("H*")
the_byte_token = "\xBA\xFE\xD9\v \xD9\xC5\xAE\xCED\xD0-\xF2\x87\xAA\bkn\x9F\xC4aY\xD1v_|6\x97\xF8g\xAB\x17"
@fermion
fermion / apns.py
Created Mar 2, 2012 — forked from scotttam/apns.py
Sends an Apple Push Notification with Python
View apns.py
import socket, ssl, json, struct
import binascii
# device token returned when the iPhone application
# registers to receive alerts
deviceToken = '39cac56f 986a0e66 3c4fd4f4 68df5598 024d2ca3 8b9f307c 741c180e 9fc30c62'
thePayLoad = {
'aps': {
'alert':'Oh no! Server\'s Down!',
@fermion
fermion / 0_README.md
Created Nov 21, 2011 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine
View 0_README.md

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard