Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script>
L_NO_TOUCH = false;
L_DISABLE_3D = false;
</script>
<style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>
@paul-english
paul-english / unisplat.py
Created August 16, 2021 19:25
Convert uniprot_trembl to massive csv
from tqdm import tqdm
import csv
order = [
"",
"ID",
"AC",
"DT",
"DE",
"GN",
@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