Skip to content

Instantly share code, notes, and snippets.

@jrmoran
jrmoran / movistar.rb
Created December 26, 2011 06:12
movistar_captcha
# Jaime Moran
require 'net/http'
def download_captcha file_name
uri = URI.parse('http://www.corporativo.telefonica.com.sv/EnviarSMSSV/faces/' +
'EnviarSMS.jsp?vrClientId=form1:imageEx1')
headers = { 'user-agent' => 'Mozilla/4.0 (Compatible; MSIE 4.0)' }
http = Net::HTTP.start(uri.host, uri.port)
response = http.request_get(uri.path, headers)
@jrmoran
jrmoran / Cakefile
Created December 30, 2011 01:44
Cakefile to document, compile, join and minify CoffeeScript files for client side apps.
# Cakefile to document, compile, join and minify CoffeeScript files for
# client side apps. Just edit the config object literal.
#
# -jrmoran
fs = require 'fs'
{exec, spawn} = require 'child_process'
# order of files in `inFiles` is important
config =
timeIt = (f)->
start = Date.now()
f()
console.log 'time: ', Date.now() - start, 'ms'
adder = ->
total = 0
((n = 0)-> total += n)
timeIt ->
@jrmoran
jrmoran / loader.js
Created January 14, 2012 04:55
dynamic script loader
var myLoader = function(filename, fun) {
var head = document.getElementsByTagName('head')[0],
script = document.createElement('script');
script.type = 'text/javascript';
script.src = filename;
if(typeof fun === 'function'){ script.onload = fun; }
head.appendChild(script);
};
@jrmoran
jrmoran / App.coffee
Created January 16, 2012 09:54
Backbone and CoffeeScript
$ ->
# Inspired in
# [this](http://adamjspooner.github.com/coffeescript-meet-backbonejs/)
#
# Live sample [here](http://jrmoran.com/playground/backbone-coffeescript/)
# override backbone sync, so when we remove/save items no server calls
# are made
Backbone.sync = (method, model, success, error) -> success()
@jrmoran
jrmoran / app.coffee
Created January 16, 2012 20:57
Precompiled Haml templates with CoffeeScript
companies = [{"id":1,"ticker":"AAPL","name":"Apple Inc"},
{"id":2,"ticker":"ABC","name":"Amerisourcebergen Corp"},
{"id":3,"ticker":"ABT","name":"Abbott Labs"},
{"id":4,"ticker":"ACE","name":"Ace Ltd"},
{"id":5,"ticker":"ADBE","name":"Adobe Sys Inc"}]
_.templateSettings = interpolate :/\{\{(.+?)\}\}/g
$ ->
@jrmoran
jrmoran / posterous-disqus.rb
Created January 31, 2012 08:35
Exporting Posterous comments to Disqus
require 'posterous'
require 'time'
# Add your credentials Here
Posterous.config = {
'username' => '<email-address>',
'password' => '<password>',
'api_token' => '<api-token>'
}
@jrmoran
jrmoran / fibonacci-50.clj
Created February 7, 2012 18:14
Fibonacci Sequence
(defn fib [n]
(Math/round (/ (- (Math/pow 1.618034 n)
(Math/pow (- 0.618034) n))
(Math/sqrt 5))))
(map fib (range 51))
;; (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524579 5702888 9227467 14930356 24157823 39088179 63246003 102334183 165580188 267914374 433494567 701408948 1134903525 1836312490 2971216044 4807528580 7778744699 12586273401)
@jrmoran
jrmoran / codificacion.txt
Created February 15, 2012 00:11
Codificación SVMap
m0101 Ahuachapán
m0102 Apaneca
m0103 Atiquizaya
m0104 Concepción de Ataco
m0105 El Refugio
m0106 Guaymango
m0107 Jujutla
m0108 San Francisco Menéndez
m0109 San Lorenzo
m0110 San Pedro Puxtla
@jrmoran
jrmoran / google-column-chart.js
Created March 7, 2012 03:57
playing with google charts
function drawVisualization() {
var col1 = ["AP","AP-PAN","ARENA","CD","CD-PNL","CDU","CDU-FMLN","CDU-PSD","FC","FDR","FDR-CD","FDR-PDC","FDR-PDC-CD","FMLN","FMLN-CD","FMLN-PDC","FMLN-PSD","PAN","PCN","PDC","PDC-FMLN","PDC-FMLN-CD","PDC-PMR-PSD","PDC-PSD","PMR","PMR-PDC","PMR-PDC-PSD-CDU","PMR-PSD","PMR-PSD-CDU","PNL","PPR","PSD"];
var col2 = ["AP","AP-PAN","ARENA","CD","CD-PNL","CDU","CDU-FMLN","CDU-PSD","FC","FDR","FDR-CD","FDR-PDC","FDR-PDC-CD","FMLN","FMLN-CD","FMLN-PDC","FMLN-PSD","PAN","PCN","PDC","PDC-FMLN","PDC-FMLN-CD","PDC-PMR-PSD","PDC-PSD","PMR","PMR-PDC","PMR-PDC-PSD-CDU","PMR-PSD","PMR-PSD-CDU","PNL","PPR","PSD"];
var table1 = [["2003",11990,374,491452,0,0,37629,84995,123,10208,0,0,0,0,471042,0,19739,259,11416,210056,104494,0,0,13105,592,26447,4101,2493,3104,374,0,20419,7773],["2006",0,0,791811,30778,24101,0,0,0,0,0,0,0,0,670711,106314,0,0,0,307330,173982,12192,0,0,0,0,0,0,0,0,2637,0,0],["2009",0,0,867273,25204,0,0,0,0,0,20962,6450,5020,1689,886161,237119,0,0,0,235989,185844,8755,7811,0,