+
More
Recent News and Links
  • No bookmarks avaliable.
MySQL hackery: ON DUPLICATE KEY with IF!
Oct 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
Oct 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
Sep 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
Jul 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
Jul 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 visibility in Ahimsa for WordPress
Nov 14th, 2008 by ravi

For Ahimsa for WP 2.0’s collapsible sidebar, I made a design choice to leave the sidebar visible by default on the main page (this is configurable), and hidden by default for posts and pages (this is not configurable). The thinking here was that when a visitor is reading a page or post, the browser real estate for the content should be maximised, and distractions minimised.

However, I have received quite a few requests to make the sidebar visibility configurable for pages and posts also, and far be it for me to question my users’ design choices ;-). So I have created a bug, which you are encouraged to track, comment on, etc. I have targeted this feature for the immediate next release (2.1).

In the meantime, here is how you can overcome this feature of mine, right now:

1. Visit your blog’s admin page and choose Design.
2. Click on Theme Editor.

Choose Design in WP Admin Page

Edit Page and Single Post templates
3. Edit the Page and Single Post templates one at a time, and remove the following section of JavaScript code (present at the top of the Single Post template and the bottom of the Page template):

<script language=’JavaScript’>
fadeSideBar();
</script>


Google Talk via SOCKS
Sep 18th, 2008 by ravi

For some reason, Google’s services do not play well with a SOCKS proxy (if you are unfortunate enough to be behind a restrictive firewall). One workaround for Google Talk is to set your chat client (Adium X is show below) to connect to talk.google.com on port 80.

Google Talk via SOCKS

Google Chrome comic book
Sep 4th, 2008 by ravi

Google Chrome logo
If you cannot download Google Chrome (not available for us Mac and Unix types :-(), you can at least spend time reading the most excellent comic book that explains the browser. Why? Because, IMHO, it is a veritable modern CS 101 (operating systems, process/memory management, threading, interpreted languages, and so on)! Check it out!

Chrome comic page

Skype, Mac OS and firewalls
Aug 25th, 2008 by ravi

Skype logoIf you use Skype and are unfortunate enough to sit behind a firewall (such as at work), but have some means to use a SOCKS proxy (such as if outgoing SSH is permitted through your firewall), then you have probably already set things up so you can reach some of your external services (like chat, IMAP for mail, etc) to use the SOCKS proxy. While the Interwebs are littered with various pages that discuss Skype settings for SOCKS, the sad truth (as confirmed from the horse’s mouth) is that Skype for Mac does not currently support SOCKS (either as a Skype Preference, or via the system wide proxy settings). You can join me in holding your breath and waiting… the Skype engineer I communicated with indicated that this is one of their top priorities. I should trust him on that, yes?

Olympics 2008 Beijing competition schedule
Aug 7th, 2008 by ravi

If like me you were seeking a iCalendar schedule of the entire 2008 Beijing Olympics you can find it at iCalShare: Olympics 2008 Beijing competition schedule. Be warned that it will visually overwhelm you with the number of entries! ;-)

[ Link ]

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