#hackersagainstdiscrimination

Posted: March 27th, 2011 | Author: | Filed under: Uncategorized | Comments Off

I have started painting using watercolors again. It’s a beautiful feeling. I realized that I could create different skin colors using the paint and that can either lead to a cartoon like these or something different. Just loved this idea!

Disclaimer – This is the first time I tried drawing Tux.


PHP-JSON Special Characters

Posted: January 28th, 2011 | Author: | Filed under: Uncategorized | Tags: , , , , | Comments Off

Wanted to share this with the group since it took me 3 hours to figure this out.

I was trying to retrieve JSON data from a third party service using a PHP.
In PHP , if you use curl_exec() functions to retrieve JSON data, it returns it in a string form. You can do json_decode($string, true) to retrieve it in an associative array form.

$url = "www.example.com/data.json";
	$curl = curl_init();
	curl_setopt( $curl, CURLOPT_URL, $url );
	curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
	$result = curl_exec( $curl );
	curl_close( $curl );
        $return = json_decode( $result, true);
        echo $return["description"];

All is fine if your json data doesn’t have special characters like “é”, for example

{
"description":"Eric Benét performs.",
"origAirDate":"2011-01-27", 
"stationId":11269,
"endTime":
"Thu Jan 27 11:00:00 EST 2011","startTime":"Thu Jan 27 10:00:00 EST 2011",
"title":"The Wendy Williams Show",
"isVisible":true,
"rating":"TV-PG"
}

To handle these special characters make sure that you do

 $result = utf8_encode($result); // before json_decode
 $return = json_decode( $result, true);
 echo $return["description"];

Source

Hope this helps


ns2.34 setup on Ubuntu Lucid Lynx 10.04

Posted: September 17th, 2010 | Author: | Filed under: technical, Uncategorized | Comments Off

Setting up ns2 on Ubuntu (Lucid Lynx 10.04),

$ sudo apt-get update
$ sudo apt-get install build-essential autoconf automake libxmu-dev libxt-dev libxt6 libsm-dev libsm6 libice-dev libice6 vim

Download ns-allinone.2.34.tar.gz – http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/

$ tar -xvzf ns-allinone.2.34.tar.gz
$ cd ns-allinone.2.34/
$ ./install

You might hit the error
otcl-1.13 make failed! Exiting

Solution
in otcl-1.13/configure file -
replace

Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="ld -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""
;;

with

Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="gcc -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""
;;

This should work now.
Note for this to work the CC value in Makefile.in inside otcl folder should be @CC@. It did not work when I changed it to gcc 4.3
Hope this helps