Skip to content

Instantly share code, notes, and snippets.

View bearettoaks's full-sized avatar

Bearett Oaks bearettoaks

View GitHub Profile
@bearettoaks
bearettoaks / ghosting.rb
Last active May 1, 2017 21:54
Ghosting as a user
# config/routes.rb
resource :ghost, only: [:create, :destroy]
# app/controllers/ghosts_controller.rb
class GhostsController < ApplicationController
def create
session[:admin_id] = current_user.id
user = User.find(params[:user_id])
sign_in user
@bearettoaks
bearettoaks / .pryrc
Created March 14, 2017 19:07
Custom Environment Consoles
# .pryrc
color_escape_codes = {
black: "\033[0;30m",
red: "\033[0;31m",
green: "\033[0;32m",
yellow: "\033[0;33m",
blue: "\033[0;34m",
purple: "\033[0;35m",
cyan: "\033[0;36m",
reset: "\033[0;0m"
@bearettoaks
bearettoaks / modal.html.slim
Created March 9, 2017 19:27
Bootstrap slim modal
/! Modal
#myModal.modal.fade aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog role="document"
.modal-content
.modal-header
button.close aria-label="Close" data-dismiss="modal" type="button"
span aria-hidden="true" &times;
h4#myModalLabel.modal-title Modal title
.modal-body
| \...
@bearettoaks
bearettoaks / modal.html.slim
Created March 9, 2017 19:27
Bootstrap slim modal
/! Modal
#myModal.modal.fade aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog role="document"
.modal-content
.modal-header
button.close aria-label="Close" data-dismiss="modal" type="button"
span aria-hidden="true" &times;
h4#myModalLabel.modal-title Modal title
.modal-body
| \...
@bearettoaks
bearettoaks / laptop
Created February 11, 2017 21:43
Shell script to setup a rails development machine
#!/bin/sh
# exit on any error
set -e
echo | echo "$(tput setaf 3)Setting up machine for Ruby on Rails development\n\n"
echo "$(tput setaf 3)Installing laptop setup..."
echo "$(tput setaf 7)"
curl --remote-name https://raw.githubusercontent.com/thoughtbot/laptop/master/mac
sh mac 2>&1
@bearettoaks
bearettoaks / tmux.hybrid
Created January 18, 2017 05:57
tmux hybrid color scheme
## color sheme: hybrid
# default statusbar colors
set-option -g status-bg colour0 #base02
set-option -g status-fg colour6 # colour100 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour13 #base0
set-window-option -g window-status-bg default
@bearettoaks
bearettoaks / ruby_methods
Created January 17, 2017 19:52
Ruby methods for interview process.
# method 1
# returns members of the Fibonacci series up to a certain value
def method_one(max)
i1, i2 = 1, 1
while i1 <= max
yield i1
i1, i2 = i2, i1+i2
end
end
# demo.gemspec
Gem::Specification.new do |spec|
spec.name = "Demogem"
spec.version = "1.0.2"
spec.authors = ["Carl Weis"]
spec.email = ["carl@carlweis.com"]
spec.description = %q{A Ruby library for a demo app.}
spec.summary = %q{Demo Gem Library}
spec.homepage = "http://carlweis.com/gems/demo"
spec.license = "MIT"
set nocompatible " be iMproved, required
so ~/.vim/plugins.vim " load vundle plugins
syntax enable
"-------------General Settings--------------"
set backspace=indent,eol,start "Make backspace behave like every other editor.
let mapleader = ',' "The default leader is \, but a comma is much better.
@bearettoaks
bearettoaks / form_helper.rb
Created January 23, 2016 20:19
Rails Twitter Boostrap form helper.
module FormHelper
def errors_for(form, field)
content_tag(:p, form.object.errors[field].try(:first), class: 'help-block')
end
def form_group_for(form, field, &block)
has_errors = form.object.errors[field].present?
content_tag :div, class: "form-group #{'has-error' if has_errors}" do
concat form.label(field, class: 'control-label')