Skip to content

Instantly share code, notes, and snippets.

@schwern
schwern / permutation.go
Last active August 31, 2021 14:18
A permutation library based on Paul Hankin's from https://stackoverflow.com/a/30230552/14660
package permutation
// Based on https://stackoverflow.com/a/30230552/14660 by Paul Hankin
// perm := NewPermutation( slice )
// for next := perm.Next(); next != nil; next = perm.Next() {
// ...
// }
//
// or
<dgryski@kamek[powbench] \ʕ◔ϖ◔ʔ/ > go test -test.bench=.
BenchmarkPolyPow-4 5000000 286 ns/op
BenchmarkPolyFast-4 100000000 16.7 ns/op
PASS
ok github.com/dgryski/powbench 3.430s
@lleveque
lleveque / go-complete.sh
Last active December 13, 2016 20:55
When in your $GOPATH, make `go` autocomplete to packages. Add this to your .bashrc.
function _gocomplete_()
{
# What do we want to autocomplete ?
local word=${COMP_WORDS[COMP_CWORD]}
# list packages that match in src/ subfolder, discarding warnings if no result
COMPREPLY=($(go list ./src/"${word}"... 2>/dev/null))
}
# register autocomplete function for `go`
complete -F _gocomplete_ go
@JonCole
JonCole / Redis-BestPractices-General.md
Last active April 27, 2024 12:50
Redis Best Practices

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@ajkeeton
ajkeeton / permessage_deflate_issue_poc
Created July 18, 2016 19:56
Permessage-deflate issue with Go's deflate
package main
import (
"compress/flate"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
// "bufio"
"bytes"
@JonCole
JonCole / WhatHappenedToMyDataInRedis.md
Last active October 28, 2019 19:43
What happened to my data in Redis?
@maksymx
maksymx / install_opencv_2.4.11_fedora.sh
Created April 5, 2016 10:55
Install OpenCV 2.4.11 Fedora 21
yum install cmake
yum install python-devel numpy
yum install gcc gcc-c++
yum install gtk2-devel libdc1394-devel libv4l-devel ffmpeg-devel gstreamer-plugins-base-devel libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel
yum install libtiff-devel libwebp-devel tbb-devel eigen3-devel python-sphinx texlive
pushd /tmp
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.11/opencv-2.4.11.zip
unzip opencv-2.4.11.zip
cd opencv-2.4.11
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@tkrajina
tkrajina / remove_accents.go
Created January 31, 2016 08:21
Golang remove accents
package main
import (
"fmt"
"unicode"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
@nitoyon
nitoyon / rgb.go
Created January 1, 2016 16:08
Generate Animation GIF with Golang
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"math"
"os"
)