October 2008

Show hidden files for OS X

    
    defaults write com.apple.finder AppleShowAllFiles TRUE

    killall Finder
    
Share

os x

Comments Off

Permalink

Install of mono 2.0 failed on OS X PowerBook G4

I just tried to install mono version 2 from darwin ports.

Before starting i uninstalled the mono i had already:


#!/bin/sh -x
#This script removes Mono from an OS X System.  It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-SVN.pkg
cd /usr/bin
for i in `ls -al | grep Mono | awk '{print $9}'`; do
rm ${i}
done

First i could search for the mono package by typing

$ port search mono

To begin with this did not show the right version so i did :

$ port selfupdate

This checks for a new version of port and updates its list of available software.

now i see:


coco:~ Jim$ port search mono
mono                           devel/mono     2.0          Implementation of the .NET Development Framework
mono-addins                    devel/mono-addins 0.3          Mono.Addins is a framework for creating extensible applications
monodoc                        devel/monodoc  2.0          Documentation for the Mono .NET Development Framework
monotone                       devel/monotone 0.41         A distributed version control system
mod_mono                       www/mod_mono   1.1.16.1     an Apache plug-in for hosting the Mono System.Web classes
coco:~ Jim$

so all good, i ran

port install mono

but get :


darwin_stop_world.c:307: error: 'ppc_thread_state_t' has no member named '__r31'
make[3]: *** [darwin_stop_world.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

A quick search on google brought this:

http://lists.macosforge.org/pipermail/macports-tickets/2008-February/005279.html

The instructions here talk about editing this darwin_stop_world.c file and changing some constant values. They give the path to the file for an older version but a bit of ls ing turned up the new folder:

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mono/work/mono-2.0/libgc/darwin_stop_world.c

Ok, so now the tricksy bit…

The instructions in the above link talk about some constants not set up correctly. On the line wher ei saw my exception, it was referring to the following bit of code:


#elif defined(POWERPC)
#if defined(_STRUCT_PPC_EXCEPTION_STATE)
	lo = (void*)(state.__r1 - PPC_RED_ZONE_SIZE);

	GC_push_one(state.__r0);
	GC_push_one(state.__r2);
	GC_push_one(state.__r3);
	GC_push_one(state.__r4);
	GC_push_one(state.__r5);
	GC_push_one(state.__r6);
	GC_push_one(state.__r7);
	GC_push_one(state.__r8);
	GC_push_one(state.__r9);
	GC_push_one(state.__r10);
	GC_push_one(state.__r11);
	GC_push_one(state.__r12);
	GC_push_one(state.__r13);
	GC_push_one(state.__r14);
	GC_push_one(state.__r15);
	GC_push_one(state.__r16);
	GC_push_one(state.__r17);
	GC_push_one(state.__r18);
	GC_push_one(state.__r19);
	GC_push_one(state.__r20);
	GC_push_one(state.__r21);
	GC_push_one(state.__r22);
	GC_push_one(state.__r23);
	GC_push_one(state.__r24);
	GC_push_one(state.__r25);
	GC_push_one(state.__r26);
	GC_push_one(state.__r27);
	GC_push_one(state.__r28);
	GC_push_one(state.__r29);
	GC_push_one(state.__r30);
	GC_push_one(state.__r31);
#else

in the post, he seemed to simply remove all the ‘__’ underscores and it worked… so:


	#if defined(_STRUCT_PPC_EXCEPTION_STATE)
		lo = (void*)(state.r1 - PPC_RED_ZONE_SIZE);

		GC_push_one(state.r0);
		GC_push_one(state.r2);
		GC_push_one(state.r3);
		GC_push_one(state.r4);
		GC_push_one(state.r5);
		GC_push_one(state.r6);
		GC_push_one(state.r7);
		GC_push_one(state.r8);
		GC_push_one(state.r9);
		GC_push_one(state.r10);
		GC_push_one(state.r11);
		GC_push_one(state.r12);
		GC_push_one(state.r13);
		GC_push_one(state.r14);
		GC_push_one(state.r15);
		GC_push_one(state.r16);
		GC_push_one(state.r17);
		GC_push_one(state.r18);
		GC_push_one(state.r19);
		GC_push_one(state.r20);
		GC_push_one(state.r21);
		GC_push_one(state.r22);
		GC_push_one(state.r23);
		GC_push_one(state.r24);
		GC_push_one(state.r25);
		GC_push_one(state.r26);
		GC_push_one(state.r27);
		GC_push_one(state.r28);
		GC_push_one(state.r29);
		GC_push_one(state.r30);
		GC_push_one(state.r31);
	#else

This was defined on lines 130 and 273

the second one now looks like :

	
		#if defined(_STRUCT_PPC_EXCEPTION_STATE)
			lo = (void*)(info.r1 - PPC_RED_ZONE_SIZE);
			hi = (ptr_t)FindTopOfStack(info.r1);

			GC_push_one(info.r0);
			GC_push_one(info.r2);
			GC_push_one(info.r3);
			GC_push_one(info.r4);
			GC_push_one(info.r5);
			GC_push_one(info.r6);
			GC_push_one(info.r7);
			GC_push_one(info.r8);
			GC_push_one(info.r9);
			GC_push_one(info.r10);
			GC_push_one(info.r11);
			GC_push_one(info.r12);
			GC_push_one(info.r13);
			GC_push_one(info.r14);
			GC_push_one(info.r15);
			GC_push_one(info.r16);
			GC_push_one(info.r17);
			GC_push_one(info.r18);
			GC_push_one(info.r19);
			GC_push_one(info.r20);
			GC_push_one(info.r21);
			GC_push_one(info.r22);
			GC_push_one(info.r23);
			GC_push_one(info.r24);
			GC_push_one(info.r25);
			GC_push_one(info.r26);
			GC_push_one(info.r27);
			GC_push_one(info.r28);
			GC_push_one(info.r29);
			GC_push_one(info.r30);
			GC_push_one(info.r31);
		#else
	

Watch out for the top of stack one! its an extra one.

ok this works!

I had to restart the terminal because it didnt seem to find the new programs – it still thought mcs lived in /usr/bin not /opt/local/bin which is where port puts it.

Now i can compile c# version 3.0!!

oh yeah, be sure to use gmcs to compile, not mcs which is the old one.

Share

c#
code
os x
thoughtblog
thoughtworks

Comments Off

Permalink

Can Agile Scale ?

I just received this link from Tom Marsh at the guardian, its quite an interesting article and thought it would be worth publicising on our blog.

http://www.theregister.co.uk/2008/10/08/scaling_agile_development_poll_200810/

enjoy.

Share

agile
thoughtblog
thoughtworks

Comments Off

Permalink

Format a SQL String nicely (and simply)

After playing with regular expressions in notepad+, we were writing some tests around a SQL based query language and wanted to print out the queries nicely.

We came up with the remarkably simply yet effective use of String.replace() to create the following:


     String querystring = getSomeQueryString();
     System.out.println(queryString
                .replaceAll("WHERE", "\\nWHERE")
                .replaceAll("AND", "\\n\\tAND")
                .replaceAll("OR", "\\n\\t\\tOR"));

Well it worked for ours, think might need some adjustment for different OR / AND structures.

Share

code
databases

Comments Off

Permalink

Referential transparency

Just learned this term.

from wikkipedia

basically if a function can be evaluated and then replaced by that value in the algorithm, it is referentially transparent

e.g. the function plusOne(int x) { return x + 1; } is referentially transparent as it will always return the same value for each value of x.

e.g. the function today() is not transparent because if you replaced it on one day with its value of “25th July 2008″ and then ran the program on a different day the result of the progam would be different.

easy eh?

Share

code
design

Comments Off

Permalink