Skip to content

Instantly share code, notes, and snippets.

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;
}
export default (val) => ("0000000" + (val >>> 0).toString(16)).substr(-8);
export default (val) => val && typeof val.then === 'function';
#!/bin/bash
spinner() {
local i sp n
sp='/-\|'
n=${#sp}
printf ' '
while sleep 0.1; do
printf "%s\b" "${sp:i++%n:1}"
done
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');
};
@di3
di3 / City.php
Last active May 17, 2019 13:45
laravel city model
<?php
namespace App\Models;
class City extends Model {
/**
* The database table used by the model.
* @var string
*/
protected $table = 'cities';
public $timestamps = false;
#!/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