Skip to content

Instantly share code, notes, and snippets.

@ivey
ivey / gist:19340
Created October 24, 2008 03:34 — forked from paltman/gist:19339
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = git@github.com:paltman/<private_repo>.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
(defun merb-console (app host user &optional env working-dir)
"Connect to a remote host and run merb"
(interactive)
(require 'inf-ruby)
(let ((buffer-name-for-comint (concat app "-console"))
(buffer-name (concat "*" app "-console*"))
(env (if env env "production"))
(working-dir (if working-dir working-dir
(concat "/data/" app "/current")))
(cmdlist `("ssh" ,host "-t"
@ivey
ivey / .emacs
Created October 24, 2008 15:22
(defun open-next-http-url ()
"Search forward to the next http/https URL, and open it"
(interactive)
(save-excursion
(nonincremental-re-search-forward "https*://")
(browse-url-at-point))
)
for app in /merbapps/* ; do
echo "Starting $app"
cd $app
if [ -e bin/merb ]
MERB_ENV=production bin/merb
else
MERB_ENV=production merb
fi
cd ..
done
@ivey
ivey / .emacs
Created October 24, 2008 18:51
(defvar user-temporary-file-directory
(concat temporary-file-directory user-login-name "/"))
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
`(("." . ,user-temporary-file-directory)
(,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
(concat user-temporary-file-directory ".auto-saves-"))
@ivey
ivey / *merb*
Created October 29, 2008 01:44
console 1:
merb : worker (port 4000) ~ Starting Mongrel at port 4000
merb : worker (port 4000) ~ Successfully bound to port 4000
^C ~ Reaping Workers
merb : worker (port 4000) ~ Exiting port 4000
console 2:
declare -a pids
i=0
for pid in log/merb.*.pid ; do
if [ $pid != "log/merb.main.pid" ]; then
pids[$i]=`cat $pid`
fi
(( i++ ))
done
declare -a pids
i=0
for pid in log/merb.*.pid ; do
if [ $pid == "log/merb.main.pid" ]; then
echo "Killing master process"
kill -9 `cat $pid`
else
pids[$i]=`cat $pid`
fi
def HTTP.get_truncated_response(uri_or_host, path = nil, port = nil, &block)
range = { 'Range' => "bytes=0-1000"}
if path
host = uri_or_host
new(host, port || HTTP.default_port).start {|http|
return http.request_get(path, range, &block)
}
else
uri = uri_or_host
new(uri.host, uri.port).start {|http|
def fetch_with_limits(uri_str, limit = 10)
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
url = URI.parse(uri_str)
req = Net::HTTP::Post.new(url.path)
req.range = (0..1000)
response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
case response
when Net::HTTPSuccess then response
when Net::HTTPRedirection then fetch(response['location'], limit - 1)