FindingIT

it s all coming back to me now Article

(back) (bak) the posterior part of the trunk from the neck to the pelvis; called also dorsum [TA].

Home

it s all coming back to me now Navigation

It S All Coming Back To Me Now
Laid Back Bakerman
Upper Back Pain
Baby Got Back Mp3




Below, you'll find extensive information on leading it s all coming back to me now articles and products to help you on your way to success.

Flipping Real Estate Contracts - Did You Line Up Your Buyers?
By alyssa collins

Flipping real estate contracts can be a great way for new real estate investors to turn profits without assuming the typical risks associated with buying and selling real estate. You're merely finding properties, locking in a sales price with the current owner and reselling that right to another investor to buy the property at the price you locked in.

By flipping real estate contracts you never own the physical property, so you don't have to worry about rehabbing or holding costs. Of course this is attractive because you assume no risk.

How do you start out?

Keep in mind, when flipping real estate contracts the best place to start is with a buyer of your contract.

Finding a hot property with a motivated seller and NOT having a buyer or network of potential buyers for your contract will seriously delay or destroy your profit potential.

Lining up a good network of professionals that can quickly convert your deals into cash should be your first priority.

Finding Buyers

To flip real estate contracts you need to gain the confidence of investors whose goal is to quickly re-sell any property acquired via your contracts.

Newspaper ads - Look for these investors in the newspaper under ads like "we buy houses" or we buy ugly houses".

Be honest and up front by letting them know you are looking for houses that need to be rehabbed. Also ask them if they would like to be contacted when you find a potential deal.

I assure you, if you establish a good relationship with these types of investors they will be very eager to work with you. The final investor usually does not want to do the initial legwork of sourcing properties so keep that in mind.

Also,

Ask your potential investor where they want to buy houses and what their price range is.
Location and price are critical to many investors, only willing to work in certain areas at predefined price ranges. Other investors may want you to contact them about any potential good deal.

Also

I Almost Spanked A Monkey
The Metro ground to a halt, brakes screaming at a station so far underground it could be the dead-centre of the earth. The doors sighed open and in stepped a man. I had seen him before. Or I thought I had.

He billowed through the doors, his long black coat a full two seconds behind him then stepped into the carriage and stopped, giving his coat an opportunity to catch up. His red waistcoat, his yellow and red striped trousers, his moustachioed face, the teeth like a burnt fence… somehow it rang a bell. It was only when two small monkeys darted out of the folds of his coat that it became apparent.

An alarm sounded and the doors slid shut.

"Ladies and gentlemen," he said with a voice as booming as I expected. "I have a rare treat for you today – without a net my monkey here will perform something never before seen on any underground transport system in the world."

People were staring. I was staring. The monkey stood upright staring back with only a tiny red waistcoat to cover his modesty.

"Not even the subway in New York has seen such a performance," he said. "My little friend here will sing the 'Superstition' by the genius that is Stevie Wonder. In G sharp."

People were walking up the carriages, eager to see what the lunatic in fancy dress was shouting about. I was no different and I stumbled forward as the Metro pulled away.

"Take it away, Terry."

We all stared at the monkey. He had drawn itself up onto its back legs, his hairy palms outstretched and opened his mouth. The Metro jolted all of the passengers forward but he remained, baring his fangs and emitting a howl.

So Terry burst into 'Superstition'. Apparently in G sharp. It was then I noticed the other monkey.

He was on his way to the front of the carriage but skittered to a stop too soon. I watched helplessly as he reached a furry fist into a handbag. Out came the purse then he scampered back, stealth-style to his master. A quick pit-stop in his master's coat and he was off again, back down the carriage. The paw flashed out again, this time into a skater's low riders. He tugged at the contents and the jeans slid down slightly.

I could see he had a problem and as I leaned forward I saw the wallet attached to the jeans by a chain. It wasn't enough, the monkey was wily and released the catch before taking the booty and bolting. Whilst all this was happening, Terry hadn't missed a beat and was keeping a good tune in spite of the fact that it was in G sharp.

His friend, meanwhile, changed direction. Our eyes met and I could feel his panic. I wasn't supposed to be watching him. I was supposed to be marvelling at his mate Terry's singing, everyone else was. He eyed me suspiciously for a moment and then charged across the carriage towards his next target: me.

I wasn't sure how to react to a monkey ambush. My breathing was heavy. I seemed to be squinting, focussing, trying to keep that evil little shit in my sights. For a moment he was gone and then pop – there he was, just out of reach. I knew then I had to kick that monkey's arse.

Slowly, he stood upright, his miniscule monkey mind processing some long-held instinct. He lifted his right arm. The paw was limp but began to make a fist as it climbed. He froze, fist aloft and stared deep into my eyes as I waited for his move.
The door sighed open.

He stared. I stared.

An alarm sounded. The door slid shut.

We moved forward and so did his hand, shooting down and cupping his fucking monkey nuts. He yanked at them with one paw whilst frantically beating his chest with the other. And then, whoosh, he vanishes.

And I was checking my pockets, on my hands and knees, emptying them onto the floor. I hadn't taken the opportunity and kicked his skinny arse when I had the chance. And I had paid the price; the gypsy, Terry, the light-fingered marmoset and my wallet. All gone.

An alarm sounded and the door slid shut.

]]>

Star Wars versus Superman
  He stood there, perched, waiting for the feeling of the edge of the building under the balls of his feet.  It would almost be like diving into the deep end of a swimming pool, he told himself.  The terrible churning way down in his stomach filled him with the reality that this was much more final.  It wasn’t as difficult as he had imagined to get up there, he just darted through the polished reception, rode the lift to the twenty-fifth floor and then ducked and dived people’s gaze through the final three floors to the roof.

  Over the road Hyde Park sprawled lazily into the distance.  He tried to concentrate on it, fool himself into calmness but vertigo kicked at his consciousness, spiralling the world below. He could just make out a man running along with a kite, his wife and daughter standing watching as it soared into the air.  All of the figures swung nauseatingly in and out of focus. 

  He I looked straight down the twenty-eight floors, snapping back into focus as he stared down the precipice.  Was this really the right thing to do?

  Yes.  It was too late now, there was no other choice.

  The silence swelled around him as he began the countdown in his mind.

  3 – 2 – 1…

  The strangest feeling engulfs you as your feet push against the edge.  It is total commitment.  Commitment that he hadn’t managed for anything else in his whole life.

  For a couple of seconds, that’s all there is; a man floating in the air, the hotel behind him, the park over the road, the ground below.  Everything stops, then:

  BANG

  The wind hits him hard, gravity realises what he’s done and wraps its cold fist around him, dragging him to the ground.  Vision blurs as the acceleration takes hold and then it’s over, time to get off the rollercoaster.

*

    The sun was shining intermittently and so, in spite of the wind,  I decided to have a quick walk through the park then along to Hyde Park underground station.  It a little further than Green Park but it gave me an excuse to pretend to myself I’d done some exercise. 

  Hitting the traffic and pedestrians on Park Lane as I left the park I became aware of a humming, a tune.  As people turned off, entered the park, crossed the road, I became aware of its’ origin.  The strange irritating tune was coming from a strange, irritating man walking a few paces ahead of me.

  Of course, as soon as I heard it, I needed to know what he was humming.  Not that I could ask him.  He might think I was a lunatic when it was apparent that he was the person displaying the symptoms.

  We soon reached traffic lights and the pair of us stood in the melee of pedestrians waiting for that elusive green man.  He – unaware and gazing intently across the road, waiting for the signal.  Me – pushing others out of the way to get within three people of him, two people, then right behind him to hear:

  Dun dun dun der diddle der,  dun dun dun der diddle der

  Now, I was sure I recognised it and that really started to piss me off.  I started to ask him but stopped, mid-syllable when I became aware that he wasn’t looking across the road, he was looking up in the sky, way up at the top of the Hilton Hotel that sits like a modern monolith opposite us.  I can feel the blood boiling inside me, I know this tune, I’ve heard it a million times before.  As it sits there, on the tip of my tongue, the verge of remembering, he starts frantically pushing through the crowd in front of him, trying to get away and take the song with him.

  Instinctively I reached out and put my hand on his shoulder, and his jacket came loose, falling to the floor.  It wasn’t until the sweater had come off and he was tearing at his shirt underneath that I followed his gaze upwards and saw what he had been looking at; I raised my eyes just in time to catch a figure at the top of the hotel push himself off into the open air.

  And that was what it took to remember.  My brain temporarily disconnected from it’s current obsession for a split second, running in neutral as I stared up open-mouthed at the jumper.  I couldn’t believe it, the song he was humming was the theme from Star Wars. As I watched him clambering over the bonnets of cars I could hear him in full voice:

    Der der da-da da-da daaaah!

  My eyes flicked between the jumper and the semi-naked man.  He’d reached the other side of the road and I could see what he was doing.  An old woman was waiting for a taxi  in front of the hotel.  Just where the body would land.  He was trying to be the hero, and that was why my mouth hung open – he was trying to sing the theme from Superman and getting it wrong.

  Fucking idiot.

  This imbecile bouncing through the crowds bastardising  John Williams’ best work and worse still, mistaking the great composer’s finest hour for one of his lesser works.  At the back of my mind I was hoping that the little prick would trip and fall, have to watch his hero-mission fail with a crunch of his nose.  I mean I’ll admit that there are some similar musical motifs in Williams’ work but you have to look at the catalogue as a whole.  Jaws, Indiana Jones, these are the touches of genius that elevate him above the majority of composers.

  Of course you couldn’t have second-guessed what happened next.   There was a crack as the superman made contact with the pensioner, knocking her off her feet and rolling with her into the road.  I smirked as somewhere an invisible conductor of fate waved his baton and with the perfect timing of the Star Wars main theme the jumper was whipped out of his descent as a parachute opened above him.

  I started to laugh as he drifted the final few seconds to the ground.  I doubled over. The people around me looked on, not knowing what was more bizarre, the naked man assaulting an old woman, the BASE jumper bundling up his parachute and sprinting towards the relative safety of the park or me, the man unable to stands up straight due to his hysterics.

  By the time I had calmed myself down the police and ambulance had arrived.  The former were busy questioning the naked idiot whilst the latter attended to his handiwork.  Both kept glancing over to the man propped against a tree still giggling slightly to himself that at least one musical ingrate had finally got his just dessert.

  As I headed towards Hyde Park underground station I picked up his discarded t-shirt from the gutter and slipped it into my pocket.  A gift from the invisible conductor in the sky.

]]>

A Stroll Along The Prom, Prom, Prom
A Stroll Along The Prom, Prom, Prom

By Adam Maxwell

"Nah, Tommy said he was on his last legs at the home," replied Percy.

"Bastard still owes me a tenner."

"You'll never see that again."

"Remember when he lost that bet with the sergeant and didn't have any money?"

Percy laughed, "Yes, and the sarge beat him to within an inch of his life!"

The pair stopped by one of the booths that peppered the prom and stared out to sea, both lost in the memory.

Out of the shadows of a viewing booth a youngster stepped into their path.

They stopped.

"Money. Now. And your watches."

He was cocky, not even a hint of threat in his voice until.

"Now, grandads!" he screamed, phlegm flying from his mouth and shoving the stickless septegenarian backwards.

Carefully the old man reached an antique hand into his coat pocket and began rummaging for something. After a few moments he began to remove it.

The second gentleman, Mac, took the opportunity and lifted his cane into the air, whirling it left to right and connecting with the boy's temple with a crunch.

The youngster crumpled to the ground and grandad number one pressed a button and the blade of a knife jumped out to slice through the sea-fretted air.

Percy lunged forward towards the prone kid lying face-down on the ground and slid the knife into his back under the ribs.

A hiss escaped from between the kid's lips and he fell forward to the floor, his hands grasping out for anything, his jaw opening and closing like a fish dragged from the sea. Almost as soon as he hit the floor Percy lowered himself carefully to the boy's side, staring into his eyes as he began to turn faintly blue. Percy shook his head and gently placed his leather-gloved hand over the boy's mouth and nose and watched as he slowly, silently suffocated.

"Lung?"

"Lung," he nodded, taking the wallet from the tracksuit bottoms. For a moment he broke his gaze as he checked the contents of the wallet. He took out a picture of the boy with his girlfriend or wife and child. "Is this how you support them?"

The kid's mouth was still bobbing as his face began to turn blue. Percy tossed the photo at him and hauled himself back to his feet before putting the wallet in his coat pocket.

The pair moved off a little faster than before.

"Where'd you learn that?"

"The Sarge."

A smile cracked across Mac's face as the memory played back in his mind.

]]>

Rudolph Redux
Rudolph Redux

By Adam Maxwell

Soon after what I now refer to as my 'Holiday Incident' I started writing 'Happy Holidays?' in cards instead of 'Merry Christmas!'

My wife was screaming out of the landing window.

"You are not putting that monstrosity on my roof."

I looked down at Rudolph standing two feet tall next to me. His paint was peeling, one antler had broken off leaving only a long, sharp, shard pointing straight up and a long length of cable protruded from his worn posterior that, when plugged in, would illuminate him for the whole neighbourhood to see.

Of course that wasn't the thought going through my head as I hung from the roof of my house, the electrical cord that was wrapped around my foot the only thing keeping me from falling two stories and landing on my head. And Rudolph? Well, instead of lighting up he was swinging and hitting me repeatedly in the face. My wife was inside the house and I was shouting and maybe I was screaming. When I eventually told the story to my friends I didn't mention the screaming.

I could see frost on the garden as it spun underneath me as I hung, twisting in the air, molested by a shabby reindeer.

"What do you want? I'm trying to get ready, we're going out in half an hour."

I could hear her through the bedroom window. She sounded the same upside down as she did the right way up.

Dear Santa, I have been a very good boy this year, please don't let me become the person they remember as Reindeer Man.

LOCAL MAN FOUND WITH HEAD UP REINDEER'S ARSE.

Children would make pilgrimages to the place where Rudolph nearly bought the big one.

"No, darling. Santa was worried but it was alright in the end - Rudolph could fly but the Reindeer Man couldn't."

I kept thinking of ice skaters and how they keep their balance after spinning around over and over. My memory was telling me that they tried to keep focussed on one fixed point so I tried it and the number on the door 81 became my focus. Really I was just trying to keep from thinking about how old the cable was and how it would snap at any second.

I started in the loft looking for decorations except I knew we didn't have any because we'd just moved into the house two months ago. My wife is at the bottom of the ladder saying, "Just go to the shop and buy a tree. If you wait for five minutes I'll come with you and help you choose baubles."

Notice the careful positioning of the word 'help'.

So, of course, I ignored her and started rummaging, a medium sized torch shoved into my mouth wedging it so far open that my jaw ached and saliva ran down at the corners. It was a treasure trove up there but for every box I opened, for every neatly wrapped nugget of a forgotten holiday season I found I was greeted with a thump, a bump or a grump from the Grinch downstairs.

Dear Santa, although I have not been a particularly good boy this year I was wondering whether you would see your way clear to leaving me a ball gag and restraints. They aren't for me so I thought you may make an exception.

It was then I found him. My soon to be nemesis. Dusty. Forgotten. Rudolph.

I carefully carried him down the ladder to the landing, put him lightly on the ground and began dusting him off. It elicited exactly the response I expected.

"What the bloody hell is that?" screamed my current nemesis.

On the third day of Christmas my true love gave to me; three blazing rows, two dirty looks and a promise there'd be no sex for me.

There were these carol singers in Australia who had gone out to do their thing and two of them had died of sunstroke. Perfectly normal thing to do at that time of year but they got carried away, filled with the spirit of the season and that was it, game over. This sort of thing happens every day, we just don't expect it to happen to us.

Rudolph had proved to be heavier than I imagined and it took me some time to wrestle the damn thing step by step, hauling it towards its appointment on the roof. By the time we reached our destination I was panting from the effort, I put him down by my side and bent over, my hands on my knees as I tried to catch my breath and... well you know the rest.

Dear Santa, thank you for the lovely flowers. And the grapes. The doctors and nurses have been wonderful and although the injuries I suffered were extensive only one of them is permanent. As I fell, only the only thing that stopped my face from hitting the pavement was a certain red-nosed friend of yours. I have been in touch with my lawyer who says I have a good case against you as I was erecting an effigy in your honour, thereby working for your, therefore you are liable as an employer. You will be hearing from us in due course.

A long time later, many months after I got out of the hospital my wife and I returned to the old house. It was November, maybe early December. I'd grown used to wearing the patch over my eye. We stood, the cold biting at us, my arm around her as she snuggled in for warmth and we looked at the house.

After a couple of minutes my wife said, "Come on darling, it's freezing. Can we go now?"

I smiled and nodded, kissed her brow and a kid ran out of the open garage wrapped up and ready for the cold. He ran past us, did a double take and stopped.

"Mister," he said, staring at me wide-eyed. "Are you a pirate?"

I laughed and shook my head.

"Wh-?" he began but the sentence stalled.

"You have to be a good boy at Christmas time," I said, leaning in close to impart secret knowledge to him. "I was a bad boy and Rudolph did this to me with his antlers..."

I lifted the patch. The kid screamed and ran. To destroy the good name of Rudolph was one of the things I enjoyed most.

My wife and I turned our backs on the incident at number 18 and went to find a bar we used to drink in.

]]>

B Flat Major Seventh
B Flat Major Seventh

By Adam Maxwell

Charlie felt sick.

Sick to his stomach.

In fact he felt sick beneath his stomach. So far down it was nearly back up in his kidneys. Outside it was dusk and he had been sitting in this shitty little room on the solitary wooden chair for around eight hours. At that moment the sun chose to start poking its head up from beneath the massive buildings that towered on the horizon and the light darted from their reflective exteriors, trying its hardest to play some fucked up mind game with him.

The coffee sitting in its cardboard cup on the small wooden table to the left of the window had long since gone cold and despite the girl who served him's remark that it would cheer him up it had spectacularly failed to do so. It was freezing in here, and that made it worse.

He moved towards the rifle that was leaning reassuringly against the peeling wallpaper to the right of the window, shouldered it and looked intently through the infra-red sights at the scene below.

Nothing moved.

No-one walked past.

Not yet. But he would come soon enough and then Charlie would have to do what he had been paid to do. All of a sudden he felt another of those twists in his sub-stomach area and thought he might have to desert his post to visit the little boys room. No, he couldn't, he would have to shit himself and be done with it because this was one job he was going to have to finish.

He never used to be like this. He remembered well the times when he could stalk someone for weeks, strike the fear of God into them before finally taking out the target. It was a real rush, a total danger sport; not like paint balling, bungee jumping or any of those so-called men's games. He was the real thing, the man with the golden gun. Even called himself Bond for a while in the early days, but it never really stuck with his employers. They always laughed and that wasn't the kind of reaction you wanted from someone who was going to give you hundreds of thousands of quid for putting a bullet between someone's eyes. So he was always just Charlie after that. Didn't try to inspire fear, didn't try to be pretentious, his reputation spoke for itself. Still does. Still speaks for itself, he told himself.

But for him it was different. Now he'd done so many hits he couldn't even remember how many people he had killed. He used to like painting, that was always his passion but his mother had insisted that the modern world still needed people with a trade; a trade is a commodity, if you can do something that no-one else can then you will always be in demand, that's what she had said. So in a roundabout sort of way that's what he'd done. There was certainly a lack of his profession. You couldn't just walk down any high street and find your local assassin's guild. That was all just fairy stories. It was just that he'd had enough.

Out of the corner of his eye, Charlie glimpsed movement down below in the street. He stepped to the side of the window and carefully looked to see what was happening.

A removal lorry had pulled up in front of the building opposite. Was this someone else muscling in on his job? Perhaps an escape route if the target had been warned? He stood still just watching and waiting, waiting and watching. The van had all the hallmarks of a real removal van, with Stravinsky & Son stencilled in red on the shabby green side of it. The two men who got out of the truck had matching shabby green overalls with the same moniker badly outlined on them. One man was oldish, perhaps late forties and the other younger in his early twenties. Stravinsky, no doubt. And son.

He took a look through the gun sight, checking out what the men were doing and other than being in the wrong place at the wrong time there was nothing strange about them. Just removal men doing their job. What struck Charlie as being odd was that such a sizeable removal van would usually pull up at the front of the building, not next to the fire exit. He once again put the gun back in its resting place against the wall before standing back in the darkness of the room and watching the two men at work.

Being a removal man would have been a profession. Being a removal man wouldn't give him acid indigestion so bad he felt like he had been eating raw chillies non-stop for twelve hours a day. Maybe he should just give it up, pack the rifle into his courier-bag and fly off somewhere where they wouldn't find him.

But they would find him, he knew that. You can only disappear if you've finished the job, otherwise you'll be on the receiving end for the next job. The only reason Charlie knew that so well was because the last thing most hit men expected was to be hit when they went to ground. It was all about planning and once the getaway was made most of them felt safe. He knew it wasn't like that in reality but if you had never killed a killer then you wouldn't know, would you?
Another vehicle pulled up outside, this time to the right of his field of vision; a crane, big, orange and suspicious. This was getting more complicated by the minute. Basically there were two choices, would he stay and do the job, risking being seen by the workman in the crane and the removal men or would he put it off again, just the same as he had the last two days?

All he had to do was tempt this guy out into the open and that would be it, one squeeze and one small-time politician would never make it big. Joe 'Lucky' Luciano would never be a senator. Bugger it, there wasn't any real choice about it, he had to do the job and do it now. The removal men were carefully wheeling a grand piano out onto some kind of net on the pavement. Charlie picked up his mobile phone and phoned the front desk of the flats opposite.

"Hello," said an overly enthusiastic Canadian woman's voice on the other end of the line. "How can I be of service."
Charlie took a deep breath, preparing himself.

"Hi, buddy," he drawled in his best Humphrey Bogart voice. "We've got a piano to hoist up here, which floor is it going to again?"

"One moment sir," the line went dead, then blasted some cheesy rock music for a couple of seconds. "Well, its going to the top floor so if you guys take it to the roof, we'll take it from there."

"No problem," he felt himself slipping back into his native tongue. "Cheers." Charlie hung up before the receptionist noticed his newly acquired English accent.

"Tits." said Charlie under his breath. He looked out of the window and up to the floor where his man lived. The lights in his flat were on now and he could see movement inside. He once again picked up the rifle and aimed its sight at one of the windows of Luciano's flat. He could see Luciano wandering around inside in his trademark grey suit.

Charlie couldn't do it. He started to sweat. His heart began to beat so hard it felt like it was trying to escape through his throat. Shit. This wasn't right. He couldn't do it. He wouldn't do it.

He sat down.

He stood up.

He would do it.

Probably.

He targeted the other of Luciano's windows this time, looking for movement in case there was anyone else in there. No-one but Luciano. And a flying grand piano. He put the gun against the wall again as the crane hoisted the piano past Luciano's second floor flat, past the third floor, fourth, fifth and then ground to a halt at the sixth and final floor.

Charlie watched.

A window opened and a man leaned out. He was inspecting the piano before they winched it all the way to the roof. The removal men had locked up their van and were making ready to leave; first Stravinsky, then son got into the van, stalled it once and drove off.

OK, this is it.

Charlie began fingering the mobile phone in his pocket. It was time. Couldn't put it off any longer.

He lit a cigarette and sat on the floor.

"One last time," he closed his eyes and took a long, hard drag. "Just this one last time."

He walked to the window and opened it. This is it, he thought. He flicked his half-finished cigarette out of the window. It slowly spiralled down the two floors to the empty alley beneath.

He took the phone out of his pocket and dialled the front desk of the flats again.

"Hello," said the same voice as before. "How can I be of service."

Charlie took a deep breath.

"There's a bomb in the foyer," he said in the thickest Belfast twang he could manage. "We will not be ignored. We'll blow your fuckin flats up."

"What's the codeword?" asked the woman.

Charlie fumbled slightly. This didn't usually happen.

"Bomb."

He hung up. The fire alarms started blaring.

He pocketed the phone, grabbed the gun and took the safety off.

The fire door on the ground floor flew open and five people came tearing out. The staff.

The flats were so bloody elitist.

Two more people bolted out of the door. The first floor occupants.

There was no way they would risk letting the occupants out the front. They had money to make and dead people can't pay rent.

Charlie was going to be sick. Definitely.

He looked around for something to be sick into. There wasn't anything so he just had to swallow it back down.

One more person came fleeing out the door. Probably the second floor occupant.

Charlie felt like his head was going to explode. His heart had reached such a pace it was in danger of breaking the land-speed record.

It was time.

He couldn't do it.

Yes he could. He bloody well had to.

A man who looked about six foot seven walked out of the door. It was all going to plan. He was Luciano's body guard.
The body guard blocked the view of the door but Charlie waited in the darkness, ready to put him out of a job.

Charlie waited. The bouncer looked left.

Charlie waited. The bouncer looked right.

Charlie swallowed more of his own vomit. The bouncer turned and spoke to someone behind him. He began to move left.

Luciano walked out in slow motion. Charlie had him in the crosshair now. Luciano's life was hanging by a thread. Charlie took his final aim, braced himself for the kickback from the rifle, closed his eyes and squeezed the trigger.

There was a noise that sounded not entirely unlike a B flat major seventh.

Charlie opened his eyes to see the two men, Luciano and bodyguard, had both been crushed by the grand piano.

Shit, was this good or bad?

Charlie's head began spinning. So what had he hit?

He dropped the gun to the floor and stared at the scene beneath him.

The piano had a gunshot wound in the centre of the keyboard.

Charlie passed out.

]]>

Jim Morrison's Leg
Jim Morrison's Leg

By Adam Maxwell

"I stole Oscar Wilde's cock you know?" said Jamie.

"No you didn't," I said. "You just told me you'd never done this before."

"I haven't. But you know that massive statue of an angel?"

My shoulders ached as the spade pushed into the ground once more. It only took a month of working in the Pere Lachaise to get this far. Paris' most famous cemetery, the resting place of such luminaries as Edith Piaf and Oscar Wilde had eagerly taken me on. In fact such an impression had been made I felt confident my employers would forgive the minor indiscretion currently being perpetrated. I put down the spade as I reached softer soil, took off my cap, wiped the sweat from my brow and tossed the useless garment onto the tombstone of the grave I was digging up.

"Please tell me that you didn't reduce one of history's finest literary minds to the level of a nob gag..." I trailed off, knowing only too well where this conversation was going.

"That's right! I got in here, chiseled it off and two days later I sold it on eBay." Jamie took another swig from the bottle of wine that seemed to permanently reside in his overall pocket.

The Pere Lachaise stretched out around us like an orchestra, the arrondissement's cutting through the pit with great sweeps separating the violinist from the cellist and the famous from the infamous.

"Shut up and keep digging," I launched the shovel into the earth and with a crack that echoed in the purple night I struck a rock. The handle sheared, leaving it half in my hand and half wedged into the ground, jutting out like some sort of warning to passing vampires.

"Ah shit!"

Jamie started laughing.

"For God's sake shut up. I'm going to have to go and get another one now."

"At this time of night?"

"Yes. At this time of night. Listen, I'll go to the gatehouse and grab one from the gardener's supplies. I'm sure I've got the keys in my bag."

Hauling myself out of the pit we had created, the loose soil around the edges crumbling back down and making more work for us, I stared for a moment at Jamie down there as he continued digging before scrabbling in my holdall. "Keep at it, I'll be back as soon as I can."

Walking away, the sound of Jamie whistling some tuneless dirge he had picked up in the cafe.

"They're all fucking French - no-one understands a word we're saying. Do you?" he stood up and addressed the cafe as a whole, squinting at the sun dancing in through the bay windows. "Does anyone here speak English?"

One or two hands went up, some words were muttered and then a more were tentatively pushed into the air. After a few seconds the cafe wasn't visible for raised hands.

"Ah. Okay then let's go. So what was it that you wanted to tell me that was so secret anyway?"

Jamie may have been lacking a lot of traits but dependability certainly wasn't one of them and it was this something I was relying on for the task I was about to sign him up for.

"You see Jamie," I said as the door of the cafe shut behind us.

"They've always been the same if you ask me," he interrupted.

"There's this thing I've been thinking about doing."

"All eating their fucking croissants and being so bloody aloof."

"I think it's the only way I can start to move forward as a musician."

"Music? Don't talk to me about music - all they bloody listen to is that sodding Edith Piaf..."

"Well not just as a musician as a person as well."

"I tell you what Dan if I ever get the chance I'm gonna take a piss on that woman's grave."

"I'm sure that will help," I snapped. "Now listen I need your help."

And so I told him. I mean I glossed over some of it. Made it sound like the sort of student prank we used to play but for the most part I told him the truth. How I wanted to go to the Pere Lachaise and pay the late Jim Morrison a visit. How I wanted to take his femur and have it made into a trumpet.

"You are a good trumpet player," Jamie nodded in agreement.

"It's a Tibetan thing. Apparently their sound is so deep it has a resonance you just can't imagine."

"I can imagine."

"No, it's not just that."

There was a pause and we looked at each other for a moment.

"It's your Dad isn't it?"

I nodded.

"Anything to get one over on these Frenchies mate," he said.

"Jamie, you've lived here for eight years and your fiancee is French. Please shut up."

Back in the incendiary void of the cupboard things weren't going quite so well. We didn't have a contingency plan for getting caught.

"Yeah, I told you," said Gerry, one of my co-workers. "I've just got to find my house keys and then I'll pick you up."

Footsteps clattered by, circling the room, with Gerry occasionally pausing to rummage in a bag or box. I tried to crane my neck, to see if the light that was breaking in illuminated any keys around me.

"No sweetie, I really mean it. Of course I'm not with another woman, that's ridiculous."

It was only a matter of seconds before he would be discovered. If only I hadn't hidden in the cupboard. At least then I could have got away with pretending I had fallen asleep.

"I'll be right over as soon as I - aha!"

I waited, not daring to breath, to move or even blink. I stared at the crack in the door.

"Yes. Oui. Oui. C'est ca ma petite lapin."

The light went out, the door shut and I exhaled.

"Where the hell have you been?"

I waved the new spade at him and he waved his wine at me in return.

"I decided to stop."

"What?" I shouted. "We haven't got time for you to stop!"

"Calm down. I had to stop for two reasons. Firstly because I needed a piss."

"Oh you didn't," I asked, scared of the response but knowing it all the same. "Please tell me you didn't..."

"I did," he grinned. "I pissed on Edith Piaf's grave!"

"Jamie! Do you have any idea how disrespectful that is?"

"And secondly, cos I think we're nearly there."

"Shit! Are you serious?"

I scrambled into the grave, shovel in hand and started digging. Within a matter of minutes my spade met with wooden resistance.

"This is it," I whispered to Jamie who was hovering over the grave-mouth.

Soon we had cleared the top of the casket and the plaque, although tarnished, bore the Lizard King's name.

The crowbar slid easily into my hands as I braced myself against the grave's sides and began levering at the head of the coffin. My hands felt clammy as the wood cracked and splintered, giving way easily to the pressure.

"This is it! This really is it!"

"Open the bloody coffin already and let's get out of here," said Jamie. "Someone's bound to come along eventually you know."

The lid crackled open, gasses hissing out as the seal that had been made decades earlier was broken.

"Well? Have you got it?"

I hoisted the lid to one side.

"Jamie," I said. "I think we have a problem."

"What do you mean?"

"Well, it seems he's escaped."

"Shit, you mean someone has beaten us to it?" Jamie passed me a torch and I shone it into the vacant coffin.

"No, I mean that I don't think he was ever..."

I trailed off as the torch glanced upon a small white piece of paper lying halfway down the length of the coffin. Reaching out, I picked it up. It was a business card. On it was printed an address in Paris and three words.

James Douglas Morrison.

It was over and I knew it. The flashlight performed a brief diminuendo over the empty casket as I gathered together what little evidence was left. I put the business card in my pocket and as the pair of us walked away I took out the harmonica, staring at its rust-encrusted reeds in the pre-dawn light.

I wiped it on my sleeve and then, after a moment put it to my lips and exhaled, inhaled, exhaled. It sounded awful but it reminded me of a Bob Dylan song I couldn't remember the name of.

"Sounds like Chas and Dave that," said Jamie. "I miss Chas and Dave."

]]>

The Dangers of eBay
The Dangers of eBay

By Adam Maxwell

ENTER YOUR WISH HERE.

PLEASE BE CONCISE AND SPECIFIC.

They were simple enough instructions, most people seemed to be able to follow them.

SALE OF YOUR SOUL IS ETERNALLY BINDING.

WARNING: WISHES MAY NOT BE HONOURED.

That wasn’t how it started of course, I had bought my first soul. On eBay. It satisfied me for a while, the novelty value of owning someone else’s immortal soul made me laugh. I felt like a better person, it was as if I was walking around draped in a spiritual blanket.

Soon after my actions became somewhat erratic and, believing that I would be immune from eternal damnation, got involved in something that not only tarnished the soul I had bought but also cast a pretty dark shadow over my own. I knew I needed more protection and so hit upon the idea of setting up my own website. It was a simple enough affair where people could come along, fill in their name, address, email address and check a box to say they wished to give me their immortal soul for perpetuity. So that they felt I offered a better deal than other sites of a similar nature I put in a clause by which they could retain their soul until their death, whereupon the soul would revert to me. What they got in return was whatever they wished for. In theory.

People came, of course. First tens, then hundreds, then thousands every day. Not all of them sold their soul but many did and I soon had more souls than I knew what to do with. I had become a soul broker.

I made sure I kept strict records, cataloguing and databasing every soul I bought and what their wish would be should I deign to grant it. Most were ridiculous; money, women, power. Occasionally they were worrying with deeply disturbing undertones. These were my favourites, I had a special section I would read often about what these crazies wanted. I felt close to them, fond of their unsettling tendencies, worried about them even.

There was one I had become particularly obsessed by, her name was Lynne and she had wished for her life to end. Quickly. I worried for her but mostly I worried that she may be tarnishing the soul that was meant for me. After all, if I had nothing to live for I can think of a few pretty depraved things I would get into before I threw in the towel.

Soon after the paranoia had set in over this I began waking in the night, my sheets soaked with sweat, even in the daytime I heard voices warning me I had been duped. Perhaps her soul was already so tainted and stained that I was actually in a worse position by owning it, it was conceivable she had palmed it off onto an unsuspecting broker.

My worries finally peaked when, passing a newsagent I noticed a bill proclaiming the attempted suicide of a woman. She had tried to jump off the suspension bridge and had broken most of the bones in her body. She was alive, but only just. In the newspaper she was identified as ‘a woman from Finch Avenue’.

I didn’t even need to check. I knew it was Lynne, I knew her address by heart.

Within the hour I was at the hospital, at her bedside. She was conscious, coherent but slightly groggy and didn’t recognise me. I couldn’t risk her behaviour any longer, I had to make sure that she didn’t do anything else to what was very nearly my property. After all, you wouldn’t buy a second hand car if you knew it didn’t start so why should I buy a soul that wasn’t properly looked after. It was time to grant her wish.

I stood for a second looking at her looking at me and then told her I was the one who owned her soul.

"No, please!" she shouted. "I’ve changed my mind."

"Shhhh Lynne, it’s alright." I said, smiling. "I’m here to grant your wish."

]]>

King of the Squirrels
King of the Squirrels

By Adam Maxwell

It's quite natural you know. To have imaginary friends. I bet you had one or if you didn't then I bet someone you knew did. It all starts that way but it's a fine line between fact and fiction and just because I believe it doesn't mean that you will. Or vice versa. So they had been there for quite some time, you see, lurking around only no-one believed me. Anyway, I'll tell you about it all just sit down and listen, that's it, that's it, let me explain.

Some kids have irrational fears, and in a sense I was one of them. It's not as common I would imagine but its just as real as any fear anyone out there might have. I remember it started when I was around six or perhaps seven, it was quite harmless then just a little bit of excitement in the childhood bubble. Then when I was around ten years old it all just vanished. I found it quite sinister at the time but that's why I mentioned the imaginary friends because it vanished - just like that.

My teenage years passed relatively uneventfully apart from the odd night waking up to sweat-soaked sheets and screaming into my pillow. Nothing unusual there you might say but you'd be wrong of course and for once ignorance would be a perfect excuse. It was when I turned twenty; that's when the trouble really started.

It was a cold morning when I woke up, one of those mornings when the duvet world almost wouldn't let me go back into the real world, it kept me prisoner for a good ten minutes after the alarm clock had gone off. When I finally dragged myself out, showered, shaved and ran out of the door I was still groggy from sleep but awake enough to be aware that something was wrong. I locked the door firmly and strode down towards the garden gate before having a moment's indecision and running back to check if I really had locked the door.

It was then I caught a glimpse out of the corner of my eye, a flash of red disappearing in the trees at the far side of next door's garden. That was the moment that my worst fears were confirmed.

It's propaganda, you see? The newscasters have been waging a war against me and people like me for years now. They have been 'informing' us of the decline in population of the red squirrel, how the aggressive old American grey squirrel is taking over and eating all of poor old red's food. It's bollocks of course. The red squirrel never went into decline, it just saw its chance and instead of going the way of the dolphin and ending up doing party tricks at 'Squirrel World' to earn its daily bread it went underground.

My imaginary friend, it turns out, wasn't so imaginary after all. I mean, admittedly he was a squirrel but we used to have such fun together - playing in the garden, boyish tumbles in the autumn leaves, fighting over nuts, that sort of thing. Perfectly normal. Then it all went wrong, they tried to take Gerald (my squirrel's name was Gerald) away from me. Neither of us wanted to be parted but the Grand Squirrel Council had decided. All red squirrels underground.

It turned out that Gerald was part of a squirrel militia, a crack band of nut gatherers that were on a mission to infiltrate wholesalers to provide food for the hoards of underground squirrels. In retrospect I can see why they came after him. He had jeopardised the mission and I was an accessory to it. I really used to panic about those squirrels coming after me but then, all of a sudden, it all went quiet.

Of course, apart from you, I have only ever told one other person. A woman I became very close to; loved even. Told her the whole story, opened my heart and she just took one look and walked out the door. Never seen her since. I soon learned that it wasn't an easy thing to accept and so I'd better keep it to myself except now it doesn't matter does it? So where was I - ah yes, leaving the house.

All day at the office I felt eyes watching me; from the air conditioning grill, from just behind the window ledge, just ducking out of sight as I brought them into my field of vision but always there on the periphery. It was a quiet day, I didn't have any meetings so I just sat at my desk and worked. By the time it came to five o'clock I felt physically drained, like I had just spent the day chasing my tail.

I arrived home exhausted, tried to watch a program about zoos in Russia on the television, rapidly gave up and went into a deep and troubled sleep.

I dreamt. About things I can only half recall; a fog, a room with no windows and the eyes watching me, always the eyes. When I awoke the sheets were drenched in sweat and I felt twice as tired as when I had gone to bed. It was still quarter of an hour before the alarm was due to sound but I got up anyway, not feeling like I could really rest in the state I was in.

Then it happened, I saw one sitting at the end of my garden. As I stood in my dressing gown with my coffee grasped firmly in my right hand the little bastard wandered out into the middle of the garden, jumped on the bird table and started eating the seeds I had left there.

Needless to say I was horror-struck, he chomped away for a good ten seconds before looking towards the window, winking and then running off. I sat down. I tried to compose myself, but I knew they had come for me. I didn't know what I could do, there was nothing else to do, if I stayed here I was a sitting duck, at least if I was in the office people could help me, see them coming and stop them from getting to me.

*

I looked fixedly out of the office window at the small piece of parklands the contractors had decided to dump in the middle of the city. It was no more than twenty metres square, a couple of benches, a bird bath and a scrawny looking tree. It was supposed to give you somewhere to sit on your dinner hour and eat your sandwiches. Unfortunately with space running low, towards the end of the construction the builders had decided, in their wisdom, to turn it into a park-cum-roundabout.

My secretary Anne walked in.

"Mr Jones," she cooed politely.

"Morning Anne," I didn't turn around to face her, I wanted to make sure they weren't out there first.

"There's a meeting at half past one but with Mr Todd but until then you're pretty much free." She waited expectantly for an answer but my mind was a blank. After a long, uncomfortable pause, she added, "I'm going to get some coffee for myself, would you like some?"

"Yes," I replied, turning around. "Yes please Anne, that would be lovely."

I smiled the best I could and that seemed to put her at ease, she went about her business and I tried to go about mine.

I switched on my computer and with a stuttering whirr, it slowly came to life. It was an irritating but familiar sound and a sound that, this time, wasn't right. I walked around behind the computer and listened. It was a scratching noise, like claws on metal. But it wasn't coming from the computer. I spun around and surveyed the office; the wastepaper bin, my filing cabinets, in the stationary cupboard. None of them seemed plausible. And then it struck me.

Just above my desk was a grille. It was no more than twenty centimetres square but it pumped a constant supply of not-quite-warm-enough air around and around the office. I pulled my chair under the grille, it wheels gliding smoothly across the smooth carpet tiles. With one hand steadying myself against the desk I tried to balance on the chair to look into the grille. It was dark up there, very dark but there was a definite scratching coming from inside I reached up to remove the grille and...

"Here's your coffee Mr Jones," I turned too quickly to see Anne come through the door, and suddenly everything was movement.

I woke up ten minutes later propped against the desk with Anne apologising profusely and trying to mop my brow with something brown and damp. I had hit my head on the desk on the way to the floor. "Are you ok Mr Jones? I startled you, I'm sorry, how's your head feeling?"

"It's alright, I thought..." I mentally retraced my steps, knowing she would call more than an ambulance if I told her the truth. "I thought the grille was loose, I was just checking. Stupid really. I feel an idiot." That much was true. I really did feel an idiot.

"You need some fresh," she looked over to the windows. "The windows in here don't open. Why don't we wander out to the park? You can compose yourself out there."

"No, really, I'll be ok," but I had checked the park. They weren't there. They were in here. I was safer outside. "Oh, alright, but just for a few minutes."

*

The post-rush hour air was crisp but murky outside, every time I breathed out it felt wrong, almost like I was breathing water instead of air. We reached a bench in the park and I took a big, long lung-full of the city air. Maybe it was just me, maybe it was all just a fantasy that some learned psychiatrist would be able to talk me out of. First thing tomorrow I'll call up the best one there is and make an appointment. I opened my mouth to tell Anne the story but she had vanished.

I stood up and spun around but she was nowhere to be seen. One second she was there, the next - gone. The scratching started again, but not on metal, this time it was on wood, on concrete and getting louder. I looked up into a tree and some fifty or sixty red squirrel began to emerge, each tree I looked at, the same thing happened. More and more of them until I was surrounded.

It was then I began to seriously panic.

"ANNNNNNNNE!" I screamed, hoping that if she didn't answer then someone would at least come and see this gang of squirrels. "SOMEBODY HELP!"

As one, the squirrels quizzically cocked their collective heads to one side as if mocking my screams. I dropped to my knees, unable to think of anywhere to run. This was it, I was surrounded. I began sobbing, my hands went to my head involuntarily. The squirrels began to advance and...

*

I woke up in here. They've been very nice to me. Anne came to visit and said she hoped I'd get better soon. The doctors, they keep asking me how I feel, am I comfortable? I overheard them, they think I've had a breakdown, but you believe me don't you? I knew you would when you walked in. And you see, I can prove it.

Last night, after they locked the doors and turned the lights out, they came back. They came through the air-conditioning, just like in the office. A nice squirrel called Bruce came on his own and explained it all to me, it was just a misunderstanding and he gave me this: it's a golden acorn. And you know what that makes me don't you?

]]>

Happiness is a Warm Gun
Happiness Is A Warm Gun

By Adam Maxwell

I wasn’t sure if I had dug the grave deep enough. After all, he was tall as me. But here, under the willow tree he loved so much seemed a fitting place to bury him. He would have wanted it this way.

I mean, there is very little I am sure of in this life but following the literal advice of the same man who had once claimed to be a Walrus was not the beginning of an adventure I may someday relate to my grandchildren. Even as I pressed that ‘Start’ button on the microwave I should have known it would end in disaster.

And so here I was, with the weeping willow’s sharp branches stinging the top of my head, jabbing into me as I continued digging. It was more tiring than I would have expected but felt somehow satisfying as the spade sliced clinically into the soft earth of my garden.

I had only set the microwave to cook for four minutes but even that was three minutes and sixteen seconds too long. It felt right, at the time, to test the theory, to see if John Lennon meant it literally or metaphorically. Now the words rang hollow in my ears.

I had watched from the other side of the kitchen as the microwave sprung to life, the turntable inside rotating the pistol and the familiar hum of convenience cookery. Perhaps I should have taken out the bullets. With a whirr the machine rotated its deadly dish, animated but unaware of the potential implications of nuking this 9mm entree.

After fifteen seconds I retreated to the hallway, poking my head around the door just enough to see what would happen. I giggled under my breath as the adrenalin began to trickle into my system.

Thirty seconds and the sparks were flying inside the viewing window.

Forty seconds and Paul, my Irish Wolfhound, sprinted down the hall, into the kitchen and skidded to a halt on the polished floor looking at me and panting heavily. I leaped forward to grab him but, all of a sudden: bang, bang, shoot, shoot.

Paul was indeed dead.

]]>

ask if they are typically a cash buyer or will need time to arrange financing for the project.

Foreclosure Auction Sales - A great opportunity to meet investors is at foreclosure auctions. Most of these investors are cash buyers who prefer not to do the legwork of sourcing deals. To successfully flip real estate contracts make sure you visit these auctions regularly.

Come prepared with business cards in hand; introduce yourself prior to or after the auction (not during as investors may be annoyed by the distraction).

Let them know your business is locating and accurately evaluating properties that have profit potential for rehab investors.

Ask if they would like to be contacted when you have located properties that fit their location and price parameters.

Summary

Finding buyers for your contracts is critical to your success flipping real estate contracts.
Starting with these two sourcing methods above should get you started building your network of viable investors.

Having a buyer ready for your contract is just as critical as finding that great property. It may seem backwards but remember, time is the enemy when trying to close real estate deals

Find out what it takes to be successful flipping real estate contracts and how you can gain credibility with your investor network.

Article Directory: http://www.articlecube.com

Leslie Collins has executed hundreds of pre-foreclosure deals in the last 5 years - which actually helped distressed homeowners as well as generating thousands of dollars in profits. Interested in learning how to flip real estate contracts for profit? - Visit: < href="http://www.ez-mortgage-calculator.net/find-and-assign.asp">Find and Assign - beginners guide to real estate profits.


We strive to provide only quality articles, so if there is a specific topic related to back that you would like us to cover, please contact us at any time.

And again, thank you to those contributing daily to our it s all coming back to me now website.

Lisp in Ruby
<p style="padding-left:3em;"><em>I stumbled across <a href="http://bc.tech.coop/blog/080101.html">this</a> and it got me thinking &#8230;</em></p> <h3>Update</h3> <p style="padding-left:3em;"><em>I&#8217;ve updated the Textile formatter on the site and the code for this entry is now displaying correctly. The previous version was swalling the == operators in the code.</em></p> <h2>Lisp 1.5 Programmer&#8217;s Manual</h2> <p>I stumbled across <a href="http://bc.tech.coop/blog/080101.html">this</a> in Bill Clementson&#8217;s blog and remembered using the Lisp 1.5 Prgrammers manual from the college years. I have strong memories of pouring over that particular page in the manual and attempting to understand all the nuances.</p> <p>If you&#8217;ve never read the Lisp 1.5 Programamers Manual, page 13 is the guts of a Lisp Interpreter, the &#8220;eval&#8221; and &#8220;apply&#8221; functions. It is written in Lisp, although the notation used is a bit funky. The entire interpreter (minus two utility functions) is presented on a single page of the book. Talk about a concise language definition!</p> <h2>In Ruby?</h2> <p>I had often thought about implementing a Lisp interpreter, but back in the &#8220;old days&#8221;, the thought of implementing garbage collection and the whole runtime thing was a bit daunting. This was in the day before C, so my implementation language would have been assembler &#8230; yech.</p> <p>But as I was reviewing the page, I realized that with today&#8217;s modern languages, I could problably just convert the funky M-Expressions used on page 13 directly into code. So &#8230; why not?</p> <h2>The Code</h2> <p>Here is the complete Ruby source code for the Lisp interpreter from page 13 of the Lisp Programmers manual:</p> <pre> # Kernel Extensions to support Lisp class Object def lisp_string to_s end end class NilClass def lisp_string "nil" end end class Array # Convert an Array into an S-expression (i.e. linked list). # Subarrays are converted as well. def sexp result = nil reverse.each do |item| item = item.sexp if item.respond_to?(:sexp) result = cons(item, result) end result end end # The Basic Lisp Cons cell data structures. Cons cells consist of a # head and a tail. class Cons attr_reader :head, :tail def initialize(head, tail) @head, @tail = head, tail end def ==(other) return false unless other.class == Cons return true if self.object_id == other.object_id return car(self) == car(other) &#38;&#38; cdr(self) == cdr(other) end # Convert the lisp expression to a string. def lisp_string e = self result = "(" while e if e.class != Cons result &lt;&lt; ". " &lt;&lt; e.lisp_string e = nil else result &lt;&lt; car(e).lisp_string e = cdr(e) result &lt;&lt; " " if e end end result &lt;&lt; ")" result end end # Lisp Primitive Functions. # It is an atom if it is not a cons cell. def atom?(a) a.class != Cons end # Get the head of a list. def car(e) e.head end # Get the tail of a list. def cdr(e) e.tail end # Construct a new list from a head and a tail. def cons(h,t) Cons.new(h,t) end # Here is the guts of the Lisp interpreter. Apply and eval work # together to interpret the S-expression. These definitions are taken # directly from page 13 of the Lisp 1.5 Programmer's Manual. def apply(fn, x, a) if atom?(fn) case fn when :car then caar(x) when :cdr then cdar(x) when :cons then cons(car(x), cadr(x)) when :atom then atom?(car(x)) when :eq then car(x) == cadr(x) else apply(eval(fn,a), x, a) end elsif car(fn) == :lambda eval(caddr(fn), pairlis(cadr(fn), x, a)) elsif car(fn) == :label apply(caddr(fn), x, cons(cons(cadr(fn), caddr(fn)), a)) end end def eval(e,a) if atom?(e) cdr(assoc(e,a)) elsif atom?(car(e)) if car(e) == :quote cadr(e) elsif car(e) == :cond evcon(cdr(e),a) else apply(car(e), evlis(cdr(e), a), a) end else apply(car(e), evlis(cdr(e), a), a) end end # And now some utility functions used by apply and eval. These are # also given in the Lisp 1.5 Programmer's Manual. def evcon(c,a) if eval(caar(c), a) eval(cadar(c), a) else evcon(cdr(c), a) end end def evlis(m, a) if m.nil? nil else cons(eval(car(m),a), evlis(cdr(m), a)) end end def assoc(a, e) if e.nil? fail "#{a.inspect} not bound" elsif a == caar(e) car(e) else assoc(a, cdr(e)) end end def pairlis(vars, vals, a) while vars &#38;&#38; vals a = cons(cons(car(vars), car(vals)), a) vars = cdr(vars) vals = cdr(vals) end a end # Handy lisp utility functions built on car and cdr. def caar(e) car(car(e)) end def cadr(e) car(cdr(e)) end def caddr(e) car(cdr(cdr(e))) end def cdar(e) cdr(car(e)) end def cadar(e) car(cdr(car(e))) end </pre> <h2>An Example</h2> <p>And to prove it, here&#8217;s an example program using Lisp. I didn&#8217;t bother to write a Lisp parser, so I need to express the lists in standard Ruby Array notation (which is converted to a linked list via the &#8220;sexp&#8221; method).</p> <p>Here&#8217;s the ruby program using the lisp interpreter. The Lisp system is very primitive. The only way to define the function needed is to put them in the environment structure, which is simply an association list of keys and values.</p> <pre> require 'lisp' # Create an environment where the reverse, rev_shift and null # functions are bound to an appropriate identifier. env = [ cons(:rev_shift, [:lambda, [:list, :result], [:cond, [[:null, :list], :result], [:t, [:rev_shift, [:cdr, :list], [:cons, [:car, :list], :result]]]]].sexp), cons(:reverse, [:lambda, [:list], [:rev_shift, :list, nil]].sexp), cons(:null, [:lambda, [:e], [:eq, :e, nil]].sexp), cons(:t, true), cons(nil, nil) ].sexp # Evaluate an S-Expression and print the result exp = [:reverse, [:quote, [:a, :b, :c, :d, :e]]].sexp puts "EVAL: #{exp.lisp_string}" puts " =&gt; #{eval(exp,env).lisp_string}" </pre> <p>The program will print:</p> <pre><code>$ ruby reverse.rb EVAL: (reverse (quote (a b c d e))) =&gt; (e d c b a)</code></pre> <p>All I need to do is write a Lisp parser and a <span class="caps">REPL</span>, and I&#8217;m in business!</p> <h2>The Example in Standard Lisp Notation</h2> <p>If you found the Ruby-ized Lisp code hard to read, here is the reverse funtions written in a more Lisp-like manner.</p> <pre> (defun reverse (list) (rev-shift list nil)) (defun rev-shift (list result) (cond ((null list) result) (t (rev-shift (cdr list) (cons (car list) result))) )) </pre>
The Arc Challenge
<p style="padding-left:3em;"><em>Paul Graham issues the Arc Challenge &#8230; who could resist?</em></p> <h2>Paul Graham&#8217;s Arc Challenge</h2> <p>You can read about the Arc Challenge here: <a href="http://www.paulgraham.com/arcchallenge.html">The Arc Challenge</a>. Go ahead a read it now, but I will summarize the challenge.</p> <p><strong>Write a web program such that:</strong></p> <ul> <li>The first page of the program displays nothing but a text box and a submit button. You enter some arbitrary text and press the submit button, which takes you to &#8230;</li> </ul> <ul> <li>The second page is nothing but a single link labeled &#8220;click here&#8221;. The <span class="caps">URL</span> linked to must not contain the text entered in the first step (i.e. you are not supposed to pass the text as a parameter on the link). Clicking the link takes you to &#8230;</li> </ul> <ul> <li>The third page which contains &#8220;You said: <span class="caps">XXX</span>&#8221; (where <span class="caps">XXX</span> is the text you entered in the first step).</li> </ul> <p>Here&#8217;s a screen cast demoing my solution to the Arc Challenge. (We will show the code shortly).</p> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="466" height="281"> <param name="movie" value="http://content.screencast.com/bootstrap.swf"></param> <param name="quality" value="high"></param> <param name="bgcolor" value="#FFFFFF"></param> <param name="flashVars" value="thumb=http://content.screencast.com/media/762eebca-fa50-49f8-9b88-dc7652bd3c9a_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_Thumbnail.gif&#38;content=http://content.screencast.com/media/499ec89e-b124-4dcb-bcd0-e74f6fac495f_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_00000084.swf&#38;width=466&#38;height=281"></param> <param name="allowFullScreen" value="true"></param> <param name="scale" value="showall"></param> <param name="allowScriptAccess" value="always"></param> <embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="466" height="281" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/762eebca-fa50-49f8-9b88-dc7652bd3c9a_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_Thumbnail.gif&#38;content=http://content.screencast.com/media/499ec89e-b124-4dcb-bcd0-e74f6fac495f_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_00000084.swf&#38;width=466&#38;height=281" allowFullScreen="true" scale="showall"></embed> </object> <h2>Paul&#8217;s Solution</h2> <p>Paul has been working on designing Arc, his ideal programming language for the future. Given Paul&#8217;s language preferences, it is no surprise that Arc is very Lisp-like. Here is Paul&#8217;s solution written in Arc:</p> <pre class="testcode"> (defop said req (aform [w/link (pr "you said: " (arg _ "foo")) (pr "click here")] (input "foo") (submit))) </pre> <p>Paul points out that the solution is very short and elegant, only 23 nodes in the codetree. I&#8217;m sure I don&#8217;t quite understand exactly what it is doing (I&#8217;d love to see a step by step explanation of the code). He wonders what it would look like in other languages.</p> <p>Several people have responded with solutions in their own languages. I&#8217;ve seen a <a href="http://www.lukas-renggli.ch/blog/take-the-arc-challenge?_s=BXjPNOJFnBmoYxtA&#38;_k=lERhwwWC">Smalltalk Solution</a> as well as a <a href="http://arc-challenge.heroku.com/">Ruby solution</a> (which pretty closely mimics the Arc code from Paul) on the <a href="http://arclanguage.org/item?id=722">Arc Language Forum</a> page that was setup for responses.</p> <h2>Continuation Web Servers</h2> <p>The Arc challenge is a perfect candidate for a continuation based server solution. And I recalled that Chad Fowler and I had written a demo continuation based server for the <a href="http://onestepback.org/articles/callcc/">Continuations Demystified</a> talk we did at RubyConf 2005. (Look for the &#8220;Poor Man&#8217;s Seaside Demo in that presentation.) I wondered how easy it be to code up an Arc challenge solution using that code base.</p> <p>The key to a continuation based server is that it allows the programmer to code in a linear fashion. All the request/response nature of web interaction is completely hidden from you as a programmer.</p> <p>For example, let&#8217;s pretend we wanted to solve the Arc challenge using a terminal and command line rather than a web based solution. How would you write it? Probably something like this:</p> <pre class="rubycode"> text = gets puts "click here" gets puts "You said: #{text}" </pre> <p>Simple, linear programming. (OK, printing &#8220;click here&#8221; is silly in a text program, but you get the idea). You ask a question and read a response. You pause for a click. You then tell the user what the result is.</p> <p>Ask. Pause. Tell.</p> <p>Those are our basic abstract operations for this problem. Lets rewrite our text based solution using these abstractions. We&#8217;ll put this in a file called &#8220;arc_challenge.rb&#8221;.</p> <pre class="rubycode"> Conversation.interact do |io| text = io.ask io.pause("click here") io.tell("You said: #{text}") end </pre> <p>I&#8217;ve introduced three operations (methods) that are provided by an I/O object (let&#8217;s ignore the interact line for now). &#8220;ask&#8221; will ask the user for input, returning the string. &#8220;pause&#8221; will pause until the user indicates he/she is ready to continue (e.g. pressing return in our command line version). &#8220;tell&#8221; sends the given string to the user.</p> <p>So, what does &#8220;Conversation.interact&#8221; do? It creates the environment where the user have a conversation with the program. The interation is controlled through our ask/pause/tell functions provided by the I/O object passed to the interact block.</p> <p>Here is an implementation of a text based conversation.</p> <pre class="rubycode"> class TextBased def interact yield(self) end def ask(prompt=nil) print prompt, " " if prompt gets.chomp end def pause(prompt="") print prompt, " " if prompt gets end def tell(message) puts message end end Conversation = TextBased.new </pre> <p>To run the text based conversation, just require the text. Here&#8217;s a demo:</p> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="465" height="238"> <param name="movie" value="http://content.screencast.com/bootstrap.swf"></param> <param name="quality" value="high"></param> <param name="bgcolor" value="#FFFFFF"></param> <param name="flashVars" value="thumb=http://content.screencast.com/media/1ae5f9ce-5bc5-4360-8cbc-83b165a434ab_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_Thumbnail.gif&#38;content=http://content.screencast.com/media/90dd373a-0352-4710-acb1-6b18620a5609_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_00000080.swf&#38;width=465&#38;height=238"></param> <param name="allowFullScreen" value="true"></param> <param name="scale" value="showall"></param> <param name="allowScriptAccess" value="always"></param> <embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="465" height="238" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/1ae5f9ce-5bc5-4360-8cbc-83b165a434ab_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_Thumbnail.gif&#38;content=http://content.screencast.com/media/90dd373a-0352-4710-acb1-6b18620a5609_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_00000080.swf&#38;width=465&#38;height=238" allowFullScreen="true" scale="showall"></embed> </object> <h2>Arc on the Web</h2> <p>Well, anybody can solve the challenge in text mode. How much work do we have to do to get it on the web.</p> <p>The answer: Zero!</p> <p>The code Chad and I wrote for <a href="http://onestepback.org/articles/callcc/">Continuations Demystified</a> includes a web-based version of the conversation object that is ready to go. All we have to do is plug it in and run it. No changes are required to our basic Arc challenge solution.</p> <p>Again, a screen demo:</p> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="538" height="352"> <param name="movie" value="http://content.screencast.com/bootstrap.swf"></param> <param name="quality" value="high"></param> <param name="bgcolor" value="#FFFFFF"></param> <param name="flashVars" value="thumb=http://content.screencast.com/media/a8773d13-5fe0-46f2-adcf-8ae4830c6e53_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_Thumbnail.gif&#38;content=http://content.screencast.com/media/2918dffc-1f80-401b-8063-d8c8bb908016_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_00000082.swf&#38;width=538&#38;height=352"></param> <param name="allowFullScreen" value="true"></param> <param name="scale" value="showall"></param> <param name="allowScriptAccess" value="always"></param> <embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="538" height="352" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/a8773d13-5fe0-46f2-adcf-8ae4830c6e53_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_Thumbnail.gif&#38;content=http://content.screencast.com/media/2918dffc-1f80-401b-8063-d8c8bb908016_e67edb68-7ed6-4b26-9b5e-cd2fd2207a40_static_0_0_00000082.swf&#38;width=538&#38;height=352" allowFullScreen="true" scale="showall"></embed> </object> <p>Yes, we know that although we now have our Arc Challenge on the web, we haven&#8217;t quite conformed to the exact requirements of the challenge. We will handle that next.</p> <h2>The Final Arc Solution</h2> <p>The problem is that the current Web based conversation object makes all kinds of assumptions that are not appropriate for the final Arc solution.</p> <p>In particular, we need to change:</p> <ul> <li>Get rid the head line, restart link and other extraneous <span class="caps">HTML</span> elements.</li> </ul> <ul> <li>Don&#8217;t keep a running log of the conversation. When you move to a new page, you start from scratch.</li> </ul> <ul> <li>The &#8220;click here&#8221; should be a real link, not just a text box where you can press enter.</li> </ul> <p>To get to here, we will have to make some modifications to the conversation web library. It turns out the changes are pretty straight forward. The whole interaction framework is controlled by the Conversation object that implements ask/pause/tell methods. You can see the changes made for the Arc challenge in the &#8220;noecho_web_based.rb&#8221; file (see the end of this post for the availability of the source code).</p> <h2>The Final Conversation Based Solution</h2> <p>In cased you missed it, here is the Arc Challenge Solution:</p> <pre class="rubycode"> Conversation.interact do |io| text = io.ask io.pause("click here") io.tell("You said: #{text}") end </pre> <p>Yep, it&#8217;s the exact same file we used for the text based solution. I don&#8217;t know if it is as elegant as Paul&#8217;s version, but I certainly find it easy to read and understand. (Rerun the <a href="http://www.screencast.com/t/mFoZAA7N">very first screen cast</a> in this posting if you want to see it in action again).</p> <p>If you want to look at the code, there is a <a href="http://onestepback.org/download/conversations.tgz">tarball</a> available that contains all the continuation server demo code from <a href="http://onestepback.org/articles/callcc/">Continuations Demystified</a> talk, as well as the two new files I added for the Arc challenge. &#8220;arc_challenge.rb&#8221; is the actually solution and &#8220;noecho_web_based.rb&#8221; is the conversation library that renders the solution in the style set forth by the challenge.</p> <p>Enjoy.</p>
Erlang-like Method Definition in FlexMock
<p style="padding-left:3em;"><em>Some fun with Erlang and FlexMock.</em></p> <h2>Erlang Function Definitions</h2> <p>Erlang defines functions by listing a set of possible argument lists and the body of the function to be executed for each argument list. For example, the factorial function might be defined in Erlang as:</p> <pre> factorial(0) -&gt; 1; factorial(N) -&gt; N * fac(N-1). </pre> <p>If factorial is called with a 0 (zero) for an argument, the first argument list will be chosen and the value of the factorial function will be 1. Otherwise, the value returned will be calculated by a recursive call to factorial.</p> <h2>FlexMock and Erlang</h2> <p>While playing around with FlexMock the other day, I realized that it does parameter matching, much like Erlang, when deciding what mock method to call. So I started wondering if you could write Erlang-like function definitions in FlexMock.</p> <p>Here&#8217;s the result.</p> <pre> mock = flexmock('fact') mock.should_receive(:factorial).with(0).and_return(1) mock.should_receive(:factorial).with(Integer). and_return { |n| n * mock.factorial(n-1) } </pre> <p>Ok, that was fun. But let&#8217;s not start building entire systems using nothing but FlexMock.</p>
FlexMock 0.6.4 Release
<p style="padding-left:3em;"><em>New Release of FlexMock</em></p> <h2>FlexMock 0.6.4 Release</h2> <p>Just wanted to drop a quick note that a new version of FlexMock is now available.</p> <p>There are two nice enhancements and a minor bug fix in this version.</p> The first enhancement is for mocking ActiveRecord objects. The folks at EdgeCase use a mockmodel() method for the RSpec mock that returns a mock that has some common ActiveRecord methods mocked (stubbed) with some reasonable values. This make is a bit more convenient when mocking Rails models. FlexMock now supports this natively, just say <code>flexmock(:model, YourRailsModel)</code> to create a mock object that mimics a YourRailsModel object. <p>The second enhancement is in regard to the <a href="http://onestepback.org/index.cgi/Tech/Ruby/FlexMockReturns.red">What Should flexmock(real_obj) Return?</a> question I blogged about last May. I asked the question: What should flexmock(real_obj) return, the real object or the mock object? Someone had suggested returning the real object when flexmock() is given a block. There was some positive response to that, so that was included in the FlexMock release.</p> <p>But after several months of using it, I found it difficult to remember which version of flexmock() returned what. At one point I found myself caling flexmock() with an empty block, just to get the real object back. That was madness.</p> <p>So starting with release 0.6.4, flexmock will always return the real object. This is the best of both worlds, but it comes with a small price. Real objects partially mocked by FlexMode will now be enhanced with some extra methods, just enough methods so that addition mock behavior can be added to it. For example, <code>should_receive</code> is added to the partially mocked real object. This pollutes the method namespace for an object, but the result is much simplier for the programmer to use. If you <strong>really</strong> want to avoid method namespace pollution, there is a :safe mode offered. Read the docs for all the gory details.</p> <h2>By The Way, If You Grabbed Version 0.6.3 &#8230;</h2> <p>If you are one of the handful of people that downloaded verion 0.6.3 yesterday, then go ahead and grab 0.6.4. The only difference is in the <span class="caps">API</span> for mocking ActiveRecord models. After using it for a bit, I realized that the <span class="caps">API</span> could be improved, hence version 0.6.4. Sorry about that.</p>
Using FlexMock to Test Computational Fluid Dynamics Code
<p style="padding-left:3em;"><em>This is a fun example of using FlexMock</em></p> <h2>Andrew Sweeney Asks:</h2> <p>Andrew Sweeney emailed me with the following question:</p> <p style="padding-left:3em;"><em>I am currently working on a ruby project in which I think flexmock would be a good fit for unit testing. I have read the documentation and gone over the examples however fail to wrap my head around how to apply flexmock to my own app. I was hoping that you could give me some guidence and get me started or point me in the right direction. </em></p> <p>You can find his original source code <a href="http://wikis.onestepback.org/OSB/page/show/OriginalF3DQueueCode">here</a>.</p> <p>I thought his problem was interesting enough to write it up as an example of using FlexMock. Andrew and his mentor, <a href="http://www.workingwithrails.com/person/6007-bil-kleb">Bil Kleb</a> gave permission for me to reproduce the code in my blog. The F3DQueue class is part of a <a href="http://fun3d.larc.nasa.gov">Computational Fluid Dynamics</a> project (<a href="http://fun3d.larc.nasa.gov">http://fun3d.larc.nasa.gov</a>) at <span class="caps">NASA</span>.</p> <h2>Quick Code Review</h2> <p>The F3DQueue class is small, so there&#8217;s not a lot of code we need to wade through. We see it uses a second class named AutoF3D, but the only clues we have to what AutoF3D might do are the four method calls on the &#8220;job&#8221; object in the <ins>run</ins> method.</p> <p>It looks like the main interface to the queue object is the <ins>add_to_queue</ins> method. There is a thread started that pulls jobs (i.e. AutoF3D objects) from the queue and processes them in turn. There is some server delays built into the system. I presume that Computational Fluid Dynamics is, ummm, computationally complex and the delays are just there to make sure the workload does eat up <em>all</em> the <span class="caps">CPU</span> time on the server.</p> <h2>Starting Testing</h2> <p>When writing new code, I always like to approach it in a Test-First manner. Because I won&#8217;t write solution code without a test that forces me to write it, I have a high confidence that the code is well covered with tests.</p> <p>Unfortunately, dealing with legacy code means that the code is already written and the test-first approach won&#8217;t work. That&#8217;s ok, I have a little trick that I use. Just comment out the bodies of all the methods in the class you are about to test. Then write the tests that force you to <em>uncomment</em> the code. Just uncomment only enought to get the tests to pass, don&#8217;t uncomment anything you don&#8217;t have to. You have enough tests when all the code has been uncommented. The technique is <em>almost</em> as good as doing real test-first.</p> <h2>The Commented Out Version</h2> <p><a href="http://wikis.onestepback.org/OSB/page/show/CommentedF3DQueueCode">Here</a> is the code base as I started the test.</p> <h2>An Existence Test</h2> <p>I almost always start out with an existence test. Existence tests basically prove the proper files are included and the object can be created. Normally I delete these after a few tests have been written. But I left this one in for an example.</p> <pre class="testcode"> def test_initial_conditions q = F3DQueue.new assert_not_nil q end </pre> <p>Nothing really exciting here. Let&#8217;s move on &#8230;</p> <h2>Proving <span class="caps">FIFO</span> Queue Order</h2> <p>The first thing I want to prove is that items put into the queue are removed in <span class="caps">FIFO</span> order. Since <ins>add_to_queue</ins> creates a AutoF3D object, I mock out the <ins>new</ins> method on the class object and tell FlexMock to expect <ins>new</ins> to be called twice. Once with :a, :b, and :c as parameters, then again with :x, :y, :z paramters. Each invocation of <ins>new</ins> will return a different symbol (:first and :second) so we can easily test the items are pulled off the queue in <span class="caps">FIFO</span> order.</p> <p>Notice that I pass in simple symbols for the arguments to <ins>add_to_queue</ins>. Our code doesn&#8217;t interpret the values of the arguments, they are merely passed directly to the AutoF3D constructor. All we do is verify that the AutoF3D (mocked) constructor does indeed receive the arguments we pass in.</p> <p>Here&#8217;s the test:</p> <pre class="testcode"> def test_adding_to_queue_is_removed_in_fifo_order flexmock(AutoF3D).should_receive(:new).once.with(:a, :b, :c).and_return(:first).ordered flexmock(AutoF3D).should_receive(:new).once.with(:x, :y, :z).and_return(:second).ordered q = F3DQueue.new q.add_to_queue(:a, :b, :c) q.add_to_queue(:x, :y, :z) assert_equal :first, q.remove_from_queue assert_equal :second, q.remove_from_queue end </pre> <p>This test caused three changes. First, the <ins>add_to_queue</ins> method needed lines uncommented:</p> <pre class="rubycode"> def add_to_queue(modelLoc, params, gridFile) autoF3D = AutoF3D.new(modelLoc, params, gridFile) @queue.push autoF3D # $log.info 'Request added to queue' end </pre> <p>(Notice I didn&#8217;t uncomment the log. The logger is not needed to pass the test, and doesn&#8217;t contribute to the actual functionality of the method. I will not be testing the logger in the for the purposes of this article.)</p> <p>Also the <ins>remove_from_queue</ins> needed its body uncommented:</p> <pre class="rubycode"> def remove_from_queue @queue.pop end </pre> <p>And finally, the initializer code needed to create the queue array:</p> <pre class="rubycode"> def initialize @queue = [] # Thread.new{ process } end </pre> <p>Notice that the <ins>Thread.new</ins> line is left commented. We will deal with that in a bit.</p> <p>So now we run the test:</p> <pre class="shell"> $ ruby test_f3dqueue.rb Started F. Finished in 0.010184 seconds. 1) Failure: test_adding_to_queue_is_removed_in_fifo_order(TestF3DQueue) [test_f3dqueue.rb:23]: &lt;:first&gt; expected but was &lt;:second&gt;. 2 tests, 2 assertions, 1 failures, 0 errors </pre> <p>Oops! This test uncovered the first bug. The code as written has stack behavior (i.e. <span class="caps">LIFO</span>). The naming seems to indicate that we want <span class="caps">FIFO</span>.</p> <p>No problem. That&#8217;s an easy fix.</p> <pre class="rubycode"> def remove_from_queue @queue.shift end </pre> <p>Now the tests run clean:</p> <pre class="shell"> $ ruby test_f3dqueue.rb Started .. Finished in 0.001925 seconds. 2 tests, 3 assertions, 0 failures, 0 errors </pre> <h2>Proving that Running a Job Works</h2> <p>Now when I run a job, I need to show that the proper four methods are called once each and in the proper order. This is very straight forward using FlexMock.</p> <pre class="testcode"> def test_running_a_job_will_call_the_right_stuff_in_the_right_order job = flexmock("job") job.should_receive(:generate_geometry_and_grid).once.ordered job.should_receive(:partition_grid_and_initialize_flow).once.ordered job.should_receive(:run_flow_solver).once.ordered job.should_receive(:post_process_solution).once.ordered q = F3DQueue.new q.run(job) end </pre> <p>Uncommenting the body of <ins>run</ins> is all that is needed here:</p> <pre class="rubycode"> def run( job ) # $log.info 'Request being processed' job.generate_geometry_and_grid # $log.info 'Created Geometry' job.partition_grid_and_initialize_flow # $log.info 'Partitioned Grid' job.run_flow_solver # $log.info 'Flow Solver Completed' job.post_process_solution # $log.info 'Post process Completed' # $log.info 'Request completed' end </pre> <p>Test are now showing:</p> <pre class="shell"> 3 tests, 3 assertions, 0 failures, 0 errors </pre> <h2>Processing an Empty Queue</h2> <p>Ok, now it gets interesting. I want to show that attempting to process a job when the queue is empty will cause the process to sleep for the check queue interval.</p> <p>This is one spot where I changed the code to make it easier to test. It is difficult to test endless loops in unit tests (it tends to make the tests run a <em>bit</em> long), so I broke out the logic for a single pass through the loop into a method called <ins>process_one_job</ins>. We can then test this logic without dealing with the looping at the same time.</p> <p>Note: It is possible to test endless loops and an example will be given below. But it is slightly tricky and this allows us to concentrate on proving the logic.</p> <p>If there are no jobs to be processed, then all the code should do is sleep for a particular amount of time. We will locally mock out the <ins>sleep</ins> method on the queue object and insist that it will be called exactly once with the expected interval.</p> <pre class="testcode"> def test_processing_with_no_jobs_will_sleep_the_check_interval q = F3DQueue.new flexmock(q).should_receive(:sleep).once.with(F3DQueue::CHECK_QUEUE_INTERVAL) q.process_one_job end </pre> <p>Here is <ins>process_one_job</ins> with just two lines uncommented so that the test will pass.</p> <pre class="rubycode"> def process_one_job # execution_attempts = 0 job = remove_from_queue # begin # if job # run job # execution_attempts = 0 # sleep SERVER_RECOVERY_TIME # else sleep CHECK_QUEUE_INTERVAL # end # rescue # $log.warn 'An error occurred during execution' # $log.warn $ERROR_INFO # $log.debug $ERROR_POSITION # sleep SERVER_RECOVERY_TIME # if execution_attempts &gt; MAX_EXECUTION_ATTEMPTS # $log.error 'Too many failed execution_attempts: aborting' # raise # else # execution_attempts += 1 # retry # end # end end </pre> <p>There&#8217;s a lot of code still left commented in that method. Now we need a test to force us to uncomment more code.</p> <h2>Handling a Single Job</h2> <p>Ok, now what happens when a single job is in the queue. We will assume the happy path (i.e. no exceptions) so we expect <ins>run</ins> to be called with the queued object, and then a sleep with the recovery interval.</p> <p>A couple of things to note. First, we mock out AutoF3D again so that when we request something added to the queue, we control what kind of object is returned. We <em>could</em> return a mock object and then mock out the four methods that <ins>run</ins> will be calling.</p> <p>However, I chose a slightly different approach. AutoF3D is mocked so that it returns a simple symbol. Then I mock out the <ins>run</ins> method to do nothing (but it is expected to be called once). This is slightly controversial because I am actually mocking a method on the object under test. But the run method is fairly simple, and we know that <ins>run</ins> works because of our previous test, so in the end we get clearer and simpler code.</p> <p>Also note that the <ins>run</ins> and <ins>sleep</ins> methods mocks are ordered. This means <ins>run</ins> will be called first, then <ins>sleep</ins>.</p> <pre class="testcode"> def test_processing_with_a_single_job_will_run_the_job_and_pause_for_recovery q = F3DQueue.new flexmock(AutoF3D).should_receive(:new).once.and_return(:job) flexmock(q).should_receive(:run).once.with(:job).ordered flexmock(q).should_receive(:sleep).once.with(F3DQueue::SERVER_RECOVERY_TIME).ordered q.add_to_queue(:a, :b, :c) q.process_one_job end </pre> <p>Now we get to uncomment even more lines in <ins>process_one_job</ins>.</p> <pre class="rubycode"> def process_one_job # execution_attempts = 0 job = remove_from_queue # begin if job run job # execution_attempts = 0 sleep SERVER_RECOVERY_TIME else sleep CHECK_QUEUE_INTERVAL end # rescue # $log.warn 'An error occurred during execution' # $log.warn $ERROR_INFO # $log.debug $ERROR_POSITION # sleep SERVER_RECOVERY_TIME # if execution_attempts &gt; MAX_EXECUTION_ATTEMPTS # $log.error 'Too many failed execution_attempts: aborting' # raise # else # execution_attempts += 1 # retry # end # end end </pre> <p>That just leaves the error handling code to be uncommented. So that will be next.</p> <h2> Handling a Job With Errors</h2> <p>Now we want to test the case where processing a job will return an exception. This test exercise the exception recovery code in the original code base. The technique is similar to the last test, but this time we specify two mock calls for <ins>run</ins>. The first time <ins>run</ins> will return an exception. The second time it is called, it will complete normally.</p> <p>Notice that we have ordered <ins>run</ins> and <ins>sleep</ins> so that they interleave execution with each other.</p> <pre class="testcode"> def test_if_a_job_fails_retry_after_recovery_time q = F3DQueue.new flexmock(AutoF3D).should_receive(:new).once.and_return(:job) flexmock(q).should_receive(:run).once.with(:job).and_raise(RuntimeError).ordered flexmock(q).should_receive(:sleep).once.with(F3DQueue::SERVER_RECOVERY_TIME).ordered flexmock(q).should_receive(:run).once.with(:job).ordered flexmock(q).should_receive(:sleep).once.with(F3DQueue::SERVER_RECOVERY_TIME).ordered q.add_to_queue(:a, :b, :c) q.process_one_job end </pre> <p>I was showing this test code to one of my coworkers and they were a little surprised that the second expectation on <ins>run</ins> didn&#8217;t override the first expectation. FlexMock is explicitly designed to allow you to stack expectations like this. When searching for an expectation during mocking, FlexMock will use the first one matching one if finds. When an expectation has been used its designated number of times (in the above test, the <ins>once</ins> method designates that the expectation should only be used once), FlexMock will begin to use matching expectations that are defined later.</p> <p>The upshot is this is that it is easy to define mock behavior for multiple calls to the same method.</p> <p>Here&#8217;s the latest <ins>process_one_job</ins> method with some more lines uncommented. We are getting close to the end with this one.</p> <pre class="rubycode"> def process_one_job # execution_attempts = 0 job = remove_from_queue begin if job run job # execution_attempts = 0 sleep SERVER_RECOVERY_TIME else sleep CHECK_QUEUE_INTERVAL end rescue # $log.warn 'An error occurred during execution' # $log.warn $ERROR_INFO # $log.debug $ERROR_POSITION sleep SERVER_RECOVERY_TIME # if execution_attempts &gt; MAX_EXECUTION_ATTEMPTS # $log.error 'Too many failed execution_attempts: aborting' # raise # else # execution_attempts += 1 retry # end end end </pre> <h2>Processing Jobs that Continually Fail</h2> <p>Finally w