Skip to content

Instantly share code, notes, and snippets.

View docwhat's full-sized avatar

Christian Höltje docwhat

View GitHub Profile
@docwhat
docwhat / gist:a2df518e46c78a771d75
Created October 31, 2014 19:51
Debugging HTTPS connections to fedoraproject.org
# OS X Mavericks
$ openssl s_client -state -msg -debug -connect fedoraproject.org:443
CONNECTED(00000003)
SSL_connect:before/connect initialization
write to 0x7fe6a2600000 [0x7fe6a3001000] (130 bytes => 130 (0x82))
0000 - 80 80 01 03 01 00 57 00-00 00 20 00 00 39 00 00 ......W... ..9..
0010 - 38 00 00 35 00 00 16 00-00 13 00 00 0a 07 00 c0 8..5............
0020 - 00 00 33 00 00 32 00 00-2f 00 00 9a 00 00 99 00 ..3..2../.......
0030 - 00 96 03 00 80 00 00 05-00 00 04 01 00 80 00 00 ................
0040 - 15 00 00 12 00 00 09 06-00 40 00 00 14 00 00 11 .........@......
@docwhat
docwhat / .kitchen.yml
Created October 15, 2014 20:07
Chef Zero setting the environment for the node.
---
driver:
name: vagrant
provisioner:
name: chef_zero
environments_path: test/environments
client_rb:
# solo_rb: # Was used for solo
environment: kitchen
require 'benchmark'
hash = {}
(1..5_000_000)
.map { |x| format '%020d', x }
.each { |k| hash["header#{k}"] = "value#{k.reverse}" }
Benchmark.bm(50) do |x|
puts "RUBY: #{RUBY_VERSION}"
x.report('map w/split join') { hash.map { |k, v| [k, v].join(':') } }
@docwhat
docwhat / redesign.md
Last active August 29, 2015 14:03
Chef Data Bag redesign thoughts

Redesigning Data Bags

The current Chef data bag has many problems. Chef provides no help when dealing with encrypted data. It can be confusing when things are missing or don't work correctly. Some cookbooks assume various mechanisms for encryption or assume none.

Altogether it is confusing and hard to use and maintain.

@docwhat
docwhat / .gitignore
Last active December 19, 2015 17:39
Windows newlines (`\r`) appearing in the saved output: An example of the bug in GitLab: gitlabhq/gitlabhq#3982 and posted in ace/issues#1515
/tmp/
/.bundle/
/ace-builds/
@docwhat
docwhat / should_receive_example_spec.rb
Created July 12, 2013 20:43
I'm trying to figure out what the correct style for `should_receive` should be. Based on rspec/rspec_mocks#362
class RemotingApi
def do_auth(username, password, domain)
puts "Oooh, athenticating #{user} on #{domain}!"
return true
end
end
class MySystem
DEFAULT_DOMAIN = "ExampleCorp"
def login(u, p)
@docwhat
docwhat / ssl-test.rb
Last active December 19, 2015 03:19
A simple script to troubleshoot SSL problems; notably a missing CA bundle.
#!/usr/bin/env ruby
# A simple script to troubleshoot SSL problems; notably
# a missing CA bundle.
#
# Example errors that can be troubleshot:
# SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
#
# Christian Höltje / docwhat.org
require 'net/https'
@docwhat
docwhat / traceback_example.bash
Last active April 6, 2022 02:52
A template showing how to do bash tracebacks. This makes using `set -eu` much more comfortable.
#!/bin/bash
#
# Tracebacks in bash
# https://docwhat.org/tracebacks-in-bash/
#
# Just take the code between the "cut here" lines
# and put it in your own program.
#
# Written by Christian Höltje
# Donated to the public domain in 2013
@docwhat
docwhat / ssl-test.rb
Created June 15, 2013 03:06
A simple ruby program to detect if your root ca bundle is working or not.
require 'net/https'
require 'uri'
uri = URI.parse "https://www.google.com/"
https = Net::HTTP.new uri.host, uri.port
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
begin
response = https.get(uri.request_uri)
@docwhat
docwhat / aliases.zsh
Created December 8, 2012 22:42
Fixing crashes with Vim and MacVim on OS X
for i in /usr/local/opt/vim/bin/*(N) /usr/local/opt/macvim/bin/*(N); do
i=$(basename $i)
alias "${i}"="env -u GEM_PATH -u GEM_HOME command ${i}"
done