Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
scope :current, where(:current=>true}
validate :only_one_current
protected
def only_one_current
errors.add_to_base("Only one event can be current") if Event.current.reject{|c| c.eql?(self)}.size>0
end
# Setup ruby for rails development. Installs [:rvm, :homebrew, :wget]
echo -e '\n\n###########################################\nThanks! Now grab a beverage...\nThis may take awhile\n###########################################\n\n'
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
brew install wget
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo -e "\n[[ -s '$HOME/.rvm/scripts/rvm' ]] && . '$HOME/.rvm/scripts/rvm' # This loads RVM into a shell session." >> ~/.bash_profile
source ~/.bash_profile
echo -e '\n\n###########################################\nDone!\n###########################################\n\n'
@bsodmike
bsodmike / gist:1012044
Created June 7, 2011 11:12
How to find out everything you can override in a refinerycms project
cd /tmp
refinerycms bar
cd bar
git init .
git add .
git commit -a -m "Hide these files"
rake refinery:override view=**/*
rake refinery:override controller=**/*
rake refinery:override model=**/*
git add -N .
# I deleted this...
commit 94915c43fbe47e3a0f7dbb81affdd0106ba4a72c
Author: Daniel <znowm4n@gmail.com>
Date: Tue Jul 5 20:56:23 2011 +0200
update
diff --git a/app/views/layouts/_menu.haml b/app/views/layouts/_menu.haml
index 0a4d03f..8ea6eff 100644
@bsodmike
bsodmike / gist:1068376
Created July 6, 2011 21:29 — forked from tshddx/gist:1068361
Rails. Render a layout outside a controller, with text and locals
av = ActionView::Base.new(Rails::Configuration.new.view_path)
av.render(
{:text => this_goes_to_yield, :layout => "layouts/blah.html.erb"}, # the options hash
{:title => 'blah', :body => 'hello'} # the locals hash
)
@bsodmike
bsodmike / model.rb
Created July 8, 2011 21:44 — forked from jonpaul/model.rb
validates is_good
validate :is_valid_time
def valid_time?
self.time > 24.hours.from_now
end
def is_valid_time
errors.add("Your object", "is not valid. Other explainations.") unless valid_time?
end
@bsodmike
bsodmike / .watchr
Created July 8, 2011 21:57 — forked from ogredude/.watchr
My .watchr with red/green and Growl support
# Run me with:
#
# $ watchr .watchr
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def growl(result)
result_lines = result.split("\n")
  • Picture/File Archive on the admin site

  • Ability to upload files + file archive

  • Opportunity for bold, italic and underlined on news titles - An inline editor like tinyMCE (daniel)

  • Same system on program pages as the news page - image, text and read more when you reach over 120 + characters merge with text 2, where we could write a minimum of 3 lines. + Link under each performance: Info on ticket sales

  • More events at. day on the calendar - possibly.

  • Link by each event in the calendar - in admin module where you can choose for a page on the site, which should be linked on to

@bsodmike
bsodmike / development.rb
Created August 29, 2011 08:14 — forked from MyArtChannel/development.rb
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@bsodmike
bsodmike / engine.rb
Created September 20, 2011 10:24 — forked from workmad3/gist:1228805
Another approach to dynamically defining application routes in Rails engine
module ActionDispatch::Routing
class Mapper
def engine_routing
#define your routes here. You can use all the normal route DSL stuff
resources :dashboard
end
end
end
module OilChange