Author Archive

I just upgraded my MacBook Pro’s hard drive to one with a bigger capacity. After restoring the contents from the old drive to the new one using an image created by SuperDuper!, I keep on getting this error every time I launch the Terminal application:

dyld: shared cached was built against a different libSystem.dylib, ignoring cache

After googling around, I found this discussion thread from Apple’s Support Forum on how to fix the error:
sudo update_dyld_shared_cache -force
Categories : Mac OS X
Comments (0)
Aug
09

Wish you were here!

Posted by: celso | Comments (0)

… but this is probably the next best thing! :-) Took some panorama shots of the front and back yards today. It’s been a while since I’ve done my last panoramas, so it’s almost like learning from the beginning once again. Anyway, here’s the result and pardon some of the photo misalignments.


Frontyard


Backyard

Note:This requires the Flash Player to view the panoramas. For more information about Flash Player, please visit http://www.macromedia.com/software/flash/about/.If you cannot view the panorama, please download and install the latest version of Flash 10 player.

Categories : General
Comments (0)
Feb
26

Read string from stdin using fgets

Posted by: celso | Comments Comments Off
#include <stdio.h>
#include <string.h>

int main(void)
{
  char str[80];
  int i;

  printf("Enter a string: ");
  fgets(str, 10, stdin);

  /* remove newline, if present */
  i = strlen(str)-1;
  if( str[ i ] == '\n')
      str[i] = '\0';

  printf("This is your string: %s", str);

  return 0;
}
Categories : C
Comments Comments Off
Feb
01

How to determine DST time changes

Posted by: celso | Comments (0)

Here’s how to determine the dates when the Daylight Savings Time changes for a given year (I keep forgetting how to do this.):


zdump -v /etc/localtime|grep 2008 /etc/localtime Sun Mar 9 06:59:59 2008 UTC = Sun Mar 9 01:59:59 2008 EST isdst=0 gmtoff=-18000 /etc/localtime Sun Mar 9 07:00:00 2008 UTC = Sun Mar 9 03:00:00 2008 EDT isdst=1 gmtoff=-14400 /etc/localtime Sun Nov 2 05:59:59 2008 UTC = Sun Nov 2 01:59:59 2008 EDT isdst=1 gmtoff=-14400 /etc/localtime Sun Nov 2 06:00:00 2008 UTC = Sun Nov 2 01:00:00 2008 EST isdst=0 gmtoff=-18000

Obviously, change 2008 to whatever year you want.

Categories : Linux, Mac OS X, Notes
Comments (0)
Jan
10

Uninstall Perl Module

Posted by: celso | Comments (0)

Here's how to cleanly uninstall any Perl module:

#!/usr/local/bin/perl

use ExtUtils::Packlist;
use ExtUtils::Installed;

$ARGV[0] or die "Usage: $0 Module::Name\n";

my $mod = $ARGV[0];

my $inst = ExtUtils::Installed->new();

foreach my $item (sort($inst->files($mod))) {
         print "removing $item\n";
         unlink $item;
}

my $packfile = $inst->packlist($mod)->packlist_file();
print "removing $packfile\n";
unlink $packfile;
Categories : Notes, Perl
Comments (0)
Aug
29

Find Out the Top 10 CPU Hogs

Posted by: celso | Comments (0)

I found this command useful in finding out which top 10 processes are hogging my CPU resources. Note that this command is specific to the Red Hat flavor of Linux. See the man page for ps for the correct output format to use for your specific platform:

ps -eo pcpu,pid,user,args | sort -k1 -r | head -11

Substitue pcpu above with pmem to see the memory hogs instead.

Categories : Linux, Notes
Comments (0)
Aug
28

Bourne Shell Logging Routine

Posted by: celso | Comments (0)

Here’s another logging routine, this one is written in Bourne shell:

#!/bin/sh

log_message() {
    echo `date "+%m/%d/%y %H:%M:%S %Z"` "$1" | tee -a aaa.out
}

log_message "Hello there"
log_message "Goodbye"

Sample output:

08/28/07 23:16:13 EDT Hello there
08/28/07 23:16:13 EDT Goodbye

Categories : Linux, Mac OS X, MySQL, Notes
Comments (0)
Aug
23

Setting MySQL Password

Posted by: celso | Comments (1)

To set up root password the first time:

$ mysqladmin -u root password NeWPasSwORd

To change an existing root password:

$ mysqladmin -u root -p oldpassword newpass
Enter password:

To change a normal user password:

$ mysqladmin -u dbuser-p oldpassword newpass
Categories : MySQL, Notes
Comments (1)
Jul
13

Sorting IP Addresses

Posted by: celso | Comments (0)

The following will sort an array of IP addresses in @in and the sorted IP addresses will be in @out.

@out = sort {
    pack('C4' => $a =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
    cmp
    pack('C4' => $b =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
} @in;

What this does is it forms a string of four bytes out the IP address octet using the pack() function then sorts it lexicographically.

See also Sorting Section Numbers

Categories : Notes, Perl
Comments (0)
Jun
07

Determining the External IP Address

Posted by: celso | Comments (0)

Here’s how to find out your external IP address courtesy of this hint:

http://www.macosxhints.com/article.php?story=20060602180942480


curl --silent http://checkip.dyndns.org
    | awk '{print $6}' | cut -f 1 -d "<"

If you are using Apple's Airport Extreme Basestation (mine is particularly the Time Capsule and this is where I have tested this), and you have the SNMP interface enabled, you can run the following command


prompt$ snmpwalk -Os -c public -v 1 192.168.63.1 ipAdEntAddr IpAddress \
    | grep -E -v '(127.0.0|169.254|192.168.63.1)' \
    | cut -d : -f 2 | sed 's/ //g'
Categories : Linux, Mac OS X, Notes
Comments (0)