A human way to define regular expressions?

Dear lord, I hope no one is actually using this in production. pattern = Hexpress.new. start("http"). maybe("s"). with("://"). maybe { words.with(".") }. find { matching { [word, "-"] }.multiple }. has("."). either("com", "org"). maybe("/"). ending pattern.to_r #=> /^http(?:s)?:\/\/(?:(?:\w)+\.)?([\w\-]+)\.(?:com|org)(?:\/)?$/ via Hexpress by krainboltgreene.

September 5, 2013 · 1 min · chetan

How Poverty Taxes the Brain

Researchers publishing some groundbreaking findings today in the journal Science have concluded that poverty imposes such a massive cognitive load on the poor that they have little bandwidth left over to do many of the things that might lift them out of poverty – like go to night school, or search for a new job, or even remember to pay bills on time. via How Poverty Taxes the Brain - Emily Badger - The Atlantic Cities. ...

August 31, 2013 · 1 min · chetan

Resetting the chronograph on the Tissot PRC 200

The large seconds hand (#6 in the diagram above) on my watch somehow got screwed up; when resetting the chronograph, it would always rest on 56 instead of zero. Apparently fixing this is an undocumented feature, though really quite easy to do. Simply pull out the crown (#12) to the second position as if setting the date. Now, when you press the reset button (#11) the seconds hand will advance by one. Just keep pressing it until you reach zero and you’re all set! ...

November 5, 2012 · 1 min · chetan

How to fix wget certificate issues

If you’ve ever run into this annoying message before: $ wget https://raw.github.com/bagder/curl/master/lib/mk-ca-bundle.pl --2012-06-12 14:42:46-- https://raw.github.com/bagder/curl/master/lib/mk-ca-bundle.pl Resolving raw.github.com... 207.97.227.243 Connecting to raw.github.com|207.97.227.243|:443... connected. ERROR: cannot verify raw.github.com's certificate, issued by `/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3': Unable to locally verify the issuer's authority. To connect to raw.github.com insecurely, use `--no-check-certificate'. There’s actually an easy fix! You may want to run ~/.ssl/mk-ca-bundle.pl occasionally to keep things up to date as well.

June 12, 2012 · 1 min · chetan

Profiling Java programs on OS X

Sounds easy, doesn’t it? Well it actually is quite simple but the error messages along the way can really trip you up! My first attempt at profiling a bit of code was to use the full-boat Eclipse stack: Eclipse Test & Performance Tools Platform Project! Well, what they don’t tell you anywhere on the project page is that it’s only supported on Windows and Linux. A Mac port was started sometime around 2004 and never completed. Yeah, it’s been that long! ...

May 19, 2011 · 2 min · chetan

Compiling Q4M on OS X

I recently compiled Q4M on my Mac and I’m documenting it here now because it proved to be somewhat painful so hopefully you’ll avoid a bit of grief by reading this. First off, you need MySQL Server. I’ve been using MacPorts for some time now, so this is installed via ports. Unfortunately, it seems to be a pretty barebones config so I had to create a custom variant to add the necessary --with-fast-mutexes option. You can grab my modified Portfile from github. Just clone it into some directory and then add that path into /opt/local/etc/macports/sources.conf before the rsync line. Once you have that, go ahead and reinstall MySQL: ...

May 12, 2011 · 1 min · chetan

Getting things done - DDG style

I have no idea how Gabriel ever gets anything done, considering that he’s constantly responding to emails, tweets, forum posts, comments on various sites and IRC – just to name a few! Here’s a typical exchange from earlier today when I reported a poorly performing query on DDG: I used to be like that when I was at Operative but I don’t think I was anywhere near as productive as him. ...

February 18, 2011 · 1 min · chetan

Relaunching lunchomizer.com

I spent a bunch of time the last couple of days sprucing up a few of my personal projects. Today was mostly spent on the lunchomizer, which gives you random suggestions for lunch, based on your location. It still only works for Midtown Manhattan since the locations all come from Midtown Lunch and that’s also the neighborhood where I happen to work. The biggest change today was fixing the HTML5 location support and a much better mobile experience via a separate Rails layout tailored for small screens. All in all, it was pretty easy, but one thing that surprised me was a noticeable lack of a de facto standard library for doing mobile, or really any, browser detection. I ended up using a gem called Nomadic and that worked well with the following controller code: ...

February 13, 2011 · 1 min · chetan

Creepy voicemail

I got this creepy voicemail today on an unused Vonage number that I have: Your browser does not support the new element. You can download the file instead. Vonage transcription: “Good morning and good morning and good more and then I’m. I’m alone. So in the shower. I am gonna be more than any card board boat races in my dreams. Swimming in the lake trip the water” PS. this is just an excuse for me try out the new HTML5 tag, which apparently doesn’t work in Firefox 3.6.x. ...

February 11, 2011 · 1 min · chetan

Stupid Windows Firewall

So it turns out that Windows Firewall, even in Windows 2008, still can’t accept a range of ports, either in the UI or via command line, most commonly when setting up PASV FTP transfers. The common workaround is to create one entry per port in your range like so: C:> FOR /L %I IN (60000,1,60200) DO netsh firewall add portopening TCP %I "Passive FTP"%I While this does work, it’s slightly annoying that you have to create 200 individual entries in your config. My slightly better workaround is to just stick every port into the text entry field using this simple ruby helper: ...

January 30, 2011 · 1 min · chetan