Below are the key points listed in the book, I rewrite them a bit using my words. (Hope it does not violate any rules. :) )
1. Using metaphors requires heuristic thinking, not algorithmic.
2. It is actually about analogism to the activities you are familiar with.
3. A programmer should own multi-tools as a toolbox, then use the tools according to the different jobs.
2010/03/24
Code Complete: My notes for Chapter 1
Below are the key points listed in the book, I rewrite them a bit using my words. (Hope it does not violate any rules. :) )
1. The most important event in software development is "Software construction".
2. The construction includes design, coding, debugging, and developer testing.
3. The "KNOW HOW" of construction decides how good a programmer you are.
1. The most important event in software development is "Software construction".
2. The construction includes design, coding, debugging, and developer testing.
3. The "KNOW HOW" of construction decides how good a programmer you are.
2010/02/11
MRTG in FreeBSD
I've searched online for a long time.... but today I found it is not that complicated to run MRTG on a FreeBSD server.
People recommended that installing net-snmpd first before MRTG. Somehow, since I have a FreeBSD 7.2, it has bsnmpd already.
So, all we have to do is to activate bsnmpd by adding the line, [ bsnmpd_enable="YES" ] in /etc/rc.conf .
Then, as usual, cd to /usr/ports/net-mgmt/mrtg to complete the installation.
After installing, do cfgmaker to configure everything as following.
In CLI:
cfgmaker --global 'WorkDir: /usr/local/www/apache22/data/mrtg' --global 'Options[_]: growright, bits' --global 'WithPeak[_]: wmy' public@localhost > /usr/local/etc/mrtg/mrtg.cfg
Next, the index:
indexmaker --title 'MRTG' --addhead='' --output /usr/local/www/apache22/data/mrtg/index.html --columns=1 --nolegend /usr/local/etc/mrtg/mrtg.cfg
Last, run mrtg for about three times till no error messages.
mrtg /usr/local/etc/mrtg/mrtg.cfg
Add mrtg to crontab! (per 5 min)
*/5 * * * * /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
People recommended that installing net-snmpd first before MRTG. Somehow, since I have a FreeBSD 7.2, it has bsnmpd already.
So, all we have to do is to activate bsnmpd by adding the line, [ bsnmpd_enable="YES" ] in /etc/rc.conf .
Then, as usual, cd to /usr/ports/net-mgmt/mrtg to complete the installation.
After installing, do cfgmaker to configure everything as following.
In CLI:
cfgmaker --global 'WorkDir: /usr/local/www/apache22/data/mrtg' --global 'Options[_]: growright, bits' --global 'WithPeak[_]: wmy' public@localhost > /usr/local/etc/mrtg/mrtg.cfg
Next, the index:
indexmaker --title 'MRTG' --addhead='' --output /usr/local/www/apache22/data/mrtg/index.html --columns=1 --nolegend /usr/local/etc/mrtg/mrtg.cfg
Last, run mrtg for about three times till no error messages.
mrtg /usr/local/etc/mrtg/mrtg.cfg
Add mrtg to crontab! (per 5 min)
*/5 * * * * /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
2010/01/18
eclipse on ubuntu
Once the JVM is installed...., we can start to use eclipse as our IDE.
0. download eclipse
1. change owned by root on eclipse directory
sudo chown -R root:root /directory of eclipse
2. make eclipse executable (jump to the directory locates eclipse)
sudo chmod +x eclipse
3. eclipse executable
sudo touch /directory of eclipse
sudo chmod 755 /directory of eclipse
sudo vi /directory of eclipse
eclipse -clean
0. download eclipse
1. change owned by root on eclipse directory
sudo chown -R root:root /directory of eclipse
2. make eclipse executable (jump to the directory locates eclipse)
sudo chmod +x eclipse
3. eclipse executable
sudo touch /directory of eclipse
sudo chmod 755 /directory of eclipse
sudo vi /directory of eclipse
4. before the 1st run:eclipse -clean
Write an Email Read Notifier!
This is a step by step tutorial for getting to know when your email was read or not using php script in the mail.
1. You might need a handful www server with php enabled in advance. (e.g. apache + php) In my computer, I run appserv for Windows XP. It is easy to get. (http://www.appservnetwork.com/)
2. Download PHPMailer. (http://phpmailer.worxware.com/) We need it to connect to the gmail SMTP to access an account as the mail sender.
3. After extracting the file of PHPMailer, modify the file in example folder to fit your own situation. (I want to use my gmail, so I modified the file "test_smtp_gmail_basic.php".)
4. Embedded the code in the mail you want to trace. (Put it as if it's a image in the mail. This is only useful for a HTML supported mail. As long as your recipient doesn't disable the function....)
5. You will get a mail notification once your mail was read.
1. You might need a handful www server with php enabled in advance. (e.g. apache + php) In my computer, I run appserv for Windows XP. It is easy to get. (http://www.appservnetwork.com/)
2. Download PHPMailer. (http://phpmailer.worxware.com/) We need it to connect to the gmail SMTP to access an account as the mail sender.
3. After extracting the file of PHPMailer, modify the file in example folder to fit your own situation. (I want to use my gmail, so I modified the file "test_smtp_gmail_basic.php".)
4. Embedded the code in the mail you want to trace. (Put it as if it's a image in the mail. This is only useful for a HTML supported mail. As long as your recipient doesn't disable the function....)
5. You will get a mail notification once your mail was read.
2010/01/11
Howto: Configure Port Forwarding with NAT on VirtualBox!!
If you want to configure your sshd, follow the steps bellow:
1. First stop the guest OS
2. On CLI: type the three instructions
# VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/Protocol" TCP
e.g. ssh goes via TCP
# VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/GuestPort" 22
p.s. 22 is sshd port default value
# VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/HostPort" 2222
p.s. I'd like to apply 2222 on host OS to forward the service for me
3. Then the service is forwarded!!
P.S. e1000 is my adapter Intel PRO 1000; can be replaced according to your own settings.
1. First stop the guest OS
2. On CLI: type the three instructions
# VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/Protocol" TCP
e.g. ssh goes via TCP
# VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/GuestPort" 22
p.s. 22 is sshd port default value
# VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/HostPort" 2222
p.s. I'd like to apply 2222 on host OS to forward the service for me
3. Then the service is forwarded!!
P.S. e1000 is my adapter Intel PRO 1000; can be replaced according to your own settings.
FreeBSD -- What if I forgot my passwd on mysql!?
Oops! On my machine, I run FreeBSD OS with mysql on it. But today.... the passwd on mysql was changed by system! (I tried to change passwd via "change passwd" bottom on main page... somehow, it generated a passwd ramdomly!!)
Couldn't access my db..... so I go browsing the fine web!! XD
The solution is as following:
1. Stop mysql service first!!
# /usr/local/etc/rc.d/mysql-server stop
2. Then let's get into the safe mode.
# mysqld_safe -u root --skip-grant-tables &
3. In the mode....
a). # mysql
b). >use mysql //select the db "mysql"
c). >UPDATE user SET password=password('enter passwd here') where user='root';
d). >FLUSH PRIVILEGES;
e). >exit
Now, I can access again.....
Couldn't access my db..... so I go browsing the fine web!! XD
The solution is as following:
1. Stop mysql service first!!
# /usr/local/etc/rc.d/mysql-server stop
2. Then let's get into the safe mode.
# mysqld_safe -u root --skip-grant-tables &
3. In the mode....
a). # mysql
b). >use mysql //select the db "mysql"
c). >UPDATE user SET password=password('enter passwd here') where user='root';
d). >FLUSH PRIVILEGES;
e). >exit
Now, I can access again.....
2010/01/04
Launch Nessus
1. Run /usr/local/nessus/sbin/nessus-adduser to add a user
2. Register Nessus at http://www.nessus.org/register/
3. Start nessusd by typing /usr/local/etc/rc.d/nessusd.sh start
2. Register Nessus at http://www.nessus.org/register/
3. Start nessusd by typing /usr/local/etc/rc.d/nessusd.sh start
FreeBSD: pkg_add sample
Now we demo how to use "pkg_add" to install packages.
The sample here is Nessus 4.2.0!
1. You must have the package: Nessus-4.2.0-fbsd7.tbz
2. Just type "pkg_add Nessus-4.2.0-fbsd7.tbz" in the command line as root.
3. Finished.... (so so fast!!)
The sample here is Nessus 4.2.0!
1. You must have the package: Nessus-4.2.0-fbsd7.tbz
2. Just type "pkg_add Nessus-4.2.0-fbsd7.tbz" in the command line as root.
3. Finished.... (so so fast!!)
Configure NAT in VM 4
1. First, open network connection
2. Choose "properties" after right clicking
3. In the "Advanced" tag, enable "Internet Connection Sharing"
----------------------------------------------------------------
Now switch to the editor of "Manage Virtual Network"
1. Click on the NAT tag, then edit the settings
2. Choose "port forwarding" and edit it
3. Done
2. Choose "properties" after right clicking
3. In the "Advanced" tag, enable "Internet Connection Sharing"
----------------------------------------------------------------
Now switch to the editor of "Manage Virtual Network"
1. Click on the NAT tag, then edit the settings
2. Choose "port forwarding" and edit it
3. Done
Where's the sudoers file!?
Oh….no! Here it comes again…. I just cannot find the sudoers file!!
The Answer!?
It's right in /usr/local/etc/sudoers after installation!!
note that it's NOT in /etc/sudoers
The Answer!?
It's right in /usr/local/etc/sudoers after installation!!
note that it's NOT in /etc/sudoers
Subscribe to:
Posts (Atom)