Posts

Showing posts from July, 2012

More Clojure Datomic experiments: decoupling data building and transactions, and adding text search

I wrote two days ago and yesterday about my experiments for getting up to speed on Datomic. In the Datomic news group, Rich Hickey suggested that I keep any helper code for data-building separate from helper code for managing database access/transactions. I have reworked my code and added code to experiment with text search. Now that I have a few days of experimenting with Datomic I think I understand how I will structure an application for a side project: write a small helper library that is application independent, much as the code snippets in this article. Write another application specific helper library that layers on top of the application independent library that encapsulates all data store functionality that I will need, and unit test this separately. Then I can write the application layer that will probably not have any Datomic application specific code. After I finish the first version of my side project this morning then I will help my customer on his Datomic project. ...

A little Clojure wrapper for Datomic

I wrote yesterday about getting started with Datomic in a lein based project. Probably because I am not up to speed with Datomic idioms, a lot of the data boilerplate bugs me so I wrote a little wrapper to hide all of this from my view. Starting with a some code by Michael Nygard I saw on the Datomic newsgroup I wrapped creating database attributes and adding data to the data store. I formated the following code in a funky way to make it fit on this web page: (ns datomic-test.core (:use [datomic.api :as api])) (defn attribute [id t c doc] ; by Michael Nygard {:db/id (api/tempid :db.part/db) :db/ident id :db/valueType t :db/cardinality c :db/doc doc :db.install/_attribute :db.part/db}) (defn string-singleton-attribute [conn id doc] @(api/transact conn [(attribute id :db.type/string :db.cardinality/one doc)])) (defn string-multiple-attribute [conn id doc] @(api/transact conn [(attribute id :db.type/string :db.cardinality/many doc)])...

Using the Datomic free edition in a lein based project

Hopefully I can save a few people some time: I flailed a bit trying to use the first released version yesterday but after updating a new version (datomic-free-0.8.3343) life is good. Download a recent release, and do a local maven install: mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic-free -Dfile=datomic-free-0.8.3343.jar -DpomFile=pom.xml Setting a lein project.clj file for this version: (defproject datomic-test "1.0.0-SNAPSHOT" :description "Datomic test" :dependencies [[org.clojure/clojure "1.4.0"] [com.datomic/datomic-free "0.8.3343"]]) Do a lein deps and then in the datomic-free-0.8.3343 directory start up a transactor using the H2db embedded database: cp config/samples/free-transactor-template.properties mw.propreties bin/transactor mw.propreties When you run the transactor it prints out the pattern for a connection URI and I used this in a modified version of the Datomic developer's Clojure...

Using the new Bing Web Search API from Java and Clojure

I wrote a simple wrapper that is on github for calling the new API . The old API will not work starting in August 2012 so it was time to update. The README file on github has a simple example for using the JAR created by this project in a Clojure project (a pre-built JAR is also included in the github repository). The wrapper is simple, but will save you a few minutes writing one yourself if you need to use Bing Web Search in Java, Clojure, JRuby, etc. You get 100 free searches/day with the new API and there is a charge if you need more API calls per day.

New cellphone: Samsung Galaxy S III

My almost three year old Droid phone still works great and it was not so easy getting a new phone. What convinced me to upgrade was the Samsung Galaxy S III's screen resolution of 1280 x 720 pixels. Sure upgrading from Android 2.x to 4.x is nice, but having a high density screen makes reading email, browsing the web, reading using the Kindle app, etc. all feel very natural, even on such a small device as a cellphone. Also: the Netflix app is fantastic: unbelievably easy to watch video at this screen resolution, even on a tiny device. I have been an enthusiastic iPad owner, but I think that the Samsung Galaxy S III will replace using the iPad about half the time. I had thought about getting a Nexus 7 tablet for occasions then the iPad was bigger (and heavier!!) than what I needed it for. At least for now, a larger cell phone with a high density screen seems to fill that niche better. One thing that surprised me after using my old phone for almost three years: I didn't manua...

My simple hack for using local JAR files in my Clojure lein projects

Maybe I shouldn't share bad habits with people but occasionally I see articles for setting up local maven repositories, etc. for using local JAR files in Clojure lein based projects. I have a kludge for doing this simply. Now, I have to admit that I tend to use a lot of Java code and 3rd party JARs in my Clojure projects - nice if libraries are in Clojars, but if not I create a directory local_jars in a project directory, put any local JARs there, and instead of using lein deps and lein clean I use a Makefile like: deps: lein deps cp local_jars/*.jar lib/ clean: rm -f -r lib/* Really simple. A side benefit is that I use lein1 in some projects and lein2 in others. Using Makefile targets insulates me from mistakes using the incorrect version of lein. Anyone have a better way of doing this? Please let me know.

Secrets of a polygot programmer

I often read opinions about using the best tool for the job in reference to choosing programming languages, frameworks, and libraries. I am a polygot programmer but I am one mostly because I use languages and other software tools that my customers request. Seriously as a consultant I serve my customers' best interests and that process usually does not include trying to get their teams to pivot to use my favorite tools. For my own side projects I am for the most part happy enough to use any of the languages that I feel most comfortable with, my favorites being Ruby and Clojure, but I also really like to use Java and Common Lisp. I usually choose languages for my own projects based on available frameworks and libraires that I can build my code on, and more rarely because of specific language features. Yes, I feel a little heretical saying that! My secret for being comfortable with several languages is that I try to make the development experience similar across programming lang...

I have been loving Ubuntu 12.04

12.04 was released a few months ago but I just got around to upgrading my Toshiba U505 yesterday. I must say that I don't understand some of the negative comments about Unity that I have read. Unity feels intuitive and so far has just worked for everything I have tried. A minute of google'ing found directions for seting up desktop files in .local/share/applications/ . For an example, here is my .local/share/applications/rubymine.desktop file: [Desktop Entry] Version=1.0 Type=Application Terminal=false Exec=/home/rubymine/bin/rubymine.sh Name=RubyMine Icon=/home/rubymine/bin/RMlogo.svg Obviously change file names and paths as required for your apps and your system. Then anytime when I need to run RubyMine I tap the ALT key and the Unity search bar appears; I start typing the first few letters of RubyMine and when the icon pops up I just click it. I also set up IntelliJ this way for Clojure and Java development. I prefer this to creating task bar icons. Very similar to using Co...

I just released some NLP code for Pharo Smalltalk

After writing about Pharo Smalltalk the other day I started looking at some of my old projects. I created a new github repo for my Pharo code and I'll add code as I have time to re-test it and clean it up. There is not much there right now, just a part of speech (POS) tagger. Edit: 2017/05/20: much improved with summarization, entity detection, and classification. Enjoy!

Nice: OpenCyc version 4.0 has been released

The last release 2.0 was made available almost three years ago, so I was very happy to see that version 4 is available . OpenCyc is a knowledge base and ontology containing about 270K terms and 2 million triples. There are now many more links to outside (or OpenCyc) knowledge resources like DBPedia, UMBEL, Wordnet, etc. Check out the new features. I downloaded the Linux version (requires Java 6, 3 GB memory, and is only for 64 bit OSs and Java). I had no problems at all running it on 64bit Ubuntu and OS X Mountain Lion (developer preview 4) - it only took a few minutes to install and run. Just follow the instructions in the README.txt file and try the web interface at http://localhost:3602/cgi-bin/cg?cb-start Nice to see this the free version of Cyc getting support and development efforts. I would be very interested in hearing from people who have done projects with either OpenCyc or the OpenCyc OWL/RDF data. 9-9-2012 update: Alyona Medelyan provided a link for downloading ...

Using Dojo Mobile in Clojure Noir web apps

Image
I made a first cut at wrapping Dojo Mobile for use in Clojure Noir web app projects. If you want to try what I wrote this morning here is the github repo . The code is really crude. For example, I just embedded Javascript to test AJAX right in a Noir Clojure view file and I don't make full use hiccup. If I have time in the future, I would like to support a wide range of Dojo control elements and perhaps even use ClojureScript. Pull requests welcomed :-) Here is what it looks like on an iOS device: Controls work and look different on different devices. This is part of the magic that Dojo Mobile does for us. On the Android platform a selection list behaves like an Android selection list:

A shoutout and thanks to the Pharo Smalltalk developers

Pharo is a fork from the Squeak open-source Smalltalk and provides an incredibly rich development environment. As a consultant people pay me to design and write code in Ruby, Clojure, Common Lisp, and Java. That said, for non-work related experiments, Pharo is a lot of fun to use: a modern and free Smalltalk environment. I just wanted to say thanks to the Pharo team: great work! I recently downloaded the 2.0 development build - exciting to see new features. One thing in particular that strikes me as awesome about Pharo is that it is very light weight, using little memory and CPU resources. I wrote a blog 5 years ago about deploying Squeak to Linux servers. I am a little surprised that Pharo is not more widely used for rich web applications but with so many great languages and frameworks (Rails, Sinatra, Clojure Noir, Java Play Framework, GWT, etc., etc.) there is a lot of competition for developer mindshare. My personal interest in Smalltalk started when I got a Xerox 1108 Lisp Mach...

Code examples for a Dojo Mobile one page application. Backend in Ruby/Sinatra

I wrote a few days ago that I am excited about how easy it is to make simple one page web apps using Dojo Mobile that look good and work fine on portable devices (Android and iOS) and regular web browsers. I don't do a lot of UI development for my work but when I do write web apps it is great to also be able to support mobile devices with a small amount of additional simple code. In this post I will show you hopefully useful code snippets for cookingspace.com that may save you some time if you want to write the same type of apps. Last weekend I decided that I wanted a new mobile web interface to my old Cooking Space web site. I wanted to be able to quickly look up a recipe on my cellphone, see the ingredient list, and be able to specify how many people need to be served. I also want to see the nutrition data for the recipe. A top level requirement is that once the web page renders then everything is updated with AJAX. There are only two user interactions: Enter a few search term...

Experimenting with Dojo Mobile

In my work I specialize in Natural Language Processing (NLP), text mining, and general AI development. That said I find myself writing a lot of web apps and what I really want is an easy to use web client stack with rich controls and that facilitates writing one web app that looks and works OK in web browsers, Android phones and tablets, iPhones, and iPads. Five years ago I wrote a very simple web app cookingspace.com that let me look up the nutrients (using the USDA nutrition database) for recipes we frequently make. I have just spent a few hours rewriting the front end using Dojo Mobile, removing a lot of features that I don't need anymore that is hosted at mobile.cookingspace.com . The new app lets me quickly check nutrients and also on portable devices I can use it while grocery shopping to make sure I get the ingredients I need for making dinner. Both apps are deployed at Heroku (thanks Heroku!). Dojo is really a nice web client toolkit. I suggest you take a look if you ...