Problems in India or India in Problems


Problems in India or India in Problem: bad education, corrupt politicians and entire system, inequality, inflation, rapes, terrorism, overpopulation, brain drain, malnutrition, gender inequality, pollution, slow legal system, only urban development leading to migration of people to urban areas, people like Mallya enjoying life and farmers dying everyday due to huge debts, never ending list…

Scrolling Menu using Jquery


Hi Guys..

In this post I want to share a method of how you can implement scrollable Menu on HTML page using
Jquery.
The steps to implement scrollable Menu are as follows: Demo is available here

1. Include the Jquery Library:

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>

2. Now, lets start with the menu which we want to be scrollable:

Let’s assign id as “scrollable-menu” to the menu:(The menu will be as under)

<div id="scrollable-menu">
<ul>
<li>Home</li>
<li>Pictures</li>
<li>Contact Me</li>
</ul>
</div>

3. Next is we start write the script code using jquery to implement the scroll:
Jquery has a function to handle the event scroll.

// This is the scroll event handler
$(window).scroll(function() {
//Write the action on scroll event here.
});

4. Lets get down on the action of moving the menu as we perform the action of scrolling:

$(window).scroll(function(){
$("#scrollable-menu")
.animate({"marginTop": ($(window).scrollTop()) + "px"}, "slow" );
});

Explanation:
$(window).scroll –> this is the function for scroll event for Window.
This event occurs whenever you scroll the window on browser and this
function will get executed.

$(“#scrollable-menu”) –> this is the selector which gets you the instance of DOM object
with id scrollable-menu and as we want to scroll the menu we are using its id

.animate is the function provided by jquery to perform custom animations on
object using CSS properties.

$(window).scrollTop() –> this is the function which provides us the numerical figure
of the amount of scroll performed on window
Ans using this value we are setting the margin-top value of Menu so, that it is
seen in the visible area of the page.
“slow” is the parameter of animate function to enable the animation on screen,
you can also use any numerical value in place of slow(it is in milli seconds)
More about animate function – here
More about scrollTop Function – here

5. Because this event can fire many times in a row we need to make sure we stop all previous repositions before progressing with the latest one. Imagine a users scrolls 3-4 times really fast. We want just the last call to be in control of the repositioning. Ensuring that all repositioning is stopped beforehand makes for much faster handling of the event, resulting in smoother animation. We call this BEFORE the code snippet above.

$(window).scroll(function(){
$("#scrollable-menu")
.stop()
.animate({"marginTop": ($(window).scrollTop()) + "px"}, "slow" );
});

6. One more way we can make the code smoother is storing the instance for the object that needs to be accessed
for every scroll event. Whenever the scroll event fires jQuery traverses the DOM looking for our element. In order to alleviate this overhead we can simply store the jQuery reference to our element in a variable when the DOM is initialised and reference this instead.

var $scrollableMenu = $("#scrollable-menu");

$(window).scroll(function(){
$scrollableMenu
.stop()
.animate({"marginTop": ($(window).scrollTop() + 30) + "px"}, "slow" );
});

7. The final Code will be as follows:

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script>
$().ready(function() {
var $scrollableMenu = $("#scrollable-menu");

$(window).scroll(function(){
$scrollableMenu
.stop()
.animate({"marginTop": ($(window).scrollTop() + 30) + "px"}, "slow" );
});
});
</script>

Thats all.. Jquery makes all simple.. 🙂 😀

Happy Birthday MOM


Its only your love mom
That brought me in this beautiful world
And gave best family in this world
Taught me how beautiful this world is..

Its just your love mom……
You hug me tight when I cry
You lift me up when I fall
You shaped my life like beautiful pot

Its just your love mom
You forgive all my silly mistakes
You fight for me against everything that come in my way
Your smile keeps me happy and alive

Its just your love mom
Now as I am far away from you
Its hard to show what I feel for you
You are tears in my eyes and smile on my face
I don’t say that I miss you because
You are always there with me like shadow ..so I say…

ITS ONLY YOUR LOVE MOM

Many Many Happy returns of the day to you MOM… 🙂
Reference: via @Shruti Zamwar

IE vs FF Working with dynamic Tables


Today I am gonna write another thing I came across while working on Javascript.
Sometimes, even if it’s easier to work with list <li> elements in HTML, but the design department may make a
design using tables.
Well what I wanted to do was read some information and dynamically create table and assign correct info to its
rows, columns.
Lets write the basic HTML code for table element:

<table>
<tr>
<td>Row1 Column1</td>
<td>Row1 Column2</td>
</tr>
<tr>
<td>Row2 Column1</td>
<td>Row2 Column2</td>
</tr>
</table>

So, looking at the table and other tags used with table, I made those elements using the Javascript Code.
The Code used to create table is as follows:

var myTable = document.createElement("table");
var myRow = document.createElement("tr");
var myCell = document.createElement("td");
myCell.innerHTML = "Hello World!";
myTable.appendChild(myRow);
myRow .appendChild(myCell);

Now, for this Javascript, Firefox was fine, but it did not worked on IE. So, I searched on Internet and then using
Firebug I noticed one thing that we also have another element inside table as <tbody> and this was the actual problem.
On FF it makes this element and adds it to the table tag. But, IE does not.
So, the new code that worked for both IE and FF is as under:

var myTable = document.createElement("table");
var myTbody = document.createElement("tbody");
var myRow = document.createElement("tr");
var myCell = document.createElement("td");
myCell.innerHTML = "Hello World!";
myTable.appendChild(myTbody);
myTbody.appendChild(myRow);
myRow.appendChild(myCell);

And, as you can see in the code above, I am manually creating the tbody element and appending it to the table.
And, the row element is appended to this tbody element.
Finally, the problem with creating tables dynamically was solved. 🙂
May this help you when u face similar problem.
Cheers.. 🙂

JSONP… and why JSONP


How to start.. ?

I am working on Ajax and I need to get some data, that is using XML.

If I am working on domain, lets say  mysite.com and I need to get some data using xml

from the same domain,  where the xml url is mysite.com/myxml.xml , So here you can direct

get the xml from this specific domain using HttpRequest.

But, what if you want data from some other domain, may be  othersite.com/.

So, here XML will not be of an use, as XML httpRequest works only for the same domain

i.e. the requester and the responder are the same domains.

So, you may say lets use JSON. But, here JSON is also of no use.

As, JSON is just a formatting of data for (similar to XML)XML.

But it is also of no use for Cross Domain data Access.

What is JSON:  JSON is Java Script Object Notaion. It is a lightweight data-interchange format.

The JSON filename extension is .json.

JSON is an alternative to XML and it is more easy to access than XML.

So if XML is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<contacts>
    <contact id="1">
        <name>Anu Zamwar</name>
        <phone>123-456-7890</phone>
        <address>
            <street>123 JFKStreet</street>
            <city>Any Town</city>
            <state>Any State</state>
            <zipCode>12345</zipCode>
        </address>
    </contact>
</contacts>

So, JSON for this XML will be as:

{
   "contacts" : {
      "contact" : {
         "@attributes" : {
            "id" : "1"
         },
         "name" : "Anu Zamwar",
         "phone" : "123-456-7890",
         "address" : {
            "street" : "123 JFK Street",
            "city" : "Any Town",
            "state" : "Any State",
            "zipCode" : "12345"
         }
      }
   }
}

So, now let me get back to the point, how to overcome the problem of Cross Domain Data Access.

JSONP is a means by which to get JSON data from another

domain than the one your page is on.

If you try and use Ajax to request data from a different

domain than the page, you’ll get a security error.

One way around this is a concept some call “JSONP”.

This is where you include a script tag in your document. This script

tag points to an external javascript source and when the

script tag loads it executes (like any other script tag).

The catch is that you need to be able to tell that server what

to wrap the data with so your functions can handle it.

Let’s say we are on this page at clientcide.com.

Let’s say we want to get some data from the flicker api at flicker.com/services/api.

Here’s a simple request that gets the latest photos:

http://www.flickr.com/services/feeds/photos_public.gne?format=json

To Overcome this problem of Cross Domain Data Access, JSONP comes into picture. What is JSONP?

I asked this to Google and he gave me few answers as always. You can also get some from googly..

So, whats the difference between JSON and JSONP. Both are same, except the difference that in JSONP,

you also include a call back function name. So, when u need to get the data of this JSONP using AJAX,

you need to tell AJAx the name of the call back Function defined in JSONP file.

How will the above JSON look when written as JSONP:

func({
   "contacts" : {
      "contact" : {
           "@attributes" : {
                 "id" : "1"
            },
         "name" : "Anu Zamwar",
         "phone" : "123-456-7890",
         "address" : {
            "street" : "123 JFK Street",
            "city" : "Any Town",
            "state" : "Any State",
            "zipCode" : "12345"
         }
      }
   }
});

⇒ func is the Callback function, used in the above JSONP file.
Now let this above JSONP file name be myjsonp.json

and it is under domain → http://www.othersdomain.com/myjsonp.json

And you domain is http://www.mydomain.com/

I am using Jquery.ajax to show the working with JSONP. Code is as follows:

$.ajax({
url: "http://www.othersdomain.com/myjsonp.json", //URL of JSONP File
dataType: "jsonp",  // Data type is JSONP
processData: false, // No need to process Data, we use it as JSONP
jsonpCallback: "func",  // Callback function
success: function(data,textStatus,obj) {
var name = data.contacts.contact.name;
alert("Name is: " + name);

} });

So, here it is the use of JSONP to over come the problem of Cross Domain Requests..

🙂

Mother Oh Mother..


I dedicate this poem to my mother.. Love you the most..
————
I was a just-born and she was Twenty-Five,
Though we were we, we were one.
I would cry out and she would respond in love always,
I would learn nothing but she never got tired to teach.

I was surrounded by monsters eager to pull my cheek,
but they would vanish the moment I was wet and weep.
She would come running and hold me in her arms,
as if I had won the contest of the charms.

Now I was able to walk and chew,
and hey, I was two.
I and she could now understand each other,
I was her everything and she needed no other.

I would try to walk and fall down,
But knowing she was with me,
the fear of getting hurt was now gone.
We still could not converse that effectively,
But she would understand my needs so easily.

I could now roam about free,
because now I have turned three.
I was ready to join a new world,
my academic life was now gonna mould.

She would dress me as best as a prince,
but when I would come back,
she would need at least an hour to rinse.
I was now able to talk,
I was a ferry and she was my dock.

I still remember the child, whose shirt I had tore,
Hey buddy, I have turned four.
I now came home a little late,
Nevertheless finding her waiting at the gate.
She would hug me and carry me in her arms,
it felt like flying through the farms.
We now did the homework together,
I would spoil the home and she used to work.

Years passed and now I was eighteen,
and with each year I would forget to lean.
I wouldn’t care for what she said,
because now I had become mean.
She would ask me to study for a good future,
but I was busy in a different culture.
Now I had many shes in my life,
I dreamed of having one of them as my wife.

I changed a lot which she did not teach,
She would try to hug me but I was out of reach.
She still waited for me at the gate,
but I would look at her with utmost hate.
She would be awake till late in the night,
because I wasn’t home, I was enjoying somewhere.
She had so much to scold, but she never did say,
hoping to find me better the next day.
Time went on and now I am grown,
lost in the world of my own.

I and she, between us have a river,
I have left her for my career.
When I was young, for me, she sacrificed her ambitions,
but I don’t care, I now have my own mission.
I am not with her now, I am in a different city,
she is so old now but I don’t even pity.

She needs me now but I am nowhere to find,
in the race for appraisal, I have become blind.
In a few years from now, I will be two,
there will be in my life someone new.
Then I’ll forget even to bother,
I am her son and she is my Mother
———————————

Nice rhyme and a good meaning. 😀

Lucid Lynx — Ubuntu 10.04


After Every six months(April and October), I am waiting for release of the .04 and .10 version of Ubuntu Systems. I am always eager to see the updates in the updated versions. And so,  here I am waiting for the April Version of Ubuntu 10.04, named asLucid Lynx“.

So Lets take a look on to what are the features in Lucid Lynx: The new style in Ubuntu is inspired by the idea of “Light“.

New Logos:

1. Gnome 3 though awaited to be there in the release. Lucid still has Gnome 2.x version used in it. So there will not be many changes in the look and UI part. It is of course to be expected that Gnome 3 will have a lot of rough edges at its birth, which again doesn’t make it ideal in a LST release.

The upcoming Gnome 3 that is to be released early 2010, can already be tested in an early stage in Ubuntu 9.10. If you want to test the Gnome Shell, install the package “gnome-shell“,

open a terminal and enter the command gnome-shell –replace&“.

2. More Fast Boot: After using Ubuntu 9.10, I am sure that the system boots extremely fast, takes very very little time.  And I suppose that 10.04 will also lead to the same experience. Boot speed has been a hot topic for a long time now and Ubuntu has come a long way in the last few releases. For Ubuntu 10.04 the target boot speed is 10 seconds! The reference platform for this target is a Dell Mini 9 netbook with a slow CPU and fast SSD that makes it an excellent “middle of the road” machine.  Some people’s machines will be slower, some will be faster.There’s also a plan to improve the speed on the installation process. Currently when installing packages in Ubuntu the download is a separate step from the unpack/configure. Ubuntu will be able to install package faster by doing downloads and installs in parallel. While downloading the cpu and disk are mostly idle. While installing the network is idle. Doing them in parallel is a good way to utilize both systems.
Under the hood Ubuntu 10.04 will also be switching to using a swap file, instead of a separate partition. This will allow on-the-fly resizing.

A graphical OS selector is planned for switching (rebooting) between two or more operative systems. The preferred version of the graphical OS selector will have easily recognizable logos for the installed OSs. This will require a lot of work and might not actually land in 10.04.

3. New Boot Splash :

Ubuntu Splash

4. Some other Features:

Mozilla FireFox: Default search engine has been changed to Yahoo! Default Home Page will use either Google or Yahoo! depending on user setting.

Linux Kernel: It includes the 2.6.32-14.20 kernel based on 2.6.32.8.

The likewise-open package, which provides Active Directory authentication and server support for Linux, has been updated to version 5.4. The package supports upgrades from both the officially supported versions 4.0 (Ubuntu 8.04 LTS) and 4.1 (Ubuntu 9.10), as well as the likewise-open5 packages from universe. Since this upgrade involves a lot of configuration file changes and in-place database upgrades, testing and feedback is appreciated.

SNS-> Go Social: Ubuntu now feature built in integration with Twitter, identi.ca, Facebook, and other social networks with theMeMenu in the panel, which is built upon the Gwibber project, which has a completely new, more reliable backend built on top of desktopcouch. Gwibber now also supports a multi-column view for monitoring multiple feeds simultaneously.

Ubuntu 10.04 Lucid Lynx

Ubuntu 10.04 Lucid Lynx

Ubuntu 10.04 will be out on 29th April, 2010

Want to know about Ubuntu More.

Cheers….

Helping those who need help 😀