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
| #!/usr/bin/python | |
| """ | |
| advanced-flood.py | |
| @author: Randall Degges | |
| @email: rdegges@gmail.com | |
| @date: 11-20-09 | |
| This program floods the specified phone number and spoofs caller ID making it |
| #!/usr/bin/env bash | |
| # | |
| # url : https://gist.github.com/672684 | |
| # version : 2.0.2 | |
| # name : appify | |
| # description : Create the simplest possible mac app from a shell script. | |
| # usage : cat my-script.sh | appify MyApp | |
| # platform : Mac OS X | |
| # author : Thomas Aylott <[email protected]> |
| #!/bin/sh | |
| # ------------------------------------------------------------------------------ | |
| # SOME INFOS : fairly standard (debian) init script. | |
| # Note that node doesn't create a PID file (hence --make-pidfile) | |
| # has to be run in the background (hence --background) | |
| # and NOT as root (hence --chuid) | |
| # | |
| # MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit | |
| # INIT-INFO RULES http://wiki.debian.org/LSBInitScripts | |
| # INSTALL/REMOVE http://www.debian-administration.org/articles/28 |
| var sip = require('sip'); | |
| var sys = require('sys'); | |
| var redis = require('redis'); | |
| //Trim leading and trailing whitespace from string values. | |
| function trim(str) { | |
| return str.replace(/^\s+|\s+$/g, ''); | |
| } | |
| sip.start({},function(request) { |
| // Run Redis - cd redis-2.2.4 and run src/redis-server | |
| var sip = require('sip'); | |
| var sys = require('sys'); | |
| var redis = require('redis'); | |
| var tropoapi = require('tropo-webapi'); | |
| //Trim leading and trailing whitespace from string values. | |
| function trim(str) { | |
| return str.replace(/^\s+|\s+$/g, ''); |
Some exercises from the Falsy Values workshops.
The good parts:
| // Dependencies. | |
| var express = require('express') | |
| app = module.exports = express.createServer(), | |
| del = function(req, res) { res.clearCookie('login_token'); res.redirect('/'); }, | |
| set = function(req, res) { res.cookie('login_token', +new Date(), { maxAge: 3600000, path: '/' }); res.redirect('/'); }; | |
| // Config | |
| app.configure(function() { | |
| app.use(express.bodyParser()); | |
| app.use(express.cookieParser()); |
| for (var i = 0; i < 1024 * 1024; i++) { | |
| process.nextTick(function () { Math.sqrt(i) } ) | |
| } |
| // {{compare unicorns ponies operator="<"}} | |
| // I knew it, unicorns are just low-quality ponies! | |
| // {{/compare}} | |
| // | |
| // (defaults to == if operator omitted) | |
| // | |
| // {{equal unicorns ponies }} | |
| // That's amazing, unicorns are actually undercover ponies | |
| // {{/equal}} | |
| // (from http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/) |