Skip to content

Instantly share code, notes, and snippets.

Carlo Alberto Ferraris CAFxX

Block or report user

Report or block CAFxX

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View optcpu.go
func getOptimalCpuConfig(request, limit float64) (request, limit float64, cores int) {
if request == 0 && limit == 0 {
} else if request < 0 {
panic("negative request")
} else if limit < 0 {
panic("negative limit")
} else if limit != 0 && request > limit {
panic("request > limit")
CAFxX / hibp_bloom_poc.go
Last active Oct 1, 2019
quick and dirty bloom filter service for querying the haveibeenpwned dataset
View hibp_bloom_poc.go
package main
import (
View atomic_splitmix64.go
package fastrand
import (
type SplitMix64 uint64
var _ rand.Source64 = &SplitMix64{}
View sharded.go
package sharded
Last active Jun 6, 2019
Github wishlist

GitHub wishlist

Smart redirect for branch-less URLs

URLs of the form should redirect to if:

  • something does not match a branch name
  • something/somethingelse exists in defaultbranch

Smart redirect for renamed files

URLs of the form should redirect to if:

  • something/somethingelse else does not currently exist in branch
CAFxX / asm.s
Last active May 25, 2019
All the missing AMD64 atomic instructions for Golang
View asm.s
// Code generated by command: go run gen.go -out asm.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"
// func AddInt8(addr *int8, a0 int8)
TEXT ·AddInt8(SB), NOSPLIT, $0-16
MOVQ addr+0(FP), AX
MOVB a0+8(FP), CL
Last active May 22, 2019
Index of gists
Last active Jun 5, 2019
Minimize allocations in Go

📂 Minimize allocations in Go

Working with protobuf in Go puts significant load on the memory subsystem, as protobuf-generated structures often contain a significant amount of pointers.

One way to minimize the number of allocations is to allocate all the fields at the same time, and then use internal pointers to wire them up.

Let's pretend you have (the generated Go code for) four messages A, B, C, and D (note: for clarity this is not really protobuf-generated code, but the technique

View asyncwriter.go
package main
import (
type AsyncWriter struct {
View .hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
You can’t perform that action at this time.