Skip to content

Instantly share code, notes, and snippets.

@djspinmonkey
djspinmonkey / gist:1345883
Created November 7, 2011 19:26
An implementation of destruct without using eval or #binding
def assert( bool, msg )
puts (bool ? "Pass " : "Fail ") + msg
end
class Hash
def destruct( &block )
vals = block.parameters.map { |p| self[p[1]] }
block.call(*vals)
end
end
@chriseppstein
chriseppstein / dry_inner_content_using_capture.haml
Created May 23, 2011 19:07
This gist shows some approaches for using haml without repeating inner content
- content_for(:inner_content) do
= render :partial => "inner_content"
- if some_condition
%outertag1= yield :inner_content
- else
%outertag2= yield :inner_content
@aaronrussell
aaronrussell / background_noise_function.rb
Created March 5, 2011 18:24
Sass implementation of the Noisy jquery plugin: https://github.com/DanielRapp/Noisy
require "rubygems"
require "chunky_png"
require "base64"
module Sass::Script::Functions
def background_noise(c, noise = 0.5, opacity = 0.08, size = 200, mono = false)
# Convert SASS numbers to Ruby classes
noise = noise.to_s.to_f if noise.is_a? Sass::Script::Number
@atr000
atr000 / shellfm-growl.py
Created July 28, 2010 02:40
shell-fm python growl notifier
#!/usr/bin/env python
"""
Just put this line in your ~/.shell-fm/shell-fm.rc
np-cmd = /path/to/shellfm-notify "%a" "%t" "%l"
"""
import os
import sys
import Image
#!/usr/bin/env zsh
if [[ -s "${TM_PROJECT_DIRECTORY}/.rvmrc" ]]
then
source "${TM_PROJECT_DIRECTORY}/.rvmrc"
fi
exec ruby "$@"
@gus
gus / index.txt
Created November 30, 2009 21:55 — forked from toothrot/index.txt
Ruby/Clojure analogs
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation: