Skip to content

Instantly share code, notes, and snippets.

View kentquirk's full-sized avatar

Kent Quirk kentquirk

View GitHub Profile
@kentquirk
kentquirk / fixpath.py
Created December 7, 2017 02:58
fixpath.py is a script to clean up a path
#! /usr/bin/env python
# returns a path with some special front/back values and dups removed
import os
import sys
def getenv(name):
try:
return os.environ[name].split(':')
@kentquirk
kentquirk / objtest.go
Created June 28, 2018 01:44
Full hasher object with promises
package main
//go:generate gopherjs build --minify
import (
"crypto/sha256"
"errors"
"github.com/gopherjs/gopherjs/js"
"github.com/miratronix/jopher"
@kentquirk
kentquirk / test.js
Created June 28, 2018 01:48
Test of full hasher with promises
m = require("./objtest3.js");
h = m.newHasher("This is a test")
h.hash().then((r) => {
console.log("hash of '" + h.s + "' is:", r.slice(0, 4))
}).catch((e) => {
console.log("Error: ", e)
});
@kentquirk
kentquirk / hashit.go
Created June 28, 2018 02:13
hashit function in go
func hashit(s string) []byte {
h := sha256.New()
h.Write([]byte(s))
return h.Sum(nil)
}
@kentquirk
kentquirk / simple.go
Created June 28, 2018 02:15
Simple gopherjs module demo
package main
//go:generate gopherjs build --minify
// This is an experiment to see if gopherjs can reasonably generate js code from go source
// so that we can have a single-source solution for keys and addresses.
// Use "go generate" to build this.
import (
"crypto/sha256"
@kentquirk
kentquirk / 1.sh
Created June 28, 2018 03:11
Shows results of running simple.js
$ node
> simple=require("./simple.js")
{ hashit: [Function] }
> simple.hashit("This is a test")
Uint8Array [
199,
190,
30,
217,
2,
@kentquirk
kentquirk / test.js
Created June 28, 2018 03:13
Simple test.js
simple = require("./simple.js");
h = simple.hashit("This is a test")
console.log(h.length)
@kentquirk
kentquirk / objtest.go
Created June 28, 2018 03:16
How to use an object sent by JS in gopherjs
package main
//go:generate gopherjs build --minify
import (
"crypto/sha256"
"github.com/gopherjs/gopherjs/js"
)
@kentquirk
kentquirk / test.js
Created June 28, 2018 03:17
Test script for objtest
m = require("./objtest.js");
h = m.hashobj({
name: "Kent",
address: "Somewhere in Space and Time",
city: "Specificity",
state: "CT"
})
console.log(h.slice(0, 4))
@kentquirk
kentquirk / objtest.go
Created June 28, 2018 03:38
Using a Go struct to shadow a JS Object
package main
//go:generate gopherjs build --minify
import (
"crypto/sha256"
"github.com/gopherjs/gopherjs/js"
)