Skip to content

Instantly share code, notes, and snippets.

= form_for @nurse, do |f|
- @nurse.errors.full_messages.each do |msg|
%p= msg
%fieldset
%p
= f.label "Name: ",:class => 'required'
%br/
= f.text_field :name, :id => 'name', :class => 'half'
%p
= f.label "Telephone Number: ",:class => 'required'
@chocnut
chocnut / blank_gist
Created November 4, 2011 06:50
blank_gist
<?php
if ( $_SERVER['HTTP_HOST'] == 'hourtown.com' ) {
header('location: http://www.hourtown.com' . $_SERVER['REQUEST_URI']);
exit;
}
if (in_array($_SERVER['REMOTE_ADDR'], array('72.32.197.151'))){
sleep(rand(10,50));
}
@chocnut
chocnut / GEMFILE
Created November 25, 2011 03:53
GEM File for deployment
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'mysql2', '< 0.3'
gem 'haml-rails'
gem 'devise'
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
@chocnut
chocnut / deploy.rb
Created November 25, 2011 03:57
deploy.rb
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
require 'bundler/capistrano'
set :application, "staging.xxxx.com"
#set :repository, "."
set :scm, :git
set :repository, "."
set :deploy_via, :copy
# set :port, 16888
@chocnut
chocnut / .zshrc
Created December 10, 2011 22:20
Add this to your zshrc profile for RVM to load propery
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
alias rake="noglob rake"
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
@chocnut
chocnut / gist:1542436
Created December 31, 2011 01:51
has_many problem :)
Models
class User < ActiveRecord::Base
has_many :dnshospitals
has_many :hospitals, :through => :dnshospitals
end
class Hospital < ActiveRecord::Base
has_many :dnshospitals
has_many :users, :through => :dnshospitals
@chocnut
chocnut / availability.rb
Created January 15, 2012 23:23
Multiple Filter via Scope
class Availability < ActiveRecord::Base
attr_accessible :name, :hospital_tokens, :start_at, :end_at, :shift
has_many :appointments
has_many :hospitals, :through => :appointments
belongs_to :user
has_event_calendar
attr_reader :hospital_tokens
scope :by_hospital, lambda { |hospital| selected_hospital(hospital) }
scope :by_date, lambda { |date| where("start_at >= ? AND start_at <= ?", date, date) }
@chocnut
chocnut / recurring.php
Created September 4, 2012 03:10
Recurring dates in PHP
<?php
require_once('When.php');
$_POST['weekly'] = true;
//array('MO','TU','WE','TH','FR','SA','SU')
$repeat_days = $_POST['selected_days'];
$repeat_type = isset($_POST['weekly']) ?: $_POST['monthly'];
//e.g 01/01/2013
$end = $_POST['end_date'];
@chocnut
chocnut / gist:3653137
Created September 6, 2012 08:37
php test
$week_no = array(2,3,4);
$days = array('TU', 'WE', 'TH');
foreach ($week_no as $n) {
foreach ($days as $d) {
$out[] = $n . $d;
}
}
var_dump($out); // array('2TU', '2WE', '2TH','3TU', '3WE', '3TH, '4TU', '4WE', '4TH)
@chocnut
chocnut / app._config.routes.yml
Created September 15, 2012 00:33 — forked from wilr/app._config.routes.yml
Basic SilverStripe 3.0 Framework Bootstrap
---
Name: app
After: framework/routes#coreroutes
---
Director:
rules:
'dev': 'DevelopmentAdmin'
'sitemap.xml': 'GoogleSitemap'
'$Action' : 'BaseController'