Skip to content

Instantly share code, notes, and snippets.

@jeffhung
jeffhung / auto_buffer.hpp
Created August 13, 2011 10:19
Two buffer classes I wrote before, for slightly different purpose.
/**
* The auto_buffer class acts as a buffer of @p T, but allocate statically or
* dynamically according to requested buffer size. If requested buffer size
* is greater than @p StaticBytes, auto_buffer will dynamically allocate
* required memory space for the buffer, instead of statically as a member
* array.
*
* Usually, dynamic allocation gets more overheads, but if requested size is
* too large, we may exceed stack limit too soon. So, a smarter strategy is
* to allocate statically if required size is small, and turn to dynamic
@jeffhung
jeffhung / irssi-quick-config.txt
Created January 20, 2011 14:52
Example for Quick IRSSI Configuration
# Do these once
/SET term_charset UTF-8
/SET recode_transliterate ON
/SET recode_fallback Big5
/SET recode_out_default_charset UTF-8
/SET autolog_path ~/logs/irclog-$0/irclog.$1.$0.%Y%m.log
# Do these once per (irc) network
/NETWORK ADD -kicks 4 -msgs 1 -modes 4 -whois 1 freenode
/SERVER ADD -auto -network freenode irc.freenode.net
#!/bin/sh
# ---------------------------------------------------------------------------
# Copyright (c) 2010, Jeff Hung
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
#!/usr/bin/perl -w
# ---------------------------------------------------------------------------
# wp2docbook.pl - Perl script to convert wordpress dump file to docbook XML
# files.
# Copyright (c) 2007-2009, Jeff Hung
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@jeffhung
jeffhung / gist:29707
Created November 27, 2008 08:31
vc-build.bat
@ECHO OFF
REM --------------------------------------------------------------------------
REM $Date: 2008-11-26 14:07:08 +0800 (??銝? 26 ????2008) $
REM $Rev: 406 $
REM $Author: jeffhung $
REM --------------------------------------------------------------------------
REM revid: "@(#) $Id: vc-build.bat 406 2008-11-26 06:07:08Z jeffhung $"
REM --------------------------------------------------------------------------
IF "%1"=="" GOTO :USAGE
@jeffhung
jeffhung / gist:18077
Created October 20, 2008 14:49
Generate graphviz digraph script <dot-file> according to project dependencies that parsed from VC6 workspace file <dsw-file>.
#!/usr/bin/perl -w
# ----------------------------------------------------------------------------
# $Date: 2007-10-29 18:15:53 +0800 (星期一, 29 十月 2007) $
# $Rev: 408 $
# $Author: jeffhung $
# ----------------------------------------------------------------------------
# revid: "@(#) $Id: dsw2dot.pl 408 2007-10-29 10:15:53Z jeffhung $"
# ----------------------------------------------------------------------------
use strict;
#include <cstdio>
#if defined(_CPPRTTI)
# define DIRECT_CPPRTTI_DEFINED "yes"
#else
# define DIRECT_CPPRTTI_DEFINED "no"
#endif
#define CPPRTTI_DEFINED defined(_CPPRTTI)
bool config_db::update_from_csv(const char* csv_file)
{
try {
vector< vector<string> > data_table;
ifstream ifs(csv_file);
while (ifs) {
string line;
getline(ifs, line);
vector<string> tokens;
// splits line string delimited by ",", and save to tokens.