Skip to content

Instantly share code, notes, and snippets.

View sporkd's full-sized avatar

Peter Gumeson sporkd

View GitHub Profile
require 'htmlentities'
class String
def plain_text
coder = HTMLEntities.new
coder.decode(self).gsub(/<\/?[^>]*>/, '')
end
def html
coder = HTMLEntities.new
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>popup test</title>
<style type="text/css" media="screen">
has_many :tags_taggings, :as => :taggable, :class_name => 'Tagging', :conditions => "taggings.association = 'tags'", :dependent => :destroy
has_many :tags, :class_name => 'Tag', :through => :tags_taggings, :source => :tag
has_many :likes_taggings, :as => :taggable, :class_name => 'Tagging', :conditions => "taggings.association = 'likes'", :dependent => :destroy
has_many :likes, :class_name => 'Tag', :through => :likes_taggings, :source => :tag
define_index do
indexes tags(:name), :as => :tags
indexes likes(:name), :as => :likes
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>test</title>
<style type="text/css" media="screen">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>test</title>
<style type="text/css" media="screen">
# Shell script for switching between ruby versions
#
# Hat Tip To
# http://www.metaskills.net/2009/1/20/multiruby-the-macports-way-testing-your-rails-apps-with-ruby-1-9
#
chruby () {
v=`ruby -e "puts RUBY_VERSION.split('.')[0,2].join('.')"`
if [ $v = "1.9" ]; then
cv="1.8"