This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
span { | |
display: inline-block; | |
background: url(IMAGE); | |
width: 156px; | |
height: 154px; | |
border: 1px solid blue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nodes = <<<HTML | |
<div> | |
div | |
<p> ... </p> | |
</div> | |
HTML; | |
$dom = new DOMDocument; | |
$dom->loadHTML($nodes); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Old, bad, antiquated way | |
var value = db.synchronousRead("SELECT value"); | |
emit(value); | |
// Good, asynchronous way | |
db.asynchronousRead("SELECT value").done(function (value) { | |
emit(value); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Serial, naive implementation | |
// one and two are not dependent on each other | |
db.read("SELECT ONE").done(function (one) { | |
db.read("SELECT TWO").done(function (two) { | |
emit(one, two); | |
}); | |
}); | |
// Parallel | |
var async = require("async"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PS1='\[\e[01;32m\]andrew\[\e[01;3$(($RANDOM % 8))m\]@\[\e[01;32m\]home \[\e[01;31m\]\w \[\e[01;33m\]$\[\e[0m\] ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
randomize_prompt_color () { | |
git=$(git_prompt_info) | |
if [ -n "$git" ]; then | |
git="$git " | |
fi | |
PROMPT="%{$fg_bold[green]%}%n%F{$((RANDOM % 8))}@%{$fg[magenta]%}%m %{$fg_bold[cyan]%}%~ %{$fg_bold[blue]%}$git%{$fg_bold[red]%}%(!.#.\$) %{$reset_color%}" | |
if [ -n "$VIRTUAL_ENV" ]; then | |
PROMPT="(pyvenv: $(basename $VIRTUAL_ENV)) $PROMPT" | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function required(params) { | |
return function (req, res, cb) { | |
params.every(function (elem) { return req.body.hasOwnProperty(elem); }) | |
&& cb() | |
|| res.send(400); | |
}; | |
}; | |
/** | |
* Sample route |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// quotes around keys are not required | |
( {key: "value"} ); | |
// many JS parsers allow a trailing comma in a list | |
( [{"name": "value"},] ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* syntax errors */ | |
{"k": "v"} | |
function () {}() | |
/* valid */ | |
( {"k":"v"} ) | |
( function () {}() ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON().done(function (json) { | |
$.parseJSON(json); | |
}); |