I decided to move all my code from svn to git after I started using GIT with github.com last week. However github plan to charge for private repositories soon so I decided to migrate from github to my slicehost server for private repositories and use github for any public repositories.

This post assumes you already have git installed on you local machine

First of all you will need to install git

apt-get install git-core

Then get you public key and add it to the authorised keys for your github account

cat ~/.ssh/id_rsa.pub 

Now clone your repository to your server

git clone git@github.com:GITHUB-USER/REPOSITRY.git /git/REPOSITRY.git

Now clone to you local machine, im using ssh for this as I have the keys setup

git clone git+ssh://USER@YOUR-SERVER.COM/git/REPOSITRY.git REPOSITRY

That should be it, you will now be able to push to your server instead of git hub.

git push origin master

To make commit messages a little easier you can set a git editor, edit this file

mate ~/.bash_login

and add this line

export GIT_EDITOR="mate -w"

Today I decided to finally open my Erlang book, below are some quick instructions on how to install Erlang on OS X 10.5

You will need to install Xcode (you can download from apple)

Install commands

I like to keep all my source files in /usr/local/src you can change this directory if you like to keep them elsewhere

cd /usr/local/src
curl -O http://www.erlang.org/download/otp_src_R12B-0.tar.gz
tar xzvf otp_src_R12B-0.tar.gz
cd otp_src_R12B-0
./configure --prefix=/usr/local
make
sudo make install

Erlang Shell

Now we can check Erlang was installed correctly, lets launch the Erlang shell

erl

We should now have an Erlang shell that we can type some expressions into

4*5.
11*99.

Other Methods

You can also install using Fink (slightly out of date version) and Mac ports

After failing to learn the guitar over the past 3 years I decided to try drawing instead.

Pete Doherty

I have edited the contrast in this pic (which makes it look a lot better) as I currently have 1 pencil so shading is proving hard.

I have some more sketch's over at Flickr

desc "Load production data into development database"
task :load_production_data, :roles => :db, :only => {:primary => true} do
  
  database = YAML::load_file('config/database.yml')
 
  file_name = "production.#{Time.now.strftime "%Y-%m-%d_%H:%M:%S"}.sql"
  file_path = "db/"
 
  run "mysqldump -u #{database['production']['username']} --password=#{database['production']['password']} #{database['production']['database']} > /tmp/#{file_name}" do |channel, stream, data|
    puts data
  end
  
  get "/tmp/#{file_name}", "#{file_path}#{file_name}"
  run "rm /tmp/#{file_name}"
  
  system "mysql -u #{database['development']['username']} --password=#{database['development']['password']} #{database['development']['database']} < #{file_path}#{file_name}; rm -f #{file_path}#{file_name}"
end

I've wanted to send football updates via Twitter for a while now, but never found the time to do it. Today I made a quick Rails app that parses an xml file from skysports and then sends alerts to twitter using the Twitter4R gem, I run it a few times and it worked well.

At the moment it is running of my desktop so it's not posting updates unless I run the script, some of the code is pretty messy but its not bad for an hour.

code

require 'rexml/document'
require 'net/http'
require 'twitter'

class LiveScoresController < ApplicationController
  
  def index
    # set date and time - needed to get feed and select only new items
    date = Time.now.strftime('%Y%m%d')
    time = Time.now - (60*1)
      
    # grab the latest xml file
    @xml = Net::HTTP.start("scores.skysports.com") do |http|
      req = Net::HTTP::Get.new("/commonfiles/files/fixtures/"+date+"/"+date+"_events.xml")
      http.request(req).body
    end
    
    # connect to Twitter
    twitter = Twitter::Client.new(:login => 'livescores', :password => '************')
    
    # loop through xml
    REXML::Document.new(@xml).elements.each('//Event') do |game|
    
    # limit to recent events only
      if game.attributes["time"] > time.strftime('%H:%M')

        # GOAL
        if game.attributes["type"] == "GS"
          alert = "GOAL! \n"+game.attributes["player"]+" ("+game.attributes["matchtime"]+" mins)\n"+game.attributes["hometeam"]+" "+game.attributes["HomeScore"]+" - "+game.attributes["AwayScore"]+" "+game.attributes["awayteam"]
          twitter.status(:post, alert)
        end

        # FULL TIME SCORE
        if game.attributes["type"] == "FT"
          alert = "FULL TIME \n"+game.attributes["hometeam"]+" "+game.attributes["HomeScore"]+" - "+game.attributes["AwayScore"]+" "+game.attributes["awayteam"]          
          twitter.status(:post, alert)
        end          
      end
    end
    
  end
end

For it to be of any use there needs to be a way of filtering by team (I'm not sure if twitter lets you filter what alerts you get from a friend), If I decide to schedule this script then I may just change the code to limit to my team.

Some gig pictures using my new Cannon 400D

Los Campesinos!

Luminaire

This weekend I went the Yahoo/BBC hackday at Alexandra Palace with Andy and Ben, after turning up with no idea of what to do and walking in via the stage we finally decided to do something with a map, which was the one thing we agreed not to do a week ago.

However before we could get started the wireless went down, luckily we bought our wii, then we were struck by lightning which resulted in the roof opening and it raining on us, wii quickly packed away we waited while they closed the roof and restored electricity.

Where shall I live

We decided to plot onto a yahoo map statistics for each main post code in London which we pulled from upmystreet, so you could see at a glance where it would be nice to live, more info here

Video of our hack plotting

It took around 35 mins to get the data for each filter mainly because the wireless was so slow, this is a time lapsed version.

All in all I really enjoyed hackday, the yahoo team were very helpful and they gave away pizza and bean bags, what more could you want.

Our hack can be seen here, its a little slow as it needs to pull back a lot of small files with details for each post code, we may change this to be more efficient shortly, I would like to say a huge thanks to Mirek Grymuza who changed part of the live maps api to help us.

What next?

We are thinking of continuing with this project, mainly to optimise but possibly to include property listings pulled from another site, if you have any ideas or want to help please contact me.

A list of all the hacks with there urls is available here

I recently put together a travel section on my site it used google maps to show where I had been and pulled tagged photos from my flickr account. I have been using upcoming.org for a few weeks and thought it would be interesting to take the mashup I had made and add my events using the upcoming API.

upcoming api

I was going to make this into a page where you could enter your username and it would create a page for you but the upcoming api requires that a user authenticate your app to access their account details. Authentication wasn't a problem but access is all or nothing and meant I could delete a users events etc and I didn't want to store users keys if they gave that much control.

I found the upcoming api to be very easy to use, the documentation was easy to follow and examples were quiet detailed, its just a shame they don't support read only authentication.

geo-data

upcoming doesn't send the geo data for UK venues so I needed to do this myself, multimap.com stores this information in the meta tags of ma pages so I made a small script to get this info

@pc         = params[:pc]
@path       = '/map/browse.cgi?client=public&db=GB&pc='+@pc+'&advanced=truescale=5000'
@server     = 'www.multimap.com'

# connect and pull data
@html = Net::HTTP.start(@server) do |http|
  req = Net::HTTP::Get.new(@path)
  http.request(req).body
end

@geo_data = @html.scan(/<[\s]*meta name=\"geo.position\"?([^>"\']*)["\']?[\s]*content[\s]*=[\s]*["\']?([^>"\']*)["\']?[\s]*[\/]?[\s]*>/si)

return @geo_data

upcoming, google maps, flickr mashup

I've wanted to use the google maps api for a while now but haven't really found a reason to do so.

I was putting a few pictures online from my traveling last year and decided to use google maps to plot my route, the api was really easy although the plot doesn't work in IE (surprise!).

I then decided to pull my pictures from flickr for each of the points on my map, I used the flickr rss feed for this as the flickr gem for rails has the authors API key in a config file that I can't edit with my hosting, I used JQuery to make make the ajax request and at the same time tell the map to move to the correct location.

google maps, flickr mashup

I have been using TextMate a Mac based editing tool for some time now, at first glance it appears very simple, its clean and well designed with some very powerful features built in, over the past 2 weeks I have started to make use of the bundles feature. By default TextMate coms packed with bundles for all kinds of languages with an editor so you can add your own or edit any of the ones included.

Bundles allow you to add commands, macros, snippets and actions when an file is dragged onto a document. So far I have used these for things like re-starting apache, starting a new function, adding tables to html, rendering in rails and various CSS layout properties.

I have now created my first bundle which is focused on the html templates and PHP functions that we often use at Spring. My bundle mainly contains shell commands for things like, copying files into the current project, importing html into the current document, checking for placeholder variables.

I found the ability to set shell variables in the Preferences pane really useful as this stopped me having to redeclare the same variables in each command, I have also made use of TextMates inclusion of CocoaDialog to include progress bars and Growl style bubble messages

One thing I did find very strange is that the bundle editor doesn't make use of TextMates syntax highlighting (hopefully something in version 2)

textmate bundles editor
lastest photos
photo John Lennon John Lennon John Lennon Louvre, Paris Paris Paris Eiffel Tower, Paris Eiffel Tower, Paris Paris King's Cross St Pancras Pete Doherty
flickr