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 / 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;
};
}
@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

#!/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
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
@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: <[email protected]>
;;; 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))
pgcli -h localhost -u postgres -d api_development
select * from graphile_worker.jobs
@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
@jthodge
jthodge / markup.rkt
Created September 11, 2020 00:54
ask professor markup
(define (ask-professor . elements)
`(div ((id "askme"))
(h4 "Ask Professor Markup")
(div ((class "inner"))
(blockquote
,@elements
)
)
))
@jthodge
jthodge / unfollow.js
Created September 20, 2020 15:15 — forked from JamieMason/unfollow.js.md
Unfollow everyone on twitter.com
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/7580315
//
// 1. Go to https://twitter.com/YOUR_USER_NAME/following
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
//
// Last Updated: 09 April 2020
(() => {
const $followButtons = '[data-testid$="-unfollow"]';
@jthodge
jthodge / stats.sh
Created July 19, 2021 23:31
Script for iterating over git revisions and computing statistics for each
#!/bin/bash
set -e
file_pattern=$1
function main {
for rev in `revisions`; do
echo "`number_of_lines` `commit_description`"
done