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
// https://github.com/Offirmo/blog/blob/gh-pages/tosort/javascript-daily/mod-floating.md | |
const floating = require('floating.js) | |
floating({ | |
content: '<span style="color: snow">❄</span>', | |
number: 25, | |
direction: 'reverse', | |
size: [0.5, 2.5], | |
}) |
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
/////// GET | |
fetch('/user/search?activeFilter=pending&max-results=11') | |
.then(response => { | |
const {ok, status} = response; | |
if (!ok || status !== 200) | |
throw new Error(); | |
return response.json(); | |
}) | |
.catch((e => { | |
console.log('parsing failed or whatever', e) |
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
// +++ https://blog.garstasio.com/you-dont-need-jquery/selectors/ | |
// http://youmightnotneedjquery.com/ | |
/// various access | |
self // https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope | |
self.origin | |
self.isSecureContext | |
window | |
window.document |
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 https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Op%C3%A9rateurs/Affecter_par_d%C3%A9composition | |
var metadata = { | |
title: "Scratchpad", | |
translations: [ | |
{ | |
locale: "de", | |
localization_tags: [ ], | |
last_edit: "2014-04-14T08:43:37", | |
url: "/de/docs/Tools/Scratchpad", | |
title: "JavaScript-Umgebung" |
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
#!/usr/bin/env bash | |
## https://stackoverflow.com/questions/31313305/portably-trapping-err-in-shell-script | |
## http://mywiki.wooledge.org/BashFAQ/105 | |
set -o errexit | |
## current shell can be tested with this: | |
## https://stackoverflow.com/a/11097703/587407 | |
echo "* current shell : '`ps -p $$ -ocomm=`'" |
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
/** | |
* Conveniently proxy functions instead of storing the value and applying it yourself. | |
* | |
* proxyFunction(someApiFunction, (args, callOriginalFunction) => { | |
* if (whateverYouWant) { | |
* return 'custom value' | |
* // Never call the original | |
* } | |
* | |
* |
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
// null coalescings https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing | |
foo = foo ?? 42 | |
foo ??= 42 | |
// optional chaining https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining | |
dog?.name | |
dog?.[name] | |
hello?.(target) |
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 'marky' | |
const user_timing_measurement = (window as any).user_timing_measurement | |
user_timing_measurement.mark('bootstrap') | |
... | |
user_timing_measurement.stop('bootstrap') | |
// https://www.html5rocks.com/en/tutorials/webperformance/basics/ |
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 obs$ = Rx.Observable.create((observer) => { | |
observer.next(1) | |
// either: | |
observer.error(new Error('404')) | |
observer.complete() | |
}) | |
observable.subscribe( | |
value => console.log(value), | |
err => console.error(value), |
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 _ = require('lodash') | |
/////// REDUCE /////// | |
res = .reduce((acc, val) => { | |
return acc + val | |
}, 0) | |
err = decorators.reduce((err, decorator) => { | |
return decorator(err) | |
}, err) |