Thursday, January 03, 2013

GitHub/Bitbucket: Fixing The server's host key is not cached in the registry

If you are using putty as your ssh-agent, then to fix the annoying error you get when connecting to either GiHub or BitBucket for the first time :

"The server's host key is not cached in the registry"

Or you will get some output like this


The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1024 [fingerprint here]
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)


You'll type "y" but you will get a failure response, because "git" won't be able to recognize your "y" since
that whole response is really coming from "putty" not from "git"

To fix this use "plink.exe" (comes with putty installation) to connect to either github or bitbucket

plink -agent github.com

plink -agent bitbucket.org

This will prompt you to save the host key in registry , and enter yes, then try your git command again, and it should be working.

Thursday, December 27, 2012

Runnign Unix/Linux Commands On Windows

Running *Nix Commands On Windows

Below are list of exe's or bundle of exe's that  gives your the power to run majority of *nix commands that you use every day on your nix environment.

Makehttp://gnuwin32.sourceforge.net/packages/make.htm

WinBashhttp://win-bash.sourceforge.net/

UnxUtilshttp://unxutils.sourceforge.net/

To Be Continued...

Thursday, May 10, 2012

Debugging a hanging Java process started from shell/cron

This is a quick help tip in case you face this situation :
You have a JAVA process started from shell script or cron , and it never finishes .

1- Find out the ID of that hanging java process
From Java jdk , you can use the command "jps" (you will need some permission to run that).

2- Find out what is your job current stack trace looks like
Again from the jdk , you can use the command "jstack -F " , this will print all the stack trace for
all threads running, plus each thread status

There are many other ways, but this is the simplest and all comes within your download of java jdk.

Friday, September 09, 2011

iPhone 3G/4G tester - online website test emulator with flip

Test how your website will look when viewed with iPhone
iPhone 3G/4G tester - online website test emulator with flip

Monday, August 22, 2011

Implement Inheritance in NodeJs

I'm learning Nodejs these days , and coming from an OOP background, i tend to get things done closer to how i'm doing there.

So I wanted all my Nodejs objects to inherit from a base object , that provide utilities common to every other thing .. this is in OOP known as inheritance.

In JavaScript world class/inheritance isn't officially a feature of the language, but its doable, for example the following JavaScript method copies the prototype of one object to another,

function inherit (parent, descendant) {
                var sConstructor = parent.toString();
		var aMatch = sConstructor.match(/\s*function (.*)\(/);
		if(aMatch != null) {
			descendant.prototype[aMatch[1]] = parent;
		}
		for(var m in parent.prototype) {
			descendant.prototype[m] = parent.prototype[m];
		}
The result of this method is, all functions implemented by the parent will now be added to the descendant.

Fine so far, now how to get this done in Nodejs.

NodeJs combine/organize code into what so called "Modules" , and each module should export (the term used by Nodejs) an object that reference the methods defined in the module.

So for example, we will have a module named "baseObject" defined as follows :

var util = require('util');
var base = function() {}

base.prototype = {
	asString : function() {
		return util.inspect(this, true, null);
	}
}
module.exports = base;

 This module defined an object called base, that have a single method called "asString()" which simply dumps a string representation of the object using Nodejs "util.inspect" method , and we export this object .

And we have another object called "settings" that also needs to define a method "asString()" to dump the string representation of that object , defiantly the proper way to do this in Java is to have "settings" inherit from "base" , but how to do so in Nodejs , here is how :

var obj = require("./utils/objectUtils.js");// Defines "inherit" method
var base = require("./utils/baseObject.js");// Holds "asString()" method that we want "settings" to inherit it.
var settings = function() {
	this.x=1;
        this.y=2
}
// Inheirt from the base object 
obj.inherit(base,settings);
module.exports = new settings();

So what did we do is , before we export the module , we called the method "inherit" to copy the prototype of "base" class into "settings" class.

This will result having the following code simply works :

var settings=require('./settings.js');
console.log(settings.asString());

Friday, August 19, 2011

Friday, July 15, 2011

Nagstamon : Nagios Windows Desktop Integration/ Status Monitor Utility

Nagstamon is a utility that sets at your system tray in Windows listening for your Nagios alerts , incredibly helpful if you don't want to set looking at your Email all the time.