Skip to content

Instantly share code, notes, and snippets.

View paul-english's full-sized avatar

Paul English paul-english

View GitHub Profile
@paul-english
paul-english / redis_disjoint_set.py
Created December 27, 2019 19:17
Redis Disjoint Set
import random
class RedisDisjointSet(object):
"""
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
UTF-8 based persistent disjoint set structure that just assumes there's a local redis
"""
def __init__(self, seed=None):
@paul-english
paul-english / gist:f1f9527fdeed923ce11c70e4713d3c62
Created September 4, 2019 22:09
unlocked screen one liner
echo "echo 'sleep 1' >> ~/.profile" >> ~/.profile
create table penglish_scratch.naics_desc_lookup (
code varchar(6) sortkey distkey,
description varchar(255)
);
insert into penglish_scratch.naics_desc_lookup values
('11', 'Agriculture, Forestry, Fishing and Hunting'),
('111', 'Crop Production'),
('1111', 'Oilseed and Grain Farming'),
@paul-english
paul-english / parse_elixir_dump_column.py
Created April 19, 2019 20:48
We have some database columns that are a dumping ground for Elixir maps, elixir keyword lists, elixir structs, html, xml, & JSON. This parses them all.
from lark import Lark
l = Lark('''
?start: elixir_item | json_value | xml | node
///////////////////////
// JSON
?json_value: json_object
| json_array
import requests
from slackclient import SlackClient
DAYS = 1
FTL_URL = "https://backend.thefoodtruckleague.com/events/?days=%s&name=" % DAYS
SLACK_TOKEN = ""
def post_food_trucks_for_the_day():
sc = SlackClient(SLACK_TOKEN)
@paul-english
paul-english / code.js
Created February 23, 2018 17:16
JS bayes ab calc
var g = 7;
var p = [
0.99999999999980993,
676.5203681218851,
-1259.1392167224028,
771.32342877765313,
-176.61502916214059,
12.507343278686905,
-0.13857109526572012,
9.9843695780195716e-6,
@paul-english
paul-english / rs_levenshtein.sql
Last active December 2, 2024 15:57
Redshift Levenshtein UDF
CREATE FUNCTION levenshtein(s1 varchar, s2 varchar) RETURNS integer IMMUTABLE AS $$
import numpy as np
# https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#Python
def levenshtein(source, target):
source = source or ""
target = target or ""
if len(source) < len(target):
return levenshtein(target, source)
import random
import numpy as np
from sacred import Experiment
ex = Experiment()
@ex.config
def config():
n_sims = 1000
set nocompatible
filetype on "make sure it's on first, otherwise bad exit code
filetype off "Required for Vundle
" Using vundle
" Install with git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
set rtp+=~/.vim/bundle/vundle
call vundle#begin()
@paul-english
paul-english / lunch.py
Created October 31, 2017 22:12
Lunch randomizer
#!/usr/bin/env python
# !/usr/bin/env python
from __future__ import division, print_function
import random
import sys
from datetime import datetime
import numpy as np
import slackweb