Skip to content

Instantly share code, notes, and snippets.

View compwron's full-sized avatar
💭
https://github.com/drop-ice/dear-github-2.0

compwron compwron

💭
https://github.com/drop-ice/dear-github-2.0
View GitHub Profile
@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)]
@compwron
compwron / healthtech.txt
Created October 17, 2019 02:31
some healthtech places to work
Apple Health
AgileMD
Alpha Health
Alto Pharmacy
Amino Healthcare
Augmedix
Benchling
Carbon Health
Clover Health
Cricket Health
@compwron
compwron / judge.rb
Created June 25, 2019 06:57
judge.rb aiming for a tie, doesn't work yet
def pick_tie_jurors(potential_jurors, k)
potential_jurors.combination(k).map do |combo| # 2 3
p_tie = combo.combination(combo.count / 2).map { |possibles| # [2] # [3]
# inverses = [2, 3] - [2] # bug with distinct # [3]
inverses = (combo - possibles).map { |i| 1 - i } # bug with distinct # [3]
acc = 0
possibles.map { |pos|
inverses.map { |inv|
pos * inv