Other articles

  1. Embedded jetty with CDI (Weld)

    Project overview

    ├── main
    │   ├── java
    │   │   └── oct
    │   │       └── im
    │   │           ├── bean
    │   │           │   └── TestBean.java
    │   │           ├── Run.java
    │   │           └── servlet
    │   │               └── TestServlet.java
    │   └── resources
    │       ├── META-INF
    │       │   └── beans.xml
    │       └── webapp
    │           └── WEB-INF
    │               └── web.xml
    └── test
        ├── java
                └── resources


    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001 ...
    read more


  2. Fiddler not capturing google chrome traffic

    Fiddler is a great tool for tracking/debugging your network traffics. But sometimes it doesn't work with google chrome.

    Turns out that some of my google extensions, "Unblock Youku" and "Proxy SwitchySharp", will interfere with chrome's proxy settings, causing fiddler not working. Disabling them makes fiddler works again ...

    read more


  3. Upgrade 12.04LTS to 14.04 LTS, problems and fixes

    Command line

    do-release-upgrade -d


    update-manager -d



    Python=> ImportError: No module named _io

    Install python-dev fixes this. And you will need to recreate your virtual environments

    sudo apt-get install python-dev

    My ibus-pinyin is broke.

    My ibus-pinyin got messed up after the upgrade. seems like it was changed to "ShuangPin ...

    read more


  4. Curl -d VS --data-binary

    In short: -d will remove new lines, but --data-binary will keep everythin as it's.

    -d, --data (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the ...

    read more


  5. Working with multiple git repositories


    There are three machines: Server, Working machine, home machine. The server hosts a git repository. And eventually all codes will end up to the server.

    Working machine is where i do most of my daily development, and the changes will be pushed to the server.

    Occasionally, i also do ...

    read more


  6. An example of Git pre-push hook

    An example of Git pre-push hook

    Git hooks are actually bash scripts that would be triggered by certain actions. A pre-push hook is triggered before a push action.

    The hook below will check there is any New or Modified java files in the repository before the push happens. If yes ...

    read more


  7. How to create logback Loggers dynamically/Pragmatically

    Code snippet

    import ch.qos.logback.classic.Logger;
    import ch.qos.logback.classic.LoggerContext;
    import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
    import ch.qos.logback.core.rolling.RollingFileAppender;
    import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
    import java.io.File;
    import org.slf4j.LoggerFactory;
    private void demo() {
        LoggerContext context = (LoggerContext) LoggerFactory ...
    read more


  8. How to setup OpenVPN server and client (Amazon EC2)

    Setup and configuration

    Install OpenVPN

        sudo apt-get install openvpn

    Server setup

    I don’t want to work inside /etc/openvpn directly, so let’s create a working folder first:

        mkdir vpnserver
        cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* vpnserver/
        cd vpnserver

    Create certificates for server

    My vpn ...

    read more


  9. Clipboards

    X11 has these things called ""selections.” They have names. There are really only two you need to know about: the Primary selection and the Clipboard selection. An application is said to "own” a selection when it raises its hand and says, "I have the Primary selection now.” Only one application ...

    read more