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
71672f91568110e8bdc9a8e7e00857857c4759ff
Ruby
lehongson12/import_data
/lib/import_data/helpers/argument_validation_helper.rb
UTF-8
954
3
3
[]
no_license
module ArgumentValidationHelper def class_name_valid? class_name if class_name.blank? puts "class_name is required!" return false end model = Kernel.const_get(class_name) rescue nil if model.nil? puts "#{class_name} is not existed." return false end unless model.new....
true
42a948d9df4f08c8e0320856844f1546685422b0
Ruby
StupendousOne/ruby-project-guidelines-atlanta-web-033020
/lib/Models/Delete.rb
UTF-8
867
2.75
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Delete def delete_menu(current_user, prompt) stay_in_menu = true while stay_in_menu do case prompt.select("What would you like to do?",["Select a Review to Delete", "Back"]) when "Select a Review to Delete" delete_review(current_user,prompt) ...
true
318d557d725a67116de46efa32248b9a4cbbdd74
Ruby
meedan/check-api
/app/models/claim.rb
UTF-8
336
2.53125
3
[ "MIT" ]
permissive
class Claim < Media attr_accessor :quote_attributions before_validation :remove_null_bytes validates :quote, presence: true, on: :create def text self.quote end def media_type 'quote' end private def remove_null_bytes self.quote = self.quote.gsub("\u0000", "\\u0000") unless self.quote...
true
0d4e2a8749a1e9dc2749587ee23f17c4ac327156
Ruby
dreamrukia/COMP2150A4
/LZW_latest_version/KeyValueHash.rb
UTF-8
492
2.828125
3
[]
no_license
script_dir = File.dirname(__FILE__) $LOAD_PATH.unshift script_dir require 'Hashable' require 'StringHash' require 'IntHash' class KeyValueHash attr_reader :hashvalue attr_accessor :value def initialize(key, value) @hashvalue = key.hashvalue @key = key @value = value end def =...
true
89af33a03bdd4ad4b2e3652886cece2233a0673c
Ruby
jpatel531/reimplementing-ruby-inject-method
/spec/inject_spec.rb
UTF-8
839
3.3125
3
[]
no_license
require 'inject' describe "my inject" do let(:array) {[1,2,3,4]} it "can sum numbers" do sum = lambda {|sum, n| sum + n} true_inject = [1,2,3,4].inject(:+) expect(array.my_inject(&sum)).to eq true_inject end it "can minus numbers" do dimin = lambda {|acc, n| acc - n} true_inject = array.inject(:-) ...
true
e326b66b63c09e51670c9e22a5eba3d198987bce
Ruby
samjaninf/cb_nitride
/lib/cb_nitride/public_hasher.rb
UTF-8
2,324
2.78125
3
[ "MIT" ]
permissive
require 'mechanize' require 'mechanize_clip' require 'nokogiri' module CbNitride class PublicHasher include HasherMethods attr_reader :diamond_number, :agent, :container_class, :search_url, :image_class BASE_URL = "http://www.previewsworld.com" DIAMOND_NUMBER_SEARCH_PATH = "/Home/1/1/71/952?stockIte...
true
a78bf8f668ff6dbf4cec2079735cedc8cd1c5bf4
Ruby
BenBrostoff/euler_problems
/18_67_max_path/18_67.rb
UTF-8
1,026
3.59375
4
[]
no_license
def parse(file) array = [] file = File.new(file, "r") while (line = file.gets) array << line.split(" ").map {|x| x.to_i} end return array end def shorten_by_one(array) shortened = [] array.each_with_index do |num, index| shortened << [num, array[index + 1]].max if index < array.length - 1 end ...
true
a8738249a9306448d95db5f93f8393624c7cd367
Ruby
leovcunha/ruby-projects
/1.software-foundations/rspec_exercise_1/rspec_demo_solution/spec/add_spec.rb
UTF-8
266
2.921875
3
[]
no_license
require "add" describe "add method" do it "should accept two numbers as arguments" do expect { add(2, 3) }.to_not raise_error end it "should return the sum of the two numbers" do expect(add(2, 3)).to eq(5) expect(add(10, 12)).to eq(22) end end
true
36781a802f688011151b9f860b004a5a6ead4960
Ruby
laktek/Visual-Search
/map.rb
UTF-8
1,712
2.5625
3
[]
no_license
require "rubygems" require "eventmachine" require 'hornetseye' include Hornetseye require 'multiarray_ext' module Map def match_image(target_image, template_image) begin image = MultiArray.load_grey8( target_image ) template = MultiArray.load_grey8( template_image ) ncc = image.ncc( template ...
true
834408aed66cff3b3156e7c85ad82970c55902b0
Ruby
Resonious/solargraph
/lib/solargraph/pin/local_variable.rb
UTF-8
2,968
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Solargraph module Pin class LocalVariable < BaseVariable # @return [Range] attr_reader :presence def initialize assignment: nil, presence: nil, **splat super(**splat) @assignment = assignment @presence = presence end def...
true
5d0b23e06cfa7993f895359cde0966fd7f78994b
Ruby
jjyr/pb_actor
/lib/pb_actor/future.rb
UTF-8
375
2.59375
3
[ "MIT" ]
permissive
module PbActor class Future def initialize id, wr, rd @id = id @wr= wr @rd = rd end def value Message.send [:future_value_get, @id], @wr type, value = Message.recv @rd if type == :future_value value else raise "unknown message type: #{type.inspect...
true
20b84cf9b39adeea80413fa6dc66728d35caf05c
Ruby
ray0h/TOP_Ruby_Chess
/lib/modules/board_helpers.rb
UTF-8
879
3.46875
3
[]
no_license
# methods to help navigate boards/pieces module BoardHelpers # methods to help define general movement logic # translate [row][col] coords from 'A2' move def parse_coord(square) square = square.split('') row = square[1].to_i - 1 col = square[0].bytes[0] - 65 [row, col] end # translate 'A2' t...
true
9b9a845c402c8a5fd71fe31fd20029014e1844b6
Ruby
infertux/omniconf
/spec/omniconf/configuration_spec.rb
UTF-8
2,411
2.890625
3
[ "MIT" ]
permissive
require 'spec_helper' require 'omniconf/configuration' describe Omniconf::Configuration do let(:hash) do { 'key' => 'level0', 'nested0' => { 'key' => 'level1', 'nested1' => { 'key' => 'level2', 'nested2' => { 'answer' => 42 } } }...
true
a1b75ef48aaf1e2980411c8e9f1e4d5517bd1211
Ruby
gengogo5/atcoder
/ABC/abc038/ABC038_B.rb
UTF-8
137
2.765625
3
[]
no_license
H,W = 2.times.map { gets.split.map(&:to_i) }.transpose puts H[0] == H[1] || H[0] == W[1] || H[1] == W[0] || W[0] == W[1] ? 'YES' : 'NO'
true
e743a797946525d48ef3772dd768cc286cc3e41d
Ruby
wiltonlazary/jules
/lib/jules/element_container.rb
UTF-8
1,315
2.5625
3
[ "MIT" ]
permissive
module Jules module ElementContainer def element(element_name, selector) class_eval %{ def #{element_name} @#{element_name} ||= Jules::Element.new("#{selector}") end } end def elements(collection_name, selector) define_method collection_name.to_s do res...
true
1195be402646f728326ef9fa5f98ac912d5ec606
Ruby
stevemr77/dog_treats_ruby_classes_practice
/environment.rb
UTF-8
326
2.640625
3
[]
no_license
require 'pry' require_relative './dog' require_relative './treat' fluffy = Dog.new 'Fluffy', 3 floofy = Dog.new 'Floofy', 4 lima = Dog.new 'Lima', 5 prancer = Dog.new 'Prancer', 6 sunshine = Dog.new 'Sunshine', 7 bixby = Dog.new 'Bixby', 8 spot = Dog.new 'Spot', 9 # make 3 treats that belong to different dogs bindi...
true
0639c6974969f903424ce53cdb2b03498eb57b23
Ruby
AiErik/homework
/hw3_employees/employee.rb
UTF-8
528
3.5
4
[]
no_license
class Employee def initialize(name:, email:, phone:, salary:) @name = name @email = email @phone = phone @salary = salary @review = '' @expectations = nil end def name @name end def email @email end def phone @phone end def salary @salary end def review...
true
8de457d36b829fe95033ad153cbf056acf9962eb
Ruby
lorawoodford/manifester
/processor/bin/site.rb
UTF-8
2,412
2.765625
3
[]
no_license
#!/usr/bin/env ruby require 'bcrypt' require 'optparse' require_relative '../config/db' options = {} required_add = %w[site manifest name contact email timezone] required_del = %w[site] optparse = OptionParser.new do |opts| opts.banner = 'Usage: site.rb [options]' opts.on('-a', '--[no-]ad...
true
e1f4c9041e4fdb25f4610455118345cf1ef174cf
Ruby
neontapir/managertools-logging
/lib/team.rb
UTF-8
1,219
3.15625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'attr_extras' require_relative 'employee' require_relative 'employee_folder' require_relative 'path_string_extensions' require_relative 'team_finder' # Represents a delivery team # @!attribute [r] team # @return [String] the path name of the team class Team attr_value :team...
true
4c3e3f732ded481d50979c0eec0f0d943e4606a0
Ruby
eainathh/dado
/dado.rb
UTF-8
296
3.109375
3
[]
no_license
class Dado def rolar @numeroMostrado = 1 + rand(6) @numeroMostrado end def mostrado @numeroMostrado end end dado1 = Dado.new dado2 = Dado.new puts dado1.rolar puts dado2.rolar puts dado1.mostrado puts dado1.mostrado puts dado2.mostrado dado1.rolar puts dado1.mostrado
true
f11beae3d8dd981bf0a10320f963f7f6f39c3f40
Ruby
MatthieuCroset/rubyv1
/exo_08.rb
UTF-8
91
3.03125
3
[]
no_license
puts "un nombre stp :" print "> " nb = gets.chomp.to_i until nb<0 puts nb nb -= 1 end
true
53de2970e6b15c62e80da83c69a7a038a6454cf6
Ruby
vjoel/redshift
/examples/queue.rb
UTF-8
1,054
3.234375
3
[ "Ruby" ]
permissive
# Example of some basic features of queues. Uses strings as messages # just to make the matching examples simple. See also queue2.rb. require 'redshift' include RedShift class Receiver < Component queue :q transition do wait :q => /time is now 2/ action do msg = q.pop puts "SPECIAL CASE! p...
true
11950006147e95c78b888844ff4c1728c95ba6c4
Ruby
tenderlove/concurrent-ruby
/lib/concurrent/channel/waitable_list.rb
UTF-8
647
3.1875
3
[ "Ruby", "MIT" ]
permissive
require 'concurrent/atomic/condition' module Concurrent class WaitableList def initialize @mutex = Mutex.new @condition = Condition.new @list = [] end def size @mutex.synchronize { @list.size } end def empty? @mutex.synchronize { @list.empty? } end def p...
true
e4a5eaacc0e890c3864527e60275dc1c36debacb
Ruby
ludwiggj/ruby-pickaxe
/ch04-containers-blocks-iterators/blocks/block_as_object.rb
UTF-8
678
4.40625
4
[]
no_license
def create_block_object(&block) block end bo = create_block_object { |param| puts "You called me with #{param}" } bo.call 99 # => You called me with 99 bo.call "cat" # => You called me with cat # This is so useful that Ruby provides two built-in methods that convert a block to an object. # Both lambda and Proc....
true
48c51737d08c169cb11298f3139c47ff670717c6
Ruby
Cmajewski/travel-tips-sinatra-project
/app/controllers/helpers.rb
UTF-8
651
2.625
3
[]
no_license
require_all 'app' class Helpers def self.current_user(session) User.find(session[:user_id]) end def self.logged_in?(session) !!session[:user_id] end def self.destination_exist?(city_name) @name=city_name.downcase !!Destination.find_by(city_name: @name) end def ...
true
ccb79df01bc1640065c8725b500fcdb1ee6c2d0a
Ruby
bagilevi/strategy_bag
/lib/strategy_bag.rb
UTF-8
2,971
2.890625
3
[ "MIT" ]
permissive
class StrategyBag def initialize(*args) interface, *param_values = args if param_values.size != self.class.param_names.size raise ArgumentError, "expected params: interface, #{self.class.param_names.map(&:to_s).join(', ')}, but only #{args.size} params given" end @evaluator = Evaluator.new ...
true
4c90f1ec6c2195e1a23d82141e1e7661add7c516
Ruby
NickyH/wdi3-rails
/r2013-03-28-binary-tree/main.rb
UTF-8
1,553
3.453125
3
[]
no_license
require 'pry' require 'pry-debugger' require 'pry-stack_explorer' class Node attr_accessor :d, :p, :n def initialize(data) self.d = data self.p = self.n = nil end def to_s nxt = self.n.nil? ? 'empty' : self.n.d prv = self.p.nil? ? 'empty' : self.p.d "#{prv} <- #{self.d} -> #{nxt}" end e...
true
e31f6cee231d7d1625e1c9792f095c08ccb89a99
Ruby
annaship/taxa
/resolver_api_res.rb
UTF-8
9,152
2.65625
3
[]
no_license
#!/usr/bin/env ruby require "rubygems" require "json" require "dbi" require 'rest-client' require 'uri' require 'open-uri' # gem install dbd-mysql def use_args() if ARGV[0].nil? print "Please provide an input file name in json format\n" exit end file_in_name = ARGV[0] file_out_name = ARGV[1] ||= fi...
true
707f5273c9a9c882b3e3400d0167be714c6d1ded
Ruby
arosini/rails-starter-app
/features/step_definitions/general/form_steps.rb
UTF-8
1,685
2.546875
3
[]
no_license
# Put shared steps for interacting with forms and their components here. # GIVEN Given(/^I have entered "(.*?)" in the "(.*?)" field$/) do |value, field| fill_in field, with: value end Given(/^I have filled out the "(.*?)" form with the following values:$/) do |form, table| within(:css, 'form#' + form.downcase.tr...
true
587dece66c3609feea4d1c4f21c5a81e45140c1e
Ruby
critsmet/key-for-min-value-prework
/key_for_min.rb
UTF-8
220
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def key_for_min_value(name_hash) k = "" v = 1000 name_hash.each do |key, value| if value < v v = value k = key end next if value > v end if name_hash.empty? == true return nil end return k end
true
d8f33360a92417455d95df4642644198033260d7
Ruby
LucasBallestrino/moove-it-coding-challenge-LucasBallestrino
/lib/RubyMemcachedClient.rb
UTF-8
6,336
2.921875
3
[]
no_license
# Moove IT coding-challenge # coded by: Lucas Ballestrino # 20/09/2020 require 'socket' class RubyMemcachedClient def initialize(ip,port) @ipdir = ip @port = port @socket = TCPSocket.new @ip , @port end def newconn(ip,port) @ipdir = ip @port = port @socket = TCPSocket.new @ip , @port ...
true
2635b660128fb07cdbeab94a845d594f415da873
Ruby
nosakos/assessment
/ruby-numerals/app/controllers/numerals_controller.rb
UTF-8
2,637
3.28125
3
[]
no_license
class NumeralsController < ApplicationController @@small_numbers = Array["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] @@tens = Array["", "", "twenty", "thirty", "forty", "f...
true
2db38fad95d3fad0d155db49f3bee771ed952f87
Ruby
dlangsam/Ironhack
/Week1/pairprogramming1.rb
UTF-8
1,697
4.03125
4
[]
no_license
class ProgrammingLanguage attr_accessor :name, :age, :type def initialize(name, age, type) @name = name @age = age @type = type end end ruby = ProgrammingLanguage.new("Ruby", 21, "Dynamic") python = ProgrammingLanguage.new("Python", 24, "Dynamic") javascript = ProgrammingLanguage.new("JavaScript",...
true
9153f4f4c716d4ee540c0bdb9a8f21b73c5b4f63
Ruby
AntonCherkago/RoR-Ruby-Basics
/1 lesson/76.rb
UTF-8
227
2.984375
3
[]
no_license
# Дан целочисленный массив. Найти среднее арифметическое квадратов его элементов a = [1, 2, 3, 4, 5] p (a.inject(0){ |sum, i| sum + i**2.abs }.to_f) / a.size
true
d99fafb3b16fc87b607ab7f8fa57d4078e904125
Ruby
AnnaErshova/playlister-cli-web-0615-public
/app/models/library_parser.rb
UTF-8
1,343
3.53125
4
[]
no_license
class LibraryParser "./db/data" attr_accessor :path def initialize # I thought we are supposed to initialize it with a directory?! @path = path end # return all the filenames within the target directory. def files Dir["./db/data/*"] end # actually parse all the file names and create corresp...
true
4c5983cd17247119d7a28da0e22799f51405b9c8
Ruby
kantarjiev/BAMRU-Org
/lib/date_range.rb
UTF-8
960
3
3
[ "MIT" ]
permissive
class DateRange class << self def start Time.now.beginning_of_month end def finish (Time.now + 1.year).end_of_month end def cal_start return Time.now.beginning_of_month if MM_ENV == 'test' (Time.now - 1.year).beginning_of_year end def cal_finish return (T...
true
c102de95d2dba92c01830dc1c7d70f36d0785dc6
Ruby
hcurotta/fairfax_receipt_test
/run_receipt.rb
UTF-8
521
2.90625
3
[]
no_license
require './lib/receipt' require './lib/calculator' # input 1 # input = "Quantity, Product, Price\n1, book, 12.49\n1, music cd, 14.99\n1, chocolate bar, 0.85" # input 2 input = "Quantity, Product, Price\n1, imported box of chocolates, 10.00\n1, imported bottle of perfume, 47.50" # input 3 # input = "Quantity, Product...
true
761f7fc715fd3dfe40d6aa6abe1b68efbf7cbc99
Ruby
drodeo/feeds
/app/services/feeds/fetch_feed.rb
UTF-8
2,360
2.765625
3
[]
no_license
require "feedjira" class FetchFeed USER_AGENT = "Feedjira".freeze MAX_RETRIES = 3 MIN_YEAR = 1970 def initialize(feed, parser: Feedjira::Feed, logger: nil) @feed = feed @parser = parser @logger = logger end def fetch raw_feed = fetch_raw_feed if raw_feed == 304 feed_not_modifi...
true
ca113ddbf5062b12605e197a3282da4b29acd0e3
Ruby
AbbiAld/ruby-the-hard-way
/ex6.rb
UTF-8
573
4.3125
4
[]
no_license
#Types of people, in binary types_of_people = 10 #Joke x = "There are #{types_of_people} types of people." binary = "binary" do_not = "don't" #Punchline y = "Those who know #{binary} and those who #{do_not}." # Tell joke puts x puts y #Tell joke again (this makes it funnier) puts "I said: #{x}." puts "I also said:...
true
d5ae882ffc8bbb846e2ebc14eed50d6d3534d120
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/src/174.rb
UTF-8
90
2.78125
3
[]
no_license
def compute(s1, s2) [s1, s2].map(&:length).min.times.count { |i| s1[i] != s2[i] } end
true
5c6b4ddae174a4bc7ff4c22cb2ebd278267e4688
Ruby
LeroyHutchinsonJ/ttt-6-position-taken-rb-cb-gh-000
/lib/position_taken.rb
UTF-8
219
3.40625
3
[]
no_license
# code your #position_taken? method here! def position_taken?(board, index) if(board[index] == "" || board[index] == " " || board[index] == nil) false elsif board[index] == "X" || board[index] == "O" true end end
true
29321d2d46506eecc045c5aa72bb13f7f808863b
Ruby
hkumar1993/coding_assessments
/2017_12_14/lib/character_diffs.rb
UTF-8
623
3.140625
3
[]
no_license
def character_diffs(a,b) longer = a.length > b.length ? a : b shorter = a.length > b.length ? b : a longer_chars = Hash.new(0) shorter_chars = Hash.new(0) longer.chars.each do |c| longer_chars[c] += 1 end shorter.chars.each do |c| byebug if longer_chars.values.any? { ...
true
0abb606848cd0e283644d29f7dc6eec7cf24c3b8
Ruby
imdea-software/popl-2016-artifact
/lib/prelude.rb
UTF-8
1,979
2.875
3
[ "MIT" ]
permissive
require 'optparse' require 'ostruct' require 'logger' require 'yaml' module Kernel def log_filter(pattern) (@@log_filters ||= []) << pattern end def log @@logger ||= ( l = Logger.new(STDOUT,'daily') l.formatter = proc do |severity, datetime, progname, msg| next if progname && (@@log_...
true
829dca85d320ccdd9fb93a6388e9c31d8da3109c
Ruby
duytran21/finance-tracker
/app/models/stock.rb
UTF-8
861
2.953125
3
[]
no_license
class Stock < ApplicationRecord has_many :user_stocks has_many :users, through: :user_stocks def self.find_by_ticker(ticker_symbol) where(ticker: ticker_symbol).first end def self.new_from_lookup(ticker_symbol) looked_up_stock = StockQuote::Stock.quote(ticker_symbol) return nil unless looked_up_stoc...
true
75818e61d01be4c4dbfb7331e056f263a5d144c8
Ruby
Benjamin-G/ttt-8-turn-bootcamp-prep-000
/lib/turn.rb
UTF-8
829
3.953125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn(board) puts "Please enter 1-9:" turn=gets.strip x=input_to_index(turn) if (!valid_move?(board,x)) turn(board) else move(board,x) end display_board(board) end def display_board(brd) #displays board puts " #{brd[0]} | #{brd[1]} | #{brd[2]} " puts "-----------" puts " #{brd[3]} | #{br...
true
c99d5dcda05af1f933efa4c5a75d7b471d031b1c
Ruby
rspec-given/sorcerer
/lib/sorcerer/resource.rb
UTF-8
24,010
2.78125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'ripper' module Sorcerer class Resource class SorcererError < StandardError end class NoHandlerError < SorcererError end class NotSexpError < SorcererError end class UnexpectedSexpError < SorcererError end def initialize(sexp, options={}) @se...
true
e0b7fa3a593295b116961aaa9796eda4e9b8d5af
Ruby
cmacaulay/headcount
/lib/statewide_test_repository.rb
UTF-8
2,217
3
3
[]
no_license
require_relative 'statewide_test' class StatewideTestRepository include DataTranslator attr_reader :statewide_tests def initialize @statewide_tests = Hash.new end def load_data(data) if data.has_key?(:statewide_testing) create_repository(data[:statewide_testing]) end e...
true
ea06f5f8373374b77c9ba1588c475a8d1ed25eb2
Ruby
J-Y/RubyQuiz
/ruby_quiz/quiz148_sols/solutions/Harry Kakueki/postfix_to_infix.rb
UTF-8
720
3.671875
4
[ "MIT" ]
permissive
# Here is my solution. # It solves the minimum requirements with minimal error checking. # Removes some parentheses. #str = "1 56 35 + 16 9 - / +" str = "1 2 - 3 4 - - 2 * 7.4 + 3.14 * 2 / 1.2 + 3 4 - -" ops = %w[+ - * /] arr = str.split(/\s+/) err = arr.select {|c| c =~ /^\d+\.?\d?/ || ops.include?(c)} the_stack = [] ...
true
eb189cee863d62484b0b13cc9f31a73ccc876650
Ruby
nxdf2015/odin-advanced-building-blocks
/enumerable/lib/enumerable.rb
UTF-8
1,328
3.421875
3
[]
no_license
module Enumerable def my_each(&bloc) for item in self yield(item) end end def my_each_with_index (0..self.length).my_each do |i| yield(i,self[i]) end end def my_select r = [] self.my...
true
6f6f5b8279fb64ed85ea73aa773932a471464517
Ruby
Bago213/beryexchange
/vendor/bundle/ruby/2.2.0/gems/http_accept_language-2.0.1/spec/parser_spec.rb
UTF-8
1,763
2.59375
3
[ "MIT" ]
permissive
require 'http_accept_language/parser' describe HttpAcceptLanguage::Parser do def parser @parser ||= HttpAcceptLanguage::Parser.new('en-us,en-gb;q=0.8,en;q=0.6,es-419') end it "should return empty array" do parser.header = nil parser.user_preferred_languages.should eq [] end it "should properly...
true
599ccd3183a67c4164397183b800e635433e4ca9
Ruby
jichen3000/testhelper
/lib/testhelper.rb
UTF-8
2,377
3.140625
3
[]
no_license
direc = File.dirname(__FILE__) require "#{direc}/file_line" require 'pp' module TestHelper module ObjectMixin # It will pretty print the self, with title. def pt(title=nil) location_str = caller()[0] if title == nil title = SourceFile.get_variable_name(locat...
true
ef0cd90047eb44ca8d5b34609e07af14555687da
Ruby
yesmeck/user_notification
/lib/user_notification/models/activist.rb
UTF-8
1,492
2.53125
3
[ "MIT" ]
permissive
module UserNotification # Module extending classes that serve as owners module Activist extend ActiveSupport::Concern # Module extending classes that serve as owners module ClassMethods # Adds ActiveRecord associations to model to simplify fetching # so you can list notifications performed ...
true
25cddda3ac5915831f1fb1c12a954ce6824a160c
Ruby
TruptiHosmani/CodeEval-Easy
/string_substitution.rb
UTF-8
857
3.09375
3
[]
no_license
def string_substitution(stringSub, find, replace) return stringSub if find.empty? || replace.empty? #find all the indices of the find begin index = Array.new for i in 0..find.length-1 if index.empty? index << (stringSub.index find[i]) else temp = (stringSub.index(find[i],index[i-1]) ) ...
true
3eb0da9dbf5832b9fd4f683684e63c2a225adabc
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/gigasecond/b46ed2b30cf246b5ad46ffb5a3d28f04.rb
UTF-8
133
2.71875
3
[]
no_license
require 'date' require 'time' class Gigasecond def self.from(date_of_birth) (date_of_birth.to_time + 10**9).to_date end end
true
f30f49c20cff1a2f09a0e8d5ac80a7e4cb27e765
Ruby
shivasurya/coop-fall-2020-challenge
/tests/ruby_solution_test.rb
UTF-8
2,054
2.9375
3
[]
no_license
require_relative "../solution_ruby" require "test/unit" require "json" class TestChallenge < Test::Unit::TestCase # Happy path tests def test_add sourcer = EventSourcer.new sourcer.add(2) sourcer.add(5) assert_equal sourcer.value, 7 end def test_subtract sourcer = EventSourcer.new so...
true
c3e2a91b62dbd7272cc2221f382ce79f7b55864f
Ruby
butcallmeJo/ruby
/http_to_json.rb
UTF-8
470
2.734375
3
[]
no_license
require 'httpclient' require 'json' def http_to_json(url) extheaders = { 'User-Agent' => 'Holberton_School', 'Authorization' => 'token fffa38b10948aa7eff293682308672bc95672ae3' } http = HTTPClient.new response = http.get(url, nil, extheaders) # error handling and exiting if wrong status if respo...
true
c1f4785069b031742fae4077e738e0099fc1a6d6
Ruby
lukaselmer/ethz-asl-testmaster
/app/services/test_run_cron.rb
UTF-8
2,110
2.6875
3
[]
no_license
class TestRunCron def initialize @ssh_user = ENV['AWS_SSH_USER'] @machine_service = MachineService.new end def run @machine_service.sync_aws_instances running_test = query_running_test if running_test return if test_run_still_running? running_test puts "#{Time.now}: Stopping tes...
true
e5fe7f1e1b601e85d684c4af76d220630358f4e3
Ruby
Paru871/ruby-practices
/02.calendar/calendar.rb
UTF-8
859
3.71875
4
[]
no_license
#!/usr/bin/env ruby require 'date' require 'optparse' options = ARGV.getopts("y:", "m:") today = Date.today if options["y"] year = options["y"].to_i else year = today.year end if options["m"] month = options["m"].to_i else month = today.month end title = Date.new(year,month,1).strftime("%-m月 %Y") header = [...
true
49fb3cde71b37922c98cc804eae091ba8045039f
Ruby
eregon/Classes
/math/expression.rb
UTF-8
2,073
3.453125
3
[]
no_license
=begin Math Expression Functions Derivee Integrale =end =begin Symbol name String deriv: derivative String integ: integral =end module MathExp class Function attr_reader :name, :deriv, :integ def initialize(name, of = nil, deriv = '', integ = '') @name = name.to_sym of = MathExp.x if of.nil...
true
fc4f6a422f636ae353d45caaf6d876980e6bd0e9
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/rna-transcription/c465caef61714935a923c050b2b25101.rb
UTF-8
196
2.796875
3
[]
no_license
class Complement @dna = "GCTA" @rna = "CGAU" def self.of_dna(dna_sequence) dna_sequence.tr(@dna, @rna) end def self.of_rna(rna_sequence) rna_sequence.tr(@rna, @dna) end end
true
b698596570bc870aaae5c999f69ac277c4a83cb5
Ruby
elia/shoes4
/lib/shoes/swt/shape.rb
UTF-8
2,468
2.78125
3
[ "MIT" ]
permissive
class Shoes module Swt class Shape include Common::Fill include Common::Stroke include Common::PainterUpdatesPosition # Creates a new Shoes::Swt::Shape # # @param [Shoes::Shape] dsl The dsl object to provide gui for # @param [Hash] opts Initialization options # ...
true
55c1bd4810dff1c36d1d187b43e7ccda1c72b431
Ruby
lorenzocassulo/esercizi
/06flussi/bottigliesulmuro_2.rb
UTF-8
561
3.515625
4
[]
no_license
# encoding: utf-8 puts 'Quante bottiglie di birra sul muro?' bottiglie = gets.chomp.to_i while bottiglie != 99 if bottiglie < 99 puts 'Le bottiglie sono di più' bottiglie = gets.chomp.to_i else puts 'Le bottiglie sono di meno' bottiglie = gets.chomp.to_i end end if bottiglie == 99 while (bottiglie.to_i > 1) ...
true
492b899f054e33dd51436be992956268984ce574
Ruby
andreydjason/rails-play
/.others/ruby_readline_play.rb
UTF-8
955
2.78125
3
[]
no_license
#!/usr/bin/ruby require 'readline' #-------------------------------- # Store the state of the terminal stty_save = `stty -g`.chomp #-------------------------------- Readline.completion_append_character = " " Readline.completion_proc = Proc.new do |str| Dir[str+'*'].grep( /^#{Regexp.escape(str)}/ ) end # Readli...
true
0f4c4949744b991d62a10efb749d6c84d8b4b7fb
Ruby
land-pack/ruby-example
/buildin/hash_demo.rb
UTF-8
209
3.0625
3
[]
no_license
#!/usr/local/bin/ruby a = {"name" => "frank", "age" => 25 } puts a.length puts a["name"] puts a["no_key"] a2 = Hash.new a2[:first] = "Frank" a2[:second] = "AK" puts a2.length puts a2 puts a2[:second]
true
473b75483151d90109afcb8fa02bc9af0711ecfe
Ruby
neoDJS/ruby-music-library-cli-noukod-000
/lib/artist.rb
UTF-8
528
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist extend Concerns::Findable extend Concerns::ClassMethods include Concerns::InstanceMethods @@all = [] attr_accessor :name attr_reader :songs def initialize(name = "") @name = name @songs = [] end def self.all @@all end def add_song(song) @songs << song if !@songs.incl...
true
199184f7063f4f7a0266da5cea5488dd7382e0ca
Ruby
aji-slater/Taskerly
/test/models/task_test.rb
UTF-8
2,015
2.53125
3
[]
no_license
require 'test_helper' class TaskTest < ActiveSupport::TestCase test 'tasks without users can\'t exist' do task = Task.create(name: 'failing task') assert_equal nil, task.id end test 'default state is false' do task = FactoryGirl.create(:task) assert_equal false, task.state end test 'a task ...
true
bd8744adbba73eb76eed37cc9cf5c2b0e41167a4
Ruby
atulonruby/game_of_life
/game_of_life.rb
UTF-8
800
3.640625
4
[]
no_license
class World attr_accessor :rows,:cols,:cell_grid def initialize(rows=3,cols=3) @rows = rows @cols = cols @cell_grid = Array.new(rows) do |row| Array.new(cols) do |col| Cell.new(col,row) end end end def live_neighbours_around_cell(cell) live_neighbours = [] live_neigh...
true
a3e66fed0ac18c8d292ad45ed2e8b75a04da9a5d
Ruby
lanastasov/intro-to-programming
/06-arrays/arrays.rb
UTF-8
2,245
4.5
4
[]
no_license
# 1. Below we have given you an array and a number. Write a program that # checks to see if the number appears in the array. arr = [1, 3, 5, 7, 9, 11] number = 3 puts arr.include? number # 2. What will the following programs return? What is value of arr after each? # arr = ["b", "a"] # arr = arr.product(Ar...
true
958801d5a9ac0981dc41898a1bbb19b9b6190762
Ruby
Waltersin/blogw
/app/controllers/articles_controller.rb
UTF-8
1,116
2.515625
3
[]
no_license
class ArticlesController < ApplicationController #GET /articles Esta accion trae la lista de todos los articulos def index #Todos los registros select * from articles; @articles = Article.all end #GET /articles/:id def show #Encontrar un registro por id @article = Article.find(params[:id]) ...
true
26d3d1ffccb64a0eec8ab8674ce46df1143e458a
Ruby
theandrewykim/codedrills
/proj_euler/problem_2/prob_2.rb
UTF-8
384
3.828125
4
[]
no_license
def fibonacci(number) fib_array = [0] current_number = 1 until current_number >= number fib_array.push(current_number) current_number = fib_array[-1] + fib_array[-2] end return fib_array end def even_sum(array) evens = [] array.each {|number| evens << number if number % 2 == 0 } evens.reduce(...
true
ae98a8a8fe4b26186e52607a4a721f7d19706303
Ruby
t-hnh10/ruby-challenges
/05_in_array.rb
UTF-8
1,459
4.78125
5
[]
no_license
# Methods # Write a method called 'in_array' which will take # two parameteres: # One as a string and one as an array of strings # Return a boolean indicationg whether or not the # string is found in the array. # Test your solution with: # ruby tests/05_in_array_test.rb # Example: # "hello", ["hi","ho...
true
34f447a206237581da0e2cdbed054548e1578046
Ruby
cgsimmons/euler_exercises
/ruby/6_Sum_Square_Difference.rb
UTF-8
701
3.9375
4
[]
no_license
#!/usr/bin/ruby #The sum of the squares of the first ten natural numbers is, #12 + 22 + ... + 102 = 385 #The square of the sum of the first ten natural numbers is, #(1 + 2 + ... + 10)2 = 552 = 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
ae56d566d199c4c0a5d2ffc7df4de73bfbc964b2
Ruby
maksimhn/ruby_class_methods_self
/lib/cat.rb
UTF-8
180
3.15625
3
[]
no_license
class Cat @cat_number = 0 def intiailize @cat_number = self.class.add_cat end def self.add_cat @cat_number += 1 end def cat_number @cat_number end end
true
f44b27ae54d37b0fa26597d16df89a2137afddce
Ruby
sun-mit/Ruby
/method.rb
UTF-8
152
3.28125
3
[]
no_license
def demo_method (name="no name" , age = 0) puts ("Hello my name is : " + name + " and i am " + age.to_s + " years old" ) end demo_method("Amit",23)
true
01a51acb012611207b521b4c4814dbd0e3f37269
Ruby
groting/Thinknetica_ROR
/Lesson_3/train_int.rb
UTF-8
2,942
3.359375
3
[]
no_license
require_relative 'cargo_train' require_relative 'passenger_train' require_relative 'cargo_wagon' require_relative 'passenger_wagon' module TrainInterface def create_train set_train_number raise 'Такой поезд уже существует!' if Train.all.key?(train_number) puts 'Введите тип поезда(Грузовой(а)\Пассажирский...
true
f957b8e7391ff70344e984de686596bb2d3bc625
Ruby
davis-campbell/ruby
/adv-building-blocks/spec/caesar_spec.rb
UTF-8
612
3.09375
3
[]
no_license
require_relative '../caesar_cipher' describe '#caesar_cipher' do it 'shifts lowercase letters' do expect(caesar_cipher('a', 6)).to eq('g') end it 'shifts uppercase letters' do expect(caesar_cipher('A', 6)).to eq('G') end it 'does not shift other characters' do expect(caesar_cipher('!@#$%', 6)).to...
true
758662c14f2eb51d48bc49a1cfd0b673330763a4
Ruby
raghuboosetty/employee_gift_cards_system
/db/seeds.rb
UTF-8
2,456
2.53125
3
[]
no_license
unless Admin.find_by_email('admin@zaggle.com') puts 'Seeding Admin...' Admin.create(email: 'admin@zaggle.com', password: 'password', password_confirmation: 'password') end puts 'Seeding Default Data...' [ { name: 'FOOD & GROCERIES', code: 'FDG', limit: '2200' }, { name: 'FUEL', code: 'FUL', limit: '1600' }, ...
true
b4fee56ba4afcdc47899fc9b16c70dc120e9e1c4
Ruby
a2ikm/ruby-sandbox
/tree.rb
UTF-8
1,284
2.921875
3
[]
no_license
#!/usr/bin/env ruby require File.expand_path("../vendor/natcmp", __FILE__) def empty [:node, nil] end def empty?(tree) tree[1].nil? end def insert(new_key, new_value, tree) if empty?(tree) [:node, [new_key, new_value, empty, empty]] else key, value, smaller, larger = tree[1] case String.natcmp(n...
true
5e7fffdf179ef6abdb56bf0f551a1415128d25cf
Ruby
jetsgit/hi_card
/lib/player.rb
UTF-8
134
3.09375
3
[]
no_license
class Player attr_accessor :name, :card, :wins def initialize(name = "") @name = name @card = nil @wins = 0 end end
true
3c9bb1ccae37e17371e2a0691b9d214f14710c52
Ruby
arcticleo/realogy
/lib/realogy/app/models/realogy/listing.rb
UTF-8
22,136
2.640625
3
[ "MIT" ]
permissive
class Realogy::Listing < Realogy::Entity # Array def company_names return nil if self.agents.nil? self.agents.map{|a| a.dig_for_string("office", "companyName")}.uniq end # fullBath : Integer # Number of full baths in the property def full_bath self.dig_for_integer("fullBath") end # half...
true
949dcb36f6903d35a78cbc0daedc4dedd757f161
Ruby
ZiluoH/aALecture
/block_basics.rb
UTF-8
93
3.453125
3
[]
no_license
def double_eles(arr) arr.map do |ele| ele * 2 end end p double_eles([1,2,3])
true
75cffa043fd1a01b45decaf2eb1ef7cb9e9f1542
Ruby
clairton/quantity
/app/models/quantity/value.rb
UTF-8
1,153
2.75
3
[ "MIT" ]
permissive
module Quantity class Value < ActiveRecord::Base include Quantity::Parseable attr_accessor :string belongs_to :unit, inverse_of: :values validates :amount, numericality: true validates :unit, presence: true # def initialize(options={}) # if options['string'] # options.merge Uni...
true
eabef6a19bcfe2b42b7123b19a7e65c44cd54813
Ruby
mkikegawa/Talking_robot_2
/lib/Author.rb
UTF-8
173
2.71875
3
[]
no_license
require 'pry' require './Person' class Author < Person def initialize(args = {}) super @name = "Martin" @age = "42" @gender = "M" end end
true
6120218ed288177590489c13e990a56854c84d9c
Ruby
rubykorea/codingdojo
/2012_12_06/zookd & mike/minesweep.rb
UTF-8
1,254
3.171875
3
[]
no_license
def cal(width, height, mine_rate = 0.125) start = Time.now width = [width, 10000].min height = [height, 10000].min mine_rate = [mine_rate, 0.9].min # create map map = Array.new(width) { Array.new(height, 0)} # locate mine mine_number = (width * height * mine_rate).round count = 0 u...
true
3060dad857b9e55ba1fce5ac73c676410ebd557a
Ruby
kohski/code_wars_study
/20190420_who_like.rb
UTF-8
1,546
4.09375
4
[]
no_license
# likes [] // must be "no one likes this" # likes ["Peter"] // must be "Peter likes this" # likes ["Jacob", "Alex"] // must be "Jacob and Alex like this" # likes ["Max", "John", "Mark"] // must be "Max, John and Mark like this" # likes ["Alex", "Jacob", "Mark", "Max"] // must be "Alex, Jacob and 2 others like this" # ...
true
c4c2f2e08bd0dee28a1d95999f49e0cdd6b1d9a9
Ruby
antmelnyk/KlanzDeckbuilder
/app/models/deck.rb
UTF-8
1,482
2.8125
3
[]
no_license
class Deck < ApplicationRecord ROOMS = [%w[Потасовка Потасовка], ['Турнир Арпада', 'Турнир Арпада'], %w[Арена Арена], %w[Ивент Ивент]] VALID_ROOM = /\AПотасовка\z|\AТурнир Арпада\z|\AАрена\z|\AИвент\z/ VALID_DECK_REGEX = /\A([\d]+_){15,}\z/ validates :name, presence: true, length: { maximum: 40 } validates ...
true
4870334ca8249ea57e65415a0300eef8a1394806
Ruby
cielavenir/procon
/aizu/tyama_aizu2799.rb
UTF-8
116
2.53125
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby n,m,*a=$<.read.split.map(&:to_i) r=a.select{|e|e>m}.map{|e|e-m}.reduce(0,:+) puts r>0 ? r : :kusoge
true
616ce38a3ebddd6ab571d208e58f9ce37189a87e
Ruby
ChristofBecu/challenges-contests
/codechef/pratice/beginner/findRemainder/findRemainder.rb
UTF-8
88
3.125
3
[]
no_license
gets.chomp.to_i.times do #T a, b = gets.chomp.split().map(&:to_i) puts a % b end
true
1bffca878f1484cfb00dcbc5a35e73245f9d217e
Ruby
EPICZEUS/OO-mini-project-nyc-web-102918
/app/models/RecipeCard.rb
UTF-8
252
2.84375
3
[]
no_license
class RecipeCard @@all = [] def self.all @@all end attr_accessor :rating attr_reader :user, :recipe, :date def initialize(rating, user, recipe) @rating = rating @user = user @recipe = recipe @date = Time.now @@all << self end end
true
b8353aca92af57453094fba7b9c17ef40154750e
Ruby
SiunCyclone/pe
/028.rb
UTF-8
142
2.78125
3
[]
no_license
def foo(num,sum,dis,n) return sum if n==num**2 4.times{|i| n += dis sum += n } foo(num,sum,dis+2,n) end p foo(1001,1,2,1)
true
3a337debc4e1d77193b8deb8e3d454a1313552c9
Ruby
goobering/w2_d2_homework
/river.rb
UTF-8
304
3.90625
4
[]
no_license
class River def initialize(name) @name = name @fish = [] end def name() return @name end def fish() return @fish end def get_num_fish() return @fish.count() end def add_fish(fish) @fish.push(fish) end def remove_fish(fish) if @fish.include?(fish) @fish.delete(fish) end end end
true
fd076dedc00052ab173a2b8c5c91a4f227b06fb1
Ruby
3Seventy/vector370-ruby
/examples/subscription/edit_subscription.rb
UTF-8
984
2.875
3
[ "BSD-3-Clause" ]
permissive
require 'three_seventy_api' require 'yaml' # Example to edit a subscription. class EditSubscription def run # Load the config file config = YAML.load_file(File.expand_path("../../config.yml", __FILE__)) # Load the account_id from config. account_id = config['account_id'] # Load the url from config...
true
3567a3c241f049574894d4b4cf26aa9b3c534d24
Ruby
bf4/tooter
/lib/expand_url.rb
UTF-8
4,868
2.6875
3
[ "MIT" ]
permissive
require 'net/http' require 'net/https' require 'uri' # e.g. # url = http://t.co/z4t0E1vArh # ExpandUrl.expand_url(url) # => "http://www.haaretz.com/news/national/israel-s-ag-impels-ministers-to-crack-down-on-exclusion-of-women.premium-1.519917" module ExpandUrl class ExpansionError < StandardError; end module Expa...
true
add3dd238fe9238a41e48b9d42a1084e51537870
Ruby
bdiveley/battleship
/test/ship_test.rb
UTF-8
1,808
3.21875
3
[]
no_license
require './test/test_helper.rb' class ShipTest < Minitest::Test def test_new_ship_exists ship = Ship.new("Destroyer", 2) assert_instance_of Ship, ship end def test_instance_variables ship = Ship.new("Cruiser", 3) assert_equal "Cruiser", ship.name assert_equal 3, ship.length end def t...
true
1cee5e375c63756d4a109d36b995bb0c8f5b5fef
Ruby
domelon/spree
/core/app/models/adjustment.rb
UTF-8
2,639
3.015625
3
[ "BSD-3-Clause" ]
permissive
# *Adjustment* model is a super class of all models that change order total. # # All adjustments associated with order are added to _item_total_. # charges always have positive amount (they increase total), # credits always have negative totals as they decrease the order total. # # h3. Basic usage # # Before checkout i...
true
33609df4410f8c8478740dd8d4c5f56358bfe958
Ruby
kalpeshzerwal/ruby_assignment
/rubbyassignment/assignmentno_3/product.rb
UTF-8
1,914
3.15625
3
[]
no_license
require 'json' require_relative 'fileoperation' class Product < Fileoperation def addproduct(sr_no) sr_no=1 puts 'Enter the Name of product' product_name = gets.strip puts 'Enter Product price' price = gets.strip puts 'Enter stock item' stock = gets.strip puts 'Enter company_name' company_name = get...
true
e01b30c57b5d469fb672dfaab4c014cc35f08a4b
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/etl/8983252cb016443997751e8c72e1bf12.rb
UTF-8
179
2.78125
3
[]
no_license
class ETL def self.transform(input) input.keys.each_with_object({}) do | elem, acc | input[elem].each { | value | acc[value.downcase] = elem } end end end
true
0c432aad93e72c5511795de8aef6ee5b97b5cbe6
Ruby
brenoperucchi/tdlib-ruby
/lib/tdlib/types/local_file.rb
UTF-8
1,377
2.8125
3
[ "MIT" ]
permissive
module TD::Types # Represents a local file. # # @attr path [String, nil] Local path to the locally available file part; may be empty. # @attr can_be_downloaded [Boolean] True, if it is possible to try to download or generate the file. # @attr can_be_deleted [Boolean] True, if the file can be deleted. # @att...
true
ae829e98b8739e6be28351d0b5f8c3d8542b32ce
Ruby
SteRobWms/ruby-objects-has-many-lab-houston-web-012720
/lib/artist.rb
UTF-8
703
3.53125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require_relative 'song.rb' require 'pry' class Artist @@all = [] attr_accessor :name def initialize(name) @name = name @@all << self end def self.all @@all end def songs Song.all.select{|i| i.artist == self} end def add_song(song) Song.a...
true
8519a944e4ba5efb8e33d3d98b4b544da4bb7831
Ruby
abidiaz/tweet-shortener-001-prework-web
/tweet_shortener.rb
UTF-8
1,297
4.125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def dictionary dictionary = { "hello" => "hi", "to" => "2", "two" => "2", "too" => "2", "for" => "4", "four" => "4", "be" => "b", "you" => "u", "at" => "@", "and" => "&" } end def word_substituter(tweet) #method receives a tweet, changes tweet to an array #compares array to...
true