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.
var user = { | |
validateCredentials: function (username, password) { | |
return ( | |
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' } | |
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' } | |
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' } | |
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' } | |
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' } | |
: false | |
); |
var color = require('colors'); | |
var stdin = process.openStdin() | |
, slides = { | |
1: "\tNode.js" + | |
"\n\n\t\tJavascript running on the server" + | |
"\n\n\t\tWritten in C++ (POSIX)" + | |
"\n\n\t\tWraps V8 JS VM (Google/Chrome)" | |
, 2: "\tOthers / Evented I/O" + | |
"\n\n\t\t > Reactor Pattern" + | |
"\n\n\t\t > EventMachine(Ruby) / Twisted (Python)" + |
var flatiron = require('flatiron') | |
, connect = require('connect') | |
, path = require('path') | |
, fs = require('fs') | |
, plates = require('plates') | |
, director = require('director') | |
, util = require('util') | |
, keys = require('./auth_keys') | |
, passport = require('passport') | |
, TwitterStrategy = require('passport-twitter').Strategy |
Type | Name | Description |
---|---|---|
int64_t | arg0, ..., arg9 | The first ten input arguments to a probe represented as raw 64-bit integers. If fewer than ten arguments are passed to the current probe, the remaining variables return zero. |
array | args[] | The typed arguments to the current probe, if any. The args[] array is accessed using an integer index, but each element is deined to be the type corresponding to the given probe argument. For example, if args[] is referenced by a read(2)system call probe, args[0] is of type int, args[1] is of type void *, and args[2] is of type size_t. |
uintptr_t | caller | The program counter location of the current thread just before entering the current probe. |
chipid_t | chip | The CPU chip identiier for the current physical chip. |
processorid_t | cpu | The CPU identiier for the current CPU. |
cpuinfo_t | *curcpu | The CPU information for the current CPU. |
lwpsinfo_t | *curlwpsinfo | The lightweight process (LWP) state of the LWP a |
// just a quick brainstorm for my dynamo API: https://github.com/jed/dynamo | |
// is it worth it to use uglify-js to parse functions into ASTs, to be transformed into dynamo's non-standard query language? | |
// the good: | |
// - no need to learn new API, just use javascript to query | |
// - API ends up resembling well-known .map and .filter style | |
// - would be entirely optional, compiling into specifiable query objects | |
// the bad: |
// Lack of tail call optimization in JS | |
var sum = function(x, y) { | |
return y > 0 ? sum(x + 1, y - 1) : | |
y < 0 ? sum(x - 1, y + 1) : | |
x | |
} | |
sum(20, 100000) // => RangeError: Maximum call stack size exceeded | |
// Using workaround |
/* | |
Pascal's triangle | |
0 001 | |
1 001 001 | |
2 001 002 001 | |
3 001 003 003 001 | |
4 001 004 006 004 001 | |
5 001 005 010 010 005 001 | |
6 001 006 015 020 015 006 001 |
#!/bin/bash | |
# Script to backup git repo to S3 | |
# Set bucket, dir, password and account to use for the backup. I keep mine in local env vars | |
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc | |
bucket=$GITHUB_BACKUP_BUCKET | |
dir=$GITHUB_BACKUP_DIR | |
password=$GITHUB_BACKUP_PASSWORD | |
account=$GITHUB_ACCOUNT |
/** | |
* The Article domain object, this can be completely custom or | |
* part of some ORM. It doesn't really matter. It's an object you | |
* can call methods on. As long as you return some compatible | |
* promise-like thing to the data/render cycle | |
*/ | |
var util = require('util') | |
, Q = require('q') // https://github.com/kriskowal/q | |
, db = require('./data-layer') | |
, Domain = require('./domain'); |