Skip to content

Instantly share code, notes, and snippets.

View warpfork's full-sized avatar

Eric Myhre warpfork

View GitHub Profile
@warpfork
warpfork / gist:6343783
Last active December 21, 2015 17:59
comparison of techniques to obtain reproducible and offline builds (ascii table)
```
core transparent multiple permanent bloat
approach offline? fast reproducible when library histories to source repo
---------- -------- ---- ------------ ------------ --------- ---------------
script (clone semantic no/fail no yes (`checkout yes no no
at build time) -f $HASH`)
script (clone semantic yes yes yes yes no no
once, checkout
package main
import (
"fmt"
"net/http"
)
func handler(resp http.ResponseWriter, req *http.Request) {
fmt.Printf("serving \"%s\"\n", req.URL.Path)
http.ServeFile(resp, req, req.URL.Path[1:])
#!/bin/bash
interests=("$@")
for x in "${interests[@]}"; do
echo -ne "\t$x"
done
echo
while true; do
snap=`ps -A -o rss -o cmd` # downgrade to '-a' or leave it out entirely for confined scope
@warpfork
warpfork / chans_test.go
Last active August 29, 2015 14:13
"generic" channels & benchmark
package what
import (
"encoding/json"
"reflect"
"testing"
)
type testStruct struct {
A string
@warpfork
warpfork / sshfs
Created January 30, 2015 03:38
sshfs
#!/bin/bash
mkdir -p "${locPath}" && \
trap '( fusermount -u "${locPath}" && rmdir "${locPath}" ) 2>/dev/null ; exit $?' INT TERM EXIT && \
(
declare -a opts
opts=();
opts+=("-o sshfs_sync"); # synchronous writes
opts+=("-o no_readahead"); # synchronous reads
opts+=("-o reconnect"); # try harder
@warpfork
warpfork / gist:109b0b18df65579b498b
Last active August 29, 2015 14:15
zfs is actually not super cool
#!/bin/bash
# Summary: ZFS snapshots have a variety of remarkable limitations.
#
# - "recv" has no way to just accept snapshot data without actually checking it out onto the volume working tree.
# - it's probably going to have to be coddled by having a spare dataset off to the side that does network receives.
# - "revert" to a snapshot is unsafe for anything other than depth=1 and may destroy snapshots.
# - it has to be replaced by forking, and figuring out how to do an atomic replace. ("zfs rename" appears to be up to the task, but do note that it's precisely the atomicity level of any other mount operation; no more no less.)
# - "clone" operations, which you'd think would be the right choice for "forking" a dataset, are just bonkers: clone causes data dependencies (deletes get weird) and the clones aren't capable of receiving incremental updates (bake your noodle on that one).
# - the "promote" operation screws with the persistency of the thing you cloned *from* as well as the clone; at that point,
@warpfork
warpfork / liteide-wrapper
Created March 10, 2015 23:19
a wrapper script for teaching liteide how to workspaces
#!/bin/bash
set -euo pipefail
IFS=$'\0'
#
# config
# (you'll want to fix these to your environment, or change the project auto-detect to fit.)
#
litespace="~/liteideSpace/"
sourcespace="~/repos/"
@warpfork
warpfork / go1.5-from-go1.5.frm
Last active February 18, 2016 02:00
go-building-go
##
## The following configuration is a contained environment with deterministic inputs (checked by a strong hash)
## which uses the go1.5 release for linux to *build* the go1.5 binaries for linux.
## (Jump to the bash script in the middle if you're just reading and willing to take the inputs for granted.)
##
## It then hashes the results so you can easily check that they are self-consistent when you run this process
## repeatedly on your own computer. (The use of sandboxes means we're confident there's no leakage
## of state across repetitions.)
##
## Note that this does *not* check that the results are identical to the `bin` folder in the upstream
@warpfork
warpfork / practices-golang-plugin-patterns.md
Created May 31, 2016 16:00
Golang Practices: Patterns for "plugin" Package Layouts

wise choices for plugin patterns in golang

Any time you use an interface, really -- if it's a small one, you might cram everything into one package. If it's not small... you need to decide how to lay out your packaging!

Phase 1: Declare interfaces and API data types in a top level package

Put all the interfaces (and, any other structures that are completely shared data types and part of the general API) in one package. This is the stuff that most of your program is referring to already, so this is a process of making those boundaries explicit.

@warpfork
warpfork / wtfdisks
Created July 7, 2016 04:39
wtfdisks -- make smartmon output vaguely readable. maybe.
#!/bin/bash
#
# Turn on smartmon;
# ask it to do a test;
# wait an arbitrary amount of time because smartmon's api is childish;
# ask for failure reports.
#
# Pretty print the whole thing, in as much as possible, because smartmon's output is fugly to the point of impeding usability.
#