Skip to content

Instantly share code, notes, and snippets.

View localhots's full-sized avatar

Gregory Eremin localhots

View GitHub Profile

Keybase proof

I hereby claim:

  • I am localhots on github.
  • I am localhots (https://keybase.io/localhots) on keybase.
  • I have a public key ASCDKmJ4kwqvKdd3GxSPxccArJxaM3JzCVfx6_vQDTdd9wo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am localhots on github.
  • I am localhots (https://keybase.io/localhots) on keybase.
  • I have a public key ASCDKmJ4kwqvKdd3GxSPxccArJxaM3JzCVfx6_vQDTdd9wo

To claim this, I am signing this object:

@localhots
localhots / results.txt
Created February 4, 2019 13:41
Switch vs map performance in Go
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/localhots/playground/switch_vs_map
BenchmarkSwitch-8 2000000000 0.34 ns/op
BenchmarkSwitchMiss-8 2000000000 0.64 ns/op
BenchmarkMap-8 300000000 4.11 ns/op
BenchmarkMapMiss-8 200000000 8.18 ns/op
PASS
ok github.com/localhots/playground/switch_vs_map 6.219s
@localhots
localhots / keybase.md
Created April 3, 2017 09:37
Keybase verification

Keybase proof

I hereby claim:

  • I am localhots on github.
  • I am localhots (https://keybase.io/localhots) on keybase.
  • I have a public key whose fingerprint is 652D CD01 4C33 1C79 9409 EBBC 716E 17BC 4B46 571B

To claim this, I am signing this object:

PROJECTS=$HOME/Code
function c { cd $(realpath $PROJECTS/$1); }
function _c { __bash_directory_complete $PROJECTS; }
complete -F _c c
function __bash_directory_complete {
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -o nospace -W "$(ls $1)" -- $cur))
}
func processWithBatches(items []uint32, batchSize int, f func(batch []uint32)) {
if len(items) == 0 {
return
}
if len(items) <= batchSize {
f(items)
} else {
f(items[:batchSize])
processWithBatches(items[batchSize:], batchSize, f)
package main
import (
"log"
"runtime"
"strings"
)
const (
rootPath = "/path/to/project/root/"
package main
import "time"
// Uint32BatchWithTimeout is an implementation of a batch that starts processing
// either if maximum size or timeout is reached.
type Uint32BatchWithTimeout struct {
size int
timeout time.Duration
fun func(batch []uint32)
package main
import (
"flag"
"fmt"
"time"
as "github.com/aerospike/aerospike-client-go"
)
@localhots
localhots / config.ru
Created August 27, 2014 13:14
Unicorn worker killer + out-of-band garbage collection
require 'bundler'
Bundler.setup
require 'unicorn'
begin
# Unicorn self-process killer
require 'unicorn/worker_killer'
# Max requests per worker