Skip to content

Instantly share code, notes, and snippets.

View paulochf's full-sized avatar
⌨️

Paulo Haddad paulochf

⌨️
View GitHub Profile
@paulochf
paulochf / Preferences.sublime-settings
Last active August 29, 2015 14:05
My Sublime Text 3 editor settings
{
"always_prompt_for_file_reload": true,
"always_show_minimap_viewport": true,
"animation_enabled": true,
"atomic_save": true,
"auto_close_tags": true,
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
@paulochf
paulochf / strsplit.sql
Created February 10, 2015 20:20
MySQL split function: get nth splitted term from string separated value
-- Retrieved from http://dev.mysql.com/doc/refman/5.6/en/string-functions.html at 2015-feb-10 18:16
-- Working on MySQL version 5.6.19-0ubuntu0.14.04.1 (Ubuntu)
--
-- Posted by Chris Stubben on August 21 2008 3:49pm
-- Split delimited strings
CREATE FUNCTION
strSplit(x VARCHAR(255), delim VARCHAR(12), pos INT) RETURNS VARCHAR(255)
return
REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
@paulochf
paulochf / countries.sql
Last active April 26, 2024 09:50 — forked from adhipg/countries.sql
Outdated. Used with discretion. Accepting updates.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@paulochf
paulochf / ipython_notebook_large_width.py
Last active September 22, 2022 22:22
IPython/Jupyter Notebook enlarge/change cell width
from IPython.display import display, HTML
display(HTML(data="""
<style>
div#notebook-container { width: 95%; }
div#menubar-container { width: 65%; }
div#maintoolbar-container { width: 99%; }
</style>
"""))
@paulochf
paulochf / gist:80babb1e6e350b72e9ba
Last active September 2, 2016 20:40
Installing pyenv + virtualenv + Python 3.4.3 + new environment
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
pyenv install 3.4.3
mkvirtualenv -p `pyenv which python3` env-py343
@paulochf
paulochf / urldecode.sql
Created March 11, 2016 19:10
URL decode for MySQL
-- Found at http://stackoverflow.com/a/17922821/597349
DROP TABLE IF EXISTS urlcodemap;
CREATE TABLE `urlcodemap` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`encoded` VARCHAR(128) NOT NULL,
`decoded` VARCHAR(128) NOT NULL,
UNIQUE KEY urlcodemapUIdx1(encoded),
PRIMARY KEY (`id`)
@paulochf
paulochf / Workshop.ipynb
Last active August 26, 2016 13:22
Python presentation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paulochf
paulochf / pydata_dc_2016_vi_in_python.ipynb
Created November 3, 2016 17:14 — forked from AustinRochford/pydata_dc_2016_vi_in_python.ipynb
PyData DC 2016 Variational Inference in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paulochf
paulochf / dataframe_diff.py
Created April 26, 2017 20:21
Prints differences between two given DataFrame's
import numpy as np
import pandas as pd
def df_diff(df1, df2):
# Extracted from
# http://stackoverflow.com/a/17095620
diffs = df1 != df2
ne_stacked = diffs.stack()
changed = ne_stacked[ne_stacked]
@paulochf
paulochf / types_max_values_ordering.ipynb
Created November 28, 2017 19:40
Numpy types ordering regarding their maximum values
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.