Skip to content

Instantly share code, notes, and snippets.

View tsuna's full-sized avatar

Benoit Sigoure tsuna

View GitHub Profile
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;
public class t {
static public void main(String[] args) {
HashMap<String, Integer> hm = new HashMap<String, Integer>();
hm.put("answer", 42);
@tsuna
tsuna / 0001-Don-t-shutdown-while-RPCs-are-waiting-for-a-ROOT-loo.patch
Created November 22, 2010 05:17
Netty getting stuck in an infinite loop during shutdown
From 07d1425781f08799ff9ef59f9cd578fa63a2e83f Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <[email protected]>
Date: Sun, 21 Nov 2010 20:42:20 -0800
Subject: [PATCH] Don't shutdown while RPCs are waiting for a -ROOT- lookup.
The following scenario led to data loss:
1. Application starts.
2. A PutRequest is generated, triggers a -ROOT- lookup.
3. Application calls shutdown() on the HBaseClient, the client
terminates and the PutRequest is lost.
@tsuna
tsuna / 0001-Add-support-for-CDHb3.patch
Created January 18, 2011 08:28
Add support for CDHb3 in asynchbase.
From fd1d76efba48269aaec80e90f629f01ba4581fed Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <[email protected]>
Date: Tue, 18 Jan 2011 00:21:20 -0800
Subject: [PATCH] Add support for CDHb3.
This change adds support for CDHb3. In order to enable the new code,
the JVM must be given the following system property in argument:
-Dorg.hbase.async.cdhb3
CDHb3 includes a temporary patch that changes the format of the "hello"
@tsuna
tsuna / 0001-Add-support-for-HBase-0.90.patch
Created January 28, 2011 01:36
Add support for HBase 0.90 in asynchbase.
From 7a538914c93f8a92b9c80e5c533e73d97e8423c8 Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <[email protected]>
Date: Thu, 27 Jan 2011 17:33:37 -0800
Subject: [PATCH] Add support for HBase 0.90.
In order to enable the new code, the JVM must be given the following
system property in argument:
-Dorg.hbase.async.v0.90
For HBASE-3174, revision r1029115 (or 08e64aae in Git) changed the
@tsuna
tsuna / tsdq.py
Created February 27, 2011 09:29
Quick script to run a couple queries against a TSD and time it
#!/usr/bin/python
import httplib
import json
import os
import shutil
import time
def purge_tsd_cache():
for dir in (dir for dir in os.listdir("/tmp/tsd") if dir[0] != "."):
@tsuna
tsuna / gist:1119725
Created August 2, 2011 07:07
TSDB query start time underflow
diff --git a/src/core/TsdbQuery.java b/src/core/TsdbQuery.java
index 2edd53c..8776e89 100644
--- a/src/core/TsdbQuery.java
+++ b/src/core/TsdbQuery.java
@@ -401,7 +401,8 @@ final class TsdbQuery implements Query {
// but this doesn't really matter.
// Additionally, in case our sample_interval is large, we need to look
// even further before/after, so use that too.
- return getStartTime() - Const.MAX_TIMESPAN * 2 - sample_interval;
+ final long t = getStartTime() - Const.MAX_TIMESPAN * 2 - sample_interval;
@tsuna
tsuna / memcachemon.py
Created August 10, 2011 06:43
Memcache collector for tcollector
#!/usr/bin/env python
import socket
import subprocess
import sys
import time
COLLECTION_INTERVAL = 15 # seconds
@tsuna
tsuna / nagiosirc.pl
Created August 10, 2011 22:38
Handy little bot to get Nagios notifications on IRC
#!/usr/bin/perl -w
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
@tsuna
tsuna / re2-bitstate.s
Created September 24, 2011 08:23
RE2's BitState::ShouldVisit disassembled manually
/*./re2/prog.h:100*/ 0x0000000000411f0b <+523>: mov 0x50(%rbx),%rdi # rdi = visited_
/*./re2/prog.h:100*/ 0x0000000000411f0f <+527>: add $0x1,%edx # edx = text_.size() + 1
/*re2/bitstate.cc:97*/ 0x0000000000411f12 <+530>: imul %esi,%edx # esi = id, edx = id * (text_.size() + 1)
/*re2/bitstate.cc:97*/ 0x0000000000411f15 <+533>: add %r14d,%edx # r14d = p, edx = id * (text_.size() + 1) + p
/*re2/bitstate.cc:97*/ 0x0000000000411f18 <+536>: sub %eax,%edx # eax = text_.begin(), edx = n
/*re2/bitstate.cc:98*/ 0x0000000000411f1a <+538>: mov %edx,%eax # eax = n
/*re2/bitstate.cc:98*/ 0x0000000000411f1c <+540>: mov %edx,%ecx # ecx = n
/*re2/bitstate.cc:98*/ 0x0000000000411f1e <+542>: shr $0x5,%eax # eax = n >> 5 = n / VisitedBits
/*re2/bitstate.cc:98*/ 0x0000000000411f21 <+545>: and $0x1f,%ecx # ecx = n & (VisitedBits - 1)
/*re2/bitstate.cc:98*/ 0x0000000000411f24 <+548>: mov
@tsuna
tsuna / ztc.py
Created September 30, 2011 21:22
Template for a simple HTTP server for Zero Touch Provisioning with Arista switches
#!/usr/bin/python
# Copyright (c) 2011 StumbleUpon, Inc. 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.