Skip to content

Instantly share code, notes, and snippets.

@fujiwara
fujiwara / trapper.go
Created December 12, 2014 06:50
An example for your zabbix trapper daemon.
package main
import (
"log"
"github.com/fujiwara/go-zabbix-get/zabbix"
)
func main() {
err := zabbix.RunTrapperServer(
@fujiwara
fujiwara / bench.go
Created January 6, 2015 07:26
toInt64 bench
package fluent_test
import (
"reflect"
"testing"
)
var testNumbers = []interface{}{
int(10),
uint(10),
@fujiwara
fujiwara / build.txt
Last active August 29, 2015 14:13
go-bindata backend file server
$ go-bindata -prefix=public public/...
$ go build
package mapbench_test
import "testing"
var N = 1000000
func BenchmarkMap(b *testing.B) {
for i := 0; i < b.N; i++ {
m := map[int]int{}
for j := 0; j < N; j++ {
@fujiwara
fujiwara / multitail-consul
Created May 18, 2015 01:58
multitail-consul
#!/bin/bash
set -e
node="$1"
cmd="$2"
nodes=$(consul members -status alive | awk "/$node/{ print \$1 }")
args=()
for n in $nodes
@fujiwara
fujiwara / multitail-consul
Created May 20, 2015 07:47
multitail-consul
#!/usr/bin/perl
use strict;
use warnings;
my $regex = shift;
my $cmd = quotemeta(shift);
my @nodes = `consul members -status alive`;
shift @nodes; # dispose header
@nodes = grep /$regex/, map { (split /\s+/, $_)[0] } @nodes;
package main
import (
"flag"
"fmt"
)
type strslice []string
func (s *strslice) String() string {
@fujiwara
fujiwara / nssh.go
Last active August 29, 2015 14:26
nssh
package main
import (
"bufio"
"flag"
"fmt"
"io"
"os"
"os/exec"
"sync"
MATCH FAILED
input: [[% USE LinkTo -%]\n[% args = {\n href => '/link/to?foo=bar',\n hoge => 'huga',\n in => 'put',\n} -%]\n[% LinkTo.link_to('link_text', args) %]\n]
expect: [<a href="/link/to?foo=bar&amp;in=put&amp;hoge=huga">link_text</a>]
output: [<a href="/link/to?foo=bar&amp;hoge=huga&amp;in=put">link_text</a>]
FAILED 13: - template text 5 did not match expected
not ok 13 - template text 5 did not match expected
--- browser.xul.orig 2009-05-08 23:29:02.000000000 +0900
+++ browser.xul 2009-05-10 11:05:38.000000000 +0900
@@ -1,26 +1,26 @@
<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popup id="contentAreaContextMenu">
+ <menuseparator insertafter="placesMenu" />
<menuitem
class="menuitem-iconic"
- insertbefore="context-bookmarklink"