Blogger

Clearcase Cheat Sheet

• write a new config spec with private branch (by hand)
• this doesn't work unless the "branch type" already exists (see below)

element * CHECKEDOUT
element * ...\my_private_branch\LATEST
mkbranch my_private_branch
element * \main\LATEST
element * \main\0

• windows example of creating the "branch type"
• you might have to do this on all vobs from which you plan to checkout
cd /d "X:/my_vob"
cleartool mkbrtype –nc my_private_branch

• here's where the help files are on my computer
file:///C:/Program%20Files/Rational/ClearCase/doc/help/cc_ref/ct_rmname.htm

• to remove a file from a view (it still exists in clearcase) you use the rmname command
• the folder must already be checked out
cleartool rmname myfile.cxx

• to move a file from one place to another, you use the mv command
cleartool mv myfile.cxx somewhere\myfile.cxx

• to add a new file to source control, you use the mkelem command
• here's an example in unix
cd /vobs/myvob/myfolder
cleartool checkout -unr -nc mysubfolder
cd mysubfolder
cleartool mkelem myexistingfile.cxx
.
cleartool checkin myexistingfile.cxx
<your comments here>
.
cd ../
cleartool checkin mysubfolder
.

• to see the difference between two versions of a certain file
cleardiff \myvob\myfolder\myfile.cxx@@\main\mybranch\2 \myvob\myfolder\myfile.cxx@@\main\anotherbranch\3

• to get/set permission info for a file in clearcase
Z:\myvob\myfolder>cleartool describe -long myfile.exe

version "myfile.exe@@\main\1"
created 2009-03-30T13:45:41-04 by Michael Holtstrom (myname.mygroup@mymachine)
"checkin comments"
Element Protection:
User : DOMAIN\myname : r--
Group: DOMAIN\mygroup : r--
Other: : r--
element type: compressed_file
predecessor version: \main\0
Attributes:

Z:\myvob\myfolder>cleartool protect -chmod 755 myfile.exe

• to get help
cleartool man

• for a given view, what are the versions of a certain set of files
Z:\myvob\myfolder>cleartool find . -nr -type f -name sk*.h -cvi -print

. All elements in and below the current directory [Z:\myvob\myfolder]
-nr Don't recurse. Only look at elements within this directory.
-type f Only look at elements that are of type file (i.e. not directories, not symlinks)
-name sk*.h Only look at files whose names start with 'sk' and end with '.h'
-cvi Display the version that is currently selected by this view.
-print Print the result-set to screen

• same as above but the search location is explicitly specified
Z:\>cleartool find "Z:\myvob\myfolder" -nr -type f -name sk*.h -cvi -print

• for a set of files, find those that are on a certain branch and report the version selected by this view
Z:\myvob\myfolder>cleartool find . -nr -type f -name sk*.h -branch "brtype(mybranch)" -cvi -print

-branch "brtype(mybranch)" == First eliminate all versions of selected elements that *aren't* on branch 'mybranch'
-cvi == Then from the remainder, only keep the versions that are currently selected by this view.

See above for meaning of [ . -nr -type f -name sk*.h -print ]

• for a set of files, find those that aren't on a certain branch and report the version selected by this view
Z:\myvob\myfolder>cleartool find . -nr -type f -name sk*.h -branch "!brtype(main)" -cvi -print

-branch "!brtype(main)" == First eliminate all versions of selected elements that *are* on branch 'main'
-cvi == Then from the remainder, only keep the versions that are currently selected by this view.

See above for meaning of [ . -nr -type f -name sk*.h -print ]

• find all files of a certain type in a certain location
Z:\>cleartool find "Z:\myvob\myfolder" "Z:\myvob\another" -nr -type f -name *.h -cvi -print

"Z:\myvob\myfolder" "Z:\myvob\another" == All elements in and below these directories [Z:\myvob\myfolder], [Z:\myvob\another]
-name *.h == Only look at files whose names end with '.h'

See above for meaning of [ -nr -type f -cvi -print ]

• find all files from a set of types/extensions in a certain location
Z:\>cleartool find "Z:\myvob\myfolder" "Z:\myvob\another" -nr -type f -name *.[tch]* -cvi -print

-name *.[tch]* == Only look at files whose names contain '.t' or '.c' or '.h' (i.e. '.txt', '.cpp', '.cxx', '.c', '.h')

See above for meaning of [ "Z:\myvob\myfolder" "Z:\myvob\another" -nr -type f -cvi -print ]


Moving from vs6 to vs9 breaks Latin1 support

I have a database that contains latin1 data and is accessed by several applications. One application runs in the msdos console. We used to build it with vs6 (msdev98) but recently moved to vs9 (microsoft visual studio 2008). We call setlocale(LC_CTYPE,"") near startup.

Default winxp is oem cp437. That means that not all latin1 characters can be displayed in msdos. Consequently, we detect these characters and display simple-ascii escape sequences instead.

Default winxp is LC_CTYPE English_United States.1252. In vs6 that didn't matter, but in vs9, when using printf, a magic last-minute best-fit mapping occurs. This is very painful for me.

I put together the following app so that I could see what's going on. As far as I can tell, the only way to defeat vs9's best-fit mapping is to instead call setlocale(LC_CTYPE,".OCP").


Monty Hall Problem and Intuitive Solutions

Classical Problem

There are three doors. Two hide nothing. One hides a car. In phase 1, you pick a door. Monty (knowing where the car is) opens a door that does not hide a car and that you did not pick. In phase 2, you may stay with your chosen door (StayStrategy) or you may change your guess to the one remaining door (SwapStrategy). If you've picked the door that hides the car, you win the car.

The Truth

In the Classical Monty Hall problem, the StayStrategy succeeds with 1/3 probability, and the SwapStrategy succeeds with 2/3 probability.

Hand Wavy Justification

Imagine that there are 100 doors. You choose one. Knowing where the car is, Monty Hall opens 98 doors (other than your pick) that don't have the car. It is intuitively clear that your door has low probability of success, while the swap door has high probability of success.

Modified Problem

Imagine the same game, except Monty Hall doesn't know where the car is. After you pick a door in phase 1, he randomly reveals one of the remaining two doors. Now consider the situation where (by chance) he does not reveal the car. Should you stay or swap? Note: this problem only considers the situation when Monty Hall (by chance) has opened a door that does not hide the car.

The Truth

In the Modified Monty Hall problem, the StayStrategy succeeds with 1/2 probability, and the SwapStrategy succeeds with 1/2 probability.

A False Hand Wavy Argument

Imagine that there are 100 doors. You choose one. Not knowing where the car is, Monty Hall opens 98 doors (other than your pick) that don't have the car. This situation is highly unlikely, but possible. Originally, you knew that your door had a 1/100 probability of hiding the car, so it must reasonably be true that all the other doors combined had a 99/100 probability of hiding the car, and since they have been narrowed to one selection, the swap door must have a higher probability of success.

Proof For The Classical Problem

The Classical Monty Hall problem is exactly equivalent to the following problem. You pick a door with a 1/3 probability of success. There is a 2/3 probability that one of the other two doors hides the car. You are given the option of opening and winning the contents of just your selected door (StayStrategy) or both the other doors (SwapStrategy). Because Monty Hall never reveals the car, the (SwapStrategy) is exactly equivalent to having both the other doors, and therefore 2/3 probability of success. It is important to remember that there are only two possible outcomes to this game: the stay door hid the car or the swap door hid the car. The Monty door never hides the car. This proof is particularly evident when examining the source code for a simulation of the game. In the simulation it is not necessary to determine which door Monty reveals. All you need to do is randomly generate a car on [1..3] and randomly generate a guess on [1..3]. If the car equals the guess then the (StayStrategy) wins, otherwise the (SwapStrategy) wins.

Proof For The Modified Problem

The Modified Monty Hall problem is actually three problems considered in isolation. It is true that your original pick has 1/3 probability of success. It is true that Monty Hall is not allowed to reveal your door. This does not change the fact that the door Monty Hall picks has a 1/3 probability of hiding the car. Since neither your nor Monty have knowledge of which door hides the car, regardless of the picks, each door has a 1/3 probability of hiding the car. Hence in the millions of times that the game is played, 1/3 of the games end with Monty Hall accidentally revealing the car. In the remaining 2/3 of the games played there is a 50% probability that the (StayStrategy) wins, and a 50% probability that the (SwapStrategy) wins. That is to say that 1/3 of all games end with Monty Hall accidentally revealing the car, 1/3 of all games end with your original pick hiding the car, and 1/3 of all games end with the remaining door (picked by neither you nor Monty) hiding the car.

If You Don't Believe Me

Java Simulation Source Code
Java Simulation Executable Jar File
Java Simulation Results


Customizing Blogger

I started with the Minima template and made a few changes. Basically I just changed some of the styles, removed the header, replaced the sidebar and body divs with a table so that the page would resize nicely without one or the other getting pushed to the bottom, and embedded my own title inside the sidebar area.


/* ---- Header ---- */

#header {
text-align: left;
color:$pagetitlecolor;
font: $pagetitlefont;
white-space: nowrap;
}
#header h1 { }
#header a { }
#header a:hover { }
#header .description { }
#header-wrapper { }
#header-inner { }
#header img { }

/* ---- Body ---- */

#outer-wrapper {
margin:0 auto;
padding:10px;
text-align:$startSide;
font: $bodyfont;
}

#main-wrapper {
padding-left: 30px;
max-width:700px;
vertical-align: top;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

#sidebar-wrapper {
width: 220px;
vertical-align: top;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}
...

<table align='center'><tr><td id='sidebar-wrapper'>
<div id='header'>Michael Holtstrom</div>

...

</td><td id='main-wrapper'>

...

</td></tr></table>

Also, I'm using syntaxhighlighter which I first heard about at developertips.blogspot.com. But the author of syntaxhighlighter links to blog.cartercole.com which gives simple instructions and the text you need to paste into your blogger template to get it running. It's probably best to host the source yourself, but for now I'm going with quick-and-easy.


Windows Dos Batch Files


@echo off

IF .%1 == . (
GOTO ERROR
) ELSE IF .%1 == .goat (
SET MSG=echo good guess
) ELSE (
SET MSG=echo nope %1 is wrong
)

IF .%2 == . (
GOTO ACTION
) ELSE IF .%2 == .goat (
SET MSG=%MSG% ^& echo good guess
) ELSE (
SET MSG=%MSG% ^& echo nope %2 is wrong
)

IF NOT .%3 == . ( GOTO ERROR )

:ACTION
echo.
echo Thanks for playing.
%MSG%
GOTO DONE

:ERROR
echo.
echo doit ^<guess^> [^<another^>]
echo.
echo Example: doit mouse
echo.

:DONE

You don't need quotes. But in order to check for empty vars you can prefix with anything, for example a dot. You get the args via %1, %2, etc. You set vars using anyname and later read them via %anyname%. You can mimic functions via GOTO. Special characters like <>& need to be escaped via ^ in order to be printed. You can print an empty line via echo followed by a dot, but you can't embed a line break in an echo. You can build a var that is a series of echo commands separated via the & symbol (which indicates that a new command is starting).


Living in Linux

Who is connected on what port?

netstat -atn
netstat -at
lsof | head -1
lsof | grep TCP

 |  Tribal Worker  |  Terms  |  Aggressive Software  |  Feedback  |