Stumblings

Do the math

Posted in Uncategorized by Rahul on January 28th, 2007

Got my W2 in the mail yesterday. Did some quick math to figure out how much I paid in taxes last year. Bad idea. Calmed myself down by thinking “Hey, a lot of that money is being spent on your own good. Essential stuff, such as a good education for your kids”. Then I happened to see this.

[via Reddit]

2006

Posted in India by Rahul on January 4th, 2007

A better summary of 2006, I am yet to read.

2006 : The Year Of Living Precariously

(May only make sense if you are familiar with events and personalities in India though)

Some Books

Posted in Uncategorized by Rahul on December 25th, 2006

Most books I have read, I had to track down. Here are some that found me and I’m glad they did. They were unlike anything I had ever read before. After reading each of these, I had this rare feeling - the feeling that I had grown up just a tiny bit between beginning and end.

The Dark Crusader - Alistair MacLean

Age about 12. A rather disappointing trip to the raddiwallah, since it hadn’t yielded any books by authors I was familiar with. I had reluctantly picked this one up. I don’t think there are many Alistair MacLean books I did not devour in subsequent years.

Second Foundation - Isaac Asimov

Age 16. The library had been flooded and they were they were throwing out books that had been “damaged”. My brother happened to be around and he picked up some for me. Another book on this list was a collection of novels by Raymond Chandler.

To Kill a Mockingbird - Harper Lee

Age 19. A friend who lived a few doors down in the dorm lent me this one. I don’t think I put it down till I finished it.

The TV Licence

Posted in Uncategorized by Rahul on November 19th, 2006

The only radio/TV news source I rely on for balanced coverage is the BBC. I recently learned of the UK TV Licence fees that ultimately fund the BBC.

An interesting issue to say the least. On one hand, the ability to provide fair, balanced and commercial free coverage by having no obligations to advertisers. A strict licencing regime to pay for it on the other. I am sort of glad I don’t have to pick sides on this one. See this wikipedia page about the debate.

Mostly Harmless

Posted in Uncategorized by Rahul on November 19th, 2006

The BBC it seems, organized a contest for the best Hitchhikers guide entry about the Earth. In their own words:

The Hitchhiker’s Guide to the Galaxy famously described the Earth with a single word: Harmless. After years of research by Ford Prefect the entry was expanded slightly - to Mostly Harmless.

We asked you to write a more comprehensive (but equally witty) description using exactly 264 words*.

*In “So Long And Thanks For All The Fish” Douglas revealed that Ford had in fact written a substantial article about Earth for the Guide. Douglas described the entry using 264 words.

This and this were awarded the joint first prize. Excerpts:

You could spend many Earth years sightseeing, which is handy since leaving is difficult. Some must-sees for a short visit are:

Norway and New Zealand. The finest fjords in the Galaxy, with no admission charge.

Deep ocean. Top galactic backpackers’ hangout, but virtually unknown to the locals. The dolphins are friendly, if rather smug.
New York. Ridiculous place. You’ll love it. 

Of other literature, “A Brief History of Time” is really very funny indeed, and “Lord of the Rings” is the only other book anyone ever mentions.

Fun stuff.

Quotation

Posted in Uncategorized by Rahul on November 19th, 2006
Quotation, n: An ordinary line, magically transformed into an insightful, pithy and universal truth, merely by quoting it completely out of context.
Rahul Agarwal

Here are some better quotations on … err … quotations, from the quotationspage:

People will accept your ideas much more readily if you tell them Benjamin Franklin said it first.
David H. Comins
Quotation, n: The act of repeating erroneously the words of another.
Ambrose Bierce (1842 - 1914), The Devil’s Dictionary
The point of quotations is that one can use another’s words to be insulting.
Amanda Cross (1926 - )

No evil shahs live on

Posted in Uncategorized by Rahul on November 7th, 2006

That is a palindrome. Surprisingly relevant to current events.

Check this site out for more.

[via Reddit]

Oracle Application Contexts

Posted in Oracle by Rahul on November 7th, 2006

A quick writeup on Oracle Application Contexts

Overview
Link to 9i Documentation
Link to 10g Documentation

From the documentation:

Application contexts allow you to write applications which draw upon certain aspects of a user’s session information. It provides a way to define, set, and access attributes that an application can use.
An Application context is a namespace. Each Application Context namespace can have multiple attributes (name/value pairs). These are associated with a user session and can be set/accessed multiple times.

Creating Context
To create a context namespace called sls_app_context:


CREATE CONTEXT sls_app_context USING sls_app_context_pkg
/

To create a context namespace, you must have CREATE ANY CONTEXT system privilege.

sls_app_context_pkg is a PL/SQL package that can change the Application context.

You can only set the context attributes inside the trusted procedure/package you named in the CREATE CONTEXT statement. This prevents a malicious user from changing context attributes without proper attribute validation. The sls_app_context_pkg is the trusted package.

Set Context
Package sls_app_context_pkg would be defined as follows:
CREATE OR REPLACE PACKAGE sls_app_context_pkg AS
– Set App Id for App User management
PROCEDURE set_app_id (p_app_id Varchar2);
– Set period of interest
PROCEDURE set_period (p_period Integer);
END;
/
CREATE OR REPLACE PACKAGE BODY sls_app_context_pkg AS
– Set App Id for App User management
PROCEDURE set_app_id (p_app_id Varchar2) IS
BEGIN
DBMS_SESSION.SET_CONTEXT(’sls_app_context’, ‘app_id’, p_app_id);
END;
– Set period of interest
PROCEDURE set_period (p_period Integer) IS
BEGIN
DBMS_SESSION.SET_CONTEXT(’sls_app_context’, ‘period’, p_period);
END;
END;
/

Now, the context can be set by any program unit (procedure/trigger etc) by calling the appropriate procedure from sls_app_context_pkg.

PROCEDURE login_proc IS
v_app_id Varchar2(256);
BEGIN
– Set app_id context attribute
SELECT char_value
INTO v_app_id
FROM tsysstg stg
WHERE stg.code = ‘APP_ID’;
sls_app_context_pkg.set_app_id(v_app_id);
– set period context attribute
sls_app_context_pkg.set_period(To_Number(To_Char(Sysdate,’MM’))); — Assuming period is month number
END;
/

Get Context
To access the context attribute value use the SYS_CONTEXT function:

DECLARE
v_period Integer;
BEGIN


v_period := SYS_CONTEXT(’SLS_APP_CONTEXT’,'period’);

END;

This function can be used in various places. Some examples:
1. In queries (including views)
2. In PL/SQL code
3. As default values for table columns

CREATE TABLE txxxtab (
id number(10),
col1 varchar2(30),
col2 varchar2(10),
period number(10) DEFAULT SYS_CONTEXT(’SLS_APP_CONTEXT’,'period’))
/
CREATE VIEW txxxtab_vw AS
SELECT id,
col1,
col2
FROM txxxtab
WHERE period = SYS_CONTEXT(’SLS_APP_CONTEXT’,'period’)
/
CREATE OR REPLACE PROCEDURE some_proc IS
v_period Integer;
BEGIN


v_period := SYS_CONTEXT(’SLS_APP_CONTEXT’,'period’);

END;
/
insert into txxxtab_vw values (1,’AAA’,'A’);
insert into txxxtab_vw values (1,’BBB’,'B’);
insert into txxxtab_vw values (1,’BBB’,'B’);
SELECT *
FROM txxxtab
WHERE period = SYS_CONTEXT(’SLS_APP_CONTEXT’,'period’)
/

Built-in Contexts
There is a built-in context USERENV that provides information about the current session. Some examples:

TERMINAL
Returns the operating system identifier for the client of the current session. “Virtual” in TCP/IP

LANGUAGE
Returns the language and territory currently used by the session, along with the database character set in the form: language_territory.characterset

LANG
Returns abbreviation for the language name

SESSIONID
Returns auditing session identifier

INSTANCE
Returns instance identification number of the current instance

OS_USER
Returns the operating system username of the client process that initiated the database session

These are accessed like user defined Application contexts i.e. using the SYS_CONTEXT function.

DECLARE
v_os_user varchar2(256);
BEGIN


v_os_user := SYS_CONTEXT(’USERENV’,'OS_USER’);

END;
/

Segmentation

Posted in Oracle by Rahul on June 3rd, 2006

Everything you wanted to know about Segmentation, but were afraid to ask.

Camels and Rubber Duckies - Joel on Software

That was all I was going to publish. But then, what’s a blog post without a rant. So here’s more. A quote from Joel’s article:

In the world of software, you can just make a version of your product called “Professional” and another version called “Home” with some inconsequential differences, and hope that the corporate purchasers (again, the people who are not spending their own money) will be too embarassed at the thought of using “Windows XP Home Edition” at work and they’ll buy the Pro edition. Home Edition at work? Somehow that feels like coming to work in your pyjamas! Ick!

I run Oracle 10g XE on my laptop running Windows XP Home Edition. I don’t run any mission critical applications, but so far XE does what I ask it to do. However, from the minimum system requirements in the XE Installation guide :

One of the following 32-bit Windows operating systems:

  • Windows 2000 Service Pack 4 or later
  • Windows Server 2003
  • Windows XP Professional Service Pack 1 or later

If I hadn’t tried to run XE on the Home Edition, I would end up spendng an extra $119 on my next PC. Given that XE itself is “free to develop, deploy and distribute” it just doesn’t make sense to put money in the competitions pocket. I wish Oracle would just publish a list of XE features that cannot be used when running Windows XP Home.

Update

From the same XE installation guide mentioned above:

It is not possible to disable simple file sharing on Microsoft Windows XP Home. Oracle strongly recommends that you upgrade to one of the required operating systems identified in “System Requirements”. However, if you cannot upgrade, then Oracle recommends that you enable the firewall and ensure that port 1521 (or the Oracle listener port you configured during installation) is blocked. Note that blocking port 1521 blocks remote access to the database over TCP/IP.

To enable the firewall (or check that the firewall is enabled) on Microsoft Windows XP, see Microsoft Knowledge Base article number 283673, “How to turn on or turn off the firewall in Windows XP.”

So it seems the sytem requirements are not “minimum” system requirements and you can install XE on the XP Home Edition. The Professional Edition is recommended for security issues.

What really is an RSS feed?

Posted in RSS, Web 2.0 by Rahul on May 7th, 2006

If you have been trying to make sense of all the Web 2.0 hype, you probably have wondered what RSS is. To me an RSS feed is:

  • a mechanism to inform people of changes to your website content
  • an XML document (that conforms to the RSS specification),
  • accessible over HTTP
  • that automatically updates when you update your website content

Let's use a sample from the RSS Specification page at Harvard. The location of the RSS feed file is:

http://media-cyber.law.harvard.edu/blogs/gems/tech/rss2sample.xml

Once you point your RSS Reader to the above location, it reads the feed and displays it in human readable format. Here is what my favorite Reader, Netvibes displays:

Feed Reader

Lets take the XML file apart. The channel represents a feed.

<title>Liftoff News</title>
    <link>http://liftoff.msfc.nasa.gov/</link>
    <description>Liftoff to Space Exploration.</description>
    <language>en-us</language>
    <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>

The title ("Liftoff News&quot ;) usually shows up as the feed title in your reader. The link is a URL to your main site/blog etc.

The most important pieces in the feed are items. These show up as a list in your reader. If this was a feed of your blog, then each item would represent a blog post.

<item>
      <title>The Engine That Does More</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
      <description>Before man travels to Mars, NASA hopes to design new engines
        that will let us fly through the Solar System more quickly.  The proposed
        VASIMR engine would do that.</description>
      <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
    </item>

Each item has a title, link, description and guid. The title ("The Engine That Does More&quot ;) appears in the feed. The description is what appears when you hover your mouse over the item title in most readers. The link is where you are redirected to when you click the item (which is the whole purpose of publishing the feed if you ask me). I am assuming the guid is so that the reader can tell two posts apart even if they have the same title.

Resources