Categories
- Bisdak Blogger (1)
- chicks (1)
- Coffee and Paste (1)
- css (5)
- Excel (1)
- General Info (5)
- HTML (1)
- javascript (6)
- more (9)
- Movies (1)
- MySQL (1)
- pdf (1)
- Photoshop (1)
- PHP (22)
- SEO (1)
- sports (2)
Blog Archive
-
▼
2009
(36)
-
►
March
(15)
- strlen vs isset in PHP
- 40 Tips for optimizing your php code
- $HTTP_SERVER_VARS
- Cross browser compatibility test site
- Detecting Mobile Browsers in PHP
- The Windows-versus-Linux server face-off
- Passing JavaScript variables to PHP
- single-quote( ' ) vs double-quote ( " ) in PHP
- PHP Arrays
- Advantages of Using Functions
- Differences between constants and variables
- $_GET vs $_POST in PHP Forms
- require() vs include() in PHP
- Gates Regain His Title As Worlds Richest Man!
- What does !important mean in CSS?
-
►
February
(12)
- Javascript onclick return false does not work in I...
- Coffeeandpase Blogger: A Heavy Downloader
- Where is php.ini?
- Make a face
- Turn your photo into a cartoon
- Retrieving Japanese Text from MySQL using PHP
- CSS Play: Experiments with CSS
- New Online MD5 Hash Cracker!
- PNG Alpha Transparency Fix in IE
- Blogger.com as a website instead of a blog?
- Email address validation using Javascript
- PHPMailer: SMTP Authentication
-
►
March
(15)
-
►
2008
(14)
-
►
December
(8)
- Simple php pagination
- Create Image Thumbnails Using PHP and GD
- How to create a dynamic bar graph using PHP and GD...
- How to create a dynamic line graph using PHP and G...
- Simple PHP Image Watermark
- Manny Pacquiao vs Oscar De la Hoya (The Dream Matc...
- Live free streaming!!! Pacquiao vs. De La Hoya
- Javascript equivalent for PHP Functions
-
►
December
(8)
Blog Roll
- Monkeetech
- Atenean101
- Batangsaag.blogspot.com
- Batangyagit.com
- Bethelo
- beyond-the-norms.org
- Brightartclass.blogspot.com
- Bugits
- Cebu Directories
- Cebudaily.com
- CebuElection
- Cebuheritage.com
- Cebuimage.blogspot.com
- Cebupacificairlines.ph
- Codes Depot
- Dahonglaya.com
- Empressofdrac
- Errol Duazo
- EUTS
- Iamdownloader.com
- Ibeejing
- Icymartagimacruz
- Ie-student
- In-indie.org
- Jerry Gervacio
- Lagahit.com
- Marroxas2010
- Mcbilly.com
- Miongandmarquee
- Nurseter
- Pinoyworld.org
- Punkies07
- QueerChef
- Sinjin.ph
- softwareportables
- Sunchoke.net
- VeganPrince
- Vera
- Veryducky
- Yugatech
Disabling IE "save image" buttons
How to disable the command buttons that pop-up when you hover over an image in IE?
You can disable the Image Toolbar either through a meta tag
<META HTTP-EQUIV='imagetoolbar' CONTENT='no' >
or by setting the attribute GALLERYIMG='no' to an IMG tag element.
<img src='monkee.jpg' GALLERYIMG='no' >
For more info see: http://support.microsoft.c
ASCII Table
ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort. ASCII was developed a long time ago and now the non-printing characters are rarely used for their original purpose. Below is the ASCII character table and this includes descriptions of the first 32 non-printing characters. ASCII was actually designed for use with teletypes and so the descriptions are somewhat obscure. If someone says they want your CV however in ASCII format, all this means is they want 'plain' text with no formatting such as tabs, bold or underscoring - the raw format that any computer can understand. This is usually so they can easily import the file into their own applications without issues. Notepad.exe creates ASCII text, or in MS Word you can save a file as 'text only'
Extended ASCII Codes
As people gradually required computers to understand additional characters and non-printing characters the ASCII set became restrictive. As with most technology, it took a while to get a single standard for these extra characters and hence there are few varying 'extended' sets. The most popular is presented below.
Leaked X-Men Origins: Wolverine Unedited
X-Men Origins: Wolverine is scheduled to be released by the end of this month. However, the producers hit a snag when a leaked version of the movie was uploaded on the internet. As of this writing, you can watch X-Men Origins: Wolverine online here or download it in almost all of the major torrent sites.
But before watching the leaked version, here’s the official statement on why you shouldn’t watch X-Men Origins: Wolverine online:
Fox Co-Chairman Tom Rothman issued an official statement ensuring the fans and moviegoing public that the leaked version is indeed an early rough cut, with temporary sound and music and a darker appearance than the finished footage.
Rothman’s statement notes that “The version that went out is unfinished. It’s about 10 minutes shorter, doesn’t have key scenes, it wasn’t edited, and none of the effects shots were in any remotely final form. It’s a complete misrepresentation of the film and is deeply unfair to the people who have worked on it for years.”
Rothman is touting a bunch of footage shot in Canada earlier this year that he says is not even included in the version online. And he insists that both he and Hugh Jackman have vowed to stop at nothing to get the movie out to as many fans as possible. “Hugh was heartbroken and hurt when he found out. He’s lived with this thing for 10 years. But he’s also a man and knows that life isn’t fair, and is more determined than ever,” Rothman says. “Hugh and I exchanged e-mails: Basically, we’re not going to let the bastards win. But we didn’t use the word ‘bastards.’ That’s a slightly sanitized version.”
Likewise, fans and supporters of the movie in the Phils. have affirmed that the leaked version is more like watching behind-the-scenes of X-MEN ORIGINS: WOLVERINE. It is worthy to note that in unison, those who have come in possession of the unfinished version vowed that they will still definitely see it on the big screen when it opens April 30 (in Phil. theaters) since most of the scenes have unfinished, rough 3D special effects, blank frames, dull moments due to muted speaking lines and sound effects and the appearance of blue dots in every scene from start to end.
There you go. Let’s just wait for April 30. :)
Bidvertiser Payment: $26.43 USD
This is the first time I received payment from Bidvertiser. Yah..Bidvertiser is not a scam. They really pay.
So far, Bidvertiser is performing good on my blogs. I want to thanks Bidvertiser for sending me the payment and Bidvertiser is a great program as well as great AdSense Alternative.
If you still have not signed up, click here to join.
strlen vs isset in PHP
When working with strings and you need to check that the string is either of a certain length you’d understandably would want to use the strlen() function. This function is pretty quick since it’s operation does not perform any calculation but merely return the already known length of a string available in the zval structure (internal C struct used to store variables in PHP). However because strlen() is a function it is still somewhat slow because the function call requires several operations such as lowercase & hashtable lookup followed by the execution of said function. In some instance you can improve the speed of your code by using an isset() trick.
<?
if (strlen($foo) < 5) { echo "Foo is too short"; }
if (!isset($foo{5})) { echo "Foo is too short"; }
?>
Calling isset() happens to be faster then strlen() because unlike strlen(), isset() is a language construct and not a function meaning that it’s execution does not require function lookups and lowercase. This means you have virtually no overhead on top of the actual code that determines the string’s length.
40 Tips for optimizing your php code
- If a method can be static, declare it static. Speed improvement is by a factor of 4.
- echo is faster than print.
- Use echo's multiple parameters instead of string concatenation.
- Set the maxvalue for your for-loops before and not in the loop.
- Unset your variables to free memory, especially large arrays.
- Avoid magic like __get, __set, __autoload
- require_once() is expensive
- Use full paths in includes and requires, less time spent on resolving the OS paths.
- If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()
- See if you can use strncasecmp, strpbrk and stripos instead of regex
- str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4
- If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.
- It's better to use switch statements than multi if, else if, statements.
- Error suppression with @ is very slow.
- Turn on apache's mod_deflate
- Close your database connections when you're done with them
- $row[’id’] is 7 times faster than $row[id]
- Error messages are expensive
- Do not use functions inside of for loop, such as for ($x=0; $x <>
- Incrementing a local variable in a method is the fastest. Nearly the same as calling a local variable in a function.
- Incrementing a global variable is 2 times slow than a local var.
- Incrementing an object property (eg. $this->prop++) is 3 times slower than a local variable.
- Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one.
- Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var). PHP probably does a check to see if the global exists.
- Method invocation appears to be independent of the number of methods defined in the class because I added 10 more methods to the test class (before and after the test method) with no change in performance.
- Methods in derived classes run faster than ones defined in the base class.
- A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. A similar method call is of course about 15 $localvar++ operations.
- Surrounding your string by ' instead of " will make things interpret a little faster since php looks for variables inside "..." but not inside '...'. Of course you can only do this when you don't need to have variables in the string.
- When echoing strings it's faster to separate them by comma instead of dot. Note: This only works with echo, which is a function that can take several strings as arguments.
- A PHP script will be served at least 2-10 times slower than a static HTML page by Apache. Try to use more static HTML pages and fewer scripts.
- Your PHP scripts are recompiled every time unless the scripts are cached. Install a PHP caching product to typically increase performance by 25-100% by removing compile times.
- Cache as much as possible. Use memcached - memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load. OP code caches are useful so that your script does not have to be compiled on every request
- When working with strings and you need to check that the string is either of a certain length you'd understandably would want to use the strlen() function. This function is pretty quick since it's operation does not perform any calculation but merely return the already known length of a string available in the zval structure (internal C struct used to store variables in PHP). However because strlen() is a function it is still somewhat slow because the function call requires several operations such as lowercase & hashtable lookup followed by the execution of said function. In some instance you can improve the speed of your code by using an isset() trick.
Ex.
if (strlen($foo) < 5) { echo "Foo is too short"; }
vs.
if (!isset($foo{5})) { echo "Foo is too short"; }
Calling isset() happens to be faster then strlen() because unlike strlen(), isset() is a language construct and not a function meaning that it's execution does not require function lookups and lowercase. This means you have virtually no overhead on top of the actual code that determines the string's length.
more about isset() vs strlen() here - When incrementing or decrementing the value of the variable $i++ happens to be a tad slower then ++$i. This is something PHP specific and does not apply to other languages, so don't go modifying your C or Java code thinking it'll suddenly become faster, it won't. ++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend's PHP optimizer. It is a still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer.
- Not everything has to be OOP, often it is too much overhead, each method and object call consumes a lot of memory.
- Do not implement every data structure as a class, arrays are useful, too
- Don't split methods too much, think, which code you will really re-use
- You can always split the code of a method later, when needed
- Make use of the countless predefined functions
- If you have very time consuming functions in your code, consider writing them as C extensions
- Profile your code. A profiler shows you, which parts of your code consumes how many time. The Xdebug debugger already contains a profiler. Profiling shows you the bottlenecks in overview
- mod_gzip which is available as an Apache module compresses your data on the fly and can reduce the data to transfer up to 80%
- Excellent Article about optimizing php by John Lim
Disclamer: This was article wasn't really mine, someone emailed this to me and I just found it useful.
$HTTP_SERVER_VARS
Basic surfer information variables (from HTTP_SERVER_VARS)
<?php
$surfer_info[ip] = $HTTP_SERVER_VARS["REMOTE_ADDR"];
// $surfer_info[real_ip] will only contain something if the surfer used a transparent proxy
$surfer_info[real_ip] = $HTTP_SERVER_VARS["X_FORWARDED_FOR"];
$surfer_info[port] = $HTTP_SERVER_VARS["REMOTE_PORT"];
$surfer_info[browser_lang] = $HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"];
$surfer_info[user_agent] = $HTTP_SERVER_VARS["HTTP_USER_AGENT"];
$surfer_info[request_path] = $HTTP_SERVER_VARS["PATH_INFO"];
$surfer_info[request_query] = $HTTP_SERVER_VARS["QUERY_STRING"];
$surfer_info[request_method] = $HTTP_SERVER_VARS["REQUEST_METHOD"];
$surfer_info[http_referrer] = $HTTP_SERVER_VARS["HTTP_REFERER"];
?>
It is just a row of variables, - it is up to you to decide how they are useful to your script and how to integrate them.
But if you want to see something happening any way, add
print_r($surfer_info);
to the bottom of the script (but before the closing ?>). Doing so will cause the script to show you what information the variables picked up.
Cross browser compatibility test site
BROWSERSHOTS.ORG
I use this site everytime i check my design. You can choose from a lot of browsers too. This site is amazing.
How the site works:
Browsershots makes screenshots of your web design in different browsers. It is a free open-source online service created by Johann C. Rocholl. When you submit your web address, it will be added to the job queue. A number of distributed computers will open your website in their browser. Then they will make screenshots and upload them to the central server where you can see the result.
Detecting Mobile Browsers in PHP
I used the following block of code to redirect site to a page when it is been accessed via mobile phone browser and to another page when it is accessed via desktop browsers. This is tested in ie, firefox, netscape, opera, chrome and some mobile phone browser simulator. This works well for me.
<?
$site1 = "http://coffeeandpaste.blogspot.com/";
$site2 = "http://monkeetech.blogspot.com/";
$BrowserSplit = explode("/",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]);
$Machine = $BrowserSplit[0];
if($Machine == "Opera" || $Machine == "Mozilla") {
header("location: $site1");
}
else {
header("location: $site2");
}
?>


