Skip to content

Instantly share code, notes, and snippets.

View docwhat's full-sized avatar

Christian Höltje docwhat

View GitHub Profile
watch( 'spec/.*_spec\.rb' ) {|md| system("rspec #{md[0]}") }
@docwhat
docwhat / RunResultTests.py
Created January 24, 2012 20:02
Example of testing crossplatform
def test_run_a_command_successfully(self):
"Run a command successfully"
if is_windows():
obj = RunResult("cmd", "/c", "exit 0")
else:
obj = RunResult("sh", "-c", "exit 0")
assert_equal(obj.exitcode, 0)
def test_run_a_command_unsuccessfully(self):
"Run a command unsuccessfully"
@docwhat
docwhat / vacuum-maintenance.sh
Created March 4, 2012 16:40
Script to vacuum all sqlite database on my system
#!/bin/bash
set -eu
echo "Scanning for sqlite databases..."
find \
~/Library\
~/Pictures/\
-type f '(' -iname '*.sqlite' -o -iname '*.db' ')' \
-print0 | while read -r -d $'\0' filename; do
rvm_make_flags="-j 10"
rvm_install_on_use_flag=1
rvm_gemset_create_on_use_flag=1
export rvm_path="/home/holtje/.rvm"
@docwhat
docwhat / example1.vim
Created June 22, 2012 15:29
Wrapper function to save your cursor and window positions and your last search.
" Re-indents buffer.
nmap <silent> <Leader>g :call Preserve("normal gg=G")<CR>
" Removes all trailing whitespace in buffer.
nmap <silent> <Leader><space> :call Preserve("%s/\\s\\+$//e")<CR>
@docwhat
docwhat / Gemfile
Created October 6, 2012 03:36
Example of cross-platform Guard support gems
group :tools do
gem "guard"
gem "guard-bundler"
gem "guard-rspec"
#For detecting changes in the filesystem
gem 'rb-inotify', :require => false
gem 'rb-fsevent', :require => false
#For displaying notices
@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
@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 / 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
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'