MySQL encoding error: Warning (Code 1366): Incorrect string value: '\xE9, a <...' for column 'body' at row 3

While performing a CSV import recently, I ran into the following error messages:

Warning (Code 1366): Incorrect string value: '\xE9, a <...' for column 'body' at row 3
Warning (Code 1366): Incorrect string value: '\xE6. He ...' for column 'body' at row 24
Warning (Code 1366): Incorrect string value: '\xE9, and...' for column 'body' at row 26

The first message was triggered due to the accented é in the word, protegé, in the input. The rest of the field was not imported. The others were similarly triggered.

Changing a file's encoding using Vim

During imports and stuff, it's imperative that all steps utilise the same encoding/character set. If a text file is not using the preferred encoding, we can use Vim to change it during its save action as follows:

:set fileencoding=utf8
:w

or if you want to save it to a different file and leave the current file unchanged:

:w ++enc=utf-8 newfile.txt

Vim does not respect certain regex character classes during substitutions

Just now while attempting to perform a substitution in GVim, I found that the regex was not working as expected. Apparently, instead of matching all non-whitespace characters denoted by the shorthand class \S, the engine was matching the letter S instead, which was odd. It turns out that, as usual, I was the one at fault. What I was doing wrong was attempting to use the character class within [] groups.

Vim runs out of memory during a find and replace

Earlier today, I had to perform a substitution in Gvim within a 2GB file. Unfortunately, after a few thousand operations, Vim ran out of memory with the following error:

  Out of memory!
Out of memory!  (allocating XXX bytes)

Windows too complained about running out of virtual memory and my system slowed down to treacle-like response times.

What is a female guru called?

According to a handy Sanskrit dictionary from the library, the female equivalent of a guru (गुरु) is a gurvi (गुर्वी). This is confirmed to an extent in a couple of places. It is also interesting to note that guru literally means grave or weighty and is cognate with the English word grave.

Upgrading KTorrent in Kubuntu Precise

KTorrent on the LTS release of Kubuntu—Precise Pangolin aka 12.04—is perfectly fine except for the fact that it comes only with version 4.1. Unfortunately, this package is missing a few features that I was looking for, especially the option to add magnet links via its web interface.

Upgrading from 4.1 to 4.3 (the latest version at the time of writing) is pretty straightforward if one is happy to accept PPA sources.

Replacing all occurences of a string in a file with another

In Linux, replacing all instances of a string with another string is easy thanks to sed. A simple example is as follows:

To replace the string foo with the string bar in all .txt files:

PDOException: SQLSTATE[HY000]: General error: 144 Table 'cache_menu' is marked as crashed and last (automatic?) repair failed: DELETE FROM {cache_menu};

While trying to edit a menu on a Drupal site, I found that none of my changes were being saved. Looking at the logs led me to the following error message:

PDOException: SQLSTATE[HY000]: General error: 144 Table 'cache_menu' is marked as crashed and last (automatic?) repair failed: DELETE FROM {cache_menu};

Simply restarting MySQL did not fix things and it looked like I had to get my hands a li'l dirty.

Class 'MollomDrupal' not found

I upgraded the Mollom module on this site from the 7.1.x version to the newer branch of 7.2.x and ran into a White Screen of Death (WSOD). Checking the logs pointed me to the Mollom error:

Class 'MollomDrupal' not found

It's tough to fix this as you might not be able to even log into the site to get to the admin page. Therefore, you will need to disable the module from the database.

Why is a penis also called a cock?

Somebody asked me earlier today why a penis is also called a cock. I assumed that it had something to do with the rooster (the male chicken) being called a cock. While this is true, there's a little bit more to tell. Here's a brief investigation into the matter.

According to Etymonline:

Slang sense of "penis" is attested since 1610s (but cf. pillicock "penis," from c.1300);

Pages

Subscribe to languor.us RSS