Eamonn O'Brien-Strain

MastodonBlueskyThreads


layout: post ref: http://www.uclassify.com/UrlApiDocumentation.aspx categories: Programming


uClassify – URL API Documentation


JavaScript code to make your website comply with the new EU Cookie Law.



layout: post title: Feeling Like JQuery Is Too Bloated? ref: https://web.archive.org/web/20121028233133/http://ender.no.de:80/ categories: Programming


Feeling like JQuery is too bloated? Ender provides an alternative package-manager approach for assembling light-weight JavaScript libraries.



layout: post title: Simple, clean pure-CSS tooltips ref: http://psacake.com/web/jl.asp categories: Programming


Simple, clean pure-CSS tooltips


http://javascript.crockford.com/private.html

Here are two different ways of defining a class in Coffeescript:

    class Container

      constructor: (@member) ->

      secret = 3

      dec = ->
        if secret > 0
          secret -= 1
          true
        else
          false

      service : ->
        if dec() then @member else null

    Container::stamp = (string) ->
      @member + string
    Container = (param) ->

      @member = param
      secret = 3

      dec = ->
        if secret > 0
          secret -= 1
          true
        else
          false

      @service = ->
        if dec() then @member else null

      null

    Container::stamp = (string) ->
      @member + string

Both of these define a class called Container with

  • a public field member initialized by a constructor parameter
  • a private field secret
  • a private method dec
  • a privileged method service
  • a public method stamp

We can use both in the same way:

    myContainer = new Container 'abc'

    console.log  myContainer.member      # abc
    console.log  myContainer.stamp 'def' # abcdef
    console.log  myContainer.service()   # abc
    console.log  myContainer.service()   # abc
    console.log  myContainer.service()   # abc
    console.log  myContainer.service()   # null

The version above on the left is the special class syntax that Coffeescript provides. However, to me, this extra layer of syntax seems to depart a bit from the “Coffeescript is just JavaScript” philosophy.

The version above on the right is a translation of Douglas Crockford's pattern, using his example.

Which is better? The left is a bit easier to read for a newcomer to the language, but I find the right more elegant because there is less “magic”.

And there is another advantage to the Crockford style. Consider this small modification:

    Container = (param, decrementBy) ->

      @member = param
      secret = 3

      dec = ->
        if secret > 0
          secret -= decrementBy
          true
        else
          false

      @service = ->
        if dec() then @member else null

      null

    Container::stamp = (string) ->
      @member + string

Here we have generalized the class by adding a decrementBy parameter to the constructor. We do not copy this to a property, but any of the private or privileged methods in the class can use it. (Don't you love closures!). There is no way to do this using the Coffeescript class syntax in a way that would prevent the decrementBy value being modified from outside the object.

I think I might switch to using the Crockford-style classes.


One of the really nice things about the sbt build system (for building Scala projects) or the coffeescript compiler is that they have a “watch” mode.

When you invoke a command in that mode (prepending with “~” (tilde) in sbt or adding the “—watch” argument to coffee) they continuously monitor your files and execute the compile or build action as soon as you save one of your source files to disk. Some IDEs, such as Eclipse, have that feature too — saving a file triggers an immediately compile.

But what if you are using an older build system like make, ant, or maven?

Well, if you are working on Linux, you can add this continuous build mode to any build system.

First, install inotify-tools, which on Ubuntu and similar distributions means doing:

sudo apt-get install inotify-tools

Then, for make, create an executable script called “~make” somewhere in your path with the following contents

#!/bin/sh -x

make $*
while inotifywait -e modify .
do
  make $*
done

Now where you would normally type

make something

you can type

~make something

and start editing files. Every time you save a file the make will execute.

For ant, maven, or any other command-line build system, just modify the script to replace make in the two places it occurs.



date: '2012-01-21 23:01:28' layout: post slug: day-after-occupy-protest-bank-modification status: publish ref: http://www.flickr.com/photos/eob/6740579771/ title: 'Day after Occupy protest: Bank Modification' wordpressid: '3184' categories: Society image: http://farm8.staticflickr.com/7145/67405797712acd3116d1_d.jpg image-text: Bank of America building on Montgomery St, San Francisco


Day after Occupy protest: Bank Modification

Walking down Montgomery Street in San Francisco, the day after an Occupy march, we saw that Bank of America had been subject to some modification.


If your users are also your customers, then you are lucky. It makes a lot of design and marketing decisions a lot simpler. You can focus laser-like on providing features that your users are willing to pay for.

However the user is not always the customer. For example, if you are selling software to a large enterprise then the person making the buying decision is not the user, which is why so much software used internally in large companies is so crappy.

And many of you working in the consumer Internet space have the same business model that broadcast television has had for more than half a century: give the service for free to users and get money from advertisers. To be successful you need to simultaneously keep your users (consumers) happy while keeping your customers (advertisers) willing to pay you. This is often hard.



date: '2011-06-19 15:48:26' layout: post slug: rest-nosql-capability-security-unified-document-creation-data-model status: publish ref: http://www.slideshare.net/eobrain/book-widget-embedding-automated-photodocument-publication-on-the-web-and-in-mobile-devices title: 'REST, noSQL, Capability Security, and a Unified Document-Creation Data Model ' wordpress_id: '1213' categories: Programming


View more presentations from Eamonn O'Brien-Strain

This is a presentation I gave earlier this year at the Electronic Imaging conference. There are more details in the paper that went along with the presentation.