Skip to content

Instantly share code, notes, and snippets.

View tsuna's full-sized avatar

Benoit Sigoure tsuna

View GitHub Profile
@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 / 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 / mapredrpc.py
Created April 23, 2013 07:55
Simple example of how to send a Hadoop RPC to the JobTracker from pure-Python code
#!/usr/bin/python
import socket
import struct
from protobuf import IpcConnectionContext_pb2 as IpcConnectionContext
from protobuf import RpcPayloadHeader_pb2 as RpcPayloadHeader
# --- Connection header ---
# Client.writeConnectionHeader()
preamble = (
@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 / server.py
Created January 5, 2012 01:44
A simple example of a threaded TCP server in Python.
#!/usr/bin/python
# A simple example of a threaded TCP server in Python.
#
# Copyright (c) 2012 Benoit Sigoure All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright notice,
@tsuna
tsuna / count_hbase.sh
Created November 17, 2011 18:42
Script to get stats on the number of KeyValue and size of an HBase table, directly from HFiles
#!/bin/bash
# Copyright (c) 2010, 2011 Benoit Sigoure. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
@tsuna
tsuna / mysqlpool.scala
Created March 30, 2012 00:15
MySQL JDBC connection pool for Scala + Finagle
// Copyright (C) 2012 Benoit Sigoure
// Copyright (C) 2012 StumbleUpon, Inc.
// This library is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version. This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
// General Public License for more details. You should have received a copy
// of the GNU Lesser General Public License along with this program. If not,
@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 / 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>();