Skip to content

Instantly share code, notes, and snippets.

View twillis's full-sized avatar

Tom Willis twillis

  • Cincinnati Ohio
View GitHub Profile

In reference to https://www.reddit.com/r/learnpython/comments/8senm4/convert_json_response_into_objects/

I have to do a lot of this stuff for work consuming ADT messages from EMR's, there's really no way of getting around having to document the shape of the json you are expecting, but there are strategies for making it more pleasant/bullet proof.

There's marshmallow(https://marshmallow.readthedocs.io/en/latest/) which allows you to declare classes to serialize your json or portions of the json into concrete objects, with the added bonus of reliable type conversion and validation(which is needed more often than not).

@twillis
twillis / gist:3afe06c4fd162a7495a61f17f753e30d
Created August 20, 2016 19:41
An Approximate Midi only drumkit or hydrogen to what the Alesis SR18 expects from MIDI as far as I can tell
<?xml version="1.0" encoding="UTF-8"?>
<drumkit_info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.hydrogen-music.org/drumkit">
<name>Drum Machine</name>
<author>Tom Willis</author>
<info>simple map for alesis SR18</info>
<license>undefined license</license>
<instrumentList>
<instrument>
<id>0</id>
<name>Kick</name>
@twillis
twillis / om-next-tutorial.core.cljs
Created November 28, 2015 14:16
studying the om.next framework just trying to keep it all in my head.
(ns om-next-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[cljs.pprint :as pp]))
(enable-console-print!)
;; used for initial state in reconciler
@twillis
twillis / om-next-tutorial.core.cljs
Created November 28, 2015 14:15
studying the om.next framework just trying to keep it all in my head.
(ns om-next-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[cljs.pprint :as pp]))
(enable-console-print!)
;; used for initial state in reconciler
@twillis
twillis / gist:d385ed819a16db58bf63
Created December 6, 2014 22:01
ocr clock story 1
(ns bank-ocr
(:require [clojure.test :refer :all]
[clojure.string :as string]))
(def test-acct
"
_ _ _ _ _ _ _
|_||_|| || ||_ | | ||_
| _||_||_||_| | | | _|
@twillis
twillis / gist:7edba071c1bced013e17
Created July 12, 2014 19:53
Example usage of pyramid_angularstarter
class Foo(object):
def __init__(self,x, y) :
print "ithis is the connstructor, we typically put attributes on self here"
self.x = x
self.y = y
def say_hello(self):
print "hi i'm an instance method, my x is %s and my y is %s" % (self.x, self.y
)
@twillis
twillis / gist:065053bd0340fb28f10a
Created May 8, 2014 22:30
I can crash supercollider yay. play-note is probably wrong and either should free the synth after the note or talk to it differently
;;
(use 'overtone.core)
;; (boot-external-server)
(connect-external-server)
;; define: music
;; vocal or instrumental sounds (or both) combined in
;; such a way as to produce beauty of form, harmony, and expression of
;; emotion.

Music Composition with clojure

Overtone is a really cool environment for making music with clojure. Most examples I have seen focus more on the aspects of live performance where as I wondered how one could use it as an environment for composing music. Being new to clojure, and a part time musician I decided to see how far I could get using clojure/overtone to write songs.

@twillis
twillis / gist:11386711
Created April 28, 2014 23:13
experiments with music composition in clojure + overtone
(use 'overtone.core)
(boot-external-server)
;; define: music
;; vocal or instrumental sounds (or both) combined in
;; such a way as to produce beauty of form, harmony, and expression of
;; emotion.
;; or a series of sounds(notes) played in sequence