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
bcf8a94f1cc9cf612b32c4e3e15e51e07729c093
Ruby
cmarshall10450/week-2-day-2-snakes-and-ladders
/specs/Dice.spec.rb
UTF-8
366
3.0625
3
[]
no_license
require('minitest/autorun') require_relative('../Dice') class TestDice < MiniTest::Test def setup @dice = Dice.new() end def test_has_6_sides assert_equal(6, @dice.sides.count) end def test_dice_rolls_random_number_between_1_and_6 result = @dice.roll possible_nums = [1, 2, 3, 4, 5, 6] assert_equal(t...
true
a62bd0c3d71ce813cbb4f201c2e201d449e8408a
Ruby
datamapper/dm-adjust
/lib/dm-adjust/collection.rb
UTF-8
1,411
2.65625
3
[ "MIT" ]
permissive
module DataMapper class Collection def adjust(attributes = {}, reload = false) raise NotImplementedError, 'adjust *with* validations has not be written yet, try adjust!' end ## # increment or decrement attributes on a collection # # @example [Usage] # * People.all.adjust(:salary ...
true
5c33b122da59f1f9cc015298acdcf1847c25a470
Ruby
murdens/Ruby
/prog5.rb
UTF-8
209
3.25
3
[]
no_license
str ='' while str != 'BYE' #puts 'Hi, Sonny' str = gets.chomp if str == str.upcase puts 'NO, NOT SINCE ' + rand(1930..1951).to_s+'!' else puts 'HUH?! SPEAK UP, SONNY!' end end
true
cd84625924da25709ca86d4273a010534544e2be
Ruby
geckods/CodeForces
/ED59/b.rb
UTF-8
209
2.9375
3
[]
no_license
if File.exists?("input") $stdin = File.open("input") $stdout = File.open("output","w") end n = gets.to_i n.times do kx = gets.chomp.split(" ").map(&:to_i) k = kx[0] x = kx[1] puts 9*(k-1) + x end
true
7c6c893ead7e1b096e16769e6fcf3972b7966521
Ruby
alexg622/project_euler_app_academy
/problem_fifteen.rb
UTF-8
224
3.234375
3
[]
no_license
# Lattice Paths # Problem 15 def lattice_paths(num_one, num_two) total_moves = num_one + num_two (1..total_moves).inject(:*) / (1..num_two).inject(:*) / ((1..num_one).inject(:*)) end lattice_paths(20, 20) # 137846528820
true
3a801e39550e986622612614921f763f16c479b9
Ruby
Neetha11/Test
/stud_string.rb
UTF-8
1,248
3.796875
4
[]
no_license
final = "" for i in 0..2 puts "Enter the student first name" first_name = gets.chomp puts "Enter the student second name" second_name =gets.chomp puts "Enter their marks" marks=gets.chomp final = final.concat(first_name.concat(second_name).concat('$').conc...
true
d1895c8b785cb704eecd722f7e7f31e776366bbb
Ruby
charliepatronr/rails-challenge-practice-chi01-seng-ft-080320
/app/models/company.rb
UTF-8
1,551
2.59375
3
[]
no_license
class Company < ApplicationRecord has_many :offices has_many :buildings, through: :offices has_many :employees accepts_nested_attributes_for :offices #why did office_ids work? Does this validation take care of both office_id and company_id??? validates :name, :office_ids, presence: true ...
true
27e8625158aa6704a6f4135b4e8c0b7d532376b4
Ruby
emomax/AdventOfCode2015
/dec8/task1/main.rb
UTF-8
1,995
3.703125
4
[]
no_license
################# # Pieslicer # # 2015 # ################# ## --- Day 8, task 1: Matchsticks --- # Space on the sleigh is limited this year, and # so Santa will be bringing his list as a digital # copy. He needs to know how much space it will # take up when stored. # It is common in many programming lan...
true
0caa5d1dbf79e52878bac4f456a637bd6b3e659d
Ruby
strivedi183/wdi3-rails
/r2013-03-08-tradr/app/models/stock.rb
UTF-8
778
2.78125
3
[]
no_license
# == Schema Information # # Table name: stocks # # id :integer not null, primary key # symbol :string(255) # price :decimal(, ) # shares :integer # user_id :integer # created_at :datetime not null # updated_at :datetime not null # class Stock < ActiveRecord::Base...
true
43d6a087aad52aa3971e13244d9fb22d9001d2d3
Ruby
chrisg67/solar-panels-rails
/spec/models/five_minute_reading_spec.rb
UTF-8
1,626
2.546875
3
[]
no_license
require 'spec_helper' describe FiveMinuteReading do before { @reading = FiveMinuteReading.new(time: "2013-08-07 10:05:00", power: 0.2, total_power: 5888.0 ) } subject { @reading } it { should respond_to(:time) } it { should respond_to(:power) } it { should respond_to(:total_power) } describe "when time i...
true
6c6499ebc131b02fad8f81b8eb5409733623ec69
Ruby
jamillosantos/tfprog2012.1
/classes/base/Player.rb
UTF-8
1,762
2.515625
3
[]
no_license
module MadBirds module Base class Player < Chingu::BasicGameObject attr_reader :startTime, :char attr_accessor :name, :deaths, :kills trait :timer def initialize(options) super self.name = options[:name] self.kills = 0 self.deaths = 0 @startTime = Gosu::milliseconds end publi...
true
89c9e6eedebab718c61a8b52eefbf7e17cb81d17
Ruby
gmanirud/interngr
/spec/models/student_spec.rb
UTF-8
3,448
2.609375
3
[]
no_license
require 'spec_helper' #Spec for the student model describe Student do before {@test_student = Student.new(fname: "Bob", lname: "Loblaw", password: "interngrpass", password_confirmation: "interngrpass", email: "bob@mail.utoronto.ca", year: 1, school: "University of Toronto", discipline: "ECE")} subject {@test_studen...
true
c7f6cce53cc39e39e5f13f0ebdcb10716014d744
Ruby
antoshalee/kaminari-logarithmic
/lib/kaminari/logarithmic/strategies/base_strategy.rb
UTF-8
553
2.59375
3
[ "MIT" ]
permissive
module Kaminari module Logarithmic module Strategies class BaseStrategy def build fail NotImplementedError end private def asc? @asc ||= (@global_start <= @global_finish) end def desc? !asc? end def enough?(val...
true
7ef39a685fc1798db72d7b20b5bcd6d9b4385802
Ruby
tjlytle/halidator
/lib/halidator.rb
UTF-8
767
2.65625
3
[]
no_license
require 'json' require_relative './halidate/pure_ruby' require_relative './halidate/json_schema' class Halidator attr_accessor :errors def initialize(hal, engine = :pure_ruby) case hal when String @json_string = hal parse_json else @json = hal end @errors = [] if engine ==...
true
2185da378751a2595fa0c2b2edf1bb4c4411c610
Ruby
fredrondina/mod1_final_paired_assessment
/lib/student.rb
UTF-8
322
3.59375
4
[]
no_license
require 'pry' class Student attr_reader :name, :age, :scores def initialize(attribute_hash = Hash.new) @name = attribute_hash[:name] @age = attribute_hash[:age] @scores = [] end def log_score(score) @scores << score end def grade (@scores.sum.to_f / @scores.length).round(1) end en...
true
a449ef4d4b20cad9b3e0f013c4a03636e2b185df
Ruby
itiut/sutra-copying
/perfect-ruby/c08/li08.05.rb
UTF-8
77
2.578125
3
[]
no_license
def yield_proc yield end proc_obj = Proc.new { 1 } p yield_proc &proc_obj
true
c1565d4ce9c1dee40d61677e4250500130d79f0c
Ruby
lwoodson/ddata
/spec/ddata/hash_spec.rb
UTF-8
1,200
2.75
3
[ "MIT" ]
permissive
require 'ddata/hash' describe Ddata::Hash do let(:redis) {Redis.new} let(:dhash) {Ddata::Hash.new(connection: redis, key: 'ddata-hash')} before {redis.flushdb} describe "#__setobj__ & #__getobj__" do it "should store hash in redis" do dhash.__setobj__(a: 1, b: 2) redis.keys.should == ['ddata-...
true
53a67073d634e36e833a145b53aefb8363036f2b
Ruby
DeuterGraves/codeclan_kareoke_classes_homework
/specs/venue_spec.rb
UTF-8
2,607
3.421875
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require("pry") require_relative("../song.rb") require_relative("../guest.rb") require_relative("../room.rb") require_relative("../venue.rb") class VenueTest < MiniTest::Test def setup() @song1 = Song.new("Golden Chain of Hate", "Blue Balls Deluxe", "Whisky, who...
true
6cdbcdcf3cd621b3f0c3a47aa1495777c17d726b
Ruby
jkshareef/collections_practice-seattle-web-career-042219
/collections_practice.rb
UTF-8
883
3.859375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def sort_array_asc(array) return array.sort end def sort_array_desc(array) return array.sort { |x,y| y <=> x } end def sort_array_char_count(array) array.sort_by { |word| word.length } end def swap_elements(array) array.insert(1, array[2]) array.delete_at(3) array end def swap_elements_f...
true
53626afe75f9f7b79a0fe83342bf1fd6a19bc20e
Ruby
dibyn/CodeWars-Challenges
/RubyCodeWarz/no_of_people_inBus.rb
UTF-8
1,948
4.28125
4
[]
no_license
=begin Number of people in the bus There is a bus moving in the city, and it takes and drop some people in each bus stop. You are provided a list (or array in JS) of integer array. Each integer array has two items which represent number of people get into bus (The first item) and number of people get off the bus (The...
true
0bb53bab862efa63b29b76d5c68e24c18c342605
Ruby
motri/oystercard
/lib/journey.rb
UTF-8
546
3.203125
3
[]
no_license
class Journey attr_reader :history, :in_journey, :entry_station, :exit_station, :journey def initialize @in_journey = false @entry_station = nil @exit_station = nil end def start(station) print 'Forgot to tap out!' if @in_journey @in_journey = true @entry_station = station @jour...
true
dc34ef4599c003babf620bb380b4964dade85c9a
Ruby
presha/Employee
/company1.rb
UTF-8
990
3.65625
4
[]
no_license
#Testing file.. require "Trainee" require "Developer" class Company1 attr_accessor :company_name def initialize(name=nil) self.company_name = name @employees=[] end def display_name self.company_name end def << (employee) @employees<<employee end def display_employees @employ...
true
0a6c9bc2ada46e989ebea27e56b0d0d819fb807d
Ruby
ubpb/katalog
/app/services/concerns/record_related_service.rb
UTF-8
1,423
2.609375
3
[ "MIT" ]
permissive
module RecordRelatedService extend ActiveSupport::Concern # A helper method which tries to update the record property of each element # of a collection of objects responding to 'record'. Therefor, it issues a # search using the given search_engine_adapter and updates the record property # for each element wh...
true
efc797e02792669857215888c794b3e87a1a86fd
Ruby
95-Samb/advent-of-code
/intcode_helpers/intcode_instructions.rb
UTF-8
873
2.921875
3
[]
no_license
class IntcodeInstructions def execute(instruction,i,intcode,parameters) @cycle = [1,2,7,8].include?(instruction) ? 4 : 2 case instruction when 1 intcode[intcode[i + 3]] = parameters[0] + parameters[1] when 2 intcode[intcode[i + 3]] = parameters[0] * parameters[1] when 5 ...
true
d0abf916b28b2a7e8952352eac944978bde72144
Ruby
kauec/Glasses-1
/spec/tests/range_search_test.rb
UTF-8
1,838
2.609375
3
[ "MIT" ]
permissive
describe 'search entries which have a value within a specific range' do context 'search with params sanitized by ActiveRecord' do it 'returns all the results with a field bigger than or equal to some arbitrary value' do (Glasses.search_range(Player, {age_min: '110'}).size).should == 3 end it 'returns all ...
true
26cbda4453632c069446e679cccf36a2d3c67274
Ruby
jamisonordway/denver_puplic_library
/lib/book.rb
UTF-8
340
2.65625
3
[]
no_license
class Book attr_reader :author_first_name, :author_last_name, :title, :publication_date attr_accessor :book_info def initialize(hash) @author_first_name = hash.values[0] @author_last_name = hash.values[1] @title = hash.values[2] @publication_date = hash.v...
true
c99e7f20da1603189afcb2f755428eb4e21c2d6d
Ruby
projectcypress/health-data-standards
/test/unit/ext/string_test.rb
UTF-8
388
2.609375
3
[ "Apache-2.0" ]
permissive
require 'test_helper' class StringTest < ActiveSupport::TestCase test "can be true values" do assert "TRUE".to_boolean assert "true".to_boolean assert "t".to_boolean assert "1".to_boolean end test "can be false values" do assert ! "false".to_boolean end test "will return false for n...
true
09a5800ccfc88529bcddbde9a8f569991ec7f490
Ruby
darchi07/codeiq
/exruby3.rb
UTF-8
282
3.359375
3
[]
no_license
# coding: utf-8 #filenameの文字列の長さの結果が8で出力されるのはどれ? filename = "text.txt" puts "length :#{filename.length}" puts "size: #{filename.size}" puts "count : #{filename.count}" #答え:lengthとsize,countは配列の要素数を返す関数
true
1005144b3a0802206e56e87c327bcbc8294b3770
Ruby
ayjlee/betsy
/test/models/order_item_test.rb
UTF-8
1,518
2.59375
3
[]
no_license
require "test_helper" describe OrderItem do let(:item1) {order_items(:orderitem1)} let(:order1) {orders(:pending_order)} let(:product) { products(:soap)} describe 'relationships' do it "has a product" do item1.must_respond_to :product item1.must_be_kind_of OrderItem item1.product.must_be...
true
6d078696043f27d3a254559cdbb197faaa2a9ea4
Ruby
e86400/phase-0-tracks
/ruby/santa.rb
UTF-8
1,406
3.328125
3
[]
no_license
class Santa def initialize(gender, ethnicity) #puts "Initializing Santa instance..." @gender = gender @ethnicity = ethnicity @age = 0 end def speak puts "Ho, ho, ho! Haaaappy holidays!" end def eat_milk_and_cookies(snickerdoodle) puts "That was a good #{snickerdoodle}!" end #r...
true
6138f72023a2cd0e59f1d2b1168b22484be35965
Ruby
FSolM/bowling-score-giver
/lib/FileHandling.rb
UTF-8
2,231
3.828125
4
[]
no_license
require "./lib/helpers/ErrorMessages.rb" ## # This module contains all the methods that are necessary for handling and parsing the data from the text file module FileHandling VALUES = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "F"] ## # The #extension works as a quick inspector of the inputted fi...
true
78a0563db2c38b30b23682c93b1b1e31ec4fe148
Ruby
plato721/head-first-design-ruby
/compound_patterns/ducks/duck_simulator.rb
UTF-8
910
2.859375
3
[]
no_license
#!/usr/bin/env ruby Dir['./lib/**/*.rb'].each { |f| require f} class DuckSimulator def initialize(duck_factory=nil) @duck_factory = duck_factory @duck_factory ||= QuackCounterFactory.new end def perform all_ducks = Flock.new # some assorted ducks ducks = ["mallard_duck", "decoy_duck", "dar...
true
24a340ec7736061e3652dd9bfa36018ebfd79f76
Ruby
bcurren/unison
/spec/unit/tuples/primitive_tuple_spec.rb
UTF-8
40,999
2.96875
3
[]
no_license
require File.expand_path("#{File.dirname(__FILE__)}/../../unison_spec_helper") module Unison module Tuples describe PrimitiveTuple do attr_reader :tuple describe "Class Methods" do describe ".new" do context "when .polymorphic_allocate is overridden" do it "returns the ...
true
f56eb97b4db4bdc1f1c1aebd2eb6dc5583fcaefa
Ruby
robesris/fb_nd
/app/models/piece/nav.rb
UTF-8
644
2.59375
3
[]
no_license
class Piece::Nav < Piece def val 60 end def side1 Constants::KING end def move_to(space, pass) self.player.update_attribute(:in_check_this_turn, self.in_check?) super(space, pass) end def in_check? self.player.in_check? end def flip return false if self.in_check? || self....
true
0be011aaf6a2553c2a120710c58e0c2c806ef0ff
Ruby
haydenwalls/Solar-System
/planet.rb
UTF-8
733
3.25
3
[]
no_license
class Planet attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact def initialize(name, color, mass_kg, distance_from_sun_km, fun_fact) raise ArgumentError.new("Mass value must be greater than zero") if mass_kg.to_i <= 0 raise ArgumentError.new("Distance from Sun must be greater than z...
true
d77fd9d7c7199497eea9db8df7bb630211b0d5fd
Ruby
bchatelard/CronIt
/lib/cron_it.rb
UTF-8
386
2.546875
3
[]
no_license
require 'active_support/time' class CronIt def self._every @every || [] end def self.every(time, opts = {}) @every ||= [] @every << [time, opts] end def self._run @run ||= [] b = eval("#{self.to_s}.new") if !b.nil? @run.each do |r| eval("b.#{r}") end end end...
true
33d5c33851a55d1b0e265b525f9bc9fec3e4c367
Ruby
timsully/RB_101_Programming_Foundations
/lesson_04/practice_problems_01/practice_problem_02.rb
UTF-8
354
4.09375
4
[]
no_license
# Practice Problem 2 # How does count treat the block's return value? How can we find out? ['ant', 'bat', 'caterpillar'].count do |str| str.length < 4 end # A block is given so it counts the number of elements for which the block returns a true value. Thus, returning the numbers of elements that is less than 4 chara...
true
a6ed824f8eb5ec9fdd7e226ce4925e0183365176
Ruby
ko1/ruby-ptrace
/sample/fakeeintr.rb
UTF-8
1,664
3.0625
3
[]
no_license
# # fakeeintr.rb # require 'optparse' require 'ptrace' opt = OptionParser.new{|o| o.on('-p', '--pid PID'){|pid| $pid = pid.to_i } o.on('--unistd UNISTD_FILE_PATH'){|us| # for exmaple: '/usr/include/asm-i486/unistd.h' $uni_std_file_path = us } o.on('-v', '--verbose'){ $verbose = true } } o...
true
1daf4fe268d4713a81716617f896840721721f63
Ruby
pdxwolfy/Challenges
/Pascal/pascals_triangle.rb
UTF-8
764
3.546875
4
[]
no_license
#!/usr/bin/env ruby # Copyright (c) 2016 Pete Hanson # frozen_string_literal: true # :reek:FeatureEnvy class Triangle attr_reader :rows def initialize height @rows = (1..height).map { next_row } end private def next_row bottom_row = @previous_row ? [0, *@previous_row, 0] : [0, 1] @previous_row...
true
9ceb13084b922e3042345b2c644da0a584ecbf5d
Ruby
mhdz9/codewars
/Ruby/ipv4-to-int32.rb
UTF-8
764
3.875
4
[]
no_license
=begin Take the following IPv4 address: 128.32.10.1 This address has 4 octets where each octet is a single byte (or 8 bits). - 1st octet 128 has the binary representation: 10000000 - 2nd octet 32 has the binary representation: 00100000 - 3rd octet 10 has the binary representation: 00001010 - 4th octet 1 has the bi...
true
97c7b2b01595402b68b6baa6e7c8f4bfdec6d194
Ruby
PersonofNote/cypher-sinatra
/cypher.rb
UTF-8
1,050
3.46875
3
[]
no_license
require 'sinatra' #puts "Secrets! Put in a message and I'll encode it for you." #message = gets.chomp #puts "Input a (whole) number for me to use." #shift = gets.chomp.to_i def ceasar_cypher(message,shift) new_message = [] letters = message.split('') letters.each do |lett| num = lett.ord if num.between?(97...
true
cf215eff873f351020c7ae7926bf281708d74878
Ruby
clyeager/oop
/lesson_4/practice_problems_medium1/medium1_1.rb
UTF-8
405
3.578125
4
[]
no_license
class BankAccount attr_reader :balance def initialize(starting_balance) @balance = starting_balance end def positive_balance? balance >= 0 end end #Alyssa thinks Ben is missing the @ on the balance instance variable in the body # of the positive_balance? method. Who is right? #Ben is correct becau...
true
fc560259ffa5cc1c0507fc9961bb0662ad567862
Ruby
night1ightning/ruby_course
/listen1/calculate_ideal_weith.rb
UTF-8
576
3.5625
4
[]
no_license
require 'io/console' def ideal_weight(growth) growth - 110 end puts "Программа подсчета"\ " идеального веса попросит вас ввести имя и рост.\n"\ "Введите Enter, чтобы начать.\n" STDIN.getch print ' Ваше имя : ' name = gets.chomp print ' Ваш рост : ' growth = gets.to_i puts '' weight = ideal_weight(growth) if...
true
3f2b175019fd9bd39cdc5e927e22eec376a711a7
Ruby
mrcc87/arduino_ruby
/blink_led_menu.rb
UTF-8
945
2.640625
3
[]
no_license
require 'artoo' # Circuit and schematic here: http://arduino.cc/en/Tutorial/Blink # connection :arduino, :adaptor => :firmata, :port => '/dev/cu.usbmodemfa131' #linux #connection :firmata, :adaptor => :firmata, :port => '127.0.0.1:8023' device :board, :driver => :device_info device :led, :driver => :led, :pin => 13 wo...
true
2fabc60f0b72257f60d8326dded264376deaaf8e
Ruby
NativeScript/webkit
/Tools/iExploder/iexploder-1.7.2/tools/osx_last_crash.rb
UTF-8
1,664
2.515625
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby # Copyright 2010 Thomas Stromberg - All Rights Reserved. # # 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 req...
true
5c446483b9ed472c1265ac985de7c38b2c2dfa8b
Ruby
zbb272/OO-mini-project-dc-web-career-021819
/app/models/Allergen.rb
UTF-8
204
2.875
3
[]
no_license
class Allergen attr_accessor :ingredient, :user @@all = [] def initialize (ingredient, user) @ingredient, @user = ingredient, user @@all << self end def self.all @@all end end
true
7b5b137f4e9096d0d39538c061b3df21afdbb91e
Ruby
eashman/verisign_vip
/lib/verisign_vip.rb
UTF-8
13,818
2.625
3
[ "MIT" ]
permissive
require 'rubygems' require 'savon' require 'uuidtools' require 'hpricot' require 'yaml' class VerisignVIP class << self # Use the ActivateToken API to activate new or # inactive credentials. If the activation is # successful, the credential is Enabled and # ready for use. def activate_toke...
true
ab2259f14b76c0cb28200a0e4bccc6db2ecf70f0
Ruby
wjb108/intro-programming-with-ruby
/ruby_exercises_prep_folder/loops1/loopception.rb
UTF-8
1,528
4.375
4
[]
no_license
=begin The code below is an example of a nested loop. Both loops currently loop infinitely. Modify the code so each loop stops after the first iteration. =end =begin My Answer: added break in lines 17 and 19, 17 more obvious and 19 less obvious had i put a break in line 15 it wouldn't have executed the rest of the com...
true
af4d597aded40bc598ccf113cf367c3ecf0672db
Ruby
elikohen/EKServicesGenerator
/model/service.rb
UTF-8
662
2.640625
3
[]
no_license
class Service attr_accessor :messages @messages def hasPost messages.each do |message| if message.isPost || message.isPostJSON return true end end return false end def hasGet messages.each do |message| if message.isGet return true end end re...
true
1d6cbe7e096b6c18687c8588edc8aca53e400296
Ruby
apiology/punchlist
/lib/punchlist/renderer.rb
UTF-8
362
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Punchlist # Render a text format of offenses class CliRenderer def render(output) lines = output.map do |offense| "#{offense.filename}:#{offense.line_num}: #{offense.line}" end out = lines.join("\n") if out.empty? out else ...
true
7c6e0314820e96530520cbadc0518bc778d5d880
Ruby
apfeltee/shellstuff
/programs/curse.rb
UTF-8
849
2.890625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
#!/usr/bin/env ruby require "pp" require "optparse" require "shellwords" INITIAL_CURSEWORDS = %w(fuck shit crap damn bastard idiot) class CurseWords def initialize @cursewords = INITIAL_CURSEWORDS @opts = %w(-A3 -inP --color=always) @realargs = [] @prs = OptionParser.new{|prs| prs.on("-w <s>"...
true
03462769916f4a8fb1ea8e4b1d4516f671448b4f
Ruby
hidetsubo/.emacs.d
/src/rurima/db-1_9_3/method/-rake-file-utils/i.verbose.rake
UTF-8
532
3.171875
3
[]
no_license
kind=defined visibility=public names=verbose --- verbose(value = nil){ ... } 詳細を出力するかどうかを制御します。 @param value 真を指定すると詳細を出力します。 例 verbose # 現在の状態を返します。 verbose(v) # 与えられた状態に変更します。 verbose(v) { code } # ブロックを評価する間だけ与えられた状態に変更します。 # ブロックの評価が終わると元の値に戻します。
true
3304cb5f7b09f8f49f82360d9d0462f660feae41
Ruby
srividhyashanker/cs61aPrepCourse
/Chapter14/programLogger.rb
UTF-8
327
3.046875
3
[]
no_license
def log descriptionOfBlock, &block puts 'Beginning "' + descriptionOfBlock + '"...' doBlock = block.call puts '..."' + descriptionOfBlock + '" finished, returning: ' + doBlock.to_s end log 'outer block' do log 'some little block' do 2 + 2 +1 end log 'yet another block' do puts 'I like Thai food!' end 5 == ...
true
4f9b374daa85f208b164290f7bfc4f7aefa30feb
Ruby
dariota/swagger-demo
/client/echo_client.rb
UTF-8
487
2.515625
3
[]
no_license
require 'swagger_client' require 'echo_api_remote' api_client = SwaggerClient::EchoServerApi.new remote_client = EchoApiRemote::EchoServerApi.new data, status_code, headers = api_client.what_did_i_say_with_http_info(ARGV[0]) puts "Local:" puts "\tI said: \"#{data.client_said}\"" puts "\tStatus: #{status_code}" data...
true
095115567e721b8dcaab1fc46e1da552e5eadf96
Ruby
kareemgrant/warmup-exercises
/15-say-1/say.rb
UTF-8
1,035
4.09375
4
[]
no_license
class Say def initialize(number) left = number tens = left/10 num_string = '' case tens when 9 num_string += "ninety" when 8 num_string += "eighty" when 7 num_string += "seventy" when 6 num_string += "sixty" when 5 num_string += "fifty" when 4 ...
true
f34446e58267a842e004899b41169fc0c39671a1
Ruby
yunglleung1/OO-Art-Gallery-nyc-web-071618
/app/models/painting.rb
UTF-8
423
3.375
3
[]
no_license
class Painting attr_reader :title, :style @@all = [] def initialize(title, style) @title = title @style = style @@all << self end def self.all# Get a list of all paintings @@all end def self.get_painting_styles# Get a list of all painting styles style = all.map do |painting| ...
true
15a902cddff6a8c141473f05f41f44cc660b58bf
Ruby
Brendamcr2/Game
/Game.rb
UTF-8
1,141
3.546875
4
[]
no_license
Nice Job Girl!! xoxo Rhece! control_var = "" until control_var == "exit" puts "Welcome to Trivia!" puts "Today you will be tested on how well you know movies!" puts "Good luck! Write begin when ready to start Trivia!" welcome = gets.chomp case welcome when "begin" puts "_____________________________________________...
true
53d1b50a8ba6ccb35037647581e4cd2f37bc0233
Ruby
orimolad/aa_classwork
/w4d1/skeleton/lib/00_tree_node.rb
UTF-8
1,368
3.5
4
[]
no_license
require "byebug" class PolyTreeNode attr_reader :value, :parent, :children def initialize(value) @value = value @parent = nil @children = [] end def parent=(node) # node = nil or any node instance if node == nil @parent.children.delete(self) @parent = nil elsif ...
true
795342a91df740e7c6886ad9b0a96f4c8bcf23e0
Ruby
epogue/wowwer
/lib/wowwer/race.rb
UTF-8
429
2.765625
3
[ "MIT" ]
permissive
module Wowwer class Race < Wowwer::Base class << self def all(options={}) @races ||= get("data/character/races", options)['races'].map do |race| new race end end def find(id, options={}) all(options).detect{|r| r.id == id } end def find_by_name(nam...
true
35754bcce9af969ef06169d766d4a931dba20335
Ruby
huminya/homework
/lrthw/ex19.rb
UTF-8
890
4.3125
4
[]
no_license
def cheese_and_crackers(cheese_count, boxes_of_crackers) puts "You have #{cheese_count} cheeses!" puts "You have #{boxes_of_crackers} boxes of crackers!" puts "Man that's enough for a party!" puts "Get a blanket." puts # a blank line end # directly use numbers puts "We can just give the function numbers ...
true
e8b006b01cb28d0767faa64374554585df172b56
Ruby
Gutylla/ctci-ruby
/kpalindrome.rb
UTF-8
498
3.28125
3
[]
no_license
def kpalindrome(s, k) isKPalDP(s, s.reverse) <= 2*k end def isKPalDP(str1, str2) n = str1.length dp = Array.new(n+1) { Array.new(n+1) } (n+1).times do |i| (n+1).times do |j| if i == 0 dp[i][j] = j elsif j == 0 dp[i][j] = i elsif str1[i - 1] == str2[j - 1] d...
true
c609e67d52df0748f5c9af2f162b1ba31236def5
Ruby
Jonesyd/launchschool_exercises
/small_problems/42_e5_after_midnight_p1.rb
UTF-8
573
3.6875
4
[]
no_license
def plus_24(num) if num < 0 num += 24 plus_24(num) else num end end def time_of_day(integer) hours, mins = integer.divmod(60) days, hours = hours.divmod(24) if hours >= 24 hours = plus_24(hours) if integer < 0 array = [mins, hours] hour = array.fetch(1) { 0 } array = [mins, hour] for...
true
f970fee87bded457ddcc437a84498621a8d5e713
Ruby
eleetyson/practice
/majority-element-rb/majority_element.rb
UTF-8
452
3.625
4
[]
no_license
# given an array of numbers, return the majority element # the majority element is a value that makes up more than half of the array's elements # assume that the given array will always have a majority element # also assume that the array length is always at least one element def find_majority_element(nums) counts = ...
true
8043c1835a61734991f048462f5d454574088c1d
Ruby
paratiger/Whisky-list
/test/shoulda/custom_matchers/be_valid_with_factory_matcher.rb
UTF-8
785
2.671875
3
[]
no_license
module Shoulda module CustomMatchers def be_valid_with_factory BeValidWithFactoryMatcher.new( self.name.gsub(/Test$/, '').underscore.to_sym ) end class BeValidWithFactoryMatcher def initialize(class_name) @class_name = class_name end def matches?(subject) ...
true
59726d33713c82191742262cecf00c837575f6d6
Ruby
tienan/textlab
/plot_2.rb
UTF-8
3,209
2.65625
3
[]
no_license
require 'tk' class TkEvent::Event attr_accessor :x_nonzoom, :y_nonzoom end class TkScrolledCanvas < TkCanvas include TkComposite attr_reader :zoom def initialize_composite(keys={}) @zoom = 1.0 @h_scr = TkScrollbar.new(@frame) @v_scr = TkScrollbar.new(@frame) @canvas = TkCanvas.new(@frame) ...
true
8c3c9a75b62da0c4f24114526156e12c55250876
Ruby
raza23/pfwtfp-practice-with-array-integers-lab-atl-web-042219-gap
/lib/array_practice.rb
UTF-8
1,302
3.953125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
array_of_integers = *0...50 def all_odds(array) array.find_all{|x| x%2 == 1} # return all odd numbers from the input array end def all_evens(array) array.find_all{|x| x%2 == 0} # return all even numbers from the input array end def all_squares(array) array.map{|x| x ** 2} # return the square of all numbe...
true
af630361a88394b5bf6df174bc55c81696906cfc
Ruby
pbcoronel/project_euler
/ruby/problem_007.rb
UTF-8
101
2.875
3
[]
no_license
require "prime" def getprime(n) array = Prime.first n array.last end p getprime(10001)
true
9f26729cf222831122f3a5e1c8c5a67e300d6344
Ruby
lukesiem/joggle-rails
/spec/product_spec.rb
UTF-8
1,139
2.609375
3
[]
no_license
require 'rails_helper' RSpec.describe Product, type: :model do describe 'Validations' do before(:each) do @category = Category.new(name: 'Fruit') end it "is valid if it has all attributes" do @product = Product.new(name: 'Watermelon', price: 200, quantity: 30, category: @category) e...
true
b4570acdfde36df8108c8aabaad9e445fdbad678
Ruby
bonitour/API-3.0-Ruby
/lib/cielo/api30/external_authentication.rb
UTF-8
1,740
2.625
3
[ "MIT" ]
permissive
module Cielo module API30 # Credit card data # # @attr [String] card_number Credit card number # @attr [String] holder Holder name # @attr [String] expiration_date Credit card expiration date # @attr [String] security_code Credit card security code # @attr [Boolean] save_card Whether or no...
true
98dfecc9c01bea9bf2b6a496dd5d82c78b1fdba3
Ruby
valeriecs10/chess
/pieces/stepable.rb
UTF-8
501
2.828125
3
[]
no_license
module Stepable def moves move_diffs.each_with_object([]) do |diff, arr| current_pos = [@pos[0] + diff[0], @pos[1] + diff[1]] next unless @board.valid_pos?(current_pos) if @board[current_pos].is_a?(NullPiece) || @board[current_pos].color != self.color a...
true
57395f628ef9e04f596819d8431bee56bb74608e
Ruby
tkosuga/tiikitter.jp
/app/lib/google_map/geo_coder.rb
UTF-8
1,605
3.34375
3
[]
no_license
# # これの 移植。 # http://wiki.forum.nokia.com/index.php/Google_Maps_API_in_Java_ME%EF%BC%88%E6%97%A5%E6%9C%AC%E8%AA%9E%EF%BC%89 # class GoogleMap::GeoCoder include Math OFFSET = 2 ** 28 RADIUS = OFFSET / Math::PI # # 経度を指定したピクセルで移動します # def move_lng_by_pixel(x, delta, zoom) (((lng_...
true
e354fd70406460169232547ce1e8db58e48496b3
Ruby
kzkn/sakuramarket
/app/models/purchase.rb
UTF-8
2,239
2.78125
3
[]
no_license
class Purchase < ApplicationRecord TAX_RATE = 0.08 SHIP_TIME_CANDIDATES = %w(8-12 12-14 14-16 16-18 18-20 20-21) belongs_to :order, touch: true validates :order, presence: true, uniqueness: true validates :tax_rate, numericality: true validates :cod_cost, numericality: true validates :ship_cost, numeric...
true
e8a8b76a8c5cdef72c4711269ab522e9cc7a4ffe
Ruby
JC-LL/gtk3_ruminations
/methodo_1/5_force_directed_graph_drawing/window.rb
UTF-8
3,691
2.703125
3
[]
no_license
require 'gtk3' class Canvas < Gtk::DrawingArea def initialize super() set_size_request(800,100) signal_connect('draw') do on_expose end end def on_expose cr = window.create_cairo_context cr.set_line_width(0.5) w = allocation.width h = allocation.height cr.translate(...
true
f9e33ab7fe76f11e9ca99617ffb09d188fcc3577
Ruby
VanQuishi/hangman-game
/lib/hangman.rb
UTF-8
6,427
3.484375
3
[]
no_license
require "csv" class Hangman attr_accessor :player_name attr_reader :misses, :corrects, :stage, :id attr_reader :key_word #for the sake of debugging. Take this out when finished public def initialize(player_name,misses=[],corrects=[],stage=0,key_word = find_key_word("5desk.txt"),id = -1) ...
true
98c57d43016c1e2bae5b2283e7ed9d18ecd7fbe0
Ruby
KOCage/Vinehalla
/db/seeds.rb
UTF-8
5,757
2.96875
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 bin/rails db:seed command (or created alongside the database with db:setup). # # File structure necessary for seed script to work: # File structure expected to be VINEHALLA_PAT...
true
0b3aeaf595741b31b4be761d8bca4dcfcd13ecbc
Ruby
rmagick/rmagick
/spec/rmagick/image/displace_spec.rb
UTF-8
2,200
2.703125
3
[ "MIT" ]
permissive
RSpec.describe Magick::Image, '#displace' do it 'works' do image = described_class.new(20, 20) image2 = described_class.new(20, 20) { |options| options.background_color = 'black' } expect { image.displace(image2, 25) }.not_to raise_error result = image.displace(image2, 25) expect(result).to be_in...
true
ed9c5612f307b5f5871fe205335ed15534e7fcc3
Ruby
xdanielsb/Ruby_Workshop
/palindrome.rb
UTF-8
342
4
4
[]
no_license
=begin Daniel Santos Super easy program to say if a set of words are palindromes =end def is_palindrome(*args) args.each do |word| if word != word.reverse puts word return FALSE end end return true end result = is_palindrome("lol", "mariiram", "jjjeeejjj") unless result puts "...
true
9688a33848b2064e5fbc7ca5cc70037379d78862
Ruby
LyleF27/Lauch-school-intro-to-programming-ruby
/chapter_8_hashes/exercise_2.rb
UTF-8
421
3.96875
4
[]
no_license
# Look at Ruby's merge method. Notice that it has two versions. What is the difference between merge and merge!? Write a program that uses both and illustrate the differences. # the difference is that the merge without the ! doesnt mutate the caller and the merge! with the ! does hash1 = { cats: ["Simba", "Nala"] }...
true
bed2ffc7756e133ad6e4ab7c79ad8b45b01e72cd
Ruby
elailai94/Watts
/source-code/screens/geometry-screens/triangle_area_screen.rb
UTF-8
2,738
2.6875
3
[ "MIT" ]
permissive
#============================================================================== # Watts # # @description: Module for providing functions to work with TriangleAreaScreen # objects # @author: Elisha Lai # @version: 0.0.1 15/06/2015 #============================================================================== # Trian...
true
d70b7bfc1101d667ca3c3cad16fba22172c68847
Ruby
stringham/contests
/2012-mebipenny/finals/server/territory/move.rb
UTF-8
170
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Territory class Move PASS = 'PASS' attr_reader :tile, :favor def initialize(tile, favor) @tile = tile @favor = favor end end end
true
b6d4df301da1b9c03441018f2fd843fcdd139cbb
Ruby
CelesteComet/Launch-School
/challenges/Clock/clock.rb
UTF-8
730
3.578125
4
[]
no_license
class Clock def initialize(minutes) @total_minutes = minutes % 1440 @hours = @total_minutes / 60 @minutes = @total_minutes % 60 end def self.at(hours, minutes = 0) Clock.new(hours * 60 + minutes) end def +(minutes) Clock.new(@total_minutes += minutes) end def -(minutes) Clock.n...
true
f73c1e897962e7b6c03ec306bc160339191e7355
Ruby
kazuhiroinaba/clear_sky
/sky.rb
UTF-8
3,090
3.75
4
[ "MIT" ]
permissive
require 'rubygems' require 'rmagick' =begin blue = light rain /snow green = light thunderstorms/moderate rain shower yellow = moderate thunderstorms, rainshower magenta to read = severe thunderstorm / flooding rain =end =begin HSL color value: 360 : red 300 : purple 240 : blue 120 : green 60 : yellow 0 : red =end...
true
5a4d1929784edad206da45bb564748e1486f563e
Ruby
sjwats/payroll
/app/models/commission.rb
UTF-8
1,641
3.6875
4
[]
no_license
#require_relative 'sales' class Commission < Employee #the initialize method is inherited from Employee which along with attr_reader #allows us to instantiate each new Commission employee with the same #instance variables used in Employee (@last_name etc) here to call the Commission #employees attributes (@last...
true
8520385b4e839e79012051e3e7fbd662ceec0942
Ruby
uk-gov-mirror/ONSdigital.ons_data_models
/test/models/observation_test.rb
UTF-8
2,506
2.625
3
[ "MIT" ]
permissive
require "test_helper" require "models/observation" class ObservationTest < ActiveSupport::TestCase context "with an observation" do should "have required fields" do observation = FactoryGirl.build(:empty_observation) assert observation.valid? == false assert observation.errors[:slug].empty? == ...
true
1fb382eb3dfb215640e56923ce388d62c7d2a630
Ruby
jonathanhester/projecteuler
/prob_9.rb
UTF-8
124
3.078125
3
[]
no_license
(1..1000).each do |i| (1..1000).each do |j| x = 1000 - i - j puts x * i * j if x * x == (i * i + j * j) end end
true
04bd455df479e69382ce1bbfcc2c24ec2395b68d
Ruby
YDOCHOUSE/learn_ruby
/07_book_titles/book.rb
UTF-8
472
3.703125
4
[]
no_license
class Book attr_writer :title def initialize(title='') @title = title end def title titleize(@title) end def titleize(string) book_title = string.split(' ') no_cap = ['the','a', 'an', 'at', 'by', 'for', 'in', 'of', 'on', 'to', 'up', 'and', 'as', 'but', 'it', 'or'] book_title.each do |...
true
756ff2d7ff606a37982f12078cc5366286d881dc
Ruby
aarti/data-structures-ruby
/code/bplustree/bplustree_test.rb
UTF-8
505
2.65625
3
[ "MIT" ]
permissive
require 'minitest/autorun' require_relative 'bplustree' class BplustreeTest < MiniTest::Unit::TestCase def test_initialize_btree branching_factor = 3 first = {"1"=> "one"} second ={"2"=> "My Second Data"} b = Bplustree.new(branching_factor, first, second ) assert_equal false, b.root.is_leaf ...
true
92b06e0042c538d2ab17ee4258f8c1e1f01c1d5e
Ruby
mayra-cabrera/sudoku-validator
/lib/subgrid.rb
UTF-8
423
3.21875
3
[]
no_license
class Subgrid GRIDS = [0, 1, 2] X1 = [0, 1, 2] X2 = [3, 4, 5] X3 = [6, 7, 8] POSITIONS = [X1, X2, X3] attr_reader :values def initialize data self.values = data end def values=(data) @values = [] GRIDS.each do |grid| POSITIONS.each do |position| subgrid = [] positio...
true
07ee907520c0b1d7338192df5d4007f0ae7ec30b
Ruby
stuartc/marsbot
/spec/lib/marsbot/tracker_spec.rb
UTF-8
1,591
2.71875
3
[]
no_license
# frozen_string_literal: true require 'spec_helper' describe Marsbot::Tracker do let(:plane) { Marsbot::Plane.new(x: 5, y: 3) } let(:tracker) { described_class.new(plane: plane) } describe '#out_of_bounds' do before do tracker << robot end subject { tracker.out_of_bounds } context 'whe...
true
4b91400b79beca9a83c5b90bfee01f86f370b6d9
Ruby
benmerkel/homework_assignments
/methods_and_flow_control/fizz_buzz.rb
UTF-8
430
3.53125
4
[]
no_license
#!/usr/bin/env ruby # While doing some research on loops, I saw the 'for' # loop and decided to go with this. It seems pretty clean # in that I don't have to declare 'counter' separately # from the 'for' loop. for counter in (1..100) if (counter % 3).zero? && (counter % 5).zero? puts 'FizzBuzz' elsif (count...
true
89bd58dfa32807c043813dcc3e31f88ac92b1a16
Ruby
amandeep1420/RB101
/RB101/Small Problems/E9/8_sequence.rb
UTF-8
538
3.890625
4
[]
no_license
# def sequence(count, num) # result_arr = [] # for i in (1..count) # result_arr << num * i # end # result_arr # end # note: ranges have access to #Enumerable methods; don't need to convert to array beforehand # see below: (1..5).map { |num| num } => [1, 2, 3, 4, 5] # so.... def sequence(count, num) (1...
true
5b3784f7db491575dc074ceea08ad9473b55a676
Ruby
rodrigomanhaes/rasper_client
/lib/rasper_client/client.rb
UTF-8
3,064
2.671875
3
[ "MIT" ]
permissive
require 'net/http' require 'base64' require 'json' module RasperClient class Client def initialize(host:, port: nil, timeout: nil, path_prefix: nil, secure: true, empty_nil_values: false, username: nil, password: nil) @host = host @port = port @timeout = ti...
true
8a7fae0722fe563762e7ea3c83b6201611077a1b
Ruby
zooniverse-glacier/lita-zooniverse
/lib/lita/api/ouroboros_project.rb
UTF-8
1,532
2.59375
3
[]
no_license
require_relative 'project' module Lita module Api class OuroborosProject include Api::Project def self.api_headers { "Content-Type" => "application/json", "Accept" => "application/json" } end def self.projects_search(project_names) project_na...
true
fd9d452578c8cb21218e8864e4c4d6657e282b0a
Ruby
edhowland/viper
/lib/bufnode/peek.rb
UTF-8
329
2.828125
3
[ "MIT" ]
permissive
# peek - class Peek - command peek - returns char of LineNode/right class Peek < BaseNodeCommand def call(*args, env:, frames:) a = args_parse! args if @options[:r] perform(a[0], env: env, frames: frames) { |node| node[-1] } else perform(a[0], env: env, frames: frames, &:first) end ...
true
23b0def09c4cbec30cc0c69d5abc00ec13540287
Ruby
y-kazuya/Rest_App
/app/models/owner.rb
UTF-8
1,870
2.71875
3
[]
no_license
class Owner < ApplicationRecord attr_accessor :remember_token before_save { email.downcase! } ###################validates############################################################ validates :name, presence: true, length: { maximum: 50 }, uniqueness: true VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\...
true
8e73146c374ef0d3106b88f62a07c13b10374b23
Ruby
ajesler/advent-of-code
/2020/ruby/day01/solution.rb
UTF-8
2,037
2.8125
3
[]
no_license
# frozen_string_literal: true # Run the solver with the input after __END__ # $ ruby solver.rb # # Run the solver using a file as input # $ ruby solver.rb test_input.txt # # Run solver specs with # $ ruby solver.rb --specs class Solver def initialize(numbers, components: 2) @numbers = numbers @components = ...
true
f3eb347029bd260d85a4cc757d8b60758bd5e2b3
Ruby
alexanderwjrussell/CodeWars
/ConvertToUnicode.rb
UTF-8
155
3.375
3
[]
no_license
def uni_total(string) array = string.chars.to_a total = 0 array.each do |n| total = total + n.ord end puts total end uni_total("Alexander")
true
6e61fecf3abcb12bf9f8cb751132daa9b2c71885
Ruby
YuukiMAEDA/AtCoder
/Ruby/ABC/C/GeT_AC.rb
UTF-8
243
2.625
3
[]
no_license
n,q=gets.split.map(&:to_i) s=gets.chomp lrs=q.times.map{gets.split.map(&:to_i)} sum=[0]*(n+1) (n-1).times do |i| sum[i+1]+=1 if s[i]=="A" && s[i+1]=="C" end n.times{|i| sum[i+1]+=sum[i]} lrs.each do |lr| puts sum[lr[1]-1]-sum[lr[0]-1] end
true
9d4a8859fc4821fae185f2473d6223df55e6c2bc
Ruby
ralake/Battleships
/lib/player.rb
UTF-8
140
2.8125
3
[]
no_license
class Player attr_accessor :board def board @board end def receive_shot(coordinates) @board.shoot(coordinates) end end
true
ab6aa8385c92b3dede9f5e42c4792e8b7b1a5f7d
Ruby
jwStriker/aAclasswork
/Chess Final/piece.rb
UTF-8
1,907
3.546875
4
[]
no_license
require_relative 'slideable.rb' require_relative 'stepable.rb' class Piece attr_reader :value, :color, :board attr_accessor :position def initialize(color, board, position) #@value = :* @color = color @board = board @position = position end end class Pawn < Piece def initialize(color, board...
true