Blog

javascript undefined, null, undefined property, 0, false, '', ==, ===, typeof

Mar 22, 2012

== Equals>If the two operands are not of the same type, JavaScript converts the operands then applies strict comparison.

=== Strict equal

Returns true if the operands are strictly equal  with no type conversion.

typeof

The  typeof operator returns a string indicating the type of the unevaluated operand.

typeof undefined === ’undefined’

undefined

A variable that has not been assigned a value is of type undefined.

false

Examples of expressions that can be converted to false are those that evaluate to null, 0, the empty string (“”), or undefined.

null

null is an object. It’s type is null. Null and Undefined types are  == (but not  ===)

Undeclared variable

/ var z*/

*z.x  // throws a ReferenceError

Check for undefined variable

*var x;

*if (x === undefined) {

*   // these statements execute

*}

*else {

*   // these statements do not execute

*} check for undeclared variable

*// x has not been defined before

*if (typeof x === ’undefined’) { // evaluates to true without errors

*   // these statements execute

*}

*

*if(x === undefined){ // throws a ReferenceError

*

*} check for object property

*var myobj = {‘a’:’a’};

*myobj.hasOwnProperty(‘a’) // true

*var myobj2 = Object.create(myobj);

*myobj2.hasOwnProperty(‘a’) //false

*‘a’ in myobj2 // true check for null

*var c = null

*if (c === null) { // true

*} References

http://saladwithsteve.com/2008/02/javascript-undefined-vs-null.html

http://constc.blogspot.com/2008/07/undeclared-undefined-null-in-javascript.html

http://www.mapbender.org/JavaScript_pitfalls:_null,_false,_undefined,_NaN

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined

https://developer.mozilla.org/en/JavaScript/Reference/Operators/Comparison_Operators

https://developer.mozilla.org/en/JavaScript/Reference/Operators/typeof

http://www.nczonline.net/blog/2010/07/27/determining-if-an-object-property-exists/

Categories : JavaScript

Connecting to Amazon EC2 Linux instance using PuTTY

Mar 16, 2012

EC2 private key file has extension .pem , which cannot be used by PuTTY. So we have to convert .pem to .ppk format which PuTTY accepts.  Listing the steps below to do it,

  • Download PuTTYgen -  http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe

  • Launch PuTTYgen, Using the ‘Import’ command from the ‘Conversions’ menu, load the .pem file of EC2 and press  ’Save Private Key button’. Ignore warning about leaving the passphrase blank.  The file will be saved with .ppk extension

  • Now launch PuTTY, go to SSH panel, ‘Private key file for authentication’ load the .ppk file, and now you can use PuTTY to connect to the EC2 instance.

References:

Categories : SSH   Linux   Cloud

Using Ubuntu GUI remotely using NoMachine or Xming from Windows 7

Mar 12, 2012

Solution 1: NoMachine

Steps:

Solution 2: Xming

Steps:

Problem: Graphical programs are very slow.

Solution:  Enabling “SSH compression” might help if you use a low bandwidth connection. The option is under Connection > SSH in the left menu of PuTTY. ( http://doc.es.aau.dk/it_services/software/windows/putty_and_xming/)

Conclusion:

I am using  NoMachine, as Xming(6.9.0.31) was slow even after using SSH compression. And the latest version of Xming(7.5.0.45), which possibly has fixes for slow GUI ( http://www.straightrunning.com/XmingNotes/) was not  available for free.

Categories : Linux   Ubuntu

Running Spotify(Free) for Windows in Ubuntu 11.10 (oneiric) using Wine

Dec 3, 2011

*Make sure you have Wine installed  http://www.winehq.org/download/ubuntu

*Dowload Spotify for Windows from http://www.spotify.com/us/download/windows/

*Open the downloaded “Spotify Installer.exe” to install Spotify through Wine

*Now open a console and run the following command (this step is to solve Spotify crash issue - reference  http://getsatisfaction.com/spotify/topics/spotify_crashes_at_start_on_ubuntu_11_04_with_wine)

*winetricks winhttp

*Now in your Desktop click on the Spotify launch icon to launch Spotify

*Login with your Spotify account and enjoy free Music

Categories : Linux   Ubuntu   Music

How to setup MCE IR Remote for XBMC

Sep 24, 2011

IR Remote model which I am using is “Noah Company MediaGate HA-IR01SV Windows Vista Home Premium and Windows Vista Ultimate MCE Remote Control, 1 Channel IR (Silver)”.

Steps to get it working*Connect the IR receiver to the USB port.

*Install lirc

sudo apt-get install lirc

*In the configuration page shown for lirc during installation, you have to choose the type of remote. Here choose as “Windows Media Center Transceivers/Remotes (all)”. Select OK

*For any of the other selections asked in next configuration pages, proceed with the default option selected.

*To test if setup is proper, open console and enter command “irw”. It should appear to hang, now press buttons in the remote, and you should see the key presses printed on the terminal. Now you are ready to use your remote with XBMC.

References

https://help.ubuntu.com/community/LIRC

Categories : Linxu   XBMC