Category: English


Firefox 4Chrome 12IE 7Centrado IE9IE 8Opera 11Safari 5

Centering Vertically and Horizontally in HTML using CSS is a pain, so here’s a litte example (self commented) that can be used as a reference.

EXAMPLE (DOCUMENTED)

This works for:

  • IE 7-8-9
  • Chrome 12 on Mac
  • Firefox 4 on Mac
  • Opera 11 on Mac
  • Safari 5 on Mac
  • Expected to work on the same browsers on other OSs.

Charlie and the factory

Not only programming, some humour as well.

How to measure execution time in PHP

While working with José ABCD (that’s not his last name… he likes to remain unknown) we were talking about two ways of solving a problem un PHP and which would be the best in terms of speed. To solve this, we decided to use microtime(). This is what we did:
Code


          $cicles = 5000; // Number of cicles

          $totalTime = 0; // Total time, set to 0
          for ($i=0; $i<$cicles; $i++){ // This for gets run for $cicles times
               $timeInit = microtime(); // Initial time
                    ## código a probar aquí ## // This is the code to test, it can be a function or several lines of code
               $timeEnd = microtime(); // End time
                    // Next we process time to get a total amout of time during all $cicles
               $timeInit = explode(" ", $timeInit);
               $timeInit = (double) $timeInit[0] + $timeInit[1];
               $timeEnd = explode(" ", $timeEnd);
               $timeEnd = (double) $timeEnd[0] + $timeEnd[1];
               $totalTime += ($timeEnd - $timeInit);
          }
          $timeAvg = $totalTime / $cicles; // Average time
                    // We print our results
          echo "<div>";
          echo "Total = ".$totalTime."<br>";
          echo "Avg = ".$timeAvg."<br>--<br>";
          echo "</div>";

DocuCenter.cl Launched!

DocuCenter - Compartiendo Información

We are very proud to announce the launching of DocuCenter.cl. Feel free to check it out and let us know if you like it.

While building a site on one of our servers we had no issues with the character set. We were using latin1 (iso-8859-1) for the HTML files meta tag and also on the MySql database. However, that didn’t happen when we were going live on our client’s server. Their Apache was using UTF-8 and on the HTTP headers it returned “Content-Type: text/html; charset=UTF-8″ so our charset was a problem. And we had to do the transition.

Changing files from latin1 to UTF-8 was kind of easy with a script. However, changing the database from latin1 to UTF-8 was kind of a pain… one solved easily at the end but still a pain. So, to spare some time for whoever needs this, here’s what I did.

I tried first with “ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;“, but apparently what that does is to change the default character set for the table and set the space to save data in that particular character set. Then I tried to modify each column with “ALTER TABLE table MODIFY column TEXT CHARACTER SET utf8;” but that didn’t work either, apparently that changes the character set for a column but doesn’t change its contents.

Soooooo, the solution is to first pass each column to a binary character set** and then pass it to the character set needed, like this:

ALTER TABLE table MODIFY title BLOB;
ALTER TABLE table MODIFY title VARCHAR(250) CHARACTER SET latin1;
ALTER TABLE table MODIFY title VARCHAR(250) CHARACTER SET utf8;

Keep in mind to change every columns data type on the first and third line with what you actually need. This conversion isn’t needed for columns with data types different than text.

**: http://dev.mysql.com/doc/refman/5.1/en/alter-table.html:

If you specify CONVERT TO CHARACTER SET binary, the CHAR, VARCHAR, and TEXT columns are converted to their corresponding binary string types (BINARY, VARBINARY, BLOB). This means that the columns no longer will have a character set and a subsequent CONVERT TO operation will not apply to them.

First, a little intro about PATH. It’s a system variable used in terminal (in OS X). It’s the place where the os looks for commands to be executed, it’s very useful since it allows you to just type “less” instead of “/usr/bin/less”; that works for every originally installed commands on the system. However, if you want to be able to type a command like “mysql” for instance, you have to tell the system where to look, you do this by adding the directory to PATH. You can do this every time by doing “export PATH=$PATH:/usr/local/mysql” or by adding this to some initial script executed by the shell. View Full Article »

I was creating a system and i needed to find a way to assign a work schedule to several employees of a company and control them easily, rapidly and intuitively. For this, from a table created with divs and checkbox, I put “days” on the columns side and “hours” on the row side, then I includes the possibility to select and unselect the work hours of one or more days, clicking and dragging the mouse inside the table. This table is configurable, fast and easy to integrate and use, I gave it the name of EasySelector.

You can see the result in the demo below: Demo
View Full Article »

A free gift for everyoneTo celebrate the start of the spring season, BoldLab has a special gift: a set of 20 flash cards, detailing homemade recipes for hair and face care. You can download it here. Enjoy!

Next a correct XHTML example that validates. I wrote it to have a way to remember how it should be built and avoid searching for the same stuff every time.

Code


<?xml version="1.0" encoding="UTF-8"?>

<!-- This is a comment -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
     The "Strict" part can be:
          -Strict, meaning all look should be accomplished by CSS
          -Transitional, meaning some HTML4 elements are allowed, like align="center"
          -Frameset, allowing frames
     To know more:

http://w3schools.com/xhtml/xhtml_dtd.asp

-->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">

     <head>
          <title>Title</title>
          
          <!-- meta -->
          <meta name="description" content="An example page" />
          <meta name="keywords" content="example, page, xhtml" />
          <meta name="author" content="Iam Me" />
          <!-- About meta: http://w3schools.com/tags/tag_meta.asp -->
          <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
          
          <!-- External file Script -->
          <script type="text/javascript" src="main.js"></script>
          <!-- Local Script -->
          <script type="text/javascript">
               //<![CDATA[
               alert("This is an Alert! Inside <head>.");
               //]]>
          </script>
          
          <!-- css -->
          <!-- <style> not allowed in <body> -->
          <!-- External file CSS -->
          <link rel="stylesheet" href="look.css" type="text/css" />
          <!-- Local CSS -->
          <style type="text/css">
               h1 {
                    color: #fa6;
               }
          </style>

     </head>
     
     <body>
          <script type="text/javascript">
               //<![CDATA[
               alert("This is an Alert! Inside <body>.");
               //]]>
          </script>
          
          <!-- noscript:
               to work it has to be inside one of the following tags:
               "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del".
               These tags are "display: block" (css).
          -->
          <noscript><h1>This doesN'T appear on a browser with JavaScript active</h1></noscript>
          
          <h2>An h2 example</h2>
          
          <p><abbr title="Extensible HyperText Markup Language">XHTML</abbr></p>
     
     </body>

</html>

Java 4 ever…

This little video is the story of a family separated between Java and .Net – Great Drama.



Powered by WordPress and Motion by 85ideas.