Skip to content

Instantly share code, notes, and snippets.

View compwron's full-sized avatar
💭
Hello world

compwron compwron

💭
Hello world
View GitHub Profile
@compwron
compwron / _populate_missing_weeks.py
Created February 27, 2020 08:41
code that thankfully we don't need to _populate_missing_weeks
def _populate_missing_weeks(session: Session,
result_dict: List[Dict[str, str]], start_date: str, end_date: str) -> List[Dict[str, str]]:
# result_dict_week_start_dates = list(map(lambda data: data['start'], result_dict))
result_dict_week_start_dates = set(data['start'] for data in result_dict)
for week_start, week_end in _week_starts_between(session, start_date, end_date):
if week_start not in result_dict_week_start_dates:
result_dict.append({
'messages_received_per_patient': Decimal(0),
'start': week_start,
'end': week_end
@compwron
compwron / auto_transcript.txt
Last active February 27, 2020 03:09
Youtube's automated transcript of an interview with Dr. Kathy Leonard from Publix
https://www.youtube.com/watch?v=58FpZrp48Oo
[Music] welcome back to our in my podcast my name is Nima I'm an and today we're joined by dr. Cathy Leonard the pharmacy operations manager at Publix thank you for joining us thank you for having me so we see here that you actually greeted us very well so we want to thank you first for giving us these gifts really appreciate it so um presentation seems like it's very key at Publix is that something that you guys are about is that is that something that you guys instill absolutely I think it's part of just human nature you know you look for the best qualities and in people and how they present you both all of you have presented yourselves very well this morning but you look for that it makes that first impression on people and it's no different in our stores from how our pharmacists interact with patients how they interact with prescribers and how they interact with each other all goes a long way with our customers and the brand and what we're trying to build at Pub
@compwron
compwron / extending_sqlite.py
Last active March 28, 2020 21:27
demo of how I make sqlite pretend to be mysql better so we can test code which runs raw sql
# conftest.py
import datetime
from time import strptime
from dateutil import parser
from sqlalchemy import create_engine
def is_test():
"""
@compwron
compwron / wait_for_demo.py
Last active January 3, 2020 00:45
demo of waiting for a condition
import time
from random import randint
def demo():
foo = randint(0, 100)
print(f"int is {foo}")
return foo % 5 == 0
def _wait_for(condition_func, interval=0.5, max_time=15):
@compwron
compwron / picky_eater_list.txt
Created December 26, 2019 21:51
picky eater list
1.Miracle Whip
2.Pickles
3.Cilantro
4.Black Jelly Beans
5.Pineapple Pizza
6.Sardines
6.Oysters
8.Sushi
9. Candy Corn
10. Vienna Sausages
@compwron
compwron / ExportKindle.js
Created December 21, 2019 22:18 — forked from jkubecki/ExportKindle.js
Amazon Kindle Export
// The following data should be run in the console while viewing the page https://read.amazon.com/
// It will export a CSV file called "download" which can (and should) be renamed with a .csv extension
var db = openDatabase('K4W', '3', 'thedatabase', 1024 * 1024);
getAmazonCsv = function() {
// Set header for CSV export line - change this if you change the fields used
var csvData = "ASIN,Title,Authors,PurchaseDate\n";
db.transaction(function(tx) {
@compwron
compwron / react-router-v4-upgrade-notes.txt
Created December 5, 2019 06:04
Notes on how to upgrade to react-router v4
note- we use auth0, some of this is specific to that
steps:
launch and look at the UI to make sure everthing is working
npm update all gently (i.e "npm update" without hand-editing package.json)
dependencies: (these will need the ^ later but for now leave it as is until it's proven to work)
- "react-router": "4.4.0-beta.8",
- react-router-redux -> "react-router-dom": "4.4.0-beta.8",
- "redux-auth-wrapper": "^2.1.0",
(note: add the ^ after changes are done so upgrades will kick in- there are more versions already!!)
@compwron
compwron / hack.js
Created November 22, 2019 22:56
hack for auth redirect w/ react-router 4 and redux-aut-wrapper
function handleAuthenticated (dispatch) {
lock.on('authenticated', ({ accessToken, idToken, state }) => {
lock.getUserInfo(accessToken, (error, user) => {
if (error) {
return dispatch(lockError(error))
}
setUser(user)
setToken(idToken)
@compwron
compwron / flag_combine.js
Created November 15, 2019 06:54
just a simple reduce with some domain, pre-refactoring
import {List, Map} from 'immutable'
test('test name goes here', () => {
const currentFlags = List([
Map({id: 7, tag: 'flag/bbb:JAR'}),
Map({id: 6, tag: 'flag/bbb'}),
Map({id: 9, tag: 'flag/ccc:ADV'}),
Map({id: 8, tag: 'flag/bbb:ELI'}),
Map({id: 10, tag: 'flag/ccc:JAR'})
])
@compwron
compwron / sqlalchemy_most_frequent_queries.py
Created November 9, 2019 04:13
Demo of how to test for n+1 queries produced by sqlalchemy
# for use with sqlalchemy
def test_foo():
stmts = []
def catch_queries(conn, cursor, statement, a, b, c):
stmts.append(statement)
event.listen(engine, "before_cursor_execute", catch_queries)
do_thing()
assert _most_frequent_queries(queries=stmts, query_count=4, query_type='SELECT', query_print_length=50) == [('SELECT X FROM Y', 5)]