Skip to content

Instantly share code, notes, and snippets.

View neurosnap's full-sized avatar

Eric Bower neurosnap

View GitHub Profile
@neurosnap
neurosnap / gist:9360098
Created March 5, 2014 02:31
Anonymize a DICOM
def anonymize(filename, output_filename, new_person_name="anonymous",
new_patient_id="id", remove_curves=True, remove_private_tags=True):
def sanitize_html(dataset):
"""Removing all potential XSS attacks embedded within the dicom file"""
dataset.walk(sanitize_callback)
return dataset
def sanitize_callback(dataset, data_element):
"""Call from dataset "walk" recursive function for all data elements. """
@neurosnap
neurosnap / gist:3a1824c31643367bbb0e
Created June 30, 2014 13:29
gdcmswig.py -- DataElement
class DataElement(_object):
"""
Class to represent a Data Element either Implicit or Explicit.
DATA ELEMENT: A unit of information as defined by a single entry in
the data dictionary. An encoded Information Object Definition ( IOD)
Attribute that is composed of, at a minimum, three fields: a Data
Element Tag, a Value Length, and a Value Field. For some specific
Transfer Syntaxes, a Data Element also contains a VR Field where the
Value Representation of that Data Element is specified explicitly.
@neurosnap
neurosnap / gist:f7f9989941ef21346332
Created July 8, 2014 18:25
V3 SpokenLayer landing.js
$(function() {
$("#nol_start").on("click", function() {
$("#sl_queue > div").each(function() {
sl_start(this);
});
});
$(".nol_play").on("click", function() {
//sl_start(this);
@neurosnap
neurosnap / gist:c1580fe7b33f65330c23
Last active August 29, 2015 14:03
Array of dictionaries to group data
@app.route('/')
def landing():
arts = Articles.query.\
filter(Articles.active==True).\
filter(Articles.ready==True).all() #.\
#order_by(desc(Articles.created)).all()
# get today's date
today = datetime.date.today()
@neurosnap
neurosnap / author.py
Created May 4, 2015 14:51
Authors on Freep Article
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import requests
# lets download the article web page
r = requests.get('http://www.freep.com/story/life/advice/2015/05/04/mother-law-meant-selfish/26706999/')
print("Grabbing data from {}".format(r.url))
r.raise_for_status()
@neurosnap
neurosnap / wat.py
Last active September 10, 2015 13:49
members = {
"class": self._class,
"number": self.number,
"part_number": self.part_number,
"description": self.description,
"quantity": self.quantity,
}
return """Class: {class}\t
Number: {number}\t
async function getThreads(api, dispatch) {
try {
let mailboxes = await api.get(`mailboxes`);
mailboxes = mailboxes.mailboxes;
for (let i = 0; i < mailboxes.length; i++) {
let box = mailboxes[i];
let inbox = await api.get(`mailboxes/${box.id}/threads/folder/in`);
for (let i = 0; i < inbox.threads.length; i++) {
function main(sources) {
const auth$ = Auth(sources);
const apiDomain = getAPIDomain();
const apiMailboxes = `${apiDomain}/mailboxes`;
const getMailboxes$ = auth$.state$.map(accInfo => {
console.log(accInfo);
return {
url: apiMailboxes,
@neurosnap
neurosnap / actionCreator.js
Created November 19, 2016 03:39
Simple action creator
// actionCreator.js
export default (type: string) => (payload: Object) => ({ type, payload });
// Examples
export const FETCH_THREADS = 'threadFetch/FETCH';
export const fetchThreads = actionCreator(FETCH_THREADS);
export const FETCH_NEXT_PAGE = 'threadFetch/FETCH_NEXT_PAGE';
export const fetchNextPage = actionCreator(FETCH_NEXT_PAGE);
describe('getFolderCount', () => {
const getFolderCount = selectors.getFolderCount;
before(() => {
sinon.stub(selectors, 'getDisplayFolderProp');
sinon.stub(selectors, 'getFoldersHash');
sinon.stub(selectors, 'calcFolderCount');
sinon.stub(coreSelectors, 'getMailboxes');
sinon.stub(coreSelectors, 'getThreadIdsByFolder');
getFolderCount({}, {});
});