Skip to content

Instantly share code, notes, and snippets.

var http = require('http');
var nerve = exports;
nerve.serve = function(app, port, host) {
function send_html(content, status_code) {
this.sendHeader(status_code || 200, {"Content-Type":"text/html","Content-Length":content.length});
this.sendBody(content);
this.finish();
}
var http = require('http');
// example usage:
//
// require('./nerve');
//
// nerve([
// [/^\/hello\/(.*)$/, function(req, res, name) {
// res.send_html('Hello, ' + name + '!');
// }]
var http = require('http');
// example usage:
//
// var nerve = require('./nerve');
//
// nerve.create_app(
// [
// [/^\/hello\/(.*)$/, function(req, res, name) {
// res.send_html('Hello, ' + name + '!');
// this returns undefined, not the object that follows the return
return
{
foo: "bar"
};
/*global require, process */
(function() {
var http = require('http'), posix = require('posix'), url = require('url'), cache = {}, mime_types = {};
function extname(path) {
var index = path.lastIndexOf('.');
if (index < 0) {
return;
}
return path.slice(index + 1);
var sys = require("sys"),
http = require("http");
data = '/';
url = 'www.google.com';
url = 'www.neeraj.name'
var con = http.createClient(80, url);
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import random
class SimpleCounterShard(db.Model):
count = db.IntegerProperty(required=True, default=0)
NUM_SHARDS = 10
var http = require('http'),
sys = require('sys'),
couchdb = require('./lib/couchdb'),
port = process.env.PORT || 8001,
COUCH_PORT = 5984,
COUCH_SERVER = 'localhost',
COUCH_USER = null,
COUCH_PASSWORD = null;
function getCounter(callback) {
@gjritter
gjritter / gist:3876791
Created October 12, 2012 01:14
Custom segue to flip between a source and destination controller within a navigation controller
- (void) perform {
UIViewController* source = self.sourceViewController;
[UIView transitionWithView:source.navigationController.view duration:0.5f options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
[source.navigationController setViewControllers:@[self.destinationViewController] animated:NO];
} completion:nil];
}
@gjritter
gjritter / gist:4597854
Created January 22, 2013 19:52
The setSelected:animated: and setHighlighted:animated: methods of UITableViewCell appear to make all of the selected background view's subviews transparent. This is annoying when the selected background view contains views that you intend to be non-transparent (like the custom dividers in this example). It necessitates having to add the colors b…
- (id) initWithCoder:(NSCoder*) coder {
if (self = [super initWithCoder:coder]) {
self.backgroundView = [self createBackgroundViewWithBackgroundColor:[UIColor clearColor]];
self.selectedBackgroundView = [self createBackgroundViewWithBackgroundColor:[UIColor colorWithWhite:57.0f/255.0f alpha:1.0f]];
}
return self;
}
- (UIView*) createBackgroundViewWithBackgroundColor:(UIColor*) backgroundColor {
UIView* backgroundView = [[UIView alloc] initWithFrame:self.bounds];