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
Q = require 'q' | |
_ = require 'underscore' | |
photos = [1..100] | |
partition = (n, coll) -> | |
_.values(_.groupBy(coll, (x, i) -> Math.floor i/n)) | |
scaleImage = (img, i) -> | |
Q.delay(200).then -> console.log "processed image #{i}" |
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
module Helpers | |
def select2(scope, opts) | |
scope.find('.select2-choice').click | |
if opts.has_key? :type_in | |
input = find '.select2-drop-active:not(.select2-offscreen) .select2-search .select2-input' | |
input.set opts[:type_in] | |
input.trigger('keyup-change') | |
end |
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
// james-coffee/index.js | |
var james = require('james'), | |
coffee = require('coffee-script'); | |
coffee.createStream = function() { | |
return james.createTransformation(function(content, callback) { | |
// Process the file content and call the callback with the result. | |
try { | |
res = coffee.compile(content); |
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
module.exports = class FooController | |
get: ({params: {foo}}, res) -> | |
get("http://localhost:9292/api/#{foo}.json") | |
.then (response) -> | |
res.status response.status | |
if response.status == 200 | |
then res.end JSON.stringify transformResponse response.body | |
else res.end response.text |
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
reduce = (f, initial) -> (xs) -> Array::reduce.call xs, f, initial | |
butlast = (xs) -> xs.slice 0, xs.length - 1 | |
sum = (x, y) -> x + y | |
addInputStream = (xs) -> | |
input = $('<input />') | |
.appendTo('#inputs') | |
.asEventStream('input') | |
.map('.target.value') | |
.map(parseInt) |
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
express = require 'express' | |
http = require 'http' | |
app = express() | |
app.get '/hello', (_, res) -> res.send "Hello world!" | |
http.createServer(app).listen 3000 | |
http.createServer(app).listen 3010 |
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
search: ({query: {q}}, res) => | |
@collection.then((coll) -> | |
coll.find(key: new RegExp(q, 'i')) | |
.sort(_id: -1) | |
.limit(20) | |
.stream() | |
.pipe(JSONStream.stringify()) | |
.pipe(res)) | |
.done() |
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
#!/usr/bin/python | |
from sys import * | |
import xlrd | |
import csv | |
def to_utf8(val): | |
if isinstance(val, basestring): | |
return val.encode('utf-8') | |
else: |
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
bin/ansible:#!/usr/bin/env python | |
bin/ansible-doc:#!/usr/bin/env python | |
bin/ansible-galaxy:#!/usr/bin/env python | |
bin/ansible-playbook:#!/usr/bin/env python | |
bin/ansible-pull:#!/usr/bin/env python | |
docsite/build-site.py:#!/usr/bin/env python | |
examples/scripts/uptime.py:#!/usr/bin/python | |
hacking/module_formatter.py:#!/usr/bin/env python | |
hacking/test-module:#!/usr/bin/env python | |
lib/ansible/runner/action_plugins/synchronize.py:#!/usr/bin/python |
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
fs = require 'fs' | |
{Transform} = require 'stream' | |
class Reverser extends Transform | |
_transform: (data, encoding, done) -> | |
@push data.toString().split('').reverse().join '' | |
done() | |
class UpperCaser extends Transform | |
_transform: (data, encoding, done) -> |