HTTP 403 Permission denied due to error “unable to check htaccess file”

Added some new icons to a site I was building but they refused to load. I got a HTTP/403 (permission denied) error on the files. When I looked in the apache log file I saw the following.

[Sat Oct 18 08:56:54 2014] [crit] [client 127.0.0.1] (13)Permission denied: [...]/public/assets/img/icons/social/cuteicons/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

The problem was, the only directory with a .htaccess file was the root directory of the website. What was wrong? Well, it turns out the directories the icons were in had the wrong permissions set. I hade copied an unzipped folder directly in to my web site. In order for apache to work properly every directory has to have the execute flag set.

So, after a…

chmod 755 /folder/name

…the icons loaded as they should.

Standard

AngularJS and IE8, directive that compiles HTML

I have a directive that loads an article in HTML from a CMS via a REST API and a template file what should be compiled together with the article.


element.html(templateLoaded.data);
scope.document = theLoadedArticle;
$compile(element.contents())(scope);

This worked in most browsers except our old “friend” Internet Explorer 8. The reason is I have another directive in the loaded template file and I need to tell the DOM compiler about this (IE8 is cranky about non-html tags).

So, inside the template file I added:


<script type="text/javascript">
//Needed for IE8/9
document.createElement('my-directive');
</script>

Now it works. It could probably be done outside the template file as well.

Standard

WordPress, Drupal or Roll Your Own?

When should you use existing CMSs as WordPress or Drupal and when should you build one yourself?

Of course, building a CMS from scratch would be insane but with emerging technologies and standards such as git (for version control), Markdown (for editing), Neo4J (for metadata) and Solr or ElasticSearch for indexing the data, you can get extremely far by putting the pieces together yourself.

Add to that the recent rise in popularity of Javascript frameworks such as AngularJS or Backbone, with which you tend to get a cleaner split between REST-API and UI, and you don’t even have to render the web pages on a server. Static HTML-files with Javascript are fine.

So maybe the time has come to say goodbye to the web CMS that tries to do everything and say hello to a toolbox of world class, open source and free components that you put together yourself to build a framework?

Standard

John Carmack on Software Engineering

A very good read here from game programming legend John Carmack.

In real­ity in com­puter sci­ence, just about the only thing that’s really sci­ence is when you’re talk­ing about algo­rithms. And opti­miza­tion is an engi­neer­ing. But those don’t actu­ally occupy that much of the total time spent pro­gram­ming. You know, we have a few pro­gram­mers that spend a lot of time on opti­miz­ing and some of the select­ing of algo­rithms on there, but 90% of the pro­gram­mers are doing pro­gram­ming work to make things hap­pen. And when I start to look at what’s really hap­pen­ing in all of these, there really is no sci­ence and engi­neer­ing and objec­tiv­ity to most of these tasks. You know, one of the pro­gram­mers actu­ally says that he does a lot of mon­key programming—you know beat­ing on things and mak­ing stuff hap­pen. And I, you know we like to think that we can be smart engi­neers about this, that there are objec­tive ways to make good soft­ware, but as I’ve been look­ing at this more and more, it’s been strik­ing to me how much that really isn’t the case.

The whole post is worth a read.

Standard

Drupal 7 Youtube videos as fields in content type

I have been doing quite a lot of work with Drupal 7 the last couple of months. It has its ups and downs but one thing that it always tries to do is to prevent you from having to write your own code to solve problems.
It gets quite annoying then when simple things don’t work. In my case I wanted a content type with nothing but a title and a video field that shows Youtube videos that the editor pasted the URL to. That should work, right?

Well, yes, it should, but not without problems. First, I installed the Media module and then the Media:Youtube module. I set up a content type with a field of the type Multimedia Asset.

Then comes the kicker: without doing the following things didn’t work. The videos didn’t show up at all. It took me quite some time to figure this out.

At the Manage Display tab I had to first remove the video (make it Hidden) and then add it again so that I could choose a file view mode. See screenshot below.

The display types are defined in Config > File Types > Manage file display. Here I can choose Youtube video and after making sure the content type chooses a file view mode the video was displayed. *phew!*

Standard

Lean Startup Books

Speaking of books, I just set up a new blog focused on books about lean startup.
In case you don’t know, a lean startup is an organization in search of a scalable business model. It is heavily influenced by the agile software movement. (I even wrote a manifesto for it! :)
So far, I’ve only added four books but I will add more later and also categorize the books into sections such as software development processes, good living, marketing etc.
These are basically the books I’m reading myself so I thought I might as well collect it all and put it on a web site.

Standard

Programming books

There was a thread on Hacker News about influential books for programmers. I wrote a comment which I might as well rewrite for this blog because it’s an interesting subject.

So… the answer to this question depends a lot on in what stage of programming maturity you are.

The thing is, I remember the exact moment I “got” what a class in C++ was. It was a true relevation. Even though I had been programming for a few years (on my Commodore 64 and Amiga – mostly BASIC and some assembler) it wasn’t until I was 19 that I fully understood the concept of a class.

I can definitely say that I was a different programmer after that day. It was like leveling up in an RPG.

It took me a few more years to get object oriented design…

Yeah, maybe I’m a slow learner (although I have seen enough of other people’s code to conclude that I’m not alone) but the point is that at different stages of my journey to learn the programming craft I have been open to different ideas and insights.

I don’t think there’s one book that alone would have taken me all the way. The right book at the right moment can push you over a cliff of insight but software development is truly a craft of the mind and it takes many years to be really good at. I’m not there yet.

What’s your favorite programming books?

Standard

Working as a programmer in Sweden

Sweden Software

This blog ranks quite high on searches related to software in Sweden (gee, I wonder why :) ) so I sometimes get email from people who’s interested in moving to Sweden to work as a programmer.

I just replied to such an email and thought that the answer might be interesting for others to read as well, so here you go.

Great to hear about your moving plans. Even though the weather here right now makes you dream of warmer places, Sweden is a great place for a career in tech.

The job market for programmers is really good at the moment – at least in the Stockholm area. I’m not so sure about the rest of the country but Gothenburg seems to be doing fine as well. The Malmö/Lund area is still suffering from layoffs at the larger companies in the area (Sony Ericsson, Astra Zeneca, Ericsson) but there is a thriving mobile business growing there. They also benefit from having Copenhagen so close. Danish salaries are higher so Swedish programmers are a bargain in Denmark.

In Stockholm there are lots of headquarters, naturally, which means quite a lot of Big Systems written in Java or .Net. This is also where most of the marketing departments are located which means quite a lot of work for web agencies, CMS vendors etc.

In southern Sweden (Malmö/Lund) as I mentioned there is a strong mobile culture with Sony Ericsson at the epicenter. Lots of smaller spinoffs but also competitors or partners that’s establishing in the area. Sony Ericsson is almost always looking for embedded C-programmers with Android development growing a lot lately.

When it comes to the spoken language that varies a lot. The bigger international companies like Ericsson I’d say it’s no problem to speak English. The same goes for smaller firms like web or mobile agencies or startups. Most people in Sweden knows English. It can, however, be a problem once you leave the tech sphere. I currently work for a consultancy business in Stockholm and Swedish is a must for some of our clients. We have clients in the insurance, finance and retail business and they’re not as international as for example the telecom business.

I will probably write more about this subject in the future. Sweden needs more good software developers so please come here! :)

Standard