Skip to content

Instantly share code, notes, and snippets.

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.
#include <cstdio>
#if defined(_CPPRTTI)
# define DIRECT_CPPRTTI_DEFINED "yes"
#else
# define DIRECT_CPPRTTI_DEFINED "no"
#endif
#define CPPRTTI_DEFINED defined(_CPPRTTI)
@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;
@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
#!/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:
#!/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
@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
@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 / gist:1160862
Created August 21, 2011 17:12
IRC Log for #coscup in Aug, 2011.
--- Log opened Mon Aug 01 00:00:23 2011
--- Day changed Wed Aug 03 2011
[20110803T091729+0800]< sanyuan> w
--- Log closed Thu Aug 04 07:52:01 2011
--- Log opened Thu Aug 04 07:52:07 2011
[20110804T075207+0800]-!- Irssi: #coscup: Total of 27 nicks [3 ops, 0 halfops, 0 voices, 24 normal]
[20110804T075320+0800]-!- Irssi: Join to #coscup was synced in 77 secs
--- Day changed Mon Aug 08 2011
[20110808T130743+0800]-!- kyu is now known as kengyu
--- Day changed Tue Aug 09 2011
@jeffhung
jeffhung / irclog-osdc.tw-2012.txt
Created April 16, 2012 02:02
OSDC.tw 2012 IRC log
Before you enjoy the log, please consider attending OSDC.tw Hackathon:
https://github.com/jeffhung/osdc-2012-hackathon
Feel free to join the event to have fun and meet people, even if you have no
idea what to hack yet.
--- Log opened Sat Apr 14 07:08:57 2012
[20120414T073730+0800]< darkx> 大家早安
[20120414T083658+0800]< miyagawa> which building is the venue? http://www.sinica.edu.tw/as/map/asmap_c.html