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 / better-web.md
Created March 12, 2019 13:19
Building That Better Web

Building That Better Web

In honor of the 30th anniversary of the web, I wanted to share a few thoughts about what a better web could aspire to be, and challenge us to move toward it.

The Worser Web

It's tempting to frame "better" simply in terms of improvement and progress, as in how far the web has come over the last 20+ years. As a developer, I like many others get all too excited about fancy new features like Service Workers, WebRTC, and yes, even CSS Grids. The pace of change is dizzying, but it feels like a great problem to have too many awesome features to learn and use!

So in one practical respect, a better web is one that empowers developers and users alike to express themselves and connect with others more fluently.

@getify
getify / 1.js
Created March 6, 2019 02:02
Promise.lazyAll(..)
Promise.lazyAll = async function lazyAll(iter) {
var results = [];
for await (let val of iter) {
results.push(val);
}
return results;
};
(async function(){
console.log( `results(1): ${ await Promise.lazyAll( [1,2,3] )}` );
@getify
getify / 1.md
Created March 2, 2019 15:16
problem making eslint plugin work... help!?
$> node_modules/eslint/bin/eslint.js --version
v5.15.0

$> cat foo.js
"use strict";
var x = y => foo(y);

$> cat .eslintrc.json
@getify
getify / 1.js
Created February 14, 2019 20:55
thenify()... turn an err-first callback into two functions that can suitably be passed to a promise.then(..) and/or .catch(..)
function somethingThatReturnsAPromise(x,y,z) { .. }
function myCallback(err,v) {
if (err) {
console.error(err);
}
else {
console.log(v);
}
}
@getify
getify / fizzbuzz.js
Created December 13, 2018 18:29
my first ever attempt at fizzbuzz
function fizzbuzz() {
for (let i = 1; i <= 100; i++) {
let div3 = i % 3 == 0;
let div5 = i % 5 == 0;
if (div3 && div5) {
console.log("FizzBuzz");
}
else if (div3) {
console.log("Fizz");
}
@getify
getify / 1.js
Last active February 25, 2020 11:27
exploring readability differences
let names = people.map(personToGetNameFrom => personToGetNameFrom.name);
// ******************
let getName = person => person.name;
let names = people.map(getName);
// ******************
function getName(person) { return person.name; }
@getify
getify / 1.js
Last active June 30, 2022 16:35
fun little experiment... a point-free definition for "copySession()" (essentially a shallow object copy)
// function copySession(sess) {
// return { ...sess };
// }
var copySession = compose(
reduce(
compose(
flip,
binary,
uncurry,
@getify
getify / 1.js
Last active February 5, 2019 10:15
React's `useCallback(..)` memoization... how does it work?
function Foo() {
var [x,setX] = useState(0);
var [y,setY] = useState(1);
var cb = useCallback(
function printXYIfChanged() { console.log(x,y); },
[x,y]
);
useEffect(
function pollingXY(){
var intv = setInterval(cb,100);
@getify
getify / 1.js
Last active July 20, 2022 19:31
regex matching escaped or non-escaped character
var a = "j"; // "j"
var b = "\\j"; // "\j"
var c = "\\\\j"; // "\\j"
var d = "\\\\\\j"; // "\\\j"
var e = "\\\\\\\\j"; // "\\\\j"
var f = "\\\\\\\\\\j"; // "\\\\\j"
var just_j = nonescapedRE("j");
just_j.test(a); // true
just_j.test(b); // false
@getify
getify / 1.js
Last active June 2, 2020 11:07
multiple-field sorter
var data = [
{ a: 4, b: 12, c: "elderberry" },
{ a: 2, b: 10, c: "cherry", d: 4 },
{ a: 4, b: 12, c: "durian" },
{ a: 2, b: 10, c: "cherry", },
{ a: 3, b: 12, c: "durian" },
{ a: 1, b: 10, c: "apple", },
{ a: 1, b: 11, c: "apple", },
{ a: 1, b: 11, c: "banana", },
{ a: 2, b: 10, c: "banana", },