Email validation is harder than you think.

I got asked recently about email validation: is “+” valid?

Yes, the plus sign is a legal character in an email address. Though even if it were not, you’d do well to accept that character since it’s used by millions of Gmail users:

Many surprising characters are legal in an email address. Pretty much everybody gets email validation wrong.

If you still want to take a shot at evaluate the correctness of an email address string, at least do it with library that uses a parser and has attempted (nevertheless imperfectly) the difficult task of complying with all the relevant RFCs. For example:

“What Next” resources for RailsGirls grads in San Francisco

In an average month, San Francisco’s SOMA neighborhood is host to more than 30 workshops, classes, and study groups that are:

  • specifically for women to learn programming, maintain ongoing study, and enter the profession;
  • provided by professional programmers, who teach and mentor for the sheer darned pleasure of sharing what they know and expanding the community; and
  • all of it either completely free or else low-cost (with up to 100% scholarships available for the latter, as needed)

And thosre are just the ones about the principal languages of the Rails stack: Ruby, HTML, CSS, and JavaScript.

Yes, 30 events per month that meet all of those criteria.

So many opportunities to see, do, learn, teach, lead, mentor.

This weekend I had the pleasure of volunteering at yet another of these local events. RailsGirls held its second workshop in San Francisco; another organization easing into this vibrant mix. Welcome, RailsGirls grads! Here’s a couple slides introducing you to the abundance of local answers to “What’s next?” I hope we’ll get to see you again, soon, at several of ‘em.

UPDATE: Fixed the hashtag. Added 2 more resources.

Submitting commits to official Ruby & Rails documentation

Done! Submitted my very first commit for the official Ruby documentation.

Patting myself on the back for having spotted the error. It was over 2 months old — surprising for a standard library like URI::HTTP. So I second-guessed myself initially.

Surely that doc gets scrutinized by hundreds of people daily. Surely someone else would have spotted it ages ago, if it were done incorrectly. Surely I just haven’t heard about some fancy new syntactical construct. Surely the fact that the example doesn’t work for me is because I must’ve done something incorrectly. Surely.

That voice in the back of the head is noise from imposter syndrome. Shut up, you.

Doubt like this depends too on believing that those who have contributed to Ruby are infallible. A mythbuster, for me and for you:

$ cd ruby-official-repo
$ git log | grep -ic "typo"
842

Trust your instinct. Verify. Make better things happen. Commit.

Last month I also made a first commit for the official Rails documentation, and — hooray! — it was accepted. Though not without a brief facepalm moment when I accidentally submitted a big bunch of other people’s commits with it. Luckily, the railsdocs repository is maintained separately from the Rails codebase. So it was a quick fix by doing git reset --HARD on master branch then the documentation maintainers and I each did a git push -f on our respective repos, and rebased my branch’s commit back in. Voila, solved.

It’s a good example of where Git is a big win for contributor, maintainers, and collaborators. It is also a good example of how wins like these are made easiest when developers are required to submit to an upstream via a branch rather than on top of master.

So, summary: I can now put “Rails documentation contributor” on the résumé, and hopefully soon will be able to put “Ruby documentation contributor” on it too. Don’t worry; even though I’m a cool kid now, I still want to hang out with you.

UPDATE: Mission accomplished. What fun.

Learn HTTP (and a lot of other useful webdev topics) at Confident Coding III

I’m speaking October 21st at Confident Coding III (“Everything Else You Need to Know”), an all-day web technology education conference for women and friends. We’ll be at Microsoft’s San Francisco offices at Market & Powell. Join us for a fun day of learning about developer tools, automation, HTTP, the commandline, and more. Really useful stuff. Come!

(Pssst. Women still earn 77% of what men do. Use discount code EQUALITY to register at 77% price.)

Git “corrupt patch” when staging

In an ideal world, you could check out any arbitrary commit and it’s pass all tests, and have no bits of code trailing along that belong to another feature/issue. Line-by-line staging is how I first got religion where Git was concerned. Judicious use of it truly makes ideal commits feasible. Ahhh. Truly a Cool Git Trick.

But there’s a bug. Maybe you’ve seen it. Periodically, seemingly at random, attempting to stage or unstage a line results in an patch error such as “Applying patch failed with return value 128. Error: fatal: corrupt patch at line 12“. Don’t believe it.

The bug originates with Git-Gui, which doesn’t know how to stage a line when the file doesn’t end with a trailing newline (EOF). It’s been a known problem since at least 2010 and it’s a bug that’s still around today.

Add the trailing newline. Solved.

P.S. Want to learn about staging lines with Git? Check out “Splitting up commits the easy way” by Peter Savage. GitX(L) and SourceTree both support this workflow really well, and (ironically) are much nicer GUIs overall. SourceTree, by the way, doesn’t show this bug. GitX(L) does. Bah humbug.

Mountain Lion App Store + previous install of Growl == unhappy

The new Notifications Center in Mountain Lion is a pale, pale imitation of good ol’ Growl. But after upgrading OSX, the App Store refused to update Growl. Upon clicking the “update” button, the store kept complaining:

"You have updates available for other accounts. To update this application, sign in to the account you used to purchase it."

Don’t believe it. At least, don’t assume it’s returning a correct error message for your situation. While some people do purchase software under multiple accounts, this wasn’t the case here.

The actual complication:

The App Store doesn’t know how to cope with a previous Growl install — even one purchased through the store and not currently running.

How to solve it:

  1. Download* Growl Version Detective
  2. Remove everything it identifies in the “Growl” tab. (Don’t worry about the Frameworks tab)
  3. Trash /Applications/Growl.app

Voila. The App Store’s “upgrade” button is replaced by “install”. Smooth sailing from there. Including notifications that are top-rate. Hurrah.

Cool Git Tricks

At the last Women Who Code Lightening Talks, I presented “Cool Git Tricks (That I learn when things go badly)”, a quick and cheeky intro to some very handy features that even experienced users are frequently unaware of. [SLIDES] [VIDEO]

Git information to your shell prompt?!

Many said their favorite trick was the custom shell prompt (see the slides for how great this is). They were awed that you can do that.

Me too. I’d first seen it in “McCullough and Berglund on Mastering Git”, and had to know how the heck Matthew McCullough made his insaaaaane prompt. You’ve got to see it in action.

In fact, see the whole 5-hour video while you’re at it. Great for anyone who’s been banging their head against Git for a while. Earlier this year the team released a 4-hour followup to it, McCullough and Berglund on Mastering Advanced Git.

After seeing my Cool Git Tricks presentation, Chiu-Ki Chan was inspired to create her own Git prompt and showed code examples of what she’d done. Here’s a Gist of the code for mine, while we’re at it:

Have fun playing with the examples Chiu-Ki and I have given. Here’s code for Matthew McCullough’s Bash shell prompt too while we’re at it.

Learning how to customize your prompt like this is a tantalizing preview of what Git’s low-level “plumbing” makes possible.

JavaScript for Cats

JavaScript for Cats is a new, quite good, intro-level JavaScript tutorial. Nice to see lazy savvy use of the WebKit console incorporated into learning immediately.

I’m looking forward to the author’s promised upcoming additions of looping, objects, JSON, Node.js, and “server side catgramming”.

Therapeutic Refactoring

(Credit: “O.P.C.” by Abstruse Goose)

Katrina Owen‘s talk on what she terms “Therapeutic Refactoring” takes a fascinating approach to spaghetti code that arrives without specs or documentation. The answer is so simple it could be mistaken for TDD itself. But “test driven development” doesn’t describe how tests fit in here. She’s using tests as inquiries. “Hello, codebase. What do you do and what are you expecting?” There’s a bit of awe at watching an application reveal itself to a test doing nothing.

Watch the whole thing: Therapeutic Refactoring, by Katrina Owen, Scottish Ruby Conference 2012

Fix for “make: /usr/bin/gcc-4.2: No such file or directory”

When using “gem install [something]” after installing Mountain Lion, you may encounter this error:

Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.

make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1

Apple removed GCC 4.2. We’ll just put it back where make expects it to be. First install the package manager Homebrew. Then in Terminal do:

$ brew tap homebrew/dupes
$ brew install apple-gcc42
$ sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

UPDATED: added the brew tap line. As rathrio notes, for some users the extra step is necessary.

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.