Skip to content

Instantly share code, notes, and snippets.

View abg's full-sized avatar

Andrew Garner abg

  • VMware
  • San Antonio
View GitHub Profile
@abg
abg / compute_checksums_advanced.py
Last active November 22, 2019 20:49
Compute checksums with external program vs. python stdlib, with python3 compatibility
from __future__ import print_function
import argparse
import codecs
import hashlib
import os
import subprocess
import sys
import time
try:
import os
import subprocess
import sys
def run_checksum(basedir, filename, output):
args = ['xxhsum', filename]
process = subprocess.Popen(args, stdout=output, close_fds=True, cwd=basedir)
if process.wait() != 0:
raise subprocess.CalledProcessError(process.returncode, args)
@abg
abg / poll_read_only.go
Created February 15, 2019 15:40
Simple Test Harness to time querying the read_only status on a MySQL instance via various implementations
package main
import (
"database/sql"
"flag"
"log"
"os"
"time"
_ "github.com/go-sql-driver/mysql"
package filesystem
// See: https://talks.golang.org/2012/10things.slide#1
// Also see github.com/spf13/afero
// Playground for testing some fake / TDD ideas around filesystem bits
// With https://github.com/maxbrunsfeld/counterfeiter can be used
// to Stub out various os.* bits to focus tests
import (
#!/usr/bin/env python
## Chug github.com/cloudfoundry/lager logs
import json
import sys
import datetime
for line in sys.stdin:
try:
@abg
abg / fincore_raw.go
Created May 9, 2017 16:00
Quick & Dirty implementation of fincore in go
package main
import (
"fmt"
"os"
"syscall"
"unsafe"
)
func fincore(path string) {
@abg
abg / uncache.go
Last active May 8, 2017 15:38
Uncache a set of files (reimplementation of: https://dom.as/2009/06/26/uncache/)
package main
import (
"fmt"
"os"
"path/filepath"
"golang.org/x/sys/unix"
)
if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
# To avoid comparing data directory and BINLOG_DIRNAME
mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
pushd $BINLOG_DIRNAME &>/dev/null
for bfiles in $(ls -1 ${BINLOG_FILENAME}.[0-9]*);do
@abg
abg / mdev_8865.py
Last active October 30, 2015 05:09
#!/usr/bin/env python
import os
import pprint
import random
import MySQLdb
c = MySQLdb.connect(read_default_file=os.path.abspath('my.sandbox.cnf'), db='test')
cursor = c.cursor()
"""
Iterative table checksum of tables with composite keys
This uses an algorithm similar to mk-table-sync's Nibble
algorithm but intended purely for checking if a master/slave
are in sync.
"""
import os, sys
import time
import warnings