I hereby claim:
- I am jlp78 on github.
- I am jlp78 (https://keybase.io/jlp78) on keybase.
- I have a public key ASA4GlL9W7ntCovvwzSCNXFXgrRSJpTl3YOps3_2Ki368Ao
To claim this, I am signing this object:
#! /usr/bin/perl | |
# implement the monty hall problem, run it a while, calculate percentages | |
sub make_doors { | |
my($car, @door, $i); | |
$car = int(rand(3)); | |
for ($i = 0; $i < 3; $i++) { | |
$door[$i] = ($i == $car); |
# from Aaron Toppence (eightyeight) https://ae7.st/p/734 | |
# updated to detect if TOR is not running | |
expandurl () { | |
(torsocks wget --spider -O - -S $1 2>&1 | | |
awk '/^Location/ {gsub("\\?utm_.*$",""); print $2; exit 0} | |
/socks5 libc connect: Connection refused/ {exit 1}') || | |
(echo "warning, TOR not enabled" | |
wget --spider -O - -S $1 2>&1 | | |
awk '/^Location/ {gsub("\\?utm_.*$",""); print $2; exit 0}') | |
} |
eject () { | |
case "x$1" in | |
x) | |
disk=`osascript -e 'tell application "Finder" to get name of every disk whose ejectable is true' 2>/dev/null | | |
perl -ne 'print((split(", "))[0], "\n");'` | |
;; | |
*) | |
disk="$1" | |
;; | |
esac |
I hereby claim:
To claim this, I am signing this object:
# lifted from http://bit.ly/2iJfRou (codereview.stackexchange.com) | |
# yeah, I can't believe how painful this is in Python. Perl's auto-incrementing | |
# strings have this beat by a mile. | |
def incr_chr(c): | |
return chr(ord(c) + 1) if c != 'Z' else 'A' | |
def incr_str(s): | |
lpart = s.rstrip('Z') | |
num_replacements = len(s) - len(lpart) | |
new_s = lpart[:-1] + incr_chr(lpart[-1]) if lpart else 'A' |