Skip to content

Instantly share code, notes, and snippets.

View meineerde's full-sized avatar

Holger Just meineerde

View GitHub Profile
@meineerde
meineerde / haproxy.cfg
Last active August 29, 2015 13:55
Example HAProxy configuration
frontend http
bind :80
mode http
option http-server-close
# send request to the main backend until it has 50 parallel request
use_backend main if { be_conn(main) le 50 }
# send further requests to the others backend
use_backend others if { be_conn(main) gt 50 }
@meineerde
meineerde / http_client.rb
Created June 23, 2014 14:47
But this file into one of your cookbooks preferably one loaded rather early in the `libraries` directory, i.e. into `my_cookbook/libraries/http_client.rb`. This applies the patch in https://github.com/opscode/chef/pull/1471 on the fly.
require 'chef/http/http_request'
# Remove this patch once there is a released chef version which includes
# https://github.com/opscode/chef/pull/1471
class Chef
class HTTP
class HTTPRequest
URI_SCHEME_DEFAULT_PORT ||= { 'http' => 80, 'https' => 443 }.freeze
@meineerde
meineerde / gist:559348515ba8daba6eb1
Created November 14, 2014 15:58
HAProxy redirect from /a/(.*) to /b/\1
http-request del-header X-Redirect-To
http-request set-header X-Redirect-To %[req.uri] if { path_beg /a }
http-request replace-header X-Redirect-To /a/(.*) /b/\1 if { hdr_cnt(X-Redirect-To) gt 0 }
http-request redirect location %[req.hdr(X-Redirect-To)] if { hdr_cnt(X-Redirect-To) gt 0 }
@meineerde
meineerde / mkpasswd.py
Created November 24, 2014 17:39
mkpasswd in python
#!/usr/bin/env python
# Generate a new SHA512 shadow password hash from a given password
# Based on https://github.com/antoncohen/mksha
import getpass
import sys
# To install this library, use one of these:
# pip install passlib
@meineerde
meineerde / warmup-001.rb
Created January 12, 2015 18:44
ruby-colearning-warmup
#!/usr/bin/env ruby
KNOWLEDGE = {
"gustavo" => ["learing ruby", "drinking beer", "sitting at the Spree"],
"duilio" => ["teaching ruby", "sunbathing", "doing stuff"],
"max" => ["eating great food", "another thing", "a third"]
}
def get_knowledge(person)
favorite_things = KNOWLEDGE[person]
@meineerde
meineerde / haproxy.cfg
Last active August 29, 2015 14:13
HaProxy speedy split
frontend ssl
bind :443 ssl crt /etc/haproxy/crts npn spdy/2,http/1.1
mode tcp
use_backend speedy if { ssl_fc_npn -m str spdy/2 }
default_backend http
frontend http_internal
bind 127.0.0.1:8443
begin
puts "Hello World"
raise StandardError, '(╯°□°)╯︵ ┻━┻'
rescue => ಠ_ಠ
puts ಠ_ಠ.message
puts ಠ_ಠ.backtrace.join('\n')
end
# make sure to require this in your init.rb
class MyPluginIssueHook < Redmine::Hook::ViewListener
# this just renders the partial
# the contents of the context ahsh is made available as local variables to the partial
render_on :view_issues_form_details_bottom, :partial => 'hooks/view_issues_form_details_bottom'
def controller_account_success_authentication_after(context={ })
# do something here
<IfModule mod_passenger.c>
PassengerRoot /var/ruby/1.8/gem_home/gems/passenger-2.2.11
PassengerRuby /usr/ruby/1.8/bin/ruby
PassengerEnabled on
PassengerUserSwitching on
PassengerDefaultUser passenger
</IfModule>
# First run script/generate redmine_plugin add_link
# Put in vendor/plugins/redmine_add_link/init.rb
require 'redmine'
Redmine::Plugin.register :redmine_rt_link do
name 'Redmine Add Link'
author 'Holger Just'
url 'http://dev.holgerjust.de/projects/redmine-misc'