Skip to content

Instantly share code, notes, and snippets.

View danudey's full-sized avatar
🐪

Daniel Fox danudey

🐪
View GitHub Profile
@danudey
danudey / update_classpath.groovy
Created January 4, 2021 22:58
How to use the Jenkins script console to add jars to your classpath without reloading
// 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 July 11, 2019 18:43
An ugly little script to test the affect of various object allocation 'strategies' in Python
#!/usr/bin/env python
import sys
import time
from random import randint
import gc
import subprocess
import os
#!/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 December 8, 2015 22:53
A simple 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
>>> 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)}
>>> 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']
>>> 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)}
@danudey
danudey / gist:151046
Created July 21, 2009 01:37
Crasher on Snow Leopard
#!/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 June 26, 2009 22:47
Fantasy Balancer Config
<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>
09-06-11 2:25:33 PM Nambu[26269] Failed to call designated initializer on NSManagedObject class 'NBDataManager'
09-06-11 2:25:33 PM GrowlHelperApp[244] Auto-discovered registration ticket in Nambu (located at /Applications/Nambu.app)
09-06-11 2:25:33 PM Nambu[26269] change: <NBTwitterMessageListViewController: 0x455e20>
09-06-11 2:25:33 PM Nambu[26269] NSExceptionHandler has recorded the following exception:
NSInvalidArgumentException -- Unlocking Focus on wrong view (<NSClipView: 0x362bd0>), expected <NBTCView: 0x364860>
Stack trace: 0x93368d24 0x988d90fd 0x95e83478 0x95ecf43a 0x91605414 0x91609b6c 0x916cbca1 0x916cb06a 0x91723429 0x91661b97 0x9166177f 0x91661624 0x915ad017 0x915b895a 0x915b8605 0x6b877 0x6b5d7 0x6a3f1 0x91601d22 0x916020ba 0x916020ba 0x916020ba 0x916020ba 0x916020ba 0x916020ba 0x91704bc3 0x91be19a0 0x91be6685 0x915ff1b3 0x915ff631 0x915ff631 0x915ff631 0x915ff631 0x915ff631 0x915fd78b 0x916f59b4 0x915f9936 0x915f70bf 0x9161a895 0x91cc83be 0x935be316