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
499f925ef3d69d8fbef3c8d21e8d56d420c93955
Ruby
rahulpatel2/exercism
/ruby/pascals-triangle/pascals_triangle.rb
UTF-8
423
3.671875
4
[]
no_license
# Paskal Tringle In Ruby class Triangle def initialize(size) @size = size end def rows return [[1]] if @size == 1 (1...@size).each_with_object([[1]]) do |index, paskal_rows| paskal_rows << generate(paskal_rows[index - 1]) end end def generate(array) (0...array.length - 1).each_with...
true
bdbebd44101380d3b98eac329e241ccaf400a563
Ruby
AbbottMichael/space_force_2105
/lib/spacecraft.rb
UTF-8
278
2.859375
3
[]
no_license
class Spacecraft attr_reader :name, :fuel, :requirements def initialize(data_hash) @name = data_hash[:name] @fuel = data_hash[:fuel] @requirements = [] end def add_requirement(data_hash) @requirements << data_hash end end
true
c92aa4b0e936ddca467cb2bd5fe1e56ae702d889
Ruby
antiny/Code4Pro
/db/seeds.rb
UTF-8
3,734
2.53125
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
dbc7c17bb6aee83c3256e2e1a9112f57d544ad01
Ruby
bharatvb6/Ruby-Learning
/raindrops.rb
UTF-8
542
3.515625
4
[]
no_license
require 'prime' class Raindrops @raindrop_sounds = Hash[3 => "Pling", 5 => "Plang", 7 => "Plong"] def self.factors(num) num.prime_division.map(&:first) end def self.convert(input) @sound = "" @factors = Array.new @factors = Raindrops.factors(input) #p "factors of #{input} is #{@factors} and #{@raindrop_s...
true
647107835eb5c111e8b5dc035e0344131272b91d
Ruby
salo18/intro-to-ruby
/Chapter4_FlowControl/e6.rb
UTF-8
458
3.484375
3
[]
no_license
(32 * 4) >= "129" ## false - integer != string ### WRONG - this raises and error but for the same reasons mentioned 847 == '874' ## false - integer != string '847' < '846' ## false - last value is compared and 6 is not greater than 7 '847' > '846' ## true - last value is compared and 7 is greater than 6 '847' > '8478'...
true
607c5727e373e3ea54ea6ff5656cba8a4b78d42d
Ruby
parkify/parkify-rails
/100028/update_images.rb
UTF-8
2,935
2.609375
3
[]
no_license
#!/usr/local/bin/ruby require 'rake' require 'rest_client' require 'active_support' production_server = ( ARGV.include?("--parkify-rails")) SERVER_URL = "http://parkify-rails-staging.herokuapp.com" if production_server SERVER_URL = "http://parkify-rails.herokuapp.com" end #find which sign_id to update current_dir...
true
f1a2eb4c6a24875341b7ccef973cc595a54f52d7
Ruby
helmedeiros/ruby_bits
/level_2/1_optional_argument/game.rb
UTF-8
155
3.109375
3
[ "Apache-2.0" ]
permissive
def new_game(name, year = nil, system = nil) { name: name, year: year, system: system } end game = new_game("Street Figher II") puts game
true
0d4a533825b5f4a965c5cc5082eb796e3345461e
Ruby
nguyenductung/galaxylegend
/lib/bullet.rb
UTF-8
1,708
2.890625
3
[]
no_license
class Bullet < GameObject class << self def image1 window @image1 ||= Gosu::Image.new(window, "assets/bullet1.png", true) end def image2 window @image2 ||= Gosu::Image.new(window, "assets/bullet2.png", true) end def fire_sound window @fire_sound ||= Gosu::Sample.new(window, "a...
true
53ca8a45d626e09151421aea5583401120a4f485
Ruby
marianneoco/battle
/app.rb
UTF-8
931
2.75
3
[]
no_license
require 'sinatra' require './lib/player' require './lib/computer' require './lib/game' class Battle < Sinatra::Base get '/' do erb :index end post '/names' do @player1 = Player.new(params[:player_1_name]) if params[:player_2_name].empty? @player2 = Computer.new("COMPUTER") else @pl...
true
8f7b45fc677a0d1bc350dba2ec1c65927952df2b
Ruby
jacobo/tnaidar
/lib/plugins/string_extensions/lib/string_extensions.rb
UTF-8
258
2.8125
3
[ "MIT" ]
permissive
module StringExtensions def titlecase self.gsub(/((?:^|\s)[a-z])/) { $1.upcase } end def to_name(last_part = '') self.underscore.gsub('/', ' ').humanize.titlecase.gsub(/\s*#{last_part}$/, '') end end String.send :include, StringExtensions
true
abc8f5f25bba93c0fda34aab3c24f89b3db6ef81
Ruby
RISCfuture/giffy
/app/controllers/slack_command_controller.rb
UTF-8
1,389
2.578125
3
[]
no_license
require 'slack' # @abstract # # Abstract superclass for all controllers that respond to Slack slash command. # This controller # # * validates the verification token given with the request against the app's # verification token (ignoring the request if it doesn't match), # * rescues from exceptions by returning a sh...
true
9afd2e61642986c593b98e550032206072022c6d
Ruby
farishkash/ruby
/note.rb
UTF-8
579
3.453125
3
[]
no_license
class Note attr_accessor :notes def initialize(notes) @notes = notes end def show puts "Testing this note #{@notes}" end def preview puts "Preview of my notes:" @notes.each do |note| if note.notes.length < 30 puts note.notes else puts note.notes[0..29] + "(......
true
b0e41aed5218aecc476d3399a3b3305b440a41ad
Ruby
calacademy-research/antcat
/app/services/what_links_here_columns.rb
UTF-8
795
2.5625
3
[]
no_license
# frozen_string_literal: true class WhatLinksHereColumns def initialize record, columns_referencing_record @record = record @columns_referencing_record = columns_referencing_record end def all columns end def any? any_columns? end private attr_reader :record, :columns_referencing_...
true
3db9c0853e462a9a136ed9c2ce5a04879ea1388a
Ruby
pastorp3/Telegram_motivational_bot
/lib/bot.rb
UTF-8
1,697
3.171875
3
[ "MIT" ]
permissive
# rubocop:disable Metrics/MethodLength # rubocop:disable Layout/LineLength # rubocop:disable Style/RedundantInterpolation # rubocop:disable Layout/IndentationConsistency require 'telegram/bot' require_relative 'motivate.rb' require_relative 'joke.rb' class Bot def initialize token = '1167629539:AAGQm4Kj0hUclTkDE...
true
5bacba83596d3c37300df79793e62600eb057a05
Ruby
talum/espresso-shot
/lovenotes.rb
UTF-8
61
2.90625
3
[]
no_license
love = true while (love) puts "I love you" love = false end
true
ce62b7ce74725a022962ef07f5fa142e798543b8
Ruby
Jun-Fukushima/test2
/test.rb
UTF-8
54
3.09375
3
[]
no_license
sum=0 (1..100).each do |n| sum = n+sum end puts sum
true
e76dda6c351ab7b61e03e99721a5babb24bcf535
Ruby
dshue20/AA_classwork
/Week_6/W6D3/chess/slideable.rb
UTF-8
2,055
3.546875
4
[]
no_license
require "byebug" module Slideable def possible_moves x,y = pos get_bishop_moves(x,y) if move_dirs.include?("diagonal") get_rook_moves(x,y) if move_dirs.include?("h/v") moves end def get_rook_moves(x,y) # moving left temp = x until temp == 0 ...
true
57c6f912183e19ab9629ee6d773d89e11afe56a9
Ruby
paritoshbotre/Training_josh
/methods.rb
UTF-8
408
3.5
4
[]
no_license
def sum_of_four num1, num2, num3, num4 sum = num1 + num2 + num3 + num4 end def addition_of_2 num1, num2 num1 + num2 end def empty? end def concate_string string1, string2 return "Not String Arguments" if !string1.is_a? String return "Not String Arguments" if !string2.is_a? String string1 + string2 end sum...
true
eb27cdb8771ee7e8353d3084a2bddf470aaaa4f8
Ruby
violetzijing/practice
/string/camel-string.rb
UTF-8
135
3.234375
3
[]
no_license
#!/usr/bin/env ruby # s = gets.strip array = s.split("") count = 1 array.each {|i| count += 1 if ('A'..'Z').include? i } puts count
true
7ee17015568ec5d4229076b301998575ddedce7d
Ruby
10kh-at-rb/appacademy_curriculum_followup
/w3d2/reply.rb
UTF-8
1,550
2.90625
3
[]
no_license
require_relative 'questions_database' require_relative 'table' class Reply def self.all results = QuestionsDatabase.instance.execute('SELECT * FROM replies') results.map { |result| Reply.new(result) } end def self.find_by_question_id(question_id) results = QuestionsDatabase.instance.execute(<<-SQL,...
true
d35466d44bfca9c1d6048d9e752e82bec86a120d
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/src/4312.rb
UTF-8
199
3.28125
3
[]
no_license
class Hamming def compute(left, right) diff = 0 0.upto([left.length, right.length].min - 1) do |i| if left[i] != right[i] diff = diff + 1 end end diff end end
true
49e950d5f29122b094032ddb741af6083c072bd2
Ruby
regishideki/parrondo_paradox
/game_random.rb
UTF-8
190
3.03125
3
[]
no_license
class GameRandom def initialize(games) @games = games @random = Random.new end def play(chips) chosen = @random.rand(@games.size) @games[chosen].play(chips) end end
true
66833a1c0826ee6e5dbabfc0953a6668e9f3fcf7
Ruby
kazuminn/my_twitter_scripts
/description_follow.rb
UTF-8
915
2.5625
3
[]
no_license
# encoding:utf-8 require 'twitter' client = Twitter::REST::Client.new do |config| config.consumer_key = "" config.consumer_secret = "" config.access_token = "" config.access_token_secret = "" end followers_list = client.friends("") =begin followers_list.each do |x| p x.description end =end number...
true
34d03a884b0b540843136befe3a02514abb14160
Ruby
deepigarg/rubyx
/test/sol/test_while_statement1.rb
UTF-8
1,123
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require_relative "helper" module Sol class TestWhileConditionSlotMachine < MiniTest::Test include SolCompile def setup @compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4") @ins = @compiler.slot_instructions.next end def test_condition_compiles_to_check ...
true
23296765a721c3ddb5799dbed68bd3abe881670e
Ruby
dball1126/Coding_problems
/ruby/minimum_dominos.rb
UTF-8
641
3.515625
4
[]
no_license
def min_domino_rotations(a, b) aHash = Hash.new(0) bHash = Hash.new(0) min = Float::INFINITY a.each{|x| aHash[x] += 1} b.each{|x| bHash[x] += 1} (0...a.length-1).each do |i| ele1 = a[i] ele2 = b[i] if bHash[ele1].has_key?(ele1) && aHash[ele1] + bHash[ele1] >= a.length min = [min, a.length...
true
b2591cfb3555ca3ef88139f3c0fd314b75c50618
Ruby
sheamunion/dbc-phase-0
/week-5/die-class/my_solution.rb
UTF-8
5,673
4.5
4
[ "MIT" ]
permissive
=begin Die Class 1: Numeric I worked on this challenge [by myself] I spent 3.07 hours on this challenge. 0. Pseudocode Input: - a number (denoting some number of sides) - a request to display or set the number of sides of a die - a request to roll the die Output: - a number (the number of sides of a die), a...
true
453d8ee6ef648559411a5f641c7c7265cb004804
Ruby
ryosuke-endo/constants_management
/lib/constants_management.rb
UTF-8
459
2.734375
3
[ "MIT" ]
permissive
require 'yaml' class ConstantsManagement def initialize(source = self.class.source) create_const(YAML.load(File.open(source))) end def create_const(date) date.each do |klass, value| name = value.keys.first.upcase const = value.values.first self.class.const_set(klass, Class.new { |k| ...
true
a1d0306c15bee7a4d0bc4544f78f9dcb933d13fa
Ruby
pdougall1/game_of_life
/spec/game_spec.rb
UTF-8
460
2.875
3
[]
no_license
require 'stringio' require_relative '../lib/world' require_relative '../lib/cell' require_relative '../lib/game' describe Game do # not quite sure how to test the IO from the console. # def get_coordinates # $stdin.gets.chomp # end # before do # $stdin = StringIO.new("[1,2], [2,2], [3,1]") # end # af...
true
c00e1b763850536ce58de0f0bace32d73e74971f
Ruby
ChuckJHardy/ParseHub
/lib/parse_hub/promise.rb
UTF-8
801
2.890625
3
[ "MIT" ]
permissive
class ParseHub class Promise RESCUE_WAIT = 5 def initialize(waits:, trys:, answer:, finished:, delete:) @waits = waits @trys = trys @answer = answer @finished = finished @delete = delete end def self.run(*args, &block) new(*args).run(&block) end def run(&...
true
5bba67cdecb1ab72729bb6801e684e777bad598f
Ruby
fluorine/vowelremoval-gem
/test/test_vowelremoval.rb
UTF-8
354
2.890625
3
[ "MIT" ]
permissive
require "test/unit" require "../lib/vowelremoval.rb" class TestVowelRemoval < Test::Unit::TestCase def test_vowel_removal1 assert_equal("hola mundo".remove_vowels, "hl mnd") end def test_vowel_removal2 assert_equal("aeiou".remove_vowels, "") end def test_vowel_removal3 assert_equal("Viva Cristo...
true
855e9b005598235eab3a95f88112b1d5f2b592c9
Ruby
aaaa777/musicbot
/lib/bot.rb
UTF-8
663
2.53125
3
[]
no_license
require 'discordrb' class MusicBot < Discordrb::Commands::CommandBot def initialize() super( token: ENV['TOKEN'], prefix: 'm@'# default prefix. it will be selectable by Proc ) @downloader = YoutubeDL::Client.new end def start run end private def add_command(sym, **options, &...
true
3d9ba362a4f3057f3c1c769bd03bb343506c7268
Ruby
emilianolowe/launch-school-exercises
/Ruby/easy/easy1/how_many?.rb
UTF-8
352
3.703125
4
[]
no_license
#how_many? def count_occurrences(list) stock = Hash.new(0) list.each do |make| stock[make.downcase] += 1 end puts stock end vehicles = [ 'car', 'car', 'truck', 'car', 'SUV', 'truck', 'motorcycle', 'motorcycle', 'car', 'truck' ] count_occurrences(vehicles) # Expected Output =begin car => 4 truck =>...
true
d6c695b2a1ba0cb9206e2280e3b10231f912c460
Ruby
JustinData/GA-WDI-Work
/w01/d04/Justin/cap.rb
UTF-8
555
4.09375
4
[]
no_license
# "welcome to class!" # name of student, it's great to have you" # " " #"________________________________________" # capitalize all names, PJ requires a different method students =["remy the dog", "pj", "jeff", "peter"] students.each do |value| if value == "pj" puts "welcome to class!" puts "#{value.upcase}, it'...
true
7484f5cccbeebe688dee2961386875756e33be3b
Ruby
Holy-0116/rent-tools-app
/spec/models/address_spec.rb
UTF-8
2,881
2.5625
3
[]
no_license
require 'rails_helper' RSpec.describe Address, type: :model do before do @address = FactoryBot.build(:address) end describe "住所登録機能" do context "住所登録ができるとき" do it "全ての情報が入力されていれば登録できる" do expect(@address).to be_valid end it "建物名がなくても登録できる" do @address.building_name = n...
true
8fc727f241bc5e756349f953aa796ac3d6a038c8
Ruby
AlexisAuriac/202unsold_2018
/Parameters.rb
UTF-8
855
3.09375
3
[]
no_license
def usage() puts("USAGE") puts("\t./202unsold a b") puts("DESCRIPTION") puts("\ta\tconstant computed from the past results") puts("\tb\tconstant computed from the past results") end module Parameters def Parameters.parseParameters(argv) if argv.length == 1 and argv[0] == "-h" ...
true
84704f2639259aecd2a8fb4b759e58841ed1eb4a
Ruby
yuta-pharmacy2359/ruby_tutorial
/第4章/Sample4_7_14.rb
UTF-8
130
3.09375
3
[]
no_license
a = 'iphone' p a[2] #"h" p a[2, 3] #"hon" p a[-2] #n a[0] = 'X' p a #"Xphone" a[1, 4] = 'Y' p a #"XYe" a << 'fgh' p a #"XYefgh"
true
d484f308857b9203cd74e2858d2f58e643cf783e
Ruby
chevalun/projecteuler
/1-50/pe_34.rb
UTF-8
200
2.546875
3
[]
no_license
fac = [1] for i in 1..9 do fac[i] = fac[i-1]*i end s = 0 for i in 3..2540160 do sum = 0 temp = i.to_s for j in 0..temp.size-1 sum += fac[temp[j].to_i-48] end s += i if sum == i end p s
true
8c1e8c913ca5f5f89702c14249d4a53bc4c128fb
Ruby
CharlesDeLeo979/apis-and-iteration-dc-web-091619
/lib/command_line_interface.rb
UTF-8
161
3.21875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def welcome puts "Welcome to STARWARS SEARCH!" end def get_character_from_user puts "please enter a character name" char = gets.chomp char.downcase end
true
5eb2c20bb8e79912a12fdda8405db1e3221fbcd7
Ruby
Thialison/Marvel-API
/features/step_definitions/marvel_steps.rb
UTF-8
1,086
2.5625
3
[]
no_license
Dado("que acesse o EndPoint characters") do @marvel = MarvelChacarters.new end Quando("buscar por 5 personagens") do @marvel.buscar_por_cinco_personagens end Quando("buscar as comics de um único personagem") do @marvel.buscar_comics end Quando("buscar por pelo id {string}") do |id| @marvel_personagem_id = @m...
true
dada463e6293f0cb450a893645095cb4dba90aac
Ruby
domo2192/futbol
/test/game_test.rb
UTF-8
810
2.5625
3
[]
no_license
require 'CSV' require './test/test_helper' require 'mocha/minitest' require './lib/stat_tracker' require './lib/games_repo' require './lib/game' class GameTest < Minitest::Test def setup row = CSV.readlines('./data/games.csv', headers: :true, header_converters: :symbol)[0] @parent = mock('game_repo') @ga...
true
ba6d986a6bb2a310d564f829f8896cac330b5038
Ruby
orfah/samples
/l/1/distance.rb
UTF-8
5,318
3.703125
4
[]
no_license
#!/usr/local/bin/ruby # require 'optparse' require 'pp' # add a to_radians class to Fixnum and Float. Better solution? Leaves # out Integer, BigNum, etc... class Fixnum def to_radians self.to_f * (Math::PI/180) end end class Float def to_radians self * (Math::PI/180) end def mi_to_km self * 1....
true
a5aa02574e7f2e4ae3f9da9c65593b43b4132e04
Ruby
bocaruby/jambi
/lib/jambi/gem/catalog.rb
UTF-8
487
2.671875
3
[]
no_license
class Jambi::Gem::Catalog attr_reader :dir def initialize(dir) raise "Invalid catalog!" if dir.nil? || dir.empty? || !File.exists?(dir) @dir = dir end def gems @gems ||= Dir["#{@dir}/*"].map {|p| Jambi::Gem.new(p, self)}.sort end def gems_by_name(name) (@gems_by_name ||= {})[name] ||= gem...
true
d7bb7feee555ad2f2900e113ea8ac63961260aab
Ruby
rgathergood/CodeClan
/week_03/day_03/pizza_shop_end_point/models/customer.rb
UTF-8
887
3.15625
3
[]
no_license
require_relative('../db/sql_runner.rb') class Customer attr_reader(:id, :name) def initialize(options) @id = options['id'].to_i if options['id'] @name = options['name'] end def pizza_orders() sql = "SELECT * FROM pizza_orders WHERE customer_id = $1" values = [@id] results = SqlRunner....
true
307fa906955d81f7b2d6c170470967302556b644
Ruby
ysulaiman/communique
/experiments/meetings_mate.rb
UTF-8
4,924
2.53125
3
[]
no_license
# The purpose of this experiment is to study the relation between the number of # methods that do not contribute to solving the problem at hand and the # performance of the planner in terms of the number of explored nodes and the # (execution) time taken by the planner to solve the problem. # # The use case and classes...
true
9a6a5855ea857eb5a79fcf831ea690affbb78f00
Ruby
petems/rapgenius
/lib/rapgenius/scraper.rb
UTF-8
572
2.796875
3
[ "MIT" ]
permissive
require 'nokogiri' require 'httparty' module RapGenius module Scraper BASE_URL = "http://rapgenius.com/".freeze attr_reader :url def url=(url) if !(url =~ /^https?:\/\//) @url = "#{BASE_URL}#{url}" else @url = url end end def document @document ||= Nok...
true
7cd421e45d79c596ef505c38e12f482206bdc99a
Ruby
zeuslearning/lara
/app/models/sequence.rb
UTF-8
3,550
2.578125
3
[ "MIT" ]
permissive
class Sequence < ActiveRecord::Base attr_accessible :description, :title, :theme_id, :project_id, :user_id, :logo, :display_title, :thumbnail_url, :abstract include Publishable # models/publishable.rb defines pub & official has_many :lightweight_activities_sequences, :order => :position, :dependent => :destr...
true
06ed9672beb31c7d2a0788c6144ce5ce7056118f
Ruby
mxrch/thp_TDD
/01_temperature/temperature.rb
UTF-8
88
3
3
[]
no_license
def ftoc(nb) return (nb - 32) * 5/9 end def ctof(nb) return nb.to_f * 9/5 + 32 end
true
789c09c8f0159c1dffb381e0fb5c7e499ffd34aa
Ruby
fpcMotif/slack-shellbot
/slack-shellbot/commands/help.rb
UTF-8
1,096
2.640625
3
[ "MIT" ]
permissive
module SlackShellbot module Commands class Help < SlackRubyBot::Commands::Base HELP = <<-EOS I am your friendly Shellbot, here to help. General ------- help - get this helpful message uname - print the operating system name whoami - print your username Shell ----- ...
true
c5cc7ab8d5d00c114c9d03a7f177558caea8a58b
Ruby
railsfactory-pavan/Training
/Week-I/parser/check_class.rb
UTF-8
588
2.796875
3
[]
no_license
#method that check class declaration in cpp file def class_check(fname) class_no=0 l_no=0 ufile=File.open(fname,'r') ufile.each_line{|line| line.strip! l_no+=1 if line=~/^((public|protected|private)\s)?(class){1}\s[a-zA-Z_][a-zA-Z0-9_]+(\:((public|private)\s)?[a-zA-Z_][a-zA-Z0-9_]+(\,((public|privat...
true
ff4033aac2629d38884bb3837e062f526173ec4d
Ruby
ZulqarnainNazir/impact-sample
/app/classes/feeds/parsers/ical_parser.rb
UTF-8
843
2.671875
3
[]
no_license
# This parser process ical feeds via an ICS file require 'icalendar' module Feeds module Parsers class IcalParser < Feeds::BaseParser def parse(feed) cal_file = open(feed.url) calendars = Icalendar::Calendar.parse(cal_file) calendars.map do |calendar| calendar.events.map d...
true
11878e3ae92ca0bb860eb7c38022b79ee0a05a85
Ruby
sul-dlss/SearchWorks
/app/services/live_lookup/sirsi.rb
UTF-8
3,278
2.546875
3
[ "Apache-2.0" ]
permissive
class LiveLookup class Sirsi HIDE_DUE_DATE_LIBS = ['RUMSEYMAP'].freeze delegate :as_json, :to_json, to: :records def initialize(ids) @ids = ids end def records @records ||= response.xpath('//record').map do |record| LiveLookup::Sirsi::Record.new(record).as_json end ...
true
6f154f808a1f28f8a93ae6313737013a9c278969
Ruby
mmc1ntyre/toys
/toys-core/lib/toys/middleware.rb
UTF-8
4,321
2.65625
3
[ "MIT" ]
permissive
# frozen_string_literal: true # Copyright 2019 Daniel Azuma # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, mod...
true
d44d9388ce618d19c13f064195a619edcbdfbc89
Ruby
cwi-swat/meta-environment
/sisyphus/src/building/session.rb
UTF-8
1,352
2.765625
3
[]
no_license
module Building class Session attr_reader :time, :host, :db_session def initialize(time, host, db_session) @time = time @host = host @built = {} @emails = {} @db_session = db_session end def hostname if @host =~ /^([a-zA-Z0-9\-_.]+ [a-zA-Z0-9\-_.]+)/ then ...
true
efa9db905df48a0f57d4ce39fe33dac0b620031b
Ruby
Tahina93/ruby-event-oop
/lib/event.rb
UTF-8
776
3.421875
3
[]
no_license
require "pry" require "time" class Event attr_accessor :start_date, :duration, :title, :attendees def initialize(start_date, duration, title, attendees) @start_date = Time.parse(start_date) @duration = duration @title = title @attendees = attendees end def postpone_24h(start_date) @s...
true
b134b55250e71abab94a4701157fe0887ca039b6
Ruby
gumayunov/access_schema
/lib/access_schema/loggers/test_logger.rb
UTF-8
366
2.515625
3
[ "MIT" ]
permissive
module AccessSchema class TestLogger attr_reader :output attr_accessor :log_only_level %w{debug info warn error fatal}.each do |level| define_method(level) do |message = nil, &block| return if log_only_level && level != log_only_level @output = [@output, message || block.call].com...
true
d9b7b5aae154d21093584a95a0ff2bb78eb72561
Ruby
hashcrof/Algorithms
/reverse_polish_notation.rb
UTF-8
864
3.96875
4
[]
no_license
=begin Given a math expression in infix notation, generate the postfix notation The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . =end ###Shunting-Yard Algorithm def postfix(s) s = s.gsub(/\s/, '') len = s.length return 0 if len < 1 queue = [] op_stack = [] ...
true
d13b6d3a39701f3b6fbffee518b8710f6f5c3817
Ruby
codeZeilen/cocu
/test/cocu_test.rb
UTF-8
1,184
2.65625
3
[ "MIT" ]
permissive
require 'test_helper' require 'cucumber/formatter/cocu' class CocuTest < ActiveSupport::TestCase test "truth" do assert_kind_of Module, Cocu end end class Cucumber::Formatter::CoCu #public :reformat_name end class CocuFormatterTest < ActiveSupport::TestCase test "reformat name string" do name_stri...
true
562c350c7bfae7e0f56f3efd9eaba357c2a64499
Ruby
smith558/HackerRank_solutions
/breaking_the_records.rb
UTF-8
389
3.578125
4
[]
no_license
# Complete the breakingRecords function below. def breaking_records(scores) min, max = scores.first, scores.first min_breaks, max_breaks = 0, 0 scores.each do |i| if i > max max_breaks += 1 max = i elsif i < min min_breaks += 1 min = i end end [max_breaks, min_breaks] end ...
true
a30172130d850a062426a729070fc000d3764596
Ruby
bfolkens/snapshot-ebs
/lib/snapshot_ebs.rb
UTF-8
1,729
2.546875
3
[]
no_license
require 'rubygems' require 'logger' gem 'right_aws', '~>3.0.4' require 'right_aws' require 'net/http' require File.dirname(__FILE__) + '/silence_net_http' def lock_lvm(options = {}, &block) lvm_devs = `/sbin/dmsetup ls`.split("\n").map {|line| line.gsub /^(.+?)\t.*/, '\1' } lvm_devs.each do |lvmdev| $logger.info...
true
ab9fd93d0a638cc4ca704a29439cb2f3d4b97ca2
Ruby
gusmattos1/ruby_fundamentals_gusta
/exercise4.1.rb
UTF-8
155
3.75
4
[]
no_license
puts "What is your number today?" number = gets.chomp.to_i if number > 100 puts "that's a big number!" else puts "why not dream a little bigger?" end
true
4ce60306a841c36d61b4335119fb63b9c2c66052
Ruby
kcsoderstrom/Checkers
/board.rb
UTF-8
4,484
3.359375
3
[]
no_license
require_relative 'game' require_relative 'piece' require_relative 'cursor' require_relative 'chars_array' require_relative 'plane_like' require_relative 'chess_clock' require_relative 'checkers_errors' require_relative 'symbol' require 'colorize' class Board include PlaneLike include CheckersErrors COLORS = [:...
true
a856d66974b3ef850932791f68fa84ef1ce095b0
Ruby
dnewbie25/dnewbie25.github.io
/Ruby-Projects/Basic-Projects/Stock-Picker.rb
UTF-8
1,156
3.59375
4
[]
no_license
stocks_record = [17,3,6,9,15,8,6,1,10] def stock_picker(stocks) best_days = [] profit = 0 # loop from zero until array length entirely (0..(stocks.length-1)).each do |buy| # loop from day 2 forward for the selling. buy + 1 because otherwise it will start counting from day 2 all the time. This new ...
true
daf6a681521315f8f2190bbf683a94ff8c43ad48
Ruby
toptal/disqus_api
/lib/disqus_api/namespace.rb
UTF-8
1,303
2.796875
3
[ "MIT" ]
permissive
module DisqusApi class Namespace attr_reader :api, :name, :specification # @param [Api] api # @param [String, Symbol] name def initialize(api, name) @api = api @name = name @specification = @api.specifications[@name] @specification or raise(ArgumentError, "No such namespace <#...
true
348fc3a3c4c58bc710f29a58e97bd2e89a17ec64
Ruby
ipublic/marketplace
/app/models/parties/party_role_kind.rb
UTF-8
2,017
2.609375
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
# Actor roles or categories that a Party entity plays in the context of the enterprise. module Parties class PartyRoleKind include Mongoid::Document include Mongoid::Timestamps field :key, type: Symbol field :title, type: String field :description, type: String # Used for en...
true
0e3296e192b0b2610c3ad2a0c4297a78f4001fdf
Ruby
takatoshi-maeda/jawbone_up-client
/lib/jawbone_up/client/response.rb
UTF-8
756
2.671875
3
[ "MIT" ]
permissive
require 'jawbone_up/client/response/meta' require 'jawbone_up/client/response/item' module JawboneUp class Client class Response include Enumerable def initialize(response) @response = response end def code @response.code end def headers @response.he...
true
197172662a4639282cef946f507c4c7244e0c5ef
Ruby
davidsonhr1/orby
/scripts/ruby/oracle_sequence_fix.rb
UTF-8
3,289
2.734375
3
[]
no_license
require_relative '../../require.rb' require_relative '../../initialize.rb' include OrbyInitialize class Recreate_sequence def initialize time = Time.new @arg = OrbyInitialize.init @sequences_file = YAML.load_file("#{__dir__}/config/sequences.yaml") printf "Connecting to #{@arg[:ur...
true
d2f771002b8dbd031b2940a164e25d1e62de34f9
Ruby
bomberstudios/stone
/bin/stone-gen
UTF-8
1,375
2.875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'fileutils' require 'rubygems' def usage puts <<-EOS stone-gen model EOS end def model_usage puts <<-EOS stone-gen model ModelName field:type field:type ... e.g. stone-gen model Author name:string street_number:fixnum Works just like all the other mod...
true
c3b5ab5668e8dfac7fafc7e0252ca6a1d91c3767
Ruby
johnvpetersen/Nerd-Dinner-on-Rails
/lib/jsondinner.rb
UTF-8
476
2.640625
3
[]
no_license
class JsonDinner def initialize(dinnerid,title,latitude,longitude,description,rsvpcount,searchlatitude,searchlongitude,searchlocation,distance) @DinnerID = dinnerid @Title = title @Latitude = latitude @Longitude = longitude @Description = description @RSVPCount = rsvpcount @...
true
86e0ec4f1274e747616e4432a2cbc42096e00253
Ruby
NoahZinter/relational_rails
/spec/features/manufacturers/vehicles/index_spec.rb
UTF-8
4,460
2.640625
3
[]
no_license
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Manufacturer Vehicles Index' do it 'shows all of a manufacturers vehicles' do manufacturer = Manufacturer.create!(name: 'Zonda', production_capacity: 40, is_open: true) car_1 = manufacturer.vehicles.create!(name: 'Speedini', year: 1990, pr...
true
930b9cd3feb756cc510976303e84d89d42675f29
Ruby
Salsa-Dude/ruby-code-review
/Arrays-III/zip.rb
UTF-8
117
3.53125
4
[]
no_license
names = ["joe", "alex", "lina"] ages = [12, 29, 34] p names.zip(ages) # [["joe", 12], ["alex", 29], ["lina", 34]]
true
acbebad59733033cb293be19a245415e6a9d82a8
Ruby
AlinaMoskieva/sport_cms
/app/query_objects/top_news_in_category_query.rb
UTF-8
642
2.6875
3
[]
no_license
class TopNewsInCategoryQuery DEFAULT_LIMIT = 3 attr_reader :page, :limit private :page, :limit def initialize(page, limit: DEFAULT_LIMIT) @page = page @limit = limit end def all return top_in_category if top_in_category.any? top_in_site end private def published_pages Page.whe...
true
1c47165c8b41b0a4043b71d4eabc3f254d92030a
Ruby
mb-kaizen/coding-challenges-koans-data-structures-etc.
/data_structures/singly_linked_list_re.rb
UTF-8
958
3.9375
4
[]
no_license
class Node attr_accessor :value, :pointer def initialize(value) @value = value @pointer end end class LinkedList def initialize(value) @head = Node.new(value) end def move_to_last_node current_node = @head while current_node.pointer current_node = current_node.pointer end return current_node...
true
bbd72f8cb8f35f00e76fc7b03f9b9b8b587ff9d7
Ruby
soliverit/ollieml
/examples/geneva_scehdule_climate_translation.rb
UTF-8
9,913
2.640625
3
[]
no_license
CSV_DATA_PATH = "./data/geneva_schedule_climate.csv" ELEC_COST = 0.153 GAS_COST = 0.034 ELEC_CO2 = 0.519 GAS_CO2 = 0.216 DPP_RATE = 0.035 RETROFIT_COST = 83112 if ! CSV_DATA_PATH Lpr.p "Define CSV_DATA_PATH before continuing (I've got it in a data/ sub folder" return end Lpr.p """ ## # Introduction / Overvie...
true
94921d69fa9fe66c2686d6a140d2dbaeb7827bbb
Ruby
scottrfrancis/RubyPeaks
/lib/trainingpeaks.rb
UTF-8
4,889
2.921875
3
[ "Apache-2.0" ]
permissive
require 'open-uri' require 'savon' class TrainingPeaks TPBASE= 'http://www.trainingpeaks.com/tpwebservices/service.asmx' TPWSDL= TPBASE + '?WSDL' @@client = nil attr_accessor :user, :password, :client, :guid, :athletes, :personID # # you can init the class without a user/password, but you'll ne...
true
e58aac8466dc332eb93ca324651434a4a0567518
Ruby
dwillis/mccandlish
/lib/mccandlish/result.rb
UTF-8
713
2.65625
3
[ "MIT" ]
permissive
module Mccandlish class Result attr_reader :hits, :offset, :copyright, :status, :articles, :facets def initialize(params={}) params.each_pair do |k,v| instance_variable_set("@#{k}", v) end end def to_s "<Result: #{hits} hits>" end def self.create_f...
true
d7572e833e8efae23d4384571f8f9d6f1d49e583
Ruby
monfil/fase1-1
/semana3/examen2/flight/app/controllers/controller.rb
UTF-8
5,538
2.859375
3
[]
no_license
class Controller def initialize(args) @view = View.new send(args[0]) end def index @view.index while true @choice = STDIN.gets.chomp break if @choice == '1' || @choice == '2' || @choice == '3' @view.error end if @choice == "1" @view.reservations reservations...
true
3698189d7453263226a1a192cac35420296d1a91
Ruby
UchikoMisc/bonus-drink
/bonus_drink.rb
UTF-8
317
3.375
3
[]
no_license
class BonusDrink BONUS_AMOUNT=3 def self.total_count_for(amount) amount + calculate_bonus(amount) end def self.calculate_bonus(amount) bonus = amount / BONUS_AMOUNT rest = amount % BONUS_AMOUNT if bonus == 0 return 0 else bonus + calculate_bonus(bonus+rest) end end end
true
7d77a56139afa4c5038c234f189ceb91bc826726
Ruby
jmettraux/ruote
/lib/ruote/exp/fe_save.rb
UTF-8
2,142
2.65625
3
[ "MIT" ]
permissive
#-- # Copyright (c) 2005-2013, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy...
true
758af17be8f30fc8461b6f0e04e322436078eec1
Ruby
rgo/adventofcode-2020
/10-adapter-array/main_2.rb
UTF-8
234
2.71875
3
[]
no_license
#!/usr/bin/env ruby # frozen_string_literal: true require './adapter' require 'open-uri' input = URI.open('input.txt').readlines.map(&:to_i) adapter = Adapter.new(input) puts "Number of arrangements: #{adapter.count_arrangements}"
true
c600bb78fc9872d3e00b61356062361064b4876b
Ruby
ahtee/ruby-nku
/otteb1-lab10/mimeTypeParser.rb
UTF-8
1,050
3.40625
3
[]
no_license
#!/usr/bin/ruby #This program was written by Ben Otte. #This program gets each line of the mime.types file , separates the line, and returns each line in a hash array which we can use for reference. #Add hash array and use value.join(',') hashArray = Hash.new file= File.new("/etc/mime.types") do |file| while (line ...
true
eb5dab27d1c567c517c8ad0d34d5fce5577a16e5
Ruby
16max/rub
/cod/auf/05_class_player.rb
UTF-8
1,303
4.34375
4
[]
no_license
# a. erstellen Sie eine Klasse mit der Bezeichnung Player # b. erstellen Sie ein Objekt player1 der Klasse # c. erstellen Sie eine initialize - Methode, die die Parameter name und health hat und aus diesen Werten die Instanzvariablen @name und @health initialisiert # d. updaten Sie das Objekt player1 und lassen sich d...
true
40061f8917e6decbf5c12ba755590fb2ed84524e
Ruby
heather-kirk/activerecord-validations-lab-online-web-pt-011419
/app/models/post.rb
UTF-8
432
2.609375
3
[]
no_license
class Post < ActiveRecord::Base validates :title, presence: true validates :content, length:{minimum: 250} validates :summary, length:{maximum: 250} validates :category, inclusion:{in:%w(Fiction Non-Fiction)} validate :clickbait? CLICKBAIT = [/Won't Believe/, /Secret/, /Top[0-9]/, /Guess/] def clic...
true
2997273fe6b566ec5fce94eeca67a18d92640333
Ruby
istana/divan
/lib/divan/helpers.rb
UTF-8
573
2.78125
3
[ "MIT" ]
permissive
require 'cgi' module Divan module Helpers def pacify_blank(*objects) for object in objects if object.blank? raise(ArgumentError, 'Object cannot be blank') end end true end def uri_encode(what) if what.respond_to?(:to_s) what = what.to_s else raise(ArgumentError, 'Argument ca...
true
0a366706806e9956c11519941d40c1fbdd62c25a
Ruby
rossmari/imaged_digits_parser
/lib/rows_excel_builder.rb
UTF-8
937
2.75
3
[]
no_license
class RowsExcelBuilder class << self def generate_xlsx(category_id) package = Axlsx::Package.new wb = package.workbook ws = wb.add_worksheet name: 'First page' header_style = wb.styles.add_style(b: true, sz: 14, alignment: { horizontal: :center}) ws.add_row(['Name', 'Category'] +...
true
472a88488d0dfa21e0621cc41e73ed67f7e4fa6a
Ruby
AteroConfigs/gurgitate-mail
/gurgitate-mail.RB
UTF-8
14,827
3.046875
3
[]
no_license
#!/opt/bin/ruby # -*- encoding : utf-8 -*- #------------------------------------------------------------------------ # Mail filter package #------------------------------------------------------------------------ require 'etc' require 'gurgitate/mailmessage' require 'gurgitate/deliver' module Gurgitate # This is...
true
91e9fab8b0e2c65919c76d9e8f264384b4aa4218
Ruby
famished-tiger/Rley
/lib/rley/sppf/alternative_node.rb
UTF-8
1,369
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true require_relative 'composite_node' module Rley # This module is used as a namespace module SPPF # This module is used as a namespace # A node in a parse forest that is a child # of a parent node with :or refinement class AlternativeNode < CompositeNode # @return [Strin...
true
5ea45f305f03842299e787ec91673c2ca103b4c0
Ruby
snorkpete/everycent
/spec/models/shared_examples/cumulative_allocation_spec.rb
UTF-8
2,401
2.84375
3
[ "MIT" ]
permissive
shared_examples_for "CumulativeAllocation" do describe "#CumulativeAllocation" do before do @budget = create(:budget, start_date: Date.new(2019, 12, 25)) @allocation = create(:allocation, budget: @budget, is_cumulative: true, amount: 6200) end it "has a flag that determines if allocation is...
true
c9754b47451f084b89e8042500677d6f26b9f4f1
Ruby
Adedee/ruby
/Exercise13/lib/FactorialClass.rb
UTF-8
240
3.546875
4
[]
no_license
class Factorial def initialize(text) @num = text end def to_s fnum = Float(@num) j = fnum (2..fnum).step(1).reverse_each do |i| j = j*(i - 1) end puts "#{fnum.to_i}! is #{j.to_i}" end end
true
636a9a82e9ad13e4258f36d98f6162ac348bd3de
Ruby
DovileSand/Battle
/spec/player_spec.rb
UTF-8
521
2.703125
3
[]
no_license
require 'player' describe Player do subject(:duck) {Player.new('Duck')} subject(:eagle) {Player.new('Eagle')} context '#player_name' do it 'returns player name' do expect(duck.player_name).to eq('Duck') end end context '#attack' do it 'reduces player hitpoints' do expect(eagle).to rece...
true
dbf3943bd8c96a82da87ec88e739618a4a2f7f94
Ruby
zeroDivisible/advent-of-code
/2018/ruby/day_02/ruby/script.rb
UTF-8
681
3.296875
3
[]
no_license
require 'set' input = File.readlines('input.txt') # step 1 twos = 0 threes = 0 input.each do |line| counts = line.each_char.to_a.inject(Hash.new(0)) { |h,v| h[v] += 1; h } twos += 1 if counts.values.include?(2) threes += 1 if counts.values.include?(3) end puts twos * threes # step 2 lines = [] input.each do...
true
8a7544e0b2480dd66d368c9b99f4189d1f0ab4ec
Ruby
invalidusrname/adventofcode
/2018/ruby/lib/advent_06.rb
UTF-8
3,481
3.640625
4
[]
no_license
class Coordinate attr_reader :x, :y, :count attr_writer :count def initialize(x, y) @x = x @y = y @count = 1 end def to_s name end def name "(#{x},#{y})" end end class ChronalCoordinates attr_reader :coordinates def initialize(coordinates) @coordinates = coordinates ...
true
f8690bd0242e170a55d99d8c9374ef3635337b33
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/b7609a3c4e6c4931aae1f70d53ff7ead.rb
UTF-8
583
3.609375
4
[]
no_license
class Bob SAID_NOTHING_REPLY = 'Fine. Be that way!' YELLING_REPLY = 'Woah, chill out!' QUESTION_REPLY = 'Sure.' DEFAULT_REPLY = 'Whatever.' QUESTION_MARK = '?' def hey (message) if said_nothing? message SAID_NOTHING_REPLY elsif yelling? message YELLING_REPLY elsif question? message ...
true
ad447417512cfcc0386aa82e2ca3246310ab4e00
Ruby
kevinkim1030/ruby-enumerables-cartoon-collections-lab-nyc-web-102819
/cartoon_collections.rb
UTF-8
459
3.421875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def roll_call_dwarves(names) i = 0 while i < names.length puts "#{i + 1}. #{names[i]}" i +=1 end end def summon_captain_planet(array) new_array = [] array.collect do |i| new_array << "#{i.capitalize}!" end new_array end def long_planeteer_calls(array) array.any? do |i| i.length > 4 en...
true
892940e9cf68062d0e301fb2d05bbab12711898d
Ruby
tbierwirth/battleship
/test/board_test.rb
UTF-8
5,875
3.40625
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require 'pry' require './lib/board' require './lib/cell' require './lib/ship' class BoardTest < MiniTest::Test def setup @board = Board.new @cruiser = Ship.new("Cruiser", 3) @submarine = Ship.new("Submarine", 2) end def test_board_exists assert...
true
520c3d128885506591ea688f1885fda5e7a492c7
Ruby
onk/brahman
/lib/brahman/mergeinfo.rb
UTF-8
1,225
2.984375
3
[ "MIT" ]
permissive
module Brahman class Mergeinfo # mergeinfo string to list # # あいまいな入力も受け付け # * m-n を展開し # * r を取り除いて # 配列にして返す def self.str_to_list(mergeinfo) mergeinfo.split(',').map{|e| if e =~ /-/ min,max = e.delete("r").split("-") (min..max).to_a else ...
true
ce0f684d0123fcb0f9c5c16b65380798c2afee73
Ruby
pofystyy/codewars
/7 kyu/square_every_digit.rb
UTF-8
390
4.375
4
[]
no_license
# https://www.codewars.com/kata/546e2562b03326a88e000020 # Details: # Welcome. In this kata, you are asked to square every digit of a number. # For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1. # Note: The function accepts an integer and returns an integer def sq...
true
942dcca3a75750a31fa494e5a51c6256bebb303f
Ruby
mpatel5/Cards
/cards.rb
UTF-8
794
4.125
4
[]
no_license
class Card attr_accessor :rank, :suit def initialize(rank, suit) self.rank = rank self.suit = suit end def output_card puts "#{self.rank} of #{self.suit}" end end class Deck def initialize @cards = [] @ranks = [1,2,3,4,5,6,7,8,9,10,:jack,:queen,:king,...
true
6b3189d65f2884c1bb14b0b863992828e73a3af9
Ruby
GAnjali/ruby-practice
/6.arrays/array_operations.rb
UTF-8
573
3.9375
4
[]
no_license
array = [1, 'Bob', 4.33, 'another string'] puts array.first puts array.first(2) puts array.last puts array[3] array.push(3) puts array array.pop puts array array.concat([2, 3]) array << 3 puts array array = Array.new(4) array[0]=1 array[1]=2 array[2]=3 array[3]=4 array.map{|num| num**2} array array.collect{|num| nu...
true
92d9aec820b4cfcfa65cad7d8c348a20f3e04190
Ruby
marek2901/subject_manager_demo_app
/app/models/participant.rb
UTF-8
548
2.609375
3
[]
no_license
class Participant include ActiveModel::Model attr_accessor :subject_id, :participant_id validates_presence_of :subject_id, :participant_id def save if valid? begin Subject.find(subject_id).students << Student.find(participant_id) rescue StandardError false end true ...
true
7c4b7e77472a9b12164e1f00685eee9518c95615
Ruby
spinute/rumale
/lib/rumale/nearest_neighbors/k_neighbors_classifier.rb
UTF-8
6,666
3.25
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
# frozen_string_literal: true require 'rumale/base/base_estimator' require 'rumale/base/classifier' module Rumale # This module consists of the classes that implement estimators based on nearest neighbors rule. module NearestNeighbors # KNeighborsClassifier is a class that implements the classifier with the k...
true