Saturday, September 21, 2013

How to password protect a Pages file on iCloud

It took me awhile to figure out how to do this it so I thought I'd post it.

This isn't special for iCloud usage of course, it's for the Pages file in general which can be stored locally or on iCloud. It's very handy for accessing a sensitive doc from home, work or on the go with the phone.

Anyway, it's very easy. The feature is tucked away in the Inspector. See below.

Thursday, September 19, 2013

Drawing class diagrams or flow diagrams in ascii characters

I've always wanted this, and I have often thought about writing it. But I needn't.
This is great.

Drawing flow diagrams, or class diagrams in ascii.

| Comparison |
+------------+            e.g. Apple     e.g. Pear    e.g. Grape
                          +---------+   +---------+   +---------+
                          | Thing   |   | Thing   |   | Thing   |
                          |         |   |         |   |         |
                          +---------+   +---------+   +---------+

  +---------------+       +----------+  +----------+  +----------+
  |ComparisonPoint|       |Calculated|  |Calculated|  |Calculated|
  +---------------+       | Value    |  | Value    |  | Value    |
                          +----------+  +----------+  +----------+

  +---------------+       +----------+  +----------+  +----------+
  |ComparisonPoint|       |Calculated|  |Calculated|  |Calculated|
  +---------------+       | Value    |  | Value    |  | Value    |
                          +----------+  +----------+  +----------+

  +---------------+       +----------+  +----------+  +----------+
  |ComparisonPoint|       |Calculated|  |Calculated|  |Calculated|
  +---------------+       | Value    |  | Value    |  | Value    |
                          +----------+  +----------+  +----------+

                          +----------+  +----------+  +----------+
                          |Comparison|  |Comparison|  |Comparison|
                          | result   |  | result   |  | result   |
                          +----------+  +----------+  +----------+

         Strategy Pattern

        +-----------------------+        +----------------+
        |      Context          |        |   IStrategy    |
        |-----------------------|        |----------------|
        |                       +-------->                |
        | ctor(IStrategy)       |        |                |
        |                       |        | PerformWork()  |
        +-----------------------+        +---^------------+
                                             |                          +
                       |                          |
                       |                          |
        +-----------+--+-----+      +-------------+------+
        | ConcreteStrategyA  |      | ConcreteStrategyB  |
        |--------------------|      |--------------------|
        |                    |      |                    |
        | PerformWork()      |      | PerformWork()      |
        +--------------------+      +--------------------+

Wednesday, September 11, 2013

Install libraries into Clojure

This can be a bit confusing at the beginning, the loading of libraries into the Clojure project.
For this I use Eclipse and the excellent CounterClockwise.

The initial dependencies can be found in the Leiningen dependencies folder, shown below.

This is the initial project.clj file with one single dependency.

Adding the dependencies to the project.clj file

Doing the above will make Lein go and get the libs and place them in the dependencies folder as shown.

Not using Eclipse?

If Lein is installed, you can navigate to the project folder in the command line, terminal, and enter:
lein deps

Monday, September 9, 2013

Six Deadly Sins of Leadership - a comment

This post by Jack Welch and Suzy Welch appeared on Linked in and it struck a note with me. I feel that there is a lot in it that I think I agree with. I'm not sure if I'm entirely in agreement with the list or if it really matters whether I agree or not but there is, deep down in me, a healthy dislike of the mundane, uncreative and uninspired leadership/management here in the UK.

The main headings of the article are, the six deadly sins are:

  1. Not giving self-confidence its due.
  2. Muzzling voice
  3. Acting phoney
  4. Lacking the guts to differentiate
  5. Fixation on results at the expense of values.
  6. Skipping the fun part
The trouble with these lists are that they can only dumb-down what is a very serious problem. That's a bit unfair of me as its purpose is to highlight some problems and I guess it works at that. It's generated me to waffle on in this post to no-one in particular, so at least I'm thinking about it. But dumbing-down? Well probably. Or maybe just over-simplifying. Perhaps that's a nicer way to say it.

#1 - Not giving self-confidence its due

"Self-confidence is the lifeblood of success."

I'm not a great manager, or leader in the charismatic way, but I think and learn and challenge. Sometimes when time permits I can look up and innovate. But the above list of six things are not quite right, or in the right order. You do tend to associate precedence to the order of things and, Not giving self-confidence its due, isn't number one.
There are at least two equally important and crucial additional aspects to this. 
One - Not giving confidence or time to the person that lacks confidence. I have seen an environment where a person was not regarded highly for his talents. In fact the prevailing opinion of him was truely low. Behind the scenes, management would talk rather poorly of the person. I knew the person was bright, was hard-working, sharp, but there were issues. The transformation to this person's life, career and prospects are now profoundly improved because I worked at this, pressing  ahead with  support and mentoring. I remember that it took just one year from meeting this person to bring about significant change to him and the team.
Two - not dealing with the over-confident or arrogant.
This is tough and it takes good judgement and self-control. One person's arrogant is another person's genius. You must get it right but you must look at the personal interplay in the team and ensure that personalities are in control and in some sort of harmonious balance and that other potential stars are not being stifled. I've seen very dominant characters suppress others through bullying or sheer confidence. Whatever the method of handling this, it is important.

#2 - Muzzling voice

"Perhaps the most frustrating way that leaders underperform is by over-talking." 

Over-talking is bad. Yes I agree to that. But, over-talking is different to over-driving the discussion to your favour. I talk too much after coffee, but always listen to the input of the team. Collectively we know more and are greater than the sum of our individual voices. So I agree in general with the #2 but I think it's slightly off.

#3 - Acting phoney

"Can you spot a phoney  Of course you can – and so can your people. Indeed, if there is one widespread human capability, it is sniffing out someone who is putting on airs, pretending to be who they’re not, or just keeping their real self hidden. Yet too many leaders spend way too much time creating personas that put a wall between them and their employees. What a waste."

I didn't agree with this at first. I thought it over simplified what I imagined to be the real problem. But now I think I agree. There are a lot of "suits". Even if they don't wear them. Often they are well intentioned and well-ordered. Sometimes they are playing the corporate ladder of survival and progression. Maybe the companies need them. Maybe the company simply needs fewer of them. But there is a style that can be destructive to creativity and motivation. This needs to be understood and managed.

#4 - Lacking the guts to differentiate

"You only have to be in business a few weeks to know that not all investment opportunities are created equal. But some leaders can’t face that reality, and so they sprinkle their resources like cheese on a pizza, a little bit everywhere 
But leaders who don’t differentiate do the most damage when it comes to people. Unwilling to deliver candid, rigorous performance reviews, they give every employee the same kind of bland, mushy, “nice job” sign-off."

Yes I probably understand this and agree. But  headline problem for this list. I'm not sure because I haven't managed many managers.

#5 - Fixation on results at the expense of values.

"Everyone knows that leaders deliver. Oratory and inspiration without results equal…well, a whole lot of nothing. But leaders are committing a real dereliction of duties if all they care about are the numbers."

I like this one. One thought along these lines that I believe is with visual products for example. It is simply not good enough to provide function and expect to differentiate ourselves from the rest. If we can get people to love our product through aesthetics or service then we have values and we have pride.  There are many aspects to this results v values equation that I need to think about. I will waffle on some more in another post.

#6 - Skipping the fun part

"What a lost opportunity. Celebrating makes people feel like winners and creates an atmosphere of recognition and positive energy. Imagine a team winning the World Series without champagne spraying everywhere. You can’t! And yet companies win all the time and let it go without so much as a high-five."

I agree in the celebration part but celebration is not the only definition or expression of fun. Before that there is the fun of doing the job. I'm thinking particularly of a development environment here and there has to be a lot of appropriate fun. Interaction in the team, jokes, support, team work, banter - all useful where appropriate and sensitive to those who might feel alienated by certain behaviour.
Success comes daily. Solving a sticky bug, a change to a design, writing a good doc. It's not all big end-of-project celebrations.

Sunday, September 8, 2013

How to make a Clojure program executable (Mac or Linux)

1. Create the project

Using Eclipse (and CounterClockwise) create a new project to try this out.
Create the project using the Leiningen option, the default.

For this example I created a project named, getting-data

2. Edit the source file (:gen-class)

In the getting-data.core file, in the src folder:

Add the directive:

I have also added a simple "say hello" function.

(ns getting-data.core

(defn say-hello [n]
  (println "hello, " n))

(defn -main [& args]
 (say-hello "john"))

3. Edit the project.clj file - :main getting-data.core

(defproject getting-data "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.5.1"]]
  :main getting-data.core)

You can see the text  :main getting-data.core has been added.

4. Download Leiningen.

This needs to be done to run the executable from the command line. Counterclockwise instals its own version of Lein but we will need our own.
This is very simple.
Go to and download the script. You place the script where it can be executed, make it executable and run it. This will install Leiningen.

These are the instructions from the Leiningen page:
  1. Make sure you have a Java JDK version 6 or later.
  2. Download the script.
  3. Place it on your $PATH. (~/bin is a good choice if it is on your path.)
  4. Set it to be executable. (chmod 755 ~/bin/lein)
Downloading on the Mac will place the file into the Download folder. use the mv unix comand to move it and rename the file if needs be. You may need to remove a ".txt" extension of the file as you mv it to the ~/bin folder.

5. Navigate to the project in Terminal

This may be similar to this: cd ~/Documents/workspace/getting-data/

Check the files exist:

John-Mac-mini:getting-data John$ ls -l
total 16
-rw-r--r--  1 John  staff  202  7 Sep 19:56
drwxr-xr-x  3 John  staff  102  7 Sep 19:56 bin
drwxr-xr-x  3 John  staff  102  7 Sep 19:56 doc
-rw-r--r--  1 John  staff  298  8 Sep 13:56 project.clj
drwxr-xr-x  2 John  staff   68  7 Sep 19:56 resources
drwxr-xr-x  3 John  staff  102  7 Sep 19:56 src
drwxr-xr-x  3 John  staff  102  7 Sep 19:56 target
drwxr-xr-x  3 John  staff  102  7 Sep 19:56 test

Now just check the project file is correct:

Enter cat project.clj at the command line.

John-Mac-mini:getting-data John$ cat project.clj
(defproject getting-data "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.5.1"]]
  :main getting-data.core)

Yes that looks like the file.

6. Now run the file using, lein run

John-Mac-mini:getting-data John$ lein run
hello,  john

This doesn't create the executable, it simply runs the project. We can leave this step out if we wish.

7. Now we can create the executable Jar

Use, lein uberjar

This will contain all the dependencies and will be placed in the ./target folder.

John-Mac-mini:getting-data John$ lein uberjar
Warning: specified :main without including it in :aot. 
Implicit AOT of :main will be removed in Leiningen 3.0.0. 
If you only need AOT for your uberjar, consider adding :aot :all into your
:uberjar profile instead.
Compiling getting-data.core
Created /Users/John/Documents/workspace/getting-data/target/getting-data-0.1.0-SNAPSHOT.jar
Created /Users/John/Documents/workspace/getting-data/target/getting-data-0.1.0-SNAPSHOT-standalone.jar

It has created two files:

8. Run the file

java -jar ./target/getting-data-0.1.0-SNAPSHOT-standalone.jar 

Friday, September 6, 2013

How to find what is in the Clojure libraries with REPL

First, load the clojure.repl lib

First you need to load the clojure.repl library. You should be able to do this by typing:
(use 'clojure.repl)
If this fails then see this post

What functions are available in a library

For example, what functions are in the repo library:
(dir clojure.repl)

Lookup documentation for a function

If you want to lookup the documentation for "when" for example, type:
(doc when)

Find definition by matching it's name

If we want to find all the definitions that contain the word "map" in their names then use apropos.
(apropos "map")

Find all documentation that contain a word

If you want to look up all definitions that have the word "stream" in it's documentation then type:
(find-doc "stream")

Look at the source code of a function

If you want to see the code for a function, yours or the Clojure functions.
To find the source code of the defn function, type:
(source defn)


you can visit the Clojure cheat-sheet at or you can query via the REPL.

Can't get (use 'clojure.repl) to work in Clojure

Clojure 1.5.1
In the REPL you might not be able to use the clojure.repl library.

Normally you would type:
(use 'clojure.repl)

However this causes a problem. You need to Require it first.

So type,
(require 'clojure.repl)

(use 'clojure.repl)

Sunday, September 1, 2013

Propositional logic, First order logic and Higher order logic

Propositional logic

In Propositional logic symbols represent Facts (Propositions).
for example:
W - the person is a woman.

Syntactic elements


First order logic (First order predicate calculus)

First-order logic represents the world in terms of objects and predicates. It uses the relations between objects and their properties. It also uses quantifiers and connectives.

syntactic examples

Objects - door, house, dog, ...
Relation - employer, sister, inside, ...
Properties - black, free, empty, hot, ...
Functions - first in, father of, friend of, ...

Syntactic elements

terms - objects
Quantifiers - UNIVERSAL (for all),  and EXISTENTIAL (there exists)
EQUALITY symbol (=)


In propositional logic every expression is a sentence and every sentence expresses a fact. In addition to sentences First order logic also has terms that represent objects.

Higher-order logic

First order logic is so called because it works with the first order objects of the world. Higher-order logic enables us to quantify not only objects, but relations as well. What that can mean in practice is that two objects can be thought of as equal if and only if all of their properties are equivalent . We could say that two functions are equal when their arguments have the same value.

I'm not too sure of the value of HOL and it seems a bit contentious.