Archive for the ‘ journal ’ Category

Python Development Environment — Part II

Let’s start with Part II of Python Development Enviroment set up. After you setting up the isolated environment with virtualenv, the next question is how to install Python package(s)? As we set our virtual environment to not use system-wide Python package, it is really troublesome to install it manually.

Met pip, a next generation of Python package manager. You can see in the website, that pip is built to improve easy_install. pip has a lot of advantages on easy_install, but it has some drawbacks too, such:

  1. cannot install from eggs. pip only install from source.
  2. does not understand setuptools extras
  3. not compatible to package which extensively customize distutils or setuptools in their setup.py file

pip is a perfect combination for virtualenv, they even state that pip is most nutritious when you used it with virtualenv. You can force pip to only run when a virtual environment activated by issuing this command:
export PIP_REQUIRE_VIRTUALENV=true
in your shell.

How to use pip? If you search for a Python package, just type
pip search
and install it by
pip install
pip will manage all the requirements by using information from PyPI

The most awesome feature of pip is the ability to “freeze” the requirements packages of a virtual environment. You can use this “requirement files” to install to another virtual environment. You can do it by typing these:
$ pip freeze > requirement.txt ## Generating requirement files
$ pip install -r requirement.txt ## Install from requirement file

You can also install bash completion with issuing this command
$ pip completion –bash >> ~/.profile

pip is a wonderful tool, use it with virtualenv and let the code begin.

Django Development Notes – 1

I was reading about this about setting up Jenkins with Rails for Continous Integration, and it crossed my mind, thing will be great if I set a Jenkins server to doing some automated task for a Django project. I proposed this to our solution architect, and he suggests me to try thing first, before make an adjustment to our current development workflow. And the journey began…

At the moment, I am developing a personal django web application, a project bug tracking software, specially tailored for my needs. It use PostgreSQL database, because I just hate SQLite and MySQL (no offense though). In python you use psycopg2 for connecting to PostgreSQL database.

I googled about django and Jenkins integration, and I found django-jenkins, and I found it is supposed to be easy. All you need is to install django-jenkins packages using pip
pip install django-jenkins
then add django_jenkins into your INSTALLED_APPS in your settings.py file. Lastly, run the task for Jenkins, by issuing this command:
python manage.py jenkins

When I ran that command, I got this error:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django_jenkins/management/commands/__init__.py", line 70, in handle
    if test_runner.run_tests(test_labels):
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django_jenkins/runner.py", line 339, in run_tests
    self.teardown_databases(old_config)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/test/simple.py", line 327, in teardown_databases
    connection.creation.destroy_test_db(old_name, self.verbosity)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/db/backends/creation.py", line 461, in destroy_test_db
    self._destroy_test_db(test_database_name, verbosity)
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/db/backends/creation.py", line 470, in _destroy_test_db
    self.set_autocommit()
  File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/db/backends/creation.py", line 481, in set_autocommit
    self.connection.connection.autocommit = True
psycopg2.ProgrammingError: autocommit cannot be used inside a transaction

WFT is this error? After doing some googling, I found that Django’s test suite is incompatible with psycopg2 newer than 2.4.1. This issues has been around about 9 months and still no fix from Django. The only fix I found is to install psycopg2 2.4.1 version. You can do that by doing this:
pip uninstall psycopg2 # answer by typing ‘y’
pip install psycopg2==2.4.1

Python Development Tools – Part I

This time, I want to share about Python development environment setup that I use daily. I love Python programming language, because it provides simple syntax with high readibility level. Currently I am learning Django, a popular web framework powered by Python.

To set your Python development environment, you should (if not must) use these tools, known as virtualenv and pip. You can install them by using easy_install by typing this command:
$ sudo easy_install pip
$ sudo easy_install virtualenv

easy_install will install (doh) these package to system-wide Python package directory, enabling you to use pip and virtualenv in your system.

What is virtualenv? Taken from its website, virtualenv is a tool to create an isolated Python environment. You can have a package with multiple versions depending to each your application. virtualenv also keep these packages separated from system-wide Python package, which good if you are an early adopter. You can create a virtual environment for learning some new features where the stable version is not intact with the upgrade.

To start use virtualenv you can launch your Terminal application and type:
python virtualenv.py –distribute –no-site-packages
The command will set an isolated enviroment by not using any Python packages installed in your system. You can install the same package with newer version without damaging your system configuration.

I suggest you to install virtualenvwrapper, a command-line utility which provide wrapper for creating, deleting or managing your virtual environment. It is a good idea to install virtualenvwrapper as a system-wide Python package. Some very useful commands are:

  1. lssitepackage — for listing all your virtual environment
  2. workon <env> — switching to another
  3. deactivate — exit from current virtual environment
  4. mkvirtualenv — wrapper for creating new virtual environment
  5. rmvirtualenv — deleting existing virtual environment

You can find another useful commands in the documentation section.
By using virtualenv and virtualenvwrapper, you can create and manage isolated environment for your Python application. You can take it further by combining with Pythonbrew a not-so-new-but-just-found-out-about-it tool, which allows you install multiple version of Python. I will talk about it later, since I am still learning to use it.

See you in Part II

Language in 2011 – Part II

This is the sencond part of computer programming language(s), I’ve learnt inthe past year.

Scala

Scala is a JVM-based programming language. It is a combination between functional programming and object-oriented programming. I learnt Scala because I want to learn about Lift, which used by foursquare.
I dound Scala is a very powerful language, especially comparing to Java. The biggest advantage of Scala is its compatibility with Java, since Scala compiles to JVM bytecode. You can use existing Java technology stack with Scala

Clojure

Another rising star, Clojure is a lisp dialect JVM-based language. I have not explore this further, but I’ve seen some interesting apps built on Clojure.

Common LISP

I learn Common LISP after reading a link from reddit. I found Lisp as the best programming language for teaching. It provides clear ilustration of function and processes. Great language, I suggest you to learn it.

And that is all. Still far more to go. I am planning to concentrate on Python this year, and maybe learning a bit about HTML5 and Javascript.

Development Tools in Mac OS X

I purchased a 2011 MacBook Air for replacing my old office laptops as my primary development machine. I used GNU/Linux in my old laptop, which I found providing very similar environment with Mac OS X. My new MacBook Air came with Mac OS X 10.7 a.k.a Lion, which according to the definition, providing the best of iOS to Mac environment. Since I myself also own an original iPad, I found no problem with all these new feature in Mac OS X 10.7, including the controversial natural scrolling feature.

I myself also familiar with Mac OS X environment, my wife already has a MacBook Pro with Mac OS X 10.6 installed. IMHO, Mac is a very fun environment to work with, you do not have to worry about small-yet-annoying thing, so you can focus on your work. Mac is also known as one of hacker’s environment. It inherits UNIX stability and simplicity. Coming from GNU/Linux world, I found Mac OS X is a very entertaining environment, you can use almost all tools from UNIX, and the most important thing is, I get it in avery consistent GUI which I love.

So the journey to set up a develop machine based on MacBook Air is continued. I read some interesting links like this, which give me a list of development tools worth using in Mac OS X 10.7. You can find a lot of websites which compiles a list of development tools on the Internet.

For transforming your Mac into a ‘optimus prime’ of development machine, you can try these steps below:

  1. Installing XCode.

    XCode is a primary requirement for development in Mac. XCode package contains all base files and applications like C-compiler, core libraries which used frequently in UNIX-style installation. (./configure && make && make install). You can download XCode from Apple website, or using Mac App Store. For 10.7 users, you can get the latest version (XCode 4.2) freely from Mac App Store. FYI, XCode itself is a huge package (3-4 GB in size) so you may need a reliable Internet connection for downloading it.

  2. Homebrew

    Homebrew called itself a missing package manager for OSX. You can find it here. Some of old-time Mac users use MacPorts, but I prefer using Homebrew because it is frequently updated, and it is easier to use. Homebrew is easier to install than MacPorts. Homebrew use ‘recipe’ stored in a Git repository, for installing packages.

  3. iTerm2

    A perfect replacement for Terminal app on Mac. You can get all transparent background, full screen support on Lion, and it fixs the most annoying feature on Terminal, it quits when you hit Cmd+D.

  4. TextMate

    I have heard that TextMate is the best text editor around. I have tried to mimic TextMate’s behavious in my Vim editor, using plugins and configurations. Still, I can not get all TextMate’s feature in my Vim. So, when I purchased my Mac, I immediately purchased a license of TextMate. Quite pricy, but as far as I use TextMate, the money was worth it. For you guys whose an TextMate license, you can get TextMate 2 as a free upgrade. Still in alpha phase, but it has a promising future ahead.

  5. Dropbox

    My personal favourite for synchronizing files among my devices. I can store a document in my iPad, preview it in my Nexus S and examine it in my Mac. It works seamlessly, with no annoying prompt whatsoever. If you are an iPad owner, there are tons of applications that use Dropbox as their storage. You will get 2 GB space for free plan, but you can expand it, by spreading the news of Dropbox in your circle of friends or co-workers. You can get extra space up to 4 GB, which is awesome for a free plan.

  6. Evernote

    Another favourite application of mine. Evernote will help you to take note(s) everywhere, in any form of notes. You can store images, sounds, and of course notes. Evernote is a freemium service. I found the free plan is enough, but if you want an offline capability, you can upgrade your account to Evernote Pro. I also use Evernote in combination with Instapaper to store my bookmarks. You can install evernote’s browser extension which allow you to ‘clip’ an website and store it as a note in Evernote. Very helpful, since you might only want to store a slice of a website, not the whole page.

  7. Instapaper

    Instapaper is brillian web application out there. Instapaper provide a service to store a link / page to read later. Instapaper start from iOS platform, where you can save a link and open it later on the other device. I purchased a subscribe account, where I will be able to call all public API without any limit. Instapaper’s services is deeply integrated to my favourite apps in iOS platform, Zite and Flipboard. I can save an article and open it at my Mac using this service.

  8. MacVim

    A port of legendary Vim (VI improved) text editor in Mac OS X. Even I already have my TextMate, I still use Vim because, let’s face it, TextMate is Mac-only Text Editor, while Vim is cross-flatform. Your vim knowledge can save you a lot of time in text editing. I am still learning the shortcuts, which is a lot :)

  9. Google Chrome

    Every Mac ships with Safari as their default browser. Unfortunately, it is slow. It takes a lot of CPU and memory, eventhough I have disabled the flash plugin. Since, Firefox is also a memory hog (even worse!), I turn myself to Google’s Chrome. I use the Chrome browser from stable and canary release. Even Safari and Firefox have released their new version, Chrome is still the best and the fastest browser in town.

These are my development tools in Mac OS X. Some honorable mentions are:

  1. Remind Me Later

    A tiny app sitting in your menu bar waiting for you to enter your agenda. It stores all your agenda (to-do list, event what so ever) in iCal. The best thing is, Remind Me Later understand natural language input. I am not so sure, whether it is iCal’s or Remind Me Later’s feature, but it is awesome!

  2. Pomodoro

    This app helps me to practise Pomodoro Technique. It is a time management system that can help you to improve your productivity. I am a easy-to-lost-focus man, so I really need a better time management. As far as it goes, it is really help me to be better man.

  3. Mou

    I am a fan of John Gruber’s markdown format. Mou is a simple-yet-powerful Markdown editor. It gives you real-time preview of your text. It helps me to write some documents, including my blog posts.

  4. Alfred

    Those Mac veterans must know about QuickSilver, a launcher with a lot of extensions which save your time. Meet Alfred, a great alternative to QuickSilver, it is fast, it is extensible, and the most important thing is, it is still actively developed. You can purhcase Alfred Powerpack to unleash the ability to the highest level.

  5. Go2Shell and DTerm

    Two great utilites to help you interact with your finder. Go2Shell gives you access to Terminal from any folder you open. While DTerm has more generic function, it will allow you to do ANYTHING from your finder. You can find DTerm here. It is awesome application.

And that’s all my apps. Hope you can enjoy it. You can share other apps by commenting this post.

Language in 2011 – Part I

In 2011 I started and/or continued to learn these language(s)

Python

I love how a python code is written. Python has a very detailed guidance for writing their code, so there will be no ambiguous code. Python code is really easy to read, you can learn Python by reading other’s code regularly.  Python also has a functional feature which is very interesting for me. At the moment, I learn Python by creating application in Django, a popular Python Web Development framework.

Ruby

Ruby is another lovely language that I learned this year. I love how a Ruby code can contain such a beautiful code. Ruby use a natural name for their method and syntax, which makes te code is really easy to read. I learned Ruby on Rails, which is currently in 3.0 version. It gives me another perspective in developing web application, which use Convention over Configuration paradigm. I must admit, it is a very interesting approach.

Java

I still learned Java (specially Java SE) because I am teaching a Foundation of Programming Course using Java. I found out that there are plenty of things in Java that I understand after I teach a Java course. It forces me to learn much more, by buying Java Puzzlers book. There are many puzzles that hit me.

Continued to Part II

Beralih ke Mac

Saya merupakan penggemar Apple Inc, dengan segala alat produksinya. Bentuknya yang elegan, prestise yang dibungkus dalam sebuah
kemudahan pemakaian menjadi alasan saya menginginkan gadget keluaran perusahaan asal Cupertino tersebut. Sayangnya keinginan
tersebut terhambat dari sisi pendanaan, di mana harga dari gadget Apple ini terbilang tidak murah. Apalagi sebagai orang komputer,
kita dapat membandingkan spesifikasi dari gadget tersebut dengan produsen lainnya. Terkadang, gadget keluaran Apple ini menggunakan
teknologi yang tidak awam, serta komponen yang paling baru.

Walaupun dengan segala kekurangannya, gadget keluaran Apple tetaplah sebuah gadget yang menarik. Kinerja dari gadget Apple juga tidak
buruk, bahkan bisa dibilang sangat baik dibandingkan dengan kompetitornya. Dengan sistem operasi yang dikembangkan sendiri, maka Apple
dapat menyesuaikan dengan perangkat keras sehingga menghasilkan performa yang sangat baik. Seperti yang pernah diucapkan oleh mendiang Co-Founder Apple, Inc. Steve Jobs, “a good software Company makes its own hardware”. Prinsip ini yang dipegang oleh Apple, sehingga semua komponen dari hulu sampai hilir, diproduksi oleh Apple sendiri.

Kegemaran akan gadget Apple ini saya tularkan juga ke orang sekeliling saya. Orang pertama yang terpengaruh adalah istri saya (saat itu
masih menjadi pacar), yang sedang mencari sebuah laptop untuk mendukung pekerjaannya sebagai dosen dan aktivitasnya sebagai mahasiswa
pascasarjana. Sebuah MacBook White menjadi pilihannya, karena warna putihnya yang manis serta daya tahan baterainya yang sangat mendukung mobilitasnya. Korban berikutnya adalah adik sendiri, yang juga membeli MacBook White, tidak lama setelah Apple mengeluarkan sistem operasi terbaru dari seri kucing besar, yaitu MacOS X 10.5 Leopard. Berbagai macam animasi, serta terobosan yang dikemas dengan sangat baik membuat saya semakin bernafsu untuk mengumpulkan uang demi gadget Apple. Terlebih lagi saat adik saya memutuskan untuk membeli sebuah iPod Touch, yang menjadi teman baik dalam menghabiskan waktu untuk bersenang-senang.

Setelah bekerja beberapa lama, dan mengumpulkan uang, akhirnya saya mendapatkan rezeki untuk membeli gadget Apple. Yang lucu, gadget Apple yang saya beli bukan sebuah komputer, melainkan tablet keluaran Apple, yaitu iPad. Saya sudah naksir berat dengan gadget tersebut saat
pertama kali diperkenalkan. Saat itu saya berpikir, iPad dapat menjadi sebuah gadget yang memenuhi kebutuhan saya untuk mengakses Internet saat pulang dari kantor. Terlebih lagi, saya sudah memasang jaringan nirkabel di rumah, yang terhubung dengan Internet berkecepatan dan  stabil tanpa kuota. Dengan iPad, saya tidak perlu mengeluarkan laptop hanya untuk melihat email atau mengikuti berita terkini serta  memantau lini masa jejaring sosial saya. Berbarengan dengan momen tersebut, istri berkeinginan untuk melakukan upgrade MacBook White-nya yang dirasakan sudah lambat dengan MacBook Pro yang memiliki kekuatan komputasi lebih baik.

Tidak lama saat iPad masuk ke negeri tercinta ini, Apple mengumumkan ketersediaan baru dari MacBook Air, sebuah laptop ultra ringan dengan tebal tidak lebih dari 2 cm. Selama ini, MacBook Air dikemas dengan spesifikasi yang jauh lebih rendah dibandingkan MacBook White atau MacBook Pro, karena ruang yang tersedia jauh lebih kecil. Akan tetapi, di awal tahun ini, produsen prosesor Intel, yang menjadi mitra
Apple selama beberapa tahun ini sebagai pemasok prosesor untuk MacBook dan Mac telah berhasil membuat versi chipset terbarunya, yaitu
Sandy Bridge dengan ukuran yang cocok dengan spesifikasi MacBook Air. Keberhasilan ini menghasilkan sebuah laptop yang sangat ringan,
namun di saat yang sama, memiliki kekuatan komputasi jauh di atas MacBook Pro. Dengan menggunakan harddisk SSD, maka kecepatan proses dari MacBook Air jauh meningkat dibandingkan sebelumnya. Hal yang terbaik adalah, Apple menurunkan harga dari MacBook Air sehingga lebih terjangkau.

Saat tersebut adalah saat yang sangat membahagiakan, mengingat saya sudah lama menginginkan sebuah laptop MacBook, namun dengan berat yang ringan. Selama ini, keluhan saya mengenai MacBook Air adalah konektivitas yang tersedia, mengingat hanya menyediakan koneksi jaringan nirkabel saja. Akan tetapi, setelah menggunakan iPad selama beberapa waktu, saya merasakan bahwa hal tersebut bukan menjadi masalah. Dengan keberadaan App Store dan Mac App Store, proses instalasi aplikasi tidak membutuhkan media optik lagi. Dan kondisi jaringan nirkabel yang dapat diandalkan juga membuat MacBook Air semakin menjadi pilihan.

MacBook AirSetelah membaca review, yang menyebutkan bahwa generasi MacBook Air ini merupakan laptop Apple yang paling baik, saya memutuskan untuk membeli sebuah MacBook Air dengan spesifikasi Intel Core i5, memori 4 GB, serta 128 GB SSD sebagai storage. Saya juga membeli USB to
Ethernet sebagai langkah pencegahan, serta memesan Incipio Feather Case untuk melindungi MacBook Air ini. Dengan tenaga baru dari
sistem operasi MacOS X Lion, yang membawa beberapa fitur iOS di iPad ke dalam Mac, saat ini MacBook Air sudah menjadi mesin utama
dalam bekerja dan bersenang-senang.

Kembali nge-blog

Selama ini, saya menggunakan fitur automated posting dari WordPress yang menghubungkan akun delicious.com dengan blog ini. Fitur tersebut akan membuat sebuah posting di blog ini yang berisikan link yang hasil penyimpanan link dari delicious.com. Hampir selama 1 tahun, blog ini hanya berisikan posting dari link delicious.com.

Saat lebaran tahun 2011, timbul masalah dalam auto posting yang disediakan oleh WordPress.com. Setiap link dari delicious.com muncul berkali-kali dalam posting blog. Permasalahan ini sangat mengganggu, terutama karena blog ini terhubung dengan twitter, sehingga memenuhi Timeline twitter saya. Setelah mendapatkan akses Internet, maka saya menon-aktifkan link dari blog ini ke twitter.com sebagai tindakan penyelesaian sementara.

Setelah liburan selesai, saya tetap tidak punya waktu untuk mencari penyebab mengapa postingan link dari delicious.com ini bermasalah. Sampai akhirnya, delicious.com mengubah API dan posting mengenai link ini akhirnya berhenti. Sungguh disayangkan, mengingat delicious.com ini telah menjadi pilihan saya untuk menyimpan bookmark.

Akhirnya di saat saya memiliki waktu luang, saya memulai ‘pembersihan’ terhadap blog ini. Ternyata sangat sulit untuk melakukan penghapusan terhadap banyak posting di WordPress.com. Beberapa kali saya mendapatkan pesan kesalahan dalam proses penghapusan.

Saat ini saya sekarang mencoba berkomitmen untuk menuliskan posting ke blog ini, minimal 1 minggu sekali. Saya ingin mengembalikan blog ini ke tujuannya semula, yaitu sebagai tempat untuk menampung semua pendapat, pembelajaran, dan tidak ketinggalan keluhan. Semoga dapat memberikan manfaat bagi sesama.

links for 2011-10-09

links for 2011-09-26

Follow

Get every new post delivered to your Inbox.