Carbon Dating

16 May 2020

, ,


Over the years, I’ve built a whole library of helper functions for working with dates in php, but I think they’re all a thing of the past now. Because I’ve been playing with Carbon Date library by Brian Nesbitt. It’s best described as Php’s DateTime for humans.

Here follows a quick summary, but I’m just looking at the very tip of the iceberg. Lots more!

Read More

Using Bootstrap Modals with Laravel

9 May 2020

, ,


I use modal popups all over the place in my web applications. The most frequent use is to make the user confirm deletion, either by typing DELETE into a form or by giving a reason for deleting the item in question. And I want to make this work in Laravel.

Note: this is klunky.  I’ve been playing with Laravel for a few weeks and if I end up using it as an ongoing development platform, then yes, things will be rewritten.

Read More

Project Management as a treeswing

22 Nov 2012

, , ,


Talking to a customer t’other day and I mentioned the (infamous) tree swing cartoon. He had no idea what I was talking about.

Read More

Mac OS: Can’t move .svn/tmp/entries to .svn/entries: Operation not permitted

5 Aug 2012

, , ,


I’ve recently had a completely new (to me) SVN problem. I’ve been trying to update my SVN working copy from the reposisty and I get this error:

Can’t move ‘.svn/tmp/entries’ to ‘.svn/entries’: Operation not permitted

I’ve tried running the svn cleanup, but no joy. Google is my friend… the fix is to run this command in terminal

cd workingdir
chflags -Rv nouchg .

chflags – Change File Flags command
-R recursive, -v Verbose (tells you which files changed)
nouchg means the file can be changed (immutable bit cleared)

The immutable bit was a new one to me, so I had to go and look that one up as well. When you can’t take the chance of a file getting accidentally munged, you can set the immutable bit. Not even root can delete a file with the immutable bit set, unless they clears the bit first (making accidental removal highly unlikely). Very sensible, and since I’m exactly the kind of person who might accidentally delete whole swaths of files while in root mode, I can really see the point of an immutable bit.

However, I couldn’t work out how or where the immutable bit was being set. More googling … this seems to be a common problem where some developers are using windows & others are using mac os x. Still not sure of the WHY but the context makes sense.

Names Changed to Protect the Guilty

3 Jul 2012

, ,


This came to me via one of my clients – they were talking about problems they’d had with another web developer.

The site in question is a standard ecommerce site where users have to register as part of the checkout process, and login to get downloads, and special discounts. Problem started when the site owner got this email from one of their customers.

I want to report that your site is NOT secure.
I had forgotten my password. So I did a Google search to see if I can find the webpage on how to re-set it.
Guess what? Someone has hacked your site and obtained all the passwords and email addresses and posted them online.
Sure enough, I found my email … and my forgotten password.

Basically, some script kiddies had hacked the site and posted all email addresses and passwords online with lots of (in)appropriate “ha ha, we got you good!” messages

Read More

The Life of a Software Engineer

22 Jun 2012

, ,


Life of a software engineer

Every time. This happens every time.

I’ve been trying to find the source of this wonderful cartoon, but have just ended up with loads and loads of blogs where people go “me too!”

RIP Dennis Ritchie

26 Oct 2011

,


Hello World

printf("Goodbye world");

Trailing Comma or Leading Comma

7 Dec 2008

,


We all know that Internet Explorer is a pain in the backside. But the particular pain I wanted to write about is its pickiness about commas in Javascript. For example:

var cars = new Array(
   'Saab' ,
   'Volvo',
   'BMW',
);

If you’re used to programming in Php or Perl, that trailing comma is perfectly okay, and could even be considered good practice because it makes really easy to extend the array – just add a new line and leave another trailing comma. The only problem is – this trailing comma is not strictly legal in Javascript. However, just about every implementation out there will allow it except for (cue drum roll) Internet Explorer.

So I’ve taken to coding lists like this:

var cars = new Array(
   'Saab' ,
  ,'Volvo'
  ,'BMW'
);

I’ve taken to using the same style pretty much everywhere I have a comma-separated list of things – it’s particularly helpful in SQL server stored procedures.

insert into t_users (
   store_id
   , user_accesslevel
   , user_status
   , user_number
   , user_title
   , user_firstname
   , user_lastname
) values (
   @store_id
   , @user_accesslevel
   , @user_status
   , @user_number
   , @user_title
   , @user_firstname
   , @user_lastname
)

Failing with grace and artistry

1 Jun 2007

, ,


One of the problems I’ve always had with PHP error handling is catching the fatal errors. If a php script encounters a fatal error it stops, and the desired error handling code does not get executed.

So the user will (usually) be confronted with a blank screen and, worse still, since the error isn’t logged I don’t know about it and therefore can’t fix it.

It’s a rare and confident user who will report a blank page or other such glitch; people are so used to working with a certain level of pain when using a computer that they just assume it’s unavoidable or that it’s been caused by their own inadequacy in some way.

Anyway, (thank-you PHP London user group) I now have a solution using the register_shutdown_function()

<?
register_shutdown_function('cleanExit');

// ... go and do all sorts of exciting stuff ...

$running = false;

function cleanExit() {
	if ($GLOBALS['running'])) {
		// script is still running - it's an ERROR
		// tell Bronwen about the error
		// tell user it's not their fault
	}
}
>

Favourite error message of the week

11 Nov 2006

,


‘Subtitle – Study Programming and Learn New Things About Punctuation

This week, when running a Php script, I got the error message:

Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM

After the “what!” reaction, I looked it up (remember, Google is your friend) and found that PAAMAYIM_NEKUDOTAYIM is Hebrew for a pair of colons.

It’s very nice that there is a word for a pair of colons (:: is used to access a static element of a class, so it can be used), but I feel that I am rather unlikely to use this term in casual conversation, or even in geeky programming-type conversations. I wonder if developers who have English as a second langauge have similar problems with the more standard and less esoteric error messages.

I’m also reminded, but not in a particularly nice way, of my first job where I wrote code for a Geac 9000 library computer in a language called ZOPL (ZOPL stands for “Version Z, Our Programming Language”). The guy who’d written the ZOPL compiler had obviously been a Pink Floyd fan and some of the error messages reflected this.