Skip to content

Instantly share code, notes, and snippets.

View dgfitch's full-sized avatar

Dan Fitch dgfitch

View GitHub Profile
@dgfitch
dgfitch / widen_nihtoolbox.py
Last active March 27, 2023 22:36
Widen and pivot NIH Toolbox uploaded data into usable format
#!/usr/bin/env python3
"""
Takes NIH Toolbox data and transforms it from long (one row per score or
response) to wide (one row per participant, or 'PIN' as labeled in the NIH
Toolbox output.
Output from this will be fed to scorify, and the output from that will be fed
to ndaify.py
@dgfitch
dgfitch / vlc_pyglet.py
Created April 26, 2019 17:44
Using libvlc from python to display video via OpenGL (cheating slightly with pyglet)
from __future__ import absolute_import, division, print_function
import time
import os
import sys
import threading
import logging
import ctypes
@dgfitch
dgfitch / opavote_ranked_ballot_counter.py
Last active March 17, 2022 17:26
Simple shredder for Opavote BLT format ranked choice ballots
#!/usr/bin/env python3
import sys
with open(sys.argv[1], 'r') as ballot_file:
lines = [line.rstrip() for line in ballot_file]
# Trim first header and final line
lines.pop(0)
lines.pop()
@dgfitch
dgfitch / r.def
Created February 8, 2022 19:40
Singularity definition file for R
BootStrap: docker
From: ubuntu:18.04
%labels
Maintainer Dan Fitch
R_Version 3.6.3
%apprun R
exec R "${@}"
@dgfitch
dgfitch / dashstack.py
Last active September 29, 2021 11:18
Stack the UW COVID dashboard graphs, dividing positive tests into tests to get a positive percentage chart.
import re
import requests
from requests_html import HTMLSession
import pandas as pd
import matplotlib.pyplot as plt
session = HTMLSession()
r = session.get('https://covidresponse.wisc.edu/dashboard/')
@dgfitch
dgfitch / git-checkpoint.sh
Created April 28, 2015 17:58
git-checkpoint: Script to allow non-git-experts to use git with a single command, "git checkpoint"
#!/bin/sh
# git-checkpoint
# ==============
# Minimal version tracking with git using a single command.
#
# Intended to ease people new to git into easy versioning
# in a single server repository location, but they can also
# expand on their knowledge and use other git commands as
# they learn.
@dgfitch
dgfitch / nih_toolbox.php
Created August 29, 2019 15:06
Simple web service endpoint for NIH Toolbox in PHP
<?php
$target_dir = "uploads/";
error_reporting(-1);
ini_set('display_errors', 'On');
date_default_timezone_set('America/Chicago');
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header('Content-Length: 0');
header('Connection: keep-alive');
@dgfitch
dgfitch / README.md
Last active April 3, 2019 17:26
Draw your feels

Preliminary experimenting with d3, "draw your feelings"

@dgfitch
dgfitch / gulp.txt
Created March 28, 2017 00:53
Gulp error trying to watch gibber.graphics.lib
dan@batman:~/git/gibber.graphics.lib$ gulp
[19:52:44] Warning: gulp version mismatch:
[19:52:44] Global gulp is 3.9.1
[19:52:44] Local gulp is 3.8.11
[19:52:44] Using gulpfile ~/git/gibber.graphics.lib/gulpfile.js
[19:52:44] Starting 'client'...
[19:52:44] 'client' errored after 22 ms
[19:52:44] TypeError: gulp.src(...).pipe(...).pipe is not a function
at Gulp.<anonymous> (/home/dan/git/gibber.graphics.lib/gulpfile.js:23:6)
at module.exports (/home/dan/git/gibber.graphics.lib/node_modules/orchestrator/lib/runTask.js:34:7)
@dgfitch
dgfitch / simple_wcf.fs
Created November 3, 2010 20:31
A sample WCF host and client in F#, extremely simple but a starting point
open System
open System.ServiceModel
open System.ServiceModel.Description
[<ServiceContract(ConfigurationName = "PublishService", Namespace = "http://xyz.gov/PublishService")>]
[<ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)>]
type IPublishService =
[<OperationContract(Name="TestMethod")>]
abstract member TestMethod : name:string -> string