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 pprofile | |
profiler = pprofile.Profile() | |
profiler.enable() | |
# Your slow code here | |
profiler.disable() | |
with open('/some/path/to/profile.prof', 'w') as file_: |
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
// #define GENERAL_SWITCH_PIN 13 // 8 | |
// #define DIRECTION_PIN 12 // 9 | |
// #define UP_SWITCH_PIN 11 // 10 | |
// #define DOWN_SWITCH_PIN 10 // 11 | |
// #define BUTTON_UP_PIN 9 // 12 | |
// #define BUTTON_DOWN_PIN 8 // 13 | |
#define GENERAL_SWITCH_PIN 6 // 8 | |
#define DIRECTION_PIN 5 // 9 | |
#define UP_SWITCH_PIN 3 // 10 |
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 | |
if wmctrl -m | grep "mode: ON"; then | |
exec wmctrl -k off | |
else | |
exec wmctrl -k on | |
fi |
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 | |
du -k --max-depth=1 | sort -nr | awk ' | |
BEGIN { | |
split("KB,MB,GB,TB", Units, ","); | |
} | |
{ | |
u = 1; | |
while ($1 >= 1024) { | |
$1 = $1 / 1024; | |
u += 1 |
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
# Config taken from http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ | |
set-option -g default-shell $SHELL | |
# split panes using | and - | |
bind | split-window -h | |
bind - split-window -v | |
unbind '"' | |
unbind % |
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
# to get in a terminal: curl -X GET http://is.gd/installzsh_sh > installzsh.sh | |
TARGET_USER=$1 | |
echo "Installing zsh..." | |
sudo apt-get install git curl zsh -y > /dev/null; | |
echo "Installing oh-my-zsh" | |
if [ "$TARGET_USER" != "" ]; then | |
echo "Installing oh-my-zsh for user $TARGET_USER"; | |
export RUNZSH=no |
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
# From stackoverflow answer https://stackoverflow.com/a/938800 | |
import os | |
_proc_status = '/proc/%d/status' % os.getpid() | |
_scale = {'kB': 1024.0, 'mB': 1024.0*1024.0, | |
'KB': 1024.0, 'MB': 1024.0*1024.0} | |
def _VmB(VmKey): | |
'''Private. |
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 sys | |
import socket | |
from struct import unpack | |
import pprint | |
from collections import namedtuple | |
interface = sys.argv[1] | |
raw_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) |
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
# Place this in /etc/ufw/before.rules | |
*nat | |
-A PREROUTING -p tcp -s 10.10.0.0/24 --dport 7000 -j DNAT --to-destination 10.0.0.3:7000 | |
-A PREROUTING -p tcp -s 10.10.0.0/24 --dport 9160 -j DNAT --to-destination 10.0.0.3:9160 | |
-A PREROUTING -p tcp -s 10.10.0.0/24 --dport 9042 -j DNAT --to-destination 10.0.0.3:9042 | |
COMMIT |
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
upstream local { | |
server localhost:19999; | |
keepalive 64; | |
} | |
upstream some_other { | |
server some_other:19999; | |
keepalive: 64; | |
} |
OlderNewer