Skip to content

Instantly share code, notes, and snippets.

View kentquirk's full-sized avatar

Kent Quirk kentquirk

View GitHub Profile
@kentquirk
kentquirk / main.go
Created November 17, 2022 22:52
Dynamic sampler fun
package main
import (
"fmt"
"math/rand"
"time"
dynsampler "github.com/honeycombio/dynsampler-go"
)
@kentquirk
kentquirk / .bash_profile
Created August 9, 2018 02:27
persistent history
#################################################################
# keep a permanent history of commands typed across all windows.
# This uses the history command to match the part that was typed,
# then uses BASH_REMATCH to extract that part and store it in the
# .persistent_history file. This is run automatically every time
# the prompt is redisplayed.
log_bash_persistent_history() {
[[
$(history 1) =~ ^[[:space:]]*[0-9]+[[:space:]]+(.*)$
@kentquirk
kentquirk / .bash_profile
Created August 9, 2018 02:10
kent's color prompt
#################################################################
# Here's a bunch of stuff to do prompts that are sensitive to git and svn
# sets the title of the iterm2 window
title()
{
TITLE=$*;
export PROMPT_COMMAND='echo -ne "\033]0;$TITLE\007"'
}
@kentquirk
kentquirk / test.js
Created June 28, 2018 03:40
Using Go structs from JS
m = require("./objtest2.js");
h = m.hashobj({
name: "Kent",
address: "Somewhere in Space and Time",
city: "Specificity",
state: "CT"
})
console.log(h.hash.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"
)
@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: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:13
Simple test.js
simple = require("./simple.js");
h = simple.hashit("This is a test")
console.log(h.length)
@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 / 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"