Skip to content

Instantly share code, notes, and snippets.

trobrock / notify.rb
Created Jun 20, 2013
weechat ruby notifications, thanks @joelteon
View notify.rb
require 'ruby_gntp'
Weechat.register "notify", "otters", "0.2", "GPL", "notify: A real time notification system for weechat", "", ""
Settings = {
:show_hilights => "on",
:show_priv_msg => "on"
def notify_show data, buffer, empty, tagsn, isdisp, ishilight, prefix, msg
andrewkatz / .zshrc
Created May 6, 2013
Simple command for ssh'ing into rails hosts. Thanks to @trobrock for the ruby script.
View .zshrc
# Usage:
# rails_ssh release cron
# => ssh
hostname="$(ruby $HOME/Scripts/parse_cap_config.rb $2)"
ssh $username@$hostname
andreas / gist:5432990
Created Apr 22, 2013
Use [rblineprof]( for profiling Rails apps
View gist:5432990
class RBLineProfiler
WALL_TIME_LIMIT = 10e3 # ms
def initialize(app)
@app = app
def call(env)
result = nil
profile = lineprof(/./) { result = }
knuckolls / AAA-usage.txt
Last active Dec 15, 2015
General Vagrant configuration for berkshelf cookbooks that works with chef-solo or chef-client and grabs chef-client information from knife.rb.
View AAA-usage.txt
Gem versions are important due to dependency pinning problems w/ Berkshelf, Chef, and Vagrant
circa March 15th, 2013.
The older version of chef won't impact the version of chef that gets provisioned on your vagrant
box, it's just for loading the knife.rb configuration.
Use bundle exec if you want these things to operate together correctly.
$ bundle exec vagrant up solo
$ bundle exec berks upload
mudge / logstash.conf
Last active Apr 17, 2019
A grok pattern for Rails 3.2 logs for use with logstash. Assumes that you have a multiline filter to combine Rails logs into one line and only one worker is logging to a file (c.f.
View logstash.conf
multiline {
tags => ["rails"]
pattern => "^Started"
negate => true
what => "previous"
jbyck / gist:5036615
Created Feb 26, 2013
403 Error in Chef Run List
View gist:5036615
"exception": "Net::HTTPServerException: deploy_revision[wikiposit] (/var/chef/cache/cookbooks/application/providers/default.rb line 122) had an error: Net::HTTPServerException: template[/etc/unicorn/wikiposit.rb] (/var/chef/cache/cookbooks/unicorn/definitions/unicorn_config.rb line 38) had an error: Net::HTTPServerException: 403 \"Forbidden\"",
"backtrace": [
"/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2632:in `error!'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:259:in `block in streaming_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:280:in `retriable_rest_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:236:in `streaming_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:97:in `get'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook/remote_file_vendor.rb:63:in `get_filename'",
View vagrant-cache.rb
config.vm.provision :shell do |shell|
shell.inline = "apt-get update; apt-get install -y apt-cacher-ng bindfs; service apt-cacher-ng stop; bindfs --mirror=apt-cacher-ng:@apt-cacher-ng /vagrant/cache /var/cache/apt-cacher-ng; echo 'Acquire::http { Proxy \"\"; };' > /etc/apt/apt.conf.d/01proxy; echo ' \"DIRECT\";' >> /etc/apt/apt.conf.d/01proxy; service apt-cacher-ng start"
kennethkalmer / deploy.rb
Created Oct 4, 2012
Capistrano config for near-zero downtime deployments
View deploy.rb
# Based heavily on the deployment recipe dicussed in the article at
# but tweaked to fit our setup...
# Multistage setup
set :stages, %w(production staging)
juanje / gist:3797297
Created Sep 28, 2012
Mount apt cache of a Vagrant box in the host to spin up the packages installation
View gist:3797297

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir ='cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
asenchi /
Created Sep 20, 2012 — forked from jordansissel/
parsing mysql's bullshit query log format with logstash

parsing mysql query logs with logstash

The problem is that some lines in the file are missing timestamps when they aren't continuations of any previous line. It's dumb, really.

The mysql query log is seriously bullshit format, but nothing logstash can't unscrew.

The main goal here is to show how we can fix the 'missing timestamp' problem.

% ruby bin/logstash agent -e '