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
navigator.serviceWorker.getRegistrations() | |
.then(function(registrations) { | |
for(let registration of registrations) { | |
registration.unregister() | |
.then(function() { | |
return self.clients.matchAll(); | |
}) | |
.then(function(clients) { | |
clients.forEach(client => { | |
if (client.url && "navigate" in client) { |
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
# Apache 2 rewrite rule for single page apps | |
RewriteCond %{REQUEST_URI} (?<!\.mpeg|\.html|\.mp4|.\json|\.css|\.xml|\.eot|\.gif|\.ico|\.jpeg|\.jpg|\.JPEG|\.JPG|\.js|\.gif|\.GIF|\.png|\.PNG|\.svg|\.swf|\.ttf|\.woff|\.woff2|\.jsonp|\.webp|\.svgz|\.ttc|\.mp3|\.m4a|\.f4a|\.f4v|\.webm|\.m4v|\.f4v|\.f4p|\.ogv|\.ogg|\.oga)$ | |
RewriteCond %{REQUEST_URI} !(.*)/$ | |
RewriteRule . /index.html |
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
"name": "xt-boilerplate", | |
"version": "1.0.0", | |
"private": true, | |
"description": "An unopinionated boilerplate for creating web applications", | |
"main": "src/index.js", | |
"lint-staged": { | |
"linters": { | |
"*.{ts,js,tsx,t.ds}": [ | |
"prettier --write", | |
"eslint --fix", |
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 | |
npm run build | |
# get the current branch name and create a directory destination using it | |
dest_dir="project-dir/$(git rev-parse --abbrev-ref HEAD)" | |
# make the destination directory | |
mkdir -p $dest_dir | |
# copy the web build |
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 getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
function generateRandomNumbers(length) { | |
var numArray = []; | |
for (var i = 0; i < length; i++) { | |
numArray[i] = getRandomInt(1, 10000); | |
} | |
return numArray; |
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
// Example use of $.globalEval | |
$.globalEval(data) | |
// Refactor for CSP | |
eval.call(null, data) |
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
// Main thread | |
var test = document.getElementById('test'); | |
drawWorker = work(require('./draw-worker.js')); | |
drawWorker.addEventListener('message', function(e) { | |
if (e.data.msg === 'tick') { | |
sketchUpdateFn(); | |
} | |
}); | |
drawWorker.postMessage({draw: true, rate: appFrameRate}); | |
drawWorker.onerror = function(e) { |
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
/** | |
* returns the largest negative number in a given array | |
* @param {Array} arr [the array to act on] | |
* @return {Number} [the largest negative number] | |
*/ | |
function getLargestNegNumInArr(arr) { | |
return arr.reduce(function(prevVal, curVal) { | |
if (curVal < prevVal) { | |
prevVal = curVal; | |
} |
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
/** | |
* returns the largest positive number in a given array | |
* @param {Array} arr [the array to act on] | |
* @return {Array} [the largest number] | |
*/ | |
function getLargestPosNumInArr(arr) { | |
return arr.reduce(function(prevVal, curVal) { | |
if (curVal > prevVal) { | |
prevVal = curVal; | |
} |
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
p5.SoundFile.prototype.setVolume = function (vol, rampTime, tFromNow, volFrom, volTo) { | |
if (typeof vol === 'number') { | |
var rampTime = rampTime || 0; | |
var tFromNow = tFromNow || 0; | |
var now = p5sound.audiocontext.currentTime; | |
var currentVol = this.output.gain.value; | |
this.output.gain.cancelScheduledValues(now + tFromNow); | |
// Attack | |
if (typeof volFrom === 'number' && volFrom >= 0) { | |
this.output.gain.linearRampToValueAtTime(volFrom, now + tFromNow); |
NewerOlder