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
36e3c167aa2270a203d32a9a4ba2f45596a50198
Ruby
mmatney22/ruby-objects-has-many-through-readme-online-web-sp-000
/lib/waiter.rb
UTF-8
691
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Waiter attr_accessor :name, :yrs_experience @@all = [] def initialize(name, yrs_experience) @name = name @yrs_experience = yrs_experience @@all << self end def self.all @@all end def new_meal(customer, total, tip = 0) Meal.new(self, customer, total, tip) end def meals Meal.all.s...
true
4291ef484a57cb5319b90d7a631d91122f7c58e9
Ruby
blcklst-eng/kimmel
/app/models/message_media_image_variant.rb
UTF-8
836
2.65625
3
[]
no_license
class MessageMediaImageVariant def initialize(media:, height:, width:) @height = height @width = width @original = media @variant = original.variant(resize: "#{height} x #{width}") end def height return original_height unless apply? original_height * ratio end def width return o...
true
eee46205a11eef3c9b0683d31f4de03ecb07cf6b
Ruby
momchianev/test
/study/11.rb
UTF-8
82
2.90625
3
[]
no_license
# with kur n = 0 while n <= 999 n = n + 1 print n print "\nkur" end
true
ee43e30e9233817e0e23c90b64aae600eb62ded8
Ruby
klavinslab/ProtocolsForReview
/high_throughput_culturing/protocol/dilute_collection/protocol.rb
UTF-8
7,748
2.625
3
[]
no_license
# By: Eriberto Lopez # elopez3@uw.edu # 08/13/19 needs "Standard Libs/Debug" needs "High Throughput Culturing/HighThroughputHelper" class Protocol include HighThroughputHelper include Debug # DEF INPUT = "Culture Plate" OUTPUT = "Diluted Plate" DILUTION = "Dilution" MEDIA = "Media" KEEP_IN_PLT = "K...
true
859d9071571e7d151a9927ebe14f45d8b3c645cf
Ruby
lucas-duarte-webjump/POO_Ruby
/animal1.rb
UTF-8
289
2.78125
3
[]
no_license
class Animal def pular puts 'Toing! toing! boing! poing!' end def dormir puts 'ZzzzZzz!' end end class Cachorro < Animal def latir puts 'Au au' end end cachorro = Cachorro.new cachorro.pular cachorro.latir cachorro.dormir gato.pular
true
1d3a032ecb5fc9feedf5b9112d2f372b3a6cbdd2
Ruby
rankoliang/chess
/lib/chess_config.rb
UTF-8
2,357
2.75
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'paint' # Contains contants used throughout the program # :reek:TooManyConstants module ChessConfig SAVE_DIR = 'saves' BOARD_WIDTH = 8 BOARD_HEIGHT = 8 TRUE_COLORS = true Paint.mode = 256 unless TRUE_COLORS # rubocop:disable Style/StringLiterals BACKGROUND_DARK = Ha...
true
d09181b9e82005f4f0bb8d96de14424cba617d36
Ruby
sherpanat/AR-Basics-246
/db/seeds.rb
UTF-8
293
2.84375
3
[]
no_license
# This is where you can create initial data for your app. require 'faker' puts 'Seed begins' 20.times do restaurant = Restaurant.new( name: Faker::Hipster.word, address: Faker::Address.street_address ) restaurant.save end puts 'Has successfully created 20 hypsters restaurants'
true
b71188be9f8a0b9fb3bbcf7943648a26101aa1f0
Ruby
jflohre/bowling_kata
/spec/bowlingkata2_spec.rb
UTF-8
3,002
3.015625
3
[]
no_license
require "spec_helper" describe 'Bowling' do let(:game) {game = Game.new} it 'should return a new game' do game.should be_an_instance_of Game end it 'should return 10 if the first frame has an X' do game.line([['X'],[0,0]]).should == 10 end it 'should return 10 if the first frame has a /' do game.line(...
true
93d12a99a5e2f62de9d2699a18f10e1357605bb5
Ruby
michael-mm/launch_school_back_end
/intro_to_programming/exercises/8.rb
UTF-8
208
2.890625
3
[]
no_license
#Hash using both ruby syntx styles #old style: epl = {:north_london => "arsenal", :merseyside => "liverpool"} puts epl[:north_london] #new styles: mls = {west: "la_galaxy", east: "chicago"} puts mls[:east]
true
6b47218208ff0664c4ea6d9addb3d97ce76a0c84
Ruby
techtronics/Booting-the-Analytics-Application
/src/ruby/create_avros.rb
UTF-8
976
2.734375
3
[]
no_license
require 'rubygems' require 'avro' require 'voldemort-rb' require 'json' # This is our Avro schema SCHEMA = <<-JSON { "type": "record", "name": "Email", "fields" : [ {"name": "message_id", "type": "int"}, {"name": "topic", "type": "string"}, {"name": "user_id", "type": "int"} ]} JSON puts "Avro Schem...
true
c2327d74242c87537e87ab564db26db17994585f
Ruby
Moemi-Otsu/graduate_app
/spec/models/user_spec.rb
UTF-8
1,995
2.546875
3
[]
no_license
require 'rails_helper' RSpec.describe User, type: :model do let(:user) { create(:user) } let(:second_user) { create(:second_user) } describe 'バリデーション確認' do it "nameが存在しなければ、エラーを出す" do user = User.new expect(user.valid?).to be false expect(user.errors[:name]).to include("を入力してください") e...
true
0d0292adf88d0825e011bc45e80060022ac266e3
Ruby
IanGeraldKing/3C_tictactoe
/board_v1.rb
UTF-8
885
3.921875
4
[]
no_license
class Board GAP = " " def initialize @board = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] end ### Architecting the Board ### def rows rows = [] @board.each do |row| rows <<row.join end return rows end def columns columns = [] for i in 0..2 column = "" @board.each do |row| colu...
true
67feee5fb6f3cfdee04c7a8729dc2821e927e624
Ruby
jajapop-m/AtCoder
/ABC_174/B.rb
UTF-8
132
2.84375
3
[]
no_license
n,d = gets.split.map(&:to_i) count = 0 n.times do x,y = gets.split.map(&:to_i) count += 1 if x**2 + y**2 <= d*d end puts count
true
bbe7eb49a1db58d4b8fa52f7a9e6f45270889896
Ruby
leonardodiasb/ruby-capstone
/classes/music_album.rb
UTF-8
272
2.578125
3
[]
no_license
class MusicAlbum < Item attr_accessor :on_spotify, :title def initialize(*args, title:, on_spotify: true) super(*args) @on_spotify = on_spotify @title = title end private def can_be_archived? @publish_date > 10 && @on_spotify = true end end
true
3bca06a3483654a6b9a4dd40a4e3b03b62792891
Ruby
ruckserve/JuniorDevs
/patterns/decorator/retry/client.rb
UTF-8
204
3.296875
3
[]
no_license
class Client def initialize(obj) @obj = obj end def call_it begin @obj.get() rescue => e puts e.inspect end end def print_it @obj.print_hello_world() end end
true
c6e34d84ff718f6e2ddfdcb97206ce9feee4c89d
Ruby
josh-works/exercism
/ruby/nth-prime/nth_prime.rb
UTF-8
475
3.328125
3
[]
no_license
require 'pry' class Prime def self.nth(number) raise ArgumentError if number == 0 counter = 2 current_number = 2 while (counter <= number) do current_number += 1 counter += 1 if is_prime?(current_number) end current_number end private def self.is_prime?(number) (2...
true
d044b17cb9a902fa311d278a182e5b2aebd87907
Ruby
anoiaque/sudoku_solver_2.0
/lib/sudoku.rb
UTF-8
1,784
3.328125
3
[]
no_license
require 'sudoku_extensions.rb' class Sudoku @elements =[] @blocks =[] @lines =[] @columns =[] attr_accessor :elements,:blocks,:lines,:columns def solve change = false #generate_doublons # self.each_line {|l| l.solve_doublons} (1..9).each do |number| (1..81...
true
5c544bc8b892448e72ed7255ecd92cae1df1c921
Ruby
collinmay/bigrobot
/robot/adapter/sabertooth.rb
UTF-8
1,484
2.90625
3
[]
no_license
# Author: Collin May require_relative "../sensors.rb" module Adapters class Sabertooth def initialize(connection, addr=128) @connection = connection @m1 = Motor.new(self, 1) @m2 = Motor.new(self, 2) @addr = addr end attr_reader :connection attr_reader :m1 attr_reader :m2...
true
59d59dfaccd80c597436110327d3c4e23409bf4d
Ruby
chemunoz/Ironhack
/PreWork/03-Ruby/07-Shake Shack/christopher-milkshake.rb
UTF-8
1,736
3.8125
4
[]
no_license
require 'pry' #binding.pry class ShakeShope def initialize @carta_milkshakes = [] end def add_milkshakes(milkshake) @carta_milkshakes.push(milkshake) end def milkshakes_list @carta_milkshakes.each do |milkshaker| #milkshaker #milkshake.price_of_milkshake #la anterior linea da como error un u...
true
410b42aa43a514d866e8ff0a1aba1ccd2665a94e
Ruby
codemargaret/rock_paper_scissors_ruby
/lib/rps.rb
UTF-8
814
3.78125
4
[ "MIT" ]
permissive
require('pry') class RPS def initialize(player1,player2) @player1 = player1 @player2 = player2 end def wins(player1, player2) if (player1 === "rock") & (player2 === "scissors") "rock beats scissors player 1 wins" elsif (player1 === "paper") & (player2 === "rock") "paper beats rock pla...
true
2aea5a366ac90f63eba178cb0a1b0c071c6e5b3f
Ruby
Slouch07/RB101
/Small_Problems/Easy_1/how_many.rb
UTF-8
316
3.1875
3
[]
no_license
vehicles = [ 'car', 'car', 'truck', 'car', 'SUV', 'truck', 'motorcycle', 'motorcycle', 'car', 'truck' ] def count_occurrences(array) occurences = {} array.uniq.each { |item| occurences[item] = array.count(item) } occurences.each { |key, value| puts "#{key} => #{value}" } end count_occurrences(vehicles)
true
a3128114c237332955eed361ba6e2f4700c4ca4a
Ruby
caitp222/algorithms
/word_length.rb
UTF-8
328
3.328125
3
[]
no_license
def word_length(arr) hash = {} arr.each do |word| hash[word] = word.length end hash end p word_length(["a", "bb", "a", "bb"]) == {"bb" => 2, "a" => 1} p word_length(["this", "and", "that", "and"]) == {"that" => 4, "and" => 3, "this" => 4} p word_length(["code", "code", "code", "bug"]) == {"code" => 4, "bug...
true
a9341216d1cff84601ee9ba3c9338c26029ed925
Ruby
kdow/factorial
/lib/factorial.rb
UTF-8
334
4.125
4
[]
no_license
# Computes factorial of the input number and returns it # Time complexity: O(n) where n is the value of the input number # Space complexity: O(1) def factorial(number) unless number raise ArgumentError, "Non-number entered." end if number == 1 || number == 0 return 1 else number * factorial(number -...
true
2fa7ace8f5f81b243181943295d255afc245c426
Ruby
sebaquevedo/desafiolatam
/clase13/palabra_final.rb
UTF-8
771
3.796875
4
[ "MIT" ]
permissive
#agrega palabra al final #solucion iterar array # puts "ingrese la palaba a buscar" # palabra = gets.chomp #lee palabra desde consola # file = File.open("hola.txt", "r"){ |file| file.read } #abre y lee archivo # array_palabras = file.split("\n") #separa por saltos de linea # count = 0 # array_palabras.each{|va...
true
bb49bc989bb9d6ad3ae7cb36b67db462b45a5437
Ruby
rsl/stringex
/test/unit/localization/da_test.rb
UTF-8
3,961
2.921875
3
[ "MIT" ]
permissive
# encoding: UTF-8 require 'test_helper' require 'i18n' require 'stringex' class DanishYAMLLocalizationTest < Test::Unit::TestCase def setup Stringex::Localization.reset! Stringex::Localization.backend = :i18n Stringex::Localization.backend.load_translations :da Stringex::Localization.locale = :da ...
true
e0c6615c14e38b603cb4392e9ff988bcfe607124
Ruby
aaj3f/alphabetize-in-esperanto-online-web-prework
/lib/alphabetize.rb
UTF-8
293
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' ESPERANTO_ALPHABET = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz" #binding.pry def alphabetize(arr) arr.sort_by do |phrase| #binding.pry new_array = phrase.split("") #binding.pry new_array.collect do |letter| ESPERANTO_ALPHABET.index(letter) end end end
true
4003e30999909f63cebc15a7785e88438a7c0671
Ruby
narogers/sidrat
/app/validators/broadcast_validator.rb
UTF-8
1,365
2.5625
3
[ "Apache-2.0" ]
permissive
class BroadcastValidator < ActiveModel::Validator def validate(record) end_of_range = DateTime.now + (5*365) puts "Validating broadcast information for #{record}" unless ['unaired', 'broadcast'].include?(record.broadcast_status) record.errors.add(:broadcast_status, "The current status is not va...
true
26839a116e30dcef45b36d5187fd2b32a8562267
Ruby
sergio-bobillier/tdd-ruby
/strings/runner.rb
UTF-8
724
3.796875
4
[]
no_license
require_relative 'basic_string' require_relative 'quoted_string' puts '#### BasicString ####' sentence = BasicString.new('A rose by any other name still smells sweet') words = ['Rose', 'rose', 'smell', 'Sweet', 'violet', 'any other', 'a', 'A'] puts '#include?' words.each do |word| puts "\t" + [word, sentence.inclu...
true
c2ce97fd8d2a63474e17b83028191661871f37a5
Ruby
apmiller108/anomalous
/lib/anomalous/plot/histogram.rb
UTF-8
1,052
2.796875
3
[ "MIT" ]
permissive
require 'nyaplot' module Anomalous module Plot class Histogram def initialize(features, options = {}) @ith_feature = options[:ith_feature] || :all @dir = options[:dir] || 'histograms' @bins = options[:bins] || 100 @features = filter_feature_s...
true
23f042a9fa633067f1348ae04798215214c60b31
Ruby
seanlucius/ruby-object-attributes-lab-bootcamp-prep-000
/lib/person.rb
UTF-8
205
3.046875
3
[]
no_license
class Person def name @name end def name=(new_person_name) @name = new_person_name end def job @job end def job=(new_person_job) @job = new_person_job end end
true
119489d2c13cc703645be3cb2618d8fd4f3ec4f1
Ruby
alandotcom/usps_intelligent_barcode
/spec/routing_code_spec.rb
UTF-8
4,420
2.6875
3
[ "MIT" ]
permissive
require File.expand_path('spec_helper', File.dirname(__FILE__)) module Imb describe RoutingCode do describe '::coerce' do let(:zip) {85308} let(:plus4) {1465} let(:delivery_point) {12} subject {RoutingCode.coerce(o)} shared_examples 'coerces' do its(:zip) {should == zip...
true
ae8be916f4a18968a4ba8b1a4977cd7f3f648d8c
Ruby
anishshrestha007/BoggleGame
/app/controllers/v1/game_controller.rb
UTF-8
2,603
3.203125
3
[ "MIT" ]
permissive
class V1::GameController < ApplicationController def index end # Gets Game Data # Url: /v1/game/getGameData # Description: Get a new set of words based on the provided matrix size def getGameData length = params[:length] status = STATUS_OK can_proceed = true error_msg = "" response_data...
true
707585e560413eb0a094e531408873356208de33
Ruby
danwyryunq/eis
/kata3/spec/batalla_naval_spec.rb
UTF-8
4,711
3.015625
3
[]
no_license
require 'rspec' require_relative '../model/batalla_naval.rb' describe 'BatallaNaval' do let(:juego) { BatallaNaval.new(10,10) } let(:jugador) { 1 } it 'el juego se inicializa con tableros de 10 casilleros de alto y 10 de ancho' do expect( juego.alto_tablero ).to eq 10 expect( juego.ancho_tablero ).to eq...
true
4a81c432466c576667b57768f5546e1f8af27d35
Ruby
ianmcknnn/ruby-enumerables-hash-practice-nyc-pigeon-organizer-lab-wdc01-seng-ft-060120
/nyc_pigeon_organizer.rb
UTF-8
1,445
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def nyc_pigeon_organizer(data) #initializing a hash, a name array, and a data_type_list to which to add #things as we see them in the loops new_hash = {} name_list = [] data_type_list = [] #loop through the hash of data-types data.each_pair do |data_type, hash| #loop through the hash of features ...
true
9f5d0109eb13b3a47c8d0fdf9441e204f31a1194
Ruby
killy971/project-euler
/ruby/041.rb
UTF-8
449
3.09375
3
[]
no_license
#!/usr/bin/ruby1.9 # vim:set ts=2 sw=2: require 'mathn' class Integer def is_pandigital str = to_s digits = str.split("").sort return false if digits.uniq.size < digits.size # str[0] == ?1 && str[digits.size - 1] == digits.size + 48 digits[0].to_i == 1 && digits[digits.size - 1].to_i == digits.size end en...
true
c88d1738366445abe807c4fb3bbbc540c81a6ab4
Ruby
uqbar-paco/metaprogramacion-xunit-clase-20132c
/test/motor_xunit_spec.rb
UTF-8
1,019
2.78125
3
[]
no_license
require_relative '../xunit/mi_test' require_relative '../xunit/motor_xunit' require 'rspec' describe 'Testeo de motor xunit' do it 'ejecutar si todos estan bien' do motor= MotorXUnit.new resultados = motor.correr_todos_los_tests(MiTest) expect(resultados.all? { |resultado| resultado.paso? })...
true
5d5529bbb6022b4d9de8fd707531ddd85cfb5432
Ruby
gltaborda/ruby_the_odin_project
/chess/lib/game.rb
UTF-8
734
3.34375
3
[]
no_license
require_relative 'board' require_relative 'player' class Game attr_reader :board, :players attr_accessor :winner def initialize(player1, player2) @board = Board.new @players = [player1, player2] @winner = false end def play_match board.load board.display until over? array = pl...
true
9476415eac1f7b097786b3667ec8813057dea838
Ruby
hiddenone/Portfolio-Project-1-User-Stories
/app/helpers/application_helper.rb
UTF-8
666
2.515625
3
[]
no_license
module ApplicationHelper # Allows setting the value to show in an HTML select # param: attribute, e.g., @story.priority # param: default_value, what to show if no value exists for # and instantiation def options_default(attribute, default_value) if attribute return attribute else ...
true
791daacfb5c5b4de731873cdfc140bda8cc9cab2
Ruby
bougui505/blog
/_plugins/jekyll.tag-cloud.rb
UTF-8
3,251
2.984375
3
[ "MIT" ]
permissive
# Copyright (C) 2011 Anurag Priyam - MIT License module Jekyll # Jekyll plugin to generate tag clouds. # # The plugin defines a `tag_cloud` tag that is rendered by Liquid into a tag # cloud: # # <div class='cloud'> # {% tag_cloud %} # </div> # # The tag cloud itself is a collection...
true
017007f4c12935f56b94d6149b2131f2ad58681d
Ruby
nigel-lowry/means
/lib/means.rb
UTF-8
3,698
3.859375
4
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'mathn' require 'active_support/all' # Allows calculation of arithmetic, geometric and harmonic means. # Class methods allow the passing in of a data set. # Alternatively an object can be created and elements can # be added with #push class Mean # Calculate the arithmetic mean # @param [Array<Numeric>] d...
true
aea92c218dde8c594a05abfdcfb424ca98150fb7
Ruby
exceedhl/algorithm_coursra_problems
/scc/graph.rb
UTF-8
1,693
3.390625
3
[]
no_license
require 'pp' class Node attr_reader :index attr_accessor :incoming_edges, :outgoing_edges def initialize(index) @index = index @incoming_edges = [] @outgoing_edges = [] end def to_s index.to_s end def print puts "node: #{index.to_s}" puts " incoming edges: #{incoming_edges....
true
7462d490f8f13d829ee043e98cd13089e78d41fc
Ruby
foymikek/backend_mod_1_prework
/day_1/ex7.rb
UTF-8
2,304
4.0625
4
[]
no_license
# prints the text in the quotation marks and makes a new line, /n puts "Mary had a little lamb." # prints the string in the curly brackets within the parent string and # makes a new line, /n puts "Its fleece was white as #{'snow'}." # prints the text within the quotation marks and makes a new line, /n puts "And everywh...
true
73e55ad51dac36d4472ee3dd2bed77af6ceaef0f
Ruby
eugmill/euler
/ruby/problem06.rb
UTF-8
638
4.09375
4
[]
no_license
=begin The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 55^2 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 302...
true
0119c8b76cd0794907f323c3688e5bddee29c0ea
Ruby
pariyathida/my-warehouse
/test/models/parcel_test.rb
UTF-8
3,217
2.921875
3
[]
no_license
require 'test_helper' class ParcelTest < ActiveSupport::TestCase def setup @parcel = parcels(:supplementary_food_parcel) end # # Validation # test "that it raises errors when fields are blank" do parcel = Parcel.new(id: 1) assert_equal false, parcel.valid? assert_equal "can't be blank", ...
true
f55e171619d5bd4ff2e45b3862645a99786a6ec7
Ruby
tejasmanohar/timgur
/app.rb
UTF-8
1,340
2.625
3
[ "MIT" ]
permissive
### Gems require 'orchestrate' require 'sinatra' require 'twilio-ruby' ### API Clients app = Orchestrate::Application.new(ENV['ORCHESTRATE_API_KEY']) subscribers = app[:subscribers] client = Orchestrate::Client.new(ENV['ORCHESTRATE_API_KEY']) ### Configure Twilio Twilio.configure do |config| config.account_sid = ...
true
d2be3aba92b5e0dd1084d0ff4f3ceb00e5bbec89
Ruby
cielavenir/procon
/codeforces/tyama_codeforces630N.rb
UTF-8
119
2.78125
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby a,b,c=gets.split.map(&:to_f) (a=-a;b=-b;c=-c)if a<0 puts [1,-1].map{|s|(-b+s*Math.sqrt(b*b-4*a*c))/2/a}
true
f3bec9485ac1d89abdd0b914ef4cced6f70422d0
Ruby
VictorHolanda21/cursoRuby
/exercicios/exercicio02/quest11.rb
UTF-8
178
3.59375
4
[]
no_license
puts "Digite uma nota entre 0 e 10: " nota = gets.chomp.to_i while (nota>10 || nota<0) puts "Nota inválida!" puts "Digite uma nota entre 0 e 10: " nota = gets.chomp.to_i end
true
947dff9ca05634de80378f56aa8b059a25bd52bf
Ruby
TuftsUniversity/whowas
/lib/generators/whowas/templates/search_method.rb
UTF-8
1,984
2.984375
3
[ "MIT" ]
permissive
module Whowas class MySearchMethod # All required public methods are contained in the Middleware package. It # initializes the search method, calls search on the adapter with the # provided input, and returns the output to the next search method or the # caller. # # The Searchable modules ...
true
b432f6be756526c62c950667491466ea1de2522e
Ruby
heedspin/doogle
/lib/doogle/spec_version_synchronizer.rb
UTF-8
1,389
2.515625
3
[ "MIT" ]
permissive
require 'plutolib/logger_utils' class Doogle::SpecVersionSynchronizer include Plutolib::LoggerUtils def initialize(spec_version_id=nil) @spec_version_id = spec_version_id @web_creates = 0 @web_updates = 0 @web_no_change = 0 @web_errors = 0 @web_deletes = 0 end def run_in_background! ...
true
196a50d7a59f04b64608f7b98c129c4e8ff8aa1e
Ruby
forestturner/w2d5
/lib/p02_hashing.rb
UTF-8
540
3.234375
3
[]
no_license
class Fixnum # Fixnum#hash already implemented for you end # class Array # def hash # # sum = 0 # self.flatten.each_with_index { |el, index| sum += (el * index) } # sum.hash # end # end class String def hash int_array = self.split("").map { |el| el.ord } int_array.hash end end class Ha...
true
9408b7bb6a1e607783099988edba3ff51b2d3710
Ruby
sajoy/hair_salon
/spec/client_spec.rb
UTF-8
2,387
2.6875
3
[]
no_license
require('spec_helper') describe(Client) do describe('#id') do it("will return a client's unique id as a fixnum") do client1 = Client.new({:name => "Kris K.", :id => nil}) client1.save() expect(client1.id()).to(be_an_instance_of(Fixnum)) end end describe('#name') do it("will return...
true
943e8e803d05b20a3c371ef29159d478c900fb69
Ruby
samvaughn/courseproject
/ninety_nine.rb
UTF-8
607
3.125
3
[]
no_license
begin_bottles = 5 now_bottles = begin_bottles while now_bottles > 2 puts now_bottles.to_s + ' bottles of beer on the wall' puts now_bottles.to_s + ' bottles of beer' puts 'Take one down, pass it around' now_bottles = now_bottles - 1 puts now_bottles.to_s + ' bottles of beer on the wall' puts end puts '2 bottles...
true
6959b1a7ac1a53ad38dd0fe4a6afbfd33b451231
Ruby
ryo-s2000/practice-ruby
/ruby/somecode/erro.rb
UTF-8
405
3.125
3
[]
no_license
begin # わざと例外を起こす 5 + nil # 例外オブジェクトを変数 error に代入 rescue => error # 変数 error を配列で表示する。 p error.message p error.backtrace end begin # わざと例外を起こす 5 + "konnitha" # 例外オブジェクトを変数 error に代入 rescue => error # 変数 error を配列で表示 p error.message p error.backtrace end
true
a3832d6b03cb6237f180ff2c2a26555abe93cd97
Ruby
rpepato/rgis
/lib/rgis/services/geometry_service.rb
UTF-8
9,054
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'rgis/lookup' require 'rgis/request' module RGis module Services module GeometryService def project(params = {}) pre_validate_request response = project_geometry(params) parse_result(response) end def project!(params = {}) pre_validate_request ...
true
e999f513b0419d83b9d61680afbff3263aaed6a6
Ruby
colorbox/AtCoderLog
/abc/062/d.rb
UTF-8
2,661
3.515625
4
[]
no_license
class PriorityQueue attr_accessor :data def initialize(arr=[]) @data = arr end def push(e) @data.push(e) current_index = @data.size-1 parent_index = parent(current_index) while current_index > 0 && @data[parent_index] > @data[current_index] @data[current_index] = @data[parent_index...
true
8457af77c1e153d8c9192a14d7f6f12e3c9a54b8
Ruby
frankzinner/RubyScripts
/tests/Haushaltskonto_test.rb
UTF-8
997
2.90625
3
[]
no_license
require "Haushaltskonto" require "test/unit" class HaushaltskontoTest < Test::Unit::TestCase @filename @instance def setup #@filename = File.expand_path('~/Projects/RubyScripts/tests/TESTFILE.CVS') @filename = File.expand_path('~/Projects/RubyScripts/tests/Umsatzanzeige.csv') @instance = Haushaltskonto.new(...
true
25593a27f0bcc79b26a0536c42514e31991a179d
Ruby
Yuuki-oomaru/ruby-practice
/2-8.rb
UTF-8
170
3.125
3
[]
no_license
puts "計算をはじめます" puts "2つの数字を入力してください" a=gets.to_i b=gets.to_i puts "出力します" puts "a*b=#{a*b}" puts "終了します"
true
51979b9ee2c7a0138d011a3797b130da94d2227a
Ruby
gaofeiii/Dino.game-server
/app/models/god_const.rb
UTF-8
639
3.015625
3
[]
no_license
module GodConst module ClassMethods @@hashes = { :intelligence => 1, # 智力之神 :business => 2, # 商业之神 :war => 3, # 战争之神 :argriculture => 4 # 农业之神 } @@gods = { 1 => { :name => :god_of_argriculture, }, 2 => { :name => :god_of_business, }, 3 => { :name => :god_of_war, ...
true
683192bbf3f6a715d1fdba2c40afb9e79c09874e
Ruby
pikajude/phl
/app/models/scheduled_attendance.rb
UTF-8
441
2.546875
3
[]
no_license
class ScheduledAttendance < ActiveRecord::Base belongs_to :player belongs_to :game validates_presence_of :player validates_presence_of :game validate :correct_team private def correct_team unless self.game.away_team.players.where(id: self.player_id).exists? || self.game.home_team.players.w...
true
9db03a526995234d35891f315f1c4512cc3a8e09
Ruby
tongxm520/ruby-code
/basic/lib/verifier.rb
UTF-8
626
3.84375
4
[]
no_license
class Verifier def initialize(*words) @words=words @count=0 end def verified?(string) for e in @words while(string[e]) @count+=1 return true end end return false end def match_count @count end end v=Verifier.new "apple","orange" puts v.verified?("i got an appl...
true
1482f9b680edf169b0e68fda768b2fd9c412a493
Ruby
nnakagaki/code-eval
/moderate/trailing_string.rb
UTF-8
165
3.109375
3
[]
no_license
File.open(ARGV[0]).each_line do |line| line.chomp! str, substr = line.split(",") if str[str.length - substr.length..-1] == substr puts 1 else puts 0 end end
true
549eb986f49b4cb5fd2aa48707421f6c5c25cc7b
Ruby
wwilco/wdiall
/w07/d01/sina/server.rb
UTF-8
5,073
3.09375
3
[]
no_license
require 'sinatra' get '/coin_toss' do string = "<h1>heads or tails</h1>" erb :index, locals:{msg: string} end get '/dice_roll' do arr = [1,2,3,4,5,6].sample string = "<h1>#{arr}</h1>" erb :index, locals:{msg: string} end get '/magic8ball/will%20it%20snow%20tomorrow' do arr = [ "It is certain", "I...
true
21e2e43f14ac944154fb60b4c5cc6ea0460c1437
Ruby
lborner/calculators
/laby.rb
UTF-8
242
3.4375
3
[]
no_license
puts "What is the length of the base of your triangle" number = gets.chomp.to_f puts "What is the height of the triangle?" service = gets.chomp.to_f totalarea = number*service/2 puts "The area of the triangle is " + totalarea.to_s
true
241cd5898102a921aa439064565a645a8b3f2f5b
Ruby
autogrow/RedisAlerting
/lib/redis_alerting/config.rb
UTF-8
1,199
2.671875
3
[ "MIT" ]
permissive
module RedisAlerting class Config def initialize(opts) @config = opts parse_config end def to_hash @config end private def parse_config raise ArgumentError, "No config file specified" if @config[:config].nil? # automatically use a relative config pat...
true
44977518c83a4d422688c0ce78d77379a6859df7
Ruby
jthoenes/code_slide_generator
/lib/power_point/text_range.rb
UTF-8
1,002
2.65625
3
[ "Apache-2.0" ]
permissive
module PowerPoint class TextRange def initialize shape, text_range @shape, @text_range = shape, text_range end def text begin return @text_range.Text rescue return "" end end def add_text text start_position = @text_range.Length+1 @text_range.InsertAfter text...
true
f22a166dcefefad488cb117872ebd2285e600790
Ruby
gstewart88/Hotels
/methods.rb
UTF-8
1,369
4.1875
4
[]
no_license
def menu puts `clear` puts "*** Poor Hotels - Our hotels are just the worst ***" puts puts puts "1. Check In" puts "2. Check Out" puts "3. Lists all Rooms" puts "4. List all Guests" puts "5. Create Room" puts "6. Create Guest" puts "7. Occupancy Report" # puts "8. List Hotels" puts puts "0. ...
true
e56123ebf08fa587eaa8787f82fe7d3d06f382f1
Ruby
HarrisonMc555/euler
/euler51.rb
UTF-8
3,867
3.59375
4
[]
no_license
#!/usr/bin/env ruby require 'prime' module Enumerable def this_many? n, &block count = 0 self.each { |x| if block.call x count += 1 return false if count > n end } return count == n end def this_many_range? range, &block count = 0 e = self.each been_in_r...
true
04fc8ce559a5e963583c34751e1a501180346891
Ruby
stoic-coder/hetzner-k3s
/lib/hetzner/infra/ssh_key.rb
UTF-8
1,799
2.953125
3
[ "MIT" ]
permissive
module Hetzner class SSHKey def initialize(hetzner_client:, cluster_name:) @hetzner_client = hetzner_client @cluster_name = cluster_name end def create(ssh_key_path:) @ssh_key_path = ssh_key_path puts if ssh_key = find_ssh_key puts "SSH key already exists, skipping...
true
96bac2c6ebec42b17acb0841abe4f823135da00b
Ruby
VIP-eDemocracy/elmo
/app/models/form_versioning_policy.rb
UTF-8
2,975
2.75
3
[ "Apache-2.0" ]
permissive
# Implements the policy about when a form's version should be upgraded. # Any form component objects (Option, OptionSet, OptionNode, Question, Questioning) should call this class after updating. # It will tell the appropriate Forms to upgrade their versions. class FormVersioningPolicy # Sets the upgrade_neccessary fl...
true
7b8e76a132c3fa8443502f3ea8a92911f26260c7
Ruby
sunny-b/backend_practice
/Programming_Foundations/Lesson_2_SmProg/calculator.rb
UTF-8
2,126
4.3125
4
[]
no_license
# Build a calculator that takes two numbers and an operation, # and then displays the results. require 'yaml' MESSAGES = YAML.load_file('calculator_messages.yml') def prompt(message) Kernel.puts("=> #{message}") end def valid_number?(num) num =~ /[[:digit:]]/ end def valid_operation?(num) (1..4).cover? num.to...
true
bafc4ed2023251d5bd03d7427de9d2e3684f14f3
Ruby
edmondtam1/ruby-small-problems
/advanced_ruby/challenges/medium_1/protein_translation/protein_translation.rb
UTF-8
880
3.203125
3
[]
no_license
class InvalidCodonError < StandardError end class Translation CODON_MAPPING = { ['AUG'] => 'Methionine', ['UUU', 'UUC'] => 'Phenylalanine', ['UUA', 'UUG'] => 'Leucine', ['UCU', 'UCC', 'UCA', 'UCG'] => 'Serine', ['UAU', 'UAC'] => 'Tyrosine', ['UGU', 'UGC'] => 'Cysteine', ['UGG'] => 'Trypto...
true
17bd2bdbed501b0fbb3c4ac5552940d4908ecf48
Ruby
jan-czekawski/introduction-to-programming-exercises
/more/mongo/mongoid/module_3/41_pluck_scope.rb
UTF-8
2,114
3.1875
3
[]
no_license
# pluck => will get all the non nil values for the provided field Movie.all.pluck(:title) # entire doc is not returned; selected fields at the db level # using a projection is retrieved # entire doc is returned, grab 2 fields, rest is discarded Movie.where(rated: "PG").map { |movie| [movie.title, movie.release_date]}...
true
2cfe9088aef27e49f3e0f16f795cc26f5be87cc4
Ruby
Dan2552/gathering-of-scripts
/ruby/simple-rspec
UTF-8
5,135
3.1875
3
[]
no_license
#!/usr/bin/env ruby require 'open3' require 'pry' require 'io/console' class String def black; "\e[30m#{self}\e[0m" end def red; "\e[31m#{self}\e[0m" end def green; "\e[32m#{self}\e[0m" end def brown; "\e[33m#{self}\e[0m" end def yellow; "\e[33m#{self}\e[0m" end...
true
a9ca5fd9c25ad008fea7d2f73bb4b0337b4653df
Ruby
MrOdnan/Ruby
/RockPaperScissors-practice
UTF-8
1,641
4.25
4
[]
no_license
#!/usr/bin/env ruby class Rps def intro puts "Welcome to Rock, Paper, Scissors!" sleep(0.5) puts "Please enter your name" @player_name = gets.chomp sleep(0.5) puts "Welcome #{@player_name}!" end def weapon_player sleep(0.5) @weapon_player = gets.chomp.downcase if !(@weapon_player == "rock" |...
true
a4fd2534815a763ba7ef62083752cc1022dad298
Ruby
hanqingchen15/Algorithms
/Binary Search/findPeakElement.rb
UTF-8
308
3.375
3
[]
no_license
def find_peak_element(nums) left = 0 right = nums.length - 1 while left <= right return left if left == right mid = left + (right - left) / 2 if nums[mid] < nums[mid + 1] left = mid + 1 else right = mid end end return -1 end
true
c42e1ab8ac15e93312d130fabad5d671b87d72db
Ruby
ketan37dm/marvelor
/lib/marvelor/api/character_info.rb
UTF-8
822
2.53125
3
[ "MIT" ]
permissive
module Marvelor module API class CharacterInfo < BaseInfo attr_accessor :options PER_PAGE = 30 BASE_URL = '/v1/public/characters' def initialize(options = {}) @options = options end def fetch_response self.class.get(url, params) rescue => e { ...
true
ae720a6e76959d95125d2f68b39ee41330a9b60f
Ruby
VladimirGarciaM/POO_TF_V01
/TF/model/servicio.rb
UTF-8
250
2.796875
3
[]
no_license
class Servicio attr_accessor :codigo, :nombre, :residente, :estado, :mes def initialize(codigo, nombre, residente, estado, mes) @codigo, @nombre, @residente, @estado, @mes = codigo, nombre, residente, estado, mes end def pago end end
true
ccbafeac76543ac24a27803e92c36f671bcd76af
Ruby
DamirSvrtan/noodles
/lib/noodles/environment.rb
UTF-8
738
2.640625
3
[ "MIT" ]
permissive
module Noodles module Environment class << self def development? environment.to_s == 'development' end def production? environment.to_s == 'production' end def test? environment.to_s == 'test' end def environment? environment end ...
true
05b3de644fbe73e8c5617308ff91014ef86cd036
Ruby
LiliFelsen/ttt-10-current-player-bootcamp-prep-000
/lib/current_player.rb
UTF-8
183
3.109375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn_count(board) count = 0 board.each do |move| if move == "X" || move == "O" count += 1 end end count end def current_player(board) turn_count(board).even? ? "X" : "O" end
true
711a9ea32acbe5d79034be2aa357cffda54c420c
Ruby
saifulAbu/ProgrammingRuby
/24/dynamic-class.rb
UTF-8
223
3.515625
4
[]
no_license
Person = Struct.new(:name, :address, :likes) class Person def to_s "#{self.name} lives in #{self.address} and likes #{self.likes}" end end dave = Person.new("dave", "tx") dave.likes = "programming languages" puts dave
true
9055fcdd1c5dd1d5770a28f5533c1226b5823088
Ruby
SajjadAhmad14/Enumerables
/enum.rb
UTF-8
4,305
2.828125
3
[]
no_license
# rubocop:disable Metrics/ModuleLength # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity module Enumerable def my_each return to_enum(:my_each) unless block_given? size.times do |x| yield to_a[x] end self end ...
true
2b42ff6b75d74aac9e6926ffc4c27deee3a2a1aa
Ruby
rvadalamudi/ruby_programing
/Ruby/string_sort.rb
UTF-8
215
3.75
4
[]
no_license
def string_sort(string) result = [] words = string.split(" ").to_a result = words.sort_by { |x| x.length } result.join(" ") end puts "enter a string : " string = gets.chomp op = string_sort(string) puts "#{op}"
true
f2709fe5007a584ab7a801cea5d2ce059851f092
Ruby
pombredanne/ruby-deb822
/lib/deb822/scanner.rb
UTF-8
1,801
2.9375
3
[ "MIT" ]
permissive
require 'deb822' require 'stringio' module Deb822 # Low-level parser for deb822 documents class Scanner def initialize(input) @input = input.is_a?(String) ? StringIO.new(input) : input @in_paragraph = false end WS = /[ \t]/ def next_line loop do begin line = @...
true
bc532a19dbdf5f937acedd34d4cbb3f65bcd8fd7
Ruby
LBHackney-IT/report-a-defect
/app/presenters/report_presenter.rb
UTF-8
2,469
2.71875
3
[ "MIT" ]
permissive
module ReportPresenter attr_accessor :schemes, :report_form def date_range "From #{report_form.from_date} to #{report_form.to_date}" end def defects_by_status(text:) defects.where(status: text) end def defects_by_category(category:) trade_names = Defect::CATEGORIES[category] defects.for_t...
true
c8d7b7322ebb1d754edd6bd04db3329cb9149596
Ruby
bjoernalbers/faxomat
/spec/validators/fax_validator_spec.rb
UTF-8
1,096
2.8125
3
[ "MIT" ]
permissive
describe FaxValidator do let(:subject) do class SampleModel include ActiveModel::Model attr_accessor :fax_number validates :fax_number, fax: true # This enables the FaxValidator. end SampleModel.new end it 'validates minimum length' do subject.fax_number = '0123456' ...
true
66ff5a94bee4a43f140f7a0fd90771c740b34e1e
Ruby
floatbox/eap-ota
/lib/layered_exchange.rb
UTF-8
3,447
3
3
[]
no_license
# example # date = Date.today # ExchangeWithFallback.new( # SynchronizedRates.new( # DoubleConvertThrough.new('RUB', # InverseRatesFor.new( {from: 'RUB'}, # RatesUpdatedWithFallback.new( # ActiveRecordRates.new(CurrencyRate.where(date: date, bank: 'cbr')), # LazyR...
true
64bb4f7a1fe63b96cd7d6971a49b98ac503ab9b6
Ruby
gchelms/rumi-ruby
/lib/dictionary.rb
UTF-8
433
2.5625
3
[ "MIT" ]
permissive
require 'marky_markov' markov = MarkyMarkov::Dictionary.new('dictionary') markov.parse_file "there_is_a_way.txt" markov.parse_file "the_breeze_at_dawn.txt" markov.parse_file "not_intrigued_with_evening.txt" markov.parse_file "moving_water.txt" markov.parse_file "out_beyond_ideas.txt" markov.parse_file "there_is_a_commu...
true
7c675fadcc45062604902ebd42c43ab642f9c134
Ruby
thechanmoon/ramda-ruby
/spec/ramda/relation_spec.rb
UTF-8
6,158
2.875
3
[ "MIT", "Ruby" ]
permissive
require 'spec_helper' describe Ramda::Relation do let(:r) { Ramda } context '#equals' do it 'from docs' do expect(r.equals(1, 1)).to be_truthy expect(r.equals(1, '1')).to be_falsey expect(r.equals([1, 2, 3], [1, 2, 3])).to be_truthy expect(r.equals({}, {})).to be_truthy end it...
true
b2d3074dd17f71e1d7ebe299621275a5fc97d6e4
Ruby
osahyoun/boutros
/lib/boutros.rb
UTF-8
593
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "boutros/version" require 'boutros/client' require 'boutros/config' module Boutros extend Config class << self # Alias for Boutros::Client.new # # @return [Boutros::Client] def new(options={}) Boutros::Client.new(options) end # Delegate to Boutros::Client def method_miss...
true
df5db57884fa528e7332928c803298b6c3aac991
Ruby
GapIntelligence/gapintelligence-gem
/lib/gap_intelligence/client/requestable.rb
UTF-8
1,929
2.515625
3
[ "MIT" ]
permissive
module GapIntelligence module Requestable # Makes a request to a specified endpoint # # @param [Symbol] method one of :get, :post, :put, :delete # @param [String] path URL path of request # @param [Hash] options the options to make the request with # @yield [req] The Faraday request # @rai...
true
486d291eac842be418c8f9670b7e2d657a941d79
Ruby
plawtr/mortgage
/mortgage.rb
UTF-8
466
3.140625
3
[]
no_license
def provide_mortgage?(salary, deposit, property_value, bankrupt) return false if bankrupt loan_amount = property_value - deposit property_value <= 650000 ? min_deposit = 0.05 : min_deposit = 0.20 # 20% max_multiplier = 5 # how many annual incomes can be borrowed return true if deposit/property_value >= 0.75 ...
true
f33f8ec048b53c877c4c52c7d832da3b1548ff7d
Ruby
Joshuaatt/dictionary
/spec/word_spec.rb
UTF-8
673
2.953125
3
[]
no_license
require("rspec") require("word") describe(Word) do describe("#initialize") do it("creates a new Word object, and instantiates it with the two " \ "provided arguments") do expect(test_def = Word.new("carrot", "english")).to(eq(test_def)) end end describe("#word") do it("returns the Word for...
true
6caa70d650fdabc20443e131eb39d1a8b7966310
Ruby
pierrewebdev/programming-univbasics-4-simple-looping-lab-nyc04-seng-ft-071220
/lib/simple_loops.rb
UTF-8
471
3.875
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Write your methods here def loop_message_five_times(message) count = 0 until count == 5 do puts message count += 1 end end def loop_message_n_times(message,n) count = 0 until count == n do puts message count += 1 end end def output_array(message) message.each do |element| puts ele...
true
4857df00b05e1fa4e2c2147f88e1b7459f06803b
Ruby
abbyarmada/LamaZone
/app/models/order_item.rb
UTF-8
1,253
2.765625
3
[]
no_license
class OrderItem < ActiveRecord::Base before_validation :update_price validates :price, :quantity, presence: true validates :price, numericality: { greater_than: 0 } validates :quantity, numericality: { only_integer: true, greater_than_or_equal_to: 0 } belongs_to :book ...
true
0919a4ac9bc25498473e7d4a02eef5c3514a8d4d
Ruby
andrew1barron/Project
/app/models/user.rb
UTF-8
713
2.65625
3
[]
no_license
class User < ActiveRecord::Base # shows the user has a secure, encrypted password has_secure_password # can own many posts and replies, both of which are dependent on the user existing has_many :posts, dependent: :destroy has_many :replies, dependent: :destroy # User must have a first and last name #...
true
8d11f9bdb71e242147b6c3542e0a924698f40787
Ruby
weima-sage/rspec-rails
/gatherer/app/helpers/tasks_helper.rb
UTF-8
439
2.59375
3
[]
no_license
module TasksHelper include ProjectManagement def self.recent_time?(time) time >= VELOCITY_COUNTING_WEEKS.weeks.ago end def self.size_sum(tasks_to_sum) tasks_to_sum.to_a.inject(0) { |current, task| current + task.size } end def self.velocity_sum(tasks_to_sum) tasks_to_sum.to_a.inject(0) { |cur...
true
bb926db23561c6d290ba637be8176f582154a158
Ruby
palhamel/Ruby_exercises
/times_test.rb
UTF-8
48
3.0625
3
[]
no_license
30.times do print "What's your name? " end
true
c4c702a0c6b437631b05f9ddea6d5ab24aaf4334
Ruby
scmgalaxy/chef_environment
/chef-repo/ruby_code/staticmethod.rb
UTF-8
522
3.640625
4
[]
no_license
module AwesomeModule class Awesomeclass attr_accessor :awesome_level def initialize(awesome_level) @awesome_level=awesome_level end def self.mystatic_method puts " i am static method" end def mynonstatic_method puts "i am in non static method" end end end foo=AwesomeModule::Awesomeclass.new(10...
true
3f6bbf9b35d1d652ede4ebc0e87bb2adc6bc228b
Ruby
funapy-sandbox/ruby_sample
/7/24/main.rb
UTF-8
63
2.828125
3
[]
no_license
def hoge() yield ?a yield ?b end hoge() do |ch| p ch end
true
4ec42359061e62b27113f55cc9cb62710b41b910
Ruby
mjjor/mems
/app/controllers/coil_length_controller.rb
UTF-8
2,144
2.59375
3
[]
no_license
class CoilLengthController < ApplicationController layout "mems_landing" def lengthNew end def lengthCalc @outerDiam = params[:outerDiamIn].split.map {|r| Rational(r) }.inject(:+).to_f @innerDiam = params[:innerDiamIn].split.map {|r| Rational(r) }.inject(:+).to_f @width = params[:w...
true