Categories
Code

Outlook Hates Line Breaks

If you’ve ever wondered why your plain text email message is randomly ignoring line breaks like n or rn then you’re not alone. I regularly use PHPMailer to send off automated emails and usually in plain text to keep it simple.

What Outlook 2003 (and 2002 and 2007 versions apparently) likes to do is be super helpful and remove what it regards as extra line breaks. It won’t be consistent either within a single mail or across many but it will make the content difficult to read. What you thought would be new lines will now be joined up in places and it seems to happen more often the further through the content you go.

There don’t seem to be many fixes for this issue but there are a few work arounds to help out.

  1. Turn off this “feature” in Outlook in the Tools»Options menu. Honestly I’m not sure what use it is anyway. Unfortunately you’d have to do this on all the recipient’s computers.
  2. Use HTML in your email rather than plain text. Depending on your content and need for complete accuracy, perhaps more time than it’s worth.
  3. Add twice the number of line breaks where you currently have them. This seems to help but now your email is rather full of white space and may be more difficult to read.

Other than changing email clients, which is pretty unlikely, that’s about it. If you know of other options to try and get Outlook to not remove line breaks, please leave a comment below. This Microsoft KB article explains which versions of Outlook are affected http://support.microsoft.com/kb/287816.

Categories
Code

New Version of Kisimi Wiki is Available

I’m happy to announce that a new version of Weka Design’s free wiki software called Kisimi is available. There are a huge number of improvements in the 20091025 release. Here are some of the more important ones.

  • Page security allows you to dictate exactly who can view and edit your pages. Some people can edit your pages, some can view and everyone else can’t see a thing. Security is as finely grained as you want it to be.
  • Kisimi now comes with an upgrade option at installation time and things are a little smarter. Installation can take less than 2 minutes!
  • Longer pages with headings can automatically generate a table of contents section.
  • Users can specify a timezone so that the dates and times are relevant to their location.
  • Administrators can prevent new user sign ups. Handy for those sites publishing their documentation and support pages to the world.
  • Any user with an email address listed at www.gravatar.com has their avatar image appear in their preferences.
  • Tidier user interface with plenty of little shiny bits.
  • Plenty of bug fixes including those messages for PHP configs that show all warnings. It’s still recommnended that PHP is configured without warnings for production servers.

Just head to http://kisimi.wekadesign.co.nz to download the latest version and start managing your online wiki content better.

Categories
Code

Adding up Rows with JQuery

Simple and sometimes unnecessary function to add table cells together and populate another with the total. Using jQuery because its easy and it works and we all love it.

$(document).ready(function() {
    var x = 0;
    $("td.num").each(function() {
        x += parseInt($(this).html());
    })
    $("td#total").html(x);
});

Where your table cells to add up are <td class=”num”> and the table cell that has the total is <td id=”total”>.

Categories
Code Interesting Stuff

A Closer Look at Wiki Authorship

Jeff Atwood takes an interesting look at the history of changes to wiki pages and the balance between opinion and fact. The larger wikis (e.g. Wikipedia) have a huge amount of data around page edits and Jeff’s article also highlights an IBM study on how the more popular Wikipedia content evolves over time.

There’s also a comment about one of my favourite subjects – reading too much into statistics. Apparently Jimmy Wales (Wikipedia co-founder) looked into who was responsible for most of the articles changes and found that 0.7% of users were responsible for over 50% of all edits. But an “edit” may be a spelling correction rather than adding content or altering the facts or meaning in an article. As it turns out, the data points to these hyper-active users doing just that – cleaning up after everyone else.

Kisimi uses a basic string comparison function called simple_text() to show the relative difference between two versions of a page. We could also use the Levenshtein function which gives the minimum changes to go from string A to sting B, but that doesn’t always make much sense for larger content changes. If someone sees that two versions are 96% the same then it’s obvious they’re much the same.

Categories
Code Web Design

Why Aren’t You Using FireBug?

I’ve been using the Firefox browser addon called FireBug for a while now and am amazed at how helpful it is. If you’re a web developer, and especially if you use JavaScript and AJAX methods, you should be using it.

For example, while developing I like to add in timers to PHP based pages to show how long things are taking. This way if a SQL statement needs some fine-tuning or a change slows things down I can see it happen. FireBug extends this to the entire page and the HTTP traffic. Here’s what happens when I load a page that has a few JavaScript calls, small images and a single CSS link in it,

Straight away it’s obvious what’s taking up the bulk of the time – those two library calls. Once I take those out of the equation the load time drops to under a second. And through all this the PHP timer function only shows me how long the server-side work is taking.

With FireBug I know who (in a geeky code way) is doing what and with who and I can act on it. Now that’s helpful.

Categories
Code Sys Admin

Creating UNIX Time in Windows Script

I recently found myself needing to convert a date/time in a Windows vbs script to UNIX time and struggled to find an example of how to do this. Correct me if I’m wrong, but there doesn’t seem to be any built-in function to change 20070109161723+720 to 1168359443.

After fine-tuning a few Google queries I found using the DateDiff function the easiest way and came up with,

Function WMIDateToUNIX(strDate)
ConvertedDate = CDate(Mid(strDate, 7, 2) & "/" & _
Mid(strDate, 5, 2) & "/" & Left(strDate, 4) _
& " " & Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & Mid(strDate,13, 2))

WMIDateToUNIX = DateDiff(“s”, “01/01/1970 00:00:00”,ConvertedDate)
End Function

Not the prettiest code I’ll admit, but if someone else can use it that’s all well and good.

Categories
Code

Decent Docs for Prototype

Recently stumbled across some decent documentation for the AJAX framework Prototype. Didn’t help me with what I was after but it’ll be useful in the future and to many others I’m sure.
I’m sure there’s more good stuff out there so leave a comment if there’s anything better.

Using Prototype v1.4.0

Categories
Code

Want to mix PHP with AJAX?

AJAX is of course the current web development buzz-word and has been for the last few months. Really it’s some fancy Javascript that runs when actions happen (like moving out of a form field) and talks back to the server end of things.

In it’s basic form, your code then runs on the server and throws some XML (the X in AJAX) data back to the client-side to act on. But where can I use all my PHP code you ask? Well that’s where xajax comes into play.

xajax is one of many libraries/frameworks that has sprung up in the last 12 months. For PHP it’s one of the best in my limited experience and certainly one of the most straight forward to use.

What xajax does is wrap calls back to your PHP functions in JavaScript, hence taking most of that translation out of the way. You include the xajax libraries, declare your PHP functions you want to use on that page and then link them to the actions you want to make stuff happen.

In more detail,

The xajax PHP object generates JavaScript wrapper functions for the PHP functions you want to be able to call asynchronously from your application. When called, these wrapper functions use JavaScript’s XMLHttpRequest object to asynchronously communicate with the xajax object on the server which calls the corresponding PHP functions. Upon completion, an xajax XML response is returned from the PHP functions, which xajax passes back to the application. The XML response contains instructions and data that are parsed by xajax’s JavaScript message pump and used to update the content of your application.

Categories
Code

Using UTF8 in PHP

Harry Fuecks from SitePoint has put together what looks to be a very handy library to allow PHP manipulation of UTF8 strings.

Historically whenever PHP has been given the task of changing UTF8 encoded strings (ie. form entries that your users input) it's not given out any nice in return. Full support is due in PHP6 but that is still a wee way off (and I bet there are a few of you still using PHP4).

So for the PHP coder who has been missing out until now got and grab Harry's new library.

Categories
Code

Subversion via Apache on Ubuntu

After using Subversion and different Linux servers (now Ubuntu) for quite a while this is the only How-To that I’ve found that is easy to follow and works straight away.
David Winter

Now I can access my code repository from work and come home to work from the same system here.

Update: Except I now find that our corporate firewall block the Report requests. Lucky we have an open line in our office to get around that. 😉