Skip to content

Instantly share code, notes, and snippets.

View efraintorlo's full-sized avatar
🤯
Learning in real world, I'll back later !

ETL efraintorlo

🤯
Learning in real world, I'll back later !
View GitHub Profile
@efraintorlo
efraintorlo / jupyterhub_nginx.conf
Created January 30, 2022 00:52
Nginx config to expose JupyterHub (Use in Local Network Only)
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name 127.0.0.1;
charset utf-8;
client_max_body_size 10M;
@efraintorlo
efraintorlo / jupyterhub_supervisord.conf
Created January 30, 2022 00:45
Start JupyterHub using Supervisord, it asumes Node is available via NVM
[program:jupyterhub]
environment=HOME='/home/user'
directory=/home/user/PythonProjects/jupyterhub
command=/bin/bash -c 'source ~/.nvm/nvm.sh && source ~/.bashrc && nvm use default && source venv/bin/activate && jupyterhub'
user=user
autostart=true
autorestart=true
startretries=3
stderr_logfile = /var/log/supervisor/jupyterhub-stderr.log
stdout_logfile = /var/log/supervisor/jupyterhub-stdout.log
@efraintorlo
efraintorlo / is_preliminary_matplotlib.py
Created September 6, 2017 20:12
Add Text "Preliminary" to the Matplotlib figure's background
def is_preliminary(ax, color='0.5', alpha=0.4):
""" Add the 'Preliminary' legend into a plot
ax: Must be a matplotlib.axes._subplots.AxesSubplot
In practice ax is a Seaborn's plot.
"""
sizes = ax.figure.get_size_inches()
size = 6.0 * np.sqrt(sizes[0]**2.0 + sizes[1]**2.0)
ax.figure.text(0.5, 0.5, 'Preliminary',
fontsize=size, color=color,
@efraintorlo
efraintorlo / import_data_jupyter_azureML.py
Created July 13, 2017 15:11
Import dataset to Jupyter in Azure Machine Learning
from azureml import Workspace
ws = Workspace()
ds = ws.datasets['data.csv']
frame = ds.to_dataframe()
@efraintorlo
efraintorlo / get_info_from_pdf_paper.py
Created February 20, 2017 02:47
Retrieve BibTeX info from PDF paper (it works if doi is included in the text)
from pyinspire import pyinspire
from PyPDF2 import PdfFileReader
import re
import sys
pdf_file = 'paper_from_prd.pdf' # local file
doi_re = re.compile('10.(\d)+/([^(\s\>\"\<)])+')
input = PdfFileReader(file(pdf_file, "rb"))
text = input.getPage(0).extractText()
@efraintorlo
efraintorlo / Makefile_VIM_installer.makefile
Created December 25, 2016 17:35
VIM installer from git source.
SHELL := /bin/bash
#-----------------------------------------------
# __ __ _ __ _ _
# | \/ | __ _| | _____ / _(_) | ___
# | |\/| |/ _ | |/ / _ \ |_| | |/ _ \
# | | | | (_| | < __/ _| | | __/
# |_| |_|\__,_|_|\_\___|_| |_|_|\___|
#
#-----------------------------------------------
# VIM INSTALLER FROM SOURCE
@efraintorlo
efraintorlo / [email protected]
Last active October 8, 2016 05:26
Clean the LaTeX output for functions and expressions in SageMathCloud. This can be used to dump latex in files or for show clean latex outputs inside sagews notebooks.
import re
def latex_clean(f):
_latex = re.sub('\\\\left\([{}\w\s\\\\,]+\s\\\\right\)\s\\\\\s\{\\\\mapsto\}\s\\\\\s', '', f._latex_())
return _latex
def show_clean(f):
_latex = r"$" + latex_clean(f) + "$"
show(_latex)
@efraintorlo
efraintorlo / player_control.sh
Created August 16, 2016 05:21
Player control from Terminal (Aliases Linux)
alias pp="playerctl play-pause && playerctl metadata title"
alias pn="playerctl next && playerctl metadata title"
alias pb="playerctl previous && playerctl metadata title"
alias p+="playerctl volume"
alias pv="playerctl volume"
@efraintorlo
efraintorlo / volume_alias_linux.sh
Created August 16, 2016 05:18
Volume Up & Down from Terminal Aliases (Linux)
alias k='amixer -D pulse sset Master 10%+ |sed -n "s/.*\[\([^]]*\%\)\].*/Volume:\1/p" | head -1'
alias j='amixer -D pulse sset Master 10%- |sed -n "s/.*\[\([^]]*\%\)\].*/Volume:\1/p" | head -1'
alias kk='k && k'
alias jj='j && j'
@efraintorlo
efraintorlo / odrive_status_zsh_theme.sh
Last active August 2, 2016 19:44
Odrive status for zsh
# check this ys.zsh-theme fork:
# https://github.com/elchinot7/dotfiles/blob/master/ys-modified-chinot7.zsh-theme
# This can be used to show the Odrive Sync status in Linux/OSX
# Add the line:
# ${odrive_info} \
# to the string PROMPT
# Odrive status
local odrive_info='$(ys_prompt_odrive)'