Skip to content

Instantly share code, notes, and snippets.

View danryan's full-sized avatar
🔥

Dan Ryan danryan

🔥
View GitHub Profile
@mudge
mudge / logstash.conf
Last active April 17, 2019 07:58
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. https://gist.github.com/mudge/5063930).
multiline {
tags => ["rails"]
pattern => "^Started"
negate => true
what => "previous"
}
@jbyck
jbyck / gist:5036615
Created February 26, 2013 07:19
403 Error in Chef Run List
"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'",
"/opt/chef/embedded/lib/ruby/gems
if ENV['ES_CACHE']
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 \"http://127.0.0.1:3142\"; };' > /etc/apt/apt.conf.d/01proxy; echo 'Acquire::https::Proxy::apt.repo.enstratus.com \"DIRECT\";' >> /etc/apt/apt.conf.d/01proxy; service apt-cacher-ng start"
end
end
@kennethkalmer
kennethkalmer / deploy.rb
Created October 4, 2012 10:16
Capistrano config for near-zero downtime deployments
#
# Based heavily on the deployment recipe dicussed in the article at
# http://ariejan.net/2011/09/14/lighting-fast-zero-downtime-deployments-with-git-capistrano-nginx-and-unicorn
# but tweaked to fit our setup...
#
# NO WARRANTY, IMPLIED OR OTHERWISE
#
# Multistage setup
set :stages, %w(production staging)
@juanje
juanje / gist:3797297
Created September 28, 2012 00:38
Mount apt cache of a Vagrant box in the host to spin up the packages installation

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 = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
 cache_dir
@asenchi
asenchi / logstash-mysql-query-parse.md
Created September 20, 2012 01:06 — forked from jordansissel/logstash-mysql-query-parse.md
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 '

node "master" do
action :provision
platform MasterMind::Platform::Vagrant
# needed for aws, rackspace, etc. but not vagrant
# credentials aws_credentials_hash
definition "/home/foo/vms/Vagrantfile"
end
node "standby" do
action :provision
@marcomd
marcomd / gist:3129118
Created July 17, 2012 12:18
Authenticate your API with devise, token by header
#Session controller provides a token
#/controllers/api/sessions_controller.rb
class Api::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :except => [:create]
before_filter :ensure_params_exist, :except => [:destroy]
respond_to :json
def create
resource = User.find_for_database_authentication(:email => params[:user_login][:email])
return invalid_login_attempt unless resource
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 19, 2025 17:31 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@MicahElliott
MicahElliott / rbenv-howto.md
Created April 17, 2012 18:11
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev