Skip to content

Instantly share code, notes, and snippets.

View legnaleurc's full-sized avatar

Wei-Cheng Pan legnaleurc

View GitHub Profile
@legnaleurc
legnaleurc / arg.py
Created September 22, 2014 16:16
argparse bug
from __future__ import unicode_literals
from __future__ import print_function
import argparse
a = argparse.ArgumentParser()
b = a.add_subparsers(dest='command')
b.add_parser('test')
c = a.parse_args([])
print(c.command is None)
@legnaleurc
legnaleurc / wv.py
Created December 27, 2014 03:26
webview example
#! /usr/bin/env python3
import sys
from PySide import QtGui, QtWebKit
app = QtGui.QApplication(sys.argv)
@legnaleurc
legnaleurc / boost1.55_coroutine.patch
Last active August 29, 2015 14:23
boost1.55_coroutine.patch
Index: debian/changelog
===================================================================
--- debian/changelog (revision 14903)
+++ debian/changelog (working copy)
@@ -1,3 +1,9 @@
+boost1.55 (1.55.0+dfsg-4.1~coroutine1) experimental; urgency=low
+
+ * Enable coroutine shared library.
+
+ -- Wei-Cheng Pan <legnaleurc@gmail.com> Fri, 26 Jun 2015 04:34:46 +0000
@legnaleurc
legnaleurc / bn.cpp
Last active September 23, 2015 21:28
Binary Node
#include <memory>
#include <iostream>
class Node: public std::enable_shared_from_this< Node > {
public:
typedef std::shared_ptr< Node > NodeSP;
typedef std::weak_ptr< Node > NodeWP;
static NodeSP create( int value ) {
return NodeSP( new Node( value ) );
@legnaleurc
legnaleurc / reactor.java
Created May 24, 2011 07:26
NIO practice
package org.sandbox;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
@legnaleurc
legnaleurc / kdesrc-curses.rst
Created November 8, 2011 16:54
kdesrc-curses

kdesrc-curses

Idea for homebrew-like kdesrc-build, I'll call it kdesrc-curses

Concepts

  • Scriptable: new program or module should be easily add. Simply add a new file and inherit some classes.
#include <iostream>
#include <chrono>
#include <queue>
#include <boost/asio/io_service.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/strand.hpp>
class Runner {
@legnaleurc
legnaleurc / h264.c
Last active December 17, 2015 05:09
h.264
#define _BSD_SOURCE
#include <endian.h>
// #include "bs.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@legnaleurc
legnaleurc / transstack.py
Last active May 17, 2016 07:35
Translate C++ stack frame address to source address
#! /usr/bin/env python3
import re
import shutil
import sys
import asyncio
class BaseParser(object):