Skip to content

Instantly share code, notes, and snippets.

@stillmatic
stillmatic / parser.go
Last active June 13, 2023 17:32
golang generic struct validator
package gallant
import (
"context"
"encoding/json"
"reflect"
"github.com/go-playground/validator/v10"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
@stillmatic
stillmatic / tether.md
Last active May 19, 2022 18:34
stables

The USDC contract is at 0xdac17f958d2ee523a2206206994597c13d831ec7 -- code is pulled from https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code

The mint/burn logic is controlled by issue and redeem

    // Issue a new amount of tokens
    // these tokens are deposited into the owner address
    //
    // @param _amount Number of tokens to be issued
    function issue(uint amount) public onlyOwner {
library(gtrendsR)
library(CausalImpact)
library(tidyverse)
plot_for_name <- function(food, time="today+5-y") {
df <- gtrendsR::gtrends(food, geo="US", time=time)
idx <- length(df$interest_over_time$date) - 6
ggplot2::ggplot(df$interest_over_time, aes(x=date, y=hits)) +
ggtitle(paste0("Search volume for '", food, "'"), subtitle = "Source: Google Trends, US Data") + geom_line() +
geom_vline(xintercept = df$interest_over_time$date[idx], color='red') +
@stillmatic
stillmatic / groupby_listagg.py
Last active February 6, 2020 05:32
fast numpy groupby + listagg
import pandas as pd
import numpy as np
def fast_groupby_listagg(df, grouping_idx, presorted):
"""
given a grouping column, (or set of columns), we find all grouping sets.
note that this code expects a 2-d array and outputs a 3-d array.
we also convert values to float32 (trading precision for performance).
We can't make this file beautiful and searchable because it's too large.
id,date_account_created,timestamp_first_active,date_first_booking,gender,age,signup_method,signup_flow,language,affiliate_channel,affiliate_provider,first_affiliate_tracked,signup_app,first_device_type,first_browser,country_destination
gxn3p5htnn,2010-06-28,20090319043255,,-unknown-,,facebook,0,en,direct,direct,untracked,Web,Mac Desktop,Chrome,NDF
820tgsjxq7,2011-05-25,20090523174809,,MALE,38.0,facebook,0,en,seo,google,untracked,Web,Mac Desktop,Chrome,NDF
4ft3gnwmtx,2010-09-28,20090609231247,2010-08-02,FEMALE,56.0,basic,3,en,direct,direct,untracked,Web,Windows Desktop,IE,US
bjjt8pjhuk,2011-12-05,20091031060129,2012-09-08,FEMALE,42.0,facebook,0,en,direct,direct,untracked,Web,Mac Desktop,Firefox,other
87mebub9p4,2010-09-14,20091208061105,2010-02-18,-unknown-,41.0,basic,0,en,direct,direct,untracked,Web,Mac Desktop,Chrome,US
osr2jwljor,2010-01-01,20100101215619,2010-01-02,-unknown-,,basic,0,en,other,other,omg,Web,Mac Desktop,Chrome,US
lsw9q7uk0j,2010-01-02,20100102012558,2010-01-05,FEMALE,46.0,basic,0,en,other,cr
:root {
--dark-primary-color): #D32F2F;
--default-primary-color: #F44336;
--light-primary-color: #FFCDD2;
--text-primary-color: #FFFFFF;
--accent-color: #607D8B;
--primary-text-color: #212121;
--secondary-text-color: #757575;
--divider-color: #BDBDBD;
--bg-light-color:#fafafa;
@stillmatic
stillmatic / writeup.md
Created September 28, 2017 22:11
pao notes

Ellen Pao talk 9/27

The first story Ellen Pao told was about the “ice cream man.” There's no cheerful jingle to this story, just a law firm partner who stood outside a female lawyer's office everyday after lunch, licking an ice cream cone while staring at her. Management's response to these instances of sexism were invariably dismissive, e.g. “you should be flattered he's interested in you,” or “it's just one weird guy, but overall it's not that bad, right?” The result is an environment that views sexism as the product of just one bad apple, but it's instead the product of a bad system: one which condones and encourages “boys club” behavior. Staffing decisions were made at all-male steak dinners and strip club visits, which reifies the structural exclusion present within VC and tech.

It's now clear that tech has a diversity problem, given the wide range of stories over the last few years: Amazon, Susan Fowler at Uber, Leslie Miley at Twitter, SoFi recently, and almost certainly more we haven't heard.

@stillmatic
stillmatic / .vimrc
Created August 16, 2017 05:19
vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
set title
set ruler
set wrap
set autoread
set wildmenu
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
``` r
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.3.2
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':