Skip to content

Instantly share code, notes, and snippets.

View nmische's full-sized avatar

Nathan Mische nmische

  • Philadelphia, PA
  • 18:51 (UTC -04:00)
View GitHub Profile
@nmische
nmische / conflict.groovy
Created February 13, 2014 02:47
Example of how to find time conflicts.
@Grab(group='joda-time', module='joda-time', version='2.3')
import org.joda.time.DateTime
def eventList = [
[ name: "Event One", startDate: new DateTime(2014,2,12,11,0,0), endDate: new DateTime(2014,2,12,12,0,0) ],
[ name: "Event Two", startDate: new DateTime(2014,2,12,13,0,0), endDate: new DateTime(2014,2,12,14,0,0) ],
[ name: "Event Three", startDate: new DateTime(2014,2,12,11,30,0), endDate: new DateTime(2014,2,12,12,30,0) ],
[ name: "Event Four", startDate: new DateTime(2014,2,12,9,0,0), endDate: new DateTime(2014,2,12,10,0,0) ],
[ name: "Event Five", startDate: new DateTime(2014,2,12,9,0,0), endDate: new DateTime(2014,2,12,10,0,0) ],
[ name: "Event Six", startDate: new DateTime(2014,2,12,10,0,0), endDate: new DateTime(2014,2,12,11,0,0) ],
@nmische
nmische / rpms
Created March 3, 2014 19:21
Shibboleth SP RPMs for Amazon Linux
curl-openssl-7.33.0-1.1.x86_64.rpm
curl-openssl-debuginfo-7.33.0-1.1.x86_64.rpm
libcurl-openssl-7.33.0-1.1.x86_64.rpm
libcurl-openssl-devel-7.33.0-1.1.x86_64.rpm
liblog4shib-devel-1.0.8-1.1.x86_64.rpm
liblog4shib1-1.0.8-1.1.x86_64.rpm
libsaml-devel-2.5.3-1.1.x86_64.rpm
libsaml8-2.5.3-1.1.x86_64.rpm
libxerces-c-3_1-3.1.1-2.1.x86_64.rpm
libxerces-c-devel-3.1.1-2.1.x86_64.rpm
@nmische
nmische / dedupe.sh
Created March 19, 2014 17:32
One liner to remove items in dupes.txt from full.txt
comm -23i <(cat full.txt | sort | uniq -i) <(cat dupes.txt | sort | uniq -i)
@nmische
nmische / sorting_fun_01.py
Last active August 29, 2015 13:57
Chain a list of tuples.
# We can sort using a custom adjacency index that allows us to pick the starting node.
tickets = [('PHL','NYC'),('IAD','PHL'),('SFO','IAD'),('NYC','SFO')]
sortedTickets = []
index = {}
for t in tickets:
if t[0] not in index:
index[t[0]] = t
def getNext(ticket):
@nmische
nmische / convert-to-utf8.groovy
Created May 27, 2014 15:00
A script to convert files to UTF-8.
new File('~/tmp').eachFile {
def toolkit = new CharsetToolkit(it)
def cs = toolkit.getCharset().toString()
def filePath = it.path + '/' + it.name
println filePath + ': ' + cs
if (cs != 'UTF-8') {
def content = it.getText(cs)
it.write(content ,'UTF-8')
@nmische
nmische / bootstrap.sh
Created August 12, 2014 14:13
CFEngine 3.3.9 Bootstrap
#! /bin/sh
cf-agent --bootstrap --policy-server 10.0.2.15
@nmische
nmische / test.sh
Created December 4, 2014 04:09
nc test for failure
nc -v -z -w 3 google.com 80 &> /dev/null && echo "Online" || echo "Offline"
@nmische
nmische / storage.cf
Created January 8, 2015 21:17
Storage CFEngine Example
bundle agent netapp_nfs(server, source) {
storage:
"/data"
mount => netapp_mount($(server), $(source)),
classes => classes_generic("netapp_nfs");
}
body mount netapp_mount(server, source) {
mount_type => "nfs";
mount_server => "$(server)";
wrench
hosts
-i --include-context comma delimited string of regular expression strings
-x --exclude-context comma delimited string of regular expression strings
-d --data-centers list of datacenters
"datacenter ip hostname"