Pokazywanie postów oznaczonych etykietą troubleshooting. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą troubleshooting. Pokaż wszystkie posty

czwartek, 20 kwietnia 2017

Angular2 - Cannot read property 'id' of undefined for ngModel

Lets take the following piece of code
 <form>
    <select [(ngModel)]="project.id"...
In this case when there is no 'project' value set yet it will be thrown an error with the following message: Cannot read property 'id' of undefined

Maybe '?' operator can help us? Let's try.

 <form>
    <select [(ngModel)]="project?.id"...
Nope, this will cause template parsing error: Parser Error: The '?.' operator cannot be used in the assignment at column 13 in [project?.id=$event]

And what about the ngIf directive?

 <form *ngIf="project" >
    <select [(ngModel)]="project.id"...
Ufff. It works ;)

czwartek, 14 stycznia 2016

Ubuntu - disappeared unity windows recovery guide

I found myself really confused that after some operations (eg. switching external displays around) I cannot activate opened applications. I suspected that those apps have to be somewhere on desktop, but apparently not in current view port. There have to be a way to grab and move them.. but how??

After a while of googling wmctrl nifty friend was on my toolbox ready for action.

Lets start from looking at options by typing wmctrl -h for displaying a help.
Now try to figure out what windows are on your desktop:

$ wmctrl -l
0x02e00002  0 krma-laptok XdndCollectionWindowImp
0x02e00005  0 krma-laptok unity-launcher
0x02e00008  0 krma-laptok unity-panel
0x02e0000b  0 krma-laptok unity-dash
0x02e0000c  0 krma-laptok Hud
0x0280000a  0 krma-laptok Desktop
0x0460000b  0 krma-laptok krma@krma-laptok: ~
0x044000b3  0 krma-laptok Inbox - Mozilla Thunderbird
0x0400053b  0 krma-laptok Java - Eclipse 

Lets look at the desktop present on our system
$ wmctrl -d
0  * DG: 3840x1080  VP: 0,0  WA: 45,24 3795x1056  N/A
But how to identify those that are out of viewport?
$ wmctrl -lG
0x02e00002  0 -3940 -1180 3840 1080 krma-laptok XdndCollectionWindowImp
0x02e00005  0 0    24   45   1056 krma-laptok unity-launcher
0x02e00008  0 0    0    1920 24   krma-laptok unity-panel
0x02e0000b  0 -1241 -740 1141 640  krma-laptok unity-dash
0x02e0000c  0 -1060 -164 960  64   krma-laptok Hud
0x0280000a  0 0    0    3840 1080 krma-laptok Desktop
0x0460000b  0 2101 114  1601 844  krma-laptok krma@krma-laptok: ~
0x044000b3  0 70   266  1294 629  krma-laptok Inbox - Mozilla Thunderbird
0x0400053b  0 7655 92   1860 988  krma-laptok Java - Eclipse
Eclipse's x position seems to be a little to high, isn't? Lets move it to (20,20) and leave existing size (1860,988) unchanged:
$ wmctrl -i -r 0x0400053b -e 0,20,20,-1,-1
PS. another nice tool is xdotool. It can
$ xdotool getwindowgeometry 0x0400053b
Window 67110203
  Position: 55,62 (screen: 0)
  Geometry: 1860x988
Note that position is different from (20,20) - moved (35,42)??

czwartek, 9 kwietnia 2015

Remmina, Freerdp - how to change keyboard layout on target windows machine

Cannot type underscore sign - question mark is put instead? Most probably keyboard layout is wrong. Check what keyboard layout you have set at the moment.
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     pl,us
Above we can see two layouts in order: "pl" followed by "us". Lets switch them.
setxkbmap -layout us,pl
Now try to reconnect to the server. Underscore is again underscore ;)

wtorek, 17 marca 2015

This account is currently not available - how to execute command as user with nologin shell set

How to run a command as a user without bash shell set?

There is actually one nifty way to do this - use the su command with combination of two options s and c.
# su -s /bin/bash -c 'touch /tmp/file' 
What actually will happen here is basically overriding configured shell with the one passed with "-s" option.

środa, 28 stycznia 2015

Why running docker command returns "/var/run/docker.sock: permission denied"

/var/run/docker.sock: permission denied

$ 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?
First quick look at the /var/run/docker.sock file.
$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 sty 28 11:53 /var/run/docker.sock
The solution should be now clear - you can solve the issue by adding user you are logged in to the docker group.

So, let's do this:

$ sudo gpasswd -a ${USER} docker
There should be now a change in /etc/group file.
$ cat /etc/group | grep ^docker
Next you need start new terminal session to apply the change and check if you are in the docker group. Should be listed in the following command execution:
$ groups
If still cannot see docker in the groups you're in - and you run linux with graphical interface (eg Ubuntu) you may need basically restart machine. Once done restart your docker container (if you were not needed restarting machine in previous step ;)
$ sudo service docker.io restart
That's all, now docker ps should be no problem to run.

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 ;).