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
| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| # Readable and fast | |
| require 'benchmark' | |
| class FizzBuzz | |
| FIZZ = 'Fizz'.freeze | |
| BUZZ = 'Buzz'.freeze |
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_relative './player.rb' | |
| # Represents the game. Manages the flow of the game and players' turns. | |
| class Game | |
| attr_reader :player1, :player2 | |
| # Initializes a new game with two players and a specified board size. | |
| # | |
| # @param board_size [Integer] the size of the game board. | |
| def initialize(board_size = 10) |
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
| bob = Person.new('Bob', 'Smith', 'bob@example.com', '444-333-4444') | |
| john = Person.new('John', 'Smith', 'john@example.com', '555-444-3333') | |
| # full_nane is a public method | |
| bob.full_name | |
| # => "Smith, Bob" | |
| john.full_name | |
| # => "Smith, John" | |
| # email is a protected method. |
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 'forwardable' | |
| require_relative 'securities' | |
| class Bursty | |
| extend Forwardable | |
| def_delegators :securities, :companies, :symbols | |
| MONTHS = %w(January February March April May June July August September October November December) | |
| YEARS = (2007..2017).map(&:to_s) |
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
| FROM ubuntu:16.04 | |
| RUN apt-get update && \ | |
| apt-get -y upgrade && \ | |
| apt-get install -y build-essential && \ | |
| apt-get install -y software-properties-common && \ | |
| apt-get install -y vim curl git man unzip wget && \ | |
| apt-get install -y net-tools iputils-ping apache2 apache2-utils | |
| RUN apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "` & \ |
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
| class Customer < ActiveRecord::Base | |
| include Concerns::ResourceBuilder | |
| self.ref_type_key = :customer | |
| self.table_name = "D_customer" | |
| self.primary_key = 'pkId' | |
| scope :states, -> (list) { where(state: list.split(',').map(&:strip)) } | |
| 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
| tree = [ | |
| // branch eles | |
| [ | |
| // spouse ele | |
| [] | |
| // spouse ele | |
| [], | |
| // spouse ele | |
| [], | |
| // branch eles |
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
| // relation = ['Mother', 'Father', 'Son', 'Daughter', etc] | |
| { | |
| "name": "", | |
| "relation": "", | |
| "branch": [ | |
| "name": "", | |
| "relation": "", | |
| "branch": [ | |
| "name": "", | |
| "relation": "", |
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
| def create_tag(tag, **args) | |
| attributes = args.map { |k,v| " #{k}=\"#{v}\"" }.join | |
| block = yield if block_given? | |
| "<%s%s>%s</%s>" % [tag, attributes, block, tag] | |
| 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
| =begin | |
| a | |
| / \ | |
| b c | |
| / / \ | |
| d e f | |
| tree = ['a', ['b', 'd' ], ['c', 'e', 'f']] |
NewerOlder