Skip to content

Instantly share code, notes, and snippets.

View kentquirk's full-sized avatar

Kent Quirk kentquirk

View GitHub Profile
@kentquirk
kentquirk / tidepool_dummy_api.md
Last active December 24, 2015 06:19
Task list and discussion for Tidepool's dummy API

dummy-api

All our techniques are being tested and documented in the repository called dummy-api.

  • Set up gruntfile structure
  • JSHint / code formatting documentation
  • JSHint gruntfile
  • Set up documentation with docco
  • docco gruntfile
  • License template system built
@kentquirk
kentquirk / MakeVsGrunt.md
Last active December 24, 2015 23:29
Build tools discussion for Tidepool

Build tools -- Make vs Grunt (vs Ant or other options)

We need to make a decision about build tools.

  • Make: venerable, but crusty. Dependency model doesn't work for a lot of things (you just have a list of commands). Not effectively cross platform -- Windows users in particular don't work well with make. Bit of a pain to set up but doesn't create additional dependencies. Everyone knows how to do easy stuff, but hard stuff can get really hard and ugly.
  • Grunt: the tool of choice for node projects. We're a node project. Cross platform. Pulls in lots of dependencies if you install it locally. Easy to set up the grunt files badly.
  • Pure JS scripts -- requires a little more scaffolding to set up; Grunt has that built in. Why bother? (See article below for one person's take on why he bothered.)
  • Jake: it's basically trying to do a make-like design but using javascript. Some good ideas, but like make, complex stuff requires a PhD to pull off.
  • Ant or Maven or
@kentquirk
kentquirk / dumpVars.py
Created March 7, 2014 18:18
Get a list of non-callable items from an object and return their names and values
import os.path
def dumpVars(r):
apivars = [(k, type(getattr(r, k))) for k in dir(r) if not k.startswith('_') and not callable(getattr(r, k))]
values = [(k[0], getattr(r, k[0])) for k in apivars]
return values
print dumpVars(os.path)
@kentquirk
kentquirk / unitstest.py
Created May 27, 2014 13:40
Shows how storing data in ints is a problem but in floats works just fine
# This is a small program that tests conversion to and from different formats
# and makes sure that numbers that undergo conversion don't lose precision.
import math
# truncates a number to the given number of digits after the decimal
def truncate(x, digits):
p = math.pow(10, digits)
return int(x * p)/p
@kentquirk
kentquirk / Go14MongoVagrant-20150514-0330.sh
Last active August 29, 2015 14:21
Provisioning script for a mongo-backed go server on a vagrant box
#! /bin/bash
# Provisioning script for a mongo-backed go server on a vagrant box
echo "install basic requirements"
apt-get --quiet -y update
DEBIAN_FRONTEND=noninteractive apt-get --quiet -y upgrade
apt-get --quiet -y install build-essential mercurial git curl libssl-dev pkg-config tree mongodb bison make gcc binutils
@kentquirk
kentquirk / .bash_profile
Last active August 29, 2015 14:21
a starter version of .bash_profile for new machines
# this is extra bash stuff to make things easier to manage
shopt -s histappend
HISTFILESIZE=2000
HISTSIZE=1000
export TERM=xterm-256color
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
@kentquirk
kentquirk / addToYour.bash_profile
Last active August 29, 2015 14:21
Bash prompt for displaying git/svn revision info
#################################################################
# Here's a bunch of stuff to do prompts that are sensitive to git and svn
WHT='\e[22;37m'
TEAL='\e[22;36m'
BLK='\e[22;30m'
RED='\e[22;31m'
GRN='\e[22;32m'
YEL='\e[22;33m'
BLU='\e[22;34m'
type Data struct {
Data []struct {
Data struct {
Stimulus string `json:"stimulus,omitempty"`
Template string `json:"template,omitempty"`
Type string `json:"type,omitempty"`
Validation struct {
ScoringType string `json:"scoring_type,omitempty"`
ValidResponse struct {
Score int `json:"score,omitempty"`
@kentquirk
kentquirk / sanitize.go
Created September 17, 2015 21:45
SanitizeHTML
// SanitizeHTML strips html tags, replace common entities
func SanitizeHTML(s string) string {
output := ""
// Shortcut strings with no tags in them
if !strings.ContainsAny(s, "<>") {
output = s
} else {
@kentquirk
kentquirk / decodeToken.go
Last active October 9, 2015 20:45
decodeGoogleOAuthToken
// This file isn't really needed but I'm not ready to delete it yet.
package main
import (
"bytes"
"crypto"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"