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 tempfile | |
import pickle | |
import os | |
from functools import wraps | |
def _encode_fcall(f, *args, **kwargs): | |
""" | |
Encode a function invocation to a dictionary (function call descriptor). | |
Structure of the function call descriptor: |
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
/* | |
Under context of Chrome browser, and if the URL starts with "https://arxiv.org/": | |
"Windows + Alt + P" - Go to PDF is in abstract page, and go to abstract page if in PDF | |
(will not overwrite clipboard) | |
*/ | |
#IfWinActive ahk_exe chrome.exe | |
#!p:: | |
Send ^l | |
Sleep, 100 | |
oldClipboard := Clipboard |
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
""" | |
Carlini-Wagner attack (http://arxiv.org/abs/1608.04644). | |
For detailed usage see my repo: https://github.com/kkew3/pytorch-cw2.git | |
Referential implementation: | |
- https://github.com/carlini/nn_robust_attacks.git (the original implementation) | |
- https://github.com/rwightman/pytorch-nips2017-attack-example.git | |
""" | |
import operator as op |
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 boltons.iterutils import remap # pip install boltons | |
from pprint import pprint | |
def inspect_structure(obj): | |
""" | |
>>> inspect_structure([1, 2]) | |
[<type 'int'>, <type 'int'>] | |
>>> import numpy as np | |
>>> inspect_structure([1, {3:'hola'}, np.eye(2)]) |
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
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
# this set of dependencies is acquired from: | |
# https://github.com/jupyter/jupyter_console/issues/158#issue-330642313 | |
jupyter==1.0.0 | |
jupyter-client==5.2.3 | |
jupyter-console==5.2.0 | |
jupyter-core==4.4.0 | |
ipython==6.4.0 | |
prompt-toolkit==1.0.15 |
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/bash | |
if [ "${BASH_SOURCE[0]}" = "\${0}" ]; then | |
echo This script intends to be sourced rather than be called >> /dev/stderr | |
exit 1 | |
fi | |
__findrt_upward() { | |
local acc="" | |
local targetrt="" | |
local venv="rt" # virtualenv name to search for |
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
if [ "${BASH_SOURCE[0]}" != "$0" ]; then | |
echo "This script intends to be called rather than be sourced" | |
return 1 | |
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
/^ *$/d | |
/^#[^!]/d | |
1,/^#!\(\/bin\/\|\/usr\/bin\/env \)\(ba\)\?sh$/p | |
/^#!\(\/bin\/\|\/usr\/bin\/env \)\(ba\)\?sh$/q |
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 delegates(method_names, to): | |
def dm(method_name): | |
def fwraps(self, *args, **kwargs): | |
wrappedf = getattr(getattr(self, to), method_name) | |
return wrappedf(*args, **kwargs) | |
fwraps.__name__ = method_name | |
return fwraps | |
def cwraps(cls): | |
for name in method_names: | |
setattr(cls, name, dm(name)) |
OlderNewer