Tuesday, July 31, 2007

Google Tricks

Enter just the word http for your search to find the top 1000 PageRanked sites.

Enter only www in your search to see how Google ranks the top 1,000 sites.

Manually type the following prefixes and note their utility:

# link:url Shows other pages with links to that url.
# related:url same as "what's related" on serps.
# site:domain restricts search results to the given domain.
# allinurl: shows only pages with all terms in the url.
# inurl: like allinurl, but only for the next query word.
# allintitle: shows only results with terms in title.
# intitle: similar to allintitle, but only for the next word. "intitle:seoforgoogle google" finds only pages with seoforgoogle in the title, and google anywhere on the page.
# cache:url will show the Google version of the passed url.
# info:url will show a page containing links to related searches, backlinks, and pages containing the url. This is the same as typing the url into the search box.
# spell: will spell check your query and search for it.
# stocks: will lookup the search query in a stock index.
# filetype: will restrict searches to that filetype. "-filetype:pdf" to remove Adobe PDF files.
# daterange: is supported in Julian date format only. 2452384 is an example of a Julian date.
# maps: If you enter a street address, a link to Yahoo Maps and to MapBlast will be presented.
# phone: enter anything that looks like a phone number to have a name and address displayed. Same is true for something that looks like an address (include a name and zip code)
# site:www.somesite.net "+www.somesite.+net" - (tells you how many pages of your site are indexed by google)
# allintext: searches only within text of pages, but not in the links or page title
# allinlinks: searches only within links, not text or title

Saturday, January 06, 2007

Top 5 new (and cool!) features in PHP5 that you probably haven’t heard of at vexxhost

PHP5 has brought so much new features but because of its big syntax changes, a big percentage of the PHP developing base has not made the change. Here are the top 10 new features that could change your mind.

Read more at vexxhost.com/blog/?p=27

Saturday, December 09, 2006

PHP Optimization Tricks

There are a number of tricks that you can use to squeeze the last bit of performance from your scripts. These tricks won't make your applications much faster, but can give you that little edge in performance you may be looking for. More importantly it may give you insight into how PHP internals works allowing you to write code that can be executed in more optimal fashion by the Zend Engine. Please keep in mind that these are not the 1st optimization you should perform. There are some far easier and more performance advantageous tricks, however once those are exhausted and you don't feel like turning to C, these maybe tricks you would want to consider. So, without further ado...
1) 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 a isset() trick.

Ex.
if (strlen($foo) < href="http://php-docs.blogspot.com/">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.

3) When it comes to printing text to screen PHP has so many methodologies to do it, not many users even know all of them. This tends to result in people using output methods they are already familiar from other languages. While this is certainly an understandable approach it is often not best one as far as performance in concerned.

print vs echo

Even both of these output mechanism are language constructs, if you benchmark the two you will quickly discover that print() is slower then echo(). The reason for that is quite simple, print function will return a status indicating if it was successful or not, while echo simply print the text and nothing more. Since in most cases (haven't seen one yet) this status is not necessary and is almost never used it is pointless and simply adds unnecessary overhead.

printf

Using printf() is slow for multitude of reasons and I would strongly discourage it's usage unless you absolutely need to use the functionality this function offers. Unlike print and echo printf() is a function with associated function execution overhead. More over printf() is designed to support various formatting schemes that for the most part are not needed in a language that is typeless and will automatically do the necessary type conversions. To handle formatting printf() needs to scan the specified string for special formatting code that are to be replaced with variables. As you can probably imagine that is quite slow and rather inefficient.

heredoc

This output method comes to PHP from PERL and like most features adopted from other languages it's not very friendly as far as performance is concerned. While this method allows you to easily output large chunks of text while preserving things like newlines and even allow for variable handling inside the text block this is quite slow and there are better ways to do that. Performance wise this is just marginally faster then printf() however it does not offer nearly as much functionality.

?> <?

When you need to output a large or even a medium sized static bit of text it is faster and simpler to put it outside the of PHP. This will make the PHP's parser effectively skipover this bit of text and output it as is without any overhead. You should be careful however and not use this for many small strings in between PHP code as multiple context switches between PHP and plain text will ebb away at the performance gained by not having PHP print the text via one of it's functions or constructs.

4) Many scripts tend to reply on regular expression to validate the input specified by user. While validating input is a superb idea, doing so via regular expression can be quite slow. In many cases the process of validation merely involved checking the source string against a certain character list such as A-Z or 0-9, etc... Instead of using regex in many instances you can instead use the ctype extension (enabled by default since PHP 4.2.0) to do the same. The ctype extension offers a series of function wrappers around C's is*() function that check whether a particular character is within a certain range. Unlike the C function that can only work a character at a time, PHP function can operate on entire strings and are far faster then equivalent regular expressions.
Ex.
preg_match("![0-9]+!", $foo);
vs
ctype_digit($foo);

5) Another common operation in PHP scripts is array searching. This process can be quite slow as regular search mechanism such as in_array() or manuall implementation work by itterating through the entire array. This can be quite a performance hit if you are searching through a large array or need to perform the searches frequently. So what can you do? Well, you can do a trick that relies upon the way that Zend Engine stores array data. Internally arrays are stored inside hash tables when they array element (key) is the key of the hashtables used to find the data and result is the value associated with that key. Since hashtable lookups are quite fast, you can simplify array searching by making the data you intend to search through the key of the array, then searching for the data is as simple as $value = isset($foo[$bar])) ? $foo[$bar] : NULL;. This searching mechanism is way faster then manual array iteration, even though having string keys maybe more memory intensive then using simple numeric keys.

Ex.

$keys = array("apples", "oranges", "mangoes", "tomatoes", "pickles");
if (in_array('mangoes', $keys)) { ... }

vs

$keys = array("apples" => 1, "oranges" => 1, "mangoes" => 1, "tomatoes" => 1, "pickles" => 1);
if (isset($keys['mangoes'])) { ... }

The bottom search mechanism is roughly 3 times faster.

Tuesday, November 07, 2006

Programming Designs Forums / 10 Old Photos of Famous Programmers and Business Men

Found some cool old photos of various people such as Linus Torvald, Larry Page, Sergey Brin, Dennis Ritchie, Steve Woznaik, Steve Jobs, and more. A blast from the past.

PHP Programming1. Tim Berners Lee. Founder of the World Wide Web.PHP Programming2. Steve Woznaik (the one sitting down) and Steve Jobs of APPLE Computers. He was three months late in filing a name for the business because he didn't get any better name for his new company. So one day he told to the staff: "If I'll not get better name by 5 o'clcok today, our company's name will be anything he likes..." so at 5 o'clcok nobody comeup with better name, and he was eating APPLE that time... so he keep the name of the company 'Apple Computers'.PHP Programming3. Bill Hewlett (left) and Dave Packard (right) of HP. Behind them in the picture is the famous HP Garage. Bill Hewlett and Dave Packard tossed a coin to decide whether the company they founded would be called Hewlett-Packard or Packard-Hewlett. And the winner was NOT Bill... the winner was Dave.PHP Programming4. Picture taken when Microsoft was started. What a group of nerds xDPHP Programming5. Ken Thompson (left) and Dennis Ritchie (right) , creators of UNIX. Dennis Ritchie improved on the B programming language and called it 'New B'. B was created by Ken Thompson as a revision of the Bon programming language (named after his wife Bonnie). He later called it C.PHP Programming6. Larry Page (left) and Sergey Brin (right), founders of Google. Google was originally named 'Googol'. After founders (Stanford graduates) Sergey Brin and Larry Page presented their project to an angel investor... they received a cheque made out to 'Google' !... So they kept name as GOOGLE.PHP Programming7. Gordon Moore (left) and Bob Noyce (right) ,founders of Intel. Bob Noyce and Gordon Moore wanted to name their new company 'Moore Noyce'. But that was already trademarked by a hotel chain... So they had to settle for an acronym of INTegrated ELectronics... INTELPHP Programming8. Scott Mc Nealy, Andreas Bechtolsheim , Bill Joy and Vinod Khosla of SUN(StanfordUniversity Network) MicroSystems. Founded by four StanfordUniversity buddies. Andreas Bechtolsheim built a microcomputer; Vinod Khosla recruited him; Scott McNealy to manufacture computers based on it; and Bill Joy to develop a UNIX-based OS for the computer... SUN is the acronym for Stanford University Network.PHP Programming9. Linus Torvalds of Linux Operating System Linus Torvalds originally used the Minix OS on his system which he replaced by his OS. Hence the working name was Linux (Linus' Minix). He thought the name to be too egotistical and planned to name it Freax (free + freak + x). His friend Ari Lemmk encouraged Linus to upload it to a network so it could be easily downloaded. Ari gave Linus a directory called linux on his FTP server, as he did not like the name Freax. Linus like that directory name and he kept the name of his new OS to LINUX...PHP Programming10. Picture taken when INFOSYS was started. This picture was found in the album of the clerk who took this picture on his birthday...

Thursday, September 07, 2006

PHP statistics for August 2006

Here are the PHP stats for August 2006. To learn about methodology, read la section phpversion. 15 millions servers were surveyed during May, and 8,2 were used for stats : domaines without web sites, those unreachable, ISP or domain parkings were not considered.

Read more at www.nexen.net/chiffres_...

Thursday, August 10, 2006

Jani Taskinen, Lead PHP Developer, Quits

Jani Taskinen, one of the lead developers of the Zend Engine (the engine that powers PHP), as well as a lead developer for the thread safety system and other core components of the PHP project, has quit in a relatively cryptic message to the php-internals mailing list. Jani has been involved with PHP for about 6 years and his loss will undoubtedly be a big blow for the PHP project.


From: Jani Taskinen

Thank you all for the last 6 years or so.
It has been fun (sometimes) and many times not so much fun.
Unfortunately I have had enough and I don't want to be associated with this project anymore. I'm sure most people (the ones who matter) can understand why. If someone doesn't, I could not care less. Take care.

Please do not reply to this email.

--Jani

p.s. Delete my CVS account. I have no use for it anymore


From IRC conversation:

"_sniper_" is Jani Taskinen.

<_sniper_> hehehehe..
<_sniper_> all other members of the UN security council wanted to condemn Israel for attacking the UN post but USA (freedom and democracy) vetoed it....Israel says the resolution was fair.
<_sniper_> hell yeah..
<_sniper_> NUKE ISRAEL!
<_sniper_> I'm so full of that fucking country..
indeed
<_sniper_> Eye for an eye..I'll kill one Israel officer for one of ours, is that fair?
<_sniper_> I bet I'll be hanged for that.
<_sniper_> They kill one of my brother-in-arms-for-peace..I think I'm entitled to kill one of their nazis.
<_sniper_> Hezbollah, where can I enlist?
<_sniper_> FYI: I don't care at all what anybody thinks about me. I'm going to be openly anti-Israel from now on. This was the last straw for me. Fuck you jews.
<_sniper_> I will also quit this project. As long as it's backed by some Israel company, I don't want to have anything to do with it.
<_sniper_> Good bye.
<-- _sniper_ (~jani@a88-112-115-63.elisa-laajakaista.fi) has left #php.pecl

Saturday, July 15, 2006

Implementing Additional Methods with mysqli and PHP 5

Welcome to the third installment of the series "Using mysqli in PHP5." Comprised of three articles, this series teaches you how to use the most important methods and properties included in the "mysqli" extension, which is bundled with PHP 5, in order to get the most out of the MySQL 4.1 database server and above.

Introduction

If you've been reading up my two previous articles, then quite probably you'll know how to utilize the mysqli's core methods for connecting to MySQL, as well as performing many other useful tasks, such as running single and multiple queries, preparing SQL statements, and using the COMMIT and ROLLBACK features found in MySQL 4.1 and up. What's more, you'll surely recall that this extension allows you to handle one or more result sets via an object-oriented approach, which is very convenient if you're particularly inclined to work with object-based applications.Additionally, I covered, with numerous hands-on examples, other combinations of handy methods and properties, in order to show you how to perform some common MySQL-related operations. In this case obviously I'm talking about counting the number of rows affected after running a specific query, or determining the number of rows returned by a result set, among others. Of course, one of the best points regarding the use of the "mysql" library rests on how easily it allows you to accomplish all the things (and more) that I mentioned before by using an object-oriented approach, without the need to define custom classes. Once the library is available to your system, you can go ahead and start writing down object-based code.Well, if I stand behind the previous paragraphs, I must say that the "mysqli" extension offers an impressive set of features, which can be implemented right from the very beginning. However, and speaking of its cool features, in the next few lines, I'm going to show you a few more. Over the course of this last tutorial, I'll be covering some other methods and properties, mainly aimed at finding the IDs after inserting new rows, and obtaining information about specific table fields.Now, be patient and start reading the last chapter of this story. Let's do it together!

Next: Fetching rows, finding IDs and moving result set pointers: implementing the “fetch_array()” and “data_seek()” methods >>

Tuesday, June 20, 2006

PHP DEVELOPMENT :: GOOGLE CALENDARE

Now you can get the word out to anyone, because we just added a new publishing feature that lets you show an interactive calendar to others -- even if they don't use Google Calendar.

Read more at googleblog.blogspot.com...

Saturday, June 10, 2006

Developing PHP the Ajax way

Asynchronous JavaScript and XML ( Ajax ), is arguably the most popular new Web technology. In this two-part "Developing PHP the Ajax way" series, you will create a simple photo album as an online Web application, entirely in PHP and the Simple Ajax Toolkit (Sajax). You'll begin by writing a simple photo album using the standard method of PHP development and later apply Sajax to make it an active Web application.

Read more at www-128.ibm.com/develop...

The Basics of Serializing Objects in PHP

Object serialization in PHP is very easy, and can be used for a variety of different purposes. It can be used to perform some fairly complex operations, in fact. This article, the first of a three-part series, introduces you to object serialization and a number of the tasks for which you can put this approach to use.

Read more at www.devshed.com/c/a/ PHP ...

Saturday, May 27, 2006

PHP DEVELOPMENT: Picasa for Linux

Let's say you happily use Linux, but you sometimes find yourself wishing you had access to interesting new apps that launch for Windows but not Linux. And maybe, like a lot of us, you have a lot of photos stored on your personal machine, and you've read about or even tried Google's photo organizer, Picasa. But using it means switching to Windows, even temporarily. (We know--thanks but no thanks.)

Read more at googleblog.blogspot.com...

Tuesday, May 23, 2006

An Introduction to Sockets in PHP

Working with low-level sockets can be a painful task in PHP. Fortunately, PHP offers a nice library of socket handling functions to make your life easier. If you do a lot of network programming in PHP, you will want to check out this three-part series, which starts with the basics and takes you through more advanced approaches. This article is the first one in the series.

Read more at www.devshed.com/c/a/PHP...

Thursday, May 18, 2006

PHP IDE Debug Protocol

Lately there were many questions and comments on blogs and in PHP related forums regarding the debugger protocol, which will be used in the PHP IDE project at Eclipse.org. For those of you who are not familiar with the ' debug protocol ' term or do not know what I am talking about here is a short explanation. PHP IDE Debug Protocol

Wednesday, May 17, 2006

Making AJAX development easier

AJAX has the power to make your site more compelling and more dynamic, but AJAX development is often complicated, with much of the development time spent working around browser quirks and the fragility of AJAX components. Trust us, we know--the development of our own AJAX apps, like Google Maps and Google Calendar, caused us no small amount of AJAX-induced frustration.

Making AJAX development easier

Monday, May 15, 2006

Creating ZIP and TAR archives on the fly with PHP

In this tutorial you will learn how to create ZIP and TAR archives dynamically using PHP and the PEAR::Archive_Zip and PEAR::Archive_Tar packages.

Creating ZIP and TAR archives on the fly with PHP

Thursday, May 11, 2006

PHP Optimization

Php optimization is the skill of fine tuning an application to extract maximum performance with minimum server load. Many of my clients in the past have wondered why I spend extra hours just to get the script execution time to be cut down by 1 second.

PHP Optimization

PHP GAINS IN THE TIOBE PROGRAMMING COMMUNITY INDEX

The TIOBE Programming Community Index has been updated for April 2006 showing their view on the status of programming languages in the development community. PHP moves up a spot from 5th to 4th. The long-in-the-tooth C fades back a bit relinquishing 1st place to Java, while C++ gains on its brethren with PHP biting on its heels (a margin of 0.02 between their percentages). PHP has a higher climb rate so expect another big move in the coming year.

Monday, May 08, 2006

PHP : Zend Framework

PHP Powers the WebNow, the world's most popular web programming language gets even better with an easy to use framework for developing the next generation of web applications.

Read more at framework.zend.com/

PHP Documentation

PHP Documentation - little collection of the docs,tutorials and howtos related to Linux/Unix programming, system administration and web development. PHP Documentation

Read more at www.php.net/docs.php