Skip to content

Instantly share code, notes, and snippets.

View cubicdaiya's full-sized avatar

Tatsuhiko Kubo cubicdaiya

View GitHub Profile
#define PREFIX_FREE(p) \
do { \
free(p); \
(p) = NULL; \
} while(false)
function round(num)
return math.floor(num+.5)
end
def get_ext(ent):
root, ext = os.path.splitext(ent)
return ext
#!/bin/sh
find . | egrep '#$' | xargs rm
a = [ 1, 15, 2, 3, 3, 31, 34, 99 ];
a.sort();
try {
x = y;
} catch (e) {
console.log(e.message); // y is not defined
}
var memoizer = function (memo, fundamental) {
var shell = function (n) {
var result = memo[n];
if (typeof result !== 'number') {
result = fundamental(shell, n);
memo[n] = result;
}
return result;
};
int count_str (char *buf, const char *s, int len)
{
int c;
char *p;
c = 0;
p = buf;
while (p != NULL) {
p = strstr(p, s);
if (p != NULL) {
p += len;
#include <string.h>
/**
* The algorithm implemented here is based Boyer-Moore algorithm
*/
// following functions can process ascii character
void bm_create_table (char *pattern, int *skip)
{
def configure(conf, libs, headers, funcs):
if not conf.CheckCC():
print "c compiler is not installed!"
return False
for lib in libs:
if not conf.CheckLib(lib):
print "library " + lib + " not installed!"
return False