Skip to content

Instantly share code, notes, and snippets.

View lestrrat's full-sized avatar

lestrrat lestrrat

View GitHub Profile
@lestrrat
lestrrat / gist:9926190
Created April 2, 2014 01:08
P5-Xslate vs Go-Xslate as of April 2, 2014, commit 15d8ca69d3ecc8a46bf50e422d31d2f204415755
following shows that the Go version is MUCH faster parsing the templates, but the VM is slower.
see https://github.com/lestrrat/go-xslate/tree/master/bench
$ perl driver.pl
# p5-xslate (cache DISABLED)
iter (10)
* Elapsed: 0.05115 seconds
* Iter per sec: 195.503421309873 iter/sec
iter (100)
* Elapsed: 0.188323 seconds
@lestrrat
lestrrat / mecab.go
Created March 10, 2014 05:00
俺俺 golang mecabバインディング(mecabで日本語をトークナイズするためのミニマルなヤツ)
package tokenizer
/*
#cgo CFLAGS: XXX CHANGE ME XXX
#cfo LDFALGS: XXX CHANGE ME XXX
#include <mecab.h>
struct mecab_t {}
*/
import "C"
import "errors"
@lestrrat
lestrrat / gist:9104980
Last active August 3, 2017 21:55
ヘビメタ英語を日常で使う風景
use strict;
use feature 'say';
use CGI;
main() unless caller();
sub main {
local $ENV{REQUEST_METHOD} = "GET";
qstring_is_not_empty();
qstring_is_empty();
[submodule "modules/stf"]
url = git://github.com/stf-storage/stf.git
[submodule "modules/stf-ircbot"]
url = git://github.com/stf-storage/stf-ircbot.git
@lestrrat
lestrrat / perl-go-stf-benchmark.md
Created December 10, 2013 04:55
Simple benchmark against STF Distribute Object Storage written in Perl and in Go

STF Distribute Object Storage (perl vs go)

This is a VERY limited benchmark. Take with a grain of salt. (go-stf-server)[https://github.com/stf-storage/go-stf-server] is still in half baked state, but can connect to the same database as the more mature (perl version)[https://github.com/stf-storage/stf], and handle GET requests.

And since the go version is still half-baked, this benchmark is for GET only.

Basic benchmark strategy

The original STF dispatcher PSGI application is running behind nginx reverse proxy on the same host, which handles the reproxying via X-Reproxy-URL. In this benchmark, I'm just sending GET requests directly to port 5000 (PSGI), and port 8080 (go) on the localhost via ab:

@lestrrat
lestrrat / gist:7557452
Created November 20, 2013 03:55
Proposal for new Xslate Loader
package Text::Xslate::Loader::File;
use Mouse;
use Data::MessagePack;
use File::Spec;
use File::Temp ();
use Log::Minimal;
use constant ST_MTIME => 9;
use Text::Xslate::Util ();
@lestrrat
lestrrat / MurmurHash (obsolete, version1)
Created November 13, 2013 00:35
I needed this for backcompat.
func murmurHash (data []byte) uint32 {
const m uint32 = 0x5bd1e995
const r uint8 = 16
var length uint32 = uint32(len(data))
var h uint32 = length * m
nblocks := int(length / 4)
buf := bytes.NewBuffer(data)
for i := 0; i < nblocks; i++ {
var x uint32
if (foo) {
fprintf(stderr, "Hello!\n");
} else
{
fprintf(stderr, "Bite me!\n");
}
@lestrrat
lestrrat / gist:7260649
Created November 1, 2013 03:37
Practicing go. Enqueues all objects in STF storage (https://github.com/stf/stf-storage) to RepairObject queue, w/o disrupting services
package main
import (
"database/sql"
"fmt"
"log"
"math"
"math/rand"
"time"
"runtime"
_ "github.com/go-sql-driver/mysql"