Skip to content

Instantly share code, notes, and snippets.

@hunj
hunj / rdoc_example.rb
Created May 28, 2015 01:09
Ruby RDoc Example
## Found in: http://blog.firsthand.ca/2010/09/ruby-rdoc-example.html
# * Style guide based on Rails documention
module Namespace #:nodoc: don't document this
# Generic Namespace exception class
class NamespaceError < StandardError
end
# Raised when...
@tomdale
tomdale / gist:3981133
Last active November 26, 2019 21:19
Ember.js Router API v2

WARNING

This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
@gerred
gerred / .irbrc
Created June 17, 2011 18:27
My .irbrc file
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
$LOAD_PATH << gem_path
end
end
end
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@superchris
superchris / asset_server.rb
Created May 21, 2011 18:01
asset server initializer
require 'tilt'
ENV['COFFEESCRIPT_SOURCE_PATH'] = Rails.root.join(
"app", "assets", "javascripts", "vendor", "coffee-script.js")
class BareCoffeeScriptTemplate < Sprockets::CoffeeScriptTemplate
def evaluate(scope, locals, &block)
@output ||= CoffeeScript.compile(data, :bare => true)
end
end
@nathos
nathos / fancy-hover-mixin.sass
Last active September 25, 2015 17:47
Compass fancy-hover - snazzy-looking image replacement hovers with an animated opacity ramp. Now using Compass sprites so you don't have to do the dirty work! See the demo at http://nathos.github.com/fancy-hovers/
@mixin fancy-hover($sprite_dir, $off_state, $hover_state, $speed: 0.3s)
$sprites: sprite-map("#{$sprite_dir}/*.png")
$width: image-width(sprite_file($sprites, $off_state))
$height: image-height(sprite_file($sprites, $off_state))
@include hide-text
width: $width
height: $height
background: sprite($sprites, $off_state) no-repeat
display: block
position: relative
@jcromartie
jcromartie / gsd.sh
Created May 4, 2011 15:40
Elegant Bash-based Get-Shit-Done script
#!/usr/bin/env bash
# edit this list, or set GSD_SITES to add your custom sites
SITES="$GSD_SITES reddit.com forums.somethingawful.com somethingawful.com digg.com break.com news.ycombinator.com infoq.com bebo.com twitter.com facebook.com blip.com youtube.com vimeo.com delicious.com flickr.com friendster.com hi5.com linkedin.com livejournal.com meetup.com myspace.com plurk.com stickam.com stumbleupon.com yelp.com slashdot.com"
HOSTFILE="/etc/hosts"
if [ ! -w $HOSTFILE ]
then
echo "cannot write to $HOSTFILE, try running with sudo"
describe JobSearch do
context 'units' do
before do
Sunspot.session = SunspotMatchers::SunspotSessionSpy.new(Sunspot.session)
end
after do
Sunspot.session = Sunspot.session.original_session
end
@ernie
ernie / GoDaddy CLI
Created April 6, 2011 15:45
If GoDaddy did CLI domain registration...
$ godaddy buy wynn.fm
-- Reading CC Info from .godaddy...
-- THANK YOU FOR PURCHASING YOUR DOMAIN WITH GODADDY!
-- WHILE OUR SERVERS THINK ABOUT REGISTERING YOUR DOMAIN
-- NAME, PLEASE GIVE CAREFUL CONSIDERATION TO THE
-- FOLLOWING SPECIAL OFFERS!!!
Would you like to also register the following and SAVE 64%?
wynn.net