Skip to content

Instantly share code, notes, and snippets.

@nimbus154
nimbus154 / coroutines.js
Last active February 8, 2016 17:08
Using & testing coroutines in Node.js with co & tape
const bluebird = require('bluebird');
const co = require('co');
const fs = bluebird.promisifyAll(require('fs'));
const _ = require('lodash');
function lsPromise() {
return co(function* () {
let paths = { current: '.', root: '/' };
return yield _.mapValues(paths, path => fs.readdirAsync(path));
});
@nimbus154
nimbus154 / install_node.sh
Created March 14, 2014 19:21
Simple Node.js setup
apt-get -y install wget
cd /tmp
wget http://nodejs.org/dist/v0.10.22/node-v0.10.22-linux-x64.tar.gz
tar -zxf node-v0.10.22-linux-x64.tar.gz
rm node-v0.10.22-linux-x64.tar.gz
mkdir /usr/local/node
mv node-v0.10.22-linux-x64 /usr/local/node/0.10.22
ln -s /usr/local/node/0.10.22/bin/node /usr/local/bin/node
ln -s /usr/local/node/0.10.22/bin/npm /usr/local/bin/npm
@nimbus154
nimbus154 / dictionary.py
Created April 21, 2013 23:54
An example of how to write functional tests for a RESTful API using the Bottle microframework.
from bottle import get, run, request, post, Bottle, abort, error, response, debug, redirect
# This is a dictionary endpoint. It retrieves definitions for words.
# You can also add words to the dictionary.
# this allows our bottle application to be accessible outside this file
app = Bottle()
dictionary = {
"lugubrious": "extremely sad",