Skip to content

Instantly share code, notes, and snippets.

View jeffrafter's full-sized avatar
You are amazing

Jeff Rafter (he/him) jeffrafter

You are amazing
View GitHub Profile
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
@jeffrafter
jeffrafter / gist:1328625
Last active December 26, 2018 12:54
Local nginx proxy to rails s
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@jeffrafter
jeffrafter / gist:1320556
Created October 27, 2011 19:19
Goodbye growlnotify.
module Growl
def notify message = nil, options = {}, &block
`say "#{message}"`
end
end
@jeffrafter
jeffrafter / .bashrc
Created October 21, 2011 19:50
SSH agent forwarding for bash rc
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
@jeffrafter
jeffrafter / gist:1291071
Created October 16, 2011 16:01
How to submit AJAX PUT/POST in Rails and not have CSRF protection clear the session
Put this in your layout (in <head>)
<%- if protect_against_forgery? -%>
<meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" />
<%- end -%>
Setup your params like this:
var params = {
In your controllers:
before_filter :set_time_zone, :if => :signed_in?
Application Controller
def set_time_zone
Time.zone = current_user.time_zone if current_user && current_user.time_zone.present?
end
@jeffrafter
jeffrafter / nginx.conf
Created September 20, 2011 15:58
Nginx proxy pass to localhost:3000 for development
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@jeffrafter
jeffrafter / .inputrc
Created September 9, 2011 02:44
The most awesome key completion ever.
cat ~/.inputrc
# Remote nano/pico treats delete/backspace sanely
# Actually what this does is kill the e key...
# export TERM=xterm
set show-all-if-ambiguous on
set completion-ignore-case on
set bell-style none
# set prefer-visible-bell
@jeffrafter
jeffrafter / ie6.sh
Created August 11, 2011 16:04
Setup a VirtualBox instance that allows you to test IE Locally from OSX
#!/bin/bash
# Much of this came from a few blog articles and one base script that I can't find now
# It is updated for the current VHD files (which supposedly expired on Aug 9th, 2011
# but still work.
#
# Requirements: Virtual Box installed, unrar (from homebrew is fine)
#
# If you want to remove stuff, open up Virtual Box and remove the VM and delete files.
#
module Fog
module SSH
class Real
def run(commands)
commands = [*commands]
results = []
begin
Net::SSH.start(@address, @username, @options) do |ssh|
commands.each do |command|
result = Result.new(command)