RSS ? Recent Blog Posts

Blogs » Archive for August, 2006

Pimpin Harry’s pretty bluescreen

by Maarten Manders

Proper error and exception display can save you a lot af time and nerves. A few months ago, Harry published a slick bluescreen script for exception handling. I modified it to handle errors as well and added some features which make it useful in productive systems as well:

  • Error logging
  • Error Mailing
  • Configuration

The script logs or mails unique errors only once to prevent your log file or mailbox to be spammed with the same error again and again. It also takes care of the error level including shutup operator. It’s a little bit hacky but did well on our dev servers (where errors tend to happen) in the past few weeks.

To use it, download and include the two files and then setup the error and exception handler in your PHP script:

set_exception_handler(array(’ErrorHandler’, ‘handleException’));
set_error_handler(array(’ErrorHandler’, ‘handleError’));

 

Hot PHP UTF-8 tips

by Harry Fuecks

As a result of all the noise about UTF-8, got an email from Marek Gayer with some very smart tips on handling UTF-8. What follows is a discussion illustrating what happens when you get obsessed with performance and optimizations (be warned - may be boring, depending on your perspective).

Outrunning mbstring case functions with native PHP implementations

The native PHP strtolower / strtoupper functions don’t understand UTF-8 - they can only handle characters in the ASCII range plus (may) examine your servers locale setting for further character information. The latter behaviour actually makes them “dangerous” to use on a UTF-8 string, because there’s a chance that strtolower could mistake bytes in a UTF-8 multi-byte sequences as being something it should convert to lowercase, breaking the encoding. That shouldn’t be a problem if you’re writing code for a server you control but it is if you’re writing software for other people to use.

Restricting locale behaviour

Turns out you can disable this locale behaviour by restricting your locale to the POSIX locale, which means only characters in the ASCII range will be considered (overriding whatever your server’s locale settings are), by executing the following;

<?php
setlocale(LC_CTYPE, ‘C’);

That should work on any platform (certainly *Nix-based and Windows) and …

 

Rails 1.1.5 security fix release

by Tim Lucas

The Rails team have released another security update, 1.1.5. Update your code/environment.rb to point to the new gem version, or go grab 1.1.5 and put it in your application’s vendor directory.

 

August Reading Materials from .NETLand

by Wyatt Barnett

People often ask me how I know so much. I tell them I am divinely inspired, but that is a lie. The truth is I read a lot. Possibly too much. And probably should get out more and see the sun or somesuch. But I hate the big blue room with a passion.

Part of the reason I read so much is that there are a lot of .NET resources on the web. But the signal to noise ratio can be a bit low at times. In any case, I thought I would share some recent items as well as some of the regular sources . . .

 

Render 3D Worlds Using CSS and the DOM

by Alex Walker

Cast your mind back through to mists of time to January 2001 — reality TV is hip and fresh, ‘Dubya’ is unpacking boxes in the Oval Office and Tantek Celik — he of box model hack fame — first introduces the idea of using the interaction of CSS borders to create diagonal lines without the need for graphics . His ‘A Study of Regular Polygons’ demonstrated that by varying the thickness of CSS borders properties it was possible to create simple geometric shapes.

Diagonal Lines

I clearly remember being quite gobsmacked by this idea at the time, but it also seemed a bit too obscure to be truly useful in everyday web development. Admittedly, a few developers managed to tease logos (Kevin did the SitePoint logo in a Tech Times edition) and simple diagrams out of a brittle tangle of DIVs, but in general it was all more about bloodymindedness than utility.

It’s taken five and a half years, but our own James Edwards (co-author of ‘The JavaScript Anthology’) has actually come up with a practical application of the technique. Using nothing more than Tantek’s idea, some JavaScript and some serious math noodling, James has constructed a working dynamic 3D …

 

Scripters UTF-8 Survival Guide (slides)

by Harry Fuecks

Following on from here, the presentation is now available here (PDF). Related recent discovery is TCPDF - basically a fork of FPDF (a pure-PHP PDF creator) but comes bundled with fonts that can handle a significant chunk of Unicode.

Anyway - many thanks to the local.ch team for hosting us.

 

UTF-8 Survival at webtuesday.ch

by Harry Fuecks

Continuing with the theory that everyone lives in Zurich, doing a talk tonight: “Scripters UTF-8 Survival Guide”. More detail here - feel free to drop by (will post the slides tomorrow)

So this isn’t a complete spam post, a question…

If you’re using Unicode / UTF-8, do you still need HTML entities?

My view is here…

With modern web browsers and widespead support for UTF-8, you don’t need htmlentities because all of these characters can be represented directly in UTF-8. More importantly, in general, only browsers support HTML’s special characters - a normal text editor, for example, is unaware of HTML entities. Depending on what you’re doing, using htmlentities may reduce the ability of other systems to “consume” your content.

Who wants to shoot that down?

 

Getting Strongly-Typed Control References out of LoginViews–without using FindControl()

by Wyatt Barnett

Get tired of using FindControl() and being tied to an ever-changing control heirarchy? Well, here is a trick for creating strongly-typed Page-level references to controls buried in the various ITemplate controls, such as LoginView.

 

OSCON 2006: When Interface Design Attacks

by Matthew Eernisse

Amy Hoy is the author of a Ruby on Rails- and design-oriented blog, Slash7.

I was amazed to see how packed this session was. They propped the doors open, and people were actually standing around outside the door trying to listen. It was really good to see that so many developers are looking for a way to make their interfaces more usable.

Amy started off with some really good, basic points to keep in mind:

1. People have expectations about how stuff on the Web works (e.g., navigation sidebars, ignoring ads, etc.)
2. Users ’satisfice’ or give up. (’Satisficing’ is where users will accept the first option that’s workable rather
that holding out for what’s optimal.)
3. Users scan rather than reading — many users will not scroll
4. Lots of people on the Web have low literacy

She also gave some simple principles to follow:

1. Text — keep it simple, break it up, highlight key text, use headings and lists
2. Forms — put labels on top, not to the left of form elements, break forms into sections
3. Buttons — Make it hard to click them accidentally, don’t put ‘delete’ right next to ‘cancel,’ describe results in clear English

She ended off with a really good suggestion — ask …

 

OSCON 2006: TimeTravel Tables in PostgreSQL

by Matthew Eernisse

A. Elein Mustain is a veteran developer of Ingres, Illustra, and Informix, and is the author of the weekly PostgreSQL General Bits column.

Elein showed how to use timestamps to keep an audit trail of all changes in your DB. With this technique, you never actually delete records, you just give them an end date. Multiple copies of a record (again, with timestamps for each one) also allow you to track edits. (This is a pretty standard approach, especially in ‘validated’ environments, or in government-regulated industries.)

The value of using Postgres here is in the advanced features like triggers that you can use with your deletes and updates to offload the work needed to maintain this ‘time travel’ system — rather than forcing your app logic to keep up with all of it.

You can also use PostgreSQL’s views to query the database for only the current data, or write procedural functions to query the state of the database at a particular point in time in the past.

Elein has her slides available online here.

 

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Logo Design, Web page Design and more!

99designs

  • Custom logo designs created ‘just for you’.
  • Pick the design you like best.
  • Only pay if you’re satisfied with the result.

It's Back!
FREE PDF with any printed book!