Posted on May 14, 2010 by Rowan
This is a quick description of how I got PHPUnit working on Windows without installing PEAR
The PHPUnit documentation is a cryptic and sparse when describing how to install PHPUnit on windows.
I am assuming that PHP is already installed and working.
- Download the latest version of PHPUnit (currently 3.4.9) from here http://pear.phpunit.de/get/
- Extract to somewhere (I put it in my PHP directory)
- Edit the phpunit.bat file. At the bottom of the file there are two lines:
%PHPBIN% "@bin_dir@\phpunit" %*
- Change them to something like this:
set PHPBIN="C:\Program Files (x86)\PHP\php.exe"
%PHPBIN% "C:\Program Files (x86)\PHP\phpunit.php" %*
- To test if PHPUnit is working run “
phpunit --help” from a command prompt (PHP directory needs to be set in the path environment variable).
Filed under: Programming | Leave a comment »
Posted on April 26, 2010 by Rowan
We have a system that needs to send automated emails. But we were having a problems where we were not getting bounce emails from invalid email addresses.
After half a day of digging it turns out the problem was that the Return-Path header was being set to the user that the web server runs as. Which was a non-existent email address.
To set the Return-Path in PHP on a unix environment use:
mail('firstname.lastname@example.org', 'the subject', 'the message', null, '-email@example.com');
In windows envioronment use:
For more information see: http://www.php.net/manual/en/function.mail.php
Filed under: Programming | Leave a comment »
Posted on June 11, 2009 by Rowan
I like my music in artist folders so I created this little VB Script to move music albums into single folders.
It takes a folder full of albums in the format “Artist – Album” and creates a folder for each artist, then moves the Albums into that folder.
For example if you have a folder C:\Music and sub folders in the format “Artist – Album” like below:
C:\Music\Artist1 – Album1
C:\Music\Artist1 – Album2
C:\Music\Artist2 – Album1
It will turn it into:
C:\Music\Artist1\Artits1 – Album1
C:\Music\Artist1\Artist1 – Album2
C:\Music\Artits2\Artits2 – Album1
Just copy the below code into a text file, rename it something like “music mover.vbs” put it in your root music directory (C:\Music\ in my example) and run it. Your music should now be in folders by artist.
Dim fso, folderObj, folders, outputFile, currentDir, newFolder, dashPos, folderName
Set fso = CreateObject("Scripting.FileSystemObject")
currentDir = fso.GetAbsolutePathName(".") + "\"
Set outputFile = fso.CreateTextFile(currentDir&"\FileList.txt", True) 'file for loging things
Set folderObj = fso.GetFolder(currentDir)
Set folders = folderObj.SubFolders
For each folderIdx In folders
newFolder = ""
dashPos = InStr(folderIdx.Name, "-")
folderName = currentDir + folderIdx.Name
if dashPos <> 0 then 'we found a dash in the folder name (asuming that there are no artists or albums with dashes in their names the format is Artist - Album)
newFolder = currentDir + Trim(Left(folderIdx.Name, dashPos-1))
if not fso.FolderExists(newFolder) then
outputFile.WriteLine("Created new folder (" + Trim(Left(folderIdx.Name, dashPos-1)) + ")")
outputFile.WriteLine("Folder already exists (" + Trim(Left(folderIdx.Name, dashPos-1)) + ")")
outputFile.WriteLine(" - Added (" + folderIdx.Name + ")")
Call fso.MoveFolder(folderName, newFolder + "\\")
If I feel like it I might write a script that does the opposite, takes Music\Artist\Artist – Album and moves them to Music\Artist – Album.
Filed under: Programming | 1 Comment »
Posted on May 27, 2009 by Rowan
Sort of an addition to my previous post, Notes doesn’t like large tables being created with AppendTable().
You get this error “Illegal column width – check Left and Right margins”. The work around is to create the table with only one row and the desired columns and then use AddRow() to add up to 255 rows.
See the IBM technote for more infomation.
Filed under: Programming | Tagged: Lotus Notes | Leave a comment »
Posted on April 3, 2009 by Rowan
Some times Lotus Notes frustrates the hell out of me. Someone decided that it would be a good idea to put a hard limit (or at least a tiny limit) on the number of rows that a table can have
I’m not using composite applications introduced in Lotus Notes 8, I assume it handles this kind of thing a lot better. But the java client is to heavy weight and all our database (Applications) and they use the standard design elements anyway.
If you try and create a table with more than 255 rows you will get the error:
“Table can have only 255 rows”
List of Domino limits
The solution is to basically keep creating new tables when you hit the row limit. The only problem is that it creates a gap between the tables which may mess up the layout a little.
Here is a simple function I wrote to break up an array into multiple tables if there are to many rows and add it to rich text field
rtField – the field you want to add the tables to
tableData – a 2D array that gets converted into a table (this holds the table data)
rows – the number of rows in the tableData array
cols – the number of columns in the tableData array
Sub CreateTable(rtField As NotesRichTextItem, tableData As Variant, rows As Integer, cols As Integer)
numFullTablesToAdd% = 0
numFullTablesToAdd% = Fix(rows/255)
‘add tables first
For i%=1 To numFullTablesToAdd%
Call rtField.AppendTable(255, cols) ‘ max row tables
Call rtField.AppendTable(rows Mod 255, cols) ‘ whats left
Dim rtnav As NotesRichTextNavigator
Set rtnav = rtField.CreateNavigator
‘Dim rtTable As NotesRichTextTable
For r%=0 To rows-1
For c%=0 To cols-1
Call rtField.AppendText(tableData(r%, c%))
There maybe a way to instead create a table with HTML but I haven’t worked out out yet. Will update if I find a better solution
Filed under: Programming | Tagged: Code, Lotus Notes | 1 Comment »