Skip to content

Instantly share code, notes, and snippets.

View baldwindavid's full-sized avatar

David Baldwin baldwindavid

  • Indianapolis, IN
View GitHub Profile
# 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?
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
- In HEAD
:javascript
jQuery(document).ready(function($){
#{yield :ready}
});
- In VIEW
- content_for :ready do
<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;}
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?
require 'rubygems'
require 'sinatra'
require 'active_hash'
### HAS_MANY AND BELONGS_TO
module ActiveHash
class Base
class << self
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)
require 'rubygems'
require 'httparty'
module Icontact
# This info was gleaned from developer.icontact.com
# Get a sandbox APP ID from here
APP_ID = "XXXXXXXXXXXXXXXXXXXXX"
@property.asking_price_type == 'Price' ? number_to_currency(@property.asking_price, :precision => 0) : "#{number_to_currency(@property.asking_price)}/SF"
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;}