website stat
PT Se está à procura da versão em português do meu blog clique aqui

Resume with scp

Secure Copy (scp) is a very interesting tool for securely transferring files over a network. If you do a lot of scp's you'll soon step against an unfinished transfer that you'll want to resume. Well, look no further. Here's an instant tip on how to resume an scp copy.

[bash]
alias scpr="rsync --partial --progress --rsh=ssh"
[/bash]

Now, restart or initiate another shell session. Instead of using scp just use the alias scpr that makes use of rsync to resume your transfer. The cream on top of the cake is the global progress bar!

Rails/Globalize tip

I'm absolutely burdened in work so there's no time for blogging or whatever might refrain me from producing (few exceptions apply — am I becoming a workaholic? nevermind the rhetoric question, I've always been one). But this tip is quick and very interesting.

If you're using the i18n/l13n Globalize plugin for your Ruby on Rails projects and you need to escape something from being translated in the middle of a sentence, you do not need to split it and then concatenate it as follows:

RUBY:
  1. "to be translated ".t + user.name + " more to be translated".t

You can simply use Ruby's sugar candy to the string format function.

RUBY:
  1. "to be translated %s more to be translated".t % user.name

Just make sure your translators don't mess up the %s placeholder.

There’s a new phishing approach in town!

Impressive how phisers have been constantly evolving the tools and approaches to scam people over.

Usually, they resort to replicating a page of a bank, PayPal, whatever, and put it on a different URL. People are lead to believe that they're actually logging in to the target website and they capture your authentication information.

This can be easily overcome with a little bit of precaution — make sure you're buying the milk from the milkman, i.e., reassure you're logging on the right website.

The newest approach, that I've just witnessed through the means of an email inbox assault, goes a little bit further in order to outcome this smartness one might use to unveil the scam. They exploit the original website to their benefit.

On this case, I received an email proclaiming to be from Paypal that said my account had limited access and I had to login. I wondered about it being a scam attempt but, nonetheless, checked the URL. Guess what? It started with https://www.paypal.com. It was even on an SSL encrypted HTTP channel. What could it be?

Now, if you've used Paypal before, you'd notice that many redirects occur between sign in and landing pages and also from external websites. They could have taken two approaches to pass the landing page around: by the means of a cookie or passing in directly on the URI. They took the second option. What happened was that the attacker simply replaced the redirect parameter with his own target website, misleading people into believing that everything should be fine.

The URL looks like this (if you haven't read the whole post, please realize this URL is a phishing attempt! Be careful).

https://www.paypal.com/cgi-bin/webscr/cgi-bin/webscr?cmd=_ssr&return=http%3A%2F%2Fpaypal-us.6s.pl/?cgi-bin.webscrcmd=_login-run.webscrcmd=_account-run.CaseIDNumberPP-046-631-789

As one can see, Paypal will freely redirect to the attacker's website.

Be careful.

Update - Phishing, of course. Typo fixed.

iPhone 3G

Apple simply blew up the competition. Destroyed. Annihilated.

iPhone 3G with GPS starting at $199. Unbeatable.

Mine will be ordered whenever it's available at the Apple stores.

Firefox 3 RC1

firefox_logo.jpg

It's fast. Damn fast. It's slick. Responsive. It has a nice theme. And tons of useful plugins that I can't live without like Firebug and WebDeveloper.

Firefox has always been my browser of choice on Windows and Linux and holds a very important place in what regards to web development on Mac OS X. But now I'm considering making it my default browser and displacing Safari. We'll see how things turn out.

Bottom line: a competitive market is wonderful.

OpenOffice.org 3 is awesome!

open-office-org-3-startup.png

After having used it for over a week, I must conclude that OpenOffice.org 3 beta is quite an achievement. It's faster, it now sports an Aqua interface (lovely for us, Mac OS X users), it's simple yet beautiful. It's more solid than ever before and comes with a full range of functionalities that the common user will certainly put to good use.

It still doesn't grasp to the extent of Microsoft Office's plethora of functionality, but it's definitely more than enough for the average Joe. Don't expect complex financial plugins to be available, but you're welcome to start programming your own. It's still a remarkable achievement in the Free Software world.

Congratulations to Sun and to the OpenOffice.org team.

MySQL to remain 100% Open Source

After MySQL was bought by Sun, a rumour started circulating stating that certain features of MySQL would be targeted at the enterprise version only and would never make part of the community version.

Right after this rumour started spreading around, criticisms arose and now it seems that Sun and MySQL paid attention to the community. Therefore, they're retracting back and dropping any plans of making pieces of MySQL closed source.

Hereto MySQL is to remain Open Source. After all, the community shaped MySQL the way it is today.

22″ displays are useless

Here's the point: most if not all the 22" displays have a resolution of 1680x1050, precisely the same resolution of most of the 20" displays. That means that buying a 22" won't add any real estate but only take some extra money out of your pocket.

22" might be useful for people that need to see everything in huge size. In that case you'll appreciate fonts set to 12px looking like they're 16px.

P.S. - On the other hand, a 22" display with a 1900x1200 resolution (equal to 24" displays) would be amazing.

Twitter and Ruby on Rails

First off, one clear remark: according to Evan Williams, Twitter is not abandoning Ruby on Rails. Got it?

Secondly, on an application such as Twitter that relies heavily on services and messaging Rails accounts for.. hmm.. 3% of the whole application?

Twitter is suffering from being a very write-intensive application, having an architecture not initially thought for scalability (handling tons of write requests per second and propagating them is not an easy task) and because, well, everyone uses it.

I do remember the numerous times Hi5, Digg or Facebook were down and, guess what, those are PHP and Java applications.

MacRuby 0.1

I am pleased to announce the first release of MacRuby, 0.1.

MacRuby is a version of Ruby that runs on top of Objective-C. More precisely, MacRuby is currently a port of the Ruby 1.9 implementation for the Objective-C runtime and garbage collector.

So far, since the project beginning was announced a few weeks ago, many bugs were fixed and features added. MacRuby is still at this point experimental, although if it’s also usable.

The purpose of this version is to release functional code, and also to let you test the new user experience. Please note that the project implementation will change deeply in the next releases.

You can learn more about the project on its homepage, and download a binary installer.

Enjoy!

Having access to the full potential of ObjectiveC by using Ruby (in the same fashion that one can use .NET through IronRuby) would be something of amazing and might draw a lot of attention back to Cocoa and application development on Mac OS X.

Dell Portugal vs Dell Spain

KM529.jpg

Take a look at the price discrepancies between Dell Portugal and Dell Spain when buying a 20" UltraSharp monitor (2009WFP)

Portugal: €269.00 + VAT (20%)
Spain: €249.63 (16% VAT included)

So, excluding VAT, the 2009WFP is approximately 22% cheaper in Spain.

Dell: it should be the other way around.

OOXML becomes an ISO standard

Lesson of the day: money wins.

getElementsByClassName has changed

Both Safari 3.1 and Firefox 3 Beta 4 have heavily changed the DOM method getElementsByClassName to reflect W3C specifications. Therefore, there's a strong chance that you'll have a couple of users complaining in case you're using this method.

To overcome this your best bet is probably relying on a high level select function like the one provided in Prototype or in jQuery's select.

Sweet Irony

20060226-gmail-logo-google-tm.jpg vs mail1.jpg

Life is replenished in irony. I've been praying for IMAP support on Gmail for ages. I sent several emails, I had the chance to talk to one of Gmail team engineers at GooglePlex, I wrote several posts begging for IMAP support.

Google finally added IMAP support about half an year ago. I was relentlessly happy. In a flash I was setting up my dusty email clients (Thunderbird on Linux/Windows, Mailapp on Mac OS X) so I could use them again. When I finished doing it, I thought to my self: Great!

But then I started missing Gmail's labels. So easy to support. Soon after I was also missing Gmail's excellent email threading system. And the quick search! Only Mailapp on Leopard (due to Spotlight indexing) was as fast as Gmail on diving through thousands of emails.

All in all, I soon realized that there's no advantage in having an email client comparatively to having Gmail's powerful web interface. But I might be missing something. I'll therefore ask our dear lazy web why should one use an email client like Thunderbird or Mailapp instead of Gmail's powerful web interface.

The iPhone has an SDK

Forget the title. I'm not going to talk about the virtues of the SDK or give the already-old news that the iPhone now has an SDK. Just behold on the word now.

One might think that Apple was obliged to create an SDK due to popular demand. But this is Apple. No one forces Apple so if it wasn't their intention to develop an SDK they wouldn't develop an SDK. Furthermore, take a look at how fast they built it. Too fast. It was already being made prior to the launch of the iPhone, one might conclude.

Why did Apple took so long to launch it then? It goes beyond the eyes of the viewer. Steve Jobs is damn smart and so are Apple's Directors. Think about it. The SDK will be of utter importance to the corporate users so they can access their applications and corporate email. Regular users might get a game or two but the default set of applications is already quite good, so the SDK won't bring any breath-taking application.

On top of that, corporate users don't rush to buy the latest tech gadget. Common users do it.

So what Apple basically did was refreshing the hype on the iPhone without having to upgrade it or throw a shiny new model. These guys are good at this, whether you like them or not.

P.S. - As soon as there's a GPS application for the iPhone, I'm finally buying one.

10 things I hate to read on other people’s blogs

Here's a 10 items list of the things that importunate me the most when reading other people's blogs.

10) Top 10 lists like this very one;
9) ?
8) "Links for today" posts. If I want links I'll just go to del.icio.us, thanks;
7) Posts containing images that have nothing to do with its content;
6) Gossip and pop posts;
5) Posts citing other articles and essays that don't contain a link to the original post;
4) Political propaganda (propaganda differs from facts, ideologies or politics in general), being it neoliberal or communist;
3) People begging to subscribe to their feed. If I like your blog I'll do it, if you beg, I won't;
2) Posts garbled with inexcusable grammar mistakes like "I are good to jumping";
1) Writing "M$" instead of Microsoft. C'mon, we all dislike Microsoft a bit (a lot), but that's just childish;

MySQL 5 x64 flies

I've just installed MySQL 5.0.51a x64 on my development machine (Mac OS X Leopard) and on my test machine (Ubuntu x64) and this is damn fast. No, really, you can notice the speed improvements over the x86 version even without having to run one single benchmark.

If you're not upgrading from heavily different architectures (like *nix to Windows Windows to *nix) copying the entire data/ folder might pull the trick. Migrating from x86 to x64 works because MySQL doesn't store any pointer or other architecture-dependent in the data files, otherwise you'd have to do a full dump and proceed with a restore of all the tables.

64 bits registers in database environments is definitely a blessing. Oh, and making use of more than 4GB of addressing space is also useful.

Vobis Top Laptop Sales

Vobis is a Portuguese computer store like CompUSA used to be in the US.

Here's the list of the laptop top sales. Apple occupies three slots of the top five, winning the first and second place.

Don’t buy the Macbook Air…

Buy this brand new Dell instead...

dell_d630.jpg

Dell XFR

Nãaa.

P.S. - This post serves to show that there are niches for different products, even for this damn ugly Dell.

Going for a cheap NAS

I'm in the market looking for acquiring a cheap yet powerful NAS.

The first option is maintaining your own machine (choose your *nix flavor) with an array of disks in RAID1 and SMB/CIFS. Yeah, cool, but it has a couple of disadvantages: 1) it wastes more energy because it will probably be running on a more powerful CPU; 2) maintenance is not as straightforward as pushing a reset button; 3) it probably won't allow hot-swap as most NAS devices allow; 4) you'll waste much more time.

If I were to go to a custom-tailored NAS I'd definitely choose FreeNAS, which is a stripped down version of FreeBSD with a very cute web interface for configuring everything. It's stupidly easy to configure (you don't even notice it's running over FreeBSD), lightweight and powerful. But it still suffers from problems previously referred, namely 1) and 3).

In the end, I just want something that you plug, configure an IP and that's it. Considering these requirements of tantamount importance, I've looked up and I got the following contenders:

1) HP mv2120
2) Dlink DNS-323
3) LaCie 2big Network

All of them run on Linux and provide about the same functionalities. Except for Dlink, all of them have a 1Gbps network card, work over CIFS and allow RAID1. They all work over a web interface and have at least one extra USB 2.0 connection that could be used to plug another external hard drive.

The HP model is hot sexy but it hasn't been released yet (expected March 2008) and these kind of business products from HP are usually hard to get for non-resellers like me.

Dlink lacks the 1Gbps port but, except for that, nothing note-worthy.

LaCie seems like the winning contender. It already comes with the two hard drivers which is a major plus, sparing you from having to purchase separate disks. It's nice, sleek and not that expensive. €480 for the 1TB version, which already includes 2x 500GB SATA-II hard drives. Another major plus (along with HP's mv2120) is that it includes a really nice backup utility that might be useful for Windows machines, unaware of the power of rsync.

I'm probably going for LaCie 2big Network 1TB (which is actually 500GB on RAID1).

Even virus run cooler on a Mac ;-)


P.S. - Contains a video.

Convert a physical Linux to VMWare

I recently decided to convert a Linux installed on a physical machine to be run inside VMware, hosted on a much more powerful machine. Two reasons for this: 1) the host machine is quite powerful (2x Quad Core Xeon, 4GB RAM); 2) the Linux image was lightweight enough.

The process was quite simple. I started by installing the same version of Ubuntu (Ubuntu server 7.10) that I had previously installed on the physical machine. I could just use dd to make a full copy of the / partition and pray that the devices get correctly re-detected but this way was cleaner and safer. The Ubuntu installer detected all the virtual hardware and configured correctly.

Now it was time to make a raw copy of key directories like /var, /usr, /etc/, ... You can't copy the files while the target Linux is running so I just popped in a Ubuntu Live CD and mounted the target disk. To make things easier, I installed openssh-server on the Live CD Linux instance, mounted the target disk in /media/disk and issued the following command:

CODE:
  1. $ tar -zcvpf - --exclude=/proc/* --exclude=/dev/* --exclude=/media/* --exclude=/boot/* --exclude=/tmp/* --exclude=/var/cache/apt-get --exclude=/sys / | ssh root@new_host "cat> a.tar.gz | tar -xvvf a.tar.gz /media/disk"

The aforementioned command will tar gunzip all the relevant system directories, excluding device files and other system-specific settings.

When finished, you're almost done. The only thing left will be fixing the UUIDs that identify the partition blocks. Just issue a $ sudo vol_id --uuid /dev/sdaX for each partition and replace /etc/fstab and /etc/mtab accordingly.

And you're probably done. This is a very brief tutorial as this is directed for experts. You can fill in the gaps.

Time.now.usec in Windows

There are certain things that one programmer only thinks of when it comes across them. The one I'm about to tell is definitely the case.

I was deploying a custom made Ruby application on some Windows machines of a client. While testing the deployment, there were some weird errors that couldn't be happening: duplicate keys while inserting a record on the database. The field causing the error was set as unique as it is a record id on a third party billing software. It was a timestamp including milliseconds.

Now, generating a timestamp up to the milliseconds level worked fine on my development machine (Mac OS X) and on my server machine (Linux/Ubuntu) as well, but it was failing miserably on Windows. Why's that? Could it be that Windows doesn't update its timer often enough? Gotcha!

For some unexplainable reason, Windows (Vista!) only updates its timer every 10ms, meaning that two consecutive requests for time will get the same timestamp. While on *nix machines you get time updates up to the nanosecond level, on Windows you have a long time before an update happens. And 10ms in the computer world is an eternity!

So here's the quick fix for stopping this from happening. Just stick a Kernel.sleep(0.01) before the Time.now.usec call and you should be fine. It's ugly, it makes you lose 10ms of your processing power but it's a practical and fast fix.

P.S. - You can test this behavior by doing 10.times do puts Time.now.usec end on irb. Depending on your CPU, you might get up to 10 times the same time! On a low-end Dual Core HP laptop I got about 4 different times in 10 successive calls.

Thanks Vodafone

It's March 2008 and Vodafone's website still doesn't work correctly with WebKit web browsers like Safari or Konqueror.

Who said Apple is expensive?

aapldell.gif

Dell is one of dirty-cheapest hardware companies out there.

Whoever still thinks that Apple is expensive must be living in 1980.

Firefox slow on localhost connections on Vista?

I've been working on a project for a client consisting of a website running on a couple of laptops (about 10). This project has been developed in Ruby on Rails and everything went fine until the final deployment on the laptop machines running Vista. On these machines (cheap HP G7000 by the way) it was really slooow. And I mean it.

I did some benchmarking and I was getting around 10 reqs/sec on a high load web page without any kind of caching. 10 reqs/sec is more than enough for a single user web application. It couldn't be it. Also, it was working blazingly fast on my laptop.

I never questioned Firefox. I've never had speed issues with Firefox in the past. But anyway, I popped up Internet Explorer and I was incredule to see that the site was flying in IE7.

A quick Google search led me to this. For some particular reason I'm yet to assert, Firefox gets stuck if IPv6 for DNS querying is activated on Windows Vista.

A simple

network.dns.disableIPv6 false

under about:config will fix it.

I disabled it and the problem is gone. I'm wondering who's fault is it.. considering that under the same settings Firefox runs perfectly fine in Windows XP, Mac OS X and Linux I'm very suspicious about Windows Vista. I loath it.

P.S. - Not to add that Vista's unzip utility is seriously broken. It was extracting a 50MB zip file (InstantRails, by the way) at a rate of 5Kb/sec. Downloading the open source 7-Zip, installing and then extracting the file was faster than waiting for Vista's unzip to finish its job.

What a kerfuffle… with an happy ending!

Wow. This was something.

What happened dude?

It all begun yesterday. I started feeling sick and the cough and fever were chasing me like hell. Next day (today), I woke up fairly bad and unable to work. The best I could do would be standing still in front of the TV watching the news. Even movies were too much for me. Unable to work, I decided it was time to take care of less relevant things -- like finally upgrading my Macbook to Leopard.

As you clearly shouldn't do, I decided that doing a backup was too boring. 100GB of data would take quite some time and my boredom levels wouldn't permit it. Absolutely unwise! And I had all the relevant data stored on my server anyway -- so, a failed upgrade only meant installing tons of applications, MacPorts, tuning the system, restoring data.

So I went forward with the unwise decision of skipping the backup. But when you're sick (and even when you're healthy) you can do dumb things. Twice. In a row.

I popped in the Leopard DVD and I did my second mistake: skip the verification of the DVD. Guess what? Yes, the DVD was scratched. So during upgrade it suddenly aborted upon a failing checksum. Oh boy, I was mad.

The DVD was indeed scratched. I should have noticed before or at least have waited for the checksum to finish. Result? A dead system.

Did you give up and did an Erase and Install?

That thought popped through my mind. But I'm not an easy quitter. That would be the easy exit.

Although I don't have that much knowledge of the Mac OS X installation process, it couldn't differ that much from the *nix world -- run a couple of scripts, delete some files here, add some files there and update configuration files. Therefore, a deterministic process. This would mean that repeating the process would work.

Considering this, I created an image of the DVD and burned it on a blank dual layer DVD. Sticked it in and did an upgrade. Again.

It went through. This was a fresh, blank DVD so no way in hell it could have scratches. Restart. Cross Fingers.

Now what?

Oh, the joy of an endless wheel spinning around. After 15 minutes on the grey screen with the Apple logo and the spinning wheel I realized it was a dead end. Something was wrong. Google to the rescue.

First, I tried doing a safe boot. Wouldn't work. Then I tried a verbose boot to see whether the kernel was panicking. It wasn't, but somehow the boot process was failing. It could be due to a kernel extension from the prior system that was causing some incompatibilities. Let's take care of that.

I found this really helpful article. It explained how to remove some caches or disable some kernel extensions. Thanks to the microkernel nature of Mac OS X's Mach kernel, doing it was fairly easy.

But it didn't solve the problem. The system was still not booting.

So, you gave up and did an Erase & Install

Wrong. I couldn't settle with such mess and resort to the easiest exit: format and install. That's too Windows-ish.

So I decided to do another upgrade install. Some third-party kernel extensions were disabled and it might work now.

Installation went fine and the system finally booted up to a login screen. Tcharam.

Done!

Not quite. My user account was gone. Actually, my user's folder was still there, my I was unable to login with my username. Vanished to the confinements of /dev/null. Off we go to another reboot, this time in single user mode.

While in single user mode, I've activated the root account so I could login to the system. $ sudo passwd root did the trick and in a couple of minutes I was logging in into Leopard's root account.

From there, I just re-created my user account. It detected my user home folder and imported all my settings -- from the background image to the icon disposition.

Lessons from a turd to you kiddos

Ok, what did we learn today? Backup. Really. If I had done a backup with SuperDuper! I could easily restore the system up to a bootable state and then just repeat the installation process this time with a workable DVD.

But if you're too lazy to backup (now seriously: I only did this because all important data is stored on my home server -- NEVER, and I mean, NEVER, do this) at least check that the friggin' DVD is working.

Fortunately this had an happy ending. I've just installed 10.5.2 and everything seems miraculously fine. As Lou from Little Britain would have said: "What a kerfuffle!"

Are you ready?

Imagine traveling on a bus and getting through tons of traffic. Options: 1) read a book or a journal, in case you carry one; 2) mock at people around you; 3) go nuts and start yelling at the person sitting nearby; 4) do nothing, tumble your eyes and ignore.

There's a fifth option. Grab your mobile phone and see where your friends are. Check what are your friends doing or send the picture you grabbed from the hot chick in front of you. Wouldn't that be insanely cool? (crowd cheers).

Well, some guys are doing precisely that. They realized technologies are shifting and the mobile phone is to become the main stage for communications. I might add that the real boost will happen when prices for internet access through mobile carriers drop. But the phenomena is already happening. There's no way back.

So, why don't you pay them a visit? They're still tinkering with their debuggers but sometime in the near future they might have something ready.

We welcome you, Handivi.

I’m marveled with Sphinx

It took me half an hour to have Sphinx up and running indexing a couple of related tables and doing queries in Sphinx using through Rails.

Andrew Aksyonoff, you rock dude! Way to go!

P.S. - And so does Kent Sibilev for having written the acts_as_sphinx Rails plugin.

P.S. 2 - Note to self: if I ever get rich, give a bunch of money to these Open Source developers. They truly deserve it.

Ferret or Sphinx?

When looking for a full text search engine you wonder whether your database will be enough. For more than 2M records, some databases like MySQL might not handle it very well and take longer than desired (way longer if you have multiple indexes and crossover queries). PostgreSQL has some advantage here due to its built-in tsearch2 engine. But even tsearch2 might not be enough if we're dealing with complex documents and lots of records.

So you've realized you need a real document full text search engine. One name pops to mind: Lucene. That's an obvious choice if you're using Java. If you're not, integrating Lucene with your project is trickier.

If we're talking about Ruby projects, other two options pop to mind: Ferret and Sphinx. Let's spoil it and quote some authorities in the Ruby community:

We've used ferret on past projects... and now use sphinx. We're not
likely going back to ferret. ;-)

Robby Russell
Founder and Executive Director

And now from EngineYard,

Ferret is unstable in production. Segfaults, corrupted indexes
galore. We've switched around 40 clients form ferret to sphinx and
solved their problems this way. I will never use ferret again after
all the problems I have seen it cause peoples production apps.

Plus sphinx can reindex many many times faster then ferret and uses
less cpu and memory as well.

Cheers-
- Ezra Zygmuntowicz
-- Founder & Software Architect

Ok, when something as crystal clear as these statements come from these kind of people there are very few questions remaining as to which one to choose. You probably stick to Sphinx.

But let's make it clear why Sphinx will probably be the best choice: it talks to MySQL directly so there's no need for you to handle the data back and forth to the search engine; it's darn fast and efficient; it's used on high load websites like ThePirateBay.

I've actually used Ferret in the past and still use in some of my projects (like blogaqui.com) and it has served me well. But these websites do not hold millions of records. The most complex queries it does is to blog posts, and I have around 500k stored in blogaqui's database.

Sphinx it is, then.