Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Fox danudey

View GitHub Profile
@danudey
danudey / update_classpath.groovy
Created Jan 4, 2021
How to use the Jenkins script console to add jars to your classpath without reloading
View update_classpath.groovy
// Import a class from outside of Jenkins, so that we can get
// The external class loader being used. In our case, we're using
// a class from the MySQL Connector/J library, which we have in
// file:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext
import com.mysql.jdbc.Util
// Get a reference to the global class laoder that was used
/// for that class
def loader = Util.class.getClassLoader()
@danudey
danudey / pythonsizes.py
Created Jul 11, 2019
An ugly little script to test the affect of various object allocation 'strategies' in Python
View pythonsizes.py
#!/usr/bin/env python
import sys
import time
from random import randint
import gc
import subprocess
import os
View gamblers_fallacy.py
#!/usr/bin/env python
from __future__ import division
import random
class Die(object):
"""The Gambler's Fallacy made manifest"""
def __init__(self, size):
self.size = size
self.state = [1 for i in xrange(size)]
@danudey
danudey / custom.vimrc
Created Dec 8, 2015
A simple custom vimrc
View custom.vimrc
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set smartcase " Do smart case matching
set incsearch " Incremental search
set mouse=a " Enable mouse usage (all modes)
set encoding=utf-8 " Set default file encoding
syntax on " Enable syntax highlighting
filetype plugin indent on " When loading a syntax plugin, load filetype indent rules
" These are default on our servers but not necessarily elsewhere
@danudey
danudey / 12lines.py
Last active Aug 29, 2015
Twelve lines of Christmas
View 12lines.py
#!/usr/bin/env python
gifts = ("partridge in a pear tree", "turtle doves", "french hens",
"calling birds", "golden rings", "geese-a-laying", "swans-a-swimming",
"maids-a-milking", "ladies dancing", "lords-a-leaping", "pipers piping",
"drummers drumming",)
for i in xrange(1,len(gifts)+1):
print "On the {} day of Christmas, my true love gave to me:".format(
str(i)+("th" if 4<=i%100<=20 else {1:"st",2:"nd",3:"rd"}.get(i%10, "th")))
for j, gift in list(enumerate(gifts[:i],1))[::-1]:
View gist:163505
>>> start = time.gmtime(time.time()-(3600*24*10))
>>> end = time.gmtime()
>>> downtimes = p.downtimesFor(p.checks[0],start,end)
>>> for downtime in downtimes:
... print downtime
...
{'duration': 0, 'to': (2009, 7, 28, 19, 0, 0.0), 'from': (2009, 7, 27, 19, 0, 0.0)}
{'duration': 0, 'to': (2009, 7, 29, 19, 0, 0.0), 'from': (2009, 7, 28, 19, 0, 0.0)}
{'duration': 0, 'to': (2009, 7, 30, 19, 0, 0.0), 'from': (2009, 7, 29, 19, 0, 0.0)}
{'duration': 0, 'to': (2009, 7, 31, 19, 0, 0.0), 'from': (2009, 7, 30, 19, 0, 0.0)}
View gist:163503
>>> for state in p.states:
... print state
...
{'checkName': 'webserver 1', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 19, 3, 13.0)}
{'checkName': 'webserver 1 ssl', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 19, 2, 59.0)}
{'checkName': 'imap server', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 19, 3, 27.0)}
{'checkName': 'incoming smtp', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 18, 58, 39.0)}
{'checkName': 'outgoing smtp', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 18, 57, 41.0)}
{'checkName': 'DNS server 1', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 19, 2, 38.0)}
{'checkName': 'DNS server 2', 'checkState': 'CHECK_UP', 'lastCheckTime': (2009, 8, 6, 19, 2, 39.0)}
View gist:163500
>>> import pingdom
>>> p = pingdom.Pingdom("user@example.com","your_password","your_api_key")
>>> p.locations
['Dallas, TX, USA', 'Dallas 2, TX, USA', 'Singapore', 'Sydney, Australia', 'Mumbai, India', 'Gloucester, England', 'Sacramento, CA, USA', 'Amsterdam, Holland', 'San Francisco, CA, USA', 'Vasteras, Sweden', 'Berkeley, CA, USA', 'Vasteras 2, Sweden', 'Dallas 3, TX, USA', 'Houston, TX, USA', 'Reading, England', 'Stockholm, Sweden', 'Stockholm 2, Sweden', 'Stockholm 3, Sweden', 'Houston 2, TX, USA', 'Montreal, Canada', 'London, UK', 'Dallas 4, TX', 'Herndon, VA', 'Paris, France', 'Houston 3, TX', 'Amsterdam 2, Netherlands', 'London 2, UK']
>>> p.checks
['webserver 1', 'webserver 1 ssl', 'imap server', 'incoming smtp', 'outgoing smtp', 'DNS server 1', 'DNS server 2', 'staging webserver', 'staging DB server', 'webserver 2', 'webserver 3']
@danudey
danudey / gist:151046
Created Jul 21, 2009
Crasher on Snow Leopard
View gist:151046
#!/usr/bin/env python
from SOAPpy import WSDL
WSDLFILE = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl'
class wsdl(object):
def __init__(self,apikey):
self._server = WSDL.Proxy(WSDLFILE)
f = wsdl("blah blah blah")
@danudey
danudey / gist:136801
Created Jun 26, 2009
Fantasy Balancer Config
View gist:136801
<Proxy balancer://fantasyappcluster>
BalancerMember http://fantasyweb1int retry=2
BalancerMember http://fantasyweb2int retry=2
BalancerMember http://fantasyweb3int retry=2
BalancerMember http://fantasyweb5int retry=2
BalancerMember http://fantasyweb6int retry=2
BalancerMember http://fantasyweb7int retry=2
</Proxy>