Skip to content

Instantly share code, notes, and snippets.

@dansimau
dansimau / colourpicker.scpt
Created August 5, 2012 15:40
A colour picker app for Mac OS X
set the RGB16bit_list to (choose color)
-- convert choosen color to HEX
set the formatedColor to my RBG_to_HEX(RGB16bit_list)
set the clipboard to formatedColor
display dialog "HEX colour value (" & formatedColor & ") has been copied to the clipboard." with icon 1 buttons {"Dismiss"} default button {"Dismiss"} giving up after 10
on RBG_to_HEX(RGB_values)
-- this subroutine was taken from "http://www.apple.com/applescript/sbrt/sbrt-04.html"
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
@dansimau
dansimau / nfs-remount.sh
Created July 17, 2012 15:33
Bash script to add psuedo-remount functionality to NFS mounts in Linux
#!/bin/bash
#
# Remount a filesystem with new options by unmounting it first (with umount)
# and mounting it again.
#
# Used for filesystems that do not support the -o remount option (eg. NFS).
#
# Compatible with Linux/bash only.
#
# 2012-07-17
@dansimau
dansimau / README.md
Created July 13, 2012 10:39
Enable git-style colour output in regular diff on Mac OS X

Enable git-style colour output in regular diff

Mac OS X

  1. Install colordiff using Homebrew:

     brew install colordiff
    
  2. Add function to your ~/.bash_profile:

@dansimau
dansimau / .gitignore
Created May 20, 2012 23:52 — forked from urschrei/mkflask.sh
Bootstrap a Flask project on Ubuntu Precise, with Puppet, Vagrant and Fabric. (For latest version, see https://github.com/dansimau/flask-bootstrap)
*~
*.pyc
.vagrant
venv
@dansimau
dansimau / showdown.js
Created February 28, 2012 10:12
Markdown-to-HTML file converter using showdown JS library (Node.js)
#!/usr/bin/env node
/**
* Takes specified Markdown files outputs them as HTML.
*
* Requires showdown:
*
* npm install showdown
*
* dan@dans.im
@dansimau
dansimau / reduce-backups.sh
Created January 20, 2012 09:57
Prunes Squiz CMS backups to the last X number of days. Will bail out if the backups have broken, to avoid deleting backups if they may be needed.
#!/bin/bash
#
# Reduces the total number of Squiz CMS backups to the last X days', whilst
# also ensuring at least X number of backups always exist.
#
# In other words, we want only the last X number of days' backups unless the
# backups have failed, in which case we'd prefer to keep the old ones until
# the backup is running again.
#
# dsimmons@squiz.co.uk
@dansimau
dansimau / pgclone.sh
Created January 18, 2012 12:52
Clones a new PostgreSQL standby server from master
#/bin/sh -x
#
# Restores a slave node from the specified master and sets up recovery.conf
# with streaming replication.
#
# dsimmons@squiz.co.uk
# 2012-01-24
#
if [ -z "$1" -o "$1" == "--help" ]; then
@dansimau
dansimau / pglag.sh
Created January 9, 2012 11:58
Calculate the replication lag between postgresql master and one or more slaves in streaming replication mode.
#!/bin/bash
#
# Show replication lag for one or more postgresql slaves in streaming replication.
#
# dsimmons@squiz.co.uk
# 2012-01-09
#
psql="which psql"
psql_extra_opts=""
@dansimau
dansimau / pgprepmgr.sh
Created January 9, 2012 10:57
Wrapper for pgpools' pcp tools to help you manage your pgpool setup and postgresql cluster. See usage in the comment below.
#!/bin/bash
#
# pgpool-II replication manager
#
# Interfaces with pgpool's pcp command-line tools to provide access to common functions for managing
# load-balancing and failover.
#
# dsimmons@squiz.co.uk
# 2011-08-28
@dansimau
dansimau / ping-csv.sh
Created December 23, 2011 11:01
Ping a host and output each reply in CSV format
#!/bin/bash
#
# Do a ping and output results as CSV.
#
# dsimmons@squiz.co.uk
# 2011-12-23
#
if [ $# -lt 1 ]; then
echo "Usage: $0 [--add-timestamp] <ping host>"