Skip to content

Instantly share code, notes, and snippets.

View GuiMarthe's full-sized avatar

Guilherme Marthe GuiMarthe

View GitHub Profile
@GuiMarthe
GuiMarthe / compinit.zsh
Created January 2, 2023 15:34 — forked from ctechols/compinit.zsh
Speed up zsh compinit by only checking cache once a day.
# On slow systems, checking the cached .zcompdump file to see if it must be
# regenerated adds a noticable delay to zsh startup. This little hack restricts
# it to once a day. It should be pasted into your own completion file.
#
# The globbing is a little complicated here:
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct.
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error)
# - '.' matches "regular files"
# - 'mh+24' matches files (or directories or whatever) that are older than 24 hours.
autoload -Uz compinit
@GuiMarthe
GuiMarthe / validateType.js
Created January 2, 2023 14:30 — forked from Nick-Gabe/validateType.js
Validate types of an object or value based on expected result.
function validateType(expected, input) {
if (!input) return false;
// maps verifications for standard types and custom classes
const typeVerifier = {
Object: (x) => typeof x === 'object' &&
!Array.isArray(x) &&
x !== null,
String: (x) => typeof x === 'string',
Number: (x) => typeof x === 'number',
@GuiMarthe
GuiMarthe / README.md
Created December 12, 2022 18:25 — forked from elalemanyo/README.md
Debug zsh startup time

Debug zsh startup time

  1. Inject profiling code

    At the beginning of your .zshrc add following: zmodload zsh/zprof

    and at the end add: zprof

    This will load zprof mod and display what your shell was doing durung your initialization.

import pandas as pd
import datetime
from datetime import datetime as dt
from dateutil.relativedelta import *
class TimeBasedCV(object):
'''
Parameters
----------
train_period: int
def get_feature_names(column_transformer):
"""Get feature names from all transformers.
Returns
-------
feature_names : list of strings
Names of the features produced by transform.
"""
# Remove the internal helper function
#check_is_fitted(column_transformer)
@GuiMarthe
GuiMarthe / pre-commit-python-breakpoint.sh
Last active August 10, 2021 17:43
A pre commit hook for finding python `brekpoint` or `set_trace` in *.py files.
#!/bin/bash
grep_output=$(grep --color=always -E '^.*(breakpoint|set_trace)\(\)' -H -n -R -I -o --include="*.py")
[ $grep_output ] \
&& echo 'Found breakpoint or set_trace in your code.' \
&& echo "$grep_output"\
&& exit 1 \
|| exit 0
@GuiMarthe
GuiMarthe / degreener.sh
Created April 30, 2021 01:50
When you copy a file from an external drive onto linux, the files gets weird permissions and gets colored differently by your standard `ls` std outupt. This changes the permission so that it degreens it.
//When you copy a file from an external drive onto linux, the files gets weird permissions and gets colored differently by your standard `ls` std outupt.
//This changes the permissions so that it degreens it.
function degreen() {
chmod -R a-x,o-w,+ $@
}
@GuiMarthe
GuiMarthe / psgrep.sh
Created April 13, 2021 15:13
neat little function to show a parent and child process in a terminal
function psgrep() { ps axuf | grep -v grep | grep "$@" -i --color=auto; }
@GuiMarthe
GuiMarthe / crossing.py
Last active September 13, 2021 20:11
A quick pandas function to return the cross product of two data frames, kind of emulating tidyr::crossing function.
import pandas as pd
from functools import reduce
def crossing(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame:
"""
Returns a data frame with the cross product (every pair possible) of rows
between df1 and df2
"""
df1["join_key"] = 0
df2["join_key"] = 0
@GuiMarthe
GuiMarthe / www.bclplaw.com.litigation.R
Created September 16, 2019 20:03
A nice chart by @hrbrmstr on twitter that I want to save for later
library(ggalt)
library(hrbrthemes)
library(tidyverse)
structure(list(district = structure(13:1, .Label = c("E.D. New York",
"D. New Jersey", "W.D. Wisconsin", "D. Delaware", "S.D. Florida",
"N.D. Illinois", "M.D. Florida", "S.D. New York", "D. Connecticut",
"D. Maryland", "N.D. California", "N.D. Georgia", "C.D. California"
), class = "factor"), `2017` = c(0.14, 0.16, 0.14, 0.01, 0.01,
0.04, 0.04, 0.04, 0.03, 0.01, 0.01, 0.06, 0.03), `2018` = c(0.26,