no matter how long you've been using it, bash is an endless treasure trove of hidden gems thirsting to make your life better. here is a small tasting flight of favorite bash friends I've remembered to write down.
My personal rule of thumb: if I've typed something more than twice, it's time to turn it into a macro.
When have you ever changed directories and not wanted to see the contents of your new location? Rarely.
# cd+ls, only the most used pair of commands of all time ever
function cl() {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: | |
// go test <options> -cpuprofile cpu.prof -memprofile mem.prof ./... | |
// go tool pprof # Interactive console | |
// go tool pprof -http=localhost:6060 cpu.prof # Visualization | |
import ( | |
"flag" | |
"log" | |
"runtime" | |
"runtime/pprof" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simulate 'Cumulative' type relationshipRPG trials. | |
""" | |
import csv | |
import math | |
import random | |
import time | |
import unittest |
Official walkthrough: Tour of Go
- think of a channel as a way of creating a stream IO between two concurrent subroutines
- Go race detector
- locking with WaitGroup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
brew update | |
brew upgrade | |
go get -u golint # and maybe more |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# OSX 10.12 broke brew; I just nuked it and reinstalled | |
# OSX 10.12 switched from GNU grep to FreeBSD grep, breaking `grep -Po` | |
brew install grep --with-default-names | |
# System Integrity Protection fucks up a lot of dev shit | |
sudo chown -R $USER /usr/local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Display my IP address on an I2C OLED screen connected over GPIO """ | |
import socket | |
import time | |
from PIL import Image | |
from PIL import ImageDraw | |
from PIL import ImageFont | |
import Adafruit_GPIO.SPI as SPI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cameras=(0 1 2) | |
function apply_cams() { | |
# Apply `v4l2-ctl $@` to all cams | |
# Example usage: apply_cams -C focus_auto | |
for cam in "${cameras[@]}"; do | |
echo "/dev/video$cam" | |
v4l2-ctl -d $cam $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Solutions from https://www.quora.com/How-do-I-disable-iTunes-from-popping-up-in-Mac-OS | |
# Stop daemon | |
## Change permissions so it can't execute. This can be done from the command line using this command: | |
sudo chmod -x /System/Library/CoreServices/rcd.app/Contents/MacOS | |
## Or, unload it using this command: | |
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist | |
# System Preferences > Users & Groups > Login Items --> remove iTunes Helper |