Skip to content

Instantly share code, notes, and snippets.

View hideo55's full-sized avatar

Hideaki Ohno hideo55

View GitHub Profile
@hideo55
hideo55 / bench.txt
Created June 26, 2015 05:52
bit vector benchmark
MIN_NUM_BITS: 1024
MAX_NUM_BITS: 1073741824
NUM_TRIALS: 11
NUM_QUERIES: 1048576
ONES_RATIO: 0.5
#bits hsds(get) hsds(rank) hsds(select) hsds_f(get) hsds_f(rank) hsds_f(select)
1024 0.00244131 0.0132391 0.0261678 0.00247951 0.0132627 0.0327091
2048 0.00253885 0.0134974 0.0286714 0.00242721 0.013378 0.0313551
4096 0.00243108 0.01322 0.0307464 0.002447 0.0132657 0.0299397
8192 0.00264367 0.0146645 0.0412597 0.00242221 0.0132331 0.0316086
#include <cstdio>
void hexDump(const void *buf, int size)
{
int i,j;
unsigned char *p = (unsigned char *)buf, tmp[20];
printf("+0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F| -- ASCII --\r\n");
printf("--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+----------------\r\n");
for (i=0; p-(unsigned char *)buf<size; i++) {
for (j=0; j<16; j++) {
@hideo55
hideo55 / gist:f7c7364b972d8aec63b9
Last active August 29, 2015 14:01
Enumerate multiple of 3 in one-liner(69byte).
perl -e 'sprintf("%b",$_)=~/^(0|1(01*0)*1)+$/&&print$_,$/for 0..1e2'
@hideo55
hideo55 / cursor.md
Created May 6, 2014 12:50
[Note] node-unqlite Cursor API

#Cursor API

Iteration

var db = new unqlite.Database('/path/to/db');
db.open(function(){
  var cursor = db.cursor();
  for(cursor.first(); cursor.isValid(); cursor.next()){
    cursor.getKeyValue(function(err, key, value) {
 ...
use Test::More;
use Config;
use File::Spec::Functions qw(catdir catfile rel2abs);
use File::Path;
use File::Temp qw(tempdir);
use File::Copy::Recursive 'dircopy';
use Cwd::Guard qw(cwd_guard);
use Capture::Tiny qw(capture);
my $perl = $Config{perlpath};
@hideo55
hideo55 / digest_pp
Created June 17, 2013 05:55
Benchmark test of pure perl Digest::* implementation.
Rate sha md5 murmur3
sha 808/s -- -92% -92%
md5 10000/s 1138% -- -2%
murmur3 10204/s 1163% 2% --
@hideo55
hideo55 / FindSSE.cmake
Created May 24, 2013 11:35
CMake module that detect SSE support
# Check if SSE instructions are available on the machine where
# the project is compiled.
MACRO (FindSSE)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO)
STRING(REGEX REPLACE "^.*(sse2).*$" "¥¥1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "sse2" "${SSE_THERE}" SSE2_TRUE)
/* NO-OP for little-endian platforms */
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define BYTESWAP(x) (x)
# endif
/* if __BYTE_ORDER__ is not predefined (like FreeBSD), use arch */
#elif defined(__i386) || defined(__x86_64) \
|| defined(__alpha) || defined(__vax)
# define BYTESWAP(x) (x)
@hideo55
hideo55 / metacpan_fav.pl
Last active December 14, 2015 15:09
metacpan fav search
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use JSON;
use Furl;
use constant {
METACPAN_URL => 'http://api.metacpan.org',
API_FAV => '/v0/favorite/_search?q=distribution:',
API_USER => '/v0/author/_search?q=user:',
@hideo55
hideo55 / metacpan_fav.md
Last active December 14, 2015 15:08
metacpanで++er逆引き