Windows on VirtualBox on CentOs using RDP

  • Installing kernel-devel was recommended by several pages, so I just did it.

sudo yum install kernel-devel

Install VirtualBox and extension pack

  • Get repo
    cd /etc/yum.repos.d
    sudo wget
  • You can change enabled when you don't need this repo.

  • Install VirtualBox and extension pack.
    sudo yum install VirtualBox-5.0
    wget$(vboxmanage -v | cut -d'r' -f 1)/Oracle_VM_VirtualBox_Extension_Pack-$(vboxmanage -v | cut -d'r' -f 1)-$(vboxmanage -v | cut -d'r' -f 2).vbox-extpack
    sudo vboxmanage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-$(vboxmanage -v | cut -d'r' -f 1)-$(vboxmanage -v | cut -d'r' -f 2).vbox-extpack

Create VM

  • If you have an ova file import it into VirtualBox

vboxmanage import OVA_FILE_PATH

  • If you have an iso file
    • To get ostypes: vboxmanage list ostypes | grep -i window | grep ID
    • Assume you have VMNAME variable, such as export VMNAME=win10
    • Create VM vboxmanage createvm --name $VMNAME --ostype Windows10_64 --register
    • vboxmanage modifyvm $VMNAME --memory 1024 --acpi on --boot1 dvd --nic1 nat
    • Create HDD vboxmanage createhd --filename '$VMNAME.vdi' --size 10240
    • Add IDE controller vboxmanage storagectl $VMNAME --name 'ide ctrl' --add ide --controller PIIX4
    • Attach HDD vboxmanage storageattach $VMNAME --storagectl 'ide ctrl' --port 0 --device 0 --type hdd --medium ./$VMNAME.vdi
    • Attach ISO file as DVD driver vboxmanage storageattach win10 --storagectl 'ide ctrl' --port 0 --device 1 --type dvddrive --medium PATH_TO_ISO_FILE

Set VRDE mode

vboxmanage modifyvm $VMNAME --vrde on

Start VM

vboxmanage startvm --type headless $VMNAME

Check if RDP is listening on 3389 port

netstat -ntl | grep 3389

Run Client to get screen.

  • I downloaded Parallels Client from App Store for my osx, which works perfectly.




Remember to turn off TSO GSO

Before start capturing your packets to troubleshoot, remember to turn off tso and gso. Segment offloading is to let your NIC deal with packet processing, such as packet fragmentation and retransmission. This generally is good but hides your real packet transmission. In linux, you can disable this features by executing below commands.
ethtool -K tso off gso off

Capture TCP packet to a host:port

tcpdump -i -s 0 -vv -nn "tcp and host and 443 "

  • -s 0: do not truncate packets

Capture TCP packet of a subnet

tcpdump -i -s 0 -vv -nn "tcp and net"

Capture UDP packet of specific bytes

tcpdump -i -s 0 -vv -nn "udp[10:4] = 0x01020304"

Filter out a tcpdump file to another file

tcpdump -r-w "tcp and port 8080"

likely, unlikely in Linux

likely and unlikely

You would have seen "likely" and "unlikely" macros in Linux kernels, modules or other programs. What are the macros doing? How do I properly use them?

kernel newbies – FAQ/LikelyUnlikely

Please visit kernel newbies' FAQ, it'll give you more detail and correct information.


The macros live in compiler.h, and looks pretty simple.

#define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0)

What is the expected behavior?

likely and unlikely does nothing to do with program logic. This means that you don't need to change the conditions due to likely and unlikely.

__builtin_expect(long EXP, long c)

Programs do prefetching following commands. When it sees a branch it follows the prediction information. So, if the prediction is wrong, it should discard the prefetched commands. Here you can give an information that this EXP will be true almost times or vice versa. This enables programs do a right prediction and enhances the performance.


<code>// Let&#39;s say we have a do_something() function that returns 1 when succeed.
// And you expect that it succeeds for happy cases (most of the time)
// You can utilize likely
if (likely(do_something())) {
   // Do happy logics

// Or you may love this more
if (unlikely(do_something())) {
    // Computer can expect that this part will not be executed mostly, and it can prefetching the out of this if statement (or else part).

Semaphore vs. Mutex

Good posts about Semaphore vs. Mutex


Important difference between Mutex and Semaphore.

– Mutex lock is released by the thread which have acquired the lock.

– Semaphore can be released by other threads.

Semaphore is suitable for producer & consumer pattern.

Install python and openCV to windows7

reference :


Python 2.7 –

NumPy(Numerical Python) –

SciPy –

Download openCV with .exe from

Install it to c:openCV

copy c:openCVbuildpython2.7cv2.pyd c:Python27Libsite-packages
test by running

JD-GUI bug, it dropped explicit casts

최근에, framework 을 수정할 일이 있었는데, 큰 문제를 일으킬뻔 한 jd-gui 버그가 있어 글로 정리..

1. 시스템이 여러개라 메인시스템을 제외하고 framework library 의 소스가 따로 관리되지 않고 있었음.

2. framework 의 개선이 있어서 작업을 하고 메인시스템 외의 시스템은

decompile 해서 해당 함수 수정하고 다시 compile 해서 jar로 생성 후 반영

위와 같은 작업을 하고 있었는데 decompiler 로 jd-gui를 사용했다. jar 전체를 java 소스로 뽑아주는 기능이 있었기 때문이다.

전체 소스를 비교하면서 작업을 꼼꼼히 하기 위해서 사용했었는데..

문제는 이것.

원 소스 :

public class TestClass {

	public int ceil(int a, int b) {
		return (int) Math.ceil((double)a/(double)b);

jd-gui가 de-compile 한 java (BUG!)

public class TestClass
  public int ceil(int a, int b)
    return (int)Math.ceil(a/b);

jad.exe가 de-compile 한 java

public class TestClass

    public TestClass()

    public int ceil(int a, int b)
        return (int)Math.ceil((double)a / (double)b);

jd-gui가 명시적 casting을 날려먹음..

결과.. 2, 100 이 파라미터로 넘어가면..

원함수는 1을 리턴했으나, jd-gui를 믿었다면 0을 리턴하게 되므로 로직이 변경됨..

주의하세요 !

Tip of uploading images to tumblr using OAuth on iOS

To make my app, merge&share, I had to use OAuth to upload multiple services including tumblr.

There’s some problem, and I still don’t know which one is problem between OAuthConsumer library and tumblr.

OAuthConsumer Library makes authorization header using all parameters and if I include NSData, it may not work correctly.

– OR –

Tumblr doesn’t recognize the authorization header that OAuthConsumer made correct.

Therefore, I makes different approach to upload tumblr.

Step 1. Create OAuthHeader with only string parameters

Step 2. Create another request by using ASIFormDataRequest again and set header directly

here’s code

- (void)exportImage:(NSData *)image message:(NSString *)message withAccount:(Account *)account {

    OAToken *token = [[[OAToken alloc] initWithKey:account.token secret:account.key] autorelease];
    OAConsumer *consumer = [[[OAConsumer alloc] initWithKey:TUMBLR_API_KEY secret:TUMBLR_API_SECRET] autorelease];

    NSString *baseHost = [[account.album stringByReplacingOccurrencesOfString:@"http://" withString:@""]
                          stringByReplacingOccurrencesOfString:@"https://" withString:@""];

    NSString *requestUrl =

    [NSString stringWithFormat:@"", baseHost];

    OAMutableURLRequest *request = [[[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:requestUrl]
                                                           signatureProvider:nil] autorelease];

    [request setHTTPMethod:@"POST"];

    [request setParameters:[NSArray arrayWithObjects:
                            [OARequestParameter requestParameter:@"type" value:@"photo"],
                            [OARequestParameter requestParameter:@"caption" value:message],
    [request prepare];
    NSString *oAuthHeader = [request valueForHTTPHeaderField:@"Authorization"];
    DLog(@"OAuthHeader : %@", oAuthHeader);

    ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:requestUrl]];

    [req setRequestMethod:@"POST"];
    [req addRequestHeader:@"Authorization" value:oAuthHeader];
    [req addPostValue:@"photo" forKey:@"type"];
    [req addPostValue:message forKey:@"caption"];
    //    [req addPostValue:@"photo.jpg" forKey:@"file"];
    [req addData:image withFileName:@"photo.jpg" andContentType:@"image/jpeg" forKey:@"data"];

    [req startSynchronous];
    int statusCode = [req responseStatusCode];
    DLog(@"sending completed with status code : %d", statusCode);
    DLog(@"RESP : %@", [req responseString]);

    NSData *respData = [req responseData];

    [req release];

    if( statusCode != 201 ) {
        @throw [NSException exceptionWithName:NSLocalizedString(@"Error", @"")
                                       reason:[NSString stringWithFormat:@"status : %d", statusCode]



Apache – tomcat 연동 virtualhost 사용

mod_jk를 사용하여 apache와 톰캣을 연동한다.

mod_jk 다운로드 :


LoadModule jk_module /ssw/apps/apache/modules/

<IfModule jk_module>
JkWorkersFile /ssw/apps/apache/modules/jk_module/
JkShmFile    /ssw/log/apache/mod_jk/mod_jk.shm
JkLogFile    /ssw/log/apache/mod_jk/mod_jk.log
JkLogLevel   trace
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
#JkMount /*.jsp worker1
#JkMountCopy On


<VirtualHost *:80>
DocumentRoot "/ssw/web/docs/dev"
ErrorLog "/ssw/log/apache/docs/dev/error_log"
CustomLog "/ssw/log/apache/docs/dev/access_log" common
JkMount /*.jsp worker1
JkMountCopy On