Skip to content

Instantly share code, notes, and snippets.

Just coding

Kyle Simpson getify

Just coding
View GitHub Profile
getify /
Created Oct 20, 2020
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

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:


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 / test.js
Created Aug 27, 2020
fun call-stack experiment
View test.js
function foo() {
function bar() {
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.



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.

getify /
Last active Jul 27, 2020
AutoHotKeys (AHK) script for cycling active focus between a selected ("recorded") set of open windows

Download Icon:

How To Use

  1. While focused on an open window (like a browser or editor), hit the "record" hotkey (default: win+ctrl+shift+?) to add an app to the focus cycle list. Tooltips will pop up notifying you of recorded apps, or if there's an issue recording.

  2. To cycle forward through recorded apps, use the "cycle forward" hotkey (default: win+ctrl+shift+>), or click the system-tray icon, or click the menu Item "Cycle Apps" menu item.

  3. To cycle backward, use the "cycle backward" hotkey (default: win+ctrl+shift+<).

getify /
Created Jul 16, 2020
Monads and Friends...

Monads and Friends...

Over the last 24-48 hours, I've fielded quite a flurry of tweets related to a couple of threads I posted recently. Upon reflection on the feedback, especially the negative stuff, I decided to write this blog post to clarify a few things about my background on the topic, what I was trying to say, what I've done so far, and what I'm hoping to do (and learn!) in the future.

It's a bit of a lengthy read, but if you find you've got the time, I hope you'll read it.

To be clear, the feedback has been on a broad spectrum. A lot of it was actually quite positive, people thanking me and appreciating my continued efforts to try to make dev topics approachable. As a matter of fact, over the years, I've received boat loads of such positive feedback, and I'm tremendously grateful that I've had a helpful impact on so many lives.

But some of it veered decidedly the other direction. I'm deliberately not linking to it, because I don't want to either amplify or gang up on those folks. I'm offended an

getify / 1.js
Last active Jun 7, 2020
native JS async-iterator event stream
View 1.js
async function main() {
var btn = document.getElementById("my-button");
// eventStream here is a native JS async iterator
var eventStream = onEvent(btn)("click");
// this is the key thing: we can use a `for-await..of` loop
// to consume the async-iterator
for await (let evt of eventStream) {
getify / 1.js
Last active Aug 18, 2020
in JS, exploring async (promise-based) Haskell-style `do`-block syntax for the IO monad Demo:
View 1.js
// setup all the utilities to be used
var delay = (ms,cancel = new AbortController()) => {
var pr = new Promise(res => {
var intv = setTimeout(res,ms);
cancel.signal.addEventListener("abort",() => { clearTimeout(intv); res(); });
pr.abort = () => cancel.abort();
return pr;
View MicDevice.ahk
#include VA.ahk
SwitchMicDevice(micName) {
return VA_SetDefaultEndpoint(micName,1)
GetMicDeviceID(micName) {
deviceIDPtr := GetMicDevice(A_Index)
You can’t perform that action at this time.