Skip to content

Instantly share code, notes, and snippets.

Wade Schulz, MD, PhD wadeschulz

Block or report user

Report or block wadeschulz

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
@wadeschulz
wadeschulz / mimic-deid-preprocessing.py
Last active Dec 18, 2018
Python Regex to Preprocess Deidentified Sections of MIMIC-III Notes
View mimic-deid-preprocessing.py
regex1 = re.compile("\[\*\*(\d*\-\d*\-\d*)\*\*\]") # regex to remove special characters from shifted yyyy-MM-dd format
regex2 = re.compile("\[\*\*(\d*\-\d*)\*\*\]") # regex to remove special characters from shifted MM-dd format
regex3 = re.compile("\[\*\*(\d*)\*\*\]") # regex to remove special characters from shifted MM or dd format
regex4 = re.compile("\[\*\*[^\*]+\*\*\]") # regex to remove remaining de'id fields
@wadeschulz
wadeschulz / scores-to-roc.py
Created Dec 10, 2017
Create ROC curve from ML scores in numpy array
View scores-to-roc.py
from sklearn import metrics
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def create_roc_curve(labels, scores, positive_label)
fpr, tpr, thresholds = metrics.roc_curve(labels, scores, pos_label=positive_label)
roc_auc = auc(fpr, tpr)
plt.title('Receiver Operating Characteristic')
@wadeschulz
wadeschulz / ipython_notebook_in_git.md
Created Dec 3, 2017 — forked from pbugnion/ ipython_notebook_in_git.md
Keeping IPython notebooks under Git version control
View ipython_notebook_in_git.md

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

@wadeschulz
wadeschulz / merge-keytab.sh
Created Apr 23, 2016
kerberos-merge-keytab.sh
View merge-keytab.sh
// Merge multiple keytabs into single keytab
$ ktutil
$ ktutil: rkt KEYTAB1.keytab
$ ktutil: rkt KEYTAB2.keytab
$ ktutil: wkt MERGEDKEYTAB.keytab
@wadeschulz
wadeschulz / ranger_password_reset.py
Created Apr 2, 2016
Ranger password reset script
View ranger_password_reset.py
import md5
user = ''
pass = ''
print md5.new(pass + "{" + user + "}").hexdigest()
View elasticsearch.yml
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,
@wadeschulz
wadeschulz / hash_generator.py
Created Jan 6, 2016
Python script to generate md5 and sha1 hashes for files of given extension in a directory
View hash_generator.py
import hashlib, os
def hashfile(afile, hasher, blocksize=65536):
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.hexdigest()
path = raw_input("Enter directory to scan: ")
@wadeschulz
wadeschulz / kafkaTopic.sh
Created Nov 24, 2015
Create Kafka Topic
View kafkaTopic.sh
./kafka-topics.sh --create --zookeeper {HOSTNAME}:2181 --replication-factor 1 --partitions 1 --topic {topicname}
@wadeschulz
wadeschulz / CreateIndex.cs
Created Aug 16, 2015
Create Elastic Index with Mapping
View CreateIndex.cs
var client = new ElasticClient();
var replicas = 0;
var shards = 3;
client.CreateIndex(index, c => c.NumberOfReplicas(replicas).NumberOfShards(shards)
.AddMapping<T>(m => m.MapFromAttributes()));
@wadeschulz
wadeschulz / csharp-random-string
Created Jul 8, 2015
C# Random String Generator
View csharp-random-string
public class TokenGenerator
{
public static string Generate(int size)
{
// Characters except I, l, O, 1, o, and 0 to decrease confusion when hand typing tokens
var charSet = "abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!@#$%&()";
var chars = charSet.ToCharArray();
var data = new byte[1];
var crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
You can’t perform that action at this time.