Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Add or list DNS entries in an 02 wireless box
# To compensate for O2's unreliable DNS provision
# h/u/p for standard O2 wireless box
host=192.168.1.254
user=SuperUser
pass=O2Br0ad64nd
# OpenDNS server to add
#!/usr/bin/env python
#
# Music collection reconcile - which tracks are new locally/on external HD?
#
# Basically a poor-man's rsync, but it seems faster for solely this task. Also
# less likely to generate false positives, although it can make false negatives
# e.g. if files have been changed (ID3 information etc.)
import sys
import glob
@jpstacey
jpstacey / example.php
Created June 11, 2010 11:46
Clean Drupal hook_views_Default_views
<?php
/**
* Implementation of hook_views_default_views
*/
function example_views_default_views() {
return example_default_views_from_files();
}
/**
* Helper function for default views - get from files in a subdirectory
@jpstacey
jpstacey / .gitconfig
Last active February 7, 2024 04:35
Sample git config
# See the following for references:
# * http://www.metacircus.com/hacking/2011/02/18/play-git-like-a-violin.html
# * http://cheat.errtheblog.com/s/git/
# * http://pyrtsa.posterous.com/aligning-your-git-logs
# * http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
# Git >v1.7.10 lets you include external files
# Put your user configuration in here, so it never
# accidentally gets checked in
[include]
@jpstacey
jpstacey / db_search.php
Created June 27, 2011 11:42
Search all tables in a Drupal database using Drupal bootstrap to get a db connection
<?php
/**
* Search all Drupal database tables for a string
* Uses simple concat(), so could
* (a) have false positives through concat or
* (b) have false negatives through TEXT trimming
*/
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
@jpstacey
jpstacey / gist:1133723
Created August 9, 2011 10:29
Causing MySQL to raise an exception from a trigger
-- MySQL does not implement raising exceptions within triggers. Here's a hacky model for doing so.
-- This permits unwanted conditions to bubble up to the application layer, to be dealt with
-- Only use this during debugging. Don't rely on this in production code as it's a hack.
DELIMITER $$
-- Procedure guaranteed to raise an exception
CREATE PROCEDURE die_horribly() SQL SECURITY INVOKER DETERMINISTIC
BEGIN
INSERT INTO does_not_exist (nid) VALUES (NULL);
@jpstacey
jpstacey / .bashrc_snippet_git_branch
Created October 28, 2011 11:20
Display git branch in your command prompt
# Via rjmackay
# Add git ps1 $(__git_ps1 " (%s)")
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[0;33m\]$(__git_ps1 " (%s)")\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (%s)")\$ '
fi
force_color_prompt=yes
@jpstacey
jpstacey / gist:5720430
Last active December 18, 2015 03:48
Initial attempts to run computerminds:parrot VM
...
[default] Running Puppet with /tmp/vagrant-puppet/manifests/bootstrap.pp...
stdin: is not a tty
err: /Stage[main]//Node[default]/Package[puppet]/ensure: change from purged to latest failed: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install puppet' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
augeas-lenses debconf-utils facter libaugeas-ruby1.8 libaugeas0 libreadline5
libruby libruby1.8 libshadow-ruby1.8 puppet-common ruby ruby1.8
@jpstacey
jpstacey / country_flags_imagemagick.sh
Created August 6, 2013 10:47
Adding country flags to the corner of a generic icon
# Country flags on icons
for i in uk us au; do composite -geometry wxh+top+left $i.png original-icon.png icon-$i.png; done
@jpstacey
jpstacey / freelance drupal killer contract.md
Last active December 26, 2015 13:09 — forked from manarth/drupal killer contract.md
Contract between a freelance Drupal developer and another party

Freelance Technical Consultancy Contract

Between me: [my name]
and you: [customer name]

Summary