Skoda Fabia VRS, temperature beep, expansion tank replacement

Problem: My Fabia’s temperature indicator light started flashing and beeping at me a few minutes after the engine was started, each time I used the car. The coolant level was fine, and the car seemed to get up to temperature quickly and stay there, never overheating. A quick search of the Briskoda forum revealed that this is a common fault, caused by faulty terminals and/or electrodes in the expansion tank vessel.

Solution: On the VRS models, and possibly others, the electrodes that measure coolant level cannot be replaced or cleaned, so a complete expansion tank replacement is needed. Thankfully these are cheap (about a tenner) and easy to fit. Here is a fitting guide, with photos where necessary: Continue reading “Skoda Fabia VRS, temperature beep, expansion tank replacement”

Replace nearside headlamp on Fabia vRS Mk1 without removing battery!

Problem: According to many websites and a few mechanics, replacing the nearside headlamp on a Mk1 Fabia vRS involves removing the battery and battery box. This is because the clear plastic light-cluster cover almost touches the plastic battery box. Thankfully this is not true, as I’ve just found out… you don’t even need very small hands 🙂 Continue reading “Replace nearside headlamp on Fabia vRS Mk1 without removing battery!”

Launch Google Chrome Incognito from the terminal or a shortcut in OSX

Problem: Ok not really a problem, but I want to be able to launch Google Chrome straight to Incognito mode from a shortcut. This is useful when logging into multiple bank accounts, Google Apps accounts, or testing session based websites. etc etc etc.

Fix: Thankfully the Google Chrome.app can be launched with the –incognito switch to do just that. The terminal command to do this, assuming the browser is sitting in /Applications/ is this:

open -a /Applications/Google Chrome.app --args --incognito

Note: –args has to be passed to satisfy the ‘open’ command’s arguments first.

Launching it from a shortcut: If you want to create a shortcut to do this, open AppleScript Editor and enter the following:

tell application "Terminal"
	activate
	do script "open -a /Applications/Google\ Chrome.app --args --incognito;"
	delay 1
	quit
end tell

Note: The space in the Google Chrome.app name must be double-escaped with two backslashes like that to work. Also, without the delay I found that the script exits too quickly or something like that, and it doesn’t work.

Save the above script as an Application, and call it something like ‘Incognito’. Running this app will launch Terminal, Chrome Incognito, then exit Terminal. Bingo!

Giving your Incognito app an Icon: I’ve added the app to my Dock, and given it a special icon (see below for a downloadable PNG icon). To do this:

  • Open the image you want to use as the icon – it should be a 512×512 24bit PNG if possible – and copy the image to the clipboard. If you are using Preview to view the image, do cmd+a to select all, then cmd+c to copy it… this works for most other graphics packages also.
  • Locate the app you created above in Finder, then press cmd+i to bring up the info window (alternatively right-click the app then select ‘get info’).
  • In the resulting pop-up, click on the icon at the top to highlight it like so (notice the blue halo around it):
    Original Script Icon
  • Then use cmd+v to paste the new icon from the clopboard into the icon area and it should look like this:
    New Incognito icon
  • Close the info window, and it’s done. You should now have a nice looking shortcut that opens Chrome Incognito with one or two clicks!

Feel free to use this icon. It’s just the standard one with some ‘colour replace’ work to make it blue. You could paste some tacky sun glasses over it if you wished 🙂

Reboot Mac OS 10.* to BOOTCAMP from a desktop icon

Problem: I want a quick way to restart my macbook and boot to the Bootcamp partition with one or two clicks, for the next boot only. The two existing ways are:

  • Restart OS X then hold the option key after the startup sound to bring up the boot options. This can be a pain if you miss the sound, or if you want to initiate a reboot and then bog off and make a cup of tea.
  • Go to System Preferences > Startup Disk > select the Bootcamp partition > Click Restart. This sets the default boot disk, so needs to be un-set next time you want to boot back into OS X.

Solution: Mac OS can be rebooted with the shutdown command, and boot partition can be set with the bless command. like so:

sudo bless -mount "/Volumes/BOOTCAMP" -legacy -setBoot -nextonly; sudo shutdown -r now

(Assuming your bootcamp partition exists at /Volumes/BOOTCAMP)

As is probably obvious from the command, the -nextonly part means that the boot partition is being changed for the next boot only. The -r part of the shutdown command means it will reboot again, and the ‘now’ command means just that.. do it right NOW.

Running from an icon: The command above can be run with a small script like so:

  • Run AppleScript Editor.
  • type the following into the editor window:
tell application "Terminal"
	do script "sudo bless -mount "/Volumes/BOOTCAMP" -legacy -setBoot -nextonly;sudo shutdown -r now"
end tell
  • Save this script as an ‘Application’ to your desktop and give it an obvious name like ‘Reboot to Windows’.
  • Double-click the icon and Terminal should run, asking you for a password. Much quicker 🙂 (if you want to cancel the process, use CTRL+C to exit the script as you usually would)
Any comments or improvements? Please leave them below!

Convert eregi_replace to preg_replace in old class.phpmailer.php scripts

Problem: I have lots of legacy php code on old sites that uses eregi_replace to format up an HTML email body. As eregi_replace is now depreciated it can be replaced with preg_replace. This is tricky sometimes because the formatting is quite different.

Fix: Here’s a common line from class.phpmailer.php scripts:

$emailBody = eregi_replace("[]",'',$emailBody);

To convert that you’ll need to do this:

$emailBody = preg_replace("/\\/", '', $emailBody);

Wondering why there are so MANY escaping backslashes there? I asked that question and got this answer:

“..the backslash needs to be escaped once for the php string’s benefit, then again for the interpretation of the regular expression engine, as escaped characters like d indicate a digit in regular expressions. So a pattern of \d would match a digit, but \\d would match a backslash then a d character. PHP strings are lenient on backslashing when it isn’t necessary, so:
– setting a string to “d” will give it a value of d (the same as setting it to “\d”).
– but setting it to “”” will give a value of “.
– and setting it to “” will return a syntax error.

– PHP double quoted strings will consume the (first) backslash for \ n t r and “.
– PHP single quoted strings will only consume the first backslash for \ and ‘ “

There.. clear as mud!

WordPress replaces double and triple hyphens (– or —)

Problem: The other day I was trying to type two hypens (–) in a post, and when I saved/published the post, WordPress reformatted the hypens to display as an ‘en dash‘ (–).

More Info: After some searching about, and some helpful info provided in the WordPress Codex, I found out about a WP function called ‘wptexturize’ which is applied each time a post is rendered. The function – which can be found in ‘wp-includes/formatting.php’ – replaces quite a few things, like ™ to ™ etc.

Fix: You could stop this happening a number of ways i.e. editing the function to stop it doing the replace altogether, or install a plugin that does it (maybe this one, haven’t tried it!). I decided to use WordPress’s remove_filter function to stop the reformatting taking place.

To do this, open the ‘functions.php’ file within your theme. If one does not exist, create it.

Add the following code to the bottom of the file, taking care not to end up with too many or too few <?php tags:

<?php
remove_filter('the_content', 'wptexturize');
remove_filter('the_title', 'wptexturize');
?>

Then save the file (or ‘update’ if you’re doing this via the theme editor in WP admin) and view your post. That should do it! (proof is here, you can only see those double and triple hyphens in this blog post title because I’ve just added the code above to this sites functions.php also!)

Batch rename file extensions from .jpg to .png in terminal

Problem: A client sent me 164 images with incorrect extensions on them. I needed to change them all from .jpg to .png.

Fix: Open up terminal, navigate to the directory containing all the images and type:

ls *.jpg | awk '{print("mv "$1" "$1)}' | sed 's/jpg/png/2' | /bin/sh

..that should do it! This one-liner makes use of sed and awk unix utilities.

Add ‘Drafts’ sorting to Shopp Products list

Problem: There is no ‘drafts’ view filter in the Shopp (>1.1.9) Product Manager, i.e you can’t quickly list all the products that have ‘draft’ status in one go.

Fix: I made this mod to answer a question in the Shopp Helpdesk forum, it’s not very tested, but seems to work perfectly!

Open ‘wp-content/plugins/shopp/core/flow/Warehouse.php’ and replace this:

198
$subfilters = array('f' => 'featured','p' => 'published','s' => 'onsale','i' => 'inventory');

With this:

198
$subfilters = array('f' => 'featured','p' => 'published','d' => 'draft','s' => 'onsale','i' => 'inventory');

Then in the same file replace this:

199
200
201
202
203
204
205
$subs = array(
'all' => array('label' => __('All','Shopp'),'columns' => "count(distinct pd.id) AS total",'where'=>'true'),
'published' => array('label' => __('Published','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.status='publish'",'request' => 'p'),
'onsale' => array('label' => __('On Sale','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pt.sale='on'",'request' => 's'),
'featured' => array('label' => __('Featured','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.featured='on'",'request' => 'f'),
'inventory' => array('label' => __('Inventory','Shopp'),'total' => 0,'columns' => "count(distinct pt.id) AS total",'where'=>"pt.inventory='on' AND pt.type!='N/A'",'grouping'=>'pt.id','request' => 'i')
);

With this:

199
200
201
202
203
204
205
206
$subs = array(
'all' => array('label' => __('All','Shopp'),'columns' => "count(distinct pd.id) AS total",'where'=>'true'),
'published' => array('label' => __('Published','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.status='publish'",'request' => 'p'),
'draft' => array('label' => __('Draft','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.status='draft'",'request' => 'd'),
'onsale' => array('label' => __('On Sale','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pt.sale='on'",'request' => 's'),
'featured' => array('label' => __('Featured','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.featured='on'",'request' => 'f'),
'inventory' => array('label' => __('Inventory','Shopp'),'total' => 0,'columns' => "count(distinct pt.id) AS total",'where'=>"pt.inventory='on' AND pt.type!='N/A'",'grouping'=>'pt.id','request' => 'i')
);

Hopefully this will be included in a future version of Shopp.

Resize a U Bolt properly without heating

Problem: When re-fitting the ARB to the GT6 with new U Bolts, I found the new ones were too wide, and forcing them in would have resulted the badly seated washers and nuts:

Old and new U Bolts
Old and new U Bolts, too dissimilar

Fix: The new U Bolts could be bent to shape in a metalworking vice, but there’s an easy way to make sure they remain parallel:

Putting the U Bolt in the Vice
Put the U Bolt in the Vice and protect the threads a little
Find something exactly the inside-size of the old U Bolt
Find something exactly the inside-size of the old U Bolt
Tighten the new U Bolt against the chosen spacer
Tighten the new U Bolt against the chosen spacer
Keep checking against the old item until it's correct
Keep checking against the old item until it’s correct
Once it's right, note the flats are still perfectly parallel
Once it’s right, note the flats are still perfectly parallel