Skip to content

Instantly share code, notes, and snippets.

@alk
alk / gist:952958
Created May 3, 2011 07:38
Emacs lisp snippets for setting up distel and erlang remote shell for membase
;; https://github.com/alk/elisp-regex-dsl
(require 'regex-dsl)
;;; http://cvs.savannah.gnu.org/viewvc/*checkout*/emacs/lisp/json.el?root=emacs
(require 'json)
(setq *alk-membase-default-host* "Administrator:asdasd@lh:9000")
(setq *alk-membase-host-split-re* (redsl-to-regexp '(concat (line-begin)
(\? (concat (cap-group (literal ".*?"))
(\? (concat ":" (cap-group (literal ".*?"))))
"@"))
@alk
alk / gist:1148755
Created August 16, 2011 09:57
grab tcmalloc stats into /tmp/malloc-stats
set $mem = malloc(1048576)
p $mem
set language c++
call MallocExtension::instance()->GetStats($mem, 1048575)
set $fd = open("/tmp/malloc-stats", 512 + 64 + 1, 0644)
call write($fd, $mem, memchr($mem, 0, 1048575) - $mem)
call close($fd)
call free($mem)
#!/usr/bin/env ruby
require 'rubygems'
require 'restclient'
require 'nokogiri'
require 'active_support/core_ext'
require 'uri/http'
def get!(url)
RestClient::Request.execute(:method => :get, :url => url)
@alk
alk / test_fua.c
Created February 25, 2013 18:46
playing with FUA via linux's scsi-generic API: http://www.tldp.org/HOWTO/SCSI-Generic-HOWTO/
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@alk
alk / hle_test.c
Created September 21, 2013 23:20
tsx test
#include <stdlib.h>
#include <stdio.h>
/* note: much of tsx code was stolen from glibc */
/* Official RTM intrinsics interface matching gcc/icc, but works
on older gcc compatible compilers and binutils.
We should somehow detect if the compiler supports it, because
it may be able to generate slightly better code. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int allocs_count = 16384;
int alloc_min = 1024 * 1024;
int alloc_max = 1024 * 1024 * 128;
// -*- mode: C++; indent-tabs-mode: t; c-basic-offset: 8 -*-
//
// -- running on self-built 52
// # ./collation_test
// running memcmp("00000001", "00000023"): 5.6 ns
// running icu_cs("00000001", "00000023"): 508 ns
// running icu_d("00000001", "00000023"): 78.3 ns
// running icu_du("00000001", "00000023"): 94.5 ns
// running memcmp("00000001", "00300023"): 6.2 ns
// running icu_cs("00000001", "00300023"): 260 ns
#!/usr/bin/ruby
files = Dir["**/*.h"] + Dir["**/*.cc"] + Dir["**/*.hh"]
lic = {}
files.each do |fn|
# puts "fn: #{fn.inspect}"
lines = IO.readlines(fn)
if lines.empty?
@alk
alk / alk-malloc-test.c
Created June 21, 2014 21:43
alk-malloc-test
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <assert.h>
#define HISTORY_SIZE (1024*1024)
#define CHUNK_MIN (2*1024*1024)
#define CHUNK_MAX (32*1024*1024)
@alk
alk / maps-balancedness.rb
Last active February 22, 2016 11:40
maps-balancedness.rb
#!/usr/bin/ruby
# coding: utf-8
require 'json'
require 'pp'
require 'optparse'
require 'rubygems'
require 'restclient'