Skip to content

Instantly share code, notes, and snippets.

class ApplicationController < ActionController::Base
include HoptoadNotifier::Catcher
around_filter :ensure_page_title
def ensure_page_title
yield
*/1 * * * * ( [ ! -f /tmp/send_email_message.lock ] && unset SEND_EMAIL_MESSAGELOCK && touch /tmp/send_email_message.lock && export SEND_EMAIL_MESSAGELOCK=1 && cd /home/neeraj/apps/demo_production/current ; /usr/bin/rake email:run RAILS_ENV=production >> /home/neeraj/apps/demo_production/current/log/send_email_message.log ; [ "$SEND_EMAIL_MESSAGELOCK" = "1" ] && rm -f /tmp/send_email_message.lock ) > /dev/null 2>&1
module ActiveSupport
Inflector.inflections do |inflect|
inflect.plural(/$/, 's')
inflect.plural(/s$/i, 's')
inflect.plural(/(ax|test)is$/i, '\1es')
inflect.plural(/(octop|vir)us$/i, '\1i')
inflect.plural(/(alias|status)$/i, '\1es')
inflect.plural(/(bu)s$/i, '\1ses')
inflect.plural(/(buffal|tomat)o$/i, '\1oes')
inflect.plural(/([ti])um$/i, '\1a')
module Shoulda # :nodoc:
module ActiveRecord # :nodoc:
module Matchers
def validate_format_of(attr)
ValidateFormatOfMatcher.new(attr)
end
class ValidateFormatOfMatcher < ValidationMatcher # :nodoc:
@neerajsingh0101
neerajsingh0101 / where to place routes in plugin
Created May 21, 2009 19:20
where to place routes in plugin
-myplugin
--app
---controllers
--config
---routes.rb
-init.rb
-lib
-tasks
-test
-README
class Article < ActiveRecord::Base
end
class User < ActiveRecord::Base
has_many :articles
roll_searchable_for do
searchable_for :first_name
searchable_for :last_name
searchable_for :email,
:condition => "users.email LIKE :search_term AND users.id > 1"
require 'rubygems'
require 'eventmachine'
module ChatClient
def self.list
@list ||= []
end
def post_init
@name = "anonymous_#{rand(99999)}"
var highlightClass = 'hl';
function createHighlights(text, regex, node,parentn) {
if (regex.exec(text) != null) {
parentn.insertBefore(document.createTextNode(RegExp.$1),node);
highlightNode = document.createElement("span");
highlightNode.className = highlightClass;
highlightNode.appendChild(document.createTextNode(RegExp.$2));
students
-------
INT id
STRING first_name
STRING last_name
STRING full_name
STRING mother_name
STRING father_name
specializations ( fields in which one might major/minor )