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 /:

Dockerfile

How to change password to the root user?

RUN echo 'root:my_password' |chpasswd

Troubleshooting

$ 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

środa, 4 czerwca 2014

Binding key strokes to eclipse commands

The key is specified as uppercased character. However, there can be also specified other keys, which can be also no printable.
The following special literals are available :
  • SPACE, TAB, CR, DEL, ESC, BREAK, BS, CAPS_LOCK, END, HOME, INSERT, PAGE_UP, PAGE_DOWN
  • ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP
  • F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, FF
  • NUM_LOCK, NUMPAD_0, NUMPAD_1, NUMPAD_2, NUMPAD_3, NUMPAD_4, NUMPAD_5, NUMPAD_6, NUMPAD_7, NUMPAD_8, NUMPAD_9, NUMPAD_ADD, NUMPAD_DECIMAL, NUMPAD_DIVIDE, NUMPAD_ENTER, NUMPAD_EQUAL, NUMPAD_MULTIPLY, NUMPAD_SUBTRACT
  • LF, NUL, , PAUSE, PRINT_SCREEN, SCROLL_LOCK, and VT

poniedziałek, 12 maja 2014

How to lock IntelliJ IDEA on Unity launcher

Most straightforward way is running the IntelliJ from command line and once opened "right click" on icon appeared on the launcher and click "Lock to Launcher".

Now you can go to terminal (Ctrl+Atl+T) and edit newly created desktop file ~/.local/share/applications/jetbrains-idea-ce.desktop

The key point is to fix Exec entry - should be path to the ./idea.sh start script. Note that if you have not JAVA_HOME set in your environment, you need set one as shown below.
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=IntelliJ IDEA
Icon=jetbrains-idea-ce.png
Path=/home/krma/Downloads/idea-IC-135.690/bin
Exec=env JAVA_HOME=/usr/lib/jvm/java-8-oracle /home/krma/Downloads/idea-IC-135.690/bin/idea.sh
StartupNotify=false
StartupWMClass=jetbrains-idea-ce
OnlyShowIn=Unity;
X-UnityGenerated=true
That is basically all.

czwartek, 8 maja 2014

Eclipse PDE - all about Eclipse Commands

The goal of this site is gather most useful locationURI's one can like to attach custom command for Eclipse environment.

menu:org.eclipse.ui.views.ProblemView
menu:window?after=newEditor
popup:org.eclipse.ui.menus.showInMenu popup:#TextEditorContext?after=copy popup:#TextEditorContext?endof=group.find popup:#TextEditorContext?after=group.open popup:#TextEditorContext?after=group.edit

Useful commands

  • org.eclipse.ui.ide
    • org.eclipse.ui.edit.text.openLocalFile (Open a local file)
    • org.eclipse.ui.navigate.goToResource (Go to particulare resource in the active window)
    • org.eclipse.ui.navigate.openResource (Open an editor on a praticular resource)
      • handler: org.eclipse.ui.internal.ide.handlers.OpenResourceHandler
      • param: filePath
    • org.eclipse.ui.edit.addTask (Add a task)
      • defaultHandler:  no
    • org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals (Suggest possible fixes for a problem)
      • deafultHander: no
    • org.eclipse.ui.navigate.showResourceByPath (Show a resource in the Navigator given its path)
      • defaultHandler: org.eclipse.ui.internal.ide.handlers.ShowResourceByPathHandler
      • resourcePath
    • org.eclipse.ui.ide.copyBuildIdCommand (Copies the build id to the clipboard)
      • defaultHandler: org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler
  • org.eclipse.ui
    • org.eclipse.ui.newWizard (Open wizard)
      • param: newWizardId
    • org.eclipse.ui.file.import
      • param:  importWizardId
    • org.eclipse.ui.file.export
      • param: exportWizardId

Invoke programmatically

ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getService(ICommandService.class);

IEvaluationService evaluationService = (IEvaluationService) PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getService(IEvaluationService.class);
try {
 Command c = commandService.getCommand("org.eclipse.ui.newWizard");

 Map<String, String> params = new HashMap<String, String>();
 params.put("newWizardId", "mywizard.id");

 c.executeWithChecks(new ExecutionEvent(c, params, null, evaluationService.getCurrentState()));

} catch (Exception ex) {
 throw new RuntimeException("Open new wizard command not found");
}

 Menus


   
      
         
             
             
             
             
         
      
   



   
      
         
           
         
      
      
        
      
   



   
      
      
         
            
            
         
      
   



   


wtorek, 6 maja 2014

Ubuntu 14.04 - How to dock applications to the Unity launcher

There is a gsettings command which let us do the job.

First we need to retrieve current configuration.

gsettings get com.canonical.Unity.Launcher favorites

We should receive something like that:

['application://nautilus.desktop', 'application://firefox.desktop', 'application://ubuntu-software-center.desktop', 'application://unity-control-center.desktop', 'unity://running-apps', 'application://eclipse.desktop', 'unity://expo-icon', 'unity://devices']

Now we need to put our application (luna.desktop entry - should be created manually in well-known applications folder - eg. ~/.local/share/applications/luna.desktop)

gsettings set com.canonical.Unity.Launcher favorites ['application://nautilus.desktop', 'application://firefox.desktop', 'application://ubuntu-software-center.desktop', 'application://unity-control-center.desktop', 'unity://running-apps', 'application://eclipse.desktop', 'application://luna.desktop', 'unity://expo-icon', 'unity://devices']

New launcher item will appear immediately.

piątek, 14 czerwca 2013

RMI headache - (too) many network interfaces



Assuming we have more then one network interface on our machine and assuming they are no routeable each other you can be faced a wierd behavior of RMI RemoteObject.

If you use TCP protocol as a transport creating an object of UnicastServerRef underneeth there is LifeRef object created, which in turn calls TCPEndpoint.getLocalEndpoint() method.

getLocalEndpoint() implementation do the following:
  • creates TCPEndpoint object with null value passed as hostname
  • resamples local host
return AccessController.doPrivileged(new GetPropertyAction("java.rmi.server.hostname"));

So make sure it points to the proper one ;).

wtorek, 21 maja 2013

VBScript for begginers


Some initial facts


  • Concatenation operator: &
  • No semicolon required at the end of line



Most basic constructs



  • Allocation: Dim aRoot as Root
  • Assingment:  Set aParam = CurrentTSTest
  • TypeOf
    • If TypeOf p Is IParameterValue Then 
          TDOutput.Print("Value: " & p.Value)
      End If 
  • TypeName(o) - displays type of  the object passed.

 

Loop statements


  •  For Each param In lst
            With param
              TDOutput.Print("Name: " & .Name & ", Value: " & .DefaultValue)
            End With
    Next
 
  • Dim i%
        For i = 1 To lst.Count
            Set instance = lst.Item(i)
            Debug.Print "Instance name: " & instance.name & " id: " & instance.ID
    Next i
     



Useful links: