Using git-svn to connect to a Subversion repository via Git

April 26th, 2010

This is quite simple on Linux.
* Install git, subversion and git-svn (the latter can be installed on Ubuntu using apt-get install git-svn)
* Acquire a copy of an svn repository (or just a folder in the repository) as a git repository locally
git svn clone https://yoursubversionserver.com/svn/trunk/some_folder
Note: You can choose to omit the ’some_folder’ at the end if you want everything in trunk. You can also be more specific about which folder you are interested in, eg.
git svn clone https://yoursubversionserver.com/svn/trunk/some_folder/wow/really/specifc/folder
* Change a file in the repository and use the usual git commit command to commit it to a local repository
* To push changes from your local git repo to the subversion repo use
git svn dcommit
* To pull down changes from the remote subversion repo to your local git repository use
git svn rebase
* Just to be clear – in the last step we really did use the git svn rebase command to get changes from the remote repository.

** Do not use git pull. See the REBASE VS. PULL/MERGE section of the git-svn docs as to why **

** Do not use git clone/pull/merge/push on your local git repositories that are derived from a subversion repo. See the CAVEATS section of the git-svn docs as to why **

More basic examples are also list at the bottom of the git-svn docs.

And if you want to see a great example of a git-svn workflow in action, check out Jérémie Laval’s blog post – Working on Mono with git-svn.

Lifting the lid on Open Jam!

April 16th, 2010

Open Jam was an Ubuntu Ireland lead event which invited all members of the Open Source community to come along to Enterprise Ireland’s Dublin offices at East Point on Saturday the 27th of March. And come along they surely did, really show-casing the diversity of groups we have here in Ireland – users of Open Source software, developers, admins and advocates. The timing of Open Jam was to coincide with the Ubuntu Global Jam – where contributors to the Ubuntu project focus on finding, prioritising and fixing bugs as well improving documentation, artwork and more. The ‘Open’ in Open Jam was to extend that spirit to everyone – independent of their area of interest or skillset – to collaborate, learn and share.

After the welcoming talk, some people got straight down to business, while others took the opportunity to chat and chill out after a long week in the office. Thanks to the excellent organisation skills of David Scanlon of Enterprise Ireland the event sported two rooms – one main room where you could hack away on your favourite project and another where liked-minded folks could get together and have a BoF (Birds of a Feather) session on a particular topic. Tunes were supplied on the day, pumped through Enterprise Ireland’s very tasty A/V system, by Luis Bethencourt – a.k.a. Mr Ubuntu Studio (Ubuntu Studio is a multimedia creation flavor of Ubuntu that Luis leads). In the BoF room, Rory Geoghegan kicked off the proceedings with a great intro to the Python programming language. This was followed by Anton Krasovsky’s highly popular talk on Erlang – which seemed to bring out the inner developer in everyone and sparked a meandering conversation through programming patterns, architectures and practices of every language under the sun. Anton is the author of pavo.me – a mulitmedia Twitter client for any pretty much phone that supports Java.

After lunch, which was graciously sponsored by Microsoft, Rory McCann gave an insightful talk on Ubuntu’s software collaboration platform Launchpad. Laurent Coudeur, part of the GNOME translations team, presented on the theme of language translations. He’s always on the lookout for people to help the translation effort (especially regarding Irish, so if you’re interested in helping then get in touch with him on his blog, where he also has a write up and more photos of Open Jam). Away from the lightning talks, Halo Labs, which is a community of Independent IT Service Providers, were beavering away on Linux appliances like Workgroup Server & Asterisk Box, with Patrick O’Conner and Russell Davies probably scooping the award for being the most industrious attendees!

Musical talent was a feature of the day, with Harry van Haaren from U.L. providing a really interesting lightning talk on his work in progress Luppp project; hooking up a MIDI board to his C++ based looping software – allowing part of a live instrument performance to be looped on the fly and built upon. UCD Open Source Labs (represented by Alexander Ufimtsev, Keith Byrne, Aidan Church, David Murphy and Chris Duffin) announced their availability to to support Open Source projects by providing facilities for collaboration, project planning and development of Open Source software – check out the UCD Open Source Labs website for more details.

The Open Source .NET scene had a strong presence with Dublin Alt.NET members on hand ready to participate in any conversation that had the mere mention of the words ‘design pattern’ :-) Andrea Magnorsky introduced the audience to the .NET DLR (Dynamic Language Runtime), which allows languages such as Ruby and Python to run on the .NET framework. Mono hackers Alan McGovern and Jérémie Laval gave a lively talk on the Mono framework, MonoDevelop and related platforms such as MonoTouch for the iPhone and Moonlight. Qamir Hussain presented on A.I. & Distributed Agent frameworks which he’s working with at the moment. Later in the day, Rory McCann was back on stage, this time with Larry O’Neill, to give a talk on the facinating Open Street Map project, which marches on mapping the world in an Open fashion. Oh and some random walked in off the street and chipped in with a quick talk on Qt, Ruby and Rails :-)

To round off, again a big thanks to David at E.I. for being such a kind host and also Laura Czajkowski, Jeffrey Roe and Qamir Hussain for helping to organise the event. It’s great to have Enterprise Ireland helping events like this, which really boost the Open Source community and innovation in Ireland. Most of all, thanks to you, everyone who showed up and helped make it a great event. The good news is that there’s no let up in the flood of Open Source events in the next few weeks with OSSBarcamp on April 17th and Open Spaces Coding Day on April 24th. Phew! Being Open was never so easy!

P.S. While the resulting projects need not be Open Source, a superb sounding collaborative event that’s on the horizon and worth a mention is Dublin’s Startup Weekend! This could be your chance to get that great idea in the back of your head implemented over a weekend sprint with other techies involved. It’s being organised by Sean Murphy and if interested visit the Startup Weekend website for more details.

P.S. If you want to leave your twitter handle to get in contact with others at the event then feel free to edit it into the Open Jam Attendees List

And finally, some more Open Jam pics…

Hooking up a laptop to a projector using Nvidia Twinview on Kubuntu

March 29th, 2010

UPDATE 1: As far as it can be confusing as to whether Nvidia Twinview is changing the underlying resolution of your display. Here’s some tips that may help

  • Adjust the resolution ***before*** you hook up your laptop to a projector
  • If you adjust the resolution and it doesn’t look like what you would expect (eg. the bottom half your display is missing) then logging out and back in may help

UPDATE 2: I found that adjusting the display settings using a tool other than Twinview helped (in KDE on OpenSuse 11.2 I found that searching for sax2, a part of YaST, let me change my screen resolution without problems – once I dropped the screen resolution to be the same as the resolution of the projector then I didn’t need to mess around with Twinview at all).

Here is the rest of the original article…

The number of configuration options can be a bit daunting when you haven’t used Nvidia Twinview before. Here’s a quick simple recipe

* Set both the laptop screen to be the same as the maximum supported resolution of the projector (you can use the ‘Model’ dropdown list to choose between settings for the laptop and the projector). If you set the of the project to Auto and click apply the diagram should tell you the max supported resolution for the projector
* Ensure position is set to Absolute for both the laptop and the projector
* You can drag the actual boxes representing each screen in the diagram but the best thing to do is ensure they overlap as much as possible
* Finally click Apply and you should get a pretty good match. You may still need to resize the window you want to show in order to get the projector fully displaying it

Getting Google Calendar to work with KDE’s KOrganizer, Kontact and KMail (on Kubuntu 9.10 Karmic Koala)

February 19th, 2010

Woah! That’s a lot of K’s in the title! But it’s all in the name of getting your calender talking to your desktop so it’s for a good kause (sorry!)

There’s this great package in KDE that has a really cool name called Akonadi (pronounced Ahh-Kon-ahh-dee if you want to impress your friends!). But more than just a cool name it does cool things – particularly in the realm of syncing data on your desktop with a remote server. Ooo yeah, including Google’s servers. Akonadi is one of the ‘pillars’ of the KDE platform and here’s how you can use that pillar to prop up your schedules and calendaring with KOrganizer-Google integration. It’s easy on Kubuntu Karmic!

– Install the Google data package for Akonadi
sudo apt-get install akonadi-kde-resource-googledata
– Ensure the Akonadi Tray Utility is running by performing the following steps
– Search for Akonadi in the search box of the Kickoff Launcher (KDE’s “Start” menu). Click the Akonadi Tray Utility that is found
– Go to the tray on the bottom right of your beautiful KDE desktop and click the small arrow, if necessary, to to expand all the tray icons
– You should see an icon for Akonadi. Right click on it and select ‘Start Akonadi’
– This should start the Akonadi server. You can verify this by right clicking the icon again and checking to see that there is now a ‘Stop Akonadi’ option
– Right click on the Akonadi icon yet again and select ‘Configure’
– Under the Akonadi Resources configuration, click Add and elect to add a Google Calendar Data Resource
– Enter your login details for your google account
– Next it’s off to Kontact. Go to the Calendar in Kontact
– There should be a small Calendar pane on the bottom right to set up calendar resources. Click the Plus sign to add an “Akonadi (Provides access to calendars stored in Akonadi calendar folders)”
– In the resulting popup, choose the google resource in the list and ensure that Events is ticked to the right of it. (I didn’t try to get Todos or Journals working because I don’t use them)
– Hey presto! All your calendar details should now be pulled into KOrganizers calendar! Hurrah!!!

Just to note, at time of writing I found that I had to search and find the Akonadi Tray Utility on restarting the computer. Once it’s in the System Tray elect to start Akonadi as we did above and you’re back in the game! If you find a solution to this minor inconvenience on restarting your machine then please post below!

Thanks to Christian Mangold for this article which served as a great reference.

A Ruby Module that mixes in Class Methods (static) and Instance Methods

February 4th, 2010

Ho ho, this one can catch you out more than once so it’s high time to write a blog post to cover this off. Turns out it’s a commonly used pattern to the rescue. Thanks to eoin on #ruby.ie for pointing to the solution on RailsTips.org.

Here’s quite a tasty diagram too for easy reference.

module Swingable

    def self.included(base)
        base.extend(ClassMethods)
    end

    def instance_swing
        puts 'Did an instance swing!'
    end

    module ClassMethods
        def static_swing
            puts 'Did a static swing!'
        end
    end
end

class BaseballBat
   include Swingable
end

BaseballBat.static_swing
BaseballBat.new.instance_swing

ossdev-ireland: A new Irish Open Source Developers Group

January 18th, 2010

ossdev-ireland is a group set up to act as a melting pot for the various different Open Source groups in Ireland.

Many group mailing lists already exist in Ireland for individual technologies, development languages and frameworks. However, each community is sandboxed into its own world. As a result there is less chance for cross-pollination of ideas between FOSS technologies, communities and individuals. The ossdev-ireland mailing list is to augment the existing mailing lists as a place to share ideas across the entire Open Source development community in Ireland.

In particular, it would be great to see the outcomes of code jams, bug triage sessions, or even links to slides that were presented at a group meetup, posted here. You never know who may be interested!

So if you want to browse or join ossdev-ireland, please visit us at http://groups.google.com/group/ossdev-ireland

Qt Programming Tips

January 16th, 2010

This is a little more of an unusual blog post. It’s going to simply house a slowly growing list of Qt tips over time. Here goes

* Qt has the concept of models baked in. Usually you will only want to use them if you have a list of records involved. So let’s say you have a list of contacts like in an address book then this could be encapsulated in a QAbstractTableModel. If you just want to display a record in one-off fashion you can just populate a bunch of form fields (such as QLineEdits).

Santa’s got Gems baby! Ruby Ireland Christmas Meetup 2009

December 18th, 2009

Ho ho ho! The month’s Ruby Ireland meetup sprag right out of the traps with early adopters showing up at 6pm in the lobby area of the Trinity Capital Hotel, Wed Dec 16th. Easing into the evening with a 4 euro pint and talk of Android phones – seemingly the top item of everyone’s Christmas shopping list – the latest crop of gems in the Ruby world was in hot debate, gemcutter in particular.

A couple of folks had been playing around with RubyGame for visualising data as it changes on the fly – showing that this framework is for more than just gaming. The XML/HTML parser Nokogiri was also mentioned a few of times in passing, with the particularly eye-catching quote “XML is like violence – if it doesn’t solve your problems, you are not using enough of it” adorning the home page of its website. And the cracking little tool tig was also brought up, which has a dinky little ncurses interface into git repositories. Pretty cool; not least because it makes it easier for newbies to avoid being bitten when they start git’tin.

The downstairs lobby in the hotel worked out great for people to meet up and relax, with most people turning up at the scheduled 7 o clock for kick off. From there we took over the, what has to be said, pretty classy meeting room complete with old style couches and some Joan Miró paintings. Just in tune with the creative buzz we had going on. There wasn’t too much talk of Ruby for a while as most people were in stunned admiration of the room. Then the food platter arrived. Impressively, this is when everyone showed off their good manners by looking shyly at the platter for a few minutes, with that kind of “You first, sir” glint in their eye, before taking the plunge and sinking into the pakoras and wedges! Pretty much undoing any good work in the gym from earlier in the day!

One of the funnier moments of the night was when someone went to check the tweets against the (now settled upon) #rubyireland hashtag. Only to find lost rubyists tweeting from the hotel lobby as to where the meetup was on. After a quick runaround the lobby to herd anyone wielding a Macbook into the meeting room, the evening was back on track. We split up into a few smaller groups, with the main walk-through being on the qtonrails – a Rails plugin to simply developing applications on Linux and other platforms using Nokia’s Qt framework atop Rails.

To finish off we had a bit of improv comedy from everyone at different closing stages of the evening; in particular Paul O’Malley with his faithful rendition of an emotion beekeeper. And yes now we’re straying off topic so it’s probably time to go. We’ll leave you with Paul’s write up of last night’s shenanigans :-)

Thanks to everyone who showed. Have a great Christmas and catch ye all in Jan 2010 – surely destined to be the decade of Ruby domination!

Ciao,
Dec

Generate Rails Migrations from your PostgreSQL or MySQL database

November 26th, 2009

1) Create a new empty Rails project called schemer

2) In your config/database.yml file, point at the database you wish to dump to a migrations file

3) Run the command ‘rake db:schema:dump’. This should create a db/schema.rb file. Amazingly this effectively is your migrations file!

4) To tidy up create a file called file db/migrate/20091125205635_create_initial_schema.rb

5) Then copy the create_table statements from the schema.rb file into the new file 20091125205635_create_initial_schema.rb. Here’s a template

class CreateInitialSchema < ActiveRecord::Migration

  def self.up
    # Put all create_table statements from schema.rb file here
    # Note: You don't need the 'ActiveRecord::Schema.define(:version' line or it's enclosing end statement
    # ...
    # ...
  end

  def self.down
    # Don't really need this
  end

end

6) Once you’ve all this done you can just run ‘rake db:migrate’ and you should have a new sqlite db up and running under db/development.sqlite3

Thanks to Justin Ball on this Nobody Listens Anyway blog at Dump an Existing Database Schema Into a Ruby On Rails Migration Ready Format for the basis of this tip. Sometimes somebody does…

Eight Useful Git Tips

November 22nd, 2009

1.) You can check your config using git config -l

This tells you useful stuff like what remotes you’re bound to, etc.

2.) You can blow away files listed as ‘untracked’ (by the git status command) using git clean (be careful!).

If you want any of those files to hang around (but not appear as ‘untracked’) then add them to your  .gitignore file.

3.) You can re-enter your last commit using git commit --amend. What’s nifty is that you can change files (including file addition and deletion) as well as the commit message. Just do what you gotta do before running the amend command and enter a replacement commit message.

4.) You can undo your last commit completely using git reset HEAD^

*** This does not change the working tree ***

Alternatively, you can use the syntax git HEAD~2 instead of HEAD^^

5.) Refer to the last revision by HEAD, the second last as HEAD^ and the third last as HEAD^^

You can keep adding carrets forever! Sounding like Bugs Bunny there.

6.) You can see the contents of a file from a revision using

git show rev:path/to/file

7.) Ok, this tip is a bit of a longer one. Use git merge some_other_branch to merge another branch into the one your working on. (Note that git pull does a merge automatically once it’s completely – if you don’t want this to happen use git fetch). There are a few possible outcomes:

Fast-forward merge : If changes were made on only one of the branches since the last merge, then the merge should happen without any need for you to act.

Three-way merge: If changes were made on both branches, then git decides how to merge them using an algorithm. If any changes conflict with each other, then git will report them and let you resolve them. Once you’ve fixed any conflicts then you can git commit.

If there were no conflicts, git automatically does a commit with a stock commit message for the log. If you don’t like the idea of this then use git merge --no-commit some_other_branch. You need to manually do the commit afterwards. (This is more like how other distributed VCS’s such as Mercurial. This was the tip that inspired this post!).

8.) Finally, one tip that I found useful is that you don’t want to git pull into your repository when you have uncommitted changes. Especially if you treasure your sanity. Instead git stash is your friend. Here’s how
* Do a git stash to move your uncommitted changes to a magical place in git temporarily
* Then do the git pull
* And finally do a git stash apply. This will now move your ’stashed’ uncommitted changes back (from the magical temporary place in git) into your working directory and take into account what what was changed by the pull. Neat!

Tips 1-7 taken from:  Git – SVN Crash Course. Tip 8 taken from painful experience :-)

If you want a good detailed yet friendly reference on a particular command search the Git User Manual on kernel.org.