The sky is the limit

Reaching it will give you emptiness

Coding

If it’s not possible to code, it’s not worth doing.

Music

Playing, recording, producing, mixing, mastering.

Presentation

Backgrounds, text, visualizing

$

Running

Halv marathon is fun

Puzzles

Using my brain is vital

Knowledge

You can never know to much

#gravatar, easy way of update your avatar

If you are, like me, having a user at many different sites, I suggest checking out www.gravatar.com. Create your avatar once, and use it everywhere. If you want to change it everywhere, change it one place. I’ve been using it for a long time, and I love it.

Reformat your source code with #IntelliJ

Writing correctly formatted code isn’t easy to do all the time. So what do you do when you have eg written your json files like:

{ "test": "testing"
, "bla": "blabla"
, "yo": "yo to you"}

and want it to be:

{
  "test": "testing",
  "bla": "blabla",
  "yo": "yo to you"
}

You go into your file and press alt-win-l (alt-cmd-l on mac). Voila. It’s formatted correctly.

But then you understand that you have a lot of files that needs to be reformatted. Well, select all you files in the project window (shift/alt) and when in the project window press alt-win-l. You probably get a popup asking for optimizing, rearranging etc. Just leave them and press OK. Voila. All files correctly formatted.

Now you can go and get your well earned coffee break.

IntelliJ and TODO

When you code, it’s often you come up with an idea or shortcoming of your function. It’s easy to code on and think you can remember it later. You don’t, trust me.

So what do you do when you’re in an editor like IntelliJ? Well, you add a TODO: entry.


// TODO: This should probably be shortened
// TODO: Perhaps add yield on each result to support generators?
// TODO: Add callback?
var fibonacci = function(pos) {
    if (pos===0) return 0;
    if (pos===1) return 1;
    var result = 1;
    var last = 0;
    for(var i=2;i<=pos;i++) {
        var newLast = result;
        result = result+last;
        last = newLast;
    }
    return result;
}

console.log(fibonacci(10));

We came up with three ideas when writing that function. Then you switch to another file, do you stuff. Before you know it, it’s gone two weeks since you added the TODO blocks. So what do you do in IntelliJ? You press win-6 (Windows) or cmd-6 (Mac) and get your TODO-list up and running. Choose Project (or File or Scope), and find all your TODOs. And if you wonder how to remove the list again, just press the same win-6, cmd-6

Node.js and random port

Sometimes you need to open a random port on your node server. You can of course try a random one to see if it fails, but a npm module makes this easy:

npm install portfinder
var pf = require('portfinder');
var http = require('http');

// If you want to change the first port to check
pf.basePort = 9000; // default is 8000

pf.getPort(function(err, port) {
  if (err) return; // handle error
  http.createServer().listen(port);
  console.log("I'm now listening on port "+port);
});

More information about the module is found at npmjs.com

Helping the world for free in the winter with #Folding@Home

When it gets colder, we use a lot of money to heat the house. Imagine if this money could be used to solve the Alzheimer’s disease, without it costing you anything more?

Impossible, you might say! Nope. It’s as simple as going to http://folding.stanford.edu, press “Start Folding” and voila you will help the world to find a solution to the diseases as Alzheimer, Huntington, Parkinson etc.

What’s going on?

  1. You will use the computer to solve the diseases
  2. Your computer gets hotter of working, that heats your house
  3. You turn down the heat in your house, because your machine is warming instead
  4. Power costs are exactly equal, because the heat is heat, no matter what make it
  5. The world wins. Maybe even you one day, because we found the solution to a disease you got

So, help the world for free during the winter months! It does not cost you many minutes to go to http://folding.stanford.edu. But remember, when summer comes and you start cooling the house, turn off folding also

Right now in my computer to help solve: “This project explores the folding and dynamics of E.coli RNase H.”

If you want to be part of my team, use teamnr: 227348. But feel free to be teamless. The important part is that you contribute.

Btw, there are more projects like this you can use to generate your heat. Another good one is http://boinc.berkeley.edu/

%d bloggers like this: