Skip to content

Instantly share code, notes, and snippets.

View GuiMarthe's full-sized avatar

Guilherme Marthe GuiMarthe

View GitHub Profile
import pandas as pd
import datetime
from datetime import datetime as dt
from dateutil.relativedelta import *
class TimeBasedCV(object):
'''
Parameters
----------
train_period: int
library(tidyverse)
library(RecordLinkage)
df <- data.frame(name = c("Agent Peggy Carter", "Peggy Carter", "Outro Nome"),
sum = 1:3) %>%
mutate_if(is.factor, as.character)
# Comparando sempre o nome anterior
df %>%
mutate(dist = levenshteinSim(name, lag(name, default = "")),
final_name = ifelse(dist > 0.5, lag(name), name)) %>%
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@elalemanyo
elalemanyo / README.md
Last active June 21, 2024 03:33
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.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johnhw
johnhw / umap_sparse.py
Last active January 6, 2024 16:09
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@tinkertim
tinkertim / simple-egg-pasta.md
Last active December 30, 2023 10:13
Simple yet semi-foolproof egg pasta dough

Description

This is a simple egg pasta recipe that I've been refining over the years of making fresh pasta for my family. It's based on a recipe I picked up while I was a line cook at a family Italian place about 20 years ago that has long since gone out of business; I've put it back together and adjusted it so it scales down as easily as it does up. Originally, this was made in 10kg (20+ pound) batches.

This dough isn't suitable for extruders, it is intended for rolling and cutting. That means you can make pretty much any kind of noodle, or lasagna sheet out of it. If you want to make ravioli or other stuffed pasta, you want to use a recipe with quite a bit more egg in it, and more steps for drying. If you want to make shaped pasta, such as shells, you probably want a durum wheat & water (eggless) dough recipe instead.

Yield

@amberjrivera
amberjrivera / Pipeline-guide.md
Created January 26, 2018 05:02
Quick tutorial on Sklearn's Pipeline constructor for machine learning

If You've Never Used Sklearn's Pipeline Constructor...You're Doing It Wrong

How To Use sklearn Pipelines, FeatureUnions, and GridSearchCV With Your Own Transformers

By Emily Gill and Amber Rivera

What's a Pipeline and Why Use One?

The Pipeline constructor from sklearn allows you to chain transformers and estimators together into a sequence that functions as one cohesive unit. For example, if your model involves feature selection, standardization, and then regression, those three steps, each as it's own class, could be encapsulated together via Pipeline.

Benefits: readability, reusability and easier experimentation.
@romainl
romainl / vanilla-linter.md
Last active May 6, 2024 01:48
Linting your code, the vanilla way

Linting your code, the vanilla way

You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.

Defining makeprg

autocmd FileType <filetype> setlocal makeprg=<external command>

This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.

library(sp)
library(rgdal)
library(rgeos)
library(raster)
library(ggplot2)
# Lê um shapefile com UFs do Brasil - http://www.usp.br/nereus/?dados=brasil
uf <- readOGR("../_temp/ufe.shp",encoding="UTF-8",stringsAsFactors = FALSE)
uf_centroides <- gCentroid(uf,byid = TRUE)
ufs = gSimplify(uf,tol=0.01)