Keybase proof
I hereby claim:
- I am markwatson on github.
- I am markwatson (https://keybase.io/markwatson) on keybase.
- I have a public key ASCuAq64t3gLeQezhPXltcKBo12vkezVThpaCWjAF65M2Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
public java.lang.String toString() { | |
#if ( $members.size() > 0 ) | |
#set ( $i = 0 ) | |
return "{\"_class\":\"$classname\", " + | |
#foreach( $member in $members ) | |
#set ( $i = $i + 1 ) | |
#if ( $i == $members.size() ) | |
#set ( $postfix = "+" ) | |
#else | |
#set ( $postfix = "+ "", "" + " ) |
$.fn.mwOnChange = function(callback, timeout) { | |
return $(this).each(function() { | |
if (timeout === undefined) { | |
timeout = 500; | |
} | |
var eventNames = 'keydown paste input'; | |
var timeoutId = null; | |
$(this).on(eventNames, function(e) { | |
var self = this; |
var createEl = function(type, props, children) { | |
var el = document.createElement(type); | |
if (props) { | |
for (var key in props) { | |
if (props.hasOwnProperty(key)) { | |
if (key == "css") { | |
if (props[key].length > 0) { | |
el.style.cssText = props[key].join(';') + ";"; | |
} | |
} else { |
function countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |
import re | |
import unittest | |
class CsvReader(object): | |
""" | |
Reads CSV files while handling all types of edge cases. | |
""" | |
def __init__(self, lines): | |
""" | |
A new CSV reader with the given lines. |
#/usr/bin/env python | |
""" | |
time_cards.py | |
This utility tracks time. | |
""" | |
import datetime | |
import atexit |
# Takes an array of totals_tuples and combines them into a single tuple. | |
def self.merge_tuples(tuples) | |
tuples.inject([]) do |xs, ys| | |
l = [xs.length, ys.length].max | |
zs = [] | |
l.times.each do |i| | |
zs[i] = (xs[i] || 0) + (ys[i] || 0) | |
end | |
zs | |
end |
import sublime, sublime_plugin | |
import json | |
import re | |
class PrettyJsonCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
re_json_p = re.compile(r'^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$') | |
try: | |
for region in self.view.sel(): |
def mean(x): return sum(x) / len(x) | |
def std_dev(x, mx=None): | |
if mx is None: | |
mx = mean(x) | |
return math.sqrt(sum((i - mx)**2 for i in x)/len(x)) |