Archive for the 'English' Category

Shell-script: variable default vaule

  • english
  • spanish

It’s possible to assign a default value to a variable in case it isn’t already defined. The syntax is:

FOO=${FOO:=bar}

Example:

$ FOO=${FOO:=bar} $ echo $FOO bar $ BAR=test $ BAR=${BAR:=foo} $ echo $BAR test
Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

watch

  • english
  • spanish

watch runs a command and keeps its output on screen updating it ever X seconds and, optionally, highlighting the differences on the output between executions. It’s an easy way to monitor the output of some command without having to spend several minutes pressing “cursor up - enter”. :-)

watch -n 1 "ps aux | grep apache"

Si te ha interesado, ¿me invitas a una cerveza? / If you liked the post, would you buy me a beer?

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

WordPress thumbnails the size you want

  • english
  • spanish

One thing I always missed in WordPress is the ability to select the size of the thumbnail that’s generated every time you upload a picture to your blog. The default size is quite small, sometimes you may want it, for example, to be as wide as the page, without needing to scale the original pic down in HTML with width=”xx”.

I’ve found today the imagesControlSize plugin by aNieto2k, that allows you to select the thumbnail’s width when uploading an image (the height is calculated automatically, maintaining the aspect ratio). Works great.

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Time Machine and Virtual Machines

  • english
  • spanish

A small detail about Time Machine I hadn’t thought about before: this article recommends removing all the virtual disks from virtual machines like VMWare, Virtual Box, et al. from the backup.

Makes sense: Time Machine works at a file level, in the end it’s just something like this but with an über-posh interface. So every time you boot one of your VMs, some small change will inevitably be made on some file inside it, causing Time Machine to store a new copy of the full virtual disk.

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

fonebridge2 Case Study

  • english
  • spanish

Some days ago, a representative of Redfone Communications got in touch with me because of a HOWTO I wrote some months ago about building Asteirsk clusters with the fonebridge2: they liked it and wanted me to write a Case Study about the cluster I built at my previous job.

The Case Study has just been published and is available here:

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Broadcom Wireless on Linux

  • english
  • spanish

At work I have a Dell laptop with a Broadcom BCM94311MCG wireless card:

# lspci ... 0b:00.0 Network controller: Broadcom Corporation BCM94311MCG wlan mini-PCI (rev 01) ... # lspci -n ... 0b:00.0 0280: 14e4:4311 (rev 01) ...

The drivers that Ubuntu installs by default were giving me lots of headaches depending on the network’s access point: on some of them the card worked OK; on some others I kept loosing the connection every few minutes, or I couldn’t connect at all. I never found out if the problem was the encryption algorithm in use, or the wifi a/b/g/whatever protocol. Bottom line is the driver worked on some networks but didn’t on some others.

A co-worker told me he had the same problem until he switched to the ndiswrapper driver, so reluctantly I tried it. It work great. :)
More info here:

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Reports by parent category for Buddi

  • english
  • spanish

Buddi is a nice little program that helps you managing your personal budget, by defining categories, assigning a budget to them, etc. I’m quite bad at this kind of things, and after two months using Buddi I know how much I expend on things, and how much can I save each month. I love it.

One of my favorite features of Buddi is that it has an API that allows you to develop new reports, so I’ve developed mine. I have all my categories in groups (bills: electricity, water, telephone; home: food, drugstore, others; you get the picture), but all the reports in Buddi show all categories in a flat list without grouping them by parent category. This plugin does just that: all sub-categories are shown right under the parent one, and all of their budgets and expenses are added to those of the parent category, so that you can easily and quickly know how much you expend on each group.

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Shell-script: substrings

  • english
  • spanish

You can work with substrings in bash using the following syntax:

${VARIABLE:START:LENGTH}

Like in:

$ A=abcdefghi $ echo ${A:3:2} de
Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

cssh: Cluster SSH

  • english
  • spanish

cssh.jpg

Cluster SSH (cssh) is one of mankind’s greatest achievements. Really. Or at least, from a sysadmin point of view. :-) It’s one of those programs that, once you know it and start using it, you wonder how were you able to survive all those dark years without it.

cssh takes a username and several IP addresses on the command line, and opens a SSH session against each of those servers on an independent xterm window. Then, you can click on any of these windows and work independently with that particular server, or go back to the cssh console and write there, and ssh will retransmit each keypress to every SSH session.

This is a very useful tool when working with server farms, clusters, etc. For example lately I’ve been doing some monitoring and maintenance tasks on a 32-server farm on a major ISP: one by one each config modification would have take hours, with cssh it is a matter of minutes. :) Besides, as it replicates every keypress, it even works with text editors like vi: you can edit a file on every server at the same time, navigate through it, modify it… in parallel on every server. You have to be very careful when doing this, though. ;)

Si te ha interesado, ¿me invitas a una cerveza? / If you liked the post, would you buy me a beer?

Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Shell-script: timestamp

  • english
  • spanish

A one-liner function that, when piped with the output of another command, prepends each line of that command’s output with a timestamp.

Very useful with commands that output a series of lines periodically but without a timestamp (like vmstat), so that you can’t just send their output to a file and go back to it later without a timeframe.

$ function timestamp { while read l; do d=`date +%H:%M:%S`; echo -e "$d $l"; done; }
$ vmstat 1 | timestamp 12:17:03 procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- 12:17:03 r b swpd free buff cache si so bi bo in cs us sy id wa 12:17:03 1 0 4 16740 42816 395164 0 0 6 5 174 11 3 1 96 0 12:17:04 0 0 4 16656 42816 395184 0 0 0 0 393 510 1 1 98 0 12:17:05 0 0 4 16656 42816 395184 0 0 0 0 391 781 2 1 98 0 12:17:06 1 0 4 16656 42824 395176 0 0 0 84 462 976 3 1 95 0 12:17:07 0 0 4 16656 42824 395184 0 0 0 0 433 1545 11 3 86 0 12:17:08 0 0 4 16656 42824 395184 0 0 0 0 356 807 1 2 97 0
Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb



Creative Commons Attribution-NonCommercial 2.5 Spain
Creative Commons Attribution-NonCommercial 2.5 Spain