Posts (page 2)
Today, I've had an interview with Mr Quang at stanyan. It's not so good, but I'm pleased with it because I try my best without well preparation for the Test Driven question.
Look at the above picture, the core circle is what the content of this interview, I did not prepare for it well so I anwser some questions so long and complex ,,, forget it. I learn so much from this interview
Test Driven - Pair programming - Simple design - Refactoring
The core circle is the reason why he always asks me to have simplest solution and refactoring the code. You show me the way to approach XP.
Thank you very much
This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application on Ubuntu Linux, and also set up the server so it allows access to other PC’s on your network.
Before we move on, this guide was tested on the current release of Ubuntu Linux, (8.04 - Hardy Heron) and PostgreSQL 8.3, but it should also be applicable to older versions (of Ubuntu and PostgreSQL) and other Debian based distros.
Right for the basic installation, at the command-line, enter the following commands (or search for the listed packages in synaptic if you prefer that way of working):
$ sudo apt-get install postgresql postgresql-client postgresql-contrib
$ sudo apt-get install pgadmin3
This installs the database server/client, some extra utility scripts and the pgAdmin GUI application for working with the database.
Now we need to reset the password for the ‘postgres’ admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):
$ sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q
That alters the password for within the database, now we need to do the same for the unix user ‘postgres’:
$ sudo passwd -d postgres
$ sudo su postgres -c passwd
Now enter the same password that you used previously.
Then, from here on in we can use both pgAdmin and command-line access (as the postgres user) to run the database server. But before you jump into pgAdmin we should set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmin. Run the following at the command-line:
$ sudo su postgres -c psql < /usr/share/postgresql/8.3/contrib/adminpack.sql
Finally, we need to open up the server so that we can access and use it remotely - unless you only want to access the database on the local machine. To do this, first, we need to edit the postgresql.conf file:
$ sudo vi /etc/postgresql/8.3/main/postgresql.conf
Now, to edit a couple of lines in the ‘Connections and Authentication’ section…
Change the line:
#listen_addresses = 'localhost'
to
listen_addresses = '*'
and also change the line:
#password_encryption = on
to
password_encryption = on
Then save the file and close vi.
Now for the final step, we must define who can access the server. This is all done using the pg_hba.conf file.1
$ sudo vi /etc/postgresql/8.3/main/pg_hba.conf
Comment out, or delete the current contents of the file, then add this text to the bottom of the file:
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local all postgres md5
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Connections for all PCs on the subnet
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all [ip address] [subnet mask] md5
and in the last line, add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server (i.e. 138.250.192.115). However, if you would like to enable access to a range of IP addresses, just substitute the last number for a zero and all machines within that range will be allowed access (i.e. 138.250.192.0 would allow all machines with an IP address 138.250.192.x to use the database server).
That’s it, now all you have to do is restart the server:
$ sudo /etc/init.d/postgresql-8.3 restart
ref: http://hocuspokus.net/2008/05/13/install-postgresql-on-ubuntu-804/
AP4R (Asynchronous Process for Rails )
What is AP4R ?
AP4R, Asynchronous Processing for Ruby, is the implementation of reliable asynchronous message processing. It provides message queuing, and also message dispatching. Using asynchronous processing, we can cut down turn-around-time of web applications by queuing, or can utilize more machine power by load-balancing
Features
Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchronously.
Asynchronous messaging is reliable by RDBMS persistence (now MySQL only) or file persistence, under the favor of reliable-msg.
Load balancing over multiple AP4R processes on single/multiple server(s) is supported.
Asynchronous logics are called via various protocols, such as XML-RPC, SOAP, HTTP POST, and more.
How strong is AP4R?
QESTION: I am considering on the use of AP4R for our project named "CLIK" for the time being. CLIK is essentially a Rails front-end to a data crunching job that ultimately creates a climate prediction. Some of these jobs only takes a few seconds to finish, some a few minutes, and intensive calculations 30 minutes or more. Obviously we need to put many of these jobs in the background and get the output after the job is done. Actually we use a separate data processing server on a remote machine using Drb. I explored a few solutions by googling and found projects like "Background Job", "rudeQ", "Workling" etc, which provide queing and background processing. My question is how "AP4R" compares to or is different from these others?
ANWSER: One big difference is robustness. AP4R has 'SAF' function which guarantees a message delivery between your CLIK and AP4R server. As a result, no matter what happens, for example database and N/W trouble, server down and so on, you don't lose your crunched data. A message is stored in a database before sending AP4R, you can resend the message after recovery from system failure.
- But when I wrote my AP4R demo, I'm so disappointed : The architecture is bloated, less support drb, full support message delivery via various web service protocol HTTP, XMLRPC
Spawn
Features
Fork or thread a background process
Very simple, it's just a rails plugin does not need drb server => weak.
If you really need a queue, use Starling, which Blaine Cook of Twitter released, like, yesterday. Or SQS if you need really huge storage. If you just want to fire and forget a local process as you say, I think Spawn is pretty good ( http://rubyforge.org/projects/spawn ). I haven’t actually used it but seems like the best of the forking bunch. That should eliminate the startup overhead. On the other hand, you don’t get any message reliability or cross-machine scheduling. ..I agree that BDrb is shady (actually all of Drb is shady). ap4r is too
bloated. Thruqueue is promising if you make it past the crazy dependencies list. BackgroundFu is like a worse Spawn.”- Spawn is simplest, we cannot manage our process (fire and forget) and not have scheduling
Is AP4R really good?
After a few hours modify Asset Packager, my rails apps auto combine css, js when deploy on production mode, especially i use yuicompressor instead of default jsmin.
:D
ref:http://synthesis.sbecker.net/pages/asset_packager
NuVia GHX project has a big problem about better performance, YSlow show me that my site is very very slow (grade F ). After two days dig into research gzip javascript and optimize extjs library my site get better grade D (yeah).
If you have a NGINX server let config it auto gzip static file to accelerate your site (don't use rails plugin to gzip such as Tiny MCE )
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml; #add text/javascript text/css
gzip_disable "MSIE [1-6]\.";
http://wiki.codemongers.com/NginxHttpGzipModule?highlight=%28gzip%29