Skip to content

Instantly share code, notes, and snippets.

Lucas Wiman lucaswiman

Block or report user

Report or block lucaswiman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View threaded_map.py
from typing import Callable, Iterable, T
from multiprocessing.pool import ThreadPool
def threaded_map(f: Callable[..., T], it: Iterable, num_threads: int) -> Iterable[T]:
pool = ThreadPool(num_threads)
try:
results = pool.map(f, it)
finally:
pool.close()
View X222-COB-claim-from-billing-provider-to-payer-b.edi
ISA*00* *00* *27*SSSSSS *27*PPPPP *091006*1248*`*00501*000000001*1*P*:~GS*HC*SSSSSS*PPPPP*20091006*1248*3001*X*005010X222A1~ST*837*1234*005010X222A1~BHT*0019*00*0123*20051015*1023*CH~NM1*41*2*PREMIER BILLING SERVICE*****46*12EEER 000TY~PER*IC*JERRY*TE*3055552222~NM1*40*2*GREAT PRAIRIES HEALTH*****46*567890~HL*1**20*1~NM1*85*1*KILDARE*BEN****XX*1999996666~N3*1234SEAWAY ST~N4*MIAMI*FL*33111~REF*EI*123456789~PER*IC*CONNIE*TE*3055551234~NM1*87*2~N3*2345*OCEAN BLVD~N4*MIAMI*FL*3111~HL*2*1*22*1~SBR*S********CI~NM1*IL*1*SMITH*JACK****MI*222334444~DMG*D8*19431022*M~NM1*PR*2*GREAT PRAIRIES HEALTH*****PI*567890~N3*4456 SOUTH SHORE BLVD~N4*CHICAGO*IL*44444~REF*G2*567890~HL*3*2*23*0~PAT*19~NM1*QC*1*SMITH*TED~N3*236 N MAIN ST~N4*MIAMI*FL*33413~DMG*D8*19730501*M~CLM*26407789*79.04***11:B:1*Y*A*Y*I~HI*BK:4779*BF:2724*BF:2780*BF:53081~NM1*82*1*KILDARE*BEN****XX*1999996666~PRV*PE*PXC*204C00000X~REF*G2*88877~NM1*77*2*KILDARE ASSOCIATES*****XX*1581234567~N3*2345 OCEAN BLVD~N4*MIAMI*FL*33111~SB
@lucaswiman
lucaswiman / field-serialize.py
Created Jul 18, 2018
Serialize/deserialize from a django model field.
View field-serialize.py
class _Stub(object):
pass
def serialize(model_class, field_name, value):
field = model_class._meta.get_field(field_name)
obj = _Stub()
setattr(obj, field.attname, value)
return field.value_to_string(obj)
View imports-graph.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View jsonpatch-trigger.sql
DROP TABLE IF EXISTS mytable;
DROP TABLE IF EXISTS mytable_patches;
CREATE TABLE mytable(
id SERIAL PRIMARY KEY,
data JSON
);
CREATE TABLE mytable_patches(
id SERIAL PRIMARY KEY,
@lucaswiman
lucaswiman / runtime_union.py
Last active Jun 25, 2017
It is hard to use Union in runtime type checks
View runtime_union.py
>>> type(Union[int, str])
typing.Union
>>> type(Union[int, str]) == Union
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/lucaswiman/.pyenv/versions/3.6/lib/python3.6/typing.py", line 760, in __eq__
return self._subs_tree() == other
File "/Users/lucaswiman/.pyenv/versions/3.6/lib/python3.6/typing.py", line 760, in __eq__
return self._subs_tree() == other
File "/Users/lucaswiman/.pyenv/versions/3.6/lib/python3.6/typing.py", line 760, in __eq__
@lucaswiman
lucaswiman / .sh
Created Jun 10, 2017
grep co-occurrences
View .sh
function git-co-occurrences() {
pattern1="$1"
pattern2="$2"
comm -12 <(git grep -E "$pattern1" | cut -d ':' -f1 | sort | uniq) <(git grep -E "$pattern2" | cut -d ':' -f1 | sort | uniq)
}
@lucaswiman
lucaswiman / Ties+regular+expression.ipynb
Created Mar 11, 2017
Playing with a regular language for tying ties.
View Ties+regular+expression.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -y install apt-utils
RUN apt-get -y install git
RUN git clone https://github.com/pygraphviz/pygraphviz.git /root/pygraphviz
RUN apt-get -y install build-essential
RUN apt-get -y install python
RUN apt-get -y install python-dev
RUN apt-get -y install python-setuptools
RUN apt-get -y install autoconf
View bubble-generator.tcl
canvas .c -bg white
# Graphs:
#
set all_graphs {
sql-stmt-list {
toploop {optx sql-stmt} ;
}
sql-stmt {
line
You can’t perform that action at this time.