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 / 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 / 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 / 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 / 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 / open_uri.rb
Created October 7, 2011 21:46
Allow open-uri to follow unsafe redirects (i.e. https to http)
# Allow open-uri to follow unsafe redirects (i.e. https to http).
# Relevant issue:
# http://redmine.ruby-lang.org/issues/3719
# Source here:
# https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
module OpenURI
class <<self
alias_method :open_uri_original, :open_uri
alias_method :redirectable_cautious?, :redirectable?
@zaius
zaius / 0001-Update-for-10.6.patch
Created April 26, 2011 21:48
TerminalTabSwitching update for 10.6
From 95badf3776ce6a69bdff356649c7f345567c148c Mon Sep 17 00:00:00 2001
From: David Kelso <david@kelso.id.au>
Date: Tue, 26 Apr 2011 14:44:09 -0700
Subject: [PATCH] Update for 10.6.
---
TerminalTabSwitching.xcodeproj/project.pbxproj | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/TerminalTabSwitching.xcodeproj/project.pbxproj b/TerminalTabSwitching.xcodeproj/project.pbxproj
@zaius
zaius / console.html
Created January 21, 2011 05:59
Overriding of console for debugging on jquery plugins
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$.fn.myWidget = function(params) {
(function(console){
if (!params.debug) console = { log: function(){} };
console.log("Logging enabled!");
})(console);
@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 / flashblock.html
Created October 26, 2010 03:20
Inconsistent problem with flashblock and swfobject
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" type="text/javascript"></script>
<script type="text/javascript">
swfobject.registerObject("swfobject_static", "9.0.115", "expressInstall.swf");
</script>
</head>