Opinions are like assholes, every one has got one.
This one is mine.
Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.
| // Javascript Doubly Ended Queue | |
| var Dequeue = function() { | |
| this._head = new Dequeue.Node(); | |
| this._tail = new Dequeue.Node(); | |
| this._head._next = this._tail; | |
| this._tail._prev = this._head; | |
| } | |
| Dequeue.Node = function(data) { | |
| this._data = data; |
| # 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 |
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: carbon-cache | |
| # Required-Start: $remote_fs $syslog | |
| # Required-Stop: $remote_fs $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: carbon-cache init script | |
| # Description: An init script for Graphite's carbon-cache daemon. | |
| ### END INIT INFO |
| module.exports = setup; | |
| setup.consumes = ["http"]; | |
| function setup(config, imports, register) { | |
| imports.http.wrap(require('./middleware')(config)); | |
| register(); | |
| } |
| // | |
| // Calculating prime factors in polynomial time using node.js process.prevTick() | |
| // | |
| // see: http://en.wikipedia.org/wiki/Prime_factor | |
| // see: http://en.wikipedia.org/wiki/Novikov_self-consistency_principle | |
| // | |
| // Authors: | |
| // http://jesusabdullah.net/ | |
| // http://marak.com | |
| // |
| def greet(first:string, last:string) { | |
| ret "Hello " + first + " " + last | |
| } | |
| var cluster = require('cluster'); | |
| var PORT = +process.env.PORT || 1337; | |
| if (cluster.isMaster) { | |
| // In real life, you'd probably use more than just 2 workers, | |
| // and perhaps not put the master and worker in the same file. | |
| cluster.fork(); | |
| cluster.fork(); | |
| cluster.on('disconnect', function(worker) { |
| # setup fd 3 as udp connection to drone | |
| exec 3<>/dev/udp/192.168.1.1/5556 | |
| # takeoff | |
| echo -e "AT*REF=1,512\r" >&3 | |
| # landing | |
| echo -e "AT*REF=2,0\r" >&3 | |
| ... | |
| # profit? |
| function params(fn) { | |
| var str = fn.toString(); | |
| var sig = str.match(/\(([^)]*)\)/)[1]; | |
| if (!sig) return []; | |
| return sig.split(', '); | |
| } | |
| console.api = function(obj){ | |
| console.log(); | |
| var proto = Object.getPrototypeOf(obj); |