This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @pg_searches.each do |pg_search| %> | |
<% if pg_search.searchable.class == Book %> | |
<p> <%= link_to pg_search.searchable.title, pg_search.searchable %></p> | |
<% elsif pg_search.searchable.class == Chapter %> | |
<p> <%= link_to pg_search.searchable.title, [pg_search.searchable.book, pg_search.searchable] %></p> | |
<% end %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: Collect all of the H2's into a variable | |
$headings = $("h2") | |
// Step 2: Iterate through them and add some text | |
$.each($headings, function(index, value){ | |
$("#toc-container").append("<li>" + $(value).html() +"</li>") | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#timeofday").change(function(){ | |
console.log($(this).text) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*= require_self | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This expects an input like: | |
<select data-id=<%= ri.id %> ...other stuff...></select> | |
$(".some-input").change(function(){ | |
var ri_id = $(this).data('id') | |
data = { | |
amount : $(this).val() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script> | |
$.each($(".google-place"), function(index, value) { | |
var autocomplete = new google.maps.places.Autocomplete(value); | |
google.maps.event.addListener(autocomplete, 'place_changed', function() { | |
var place = autocomplete.getPlace(); | |
window.foo = place |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sorting | |
def sort_by_length(array) | |
array.sort { |x, y| x.length <=> y.length } | |
end | |
def filter(array) | |
array.select { |v| v > 5 } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnitedStatesPresident | |
include Presidential | |
def self.citizenship | |
"The United States of America" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_to_array(h ={}) | |
a = [] | |
h.each do |key, value| | |
a << key + value | |
end | |
a | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calculator | |
def self.description | |
"Performs basic mathematical operations" | |
end | |
# def instance methods | |
# calc = Calculator.new(7,2) | |
# end | |
def initialize(x, y) |