programming

Groking Grep

I've been slow on posting tweaks and hacks lately because I've been getting acquainted with Regex and BBEdit. Here's a good approximation of what it's like for me to write regex expressions: I'm trying to translate Sun Tzu's "The Art of War" into Swahili with a reference library of Chinese restaurant menus. Fortunately, some menus are better than others. Occasionally, I end up with a regular expression that I have no memory of creating and no understanding of why it works.

Irregular Expression Link

I know I already posted about Regex, but come on, this is pretty hilarious. Apparently this regex actually does match something. I'm sure this is self-documenting to someone.

Learn Regex The Hard Way

Nice site with plenty of course work to learn Regex, Python, Ruby, C and SQL. I’ve read plenty on the Learn Python the Hard Way site, but I had no idea there were other courses.

Python Decorators Link

You know, this is the first time I think I actually understand decorators. I'm kind of dense. By way of Clark's Tech Blog.

The Value of Coding Today Link

Collin Donnell has a even tempered discussion of how coding fits into modern society today. I think knowing some kind of coding is like knowing basic physics or any math beyond addition or subtraction. You can get along pretty well without knowing it. If you're well positioned in life you will never need to know it. If you're not, then it's only going to give you more opportunities in life.

AppleScript-Cocoa Over PyObjC?

What’s more odd to me, is that Apple has dropped the PyObjC support but gave AppleScript a giant boost with Cocoa-AppleScript. Don’t get me wrong, I like AppleScript fine, but it sure isn’t as flexible as Python or Ruby[1]. Anyway, if your thinking about making any AppleScript-Cocoa projects, here’s a very good tutorial over at MacScripter.  UPDATE: There are also great resources over at MacAutomation.com, including what looks like a good book.

Safe URL System Service

Following on the previous post, I decided to try something new (for me). I wanted to turn my Safe URL Python script into a services extension. The easiest way I know to make a new services menu item is through Automator. I typically shy away from services because my list of text services is already quite long and disorganized. In this case, I really just wanted to try converting a Python script into a system service.

Making Safe URLs

I need to do this often enough, I wrote a macro with some Python for it. The macro converts a url with invalid characters (such as spaces) to a safe encoded url. Importantly, the forward slashes, colons, question marks, equal signs, quotes and hashes that are necessary to pass queries and parameters are untouched by the conversion. A common example for me is as follows. Select a URL that has bad actors in it: http://www.

Scripting Bridge Redirect

A funny thing happened when I was reading through references for Python on OS X. Dr.Drang had a link to Apple's Scripting Bridge page. The funny part is that Apple appears to now redirect that page to the Automator page. It doesn't give me a lot of confidence in learning the Scripting Bridge. Here's the new home.