Docker – useful command

$ docker log <container id> // show logs
$ docker port <container id> // show port mapping
$ docker inspect <container id> // inspect container settings
Posted in docker | Tagged | Leave a comment

Java – Task polling example with Java 8

public void completionService(ExecutorService executor) {
    CompletionService<CustomTaskResult> completionService =
        new ExecutorCompletionService<CustomTaskResult>(executor);

    completionService.submit(() => {
        // to something
    });


    Future<CustomTaskResult> future = null
    while ((future = completionService.poll()) != null) {

    	// do something

    }
}
Posted in Java, Programming | Tagged | Leave a comment

Angular 2 book

Angular 2 Development with TypeScript

https://www.manning.com/books/angular-2-development-with-typescript

Posted in book | Tagged | Leave a comment

Rake – useful command line options

$ rake -P
$ rake -T #display description
$ rake -T buy #display contains "buy" in name
$ rake -W buy #display path of task "buy"
$ rake -D 
Posted in Programming, rake | Leave a comment

Python – REST API call example with a self certificated SSL connection

import time
import http.client
import ssl
import json

conn = http.client.HTTPSConnection("localhost:9990", timeout=5, context=ssl._create_unverified_context())

csvFileDat = ""
with open("c:\\tmp\\test.csv") as inputFile:
    csvFileDat = inputFile.read()

headers = {
    'content-type': "text/plain",
    'authorization': "Basic base64encoded"
}

sumTotal = 0

repeatCount = 100
for idx in range(repeatCount):
    start = time.time()

    conn.request("PUT", "/rest/import", csvFileDat, headers)

    res = conn.getresponse()
    data = res.read()

    end = time.time()
    elapse = end - start
    sumTotal += elapse

    result = json.loads(data.decode('utf-8'))

print("Total time: {}, Avg: {}".format(sumTotal, sumTotal / repeatCount))

Posted in Programming, python | Tagged | Leave a comment

C++ 14 – co-routine with boost library

It is worth to read the following blog if interested in C++ co-routine support.

https://blogs.msdn.microsoft.com/vcblog/2017/05/19/using-c-coroutines-with-boost-c-libraries/

Posted in C++, Programming | Leave a comment

Linux – Useful Git book(Linux inside)

https://www.gitbook.com/book/0xax/linux-insides/details

Posted in Linux, Programming | Leave a comment