Skip to content

Instantly share code, notes, and snippets.

@banthar
banthar / stack_trace.c
Created November 7, 2011 01:41
stacktrace with libunwind and elfutils
// stack_trace.c
//
// gcc stack_trace.c -ldw -lunwind -g -o stack_trace
#define UNW_LOCAL_ONLY
#include <elfutils/libdwfl.h>
#include <libunwind.h>
#include <stdio.h>
@banthar
banthar / Split.java
Created June 13, 2012 10:33
java split benchmark
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Split {
private static String string = "a/b/c/d/e/f/g/h/i/j/asd/asdas/dasdjasodjoa/sjd/oajs/djoasjd/as/odj/jaowdj/oajw/odj/aojwd/oja/owjd/oja/wjdoja/wdj/awjdojaw/odj/oawjd/oja/wjdoawjdojaw/d/dff";
@banthar
banthar / xkcd_hell.user.js
Created June 14, 2010 18:30
hell tetris
// ==UserScript==
// @name XKCD Hell playable game
// @namespace http://example.com/
// @description Turns XKCD comic #724 into playable game
// @include http://xkcd.com/724/
// @version 1.0
// ==/UserScript==
/*
* Physaxe (http://code.google.com/p/physaxe/) copyright notice:
@banthar
banthar / curses_test.c
Created December 5, 2011 00:04
curses demo
#include <stdio.h>
#include <curses.h>
int main(int argc, char*argv[])
{
initscr();
printw("curses - press any key");
getch();
endwin();
public class Test {
static int a;
public static boolean f(int b) {
while(true) {
if( a==3 ) {
return true;
}
try {
<html>
<head>
<script>
function put(data, callback) {
request("PUT", "https://api.myjson.com/bins/4wq17", JSON.stringify(data), callback)
}
function get(callback) {
request("GET", "https://api.myjson.com/bins/4wq17", null, callback)
}
function request(method, url, data, callback) {
@banthar
banthar / browser.py
Last active December 31, 2015 18:59
#!/usr/bin/python
import gtk, webkit, sys, time, gobject
class Browser:
def __init__(self, window, url):
self.window = window
self.view = (webkit.WebView(), webkit.WebView())
self.url = url
@banthar
banthar / R.java
Created September 22, 2013 08:22
import java.util.Random;
public class R {
private static long doRead(final Random r, final long rangeStart,
final long rangeEnd) {
long retVal = 0;
final long range = rangeEnd - rangeStart;
// Fill until we get to range
@banthar
banthar / go-gl.patch
Created September 11, 2013 17:36
golang + OSMesa
diff --git a/gl.go b/gl.go
index 89581f3..8ba19cb 100644
--- a/gl.go
+++ b/gl.go
@@ -4,13 +4,8 @@
package gl
-// #cgo darwin LDFLAGS: -framework OpenGL -lGLEW
-// #cgo windows LDFLAGS: -lglew32 -lopengl32
// stack_trace.c
//
// gcc stack_trace.c -ldw -lunwind -g -o stack_trace
#define UNW_LOCAL_ONLY
#include <elfutils/libdwfl.h>
#include <libunwind.h>
#include<signal.h>