Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
😎
losing my sight, losing my mind, go to the general to save some time

Tom Scott tubbo

😎
losing my sight, losing my mind, go to the general to save some time
View GitHub Profile
def insert_flash
content_tag :div, class: 'flash' do
flash.each do |name, msg|
if msg.is_a?(String)
concat( content_tag( :div, class: "fade in alert alert-#{ flash_type_to_bootstrap(name) }") do
concat( button_tag( "×".html_safe, class: "close", "aria-hidden" => true, "data-dismiss" => "alert" ) )
concat( content_tag :div, msg, :id => "flash_#{name}" )
end )
end
end
<%= form_for @project do |f| %>
<% if @project.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@project.errors.count, "error") %> prohibited
this project from being saved:</h2>
<ul>
<% @project.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>

Keybase proof

I hereby claim:

  • I am tubbo on github.
  • I am tubbo (https://keybase.io/tubbo) on keybase.
  • I have a public key whose fingerprint is 36EF CE58 007F FC36 676E A414 A022 AB3D 5CEA 7017

To claim this, I am signing this object:

7 class ChargeMailer < ActionMailer::Base
6 default :from => "mygmailaddress@gmail.com"
5
4 def registration_confirmation(cust)
3 @customer = cust
2 mail(:to => "#{cust.email}", :subject => "Your Order Confirmation")
1 end
0 end
~
require 'spec_helper'
describe User do
it "has a valid factory" do
build(:user).should be_valid
end
it "is invalid without an email" do
build(:user, email: nil).should_not be_valid
end
class CreateWords < ActiveRecord::Migration
def change
create_table :words do |t|
t.string :text
t.integer :frequency
t.integer :mistakes
t.timestamps
end
end
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :require_login
helper_method :current_user
private
---
BUNDLE_BIN: vendor/gems/bin
BUNDLE_PATH: vendor/gems
BUNDLE_DISABLE_SHARED_GEMS: '0'
BUNDLE_LOCAL__ACTIVE_COPY: "/Users/tscott/Code/active_copy"
BUNDLE_LOCAL__BOWERY: "/Users/tscott/Code/bowery"
module UsersHelper
#Returns the Gravatar for the given user.
def gravatar_for(user, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
image_tag(gravatar_url, alt: user.email, class: "img-responsive")
end
module UsersHelper
#Returns the Gravatar for the given user.
def gravatar_for(user, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
image_tag(gravatar_url, alt: user.email, class: "img-responsive")
end