Skip to content

Instantly share code, notes, and snippets.

View bryanaknight's full-sized avatar
💅
making github on github

Bryana Knight bryanaknight

💅
making github on github
View GitHub Profile
@bryanaknight
bryanaknight / tabbed columns
Created September 19, 2013 01:16
Tabbed columns
def queue_print
puts @queue.to_s.upcase
puts "LAST_NAME".ljust(15)+"FIRST_NAME".ljust(15)+"EMAIL".ljust(50)+"ZIPCODE".ljust(15)+"CITY".ljust(30)+"STATE".ljust(15)+"ADDRESS".ljust(50)+"PHONE".ljust(15)
@queue.each do |row|
puts row[:last_name].ljust(15)+row[:first_name].ljust(15)+row[:email_address].ljust(50)+row[:zipcode].ljust(15)+row[:city].ljust(30)+row[:state].ljust(15)+row[:street].ljust(15)+"#{@phonenumber}"
end
# print @queue[0]
end
@bryanaknight
bryanaknight / gist:7077604
Last active December 26, 2015 02:19
Scrabble
class Scrabble
def initialize
SCORES = {"A"=>1, "B"=>3, "C"=>3, "D"=>2, "E"=>1, "F"=>4, "G"=>2, "H"=>4, "I"=>1, "J"=>8,
"K"=>5, "L"=>1, "M"=>3, "N"=>1, "O"=>1, "P"=>3, "Q"=>10, "R"=>1, "S"=>1, "T"=>1,
"U"=>1, "V"=>4, "W"=>4, "X"=>8, "Y"=>4, "Z"=>10}
end
def self.score(word)
SCORES[word.upcase]
end
@bryanaknight
bryanaknight / gist:7296659
Created November 4, 2013 01:05
Blogger controller test
require 'test_helper'
class ArticlesControllerTest < ActionController::TestCase
test "index method lists all articles" do
Article.create(title: "First", body: "Body")
Article.create(title: "Second", body: "Body")
articles = Article.all
assert_equal 2, articles.count
#when I run rake, getting 4 articles instead of 2
return true if number.even?
else
return false
vs.
def test_count_one_word
phrase = Phrase.new("word")
counts = {"word" => 1}
assert_equal counts, phrase.word_count
class Hamming
def self.compute(sequence1, sequence2)
sequence1 = sequence1.split('')
sequence2 = sequence2.split('')
sequence1.zip(sequence2).count do |string_a, string_b|
self.substitution?(string_a, string_b)
end
end
@bryanaknight
bryanaknight / gist:7918800
Created December 11, 2013 21:30
Cart test
describe "adding items and viewing cart" do
it "has unique cart for each restaurant" do
new_restaurant = FactoryGirl.create(:restaurant)
new_item = FactoryGirl.create(:item, restaurant_id: new_restaurant.id)
visit "/#{new_restaurant.slug}"
click_on('Add to Cart')
expect(page).to have_content("Bacon")
new_restaurant2 = FactoryGirl.create(:restaurant, title: "Parsley", description: "blah balh")
new_item2 = FactoryGirl.create(:item, restaurant_id: new_restaurant2.id, title: "brown fried food", description: "fried brown food")
require 'oauth'
require 'json'
require 'pp'
CONSUMER_KEY = OAuth::Consumer.new(
'qLqLjhVG6TQDesSYnT3bw',
'9Zw1OIB17651BMZUEsRlA5CKk3qG1MJclzr0f0Qq0')
ACCESS_TOKEN = OAuth::Token.new(
'321130543-9SPLOfIzXbHDuWnaZSyBBm3ctix0xrh6REooGZSd',
runtime! autoload/pathogen.vim
syntax on
filetype plugin indent on
set visualbell
set wildmenu
set wildmode=list:longest,full
@bryanaknight
bryanaknight / gist:e811521d21caeae9465a
Created February 10, 2016 21:00
search test failures
1) Failure:
Api::SearchTest#test__search_issues_sort_issues_in_ascending_order_L936 [/Users/bryanaknight/github/github/test/integration/api/search_test.rb:941]:
Expected: 2
Actual: 0
2) Failure:
Api::SearchTest#test__search_issues_include_issues_in_private_repo_for_integration_bot_with_access_to_the_repo_s_issues__with_search_scoped_to_that_repo_L853 [/Users/bryanaknight/github/github/test/integ$
ation/api/search_test.rb:865]:
Expected: 1
Actual: 0
module GitHub
class Cache
def fetch(*opts)
opts[:cache_key].prepend current_tenant.id
super(opts)
end
def get(*opts)
opts[:cache_key].prepend current_tenant.id