Skip to content

Instantly share code, notes, and snippets.

int main()
{
__asm__(";foo");
char a[1024] = {0,};
__asm__(";end");
/*
# 4 "x.c" 1
;foo
# 0 "" 2
leal 12(%esp), %ebx
@t3rmin4t0r
t3rmin4t0r / zend-open-files.txt
Created October 30, 2010 19:15
Zend CG(open_files)
Culprit - zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
====================PHP 5.1====================
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
{
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
}
...
pthread_ulock_t *apc_pthreadulock_create(pthread_ulock_t *lock TSRMLS_DC)
{
int result;
pthread_rwlockattr_t* attr;
attr = malloc(sizeof(pthread_rwlockattr_t));
pthread_mutexattr_t* mutex_attr;
mutex_attr = malloc(sizeof(pthread_mutexattr_t));
result = pthread_rwlockattr_init(attr);
@t3rmin4t0r
t3rmin4t0r / Makefile
Created October 4, 2012 18:07
Test MMAP buffers in Java
JAVA=java
JAVA_ARGS=-server -Xmx2048m
all:
javac *.java
rm result large.txt;
for size in 8 16 64 256 512 1024 1500 2000; do \
$(JAVA) $(JAVA_ARGS) TestBuffers mapped $$size | tee -a result; \
$(JAVA) $(JAVA_ARGS) TestBuffers direct $$size | tee -a result; \
@t3rmin4t0r
t3rmin4t0r / gen-rsa.py
Created June 9, 2013 19:56
RSA PEM simplified example
from Crypto.PublicKey import RSA
def genKey(bits=1024):
key = RSA.generate(2048)
f = open('rsa1024.pem','w')
f.write(key.exportKey('PEM'))
f.close()
return "rsa1024.pem"
pem = genKey(512)
@t3rmin4t0r
t3rmin4t0r / pull-logs.sh
Created June 10, 2013 16:58
hadoop pull-logs script
#!/bin/bash
for JOBID in $*; do
ATTEMPTS=$(mapred job -list-attempt-ids $JOBID MAP completed; mapred job -list-attempt-ids $JOBID REDUCE completed)
mkdir -p $JOBID
echo $ATTEMPTS | xargs -P 32 -n 1 bash -c "mapred job -logs $JOBID \$0 > $JOBID/\$0.log" 2> /dev/null
done
@t3rmin4t0r
t3rmin4t0r / saddest-story-never-written.md
Created June 10, 2013 17:44
For sale. Baby shoes. Never worn.

The shoes mocked me as they sit on the mantle-piece. They were pink. Girls like pink, don't they. Or so they're told, I guess. I would've called mine Gladys. She would've played with guns and cars, if I had any say in it. Unless she wanted dolls, but it's hard to tell if what they really want is what the girl next door has.

@t3rmin4t0r
t3rmin4t0r / fatjar.sh
Created July 26, 2013 18:45
fat jar creation script. hadoop classpath | ./fatjar.sh hadoop-fat.jar
#!/bin/bash
jso_file=$1
read classpath
TMPDIR=$(mktemp -d -t classes-XXXXXX)
#echo jso: $jso_file
#echo classpath: $classpath
@t3rmin4t0r
t3rmin4t0r / hdfs2-example.go
Last active December 24, 2015 06:19
HDFS2 go reader/writer example
package main
/*
To build, you need the following magic & an HDP2 install
export CGO_CFLAGS="-I/usr/include/ -I$HADOOP_HOME/include"
export CGO_LDFLAGS="-L $HADOOP_HOME/lib/native -L $JAVA_HOME/jre/lib/amd64/server/"
Then just
@t3rmin4t0r
t3rmin4t0r / startrails.py
Created October 14, 2013 03:56
gimp star-trails layer stacker
import math
from gimpfu import *
import sys, os, math
def do_stack_propogate(image,drawable,apply_mask=False):
top = image.active_layer
found = False
n = len(image.layers)
i = 0