Skip to content

Instantly share code, notes, and snippets.

include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <math.h>
#include "stinger_utils/timer.h"
int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) {
int64_t b= -1, j = 0;
@robmccoll
robmccoll / Named C Params
Created October 16, 2014 02:07
This is a preprocessor hack to emulate named parameters in C
#include <stdio.h>
typedef struct {
int len;
int * int_arr;
char * char_arr;
} print_arr_args;
#define print_array(...) print_array_impl((print_arr_args){__VA_ARGS__})
void print_array_impl(print_arr_args args) {

Keybase proof

I hereby claim:

  • I am robmccoll on github.
  • I am robmccoll (https://keybase.io/robmccoll) on keybase.
  • I have a public key whose fingerprint is 409E F943 610E 031D DF3B A2E7 FA3C BFF9 05C1 89AA

To claim this, I am signing this object:

#!/bin/bash
# A hacky bash script that scans Go vendor dirs for licenses.
# License checking could probably be improved...
CODEDIRS=$(find vendor -name "*.go" | xargs dirname | sort | uniq)
LICENSEDIRS=$(find vendor -name LICENSE | xargs dirname)
# echo -e "CODE DIRS *********************\n"
# echo -n "$CODEDIRS"
# echo -e "\n\nLICENSE DIRS *********************\n"
@robmccoll
robmccoll / main_test.go
Created January 25, 2019 15:00
Go chan bool loop vs. sync.WaitGroup bench
package main
import (
"sync"
"testing"
)
func immediateWG(wg *sync.WaitGroup) {
wg.Done()
}
@robmccoll
robmccoll / main.cpp
Last active January 25, 2019 15:09
Attempt at generating Access / Mutate C# style
#include <iostream>
#include <string>
#include <exception>
// The idea is to provide conveniences that:
// - create get() and set() methods for you
// - have low boilerplate
// - be easy to read / understand (if something is declared rewrite<class> name;
// I can expect that it has get() and set() methods).
// - allow easy override / implementation later
@robmccoll
robmccoll / go_string_alias_types.md
Created April 3, 2020 19:23
Go language idea: String alias types

Improved Go string alias types? (needs better name)

What?

func Authenticate(user string:UserID, password string:UserPassword) (string:JWT, error) {
  // ...
}

type User struct {

UserID string:UserID