Saturday, 27 July 2013

Install Google Chrome in Ubuntu using Google's repositories

This is mostly a note to myself to save a minute of searching every time I need it:
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable

Tuesday, 25 June 2013

Copy files in a directory tree matching pattern(s) while preserving the relative path

Have you ever wanted to copy all files of a certain type from a large directory tree to an identical directory tree?

For example, one time I needed to copy all the .so files from /var/lib/gems to the vendor directory because for some reason, dependencies didn't. Copying all files didn't appeal to me, so I made this script.

Why I will not sign an NDA

I do appreciate people contacting me about a business idea they have where they need the help of an experienced software architect or database specialist. However so many non-tech people keep asking for NDAs, and often so after writing only one sentence (or less) about what the project is about. Because this happens more than once, I'll do what any serious developer would do - write a script to automate it. So here's my automated reply:

Tuesday, 9 April 2013

Replacing a failed Software RAID-1 disk on Ubuntu 12.04

Preparation:

Figure out which disk is broken

In my case this was easy, as the server is hosted, and the hosting company did a hardware check for me after random failures where the server suddenly died. They reported the following:
The requested check is finished now. We found problems with the drive with SN Z1F0WA1P so please confirm the complete loss of data on it and tell us when we may shutdown the server to change it.

Nice!
Luckily I set up RAID-1 so the "complete loss of data" is not really a big problem.
I found the device id of the failed disk this way:

Friday, 15 March 2013

Looping/iterating through files - in Linux, Bash Command Line/Shell



#!/bin/sh

if [ "$1" == "" ]; then
  echo "Syntax: $0 filenames"
  echo "(filenames can be any (positive) number of files)"
  exit 1
fi
for file in $@
do
  [ -f $file ] && echo "Full Path: $file - Base Filename: $(basename $file)"
  # note: Full Path will only contain a path if the input arguments contain paths.
  # basename will always strip the path, if any
  # the [ -f $file ] bit filters out files only, so we don't process directories
done



Thursday, 14 March 2013

[SOLVED] curl-config issue installing esniper on Ubuntu 12.04 Precise Pangolin


I recently installed esniper on Ubuntu 12.04 LTS (Precise Pangolin) and had problems installing it at first. Configure stopped on curl-config, even though curl was installed.

$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes

Wednesday, 13 March 2013

TTYtter - A twitter client that makes twitter almost usable (like IRC)!

Twitter has been something I reluctantly used every 3-6 months or so, but I just did a search for command line twitter clients and was delighted that there were a few. I tried out one called TTYtter, which made twitter almost like IRC - in other words much more usable than the lame web interface!

Here's how to install on Ubuntu. I went for the latest version rather than the one in Ubuntu's repository.