Wednesday 30 December 2009

Find Text Inside a Stored Procedure or Used Defined Function

How to find text inside a stored procedure or user defined function

One of the most useful stored procedures I have in my toolkit that I find myself using over and over on any system that I work on is the following procedure that allows me to return a list of stored procedures and user defined functions that contain a particular string of text.

I maybe looking for all procs or UDF's that contain a table or view name or need a list of all procs that do have SET NOCOUNT ON so that I can find those that don't or I may just be looking for a particular variable name or comment within all my procs and functions.

It makes use of the system view syscomments which stores all the text within the stored procedures and user defined functions contained within your SQL Server database. This is just another example of how having knowledge of the system views is a very useful skill to know.

The code is below.

CREATE PROCEDURE [dbo].[usp_sql_find_string_in_proc_or_udf]

@FindStr AS VARCHAR(500)



JOIN sysobjects as obj
ON = and obj.type IN ('P','FN', 'IF', 'TF')
WHERE lower(TEXT) LIKE '%' + ltrim(rtrim(lower(@FindStr))) + '%'

You call it simply like so:

EXEC dbo.usp_sql_find_string_in_proc_or_udf 'SOME_TABLE'

EXEC dbo.usp_sql_find_string_in_proc_or_udf '@ErrorVar varchar(100)'

It's one of those simple procedures that are very handy to have and save a lot of time. Being able to find a piece of text within all your stored procedures and functions quickly could literally save you hours of hunting about on a large system.

Sunday 27 December 2009

Writing a Port Scanner In PHP

How to write a Port Scanner in PHP

I am pretty new to PHP but one of the things I like about PHP as opposed to other server side scripting languages such as ASP Classic (JavaScript or VBScript) is the amount of functionality that is built into the language. 

With ASP Classic if you want to do anything remotely sexy you have to write a COM component and then register the DLL on the web server which most tech support teams hate to do when they know its a custom COM component so it can be quite a pain to do anything on a socket level, Reverse DNS checks, Whois checks and other functions that are easy to do in PHP.

One of the things I liked about PHP was its socket functionality and I stumbled across a couple of Port Scanner tools on the web however they seemed to give incorrect results when running them against sites where I knew the open ports.

Whether this was due to the firewall running on their webserver preventing access to certain ports I do not know. However to validate whether your port scan results are correct you should run the following test on the server you want to scan to list out all the public ports that are currently listening:

C:\DOCUME~1\me>netstat -a

Active Connections

Proto  Local Address          Foreign Address        State
TCP    somecomputer:http  LISTENING
TCP    somecomputer:epmap  LISTENING
TCP    somecomputer:microsoft-ds  LISTENING
TCP    somecomputer:1032  LISTENING
TCP    somecomputer:1110  LISTENING
TCP    somecomputer:pptp  LISTENING
TCP    somecomputer:2869  LISTENING
TCP    somecomputer:3306  LISTENING
TCP    somecomputer:6670  LISTENING
TCP    somecomputer:netbios-ssn  LISTENING
TCP    somecomputer:1161        ESTABLISHED
TCP    somecomputer:1036  LISTENING
TCP    somecomputer:1110       localhost:4809         ESTABLISHED
TCP    somecomputer:1110       localhost:4857         TIME_WAIT
TCP    somecomputer:1110       localhost:4863         TIME_WAIT

This is just a snapshot of the full output you would expect to get. However for those ports on the server you are checking that appear as LISTENING and who don't have a foreign address that ends in port number of zero then a port scanner tool with full access should be able to find them.

The tool you need to use in PHP for this exercise is the fsockopen function which allows you to open a socket to a port. You can then read in any default response which certain ports will give you whereas for others you will not get any response unless you send a valid request first in a similar way to a Telnet conversation.

You can also check whether a port on a server should respond to a port scan by running a Telnet session on the command prompt e.g

C:\DOCUME~1\me>telnet 80

If you do not get a timeout response then you have an open port.

The PHP port scanner script I wrote can be downloaded here: portscanner.php
To get the best out of it and not be blocked by your public webservers firewall run it from your localhost e.g:

Enter in the domain or IP you are wanting to port scan and then hit run.
For example port scanning one of my sites with this tool returns the following results (I am only showing a few of the results).

The Port is shown in the left hand side column and the right hand side will show either Closed and the error message if the port could not be accessed or Open and any response from the Port or "none" if none was returned.
20 - FTP-Data Closed - Timeout
21 - FTP Closed - Timeout
22 - SSH Open - SSH-2.0-OpenSSH_5.1p1 Debian-5
23 - Telnet Closed - Timeout
25 - SMTP Open - 220 ESMTP Postfix (Debian/GNU)
37 - Time Closed - Timeout
53 - DNS Open - none

The main bit of code is here:
// open the port on the required host and set a timeout to 1 second.
$fp = fsockopen($url, $port, $errno, $errstr, 1);

// check whether object is a valid resource
if (is_resource($fp)){

// check for a response back from the port
$response = trim(fread($fp,4096)); 

Let me know of any problems with it and don't go using it for nefarious means.

Remember hacking is illegal and is actually now considered as terrorism in certain countries. So if you don't want to end up in an orange jump suit being water boarded then don't go off port scanning US military installation networks or you will end up like Gary McKinnon!

Reasons why Google Chrome is a great Browser

A list of reasons why Google Chrome is a great Browser

Ever since Google introduced Chrome I have been using it all the time for surfing the net. I had been using FireFox purely for the standards compliance, speed and features but then the more features that were added the slower it got.

I still use FireFox for development and its rich library of plugins and you can speed it up by following the tweaks listed in my Increasing FireFox Performance article. However when I just want to surf the net, watch movies or read articles Chrome is the browser I choose. Here are some reasons why.

  • Reason 1 Chrome is great > It's simple to use and not full of features that are purely there for marketing but you never use. It does the job simply and it does it well.
  • Reason 2 Chrome is great > The Bookmark bar is great for storing quick links to your favourite sites.
  • Reason 3 Chrome is great > It's Fast. It's fast to startup and fast to load pages. It's JavaScript engine is also fast and solid its less forgiving than FireFox that could be considered a good thing or a bad thing depending on how sloppy your code is.
  • Reason 4 Chrome is great > It's Easy to surf in a semi private mode e.g Incognito browsing any cookies are destroyed after browsing and no download or browsing history is kept.
  • Reason 5 Chrome is great > The inbuilt developer tools are pretty good. The Developer console offers a good debugger, JavaScript console, DOM viewer and element inspector.
  • Reason 6 Chrome is great > Its standards compliant.
  • Reason 7 Chrome is great > It now has support for add-ons and plugins so can compete with FireFox for great features. Turn off adverts and flash by default to speed up load time even more. Read my article on Google Chrome plugins for more details.

Thursday 24 December 2009

Performance Tuning your PC and Internet Connection

How to performance tune your Computer and Internet Connection

I recently had major issues with performance on my laptop and an intermittent slowdown which meant that I couldn't watch streamed movies (e.g YouTube) or remotely access my office computer due to the slow internet connection. Certain times of the day it was fine but at night it was generally bad. This article is based on the steps that I used to diagnose and overcome the problem. It can also be used by those of you who just wish to get the best performance out of your computers.

Is the problem related to your Internet speed or overall computer performance?

Are you only experiencing problems when you are on the Internet such as slow loading web pages, stuttering video streaming or videos just not playing. Or are you having problems running desktop applications such as programs that are slow to open or files that are slow to save. Is just navigating your PC a task in itself or are you experiencing popups all the time that you don't recognise asking you "To run performance checks", "Install this Spyware checker" or pages filled with adverts or links to advertisements that you don't know where they have come from?

Computer Related Problems

First thing is to ensure you don't have a virus, Trojan or Spyware on your PC.
  • If you use Internet Explorer to surf the Internet then there is a good chance you might have a virus as this browser is well known for its many security holes. Consider changing your browser to either Chrome or Firefox. Chrome is a very fast browser and Firefox is a favourite of developers due to the huge number of add-ons available for it.
  • If you use a PC Make sure you install any Windows updates as they reguarly contain patches for security vulnerabilities.
  • If you don't have a virus / spyware checker installed then download one of the good free ones e.g Malwarebytes Anti-Malware, Spybot Search and destroy, Ad-Aware or even better download multiple applications as its not uncommon for one app to find items that another one will not. Remember to always update the virus definitions before running it.
  • If your virus software doesn't find a virus it doesn't mean you don't have one it could just mean that its either a new virus that definitions haven't been created for or its already managed to take hold of your PC and block any virus checker from finding it. Try running a program such as Trend Micro's HijackThis which checks for suspicious looking processes and activity on your PC rather than looking for known virus definitions. If you are unsure about a flagged item you should send the outputted report to one of the recommend forums where specialists will analyse the report and give you detailed info on any action required such as running the Trojan removal tool SDFix.exe.
Once spyware and viruses have been ruled out you should run some basic maintenance on your computer which can be done manually or by downloading one of the many optimiser tools that are available on the net. I have investigated many of these tools and by far the best one I have found is TuneUp Utilities which offers all the tools you need to clean and speed up your PC and browser with a very easy to use interface.

TuneUp Utilities 2010

It offers the ability to modify computer and browser settings to speed up your browsing, remove un-used programs, clean up and defrag your hard-drive and registry, speed up your PC by disabling a number of memory and CPU intensive operations that offer little benefit and much more. There is also a "One Click Optimiser" button which checks your system and offers the solutions. If you want to save a lot of time downloading numerous tool or doing it all by hand then this is the tool for you.

Tuning up your PC Manually

  • Defrag your hard-drive. Over time your disk will get fragmented as new files are added and existing ones are edited or deleted. A heavily fragmented drive slows down file retrieval and saving. You can do this through the Accessories > System Tools > Disk Fragmenter option or you can download a tool like Defraggler to do this for you.
  • Remove old programs and shortcuts to those programs if you never use them any-more. You can use the Add-Remove programs option from the Control Panel to do this or download a program like CCleaner which offers a number of options to help clean up your computer.
  • Remove anything from your startup menu that you hardly use or don't require to be running when you start-up your computer.
  • Clean up your Registry. Often when files are installed or deleted keys are left in the registry that are no longer required. Like any database the more useless information it contains the slower the retrieval of useful info becomes. A tool like TuneUp Utilities or CCleaner offers you the ability to do this easily without having to trawl through the registry looking for keys by hand.
  • Disable memory and CPU intensive operations that run in the background when you require optimal performance. For example disk defragmentation or a full virus scan will slow down your PC when running. This is one of the good things about TuneUp Utilities Turbo Mode as it can be set on or off when required and will ensure that any CPU or Memory intensive operations can be disabled when you require optimal performance.
  • Configure the advanced settings in Control Panel > System > Advanced > Performance.
    1. Under the Visual Effects tab you should set the option to "Adjust for best performance".
    2. On the Advanced tab you should ensure Processor Scheduling and Memory Usage is set to Programs
    3. For Virtual Memory make sure both the initial and maximum size are set the same which according to Microsoft its recommended that this should be 1.5 times your system memory.
    4. Under the Data Execution Prevention tab you should set to"turn on DEP for all programs and services except those I select"
  • Clean up your temporary browser files. Make sure your cache and Internet history doesn't get too large so clean all temporary Internet files on a regular basis. The cache is great for helping sites you regularly visit load quickly but the larger it gets the slower page loads get for all sites.
  • Remove any add-ons that you never use anymore. In Firefox the more add-ons you have the slower the browser can be when loading and they can even cause errors. You will often have duplicate add-ons e.g different versions of Java which can be removed.
  • Install Advert and Flash blocker add-ons if your browser supports it (Firefox, Chrome). Without having to load Flash files and other adverts the page load times can be increased dramatically.
  • Disable JavaScript by default. Not only do most web delivered viruses use JavaScript to infect new PC's it can slow down page load times and make pages seem unresponsive during certain events e.g window, DOM load. All browsers will let you disable JavaScript and in IE VBScript from their inbuilt Options. However to make it easier to set which sites have it on and off you can install add-ons such as NoScript or the Web Developer toolbar. A lot of sites use JavaScript to display adverts, load flash or other videos, validate form fields and deliver other forms of content. Therefore you may find that by having JavaScript disabled you have reduced functionality on many sites. However pages should load a lot quicker and if you do trust the site or require the missing functionality you can always re-enable it.
  • Disable 3rd party cookies. These are cookies that are not set by the site you are visiting and are usually used by advertisers for tracking the sites you visit so that they can deliver more targeted advertisiments. Even Google uses these kinds of cookies now and many people consider them an invasion of their privacy which is why most Spyware tools identify them as items to be removed. This is how to disable 3rd party cookies in the top 3 browsers.
    1. Chrome you can do this by going to Tools > Options > Under The Hood > Privacy > Cookie Settings > Accept cookies only from sites I visit.
    2. Internet Explorer go to Tools > Internet Options > Privacy and then set your Privacy level to Medium high which will disable most 3rd party cookies and some 1st party ones. This will still allow you to login to sites but should prevent all the tracker and advert cookies that accumulate as you surf the net.
    3. Firefox removed the option to block 3rd party cookies in version 2 saying it was impossible to accomplish however you can still do this by either installing an add-on called CookieSafe or changing your user preferences by entering about:config in the address bar and then searching for network.cookie.cookieBehavior. The possible values are 0 which accepts all cookies, 1 only accept cookies from the same server and 2 disable all cookies. Set it to 1 to block 3rd party cookies.
  • Enable Popup blockers and disable any un-used toolbars e.g Google, Yahoo etc.
  • In FireFox disable Firebug and any other DOM manipulating add-ons and only enable them when required. Firebug has steadily got worse over the years in slowing down sites due to all the extra functionality that has been added to it. Therefore it should only be used when developing sites or when you need to use one of its features. The same goes for any other add-ons that you only use on certain sites or at certain times. Having less add-ons to load will increase page load times.
  • In Firefox tweak your config settings to improve performance. Read this article on which settings to tweak to get the best performance possible.
Testing for Network Problems

If you are having issues with slow loading pages when browsing or video streaming then you need to find out whether the problem is local to your home or a general network problem that you need to contact your ISP about.

Before doing anything else you should get some basic details of your network if you don't know them already such as the IP address of your gateway to the internet. Open a command prompt window and type "ipconfig". You should note down the results e.g

C:\Documents and Settings\me>ipconfig

Windows IP Configuration

Ethernet adapter Local Area Connection:

Media State . . . . . . . . . . . : Media disconnected

Ethernet adapter Wireless Network Connection:

Connection-specific DNS Suffix  . :
IP Address. . . . . . . . . . . . :
Subnet Mask . . . . . . . . . . . :
Default Gateway . . . . . . . . . : 

Note down the IP address and the Default Gateway address. The IP Address is your computer and the default Gateway is your connection to the outside world. In this case its a wireless router which is then connected to the Virgin Cable box.

We can now test whether the network problem is with my PC to the wireless or the main router or somewhere else by doing some PING tests.

A "Ping" measures the time that passes between the initial send of the Ping, and the receival of the "Reply" by the machine you pinged. The amount of time that passes during a ping is slightly influenced by the amount of hardware the ping is passed trough, as each would have to relay the ping further. However, there is no set formula for this, as the ping speed also depends upon the speed of the network, how busy it is, and so on.

  • A ping to your default gateway should be very quick e.g 1-2 ms
  • A ping to other computers on your LAN should be between 1-10 MS (good)
  • Pings to external websites such as take anything from 20 - 150 MS anything under 50ms is good to an external site.
  • Pings to sites on the other side of the world that go through many hops e.g from the UK to should report times of <500ms if the network is good.
So lets do some ping's, first to my gateway then to and then to somewhere very far away e.g

C:\Documents and Settings\me>ping

PPinging with 32 bytes of data:

Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128

Ping statistics for
 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
 Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\Documents and Settings\me>ping

Pinging [] with 32 bytes of data:

Reply from bytes=32 time=32ms TTL=52
Reply from bytes=32 time=28ms TTL=52
Reply from bytes=32 time=32ms TTL=52
Reply from bytes=32 time=30ms TTL=52

Ping statistics for
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 28ms, Maximum = 32ms, Average = 30ms

C:\Documents and Settings\me>ping

Pinging [] with 32 bytes of data:

Reply from bytes=32 time=606ms TTL=48
Reply from bytes=32 time=526ms TTL=48
Reply from bytes=32 time=446ms TTL=48
Reply from bytes=32 time=445ms TTL=48

Ping statistics for
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 445ms, Maximum = 606ms, Average = 505ms

If you are suffering packet loss or long delays then should investigate further.

Another good test from the command prompt is either the tracert / traceroute command or pathping which will do a series of pings from your PC to the destination showing you the addresses of each router it has to pass through and any delay it suffers on the way.

For example lets try a pathping to

C:\Documents and Settings\me>pathping

Tracing route to []
over a maximum of 30 hops:
0 []
3 []
4 []
5 []
6 []
7 []
8 []
9 []
14 []

Computing statistics for 350 seconds...
Source to Here   This Node/Link
Hop  RTT    Lost/Sent = Pct  Lost/Sent = Pct  Address
              0/ 100 =  0%   |
1    0ms     1/ 100 =  1%     1/ 100 =  1%
              0/ 100 =  0%   |
2  ---     100/ 100 =100%   100/ 100 =100%
              0/ 100 =  0%   |
3   14ms     4/ 100 =  4%     4/ 100 =  4% []
              0/ 100 =  0%   |
4   16ms     2/ 100 =  2%     2/ 100 =  2% []
              0/ 100 =  0%   |
5   14ms     2/ 100 =  2%     2/ 100 =  2% []
              0/ 100 =  0%   |
6   27ms     1/ 100 =  1%     1/ 100 =  1%
.net []
              0/ 100 =  0%   |
7   24ms     1/ 100 =  1%     1/ 100 =  1%
.net []
              0/ 100 =  0%   |
8   31ms     1/ 100 =  1%     1/ 100 =  1% []
              0/ 100 =  0%   |
9   33ms     0/ 100 =  0%     0/ 100 =  0%  158-14-250-212.static.virginmedia.
com []
              0/ 100 =  0%   |
10   25ms     1/ 100 =  1%     1/ 100 =  1%
              0/ 100 =  0%   |
11   37ms     1/ 100 =  1%     1/ 100 =  1%
              0/ 100 =  0%   |
12   39ms     1/ 100 =  1%     1/ 100 =  1%
              0/ 100 =  0%   |
13   41ms     0/ 100 =  0%     0/ 100 =  0%
              0/ 100 =  0%   |
14   35ms     0/ 100 =  0%     0/ 100 =  0% [

Trace complete.

If you are suffering severe packet loss between routers then that could signify a problem or it may just be that the router is not set up to respond to pings and therefore any ping to that IP would report a time out.

Another test is to compare whether the speeds promised by your broadband provider are actually being delivered to you. There are many speed test sites out there but I tend to use OR which will measure your download and upload speeds.

You should always do multiple tests and then take an average reading. When I was debugging the issue with my laptop and the wireless connection it had to my main PC and router I was alternating tests between both machines and recording the times to note any difference.

Broadband providers never seem to deliver exactly what they promise but if you are currently getting anything over 2Mbps you shouldn't be getting video streaming issues unless its High Definition movies. Upload speeds will always be a lot less than download speeds so don't expect equality on those two measurments however if like me you were getting periods of the day where your download speed was measured less than 100Kbps then there is definitely something wrong somewhere.

One thing you should remember when dealing with speeds on the net is that the measurements are different than those for disk space. 1Mb is one megabit and 1MB is one megabyte. You can always tell by the letter b as if its capitilised then its bytes and if its lower case its bits. Another thing to note is that a rate of one kilobyte per second (KBps) equals 1000 (not 1024) bytes per second.

If your network problems are intermittent then you should download a tool like networx which allows you to monitor your bandwidth usage, show hourly, daily, monthly reports, set limits on usage and run diagnosis tools such as tracert and ping but in a visual manner.

Run the bandwidth monitoring tool throughout the day and run hourly speed tests this should tell you whether your network problems happen at certain times of the day and provide you with evidence that you can then download as an XLS to provide to your ISP when you contact them to complain.

Wireless Network Issues

If like me you use a laptop that is connected to the main router by a wireless connection then you should rule out problems with the wireless set-up. Run some pings from your PC to the wireless router to check for any issues but ensure that your router is set-up to accept ping requests first.

  • Make sure you have the latest firmware, software and drivers in your router, modem and network adaptor. Communications and hardware companies are always updating the software inside their devices so you should make sure you have the most up to date drivers and other software for your equipment. You should be able to download this from the manufacturers website.
  • Tune your wireless access point. If you get substantially higher speeds when you connect directly to your broadband instead of using wireless networking, this can be due to interference from other Wi-Fi installations nearby, especially if you are in a city. Find out if there is a problem by plugging the network output from your broadband moden directly into the Ethernet port on your laptop or desktop and seeing if speeds improve. If so, try changing the channel of your wireless network: there'll be a setting in its configuration screen, which you can get to via your browser. Check your handbook for details of your router. You should also try moving your laptop around the house to see if you get a better or worse signal depending on where you are.
  • Make sure you are not getting electrical or radio interference from other devices in your house. Lots of gadgets including radios, media streamers, mobile phones and tools to send TV signals around the house use Wi-Fi and they're all sharing the same airwaves. Try turning off all electrical equipment to see if that improves the signal and then one by one turn them on again until you find the culprit. Even mains wiring that runs alongside telephone or network cables can cause a problem.
  • Whilst on the wireless network place your laptop right next to the main router and run some speed tests. If you are having issues with speed whilst directly next to the router then it maybe a problem with the wireless router itself or the wireless internet card your PC or laptop is using.
TCP / IP Tuning

Computers are shipped with default TCP / IP settings that are designed to work with all network speeds, dial ups, DSL and Cable. This means that you can tweak various settings so that they are optimal for your computer.

There are various tools that can help you do this easily such as TuneUp Utilities or there are those such as DrTCP or TCP Optimizer that allow you to view and edit various settings such as your MTU Maximum Transmission Unit or maximum packet size and RWIN (TCP Recieve Window). Out of both these tools TCP Optimizer offers the more configuration options, a registry editor and some tests to calculate your MTU correctly.

For those of you interested in what these values mean then the MTU is the maximum Ethernet packet size your PC will send. If a packet that is too large is sent then it will get split up into chunks (fragmented) and then re-assembled at the destination which obviously is not optimal. Therefore you want the MTU value to be the largest packet size that can be sent without becoming fragmented.

Unless otherwise set, Windows defaults MTU to 1500, or a lower value of 576 for external networks. 1500 is OK unless you are running PPPoE, want to use IPSec (Secure VPNs) or both, then it's too big. 576 is not efficient for the broadband/Internet as it's too small. For Windows VISTA users it's recommended to leave this value alone as apparently it does a pretty good job of automatically calculating these settings anyway.

You can calculate this yourself with the command prompt by doing the following tests.

Windows 2000/XP users:

ping -f -l 1472
(That is a dash lower case "L," not a dash "1." Also note the spaces in between the sections.)

Linux users:

ping -s 1472

OS X users:

ping -D -s 1472

Linux and OS X commands are case sensitive.

Press Enter. Then reduce 1472 by 10 until you no longer get the "packet needs to be fragmented" error message. Then increase by 1 until you are 1 less away from getting the "packet need to be fragmented" message again.

Add 28 more to this (since you specified ping packet size, not including IP/ICMP header of 28 bytes), and this is your MaxMTU.

If you can ping through with the number at 1472, you are done! Stop right there. Add 28 and your MaxMTU is 1500.

For PPPoE, your MaxMTU should be no more than 1492 to allow space for the 8 byte PPPoE "wrapper," but again, experiment to find the optimal value. For PPPoE, the stakes are high as if you get your MTU wrong, you may not just be sub-optimal, things like uploading files or web pages may stall or not work at all.

This example shows you how to do it by hand. If you you downloaded the TCP Optimizer tool go to the largest MTU tab and run the test. You will see that it does a similar test to the one below but obviously its automated to save you time.

C:\Documents and Settings\me>ping -f -l 1472

Pinging [] with 1472 bytes of data:

Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.

Ping statistics for
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Documents and Settings\me>ping -f -l 1462

Pinging [] with 1462 bytes of data:

Reply from bytes=64 (sent 1462) time=33ms TTL=52
Reply from bytes=64 (sent 1462) time=31ms TTL=52
Reply from bytes=64 (sent 1462) time=33ms TTL=52
Reply from bytes=64 (sent 1462) time=42ms TTL=52

Ping statistics for
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 31ms, Maximum = 42ms, Average = 34ms

C:\Documents and Settings\me>ping -f -l 1463

Pinging [] with 1463 bytes of data:

Reply from bytes=64 (sent 1463) time=32ms TTL=52
Reply from bytes=64 (sent 1463) time=29ms TTL=52
Reply from bytes=64 (sent 1463) time=30ms TTL=52
Reply from bytes=64 (sent 1463) time=32ms TTL=52

Ping statistics for
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 29ms, Maximum = 32ms, Average = 30ms

C:\Documents and Settings\me>ping -f -l 1465

Pinging [] with 1465 bytes of data:

Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.

Ping statistics for
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

There you go the MTU is 1464 + 28 = 1492

The other settings available in the TCP Optimizer tool are:

This parameter controls the use of RFC 1323 Timestamp and Window Scale TCP options. Explicit settings for timestamps and window scaling are manipulated with flag bits. Bit 0 controls window scaling, and bit 1 controls timestamps.

Description: The TcpWindowSize parameter can be used to set the receive window on a per-interface basis. This parameter can be used to set a global limit for the TCP window size on a system-wide basis.

TCP Window size
This parameter determines the maximum TCP receive window size offered. The receive window specifies the number of bytes that a sender can transmit without receiving an acknowledgment. In general, larger receive windows improve performance over high-delay, high-bandwidth networks. For greatest efficiency, the receive window should be an even multiple of the TCP Maximum Segment Size (MSS). This parameter is both a per-interface parameter and a global parameter, depending upon where the registry key is located. If there is a value for a specific interface, that value overrides the system-wide value. See also GobalMaxTcpWindowSize.

Contact your ISP

If you have cleaned and tuned your computer and browser and optimised all your settings to rule everything else out and you're still having problems related to network speed then contact your ISP. Provide them with as much information that you have gathered as possible to show that the problem is not related to your computer set-up. If you have intermittent speed issues show them the charts from networx that you can print out (by hour, by day) to show the problem. Do not give your ISP a chance to blame the issue on your own PC or setup a with most companies they will try and get out of paying for something if they possibly can. You never know they may offer you a new modem and raise you from 2Mbps to 20Mbps like they did to me. Funnily enough as soon as the new modem was plugged in all my network issues were solved instantly!

Hopefully this article has been a good guide to performance tweaks and remember if you want to do it the easy way purchase TuneUp Utilities as it could save your a lot of time, effort and heartache. I don't often recommend software to buy but for only £29.99 you cannot really go wrong when compared with the amount of time you will save.

TuneUp Utilities 2010

Performance Tuning Firefox

Firefox Tweaks for increased Speed and Performance

This article has been written specifically about improving the performance of the FireFox browser. If you are having problems regarding performance in general then I would suggest looking into other areas first before tweaking your browser settings.

I have written a specific article about performance tuning your PC, Network and Browser here:

The following guide should only be attempted by those people who are comfortable with changing core application settings. For those people who want to increase browser performance without fiddling about with the configuration I would recommend the following:

-Use the free to download application FireTune which will modify some of the same settings that I am going to list automatically.

-Use the TuneUp Utilities Application which will modify some FireFox settings as well as numerous other settings related to Browser performance, TCP/IP settings, Disk space, registry, un-used programs, CPU and Memory management and numerous other performance tweaks.

Otherwise go to about:config in the address bar of FireFox and enter the "here be dragons" section.

Most of these options will already exist but if they don't you can add them to the config by right clicking, selecting New (boolean, string, integer) adding the the correct name and then the correct value. Obviously if the value is a number you choose integer and if its true or false boolean otherwise its a string.

Before doing any changes you should make a backup either manually by writing down current settings or using FireTune to do a backup or just copy the current settings from C:\Program Files\Mozilla Firefox\defaults\pref. Obviously if you saved your version of Firefox somewhere other than Program Files then you should look there.

Do a page load speed test before and after any changes from to see if the changes have made any difference always making sure that the browser cache is cleared before each test to make the comparisons fair.

To find out what each tweak does just append the full name to this URL


network.http.max-connections = 30
network.http.max-connections-per-server = 15
network.http.max-persistent-connections-per-proxy = 24
network.http.max-persistent-connections-per-server = 8
network.http.pipelining true
network.http.proxy.pipelining true
network.http.pipelining.firstrequest false
network.http.pipelining.maxrequests 8
network.http.request.max-start-delay 0
network.prefetch-next false
network.ftp.idleConnectionTimeout 300
network.http.keep-alive.timeout 30
browser.history_expire_days_min 10
browser.cache.memory.enable true

The following option depends on your RAM
  • For RAM over 2GB I use 65536
  • For RAM sizes between 512MB and 1GB, start with 15000.
  • For RAM sizes between 128MB and 512M, try 5000

The following article will list out the default values for this option.

browser.cache.memory.capacity = 65536 (see above for details)

content.interrupt.parsing[boolean] true
network.dnsCacheEntries [integer] 255
network.dnsCacheExpiration [integer] 86400
config.trim_on_minimize[boolean] true
nglayout.initialpaint.delay[integer] 100

This setting will disable 3rd party cookies from being saved. The possible values are 0 which accepts all cookies, 1 only accept cookies from the same server and 2 disable all cookies. Set it to 1 to block 3rd party cookies.

network.cookie.cookieBehavior 1

Optional - May increase performance but will also reduce usability so choose carefully

Limits the maximum number of pages stored in memory in such a way that they don’t have to be re-parsed when pressing Back and Forward. If you, like me, are not using the Back and Forward buttons that much but rather tabs then I see no reason for Firefox to keep a lot of memory with this.

browser.sessionhistory.max_total_viewers change to 1 (default: -1)

Disable Extension Compatibility Checks so that each time you load Firefox it doesn't check for new versions of your extensions. You must remember to do this manually from time to time if they stop working though!

extensions.checkCompatibility = False
extensions.checkUpdateSecurity = False

Stop Displaying Website Icon (Favicon) in Address bar & On Tab = False

Cool tweaks - Non Performance related

layout.spellcheckDefault 2 - extend spellcheck to form elements inputs as well as textareas
browser.blink_allowed = false - 'disable blinking text from <blink> true - opens any search results from the search bar in a new tab instead of overwriting existing one

Open View Source in your favourite editor e.g Editplus

view_source.editor.path= Path of Editor e.g C:\Program Files\EditPlus 2\editplus.exe

You also often have a lot of tabs open? This setting will decrease the minimum width of the tab so that more fits in before you need to scroll to see more tabs.

browser.tabs.tabMinWidth change to 70

To Enable Single Click Select URL of address bar use the below about:config Tweak

browser.urlbar.clickSelectsAll = True

To disable Single Click Select

browser.urlbar.clickSelectsAll = False

Auto Complete URL while You type at address Bar

browser.urlbar.autoFill true

This is a good hack to trim down that huge auto-complete list on your URL bar. By default it displays maximum 12 URL

browser.urlbar.maxRichResults (pick a number from 1 to 12)

Monday 21 December 2009

Add-On Support for Chrome

Google Chrome Plugins

Google Chrome has been my favourite browser for plain old web surfing since it came out but one of the few downsides to this fast loading and stable browser is the lack of support for add-ons. This is one of the reasons FireFox has claimed such a major stake in the browser market because there are literally hundreds if not thousands of add-ons available to extend the browsers functionality.

Now Chrome has finally caught up and if you are subscribing to Googles dev channel you will be pleased to know that there are already a hundred or so add-ons waiting to be installed on your favorite browser. I have already installed Flashblock and Adblock and they seem to be working well. There does exist a web developer toolbar but its functionality is so cut down and basic at the moment its probably not worth getting.

Now if you are like me and have been working around the lack of plugins for Chrome by using bookmarklets then you will be pleased with this news. However if you are still interested in using bookmarklets which will work cross browser then here is another good one. It allows you to download Flash videos from YouTube at a click of a button so that you can watch them later on.

All you need to do is right click on the bookmarks bar (which should always be made visible) and then click "Add". Then in the Name you should put "YouTube Flash Downloader" or something similar and then for the URL you should paste in the following code:

javascript:window.location.href = '' + yt.getConfig("SWF_ARGS")['video_id'] + "&sk=" + yt.getConfig("SWF_ARGS")['sk'] + '&t=' + yt.getConfig("SWF_ARGS")['t'];

This code has been updated to work with the recent changes in YouTubes API so don't worry as I know there is an old version of this bookmarklet floating around the web that doesn't work since November this year.

Now when you are on YouTube and a video starts playing you can just click on that bookmark link and the video should start downloading to your computer.

If you don't have a Flash player installed on your computer and want to play the FLV files in Windows Media Player then you can download an extension from the following location:

If you are interested in other cool bookmarklets then check out my previous article which contained one for viewing the generated source code of a page and one for dynamic DOM inspection.

Remember the cool thing about bookmarklets as apposed to add-ons is that they should work in all modern browsers as they are pure JavaScript. That even means IE 6!!

Also before everyone gets carried away installing lots of add-ons for Chrome just take a step back and remember why you're using Chrome in the first place. For me its because FireFox, which I use for all my web development, has so many add-ons installed that its become very slow to load and many of the add-ons can cause slow page loads e.g Firebug or errors. Therefore if you're like me and use many browsers keep the add-ons to a minimum and keep your web browsing fast.

I will shortly be writing an article about increasing speed and performance for all the major browsers but as a teaser I would give these pointers to quicker browsing.

  • Remove all add-ons that you never use anymore and disable those you rarely use.
  • Add-ons that will make your web surfing quicker such as FlashBlock, AdBlockPlus and NoScript are all good. Only enable those Flash movies and adverts if you really need to.
  • Turn off inbuilt RSS readers and use a special app if you require it.
  • Turn off all 3rd party cookies but keep Session cookies enabled.
  • Trawl through those preference settings and disable anything you do not use.
  • Disable link pre-fetching.
  • Regularly clear your cache, history and auto-complete data.
Those are some very simple tips for increasing speed. I will go into more detail about the user preferences, http.pipelining, max-connections and TCP/IP settings another day.

Sunday 13 December 2009

New Jobboards Added to Strictly Jobs

Get your next IT job using Strictly Jobs

Just to let you know that my job aggregator Strictly Jobs has had another 10 jobboards added to it. Including jobs from my newest jobboard which specialises in cloud computing so if you are looking for jobs seeding clouds and creating rain cloud applications or storm cloud networks then this is the site for you :)

Currently has 2700+ IT related vacancies so have a look and see if anything takes your fancy. All job results link back to the original site where you can make an application or sign up to allow clients to search your CV.

Later on I will be adding more features to the search engine to make it more of a jobboard and allow clients to post jobs directly however until then you can save yourself time going from board to board and use my job portal.

Saturday 12 December 2009

Setting up a new site for SEO

Creating a new system for Search Engine Optimisation

When you are creating a new website the amount of time from conception to roll out can be anything up to a few months. I am talking here about custom built systems not Wordpress or blogger type sites that can be knocked up instantly.

You have the design work to be done, the back end to be developed, debugging and testing and any number of changes to accommodate for. This is usually an iterative process and once its complete and the site is live the owner will then concentrate on SEO by looking into viable search terms to target and trying to get back-links to the system as well as creating an online presence for the site.

The problem with this approach is that the SEO marketing is left until last and as we know with the major search engines they can be quite slow to react to changes within a site and Google will only update the Page Ranking for your site every few months. Therefore a good idea would be to move the SEO right to the front of your process so that you gain the benefits that time brings an online presence before the actual roll out of your site.

How would you go about this? How can you build up an online presence when there is nothing to present to the online world? Well here are some ideas that you can take onboard.

1. Get your domain purchased and ready as soon as possible.

2. Don't worry about features and functionality at this point as you will be doing this over the next few months as you site is being created. However once you have access to your webserver and your domain is ready put up a holding page.
This should be a pure HTML page that loads fast and contains lots of text describing your site and what features its going to be providing. Make sure the content explains that this system is coming soon and not ready yet. The content should not be a list of spammy keywords but it should contain various configurations of the search terms you want to target.

3. Make sure your holding page is laid out correctly with H1, H2 tags, paragraphs containing your targeted keywords wrapped in strong or em tags and links to other static pages. Do not use too much highlighted text but concentrate it on your key search terms.

4. If possible create static versions of the main pages that you are expecting to use on your finished system and link to them from your home page. For example if you are a catalogue site put up a static results page with a number of product items on it. Target your main sales items, the ones that you are hoping to sell the most of once the main site is ready. If you are going to gain SEO points for site age then you want those points to be related to items that will benefit you in future.

5. Make sure its clear that your site isn't ready yet and if possible have an email link or form where potential customers can put their names down on a mailing list to be informed when the site goes live. Or if you are a shop and have the ability to take orders offline ask them to contact you by email or phone if they see something they like. This way you can drum up interest before your site is ready.

6. Once you have a temporary website up you can concentrate on getting your real system ready without losing out on all the benefits of SEO that just having a site online gain. For example search engines such as Google will not even consider putting brand new sites at the top of rankings for certain search terms until a set period of time has passed. Known as a Sandbox this is to prevent spam sites from being created with huge numbers of backlinks taking all the top spots.
You may still be able to find your site in the index by searching for your domain or company name but other search terms which you are trying to target may not give you the desired result. Therefore having a temporary site up and running until your main site is ready is one way to get over this time delay as you really don't want your new site to suffer the sandbox on release date.

7. Search engines also see the length of time a site has been around as an important factor in calculating a sites authority. Remember site authority is important as when you get backlinks from sites with a higher authority than yours it helps boost your sites authority and also increases your Page Rank therefore you should aim to get backlinks in from sites with high authority but not link back as this may cancel out the benefit.

8. Remember Page Rank (PR) only gives an indication of the number of sites that link to yours. It doesn't say anything about the quality of your site in terms of content or the quality of the links that are pointing to you.
In the old days Page Rank was important as it was used as a way of allowing Internet users to rank the sites on the web as they would only be linking to good sites or so the idea went. However as with most ideas it was soon worked out that link farms and link exchanges could boost a sites PR which is why so many people still think that getting thousands of inbound links from anywhere is still a good thing.
I have no idea whether Google still considers PR on itself a useful tool but I have heard from many people that they don't. Because any site could get thousands of inbound links into them from link exchanges I am pretty certain that Google do not consider it that important in ranking otherwise all the top spots for most search terms would be taken up by spammy sites that offer nothing but ebooks or get rich schemes or other MLM BS.

9. Back links are important as Google still looks for sites that have good site authority that link to your site. If you are a new site selling custom widgets then you should aim to get backlinks from other widget selling sites or sites that relate to widgets in some way.
Having lots of backlinks from sites that have nothing to do with widgets won't help. Your PR may go up to a certain level but it doesn't tell Google that you are considered a relevant site in your field. Your site authority will go up when you have lots of sites in the same field as yours linking to you.

10. Backlinks are also important as they help get your pages indexed quickly by search engines. If you create a new page but have no inbound links to it then it may not get indexed even if the page is linked to internally or listed in your sitemap. I have found the quickest way to get a page indexed is by having some good quality backlinks to it from external sites.

11. If you are going to pay for advertising on other sites then you need to decide what you hope to get out of the advert as most advertising system that run over multiple sites use JavaScript iframes to load the advert content. Therefore if you are hoping to get backlinks to your site you are going to be disappointed unless the adverts are loaded server side so that search engine spiders can crawl them. If you are just trying to get brand awareness or drive traffic through clicks then Javascript loaded adverts are fine.

12. When you do use images wrapped in anchor tags on your site or adverts on other sites that take this format you should make use of all the available attributes. With an image wrapped in an anchor you have 3 possible areas to add search engine friendly content. These are the title attribute on the anchor tag and the title and ALT attributes on the image tag. Make sure you put good search terms in all 3 places and try to vary the terms so that you are making the most of these opportunities. Do not just put the name of your site in the attributes e.g

title = "Strictly Software"

but add search terms e.g

title = "Technical advice and free scripts from Strictly Software"

and then alternate it on the other two

title = "Strictly Software technical blog and downloads for developers"

ALT = "Technical development from Strictly Software, free downloads and great code"

13. The ALT tag is used for when the image cannot be loaded such as text browsers. However because text browsers or image free browsers are very rare you can probably add more text than the recommended short description of the image that an ALT tag is for.

14. Use commas in your search terms and try to get multiple sentence variations out of one piece of text without resorting to a list of keywords. Search bots are quite clever and can spot spam a mile away nowadays so you should make your search terms readable but also combine 2 or more search terms. For example.

title = "free online tools from Strictly Software the best technical blog for downloads and technical advice for free"

Now as a human reading this you might think its a bit unreadable as its quite long however for bots who crawl your site they will see this and not be able to tell that its slightly wordy only that it's not a list of spam keywords. However once your page has been indexed you now can search on the following variations to find the page.

Free online tools
Free online tools from Strictly Software
tools from Strictly Software
Strictly Software the best technical blog
Strictly Software the best technical blog for downloads
technical blog
technical blog for downloads
downloads and technical advice
downloads and technical advice for free
technical advice for free

Obviously this is just a quick example but you see what I mean. Make the most of your title and ALT attributes.

15. Good content is the most important thing on a site. If you are writing a blog then short one paragraph articles are no good as:
  1. They don't look like authoritative examples of the topic you are writing about
  2. They don't offer you the option to highlight the various search terms and combinations that you are targeting without it looking like spam.
  3. They don't offer the reader much and therefore you are less likely to get natural inbound links.

16. META tags are not as important as SEO applications downloaded from the web would like you to think. Most search engines ignore the keywords META tag nowadays and the description tag is hardly used anymore on search engine results pages unless no other search term specific content can be found in the article. Page titles are useful for usability and offer another area to enter search terms specific to the page but none of these are as important as good quality content.

17. Make sure your page content is split out appropriately with H1 tags to denote the topic and then H2 tags for sub headers and so on. Search engines see content within headers, anchor text and strong and em tags as more important than the other content as you have specially marked it out for the users attention therefore the search engine will also pay more attention to it. Do not wrap all your content in headers or strong tags as this will be seen as spam so keep it to under 10% of the overall content.

18. Put all your important links towards the top of the page and try to keep the number of links on a page to under a 100. I have seen pages that contain 250+ links and the most important links e.g to the site index were at the bottom in the footer and did not get indexed.

19. If you have lots of CSS or SCRIPT content try to put these in external files and reference them as far down the page as is possible so that your main content is the first thing a spider comes across. Try to put all your CSS references above any SCRIPT references as the browser will stop rendering the page to load in external script which may cause a nasty effect. This is one thing I hate about Googles AdSense adverts as you have to insert the SCRIPT at the place in the HTML where you want the advert to display and depending on how slow Google is to load the content it can cause a horrible delay. I have tried myself hacking about with this but as of yet don't have a way round it so if anyone does please let me know!

20. Make sure all images have width and height attributes on them. This is so that the browser does not have to wait for the image to load so it can look up the actual size of the image before being able to display it. With a specified height and width it can render the whole page and put aside the correct space for the image before it has loaded. As page load speed is one of the things that Google is now concentrating on when determining ranking then it makes sense to make your pages load as fast as possible.

So there are some tips to utilize on your temporary site as well as the completed site. If you can make the most of the time that it takes to get your site finished by having a search engine optimised temporary site up and running and gaining SEO points just by being accessible then you won't have to try so hard once your real site is ready.

There are lots more things you can try and you should download the various versions of all the Search Engine Optimiser tools that are available on the web. Most of these tools do basic content analysis by determining how much of the content is specific to various search terms as well as looking for missing or non specific META and other tags. However good SEO is something that is learnt over time and once you know the key aspects to look for its just a case of trial and error. Check out your competitor sites and see how they have optimised their pages, who is linking to them and what search terms they rank high on then try to target variations of terms that users search on but are not already saturated by existing sites. As with most things in life its mostly trial and error.

Tuesday 1 December 2009

Web Developer Browser Survery

Browser Survey for Web Developers

I have created a small survey aimed at web developers to gauge their opinions on the various browsers they use for developing and surfing the net. There are many great browsers out on the market and the browser that is best for development may not necessarily the one that is used for web surfing. For example I tend to do all my development in Firefox due to all the useful add-ons that are available for it such as Firebug, Web Developer toolbar and the Hackbar. However because of the number of add-ons its very slow to start and can be slow on loading certain pages. Therefore for pure web surfing I tend to use Chrome because its simple and quick.

Please spend a few minutes to take part in this survey and let me know what you think.

Take part in survey now