Date formatting not working after installing qTranslate

I just installed qTranslate to have multilingual entries. It’s a really good internationalization plugin, I’ve used it on other WordPress installations before with great results.

After installing it with WordPress 3.0.1 though, the date format for posts wasn’t being parsed, showing instead the raw format:

Posted on %e de %B de %Y by johnny

I found a solution for this on the qTranslate forums:

  • Edit qtranslate_utils.php, line 143 from this:
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%%';
    to this:
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%';

It seems the extra percentage sign makes it so the percentage sign in the format gets interpreted as literal percentage signs and therefore they don’t get parsed by strftime().

The formatting in Spanish and Catalan isn’t completely fixed though, spurious “02UTC” strings are being added after each date component.

Resources

Posted in Uncategorized | 6 Comments

Merge Excel spreadsheets with common columns

Today I had a problem that is a non-starter when dealing with relational databases: I needed to do an inner join on two sets of data.

Instead what I had was two Excel spreadsheets, and it ended up taking much more time than I would have liked.

I wanted to “join” the spreadsheets based on a common email column. I thought this would be easy: there must be a built-in Excel wizard to do just that, right? Seemingly not, and the solution I ended up finding was to treat Excel like some Frankenstein SQL database.

At first I thought the “Consolidate” feature would accomplish what I needed. I wasn’t managing to make it do what I wanted after looking at a few “How to use Excel consolidate” guides though. The guides I was finding were very “point-here, click-that, there you go—magic”, without explaining what pointing here and clicking that actually did. I gave up on it.

Then I tried searching for “join tables excel” and got a lot of relevant add-ons that did exactly that, but they all cost money.

Finally I stumbled across a Microsoft article explaining how to do exactly what I wanted with Microsoft Query.

The only problem(s) with the article are:

  • It is aimed at mail merges in Word.
  • I wasn’t able to add more than one Excel file as a data source, as they are able to do in the article.
  • It’s a ten year-old article. Also it seems the Microsoft Query interface hasn’t been updated since Windows 3.1.

It took me some back-and-forth between the article, Excel and Microsoft Query to get the results that I needed so I’m documenting the steps for posterity.

Get the data in the same place

All the data has to be in the same spreadsheet; I didn’t find a way to add more than one spreadsheet to Microsoft Query.

In my case, I was trying to end up with the rows from Spreadsheet 1 whose email was the same as in Spreadsheet 2. I just copied the email column from Spreadsheet 2 into Spreadsheet 1.

Define names to use as tables

Microsoft Query uses names defined in Excel to create its “tables”. I needed two of these “tables”: one for Spreadsheet 1′s information (id and email) and one for Spreadsheet 2′s information (email, which I’d pasted into Spreadsheet 1).

To create the first table I selected the two columns I wanted and then clicked “Define Name” in the “Formulas” menu, “Named cells” panel. I called it “emailsall”.

The second table was created the same way, except selecting the “emails” column that I had pasted in from Spreadsheet 2, and naming it “emailsshort”.

Query the “tables”

To get the results of the faux join I wanted I created a new Excel spreadsheet and then clicked on the “Data” menu, then on “From Other Sources” inside the “Get External Data” panel, and finally “From Microsoft Query”.

At the “Choose Data Source” screen I selected “Excel Files” and opened Spreadsheet 1. In “Choose Columns”, I added the two “tables” that had just been created. When clicking “Next” the Wizard complained about not being able to join the tables itself and they had to be manually joined. I clicked “OK” and in the Microsoft Query window clicked the little “SQL” button.

In the SQL window I edited the query to do an inner join and got the results I needed. The query went something like this:

SELECT emailall.id, emailall.email
FROM emailall emailall
INNER JOIN emailshort on emailall.email = emailshort.email

Finally go to the “File” menu -> “Return Data to Microsoft Excel”

Resources

Posted in Uncategorized | Tagged , | Leave a comment

How to check database type of subversion repository

Doing some maintenance on my Subversion repository –namely taking out a directory and creating a new repository with only that directory– I wanted to find out how to check what type of database (FSFS or Berkeley DB) my current svn repository uses.

After some searching all I came up with were pages talking about the two database types, not what database type an existing Subversion repository uses. I decided to look around the file structure of my repository and found an aptly-named file called “fs-type“. Calling cat on the file told me what I needed:

$ cat {PATH_TO_REPO}/db/fs-type
fsfs

Yet another contribution to the blogosphere, from yours truly.

I got this searching google images for "blogosphere contributon". Is this a sign?

I got this searching google images for "blogosphere contributon". Is it a sign?

Posted in Uncategorized | Tagged | Leave a comment

Select boot device key on Sony Vaios

Most BIOSes nowadays have a feature whereby pressing a specific F key brings up a one-time boot device selection menu, handy for operating system (re)installs. The BIOS on my new Vaio didn’t display any information regarding keys (not even how to get into the BIOS). After blindly trying escape and del, F2 got me into the BIOS. There was no one-time boot option in the BIOS so I did a google search. A random post in a random thread said to try F11, which cycles the boot device through the available media.

I was trying to boot from USB: the first time I pressed F11 during boot the laptop tried booting from the empty CD drive. The second time (I can’t remember if the laptop rebooted itself, or if I had to) I pressed F11 it successfully booted from the USB.

Resources

Posted in Uncategorized | Tagged | Leave a comment

Find XPath to any element quickly with FireBug

I just discovered a way to quickly find the XPath to any element on a webpage with Firebug. This will help me a lot in the development of my Greasemonkey script HorariGlobal.

  • Right-click on element.
  • Click on “Inspect element” entry.
  • Go to HTML tab in the Firebug frame then the style tab on the right.
  • Right-click on empty space in that frame, select “Edit element style”
  • Hover mouse over the text item “element.style {” that has just appeared.

I imagine there is a tool somewhere out there that will do this in one step, but this will do me for now.

Edit: I found out that right clicking on a tag in Firebug’s HTML tab and clicking on “Copy XPath” is a much quicker method.

Posted in Uncategorized | Tagged , | Leave a comment

“Logon failure: unknown username or bad password.” when trying to access Windows XP share from Windows 7

After a recent Windows Update I could no longer access the folders on my Windows XP file server. A window popped up asking for a username and password even though they are both the same on the two computers. The error message each time was “Logon failure: unknown username or bad password.”

I typed in my username and password five times. It reached the point where I thought I had gone crazy and was typing in the wrong one: it kept on coming back to me with the dreaded “Logon failure: unknown username or bad password.”.

I quickly returned to my senses and guessed something was up with the authentication between XP and Windows 7. A few Google searches later I found out that a Local Security Policy needs changing.

  • Open the Start menu
  • Type “Local Security Policy” in the search box
  • Open Local Security Policy
  • Navigate to “Local Policies” -> “Security Options” and then locate the entry named “Network security: LAN Manager authentication level”. Double click on it.
  • In the dropdown list choose “Send LM & NTLM – use NTLMv2 session security if negotiated
  • Click OK

It seems that a recent Windows Update has changed that policy’s settings to be undefined, which —from what I can tell— forces NTLMv2 session security always. My XP installation mustn’t have NTLMv2 capability and that is why I kept seeing “Logon failure: unknown username or bad password.” errors.

After changing the local policy I was immediately able to connect to my network shares again.

Links

Posted in Uncategorized | Tagged , , | 10 Comments

Turning screen off with “Access IBM” button

My trusty old T43 has a blue “Access IBM” button just above the F-key row that has sat unused ever since I first reinstalled windows. The other day while browsing the thinkpads.com forums I found an interesting use for this button: turning the screen off.

As time passes, I get more and more conscientious about taking care of my laptop. It recently occurred to me that I needlessly leave the screen on for hours on end, shortening the life of the CCFL backlight. My warranty ran out last year and I’m not planning on buying a new laptop in the near future, so I’m keen on taking good care of it. I could configure the different power plans to turn the display off after X minutes of being idle but the Lenovo Power Manager utility crashes each time I open it, and there is no update for that yet.

Plus, pressing the Access IBM button (which I never use anyway) and having the screen turn off, fading into black, is more fun.

On to the instructions; first we need an executable that turns the screen off and then we need to edit the registry so it is executed when the Access IBM button is pressed.

Executable

Registry edit

To make the Access IBM button do anything when pressed there needs to be a key in the registry for it. Create the following registry key if it doesn’t exist
HKEY_LOCAL_MACHINE\SOFTWARE\IBM\TPHOTKEY\8001
Inside this key create a new string value named “File”. Double click on it and insert the path to the executable in the data field. In my case it was:
C:\\Scripts\\MonitorOff.exe
All done. Pressing the button now turns off the display (the laptop screen and any other display attached) and the ThinkLight. Moving the mouse or pressing a key on the keyboard turns the monitor(s) back on (not the ThinkLight).

Links

Solution: Using ThinkVantage button to turn off monitor – Thread at thinkpads.com forums with original instructions. Credit to yak, the author of MonitorOff.exe

ThinkPad Button – Information about the different Thinkpad buttons in existence at ThinkWiki

Posted in Uncategorized | Tagged | Leave a comment

Revisiting PPPoE forwarding to PfSense

A few months ago I described how I started using PfSense as a proper gateway. I configured my ADSL router to act as just a modem, forwarding the PPPoE tunnel to PfSense. PfSense would then be in charge of everything related to the internet connection.

I initially did it because I was having to restart the ADSL router every so often. It would lock up, not creating any new connections, which annoyed everyone trying to use the internet. The goal was to have a rock-solid connection that didn’t need restarting ever.

A few months have passed and I had forgotten about the last sentence in my initial post: to see whether the situation improved at all, or whether it was still locking up.

During my almost-daily checking up on the site -I am the only visitor, after all. Those stats don’t create themselves!- that last phrase caught my eye and I realised I should follow up, for posterity if nothing else.

The result has been as I’d hoped: I haven’t restarted the ADSL modem or the PfSense box since I set it up. The only downtime has been when the electricity went out, about 57 days, 03:53h ago.

Posted in Uncategorized | Tagged , | Leave a comment

Automounting Windows samba share with autofs – dollar sign and SELinux woes

The target directory for my (well, the one I got from DokuWiki’s wiki vOv) DokuWiki backup script is on a Windows fileserver. I did some searching and the best way to access this share seemed to be using autofs to mount the share only when the local directory it is mapped to is accessed. This way there is no worry that the file server is down when the Linux server boots and tries to mount the network share – which would require manual intervention to resolve (or testing that the share is available in the script). Instead, each time the script is run the share is mounted; and if it does fail for whatever reason hopefully the issue will be fixed for the next execution.

To set up autofs I used the information at this CentOS wiki page. Initially I went with the “Basic Method” because I couldn’t get autofs to work. I later found out that autofs was failing because the share name I was trying to connect to had a dollar sign, which I wasn’t escaping.

After reading the autofs errors in the system log, I caught on to the fact autofs wasn’t even able to find the share, which made me think about having to escape the dollar sign. A few searches later confirmed it, so I tried putting a backslash infront of the dollar sign, which worked. In a way.

Autofs was now spitting out another type of error. SELinux was denying access -like it  always does >:(- to the filesystem or something. Searching the internet didn’t provide me with a conclusive solution (I have no idea how SELinux actually works and it seems like a very broad topic). I decided to just disable SELinux at the start of the backup script, and reenable it at the end. Can’t get much more jerry rigged than that can you?

Posted in Uncategorized | Tagged , , | Leave a comment

Backing up DokuWiki with rotating backups on a samba share

After procrastinating for a while I got down to setting up backups for our DokuWiki installation: it was getting to the point where it had enough useful information that losing it would be a Disaster. I got cold sweats just imagining having to type all that stuff up again.

Some searching later I found this pretty good DokuWiki backup script over at the official wiki. After customising the script and spending a (long) while mounting a remote samba share, I added the script to the crontab on a daily schedule.

It’s now a few weeks later and I have a seven-day rotating set of backups for our documentation, getting backed up both to tape and to a remote fileserver. I had a gander through the backups the other day and noticed, however, that the rotating portion of the script seems to be a bit wonky. Each day’s backup folder seems to have a subfolder with a full backup inside it, a few levels deep. For now it’s not too serious as it’s only a few hundred MB, but it’s something I’ll have to look into.

Next up are my adventures with dollar-sign-in-the-name samba shares and my misadventures with SELinux. For now though it’s bed time, and luckily for me I get to sleep with one less worry on my mind.

Posted in Uncategorized | Tagged , | Leave a comment