Wednesday, May 30, 2007

ColdFusion / .NET Integration

 

.NET Feature — ColdFusion/.NET Integration — As both a .NET programmer and ColdFusion developer, I always wondered how I could leverage the world of .NET in ColdFusion. Both platforms come with powerful features and using them together might be a wonderful friendship, if one could only make them cooperate. There are two worlds out there and none of them is an island.

Hey, very neat article from .Net Developer's Journal.  And great timing, as I'm right in the middle of converting our company's main product from ColdFusion 7 to .Net.  I'm actually quite impressed with this article for a few reasons:

  1. It doesn't take the easy route and say "Just do web services" (although it does throw that idea a mention right on the first page).
  2. It's not just an advertisement for ColdFusion 8 (Scorpio) which is apparently going to have even more .Net integration.
  3. It shows how to integrate with .Net 3.0, so it's right up to date with the latest technology.

I've already forwarded it to my team and look forward to printing it and reading it in more depth on the train to work tomorrow.

Technorati tags: ,

Optimizing Rails on Oracle

Many of my articles are about working with Rails, particularly on Oracle.  It's nice to see that Oracle has their own page on optimizing the two.  I especially like that it breaks down how Rails creates the SQL statements behind the scenes, and then looks at ways to optimize that SQL. 

 

Technorati tags: , , ,

Tuesday, May 29, 2007

Ruby Regular Expressions

Aha, another quick lesson learned.  In Ruby, the regular expression is an object unto itself with its own syntax.  So to do a simple search and replace you do something like this:

"The quick brown fox".gsub /brown/, "purple"

which replaces the results of a match with regular expression "brown" with the string "purple".

But what if you wanted to do something more dynamic, like, say, matching a color based on a variable?  You can just as easily do this:

color="brown"

"the quick brown fox".gsub color, "purple"

And it will work.  Ay, though, but here's the rub -- it's no longer matching it as a regular expression.  Try this test:

input = "start:   data"

data = input.gsub! "start:( +)", ""

that should strip off the start: as well as one or more spaces, right? Nope.  It fails to match.  That's because since I'm passing a string it's not evaluating it as a regular expression.

Wrap that first element in a constructor for Regexp:    Regexp.new("start:( +)")  and you'll get the right answer.

 

Technorati tags: ,

RegExp : "Lazy Star"

Hey, I learned something new today.  Cool.  I'm trying to scrape some HTML so that I can produce an XML document out of it, and I came to this piece of logic.  I want to get rid of <a> links and just leave the text.  So if I have  "Blah blah <a href=foo>bar</a> something else" then I would just be left with "Blah blah bar something else."

First attempt (this is in Ruby, by the way):

line.gsub! /<a href=(.*)>/, ""

line.gsub! /<\/a>/, ""

In other words just a brute force attempt to chop out the tags, leaving the middle.  This appeared to work.  Except when I had nested tags.  In a case like this:

<th class="header"><em>This is a <a href="link">link</a></em></th>

I would end up with this: 

<th class="head"><em>This is a

Because it turns out the first .* was being greedy and going all the way to the last occurence of the > character (the one with the th) and eating the whole line.

I recalled the term "greedy regular expressions" from lessons I used to get from a coworker (Hi SteveO!) so I went googling and came across this rather lovely reference page which told me exactly what I wanted.  Namely that a single star is "Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is not matched at all.", and that there is a syntax *? called the "lazy star" which is "Lazy, so the engine first attempts to skip the previous item, before trying permutations with ever increasing matches of the preceding item."

Perfect.  Changing my regular expression to:

line.gsub! /<a href=(.*?)>/, ""

Did exactly what I wanted, finding the first > and stopping.

I knew about the typical use of ? as a "0 or 1" matcher (as well as + for "at least one") but this was the first time that I'd had opportunity to use the * in conjunction with ?.  Learn something new every day.

 

Friday, May 18, 2007

How To Do Clouds In Photoshop

This post appears to have been removed, the link is broken. I don't know why. Sorry about that.

http://www.impulze.net/v3/portfolio/9/22/

I'm not much of a Photoshop user (the Gimp is the closest I come), but I am a fan of watching clouds.  I've always wanted some software that would generate random clouds for me, something I could use as wallpaper.  I like meditating by finding interesting scenes in them (and I'm not just talking about "hey that one looks like a dog"). 

So I was pleased to find this tutorial specifically on creating "realistic" clouds.  When I get some free time I'm going to see if all the techniques work in the Gimp.  Hey, does somebody want to script something up for me that regularly regenerates a file of clouds that I can attach to my desktop? :)

 

Technorati tags: , , ,

Biggest Myths About The Workplace

Update: Link fixed, thanks Rob.

Guy Kawasaki has up an article by Penelope Trunk on 9 "myths of the workplace".  I disagree just a bit with #2 (job hopping will hurt you) and #6 (you need a good resume).  Yes, if you're saying that "you absolutely must not jobhop" and "you must have an awesome resume" otherwise you will never get any jobs, ever, then yes, of course that's stupid. 

But realistically, the resume and the employment history do matter.  I used to interview at a place that was pretty hard to get into, the sort of place where you ran a gauntlet that required writing (and being quizzed on) source code, all the way up to getting the blessing of the company president.  We turned away way, way more resumes than we accepted.  Very rarely did we get somebody in by way of personal connection.  Typically this was because our technical requirements were so specific that either nobody knew someone that fit them, or else they were afraid to send their friends in who were not a perfect match for fear of being blamed for wasting everybody's time.  I always wondered about the coincidence that the last person I ever interviewed for the place turned out to be not even close (I was the first interview and did not ask the necessary weedout questions, apparently).  I was taken out of the interviewing loop immediately after that.

Penelope's right, I wouldn't be too worried about which verb to use (did I lead the project, or did I spearhead it??).  But I guarantee that at some places you are going to get thoroughly quizzed on what you say you did.  You say you've got skills in Smalltalk?  Great, tell me what you did.  Don't lie to get yourself in the door. Since I interview and hire technical people, one of the rules of thumb I've always used is, "If you list it as a technical skill, then you'd better show me in the work history where you used it." 

As for the job hopping, that's a hard one.  You don't want to tell people they have to stay in a horrible job for a year just so it doesn't look bad on the resume.  What looks bad is a pattern of that.  Fine, you left one job because it wasn't a right match, or because the boss hated you, or you got a better offer. But if you did that 5 times in 3 years?  I'm going to have to wonder whether you'll do that to me, too.  If you're having that much difficulty finding a job you like, then how am I supposed to know if the job I'm offering you is going to be any different?

Don't be afraid of the great big working world.  There's room for everybody, and almost nothing that you can do will be such a black mark that you'll never work again.  But by all means treat your career like one big entity, not just a series of jobs.  What you do with your life says something about you.  You're not getting a clean slate every time you end one job and start a new one.  You need to be able to explain why you made the leap that you did.  There's a certain level of accountability there.  Your new job expects you to be accountable for your actions, and that resume and interview are really the only things they've got to base their decision on. 

Thursday, May 17, 2007

Jobacle.com Career Questionnaire

Over at Jobacle.com Andrew's doing a "Career Questionnaire", so I thought I'd throw my two cents in:

Worst Boss

Two of my children were born during my time at one company, and both times I had to send out my own email because my boss "dropped the ball".  Not sure that makes him the worst, but it was pretty lame.  I suppose the worst was the manager who used to come into my office and fish the Coke cans out of my trash.  One day I asked him, "Oh, is that like for a boy scout fund raiser or something?" and he said, "No, just mad money for me to buy toys."  The guy who decides how much of a raise I should get is digging for nickels in my garbage?  Eeesh.

Best Boss

I liked David.  He was as close to a business mentor as I've ever gotten.  He always had the right mix of "I'm your friend and I can hang out with you after work" and "I'll give you a long leash to work on what makes you happy", coupled with an ability to say "If you screw up I'm going to tear you a new one" while not making you feel personally humiliated.  Does that make sense?  I could drink a beer with the guy, get yelled at in a meeting, and then drink a beer with him the next day, no hard feelings.  Separating work life from personal life was a very important lesson.

Most Innovative Colleague

Some of the engineers at my last job were brilliant coders.  A couple of them left you with no doubt that if necessary, they could code the entire product themselves.  In a weekend.  And still take a break to play frisbee.

Most Rewarding Task

My first job out of college was working on a medical device to detect osteoporosis (ever see a commercial for Fosamax?  I worked on those clinical trials).  So I suppose that preventing little old ladies from falling and breaking their hip is pretty high on the list.  Now I work at a place helping kids get into college. 

Best Item You "Permanently Borrowed"

When I got laid off from one job they seem to have forgotten that I had an IBM Thinkpad.  A few months after the fact I actually ruined it by spilling soda in it, and one of my contacts that was still at the company let me swap it out for another one of the machines in the office :).  Very nice.

Most Embarrassing Moment

I was in a meeting discussing the planning for a particularly large project.  A meeting which, for some reason I can't remember, included people like the head of sales and the president of the company.  My boss was always telling me about how much of an idiot the head of sales was, so as he babbled I found myself smirk and shaking my head.  I can't even remember why. But I do remember the president of the company pausing the conversation to say, "We have laughter in the corner over here.  Do you have an opinion?"  Ummm....ahhhh......eeeeeeep!

Lowest Pay

When I was in high school I was a bagger at the supermarket.  The minimum wage was $3.35/hr.  Does that count?  I remember going to a union contract meeting where the representative basically said "this contract is fine for everyone except the baggers."  So when the voting slips came around I wrote No on mine. The guy next to me, a cashier, saw it and called me an *sshole.  I think I was 14.

Worst Holiday Gift or Bonus

I worked at a place where we used to get a turkey for Thanksgiving, that was fun.  For worst, though, I'm gonna give this one to my dad.  His whole career (40 years) he worked as a meatcutter at Stop and Shop.  One year they said that there'd be a bonus for Christmas.  On Tuesday a Stop and Shop television commercial ran that ended with an animation of Santa Claus writing, "From all of us to all of you, Thank You.  Merry Christmas."  That was it.

Bonus: Your Typical Day

Everybody knows about my commute.  When I get in I check the email and scan a couple of key technical feeds to see if anything interesting is happening, or if any relevant tutorials have shown up on .Net or Rails.  Every other day or so I'll have 2-3 meetings for project planning. Mostly, though, I'm writing code.  Visual Studio, C# code.  If I'm lucky I get to work in Ruby for some projects.  Sometimes it's data mining which means working in shell scripts and other Unix loveliness.  I'm out the door around 4:40 so I can catch a train home in time to help my wife get dinner on the table.  Once the kids are in bed I'll get back on the computer around 9pm or so and do a little work depending on how much needs to get done.  Sometimes that's just wrapping up some emails or some documentation, sometimes it's continuing long running jobs that weren't done yet.

Wednesday, May 16, 2007

Is "Scratch" The New LOGO?

http://scratch.mit.edu

As a lifelong programmer I've been anxious to see if my children will follow in my footsteps.  I've often daydreamed about bringing the programming language to them, something very animation heavy done entirely in shapes and colors (since they are all too young to meaningfully even read yet).  Well I certainly don't have the time to go creating new languages (my kids will probably outgrow it before I'm done anyway), but thankfully there are people at MIT working on exactly this problem.  This week they're getting lots of press for "Scratch", their new free programming environment for kids.  I've got it loaded up right now, and it's actually pretty cool.

Folks who've been programming since they were kids may remember LOGO, the language where you moved a turtle around a screen with commands like "Forward 10, turn right, pen down" and so on.  Those are all still here.  Scratch is a bit heavier on the sprites and animation than I remember Logo being, and it even includes a paint program so you can make your own sprites.  Make a couple of versions of your figure, then with a simple "Forever->Next Sprite" loop, you've got animation.  Nice.

The kit comes with a number of games of varying complexity.  This is awesome.  Anybody that learned to program as a kid will tell you that the best thing to do was to get the source code to a game and start changing the variables.  I remember typing in code from something called More BASIC Computer Games.  I used to hang out at the local Radio Shack before I got my own computer.  With Scratch you can do the same thing.  Only now the source code isn't so much about the reading and the typing, it's more about snapping together the blocks ala Legos.  You do still need to read - the blocks have words on them - but you don't really need to type it all in yourself.  There's even a simple green flag to run it and a red stop sign to stop it, so if dad has to help the kids put the program together, they can still work it themselves.

I haven't gotten my kids in front of it yet but I hope to as soon as I can.  They're always intrigued when I have something new to show them on the computer.  The question will be whether they're interested in actually modifying the games, or just trying to play them. We shall see!

 

Wednesday, May 09, 2007

Parent Hack : Making Mom A Mix Tape

Every parent of little ones has, at one point or another, tried to record them saying something cute. But it's always been impossible to capture the moment the right way, while not hearing dad say "Say it! Say it now!!" in the background, with the right volume, no background noise, etc... Getting a meaningful amount of content? Forget it.

That is, until now. If you've got a computer then you can put the latest podcasting mania to work for you and whip up a quick gift for mom. Got a microphone? If you've been doing Skype you do. Many webcams even have them built in. Now go get yourself a copy of Audacity, the free sound editing program that everybody's raving about.

Now, grab the kids. Start recording. Have them say something cute, or sing a song, or tell a knock knock joke. Using Audacity you'll be able to cut out the big pauses (just select and delete) when they forget what to say, and cut yourself out of the background giving them clues to the words. Then boost the volume in case they were whispering (effects, amplify). If you really want to get fancy and you've got more than one child, record them each singing the same song and then merge them together to create a harmony.

Repeat until you're bored. Get at least one audio of them saying "Happy Mother's Day, Mommy" and burn it all onto a CD. Bet she loves it.  Mix in a handful of her favorite songs.

I'm making one for my wife right now. Don't anybody tell her. I'm posting here instead of on my regular family website because she reads that one.

 

Friday, May 04, 2007

The TED Talks Are Online

I'd been waiting for the TED talks as they trickled into my iTunes video podcast.  But they were few and far between, and the ones I got were years old. 

I just discovered that many more of them are online for viewing and download.  Go check it out.  Now.  Seriously.  There's something for everybody - politics, business, music, technology, you name it.  Bill Clinton and Al Gore spoke.  Jeff Bezos, Larry and Sergei, Dean Kamen.  Outstanding content, all around.

The visualization is neat, but don't forget to browse the categories.  At any given time you're only seeing what fits on the page, you're not seeing everything they've got.  Sort it a few different ways (by email, by date, etc...) to make sure you're getting everything.  I love that there is a a "Download MP4 Video to iTunes" link right on the page so I can just pick which ones I want and have them automatically show up on my iPod for the drive home.  Nice!

 

Technorati tags: , , , ,

Tuesday, May 01, 2007

New Elevator Technology & Usability Bugs

We've heard for awhile about the new type of elevator where, in the lobby, you press the number of the floor you want, and then you go wait for the elevator that's going to that floor.  No buttons inside the elevator, everything's an express trip.  Well apparently 7 World Trade Center has them installed, and there are some usability bugs that may not have been considered.  Joel points out one I hadn't thought of -- that people unfamiliar with the system will jump into the elevator and then be stuck going for a ride.  I think that problem's got a built in shelf life, though, if the technology catches on.  Eventually people will recognize the new elevator control as the way that it's done, and work with it.

I can think of some more human factors as well:

  1. You're having a conversation with your coworker who gets off on 7, but you work on 9.  You can't ride up together for 7 floors, unless you want to get off on 7 and then wait for one going to 9.
  2. If you're going against traffic, like for instance you're on 7 and want to go up to 9 instead of down to the lobby, how long will you have to wait for an elevator?  Won't the majority of trips be back and forth to the lobby?  At least with the old system you could catch a ride on one that was heading up that would stop for you.
  3. How does the display in the lobby work?  I've pressed 9, now somehow it has to signal to me to go wait at the C elevator.  But in the morning rush hour say that there are half a dozen people behind me also heading for 9.  Do they know that C is going to 9?  Or do they each have to take a turn at the button? 
  4. How many elevators are there, and how many floors in the building?  Seems like there's a simple math problem there -- if you've got 10 elevators, and 12 people all come into the lobby heading for different floors, 2 people are going to be told "Sorry, wait for the next one," even though only one person is getting on each elevator.
  5. Are the door open and close buttons in these things, or are those obsolete now?  After all, the door open button is really only for people diving for the elevator at the last moment (which I suppose could still happen, although as Joel points out not as much as it used to because most of those people weren't going to your floor anyway).  Or it could also be for those times when you're staying on the elevator and holding the button for people to get off.  But you're getting off too, so unless you're just being a gentleman and holding it for the others, it's unneeded.  The door close button, meanwhile, is really only for those morons who need to get to their floor half a second sooner than they would have, so while you exit on your floor they sit their with their finger on the button impatiently waiting for you to exit so that they can hit the button and get their ever so faster.  That problem as well is gone, since the only people on the elevator with you are people on your floor.

It seems like a technology that is good for rush hour times, but maybe not so much as the only solution.  During the non-rush hour times when there's only a trickle of people using the elevators, it seems like there'll be mostly annoyances.  In the article, Joel points out the example of "two people going to the same floor might have taken two different elevators, thus resulting in an unnecessary trip."  True enough.  But in this scenario if we have somebody going to 7 and somebody going to 9, then instead of having a single elevator make the trip to 9 and back down to the lobby, you have one go from lobby to 7 and back, and one go from lobby to 9 and back.  That's far more wasteful.