Posted by: Asit | April 7, 2009

Badi Mushkil se Duniya me Dost Milte Hai….

This is a line of a famous Hindi song by Kishor Da. This line completely fits to my friends. 

My father got a major heart attack and I was in Bangalore. I had to rush to my native place, Kanpur. Before leaving, I just informed one of best friend around me about my arrival. I informed other and he booked the flight ticket on-line. I reached Delhi then from there I took train and reached Kanpur. I was trying to grab an auto, but what I saw another friend already waiting for me. He took me directly to the hospital where papa was admitted. Within half an hour all my true friends gathered at the hospital and offered to stay there for any kind of requirement.

We 5 guys stayed at the hospital for full 7 nights without a single nap for a single minute. In that span of time all of them slept just for 2-3 hours in day time. Although all of them were very busy in there work schedule and one of them was fasting for 8 days due to Navrata, they took care of my dad with me. Although they are not strong financially, they offered the financial support. But at that time I required moral support very badly which they provided just by their presence.

Now my dad is out of danger and about to be released from the hospital within 2-3 days. After being assured about papa’s health, I came back to Bangalore, but friends are still there supporting my family. I will not give thanks to them for their efforts but will pray to God to make me available whenever any of my friends seeks my presence.

Posted by: Asit | March 26, 2009

Funny things about Ghajini:

Amir Khan’s latest released movie Ghajini is the biggest Bollywood hit of the year 2008. I have seen the movie and appreciated a lot. I could find good humor in the happy part of the movie. but the kids of this generation are smarter and more humorous than the adults. Want to know how? Just read below….

fun in Ghajini

Humor in Ghajini

Here I am going to show how one can create breadcrumbs in the web application based on Zend Framework. This can be achieved by creating a helper method. Before creating helper method, we need to do the following exercise:

  • Create Zend view object,
  • Add view script path,
  • Add the default helper path to the view object,

Now lets start step by step:

Creating Zend view object:

$view = Zend_View();

Adding view script path:

$viewPath = “path/to/viewsDirectory”;
$view->addScriptPath($viewPath);

Adding the default helper path to the vew object:

$helperPath = “path/to/helperDirectory”;      Zend_Controller_Action_HelperBroker::getStaticHelper(’viewRenderer’)->setView($view);
$view->addHelperPath($helperPath, ‘Helper_’);

Now creating the class for the breadcrumbs:

class Helper_BreadCrumbs {

public function breadCrumb(){
$cFront = Zend_Controller_Front::getInstance();
$module = $cFront->getRequest()->getModuleName();
$module = strtolower($module);

$controller = $cFront->getRequest()->getControllerName();
$controller = strtolower($controller);

$action = $cFront->getRequest()->getActionName();
$action = strtolower($action);

if($module == “default” && $controller == “index” && $action == “index”){
return;
}
//Home link
$home = ‘<a href=”/”>Home</a>’;

//start breadcrumbs
$bCrumbs = $home . “::”;
if($action == “index”){
$bCrumbs .= $controller;
}
else{
$bCrumbs .= “<a href=’/$controller’>$controller</a>::
<a href=’/$controller/$action’>$action</a>”;
}

return $bCrumbs;
}
}

Hope this article will help the web application users to indicate “where are you”.

Posted by: Asit | March 20, 2009

Zend Framework:: Caching the database query results

Caching is basically used to improve the performance of the application. Your application may consists of multiple expensive queries ruining the application performance.  The Zend_Cache component of Zend Framework provides a good feature to improve the page performance by caching the database query results. Here is the sample code :

// Creating the cache options
$frontend = array(
‘lifetime’ => 86400, // cache lifetime of 24 hours (time is in seconds)
‘automatic_serialization’ => true  //default is false
);

$cachedir = /path/to/cacheDirectory;
if(!is_dir($cachedir)){
mkdir($cachedir,0755);
}

$backend = array(’cache_dir’ => $cachedir);

// Getting a Zend_Cache_Core object
$zend_cache = Zend_Cache::factory(’Core’, ‘File’, $frontend, $backend);

$result = run_query($zend_cache);
print_r($result);

function run_query($cacheObj){
$q = “Database query”;
if(!$result = $cacheObj->cache->load(”myresult”)){
$db = Zend_Db::factory(DB_connection_parameters);
$result = $db->fetchAll($q);
$cacheObj->save($result, “myresult”);
}
else {
echo “This result is from cache.”;
}
return $result;
}

Caution: You should give the unique name in the “load(’name’) and save(’name’)” functions.
Otherwise you will get the same result on the pages where the query is intended to produce
different results.

Posted by: Asit | December 31, 2008

IE7.0-Expected Identifier or String…Bang the bug

Hi,

While testing my application, I was very happy by getting smooth run on the FireFox and Safari.  But when I tested that on IE7.0, I was banged with the error popup-

“Expected identifier or string”

on the very first page of the application. I started trying out putting few alerts on the very first javascript file loaded, but failed. After digging a lot, I found the way to get-rid-of this issue. Here is the soultion-

The problem JavaScript code was-

1    function txtCellEditor(){
2        var txt = new YAHOO.widget.TextboxCellEditor({
3                  asyncSubmitter: asyncUpdate,
4                  validator:YAHOO.widget.DataTable.validateNumber,
5                  });
6        return txt;
7    }

The main problem was the “,”(comma) at the line 4. I removed the comma and the application started working fine on IE7 also.

Actually for IE, there should be no comma after the function closing(after the braces{}), or the parameters passed to the functions or the class constructors. IE considers that as a new line.

Enjoy debugging……

Posted by: Asit | June 26, 2008

PHP-Showing image having name with “%2F”

If you want to display an image on an HTML page, you can simply use the <img> tag. But if the image name consists of the html entity “%2F”, it is difficult to do that. For example:

The image name is : foo%2Fbar.png

<img src=”/images/foo%2Fbar.png” title=”image” alt=”image” />

The html page will try to get the image from the directory: /images/foo/bar.png

This way the page will never get the image and won’t be able to display that. I have a trick to solve this problem. Here it is:

<?php

<html>

<p>The correct image is:

<img src=”<?php echo substr_replace(”/images/foo%2Fbar.png”, ‘%252F’, -10, -7) ?>” alt=”image” title=”image” />

</html>

?>

This code will display the image by replacing “%2F” with “%252F” and you will not be blamed to have extra subdirectories.

Posted by: Asit | April 29, 2008

Breaking News!!

breakinig news

You open the TV to get some news updates. You rush to a news channel who claims to be the best news channel. Suddenly you hold your breath seeing the Breaking News heading. The breaking news is:

Breaking News:: Tulsi ki wapasi………………

Your excitement ends up with frustration and irritation. You change the channel. After some time, you again reach the same channel, now the breaking news is::

Breaking News:: Mumbai ke zoo me ek magarmacchh ne anda diya……….

Now either you want to break your head or the TV. Obviously you don’t do any one. So you simply switch off the TV. After 1 hour you again open the TV with some hope. Now the best news channel is showing the clippings of some idiot Saas-Bahu daily soap which is becoming the epic in television history. Now I don’t have words to express your frustration level. Finally you start searching for the news paper having older but better news.

This is now the standard of news channels. They try to make the simple news, sensational. They have hours to discuss what Khali did in WWE, but don’t have even 5 minutes for successful launch of 10 satellites at one go. They have full time to discuss about Dhoni’s hair style but not to discuss about the people who spent their lives serving for society.

I suggest, they should claim to be the best entertainment channel.

Posted by: Asit | February 25, 2008

When my heart broke

Here you can see what happened, when I proposed the first girl in my life :-)

Posted by: Asit | February 1, 2008

Fool or lack of information!!

Few days back, I asked one of my good friend to send me some money. He agreed and went to the nearest ATM to deposit money. He simply filled all the information regarding my account on the envelop and drop that into the “Cheque Drop Box”. When I didn’t get the money after expected days, I called him to ask. When he told, what he did, I died of laugh at his foolishness. The amazing thing was, he doesn’t have account in that bank too.

After sometime I thought that, why to blame only his foolishness. People do lots of things carelessly. He may be dump but the banking system was also a big “Dump”. This is the responsibility of the “System ” to be informative enough to suggest right steps to use them. If someone is giving wrong input to any system, either software or hardware, the system is responsible. I think he should claim for his money but he doesn’t have any proof ( this is surely his foolishness :) ).

The banking system should provide “what to do” along with “what NOT to do(At least what mistakes one can do.)”.

I think bank should paste/print these on the envelop or on ATM centers:

1- You can not deposit cash here if you don’t have account with us.

2- Please do not drop cash in the “cheque drop box”.

3- You must have ATM card to deposit cash at ATM points.

Posted by: Asit | December 14, 2007

.NET Framework:: Basics

net.jpg

I am posting some basic questions on .NET Framework which will help the beginners.

1- What is .NET framework?
Ans :

Wiki defines

“The Microsoft .NET Framework is a software component that is a part of modern Microsoft Windows operating systems. It provides a large body of pre-coded solutions to common program requirements, and manages the execution of programs written specifically for the framework.”

Another one

A programming infrastructure created by Microsoft for building, deploying, and running applications and services that use .NET technologies, such as desktop applications and Web services. It provides a highly productive, standards-based, multi-language environment for integrating existing investments with next-generation applications and services, as well as the agility to solve the challenges of deployment and operation of Internet-scale applications.
.NET Framework consists of 3 main parts :

  • Common Language Runtime,
  • .NET Framework class library,
  • ASP.NET

2- What is CLR?

Ans :
CLR stands for Common Language Runtime. It is the implementation of CLI, Common Language Infrastructure which defines the execution environment for program code. The role of CLR starts after the compilation of the code written in the different languages by their respective compilers. The compiler converts the code into the CIL(Common Intermediate Language). The CLR’s just-in-time compiler converts this CIL code into the native code specific to the operating system at runtime. The CLR also provides other important services including:

  • Memory Management,
  • Thread Management,
  • Exception Handling,
  • Security,
  • Garbage Collection

3- What is CLI?

Ans:

This is the main component of .NET framework. CLI stands for Common Language Infrastructure. CLI is a “specification” which defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures. The implementation of CLI is known as CLR, Common Language Runtime. CLI describes four aspects:

  • Common Type System (CTS),
  • Metadata,
  • Common Language Specification (CLS),
  • Virtual Execution System (VES)

4- What is MSIL?
Ans:
MSIL stands for Microsoft’s Standard Implementation Language. Now it is known as CIL, Common Intermediate Language. This is the bytecode formed after the compilation of the program code.

5- What is CTS?
Ans:
CTS stands for Common Type System. It is a part of CLI. The .NET framework supports type definitions which are independent of any specific programming language, and CTS covers a range of topics related to type handling. These topics include type safety, cross-language sharing of typed data, type behavior and features, and performance.

6- What is JIT compiler?
Ans:
JIT stands for Just-in-time compiler and is a part of the CLR. JIT compiler, at runtime, compiles the CIL (bytecode) into the native code specific to the operating system.

7- What is CLS?
Ans:
Common Language Specification is a set of basic language features needed by many applications. It helps enhance and ensure language interoperability by defining a set of features that developers can rely on to be available in a wide variety of languages.

8- What is VES?
Ans:
VES stands for Virtual Execution System. It provides an environment for executing managed code. It also gives the support for a set of built-in data types, defines a hypothetical machine with an associated machine model and state, a set of control flow constructs, and an exception handling model.To a large extent, the purpose of the VES is to provide the support required to execute the Common Intermediate Language instruction set.

9- What are .NET Assemblies?
Ans:
.NET Assemblies contain the intermediate CIL code. Assemblies are stored in the Portable Executable (PE) format. It consists of one or more files, but one of these must contain the manifest, which has the metadata for the assembly. The complete name of an assembly contains its simple text name, version number, culture and public key token.

I will continue with some more stuff on different topics.

Older Posts »

Categories