Skip to content

Instantly share code, notes, and snippets.

View JayH5's full-sized avatar

Jamie Hewland JayH5

  • Apple
  • London, UK
View GitHub Profile
@JayH5
JayH5 / threadpool.rb
Created November 26, 2013 14:37
Simple Ruby threadpool
require 'set'
require 'thread'
module Prod
# A simple thread pool for running N parallel jobs.
#
# pool = ThreadPool.new(5)
# 20.times do
# pool.next_thread{ sleep 2 }
@JayH5
JayH5 / gist:9208926
Created February 25, 2014 13:41
Stripy Processing example
int WIDTH = 800;
int HEIGHT = 400;
int ROWS = 10;
int ROW_HEIGHT = 40;
int STROKE_WIDTH = 10;
void setup() {
// This code happens once, right when our sketch is launched
size(WIDTH, HEIGHT);
background(255);
@JayH5
JayH5 / helpers.py
Created July 1, 2015 13:35
MessageSequenceHelper
from datetime import datetime, timedelta
from twisted.internet.defer import inlineCallbacks, returnValue
from zope.interface import implements
from vumi.tests.helpers import IHelper
from vumi.message import format_vumi_date
class MessageSequenceHelper(object):
@JayH5
JayH5 / test_test_helpers.py
Created July 1, 2015 15:01
MessageSequenceHelper test
from datetime import timedelta
from twisted.internet.defer import inlineCallbacks
from vumi.message import parse_vumi_date
from vumi.tests.helpers import VumiTestCase, MessageHelper
from vumi_message_store.tests.helpers import MessageSequenceHelper
class FakeBackend(object):
@JayH5
JayH5 / gist:b9f964796dab4a49d40d
Created July 6, 2015 12:11
pypy py.test loop on fail syscall failure
_ ERROR at teardown of TestMessageExportResource.test_disconnect_kills_server __
Traceback (most recent call last):
File "/home/vagrant/Envs/vumi-msg-store-pypy/site-packages/twisted/trial/_asynctest.py", line 209, in _cleanUp
clean = util._Janitor(self, result).postCaseCleanup()
File "/home/vagrant/Envs/vumi-msg-store-pypy/site-packages/twisted/trial/util.py", line 98, in postCaseCleanup
calls = self._cleanPending()
File "/home/vagrant/Envs/vumi-msg-store-pypy/site-packages/twisted/internet/utils.py", line 218, in warningSuppressingWrapper
return runWithWarningsSuppressed(suppressedWarnings, f, *a, **kw)
File "/home/vagrant/Envs/vumi-msg-store-pypy/site-packages/twisted/internet/utils.py", line 201, in runWithWarningsSuppressed
reraise(exc_info[1], exc_info[2])
@JayH5
JayH5 / test_model.py
Created July 8, 2015 12:26
Test for page length
@Manager.calls_manager
def test_index_keys_page_length(self):
indexed_model = self.manager.proxy(IndexedModel)
yield indexed_model("foo1", a=1, b=u"one").save()
yield indexed_model("foo2", a=1, b=u"one").save()
yield indexed_model("foo3", a=1, b=None).save()
keys1 = yield indexed_model.index_keys_page('a', 1, max_results=2)
self.assertEqual(len(keys1), 2)
#! /usr/bin/python
# Check that all the apps in Marathon are stored as services in Consul.
import requests
HOST = '10.1.1.13'
CONSUL_PORT = 8500
MARATHON_PORT = 8080
def get_marathon_app_ids(host, port):
#! /usr/bin/python
# Sanity check that consul-template is writing the services in Consul to the
# nginx config file.
import requests
HOST = '10.1.1.13'
CONSUL_PORT = 8500
NGINX_CONFIG_PATH = '/etc/nginx/sites-enabled/consul_template.conf'
diff --git a/manifests/config.pp b/manifests/config.pp
index 7fbe41a..a7dc508 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -29,21 +29,23 @@ class marathon::config(
}
if ($mesos_auth_principal != undef and $mesos_auth_secret != undef) {
- $secret_options = {
- 'mesos_authentication_principal' => $mesos_auth_principal,
@JayH5
JayH5 / test_server.py
Created February 22, 2016 09:25
txfake server testing
import json
import treq
from twisted.internet.defer import inlineCallbacks
from twisted.trial.unittest import TestCase
from twisted.web.client import ProxyAgent
from twisted.web.server import Site
from txfake import FakeServer