Skip to content

Instantly share code, notes, and snippets.

def test_get_price():
exchange_gw = UniswapGateway()
usdt = Token(address="0xdAC17F958D2ee523a2206206994597C13D831ec7")
wbtc = Token(address="0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599")
order = Order(
inp_token=usdt,
out_token=wbtc,
amount=1
)
@kayibal
kayibal / build_pypi_url.py
Last active October 17, 2019 15:36
DR PyPi URL builder
#!/Users/kayibal/miniconda3/bin/python
import boto3
import click
from urllib.parse import urlparse, urlunparse
def pypi_url(env):
ssm = boto3.client("ssm")
url = ssm.get_parameter(Name=f"/CodeBuild/PyPi/{env}/url", WithDecryption=True)[
"Parameter"
]["Value"]
@kayibal
kayibal / style.py
Created October 16, 2019 13:44
Data Revenue CI styled plots
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_style('whitegrid')
sns.set_palette(sns.dark_palette((0.6, 0.6, 0.6), reverse=True))
plt.rcParams["figure.figsize"] = (15, 7)
@kayibal
kayibal / kick_table.txt
Created August 6, 2019 22:26
Best emoji ever
(╯°□°)╯︵ ┻━┻
@kayibal
kayibal / compute_overlap.py
Created June 26, 2019 11:38
Computes overlap between two ranges
import numpy as np
def compute_overlap(x1, x2, y1, y2):
if x2 >= y1 and y2 >= x1:
if x1 < y1 < x2 and x2 < y2:
return x2 - y1
elif y1 < x1 < y2 and y2 < x2:
return y2 - x1
elif x1 < y1 and y2 < x2:
return y2 - y1
"""Recommendation module.
This module deals with using lightFM models in production and includes a
LightFm subclass which provides a predict_online method to use in API or
similar scenarios.
"""
import operator
from logging import getLogger
import numpy as np
# export PROJECT=is24_user_scoring
# export PROD_SETTINGS=is24.settings.production
# export VERSION=v2.0.1
sleep 5m
cd /home/ec2-user
sudo pip install awscli
if [ ! -d "$PROJECT" ]; then
git clone git@github.com:datarevenue-berlin/$PROJECT.git
ln -s $PROJECT bin;
fi
@kayibal
kayibal / install_xgboost.sh
Created May 3, 2017 18:02
Installs xgboost pyhton package from master
#!/usr/bin/env bash
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
sudo make -j4
cd python-package
python3 setup.py install
rm -rf xgboost
@kayibal
kayibal / best_models.py
Created February 4, 2017 16:50
Best models for mlp
import re
import nltk
from nltk.tokenize.regexp import RegexpTokenizer
from nltk.corpus import stopwords
from sklearn.svm import SVC
from sklearn.naive_bayes import BernoulliNB
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.feature_selection import SelectPercentile
@kayibal
kayibal / idle_instance_notification.sh
Last active November 17, 2016 13:40
Send an SMS in case the ec2 instance is idle
#!/usr/bin/env bash
MIN_LOAD=1
ADMIN_NUMBERS=( "+49NUMBER1" "+49NUMBER2" )
if ! who | grep -q *; then
echo "users logged in"
exit 0
fi