Monthly Archive for December, 2005

CLI shortcuts, 5

To get error code of last executed command:

echo $?

Simple script to switch IPs

#!/bin/bash
# Switch IP script, v.1 - iandexter@philrice.gov.ph

CONFIG_DIR=/etc/sysconfig/network-scripts
ROOT_UID=0
ERRROR_XCD=66
ERROR_NOTROOT=67

# Run as root
if [ "$UID" -ne "$ROOT_UID" ]
then
   echo "Must be root to run this script."
   exit $ERROR_NOTROOT
fi

cd $CONFIG_DIR || {
   echo "Cannot change to config dir."
   exit $ERROR_XCD
}

if [ -z "$1" ]
then
   echo "Usage: `basename $0` [afrdis|preginet|globe]"
   exit 1
else
   if grep -q $1 ifcfg-eth0
   then
      echo "Already linked. Not switching anymore."
      exit 0
   else
      echo "Switching to $1 link..."
      cp ifcfg-eth0.$1 ifcfg-eth0
      ifdown eth0
      ifup eth0
      ifconfig eth0
      exit 0
   fi
fi

Drupal modules loaded in CMS

Using the following modules in my Drupal CMS implementation:

  • Archive
  • Attachment
  • BasicEvent
  • Event
  • Excerpt
  • Feedback
  • Filemanager
  • Flexinode
  • Forward
  • Help
  • Image
  • Img_assist
  • Menu
  • Node
  • Nodewords
  • Notify
  • Page
  • Path
  • Pathauto
  • Print
  • RSVP
  • Search
  • Service_links
  • Similar
  • Simplenews
  • Sitemenu
  • Taxonomy
  • Taxonomy_access
  • TinyMCE
  • WatchdogNotify

Up next:

  1. Themeing the front_page. I’ve created a PHP snippet to list and beautify recent news items.
  2. Clean up the code. The HTML source is a mess! Will have to dig deeper into that.
  3. Integrate with Gallery (there’s a Drupal module for this) and MediaWiki (if possible). I wil be needing these apps if I want to make my life easier.
  4. Migrate from the old CMS. Now this will be a pain. Would have to do this manually as the tables are way, way different. Ugh!

Google Maps API experiment, revisited

Apparently, I goofed.

When I visited my Google Maps API project this morning, the map was missing! Thanks to Migs Paraz for pointing that out.

In the previous version, I added a few div items that shouldn’t be there (in the spirit of separating content, presentation and behavior in the code). I cleaned the code a bit: completely separating the Javascript code to another file so the HTML will not be cluttered, and added an if (GBrowserIsCompatible()) check.

The XML is still as it is. Will have to consult with the content developers on what other info to include. And I’m still not sure about the GPS locations because I just gathered the samples from Global Gazetteer Version 2.1. Will have to check with the GIS people on Monday.

For now, here it is. It’s really not that much: there’s a list of interesting points on the left that you can click to display info on the map. I’ll be adding the relevant information soon, such as the websites, statistics and related links. The points, by the way, are some areas where our project is currently working in.

Playing with Google Maps

I’m messing around with the Google Maps API for an app I’ll be deploying for my project.

The idea is to map all available (preferably web-based) information on agriculture in the Philippines. The resulting map can also be used to display other agricultural information resources like available seed stocks, farmers cooperatives, learning centers for extension workers and farmers, etc. For now, I’ll just be displaying the locations.

The (very) alpha app (baby steps here…) uses GPS waypoints from an XML file, then display them as markers on the map, with the corresponding info in the infowindows. Our GIS people here at the office were off on a field study so I couldn’t grab the available GPS data. (Memo to self: suggest a central {shareable} repo for their accumulated data.) I had to grab some sample GPS points from WayPointsDotPH. I use dBoracay for, sort of, my centerpoint in the map. Heh.

There’s plenty of room for improvement. The XML, for example, is flat and could be a lot richer. (Had to snatch the sample XML file from the Google Maps API reference.) The infowindows should also display a lot more, er, info. I’ll look it over during the break. Not! (It’s Christmas, my goodness! :)) But this project is definitely worth the extra hours.