Skip to content

Instantly share code, notes, and snippets.

View markwatson's full-sized avatar
💻
hacking the mainframe

Mark Watson markwatson

💻
hacking the mainframe
View GitHub Profile
@markwatson
markwatson / jwks.json
Last active October 6, 2022 21:05
testjwk.json
[{"crv":"P-256","x":"AK8tZe41dys_C6BTzKdueyB4aZ4Wf-PCujzb7j3i7m2d","y":"Ziv-DVie-hMW4GV9jzlPqs77nsu0Msh0-TU3lgXUdE0=","kty":"EC","use":"sig","keyOps":["sign","verify"],"alg":"ES256","kid":"arn:aws:kms:us-east-1:000000000000:key/0d134cc0-7bd3-48a9-89eb-e7cfb0188b41"}]
@markwatson
markwatson / keybase.md
Created January 3, 2018 21:44
Keybase verification

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:

@markwatson
markwatson / toString Generator
Created February 9, 2016 07:02 — forked from jenslohmann/toString Generator
Java toString() generator for IntelliJ IDEA that generates JSON
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 = "+ "", "" + " )
@markwatson
markwatson / onChange.js
Created February 23, 2015 19:27
Helper to live check for input box changes in JavaScript.
$.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;
@markwatson
markwatson / createEl.js
Created May 29, 2014 22:01
Create elements in javascript. Useful to me, not that useful in general.
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) {
@markwatson
markwatson / csv.py
Last active August 29, 2015 13:56
Reads CSV files while handling all types of edge cases. (Built as an exercise - probably not useful)
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.
@markwatson
markwatson / time_card.py
Created July 16, 2013 04:21
A simple time tracker script.
#/usr/bin/env python
"""
time_cards.py
This utility tracks time.
"""
import datetime
import atexit
@markwatson
markwatson / merge_tuples.rb
Created March 11, 2013 21:40
Merges an array of arrays by adding the elements together.
# 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
@markwatson
markwatson / pretty_json.py
Last active December 12, 2015 04:58
A sublime text plugin that pretty formats all the select JSON blobs.
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():