July 04, 2008

Lazyweb request: how to find full path to script

Dear Lazyweb,

this is something that I searched for quite some time and could not find yet, maybe a helpful soul knows.

In a bourne shell script, how can I find the full path of the script being executed?

Thanks in advance.

No more bazzilion git-* commands

In case you use the script from the last post, be advised that the current master branch of git.git no longer installs all those git-* on your PATH.

The current git/bin/ contents are:

melo@MrTray:melo $ ls -l /usr/local/git/bin
total 14664
-rwxr-xr-x   89 root  wheel  2826820 Jul  4 10:05 git
-rwxr-xr-x    1 root  wheel   573476 Jul  4 10:05 git-receive-pack
-rwxr-xr-x    1 root  wheel  2826820 Jul  4 10:05 git-upload-archive
-rwxr-xr-x    1 root  wheel   994596 Jul  4 10:05 git-upload-pack
-rwxr-xr-x    1 root  wheel   273636 Jul  4 10:05 gitk

I'm using version v1.5.6.1-204-g6991357. This is not the final 1.6 release (the next one), so you might see further commands added (git-shell might join this list).

At least for me, this required some training because I liked to git-TAB to complete...

x-git-update-to-latest-version

This morning in the git mailing list, I wrote a small shell recipe to update your git to the latest version but keeping the previous ones around, in case something goes wrong.

I noticed that what I wrote was a lot better than the hack-and-slash script I was using, so I promoted a cleaned up version of that to my scripts stash. Hence, you can now download x-git-update-to-latest-version and enjoy painless git updates.

You need to tweak two things at the top of the script:

  • the location on your hard drive of the git.git clone (you need to create that with git clone git://git.kernel.org/pub/scm/git/git.git first);
  • the base directory where all the git versions will live.

You'll end up with something like this (I use /usr/local as my base directory):

melo@MrTray:melo $ ls -dla /usr/local/git*
lrwxr-xr-x   1 root  wheel   25 Jul  4 10:05 /usr/local/git -> git-v1.5.6.1-204-g6991357
drwxr-xr-x   7 root  wheel  238 Jul  4 10:05 /usr/local/git-v1.5.6.1-204-g6991357

Each version will be named git-VERSION where VERSION is the output of git-describe. A symbolic link named git points to the latest version.

Just add BASEDIR/git/bin to your PATH and your are done.

Small tweak to my mail setup

I try to keep my inbox empty, but due to a lack of a task manager that I can feel good about, I don't have a place to put pending tasks.

So sometimes I leave them on my inbox. Not good.

Until I find a good system that I like to use, to keep my tasks and projects, I made a small adjustment to my mail habits. I already have an extensive list of rules to filter mailing lists and other regular emails to proper folders.

What I did now was this:

  • created an Interesting Folders smart folder: basically, it joins together the folders (either mailing lists, or my regular inbox) that I want to keep a close eye on;
  • created a Quick Read smart folder: simple condition - show everything from Interesting Folders that is not read.

So each time I open up my email client, I just look at the Quick Read folder. It shows only new mail messages that I haven't read yet. The thing I like the most is that if I need to do something later, I can just leave it there and it will disappear on my next check, but still be safely stored on the original folder.

It's not perfect by any means, but its working very well for me.

Free weather report

There is a storm coming in.

Its time you realize that the best way to keep your mail service operational is to outsource the SMTP part. I did it last year, kept the IMAP server, moved the SMTP server of to Postini (before the Google buyout) and I must say I'm very happy.

July 02, 2008

MySQL advice

When people ask me what MySQL to use, I used to respond "Go to http://dev.mysql.com/ and download the community edition". I recommend it over any version of MySQL that is bundled with your OS.

But I also listen to people who know more than me when it comes to MySQL, and one of those just asked (and presented facts) if the those binaries are in fact dead.

So right now, my new advice on MySQL choices is this: read the latest MySQL Performance blog article and decide what you want.

I'm going to test the Jeremy Cole's releases of MySQL to see if they work correctly with my environment, and I'll keep you posted.

One thing will still send me to dev.mysql.com, though: Mac OS X binaries. Jeremy only has RedHat Enterprise Linux RPMs Update: I was wrong. At least the Enterprise version has Mac OS X binaries. Thanks to Joaquim Carvalho for pointing them out for me.

Off

Some articles should have comments turned off.

RabbitMQ added support for XMPP

This is interesting news. RabbitMQ, an open source implementation of APMQ in Erlang, now has support for XMPP using Ejabberd and mod_rabbitmq.

It seems to be MUC-based, not PubSub. I hope to see a future version with PubSub in the future.

Disabled menu items

A bit because of my last post, I couldn't stop noticing a similar trend in software development.

There is a series of posts about disabled menu items. It all started with Joel Spolsky "Don't hide or disable menu items".

That had a strong reaction from Daniel Jaikut (my personal favorite take on this) and John Gruber, amongst others.

I'm not a GUI application developer, but I must say that it just sounds pretty wrong to go into pop-up-hell to solve the problem. Sure, we could use a in-application tool to explain why the menu is disabled, but that should be optional (like the search menu function in Leopard).

Joel assumption is that users are not very smart and need some explicit text dialog boxes to explain things to him. This is of course true for many many users, but software developers should also be concerned with raising the bar of the average user. Sure, its not popular and you might sell fewer copies, but users need to be probed, poked and pushed to be a little smarter.

Road blocks can be challenging and the felling you get when you figure it out why something is grayed out is worth a thousand dummy books. Not because these particular problem was solved, but because the user developed a mental framework on how to tackle the next difficulty.

If you clear the road of all the roadblocks, your users will only know how to drive straight and they will crash on the first curve. If they are used to reason things out, and understand why some menu items are grayed out, you'll end up with a user base capable of making better use of your software, and allows you to write more full-filling software applications.

Make it harder

Right now, in Portugal and in other places like the US, our schools are lowering the bar (making tests easier) to have a higher percentage of students with passing grades.

This is wrong because the only thing that its raising is the bar of mediocrity.

Tests should be hard not because we like failing grades and angry students but because hard tests force students to evolve their reasoning and deductive skills, memory, and a lot other brain activities.

The worst case scenario is not having a poor student fail a passing test, the worst case scenario is having the next generation of bright students not being pushed to their full potential because they slept through their early years, and ended up a lazy brain.

Forget breakthrough advancements in medical, science, math, chemistry, and other areas. It was so easy to fly through the early years, the above-average kids just fell asleep and their capabilities where not exercised when they most needed, in their youth.

You are worried with the growing segment of the population that is growing fat because of bad lifestyle decisions and even worse food choices? That will be nothing if the next generation of leaders is made of average minded people, with poor to zero knowledge of history and culture, not to mention science.

That's my worst fear.

And you know what? It's your fault, and mine. Its our fault because you and I need to get off our asses and do one of two things:

  • be more politically active, run for local office, talk about education where ever you go, make it your national number one priority;
  • or if you are not inclined to be a politician, make sure your own politicians talk about education. Ask them, prod them, organize groups for higher standards, make your voice heard.

And if a pro-education politician gets elected, support him, defend him, give him cloud cover. Education is not a sexy subject and harsh measures might be required. Having Be aware of what is being done to the future of your kids, help in what you can.

I don't know if I will live to my own expectation on this, I sure hope so. Because this is an example of the right meaning to the word important.

June 30, 2008

Behind the scenes of Tarpipe XMPP

Alex and Adam asked me to elaborate on the tools I used to implement the Tarpipe XMPP gateway.

I used the Net::XMPP2 Perl module, in particular the Net::XMPP2::Component class. It uses the AnyEvent async framework, which in turn support the EV library , giving you all the love of kernel polling.

Until the Net::XMPP2 author releases a new version, you should use my own copy if you plan on doing external component work (check the component-reply-with-from branch). Net::XMPP2 is widely used for bots, but not that many components, and some methods need some love to work properly in a component environment.

The HTTP part was done using the excellent AnyEvent::HTTP class. I'm using my own version, which includes a bug fix to the http_post function (on its way to release 1.03 of AnyEvent::HTTP) and adds support for HTTP::Request to http_request. I hope to see this included in the main AnyEvent::HTTP distribution but I still need to update the documentation.

The rest is just glue code.

Using Tarpipe via XMPP

Tarpipe is a wonderful service to execute a workflow of web services. You create your workflow visually, and then you send an email or POST to a API end-point to run it.

For example, this is the workflow I use to post to Twitter, Jaiku, and Pownce:

Tarpipe Microblog Workflow

Usually I would send an email and my subject would be posted, but I also have an IM client always available.

So I wrote this XMPP-to-Tarpipe gateway. Its simple to use:

  • use Tarpipe to create an workflow: you must use the REST Decoder;
  • When you save the workflow, you'll be given a API token, a 32 char hex-string;
  • subscribe <the API token>@tarpipe.simplicidade.org. You can subscribe from multiple JIDs.

That's it: you now have a new buddy on your roster. Any message sent to him (apart from help) will trigger the Tarpipe workflow.

Have fun.

June 28, 2008

OAuth and Google

Excellent news!

Google now supports OAuth on all Goggle Data APIs.

*jour

On the topic of Bonjour goodies, take a moment to read about, and install, some of the *jour tools.

Very cool stuff.

Bounjour, CPAN!

For a Perl programmer, a local (on your laptop) CPAN mirror is a worthy investment. The problem is that a full mirror is 5.8Gb of disk space. Fortunately we have CPAN::Mini that creates a mirror of the most important stuff using only 830Mb.

So now you have your local mirror, and after you add the path to your cpan urllist configuration, all your module installations will use this faster mirror.

But you shouldn't stop there. If you are using a Mac with 10.4.x or above, you can share you CPAN mirror with the others on your local lan, and announce it proudly using Bonjour.

To do that, just follow these steps. First create a Apache configuration file at /etc/httpd/users/. I called mine cpan.conf and it looks like this:

#
# My local mini CPAN mirror
#

Alias /cpan/ /Users/melo/Documents/cpan/
<Directory "/Users/melo/Documents/cpan/">
    Options none
    AllowOverride none
    Order allow,deny
    Allow from all
</Directory>

RegisterResource "Local CPAN Mirror" /cpan/ 80

This will share your CPAN mirror (change /Users/melo/Documents/cpan/ to the path of your local mirror) and announce it via Bounjour with the name "Local CPAN Mirror".

Make sure that you start Web Sharing, at System Preferences, Sharing. If yes, stop and then start to load the new configuration file.

To use this CPAN mirror from other computers, you just start cpan, and then type o conf urllist URL where URL is the URL advertised.

Clicky Web Analytics