Ruby on Rails: gem install versus apt-get
UPDATE: Thanks to Ryan, Ant and Fern for the tips. With that in mind I found an online Slicehost tutorial that contained the steps and explained how to install ruby via apt-get, then get the latest rubygems, install that manually, ran gem to update itself, then run gem to install rails – as suggested. The steps I took from that page:
(more…)
HOWTO build your own open source Dropbox clone
UPDATE: Thanks to everyone who has contributed to this, and the Reddit thread, as it has provided some great ideas building off of my concept. I’m starting to rethink about how we could have version control on top of things, and I’ll update things when I have more to share. Also, does anyone have iFolder (thanks for the proper link working? It looks like you need SUSE Linux, which I don’t have access to, plus I know most Novell projects need a *ton* of Mono dependencies installed to have any of their stuff working, at least on the server side; but it sounds like they have Mac, Linux and Windows clients, which is encouraging. While for my needs something a bit more ‘close to the bone’ (as below) might be better for the server side, having it be inter-operable with something like iFolder could provide a lot more functionality for others.
First off, if you haven’t tried Dropbox, you should check it out; sync all of your computers via the Dropbox servers, their basic free service gives you 2Gigs of space and works cross-platform (Windows, Mac, Linux). I use it daily at home and work, and just having a live backup of my main data for my work workstation, my home netbook, and any other computer I need to login to is a huge win. Plus, I have various ’shared’ folders that distribute certain data to certain users that I’ve granted access to, this means work details can be updated and automatically distributed to the folks I want to review/use the data. I recommend everyone try it out, and see how useful it is, it’s turned into a game changer for me. So a few months ago they made headlines on supporting Linux as they released the client as open source. While this got hopes up for many, it was only the client that was open source, the server is still proprietary. While slightly disappointing, this is fine, they’re a company trying to make money. I don’t fault them for this, it’s just that a free, portable service like that would be a killer app. (more…)
HOWTO: log the user’s IP, not the proxy’s, in nginx access log

nginx
So back in January I had a post about HOWTO: log the user’s IP, not the proxy’s, in Lighttpd access log, but today I switched that system to run nginx (actually nginx has been running since early this year, I just got lazy on running Varnish) fronted again by Varnish. I had the same issue, but not much trouble solving it. Since I often refer to my own notes on fak3r, I’m recording it here for myself, and anyone streaming in from Google. So, as I talked about before, when you run a webserver behind Varnish doing http acceleration, the webserver access logs will display the IP of the proxy (generally 127.0.0.1) instead of the end user’s IP. This not only breaks any kind of tracking or reporting you want to run against your webserver logs. Since this server runs Varnish in front of nginx, and it reveals the end user’s IP in the header as X-Forwarded-For, so it’s just a matter of making nginx use that variable in its access logs instead of the default variable defining the referring IP. Once we know that, the configuration is simple. Edit your nginx.conf file:
vi /etc/nginx/nginx.conf
Once in the file, find the block about logging, and add the following to it:
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"' ;
access_log /var/log/nginx/access.log main;and finally, restart nginx
/etc/init.d/nginx restart
If you look at the logfiles now you’ll see the IP of the original requester!
HOWTO: install Ruby on Rails on Debian or Ubuntu Linux easily
In the early days of this blog I used to run it on Typo, which *was* a great Ruby on Rails blogging platform (at one time). Unfortunately the project stalled (for years) and I ended up jumping ship after a few months of bugs and the ever crashing Rails server, WEBrick. Yes, if you search Netcraft you could see that was my *exposed* server at the time…not good!
Now if you look, Typo is still kicking, and it *may* be a solid platform now, I hope it is, as I even contributed a ton of the achieved themes that live on in the ‘Theme Garden’ there. But on I moved into the world of MySQL/PHP front end sites via great apps like Drupal and Wordpress, fast forward, Ruby on Rails is a mature platform now, and I am evaluating webapps at work, so I needed to install Rails on Debian GNU/Linux (but of course these directions would work just as well in Ubuntu Linux. It’s amazing simple, I took some steps from the Ruby on Rails wiki, first install the dependencies for good measure: (more…)
HOWTO: webserver in 100 lines of Bash
I’m a big Bash fan, I know Perl is the more popular scripting language, and I’m slowly using it more, but hey, if I need something done, I can do it quicker in Bash (keeping in mind that I’m a systems guy, not a dev guy). While at work looking up Bash related syntax I came across a page describing how to run a webserver with 100 lines of Bash. It uses the old school GNU utility Netcat (nc) for communication between the pipes, and just a ton of basic logic and functions to pass it on to the user. It’s one of those things I look at and can’t believe it works, but it does. Of course security is unknown, as is the original author, but I consider this a reference on how to do networking things in Bash; who knows what I’ll use (parts) of it for. If anyone has details on who originally wrote this I’m all ears.[sourcecode language='xml']#!/bin/bash
function debug {
local severity=”$1″
shift
local message=”$@”
echo -n “`date -u`” 1>&2
echo -ne ‘\t’ 1>&2
echo -n “$severity” 1>&2
echo -ne ‘\t’ 1>&2
echo “$message” 1>&2
}
function fix_path {
echo -n “$1″ | head -n 1 | sed ’s|^[/.-]*||’ | sed ’s|/\.*|/|g’
}
function serve_dir {
local dir=”`fix_path “$1″`”
if [ "$dir" = "" ]; then
dir=”./”
fi
echo ‘HTTP/1.1 200 OK’
echo ‘Content-type: text/html;charset=UTF-8′
echo
echo LISTING “$dir”
echo ‘
‘
ls -p “$dir” | sed -e ’s|^\(.*\)$|\1
|’
}
function serve_file {
echo ‘HTTP/1.1 200 OK’
echo ‘Content-type: application/x-download-this’
echo
local file=”`fix_path “$1″`”
debug INFO serving file “$file”
cat “$file”
}
function process {
local url=”`gawk ‘{print $2}’ | head -n 1`”
case “$url” in
*/)
debug INFO Processing “$url” as dir
serve_dir “$url”
break
;;
*)
debug INFO Processing “$url” as file
serve_file “$url”
;;
esac
}
function serve {
local port=”$1″
local sin=”$2″
local sout=”$3″
while debug INFO Running nc; do
nc -l -p “$port” < "$sin" > “$sout” &
pid=”$!”
debug INFO Server PID: “$pid”
trap cleanup SIGINT
head -n 1 “$sout” | process > “$sin”
trap – SIGINT
debug INFO Killing nc
kill “$pid”
done
debug INFO Quiting server
}
function cleanup {
debug INFO Caught signal, quitting…
rm -Rf “$tmp_dir”
exit
}
tmp_dir=”`mktemp -d -t http_server.XXXXXXXXXX`”
sin=”$tmp_dir”/in
sout=”$tmp_dir”/out
pid=0
port=”$1″
mkfifo “$sin”
mkfifo “$sout”
debug INFO Starting server on port “$port”
serve “$port” “$sin” “$sout”
cleanup[/sourcecode]
HOWTO: conky config (conkyrc) for Debian Part 2
I changed around my Conky config, and it’s something you could do forever, but it’s great because it can be as heavy or light as you want it. Recently I dropped Gnome almost all together to run Openbox (full HOWTO on this forthcoming). I found a panel that will house things like nm-applet output, but was missing things like a simple clock, network activity, etc. So now, using most of the same code/look that I used here, I have a small, transparent strip at the bottom of the screen showing me time, date, proc, proc temp, network up, network down, and power status (battery, AC and the level of charge). It looks good, it’s light, it’s all I need. Nice to bring some of the memory requirements down from Gnome as well.
# Create own window instead of using desktop (required in nautilus)
own_window true
own_window_hints undecorated,below,skip_taskbar
background no
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer true
# fiddle with window
use_spacer right
use_xft true
# Update interval in seconds
update_interval 3.0
# Minimum size of text area
minimum_size 10000 5
# Draw shades?
draw_shades yes
# Text stuff
draw_outline no # amplifies text if yes
draw_borders no
uppercase no # set to yes if you want all text to be in uppercase
# Stippled borders?
stippled_borders 8# border margins
border_margin 1
# border width
border_width 1
# Default colors and also border colors, grey90 == #e5e5e5
default_color white
default_shade_color black
default_outline_color white
own_window_colour brown
own_window_transparent yes
# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
alignment bottom_left
#alignment bottom_right
# Gap between borders of screen and text
gap_x 10
gap_y 5
# stuff after ‘TEXT’ will be formatted on screen
override_utf8_locale no
#xftfont Terminus:size=8
xftfont Terminus:size=10
xftalpha 0.8
#Mail:${color}${execi 300 python ~/scripts/gmail.py}
TEXT${offset 0}${color }${time %H:%M} ${color slate grey}${time %Z }Date: ${color }${time %a, } ${time %e %B %G} ${offset 0} ${offset 0} ${color slate grey}Proc:${color} $cpu%${offset 5}${acpitemp}C${offset 5}${cpugraph 16,100 000000 ffffff} ${offset 0} ${color slate grey}Net:${offset 5}${color}Up:${upspeed wlan0}k/s${offset 5}${upspeedgraph wlan0 16,100 000000 ffffff}${offset 0} ${color}Dn:${downspeed wlan0}k/s${color}${offset 5}${downspeedgraph wlan0 16,100 000000 ffffff} ${color slate grey} Power:${offset 5}${color}${battery}
Try it, you might like it – I’ll keep working on it, I’m sure I’ll find more things to add/improve. Conky rocks.
HOWTO: recursively download only specific file types
Have you ever found a batch of mp3s online on someone’s ‘Index of’ page? I know you have (and if not, do a search for ‘google hacks’ in google to learn about the fun) The issue always comes up that I find an album I want to grab, but the individual files are in a directory, so you have something like band_name-album_name/01-songone.mp3, and so on. To grab all of them I used to issue a wget command, with the -r (recursive) switch like this:
wget -r http://www.someurl.com/band_name*
but then I’d end up with a ton of other files from the root directory that would take time and confuse the download so I’d have to search around for the mp3 payload. I found a better way to do it, still using the -r for recursive search, but then only downloading the mp3s, forgoing any html pages or other directories in the root. The command goes something like this:
wget -A mp3,mpg,mpeg,avi -r -l 3 http://www.someurl.com/band_name*
The curl command operates in a similar way. Its advantage is that it’s actively developed. Other similar commands that you can use are snarf, fget, and fetch, but I don’t see a direct advantage over wget with the proper filters.
HOWTO: conky config (conkyrc) for Debian
If you run a Linux desktop you need to be using conky. It compiles all those shiny gadget you see on other desktops eating system RAM, down to what you need; information on what your system is doing. So try it out, install conky, and then drop this into your home directory as .conkyrc – then run conky. The file is pretty self explanatory, enjoy!
HOWTO: use monit to keep Lighttpd and Varnish running
Thanks to a post from Steve over at debian-administration.org, I finally got around to setting up monit, the little monitoring app we use at work to keep things sane. I was getting around to installing it at home, but it became more urgent when Varnish went down last week; without it running there’s nothing to handle requests on :80, so as a webserver it’s dead. So here’s my monitrc for the webserver Lighttpd fronted by Varnish, acting in the reverse proxy/http accel role. Varn is listening on 80, then, if things aren’t cached, it forwards things on to Lighttpd listening on 82. Lighty also listens on the standard 443 for HTTPS requests, so we check that as well.
check process varnish with pidfile /var/run/varnishd.pid start program = "/etc/init.d/varnish start" stop program = "/etc/init.d/varnish stop" if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 200.0 MB for 5 cycles then restart if children > 250 then restart if loadavg(5min) greater than 10 for 8 cycles then stop if failed host 127.0.0.1 port 80 protocol http then restart if 3 restarts within 5 cycles then timeout check process lighttpd with pidfile /var/run/lighttpd.pid start program = "/etc/init.d/lighttpd start" stop program = "/etc/init.d/lighttpd stop" if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 200.0 MB for 5 cycles then restart if children > 250 then restart if loadavg(5min) greater than 10 for 8 cycles then stop if failed host 127.0.0.1 port 82 protocol http then restart if failed host 127.0.0.1 port 443 type tcpssl protocol http with timeout 15 seconds then restart if 3 restarts within 5 cycles then timeout
So now we have monit watching Lighttpd, Varnish, Postifx, MySQL and OpenSSH – restarting things if they fail, and emailing me the status when they do. Next on to some long term trending with Cacti providing some rrd graphing and then we’ll really have an idea of what this box is doing and be able to tune it accordingly.
HOWTO: log the user’s IP, not the proxy’s, in Lighttpd access log
When you run a webserver behind a reverse proxy or HTTP accelerator like Squid or Varnish, the webserver access logs will display the IP of the proxy (generally 127.0.0.1) instead of the end user’s IP. This not only breaks any kind of tracking or reporting you want to run against your webserver logs, but it also takes away a datapoint I’ve had use for in general server admin tasks. This server runs Varnish in front of Lighttpd, and it reveals the end user’s IP in the header as X-Forwarded-For, so it’s just a matter of making Lighttpd (lighty) use that variable in its access logs instead of the default variable defining the referring IP. Once we know that, the configuration is simple; in lighttpd.conf, enter this:
accesslog.format = "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b /
\"%{Referer}i\" \"%{User-Agent}i\""For the definition of these variables, and plenty more, hit Lighty’s wiki. Props to the poster on the Varnish mailing list for bringing this up and reminding me to fix it! I’ve sent this link to the list so now it’s out there.
Buying a Linux laptop in 2007
It’s time for a new laptop, as I’ve detailed, I’ve ripped apart, inserted coins and duct-taped the old iBook back together again enough times, and it’s no longer viable. It’ll work fine on a flat surface, but if you try to use it as a laptop the minor flexing must loosen the video chip, because you quickly find your video locked, with a hard reboot the only fix. The wildcards are me as a buyer, since I’m hardly ordinary with my expectation that any laptop or desktop I’m going to buy is only going to run Linux, and the recent announcements by HP, IBM/Lenovo and Dell about their Linux support (some even pre-installed), I knew I’d finally have choices to consider. In the end I came up with a pretty current system, that Debian or Ubuntu will be 100% compatible with, and will be proud to call home. The detailed specs:
Intel Core 2 Duo T5470, 1.6GHz, 800Mhz FSB, 2M L2 Cache
15.4 inch Wide Screen XGA LCD display
1GB, DDR2, 667MHz 2 DIMM
128MB NVIDIA GeForce 8400M GS
120G 5400RPM SATA Hard Drive
Integrated 10/100 Network Cardand Modem
8X DVD+/-RW with double-layer DVD+R write capability
Integrated High Definition Audio 2.0
Intel 3945 WLAN (802.11a/g) Mini Card
Integrated 2.0 mega pixel webcam
Integrated Bluetooth
85 WHr 9-cell Lithium Ion Primary Battery
This is more system that I originally spec’d out, but the price was right, so I’m very happy. Before I reveal which brand I picked, I’ll tell the interesting story of how I ended up with the ‘top I did, and how things compare for laptop Linux options these days, it’s an interesting ride.
NOTE: feel free to Digg this article if you like it.
HOWTO: notes on securing Debian
Looking over the Debian own harden-doc guide online, (which is a monster of a resource) as well as Debian Help’s security page gave me some excellent new ideas on how to secure Debian and Linux in general. Also today i found a netstat command with some nice switches to help you figure out what is listening on each port in an easy to read layout, -plunt:
netstat -plunt
Plus it’s fun to say, ‘plunt’. Lastly there’s a good overview of deborphan (which assists you in keeping your system clear of unneeded packages) with coverage on how to use it at Debian Adminstrator.org. But in the comments a thread talks about how it’s better to use aptitude, as this does it automatically.
HOWTO: failed to set xfermode [SOLVED]
UPDATE: thanks to a comment below from Ted, we now have a solution to have this option persist across kernel updates. In grub, “…at the end of this new menu item add it as an argument to the line:
defoptions=quiet splash irqpoll
I knew there had to be a way, thanks for the post Ted!
There’s a known bug in Ubuntu 7.04 (Feisty) with some ata detection routine that causes the system to take over 2 minutes to boot. Since this has happened to me more than once I’m documenting it here for me, and for other desperate souls that may find their way here. If your system is very slow to boot, and you see error messages in your dmesg (`dmesg | grep ata`) such as this:
[ 34.122465] ata1.00: qc timeout (cmd 0xef) [ 34.122519] ata1.00: failed to set xfermode (err_mask=0x4) [ 34.122565] ata1: failed to recover some devices, retrying in 5 secs [ 46.260055] ata1: port is slow to respond, please be patient (Status 0x90) [ 69.218482] ata1: port failed to respond (30 secs, Status 0x90)
You just need to ad `irqpoll` to your grub line. So in so in /boot/grub/menu.lst I added irqpoll to the kernel line:
kernel /boot/vmlinuz-2.6.20-15-generic root=UUID=48c5a348-eb39-4171-8531-671a49fdb75b ro quiet splash irqpoll
and it fixes the issue. Probably a work around, but since this resets every time you install a new kernel you’ll realize when it’s broken and when it’s fixed. Oh, and my system boots in 21 seconds now…is it geeky that I know that, and I tweaked the system to make it boot faster than the 27 seconds it was booting in? I guess we’ll never know! ![]()
HOWTO: Jimmac mouse cursors on XP
So the only thing I don’t love about my new job is the same old thing; you have to run Windows XP on the desktop. Yeah, I’ll give it a bit more time before I really start pushing to run Linux on the desktop, so until then it’s my ongoing struggle to get XP to work the way I want it to (ie- more like Linux). One simple way is to install the excellent Jimmac mouse cursor theme that’s the default for the majority of Linux distributions. Jakub Steiner (aka Jimmac) is the famous designer of this set, and with a 3rd party app called CursorXP , it’s a snap to get them into XP. First grab the Jimmac theme created to work with CursorXP, then Download and install CursorXP and get into its config menu, which is a new tab under Settings > Mouse. From the drop down list choose <Broswe>, point it to the theme and you’re done. You wouldn’t think a change of mouse cursors would change the feel of a system so much, but these do; I feel more at home. Even if you’ve never used Linux you’ll still love this cursor set, try it, it’s all free.
HOWTO: populate your term’s title automatically
When you’re running a ton of termial windows or tabs, it helps to have the title of the box name, along with some environment values, easily available to keep you orientated. Here’s a quick script I created to do this automatically when called via your .profile file in your home directory.
#!/bin/bash
HOST_NAME=`hostname -f`
if [ `id -u` = 0 ]; then
OPT="`uname` (`uname -a | cut -f12 -d' ' -`) - ROOT USER"
else
OPT="`uname` (`uname -a | cut -f12 -d' ' -`)"
fi
REPLACE="${HOST_NAME} - ${OPT}"
echo -n -e "\033]0; $REPLACE \007 "
echo "${REPLACE}"
exit 0When I run this script in my term here at work, the title or tab becomes:
nldg-8 (Linux / x86_64)
Drop this into a bin directory your user can hit – I always put on in my home directory and append ~/bin to my PATH in my .profile. For Solaris fans/users, it needs to be done a bit differently:
#!/usr/local/bin/bash
HOST_NAME=`uname -a | cut -f2 -d' ' -`
OPT="(`uname -a | cut -f1 -d' ' -` / `uname -a | cut -f6 -d' '`)"
REPLACE="${HOST_NAME} - ${OPT}"
echo -n -e "\033]0; $REPLACE \007 "
echo "${REPLACE}"
exit 0foo
HOWTO: fix a G3 iBook with a “bad logic board” for 26 cents
I’ve had a 12″ G3 iBook since ~2002, and I’ve really liked it. Of course me being me, I’ve run Linux on it for almost the whole time, even running a dual boot of OS X and Gentoo Linux back when I used this puppy on the job. The only thing I (and likely millions of other customers) didn’t like is the systemic “logic board” failure. Yes, the logic board, which is just Apple’s name for the motherboard, would fail, prompting a call to Apple, followed by about a one week turnaround on the repair, which was all covered under warranty. The only thing is, this only reset your iBook back to the original state, after using the iBook for so long, this issue would occur again, leaving you with a shinny door stop. Mine had come and gone 3 times, so this final failure fell far outside of even the extended program to cover the fix. Fast forward to last week, I had resigned from my gig at Mastercard, thus turning in my work laptop, leaving with no convent way (I can go downstairs to my desktop, but…) to work on a system and check my email. I got the iBook out of the drawer and started looking around for info online to solve this from a DIY angle. One interesting way was to burn a tea light directly on the video chip, eventually making it hot enough to resolder itself to the board! I was going to do this, when I found a lower tech, less risky, fix, with perhaps even more permanent results. You open the iBook, put some sort of shim just underneath the video chip forcing it to stay in contact with the logic board; that’s it! There are plenty of sites out there now talking about this, but this one seemed the most direct. So I opened the iBook, found that little square you see in the pictures, duct taped a penny topped by a quarter to the metal, and all of a sudden had a revived laptop. It’s fun when things are so easy. Oh, and Ubuntu Linux Feisty (7.04) for the PowerPC runs very, nicely on the iBook! So much more power saving features, and the promise of Gnash to cover all the flash sites makes it a great laptop.
HOWTO: ssh tunneling for fun and profit
Recently I had an issue at work; while trying to transfer files between Unix hosts we were unable to hit the known scp port, but we could still hit the ssh port. All of this was occurring from home, late at night on a Saturday where I was the main technical point man to move/install these files. In the past I had done ssh tunneling, but never on the fly to fix something like this, so I cracked open my notes and did a quick Google search for a refresher.
The first we’ll look at the basic syntax of the command to setup the SSH tunnel:
ssh -L <local free port>:localhost:<local sshd port> -p <remote host sshd port> <remote host name>
Where:
- <local free port> is an unused high-number port on the local host
- <local sshd port> is the ssh port on the local host
- <remote host sshd port> is the remote host’s ssh port
- <remote host name> is the remote host you want to tunnel to
So, for example, if I wanted to copy files from work to my homeserver (but scp/sftp wasn’t running there) I could still scp the file via the ssh tunnel to home. Here’s how I’d do it:
ssh -L 5555:localhost:22 -p 2222 fak3r.com
Then I’d point to the tunnel while I issue a command I’d like to direct to it, and give it a username that is valid on the remote host:
scp –P 5555 fiile.txt bob@localhost:~
The file would then be in the home directory for bob’s account on fak3r.com. So anything directed at my local port of 5555 would be tunneled via ssh to the remote host’s sshd port of 2222 all via the tunnel I setup on my localhost, whose sshd is running on the default port of 22.
Global warming: 51 things we can do

Time has an article about 51 things we, along with scientists, businesses and governments, can do to slow global warming and cut carbon emissions. “Here is our guide to some of the planet’s best ideas” This is getting more and more press of late thanks to Al Gore’s movie, An Inconvienent Truth, and regardless of what you think about that, thinking longterm for our environment helps EVERYONE! While we’re on the topic, to keep in this mindset and come up with new ideas, visit EcoGeek and Treehugger; both fantastic sites. I’m now researching how I can get started with solar panels on my roof along with all that it entails to either directly power something, or to contribute to the grid. What are you doing to help? At the very least we should all get a free energy audit of our homes via the local electric company.
Transfer files via netcat and tar
Netcat (nc) is a “…simple Unix utility which reads and writes data across network connections, using TCP or UDP protocol. It is designed to be a reliable back-end” tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities.” Basically it’s another small, cool Unix tool that allows you to do tons of cool stuff. I found this example out there that lets you transfer files via tar from one box to another. As with anything to do with nc, it’s dead simple, and logical. On the target box, start nc to listen on a port, and tar up anything it ‘hears’ like this:
nc -l -p $PORT | tar -xf -
Then, on the source system, have tar pipe out to netcat, that is pointed to the target host/ip:
tar -cf - $DIRECTORY | nc $HOST $PORT
Damn, how cool. There’s plenty more info out there, and the more you look the more you’ll realize what you can do with nc. Tons of great info at the above Wikipedia link, and I also found a great overview at Vulwatch.org. Have fun!
HOWTO: have vim create backup and tmp directories
This may only apply to those of us geeks that use vim to admin servers daily, but today I needed a way to backup, and automate the creation of backup and tmp directories to house those ever annoying ~ and .swp files from showing up in my working directory ($PWD). I didn’t want to lose them, just move them somewhere so they don’t clutter up the directory I’m working in. The solution was a function I found on the vim forums. Basically it uses directories it creates in your home directory, so you’ll have something like ~/.vim/backup and ~/.vim/tmp which is perfect; files are moved out of the way, but still backed up in a place you can rely on. I slightly reworked this, you can try it out by opening your ~/.vimrc file, and find the line:
set backup " keep a backup fileThen after that cut/paste the following (if you don’t have the set backup line, add it first):
function InitBackupDir()
let separator = "."
let parent = $HOME .'/' . separator . 'vim/'
let backup = parent . 'backup/'
let tmp = parent . 'tmp/'
if exists("*mkdir")
if !isdirectory(parent)
call mkdir(parent)
endif
if !isdirectory(backup)
call mkdir(backup)
endif
if !isdirectory(tmp)
call mkdir(tmp)
endifendif
let missing_dir = 0
if isdirectory(tmp)
execute 'set backupdir=' . escape(backup, " ") . "/,."
else
let missing_dir = 1
endif
if isdirectory(backup)
execute 'set directory=' . escape(tmp, " ") . "/,."
else
let missing_dir = 1
endif
if missing_dir
echo "Warning: Unable to create backup directories: " . backup ." and " . tmp
echo "Try: mkdir -p " . backupecho "and: mkdir -p " . tmp
set backupdir=. set directory=.
endifendfunction call InitBackupDir()
HOWTO generate a list of installed packages for disaster recovery
I came across this page again, seems they took my advice to heart on the one line command to grep out a list of all installed packages on a Debian or Ubuntu system. This creates a file that you can use as a DR (disaster recovery) map of all installed apps — you only need to install your base system, and then use this file to reinstall all of your apps. Their earlier versions didn’t produce a clean list and it certiainly didn’t go the extra mile of emailing a copy to you.
dpkg -–get-selections | grep -v deinstall > ubuntu-files; cat ubuntu-files
| mailx -s “ubuntu-files” my.mail@my.address
First Beta Release of Ubuntu 6.10
The Ubuntu team is proud to announce the Beta Release of Ubuntu 6.10 – codenamed “Edgy Eft”. Featuring the new init system, Readahead, is dealing with speeding up boot times, Betas of the lastest Firefox and Gaim, new photo software F-Spot, Tomboy on by default, and for compwiz fiends (like me) we can play with AIGLX natively with Xorg 7.1 – nice. To Get Ubuntu 6.10 Beta, Download from a US mirrors here: http://us.releases.ubuntu.com/6.10/ I have a fully working updated Dapper on my home workstation, but hey, I needs to have the latest, so I’ll likely give this a go soon.
Why email is addictive (and what to do about it)
“Email is addictive because it is a variable-interval reinforcement schedule. Checking email is a behavior that has variable interval reinforcement. Sometimes, but not every time, the behavior produces a reward. Everyone loves to get an email from a friend, or some good news, or even an amusing web link” i.e. rewards.
HOWTO: Use a file list in Ubuntu for quick system restore
While I’ve read this plenty of times, today via Digg I found complete docs that I wanted to save on how to restore a Ubuntu Linux install; bringing it back to the way you had it from a fresh install easily. Why would you need this? Well, hard drives die, but more often (in my case at least) it’s *fun* to start with a fresh system when new versions of Ubuntu come out, or when you *have* to try out the latest/fastest filesystem, or you can’t live without the latest/bleeding edge apps/features. So to start, you’ll first need a snapshot of your installed applications on your working system, which is easy enough to do:
dpkg –-get-selections | grep -v deinstall > ubuntu-files
After this you could copy the file ubuntu-files to a USB thumbdrive, and while this would work, let’s go for some x-tra credit and have this created file emailed out for easy remote storage:
dpkg –-get-selections | grep -v deinstall > ubuntu-files;
cat ubuntu-files | mailx -s "ubuntu-files" fak3r@fak3r.com
When you reinstall the next time just do a quick base install of Ubuntu, which takes all of 15 minutes on today’s average machines, then drop to the cmd line, grab your ubuntu-files file and then run the following:
sudo apt-get update sudo apt-get dist-upgrade dpkg –set-selections < ubuntu-files
Now you’re back to the point of your last snapshot with all the kewl apps you installed that broke things in the first place! Oh, wait…








