Touch Monitors Are On My Wishlist

I think I want touch screen monitors for my work and home desktops. I might be one of the few who still uses a desktop, but my quirky thoughts on the coming obsolescence of laptops as a form factor can be saved for another time.

The appeal of touch monitors is not to replace my mouse or keyboard, but rather to do the things they aren’t terribly great at. For example when I want to re position my cursor from my browser on one monitor to a specific location in my text editor on another, neither the mouse nor the keyboard are able to do this with the level of efficiency that a touch screen enables. To illustrate what I mean it helps to detail the steps a bit.

With the mouse I first have to find the cursor. This is normally not so difficult and there are even tools to help, but it is a task none-the-less. It gets a little worse if the window currently in focus doesn’t have the mouse within its space. Usually what happens is I wiggle my mouse or finger on the track pad and find the movement with my eye. With dual monitor setups this is yet less trivial.  Step two involves navigating the pointer to the next location. Step three is clicking to place the cursor. Step four is placing my hands back on the keyboard to start typing.

With a keyboard there are so many options for keyboard shortcuts and paths to accomplish the task that whatever steps I chose someone could just say, ‘well my [secret hidden] way is much simpler’ and probably be right, but a typical person like myself in a typical scenario as I often find myself in might use alt+tab to select a new window to focus from the list of open windows, and either press that multiple times until they land on the one they want or use arrow keys. In Ubuntu this method uses icons and I have to remember which icon belongs to the program window I want to focus on (text editor). Add two more little steps if I happen to have two text editor windows open so that I pick the right one. Once I get the right window in focus. I hunt down the blinking cursor with my eye and move the cursor with the arrow keys (or in my case nimble well trained fingers with lots of keyboard keys in combination that are faster than using only arrow keys.) to the desired location.

With a touchscreen I could simply reach up and touch the place on the screen I want the cursor to now be at, put my hand back on the keyboard and start typing.

And there are probably infinite combinations of using all three interaction avenues to accomplish the task depending on if it involves multiple windows of the same application, minimized or hidden windows, scrolling to window content that is out of view, tabs within the application, windows on other virtual desktops, etc.

Anyway long boring bit about HCI, but point of it is that I think touch is here to stay because it is a intuitive and useful way of interacting with computers. It has been overplayed so much that I kinda hate bringing up how effortlessly my kids use a tablet, but seriously, they do, and observing them on it is part of why I am thinking about this. Personally I don’t think touch interaction will replace keyboard, mice, or track pads on platforms where those already dominate. Touch screens will merely compliment them very nicely. And as cool as other interaction methods such as eye tracking, voice recognition, or body gesture readers are conceptually, for the near future at least, I see those as only being practically applicable for niche cases whereas touch seems beneficial in many more scenarios. My take away from all these thoughts is probably nothing all that revelatory or novel. It is simply that it doesn’t matter what sort of device you are designing your application GUI for anymore, you need to consider if, where, and how to make it touch friendly because, even if your particular platform doesn’t have touch capabilities now, I guess the odds that it will in the future are increasing rapidly.

trying out zsh and oh-my-zsh on ubuntu

Using the terminal all day I figured I should ‘sharpen the axe’ a bit. I have played around with configuring bash, but mostly I don’t know what I am doing in that .bashrc file. I tried a few ways to get the terminal tab titles to be something shorter so they would actually be usefull for example. no luck there. Tried customizing the prompt to include git status if I was in a git repo. Got that one to sorta work, but screwed up some other stuff in the process…

Noticed zsh is a alternative that has a vocal fan base, thought I’d see if it lived up to the hype. I’ve been using it for a couple months now but so far I think I like it, and I am sure I have only scratched the surface of what it is capable of. which was probably true of bash as well…

Anyway, installing isn’t to hard, but not very obvious so I thought I would document how I did it to see if anyone wanted to chime in on how I did it wrong, or possibly would find it usefull.

First install zsh package from Software Centere or using apt-get install zsh
Use bash terminal one last time to install oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh)
open edit>profile preferences in the terminal menu
on the second tab ‘Title and Command’ check ‘Run custom command instead of my shell’ and enter ‘zsh’ in the text input.
Restart Terminal
Viola!

edit .zshrc as desired.

Grails and Spine.js decoupled development setup

Using Grails as the API server for a spine app and Spine.js as a front end framework has been going well. My Spine app has up till now lived in the web-apps directory of my Grails app. After living with this arrangement for a while I started to realize how separating the two even further would have many all-around advantages. Decoupling code makes new projects easier to manage by isolating versioning, testing, deployment/release for example.

In production environments this sort of setup isn’t all that uncommon, you let Apache or something like it serve static image, js or css files and use mod_jk or some proxy setup to pass the rest on to Java app server like Tomcat.

My setup is a little different in that I want to serve html and js and have to make sure all relative links still work for ajax API requests, and locally there is a cross domain issue if you try to simply work from files in the browser and make calls to Grails running on Tomcat

Long story short; to get my decoupled dev setup here is what I did:

  1. Install Apache
  2. Get it running
  3. Set up virtualhost that will proxy appropriate requests to Grails (need mod_proxy_http)
  4. Add alias definitions for Spine apps

Steps one and two are relatively standard stuff. On Ubuntu it is trivially easy. (sudo apt-get install apache2)

Step 3 was new to me. Searching turned up a good starting point on that, but simply proxy isn’t what I really needed. That brings us to step 4. I needed some interceptors (Alias’) for my spine apps, so that relative links still played nice. For example, I wanted ‘http://localhost/grailsApp/spineApp/’ to direct to my Spine app, while links within the spine app like ‘../api/book/5′ were handled by Grails. an old forum post contained the nugget I was looking for.

Basicially this is what I needed inside of my virtualhost block:

ProxyPass /grailsApp/spineApp !
Alias /grailsApp/spineApp /path/to/spineApp/on/fileSystem

ProxyRequests Off
ProxyPreserveHost On

ProxyPass /grailsApp http://127.0.0.1:8080/grailsApp
ProxyPassReverse /grailsAPp http://127.0.0.1:8080/grailsApp

Grails config will have to change to handle redirects and such in grails controllers, that setting is normally in grails-app/conf/Config.groovy

environments {
development {
grails.serverURL = "http://localhost/grailsApp"
...

flattr this!

Customized Grails Controller for REST

Update: new code https://gist.github.com/4152409

Grails can do RESTfull easily enough, but I wanted a restful API from grails without throwing out grails scaffolding, So I decided to customize Grails’ controller template.

grails install-templates

then in [app-name]/src/templates/scaffolding/Controller.groovy

import org.springframework.dao.DataIntegrityViolationException
import grails.converters.XML
import grails.converters.JSON

class ${className}Controller {

	static allowedMethods = [list:'GET',
		show:'GET',
		edit:['GET', 'POST'],
		save:'POST',
		update:['POST','PUT'],
		delete:['POST','DELETE']
	]

	def index() {
		redirect(action: "list", params: params)
	}

	def list() {
		params.max = Math.min(params.max ? params.int('max') : 50, 200)
		def list = ${className}.list(params)
		def listObject = [${propertyName}List: list, ${propertyName}Total: ${className}.count()]
		withFormat {
			html listObject
			json { render list as JSON }
			xml { render listObject as XML }
		}
	}

	def create() {
		[${propertyName}: new ${className}(params)]
	}

	def save() {
		def ${propertyName} = new ${className}(params)
		if (!${propertyName}.save(flush: true)) {
			withFormat {
				html {render(view: "create", model: [${propertyName}: ${propertyName}])}
				json {
					response.status = 403
					render ${propertyName}.errors as JSON
				}
				xml {
					response.status =403
					render ${propertyName}.errors as XML
				}
			}
			return
		}
		flash.message = message(code: 'default.created.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), ${propertyName}.id])
		withFormat {
			html {
				redirect(action: "show", id: ${propertyName}.id)
			}
			json {
				response.status = 201
				render ${propertyName} as JSON
			}
			xml {
				response.status = 201
				render ${propertyName}.id
			}
		}
	}

	def show() {
		def ${propertyName} = ${className}.get(params.id)
		if (!${propertyName}) {
			withFormat {
				html {
					flash.message = message(code: 'default.not.found.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
					redirect(action: "list")
				}
				json { response.sendError(404) }
				xml { response.sendError(404) }
			}
			return
		}
		def object = [${propertyName}: ${propertyName}]
		withFormat {
			html {object}
			json { render object as JSON }
			xml { render object as XML }
		}
	}

	def edit() {
		def ${propertyName} = ${className}.get(params.id)
		if (!${propertyName}) {
			flash.message = message(code: 'default.not.found.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
			redirect(action: "list")
			return
		}
		[${propertyName}: ${propertyName}]
	}

	def update() {
		def ${propertyName} = ${className}.get(params.id)
		if (!${propertyName}) {
			withFormat {
				html {
					flash.message = message(code: 'default.not.found.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
					redirect(action:"list")
				}
				json { response.sendError(404) }
				xml { response.sendError(404) }
			}
			return
		}

		if (params.version) {
			def version = params.version.toLong()
			if (${propertyName}.version > version) {
				${propertyName}.errors.rejectValue("version", "default.optimistic.locking.failure",
						  [message(code: '${domainClass.propertyName}.label', default: '${className}')] as Object[],
						  "Another user has updated this ${className} while you were editing")
				withFormat {
					html {render(view: "edit", model: [${propertyName}: ${propertyName}])}
					json { response.sendError(409) }
					xml { response.sendError(409) }
				}
				return
			}
		}

		${propertyName}.properties = params

		if (!${propertyName}.save(flush: true)) {
			withFormat {
				html {render(view: "edit", model: [${propertyName}: ${propertyName}])}
				json {
					response.status = 403
					render ${propertyName}.errors as JSON
				}
				xml {
					response.status = 403
					render ${propertyName}.errors as XML
				}
			}
			return
		}
		withFormat {
			html {
				flash.message = message(code: 'default.updated.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), ${propertyName}.id])
				redirect(action: "show", id: ${propertyName}.id)
			}
			json {
				response.status = 204
				render ${propertyName} as JSON
			}
			xml {
				response.status = 204
				render ''
			}
		}
	}

	def delete() {
		def ${propertyName} = ${className}.get(params.id)
		if (!${propertyName}) {
			withFormat {
				html {
					flash.message = message(code: 'default.not.found.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
					redirect(action: "list")
				}
				json { response.sendError(404) }
				xml { response.sendError(404) }
			}
			return
		}
		try {
			${propertyName}.delete(flush: true)
			withFormat {
				html {
					flash.message = message(code: 'default.deleted.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
					redirect(action: "list")
				}
				json {
					response.status = 204
					render ''
				}
				xml {
					response.status = 204
					render ''
				}
			}
		}
		catch (DataIntegrityViolationException e) {
			withFormat {
				html {
					flash.message = message(code: 'default.not.deleted.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
					redirect(action: "show", id: params.id)
				}
				json { response.sendError(500) }
				xml { response.sendError(500) }
			}
		}
	}

}

then modify your UrlMappings.groovy file to look something like this:

class UrlMappings {

	static mappings = {
		"/$controller/$action?/$id?"{
			constraints {
			// apply constraints here
			}
		}
		name api0: "/api/$controller/$id"(parseRequest:true){
			action = [GET: "show", PUT: "update", DELETE: "delete"]
			constraints {
				id(matches:/\d+/)
			}
		}

		name api1: "/api/$controller"(parseRequest:true){
			action = [GET: "list", POST: "save"]
		}
	}
}

I found the JSON Restful plugin a while after I already did most of this, so that is another way to go. Other than it having some issues in grails 2 right now it looks like a really good option, but one thing I like about my approach is that if you want to customize your API in fine detail you can do so. You can always generate individual controllers and modify them of course. Another option is registering custom marshallers. The simple example for customizing your JSON output without changing any controller code would be doing something like this in your Bootstrap.groovy

import grails.converters.JSON
class BootStrap {
  def init = {servletContext ->;
    JSON.registerObjectMarshaller(Person) {
      def returnArray = [:]
      returnArray['name'] = it.name
      returnArray['addrs'] = it.addresses
      return returnArray
    }
    ...
  }

...

flattr this!

RESTfullness and web-frameworks

After working on an offline mobile web app that integrated with a Grails backend, and after that being prompted to explore options for a new some green field development, which lead me to re-evalutate things like REST to NoSQL to MVC frameworks in general to mobile frameworks, to front-end frameworks in general. I feel like I have started to form a more robust comprehension of where web-app development is headed in general, and most of the web-frameworks I know of seem to be missing it so far. This would be hard to articulate briefly, but blogs are good for taking a wild stab at that sort of thing, right? Disclaimer: this is just me sort of thinking out loud, so take it for what it is.

I am coming to the conclusion that I don’t think I want to use Grails anymore. Either that or I want to gut it of a lot of what it does. Sitemesh, don’t need it. Hibernate, don’t really want SQL database anymore, schema’s are so restricting/un-agile, so don’t need it. GORM, dislike it about as much as I find it useful, so could really take it or leave it. if you end up working with a object DB then it is pretty much an unnecessary abstraction anyway. Groovy, well I like it better than Java, but honestly Scala seems like it might be the most promising language on the JVM, and for that matter other non-JVM languages have plenty of appeal too. Resources plugin, Tablibs (built in or customizable), Scaffolding and Templates, i18n… better handled by a front-end framework.

Or…  RESTfullness and MVC are beautifully simple things, and these plus the idea that next generation web applications can no-longer count on consistent and/or high-speed connectivity, but can count on robust javascript engines on the client side means that pushing as much of the application to the client as possible is now something to strongly consider. . Grails (and lets not just pick on Grails, most web-frameworks I know of) is still stuck in the paradigm where views are generated server-side .

Grails, again, to be fair, this seems to be a pattern for web frameworks in general, has been advancing in ways that make it more powerful and thus more complex, not less. True it does a decent job of hiding that complexity away most of the time, but even so, what if  its being there is all unnecessary in the first place? The trend in the way people are using their computers/devices would seem to me to drive rich apps working on the client-side with relatively simple storage and syncing services that they connect to. Maybe what it means for web-frameworks to evolve at this point means to specialize, simplify, and strip down.

flattr this!

SSH tunneling in Ubuntu

I wanted to work with a PostgreSQL DB remotely with PgAdmin, but I didn’t really want to figure out how to allow the DB to accept external connections in a secure way. Since I have SSH access this should be very doable. I have seen co-workers use putty for SSH tunneling before, and had previously used Putty on Ubuntu to copy that, but setting up my Natty workstation I figured there had to be a more native way to do it. Of course I could do tunneling straight from the command line. If I could ever remember the steps for it that approach would work great. Instead I found a tool called Gnome SSH Tunnel Manager (gSTM) and installed that from the Ubuntu repos. It is pretty straight forward to configure if you understand the concept of tunneling, which I only barely do, so I needed a little help getting set up, but after that it is dead simple.

  1. Install gSTM and start it up.
  2. Click ‘Add’ for a new tunnel bookmark, and name it.
  3. Add IP and user login for remote machine.
  4. Leave port and privatekey as default (unless you know what they are used for in which case you probably know what to put in there).
  5. In the port redirection section click ‘Add’, a new dialog will appear.
  6. Type is ‘local’.
  7. ‘Port’ is the port on your local machine you want to assign the tunnel to (I did 5666).
  8. ‘To host’ can be set to ‘localhost’.
  9. ‘To Port’ is the port used on the remote machine. default PostgreSQL is 5432.
  10. Click ‘OK’ and all the settings are done for gSTM so click ‘OK’ again to close the settings dialog.
  11. Highlight new tunnel, and click ‘Start’ – it should prompt you for the ssh password.
  12. Ta-da!
  13. Now use pgAdmin, or  another application to connect to the DB at localhost:5666 (or whatever port you set in step 7 above..).

Now I just need to make sure my tunnel is running in order to have access to the DB locally. Very cool! Probably where I got most confused was with the ‘To host’ and ‘To port’ settings, the wording seems backwards. Is that just me?

flattr this!

Jan 2010 Ubuntu Browser Benchmarks

A follow-up of this.

Note: I am just comparing Javascript. This is no longer a good way to benchmark a whole browser, if it ever was… but it is just interesting to me, and gives one metric that is an important one.

Environment is Ubuntu 10.10 64bit on Core2Quad@2.66Ghz

Browser Version Sunspider result
Chromium 10.0.634.0 277.2ms +/- 1.8%
Midori 0.2.9 388.5ms +/- 1.0%
Epiphany 2.30.2 382.0ms +/- 2.4%
Opera 11.00 352.6ms +/- 1.8%
Firefox 3.6.14pre 1883.8ms +/- 2.6%
Swiftfox 3.6.12 1068.2ms +/- 2.3%
Firefox 4b10pre 283.6ms +/- 5.0%

All the browsers have advanced pretty well. Once Firefox 4 finally ships I’d say the playing field is pretty level for javascript performance in browsers on Linux. In real world usage I just don’t know that anyone would be able to distinguish a speed difference between the browsers when it comes to javascript. The next pieces browsers need to keep working on are HTML5 and CSS3 implementations, Hardware acceleration for 2D and 3D rendering, and additional browser features, like extensibility and ‘installable’ web apps.

As a web developer I am excited about where things are going, and how the web as a platform is advancing. Native (meaning native to the OS/Desktop environment) applications aren’t gone yet, and probably won’t be for a long time yet, but they are needing a better and better excuse to not move into the browser. What would be the benefit of that you ask? The same that Java Swing, Adobe AIR and others have tried to achieve. OS independence. You write it for Firefox according to defined standards and it should work on all browsers that implement the same standards on all the OS’s. That is a big deal! I think a couple prime candidates for proof of concept browser apps would be all the little games normally included in Ubuntu. Mines, Solitaire, Tetris clones etc. and maybe the social networking client like Gwibber. If only I had more time to play…

Update: I played some with Tetris in a browser idea

flattr this!

A Service is not a Product

A recent article details How Google Is ‘Closed’, Just Like Apple

I have to disagree. They may both have aspects that are closed, but they are definitely not ‘just like’ each other. Apple sells a product that is closed, Google sells a service that is closed. The difference is crucial, and should be obvious to anyone who has taken business 101. Some companies make money on a product some on a service. A closed service is nothing new, and doesn’t offend me (though it may entrap me). A closed product is a new concept. It is offensive because it restricts me in new ways that I am not accustomed to evidenced by new laws that have to be created to enforce the restrictions. I would add that if these restrictions actually were justifiable we wouldn’t need new laws to enforce them and thus wouldn’t feel offended.

Apple has plenty of closed services as well by the way, so they may qualify as doubly closed, or maybe closed squared?

flattr this!

my sunspider test results for Sept.

Run on Ubuntu 10.04 64bit on core2quad@2.66Ghtz

Browser Version Sunspider result
Chromium 7.0.530.0 336.0ms +/- 9.1%
Midori 0.2.8 366.4ms +/- 2.1%
Epiphany 2.30.2 454.4ms +/- 3.8%
Opera 10.62 397.8ms +/- 2.8%
Firefox 3.6.11pre 1805.0ms +/- 3.0%
Swiftfox 3.6.10 955.0ms +/- 1.3%
Firefox 4b7pre 462.6ms +/- 7.9%

Chromium is still leading the pack, but it’s lead is not as dramatic as it used to be. Firefox 4 is shaping up to be a pretty stellar browser overall. Still waiting for the UI on Linux to get some love though. Swiftfox, which is essentially Firefox optimized for specific chip architectures, is interesting. It is almost twice as fast in this benchmark compared to standard Firefox . Maybe Firefox should do this themselves if they want to eek out some extra performance, but I suppose there are reasons not to as well.

Looking back it is pretty impressive how much faster browser javascript has gotten over the last couple years.

flattr this!

Pragmatism, Idealism, Tension and Balance

A friend and I got into a brief discussion around audio codecs and licence restrictions today as we talked about working on something together – specifically why Firefox doesn’t support mp3 in their audio tag. Other discussions we have had hit on this idea of pragmatism vs. idealism. Today I was reminded of this now-out-of-date article that still had some interesting points to make (while also making dumb points along the way).

What I gleaned from the article is that there can be a good sort of balance these perspectives can bring each other. That balance is achieved in a tension between not completely ignoring the reality of the situation, and not completely capitulating on principles that matter.
It seems to me this thought can be applied more broadly to things outside the realm of software development. Church practice, politics, family life, etc. In most things I tend to find myself farther to the side of the spectrum of “we can’t compromise on principles”. Some people I have relationships with tend to balance my perspective with their “don’t be unrealistic” perspective. There can be some tension in those relationships in the process, but I am finding myself appreciating that more than I used to. The tension can be a good thing.

flattr this!