Tuesday, November 23, 2010

Force a compiler Failure

#define COMPILE_TIME_ASSERT(expr) \
typedef char compile_time_constraint[(expr)? 1:-1]

Wednesday, October 27, 2010

COMPARE

CMP Carry/Overflow

Private Virtual Functions

#include
using namespace std;

class A
{
virtual void print1() { cout "1 Aprivate" endl; }
public:
virtual void print2() { cout "2 Apublic" endl; }

class B : public A
{
virtual void print2() { cout << "2 Bprivate" endl; }
public:
virtual void print1() {cout << "1 Bpublic" endl; }

int main(int argv, char* argc[])
{
A a;
B b;
a.print2();
b.print1();
A* ab = &b;
ab->print2();
return 0;
}

outputs...

2 Apublic
1 Bpublic
2 Bprivate

Friday, August 6, 2010

Trigger Content

Sql Server:
SELECT TR.NAME, COM.*
FROM SYS.TRIGGERS TR, SYSCOMMENTS COM
WHERE TR.OBJECT_ID = COM.ID
AND TR.NAME='triggerhere'

Oracle:
SELECT *
FROM all_constraints
WHERE table_name='NAME_OF_YOUR_TABLE'
AND constraint_type='C';

Sunday, March 28, 2010

Synclock

"A SyncLock block behaves like a Try...Finally construction in which the Try block acquires an exclusive lock on lockobject and the Finally block releases it. Because of this, the SyncLock block guarantees release of the lock, no matter how you exit the block. This is true even in the case of an unhandled exception." - MSDN
Public Sub Foo()
Dim sText As String
Dim objLock As Object = New Object()
Try
Monitor.Enter(objLock)
Try
sText = "Hello"
Finally
Monitor.Exit(objLock)
End Try
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub
- DeveloperFusion

Friday, March 26, 2010

C: Compiling GNU Projects on Windows

I wanted to port the programs I commonly use on Linux to Windows. In particular I have been working on wdiff. A program that compares the differences word by word of two files.

Currently I have been able to successfully compile the program on windows through Cygwin. I also was able to reproduce it on my colleges Redhat server.

The steps I took were:

wget http://ftp.gnu.org/gnu/wdiff/
tar -xzvf wdiff-0.5.tar.gz
cd wdiff-0.5
./configre
make (install) wdiff

However, I would like to run the program natively on Windows similar to the Project: UnixUtils.

I am currently working on a custom port due to the fact that I cannot run ./configure to establish a make file. Suggestions would be greatly appreciated.

Sunday, January 31, 2010

Python vs Perl

EXTERIOR: DAGOBAH -- DAY
With Yoda strapped to his back, Luke climbs up one of
the many thick vines that grow in the swamp until he
reaches the Dagobah statistics lab. Panting heavily, he
continues his exercises -- grepping, installing new
packages, logging in as root, and writing replacements for
two-year-old shell scripts in Python.

YODA: Code! Yes. A programmer's strength flows from code
maintainability. But beware of Perl. Terse syntax... more
than one way to do it... default variables. The dark side
of code maintainability are they. Easily they flow, quick
to join you when code you write. If once you start down the
dark path, forever will it dominate your destiny, consume
you it will.

LUKE: Is Perl better than Python?

YODA: No... no... no. Quicker, easier, more seductive.

LUKE: But how will I know why Python is better than Perl?

YODA: You will know. When your code you try to read six months
from now.

Taken from: Python Humor

Thursday, January 21, 2010