Skip to content

Instantly share code, notes, and snippets.

View baldwindavid's full-sized avatar

David Baldwin baldwindavid

  • Indianapolis, IN
View GitHub Profile
# 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)
module Breadcrumb
def breadcrumbs
rbreadcrumbs.reverse
end
def rbreadcrumbs
crumbs = []
crumbs << self
crumbs << self.parent.rbreadcrumbs if self.parent
# 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
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
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
class ApplicationController < ActionController::Base
sublayout '2col'
end
class PagesController < ApplicationController
sublayout '3col'
end
class AdminController < ApplicationController
sublayout '1col'
In layout file below linked stylesheets/js files. Note: This is HAML...
:javascript
jQuery(function($){
#{yield :onload}
});
In view files. Again HAML...
@baldwindavid
baldwindavid / gist:88795
Created April 1, 2009 17:24
Jquery / Rails Basic Setup
// outside of this you can refer to jQuery as $j
$j = jQuery.noConflict();
jQuery(document).ready(function($){
// your stuff goes here!
// just use $ to refer to jQuery from within here
});
# make'em pretty colors
export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '
# show current Git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"