Skip to content

Instantly share code, notes, and snippets.

View mrdavidlaing's full-sized avatar
🤘

David Laing mrdavidlaing

🤘
View GitHub Profile
@mrdavidlaing
mrdavidlaing / CreditCard-complex-functional.js
Created April 16, 2011 21:27
A simple example of the "switch" code smell
function CreditCard(http) {
this.process = function(cardType, cardNumber) {
var cardProcessor = {
"VISA": this.processVisa,
"MASTERCARD": this.processMasterCard,
"AMEX": this.processAmex
};
cardProcessor[cardType](cardNumber);
};
this.processVisa = function(cardNumber) {
@mrdavidlaing
mrdavidlaing / EC2-2013-02-01.yml
Created January 20, 2014 13:42
Add support for spot instances to BOSH AWS CPI
# Replace: /var/vcap/packages/director/gem_home/gems/aws-sdk-1.8.5/lib/aws/api_config/EC2-2013-02-01.yml
#
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
@mrdavidlaing
mrdavidlaing / Price-Latency-Kibana-dashboard.json
Last active December 28, 2015 02:39
Price Latency Kibana dashboard
{
"title": "Price Latency",
"services": {
"query": {
"idQueue": [],
"list": {
"0": {
"query": "*",
"alias": "All",
"color": "#DEDAF7",
@mrdavidlaing
mrdavidlaing / gist:4609876
Created January 23, 2013 16:58
Using latest http://github.com/zephirworks/cloudfoundry-mongodb-service-cookbook bundle exec kitchen test --platform ubuntu-12.04 gives: ``` [Wed, 23 Jan 2013 16:38:11 +0000] FATAL: NoMethodError: undefined method `notifies' for "cloudfoundry_source[cloud_controller]":String /Users/mrdavidlaing/.rvm/gems/ruby-1.9.3-p0/gems/vagrant-1.0.5/lib/vagr…
[16:32][mrdavidlaing@maccy001:~/Projects/zephirworks/cloudfoundry-mongodb-service-cookbook(master)]$ rm -rf /Users/mrdavidlaing/Projects/zephirwor/cloudfoundry-mongodb-service-cookbook/test/kitchen/.kitchen/
[16:32][mrdavidlaing@maccy001:~/Projects/zephirworks/cloudfoundry-mongodb-service-cookbook(master)]$ bundle exec kitchen test --platform ubuntu-12.04
checking cloudfoundry-mongodb-service
WARNING: No cookbooks to test in /Users/mrdavidlaing/Projects/zephirworks/cloudfoundry-mongodb-service-cookbook/.. - is your cookbook path misconfigured?
Assembling required cookbooks at [/Users/mrdavidlaing/Projects/zephirworks/cloudfoundry-mongodb-service-cookbook/test/kitchen/.kitchen/cookbooks].
[ubuntu-12.04] Importing base box 'opscode-ubuntu-12.04'...
[ubuntu-12.04] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
@mrdavidlaing
mrdavidlaing / microcf.app.rb.patch
Created January 23, 2013 15:57
w.r.t: http://help.ironfoundry.org/tickets/56610 Changes to .rb files in c:\IronFoundry\setup to get the IronFoundry DEA to connect to the latest Micro Cloud Foundry (v119).
--- /var/vcap/packages/cloud_controller/cloud_controller/app/models/app.rb 2012-01-30 20:24:18.000000000 +0000
+++ /var/vcap/packages/cloud_controller/cloud_controller/app/models/app_new.rb 2012-03-13 23:24:19.214790495 +0000
@@ -23,8 +23,8 @@
AppStates = %w[STOPPED STARTED]
PackageStates = %w[PENDING STAGED FAILED]
- Runtimes = %w[ruby18 ruby19 java node node06 php erlangR14B02 python26]
- Frameworks = %w[sinatra rails3 java_web spring grails node php otp_rebar lift wsgi django unknown]
+ Runtimes = %w[ruby18 ruby19 java node php erlangR14B02 python26 aspdotnet40]
+ Frameworks = %w[sinatra rails3 java_web spring grails node php otp_rebar lift aspdotnet wsgi django unknown]
List<Market> markets = api.GetMarkets(MarketType.FX);
/*
* Using a primitive for loop
* - Opportunity for off by one errors
* - Syntax noise - declaring an empty List, thinking about i & markets[i]
*/
List<Market> openMarkets = new List<Market>();
for(int i=0; i < markets.Count; i++)
{
@mrdavidlaing
mrdavidlaing / gist:9d8d934372cba968169a
Created June 11, 2015 09:19
ELK-for-PCF UAA client
--- /dev/null
+++ b/templates/logsearch_for_cloudfoundry.yml
@@ -0,0 +1,17 @@
+properties:
+ uaa:
+ clients:
+ elk-for-pcf:
+ authorities: uaa.none
+ authorized-grant-types: authorization_code,refresh_token
+ override: true
@mrdavidlaing
mrdavidlaing / Instructions.md
Created March 31, 2015 13:50
CF v205 + Logsearch v19 + logsearch-for-cloudfoundry-boshrelease
@mrdavidlaing
mrdavidlaing / README.md
Last active August 29, 2015 14:08
Ship wp-stream data to ingestor.meta.logsearch.io

##Install After installing the WP-Stream plugin tested with - this version, replace wp-content/plugins/stream/classes/class-wp-stream-api.php with the modified file below to have WP-Stream also ship its data to ingestor.meta.logsearch.io so it can be seen in the WP-Stream dashboard

See diff for details of the changes; basically one function and one call to that function

##Firewall rules The source IP of the WP host needs to be added to the [TrustedIngestion Security Group](https://github.com/cityindex/labs-operations/bl