Skip to content

Instantly share code, notes, and snippets.

View brand-it's full-sized avatar

Brandt Lareau brand-it

View GitHub Profile
module ApplicationHelper
# Basic function with this if you have any object.errors that you wanted formated you just call this method and it will handle the formating
def error_summery( object )
return unless object.errors.any?
# Build the messages li
messages = []
object.errors.full_messages.each do |msg|
messages << content_tag(:li, msg)
end
content_tag(:div, "Please review the errors below", class: 'alert alert-danger') +
#!/bin/bash
cd ~/starbound/linux64
./starbound_server
#!/bin/bash
read -p "Enter Username: " username
~/steamcmd/steamcmd.sh +login $username +force_install_dir ~/starbound +app_update 211820 +quit
@font-face {
font-family: 'Glyphicons Halflings';
src: url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot'), '#{$icon-font-path}#{$icon-font-name}.eot'));
src: url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot?#iefix'), '#{$icon-font-path}#{$icon-font-name}.eot?#iefix')) format('embedded-opentype'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.woff2'), '#{$icon-font-path}#{$icon-font-name}.woff2')) format('woff2'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.woff'), '#{$icon-font-path}#{$icon-font-name}.woff')) format('woff'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.ttf'), '#{$icon-font-path}#{$icon-font-name}.ttf')) format('truetype'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.svg##{$icon-font-svg-id}'),
class ApplicationController < ActionController::Base
before_filter :set_current_user
protected
def set_current_user
# Call in model with User.current_user
User.current_user = self.current_user
end
end
@brand-it
brand-it / error_form_builder.rb
Created April 1, 2010 02:58
It takes the error messages and moves them next to the label. Only show one error at a time pure field.
class ErrorFormBuilder < ActionView::Helpers::FormBuilder
#Adds error message directly inline to a form label
#Accepts all the options normall passed to form.label as well as:
# :hide_errors - true if you don't want errors displayed on this label
# :additional_text - Will add additional text after the error message or after the label if no errors
def label(method, text = nil, options = {})
#Check to see if text for this label has been supplied and humanize the field name if not.
text = text || method.to_s.humanize
#Get a reference to the model object
object = @template.instance_variable_get("@#{@object_name}")
@brand-it
brand-it / application_controller.rb
Created April 1, 2010 03:00
It is a creative way to create access levels for the admin and any other type of users. Very scalable.
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
# Make sure that all the methods that redirect are handled in the controllers.
class ApplicationController < ActionController::Base
include AuthenticatedSystem
include Userstamp
include ExceptionLoggable
local_addresses.clear
@brand-it
brand-it / import.rake
Created April 1, 2010 02:55
This is a cool little image importer for web sites kinda out dated but still useful. Used as a rake.
namespace :images do
require 'action_controller'
require 'action_controller/test_process.rb'
require 'find'
desc "Imports all the images into the database as well as formats the for your use."
task :import => :environment do
cards = Array.new
Card.find(:all).map do |t|
cards << ["#{t.name}"]
@brand-it
brand-it / application_helper.rb
Created June 24, 2011 06:04
This is kinda of a basic little helper to tell you if the page that you are on is the one you were looking for
module ApplicationHelper
# A nice way to help the views tell if you are on the current page you want to be on.
def current_view(params, options = {})
results = options[:result] || "true"
valid = true
options.each do |option|
for param in params
@brand-it
brand-it / photo_uploader.rb
Created July 8, 2011 07:38
I am Loving CarrierWave and thought I would share the code I am using on r3dux.net. I have loved its connection information for S3.
# encoding: utf-8
class PhotoUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
if RAILS_ENV == "development"
storage :file