Skip to content

Instantly share code, notes, and snippets.

View boblmartens's full-sized avatar

Bob Martens boblmartens

View GitHub Profile
@boblmartens
boblmartens / user.rb
Created November 25, 2008 01:31
a possible password system
attr_accessor :new_password
validates_presence_of :new_password, :on => :create
validates_length_of :new_password, :minimum => 6, :allow_nil => true, :allow_blank => true, :unless => :new_password.blank?
validates_confirmation_of :new_password
before_save :set_encrypted_password
def set_encrypted_password
write_attribute(:password, Client.encrypt_password(@new_password)) unless @new_password.nil? || @new_password.blank?
<h2>Welcome to Jibber!</h2>
<% if @posts.size == 0 %>
<p>I'm sorry, you need to write a post.</p>
<% else %>
<%= render :partial => @posts %>
<% end %>
<h2>Welcome to Jibber!</h2>
<% if @posts.size == 0 %>
<p>I'm sorry, you need to write a post.</p>
<% else %>
<% @posts.each do |post| %>
<div class="indexPostContainer">
<h3><%= link_to post.title, post %></h3>
<h4>Posted by <%= post.user.name %> at <%= post.created_at %></h4>
<h5>Tags: <%= post.tag_list %></h5>
<%= markdown post.body %>
<% render :partial => "comments/add_comment", :object => @comment = Comment.new, :locals => { :button_name => 'post comment' } %>
##
# Calendar helper with proper events
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/
#
# (C) 2009 James S Urquhart (jamesu at gmail dot com)
# Derived from calendar_helper
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php
##
# standard.rb
# from Bob Martens
# standard Rails template used for BobMartens.net development
# needed gems
gem 'authlogic'
gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => 'http://gems.github.com'
gem 'thoughtbot-factory_girl', :lib => 'shoulda', :source => 'http://gems.github.com'
gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
require 'net/imap'
require 'pp'
require 'yaml'
conf = File.open( 'config.yaml' ) { |yf| YAML::load( yf ) }
#custom verification callback used here only for debugging
VerifyCallbackProc = proc do |v, ctx|
#p ctx.methods
#p v, ctx.current_cert, ctx.chain
class Address
include Mongoid::Document
belongs_to :user, :inverse_of => :addresses
belongs_to :venue, :inverse_of => :venues
field :street, :type => String
field :city, :type => String
field :state, :type => String
field :zip, :type => Integer
class InterventionsController < ApplicationController
inherit_resources
actions :create, :update, :edit, :new
nested_belongs_to :patient, :drug_therapy_problem
create! do |success, failure|
success.html do
@intervention.activate!("Manual communication")
end
failure.html { render :action => 'new', :status => :unprocessable_entity }
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.