Skip to content

Instantly share code, notes, and snippets.

View tobias's full-sized avatar

Toby Crawley tobias

View GitHub Profile
#!/usr/bin/ruby
require 'rubygems'
require 'tinder'
load "#{ENV['HOME']}/.campfire_status"
msg = "[#{USER_NAME} @ #{Time.now.strftime('%I:%M%p')}] #{ARGV.join(' ')}"
campfire = Tinder::Campfire.new(CAMPFIRE_SITE)
campfire.login(CAMPFIRE_EMAIL, CAMPFIRE_PASSWORD)
@tobias
tobias / gist:227109
Created November 5, 2009 15:16
.campfire_status
CAMPFIRE_SITE = 'sitename'
CAMPFIRE_EMAIL = '[email protected]'
CAMPFIRE_PASSWORD = 'password'
CAMPFIRE_ROOM = 'Status'
USER_NAME = 'Tobias'
# on Start
do shell script "~/bin/set_campfire_status.rb \"Starting Pomodoro '$pomodoroName'\""
# on End
do shell script "~/bin/set_campfire_status.rb \"Pomodoro '$pomodoroName' ended\""
# on Reset
do shell script "~/bin/set_campfire_status.rb \"Pomodoro '$pomodoroName' ended (reset)\""
#!/usr/bin/ruby
if ARGV[0] =~ /^i/
msg = 'In the office'
elsif ARGV[0] =~ /^o/
msg = 'Out of the office'
else
puts 'first argument must be "i[n]" or "o[ut]"'
exit
end
task :setup_known_hosts do
run "echo 'github.com,65.74.180.52 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' > ~/.ssh/known_hosts"
end
before "deploy:update_code", "setup_known_hosts"
<%
# config/rubber/role/delayed_job/delayed_job-monit.conf
@path = '/etc/monit/monit.d/delayed_job-monit.conf'
%>
check process delayed_job with pidfile <%= RUBBER_ROOT %>/tmp/pids/delayed_job.pid
start program = "<%= RUBBER_ROOT %>/script/delayed_job start"
stop program = "<%= RUBBER_ROOT %>/script/delayed_job stop"
group delayed_job-<%= RUBBER_ENV %>
(defun ack-in-project (pattern)
"Run ack, with user-specified ARGS, and collect output in a buffer.
While ack runs asynchronously, you can use the \\[next-error] command to
find the text that ack hits refer to. The command actually run is
defined by the ack-command variable."
(interactive (list (read-string "Ack for (in app root): " (thing-at-point 'symbol))))
(let (compile-command
(compilation-error-regexp-alist grep-regexp-alist)
(compilation-directory default-directory)
(defun comment-ruby-region-as-block (start end)
"Comments out the region between START and END with ruby =begin and =end markers.
After executing, the point will be at bol for the line just after or just before
the comment block, depending on whether point is START or END when called."
(interactive "r")
(let ((original-point (point))
(end-line (line-number-at-pos start))
(start-text "\n=begin\n")
(end-text "=end\n\n"))
(save-excursion
(defun rails-generate-migration (args)
"Runs 'script/generate migration ARGS' and opens the new migration in a buffer."
(interactive
(list (read-string "generate migration: ")))
(let
((command (format "ruby %sscript/generate migration %s" (rinari-root) args))
(result nil))
(message "calling: %s" command)
(setq result (shell-command-to-string command))
(if (string-match "^ *create *\\(db/migrate/.*\\.rb\\)$" result)
(defun open-trace-and-file (tracefile file linenum)
"Open visit TRACEFILE in one window (in compilation mode), and visit FILE at LINENUM in another"
(find-file-other-window tracefile)
(compilation-mode)
(goto-line 2)
(find-file-other-window file)
(goto-line linenum))