Skip to content

Instantly share code, notes, and snippets.

View rolandobrown's full-sized avatar

Rolando Brown rolandobrown

View GitHub Profile
@rolandobrown
rolandobrown / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rolandobrown
rolandobrown / group.rb
Last active August 29, 2015 14:26 — forked from panthomakos/group.rb
Improved Custom Error Messages in Ruby
class Group
module Error
class Standard < StandardError; end
class AlreadyAMember < Standard; end
class NotPermittedToJoin < Standard; end
end
def join user
raise Error::NotPermittedToJoin unless self.permitted?(user)
raise Error::AlreadyAMember if self.member?(user)
puts "I grew up understanding that Wu-Tang Is Forever, never to be imitated or duplicated. This is simply an example of using gsub & regular expressions."
@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
@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 / 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 / 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 / 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 / install_rspec.rb
Created August 25, 2015 09:41
install RSpec
$ gem install rspec
@rolandobrown
rolandobrown / new_gist_file_0
Last active August 29, 2015 14:28
RSpec Help
rspec --help