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
#!/usr/bin/env bash | |
set -e # errexit | |
set -u # nounset | |
set -x # echo |
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/sh | |
# Run a process silenced and disowned. | |
# Example Usage: ds firefox | |
if test -t 1; then | |
exec 1>/dev/null | |
fi | |
if test -t 2; then | |
exec 2>/dev/null |
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
class SimpleStore(object): | |
"""Dead simple storage. Basically a dictionary.""" | |
def __init__(self): | |
self.data = {} | |
def get(self, key): | |
return self.data[key] | |
def set(self, key, value): | |
self.data[key] = value |
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
#!/usr/bin/env bash | |
# Launch zathura from a link in your clipboard. | |
# Requires zatweb. | |
set -e | |
URL=$(xclip -selection clipboard -o) | |
zatweb "$URL" |
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
#!/usr/bin/env bash | |
# Script to continously run go tests. | |
# Courtesy of Jon Gjengset. | |
rm -f results.log | |
while true; do | |
echo "Starting trial." | |
go test -test.timeout 80s 2>run.err | tee run.log | grep -P '^(--- )?FAIL|Passed|^Test:|^ok' | tee -a results.log; | |
if grep FAIL run.log; then |
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
import numpy as np | |
print "\n\n" | |
# Width and height of the image. | |
W = 5 | |
H = 5 | |
# Generate a random image. | |
x = np.random.rand(W, H) > 0.5 |
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
#!/usr/bin/env bash | |
(emacsclient -c "$@" &) |
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
#!/usr/bin/env bash | |
# Copy the url of the active ngrok connection to the clipboard. | |
# Usage: | |
# ngrok-copy # copies e.g. https://3cd67858.ngrok.io to clipboard. | |
# ngrok-copy -u # copies e.g. http://3cd67858.ngrok.io to clipboard. | |
if [[ "$1" == "-u" ]]; then | |
NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "http://.*?ngrok.io" -oh` | |
else | |
NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "https://.*?ngrok.io" -oh` |
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
#!/usr/bin/env bash | |
# Start google-chrome with the right X touch input device. | |
TOUCHID=`xinput list | ag touchscreen | grep -P "id=\K\d+" -o` | |
google-chrome --touch-devices=$TOUCHID |
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
#!/usr/bin/env python | |
""" | |
Create a reverse proxy tunnel from a remote host back to localhost. | |
Useful for sharing local services with people who can only access the remote host. | |
You may need to add the line | |
GatewayPorts yes | |
to the /etc/ssh/sshd_config of the remote. | |
And then restart the ssh service (sudo service ssh restart). |