Skip to content

Instantly share code, notes, and snippets.

<h1><%= markdown_to_html @post.title %></h1>
<div class="row">
<div class="col-md-8">
<small>
<%= image_tag(@post.user.avatar.tiny.url) if @post.user.avatar? %>
submitted <%= time_ago_in_words(@post.created_at) %> ago by
<%= @post.user.name %>
@beaugaines
beaugaines / init_vs_accessor.rb
Created October 8, 2015 05:24
Initialize vs attr_accessor
class Dog
def initialize(breed, color)
@breed, @color = breed, color
end
def describe_me
"I am a #{@breed} and I am #{@color}"
end
end
@beaugaines
beaugaines / domain_modeling
Created October 28, 2015 16:29
homebrew_domain_modeling
User
has_many :recipes
- email
- name
- location
Recipe
belongs_to :user
has_many :recipe_fermentables
@beaugaines
beaugaines / devise_to_haml.sh
Created November 11, 2015 02:50
convert devise views to haml
for f in app/views/devise/**/*.erb; do html2haml -e $f ${f%erb}haml && rm $f; done
@beaugaines
beaugaines / contact_data.tsv
Created May 18, 2016 15:27
tsv contact data
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
First Name Last Name Email Address Phone Number Company Name
Gerhard Kautzer [email protected] 1-207-643-1816 Hodkiewicz-Lynch
Myra Crona [email protected] (724)196-9470 x998 Champlin-Hahn
Josh Donnelly [email protected] 081-799-3139 x248 Casper Group
Verna Farrell [email protected] 731.101.6219 Rosenbaum-Hane
Lauriane Stracke [email protected] 1-033-511-1831 x471 Prohaska-Sporer
Kaya Luettgen [email protected] (511)745-9273 Wyman, Trantow and Hane
Steve Davis [email protected] 787.315.2611 x747 Kuhic-Lowe
Citlalli Pfeffer [email protected] 329-584-6962 x047 Gorczany and Sons
Litzy Turcotte [email protected] 1-084-641-4078 x4410 Hintz-Schmitt
@beaugaines
beaugaines / sass_random_colors.scss
Created May 22, 2016 16:43
random colors in sass
@mixin random-color($selector) {
#{$selector}: unquote("rgba(#{random(256) - 1}, #{random(256)-1}, #{random(256 - 1)}, #{random(100)/100})");
}
$tags: (h1, h2, h3, h4, h5, p, li, a, strong, small, em);
@each $tag in $tags {
#{$tag} {
@include random-color('color');
}
@beaugaines
beaugaines / show.html.erb
Created July 8, 2016 17:18
complete items with checkbox
<% @items.each do |item| %>
<p>
<%= item.name %>
<%= form_for [current_user, item], method: :delete do |f| %>
<%= check_box_tag :complete, nil, false, onclick: "this.form.submit()" %>
<%= label_tag :complete, 'Complete' %>
<% end %>
</p>
<% end %>
<% flash.each do |k,v| %>
<div class="alert alert-<%= k == 'notice' ? 'info' : 'danger' %> fade in">
<button class="close" data-dismiss="alert">
<i class="fa fa-fw fa-info"></i>
<strong><Info><%= k %>!</strong> <%= raw(v) %>
</button>
</div>
<% end %>

Checkpoint:

git checkout -b branch-name
git status (use often as needed)
git add .
git commit -m "Description"

git checkout master
git merge branch-name
class TopicsController < ApplicationController
before_action :require_sign_in, except: [:index, :show]
before_action :authorize!, except: [:index, :show]
def index
@topics = Topic.all
end
def new
@topic = Topic.new