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/
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; |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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 |
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :api | |
draw :account | |
draw :session |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
require 'action_dispatch/middleware/static' | |
module Middleware | |
class FileHandler < ActionDispatch::FileHandler | |
def initialize(root, assets_path, cache_control) | |
@assets_path = assets_path.chomp('/') + '/' | |
super(root, cache_control) | |
end | |
def match?(path) |
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 |
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'] |
(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/