Wednesday, December 23, 2009

CVS

Quick start to CVS on linux.

CVSNT/CVS 2.x client/server downloads for windows, linux and Mac OS X:
http://www.march-hare.com/cvspro/

WinCVS client also can be separately downloaded from WinCVS download.



Set up CVSNT 2.5.04 on WindowsXP or Windows 2003 server:
(The following steps are extracted from here)

1. Preparation
1) Prepare a NTFS partition for CVSNT. [this is not necessary]
2) In folder's Tools -> Folder Options -> View -> Advanced Settings,
Cancel "Use Simple File Sharing (recommended)". [this is not necessary]
3) Create two folders:
- D:\Temp, set its security settting to "fully control" by all users.
- D:\CVSRepo. This will be where repositories are stored in.
2. Installation of CVSNT. Use default settings.
3. Configure
1) First create two windows system accounts, say CVS_Mgr and CVS_Usr.
2) Open CVS control panel, in tab "About", Click on "Stop" to stop CVSNT service.
3) In "server settings" tab, choose "Temporary" folder to the previous created D:\Temp.
Choose "CVS_Mgr" or "CVS_Usr" for "Run as user".
4) In "Repository configuration" tab, add new repository,
set "Location" to "D:\CVSRepo", and set "Name" to "\CVSRepo".
Leave "Default repository" unchecked and the rest 3 checkboxes checked.
5) Now in CVS control panel, in tab "About", Click on "Start" to start CVSNT service.
6) Add users. Do this from command line in a DOS windows.
Let CVS_Mgr belong to the Administrators group.
In command line, type these:
set cvsroot=:sspi:<computer name>:/CVSRepo
cvs passwd ­-a CVS_Mgr
cvs passwd ­-a CVS_Usr
It will prompt for the passwords of these 2 users.
Now the setup is done.
7) Use the following to test it:
In a DOS window, type
set cvsroot=:pserver:CVS_Mgr@<computer name>:/CVSRepo
cvs login
cvs ls
This will list the current files in the repository.
Now one can connect to the CVSNT server from CVS clients on other machines.

Saturday, December 12, 2009

Bloom Filter

One problem is to determine if a given value x exists in a set S. When the size of the set S is huge, there can be computational cost and storage difficulty.

Bloom filter solves this problem by a way similar to this:
1) preprocess the set: for every value w in the set S, compute a feature vector (v_w1, v_w2, .. v_wn). In the entire vector space, set these as 1, set the rest as 0.
2) compute the feature vector for the given value x (v_x1, v_x2, ..., v_xn). Now if all of v_x1, v_x2, ..., v_xn are 1, then it's possible the value x is in the set S.

The issue is possible false-positive: x is not in the set, but its feature vector are all 1s. To solve the issue, the key is to choose good vector computation function(s). Usually the probability of false positive is 0.0001 or below.

The advantage, on the other hand, is that there is NO false-negative: if computation shows the value x does not exist, then this is 100% correct. Therefore bloom filter is very reliable and efficient in ruling out a value that does not exist.

See this page for a more detailed explanation for bloom filter, and a piece of comment.
More topics of the application of math from this author are here.

Read/Write Excel on Windows & Linux

On windows read/write Excel is easy. Set up ODBC for read and write connections on source and destination Excel files. For some reason Microsoft does not allow delete records in Excel through the ODBC interface (actually might be in any other interfaces), so delete can be done by replacing the current Excel with a blank Excel at the File System level.

In linux, there are modules created by people in PHP to do this, such as PHPExcel. So you download the library and use it. In Perl, the modules Spreadsheet::ParseExcel and Spreadsheet:WriteExcel are written by Takanori Kawai and John McNamara in 2000 and tincluded into CPAN. If your Perl installation does not come with this, install them (e.g., using PPM on windows or CPAN on linux). Some example code are here. This code works for Excel up to version 2000. I didn't try on more recent versions. On windows Perl also can manipulate Excel using the Win32::OLE package which is recommended.

To write Excel file, there is a shortcut to output to a *.csv file. A *.csv file uses comma as delimiter and is opened by Excel, then you can save it as a true Excel file. To escape comma in a *.csv file, quote the entry by double quotes, e.g., "a,b". To include a double quote in an quoted entry, replace it with two double quotes, e.g., "a""b".

Thursday, December 10, 2009

Network tools

To find out what server (IIS/Apache etc.) a site is running:
http://uptime.netcraft.com/up/graph
or: http://whois.domaintools.com/thedomainname.com

Many tools for analyzing web stuff:
http://www.dnsstuff.com/tools/

Saturday, December 5, 2009

DOS batch file to backup files

Batch file backup_mystuff.bat:

echo off
REM
REM This script backs up files.
REM Files listed in %exclude_list% are excluded.
REM
REM Reference: http://www.ahuka.com/backup/backup3.html
REM By: XC
REM Created on: 12/5/2009
REM Last modified: 12/5/2009
REM
echo.
echo == Back Up Files ==
echo.

REM
REM Use this, and !var! after assignment.
REM Otherwise the input value will be buffered until next execution.
REM
SETLOCAL ENABLEDELAYEDEXPANSION

set "dstDir=mystuff_%date:~10,4%-%date:~4,2%-%date:~7,2%"
set srcDir=D:\wwwroot\mystuff
set exclude_list=mystuff_exclude_list.txt

if EXIST %dstDir% (
(set USRINPUT=)
set /P USRINPUT=Delete existing directory %dstDir% [y/n]:
REM echo Your input was: !USRINPUT!

if "!USRINPUT!" == "y" goto:go_on
if "!USRINPUT!" == "Y" goto:go_on
REM If input is not 'y' or 'Y', exit.
goto:EOF

:go_on
echo Delete existing directory %dstDir%...
rmdir /S /Q %dstDir%
)

echo.Copy files from %srcDir% to %dstDir%, please wait...
echo.

mkdir %str%
xcopy /E /V /Y /Q /EXCLUDE:%exclude_list% %srcDir%\* %dstDir%\.
echo.

And example mystuff_exclude_list.txt file:

D:\wwwroot\mystuff\download
D:\wwwroot\mystuff\aspnet_client

Blog Archive

Followers