Debugging shell scripts, User Interfaces and compiled programs on Linux

When I want to debug a shell/bash shell script, I add the following to the script:


set -x
export PS4='+(${BASH_SOURCE}:${LINENO}): '

Other times, I export PS4 in my interactive shell, and run the script with “bash -x /path/to/script”. More bash script debugging tips are here: http://wiki.bash-hackers.org/scripting/debuggingtips

When I want to see what commands are being run on a Linux machine by a higher-level user interface, I turn to startmon. It shows me every process created, along with its arguments. This can be useful for figuring out how a CD/DVD-creation program calls wodim/cdrecord, or how it mounts a drive.

When I don’t have source code to a compiled program, and I want to see what system calls it is making, and check into why it might be failing to run, I use strace.

When I want to find out which programs are preventing me from unmounting a DVD or a USB flash drive, I use ‘lsof‘, which is available for nearly every UNIX-like operating system.

When I want to know what programs are consuming the most disk I/O and making things go slow, I use ‘top’ to see the top-memory consumers, and whether they have a high number of page faults. I use ‘iotop’ as well.

OpenWest notes: Do more with LESSCSS

I attended Jake Smith‘s presentation, “Do more with LESSCSS” at the OpenWest conference. Here are my rough notes.

Why use LESSCSS? Be organized in your CSS code — DRY principle (Do Not Repeat yourself)

What is LESSCSS not?

  • doesn’t solve IE or other browser bugs
  • doesn’t save you from yourself.

Gives you:

  1. variables, which are especially useful to help you reference paths or colors or fonts using String interpolation: ‘@{imgPath}divider.png’
  2. nesting. But don’t nest unless you really need to. Never go more than three levels deep on your nesting because it will bloat out your CSS.
  3. Normally, @import slows down page load times, but LESSCSS combines all your imports so that it’s a single HTTP GET.
  4. Hex math to make colors lighter or darker (as for visited links, etc.)
  5. Mixins — the heart of LESS.
  6. if/else — called guards. It looks like a media query.
  7. scope — inherit the closest variable
  8. namespacing

You can have less.js load and compile your less css. But don’t do it. Use CodeKit (a paid tool) instead to compile it before your browser sees it. It will minify it for you as well. There’s also the “Less App”, which is free. SimpleLESS works on Windows and Mac. And there’s LiveReload, which is a paid app for Linux, Windows and Mac. Or use the command line using Node.js’s nvm, then “lessc myfile.less output.min.css -x”

There’s a LESS compiler for PHP, Ruby, etc., but do not use them — they’re not being kept up-to-date.

LESS vs SASS

SASS has a built-in sprite generator. But Jake generates his own sprites.
LESS is gaining features of SASS, like @extend.

LESS 1.4 will have (will be delivered by the end of the month):

  1. :extend() functionality
  2. math must be wrapped in parenthesis
  3. variables as default variables
  4. new math functions
  5. convert function: convert(5em, px)

Fun and enjoyment when projects involve others

I believe we’re social beings, and that we succeed or fail based on the quality of our interactions with others. Such interactions introduce accountability and are educational and motivating.

Jake Edge reports that when Linus Torvalds was asked what motivated him to write Linux, the answer was that

If Linux hadn’t attracted other people right away, the project probably would have died within six months. But the involvement of others was a “huge motivating factor” for [Linus] to continue, because it “made it much more fun“.