Skip to content

Instantly share code, notes, and snippets.

View jthodge's full-sized avatar
🎯
Focusing

Taylor Hodge jthodge

🎯
Focusing
View GitHub Profile
@jthodge
jthodge / universal-switcher
Created September 6, 2020 22:07
Show macOS app switcher across all monitors
defaults write com.apple.Dock appswitcher-all-displays -bool true
killall Dock
pgcli -h localhost -u postgres -d api_development
select * from graphile_worker.jobs
@jthodge
jthodge / fix-emacs-permissions-catalina.el
Created April 12, 2020 21:22 — forked from dive/fix-emacs-permissions-catalina.el
Fix Emacs permissions on macOS Catalina
;;; package --- Fix permissions for Emacs.app on macOS Catalina
;;; Author: Artem Loenko
;;; Mail-To: <artyom.loenko@mac.com>
;;; Commentary:
;;; Code:
(defconst _default-emacs-app-plist-path "/Applications/Emacs.app/Contents/Info.plist")
(defconst _temp-buffer-name "*fixing Emacs permissions*")
(defconst _temp-buffer (get-buffer-create _temp-buffer-name))
(with-current-buffer _temp-buffer (erase-buffer))
let re = /a/g
re.test('ab') // returns true
re.test('ab') // this will fail! re.lastIndex === 1 so it starts searching at 'b'
re.test('ab') // this will pass! since it failed, re.lastIndex is reset to 0
// https://stackoverflow.com/questions/11477415/why-does-javascripts-regex-exec-not-always-return-the-same-value
#!/bin/bash
# Set standby delay on battery to 12hr
sudo pmset -b standbydelay 43200
# Disable it entirely on battery
sudo pmset -c standby 0
# Disable hibernation
sudo pmset -a hibernatemode 0
@jthodge
jthodge / latency.markdown
Created December 21, 2019 20:06 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jthodge
jthodge / thunk-example.ts
Last active December 21, 2019 03:01 — forked from maxchehab/example.ts
type Sum = (x: number, y: number) => number;
export function CreateSum(): Sum {
return function(x: number, y: number): number {
return x + y;
};
}