Skip to content

Instantly share code, notes, and snippets.

View bourke's full-sized avatar

Michael Bourke bourke

View GitHub Profile
@junosuarez
junosuarez / gitstatus-prompt.zsh
Created October 28, 2022 07:46
starship + gitstatusd
#!/bin/zsh
# include this file in your shell config
autoload -Uz add-zsh-hook
# this file comes from installing https://github.com/romkatv/gitstatus
SOURCE "${HOMEBREW_PREFIX:-/usr/local}/opt/gitstatus/gitstatus.plugin.zsh" || return
gitstatusd_instance='GSD'
# the following are a mystery - why do they define the fn names with $1?
@llimllib
llimllib / Makefile
Last active March 20, 2022 20:08
The simplest possible use of esbuild to import a package and run a function in the browser
build:
./node_modules/.bin/esbuild index.js --bundle --outfile=out.js
@sandys
sandys / Fastapi-sqlalchemy-pydantic-dataclasses-reloadable-logging.md
Last active June 30, 2024 09:23
fastapi with python 3.10 dataclasses - used to create both sqlalchemy and pydantic models simultaneously. And setting up sqlalchemy the right way (without deadlocks or other problems). Additionally, this also takes care of unified logging when running under gunicorn..as well as being able to run in restartable mode.
@zzzeek
zzzeek / msg373145.rst
Last active October 22, 2022 12:36
asyncio support for SQLAlchemy (and Flask, and any other blocking-IO library)

This is a cross post of something I just posted on the Python bug tracker at https://bugs.python.org/msg373145.

I seem to have two cents to offer so here it is. An obscure issue in the Python bug tracker is probably not the right place for this so consider this as an early draft of something that maybe I'll talk about more elsewhere.

> This basically divides code into two islands - async and non-async

@chockenberry
chockenberry / Debug.swift
Last active April 11, 2024 13:22
Debug and release logging in Swift that's reminiscent of NSLog()
//
// Debug.swift
//
// Created by Craig Hockenberry on 3/15/17.
// Updated by Craig Hockenberry on 2/20/24.
// Usage:
//
// SplineReticulationManager.swift:
//
@gaearon
gaearon / uselayouteffect-ssr.md
Last active July 7, 2024 18:47
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@jagmoreira
jagmoreira / update_envs_micro_python.sh
Created May 13, 2017 21:30
Updates all pyenv virtual environments to the latest micro version of Python
#!/usr/bin/env bash
#
# update_envs_micro_python.sh
#
# Updates all pyenv virtual environments to the latest micro version of Python
#
# Author: Joao Moreira (jagmoreira)
#
# First update pyenv to get any new python versions
@milch
milch / mail_to_notes.rb
Last active April 8, 2024 01:38
Ruby script to convert a mail (.eml/.emlx) file to a note in macOS Notes.app.
require 'base64'
require 'digest'
require 'mail'
require 'nokogiri'
require 'shellwords'
file = ARGV.first
puts "Processing file #{file}"
contents = File.read(file)
@gferreira
gferreira / varfonts-css_03.css
Last active April 18, 2023 14:31
Univers in CSS
/*
Exercise 3:
Univers in CSS – a tribute to Adrian Frutiger
39
45 46 47 48 49
53 55 56 57 58 59
63 65 66 67 68
73 75 76
83