Skip to content

Instantly share code, notes, and snippets.

<%= select(:team, :id, team_selection_matrix, {}, :onchange => "display(this,'#{@team.id}');") %>
@ajmorris
ajmorris / functions.php
Created February 17, 2014 19:01
example add_theme_support
if ( function_exists( 'add_theme_support' )) {
add_theme_support( 'post-thumbnails' );
// Add our image sizes
add_image_size( 'slider-thumb', 500, 372, true );
add_image_size( 'small-slider-thumb', 300, 174, true );
add_image_size( 'post-thumb', 820, 320, true);
}
@ajmorris
ajmorris / gfhubspotaddon.php
Created April 15, 2014 21:13
GFHubSpotAddon
<?php
/**
* Plugin Name.
*
* @package GF HubSpot Add-On
* @author AJ Morris
* @license GPL-2.0+
* @link http://example.com
* @copyright 2013 Your Name or Company Name
*
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
function enqueue_my_styles() {
global $wp_styles;
// Load the main stylesheet
wp_enqueue_style( 'my-theme', get_stylesheet_directory_uri() . '/style.css' );
@ajmorris
ajmorris / kb-press.php
Last active August 29, 2015 14:01
function containing transients
<?php
/**
* Plugin Name.
*
* @package Support_KB_Press
* @author Your Name <email@example.com>
* @license GPL-2.0+
* @link http://example.com
* @copyright 2014 Your Name or Company Name
*/
require "lockdown"
require File.join(File.dirname(__FILE__), "session")
Lockdown::System.configure do
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Configuration Options
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Options with defaults:
#
def discretionary_leave
self.tokens.discretionary.map {|time| time.hours}.sum
end
def accrued_annual_leave(year=current_fiscal_year)
RateInfo.new(self, year).accrued_leave + discretionary_leave
end
def net_annual_leave(year=current_fiscal_year)
accrued_annual_leave(year) - used_annual_leave(year)
xml.instruct! :xml, :version =>"1.0"
xml.feed(:xmlns => "http://www.w3.org/2005/Atom") do |feed|
feed.title('My Super Cool Feed!')
feed.link "rel" => "self", "href" => url_for(:only_path => false,
:controller => 'articles',
:action => 'atom')
feed.link "rel" => "alternate", "href" => url_for(:only_path => false,
:controller => 'articles')
feed.updated @articles.first.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ" if @articles.any?
feed.author { feed.name "Academic Technologies" }
require 'rubygems'
require 'net/ldap'
module Merb::Authentication::Strategies
class AtLdap < Merb::Authentication::Strategy
def run!( login, password )
initialize_ldap_connection unless @ldap
@ldap.bind_as(
:base => "cn=#{login},ou=cats,o=gwu",
# Originally from http://www.benlog.org/2008/6/29/bare-bones-date-picker-for-merb
# Modified for new Merb 0.9.6 helpers
module Merb::Helpers::Form
def date_field(*args)
if bound?(*args)
current_form_context.bound_date_field(*args)
else
current_form_context.unbound_date_field(*args)
end
end