Installing and running clojure and Leiningen on windows 8

I’ve played around a little with Clojure on several occasions before, but never really done anything serious with it. I’ve decided to give it another try now, and I was pleasantly surprised by how easy it has gotten to install it on windows 8.

Earlier, I’ve run it in different ways, such as through emacs, directly on a command line, and from within the Eclipse IDE. I tried to get Leiningen to work too, some time ago, but had some problems getting it to run, which I never got round to solving.

This time, I followed these simple steps to get Clojure running via Leiningen, from a powershell console:

  • Open a powershell window in administrator mode (this is important – you won’t be able to install Leiningen if you’re not in admin mode).
  • Downlolad the .bat- file for windows available directly from the main page at (new window). For simplicity, I chose to place this right under a new catalog at c:\lein\
  • Install leiningen directly from the command line:

    ./lein self-install

    That should download Leiningen, Clojure, and all the other stuff you need automatically.

  • Now you should be able to start the REPL and start coding via Leiningen using:

    lein repl

Posted in English, Science & tech, Tips | Tagged , , , , , | Leave a comment

Book review: “Influencer”, by Patterson et. al.

I’m currently reading “Influencer: The power to change anything” by Patterson, Despite the somewhat corny title with it’s grandiose promise, I’m finding the book quite interesting. It describes a set of factors or forces that affect how people behave, and which should be taken into consideration when trying to change behavior. The two main forces are motivation (“is changing this habit worth the trouble?”), and belief in ones ability (“will I be able to change this habit?”), and these are further subdivided into personal, structural, and social factors. This results in six target areas for incentives, each of which is discussed in detail in the book. When enough effort is put into each of them, change will, according to the authors, be inevitable.

The book includes many and various real-world examples and case-studies, ranging from fighting the spread of diseases such as Aids or the Guinea worm parasite in Africa, to increasing effectiveness in an American car factory, or rehabilitating life-long criminals and helping them integrate into society. Each case describes how the six factors have been targeted in order to make unwanted behavior unappealing or difficult, and new/positive behavior easy and attractive.

I’m about half way through the book at this point, and the theories and strategies provided have been quite plausible and interesting. Beyond the title, the book does not promise change to be easy. It does, however, provide a framework in which to understand a lot of human behavior and the motivation behind it, and a set of tools and strategies for influencing it. All in all, a good read so far, with a nice mix of theories and strategies, and stories to back them up and make them memorable.

Posted in News, Politics and more, Reviews | Tagged , , , , , | Leave a comment

Reactions in Norway after 22.07.2011

As a Norwegian, I’d like to share some thoughts I’ve had since the terrorist attacks in Oslo and on Utøya last Friday. First of all I would like to extend my condolences and sympathy to all those affected directly by the attacks. These have been horrible, tragic events that are difficult to comprehend, and which have shocked us all.

One country
What has happened is terrible, and it is bound to affect us for a long time to come. The way the Norwegian leaders and people have met this however, makes me proud. Our values will remain unchanged or strengthened. To say that we will not be pushed or manipulated into fear or violence by one deluded man with a perverted ideology is to state the obvious. The last few days have been filled with hundreds of thousands of candles and flowers, moving words and songs, interspersed with quiet moments for reflection. A record number of people have been out in the streets day after day to pay their respects and share the pain, and a solemn calm has rested over the entire country in a way we have ever experienced before.

Shame, but also relief
It may sound like a strange sentiment, but I’ve heard it from many different people, and I feel it myself too: We are ashamed that the terrorist was “one of our own”, seemingly a typical, normal young Norwegian man. It disgusts us and his actions go against everything we stand for. At the same time, many of us are relieved that this was not a plot by fundamentalist Muslim terrorists, for who knows what reactions we would have seen here and in the rest of the world then? The attacks were horrible, no matter who carried them out, but as a group, the Muslims are exceptionally easy to heap together and blame these days. Thankfully the fear and anger that might then have been directed towards innocent people never materialized, since the terrorist did not live up to the stereotype so many had expected.

I think this is a subtle point that needs to be made abundantly clear: We were attacked, not in protest or retaliation by fundamental Muslims, but by a paranoid and deluded Norwegian who fears the open, friendly, multicultural society we are striving to create. In my view, the attacks themselves and the reactions following them can only confirm and strengthen our commitment to that society.

Reactions towards Muslims and our responsibilities
If some ethnic Norwegians were relieved, many Muslims were all the more so. For many, the night following the attacks had been sleepless and filled with fear of blame and repercussions. Instead Muslims are now showing their support along with everyone else. Summer Ejaz is the spokesperson for the Islamic Council in Norway, an organization that tries to help form a Norwegian-Muslim identity that can integrate well into Norwegian society, and to create dialogue between Muslims and non-Muslims. In an interview with the newspaper Aftenbladet he says (my own translation):

I think it [the attack] will strengthen the ties between Norwegians and immigrants. The attack has shown that the enemy can be found among all groups, and that evil can only be met with fellowship.
(Original article in Norwegian)

Given the new situation in the wake of these attacks, is there anything we can do to improve the ties between Muslims and non-Muslims? There will always to be challenges as we try to build a better society, but I believe this is an opportunity that we ought to make use of. These last few days have brought all who live in Norway closer together. Continuing this, especially with regard to that one group of people which is often eyed with such suspicion, would be the perfect protest against the man and the ideas behind the attacks on Oslo and Utøya.

Parts of the Muslim population itself has been trying to reach out to the rest of us for some time now. Take the “Tea Time”-initiative for instance, wherein Muslims are encouraged to invite their neighbors or others over for tea. Commercials aired on TV and radio encourage us to get together, for as one girl in the ad (posted below) states, those who know any Muslims do not seem to be afraid of them.

I think this is a admirable initiative, and one that deserves more attention. You can find more information (unfortunately only in Norwegian) at, or see the commercial below.

If you are a Muslim living in Norway, what would it take for you to invite someone you don’t know over for tea? If you are a non-Muslim, would you accept? I’d like to think that I would; Who knows where such a small first step may lead in time?

Posted in News, Politics and more | Leave a comment

Wordcount for PDF in Emacs (linux)

Need to do a word count in Emacs? Strangely enough, that’s one thing that is not as easy as one would think. Anyway, if you DO need word count, chances are it’s because your using Latex to write whatever it is you are writing, and exporting it to PDF. If so, here’s a solution that should work if you’re using Linux:

(defun pdf-word-count ()
(setq cfile (buffer-file-name))
(setq txt-file (concat cfile ".txt"))
(shell-command (concat "pdftotext " cfile " " txt-file))
(shell-command (concat "wc " txt-file))
(shell-command-to-string (concat "rm " txt-file)))
(global-set-key "\C-xw" 'pdf-word-count)

Just add this to your .emacs file, and you will be able to count the words in any PDF-file. To count the words in your Latex-document, there are three steps:

  • C-c C-c: Compile the PDF, as always
  • C-c C-c again: Now, the generated PDF should be opened in Emacs, so you can see it, and the buffer containing it will be active.
  • C-x w: This executes the code and displays the count in the minibuffer.

The result should look something like this:

24 7490 46689 /home/mystuff/mydocument.pdf.txt

The first number is the new-line count, the second is the word count, and the last is the number of bytes (in the temporary file which follows; in this case, “mydocument.pdf.txt”, which contains the extracted text from “mydocument.pdf”).

The way this works is a little crude, but it gets the job done; It actually fetches the name of the file in the currently active buffer, and creats a variable with the same name, only with “.txt” appended to it. The text in the pdf is then extracted with the Linux command “pdftotext”, and stored to a file with that name. The word count is then performed on that text using the “wc”-command, before the text-file is deleted.


  • This should work on any PDF-file, as long as the text can be exported.
  • If you want to use a different key-combo, just change “\C-xw” in the last line
Posted in Science & tech, Tips | Tagged , , , , , , , , , , , | Leave a comment

Using Caps Lock as an extra Ctrl in suse 11.2/kde

As I’m using Emacs on a regular basis these days, I’m totally dependent on my left control-key being easy to reach (if you don’t know what I’m talking about, go read about emacs before continuing!). It may sound like a trivial problem, but you’re little-finger will tend to get pretty tired after reaching for that button way-down-there-at-the-corner again and again during a long day of writing (if you think I’m overstating the problem, you clearly didn’t follow my first advice: Read about, or better yet, try out Emacs for a couple of weeks!).

Yesterday I came across this tip, that I hadn’t thought about: Why not switch the Ctrl-key with the Caps Lock? The latter is hardly ever used anyway! At first I thought nah, silly unnecessary idea – using the control key is not THAT big of a hassle anyway. Then today, after working en Emacs for only a short while, it became too tempting, and I decided to swap it after all. Or rather, I turned Caps into an extra Ctrl-key. The reason is that I use Ctrl + Alt and the arrow keys to switch between desktops, a combo I’ve used for years, so I wouldn’t want to mess that up.

Luckily, KDE has this sweet feature, which lets you set just these things, simple as… well, something really simple:

Using caps as an extra ctrl in KDE

Under system settings -> Regional & Language

I’m still getting used to this, but I don’t think it’s going to take long. Best of all, this works across the OS, of course; opening a new window in my browser, or what ever else I might use Ctrl for is now easier. I definitely recommend giving it a whirl. Enjoy! 🙂

Posted in Science & tech, Tips | Tagged , , , , , , , , , , , , , , , , | Leave a comment

The IPhone is compatible with A.D. time travel

I had to reset the date on my IPod today, and stumbled upon something interesting. It happened because the date had somehow been reset to the year 2000. Fine. Ten years back now seems a while ago, but oh well. Not that interesting. Then I tried to see how far back I could scroll. I was expecting something like a few years back, or maybe back to January 1., 1970 (An alternative “Year 0” for those of us who know a little about dates in computers). But nope, scrolled back passed it. Way passed it. In fact, it went so far back, I had a little time to think while I was scrolling. I wonder if Dr.Who has an IPad or an IPhone (or had? Or will have? Sidenote: What is the correct verb-form to use when referring to someone who travels in time?). Does his sonic screwdriver have a calender, and if so, is it as good as that of the IPhone?

Anyway, I finally reached the year 0001. Then 0001 again. Yup, that’s right: There are two instances of the year 1, then nothing. I guess that means my IPod (and presumably, IPhones, IPads and possibly other I-thingies) are compatible with time travel, so long as you don’t go back beyond the birth-year of Jesus, a year that was so great, they decided to run it twice (Probably due to record sales of Christmas-related software from the App-store).

You know what is a little strange though? Although it is possible to time travel scroll forward to beyond the year 9999 (yes, right through 10000 and onwards), as soon as you let go, the dial jumps right back to 2038. So apparently, 2010 years into the past is OK, but 28 years into the future is not. I’m guessing Dr.Who would have felt cheated.

Posted in Humor | Tagged , , , , | 2 Comments

Why latex only includes one of your files

Just another quick tip that might help someone save some time and frustration:

If when writing in Latex, you try to include one or more finished files into another file and only part of the final documents is generated, check if you’ve remembered to remove the final line in the included documents, typically:


If you don’t remove it, that line will terminate the output and your document after the first included file, leaving anything after it out.

It’s strange, how the simplest, silliest, and in retrospect, most obvious mistakes can often be the most frustrating! 🙂

Posted in Science & tech, Tips | Tagged , , , , , , , , , , , , | Leave a comment