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
ask() { | |
local prompt default reply | |
while true; do | |
if [ "${2:-}" = "Y" ]; then | |
prompt="Y/n" | |
default=Y | |
elif [ "${2:-}" = "N" ]; then | |
prompt="y/N" |
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
[print("{:<30}{:<30}".format(key, str(val))) for key, val in locals().items() if "__" not in key] |
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
# Function | |
wait_file() { | |
local file="$1"; shift | |
local wait_seconds="${1:-10}"; shift # 10 seconds as default timeout | |
until test $((wait_seconds--)) -eq 0 -o ! -f "$file" ; do sleep 1; done | |
((++wait_seconds)) | |
} |
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
# Semi-Secret | |
actualities.google.com – alias for news.google.com | |
d.google.com – same as www.google.com | |
email.google.com – redirects to mail.google.com (obviously) | |
fusion.google.com – redirects to www.google.com | |
locale.google.com – redirects to local.google.com | |
purchase.google.com – same as www.google.com | |
relay.google.com – nothing (possibly a mail relay server?) |
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
# Simple script to visualize a binary string as a pixel matrix | |
# Example input: "01100001110101011100010[...]" | |
# Note that the data length should be some n^2 to produce a square image | |
import numpy as np | |
from math import sqrt | |
file = open('input.txt', 'r') | |
cont = file.read()[:-1] | |
data = [_char == '1' for _char in cont] |
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 python2.7 | |
from Crypto.Util.number import long_to_bytes | |
import gmpy2 | |
# values given by private key | |
p = ... | |
q = ... | |
dp = ... | |
dq = ... | |
iq = gmpy2.invert(q, p) # or given by private key |
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 re | |
>>> str = "10abc9df7a8z" | |
>>> searcher = re.compile("[0-9]+[a-zA-Z]+") | |
>>> blocks = searcher.findall(str) | |
>>> blocks | |
['10abc', '9df', '7a', '8z'] | |
>>> searcher = re.compile("[0-9]+|[a-zA-Z]+") | |
>>> parts = [searcher.findall(block) for block in blocks] | |
>>> parts |
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
String.prototype.replaceAll = function (search, replacement) { //String replace function | |
return this.replace(new RegExp(search, 'g'), replacement); | |
}; |
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
//Re-maps a number from one range to another. | |
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) | |
{ | |
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; | |
} |
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
var sId = /SESS\w*ID=([^;]+)/i.test(document.cookie) ? RegExp.$1 : false; |
OlderNewer