I recently changed the layout and the column resize effected the display of images and Picasa galleries. To overcome these issues I used the MySQL REPLACE command which made changing embedded HTML a breeze.

If you do not know how to run SQL statements against your database it is probably better that you do not try this as it may lead to serious damage to your blog, it may even destroy all your work so take care.

Start by taking a full backup of your database. Then take a copy of the wp_posts table so should disaster happen recovery will be simple and fast.

UPDATE wp_posts
SET post_content =
REPLACE(
	post_content,
	'width="800" height="533"',	
	'width="650" height="432"'
)

In the above example I wanted to replace all entries with a width of 800, height of 533 with 650 and 432 respectively. The entire database updates when this SQL statement runs. As a precaution consider making another copy of the table to test the SQL statement first.

 

batch render 300x195 How to batch render and stretch in Sony Vegas 11 Pro

Selecting batch render in Sony Vegas Pro

If you have prepared regions in a video which you wish to output as individual files Sony Vegas Pro has a simple script called “Batch Render” that will do the dirty work for you. However it won’t stretch to fill video for you and if this is a requirement then you need to change the script.

Research reveals Vegas Pro versions before 9 would handle stretching to avoid letterboxing too. However the default installation no longer does. This is how you do it:-

  1. Locate the script directory (usually C:\Program Files\Sony\Vegas Pro 11.0\Script Menu)
  2. Make a copy of “Batch Render.cs” and call it “Batch Render Stretch.cs”
  3. Open the new file in a text editor and find the two lines that begin “args.OutputFile =”. You will find them around line 97 and 106.
  4. Create a new line below them and add “args.StretchToFill = true;” (without the quotes (see below)
  5. Save your changes, refresh the script listing in Vegas and use the new script to render files as before but use this new script instead
  6. After your changes the code should look something like this:-

    if (RenderMode.Regions == renderMode) {
    	int regionIndex = 0;
    	foreach (Sony.Vegas.Region region in myVegas.Project.Regions) {
    		String regionFilename = String.Format("{0}[{1}]{2}",
    				filename,
    				regionIndex.ToString(),
    				renderItem.Extension);
    		RenderArgs args = new RenderArgs();
    		args.OutputFile = regionFilename;
    		args.StretchToFill = true;  // <------------ Add this line
    		args.RenderTemplate = renderItem.Template;
    		args.Start = region.Position;
    		args.Length = region.Length;
    		renders.Add(args);
    		regionIndex++;
    	}
    } else {
    	filename += renderItem.Extension;
    	RenderArgs args = new RenderArgs();
    	args.OutputFile = filename;
    	args.StretchToFill = true;  // <------------ Add this line
    	args.RenderTemplate = renderItem.Template;
    	args.UseSelection = (renderMode == RenderMode.Selection);
    	renders.Add(args);
    }

    If programming’s not your thing you can download a copy of the script ready-made by clicking here.

    If you’re interested in programming Vegas this is a good starter video:

 

If you need to restrict the characters input into an HTML text form field, use the following Javascript to save time and resources wasted on a round trip to the server.

// Removes all non word characters such as +#</>
frmYourForm.inputText.onkeyup=function(e){
  e=e || window.event;
  var w=e.target || e.srcElement;
  w.value= w.value.replace(/[^\w-]+/g,'');
}

For other patterns check the list on W3Schools.

 

You will need access to your database via PHPMyadmin or other similar tool, if you don’t know what this means ask your IT or host to help out.

1. Open your Joomla database and look for the ???_users table where ??? is the prefix you selected during installation.
2. Open an SQL editor and enter the following code (replacing ??? with the prefix used in your database)

UPDATE ???_users SETPASSWORD= MD5('password')WHERE usertype ="Super Administrator"

If it worked you will see something similar to this:-

1rowaffected How to Reset the Joomla Super Admin Password

If you don’t then you will need to look through the list of users. You may find that a security measure (whether human or machine) has renamed the usertype to ‘deprecated’ or other setting to block its use. Edit this back to Super Administrator and rerun the above steps.

 

This is a note to self.  When you see Warning: Invalid argument supplied for foreach() in /home/yourdom/public_html/libraries/joomla/database/database/mysqli.php on line 391 it means the host has run out of disk space on the tmp folder used for sessions and other temporary files.  Specifically Joomla is trying to create a temporary table and it appears it gets as far as creating the pointer and php/mysql errors at the point of reading the data rather than at the point of adding data to the table.

So if you are not me and you have this error then the solution is to ask your host to clear out the /tmp folder and increase the amount of disk space allocated to it so it doesn’t happen again.

 

3082818 s Network Natzies Neutralize Net ProgressHave you noticed the growing number of communications interrupted by network policies? Recently I have been told by in-house support staff they cannot see links to images and videos in their email. Its natural for companies to police what travels across their network but the current set of rules employed by some companies appear to be draconian and certainly get in the way of good communication. For years I have taken screenshots and more recently video demonstrations for support and training purposes. To avoid email attachment limitations I upload these to websites such as Screencast and Youtube.

Screencast is a professional and paid for service specifically designed for the secure sharing of images and video’s so when government and organisations ban Screencast and Youtube traffic across their network you have to wonder why. Are they not secure? Is this anti competitive? Do they not have protection against virus and malware that maybe included in the stream?

But why Youtube too? Surely Youtube’s rules over what can be uploaded and the many people that report innappropriate material is good enough, why ban the entire site? Is it purely that government and these organisations do not trust their staff that they have to introduce rules reminiscent of 19th century schools?

Its frustrating to put together a report that includes images and video links to help with the description only for it to be rejected by some daft Network Natzie who wishes to exert control over the network presumably to maintain a false impression that he/she is important.

Network policies and protection are important but if it damages the reputation or ability for a company to function then its counter productive. If you cannot protect your network without disabling the value that network provides then why bother? Save yourself a bunch and drill your head into the sand.

 

Part of the fun in walking is navigating your way along paths and areas of public access with unfamiliar surroundings. Another important part is the place, I would rather be walking through woods or interesting countryside than shooting the sun in the middle of the Atlantic, and I am sure there’s an even amount of people who prefer the reverse.

One thing in common between air sea and land navigators is the preparation they make before a journey. The more information they have to hand during the journey the easier and safer they and their fellow travellers will be.

<Lecture Warning>
Pilots inform ATC of their intended routes, sailors give the coastguard with their routes and walkers give details of their route to family and proper authorities, at least that’s what is supposed to happen. Have you ever heard a child told off for not letting mum and dad know where they have been? Maybe it’s not so common with mobile phones today but really, if you are a regular walker, runner, climber or enjoy any activity outside it’s a good idea to provide someone with as much information about your activity as you can. This makes it easier for you to be located by rescue services should the need arise.

A Route Card is ideal for this purpose.
</Lecture Warning>

What is a route card?
It’s a list of waypoints and useful information to help you find your way across unfamiliar locations. Combined with a map and compass the route card will make sure you know where you are always. Here is an example:

SDC10327 Create a Route Card in Word 2010 & Garmin Mapsource

Example Walking Navigation Route Card

The idea is simple, you walk from one grid reference to the next after the pre-prepared magnetic bearing. If you have a good eye for distance (or are a neurotic pace counter) you don’t need much more that you see in this example. If you are interested in route cards you already know that.

This walk is straight forward because it follows the shoreline. Ordinarily I would add more notes, things I expect to see at some of the points to help me find them. Google Earth and Bing Maps are good for this.

Bing Maps include Ordnance Survey. You cannot draw your route with a mouse like you can on Ordnance Survey’s website but you can use it to check your folded map is up to date and switching between views helps you to understand the terrain better.

You can print your map from Bing or Ordnance Survey and add bearing checks. By preparing your route card and maps at home you can use satellite views to research potential waypoints and markers for bearings. Here’s the Bawdsey Walk map I prepared:

image1 Create a Route Card in Word 2010 & Garmin Mapsource

Bawdsey Beach Walk Ordnance Survey Map

The dark blue line is the intended track. The numbers are taken from the Route Card. The red lines point to a marker on the map, in this case the church. It doesn’t have to be a single point of course but on this map there are only three distinctive things outside Martello Towers and that’s Sea, Sand and a Church.

The red lines are numbered and I have spaced them at convenient points throughout the walk. At any point in the walk it will be easy to work out my place so long as I can see the Church.

How to use the Route Card Template
I have only tested the template in Microsoft Word 2010, I have no idea if it will work in any other version. You will also need Mapsource from Garmin. You do not need any of the maps, it’s just a way of creating a formatted list of waypoints. Garmin allows you to import KML and GPX files which covers most software, if you are stuck try Getamap from Ordnance Survey, there are some free options, I’m not sure if that allows you to export gpx files but the paid version does (they had a launch offer with 50% off when I bought in April 2011). Go to http://www.getamap.ordnancesurveyleisure.co.uk/ for more information.

The video demonstrates the Route Card template, hopefully that will be enough to get you started but if you find any bugs, have any suggestions, or need help using it please leave a comment.

Download Template

Release Date: 21 July, 2011

  • Now shows elevation and climb
  • Calculates page numbers

Download the Walkers Route Card Template for Word 2010

 

A short function to extract numbers from a string in PHP using a regular expression.

function extract_numbers($string) {
	preg_match_all('/([\d]+)/', $string, $match);
	return $match[0];
}

This function returns numbers in an array. See The Bit Repository for more details.  Kudos to Gabriel C for a straight forward solution.

 

swfupload makes uploading multiple files a snap and look good at the same time. It can be downloaded from Google Code with examples and implementation takes just a few minutes.

Firefox has a problem with the addPostParam call used to add post parameters dynamically. In normal use this is not important but if you wish to pass extra information with the files such as the name of a group to be associated with the files extra work is needed.

It appears only the second and subsequent calls work correctly, yet making two calls right away has no effect, so this won’t work:-

  swfu.addPostParam('groups',params);
  swfu.addPostParam('groups',params);

Firefox also fails if you change the visibility or display settings for container divs and yet these work ok in IE, so if you wish to hide the upload button until another HTML control is completed (such as a location selection filed or group name) you must move the button off the visible area (such as -1000px to the left) and return it afer a valid selection has been made.

How to bully swfupload to work in Firefox

The solution, found for me by my son an hero Adam, was to ignore the documentation and examples that come with it and load the swfu object only when needed and not to use window.onload. I have a function called updgroupval() that is called by the onclick event of a series of checkboxes, the first time this is called the swfu object is loaded:-

function updgroupval(ctl,id) {
	if(ctl.checked) {
		ctl.value = id;
	} else {
		ctl.value = '';
	}
	var params='';
        //a2s converts array into a csv string
	params = a2s(document.form1.group);
	var button = document.getElementById('SWFUpload_0');
	if(params != '') {
		if(swfu) {
			if(button.style.position == "absolute") {
				button.style.position = 'relative';
				button.style.left='0px';
			}
			swfu.addPostParam('groups',params);
		}else{
			settings.post_params.groups = params; 
                        //Create object
			swfu = new SWFUpload(settings);        
		}
	} else {
		button.style.position = 'absolute';
		button.style.left='-100000px';
 
	}	
}

By creating the object after the page has loaded Firefox and the object manage to communicate with addPostParam in the way described in their documentation. Whether this is just a freak of the versions I am using or total nonsense I don’t care. Now I can demonstrate smooth and stylish uploads in Firefox and IE and Chrome, all versions.

 

PHPMyadmin no longer adds a new host automatically (at least at 1.03am I could not find it) so here’s how it’s done manually:-

GRANT ALL PRIVILEGES ON *.* 
TO root@10.10.161.114 
IDENTIFIED BY 'secretpassword'
WITH GRANT OPTION

The with grant option is dangerous so only provide if absolutely necessary (the user can grant and deny privileges to other users).

© 2011 Martyn Walker | Software Architect | Hiker And Hacker Suffusion theme by Sayontan Sinha