Skip to content

Instantly share code, notes, and snippets.

Ryan McDevitt mc706

Block or report user

Report or block mc706

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View parallelism.py
from queue import Queue
from threading import Thread
from typing import Iterable, Callable, Optional
def parallel_process(work: Iterable, task_func: Callable, num_threads: int, callback: Optional[Callable] = None) -> None:
"""
Processes work in parallel using a queue-worker pattern.
Breaks up work into `num_threads` workers, which will call `task_func` for each item in work.
@mc706
mc706 / overlaps.js
Created Mar 29, 2017
phillydev#daily_programmer-2017-03-29.js
View overlaps.js
function overlaps(...pairs) {
return pairs.sort().reduce((clusters, pair) => {
let i = clusters.findIndex(c => Math.max(c[0],pair[0]) <= Math.min(c[1],pair[1]));
if (i !== -1) {
clusters[i] = [Math.min(clusters[i][0], pair[0]), Math.max(clusters[i][1], pair[1])]
} else {
clusters.push(pair)
}
return clusters
},[]);
@mc706
mc706 / overlaps.py
Last active Mar 29, 2017
phillydev#daily_programmer-2017-03-29.py
View overlaps.py
def overlaps(pairs):
clusters = []
for pair in sorted(pairs):
low, high = pair
found = False
for i, cluster in enumerate(clusters):
cluster_low, cluster_high = cluster
if max(low, cluster_low) <= min(high, cluster_high):
found = True
clusters[i] = [min(low, cluster_low), max(high, cluster_high)]
View keybase.md

Keybase proof

I hereby claim:

  • I am mc706 on github.
  • I am mc706 (https://keybase.io/mc706) on keybase.
  • I have a public key whose fingerprint is 8AFC 84AA E445 6147 69DF 6671 662C CDAB 706D 996F

To claim this, I am signing this object:

@mc706
mc706 / gittime.sh
Last active Oct 19, 2015
a quick one off bash script to total hours in commit messages matching Time: [1.5] pattern per user
View gittime.sh
#!/usr/bin/env bash
OIFS=$IFS;
IFS=$'\n';
TAGS=$(git log --tags --simplify-by-decoration --pretty="format:%ci %d" | grep -o "\(tag:\s[v0-9\.]*\)" | sed "s/tag: //g")
CONTRIBUTORS=$(git shortlog -e -s | grep -o "<.*>"| sed 's/[<>]//g');
OUTPUT=()
HEADER=("CONTRIBUTORS")
for name in $CONTRIBUTORS
do
@mc706
mc706 / blockslide.html
Created May 15, 2013
A whirlpool of colors generated in javascript and jquery.
View blockslide.html
<html>
<style>
.row {
float: left;
clear: left;
}
.box{
float:left;
height:20px;
You can’t perform that action at this time.