Skip to content

Instantly share code, notes, and snippets.

View seanhandley's full-sized avatar
🧀
Eating cheese

Sean Handley seanhandley

🧀
Eating cheese
View GitHub Profile
15:01 ~/src/datacentred/stronghold 2.1.2 (testing)
$ cap staging deploy
DEBUG[676eda95] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.1.2 ] on rails01.sal01.datacentred.co.uk
DEBUG[676eda95] Command: [ ! -d ~/.rbenv/versions/2.1.2 ]
DEBUG[676eda95] Finished in 0.317 seconds with exit status 1 (failed).
INFO[1ad89142] Running /usr/bin/env mkdir -p /tmp/stronghold/ on rails01.sal01.datacentred.co.uk
DEBUG[1ad89142] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 /usr/bin/env mkdir -p /tmp/stronghold/ )
INFO[1ad89142] Finished in 0.015 seconds with exit status 0 (successful).
DEBUGUploading /tmp/stronghold/git-ssh.sh 0.0%
INFOUploading /tmp/stronghold/git-ssh.sh 100.0%
require 'redcarpet'
module TicketsHelper
def markdown(text)
render_options = {
# will remove from the output HTML tags inputted by user
filter_html: true,
# will insert <br /> tags in paragraphs where are newlines
# (ignored by default)
hard_wrap: true,
module.exports = (robot) ->
robot.hear /bork/i, (msg) ->
msg.send "bork bork bork!"
robot.respond /icinga status/i, (msg) ->
nagios_api_state(msg)
nagios_api_state = (msg) ->
reply = []
headers = {
'Content-Type': 'application/json',
'Content-Length': 0
}
options = {
robot.respond /icinga downtime (\S+)$/i, (msg) ->
name = msg.message.user.name.toLowerCase()
host = msg.match[1].trim().toLowerCase()
nagios_api_call 'on', {host: host, duration: 7200, author: name}, msg
cronJob = require('cron').CronJob
tz = 'Europe/London'
new cronJob('0 30 9 * * 1-5', (() -> workdaysNineThirtyAm(robot)), null, true, tz)
workdaysNineThirtyAm = (robot) ->
nagios_api_state({
reply: (text) ->
robot.messageRoom 'room@conf.hipchat.com', "Good morning! Time for an Icinga update."
robot.messageRoom 'room@conf.hipchat.com', text
})
things.each do |thing|
Thread.new do
SlowApi.send(thing)
end
end.each(&:join)
@seanhandley
seanhandley / cheryl.rb
Last active August 29, 2015 14:20
Cheryl's Birthday Explained With Ruby
DATES = [
"May 15", "May 16", "May 19",
"June 17", "June 18",
"July 14", "July 16",
"August 14", "August 15", "August 17"
]
def month(date); date.split[0]; end
def day(date); date.split[1]; end
$ ping google.com
PING google.com (216.58.210.14): 56 data bytes
64 bytes from 216.58.210.14: icmp_seq=0 ttl=56 time=32.953 ms
64 bytes from 216.58.210.14: icmp_seq=1 ttl=56 time=24.376 ms
Request timeout for icmp_seq 2
64 bytes from 216.58.210.14: icmp_seq=3 ttl=56 time=134.158 ms
64 bytes from 216.58.210.14: icmp_seq=4 ttl=56 time=746.034 ms
64 bytes from 216.58.210.14: icmp_seq=5 ttl=56 time=186.765 ms
64 bytes from 216.58.210.14: icmp_seq=6 ttl=56 time=197.410 ms
64 bytes from 216.58.210.14: icmp_seq=7 ttl=56 time=291.883 ms