Skip to content

Instantly share code, notes, and snippets.

Daniel Fox danudey

Block or report user

Report or block danudey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
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']
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: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)}
@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>
View gist:128249
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
View gist:127532
# $Id: Portfile 52077 2009-06-09 19:30:08Z blb@macports.org $
PortSystem 1.0
name libmemcached
version 0.30
description libmemcached is a C and C++ client library to the memcached server
long_description libmemcached is a C and C++ client library for memcached. \
It has been designed to be light on memory usage, thread safe, \
and provide full access to server side methods.
You can’t perform that action at this time.