A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
For Mac users, I highly recommend iTerm 2 + Solarized Dark
#! /usr/bin/env bash | |
function nEnabled { | |
system_profiler -detailLevel mini SPAirPortDataType | grep -e 'Supported PHY Modes: .*n' | |
} | |
until nEnabled && sleep 2 && nEnabled; | |
do | |
echo 'resetting airport' | |
networksetup -setairportpower en1 off; networksetup -setairportpower en1 on |
var foo = require('./foo') | |
, barOfFoo = moduleOfModule('./bar', './foo') | |
function moduleOfModule(module, ofModule) { | |
var c = require.cache[require.resolve(ofModule)] | |
, f = require.resolve(module, c) | |
, r | |
c.children.some(function(c) { | |
if(c.filename === f) { | |
r = c.exports |
JSON._dateReviver = function (k,v) { | |
if (v.length !== 24 || typeof v !== 'string') return v | |
try {return new Date(v)} | |
catch(e) {return v} | |
} | |
JSON.parseWithDates = function (obj) { | |
return JSON.parse(obj, JSON._dateReviver); | |
} |
// Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp. | |
// Captures within lookbehind are not included in match results. Lazy | |
// repetition in lookbehind may lead to unexpected results. | |
(function (XRegExp) { | |
function prepareLb(lb) { | |
// Allow mode modifier before lookbehind | |
var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb); | |
return { |
#!/bin/bash | |
# list of programs we depend on | |
progs="xdpyinfo grep head sed ffmpeg pacat parec sox" | |
# check for programs we depend on | |
result=0 | |
for prog in $progs | |
do | |
type -p $prog > /dev/null |
This is about getting rid of Dependency Injection Container and DI practices taken from Java. Good bye Java, viva la PHP!
We start with common example. Session.
<?php
class SessionStorage {
function __construct()
// Named constants with unique integer values | |
var C = {}; | |
// Tokenizer States | |
var START = C.START = 0x11; | |
var TRUE1 = C.TRUE1 = 0x21; | |
var TRUE2 = C.TRUE2 = 0x22; | |
var TRUE3 = C.TRUE3 = 0x23; | |
var FALSE1 = C.FALSE1 = 0x31; | |
var FALSE2 = C.FALSE2 = 0x32; | |
var FALSE3 = C.FALSE3 = 0x33; |
/* | |
A simple newline delimited JSON protocol. | |
Receiving Usage: | |
protocol = require('./json-protocol'); | |
// parsing data | |
parser = protocol.StreamParser(); |
/** | |
* __proto__ and prototype | |
* - the __proto__ property the instance's 'parent' up the prototype chain | |
* - the prototype property refers what new instances of the type will have their __proto__ set to, i.e. what will be the new instance's 'parent' up the prototype chain | |
*/ | |
/* Given */ | |
function Object () {} | |
Object.prototype = { | |
__proto__: null |