Skip to content

Instantly share code, notes, and snippets.

@msuarz
msuarz / music.rb
Last active August 29, 2015 14:05
music folder cleanup
#encoding: IBM437
require 'rake'
require 'fileutils'
task :clean, :folder do |t, args|
Music.new(args.to_hash).cleanup
end
task :biggie, :folder do |t, args|
loadTasks = require 'load-grunt-tasks'
module.exports = (grunt) ->
env = process.env
cwd = process.cwd()
root = "#{cwd}/../../go"
src = "#{root}/src/#{env.src}"
command = (cmd, opts) ->
command: cmd
@msuarz
msuarz / game_of_life.coffee
Created December 2, 2011 14:07
Conway's Game of Life in Coffeescript
class exports.GameOfLife
constructor: (@cells) -> @read_board()
evolve: ->
for row in [0...@size]
for col in [0...@size]
@evolve_at row, col
evolve_at: (@row, @col, neighbors = @neighbors()) ->
@msuarz
msuarz / Calculator.js
Created February 14, 2012 01:55
Calculator
exports.Calculator = (function() {
function Calculator() {}
Calculator.prototype.square = function(x) {
return x * x;
};
return Calculator;
exports.build_multiple_files_engine = (done) ->
add_file 'people_perf_multiple', 'common', files.common, ->
add_file 'people_perf_multiple', 'test', files.test_common, ->
add_file 'people_perf_multiple', 'test1', files.test1, ->
add_file 'people_perf_multiple', 'test2', files.test2, done
@msuarz
msuarz / async.coffee
Created April 27, 2012 15:00
async vs step
async.series [
(done) -> fs.writeFile '/tmp/test', 'yay', ->
console.log 'yay!!'
done null
(done) ->
console.log 'hello'
done null
-> console.log 'world'
]
exports.benchmark = (user_options) ->
start user_options
queue = async.queue run, options.workers
queue.drain = finish
queue.push i for i in [1..options.runs]
class exports.Login
'when a user logs in': -> true
'it should be greeted': -> true
'when #{user} logs in': (user) -> true
'it should say #{msg}': (msg) -> true
@msuarz
msuarz / test.coffee
Created July 11, 2012 18:30
catching exceptions in callbacks
should = require 'should'
describe 'cool', ->
it 'is', (done) -> done()
it 'is not', (done) ->
process.nextTick ->
true.should.be.false
@msuarz
msuarz / gist:5062044
Last active December 14, 2015 08:59
wd = require('wd');
browser = wd.remote 'localhost', 9134
products = []
browser.init ->
browser.get "http://www.shopmania.es", ->
browser.elementById 'autocomplete_prod', (err, el)->
browser.clear el, (err)->
browser.type el, '3TL941C', (err)->