The ‘Wrong’ Email

There are a lot of posts and discussions around on what gets classified as a good email and what doesn’t. Well i don’t really recall any of that. But over the last 10 years i have learned a few things about writing a email the ‘correct’ way.

Here are a few of those things that i try and make sure goes into each email that i write.

KISS. (don’t know KISS, look it up)

Just by typing an email in English is not enough. The mail should convey the message the first time a person reads it. Just by vomiting some ‘cool’ terms into the mail doesn’t make it any better. If the recipient has to read the mail thrice and more to understand, it is the problem of the sender. What’s wrong in sending an easy to understand email? No one will look down up on you like you committed blasphemy. Email is a means of communication so keep it simple.

The other day, i was assigned some new work and i had to mail the concerned person about the finer details and tasks. The mail that i received proved to be tougher than the work that was assigned. Read the mail twice in the morning, took a coffee break, read it again twice and by noon it started to make sense. That was half a day’s of productive time spent reading one single mail.

Here’s the rule i follow – If you can’t really explain something in simple terms, then you have no idea what you’re trying to do and have no real understanding about it. Period!

If it is more than two pages long, schedule a meeting.

This follows from the previous point. Even after you have made the mail simple and easy to understand, if it runs for more than two pages, then it is better to schedule a meeting with specific agenda. No matter how simple the mail might be, the recipient would be far away from the message by the time they reach the bottom of the mail. Now they have to start all over again. Then there will be follow up queries and clarifications and the cycle will go on.

Wouldn’t it be simpler to mail someone with the highlights and then schedule an informal meeting instead. A 10 minute meeting, even over the phone, is better than 2 days of emails flying around. Well, if it is something that has been documented, send them the link for god sake! No one cares about your explanation.

If you have to spent more than 10 minutes on an email, you’re definitely doing it wrong.

Even after following the last 2 steps, if you are still going to spend more than 10 minutes to compose an email, then obviously you’re doing it wrong. But, how the hell can you get it wrong? After all it is just an email.

If you can’t narrow down on what you want to communicate, then obviously you are going to have a lot of information (in simple sentences) and would end up confusing yourself. Here’s the thing, apart from mailing someone who is important (like your boss or CEO), if you find yourself asking, “does this mail serve the purpose?” or “is this correct?” then chances are that you have got it wrong somewhere.

So the next time you have to send an email to someone, just think for a moment what you want to convey and concentrate on that single message.

U shud not do tis.

It’s not like we are charged per character for an email. The situation is not even such that and extra character or two is going to choke the network. So please stop using all the lingo you picked up by posing as a girl in a public chat room. I can understand using this while text-ing someone. But even that is lame after some time.

There are some acceptable acronyms that you can use in an email. Like the name of the a product, user pointers like F.Y.I., descriptors like FUBAR etc. But a like that goes, ‘I thot v shud meet 4 cofe’, is simply lame. Even the argument that you were in a hurry doesn’t sell here. How hard was it to lift the damn finger and punch in two more letters?

——

Feel free to share your thoughts and experience.

Screen-Rotation Lock on iOS 4

After the iOS4 update for my iPad, i noticed that the screen-rotation lock button has changed to the mute button. If you are not aware of what i’m talking about, it’s the one right next to the volume control button on your iPad. It turns out that, the button was originally designed for ‘Mute’, but later changed to ‘screen-rotation’ lock and now they reverted it to ‘mute’.

I needed the rotation lock more than mute as i do most of my reading on iPad using GoodReader, Flipboard etc. . A bit of ‘googling’ showed me the way. Here it is -

1. Double-click the “Home” button to bring up the application switcher. (iOS4 supports multi taking, if you didn’t know)

Picture

2. Slide it to the right.

Picture-2

3. There you go, the rotation lock button is right there.

Picture-3

Enjoy… :)

Using DataPower XSLT extension to add custom Headers

N.B. this tutorial assumes the reader has some knowledge of DataPower.

IBM WebSphere DataPower SOA Appliances provides, apart from the XSLT1.0 extension functions, a wide range of DataPower specific XSLT extensions functions. Anyone who has got their hands dirty trying to do DataPower programming using XSLT knows that there are many ways to solve a problem.

In this post i will explain how to add a custom header to a request/response. More specifically i will add a custom response header to an HTTP request. If you have gone through the DataPower Extension Elements and Functions Catalog knows that there are 2 options available -

  1. set-http-request-header and set-http-response-header
  2. set-request-header and set-response-header

The later being for both HTTP and MQ.

I will be using the set-response-header in this example. This is particularly useful when dealing with web-services.

We will consider the following scenario –

  1. User makes a simple HTTP POST to a DataPower HTTP FSPH
  2. The backend of the DataPower config echoes the POST message
  3. On the response rule we add a custom header

This way we can verify the header getting added without having to enable the debug logs or probe on the appliance.

The policy looks like the one below.

addHeader

Under the Server to Client rule, which is our response rule, I have added a Transform action. The style sheet with in the Transform action just adds a custom header to the response rule. This is the XSLT that I used

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dp="http://www.datapower.com/extensions"
                extension-element-prefixes="dp"
                exclude-result-prefixes="dp">        
<xsl:template match="/">
<xsl:variable name="s" select="dp:variable('var://service/routing-url')" />
<dp:set-http-response-header name="'SomeRandomlyAddedHeader'" value="$s"/>
</xsl:template>
</xsl:stylesheet>

We are adding an additional header “’SomeRandomlyAddedHeader”. When we place the POST request to the DataPower service we get the headers as shown below –

addHeaderRequest

“Hello World” in 10 Languages

How to print “Hello World!” in 10 Languages (compiled, interpreted and markup included).

1. C

#include<stdio.h>
int main ()
{
printf(“Hello World!\n”);
return 0;
}

2. Java

class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello World!”);
}
}

3. (Bash) Shell Script

#!/bin/bash

echo “Hello world!”

4. Perl

#!/usr/bin/perl

print “Hello World!”;

5. Python

Python 2.0

#!/usr/local/bin/python

print “Hello World!”

Python 3.0

#!/usr/local/bin/python

print(“Hello World!”)

6. Tcl

puts “Hello World!”

7. HTML

<html>
<head>
<title>Hello World</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>

8. JavaScript

<html>
<head>
<title>Hello World</title>
<script type=”text/javascript”>
document.write(“Hello World!”);
</script>
</head>
<body>
</body>
</html>

9. PHP

<?php
echo “Hello World!”;
?>

10. XSLT

<?xml version=”1.0″ encoding=”UTF-8″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>
<xsl:template match=”/”>
Hello World
</xsl:template>
</xsl:stylesheet>

How to : Conditional Processing using DataPower Multistep Policy

N.B. this tutorial assumes the reader has some knowledge of DataPower. for configuration files scroll to the end

In the previous post, i explained how to do a simple parameter passing within a multistep rule of DataPower. In this post i will be taking you through the Conditional Action of the multistep rule. The usage of the conditional rule will be more clear by using a sample scenario.

We will build on the previous addition example. Just that this time we need to do all the four operation – addition, subtraction, multiplication and deletion. The request XML that was used has been changed to -

<?xml version=”1.0″ encoding=”UTF-8″?>
<data>
<operation>multiply</operation>
<number1>200</number1>
<number2>10</number2>
</data>

The idea here is to read the value of <operation/>, and do the corresponding action on <number1/> and <number2/>. The result-xml will be send back to the client as -

<result>2000</result>

Click on the image to see how the rule will be configured.

A Multi-Protocol Gateway will be used here. The following properties of the MPGW remains the same from the previous example -

1. HTTP Front Side Protocol Handler
2. Static-backend with an HTTP Service configured on the appliance itself with the mode set as ‘echo’
3. Request Type and Response Type will be XML

Leave the rest of the fields at its default values.

Configuring the Multi-Protocol Gateway Policy with Conditional Client to Server Rule

This rule is the same as with the previous example with one small difference. Right after the Match Action we introduce a Conditional Action. Using this Conditional Action we will do something like a switch-case flow control. Using XPath expressions we will check what is the value of <operation> is and then accordigly set a variable var://context/condition/operation. If the value doesnt match – add, subtract, multiply or divide – then we set it as ‘error‘.

1. Drag an Advanced Action to the line

2. Double-click to edit the action and select Conditional Action. Click Next

3. For Match Condition, using the XPath Tool, format the XPath expression to retrieve the value of the <operation> and match it to ‘add’ – /data/operation[normalize-space(.) = 'add']

4. For Action, select Set Variable and click Create Action

5. In the window that opens enter the Variable Name as ‘context/condition/operation’. The variable that we created now becomes var://context/condition/operation. For Variable Assignment enter the value as add.

6. Leave the rest of the fields at its default values itself. Click Done.

Repeat the steps for subtract, multiply and divide. The last Match Condition should be *, this acts like the ‘otherwise’ condition of a switch-case statement. If we are not able to match any of the four operations then set the variable as ‘error’

Once the Conditional Action has been done, proceed to create two Transform Actions just like the previous example and proceed in a similar fashion.

For the last transform action instead of the add.xsl we set a new stylesheet. This stylesheet will read the value of “var://context/condition/operation” and then do the appropriate action on number1 and number2.

<xsl:template match=”/”>
<xsl:variable name=”operation” select=”dp:variable(‘var://context/condition/operation’)“/>
<xsl:variable name=”num1″ select=”dp:variable(‘var://context/number_1′)“/>
<xsl:variable name=”num2″ select=”dp:variable(‘var://context/number_2′)“/>
<xsl:choose>
<xsl:when test=”$operation = ‘add’”>
<xsl:variable name=”result” select=”$num1 + $num2″/>
<result><xsl:copy-of select=”$result”/></result>
</xsl:when>
<xsl:when test=”$operation = ‘subtract’”>
<xsl:variable name=”result” select=”$num1 – $num2″/>
<result><xsl:copy-of select=”$result”/></result>
</xsl:when>
<xsl:when test=”$operation = ‘multiply’”>
<xsl:variable name=”result” select=”$num1 * $num2″/>
<result><xsl:copy-of select=”$result”/></result>
</xsl:when>
<xsl:when test=”$operation = ‘divide’”>
<xsl:variable name=”result” select=”$num1 / $num2″/>
<result><xsl:copy-of select=”$result”/></result>
</xsl:when>
<xsl:otherwise>
<result>ERROR! Operation not found</result>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Set the policy for the Multi-Protocol Gateway as the one that we created above. Appy and Save.

Post the request xml to the HTTP Front Side Listener. Vary the value of <operation> as given below and verify the results.

<operation>add</operation>
<operation>subtract</operation>
<operation>multiply</operation>
<operation>divide</operation>