Skip to content

Instantly share code, notes, and snippets.

#!/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?
// -*- 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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int allocs_count = 16384;
int alloc_min = 1024 * 1024;
int alloc_max = 1024 * 1024 * 128;
@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. */
@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>
#!/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 / 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)
@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 ".*?"))))
"@"))
var AmbTest = TestCase("AmbTest");
AmbTest.prototype.testBasic = function () {
function beats(ix, iy, jx, jy) {
return ix == jx || Math.abs(ix-jx) == jy-iy;
}
var result = ambRun(function (amb, fail) {
var queenPos = [];
for (var i = 0; i < 8; i++) {
var lastPos = amb([0,1,2,3,4,5,6,7]);
#include <stdint.h>
struct KindaAtomic64 {
union data_type {
volatile uint64_t u64;
#ifndef WORDS_BIGENDIAN
struct {
volatile uint32_t low;
volatile uint32_t high;
} u32;