Kavoir & Whatever

Katrina Costedio Steals (

Katrina Costedio currently lives in Sarasota, Florida and has a small design firm ( that attends to small business needs doing all kinds of design work: print design, card design, logo design and web design. She’s planning to go to San Francisco, California, though.

I worked for her on 2 projects, namely maahs acupuncture clinic site, including PSD to CSS/HTML service and a php contact form; and including ALL stuff that’s basically from PSD design to everything – PSD to CSS/HTML, php CMS and shopping cart. Other than these, I have helped her with other sites as well:

  1. some wordpress work for
  2. fixing a few css and javascript errors for
  3. there’s some more I can’t remember now…

Katrina Costedio would have been a good lady, if she has kept her words and not stolen my work without paying me a penny.

Below is an email message I planned to send her but understandably as  she might have blacklisted me, I’ll just post it here for all to see:

So launches with my code? You know you haven’t paid me a penny for it, so technically it’s all my property and you are stealing. We never had any contract that says if all goes this way, you unconditionally own everything I did.I thought you said you would be losing thousands dollars more to finish what I started. I beg your pardon. It’s you who shut me off from the servers and projects by suddenly changing all the login passwords. I feel stupid and betrayed the next morning when I found out I couldn’t log in any more. Not to mention you never started from scratch again. Instead, you stole my work shamelessly for your own clients. Because I have spent a month on your project and it’s almost done!

Katrina Costedio is stealing.

You crapped my code as unsecure and stolen yet you use it with no shame. What kind of b*tch are you? (I still have all her original words in my mail box.)

Also we haven’t finished up with my “copyright” issues yet, which file did you say I stole from other people and didn’t even bother to remove the copyright information? Ohhh, if it happends to be jquery.js or, they are licensed under LGPL for crying out loud and almost all sites use them! I can’t believe you were trying to come up with this kind of shit to demonize me? So that you can take my hard work free? At least get a programming class before doing that, katie.

Business and Marketing Content / SEO Tips & Tutorials Kavoir & Whatever

I dismiss SEO

Other than a descriptive title and a few describing words about what the current page is about, there’s no more needed to be done SEO-wise. No more. Period.

Why, when I can create art, fulfill dreams, amuse and please my users and make them feel they have never been treated so well on other sites, should I spend majority of the time doing SEO chores and hunting for a few pathetic back links?

SQL / MySQL Tips and Tutorials

MySQL: Add Statistics Column for the Number Count of Records from Another Table

It’s hard to describe this scenario precisely with limited title length. Basically, this is when you want to dedicate a field in ‘category’ table to store the number of articles or posts in ‘post’ table that fall into this category.

Previously, you had both ‘category’ table to store post categories and ‘post’ table to store posts. Each post must fall under a category for the sake of categorization referenced by a field named ‘category’ in table ‘post’ that bears the ID of the category in table ‘category’ that this post belongs to.

I hope I have made myself clear on this.


Now the problem is that you want to display the count of posts under each category and there are apparently a large number of them so preferably you don’t want to count through them all each time a web page is loaded so as to reduce mysql server load.


The solution is obvious. You’d make an additional column for table ‘category’ arbitrarily named ‘count’ for example. And update it once there’s an addition to the posts or a deletion from the existing. Now how do we do that.

Assume that there are only 2 columns in the current ‘category’ table, one is ID and the other is TITLE. To create another category table from the existing one with an additional ‘count’ field:

CREATE TABLE category2 SELECT AS id, category.title AS title, COUNT( post.category ) AS count
FROM category, post
WHERE post.category =
GROUP BY post.category 

This would create a new table called ‘category2’ that’s no different from the original ‘category’ table except for the additional column we just added: ‘count’.

Executing this single SQL query, not only is the new column created but they are also filled with the count of the posts that are assigned to each of the category.

The last task of this job will be to drop the original ‘category’ table and rename ‘category2’ to ‘category’.

Another Solution

By the help of an extra temporary table, you can also add a number / count column by combining the following 2 tips:

  1. Create a temporary table of rows with id and count: counting records number.
  2. Transfer the statistics from the temporary table to the newly created column of the original table: update more than one rows with a single update query.
PHP Tips & Tutorials

PHP: Convert between Numerical Bases | Binary Number, Decimal Number, Octal Number and Hexadecimal Number Conversions

Different number notations for different numerical bases:

0144  // base 8
 100  // base 10
0x64  // base 16

To convert between number bases, use PHP base_convert() function:

$hex = 'a1'; // hexadecimal number (base 16)
$decimal = base_convert($hex, 16, 10); // $hex converted from base 16 to base 10 and $decimal is now 161
$bin = '101'; // binary number (base 2)
$decimal = base_convert($bin, 2, 10); // $bin converted from base 2 to base 10 and $decimal is now 5

base_convert() function changes a number string from the original base to the target base number string. Other than this, there are also other specialized base conversion functions in PHP that’s basically created around decimal (base 10):

// convert to base 10
print bindec(11011); // 27
print octdec(33);    // 27
print hexdec('1b');  // 27

// convert from base 10
print decbin(27);    // 11011
print decoct(27);    // 33
print dechex(27);    // 1b
PHP Tips & Tutorials

PHP: Convert Degrees to Radians and Convert Radians to Degrees

Degrees and radians are different metric means to gauge an angle. They are mutually convertible in PHP. Simply use the PHP degrees to radians function deg2rad() and PHP radians to degrees function rad2deg().

$degrees = 180;
$radians = deg2rad($degrees); // 3.1416
$degrees = rad2deg($radians); // 180

Because trigonometric calculations are usually done in radians, you have to convert the degrees into radians:

$cosine = cos(deg2rad($degrees));
PHP Tips & Tutorials

PHP: Number Format Function to Format Numbers in PHP (Integer or Float)

To display numbers to end users, especially large numbers, you may need to format them to be more user friendly. For example, with a large integer 43386000.75, it is usually preferred to comma-separate every 3 digits to this:


To format numbers this way in PHP, you need number_format() function:

print number_format(43386000.75); // prints '43,386,000.75'

This is English notation of numbers with thousands separator. For French number notation:

print number_format(43386000, 2, ',', ' '); // prints '43 386 000,75'

Deducing from the parameters used in the above example, we have the number_format() function synopsis:

string number_format ( float $number , int $decimals , string $dec_point , string $thousands_sep )

With number_format(), you can format any integer number of floating point number by thousands separator (which in most cases is a comma), decimal point (which usually is a period point), number of decimal digits after the decimal point.

HTTP Tips & Tutorials PHP Tips & Tutorials

PHP: Send HTML Email (mail)

As we all know the simplest approach to create an email message and send it out is to use the php mail() function. A typical usage example would be:

mail('[email protected]', 'Subject Title', 'Message body goes here.');

However, as the mail() function sends emails in text/plain mime type by default, if you include HTML code in the message body, it would not be interpreted as HTML at all. Instead, all the tags and attributes are displayed as they are.

To work around this and send HTML email with PHP mail() function, you will have to modify the message mime type to text/html. In practice, use the mail() function with an additional argument to set arbitrary headers for the email message:

$to = '[email protected]';
$subject = 'Purchase Successful!';
$message = '
	<title>Purchase Successful!</title>
	<p>Here are the order details:</p>
	<p> ... </p>
	<p><a href="">back to store</a></p>

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);

Now the email dispatched to the recipient will have all the HTML in it working as expected.

PHP Tips & Tutorials

PHP: Wrap Long Lines | Insert Line Breaks into a Long String

Some strings of texts may lack necessary wraps and don’t have natural line breaks in them so that the lines are too long to read comfortably. Therefore, you want a way to insert line breaks in to the string every dozens of characters.

The php function you need is wordwrap():

$s = ' ... '; // very long single line string text
$s_wrapped = wordwrap($s, 60); // $s is wrapped by every 60 characters and evaluated to $s_wrapped

Line breaks are inserted into the original text every 60 characters.

PHP Tips & Tutorials

PHP String Case: Uppercase all Letters or Lowercase all Letters in a String | Uppercase First Letter of a String | Uppercase First Letter of all Words in a String

It’s common that you need to reformat the texts in PHP and make them look a little more formal. For example, the first letter of all sentences should be uppercased, or with a title, the first letter of all words should also be made uppercase; in other situations, you may want all letters to be in uppercase.

Make all letters in a string lowercase
strtolower('ABc De!'); // returns 'abc de!'
Make all letters in a string uppercase
strtoupper('ABc De!'); // returns 'ABC DE!'
Make the first letter of every word uppercase
ucwords('world digital library'); // returns 'World Digital Library'
Make the first letter of a sentence uppercase
ucfirst('how are you?'); // returns 'How are you?'
PHP Tips & Tutorials

PHP: Change Tabs to Spaces and Vice Versa in String | Change Tab Sizes / Lengths in Strings

Everyone who ever dealt with formatting code in PHP string manipulations may want to switch between different tab sizes or simply change spaces to tabs or tabs to spaces in the formatted code string.

The function we’ll need for these is str_replace(), the string search and replace php function. For example:

Switch between tabs and spaces

By spaces, I mean spaces used to start a new line of code that indents that line rather than all the spaces including those used simply between words. Therefore, you generally want to change tabs to spaces in double:

$spaced = '(spaces) some code';
$tabbed = str_replace('  ', "\t", $spaced); // 2 spaces is the 1st parameter

To change tabs back to spaces (preferably in double spaces as well, such as 4 spaces), just reverse the process:

$tabbed = '(tabs) some code';
$spaced = str_replace("\t", '    ', $tabbed); // 4 spaces is the 2nd parameter

“\t” is the byte representation of a tab.

Change tab sizes / lengths

Essentially the same, just use the function str_replace() to change the number of spaces used in place of a tab.