Visual Studio 2008: Release vs. Debug

December 11th, 2007

Some observations:

  • String pooling seems to be enabled in Debug (although not selected)
  • __FILE__ is expanded with relative path in release build, but contains absolute paths in debug mode. The "use full paths" option was set to "no" in Release and Debug

Delete of Team Foundation Server Builds

September 11th, 2007

environment Team Foundation Server 2005

problem Delete all builds except the most 10 recent

solution Using powershell

CleanupNightlyBuild.cmd

powershell.exe c:\DirWherePs1FileIs\CleanupNightlyBuildDontCallMe.ps1

pause

CleanupNightlyBuildDontCallMe.ps1

$tfbuild="C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\TFSBuild.exe"

# sort by time
$dirs=(ls "c:\\DropLocation\\BuildLabel_*" | sort -property LastWriteTime -desc)

# delete all except the newest 10 ([math]::max)
# -f op
$dirs | select -last ([math]::Max($dirs.length-10,0)) `
| %{ .$tfbuild delete http://tfsserver:8080 TuT ('"{0}"' -f $_.Name) /noprompt }

gSoap and MapPoint

August 17th, 2007

environment linux, Qt, c, gsoap, Microsoft MapPoint

problem I want an IRC bot which can calculate distances between users and display the local time of a user

solution Modifications to karmabot, which is written in Qt. The MapPoint WebService comes in handy. Although gSoap doesn't like MapPoint straight OOTB. Thus you need to remove "opaque=" from

gsoap-linux-2.7/plugin/httpda.c:243:      sprintf(soap->gt;tmpbuf, "Digest realm=\\"%s\\", username=\\"%s\\", nonce=\\"%s\\", uri=\\"%s\\", qop=\\"%s\\", nc=%s, cnonce=\\"%s\\", response=\\"%s\\", opaque=\\"%s\\"", soap->gt;authrealm, soap->gt;userid, data->gt;nonce, soap->gt;path, qop, ncount, cnonce, response, data->gt;opaque);
gsoap-linux-2.7/plugin/httpda.c:245:      sprintf(soap->gt;tmpbuf, "Digest realm=\\"%s\\", username=\\"%s\\", nonce=\\"%s\\", uri=\\"%s\\", response=\\"%s\\", opaque=\\"%s\\"", soap->gt;authrealm, soap->gt;userid, data->gt;nonce, soap->gt;path, response, data->gt;opaque);

thanks to this posting.
You need to use httpda.h for digest authentication. Add gsoap-linux-2.7/plugin/httpda.c and gsoap-linux-2.7/plugin/md5evp.c and link against openssl (-lssl). That should do the trick. Because it cost me some time, I'll paste code for a find request:

char* arr[] = { "PopulatedPlace" };
struct mpt__ArrayOfString EntityTypeNames = {1, arr };

struct mpt__FindSpecification spec = {
        "MapPoint.World",
        "Vienna, Austria",
        &EntityTypeNames,
        NULL };

struct _mpt__Find req = { &spec };
if(soap_call___ns2__Find(gSoap, NULL, NULL, &req, resp) != SOAP_OK)

IRC Bot with R

August 14th, 2007

environment IRC (internet relay chat), R

problem Evaluate R code in an IRC channel and post the output of R back into the channel

solution A modified KarmaBot version. Come to EFNet into the channel #statistics.

Syntax: "r: <R-Code>"

Sample: "r: 1:4"

Re-format #defines into C# enums

August 12th, 2007

environment msdn documentation, gvim, C#

problem I want legacy C defines like this to be represented by a nice C# enum.

solution

  1. Copy the table from msdn containing the #define names, values and comments to gvim
  2. Use this regular expression
    %s#\\v(\\u)([A-Z_]+) (0x\\d+)L (.*)#^M///<summary>^M/// \\4^M///</summary>^M\\1\\L\\2 = \\3,#
  3. Paste into your C# file

Notes

  • \v sets vim to very magic mode - fear - so the () don't have to be escaped.
  • \u matches uppercase characters.
  • ^M is a new line - on Windows use "Strg+Q Enter" to get it.
  • \L\2 changes the contents of the succedding back reference to lower case.

Overloading new, delete in C++

July 7th, 2007

environment C++ with Visual Studio 2005

problem Override new operator including additional parameter. Override delete operator and check if the correct delete operator is called when invoked on a base class.

solution


class A
{
};

class B : public A
{
public:
void *operator new( size_t stAllocateBlock, char chInit )
{
printf("B.new called\n");
return malloc(stAllocateBlock);
}

void operator delete( void * p, size_t)
{
printf("B.delete called\n");
free(p);
}
};

main:

A* a = new('a') B;

delete a;

Well, B::delete is not invoked.

links

Gentoo, ebda is big kernel setup stack overlaps lilo

June 25th, 2007

environment gentoo

problem error message on boot ebda is big kernel setup stack overlaps lilo

solution mount using gentoo live cd, mount proc, mount root, mount boot, chroot, /sbin/lilo *done*

Gentoo, fail2ban and ssh - no OOTB experience

June 13th, 2007

environment gentoo, fail2ban >0.8

problem drop ip packets from host that failed to authenticate via ssh

solution

1. emerge fail2ban
2. edit /etc/fail2ban/jail.conf

Look for [ssh-iptables] and fix:

enabled = true
logpath = /var/log/messages

If you want emails, fix 'dest='.

debugging/monitoring

Nice summary

/usr/bin/fail2ban-client status ssh-iptables

Axiom and MediaWiki

May 27th, 2007

environment MediaWiki, Axiom

problem Integration like R Extension missing

solution Download this and put it into your extensions/ directory.

Edit LocalSettings.php and append require_once('extensions/Axiomext.php'); at the end.

links Apperently they support a different Wiki

offical extension site

credits Thanks to Bill Page and Martin Rubey.

Sony VGN-S2HP + Vista = NO MemoryStick!

May 26th, 2007

environment Sony VGN-S2HP, Windows Vista, Sony Memory Stick Reader

problem No drive

solution

  1. Get Windows XP Preinstalled drivers from Sony
  2. Extract MemoryStick\1.0.2.0.zip
  3. Go to device manager and select Update driver and navigate to the extracted files from 1.0.2.0.zip