Colorized tail

28 May

I was tailing a logfile and I wanted to colorize some specific keywords in it. I found Andreas Schamanek’s mycolorize which serves perfectly for the purpose.

Download it and use it by doing

$ tail logfile | ~/mycolorize color 'regexp'

You can check additional examples and documentation on the website.

Issue with Terminator keybindings in Ubuntu 12.04

17 May

If Terminator keybindings with Ctrl-something are not working for you, it’s due to a bug.

Until it is fixed, you can edit your ~/.config/terminator/config and replace <Primary> by <Ctrl>.

Clone-a-database one-liner

9 May

I had to clone a remote MySQL database into my Ubuntu notebook, and I just felt like doing a one-liner for it.

$ mysqladmin -f -uroot create sandbox &&
ssh "mysqldump -uroot sandbox | gzip -f" | gunzip | mysql -uroot sandbox

Sending data to the clipboard from command line

26 Apr

In several occasions I find myself catting some file and then having to select the entire text with the mouse. If I want to keep my hands on the keyboard, I have to do a vim file, ggVG, “+y, :q.

Well, I found a way to do it faster and nicer simply by piping to the clipboard, thanks to xclip.

To use it, just install it and configure an alias in your .bashrc file, as follows:

$ sudo apt-get install xclip
$ alias clipboard='xclip -selection clipboard'

Then, when you need to do something like configuring your SSH key in GitHub, you just:

$ cat ~/.ssh/ | clipboard

Thanks to Brian Racer for this snippet!

Enhancing vim for Scala

6 Apr

You like Scala. You like programming. You like vim. You are happy.

Here’s the 2-line solution to increase your happiness even more:

cd ~/.vim
svn export --force .

And there you go, nice indent and syntax highlighting support for Scala.

Massive thanks to Nico “@nfmelendez” Meléndez for pointing this excellent package!

A “did you mean” alternative to the NASCAR problem

2 Apr

I’ve been playing with an experimental UI for avoiding the NASCAR problem. The main idea is to be more open in the expected input from the user.

Nowadays we have several popular identities we use in business cards, e-mail signatures, presentation slides, etc. Depending on what I do like the most, and probably depending on the context as well, I may say I’m @luisfarzati. Or Or Or just find me by luisfarzati: it’s the screen name I use everywhere: LinkedIn, Flickr, GitHub, and so on.

Most of these services have an open API with a public, limited access that allows anyone to know if there’s a person registered under a certain username.

Why don’t we leverage these APIs and let the user input whatever they want to login? If it exists as a valid username out there, we’ll find it and suggest it.

Feel free to try with many combinations. @twittername,,,, WordPress blog URL, Open ID URL, etc.

You can try the concept demo or get the source files on GitHub.

Enhancing vim as an HTML/JS/CSS/PHP editor

11 Jan

I have enough of heavyweight, sometimes cluttered IDEs. I don’t know, maybe I’m getting too old-school or something, but I find myself working faster with plain old vim.

Of course, over time I have been optimizing the editor with the addition of several plugins and customization of its settings.

Here is my current vim setup focused on HTML, JS, CSS and PHP programming:

  1. Install NERDTree
    This gives you a nice tree view of the filesystem.
  2. Install IndentAnything
    Name says it all.
  3. Install JavaScript indentation
    A nice JS indentation for IndentAnything
  4. Install JSLint
    Validates the code for compilation errors as well as styling and informs you of this, almost in real-time!

You might want to throw in some visual enhancements as well. The railscasts color scheme along with the Monaco font are a pretty good combination.

Finally, my .vimrc file:

"Keyboard mappings
map :NERDTreeToggle

"FileType support
set filetype=on
filetype plugin on
filetype indent on

"Color scheme and font
autocmd FileType javascript,html,css,php colorscheme railscasts
autocmd FileType javascript,html,css,php set gfn=Monaco\ 10

"Hightlight current line
autocmd FileType javascript,html,css,php autocmd InsertLeave * set nocursorline
autocmd FileType javascript,html,css,php autocmd InsertEnter * set cursorline
autocmd FileType javascript,html,css,php highlight CursorLine ctermbg=40 cterm=NONE

autocmd FileType javascript,html,css,php set ai
autocmd FileType javascript,html,css,php set sw=2
autocmd FileType javascript,html,css,php set ts=2
autocmd FileType javascript,html,css,php set sts=2
autocmd FileType javascript,css,php set textwidth=79

"Enable autocompletion
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

"Enable line numbers
autocmd FileType javascript,css,php set number

"Enable incremental search
autocmd FileType javascript,html,css,php set incsearch

And that’s it. Please feel free to post your suggestions!

One-liner for downloading and extracting a tar.gz

18 Nov

I’m not the typical Linux one-linerd, but there are some that I find very useful.

Why execute 3 commands to download a tar.gz file, extract its contents and delete the archive, when actually there’s no need to store the archive physically (you only care about its contents) and you could save one command in the process?

So that’s why I love
wget -O- <url> | tar zxv
I tried the same for zip files but it doesn’t work. According to man unzip:

Archives read from standard input are not yet supported, except with funzip (and then only the first member of the archive can be extracted).

If anyone knows a workaround, it will be very appreciated!


Facebook is the new Web

9 Nov

Meanwhile, in the future…

Open the lid of your Facebook laptop (which is a netbook, but with Facebook OS), or turn on your Facebook phone, or put channel Facebook in your Smart TV. Do everything (in Facebook, of course). Done.

Really. Name one thing you can’t get on Facebook: E-mail. Oh, wait.

Chris Messina wrote an excellent post about the death of the URL. I think I would go a step further and think about the death of the Web. No bookmarks. No searching. Everybody wants whatever is relevant now: if your website doesn’t show up among the conversations, it probably doesn’t worth a visit. Period.

Sitting in front of your computer and opening Facebook is the new sitting in front of your TV and zapping through the channels.

Where Open ID failed, Facebook Connect succeeded. Where AOL failed, Facebook succeeded.

I wouldn’t be surprised to see Facebook launching a browser next year.

Update: according to comScore, Facebook took the lead in time spent:

Ubuntu 10.10 suspend/resume issue

3 Nov

Tired of virtualboxing Linux for development (nothing wrong with VirtualBox, though) I’ve decided to dual-boot with Ubuntu 10.10 desktop edition. Everything was just fine until I close the lid and had some lunch. When I came back I found out that Ubuntu was booting from the start.

I had it fixed by adding the following option to GRUB_CMDLINE_LINUX in the /etc/default/grub file:
Then I had to update grub by executing
sudo update-grub
And finally, had to restart Ubuntu in order to get the new boot configuration.


%d bloggers like this: