Skip to content

Instantly share code, notes, and snippets.

View matsimitsu's full-sized avatar

Robert Beekman matsimitsu

View GitHub Profile
@matsimitsu
matsimitsu / sidekiq_max_memory_middleware.rb
Created September 9, 2016 07:49
Sidekiq Max Memory Middleware
# config/initializers/sidekiq_max_memory_middleware.rb
require 'socket'
class MaxMemoryMiddleware
attr_reader :active, :max_oom, :shutdown
cattr_reader :cached_mb, :last_checked_at, :hostname
def initialize
if ENV['MAX_SIDEKIQ_OOM']
@active = true
@matsimitsu
matsimitsu / appsignal_deployment.py
Created September 1, 2016 15:19
Appsignal Ansible Plugin
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2014 Robert Beekman <[email protected]>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
#!/usr/bin/env ruby
require 'rubygems'
require 'mqtt'
MQTT::Client.connect('192.168.0.20') do |client|
client.subscribe('components/plex/on', 'components/plex/off')
client.get do |topic,message|
case topic
when 'components/plex/on' then `open -a /Applications/Plex.app`
class @Appsignal
constructor: ->
@action = ""
@tags = {}
set_action: (action) ->
@action = action
tag_request: (tags) ->
@matsimitsu
matsimitsu / appsignal_deployment.py
Created February 4, 2016 17:49
Ansible script to notify AppSignal of new deploy
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2014 Robert Beekman <[email protected]>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@matsimitsu
matsimitsu / appsignal_deployment.py
Created February 4, 2016 17:48
Ansible script to notify AppSignal of new deploy
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2014 Robert Beekman <[email protected]>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@matsimitsu
matsimitsu / gist:ac18fb557d543b2ca56a
Created July 11, 2015 14:04
Matrioska init scropt
description "Matrioska"
start on runlevel [2]
stop on runlevel [016]
env GOMAXPROCS=4
export GOMAXPROCS
limit nofile 4096 8192
respawn # respawn the service if it dies
http {
proxy_cache_path /tmp/cache levels=1:2 keys_zone=photo-cache:8m max_size=5000m inactive=43829m;
proxy_cache_key $host$uri$is_args$args;
server {
proxy_cache photo-cache;
listen 80;
server_name cdn.matsimitsu.com;
access_log logs/cdn.access.log;
module Authenticator
class Authentication
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
if authenticated?
@app.call(env)
env['rack.input'].read(1)
env['rack.input'].rewind