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
# pyenv | |
sudo apt-get install -y --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev | |
git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc | |
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc | |
source ~/.zshrc | |
pyenv install 3.7.4 | |
pyenv global 3.7.4 |
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
# general | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
# zshrc | |
sudo apt install -y zsh | |
sudo apt-get install -y powerline fonts-powerline | |
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc | |
sudo chsh -s /bin/zsh ubuntu |
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 { lookup } from 'dns'; | |
export default async function(name) { | |
return new Promise((resolve, reject) => { | |
lookup(name, (err, ips) => { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(ips); | |
} |
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 sanic import Sanic, Blueprint | |
from jinja2 import Environment, PackageLoader, select_autoescape | |
from sanic.response import html | |
def get_package_name(): | |
return __name__.split('.')[0] | |
class InjectJinjaSupport(object): |
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 pandas as pd | |
from matplotlib import pyplot as plt | |
plt.figure(figsize=(10,5)) | |
ax = df.column1.sort_values(ascending=False).head(10).plot.barh() | |
ax.set_title("My Awesome Title", fontsize=12) | |
for patch in ax.patches: | |
ax.text( |
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 explode(df, by_column, new_col_name): | |
rows = [] | |
for row in df.itertuples(): | |
for value in getattr(row, by_column): | |
rows.append({ | |
new_col_name: value, | |
**{ | |
key: getattr(row, key) | |
for key in row._fields |
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
#!/usr/bin/python | |
# | |
# Pickle deserialization RCE payload. | |
# To be invoked with command to execute at it's first parameter. | |
# Otherwise, the default one will be used. | |
# | |
import cPickle | |
import sys | |
import base64 |
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
@ | |
* | |
0 | |
00 | |
0-0 | |
000 | |
0000 | |
00000 | |
000000 |
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
# author: @Daniel_Abeles | |
# date: 13/02/2018 | |
# assuming we have a data frame called "df" | |
# we can "groupby" by a column col1 | |
# and collect all the distinct values of col2 | |
df.groupby("col1").agg({ | |
"col2": lambda x: set(x) | |
}) |
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
# author: @Daniel_Abeles | |
# date: 23/12/2017 | |
def inject_generic_repr(cls): | |
""" Injects a generic repr function """ | |
def generic_repr(that): | |
class_items = [f'{k}={v}' for k, v in that.__dict__.items()] | |
return f'<{that.__class__.__name__} ' + ', '.join(class_items) + '>' |