Skip to content

Instantly share code, notes, and snippets.

View thomasritz's full-sized avatar

Thomas Ritz thomasritz

View GitHub Profile
@thomasritz
thomasritz / direnv.elv
Last active March 8, 2018 05:32
elvish direnv integration
# ~/.elvish/lib/direnv.elv
fn hook []{
env = (or (direnv export json | from-json) [&])
if (> (count $env) 0) {
f = (mktemp)
keys $env | each [k]{ echo "E:"$k" = \""$env[$k]"\"" >> $f }
-source $f
rm -f $f
}
@thomasritz
thomasritz / memcached.yml.erb
Created August 30, 2013 09:35
custom OpsWorks cookbook memcached.yml.erb that supports memcached cluster
# rails/templates/default/memcached.yml.erb
<%
instances = node[:opsworks][:layers][:memcached][:instances]
instances = {:localhost => {:private_ip => "127.0.0.1"}} if instances.empty?
-%>
hosts:
<% instances.each_pair do |name, cache_server| -%>
- "<%= cache_server[:private_ip]%>:<%= @memcached[:port] %>"
<% end -%>
@thomasritz
thomasritz / gist:3722212
Created September 14, 2012 14:24
git bisect example session
# See man page http://git-scm.com/docs/git-bisect
# Start the bisect process
» git bisect start
# Mark current commit as bad
» git bisect bad
@thomasritz
thomasritz / gist:3489173
Created August 27, 2012 14:49
Entwicklungsumgebung für Ruby 1.8.7 auf Mountain Lion
Sehr hilfreiche Anleitung fürs Installieren einer Entwicklungsumgebung auf Mountain Lion.
http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
- Xcode
- Xcode Command Line Tools
- Homebrew GCC
- Mysql chown
- X11 Quartz
brew uninstall imagemagick
@thomasritz
thomasritz / gist:2895206
Created June 8, 2012 11:48
Organize ssh config in separate files
mkdir -p $HOME/.ssh/conf.d
mv $HOME/.ssh/config $HOME/.ssh/conf.d/orig.conf
echo 'cat $HOME/.ssh/conf.d/*.conf > $HOME/.ssh/config' >> $HOME/.zshrc
@thomasritz
thomasritz / application.rb
Created May 10, 2012 14:23
If rendering a Cell causes an error, catch it, report the exception to Airbrake and render nothing
# config/application.rb
unless Rails.env.development?
Cell::Rendering::ClassMethods.class_eval do
def render_cell_for(name, state, *args)
cell = nil
cell = create_cell_for(name, *args)
yield cell if block_given?
render_cell_state(cell, state, *args)
rescue => exception
We couldn’t find that file to show.
# (Gem install did not work with PostgreSQL binary from enterprisedb.)
#
# - Install PostgreSQL with homebrew (requires XCode):
# cd $HOME/d/other
# git clone git://github.com/mxcl/homebrew.git
# cd homebrew
# brew install postgresql
# - Add $HOME/d/other/homebrew/bin to $PATH
# - Follow the further instructions:
# initdb $HOME/d/other/homebrew/var/postgres

Vim

augroup DeleteTrailingWhitespaces
  autocmd!
  autocmd BufWritePre * ks|execute "%s/\\s\\+$//ge"|'s
augroup END

Emacs