Skip to content

Instantly share code, notes, and snippets.

View wespatrocinio's full-sized avatar

Weslley S. Patrocinio wespatrocinio

View GitHub Profile

Keybase proof

I hereby claim:

  • I am wespatrocinio on github.
  • I am wespatrocinio (https://keybase.io/wespatrocinio) on keybase.
  • I have a public key ASC0k-9go5xnhUW0gsfUwXqHlLOcGyuJF4QxQk_W92i7Cwo

To claim this, I am signing this object:

@wespatrocinio
wespatrocinio / cedilla_manjaro.md
Created May 4, 2020 13:12
How to set cedilla char into Manjaro with US Intl keyboard
@wespatrocinio
wespatrocinio / .XCompose
Created May 4, 2020 13:09
.XCompose file to latin characters
#-#-#-#-#-#-#-#
# ~/.XCompose
# To change the US International keyboard layout to behave like the
# Microsoft Windows (TM) version of the layout
# by @tamh [48bytes at gmail com]
#
# Released under GPL v3+. Please refer to it by going to:
# <http://www.gnu.org/licenses/gpl-3.0.html>
#-#-#-#
@wespatrocinio
wespatrocinio / run_jupyter_with_no_token.sh
Created April 14, 2020 18:55
Run a Jupyter Lab | Notebook instance with no token and without checking it (to enable remote VS Code connection)
jupyter lab --port=8866 --NotebookApp.token='' --no-browser --NotebookApp.disable_check_xsrf=True
jupyter-notebook --port=8866 --NotebookApp.token='' --no-browser --NotebookApp.disable_check_xsrf=True
@wespatrocinio
wespatrocinio / BK_tree_sample.py
Last active February 16, 2020 17:46
Sample about how to create a BK tree and use it
# pip install pybktree && pip install python-Levenshtein
from pybktree import BKTree
from Levenshtein import distance as levenshtein_distance
WORDS_LIST = ['car', 'house', 'jar', 'mouse', 'engineer', 'pioneer', 'Jamaica']
tree = BKTree(levenshtein_distance, WORDS_LIST)
@wespatrocinio
wespatrocinio / run_jupyter_lab_token_browser.sh
Created February 14, 2020 16:24
Start jupyter lab server with no token & no browser
jupyter lab --port=<PORT> --NotebookApp.token='' --no-browser
@wespatrocinio
wespatrocinio / edition_distance.py
Last active February 10, 2020 20:23
Code to calculate the edition distance between two strings
# Install it by "pip install python-Levenshtein"
from Levenshtein import distance
def calculate_distance(str_1, str_2):
""" Given two string, applies the Levenshtein's method to calculate the
editon distance
"""
return distance(str_1, str_2)
@wespatrocinio
wespatrocinio / random_dataframe.py
Last active February 6, 2020 12:42
Code to generate a random 2D Pandas dataframe
import random
import pandas as pd
import numpy as np
def generate_random_df_2d(x_size: int, y_size: int) -> pd.DataFrame:
""" Generate a dataframe with dimensions 'x_size' and 'y_size' filled with
random float numbers between 0 and 1
"""
return pd.DataFrame(np.random.random_sample(size=(x_size, y_size)))
from pyspark import SparkContext
import random
def inside(p):
x, y = random.random(), random.random()
return x*x + y*y < 1
NUM_SAMPLES = 1000
@wespatrocinio
wespatrocinio / tables_size.sql
Created December 21, 2017 12:02
Get the table size of a Redshift database
SELECT tbl, name, size_mb FROM
(
SELECT tbl, count(*) AS size_mb
FROM stv_blocklist
GROUP BY tbl
)
LEFT JOIN
(select distinct id, name FROM stv_tbl_perm)
ON id = tbl
ORDER BY size_mb DESC