Another ldir Update!


Written by

Yes, I know… No updates for nearly 12 months and then two come along in the same week!

ldir version 1.7.9 is now 10% smaller than 1.7.8! As well as saving minimal disk space, it’s also had some speed increaces.

The only downside is that we had to remove error code 3 from the function in order to speed it up; there are more speed increases to be had if I could reliably detect the file type icons with a fail over if there isn’t a type without utilising cURL.

If you want to customise ldir to not do those checks and just ignore unknown file type icons then the following code alterations will make a significant speed increase.

Change: (approx line 160)

$img = "unknown.png";
$type = "Unknown File";
//Remove this check to speed things up.
if(ldir_url_exists($ldir['im'].strtolower($ext).".png",$ldir['v'])) {
    $img = strtolower($ext).".png";
    $type = strtoupper($ext)." File";
}

To:

$img = strtolower($ext).".png";
$type = strtoupper($ext)." File";

ldir update


Written by

It’s been nearly a year since any update to ldir; mainly because it’s working quite well without any bugs etc but this update is only minor.

Here’s the Change Log

Version 1.7.8

  • Added better support for styling – Removed inline width CSS & Added CSS styles for each column
  • Removed some linebreaks.
  • Removed/Condensed some code (upto 7% smaller)
  • Custom UserAgent in CURL Opts.

So in simple terms, I’ve made it tell dropbox (the icon host) that it’s a web app, removed clutter around the code, condensed a few lines and added selectors rather than inline css so styling it (and making it responsive) should be much easier.

Responsive Web Design?


Written by

If you’re writing a new responsive website which seems to be the way to go for a single maintained site that is accessable via mobiles, tablets and phones then here’s some key screen resolutions to be targeting:

Description/Name Resolution Extra Info & Estimated Date
QVGA 320×240 Typically non-smart phones (and Smartphones c.2005)
HVGA 480×320 Typically older smartphones (c.2008)
VGA 640×480 Typically older smartphones (c.2008)
WVGA 800×480 Low-End Smartphones (c.2010 onwards)
SVGA 800×600 Low-End Computers (c.2000) and mid-range tablets
XGA 1024×768 Mid Range Computers (c.2005)
SXGA 1280×1024 Current Computer Screen (c.2010 onwards)
720p HD 1280×720 HD TVs, High-End Smart-Phones/Tablets
WXGA 1280×800 Laptops, Computers and High-End Smartphones/Tablets
WXGA+ 1440×900 Typically Laptops and Computers
Key/Odd Resolutions:
ipad & 2 768×1024 Portrait XGA
iPad 3 1536×2048 XGA
Kindle Fire 600×1024
iPhone 1, 2, 3 & 3G 320×480 Portrait HVGA
iPhone 4, 4S 640×960 Portrait DVGA
iPhone 5 640×1136
HTC Sensation 540×690

This is just a small list of resolutions that’s in use out int he wild so to speak. The varying resolutions does make it slightly harder to get a consistant experience throughout but as long as your site looks good in the first list then you will have hit the majority of devices (as long as you remember to test portrait and landscape!).

As you can also see, Apple has recently decided to use strange resolutions in their devices where as most newer smart phones are 800×1280.

If you’re creating a responsive layout then there’s lots of resources out there to create a fluid grid to reflow the content when the screen size changes. I personally recommend Zurb’s Foundation but the latest version doesn’t support IE7; although IE7 usage is shrinking.

Batch Scripts and Sixty Four Bits of Architecture


Written by

I was recently writing a batch script to auto-install service packs onto windows, detecting the OS version was relatively simple and there’s plenty of scripts on the internets to do this; on the otherhand, detecting between 32 and 64bit architectures is much more complicated.

Microsoft has a KB artictle with batch script code to do this which is great apart from it doesn’t work under a standard user account and might not even work on an admin account (it didn’t work on my domain admin account), so if MS can’t supply code that works is there even a detection method?

Some people suggest that you should be searching for the %programfiles(x86)% variable which is only on 64bit systems, this is great apart from it didn’t work either.

I then stumbled by chance on a great solution which is to check the %PROCESSOR_ARCHITECTURE% variable. This worked great! I have been told that if the machine has WMI disabled then this wouldn’t work but most systems have WMI enabled.

If "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
     echo x64
     "X:\Windows 7 x64 SP1.exe" /passive /norestart
 ) ELSE (
     echo x86
     "X:\Windows 7 x86 SP1.exe" /passive /norestart
)

That’s the code that I’m now using to detect the architecture of the systema nd install the correct SP, although it will attempt to install the 32bit Service pack onto 64Itinium machines; an extra check can be included to test for that but I’m unlikely to stumble upon an Itinium based system in my 20 PC office…

Variable System Result
%PROCESSOR_ARCHITECTURE% 32bit x86
64bit AMD64
WOW64 x86
Itinium IA64
%PROCESSOR_ARCHITEW6432% 32bit null
64bit null
WOW64 AMD64

Hope this is useful to others.

Migrating MySQL to a Different System the Easy Way


Written by

Well this week I’ve replaced my personal home server and reinstalled my work’s development server; both these systems have a MySQL server running which contain databases (duh) that would be either too large to import/export or too complex to rebuild from scratch.

So I decided to find a way of copying the database files directly between systems and it’s actually dead easy and strangely not very well documented! So here’s the steps to do it fairly painlessly.

This guide assumes you have a root account and root database access.

Step 1:

Log into MySQL and lock the databases from being edited by typing the following:

FLUSH TABLES WITH READ LOCK

Step 2:

In your favorite shell copy the databases like so:

cp -R /var/lib/mysql /mnt/mounted

Step 3:

On your new system copy the databases into the correct location:

cp -R /mnt/mounted/mysql /var/lib

Step 4:

Fix the permissions on the databases

chmod -R 700 /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql

Step 5:

Reboot MySQL server

service mysql restart

or

/etc/init.d/mysql restart

Step 6:

Unlock the databases by typing this into MySQL

UNLOCK TABLES;

All your databases and previous permissions should now be copied accross and working!