Skip to content

Instantly share code, notes, and snippets.

View andyvanee's full-sized avatar

Andy Vanee andyvanee

View GitHub Profile
@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 March 24, 2024 20:08
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)
@andyvanee
andyvanee / README.md
Last active October 29, 2019 17:46
Steps to run MySQL from a given data directory.

Sometimes it's nice to run MySQL (MariaDB) on your local machine in a completely contained environment. This outlines the minimum steps to make that happen.

  • Start with setup.sh to get a root login.
  • Then create a non-root user with the following:

GRANT ALL PRIVILEGES ON *.* TO 'user-name'@'localhost' IDENTIFIED BY 'user-password';

  • Update data/my.cnf with the client username and password you just created.
  • You should probably also add the entire data directory to your .gitignore file.
@andyvanee
andyvanee / SomeClass.php
Last active October 23, 2019 19:01
Demonstrating how to assign to private class members in PHP (not recommended)
<?php
class SomeClass {
private $priv;
public $pub;
}
// This function demonstrates how to access and assign to private
// or undeclared class members using Closure::bindTo
function assignPrivate($obj, $key, $value) {