Skip to content

Instantly share code, notes, and snippets.

View birkin's full-sized avatar

Birkin James Diana birkin

View GitHub Profile
@birkin
birkin / pairtree.py
Created December 5, 2021 14:06
playnig with os.makedirs() & pairtree
"""
Skimming <https://realpython.com/working-with-files-in-python/>
for some forgotten reason, I came across the section "Creating Multiple Directories",
which showed how the command:
... os.makedirs( '2018/10/05' )
...will create a hierarchy of directories like:
.
@birkin
birkin / robust_no.py
Last active November 19, 2021 17:34
retry with backoff experimentation
import pprint, requests
def query_solr():
url = 'http://solr_url'
r = requests.get( url, timeout=5 )
result = r.json()
return result
@birkin
birkin / referent_relationships_api_sketch.md
Last active September 21, 2021 14:37
thoughts on referent-relationship api
@birkin
birkin / querystring_to_dict.py
Created August 30, 2021 18:51
non-django querystring handling
'''
Reminder for handling querystrings outside of django.
Notes...
- It's legal to have duplicate keys
- This is a messy, real openURL, with three foo test keys
- foo1 shows that a string with a comma is still parsed as a single string
- foo2 shows that a key without a val is ignored
- foo3 shows that a key with an `=` but without a val is also ignored
'''
@birkin
birkin / randomize.rs
Created July 20, 2021 11:01
rust randomization
Since this'll be replaced, archiving here my first rust randomization code...
```
pub async fn validate_bib( &self, bib: &str ) -> bool {
use rand::Rng;
let mut rng = rand::thread_rng();
let i: u8 = rng.gen_range( 0..2 ); // low, 0; high, 1
println!( "i, ``{:?}``", i );
if i == 0 {
false
@birkin
birkin / bigfile.py
Last active May 8, 2020 18:49
speed play searching through a 5.7GB file via grep, python, rust, and ripgrep
import datetime
start_time = datetime.datetime.now()
with open('./5p7_gb.txt', 'rb' ) as fhandler:
count = 0
for (i, line) in enumerate( fhandler ):
i += 1
if b'Message-ID:' in line:
count += 1
print( f'count, ``{count}``' )

scraping notes

(actual data is down at #7)

  1. grabbed the data

    (requests isn't part of native python, i installed it via pip install requests)

     >>>
    

>>> import requests

@birkin
birkin / django_react_experimentation.md
Created March 26, 2020 12:17
Notes from working through youtube tutorial. Tags: react django babel webpack.
@birkin
birkin / 2019-stuff.md
Last active March 8, 2021 22:42
work-refection

stuff i did

(march-2019 through february-2020)

code...

  • annex-counts
  • created added web-app for B.H. to get counts of different types for any date and any of the four categories
@birkin
birkin / barcode_extractor.py
Last active January 28, 2020 20:10
extract barcodes from end-of-day report files
"""
Usage:
- cd to the `annex_accessions` directory
- run $ python3 ./barcode_extractor.py
"""
import logging, os, pprint
logging.basicConfig(