Skip to content

Instantly share code, notes, and snippets.

View bishopandco's full-sized avatar
😈
CRUSHMODE

Michael Bishop bishopandco

😈
CRUSHMODE
View GitHub Profile
module ActiveSupport
class BufferedLogger
module Severity
COLORIZE = 10
end
include Severity
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
message = "\e[0;45m#{message}\e[0;0m\n" if severity == 10
@bishopandco
bishopandco / Colorized Logger
Created May 22, 2012 01:20 — forked from esmarkowski/Colorized Logger
beautiful colorized messages.
module ActiveSupport
class BufferedLogger
module Severity
COLORIZE = 10
end
include Severity
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
message = "\e[0;45m#{message}\e[0;0m\n" if severity == 10
# will look in db/seeds/admin_users.rb
plant :admin_users
# block syntax
plant :about_us do |seed|
seed.path = 'db/seeds/some_folder'
end
# addressable.rb
module Schemata
module Schema
def addressable
apply_schema :street_address_1, String
apply_schema :street_address_2, String
apply_schema :city, String
apply_schema :state, String
apply_schema :zip_code, String
apply_schema :country, String
class MainController < ApplicationController
include Cable::Helpers::CableControllerHelpers
# def find_by_url
# unless request_is_missing_static_resource?
# @location = Location.includes(:menus).find_by_marketable_url( params[:url] ) || Location.includes(:menus).find_by_url( request.path )
# unless @location.nil?
# @resource = @location.resource
# @page_title = (@location.title.nil?) ? "" : @location.title
# send(@location.special_action) unless @location.special_action.blank?
# @continue_execution = send(@location.special_action) unless @location.special_action.blank?
@bishopandco
bishopandco / application_controller.rb
Created June 30, 2011 02:50
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :menus
def menus
@authors = Author.all
end
end
@bishopandco
bishopandco / some.rb
Created June 9, 2011 22:25
Date Range
Model.where(:something => something, :call_date => start_date..end_date)
class Order < ActiveRecord::Base
validate :ship_to_field
def ship_to_field
errors[:base] << "Please choose a shipping method" unless [true,false].include?(self.ship_to)
end
end
@bishopandco
bishopandco / gist:951005
Created May 1, 2011 23:59
apeiros_ needs an energy tank
DOOOD NDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDN DOOOD
O***O D-------------------------------D O***O
O***O D-------------------------------D O***O
O*******O N88888888888O-------------------D O*******O
O*******O N88888888888O-------------------D O*******O
DOOO-$$$7***O DOOOOOOOOOOOO-------------------D O***7$$$-OOOD
O***$888$***O D-------------------------------D O***$888$***O
O***$888$***O D-------------------------------D O***$888$***O
def serialize
h={}
self.instance_variables.each do |variab|
h[variab.gsub("@","").to_sym] = self.instance_variable_get(variab)
end
h
end