Archiv der Kategorie programming

GWt extreme

seems I learned how to embed :-). I went through a couple of good presentations recorded at Google I/O recently. while I liked the Lombardi folks explaining how they switched from flash to dojo finally implementing GWT, as well as the one showing the recent advances in GWT 1.5 (Javascript and DOM programming in GWT) where its getting clear that they want to ease (or better shield you) from accessing low level DOM. But nevertheless the presentation embedded above gets into gwtquery, fast drawing and a very nice way to develop gadgets.

Hibernate examples

some small examples covering various hibernate issues.

tcp_echo

even the echo service is disabled on Linux machines, it’s nevertheless an easy way to figure out spurios network delays. TIn perl the basics are already written in the NET::PING module. I only added some timing to it. If you don’t have the perl modules installed, a workaround is creating a script containing the line

echo $2 | /usr/bin/netcat -v $1 7

which you could than invoke with time scriptname host.domain.dmn string_to_use
here ist the other way

#!/usr/bin/perl
# simple tcp echo programm
# sample usage (verbose mode)
# /xxx/bin/tcp_echo.pl -v 1 -h host.domain.dmn
# /xxx/bin/tcp_echo.pl: host.domain.dmn 2
# res = 1 host host.domain.dmn time: 0.012088
# sample usage (normal mode)
# /root/bin/tcp_echo.pl -h host.domain.dmn
# res = 1 host host.domain.dmn time: 0.010903
#
use strict;
use Getopt::Long;
use Net::Ping;
use Time::HiRes;
use Time::HiRes qw(gettimeofday tv_interval);

my $program_name = $0;
my $timeout = 2;
my $hostname = “localhost”;
my $debug = 0;

sub helpMessage()
{
print “$program_name [-h|-?] [-v #] [-t #] [-h FQDM] [\n”;
print “-help|? this message\n”;
print “-v[erbose] enables debug messages \n”;
print “-t[imeout] timeout (default: 2)\n”;
print “-h[ost] hostname FQDN (default: localhost) \n”;
exit 1;
}

sub run()
{
my $t0 = [gettimeofday];
my $res = pingecho( $hostname, $timeout );
my $t1 = [gettimeofday];
my $elapsed = tv_interval $t0, $t1;
print “res = $res host $hostname time: $elapsed\n”;
}

Getopt::Long::Configure (”bundling”);
my $l_result = GetOptions (
‘help|?’ => sub { helpMessage() },
‘verbose|v=n’ => \$debug,,
‘host|h=s’ => \$hostname,
‘timeout|t=n’ => \$timeout);

print “$program_name: $hostname $timeout \n” if $debug;

&run();

proc/net/netstat monitor

I recently grabbed a little tcl script which you can use for process monitoring. Can’t remember the actual URL where I took it from, and it had no comments in it. Nevertheless, even it’s about a decade ago i worked with tcl, i changed it to print out which TCPext: fields of the netstat command changed. perhaps somebody can use it

#!/usr/bin/tclsh
#
# small utility to print the tcpext. flags that changed.
# Free to use, no warranty etc….
#
# ./mon_linux_netstat
# CTRL-C to stop
#
# Pit 03.07.07

cd /proc/net

set tcp_arr {
TCPEXTFAKE
SyncookiesSent
SyncookiesRecv
SyncookiesFailed
EmbryonicRsts
PruneCalled
RcvPruned
OfoPruned
OutOfWindowIcmps
LockDroppedIcmps
ArpFilter
TW
TWRecycled
TWKilled
PAWSPassive
PAWSActive
PAWSEstab
DelayedACKs
DelayedACKLocked
DelayedACKLost
ListenOverflows
ListenDrops
TCPPrequeued
TCPDirectCopyFromBacklog
TCPDirectCopyFromPrequeue
TCPPrequeueDropped
TCPHPHits
TCPHPHitsToUser
TCPPureAcks
TCPHPAcks
TCPRenoRecovery
TCPSackRecovery
TCPSACKReneging
TCPFACKReorder
TCPSACKReorder
TCPRenoReorder
TCPTSReorder
TCPFullUndo
TCPPartialUndo
TCPDSACKUndo
TCPLossUndo
TCPLoss
TCPLostRetransmit
TCPRenoFailures
TCPSackFailures
TCPLossFailures
TCPFastRetrans
TCPForwardRetrans
TCPSlowStartRetrans
TCPTimeouts
TCPRenoRecoveryFail
TCPSackRecoveryFail
TCPSchedulerFailed
TCPRcvCollapsed
TCPDSACKOldSent
TCPDSACKOfoSent
TCPDSACKRecv
TCPDSACKOfoRecv
TCPAbortOnSyn
TCPAbortOnData
TCPAbortOnClose
TCPAbortOnMemory
TCPAbortOnTimeout
TCPAbortOnLinger
TCPAbortFailed
TCPMemoryPressures
}

#
# read in the values from the netstat file
proc scan_net { _dat} {
upvar $_dat dat
global tcp_arr

set in [open “netstat” “r”]
set l [gets $in]
set l [gets $in]
close $in

set a [split $l ” “]

foreach x $a n $tcp_arr {
if {[string match “TcpExt:” $x]} {
continue
}
set dat($n) $x
#puts “dat von n($n) = $dat($n) ”
}
}

#
# set inital data array and fill it
array set dat {}
scan_net dat

# forever
# sleep 1 second, read in second array
# loop and compare values, if different print the sum
# reset the initial array and copy new to old
while {1} {
after 1000

array set new_dat {}
scan_net new_dat

set somechange 0
foreach a $tcp_arr {
if {[string match “TCPEXTFAKE” $a]} {
continue
}
if {$new_dat($a) != $dat($a)} {
set res [expr {$new_dat($a) - $dat($a)}]
#puts “attribute ‘$a’ from $dat($a) to $new_dat($a) $res”
puts “‘$a’ $res”
set somechange 1
}
}

if {$somechange} {
puts “”
}

array set dat {}
array set dat [array get new_dat]
}

Web3D Enters Formal Liaison with Khronos Group

X3D and COLLADA is the initial focus of synergy

There’s also a whitepaper Developing Web Applications with COLLADA and X3D. Lets hope that they really meet their goals.

Ever heard of Al Khwarizmi

From the intro of a new online book about algrithms , the draft was devoted to the public by its authors S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani.   

“Al Khwarizmi laid out the basic methods for adding, multiplying, and dividing numbers. even extracting square roots and calculating digits of PI. These procedures were precise, unambiguous, mechanical, efficient, correct.in short, they were algorithms, a term coined to honor the wise man after the decimal system was nally adopted in Europe, many centuries later.”