View gitsubmodules_install.sh
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/sh | |
set -e | |
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | | |
while read path_key path | |
do | |
url_key=$(echo $path_key | sed 's/\.path/.url/') | |
url=$(git config -f .gitmodules --get "$url_key") | |
git submodule add $url $path | |
done |
View is_node.js
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
export default (o) => { | |
if (typeof o == 'undefined' || o === null) return false; | |
return (typeof Node == 'object' ? o instanceof Node : o && typeof o == 'object' && typeof o.nodeType == 'number' && typeof o.nodeName == 'string'); | |
}; |
View spinner.sh
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 | |
spinner() { | |
local i sp n | |
sp='/-\|' | |
n=${#sp} | |
printf ' ' | |
while sleep 0.1; do | |
printf "%s\b" "${sp:i++%n:1}" | |
done |
View isPromise.js
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
export default (val) => val && typeof val.then === 'function'; |
View toHex.js
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
export default (val) => ("0000000" + (val >>> 0).toString(16)).substr(-8); |
View hash_fnv32a.js
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
const FNV_OFFSET_32 = 0x811c9dc5; | |
export const hash_fnv32a (input) => { | |
let hval = FNV_OFFSET_32; | |
// Strips unicode bits, only the lower 8 bits of the values are used | |
for (var i = 0; i < input.length; i++) { | |
hval = hval ^ (input.charCodeAt(i) & 0xFF); | |
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24); | |
} | |
return hval >>> 0; | |
} |
View binary.js
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
//Hamming weight | |
export const getBitCount32 = (n) => { | |
n = n - ((n >> 1) & 0x55555555); | |
n = (n & 0x33333333) + ((n >> 2) & 0x33333333); | |
return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; | |
} | |
export const getBitCount = (n) => { | |
let str = n.toString(2), count = 0; | |
for (let i = str.length - 1; i >= 0; i--) { |
View array.js
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
export const shuffle = (array) => { | |
for (let i = array.length - 1; i > 0; i--) { | |
let rand = Math.floor(Math.random() * (i + 1)); | |
[array[i], array[rand]] = [array[rand], array[i]] | |
} | |
} | |
export const filter = (arr, cb) => { | |
var r = []; | |
for (let i = 0, c = arr.length; i < c; i++) { |
View disableTextSelection.js
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
export default { | |
WebkitTouchCallout: "none", | |
MozUserSelect: "none", | |
WebkitUserSelect: "none", | |
KhtmlUserSelect: "none", | |
msUserSelect: "none", | |
OUserSelect: "none", | |
userSelect: "none" | |
} |
View City.php
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
<?php | |
namespace App\Models; | |
class City extends Model { | |
/** | |
* The database table used by the model. | |
* @var string | |
*/ | |
protected $table = 'cities'; | |
public $timestamps = false; |
NewerOlder