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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
// do not use result cache, nor line and column tracking | |
{ var indentStack = [], indent = ""; } | |
start | |
= INDENT? lines:( blank / line )* | |
{ return lines; } | |
line | |
= SAMEDENT line:(!EOL c:. { return c; })+ EOL? |
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
#!/bin/sh | |
# prerequisite: sudo su - postgres | |
CONFIGURATION_FILE="/etc/postgresql/9.4/main/pg_hba.conf" | |
CURRENT_IP=$(last -i | grep "still logged" | awk '{ print $3 }') | |
IPV4_REGEX="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" | |
if [ ! -f "$CONFIGURATION_FILE" ]; then | |
echo "File not found: $CONFIGURATION_FILE" | |
exit 1 |
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
var node = { | |
value: -120, | |
left: { | |
value: -2120, | |
left: { value: -20 }, | |
right: { value: -30 } | |
}, | |
right: { | |
value: -20, | |
left: {value: 20 }, |
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
/** | |
* Command Dispatcher for managing {@code App.Command}. | |
* | |
* {@link http://en.wikipedia.org/wiki/Command_pattern|Command Pattern} | |
*/ | |
App.CommandController = Ember.Controller.extend({ | |
commands: null, | |
result: null, | |
position: 0, | |
maxRedo: 0, |
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(History) { | |
if (!Ember.Object.detectInstance(History)) { | |
throw new Error("Native `Ember.History` is already defined."); | |
} | |
if (Ember.Evented.detect(History)) { | |
return; | |
} else { | |
History.reopen(Ember.Evented); | |
} |
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
describe('filterObject', function () { | |
it('should filter out falsey values', function () { | |
var actual = filterObject({ | |
empty: '', | |
depth: 0, | |
nested: { | |
empty: '', | |
depth: 1, | |
nested: { | |
empty: '', |
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() { | |
if (!/youtube.com$/i.test(location.host)) { | |
alert("hostname does not match 'youtube.com'"); | |
return; | |
} | |
var timeout; | |
var resume; | |
var repeat = function repeat() { | |
clearTimeout(timeout); |
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
var util = require('util'); | |
var chalk = require('chalk'); | |
var LOG_TYPE = chalk.bold.black('[') + '%s' + chalk.bold.black(']') + ':'; | |
var ALL = { | |
type: 'ALL' | |
}; | |
var TRACE = { | |
type: 'TRACE', | |
fn: console.log, |
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 pad(n, count) { | |
// http://stackoverflow.com/a/15398371 | |
var length = (Math.log(Math.abs(n + 1)) * 0.43429448190325176 | 0) + 1; | |
count = Math.max(count - length, 0); | |
if (n < 10) { | |
return n; | |
} | |
// http://stackoverflow.com/a/5450113 |