This file contains hidden or 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 | |
| import sys | |
| import subprocess | |
| import netifaces | |
| if __name__ == "__main__": | |
| ipv4 = netifaces.ifaddresses('wlan0')[netifaces.AF_INET][0]['addr'] | |
| print ipv4 | |
| if len(sys.argv) > 1: | |
| subprocess.Popen(["sm", "-f", "#000", "-b", "#DDD", " {} ".format(ipv4)]) |
This file contains hidden or 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
| object SententialCalculus { | |
| // Here is a scala program which classifies an SC sentence. | |
| // It recognizes whether the sentence is an SC sentence, | |
| // and returns the parsed typed tree. | |
| // You can run this with the following command, but here's | |
| // an executive summary. | |
| // fsc -d build classifier.scala && scala -classpath build SententialCalculus | |
| // Executive summary: | |
| // If the input is a single predicate atom, this is an atom. | |
| // If the input starts with a NOT, this is a negation. |
This file contains hidden or 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). |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |