Skip to content

Instantly share code, notes, and snippets.

View djui's full-sized avatar

Uwe Dauernheim djui

View GitHub Profile
$ grep -n -r 'func init()' * | grep -v vendor | grep -v compile | grep -v '_.*\.go'
cmd/asm/internal/flags/flags.go:31:func init() {
cmd/doc/dirs.go:28:func init() {
cmd/fix/context.go:11:func init() {
cmd/fix/gotypes.go:12:func init() {
cmd/fix/netipv6zone.go:9:func init() {
cmd/fix/printerconfig.go:9:func init() {
cmd/go/bug.go:30:func init() {
cmd/go/build.go:140:func init() {
cmd/go/build.go:197:func init() {
// Generated music inspired by https://www.youtube.com/watch?v=MqZgoNRERY8
//
// First you need to install SoX: brew install sox
//
// go run music.go | play -c 1 -b 8 -e unsigned -t raw -r 22k -
package main
import "fmt"
<html>
<head>
<style>
body {
background-color: #f00;
}
</style>
</head>
<body>
</body>
@djui
djui / concept.md
Last active August 28, 2016 21:26
KTANE - Keep talking and nobody explodes

Example

╔═══════════════╗ ╔═══════════════╗ ╔═══════════════╗
║    ┌─────┐  * ║ ║    ┌───┐    * ║ ║  ┌───┐┌─┰─┐ *︎ ║
║    │ x x │    ║ ║    │ 3 │    ▉ ║ ║  │ ℵ ││ Ψ │   ║
║    └─────┘    ║ ║    └───┘    ▉ ║ ║  └───┘└───┘   ║
║ _        _  _ ║ ║┌─┐┌─┐┌─┐┌─┐ ▉ ║ ║  ┌─┰─┐┌───┐   ║
║| ||_| .  _||_ ║ ║│1││4││3││2│ ▉ ║ ║  │ ξ ││ σ │   ║
║|_|  | . |_ |_|║ ║└─┘└─┘└─┘└─┘ ▉ ║ ║  └───┘└───┘   ║

╚═══════════════╝ ╚═══════════════╝ ╚═══════════════╝

@djui
djui / slice.go
Created July 26, 2016 16:59
Explaining how nil in Go works for slices
package main
import (
"fmt"
"reflect"
"unsafe"
)
func main() {
var x []byte
@djui
djui / PushEvent.go
Last active May 25, 2016 08:03
go-github push event handling
github.PushEvent{
Repo:github.PushEventRepository{
CreatedAt:github.Timestamp{2015-10-26 15:42:55 +0000 UTC},
DefaultBranch:"master",
Description:"A simple continuous integration server using Hookbot to subscribe to branch changes on Github hosted repositories.",
Fork:false,
ForksCount:0,
FullName:"scraperwiki/seaeye",
HasDownloads:true,
HasIssues:true,
$ pwd
/Users/uwe/dev/inception-test
$ touch hello_inception
$ docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/foo docker
/ # ls /foo/hello_inception
/foo/hello_inception
/ # cd /foo
/foo # docker run --rm -it -v $(pwd):/foo docker
@djui
djui / go-test-pretty
Created March 23, 2016 14:41
Highlights the go test output
#!/bin/bash
sed ''/RUN/s//$(printf "\033[30;1mRUN\033[0m")/'' | \
sed ''/PASS:/s//$(printf "\033[32mPASS\033[0m:")/'' | \
sed ''/PASS/s//$(printf "\033[32;1mPASS\033[0m")/'' | \
sed ''/SKIP:/s//$(printf "\033[33mSKIP\033[0m:")/'' | \
sed ''/SKIP/s//$(printf "\033[33;1mSKIP\033[0m")/'' | \
sed ''/FAIL:/s//$(printf "\033[31mFAIL\033[0m:")/'' | \
sed ''/FAIL/s//$(printf "\033[31;1mFAIL\033[0m")/''
@djui
djui / s3_foreach.go
Last active March 2, 2016 16:40
Takes a list of S3 URLs and applies a function on each file
package main
import (
"bufio"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
"sync"
@djui
djui / go-funclen
Last active February 17, 2016 17:17
Print a list of all most-outer scope Go functions sorted by their length.
#!/usr/bin/env python3
import glob
import json
import sys
def main(args):
if not args:
print("Usage: go-funclen BASEDIR", file=sys.stderr)