They say you learn something new every day.

I haven’t done this for a while now, but I was thinking about where to store some useful nuggets I’ve come across while learning WordPress and it occured to me that that is exactly what this is for.

In WordPress, there’s a button at the bottom of articles that, if you’re logged in, gives you quick access to edit the article. It uses this function:

edit_post_link()

It’s all very, but what if you want to change what it says?

Turns out, it’s easy enough:

edit_post_link(‘New text’)

I’m impressed by how good the WordPress documentation is actually – especially since a lot of the code is horrible old php.

For some reason, you can’t do this in vbscript:

x = 15 
Dim demoArray(x) 

It throws this error:

Microsoft VBScript compilation (0x800A0402) 
Expected integer constant

Instead, you have to do this:

x = 15 
Dim demoArray() 
ReDim demoArray(x) 

I use Sony Vegas for video editing. It’s a great application: really simple, and somehow much more intuitive than Premier Pro or Avid.

By default, when you install it on Windows, it can’t read mov files, because Windows doesn’t come with the driver, so, sadly, you need to install Quick Time.

For some reason though, at least with my version of Sony Vegas (8), there’s a problem with the latest version of QuickTime, and Vegas can only get the sound, not the video from MOV files.

The solution is to install an old version of Quick Time. I’ve used 7.62 in my latest project, and that worked fine, so anything older than that is fine. 

Usually, in vbscript, a line break is

vbCrLf 

 But that’s actually a new line and a carriage return, so to be on the safe side, if you want to get rid of line breaks, it’s best to also remove:

vbCr

vbLF

too 

Still messing around with Virtual Hard drives today, I needed to get a large file off of a VHD (and actually, I needed to add a file to it as well).

I always find virutalisation a little tricky, but discovered today you can add VHD files as virtual hard drives in Windows 7.

Just go to Computer Management, then click on Disk Management On the Action menu, select Attach VHD and you’re away. It’ll appear in My Computer, like any other drive.

I needed to compact an Access database on a machine that doesn’t have Access installed.

It turns out there’s a Microsoft command line tool that can do this quite easily: http://support.microsoft.com/kb/295334

The syntax is quite simple:

jetcomp.exe -src:”C:\database.MDB” -dest:”databasec.MDB”

It’s always annoyed me that some items in Windows 7 wouldn’t allow you to pin them to the start menu. It turns out, if you hold down shift while you right click you get the option to pin anything to the start menu.

I feel silly now for not knowing that. 

I’m thinking of reinstalling Windows 7 (yes, I know 8 is out, but I don’t want it). New Year, new OS. God I know how to party.

When I install a new OS, I always install it onto a virtual machine first. To test it, and also because my install disc is one I customized a bit.

So, I cranked up Microsoft Virtual Machine 2007 and installed Windows 7. All was fine, except I couldn’t connect the virtual machine to the Internet. I tried setting the network adapter to NAT as Google advised, and nothing.

Then I found someone mentioning that there’s a feature on your network adapter to enable virtual sharing. So I fired up Networking Sharing Centre. 

  • Clicked on the active connection 
  • Clicked Properties
  • And ticked “Virtual machine network services”.

Low and beyond, the wireless network adapter was now an option on the virtual machine and I was away.

For some websites that I run I fairly regularly need to resize some photos to a certain width. ImageMagick is a great application for command line image manipulation.

The syntax to convert a file to a specific width and the corresponding height (which is what I want to do) is:

convert InputName.jpg -resize 550x Outputname.jpg 

What I’ve found useful is running command line scripts through vbscript:

Set wshShell = WScript.CreateObject(“WSCript.shell”)
wshShell.Run “cmd.exe /C convert InputName.jpg -resize 550x Outputname.jpg”, 0, True

I know you can do all sorts of clever things from the command line, but not quite as many as vbscript can. I find it really useful to be able to access all of the vbscript logic, and read and write text files and so on, while at the same time being able to issue commands to the command prompt.

I have a spreadsheet, with a list of days in it. I want to sort them by their order in the week (ie, Monday – Sunday), but Excel being Excel, it seems them as words and sorts them in alphabetical order.

I’ve had a bit of a play and found two functions I never really use, both of which can do this:

Match

=MATCH(A1,{“Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”,”Sunday”},0) 

This is neat and  concise, but just returns the array element number.

Lookup

=LOOKUP(A1,{“Friday”,5;”Monday”,1;”Saturday”,6;”Sunday”,7;”Thursday”,4;”Tues
day”,2;”Wednesday”,3}) 

 A bit longer, but allows you to return arbitrary values, not just the array position.

Tag Cloud