Skip to content

Instantly share code, notes, and snippets.

View davidselassie's full-sized avatar

David Selassie davidselassie

View GitHub Profile
@davidselassie
davidselassie / exception_label.rs
Created August 25, 2023 00:10
Hack Day Mixed Rust-Python Tracebacks
use std::panic::Location;
use pyo3::exceptions::PyValueError;
use pyo3::ffi;
use pyo3::prelude::*;
use pyo3::types::PyDict;
use pyo3::types::PyFrame;
use pyo3::types::PyTraceback;
use pyo3::AsPyPointer;
@davidselassie
davidselassie / demo_tsdb_input.py
Created March 7, 2023 01:01
Sample partitioned input from a time series DB
class BTRDBUUIDInput(PartInput):
def __init__(start_ts_ns, end_ts_ns, batch_size_ns):
self.start_ts_ns = start_ts_ns
self.end_ts_ns = end_ts_ns
self.batch_size_ns = batch_size_ns
def list_parts(self):
# Each UUID is its own partition. The resume state is the time
# offset in the stream for that UUID.
conn = btrdb.connect(BTRDB_ENDPOINT)
@davidselassie
davidselassie / wikistream_top.py
Created March 4, 2022 22:26
Wikistream example that returns a running top 10
import collections
import json
import operator
from datetime import timedelta
import sseclient
import urllib3
from bytewax import Dataflow, inputs, parse, spawn_cluster
@davidselassie
davidselassie / 42140.md
Created February 13, 2018 00:35
Plaid describes when we know we've caught back up on txns after auth update

Transactions and Webhooks after Auth Update #42140 Jan 30, 2018 RESOLVED

David Selassie Jan 25, 2018

When a Plaid Item needs an auth update, it seems like Plaid can't access new txn or balance data for that Item.

  1. When the Link UI finishes an auth update, will we soon receive webhooks for txns that were made during the window when the auth was invalid and Plaid didn't have access?

E.g. Customer changes their bank password on Jan 1st. They make a purchase from that bank account on Jan 2nd; we won't get a webhook for that then because Plaid can't get new data. On Jan 3rd, they go through the Link auth update. Will we get a webhook for the txn on Jan 2nd, but delivered on the 3rd?

  1. Is there any delay between when the auth update is completed in the Link UI and when our backend can query for transactions during the time window when the auth was invalid?
@davidselassie
davidselassie / access-to-item.sh
Created January 25, 2018 21:56
Script to find matching Plaid Item IDs from a list of Plaid Access Tokens
#!/bin/bash
if [[ "$1" == '-h' || "$1" == '--help' ]]
then
echo "USAGE: $(basename $0) < ACCESS_TOKENS.csv > ITEM_ACCESS_TOKENS.csv" 1>&2
echo "Takes a CSV of Access Tokens from Plaid in the column 'access_token' and finds the" 1>&2
echo "corresponding Item ID and outputs that in the column 'item_id', along with the" 1>&2
echo "original Access Token in 'access_token'." 1>&2
exit 1
fi
@davidselassie
davidselassie / round.py
Last active September 23, 2016 22:06
Encapsulating encoded score
LETTER_OFFSET = ord('a')
ROUND_LENGTH = 25
def _letter_to_index(a):
"""Return the index of a letter.
>>> _letter_to_index('q')
16
>>> _letter_to_index('z')
@davidselassie
davidselassie / uncertain_rounding.js
Created October 5, 2012 07:18
Javascript rounding to specific number of significant figures or an uncertainty.
var roundAway = function(x) {
// Rounds a number to the next integer away from 0.
//
// Args:
// x - Number to round.
// Returns:
// rounded - Next integer from x away from 0.
if (x >= 0) {
return Math.ceil(x);