Skip to content

Instantly share code, notes, and snippets.

sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate
sudo chmod +x /usr/local/bin/rsub
@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
@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 / 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
# 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 [email protected]:datarevenue-berlin/$PROJECT.git
ln -s $PROJECT bin;
fi
"""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
@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
@kayibal
kayibal / kick_table.txt
Created August 6, 2019 22:26
Best emoji ever
(╯°□°)╯︵ ┻━┻
@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 / 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"]