Skip to content

Instantly share code, notes, and snippets.

View rolandobrown's full-sized avatar

Rolando Brown rolandobrown

View GitHub Profile
@rolandobrown
rolandobrown / aretha_spec.rb
Created August 25, 2015 11:53
Aretha RSpec
# aretha_spec.rb
require_relative '../aretha.rb' #connect test to code
aretha = Aretha.new
RSpec.describe Aretha do
describe "#done_you_wrong!" do
it "ain't gonna do you wrong while you're gone" do
expect(aretha.done_you_wrong!).not_to be_truthy
end
@rolandobrown
rolandobrown / aretha.rb
Created August 25, 2015 11:51
Aretha.rb
class Aretha
def done_you_wrong!
false
end
def wanna_do_you_wrong(truth)
@truth = truth
false unless truth != "False"
@rolandobrown
rolandobrown / shouldbe_expect.rb
Created August 25, 2015 09:46
RSpec Syntax should_be Expect
Old: my_object.should_not_be_a_kind_of(Foo)
New: expect(my_object).not_to be_a_kind_of(Foo)
@rolandobrown
rolandobrown / new_gist_file_0
Last active August 29, 2015 14:28
RSpec Help
rspec --help
@rolandobrown
rolandobrown / install_rspec.rb
Created August 25, 2015 09:41
install RSpec
$ gem install rspec
@rolandobrown
rolandobrown / aretha_spec.rb
Last active August 29, 2015 14:28
Aretha 1
# aretha_spec.rb
require_relative 'aretha.rb' #connect test to code
aretha = Aretha.new
RSpec.describe Aretha do
describe "#done_you_wrong!" do
it "ain't gonna do you wrong while you're gone" do
expect(aretha.done_you_wrong!).not_to be_truthy
end
@rolandobrown
rolandobrown / ruby.rb
Created August 11, 2015 18:58
Ruby Final Projects (CLI-Group 12)
# require 'net/http'
require_relative "./key.rb"
require 'rest-client'
# require 'pry'
nytimes_today_json = RestClient.get("http://api.nytimes.com/svc/search/v2/articlesearch.json?callback=svc_search_v2_articlesearch&q=love&begin_date=20150811&end_date=20150811&hl=true&api-key=#{NYT}")
today_parsed = JSON.parse(nytimes_today_json)
# nytimes_20140811_json = RestClient.get("http://api.nytimes.com/svc/search/v2/articlesearch.json?callback=svc_search_v2_articlesearch&q=love&begin_date=20140811&end_date=20150811&hl=true&api-key=$NYT")
# 20140811_parsed = JSON.parse(nytimes_20140811_json)
@rolandobrown
rolandobrown / slang_regular.rb
Last active August 29, 2015 14:27
Slang Expressions != Regular Expressions
"Slang Expressions" != "Regular Expressions"
"Regular Expressions" != ["Bam!", "Aw, man!"]
#Give thanks for the Brolic Scholars, those Honorary Sociolinguistic Prodigies.
@rolandobrown
rolandobrown / hiphop_elements.rb
Last active August 29, 2015 14:27
A method that numbers an array of Hip-Hop Elements as expressed by Kool D.J. Herc and Afrikka Bambatta. Note, this does not include the 9 Refinitions established by KRS-One. Also, big love to Pebblee Poo.
# This method numbers the array of Hip-Hop Elements as expressed by Kool D.J. Herc and Afrikka Bambatta.
# Note, this does not include the 9 Refinitions established by KRS-One. Also, big love to Pebblee Poo.
elements = ["Breaking", "Mc'ing", "Graffiti Art", "DJ'ing", "Knowledge"]
def hip_hop_culture(elements)
elements.map.with_index(1) { |elements, idx| puts "#{idx}. #{elements}"}
# with_index(offset = 0) {|(*args), idx| ... }
end
@rolandobrown
rolandobrown / gsub_regexp.rb
Created August 11, 2015 05:55
Example of gsub & regexp
def alias
# kinda colorful transformations using gsub & regexp
@chorus.gsub(/(wu(-|\s)tang\sclan)/i,
@name).gsub(/motherfucking slums/i,
@switchup).gsub(/fuck/i,
@aka).gsub(/busted/i, "trusted")
end