Skip to content

Instantly share code, notes, and snippets.

View shaundomingo's full-sized avatar

Shaun Domingo shaundomingo

  • Macquarie Cloud Services
  • Sydney
View GitHub Profile
@shaundomingo
shaundomingo / proc_nf_destroy_historical_data.sql
Last active August 29, 2015 14:27
Script to automate the cleanup of old, unnecessary data in cloud and cloud_usage tables
-- CLEAN UP RECORDS
DROP PROCEDURE IF EXISTS cloud.nf_destroy_historical_data;
delimiter //
CREATE PROCEDURE cloud.nf_destroy_historical_data(IN tableName VARCHAR(255), IN columnCriteria VARCHAR(255), IN batchSize INTEGER, IN intervalDays INTEGER, IN dryRun INTEGER, IN debugOn INTEGER)
BEGIN
SET @count_rows_query = CONCAT("SELECT count(id) INTO @table_row_count FROM ", tableName);
SET @min_id_query = CONCAT("SELECT MIN(id), MAX(id) INTO @a, @m FROM ", tableName, " WHERE ", columnCriteria, " < DATE_SUB(CURRENT_DATE(), INTERVAL ", intervalDays, " DAY)");
SET @get_batch_query = CONCAT("SELECT id INTO @z FROM ", tableName, " WHERE id >= @a ORDER BY id LIMIT ", batchSize, ",1");
SET @delete_batch_query = CONCAT("DELETE FROM ", tableName, " where id >= @a AND id < @z AND ", columnCriteria, " < DATE_SUB(CURRENT_DATE(), INTERVAL ", intervalDays, " DAY)");
SET @dry_run_delete_batch_query = CONCAT("SELECT COUNT(*) FROM ", tableName, " where id >= @a AND id < @z AND ", columnCriteria, " < DATE_SUB(CURRENT_DATE(), I
@shaundomingo
shaundomingo / gist:1fff588c24ba88b143f5
Last active August 29, 2015 14:25
Kubernetes Node / Minion
#cloud-config
users:
- name: core
passwd: $6fJRjBeFH.J.
write-files:
- path: /opt/bin/wupiao
permissions: '0755'
content: |
#!/bin/bash
# [w]ait [u]ntil [p]ort [i]s [a]ctually [o]pen
@shaundomingo
shaundomingo / gist:43a32b72904d89f90d58
Last active October 28, 2018 18:28
CoreOS in anger - deploying a scalable wordpress cluster on CoreOS with fleet, docker and vulcand

CoreOS can seem daunting at first. This tutorial is built to encourage you in your journey and to demonstrate the power of this minimalistic operating system.

Exercise 1: Boot up a 3 machine coreos cluster

1a: Install prerequisite software

1b: Clone the coreos-vagrant repo

#cloud-config
coreos:
update:
reboot-strategy: best-effort
etcd:
discovery: https://discovery.etcd.io/5bd13a16d1852c1ef38726305ea7b0be
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
fleet: