Skip to content

Instantly share code, notes, and snippets.

View barnes7td's full-sized avatar

Timothy Barnes barnes7td

  • CleanSlate
  • Indianapolis, IN
View GitHub Profile
@barnes7td
barnes7td / email.rb
Last active August 29, 2015 13:55
FactoryGirl factory for griddler email
FactoryGirl.define do
factory :email, class: OpenStruct do
# to [{ full: 'to_user@email.com', email: 'to_user@email.com', token: 'to_user', host: 'email.com', name: nil }]
# from 'user@email.com'
subject 'email subject'
body 'Hello!'
end
end
source 'https://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'sqlite3'
end
class Array
def sum_numbers
total = 0
self.each do |n|
p "#{total} + #{n} = #{total+n}"
total = total + n
end
total
end
end
@barnes7td
barnes7td / montensia_seed_file.rb
Last active August 29, 2015 13:56
Fixed Seed File
require 'faker'
#Create 15 topics
topics = []
15.times do
topics << Topic.create(
name: Faker::Lorem.words(rand(1..10)).join(" "),
description: Faker::Lorem.paragraph(rand(1..4))
)
end
require 'faker'
# Create 15 topics
topics = []
15.times do
topics << Topic.create(
name: Faker::Lorem.sentence,
description: Faker::Lorem.paragraph
)
end
@barnes7td
barnes7td / hamming_original.rb
Created June 14, 2014 00:07
Exercism.io Hamming
class Hamming
def self.compute(first_gene, second_gene)
length = first_gene.length < second_gene.length ? first_gene.length : second_gene.length
score = 0
(0..(length - 1)).each do |index|
score += 1 unless first_gene[index] == second_gene[index]
end
score
end
end
@barnes7td
barnes7td / gist:59a99562847a4ec6a3b0
Created November 7, 2014 15:25
[UI] Refactor HTML methods for grid out of Update Title Controller.

I moved all the files associated with update_title to a update_title directory. These files include:

client/app/components/floorplan/update_title/update_title.js client/app/components/floorplan/update_title/update_title_address_hold.js client/app/components/floorplan/update_title/update_title_address_hold_test.js client/app/components/floorplan/update_title/update_title_formatter.js client/app/components/floorplan/update_title/update_title_formatter_test.js client/app/components/floorplan/update_title/update_title_modal.html client/app/components/floorplan/update_title/update_title_service.js client/app/components/floorplan/update_title/update_title_service_test.js

@barnes7td
barnes7td / index.html.erb
Created November 12, 2014 13:06
index page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Framework Test Page</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" src="//normalize-css.googlecode.com/svn/trunk/normalize.css">
<link href='http://fonts.googleapis.com/css?family=Indie+Flower' rel='stylesheet' type='text/css'>
</head>
<body>
- @items.each do |item|
= item.name
= link_to "", [item.list, item], method: :delete, { class: 'glyphicon glyphicon-ok', id: "item-#{item.id}" }, remote: true
%br/
@barnes7td
barnes7td / longest_word.rb
Last active August 29, 2015 14:17
Longest Word
# Dan Oliphant's version
# More Concise version [Tested and works! :) ]
def longest_word(sentence)
sorted_sentence_as_array = sentence.split(" ").sort_by { |s| s.length }.reverse
max = sorted_sentence_as_array.first.length
sorted_sentence_as_array.select { |w| w.length == max }
end
# Cool. I will check this out.