Skip to content

Instantly share code, notes, and snippets.

View klingtnet's full-sized avatar
a damn fine cup of coffee

Andreas Linz klingtnet

a damn fine cup of coffee
View GitHub Profile
@heyLu
heyLu / unix-socket.go
Created June 7, 2016 07:48
Unix sockets in Go
package main
import (
"fmt"
"net"
"os"
"os/signal"
"time"
)
@panzerdev
panzerdev / redis_pub_sub.go
Last active October 24, 2018 13:42
Redis based worker
package main
import (
"context"
"github.com/go-redis/redis"
"sync"
"time"
)
type RedisConsumer struct {
@miku
miku / main.go
Last active May 15, 2020 22:03
On the fly content type detection.
// Tee plus LimitWriter.
// LimitWriter taken from: https://github.com/kubernetes/kubernetes/blob/579e0c74c150085b3fac01f6a33b66db96922f93/pkg/kubelet/util/ioutils/ioutils.go#L39-L70
//
package main
import (
"bytes"
"flag"
"io"
"io/ioutil"
@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@dmitshur
dmitshur / gist:6927554
Last active September 17, 2023 07:35
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.

WARNING: This gist was created in 2013 and targets the legacy GOPATH mode. If you're reading this in 2021 or later, you're likely better served by reading https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.

$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@kennwhite
kennwhite / https.go
Last active December 24, 2023 22:06
Simple https http/2 static web server with HSTS & CSP (A+ SSLLabs & securityheaders.io rating) in Go using LetsEncrypt acme autocert
package main
import (
"crypto/tls"
"golang.org/x/crypto/acme/autocert"
"log"
"net"
"net/http"
)
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 16, 2024 12:16
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@adrienbeau
adrienbeau / how-to-run-melodics-on-linux-using-bottles.md
Created January 7, 2024 10:55
How to run Melodics on Linux using Bottles

How to run Melodics on Linux using Bottles

TL;DR: Melodics runs out-of-the-box with the current version of Bottles and its default settings. However Melodics uses your browser to handle logins, and expects your browser to be able to call the Melodics app once logged-in. Read "Melodics Desktop Integration" below to set that up.

Versions tested:

@brson
brson / gist:9dec4195a88066fa42e6
Last active April 19, 2024 00:34
A Rust Syntax Guide

A Guide to Rust Syntax

A very brief guide to Rust syntax. It assumes you are already familiar with programming concepts.

This was written in 2014. It is not a good reference for Rust today, though the content is still correct.

cheats.rs looks like a good alternative.

Assert macro

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: