Home

ceilingfish

Recent Entries

You are viewing the most recent 17 entries

April 7th, 2009

09:53 pm: The Prototype $$ operator and ruby datetime form helpers

Ruby form helpers come in all sorts of shapes and sizes, but one that's particularly helpful (being a sensible higher level abstraction) are the DateHelper methods. However when I was using them today I found a bit of a problem with manipulating them in Javascript. specifically I wasn't able to do the following:

<%= f.check_box :toggle_date_time, :onclick => "$('my-date-time-selector').disable()" %>
<%= f.select_datetime :my_date_time, {}, { :id=> 'my-date-time-selector'} %>


What I'm trying to do here is disable all the datetime fields when a checkbox is ticked, however it just doesn't work. It obviously doesn't work, because the date time helper is creating multiple fields, and Prototype's $ method is trying to reference a single html element (it turns out the creators of the DateHelper methods foresaw this and trying the above just doesn't give any of the elements ids).



So we need to find a way to reference all of these elements, which is pretty simple with Prototype's $$ operator. It allows you to get all the elements that match a css rule, so in this case we can get it to reference a matching css class name:



<%= f.check_box :toggle_date_time, :onclick => "$$('.my-date-time-selector').each(new function(el){el.disable()})" %>
<%= f.select_datetime :my_date_time, {}, { :class => 'my-date-time-selector' } %>


This assigns all the datetime selector elements the 'my-date-time-selector' class, and prototype then allows us to iterate over each of these objects. How marvellous.



March 12th, 2008

05:54 pm: Flash binary sockets
Things to know about flash binary sockets.

  • When serving socket policy files remember that they are terminated by a null byte (It says this very clearly in this article about security from adobe but it still got me.

  • When you are using the readUTFbytes method of flash.net.Socket it will remove any null bytes from the data you recieve (that's \u0000 for all you unicode character code fans out there).

  • The socketData event of flash.net.Socket will be triggered by the server sending no more data, and also sending a null byte. The server sending no more data is the real trick here as this means that when you've got alot of lag on your connection you'll get this fired when perhaps you weren't expecting it.



Tags:

November 12th, 2007

09:44 pm: Embedded model operations
OK, So thinking about MVC architecture, I'd always been lead to believe that the controller should decide which operations need to be performed, and then leave it to the actual model object to decide the specific steps of how to execute those functions.

Take fruit, for example, if I had a fruit controller and one of the operations is peel, the actual implementation of the peel operation is going to be different for each fruit. An orange is going to be a very traditional implementation, an apple is going to have to make use of some kind of blade or knife model, and a grape will- I assume- throw an unsupported operation exception.

What I'm wondering is, when does the tipping point come where you no longer want these operations to be deterministic based on just the model object alone? Should I actually be using like a context object as well to determine the actual operation I perform. Take for example the tomato. If a tomato is a fruit then yes, of course we want to peel it, however if it's not then I guess the idea of peeling a vegetable is insane (or at least insane in the context of trying to peel it with a fruit controller). So do you need a context here? Something akin to your perspective on whether a tomato is a vegetable or a fruit? I'm going to write it in pseudo-ruby code, because I'm bored.

So here's my original idea with the peel operation intrinsic to the fruit:

class Fruit

def peel; end

end

class Apple < Fruit

attr_accessor :radius

def peel
for section in surface do
knife.cut(section)
end
end

end

class Orange < Fruit

attr_accessor :radius

def peel
for section in surface do
hands.rip_off(section)
end
end

end


Which is all well and good. However consider the tomato situation, here we have a more pure model, which literally just models the data about the tomato.



class Fruit
end

class Tomato
attr_accessor :radius, :colour, :weight
end

class Attitude
end

class ThinksTomatoesAreFruit < Tomato
end

class ThinksTomatoesAreVegetables < Tomato
end


To determine the operation I guess you'll need an operation factory, so something like:



class TomatoPeelOperationFactory

def create(material,attitude)

if(attitude.kind_of?(ThinksTomatoesAreVegetables.class))
return new PeelTomatoOperation(material)
else
throw new OperationNotSupportedException("You can't peel a tomato. It's a vegetable")
end
end



Hmm. Seems like an unpleasant coupling. Alternatively should the model object actually have awareness of it's context and adapt to performing the correct operation based on the context's state at invocation. But that's a similarly awkward coupling. Additionally you'd need to have some consistent way to ensure that model objects could always be updated with the correct context. And what happens when you need to perform operations in different contexts simultaneously. OK, so I guess the context has to be externalised. maybe I should go eat.

October 28th, 2006

03:37 pm: Is that a hat?
I appear to live in Leeds. That's a bit of a change isn't it?

I also appear to be a Java programmer as well.

I'm sure I wasn't a Java programmer last time I checked.

But then again I was wearing socks last time I checked.

For some reason the realisation that I am not wearing socks has made me long to go and visit Edinburgh, I really don't know why as I haven't ever been to Edinburgh.

(Well, once, with an anti-poverty march, but I didn't really see Edinburgh just about 100,000 people, and lots of police)

August 29th, 2006

02:19 pm: Leeds

Went to the leeds festival.


Was good.


technorati tags:, , , , ,



June 10th, 2006

10:26 pm: spod
Can I just say. FAT32 doesn't support symlinks....

I hate FAT32.

Current Location: Spodpit
Current Mood: geeky
Current Music: Super furries - Something for the weekend
Tags: , ,

June 8th, 2006

07:27 pm: Stop
And the jobhunt is over.
Ladies & Gentlemen, I give you, dubit:

dubit.co.uk

I'm going to Leeds!

Current Location: Cloud 9
Current Mood: ecstatic
Current Music: I could have danced all night
Tags: , , ,

June 1st, 2006

07:18 pm: Ok, another job interview. On Monday. In Leeds. Somewhere. At 9am...

I so love job agencies.

Got a call from what I assumed was the IRA last night, turned out to be a nice lady from Huxleys Associates, asking me about myself and wanting to see details of my career. I supplied said details and even revised my CV (which apparently sucked royally).

I mentioned that I had friends in Leeds, well a friend, that lived near Leeds. ahem.

Well at least I am getting plenty of interviews.

May 20th, 2006

01:21 pm: If Mistakes were apples, you are such a strudel
Things done:


  • Got two job interviews

  • Bought times. Got addicted to Su doku, again.

  • Spent an entire evening in a bird hut

  • Saw the Da Vinci code

  • Looked forward to seeing a decent film next week instead.

  • Continued investigating the possibilities of JSON and tried to think of something fun to do with it.

  • Got jealous of all these people with new shiny cameras.

  • Remembered I can't do photography for shit. Ah well, I'll get a cake instead.



Current Music: Le Chic - free cow

May 2nd, 2006

10:28 pm:

Wait by Galway Kinnell



Wait-
Wait.
Distrust everything if you have to,
But trust the hours. Haven't they
carried you everywhere, up to now?
Personal events will become interesting again.
Hair will be interesting.
Pain will be interesting.
Buds that open out of season will become interesting.
Second-hand gloves will become lovely again;
Their memories are what give them
the need for other hands. And the desolation
of lovers is the same: that enormous emptiness
carved out of such tiny beings as we are
ask to be filled; the need
for the new love is faithfulness to the old.

Wait.
Don't go too early.
You're tired. But everyone's tired.
But no one is tired enough.
Only wait a little and listen:
Music of hair,
Music of pain,
Music of looms weaving all our loves again.
Be there to hear it, it will be the only time,
Most of all to hear
the flute of your whole existence,
rehearsed by the sorrows, play itself into total exhaustion.

How cool is that?


PS. posted here by her. Though she didn't write it. He did. Him (or her) up there in bold.



April 29th, 2006

10:39 am: Well, I have probably had a couple of weeks that were reasonably noteworthy. I have been to see the a fantastic interpretation of Edward Scissorhands, communicated through the medium of dance. Which given the expressiveness of the players worked remarkably well.

I also finally made contact with littleTom, which is a relief, as I was worrying that he was dead (this is all a little unfair really, as it was him that rang me). I must sort out dates for the little furry chap to come and stay, preferably when something interesting is happening. Which may be a bank holiday near you (or, in fact, me)

So yeah, should have probably updated with this earlier, but I have been trying to be ultra effcient these past few weeks. Unfortunately I appear to have realised too late that being efficient actually involves doing everything that you say you're going to do. And more. I basically was trying to do everything that I said I would, but that didn't appear to be quite right, I need to do everything that needs doing, which may really be a hell of a lot more. I'm not sure that I can get all that done though. Maybe I need to limit my ambitions. Maybe I should just give up and go back to being inefficient.



April 6th, 2006

10:38 pm: Dwarves
Went to see Carmina Burana this evening. Which was very odd.

There was dwarves (real dwarves), horses (real horses), a crucifixition (probably not real), and Nuns (probably not real nuns). I wasn't really expecting that. Possibly there was more to the strange singing and stamping than I witnessed. It might have made more sense if we had arrived at the beginning, instead we stayed at the restaurant and came in at our own beginning (probably not the real beginning).

In a shocking act of wierdness I am not asleep... I am going to go and lie down and consider the significance of this.

Night all.

Current Location: Bed
Current Mood: placid
Current Music: Eels - Dead of winter
Tags: , ,

March 12th, 2006

12:04 pm: Sheffield
I have been scampering around interesting and random bits of the country. It was fun.

My company sent me down to manchester for training, however to make up for this I got to see the musical printer! It's this big thingy (well, thingies, apparently they come in two) which instead of beeping to warn you that there is a possibility it might rip your legs off plays a rather jolly tune. When I saw it they were getting it ready. It was declaring this with a charming rendition of I'm A Little Teapot.

One of my course mates accused me of not being gay enough. Hmph, frankly.

Speaking of not being gay enough, I then met up with [info]athena_arena, post training for a damn good wagamama - ing. And got myself utterly wagamama'd. I thank said miss Athena for the usage of her toilet.

Finally if anyone ever tells you that Sheffield is ugly, chase them and sell them to french cheese distributors, it's all a lie. Sheffield has strange builders, a small army of cafe's and ceramic boobies. Sheffield wins.

PS I may have managed to introduce a boobies step into the Quality Control process of my company.

PPS Must get House.

PPPS Boobies.

Current Mood: where are my socks?
Current Music: Divine Comedy - Songs of Love
Tags: , , ,

March 5th, 2006

05:10 pm: Progress
So. on rolls the job hunt, and I have made pretty good progress really. today I have applied for:


  • Web Development Support - London

  • Web E-Marketing Developer - Warwickshire

  • Project Manager - Web Development - Nottingham



Which I am feeling exceedingly smug about. All this of course has relied on me completing my CV, which I have also done.

Of course I am applying for all these jobs now, and I'm not actually going to be able to take up any of the positions until like August. but I suppose I haven't ever been to a job interview, so the practice might be fun. That and I'll get to go to loads of fun new places for interviews, probably pretty soon too, cos all these applications were for companies who needed someone there yesterday.

Arkward moment of the day: My MSN away message was set to "Do not disturb, I'm applying for jobs", and my boss pops up and asks me a question. The MSN thinger autoresponds with my away message. Arse.

Oh yes, we've had an Ali all weekend, who we took to watch horses doing very strange things. with cossacks.

Current Mood: busy
Current Music: Goldfinger - 99 red balloons
Tags:

February 28th, 2006

09:28 pm: Jobs. And the retrieval thereof

Well I have this thing, I may as well try and use it.

I have finally got my CV written and I think it's time to apply for some random jobs. I don't think I'll get anything round here (unfortunately this is the North East and I'm not a car mechanic, so I'm a bit out of luck when it comes to jobs), but I might get some interviews.

Funny thing is I haven't ever actually been to a job interview, I have been working at Web Rocket Design for about 2 years, but I didn't really have an interview for that, my boss just talked at me for 5 minutes on the phone. It was quite weird. So I am guessing I need some experience.

PS. Tonight I did actually eat all the pies.



Current Mood: full
Current Music: None
Tags:

May 20th, 2005

02:24 pm: Well would you look at that.
OK. Let's face it, I have a memory that's about as good as a stoned goldfish, so this probably isn't going to get updated too often. It does however allow me to post comments to my good friend athena_arena's journal without having to appear as the anonymous masked man.

That said, I have actually seen anal passages that have better decor than this default style, anyone please help!

Current Mood: accomplished
Powered by LiveJournal.com

Advertisement