Archive

Author Archive

How To Fix “The total number of locks exceeds the lock table size”

March 4th, 2010 Masao No comments

This usually happens when you’re doing massive queries on InnoDB tables:

ERROR 1206 (HY000): The total number of locks exceeds the lock table size

In /etc/my.cnf, do something like this:

innodb_buffer_pool_size=524288000

By default, MySQL sets innodb_buffer_pool_size to 8MB.

500 megabytes = 524 288 000 bytes

Categories: Linux, MySQL Tags:

Atlas Remote Add 15-Second Back

February 26th, 2010 Masao No comments

Most Comcast remotes have a counter-clockwise curly arrow that is pre-programmed for this code.

1. Press the “Cable” button at the top of the remote to put it into Cable Box control mode.
2. Press and hold the “Setup” button until the “Cable” button blinks twice.
3. Type in the code 994. The “Cable” button will blink twice.
4. Press (do not hold) the “Setup” button.
5. Type in the code 00179.
6. Press whatever button you want to map the 15-second back command to (ex: A / Lock). The “Cable” button will blink twice if successful.

‘Note: To reprogram a “One For All” remote please see this page– http://www.hifi-remote.com/ofa/advanced.shtml

Categories: Cable Tags:

Atlas Remote Add 30-Second Skip

February 26th, 2010 Masao No comments

Add 30-Second Skip

The following technique can be used to map an unused or unneeded button on the “silver” remote to the 30-second skip command. Current versions of the i-Guide software will skip forward 30 seconds into a recording when this command is sent. A good choice is the ‘A / Lock’ button since many users don’t need that function; you can feel both the ‘15-second-back’ and ‘30-second-skip’ buttons with one finger and move between them without looking. Another option is to reprogram the ‘15-second back’ button, since PgDn already provides that functionality. Some users have found, however, that double-clicking the play button results in a 30-second skip forward.

1. Press the “Cable” button at the top of the remote to put it into Cable Box control mode.
2. Press and hold the “Setup” button until the “Cable” button blinks twice.
3. Type in the code 994. The “Cable” button will blink twice.
4. Press (do not hold) the “Setup” button.
5. Type in the code 00173.
6. Press whatever button you want to map the 30-second skip command to (ex: A / Lock). The “Cable” button will blink twice if successful.

Note: This did not work on boxes with the Microsoft TV Foundation Interface (previously used in Washington State, but now converted back to the i-Guide software). As of firmware version 12.22 Insight Cable disabled this feature, but has been re-enabled in firmware version 16.35. Comcast software Version 73.44 disabled this feature, but the latest software, Version 74.53-3321, re-enables it (this has been confirmed on the 3416 w/ 16.20 firmware). See software for more info.

Note: As of software A25.2-2, the Page Up key is removed from some operators and others have programmed it as a 5 min skip.

Note: This code does work for the PACE TDC577X (vegas) standard def DVR with Comcast service (SW version 75.69-a25p2-2S1.r-8).

Categories: Cable Tags:

How To Add Quick Launch Toolbar in Windows 7

February 18th, 2010 Masao No comments

Windows 7 does not have the QuickLaunch toolbar enabled by default. Here’s how to add it:

  • Right-click the taskbar, then click “New Toolbar”
  • In the Folder input field, copy and paste the following line:
%userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick  Launch
  • Click “Select Folder”
  • Unlock the taskbar.
  • Right click the Quick Launch toolbar and uncheck “Show Text” and “Show Title”.
  • Drag the Quick Launch toolbar to the desired location.
  • Double-click the dotted edge of the toolbar to auto-size the toolbar to the width of the icons.

Done!

Categories: Windows Tags:

How To Fix “Metadata file does not match checksum” YUM error

December 30th, 2009 Masao No comments
# yum install -y ImageMagick-perl
Loaded plugins: fastestmirror
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package ImageMagick-perl.i386 0:6.2.8.0-4.el5_1.1 set to be updated
filelists.xml.gz                                                             | 3.9 MB     00:09
http://apt.sw.be/redhat/el5/en/i386/rpmforge/repodata/filelists.xml.gz: [Errno -1] Metadata file does not match checksum
Trying other mirror.
filelists.xml.gz                                                             | 3.9 MB     00:29
http://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/i386/rpmforge/repodata/filelists.xml.gz: [Errno -1] Metadata file does not match checksum
Trying other mirror.
filelists.xml.gz                                                             | 3.9 MB     00:12
http://fr2.rpmfind.net/linux/dag/redhat/el5/en/i386/rpmforge/repodata/filelists.xml.gz: [Errno -1] Metadata file does not match checksum
Trying other mirror.
Error: failure: repodata/filelists.xml.gz from rpmforge: [Errno 256] No more mirrors to try.

Run the following commands:

yum clean all
yum makecache
yum update

Then, it should work:

# yum install -y  ImageMagick-perl
Loaded plugins: fastestmirror
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ImageMagick-perl.i386 0:6.2.8.0-4.el5_1.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                      Arch             Version                       Repository        Size
====================================================================================================
Installing:
 ImageMagick-perl             i386             6.2.8.0-4.el5_1.1             base             145 k

Transaction Summary
====================================================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)         

Total download size: 145 k
Downloading Packages:
ImageMagick-perl-6.2.8.0-4.el5_1.1.i386.rpm                                  | 145 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ImageMagick-perl                                                             1/1 

Installed:
  ImageMagick-perl.i386 0:6.2.8.0-4.el5_1.1                                                         

Complete!
Categories: YUM Tags:

Perl Version of PHP’s “ucwords” Function

December 15th, 2009 Masao 1 comment
my $string = 'this is a string of text';
$string =~ s/\b(\w+)\b/ucfirst($1)/ge;
print "$string\n";
Categories: PHP, Perl Tags:

How To Merge PHP Objects

December 12th, 2009 Masao No comments
foreach($objectA as $k => $v) $objectB->$k = $v;
Categories: PHP Tags:

How To Change Your CPAN urllist

September 17th, 2009 Masao No comments

# cpan
cpan> o conf init

Connecting to ftp.perl.org|64.27.65.115|:21… connected.
Logging in as anonymous … Logged in!
==> SYST … done. ==> PWD … done.
==> TYPE I … done. ==> CWD /pub/CPAN … done.
==> SIZE MIRRORED.BY … 140951
==> PASV … done. ==> RETR MIRRORED.BY … done.
Length: 140951 (138K)

100%[===========================================================>] 140,951 374K/s in 0.4s

17:21:36 (374 KB/s) – `-’ saved [140951]

Now we need to know where your favorite CPAN sites are located. Push
a few sites onto the array (just in case the first on the array won’t
work). If you are mirroring CPAN to your local workstation, specify a
file: URL.

First, pick a nearby continent and country (you can pick several of
each, separated by spaces, or none if you just want to keep your
existing selections). Then, you will be presented with a list of URLs
of CPAN mirrors in the countries you selected, along with previously
selected URLs. Select some of those URLs, or just keep the old list.
Finally, you will be prompted for any extra URLs — file:, ftp:, or
http: — that host a CPAN mirror.

(1) Africa
(2) Asia
(3) Australasia
(4) Central America
(5) Europe
(6) North America
(7) Oceania
(8) South America
Select your continent (or several nearby continents) []

Categories: Everything Else Tags:

How to Install Flash Firefox Plugin for 64-bit Fedora Linux

September 13th, 2009 Masao No comments
  1. Download the plugin here.
  2. Tar -zxvf the tar.gz file.
  3. Copy that file to: /usr/lib64/mozilla/plugins
  4. Restart firefox.
  5. Check “about:plugins” in your address bar to see the Flash plugin installed

Plugin file should look like this:

/usr/lib64/mozilla/plugins/libflashplayer.so

about:plugins should look like this:

Shockwave Flash

File name: nswrapper_64_64.libflashplayer.so
Shockwave Flash 10.0 r32

Categories: Firefox, Flash, Linux Tags:

No recognized SSL/TLS toolkit detected

September 5th, 2009 Masao No comments

While running Apache configure, if you get this error:

No recognized SSL/TLS toolkit detected

…do this:

yum install -y openssl-devel # Required for Apache configure

Categories: Errors Tags:

How To Add a MySQL Column with Index

September 5th, 2009 Masao No comments

ALTER TABLE mytable
ADD mycolumn INT UNSIGNED NOT NULL AFTER othercolumn ,
ADD INDEX ( mycolumn );

Categories: MySQL Tags:

How To Fix a Perl Memory Leak

September 3rd, 2009 Masao No comments

If you’re using HTML::TreeBuilder, you might find a memory leak when creating lots of trees. You must explicitly delete the trees because HTML::Tree does not use weak refs. Here’s how to delete the ref:

use HMTL::TreeBuilder;

my $formatter = HTML::FormatText->new();

my $html_tree = HTML::TreeBuilder->new_from_content($line);
my $plain_text = $formatter->format($html_tree);
$html_tree->delete();

Or if you use HTML::Parse:

my $html_tree = parse_html($line);
$html_tree->eof();
my $plain_text = HTML::FormatText->new()->format($html_tree);
$html_tree->delete();

Or using Object::Destroyer

use Object::Destroyer;

my $html_tree = parse_html($line);
$html_tree = Object::Destroyer->new($html_tree, ‘delete’);
$html_tree->eof();

my $plain_text = HTML::FormatText->new->format($html_tree);

Source: perlmonks.org

Categories: Perl Tags:

How To Determine Directory of Sourced Bash Script

September 2nd, 2009 Masao No comments

Sourcing a script can be useful for exporting variables in the current shell.

However, you can’t use “dirname $0″ to get the directory of the script.

Here’s how to get the same effect of dirname, but still allowing you to export variables.

Relative path:

DIRNAME=${BASH_ARGV[0]%/*}

Full path:

ABSDIR=$PWD/${BASH_ARGV[0]%/*}

Categories: Bash, Linux Tags:

Hotel Room Problem

August 28th, 2009 Masao 1 comment

Three men decided to split the cost of a hotel room. The hotel manager gave them a price of $30.

The men split the bill evenly, each paying $10, and went to their room. However, the hotel manager realized that it was a Wednesday night, which meant the hotel had a special: rooms were only $25. He had overcharged them $5!

He called the bellboy, gave him five one-dollar bills and told him to return it to the men.

When the bellboy explained the situation to the men, they were so pleased at the honesty of the establishment that they promptly tipped the bellboy $2 of the $5 he had returned and each kept $1 for himself.

So each of the three men ended up paying $9 (their original $10, minus $1 back) totaling $27, plus $2 for the bellboy which makes $29. So where is the missing dollar?

Categories: Cool Problems Tags:

How To Redirect STDERR to STDOUT in Perl

August 28th, 2009 Masao 1 comment

Redirecting STDERR to STDOUT in Perl:

open STDERR, '>&STDOUT';

Reassign raw file handles:

*STDERR = *STDOUT;

Redirect all output to a logfile:

open(LOG,">/tmp/foo.log");
*STDERR = *LOG;
*STDOUT = *LOG;

Example:

#!/usr/bin/perl
use strict;
use warnings;
warn "regular error";
open STDERR, '>&STDOUT';
warn "redirected error";

Output:

[kitamura@web3 perl]$ ./stderr.pl 2>/dev/null
redirected error at ./stderr.pl 6.
Categories: Perl Tags:

Failure: The Secret to Success

August 23rd, 2009 Masao No comments

Categories: Everything Else Tags:

How to Fix an Empty Bash Shell Prompt

August 21st, 2009 Masao No comments

If you bash shell prompt is empty when logging in, here’s how to fix it.

Create a ~/.bashrc file:

if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

Create a ~/.bash_profile file:

if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi
Categories: Bash, Linux Tags:

Burning Rope Problem

August 13th, 2009 Masao 1 comment

You have two ropes that each burn for 1 hour end to end, but at varying rates.

You have a lighter. You cannot cut the ropes (and doing so wouldn’t help, since they burn at unknown rates and you only know total burn time).

How do you measure 45 minutes?

Categories: Cool Problems Tags:

8 Bricks Problem

August 13th, 2009 Masao 1 comment

You have 8 bricks, but one of them is lighter than the rest.

You have a balance you can only use twice.

How do you find the lighter brick?

Categories: Cool Problems Tags:

Monty Hall Problem

August 13th, 2009 Masao 1 comment

Of three options, you have a 1/3 chance of picking the “right” option.

If you pick one at random, then a single “wrong” option is eliminated, should you switch and why?

Categories: Cool Problems Tags: