Sunday, June 09, 2013

Switching to Octopress

I’m switching to different blogging platform. Again. There are few reasons for that. The main reason is I want to own the sources of my articles. All platforms I used before save blog posts in HTML format, which is not the source format but rather one of the representations. If I want to update an article I have to edit HTML in some online editor which is not the best way of editing. It’s especially difficult on Blogspot, because after some time Blogspot converts the articles to a single-line of HTML which is very ugly.

I’d like to have my articles in a simple format like Markdown, and the blogging engine should just render them to HTML. I also like to keep the sources on my hard drive where I can quickly grep for phrases. Essentially what I want is this

  • Separate the source of the articles from their representation.
  • Being able to save sources locally on my disk and upload them if needed to the Internet.
  • Keep the history of article changes.
  • Have flexibility in representation, i.e. being able to change the layout of the blog to whatever I want.

Neither Blogspot nor the previous platforms I used to publish my articles to provide these features. Therefore I’m switching to Jekyll.

With Jekyll you write the article in Markdown, Textile, or Liquid, and it generates the static HTML which can be uploaded to any Jekyll-aware hosting. Github, for example, is one of them.

To get even more power, I’m going to use Octopress, which is built on top of Jekyll. Apart from all Jekyll features, it also provides syntax highlighting (which is very handy when you post code snippets), professional mobile layout, and tons of plugins you can use to customize the blog.

As a part of the migration I also want to revisit my old articles and update the interesting ones. You will find them in the archives section of my new blog.

Without further ado, here is the link to my new blog: blog.ndpar.com. The sources can be found on Github.

The Blogspot blog is now deprecated.

Thursday, May 09, 2013

Stuck with your first programming language

Barbara Liskov in her keynote presentation:

I'm a little dismayed what's happened in programming languages. And the reason I'm dismayed is because on the one hand we have the programming languages that experts use — I'm thinking of Java and C# but you can name bunch of others. And the problem with these languages is — they are powerful, you can build big systems in them — but they aren't very good for beginners. And what happens in MIT, and I think this is happening across the US anyway, is the people are no longer using those languages in their introductory programming language courses, because the amount of craft you have to go through in order to write the little print-loop is just too much, and the students just get lost in the process. So they've been switching to languages like Python.

Python is very simple and nice when you start to use it. But you don't get too far down the road, if you me, before you discover it has no data abstraction at all. That's not good because big programs require modularity and encapsulation, and you'd like the language that supports that. So my question is: Can we find a language that will work for both communities? And the reason it matters is because a lot of kids start off programming in their first programming language and that's it. They may have to change eventually, but they are building huge systems in languages that are really ill-suited for this. So it would be good if the language they started off with is the one they can grow with, and would be good for building big programs as well as small ones.

Saturday, March 09, 2013

Simple ZooKeeper Cluster

Sometimes I need to run ZooKeeper ensemble on my development box to test my application on the production-like environment. I found that recreating the whole ensemble from scratch is much faster than cleaning it up using ZooKeeper CLI tool. To automate this process I created a bash script which I want to share in this blog post. I hard-coded all the paths in the script using my regular conventions. You might need to change them to yours — it should be fairly straightforward.

Before you can use the script, you need to install ZooKeeper on your box. That's what I did on my machine

$ cd /opt
$ sudo mkdir zookeeper
$ sudo chown -R andrey:admin zookeeper
$ cd zookeeper
$ wget http://apache.mirror.rafal.ca/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
$ tar xf zookeeper-3.4.5.tar.gz
$ rm zookeeper-3.4.5.tar.gz
$ ln -s zookeeper-3.4.5 zookeeper

In the end you should have a ZooKeeper installed in /opt/zookeeper/zookeeper directory.

Now download, chmod, and run the script. It will create the following files

/opt/zookeeper/zookeeper/cluster
├── server1
│   ├── conf
│   │   ├── log4j.properties
│   │   └── zoo.cfg
│   ├── data
│   │   └── myid
│   └── logs
├── server2
│   ├── conf
│   │   ├── log4j.properties
│   │   └── zoo.cfg
│   ├── data
│   │   └── myid
│   └── logs
├── server3
│   ├── conf
│   │   ├── log4j.properties
│   │   └── zoo.cfg
│   ├── data
│   │   └── myid
│   └── logs
├── start.sh
└── stop.sh

This is the minimum configuration for 3-node ensemble (cluster), which is recommended for production. To start the cluster, run the following command

$ cd /opt/zookeeper/zookeeper
$ cluster/start.sh

Check the log files to see if the cluster is successfully started

$ tail -f cluster/server{1,2,3}/logs/zookeeper.out

When the cluster is up and running, you can test your application. After you are done, shutdown the cluster using the following command

$ cluster/stop.sh
$ ps -ef | grep java

To recreate a clean cluster, just run the script again

$ ./zookeeper-init-ensemble.sh