Read my book

I wrote books about Webpack and React. Check them out!

Thursday, December 29, 2011

Blog Highlights of '11

It looks like this year is nearing its end. Thanks for tagging along! I thought it might be fun to write a post that highlights some of the nicer posts I wrote this year. So far I've been blogging around two and a half years.

I think blogging is slowly starting show its advantages. Just a while ago I needed to solve certain Django specific problem. After googling around I happened to find the solution at my blog. In essence this blog serves as a kind of auxiliary memory of mine. As a side benefit some other people might find my ramblings useful too. This in turn might lead to new chances. Blogging is definitely a good way to market yourself if you're into that sort of thing.

There has been some talk on whether or not blogging is dying. The basic premise is that social mediums such as Facebook and Twitter are eating its popularity. That's probably partially true. I believe blogs will remain to have some influence. After all you'll need something to discuss and tweet about. Most importantly blogs are more permanent by nature. It's easier to refer back to some concrete blog post than some obscure Twitter conversation ages ago. Different mediums serve different purposes.

Now that I got the intro bit out of the way, let's take a look at the year. Quite a few things happened. While at it I'll try to outline some possible ideas for the next one. It's not like I'm running out of ideas. On the contrary. There's still plenty of material left I need to get out there sooner or later.

Wednesday, December 28, 2011

Replacing iTunes on OS X with Something Better

Some time ago I finally had it with iTunes on OS X. It's a really bloated piece of software these days. So as a result I decided to look for an alternative. I wanted something simple that supports multimedia keys for playback. Apparently a combination of Clementine player and a fix to disable default bindings does the trick.

In this post I'll recap my efforts. I tried various solutions before coming up with this specific combo. I'm not a big fan of Clementine's playlist driven user interface but it does the trick on a minimal level.

Tuesday, December 27, 2011

How to Write a CSS Preprocessor Using Node.js?

CSS preprocessors seem to be really popular these days. At least there are many to choose from. See Stylus, Sass and LESS for example. These kind of tools provide some functionality missing from vanilla CSS and make it more fun to write. Some popular features include variables, functions, mixins, nesting and overall lighter syntax.

Node.js (or just Node) is another emerging technology. It is currently the leading server-side solution available for JavaScript. Effectively it enables us to use JavaScript in the whole stack instead of just client side. Some claim this makes it easier to develop (no linguistic context switch). Anyhow it's one the hot technologies out there at the moment.

In this post I'm going to show you how to use Node to write a CSS preprocessor with a selected few features. Since "less is more" I'm simply going to call this little project as "more.js". Hopefully this post gives you some ideas on how you might write your own preprocessor.

In principle they're very simple. You just take some data in, transform it and finally spit it out. Most of the magic happens in that transformation stage. I'll start with the ends (read file, write file) and move onto actual business logic right after that.

I'll be using Node v0.6.6 since that's what I've installed on my Mac at the moment. If you are a Mac person too, you can easily install it via MacPorts simply by invoking "sudo port install nodejs" at terminal. If you are using Linux you should be able to find Node from your local package management system. Note that it might not be the freshest version available so you're probably better off installing it by other means. You could just grab a package directly from their site and install that. There's a Windows version available too.

The code will likely work with a lot older version of Node as well. I used only a couple of Node specific features (mainly file IO). The rest is just vanilla JavaScript.

Monday, December 26, 2011

Brief Primer to Immaterial Rights

Disclaimer: I am not a lawyer and cannot be held legally liable if something bad happens because you read this post. M'kay?

Immaterial rights seem like a necessary bad. At least they're something we've to live with. It doesn't hurt to know something about them. In this post I'll try to explain some basic terminology related to them and not to bore you too much. If you want some real advice, consult your legal expert. This is here just so you can get started with the topic.

Immaterial Rights - What Are They?

This whole lake is mine! by mikecogh (BY-NC-SA)
Property and ownership are core tenets of both material and immaterial rights (sometimes also known as immaterial property rights (IPR).

Ownership is a right that allows the owner to exclude. If you own something, it's up to you to decide what to do with the thing that you own. If you want, you can borrow or rent it. Or perhaps not. That's totally up to you.

It's not surprising many kind of business models have been built upon this simple concept. Just consider software licensing for example. Often you just buy some kind of limited right to use some piece of software. You might not have access to its source at all.

Things get a bit sketchy when we get to the realm of immaterial. As can be inferred from the term itself, immaterial is something that's not material. This division between material and immaterial reminds me of Plato's thought of an ideal and a real world. There's the immaterial idea of a tree and actual, material trees in the world we perceive that are actual instances, representations, of the idea.

Can the concept of ownership translate to the world of immaterial? If it can, how? As it appears, there's some legislation just for this. In fact both parts, ideas and their instances, have been covered in various ways. I'll discuss these in more detail next.

Types of Immaterial Rights

Wright Flying Machine Patent by public.resource.org (BY)
There is just one, albeit powerful, way to protect ideas: patents. Patents grant an exclusivity to an idea for a limited amount of time. They have to be applied for specifically and they cost money. There are usually some additional requirements (not obvious, no precedents) that must be passed before a patent may be granted.

Trademarks make it possible to protect business related entities such as logos or specific terms. This is important as this allows businesses and individuals to manage their brand. Most importantly this gives some cover against copycats.

Trade dress covers appearance of a product in various different ways. Suppose for instance that you are building certain kind of house ornaments. You might want to get a trade dress for that. The same argument applies here as with trademarks. They'll give you some protection against competition.

Coca-Cola bottle cap by Tom BKK (BY-SA)
Both trademarks and trade dress' have to be applied for specifically and they'll cost some money. They're a powerful tool especially for businesses wishing to protect their brand identity and products in some way.

There's one important category of rights left: the copyright. Copyright applies to instances of ideas. Each work, this included, is under copyright automatically. Just like types discussed before copyright will grant you some form of exclusivity. In this case the copyright holder may control the way the work is used and shared. Copyrights are valid only for a certain period just like patents. In case of copyrights this period tends to be somewhat substantial.

As you can see each type of immaterial rights covers some specific area. Only patents cover ideas specifically. The rest cover some concrete instance of an idea. Of these particularly copyright is interesting. Even though in principle it's quite simple, there's more to it.

Additional Rights Related to Copyright

L.H.O.O.Q by Marcel Duchamp (PD)
Even though copyright grants an exclusivity on the creation itself, there are two little exceptions to that: separate works and fair use.

A new version of some copyrighted piece of work may be created as long as it's different enough to be considered a separate, not derivative work of its own. This might be a parody or a new interpretation on the original idea. Marcel Duchamp's L.H.O.O.Q shown on the right is one famous example of this.

It is possible to use copyrighted works as a part of your creation without having ask for specific permission thanks to the fair use provision. This mean too may be used for purposes of parody.

So how do you know whether or not you are in violation? There have been cases where some media has used some photo without a permission. The commercial context makes this a violation. It might be fine to reproduce some photo for personal usage but going public like this is a step too far. Ultimately it is up to a court to decide whether or not something falls under fair use or not.

Orphn Work by dolescum (BY-NC-SA)
Works not under copyright anymore are generally considered public domain. This may also apply to works that were created before any sort of legislation was in place. Shakespeare's works are likely the most known example of this.

As the term implies these works are open for public to exploit the way they want to. Overall it can be seen as a way to pass our cultural heritage to new generations.

Unfortunately sometimes it may not be clear whether or not some work is still under copyright. This kind of orphan works are problematic. Orphaned status of a work makes it risky for libraries to preserve it by digitizing as it is possible the original holder of the copyright will demand a compensation.

As you can see the concept of copyright is not without its problems. In some cases it even works against the common good even if the original copyright holder didn't want it to. Fortunately there are some ways that allow us to give up some of our rights should we want to. The extent of this depends on legislation. In some cases it is not possible to waive moral rights for instance.

Alternatives to Copyright - Copyleft and Creative Commons
Portrait of Richard Stallman by Maurizio Scorianz (BY-NC)

What happens if you take the concept of copyright and inverse it? You get something like Stallman's  copyleft.

It can be understood as a collective right. If the source of some software is under a copyleft based license, such as GPL, it effectively means you and every other person have access to it and are allowed to do anything with it as long as you remain within certain constraints. This type of software is also known as free software.

The wording is a bit unfortunate. It is important to note that free refers to free as in freedom in this case. It's not just gratis (ie. without cost). Sometimes term libré is used instead of free.

Stallman defines free software using four freedoms as follows:
  • Freedom 0: The freedom to run the program for any purpose.
  • Freedom 1: The freedom to study how the program works, and change it to make it do what you wish.
  • Freedom 2: The freedom to redistribute copies so you can help your neighbor.
  • Freedom 3: The freedom to improve the program, and release your improvements (and modified versions in general) to the public, so that the whole community benefits.
Even though the definition is quite software centric it is applicable beyond just software. The main contribution of this concept is the contrast it provides. The oft discussed concept of open source falls somewhere in between the two ends. It allows you to renounce some of your rights to the source.

For instance by using popular BSD or MIT license you require just an attribution should your source be used in some other setting. Licenses such as Apache License 2.0 provide some additional protection against software patents. If you are interested in software licenses, check out what Bruce Perens has to say on the subject.

The concept of Creative Commons can be considered a sibling of open source. It is applicable beyond software. Its primary purpose is to allow you to define which rights you retain and which you decide to revoke. Check out their license generator. It allows you to customize the license to suit your needs.

One of the nicest things about creative commons is that it nurtures culture of sharing. Whole communities, such as ccMixter, have grown on top of it. There are also many books available. This is valuable especially in the context of education. It allows educators to cooperate and write localized versions even. Particularly Khan Academy has pioneered efforts in online education. Its videos span a wide range of topics.

Conclusion

It is important to know something about immaterial rights. Using them right may provide some interesting benefits. Even though copyright is automatic, there's no reason why not to give up some rights so its easier for other people to build upon your work. You in turn can build upon the work done by others.

There's a lot of fuzziness and room for interpretation in the legislation. It also depends a lot on where you live. The view provided here has been influenced quite heavily by the Western culture. No doubt things look quite a bit different elsewhere.

I hope you managed to pick a thing or two from this post. Immaterial rights are a vast area of discussion and I just glanced briefly at the subject. There's a huge amount of related material out there for those interested.