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
find ~/Desktop -name "Screenshot*" -exec mv '{}' $SCREENSHOT_DIR \; |
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
import time | |
from contextlib import ContextDecorator | |
class Timer(ContextDecorator): | |
def __enter__(self): | |
self.start = time.time() | |
return self | |
def __exit__(self, *exc): |
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 camel_case(s): | |
s = s.split() | |
leading = [x.lower() for x in s[:1]] | |
trailing = [x.capitalize() for x in s[1:]] | |
return ''.join(leading + trailing) |
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
# Download installers | |
mkdir ~/Downloads/nvidia | |
cd ~/Downloads/nvidia | |
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run | |
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/384.59/NVIDIA-Linux-x86_64-384.59.run | |
sudo chmod +x NVIDIA-Linux-x86_64-384.59.run | |
sudo chmod +x cuda_8.0.61_375.26_linux-run | |
./cuda_8.0.61_375.26_linux-run -extract=~/Downloads/nvidia/ | |
# Uninstall old stuff | |
sudo apt-get --purge remove nvidia-* |
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
for c in df.columns: | |
if np.issubdtype(df[c].dtype, np.number): | |
# do stuff |
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 substring_index(strings, substring): | |
for i, s in enumerate(strings): | |
if substring in s: | |
return i | |
return False |
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 python3 | |
import ccxt | |
class Coin: | |
price_dict = ccxt.kraken().fetchTickers() | |
def __init__(self, abbr, name): | |
self.name = name | |
self.pair = "{}/USD".format(abbr) |
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
from datetime import datetime | |
from pandas.tseries.offsets import DateOffset, WeekOfMonth | |
from pandas.tseries.holiday import sunday_to_monday, AbstractHolidayCalendar, \ | |
Holiday, USMemorialDay, USLaborDay, USColumbusDay, USThanksgivingDay | |
class BankCalendar(AbstractHolidayCalendar): | |
rules = [ | |
Holiday("New Year's Day", month=1, day=1, observance=sunday_to_monday), |
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 list_splice(*args): | |
out = [None] * (sum(len(i) for i in args)) | |
for i, l in enumerate(args): | |
out[i::len(args)] = l | |
return out |
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
import gym | |
env = gym.make('SuperMarioBros-1-1-v0') | |
observation = env.reset() | |
done = False | |
t = 0 | |
while not done: | |
action = env.action_space.sample() # choose random action | |
observation, reward, done, info = env.step(action) # feedback from environment |
NewerOlder