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
socat TCP-LISTEN:<localport> SOCKS4A:localhost:<host>:<remoteport>,socksport=9050 | |
# for example, to ssh into secret.shell.server.org via tor, do: | |
$ socat TCP-LISTEN:22222 SOCKS4A:localhost:secret.shell.server.org:22,socksport=9050 & | |
$ ssh localhost -p 22222 |
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
def throwingFunction(): Unit = throw RuntimeError() | |
// own implementation of assertThrows | |
def assertThrows[E](f: => Unit)(implicit eType:ClassTag[E]): Unit = | |
try f | |
catch | |
case _: E => return | |
case e: Any => Assertions.fail(s"Expected ${eType.runtimeClass.getName} got ${e.getClass}") | |
Assertions.fail(s"Expected ${eType.runtimeClass.getName}") |
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
UNKNOWN_OBJECT.getClass.getDeclaredFields.foreach(v => println(s"${v.getName}: $v")) |
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
sudo apt install google-drive-ocamlfuse # to mount google drive as a pseudo fs | |
sudo apt install athena-jot # for generating the list of {A..Z} in fish shell on the fly | |
sudo apt install parallel # to control running jobs in parallel | |
# set up google drive, see https://github.com/astrada/google-drive-ocamlfuse/wiki/Authorization | |
google-drive-ocamlfuse | |
# mount google drive | |
set DRIVE_DIR GoogleDrive | |
google-drive-ocamlfuse ~/$DRIVE_DIR/ |
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
set FROM_EXT mp4 | |
set TO_EXT mkv | |
set ABR 128k | |
set CRF 22 | |
for i in *.$FROM_EXT | |
set BASENAME (basename $i .$FROM_EXT) | |
set DIRNAME (dirname $i) | |
nice -n 19 time ffmpeg -i "$DIRNAME/$BASENAME.$FROM_EXT" -vcodec libx265 -crf $CRF -ac 2 -c:a libmp3lame -b:a $ABR output.$TO_EXT; and \ | |
mv output.$TO_EXT "$DIRNAME/$BASENAME.$TO_EXT"; and \ | |
rm "$i" |
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
def command(args): | |
pass | |
parser = argparse.ArgumentParser() | |
subparser = parser.add_subparsers(title="subcommands") | |
command_parser = subparser.add_parser("command") | |
command_parser.set_defaults(func=command) | |
command_parser.add_argument("--dummy", help="some arg to the subcommand") | |
args = parser.parse_args() |
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 functools import wraps | |
def decorator_with_argument(argument=None): | |
def actual_decorator(func): | |
@wraps(func) | |
def func_wrapper(*args, **kwargs): | |
return do_stuff(func(*args, **kwargs), argument) |
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
{ | |
"Res": { | |
"Connections": { | |
"Connection": [ | |
{ | |
"@duration": "PT2H3M33S", | |
"@transfers": "2", | |
"Dep": { | |
"@time": "2018-03-20T07:47:27", | |
"Addr": { |
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
http://mobility.api.here.com/v1/route | |
?app_id={YOUR_APP_ID} | |
&app_code={YOUR_APP_CODE} | |
&profile=parkandride | |
&dep={YOUR_START_POINT} | |
&arr=41.884238,-87.638862 | |
&time=2018-03-20T07:30:00 |
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
{ | |
"Res": { | |
"Connections": { | |
"Connection": [ | |
{ | |
"@duration": "PT2H3M33S", | |
"@transfers": "2", | |
"Sections": { | |
"Sec": [ | |
{ |
NewerOlder