poniedziałek, 28 lipca 2014

How to implement onSelectionChange listener on CTabItem tabs of the CTabFolder widget

On the first glance there is no easy way for running arbitrary piece of code once one of the CTabItem tab is changed. Lucky there is generic addListener(int eventType, Listener listener) delivered with Widget class.
CTabItem item = new CTabItem(tabFolder, SWT.NULL);
Composite container = createContent(item.getParent());

item.addListener(SWT.SELECTED, new Listener() {

 public void handleEvent(Event event) {
But by default there is no such an event notified by CTabFolder. That is why we need take care of it.
tabFolder.addSelectionListener(new SelectionAdapter() {
 public void widgetSelected(SelectionEvent e) {
  tabFolder.getSelection().notifyListeners(SWT.SELECTED, new Event());
Thats all. Works like a charm ;)

czwartek, 3 lipca 2014

Docker howto - most useful commands with examples

Docker commands

Most basic commands:

docker pull ubuntu 
- downloads image from Docker repository
docker ps -a
- shows all available containers
docker ps -as
- shows all containers with the actual size of the rw-layer
docker ps -lq
- finds out container id of the last started container

How to remove all containers which name or image matches specified regular expression

  for i in $(docker ps -a | grep "REGEXP_PATTERN" | cut -f1 -d" "); do echo $i; done

Note that this command does not filter containers on any particular field - there is no difference if pattern is found on container name, image name, or any other field.

How to run bash on running container

  docker exec -ti ceb1be03097d /bin/bash

How to create image based on container

  docker commit ceb1be03097d /:


How to change password to the root user?

RUN echo 'root:my_password' |chpasswd


$ docker ps
FATA[0000] Get http:///var/run/docker.sock/v1.16/containers/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?

Try the following: $ sudo docker ps