armansyah.web.id
Because Blogging Still Matters
July 10, 2011
Everybody Moves To Google Plus
I don't blog so often and I think that the most famous social network such as Facebook and Twitter are now just boring. But hey, Google comes with a big surprise by launching its new service, Google+.
Google+ is now a new part of Google Family and considered to become the 'Facebook killer'. I my self compare it with IOS vs Android in which Facebook vs Google+ have a few similarities but have some fundamental differences.
Unfortunately, Google+ is still in limited field trial test until Google will finally ready to release it for public. Moreover, we must have an invitation in order to become a field tester. If you don't have a friend who have a G+ account yet, just fill in this form.
Fortunately, I have already been invited. Overall, I love the service and let's see it improves in the upcoming weeks.
Well, I'll be glad to see you there too. Don't forget to circle me (add me). Of course, it would be an honor for me to deliver you an invitation too :)
March 23, 2011
Python + Apache with Mod_wsgi in Windows
I intended to write this technical note for fun and possibly as my reference in the future. I have tested it on my Windows box as my consideration that there has been a lot of similar stuff written for Linux. I often use Windows for my previous small projects as the client required.
Installing python, django and any other stuffs that needed to make it work are beyond the scope of this note since I think that there's no big challenges to make them work perfectly, especially in development environment. Challenges will occur as developers run into production.
My resources:
Windows XP Pro SP3
Apache 2.2.17 (WAMP 2.1)
mod_wsgi
Python 2.7
My apache's document root is located at: c:/wamp/www. I created a directory named 'wsgi', so the full path is: c:/wamp/www/wsgi. I assumed that it would be accessed via http://localhost/wsgi/.
I added a file called dispatcher.py inside the wsgi directory. Here's a piece of code within 'dispatcher.py':
<Directory "c:/wamp/www/wsgi">
Well, It's just a simple code to print 'Hello World' to make sure that mod_wsgi + apache is working seamlessly and we are ready for the next adventures.
Installing python, django and any other stuffs that needed to make it work are beyond the scope of this note since I think that there's no big challenges to make them work perfectly, especially in development environment. Challenges will occur as developers run into production.
My resources:
Windows XP Pro SP3
Apache 2.2.17 (WAMP 2.1)
mod_wsgi
Python 2.7
My apache's document root is located at: c:/wamp/www. I created a directory named 'wsgi', so the full path is: c:/wamp/www/wsgi. I assumed that it would be accessed via http://localhost/wsgi/.
I added a file called dispatcher.py inside the wsgi directory. Here's a piece of code within 'dispatcher.py':
def application(environ, start_response):
status = '200 OK'The next step is to modify apache configuration (httpd.conf) in order to make it recognize python applications. The following lines are appended to httpd.conf and require that mod_wsgi has been installed in c:\wamp\bin\apache\Apache2.2.17\modules\mod_wsgi.so.
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /wsgi "c:/wamp/www/wsgi/dispatcher.py"
Allow Override None
Options None
Order deny,allow
Allow from all
</Directory>
</Directory>
Well, It's just a simple code to print 'Hello World' to make sure that mod_wsgi + apache is working seamlessly and we are ready for the next adventures.
March 09, 2011
JRuby on Rails 3 + Sqlite3
Tidak bisa dipungkiri bahwa performance rails untuk production, khususnya Ruby MRI merupakan salah satu isu yang selama ini sering diributkan di kalangan developer.
Salah satu alternatif untuk mendeploy aplikasi Ruby on Rails adalah menggunakan JVM, tentu saja dengan JRuby.
Resources:
1. Download lalu install JRuby
Install Rails:
Buat aplikasi JRuby on Rails:
Edit gemfile:
if defined?(JRUBY_VERSION)
gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jruby-openssl'
gem 'jruby-rack'
gem 'warbler'
else
gem 'sqlite3-ruby', :require => 'sqlite3'
end
Edit database.yml, ganti adapter sqlite3 menjadi:
Jalankan bundle install untuk mengupdate/menginstall seluruh gem beserta dependencynya:
Jalankan webserver default (webrick), lalu browse http://localhost:3000
Test dengan membuat sebuah scaffold, sebagai contoh kita buat scaffold Product.
Buat/migrasikan table (products) ke database:
jruby -S rake db:migrate
Browse http://localhost:3000/products, done!
Tested under Windows XP SP3 Pro dengan spesifikasi:
Selamat mencoba. Let's code for fun. CMIIW.
Salah satu alternatif untuk mendeploy aplikasi Ruby on Rails adalah menggunakan JVM, tentu saja dengan JRuby.
Resources:
1. Download lalu install JRuby
Install Rails:
jruby -S gem install rails
Buat aplikasi JRuby on Rails:
jruby -S rails new myapp --template http://jruby.org
Edit gemfile:
if defined?(JRUBY_VERSION)
gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jruby-openssl'
gem 'jruby-rack'
gem 'warbler'
else
gem 'sqlite3-ruby', :require => 'sqlite3'
end
Edit database.yml, ganti adapter sqlite3 menjadi:
adapter: jdbcsqlite3
Jalankan bundle install untuk mengupdate/menginstall seluruh gem beserta dependencynya:
jruby -S bundle install
Jalankan webserver default (webrick), lalu browse http://localhost:3000
jruby -S rails server
Test dengan membuat sebuah scaffold, sebagai contoh kita buat scaffold Product.
jruby -S rails generate scaffold Product name:string price:decimal
Buat/migrasikan table (products) ke database:
jruby -S rake db:migrate
Browse http://localhost:3000/products, done!
Tested under Windows XP SP3 Pro dengan spesifikasi:
jruby 1.5.6 (ruby 1.8.7)
java version "1.6.0_24"
rails 3.0.3
Selamat mencoba. Let's code for fun. CMIIW.
February 17, 2011
Load Balance Mongrel Cluster + NginX + Rails 3 + Windows
Mongrel + NginX sebagai alternatif deployment di lingkungan Windows.
Resources:
NginXRuby Installer
Rails
Install mongrel:
Untuk rails 3, tambahkan pada gemfile: gem 'mongrel', '>= 1.2.0.pre2', lalu jalankan bundle installJalankan beberapa instance mongrel:
rails server mongrel -p 8000
rails server mongrel -p 8001 Setup Load Balance NginX (nginx.conf):
http { upstream aplikasiku { server 127.0.0.1:8000; server 127.0.0.1:8001; } server { listen 80; server_name localhost; location / { proxy_pass http://aplikasiku; } } }
Jalankan NginX, browse http://localhost, done!
Subscribe to:
Posts (Atom)


