@madpilot makes

Global search and replace using the command line

If you have ever used Dreamweaver, you are probably familiar with the Global Search and Replace feature, which allows you to search and replace amongst all files with in a site, which can be very handy if you are doing a static site. If you are too hard core for Dreamweaver though, and you spend your whole day buried in a terminal window, how can you achieve the same thing? By this piece of bash-trickery, that’s how:

find . | grep html | xargs -t -I {} sh -c "cat {} | sed 's/Stuff to find/Replace with this/' > {}"
  1. find . – find all the files from the current directory down
  2. grep html – filters the output to include only filesnames with html in them
  3. xargs -t -I {} sh -c – pumps the file names into the cat command, but also sets a variable called {} that holds the filename
  4. sed ‘s/Stuff to find/Replace with this/’ – just a search and replace
  5. > {} – save the output back to the original file name A word of warning though, leave the last bit off until you are sure your output is correct, because there is no undo feature :)

Ubiquity: Three types of awesome

A couple of days ago, Mozilla labs released Ubiquity 0.1, which is a browser-based natural language command helper. Sounds geeky – and it is, but oh-so hot. Basically it’s a Firefox plugin that allows you to perform actions and pull information from services without leaving the screen you are in. If a picture tells a thousand words, a video tells a thousand pictures (That’s 1000000 words according to the ubiquity calc command).

Ubiquity for Firefox from Aza Raskin on Vimeo.

Being a command line junkie, this is FREAKING AWESOME. Not having to open up a new tab just to find a definition, or to post to twitter stops you from having to make a context switch and break your current thought process. What is even more awesome is that if you know JavaScript, you can really quickly write your own verbs. For example, I just wrote a quick verb called goto that opens a URL in a new tab [Get it here]. Think of the precious seconds I save by not having to move the mouse. It also allows you to annotate websites, and highlight text as well as colour code source that you might find, plus so much more. If you are a geek and you are on the web. Go and check it out.

JoikuSpot premium edition released

A couple of days ago, Joiku released the premium edition of their WiFi access software for Sybian phones: JoikuSpot. I’ve blogged about JoikuSpot before, and now for 15€ you can get the premium edition, which NATs mail, Skype, SSH, HTTPS and number of other protocols. They also seemed to have fixed the issue which stopped the EeePC using DHCP. This is really awesome – I can finally leave that USB cable at home. Let’s see your beloved iPhone do that!

A multi-touch pad of my very own

I simply had to have one. As I previously posted, the ever so clever guy from http://ssandler.wordpress.com/MTmini/ posted instructions for making your own multi-touch (think Microsoft Surface or iPod Touch) pad. So what can any self-respecting geek do, other than to build one? Here is what I did.

Being the impatient kind of guy that I am, I didn’t want to have to buy anything to complete the build (I had to wait unit after work, and the shops were closed), so I did a little substitution with stuff you might find around your house. The ingredients:

  • 1 x An old red wine glass box (Although any decent sized box would do)
  • 1 x A4 picture frame
  • 1 x 6 year-old Dlink DCB-C300 Webcam
  • 30 cm of baking paper
  • 4cm of sticky tape
  • 1 blob of Bluetac
  • 1 x Software bundle from http://ssandler.wordpress.com/MTmini/

I had to modify the webcam slightly, as the current configuration was too long to fit in the box very well (You need as much gap between the pad and camera as possible which will give you maximum usage space), so I had to bend some pins to get it to lie flat. Next, I bluetac’d it to the bottom of the box. Next I took the cardboard backing off the picture frame, removed the glass and covered one side in the baking paper. I used the sticky tape to fasten it in, and replace the paper-clad glass back in the frame. Placing the frame on top of said box completes the build.

After installing the software and following the instructions (including the calibration instructions) it was done! Yep. That’s right. Done. 5 minutes work really (Not includingbending the pins and digging out the drivers for the webcam). See the photos and short (badly shot) video as proof of this wondrous feat. This is SERIOUSLY COOL.

The webcam sans it’s inners

The picture frame

And the proof that is works: