This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@instance_store = {} | |
class App.Model extends Backbone.Model | |
cache_enabled: false | |
cache_key: "id" | |
constructor: (attr) -> | |
@on "destroy", @_removeFromStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
NewerOlder