Wednesday, March 26, 2008

Sorting for Humans : Natural Sort Order

How to solve the following problem when comparing or sorting strings:
1.1
1.10
1.11
1.2
etc.

1.2 should come *before* 1.10, etc., but in a naive sort it does not.

See also the C# code he cites: http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting

Subversion Authentication With a Windows Domain

Really quite easy, according to a colleague.

Monday, March 17, 2008

Technology Review: Blogs: Ed Boyden's blog: How to Think

Technology Review: Blogs: Ed Boyden's blog: How to Think: "When I applied for my faculty job at the MIT Media Lab, I had to write a teaching statement. One of the things I proposed was to teach a class called 'How to Think,' which would focus on how to be creative, thoughtful, and powerful in a world where problems are extremely complex, targets are continuously moving, and our brains often seem like nodes of enormous networks that constantly reconfigure. In the process of thinking about this, I composed 10 rules, which I sometimes share with students. I've listed them here, followed by some practical advice on implementation."

Wednesday, March 05, 2008

Tactics for Reducing the Subjective Experience of Down Time

"Time indicators

The formulae below all depend on use of a time indicator. The following choices of time indicators are listed from most to least desirable.

1. Estimated and remaining-time indicator. Place this either in a modal dialog or in the status bar at the bottom of the window.
2. "The system is alive" indicator. When it is impractical to offer the actual times, show an animated object that will let users know the system has not frozen. For longer waits, choose the rolling barber pole often found in status bars or other large animated object. For shorter waits (less than 10 seconds), you may use, instead, an animated "wait" mouse pointer, such as a spinning ball or animated hour glass.
3. "I hear and understand" indicator. When the expected wait is of short enough duration (less than 2 seconds) that displaying elapsed time, etc., is meaningless, display the hour glass."

Wednesday, February 20, 2008

How-To: vmware-tools hgfs module on Ubuntu Gutsy Gibbon (7.10)

Arg. Doesn't work out of the box, disallowing you to use shared directories. Luckily this guy provided a way to fix it!

Tuesday, February 19, 2008

Intercepting method calls in C#, an approach to Aspect-Oriented Software Development

Cool! Roy Osherove used this to develop XtUnit, an NUnit addin which implements database rollbacks, described here. He uses System.Transactions.TransactionScope, which is a .NET facility for creating transactable components. Tres cool, no?

Monday, February 04, 2008

Tuesday, January 15, 2008

Signs of a Bad Boss (seen by me in the wild)

A certain someone at a certain company fit this to a T.

Bosses are supposed to ask themselves these questions:

1. Have you ever publicly criticized an employee?

2. Do you take credit for your employees’ work?

3. Do your employees fear you?

4. Do you expect employees to do what you tell them without question?

5. Do you believe employees should know what to do without you telling them or providing guidelines?

6. Are you a yeller?

7. Do you demean employees as a form of punishment?

8. Do you play favorites?

9. Do you hate delegating?

10. Do you check everyone’s work?

Friday, January 11, 2008

How to find files that are different between two git trees (working with git and, *gulp*, SourceSafe)

I do this a lot in my project. I change a bunch of files, and since I'm working with SourceSafe, I need to know which files to check out of SourceSafe so that I can replace them with the changed versions.

Use this command:
git diff-tree -r --name-status branch1 branch2
where branch1 is the branch I'm going to check into SourceSafe and branch2 is the upstream branch.

Example:
/c/Yellowstone.master
$ git diff-tree -r --name-status master POS-safe
M Databases/OpenBook/Alter Scripts/THE ONLY 2.2 ALTER SCRIPT YOU NEED.sql
M OpenBookSolution/HotL/DirectBillPaymentForm.cs
M OpenBookSolution/HotL/EditReservationForm.cs
M OpenBookSolution/HotL/NonGraphicalReserveForm.cs
M OpenBookSolution/HotL/OpenBook.cs
M OpenBookSolution/HotL/ReportForms/ReportSelectorForm.cs
M OpenBookSolution/HotL/SelectDirectBillAccountForm.cs
A OpenBookSolution/HotLOnly.sln
D OpenBookSolution/HotLOnly/HotLOnly.sln
M OpenBookSolution/Yellowstone.OpenBook.BusinessEntities/MonetariesBusinessEntity.cs

/c/Yellowstone.master
$
The basic procedure is:
  1. hack hack hack
  2. Get my tree in good shape, usually by rebasing my branch onto the SourceSafe tracking branch.*
  3. Run the diff-tree command above to find changed files.
  4. Check out those files. If there are any warnings from SourceSafe about the files being different (and not just writable), then do the following:
    1. Get latest from SourceSafe into the SourceSafe tracking branch (typically "master") in my project.
    2. Commit.
    3. Go back to step 2 above.
  5. Merge development branch into master. Sometimes I do this step a commit or three at a time instead of an en masse merge of the branch all at once.
  6. Check changed files back into SourceSafe.
*I realize that rebasing my development branch onto "master" probably isn't the wisest thing in the world, as it loses information -- specifically, the fact that I had branched the code. It was an interesting experiment, though. Perhaps I'll go back to merging again. Although the fact that we're using SourceSafe, which doesn't have the concept of a branch, probably means that what I'm doing isn't all that un-kosher.

The flavor of git I use is msysgit.

Linus clarifies "Central Repository" issue on git in a way palatable to managers

Linus was previously rather dogmatic about having no "official" version of a project. But here he's not quite so religious and explains how you can effectively satisfy those who would like a central repository. The distinction, he says, is social, not technical:
I certainly agree that almost any project will want a "central" repository
in the sense that you want to have one canonical default source base that people think of as the "primary" source base.

But that should not be a *technical* distinction, it should be a *social* one, if you see what I mean. The reason? Quite often, certain groups would know that there is a primary archive, but for various reasons would want to ignore that knowledge: the reasons can be any of ....

ExtJS javascript library

Tres cool!
"Ext (pronounced "extent"[citation needed]) is an open-source JavaScript library, for building richly interactive web applications using techniques such as AJAX, DHTML and DOM scripting.

Originally built as an extension of YUI, Ext can now also extend jQuery and Prototype. As of version 1.1, Ext can run stand-alone without relying on any of those external libraries, though they remain an option for integration.

Ext version 2.0 can now use many different base libraries (adapters) like YUI, jQuery, Prototype or it can work Stand-alone"

Tuesday, January 08, 2008

PyPy "dot" graph viewer (Python)

Referred to from this site: http://morepypy.blogspot.com/2008/01/visualizing-python-tokenizer.html:
"For debugging purposes I implemented a visualization tool for DFAs using PyPy's pygame-based graph viewer. The graph viewer is able to visualize interactively any graph given in the graph-description language of Graphviz. Looking at the tokenizing DFA for Python is rather instructive, both for understanding how tokenizing works and (maybe) for understanding the Python language. To try it, download the dot file of the DFA and run from a pypy checkout:
$ python pypy/bin/dotviewer.py tokenizer.dot
The following is a screenshot of the graphviewer: "

Monday, January 07, 2008

TCL: Creating Temporary Files

From the page:
"Tcl doesn't have a built-in command to create a temporary file and there are no built-in variables for temp directories, so you have to do a little work.

....

I had some luck with the following procedure on a UNIX box. Maybe, somebody can check if it works for windows.

 proc tempfile {prefix suffix} {
set chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
set nrand_chars 10
set maxtries 10
set access [list RDWR CREAT EXCL TRUNC]
set permission 0600
set channel ""
set checked_dir_writable 0
set mypid [pid]
for {set i 0} {$i < $maxtries} {incr i} {
set newname $prefix
for {set j 0} {$j < $nrand_chars} {incr j} {
append newname [string index $chars \
[expr ([clock clicks] ^ $mypid) % 62]]
}
append newname $suffix
if {[file exists $newname]} {
after 1
} else {
if {[catch {open $newname $access $permission} channel]} {
if {!$checked_dir_writable} {
set dirname [file dirname $newname]
if {![file writable $dirname]} {
error "Directory $dirname is not writable"
}
set checked_dir_writable 1
}
} else {
# Success
return [list $newname $channel]
}
}
}
if {[string compare $channel ""]} {
error "Failed to open a temporary file: $chanel"
} else {
error "Failed to find an unused temporary file name"
}
}

Igor Volobouev"

Thursday, December 27, 2007

sysobjects and Object Types in SQL Server

Object type. Can be one of these object types:

C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
IF = Inlined table-function
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure