How to configure SSH Key-Based authentification

SSH Key-Based authentication can be configured in two easy steps.
All you have to do is add the user-machine’s public key to the server’s authorized_keys file.
Therefore you have to:

  1. create a public key for your user-machine
  2. write the key to the server’s ~/.ssh/authorized_keys textfile

On your local machine a private-public ssh key pair is easily created executing the following command in your terminal app:

which will yield following output

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/systemkern/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/systemkern/.ssh/id_rsa.
Your public key has been saved in /Users/systemkern/.ssh/
The key fingerprint is:
11:22:33:44:55:66:77:88:99:00:aa:bb:cc:dd:ee:ff systemkern@systemkerns-mac
The key's randomart image is:
+--[ RSA 2048]----+
| S *+ . |
| .. |
| o B + |
| o . |
| . o . |
| ... |
| * . oo o |
| . =E + |
| . o |

The program will ask you where the key file should be created also showing the default name in the output. In this exapmple the private key file will be created under ~/.ssh with the name id_rsa. The public key can be found in the same directory in the file

The optional passphrase will provide some additional protection to your login. Only if the passphrase is entered the key based authentication will work.

you can then issue the following command to save the public key on the server:
cat ~/.ssh/ | ssh user@server “mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys”

you can now log in to your server authenticated by ssh instead of by password.

Generic Singletons with C#

C# gives you most of the generic powers that also Java has. So if one were so inclined he could write a generic singleton class. This approach would free implementing classes (and their developers) from handling the instance reference and providing the getInstance() method. Granted this is not a lot of work per instance but even an avalanche is made up from tiny snowflakes.

This example was written to be used inside the Unity game development framework. Unity takes care of the initialisation, so we only have to worry about keeping the reference.

Two base classes are needed to get around some limitations of C# generic implementations. An untyped class which stands at the root of the inheritance tree (“AbstractValueController”) and a typed Class which extends this BaseClass (“ValueController”).

1) The untyped BaseClass which I chose to declare abstract to make it more distinguishable:

public class AbstractValueController : MonoBehaviour {

2) The typed Class which contains the actual singleton logic:

public abstract class ValueController<SubType> : AbstractValueController
		where SubType : AbstractValueController {

	//the reference is saved as the root type but gets casted upon retrieval
	protected static AbstractValueController instance;
	public static SubType Instance { get { return (SubType) instance; } }

	//the Awake() Method is part of the UnityFramework and very similar to a constructor
	public virtual void Awake() {
		instance = this;

3) An example implementing class which you want to be a singleton:

//class is typed with its own type for the singleton logic to work
public class Controller : ValueController<Controller> {
	//no singleton code needed  ... neat

Fuzzy Logic with jFuzzyLogic

jFuzzyLogic is an easy to use library for fuzzy logic computations.
After adding the Package to your projects classpath you only need a couple of lines of code to include and run fuzzy logic computations. Basically it is just a matter of setting variables, running the computation and then later retrieving the output parameters.

fis.setVariable("input1", arg1);
fis.setVariable("input2", arg2);

// Evaluate
Variable out = fis.getVariable("out");
System.out.println("Output = "+out.getValue());