Tuesday, February 27, 2007

8th Annual CERIAS Symposium

The dates for the $subject getting closer. If you're somewhere close to Indiana and want to see current and future trends of information security, you should consider attending this.

Link: http://www.cerias.purdue.edu/symposium/2007/

Monday, February 26, 2007

Post Removed

Sometime back, I posted a lengthy note on diabetes and some pointers to the sources from where I got the information in the hope that it'll help those suffering from diabetes. One reader, called Ahamed Nadeem (I don't know who he is) pointed out that some information and sources are incorrect. I double checked the validity of the sources and found that he was indeed correct. I removed that post from the blog. I should be very careful in writing about sensitive things like health. Many thanks to Nadeem.

First Formalization of NP-completeness

While I was looking at the subset-sum-problem (in cryptography, we call it knapsack), I came across the original paper (The Complexity of Theorem Proving Procedures) submitted to 1971 ACM Symposium on Theory of Computing by Stephen Cook who formalized the notion of NP-completeness in this paper. The paper left unsolved the greatest open question in theoretical computer science - whether complexity classes P and NP are equivalent.

Monday, February 19, 2007

Global Warming [Earth] Challenge

Watched the media conference with Richard Branson of Virgin Group which owns Virgin Atlantic Airways and Al Gore (Former US Vice president and the person behind the documentary "An inconvenient truth") sitting next to him? It's quite interesting..Virgin Group is gonna award $25 million for an invention that removes non-trivial amounts of greenhouse gases (mainly CO2) from the atmosphere. For a convincing proposal, they'll initially award $5 million and the rest in installments provided the laid out milestones are achieved. By the way, they are also pledging billions to research into bio-fuels.

It's kinda conflict of interest..running a large airline company accounts for significant emission of greenhouse gases. However, it's better than doing nothing to compensate for the damage caused.

I'm sure this'll get many universities involved and interested.

All scientists and inventors, get working!

Sunday, February 18, 2007

SOA Forecast for 2007

Here's what ZapThink forecasts:

#1: SOA Quality and Testing Market the Next Must-Have Space
- More testing and quality tools and solutions for SOA
#2: Enterprise Architect Drought
- There simply won’t be enough qualified and SOA experienced enterprise architects (EA) around
#3: The SOA Suite Busts a Few Buttons… Open Source the Remedy?
- SOA suites might get a bit too big (Vendors of a service or a product have a self-interest in promoting the need for products that probably won’t keep you away from their sales department for long)
-Leveraging the open source SOA realizations such as Apache Axis2 (java/c)

Read the full post.

Sanjiva's views on WS-* and REST

Sanjiva Weerawarana was recently interviewed by InfoQ. Here's his opinion on the subject.

Valentine's Day Reminder for Secret of Success


(Courtesy: Creating Passionate Users)

Read Kathy's valentine's day message :)

Monday, February 12, 2007

Web Services Performance, design considerations and ease of use

Employees at WSO2 published performance results of Axis2 vs. XFire along with the source code code used and the performance testing methodology. The Bileblogger criticized this with racial comments which I don't want to elaborate on here. This led to a series of nasty exchange of words. Shortly after this, Sun's JAX-WS benchmarked against Axis2. All this led to some constructive feedback and the question of usefulness and relevance of these benchmarks. Steve Laughran argues that one cannot realistically infer any result from these performance numbers. Anil John points out that these performance tests are not in par with the design considerations of web services. There's a point in what Anil says. Web services should simply be xml-in and xml-out in order to encourage interoperability and take advantage of powerful xml representation. Axis2 has in fact designed for the xml-in/xml-out model. This comes at the cost of ease of use, which is why data binding frameworks such ADB, JAXB, JiBX, etc have been introduced. We need to strike a balance between performance and ease-of-use. We need to come up with benchmarks that go well with design considerations (such as message based programming over RPC style, asynchronous web services, large data transfer, etc).

Sunday, February 4, 2007

Social Media

Enterprise 1.0 vs. Enterprise 2.0

From The Software Abstractions Blog..
What exactly is "Enterprise 2.0"? The main themes that are emerging, seem to be products/technologies that:
  1. facilitate better communication
  2. harness collective intelligence and innovation
  3. enable user-generated applications (enterprise mashups !)
The communication aspects present the most powerful paradigm-shift.





(Courtesy: Software Abstractions blog)

Source: click here

59 years ago on a day like today

In 1948, on a day like today, with the participation of representatives from many countries, the Lion flag was hoisted high in the blue skies proudly marking the symbolic gesture of independence.

The Lion Flag:


More Details:
About Sri Lanka
About Sri Lankan history

Saturday, February 3, 2007

5 Ways to spot a liar!

Little white lies of all sorts are tossed our way daily. These may not matter a whole lot, but real whoppers do. Sometime back, I read an article on RD regarding how to spot a liar. I know I am not very good at spotting those. Here are the five tips from experts from that article :)

1. Hear the Voices
- Voice (pitch) changes may well indicate deceit.
- And so does change in speech rate, breathing pattern, etc.

2. Watch Those Words
- how do we spot lies in written material, letters, resumes, etc. ??
- Believe it or not, people have developed software to spot deception in written content. One example is LIWC (Linguistic Inquiry and Word Count) by some people at the University of Texas.
- Some tips.
-- liars tend to use fewer first person pronouns
-- liars tend to use fewer exclusionary words - but, nor, except, whereas (they have trouble with complex thinking)

3. Look Past Shifty Eyes
- If people look away while answering something that should be easy to answer, that may be an indication (this may not be always true)...watch out for eye gaze

4. Bet Better at Body Language
-Observe the total person and compare it with his/her usual body language
--ex: a quiet person who talks a lot or a person who talks a lot who is now quiet

5. Check for Emotional "Leaks"
-The micro-expressions that flit across people's faces often expose what they're truly feeling or thinking as opposed to what they'd like us to believe. It isn't the frequency of a smile that matters, but the type of smile!

Professionals trained in the art of lie detection use all these techniques.

Can you spot a liar? Take the quiz!

Friday, February 2, 2007

Introduction to C++ Programming [Part 4]

Previous Related Posts: Part1 Part2 Part3

Operators

An operator is a symbol that causes the compiler to take an action. Operators act on one or more operands. There are several types of operators.

· Arithmetic operators

· Assignment operators

· Relational operators

· Logical operators

Arithmetic operators

Operator

Description

Example

+

Addition

3 + 20 evaluates to 23

-

Subscription

10 – 4 evaluates to 6

*

Multiplication

2 * 13 evaluates to 26

/

Division

15 / 2 evaluates to 7

%

Modulus

17 % 3 evaluates to 2

++

Increment

i++ is equivalent to i = i + 1

--

decrement

i-- is equivalent to i = i - 1

++ and -- are unary operators, meaning that they operate on a single operand. Each of these operators has two versions, post and pre. Let’s try to understand this by the following example.

e.g.:

//post increment
x = 10;
y = 20;
z = (x++) + y; //z evaluates to 30
a = x + y; // a evaluates to 31

//pre increment
x = 10;
y = 20;
z = (++x) + y; //z evaluates to 31
a = x + y; // a evaluates to 31

Operator precedence

Precedence is the order in which a program performs the operations in a formula. Each operator has a precedence value. These precedence values are used to evaluate expressions. If one operator has precedence over another operator, it is evaluated first. The following table shows the operator precedence in the decreasing order.


( )

Prefix ++ --

* / %

+ -

< <= > >=

== !=

||

&&


e.g.:

z = 2 + 5 * 3; //17
z = (2 + 5) * 3; //21

Assignment operators

Operator

Example

=

a = 5;

*=

a *= 5; //equivalent to a = a * 5;

+=

a += 5; //equivalent to a = a + 5;

-=

a -= 5; //equivalent to a = a - 5;

/=

a /= 5; //equivalent to a = a / 5;

%=

a %= 5; //equivalent to a = a % 5;

Relational operators

Operator

Description

==

Equal to

<=

Less than or equal to

>=

Greater than or equal to

<

Less than

>

Greater than

!=

Not equal to

Logical operators

Operator

Equivalent to

Example

&&

AND

(x > 5 ) && (x <>

||

OR

(x <> 25) //x is less than 5 or greater than 25

!

NOT

!(x > 5) //equivalent to (x <= 5)


Escape Characters

The C++ compiler recognizes some special characters for formatting. The following table shows the most common ones. You put these into your code by typing the backslash (called the escape character), followed by the character.

Character

Description

\n

new line

\t

tab

\b

backspace

\"

double quote

\'

single quote

\?

question mark

\\

backslash

\a

alert

e.g.:

cout << “This is a test. \n”;
cout << “Now alarm \a will ring\n.”;

Control Structures

If Statement

If statement is used to execute a certain set of statements based on an expression. There are several forms of if statement. Most commonly used forms are listed below. You don’t need to use braces if there is only one statement.

if (expression)
{
//statements
}

if (expression)
{
//statements
}
else
{
//statements
}

if (expression)
{
//statements

}
else if (expression2)
{
//statements

}

e.g.:

if (x != 0)
{
cout <<”x is not equal to zero\n”;
}
else
{
cout <<”x is equal to zero\n”;
}

Conditional (Ternary) operator:

The conditional operator (?:) is C++'s only ternary operator; that is, it is the only operator to take three terms. The conditional operator takes three expressions and returns a value.

Syntax:

(expression1) ? (expression2) : (expression3)

This line is read as "If expression1 is true, return the value of expression2; otherwise, return the value of expression3." Typically, this value would be assigned to a variable.

e.g.:

int x = 5;
int y = 10;
int z = (x > y) ? y : x; //since x > y is false, value of x is assigned to z.

While loop

A condition is tested, and if it is true, the body of the while loop is executed. When the conditional statement fails, the entire body of the while loop is skipped. It is possible that the body of a while loop will never execute. The while statement checks its condition before executing any of its statements, and if the condition evaluates false, the entire body of the while loop is skipped.

Syntax:

while (condition)
{
//statements
}

e.g.:

int iCount = 0;
while (iCount < 2)
{
cout << “Count is “ << iCount <<"\n";

iCount++;
}

Output:

Count is 0
Count is 1
continue
and break statements:

Usually break statement is used to break out of any loop based on a certain condition and continue statement is used to skip the current iteration based on a certain condition.

e.g1. (break):

int iCount = 0;
while (iCount < 2)
{
cout << “Count is “ << iCount <<"\n";
if ( iCount == 0)
{
cout <<”Breaking out of the loop\n”;
break;
}
iCount++;
}

Output:

Count is 0
Breaking out of the loop

e.g2. (continue):

int iCount = 0;
while (iCount < 3)
{
cout << “Count is “ << iCount <<"\n";
iCount++;
if ( iCount == 1)
{
cout <<”Continue with next loop\n”;
continue;
}

cout << ”Next count is “ <<iCount << "\n";

}

Output:

Count is 0

Continue with next loop
Count is 1
Next count is 2
Count is 2
Next count is 3

Do-While Loop

The do-while loop executes the body of the loop before its condition is tested and ensures that the body always executes at least once.

Syntax:

do
{
//statements
}
while (condition);

e.g.:

int iCount = 0;
do
{
cout << “Count is “ << iCount << "\n";

iCount--;
}
while (iCount > 0);

Output:

Count is 0

for Loop

You'll often find yourself setting up a starting condition, testing to see if the condition is true, and incrementing or otherwise changing a variable each time through the loop. In such situations, for loops are more convenient way to iterate. A for loop combines the three steps into one statement. The three steps are initialization, test, and increment.

Syntax:

for (initialization; test; increment/decrement)

{

//statements

}

e.g.:

for (int iCount = 0; iCount < 2; iCount++)

{

cout << “Count is “ << iCount <<"\n";

}


Output:
Count is 0
Count is 1

switch Statement

switch statement is a more convenient way of branching than if statement, when you want to branch to a set of statements based on several possible values.

Syntax:

switch (expression)
{
case value1:
//
statements
break;
case value2:
//statements
break;

default:
//statements
}


Expression is any legal C++ expression. If one of the case values matches the expression, execution jumps to those statements and continues to the end of the switch block, unless a break statement is encountered. If nothing matches, execution branches to the optional default statement. It is important to note that if there is no break statement at the end of a case statement, execution will fall through to the next case statement. This is sometimes necessary, but usually is an error.

e.g.:

int iScore; //assume iScore is assigned a value through cin

cout << “Score is “ << endl;

switch (iScore)

{

case 5:

cout << “Performance is average” << endl;

break;

case 10:

cout << “Performance is good” << endl;

break;

default:

cout << “Invalid Score” < < endl;

}

Thursday, February 1, 2007

A simple way to download videos from sites like YouTube

There's a really simple way to download videos from sites like YouTube. This's what you need to do:
1. Copy the URL that appear in the address bar and paste it here.
2. Rename the file to have .flv extension.
3. View it in a flash video viewer[Example: FLV Player 1.3]!

All time favorites..

All time favorites at Piled Higher and Deeper .. :)

Motivation graph
Work output graph

Function Pointers and Functors in C++ [in 5 minutes]

Function pointers are very useful technique to provide late binding, to prevent switching and to implement callbacks in C/C++. Here are some example cases of C/C++ function pointers and C++ functors which can be used to eliminate switches inside your code. (Remember the design principle? The code should be closed to modification but open to extension!)

Here's the C style of doing it:


#include <stdio.h>

/* calculate2, calcualte2, etc are functions
with the same prototype */
int calculate1(int val)
{
return val*val;
}

int calculate2(int val)
{
return val+val;
}

/* passing a function pointer */
int useCalculate(int (*fnPtr)(int), int someVal)
{
return fnPtr(someVal);
}

/* using the function which takes a function pointer */
int main()
{
printf("Using calculate1 = %d\n",
useCalculate(calculate1, 10));
printf("Using calculate2 = %d\n",
useCalculate(calculate2, 10));
return 0;
}


Here's the C++ style of doing it (with method pointers):

#include <iostream>

using namespace std;

//calcualte1, calculate2 are methods with the same prototype
class Util
{
public:
int calculate1(int val)
{
return val*val;
}
int calculate2(int val)
{
return val+val;
}
};

//the above prototype is taken as a formal argument here
class UseUtil
{
Util utilObj;

public:
int useCalculate(int (Util::*methodPtr)(int), int someVal)
{
return (utilObj.*methodPtr)(someVal);
}

};

//using the method with method pointer argument
int main()
{
UseUtil useUtilObj;
cout << "Using Calculate1 = " <<
useUtilObj.useCalculate(&Util::calculate1, 10) << "\n";
cout << "Using Calculate2 = " <<
useUtilObj.useCalculate(&Util::calculate2, 10) << "\n";
return 0;
}


Here's the C++ style of doing it again (but with functors!):

#include <iostream>
using namespace std;

//it takes a "stateless functor class"
template
class UseUtil
{
public:
int useCalculate(UtilFunctor calculate, int someVal)
{
return calculate.operator()(someVal);
}

};

//out of line way
//int UseUtil::useCalculate(
// UtilFunctor calculate, int someVal)
//{
// return calculate(someVal);
//}

//first functor class
class Cal1
{
public:
int operator()(int val)
{
return val*val;
};
};

//second functor class
class Cal2
{
public:
int operator()(int val)
{
return val+val;
}
};

int main()
{
UseUtil useUtilObj1;
Cal1 calObj1;
cout << "Using Cal1 = " <<
useUtilObj1.useCalculate(calObj1, 10) << "\n";
UseUtil useUtilObj2;
Cal2 calObj2;
cout << "Using Cal2 = " <<
useUtilObj2.useCalculate(calObj2, 10) << "\n";
return 0;
}