Repost Beyond Callbacks or How Koa helps me Code Better

REPOST FROM CODEBETTER

I noticed that CodeBetter is slowing down. Maybe dying. I’m preserving my post from there here.

Original post

For the better part of my life I have been a C# programmer. But lately I have ventured into JavaScript land. And I like it. I have come over the “what kind of junk is this”-phase and come to see the power and beauty that is “hidden under a huge steaming pile of good intentions and blunders is an elegant, expressive programming language”. You should read that book, by the way, that’s the one that made me like JavaScript.

Being a backend-guy (I will NEVER understand CSS… There – I’ve said it!) I soon came to look into Nodetoo. And pretty soon after that I met Express. Express was very nice since it reminded me of Nancy. Felt right at...

Read More

MongoDb and the "10309 Unable to create/open lock file" on Ubuntu

Ok, this was about to drive me crazy, and it seems like a lot of people have run into the same problem but sometimes my Mongo installation dies on me with an error like this:

10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating 

Yeah, I didn’t get that either. The actual error is not hard to understand, there’s some kind of permission needed on the /data/db-directory. But why? And how to fix it?

Why… well in my case it was when I had to shut down a running VirtualBox image by just closing the image window, the equivalent of pulling the cord of a running computer. So probably Mongo didn’t have time to clean up after itself…

Fix it… yeah, there’s a big number of posts on StackOverflow, take your pick. This tip worked...

Read More

Marcus Node Bits - Basic Authentication with Koa

As you might know I have fallen in love with Koa Js. I have, from experience, also come to realize that if you want to really understand a framework or tool you need to build something real with it. In that spirit, I created a little voting site that we will use in my current job. The whole application is simple; basically, you can create a question (poll maybe is a better word) that you want someone to answer. “How did you enjoy your stay?” for example. There are then only 4 valid answers: Sad smile, Disappointed smile, Smile, and Open-mouthed smile. The idea is that answering this is just pushing a button on your way out, like a physical Facebook like-button. From this, we can gather some simple, but interesting data about what people...

Read More

Do something together - what Indonesians taught me, part I

One of the things that really surprised my wife and me when we were about to move to Indonesia was the schedule for our office. Every Friday, there’s a scheduled 2.5-hour exercise session from 8 AM. Special exercise clothing is provided by the office. Except once a month when we spend that time cleaning or repairing the office. These activities are required, and nothing else happens in the office during this time (no meetings, for example).

Every office (that I have seen and passed by on the streets) participates in this. The bank down the road is exercising or playing soccer in their parking lot. The police office is doing aerobics in their courtyard, and even the churches and their staff are outside, exercising.

It felt a bit strange initially, but I have come to appreciate these activities a lot, and maybe not for the reasons you might first think.

...
Read More

Marcus Node Bits - Deploying to Heroku (and MongoHq)

I’ve been doing something for real! A very simple little polling site, that actually turned out pretty ok (saved the UI but I have a friend brushing that up for me) and might be useful. It’s built with KoaJs, of course, and using MongoDb as a database. Basically you can create a “question”, tag it with some meta data and then send a link to a page where you can start receiving answers. And there’s some very basic “export to excel”-reporting. Simple stuff. I spent maybe 3-5 hours altogether on it, in the hospital bed with my son in the bed next to me. He was pretty ok, so the concentration was not on top on either tasks for me. Bad!

This Sunday I wanted to deploy the first version of it. To Heroku. It went pretty smooth but I wanted to share my story and...

Read More

Looking for Better

Apparently my last post was not completely gibberish and contained some thoughts that you could make use of. Thanks for the feedback. Let me continue my train of thoughts here. It’s not a very long train, but it’s still a train.

Here’s where we ended: there’s a customer, we are here to delight them (thank you Stephen Deming for that phrase). Everything we do right now is just best so far in our strive to more effectively give value to the customer. We can and should, change our current state, process, organization, tools, or what have you, to try to improve. If we do the change in bigger steps there will be bigger impacts on our productivity, in smaller steps smaller impact.

See? Nothing really new or amazing here. In this post, I wanted to talk a little bit about where this can take us. Because I see...

Read More

Understanding My Perspective A Journey in Thought

I recently had a wake-up call when I realized that some of my fundamental thoughts aren’t as clear to others as they are to me. This realization prompted deep reflection on what matters to me and how I approach my work, striving to guide others with these principles.

My ideas aren’t groundbreaking; they simply prioritize producing value for someone, often referred to as “the customer.” This customer could be anyone benefiting from our work, including ourselves. Value isn’t solely monetary; it encompasses any positive impact, even personal well-being.

Why Are We Here?

For me, the question of purpose underpins everything we do. Though we may have various reasons for being in a workplace, the primary goal is to produce value. This aligns with the Salvation Army’s ethos: “Others!” We’re here to serve someone, whether external customers or colleagues.

Understanding value is crucial. It’s not just about profit but encompasses...

Read More

KoaJs and the SyntaxError Unexpected identifier error - or that time when I understood generators

It was quite sometime since I wrote a blog post with an error message in the title. However I have now got this error so many times, and keep scratching my head every time. Also I think I can explain why it happens.

Here’s an example on how to make this error occur, from the co-monk library README (not anymore maybe):

Running that code (either with “node –harmony koaErrorFail.js” or test it with “mocha –harmony-generators koaErrorFail.js”) fail with the error from the title of the blog post:

yield users.remove({}); ^^^^^ SyntaxError: Unexpected identifier 

At this point you start to think that you forgot to run the example with the --harmony flag. But of course you do that, right? Ah, maybe you are running the wrong version of Node. Again, no....

Read More

Aligning our sights - what Indonesians taught me, part I

I have now been in Indonesia for about 4 months. There’s so many new impressions and things that I’ve seen, learned and experienced that I’m starting to forget them. Some is bad, some is good, some are ugly so I thought that I would write them down. The first thing is some sort of alignment that is repeated almost everyday. In almost all workplaces that I’ve seen or heard about. Like a routine checkup on what is important here. I’ve actually experienced that before, in a very different setting.

In this post I’m planning to tell you a couple of short stories and episodes, to then try to see what this could look like in my “normal”, more western culture. I hope it will be interesting and useful.

Gothenburg Brass Band

I had the great privilege to play in the top brass band in Sweden for about 2 years....

Read More

Marcus Node Bits - Let us flex Koa Js, shall we?

The first two post of this mini-series, we picked up the basic on getting Koa Js to start as well as understand what it’s build from and the concepts behind it. It’s time to do something for real. Well over time, one might add. This post is all about using Koa to build different websites and web api’s.

By using Koa’s own examples I will show you how you can use Koa for a lot of common tasks and scenarios. Let’s dive right in.

Read More