Skip to content

Instantly share code, notes, and snippets.

💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
@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 Jun 3, 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)
View keybase.md

Keybase proof

I hereby claim:

  • I am getify on github.
  • I am getify (https://keybase.io/getify) on keybase.
  • I have a public key ASCMGyYZgzXV7OoA4Aw_DzSwADaqpyFN2enUhGeeAbxaZgo

To claim this, I am signing this object:

@getify
getify / 1.js
Last active Mar 28, 2020
illustrating the hook/stale-closure problem
View 1.js
function SomeCounter() {
const [ counter, updateCounter ] = useState(0);
useEffect(function listening(){
const btn = document.getElementById("increment-counter-btn");
btn.addEventListener("click",onClick);
},[]);
useEffect(function logger(){
// this logger() is updated each time `counter` changes, so
@getify
getify / 1.js
Last active Sep 19, 2019
quick sketch of CAF
View 1.js
btn.addEventListener("send-btn",onSend);
send = CAF(send);
var prevSend = Promise.resolve();
function onSend(evt) {
prevSend.finally(function f(){
prevSend = send(
CAF.timeout(1000,"send took too long."),
{ some: "data" }
)
@getify
getify / 1.js
Last active Sep 13, 2019
microtask queue got me singin' the blues
View 1.js
// VERSION 1 -- broken
async function *main() {
yield ready;
}
var resolve1;
var resolve2;
var ready = new Promise(function c(res){
resolve1 = res;
View 1.js
// NOTE: To see this demo: https://codepen.io/getify/pen/LYPbmYG?editors=0012
var counter = 1;
function printMessage() {
console.log(`message ${counter++}`);
}
var schedule = Scheduler(/* debounceMinimum = */50,/* throttleMaximum = */500);
You can’t perform that action at this time.