List your Apache virtual hosts

21/05/2010
apache2ctl -t -D DUMP_VHOSTS
No Comments

Copy a large directory of files using ls and xargs

13/05/2010
ls . | xargs -i -t cp ./{} /path/to/new/directory

See example 12-6 at http://www.homepage.montana.edu/~unixuser/051905/abs-guide/moreadv.html

No Comments

Rails migrations: creating a MySQL BIGINT

7/04/2010
add_column :facebook_user_id, :integer, :limit => 8 # BIGINT
No Comments

Basic use of ’screen’

25/02/2010

Using screen is a great way to leave long-running processes churning away when you’re not logged into the machine.

Open a new screen

screen

Detach from the screen

This does not interrupt whatever is running in the screen.

Press Ctrl-A then D.

Reattach to a screen you’ve already opened

screen -r

If you’ve opened multiple screens, a list will be displayed:

There are several suitable screens on:
	1681.ttys004.braeburn	(Detached)
	1686.ttys004.braeburn	(Detached)

Just use the process ID of the screen to resume the right one:

screen -r 1681
No Comments

Change your default SSH username

12/02/2010

If you’ve not had your own choice of username on your machine (for example, if your company imposes a username policy), you can set up a different default username for SSH in ~/.ssh/config:

Host *
  User chris
No Comments

Readable, colourful Terminal in Snow Leopard

27/01/2010

Terminal screenshot

  1. Install SIMBL: http://www.culater.net/software/SIMBL/SIMBL.php
  2. Install the Snow-Leopard-friendly version of the TerminalColors plugin for SIMBL: http://github.com/timmfin/terminalcolours
  3. Install the IR_Black theme and set it as default in Terminal.app preferences: http://blog.infinitered.com/entries/show/6
  4. Turn on CLI color in your .bash_profile:
    export CLICOLOR=1;
  5. Bonus round: set yourself a colourful bash prompt: http://devblog.bluefuton.com/2008/05/coloured-bash-prompt-in-os-x/
No Comments

Border radius in Chrome, Firefox and Safari

7/12/2009

Chrome 4 currently appears to be the only browser to implement the W3C’s border-radius property:

http://www.w3.org/TR/2002/WD-css3-border-20021107/#the-border-radius

border-top-left-radius: 1em;
border-top-right-radius: 1em;

You can produce the same result using proprietary attributes in Firefox 3.5 and Safari 4:

/* Firefox */
-moz-border-radius-topleft: 1em;
-moz-border-radius-topright: 1em;
 
/* Safari */
-webkit-border-top-left-radius: 1em;
-webkit-border-top-right-radius: 1em;

Source: http://www.css3.info/preview/rounded-border/

No Comments

Using find with -exec to copy large directories

13/10/2009

To copy files from one directory, you might usually do:

cp dir/* anotherdir/

If you try to do this with a particular large number of files, you may encounter the ‘argument list too long’ error. In this case you can use:

find . -exec cp {} /path/to/anotherdir/ \;

More approaches at: http://www.linuxjournal.com/article/6060

No Comments

FOWA 2009: The Future of HTML5

13/10/2009

“The web is too important for society to be in the hands of any one vendor”

– Bruce Lawson, Opera

HTML5 is more a collection of new technologies than a single new standard – we can start using parts of it today.

You can use Moderizr to check what HTML5/CSS3 features are available in your browser. You can see it in action at FindMeByIP.

Canvas/SVG

Cross-browser canvas support & speed

Canvas is possible in IE using a single script tag: check out Excanvas

Filament have created accessible charts from HTML tables using the canvas element: jQuery Visualise plugin

Accessibility: canvas or SVG?

  • With images off, canvas elements are essentially blank, whereas SVG remains as text
  • Use SVG for content and canvas for bling (for now)

Forms

Browser handles special field display and front-end validation that has traditionally required Javascript (popup calendar, focus on field, email validation, required field validation).

Examples: http://people.opera.com/brucel/demo/html5-forms-demo.html

Geolocation

Currently iPhone Safari and Firefox 3.5 only.

Examples: http://html5demos.com/geo

No Comments

Linux: email alert when disk is nearly full

30/09/2009
#!/bin/bash
# Send an email when disk space used reaches a certain threshold
FS="/"
SERVER_NAME="linux02"
EMAIL="user@example.com"
THRESHOLD=95
OUTPUT=($(LC_ALL=C df -P ${FS}))
CURRENT=$(echo ${OUTPUT[11]} | sed 's/%//')
[ $CURRENT -gt $THRESHOLD ] && df -h | mail -s "$SERVER_NAME disk space alert: $CURRENT% full" $EMAIL

I’ve set this up as a cron job run at 3am daily:

0 3 * * * ./root/maintenance/check_free_space.sh

Based upon http://www.cyberciti.biz/faq/mac-osx-unix-get-an-alert-when-my-disk-is-full/

No Comments