This file contains hidden or 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
| puts 'Enter maximum range of Fibonacci sequence:' | |
| num = gets.chomp.to_i | |
| def fib(num) | |
| sum = 0· | |
| first = 0 | |
| second = 1 | |
| even = 0 | |
| (1..num).each do |i| |
This file contains hidden or 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 'prime' | |
| p 'enter number:' | |
| num = gets.chomp.to_i | |
| def prime(num) | |
| pfactor = num.prime_division | |
| puts "The largest prime factor of #{num} is #{pfactor.last[0]}." | |
| end |
This file contains hidden or 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 'mongo' | |
| require 'mysql' | |
| include Mongo | |
| mongo_connection = MongoClient.new("localhost", 27017) | |
| itunes_db = mongo_connection.db("itunes") | |
| @collection = itunes_db["itunes"] |
This file contains hidden or 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
| # libraries that must be installed before use | |
| require 'rubygems' | |
| require 'sinatra' | |
| require 'mongo' | |
| require 'json/ext' | |
| require 'date' | |
| # create mongo instance | |
| include Mongo |
This file contains hidden or 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
| source = $("#id_on_handlebars_script_tag").html() | |
| template = Handlebars.compile source | |
| $.getJSON('some route to json markup', (data)-> | |
| $("#content_placeholder").html(template data) | |
| ).error -> | |
| console.log "error" |
This file contains hidden or 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
| <link rel="import" href="../core-scaffold/core-scaffold.html"> | |
| <link rel="import" href="../core-header-panel/core-header-panel.html"> | |
| <link rel="import" href="../core-menu/core-menu.html"> | |
| <link rel="import" href="../core-item/core-item.html"> | |
| <link rel="import" href="../core-icon-button/core-icon-button.html"> | |
| <link rel="import" href="../core-toolbar/core-toolbar.html"> | |
| <link rel="import" href="../core-menu/core-submenu.html"> | |
| <polymer-element name="my-element"> |
This file contains hidden or 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
| '%03d' % 1 # 001 |
This file contains hidden or 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 'capybara' | |
| class PizzaOrderer | |
| def initialize | |
| @session = Capybara::Session.new(:selenium) | |
| end | |
| def order_pizza | |
| open_pizza_page | |
| if @session.has_content?('Papa') |
This file contains hidden or 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
| <img src="broken_image.png" onerror="this.src='fallback_image_path.png'" /> |
This file contains hidden or 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 'Date' | |
| puts DateTime.now.strftime("%Y-%j") |