Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    Archive for the 'how-to' Category

    WordPress and Google Analytics external nofollow problem in comment links

    13th February 2009

    Since some WP release, the comment author’s link in comments is broken – it has ‘ external nofollow’ attached straight to the href attribute (which breaks the link).

    I assume that the problem is caused by Google Analytics, namely the “track outgoing clicks” feature (as recalled, might be inaccurate feature name). “Track outgoing links” adds some JavaScript code to all outgoing links, and that script has tick characters like this one ‘ which, incidentally, are also used for delimiting the values of comment anchor tags.

    To fix:
    Read the rest of this entry »

    Share

    Posted in CMS, how-to, PHP, Programming, Software, Web | 2 Comments »

    Git: how to remove file and commit from history

    13th February 2009

    Once I accidentally added circa 300 MiB of archive files to one of my git repositories (which was as small as 5 MiB). I removed those files as soon as I noticed them, but the .git directory still preserved commits with those files, and still occupied over 300 MiB.

    I have found the solution at stackoverflow (see also this question).

    This method worked for me, but I couldn’t push my rebased repository to the gitosis. I would need to re-init the gitosis repository from my rebased, but I’m not yet prepared to do that.

    There is also a slightly different method (which relies on a temporary tag instead of a temporary branch), documented in Git online manual pages; I prefer the temporary branch method.

    Below is a full copy-paste of the winning answer by Charles Bailey:

    # create and check out a temporary branch at the location of the bad merge
    git checkout -b tmpfix

    # remove the incorrectly added file
    git rm somefile.orig

    # commit the amended merge
    git commit –amend

    # go back to the master branch
    git checkout master

    # replant the master branch onto the corrected merge
    git rebase tmpfix

    # delete the temporary branch
    git branch -d tmpfix

    Also, in my case this thread at stackoverflow was highly useful. I start enjoying the concise and compact style of Charles Bailey :) :
    Read the rest of this entry »

    Share

    Posted in how-to, Links, Programming | 2 Comments »

    Blog accessibility from handheld and mobile devices

    26th December 2008

    I’ve seen someone reading my blog from a 320×240 handheld device, and realized that it must be pretty inconvenient. Testing my blog with the help of ready.mobi confirmed my worst expectations with a mobile-readiness score of 1.

    I’ve installed and then tested one-by-one a series of WP plugins designed to make your blog mobile-accessible. Testing was done using ready.mobi; all plugins were using default settings – except for viewMobile, which had Images option set to Resize, not Keep As Is.

    pluginscoresize (KiB)min cost (EUR)max cost (EUR)best speed (sec)worst speed (sec)passeswarningsfails
    mowser plugin3.573.420.010.061.012.832114
    viewMobile3.4823.380.070.401.057.672033
    PDA & iPhone2.2324.650.070.421.057.971844
    MobilePress1.7453.980.160.921.1115.081943
    no plugin0.92820.854.801.5570.410610
    Mobilize by MippinN/AN/AN/AN/AN/AN/AN/AN/AN/A

    On Mobilize by Mippin plugin ready.mobi exited with error “Could not retrieve page content”, which is no wonder as Mippin plugin redirects the handheld device’s browser to mippin.com, which converts the page into mobile-accessible form (however, it is indeed strange that mowser.com plugin worked fine, though it is also a redirector). I’ve used mippinmaker to estimate what would my blog look like via mippin – and it appears to me that mippin is using my RSS as the source of content; actually, plugin description explicitly states that. I’m sure this would get real high scores on ready.mobi, but I can’t find the way to test that; thus Mippin plugin didn’t participate in the final feature-based comparison.

    viewMobile plugin is a clear winner best by score in “plugins” group – it has the highest scores in the feature table (well, after mowser plugin, which is not a plugin but a redirector to an external service). Also, in addition to “keep as is” and “downsample”, there is an option to “strip” images – I presume that would bring the page size further down. However, viewMobile removes comment forms from posts; at the same time, PDA & iPhone plugin preserves comment forms – thus it is better for my purposes.

    The mowser-based service has even higher scores than viewMobile – but is an external dependency. For my blog, I decided to stick to PDA & iPhone plugin. Also, such a low page size (see table) is due to mowser splitting the tested main blog page into two pages – and ready.mobi then only weighs the first (much smaller) page; so there is no benefit in page size when using mowser.

    Please comment to share your experience of turning your blog mobile-accessible, or of reading my blog from handheld/mobile devices.

    P.S. If you are used to visiting websites and blogs from your handheld device, and those sites/blogs are not optimized for mobile devices, I’d recommend using the free mowser service (though Opera Mini is easier, I guess).

    P.P.S. This post wasn’t sponsored by mowser or any other mentioned services :)

    Important update: clearly, viewMobile and any other PHP-level mobile accessibility plugins are incompatible with SuperCache. So either (super) caching, or mobile version – but not both. I’ll have to look into possible solutions.

    Update 2

    A “clever” solution would be to have a subdomain or even a different TLD domain for the mobile version of the blog (to avoid SuperCache interference – ideally, both database and files would be the same, but some tiny bit of configuration would make all the difference; the easiest tiny bit would be a mod_rewrite rule). Another good solution would be to modify SuperCache’s mod_rewrite rules, so that mobile User-Agents aren’t fed cached versions – and thus viewMobile has a chance to trigger and serve correct version (this solution doesn’t require another domain or subdomain, but is less reliable).

    I’ve tried mowser plugin, but it suffers from the same cache interference problem (because it is also PHP-level, and SuperCache works at apache and mod_rewrite level). For the same reason, PDA & iPhone plugin wouldn’t work as well.

    For now, I’ve disabled SuperCache (leaving WPCache on), and turned on PDA & iPhone plugin (unlike viewMobile, it does show the comments form below each post). Seems working. Will look into domain/mod_rewrite solutions.

    Update 3

    SuperCache is back on, except for a list of mobile User-Agents; those User-Agents were also added to SuperCache’s UA exclude list. Thus now if a “normal” browser requests a page, such a request is cached, or a cached page is fed to the browser. If the mobile browser requests a page, it is not fed a cached page even if one exists, and cache page is not created while running WP’s PHP engine. Tested using both built-in browser (I could even fill in captcha while commenting) and Opera Mini on a Samsung phone: seems to work fine. However, all of ready.mobi’s phone emulators for some reason choked on the comment form’s textarea, refusing to display the page. I ignore this but if compliance is important then viewMobile will be a better choice than PDA & iPhone.

    Drawbacks of this solution: 1) mobile requests are not cached, 2) if the mobile browser’s User-Agent is not in the list, then it will be fed a standard-looking page, 3) hard to maintain – need to update both the list of UAs in .htaccess and in the configuration of SuperCache.

    Better solutions are welcome.

    Share

    Posted in how-to, Web, WP PlugIns | No Comments »

    How to fix “MySQL server has gone away” (error 2006)

    25th December 2008

    Source: George from vbulletin team.

    Two most common reasons (and fixes) for the MySQL server has gone away (error 2006) are:

    1. Server timed out and closed the connection. How to fix: check that wait_timeout variable in your mysqld’s my.cnf configuration file is large enough. On Debian: sudo nano /etc/mysql/my.cnf, set wait_timeout = 600 seconds (you can tweak/decrease this value when error 2006 is gone), then sudo /etc/init.d/mysql restart. I didn’t check, but the maximal value for wait_timeout might be around 28800 seconds (8 hours).
    2. Server dropped an incorrect or too large packet. If mysqld gets a packet that is too large or incorrect, it assumes that something has gone wrong with the client and closes the connection. You can increase the maximal packet size limit by increasing the value of max_allowed_packet in my.cnf file. On Debian: sudo nano /etc/mysql/my.cnf, set max_allowed_packet = 64M (you can tweak/decrease this value when error 2006 is gone), then sudo /etc/init.d/mysql restart.

    If you get MySQL server has gone away (error 2006) when using MySQL ODBC driver – give this hint a try.

    Share

    Posted in *nix, how-to, Software | 54 Comments »

    How to print a single page from PDF file using Linux command line interface (CLI)

    30th October 2008

    There are several ways to do that, I’ll describe the one which worked for me. Please note, that printing from CLI has an advantage of being able to print out something at work from the comfort of your home and ssh :) (provided that the printer is on and is loaded with paper).

    To extract a single page (or a range of pages), I used pdftops:
    Read the rest of this entry »

    Share

    Posted in *nix, how-to, Software | 2 Comments »

    Concise guide to CPU frequency scaling in Linux

    11th July 2008

    Debian HOW-TO: CPU power management / frequency scaling

    Also as a PDF: Debian how-to: CPU frequency scaling and power management.

    Share

    Posted in *nix, how-to, Links | No Comments »

    Windows XP Home Edition: gpedit.msc (group policy) editing via registry

    15th November 2007

    It is possible to install gpedit.msc snap-in for MMC in Windows XP Home Edition. I found the list of necessary files on pagesperso-orange.fr (in French), which also had the archive of all the necessary (again, French) files and the installation batch-file.

    Warning: you proceed at your own risk. If you do not know what you are doing – please don’t :)

    Download (original) French gpedit-pour-xp-home.zip.

    Download English gpedit for windows xp home.zip (also in 7zip archive).

    Here are instructions for manual MMC snap-in installation. Original French-version archive had a batch file which does installation automatically, which I also added to the English archive (gpedinst.bat). But you must manually verify that batch file fits your system before running it! It might be safer to follow the instructions manually.

    • Put these files:

      appmgmts.dll
      appmgr.dll
      fde.dll
      fdeploy.dll
      gpedit.msc
      gpedit.dll
      gptext.dll

      into %SystemRoot%\system32 folder (most often it’s just c:\windows\system32)

    • put these files:

      system.adm
      inetres.adm
      conf.adm

      into %SystemRoot%\system32\GroupPolicy\ADM\ (create if this folder doesn’t exist)

    • finally, run these commands one by one in the CMD window:

      regsvr32 gpedit.dll
      regsvr32 fde.dll
      regsvr32 gptext.dll
      regsvr32 appmgr.dll
      regsvr32 fdeploy.dll

    That should make gpedit.msc callable as Start -> Run -> gpedit.msc.

    Other language versions of the necessary files can be retrieved from corresponding-language installations of WinXP Professional; English version can also be downloaded directly from Microsoft website ( e.g. here , or search for “Group Policy ADM Files” at microsoft.com). Also, you can extract necessary files from available Windows distributions: just don’t forget, that “filename.dl_” is a compressed version of “filename.dll”, and can be uncompressed by using XP-bundled extract command.

    See also this comment for alternative gpedit installation (get the file from badongo first), and also this comment for one more explanation of manual installation.

    Geeks corner:

    1. a comprehensive list of the “Group Policy/User Configuration/Administrative Templates” settings in Windows XP Home Edition
    2. an extremely comprehensive Excel sheet, which maps numerous *.adm-file options to their registry equivalents – Group Policy Settings Reference (PolicySettings.xls). This file is for Windows 2000, Windows XP, and Windows 2003

    Disclaimer: I do not know if modifying (e.g. by adding gpedit) your WinXP HE is a violation of any EULAs. It’s your own responsibility to check this out and comply with any such regulations. Also, be advised that modifying any settings using gpedit.msc on WinXP HE may render some parts of the OS inoperable (in my opinion). You have been warned!

    Share

    Posted in how-to, Links, Notepad, Software | 91 Comments »