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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
90c71e98abb4f67f8eb291753360be2d8d1319e3 | Ruby | smkopp92/ruby-rpg | /spec/lib/monster_spec.rb | UTF-8 | 464 | 2.734375 | 3 | [] | no_license | require "spec_helper"
describe Monster do
describe ".new" do
it "takes a name and power" do
monster = Monster.new("Zubat", 1)
expect(monster).to be_a(Monster)
end
end
let(:monster) { Monster.new("Zubat", 1) }
describe "#name" do
it "has a reader for name" do
expect(monster.name)... | true |
9e2428b7b2f272fc67c74717882cf913d5967ca7 | Ruby | joshkim88/food-delivery-reboot | /app/repositories/customer_repository.rb | UTF-8 | 477 | 2.75 | 3 | [] | no_license | require 'csv'
require_relative '../models/customer'
require_relative 'base_repository'
class CustomerRepository < BaseRepository
def build_model(row)
row[:id] = row[:id].to_i
return Customer.new(row)
end
end
# prima = Customer.new(
# name: 'prima',
# address: 'canggu'
# )
# # it will look meals.csv ... | true |
71f3b541eaa5aa38e1b1abe085c0dc00835bf14a | Ruby | elight/l2meter | /lib/l2meter/emitter.rb | UTF-8 | 4,722 | 2.59375 | 3 | [
"MIT"
] | permissive | require "time"
module L2meter
class Emitter
attr_reader :configuration
def initialize(configuration: Configuration.new)
@configuration = configuration
@buffer = {}
@autoflush = true
@contexts = []
@outputs = []
end
def log(*args)
merge! *current_contexts, *args
... | true |
2341a29885e5fd23a13ed4d49b9cb350be2d2523 | Ruby | AIexey-L/thnkntk | /lesson_7/cargo_carriage.rb | UTF-8 | 579 | 3.21875 | 3 | [] | no_license | require_relative = 'manufacturer'
class CargoCarriage
include Manufacturer
attr_reader :free_volume
def initialize(total_volume)
@total_volume = total_volume.to_f
@free_volume = @total_volume
end
def take_volume(volume_to_take)
@free_volume = @free_volume - volume_to_take if valid_volume_... | true |
89da465cd586cd9e034cb21d125d2ad055fc3255 | Ruby | Woodpecker2020/viselitsa | /viselitsa.rb | UTF-8 | 463 | 2.859375 | 3 | [] | no_license | require_relative "game"
require_relative "result_printer"
require_relative "word_reader"
require 'unicode'
puts "Игра виселица. Версия 3. (c) goodprogrammer.ru\n\n"
sleep 1
printer = ResultPrinter.new
word_reader = WordReader.new
words_file_name = File.dirname(__FILE__) + "/data/words.txt"
game = Game.new(word_reader... | true |
945e83041b790a053e5721cdd008867f18326f8b | Ruby | mcmoyer11/odm_sl | /lib/hierarchy.rb | UTF-8 | 792 | 3.515625 | 4 | [] | no_license | # Author: Bruce Tesar
#
# A stratified constraint hierarchy. The top stratum of the hierarchy
# is first in the list, and so forth. Each stratum is a list of constraints.
class Hierarchy < Array
# Returns a duplicate hierarchy, with distinct stratum objects,
# but containing references to the very same constr... | true |
72307bd3b080e00155db0ae6241450c87adc2a1a | Ruby | Coding-Knights/chess | /spec/models/king_spec.rb | UTF-8 | 1,226 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe King, type: :model do
describe 'valid_move? for the king' do
before(:each) do
@king = FactoryBot.create(:king, x_position: '4', y_position: '4')
end
it 'should check if vertical moves are valid' do
expect(@king.valid_move?(4,5)).to eq true
end
i... | true |
30953c7b583a1a95606f01943729639e652cd626 | Ruby | bay6/railscasts | /caok/398/auth-services/app/services/authentication.rb | UTF-8 | 658 | 2.703125 | 3 | [] | no_license | class Authentication
def initialize(params, omniauth = nil)
@params = params
@omniauth = omniauth
end
def user
@user ||= @omniauth ? user_from_omniauth : user_with_password
end
def authenticated?
user.present?
end
private
def user_from_omniauth
User.where(@omniauth.slice(:provider,... | true |
16463b86604d9bb15e651bc6fd5f414c14ddbb11 | Ruby | byelipk/rubbish | /lib/rubbish/protocol.rb | UTF-8 | 485 | 2.75 | 3 | [] | no_license | module Rubbish
class Protocol
def self.marshal(ruby)
case ruby
when Symbol then "+#{ruby.to_s.upcase}\r\n"
when String then "$#{ruby.length}\r\n#{ruby}\r\n"
when Array then "*#{ruby.length}\r\n#{ruby.map {|x| marshal(x)}.join}"
when Integer then ":#{ruby}\r\n"
when nil ... | true |
5b447c23bddfae8a6e6472b6e5e99812cc28af1a | Ruby | serradura/stringub-commons | /test/stringub-commons/commons_test.rb | UTF-8 | 1,375 | 2.890625 | 3 | [] | no_license | require File.join(File.dirname(__FILE__), '..', 'test_helper')
class Stringub::CommonsTest < Test::Unit::TestCase
def setup
@spaces_and_some_text = " \n \r \t\r\n foo \t bar "
end
def test_should_return_a_single_word_in_array
assert_equal %w{Hello}, "Hello".words
end
def test_should_return... | true |
ed232c04dccdfff149ab58a69fbcfa586b6726f2 | Ruby | wozwas/JP-Text-Adventure | /main.rb | UTF-8 | 3,135 | 3.578125 | 4 | [] | no_license | require_relative "app/switch_room.rb"
require_relative "app/storage_locker.rb"
require_relative "app/stairs.rb"
def the_end(msg)
puts msg
exit(0)
end
def dead_end()
puts """
You've hit a dead end. You hear a low
growling coming from somewhere deeper
in the bunker. Better try another way.
"""
end
def r... | true |
c3c0ed281c433e1c86454ddb50e6ca65dcf9f24a | Ruby | nxt-insurance/nxt_state_machine | /lib/nxt_state_machine/transition.rb | UTF-8 | 1,707 | 2.53125 | 3 | [
"MIT"
] | permissive | module NxtStateMachine
class Transition
include Transition::Interface
def initialize(name, event:, from:, to:, state_machine:, context:, set_state_method:, arguments:, options:, &block)
@name = name
@event = event
@from = state_machine.states.resolve!(from)
@to = state_machine.states.... | true |
2ba7cde5cf2fa704c735b32d447df0678104f32e | Ruby | adamcameron/otherLanguages | /ruby/languageComparison/keyValuePairings/struct.rb | UTF-8 | 192 | 3.375 | 3 | [] | no_license | # struct.rb
def sep
puts "=" * 20
end
Name = Struct.new(:first, :last)
son = Name.new("Zachary", "Cameron Lynch")
puts son.first
puts son.last
sep
puts son.length
son.each do |k|
puts k
end
sep
| true |
7862d17be06d93bd14ea548de868692dbc8743e1 | Ruby | wisehackermonkey/csv-pagination | /slow.rb | UTF-8 | 432 | 2.828125 | 3 | [] | no_license | # slow version of the csv read program
# THIS CODE WILL CAUSE LARGE RAM SPIKE AND WILL NOT FINISH
# by Oran C
# oranbusiness@gmail.com
# github.com/wisehackermonkey
# 20190222
#
require 'csv'
file_name = "real_data-100k.csv"
csv_file = File.join(Dir.pwd, file_name)
puts "CSV FileFile Opened: #{csv_file}"
# First att... | true |
1f47c6195ff5b578fc555fb983eab3dfebf9d7d7 | Ruby | jennafrancis/apples-and-holidays-v-000 | /lib/holiday.rb | UTF-8 | 1,663 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def second_supply_for_fourth_of_july(holiday_supplies)
holiday_supplies[:summer][:fourth_of_july][1]
end
def add_supply_to_winter_holidays(holiday_hash, supply)
holiday_hash[:winter][:christmas] << supply
holiday_hash[:winter][:new_years] << supply
end
def add_supply_to_memorial_day(holiday_hash,... | true |
8970e17ee06827744d17874cfaba87a58919e65a | Ruby | jeremyf/dotzshrc | /bin/lil-regy | UTF-8 | 4,963 | 2.96875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -wU
# Background:
#
# This script is for organizing my thoughts around regular expression
# replacement. When using Atom, I have often used the find and replace with
# regular expressions. For the process, I would often preview the regular
# expression to see what matched. Then I would run ... | true |
524750356ab6ce54c23f7f9661060bc7b51cd0d6 | Ruby | neiltron/runningman | /models/user.rb | UTF-8 | 2,249 | 2.59375 | 3 | [] | no_license | class User
include Mongoid::Document
include Mongoid::Timestamps
field :email
field :password, default: nil
field :password_hash
field :password_salt
field :authentication_token
has_many :entries
validates :email,
presence: true,
uniqueness: true,
format: { with:... | true |
49cad59f66fbeebf134fb0b9372bd47ba52acad7 | Ruby | tyrbo/sales_engine_davis_dennis | /lib/merchant_repository.rb | UTF-8 | 882 | 3.25 | 3 | [] | no_license | require 'csv'
require_relative 'merchant'
require_relative 'parser'
class MerchantRepository
attr_reader :merchants,
:engine
def initialize(engine, data_path)
@merchants = Parser.new.parse(data_path + '/merchants.csv', Merchant, self)
@engine = engine
end
def inspect
"#<#{sel... | true |
b502121e5c8a987de58cc9a1f7befa26f53a10b7 | Ruby | JinZak/Game | /game/game_logic.rb | UTF-8 | 1,623 | 3.765625 | 4 | [] | no_license | class GameLogic
FIGURE = {
'1' => "камень",
'2' => "ножницы",
'3' => "бумагу"
}.freeze
# User input selection and validation
def user_input
puts 'Выберите один из вариантов и нажмите Enter: 1 - камень; 2 - ножницы; 3 - бумага'
loop do
@person_choice = $stdin.gets.chomp
puts "Вы... | true |
d34453541846ed0fda43dc740eace4a45c9f9952 | Ruby | varyonic/aw_datapipe | /lib/aw_datapipe/pipeline.rb | UTF-8 | 2,712 | 2.59375 | 3 | [
"MIT"
] | permissive | module AwDatapipe
class Pipeline
attr_accessor :id # AWS pipeline id
attr_accessor :uuid # Unique id
attr_reader :objects # ObjectHash[:id => PipelineObject]
attr_reader :parameter_metadata # Hash['parameterName' => Hash[type:|default:|description:|...]
attr_reader :parameter_values # Hash['param... | true |
d87170c92c05eea367f8254b4719397dc73e6c86 | Ruby | versaceversace/ruby-testing | /03_simon_says/simon_says.rb | UTF-8 | 400 | 3.609375 | 4 | [] | no_license | def echo(f)
f
end
def shout(u)
u.upcase
end
def repeat(sace, n = 2)
([sace] * n).join(" ") #ruby monk salute
end
def start_of_word(s, n)
s[0...n]
end
def first_word(a)
a.split(" ").first
end
def titleize(b)
words = b.split.map do |word|
if %w(the and over).include?(word)
word
else
word.capitalize
... | true |
666cf2e9627744ab0b6dc6541240377fb56cd032 | Ruby | sranso/flatiron-is-it-birthday-sinatra | /lib/countdown.rb | UTF-8 | 600 | 3.21875 | 3 | [] | no_license | # this is basically my 'notes' file for the countdown logic.
# i added this logic to holiday.rb
attr_reader :days_until, :hrs_until, :mins_until, :secs_until
def next_bday_year
if Time.now.month <= 10
Time.now.year
else
Time.now.year + 1
end
end
def countdown
time_diff = (Time.now - Time.local(next_b... | true |
2acf765ab4b009b73d10c378b410fca1710155d2 | Ruby | MrRogerino/phase-0-tracks | /databases/mental-math/mental_math.rb | UTF-8 | 3,299 | 3.90625 | 4 | [] | no_license | require 'sqlite3'
def start_test
db = SQLite3::Database.new("problems.db")
db.results_as_hash = true
create_table_cmd = <<-SQL
CREATE TABLE IF NOT EXISTS problems (
id INTEGER PRIMARY KEY,
first_num INT,
second_num INT,
operand CHAR(3),
right_answer INT,
user_... | true |
6951930d3241417d7293c514377aefff77cae6a5 | Ruby | dark-panda/dotfiles | /bin/git-bgrep | UTF-8 | 600 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'shellwords'
options = {
email: false
}
OptionParser.new { |opts|
opts.on("-e", "--email", "Show email instead of author name") { |v| options[:email] = v }
}.parse!
grep = `git grep -I -n #{ARGV.collect { |arg| Shellwords.escape(arg) }.join(" ")}`
if $? != 0
pri... | true |
5fb1337e7a9f1ca3c8c7d57f6883f93e2581331a | Ruby | kdar/challenges | /hackerrank/templates/template.rb | UTF-8 | 270 | 3.046875 | 3 | [] | no_license | require 'stringio'
TEST = ""
def solve(input)
#string = input.gets.chomp.downcase
end
def main()
# for testing purposes
if ARGV.length == 1 && ARGV[0] == "test"
solve(StringIO.new(TEST))
return
end
solve($stdin)
end
if __FILE__ == $0
main()
end
| true |
87dd379a40604de7e7777493e1e6e9514c798966 | Ruby | erodxd/blood-oath-relations-dumbo-web-career-031119 | /app/models/bloodoath.rb | UTF-8 | 650 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class BloodOath
@@ALL = []
attr_reader :follower, :cult, :year, :month, :day
def initialize(year, month, day, follower, cult)
@year = year
@month = month
@day = day
@cult = cult
@follower = follower
@@ALL << self
##recrit flwr(follower)
end
... | true |
3880e2cf0354a68f73410570cfaf99973bc179ee | Ruby | xbell/petpointer | /app/controllers/yelp_controller.rb | UTF-8 | 2,194 | 2.59375 | 3 | [] | no_license | require 'yelp'
require 'json'
class YelpController < ApplicationController
def yelp
@address = params[:address]
@vets = Yelp.client.search(@address, {category_filter: 'vet', limit: 10, sort: 1, radius_filter: 8046.72})
@pet_services = Yelp.client.search(@address, {category_filter: 'dogwalke... | true |
e267b9b456c4ffd35c08c613adaf60f4733eea91 | Ruby | androidgrl/task_manager_redo | /test/models/task_manager_test.rb | UTF-8 | 1,445 | 2.921875 | 3 | [] | no_license | require_relative '../test_helper'
class TaskManagerTest < Minitest::Test
def create_tasks(num)
num.times do |num|
data = { "title" => "title#{num}", "description" => "description#{num}"}
TaskManager.create(data)
end
end
def test_can_create_a_task
create_tasks(1)
last_id = TaskManage... | true |
e2987de704855c468ecd8ef6378b634de08c2286 | Ruby | ortizjs/algorithms_ | /LeetcodeQuestions/leetcode_challenges/February_challange/container_with_most_water.rb | UTF-8 | 341 | 3.28125 | 3 | [] | no_license | def max_area(height)
max_area = -Float::INFINITY
i = 0
j = height.length - 1
while i < j
current_area = [height[i], height[j]].min * (j - i)
max_area = [max_area, current_area].max
if (height[i] < height[j])
i += 1
else
j -= 1
end
... | true |
42210ac02513d94d8945841d87d70b687b1dd86e | Ruby | zacharytwhite/project-euler-solutions | /project_euler_rb/problem_063.rb | UTF-8 | 353 | 4.03125 | 4 | [] | no_license | # The 5-digit number, 16807=7**5, is also a fifth power. Similarly, the 9-digit number, 134217728=8**9, is a ninth power.
# How many n-digit positive integers exist which are also an nth power?
pows = []
1.upto(40) do |i|
1.upto(40) do |j|
pows << [(i**j), j, i] if j == (i**j).to_s.length
end
end
puts pows.... | true |
a6ed751d3a12239ad5bc1d68c4383bb9bca89af0 | Ruby | leri-berry/ruby | /lesson_2/fibonacchi_array.rb | UTF-8 | 253 | 3.546875 | 4 | [] | no_license | #Заполнить массив числами фибоначчи до 100
fibonacci_numbers = [0, 1]
element = 1
while element < 100
fibonacci_numbers << element
element = fibonacci_numbers[-2] + fibonacci_numbers[-1]
end
puts fibonacci_numbers | true |
4b8279b9e8f314801a5c8832b5e949879fd6c283 | Ruby | gjanee/advent-of-code-2016 | /22.rb | UTF-8 | 11,642 | 3.421875 | 3 | [] | no_license | # --- Day 22: Grid Computing ---
#
# You gain access to a massive storage cluster arranged in a grid;
# each storage node is only connected to the four nodes directly
# adjacent to it (three if the node is on an edge, two if it's in a
# corner).
#
# You can directly access data only on node /dev/grid/node-x0-y0, but
# ... | true |
1a697202669927ee6b72271f945f98e0127f1b0e | Ruby | gagandt/ruby_learn | /loops.rb | UTF-8 | 551 | 3.96875 | 4 | [] | no_license | count = 1
while (count < 5)
puts "While chala #{count} baar."
count += 1
end
puts "Until is the opposite of While!"
until (count < 2)
puts "Until chala #{6-count} baar."
count -= 1
end
puts "Each loop cahalega ab!"
nums = [1,2,3,4,5]
nums.each do |x|
puts "Each loop cahala #{x} baar."
end
puts "For chalega a... | true |
321d9db9c712e71fb7ef99361d19aa6d38cec08c | Ruby | willfowls/prepcourse | /ruby_books/intro_to_ruby/review_practice/variables/2.rb | UTF-8 | 494 | 4.21875 | 4 | [] | no_license | # write a program called age that asks user age and tells how old they will be in 10,20,30,40 years.
puts "What is your age?"
age = gets.chomp.to_i
puts "In 10 yeqrs you will be:"
puts age + 10
puts "In 20 years you will be:"
puts age + 20
puts "In 30 years you will be:"
puts age + 30
puts "In 40 years you will be... | true |
cc4e2626e19815afe4631cdead3d01b1fea39482 | Ruby | yuki0920-playground/ruby-book | /lib/chapter7.rb | UTF-8 | 1,378 | 4.375 | 4 | [] | no_license | users = []
users << {first_name: 'Alice', last_name: 'Ruby', age: 20}
users << {first_name: 'Bob', last_name: 'Python', age: 30}
users.each do |user|
puts "氏名:#{user[:first_name]} #{user[:last_name]} 年齢#{user[:age]}"
end
def full_name(user)
"#{user[:first_name]} #{user[:last_name]}"
end
users.each do |user|
pu... | true |
cb88e4b2f977485d2748525a0d871ee02a1447d9 | Ruby | justinwang11/AppAcademy | /w3d3-master/URLShortener/app/models/shortened_url.rb | UTF-8 | 1,999 | 2.578125 | 3 | [] | no_license | # == Schema Information
#
# Table name: shortened_urls
#
# id :integer not null, primary key
# short_url :string
# long_url :string
# submitter_id :integer
# created_at :datetime
# updated_at :datetime
#
require 'uri'
class ShortenedUrl < ActiveRecord::Base
validates :short_url, ... | true |
83d5bc8f1d3d1e9c4f0b8bdaaa0b51b5ada59c45 | Ruby | osak/Contest | /GCJ/2011/Qual/C.rb | UTF-8 | 623 | 3.03125 | 3 | [] | no_license | #!/usr/bin/ruby
cases = gets.to_i
1.upto(cases) do |num|
t = gets.to_i
cs = gets.split.map(&:to_i)
sum_bit = cs.inject(&:^)
sum = cs.inject(&:+)
ans = "NO"
if sum_bit == 0
tbl = Array.new(2) { Array.new(1<<20) {0} }
cs.each do |c|
tbl[0].each_with_index do |val,bit|
... | true |
2fa6f0c0992c6188400f9dfd8892e7bf42931300 | Ruby | julianrubisch/sr-filterable-reflex | /restaurant.rb | UTF-8 | 1,641 | 2.921875 | 3 | [
"MIT"
] | permissive | require "time"
# mimicks an ActiveRecord scope
module RestaurantRefinements
refine Array do
def search(query)
filter do |restaurant|
restaurant.name.downcase.include?(query.downcase)
end
end
def rating_from(from)
filter do |restaurant|
restaurant.rating >= from
... | true |
df6a8fd4db30c687cb347ce8f0421bc04599b7ce | Ruby | johnvoon/launch_school | /challenges/advanced1/ocr.rb | UTF-8 | 1,552 | 3.71875 | 4 | [
"MIT"
] | permissive | class OCR
NUMBERS_LAST_ON_LINE = {
"\s_\n|\s|\n|_|\n" => '0',
"\n\s\s|\n\s\s|\n" => '1',
"\s_\n\s_|\n|_\n" => '2',
"\s_\n\s_|\n\s_|\n" => '3',
"\n|_|\n\s\s|\n" => '4',
"\s_\n|_\n\s_|\n" => '5',
"\s_\n|_\n|_|\n" => '6',
"\s_\n\s\s|\n\s\s|\n" => '7',
"\s_\n|_|\n|_|\n" => '8',
"\s... | true |
9be9a600c8f2d3bbbf78a4e8b9fa0fe231acdfc9 | Ruby | iron-io/iron_consumer_starter | /addmsg.rb | UTF-8 | 396 | 2.765625 | 3 | [
"MIT"
] | permissive | # Simple script to put a message on the queue for testing.
require 'iron_mq'
require 'yaml'
config = YAML.load_file('config.yml')
mq = IronMQ::Client.new(config['iron'])
# qname defined by user too
qname = config['workqueue']
queue = mq.queue(qname)
msg = {
"mystring" => "Hello #NAME#!"
}
queue.post(msg.to_json)... | true |
309de07a49a4108724e313d547108031ca9ba4ad | Ruby | kozakikaoru/avalon-net | /app/models/tournament.rb | UTF-8 | 635 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
class Tournament < ApplicationRecord
has_many :results, dependent: :delete_all
accepts_nested_attributes_for :results
validates :name, presence: true
validates :game_type, presence: true
validates :prize, presence: true, numericality: { only_integer: true }
val... | true |
cecde53d7a4e37d9afe65e28a4a35c708991398a | Ruby | ezkl/peddler | /lib/mws/response.rb | UTF-8 | 1,414 | 2.875 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'mws/xml'
module MWS
# A wrapper around an Amazon Marketplace Web Service (MWS) response.
class Response
# Returns the String response body.
attr :body
# Returns the Integer HTTP response code.
attr :status
# Creates a new Response.
#
# response - A Faraday... | true |
dd806afa959b8ac009b7eeef1ecb65b3ab0a925d | Ruby | theckman/rmuh | /lib/rmuh/serverstats/advanced.rb | UTF-8 | 526 | 2.59375 | 3 | [
"MIT"
] | permissive | # -*- coding: UTF-8 -*-
require 'rmuh/serverstats/base'
module RMuh
module ServerStats
# This is an advanced extension of the Base class. This adds the ability to
# access the top level keys returned from the server using dot notation
#
# No additions / alterations exist to the methods from the Base... | true |
03cafb6d85bfaf64aa680aae20a5b1070df9ecb8 | Ruby | dealencarmarcelo/factorial | /main.rb | UTF-8 | 200 | 3.609375 | 4 | [
"MIT"
] | permissive | require './lib/factorial'
def menu
p "Digite um número inteiro para o Fatorial"
number = Integer(gets) rescue 'Por favor, dígite apenas números inteiros.'
p factorial(number)
end
menu | true |
12e55acd07b09fca4a673694de6e70933072a29a | Ruby | ministryofjustice/Claim-for-Crown-Court-Defence | /lib/tasks/rake_helpers/load_test_setup_checker.rb | UTF-8 | 3,162 | 2.8125 | 3 | [
"MIT"
] | permissive | module RakeHelpers
class LoadTestSetupChecker
WRAPPER_DIR = File.expand_path(File.join(Rails.root, '..', 'tsung-wrapper'))
PARENT_DIR = File.expand_path(File.join(Rails.root, '..'))
XML_CONFIG = File.expand_path(File.join(WRAPPER_DIR, 'config', 'project', 'adp', 'xml', 'staging-gradual-create_guilty_ple... | true |
d93135942bafdd446f38249694a79b58bf1b1c78 | Ruby | Nacht-Musik/meeting-app | /app/helpers/projects_helper.rb | UTF-8 | 3,103 | 2.546875 | 3 | [
"MIT"
] | permissive | module ProjectsHelper
class FormWithErrorMessageBuilder < ActionView::Helpers::FormBuilder
# 従来のフォームに加えて、エラーがある場合にエラーメッセージを表示するメソッド
def input_field_with_error(attribute, options={}, &block)
# 入力フォームと同じ属性のエラーメッセージを取得する
error_messages = @object.errors.full_messages_for(attribute)
# エラーがある場合のみ... | true |
9a7669d60ee5f8143ac50bdb76a6ff370662e2c0 | Ruby | trivett/BEWD-NYC | /classwork/happi/app/models/animal.rb | UTF-8 | 476 | 2.71875 | 3 | [] | no_license | class Animal < ActiveRecord::Base
belongs_to :shelter
belongs_to :client
has_many :toys
def owner
if self.client
self.client.name
elsif self.shelter
self.shelter.name
else
"I'm orphaned!"
end
end
def adopt(client)
shelter = self.shelter
shelter.animals.delete(sel... | true |
081029e309196f32caba223dec2d575f51677ef1 | Ruby | jakeaustin/wdi_2_ruby_sql_lab_hogwarts | /house.rb | UTF-8 | 830 | 3.359375 | 3 | [] | no_license | require_relative 'student'
class House
attr_reader :name, :students, :animal, :points
def initialize(name:, animal:, points: 0)
@name, @animal, @points = name, animal, points
@students = []
end
def add_student(student)
@students << student
end
def undergrad_roster
students.map {|student|... | true |
2334d5713b90ab3a9253ade146064ed858d8c846 | Ruby | svenmauer/ttt-4-display-board-rb-cb-000 | /lib/display_board.rb | UTF-8 | 254 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Define display_board that accepts a board and prints
# out the current state.
def display_board(xes)
puts " #{xes[0]} | #{xes[1]} | #{xes[2]} \n-----------\n #{xes[3]} | #{xes[4]} | #{xes[5]} \n-----------\n #{xes[6]} | #{xes[7]} | #{xes[8]} \n"
end
| true |
60acd8d67d892c1af976a6e4be20947e5d685f17 | Ruby | Petitenelly/projetruby.rb | /exo_05.rb | UTF-8 | 104 | 3.390625 | 3 | [] | no_license | puts "Choisis un nombre stp "
number = gets.chomp.to_i
number.times do
puts "Salut, ça farte?"
end | true |
d2aa480b2a5ecaf3480860a3f8a607e5f8f1fe69 | Ruby | Eiriksmal/toy-ruby-projects | /lib/movie_ticket_purchase.rb | UTF-8 | 2,627 | 3.1875 | 3 | [] | no_license | class MovieTicketPurchase
def initialize(movie_duration_minutes, day_of_week, is_balcony_seats, is_3d)
@price_modifiers = 0
@tickets_sold = []
@is_thursday = false
# save the initial parameters that effect this movie's price: 3D, balcony seats, etc.
calculate_price_modifiers(movie_duration_minut... | true |
3a1eb3882baa54c15e75ddd50b6da041da2b1855 | Ruby | Flammable-Duck/basic-ruby-projects | /bubble_sort/bubble_sort.rb | UTF-8 | 337 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: false
def bubble_sort(array)
last_iteration = array.clone
array.each_with_index do |number, index|
next if index == array.length - 1 || number < array[index + 1]
array[index] = array[index + 1]
array[index + 1] = number
end
return array if array == last_iteration
bubble... | true |
8f0136f583ba3b3049b8519408b0e6048b2a6122 | Ruby | GALTdea/piggy | /app/queries/financial_objects/annual_query.rb | UTF-8 | 1,019 | 2.578125 | 3 | [] | no_license | module FinancialObjects
class AnnualQuery < ApplicationQuery
def initialize(user, year, klass, category = nil)
super()
@user = user
@year = year
@klass = klass
@category = category
end
def total_currency
@klass.where(year_and_user)
.sum(:currency)
end
... | true |
9a9a48c38cd57bdd87ac61e5f5f3069b6978a01d | Ruby | gotchane/twitter_clone | /app/helpers/rooms_helper.rb | UTF-8 | 326 | 2.578125 | 3 | [] | no_license | module RoomsHelper
def room_participants(users)
users.map(&:name).join(" / ")
end
def message_read_count(message)
read_count = message.read_count(current_user)
read_count == 0 ? "Unread" : "Read:#{read_count}"
end
def read_state(room)
"--unread" if room.has_unread_message?(current_user)
en... | true |
4c7a9589228550578acc60e5e5190a1a00857474 | Ruby | jfahmy/array_intersection | /lib/array_intersection.rb | UTF-8 | 856 | 3.9375 | 4 | [] | no_license | # Creates a new array to return the intersection of the two input arrays
def intersection(array1, array2)
if array1 == nil || array2 == nil
return []
end
i = 0
while i < array1.length
k = 0
match = false
while k < array2.length && match == false
if array1[i] == array2[k]
match = ... | true |
85f81aa08ea7199855965947210120b8ae4fc478 | Ruby | gvino/rails_global_roles | /spec/global_roles/global_roles_spec.rb | UTF-8 | 3,050 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
# TODO Make specs readable
describe User, "with installed global role" do
context "class" do
describe "should have class methods" do
subject { User }
it { should respond_to(:values_for_global_role) }
it { User.values_for_global_role.should be_eql(User::ROLES) }
it ... | true |
3816b286ac69c4bbb9ecf55d83e0483e2ee992d4 | Ruby | zhangem/Library--Ruby-SQL | /lib/authors.rb | UTF-8 | 605 | 2.953125 | 3 | [] | no_license | class Authors
attr_reader :id, :name
def initialize(attributes)
@id = attributes['id']
@name = attributes['name']
end
def self.all
authors_list = []
results = DB.exec("SELECT * FROM authors;")
results.each do |x|
authors_list << Authors.new(x)
end
authors_list
end
def ... | true |
5e02f6cb5646d2f1ddb7839b842a9860ad05819b | Ruby | luluwang69/codewars | /kyu8/population.rb | UTF-8 | 598 | 3.453125 | 3 | [] | no_license | # def nb_year(p0, percent, aug, p)
# n = 1
#
# # p1 = p0 * (1 + percent*0.01)**n + aug
# # p2 = p1 * (1 + percent*0.01)**2 + aug
# # p3 = p2 * (1 + percent*0.01)**3 + aug
#
#
# a = Array.new(n) {|p0| p0 * (1 + percent*0.01) + aug}
#
# while a[-1] < p do
# n = n + 1
# end
# return n
# end
def nb_year(p0, ... | true |
fba818230a03f8d360985bb524cb5137a20ac58e | Ruby | ruggeri/more-practice-problems | /solutions/12_bulls_and_cows.rb | UTF-8 | 1,807 | 4.53125 | 5 | [] | no_license | # **Bulls And Cows**
#
# You are given two inputs, a string `secret` and a second string
# `guess`. You may assume both strings are of four letters.
#
# You must return two numbers. First, the number of correct letters at
# correct positions. For instance, if `secret = "abcd"` and `guess =
# "adcb"`, then the guess of ... | true |
a3554aa21c2768e375cd829929342b8049432f14 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/3daf1d02ea8e481a8cc865a21e434b1e.rb | UTF-8 | 441 | 3.6875 | 4 | [] | no_license | class Anagram
attr_reader :subject
def initialize(subject)
@subject = subject
end
def match(candidates)
candidates.select do |word|
!identical?(word) &&
anagram?(word)
end
end
def letter_frequency(string)
string.downcase.chars.sort
end
def identical?(word)
subject.... | true |
e21b533b79f7d9377215e04b473095129cde25a8 | Ruby | jwshinx/freddo | /service.rb | UTF-8 | 3,305 | 2.5625 | 3 | [] | no_license | require 'sinatra'
require 'active_record'
require 'yaml'
require 'haml'
env_index = ARGV.index("-e")
env_arg = ARGV[env_index + 1] if env_index
puts "---> 1: #{env_index.inspect}"
puts "---> 2: #{env_arg.inspect}"
env = env_arg || ENV["SINATRA_ENV"] || "development"
databases = YAML.load_file("config/database.yml")
A... | true |
079ee8ad8853ec175e40d59a1a8728bbbfe05c50 | Ruby | Darrantw/EventManager | /event_manager.rb | UTF-8 | 4,977 | 3.0625 | 3 | [] | no_license | require 'csv'
require 'google/apis/civicinfo_v2'
require 'erb'
require 'time'
require 'american_date'
def optimum_hour
contents = open_csv_file
hours_array = Array.new
hours_hash = Hash.new(0)
contents.each do |row|
date = row[:regdate]
date = Time.parse(date)
hour = date.hour
hours_array.pus... | true |
a9db94780c771f99360ac0e0f61570c9a98b9c2c | Ruby | eyupfurkan/RubyUdemy | /method.rb | UTF-8 | 168 | 2.90625 | 3 | [] | no_license | def user
puts "Hello Ruby"
end
user
def user2(first_name)
puts first_name
end
user2 "Steve"
def user_last_name(last_name)
puts last_name
end
user_last_name "Chesnowtiz" | true |
16a7e29d6d17a1dee965a9a98fe8843019fa2860 | Ruby | jessd898/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 1,744 | 4.53125 | 5 | [] | no_license |
=begin
Goal: take a real name and create a fake name
- Prompt user for their first name and then their last name
- name is stored as string, then split into array
- swap the order of the first and the last name
- store a consonants and vowel array
- loop through and with each index change vowels (aeiou) to... | true |
285fc3e3fe410c31d3a8dd0ad7492097a20d4da7 | Ruby | bfrey08/night_writer | /spec/message_spec.rb | UTF-8 | 995 | 3.296875 | 3 | [] | no_license | require './lib/message.rb'
RSpec.describe Message do
it 'exists' do
msg1 = Message.new
expect(msg1).to be_an_instance_of(Message)
end
it 'can store both translated and un translated messages as an array' do
msg1 = Message.new
expect(msg1.msg).to be_a(Array)
expect(msg1.translated_msg).to be_... | true |
95b3eb863d48ca0553435e11bbd4d7d4cc98d495 | Ruby | cyber-dojo/saver | /app/source/external/shell.rb | UTF-8 | 804 | 2.671875 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative '../lib/utf8_clean'
require 'open3'
module External
class Shell
def assert_cd_exec(path, *commands)
assert_exec(["cd #{path}"] + commands)
end
def assert_exec(*commands)
command = 'sh -c ' + quoted(commands.join(' && '))
stdout,stderr,r = Open3.capture3(command)
... | true |
eb3e9978fc12c8f0e32582978f93817dc5efbf46 | Ruby | rokibulhassan/Garage | /app/views/vehicles/show_vehicle_template.json.jbuilder | UTF-8 | 433 | 2.578125 | 3 | [] | no_license | # The fieldsets with these attributes.
# This template is used to seed data on the show vehicle page.
# It exposes the way fieldsets are displayed.
json.array! fieldsets do |json, fieldset_with_fields|
fieldset, fields = fieldset_with_fields
json.extract! fieldset, :name, :label
json.attributes fields do |jso... | true |
5cb9f9d755afbfb03e407a826a751ad78e306d1a | Ruby | rohithsankepally/ruby-learnings | /exception_handling.rb | UTF-8 | 293 | 3.46875 | 3 | [] | no_license | def divide(a, b)
if b == 0
raise "Denominator cannot be 0"
end
puts "#{a}/#{b} = #{a / b}"
rescue StandardError => e
puts "#{a} cannot be divided by #{b} : #{e.message}"
puts "StackTrace : #{e.backtrace.inspect}"
end
if __FILE__ == $0
divide(5.0, 3)
divide(5.0, 0)
end | true |
ffa1aca782277f8a96cbf35e928c0ec151ebd6ca | Ruby | mrlukaszfuszara/DeepLearninig.rb | /lib/util/conv_math.rb | UTF-8 | 3,630 | 2.859375 | 3 | [
"MIT"
] | permissive | class ConvMath
def padding(volume, pad)
pa = 0
while pa < pad
i = 0
while i < volume.size
volume[i].push([0.0] * volume[i].size)
volume[i].unshift([0.0] * (volume[i].size - 1))
j = 0
while j < volume[i].size
volume[i][j].push(0.0)
j += 1
... | true |
f7c188c9226e6afcb0b7326ef24800a440bd92de | Ruby | hipjim/Publify | /app/models/ad.rb | UTF-8 | 3,103 | 2.71875 | 3 | [] | no_license | # == Schema Information
# Schema version: 20110206151022
#
# Table name: ads
#
# id :integer(4) not null, primary key
# title :string(255) not null
# body :text default(""), not null
# ad_type :string(255) not null
# ip :string(255)
# hits :integer... | true |
87a7a0c5e0d9457cef9bb94e7c9e4ad0e29037c7 | Ruby | Keefeef/Ruby-Classes-Practice | /classes_lab_c/library.rb | UTF-8 | 472 | 2.765625 | 3 | [] | no_license | class Library
def setup
attr_accessor :book_title, :rentee_name, :rental_date
def initialize(book_title, rentee_name, rental_date)
@book_title = book_title
@rentee_name = rentee_name
@rental_date = rental_date
@book = {
title: book_title,
rental_details: {
student_nam... | true |
224ef68ce0543de13a1d64bf70075f7f9f0ece1a | Ruby | downhome/largest_remainder_method | /lib/largest_remainder_method.rb | UTF-8 | 786 | 3.375 | 3 | [
"MIT"
] | permissive | require "largest_remainder_method/version"
require "largest_remainder_method/number"
require 'bigdecimal'
class LargestRemainderMethod
class Error < StandardError; end
class << self
def round(numbers, precision: )
new(numbers, precision).call
end
end
def initialize(numbers, precision)
@numb... | true |
5b6c5b11b2e6bdad16442b4eb2bd906869b5ce72 | Ruby | jdcorona96/triangle-classification-cb-gh-000 | /lib/triangle.rb | UTF-8 | 590 | 3.421875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
# write code here
def initialize(a, b, c)
@a = a
@b = b
@c = c
end
attr_accessor :a, :b, :c
attr_reader :type
def kind
if @a+@b <= @c ||
@b+@c <= @a ||
@a+@c <= @b then
begin
raise TriangleError
end ## if_error
elsif @a == @b && ... | true |
44b520b4fb0f520338df67db518bc072f7aa3f12 | Ruby | patrickcrocker/reteamer | /spec/models/people_spec.rb | UTF-8 | 1,854 | 2.765625 | 3 | [] | no_license | require "rails_helper"
RSpec.describe People do
it "let's you save multiple objects for the same day" do
People.create(Date.current, first_name: "Peter")
People.create(6.days.from_now, first_name: "Paul")
People.create(2.days.from_now, first_name: "Mary")
expect(People.find_for(6.days.from_now).coun... | true |
deeffae754b8cb144e59a6bd6ea1dcbda798bfb2 | Ruby | Alej/WriteMyCode | /lib/RObjC/logic/tokenize.rb | UTF-8 | 1,648 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module RObjC
module Tokenize
class MissingPatternError < StandardError
end
def self.included(base)
super
base.extend(ClassMethods)
end
module ClassMethods
def tokenize_code(code)
tokenized_code = code.dup.to_code
tokens = tokenize_code!(tokenized_c... | true |
f91209292f075103755a0ded1a881062b8d4dfd8 | Ruby | tomboates/Knowstra-Admin | /csv_scripts/delete_user_answers_script.rb | UTF-8 | 1,914 | 2.765625 | 3 | [] | no_license | require 'csv'
require 'uri'
require 'net/http'
require 'net/https'
require 'cgi'
require 'json'
require 'geocoder'
## Parse Api keys
@PARSE_APP_ID = 'KRsv5fl3h1k1qvRvhEQyITCnvIZ7eq8uJDJp9JRC'
@PARSE_REST_KEY = 'SrQRoGsr3Hse9VTXaFnOA6CsopZxx8UjIvlMIFNJ'
## QA Keys
# @PARSE_APP_ID = 'DoZASTALoss5wZIOd8SAJQSSjki4BBrQ2QyH... | true |
5cbc333ba2267e03bb6a80be0892e84e86634b4b | Ruby | rongxanh88/1module-projects-complete_me | /test/node_test.rb | UTF-8 | 505 | 2.65625 | 3 | [] | no_license | require 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require '../lib/node'
class NodeTest < Minitest::Test
attr_reader :node
def setup
@node = Node.new
end
def test_node_instance
assert node.instance_of?(Node)
end
def test_has_children
childs = {}
assert_equal childs... | true |
69f0405d5386c9e08ee54901f2def2175004f0f7 | Ruby | inesgs12/ruby-boating-school-london-web-career-042219 | /app/models/instructor.rb | UTF-8 | 1,588 | 3.546875 | 4 | [] | no_license |
class Instructor
attr_reader :instructor
@@all = []
def initialize(instructor)
@instructor = instructor
@@all << self
end
def self.all
@@all
end
def tests_by_instructor
BoatingTest.all.select {|test| test.instructor == self}
end
def pass_student(student, test_name) #take these... | true |
23b176709e0dfeeb26b02b671e35da8c8cfc2100 | Ruby | lzhangss/max-bodysize-evol | /lib/remote_link_renderer.rb | UTF-8 | 933 | 2.671875 | 3 | [
"MIT"
] | permissive | # = AJAX Link Renderer
#
# Purpose: Allow will paginate to produce ajax links
#
class AjaxLinkRenderer < WillPaginate::LinkRenderer
#
# Purpose: prepare a link (see WillPaginate::LinkRenderer for details)
#
# Input: collection, options, template (see WillPaginate::LinkRenderer for details)
# Output:
# * ... | true |
97defe773ea1629f266211e5a5ddc164d98e1aed | Ruby | zorrobyte/comma_api_rb | /example/athena_example.rb | UTF-8 | 155 | 2.578125 | 3 | [] | no_license | # require 'comma-api-rb'
require_relative '../lib/comma-api-rb'
Athena = CommaAPI::Athena
carState = Athena.carState()
puts "carState: #{carState}\n\n"
| true |
818ee83746eead969a5acdb6de9f9254517c5507 | Ruby | Skywalkcat428/furima-30613 | /spec/models/item_spec.rb | UTF-8 | 3,194 | 2.765625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品情報入力' do
context '出品がうまくいくとき' do
it '出品画像、商品名、商品の説明、商品の詳細(カテゴリーと商品の状態)、配送について(配送料の負担、発送元の地域、発送までの日数)、販売価格が存在すれば登録できる' do
expect(@item).to be_valid
end
end
cont... | true |
d4dcce8796cbc3dc6664bb371f0369b551a27c90 | Ruby | Dreat/mazes_for_programmers | /binary_tree_demo.rb | UTF-8 | 127 | 2.515625 | 3 | [] | no_license | require 'grid'
require 'binary_tree'
grid = Grid.new(9,9)
BinaryTree.on(grid)
puts grid
img = grid.to_png
img.save "maze.png"
| true |
c9510d3e73164f13668b5db00647614ff5f6c324 | Ruby | sh84/filecluster | /lib/manage/copy_speed.rb | UTF-8 | 1,978 | 2.671875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'shellwords'
def copy_speed_list
FC::Var.get_speed_limits.each do |name, val|
puts name.to_s+(val ? " - limit: #{val}Mbit" : " - unlimit")
end
end
def copy_speed_add
hosts = ['all'] + all_hosts
puts "Add copy speed limit"
begin
host = stdin_read_val("Host (default #{FC::Sto... | true |
a0f3dac1ecc552360c33ef178e73c69cb34f6f93 | Ruby | tyler569/lisp | /expect.rb | UTF-8 | 1,640 | 3.421875 | 3 | [] | no_license | require 'stringio'
require_relative 'lisp'
require_relative 'colors'
def capture(&block)
sio = StringIO.new
value = nil
begin
old_stdout = $stdout
$stdout = sio
value = yield
ensure
$stdout = old_stdout
end
[value, sio.string]
end
class Expectation
@@runs = 0
@@passes = 0
@@failures ... | true |
1843384620baf847b96018934922999d8f2836a0 | Ruby | timor/mfactor | /lib/mfactor/tokenizer.rb | UTF-8 | 737 | 2.859375 | 3 | [
"Unlicense"
] | permissive | module MFactor
class Token < String
attr_reader :line, :column
def initialize(str, line, col)
super str
@line=line
@column=col
end
end
class Tokenizer
include Enumerable
attr_reader :filename
def initialize source
@filename = (source.is_a? File and source.path)
... | true |
771e58669a0c678c6fede88ee2fb6d7f9e04bb83 | Ruby | epitron/scripts | /cat-until | UTF-8 | 693 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
########################################################
gem 'slop', "~> 3.6"
require 'slop'
require 'epitools'
########################################################
########################################################
opts = Slop.parse(help: true, strict: true) do
banner "Usage: cat-unti... | true |
4cefe82e065b07c8094ad8cea8b900b0b936ca8f | Ruby | quintel/etlocal | /app/services/chart_renderer/color_generator.rb | UTF-8 | 1,346 | 2.984375 | 3 | [
"MIT"
] | permissive | class ChartRenderer
class ColorGenerator
OPACITY = 0.7
LEGEND_ITEMS_COUNT = 5
def initialize(chart, datasets)
@chart = chart
@datasets = datasets
@gradient = Gradients.new(*@chart.color_stops)
end
def generate
{
stops: stops,
legend: {
scale: ... | true |
e46fb12bca7c03e5feadeb0b381b65f614f8a55c | Ruby | cbrand/ruby-filterparams | /spec/binding/binding_parser_spec.rb | UTF-8 | 1,244 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'rspec'
require 'spec_helper'
require 'parslet/rig/rspec'
require 'filterparams/binding/binding_parser'
require 'parslet/convenience'
describe Filterparams::BindingParser do
let(:parser) { described_class.new }
it 'should be able to parse a simple parameter' do
parsed = parser.parse 'parameter'
... | true |
72e28719e32431da52796df29e636baa782a7363 | Ruby | JWNg/ruby_kickstart_challenges | /session4/2_subclassing_require.rb | UTF-8 | 894 | 3.734375 | 4 | [] | no_license | # Require the stack code from challenge 1
# The code you added causes it to do this
#
# stack = Stack.new
# stack.push 1
# stack.push 2
# stack # => (2)1)
# But sometimes you want it to inspect like an array.
# stack # => [1, 2]
#
# Subclass the Stack class and override its inspect
# so that we can do this:
#
# stack... | true |
a000055766aa1c34e495ee893697deff07e8c721 | Ruby | jbyrnes-shay/Launchschool-2019 | /small_problems/easy6/delete_vowels.rb | UTF-8 | 813 | 4.375 | 4 | [] | no_license |
=begin
sDelete vowels
Write a method that takes an array of strings,
and returns an array of the same string values,
except with the vowels (a, e, i, o, u) removed.
Example:
remove_vowels(%w(abcdefghijklmnopqrstuvwxyz)) == %w(bcdfghjklmnpqrstvwxyz)
remove_vowels(%w(green YELLOW black white)) == %w(grn YLLW blck w... | true |
f82853e3e3d8f7823dd94ebba5effad1136852a2 | Ruby | mudhabir/resource-allocation | /lib/resource_allocation.rb | UTF-8 | 4,450 | 3.15625 | 3 | [] | no_license | class ResourceAllocation
CPU_SIZE = ['large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', '10xlarge']
CPU_COUNT = {
'large'=> 1,
'xlarge'=> 2,
'2xlarge'=> 4,
'4xlarge'=> 8,
'8xlarge'=> 16,
'10xlarge'=> 32,
}
# We can update the cost of instances, add or remove instances in a region
RE... | true |
d921387da4e9a5fe67c0da363562e93be9dd4d15 | Ruby | ruby/TryRuby | /translations/renumber_translations.rb | UTF-8 | 2,485 | 3.265625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# A simple renumbering tool. Files for all languages are renumbered with an interval of 10.
# Not much checking is done (are there any files found at all, etc.)
# If --git option is added the renumbering will be executed as git commands
class RenumberTranslations
def initialize(for_real, commit... | true |
061c1d9d97de28e4ba03756cbc72e3353f1d7ca3 | Ruby | jastack/big_o | /max_windowed_range.rb | UTF-8 | 1,406 | 3.984375 | 4 | [] | no_license | def windowed_max_range(array, window_size)
max_range = nil
(0..array.length - window_size).each do |i|
windowed_array = array[i...i + window_size]
min = windowed_array.min
max = windowed_array.max
max_range = max - min if max_range.nil? || max - min > max_range
end
max_range
end
p windowed_ma... | true |
d5f6a40d5a54e6982b812e2b2eebeeea9df8542a | Ruby | roybleas/toyrobot | /run.rb | UTF-8 | 412 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
# ./run.rb ./runfiles/test01.txt ./runfiles/test02.txt ./runfiles/test03.txt ./runfiles/test04.txt ./runfiles/test05.txt
#
# Outputs
#
# 0,0,NORTH
# 0,1,NORTH
# 4,3,SOUTH
# 4,0,SOUTH
# 0,1,NORTH
# 0,0,WEST
# 3,3,NORTH
require './lib/inputfiles'
require './lib/robot'
command_list_text = ... | true |
6f4a25acf3a6bf869669f15be8e521fd731c84a9 | Ruby | samuelgustave/ruby-workbook-oo | /easy_quiz2/ex7.rb | UTF-8 | 394 | 4 | 4 | [] | no_license | # ex7.rb
class Cat
@@cats_count = 0 # this is a class variable. It counts the number
# of cats that have been instanciated because we increment it
# every time in the itialize method
def initialize(type)
@type = type
@age = 0
@@cats_count += 1
end
def self.cats_count
@@cats_count
end
... | true |
94ac12eb6c06f02a852e3d6f6ea8fb0c74da84f0 | Ruby | DT021/x-stocks | /app/models/x_stocks/position/avg_dividend_rating.rb | UTF-8 | 675 | 3.046875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module XStocks
class Position
# Average Dividend Rating Calculator
class AvgDividendRating
def initialize
@dividend_rating = 0
@market_value = 0
end
def add(dividend_rating, div_suspended, market_value)
return if market_value.zero?
... | true |
7425d4079659c32100d3a1eee634db3fba74a4af | Ruby | deprezedouard/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 1,274 | 2.765625 | 3 | [] | no_license | require 'json'
require 'open-uri'
puts 'Cleaning database...'
Dose.destroy_all
Cocktail.destroy_all
Ingredient.destroy_all
puts 'Creating ingredients...'
url = 'https://www.thecocktaildb.com/api/json/v1/1/list.php?i=list'
ingredients_serialized = open(url).read
ingredients = JSON.parse(ingredients_serialized)
ings =... | true |
e09ba115339a73772e5bf6d5efb85bf08db530af | Ruby | lkoponen/quiz_builder | /quiz_builder.rb | UTF-8 | 450 | 3.796875 | 4 | [] | no_license | require './questions'
prompt = "> "
puts "What subject would you like to work on?"
puts "Enter 1 for booleans, 2 for state capitals"
print prompt
type = gets.chomp().to_i
questions = Questions.new
if type == 1
questions = questions.boolean
elsif type == 2
questions = questions.capitals
end
questions.each do |pr... | true |
f5a98caf8a1e79b2479179952e3ce8989e72130c | Ruby | mctaylorpants/ruby-chess | /lib/knight.rb | UTF-8 | 682 | 3.015625 | 3 | [] | no_license | require "piece"
class Knight < Piece
def initialize(game, owner)
super
@type = :knight
@jumps_to_target = true
# each array within possible_offsets is an x,y offset from the current
# position of the piece. the resulting target coordinates will be
# validated by the board to make sure it ... | true |
36989d6ef404e50f11b8ea4558d49457d9a474a2 | Ruby | Kashfa/multiple-classes-lab- | /bus.rb | UTF-8 | 386 | 3.515625 | 4 | [] | no_license | class Bus
def initialize(route, destination)
@route = route
@destination = destination
@passengers = []
end
def drive
return "Brum Brum"
end
def count_passengers
return @passengers.count
end
def pick_up(name)
@passengers << name
end
def drop_off(name)
@passengers.del... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.