Skip to content

Instantly share code, notes, and snippets.

View paulochf's full-sized avatar
⌨️

Paulo Haddad paulochf

⌨️
View GitHub Profile
@paulochf
paulochf / redshift_dim_date.sql
Created September 2, 2022 00:21
Date dimension view for Redshift
-- Heavily inspired by this StackOverflow thread
-- https://stackoverflow.com/questions/47230534/how-do-i-create-a-dates-table-in-redshift
-- and tired of bumping my head in the wall after getting the generate_series() error.
DROP VIEW IF EXISTS public.dim_date;
CREATE VIEW public.dim_date AS
WITH
digit AS (
SELECT
0 AS D
@paulochf
paulochf / pandas_set_operation.ipynb
Last active July 25, 2018 17:44
Set intersection between pandas columns
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paulochf
paulochf / get_slack_threads.ipynb
Last active July 30, 2018 16:26
Get starred threads dialogs from Slack
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paulochf
paulochf / moar_pandas.py
Last active April 26, 2018 18:45
More rows/columns/width in pandas table printings without truncation
import pandas as pd
pd.set_option("display.max_rows", 200)
pd.set_option("display.max_columns", 100)
pd.set_option("display.max_colwidth", 200)
## Reset to defaults
# pd.reset_option("^display")
@paulochf
paulochf / jupyter.service
Created April 18, 2018 01:42
Jupyter Notebook as service in Ubuntu
# After Ubuntu 16.04, Systemd becomes the default.
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd
# https://gist.github.com/whophil/5a2eab328d2f8c16bb31c9ceaf23164f
# PUT THIS IN /usr/lib/systemd/system
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
@paulochf
paulochf / s3fs_profile.py
Created March 24, 2018 00:03
Use python s3fs to connect to AWS using specific profile (already in ~/.aws/)
from s3fs.core import S3FileSystem
s3 = S3FileSystem(anon=False, profile_name="your-profile-name")
print(s3.ls("s3://your-bucket/some-folder"))
@paulochf
paulochf / fix.sh
Created February 15, 2018 19:35
Pritunl icon in Ubuntu top task bar workaround
#!/usr/bin/env bash
# Doesn't fix the icon to have the right appearance, but stop the top bar from being ridiculously big.
cd /usr/share/pritunl_client && for f in `ls *svg`; do sudo sed -i -E -e 's/200([ "])/24\1/g' $f; done && cd -
@paulochf
paulochf / mapping_street_carnival.ipynb
Last active February 12, 2018 00:38
Mapping street carnival parties
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paulochf
paulochf / load.ipynb
Created February 1, 2018 20:22
Load data matrix using Numpy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paulochf
paulochf / some_transformers.py
Created January 16, 2018 16:03
A label enconding transformer
from sklearn.base import BaseEstimator, TransformerMixin
class NoFitMixin:
"""Gives fit method by inheritance."""
def fit(self, X, y=None, **fit_params):
return self
class LabelFeaturizer(BaseEstimator, TransformerMixin, NoFitMixin):