Wednesday, October 29, 2008

Transform a Twiki Table

I needed to change a TWiki table to make the rows become columns and columns become rows.

Ruby + 5 mins =

table = <<-TABLE
...paste table here...
TABLE

rows = (table.split "\n").collect { |line| line.split("|") }
puts (0.. rows[1].length).each { |col| puts "|#{rows.collect{ |row| row[col] }.join("|")}|" }

Ahhhh.. That could have been painful.

I love being a programmer. How do people that don't code handle this sort of problem?

Document-oriented Data Storage

There seems to be new interest in the concept of storing data as documents instead of tables. This is the approach that Lotus Notes took. Here is what I ahave found out so far...

A 'document' is basically a hashtable. You can store values with keys. Solutions then seem to take the Google "Map Reduce" approach to querying the data.

CouchDB allows you to define views. A view contains the results of executing a specified javascript function against each document. This is equivolent to the Google 'Map' step.

RDDB (a ruby implementation) provides for both steps...
  # First create an database object
database = Rddb::Database.new

# Put some documents into it
database << {:name => 'John', :income => 35000}
database << {:name => 'Bob', :income => 40000}
database << {:name => 'Jim', :income => 37000}

# Create a view that will return the names
database.create_view('names') do |document, args|
document.name
end

# The result of querying will return an array of names
assert_equal ['John','Bob','Jim'], database.query('names')


"Map Reduce" scales really well across machines, so I am keen to see where this goes.

I'll let you know what I find out.

Anyone got any pointers?

Tuesday, October 28, 2008

Dos Prompt for Long Paths

If you have to work with DOS at some point you find the display muddled due to deep directory trees cluttering your display.

A simple solution is setting the environment variable PROMPT=$p$_$+$g

This just adds a newline to the end of the prompt.. but makes all the difference.

Thanks to Florin Lazar for this tip

Using Outlook like Gmail 2

I forgot to mention...
Install GoogleDesktop to get much better searching through your emails.

Tuesday, October 07, 2008

Using Outlook like Gmail

I love GMail's 'Archive' feature. I wanted the same in Outlook which I am currently forced to use. So...

Sub Archive()
Dim myItem
For Each myItem In Application.Explorers.Item(0).Selection
myItem.UnRead = False
myItem.Move (Application.Explorers.Item(1).CurrentFolder().Parent.Folders("Archive"))
Next
End Sub


This little macro marks the current selected item(s) read and moves them to the 'Archive' folder (that you will need to create at the top level).

I also added a button to run the macro and called it "&XArchive" so I can go Alt+X to archive the currently selected mail item.

Works for me..
If anyone can be bothered to get it to work for all selected items that would be cool. Done...

Oh, I'm using Outlook 2000. You may need to change the macro for other version.
Let me know :)

Wednesday, October 01, 2008

Don't Drop the Bar!

You're hiring... you make a list of mandatory skills and some preferred ones. You interview someone... they don't get ticks in all the mandatory fields... so easy decision. They are mandatory! You have to say no.

Now... some time passes... you are interviewing people, but no-one seems to be passing the bar. Time is running out. You have to staff your project or it won't be viable. What do you do?

What would you do?

My thought for the day..

Staffing a project with the wrong people WILL LEAD TO FAILURE! Usually a slow, expensive failure. Having the project canceled because it wasn't viable is a much better business decision, and in the long run may save the company (and your job).

GitHub Projects