Skip to content

Instantly share code, notes, and snippets.

View getify's full-sized avatar
πŸ’­
Just coding

Kyle Simpson getify

πŸ’­
Just coding
View GitHub Profile
@getify
getify / 1.js
Last active September 29, 2021 11:58
experiment: mimicking React's new "useState()" hook for stand-alone functions, including "custom hooks"
"use strict";
[foo,bar] = TNG(foo,bar);
// NOTE: intentionally not TNG(..) wrapping useBaz(), so that it's
// basically like a "custom hook" that can be called only from other
// TNG-wrapped functions
function foo(origX,origY) {
var [x,setX] = useState(origX);
var [y,setY] = useState(origY);
@getify
getify / 1.js
Last active December 19, 2025 01:28
creating hard-bound methods on classes
class Foo {
constructor(x) { this.foo = x; }
hello() { console.log(this.foo); }
}
class Bar extends Foo {
constructor(x) { super(x); this.bar = x * 100; }
world() { console.log(this.bar); }
}
@getify
getify / 1.js
Last active November 12, 2018 14:57
the "knights-dialer" problem
// https://medium.com/@alexgolec/google-interview-questions-deconstructed-the-knights-dialer-f780d516f029
function nearby(number) {
return (
number === 0 ? [4,6] :
number == 1 ? [6,8] :
number == 2 ? [7,9] :
number == 3 ? [4,8] :
number == 4 ? [3,9,0] :
number == 6 ? [1,7,0] :
@getify
getify / 1.js
Last active March 19, 2023 08:32
tag function for formatting console.log(..) statements
function logger(strings,...values) {
var str = "";
for (let i = 0; i < strings.length; i++) {
if (i > 0) {
if (values[i-1] && typeof values[i-1] == "object") {
if (values[i-1] instanceof Error) {
if (values[i-1].stack) {
str += values[i-1].stack;
continue;
}
@getify
getify / talk.md
Last active January 14, 2019 23:27
Talk Abstract: "The Web Must PWA"

The Web Must PWA

The web is the most important platform for individual empowerment and creative expression that mankind has ever invented. What was once a meager collection of a handful of scientific documents linked together, is now an expansive graph of billions of people interacting to exchange trillions of interconnected ideas. Getting to be even a small part of building that should be tremendously exciting.

But, even as great as it is, the web faces myriad existential threats. And it's up to us, the builders of the web, to confront them head on. Privacy, security, and accessibility are the obvious big ones, but less obvious are some far deeper problems at the core of the web and how we design/build it.

Should the web go all-HTTPS? Most think so, but uncacheable HTTPS alienates 1/3 of the world's population. We can all probably imagine how bad the web is on slow connections, or even how much it costs on expensive metered-data plans. But worse than slow connection is spotty/intermittent connection or

@getify
getify / 1.md
Last active January 17, 2020 16:35
A question about JS parameter scopes, and closures over them vs function scopes

I received a question about this snippet of code:

function def(first="oldValue" , second=function(){
         return first;
}){
        var first="updatedValue";
        console.log('inside',first);
        console.log('function',second());
}
@getify
getify / 1.js
Created June 30, 2018 04:03
illustrating a use-case for willfully violating "TDZ" for stylistic reasons
// my-common-js-module.js
const prefix = "ABC_";
// NOTE: what's good here is that I'm using a `const`, but what's bad is, it's not
// located down below where my other "private" implementation details are.
// my public API for my module
module.exports = {
[`${prefix}1`]: 42,
[`${prefix}2`]: 100,
@getify
getify / 1.md
Last active September 6, 2024 20:20
can't figure out the geometry... HELP!?
@getify
getify / 1.js
Created June 2, 2018 04:09
waitForEvent(..) -- promisified event listener
function waitForEvent(elem,evtName) {
return new Promise(function c(resolve){
elem.addEventListener(evtName,function onEvent(evt){
elem.removeEventListener(evtName,onEvent,false);
resolve(evt);
},false);
});
}
@getify
getify / 1.md
Last active March 6, 2023 05:28
bookmarking some useful unicode icons

βŽ˜πŸ“‹πŸ—‘β¬’πŸ’»β¬“πŸ”€πŸ“·πŸ“ΆπŸ”„πŸ”πŸ”ŠπŸ”‡πŸ”πŸ”ŽπŸ–₯πŸ—¨πŸ’¬πŸ“ŽπŸ“‚πŸ“„πŸ“…πŸ“ŒπŸ“πŸ“πŸ“žβ˜ŽπŸ”’πŸ”“πŸ””πŸ”•πŸ”—β–Άβ–²β–Όβ—€βŸ²βŸ³βŠ—βœŽβœ“βœ”βœ—βœ˜βŠ•β˜·βœ„β˜°β™₯β˜…β˜†βš›βŒ–βš™βŒ•βŒ”βŒ«