Skip to content

Instantly share code, notes, and snippets.

View routes.rb
# USER.boldfaced.net
constraints(Subdomain) do
get 'work/:id' => 'work_items#show', as: :user_work
get '' => 'users#profile', as: :user_profile
end
View uuid.rb
VOWELS = %w[a e o u]
CONS = ('a'..'z').to_a - VOWELS
len = 5
phrase = (1..len).inject([]) {|prod,i|
prod << (i.even? ? VOWELS.sample : CONS.sample)
}.join('')
View Gemfile
source :rubygems
gem 'bubble-wrap'
gem 'motion-cocoapods'
gem 'nano-store'
View gist:3901888
var playSingleChime = function()
{
var context = new webkitAudioContext(),
gain = context.createGainNode(),
osc = context.createOscillator();
osc.connect(gain);
gain.connect(context.destination);
osc.frequency.value = 1000.0;
View gist:3896980
var context = new webkitAudioContext(),
oscillator = context.createOscillator();
oscillator.type = oscillator.SQUARE;
oscillator.frequency.value = 1000;
oscillator.connect(context.destination);
oscillator.noteOn && oscillator.noteOn(0);
setTimeout('oscillator.disconnect()', 500);
View markup.html
<div class="datetime">
<span>Sept</span>
<span>25</span>
<span>11:30 <strong>AM</strong> <span></span></span>
</div>
@kylebragger
kylebragger / force-ssl.rb
Created Nov 10, 2011 — forked from mrrooijen/force-ssl.rb
Secure with SSL (Subdomain and Protocol) in Rails 3.1
View force-ssl.rb
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :secure_with_ssl
private
def secure_with_ssl
if request.subdomain != 'secure' or request.protocol != 'https'
redirect_to :subdomain => 'secure', :protocol => 'https'
View guilloche.js
/*
---
name: guilloche
script: guilloche.js
description: guilloche
provides: [Guilloche]
...
*/
View forrst-maximize.js
/*
This would have to be modified obviously, but it proves the concept.
*/
$('.code').hide()
.clone()
.appendTo('html')
.css('position', 'absolute')
.css('top', '2.5%')
.css('left', '2.5%')
.css('width', '95%')
View auto_orient.rb
module Paperclip
class AutoOrient < Paperclip::Processor
def initialize(file, options = {}, *args)
@file = file
end
def make( *args )
dst = Tempfile.new([@basename, @format].compact.join("."))
dst.binmode