You probably noticed this blog is powered by Ghost. I tried it when it was all over HackerNews half a year (?) ago but it didn’t feel very polished (and was not announced as!). This week I felt like trying it again. Setup was really easy and it works just fine.
So I guess I will try to write something here once a week. Mostly about programming stuff.
Callbacks in node-spotify
This week I hopefully gave playlist callbacks in node-spotify a final thought. The current situation is: the user can access playlists and attach a callback like so
Problem: If you call
getPlaylists() twice you will get two different playlist arrays that contain new playlists.
I decided to save a relationsship of libspotify’s
sp_playlist and the V8 objects.
Otherwise I wouldn’t know which V8 object to use in a callback. Take
tracks_added for an example:
I want to provide
sp_playlist. With the
objectMapping map i can access it.
But this comes with the cost of added complexity in the C++ code. Also if the user gets the playlists twice with this approach only the last accessed playlist will be used in the callbacks!
This will put a little more work to users of node-spotify: You have to track your playlists more carefully. If a playlists objects goes out of scope it is advisefully to unregister all callbacks, otherwise you have to wait for the garbage collector to kick in and the callbacks to be unregistered in the destructor. Another nice thing that I can do better with this approach is to register the callbacks in libspotify only when the user registers them in node-spotify. Currently all playlist callbacks will be registered for every playlist and it will be checked in the callback function itself if the user had interest in this specific callback.
When coming to vim and emacs I always used vim. I started node-spotify completely in vim but nowadays it’s only my "console text-editor", not everyday work editor.
I always wanted to learn a bit of emacs to see how it works. I read about Org Mode sometime last year and thought it sounded really cool. This week I finally came around to give it a try. First I have to say that it’s really a pain to get emacs working on OSX, just because of the meta key. Alt does not work. If you switch alt to meta in Terminal.app you will lose the ability to input ~ which is not viable.
So I started with Emacs.app which runs in Cocoa and uses the alt key as meta while still maintaining the ability to use the special characters that are accessed via alt. But - copy-paste via cmd+c, cmd+v does not work. It also stops responding if I close a file with changes and the "do you want to save"-dialog comes up.
Nonetheless - Org Mode turned out to be really nice. I probably only scratched its surface with some todos and formatting. The concept of a plain/human readable text file that can be parsed as an agenda file by a text editor is really to my liking.