Tuesday, September 4, 2007

Google Pages Site Sitemap

A little while ago, Charles wrote a post on Google Pages. It is a rather cool service. And here's a cooler fact: it automatically generates a sitemap for you, which you can use for indexing with Google Webmaster Tools or wherever else. If you frequently update, you could even use it as a feed of sorts.

The sitemap file is called, wait for it, sitemap.xml! It won't show up in your 'Uploaded stuff' though ( since you obviously didn't upload it! ) but you can find it at http://your.google.pages.sitename.googlepages.com/sitemap.xml. But here's the worrying part; so can others. It's a public file and you have no control over the contents either. All your files will be listed in it. So for those of you that use the Google Pages space for storage, if it's stuff you don't others to find, don't put it up there. There's even an iGoogle gadget that lets your browse the contents using the sitemap. But of course, you could argue that if it's online, someone could find a way to get it, but there's a difference between leaving your front door open and locking it, knowing that a determined thief could break in anyway.

Apart from sitemap.xml, there’s also an rss.xml. This one is also generated automatically but it contains entries of only your pages, not your uploaded files.


 I first found out about sitemap.xml and the iGoogle gadget from A Consuming Experience.
 

Sunday, August 26, 2007

Finding Your Blogger blogId And postIds

Your Blogger blogId is your blog's unique identification number. You could change your blog URL and name but the blogId remains the same. You can find your Blogger blogId at quite a few places. The first is your blog's HTML source. Search for 'blogId' and you'll find something like

blogID=2091151685457159297

The next place to look is your Blogger Dashboard. If you hover the mouse pointer over the 'Manage' links ( i.e. the links for Edit Posts, Settings and Layout (or Template )), in the status bar, you should be able to see the blogId as part of the URL those links point to. Or you could right-click and select Copy Shortcut ( IE ) or Copy Link Location ( Firefox ). If you've followed any of those links, you'll also be able to see the blogId in your browser's address bar.

Finally, you can also see your blogId on the comments link on your posts. It's part of the URL again, so use the same method as for the Dashboard.

All your posts also have a unique id. The postIds are little harder to find. You can get them from the 'Manage Posts' page ( follow the Edit Posts link from your Dashboard). The Edit link for each post has the postId as part of the URL, you can view it in the status bar or by copying the link to a text-editor.

Similarly, the postId can be found as part of links on your posts, the comments link, the Email Post link among others. In almost all cases, it'll be a parameter called postId in the destination URL. One exception is the Subscribe to: Comments ( Atom ) on the individual post pages, where the postId would be the really long number in the URL. For example:

http://tipsandtricks.nogoodatcoding.com/feeds/6725560071480110191/comments/default

Here, 6725560071480110191 is the postId.


Friday, August 17, 2007

Customizing Mininova RSS Feeds

Mininova offers search-based feeds i.e. RSS feeds that can be generated according to some optional parameters.

Mininova has two basic feed URLS; one is the global RSS feed at http://mininova.org/rss.xml. The second is the RSS feed for a search, found at http://mininova.org/rss/search+terms. Incidentally, I'm a big fan of their 'clean' URLs; very easy to use and very intuitive.

Starting with the global feed, parameters that can be passed are:

  • cat : The category of the torrent. For example, 'Movies' are category 4.
  • sub : The sub-category. For example, 'Action' movies are sub-category 1 while 'Animation' movies are 29. The sub-categories aren't necessarily in sequential order. Sub-category 2 is 'Trance/ House/ Dance' under the 'Music' category.
  • user : The user name. For example, 'aXXo'. Case-insensitive, so you could use 'axxo' or 'AXXO'.
  • num : The number of results you want returned. The default count is 20 items.
  • direct : This is a new addition and doesn't take a value. It replaces the link of the feed item with the actual download URL ( you know, the one you see stating 'Download this torrent!' ) so that when you click on it, the download starts instead of you being taken to the 'General Information' page of the torrent.
You can't really combine these parameters, but if you attempt to
  • cat takes precedence over the others
  • user is ignored if either cat or sub is used
  • direct can be used with any of the others, either as the first parameter ( ?direct ) or at the end ( ?cat=1&direct )
The search feed is much less customizable but you can easily find the button for the feed at the top of the search page, if you're not comfortable fiddling with the URLs.
  • Spaces are replaced by +'s
  • You can filter a category by simply adding the category number at the end of the URL like http://mininova.org/rss/search+terms/2
  • Sub-categories don't seem to work, I was getting weird results with URLs like http://mininova.org/rss/search+terms?sub=35 or http://mininova.org/rss/search+terms?cat=35
Well, that's all there is to it. Have fun. And if you find something else, lemme know!

Saturday, July 28, 2007

Basic Authentication For XDB Realm With Tomcat

I've seen a few people asking this question recently: "When I try to access my instance of Tomcat with the URL http://localhost:8080, I get a dialog box asking for a username and password to log into the XDB Realm". Even with fresh installs, people face this problem.

The problem is that by default, Oracle listens at port 8080. And coincidentally, so does Tomcat, with default settings! And so, if you start Oracle first and Tomcat after, port 8080 is already in use when Tomcat tries to bind to it. In fact, if you look at the console or the logs, you'll see an error which says something like

Address already in use:JVM_BIND 8080

When you try to access http://localhost:8080, you are actually trying to connect to Oracle and not to Tomcat. That's why none of the default username/password combinations that come with Tomcat work.

The solution is simple: change the port that Tomcat listens on. This is assuming, of course, you want to use Oracle also. You could just get rid of it :D.

Changing the port is simple. You'll find lots of detailed explanations if you Google'ed for it. But to give it in short, open $CATALINA_HOME/conf/server.xml and look for a line which starts with

<Connector port="8080"

and change the port value to something different. I prefer using 8888. It's so much easier to type than 8080 or 8081!

Wednesday, July 25, 2007

Escape Character In Microsoft SQL Server 2000

Here's something I was spent half a morning trying to find out: how do I escape a single quote (') in Microsoft SQL Server 2000? I first tried the most obvious character- the backslash (\), but that didn't work. Then I randomly tried a few other characters but to no avail. So I ran a Google search but most of the stuff I got was for MySQL or Oracle and they seem to accept backslashes for escaping.

I finally managed to discover that the escape character is, in fact, the single quote itself! So to insert a string with a single quote in it, you need to use an SQL query like:

INSERT INTO mytable ( randomstring) VALUES ( 'Where''s the answer?' )

So now you know. What I want to know is, why couldn't they just use a backslash like everyone else?

You could also check this article out though it didn't really work for me but I didn't try that hard.

Monday, July 16, 2007

HTML Single Text Field Submit Caveat

This is something that I discovered by accident and thought it was a bug till I read this in the HTML specification:

When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form.

I was using the name of the button clicked to identify the action to take when I started receiving a null value on some occasions. After a little investigation, I realized that if I clicked the button, the code worked fine; but if I pressed the Enter key while typing in the text field, I would get a null value for the button.

If there is only one text field in a form along with a submit button, pressing Enter would cause a form submission as usual, but, the submit button would not be passed. The text field would be the recipient of the request to submit the form.

Consider this simple form that submits to itself using the GET method ( default ) so that the query string can be used to easily verify the parameters being passed.
<html>
    <body>
        <form>

            <input type="text" name="loneTextField" />

            <input type="submit" name="theSubmitButton" value="Click Me" />

        </form>
    </body>
</html>
On clicking on Click Me, the query string is:

submitCheck.html?loneTextField=Test+Contents&theSubmitButton=Click+Me

whereas on pressing Enter in the text field:

submitCheck.html?loneTextField=Test+Contents

You can easily work around this though and it's not an issue if you don't need the button, but it's worth knowing.

Thursday, July 12, 2007

Wrapping Text In JLabels

I recently picked up Swing while I was developing Tweeter!, a Java client for Twitter. A nifty little trick that I found out about was how to wrap the text inside a JLabel.

JLabels support HTML markup. So all you need to do is surround the text with HTML tags ( <html> and </html> ) and voila! The contents wrap around! If you need it to be centered, simply add a <center> tag. It's that simple!

Monday, June 25, 2007

Yahoo! Mail Beta Login Workaround

I’ve always liked Yahoo! Mail, it’s fast and simple. I’d signed up for Yahoo! Mail Beta when I’d got the option but unfortunately, it seems to still have quite a few bugs in it and more often than not, I just see the welcome screen and nothing happens after that. None of the links respond and none of the buttons work.

Now, I don’t want to opt out of the programme but I’m not really keen on having to clear my browser’s cache and reload every time I want to check my mail. So here’s what I do: as soon as the login process completes and I’m directed to the mail URL, something that looks like this:

http://us.mg2.mail.yahoo.com/dc/launch?.rand=tnrkit406744a


I stop the page from loading and change the URL to this:

http://us.mg2.mail.yahoo.com/ymv/login?ymv=0

i.e. add ymv/login?ymv=0 to the end of the original URL. This takes me to the old Yahoo! Mail; speedy and simple. The URL may be slightly different; I used to get http://us.f527.mail.yahoo.com/

earlier but nowadays I seem to be getting redirected to this server. The technique works the same on both though.

Yes, I know you can click on ‘Trouble logging in?’ and then ‘Check your email in original Yahoo! Mail’ but it takes too long that way and sometimes the page just doesn’t load.

And anyway, you have to admit, this way looks much more impressive :D

Wednesday, June 20, 2007

Converting Java Primitives To Strings

It’s fairly easy to convert the primitives in Java; byte, short, char, int, long, float, double and boolean, into Strings; simply use the toString() method of the respective wrapper classes. But there’s a far easier way.

It’s pretty well known that the String class overrides the ‘+’ operator for concatenation of strings. It’s also often mentioned that one should be careful while using code like

String total = “The sum is ” + 2 + 4; 

since this will create the string as “The sum is 24” instead of the ( assumedly ) expected “The sum is 6” since the role of ‘+’ as the concatenation operator takes precedence over addition.

This very side-effect can be utilized for all primitives. Simply concatenate the required primitive with an empty string ( “” ) and you get the value as a String! Consider the sample below:

public class ConvertToString
{
    public static void main(String[] args)
    {
        String finalOutput = "";

        byte b = 1;
        short s = 3;
        char c = 'd';
        int i = 14;
        long l = 1234;
        float f = 2.0F;
        double d = 1.55;
        boolean bn = true;

        // finalOutput = b; //will not compile
        // finalOutput = (String)b; //will not compile

        // finalOutput = Byte.toString(b); //using the corresponding wrapper class

        finalOutput = b + "";
        System.out.println("The byte as String " + finalOutput);

        finalOutput = s + "";
        System.out.println("The short as String " + finalOutput);

        finalOutput = c + "";
        System.out.println("The char as String " + finalOutput);

        finalOutput = i + "";
        System.out.println("The int as String " + finalOutput);

        finalOutput = l + "";
        System.out.println("The long as String " + finalOutput);

        finalOutput = f + "";
        System.out.println("The float as String " + finalOutput);

        finalOutput = d + "";
        System.out.println("The double as String " + finalOutput);

        finalOutput = bn + "";
        System.out.println("The boolean as String " + finalOutput);
    }
}

As you can see, there’s no need to be messing around with the wrapper classes. Admittedly, it’s not that big a deal, but it does make the code a little neater.


Sunday, June 17, 2007

Solution For Slow Hibernation

Ever since I've been using Windows XP, I've been a fan of the 'Hibernate' feature since it significantly speeds up the boot time of my machines ( shutdown may be a little slower though, but it's worth it. Also, it may actually lead to slower booting on some machines; you'll have to try it out ).

A little while ago though, I faced a very frustrating problem: Windows would take almost 10 minutes to hibernate. And it was really weird because I had reinstalled Windows a few days earlier and it had been working absolutely as expected ( notice I didn't say 'fine'; not with Windows :D ). I couldn’t' for the life of me figure out what had gone wrong.

After a little bit of Google'ing, this is the solution I discovered: you need to have 'write caching' enabled for the drive. After reinstalling, I'd turned this off and when I turned it back on, hibernation was as fast as it had been before.

To turn on write-caching for a drive under Windows XP ( I'm using Windows XP Professional ):

Right-click the icon in My Computer > Properties option > Hardware tab > Properties button > Policies tab > Check the Enable write caching on the disk checkbox

Enable Write Caching

To enable hibernation under Windows XP ( I'm using Windows XP Professional ):

Right-click on your Desktop > Screen Saver tab > Power button > Hibernate tab > Check the Enable Hibernation checkbox

Enable Hibernation

Friday, June 15, 2007

NoGoodAtCoding.com

I own it! The it in question being the domain name 'nogoodatcoding.com'. I bought it yesterday and I've been fooling around with ever since. It's made me aware of a whole new dimension to the Internet. I'm still in the process of setting stuff up and so I guess I'll be a little busy for a while...which means no long, drawn-out posts :D

I have managed to publish both my blogs to custom domains using the feature offered by Blogger. There will be a few hiccups though; notably with images loading. I've also noticed that if you type in the blog's original, blogspot name with a 'www.' prefixed, it doesn't redirect to the custom domain.

Also, the blogs may simply not be available as the propagation of the changes across the DNS over the Internet takes some time; most sites I've seen say 24-48 hours, a couple stated up to 72 hours. Though I've already checked that a few people can already access these, it may still take sometime. Actually, if you're reading this, it's already happened; and if you weren't, well, then you wouldn't have known what was happening. :D

I think this post is getting close enough to being drawn-out now; and my domain settings beckon!

Thursday, June 14, 2007

What This Blog Is About

My original blog is an account of what I'm all about. I recently decided to start posting little tips and interesting stuff relating to technology that I use and some, rare snippets of curious code. It was immediately obvious to me that it would be out of place on that blog. So I started another; this one that you're reading now.

The posts may not be regular or even frequent. You may not think them smart; some may even seem lame. But it's something that I think I'm going to enjoy doing and so I will.

Well, so that is what it's all about; tips and tricks and other interesting things that I pick up as I make my way through it all.