InquiryLabs

Politics, Programming and Possibilities

I’m liking the duckduckgo search engine

After hearing about it on ycombinator, I switched my browser’s default search engine from Google to DuckDuckGo a couple of days ago and I’ve been quite impressed so far.  I like that it puts the definition of my query front and center, if it’s available (Wikipedia is usually the source of the definition).

I also think DuckDuckGo has a better disambiguation system than Google’s results page.  For example, I was searching for the price of gold and was lazy so I just typed “Gold” in to the DDG search bar.  A whole list of interesting meanings for gold came up that I didn’t realize existed (such as the Gold parser, or the 1934 film called Gold).  I didn’t find the price of gold, so I typed out the full “Price of Gold” and immediately found what I was looking for.  The “right answer” seems to be the first link more often than not.  I’ll keep experimenting.

Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Getting WxRuby to Work on Mac OS X

    I have Ruby 1.9 running on Leopard and recently tried to get WxRuby running.  Unfortunately, it was giving me the following error:

    irb -r wx
    /opt/local/lib/ruby1.9/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle: [BUG] unknown type 0×22 (0xc given)
    ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9]

    It turns out that I had installed using “sudo gem install wxruby” when I should have installed with “sudo gem install wxruby-ruby19″.  Fixed!

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Using Rave : Ruby + Google Wave

    I’ve been playing with Google Wave recently and enjoying the challenge of making a robot for the platform.  My challenge is to create a robot that looks for “Q:” and “A:” markup and submits questions and answers to a flash card service such as FlashCardDB.com so that my Inuversity study group can use spaced repetition to optimize our study sessions.

    Because the Google Wave team first released a Python version of their robot api, I started work on the project from that direction.  Unfortunately, Python’s “mechanize” library is not as well developed as I would like to see it.  For example, among other difficulties, the ClientForm library that it depends on was unable to parse the login form at flashcarddb.com.  In addition, due to the limitation that Python’s mechanize library does not easily allow me to simulate an XmlHTTPRequest, I finally gave up on that approach.  Since Ruby’s Mechanize library is in much better shape, I thought it might be an option.

    Since I am familiar with Ruby, I searched for possible Ruby/Wave solutions and discovered the 3 main contenders (Rave, Robot Sinatra Template and Wave Robot Ruby Client).  I chose Rave because of its “package” feel: The author, Jason Rush, has worked to make each step easy from configuration, to development, to deployment.  For example, building the Java WAR file is a simple “jruby -S rave war” command, and configuration is as simple as filling out a yaml file.

    I followed the directions at Jason’s introductory post about Rave and quickly deployed my first “bot” using jruby and the Rack+Rave framework.  Unfortunately, I soon realized that version 0.1.1 of Rave which has been released to the world does not support robot versioning!  That meant that I could not increment the version number of my software to indicate that I had made changes.  The robot was stuck at version 1.0.

    This problem was solved by Jason and other contributors in the latest source code.  As of this writing, it’s not packaged as a gem yet–so I went to his git repository to get the latest.

    One gotcha: since upgrading from 0.1.1 to 0.1.2, the rackup file (config.ru) has changed.  I received this cryptic error which indicates I needed to change the line in config.ru from “run Remembry::Robot.new(:name => ‘remembry’)” to ”run Remembry::Robot.instance”.

    javax.servlet.ServletContext log: unable to create shared application instance
    org.jruby.rack.RackInitializationException: private method `new’ called for RemembryRave::Robot:Class
    from /base/data/home/apps/remembry/1.339256739153417236/WEB-INF/gems/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize’

    Also, I tried using an integer number to version my robot, but integers don’t work (use a string, such as ‘12′ instead of 12):

    sun.reflect.NativeMethodAccessorImpl invoke0: TypeError: can’t dup Fixnum
    /base/data/home/apps/remembry/1.339257167247162572/WEB-INF/gems/gems/rave-0.1.2-java/lib/models/robot.rb:16:in `version’

    In addition, it used to be that the packaged gems were configured in the Warbler::Config block in config/warbler.rb, like this:

    Warbler::Config.new do |config|
      config.gems = %w( rave json-jruby rack builder hpricot )
      config.includes = %w( robot.rb appengine-web.xml )
    end

    But it appears that the new config.yaml file is the place to put gems and other configuration:

    robot:
      name: Remembry Bot
      image_url:
      version: ‘9′
    appcfg:
      version: 1
    gems:
      - hpricot

    And finally, in order to accomplish my task, I needed to use Ruby’s Mechanize library but because the latest version of Mechanize depends on Nokogiri which in turn depends on Ruby’s Foreign Function Interface (FFI), I had to downgrade from Mechanize 0.9.3 to 0.8.5.  According to this google forum, FFI will never be supported in App Engine.

    More details on this project to come later!

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Discipline

    The word “discipline” connotes both external discipline (”That child is misbehaving—he needs to be disciplined”) as well as internal discipline (”He is a disciplined learner.”).  But I don’t think these two meanings have any relationship with one another—children do not improve the executive function of their minds via external discipline.  In fact, I think they learn in spite of external discipline.  From the research I’ve been listening to, the executive function is a more recent adaptation of the human brain (in evolutionary time) and is therefore one of the weakest and most prone to being disabled during stressful periods.  If that’s the case, then “disciplining” a child with external stressors such as a spanking would actually lead to less internal discipline/executive function.

    As Kelty recently said, “When you go to the principal’s office, you just want to get through it.  No one comes out of that office saying to themselves, ‘I am a changed child!’”

    Posted via email from Duane’s Quick Posts

  • 2 Comments
  • Filed under: Uncategorized
  • Forgot to Mention the Cougars Game

    It’s old news now, but it was so fun to be with my family and see the BYU cougars win last November!

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • This is a really neat article about the transition science is taking right now as it reframes the “placebo effect” and its role in health and the search for improvements to the body’s natural (but limited) healing system:

    Benedetti often uses the phrase “placebo response” instead of placebo effect. By definition, inert pills have no effect, but under the right conditions they can act as a catalyst for what he calls the body’s “endogenous health care system.” Like any other internal network, the placebo response has limits. It can ease the discomfort of chemotherapy, but it won’t stop the growth of tumors. It also works in reverse to produce the placebo’s evil twin, the nocebo effect. For example, men taking a commonly prescribed prostate drug who were informed that the medication may cause sexual dysfunction were twice as likely to become impotent.

    Another tidbit from this article is that certain drugs are “better than placebo” when tested in France but not when tested in the USA.  Apparently there are social considerations as well as individual effects.

    Also, the following snippet was interesting too–a 3-way placebo trial was undertaken with no actual drug or treatment at all!  Here’s how it went:

    In a study last year, Harvard Medical School researcher Ted Kaptchuk devised a clever strategy for testing his volunteers’ response to varying levels of therapeutic ritual. The study focused on irritable bowel syndrome, a painful disorder that costs more than $40 billion a year worldwide to treat. First the volunteers were placed randomly in one of three groups. One group was simply put on a waiting list; researchers know that some patients get better just because they sign up for a trial. Another group received placebo treatment from a clinician who declined to engage in small talk. Volunteers in the third group got the same sham treatment from a clinician who asked them questions about symptoms, outlined the causes of IBS, and displayed optimism about their condition.

    Not surprisingly, the health of those in the third group improved most. In fact, just by participating in the trial, volunteers in this high-interaction group got as much relief as did people taking the two leading prescription drugs for IBS. And the benefits of their bogus treatment persisted for weeks afterward, contrary to the belief—widespread in the pharmaceutical industry—that the placebo response is short-lived.

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Why not write log files in JSON format?

    Log files were invented long before the JSON data exchange format existed.  In fact, they bring a sort of crisp 1970s feel whenever I look at them… text files streaming across a terminal screen.  It’s almost like the Matrix—anyone who sees text files streaming across a terminal instantly believes we might be hackers.  But I don’t think log files are that cool.

    To be honest, I wonder why they are still in line-text format.  I realize it’s good to be able to process log files quickly (grep, sed, perl), but imagine the useful metadata that could be gleaned from log files—if only they allowed for metadata.  Is it time to start producing JSON log files?  It might be worth a look.  Here’s why I began moving in this direction.

    I first started noticing a need for something more than a line of text when this sort of thing started showing up in my log files:

    I, [2009-12-16T13:24:59.264678 #13623]  INFO — : [app:des.rb, line:26] Encode file: blah -> 

    The area of focus here is the second set of square brackets, [app:des.rb, line:26].  I was essentially starting to “tag” my log output so that I could tell where the lines were coming from.  Next, I realized some of the log lines that were reporting the results of executing external commands could benefit from metadata.  I started tagging my log lines with things like “shell:true” with additional metadata such as “process_id:39212″ and “status_code:0″ (process return code for “success”).

    Finally, I started to wonder, “Why am I not using JSON for this?”  I couldn’t think of a good reason except that JSON requires an (opening square brace) [ to begin and a (closing square brace) ] to end.  Why not add an open square bracket to the beginning of an empty log file, and let it hang open forever?  Here’s my new Ruby logging code:

    log(”Encoding file”, :level => “info”) # info is the default and can be omitted
    log(”Unable to encode”, :level => “error”, :reason => “missing command ‘des’”)

    The resulting log file looks like this:

    [{"level":"info","msg":"Encoding file","time":"2009-12-16 14:15:10 -0600","caller":["\/Users\/duanejohnson\/bin\/test.rb:10:in `<main>'"]},
    {”level”:”error”,”reason”:”missing command ‘des’”,”msg”:”Unable to encode”,”time”:”2009-12-16 14:15:10 -0600″,”caller”:["\/Users\/duanejohnson\/bin\/test.rb:11:in `<main>'"]},

    The hanging comma allows new JSON objects (hashes, essentially) to be appended to the end of the file.  A JSON reader then just has to replace the last comma with a closing square brace and it becomes a valid JSON file that can be imported to a database, or searched arbitrarily.  It’s still quite easy to use awk and grep, too, since each “object” ends in both a comma *and* a newline.

    Finally, there is a simple way with the common unix tool ’sed’ to replace the final comma with a closing brace, thus making it fairly easy to deal with the hanging comma (thanks to some helpful people at stackoverflow for this suggestion):

    sed ‘$ s/,$/]/g’

    So, for example, you could fix the hanging comma with the following:

    cat ruby.hanging.json | sed ‘$ s/,$/]/g’ >ruby.log.json

    I like being able to store more information in my log files this way.  It seems to fit my need to zoom in on data subsets and find answers to meaningful questions.  Is there anyone else who feels the same way?

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • This looks like an important discovery in psychology:

    In an exciting breakthrough for psychological science, researchers in the United States have demonstrated a drug-free way to prevent the return of a learned fear. Similar memory modification effects have been observed before, but these experiments have involved drugs such as the beta-blocker propranolol. It’s hoped the new drug-free procedure will lead to improved therapeutic techniques for people with phobias or intrusive traumatic memories. 

    Basically, there is a very high success rate for “unlearning” a fear if the fear is recalled 10 minutes prior to a training session in which the fear stimulus does not result in the feared outcome.  The amygdala essentially allows feelings surrounding the trauma to be forgotten even though the memory of the experience persists.

    – Duane

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • I like where this theory is going.  I think it deserves more discussion:

    Today, Ellis and Rothman introduce a significant new type of block universe. They say the character of the block changes dramatically when quantum mechanics is thrown into the mix. All of a sudden, the past and the future take on entirely different characteristics. The future is dominated by the weird laws of quantum mechanics in which objects can exist in two places at the same time and particles can be so deeply linked that they share the same existence. By contrast, the past is dominated by the unflinching certainty of classical mechanics.

    They point out, for example, that this crystallization process doesn’t take place entirely in the present. In quantum mechanics the past can sometimes be delayed, for example in delayed choice experiments. This means the structure of the transition from future to past is more complex than a cursory thought might suggest.   

    The part that seems most significant is the way it ties quantum dynamics to classical or relativistic mechanics.  The uncertainty that lies in the future just can’t be treated like a classical model, except in very narrow cases where all of the parameters are carefully controlled.  In the large majority of cases, small quantum effects trigger larger effects that go on to affect the final outcome in unpredictable ways.

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized