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'; | |
function removeItem(itemKey) { | |
localStorage.removeItem(itemKey); | |
} | |
function getItem(itemKey) { | |
return JSON.parse(localStorage.getItem(itemKey)); |
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
[ | |
{ | |
"from": { | |
"pos": [ | |
153.43916, | |
-29.50063 | |
], | |
"time": "2021-10-03 07:26:23" | |
}, | |
"to": { |
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
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
import React from 'react' | |
const ScrollContext = React.createContext(null) | |
export function useScroll() { | |
const scroll = React.useContext(ScrollContext) | |
if (!scroll) | |
throw new Error('Please make sure ScrollContextProvider is available') | |
return scroll |
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 | |
/** | |
* Improves the WordPress caption shortcode with HTML5 figure & figcaption, microdata & wai-aria attributes | |
* | |
* Author: @joostkiens | |
* Licensed under the MIT license | |
* | |
* @param string $val Empty | |
* @param array $attr Shortcode attributes | |
* @param string $content Shortcode content |
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 createUVWGrid = ([cx, cy, cz]) => { | |
return times(cx).map(x => times(cy).map((y) => times(cz).map(z => | |
new THREE.Vector3( | |
cx <= 1 ? 0.5 : x / (cx - 1), | |
cy <= 1 ? 0.5 : y / (cy - 1), | |
cz <= 1 ? 0.5 : z / (cz - 1) | |
) | |
))).flat(2) | |
} |
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 autoplayVideoSupported(muted = true, playsinline = true) { | |
const v = document.createElement('video') | |
v.muted = muted | |
playsinline && v.setAttribute('playsinline', 'playsinline') | |
v.setAttribute('width', 0) | |
v.setAttribute('height', 0) | |
v.style.opacity = 0 | |
document.querySelector('body').appendChild(v) | |
return new Promise((resolve, reject) => { | |
v.play() |
NewerOlder