Skip to content

Instantly share code, notes, and snippets.

View gist:1745
<%= select(:team, :id, team_selection_matrix, {}, :onchange => "display(this,'#{@team.id}');") %>
@ajmorris
ajmorris / functions.php
Created Feb 17, 2014
example add_theme_support
View functions.php
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);
}
View gfhubspotaddon.php
<?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
*
View functions.php
<?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 Aug 29, 2015
function containing transients
View kb-press.php
<?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
*/
View init.rb
require "lockdown"
require File.join(File.dirname(__FILE__), "session")
Lockdown::System.configure do
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Configuration Options
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Options with defaults:
#
View gist:11111
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)
View gist:16577
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" }
View at_ldap.rb
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",
View date_field.rb
# 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