Drupal - Bulk updating Pathauto node aliases through cron job

  1. Create the following file(e.g. cron-update-pathauto.php) in your drupal's root directory.
    <?php
    include_once './includes/bootstrap.inc';
    include_once './sites/all/modules/pathauto/pathauto.inc';
    include_once './sites/all/modules/pathauto/pathauto_node.inc';
     
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
     
    _pathauto_include();
    // variable_set('pathauto_max_bulk_update', 5000);
    node_pathauto_bulkupdate();
    ?>  
     

Drupal - Reduce memory used by the cron job and the time it takes to run

Symptoms

  • When you look at your Recent log entries, you are seeing the message Cron run exceeded the time limit and was aborted.
  • When you run the cron job manually(e.g. http://yoursite.com/cron.php), you are seeing the message Allowed memory size of ######## bytes exhausted (tried to allocate ####### bytes).

Solutions

For the sake of your tiny and low resource shared hosting webserver, change the following module's settings to reduce the memory used by the cron job and the time it takes to run:

Drupal - Theme a specific CCK field

See excellent tutorial:
http://www.advantagelabs.com/drupal-colonoscopy-or-how-theme-cck-field-drupal-6

Important: In your theme directory, it must content-field.tpl.php file.

Drupal - Setting Cron job

Setting cron job to avoid the infamous message "Cron run exceeded the time limit and was aborted", see
http://acquia.com/blog/s-files-cron-run-exceeded-time-limit-and-was-aborted

wget -O - -q -t 1  http://localhost/cron.php

SQL - Got a packet bigger than 'max_allowed_packet' bytes

When you are importing a huge *.sql file into MySQL, it sometimes shows the following error message:

mysql -u root -p databasename < huge.sql
ERROR:...Got a packet bigger than 'max_allowed_packet' bytes ...

Simply open my.ini and increase max_allowed_packet and net_buffer_length variables.
max_allowed_packet = 10M
net_buffer_length = 2M

Update: 2010-08-17:

DocBook - Generate another version of DocBook for your customer

Sometimes you want to generate a different version of your docbook for your customer. In my case, I was using the common attribute role to flag the content that I don't want the customer to see. Therefore, I set the role="NotForClient" on all nodes that I don't want my customer to see. Then, I apply an XSL sheet to remove those nodes.

Here is the XSL file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <!-- Copy everything -->

DocBook - Customize GUI elements

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format" 
	version="1.0">
 
 
  <xsl:template match="guibutton">
    <fo:inline border="1px outset #dddddd"
               background-color="#dddddd">
      <xsl:call-template name="inline.charseq"/>
    </fo:inline>
  </xsl:template>
 
</xsl:stylesheet>

Bash - Test if file/directory exists

#!/bin/bash
 
# Create a file
touch myfile.txt
 
# Create a directory
mkdir mydirectory
 
 
if [ -f myfile.txt ]
then
  echo "myfile.txt exists!"
fi
 
if [ -d mydirectory ]
then
  echo "mydirectory exists!"
fi

Bash - Get filename without extension

#!/bin/bash
 
# Description: Get filenme without extension.
# Author: Xuan Ngo
#############################################
 
filename=my_filename.txt
echo ${filename}
 
# Length of .txt is equal to 4
let fileLength=${#filename}-4
filenameWithNoExt=${filename:0:${fileLength}}
 
echo ${filenameWithNoExt} 
 
# Output:
#  my_filename.txt
#  my_filename

Varia - Microsoft Virtual PC

When Microsoft Virtual PC shutdowns by itself for no apparent reason, check for the following error message in Control Panel->Administrative Tools->Event Viewer->Application:

Faulting application Virtual PC.exe, version 6.0.192.0, time stamp 0x4822fe31, faulting module Virtual PC.exe, version 6.0.192.0, time stamp 0x4822fe31, exception code 0xc0000005, fault offset 0x000424e2, process id 0xc58, application start time 0x01cabc27053164bc.

Syndicate content