Skip to content

Instantly share code, notes, and snippets.

View remie's full-sized avatar

Remie Bolte remie

View GitHub Profile
@remie
remie / DD-669.markdown
Created January 8, 2012 20:28
Design document for Symphony Issue 669

Design document for Symphony Issue 669

This document is created to list all options for solving Symphony Issue 669. The goal is to find a way to make the config.php file aware of the environment on which it runs and to make it sharable between developers. Most of the configuration settings are the same for all environments, so only a subset needs to be changeable to deal with the differences between multiple local environments during development and releasing to T/A/P.

Requirements

  1. Allow environment specific configuration
  2. Allow configuration to be shared between developers
  3. require minimal core changes
  4. require no breaking changes to the Configuration class
@remie
remie / rct-generator.html
Last active August 29, 2015 14:17
Randomized Controlled Trial (RCT) research number generator in JavaScript
<!--
================================================================================================
Randomized Controlled Trial (RCT) research number generator in JavaScript
Generates a set of research numbers equally devided between two groups
(intervention and control group). Uses block randomization with variable
block sizes, random permutation loosly based on Knuth shuffle and random
group type selection.
Depends on Math.Random() to generate the random numbers.
#!/usr/bin/env node
###########################################################################################
# Dynamic inventory for Ansible with DNS
# Author Remie Bolte (https://nl.linkedin.com/in/remiebolte)
#
# This NodeJS script generates a dynamic inventory based on DNS TXT records.
#
# If you use the “--inventory” switch when calling Ansible, you can provide the
# path to a directory which includes inventory files. Ansible will automtically
import { default as Localhost } from './hosts/Localhost';
import { default as DefaultTimeperiod } from './timeperiods/DefaultTimeperiod';
import { Nagios, Include, NagiosCfg, HostObj, HostGroupObj } from '@remie/nagios-cli';
// Nagios configuration, CGI & Resources
import { cgi } from './cgi.cfg';
import { nagios as cfg } from './nagios.cfg';
import { resources } from './resources.cfg';
log_file=/usr/local/nagios/var/nagios.log
object_cache_file=/usr/local/nagios/var/objects.cache
precached_object_file=/usr/local/nagios/var/objects.precache
status_file=/usr/local/nagios/var/status.dat
status_update_interval=10
nagios_user=nagios
nagios_group=nagios
... 100+ more lines
import { Host, HostObj, ServiceObj, ContactObj, ContactGroupObj, Include, Check } from '@remie/nagios-cli';
import { SSH } from '../checks/SSH';
import { Ping } from '../checks/Ping';
import { HTTP } from '../checks/HTTP';
import { SI , SIOptions, SIType } from '../checks/SI';
import { Service } from '../services/Service';
import DefaultContact from '../contacts/DefaultContact';
import DefaultTimeperiod from '../timeperiods/DefaultTimeperiod';
import { Check, CheckResult, NagiosResult } from '@remie/nagios-cli';
import axios from 'axios';
export class HTTP implements Check {
private host: string;
constructor(host: string) {
this.host = host;
}
import BaseService from './BaseService';
import { Use, ServiceObj, Check } from '@remie/nagios-cli';
@Use(BaseService)
export class Service extends ServiceObj {
private _check: Check;
constructor(description: string, check: Check) {
super(description);
import { Service, ServiceObj } from '@remie/nagios-cli';
@Service({
name: 'generic-service',
service_description: 'Generic Service',
active_checks_enabled: true,
passive_checks_enabled: true,
obsess_over_service: true,
check_freshness: false,
const axios = require('axios');
// check(host, path, expectedRedirect, statusCode)
// {host}: the host header of the request (without http(s)://)
// {path}: the path after the host
// {expectedRedirect}: the full URL of the Location header that should be returned
// {statusCode}: the expected status code (optional, defaults to 302)
const check = function(host, path, expectedRedirect, statusCode) {
path = path || '';