Skip to content

Instantly share code, notes, and snippets.

View andyvanee's full-sized avatar

Andy Vanee andyvanee

View GitHub Profile
@andyvanee
andyvanee / README.md
Last active October 18, 2024 03:12
How slow is async/await?

How slow is async/await?

TL;DR - incredibly slow!

Motivation

I was working on some "framework" type code, where it often makes sense to provide wrappers where the framework accepts a user-defined callback. The sensible default is to accept an async callback since you don't know when the user might need to do any disk/network/etc calls which require an async wrapper.

@andyvanee
andyvanee / scanvideo_minimal.c
Last active June 6, 2024 04:41
Actually minimal version of rp2040 scanvideo
/*
* Actually minimal scanvideo example
*/
#include <stdio.h>
#include "pico.h"
#include "pico/scanvideo.h"
#include "pico/scanvideo/composable_scanline.h"
#include "pico/stdlib.h"
@andyvanee
andyvanee / init.lua
Last active April 4, 2024 18:51
Hammerspoon config for window management
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function() hs.reload() end)
hs.alert.show("Config loaded")
-- Fullscreen
hs.hotkey.bind({"cmd", "alt"}, "1",
function()
local window, screen = getFocusedWindowAndScreen()
window.w = screen.w
window.x = screen.x
window.y = screen.y

Problem

Google search has gotten objectively worse with increasing crawling, SEO farming and AI generated bullshit. I believe the only sane solution is to explicitly whitelist websites with known ethical publishing guidelines. I am going to attempt to build a list of sites that I trust for common search contexts.

Developer Results

General search (not focused on a specific technology):

@andyvanee
andyvanee / podcasts.md
Created February 4, 2022 20:03
Podcasts I'm currently listening to

Arts/Culture

  • The Anthropocene Reviewed
  • Life Kit (NPR)
  • Dear Hank & John
  • On Being with Krista Tippet
  • A Slight Change of Plans with Maya Shankar
  • Factually! with Adam Conover
  • Philosophize This!
  • No Such Thing As A Fish
@andyvanee
andyvanee / README.md
Last active December 21, 2021 21:56
Directus http endpoint integration

The documentation on Directus 9 extensions is scarce. This is a slightly more detailed implementation than the example given.

Notes:

  • router is an express.Router object
  • services is a bunch of getters of available services (see below)
  • database is the knex instance
  • directus.auth.refresh() will throw. It's assumed that the user has authenticated in before calling fetchJson
@andyvanee
andyvanee / README.md
Last active August 19, 2021 19:10
Basic profiler for your node scripts

Basic profiler for your node scripts

Usage
import "./profile.js"

// do some stuff...
const items = [...new Array(100)].map((x, i) => i)
for (let i of items) {
@andyvanee
andyvanee / README.md
Last active October 27, 2024 22:38
GoDaddy + LetsEncrypt Certificate Installation

GoDaddy + LetsEncrypt Certificate Installation

Valid as of September 2020

note: if you have shell access and want to automatically renew, follow the steps on this page instead

Much of the current documentation on this from LetsEncryt and Godaddy suggests that this is a very hard thing to do - but I'm okay with spending 10 minutes every 2-3 months for a free, quality SSL certificate. If you are too, here's how I do it.

@andyvanee
andyvanee / dirsum.js
Last active September 1, 2020 20:36
Calculate the checksum of a directory of files
import fs from "fs"
import crypto from "crypto"
import path from "path"
/**
* Calculate the checksum of a directory of files
*/
const dirsum = async basepath => {
const hash = crypto.createHash("sha1")
const dirOpts = { withFileTypes: true }
@andyvanee
andyvanee / tagProps.js
Created August 12, 2020 22:27
tagProps lit-element directive
import { directive } from "https://unpkg.com/@polymer/lit-element/lit-element.js?module"
const stateMap = new WeakMap()
export const tagProps = directive((tag, props = {}) => part => {
let state = stateMap.get(part)
const el = () => document.createElement(tag)
if (state === undefined) {
state = { tag, element: el() }
stateMap.set(part, state)