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
#!/usr/bin/env bash | |
function check_access () { | |
host=$1; shift | |
port=$1; shift | |
nc -zw 1 $host $port > /dev/null && echo yes || echo no | |
} | |
function set_property () { |
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 replaceUrl(key, newValue) { | |
var url = window.location.href, | |
separator = ~url.indexOf('?') ? '&' : '?', | |
re = new RegExp('([?&])' + key + '=(.*?)([?&]|$)', 'i'), | |
match = re.exec(url), | |
hasParam = !!match; | |
if (hasParam) { | |
if (match[2] === newValue || !newValue) { | |
return url.replace(re, ''); |
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 modelRating(rating, maxStars) { | |
return Array.apply(0, new Array(maxStars || 5)).map(function(ignore, index) { | |
var step = rating - index; | |
return step >= 1 ? 'full' : step >= 0.5 ? 'half' : 'empty'; | |
}); | |
} | |
modelRating(3) // ["full", "full", "full", "empty", "empty"] | |
modelRating(4.5) // ["full", "full", "full", "full", "half"] | |
modelRating(0) // ["empty", "empty", "empty", "empty", "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 insertSeparator(array, separator) { | |
var index = array.length - 1; | |
while (index) array.splice(index--, 0, separator); | |
return array; | |
} |
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/bash | |
# Pre-commit Git hook to run JSHint on JavaScript files. | |
# | |
# If you absolutely must commit without testing, | |
# use: git commit --no-verify | |
filenames=($(git diff --cached --name-only HEAD)) | |
which jshint &> /dev/null | |
if [ $? -ne 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
<html> | |
<head> | |
<script type="text/javascript"> | |
(function (d) { | |
var longTapTimer, | |
ael = 'addEventListener', | |
TAP_DELAY = 500, // ms | |
element = null, | |
onLongTap = 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
var version = '12.34'; | |
version = (function (major, minor) {return major + '.' + (++minor); }).apply(null, version.split('.')); | |
console.log(version); // 12.35 |
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
... | |
7 44 ms 47 ms 49 ms 30gigabitethernet1-3.core1.ams1.he.net [195.69.145.150] | |
8 56 ms 63 ms 56 ms 10gigabitethernet2-1.core1.par2.he.net [184.105.213.102] | |
9 134 ms 136 ms 137 ms 10gigabitethernet15-1.core1.ash1.he.net [184.105.213.93] | |
10 144 ms 149 ms 150 ms 10gigabitethernet1-2.core1.atl1.he.net [184.105.213.110] | |
11 143 ms 143 ms 143 ms 216.66.0.26 | |
12 * * * Request timed out. | |
13 182 ms 183 ms 185 ms Episode.IV [206.214.251.1] | |
14 182 ms 183 ms 185 ms A.NEW.HOPE [206.214.251.6] | |
15 183 ms 183 ms 183 ms It.is.a.period.of.civil.war [206.214.251.9] |
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 a = []; | |
console.log(a == false); // true | |
console.log(!a == false); // true | |
console.log(!!a == false); // false |
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
public class DBConnector { | |
public GlobalSaver gs = new GlobalSaver(); | |
// ... | |
} | |
public class GlobalSaver { | |
private static DBConnector dbc = new DBConnector(); | |
// ... | |
} |