Thursday, December 29, 2011

[Workaround] Ripple Riak Access via Solr Interface

Riak and Ripple are both undergoing heavy development. If you are relying on using Ripple to enable_searching on a new bucket, you'll need my fork or the monkey-patch below.

# Monkey-patch a broken Solr interface...                                                                                                   
module Riak                                                                                                                                 
  class Bucket                                                                                                                              
    def is_indexed?                                                                                                                         
      props['search'] == true || (props['precommit'] && props['precommit'].include?(SEARCH_PRECOMMIT_HOOK))                                 
    end                                                                                                                                     
    def enable_index!                                                                                                                       
      unless is_indexed?                                                                                                                    
        self.props = {"precommit" => ((props['precommit']||[]) + [SEARCH_PRECOMMIT_HOOK]), "search" => true}                                
      end                                                                                                                                   
    end                                                                                                                                     
    def disable_index!                                                                                                                      
      if is_indexed?                                                                                                                        
        self.props = {"precommit" => ((props['precommit']||[]) - [SEARCH_PRECOMMIT_HOOK]), "search" => false}                               
      end                                                                                                                                   
    end                                                                                                                                     
  end                                                                                                                                       
end     

Wednesday, December 28, 2011

[Workaround] Dnsruby GEM not working on Heroku

The rationale is in this google group:

*blah* *blah* Errno::ECONNREFUSED *blah* *blah* on heroku trying to open listening socket on localhost

The solution: after you require 'dnsruby', add this line:

require 'dnsruby'
# Patch Dnsruby which is broken on Heroku:
module Dnsruby; class SelectThread;     def get_socket_pair; srv = nil; srv = TCPServer.new('::1', 0); rsock = TCPSocket.new(srv.addr[3], srv.addr[1]); lsock = srv.accept; srv.close; return [lsock, rsock]; end; end; end

You're welcome!

Monday, December 26, 2011

[Howto] Disable Chrome's Request Throttling

Visit: chrome://net-internals/#httpThrottling

Uncheck the checkbox:

And never see this message again:
Error 139 (net::ERR_TEMPORARILY_THROTTLED): Requests to the server have been temporarily throttled.

Sunday, November 13, 2011

[Workaround] Riak create object without key

Unfortunately today's java-riak interface does not allow creating objects without specifying a key. This means effectively sending a POST rather than a PUT and not including a key (or setting key=null). For my needs, I was calling the java lib through clojure. My workaround? Pre-manufacture UUIDs:

(defn riak-post [client bucket obj]
  (let [key (uuid/uuid)]
    (client/put client bucket key
                {:value (.getBytes obj)
                 :content-type "text/plain"})
    key))

Friday, November 04, 2011

[Resolved] Whirr on OS/X fails to package from source

If you found this, you're trying to build Apache's Whirr by following these instructions and running into an error at this step:

mvn package -Ppackage

And the error looks like:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (dist-assembly) on project whirr: Failed to create assembly: Error adding file to archive: /Users/jonathan/Projects/whirr-0.6.0-incubating-src/NOTICE-src.txt isn't a file. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

The solution is:

cp NOTICE.txt NOTICE-src.txt

You're welcome!

Friday, October 28, 2011

[Resolved] Ubuntu 10.04 LTS: checking for mysql_query() in -lmysqlclient... no

Building mysql gem fails with the errors at the end of the post. To resolve:

sudo apt-get install libmysqlclient-dev

Full logs of error for searchers:


Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb 
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/usr/local/rvm/rubies/ree-1.8.7-2011.03/bin/ruby
 --with-mysql-config
 --without-mysql-config
 --with-mysql-dir
 --without-mysql-dir
 --with-mysql-include
 --without-mysql-include=${mysql-dir}/include
 --with-mysql-lib
 --without-mysql-lib=${mysql-dir}/lib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-mlib
 --without-mlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-zlib
 --without-zlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-socketlib
 --without-socketlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-nsllib
 --without-nsllib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-mygcclib
 --without-mygcclib
 --with-mysqlclientlib
 --without-mysqlclientlib

[Resolved] Clojure + Tesseract + OSX

Trying to get https://github.com/antoniogarrote/clj-tesseract working on OS/X?
Here's the fix assuming you've brew install tesseract:
diff --git a/microcr/Makefile b/microcr/Makefile
index 90abace..67b841a 100644
--- a/microcr/Makefile
+++ b/microcr/Makefile
@@ -1,5 +1,5 @@
-INCLUDES = -I/opt/local/include/tesseract `pkg-config --cflags opencv`
-LIBS = -L/opt/local/lib -ltesseract_api `pkg-config --libs opencv`
+INCLUDES = -I/usr/local/Cellar/tesseract/3.00/include/tesseract `pkg-config --cflags opencv`
+LIBS = -L/usr/local/Cellar/tesseract/3.00/lib -ltesseract_api `pkg-config --libs opencv`
DYLIB = -arch x86_64 -dynamiclib -o libmicrocr.dylib
INSTALL_PATH = -install_name /usr/local/lib/microcr/libmicrocr.dylib
CC = g++
diff --git a/microcr/src/image.h b/microcr/src/image.h
index db335cd..bb11a91 100644
--- a/microcr/src/image.h
+++ b/microcr/src/image.h
@@ -1,8 +1,10 @@
#ifndef __IMAGE_H__
#define __IMAGE_H__
+#include
#include
#include
+using namespace std;
class Image
{

Thursday, September 22, 2011

Why? heroku[router]: Error H12 (Request timeout)

Those of you getting 500 errors from Heroku may find entries like this in the logs (heroku logs):

2011-09-22T11:43:49+00:00 heroku[router]: Error H12 (Request timeout) -> GET www.domain.com/controller/action dyno=web.1 queue= wait= service=30000ms status=503 bytes=0

The H12 is a Heroku routing layer-specific problem. It indicates your request took over 30 seconds (why is for another post).

In Heroku's words:

An H12 error happens when our routing layer intercepts a request longer than 30 seconds. The request is terminated and an HTTP 504 (Gateway Timeout) response is returned to the client. Meanwhile, the dyno handling the request will finish processing. The dyno will not be able to handle further requests until processing is complete. If your app is seeing a lot of traffic, additional requests may queue behind the busy dyno, causing further H12 errors. For this reason, we recommend using the 'rack-timeout' plugin - https://github.com/kch/rack-timeout - to limit request time in your app.