wesley tanaka


Pass PHP variables to Javascript in Drupal 6


To access PHP values and variables from Javascript using Drupal, you can send them to your javascript code using Drupal's drupal_add_js as follows:

drupal_add_js(array('mymodule' => array(
'username' => 'Mike',
'uid' => 123,
'likes' => array('ice cream', 'peanuts', 'coffee'),
)), 'setting');

page not found (404) for all pages in Drupal 6


If Drupal 6 runs into a fatal problem while calling hook_menu(), your site may get into a state where all page views (the front page, the administration page, the modules page, everything) will give a 404/"Page not found"/"The requested page could not be found" error.

You can revive your site by fixing the error that caused the menu rebuild failure and then loading /update.php and completing the upgrade process (even if there are no updates available for any of the modules on your site).

SELinux file_contexts: Multiple different specifications for . . .


Was getting this error when installing/upgrading rpm software packages using yum, restarting mysql and various other tasks:

/etc/selinux/targeted/contexts/files/file_contexts: Multiple different specifications for /var/lib/awstats(/.*)? (system_u:object_r:httpd_sys_script_rw_t:s0 and system_u:object_r:awstats_var_lib_t:s0).
/etc/selinux/targeted/contexts/files/file_contexts: Multiple different specifications for /usr/share/awstats/wwwroot/cgi-bin(/.*)? (system_u:object_r:httpd_sys_script_exec_t:s0 and system_u:object_r:httpd_awstats_script_exec_t:s0).

Finding Drupal content that uses the PHP filter


One new change in Drupal 6.0 is the PHP input format is now a part of an optional module instead of being enabled by default. After upgrading from Drupal 5, you can only disable the new PHP input format module if none of your content uses it. If you would like to determine which nodes, comments, blocks and content might be using the PHP filter so that you can migrate them and turn off the PHP module, keep on reading.

Drupal 5

How to find out which nodes, comments, and blocks use the PHP input format (assumes your database table prefix is drupal_)

But I get exercise from braking


I'd love one of these knee brace regenerative braking electricity generators, so I hope it becomes commercialized and commonplace. But if it does, my prediction is the appearance of a new medical problem: knee brace hamstring atrophy syndrome.

Drop all tables in a MySQL Database


echo DROP TABLE `echo 'SHOW TABLES;' | mysql -u USER -p DATABASE | tail -n +2 | sed -e 's/$/,/'` | sed -e 's/,$/;/'

will output the necessary DROP TABLE command. If you have a my.cnf file (in the current directory) you can run the DROP at the same time with:

echo DROP TABLE `echo 'SHOW TABLES;' | mysql --defaults-file=my.cnf | tail -n +2 | sed -e 's/$/,/'` | sed -e 's/,$/;/' | mysql --defaults-file=my.cnf

Fedora 8 sopcast rpm


My gsopcast binary from ftp.fedora.cn/pub/fedora-cn/linux/7/i386/gsopcast-0.2.10-1.fc7.fcn.y1.i386.rpm was crashing in Fedora 8.

There's a qsopcast rpm that works with Fedora 8 at http://apt.magiclinux.org/magic/2.1/unstable/RPMS.os/, as well as some other useful rpms like an rpm for the BlueDJ games client.

Join multiple adjacent lines into one line in UNIX, Linux


I'm looking for the opposite or the converse of GNU fold — a command line program that would join word-wrapped text into a single line per paragraph. In other words, something that would take input containing adjacent lines of text like this:

now is
the time for
all good men

to come to the
aid of their

where adjacent paragraphs were separated with blank lines, and produce output with one line per paragraph, like this:

Nokia N82


I owned a Mainland Chinese Nokia N82 for two days, which I purchased for 4180 yuan ($575.84) from a Zhongyu Telecom embedded inside the Kunming Jin Ma Fang (金马坊) Park & Shop.

Authentication in China


Many documents in China need to have a company seal affixed to them (盖章) to make them official. From what I can tell, this involves a normal rubber stamp with the name of the company, and a normal red rubber stamp ink pad that you can buy anywhere.

Syndicate content
by Wesley Tanaka