Skip to content

Instantly share code, notes, and snippets.

@aurelian
aurelian / controller.rb
Created January 20, 2011 16:03
dumps sass variables
# ref: http://bit.ly/fN2ep8
# http://twitpic.com/3rr8dk
def sass_colors
engine= Sass::Engine.new(File.read("app/stylesheets/_colors.scss"), :syntax => :scss, :load_paths => ["app/stylesheets"])
environment= Sass::Environment.new
engine.to_tree.children.each do | node |
next unless node.kind_of? Sass::Tree::VariableNode
node.perform environment
end
@aurelian
aurelian / nokoe
Created January 3, 2011 10:11
nokogiri with pipes
#!/usr/bin/env ruby
#
# Nokoe: Nokogiri with pipes
#
# Requirements:
#
# gem install trollop
# gem install nokogiri
#
function calculate() {
var result = 0;
try {
result = parseFloat(eval(document.getElementById('calculator').value));
if(!isNaN(result) && isFinite(result))
document.getElementById('result').value= Math.round( result * 10000 ) / 10000;
} catch(err) {
}
}
@aurelian
aurelian / gist:534568
Created August 18, 2010 12:39
shows what before_filter is executed and where's that filter defined. useful to debug before_filter madness
puts "\033[1;31m=> Loading hacks: #{__FILE__}\033[0m"
module BeforeFilterHacks
def self.included(base)
base.class_eval { alias_method_chain :call, :hacks }
end
def call_with_hacks(controller, &block)
message= if method.kind_of?(Proc)
method.to_s
# config/initializers/hacks.rb
HelloController.send(:include, SomeHacks)
stalingrad ~ $ rvm install 1.9.1
/Users/aurelian/.rvm/scripts/match: line 8: conditional binary operator expected
/Users/aurelian/.rvm/scripts/match: line 8: syntax error near `=~'
/Users/aurelian/.rvm/scripts/match: line 8: ` [[ "$1" =~ $2 ]]'
/Users/aurelian/.rvm/scripts/match: line 8: conditional binary operator expected
/Users/aurelian/.rvm/scripts/match: line 8: syntax error near `=~'
/Users/aurelian/.rvm/scripts/match: line 8: ` [[ "$1" =~ $2 ]]'
/Users/aurelian/.rvm/scripts/match: line 8: conditional binary operator expected
/Users/aurelian/.rvm/scripts/match: line 8: syntax error near `=~'
/Users/aurelian/.rvm/scripts/match: line 8: ` [[ "$1" =~ $2 ]]'
require 'rubygems'
require 'twitter'
friend_ids= Twitter.friend_ids(USERNAME)
client = Twitter::Base.new(Twitter::HTTPAuth.new(USERNAME, USERPASS))
friend_ids.each do | fid |
friend= Twitter.user(fid)
puts "~> #{friend.screen_name} -> #{USERNAME}: #{client.friendship_exists?(fid, USERNAME)}"
end
see http://github.com/aurelian/grapi
@aurelian
aurelian / 2s3.rb
Created October 29, 2009 16:32
script to backup my iPhoto pictures
require 'rubygems'
require 'right_aws'
require 'ruby-growl'
require 'mime/types'
require 'digest/sha1'
if ARGV.size < 1
puts "-- #{__FILE__} folder"
exit 1
end