nunojob:~ dscape/08$ echo The Black Sheep

Posts tagged ‘OS X’

Rails::ActiveRecord XQuery && DB2::Mac

Most rails developers use OS-X. Mostly because rails is built-in the latest release (Leopard) and TextMate offers a great IDE to use with Rails. Some could argue that it also works nicely on Windows but I really believe that Rails ain’t done to be used on a Windows Platform. Many articles and interviews with rails creator DHH second this statement. Rails is easy to develop in OS X and deploy in a Linux distro of your choice.

In my most recent screen-cast I explored an interesting technique of taking advantage of rails RESTful design and DB2 pureXML features to easily create a web-service that could query a relational databases with XML support (like DB2). As you must know DB2 Express-C is distributed freely and offers no limitation to home users/small companies. So it would be awesome to expand ActiveRecord to support xml elements, if a schema was provided to the database.

I’m aware that a pure xml database stategy would be a bad approach but there are situations when it simply makes sense. And in those situations one would profit greatly of two things wich are missing.

  • XML Support for ActiveRecord – in construction?
  • DB2 for Mac – will this ever exist?

Antonio Cangiano is creating a plugin that revolves around this concepts, but in a DB2 centered perspective. In my opinion it would be best if the rails plugin worked not only for DB2 but for any database adapter with XML support – as long as such is provided.

Let me give you a sample. Imagine that you have a database model for translating you rails application. It could be something like:

Languages

  • ID, int
  • DOCUMENT, XML

Imagine that the xml file is

<language isoname="pt-PT">
  <hello>Olá</hello>
  <bye>Até a próxima!</bye>
</language>
(...)

If this makes sense in your application then you could easily do something like register your model to observe (see observer design pattern) the session[‘language’] for changes and, if it’s changed, it would get all the XML for that language – it would fall back to default if such was not available – and create the hash with the values. The problem with this approach – besides making no sense for the internationalization problem! – is that in the observer model you would have to:

Language.find :first

And fetch the whole xml and then process it. If the XML document has 10MB, it would take some time. With XQuery support on ActiveRecord we could simply

Language.find :first, 
  :xcondition => ["//language[@isoname==?]", 
    session['language']]

Or, if we simply wanted to say hello in many languages – like flickr in their first page – we could simply

Language.find :first, :xcondition => '//hello'

There are just two problems that prevent rails developers from being able to do this kind of things. And those are the lack of XQuery abilities in ActiveRecord and the fact that Mac developers cannot use DB2.

Advertisements

Howto: Change folder icon in Leopard

Copy the icon you want to use (PNG), browse to the folder you want to change the icon.

Now select it and press command + I. Now select the folder and press command + V to paste the icon.

Optimus em Ups! I did it again

Descobri hoje que a Optimus é só para Microsoft Internet Explorer e Microsoft Windows.

Penso que em breve a Microsoft irá anunciar a aquisição da Optimus passando esta a chamar-se Microsoft Optimus. Uma excelente oportunidade para mudar de fornecedor de serviços não concordam?

O .NET não veio para salvar o mundo, se se dessem ao trabalho de ler um pouco mais, explorar, aprender um bocadinho viam que existem outras soluções. Cada uma mais ou menos indicada para cada função, CLARO!

Para a Optimus parece-me evidente que não é o mais adequado dizer aos clientes: Está a usar OS-X/Linux/Whatever. Solução: Olhe, use Microsoft Windows.

E SE EU NÃO QUISER?

Na volta na próxima estão-me a dizer que tenho que ir a este café ou aquele café porque apenas ai posso fumar. Devem achar que este pais é uma republica das (e dos) bananas. Mas não é Optimus, não é.

Também estou aqui a tecer considerações sobre a empresa que fez isto. Sinto a necessidade de mudar de operadora só é pena que não haja concorrência. Vai tudo dar ao mesmo, o mesmo antro de incompetência e mediocridade que as nossas empresas se orgulham de ostentar como bandeira.

Força pessoal, peguem na bandeira e nas medalhas, juntem-se ao Socrates, ao Cavaco, ao Rui Rio, ao Menezes. Mais uns litros de gasolina e aposto que davam uma fogueira impecável.

Screencast app for Mac OS X Leopard

I’m looking for the best screencast software (sound recording is a must have) to run on my MacBook.

So far I found the following software:

From what I have read so far it seems iShowU gathers most of the preferences. But when a app is prefixed by an i mac users seem to love it immediately.

Anyone tried any of these products? What are your thoughts on them? Which one would you advice me to use?

[EDIT: Currently I have tested most of these products and I’m using iShowU and KeyCastr]

MacBook OS X Leopard Tips: Controlling the fan speed with Fan Control

I use my computer for something like 6 hours a day so it’s bound to get hot. I didn’t like the apple scheme for the fans that consists basically in making no noise until it’s hot and then make a lot of it.

So I looked for a open-source application to help me control the fan rpm and found Fan Control. I wouldn’t even post this if not for one simple fact: The source is included in the dmg file. Good job guys!

Mac OS X Leopard Tips: iSync plugin for Nokia 5300

First of all my phone sucks. I’m aware.

And when i opened iSync for the first time and saw that it wasn’t supported I was really piss*d off. I wasn’t worried about contacts – even thought it’s nice to know that if I loose my cellphone I’ll still have them – but I really needed the integration with iCal/dashboard.

I googled it and found a lot of hand-crafted solutions that I don’t think are suited the general public. Luckily someone thought of this and made a easy to install plugin to make iSync capable of synchronizing with Nokia 5300. Interested? Let’s go:

Close iSync. Download this and the unzip it to ~/Library/PhonePlugins/.

That’s it. The next time you open it you’ll be able to sync with your (not) favorite phone. Credits go to Erka, the author of this plugin.

Mac OS X Leopard Tips: Change your home directory to a different partition

Here’s something that I thought would give me some headaches. Well guess what I was wrong once again. I’m quite used to this by now so it’s actually fun. I’m sorry to be bothering you with all this Mac OS trash but I like to keep my stuff documented and this is a excellent way of doing so while helping other people.

If you are reading this I assume you want to change your Leopard home directory to somewhere else. So you can start by clicking on the apple on the top left screen and then select System Preferences. Browse to Account and ctrl + click your account to select Advanced Options. There you can change your home directory to wherever you please. Restart and you are ready to go.

Changing your home directory – or any of that other advanced options values – can have some nasty effects on your Leopard. I’m assuming you are an advanced user and familiarized with all the stuff the advanced options window.

If this is not the case and you are considering doing this anyway I’ll leave you with a piece of advice my grandma could have given to me – she actually never did so I have ruined my fair share of computers. And phones. And Playstations. I’ll better stop this list here for my own sake.

Anyway that advice is (should have been): if you don’t know what it is, don’t change it. If you want to change it: learn what it is, how it works, and then you can do what you please. And ruin the computer anyway. But only because you wanted to.