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
@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() {
@geronimod
geronimod / polling_queue.js.coffee
Last active February 17, 2017 16:05
Polling Queue
class @PollingQueue
constructor: (opts) ->
opts || (opts = {})
@queue = {}
@frequency = opts.frequency || 3000 # 3 seconds
@interval = undefined
add: (url, options = {}) ->
return unless url
@geronimod
geronimod / status_polling_queue.js.coffee
Created January 20, 2017 19:46
Status Polling Queue
class @StatusPollingQueue
constructor: () ->
@queue = []
@frequency = 3 * 1000 # 3 seconds
@interval = undefined
@failureLimit = 50
add: (url, options = {}) ->
return unless url
class @PollingQueue
constructor: () ->
@queue = []
@frequency = 3000 # 3 seconds
@interval = undefined
@failureLimit = 50
add: (url, options = {}) ->
return unless url
@geronimod
geronimod / tools.rake
Created August 4, 2016 18:31
Move s3 assets
bucket = 'intergi-phoenix'
files = S3Util.storage.directories.get(bucket, prefix: '12917/videos/').files
files.each do |file|
path = file.key
video_id = path[/videos\/(\d+)\//, 1].to_i
if video_id < 3270839
puts "skip #{video_id}"
next
@geronimod
geronimod / untitled
Created May 4, 2016 14:36
bash branch info
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
export BRANCH_INFO='$(parse_git_branch)'
export CURRENT_BRANCH='$BRANCH_INFO'
export PS1="\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\] \! \[\033[00;35m\]\w\[\033[00m\]\[\033[00m\] ($BRANCH_INFO)\$ "
@geronimod
geronimod / untitled
Last active April 13, 2016 19:22
redirect.pl
use CGI;
my $q = CGI->new;
$to_host = 'https://www1.udel.edu';
$url = $ENV{'REDIRECT_URL'};
$url =~ s/^https?:\/\/[^\/]+//g;
print $q->redirect($to_host . $url);
@geronimod
geronimod / berlin-clock.rb
Created November 22, 2013 19:33
Kata Berlin Clock
require 'minitest/autorun'
class BerlinClock
def self.seconds(seconds)
seconds.even? ? 'Y' : 'O'
end
def self.minutes(minutes)
row1 = Array.new(11, 'O').unshift(['Y'] * (minutes / 5)).flatten.first(11)
@geronimod
geronimod / roman-numbers.rb
Created November 22, 2013 15:53
Kata Roman Numbers
require 'minitest/autorun'
class Integer
# rules:
# - Si a la derecha de una cifra romana de escribe otra igual o menor, el valor de ésta se suma a la anterior.
# - La cifra "I" colocada delante de la "V" o la "X", les resta una unidad; la "X", precediendo a la "L" o a la "C", les resta diez unidades y la "C", delante de la "D" o la "M", les resta cien unidades.
# - En ningún número se puede poner una misma letra más de tres veces seguidas. En la antigüedad se ve a veces la "I" o la "X" hasta cuatro veces seguidas.
# - La "V", la "L" y la "D" no pueden duplicarse porque otras letras ("X", "C", "M") representan su valor duplicado.
# - Si entre dos cifras cualesquiera existe otra menor, ésta restará su valor a la siguiente.
@geronimod
geronimod / prime-factors.rb
Last active December 28, 2015 22:09
Kata Prime Factors
require 'minitest/autorun'
def primes(input)
out, curr_div = [], 2
begin
div, mod = input.divmod(curr_div)
if mod.zero?
out << curr_div
input = div
else