Skip to content

Instantly share code, notes, and snippets.

View kevin-cantwell's full-sized avatar
🙃
cOmpUTerZ

Kevin Cantwell kevin-cantwell

🙃
cOmpUTerZ
View GitHub Profile
@kevin-cantwell
kevin-cantwell / expand.go
Created February 26, 2020 15:09
Expand psql output
/*
Accepts an unexpanded psql result set on stdin and expands it.
*/
package main
import (
"bufio"
"fmt"
"os"
"strings"
@kevin-cantwell
kevin-cantwell / box.go
Created February 21, 2020 16:48
boxboxbox
package main
import (
"flag"
"fmt"
"math/rand"
"os"
"golang.org/x/crypto/ssh/terminal"
)
@kevin-cantwell
kevin-cantwell / dancing_gopher_playground.go
Created May 17, 2019 00:35
Prints a dancing gopher to the output in the Go playground
package main
import (
"bytes"
"context"
"fmt"
"image"
"image/gif"
"io"
"os"
@kevin-cantwell
kevin-cantwell / Dockerfile.snippet
Created March 26, 2019 14:12
Dockerfile example for migrating Debian to archive sources
# https://lists.debian.org/debian-devel-announce/2019/03/msg00006.html
RUN echo "deb http://archive.debian.org/debian jessie main" | tee /etc/apt/sources.list
RUN echo "deb http://archive.debian.org/debian/ jessie-backports main" | tee -a /etc/apt/sources.list
RUN echo "deb http://security.debian.org jessie/updates main" | tee -a /etc/apt/sources.list
RUN echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
RUN echo 'Package: *\nPin: origin "archive.debian.org"\nPin-Priority: 500' | tee -a /etc/apt/preferences.d/10-archive-pin
@kevin-cantwell
kevin-cantwell / tlsconfig.go
Last active February 26, 2019 14:56
generate a localhost tls config
// returns an ad-hoc tls config that does not need to write or read any files.
func tlsConfig() *tls.Config {
serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128))
if err != nil {
panic(err)
}
template := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
@kevin-cantwell
kevin-cantwell / main.go
Last active January 17, 2019 14:55
Print QR codes in the terminal
package main
import (
"fmt"
"net/url"
"os"
qrcode "github.com/skip2/go-qrcode"
)
@kevin-cantwell
kevin-cantwell / main.go
Created March 9, 2018 01:35
backplane connect test
package main
import (
"fmt"
"net/http"
"os"
"os/exec"
"time"
)
@kevin-cantwell
kevin-cantwell / gbear.go
Last active February 8, 2018 01:26
Exchanges a Google Oauth2 refresh token for a bearer token
package main
import (
"bytes"
"io"
"log"
"net/http"
"net/url"
"os"
)
@kevin-cantwell
kevin-cantwell / client.go
Created February 1, 2018 18:08
PTTH Client
package ptth
import (
"errors"
"net"
"net/http"
"golang.org/x/net/http2"
)
🍚 21:06:44[/gps (paired-lv=)]$ go test ./...
--- FAIL: TestBasicSolves (0.02s)
--- FAIL: TestBasicSolves/unlocks_dependencies_if_necessary_to_ensure_that_a_new_dependency_is_satisfied (0.00s)
solve_test.go:68: Root project is "root"
solve_test.go:68: 1 transitively valid internal packages
solve_test.go:68: 2 external packages imported from 2 projects
solve_test.go:68: (0) ✓ select (root)
solve_test.go:68: (1) ? attempt foo with 1 pkgs; at least 1 versions to try
solve_test.go:68: (1) try [email protected]
solve_test.go:68: (1) ✓ select [email protected] w/1 pkgs