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
# F MS Word | |
# This will cleanup 95% of the issues of copying from Word into a textarea. | |
# Notes: | |
# - This would be run on text already saved to the database | |
# - I am using Markdown convention for the bullets | |
# - I am being very lazy with em/en dashes - I could use Smarty Pants, but that opens up other issues | |
class WordCleanup | |
def self.clean(text) | |
unless text.nil? |
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
desc "Cleanup characters" | |
task :cleanup => :environment do | |
ContentItem.all.each do |item| | |
item.update_attribute :body, item.body.gsub('’', "'") unless item.body.blank? | |
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
- In HEAD | |
:javascript | |
jQuery(document).ready(function($){ | |
#{yield :ready} | |
}); | |
- In VIEW | |
- content_for :ready do |
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
<div class="weekly_builder"> | |
<div class="week"> | |
<div class="days"> | |
<div class="placeholder"> | |
<div class="day"> | |
... | |
.weekly_builder .week{background:#FFF;width:100%;height:100%;border:1px solid #ccc;overflow:hidden;} |
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 index | |
# Queries are here for clarity purposes in this demo | |
# It's of course a better idea to create a method in your model | |
users = User.find(:all) do | |
# Neato! | |
if params[:_search] == "true" | |
pseudo =~ "%#{params[:pseudo]}%" if params[:pseudo].present? | |
firstname =~ "%#{params[:firstname]}%" if params[:firstname].present? |
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 'rubygems' | |
require 'sinatra' | |
require 'active_hash' | |
### HAS_MANY AND BELONGS_TO | |
module ActiveHash | |
class Base | |
class << self | |
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 ActiveHash | |
class Base | |
def self.has_many(association_id, options = {}) | |
define_method(association_id) do | |
options = { | |
:class_name => association_id.to_s.classify, | |
:foreign_key => self.class.to_s.foreign_key | |
}.merge(options) |
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 'rubygems' | |
require 'httparty' | |
module Icontact | |
# This info was gleaned from developer.icontact.com | |
# Get a sandbox APP ID from here | |
APP_ID = "XXXXXXXXXXXXXXXXXXXXX" | |
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
@property.asking_price_type == 'Price' ? number_to_currency(@property.asking_price, :precision => 0) : "#{number_to_currency(@property.asking_price)}/SF" |
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
form.formtastic fieldset ol li { display: block; margin-bottom:.5em; } | |
form.formtastic fieldset {border:1px solid #CCC; width:400px; padding:15px; margin:15px;} | |
form.formtastic fieldset ol li label { display:block; width:200px; float:none; padding-top:.2em; } | |
form.formtastic legend { margin-bottom: 15px;} | |
form.formtastic legend span { background-color: #666; padding:8px; color:#FFF; } | |
form.formtastic .numeric { width:60px;} |