Skip to content

Instantly share code, notes, and snippets.

View tsheaff's full-sized avatar

Tyler Sheaffer tsheaff

View GitHub Profile
@miZyind
miZyind / get-valuable.ts
Last active August 24, 2024 06:50
A helper function to remove blank attributes from an object in TypeScript with type-safe
type Valuable<T> = { [K in keyof T as T[K] extends null | undefined ? never : K]: T[K] };
function getValuable<
// eslint-disable-next-line @typescript-eslint/ban-types
T extends {},
V = Valuable<T>,
>(obj: T): V {
return Object.fromEntries(
Object.entries(obj).filter(
([, v]) =>

Visual Studio Code shortcuts I use often

Navigation

Sidebar:

  • Cmd-Shift-F: search
  • Cmd-Shift-E: files

Navigating in current editor:

@davidwalter0
davidwalter0 / stash-pop-recover
Created August 10, 2017 17:42
Undoing accidental git stash pop
# https://stackoverflow.com/questions/6543519/undoing-accidental-git-stash-pop
# https://stackoverflow.com/questions/89332/how-to-recover-a-dropped-stash-in-git
accepted
If you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop on screen (thanks, Dolda).
Otherwise, you can find it using this for Linux and Unix:
git fsck --no-reflog | awk '/dangling commit/ {print $3}'
and for Windows:
@javrasya
javrasya / get_latest_git_tag_by_pattern.bash
Created January 20, 2017 15:13
Get latest git tag by a version pattern
echo "$(git tag --sort=committerdate | grep -o 'v[0-9]*\.[0-9]*\.[0-9]*' | tail -n1)"
@ake-persson
ake-persson / gist:ca29cca70f0b458aee4d
Last active January 28, 2022 17:43
Homebrew Formula for a Go app

Homebrew Formula for a Go app

These are quick notes from making my own Formula and Tap.

Add go build script to your Git repo

gobuild.sh

#!/bin/bash
@addyosmani
addyosmani / package.json
Last active May 29, 2024 15:54
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@jboner
jboner / latency.txt
Last active September 20, 2024 23:33
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD