Skip to content

Instantly share code, notes, and snippets.

View meineerde's full-sized avatar

Holger Just meineerde

View GitHub Profile
begin
puts "Hello World"
raise StandardError, '(╯°□°)╯︵ ┻━┻'
rescue => ಠ_ಠ
puts ಠ_ಠ.message
puts ಠ_ಠ.backtrace.join('\n')
end
@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
@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.cnf
Last active January 25, 2018 00:00
Redirect *.example.com to *.example.org with HAProxy
# We use a temporary header to build our new Host header from the existing one
# and then directly perform a redirect
# Clean the request and remove any existing header named X-Rewrite
http-request del-header X-REWRITE
# Copy the Host header into X-Rewrite unchanged
http-request add-header X-REWRITE %[hdr(host)] if { hdr_end(host) .example.com }
# Change the X-REWRITE Header to contain out new host name
@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 / 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 / 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 / launchd.conf
Created May 20, 2014 14:59
When running OSX Mavericks, put this file into /etc/launchd.conf to have more reasonable ulimits. The file doesn't exist by default.
# Set more reasonable ulimits
limit maxfiles 16384 32768
limit maxproc 512 1024
# Add /usr/local/bin to the global PATH used by all applications
# Be careful as this can affect the whole system when you install incompatible software here
setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
@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 / hash_hostname_for_ssh_known_hosts.rb
Last active December 29, 2015 16:09
A method to generate a hashed hostname for inclusion in a known_hosts file of OpenSSH.
require 'openssl'
require 'base64'
require 'securerandom'
def hash_hostname(hostname, salt_b64=nil)
if salt_b64
salt = Base64.decode64(salt_b64)
else
salt = SecureRandom.random_bytes(20)
salt_b64 = Base64.encode64(salt).strip