blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 4 137 | path stringlengths 2 355 | src_encoding stringclasses 31
values | length_bytes int64 11 3.9M | score float64 2.52 5.47 | int_score int64 3 5 | detected_licenses listlengths 0 49 | license_type stringclasses 2
values | text stringlengths 11 3.93M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
ca3204cd07d9229079e609a134f59af3a07d71b4 | Ruby | cldershem/nand2tetris | /10/nodes/subroutine_body_node.rb | UTF-8 | 434 | 2.515625 | 3 | [] | no_license | class SubroutineBodyNode < Struct.new(:vars, :statements)
def to_xml
builder = Builder::XmlMarkup.new
builder.subroutineBody do |xml|
xml.symbol('{')
vars.each do |var|
xml << var.to_xml
end
xml.statements do |statements_xml|
statements.each do |statement|
sta... | true |
7695e7912b44d0857652d62a3438d739352d626b | Ruby | ediliodev/hellop6idd | /app/controllers/lineats_controller.rb | UTF-8 | 27,615 | 2.734375 | 3 | [] | no_license | class LineatsController < ApplicationController
before_action :set_lineat, only: [:show, :edit, :update, :destroy, :cerrar]
# GET /lineats
# GET /lineats.json
def index
#@lineats = Lineat.all.today.order(:pelea) # SACAR LAS DE HOY OK.
@lineats = Lineat.all.today.sort_by { |a| + (a.pelea.to_i) } #no com... | true |
8aee72fdbcbad998b39050f3c5f2d9160e9a0f23 | Ruby | michaelirick/forecast | /app/models/services/forecast_service.rb | UTF-8 | 1,063 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
module Services
class ForecastService < Services::Base
def run
location = fetch_location
# binding.pry
return cached_forecast(location) unless location.forecast_expired?
new_forecast location
end
def fetch_location
Services::LocationService.ne... | true |
760d2ec7061745fdf57e88013a8515774fea6ac3 | Ruby | maurogs/shop-scheduler | /spec/models/schedule_spec.rb | UTF-8 | 2,252 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Schedule, type: :model do
let(:shop) { Shop.create(name: 'store') }
it 'should create a new schedule object' do
schedule = Schedule.new
expect(schedule).to be_a Schedule
end
it 'should respond to his fields' do
schedule = Schedule.new
expect(schedule)... | true |
df61ef02a75c56e28741222cb050faa2c964ee2b | Ruby | mikhailvs/rack-fluentd-logger | /lib/rack/fluentd_logger.rb | UTF-8 | 2,418 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'English'
require 'fluent-logger'
require 'concurrent'
require 'json'
module Rack
class FluentdLogger
class << self
attr_reader :logger, :json_parser, :preprocessor
def configure(
name: ENV['FLUENTD_NAME'],
host: ENV['FLUENTD_HOST'],
por... | true |
d87e60173d636e07ae646f28c873d432f30a8060 | Ruby | MinesJA/tools_of_trade_backend | /app/lib/authenticator.rb | UTF-8 | 1,264 | 2.84375 | 3 | [] | no_license | class Authenticator
def github(code)
access_token_resp = fetch_github_access_token(code)
puts "Authenticator, github method 1, access_token_resp:#{access_token_resp}"
user_info_resp = fetch_github_user_info(access_token_resp['access_token'])
puts "Authenticator, github method 2, user_info_resp:#{acc... | true |
3df9ab654b04ab5989a1cfa3d0441810c1514ae1 | Ruby | folajimia/launchSchoolBasics | /lesson_1/final_exe/apart.rb | UTF-8 | 302 | 3.125 | 3 | [] | no_license |
#single_words = []
words = ['white snow', 'winter wonderland', 'melting ice','slippery sidewalk', 'salted roads', 'white trees']
#words.each do |word|
# single_words.push(word.split(" "))
#end
#p single_words.flatten
single_words = words.map {|word| word.split(" ")}
a= single_words.flatten
p a
| true |
b878ebe18f33bd9a10bc55725a6eac006c84c8db | Ruby | Tkam13/atcoder-problems | /abc152/e.rb | UTF-8 | 183 | 2.6875 | 3 | [] | no_license | n = gets.to_i
as = gets.chomp.split.map(&:to_i)
MOD = 10**9+7
sum = 0
num_lcm = 1
as.each do |a|
num_lcm = num_lcm.lcm(a)
end
as.each do |a|
sum += num_lcm / a
end
puts sum % MOD
| true |
85d50fd78c485b77355c1592c4ca797eedbc4e27 | Ruby | jimm/kronut_rb | /lib/kronut/set_list.rb | UTF-8 | 1,935 | 2.890625 | 3 | [] | no_license | require_relative 'consts'
require_relative 'slot'
module Kronut
class Kronos
class SetList
attr_accessor :name, :slots, :eq_bypass, :band_levels, :control_surface_mode,
:control_surface_assign_from, :reserved
def self.from_bytes(bytes)
set_list = SetList.new
set_l... | true |
2c67f4859bc6236e45ca5b6f203f99565cfaef8a | Ruby | robt1019/introduction-to-programming | /methods/return.rb | UTF-8 | 334 | 3.546875 | 4 | [] | no_license | def add_three(number)
new_value = number + 3
puts new_value
new_value
end
def add (a, b)
a + b
end
def subtract(a, b)
a - b
end
def multiply(num1, num2)
num1 * num2
end
puts add(20, 45)
puts subtract(80, 10)
puts multiply(add(20,45), subtract(80,10))
puts add(subtract(80, 10), multiply(subtract(20, 6)... | true |
5831b7cc66ac00c33e0d1012a9ae19307dadd127 | Ruby | LostnAustin/oo-counting-sentences-online-web-sp-000 | /lib/count_sentences.rb | UTF-8 | 566 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
#attr_accessor :string
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
# binding.pry
# self.split(". " || "..." || "? " || "! " ).count
self.split(/[!{2}?.]\s/... | true |
7a654e91f32fedc87d110a3744931116c2983196 | Ruby | sakho3600/sites_villes | /09_stats_systems.rb | UTF-8 | 4,449 | 3.046875 | 3 | [
"MIT"
] | permissive | # Info sur les systèmes
require 'csv'
require_relative 'common'
require 'set'
total = 0
stats_language = Hash.new(0)
stats_language_version = Hash.new(0)
stats_application = Hash.new(0)
stats_application_version = Hash.new(0)
stats_server = Hash.new(0)
stats_server_version = Hash.new(0)
STRATES =
[
{nom: ... | true |
30d64b702edf7081da8c37524fbebc4bdbea9aab | Ruby | MrHamel/Showbot | /lib/models/wordcount.rb | UTF-8 | 5,312 | 2.65625 | 3 | [
"MIT"
] | permissive | # wordcount.rb
#
# Model that tracks the number of times a word appears across all shows.
require 'dm-core'
require 'dm-validations'
require 'dm-timestamps'
require 'dm-aggregates'
require 'stopwords'
class WordCount
include DataMapper::Resource
property :id, Serial
property :word, String, :unique => t... | true |
efe037a6bdd3a9832166206431f37f7001cc9641 | Ruby | mollerhoj/sad2 | /spec/BaconIndexer_spec.rb | UTF-8 | 688 | 2.53125 | 3 | [] | no_license | require 'Spec_helper'
describe BaconIndexer do
context "Kevin Bacon himself" do
it "should return 0" do
bacon_indexer = BaconIndexer.new
kevin_bacon = Actor.find(22591)
bacon_indexer.index(kevin_bacon).should eq(0)
end
end
context "A colleage of Kevin Bacon" do
it "should retur... | true |
65a2fd9ff3f18a27a0894a2e7413705a4d828805 | Ruby | amckinnell/nutrella | /lib/nutrella/task_board.rb | UTF-8 | 1,095 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "trello"
module Nutrella
#
# Knows how to use the Trello API to create and lookup task boards.
#
class TaskBoard
def initialize(configuration)
Trello.configure do |trello_client|
trello_client.consumer_key = configuration.fetch(:key)
trello_clien... | true |
6b4a445f3d07805ad7b1c26f98d78da53e179277 | Ruby | skateonrails/tennis_tournament | /app/game.rb | UTF-8 | 1,801 | 3.53125 | 4 | [] | no_license | # frozen_string_literal: true
# Game class is responsible for hold players names
# and display score
class Game
TIE_POINTS = 3
ADVANTAGE_DIFF_POINTS = 1
TIE_WINNER_DIFF_POINTS = 2
WINNER_DIFF_POINTS = 4
attr_reader :players, :first_player, :second_player
def initialize(first_player, second_player)
@pl... | true |
9b08220865b45c14f7663c486e3de1c720962bce | Ruby | gabefinch/phone_book | /spec/phone_book_spec.rb | UTF-8 | 5,075 | 2.8125 | 3 | [
"MIT"
] | permissive | require('rspec')
require('phone_book')
describe(Contact) do
before() do
Contact.clear()
end
describe('#name') do
it('returns the name from a contact instance') do
a = Contact.new({:name => "Bigelow",:phones => 6200})
b = Contact.new({:name => "Brenda Lee",:phones => 1234567})
c = Contac... | true |
bac98776a2e1fa6da82c95f8af45ad59d408fca9 | Ruby | botanicus/refined-refinements | /lib/refined-refinements/string.rb | UTF-8 | 468 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
module RR
module StringExts
refine String do
def titlecase
"#{self[0].upcase}#{self[1..-1]}"
end
end
refine Array do
def join_with_and(xxx = 'and', delimiter = ', ', &block)
block = Proc.new { |item| item } if block.nil?
return bloc... | true |
f45303b94177c20108912b15923f647e98c182b7 | Ruby | mrkchoi/aa_prep | /03_SQL/01_ORM/aa_questions/question_follow.rb | UTF-8 | 1,519 | 2.75 | 3 | [] | no_license | require_relative './questions.rb'
require_relative './model_base.rb'
require_relative './users.rb'
require_relative './question.rb'
########################################
# QUESTION FOLLOW
########################################
class QuestionFollow < ModelBase
attr_accessor :id, :user_id, :question_id
def sel... | true |
48b6112d11d6b41bb0f9dde6f675aeb197076266 | Ruby | ndannehower-appdev/ruby-intro | /app/controllers/programs_controller.rb | UTF-8 | 709 | 2.8125 | 3 | [] | no_license | class ProgramsController < ApplicationController
def home
# Your code goes below.
@your_output = "Replace this string with your output"
render("programs/home.html.erb")
end
def first_program
# Your code goes below.
@your_output = "Replace this string with your output"
render("programs... | true |
c8d142c2d8bd1beb3877e74a55861af926025b65 | Ruby | Landria/magic_the_gathering_cards | /lib/magic_the_gathering_cards/cards.rb | UTF-8 | 2,886 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'fetcher'
module MagicTheGatheringCards
class Cards
attr_accessor :cards_set, :attributes, :errors, :pages
class << self
def fetch(pages = nil)
new(pages).fetch
end
end
def initialize(pages)
@errors = []
@cards_set = []... | true |
1fef46d87ab4cfaaf0a5db6b424a1d5cd2a04b0f | Ruby | amcaplan/flatiron-student-scraper | /spec/student_spec.rb | UTF-8 | 1,216 | 2.640625 | 3 | [] | no_license | require_relative 'spec_helper'
describe "Student" do
let(:our_student) {{
:name => "Justin Belmont",
:img_url => "http://students.flatironschool.com/img/students/justinbelmont_profile.jpg",
:subtitle => "Woooohooo! Code.",
:summary => "Native New Yorker. Code Warrior",
:blog_url => "http:... | true |
d613ba1c306807e951a7f63e6e762fc8e97b426e | Ruby | adamlp1/pub_lab | /specs/customer_spec.rb | UTF-8 | 917 | 3.25 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../customer.rb")
require_relative("../drink.rb")
class TestCustomer < MiniTest::Test
def setup
@customer1 = Customer.new("Mary", 10, 17, 0)
@customer2 = Customer.new("Adam", 15, 20, 3)
@drink1 = Drink.new("Beer", 3.90, 3)
@drink2 = Drink.new("Gin ... | true |
ab484a6a6bcd21177822364df90b74602371d497 | Ruby | janenyasoro/head_first_ruby1 | /02_chapter2/instance_v.rb | UTF-8 | 344 | 4.25 | 4 | [] | no_license | class Dog
def make_up_name
@name = "Sandy"
end
def talk
puts "#{@name} says Bark!"
end
def move(destination)
puts "#{@name} runs to the #{destination}"
end
def make_up_age
@age = 5
end
def report_age
puts "#{@name} is #{@age} years old"
end
end
dog = Dog.new
dog.make_up_name
dog.move("yard")
dog.ma... | true |
faa9196263c9b92e42563eeab11d91de66a0e5dd | Ruby | amirrajan/a-dark-room-mruby | /app/world.rb | UTF-8 | 394 | 2.796875 | 3 | [] | no_license | class World < Hash
def initialize game
@game = game
@asthetics = Hash.new
@landmarks = Hash.new
@cleared = Hash.new
reset
end
def total_deaths
@food_deaths + @water_deaths + @battle_deaths
end
def reset
@food_deaths = 0
@water_deaths = 0
@battle_deaths = 0
end
def sh... | true |
b6486835ca5da9f703fcec5d02ea2e058dfc3ad2 | Ruby | DevHubCo/ServerDeployer | /lib/bot.rb | UTF-8 | 1,193 | 2.828125 | 3 | [] | no_license | require "net/ssh"
require_relative "./handler"
require_relative "./security"
require_relative "./updater"
require_relative "./firewall"
class Bot
attr_reader :host, :user, :options
SERVICES = [Updater, Security, Firewall]
def initialize(host, user, options = {})
@host = host
@user = user
@options =... | true |
b0917803997d29b0dc6fa3df220c06a0a76961e6 | Ruby | mattmanning/adventofcode2020 | /06/a.rb | UTF-8 | 137 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
puts File.read('input').split("\n\n").inject(0) { |total, group| total + group.delete("\n").split('').uniq.length }
| true |
21c1d60c50379efeb3c144e211d4dc5ff9bb2ca4 | Ruby | dallinbjohnson/coding_folder | /ruby/challenge/person_pickers/random_person_picker.rb | UTF-8 | 764 | 2.90625 | 3 | [] | no_license | require 'pry'
@people = ["Dallin", "Jared", "Dave", "Tyson", "Ian", "Dipesh", "Braden", "Ben", "Muhammad", "Gordon", "Brayden"]
def person_method
person = @people.sample
@people.delete(person)
person2 = @people.sample
@people.delete(person2)
if @people.empty?
people = ["Dallin", "Jared", "Dave", "Tyson", "Ian... | true |
759d8fb328e605e66307fdf14f4ee25bc8c93774 | Ruby | son1112/euler-ruby | /4.rb | UTF-8 | 654 | 4.03125 | 4 | [] | no_license | # A palindromic number reads the same both ways. The largest palindrome made
# from the product of two 2-digit numbers is 9009 = 91 x 99.
#
# Find the largest palindrome made from the product of two 3-digit numbers.
threes = (100...1000).to_a.reverse
pals = []
threes.each do |n|
a=n
b=n
while a*b != (a*b).to_... | true |
99ca19117b5622dc95df4b426aefe48d71ea2df4 | Ruby | myronmarston/stream_finder | /test/stream_finder_test.rb | UTF-8 | 802 | 2.65625 | 3 | [] | no_license | $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require 'stream_finder'
require 'mock_stream'
require 'test/unit'
class StreamFinderTest < Test::Unit::TestCase
def test_works_with_tiny_stream
sf = StreamFinder.new(MockStream.new("01"), 10)
assert_equal 1, sf.find_first_index_of_1
end
def test... | true |
080c74db00d4a702ebbed53f061af3d4547645df | Ruby | senthilkumarv/retail_analytics | /lib/profile.rb | UTF-8 | 2,693 | 2.671875 | 3 | [] | no_license | class Product
attr_accessor :lifecycle, :unit_price
def initialize(lifecycle, unit_price)
@lifecycle = lifecycle
@unit_price = unit_price
end
end
class Profile
def initialize
consume = lambda {|state| state.customer_inventory.consume(30)}
replenish = lambda {|state| state.customer_inventory.replenish(20)}... | true |
dbd408f1fd7c83743182cafc3e9ee7033c4bd652 | Ruby | shokai/glitchtweet | /plugins/fill140.rb | UTF-8 | 195 | 2.609375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
module Fill140
def Fill140.glitch(str)
len = str.split(//u).size
result = ''
(140/len).times do
result += str
end
result.chomp.strip
end
end
| true |
e07e8da9aea3d7c84e5e6392d201c7c2fe7d486a | Ruby | golpessito/OC_Survay_Rack | /filters/authentication.rb | UTF-8 | 879 | 2.796875 | 3 | [] | no_license | require 'rack'
require_relative '../models/answers'
class Authentication
def initialize (app)
@app=app
end
def call (env)
#Response
status, headers, body = @app.call(env)
response=Rack::Response.new body,status,headers
template_data = {}
#Request
request=Rack::Request.new(env)
... | true |
31cf976bc60c182f8abfe6ef6ee18722054e3ed1 | Ruby | getyoti/yoti-ruby-sdk | /lib/yoti/util/age_processor.rb | UTF-8 | 374 | 2.65625 | 3 | [
"MIT"
] | permissive | module Yoti
#
# Process age attribute
#
# @deprecated will be removed in 2.0.0 - replaced by Yoti::AgeVerification
#
class AgeProcessor
AGE_PATTERN = 'age_(over|under):[1-9][0-9]?[0-9]?'
# check if the key matches the format age_[over|under]:[1-999]
def self.is_age_verification(age_field)
... | true |
d7ea637d8ae1264c10d48ed593abfaef4108b4db | Ruby | pierre-bedouret/backend | /level4/spec/car_spec.rb | UTF-8 | 1,250 | 3.015625 | 3 | [] | no_license | begin
require_relative '../models/car'
rescue LoadError => e
if e.message =~ /car/
describe 'Car' do
it 'You need a `car.rb` file for your `Car` model' do
fail
end
end
else
raise e
end
end
# test if class car exist
describe Car do
let(:car) { Car.new }
it 'should return an ... | true |
bfe8a2e27930cd9ce9826e46fd308c1e76f0f7b7 | Ruby | Pandu1986/sanford | /lib/sanford.rb | UTF-8 | 1,575 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'ns-options'
require 'pathname'
require 'set'
require 'sanford/version'
require 'sanford/host'
require 'sanford/logger'
require 'sanford/runner'
require 'sanford/server'
require 'sanford/service_handler'
ENV['SANFORD_SERVICES_FILE'] ||= 'config/services'
module Sanford
def self.register(host)
@hosts.a... | true |
d3a0881feb032db8d79eddb58f961a50ad455932 | Ruby | cppcho/nand2tetris | /code/lib/jack/symbol_table.rb | UTF-8 | 1,639 | 3.03125 | 3 | [] | no_license | module Jack
class SymbolTable
def initialize
@class_symbols = {}
@subroutine_symbols = {}
@index_counter = {
STATIC: 0,
FIELD: 0,
ARG: 0,
VAR: 0
}
end
def start_subroutine
@subroutine_symbols.clear
@index_counter[:ARG] = 0
@index_c... | true |
8bc47ddaaa7ff0f76d8377bf55ca18c3d48b668b | Ruby | dayvsonlima/give-record | /spec/support/mocks/mock_log.rb | UTF-8 | 213 | 2.6875 | 3 | [
"MIT"
] | permissive | class MockLog
@@logs = []
def debug?
true
end
def debug(ss)
@@logs << ss
end
def error(ss)
@@logs << ss
end
def self.last
@@logs.last
end
def self.all
@@logs
end
end
| true |
3a39a3048da0b0236d706f7aeb6c97fdfb39db6d | Ruby | rkh/nii | /nii-core/lib/nii/formatters/string.rb | UTF-8 | 12,904 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module Nii::Formatters
module String
extend self
# Allows plugins to register their own +as+ option.
# @return [Hash{Symbol => #format, String}]
# @api internal
FORMAT_AS = { region: 'territory', country: 'territory', numbers: 'numbering_system', calendar_algorithm:... | true |
1af8cca928621c4a3c1ab842c3a215bde20c85d7 | Ruby | isabella232/redpear | /lib/redpear/store/value.rb | UTF-8 | 1,410 | 2.828125 | 3 | [
"MIT"
] | permissive | class Redpear::Store::Value < Redpear::Store::Base
# Deletes the value
# @see Redpear::Store::Base#purge!
alias_method :delete, :purge!
# @return [String] the value
def get
conn.get(key)
end
# @see #get
def value
get
end
# Sets the value
# @param [String] value the value to set
def s... | true |
52ab23cf264b69e394be00692af32a0dc32fae5b | Ruby | manalintsoa/lib | /00_hello.rb | UTF-8 | 263 | 3.609375 | 4 | [] | no_license | #def say_hello
#r = gets.chomp
#puts "Hello #{r}"
#end
#puts say_hello
def ask_first_name
puts"entrer votre prenom"
first_name = gets.chomp
return first_name
end
def say_hello(first_name)
puts"bonjour #{first_name}"
end
puts say_hello(ask_first_name) | true |
fc7759b9f7a042a445965501d765e1f24b52b3b7 | Ruby | raycoding/Ruby3D | /ruby3d.rb | UTF-8 | 1,239 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
include Magick
begin
raise "Pass proper Arguments" if (ARGV.empty? or ARGV.size<2)
img_info = Magick::Image::read(ARGV[1]).first
left_image = ImageList.new(ARGV[1])
right_image = ImageList.new(ARGV[1])
puts "*** Image Information ***"
puts " Image: #{AR... | true |
00ec1ad28d20a032379d621b24d80615890abbd1 | Ruby | SmallLars/codtls | /lib/codtls/h_content.rb | UTF-8 | 1,879 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'codtls/h_chello'
require 'codtls/h_verify'
require 'codtls/h_shello'
require 'codtls/h_keyexchange'
require 'codtls/h_shellodone'
require 'codtls/h_finished'
require 'codtls/h_changecipherspec'
require 'codtls/alert'
module CoDTLS
module Handshake
# Tolle Klasse
class Content
TYPE = Array.new(... | true |
4b5852bed40b7cb3bfd990aef883d37dfdb54a76 | Ruby | CarlyJ88/fizzbuzz | /spec/fizzbuzz_spec.rb | UTF-8 | 567 | 3.125 | 3 | [] | no_license | require 'fizzbuzz'
describe 'fizzbuzz' do
it 'returns "fizz" for the number 3' do
expect(3.fizzbuzz).to eq 'fizz'
end
it 'returns "buzz" for the number 5' do
expect(5.fizzbuzz).to eq 'buzz'
end
it 'returns "fizzbuzz" for the numbers 3 & 5' do
expect(15.fizzbuzz).to eq 'fizzbuzz'
end
it 'retur... | true |
d9c7a0eeb88f25b617649216061921685b097b17 | Ruby | javolpe/the_met | /lib/museum.rb | UTF-8 | 1,292 | 3.28125 | 3 | [] | no_license | class Museum
attr_reader :name,
:exhibits,
:patrons
def initialize(name)
@name = name
@exhibits = []
@patrons = []
end
def add_exhibit(exhibit)
exhibits << exhibit
end
def recommend_exhibits(patron)
recommended = []
patron.interests.map do |interest|... | true |
4a92daaabb5d2247325a9518b98a931a0e6a192b | Ruby | jasonswett/rowboat | /spec/lib/rowboat/spreadsheet_row_spec.rb | UTF-8 | 763 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require_relative '../../../lib/rowboat/spreadsheet_row'
RSpec.describe Rowboat::SpreadsheetRow do
describe '#value' do
let!(:content) do
{
'First name' => 'John',
'Last name' => 'Smith',
'Birthdate' => '5/10/1980'
}
end
it 'returns the value' do
... | true |
0334bd9c8a8dab0087d9c7237089bcce6a06fc92 | Ruby | petekinnecom/homepage | /builder/pages_compiler.rb | UTF-8 | 596 | 2.6875 | 3 | [] | no_license | require_relative './template'
require_relative './page'
class PagesCompiler < Struct.new(:pages, :template)
def self.compile(pages, template:)
new(pages, template).compile
end
def initialize(page_filenames, template_filename)
template = Template.new(template_filename)
pages = page_filenames.map {|a... | true |
f239b6b3b242fa06989b97556f68aaf6cdcfc37a | Ruby | mirandalily/project-euler-10001st-prime-q-000 | /lib/10001st_prime.rb | UTF-8 | 227 | 3.015625 | 3 | [] | no_license | # Implement your procedural solution here!
require 'prime'
def prime_number_for(num)
counter = 0
i = 2
while counter < num
if i.prime?
counter += 1
end
i += 1 unless counter == num
end
return i
end
| true |
f5de8d1af7fe46fc5d5d64958e85626dabdb71c2 | Ruby | mshytikov/bits_count | /lib/bits_count/irb_helper.rb | UTF-8 | 195 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'bits_count'
def count_bits path
stats = BitsCount::File.bits_count(path)
puts "found %d bits set to 1"%[stats[:bit1_count]]
puts "found %d bits set to 0"%[stats[:bit0_count]]
end
| true |
ad5dafc84c3c14cd058545e38d9110c718ba8d42 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/robot-name/4cfe0a02a93d471fb481ace0de04a57a.rb | UTF-8 | 285 | 3.3125 | 3 | [] | no_license | class Robot
attr_reader :name
@@all_names = []
def initialize
@name = random_name
end
def reset
@name = random_name
end
private
def random_name
(0...2).map{ ('a'..'z').to_a[rand(26)] }.join +
(0...3).map{ (0..9).to_a[rand(10)] }.join
end
end
| true |
6a56f90e68ed9e590b6d74871d204ebb812a8479 | Ruby | redice44/ruby-the-hard-way | /text-game/Dungeon.rb | UTF-8 | 576 | 2.875 | 3 | [] | no_license | require "./Room.rb"
require "./StandardResponse.rb"
class Dungeon < Room
def initialize
super(
'Dungeon',
'a thick fog as you descend the spiral staircase. The torches become further apart until there is barely any light. Holding your hand against the wall you continue to descend. Your next and final... | true |
bca4d6572a3a9918ac7329e039d827689f667202 | Ruby | Luiszaba/cli_project | /lib/Tech_News/cli.rb | UTF-8 | 2,251 | 3.609375 | 4 | [
"MIT"
] | permissive | #CLI Controller
class TechNews::CLI
def call
welcome
menu
goodbye
end
def welcome
puts "Welcome to Tech News Daily!"
end
def news_stories
puts "Lets take a quick look at whats available: "
@news = TechNews::Sources.scrape_sources
... | true |
e12a9c36e09dae7c74ba89a0c6cb31a83daf8e49 | Ruby | heatherjc07/RubyIntroduction | /4-Classes/equality.rb | UTF-8 | 95 | 3.265625 | 3 | [] | no_license | a = "abc"
b = a
c = "abc"
# same instance
a.equal?(b)
a.equal?(c)
# equivalent
a == b
a == c
| true |
263a3dddf6e4e6c9b805331618a6d04cb5b25e58 | Ruby | Joanvaro/Algoritmos | /WarGame/warGame.rb | UTF-8 | 3,012 | 3.390625 | 3 | [] | no_license | #! /usr/bin/ruby
require './Graph.rb'
$Operations = Array.new
$WarGraph = Graph.new()
def readFile(filename)
data = File.readlines(filename)
data.collect! { |x| x.delete("\n") }
$NumberOfPeople = data.delete_at(0)
data.each do |line|
$Operations << line.split(" ")
end
end
def BFS(root_node, search_... | true |
f342ca36438fd3279b81c47eb8da127f089e946f | Ruby | s-espinosa/mastermind | /lib/player.rb | UTF-8 | 229 | 3.40625 | 3 | [] | no_license | class Player
def initialize
@current_guess = []
@number_of_turns = 0
end
attr_reader :current_guess
attr_accessor :number_of_turns
def guess(guess_string)
@current_guess = guess_string.split("")
end
end
| true |
61ca1e0ce71ad4a8c31ef11765e9639a056c1740 | Ruby | briemcnally/Whiteboarding | /lib/sum_rec.rb | UTF-8 | 172 | 3.96875 | 4 | [] | no_license | # Write a function that takes an array of integers and returns their sum. Use recursion.
def sum_rec(nums)
return 0 if nums.empty?
nums[0] + sum_rec(nums.drop(1))
end
| true |
aa77ee38f14f2cbfc8cbbc1961a02f77e5fd108a | Ruby | gustafr/rps-challenge | /lib/rps.rb | UTF-8 | 843 | 3.921875 | 4 | [] | no_license |
#rock = 1
#paper = 2
#scissors = 3
def computers_choice
rand(1..3)
end
def input_ok?(item)
(item) == 'rock' || (item) == 'paper' || (item) == 'scissors' ? true : false
end
def play(item)
if input_ok?(item)
c = computers_choice
if (item) == 'rock' && c == 1
'It\'s a draw'
elsif (item) ... | true |
29951486154bcb3716763c52c79f58a29668e9a2 | Ruby | davidkellis/simstring | /lib/simstring_pure.rb | UTF-8 | 10,434 | 3.34375 | 3 | [
"MIT"
] | permissive | require 'set'
require 'pp'
module SimString
class FeatureExtractor
# returns a Set of features
def features(string)
raise "Not implemented."
end
end
NGram = Struct.new(:ngram, :index)
class NGramBuilder < FeatureExtractor
SENTINAL_CHAR = "\u00A0" # non-breaking space
attr_access... | true |
d269aaa73170e6527ef3c4c52c8ce6fa140b772f | Ruby | janklimo/codility | /missing_integer.rb | UTF-8 | 752 | 3.15625 | 3 | [] | no_license | require 'minitest/autorun'
class MissingIntTests < MiniTest::Test
def solution(a)
arr = []
a.each { |e| arr[e] = 1 if e > 0 && e <= 100_000 }
(1..100_001).each do |i|
return i unless arr[i]
end
end
def test_example_input
assert_equal 5, solution([1, 3, 6, 4, 1, 2])
end
def test_s... | true |
7d9863e5a8bbdf6387ac2022b8d453ef5407f98e | Ruby | RubyNunatak/rubykids | /teil_01/lektion_06.rb | UTF-8 | 923 | 3.078125 | 3 | [] | no_license | # lektion_06.rb
require File.dirname(__FILE__) + "/rubykids"
# if ... then ... end
richtung = "R"
if richtung == "R" then schreibe "Ich fahre nach rechts" end
if richtung == "L" then schreibe "Ich fahre nach links" end
# if ... then ... else ... end
if richtung == "R"
schreibe "Ich fahre nach rechts"
else
schre... | true |
06a0177e4064eb13af405a14558a08022019d48e | Ruby | gucci-ninja/iTradeRecipes | /app/models/item.rb | UTF-8 | 337 | 2.9375 | 3 | [] | no_license | class Item < ApplicationRecord
# My attempt at making the description more readable
# def self.scrubbed
# Item.all.each do |p|
# end
def self.get_price(item, store)
item = Item.where(store_id: store).where('name LIKE ?', "%#{item.upcase}%").first
(item.price/item.quantity).roun... | true |
046a39c2dc41bcd85a68cba9100b2baf37be1d55 | Ruby | MaxKoleshatov/Thinknetica | /lesson_8/cargo_train.rb | UTF-8 | 494 | 2.765625 | 3 | [] | no_license | # frozen_string_literal: true
class CargoTrain < Train
attr_reader :route_train, :type, :number, :speed, :wagons
def initialize(data = {})
super
@route_train = []
validate!
register_instance
@@all_train << self
end
def plus_wagon(wagon)
@wagons << wagon if @speed.zero? && wagon.instan... | true |
27fde5269d30b8a8d4b87302e549ffd5f3d43315 | Ruby | PRudge/travel_tracker | /controllers/sights_controller.rb | UTF-8 | 1,160 | 2.515625 | 3 | [] | no_license | require('sinatra')
require('sinatra/contrib/all')
require_relative('../models/sight.rb')
require_relative('../models/city.rb')
require_relative('../models/country.rb')
also_reload('../models/*')
get '/sights/new/:id' do #form for new sight
@city = City.find(params['id'])
erb(:"sights/new")
end
post '/sights' do #... | true |
27c438271390d85b983792c447325606f31a7873 | Ruby | akbarratt/rb101 | /exercises/easy3/01.rb | UTF-8 | 576 | 4 | 4 | [] | no_license | numbers = []
puts "==> Enter the 1st number:"
num1 = gets.chomp.to_i
numbers << num1
puts "==> Enter the 2nd number:"
num2 = gets.chomp.to_i
numbers << num2
puts "==> Enter the 3rd number:"
num3 = gets.chomp.to_i
numbers << num3
puts "==> Enter the 4th number:"
num4 = gets.chomp.to_i
numbers << num4
puts "==> Enter th... | true |
e2e86cc9a83df5c71e9c5cb51d208f5640635e9d | Ruby | rachaellynn/ruby_calisthenics | /euler_4.rb | UTF-8 | 369 | 3.34375 | 3 | [] | no_license | #largest palindrome from the product of 3-digit numbers
#2-digit example = 9009 = 91 × 99
firstnumber = (100..999).to_a
palindrome = 0
firstnumber.each do |item1|
(100..999).each do |item2|
total = item1 * item2
#the palindrome detector
if total.to_s == total.to_s.reverse
if total > palindrome
palindrome = ... | true |
4adfba0b125b567871bbe76767a2d5d100f8c1d5 | Ruby | danyibalazs/static_and_dynamic_testing | /card_game_spec.rb | UTF-8 | 781 | 2.953125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative('./card_game.rb')
require_relative('./card.rb')
class TestCardGame < Minitest::Test
def setup
@card1 = Card.new("Hearts", 5)
@card2 = Card.new("Diamonds", 1)
@card3 ... | true |
530ed086ae394ac5f6403a9341cbf9ff55c993a7 | Ruby | adambair/rails-initiate | /labs/07a_nested_resources_part_1.rb | UTF-8 | 656 | 2.703125 | 3 | [] | no_license | # --------------------------
# Lab 07a: Nested Resources Part 1 [ 07a_nested_resources_part_1.rb ]
# --------------------------
# Create a route that reflects the post has_many comments relationship
# Verify the routes using 'rake routes'
#
# Nest the CommentsController
# - Add a before filter to find the post from par... | true |
dd84dda9513db1f13ec049f70db637e00f008185 | Ruby | denislav-7128/software_engineering_2013 | /class2_homework/Yulian_Razkazov_3.rb | UTF-8 | 166 | 3.046875 | 3 | [] | no_license | require 'csv'
c=0.00
data=""
CSV.foreach('bank.csv') do |row|
if data==row[0]
c+=row[1].to_f
else
if row[1].to_f>c
c=row[1].to_f
data=row[0]
end
end
end
puts data
| true |
58e585bf728488633cf178be8adbe099021ecea3 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/triangle/d2a06401784b462495a37ae75d299f23.rb | UTF-8 | 626 | 3.59375 | 4 | [] | no_license | class TriangleError < StandardError
end
class Triangle
UNIQUE_SIDE_LENGTHS = {1 => :equilateral, 2 => :isosceles, 3 => :scalene}
def initialize(a, b, c)
@small, @medium, @large = [a, b, c].sort
raise TriangleError, "violates triangle inequality" if violates_triangle_inequality?
raise TriangleError, "s... | true |
b93b4ef7adff2b6ced75f470f78ad0aaa91e0017 | Ruby | thomasv314/aws-opsworks-cookbooks-chef-12 | /aws_opsworks_ebs/libraries/block_device.rb | UTF-8 | 416 | 2.6875 | 3 | [] | no_license | module BlockDevice
def self.wait_for(device, timeout = 300)
sleep_time = 10
time_elapsed = 0
while time_elapsed <= timeout
break if File.blockdev?(device)
Chef::Log.info("device #{device} not ready - waiting")
sleep sleep_time
time_elapsed += sleep_time
end
Chef::Log.inf... | true |
b356943214968bb0b37bd860eede95c11fd7bacd | Ruby | davinaSanders/Lab-Classes-Multiple | /specs/customer_spec.rb | UTF-8 | 896 | 3.0625 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../customer.rb")
require_relative("../drink.rb")
require_relative("../pub.rb")
require_relative("../food.rb")
class CustomerTest < MiniTest::Test
def setup
@drink1 = Drink.new("Beer", 2, 5)
@drink2 = Drink.new("Wine", 3, 10)
@food1 = Foo... | true |
18784395e5764d8adc027ec885168ce191d29ca2 | Ruby | haleyga/hackerrank | /super-valid-bracket-sequences/super-valid-bracket-sequences.rb | UTF-8 | 879 | 3.28125 | 3 | [] | no_license |
$sequence_map = Hash.new
$super_valid_map = Hash.new
def isSuperValid(s, k)
count = 0
(0..s.length-2).each do |i|
count += 1 if s[i] != s[i+1]
return count >= k
end
end
def getValidSequences(n)
if n == 0
$sequence_map[n] = ''
return
end
if n == 2
$sequence_map[n] = '()'
return
e... | true |
4e45675663ae051f2f6afec67ee6900bd72d2a9c | Ruby | jmuldvp/bloc-data-structures | /06-trees/binary_tree/bench.rb | UTF-8 | 995 | 3.125 | 3 | [] | no_license | require 'benchmark'
require_relative 'binary_search_tree'
require_relative 'min_heap'
bin_root = Node.new("binary root", 1)
heap_root = Node.new("heap root", 1)
bin = BinarySearchTree.new(bin_root)
heap = MinHeap.new(heap_root)
n = 100_000
Benchmark.bm(20) do |x|
x.report("tree insert") do
for i in 2..n do
... | true |
636026588607594b53909592f048c69b29225be9 | Ruby | emilyyz92/ruby-puppy-v-000 | /lib/dog.rb | UTF-8 | 260 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
attr_reader :name
@@all = []
@@name = []
def initialize(name)
@name = name
@@all<<self
@@name<<@name
end
def self.clear_all
@@name.clear
@@all.clear
end
def self.all
@@name.each {|name| puts name}
end
end
| true |
39b68d34405bb0b2bd504e0aa3dd147aaf1b0d93 | Ruby | dissemble/Landfill | /lib/landfill/g_c_snapshot.rb | UTF-8 | 1,474 | 2.9375 | 3 | [] | no_license | module Landfill
class GCSnapshot
attr_accessor :num_allocations, :allocated_size, :collections, :time, :growth, :live_objects
def initialize(values)
self.reassign values
end
def reassign(values)
self.num_allocations = values[:num_allocations]
self.allocated_size = values[:allocated... | true |
59e2d997081f8c27e1d9a438e4127a72e0ad76f0 | Ruby | IvikGH/postfix | /analyzer.rb | UTF-8 | 970 | 3.203125 | 3 | [] | no_license | class Analyzer
attr_accessor :data
def initialize
# p ' '.rjust(8) + "in analyzer.rb initialize"
@data = []
end
def take_data(hash_bounce)
# p ' '.rjust(8) + "in analyzer.rb analyze(hash_bounce)"
data << hash_bounce
end
def show_result
# p ' '.rjust(8) + "in analyzer.rb show_result"
... | true |
b06858bf5769a81a5e9698a4e80c13ba644767c6 | Ruby | kristianmandrup/code-spec | /lib/code_spec/matchers/include_module.rb | UTF-8 | 826 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module RSpec::RubyContentMatchers
class IncludeModule < RSpec::RubyContentMatcher
attr_reader :module_name, :type
def initialize module_name, type=nil
@module_name = module_name.to_s.camelize
@type = type || :include
end
def matches?(content)
@content = content
(content... | true |
c1745a2d2eeb1c0779a0487bdbc3160adc12d8d2 | Ruby | langalex/realtimebattle_rb | /spec/integration_spec.rb | UTF-8 | 2,332 | 2.546875 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe 'Real Time Battle' do
describe 'bot' do
before(:each) do
@bot = TestBot.new
@info = ObjectInfo.new 1, 1, 0
@arena = Arena.new [], 10, 10
@arena.add_object @bot, @info
end
it "should move around" d... | true |
f9bc8c4312ce03aefc78cbb818fa71a4a878af17 | Ruby | thinkerbot/configurable | /test/readme_test.rb | UTF-8 | 2,338 | 3 | 3 | [
"MIT"
] | permissive | require File.expand_path('../test_helper', __FILE__)
require 'configurable'
class ReadmeTest < Test::Unit::TestCase
class ConfigClass
include Configurable
config :flag, false # a flag
config :switch, true # an on/off switch
config :num, 3.14 # a number
config :lst, [1,2,3] # a list o... | true |
6b1c5c16cf6814ec24d1523859079c5cfebd9136 | Ruby | rrgayhart/greenhousery | /app/models/project_array.rb | UTF-8 | 4,182 | 2.5625 | 3 | [
"MIT"
] | permissive | class ProjectArray < ActiveRecord::Base
belongs_to :project
belongs_to :solar_module
attr_accessor :new_solar_module_brand, :new_solar_module_model, :new_solar_module_length, :new_solar_module_width, :new_solar_module_height, :new_solar_module_nominal_wattage
has_many :points
validates :project_id, presence: ... | true |
2623f294c784563bbf8f49069f00f1cb7f538503 | Ruby | Gmfholley/06-29-css-flashcards | /models/css_defs.rb | UTF-8 | 1,160 | 2.8125 | 3 | [] | no_license | class CSSDefinition
include DatabaseConnector
# duration - length
attr_reader :id, :errors
attr_accessor :definition, :example, :name
# initializes a Duration id
#
# optional Hash argument
# name - String of the name
# definition - String of the definition
... | true |
b6ecde610362518f1ac23937fa7db4d9669773bf | Ruby | Mycobee/weather_sweater | /app/models/forecast.rb | UTF-8 | 1,679 | 3.015625 | 3 | [] | no_license | class Forecast
attr_reader :id
def initialize(forecast_data)
@forecast_data = forecast_data
end
def current_weather
{current: { high: daily_high(today),
low: daily_low(today),
temp: current_temp,
summary: current_summary }}
end
def today
@forecast_data[:daily][:data][0]
end
def currently
... | true |
98c9bdf1ecfb93e1bbfe5f11ec02ffe76de9f584 | Ruby | AlexandreVersmee/RabbitMQ-CrawlerAndSaveHTMLAndImage | /test/display_image.rb | UTF-8 | 350 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require "./db/models/image.rb"
require 'base64'
class DisplayImage
def self.run
createimg()
end
def self.createimg()
pick = ARGV[0] || 42
img = Image.find_by(id:pick)
File.open("image.jpg", "w") do |f|
f.write(Base64.decode64(img.content))
end... | true |
3f93437e330ccd3e2daa9679268137e8d5d5ad50 | Ruby | Capleugh/flash_cards | /test/round_test.rb | UTF-8 | 3,481 | 3.4375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/turn'
require './lib/deck'
require './lib/round'
class RoundTest < Minitest::Test
def setup
@card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography)
@card_2 = Card.new("The Viking spacecraft sent back to... | true |
146dfdc8aafc2d1746ebb2faa3ff52cf0b8dfcf9 | Ruby | flacito/war_hotel | /recipes/remove_instances.rb | UTF-8 | 3,406 | 2.640625 | 3 | [] | no_license |
roles_to_wars_hash = {}
instances_hash = {}
ruby_block 'remove WARs not in role' do
block do
# Create a convenience Hash for comparison
node['war_hotel']['instances'].each do |instance|
wars = {}
instance['wars'].each do |war|
wars[war['artifact_id']] = war['version']
end
ro... | true |
be45546b4080025e3359f1a6aef778f57fc8fe5e | Ruby | eregon/adventofcode | /2020/21a.rb | UTF-8 | 491 | 2.609375 | 3 | [] | no_license | foods = File.readlines('21.txt', chomp: true).map { |line|
line.split(' (contains ', 2).then { [_1.split.map(&:to_sym), _2.chomp(')').split(', ').map(&:to_sym)] }
}
per_allergen = Hash.new { |h,k| h[k] = [] }
foods.each { |ingredients, allergens|
allergens.each { |allergen| per_allergen[allergen] << ingredients }
... | true |
411440ece2fe724dd24940c0a1e652c1b436d913 | Ruby | tcollier/family_friday | /spec/family_friday/action/list_employees_spec.rb | UTF-8 | 1,254 | 2.640625 | 3 | [] | no_license | require_relative '../../../lib/family_friday/employee_store'
require_relative '../../../lib/family_friday/action/list_employees'
module FamilyFriday
RSpec.describe Action::ListEmployees do
subject do
Action::ListEmployees.new(employee_store: employee_store, output: output)
end
let(:employee_store)... | true |
6b40fb3d8898e3dfed385768519ac84131050ff4 | Ruby | adriacustico/curso67RoR | /Ruby/Curso67/trece_basicos.rb | UTF-8 | 4,066 | 4.1875 | 4 | [] | no_license | # 1.- Mostrar 1-255
# Escriba un programa que muestre todos los números del 1 al 255.
#puts (1..255).to_a
# 2.- Mostrar números impares entre 1 y 255
# Escriba un programa que muestre todos los números impares del 1 al 255.
#puts (1..255).find_all {|a| a.odd?}.to_s
# 3.- Muestre la suma
# Escriba un programa que mu... | true |
37afa2a8f621fa7bbc55b58499db183151bf3a97 | Ruby | tomcha/shogi | /agent.rb | UTF-8 | 2,840 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# coding:utf-8
require 'socket'
require 'yaml'
require 'net/http'
require_relative './app/lib/shogi_client'
#
#クライアント設定ファイルの読み込み
config_file_name = ARGV[0]
config = YAML.load_file(config_file_name)
#クライアントのインスタンス化
client = Shogi_client.new(config['client_name'], config['client_mode'], config['thin... | true |
ffe90e78b6c4687c7278e13fb0bb8b1333dc2964 | Ruby | KeriStoller/skillcrush-ruby-challenges | /song_object.rb | UTF-8 | 1,252 | 3.84375 | 4 | [] | no_license | class Song
attr_accessor :name, :artist
end
class Alternative < Song
def genre
return "alternative"
end
end
class Country < Song
def sound
return "twangy"
end
end
class Dance < Song
def tempo
return "upbeat"
end
end
song_one = Alternative.new
song_one.name= "This must be the place"
alternative_name... | true |
d323e9a08ce527f1fa5a588eea3d9eae9aecfed6 | Ruby | Strompy/practice_challenges | /palindrome_challenge.rb | UTF-8 | 1,800 | 4.5 | 4 | [] | no_license | # Palindrome numbers challenge
# Instructions:
# The number 47 has an interesting characteristic.
#
# If you take the number, plus its reverse (47 => 74) and then add them together to a number (47+74=121) the resulting sum is a palindrome
#
# Starting at 0, find the first 25 numbers that have this same characteristic a... | true |
d65fc29abe28a3ec9cd34014941ec3f8a3537daf | Ruby | LuuuFan/Algorithms-Project | /Algorithms Project 6/Lu_Fan/lib/install_order.rb | UTF-8 | 1,142 | 3.6875 | 4 | [] | no_license | # Given an Array of tuples, where tuple[0] represents a package id,
# and tuple[1] represents its dependency, determine the order in which
# the packages should be installed. Only packages that have dependencies
# will be listed, but all packages from 1..max_id exist.
# N.B. this is how `npm` works.
# Import any file... | true |
c33f382fead0175fcc40a83d8f07688d46b16170 | Ruby | Terry-Thompson/ruby-objects-has-many-through-lab-v-000 | /lib/genre.rb | UTF-8 | 282 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
attr_accessor :name, :songs
def initialize(name)
@name = name
@songs = []
end# of initialize
def add_song(song)
@songs << song
end# of add_song
def artists
@songs.collect {|song| song.artist}
end# of artists
def songs
@songs
end# of songs
end# of class
| true |
0aac743cfd4edc4ead334da660b21350290fe9d1 | Ruby | timothymcmackin/Sample-Gitbook | /deploy.rb | UTF-8 | 5,364 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
require 'thread'
require 'rubygems'
require 'bundler/setup'
require 'aws-sdk'
require 'git'
# Shamelessly stolen from http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively
# Because multithreaded upload is pretty f-ing sweet
class S3FolderUpload
a... | true |
05f67e2a445f016c01a81dee7c139a02ac7cb471 | Ruby | SugyeongSugyeong/coderbyte | /WordCount.rb | UTF-8 | 82 | 2.65625 | 3 | [] | no_license | def WordCount(str)
# code goes here
return str.split(" ").size
end
| true |
eb78745083e26ac48eb2ab9d23897923afdffb12 | Ruby | juliana06/RB101 | /lesson_4/Loops2/1.rb | UTF-8 | 770 | 4.4375 | 4 | [] | no_license | # Input: numbers 1 to 5
# Output: number and whether it's even or odd
# Rules
# - Explict Requirements
# - Print the number
# - Print whether the number is even or odd
# - use a loop
# Algorithm:
# - start a counter outside the loop
# - initialize the loop
# - if number is odd interporlate counter with ... | true |
29048280fb743cb4c43a212a135080a3e4d44fd8 | Ruby | gcao/gocool | /app/models/uploader.rb | UTF-8 | 1,889 | 2.59375 | 3 | [] | no_license | class Uploader
def process_files description, files
uploads = files.map {|file| Upload.create!(:source_type => Upload::UPLOAD_FILE, :description => description, :file => file) }
uploads = uploads.inject([]) do |new_uploads, upload|
new_uploads << process_compressed_upload(upload)
end.flatten
up... | true |
d010b1a1c6b7fe9053bd174a5c87db5f0c207acf | Ruby | JohnFajardo/oo-my-pets-dumbo-web-062419 | /lib/owner.rb | UTF-8 | 1,241 | 3.546875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Owner
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.clear
@@all.clear
end
def self.count
@@all.count
end
def self.reset_all
@@all.clear
end
def species
@species = "human"
end
def say... | true |
46bad4a9619ab97bd4d3774c76024b46e15132ea | Ruby | thacdtd/robot_simulator | /robot_simulator/position.rb | UTF-8 | 1,270 | 3.375 | 3 | [
"MIT"
] | permissive | class Position
attr_accessor :x, :y
def initialize(args = {})
@x = args['x'] || 0
@y = args['y'] || 0
end
def coordinates
[@x, @y]
end
def valid?(table)
(x_valid?(table) && y_valid?(table)) ? true : false
end
def x_valid?(table)
left_most_position = table.origin['x']
right_mo... | true |
350d9be20b8b379e1d78cc41b918670c73ec9eb8 | Ruby | TetsuyaNegishi/atcoder | /ABS/ABC086A.rb | UTF-8 | 105 | 3.421875 | 3 | [] | no_license | a,b=gets.chomp.split(" ").map(&:to_i)
result = ((a * b) % 2) == 0 ? "Even" : "Odd"
print("#{result}\n") | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.