Skip to content

Instantly share code, notes, and snippets.

@5kg
5kg / c_printf.c
Last active December 20, 2015 09:39
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 500000; ++i) {
fprintf(stdout, "this is a test from error");
}
return 0;
}
/usr/include/dyninst:
ABI.h
Absloc.h
AbslocInterface.h
AddrLookup.h
AddrSpace.h
Aggregate.h
Annotatable.h
Archive.h
basetypes.h
spam_train, ham_train, spam_test, ham_test = ['train/spam', 'train/ham', 'test/spam', 'test/ham'].map{|t| Dir["#{ARGV[0]}/#{t}/*"].map {|fn| File.open(fn, 'r:iso8859-1').read.gsub(/[^a-zA-Z]/, ' ').split}}
spam_log, ham_log = [spam_train, ham_train].map{|t| t.flatten.instance_eval {reduce(Hash.new(0)) { |h,v| h[v] += 1.0/size; h }.select{|w, v| w.size > 2 && v > 8e-6}}.instance_eval{each {|k,v| self[k] = Math.log(v)}}}
spam_predict, ham_predict = [spam_test, ham_test].map {|t| t.map{|d| [spam_log, ham_log].map {|log| d.reduce(0){|s, w| log[w] ? s + log[w] : s}}}}
p spam_predict.size, spam_predict.select{|e| e.first < e.last}.size
p ham_predict.size, ham_predict.select{|e| e.first > e.last}.size
@5kg
5kg / deadlock
Last active December 17, 2015 11:49
(gdb) thread apply all bt full
Thread 3 (Thread 0xb5c0eb40 (LWP 956)):
#0 0xb76fc424 in __kernel_vsyscall ()
No symbol table info available.
#1 0xb6553a35 in __libc_wait (stat_loc=stat_loc@entry=0xb5c0da7c) at ../sysdeps/unix/sysv/linux/wait.c:36
resultvar = <optimized out>
oldtype = -512
#2 0xb643d706 in get_wait_shm (mmap_size=4096, sock_info=0xb646d3e0 <local_apps>) at lttng-ust-comm.c:709
status = 0
all: dyntp.so mutator mutatee
dyntp.so: dyntp.o
gcc -shared -fPIC -DPIC $^ -ldl -llttng-ust -O2 -o $@
dyntp.o: dyntp.c ust_test.h
gcc -I. -fno-strict-aliasing -Wall -g -O2 -c $< -fPIC -DPIC -o $@
mutator: mutator.o
g++ $^ -L/usr/lib/dyninst -ldyninstAPI -o $@
# Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
# OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
#
# Permission is hereby granted to use or copy this program for any
# purpose, provided the above notices are retained on all copies.
# Permission to modify the code and to distribute modified code is
# granted, provided the above notices are retained, and a notice that
# the code was modified is included with the above copyright notice.
@5kg
5kg / Makefile
Last active December 16, 2015 14:49
all: mutator mutatee
mutator: mutator.o
g++ mutator.o -L/usr/lib/dyninst -ldyninstAPI -o mutator
mutatee: mutatee.o
gcc mutatee.o -std=gnu99 -g -o mutatee -lrt
mutatee.o: mutatee.c
gcc mutatee.c -std=gnu99 -g -c -o mutatee.o
In file included from ../../include/lttng/tracepoint-event.h:62:0,
from ust_tests_hello.h:64,
from tp.cpp:26:
../../include/lttng/ust-events.h:93:6: error: expected primary-expression before ‘.’ token
.u.basic.integer = \
^
../../include/lttng/ust-tracepoint-event.h:194:3: note: in definition of macro ‘TRACEPOINT_EVENT_CLASS’
_fields \
^
../../include/lttng/ust-tracepoint-event.h:53:5: note: in expansion of macro ‘_TP_PARAMS’
@5kg
5kg / jhwhw.cls
Created April 6, 2013 13:15 — forked from jhwilson/jhwhw.cls
%=====================================================================
% jhwhw.cls
% Provide jhwhw.cls class
%=====================================================================
%=====================================================================
% Identification
%=====================================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{jhwhw}[2009/02/11 Justin Wilson's Homework Class]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 65536
#define T 10000
#define SIZE 63
struct {
char s[SIZE];