Techblog Index

So your PHP headers are already sent, but you sent nothing?

So you are coding and your transfer your files to your production server via SVN or FTP and then you start getting some “Warning: Cannot modify header information – headers already sent” errors. Well, this is not good indeed.

This errors happens when you send a header command and has already outputted text to your output buffer (generally, the browser). Then you grep your code for misleft debugging prints, echos, print_rs and var_dumps but they are gone or commented.

Oh yeah, somehow some data were added during the transfer somewhere in your source files. Great! Now some cool action!
Read the full article

The Great H1 Debate

I was recently reading a post at the Viget Engage Blog about the upcoming debate about the placement of the h1 heading HTML tag.

It seems to be just making some noise by now but I remember like for months ago reading blogs, someone just stopped and wondered if placing it at the website title was really a good ideia and made me wonder too in that time and since then I started to follow the title placement option.

Now it has become something bigger, with a website (http://h1debate.com/) tracking peoples votes on tweets and we decided to speak our mind too. Go #h1title!
Read the full article

Quick Tip: Do you miss the target?

Opening links in a new window was once quick and easy but since the target="_blank" options on a links have died (if you didn’t knew, I’m very sorry to be the one telling you this) the only way left was the javascript way.
Read the full article

Quick Tip: JavaScript integers parsing

I’ve came across a strange problem when trying to parse date parts (2009 01 21) as integers in a form validation script. Somehow my month being parsed as 0 (zero) and not as 1 (one) as supposed to be. Strange. I’ve googled around and discovered that JavaScript’s parseInt support different (not so many) number bases and by default it “guesses” the base you are trying to work.

Sure, he found the “01″ and thought “Oh yeah babe, it’s an octal number!” — wrong my friend, it’s just a zero-padded number, sorry disappointing.

So, I had to supply the second argument called radix as 10 (decimal) that is indeed the base you are going to use. Setting this makes parseInt to respect you instead of having his free-will.

So I ‘ve got:

var _orderDateMonth = parseInt($('#survey_order_date_month').val(),10); // decimal base!

NOTE: The dollar sign ($) and .val() are specific JQuery functions.

NOTE: I personally hate when people break up the date parts into different inputs. If you are already going to use JavaScript, implement a damn date-picker!

The Layout Concept

Sites with loads of pages can be hard to manage. Includes were the gold pot in the end of the rainbow times ago so people could put repeated content (like headers, footers and menus) under a single file and thus including into the page/template.

But have you ever wondered that you keep having the same include occurrences at the pages? The layout concept (that I first saw under CakePHP [but it may have come from Rails actually]) brings you more flexibility and DRYness on working with templates.
Read the full article

Quick Tip: Seeking and destroying the swapfiles leftovers

Once again with my VIM swapfiles problems, I’ve left too much of them around my app dirs on my pre-screen era. Every power-down or connection loss was the birth of a new swap. Well, they all appeared when I had to sync with the production server.
Read the full article

Tracking your mail views via Web Beacons

One of the most common problems of working with email communication between the companies and its clients is that there isn’t a way of proving that user has received the email without making him click on a link to the company site thus confirming the read.

As most webmail and mail applications can read HTML emails (and most companies sends HTML emails anyway), we can take advantage of this to help transparently track the view.
Read the full article

Updates and birth of a new MVC Framework

Hello friends.

Sorry for the lack of posting these days. I’ve been working hard on the finishings of the WebTodo project (in Brazillian Portuguese).

This project was a kickstart for my own MVC Framework. As cited in previous article, I was not confortable with the idea of using one of the existing MVC Frameworks because I’m a little paranoid of not having exact (and full) control of my code. The only way to assure quality was from coding every piece.
Read the full article

The Bomb vs The Rifle: Effective data searching

Searching never seemed something really hard to do because SQL’s LIKE was there to aid the oppressed but… does LIKE the job right?

So we have data and when it gets bigger and bigger, we need to search through it. Let’s take some approaches to the Search function and find out the better way.
Read the full article

Quick Tip: du’s –max-depth to find fat directories

Sometimes you’re working on your computer and things start to work strange. The softwares starts to crash without reason… uhoh… or my home or my temp/var folders are full.

To quickly have an overview of your directory sizes du helps wonderfully!

du is an utility binary that comes with (I think) most Linux distributions and some BSD that lists all directories’ and subdirectories’ “disk usage” (got it?). By default, du scans recursively until the last directory on tree.

The --max-depth attribute used with the -h (human-readable units) provides a good look at your disks’ size.

The following code scans only your first directories whithin your home directory:

du -h --max-depth=1 ~

Just change the --max-depth value to match your needs.