Friday, January 25, 2013

Sending Email via the UNIX Bash Shell


You would need to have sendmail and mailx packages installed.

With these, you can issue the following command to send an email via the shell:

$ echo "test" | mailx -a ./file.txt -s "subject2" abc@email.com

The above command pipes the string "test" to the mailx command which constructs an email for abc@email.com with the subject, "subject2" and an attachment, "file.txt".
Alternatively, you can enter interactive mode with the mailx command:

$ mailx -a ./file.txt -s "subject2" abc@email.com

The shell then lets you type in your message. To exit the interactive mode, you just enter a new line and type in '.'.

If sending a binary file, it's always best to encode it first:

$ uuencode file.bin file.bin | mailx -s "subject2" abc@email.com


Wednesday, January 23, 2013

Much Ado About Anothing


The PH internet was abuzz recently with news of Ricky Lo's interview with a seemingly disinterested Anne Hathaway. For starters, I don't really care what the interview was about and why it turned out to be that way. But this morning, when I was bringing up PhilStar on my office browser, there and behold a link to Ricky Lo's article, "Anne of thousand hits (http://www.philstar.com/entertainment/2013/01/23/899982/anne-thousand-hits)" that my mouse just easily gravitated to it and it was just an easy click away into reading it.

There was nothing really interesting about the article as well, as Ricky seemed to just brushed off the incident as just one of his interviews with 200 other Hollywood actors (but of course, with some stinging remark that those others were "absolutely more delightful, far nicer and totally engaging"). But what was really interesting was the comments that came with it, that pointed out that Ricky misused an idiom when he wrote "to the manner" born when referring to the dainty way Julie Andrews took her tea.

To quote the comment thread:
olinsky: It's "to the MANOR born", not "manner". Your writing is as bad as your interviewing skills.

eternatalya: From phrases.org.UK: "To the manner born." Meaning: Destined to be suited to something, by virtue of birth or custom and practice. To the manner born and to the manor born ("said" to be originated by Shakespeare) are also now virtually interchangeable, as per thousands of websites that detail both phrases' word usage. But you should already know that. 

olinsky: I taught high school English, including Shakespeare, and if you had read Hamlet, you would know the original meaning of that idiom, and the distinction between "to the manner born" ("fitted by or as if by birth or rearing to a particular position, role, or status"-Merriam Webster) and "to the manor born" ("born into circumstances of wealth and privilege"-MW). The context in which Ricky used the phrase calls for "MANOR" not "manner". Perhaps you overlooked this when you Googled the phrase: http://www.word-detective.com/2011/10/to-the-manner-manor-born/ 
This is just one example of how netizens (but more specifically, Filipino netizens) who do not have anything on their name would all of a sudden build their portfolio by saying and make claims invoking some air of authority. In this case, one claims to be a petty high school English teacher, and invokes with that authority the right to be a usage cop. But in the end, it's all hubris and not to mention a fallacy (argumentum ad verecundiam).

It does not need one to have a doctorate in linguistics to know that language evolves. And especially with the coming of the Internet, any language except probably to those which are considered dead (e.g., Latin) evolves and evolves in an ever faster pace. That language is dynamic is a reality which is hard to deny.

Even the quoted link admits that in modern usage, the terms "to the manner born" and "to the manor born", although originally different in meaning, are now losing their distinction. Or more accurately, the term "to the manner born" is losing its Shakespearian nuance (as noted, from Hamlet) in favour for the nuance connoted by the more modern idiom "to the manor born." Although, to be accurate as well, the quoted article seemed to favour keeping the two idioms distinct.

But the reality is that language is defined the community of users (not what the "authority" says it is). And overwhelmingly, the Shakespearian nuance is losing the battle against the modern usage.

Or, I don't know, I have to admit, it's the first time I heard the idiom. Maybe, the idiom itself is becoming passe, with the changing financial demographics of the modern world where there are more "nouveau riche" than the traditional "ancien riche" (i.e., for the passing usage cop... old rich).

Again, to quote Shakespeare, there's just much ado about nothing. And by that I didn't mean the debate on the idiom but on the online charlatans who dress themselves with the authority of nothing just like when the emperor's invisible clothes.

Pitious.

Tuesday, January 22, 2013

Lend your money and lose your friend


This proverb has been proved time and time again. The gist of this is that: you should never loan money to friends lest you want to get in an awkward situation of trying to get back the loan and eventually putting some strain in your friendship.

I, myself, have tried to find creative exceptions around this to my own detriment. I find that I'm not a good creditor (i.e., I don't have the gall to confront people of their loans and try to get it back). Furthermore, I do not believe in "interest" on loans (both in terms of morally and also in terms of its economic foundations), so I do not charge interest (on that point, banks and creditors should not as it is usurious). And "friends" tend to gravitate toward me because of these. And those who owe me tend to abuse these "acts of kindness." And I find that loans they owed me never really get repaid.

In this sense, the proverb also has another pragmatic meaning: when you loan money to friends, you'll discover that most of them are not really your friends.

Friendship is a reciprocal relationship. As a friend-creditor, you lend money to your friends because you want to help a friend-in-need and keep the relationship. As an act of reciprocity, you expect that friend to also want to keep that relationship by keeping with the promise to repay the debt. Thus, an act of defaulting to a debt especially with a friend negatively affects the relationship.

So hard as I find it, I have resolved not to lend out to friends... for our friendships' sake.

JSFiddle


Found a cool way to experiment with web development where you can enter an experimental HTML, CSS, and Javascript and show it's output. It's called JSFiddle.

Check it out:
http://jsfiddle.net/user/dashboard/

You do not need to sign up to start experimenting. But to create "fiddles" (i.e., stored experiments), you need to sign up and get an account.

What is good about this service is that, you can import several pre-set JS libraries including jQuery (of different versions), YUI, etc.

Only thing is that you can only choose one library at a time (you cannot import several at a time). But nonetheless, it is good enough when you want to do quick experimentation especially when building on a Java web application which would otherwise require you do a lot of configuration (not to mention the overhead of startup) just to bring up a page.

Friday, January 18, 2013

Extreme Outsourcing

Incredulous was my first impression when I first read the story online. I even remarked on my Facebook page when I reposted the link that the US TV show producers of Extreme Couponing should create an off-shoot based on this incident and call it, Extreme Outsourcing. Judge for yourself: http://securityblog.verizonbusiness.com/2013/01/14/case-study-pro-active-log-review-might-be-a-good-idea/

I don't want to recapitulate since the writer made a very good narrative.

But pondering on it after sometime, one may wonder how it feels like on the other side of situation... from the outsourced developers.

Well, I've been (and may still be) on that other side. That's how I felt when I was working back home under IT BPO companies. Of course, I do not know how much my counterparts in the US or Europe actually earned. But I had my suspicions. I usually am sent out to work on-shore to our client's offices and I'm usually given a per-diem (i.e., per day stipend) by my company's client. And all I can remark is... if you keep a very low profile in the US or Europe and preserve as much of the stipend as possible, you not only save your salary back home but can bring back much more upon your return. In fact, the per-diem is as much as twice or thrice my daily rate back home.

Now, I'm sure our US and European clients would not have brought me there if bringing me there would actually cost more than having one of their IT personnel do the job. So, my suspicion is that my counterparts would have earned more than five times I'm getting back home.

So there's a bit of sour-graping on my side upon this realisation. But I consoled myself with the usual neoclassical economic explanations (emphasising the plural) about the disparity. That their standard of living is much higher... blah blah blah... and so their cost of living is such and such and such. But I can't seem to shake away the lingering fact that, basically I'm doing the same thing as that other person is doing. And yet,
  • I'm treated as second class "resource" by my company's client.
  • I'm treated as a slave by my company and my company's client. Reifying the notion of me as a mere resource for them.
  • I have to deal with two managers who most of the times have different ideas of what the work is about.
  • I'm given deadlines which are often too compromised so in effect, I do overtime work but never clock them on my reported time sheet because my Project Manager wants to keep his/her scorecard below scrutiny.
  • I'm blind sighted by a lot of "management" decisions which does not really make sense (later did I know... and good thing I already resigned from the company when I did realise this... "upper management" only wanted to protect their ignorance from reeking to higher management)
  • and on top of it, I'm paid a measly fraction of what my counterparts enjoy.
Of course, this gripe stems from my assumption that I'm just doing the same work as they are and yet compensated less. And some might actually point this out as a flaw in the logic.

This article actually provides some sort of counter argument against that. In fact, I think in many respects the situation narrated might be analogous to what usually happens: that at the higher levels, the decision makers do not really know how much outsourcing their trustee managers and delegates employ and all the while the same have been claiming credit for what the remote pawns have actually built which they only repaid with but a fraction of their own salaries (or budgets).

Well, it's a world full of ironies... and full of inequities. But if you're on the shorter end of this relationship, you can only bite the bullet and put on the friendly client service smile.

Unix Shell stderr and stdout redirections


This has always confused me. So I'll try to recapitulate what I understand in this mini-blog for my future reference.

In a Unix shell, 0 stands for stdin, 1 stands for stdout while 2 stands for stderr.

You can redirect stderr to stdout if you append this to your Unix command:

2>&1

Corollary, you can redirect stdout to stderr (which do not usually happen) by appending this otherwise:

1>&2

By default, when you redirect a stream, it redirects stdout. Which means the this command will log stdout to the the file (but not stderr):

$ echo "test string" >test.log

Building on this, if we want not only stdout but also stderr to the directed to test.log we issue this command:

$ echo "test string" >test.log 2>&1

The command reads from left to right (and the sequence is important as the first redirection takes precedence over the later redirection specification). And it should read: "redirect stdout to test.log, then redirect the stderr to the same place stdout is going (which is test.log)."

Now, in some cases, the sequence does not "seem" make any difference but in fact there's a subtle nuance introduced by the sequence like in doing so:

$ echo "test string" 2>&1 >test.log 

In the above, it reads: "redirect stderr to the same place stdout is going (which is the console), then redirect stdout to test.log (but not stderr)." The net effect is that stderr is redirected to console but stdout is directed to test.log. The above is made more explicit by the equivalent command:

$ echo "test string" 2>&1 1>test.log 

Now consider these two commands:

$ echo "test string" >/dev/null 2>&1
$ echo "test string" 2>&1 >/dev/null

The first reads: "redirect stdout to /dev/null (meaning discard the bytes streamed to stdout), then redirect stderr to the same place stdout is going (which is now /dev/null)." The end effect is that both stdout and stderr is discarded.

The second reads: "redirect stderr to the same place stdout is going (which is the console), then redirect stdout to /dev/null (meaning discard the bytes streamed to stdout)." The end effect is that whilst stderr is printed on the console, stdout is discarded.

One link that really seems helpful is this: http://wiki.bash-hackers.org/howto/redirection_tutorial