Bien Venidos
Search
Search
Archives

My friend does a lot of web development on her laptop. It is both her personal and work machine, so it needs to have a lot of stuff installed on it (a working install of xampp, multiple sites, video editing software and games). To help ease the pressure on the hardware, I suggested we install a virtual machine to run her web server services. That will allow her to easily change from work mode to play mode and ensure all hardware resources are available for video editing or gaming.

The plan was to use Windows Virtual PC to run a VM. All the files required would be housed on the host machine’s hard drive and somehow we would share that to the xampp htdocs folder allowing her to work on the host and have the guest machine publish the updates immediately.

First up we installed Windows Virtual PC and installed a Windows 7 32-bit OS on a guest. I personally run a Ubuntu VM for this purpose, but my friend is more familiar with Windows. We installed xampp on the guest.

Next I shared the htdocs stored on the host machine. Both the physical and virtual machine are in the same homegroup and have sharing permissions set up (we can trust our own VM almost explicitly).

On the guest:

net use Z: \\host\dev\htdocs password /user:HOST\username /persistent:yes

This mounts the network share as a user on the host machine. That takes care of some permissions issues I ran into and hope to solve when I have more time (my friend needed the machine up and running to do her job!).

Once the share was mounted as a network drive, it was time to tell Apache to use the files. Instead of configuring Apache to look at the Z: drive, I decided to use Windows 7′s mklink command to create a symbolic link:

mklink /D C:\xampp\htdocs Z:

The drive will remount on start up and the symbolic link will let Apache think it is looking at files directly in the htdocs folder. Now, when the website files are changed on the host one can simply load up a browser and navigate to http://guest and see the changes!

Posted in Computers, Virtual Machines, Windows | Tagged , , Leave a comment

I use PowerShell to make doing menial tasks on my Windows 7 PC easier. I rarely save these and end up having to write them each time I want to do the same task – which is simple because PowerShell rocks.

One thing I have to do often is unrar/decompress multiple archives spanning several folders. WinRAR comes with a handy command line decompression executable – UnRAR.exe. Here is my script to do my work (mainly so that I don’t need to remember it). It needs more work to handle errors and the like, but for now it is just this.

$archive = 'C:\Path\To\Folder' # Location of the parent folder
$location = 'D:\Destination' # Location of the destination folder
$winrar = 'C:\Program Files\WinRAR\UnRAR.exe' # Location of WinRAR's UnRAR.exe

cd $location

$subfolders = dir $archive | Where-Object { $_.PSIsContainer } # Get all subfolders

$subfolders | % {
$childpath = $archive + "\" + $_.Name # Path to subfolder
Get-ChildItem $childpath -filter "*.rar" | % { # Get all RAR files in the subfolder
$file = $childpath + '\' + $_.Name # Path to RAR file in subfolder
        & $winrar e $file # Executes a string as a command
    }
}

Edit: I completely forgot I wrote this script and wrote this one to do a similar task:

$parent = 'C:\Path\To\Parent\'

$files = @()

Get-ChildItem $parent -Filter "Identifying.Filename*" | % {
$dir = $parent + $_.Name + "\"
Get-ChildItem $dir -Filter "*.rar" | % {
$file = $dir + $_.Name
$files = $files + $file
}
}

foreach ($f in $files) {
unrar e $f 'C:\Destination\Folder'
}
Posted in Computers, PowerShell, Windows Leave a comment

At work we are a predominantly Microsoft shop, the software is written in Visual Basic .NET using Visual Studio Team System 2008. We use Team Foundation Server for our source control.

Automatic Backup

VSTS provides a method of “working copies” called Shelvesets. We use these to keep pending changes together – it allows users to share changes to files easily, and to switch work tasks easily.

I use it for something else, too. There is nothing worse than losing your work due to computer malfunction (this is rare, as the changes you make are saved to the hard drive like any other file) or personal malfunction (“this was working this morning, and now I have made too many changes and broken it” – much more common). To combat this I have a simple one line batch file running as a scheduled task. It will shelve all my pending changes once an hour, so at most I will have lost an hours work.

The script:

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\TF.exe"
 shelve "Automatic Backup" /replace /noprompt

What this does is use the Team Foundation Version Control Tool to shelve all pending changes (i.e. files in source control) in a shelveset called “Automatic Backup” and replaces the previous one without prompting me. This script could be easily extended to use a Grandfather-Father-Son backup, but I don’t require it.

I then saved the script as a .bat file and created a scheduled task to run it every hour, on the hour. All I see is a CMD window pop up and disappear – it doesn’t even steal focus from my work.

Source Tree Refresh

We have about 25 developers working on my product, which means a lot of check-ins every day. To help keep my local machine up to date, I run a build and source code refresh every morning. The source code doesn’t take long to get latest, but the build (2 odd GB of DLL’s) takes about 10 minutes. To stop me from having to sit and wait, I have a scheduled task to do it for me at about 7am every morning.

Getting the latest build uses proprietary tools, but the source code can be refreshed using TF.exe. The simple one-liner is:

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\TF.exe"
    get $/PATH/TO/DEV/VB.NET /recursive

This just does a get on the VB.NET folder in TFS. Simple.

Posted in Batch Files, Computers, Windows | Tagged , , Leave a comment

Just installed the WordPress application for my HTC Trophy 7. Now I can not update my site from my phone.

Included is a picture of an award winning pumpkin from the 2011 Killarney Show.

Posted from WordPress for Windows Phone

Posted in Mobile, Random Leave a comment

My main reason for actually creating this blog (aside from brushing up on my web development) was to house all my scripts/code snippets in one place. I don’t do anything terribly fancy with my computer, but I do write a lot of scripts to help out with various tasks. My problem is I often forget to save them and end up re-writing them every time, or after every format. Now I can just come back here and take a peek at what I already have learned.

The following script uses lftp to do a reverse mirror of my host’s FTP. They charge extra for shell access, so this is an easy way to keep my dev and prod environments in sync. One day I will get around to source control (most likely SVN).

Anyway, without any more ado, here is my syncing script:

#!/bin/bash
HOST='ftp.hostname.com'
USER='admin'
PASSWD='mypassword'
R_DIR='/www/wp-content/themes/theme_dir' # remote path
L_DIR='/var/www/wp-content/themes/there_dir' # local path
# Use lftp to sync the local folders
cd $L_DIR
lftp -u $USER,$PASSWD $HOST <<END
cd $R_DIR
mirror -R
quit 0
END
Posted in Code Samples, Computers, Linux 3 Comments

So, I forgot all about this site. Tsk tsk.

This afternoon/evening I am going to do some tidying up on my Ubuntu virtual machine and maybe some work on the site itself.

I am running Windows 7 Professional here at home, but to do my development I am running Ubuntu Lucid Lynx in Windows Virtual PC. I used this post to help me get it installed. Not too much config, just a few tweaks. I know I can use VMWare or VirtualBox, but I would like to keep my machine clean from all the virtual devices that come with those options (even though they are probably better at what they do – multi-monitor support for one). This VM only runs Apache and some other tools. If I find myself running more often I will probably upgrade, or maybe even run a dual boot situation again.

Posted in Random Leave a comment

Had my 25th birthday a week ago and had a great time. I hired out one of the pink stretched Hummers to take my friends and I to Hooters on the Gold Coast. I knew it would be fun, but I didn’t know it would be that that much fun! The inside was like a mini-club and there was a massive bar for us to store drinks for the journey.

A few of my friends threw in together to buy me a 1/12th scale Tamiya Lunchbox radio controlled monster van. It needed the R/C system (transmitter and receiver), steering servo and battery, but once I bought those things it didn’t take long to build. As it was my first build of something like this, I think I did OK. I only had to strip it down twice to fix errors in my build (oops).

That said, I think radio controlled cars might be a new hobby for me. I had an excellent time building and driving my Lunchbox and I think I will buy myself a TB02D chassis when I have some money. I think that drifting calls to me, haha.

As for my ‘Box, I think I will adorn it with some custom decals and paint job.

That’s all from me for now. I have been working on the site layout in my dev environment, but haven’t uploaded the changes. I should do that sometime soon.

Posted in Uncategorized Leave a comment

Well, it’s November. This year has really gone quite quickly, but when don’t they? Someone once told me that the years speed up over time due to our perception of time changing as we get older. For example, for a six year old child, the wait till Christmas each year is excruciatingly long – one sixth of their life to be exact. For a 25 year old, that time is 1/25th of their life. Makes sense in a way.

Anyway, I figured since it is November I should get some more content up on here. I have uploaded a quotes collection from an IRC channel I have idled in since I was a wee lad. A friend of mine (Espen/Rexxie) kept these in his EdgePro quote system for many a year, but I was worried they might be lost one day since the channel is almost all but dead. A lot of them are in-jokes/you had to be there comments, but I thought it would be something to add.

I think I will add some extensions to the Quotes Collection WordPress plugin. Whoever wrote it did a smashing job for a quoting system, but it lacks an overall way to view the quotes (in a Bash.org way). I will do up some rough plans for my extension tomorrow and hopefully get started on paging the quotes :) .

Posted in Uncategorized 4 Comments

Hello, hello. This will be my first post on here, I guess. I’ve spent about five days setting up this WordPress theme. It isn’t finished yet, but I think it looks good enough for a “soft” opening.

What will I include in this blog? I am not too sure at the moment. Probably snippets of code, interesting things and small how-to’s. I often forget how to do simple tasks, and have to relearn many things over again – especially with Linux.

Anyway, that is all for now. I hope I think of something to post next, I don’t want this to be another dead-end website!

Posted in Uncategorized Leave a comment