She's Geeky

January 6th, 2009 by comment desi

Just wanted to remind everyone about the upcoming She’s Geeky Event in Mountain View CA Jan 30 – 31st. I already registered and got my flight booked so that I can be there. I hear from people who went last year and to the most recent one that the experience has been really good. So go check them out and get registered if you want to go.

Cheers
Desi

ˆ Back to top

ASP.NET – 'PASSING PARAMETERS' IN BUTTON CLICK-HANDLER

August 10th, 2007 by comment Kris

A recent posting to a technical mailing list I’m on asked how to pass a parameter to a button click-event handler. The programmer wanted to do the equivalent of this:

<asp:button ID="btnSubmit" runat="server" OnClick="Btn_Onclick(PARAM)" />

But, she knew this didn’t work, because the default signature of event handlers in ASP.NET is this:

void myBtn_OnClick(Object sender, EventArgs e)

So, she was stumped on how to pass some sort of argument to the event handler.

Now, there a certainly some kludges that would work, such as having a hidden form field which contains the ‘parameter’ value, and having the event-handler get the value that way. But surely, there’s a better way? Well, yes, of course there is! :)

This better way is to use the “CommandArgument” property on the button control. This property is directly accessable in the event handler. The added bonus is that you can write a single even-handler for all of your button clicks, and use the associated “CommandName” property to know which button fired.

So, now, in your aspx page, your button object will be declared thusly:

<asp:Button ID="test" runat="server" CommandArgument="MyVal" CommandName="ThisBtnClick" OnClick="MyBtnHandler" />

Then, in the OnClick handler, you can cast the sender object to the correct type, and get the values of
CommandName & CommandArgument. (You could make this even more generic and handle the OnClick event for different senders, but we’ll leave that for a later post! :)

void MyBtnHandler(Object sender, EventArgs e)
{
	 Button btn = (Button)sender;
          switch (btn.CommandName)
          {
                case "ThisBtnClick":
                    DoWhatever(btn.CommandArgument.ToString());
                    break;
                case "ThatBtnClick":
                    DoSomethingElse(btn.CommandArgument.ToString());
                    break;
           }
}

You can see that the switch statement uses the CommandName property to determine which button was clicked, and then can use the CommandArgument property passed in by the button click event.

Voila! You’ve “passed a parameter” to a button click-event handler!

[UPDATE] Thanks to Jim for pointing out some confusion in my sample code. I hope that this version is clearer.

ˆ Back to top

Ruby & Rails: Tracks for various skill levels

February 22nd, 2007 by comment Carmelyne Thompson

**List last updated 04/19/07** (This list just keeps growing)

Ruby has generated such great interest and following since the launch of Rails. Mantra: Do get a book of Ruby before diving into Rails.

Now while researching, I found links here and there but they were all varied depending on your skill level. This (post) is an attempt and probably not the first attempt to group links, books and training sessions available by skill level. Only published books are included at the time of this writing (..most of them I’ve read and own). I have not included books and links that delve more into getting your rails app into production mode other than Capistrano and Mongrel. Such other methods might end up in another post or as an addendum at a later time. The Advanced Level is geared toward Rails.

A must have reference book:
Ruby In A Nutshell
– by Yukihiro Matsumuto

BEGINNER LEVEL –

This level assumes that you are familiar with basic HTML, basic networks/servers and familiar with databases but have no prior programming background and entirely new to back end development.

B-L 1. Books/e-Books/Screencasts:

(Ruby)

(Rails)

B-L 2. Links:

B-L 3. Training/Classes:

INTERMEDIATE LEVEL –

This level assumes that you are very familiar with HTML, CSS, Javascipts, databases and have been doing back-end development with either ASP, Coldfusion, PHP, .NET and Java

I-L 1. Books/e-Books/Screencasts:

(Ruby)

(Rails)

I-L 2. Links:

I-L 3. Training/Classes:

ADVANCED LEVEL -

This level assumes that you are breathing and thriving in ruby and running rails applications plus adding Ajax, Subversion, Capistrano and Mongrel into the mix.

A-L 1. Books/e-Books/Screencasts:

A-L 2. Links:

A-L 3. Training/Classes:

There’s quite a few blogs out there that are just THAT awesome but do check out Planet RailsConf’s blogroll for a quick list.

I’d love to hear if you have a link or book to recommend and why you’re recommending it. :)

ˆ Back to top

Migrate me! (Links below)

September 25th, 2006 by comment sarah g

I’ve been playing with migrations in the past couple days. Migrations: a way to build and update your database schema within Rails, without using SQL, w/o losing data, and with the ability to fold your schema changes into your application so it’s easy to rollback to an earlier version of a DB or up to a more recent one. Given that ‘how do we change the DB w/o breaking the app’ problems can be painfully real, this is a really amazing tool. As DHH says on the screencast page, “going back to your former treadmill after being exposed to these movies can be exceedingly painful”. Yup. I’d already had a schema up for the project I’m starting, but was inspired to take it down and re-do it using migrations. They’re pretty amazing. Here’s a list of links I found particularly helpful, in case anyone else wants to get started, refresh, or just look at a list of links for fun:

That’s it for now. More later on my own specifics if anything interesting comes to light.

ˆ Back to top

How to add customized plural / singular word pairs in Rails

September 25th, 2006 by comment Carmelyne Thompson

Q: How do you h/t map your own pluralization word-pairs into rails? (S.G.)
A: You will find the following in environment.rb. You can uncomment the code
that iterates through the inflections and add your own custom rule. (A.O.K)
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, ‘\1en’
# inflect.singular /^(ox)en/i, ‘\1′
# inflect.irregular ‘person’, ‘people’
# inflect.uncountable %w( fish sheep )
# end

ˆ Back to top