Skip to content

Instantly share code, notes, and snippets.

View beezly's full-sized avatar

Andrew Beresford beezly

View GitHub Profile
@beezly
beezly / gist:3933203
Created October 22, 2012 18:26
Change Migration script
RENAME TABLE lookup TO lookups;
ALTER TABLE lookups DROP COLUMN section_id;
CREATE TABLE `changes` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(25) NOT NULL,
`type` enum('routine','fix','new','severe') NOT NULL,
`reason` text NOT NULL,
`duration` int(11) NOT NULL,
`impact` enum('high','low') NOT NULL,
@beezly
beezly / gist:3953098
Created October 25, 2012 14:59
TrafficScript to force Authentication over HTTPS
$headers = http.listResponseHeaderNames();
# If we find the "WWW-Authenticate" header, we change site to HTTPS
if (array.contains($headers, "WWW-Authenticate")) {
$server = http.getHostHeader();
http.changeSite("https://".$server);
}
@beezly
beezly / gist:3955784
Created October 25, 2012 22:08
VirtualServer.wsdl
This file has been truncated, but you can view the full file.
<?xml version="1.0" ?>
<!--
Copyright (c) 2005-2012 Zeus Technology. All rights reserved.
-->
<definitions name="VirtualServer"
targetNamespace="http://soap.zeus.com/zxtm/1.0/"
xmlns:zeusns="http://soap.zeus.com/zxtm/1.0/"
@beezly
beezly / gist:4250079
Created December 10, 2012 11:24
Google Script Spreadsheet function to iterate over all cells and insert the value 0 if the cell is blank
function zeroCells() {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getSheets()[0];
var selection=sheet.getDataRange();
var columns=selection.getNumColumns();
var rows=selection.getNumRows();
for (var column=1; column < columns; column++) {
for (var row=1; row < rows; row++) {
var cell=selection.getCell(row,column);
if (cell.isBlank()) {
@beezly
beezly / gist:4267198
Created December 12, 2012 11:49
trello hubot stuff.
# Description:
# Add entries to trello directly from hubot
#
# Dependencies:
# "node-trello": "0.1.2"
#
# Configuration:
# HUBOT_TRELLO_KEY - your trello developer key
#
# Commands:
@beezly
beezly / gist:5039393
Created February 26, 2013 15:37
extract from inode.c
/*
* With relative atime, only update atime if the previous atime is
* earlier than either the ctime or mtime or if at least a day has
* passed since the last atime update.
*/
static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
struct timespec now)
{
if (!(mnt->mnt_flags & MNT_RELATIME))
@beezly
beezly / gist:5124386
Created March 9, 2013 14:50
MD5 a bunch of files
find . -type f -print0 | xargs -0 openssl md5
@beezly
beezly / delegated-drive-api.rb
Last active December 17, 2015 20:39
2-legged Domain Delegated Access to Google APIs
require 'google/api_client'
# To use this code you you need to create a "service account" that has the rights
# to access the appropriate Google APIs you are going to use.
# See https://code.google.com/apis/console for info on creating service account
# credentials
# You need to grant access to your domain for this service account. There is more
# useful information and examples in other languages at
# https://developers.google.com/drive/delegation
@beezly
beezly / certificate_expiry.rb
Created July 6, 2013 23:41
certificate_expiry fact
Facter.add("certificate_expiry") do
setcode do
Puppet::SSL::Host.localhost.certificate.expiration
end
end
@beezly
beezly / tidy-kernels.sh
Last active December 24, 2015 13:59
Ubuntu machine keeps getting filled up with old kernels? Why not run this script from your crontab. === Warning - may trash your machine. Don't blame me. You downloaded it. === Run at any time without downloading (so long as you have wget) with wget -O - https://gist.github.com/beezly/6809337/raw | /bin/bash
#!/bin/bash
read -a kernels_installed <<< `dpkg -l 'linux-image-[0-9]*' | grep ^ii | awk '{ print $2 }'`
kernel_links=(/vmlinuz /vmlinuz.old)
kernels_to_keep=( )
DEBUG=0
for i in ${kernel_links[@]}; do
if [ $DEBUG -eq 1 ]; then echo "Checking $i"; fi
real_kernel_link=`readlink $i`
if [ $DEBUG -eq 1 ]; then echo "$i points to /$real_kernel_link"; fi