- A function named
dogthat prints out "Woof!" to the screen. - A function named
catthat prints out "Meow." to the screen. - A function named
hello_namethat takes a string as input and prints out "Hello, name!" wherenameis the string given as input. - A function named
even?that takes a number as input and returns true if the number is evenly divisibly by 2 and false otherwise. - A function named
multiple_of?that takes 2 inputs. For example:multiple_of?(2, 4)returnstruebecause 4 is a multiple of 2 (2*2 = 4).multiple_of?(5, 32)returns false because 32 is not a multiple of 5. - A function named
countthat takes a number as input and prints out all the numbers between 0 and number to the screen. - A function named
multiplesthat takes a number as input, and returns an array containing all results of the given number multiplied by the numbers from 1 to 10. So formultiples(5)the result should be[5,10,15,20,25, ...]
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 'open-uri' | |
| def adj_sum(multi,x,y) | |
| sum = multi[x][y].to_i | |
| if x > 0 | |
| sum += multi[x-1][y].to_i | |
| end | |
| if x < 999 |
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
| public class SubordinateLoggingContext | |
| { | |
| private static string CONNECTIONSTRING = "mongodb://connotate:[email protected]:10002/ConnotateLogs"; | |
| MongoServer mongo; | |
| MongoDatabase db; | |
| MongoCollection collection; | |
| public SubordinateLog log; | |
| public SubordinateLoggingContext() |
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 'active_record' | |
| ActiveRecord::Base.logger = Logger.new(STDERR) | |
| ActiveRecord::Base.colorize_logging = false | |
| ActiveRecord::Base.establish_connection( | |
| :adapter => "sqlite3", | |
| :dbfile => ":memory:" | |
| ) |
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
| "Joe Letizia's awesome blog 2.0".parameterize | |
| # => "joe-letizia-s-awesome-blog-2-0" |
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
| module Example | |
| class Dog | |
| attr_reader :stomach | |
| def initialize(stomach) | |
| @stomach = stomach | |
| end | |
| def hungry? | |
| stomach.empty? |
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
| presenters.ClickerAlert = function(element) { | |
| $(element).on('click', showAlert); | |
| function showAlert(){ | |
| alert("Hey, you clicked me!"); | |
| } | |
| } | |
| (function($, ns) { | |
| ns('clicker-alert', { |
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
| # On the host machine, run | |
| tmux -S /tmp/foo | |
| chmod 777 /tmp/foo | |
| # From the remote machine | |
| ssh username@host | |
| tmux -S /tmp/foo attach |
- Write a function called
stop_signthat prints out the questionWhich way do you want to turn?and then takes keyboard input from the user. If the input equalsleftprintTurning left!. If the input equalsrightprintTurning right!. If the input is anything other than the two previous options, printCrash!!! - Write a function called
spacesthat takes a string as input. Return the number or spaces in the string as an integer.
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
| module Products | |
| # What if we want to differ the content between iOS and Web? | |
| class IndexResource | |
| def initialize(product_presenters, content_type) | |
| @product_presenters = product_presenters | |
| @content_type = content_type | |
| end | |
| def render(rendering_engine = RenderingEngine) | |
| rendering_engine.render(partial_path, product_presenters: product_presenters) |
OlderNewer