Customizing Grep

Here’s a script that I wrote to help me find things at work.


#!/bin/bash

if [ ! -n "$1" ]
then
echo "Usage: `basename $0` pattern [optional args to grep]"
echo "e.g. grepit findme -i"
echo
exit 1
fi

if [ ! -n "$2" ]
then
grep -r --exclude='*.log' "$1" * | grep -v '/.svn/'
else
grep -r "$2" --exclude='*.log' "$1" * | grep -v '/.svn/'
fi

Basically I just got tired of always specifying the recursive option to grep and having to exclude svn and log files (because they were redundant or took too long to search). I also found that sometimes I wanted to add additional arguments (like -i for ignoring case or -n for line numbers). So now when I change a function in one file and want to find every place that function was used I simply do a


grepit function_name

P.S. Let me know if you know a good way to strip leading whitespace from the results.

KQtheBetrayer news

On the game itself I haven’t done that much recently. But as you can see now I have a page up(see at the top of the page). I also now have a project page on google code. http://code.google.com/p/kqthebetrayer/ If you want to download the very latest subversion release go right ahead. I think having it up on subversion will make it easier for me to edit it on different machines. I hope to release a demo by December 25th. So check back for details.

A Kingdom’s Creation 0.2

Announcing the first official release of my Wesnoth Campaign “A Kingdom’s Creation”. It is only 5 levels long currently. Since this is a very early version it is subject to change. It shouldn’t be a challenge playing on easy difficulty.

screenshot

Its the story of Corin a Mage Commander who journeys to a new land and has to unite a group of lawless individuals. The story is the sequel to my unfinished RPG KQ The Betrayer and takes place in my fantasy world (yes I need to come up with a name for it. Suggestions are welcome.) You can download it from the official Add-ons server from within Battle for Wesnoth. Its at the end of the list. I have had 39 downloads so far without publicizing it on the official Wesnoth forums.

My Podcast Solution, Part 4: The Script

Ok, so now you know that RockBox allows me to use my Ipod like any other USB drive. But how do I manage my podcasts? Well, I’m glad you asked because the answer is the power of the command line.

Hpodder is a command line utility that can keep track of podcasts for you. To add a feed I tell it to hpodder add http://feed.xml and then run hpodder without arguments to download all the episodes. But how do I keep track of which ones I’ve listened to already? The obvious solution is to delete them once I’m done with them. The problem with that is that those deleted episodes will be downloaded the next time I run hpodder. The solution to that is easy. I simply run hpodder catchup after downloading new episodes, so that subsequent runs will only download the episodes I haven’t listened to yet.

So now the next (and trickiest) question is how to synchronize the files on the Ipod with those on the hard drive. Rsync did a great job of copying a mirror image of the hard drive files to the mp3 player. But then when I deleted an episode that I was finished with (on either the hard drive or the Ipod) rsync would put it back again. Luckily I found another tool that was able to do what I wanted: Unison.

Unison’s website explains that it “allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.” It took quite a bit of reading and experimenting before I found the magic combination of arguments to make it play nicely, quickly and silently with the Ipod’s fat32 file system. But once I got it all figured out, I wrote a quick shell script to automate everything:


hpodder
hpodder catchup

echo "Please plug in the ipod now, and hit enter to continue"
read

unison -batch -fastcheck true -pretendwin -perms 0 /home/daniel/audio/podcasts/ /media/ipod/audio/podcasts/

So after all that explaining, my podcast solution is extremely simple. After I’m done listening to an episode, I delete it. Then, when I run out of stuff to listen to I run the above script and I’m good to go again. I’ve been doing it this way for several weeks now, and I just can’t get over how uber convenient it is for me. It’s way better than what I was doing before. Another win for Linux and Open Source Software!

My Podcast Solution, Part 3: Box Rocking.

While exploring my options for using an Ipod with Ubuntu, I came across a comment extolling the virtues of Rockbox. Basically the idea is to get more advanced functionality than what ships with your mp3 player by installing different firmware. And it’s not even scary to do, considering that the process is reversal, and there is a dual boot feature if you want it. Although I have to admit I’ve never tried it because I’ve been happy with the functionality that RockBox provides.

So, why do I like it? Number 1 is the ability to use my player like any other usb drive. I have all my mp3 files organized on my hard drive in a directory structure that makes sense to me, and now with RockBox I can simply copy everything over exactly as is, and navigate through the same file structure on my mp3 player to find whatever it is that I want to listen to.
There are also a bunch of other features that allow you a lot more control in how your mp3 player works. For example, one of the first things I did was switch to a bigger font size. I also switched the battery meter from graphical to numerical and made a bunch of other little customizations that make the device mine in a way that was impossible before.

I do have to admit that the switch hasn’t been entirely euphoric. The interface is new, and obviously doesn’t have a bunch of Apple usability experts behind it, so occasionally I still press the wrong button. I have a harder time reading scrolling text, and the battery life meter seems a little random. Probably the biggest thing I miss is that I can’t fast forward through a track with the scroll wheel anymore. But it’s not that big of a price to pay considering the extent to which I can customize the behavior (speed, acceleration, etc.) of holding down the forward button. As you can tell, I’m a big fan of customization. And features. I may not have any intention to ever use my mp3 player to record audio or be an alarm clock, but I find it very comforting that I could if I wanted to.

My Podcast Solution, Part 2: Things that didn’t work

While I used Itunes on my Windows laptop without an Internet connection, I got my podcasts in two ways. I would either have to lug the computer to a free wireless network, or download separate mp3 files with a public computer and transfer them with a USB stick. Then Itunes would redownload episodes that I had already listened to and otherwise confuse matters. When my laptop died, I was more than ready to make the complete switch to Linux and bid Windows and Itunes goodbye.

I was actually quite surprised when I first plugged my Ipod into my Ubuntu machine and without any coaxing, it recognized the device, popped up a music player, and listed everything I had on it. It was equally easy to copy it all to the hard drive and then organize it to my liking. Unfortunately, however, I didn’t find a good way to sync the changes back. I tried both Rhythmbox and GTKpod, and was initially impressed with their similitude to Itunes, but I just couldn’t figure out how to get the control over the podcasts and syncing that I wanted. Besides, with Itunes, I just had to live with the limitations. Now that I was on Linux, I figured there should be a way to make things work the way I wanted them to.

I wasn’t disappointed.

My Podcast Solution, Part 1: Teaser

The goal: Conveniently and easily staying on top of a few quality podcasts.

The hardware: A third generation Ipod. A Dell Ubuntu machine. (No Windows!)

The solution: RockBox, Hpodder and Unison.

The verdict: A little complicated to set up, but now it’s working like a charm.

The details: Coming Soon!

UPDATE: Here are the other posts in this series:
Part 2: Things that didn’t work
Part 3: Box Rocking
Part 4: The Script

games open and closed

Sorry for the lack of updates; I had a dull week and didn’t have any good ideas.
The open;

A new open source game released under the GPL has just been released. Spring RTS

At its current state its pretty much a multiplayer true 3D frontend for
TA. Their ambitious plan is to make the best RTS ever made. Eventually
I think they will move away from TA, but always remain compatible with
it. Since it doesn’t have an AI to fight I havent really used it much.
I find it cool that you can change your view from FPS/Total War/TA view
modes

Luola
a Finnish GPL cave flying game. It is a multiplayer game where you fly
around an almost totally destructable level and test out your wide
ranges of firepower.

The closed;

Gate 88
is a free multiplayer action RTS. The appropriate adjective for Gate 88
is psychedelic. It is quite strange but playable. I think the gameplay
could be more complex however. And it sure would make it easier if you
could set targets with your radar map. This game is free but its closed
because the author wants freedom of expression or something like that.
It seems just like AGDI’s attitude that there code and ideas are so
wonderful that they won’t share it with anyone. (AGDI is great just
selfish; I remember reading one thread on their forums about someone
asking for coding tips, and they refused to reveal their secrets.)
Though I am biased towards open source of course. :D

Wesnoth

Wesnoth 0.9 was released today. It looks like a very good release but I have not been tried it out yet. Some new additions are multiplayer improvements, more graphics, the ability to have alternate walking corpse graphics and a lot more. Windows binaries will be out soon. I’m guessing tomorrow. It looks like Wesnoth is going to be a very polished 1.0. I think Wesnoth is the model for Open Source Game development. It’s a shame that there are not many other Open games with this quality.

Open Source Games

Theres a lot of talk out there that open source just doesn’t work for creating
games. I don’t think that is necessarily the case.

Here are some Open Source games that break the mold:

Arcade

No Gravity – 3D Space shooter

Rocksndiamonds – Nice clone of boulder dash

Mirror Magic – Clone of Deflektor.

Xblast – The official site is dead here’s a fan site; Bomberman clone.

Pingus – Linux only Lemmings clone with Penguins instead of lemmings.

Kobodeluxe – An intense 2D space shooter.

Tuxracer – A 3D downhill sledding game.

Frozen Bubble – A fun arcade game sort of like upside down tetris.

BZFlag – Awesome 3D multiplayer tank game.

Armagetron Advanced – 3D multiplayer Tron/like game.

Turn Based Strategy

Battle for Wesnoth
- Wesnoth is an original fantasy turn based strategy game. The Wesnoth
community is the best open source one I’ve seen. They also release
updates roughly every two months. They are currently at version 0.8.10.
But its quite stable. Wesnoth is the only hexagon based strategy game
I’ve ever liked and I’ve tried quite a lot.

Real Time Strategy

RTS Spring – Originally a project to copy Total Annihilation in 3D. Now it supports 3rd party mods with different modes of play. The Gui enhancements are far superior to the 10+ year old TA engine.

RPG

Runesword Open source – It has been released as public domain. A great table top RPG.

KQlives – 2D Fantasy RPG.

For a more exhaustive list check Wikipedia or the Libregamewiki