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
| def self.auto_link_content(content) | |
| # Splits all HTML tags, except <a></a> tags. Keeps <a></a> tags as whole | |
| # so that we don't accidentally link already linked Keywords | |
| word_groups = content.split(/(<a[^>]*>.+?<\/a>|<\/?[^>]*>|[.]|,|['"]+)/i) | |
| word_groups.collect! do |words| | |
| (!words.match(/<\/?[^>]*>|[.]+|,+/) && words.match(/([a-zA-Z]+)/)) ? link_it(words) : words | |
| end | |
| word_groups.join | |
| 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
| 10.3 - 10 | |
| # 0.300000000000001 | |
| a = 10.3 - 10 | |
| # 0.300000000000001 | |
| b = 0.300000000000000 | |
| # 0.300000000000000 | |
| a == b | |
| # false | |
| (a + 10) == (b + 10) | |
| # true |
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 FooModule | |
| def say_hello | |
| "Hello!" | |
| end | |
| end | |
| class FooClass | |
| include FooModule | |
| 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
| # Create a file my_modeule.rb | |
| # Include it in your application load path (Standard: app/lib ) | |
| # FILE CONTENTS BEGIN HERE | |
| module MyModule | |
| def self.included(base) | |
| base.extend ClassMethods | |
| class << base | |
| attr_accessor :class_variable | |
| 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 Array | |
| def to_sentence(options = {}) | |
| # en-US: "One, Two, and Three" en-UK: "One, Two and Three" | |
| options[:last_word_connector] ||= " and " | |
| super | |
| end | |
| 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
| # To change this template, choose Tools | Templates | |
| # and open the template in the editor. | |
| class Bitly < ActiveResource::Base | |
| self.site = 'http://api.bit.ly' | |
| self.user = 'USERNAME' | |
| self.password = 'PASSWORD' | |
| cattr_accessor :login, :return_format, :api_key, :bitly_version |
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
| >> Bitly.shorten "http://www.facebook.com/home.php" | |
| => "http://bit.ly/3B2w14" | |
| >> Bitly.shorten "http://bit.ly/" | |
| => "http://bit.ly/" |
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
| >> wall "Changing the mysql root password, please bear. -Swanand" | |
| Broadcast message from root (pts/3) (Sat Nov 21 12:53:50 2009): | |
| Changing the mysql root password, please bear. Thanks, Swanand | |
| >> wall "Done. Thanks for the patience. -Swanand" | |
| Broadcast message from root (pts/3) (Sat Nov 21 12:54:44 2009): | |
| Done. Thanks for the patience. -Swanand |
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
| <?php | |
| /* | |
| Credit Card Validator | |
| Date - Sep 04, 2009 | |
| Author - Brent Shaffer | |
| ABOUT |
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
| <?php | |
| // These following lines load the project context | |
| require_once(dirname(__FILE__).'/config/ProjectConfiguration.class.php'); | |
| // I use 'prod' all the time, and 'dev' only when something goes wrong | |
| $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false); | |
| // Generally keep 'dev', I use 'prod' all the time, 'dev' only when something goes wrong | |
| // If you want to test just the models and business logic: | |
| // sfContext::createInstance($configuration); | |
| // If you want to test URL helpers and other helpers that require controller context | |
| sfContext::createInstance($configuration)->dispatch(); |
OlderNewer