Skip to content

Instantly share code, notes, and snippets.

@masiulaniec
masiulaniec / gist:d92ff30ca16e79f0b7bcd77b6fd9257c
Created July 23, 2021 02:49
SetReadBuffer effect on UDP listener
$ cat > udpbufcap.go << EOF
package main
import (
"fmt"
"io/ioutil"
"net"
"os"
"strconv"
"strings"

Approach 1: Empty upspin.Event as an indicator of receipt of full tree:

func mirror(upath upspin.PathName, events <-chan upspin.Event) {
        // localPath maps the given upspin path to a path in a local file system
        localPath := func(remote upspin.Path) string {
                ... // irrelevant detail
        }

        os.RemoveAll(localPath(upath))
@masiulaniec
masiulaniec / gist:2782828
Created May 24, 2012 17:07
Lookup ssh(1) password in factotum(4)
diff --git a/misc.c b/misc.c
index a7a23dc..73a1741 100644
--- a/misc.c
+++ b/misc.c
@@ -712,6 +712,59 @@ tun_open(int tun, int mode)
#endif
}
+/*
+ * Query factotum(4) for the password. Return NULL if not found.
@masiulaniec
masiulaniec / gist:2358239
Created April 11, 2012 09:30
parallelism with xargs
#!/bin/sh
if [ -z "$1" ]
then
# Query N load balancers in parallel.
xargs -P 10 -n 1 -d '\n' $0 poll <<EOF
10.0.0.1 community101 dc=foo1 host=lb01.foo.com
10.0.0.2 community101 dc=foo1 host=lb02.foo.com
10.0.0.3 community101 dc=foo1 host=lb03.foo.com
EOF
# A sample top level Makefile for multi package Go projects.
include $(GOROOT)/src/Make.inc
CMDS=\
command-1\
command-2\
command-3
PKGS=\