Skip to content

Instantly share code, notes, and snippets.

@aurelian
aurelian / gist:925338
Created April 18, 2011 13:31
code.rb
_headers.reject!{|h| h.starts_with?("HTTP") }.inject([]){|a, k| a<< {k.split(":")[0].gsub("-","_").downcase.to_sym => k.split(":")[1].strip}}
tag += (sequence == 0)? '.1' : ((sequence < 0)? '' : ("."+(sequence+1).to_s)
@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) {
}
}
# 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