...making Linux just a little more fun!

<-- 2c Tips | TAG Index | 1 | Knowledge Base | News Bytes -->

The Answer Gang

By Jim Dennis, Jason Creighton, Chris G, Karl-Heinz, and... (meet the Gang) ... the Editors of Linux Gazette... and You!



(?) Lifehacks

From Jimmy O'Regan

Answered By: Jimmy O'Regan, Brian Bilbrey, Raj Shekhar, Heather Stern

I'm looking for everyone's lifehacks. For more information about what a lifehack is, scroll down -- I've included the introduction to an article I was writing for another site (cough) that I couldn't make relevant there -- but in short, it's things that make your life easier, like Ben's quote catcher or my screen scrapers (they save me ~5 minutes per day that I can waste on IRC instead  :) .
So drag out your ugly scripts, or at least say what they do in principle. (No, I don't have any that haven't been made into articles already :) -- Jimmy


Lifehacks

Lifehacks are an idea that was put forward by Danny O'Brien at the O'Reilly Emerging Technology Conference. Lifehacks are the result of taking one of the basic principles of self-help -- find out how the experts work, and emulate them -- and applying it to geeks.

One of the least surprising discoveries of the Lifehacks research is that "Overprolific Alpha Geeks" spend most of their working lives using the shell. Two of the conclusions of the talk are that geeks will have private blogs/RSS feeds.

Why would you use private blogs?

Most people need to provide their bosses with periodic reports. Because feed aggregators are available for almost every imaginable platform, reading feeds is not an issue. Having reports available in a private blog offers two immediate benefits: each report is archived in a known location; and the feed reader provides notification of new entries (as well as keeping its own archive of entries). Making reports available as a feed can also boost productivity and increase communication -- sysadmins, for example, can generate many of their reports from log files, and add this to the feed so their boss no longer needs to wait around for a formal report; programmers can use scripts in CVS (or other version control systems) that generate a report containing a list of changed files and the log message for every commit.

A popular use of blogs is as a whiteboard -- people thinking out loud, inviting passers-by to offer suggestions or criticism which may help to improve an idea. By maintaining different blogs with varying levels of availability, people can share ideas with the appropriate audience without revealing things they would prefer to keep secret.

The most basic advantage of writing down an idea is that you no longer have to worry about remembering it. Even writing to a completely private blog, as a "todo" list, has advantages. Writing an idea forces you to clarify your own thoughts: the simple act of writing an idea down to remember it can lead to you expressing it well enough to share it with a wider audience. Once an idea is written, it can then be refactored -- you can share it at a later date, when you have developed it further. Another advantage is that each blog entry is automatically dated, so each idea can be compared with public blog entries from the same time, so you can discover why the idea was relevant; and if nothing else, a blog provides you with a single place where you can archive your ideas and "secret scripts" in case you need them again.

Semi-public blogs, available only on a company or department intranet, allow co-workers to keep track of each others activities and to offer and receive suggestions about ideas without publicly exposing company secrets. Information put on a semi-private blog may later become suitable for public consumption, such as a note about a bug in a product, or information about server downtime.

(!) [Brian] Thank you.
Thank you, Thank You, THANK YOU!
This is the sort of thing that I've been doing unconsciously for the last 20 years, and what's been lacking is the vision to make it a conscious process.
Every machine I have does webserving, I drop stuff into the serving space for testing, for review, for remembering.
I put stuff on my public site so that when I forget I ever knew how to do a thing, I can google for the answer and find what I wrote once upon a time (that's happened THREE times in the last year).
I rsync everything, everywhere. Cron takes care of most of it, occasionally I'll manually run a set to a sometimes running box, and then shut it down and put it in the basement. Mostly that's private stuff, and not the things that can be replicated or are static, committed to DVD+R (like the ogg collection).
I run phpGroupWare at work with Calendar, TroubleTicket and Todo modules active.
I publish fun and useful links in my webspace on the internal server - everything from a demo of how the Windows messenger error looks when Samba + ClamAV +Samba-vscan catches an inbound virus, to the mods I might make to my cube to get a nerf-weapon war type of battle-cube.
All of my email accounts are IMAP, I have 5 active places, and I copy stuff from account to account, in and out of the assorted todo sub-folders as I want to apply the topic to the part of my life in question.
(!) [Jimmy] I do the same. Anything that I really like, or may need in real life, I email to my phone (my phone has Blackberry email, so email to my private account comes in like an SMS message: straight to the phone, no need to check :)
Email is one of the top geek ways of keeping information, according to that survey. Wanna remember something, mail it to yourself.
(!) [Brian] I don't have a useful PDA. I've had FUN ones, linux-based, but I'm thinking I need a real one, one of these days. Useful AND used. All the Linux ones provided tools to sync/work with Windows boxen. Um, sorry, don't run that one, got any other choices? I'm leaning towards Treo. Any thoughts?
(!) [Jimmy] I use my phone as a pda. Getting SyncML going is something I really want to do, but I'm not sure I want to be synchronising across the Internet when the phone is right beside the blasted PC :(
SyncML is now part of the Open Mobile Alliance (http://www.openmobilealliance.org/index.html) -- Heather
(!) [Brian] I have one "blog" that I'm experimenting with, using Wordpress . There are parts of it I like, but for many purposes I really like the read-in-time-ordinal of journalling rather than the reverse mode of Blogging. I suppose that's why I've never really mentally connected with RSS feeds, even though a great number of people I know think that feeds are the greatest thing since sliced bread. Are these "problems" for me? Am I just in the wrong phase of a Candlestick-Two Faces conundrum? Thoughts, please...
I LOVE the idea of using a blog as a log watch aggregator. That ROCKS!
(!) [Jimmy] Heh. That was an obvious use I didn't see mentioned. Back in college I used to have a bunch of scripts that ran grep over various log files, diffed them against yesterday's, and mailed the result to an admin account.
I used them to track things like who used su and when etc., and had something similar in root's .bash_logout so I could compare and see who was doing what (not to snoop, just to offer a helping hand to the newbie admins).
(!) [Brian] What's in my ~/bin: 87 scripts, mostly ugly hacks to run CLI and GUI tools in a specific order. For example:
bilbrey@vimes:~/bin$ cat getpix | egrep -v "^$"

See attached brian.getpix.bash.txt

Since the USB card reader doesn't ALWAYS see media inserted, a quick cfdisk brings that problem to an end. I mount the card, copy the contents to the directory I specified on the commandline. Ick, no test for correct input, eh? Unmount, prompt, call another script to convert all to 640x480. use GQview to pick and choose. Those I keep, I may edit using GIMP from within GQview. When I'm done, I have the 640x480 snaps that I'll use on the website. Exit GQview and the script continues. Make thumbnails of the remaining files. Copy everything into my local copy of the webtree. Blow the whole processing tree away, leaving me with camera originals on the disk. I don't use this one much anymore, because I have a new camera and a new method of doing some of that stuff. I haven't automated it yet because I've been too busy to save time. Sigh.
(!) [Jimmy] I keep my photos on flickr.com (and on CD, but they're easier to find on flickr), and my links on del.icio.us . In issue #110 I described what I use to get a montage of my last N photos ( Flickr and Perl ) and My tip in #112 has a script I use to get a Netscape bookmarks-compatible version of all the links I have in del.icio.us.
(!) [Brian] I have another little script, a three liner that drops me down into the current year's working directory in my web space, pops a firefox window pointing at http://localhost/xxx/xxx/blah.php, and fires up bluefish with the most recently edited page in the window.
I have a number of scripts dedicated to setting up ssh tunnelling for VNC connections to windows desktops at my last-but-two employer out in CA, where I still consult from time to time, and it's much easier to answer Netscrape or LookOut questions when they can SHOW me instead of trying to describe things over the phone.
(!) [Heather] For being able to show someone _else_ that VNC session, VNC snapshot over at sourceforge looks nice...
(!) [Brian] I have lots of little scripts for rsyncing chunks of my local machine to other places, for web publishing, for backup, for sharing data.
I need to spend more time being efficient, writing still more tools to do my work for me.
(!) [Jimmy] Same here. I'm finding more and more that it pays to take a step outside myself and really pay attention to what I'm doing, then use this function:
histdump() { history $(($1 + 1))|head -n $1|awk '{print $2}'>sh-$(date +"%b%d-%H:%M"); }
(!) [Raj] One thing I use heavily is Emacs. It has a number of nifty modes which make life much organized for a programmer. I will list a few especially good ones
emacs-PlannerMode:
http://sacha.free.net.ph/notebook/wiki/PlannerMode.php#sec1
PlannerMode is an organizer and day planner for Emacs. It helps you keep track of your pending and completed tasks, daily schedule, dates to remember, notes and inspirations.
emacs-outline-mode: very useful if you are writing an outline for an article or just taking notes. (I find wiki-mode more user friendly, see below)
(!) [Jimmy] I'm familiar with it :) (http://linuxgazette.net/108/oregan.html)
(!) [Raj] emacs-wiki-mode: This is a Emacs mode for maintaining a local Wiki. Though I use it for making outlines of articles and keeping notes during meetings. The main idea is that you write using plain text, but it is rendered on emacs as html. (emacs-wiki-mode comes with emacs-planner-mode)
Instead of having a personal blog to keep a track of personal-todos/inspirations etc. , I use a wiki: http://rajshekhar.net/wiki
(!) [Jimmy] Ah. There's something worth mentioning. You all know and love Heather's SysadMoin (http://www.starshine.org/SysadMoin), right?
Yeah, wikis are brilliant. You can even get them for your desktop now (http://www.beatniksoftware.com/tomboy)
(!) [Heather] The great thing about MoinMoin is, it supports access control lists, so it can be public and private spaces at the same time.
Yeah, pardon my dust over there at SysadMoin, it's only available inside our LAN at the moment while I'm preparing an upgrade. Not moin's fault - I had a hard disk go crunch - most annoying - geez, it's a good thing I make regular backups. A few merges, oh, I have to re-do my dark theme too...
Ahhhhh, backups. If there's one "hack" I've taken back out of the computer world into my real life, it's making sure to have backups. Backup plans, backup copies of contact info, someone to backup for me if that old problem about not being able to be in two places at once strikes home. Save early, save often, save extras.
Over in #moin on freenode, where I have been hanging out a lot lately, there's one fellow (deitarion) who's cleaning up not only a lifetime of loose notes but also organizing and commenting on a number of files he's gathered over time, using MoinMoin Desktop Edition, in other words, a wiki designed to be personal: http://moinmoin.wikiwikiweb.de/DesktopEdition
He seems to have saved a bunch of space already and be working on some search engine tricks for it, combining it with GTKtalog (commandline fans may prefer SwissDB ) and planning on a local web proxy to manage his external bookmarks. He's working on saving enough space and/or being clear enough on what's his, to have this help his emigration from his current distro to Gentoo.
(!) [Jimmy] One of the best tips I saw is one from JWZ. He keeps an /etc/setup script, and every time he does anything from the root account, copies and pastes it into the script, and comments it saying why, before copying it to his other machines, so he can have every machine set up to exactly the same state whenever needed.
(!) [Heather] Jim (the Answer Guy) and I both keep a README file for each of our machines, either in /etc or in / (I like to hardlink them together; keeping /etc on a seperate partition from / is rare and creepy, but a symlink would do nicely - hardlinks, though, protect it from being deleted by the fs if one of the links is removed).
This file datestamps any interesting changes we do to a machine, possibly including script bits, fstab tweaks, etc. Reading it should be enough to figure out how to spin up another machine just like this one even without the box itself.
I also keep one of these in each complete chroot area I set up, since I treat them like whole machines. Which brings me to the next Lifehack :) For chroot'd environments that aren't just the single app, I change its /etc/hostname to something that clarifies what it is (past examples include "rescue", "minideb", "dev-potato", "memoryalpha" for my trek stuff), and I change the part in the root user's setup (/root/.bashrc) so that instead of asking for hostname:
export PS1='\h:\w\$ '
...it uses the contents of the hostname file:
export PS1="-=[ `cat /etc/hostname` ]=- \w\$ "
Note the doublequotes - if you use single quotes, the command to cat the file is going to be used every time, and you don't really change a chroot's hostname all the time, do you? (I certainly don't.)
Since my chroot'd prompt also looks different, even without colorization tricks that I use on my terminals, I can easily tell that I'm in the chroot, and which one I'm in. So nice when I'm ssh'd in and using a screen session heavily.
If you haven't heard of screen then for goodness' sake get it. Job control is nice, but this gives whole windows with real terminals, so the human can multitask too; things that you might want to background can be run in another window where they think they have foreground; it can be told to log one of its windows (great when a compile or some other scripted thing is about to spout lots of text you want to read later, or grep through); with some rather careful permission settings it can even be used in multi-user mode, so you can show a junior admin, your kid sister, or a linux newbie you're helping spin up to speed, the exact things that you're doing. With screen you don't need X and vnc unless you need graphics :)
(!) [Jimmy] Hey Raj, you've been holding out! http://del.icio.us/lunatech/lifehacks has the kind of stuff I was looking for and you know it! :-P
(!) [Raj] I never thought anyone else (who is a geek/programmer) would find those useful. I had collected them from manager-type fellows  :-) . You might find these useful too - http://del.icio.us/tag/cli - http://del.icio.us/lunatech/hacks
(!) [Jimmy] What, geeks don't have to deal with managers anymore?
I really liked the "Hack Yourself" link (http://www.bloodletters.com/hackyourself.shtml)

...............

You don't exist.
You just think you do.
We're nothing but the stories we tell ourselves. We know in our hearts what kind of people we are, what we're capable of, because we've told ourselves what kind of people we are. You're a carefully-rehearsed list of weaknesses and strengths you've told yourself you have.
(Self-confidence, for example, is a particularly nebulous quality you can easily talk yourself out of having.)
You owe no allegiance to that self-image if it harms you. If you don't like the story your life has become -- tell yourself a better one.

...............

The lifehacks tag is a good one to keep an eye on: http://del.icio.us/tag/lifehacks (or even http://del.icio.us/tag/lifehacks+gtd)
Since lifehacks is pretty much just self-improvement geekified:
http://c2.com/cgi/wiki?SelfImprovementPatternsRoadMap
"How to Make a Complete Map of Every Thought you Think" (http://speakeasy.org/~lion/nb) is a braindump book about how to keep a paper version of a wiki.
(!) [Heather] I think John Walker's "The Hacker's Diet" counts as his own lifehack: http://www.fourmilab.ch/hackdiet/www/hackdiet.html
(!) [Brian] THANK YOU, Jimmy, for bringing this one up!
(!) [Jimmy] You're welcome :)

This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


Each TAG thread Copyright © its authors, 2005

Published in issue 113 of Linux Gazette April 2005

<-- 2c Tips | TAG Index | 1 | Knowledge Base | News Bytes -->
Tux