This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'posterous' | |
require 'time' | |
# Add your credentials Here | |
Posterous.config = { | |
'username' => '<email-address>', | |
'password' => '<password>', | |
'api_token' => '<api-token>' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
$ -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timeIt = (f)-> | |
start = Date.now() | |
f() | |
console.log 'time: ', Date.now() - start, 'ms' | |
adder = -> | |
total = 0 | |
((n = 0)-> total += n) | |
timeIt -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn buzziffy [a b x] | |
(cond (and (zero? (mod x a)) (zero? (mod x b))) "FizzBuzz" | |
(zero? (mod x a)) "Fizz" | |
(zero? (mod x b)) "Buzz" | |
:else x)) | |
(println (apply str (map #(str (buzziffy 3 5 %) "\n") | |
(range 1 100)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def std(nums): return math.sqrt(sum([pow(n - sum(nums)/len(nums),2) for n in nums])/len(nums)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = console.log; | |
// # objects are truthy | |
var b = new Boolean(); // Never use the Boolean constructor | |
p( b.toString() ); // 'false' | |
p( b == false ); // true, use strict equality comparison with === | |
p( b === false ); // false | |
p( b ? 'yeah' : 'nope' ); // yeah |