Skip to content

Instantly share code, notes, and snippets.

View rosconap's full-sized avatar

RN rosconap

  • Thuisbioscoop BV
  • Amsterdam, Netherlands
View GitHub Profile
@rosconap
rosconap / processor.go
Last active August 7, 2023 22:02
Proccess mapper tool
// So this code is processing a channel of stuff with uniq id's. Pretend we have incomming stuffpackets
// from a network connection that are unsorted and need to be processed per id. The stuff processor will
// put these packets in their own channel to be processed with their own routine in thehandlymystuff
// function. It looks up the corresponding channel in a map. If the channel does not exists, it will be
// created and directly used for the first itteration and so on.
// StuffProcessor ...
type StuffProcessor struct {
StuffChan chan Stuff // ingest unsorted stuff packets from channel.
StuffDispatch map[string]chan Stuff // each stuff stream mapped id channel.
@rosconap
rosconap / pre-commit
Created November 13, 2016 11:55
Spellcheck your markdown files with a pre-commit hook
#!/usr/bin/env bash
# Author: Rosco Nap / cloudrkt.com
# This script is used to check files with the .md extention (markdown) for spelling errors.
# It will run each .md file through aspell and returns an exit code other then 0 when it matches.
# Where are the markdown files located?
SEARCH_DIR="content/"
# Set some fancy colors to indicate errors and wrongly spelled words.
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
output = {}
s_json = JSON.parse(Net::HTTP.get_response(URI.parse('http://localhost:8500/v1/catalog/services')).body)
services = s_json.keys.reject{|k| k == 'consul'}
services.each do |srv|
# Description:
# This script receives pages in the formats
# /usr/bin/curl -d host="$HOSTALIAS$" -d output="$SERVICEOUTPUT$" -d description="$SERVICEDESC$" -d type=service -d notificationtype="$NOTIFICATIONTYPE$ -d state="$SERVICESTATE$" $CONTACTADDRESS1$
# /usr/bin/curl -d host="$HOSTNAME$" -d output="$HOSTOUTPUT$" -d type=host -d notificationtype="$NOTIFICATIONTYPE$" -d state="$HOSTSTATE$" $CONTACTADDRESS1$
#
# Based on a gist by oremj (https://gist.github.com/oremj/3702073)
#
# Configuration:
# HUBOT_NAGIOS_URL - https://<user>:<password>@nagios.example.com/cgi-bin/nagios3
#