The original universal static instagram
(back when it was still a jekyll plugin)
Linked to from http://lukecod.es/2011/11/27/instagram-liquid-tag-plugin-for-jekyll-and-octopress/
require 'aws-sdk' | |
require 'eventmachine' | |
require 'tweetstream' | |
AWS_ACCESS_KEY = 'your_aws_access_key' | |
AWS_SECRET_KEY = 'your_aws_secret_key' | |
dynamo_db = AWS::DynamoDB.new(:access_key_id => AWS_ACCESS_KEY, :secret_access_key => AWS_SECRET_KEY) | |
table = dynamo_db.tables['tweets'] |
class FooController | |
respond_to :csv | |
def index | |
@foos = Foo.scoped | |
if stale?(:last_modified => Foo.something) | |
respond_with @gta do |format| | |
format.csv { stream_csv @foo } | |
end | |
end |
require 'eventmachine' | |
require 'net/dns' | |
require 'net/dns/resolver' | |
module EM # :nodoc: | |
module Protocols | |
include Logger::Severity | |
class AsyncResolver < Net::DNS::Resolver |
upstream unicorn { | |
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default deferred; | |
root /home/deploy/apps/<%= application %>/current/public; | |
location ^~ /assets/ { | |
gzip_static on; |
module MobileSite | |
def self.included(base) | |
base.class_eval do | |
# Uncomment for JQM Integration | |
#rescue_from ActionView::MissingTemplate, :with => :view_unavailable | |
before_filter :set_mobile_preferences | |
before_filter :redirect_to_mobile_if_applicable | |
before_filter :set_mobile_view_path |
(back when it was still a jekyll plugin)
Linked to from http://lukecod.es/2011/11/27/instagram-liquid-tag-plugin-for-jekyll-and-octopress/
[alias] | |
wip = !"git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m \"wip\"" | |
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1" | |
rb = !"git wip;git rebase -i origin/master;git unwip" | |
pr = !"git fetch;git wip;git rebase --stat origin;git unwip;git heads" | |
head = !"git log -n1" | |
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'" | |
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'" |
framework 'Cocoa' | |
framework 'QuartzCore' | |
class NSColor | |
def toCGColor | |
colorRGB = self.colorUsingColorSpaceName NSCalibratedRGBColorSpace | |
components = Array.new(4){Pointer.new(:double)} | |
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3] |
# This method finds related articles using Jaccard index (optimized for PostgreSQL). | |
# More info: http://en.wikipedia.org/wiki/Jaccard_index | |
class Article < ActiveRecord::Base | |
def related(limit=10) | |
Article.find_by_sql(%Q{ | |
SELECT | |
a.*, | |
( SELECT array_agg(t.name) FROM taggings tg, tags t |