Sunday, June 17, 2012

Download entire site with wget

$ wget -nc -E -r -k -p -D example.com,example.org -np
$ wget --no-clobber 
       --adjust-extension \
       --recursive  --convert-links --page-requisites \
       --domains=example.com,example.org --no-parent \
       www.example.com/mysite/

       -nc
       --no-clobber
           If a file is downloaded more than once in the same directory, Wget's behavior depends on a few options,
           including -nc.  In certain cases, the local file will be clobbered, or overwritten, upon repeated
           download.  In other cases it will be preserved.

           When running Wget without -N, -nc, -r, or -p, downloading the same file in the same directory will
           result in the original copy of file being preserved and the second copy being named file.1.  If that
           file is downloaded yet again, the third copy will be named file.2, and so on.  (This is also the
           behavior with -nd, even if -r or -p are in effect.)  When -nc is specified, this behavior is suppressed,
           and Wget will refuse to download newer copies of file.  Therefore, ""no-clobber"" is actually a misnomer
           in this mode---it's not clobbering that's prevented (as the numeric suffixes were already preventing
           clobbering), but rather the multiple version saving that's prevented.

           When running Wget with -r or -p, but without -N, -nd, or -nc, re-downloading a file will result in the
           new copy simply overwriting the old.  Adding -nc will prevent this behavior, instead causing the
           original version to be preserved and any newer copies on the server to be ignored.

           When running Wget with -N, with or without -r or -p, the decision as to whether or not to download a
           newer copy of a file depends on the local and remote timestamp and size of the file.  -nc may not be
           specified at the same time as -N.

           Note that when -nc is specified, files with the suffixes .html or .htm will be loaded from the local
           disk and parsed as if they had been retrieved from the Web.

       -E
       --adjust-extension
           If a file of type application/xhtml+xml or text/html is downloaded and the URL does not end with the
           regexp \.[Hh][Tt][Mm][Ll]?, this option will cause the suffix .html to be appended to the local
           filename.  This is useful, for instance, when you're mirroring a remote site that uses .asp pages, but
           you want the mirrored pages to be viewable on your stock Apache server.  Another good use for this is
           when you're downloading CGI-generated materials.  A URL like http://site.com/article.cgi?25 will be
           saved as article.cgi?25.html.

           Note that filenames changed in this way will be re-downloaded every time you re-mirror a site, because
           Wget can't tell that the local X.html file corresponds to remote URL X (since it doesn't yet know that
           the URL produces output of type text/html or application/xhtml+xml.

           As of version 1.12, Wget will also ensure that any downloaded files of type text/css end in the suffix
           .css, and the option was renamed from --html-extension, to better reflect its new behavior. The old
           option name is still acceptable, but should now be considered deprecated.

           At some point in the future, this option may well be expanded to include suffixes for other types of
           content, including content types that are not parsed by Wget.

       -r
       --recursive
           Turn on recursive retrieving.    The default maximum depth is 5.

       -l depth
       --level=depth
           Specify recursion maximum depth level depth.

       -k
       --convert-links
           After the download is complete, convert the links in the document to make them suitable for local
           viewing.  This affects not only the visible hyperlinks, but any part of the document that links to
           external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc.

           Each link will be changed in one of the two ways:

           ·   The links to files that have been downloaded by Wget will be changed to refer to the file they point
               to as a relative link.

               Example: if the downloaded file /foo/doc.html links to /bar/img.gif, also downloaded, then the link
               in doc.html will be modified to point to ../bar/img.gif.  This kind of transformation works reliably
               for arbitrary combinations of directories.

           ·   The links to files that have not been downloaded by Wget will be changed to include host name and
               absolute path of the location they point to.

               Example: if the downloaded file /foo/doc.html links to /bar/img.gif (or to ../bar/img.gif), then the
               link in doc.html will be modified to point to http://hostname/bar/img.gif.

           Because of this, local browsing works reliably: if a linked file was downloaded, the link will refer to
           its local name; if it was not downloaded, the link will refer to its full Internet address rather than
           presenting a broken link.  The fact that the former links are converted to relative links ensures that
           you can move the downloaded hierarchy to another directory.

           Note that only at the end of the download can Wget know which links have been downloaded.  Because of
           that, the work done by -k will be performed at the end of all the downloads.

       -p
       --page-requisites
           This option causes Wget to download all the files that are necessary to properly display a given HTML
           page.  This includes such things as inlined images, sounds, and referenced stylesheets.

           Ordinarily, when downloading a single HTML page, any requisite documents that may be needed to display
           it properly are not downloaded.  Using -r together with -l can help, but since Wget does not ordinarily
           distinguish between external and inlined documents, one is generally left with "leaf documents" that are
           missing their requisites.

           For instance, say document 1.html contains an "<IMG>" tag referencing 1.gif and an "<A>" tag pointing to
           external document 2.html.  Say that 2.html is similar but that its image is 2.gif and it links to
           3.html.  Say this continues up to some arbitrarily high number.

           If one executes the command:

                   wget -r -l 2 http://<site>/1.html

           then 1.html, 1.gif, 2.html, 2.gif, and 3.html will be downloaded.  As you can see, 3.html is without its
           requisite 3.gif because Wget is simply counting the number of hops (up to 2) away from 1.html in order
           to determine where to stop the recursion.  However, with this command:

                   wget -r -l 2 -p http://<site>/1.html

           all the above files and 3.html's requisite 3.gif will be downloaded.  Similarly,

                   wget -r -l 1 -p http://<site>/1.html

           will cause 1.html, 1.gif, 2.html, and 2.gif to be downloaded.  One might think that:

                   wget -r -l 0 -p http://<site>/1.html

           would download just 1.html and 1.gif, but unfortunately this is not the case, because -l 0 is equivalent
           to -l inf---that is, infinite recursion.  To download a single HTML page (or a handful of them, all
           specified on the command-line or in a -i URL input file) and its (or their) requisites, simply leave off
           -r and -l:

                   wget -p http://<site>/1.html

           Note that Wget will behave as if -r had been specified, but only that single page and its requisites
           will be downloaded.  Links from that page to external documents will not be followed.  Actually, to
           download a single page and all its requisites (even if they exist on separate websites), and make sure
           the lot displays properly locally, this author likes to use a few options in addition to -p:

                   wget -E -H -k -K -p http://<site>/<document>

           To finish off this topic, it's worth knowing that Wget's idea of an external document link is any URL
           specified in an "<A>" tag, an "<AREA>" tag, or a "<LINK>" tag other than "<LINK REL="stylesheet">".

       -D domain-list
       --domains=domain-list
           Set domains to be followed.  domain-list is a comma-separated list of domains.  Note that it does not
           turn on -H.

       --exclude-domains domain-list
           Specify the domains that are not to be followed.

       -np
       --no-parent
           Do not ever ascend to the parent directory when retrieving recursively.  This is a useful option, since
           it guarantees that only the files below a certain hierarchy will be downloaded.

Tuesday, November 15, 2011

How to protect a web page with htaccess with a password

  1. Create a .htpasswd file:
    $ htpasswd -c .htpasswd <username>
    password: 
    
  2. Create or add these lines to .htaccess file:
    • To protect a directory:
      AuthUserFile /full/path/to/.htpasswd
      AuthType Basic
      AuthName "Protected Folder"
      Require valid-user
      
    • To protect a file:
      AuthUserFile /full/path/to/.htpasswd
      AuthType Basic
      AuthName "Protected Page"
      
      <Files "protected_page.html">
        Require valid-user
      </Files>
      

Sunday, November 13, 2011

Linux Yum commands

Display available updates for installed software
$ yum list updates
Apply updates
$ yum update 
List installed packages
$ yum list installed <package-name>
# e.g.
$ yum list installed httpd
OR
$ rpm -qa | grep httpd*

Check for and update a package
$ yum update <package-name>

Search a package or list all
$ yum list <package-name/regex/wildcard>
$ yum list all

# list group packages
$ yum grouplist

Install a package
$ yum install <package-name>

Remove/Uninstall a package
$ yum remove <package-name>

Install/Update group packages
$ yum groupinstall "Development Tools"
$ yum groupupdate "Development Tools"

List packages that are not official RHN
$ yum list extras

Find out which package is a file from
$ yum whatprovides <filename>

Wednesday, October 26, 2011

Set up shared directory in Linux

Here is how to set up a shared directory or project among linux users. The scenario is:
  • The name of the shared directory: /home/projects
  • The shared group name: developers
  • Users: john, joe, and jane

First, log in as super user, create the projects directory.
$ mkdir /home/projects

Second, create a shared group.
$ groupadd developers

Set up directory for group sharing.
# Change group on the directory
$ chgrp developers /home/projects

# Set full permission for group on the directory
$ chmod -R 775 /home/projects

# Set SGID bit on the directory so that new files under this directory will inherit the directory's group instead of the user's (creator) group.
$ chmod -R g+s /home/projects

# OR combine the last two commands into one
$ chmod -R 2775 /home/projects

# Set umask on the directory so that the 'group write' permission will be inherited on new files and directories
$ umask 002


Add users to group as supplementary group.
$ useradd -G developers john
$ useradd -G developers joe
$ useradd -G developers jane

# Check their groups
$ id john

# Add a user to multiple supplementary groups (with no space after commas):
$ useradd -G wheel,ftp,www,developers john

# Add existing user to an existing group
$ usermod -a -G wheel

# Change user's primary group
$ usermod -g developers john

You can also use this command to set the primary group for a user
$ useradd -g developers john

Saturday, October 1, 2011

htaccess Directory Listing Configurations

To prevent people from browsing your directoy, put this in your .htaccess file.
Option -indexes
OR:
IndexIgnore *

To allow people to see everything in your directory:
Option +indexes


To allow people to see everything except image files:
IndexIgnore *.gif *.jpg

How to Merge Tables

This is an example of how to insert all the missing rows from one table, tbl_backup, into another table, tbl_target. Since the primary_key is auto incremented, we will use col2 and col3 to identify unique rows.

INSERT IGNORE INTO `tbl_target`
  SELECT * FROM `tbl_backup` AS bkup
  WHERE ROW(bkup.col1, bkup.col2) NOT IN
    (SELECT orig.col1, orig.col2 FROM `tbl_target` AS orig);

Monday, April 11, 2011

Replace local home directory with an existing partition

Find the UUID of the partition:
$ blkid /dev/sda1
... or ...
$ ls -l /dev/disk/by-uuid

Edit /etc/fstab file:
UUID=xxxxxxxxx /home ext3 defaults,noexec,nosuid 1 2

Move home to old-home, then remount partition.
$ mv /home /old-home
$ mkdir /home
$ mount -o remount /home

Friday, March 25, 2011

Find and delete large files

Find files larger than 1GB (display filesize and lsat modified time):

$ find <directory> -type f -size +1G
$ find <directory> -type f -size +1G -exec du -h --time {} \;


Sorted by file size (human readable size):

$ find <directory> -type f -size +1G -exec du --time {} \; | sort -n
$ find <directory> -type f -size +1G -exec du -h --time {} \; | sort -h


Find files that are larger than 1GB and older than 5 days (sorted by time):

$ find <directory> -type f -size +1G -mtime +5
$ find <directory> -type f -size +1G -mtime +5 -exec ls -lht {} +;


Find and delete files older than 5 days and larger than 1GB:

$ find <directory> -type f -size +1G -mtime +5 -exec rm {} \;

Friday, February 11, 2011

How to find out CentOS's version

$ cat /etc/issue
CentOS release 5.7 (Final)
Kernel \r on an \m

$ cat /etc/centos-release
CentOS release 6.3 (Final)

$ uname -a
Linux cle-dev 2.6.18-274.18.1.el5 #1 SMP Thu Feb 9 12:45:44 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

$ rpm -qa | grep ^centos
centos-release-notes-5.7-0
centos-release-5-7.el5.centos

$ yum list installed |grep ^centos
centos-indexhtml.noarch
centos-release.x86_64 6-3.el6.centos.9  @anaconda-CentOS-201207061011.x86_64/6.3

# Find out what package were installed with 'yum'
$ yum list installed

# e.g. mysql-server
$ yum list installed |grep ^mysql-server
mysql-server.x86_64   5.1.61-4.el6      @base

# e.g. php modules
$ yum list installed |grep ^php
php.x86_64            5.3.3-14.el6_3    @updates
php-cli.x86_64        5.3.3-14.el6_3    @updates
php-common.x86_64     5.3.3-14.el6_3    @updates
php-gd.x86_64         5.3.3-14.el6_3    @updates
php-intl.x86_64       5.3.3-14.el6_3    @updates
php-mbstring.x86_64   5.3.3-14.el6_3    @updates
php-mysql.x86_64      5.3.3-14.el6_3    @updates
php-pdo.x86_64        5.3.3-14.el6_3    @updates
php-soap.x86_64       5.3.3-14.el6_3    @updates
php-xml.x86_64        5.3.3-14.el6_3    @updates
php-xmlrpc.x86_64     5.3.3-14.el6_3    @updates


Tuesday, November 2, 2010

How to Set up The Grinder 3 for Load Testing

Basic Requirement
  1. Download and install Jython
  2. Install Jython by running this command:
    java -jar jython_installer-2.5.1.jar

How to Start The Grinder

  1. Create a grinder.properties file. (You could simply copy from grinder/examples/grinder.properties.)
  2. Set CLASSPATH to include grinder.jar
  3. Start the Console:
        java net.grinder.Console
    
  4. For each test machine, do Steps 1 and 2, and then start the Agent process:
        java net.grinder.Grinder [grinder.properties]
    
If you are getting this warning message: "can't create package cache dir", make changes to grinder.properties to look like this:
    grinder.jvm.arguments: -Dpython.cachedir=/tmp

Use command line for developing

Edit grinder.properties with these settings:
    grinder.runs = 1
    grinder.useConsole = false

TCPProxy

To find out the default proxy settings in TCPProxy:
$ export CLASSPATH=/opt/grinder/lib/grinder.jar

$ java net.grinder.TCPProxy
12/7/10 2:02:58 PM (tcpproxy): Initialising as an HTTP/HTTPS proxy with the
parameters:
   Request filters:    EchoFilter
   Response filters:   EchoFilter
   Local address:      localhost:8001
12/7/10 2:02:58 PM (tcpproxy): Engine initialised, listening on port 8001

Now, set your browser to use proxy with the above port settings.

To start the TCPProxy Console:
$ java net.grinder.TCPProxy -console -http > grinder.py

Sunday, October 10, 2010

Analyse Disk Activities in Linux

To see disk activities, you can simply issue this command:
# e.g. on /dev/sda
$ cat /sys/block/sda/stat
626485464 806972148 28053848010 1557001361 853157995 3445307000 34392097768 2090234158        0 444939685 3653907428

Using iostat:
# Display every 5 seconds
$ iostat -xm -d 5

# Display on one disk
$ iostat -p /dev/sda -d 5

Sunday, October 3, 2010

Helpful Diagnostic Non-Responsive Server Comandlines

How many HTTP connections?
$ netstat -n | grep :80 | wc -l

How many HTTPS connections?
$ netstat -n | grep :443 | wc -l

How many connections are from an IP?
$ netstat -n | grep XXX.XXX.XXX.XXX

Monday, September 20, 2010

Bash if

Syntax

if [ <condition expression> ]
then
<commands>
elif [ <condition expression> ]
then
<commands>
else
<commands>
fi
One liner
if [ <condition expression> ]; then <commands>; fi
Variations
[ <condition expression> ] && (<commands>)
test <condition expression> && (<command>; ... <command>; exit;)
&& means 'and' while || means 'or'.
If you invoke exit at the end of a sub-shell means it will not pass the return value back to parent shell.
Use {...} instead of (...) to avoid creating a sub-shell.

Condition expression operators

[ -a FILE ] True if FILE exists.
[ -b FILE ] True if FILE exists and is a block-special file.
[ -c FILE ] True if FILE exists and is a character-special file.
[ -d FILE ] True if FILE exists and is a directory.
[ -e FILE ] True if FILE exists.
[ -f FILE ] True if FILE exists and is a regular file.
[ -g FILE ] True if FILE exists and its SGID bit is set.
[ -h FILE ] True if FILE exists and is a symbolic link.
[ -k FILE ] True if FILE exists and its sticky bit is set.
[ -p FILE ] True if FILE exists and is a named pipe (FIFO).
[ -r FILE ] True if FILE exists and is readable.
[ -s FILE ] True if FILE exists and has a size greater than zero.
[ -t FD ] True if file descriptor FD is open and refers to a terminal.
[ -u FILE ] True if FILE exists and its SUID (set user ID) bit is set.
[ -w FILE ] True if FILE exists and is writable.
[ -x FILE ] True if FILE exists and is executable.
[ -O FILE ] True if FILE exists and is owned by the effective user ID.
[ -G FILE ] True if FILE exists and is owned by the effective group ID.
[ -L FILE ] True if FILE exists and is a symbolic link.
[ -N FILE ] True if FILE exists and has been modified since it was last read.
[ -S FILE ] True if FILE exists and is a socket.
[ FILE1 -nt FILE2 ] True if FILE1 has been changed more recently than FILE2, or if FILE1 exists and FILE2 does not.
[ FILE1 -ot FILE2 ] True if FILE1 is older than FILE2, or is FILE2 exists and FILE1 does not.
[ FILE1 -ef FILE2 ] True if FILE1 and FILE2 refer to the same device and inode numbers.
[ -o OPTIONNAME ] True if shell option "OPTIONNAME" is enabled.
[ -z STRING ] True of the length if "STRING" is zero.
[ -n STRING ] or [ STRING ] True if the length of "STRING" is non-zero.
[ STRING1 == STRING2 ] True if the strings are equal. "=" may be used instead of "==" for strict POSIX compliance.
[ STRING1 != STRING2 ] True if the strings are not equal.
[ STRING1 < STRING2 ] True if "STRING1" sorts before "STRING2" lexicographically in the current locale.
[ STRING1 > STRING2 ] True if "STRING1" sorts after "STRING2" lexicographically in the current locale.
[ ARG1 OP ARG2 ] "OP" is one of -eq, -ne, -lt, -le, -gt or -ge. These arithmetic binary operators return true if "ARG1" is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to "ARG2", respectively. "ARG1" and "ARG2" are integers.

Combined expressions
[ ! EXPR ] True if EXPR is false.
[ ( EXPR ) ] Returns the value of EXPR. This may be used to override the normal precedence of operators.
[ EXPR1 -a EXPR2 ] True if both EXPR1 and EXPR2 are true.
[ EXPR1 -o EXPR2 ] True if either EXPR1 or EXPR2 is true.


Ref: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

Differences with brackets

Using double brackets, [[...]], means:
  • If variable values is a string with spaces, it will not be splitted, so you could leave out the double quotes. So, instead of
    $ FOO="I am a foo"
    $ [ "$FOO" == "I am a foo" ] && echo "Indeed, I am a foo."
    
    you can do
    $ [[ $FOO == "I am a foo" ]] && echo "Indeed, I am a foo."
    
  • Wildcards do not expand to filenames, e.g.
    $ ls
    index.html
    $ FOO="index.*"
    $ echo $FOO
    index.html
    $ echo "$FOO"
    index.*
    $ echo '$FOO'
    $FOO
    
    Single bracket examples
    $ [ $FOO == index.html ] && echo "This is true"
    This is true
    $ [ $FOO == "index.html" ] && echo "This is true"
    This is true
    $ [ $FOO == index.* ] && echo "This is true"
    This is true
    $ [ $FOO == "index.*" ] || echo "This is false"
    This is false
    
    #c.f. this with double bracket examples
    $ [ "$FOO" == index.html ] || echo "This is false"
    This is false
    $ [ "$FOO" == "index.html" ] || echo "This is false"
    This is false
    $ [ "$FOO" == index.* ] || echo "This is false"
    This is false
    $ [ "$FOO" == "index.*" ] && echo "This is true"
    This is true
    
    Double bracket examples
    $ [[ $FOO == index.html ]] || echo "This is false"
    This is false
    $ [[ $FOO == "index.html" ]] || echo "This is false"
    This is false
    $ [[ $FOO == index.* ]] && echo "This is true"
    This is true
    $ [[ $FOO == "index.*" ]] && echo "This is true"
    This is true
    

Saturday, August 14, 2010

Useful IP commands in Linux

Display NIC's configurations:
# for all NIC's
$ ifconfig

# Just for eth0
$ ifconfig eth0

Assign an IP to a NIC:
$ ifconfig eth0 192.168.0.1

# assign multiple IPs
$ ifconfig eth0:0 192.168.0.1
$ ifconfig eth0:1 192.168.0.2

# assign subnet
$ ifconfig eth0 192.168.0.1 netmask 255.255.255.0

Disable/Enable NICs:
# enable
$ ifconfig eth0 up

# disable
$ ifconfig eth0 down

IP/hostname Lookup:
# look up hostname
$ host 192.168.0.1
# for more info
$ dig -x 192.168.0.1

# trace route
$ traceroute www.example.com

# trace path
$ tracepath www.example.com

# DNS test
$ host www.example.com

Friday, April 9, 2010

How to Prevent Files from Being Used by Other Website?

Added these lines to your .htaccess file.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]

Wednesday, March 10, 2010

Microsoft Office 2010 Opens for Beta Testing!

Microsoft is inviting IT professionals around the world to test Office 2010 and reflect feedbacks. This is a pre-release version of Office Professional Plus 2010, so take your pre-caution before installing.

To register and download this beta version, click here.

Make sure you have the following:
Internet access (to download Office Professional Plus 2010 Beta and get updates)

A PC with these minimum recommended specifications:
  • 500 MHz 32-bit or 64-bit processor or higher
  • 256 MB of system memory or more
  • 3.5 GB of available disk space
  • 1024x768 or higher resolution monitor
  • DVD-R/W Drive
Supported Operating Systems:
  • Windows XP with Service Pack (SP) 3 (32-bit)
  • Windows Vista with SP1 (32-bit or 64-bit)
  • Windows Server 2003 R2 (32-bit or 64-bit)
  • Windows Server 2008 with SP2 (32-bit or 64-bit)
  • Windows 7 (32-bit or 64-bit)

Friday, February 5, 2010

Keyboard Shortcuts for Google Search Results

I've always wonder why can't I navigate through the Google search result using my keyboard. There are plugins and Firefox extensions that add keyboard shortcuts to web pages but wouldn't it be nice if the webpage itself just equips this feature? Finally Google is running an experiment on this idea.

To enable Keyboard Shortcuts in Google search results, go here and be part of their experiment.

Wednesday, January 20, 2010

Initial Setup for CentOS

Set up users and groups

Create staff group with gid 123
$ /usr/sbin/groupadd -g 123 staff

Create users (with uid 1234, with user gid 123)
$ /usr/sbin/useradd -c "John Doe" -d /home/jdoe -u 1234 -s /bin/bash -g 123 jdoe

To see useradd default: $ useradd -D

Force user to change password upon login
$ passwd -e jdoe

# If not available, just expire the account by
$ chage -d0 jdoe

Add user to wheel group
# Enabled sudo for wheel group
$ visudo

# uncomment this line:
# %wheel ALL=(ALL) ALL

# Add user to wheel group
$ usermod -G10 jdoe

Set hosts.allow to allow ssh (port 22) for specific network (e.g. 123.456.789.* with subnet 255.255.255.0) and hosts.deny to deny everywhere else.
$ cat /etc/hosts.allow
#
# hosts.allow   This file contains access rules which are used to
#               allow or deny connections to network services that
#               either use the tcp_wrappers library or that have been
#               started through a tcp_wrappers-enabled xinetd.
#
#               See 'man 5 hosts_options' and 'man 5 hosts_access'
#               for information on rule syntax.
#               See 'man tcpd' for information on tcp_wrappers
#
sshd: 123.456.789.0/255.255.255.0

$ cat /etc/hosts.deny
#
# hosts.deny    This file contains access rules which are used to
#               deny connections to network services that either use
#               the tcp_wrappers library or that have been
#               started through a tcp_wrappers-enabled xinetd.
#
#               The rules in this file can also be set up in
#               /etc/hosts.allow with a 'deny' option instead.
#
#               See 'man 5 hosts_options' and 'man 5 hosts_access'
#               for information on rule syntax.
#               See 'man tcpd' for information on tcp_wrappers
#
All:All


Disallow root login in via ssh by uncomment the following line.
$ vi /etc/ssh/sshd_config

#PermitRootLogin no

$ /etc/init.d/sshd restart

Tuesday, December 29, 2009

How to Improve Windows 7 Performance

The performance on Windows 7 has improved from Vista. In most of the time I am pretty happy with it on all my machines. But when it comes to my netbook, it seems a little short. Here are a few things I did to improve its speed, which seems to help.
  1. Turn off transparency
  2. Use ReadyBoot from a fast USB flash drive
  3. Convert from FAT32 to NTFS
  4. Reduce Startup Programs
  5. Disable indexing services
    • Application Management
    • Clipbook
    • Computer Browser
    • Error Reporting Service
    • HID Input Service
    • Indexing Service
    • Net Logon
    • NetMeeting Remote Desktop Sharing
    • Network Location Awareness (NLA)
    • Network Provisioning Service
    • Portable Media Serial Number Service
    • QoS RSVP
    • Remote Desktop Help Session Manager
    • Remote Registry
    • Secondary Logon (If you only have one user on your computer)
    • TCP/IP NetBIOS Helper Service
    • Telnet
    • Uninterruptable Power Supply
    • WebClient
    • Windows Time
    • WMI Performance Adapter
  6. Disable Performance Counters
  7. Turn off Automatic Updates

Sunday, December 20, 2009

Grinder Examples

Hello World
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test

# A shorter alias for the grinder.logger.output() method.
log = grinder.logger.output

# Create a Test with a test number and a description. The test will be
# automatically registered with The Grinder console if you are using
# it.
test1 = Test(1, "Log method")

# Wrap the log() method with our Test and call the result logWrapper.
# Calls to logWrapper() will be recorded and forwarded on to the real
# log() method.
logWrapper = test1.wrap(log)

# A TestRunner instance is created for each thread. It can be used to
# store thread-specific data.
class TestRunner:

    # This method is called for every run.
    def __call__(self):
        logWrapper("Hello World")