Skip to content

Instantly share code, notes, and snippets.

View michaeldv's full-sized avatar

Michael Dvorkin michaeldv

  • Cupertino, California
View GitHub Profile
@mislav
mislav / sass_heroku.rb
Created September 17, 2010 22:17
Detect and compensate for Sass / Compass on Heroku
# drop into "initializers" dir
heroku = !!ENV['HEROKU_TYPE']
css_dir = heroku ? 'tmp' : 'public'
location = Rails.root + 'app/styles'
unless Sass::Plugin.template_location_array.any? { |pair| pair.first.to_s == location.to_s }
Sass::Plugin.add_template_location(location, Rails.root + css_dir + 'stylesheets')
end
shell /bin/bash
#term xterm-256color
term xterm
# terminfo and termcap for nice 256 color terminal
# # allow bold colors - necessary for some reason
attrcolor b ".I"
# # tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
# support for using named routes from the console
#
# files: lib/railsext.rb
#
module Kernel
private
def use_named_routes_in_the_console! options = {}
include ActionController::UrlWriter
options.to_options!
@BinaryMuse
BinaryMuse / template.rb
Created November 21, 2010 17:34
My Rails application template - under development! See comments for info.
# ============================================================================
# Info class
# ============================================================================
class ApplicationInfo < Rails::Generators::AppGenerator
attr_reader :notices, :errors, :options, :data
def initialize
@notices = [] # Array of notices to display to the user at the end
@errors = [] # Array of errors to display to the user at the end
@options = [] # Array of options selected throughout the template
#! /usr/bin/env ruby
Main {
name 'gist'
description <<-__
command line script for writing and reading to http://gist.github.com/
__
examples <<-__
module_eval(<<-__, __FILE__, __LINE__ - 1)
def #{ mode }(*args, &block)
if args.empty?
mode(#{ mode.inspect }, &block)
else
mode(#{ mode.inspect }) do
call(*args, &block)
end
end
# a little rake task to rename a Rails3 project. handles editing files,
# renaming files, and renaming directories. use NOOP=true to view
# edits/renames before performing them.
#
begin
### gem install map
#
### gem 'map'
#
Tree = {function,1,foo,1,
[{clause,1,
[{var,1,self}],
[],
[{op,1,'+',{integer,1,1},{integer,1,2}}]}]}.
% Thanks to N_Ox on #erlang for pointing erl_syntax:abstract out.
{value, Tree, _ } = erl_eval:expr(erl_syntax:revert(erl_syntax:abstract(Tree), [])).
# instead of setting all paths individually, you set all of them relative to
# another root, say my_gem/lib/rails/engine this way
if defined?(Rails)
module MyGem
class Engine < Rails::Engine
paths.path = MyGem.engine_dir
This.rubyforge_project = 'codeforpeople'
This.author = "Ara T. Howard"
This.email = "ara.t.howard@gmail.com"
This.homepage = "http://github.com/ahoward/#{ This.lib }"
task :default do
puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
end