Skip to content

Instantly share code, notes, and snippets.

View kuno's full-sized avatar

kuno kuno

View GitHub Profile

Readline

To use this module, do require('readline').

rl.createInterface(input, output, completer)

Takes two streams and creates a readline interface. The completer function is used for autocompletion. When given a substring, it returns [substr, completedStr]. TODO: write some code to make sure I'm right.

createInterface is commonly used with process.stdin and process.stdout in order to accept user input:

@kuno
kuno / gist:947846
Created April 29, 2011 04:41 — forked from jb55/gist:945731
replace nginx with connect
var connect = require('connect')
, proxy = require('http-proxy')
function redirect(loc) {
return connect.createServer(function(req, res){
res.writeHead(301, { "Location": loc });
res.end();
});
}
@kuno
kuno / nodeconf_2011.md
Created May 6, 2011 23:51 — forked from guybrush/nodeconf_2011.md
a list of slides from nodeconf 2011
@kuno
kuno / dart.txt
Created September 22, 2011 23:00 — forked from paulmillr/dart.md
Leaked internal google dart email
---------- Forwarded message ----------
From: Mark S. Miller <[email protected]>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: [email protected]
On November 10th and 11th, a number of Google teams representing a variety
of viewpoints on client-side languages met to agree on a common vision for
the future of Javascript.
@kuno
kuno / amazon_sender.py
Created September 26, 2011 12:51 — forked from amix/amazon_sender.py
Amazon SES helper script using boto
# -*- coding: utf-8 -*-
"""
amazon_sender.py
~~~~~~~~
Python helper class that can send emails using Amazon SES and boto.
The biggest feature of this class is that encodings are handled properly.
It can send both text and html emails.
This implementation is using Python's standard library (which opens up for a lot more options).
import re
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@kuno
kuno / model_caching.coffee
Created December 8, 2011 03:55 — forked from rstacruz/model_caching.coffee
Backbone.js model caching
# ## Backbone model caching
# This is a simple solution to the problem "how do I make less requests to
# my server?".
#
# Whenever you need a model instance, this will check first if the same thing
# has been fetched before, and gives you the same instance instead of fetching
# the same data from the server again.
#
# Reusing the same instance also has the great side-effect of making your
# model changeable from one part of your code, with your changes being available
@kuno
kuno / nginx.conf
Created February 7, 2012 15:51 — forked from timmyomahony/nginx.conf
Python, UWSGI, Supervisor & Nginx
upstream uwsgi {
ip_hash;
server 127.0.0.1:40000;
}
server {
listen 80;
server_name www.domain.com;
root /sites/mysite/;
access_log /sites/mysite/log/nginx/access.log;