Author Archive
Mac OS setup apache and php
In : system, Posted by admin on Jun.06, 2009
here is the steps to setup apache and php in your Mac OS X.
- Apache and PHP already came with your OS. You just need to enable it.
- Go to the apple icon on the menu bar. Select “System Preferences…” -> “Internet & Network” -> “Sharing”
- Enable “Web Sharing” by click on it
- You just enabled the web server. You can test it by go to: http://localhost/
- To enabled php, in a command window, edit /private/etc/apache2/httpd.conf
- remove the “#” character in front of this line: LoadModule php5_module libexec/apache2/libphp5.so
- restart the apache server by: sudo apachectl restart
- now you have php enabled.
- add a file called: /private/etc/apache2/users/your_username>.conf
- put this in the file:
- #
# Allow access to this user’s Sites directory for web clients.
#
<Directory “/Users/your_username/Sites/”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>- remember to replace “your_username” with your username.
- restart apache: sudo apachectl restart
- put a file in /Users/your_username/Sites/x.htm
- go to the browser: http://localhost/~your_username/x.htm
- and you will see the file.
Select a Java Web Framework
In : java, Posted by admin on Mar.03, 2009
This PDF describe how to select a Jav Web Framework such as: Spring MVC, Struts 2, Stripes, JSF, Tapestry, Wicket
How to use ftp in a shell script
In : system, Posted by admin on Mar.03, 2009
First way:
#!/bin/sh HOST='ftp.users.qwest.net' USER='yourid' PASSWD='yourpw' FILE='file.txt' ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE quit END_SCRIPT exit 0
Second way:
#!/bin/sh USER=userid PASSWD=userpw ftp -n f2dev <<SCRIPT user $USER $PASSWD binary get some.file quit SCRIPT
HAProxy – a load balancing tool
In : system, Posted by admin on Mar.03, 2009
If you are worry about load balancing. The first thing you should tried is HAProxy.
However, it is not a sure thing. Need some testing on it.
Install Linux From External USB hard drive
In : system, Posted by admin on Mar.03, 2009
After getting that new USB external hard drive case and installing that new hard drive, you need to get it installed and working with your Linux box. These instructions worked for me on Ubuntu and they should work for those with other distributions.
After putting the drive in the case, connecting it to power and plugging it into the back (or front) of your machine, the first thing you need to do is find out what device it is. USB hard drives usually show up as /dev/sdx (where x is a letter starting from a). If this is the only usb drive you have plugged in, it will most likely be /dev/sda.
To find out what it is look at the output of the command: tail /var/log/messages in your terminal. It will give you some irrelevant stuff, so look for a line that looks like this:
May 16 07:50:26 localhost kernel: Attached scsi disk sdb at scsi6, channel 0, id 0, lun 0
On my machine the drive shows up as /dev/sdb because I have an external DVD burner attached.
Now run fdisk as root and create a partition on the drive. On my Ubuntu box I did this by typing: sudo fdisk /dev/sdb into the terminal.
Once in fdisk press p to display a list of current partitions (there shouldn’t be any) and n to create a new partition. You want to create primary partition #1. fdisk will ask a few questions at this point, but since I was setting up an external drive, I didn’t want to create anything fancy so I just created one big partition for the entire drive, the default answers will do this. Once you get back to the fdisk prompt, press w to write the partition table. Now quit fdisk.
Now that you’ve got your partition set up, run the command mkfs.ext3 /dev/sdb1. I ran it as root (using sudo) on my box. This can take a long time, so if you want it to tell you what it’s doing, use the -v option.
Create a mount point
First create a directory you can use as a mount point. Mount point is a directory in the boot partition into which the drive is mounted. Usually the mount points are created under the /mnt/ -directory. Name the directory as you wish to call the new disk.
# mkdir /mnt/newdisk
You may want to issue the chmod go+x /mnt/newdisk command to grant other users access to the mountpoint. Now you may manually mount the drive by issuing command
# mount -t ext3 /dev/hdb1 /mnt/newdisk
Add hard disk to fstab
Mounting the hard drive manually every time is annoying. To mount the disk automatically, add it to fstab -file located in /etc/fstab. Depending on how you named the mount point, add the following lines to the end of /etc/fstab:
/dev/hdb1 /mnt/newdisk ext3 defaults 0 0
The first set is the partition (1st partition of hdb), second describes the mount point and the third describes the filesystem type. ‘defaults’ tells the options. The first 0 is the ‘dump’. It tells the computer whether the drive should be backed up. a ‘0′ means that it will not be backed up, a ‘1′ enables backup. The last number determines the order in which the filesystems should be checked. If it’s zero, ‘fsck’ won’t check the filesystem.
Find all large files on a Linux machine
In : system, Posted by admin on Mar.03, 2009
Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable format:
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
Yum Hangs
In : system, Posted by admin on Mar.03, 2009
Sometime yum takes a long time to finish, it is because there is a lot of old temporary rpm database is created.
To fix the problem, just do the following:
rm -f /var/lib/rpm/__db.*
Guide: Things You Shouldn’t Be Doing In Rails
In : Uncategorized, Posted by admin on Mar.03, 2009
Good read. But it is not easy to stop using some of this stuffs (like scaffolding, authentication engine, pagination). They are so easy to use and this is why people come to Ruby in the first place.
http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails
Ruby – Components may not be evil, but they sure can be slow
In : ruby, Posted by admin on Mar.03, 2009
http://railsexpress.de/blog/articles/2005/11/18/components-may-not-be-evil-but-they-sure-can-be-slow Becareful when you use Ruby components. When it goes back to the controller, it may run throught some filters and slow down the application.
Articles For Scaling Ruby On Rail Web Site
In : ruby, Posted by admin on Mar.03, 2009
Here are a set of articles for RoR scaling.
- The adventures of scaling, Stage 1
- Q&A: The adventures of scaling, Stage 1
- The adventures of scaling, Stage 2
- The adventures of scaling, Stage 3
- The adventures of scaling, Stage 4
- Scaling Rails with Apache 2.2, mod_proxy_balancer and Mongrel
Very good articles.
By the way, it said:
The old codebase roughly consisted of around 50.000 lines of PHP code (plus a closed-source CMS that’s (not included in this calculation). We’ve rewritten most of it (some features were left out on purpose) in about 5.000 lines of Rails code.