Bad Ideas – 3 in 3 days!

September 17th, 2009 by Richy B. No comments »

My first bad idea was on Tuesday when we all (at work) had a glass of wine to celebrate moving to the new office. Not such a bad idea – until after I took my sleeping pills (yep, I’m having trouble sleeping and had forgotten I was taking them when I had the wine). Sleeping pills + alcohol is a very very bad idea – my partner said that I was “vibrating” during the night, couldn’t stand up straight and I was disorientated most of Wednesday.

My second bad idea was leaving the pub for the celebrations when I did (after the glass of wine, I was on orange juice). It was absolutely pouring down with rain for the 5 minutes or so it took me to get to the tube, and 30 minutes later when I got home I was still drenched.

My third, and so far, final bad idea was this morning. I thought I’d save myself a walk from Euston Square tube station to work by changing tube lines and getting off at Goodge Street station. Silly bad idea. I had to change at Kings Cross station, up a flight of steps across and down to the southern-bound Northern Line – where I had to change again at Euston for the southern-bound Northern Line (as it branches at Euston) which involved me going up 2 escalators, across, down, across down another escalator to end up at the opposite end of the same platform. Up 2 escalators again, across and down 2 got me to the correct southern Northern line. I then exited at Goodge Street station and, seeing the lifts were very crowded, decided to walk up the steps. 139 steps later, I was even more out of breath and sweating then I was. Lovely!

Anyway, I am beginning to get a little bit of free time back after work so I should be able to resume blogging and twittering in a few days! Woot!

Techy: Find and replace on Linux excluding SVN folders

September 7th, 2009 by Richy B. No comments »

Just another snippet aid to memory, this find and replace (using perl) uses Linux’s find’s “prune” syntax to “prune” the path before it to avoid doing and search and replace on .svn folders:

find -path '*/.svn' -prune -o -type f -exec /usr/bin/perl -pi -e "s/ORIGINAL/NEW/g" {} \;

Techy: Internet Explorer 8, Reload Rendering Issues – Fixed!

September 4th, 2009 by Richy B. No comments »

I’ve just had a very very irritating time trying to debug a web page. It would load correctly into Microsoft Internet Explorer (IE) 8 and display/render correctly, but then when the page was reloaded or refreshed, it would be rendered incorrectly with a few sections offset and just generally looking wrong.

Thanks to a lot of search and trying different keywords, I found the IE8 Inconsistent Rendering when Reloading post on StackOverflow which said it was a problem with I.E. 8 and CompanionJS and/or DebugBar. Removing both of them (via the Control Panel->Add/Remove Programs / Uninstall Programs section) allowed the site to start working correctly.

Woopie!

This keyword rich post was created to try and help any other people suffering from the same Internet Explorer Page Rendering Incorrectly Upon Reload issue as I had from losing as much hair as I did!

PHP: Extract just the domain name from an URL

July 30th, 2009 by Richy B. No comments »

Although I posted this on Stack Overflow, but I thought for reference purposes I’ll keep a copy here as well on how to extract the domain name from a URL in PHP:

If you just want to handle three character top level domains – then this code works:

<?php
// let's test the code works: these should all return
// example.com , example.net or example.org
$domains=Array('here.example.com',
'example.com',
'example.org',
'here.example.org',
'example.com/ignorethis',
'example.net/',
'http://here.example.org/longtest?string=here');
foreach ($domains as $domain) {
testdomain($domain);
}
function testdomain($url) {
if (preg_match('/^((.+)\.)?([A-Za-z][0-9A-Za-z\-]{1,63})\.([A-Za-z]{3})(\/.*)?$/',$url,$matches)) {
print 'Domain is: '.$matches[3].'.'.$matches[4].'
'."\n";
} else {
print 'Domain not found in '.$url.'
'."\n";
}
}
?>

$matches[1]/$matches[2] will contain any subdomain and/or protocol, $matches[3] contains the domain name, $matches[4] the top level domain and $matches[5] contains any other URL path information.

To match most common top level domains you could try changing it to:

if (preg_match('/^((.+)\.)?([A-Za-z][0-9A-Za-z\-]{1,63})\.([A-Za-z]{2,6})(\/.*)?$/',$url,$matches)) {

Or to get it coping with everything:

if (preg_match('/^((.+)\.)?([A-Za-z][0-9A-Za-z\-]{1,63})\.(co\.uk|me\.uk|org\.uk|com|org|net|int|eu)(\/.*)?$/',$url,$matches)) {

etc etc. If you want a list of top level domains, you may find Mozilla’s TLD List useful and DKIM Reputation Detected Registered Domains code handy.

Techy: Resetting a Windows Vista Password

July 14th, 2009 by Richy B. 4 comments »

Due to staff changes at work, we had two Windows Vista PCs (Business Edition, but these instructions should work all all versions of Windows XP and Vista) which had installed/purchased software on them, but we did not know the user passwords and/or administrator passwords. We also did not have a “Password reset disc”. We therefore needed to “break into” them and it’s a lot easier than you expect.

  • First of all, from a machine which you do have access to, download the Trinity Rescue Kit (TRK) from http://trinityhome.org.
  • Now burn the ISO image to a CD/DVD (instructions will vary depending on which platform you downloaded the ISO from and what software you are using). Make sure you burn it as a “Disc Image (ISO)” (aka a “Bootable CD/DVD”) and not just storing the file “as is”.
  • Insert the TRK CD into the machine you need recovering and get the machine to boot from the CD drive (on Dell machines, just press F12 as it is booting for the “Boot Menu” and select “Boot from onboard or USB CD/DVD drive”).
  • Wait for TRK to load.
  • Select the first option on the TRK menu as you don’t need any fancy extras
  • Once booted, type “winpass -l” (that’s all in lower case and finishes with a hypen and then a lower case L for lima)
  • If you get a message about Windows already being mounted, just select the “Force” option.
  • You may then be asked to select a Windows installation – select one and see if it lists the username you are trying to reset. If it doesn’t, repeat the previous step and select another Windows installation
  • Make an exact note of the username as the spelling, spacing and capitalisation will matter
  • Type “winpass -u 'User Name'” where ‘User Name’ is the exact username you are changing. Select the same Windows installation as you did previously.
  • Select option 1 to reset the password for that account to “blank” and, if necessary, unlock the account with option 4 (if there have been too many resets previously).
  • When finished, type “q” and press return to exit winpass.
  • Eject the CD/DVD and reboot.
  • You should now be able to log into that user account without using a password (if it is the only Windows account on the machine, it should auto-boot into that account)

Needless to say, neither myself nor the makers of Trinity Rescue Kit can take any responsibility for any damage/problems caused by following these instructions and I can only say “it worked for me!” (twice).

gamy-dance
%d bloggers like this: