A very basic Vim Cheat Sheet
July 8th, 2012 by ravi

I created one. Below is a screenshot. Download it here.

Switching to British English on Mac OS X
April 12th, 2011 by ravi

UPDATE: On MacOS Sierra, after you have set your language preference using System Preferences -> Language and Region, you can then go to Text Preferences under Keyboard settings to follow step 3 (and onward) from below.

If like me you have not yet learnt to drop the ‘u’ from ‘colour’, then you might have noticed that Mac OS X Snow Leopard makes it annoyingly difficult to switch the system language preference, especially for spell checking (worse, I suspect the interface for spell check language settings is buggy). To that end, below is a quick outline of the steps I used to switch to British English (click on the small images to see the full version).
Read the rest of this entry »

Shortcodes in Ahimsa for WordPress
May 31st, 2010 by ravi

For a couple of releases now, the Ahimsa theme for WordPress has included two shortcodes which I have been too lazy to document, and this post attempts to rectify that.

Quick Fancybox Gallery

If you are not happy with just simple old Lightbox for displaying images (and image galleries), then the Fancybox is what you need, and happily for you, and using Fancybox in your blog is trivial with the Ahimsa theme using the qfgallery shortcode.

Here’s what it’s supposed to do:

QFGallery Shortcode Demo

And here’s how:

    [qfgallery title=”Photographs from Spain” scale=”0″ orient=”landscape” float=”left|right”]
    URL to image 1|title1
    URL to image 2|title2
    URL to image 3|title2
    [/qfgallery]

As is perhaps obvious, what the above does is create a thumbnail gallery (the thumbnails are sized at 128×128 pixels) of the three images, and attaches the Fancybox trigger to them, so that when a thumbnail is clicked the original picture pops up in a Fancybox window (which also provides navigation).

All arguments to the shortcode are optional.

The argument scale specifies if the image should be scaled down for the thumbnail or just a 128×128 part of it should be displayed in the thumbnail (the latter is the default). This is a good time to mention that thumbnails are generated in a hacky way: they are not created at all, but are merely browser scaled down versions of the original image. I admit this is a bad idea, especially if you have lots of images, and my only defence (if it can be called that) is that I created this shortcode to make it easy for me to post a few images without having to worry about scaling them to thumbnails, or having to use WordPress’s media manager, etc.

The orient argument specifies if the thumbnails should be displayed left to right and then in additional rows if necessary (“landscape” mode, which is the default) or in a thin vertical strip with one thumbnail per row (“portrait” mode).

The float argument translates to an equivalent setting for the CSS float property. If you want the thumbnail box to be to the right of the content, use the value “right”. Etc.

You can specify a name or title for each image by adding a “|” (pipe) symbol after the URL and then the text for the title.

FAQinWay

FAQinWay is a trivial implementation of a FAQ (a list of answers to Frequently Asked Questions) in a page or post. The answers to each question is revealed below when the reader clicks on the question. For an example, see the Ahimsa FAQ page. Questions and answers are added using the FAQinWay shortcode thus:


    [faqinway]
    This is the first question
    @@@
    This is an answer to the first question
    $$$
    This is a second question
    @@@
    Answer to the second question
    [/faqinway]
Apple iCal, Google Calendar, CalDAV and SOCKS
May 21st, 2010 by ravi

A breakthrough in my long-running quest to reach Google Calendar via CalDAV through SOCKS from behind a firewall! If that’s a mouthful the solution is equally contrived, but quite worth it… for me.

The problem: iCal, Apple’s calendar client, is capable of connecting to Google Calendar via CalDAV (support for CalDAV was recently added by Google) but incapable of using the SOCKS/proxy settings in Mac OS X. Huh? Well, that’s Apple engineering for you.

The solution, for the unfaint of heart, assuming your SOCKS proxy is achieved using SSH:

Step 1

Tunnel port 443 (HTTPS) on your desktop to 443 on www.google.com:

ssh -D .... -L 443:www.google.com:443 ....

Step 2

Configure iCal. Fire it up, bring up Preferences, click on “+”  under Accounts. Fill out as below, replacing your Google or Google Apps email address for “myemailaddress@gmail.com”:

Clicking on Create will cause iCal to whine about not finding the server or calendars. Ignore that and click again to proceed to the next screen:

The full Server Path (obscured above) is: /calendar/dav/myemailaddress@gmail.com/user/ (the email address, as mentioned earlier, should be replaced with yours).
And that’s it.
Yet another Markdown Cheatsheet
March 12th, 2010 by ravi

I have created a cheatsheet for Markdown. See this page for info and download links.


MySQL hackery: ON DUPLICATE KEY with IF!
October 15th, 2009 by ravi

Once again, since the Googles did not return this hack of mine as a possible answer (to a question that perhaps only I am concerned with):

Say you want to insert a row into a MySQL table, and if the value you supply for a unique key field already exists, then you just want to update the row that contains that value (for that key field). MySQL has a nifty little bit called ON DUPLICATE KEY UPDATE which lets you do exactly this. But what if you want to take it to 11, and carry out the UPDATE only if some condition is true. Below is my somewhat ugly hack to achieve this:

What this does is:

INSERTS a new row if no unique key has a duplicate value.

If there is such a duplicate value, then it UPDATEs the field fld2 with the supplied value for fld2 IF the supplied value for fld3 is greater than the current value for fld3 in the existing row.

Here, id is an auto-increment field that I do not want modified by the UPDATE; hence the LAST_INSERT_ID trick.

CAUTION: Use at your own risk, since I am not an SQL guru.

Mediawiki and user passwords
October 2nd, 2009 by ravi

I just spent a few hours trying to figure this out, and in the interest of saving someone equally clueless the same effort, for the Googles, a summary of my experience with user login issues in Mediawiki.

My setup uses the LdapAuthentication extension to, as can be expected, authenticate users using an LDAP directory. A few members of my team complained that they were unable to login, even though their Mediawiki login (with the first letter in lowercase) matched their LDAP uid. I am yet to nail down the exact cause of this, but it seems to have something to do with certain special characters in the password string. Change the password in LDAP (to not include these characters) and the problem disappears.

What made matters worse in my case was that in order to debug the situation, one of the users set his password to his login name (admittedly a highly insecure action, but this is not a public Wiki, and the change was temporary) and login attempts continued to fail for this person with the new, simple, password as well. Turns out that buried in the Mediawiki code (in includes/User.php) is a function isValidPassword() which implements a check that returns failure if the password and username are the same! Unfortunately the error returned is a generic “Wrong Password” error.

Which all made for a very enjoyable Friday evening!

Reply via email for WordPress blogs
September 1st, 2009 by ravi

Earlier this year, the chaps at WordPress added a very useful feature for WordPress.com blog owners: reply to comments via email. No longer do you have to plod through the comments responding to them via the reply form or through the Dashboard comment section (which despite admirable enhancements still does not offer a threaded view, making it difficult to tell if you have already responded to a comment — a very real concern for a forgetful dweeb like me).

Excellent, you say. Indeed, but the nub of it is that this brilliant new feature is unavailable for self-hosted WordPress blogs (no doubt, in part due to the intricacies of tying up with the email system of the blog owner). Needless to say there has been some anguish in the community.

Read the rest of this entry »

Fix: broken feed links at the top of the Ahimsa theme
July 4th, 2009 by ravi

The Ahimsa WordPress theme has a bug that renders the “Site” and “Comments” feed links at the top right unusable (by adding a “feed:” at the front of the URL). This will be fixed in the next release, but in the meantime, you can make the following change to overcome the problem.

Read the rest of this entry »

How to add an image in the Ahimsa Theme header
July 1st, 2009 by ravi

One question that crops up in the comments or via email is how you might add an image (such as a logo) to the red header bar of the Ahimsa theme. This is a tricky issue, because how you accomplish this depends on what the function of the image is and how large it is. Perhaps you want the image to be a background image for the header, like is the case for many WordPress themes. Or perhaps the image is a small logo. The changes to be made to the header code vary correspondingly.

Read the rest of this entry »

SIDEBAR
»
S
I
D
E
B
A
R
«
»  Substance: WordPress  »  Style: Ahren Ahimsa