affiliate_link

Wednesday, November 4, 2009

Masked Input plugin

Sometimes it is required to use a masked input box on a webpage for this i use the following
jQuery library. It allows a user to more easily enter fixed width input where you would like them to enter the data in a certain format (dates,phone numbers, etc).

http://digitalbush.com/projects/masked-input-plugin/#demo

Wednesday, October 21, 2009

Cool Tooltip - JQuery

Please refer to the following page for demo

http://cssglobe.com/lab/easytooltip/03.html

To download code

http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin

Wednesday, September 9, 2009

Top 7 PHP Security Blunders

PHP is a terrific language for the rapid development of dynamic Websites. It also has many features that are friendly to beginning programmers, such as the fact that it doesn't require variable declarations. However, many of these features can lead a programmer inadvertently to allow security holes to creep into a Web application. The popular security mailing lists teem with notes of flaws identified in PHP applications, but PHP can be as secure as any other language once you understand the basic types of flaws PHP applications tend to exhibit.

Tuesday, September 1, 2009

Performance Tuning Best Practices for MySQL



Improving Performance by Profiling PHP Applications

One of the best things about programming in PHP is how easy it is to learn the language and its libraries. Everything seems to fit together and you can almost guess how to do a specific task, even not knowing much about the function that you need to use. A lot of times you will just try doing something and be surprised that the language has that specific feature.


PHP performance tips

Profile your code to pinpoint bottlenecks

Before changing your code, you'll need to determine what is causing it to be slow. You may go through this guide, and many others on optimizing PHP, when the issue might instead be database-related or network-related. By profiling your PHP code, you can try to pinpoint bottlenecks.

Friday, August 28, 2009

PHP global arrays


The Global Array List


Old Form New Form Description
-- $GLOBALS[] The complete list of all global variables, including user defined variables at the global level.
$HTTP_GET_VARS[] $_GET[] All variables received as part of a query string in the requesting URL, or HTML form data transmitted using the GET method.
$HTTP_POST_VARS[] $_POST[] All variables recieved as an inline posted data set, normally through using the POST method in an HTML form.
$HTTP_POST_FILES[] $_FILES[] References to all files received, most commonly from HTML forms, using the POST method.
$HTTP_COOKIE_VARS[] $_COOKIE[] Any cookies returned from the client. The index key name matches the cookie name.
-- $_REQUEST[] A more recent addition that stores all user variables, including elements from the $_GET[], $_POST[], and $_COOKIE[] arrays. Prior to PHP4.3, this also includes the $_FILES[] array.
$HTTP_SERVER_VARS[] $_SERVER[] Information about the server session and the HTTP connection with the client.
$HTTP_ENV_VARS[] $_ENV[] Information about the server environment and system defined values.
$HTTP_SESSION_VARS[] $_SESSION[] IF PHP is being used for session management, this array is to store any session variables that need to be stored on the server between calls from the client.




MySql - InnoDB vs MyISAM

Most people who use MySQL know that MyISAM and InnoDB are the two most-common database engines available with the popular open-source database provider.

Storage Engine

The storage-engine is what will store, handle, and retrieve information for a particular table. As hinted by the opening of this article, there is no be-all end-all solution to every or even most cases. Each has very specific pros and cons that by design can not be all-inclusive of each other.

What is a full text search in mysql?

According to the MySQL manual, Full-text is a “natural language search”; it indexes words that appear to represent the row, using the columns you specified

MySQL has had FULLTEXT searching in one form or another since version 3.23.23. FULLTEXT indices in MySQL allow database administrators and programmers to designate any character-based field (CHAR, VARCHAR, or TEXT) as a FULLTEXT index, which allows for complex text searching against data stored in those fields.

Tuesday, June 16, 2009

How Can I Use Javascript to Allow Only Numbers?

function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}

Add the following to the onkeypress event of your text box

return isNumberKey(event)

Wednesday, May 6, 2009

What is Referential Integrity?

Referential integrity is a database concept that ensures that relationships between tables remain consistent. When one table has a foreign key to another table, the concept of referential integrity states that you may not add a record to the table that contains the foreign key unless there is a corresponding record in the linked table. It also includes the techniques known as cascading update and cascading delete, which ensure that changes made to the linked table are reflected in the primary table.

Reference: http://databases.about.com/cs/administration/g/refintegrity.htm

Friday, April 17, 2009

Stop Youtube from displaying related videos once playback of the initial video starts

To stop displaying related videos we can add a parameter (rel=0 for stop displaying) to the url of the embedded code provided by you tube. See example below

http://www.youtube.com/v/u1zgFlCw8Aw&fs=1&rel=0

For complete list of parameters check the following Google API site:

http://code.google.com/apis/youtube/player_parameters.html

Thursday, April 16, 2009

Finding duplicates with SQL?

Suppose Col1 is the field name for which you want to find duplicates:

Select Col1, Count(Col1) as count
from table1
group by Col1
having Count(Col1) > 1

.

Formatting DateTime to Date in SQL

Select convert(varchar(10),GetDate(),101)

Output: 04/16/2009

Select convert(varchar(10),GetDate(),103)

Output: 16/04/2009

Rounding a number to 2 decimal places in SQL

Use T-SQL Convert Function.

Select convert ( decimal(8,2) , 9.4125 )

Output: 9.41

What is Windows Presentation Foundation (WPF)?

Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of both standalone and browser-hosted applications. Some examples are Yahoo! Messenger and the New York Times Reader.

The core of WPF is a resolution-independent and vector-based rendering engine that is built to take advantage of modern graphics hardware. WPF extends the core with a comprehensive set of application-development features that include Extensible Application Markup Language (XAML), controls, data binding, layout, 2-D and 3-D graphics, animation, styles, templates, documents, media, text, and typography. WPF is included in the Microsoft .NET Framework, so you can build applications that incorporate other elements of the .NET Framework class library.

Reference: http://msdn.microsoft.com/en-us/library/aa970268.aspx

Wednesday, April 15, 2009

What is LINQ?

Strings act like value types in .Net?

System.String is a reference type in .NET. Don’t let anyone mislead you into thinking otherwise. You’ll hear people saying strings “act like value types”, but this doesn’t mean the runtime makes a copy of the string during assignment operations, and it doesn’t make a copy of a string when passing the string as a parameter.

The equality operator and String.Equals method compare the values of two string objects, and you won’t find a property or method on System.String with the ability to modify the contents of a string – only return a new string object. Because of these two behaviors we sometimes say strings have value type semantics (they feel like value types), but strings are reference types in the runtime. An assignment operation does not copy a string, but assigns a reference. The value given to a string parameter in a method call is the reference, not a copy of the string’s value.

using System;

class Class1

{

[STAThread]

static void Main(string[] args)

{

string s1 = "Hello";

string s2 = s1;

// this test will compare the values of the strings

// result will be TRUE since both s1 and s2

// refer to a string with the value "Hello"

bool result = String.Equals(s1, s2);

Console.WriteLine("String.Equals(s1, s2) = {0}", result);

// next we will check identity

// ReferenceEquals will return true if both parameters

// point to the same object

// result will be TRUE -both s1 and s2reference

// the same object.

// strings are reference types

// there is no copy made on assignment (s2 = s1)

result = Object.ReferenceEquals(s1, s2);

Console.WriteLine("Object.ReferenceEquals(s1, s2) = {0}", result);

// now we will make a copy of the string

s2 = String.Copy(s1);

// compare string values again

// result will be TRUE - both s1 and s2

// refer tostrings with the value of "Hello"

result = String.Equals(s1, s2);

Console.WriteLine("String.Equals(s1, s2) = {0}", result);

// check identity again

// result will be FALSE

// s1 and s2 point to different object instancesbecause we forced a copy

result = Object.ReferenceEquals(s1, s2);

Console.WriteLine("Object.ReferenceEquals(s1, s2) = {0}", result);

}

}

Reference: http://odetocode.com/Blogs/scott/archive/2005/07/21/1961.aspx

String Reference or Value type in .Net?

string is reference type but really special one. When you do operation of both string values like in your example
C = A, there is nothing in this operation simular to normal class behavior. So C doesn't have a reference of A. In that operation, a new string class is created and the value from string A is copied to string C. String C and String A are pointing in completly different memory address. That is way, when you have many string operation, for example loop and in every iteration you have a string manipulation, because of new string class generation, that operation is performance leak. In that situation it is preffered to use StringBuilder. Why, because StringBuilder doesn't create new string for any string operation.

Now for question, why string is not value type and it's reference type.
When you have let's say int value, Int type has defined lenght and that is 4 byte. And for every value type you know the exact memory space that will take. But for string you don't know that. It will be stupid to have a string type in wich you should always define how long it is. And if you want to put in that string variable a value with bigger lenght that string is defined, that will be disallowed.
Why is string a special class. It is special because you have a reference class, but the way of using it, looks like a value type. So, that's why you do operation like:
string C = A, and not string C = new string(A);
You don't have to instance string class because .NET framework do that for you when you first time set it's value. If you not set it's value string has value of null like any other reference type. Every language platform has a special treatment for string type. .NET is not exclusion from that too.

Reference: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/6344698c-c92e-4562-966f-eae92195961d

Tuesday, April 14, 2009

What is Silverlight ?

Silverlight is a new cross-browser, cross-platform implementation of the .NET Framework for building and delivering the next generation of media experiences and Rich Interactive Applications(RIA) for the web. It runs in all popular browsers, including Microsoft Internet Explorer, Mozilla Firefox, Apple Safari, Opera. The plugin required to run Silverlight is very small in size hence gets installed very quickly.
It is combination of different technolgoies into a single development platform that allows you to select tools and the programming language you want to use. Silverlight integrates seamlessly with your existing Javascript and ASP.NET AJAX code to complement functionality which you have already created.
Silverlight aims to compete with Adobe Flash and the presentation components of Ajax. It also competes with Sun Microsystems’ JavaFX, which was launched a few days after Silverlight.
Currently there are 2 major versions of Silverlight:
Silverlight 1.0 and Silverlight 2.0( previously referred to as version 1.1).

Strongly typed vs weakly typed ?

Describe SVN ?

What is static class?

Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class. Static class members can be used to separate data and behavior that is independent of any object identity: the data and functions do not change regardless of what happens to the object. Static classes can be used when there is no data or behavior in the class that depends on object identity.

A class can be declared static (in c#) , indicating that it contains only static members. It is not possible to create instances of a static class using the new keyword. Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.

Use a static class to contain methods that are not associated with a particular object. For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. You could use a static class to hold those methods.

The main features of a static class are:

Creating a static class is therefore much the same as creating a class that contains only static members and a private constructor. A private constructor prevents the class from being instantiated.

The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created.

Static classes are sealed and therefore cannot be inherited. Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.

Reference: http://msdn.microsoft.com/en-us/library/79b3xss3(VS.80).aspx

What is partial class?

One of the language enhancements in .NET 2.0—available in both VB.NET 2005 and C# 2.0—is support for partial classes. In a nutshell, partial classes mean that your class definition can be split into multiple physical files. Logically, partial classes do not make any difference to the compiler. During compile time, it simply groups all the various partial classes and treats them as a single entity.

One of the greatest benefits of partial classes is that it allows a clean separation of business logic and the user interface (in particular the code that is generated by the visual designer). Using partial classes, the UI code can be hidden from the developer, who usually has no need to access it anyway. Partial classes will also make debugging easier, as the code is partitioned into separate files.

referenced: http://www.devx.com/dotnet/Article/22603