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 DYNAMIC_CACHE = 'dynamic-cache-{{ site.time | date: "%s" }}'; | |
var STATIC_CACHE = 'static-cache-{{ site.time | date: "%s" }}'; | |
// listen for outgoing network request | |
self.addEventListener('fetch', function (event) { | |
// try to find response object in the cache | |
// associated with current request |
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 convertBase(value, fromBase) { | |
return value.split('').reverse().reduce(function (carry, digit, index) { | |
const digitVal = digit.charCodeAt(0); | |
if (digitVal >= fromBase) throw new Error('Invalid digit `' + digit + '` for base ' + fromBase + '.'); | |
return carry += digitVal * (Math.pow(fromBase, index)); | |
}, 0); | |
} | |
function encode(value, toBase = 65535 /* safe range */) { | |
var utf8 = value.toString().split('').map(function(x) { |
This file has been truncated, but you can view the full file.
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
[ | |
{ | |
"occupation_code": "00-0000", | |
"occupation_title": "All Occupations", | |
"level": "total", | |
"employment": "142,549,250", | |
"employment_rse": "0.1%", | |
"employment_per_jobs": "1000.000", | |
"median_hourly_wage": "$18.12", | |
"mean_hourly_wage": "$24.34", |
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
class Heap { | |
constructor() { | |
this.items = []; | |
} | |
seek() { return this.items[0]; } | |
} | |
export class MaxHeap extends Heap { |
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
// (c) 2018 Sem Postma | |
// This code is licensed under MIT license | |
(function () { | |
var endScopeObj = {}; | |
window.obj2xml = function (obj, opt) { | |
if (!opt) opt = {}; | |
var rootName = opt.rootName || 'root'; | |
var declaration = opt.declaration === 'auto' ? '<?xml version="1.0" encoding="utf-8"?>' : opt.declaration; | |
var indentation = opt.indentation || 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 obj2csv(obj, opt) { | |
if (typeof obj !== 'object') return null; | |
opt = opt || {}; | |
var scopechar = opt.scopechar || '/'; | |
var delimeter = opt.delimeter || ','; | |
if (Array.isArray(obj) === false) obj = [obj]; | |
var curs, name, rownum, key, queue, values = [], rows = [], headers = {}, headersArr = []; | |
for (rownum = 0; rownum < obj.length; rownum++) { |
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
const { Architect, Trainer } = synaptic; | |
const int = Math.floor; | |
const catagorical = i => { | |
const arr = new Array(26).fill(0); | |
arr[i] = 1; | |
return arr; | |
}; | |
Jimp.loadFont(Jimp.FONT_SANS_16_BLACK).then(function (font) { |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Neural network</title> | |
</head> | |
<body> | |
<h3 id="msg">Training Neural Network...</h3> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/browser/lib/jimp.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/synaptic/1.1.4/synaptic.min.js"></script> |
NewerOlder