Mar 8, 2013

SSH: using specific keys with specific hosts

First of all, I have never thought I'd post something Unix related (not that I have anything against it; it just because I am more a Windows user :)

It just happens that for personal reasons I have some VMs running Ubuntu and from time to time I need to transfer files from my host computer to the guest, i.e, from my Windows machine to Ubuntu running on the VM. Since the virtualization solution I am using has some issues regarding file/folder sharing between host/guest OS, I am using scp to do the job.

Until today I used to have a single RSA key pair to authenticate me when connecting to my Ubuntu VM and also to github and bitbucket but this has proven to no be an optimal solution. You see, when I am copying files to Ubuntu I'd like to not be forced to type any password, after all this VM has no sensitive data and is off limits since it is not connected to the internet, but since I am using a single RSA key pair for most of my authentication  needs I don't want do leave it unprotected so every time I want to copy something to the guest OS (my Ubuntu running on the VM) I find myself typing a huge, complicated password - actually very often mistyping it :(.


Today I took the time and decided I'd find out how to setup multiple RSA key pairs and use one with no password at all to authenticate me with my VM and one with a strong password for each online service I use.


Actually it was easier than I thought ;). Basically the utilities I rely on (ssh and scp) allows one to specify which identity file (the RSA file containing your private key) (-i file_path) is to be used.


if you don't want to specify which file should be used every time or if the utility you use don't allow you to specify this file (but uses ssh behind the scenes) you can use ~/.ssh/config file!

Happy codding.

Mar 6, 2013

New types from .NET 4.5

Hi.

While experimenting with WPF programing I've just stumbled on a nice, new class in .Net 4.5 (thanks to Resharper) named CallerMemberNameAttribute.

The first thing you can figure out based on its name is that it is an attribute. It's only applicable to parameters and is meant to make developers live easier when it comes to find out the name of the caller method / property / event / etc :)

Basically you add this attribute to any parameter of type string with a default value and the compiler will do its magic.

Bellow you can see an example:

public partial class Form1 : Form
{
	public Form1()
	{
		InitializeComponent();
		
		button2.Click += delegate
		{
			Foo();
		};
	}

	private void Foo([CallerMemberName] string caller = null)
	{
		MessageBox.Show("Called from : " + caller);
	}
}

This is really useful for implementing INotifyPropertyChanged interface.

Note that this gives you only the name of the member calling the method, not the type in which this method is defined.

As any other feature developers should not abuse it. For instance, IMHO, using this feature with indexers should be avoided:

public partial class Form1 : Form
{
	public Form1()
	{
		InitializeComponent();
		
		button2.Click += delegate
		{
			MessageBox.Show( this[0] );
			MessageBox.Show( this[1] );
		};
	}

	private string this[int n, [CallerMemberName] string caller = null]
	{
		return n > 0 ? this[n-1] : caller + "(" + n + ")";
	}
}

For more information, look into the documentation.

Happy codding!

Jan 4, 2013

The end of the world is approaching...

Hi

First of all, Happy new year! :)

Last night I was surprised (upset?) for getting an offer (that I could not refuse) from a well know web site (which I like pretty much, by the way) claiming that that was my last chance to subscribe to their 1 month free premium plan.

I have absolutely no problem with the offer. What gets on my nerves is the fact that they have been sending  this very same offer for the past 6 ~ 9 months, saying each time that that was my last chance. 

Come on guys. You should already have noticed that I even went to your website and started the registration process.... you should ask yourselves why I did not finished it, instead of keeping bugging me ;)

See you!


Nov 15, 2012

Learning git

If you are a software developer you should already use some sort of SCM (if not I urge you to start to learn/use one now!). 

If you have not tried Git yet you should give it a try (but keep in mind it may take some time until you really appreciate its power).

I have been working with Git for at least 2 years and I am amazed how flexible / powerful it is. Actually it is so powerful I still learn new stuff about it almost every other day! Bellow you can find some useful resources to learn a little bit more about it:

Have fun!

Oct 15, 2012

Modern times

When I was a child (not so long ago :) I used to turn on the TV and wait for some time until it warmed up (ok, don't laugh). Exactly, it was a B&W valved tube tv.

Then, at my adolescence, my father bought us a new, shine, top technology color TV; it did not used valves any more and as a result live became better (not only I could turn the TV on and start watching my favorite programs instantaneously - or play video game - but now it had colors!!

Some more time passed (just a few years) and we fast forward to current days.

Now, after a long working day, leaving my office and walking 3 meters, I take a seat in front of my shine new, 51", full hd, 3D plasma TV, turn it on and... it takes 10 ~ 20 seconds to 
start displaying any interesting content (sure the TV maker logo appears in less than 5 secs but it is not that interesting any more)! What? Are we retrogressing ?

I really don't care if these TVs are actually computers... please tv makers, do it right! make it "boot" instantaneously, don't make me wait. I can foresee how the TVs ads will look like in the near future:
you do need to have this flub glob shob TV! It has more features than a computer scientist with a PHD is able to handle and it starts in (put some low number here) seconds!
What will be the next step? getting BSODs (calm down *nix fan boys I did not forget you ;) or Core dumps while watching TV?

You may think I'm kidding about the BSOD stuff, but I am not; for sure my cable TV setupbox already "implemented" this feature (the only deviation from the original BSOD is that you get absolutely no feedback so you are left wondering what happened and the only option is to restart it (hopping it fixes the problem); seriously, it is so crap that sometimes I need to restart it multiple times to get it working again (the cable tv support staff is so used to these issues that the first thing they ask you is to reset the setupbox :m ).

What do you think?

Oct 10, 2012

Icons, Icons, Icons....

From time to time I find myself looking for icons for my own projects....

If you ever had the same need check this out.

I really recommend it :)

Happy programming.

Sep 25, 2012

Angry user...

Sorry, I could not resist the pun :)

Well, some time ago (to be more precise 1 1/2 years ago) I've bought a (Chinese) Android Tablet so I could experiment, play games and may be try to develop some program (of course I've failed miserable to write any application for it :(. You can see a picture of the device bellow (it ended up to be much more resistant than what I expected! You can see its cracked 
screen due to 2 ~ 3 not so smooth landings - thanks to my young daughter):

Anyway, I use it regularly for reading ebooks, email reading and playing basic games. Talking about games I used to play "Angry Birds" (all free editions) on this device with no problems at all; but at some point in time something has changed and since then I am not able to play it anymore. The symptoms are always the same: I launch the game, its "splash screen" shows up followed by some screens and finally the "loading" screen shows up but then the application just dies without any trace! 


I had just accepted the fact that I'd not be able to play this game again on this device but last weekend I was recovering from a small surgery and I decided to investigate it a little bit more.


First thing I did was to install a log viewer (I'm using aLogCat) to check if I could find anything on Android logs. Indeed it was pretty easy to find the information I was looking for:


E/HttpRequestHelper( 4956): Exception from HttpClient.execute.
E/HttpRequestHelper( 4956): java.net.UnknownHostException: rovio.events.medio.com
E/HttpRequestHelper( 4956): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
E/HttpRequestHelper( 4956): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
E/HttpRequestHelper( 4956): at java.net.InetAddress.getAllByName(InetAddress.java:242)
E/HttpRequestHelper( 4956): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
E/HttpRequestHelper( 4956): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
E/HttpRequestHelper( 4956): at


Huum... ok, so the application tried to resolve the host "rovio.events.medio.com" and it failed bringing the whole app down! WTF? (I tried to access this host from my desktop and the result is the same (
Interesting enough, medio.com as well events.medio.com does exist) so I assume the problem is directly related to the subdomain "rovio" on events.medio.com.

Searching on net for this error did not bring any useful answer. Also I've tried to clear Angry Birds application data, 
re-install it and even a device factory reset (due to other issues) to no avail :(. 

Have you seem this error? Any ideas how to fix it? I doubt I am the first one to stumble on it!