Sleepless? Priceless!

  • Time for this iteration of a software project: 4 months
  • Time left after the client changed their mind about the “must have” requirements: 2 months
  • Amount of sleep within the last 40+ hours: 4 hours
  • Number of JOIN clauses in an eleventh-hour SQL statement that suddenly fixes everything: 12 (LEFTies, RIGHTies, INNERs… and also a UNION)
  • Time internal deadline missed by: 55 minutes… which isn’t actually that bad, considering everything that went wrong in the 55 minutes before them
  • Money earned: nil
  • Feeling after delivery complete: priceless*.

* also: knackered – guess I’d better get some sleep!

Writing A Calendar App In Rails Vs. PHP

Some time ago, I wrote a web-based calendar application in PHP, one of my favourite programming languages. This tool would produce a HTML tabular calendar for a four week period, Monday to Sunday, in which the current date (or a user-specified date) fell in the second week (so you’re looking at this week, last week, and two weeks in the future). The user-specified date, for various reasons, would be provided as the number of seconds since the epoch (1970). In addition, the user must be able to flick forwards and backwards through the calendar, “shifting” by one or four weeks each time.

Part of this algorithm, of course, was responsible for finding the timestamp (seconds since the epoch) of the beginning of “a week last Monday”, GMT. It went something like this (pseudocode):

1. Get a handle on the beginning of "today" with [specified time] modulus [number of seconds in day]
2. Go back in time a week by deducting [number of seconds in day] multiplied by [number of days in week] (you can see I'm a real programmer, because I set "number of days in week" as a constant, in case it ever gets changed)
3. Find the previous Monday by determining what day of the week this date is on (clever functions in PHP do this for me), then take [number of seconds in day] multiplied by [number of days after Monday we are] from this to get "a week last Monday"
4. Jump forwards or backwards a number of weeks specified by the user, if necessary. Easy.
5. Of course, this isn't perfect, because this "shift backwards a week and a few days" might have put us in to "last month", in which case the calendar needs to know to deduct one month and add [number of days in last month]
6. And if we just went "back in time" beyond January, we also need to deduct a year and add 11 months. Joy.

So; not the nicest bit of code in the world.

I’ve recently been learning to program in Ruby On Rails. Ruby is a comparatively young language which has become quite popular in Japan but has only had reasonable amounts of Westernised documentation for the last four years or so. I started looking into it early this year after reading an article that compared it to Python. Rails is a web application development framework that sits on top of Ruby and promises to be “quick and structured”, becoming the “best of both worlds” between web engineering in PHP (quick and sloppy) and in Java (slow and structured). Ruby is a properly object-oriented language – even your literals are objects – and Rails takes full advantage of this.

For example, here’s my interpretation in Rails of the same bit of code as above:

@week_last_monday = 7.days.ago.gmtime.monday + params[:weeks].to_i.weeks

An explanation:

  • @week_last_monday is just a variable in which I’m keeping the result of my operation.
  • 7.days might fool you. Yes, what I’m doing there is instantiating an Integer (7, actually a Fixint, but who cares), then calling the “days” function on it, which returns me an instance of Time which represents 7 days of time.
  • Calling the ago method on my Time object, which returns me another Time object, this time one which is equal to Time.now (the time right now) minus the amount of Time I already had (7 days). Basically, I now have a handle on “7 days ago”.
  • The only thing PHP had up on me here is that it’s gmdate() function had ensured I already had my date/time in GMT; here, I have to explicitly call gmtime to do the same thing.
  • And then I simply call monday on my resulting Time object to get a handle on the beginning of the previous Monday. That simple. 24 characters of fun.
  • + params[:weeks].to_i.weeks simply increments (or decrements) the Time I have by a number of weeks specified by the user (params[:weeks] gets the number of weeks specified, to_i converts it to an integer, and weeks, like days, creates a Time object from this. In Ruby, object definitions can even override operators like +, -, <, >, etc., as if they were methods (because they are), and so the author of the Time class made it simple to perform arithmetic upon times and dates.

This was the very point at which I feel in love with Ruby on Rails.

Suz. And Naivety.

Just been having on online chat with Suz:

(15:53:41) Dan: It [an online weather forecast on a web site I run] says we should expect a wet weekend, clearing up for an overcast week.
(15:53:54) Suz: and who puts it on the web site?
(15:53:59) Dan: The BBC.
(15:53:59) Suz: i always thought it was paul
(15:54:02) Suz: oh
(15:54:06) Dan: No – it’s taken from the BBC, who take it from the MET office.
(15:54:11) Dan: It’s entirely automatic.
(15:54:28) Suz: oh i see. i wondered why paul had the time or botherdness to do it

Sweet that she thought that Paul was spending about an hour a week keeping an online calendar up-to-date manually.

Alone, And With…

People who are in on the Secret Of The Jukebox will be delighted to hear that I’ve had a good long hack at it tonight (hence it being 4:30am) and I’ve managed to get heaps done and ready for Paul to break test, including but not limited to the new “Alone, And With…” engine, which doesn’t seem to suffer any longer from the age-old bug that gives it it’s name.

I’ve just finished listening to some old hard-to-get Goo Goo Dolls albums that I acquired a little while ago. One is silly over-punky shouty hard rock stuff; very coarse and unrefined, much unlike their later stuff. The other, ‘Hold Me Up’, is much recommendable: some tracks I’d heard before, some stuff I hadn’t heard, all very very good. In particular, enjoyed ‘Laughing’, ‘Kevin’s Song’, and the older version of ‘Two Days In February’. Toy.

Bovini: A Week Well-Spent

It’s been a busy week. I’ve spent a lot of my time at the office, trying to get the replication model for Bovini working – causing much stress as it failed time and time again. For those of you without a grounding in computer science theory, replication is the art of making data be identical (and editable) in several places at once without the fundamental problems that this goes on to cause, such as data identity conflicts.

In this particular case, we have two master copies of a database, and five smaller copies of a particular one-fifth of the data each (plus a little shared data), split around seven UK sites, and who’s computers can only be made to talk to one another between the hours of midnight and 4am each weekday. So: not only does the program I’ve been writing (and sweating on, crying over, and shouting at, this week) have to pull all the data back together and spread it out, it also has to detect whether two users at different sites edit the same piece of data during the same day, work out who’s most likely to be ‘right’, and ‘fix’ the data accordingly. Or, if it’s not sure, know who to ask for assistance. It’s a clever program.

And now it seems to be done. And working. Great!

Unfortunately, working like a dog on this little project has only taken time (and energy) away from my preferred software project – Three Rings – a program I’m writing for free for National Nightline. I’m likely to have a busy weekend catching up!

Regardless, tonight… will be a night for relaxing – Bryn, Claire, Paul, Kit and I are going to spend the evening in the Ship & Castle, drinking Real Ale and playing Chez Geek. A perfect way to end a week.

Edge of darkness

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

This repost was published in hindsight, on 22 March 2019.

Kit wrote:

A day of energy and focus. Paul and I hacking through stuff, fixing, tweaking, making work, prodding, pushing.

Its a slick operation. Paul and I discuss bugs and problems, mark them up on a whiteboard on the wall (installed for the purpose) and clear off fixed issues. Dan chews through problems in staccato style – a quick hit and run raid on a bad patch of bugs, followed by some Civilisation 3.

I spent much of the early part of the day creating new icons for the help section and improving some others. Later on Paul replaced me at the terminal – weaving together a gossamer of information into a cohesive and structured explanation of how the system works.

Bryn closes hostilities with a QA roundup. Vigorous and detailed, he pulled out anything he found that was out of place or untidy in the help system and listed it for change.

So its morning. We’re a touch behind schedule – but quality of the product is all. We are determined to fix the “showstoppers” (big bugs) and make a good dent in anything silly outstanding before we declare it released. I can see that taking a few more days.

Paul and I were left discussing its worth in our currently debris-strewn living room. What does this project actually mean? It means a lot – to me, to Dan, to everyone involved. Most of all its yet more proof of the magic that is Aberystwyth.

At the edge of darkness, all that is left is tomorrow.

Eventful

Been excessively busy this last week: lots and lots of work. Pulled a 16-and-a-half hour work day on Wednesday, fixing the entire network where my co-workers were unable to. It’s a lot nicer now. In other news, I won an eBay auction for a copy of the 1974 edition of Parker Games “Careers” board game, which is fab, and Claire, Bryn, Paul, Kit and I have been playing it all week.

Three Rings schedule looks tighter and tighter. Having some doubts about getting it to a stable 1.0 release by next weekend, the deadline.

Tonight, sometime after midnight, my awful ex-, Reb (if you ever hear me complain about my ex-, it’s undoubtedly her) dropped me two text messages out of the blue asking if I’m awake and to call her, in capitals (followed by two “X”s, which I take to be kisses). I can’t be arsed. I’ll drop her a text in the morning and find out what she wants.

Right now, I’m going to coax Claire to bed for rumpy-pumpy. ;-)

Stress

Things that are causing me excess stress and reduced sleep:

WORK

  • I’m writing program features that have been paid for, but may never be used.
  • I can’t keep a pcAnywhere connection to the client open for more than a few minutes.
  • I’ve been abandoned to sort out the database replication by myself.
  • A colleague insists upon demonstrating how stressed they are about their upcoming deadline, as if I needed reminding about mine (I’m already past it, and the client keeps phoning me to tell me all about it).
  • Pulling extra hours isn’t actually getting that much more work done.

HOME

  • I still have lots of Three Rings to go, most notably a file-storing system, and I can’t find a way to focus on it.
  • I have heaps of laundry to do…
  • …oughta tidy up, too…
  • …and sort some things out with the bank, with my parents, with the Dept. of Comp. Sci…

But, above it all – the killer:

  • I can’t find the motivation to get on with any of it, and it’s all building up into a mammoth heap of incompleteness.

End of rant.

Train Girl Fantasy

Take a look at the thread on Train Girl Fantasies that Andy has accidentally started. Participate! Tell us all about your Train Girl Fantasies. We all know you’ve had them.

Last night I fixed eight or so of the bugs that Paul and Kit found in my software project the night before. They’ve promised not to find any more before I’ve had a chance to fix these ones.

Banks

It seems that NatWest now only open during the hours at which I am at work. Yet somehow I’m expected to deposit my paycheque. This makes no sense.

Mostly, I’ve been watching Futurama and drinking good beer. On Saturday, Claire and I went up to a forest North of Dolgellau and ate sandwiches and failed to find climbable trees. And I twisted my ankle. In any case, after a week of working late and coming home to evenings with everybody-in-Aber-I-know, it was good to spend some time alone with her.

I should be coding Three Rings, or Kit will shout at me. Better get on.

Thursday Afternoon

Good progress at work today, easily catching up on the things I didn’t get done yesterday on account of having been at the Royal Welsh Show.

AbNib is proving itself popular, but I’m still not happy with it: there are a load of really cool features I’d like to add, yet. But that’s a job for another day. I’ll be up in Lancashire this weekend for Andy‘s party and to visit my folks, so I can’t do it then, either.

Claire’s gotten herself temporarily sterilized with a fantastic hyperdermic full of progesterone and with the aid of the nice people at Aberystwyth Family Planning Clinic. Woo and indeed hoo. She’s (theoretically) a lot less likely to forget to have an injection every three months than she is to forget to take the pill: something she’s demonstrated herself to be very proficient at.

I’ve been excessivley stressed for the last 48 or so hours. I think it’s mostly a result of having no money and my paycheque still being a week away, and having to live off my credit card in the meantime (which I don’t like doing). Also that my crisp-wound in my mouth from the other day has developed into a spot which would probably heal faster and hurt less if I could stop playing with it, but I can’t. And that I’m not making nearly as much coding progress on Three Rings as I should be.

I have a strange urge to go for a long walk in the rain this evening. I hope it rains.

Paul In Aber

Paul made it to Aber. Woo and indeed hoo. He, Bryn, Kit, Claire, and I went to the beach and drank beer and ate pizza to celebrate. Then Claire and I took turns in an inflatable dingy and I got soaked as a wave leapt over the side. You’ll probably see their reports of this on their journals, soon, too.

The wiki I was coding got finished. Sadly, only a few of you who read this will ever be allowed to see it, but it’s pretty sweet.

Plothole appeared in the story on Andy’s LiveJournal – he has me drinking tea, which, as everybody knows, isn’t going to happen on account of (a) caffiene being a really, really bad thing for me and (b) I don’t particularly like tea. Have reported this to him and await feedback.

This made me laugh: type Weapons of Mass Destruction into Google and you’ll get this page. I laughed lots.

Hawaii

I’m scared. Kit is researching the laws governing marriage in Hawaii, and I’m not exactly sure why.

“Hey; you can get married at 15 in Hawaii!”

Meanwhile, I’m currently coding a wiki engine. For those of you who aren’t in-the-know, a wiki is a collaborative network of web pages that anybody can edit. They’re fun, if a little anarchic.

Back to the code…

Claire’s Back

=o)

Last night was fun. After spending most of a day hacking into the BBC’s weather centre (I wanted a weather forecast XML stream, but couldn’t find a free one, so with Kit’s help I stole one instead), he, Claire (recently returned) and I went down to the beach after midnight with a bottle of Caern O’Moor Bramble Wine and enjoyed the first cool air the town has seen in most of a week.

I had a weird dream last night. Apparently, so did Kit. Must’ve been something in the wine.

Norfolk

Claire’s gone to Norfolk to help her dad move house, among other things. She’s back on Sunday.

Played a little Zelda and wrote a little Three Rings code last night, but didn’t do enough of either to be called ‘productive’. Rather, I watched The Animatrix with Kit and drank Firestoker and Hobgoblin and Newcastle Brown Ale.

I miss her already.