Skip to content

Instantly share code, notes, and snippets.

View hideo55's full-sized avatar

Hideaki Ohno hideo55

View GitHub Profile
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 / 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) {
 ...
@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'
#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 / 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
package mro;
package MRO::Compat;
use strict;
use warnings;
require 5.006_000;
our $VERSION = '0.11';
BEGIN {
package Android::FixupUTF8;
sub fixup {
package Android;
no warnings 'redefine';
*do_rpc = sub {
my $self = shift;
if ( $self->trace ) {
show_trace(qq[do_rpc: $self: @_]);
}
@hideo55
hideo55 / dotcloud_mysql.pl
Created May 14, 2011 14:19
Login to MySQL shell on DotCloud
#!/usr/bin/env perl -w
use strict;
use IPC::Cmd qw/run/;
use IPC::System::Simple qw(systemx);
die "You must provide deploy name as argument" unless scalar(@ARGV) > 0;
my $deploy_name = $ARGV[0];
my ($ok, $err, undef, $stdout) = run(
/*
PC Emulator
Copyright (c) 2011 Fabrice Bellard
Redistribution or commercial use is prohibited without the author's
permission.
*/
"use strict";
var aa;
var ba = [1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1,
0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0,
@hideo55
hideo55 / tcpdump.pl
Created May 19, 2011 17:10
tcpdump like implementation of Perl
#!/usr/bin/env perl -w
use strict;
use Net::Frame::Dump::Online2;
use Net::Frame::Simple;
my $d = Net::Frame::Dump::Online2->new( dev => 'en1', );
$d->start;
while (1) {