Skip to content

Instantly share code, notes, and snippets.

Carlo Alberto Ferraris CAFxX

View GitHub Profile
CAFxX / shrinkmap.go2
Last active Jun 29, 2020
Shrinking map using go generics
View shrinkmap.go2
// Just an experiment to build a minimal "fix" for
// using go generics.
// It's actually a better "go" map than the builtin
// ones, as the zero value is a valid map. :)
package main
View serial_printf.ino
2020 CAFxX
serial_printf is a printf for Arduino Serial output that uses no dynamic allocation (malloc)
and constant stack space (in addition to that of printf).
Supports the same syntax of the standard Arduino/AVR printf-like functions.
Returns the number of characters printed.
CAFxX / dict.go
Last active Jan 28, 2020
View dict.go
package main
import (
View aligned.go
package aligned
import (
const (
cacheLineSize = unsafe.Sizeof(cpu.CacheLinePad{})
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
You can’t perform that action at this time.