Thursday, October 18, 2012

How is political correctness affecting birth rate? Do corporations by imposing against flirt none harassment rules has a side affect of reduced birth rate? just curious if it is possible to measure.

Sunday, June 19, 2011

C++ final function solution

Simple explanation:

class FinalMethod1 { //all methods private
friend class ClassWithFinalMethod; 
// friend ClassWithFinalMethod ::theFinalMethod(); //this method also works but is not as portable.
FinalMethod1(){}
 FinalMethod1(const FinalMethod1& );
 FinalMethod1& operator=(const FinalMethod1& );
};

struct Base { //only ClassWithFinalMethod can override this one.
 virtual FinalMethod1 theFinalMethod ()=0;
};

struct ClassWithFinalMethod : public Base
{
 virtual FinalMethod1 theFinalMethod () { return FinalMethod (); }
};

More comprehensive one with Boost that allow to generate N number of classes that will implement final function:

#include <boost/preprocessor/repetition.hpp>
//specify desired number of classes will be used by default.
#ifndef NUMBER_OF_SLOTS
#  define NUMBER_OF_SLOTS 4
#endif
#if NUMBER_OF_SLOTS<1
#  define NUMBER_OF_SLOTS 1
#endif

//if
//#include <boost/mpl/identity.hpp>
// is included.
#ifndef BOOST_MPL_IDENTITY_HPP_INCLUDED
struct nothing {
      typedef nothing type;
};
#define ADD_FRIEND(z,n,name) friend class name##n::type;
#else
//identity will provide type where needed.
struct nothing {};
#define ADD_FRIEND(z,n,name) friend class boost::mpl::identity<name##n>::type;
#end

//generic class that return some return value.
//May need specialization for & and * implementation.
template< typename ReturnType, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(NUMBER_OF_SLOTS, typename T, nothing) > class final
 {
 BOOST_PP_REPEAT( NUMBER_OF_SLOTS, ADD_FRIEND, T )
 ReturnType _result;
 final( ReturnType result ): _result(result) {}
 final( const final& );
public:
 inline operator ReturnType() { return _result; }
};

//specialization for void return value.
template< BOOST_PP_ENUM_PARAMS(NUMBER_OF_SLOTS,typename T) > class final <void, BOOST_PP_ENUM_PARAMS(NUMBER_OF_SLOTS,T) >
{
 BOOST_PP_REPEAT(NUMBER_OF_SLOTS,ADD_FRIEND,T)
 final( ) {}
 final( const final& ){}
};

Friday, April 1, 2011

Lady Gaga meat headphones.

Her headphone model line has got new item with new earpads made of meat.

Friday, March 25, 2011

web entry forms, or be careful what you teach.

There is a lot of pages where you asked to provide credit card, SS or phone number. A lot of them requires to type data in specific format: no space, with space, numbers only etc. There is not much coding needed on the page to accept any format and parse out needed info. Some companies like Google do so. Why the other still asking for specific format? IMHO The reason is kind silly. Various validation code is posted as an example in the programming books. Programmers do what they were told to do: Validate to the hell (means to specific format). Annoying thing spread the world. Be careful what you give as example, it can spread the world.

Wednesday, March 23, 2011

to big to fail banks.

Here is a joke, one guy decided if government could not solve to big to fail banks, he will solve himself. He moved his account out of big to small regional bank. Hope was that big bank become eventually small. 8 months late original big bank bought small regional bank. He end-up exactly where started.

Monday, March 14, 2011

Daylight savings time

When we switch to daylight saving time we suppose to save some energy. But WHY do we switch back?
That is pure tradition. There is no enough light in winter to cover all day so why bother switch back?
Time of a day is pure human defined.
Lets stick with daylight time forever, and some other countries do!

Friday, March 11, 2011

restrict access to financial accounts for tax software.

Financial institutions should create a secondary login (username/password) for tax preparation only. It is kind a security brake to provide you full login to the turbo tax. How much do you trust them? Or you change  password after it?