Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / check_replication_delay
Created July 8, 2013 20:24
Nagios Postgres replication delay check.
#!/usr/bin/env bash
##
# Postgres replication delay check.
#
# @author Jay Taylor [@jtaylor]
#
# @date 2013-07-08
#
@jaytaylor
jaytaylor / cf.sh
Last active September 10, 2025 09:34
CloudFlare command-line DNS management shell script, now with CloudFlare v4 API support!
#!/usr/bin/env bash
##
# @author Jay Taylor [@jtaylor]
# @date 2013-08-15
#
# @description CloudFlare management script.
#
# Path ENV VAR override.
@jaytaylor
jaytaylor / homebrewinfo
Last active December 21, 2015 08:08
Reporting a `homebrew` issue.
$ brew doctor
Warning: Your file-system on / appears to be CaSe SeNsItIvE.
Homebrew is less tested with that - don't worry but please report issues.
$ brew --config
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew.git
HEAD: cb9317eb03f54b1951c5c13d9e6096a36a871fef
HOMEBREW_PREFIX: /usr/local
@jaytaylor
jaytaylor / migrateSshKeys.sh
Created September 3, 2013 23:04
Ubuntu SSH system keys migration utility: This utility enables the system-wide cloning of SSH keys located at /etc/ssh, ~/.ssh, and /root/.ssh from one host to another. This makes it possible to migrate a hostname from one machine to another without triggering SSH key mismatch alerts.
#!/usr/bin/env bash
##
# @author Jay Taylor [@jtaylor]
#
# @date 2013-09-03
#
# Ubuntu SSH system keys migration utility.
#
# Used to clone system-wide SSH keys located at /etc/ssh, ~/.ssh, and /root/.ssh from one host to another. This makes
@jaytaylor
jaytaylor / timeout.sh
Created September 11, 2013 18:18
Mac OS-X does not come with the delightfully useful `timeout` program. Thankfully a rough BASH equivalent can be achieved with only 2 perl statements.
#
# Mac OS-X does not come with the delightfully useful `timeout` program. Thankfully a rough BASH equivalent can be achieved with only 2 perl statements.
#
# Originally found on SO: http://stackoverflow.com/questions/601543/command-line-command-to-auto-kill-a-command-after-a-certain-amount-of-time
#
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
## Example usage:
#
@jaytaylor
jaytaylor / repmgrd.conf
Created September 25, 2013 19:30
Postgresql repmgr daemon upstart script.
console none
start on (local-filesystems and net-device-up IFACE!=lo)
stop on [!12345]
exec start-stop-daemon --start --user postgres --exec /usr/bin/repmgrd -- -f /etc/repmgr.conf --verbose
@jaytaylor
jaytaylor / pgLogArchiver.sh
Last active September 20, 2019 15:29
Postgres log file compressor which compresses and uploads files to s3 before deleting them.
#!/usr/bin/env bash
##
# @author Jay Taylor [@jtaylor]
#
# @date 2013-10-02
#
# Postgres log file compressor which compresses and uploads files to s3 before deleting them.
# This script must be located in the same directory as the log files.
#
@jaytaylor
jaytaylor / pgBackup.sh
Last active May 15, 2018 06:49
Postgres database dump, compress and upload to s3.
#!/usr/bin/env bash
##
# @author Jay Taylor [@jtaylor]
#
# @date 2013-10-02
#
# Postgres database dump, compress and upload to s3.
#
# Make sure this script runs from a directory with enough space to hold and compress the db dump.
@jaytaylor
jaytaylor / LogicalShard.py
Created October 14, 2013 22:29
Django auto-sharding core.
# -*- coding: utf-8 -*-
"""LogicalShard model."""
__author__ = 'Jay Taylor [@jtaylor]'
from django.db.models import (
CharField,
DateTimeField,
IntegerField,
@jaytaylor
jaytaylor / toothpick.c
Last active December 26, 2015 11:28
Solution for the ACM ICPC toothpick problem: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1578. Usage: gcc -o toothpick -std=c99 toothpick.c; echo -e "35\n37\n53\n10\n20\n50" | ./toothpick
#include <stdio.h>
#include <stdlib.h>
typedef struct t_operation {
char operand;
int n;
struct t_operation* next;
} t_operation;
int opCost(t_operation* op) {