Wednesday, September 23, 2015

Visual Paradigm: Draw a table

Just a quick tip. Here's how to create a table in Visual Paradigm.

First, create a Text box, then use this associated tool:

Result:
This may seem quite obvious but at first I had to look around for quite a bit. Hope this help save some time.

Thursday, August 13, 2015

Vino VNC asks for keyring password

When you try to connect with VNC to your Ubuntu desktop which has Vino configured and running, it may trigger a gnome keyring password prompt on the local display, and the login process hangs on the remote end. There are many solutions around, and most of them leave the system somewhat dirty. Here's a procedure I've gathered which fixes the problem, even remotely, and leave the system clean.

First of all, we need to shut down the gnome keyring daemon. But I've found that all application trying to gain access to the keyring will cause it to launch. So I found the only way to stop it without removing it is to rename it. Temporarily, don't worry:

sudo mv /usr/bin/gnome-keyring-daemon /usr/bin/gnome-keyring-daemon.bak
sudo reboot

Then you should be able to connect to the remote machine with VNC. But let's not stop here and do things proper. First, reenable gnome keyring daemon and launch it so it is available to the next step:

sudo mv /usr/bin/gnome-keyring-daemon.bak /usr/bin/gnome-keyring-daemon
gnome-keyring-daemon

Make sure seahorse is installed and launch it from the VNC session. It's in System / Preferences / Passwords and Keys.

Now there's this "Login" folder. Unlock it by right clicking and choosing Unlock.

In the login folder, you will find an item named Vino. Right click on it and delete it.

And that's it. You can make sure everything is fixed by rebooting and trying to connect with VNC again.

I believe you have to leave the VNC password blank. Otherwise it'll create this item in the keyring. Feel free to confirm this in the comments. I've pulled too much hair out for this already ;)

Thursday, February 5, 2015

WebAPI OData v4: Cannot serialize a null 'entry'

In that kind of function:

public IHttpActionResult MyFunction([FromODataUri]int myParameter)
{
 return Ok(GetFoo(myParameter));
}

This may lead to the error 500 described in the title if the returned value is null. Based on this thread, One way would be to return an empty response when the return value is null:

public IHttpActionResult MyFunction([FromODataUri]int myParameter)
{
 var retval = GetFoo(myParameter);
 if (retval != null)
  return Ok(retval);
 else
  return Ok();
}

The result is a 202 OK empty response, but this doesn't seem to please some OData frameworks as I sometimes get a "Unexpected server response" message on the client side.

Now, based on this other thread, it seems the clean way to do this is to return a 404 error when the return value is null and act accordingly on the client side:

public IHttpActionResult MyFunction([FromODataUri]int myParameter)
{
 var retval = GetFoo(myParameter);
 if (retval != null)
  return Ok(retval);
 else
  return NotFound();
}


Wednesday, January 14, 2015

WebAPI OData: Only entity types support $select and $expand

I used to get this because I was trying to return a complex type which was not an entity type and use "expand" on it so to get a child property:

builder.EntitySet<MyComplexType>("MyComplexTypes").EntityType.Collection.Action("MyAction").Returns<MyComplexType>()
[HttpPost, EnableQuery(AllowedQueryOptions = AllowedQueryOptions.Expand)]
public IHttpActionResult MyAction(ODataActionParameters parameters)
{
 return Ok(new MyComplexType());
}

http://host/api/Entities/Default.MyAction?$expand=ChildProperty

Accessing this URL triggers:

"Only entity types support $select and $expand"

Instead of converting the type, which would have made non sens in my situation, here's what I did:

builder.EntitySet<MyComplexType>("MyComplexTypes").EntityType.Collection.Action("MyAction").Returns<string>()
[HttpPost]
public IHttpActionResult MyAction(ODataActionParameters parameters)
{
 return Json(new MyComplexType());
}

http://host/api/Entities/Default.MyAction

This returns a new MyComplexType object with all its children properties serialized.