Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
@Entity
@FilterDef( name="tenantFilter", parameters=@ParamDef( name="tenantId", type="string" ) )
@Filters(
@Filter( name="tenantFilter", condition="tenant_id = :tenantId" )
)
@Filter( name="tenantFilter", condition="tenant_id = :tenantId" )
)
public class Customer {
@Id
private Long id;
#!/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 / html2canvas.js
Created September 24, 2012 02:24
Snippet to load html2canvas in the actual page
this.scriptObject=document.createElement('script');
this.scriptObject.type='text/javascript';
this.scriptObject.src='http://html2canvas.hertzen.com/js/html2canvas.js';
var ssc = document.getElementsByTagName('script')[0];
ssc.parentNode.insertBefore(this.scriptObject, ssc);
this.scriptObject=document.createElement('script');
this.scriptObject.type='text/javascript';
this.scriptObject.src='http://html2canvas.hertzen.com/js/jquery.plugin.html2canvas.js';
@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