Nov
13
Programming, Uncategorized
As a programmer, I’ve often needed to generate random data of one kind or another, whether it be names, addresses or just random text. Such a task is usually very boring and tedious, and I’ve thought on several occassions ‘I should really write a tool to automate this’. Well now I have…
Introducing SPF_Random
SPF_Random is the latest class to join Si’s PHP Framework (SPF) and includes methods to generate various forms of random data:
- names (forenames, surnames and full names)
- addresses
- postcodes
- phone numbers
- dates
- job titles
- lorem ipsum text (words or paragraphs)
It’s not perfect (addresses and phone numbers are UK oriented for example) and I’m sure there are better solutions elsewhere on the interweb; but it’s certainly a very quick and simple way to generate personal details for a hundred random people. Plus it’s a completely stand-alone class, you don’t need to download the whole framework to be able to use it.
For the future I’m thinking of adding IP addresses, alphanumeric strings and item lists (especially useful for <select> lists).
Nov
5
MySQL
Storage engines are responsible for storing and retrieving all the data stored “in” MySQL. Each storage engine has its own strengths and weaknesses that determine its suitability in a particular situation.
MyISAM
MyISAM is the default storage engine in MySQL and provides a good comprimise between performance and features.
Pros:
- platform independent
- concurrent inserts
- full-text indexes
- compression
Cons:
- no transations
- table-level locking
- potentially long repair times
Good For:
- applications with many reads and few writes.
InnoDB
InnoDB is a transactional storage engine that uses MVCC and row-level locking, and includes automatic crash recovery.
Pros:
- ACID transactions
- row-level locking and MVCC
- crash recovery
- clustered indexes
- foreign key constraints
Cons:
- alterations to table structure can be slow on large tables
Good For:
- online ordering and other transaction based applications.
Memory
Memory tables store all their data in memory which means they are very fast because there is no waiting for disk I/O. They also use hash indexes which makes them very fast for lookup queries. The table definition of a Memory table will survive a server restart, but all data will be lost.
Cons:
- uses fixed-length rows which can waste memory
- table-level locking
- no support for TEXT or BLOB datatypes
- no transactions
Used for:
- lookup or mapping tables
- caching results of periodically aggregated data
- intermediate results when analysing data
Archive
The archive engine is optimised for high-speed inserting and data compression. It supports only INSERT and SELECT queries and doesn’t support DELETE, REPLACE, or UPDATE queries, or indexes. Rows are buffered and compressed using zlib as they are inserted which means much less disk I/O than MyISAM tables.
Cons:
- no support for indexes, SELECTs will perform a full table scan.
Uses:
- storing large amounts of rarely accessed data in a very small footprint, e.g. logs and audit records
CSV
The CSV storage engine stores data in text files using comma-seperated values. Other applications can open the table data file directly and read the contents. Likewise, if an application exports a CSV and saves it in the server’s data directory, the server can read the file straight away. CSV tables do not support indexes.
Uses:
- data interchange and certain types of logging.
Other Engines
There are several other storage engines available.
- Blackhole - Essentially a no-op storage engine, all INSERTS are discarded although they are recorded in the binary log and can be replayed on slaves.
- Federated - Federated tables refer to tables on a remote MySQL server.
- NDB Cluster - A specialised storage engine designed for high-performance with redundancy and load-balancing capabilities.
- Falcon - A next-generation storage engine designed for todays hardware (64bit CPUs and plenty of memory).
- Maria - A replacement for MyISAM that includes transactions, row-level locking, MVCC, and better crash recovery.
Blackhole, Federated and NDB Cluster are suitable only for specific purposes and should only be used after careful consideration. Falcon and Maria are the two modern storage engines although neither are currently considered production-stable.
Oct
26
Projects
If I spent as much time writing posts for this site as I do redesigning it…
After reviewing the previous design over a period of time, and listening to comments made by some of my friends, it was time for some design tweaks.
Gone are the rounded corners and grey headers. Now there’s sexy gradients and borders. There’s also a splash of colour (orange and green) to offset the heavy use of blue.
The biggest change is to the links pages. These now use the feeds from my new Delicious account, which makes it insanely easy for me to share the cool stuff I find on the interweb. The only problem now will be the amount of cool stuff I find. I think some bi-monthly pruning may be required to remove all the ‘fluff’.
The old links pages and Weekly Round-up posts have been removed and their links moved across to Delicious. The Daily Reading and a new Friends category have been placed in the blog sidebar, which means Leyton should stop pestering me about linking to his site.
This still leaves the problem of me actually writing some posts… So the future plan is to create some summary posts on a variety of topics so that this site will become my own quick reference guide. The first few posts will be MySQL based and cover storage engines, datatypes, query optimisations and other goodies.
Oct
20
Projects
My first solo web design gig is now live!
Ayerst Environmental are an asbestos consultancy based on the outskirts of London. They wanted a revamping of their original (and very dated) site along with the ability to modify the content themselves.
After investigating a couple of different approaches, I decided on using WordPress for the backend of the site. The main reasons for this were my previous experience with WordPress and it’s ease of use. I felt a “full blown” CMS would be overly complicated both in terms of setting up and future maintenance. The KISS principle certainly applies in this case.
The result is a clean and consistent design with content that can be easily updated when needed.
Jul
30
Technology
For those of you that haven’t already heard, there a new player on the search scene. Cuil (pronounced “cool”) is taking on the Big 3 (Google, Yahoo and Microsoft) and claims a larger search index (120 billion web pages) than any of them.
Comparisons with Google are inevitable, especially given the founders are ex-Googlers, and the general reaction so far is that Cuil fails to live up to expectations, primarily with regard to result relevance. Indeed, my first impressions were certainly not that great…
Having recently released a website for my Air Cadet squadron I thought I’d see how easy it is to find using Cuil. The query was “1343 squadron”; the results were, pretty useless, seeming to be a random collection of results for either the number 1343 or the word squadron. There was no apparent linking of the two. Appending “atc” to the query to narrow the search, results in absolutely nothing found, whereas the top four Google results for both queries are directly relevant to the search.
The biggest problem for Cuil at the moment is the risk of people trying it out, only to discover it doesn’t help them find what they’re looking for and simply returning to Google. The tech-savvy crowd will no doubt stick around to see how things progress, but I doubt the majority of web users will be so forgiving of search results that are lacking in relevance.
Further reading:
Jul
23
Technology
The other week I was discussing the issues I have with my knees when running and it was suggested I buy a knee support. So being the web-literate and lazy person that I am, I did a quick Google search in order to find a purveyor of said items. Every site I went to required me to create an account before being able to make a purchase.
Which brings me on nicely to the Number 1 Error Made By Online Retailers…
Why, oh why, oh why, do I need to sign up, create an account or join your community in order to purchase something from you?
All I want is a knee support, a bunch of flowers, a simple birthday gift; I’m not looking for a long term relationship at this point. If you do well this time and manage to deliver what I ordered, on time and for a reasonably price I may very well come back, but I don’t know you well enough yet. I don’t want to worry about how you store my password, address and credit card details, or whether you’re going to send me spam.
The number one thing that will make me leave your website and probably never come back is requiring me to open an account in order to complete a simple and potentially one-off purchase. I don’t have to do it when I shop in the high street, so why do you feel it’s ok on the Web?
A couple of years ago I used to spend a lot of time and money at Overclockers.co.uk. Their prices weren’t the lowest but the website was simple and uncluttered, and more importantly I didn’t need to create an account. Just find what I want to buy, go to the checkout, fill in the absolute minimum details for completing a credit card transaction over the internet and that’s it. Then they redesigned their site and included the apparently obligatory “My Account” functionality. Unfortunately the redesigned site was almost identical to Dabs and eBuyer and had totally lost its simple and original look and feel. Seeing as I already had accounts with eBuyer and Dabs and didn’t want another one, I stopped shopping there.
If you’re a web developer creating online retail sites, think twice before requiring an account before allowing a user to make a purchase, you could be causing your client to lose sales…
Jun
13
Random Verbiage
An entire Calculus 1 course in 20 minutes. I even vaguely understood some of it as well…
Part 1, Part 2
Jun
13
Programming
PHP 5 included a new error reporting directive, E_STRICT, which according to the manual allows PHP to “suggest changes to your code which will ensure the best interoperability and forward compatibility
“.
Basically it catches things that have been deprecated (such as call-time pass-by-reference) or are technically incorrect (such as calling a static method in a non-static way, and vice-versa).
I have this enabled on my development and production servers. Mainly because I want to know when I do something stupid like call a static method incorrectly, but also because I’m a PHP purist and believe the PHP error log shouldn’t contain anything unless explicitly put there by the application.
Recently I’ve noticed that numerous PHP applications and libraries emit all kinds of E_STRICT notices. Offenders noted so far are ADOdb, Smarty, Wordpress, Plogger and Gallery v2.
All of these are fanastic projects but the fact the code within them emits E_STRICT notices means they’re harder for me to implement and use. I usually end up having to globally search replace something, or call error-reporting() to set a lower error reporting level. The latter is made a lot harder when the application has multiple entry points (e.g. WordPress and Plogger).
The reasons behind these E_STRICT notices are usually due to the project remaining backwardly compatible with PHP4. Especially with regard to call-time pass-by-reference, as this was used extensively in PHP4 to speed up code execution when passing objects around. However the incorrect calling of a static method is a different story, it’s just sloppy OOP in my opinion. Simply testing with E_STRICT turned on would highlight these and fixing them would save a lot of headaches for those of us who run servers with E_STRICT turned on.
Alas, for that to happen we’d need projects to forego the backward compatibility with PHP4, and that is extremely unlikely. No large project with any sense is going to tear their community in two because of people like me harping on about E_STRICT.
Our only hope is for new projects to spring up focused solely on PHP5 and “proper” OOP…
Jun
12
Projects
Yesterday saw the release of my latest project, 1343 (East Grinstead) Sqn, a website for my ATC squadron.
Seeing as there are already a ton of sites that provide information on the Air Training Corps generally (not least the main Air Cadet website), I wanted to go for a more local approach and concentrate on what we do as a squadron.
The aim is to post on the activities and events the squadron attends, along with general squadron related news and announcements, and the occassional general interest piece.
The site won’t win any design awards but then that’s not the aim. Content is king, and the simple, clean design will allow that content to shine through.
The finishing touches will be going in over the next week or so. Primarily adding a few pictures to break-up the text, along with a photo gallery for a more visual representation of what the cadets get up to.
Jun
7
Random Verbiage
After three years of stagnation and neglect, and a week of designing, coding and writing, the new website is finally here.
A showcase for me, my projects and my opinions on the hot topics of the day.
Now all I need to do is think of something interesting to say…