Archive for November, 2009

PHP makes me cry

4am: editing crufty code. lots of logic mixed up in the html old school style. Across the room a pile of three HP servers that need OSes catcalling: “I think I need a rebooty…”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// TODO: Clean this input
//$tpar= $_GET[parent];
$tpar= intval($_GET['parent']);
// TODO: Why are we putting a date into the server array???
$SERVER['$today']= date('y-m-d');
// TODO: Why are we storing a negative integer value as a string???
$colname_res_fillContent = "-1";
if (isset($_GET['parent'])) {
// TODO: Check this input
//$colname_res_fillContent = (get_magic_quotes_gpc()) ? $_GET['parent'] : addslashes($_GET['parent']);
  $colname_res_fillContent = intval($_GET['parent']);
}
// TODO: Why are we storing a negative integer value as a string again???
$today_res_fillContent = "-1";
if (isset($SERVER['$today'])) {
    //
    // TODO: didn't we set this??? why are we doing this??? why not set the date here???
    //
  $today_res_fillContent = (get_magic_quotes_gpc()) ? $SERVER['$today'] : addslashes($SERVER['$today']);
}

Tags: , , ,

BC Gov’t Fail: “bc out of province vehicle inspection”

So it turns out that my blog post on my experience completing a BC “out of province” vehicle inspection is ranking in the top ten results on Google for those keywords. In my opinion, that is a failure of the BC government. It should be straightforward for citizens in this province to find information on how to register a car from a different province. It was difficult enough for me to find this information and I’m a university-trained informatics nerd.

My car was from Ontario. It was about 20 years old and it was going to be driven in Victoria, so it didn’t need an AirCare certificate.

The way I got my car registered in BC was simple. I took my car to a local mechanic who could do the inspection (Parkside Motors – I recommend them if you need a good mechanic in Victoria BC). The car failed but Andrew pointed out how it failed and offered options to get it to pass. The fixes were simple: a new muffler, a rear light, two new tires, etc. After I made the improvements, I brought the car back to the same place and they re-inspected it (for no additional charge) and then gave me two-copies of the certificate. You keep one copy in the car and one copy you give to ICBC. That’s it if you live in Victoria.

The list of things that are checked are found on the form. My main concern was failing the test and then having to pay twice for the inspection, but it turns out that it is pretty standard in the industry to offer a second inspection at no charge if you go back to the same place. Just ask them.

Tags: , , , , ,

Installing Google Go on Mac OS X Leopard

Google released a new programming language named GO that offers the benefits of a dynamic language like Python with the speed of a compiled language like C/C++. In this walkthrough, I’m going to be installing the Google Go programming language on my Mac.

To get started, make sure that you have Python and Mercurial installed on your Intel Mac (PowerPC is not supported at this point). Also make sure that you have XCode installed and that you are attached to the Internet (the test suite will need Internet access to run a few tests).

Trinity:~ kelvin$ python -V
Python 2.5.2
Trinity:~ kelvin$ hg version
Mercurial Distributed SCM (version 1.0.1)

Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Trinity:~ kelvin$ xcodebuild -version
Xcode 3.1.2
Component versions: DevToolsCore-1148.0; DevToolsSupport-1102.0
BuildVersion: 9M2621
Trinity:~ kelvin$ uname -p
i386
Trinity:~ kelvin$

Okay, now we’re going to make some environment variables that Go will use to compile your code. In my home directory, I put the following variables into the ‘.bash_profile’ file:

# Google Go Lang Vars
export GOROOT=$HOME/go
export GOOS=darwin
export GOARCH=386
export GOBIN=$HOME/bin
export PATH=$GOBIN:$PATH

Now we make sure that the environment has the variables we just set up:

Trinity:~ kelvin$ source .bash_profile
Trinity:~ kelvin$ env | grep ^GO
GOBIN=/Users/kelvin/bin
GOARCH=386
GOROOT=/Users/kelvin/go
GOOS=darwin
Trinity:~ kelvin$

Make sure that your ‘~/go’ directory doesn’t exist since the next command will make it into a Mercurial repository. We will be creating the ‘~/bin’ directory after we create the repository.

Trinity:~ kelvin$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
requesting all changes
adding changesets
adding manifests
adding file changes
added 3976 changesets with 16799 changes to 2931 files
updating working directory
1640 files updated, 0 files merged, 0 files removed, 0 files unresolved
Trinity:~ kelvin$ cd $GOROOT
Trinity:go kelvin$ ls
AUTHORS LICENSE doc include misc src
CONTRIBUTORS README favicon.ico lib pkg test
Trinity:go kelvin$ cd src/
Trinity:src kelvin$

Okay, so far we have set-up the environment and the respository. Now would be a good time to ensure the ‘~/bin’ folder actually exists. In many cases, it is already there. If it isn’t there, you need to create it and mark it executable (Hint: Try ‘mkdir ~/bin’ then ‘chmod 755 ~/bin’).

Trinity:src kelvin$ test -e ~/bin && echo 'bin exists'
bin exists
Trinity:src kelvin$

Okay, now we’re ready to build Go.

Trinity:src kelvin$ ./all.bash
rm -f *.o *.6 6.out lib9.a
rm -f bbuffered.o bfildes.o bflush.o bgetc.o bgetrune.o bgetd.o binit.o boffset.o bprint.o bputc.o bputrune.o brdline.o brdstr.o bread.o bseek.o bwrite.o *.6 6.out libbio.a
rm -f *.o *.so
.... holy crap there is a lot of output here...
./mkasmh.sh >386/asm.h.x
mv -f 386/asm.h.x 386/asm.h
8a 386/asm.s
8c -Idarwin -Idarwin/386 -wF cgocall.c
8c -Idarwin -Idarwin/386 -wF chan.c
8c -Idarwin -Idarwin/386 -wF 386/closure.c
8c -Idarwin -Idarwin/386 -wF float.c
8c -Idarwin -Idarwin/386 -wF hashmap.c
8c -Idarwin -Idarwin/386 -wF iface.c
quietgcc -o cgo2c cgo2c.c
./cgo2c malloc.cgo > malloc.c.tmp
mv -f malloc.c.tmp malloc.c
...Two peanuts were walking down the street. One was a salted...
8g -I_obj main.go
8l -L_obj -o ogle main.8

real 0m0.996s
user 0m0.831s
sys 0m0.148s

--- cd ../doc/progs

real 0m2.229s
user 0m1.714s
sys 0m0.431s

--- cd ../test/bench
fasta
reverse-complement
nbody
binary-tree
binary-tree-freelist
fannkuch
regex-dna
spectral-norm
k-nucleotide
mandelbrot
meteor-contest
pidigits
threadring
chameneosredux

--- cd ../test
0 known bugs; 0 unexpected bugs
Trinity:src kelvin$

Okay, so hopefully you now have a working copy of the Go programming language. You can try to find the executables on your system. Your compiler is ‘8g’ if for the i386 architecture.

Trinity:~ kelvin$ which 8g
/Users/kelvin/bin/8g
Trinity:~ kelvin$ which 8l
/Users/kelvin/bin/8l
Trinity:~ kelvin$ 8g
flags:
-I DIR search for packages in DIR
-d print declarations
-e no limit on number of errors printed
-f print stack frame structure
-h panic on an error
-k name specify package name
-o file specify output file
-S print the assembly language
-w print the parse tree after typing
-x print lex tokens
Trinity:~ kelvin$

Notice that ‘gccgo’ is not installed by default; if you want to try that out you need to install it separately. Try working through the examples!

Tags: , , , , ,

The White House Server! W00t!

So President Obama has finally moved whitehouse.gov over to Drupal. Launching Live HTTP Headers tells us the following (emphasis added):

HTTP/1.x 200 OK
Last-Modified: Sat, 07 Nov 2009 05:10:20 GMT
Etag: "b878176b01d8ede48b51ca5b4ede04cf"
Content-Type: text/html; charset=utf-8
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 8956
Cache-Control: must-revalidate, max-age=0
Expires: Sat, 07 Nov 2009 07:01:03 GMT
Date: Sat, 07 Nov 2009 07:01:03 GMT
Connection: keep-alive
Server: White House
P3P: CP="NON DSP COR ADM DEV IVA OTPi OUR LEG"

Downloading me some of that right now!

Tags: , , , ,