Skip to content

Instantly share code, notes, and snippets.

View mbrevoort's full-sized avatar

Mike Brevoort mbrevoort

View GitHub Profile
@mbrevoort
mbrevoort / log.go
Last active October 24, 2022 13:10
Adding caller function, filename and line number to logrus log entries
package utils
import (
"runtime"
"github.com/Sirupsen/logrus"
)
// DecorateRuntimeContext appends line, file and function context to the logger
func DecorateRuntimeContext(logger *logrus.Entry) *logrus.Entry {
@mbrevoort
mbrevoort / LogstashUDP.js
Created June 24, 2013 06:55
A simple Logstash UDP logger for Winston.
// Really simple Winston Logstash UDP Logger
var dgram = require('dgram'),
util = require('util'),
os = require('os'),
winston = require('winston');
var LogstashUDP = module.exports = function (options) {
winston.Transport.call(this, options);
options = options || {};
@mbrevoort
mbrevoort / message-builder-example.js
Last active January 9, 2017 03:22
Slack Message Builder Example
const smb = require('slack-message-builder')
smb()
.text("Would you like to play a game?")
.attachment()
.text("Choose a game to play")
.fallback("You are unable to choose a game")
.callbackId("wopr_game")
.color("#3AA3E3")
.action()
.name("chess")
@mbrevoort
mbrevoort / bot.yml
Last active September 8, 2016 04:26
Sample Beep Boop bot.yml
name: Domination Bot
description: A Bot to rule them all
avatar: avatar.jpg
config:
- name: AWS_REGION
friendly_name: AWS Region
info: Region of deployment (e.g. us-eas-1)
default: us-east-1
type: text
global: true
bb-slackaccesstoken // Slack user token for user who added your Slack App
bb-slackuserid // User Id of the user who added your Slack App
bb-slackbotaccesstoken // Bot access token if the app uses a bot
bb-slackbotuserid // User Id of bot user if the app uses a bot
bb-slackbotusername // Username of the bot user
bb-slackteamid // Slack team Id
bb-slackteamname // Slack team name
bb-slackteamdomain // Slack Domain name of the team
// convo handlers are registered with unique strings
const handleGoodDay = 'handleGoodDay'
// handle any DM that starts with 'hi'
slapp.message('^hi', 'direct_message', (msg) => {
// Ask how they are and route next message to handleGoodDay handler
msg.say('Are you having a good day?').route(handleGoodDay)
})
// register handleGoodDay handler
@mbrevoort
mbrevoort / bot.js
Created April 1, 2016 17:48
beepboop-botkit oneliner
var Botkit = require('botkit')
var controller = Botkit.slackbot()
require('beepboop-botkit').start(controller)
controller.hears('hello', ['direct_message', 'direct_mention', 'mention'], function (bot, message) {
bot.reply(message, 'Hello!')
});
#!/bin/bash
# takes a directory as the first argument and loops through all of the jpg
# images watermarking them into a watermark folder within that directory.
DIRECTORY=$1
WATERMARK=$2
mkdir -p $1/watermark
for filename in $DIRECTORY/*
do
@mbrevoort
mbrevoort / witbot.js
Created December 28, 2015 03:07
witbot botkit sample
var controller = Botkit.slackbot({ debug: false })
controller.hears('.*', 'direct_message,direct_mention', function (bot, message) {
witbot.process(message.text, bot, message)
})
witbot.hears('hello', 0.5, function (bot, message, outcome) {
bot.reply(message, 'Hello to you as well!')
})
SyntaxError: Unexpected token [
at Object.parse (native)
at parse (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/crdt/node_modules/scuttlebutt/node_modules/stream-serializer/index.js:20:17)
at Stream.onData [as write] (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/crdt/node_modules/scuttlebutt/node_modules/stream-serializer/index.js:34:7)
at Stream.write (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/lib/seaport.js:199:11)
at Stream.stream.write (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/through/index.js:25:11)
at Stream.ondata (stream.js:51:26)
at Stream.EventEmitter.emit (events.js:117:20)
at Stream.stream.emit (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/crdt/node_modules/scuttlebutt/node_modules/stream-serializer/index.js:58:33)
at Stream.st