Skip to content

Instantly share code, notes, and snippets.

@yangacer
yangacer / fsevent.cpp
Created July 19, 2013 06:28
Minimum example of FSEvent (no thread creation)
#include <CoreServices/CoreServices.h>
#include <iostream>
void callback(
ConstFSEventStreamRef stream,
void *callbackInfo,
size_t numEvents,
void *evPaths,
const FSEventStreamEventFlags evFlags[],
const FSEventStreamEventId evIds[])
@yangacer
yangacer / OOFuse.cpp
Last active December 19, 2015 17:09
Glue class member function with fuse API.
#define FUSE_USE_VERSION 26
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "glue.hpp"
struct hello_fs
@yangacer
yangacer / sqlite3_create_function_v2.c
Created February 3, 2013 16:36
sqlite3_create_functoin_v2 comment
int sqlite3_create_function_v2(
sqlite3 *db, // db connection
const char *zFunctionName, // function name
int nArg, // number of argument this function takes. -1 for arbitrary numbers
int eTextRep, // text encoding, e.g. SQLITE_UTF8 or SQLITE_ANY
void *pApp, // pinter to function context
void (*xFunc)(sqlite3_context*,int,sqlite3_value**), // a scalar function implementation
void (*xStep)(sqlite3_context*,int,sqlite3_value**), // a aggregate function implementation
void (*xFinal)(sqlite3_context*), // the same pointer with previous one
void(*xDestroy)(void*) // destroy function context
@yangacer
yangacer / gcc_demangling.hpp
Created August 11, 2012 15:05
gcc demangling
#include <typeinfo>
#include <memory>
#ifdef __GNUC__
#include <cxxabi.h>
template<typename T>
struct getname
{
std::string operator()()
@yangacer
yangacer / gcc_exclude_clang.h
Created August 11, 2012 15:01
Detect gcc (exclude clang)
#if defined(__GNUC__) && !defined(__clang__)
#define GNUC_EXCLUDE_CLANG
#else
#undef GNUC_EXCLUDE_CLANG
#endif
@yangacer
yangacer / cppdebug.cpp
Created November 28, 2011 14:10
C++ debug util
#include <iostream>
#define CERR std::cerr << __FILE__ << ":" << \
std::dec << __LINE__ << ":" <<__FUNCTION__ << "() : "
@yangacer
yangacer / hash_map.cpp
Created October 21, 2011 12:26
hash_map shapshot
int main()
{
using namespace std;
using namespace BDB;
using BDB::Structure::HashMap;
Config conf;
conf.beg = 1;
conf.end = 10;
conf.root_dir = argv[1];
@yangacer
yangacer / newline_array_src.cpp
Created August 16, 2011 17:33
boost iostreams newline filter and array source
/**
* FreeBSD 8.2
* g++ -I /usr/local/include newline_array_src.cpp
**/
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/newline.hpp>
#include <boost/iostreams/device/array.hpp>
#include <string>
#include <cstring>
@yangacer
yangacer / gprof2callgraph_abbr.sh
Created August 5, 2011 16:39
generate program profile with callgraph
#!/bin/sh
# Dependencies:
# 1. gprof
# 2. gprof2dot
# 3. c++filt
# 4. dot (/usr/ports/x11-fonts/urwfonts)
help="profcg.sh executable output"
@yangacer
yangacer / icu_converter.cpp
Created July 7, 2011 07:39
ICU converter for GB to UTF8
/****************
* Acer Yang, GAIS Laboratory, Univ. CCU, Taiwan.
*
* g++ -I/usr/local/include -L/usr/local/lib unicode-convert.cpp -licui18n -o uconv
* ./uconv input file charset_name
*
********/
#include "unicode/ucnv.h"