This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quote_argument(argument): | |
failure = ('\\', '"', '$', '`', ';') | |
for fail in failure: | |
if(argument.find(fail) != -1): | |
os._exit(255) | |
return argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from __future__ import with_statement | |
import os,stat, pickle | |
class PyCache: | |
file = "/tmp/pycache.tmp" | |
def __init__(self): pass | |
def retrieve(self): | |
try: | |
st = os.stat(self.file) | |
curtime = time.time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def allthethings(a, b=None): | |
if b == None: b = "things" | |
print "%s all the %s!" % (a,b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(id)initWithNameAndURLs:(NSString*)name xmlURL:(NSURL*)xURL ackURL:(NSURL*)aURL { | |
if ((self = [super init]) != NULL){ | |
displayName = [name retain]; | |
xmlURL = [xURL retain]; | |
ackURL = [aURL retain]; | |
return self; | |
} | |
return nil; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import random | |
>>> random.randint(1,100) | |
77 | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[18:47:57] twexler:~ $ python | |
Python 2.7.6 (default, May 17 2014, 00:21:47) | |
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.29.2)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import timeit | |
>>> timeit.timeit('import re;s="perceptes is gay";r=".*gay$";rr = re.compile(r);rr.match(s)') | |
2.5647430419921875 | |
>>> timeit.timeit('import re;s="perceptes is gay";r=".*gay$";re.match(r, s)') | |
2.603404998779297 | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
ec2 = boto.connect_ec2() | |
ec2_hosts = [ec2.get_all_tags(filters={'resource-id': i.id, 'key': 'Name'})[0].value for i in list(itertools.chain.from_iterable([res.instances for res in ec2.get_all_instances(filters={"tag-key": "server_env", "instance-state-code": 16})]))]ec2_hosts = [ec2.get_all_tags(filters={'resource-id': i.id, 'key': 'Name'})[0].value for i in list(itertools.chain.from_iterable([res.instances for res in ec2.get_all_instances(filters={"tag-key": "server_env", "instance-state-code": 16})]))]ec2_hosts = [ec2.get_all_tags(filters={'resource-id': i.id, 'key': 'Name'})[0].value for i in list(itertools.chain.from_iterable([res.instances for res in ec2.get_all_instances(filters={"tag-key": "server_env", "instance-state-code": 16})]))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto | |
import sys | |
#standard nagios exit codes | |
EXIT_OK = 0 | |
EXIT_WARN = 1 | |
EXIT_CRIT = 2 | |
EXIT_UNKN = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM litaio/ruby | |
MAINTAINER "Ted Wexler <ted@stuckinacan.com>" | |
RUN apt-get update | |
RUN apt-get install -y redis-server libssl-dev | |
RUN gem install lita | |
ADD conf/ /srv/lita-docker/ | |
WORKDIR /srv/lita-docker | |
RUN bundle install | |
CMD service redis-server start && bundle exec lita start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto.ec2 | |
import boto.vpc | |
def subnet_stats(subnet_id): | |
addresses = [] | |
ints = ec2.get_all_network_interfaces(filters={'subnet-id': subnet_id}) | |
for i in ints: | |
addresses.append(i.private_ip_address) | |
for addr in i.private_ip_addresses: | |
if addr.private_ip_address != i.private_ip_address: |
OlderNewer