Archive

Archive for November, 2007

Console input on Ruby: Masking passwords on the command line

November 19th, 2007 Dante Regis 2 comments

I like plain old console applications. They are fast (to program, compile and use) and, of course, add a cool factor, like people saying they have absolutely no idea of what you are doing!

Ruby, of course, can do console apps, but it’s not trivial to read user input. And what if you want the user to type a password? You would like, of course, to show them asteriks ‘*’ or nothing at all instead of the plain text being typed.

Well, “highline” gem covers this and much more. What about writing:

ask("Enter your password:  " ) { |q| q.echo = "x" }

And that’s all! That’s quite cool, man. It can even check if the answer matches some regex, or split it by commas, or anything you want
Take a look at it: http://highline.rubyforge.org/

Categories: programming, ruby Tags:

Change Vim Swap (.swp) files default path

November 18th, 2007 Dante Regis 4 comments

I work with subversion as a version controller, and I’m a big fan of console. But it’s quite annoying to type a “svn status” and receive lots of question marks on something.swp or .sw0 . Other version control system probably suffer from this issue, unless they have recursive ignore (which, as far as I can tell, svn doesn’t)

Well, I just found Vim Tip #20, which teaches us how to change the folder path for swp files. This way, all swap files for Vim (and, of course, gVim) will be saved on the specified directory.

The comand is :

set directory=/path/to/dir,/path/to/another/dir

There is also “set backupdir=/path/to/dir” to move those something.rb~

Hope this helps you as much as it helped me!

Categories: howto Tags:

Writing code on wordpress.com

November 18th, 2007 Dante Regis No comments

We all know that you can install plugins on your own (hosted by you) wordpress.org blog. But on wordpress.com pasting code was always a lost battle. But you can now use the

[sourcecode language=`yyyy`] [/sourcecode]

tags on your blog. There’s a list of supported languages here: Wordpress.com FAQ .
Enjoy!

Categories: Uncategorized Tags:

VMWare, Linux and Wireless Networking

November 17th, 2007 Dante Regis No comments

We all know wireless network hardware builders don’t like Linux much. Or maybe it’s the other way around. Anyway, making it work is usually a hassle, and if you got here, probably VMWare network isn’t going any good for you.

The problem is that bridged networking on VMWare (the best one for home use) requires the host’s network card to enter promiscuous mode. It is not something most Linux drivers do. You have 2 options, then: find out a way to make your card promiscuous (dirty jokes goes here) OR you use NAT networking. Much less trouble, works fine for basic Internet, but maybe can’t be used in some situations.

If you are a normal user without special needs, just try NAT network for your VMWare when you are using wireless.

Categories: Uncategorized Tags:

Notebook HD problems with linux

November 17th, 2007 Dante Regis No comments

This post has alerted me of a big problem on laptop HDs that apparently happens to Linux users (according to other post from this same author, Vista has the same issue). It seems that the power-saving technologies keep telling the hard drive heads to sleep, while Linux keeps telling the drive to read or write something down. This wake-sleep-wake process consumes the life-time of the drivers to the point of failling hardware within an year.
The current workaround is to shutdown power management to hard disks with hdparm “hdparm -B 254 /dev/sda” (or /dev/hda, depending on your configuration).
More detailed info can be found on Ubuntu Bug at Launchpad.

Powered by ScribeFire.

Categories: linux Tags: