InquiryLabs

Politics, Programming and Possibilities

Archive for November, 2009

Sign the Get FISA Right Open Letter

This open letter is the product of a long and thoughtful process that I’ve been paying attention to, associated with a mailing list led by Jon Pincus.

Please add your name to the list of concerned Americans if you care about restoring our right to know when we’re being wiretapped by the government (unless there’s a warrant), and especially if you believe the “national security letters” should be done away with.

I think it’s a terrible thing for a government to be able to systematically silence citizens who oppose it, and this open letter seems to be a positive action in that direction.

Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Reading a File with Node.js

    I’m playing with Node.js right now for one of my side projects and found that it was a little more difficult to read a file than I had anticipated.  First, I looked for an “obvious” function that would read in an entire file, but there didn’t seem to be anything like Ruby’s IO.read (I was wrong, however, see the posix.cat solution below).

    In order to get the benefits of Node.js’s event-based system, we have to use the posix utilities.  Here’s what I tried first:

    var prepareTemplate = function(file, callback) {
      posix.open(file, posix.O_RDONLY).addCallback(function(fd) {
        if (fd) {
          posix.read(fd, 100000, 0).addCallback(function(data, bytes_read) {
            var template = jsont.fromString(data);
            callback(template);
          });
          posix.close(fd);
        } else {
          sys.puts(”Unable to read file: ” + file);
        }
      });
    };

    Node.js croaked with the following error, however:

    /Users/duanejohnson/Projects/hello.js:15
      posix.open(file, process.O_RDONLY);
            ^
    TypeError: Bad argument

    Contrary to these presumably out-of-date slides, the documentation shows that the O_CREAT, O_RDONLY etc. constants are to be found in the “process” namespace (not the “posix” namespace).  That was easy to switch…. but same error.  It turns out the “mode” parameter is not optional:

    var prepareTemplate = function(file, callback) {
      posix.open(file, posix.O_RDONLY).addCallback(function(fd) {
        if (fd) {
          posix.open(file, process.O_RDONLY, 438).addCallback(function(fd) {

    The “438″ in there is simply octal “666″ (read/write permissions) turned into decimal.

    Last but not least, I found that there is a “trick” to loading files if you don’t care about concurrency (for example, when the server starts up and you want to load templates):

    var data = posix.cat(file).wait();

    Alternatively, you can use addCallback() instead of wait() to get around the concurrency issues.

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • End the Fed Rally Chicago

    Kelty and I just went for a walk in Millenium Park and happened across an End the Fed rally. It was neat to see support for Ron Paul’s “Audit the Federal Reserve” bill there.

    Sent from my iPhone

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Audit the Fed Bill Approved

    This is a snippet of the good news:

    The House Financial Services Committee has approved Rep. Ron Paul’s measure to drastically expand the government’s power to audit the Federal Reserve.

    Thank goodness Rep. Mel Watt’s anti-transparency measure was given the no-go.

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized