This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spelling | |
require 'net/https' | |
require 'uri' | |
require 'rexml/document' | |
ASPELL_WORD_DATA_REGEX = Regexp.new(/\&\s\w+\s\d+\s\d+(.*)$/) | |
ASPELL_PATH = "aspell" | |
# | |
# @param String: spell_check_text - represents the source string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'will_paginate' | |
class Array | |
def paginate(all = nil, options = {}) | |
options[:page] = (options[:page].to_i == 0) ? 1 : options[:page].to_i | |
options[:per_page] = (options[:per_page].to_i == 0) ? 30 : options[:per_page].to_i | |
pagination_array = WillPaginate::Collection.new(options[:page], options[:per_page], self.size) | |
start_index = pagination_array.offset | |
end_index = start_index + (options[:per_page] - 1) | |
array_to_concat = self[start_index..end_index] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DocumentFileTypes | |
module Microsoft | |
WORD = %w( | |
application/msword | |
application/vnd.openxmlformats-officedocument.wordprocessingml.document | |
application/vnd.openxmlformats-officedocument.wordprocessingml.template | |
application/vnd.ms-word.document.macroEnabled.12 | |
application/vnd.ms-word.template.macroEnabled.12 | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REMOTE_URL_PATTERN = /\A(?:(?:http|https):\/\/[a-z0-9]+(?:[\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(?:\:[0-9]{1,5})?).*\z/ix | |
LOCAL_URL_PATTERN = /\A(?:[a-zA-Z]{1,2}\:\\\\?).*\z/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.arrayReplace = (args...) -> | |
rtn = @ | |
for set in args | |
rtn = rtn.replace(new RegExp(set[0], 'gi'), set[1]) | |
rtn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.mapConcat = (args...) -> | |
separator = args.slice(0,1) if $.type(args[0]) == 'string' or $.type(args[0]) == 'regexp' | |
separator or= '' | |
chars = @.split(separator) | |
rtn = [] | |
for char, i in chars | |
rtn.push(args[0].call(@, char, i) or char) | |
rtn.join('') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## rake file lib/tasks/backup.rake | |
desc "Backup Everything Specified in config/backup.yml" | |
task :backup => [ "backup:db", "backup:push"] | |
namespace :backup do | |
RAILS_APPDIR = RAILS_ROOT.sub("/config/..","") | |
def interesting_tables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
module PrototypeHelper | |
def link_to_remote_if(condition, name, options = {}, html_options = nil) | |
condition ? link_to_remote(name, options, html_options) : name | |
end | |
def link_to_remote_unless(condition, name, options = {}, html_options = nil) | |
!condition ? link_to_remote(name, options, html_options) : name | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
# Confirms that a key is set in the Hash | |
def assert_required_keys(*required_keys) | |
missing_keys = [] | |
[required_keys].flatten.each { |k| missing_keys << k unless keys.has_key?(k) } | |
raise(ArgumentError, "Missing required key(s): #{missing_keys.join(", ")}") unless missing_keys.empty? | |
end | |
# Confirms that a key is present and that is has value |
NewerOlder