Skip to content

Instantly share code, notes, and snippets.

View danodonovan's full-sized avatar
🧬

Dan O'Donovan danodonovan

🧬
View GitHub Profile
@danodonovan
danodonovan / shared_memory_test.py
Last active October 29, 2019 22:05
Testing out performance of the multiprocessing.shared_memory in python 3.8
from functools import partial
import multiprocessing
from multiprocessing.managers import SharedMemoryManager
import random
import time
NUM_PROCS = 4
@danodonovan
danodonovan / restore.py
Created July 18, 2018 10:20
Script to restore items deleted from a versioned S3 bueckt
import logging
import boto3
from healx.batching import batched
from healx.iterables import flatten
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__file__)
client = boto3.client('s3')
@danodonovan
danodonovan / cypher.cql
Last active January 15, 2018 16:10
Handy Neo4j Queries
// count all node labels
MATCH (n)
RETURN labels(n), count(DISTINCT n);
// describe metagraph
CALL db.schema();
// list node stats
// Sample some nodes, reporting on property and relationship counts per node.
MATCH (n) WHERE rand() <= 0.1
@danodonovan
danodonovan / test_exit.py
Last active March 6, 2017 12:07
PyHamcrest not catching SystemExit exception
import sys
import unittest
from hamcrest import assert_that, calling, raises
import pytest
def call_exit():
sys.exit()
@danodonovan
danodonovan / parallel_class_call.py
Created July 25, 2016 22:34
Call a non-static function on a class in parallel.
from multiprocessing import Pool
from multiprocessing.pool import ApplyResult
def call_it(instance, name, args=(), kwargs=None):
if kwargs is None:
kwargs = {}
return getattr(instance, name)(*args, **kwargs)
### Keybase proof
I hereby claim:
* I am danodonovan on github.
* I am danodonovan (https://keybase.io/danodonovan) on keybase.
* I have a public key whose fingerprint is 910D 91FB 2702 4C4C 4330 0268 B631 1E01 140A B905
To claim this, I am signing this object:
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state