Skip to content

Instantly share code, notes, and snippets.

View edezekiel's full-sized avatar

Edward Ezekiel edezekiel

View GitHub Profile
@edezekiel
edezekiel / pry-blog.rb
Created November 5, 2018 18:37
binding-pry-blog
require 'pry'
class Car
def initialize
@classification = "A Car"
binding.pry
end
def describe
"I am #{@classification}, of make #{@make}"
@edezekiel
edezekiel / pry-in-loop.rb
Created November 5, 2018 18:50
Using Pry in Loops
def student_serial(i)
new_hash = {}
i.each_with_index do |value, index|
# we will add a conditional pry to
# start a session when our value is nil
binding.pry if value.nil?
new_hash["#{value}"] = index
end
@edezekiel
edezekiel / inside-pry.rb
Created November 6, 2018 11:58
Inside-Pry
[06:57:06] ~
// ♥ Pry
[1] pry(main)> whereami
At the top level.
[2] pry(main)> cd Pry
[3] pry(Pry):1> whereami
Inside Pry.
[4] pry(Pry):1>
@edezekiel
edezekiel / pry-show-docs.rb
Last active November 6, 2018 13:55
Pry-show-docs
[07:11:51] ~
// ♥ Pry
[1] pry(main)> cd Pry
[2] pry(Pry):1> ?
From: /Users/edwardezekiel/.rvm/gems/ruby-2.3.3/gems/pry-0.11.3/lib/pry/pry_instance.rb @ line 2:
Class name: Pry
Number of monkeypatches: 6. Use the `-a` option to display all available monkeypatches
Number of lines: 22
@edezekiel
edezekiel / pry-show-source.rb
Last active November 6, 2018 13:54
Pry-Show-Source
[07:13:00] ~
// ♥ Pry
[1] pry(main)> cd Pry
[2] pry(Pry):1> $
From: /Users/edwardezekiel/.rvm/gems/ruby-2.3.3/gems/pry-0.11.3/lib/pry/pry_instance.rb @ line 24:
Class name: Pry
Number of monkeypatches: 6. Use the `-a` option to display all available monkeypatches
Number of lines: 643
@edezekiel
edezekiel / activerecord-association
Created November 20, 2018 14:40
example of activerecord association
class Band < ActiveRecord::Base
has_many :sessions
has_many :concerts, through: :sessions
end
@edezekiel
edezekiel / nokogiri-example
Created November 24, 2018 13:49
nokogiri-example
def get_category
doc = Nokogiri::HTML(open("https://www.ruby-toolbox.com"))
doc.css(".category-group").each do |category|
puts category.css("h3").text
end
get_subcategory_screen
end
@edezekiel
edezekiel / form_for.html.erb
Last active November 30, 2018 19:40
example form_for and collection select to build a new employee form
#app/view/new.html.erb
<%= form_for @employee do | f | %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :dog %>
<%= f.collection_select :dog_id, @dogs, :id, :name %>
<%= f.submit %>
<% end %>
@edezekiel
edezekiel / fetch.js
Created December 21, 2018 13:22
fetch-example
fetch(url)
.then((resp) => resp.json()) // Transform the data into json
.then(function(data) {
// Create and append the li's to the ul
})
})
@edezekiel
edezekiel / fetchlineone.js
Created December 21, 2018 13:23
fetch line one
fetch(url)