Skip to content

Instantly share code, notes, and snippets.

View freman's full-sized avatar

Shannon Wynter freman

View GitHub Profile
@freman
freman / Makefile
Created February 4, 2019 05:55
Gogo proto makefile
EMPTY :=
SPACE := $(EMPTY) #
COMMA := ,
GOPATH:=$(shell go env GOPATH)
GOBIN:=${GOPATH}/bin
PROTO_PATH := ${GOPATH}/src:.
PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/gogo/protobuf/protobuf
PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/gogo/protobuf/gogoproto
package com.health.openscale.core.bluetooth;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.content.Context;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleMeasurement;
@freman
freman / pwreset.go
Created November 8, 2018 04:20
Just a password reset proof of concept no-one will use.
/*
It's commonly the case that users will hit "reset password" then get impatient
waiting for an email and hit it again thinking that some form of magic will increase
the priority of their request and make them get the email faster.
In a lot of circumstances that results in the original token in the database being
overwritten which makes it invalid. This frustrates the user when a token finally
turns up and they click on it only to have it fail.
@freman
freman / balancedroute
Created October 29, 2018 21:35
ocf:heartbeat:balancedroute
#!/bin/sh
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
usage() {
echo "usage: $0 {start|stop|status|monitor|validate-all|meta-data}"
}
@freman
freman / errors.md
Last active September 18, 2018 12:53
Error handling as it can already be done

I'd like to argue that to a great degree, we can already do error handling the way the proposal demonstrates it in the 'corrected' new example through the tools we already have without introducing new keywords or new magic.

The following achieves the same error handling in almost exactly the same way without being much longer or uglier than the reference material.

func CopyFile(src, dst string) (err error) {
	defer func() {
		if err != nil {
			err = fmt.Errorf("copy %s %s: %v", src, dst, err)
 }
@freman
freman / cooookie.patch
Last active May 11, 2018 01:28
Make go's cookie jar more url encoding tolerant.
--- /usr/local/go/src/net/http/cookiejar/jar.go 2018-05-11 10:28:23.000000000 +1000
+++ cooookie/jar.go 2018-05-11 11:27:43.000000000 +1000
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
-package cookiejar
+package cooookie
import (
# dig api.production.aws.neds.com
; <<>> DiG 9.10.6 <<>> api.production.aws.neds.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 12273
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
# dig +trace api.production.aws.neds.com
@freman
freman / login.go
Last active January 12, 2023 04:51
Log into grafana on a samsung tv
package main
// NB our grafana has keycloak in front, probably tweak a little (remove a click or two if you're just logging into grafana)
import (
"crypto/tls"
"encoding/base64"
"encoding/json"
"fmt"
"log"
@freman
freman / index.html
Created March 12, 2018 02:08
Show a portion of 4 images side by side and synchronise the clip.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style>
.wrap { position: relative; }
.wrap > img {
position: absolute;
clip: rect(0px, 400px, 400px, 0px);
@freman
freman / omg.js
Created October 24, 2017 00:08
Not-Junk all the email in the outlook junk folder
var n = 0;
var repeats = 200
function omg() {
triggerEventOnPage('._lvv_W1', 'mouseup')
$('._n_41 button').click();
window.setTimeout(function() {
$('button span:contains("Not junk")').parent().click();
window.setTimeout(function() {
$('.popupShadow ._fce_V button.ms-bcl-tp-f').click();
n++;