CSS Font Shorthand Property

CSS Font Shorthand Property

Posted in CSS Basic Ideas, CSS Shorthand Codes, Fonts | Tagged | Leave a comment

The Difference Between “Block” and “Inline” elements in CSS

The Difference Between “Block” and “Inline” elements: Read this tutorial

Posted in CSS Basic Ideas, CSS Tutorial | Tagged | Leave a comment

Get Current file path,Directory Path, Parent Directory Path in PHP

$module_name = basename(dirname(__FILE__));
__FILE__ returns the filename of the script that is currently being run.
dirname returns the directory of a given filename.
basename() returms the filename component of path. To put it better: it strips any “parent” directories off a given string.

The constant __FILE__ in PHP always returns the absolute path to the script file that’s currently active – the PHP file in which the code line is being run right now. Function dirname() returns the directory part of the given path.

Continue reading

Posted in PHP Tutorial | Tagged , | Leave a comment

Using web font – Part 2

CSS @font-face rule, a way of linking to TrueType and OpenType fonts today. Safari has supported this type of font linking since version 3.1, and Opera has announced that they plan to support it in Opera 10.

Using @font-face for font linking is relatively easy. In a stylesheet e.g stylesheet.css, each @font-face rule defines a font family name to be used, the font resource to be loaded, and the style characteristics of a given face such as whether it’s bold or italic.
Continue reading

Posted in Fonts | Tagged , , | Leave a comment

Using Web Fonts- Part 1

I have a beautiful font and I want to use this font in y website. I want to make sure that everyone can see this font using any operating system or browser. What shall I do for it. What is the CSS code to use a font in my webserver. The first step I have made that I have uploaded the font file in my website (running in a web server) using FTP method. Then what CSS code I shall use to use this font?

Continue reading

Posted in CSS Tutorial, Fonts | Tagged , | Leave a comment

Static member function in C++

Static data types can be accessed without instantiation of the class in C++. This is applicable for static functions also. The static member functions are accessible even when the class is not instantiated.

The Properties of static member function in C++ :

  • can be called, even when a class is not instantiated
  • cannot be declared as virtual.
  • cannot access THIS pointer.
  • Can access only – static member data, static member functions, data and functions outside the class.

The differences between a static member function and non-static member functions are as follows.

  • A “static member function” can access only “static member data, static member functions and data and functions outside the class”. A non-static member function can access all of the above including the static data member.
  • A static member function property : can be called, even when a class is not instantiated.
  • Non-static member function property : can be called only after instantiating the class in an object.

  • A static member function property : cannot be declared virtual.
    Non-static member function property : can be declared as virtual
  • A static member function property : Cannot have access to the ‘this’ pointer of the class.
Posted in Programming Concepts | Tagged , , , | Leave a comment

JavaScript / Any language: Delete a specific array element and shift other elements after deletion

How to delete a specific array element and shift other elements after deletion in JavaScript or any other programming languages

Here I have used an array , to be precise, predefined fixed array I have used here.
Initial array is [15,10,20,22,1,3,6].

Then I have decided to delete an item based on a comparison, here I have chosen to delete item 20.
After deletion the array will be : [15,10,22,1,3,6]

Initially after assigning the array by the statement var myArray = [15,10,20,22,1,3,6];
myArray[0]=15,
myArray[1]=10,
myArray[2]=20,
myArray[3]=22,
myArray[4]=1,
myArray[5]=3,
myArray[6]=6 and
array length = 7 found by the statement myArray.length;

After deletion the the item 20 will be deleted i.e myArray[2] and (after delete) myArray[2] will hold (before delete) myArray[3] i.e 22, (after delete) myArray[3] will hold (before delete) myArray[4] value i.e 1.

So , after deletion the array elements will be as follows :
myArray[0]=15
myArray[1]=10
myArray[2]=22
myArray[3]=1
myArray[4]=3
myArray[5]=6
array length = 6

Below we have used JavaScript splice() method, but this shifting and delete can be done without this method. I am giving you a hint.

I have not used this splice() method in the following JavaScript code snippet, you can use it also instead of the code in Gray.

Make deletion and shifting without splice() method in JavaScript. The following algorithm will work in any programming language.

The algorithm :
Step1: first reach the item which you want to delete by a FOR LOOP,
Step 2: Then get the ARRAY INDEX of that element.
Step 3: Then assign next array element to that element. Assign next array element to that element to shift and continue the process.

// Make shifting a global variable.
var shifting = 0;
for(var i = 0; i <= myArray.length-1; i++)
{
if(myArray[i] == 20)
shifting = 1;
if(shifting == 1)
myArray[i] = myArray[i+1];
}

Delete an array element and shift the rest of the element by the help of SPLICE() method in JavaScript.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var myArray = [15,10,20,22,1,3,6];
document.write("<br />"+myArray);
document.write("<br />Before delete Array Length : "+myArray.length);
for(var i = myArray.length-1; i >= 0; i–)
{
if(myArray[i] == 20)
{
myArray.splice(i,1);
}
}
document.write("<br />After deleting item 20 the array becomes : "+myArray);
document.write("<br />Array Length : "+myArray.length);
</script>
</head>

<body>
</body>
</html>

Posted in Array, JavaScript | Tagged , , , , | Leave a comment

Sorting arrays in Javascript, Numeric sorting

If you normally sort an array, then it is sorted alphabetically or lexically.

<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
var myarray = [10,1,100,23,2,33,4];
myarray.sort();
document.write(myarray);
</script>
</head>

<body>
</body>
</html>

The output will be : 1,10,100,2,23,33,4
Because the array myarray is sorted alphabetically.

But if you want to sort it numerically then pass a function in argument as mentioned below.

<html>
<head>
<script type="text/javascript">
var myarray = [10,1,100,23,2,33,4];
myarray.sort(function f(a,b) { return a-b; });
document.write(myarray);
</script>
</head>

<body>
</body>
</html>

Posted in Array, JavaScript | Tagged | Leave a comment

Mastering JavaScript Arrays, Know in details

The best tutorial I have found on JavaScript Arrays till date is here :
http://www.hunlock.com/blogs/Mastering_Javascript_Arrays

  • Creating A New Array
  • Initializing An Array
  • Storing Data In An Array
  • Multi-Dimensional Arrays
  • How JavaScript Arrays are passed to a function : Javascript Arrays Are Passed By Reference
  • Javascript Arrays Are Assigned By Reference
  • Passing Arrays As Values
  • Array.length
  • Javascript Does Not Support Associative Arrays
  • Array Methods Reference
Posted in JavaScript | Tagged | Leave a comment

jQuery Form Validation without and with Plugins

Custom contact us page for WordPress using jQuery Contact Form without a Plugin :

http://trevordavis.net/blog/wordpress-jquery-contact-form-without-a-plugin/


10 Useful jQuery Form Validation Techniques and Tutorials
http://speckyboy.com/2009/12/17/10-useful-jquery-form-validation-techniques-and-tutorials-2/


Posted in JQuery | Leave a comment