Skip to content

Instantly share code, notes, and snippets.

View rsc's full-sized avatar

Russ Cox rsc

View GitHub Profile
@rsc
rsc / cert.go
Created December 3, 2015 19:57
package main
import (
"crypto/x509"
"encoding/pem"
"log"
)
func main() {
pemData := []byte(chain)
@rsc
rsc / vet2sam
Created February 19, 2015 21:15
go vet -> sam commands
#!/usr/bin/perl
while(<>) {
chomp;
if(/^(\S+):(\d+): [^:]+: (.+) should be (.+)/) {
print "B $1\n";
$old = $3;
$new = $4;
$line = $2;
$old =~ s/([()+])/\\$1/g;
@rsc
rsc / buildall
Last active August 29, 2015 14:14
rebuild and compare all Go targets
#!/bin/bash
# Usage: buildall [-e] [-cmp] [-work]
#
# Builds everything (std) for every GOOS/GOARCH combination but installs nothing.
#
# By default, runs the builds with -toolexec 'toolstash -cmp', to test that the
# toolchain is producing bit identical output to a previous known good toolchain.
#
# Options:
@rsc
rsc / normalize.go
Created June 26, 2014 17:47
crappy normalization
package main
import "bytes"
var utab = []struct {
v, n uint16
}{
{0x00C0, 0x0041},
{0x00C1, 0x0041},
{0x00C2, 0x0041},
@rsc
rsc / ftoa.go
Created July 1, 2011 04:34
Floating Point to Decimal Conversion Is Easy
package main
import (
"fmt"
"math"
"strconv"
)
func ftoa(f float64, prec int) string {
fr, exp := math.Frexp(f)
@rsc
rsc / clpush
Last active September 24, 2015 11:27
script for pushing and popping CLs
#!/bin/sh
set -e
root=$(hg root)
if [ $# = 0 ]; then
for i in $(ls $root/.hg/codereview/cl.* 2>/dev/null)
do
n=$(echo $i | sed 's/.*cl.//')
desc=$(sed -n '/^Description:/,$p' $i | sed -n 2p)
echo +$n' '$desc