Skip to main content

Posts

The Oilman and his Parrot.

STORY II.  The Oilman and his Parrot.  An oilman possessed a parrot which used to amuse him with its agreeable prattle, and to watch his shop when he went out. One day, when the parrot was alone in the shop, a cat upset one of the oil-jars. When the oilman returned home he thought that the parrot had done this mischief, and in his anger he smote the parrot such a blow on the head as made all its feathers drop off, and so stunned it that it lost the power of speech for several days. But one day the parrot saw a bald-headed man passing the shop, and recovering its speech, it cried out, "Pray, whose oil-jar did you upset?" The passers-by smiled at the parrot's mistake in confounding baldness caused by age with the loss of its own feathers due to a blow. Rumi, Maulana Jalalu-'d-din Muhammad (2011-05-16). The Masnavi I Manavi of Rumi Complete 6 Books (Kindle Locations 107-112). OrangeSky Project. Kindle Edition.   

Junit 4.11 cheatsheet

Assertion - org.junit.Assert Equals, NotEquals, True, False, Null, NotNull - Arrays, Object & Strings Test Aggregation import org.junit.runner.RunWith ; import org.junit.runners.Suite ; @RunWith ( Suite . class ) @Suite.SuiteClasses ({ TestFeatureLogin . class , TestFeatureLogout . class , TestFeatureNavigate . class , TestFeatureUpdate . class }) public class FeatureTestSuite { // the class remains empty, // used only as a holder for the above annotations } Exception Testing @Test ( expected = IndexOutOfBoundsException . class ) public void empty () { new ArrayList < Object >(). get ( 0 ); } @Rule public ExpectedException thrown = ExpectedException.none(); @Test public void shouldTestExceptionMessage() throws IndexOutOfBoundsException { List list = new ArrayList (); thrown.expect(IndexOutOfBoundsException.class); thrown.expectMessage("Index: 0, Size:...

Cricbay DRR calculation technique made easy

Seaon is coming to an end and everyone is closely watching team DRR and here is an simple method of predicting match DRR. 10  is the magic number to get 0.50 DRR. Bat first win by 10 runs and your DRR will be 0.50. likewise 20 runs diff will give 1.00 DRR etc Bat second You need the below formula to calcuate balls required to get 0.50 DRR. (runs/runs+10) * 120) i.e. chasing 60 runs you will need ==> 60/70 * 120 ==> 103 balls to get 0.50 DRR chasing 80 you will do ==> 80/90 * 120 ==> 108 balls to get 0.50 DRR Note: if you are still wondering how to calculate loosing DRR just remember DRR lost by one team is gain by others i.e. just put a minus infront of winners DRR. Note: All the calculations are rounded to nearest decimal. --- Wondering how I got to the nos --- Bat first DRR formula ==> (Runs scored/Ball faced - Runs gave/Balls bolwed) * 6 If you bat first and win that way you and your oppoent will end up playing 12...

Takeaway from The Leadership of Muhammad (SAW) by John Adair

Key Points l A leader should exemplify or personify the qualities expected, required and admired in their working groups. A leader of soldiers, for example, needs to demonstrate courage, ‘the soldier’s virtue’, as  Shakespeare called it. l Courage is a quality shown by Muhammad at Hunayn: it is that which enables people to meet  danger without giving way to fear, to act bravely  under stress or to endure in times of adversity. l All members of working groups, organizations or communities – at all times in known history – share one thing in common: they are all persons with a  common and constant human nature. l A universal leader, then, will be a person who exemplifes such distinctively human qualities as goodness, kindness, humaneness and compassion. Did  you see any of these qualities in Muhammad? l Another generic quality of universal leaders is l All members of working groups, organizations or communities – at all times in known history – share one thing...

Review: The ABCs of Money by Natalie Pace

Key points - How to pay off credit cards (big-ticket expenses - housing, transportation and insurance) Every expert is a seller Thrive Budget (21-day vocation, dream bigger and 50% to survive vs 50% to Thrive!) Shopping for success (comfortable house in a good neighborhood at  affordable price and hard assets 401k, IRA) Grade your Guru (education to increase your skills, avoid free lunch seminars, trust results! not big job, titles an Ivy League degree, slick sales pitch) New Chips are safer than Blue Chips Hard Assets (solar panels, gold bubble)
Repeated characters when typing in remote console Details When typing into a remote console, you see unintended repeated keystrokes. Solution If you are using a wide-area or low-bandwidth connection, the time delay over the network may be long enough to cause the virtual machine to start auto-repeat. To reduce these effects, increase the time threshold necessary for auto-repeat in the remote console. Power off the virtual machine. Add a line, similar to this, at the end of your virtual machine's configuration (.vmx) file: keyboard.typematicMinDelay = "2000000" The delay is specified in micro-seconds, so the line in the example above increases the repeat time to 2 seconds. This should ensure that you never get auto-repeat unless you intend it. Power on the virtual machine. To make the changes using the vSphere Client: Power off the virtual machine Right click virtual machine select  Edit Settings Click  Options  >  General   >...

Different ways to use enum's in java

Technique:  Simple enum and retrieve/reverse lookup using valueOf() public class OrderService {     // Note : enums can be defined in its own file or inside a class if they are only relevant with it.     public enum Status { PROCESSING, SHIPPED, COMPLETED; }     public void update(long orderId, Status status) {          // something     } } // import static OrderService.Status; // import static OrderService.Status.* ; // OrderService service = new OrderService(); // service.update(100L, SHIPPED); // use enum // Status status = Status.valueOf("SHIPPED"); // reverse lookup by constant, throws IllegalArgumentException if no match. // System.out.println ( status.toString() ); // prints value - SHIPPED Technique:  Stores enum constant and value in a map, retrieve/reverse lookup using fromValue() public enum Status {         PROCESSING("processing"), SHIPPED("shippin...