Skip to content

Instantly share code, notes, and snippets.

View tsuna's full-sized avatar

Benoit Sigoure tsuna

View GitHub Profile
@tsuna
tsuna / api-server.log_1
Created July 12, 2018 23:20
kops failed upgrade
Flag --etcd-quorum-read has been deprecated, This flag is deprecated and the ability to switch off quorum read will be removed in a future release.
Flag --insecure-bind-address has been deprecated, This flag will be removed in a future version.
Flag --insecure-port has been deprecated, This flag will be removed in a future version.
I0712 22:54:43.196267 1 flags.go:27] FLAG: --address="127.0.0.1"
I0712 22:54:43.196388 1 flags.go:27] FLAG: --admission-control="[]"
I0712 22:54:43.196435 1 flags.go:27] FLAG: --admission-control-config-file=""
I0712 22:54:43.196476 1 flags.go:27] FLAG: --advertise-address="<nil>"
I0712 22:54:43.196541 1 flags.go:27] FLAG: --allow-privileged="true"
I0712 22:54:43.196582 1 flags.go:27] FLAG: --alsologtostderr="false"
I0712 22:54:43.196622 1 flags.go:27] FLAG: --anonymous-auth="false"
@tsuna
tsuna / foo.go
Created June 8, 2018 00:25
Testing code with timers in Go in a 100% deterministic manner, without relying on time passing
package main
import (
"fmt"
"time"
)
type Foo struct {
t *time.Ticker
}
@tsuna
tsuna / hash.go
Created June 5, 2018 17:20
How to hash strings in Go
package gist
import "unsafe"
//go:noescape
//go:linkname strhash runtime.strhash
func strhash(a unsafe.Pointer, h uintptr) uintptr
// StrHash returns the hash of the given string.
func StrHash(s string) uintptr {
@tsuna
tsuna / metafact.cpp
Created October 6, 2016 01:04
factorial in meta-programming
#include <iostream>
template <int i>
struct factorial {
enum {
result = factorial<i-1>::result * i,
};
};
template <>
@tsuna
tsuna / rdsosreport.txt
Created April 1, 2016 02:09
CoreOS 1000.0.0 boot problem with a broken drive
+ cat /lib/dracut/dracut-041-r2
dracut-041-r2
+ cat /proc/cmdline
rootflags=rw mount.usrflags=ro BOOT_IMAGE=/coreos/vmlinuz-a mount.usr=PARTUUID=7130c94a-213a-4e5a-8e26-6cce9662f132 rootflags=rw mount.usrflags=ro consoleblank=0 root=LABEL=ROOT console=ttyS0,115200n8 console=tty0 coreos.first_boot=1 coreos.randomize_disk_guid=00000000-0000-0000-0000-000000000001 verity.usrhash=c95407ad3c5567b16fb249f74e9662d9f4b5af55c4f1e3fe5c958c6d6845bc60
+ '[' -f /etc/cmdline ']'
+ for _i in '/etc/cmdline.d/*.conf'
+ '[' -f /etc/cmdline.d/base.conf ']'
+ echo /etc/cmdline.d/base.conf
/etc/cmdline.d/base.conf
+ cat /etc/cmdline.d/base.conf
@tsuna
tsuna / README.md
Created March 27, 2016 04:17
SSL/TLS certificate rotation with gRPC (hack/demo/POC)

gRPC SSL/TLS cert rotation

Generate a couple key pairs:

openssl req -x509 -newkey rsa:2048 -keyout key1.pem -out cert1.pem -days 42 -nodes
openssl req -x509 -newkey rsa:2048 -keyout key2.pem -out cert2.pem -days 42 -nodes
ln -s key1.pem key.pem
ln -s cert1.pem cert.pem
@tsuna
tsuna / integration_test.go
Last active August 29, 2015 14:27
gohbase integration test to access a disabled table
func TestDisabledTable(t *testing.T) {
// TODO: We leak the master client.
master := gohbase.NewClient(*host, gohbase.Admin())
logrus.WithFields(logrus.Fields{"table": table}).Info("Disabling table")
_, err := master.SendRPC(hrpc.NewDisableTable(context.Background(), []byte(table)))
if err != nil {
t.Fatalf("Failed to disable %q: %s", table, err)
}
key := "TestDisabledTable"
@tsuna
tsuna / clean_cache.sh
Created March 3, 2014 19:05
Shell script to automatically clean TSD's cache directory from a cron job
#!/bin/bash
CACHE_DIR=/tmp/tsd
diskSpaceIsShort() {
df -h "$CACHE_DIR" \
| awk 'NR==2{pct=$5; sub(/%/, "", pct); if (pct < 90) exit 1; exit 0;}'
}
if diskSpaceIsShort; then
@tsuna
tsuna / uidbench.java
Created May 30, 2013 21:31
Benchmark to measure the performance improvement of lock-less UID assignment in OpenTSDB
import org.slf4j.Logger;
import net.opentsdb.uid.UniqueId;
import org.hbase.async.HBaseClient;
final class uidbench {
private static void log(final String msg) {
System.out.println("[" + Thread.currentThread().getName() + "] " + msg);
}
@tsuna
tsuna / ComplexAsyncScanLoopDemo.java
Created May 16, 2013 22:03
Complex async scanning and processing with asynchbase
// This code is untested, may not even compile, but illustrates the idea.
class ComplexAsyncScanLoopDemo {
public Deferred<Object> scanAndProcess(final String start, final String stop) {
// This is the Deferred that the caller will wait on until everything
// we're doing has completed. If there was an object we wanted to return
// asynchronously to them as a result of whatever we're doing, we'd hand
// it to this Deferred once we're done.
final Deferred<Object> result = new Deferred<Object>();