Skip to content

Instantly share code, notes, and snippets.

View mcelaney's full-sized avatar

Brian E. McElaney mcelaney

View GitHub Profile
@mcelaney
mcelaney / FriendlyId with scaffolds and RSpec
Last active September 29, 2015 12:07
Note on altering the show action using FriendlyId with scaffolds and RSpec
# Note on altering the show action using FriendlyId with scaffolds and RSpec
# Ran into an issue while following http://railscasts.com/episodes/314-pretty-urls-with-friendlyid
# GET /articles/1
# GET /articles/1.json
def show
@article = Article.find(params[:id])
if request.path != article_path(@article)
redirect_to @article, status: :moved_permanently
end
@mcelaney
mcelaney / gist:5547395
Created May 9, 2013 13:19
Seed data for a fast example Rails app
shelf1 = Shelf.create!(name: "Top Shelf")
shelf2 = Shelf.create!(name: "Bottom Shelf")
author1 = Author.create!(first_name: "James", last_name:"Patterson")
author1.books.create!(title: "12th of Never (Women's Murder Club", shelf: shelf1)
author1.books.create!(title: "Alex Cross, Run", shelf: shelf2)
author1.books.create!(title: "Middle School: Get Me out of Here!", shelf: shelf2)
author1.books.create!(title: "Middle School: My Brother Is a Big", shelf: shelf1)
author1.books.create!(title: "11th Hour (Women's Murder Club)", shelf: shelf1)
@mcelaney
mcelaney / GitNamingConvention.markdown
Last active September 18, 2022 13:29
Git Naming Convention

A git workflow

The flexibility of a distributed version control system can make deciding on a branching strategy somewhat difficult. Tons has been written on git workflows - one writeup that I love is Atlassian Blog's Simple Git workflow is simple. You really don't need much else if you're working on your own - but if you're on a more complex project or working with a team there are some additions I'd add to keep things organized. Here is a description of my typical naming conventions:

The Develop Branch

The development branch is where all functionality is gathered during a sprint. It is the second branch created during a project (after Master) and does not merge back to anything. No code should be committed directly to the develop branch (you should ALWAYS work on a branch), no code should be committed to develop without a code review, and develop should remain as defect free as possible. Treat develop as

source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'sqlite3'
gem 'bcrypt-ruby'
gem 'haml-rails'
gem 'sass-rails', '~> 4.0.2'
gem 'uglifier'
@mcelaney
mcelaney / spec_helper.rb
Created April 25, 2014 19:28
Spec Helper Example
require 'simplecov'
SimpleCov.start 'rails'
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
@mcelaney
mcelaney / the_ladies
Created February 25, 2015 21:21
Who I would nominate to https://github.com/amirahaile/Amazing-Women-on-Twitter if I could leave whitespace in a file...
## Aisha Blake
[@AishaBlake](https://twitter.com/AishaBlake)
Operations Manager at Grand Circus. Freelance web developer and teacher engaged in the Detroit community and continuing to find new ways to further my own education.
## Anna Pawlicka
[@AnnaPawlicka](https://twitter.com/AnnaPawlicka)
Programmer. Hiker. Cook. Always looking for interesting problems to solve.
## Buffy Miller
[@buffym](https://twitter.com/buffym)

Associations in Rails

belongs_to


| Orders | _____________ | - id | | Customers | | - customer_id | -----------> | - id |


@mcelaney
mcelaney / keybase.md
Created June 5, 2015 13:41
keybase.md

Keybase proof

I hereby claim:

  • I am mcelaney on github.
  • I am mcelaney (https://keybase.io/mcelaney) on keybase.
  • I have a public key whose fingerprint is EEAA 53D8 1D69 756B C5CC 4E49 70B4 9AE4 C095 1B50

To claim this, I am signing this object:

# `Coding Test : Hamming Distance
# Write a program that can calculate the Hamming distance between two DNA
# strands.
#
# A mutation is simply a mistake that occurs during the creation or copying of a
# nucleic acid, in particular DNA. Because nucleic acids are vital to cellular
# functions, mutations tend to cause a ripple effect throughout the cell.
# Although mutations are technically mistakes, a very rare mutation may equip
# the cell with a beneficial attribute. In fact, the macro effects of
# evolution are attributable by the accumulated result of beneficial
April 11, 2016
10:15 - Salon A David Ferrucci: Salon A - AI: A Return to Meaning
11:30 - Salon D James Roper: Rethinking REST in a Microservices World
13:30 - Salon C Yehuda Katz: Stability Without Stagnation: Lessons Learned Shipping Ember
14:45 - Salon A Evan Chan: NoLambda: A new architecture combining streaming, ad hoc, machine learning, and batch analytics
16:00 - Salon D Jean Yang: Securing Software by Construction
April 12, 2016
08:45 - Salon D Bryan Helmkamp: Code Quality in Practice
10:15 - Salon A Raffi Krikorian: How Your Organization is Killing your Software