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
| #!/bin/bash | |
| ####### | |
| # A **very** dirty hack to switch second and third screen. | |
| # The reasons behind this is that, my Thinkpad dock always assigns random device names | |
| # whenever I connect the Thinkpad to it. Therefore I cannot save the setting and call it back. | |
| # This script has some assumptions: | |
| # * Alternative screen names always start with 'DP-' | |
| # * The laptop's screen name is always 'eDP-1' | |
| # * The laptop is the left-most screen. |
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
| ##### | |
| # You'll be needing two machines, the target machine and source one (makes sense, right)? | |
| ##### | |
| # On the target machine | |
| nc -l 55555 | gzip -d -c | mysql <database name> -u<user> -p<password> [ | <decrypt> ] | |
| ##### | |
| # On the source machine | |
| mysqldump -u<user> -p<password> <database name> | gzip | nc <ip of target server> 55555 [ | <encrypt> ] |
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 | |
| # | |
| # udp_hole_punch_tester.py - UDP Hole Punching test tool | |
| # | |
| # Usage: udp_hole_punch_tester.py remote_host remote_port | |
| # | |
| # Run this script simultaneously on 2 hosts to test if they can punch | |
| # a UDP hole to each other. | |
| # | |
| # * remote_port should be identical on 2 hosts. |
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
| def parity_check(incoming, type="even"): | |
| """Pass the incoming bits as string""" | |
| if type != "even" and type != "odd": | |
| return -1 | |
| if type == "even": | |
| sum = 0 | |
| if type == "odd": | |
| sum = 1 | |
| for i in incoming: sum += int(i) | |
| return sum % 2 |
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
| ############################################ | |
| # This is for CRC-8 Maxim/Dallas Algorithm | |
| # Improved with less variable and functions | |
| # Supports both Python3.x and Python2.x | |
| # Has append and check functions | |
| # When standalone, can read from either arguments or stdin | |
| # Writes to stdout cleaner | |
| # http://gist.github.com/eaydin | |
| ############################################ |
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
| ### useful when parsing strings to paragraphs | |
| ### to reassemble from lists with each element | |
| ### having a maximum length | |
| ### useful for low level reportlab pdf creation | |
| ### usage: stripLongString("My Very Extra Long String", maximumLengthINTEGER) | |
| ### Returns an array | |
| def chunkstring(string, length): | |
| #got this from http://stackoverflow.com/a/18854817/1278994 |
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
| sed 's/print \"\(.*\)\"/print\(\"\1\"\)/' filename.py |
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
| #!/bin/bash | |
| command=”/path-to/my_process.sh > /dev/null 2>&1″ | |
| job=”*/5 * * * * $command” | |
| cat <(grep -i -v “$command” <(crontab -l)) <(echo “$job”) | crontab - |