Skip to content

Instantly share code, notes, and snippets.

View gist:1384ce7a73b30f4d51129cc3fb2edc44
$ 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() {
View music.go
// 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"
View index.html
<html>
<head>
<style>
body {
background-color: #f00;
}
</style>
</head>
<body>
</body>
@djui
djui / concept.md
Last active Aug 28, 2016
KTANE - Keep talking and nobody explodes
View concept.md

Example

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

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

@djui
djui / slice.go
Created Jul 26, 2016
Explaining how nil in Go works for slices
View slice.go
package main
import (
"fmt"
"reflect"
"unsafe"
)
func main() {
var x []byte
@djui
djui / PushEvent.go
Last active May 25, 2016
go-github push event handling
View PushEvent.go
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,
View did-volume-mount-problem
$ 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 Mar 23, 2016
Highlights the go test output
View go-test-pretty
#!/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 Mar 2, 2016
Takes a list of S3 URLs and applies a function on each file
View s3_foreach.go
package main
import (
"bufio"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
"sync"
@djui
djui / go-funclen
Last active Feb 17, 2016
Print a list of all most-outer scope Go functions sorted by their length.
View go-funclen
#!/usr/bin/env python3
import glob
import json
import sys
def main(args):
if not args:
print("Usage: go-funclen BASEDIR", file=sys.stderr)