Skip to content

Instantly share code, notes, and snippets.

🙃
¡Hola!

Oleg Solomka legomushroom

🙃
¡Hola!
Block or report user

Report or block legomushroom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lexical scope illustration
function foo() {
console.log( a ); // 2
}
function bar() {
var a = 3;
foo();
}
var a = 2;
@legomushroom
legomushroom / gist:d750dcae8717702f9367
Created Jul 27, 2015
CSS onCSSTransitionEnd helper
View gist:d750dcae8717702f9367
/*
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
;
(function(document, window, index) {
var s = document.body || document.documentElement,
s = s.style,
prefixAnimation = '',
@legomushroom
legomushroom / gist:be30cddb5e4df0851c90
Created Aug 12, 2015
setPrototypesOf helper es2015
View gist:be30cddb5e4df0851c90
var obj3 = {
baz: 3
}
var obj2 = {
bar: 2
}
var obj1 = {
View gist:7689418
<script>
var url ='icons.svg';
var c=new XMLHttpRequest(); c.open('GET', url, false); c.setRequestHeader('Content-Type', 'text/xml'); c.send();
document.body.insertBefore(c.responseXML.firstChild, document.body.firstChild)
</script>
View JS surprises
// ---------------------------------------------------------------------------------------------------------------------------
```javascript
function foo () {
console.log(a);
}
var a = 2;
function bar () {
View rotary encoder [COM-09117]
/*
(Copy and paste)
Rotary encoder decoding using two interrupt lines.
Most Arduino boards have two external interrupts,
numbers 0 (on digital pin 2) and 1 (on digital pin 3).
Program sketch is for SparkFun Rotary Encoder sku: COM-09117
Connect the middle pin of the three to ground.
View gist:de99be08864456abb882e1b1ccfd247d
[1] "time: 2237.971 proportion before: 0.370550161812298 proportion after: 0.329979879275654"
2-sample test for equality of proportions with continuity correction
data: x out of n
X-squared = 1.7606, df = 1, p-value = 0.1846
alternative hypothesis: two.sided
95 percent confidence interval:
-0.01902818 0.10302818
sample estimates:
View gist:26ed522876588f3787e221d32625baa1
[1] ""
[1] ""
[1] ""
[1] "-=-=-=-=--=-=-=-=-=-=-"
[1] "---- OS: total"
[1] "-=-=-=-=--=-=-=-=-=-=-"
[1] ""
[1] ""
[1] ""
[1] "time: 1000 before: 12.81 % after: 12.79 %"
View scenarios
- [ok] silent sign in.
- [ok] silent sign in /error.
- [ok] user initiated sign in /browser.
- [ok] user initiated sign in /browser /cancel.
- [ok] user initiated sign in /browser /error.
- [ok] user initiated sign in /user code.
- [ok] user initiated sign in /user code /cancel.
- [ok] user initiated sign in /user code /error.
- [ok] user initiated sign in /user code /expired.
- [ok] user initiated sign in /user code /expired user is able to restart sign in.
View gist:e9c02c864a42bf5a8a0f91d2e0590dba
export const promiseState = async (p: Promise<any>): Promise<string> => {
const t = {};
return await Promise.race([p, t]).then(
(v) => {
return (v === t)
? 'pending'
: 'fulfilled';
},
() => 'rejected');
};
You can’t perform that action at this time.