Skip to content

Instantly share code, notes, and snippets.

View fermion's full-sized avatar
👋

Rob Sterner fermion

👋
View GitHub Profile
@fermion
fermion / viewable.js
Created September 24, 2009 16:53 — forked from gf3/viewable.js
Percentage of element in viewport
Element.addMethods({
viewable: function(el) {
// INIT
el = $(el);
var scroll = document.viewport.getScrollOffsets();
var viewport = document.viewport.getDimensions();
var offsets = el.cumulativeOffset();
var dimensions = el.getDimensions();
// Sanity check
@fermion
fermion / apns.py
Created March 2, 2012 12:35 — forked from scotttam/apns.py
Sends an Apple Push Notification with Python
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!',
#
# 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 November 5, 2012 12:53 — forked from oparrish/bootstrap_pagination_helper.rb
Link renderer to be used with will_paginate to render links to work with Twitter Bootstrap
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 October 26, 2012 11:38 — forked from erikeldridge/example.rb
A utility for signing an url using OAuth in a way that's convenient for debugging
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 October 24, 2012 19:10 — forked from gf3/model.js.coffee
Backbone Model Instance Sharing
@instance_store = {}
class App.Model extends Backbone.Model
cache_enabled: false
cache_key: "id"
constructor: (attr) ->
@on "destroy", @_removeFromStore
@fermion
fermion / reports_controller.rb
Created October 10, 2012 18:19 — forked from anonymous/ReportsController
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
# 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 April 4, 2012 10:36 — forked from ylluminate/Gemfile
Example BrowserCMS Gemfile for Heroku
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 March 2, 2012 12:35 — forked from scotttam/apns.rb
Sends an Apple Push Notification with Ruby
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"