Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
@getify
getify / 1.md
Created Oct 20, 2020
troubles with pbkdf2 between node and browser
View 1.md

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
View 1.md

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 Aug 27, 2020
fun call-stack experiment
View test.js
function foo() {
baz();
}
function bar() {
baz();
}
function baz() {
console.log(`baz() was called from: ${whereWasICalledFrom()}`);
View open-letter-asshole-hiring.md

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..

View what-hiring-should-look-like.md

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
getify / INFO.md
Last active Jul 27, 2020
AutoHotKeys (AHK) script for cycling active focus between a selected ("recorded") set of open windows
View INFO.md

Download Icon: https://jumpshare.com/v/T5yuKIP3Zc6Rr29GH5ye

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
getify / monads-and-friends.md
Created Jul 16, 2020
Monads and Friends...
View monads-and-friends.md

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
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) {
console.log("click!");
@getify
getify / 1.js
Last active Aug 18, 2020
in JS, exploring async (promise-based) Haskell-style `do`-block syntax for the IO monad Demo: https://codepen.io/getify/pen/abvjRRK?editors=0011
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) {
Loop
{
deviceIDPtr := GetMicDevice(A_Index)
You can’t perform that action at this time.