Februari 04, 2013

An Overview of Rule-Based System

Rule-Based System has slowly become an important part of Web application. This fact has been realized by many since a tremendous amount of resources start to appear on the Web. As this high volume of data and information availability appear on the Web, confusion among Web users increased. This confusion is attributed to information flood, experienced by users. Not only information flood, a lot of different things and inconsistencies happened on the Web, not to mention too many Web browsers with different capabilities in implementing standards and specifications. Different services (see *anything* as a Service) offered on the Internet. All of those things basically trigger a simple question: how can we use Internet effectively and efficiently without drowning ourselves into those confusion? Can we use something like agent (in the real world) to represent us on the Internet and doing many things automatically without our intervention?

Those questions basically are simple questions but the answers have an immense impact and involve multidisciplinary approach. Surely I can not approach the answers from all disciplines, instead I will concentrate on my background in Web Engineering although I will also include other things as well when needed. We will focus our discussion into automated jobs -- done by software agent, be it in integrated into Web application, or as a stand alone headless software agent -- so that the benefit for human is real.

Currently, to answer those important questions, people and researcher from computer science and information systems make use of techniques and methods from Artificial Intelligence field. This advancement in Web is not necessarily a new phenomenon or new method or other new things. It is merely an application of many Artificial Intelligence methods and techniques to the new platform: Web. These things are different in Artificial Intelligence era where data, knowledge, and facts are integrated internally into the system, isolated from external access. On the Web, things are much more uncontrollable, even with many hard work in the field of standards and specifications (see W3C website for more info about this). Web provides data, information, knowledge, and facts, but they seem to be much more uncontrollable and provide bigger uncertainty level (resources probably exist today, but tomorrow they will disappear without notice, resulting DNS lookup failure or 404 HTTP status or probably 500 Internal Server Error). Therefore, working with Web means that we have to understand that we may not have 100 percent success and we may also hope that we still have some successful efforts.

To benefit its users, Web need to be provide resources. In this sense we may have three categories:

  1. Syntactic Web: this Web application is a kind of Web application which only provide resources for human consumable resources. It does not provide (or if provide, it will provide very minimal) machine understandable data. Users can understand what has been written on the Web browser application, but we may not use automatic agent to process them, provide automatic job processing for human.
  2. Semantic Web: this Web application provide machine understandable data format. It enables software agent to understand the data inside so that we may then use software agent to automate job processing.
  3. Pragmatic Web: this Web application provides not only semantic content, but also integrate context into the application, therefore it enables the software agent to understand context of the resources and then enable them to communicate further towards social commitments. Rule-based system is very important in this context.
Now we should understand the importance of semantic content and rules which are integrated into Web application. Therefore, it is important for Web developers to understand how to integrate rule-based system into the Web application. 

To understand the Rule-based system, until now, there are some important Rule-based System which may be used on the Web. 
  1. Deductive Databases System: this system works by making deductions (conclusion) based on rules and facts which is stored in a databases system. One example of this system is Datalog which is syntactically a subset of Prolog.
  2. Rule engines for triples: triple here is RDF data model (Subject-Predicate-Object). RDF is used to make a statement about resources, something like "Bambang creates an article on Pragmatic Web" which consists of resources "Bambang" and "an article on Pragmatic Web" with "creates" as the predicate. 
  3. Prolog-based System: introduces logic programming, took a restricted form of first-order logic.
  4. Production Rule System: in production rule system, the application will implements a notion set of rules and each rule has a condition and a consequential action.
  5. Reactive Rule System: in reactive rule system, the application has the ability to detect an event and then react to that event automatically.
  6. Knowledge-based System: provide knowledge base so that it enables software agent to make intelligent reasoning.
I will discuss those Rule-based system more detail later. Stay tuned.






Pragmatic Web: Tinjauan Arsitektural, LAP, dan Rule-Based System


Pragmatic Web merupakan perkembangan selanjutnya dari visi Semantic Web, meskipun ada banyak tulisan serta riset yang menyatakan bahwa yang dimaksud oleh Tim Berners-Lee pada saat mencetuskan visi Semantic Web ini merupakan hal yang ingin diwujudkan oleh Pragmatic Web ini. Pragmatic Web sebenarnya masih merupakan suatu hal yang baru dan tidak hanya terbatas pada mewujudkan sumber daya di Web yang mempunyai nilai semantik, tetapi sudah sampai ke arah pemanfaatan sumber daya semantik di Web untuk menghasilkan komitmen sosial serta kolaborasi. Dari pengertiak tersebut, kita bisa memahami bahwa Pragmatic Web tidak akan mendapatkan hasil yang maksimal tanpa sumber daya semantic di Web. Secara sederhana, kita bisa mengatakan bahwa Pragmatic Web menambahkan informasi kontekstual yang memungkinkan adalah komunikasi antara aplikasi Pragmatic Web tersebut dengan aplikasi Pragmatic Web lain maupun intelligent agent di Web. Tidak hanya komunikasi, dengan adanya konteks tersebut, bisa dilakukan aksi / action sehingga bisa terjadi komitmen sosial maupun tidak terjadi komitmen sosial.

Secara arsitektural, Pragmatic Web masih menggunakan interaksi dasar client-server di Internet serta berbagai macam infrastruktrur hardware maupun software. Pragmatic Web memperoleh banyak insight dari penelitian tentang LAP (Language/Action Perspective) yang dipelopori oleh Terry Winograd. LAP menunjuk pada adanya keterkaitan antara bahasa dengan aksi yang diharapkan dari komunikasi bahasa tersebut. Winograd menyatakan bahwa LAP ini bisa menjadi suatu paradigma baru untuk merancang sistem informasi. Sebagai trigger dari action, bahasa yang terdiri atas 3 bagian, yaitu sintaks, semantik, serta pragmatik, menjadi tiga hal utama yang diperhatikan dalam merancang dan mengimplementasikan suatu sistem komputer. Bahasa mempunyai keterkaitan erat dengan aksi yang akan dilakukan oleh pihak yang diajak berkomunikasi. Searle mendefinisikan 5 hal fundamental dari kalimat bahasa yang diucapkan:
  • Assertive: ketegasan dalam menyatakan kebenaran suatu hal
  • Directive: menyatakan perintah yang harus dilaksanakan oleh pihak yang diajak berkomunikasi (baik 'keras' maupun halus).
  • Commissive: pihak yang mengkomunikasikan akan berkomitmen melaksanakan suatu hal yang akan dikerjakan di masa yang akan datang.
  • Declaration: mengumumkan suatu hal.
  • Expressive: ekspresi tentang suatu hal, misalnya sedih, gembira, memuji, dan lain-lain.
Insight dari LAP ini bisa diterapkan dalam dunia Web. Web pada dasarnya merupakan sistem tanda (dilihat dari sisi semiotika) yang berfungsi untuk mengkomunikasikan sesuatu. Klien (browser maupun headless software agent) adalah pihak-pihak yang berkomunikasi dengan aplikasi Web. Meski demikian, ada hal yang harus dipahami, bahwa Pragmatic Web terkait dengan komunikasi antar aplikasi, bukan antara manusia dengan komputer (HCI). Ini diperlukan karena terlalu banyak sumber daya di Internet dan manusia akan kerepotan dengan hal tersebut. Otomatisasi merupakan hal yang harus diperjuangkan di Internet. Pragmatic Web memungkinkan adanya interaksi serta komunikasi dan komitmen sosial secara otomatis antar aplikasi on behalf of human.

Jika demikian, bagaimana suatu aplikasi Web bisa membentuk Pragmatic Web? Pragmatic Web, secara sederhana merupakan aplikasi Web biasa dengan penambahan pada kandungan semantik dari data / informasi yang dieksploitasi untuk keperluan klien, serta mekanisme yang memungkinkan adanya komunikasi antar aplikasi dan komitmen sosial antar aplikasi tersebut. Mekanisme yang sampai saat ini dirasakan penting dan masih diteliti oleh banyak peneliti adalah integrasi dari Rule-based System ke dalam aplikasi Web. Hal ini memungkinkan agent memahami konteks dari informasi yang terdapat dalam suatu sumber daya dan kemudian bisa melakukan hal-hal tertentu berdasarkan definisi validitas pada Rule-based System tersebut. Integrasi ini memungkinkan implementasi dari insight LAP di atas ke dalam Web. Dengan menggunakan sumber daya semantik serta Rule-based System, suatu aplikasi Pragmatic Web bisa mendefinisikan 5 hal fundamental seperti yang ditulis oleh Searle di atas. 

Masih ada banyak hal yang harus dibenahi dan diimplementasikan dalam hal ini, diantaranya adalah:
  1. Interoperability antar Rule-based System. W3C sudah mendefinisikan RIF untuk keperluan interchange format dari sekian banyak format dan teknologi (RuleML, JSON-Rule, F-Logic, Datalog, SWRL, dan lain-lain). Interoperability ini merupakan hal yang kompleks dan barangkali bisa menjadi suatu disertasi sendiri.
  2. Desain arsitektural dari aplikasi Pragmatic Web. Kandidat untuk keperluan ini adalah memanfaatkan arsitektur yang dikembangkan oleh Roy T. Fielding: REST. Penggabungan REST dengan teori dari Searle di atas akan memungkinkan implementasi LAP di Web.
  3. Service Discovery. Jika aplikasi Pragmatic Web sudah dibuat, bagaimana agent bisa menemukan service yang ditawarkan oleh aplikasi tersebut?
  4. Bagaimana metodologi untuk mengembangkan aplikasi Pragmatic Web tersebut? 
Problem-problem di atas akan banyak terbantu dengan adanya referensi arsitektur dari aplikasi Pragmatic Web. Saat ini saya sedang mengembangkan arsitektur referensi berdasarkan model referensi berikut:


Model referensi awal ini akan dirinci ke dalam suatu referensi arsitektur. Referensi arsitektur sudah menyertakan komponen-komponen nyata dan akan saya tuliskan seiring dengan berkembangnya disertasi saya. 


Desember 04, 2012

Tema skripsi untuk JavaScript Ninja wannabe


Berikut saya berikan daftar mengenai tema skripsi bagi mahasiswa yang akan mengambil skripsi, khususnya bagi yang berminat di dunia JavaScript. Semua yang saya uraikan disini meliputi JavaScript di sisi server maupun di sisi client. Istilah JavaScript ninja sebenarnya merupakan istilah informal yang merujuk pada seorang developer dengan kemampuan pemrograman JavaScript yang sangat bagus. Istilah ini bahkan digunakan dalam buku yang ditulis oleh John Resig (you know him, right?): Secrets of the JavaScript Ninja (http://jsninja.com). Nah, jika anda ingin menjadi JavaScript ninja, mengapa tidak mulai mendalami dari saat kuliah dan mengambil materi skripsi tentang JavaScript? Silahkan ambil yang anda sukai dari daftar berikut ini dan gunakan kreativitas anda untuk membuat daftar ini menjadi judul yang lengkap:
  1. Membuat plugin Node.js menggunakan node-gyp (https://github.com/TooTallNate/node-gyp)
  2. Interoperabilitas Google Dart dengan JavaScript (http://www.dartlang.org/articles/js-dart-interop/)
  3. Behaviour-Driven Development menggunakan Jasmine (http://pivotal.github.com/jasmine/)
  4. Headless full-stack testing di Node.js menggunakan ZombieJS (http://zombie.labnotes.org/)
  5. Asynchronous testing menggunakan Mocha (http://visionmedia.github.com/mocha/)
  6. Headless testing menggunakan PhantomJS (http://www.phantomjs.org danhttps://github.com/ariya/phantomjs/wiki/Headless-Testing)
  7. Pengembangan aplikasi berbasis pattern Resourve-View-Presenter menggunakan FlatironJS (http://flatironjs.org)
  8. Aplikasi CLI (Command Line Interface) menggunakan FlatironJS (http://blog.jit.su/writing-cli-apps-with-flatiron)
  9. Navigation scripting dan utilitas testing menggunakan CasperJS (http://casperjs.org)
  10. Semantic template menggunakan Handlebars (http://handlebarsjs.com/)
  11. Modernizr sebagai peranti bantu pengembangan aplikasi HTML5 dan CSS3 (http://modernizr.com)
  12. Asynchronous web testing menggunakan Mocha (http://visionmedia.github.com/mocha/)
  13. Pengembangan aplikasi cloud menggunakan Node.js
  14. Pengembangan aplikasi web menggunakan NoSQL: studi kasus Node.js dan Mongoose
  15. Teknologi middleware Connect - termasuk pengembangan plugin Connect (http://www.senchalabs.org/connect/)
  16. Cross-browser websocket untuk aplikasi realtime menggunakan Socket.IO (http://socket.io)
  17. Pengembangan plugin GruntJS (http://gruntjs.com)
  18. Framework / Pustaka MVC di JavaScript (lihat daftarnya di http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/)
  19. Pengembangan aplikasi web menggunakan ExpressJS (http://expressjs.com/)
  20. Membangun aplikasi dengan teknologi obyek di JavaScript menggunakan oolib (http://idya.github.com/oolib/)
  21. Membangun aplikasi desktop berbasis HTML5, CSS3, dan JavaScript menggunakan TideSDK (http://www.tidesdk.org/)
Tentu saja ini bukan daftar yang lengkap di dunia JavaScript yang sedemikian kompleks. Jika ada tambahan lagi, catatan ini akan saya edit. Jadi, selamat menikmati proses menjadi JavaScript ninja!

Oktober 02, 2012

Git dan Github: Petunjuk Awal

Mengambil dari repo
  • git clone [lokasi]
Contoh:
  • git clone https://github.com/bpdp/buku-cloud-nodejs.git (jika menggunakan https)
  • git clone git://github.com/bpdp/buku-cloud-nodejs.git (jika menggunakan git)
Membuat repo baru di lokal
  • Buat direktori baru
  • Masuk ke direktori baru tersebut
  • Menambahkan semua file:
    • git add -A
  • Commit:
    • git commit -m "First commit - initializing empty repo"
Melihat status repo lokal
    • git status
File baru di repo
  • Menambahkan file
    • git add [file]
  • Commit:
    • git commit -m "Menambahkan file untuk ..."
  • push ke github
Mengedit file
  • Edit file
  • Commit:
    • git commit -m "Pesan"
  • push ke github
Push ke github
  • Menetapkan repo:
    • git remote add origin
      • contoh: git remote add origin https://github.com/bpdp/buku-cloud-nodejs.git
  • Push:
    • git push origin master

Agustus 24, 2012

Quick and Dirty Hack: Memeriksa dan Membandingkan Versi NodeJS

Salah satu "masalah" dari NodeJS adalah siklus rilis yang saya pikir "terlalu cepat". Seringkali bolak-balik ke website NodeJS untuk melihat apakah sudah ada rilis stabil terbaru atau belum. Sebenarnya tidak harus seperti itu, hanya saja, saya termasuk manusia aneh yang menyukai berada di posisi bleeding edge, jadi setiap ada rilis stabil terbaru, rasanya hidup tidak lengkap jika tidak menggunakan rilis terbaru. Hehehe ...

Nah, untuk keperluan itu, karena saya "capai" bolak-balik, maka saya pakai "script" untuk mengotomatiskan pekerjaan saya. Sederhana saja dan blatantly copied dari contoh di node.io. Untuk menggunakan script ini, silahkan install dulu node.io dan nanti sesuaikan lokasi modul ini di komputer anda:



#!/usr/bin/env node.io

var nodeio = require('/opt/software/nodejs/lib/node_modules/node.io');

exports.job = new nodeio.Job({
  input: false,
  run: function () {
    var url = "http://www.nodejs.org/download";
    this.getHtml(url, function(err, $) {
      if (err) {
        console.log(err);
        this.exit(err);
      } else {
        ver = $('b').text;
        console.log('Latest version: ' + ver);
        console.log('Local version: ' + process.version);
      }
    });
  }
});


Script ini (checknode.js) saya chmod +x dan saya letakkan di $PATH, jadi sewaktu-waktu ingin memeriksa, tinggal jalankan script ini:

[bpdp@bpdp-arch checknode]$ checknode.js 
Latest version: v0.8.8
Local version: v0.8.8
[bpdp@bpdp-arch checknode]$


Sayangnya, website NodeJS ini belum meng-embedd data semantik di dalamnya sehingga saya hanya berpatokan pada tag HTML Bold yang menandai versi stabil terbaru dari NodeJS. Akibatnya ya nanti jika struktur isi website NodeJS berubah, maka script ini juga akan "hancur". Lebih bagus jika website NodeJS menggunakan ontologi untuk software seperti The Software Ontology. Well, probably someday :)

Sebenarnya script ini bisa ditambahi fitur untuk mendownload versi baru (jika ada versi baru), tapi nanti dulu deh. Not so important. Yang penting ini dulu saja. Enjoy!

Agustus 23, 2012

Arch Linux Package for ArangoDB

Finally I can finish ArangoDB package PKGBUILD for Arch Linux. The people at triAGENS are helpful. Have to say thank you for their help, especially @steemann, @loremsqlsum, and @fceller. The package can be installed just by using yaourt -S arangodb.

The package PKGBUILD can be downloaded from https://aur.archlinux.org/packages.php?ID=62227



Enjoy!

Agustus 21, 2012

Change Python Interpreter Temporary (python3 -> python2)

I came across this difficulty when I try to install ArangoDB. It comes with V8 Javascript engine from Google bundled in. Installing V8 requires Python 2, not Python 3 which is the default in my Arch Linux box.

[bpdp@bpdp-arch V8]$ ls `which python`
lrwxrwxrwx 1 root root 7 Apr 24 06:48 /usr/bin/python -> python3
[bpdp@bpdp-arch V8]$

Luckily, V8 uses "#/usr/bin/env python", not "#/usr/bin/python". To change this behaviour, all I have to do is just ask "env" to use my python2 interpreter. Here's how:

1. Create symlink to python2 under the name "python"
I put the symlink into my "$HOME/bin" directory.
$ cd ~/bin
$ ln -s /usr/bin/python2 python

2. Put into PATH

$ export PATH=~/bin:$PATH

"~/bin" should preced $PATH because env use the first setting.

[bpdp@bpdp-arch arangodb]$ which python
/home/bpdp/bin/python
[bpdp@bpdp-arch arangodb]$ env python
Python 2.7.3 (default, Apr 24 2012, 00:06:13) 
[GCC 4.7.0 20120414 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

There you go!

Agustus 16, 2012

NodeJS Installation Without OS Package Management

I use Arch Linux for all my OS activities. Arch Linux has NodeJS package and can be easily installed using pacman -S nodejs but you may see that NodeJS has fast release cycle that my Arch Linux package is sometimes left behind and also sometimes I want to use a specific version (for example, Ace - and editor part of Cloud9 IDE - can not work with NodeJS 0.8.x, it needs 0.6.x). Under this scheme, it can be difficult to deal with OS package management. That said, I need to use my own way to resolve this.

So, here is the way to solve the problem. Download the binary version of NodeJS or directly go to http://nodejs.org/dist/ and get the one you need. Extract into specific directory then setup some environment variables into .bashrc so that it will be read automatically whenever I login, or put that into a file and source it whenever I need it. That's all. The details will follow if you are really helpless.

1. Download the binary version. Here I use version 0.8.7:

[bpdp@bpdp-arch nodejs]$ ls -la
total 4320
drwxr-xr-x  2 bpdp users    4096 Aug 17 06:08 .
drwxr-xr-x 22 bpdp users    4096 Aug 16 16:17 ..
-rw-r--r--  1 bpdp users 4401729 Aug 16 06:19 node-v0.8.7-linux-x86.tar.gz
[bpdp@bpdp-arch nodejs]$ 

2. Extract into the directory of your own choice:

[bpdp@bpdp-arch software]$ tar -xzvf ~/master/nodejs/node-v0.8.7-linux-x86.tar.gz
[bpdp@bpdp-arch software]$ ln -s node-v0.8.7-linux-x86 nodejs
[bpdp@bpdp-arch software]$ ls -la
....
....
drwxr-xr-x   6 bpdp users  4096 Aug 16 06:18 node-v0.8.7-linux-x86
lrwxrwxrwx   1 bpdp users    21 Aug 17 06:37 nodejs -> node-v0.8.7-linux-x86
....
....
[bpdp@bpdp-arch software]$ 

3. Set some environment variables

[bpdp@bpdp-arch environment]$ cat nodejs 
NODEJS_HOME=/home/bpdp/software/nodejs

PATH=$PATH:$NODEJS_HOME/bin
MANPATH=$MANPATH:$NODEJS_HOME/share/man
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NODEJS_HOME/lib
C_INCLUDE_PATH=$C_INCLUDE_PATH:$NODEJS_HOME/include
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$NODEJS_HOME/include

export PATH
export MANPATH
export LD_LIBRARY_PATH
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH
[bpdp@bpdp-arch environment]$ 

4. Source it whenever you need it:

$ source ~/environment/nodejs

Note: I put the env var into a file: $HOME/environment/nodejs

5. Surely you may also put that into your $HOME/.bashrc for automatic activation.

That's all. Happy coding!

Agustus 14, 2012

Working with GitHub and Clojars


This guide is used as a note for myself. If you can benefit from this note, that's fine. Here I just wish to document how I work with GitHub and Clojars. I need to do this since I have my own need for Ring middleware to reload automatically a server without restart whenever a namespace in Ring is modified. The original version was not maintained I think, since it uses Clojure 1.2.0.

GitHub

I forked the ring-reload-modified to my Github account. This can be done easily using step 1 and 2 from https://help.github.com/articles/fork-a-repo (I use only step 1 and 2 since I only want to fork and modified my forked version, not upstream version).

Let's say for this time I just want to edit the README.md and project.clj files. After I edit those files, I just put them in committed state:

[bpdp@bpdp-arch ring-reload-modified]$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add [file]..." to update what will be committed)
#   (use "git checkout -- [file]..." to discard changes in working directory)
#
# modified:   README.md
# modified:   project.clj
#
no changes added to commit (use "git add" and/or "git commit -a")
[bpdp@bpdp-arch ring-reload-modified]$

We can see from the status that it has 2 changes: README.md and project.clj but I haven't commit anything. Here's how to commit:

[bpdp@bpdp-arch ring-reload-modified]$ git commit -a
[master ada41aa] Adjust to latest Clojure version (1.4.0)
 2 files changed, 8 insertions(+), 4 deletions(-)
[bpdp@bpdp-arch ring-reload-modified]$ 

Then it's time to push the committed version to Github repository:

 [bpdp@bpdp-arch ring-reload-modified]$ git push origin master
 Username for 'https://github.com': bpdp
 Password for 'https://bpdp@github.com': 
 Counting objects: 7, done.
 Delta compression using up to 2 threads.
 Compressing objects: 100% (4/4), done.
 Writing objects: 100% (4/4), 721 bytes, done.
 Total 4 (delta 2), reused 0 (delta 0)
 To https://github.com/bpdp/ring-reload-modified.git
    6dfdc5c..ada41aa  master -> master
 [bpdp@bpdp-arch ring-reload-modified]$

Let's see the result in Github profile:



The result in Github project page (I have pushed another commit so the history is different with above).



Clojars

To upload the library, I need to prepare my ssh public key first:

[bpdp@bpdp-arch ring-reload-modified]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bpdp/.ssh/id_rsa): 
/home/bpdp/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/bpdp/.ssh/id_rsa.
Your public key has been saved in /home/bpdp/.ssh/id_rsa.pub.
The key fingerprint is:
87:fc:8f:35:18:20:2e:8f:73:d2:b5:71:ea:0e:85:01 bpdp@bpdp-arch
The key's randomart image is:
+--[ RSA 2048]----+
|    E            |
|     .           |
|      o .        |
|     . = o       |
|    . o S +      |
|     = o B o     |
|    + = o o o    |
|     + o   + .   |
|       .o . .    |
+-----------------+
[bpdp@bpdp-arch ring-reload-modified]$

The public key should be put into the Clojars first. So, first we need to register by using http://clojars.org/register:



Now, it's time to upload to Clojars:

[bpdp@bpdp-arch ring-reload-modified]$ lein2 jar   
Created /home/bpdp/master/clojure/libs/ring-reload-modified/target/ring-reload-modified-0.1.2.jar
[bpdp@bpdp-arch ring-reload-modified]$ lein2 pom
Wrote /home/bpdp/master/clojure/libs/ring-reload-modified/pom.xml
[bpdp@bpdp-arch ring-reload-modified]$ scp pom.xml target/ring-reload-modified-0.1.2.jar clojars@clojars.org:
Enter passphrase for key '/home/bpdp/.ssh/id_rsa': 
Welcome to Clojars, bpdp!
pom.xml                                                           100% 2672     2.6KB/s   00:00    
ring-reload-modified-0.1.2.jar                                    100% 5328     5.2KB/s   00:00    

Deploying org.clojars.bpdp/ring-reload-modified 0.1.2

Success! Your jars are now available from http://clojars.org/
[bpdp@bpdp-arch ring-reload-modified]$

Now I can use the library that I upload to Clojars:



That's all big guy. Have a happy hacking!


Agustus 12, 2012

Mengakses Basis Data Graph OrientDB Menggunakan Clojure

OrientDB adalah salah satu basis data NOSQL dengan kemampuan basis data obyek, graph, document, serta flat. API untuk basis data ini bermacam-macam dan karena dikembangkan menggunakan Java, maka API yang paling utama adalah Java, meski demikian, tersedia juga API untuk JavaScript dan implementasi bahasa-bahasa pemrograman berbasis JVM seperti Clojure dan Scala.

Pada tulisan ini saya akan sedikit membahas tentang akses dengan menggunakan Clojure. Wrapper Clojure untuk API OrientDB dibuat oleh Eduardo Julián. Versi binary bisa diperoleh dari http://clojars.org melalui Leiningen dan versi kode sumber bisa diperoleh di https://github.com/eduardoejp/clj-orient (sayangnya, dokumentasi kurang jelas). Langkah sederhana berikut digunakan untuk mengakses OrientDB dari Clojure menggunakan Leiningen.

1. Buat project

$ lein new orientweb

2. Hasil:

[bpdp@bpdp-arch orientweb]$ tree
|-- README.md
|-- doc
|   `-- intro.md
|-- project.clj
|-- src
|   `-- orientweb
|       `-- core.clj
`-- test
    `-- orientweb
        `-- core_test.clj
5 directories, 6 files
[bpdp@bpdp-arch orientweb]$ 

3. Edit project.clj, isikan berikut ini:
 
(defproject orientweb "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
               :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                         [clj-orient "0.5.0"]]
  :main orientweb.core)

4. Download dependencies dengan perintah:
 
lein deps

5. Koneksi terdapat pada file core.clj
 
(ns orientweb.core)
(require '[clj-orient.core :as orientcore]
            '[clj-orient.graph :as orientgraph])
 
(orientcore/set-db! (orientgraph/open-graph-db! "remote:localhost/demo" "admin" "admin"))

(def mydb (orientcore/db-info orientcore/*db*))

(defn -main 
   [& args]
   (println "Information about the database:")
   (doseq [[key val] mydb] (prn key val))
   (orientcore/close-db!))

6. Hasil eksekusi:
 
[bpdp@bpdp-arch orientweb]$ lein compile
Compiling orientweb.core
Compilation succeeded.
[bpdp@bpdp-arch orientweb]$ lein run
All namespaces already :aot compiled
Information about the database:
:name "demo"
:url "remote:localhost/demo"
:status "OPEN"
:user #
[bpdp@bpdp-arch orientweb]$ 

Happy hacking!