This file contains 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 argv = require('optimist').argv; | |
var name = argv.n; | |
var fields = argv.p.split(','); | |
console.log('public class %s {', name); | |
eachField(function (field) { | |
createMember(field); | |
}) | |
eachField(function (field) { | |
createGetter(field); |
This file contains 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 assert = require('assert'); | |
var mongoose = require('mongoose'); | |
module.exports = { | |
'Model save callback should receive error on non unique names': function () { | |
var Schema = mongoose.Schema; | |
mongoose.model('User', new Schema({ | |
name: { type: String, unique: true } | |
})); |
This file contains 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
object FizzBuzz { | |
def apply(n: Int): String = { | |
(n % 3, n % 5) match { | |
case (0, 0) => "FizzBuzz" | |
case (0, _) => "Fizz" | |
case (_, 0) => "Buzz" | |
case _ => n toString | |
} |
This file contains 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
module.exports = function (n) { | |
var ret = ''; | |
if (n % 3 === 0) ret += 'Fizz'; | |
if (n % 5 === 0) ret += 'Buzz'; | |
return ret || n; | |
}; |
This file contains 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 fizzbuzz = require('fizzbuzz') | |
, should = require('should'); | |
module.exports = { | |
'should be a function' : function () { | |
fizzbuzz.should.be.an.instanceof(Function); | |
} | |
}; | |
[ |
This file contains 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
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.WordSpec | |
class FizzBuzzSpec extends WordSpec with ShouldMatchers { | |
"FizzBuzz" should { | |
List( | |
(1, "1") | |
, (2, "2") |
This file contains 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
#!/bin/sh | |
# | |
# watch.sh - the only file-changed-watcher you'll ever need! | |
# | |
# Usage: | |
# $ sh watch.sh "echo File changed" | |
# $ sh watch.sh make "-not -name *.swp" | |
# | |
# one liner variant: |
This file contains 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 spawn = require('child_process').spawn; | |
var i, | |
result = {}, | |
host = '192.168.0.%s' | |
start = 1, | |
end = 255, | |
total = end - start; | |
for (i = start; i < end; i += 1) { | |
connect(host.replace('%s', i), result, done); |
This file contains 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 roman = require('../lib/roman') | |
, should = require('should'); | |
module.exports = { | |
'test .version': function(){ | |
roman.version.should.match(/^\d+\.\d+\.\d+$/); | |
}, | |
'should expose toRoman' : function () { | |
roman.toRoman.should.be.a('function'); | |
}, |
This file contains 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
exports.version = '0.0.1'; | |
var lookup = [ | |
[1, 'i'] | |
, [4, 'iv'] | |
, [5, 'v'] | |
, [9, 'ix'] | |
, [10, 'x'] | |
, [40, 'xl'] | |
, [50, 'l'] |