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
cd1f491c9e54da990a61ccd054e517bb388dc315
Ruby
ndrewpacheco/RB130
/ruby_challenges/easy1/sieve.rb
UTF-8
1,589
4.28125
4
[]
no_license
# Write a program that uses the Sieve of Eratosthenes to find all the primes from 2 # up to a given number. # The Sieve of Eratosthenes is a simple, ancient algorithm for # finding all prime numbers up to any given limit. # # It does so by iteratively marking as composite (i.e. not prime) #the multiples of each prime...
true
4fa19b2ffa82cf3e8d5767b449529ee26111d7f4
Ruby
loveshell/asciinema.org
/spec/models/terminal_spec.rb
UTF-8
3,513
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# encoding: utf-8 require 'spec_helper' describe Terminal do let(:terminal) { Terminal.new(6, 3) } let(:first_line_text) { subject.as_json.first.map(&:first).join.strip } before do data.each do |chunk| terminal.feed(chunk) end end after do terminal.release end describe '#snapshot' ...
true
ad89f43917da6c47162e2429d9327a337f883b95
Ruby
afast/chess-rate
/lib/board/pawn.rb
UTF-8
1,892
2.90625
3
[]
no_license
module Board class Pawn < Piece def can_move_to? position return InvalidPositionError.new unless position.valid? rank_dis = @position.rank_distance(position) # rank distance file_dis = @position.file_distance(position) # file distance can_move = (position.rank - @position.rank) == (side =...
true
c173d8636be593b6075939aac24ba4112e6de5a5
Ruby
djwonk/method_trails
/test/helpers/subject_s_exp.rb
UTF-8
846
2.5625
3
[ "MIT" ]
permissive
require 'require_relative' require_relative '/../../lib/classes/s_exp' SUBJECT_S_EXP = [:program, [ [:class, [:const_ref, [:@const, "VerySimple", [1, 6]]], nil, [:body_stmt, [ [:def, [:@ident, "method_one", [2, 6]], [:params, nil, nil, nil, nil, nil], [:body_stmt, [ ...
true
ba73c86690a13e5a3a1146a37ec9fe521179e181
Ruby
mlovic/mtb-scrape-scraper
/lib/scraper.rb
UTF-8
1,281
2.796875
3
[]
no_license
require 'uri' require 'mechanize' require_relative 'scraper/spider' require_relative 'logging' class Scraper Thread.abort_on_exception = true include Logging def initialize(processor) @url_q = Queue.new @pages_q = Queue.new @processor = processor end def start(options = {}) #offset = opt...
true
5b1e9e00c2896888a8c4e8cc2cae6e77c486b519
Ruby
freerobby/convergence
/lib/convergent_object.rb
UTF-8
281
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'celluloid' class ConvergentObject include Celluloid attr_accessor :key, :subscribers def initialize(_key, _data = nil) key = _key subscribers = [] @data = _data end def data=(_val) @data = _val query end def query data end end
true
b9d06f4dc3bb641f2abcce40ecee203bfe3c8152
Ruby
bdmac/strong_password
/lib/active_model/validations/password_strength_validator.rb
UTF-8
1,539
2.515625
3
[ "MIT" ]
permissive
require 'strong_password' module ActiveModel module Validations class PasswordStrengthValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) ps = ::StrongPassword::StrengthChecker.new(**strength_options(options, object)) unless ps.is_strong?(value.to_s) ...
true
550eac4432ff0f8adea7755cc7d452b8a62f2794
Ruby
akcedro/ruby-fall-part-time
/birthplace.rb
UTF-8
145
2.78125
3
[]
no_license
user1= {:firstname=> "Johnny", :lastname=> "Begood", :gender=> "male", :dob=> "08/21/1981", :birthplace=> "Seattle,WA"} puts user1[:birthplace]
true
aaa3acf70ee883c307e93d3825e349f9c05b781b
Ruby
BlairWhite/phase-0
/week-4/largest-integer/my_solution.rb
UTF-8
128
3.4375
3
[ "MIT" ]
permissive
def largest_integer(list_of_nums) largest = list_of_nums[0] list_of_nums.each {|i| largest = i if i > largest} largest end
true
cac5000cb73bf639f5c27d04f42c635fbc98732e
Ruby
anrosol/consolitaire
/pile.rb
UTF-8
365
3.1875
3
[]
no_license
require_relative 'card' class Pile attr_reader :cards def initialize @cards = [] end def length @cards.length end def clear @cards.clear end def empty? @cards.length == 0 end def current_card @cards.empty? ? nil : @cards.last end def add(card) @cards.push(card) ...
true
8c86a539ec6f402676a8586e43343c3b89d8b43f
Ruby
adamki/m1w1
/sfb.rb
UTF-8
366
3.625
4
[]
no_license
(1..1001).each do |x| if x%3==0&&x%5==0&&x%7==0 puts "SuperFizzBuzz" elsif x%3==0&&x%7==0 puts "SuperFizz" elsif x%5==0&&x%7==0 puts "SuperBuzz" elsif x%3==0 &&x%5==0 puts "#{x}" elsif x%3==0 puts "Fizz" elsif x%5==0 puts "Buzz" elsif x%7==0 puts "Su...
true
7875ca7a0e394e54e676c6e433365105179baebb
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/proverb/ca7880ee096640dd93b5320ddbf23fc5.rb
UTF-8
347
3.109375
3
[]
no_license
class Proverb def initialize *chain, qualifier: nil @chain = chain @qualifier = qualifier end def to_s chain.each_cons(2).map do |a, b| "For want of a #{a} the #{b} was lost.\n" end.join + "And all for the want of a #{[qualifier, chain.first].compact.join(' ')}." end private attr_rea...
true
b40da55f9f3a75ecd960e09118181b68225edbae
Ruby
frederikhappel/puppetlabs-stdlib
/lib/puppet/parser/functions/validate_puppet_resource.rb
UTF-8
755
2.625
3
[ "Apache-2.0" ]
permissive
module Puppet::Parser::Functions newfunction(:validate_puppet_resource, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are puppet resources. Abort catalog compilation if any value fails this check. ENDHEREDOC unless args.length > 0 then raise Puppet::ParseError, ("validate_...
true
f15031a7147d2d724ccb6988bf09dbdfc0577415
Ruby
interestinall/anagram-detector-v-000
/lib/anagram.rb
UTF-8
370
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Your code goes here! class Anagram attr_accessor :word def initialize(word) @word = word end def match(array) sorted_word = @word.split("").sort.join final_array = [] array.each do |word| array_word = word.split("").sort.join if sorted_word == array_word final_array <<...
true
ae458dc219f1788eccf42cc686f0011f42ce51a6
Ruby
learn-co-curriculum/chicago-se-120720
/rails-forms-and-validations/test.rb
UTF-8
312
2.90625
3
[]
no_license
# ternary operator # condition ? result if true : result if false class recipes belongs_to :category def category=(category_name) category = Categroy.find_or_create_by(name: category_name) recipe.category = category end def category_name self.category ? self.category.name : nil end end
true
ea11c6c850ee65b82eab99716ce13e6443eb942f
Ruby
kavinderd/data_structures
/lib/data_structures/linked_list.rb
UTF-8
1,345
3.40625
3
[]
no_license
module DataStructures class Link attr_reader :data attr_accessor :next def initialize(data, link=nil) @data = data @next = link end end class LinkedList def initialize(start=nil) @start = start reset_current end def <<(item) @start = Link.new(it...
true
5b1f3daf4bba723e89260c7cbcc170a929415a07
Ruby
csbpku/csce606
/app/controllers/planning_route.rb
UTF-8
576
2.640625
3
[]
no_license
class PlanningRoute attr_accessor:hash_value def init(hash_value=nil)#hash_value should be a hash object @hash_value=hash_value end def summary_update() #recalculate all the duration and distance of the whole route end def reset() @hash_value.clear end ...
true
29336a72331dbf8e19a86f31d0d1930d71c7b6ae
Ruby
luishong07/immersive-module-one-mini-mock-challenge
/author.rb
UTF-8
974
3.46875
3
[]
no_license
class Author attr_accessor :name @@all = [] def initialize(name) @name = name @@all << self end def self.all @@all end def all_books_authors BookAuthor.all.select do |bookauthor| bookauthor.author == self end end def books ...
true
4b5267d90bbce71aa79c84060ccca3062bc621aa
Ruby
Sirdmu/imageblur
/imageblur2.rb
UTF-8
1,121
3.984375
4
[]
no_license
class Image def initialize (image) @image = image end def get_coordinates coordinates = [] @image.each_with_index do |row, y| row.each_with_index do |value, x| if value == 1 coordinates<<[y, x] end end ...
true
865e26c5f3a836341da4f798bfa1d6f86552e476
Ruby
jdashton/glowing-succotash
/daniel/AoC/advent15.rb
UTF-8
397
3.1875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'lib/advent09' require_relative 'lib/advent15' input = IO .read('input/advent15.txt') .split(?,) .map(&:to_i) adv15 = Advent15.new Advent09.new.run input, adv15, adv15 puts "Oxygen system found at #{ adv15.oxygen_coords } " \ "in #{ adv15.oxygen_num_m...
true
8669de999f495390bb31f6f44fd011e76c71a9b4
Ruby
shabbirsaifee92/rspec-course
/spec/array_2_spec.rb
UTF-8
250
2.65625
3
[]
no_license
RSpec.describe Array do subject(:sally) { [1,2] } it 'can add remove elements' do expect(sally.length).to eq 2 sally.pop expect(sally.length).to eq 1 end it 'has defualt length of 2' do expect(sally.length).to eq 2 end end
true
b8336cdefc767ac40d54fe09e4855e031d76bde6
Ruby
SinkLineP/RubyOnRails-18.08.2021
/Ruby on rails/coalla-cosmetology-ddcbe64f3200/app/services/phone_sanitizer.rb
UTF-8
273
3.328125
3
[]
no_license
class PhoneSanitizer PHONE_REGEXP = /\A\d{10,11}\z/ def self.sanitize(phone) sanitized = phone.try(:gsub, /[\-\+\(\)\s\.\Q]/, '') if sanitized =~ PHONE_REGEXP && sanitized.start_with?('7', '8') sanitized[1..-1] else sanitized end end end
true
fd796a65d8a65beb9181fbc354693557aab41546
Ruby
markfranciose/drops_of_knowledge
/practice/ruby/ruby_yield.rb
UTF-8
356
4.25
4
[ "MIT" ]
permissive
# basics of yield # Using the &parameter def hello # nothing is here, yo. end hello do puts "hello!" end # executing the method on line 5 won't throw an error, but it won't print out "hello!" to the terminal. # line 5-7 is the same as: hello {puts "hello!"} def hello yield if block_given?...
true
c351c47832ff2203197c961d0ec5a73487a71175
Ruby
mwean/mac_setup
/lib/mac_setup/shell.rb
UTF-8
844
2.75
3
[ "MIT" ]
permissive
require "shellwords" require "io/console" require "open3" module MacSetup class Shell class << self def result(*command) run(*command).output end def run(*command) Result.new(*Open3.capture3(*command)) end def raw(command) system(command) end d...
true
84562febcbd3576636adcb294ab30d5beb9a1c81
Ruby
mindplace/reddit_comments_gem
/spec/reddit_comments_spec.rb
UTF-8
2,823
2.5625
3
[ "MIT" ]
permissive
require 'spec_helper' require 'pry' describe RedditComments do it 'has a version number' do expect(RedditComments::VERSION).not_to be nil end describe 'link_tested' do it 'raises error if given a non-Reddit link' do url = 'http://www.example.com' reddit_comments = RedditComments::GetComments...
true
8a89635117fb4c1dc24dbbb1416a2ac876e65ac3
Ruby
Localvox/vivialconnect-ruby
/spec/resource_spec.rb
UTF-8
11,501
2.5625
3
[ "MIT" ]
permissive
require_relative "./spec_helper" require_relative "./stubbed_response" require 'json' RSpec.describe Resource do context ".path_builder" do it "builds correct paths for base actions" do path = Resource.path_builder(:create) expect(path).to eq('/resources.json') path = Resource.path_builder(:...
true
b08eeab2a6868131e808bc2142cdc81b5630f9cb
Ruby
yurufuwarb/library
/app/controllers/book_controller.rb
UTF-8
1,969
2.734375
3
[]
no_license
class BookController < ApplicationController before_action :check_params def check_params case action_name when 'create' render_error(-1, 1, "typeパラメータを指定してください。") and return unless params.include?(:type) render_error(-1, 1, "nameパラメータを指定してください。") and return unless params.include?(:name) ...
true
80c953acbbc155c97ab6a2254a7056b4e54398c5
Ruby
Austio/learning
/Projects/Mission/evented/lib/flight_simulator.rb
UTF-8
3,004
2.671875
3
[]
no_license
class FlightSimulator include Wisper::Publisher def initialize(mission, rocket) @mission = mission @rocket = rocket @total_time = Unit.new("0 sec") @total_distance_traveled = Unit.new("0 km") end def run! return status_aborted if !@rocket.launched? return status_exploded if @rocket&.d...
true
18fe7e6c975a0f7d2e1d33a18808f7f5809fe0cf
Ruby
JuPlutonic/Flashcards
/app/services/card_comparator.rb
UTF-8
1,838
3.09375
3
[]
no_license
class CardComparator # here we use a SuperMemo2 algorithm # to read more about it, follow the link https://www.supermemo.com/english/ol/sm2.htm def initialize(params) @card = params[:card] @compared_text = params[:compared_text] end def self.call(params) Result.new(new(params).qualify) end ...
true
b94b03e8bf236a2f6ad27ea8da96396e9c2a4be1
Ruby
sleepless-p03t/Amazer
/maze
UTF-8
25,250
3.046875
3
[ "MIT" ]
permissive
#!/bin/ruby require 'io/console' load('./internals.rb') load('./portals.rb') trap("INT", "SIG_IGN") class Maze # Maze Generator from: https://rosettacode.org/wiki/Maze_generation#Ruby DIRECTIONS = [ [1, 0], [-1, 0], [0, 1], [0, -1] ] def initialize(width, height) @width = width @height = height @st...
true
e63f07367aac278372bd2bb3f4f5d10d47fff79b
Ruby
lilwillifo/week1
/flashcards/test/round_test.rb
UTF-8
1,867
3.46875
3
[]
no_license
require 'minitest' require 'minitest/autorun' require 'minitest/pride' require './lib/card.rb' require './lib/guess.rb' require './lib/deck.rb' require './lib/round.rb' class RoundTest < Minitest::Test def setup @card_1 = Card.new("What is the capital of Virginia", "Richmond") @card_2 = Card.new("What is M...
true
cec57208b35620ae03f3d91fddc26eb5502c8045
Ruby
didy400/exos-ruby
/exo_20.rb
UTF-8
247
3.125
3
[]
no_license
print "Hey! tu veux voir ma grosse pyramide? Dis moi la hauteur que tu veux entre 1 et 25!" h = Integer(gets.chomp) pyramid = "#" if h <25 h.times do puts pyramid pyramid = pyramid + "#" end else puts "Vous me surestimez très chère!" end
true
34f8e6e8e6bcc2477b675c57e0aa5c9ac3bac474
Ruby
postazure/Ruby-Practice
/CH8/joinMethod.rb
UTF-8
276
3.359375
3
[]
no_license
foods = ['artichoke','brioche','caramel'] puts foods puts #just an empty line puts foods.to_s puts puts foods.join(', ') puts puts foods.join(' :) ') + ' 8) ' #the following array does not contain anything 200.times do #this does not repeat 200 times puts [[1,0],0] end
true
3cdd6de9f58001e5beb597461cc0db602aa8bd95
Ruby
CorySpitzer/leap_years
/leap_years_spec.rb
UTF-8
1,333
3.765625
4
[]
no_license
require 'rspec' require './leap_years' # We add a Leap Day on February 29, almost every four years. The leap day is an # extra, or intercalary, day and we add it to the shortest month of the year, # February. # # In the Gregorian calendar three criteria must be taken into account to # identify leap years: # # The year...
true
783697049dc4e2df3f3269b3f0ae5a89a04056b9
Ruby
DiegoSalazar/kwipper_challenge
/app/models/user.rb
UTF-8
665
2.515625
3
[ "MIT" ]
permissive
module Kwipper class User < Model column "username", :to_s column "email", :to_s column "hashed_password", :to_s column "created_at", :to_s def self.authenticate(username, password) user = where(username: username).first user && user.hashed_password == password && user end de...
true
889ab4e1f90aab4b391971148f4e151a710ade34
Ruby
maiyama18/AtCoder
/abc/070/c.rb
UTF-8
222
3.390625
3
[]
no_license
def gcd(a, b) return a if b == 0 gcd(b, a % b) end def lcm(a, b) a * b / gcd(a, b) end n = gets.to_i t = n.times.map { gets.to_i } puts n == 1 ? t[0] : t.each_cons(2).reduce(1) {|r, (t1, t2)| lcm(r, lcm(t1, t2))}
true
1830e8c38e4b2e9807202579c73c4ab65c26d760
Ruby
kirualex/Flamingo
/vendor/bundle/ruby/2.6.0/gems/declarative-option-0.1.0/lib/declarative/options.rb
UTF-8
416
2.734375
3
[ "MIT" ]
permissive
require "declarative/option" module Declarative def self.Options(options, config={}) Options.new.tap do |hsh| options.each { |k,v| hsh[k] = Option(v, config) } end end class Options < Hash # Evaluates every element and returns a hash. Accepts context and arbitrary arguments. def...
true
d9fb396310f7dae792485e35b171ad42503f4a09
Ruby
TimBek2/phase-0
/week-4/smallest-integer/my_solution.rb
UTF-8
541
3.921875
4
[ "MIT" ]
permissive
# Smallest Integer # I worked on this challenge by myself # smallest_integer is a method that takes an array of integers as its input # and returns the smallest integer in the array # # +list_of_nums+ is an array of integers # smallest_integer(list_of_nums) should return the smallest integer in # +list_of_nums+ # # ...
true
ec3be35b539027007cc49fd419b35bead61d07a8
Ruby
isieo/lvl-up-kl-iot-demo
/app.rb
UTF-8
3,491
2.59375
3
[]
no_license
#!/usr/bin/env ruby # encoding: utf-8 require 'rubygems' require 'sinatra' require 'serialport' require 'celluloid/autostart' set :server, %w[thin mongrel webrick] set :bind, '0.0.0.0' set :port, 8000 class LightStatus @@red = 0 @@green = 0 @@blue = 0 @@device = nil @@shutdown = false @@ambient = 0 DEVI...
true
23bfa183353ff7147c6171d8f6089b45ff5de9fa
Ruby
nilbot/ruby-skippy-sample
/point.rb
UTF-8
113
3.265625
3
[]
no_license
class Point attr_reader :x, :y def initialize(x,y) @x = x @y = y end def to_s "[#{@x},#{@y}]" end end
true
465968ba4aa9e6f4a83363d3d79c24a0df79c489
Ruby
Maquech/MX-ID
/lib/MX/ID/auxiliar.rb
UTF-8
1,744
2.875
3
[ "MIT" ]
permissive
# encoding: utf-8 module MX::ID::Auxiliar module ClassMethods def en_blanco?(cadena) cadena.nil? or cadena.empty? end def fecha_con_formato(fecha) fecha.strftime("%y%m%d") end def obtener_primer_nombre_valido(nombres) arr_nombres = nombres.split(" ") if arr_nombr...
true
a43bd32dc264ae4b759b520f7db533b68a38a375
Ruby
MatthewRiggott/surf-report
/test3.rb
UTF-8
535
3.9375
4
[]
no_license
def repeat?(int) int_array = int.to_s.chars last_index = int_array.size - 1 int_array.each_with_index do |number, index| if index < last_index return true if number == int_array[index+1] end end return false end def count_Numbers(arr) arr.each do |sub_array| ...
true
a75c29c244dcca4cbdadbdb64f105ad14f9cab14
Ruby
saumyamehta17/algorithm_and_system_design
/tree/print_bottom_view.rb
UTF-8
1,848
3.71875
4
[]
no_license
require 'pry' require 'set' class Node attr_accessor :left, :right, :value def initialize(val) @value = val end end class QD attr_accessor :hd, :node def initialize(hd, node) @hd = hd @node = node end end class BinaryTree attr_accessor :root @hsh = {} @@sorted_set = SortedSet.new...
true
84c2b082d1c0c18fd9825245ff1afc9fe46c5dac
Ruby
k-p-jones/simple_playing_cards
/lib/simple_playing_cards/card.rb
UTF-8
1,374
3.4375
3
[ "MIT" ]
permissive
module SimplePlayingCards class Card include Comparable RANKS = %w[Ace 2 3 4 5 6 7 8 9 10 Jack King Queen] SUITS = %w[Spades Hearts Diamonds Clubs] attr_reader :rank, :suit attr_accessor :value, :options def initialize(rank, suit, options = {}) validate_inputs(rank, suit) ...
true
83c2679b6aaddaf287406c15c9c58ed5bb593e6b
Ruby
maeda5206/mrubyc
/sample_ruby/basic_sample06.rb
UTF-8
21
2.65625
3
[ "BSD-3-Clause" ]
permissive
n = 5 puts "n=#{n}"
true
7c494da82fe487669f8b96812955be289788d9ef
Ruby
jimbobhickville/ruby-stormondemand
/lib/Storm/Network/private.rb
UTF-8
3,773
2.796875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
# Copyright 2013 Liquid Web, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agree...
true
c033741e5ba406fd8668780f86b93e3e83831955
Ruby
al002/exercism-ruby
/hamming/hamming.rb
UTF-8
257
3.609375
4
[]
no_license
class Hamming def self.compute(a, b) raise ArgumentError if a.length != b.length a_arry = a.split("") b_arry = b.split("") count = 0 a_arry.each_with_index do |chr, i| count += 1 if chr != b_arry[i] end count end end
true
d61a5feab5c657eb3e4d8e609167b543996f6fcd
Ruby
yoshikazu-ishitsuka/WebDev-Udemy
/practice/fib2.rb
UTF-8
134
3.59375
4
[]
no_license
def fib(n) memo = [] memo[n] ||= n if n == 0 || n == 1 memo[n] ||= fib(n - 2) + fib(n - 1) end for i in 0..10 puts fib(i) end
true
b7de80389618c75c123d996be1583297e44f7e8c
Ruby
crossfireup/study
/app/ruby/select.rb
UTF-8
340
2.90625
3
[]
no_license
#!/usr/bin/env ruby rp, wp = IO.pipe mesg = "ping " 100.times { rs, ws = IO.select([rp], [wp]) if r = rs[0] ret = r.read(5) print ret case ret when /ping/ mesg = "pong\n" when /pong/ mesg = "ping " end end if w = ws[0] w.wr...
true
5de256cc3dc90f0ac13a1ecefb0eb1a013b5b603
Ruby
gregbell/observable
/spec/observable_spec.rb
UTF-8
2,338
2.546875
3
[]
no_license
require File.dirname(__FILE__) + '/spec_helper' describe Observable do after(:each) do # Reset the observables Employee.class_eval{ @observables = {} } end describe "- Creating Observables" do it "should create new observables with a name" do class Employee include Observable ...
true
3683f1c80cd17e84ce90e06de06e93ba3871381e
Ruby
njpa/launchschool-rb101
/lesson_3/3_medium_1/question_05.rb
UTF-8
1,327
4.40625
4
[]
no_license
# Alyssa asked Ben to write up a basic implementation of a Fibonacci # calculator, A user passes in two numbers, and the calculator will keep # computing the sequence until some limit is reached. # Ben coded up this implementation but complained that as soon as he ran it, # he got an error. Something about the limit v...
true
387e12d07b68b70ce44021427bfcc0bb48eb260e
Ruby
umuro/hobodemo1
/lib/extended_date.rb
UTF-8
1,139
3.015625
3
[]
no_license
# ExtendedDate is a simple extension to date making it possible to set a start year and end year inside a Hobo # application. This is necessary for things such as birthdays and events far in the future or past. class ExtendedDate < Date # It is necessary to override new, as the behavior of Hobo likes to give it th...
true
b790ea08da557f2e4a78f9df35dccb18774135a5
Ruby
blairanderson/sales_engine_web
/lib/sales_engine_web/models/finder_methods.rb
UTF-8
2,062
2.71875
3
[]
no_license
module SalesEngineWeb module FinderMethods def create(params) self.new(params).save end def add(subject) table.insert(subject.to_hash) end def random result = table.to_a.sample self.new(result) if result end def find_by_id(id) result = table.where(:id => i...
true
7164a64f52cbccf32c6c449388ea65603abd8f73
Ruby
bingo8670/ruby-programming-2.3
/5.1.ad2pingcheng.rb
UTF-8
110
3.09375
3
[]
no_license
# 将公历转换为平成纪年,1989为平成元年 ad = ARGV[0].to_i pingcheng = ad -1988 puts pingcheng
true
c20d83181cfeec2d944745d13fed487fe8d65ac3
Ruby
chef/win32-security
/lib/win32/security/acl.rb
UTF-8
6,733
2.8125
3
[ "Apache-2.0" ]
permissive
# The Win32 module serves as a namespace only. module Win32 # The Security class serves as a toplevel class namespace. class Security # The ACL class encapsulates an Access Control List. class ACL include Windows::Security::Constants include Windows::Security::Functions include Windows::...
true
c77d2fcf852284b8d4ef17a8ee1657c96c6af7e3
Ruby
breadbaker/nn-wrap
/breast/breast.rb
UTF-8
541
2.953125
3
[]
no_license
require '../nn.rb' # 1000025,5,1,1,1,2,1,3,1,1,2 class Breast < NN def initialize @fann_network = true @match_index = 10 @splitter ||= ',' @file_path ||= './breast-cancer-wisconsin.data.txt' @epochs ||= 2000 @neuron_setup ||= [5, 10, 5] @results_path ||= './results' @special_normalize ...
true
3ed0ab0705d0f3d166447e81532b4b5ea3396b9c
Ruby
oscos/launch_school
/rb100/ruby_basics/conditionals/ex07.rb
UTF-8
277
3.859375
4
[]
no_license
# ex07.rb # Stoplight (Part 2) # Answered On: 06/28/2020 # Convert the following case statement to an if statement. stoplight = ['green', 'yellow', 'red'].sample if stoplight == 'green' puts("Go!") elsif stoplight == 'yellow' puts("Slow down!") else puts("Stop!") end
true
e5c43b822f9128d7ba1f37c62cad3d63a4f055b6
Ruby
ancduncan/WAD_2.Assesment_TestDriven
/wad_dond_gen_01.rb
UTF-8
4,256
3.3125
3
[]
no_license
# Ruby code file - All your code should be located between the comments provided. # Main class module module DOND_Game # Input and output constants processed by subprocesses. MUST NOT change. GOES = 5 class Game attr_reader :sequence, :selectedboxes, :openedboxes, :chosenbox, :selectedbox, :turn, :input, :output...
true
f2ef2ab7de77d08bfc6da14d566ab7021d7d761e
Ruby
tedlarai/launch_school
/ls-introduction-to-programming/basics_2.rb
UTF-8
183
3.265625
3
[]
no_license
number = 5792 thousands = number / 1000 puts "#{thousands}" hundreds = number % 1000 / 100 puts "#{hundreds}" tens = number % 100 / 10 puts "#{tens}" ones = number % 10 puts "#{ones}"
true
f2ac47950a65ebeaa95628f1e457ae9cbd411aef
Ruby
solds-zz/programming-foundations
/lesson5/exercises/exercise16.rb
UTF-8
271
2.984375
3
[]
no_license
def generate_uuid hex_chars = "0123456789abcdef".split('') uuid = "" uuid_size = 36 hyphen_indices = [8, 13, 18, 23] uuid_size.times do |i| if hyphen_indices.include?(i) uuid << '-' else uuid << hex_chars.sample end end uuid end
true
90678f343584a3ff76e135c1a38fc71f1213d084
Ruby
yaqizhao/projet_THP
/Week1/Day3_Ruby/jeu.rb
UTF-8
737
3.984375
4
[]
no_license
def askIfRollADice puts "Please roll a dice" gets.chomp end def rollADice askIfRollADice diceResult = 1 + rand(6) puts "You rolled #{diceResult}." return diceResult end def move(diceResult, whereIwas) if diceResult == 1 if whereIwas != 0 return whereIwas - 1 else return whereIwas end elsif diceRes...
true
dab47290b210b838a0be5115d3cfc52fd037aa2f
Ruby
tanordheim/ahgoblin
/app/models/recipe_group.rb
UTF-8
2,671
2.625
3
[ "MIT" ]
permissive
class RecipeGroup < ActiveRecord::Base DURATION_12H = 12 DURATION_24H = 24 DURATION_48H = 48 # Recipe groups belong to professions. belongs_to :profession # Recipe groups belong to users. belongs_to :user # Recipe groups are associated with recipes. has_many :recipes, :dependent => :destroy # V...
true
7d2d7b10720ddab71cdae04151eb7b57df9ab29c
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/gigasecond/a794094629bc4290b6d63adabfc0611d.rb
UTF-8
113
2.90625
3
[]
no_license
class Gigasecond SECONDS_PER_DAY = 60*60*24 def self.from(date) date + (10**9)/SECONDS_PER_DAY end end
true
ccd704cb286c81d4871dab172f5c92c000c4cd6a
Ruby
runpaint/numb
/spec/numb/trimorphic_spec.rb
UTF-8
762
2.875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
describe Integer, "#trimorphic?" do TRIMORPHIC = [0,1,4,5,6,9,24,25,49,51,75,76,99,125,249,251,375, 376,499,501,624,625,749,751,875,999,1249,3751, 4375,4999,5001,5625,6249,8751,9375,9376,9999, 18751,31249,40625,49999,50001,59375,68751,81249, 90624,90625]...
true
3c8d836e066e65de6f565eebc2af138a350d35f9
Ruby
TopherBlair/programs
/Game_of_life.rb
UTF-8
553
3.765625
4
[]
no_license
matrix = [(1..10).to_a, (11..20).to_a, (21..30).to_a, (31..40).to_a, (41..50).to_a, (51..60).to_a, (61..70).to_a, (71..80).to_a, (81..90).to_a, (91..100).to_a, ] puts "Sample Matrix:" # prints out the matrix in a nice for...
true
8dc8f537dccad01abd8580b9d5b1546d3530b05e
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/roman-numerals/89ef38e345b44a8bad2cdc917805e062.rb
UTF-8
794
3.59375
4
[]
no_license
class Fixnum def to_roman romans = {0 => '', 1 => 'I', 4 => 'IV', 5 => 'V', 9 => 'IX', 10 => 'X', 50 => 'L', 100 => 'C', 500 => 'D', 1000 => 'M'} nb = self decomposition = [] result = [] if nb <= 5 if nb == 4 or nb == 5 result << romans[nb] else decomposition = nb.divmod(5) resul...
true
ccb6040901ea7418c9118f02c0f6ca84bb1f819c
Ruby
EricLondon/Ruby-Exec-Shell-With-Timeout
/test.rb
UTF-8
127
2.578125
3
[]
no_license
#!/usr/bin/env ruby require 'logger' log = Logger.new('./log.txt') (1..20).each do |i| puts i log.debug i sleep 1 end
true
d52ad60c9bbb20a07e94755465a4d528057031a8
Ruby
staskjs/swan
/bin/swan
UTF-8
1,221
2.5625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'bundler/setup' require 'swan' require 'optparse' require 'yaml' require 'open-uri' options = { init: false, init_params: '', only: [], config: '.swan.yml', } # Parse options OptionParser.new do |opts| opts.banner = 'Usage: swan [options]' opts.on('--init', 'Initialize swan c...
true
1866fd2586453a91ba9a46c0ad6dcd986b580bb9
Ruby
yasukuro6259/ruby_drill
/ruby_drill_day33.rb
UTF-8
1,403
4.15625
4
[]
no_license
問題.1 西暦の年数および月を入力し、その月の日数を求めるプログラムを書きます。 その場合、閏年について考慮する必要があります。 閏年は以下の判断基準で決まります。 ①その西暦が4で割り切れたら閏年である ②ただし、例外として100で割り切れる西暦の場合は閏年ではない ③ただし、その例外として400で割り切れる場合は閏年である つまり、西暦2000年は閏年であり、西暦2100年は閏年ではありません。 これらに対応できるように、出力例と雛形をもとに実装しましょう。 出力例 1990年2月 =>"1990年2月は28日間あります" 2000年2月 =>"2000年2月は29日間あります" 2100年2月 =>"2100年2月は2...
true
8543b4d8db4cad53bee1a75cf017d4ee88fadf3c
Ruby
filip373/design-patterns
/01_factory_method/boat.rb
UTF-8
143
3.109375
3
[]
no_license
class Boat def go(package) puts("Sailing with #{package}...") sleep(1) puts("Package #{package} delivered with boat!") end end
true
295818e2820a78dc4d8dafa64b301ae9b776a8ed
Ruby
tkhrk/poker
/spec/requests/cards_spec.rb
UTF-8
3,055
2.578125
3
[]
no_license
require 'rails_helper' RSpec.describe "API::Ver1::Cards", type: :request do let(:request_header) do { 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json' } end let(:good_cards) do '{"cards": ["H1 H13 H12 H11 H10", "H9 C9 S9 H2 C12","C13 D12 C11 H8 H7"]}' end let(:wrong_cards) do ...
true
a3509adab4b45a03c118b6e5a3176652e2ff1485
Ruby
ODINAKACHUKWU/random-room-allocator
/app.rb
UTF-8
7,320
3.328125
3
[]
no_license
# require_relative "helpers/allocation_helpers" # require_relative "lib/file_reader" # require_relative "lib/application" # require_relative "db/setup" # require_relative "controllers/application_controller" # require "pry-byebug" # require_relative "helpers/response_helpers" # Steps: # -> Get all data from files and ...
true
36c7059e51e0da8e03dd7d53ca469016cc8fd55b
Ruby
derrelldurrett/AliasMadness
/app/models/initialize_bracket/template_loader.rb
UTF-8
2,804
2.78125
3
[]
no_license
module InitializeBracket class TemplateLoader require 'assets/rgl/directed_adjacency_graph' # require_relative './template_format_error' include Singleton attr_reader :bracket_structure_data, :spec_comp_regex, :label_lookup def initialize # Construction: ...
true
f98a6204c042b8659ee57eb4c8d6fcdc23385c8f
Ruby
ymason/ironhack
/Week_10/URL_Shortly/app/models/link.rb
UTF-8
297
2.8125
3
[ "MIT" ]
permissive
class Link < ActiveRecord::Base ALPHABET = [('a' .. 'z').to_a, ('A' .. 'Z').to_a].flatten def self.generate_shortlink(link_length) ALPHABET.sample(link_length).join # shortlink = # link_length.times do # shortlink += ALPHABET[rand(ALPHABET.length)] # end # shortlink end end
true
91b63ea2d8b35114d309f1a8a512ee344754bdf9
Ruby
brpadilha/conceitos_ruby
/modulo_02/12_criando_classes.rb
UTF-8
186
3.78125
4
[]
no_license
class Pessoa def dizOla(name = 'Bruno') p "Olá #{name}" end def initialize(cont = 5) cont.times do |i| puts "Contando... #{i}" end end end p = Pessoa.new(7)
true
f9d21a93af58aee98a719f7d6b78986ce747586e
Ruby
shailaja-enbake/Ruby
/q05moreque.rb
UTF-8
783
4.03125
4
[]
no_license
puts " Q1 : What is 2 + 2 ?" var1 = gets.chomp if var1.to_i == 4 puts "Correct ! " else puts "Wrong - the answer was 4 " end puts "Q2 : What is 2 + 6 ?" var2 = gets.chomp if var2.to_i == 8 puts "Correct ! " else puts "Wrong - the answer was 8 " end puts "Q3...
true
904b762e84da775ea48a412c9aef37e933806e5f
Ruby
jimbog/cucumbering
/features/step_definitions/list_steps.rb
UTF-8
397
2.546875
3
[]
no_license
Given(/^I have the following elements$/) do |table| table.hashes.each { |element| Store.add element } end When(/^I find an element with id (\d+)$/) do |id| @result = Store.find_by_id id puts "the result is #{@result}" end Then("I should get $name") do |name| expect(@result["name"]).to eq(name) end Transform /...
true
b67052d6eab48f93e7ae9a125c9a2101db36d538
Ruby
Emik234/formtastic
/lib/formtastic/inputs/country_input.rb
UTF-8
3,624
2.8125
3
[ "MIT" ]
permissive
module Formtastic module Inputs # Outputs a country select input, wrapping around a regular country_select helper. # Rails doesn't come with a `country_select` helper by default any more, so you'll need to do # one of the following: # # * install the [country_select](https://github.com/stefanpenne...
true
c91bff646541fe9edaf2e9f8aaa02bf9b56d89da
Ruby
muratatak77/react_rails_appointment_schedule
/db/seeds.rb
UTF-8
4,220
2.796875
3
[]
no_license
=begin Name,Timezone,Day of Week,Available at,Available until Christy Schumm,(GMT-06:00) America/North_Dakota/New_Salem,Monday, 9:00AM, 5:30PM Christy Schumm,(GMT-06:00) America/North_Dakota/New_Salem,Tuesday, 8:00AM, 4:00PM Christy Schumm,(GMT-06:00) America/North_Dakota/New_Salem,Thursday, 9:00AM, 4:00PM Christy Sch...
true
006017aa420611ca69086a8d0d495ad0dcffa79e
Ruby
zaashige/ProjectEuler
/problem 1.rb
UTF-8
503
3.8125
4
[]
no_license
=begin Project Euler - Problem #1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. =end require 'benchmark' time = Benchmark.realtime do # Begin Solution multiples = Array.new...
true
0aa9c4275ef3c9f84b8da825e75df841cd116e27
Ruby
pr0biem/passgen-2.0
/app/helpers/keywords_helper.rb
UTF-8
1,613
2.90625
3
[]
no_license
module KeywordsHelper require 'securerandom' def true_rand(x) num = SecureRandom.random_number(x) until num != 0 num = SecureRandom.random_number(x) end return num end def roll_5_dice @roll = "" 5.times do @roll << true_rand(6).to_s end @roll.to_i end def roll_...
true
8593cbca76eca47f8613393638782ffacb20c697
Ruby
sarita2129/PractiseCode
/Ruby/lesson7/Inheritance.rb
UTF-8
801
4.03125
4
[]
no_license
class Employee attr_reader :name,:salary def initialize(name,salary) @name = name @salary = salary end def CalcSalary(rate) @salary += rate * salary / 100 puts "You are in main class" end end class AccountEmployee < Employee end class SalesEmployee < Employee def CalcSalary(rate,salesperYe...
true
d2053c64252291b7bd65fba2c52410adcc15b736
Ruby
saeedghorbanim/ruby_fundamentals
/ruby_puzzles.rb
UTF-8
796
3.8125
4
[]
no_license
a = [3,5,1,2,7,9,8,13,25,32] sum = 0 for j in a sum += j end puts sum puts a.reject { |number| number < 10 } people = ["John", "KB", "Oliver", "Cory", "Matthew", "Christopher"] puts people.shuffle puts people.select {|people| people.length > 5} alphabet = ("a".."z").to_a puts alphabet.shuffle.last puts alphabet...
true
79bc30fc33a372dc758f12456c980f48e261296c
Ruby
cdsandoval/mini-assignment-day4
/5. insertion_sort.rb
UTF-8
422
3.859375
4
[]
no_license
def insertionSort1(n, arr) ele = arr[n - 1] (n - 2).downto(0) do |index| if (arr[index] < ele) arr[index + 1] = ele puts arr.join(" ") break else arr[index + 1] = arr[index] puts arr.join(" ") if (index - 1 < 0) arr[0] = ele; puts arr.join(" ") end...
true
bc7af269609e6a61245dc43b99e194f66ec2e087
Ruby
anickel101/ruby-oo-practice-relationships-domains-nyc01-seng-ft-080320
/app/models/lyft/driver.rb
UTF-8
892
3.65625
4
[]
no_license
class Driver attr_reader :name @@all = [] def initialize(name) @name = name @@all << self end def self.all @@all end def new_ride(passenger, distance) Ride.new(self, passenger, distance) end #Selects all the rides that have THIS DRIVER as its dri...
true
9e0ad4e01523f6ec88c809cb25fc2ea663e2ccb0
Ruby
RasPat1/withdrawlolz
/narcs/Tester.rb
UTF-8
814
2.84375
3
[]
no_license
Dir["./funcs/*.rb"].each { |file| require file} Dir["./lib/*.rb"].each { |file| require file} class Tester def initialize end def call # Run each alg from k = 1 to k = 10 for performance comparison # Run each for 60 seconds and compare how many solutions were found k = 40 max_seconds = 60 ...
true
4f63c2e9cbd4b00f1bce483f08a8f8be5e27a94b
Ruby
bcmdarroch/Calculator
/calculator.rb
UTF-8
3,605
4.65625
5
[]
no_license
# Build a calculator command line interface (CLI) that allows a user to perform simple arithmetic. # defines addition, subtraction, multiplication, division, # exponent, and modulo methods def add(a, b) return a + b end def subtract(a, b) return a - b end def multiply(a, b) return a * b end # error when divid...
true
10bf6f2093523baadf9793289a03af89a4d01ab8
Ruby
RobertRodes/ruby-exercises
/exercises/ex_9.rb
UTF-8
86
2.65625
3
[]
no_license
h = {a:1, b:2, c:3, d:4} puts h[:b] h.store(:e, 5) h.reject! {|k,v| v < 3.5} puts h
true
fa622bcce46a6d547b89927ec8d16bf7a9d8567a
Ruby
learn-co-students/sfo-web-120919
/05-ruby-oo-review/tools/console.rb
UTF-8
806
2.546875
3
[]
no_license
require_relative '../config/environment.rb' def reload load 'config/environment.rb' end student1 = Student.new("Bob", "Saget") student2 = Student.new("Coffee", "Dad") student3 = Student.new("David", "Rosenholz") classroom1 = Classroom.new("Fox") classroom2 = Classroom.new("Borg") classroom3 = Classroom.new("Lovela...
true
458ff1a7bb5b3249d01a6bb4912bc5a8efc6ceaa
Ruby
BrianDeWitt/LearnToProgram2ndEd
/Chapter06/chap06_02.rb
UTF-8
120
2.875
3
[]
no_license
puts 'WHAT DO YOU WANT?!' whatIWant = gets.chomp puts 'WHADDAYA MEAN " ' + whatIWant.upcase + '"?!? YOU\'RE FIRED!!'
true
2d69414d34dd0129b5a2265bdd10a0de27d034e3
Ruby
kenharsch/ourvapes
/app/models/my_config.rb
UTF-8
783
3.046875
3
[]
no_license
class MyConfig def initialize @parts = {} end # type:: Product::TYPE_... or prod.type on a Product object def remove(type) @parts.delete(type) end # type:: Product::TYPE_... or prod.type on a Product object def part(type) return @parts[type] end def add_by_id(id) prod = Product.find(id) @parts[pro...
true
c3eea3bbc3d2badb135f901b2be25f9bdcbebd70
Ruby
koheiyamada/jenkins_test
/spec/models/grade_spec.rb
UTF-8
540
2.609375
3
[]
no_license
# coding: utf-8 require 'spec_helper' describe Grade do it "16個ある" do Grade.all.should have(16).items end describe '通常の学年一式' do it "14個ある" do Grade.normal.should have(14).items end end describe '学年が上がる' do it '小学3年生から浪人生まで順繰りでつながっている' do %w(es3 es4 es5 es6 jh1 jh2 jh3 hs1 hs2 hs...
true
77f441ae783af650a634ff36bf068792de759e55
Ruby
DDKatch/dip
/app/controllers/homeworks_controller.rb
UTF-8
1,616
2.640625
3
[]
no_license
class HomeworksController < ApplicationController def index init_variables symb = case params[:operation] when "and" then :and when "or" then :or when "xor" then :xor when "not" then :not when "+" then :- when "-" then :+ when "*" then :* when "/" then :/ else symb = :and ...
true
951106f4554354abc76352e4c0ea28887c78df31
Ruby
emilwall/gitflow-repo-report
/tests/test_report_generator.rb
UTF-8
730
2.53125
3
[]
no_license
require_relative '../report_generator.rb' require_relative 'test_helper.rb' class TestReportGenerator < Test::Unit::TestCase def setup tmp_repo_path = setup_tmp_repo_dir @report_generator = ReportGenerator.new File.join(tmp_repo_path, 'test_repos') end def teardown remove_tmp_repo_dir end def test_get_re...
true
a3be69c1f83816170f2d795236beecf78dbe143b
Ruby
SophiaLWu/chess
/spec/pawn_spec.rb
UTF-8
2,467
2.921875
3
[ "MIT" ]
permissive
require "spec_helper" module Chess describe Pawn do describe "#possible_moves" do describe "when the white pawn is at location [1,1] and has not moved" do let(:pawn) { Pawn.new("white", [1,1]) } it "returns [[2,1],[3,1],[2,0],[2,2]]" do expect(pawn.possible_moves).to eql(...
true
16fa569504778601dff7542b15c318c98b310b74
Ruby
bookinstock/the_robot
/spec/analyser_spec.rb
UTF-8
33,272
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'byebug' require_relative 'spec_helper' require_relative '../src/models/kline' require_relative '../src/robots/analyser' RSpec.describe 'analyser' do describe 'strategy 1' do describe 'only one kline' do it 'one up' do raw_klines = [ { 'o...
true
5e5133dac42c8a32fb95da4c4b9210b089047cc0
Ruby
evavro/Jagmeister
/RubyCodeExamples/Blocks2.rb
UTF-8
396
4.34375
4
[]
no_license
# # Author: Jag Nandigam # # More on blocks in Ruby # class Test def sum x = 0 for i in 1..10 x += yield i end x end end def main t = Test.new() y = t.sum { |i| i * i } puts y y = t.sum { |i| i % 2 } # % is remainder operator puts y y = t.s...
true
3ddc41e8857e41e948ae232a0d396367ca46a0d5
Ruby
MarhicJeromeGIT/DancingLinks
/spec/cover_solver_spec.rb
UTF-8
2,168
2.9375
3
[]
no_license
require "cover_solver" require "byebug" RSpec.describe CoverSolver do subject { described_class.new(matrix) } describe "#call" do context "empty matrix" do let(:matrix) do [] end it "raises an error" do expect { subject.call }.to raise_error(CoverSolver::InvalidMatrixSize) ...
true
e41b1212ab36873f2b03e9971fa00db7956033b9
Ruby
CodeGreer/Ruby_Challenges
/fizzbuzz.rb
UTF-8
265
3.71875
4
[]
no_license
fizzbuzz = (1..100).to_a fizzbuzz.each do |number| if number % 3 == 0 && number % 5 == 0 puts "fizzbuzz" elsif number % 5 == 0 puts "buzz" elsif number % 3 == 0 puts "fizz" elsif puts number end end
true
cd189223f6d9116aa92e4569721e0337fbc22c73
Ruby
MondayHealth/scraper
/app/jobs/scrapers/base.rb
UTF-8
1,087
2.546875
3
[]
no_license
require 'nokogiri' require 'csv' require_relative '../concerns/logged_job' module Jobs module Scrapers class MissingSourceError < Exception; end class Base extend Jobs::Concerns::LoggedJob def self.initialize_csv(path, csv_fields) unless File.exists?(path) CSV.open(path, 'w+'...
true