Sunday, July 19, 2009

Yamane's Sample Size Formula

If you are at a lost as to how to determine your sample size, I suggest you use Taro Yamane's formula:

n = N /[1+N(e)^2]

where:

n = sample size
N = population size (the universe)
e = sampling error (usually .10, .05 and .01 acceptable error)
^ = raised to the power of



Note:

This particular formula has been called Slovin's formula here in the Philippines but I kind of doubt the attribution.  I still cannot find the actual work of Slovin but Taro Yamane's work is set out clearly in his book referred below (I got a copy but this is already out of print) including the derivations of the formula.  So while a lot of Statisticians here in the Philippines calls this Slovin's formula, I continue to assert that it is Yamane's formula until I can see the actual work of Slovin. 



--------------------
Reference

Yamane, Taro. 1967.  Statistics:  An Introductory Analysis, 2nd Edition, New York.  Harper and Row.

Blocking Sites Using Squid

Steps

1. Edit the squid.conf configuration file and add the following lines:

acl blocksites url_regex "c:\squid\etc\squid-block.acl"
http_access deny blocksites


2. Create the file "squid-block.acl" with the following pattern:

.playboy.com
.friendster.com
.facebook.com
porn
pornstars


This will block the sites with URL playboy.com, friendster.com, facebook.com and
pages with "porn" or "pornstars" entries.

3. Restart squid


Saturday, July 18, 2009

Compiling and Running Squid on Windows

The following compilation procedure has been tested on MS Windows XP Professional using Squid 3.0 STABLE 16, MinGW 5.1.4 and MSYS 1.0.11.rc-1, ActivePerl 5.1.

Steps

1. Download MinGW and MSYS from http://www.mingw.org
2. Download Squid source code from http://www.squid-cache.org
3. Download the Perl installer from http://www.activestate.com/activeperl/
4. Install MinGW under the directory c:\mingw
5. Install MSYS under the directory c:\msys. Indicate where mingw is located when prompted by MSYS.

6. Add the path to Windows for the following directories:

c:\msys\1.0\bin
c:\msys\1.0\mingw\bin
c:\msys\1.0\mingw\sbin
c:\mingw\bin



This is done by going to "Start->Settings->Control Panel->System icon->Advanced tab->Environment Variables button". Then under the "System Variables" grouping, Select the "Path" and choose "Edit" button. Add the above directories at the end by delimiting it with a semi-colon (;).

8. Unpack the Squid source code and copy it to the directory c:\msys\1.0\home\{username}\squid.

The source code is in tar.gz format. You can use the 7zip software from http://www.7-zip.org to unpack the source code.

9. At the MSYS terminal, go to the Squid source code directory and run the compile commands as follows:

$ cd /home/{username}/squid
$ ./configure --prefix=/usr/local/squid --enable-win32-service
$ make all
$ make install


This will create the Squid binaries in the following directory c:\msys\1.0\local\squid

10. You can now copy the folder of Squid binaries to your desired location like "c:\squid" or create an installer package for your other machines.

The MinGW and MSYS software are not needed by Squid once you are able to create its binaries under Windows.

11. Assuming that you have relocated the Squid binaries to c:\squid, edit the squid.conf configuration file to reflect the relative references to the file locations under Windows.

12. Initialize the cache by issuing the command:

c:\squid\sbin> squid.exe -z

The will create the cache folders and files under c:\squid\var\cache


13. Start the Squid server by issuing the command:

c:\squid\sbin\squid -f c:\squid\etc\squid.conf

This will start Squid and will load the configuration file squid.conf under the directory c:\squid\etc.

Sunday, July 12, 2009

Initializing, Starting, Stopping, and Accessing the PostgreSQL Server on Windows

This assumes that you have the PostgreSQL binaries for Windows and that you have placed it at "c:\pgsql" directory. To set up PostgreSQL, copy the "libpq.dll" file located in the directory "c:\pgsql\lib" to the "c:\windows\system32" directory as follows:

c:\pgsql\lib> copy libpq.dll c:\windows\system32


To initialize the database, create the data directory and initialize it by issuing the "initdb" command in the "c:\pgsql\bin" directory as follows:

c:\pgsql\bin>mkdir c:\pgsql\data
c:\pgsql\bin>initdb -D "c:\pgsql\data"


To start the database, type the "pg_ctl" command as follows:

c:\pgsql\bin> pg_ctl -D "c:\pgsql\data" -l logfile start

This will start the PostgreSQL database and create the database log file "logfile".

To stop the database, type the "pg_ctl" command as follows:

c:\pgsql\bin> pg_ctl -D "c:\pgsql\data" stop

To access the database at the DOS command prompt on Windows, type the command:

c:\pgsql\bin> cmd.exe /c chcp 1252
c:\pgsql\bin> psql

Compiling PostgreSQL on Windows

The following compilation procedure has been tested on MS Windows XP Professional using PostgreSQL 8.4.0, MinGW 5.1.4 and MSYS 1.0.11.rc-1.

Steps

1. Download MinGW and MSYS from http://www.mingw.org
2. Download PostgreSQL source code from http://www.postgresql.org
3. Download the zlib compression library from http://www.zlib.org
4. Install MinGW under the directory c:\mingw
5. Install MSYS under the directory c:\msys. Indicate where mingw is located when prompted by MSYS.

6. Add the path to Windows for the following directories:

c:\msys\1.0\bin
c:\msys\1.0\mingw\bin
c:\msys\1.0\mingw\sbin
c:\mingw\bin



This is done by going to "Start->Settings->Control Panel->System icon->Advanced tab->Environment Variables button". Then under the "System Variables" grouping, Select the "Path" and choose "Edit" button. Add the above directories at the end by delimiting it with a semi-colon (;).

7. Install the zlib library:

a) Unpack the zlib in MSYS (c:\msys\home\{username}\zlib)
b) Run MSYS by typing the msys.bat file in c:\msys\1.0
c) At the MSYS terminal, type the following:

$ cd /home/{username}/zlib
$ make -f win32/Makefile.gcc


d) Copy the zlib1.dll to c:\mingw\bin
e) Copy the libzdll.a and libz.a to c:\mingw\lib
f) Copy the zlib.h and zconf.h to c:\mingw\include


8. Unpack the PostgreSQL source code and copy it to the directory c:\msys\1.0\home\{username}\postgresql.

The source code is in tar.gz format. You can use the 7zip software from http://www.7-zip.org to unpack the source code.

9. At the MSYS terminal, go to the PostgreSQL source code directory and run the compile commands as follows:

$ cd /home/{username}/postgresql
$ ./configure
$ make
$ make install


This will create the PostgreSQL binaries in the following directory c:\msys\1.0\local\pgsql

10. Create the default data directory for PostgreSQL as "c:\msys\1.0\local\pgsql\data"

11. You can now copy the folder of PostgreSQL binaries to your desired location like "c:\pgsql" or create an installer package for your other machines.

The MinGW and MSYS software are not needed by PostgreSQL once you are able to create its binaries under Windows.