Linux, Open Source and Web 2.0 http://articles.itecsoftware.com Itec Software Wed, 25 Aug 2010 20:06:32 +0000 en hourly 1 http://wordpress.org/?v=3.0.1 Using Regular Expression In PHP – The Basics http://articles.itecsoftware.com/web-development/using-regular-expression-in-php-the-basics http://articles.itecsoftware.com/web-development/using-regular-expression-in-php-the-basics#comments Wed, 25 Aug 2010 20:03:56 +0000 Peter http://articles.itecsoftware.com/?p=495 regular expressions cookbookRegular expressions are a powerful tool for finding, examining and/or modifying text. Regular expressions themselves are, with a general pattern notation almost like a mini programming language, allowing you to define and parse text. They enable you to search for patterns within a string, extracting matches flexible and precise. However, you should note that because regular expressions are more powerful, they also suffer from added overhead and are slower than the more basic string functions. You should make careful consideration and only use regular expressions if you have a particular need.

PHP supports two different types of regular expressions: POSIX-extended and Perl-Compatible Regular Expressions (PCRE). The PCRE functions are more commonly used, are more powerful than the POSIX ones and faster as well

In a regular expression, most characters match only themselves. For instance, if you search for the regular expression “foo” in the string “only a fool does not use regular expressions” you get a match because “foo” occurs in that string. Some characters have a special meaning. For instance, the dollar sign ($) is used to match strings that end with the given pattern. Similarly, a caret (^) character at the beginning of a regular expression indicates that it must match the beginning of the string. Characters that match themselves are called literals while characters that have special meanings are called metacharacters.

The dot (.) metacharacter matches any single character except newline (\). Hence, the pattern h.t matches hat, hothit, hut and h7t. The vertical pipe (|) metacharacter is used for alternatives in a regular expression. It behaves much like a logical OR operator and you should use it if you want to construct a pattern that matches more than one set of characters. For instance, the pattern Monday|Tuesday|Wednesday matches strings that contain “Monday” or “Tuesday” or “Wednesday”. Parentheses are used to group sequences. For example, (fri|satur)day matches “friday” or “saturday”. Using parentheses to group characters for alternation is called grouping.

If we want to match a literal metacharacter in a pattern, we have to escape it with a backslash.

To specify a set of acceptable characters in a pattern, we can either build a character class ourself, or use a predefined one. A character class lets us represent a bunch of characters as a single item. We can build our own character class by enclosing the acceptable characters in square brackets. A character class matches any one of the characters in the class. For example a character class [abc] matches a, b or c. To define a range of characters, we just add the first and last characters separated by hyphen. For example, to match all alphanumeric characters: [a-zA-Z0-9]. We can also create a negated character class, which matches any character that is not in the class. To create a negated character class, we start the character class with ^: [^0-9].

Metacharacters +, *, ?, and {} affect the number of times a pattern should be matched. + means “Match one or more of the preceding expression”, * means “Match zero or more of the preceding expression”, and ? means “Match zero or one of the preceding expression”. Curly braces {} are be used differently. With a single integer, {n} means “match exactly n occurrences of the preceding expression”, with one integer and a comma, {n,} means “match n or more occurrences of the preceding expression”, and with two comma-separated integers {n,m} means “match the previous character if it occurs at least n times, but no more than m times”.

]]>
http://articles.itecsoftware.com/web-development/using-regular-expression-in-php-the-basics/feed 0
Ubuntu 10.10 Maverick Meerkat Said To Be Radical http://articles.itecsoftware.com/linux/ubuntu-10-10-maverick-meerkat-said-to-be-radical http://articles.itecsoftware.com/linux/ubuntu-10-10-maverick-meerkat-said-to-be-radical#comments Tue, 24 Aug 2010 15:44:02 +0000 Peter http://articles.itecsoftware.com/?p=526 Ubuntu LogoThe new anticipated release of Ubuntu 10.10,  named “Maverick Meerkat” (currently in alpha2) is said to be radical, according to Marc Shuttleworth, chief of Canonical.

Canonical head Mark Shuttleworth mentioned on his blog that the upcoming Ubuntu version 10.10 will be focused on being social and fast. Shuttleworth says “The OS is getting faster and faster when it comes to boot times but the final push remains”. In the mean time, he said that the Netbook Edition of Ubuntu 10.10 will have a revamped UI and will be the fastest booting, fastest network OS for netbooks at this time. Canonical is the company that finances and oversees the Ubuntu project.

Ubuntu 10.10 is being called “Maverick Meerkat”. Meerkats are social creatures by nature and very family oriented and therefore has been adopted for this release. The Ubuntu project has been working very hard to become a viable and open source alternative to leading operating systems such as Mac OS X and  Windows 7.

Ubuntu is probably the most installed Linux distro currently, thanks to many different flavors (Ubuntu, Kubuntu, Xubuntu, Edubuntu, Ubuntu Studio and Ubuntu Netbook Edition). These variations include desktop and server versions including applicable applications and default settings. The last one is for netbooks and started with the amalgamations of Intel’s Moblin (Mobile Linux) into Ubuntu.

Ubuntu 10.10 promises to make everything faster and better than ever before, but ultimately will depend on how good Canonical is at keeping promises. Ubuntu has become a strong competitor and real alternative, and that is especially true for netbooks. For the average consumer, power users and production systems, the benefits come in the form of low cost, good stability and increased security.

Learn more about Ubuntu and the upcoming release.

]]>
http://articles.itecsoftware.com/linux/ubuntu-10-10-maverick-meerkat-said-to-be-radical/feed 0
Install And Use CouchDB With JSON And Map-Reduce http://articles.itecsoftware.com/web-development/install-and-use-couchdb-with-json-and-map-reduce http://articles.itecsoftware.com/web-development/install-and-use-couchdb-with-json-and-map-reduce#comments Sat, 14 Aug 2010 19:34:38 +0000 Peter http://articles.itecsoftware.com/?p=511 CouchDB is another offspring from the open-source, NoSQL, non-relational databases and is maintained under the Apache Foundation. It differs itself form the likes of MongoDB or Cassandra in that CouchDB is storing data in so called “documents” that are in JSON format, which can be hashes, lists, nested arrays and of course scalar values. This added complexity results in more powerful features, mainly to have a db that is not just a single key/value pair, but it comes at a price of speed reduction.

CouchDB can be a little bit of a pain to install, because it needs a few pre-requisites and they in turn have a few of their own quirks. This outline should help you get CouchDB with all it’s necessities installed. We’ve used MacOS, but you can substitute your OS where applicable.

The CouchDB source code and installer packages are downloadable here. As of this writing, version 0.11.2 is the latest stable version, with 1.0.1 just around the corner. You will also need Spider Monkey, Mozilla’s C implementation of JavaScript.

Installing SpiderMonkey

Once downloaded, extract the tarball and move into the sources folder:

tar -xzvf js-1.8.0-rc1.tar.gz

cd js/src

If you’re installing SpiderMonkey on a Mac, there is a small hack to the jsprf.c file. Adding the following two lines (in orange below) after line 60 should resolve the build issue:

60: #define VARARGS_ASSIGN(foo, bar) VA_COPY(foo,bar)
61: #elif defined(va_copy)
62: #define VARARGS_ASSIGN(foo, bar)

63: #elif defined(HAVE_VA_LIST_AS_ARRAY)

Now we should have no issue running make:

make BUILD_OPT=1 -f Makefile.ref

sudo sh

sudo make BUILD_OPT=1 JS_DIST=/usr/local -f Makefile.ref export

Installing ICU

ICU is a library for International Components for Unicode and CouchDB relies on it. Let’s download it from icu-project.org here. Once downloaded, extract the package and move into the sources folder and change some permissions before building the code:

tar -xzvf icu4c-4_4_1-src.tgz

cd icu/source

chmod +x runConfigureICU configure install-sh

./runConfigreICU -h (select the suffix for your OS and and supply it as argument to runConfigureICU, eg: ./runConfigureICU MacOS)

make

sudo make install

Installing Erlang

Erlang is the language used to build CouchDB, and you’ll have to install it if it’s not yet present. Download Erlang version 14A (latest as of this writing) from erlang.org here or use wget or curl as in the steps below.
cd /tmp
wget http://www.erlang.org/download/otp_src_R14A.tar.gz
tar -xzvf otp_src_R14A.tar.gz
cd otp_src_R14A
./configure –enable-hipe –enable-smp-support –enable-threads (–enable-darvin-universal for Mac)
make
sudo make install

Installing CouchDB

Now finally we’re ready to install CouchDB.

cd /tmp

wget http://www.apache.org/dyn/closer.cgi?path=/couchdb/0.11.2/apache-couchdb-0.11.2.tar.gz

tar -xzvf apache

cd apache-couchdb-0.11.2

./configure

make

sudo make install

sudo couchdb start

Testing our CouchDB installation

Besides the countless client libraries written in almost any language, we can simply use Telnet to create a database and do some basic data manipulation to test our installation.

telnet localhost 5984

If there are no errors and you get a response like below, you’re all set.

Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.

A good introduction to CouchDB’s commands can be found here.

]]>
http://articles.itecsoftware.com/web-development/install-and-use-couchdb-with-json-and-map-reduce/feed 0
Enable Gzip Compression In Apache And Optimize Page Load http://articles.itecsoftware.com/web-development/enable-gzip-compression-in-apache-and-optimize-page-load http://articles.itecsoftware.com/web-development/enable-gzip-compression-in-apache-and-optimize-page-load#comments Thu, 12 Aug 2010 17:31:09 +0000 Peter http://articles.itecsoftware.com/?p=471 HTML, CSS and Javascript compression is a simple and effective way to save bandwidth and speed up page load on your site. It’s often overlooked and yet simple to implement, just enable Gzip compression for the right document types and enhance your site’s user experience.

In Apache, we achieve this by enabling content encoding. When a user requests a file like http://www.msn.com/index.html, the browser communicates to a web server, and the conversation goes a something like this:

1. Browser: GET me /index.html
2. Server: Found indes.html, it’s 187KB! Response code is 200 (200 OK) , requested file is coming
3. Browser: 187KB, loading

The actual headers and protocols sent between the two are much more formal (monitor them with HTTPFox, Live HTTP Headers or others if you like.

Now, everything worked just fine in our little scenario, the browser got it’s requested file (index.html) of 187KB in size and probably also loaded include files such as javascript, css and a bunch of images. Especially on lower speed Internet connections, it took a few seconds for the page to load all files.

That’s where compression comes in. Html, javascript and css are plain text and are ideal candidates for compression, while images and videos usually underwent some compression algorithm when saved as jpg, png, avi or flv. Compressing those files would provide very little to no improvement in file size and add processing overhead to the web server. So we want to ensure we exclude those.

1. Browser: GET me /index.html, compressed if available
2. Server: Found index.html, it’s 35KB, compressed! Response code is 200 (200 OK) , requested file is coming
3. Browser: got index.html, extracting and loading

How do the browser and server know whether to send a file compressed or not?  The agreement has two parts:

1. The browser sends a header during the request, telling the server it accepts compressed content (Accept-Encoding: gzip, deflate)
2. The server sends a response if the content is actually compressed: Content-Encoding: gzip

If the server doesn’t reply with the content-encoding response header, it means the file is not compressed. The “Accept-Encoding” header is just a best effort request, meaning the server can respond either way.

Setting up the web server to enable page compression

To enable html, css and javascript compression in Apache, we add the output filter “Deflate” to the apache config, or .htaccess file. The latter is only recommended if you’re on a shared hosting plan and don’t have access to the config files. Here we declare several different formats, also called MIME types, to be delivered compressed if requested:

<Directory “/your-server-root”>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</Directory>

We encourage you to read more about mod_deflate. There is also a another option next to “mod_deflate”, the external “mod_gzip” module and can be found here. Note that:

- mod_deflate is easier to set up and is standard.
- mod_gzip seems more powerful and you can pre-compress content.

In either case, Apache checks for the “Accept-encoding” header and returns either the compressed or regular version of the file. Some older browsers however may have issues and there are special directives we can add to handle them like such:

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Once we’ve configured our server, let’s verify that we’re actually serving up compressed content.

- Online: Use the online gzip test to check whether your page is compressed.
- In your browser: Use Firebug and inspect the header for “Content-Encoding”
- View the headers: Use HTTPFox or Live HTTP Headers to examine the response headers.

Some issues to watch out for when enabling compression:

- Older browsers still can have trouble with compressed content (they say they can accept it, but really they can’t). If your site absolutely must work with Netscape 1.0 on Windows 95, you may not want to use HTTP Compression. Apache mod_deflate has some rules to avoid compression for older browsers.
- Already-compressed content: Most images, music and videos are already compressed. Don’t waste time compressing them again. In fact, you probably only need to compress the “big 3″ (HTML, CSS and Javascript).
- CPU-load: Compressing content on-the-fly uses CPU time and saves bandwidth. Usually this is a great tradeoff given the speed of compression. There are ways to pre-compress static content and send over the compressed versions. This requires more configuration; even if it’s not possible, compressing output may still be a net win. Using CPU cycles for a faster user experience is well worth it, given the short attention spans on the web.

]]>
http://articles.itecsoftware.com/web-development/enable-gzip-compression-in-apache-and-optimize-page-load/feed 0
Redis High Speed Storage Or Cache System http://articles.itecsoftware.com/web-development/redis-high-speed-storage-or-cache-system http://articles.itecsoftware.com/web-development/redis-high-speed-storage-or-cache-system#comments Wed, 11 Aug 2010 18:05:14 +0000 Peter http://articles.itecsoftware.com/?p=498 NoSQL databases are the hype, with MongoBD and CouchDB on the forefront, while Memcache has found a place in many high load web applications during the past few years. Each of these applications has their own, very specific characteristic. MongoDB finds its usage where single key-value pairs are not sufficient, but adds a slight overhead and complexity with its hash table like multi field storage architecture. CouchDB is an ideal candidate where single key-value pair storage engine is sufficient.

And there is Redis, the new kid on the block. Redis is a high speed storage or cache system, much like Memcache on steroids. Redis writes data into memory, which makes it really fast. And in contrast to Memcache, it writes data periodically to disk depending on the amount of data that has changed. Redis is been said to be able to handle in excess of 10’000 reads/writes per second!

In contrast to Memcache, Redis has its own client language. The basic “set” and “get” are pretty much standard, but we can increment values, set lists and sets and easily handle key replacements and checks for existing values.

As of this writing, version 2 is in Release Candidate 4. For production environments, you’re highly encouraged to use the stable version 1.2.6. To install Redis, download the desired version, untar and switch to the Redis directory. There is no configure script, we just call make, then copy “redis_server” and “redis-cli” to your desired location (eg. /usr/local/bin) and copy redis.conf to /etc/. Let’s start it up! Although I downloaded version 2 RC 4, the server shows version 1.3.17:

redis-server
[3926] 11 Aug 10:42:33 * Server started, Redis version 1.3.17
[3926] 11 Aug 10:42:33 * The server is now ready to accept connections on port 6379
[3926] 11 Aug 10:42:33 – 0 clients connected (0 slaves), 1074272 bytes in use
[3926] 11 Aug 10:42:33 * Server started, Redis version 1.3.17
[3926] 11 Aug 10:42:33 * The server is now ready to accept connections on port 6379
[3926] 11 Aug 10:42:33 – 0 clients connected (0 slaves), 1074272 bytes in use

We can now use Telnet to connect on port 6379 or use the Command Line Interface that comes with Redis (redis-cli) and issue some commands:

redis> get firstName
(nil)
redis> set firstName Peter
OK
redis> get firstName
“Peter”
redis> setnx firstName Peters
(integer) 0
redis> get firstName
“Peter”
redis> setnx firstNames Peters
(integer) 1
redis> get firstNames
“Peters”
redis>

Complete command reference can be found here and it’s highly encouraged that you play around with them and get familiar with the CLI commands. It is really amazing what Redis provides in terms of powerful memory storage solution coupled with such an easy setup and usage. One thing is for sure, we’re hooked.

]]>
http://articles.itecsoftware.com/web-development/redis-high-speed-storage-or-cache-system/feed 0
Create Patch Files Using Patch And Diff http://articles.itecsoftware.com/linux/create-patch-files-using-patch-and-diff http://articles.itecsoftware.com/linux/create-patch-files-using-patch-and-diff#comments Wed, 04 Aug 2010 20:00:34 +0000 Peter http://articles.itecsoftware.com/?p=484 Using diff to create batch files and subsequently running them against select files is such a convenient way to update, fix or change existing files, but many developers and system administrators simply don’t know much about them.

Here is a quick primer on using diff and apply changes for select files. Use diff –help to check out more options and flags.

NOTE: pay caution when using patching, any mistake or error are executed without warning or undo feature. It’s best to always make a backup of any file or folder that are going to be affected by your patch.

diff

Some useful flags you can specify when comparing files are -b (ignore white space difference), -B (ignore blanc lines), -r (recursive) and -i (ignore case).

Let’s say we need to change the GA analytics code on our pages and that they are unfortunately hard coded. The files are shown below as are the results from diff:

File GA_v1:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9876543-21']);
_gaq.push(['_setDomainName', '.domain.com']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl ‘ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

File GA_v2:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1234567-89']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

File GAold.patch, resulting from running diff -bi GA_v1 GA_v2 > GA_v2.patch:

2c2,3
<   _gaq.push(['_setAccount', 'UA-1234567-89']);

>   _gaq.push(['_setAccount', 'UA-9876543-21']);
>   _gaq.push(['_setDomainName', '.domain.com']);
7c8
<     ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;

>     ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl <https://ssl/> ‘ : ‘http://www’) + ‘.google-analytics.com/ga.js’;

“2c2,3″ = copy line 2 (from GA_v1) to line 2 (of GA_v2), insert line 3
“7c8″ = copy line 7 to line 8

(c – copy, d – delete, a – add)

patch

And with this file available, we now can use patch to perform the changes. One really important flag is --dry-run It does not actually change any files, just print what would happen. And -b will make a backup of your files. Please use it especially if you’re new to patching.

patch –dry-run GA_v1 < GA_v2.patch

If you get no errors, you’re good to go.

patch -b GA_v1 < GA_v2.patch (using -b to make a backup)

Doing a diff of GA_v1 and GA_v2 shows a difference of 1 empty line. We could have avoided that using the -B flag when creating the patch file using diff, but there are many more options for both, diff and patch commands and we encourage you to explore them.

]]>
http://articles.itecsoftware.com/linux/create-patch-files-using-patch-and-diff/feed 0
How To Clean Up The New Ubuntu Grub2 Boot Menu http://articles.itecsoftware.com/linux/how-to-clean-up-the-new-ubuntu-grub2-boot-menu http://articles.itecsoftware.com/linux/how-to-clean-up-the-new-ubuntu-grub2-boot-menu#comments Sun, 01 Aug 2010 18:41:14 +0000 Peter http://articles.itecsoftware.com/?p=473 Clean Up And Modify he new Ubuntu Grub2 boot menu differs quite a bit from the previous version. As Ubuntu nominated the new version 2 of the Grub boot manager as of 9.10, removing of the old problematic menu.lst file.

Ubuntu Grub2 Boot Menu

Ubuntu Grub2 Boot Menu

Grub2 is a leap forward in many ways, and most of the annoyances from menu.lst are gone. Yet, if you don’t clean up old versions of kernel entries, the boot list can quickly get messy and end up in a long list of nonsense. Let’s assume we want to remove the 2.6.32-21-generic boot menu entries. Previously, this meant editing /boot/grub/menu.lst. But with Grub2, we use the package manager to remove the kernel package from our computer, Grub automatically removes those options. Btw. if only one operating system is installed on your computer, you may not see the boot menu at all and have to hold down the SHIFT button on your keyboard while booting up to get the menu to show.

To remove old kernel versions, open up Synaptic Package Manager, found in the System > Administration menu. When Synaptic opens up, type the kernel version that you want to remove into the Quick search text field. The first few numbers should suffice. Then for each of the entries associated with the outdated kernel (e.g. linux-headers-2.6.32-21 and linux-image-2.6.32-21-generic), right-click and choose “Mark for Complete Removal”, then hit “Apply”. These entries will be gone upon the next boot.

If you like more control, or add/remove entries that are not kernel related, you can change the file grub.d located in /etc. This file contains files that hold menu entries that used to be located in /boot/grub/menu.lst. If you want to add new boot menu entries, you simply create a new file in this folder, ensure it is executable (chmod +x).

Another way to remove boot menu entries without deleting the files is to remove execute flag (chmod -x). With any change to these files, we need Grub to update it’s database: sudo update-grub.

For more information on Grub2, it’s inner workings and differences to it’s older sibling, check out Ubuntu Grub2 Wiki

]]>
http://articles.itecsoftware.com/linux/how-to-clean-up-the-new-ubuntu-grub2-boot-menu/feed 0
7 Tips To Improve Web Page Load Time http://articles.itecsoftware.com/web-development/7-tips-to-improve-web-page-load-time http://articles.itecsoftware.com/web-development/7-tips-to-improve-web-page-load-time#comments Sat, 10 Jul 2010 16:39:50 +0000 Peter http://articles.itecsoftware.com/?p=464 With the increasing focus on Google’s Site Speed Algorithm, the following are 7 tips to improve web page load time, proven techniques well known websites use to boost their site speed.

1. Enable Gzip Compression

While compressing pages adds just a tad to your web server’s overhead, it will reduce bandwidth and transmission time and make pages appear to load faster for your users. Gzip is a open source compression algorithm that can be used to compress the content of your website before your the web server sends data to a client browser. You can learn how to enable Gzip in Apache here.

2. Minify Javascript/CSS

Minify is the process (and software) of removing unnecessary formatting characters and white space from javascript code. The result is smaller files, faster transmission and quicker page loads. You can learn all about minify javascript here.

3. Use A Content Distribution Network (CDN)

A CDN is a system of interconnected servers around the glove, that distribute content and assets around among them to reduce the distance between a server and a client’s browser. They are commonly used by large media web sites, such as Youtube and Break. You can find a list of free CDNs here.

4. Optimize Images

Take advantage of image compression and reduce the size of photos and graphics on you site dramatically. Never use a raw bitmap (.bmp) on your site, instead save photos as JPEG and graphics as PNG. Smaller images tend to be ok with a smaller quality setting, while large photos should be high to enjoy.

5. Use External Hosts Javascript And CSS

The Http protocol sets a limit as to how many concurrent files can be downloaded from a given host. This is currently set to two, which means the browser will have to wait for one to finish before getting the next file. While this isn’t true of all file types, it is a good enough reason to host applicable files on alternative subdomains. Hosting your Javascript and CSS files on a different subdomain increases the amount of files the browser can download simultaneously.

6. Avoid Using Redirects

While redirects can be very useful, it’s important to remember that implementing them forces your web server to do slightly more work per applicable request. Always avoid redirect strings (301 -> 301 -> 200 or even worse 301 -> 302 -> 200) and use these tools only when no other alternatives are available.

7. Use Fewer Files

Of the most simple and quick way to improve load time is to combine files into one. Remember the limit of downloads discussed in item 5 above? Try combining Javascript and CSS files, and make use of CSS sprites. It’s a method of combining several images in one file and use CSS for positioning. You can read how popular websites using sprites here.

]]>
http://articles.itecsoftware.com/web-development/7-tips-to-improve-web-page-load-time/feed 0
Install PHP 5.2 on Ubuntu 10.04 Lucid Lynx http://articles.itecsoftware.com/web-development/install-php-5-2-on-ubuntu-10-04-lucid-lynx http://articles.itecsoftware.com/web-development/install-php-5-2-on-ubuntu-10-04-lucid-lynx#comments Wed, 30 Jun 2010 15:37:38 +0000 Peter http://articles.itecsoftware.com/?p=423 There are many reasons why we want to install PHP 5.2 on Ubuntu 10.04 Lucid Lynx, the most prominent is that many web packages are not compatible yet with PHP 5.3. Drupal 6 being a prime example.

But there is no automated method out of the box, and there are now several scripts floating around the Internet that may work or just partially work. A major concern is the ability to update, easily switch to PHP 5.3 when the application is ready and also easily add / remove extensions.

With these considerations in mind, this is the best way to install PHP 5.2 on Ubuntu 10.04 Lucid Lynx:

We will install PHP 5.2 using apt-get and install from Ralp Janke’s repository.

  • Let’s install Phyton software properties, as it makes adding the repo much easier:
    sudo apt-get install python-software-properties
  • Add the repository and install the GPG security verification key:
    add-apt-repository ppa:txwikinger/php5.2
  • Now we need to create a file called /etc/apt/preferences.d/php that locks the PHP version.
       This way they remain at 5.2 and don’t get upgraded to 5.3 whenever you run apt-get to upgrade:
    sudo vim /etc/apt/preferences.d/php then copy / paste the lines at the end of this article, save and quit vim.
  • Finally we do an update and the proper packages are pulled from the repositories:
    sudo apt-get update

If you want to verify what version you’re running, simply place a file into the root of your web server with this line “<?php phpinfo(); ?>”, save it as phpinfo.php and call it in your browser.

Copy and paste these lines into /etc/apt/preferences.d/php:

Package: libapache2-mod-php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: libapache2-mod-php5filter
Pin: version 5.2.10*
Pin-Priority: 991

Package: php-pear
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-cgi
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-cli
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-common
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-curl
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-dbg
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-dev
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-gd
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-gmp
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-ldap
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mhash
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mysql
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-odbc
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-pgsql
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-pspell
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-recode
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-snmp
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-sqlite
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-sybase
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-tidy
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-xmlrpc
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-xsl
Pin: version 5.2.10*
Pin-Priority: 991

]]>
http://articles.itecsoftware.com/web-development/install-php-5-2-on-ubuntu-10-04-lucid-lynx/feed 1
Best New Chrome Extensions For Developers http://articles.itecsoftware.com/web-development/best-new-chrome-extensions-for-developers http://articles.itecsoftware.com/web-development/best-new-chrome-extensions-for-developers#comments Sat, 19 Jun 2010 17:36:11 +0000 Peter http://articles.itecsoftware.com/?p=385 With increasing popularity in Google’s Chrome browser, so increases the demand for extensions. This is especially true for Developers, as we are used to such a nice variety of high quality tools in Firefox. And the more tools are available on one browser, the more that browser is used in developing web sites, resulting in higher quality web experience for end users on that platform. Btw., did you know that Google Chrome surpasses Safari in US browser market (macstories.net)? The following are arguably the best new Chrome extensions for developers.

6. BuiltWith Technology Profiler

BuiltWith ExtensionBuiltWith is a web site profiler tool, that returns all the technologies it can find on a particular page. BuiltWith extension helps developers, researchers and designers find out what technologies web pages are using and in turn help them to decide what technologies to implement. BuiltWith currently tracks widgets (snap preview), analytics (Google, Nielsen), frameworks (.NET, Java), publishing (WordPress, Blogger), advertising (DoubleClick, AdSense), CDNs (Amazon S3, Limelight), standards (XHTML,RSS), hosting software (Apache, IIS, CentOS, Debian).

5. Session Manager

Session Manager ExtensionWith Session Manager you can quickly save your current browser state and reload it whenever necessary. You can manage multiple sessions, rename or remove them from the session library. Each session remembers the state of the browser at its creation time, i.e the opened tabs and windows. Once a session is opened, the browser is restored to its state.

4. CSSViewer

CSS Viewer ExtensionCSS Viewer shows the css parameters of any element in a web page, to enable/disable it simply click the toolbar icon. It’s a simple CSS property viewer for designers and web developers based on the firefox add on.


3.Chrome SEO

Chrome SEO ExtensionThe Google Chrome SEO Extension provides an overview to Search Engine Optimization Tools which can help with Competitive Analysis, Keyword Research, Back-link Checks, PageRank analysis and other valuable SEO tasks.

2. Web Developer

Web Developer ExtensionThe Web Developer extension adds a toolbar button to the browser with various web developer tools. This is the official port of the popular Web Developer extension for Firefox written by the same person.

1. Firebug Lite for Google Chrome

Firebug Lite ExtensionFirebug Lite, as the name implies is the sibling of the famous version we used for so long now in Firefox. It provides the rich visual representation in HTML elements, DOM elements, and Box Model shading. It provides also some cool features like inspecting HTML elements with your mouse, DOM inspection, JavaScript debugging and live editing CSS properties.

]]>
http://articles.itecsoftware.com/web-development/best-new-chrome-extensions-for-developers/feed 0