Skip to content

Instantly share code, notes, and snippets.

View dotemacs's full-sized avatar

Александар Симић dotemacs

View GitHub Profile
(defmacro safe-wrap (fn &rest clean-up)
`(unwind-protect
(let (retval)
(condition-case ex
(setq retval (progn ,fn))
('error
(message (format "Caught exception: [%s]" ex))
(setq retval (cons 'exception (list ex)))))
retval)
,@clean-up))
# basing it on this:
# http://github.com/binarylogic/authlogic_example/blob/master/app/views/user_sessions/new.html.erb
<h1>Login</h1>
<% form_for @user_session, :url => user_session_path do |f| %>
<%= f.error_messages %>
<%= f.label :login %><br />
<%= f.text_field :login %><br />
;; nice drop down menu for Rinari: http://github.com/eschulte/rinari
(add-hook 'rinari-minor-mode-hook
'(lambda()
(easy-menu-define my-menu rinari-minor-mode-map "Rinari menu"
'("Rinari"
["Controller" rinari-find-controller]
["View" rinari-find-view]
["Model" rinari-find-model]
--- runner.rb.orig 2009-11-23 14:14:58.000000000 +0000
+++ runner.rb 2009-11-24 13:47:17.000000000 +0000
@@ -1,7 +1,6 @@
require 'rubygems'
require 'ruby_parser'
require 'erb'
-require 'haml'
require 'yaml'
module RailsBestPractices
@dotemacs
dotemacs / gist:242275
Created November 24, 2009 22:01
Enable rails_best_practices in emacs rinari mode
;; install rinari http://github.com/eschulte/rinari
;; install http://github.com/flyerhzm/rails_best_practices
;; run this in your emacs
(defun my-rinari-mode()
(defun rails-best-practices (rails-app-dir)
"Run rails_best_practices checker and provide results which you can easily navigate"
(interactive "DRails app base dir: ")
(let ((exe (executable-find "rails_best_practices")))
(if exe
;; edit rectangles of text easily
(cua-selection-mode t)
(defalias 'block-edit 'cua-set-rectangle-mark)
(global-set-key "\M-[" 'block-edit)
; eval it & then invoke it, select a desired area and try it out
; aliased it to block-edit as its easier to remember in case I ever forget the key binding
; so that I can call it up using M-x
!/usr/bin/env ruby
# convert unix time stamps to 'human' time
# by Aleksandar Simic
# 4 August 2009
if ARGV.length == 0
puts
puts 'usage: u2h unix-time-stamp'
puts
;; see this gist first http://gist.github.com/285326
(defun sumup()
"Work out the sum for a cua-mode selected column/rectangle
and add it to the kill ring, so that it can be pasted in.
Improves on: http://www.emacswiki.org/emacs/AddNumbers as it
works on the more precise, visually appealing & obvious
cua-rectangle selected area, instead of the 'plain' rectangle
select."
(interactive)
;; creates .gitignore file
;;
;; added a check, so that if a .gitignore exists already it doesn't overwrite it
(defun gitignore(dir)
"create .gitignore file in a directory supplied
populating it with the patterns/files"
(interactive "DDirectory name: ")
(setq ignore-patterns
;; modify patterns/files below as per your need
;; my improvement upon http://gist.github.com/412956
;; tried forking that gist and adding my changes, but the markup kept breaking
;; tweaked it so it only loads the settings for rinari mode
(add-hook 'rinari-minor-mode-hook
"Rinari mode tweaks"
(defun my-rinari-hook()
(defun restart-passenger ()
"Restart passenger using the current rinari root"