Latest Publications

Get Column name from MySqlDataReader

Recently someone found my blog by searching google asking how to get the column name from a MySqlDataReader. I doubt they found the answer on my blog, so I figured I’d write about, just in case anyone else needs to know.
(more…)

  • Share/Bookmark

What to write about.

Next Saturday’s story is supposed to be on travesty. The idea is to take 3 characters and make them behave completely opposite than they would normally. My problem is which characters should I write about. There is no way for the reader to know it’s a travesty unless they already know the characters. Unfortunately, at this point I don’t have any characters of my own that the audience would know enough about for the travesty to work.

So I either have to pick some really popular characters, and use them, or ignore the exercise all together. Which is why I’ve been trying to think of popular characters and what their opposites would be. (off topic, am I the only one who doesn’t like when a sentence ends with a word like ‘be’ ? It just feels wrong.) The first thing I thought of was the Simpsons, I know them better than just about anything. But the problem is how to make a travesty, they’ve done just about everything possible. Homer’s been the weakling wuss, a whiny bitch, the macho man, and the hero. It’s hard to think of something that is opposite of all that.

So who else do I know, or at least know enough to write a travesty. There’s always Fry from Futurama. I could do Harry Potter, that would make it easy to pick which three characters to use. Characters from Lost or Heros could also work.

I’m going to think about the Futurama one a bit longer, although it’ll be hard to think of some situation that they haven’t already done. — Or maybe I should do a situation they’ve already done, to further point out the travesty?

  • Share/Bookmark

7. Family

3:00 p.m.

Deb was vacuuming her bedroom when it caught hold of something under the bed. She pulled a red Swisher Sweets box from its vice grip. He lied to me. She took the box into the bathroom and lifted the toilet seat. This is one box he’s not going to smoke. When she opened the box she found letters in unsealed envelops. She put the toilet seat down and sat on it. She opened the first letter.

My Dearest,

It feels like forever since you last held me in your arms. Last night was amazing, out in the tree house, the cool breeze over our naked bodies. My body aches just thinking of your gentle touch.

Forever yours, K.

He’s cheating? No it couldn’t be he doesn’t know anyone named K. Deb sat for a moment naming all the women she knew. Their friends, his secretary, his boss … Kathrin, but It couldn’t be his boss. He was always telling her what a bitch Kathrin was … Oh my god, it is Kathrin! She started crying.  In between wiping her eyes she read several more letters, one going into painful detail.

She pulled out a suit case and started packing.

8:10 p.m.

“Hey your dad’s calling.” Kris held up his phone to show him.

“I don’t answer the phone while I’m driving.” They were waiting to park at the Savage Garden concert.

“Want me to answer?” she asked.

Troy grabbed the phone and turned it off. “No, I don’t care what he has to say, nothing’s going to keep us from this concert now.” He leaned over and started kissing her. They heard snickering from the back of the car. Troy reached back and swung is arm wildly. He hit something hard.

“Ow,” His sister and her best friend came out from under a blanket.

“What are you two doing here?” He yelled.

“Going to the concert, duh.” Megan rolled her eyes at him. Jill flipped her hair.

“You’re grounded, besides, you don’t have tickets.”

“I was planning on just taking your tickets once mom grounded you.” Megan put on fresh lip gloss. “Guess she didn’t find the box in time, oh well. We’ll just get our own tickets.” She smacked her cherry red lips.

Troy reached the parking attendant, paid the fee; he was lead to a spot. He turned off the car and faced Megan. “What box, the cigars?”

Megan handed the lipstick to Jill. “The sex notes from miss tubby here.”

Kris scowled at her.

7:25 a.m.

Phil finished his coffee and double checked his briefcase. Walking to the front door a faint vanilla smell beckoned from Troy’s open book bag. Phil pulled out a red box; it was one of his swisher sweets boxes. “Troy!” He yelled across the house.

Troy came out with his coat in hand. “Yeah yeah I’m ready.”

Phil held out the box. “You stealing my cigars again?”

“What? No way. I didn’t take anything.”

“I found this in your book bag.”

“I swear to god dad, I didn’t take them! I don’t know how they got in my bag.” Troy looked up at his father. “Please believe me. I have to goto this concert tonight.”

“Alright you can still go,” Phil took the box and headed to the master bed room. “But we are going to talk about this later.”

Phil walked in and threw the box of cigars under the bed. His wife Deb was in the shower. Phil knocked once and opened the door. “Hey hunny, I’m leaving.”

She peeked out, water ran down her face. “Ok, love you.”

Phil walked over and gave her a kiss. “Love you too.”

Walking out of his bed room, passing Megan’s room he peeked in “We’re leaving, you need a ride to school?”

7:35 a.m.

“No, Mom’s taking me.” Megan said to her father and shut the door. She brought the phone back to her ear. “You still there? It was just my dad. I know right! I don’t care if I’m grounded, I’m still going.”

She wiped blush on. “I already did. Yeah those letters from little miss piggy.” she straightened out her blouse. “Of course she will, I put it in one of dad’s old cigar boxes.” She stood up to check herself out in the mirror. “Right. right. She’ll be so upset that she won’t even know I’m gone. Alright, see you soon.”

8:00 p.m.

Phil dropped his briefcase by the door. “I’m home.”

No one answered. Phil illuminated the house as he walked though. In the kitchen he noticed his empty coffee cup was still sitting there. “Hello?” he called again. He walked down the hall way, all the bed rooms were dark. He opened the door to his bed room.

“Oh shit.” His eyes darted around the room. Drawers where pulled out, their contents littering the room. The bed was flipped over and Deb’s jewelry boxes were gone.

A car engine started outside. Phil ran to the door just in time to watch someone drive off in his car. He slumped in the doorway. We’ve been robbed?

He ran back inside panicking, “Deb? Megan? Where are you?” He threw open doors and fanatically searched the house. It was empty. He tried calling them. No answer. He called Troy, no answer.

He walked back to the bedroom, turned over the bed and sat down. A letter was stuck in the sheets.

My Dearest,

I want to rub my lips all over your body.

Forever yours, K.

K? He pulled off the sheets, more letters fell to the ground. He read those those, all from K.  He crumpled the letter. “Kevin.”

© Chris Richards 2009
  • Share/Bookmark

SubSonic and ORM

Looking into other ORMs and Linq I came across subsonic. I watched the video and build a quick little sample application with it. I had a slight problem at first because it kept giving me an error with my MySql.Data reference. I upgraded my DLL and played around with it some more, still no luck. I searched around for a bit before I found the answer, if you use their sonic.exe tool, you need to use their MySql.Data.dll as well.

Once that problem was solve, Subsonic was actually very nice to work with. I used work’s database which is a horrid mess (my boss thinks he knows DBA and won’t listen to reason.) So some of the objects sonic.exe built didn’t work correctly, I simply excluded them from the project and everything was fine. My sample code doesn’t do a whole lot but has taught me several things.

Wellness.UserCollection users = new Select().From<Wellness.User>().ExecuteAsCollection<Wellness.UserCollection>();

foreach (Wellness.User user in users)
{
    Response.Write("<p>");
    Response.Write(user.FirstName +" "+ user.MiddleInitial +" "+ user.LastName);
    Response.Write("<br />");
    Response.Write(user.Email);
    Response.Write("</p>");
}

One thing it did was make me question my own ORM project, I thought about abandoning it for SubSonic (or something like it.) But there are several things I don’t like about SubSonic. One is the perl design of giving me tons of different ways to accomplish the same task. personally I find it to be a mess. (Maybe SubSonic just takes some getting used to.) Peeking inside of the generated objects I was disappointed at the amount of code required for a seemingly simple object. My objects can’t do everything that SubSonic’s can, so maybe it’s a necessary evil.

Something I love about it is their use of generics. I like the way it looks and reads.

I think I’m going to continue my ORM development for now (not that I’ve spend a whole lot of time on it.)  I like my design the object to fit you needs and there is one correct way to do things approach.

  • Share/Bookmark

ASP.Net and MVC

I’m not sure how long this has been around, but ASP.Net now supports MVC with a framework. It’s about time! Not having MVC as always been a big disadvantage in my option (That and no real ORM until Linq).

So I’m going to spend some time hopefully in the next few weeks playing around with it and with MySql and Linq.

I found two ways to use MySql with Linq that look promising. One is the DBLinq Project and the other is to use Linq with NHibernate. Both look promising.

(For the Record, Python Rules, and PHP is pretty good for webpages.)

  • Share/Bookmark

31. Intelligence

Donnie growled in the middle of a text. He turned to Rose, who was sitting on the bed behind him. “It froze again.”

She held out her hand and he gave her the phone. Rose gave it a quick look over before popping out the battery. “Just remove the battery and it’ll reset.” She handed back the phone. He went back to texting and fussing with his hair.

“So,” Rose said, “Where are we going?”

He put his comb down and looked at her reflected in the mirror. “Well, I thought we would go to a party. ” He paused and then picked up the comb again. “You keep talking about meeting someone, and there’s a rave down Pier Street.” He avoided her eyes. “You like techno and stuff right?”

“And stuff … right.” Rose rolled her eyes and fiddled with a loose bedpost. “Have any wood glue?”

Donnie walked over to the closet and pulled out a single cheap plastic bracelet from a jewelry box. He walked back over the mirror and put the bracelet on one wrist, took it off and placed it on the other wrist.

Rose followed him with her eyes as he repeated the process of taking out a single bracelet at a time. Just take the damn box over to the mirror.

“If you really want to fix something, you can fix the rattle in my car.” He was still trying on little identical bracelets. “Did you bring something to wear, or do we need to stop at your place?”

“You didn’t tell me where we where going, remember?”

“Do you have fishnets and a skirt?” He hovered over, the two-dozen bracelets on each wrist rattled by her face.

“No.” She rolled her eyes at him. Oh Damn, guess I can’t go to the rave then.

He tossed his hands at her causing the bracelets to shift and clank against one another. He disappeared back into the closet. When he came out he threw a pair of torn black pantyhose, neon green fishnet stockings, a black 7″ skirt, and a large assortment of neon, glow in the dark, accessories.

“Finally coming out of the closet?”

“Ha ha, funny. Try this on. I don’t have any shoes that fit you, but I bet my sister does.”

She held up the skirt with two fingers and an outstretched arm. “I’m not wearing this.”

“You wear a spanky under it retard,” he said as he walked out of the room.

Rose poked through the large assortment of bracelets and necklaces. She found a blue glow in the dark pacifier that made her wonder about the stores that sold such things.

Donnie came back with several different high heel shoes, a black fishnet shirt, and a sparkling red bra.

“I’m defiantly not wearing that.” She crossed her arm.

“Just wear a white tank-top under the fishnet, trust me.”

“I don’t think so.”

He dropped the items down in front of her. “Do you want to meet a guy or not?”

“I prefer guys not tripped out on acid, thank you.”

“I can make you another outfit. There are some really great guys at these things, you should give it a chance before you just close yourself off.”

“Name one.”

“Well,” Donnie walked over to the closet, “me … for one. Look, I don’t know what you want me to do. The rave isn’t important; I’ll rent some movies or something if that’s what you want. You’ve just been so…depressed lately. I thought this might make you smile again.”

Rose held out her arms for a hug, he walked over to the bed and sat down. She grabbed and squeezed his shoulders. “I just…I mean it’s silly really.” She threw herself against the bed and hid her face in a pillow. ” I just don’t know who I am anymore. It’s like I can see this great person lost somewhere inside and I don’t know how to let her out. I work a dead end job and take classes, and for what? I don’t know what I want to do with my life. I can’t even keep a boyfriend.”

Donnie sat in silence staring at the floor.

She turned her head slightly so she could see him. “Everyone else knows what they’re doing. They live life, and I can’t even find mine. I feel like I’m drowning in it all.”

“That’s not true. I don’t know what I’m doing. I go to these raves and take X so I don’t have to think about it. I never told you this, but I really look up to you.”

Rose turned onto her back. “Why?”

“Because you have it together, you’re getting a degree in something you like, you’re so smart and you don’t even know it. You’ve fixed everything I own –”

“That’s easy.”

“See, that’s just want I mean, you can make something out of yourself. In 10 years I’m still going to be living with my parents.”

She pulled him down, “I won’t let that happen.”

“That’s just it, you have to, you just need to take the plunge and forget the consequences.”

She grabbed his head and kissed him.

© Chris Richards 2009
  • Share/Bookmark

jQuery Plugin, $.repeat()

While working on the Knit Project,  I discovered that I needed a way to repeat a string and then insert it into a jQuery/DOM object. So I created this little bit of code to do just that.

//Repeater Plugin
jQuery.fn.repeat = function(times, string) {
    //For each item matched
    this.each(function(){
        var buff = string;
        for(var i=1; i < times; i++){
            buff += string;
        }
        jQuery(this).append(buff);
    });
    return this;
}

The plugin takes two parameters, the number of times to repeat, and the string to repeat. this means that if I want to add a bunch of columns to my table rows, all I have to do is:

//Add the columns
$("table > tr").repeat( width, "<td></td>" );

Now all my table rows will have the correct number of columns.

I used .append instead of replacing the old data just in case I would ever need to keep what is already there. This could easily be changed or even turned into a switch.

Download

If this was what you were looking for, or even if it wasn’t, please leave a comment. I’ve gotten a lot of traffic from this little plugin and I would like to know if people find it useful.

  • Share/Bookmark

32. Friendship

Within a week of meeting her, Judy had started sleeping with Roger. Jeff tried to find ways to keep busy but there wasn’t a whole lot he could do. He found some old porno magazines in the basement, but most of the time he sat around wondering if they were really the last three people on earth.

After a few months of living in the old house, Roger started scouting the area for other survivors. It was his way to keep busy. Judy was always cleaning. With just the three of them and no electricity, the place never really got dirty, but she went though the motions anyway. This particular day Jeff had been sitting around feeling useless for far too long and Judy was making beds in her floral summer dress.

Jeff watched as she bent over the bed, stretching out to pull the sheets tight. He walked up behind her and put his hands on her hips. She jolted upright.

“Oh sorry, I didn’t know you where behind me.” She said.

“It’s ok, I just thought I could help.” His hands reached around pulling her into him. A hand slithered up her chest. She quickly pushed it away.

“Um excuse me.” She tried to move away, he held her tight against his body. “What do you think you’re doing?”

“You.”

“I don’t think so.” She wiggled free and backed away. “Look I know your lonely but I don’t like you like that. I mean, what would Roger say.”

“Fuck him.” He took a few quick steps and pinned her to the window. “Why does Roger always get everything? Our whole lives Roger always gets everything and I’m just left with the scraps. Well tough shit, this time I’m taking what I want.” He forced her hands above her head and started to kiss along her neck.

“He’s your best friend, you can’t do this.”

Jeff slapped her across the face. “I’ll do whatever I god damn please.” He grabbed her by the arm and flung her around onto the bed. He pounced, holding her down with his weight. He lifted up her skirt and unbuttoned his pants.

“Get the fuck off of her.” Rogers’ voice boomed across the small room. They both jumped out of the bed and turned to the door. Roger was pointing his shotgun at Jeff.

“Hey, uh, we were just –”

“Don’t bullshit me Jeff. What the fuck are you doing, huh?  I leave for a few hours and you fuck my girl?” Roger pushed Jeff to the window with the gun. He turned to Judy. “You been cheating on me? There’s only one other man in the entire world, and your sleeping with him too?”

Judy fell on the bed balling. “No, it’s not like that.”

Jeff just held up his hands watching the end of the barrel. Roger pressed it hard against his chest leaving two round bruises.     “Why man? You’ve stolen every girlfriend I’ve ever had. This was it, this was finally the one and you steal her too. Well Fuck you both.” Roger stuck the barrel in his mouth and pulled the trigger.

© Chris Richards 2009
  • Share/Bookmark

GetProperty() SetProperty()

I created the GetProperty() and SetProperty() methods to allow the base object to manage holding the variables needed for the object. I’ve implemented these methods on my old object classes just to test them out in some real world examples. I’ve found two problems, the first is that sometimes I only want to set a new value if the old value changed, so I created isPropertyDifferent() that will return true or false if the property’s value is different from the specified value. This is more useful than making the SetProperty() check it because now I can do extra processing depending on the result.

        ///
        /// Will return true if the value is different
        ///
        protected bool isPropertyDifferent(string name, object value)
        {
            //Check if it exists yet
            if (_properties.ContainsKey(name))
            {
                //Check if it's different
                if (_properties[name] == value)
                {
                    return false;
                }
            }
            //It's different or it doesn't exist.
            return true;
        }

The other issue is that right now GetProperty() only takes a value to use as the default if the Property doesn’t currently exist. But what if I want it to call a function instead? In fact that’s exactly what I want. If tags doesn’t exist, I want you to go fetch them, but I don’t want you to waste time fetching them if the value already exists (which is what It’ll do with the current implementation) so I need to figure out a simple way to use delegates here.

  • Share/Bookmark

6. The Royal We

“I figured, since it’s my birthday I should have a new car.” Cecil walked over to the bench holding a Walmart pharmacy bag. He was one of the few residents that didn’t need a Rollator (wheeled walker) to get around.

“And how old are you?” We asked. The three of us where sitting alone outside of the Golden Years Retirement Village.

“I’ll be 90 years old tomorrow. Figured it was time for a new car. It’s one of those nice ones, with a computer and such.”

“Is it here yet?”

“No not yet, my grandson, Billy is going to bring it over.”

A beautiful ’75 Pontiac Grand Ville pulled into the parking lot. Marilyn struggled to pull out a Rollator. We watched as she made her way over to us.

“Is this town square?” Marilyn flashed Cecil her famous smile that won her Miss America in 1946. We spent many nights looking at her magazine spread, now all these years later she lives in the same building. Luckily she’s still just as pretty as ever not that it mattered much with Cecil always making googly eyes at her.

“Come come, sit next to me, I was just telling the boys all about my new car. I got a new car for my birthday.” Cecil was beaming.

“Is it a convertible? I do love a convertible, wind  blowing in my hair. It’s just so … exciting.” Marilyn closed her eyes and pictured herself young again, driving down the coast line.

“Your hair has never been messy in your life.”

Marilyn giggled like a young school girl. She batted away his hand creeping up on her hair. “You old rascal, your getting me all worked up.”

“That’s the idea, cutie”

A car came rattling up to the sidewalk. The conversation hushed as we waited. A middle age man in a cheep suit got out of the running car. He walked around to the side and opened the door. Elsie got out, the man gave her a quick hug, and sped off.

“What’s the good word?” Cecil asked.

“Had a real nice lunch with my son. He’s a business man you know.”

Cecil smiled, “My boy bought me a new car for my birthday.”

“You old coot, You –”

Marilyn interrupted. “Did you son ask for money again? If he’s so rich then why does we wear a three dollar suit?”

Elsie’s face twisted. “At least my son still visits me. You’re still living in the past, no one even remembers who you are.”

“They’re fighting over you Cecil.” We said.

“Just like in the old days.” Cecil said.

Elsie laughed.

“How dare you, Cecil” Marilyn said, “I was in pictures, I still receive love letters from fans you know.”

“No, I didn’t mean you, I was talking about what the boys said.”

Elsie laughed again. “Been forgetting your medicine again?” We gave her the stink eye as she scuttled inside. She’s just jealous, Cecil’s son is always buying him nice things.

“Don’t worry about her dear, when are you getting the new car?” Marilyn said.

“My son’s bringing it around, it’s really fancy, would you like take a ride with me sometime?”

“Of course Cecil, I’ll ride with you any day.” She started to stand, We were about to go over and help her up, but Cecil caught on and helped her into the Rollator. She took him by the hand and started to walk inside.

“I really should wait for my son.”

“Don’t worry, I’m sure the boys will wait here for him.”

“Really? Will you do that for me? I don’t want to miss him.”

We smiled, “We’ll wait forever.”

Cecil waved goodbye and walked inside. We would keep our promise, just as we’ve kept it for the last six years, it was an easy job for a couple of stone tortoises like us.

© Chris Richards 2009
  • Share/Bookmark