Skip to content

Instantly share code, notes, and snippets.

View geronimod's full-sized avatar
🇦🇷
Working from home

Geronimo Diaz geronimod

🇦🇷
Working from home
View GitHub Profile
Language family Language name Native name 639-1 639-2/T 639-2/B 639-3 Notes
Northwest Caucasian Abkhaz аҧсуа ab abk abk abk
Afro-Asiatic Afar Afaraf aa aar aar aar
Indo-European Afrikaans Afrikaans af afr afr afr
Niger-Congo Akan Akan ak aka aka aka + 2 macrolanguage, Twi is [tw/twi], Fanti is [fat]
Indo-European Albanian Shqip sq sqi alb sqi + 4 macrolanguage
Afro-Asiatic Amharic አማርኛ am amh amh amh
Afro-Asiatic Arabic العربية ar ara ara ara + 30 macrolanguage, Standard Arabic is [arb]
@geronimod
geronimod / deploy.rb
Created October 1, 2011 16:07
Capistrano example config
require "bundler/capistrano" # ejecuta el bundle luego del deployment
# set(var, value)
set :rails_env, "production"
set :application, "example"
set :domain, "www.example.com.ar"
# una mejor explicacion de como trabajan los roles la pueden encontrar en https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning
role :app, domain
role :web, domain
def to_csv
header = Product.columns.map(&:name).join(',')
rows = Product.all.map do |record|
returning [] do |row|
Product.columns.each { |c| row << record.send(c) }
end.join(',')
end
[header, rows.join("\n")].join("\n")
end
csv_data = FasterCSV.generate do |csv|
# por ahora todas pero habra que dejar afuera la imagen y los templates html
# headers
csv << Product.columns.map(&:name)
Product.all.each do |record|
csv << Product.columns.map { |c| record.send(c.name) }
end
end
@geronimod
geronimod / en.yml
Created December 21, 2011 14:09
date formats
date:
formats:
default: "%Y-%m-%d"
short: "%b %d"
long: "%B %d, %Y"
long_ABY-HM: '%A %B %Y - %H:%M' #Sunday September 11 - 15:33
long_HM-ABD: '%H:%M - %A %B %d' #16:20 - Thursday September 8
short_Bd,Y: '%B %d, %Y' #September 8, 2011
short_BY': '%B %Y' #September 2011
@geronimod
geronimod / i18n_ex.rb
Created December 21, 2011 17:40
i18n translation missing monkey patch
module I18nCustom
def self.included(base)
base.send :alias_method_chain, :html_message, :data_attributes
end
def html_message_with_data_attributes
keys.shift # discard the locale
key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
translation_key = keys.join('.')
text_to_translate = I18n.t translation_key, :locale => I18n.default_locale, :default => ''
@geronimod
geronimod / application_helper.rb
Created February 14, 2012 19:19
customize error messages
def error_messages_for(objects, options = {})
objects = Array(objects)
count = objects.inject(0) {|sum, object| sum + object.errors.count }
unless count.zero?
html = {}
[:id, :class].each do |key|
if options.include?(key)
value = options[key]
html[key] = value unless value.blank?
@geronimod
geronimod / test.js
Created April 27, 2012 23:30
Scraper with zombie.js
var user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20';
var Browser = require("zombie");
var browser = new Browser({userAgent: user_agent, debug: true, waitFor: 10000});
var url = 'https://accounts.google.com/ServiceLoginAuth';
var login = 'foo@gmail.com';
var password = 'foo';
browser.visit(url, function() {
Zombie: GET https://accounts.google.com/ServiceLoginAuth
Zombie: GET https://accounts.google.com/ServiceLoginAuth => 200
Zombie: POST https://accounts.google.com/ServiceLoginAuth
Zombie: POST /ServiceLoginAuth => https://accounts.google.com/CheckCookie?chtml=LoginDoneHtml&checkedDomains=youtube&pstMsg=0
Zombie: GET https://accounts.google.com/CheckCookie?chtml=LoginDoneHtml&checkedDomains=youtube&pstMsg=0
Zombie: GET https://accounts.google.com/CheckCookie?chtml=LoginDoneHtml&checkedDomains=youtube&pstMsg=0 => 400
<html lang="en"> <meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 400 (Bad Request)!!1</title>
@geronimod
geronimod / gwt-mechanize-test.rb
Created May 1, 2012 19:03
GWT mechanize login test
# require 'rubygems'
require 'mechanize'
bot = Mechanize.new
bot.log = $stdout
bot.get('https://www.google.com/webmasters/tools') do |login_page|
home_page = login_page.form_with(:action => /ServiceLoginAuth/) do |f|
f.field_with(:name => 'Email').value = 'reporting@ninebyblue.com'
f.field_with(:name => 'Passwd').value = '{the correct pass}'