nunojob:~ dscape/08$ echo The Black Sheep

Archive for the ‘Howto’ Category

Information Retrieval using the Boolean Model in Ruby on Rails

famfamfam flag iconset yaml representation on ruby

First download the flags from famfamfam into a folder called flags (pngs only,
no subfolders!).

Now in the bash:

cd flags
wget http://www.iso.org/iso/iso3166_en_code_lists.txt
ls > file.txt
irb

Now your on the interactive ruby shell (irb).

# If you want to use this as a script just copy
# the bash lines and put them as
# system ‘cd flags’
# system ‘wget …’ and so on

# We start treating the output from the ls
# open the ls output
f = File.new ‘file.txt’
# place the file in lines
lines = f.readlines
# map those who have 2 digits codes
lines = lines.select { |line| line.size == 7 }
# get the 2 digits
lines = lines.map { |line| line[0..1] }
f.close

# Then the iso file
# open the iso file
f = File.new ‘iso3166_en_code_lists.txt’
# get rid of the notes
f.readline
# place the file in iso
iso = f.readlines
# create a new hash
hashed_iso = {}
# select non empty lines
iso.select { |a| !a.rstrip.empty? }.map do |b|
# remove the whitespaces and split in ‘;’
aux = b.rstrip.split ‘;’
# place info in the hash
hashed_iso[aux[1].downcase] = aux[0].capitalize
end
f.close

# Now we cross information giving more
# importance to what’s in the iso.
iso_famfamfam = hashed_iso.select {
# select those who have flags in famfamfam
|k,v| lines.member? k
}.sort_by {
# sort them by the name the user will see
|pair| pair[1]
}

# Now we create the contents to store in the yaml file
# create the yaml first line
yaml_lines = “hash: \n”
iso_famfamfam.each do |pair|
# for each pair, create the yaml
# representation and put in yaml_lines
yaml_lines < < ' ' + pair[0] + ': ' + pair[1] + "\n" end yaml_lines << "array: ---\n" iso_famfamfam.each do |pair| yaml_lines << '- - ' + pair[0] + "\n - " + pair[1] + "\n" end # put it in a file f = File.new 'flags.yml', 'w' f.write yaml_lines f.close #sample for loading the yaml into ruby f = File.new 'flags.yml' fy = YAML.load f [/sourcecode] Now you have your yaml representation of the flags. Do what you please. Personally I'm going to use the file to load it to Ruby when my Ruby on Rails app starts and use it as part of the registration system in the

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.

Skitchcast: Ruby Gems is now on v1.0

Here how to update your gem to 1.0 and RoR to 2.0.2

Imagem do dia

Atenção: Esta ilustração mostra como limpar as preferências do TextMate. É apenas um devaneio geek, que mostra como se pode complicar até a mais simples das coisas. A próxima versão será em base-64, para piorar ainda mais o cenário. Contudo quero deixar claro que o uso ilícito de software proprietário é crime. Se através deste exemplo descobrirem como se faz e o fizerem estão a vossa própria responsabilidade.

Creating a User Interface for XML Schema using xForms

We use XSLT all the time to convert a XML document into another format. XML Schemas are XML documents and I think it would be interesting to create the user interface and model for that specific schema using xForms. This would drastically decrease development time and would allow a quick view on what that XML Schema is all about. In other words, this would do for xForms what JAXB does for Java.

Why xForms? xForms is W3C recommendation for creating user interfaces and it’s based on the MVC pattern. This is enough to convince me, I’m all for standards.

While researching I found some works on this subject [here, here] but they are mostly on conference proceedings and therefor I thought no one had really implemented a Generic Schema to xForms transformation engine. Before giving up I asked Vítor Rodrigues about this, as IBM is know for their XML Alphaworks. Guess what? Now I have the solution.

Here’s what you need create an xForm from a Schema:

  • Download Eclipse WTP
  • Open Eclipse and browse to Help > Software Updates > Find and Install
  • Click New Remote Site
  • Name: Emerging Technologies Toolkit (ETTK) Updates
    URL: http://awwebx04.alphaworks.ibm.com/ettktechnologies/updates
  • Select it and click Finish
  • Now select Emerging Technologies Toolkit (ETTK) Updates > Emerging Technologies Toolkit – Technologies > Visual XForms Designer
  • Click next.
  • Accept the license, install the software and restart eclipse.

Now for the Visual XForms Designer I made a little screen-cast. Just click here to see it.

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.

From Ubuntu/Windows to Mac OS-X Leopard

I just got my first brand new MacBook and, as one would expect, some problems emerged by leaving my usual OS combo (Ubuntu/Windows) for Mac OS X Leopard. I’m still undecided whether to install Ubuntu or use VMWare Fusion to use Linux. As for Microsoft Windows as long as I don’t need to use .NET I don’t think I’ll install it. Not even with the free licenses Microsoft provides University of Minho students.

First I had to decide what to install:

The question you are probably asking is why Firefox instead of Safari!? Because the damn unsafe add-on for del.icio.us is just that: del.icio.us! I just can’t live without it. Maybe if the guys over there worked the basics of security we could say that it’s both excellent and safe! And don’t say there’s a add-on for Safari as well. I’ll only accept it if the add-on is as good as the one provided by Yahoo.

Now we go for the fun part. The problems and solving them. Your attention please, this is only fun for me when I do it on my computer so it won’t be pleasure if you ask me to fix your computer! Joana this one is for you, I know how your mind thinks.. Almost as badly as mine. Oh well, we are related aren’t we? :\ Please release those crazy Christmas photos to the world! :X

I’ll start with a small OS free tip and then go for the Q/A part. If you are Portuguese like myself you just hate all the results that google gives you from .br domains. Most of the results are overrated and most of the times you just wish that they weren’t there. If this is the case just do your normal search in google but write -br in the end. Just test this, go to google and type governo brasileiro -br. It works ;)

  1. How do I get my mouse to behave like a normal one by removing this dreadful acceleration?

    Easy. Check Rúben’s blog @ http://blog.0x82.com/2007/12/mac-os-and-usb-mouse.html

  2. What’s wrong with the encoding on TextEdit? The automatic descovery does not work and even when I specifically tell him to use this encoding it won’t work. The Where is ISO 8859-15 dilemma.

    Still don’t know. Anyone? If you want to test the bug just do this (from here):

    $ echo é > ~/a.txt
    $ cat ~/a.txt
    é
    Open a.txt with TextEdit and get:
    È

    Cracked it! At least I have a partial fix for Migrating documents from Ubuntu to Mac OS X Leopard:

    cmd + space terminal enter

    {go to the directory where the file is}

    bash$ iconv -f ISO-8859-15 -t UTF-8 {filename} > UTF8-{filename}

    For me it was:

    bash$ iconv -f ISO-8859-15 -t UTF-8 Pam.tex > UTF8-Pam.tex

    And yes PAM is as in Pluggable Authentication Modules. So I have a latex work on that :P

    
    
  3. Where is type-a-name application? It’s not on the dock.

    Just press cmd + space and type what you are looking for. This is called spotlight. Either this or open Finder and go to applications.

  4. Why doesn’t it show my dashboard when I go to the left/whatever corner?

    Have you even configured your mac? Common.. Click the apple on the top left corner and go to System Preferences. Exposé and Spaces. And now that you are there take a look around and configure all the other things that you neglected.

  5. This computer is always underlining the words in red. (when the spelling is right :P If not you are a dumbass for asking this!)

    Just press cmd + mouse and change the language. Thanks Nuno Veloso from Apple Tech Team for this tip.

  6. How can I see the right mouse button menu?

    crtl + mouseclick

  7. PageUp/PageDown!?

    fn+ up
    fn + down

If after this you still feel like reading about Mac OS for rookies – like myself – you can check this section in Arun Gupta’s Blog or check this extensive list of Keyboard Shortcuts. Have fun!

Now let’s get back to work, something almost impossible when your doing a report on LaTeX and the encodings are never right.

One final touch: ctrl + alt + cmd + 8. Merry Christmas! :)

del.icio.us security (or lack of it)

As you might as well have seen in my previous post I have recently joined del.icio.us daily blog posting service. However I’m not very happy with it, specially with the security.

If you use my computer to browse the web, go to del.icio.us and then click in settings -> daily blog posting will see the following page:

del.icio.us security

 

AMinhaPassword stands for My Password in Portuguese. In this place used to be the actual password that I use on my blog. I cannot understand how a service as big as del.icio.us can:

  1. Store my password as plaintext!
  2. They actually show the password to ANYONE that uses my computer.

I have already emailed the del.icio.us a complaint but have received no response so far. I know that you have to be logged in for this error to emerge but almost every del.icio.us user uses the firefox add-on provided by yahoo, so we are always logged on!

Já notaram que o Google Calendar manda SMS’s?

Eu notei quando me deparei com a noticia inserida no CeSIUM. Quem escreveu já me é conhecido por chamar a atenção pequenas features nas aplicações da google que eu não teria notado de outra forma! Se ficaram curiosos em como o fazer podem dar uma espreitadela aqui.

Agora, será que a Google atacar o mobile a sério e tornar possível o conceito do everything-everywhere. Uiii.

Afinal quem não gostava de ter os nossos PIMS, documentos, imagens, etc, disponiveis num só sitio e a partir de qualquer dispositivo com ligação a net?

WordPress Hacked?

Was wordpress hacked? Have your say :P

Wordpress Hacked

Falta o ficheiro d3x9_30.dll para correr a demo do PES2008?

O pessoal estava aqui a tentar meter o PES2008 a correr e deparamos-nos com um erro sobre a falta do ficheiro d3x9_30.dll. Como o vicio é muito e já vi por ai muita sugestão disparatada para resolver o problema aqui fica a real solução. Saquem o ficheiro dxwebsetup.exe (DirectX End User Runtime Web Installer) e corram. Problema resolvido, o vosso DirectX estava desactualizado.

Já agora a demo é porreirinha.

Se ficaram perplexos com o desafio de ontem podem ver aqui a solução.

Challenge

If you use Windows create a file/directory with the name aux and any extension. Then send it to my email.

How to delete the recycle bin icon

I use RocketDock (the single greatest piece of software ever, after all the others) to keep my apps organized. I cannot afford to have a mac so this is my way of doing this. In the dock I have access to the recycle bin and, therefor, I have no use for the standard icon on the desktop. Worse, it annoys the hell out of me. So I did a search if the good guys from Microsoft had a solution for this problem.

Well just wanted to let you know I found it..

Kidding, the solution to this is to create one file named Hide Recycle Bin.reg. Now insert this text in the file you created.

Now double click it and your good to go. In case you feel like having the old icon back, create another file and name it Show Recycle Bin.reg. Write this there and the run it.

Can you bypass rapidshare waiting time?

Before presenting the solution I would like to state that I feel very strongly against piracy. Sites like rapidshare, megaupload are the perfect scheme to make profit from illegal downloads without having to take the fall. (You can learn more about how this website works reading it’s wikipage)

If they could (they probably can) they would (ok, they probably will) sue me for saying this, but everyone knows this is the truth. I know that have the right to only offer a free service to a user whenever they wish to. It’s the way they do it that intrigued me. Can I fool “one of the biggest and fastest web hosters world wide”. Well it appears I can.

They check information from your computer (specifically your network interface MAC Address) to know what is the computer trying to access a file. I didn’t gave myself the work of checking if they let any tracking cookies in the system, I just assumed they do (and worked around it).

Before just giving the solution I found, let me just express my opinion on privacy. In my opinion no one has the right to know what computer is mine, what data is in my hard drive or what things I like to do. You should protect yourself to prevent companies from knowing stuff like who you are, what websites you visit, what is your computer, what data you have stored in your computer, what is your email (so they can flood it the way they want), etc. It’s not like I’m a hacker or that I have the most important things of the planet of my laptop, that’s certainly not the case. But all these information are about myself and for myself only. No company should be making money selling this information so a third party can benefit from it, by flooding my email or having data (like my address or phone number) where they can annoy me. They shouldn’t even know about it in the first place. So protect your information from unwanted use, check out why you should encrypt your hard drive, try to be spyware free and most of all be aware that not all is good about the internet.

For starters, how do I avoid a website from knowing it’s me. Simple:

  1. Clear your private data (how to)
  2. Close Firefox
  3. Download MAC Address Changer (here)
  4. Install the program and run it
  5. In the program select the network connection you use to access the internet from the list
  6. Hit the Change MAC button
  7. Hit Random MAC Address
  8. Hit Change now
  9. Disconnect your modem from power for 10/15 seconds (unplug the cord).
  10. Plug the cord back in.
  11. Open Firefox and go to the web page you wish to access.

Don’t forget, when your done go to MAC address changer and put your original MAC address on.

And I remind you I take no responsibility on what you do with the contents of this post, I did it so as a learning experience and I guess anyone can draw the same conclusions I did. I’m not responsible for your actions, do what you please but at your own expenses.

[EDIT: For Mac OS X Leopard users]