Friday, January 23, 2009

Script to convert MAC Address to format used by PXELinux

This script takes CCCC.CCCC.CCCC or CC:CC:CC:CC or cc:cc:cc:cc and spits out

01-cc-cc-cc-cc for a PXELinux MAC address file on the "first network segment."

#!/bin/sh
# Name: pxemac
# Usage: pxemac ${MAC Address}

OS=`uname -s`

type () {

  TYPE=`echo $1 | sed s/[A-Za-z0-9]*//g`
  if [ "$TYPE" = ".." ]
  then
    return 0
  else
    return 1
  fi

}

linux () {

  if type $1
  then
    echo $1 | sed -e "s/\./-/g" -e "s/^/01-/" -e "s/-[A-Za-z0-9]\{2\}/&-/g" | tr A-Z a-z
  else
    echo $1 | sed -e "s/\:/-/g" -e "s/^/01-/" | tr A-Z a-z
  fi

}

nonlinux () {

  if type $1
  then
    echo $1 | sed -e "s/\./-/g" -e "s/^/01-/" -e "s/-[A-Za-z0-9]\{2\}/&-/g" | tr [A-Z] [a-z]
  else
    echo $1 | sed -e "s/\:/-/g" -e "s/^/01-/" | tr '[A-Z]' '[a-z]'
  fi

}

if [ "$OS" = "Linux" ]
then
  linux $1
else
  nonlinux $1
fi

Tuesday, January 20, 2009

New word from Todd Keck (industrial designer): Crapht

Crapht (crap + craft): Something constructed by an artisan that has high production values, but very little substance.

As in:

His code is really well commented and nicely structured, but if you look deeper, it's just crapht.

or

That new artist's latest show was advertised as art, but was mostly just crapht. (courtesy of Todd Keck)

(Goes with this site nicely :)

-ghostis