Skip to content

Instantly share code, notes, and snippets.

View zaius's full-sized avatar

David Kelso zaius

  • Beyond Pricing
  • San Francisco
View GitHub Profile
@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@zaius
zaius / unbundled_require.rb
Created May 9, 2012 08:48
Allow requiring of global gems from outside of the Gemfile
# Include this in your .irbrc
def unbundled_require(gem)
if defined?(::Bundler)
spec_path = Dir.glob("#{Gem.dir}/specifications/#{gem}-*.gemspec").last
if spec_path.nil?
warn "Couldn't find #{gem}"
return
end
spec = Gem::Specification.load spec_path
@zaius
zaius / nginx.conf
Created April 10, 2012 03:19
Serve rails assets with etags from nginx
location / {
if ($uri ~* "/assets/.*-(.*)\..*") {
expires max;
add_header Cache-Control public
add_header Etag $1;
}
}
@zaius
zaius / git-submodule-rm.sh
Created May 9, 2012 07:31 — forked from barraponto/git-submodule-rm.sh
Add rm command to git submodule
#!/bin/zsh
function actual_path() {
if [ [ -z "$1" ] -a [ -d $1 ] ]; then
echo $(cd $1 && test `pwd` = `pwd -P`)
return 0
else
return 1
fi
}
@zaius
zaius / output.txt
Created February 19, 2016 21:30
Vagrant IPv6 Issue
$ vagrant up
Bringing machine 'default' up with 'vmware_fusion' provider...
==> default: Cloning VMware VM: 'hashicorp/precise64'. This can take some time...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Skipping vmnet device verification, verify_vmnet is set to false.
==> default: Deleting the VM...
/Users/zaius/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.6/lib/vagrant-vmware-fusion/action_farm.rb:784:in `hostonly_config': undefined method `+' for nil:NilClass (NoMethodError)
from /Users/zaius/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.6/lib/vagrant-vmware-fusion/action_farm.rb:706:in `block in call'
from /Users/zaius/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.6/lib/vagrant-vmware-fusion/action_farm.rb:699:in `each'
from /Users/zaius/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.6/lib/vagrant-vmware-fusion/action_farm.rb:699:in `call'
@zaius
zaius / post.js.coffee
Created December 3, 2013 22:16
Relationship mixin factory
App.Post = App.Model.extend App.RelationshipMixinFactory('comments'),
comments: DS.hasMany('comment', async: true)
@zaius
zaius / handlebars.rb
Created November 20, 2013 21:51
Serving ember templates from rails
# Put in config/initializers/handlebars.rb
# Add templates to app/assets/javascripts/templates/whatever.js.handlebars
# Then require from applicaiton.js (or any manifest) as usual. e.g.
# //= require_tree templates
class EmberHandlebars < Tilt::Template
def self.default_mime_type
'application/javascript'
end
@zaius
zaius / hostcheck.rb
Created July 1, 2013 21:10
Website monitoring with SMS notifications
#!/usr/bin/env ruby
require 'curb'
require 'yaml'
hosts = %w(
example.com
google.com
)
@zaius
zaius / .tmux.conf
Last active December 17, 2015 22:38
basic zshrc
# Remap prefix to ctrl-s - keeps ctrl-a free for start of line
set -g prefix C-s
unbind C-b
# Keep consistent with screen behavior
bind C-s last-window
bind C-d detach
bind C-c new-window
bind C-r source-file $HOME/.tmux.conf
@zaius
zaius / verisign_certs.sh
Last active October 13, 2015 22:25 — forked from grahamlyons/verisign_certs.sh
Add missing Verisign certificates back into CA bundle on Ubuntu
#!/bin/sh
CERT_PATH=/usr/local/share/ca-certificates/verisign.crt
write_certs() {
cat > $1 <<EOF
-----BEGIN CERTIFICATE-----
MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkG
A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2