This file contains 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
var FlatCoordinates = function () { | |
var FlatCoordinates = function FlatCoordinates (coordinates) { | |
this._coordinates = coordinates; | |
}; | |
FlatCoordinates.prototype.shift = function () { | |
var c = this._coordinates; | |
c.shift(); | |
c.shift(); |
This file contains 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
var styleFunction = (function () { | |
var fill = new ol.style.Fill({ color: 'rgba(255, 255, 255, 0.5)' }), | |
stroke = new ol.style.Stroke({ color: '#319FD3', width: 1 }), | |
textFill = new ol.style.Fill({ color: '#000' }), | |
textStroke = new ol.style.Stroke({ color: '#fff', width: 3 }), | |
cache = {}; | |
return function (feature, resolution) { | |
var text = resolution < 5000 ? feature.get('name') : ''; |
This file contains 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
#!/bin/bash | |
# | |
# Author: Ilia Choly <[email protected]> | |
# Year: 2014 | |
# | |
if [[ -z "$1" ]]; then | |
echo "usage: graph_memory.sh <pid>" | |
exit 1 | |
fi |
This file contains 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
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m, | |
FN_ARG_SPLIT = /,/, | |
FN_ARG = /^\s*(_?)(\S+?)\1\s*$/, | |
STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; | |
var fnSignature = function (fn) { | |
var fnText = fn.toString().replace(STRIP_COMMENTS, ''), | |
args = fnText.match(FN_ARGS); | |
if (!args) { return []; } | |
return args[1].split(FN_ARG_SPLIT).map(function (arg) { |
This file contains 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
package main | |
import ( | |
"fmt" | |
"net/http" | |
"runtime/pprof" | |
"sync" | |
) | |
var ( |
This file contains 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
(defmacro $ [&rest cmd] | |
(let [var? (fn [s] (s.startswith "$")) | |
rm-$ (fn [s] (slice s 1)) | |
`@(map (fn [s] (if (var? s) (rm-$ s) `'~s))) cmd) | |
(let [test "hello" | |
data ($ cat foo | grep $test)] | |
(print data) | |
This file contains 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
[ | |
{ | |
"song": "take it or leave it", | |
"artist": "cage the elephant" | |
}, | |
{ | |
"song": "afterlife", | |
"artist": "arcade fire" | |
}, | |
{ |
This file contains 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
<html> | |
<head> | |
<title>Change Image Color</title> | |
<style> | |
body { background-color: black; } | |
</style> | |
</head> | |
<body> | |
<canvas id="canvas"></canvas> | |
<script> |
- early return
- noun first in variable name
- use descriptive variable/parameter names
- descriptive code over pretty code
- composition over inheritance
- many simple/short functions
- be boring and explicit
- declare close to usage
- avoid global state
- don't document what you're doing, document why