Skip to content

Instantly share code, notes, and snippets.

View Den1al's full-sized avatar
🎯
Focusing

Den1al Den1al

🎯
Focusing
View GitHub Profile
@Den1al
Den1al / pyenv-bootstrap.sh
Last active July 29, 2019 08:54
Pyenv Bootstrap
# 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
@Den1al
Den1al / zsh-bootstrap.sh
Last active July 25, 2019 08:37
ZSH Bootstrap Script
# 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
@Den1al
Den1al / nodejs-async-dns-lookup.js
Created April 20, 2019 11:20
converting the old callback based DNS lookup in NodeJS to modern Async function
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);
}
@Den1al
Den1al / sanic-render-template.py
Created April 13, 2019 18:10
Injecting the render_template function to sanic apps and templates
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):
@Den1al
Den1al / pandas-plot-bar-annotation.py
Created January 9, 2019 11:14
Pandas plot bar/barh annotation script
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(
@Den1al
Den1al / pandas-explode.py
Created November 29, 2018 09:05
An implementation of HIVE's explode function in pandas
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
@Den1al
Den1al / pickle-payload.py
Created September 27, 2018 13:20 — forked from mgeeky/pickle-payload.py
Python's Pickle Remote Code Execution payload template.
#!/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
@Den1al
Den1al / all.txt
Created March 18, 2018 12:26 — forked from jhaddix/all.txt
all wordlists for every dns enumeration tool... ever.
@
*
0
00
0-0
000
0000
00000
000000
@Den1al
Den1al / pandas-groupby-collect-set.py
Last active January 14, 2022 17:25
Pandas collect-set operator on a groupby object
# 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)
})
@Den1al
Den1al / generic-repr.py
Last active February 13, 2018 16:58
A decorator that injects a generic repr function to a class
# 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) + '>'