This website is dedicated to common, day to day programming and database related Frequently Asked Questions. Popular Programming and Database Articles under one blog
Wednesday, November 4, 2009
Masked Input plugin
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
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
Tuesday, September 1, 2009
Improving Performance by Profiling PHP Applications
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
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?
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?
{
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?
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
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?
Select Col1, Count(Col1) as count
from table1
group by Col1
having Count(Col1) > 1
.
Formatting DateTime to Date in SQL
Output: 04/16/2009
Select convert(varchar(10),GetDate(),103)
Output: 16/04/2009
Rounding a number to 2 decimal places in SQL
Select convert ( decimal(8,2) , 9.4125 )
Output: 9.41
What is Windows Presentation Foundation (WPF)?
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
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 ?
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).
What is static class?
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:
-
They only contain static members.
-
They cannot be instantiated.
-
They are sealed.
-
They cannot contain Instance Constructors (C# Programming Guide).
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 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