2013-02-28

Easy way to switch to HTML5'~

Apparently, everyone should be already, capable to write a websites, by using HTML5 version. But there is still a lot of people, for whom, it's hard to leave the old habits from the older versions of HTML. I thought, that I'm one of them, but a few days ago, I found the site called:



The site is nothing else, but an HTML5 templates generator, which generates for you a clean and customizable template with everything you need to have a good start. At the main site you can choose, how big, starter kit, you would like to download. The most joyful in this, is that apart of the most basic simple template, you can also download some extras, such as Apple Touch Icons, Google Analytics or JavaScript plugins.

Little, sweet menu in CSS3 with using 'nth-child'~

In CSS3, I found 'nth-child' as very useful property. See by yourself (but remember don't use IE browser, because CSS3 doesn't work as it should works on Internet Explorer!):



The code doesn't look too much complicated, because the main trick, that I used, is contained in 'nth-child':

2013-02-27

Sliding effect in CSS3 without JS help? No problem! ;)

Somebody of you can have no clue, of the possibilities that CSS3 is offered. By using only CSS3 you can get very nice effect of sliding text and make a beautiful slider. All because of special CSS3 properties, called 'transition' and 'overflow', which combined together, give the following effect:


The code is very simple:

2013-02-22

Duplicate Content Problem!~

One of the sites, that I optimize is a very peculiar case. I had already been done everything in my power to pull it into the lead in the search results. To no avail. However, the strangest thing is that the other site, was about the same subject and I have been optimizing it on the same phrases after when, the other site very quickly reached the 1st place. I had been wondering what could be the cause of this situation, so I typed in the browser, a piece of text from the page, which allegedly was written personally by my clients ..
Oh stupid Me..! How could I not think of before, that the text on the page is not unique! Although we always ask our clients to care about the original texts on the websites and if they have no ideas about it, we offer them to write unique text. But I didn't even think, that the entire text on her - my client's page (who assured us that interceded content is original created by her) will be alive and completely copied from other texts found in the network!
So I have written new texts to the site and I ping them. After, about 2 weeks, the site finally have started to move from the place. But still, site did it sluggishly and reluctantly, and finally, at one phrase, site stuck in 16th place. Her site still can;t break into the magical top ten.
And I still have no idea what the problem is in. Is it possible that using the same method of positioning the two sites, put one site (easily) in the lead, and the other may not be able to break even for the top twenty? Or maybe it's just punishment for keeping on website kilo plagiarism for so long? -, -

2013-02-21

The array_map() problems!~..

Some time ago, I had a huge problem with understanding the array_map () function. Jeffrey Way defines it as a PHP function, which is built from 2 parameters. The first is the function to execute, and the second parameter is the array, are you working with. First parameter, within array_map, executes on every item in our parameter 2, in the array. So, array_map() syntax looks like:

        array_map(function() {
                    }, array1,array2,array3,...) // required is only array1, the remaining arrays are optional

He also gave me some example of use:

     
       function array_pluck($toPluck, $arr) {
                  $ret= array_map(function($item) use ($toPluck){
                  return $item[$toPluck];
                  }, $arr);
       print_r($ret);
       }
      ?>

But, as on my first contact with this function, the example was too much complicated for me. Or maybe I could understand it just because of 'use' enclosure, which can not be used in older versions of PHP. But whether to this, I asked my boyfriend to help me, and after his lesson, I finally understood, how array_map() working. There is his example:

      
       $table = [1,2,3] // so we have an array called $table
       $new_table = array_map(function($item) { // we create a new array, equal to array_map
             return $item+1;
             }, $table); // The function within array_map(), is working on every item from the $table and for each item, adds one
       print_r($new table); //now let's print it and see the result
       ?>



RESULT:

Array(
                  [0] => 2
                  [1] => 3
                   [2] => 4)

So, as you can see, the array_map() function works on array which as components, contains other arrays with other elements. Array_map() applying to array, execute function to each one and after that, returns an array containing all this elements, that are the execute function result.

Of course, if you want to see the result of array_map(), you don't have to use print_r, which gives you a lot of, unnecessary details. You can see the result, by using nicer way, namely, using 'foreach' conditional statement:

      

        $t = ['mama', 't', 'xx'];
        $r = array_map(function($i){
               return strlen($i);
               },$t);
        foreach($r as $item) {
               echo $item.' ';
        }
        ?>

RESULT:   4 1 2

2013-02-16

Have you heard about 'Sscanf' function?

When I asked my boyfriend, when the function 'Sscanf' can be useful, he couldn't give me a good answer to this question. My boyfriend is a PHP programmer..
.. The fact is that this function is not well known because most of the complex codes can be written without the knowledge of the 'Sscanf'. But if such function exists in the PHP programming language, there's always the possibility that, when we will be reading someone's code, we can just come across at it. Therefore, it is good to know, what 'Sscanf' is. The syntax of the function looks like this:

                                 sscanf(string, format, arg1, arg2, arg3..)

 'Sscanf' function works very easy. It is essentially the inverse of 'Sprintf' function. The 'Sprintf' syntax looks like this:

                                 sprintf(format,arg1,arg2,arg3..)

'Sprintf' function writes a formatted string to a variable. While 'Sscanf' function parses input from a string according to a format, which means that 'Sscanf' reads input for numbers and other data types from standard input. We will understand it better on simple example:

                                 <?php
                                 $result1= sprintf("s% s%, d%",'January','1st','2013');
                                 $result2= sscanf("January 1st, 2013", 's%','s%','d%');

                                 echo $result1;
                                 print_r($result2);
                                 ?> 
RESULT1:                 RESULT2:
 January 1st, 2013                    Array(    
                                                           [0]=>January
                                                    [1]=>1st,
                                                       [2]=>2013)

So as you can see, we can use 'Sscanf' when we want to capture specific values with the variables. But of course if I'm wrong, I'm always open for correction.

2013-02-14

'If' and 'switch' as Convertible Conditionals!~

In a previous post, I explained how the conditional statement 'if' syntax looks like. It is very useful when we are writing different programs, but sometimes, when the code is more complicated, it starts to look like a very messy code. Therefore, we can alternatively use convertible conditional statement 'switch', whose syntax I wrote below:

                                                 <?php

                                                 switch($variable){
                                                           case 'value';
                                                                     // do something
                                                                     break;
                                                           default:
                                                                    // do something else
                                                 }
                                                 ?>

Let's write here, piece of code, by using conditional statement 'if': 

                                                 <?php
 
                                                 $day='Thursday';

                                                 if($day=='Monday') {
                                                          echo 'Today is Monday!';
                                                 } elseif($day=='Tuesday') {

                                                          echo 'Today is Tuesday!'; 
                                                 } elseif($day=='Wednesday') {
                                                          echo 'Today is Wednesday!'; 
                                                 } elseif($day=='Thursday') {
                                                          echo 'Today is Thursday!'; 
                                                 } elseif($day=='Friday') {
                                                          echo 'Today is Friday!';
                                                 } else {
                                                          echo 'Today is Weekend!';
                                                 }
                                                 ?>

As soon as I wrote here something by using statement 'if', you can see that statement 'switch' can be use in the same way and this piece of code that I wrote you, I can write in a different way, by using the conditional 'switch':


                                                 <?php
 
                                                 $day='Thursday';

                                                 switch($day) {    

                                                        case 'Monday':
                                                                     echo 'Today is Monday!'; 
                                                                     break
                                                        case 'Tuesday':
                                                                     echo 'Today is Tuesday!'; 
                                                                     break
                                                        case 'Wednesday':
                                                                     echo 'Today is Wednesday!'; 
                                                                     break;  
                                                        case 'Thursday':
                                                                     echo 'Today is Thursday!'; 
                                                                     break
                                                        case 'Friday':
                                                                     echo 'Today is Friday!'; 
                                                                     break
                                                        default:
                                                                     echo 'Today is Weekend!'; 
                                                   }
                                                   ?>

For sure, you can see, the differences between 'if' and 'switch' conditional statements. Although 'switch' requires to be break after every instruction, but on the other hand, it needs only one bracket, due to which the code looks much more better ;)

2013-02-10

PHP has got triple equals!

It's a very interesting question, that in PHP, there are three different use of the '=' sign, in PHP conditional statements. The first and most intuitive, you can simply write, by using the easiest conditional statement - 'if', I think. This is the syntax for statement 'if':

                                                 <?php

                                                 if() {
                                                       // do something
                                                 } else {
                                                      //do something else
                                                 }

                                                 ?>


So we have here the syntax. Now, let's try to write something in PHP. For example:
                                                 <?php
                                                 $day='Monday';

                                                 if($day=='Monday') {
                                                          echo 'Day equal Monday!';
                                                 } elseif($day==='123') {
                                                          echo 'Type and Values are the same!';
                                                 } else {
                                                          echo 'Nothing here match!';
                                                 }
                                                 ?>

As you can see, we used here sign 5 times! The first use of a single character '=', means that we are signing the value to the variable ($day='Monday';). We are setting day equal Monday. At the second case, we are using a double equals ($day=='Monday';), because we are running a test: Does day equal Monday? So we are not signing anything to the variable but we are testing whether the left side equal the right side. Few programmers know, that there is also triple equals ($day==='Monday';). If we are using it, we are whether two variables are equal and also the same type. In other words, it is a comparison to see if they are both integers or both are strings. So cute<3


2013-02-07

Refleksja Schizofrenika..~

Naprawdę muszę coś z tym zrobić. Doszło już do tego stopnia, że w stresujący dzień (myśl: np. w dzień egzaminu) nie mogę wyjść z domu, bez załatwienia pewnych specyficznych, dla tego okresu czynności. Stres miota mną jak szatan! Przecież nie po to ryjesz całą noc, żeby potem (na skutek stresu) wszystko spieprzyć-,- Kampanię anty-stresową uważam za rozpoczętą.