Thursday, December 30, 2010

Comment on slashdot

One of the more fun software competitions I've run across is to write the slowest sorting algorithm. Trivial programming tricks such as do-nothing loops that just run a counter to use time disqualify you, obviously. The judging is solely on the algorithm, by comparing the O(N) functions. One of the winners in the early years was a sort that generated a random permutation of the data, and tested it for sortedness, repeating if it wasn't sorted. And it turns out that there are several progressively worse variants of this, depending on how ridiculous your random-permutation algorithm is.
I should go find this contest again, and see what sorting atrocities they've come up with in the past couple years ...
(I did once read a suggestion that such contests not be widely publicised, out of fear that managers will find them and declare the winning algorithms the new company standards. ;-)

Thursday, October 28, 2010

Reset an exisiting TCP connection

In linux it is not possible from userland to close an existing connection other than bringing down the application that is using that connection.

FreeBsd has an utility to forcefully close a connection as long as you have root privileges
http://www.freebsd.org/cgi/man.cgi?query=tcpdrop&sektion=8&manpath=FreeBSD+5.4-RELEASE

Linux does not have an equivalent tool, so you have to use TCP level hacks to forcefully RST a connection. We will have to use a combination of Tickle-ack and RST packet to force a connection reset

1. Send Tickle to remote machine
2. Remote machine sends a packet with valid ack/seq no
3. Use the ack/seq no returned by remote machine to send a RST

Step 1 and 2 are required to find the correct ack/seq no, a RST packet without correct ack/seq no is ignored by the remote machine as invalid

Sunday, October 10, 2010

Auto-close PARENT incidents in etrack

Download etrack CLI package for linux from https://engtools.engba.symantec.com/tools/etrackclipage.html. Untar the package to some location and add softlink in /usr/local/etrack

sudo ln -s /home/username/etrack5.3 /usr/local/etrack
Enable auto-login by running elogin script from /usr/local/etrack/perl/bin/elogin, which should ask for your username and store password in ~/.epass (plaintext) and all subsequent etrack commands would use this password

Create a script to automatically close all completed PARENT incidents using

echo "select incident from incident_view outer where version='PARENT' and state!='CLOSED' and assigned_to='' and incident not in (select superincident from incident_view inner where outer.incident=inner.superincident and state!='CLOSED')" | /usr/local/etrack/perl/bin/esql |
while read incident; do
echo "childs closed" | /usr/local/etrack/perl/bin/eclose -i $incident -r "SERVICE_COMPLETED" -B
done
Example to set any field in etrack to empty

/usr/local/etrack/perl/bin/eset -T @ -i $incident # will set target_version to empty for $incident

Add Etrack to search bar of firefox

Install https://addons.mozilla.org/en-US/firefox/addon/3682/ extension for firefox. This should give you ability to add any website search bar to firefox search bar.

Once you install the extension, go to etrack website, right-click on the incident number search bar, you should see a option 'Add to search bar'.

Use 'Ctrl+k' to go to firefox search bar, 'Ctrl+up/down arrow' to scroll through the list of available search engines.

Auto-check comment propogate for incidents

Install greasemonkey extension for firefox available at https://addons.mozilla.org/en-US/firefox/addon/748/ (restart firefox to complete installation of addon)

After restart, right-click on the greasemonkey icon at the bottom-right corner and select 'New user Script'

Enter details for Name/Description. Namespace is used for collision detection if 'Name' is same multiple user scripts.

Add to 'Includes'
https://engtools.engba.symantec.com/*
https://engtools.veritas.com/*


Click 'Ok', it should open an editor for editing the script, add the following code to the script
var elmLink = document.getElementsByName('propogate_comment');
elmLink[0].checked = 'checked';