Skip to content

Instantly share code, notes, and snippets.

typedef int (* cmpfn)(const void *a, const void *b);
/* interface */
void quicksort(void *pbase, size_t start, size_t end, size_t size,
cmpfn compare);
/* implementation */
void __insertion_sort(void *pbase, char *start, char *end, size_t size,
cmpfn compare)
@soap-DEIM
soap-DEIM / clear bit m to n
Created October 28, 2013 15:29
clear bit m to n
#define CLRBIT(x, m, n) ({ \
unsigned long __mask = ~0U; \
__mask &= ~0U << (n); \
__mask |= ~0U >> (sizeof(unsigned long) * 8 - (m)); \
(x) &= __mask; \
})
/*
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
____/'---'\____
.' \\| |// '.
/ \\||| : |||// \
@soap-DEIM
soap-DEIM / regex.py
Last active December 30, 2015 03:09
import re
re.findall(r"(?<=[\[])[^\[^\]]*(?=[\]])", "xxx[0xdeadbeef]yyy[aa]a")
# ['0xdeadbeef', 'aa']
re.findall(r"(?<=[\[])[^\[^\]]*(?=[\]])", "xxx[0xdeadbeef][aa]a")
# ['0xdeadbeef', 'aa']
@soap-DEIM
soap-DEIM / subtitle_checker.py
Last active December 30, 2015 06:39
A simple script for checking subtitle update from YYETS
import re
import urllib
from HTMLParser import HTMLParser
# configure area
# set search keyword and format
keyword_list = ['blacklist', 'Marvels Agents of S.H.I.E.L.D.']
fmt_list = ['WEB-DL', '720P', '1080P']
import re
import urllib
from HTMLParser import HTMLParser
# configure area
# set search keyword and format
# { 'name' : [episode_list] }
keyword_list = {'blacklist':[8], 'Marvels Agents of S.H.I.E.L.D.':[6]}
# fmt should be one of following: "MP4","WEB-DL","HDTV","1080P","720P"
--- lcd-omap3.c.original 2011-10-12 09:37:09.499884033 +0200
+++ lcd-omap3.c 2011-10-13 12:34:58.367997951 +0200
@@ -334,6 +334,124 @@
static void configure_dss_beagleboard(l4_addr_t frame_buffer)
{
+ /* begin extra dss init patch */
+
+ // NOTICE:
+ // This patch has been tested only on revision C4 boards,
/* --(.'w'.)-( .'w')-( )-( )-('w'. )-(.'w'.)-( .'w')-( )-( )-('w'. )-(.'w'.)-- */
extern "C" void _exit(int code) __attribute__ ((__noreturn__, __weak__));
void _exit(int code)
{
L4Re::Env const *e;
if (l4re_global_env && (e = L4Re::Env::env()) && e->parent().is_valid())
e->parent()->signal(0, code);
for (;;)
l4_ipc_sleep(L4_IPC_NEVER);
}
EXTERN_C void *pthread_fn(void *data)
{
Romain::App_thread *t = (Romain::App_thread*)data;
l4_cap_idx_t cap = (l4_cap_idx_t)pthread_getl4cap(pthread_self());
t->vcpu_cap(L4::Cap<L4::Thread>(cap));
/*
* Thread creation and config.
*/