Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
Some exercises from the Falsy Values workshops.
The good parts:
var http = require('http'); | |
var server = http.createServer(function (req, resp) { | |
if(req.url.match('redir')) { | |
resp.writeHead(301, {'Location':'http://google.com/', 'Expires': (new Date).toGMTString()}); | |
resp.end(); | |
} else { | |
resp.writeHead(200, {'content-type': 'text/plain', 'content-length':4}); | |
resp.end('Main'); | |
} | |
}); |
#!/bin/sh | |
SDK=`dirname $0` | |
SCRIPT=`basename $0` | |
SDKPARENT=`dirname $SDK` | |
PLATFORM=`uname -sp` | |
if [ "$PLATFORM" = "Darwin i386" -o "$PLATFORM" = "Darwin x86_64" ]; then | |
echo "iPhone Toolchain installer script by rpetrich" | |
echo "" |
// | |
// main.m | |
// ProtectTest | |
// Demonstrates newer versions of iOS now support PROT_EXEC pages, for just-in-time compilation. | |
// | |
// Must be compiled with Thumb disabled | |
// | |
// Created by Stuart Carnie on 3/4/11. | |
// Copyright 2011 Manomio LLC. All rights reserved. | |
// |
hw.ncpu: 1 | |
hw.byteorder: 1234 | |
hw.memsize: 527433728 | |
hw.activecpu: 1 | |
hw.physicalcpu: 1 | |
hw.physicalcpu_max: 1 | |
hw.logicalcpu: 1 | |
hw.logicalcpu_max: 1 | |
hw.cputype: 12 | |
hw.cpusubtype: 9 |
#! /bin/bash | |
# | |
# Program : iphone4.2-node-configure | |
# Authors : Nathan Rajlich (nathan@tootallnate.net) | |
# Michael Aaron Safyan (michaelsafyan@gmail.com) | |
# Synopsis : This program runs the "configure" script for Node.js. | |
# An install prefix of "/opt/iphone-4.2/" is used. | |
unset CPATH |
#! /bin/bash | |
# | |
# Program : iphone4.2-node-configure | |
# Authors : Nathan Rajlich (nathan@tootallnate.net) | |
# Michael Aaron Safyan (michaelsafyan@gmail.com) | |
# Synopsis : This program runs the "configure" script for Node.js. | |
# An install prefix of "/opt/iphone-4.2/" is used. | |
unset CPATH |
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; | |
NSLog(@"bundleRoot:%@",bundleRoot); | |
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:nil]; | |
NSLog(@"dirContents:%@",dirContents); |
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ | |
if([text isEqualToString:@"\n"]){ | |
[textView resignFirstResponder]; | |
return NO; | |
} | |
return YES; |
require 'rubygems' | |
require 'open-uri' | |
require 'sinatra' | |
require 'json' | |
require 'digest/sha1' | |
configure do | |
set :developer_key, ENV['LAYAR_DEVELOPER_KEY'] || "" | |
set :user_agent, ENV['USER_AGENT'] || "Layar (hsbchk) / 1.0" | |
end |