General/Techie

Interactive 3D Light Field Display

by Craig Mayhew on Jul.19, 2010, under General/Techie

Simon Holywell sent me a link to this clevor way of displaying 3d images. Now if only we could shrink this to a portable size…

Leave a Comment : more...

Windows “cat” equivelant

by Craig Mayhew on Apr.18, 2010, under General/Techie

If you need to concatenate several files on a windows system the command is as follows:

“copy /B filePart1 + filePart2 + filePart3 outFileName”

The /B indicates the files are binary files.

Leave a Comment : more...

phpuk2010

by Craig Mayhew on Feb.27, 2010, under Code, General/Techie

Back from phpuk2010 and feeling like I really want to contribute to some open source projects! I’ll summarize the main points I took away from each of the talks I attended.

Josh Holmes – Keynote talk – The Lost Art of Simplicity:

Josh talked about how overcomplicating things seems to happen all to often and grave a great example of a man simply trying to pluck an apple from a tree. He introduced me to “the truck factor” which I knew by a different name but this one has a much better ing to it :)

Stefan Priebsch – AntiPHPatterns:

I took alot away from this talk. Stefan had some great usage cases where singletons are bad and I have come across similar problems in my own code. I still think are cases where it makes sense and they are great for chucking an example together, but for production code and unit testing they are a bit of a nightmare.

He also pointed out that using global within a class is a real pain for unit testing too and ideally you should use the class __construct() function to get any required arrays/objects from outside the class (dependencies).

cakePHP took a bit of bashing during the talk due to it’s insanely high number of globals. CakePHP wasn’t alone either it seems a great many open source PHP projects are taking steps to fix there high use of globals and singletons.

Remo Biagioni – Database Optimization:

This was a story about how a small side projected grew into a multi server nightmare in just a few short years. He gave some good examples of how not to manage your databases and some equelly good examples of how to speed up different aspects of the database server. In short:

  1. Reduce the number of queries as much as possible by merging them together.
  2. INSERT IGNORES are faster than a SELECT query and then a possible a INSERT query.
  3. Move the queue to memory
  4. Use LOW_PRIORITY on DELETEs that don’t matter.
  5. memcached is awesome, if your not using memcached or something like it then you really should.
  6. If possible, avoid; LIKE, GROUP BY, DISTINCT as these are all slow.
  7. Use something like beanstalked to manage the queue.
  8. They used an MD5 hash (calculated in php) as a primary/unique row key. This is faster than using AUTO_INCREMENT to manage the primary keys. Note: you could use sha1() for even less chance of a duplicate key.

HA Proxy, Google’s  MMM, NoSQL and CouchDB all got a mention near the end and during question time.

Kore Nordmann – CouchDB & PHPillow:

This talk introduced a completely new concept to me and got me excited about a new kind of database. CouchDB is different, very different to relational databases such a MySQL. Firstly it uses http to connect to it! This opens up immediate possibilities and new security concerns but means you can make a database connection within javascript in the users browser! There is no schema in CouchDB as the “rows” are infact JSON objects. This means each row doesn’t have to follow any kind of set rules, they could have a different number of “columns” or have very different data in each “column” such as a another object or multi dimensional array. Your probably thinking the same thing I was at this point, “do we have indexes in CouchDB? and how the hell would they work”. Well, there are indexes in CouchDB and they are very flexible, but they are harder to implemenet than in say MySQL. Indexes in CouchDB are called views. These views exist as code that is run to create e.g. a btree index. The great part is, you write the code for the view! and you can write it in javascript (or other languages with the help of plugins). This gives you far more direct control of your indexes and should result in you having a far better understanding of your databases internal workings. PHPillow is the framework for implementing coucheDB within PHP.

Juliette Folmer – Regex-fu:

Although there’s not alot to blog about from the regex talk, you really had to be there… Two things I did pick up was that PCRE is faster than POSIX and the php documentation for it is here http://php.net/manual/en/book.pcre.php. Also the built in and blindingly fast PHP Filter extension is often forgotten or not known about and the documentation is here http://www.php.net/manual/en/intro.filter.php.

Damien Seguy – PHP Code Audits:

Damien gave a good talk on security in PHP, he covered the usual stuff about REGISTER_GLOBALS being a terrible idea on any system, production or development. But went into far more detail on how he searches for security issues in a short space of time so that you can quickly audit your own code. The bottom line is search the php code with the help of a tokenizer for php injection in places that use backticks require/include etc and eval. Search the codes notes for swearing and keywords such as “todo”.

A good tip for finding redundent code he gave was search for variables that only appear once. Some of these will be global variables but some of them may well lead you to old or troubling code.

Tools he recommended were Groogle, Reviewboard, Rietvold and Smartbear.

Leave a Comment :, , , , more...

The Environmental Impact of Inefficient HTML Code

by Craig Mayhew on Jan.18, 2010, under General/Techie

These factors can be used to show the environmental and financial impact of inefficient HTML.

  1. A core 2 duo e6600 uses ~30 watts more when under single core heavy load than when it is idle. 30 watts = 0.03 kWh.
  2. Assuming 10p/kWh then 1 computer second costs 0.00008333 pence.
  3. Assuming 0.54055 Kg of CO2 emissions per kWh for the average UK grid electricity then 1 second of additional computer processing time creates 0.0045g of CO2
  4. 3600 seconds in an hour

Financial Cost = (pencePerkWh/3600) * 0.03 * renderSecondsPerPageView * pageViews

Examples: (using 1 million page views, each taking 0.25 seconds)

Financial Cost = (10/3600) * 0.03 * 0.25 * 1000000 = 20 pence
CO2 Emmissions = (0.54055/3600) * 0.03 * 0.25 * 1000000 = 1.12Kg of CO2

Leave a Comment :, more...

Cloud Computers – An easy way to lose all your data

by Craig Mayhew on Nov.01, 2009, under General/Techie

Regular backups, we all know the score. If you don’t make regular backups then you will lose data.

In recent years more and more of the big players are releasing bigger and cheaper cloud solutions. e.g. Amazon’s EC2 or Microsoft’s Azure. Clouds offer incredible scalability allowing you to go from needing no processing power to thousands of CPUs or a few megabytes of storage to terabytes without ever needing to upgrade your server. Unfortunately sometimes proper backup solutions are not put in place. After all it is no easy task to backup an entire data centre in a timely manor that doesn’t impact upon the clouds performance. Even more than that the backup must be stored differently to the main cloud. For instance it’s not a good idea to backup an Amazon EC2 cloud to another EC2 cloud. If someone found an exploitable flaw in the EC2 platform that meant they could wipe the cloud or the cloud itself failed and erased all it’s data then the exact same thing could happen to the backup copy. A simple solution is to mirror your data between two cloud platforms. The perfect solution is to maintain a tape backup (or at least some kind of offline storage) of your data and keep it in geographically different place.

Cloud computers are not immune to failure, they are simply as good as the software running on them. Some good examples of massive irreversible data loss:

Upto 1 million T-Mobile sidekick customers lose their mobile data

100,000 websites wiped by hack attack

Leave a Comment :, , , more...

WQUXGA 3840×2400 desktop backgrounds

by Craig Mayhew on Oct.18, 2009, under General/Techie

Although WQUXGA doesn’t quiet roll of the tongue it is the next size up for 5:4 displays. In anticipation of screens with this many pixels I thought I better start the search now for a desktop background…

Google does actually have a few images at this resolution:
http://images.google.co.uk/images?imgsz=huge&q=3840×2400

Flickr has just one:
http://www.flickr.com/search/?q=3840×2400&m=tags

Wow, IBM built some! http://en.wikipedia.org/wiki/IBM_T220/T221_LCD_monitors

1 Comment :, more...

Block Google Analytics

by Craig Mayhew on Oct.13, 2009, under General/Techie

To block Google analytics from recording anything about you visiting a website simply add the following lines to your hosts file. This will also give you slightly faster page load times on websites that use Google analytics.

# [Google Inc]
127.0.0.1 www.google-analytics.com
127.0.0.1 pagead2.googlesyndication.com
Leave a Comment :, , more...

Distributed Computing Should Keep You Warm This Winter

by Craig Mayhew on Oct.06, 2009, under General/Techie

Autumn is now upon us in the UK and in my opinion it’s cold. Some people might remedy the problem by turning on the central heating but not I. I’ve turned on more computers and set them running folding@home or World Community Grid. This warms the house just like the central heating except that instead of just generating heat that then seeps out of my house and is slowly wasted, I’m helping to cure cancer too. It would be good if more heating systems were able to make use of the energy before just turning it into heat.

Now imagine if everyone did this? Suddenly folding@home might have 1000x the processing power and would do the same amount of protein folding this winter as it would normally do as a whole over the next 8 years (taking into account processor performance increases).

So what do you say? Will you join me in this protein folding endeavor?

Leave a Comment :, , , more...

Photosynth on Steroids

by Craig Mayhew on Sep.19, 2009, under General/Techie

These are all built from flickr images, but instead using a much improved version of the photosynth algorithms.

Fly through of the San Marco square in Venice. Reconstructed as part of the “Building Rome in a Day” project. The reconstruction contains 13,699 images.

3D reconstruction of Dubrovnik, Croatia, containing 4,619 images.

A 3D reconstruction of the Colosseum in Rome, built as part of the “Rome in a Day” project. This model was constructed from 2,106 images.

The grand canal in Venice.

Leave a Comment : more...

Microsoft .NET Framework Assistant 1.0

by Craig Mayhew on Jun.02, 2009, under General/Techie, News

Microsoft took a step to far recently when they installed an add-on into Firefox in a recent Windows update “Microsoft .NET Framework 3.5 Service Pack 1“. As you can see in the following image I have disabled but not been able to uninstall the add-on.

Microsoft .NET Framework Assistant 1.0 in Firefox Add-on Manager

The reason it can’t be removed is that Microsoft installed the add-on for all users but the Firefox GUI can only handle uninstalling add-ons for the current user. Microsoft have released a further update that installs the addon on a per user basis rather than for all users which enables you to uninstall it via the previously inactive uninstall button in the Firefox GUI. The download can be found here.

Leave a Comment :, , more...

Visit our friends!

A few highly recommended friends...