Skip to content

Instantly share code, notes, and snippets.

View blackball's full-sized avatar
🎯
Focusing

Hui blackball

🎯
Focusing
View GitHub Profile
// hooks for future customizing
typedef int (db_log_fnc)(const char *fmt, ... );
typedef void* (db_malloc_fnc)(size_t sz);
typedef void* (db_realloc_fnc)(void *ptr, size_t sz);
typedef void (db_free_fnc)(void *ptr);
typedef void (db_exit_fnc)(int status);
struct _db_hook
{
db_log_fnc *log;
@blackball
blackball / clips.c
Created November 8, 2011 05:17
demo codes to test Gist
// hooks for future customizing
typedef int (db_log_fnc)(const char *fmt, ... );
typedef void* (db_malloc_fnc)(size_t sz);
typedef void* (db_realloc_fnc)(void *ptr, size_t sz);
typedef void (db_free_fnc)(void *ptr);
typedef void (db_exit_fnc)(int status);
struct _db_hook
{
db_log_fnc *log;
@blackball
blackball / clips.c
Created November 8, 2011 05:19
test Gist
// hooks for future customizing
typedef int (db_log_fnc)(const char *fmt, ... );
typedef void* (db_malloc_fnc)(size_t sz);
typedef void* (db_realloc_fnc)(void *ptr, size_t sz);
typedef void (db_free_fnc)(void *ptr);
typedef void (db_exit_fnc)(int status);
struct _db_hook
{
db_log_fnc *log;
void pack_double(struct db *database, double d[], int n)
{
int len = sizeof(double) * n;
struct db_node *node = new_node(len);
memcpy(node->data, d, len);
dump(database, node);
}
int unpack_double(struct db *database, double d[], int n, int idx)
{
int pack_arr(struct db *dbase, void *data, int len)
{
int code = -1;
struct db_node *node = new_node(len);
memcpy(node->data, data, len);
// insert node into dbase
dump(dbase, node);
code = 0;
//----------.h file ------------
#ifndef MYVIDEOWIDGET_H
#define MYVIDEOWIDGET_H
#include <QtOpenGL/QtOpenGL>
#include <QtGui/QImage>
class MyVideoWidget : public QGLWidget
{
Q_OBJECT
@blackball
blackball / demo.py
Created December 6, 2011 09:04
subprocess
#!/usr/bin/python
"""
Simulate a command pipe in windows.
reason: I always need to do batch processing
in my dailylife, rename a bunch of files,
generate some sets from it, and move files
into different folders. Or, I have a module,
and I need to processing lots of file, but,
this module can only process one at most, and I
@blackball
blackball / example.c
Created January 4, 2012 04:37
example for vpack
#include "vpack.h"
#include <stdio.h>
struct Model
{
char c;
int pts[4];
float vec[1024];
};
/* Simple linked-list demo */
typedef struct node{
void *data;
struct node *next;
struct node *prev;
} node;
node* create(node **ns, void *data);
node* search(node **ns, void *data);
/**
* Binary search tree, a C implementation.
*
* I hope it could be a bit more efficient ;)
*
* @blackball
*/
#include <stdlib.h>
/* for futher use */