Wednesday, 28 May 2014

Purpose of the '@' symbol in CSS 0

@ has been around since the days of @import in CSS1, although it's arguably becoming increasingly common in the recent @media (CSS2, CSS3) and @font-face (CSS3) constructs. The @ syntax itself, though, is not new.

These are all known in CSS as at-rules (@). They're special instructions for the browser, not directly related to styling of (X)HTML/XML elements in Web documents using rules and properties, although they do play important roles in controlling how styles are applied.

Some code examples:
/* Import another stylesheet from within a stylesheet */

@import url(style2.css);

/* Apply this style only for printing */

@media print {

    body {

        color: #000;

        background: #fff;



/* Embed a custom web font */

@font-face {

    font-family: 'DejaVu Sans';

    src: local('DejaVu Sans Regular'), url(/fonts/DejaVuSans.ttf);

  • @font-face rules define custom fonts for use in your designs that aren't always available on all computers, so a browser downloads a font from the server and sets text in that custom font as if the user's computer had the font.
  • @media rules, in conjunction with media queries (formerly only media types), control which styles are applied and which aren't based on what media the page is being displayed in. In my code example, only when printing a document should all text be set in black against a white (the paper) background. You can use media queries to filter out print media, mobile devices and so on, and style pages differently for those.
At-rules have no relation to selectors whatsoever. Because of their varying nature, different at-rules are defined in different ways across numerous different modules.

More examples include:
(this list is far from exhaustive)

You can find another non-exhaustive list at MDN. 

Some at-rules (@) available in CSS
source page
Have any doubt, feel free to comment here! 

Tuesday, 27 May 2014

Difference between Math.floor() and Math.round() 0

 Math.floor(x) , Math.round(x)


  • Math.floor(x) and Math.round(x)  expects floating number as parameter.
  • Math.floor(x) 
    • The floor() method rounds a number DOWNWARDS to the nearest integer, and returns the result.
    • If the passed argument is an integer, the value will not be rounded.
  • Math.round(x) 
    • The round() method rounds a number to the nearest integer.
Main Difference 

  • Math.floor(x)  
    • If the parameter is 3.51, it will be rounded DOWNWARDS (out put 3).
  • Math.round(x) 
    • If the parameter is 3.49, it will be rounded DOWNWARDS (out put 3).
    • If the parameter is 3.50, it will be rounded UPWARDS (out put 4).
Have any doubt, feel free to comment here!

Monday, 26 May 2014

Jquery - check if at least one checkbox is checked 3

     In some situation we need at least one user input in check box to submit form. In that case, we should check if at least one check box is checked. So, we can simply check that condition in .click event listener of check box.

     Here we are going to enable Submit Form button at least any one of check box is checked.

$("input[type='checkbox']").click(function () {
        "disabled", !$("input[type='checkbox']").is(":checked"));
     From the above code  !$("input[type='checkbox']").is(":checked") will return switched value of boolean out put. 
If $("input[type='checkbox']").is(":checked") return true, output will be false.
If $("input[type='checkbox']").is(":checked") return false, output will be true.

     Because, if any one of the check box is checked, It will return true. So, we need change button's disabled attribute to false. For that we are using ! to change true to false and false to true .

Here is the DEMO.

Have any doubt, feel free to comment here!

Friday, 23 May 2014

How to check current day is the last day of the month in php 0

We can simply use PHP's data() function to do this.

  •  date('t') will return the last day of the month.
  •  date('j') will return the current day of the month.

So, we can simply implement our if-else logic here to get the output.
$maxDays    =  date('t');
$currentDay =  date('j');

if($maxDays == $currentDay)
    echo 'Last Day of month';
    echo 'Not last day of the month';
Have any doubt, feel free to comment here!

Wednesday, 14 May 2014

How to show particular lines from gist ? 2

I tried to show selected lines of code from my gist to my blog. I got kashif-umair's Repository from GitHub. It's very easy to implement.

This plug-in using jQuery. So, you should load jQuery library. If you are going to use this in blog or website, You can use online CDN for both jQuery and gist-embed libraries like below,
Code usage is very simple. See the Syntax below,
See the example below,
You can enter line numbers in multiple combinations also like below,
The above example code will embed line numbers 1,2,3,6 in the same order. If lines are duplicated then they will be duplicated in code too.

If you don't data-showlinenumbers attribute your output will be like below
Here you see "1" at the beginning of code. To avoid this, you can use data-showlinenumber = "false" attribute.

If you don't use data-showfooter attribute, your output will be like below,

you can see, gist file name and "hosted with - by GitHub" content in that snippet. To avoid this, you can use data-showfooter = "false" attribute.

You know one thing? In this post I used that gist-embed library to show codes. really it's awesome.

Note: There is no documentation available to style this code snippet. In this blog post I used my own style. This gist code using gist-file class. So, I used the below style code to this,

You can find  's fork. This fork is having more additional features of highlight  particular lines of code. And you can find well structured documentation there.

Have any doubt, feel free to comment here!

Tuesday, 13 May 2014

How to use sql query's between clause in filter() - concrete5 0

I just tried to filter my base query between two dates. I don't know how to use that between clause in filter() function.
after I seen code of filter() function, I found the solution. I just set false to the first parameter, and in second parameter I wrote the complete condition like below,

Finally it works.

Hope, it will help some one!

Multiple List Paginations in a one page - concrete5 0

If you want to put two or more paginated list using concrete5 pagination (item list) class, You need to set name space for each instance of a class.

for example, I am taking two various instance for a single class.
$pageList1 =  new productList();
$pageList2 =  new productList(); 

Here I'm separate resultant list using different filter queries like below,
 Concrete5 pagination class is working based on url. So, if we click on next page of pagination button, query string will be change like ?ccm_paging_p_2.

So, it will became a common paging for both paginated result. So, it will show the second page result in both lists.

To avoid this, we can use separate name space for those two instances like below,
So, if you click on paginate button of pageList1, query string will be ?ccm_paging_p_pl1=

So, it will paginate only one list which one you clicked.
setNameSpace() is a function of pagination helper in concrete5. 

Have any doubt, feel free to comment here!


Thursday, 8 May 2014

How to change MYSQL database data directory to another location? - WAMP 0

Database server storing the values in files data directory. So, if you want to change the storage location for the database, you can just put this data directory in any location in your system and tell that path to MYSQL to manipulate data.

In this post I'm going to show some screen shots to do this.

Note : I'm using WAMP in this example.

  • First step you should Stop All services
  • Just click on the WAMP icon, then select MySQL, then select my.ini file like the above image
  • After open you my.ini y.ini in your editor(notepad), find the word datadir. Here you can see the file path for data directory.
  • datadir=c:/wamp/bin/mysql/mysql5.5.24/data is current file path for data directory.
  • Just go and cut that data directory from the current place and paste it to your desired location.
  • Then replace your current directory path to your data directory.
  • For example, I pasted my data directory E:/CJ_Ramki/data. So, I changed that directory path to datadir=E:/CJ_Ramki/data like below picture.
  •  Finally Start All Services
That's it... Your database server will write and read files from you new location.

Wednesday, 7 May 2014

How to set default time zone in php? 1

to set default timezone in our php page, we can use PHP native function.



for example, if you are in New York, your timezone is "America/New_York"

standard timezone for India is "Asia/Kolkata" or "Asia/Calcutta".

WHY we need to set timezone in our PHP page?

     Consider your server in India and your client access your web page from America, In this situation you are getting date() or time() from your server using PHP, it will return server timezone. That means it will return Indian time.

     So, you should change it to American timezone to get correct date() or time() from server.

You can put this in your header of footer php file to set timezone in all of your pages.

Timezone Array

If you are giving option to select timezone to user, you should list out all timezones in your select box. You can simply use this below function to do this. it will return array of timezones.

And you can use that array in your form like the above code.