Skip to content

Instantly share code, notes, and snippets.

View tcotav's full-sized avatar

James Francis tcotav

View GitHub Profile
@tcotav
tcotav / ssh_key_clean.sh
Last active September 24, 2015 01:54
Clean ssh known_hosts files for a specified user
#!/bin/bash
# ssh_key_clean.sh user site1 site2 site3 site4
user=$1
hostlist=`echo "${@:2}"`
for hhost in $hostlist; do
ip=$(dig +short $hhost)
if [ -z "$ip" ];then
@tcotav
tcotav / etcd22_watcher.go
Created September 17, 2015 04:55
Using watch with new etcd 2.2 golang library
package main
import (
"github.com/coreos/etcd/client"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
"log"
"time"
)
func main() {
@tcotav
tcotav / initgo.sh
Created August 30, 2015 20:26
Go and etcd install script in BASH
#!/bin/bash
### Install git and basic workstation stuff
apt-get install git -y
apt-get install git-flow -y
git clone https://github.com/tcotav/workstation-init.git
cd workstation-init
ln -s ~/workstation-init/vim ~/.vim && ln -s ~/workstation-init/tmux.conf ~/.tmux.conf && ln -s ~/workstation-init/gitignore ~/.gitignore
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
@tcotav
tcotav / pandas_timeseries.py
Last active August 29, 2015 14:16
pandas timeseries dataframe from source
import pandas as pd
import datetime as dt
testdata={
"host1":[
(dt.datetime(2015, 3, 5, 12), 100),
(dt.datetime(2015, 3, 5, 12,1), 100),
(dt.datetime(2015, 3, 5, 12,2), 100),
(dt.datetime(2015, 3, 5, 12,3), 100),
(dt.datetime(2015, 3, 5, 12,4), 100),
@tcotav
tcotav / regex_extract
Created December 16, 2014 20:54
because I'm dumb and never remember the regex extraction
t = "\"productId\":\"111111\""
m = re.match("\W*productId[^:]*:\D*(\d+)", t)
if m:
print m.group(1)
@tcotav
tcotav / gist:e7843df353c72e780934
Created December 12, 2014 20:13
python logging example
import time
import logging
from logging.handlers import TimedRotatingFileHandler
loglvl = logging.DEBUG
logname="py.log"
logger=logging.getLogger(logname)
@tcotav
tcotav / sample_parse_graph
Created November 12, 2014 19:23
bit of matplotlib stuff for graphing
#!/usr/bin/env python
import sys
from os import listdir
from os.path import isfile, join, getmtime, split
from datetime import datetime
import matplotlib.pyplot as plt
import numpy as np
@tcotav
tcotav / mongodb
Created September 4, 2014 19:50
WORKING Ubuntu Mongodb Start Script
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@tcotav
tcotav / gist:ea4dd5535aef9bb5da8c
Created August 19, 2014 20:39
Using module.run with salt modules

Wut

There are multiple kinds of modules in salt. Some you can use in the jinja templates directly, but the big list requires you to use module.run

Sample code

Here's a sampe of us using module.run to invoke the module linux_sysctl.persist method:

redis_sysctl:

module.run:

@tcotav
tcotav / reinit-salt-minion.sh
Last active August 29, 2015 14:05
Re-initialize salt-minion
#!/bin/bash
# basically delete all signs of previous id and data
# and start over
/etc/init.d/salt-minion stop
rm -Rf /var/cache/salt/minion
rm /etc/salt/minion_id
rm -Rf /etc/salt/pki