Skip to content

Instantly share code, notes, and snippets.

View meineerde's full-sized avatar

Holger Just meineerde

View GitHub Profile
class NodeUpdateFromFile < ::Chef::Knife
deps do
require "chef/node"
require "chef/json_compat"
require "chef/knife/core/object_loader"
end
banner "knife node update from file FILE (options)"
def loader
module Foo
def foo; end
end
module Bar
def bar; end
end
class Baz
include Foo
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
map '/redmine' do
run RedmineApp::Application
end
@meineerde
meineerde / default.rb
Last active December 15, 2015 16:39
Chef: download a gem file and install it during compile phase.
chef_gem "my_gem"
source "#{Chef::Config[:file_cache_path]}/my.gem"
# only do anything if we are notified
action :nothing
end
remote_file "#{Chef::Config[:file_cache_path]}/my.gem" do
source "http://example.com/my.gem"
checksum "deadbeefdeadbeefdeadbeef"
%{IP:client_ip}:%{INT:client_port} \[%{HAPROXYDATE:accept_date}\] %{NOTSPACE:frontend_name} %{NOTSPACE:backend_name}/%{NOTSPACE:server_name} %{INT:time_request}/%{INT:time_queue}/%{INT:time_backend_connect}/%{INT:time_backend_response}/%{NOTSPACE:time_duration} %{INT:http_status_code} %{NOTSPACE:bytes_read} %{DATA:captured_request_cookie} %{DATA:captured_response_cookie} %{NOTSPACE:termination_state} %{INT:actconn}/%{INT:feconn}/%{INT:beconn}/%{INT:srvconn}/%{NOTSPACE:retries} %{INT:srv_queue}/%{INT:backend_queue} (\{%{HAPROXYCAPTUREDREQUESTHEADERS}\})?( )?(\{%{HAPROXYCAPTUREDRESPONSEHEADERS}\})?( )?"%{WORD:http_verb} %{URIPATHPARAM:http_request}( HTTP/%{NUMBER:http_version}")?
@meineerde
meineerde / nginx.conf
Created March 13, 2013 10:11
Check the Accept-Language Header to emulate part of Apache's content negotiation features. This is based on http://stackoverflow.com/questions/3657614/how-to-rewrite-location-in-nginx-depending-on-the-client-browsers-language
map $http_accept_language $lang {
default en;
~de de;
~en en;
}
location /foo/bar/baz/lang.js {
try_files $uri.$lang $uri;
}
@meineerde
meineerde / gist:4754693
Last active December 12, 2015 09:49
This fails only on Psych. On Syck, it works fine.
require 'yaml'
str = <<-EOF
- foo
2012-06-04 12:02:16.979
EOF
str.to_yaml
#
# TypeError: can't convert nil into Integer
# from /Users/hjust/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/psych/scalar_scanner.rb:111:in `utc'
diff --git a/db/migrate/20100714111653_build_initial_journals_for_acts_as_journalized.rb b/db/migrate/20100714111653_build_initial_journals_for_acts_as_journalized.rb
index 0e76661..80a9a60 100644
--- a/db/migrate/20100714111653_build_initial_journals_for_acts_as_journalized.rb
+++ b/db/migrate/20100714111653_build_initial_journals_for_acts_as_journalized.rb
@@ -50,6 +50,10 @@ class BuildInitialJournalsForActsAsJournalized < ActiveRecord::Migration
puts "ERROR: errors creating the initial journal for #{o.class.to_s}##{o.id.to_s}:"
puts " #{ex.message}"
end
+ rescue Exception => ex
+ puts "ERROR: errors creating the initial journal for #{o.class.to_s}##{o.id.to_s}:"
@meineerde
meineerde / logstash_elasticsearch_template
Created January 16, 2013 17:26
Elastissearch template for Logstash
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d '
{
"template": "logstash-*",
"settings": {
"index.cache.field.type" : "soft",
"index.refresh_interval" : "5s",
"index.store.compress.stored" : true,
"index.store.compress.tv" : true,
"index.query.default_field" : "@message"
},
@meineerde
meineerde / zmq_hello_world.rb
Created December 24, 2012 14:35
Send a simple ZMQ log entry
require 'zmq'
require 'logstash-event'
context = ZMQ::Context.new(1)
socket = context.socket(ZMQ::PUSH)
socket.connect("tcp://127.0.0.1:5555")
event = LogStash::Event.new(
"@message" => "Hello World"
).to_json