Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
file = open(ARGV[1]) if ARGV[1]
file ||= STDIN
doc = Hpricot(file)
puts doc / ARGV[0]
@andersonfreitas
andersonfreitas / gist:1073841
Created July 9, 2011 18:51 — forked from dhh/gist:1014971
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
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@andersonfreitas
andersonfreitas / .irbrc
Created July 22, 2011 01:29 — forked from gerred/.irbrc
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
@andersonfreitas
andersonfreitas / dedup.py
Created May 24, 2012 01:46 — forked from plamere/dedup.py
dedup.py - uses echoprint to find duplicates in a music collection
#!/usr/bin/python
import sys
import os
import pprint
import subprocess
import pickle
import atexit
import simplejson as json
sys.path.insert(0, "../API")
@andersonfreitas
andersonfreitas / translator.rb
Created July 20, 2012 20:33 — forked from vraravam/translator.rb
Use Google translate to translate a yml file from one language to generate a new one for a different language
#!/usr/bin/env ruby
if ARGV.size != 2
puts "Usage: #{$0} <from_language> <to_language>"
exit -1
end
require 'rubygems'
require 'ya2yaml' # this gem is needed for this to work!
require 'yaml'
@andersonfreitas
andersonfreitas / subdomains.rb
Created September 12, 2012 14:08 — forked from rtekie/subdomains.rb
Support for Rspec / Capybara subdomain integration testing
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
#
# Sample subdomain test:
# it "should test subdomain" do
# switch_to_subdomain("mysubdomain")
# visit root_path
# end
DEFAULT_HOST = "lvh.me"
@andersonfreitas
andersonfreitas / base.router.js
Created September 24, 2012 14:14 — forked from ianstormtaylor/base.router.js
Enhanced Backbone Router to make a lot of things easier.
define([
'underscore',
'backbone'
],
function (_, Backbone) {
return Backbone.Router.extend({
// Variants of the routes to be automatically bound to. This way you
@andersonfreitas
andersonfreitas / gist:3789796
Created September 26, 2012 18:47 — forked from sandinist/gist:1659881
forward-delete in IRB and ZSH

iTerm2

  • Go to iTerm > Preferences... > Keys
  • Add a Global Shortcut Key
  • Type the delete key as Shortcut
  • Select Send Hex Codes as Action and type 0x004
  • Click on OK and you're good to go

zsh

@andersonfreitas
andersonfreitas / object-watch.js
Created October 4, 2012 01:36 — forked from eligrey/object-watch.js
object.watch polyfill
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/