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
/** | |
* Copyright (C) 2014 Joost Kiens | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a | |
* copy of this software and associated documentation files (the "Software"), | |
* to deal in the Software without restriction, including without limitation | |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
* and/or sell copies of the Software, and to permit persons to whom the | |
* Software is furnished to do so, subject to the following conditions: | |
* |
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
<div> | |
<input type="checkbox" id="floep"> | |
<label for="floep">Floep</label> | |
</div> | |
<div> | |
<input type="checkbox" id="flap" checked="checked"> | |
<label for="flap">Flap</label> | |
</div> |
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
// Based on http://stackoverflow.com/a/20434019 | |
function calculateAccuracy(txPower, rssi) { | |
if (rssi === 0) { | |
return -1; // if we cannot determine accuracy, return -1. | |
} | |
var ratio = rssi * 1 / txPower; | |
if (ratio < 1.0) { | |
return Math.pow(ratio, 10); |
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
define(function () { | |
'use strict'; | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); | |
return function ($srcImg) { | |
var deferred = $.Deferred(); | |
var srcImg = $srcImg[0]; |
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 -e | |
ORIGINAL_WORKING_DIR=$(pwd) | |
WORKSPACE=$(cd $(dirname $0); pwd) | |
# A POSIX variable | |
OPTIND=1 # Reset in case getopts has been used previously in the shell. | |
# Initialize our own variables: | |
NAME="" |
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
/* | |
Options | |
--- | |
{ | |
from: 1, // <Number> start number, default: 0 | |
to: 100, // <Number> end number, required | |
duration: 1000, // <Number> total duration on transition, required | |
step: console.log, // <Function> function to execute on each update, receives current number as argument, required | |
ease: x => x, // <Function> custom easing function, default: linear | |
tick: fn => window.setTimeout(fn, 20) // <Function> ticker, default: requestAnimationFrame |
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
function createPathDFromCircle(cx, cy, r) { | |
return `d=" | |
M ${cx} ${cy} | |
m -${r}, 0 | |
a ${r},${r} 0 1,0 ${(r * 2)},0 | |
a ${r},${r} 0 1,0 ${-(r * 2)},0 | |
"` | |
} | |
function createPathDFromCircleStartOnTop(cx, cy, r) { |
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
select { | |
-moz-appearance: none; | |
-webkit-appearance: none; | |
appearance: none; | |
background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTUiIGhlaWdodD0iMTAiIHZpZXdCb3g9IjAgMCAxNSAxMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPHBhdGggZD0iTTEyLjUgMi41bC00LjkgNS01LjEtNSIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2U9IiMyMTFEMUUiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPg0KPC9zdmc+'); | |
background-position: calc(100% - 10px) center; | |
background-repeat: no-repeat; | |
padding-left: 10px; | |
padding-right: 20px; /* prevent text from going under background image */ | |
text-overflow: ellipsis; |
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 target = window | |
let lastY = 0 | |
target.addEventListener('touchmove', handleTouchMove) | |
function handleTouchMove(e) { | |
const { pageY } = e.changedTouches[0] | |
const scrollY = target.pageYOffset || target.scrollTop || 0 | |
if (pageY > lastY && scrollY === 0) { | |
e.preventDefault() |
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
// Preloads entire video, returns promise | |
// NOTE: if a video doesn't exist the fetch will resolve, | |
// but with a Blob type of `plain/text` | |
function preloadVideo(src) { | |
return new Promise((resolve, reject) => { | |
fetch(src) | |
.then(response => response.blob()) | |
.then(blob => | |
/^video\/\w*/.test(blob.type) | |
? resolve(URL.createObjectURL(blob)) |