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 / 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
@paul-english
paul-english / EditDistance.scala
Created July 27, 2017 18:08
EditDistance.scala, not the best for prod, spark sql has levenshtein built in, but useful as a template for spark ml transformers
import org.apache.spark.ml.Transformer
import org.apache.spark.ml.param.{ ParamMap, Param }
import org.apache.spark.ml.util.{ Identifiable, DefaultParamsWritable, DefaultParamsReadable }
import org.apache.spark.sql.functions.{ udf, col }
import org.apache.spark.sql.types.{ StructType, StructField, DoubleType }
import org.apache.spark.sql.{ Dataset, DataFrame }
object EditDistance extends DefaultParamsReadable[EditDistance] {
override def load(path: String): EditDistance = super.load(path)
#!/usr/local/bin/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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.