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
Created December 5, 2020 01:56
the "problem" with asynchronous closing of an async iterator
async function *getStuff(urls) {
showSpinner();
try {
for (let url of urls) {
let resp = await fetch(url);
yield await resp.json();
}
}
finally {
hideSpinner();
@getify
getify / 1.js
Last active December 15, 2020 15:01
a better "async generator", where `return(..)` immediately tears it down? Insipired from: https://alinacierdem.com/the-problem-with-async-generators/
// NOTE: ag(..) is defined in 2.js below
for await (let v of ag("hello")) {
console.log(`v: ${v}`);
}
// a: hello
// b
// v: 42
// c: some data: 10
// d
@getify
getify / App.jsx
Created November 28, 2020 21:37
how to do this in react?
import React, { Component } from "react";
import MyStuffParent from "./my-stuff-parent";
import MyStuff from "./my-stuff";
export default class App extends Component {
constructor() {
super();
this.state = {
showMyStuff: true
}
@getify
getify / 1.js
Last active July 20, 2022 19:24
insert object keys in order, enumerate them in order
var obj = { a: 1, b: 2, c: 3, d: 4 };
insert(obj,{ property: "g", value: 7 });
insert(obj,{ before: "g", property: "e", value: 5 });
insert(obj,{ property: "h", value: 8 });
insert(obj,{ before: "g", property: "f", value: 6 });
obj.i = 9;
console.log(keys(obj));
// [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ]
@getify
getify / 1.js
Last active September 6, 2024 19:18
trying to make race/all combinators for AbortController signals that aren't leaky
class cancelToken {
constructor(controller = new AbortController()) {
this.controller = controller;
this.signal = controller.signal;
({
pr: this.signal.pr,
rej: this.rej,
} = signalPromise(this.signal));
this.signal.pr.catch(() => {
this.controller.abort();
@getify
getify / 1.md
Created October 20, 2020 15:51
troubles with pbkdf2 between node and browser

In the code below, I generate a PBKDF2 key from my password using the same salt/iterations, first in node, then in the browser.

I'm not using any libraries on either side. I'm using the built-in crypto module in node, and the SubtleCrypto web API in the browser.

I'm trying to get both sides to generate the same base64 string of the derived key. Here's what I get:

Node:    UJ3XzqSfs1IjU3/1USt8jPb9Z9jnhevBy3TPCAPGzHPbwXI0jVk+0LoVO7zYmb1BVEtajPmkcuLUPpwju+x+IQ==
Browser: UJ3XzqSfs1IjU3_1USt8jPb9Z9jnhevBy3TPCAPGzHM
@getify
getify / 1.md
Created October 11, 2020 20:57

Need some geometry and/or trigonometry help, specifically with rotating points (about the origin) on a 2d cartesian coordinate graph. To set up the question, let's observe a few already known formulas. See this rough diagram/graph:

rotation-drawing

In the graph, you'll see point A, and you'll also see points B - F that are all shown as rotations (about the origin) from A, given a specific angle (θ). All 6 line segments (from origin to points A - F) are the same length.

If the coordinates of A (x0,y0) are known, and the desired rotation angle θ (in the counter-clockwise direction) is known, the coordinates (x1,y1) of the new point (B - F) can readily be calcuated with these formulas:

x1 = x0 * cos(θ) – y0 * sin(θ)
@getify
getify / test.js
Created August 27, 2020 20:32
fun call-stack experiment
function foo() {
baz();
}
function bar() {
baz();
}
function baz() {
console.log(`baz() was called from: ${whereWasICalledFrom()}`);

An Open Letter To Assholes Who Hire People

About a month ago I tweeted out some frustrations about an interview process I had gone through.

Recently interviewed with a major (global) tech company. They absolutely knew me and my background. Still tried to have me run thru multiple rounds of tech interviews.

..thread..

What Hiring Should Look Like

This is definitely not the first time I've written about this topic, but I haven't written formally about it in quite awhile. So I want to revisit why I think technical-position interviewing is so poorly designed, and lay out what I think would be a better process.

I'm just one guy, with a bunch of strong opinions and a bunch of flaws. So take these suggestions with a grain of salt. I'm sure there's a lot of talented, passionate folks with other thoughts, and some are probably a lot more interesting and useful than my own.

But at the same time, I hope you'll set aside the assumptions and status quo of how interviewing is always done. Just because you were hired a certain way, and even if you liked it, doesn't mean that it's a good interview process to repeat.

If you're happy with the way technical interviewing currently works at your company, fine. Just stop, don't read any further. I'm not going to spend any effort trying to convince you otherwise.