CopyFS Update

Years ago I added features to CopyFS 1.0, then 1.0.1 came out and I never bothered to forward-port my changes. After spending some time moving, merging, rebasing, etc. in git this morning, CopyFS 1.3.1M is CopyFS 1.0.1 + CopyFS 1.3M.

I worked deliberately to ensure all of the old codes were left accessible, so if you check the tags, you’ll see each version (1.0 through 1.3.1M) available if you want to rollback or whatever. Have at. I don’t expect to be actively developing this, but pull requests are welcome.

Posted in Coding, Linuxy | Tagged , , , | 2 Comments

Ruby Hash Extensions

As I mentioned before, one of the nice things about Ruby is its malleability. Here are a couple extensions to the Ruby Hash object:

class ::Hash
  def random
    return self.keys[rand(self.size)]
  end

  def byValue(subKey)
      if subKey
        self.sort_by {|key, value| value[subKey]}.reverse
      else
        self.sort_by {|key, value| value}.reverse
      end
  end
end

Simply, Hash.random will now return a random hash key. Hash.byValue will sort the hash by value. Hash.byValue(‘priority’) will sort a Hash-of-Hashes by the value of the named sub-key. TIMTOWTDI, for sure.

Posted in Coding, Linuxy | Tagged | Leave a comment

Ruby 2 From Source on CentOS 6.4

Ruby‘s autoconf doesn’t alert you to the fact that your system doesn’t have everything it could use. It’ll blindly clear you even though, for example, nothing crypto-related will work. On a fresh CentOS 6.4 install (with EPEL) the following will give you everything you need to build like a champ:

yum install gcc make gcc-c++ openssl-devel libffi-devel \
ncurses-devel gdbm-devel readline-devel bison-devel bison
Posted in Coding, Linuxy, Work | Tagged , , | 2 Comments

Which Oar Best Rows The Boat

Ted Dzuiba wrote a post that boiled down to identifying his own “language bigotry” as a step along the way to software engineering “Mastery”.

He’s absolutely correct about introspecting why one chooses to “fight” other languages. And by saying “languages” I could substitute OS platform, cloud computing, database manager, code editor, car manufacturer, religion,  Constitutional Rights, regional sports team, patriotism, etc.

We identify ourselves by our passions and beliefs.  As a means of vetting prospective employees, I have long made a habit of asking candidates “what are you?” The answers over the years include things like “mom”, “Catholic”, “firefighter”, “LARPer”, “Mac geek”, “soldier”, “Cisco network engineer”, “hunter”, “professional juggler”, “Red Sox fan”, “clergy”, “MySQL admin”, “mountain climber”, “Chevy nut”, “Java programmer”, and on and on.  When someone identifies themselves as a something you can pretty safely assume some other things: A “Red Sox fan” most likely loves baseball, hates the Yankees, also likes the Patriots [American] football team, and is located or grew up in the New England region. A “hunter” most likely feels strongly about their Second Constitutional Amendment Rights, votes centrist or right on the political scale, dislikes leftists, also enjoys the outdoors, probably fishing, and most likely desires to live somewhere more rural than more urban. Everything there is a prejudice for or against something, and it’s perfectly natural. (And yes, it’s stereotyping: that’s how we templatize correlated attributes, please carry on)

The key to finding a good employee is sussing out which of those will get in the way of delivering business value. The key to being a good employee, is introspection about why you have those feelings and if they’re relevant. As Ted says perfectly (I emboldened his italics):

I feel orders of magnitude more useful delivering business value than I feel delivering code.

A clutch statement right there – it’s not about the tools, it’s about the product and its value. I’m not advocating, and I doubt Ted is either, that any intelligent engineer should just clam up and do as they’re told – if there is value or purpose to moving against the grain, then speak up! Your value as an engineer is only partially what is produced, and constructive engagement debating how something is produced is exceptionally important as well. But know when your beliefs- your prejudices- are pointlessly in the way. Introspect on why.

My most recent position requires the use of an Apple Macintosh (gross), is completely hosted using Amazon Web Services (ick), systems scripts almost entirely written in Ruby (*twitch*): all of which I knew in advance of accepting the position. I don’t prefer a single one of those things, but would it have been a better position if they used HP laptops running Linux, had a hardware server farm, and churned out klocs of Perl? Nope. Would it be a better business? Not at all. So I use a Mac for hours a day, architect in concert with AWS’s strengths and weaknesses for hours a day, write Ruby for automation as needed, and am perfectly at peace with all of that.

Sure, I still run Linux on my own hardware, remind my colleagues that if we ran our databases on hardware vs. “the cloud” we wouldn’t have “that” problem (for whatever the problem might be), and occasionally sneak in a quick Perl script that would have taken three-to-six-times as long for me to write in Ruby (not necessarily Ruby’s fault) – but not at the cost of value.

A bad workman complains about his tools. A craftsman works with what is at hand.

Posted in Architecture, Coding, Life, Opinions | Tagged , , , , | Leave a comment

Ruby String.each

While I find Ruby to be a half-assed attempt at an object-oriented Perl, I have been using it quite a bit lately to stay consistent with a lot of existing intellectual property. One of the more maddening things is that somewhere along the way, within the 1.9.x series, the Cardinals of Ruby decided to remove the “each” method from the String object. While logically inconsistent, this method allowed one to create a function that iterated over an array, or if the item passed was a String, iterate over that one item, without extra code to detect if it was “only” a String and handle it differently. Add the below to your rb or include it in a file to get that feature “back”.


class ::String
  def each(&block)
    Array(self).each(&block)
  end
end

*sigh*

Posted in Coding, Linuxy, Rants/Tirades | Tagged , | 1 Comment

MySQL com_select Nugget

The com_select counter isn’t a raw count of how many SELECT operations the server has performed, but rather the number of SELECT operations that did not get returned from the query cache. To see the real number of SELECTs (assuming query caching is on), you need com_select + qcache_hits.

This is in MySQL’s documentation, but I thought I’d share.

Posted in Linuxy, Work | Leave a comment

SPDY for Apache

Mod_SPDY for Apache is out. If you don’t know what SPDY is, I’d recommend some light reading … or heavy reading if you’re that kind of person.

 

Posted in Architecture, Linuxy, Products | Leave a comment

NConf 1.3.0 Pass-through HTTPD Auth

If you’d like to use NConf, but want your HTTPD, e.g. Apache, to do the auth for it, apply the below patch to set the NConf user to the currently authenticated user.

--- include/head.php.orig    2012-04-03 19:34:13.774594705 +0000
+++ include/head.php    2012-04-03 19:21:39.470169672 +0000
@@ -70,7 +70,12 @@
 }else{
     // NO authentication
     $_SESSION['group'] = GROUP_ADMIN;
-    $_SESSION["userinfos"]['username'] = GROUP_ADMIN;
+    # M@
+    if( isset($_SERVER['REMOTE_USER']) ){
+    $_SESSION["userinfos"]['username'] = $_SERVER['REMOTE_USER'];
+    }else{
+        $_SESSION["userinfos"]['username'] = GROUP_ADMIN;
+    }
     message($debug, 'authentication is disabled');
     message($debug, $_SESSION["group"].' access granted');
 }
Posted in Coding, Linuxy, Work | Leave a comment

find -delete

If I hear one more person recommend using a pipe to xargs or -exec rm -f {}  to the question “how can I make ‘find’ delete the files it finds?” I’m going to scream. It’s really simple:

find /wherever -mtime +7 -type f -delete

That’s it. Nothing to remember. No shelling (exec) or piping. Real easy. Real fast.

Posted in Coding, Rants/Tirades, Work | Tagged , | Leave a comment

Video Captcha Prior Art

Nucaptcha claims to have invented video captchas. They didn’t. Neither did I, proabably, but I have talked about them publicly a few times, including this blog post from 2009.

Posted in Architecture, Life, Products | Tagged , | Leave a comment