Skip to content

Instantly share code, notes, and snippets.

View baldwindavid's full-sized avatar

David Baldwin baldwindavid

  • Indianapolis, IN
View GitHub Profile
irb(main):001:0> thing
NameError: undefined local variable or method `thing' for main:Object
from (irb):1
irb(main):002:0> defined? thing
=> nil
irb(main):003:0> thing = thing
=> nil
irb(main):004:0> thing
=> nil
irb(main):005:0> defined? thing
# Admin controller sets layout and has before filter requiring login
class ManualsController < AdminController
# only allow admins unless index or show action
padlock(:on_all_except => [:index, :show]) { current_user.admin? }
# only allow admins or users with view privileges on the show action
padlock(:on => :show) { current_user.admin? || current_user.can_view_manual?(Manual.find(params[:id])) }
def index
module Breadcrumb
def breadcrumbs
rbreadcrumbs.reverse
end
def rbreadcrumbs
crumbs = []
crumbs << self
crumbs << self.parent.rbreadcrumbs if self.parent
# STRFTIME
# %a - The abbreviated weekday name (``Sun'')
# %A - The full weekday name (``Sunday'')
# %b - The abbreviated month name (``Jan'')
# %B - The full month name (``January'')
# %c - The preferred local date and time representation
# %d - Day of the month (01..31)
# %e - Day of the month - no leading zero NOTE: need plugin for this to work in Win32
# %H - Hour of the day, 24-hour clock (00..23)
# %I - Hour of the day, 12-hour clock (01..12)
var $j = jQuery.noConflict();
jQuery(document).ready(function($){
$("#id_of_my_textarea").markItUp(nameOfSettings);
});
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept",
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var $j = jQuery.noConflict();
jQuery(document).ready(function($){
var rowGuid = 0;
require 'rubygems'
require 'httparty'
class CalorieKing
include HTTParty
basic_auth '84294d7ae4454189bf2a3ebc37a0e421', ''
base_uri 'http://foodsearch1.webservices.calorieking.com/rest'
def self.search(term)
get("/search/#{term}")
end
Comatose.configure do |config|
config.admin_includes << :your_authentication_module
config.admin_authorization = :your_auth_before_filter_method
config.admin_get_root_page do
if current_user.role == 'troop_leader'
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
!!current_user
end
# Accesses the current user from the session.
# Future calls avoid the database because nil is not equal to false.