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
460604e43120c57082e9597e7e93335c4e0c956c
Ruby
kellyi/humidity-monitor
/app/models/text_message.rb
UTF-8
724
2.65625
3
[]
no_license
require 'net/http' require 'uri' class TextMessage include ActiveModel::Model attr_accessor :environment_reading delegate :humidity, :temperature, :created_at, :message, :id, to: :environment_reading def save! send_message! end private def send_message! Net::HTTP.post_form(uri, request) en...
true
e3ac3982438587bbedfe9670052e747b4248f5ab
Ruby
hschmid516/rails-engine
/spec/requests/v1/items_find_all_request_spec.rb
UTF-8
2,759
2.53125
3
[]
no_license
require 'rails_helper' describe 'find items API' do before :each do merchant = create(:merchant) create(:item, name: 'Ski bindings', merchant: merchant, unit_price: 10) create(:item, name: 'Snowboard Bindings', merchant: merchant, unit_price: 10) create_list(:item, 8, merchant: merchant, unit_price: ...
true
009c6e5f970ce2b4251c08c326874297367ef243
Ruby
eaball35/media-ranker
/test/models/vote_test.rb
UTF-8
5,628
2.5625
3
[]
no_license
require "test_helper" describe Vote do let (:new_vote) { Vote.create(work_id: works(:new_work).id, user_id: users(:new_user).id, vote_type: "upvote") } let (:new_work2) { Work.create(category: "book", title: "Cool Book2", creator: "Cooler Author", description: "Here is a desc", publication_year: 1993,...
true
efc947e2b3dfac428c14583efa51b5c394275316
Ruby
wojtodzio/codeeval
/easy/107/main.rb
UTF-8
497
3.578125
4
[]
no_license
class Sequence attr_reader :sequence def initialize(sequence) @sequence = sequence end def shortest_subsequence (0...sequence.length).each do |iterator| break iterator + 1 if is_subseqence?(iterator) end end private def is_subseqence?(iterator) sequence.split(sequence[0..iterato...
true
6977de1d29e55f30bfb35a2c81c085e2df66ef4a
Ruby
antonylao/intro_to_ruby
/the_basics/array_creation_4.rb
UTF-8
81
2.8125
3
[]
no_license
year_movies = [1975, 2004, 2013, 2001, 1981] year_movies.each {|year| puts year}
true
4df6ebea46225e42560f87d68845b53311ab6991
Ruby
ahamid/veritas-demo
/test/dynamic_results_test.rb
UTF-8
678
2.734375
3
[]
no_license
require 'test_helper' class DynamicResultsTest < Test::Unit::TestCase def test_dynamic_results relation = Veritas::Relation.new([ [ :num, Integer ] ], generate_records) divisible_by_5 = relation.restrict(lambda { |tuple| tuple[:num] % 5 == 0}) # order([ relation[:num] ]).take(20).optimize divisible_by_5...
true
5cc7be19c64c3334f45517f5757b807507cee9e5
Ruby
Xiangrui2019/Startup-Game
/coders/alpha.rb
UTF-8
636
3.3125
3
[ "MIT" ]
permissive
class Alpha < Coder def initialize @name = '路人Alpha' @salary = 2999 end def work(remain_difficulty) seed = rand(10) if seed > 5 forward = rand(10...100) puts "#{name}刚跑了8公里,精神状态良好,成功完成项目#{forward}" remain_difficulty - forward else forward = rand(1...5) puts "#{name}昨晚补番补到大半夜,严重睡眠不足,项目只推进了#{...
true
1bea3b225509a8fe377c3ed53963b56ec11b2752
Ruby
IIIIIIIIll/RubyQuizess
/Quiz7/question17.rb
UTF-8
358
3.34375
3
[]
no_license
class BaseBallPlayer def initialize(hits, walks, at_bats) @hits=hits @walks=walks @at_bats=at_bats end def batting_average p @hits.to_f/@at_bats end def on_base_percentage p (@hits + @walks).to_f / @at_bats end end barry_bonds = BaseBallPlayer.new(330, 110, 1125) barry_bonds.batting_...
true
612f83852ba07006ad9eed48ae0a545048172530
Ruby
ludwiggj/ruby-pickaxe
/ch09-expressions/17_break_redo_next.rb
UTF-8
1,477
4.0625
4
[]
no_license
=begin break terminates the immediately enclosing loop; control resumes at the statement following the block. redo repeats the current iteration of the loop from the start but without reevaluating the condition or fetching the next element (in an iterator). next skips to the end of the loop, effectively starting the n...
true
544f767565f2b5870e222a8b12cf30bfb4dc05b1
Ruby
anmuel/wrappers
/spec/boolean_spec.rb
UTF-8
1,860
2.734375
3
[]
no_license
require 'spec_helper' describe Wrappers::Boolean do describe '.try_convert' do it 'converts anything to false that is not true' do expect(described_class.try_convert(1)).to be false expect(described_class.try_convert(false)).to be false expect(described_class.try_convert('false')).to be false ...
true
f250e960d7e450138d91955355a443732b341969
Ruby
shvets/scriptlandia
/scriptlandia-tech-examples/DP/creational/abstract-factory.rb
UTF-8
1,684
3.734375
4
[]
no_license
# abstract-factory.rb # Provides an interface for creationg families of related or dependent objects without specifying # their concrete class. # # Provides one level of interface higher than the factory pattern. It is used to return one # of several factories. # 1. common interface for type and it's speciali...
true
bdf7b7e64274acb015415056acfb7a995450e1b4
Ruby
asmolentzov/backend_prework
/day_4/ex19-2.rb
UTF-8
2,232
4.84375
5
[]
no_license
def math_greeting(name, num1, num2) puts "Hi #{name}! The numbers you have entered are #{num1} and #{num2}." puts "If you add those together, you get #{num1 + num2}." puts "If you multiply them, you get #{num1 * num2}." end # 1. Call the method just passing in arguments directly math_greeting("Anna", 10, 3) # 2...
true
919ae44bc54044f7fd1e5125153f9d705de8c7a5
Ruby
pgarduque/code-portfolio
/ruby_code/String methods pt.1.rb
UTF-8
169
2.90625
3
[]
no_license
"BIGTIME". chars.each{ |c| print "-#{c}"} puts "\n" puts "sonic".capitalize puts "WHAT IS CAPSLOCK?".downcase puts "panda".include?("and") puts "ABA".insert(1, "B")
true
78bb50fe13375c332ae76ae405d45374b63cd80f
Ruby
rubygitflow/rails-optimization-task2
/task-2.rb
UTF-8
5,228
2.765625
3
[]
no_license
# frozen_string_literal: true require 'json' # require 'pry' # require 'date' require 'set' require 'ruby-progressbar' MIN = ' min.' class User @@totalUsers = 0 attr_reader :fullName attr_reader :sessions, :browsers, :dates attr_reader :usedIE, :alwaysUsed...
true
3a990881a3d97c8b71a5a25c4581bc21899b51bd
Ruby
ohler55/wabur
/lib/wab/impl/exprs/regex.rb
UTF-8
595
2.828125
3
[ "MIT" ]
permissive
module WAB module Impl class Regex < PathExpr # Creates a new instance with the provided parameters. # # path:: path to the value to compare # rx:: regexp to match against a string value from the path lookup def initialize(path, rx) super(path) @rx = rx.is_a?(Regex...
true
f2ff3048db63f5a841d1e135589f99ec860775d2
Ruby
neddy/Launch-School
/#Study_Groups_&_Notes/Study_Group_4_(June_6)/problem_1.rb
UTF-8
1,320
4.75
5
[]
no_license
# Positive integers that are divisible exactly by the sum of their digits are called Harshad numbers. The first few Harshad numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, ... # We are interested in Harshad numbers where the product of its digit sum s and s with the digits reversed, gives the original number n. Fo...
true
e7de1508f621cef9b941a2c6ca4082101ffad402
Ruby
daryllxd/daryllxd
/app/models/date_range.rb
UTF-8
243
2.96875
3
[]
no_license
# frozen_string_literal: true class DateRange attr_reader :start_date, :end_date def initialize(start_date:, end_date:) @start_date = start_date @end_date = end_date end def one_day? (end_date - start_date) < 1 end end
true
e03d8cb5f0a7d7d7cc560b78fbdc0906b1a06675
Ruby
emielhagen/convoyer
/db/seeds.rb
UTF-8
2,261
2.8125
3
[]
no_license
puts 'Deleting all users' User.delete_all puts 'Deleting all convoys' Convoy.delete_all puts 'Deleting all favorite convoys' FavoriteConvoy.delete_all puts 'Deleting all locations' Location.delete_all puts 'Deleting all members' Member.delete_all puts 'Deleting all reviews' Review.delete_all puts '====================...
true
d066c3dc890c694023b5bd6909392c629dfedf6b
Ruby
si0005hp/ruby-algo
/test/sort_test.rb
UTF-8
581
3.1875
3
[]
no_license
require 'minitest/autorun' require_relative '../bubble_sort' require_relative '../quick_sort' require_relative '../merge_sort' def testdata(n) (1..n).map {rand(1..100)}.reduce {|a, b| a.is_a?(Array) ? [*a, b] : [a, b]} end class SortTest < Minitest::Test def test_bubble_sort data = testdata(10) ...
true
f204fc922052ee55159fe108af57887d85da1cc2
Ruby
Kmfisher13/Launch-School
/intro_exercises/exercises/six.rb
UTF-8
194
3.609375
4
[]
no_license
# six.rb # Given array (0..10, 3) remove duplicates without specifically remmoving any # one value. arr = (0..10).to_a arr.push(3) arr.uniq! #or arr.uniq without modifying original arr p arr
true
96c33af1a7b4aeea92e34a566d5f92589ca70ec0
Ruby
nndd91/alphacampcode
/kata/persistence.rb
UTF-8
345
3.375
3
[]
no_license
def persistence(n) num_string = n.to_s.split('').map(&:to_i) no_of_times = 0 while num_string.size > 1 final_value = num_string.reduce(:*) num_string = final_value.to_s.split('').map(&:to_i) no_of_times += 1 end no_of_times end p persistence(39) == 3 p persistence(4) == 0 p persistence(25) == 2...
true
40737d4f7604404938eddfdec4924c5593247928
Ruby
hamza3202/repositext
/lib/kramdown/mixins/tree_cleaner.rb
UTF-8
1,949
3.328125
3
[ "MIT" ]
permissive
module Kramdown # Include this module into any library that wants to clean up a kramdown tree # NOTE: This requires the tree traversal and manipulation methods defined in # Kramdown::ElementRt module TreeCleaner # Recursively cleans up tree under ke # @param [Kramdown::Element] ke def recursively_c...
true
11a04b768efa2d5b6e6f8ae23a630389cfe94bd8
Ruby
biospank/paperclip-site
/app/models/customer.rb
UTF-8
1,080
2.546875
3
[]
no_license
class Customer < ActiveRecord::Base belongs_to :user has_and_belongs_to_many :services validates :name, :tax_code, :address, :cap, :city, presence: { allow_blank: false, message: "Tutti i dati sono obbligatori" } validates :tax_code, length: { is: 11, if: lambda { |customer| return tr...
true
14389aab778683ffdf5ebf8dae337335e5985b06
Ruby
jozr/markdown_ruby_documentation
/lib/markdown_ruby_documentation/generate.rb
UTF-8
4,359
2.59375
3
[ "MIT" ]
permissive
module MarkdownRubyDocumentation class Generate # @param [Class] subjects ruby classes to generate documentation from. # @param [Module] erb_methods must contain #link_to_markdown and contain any additional methods for comment ERB # @param [Proc] output_object given name: and text: for use in saving the t...
true
d1711bb5a8dd5dba8b0b3066e303f0cc9eb1c6a9
Ruby
NicoMunoz909/ruby_chess
/lib/board.rb
UTF-8
3,840
3.75
4
[]
no_license
require_relative 'bishop.rb' require_relative 'king.rb' require_relative 'knigth.rb' require_relative 'pawn.rb' require_relative 'queen.rb' require_relative 'tower.rb' class Board attr_reader :cells def initialize(pieces) default_icons = squares_icons() @cells = [0,1,2,3,4,5,6,7].repeated_permutation(2)....
true
ee604c1325b5fd9deeb7adb8e6c6528f5414d9a9
Ruby
ricardogpsf/ruby-course
/aula04/exercicios_resolvidos_aula03/cpf_validator.rb
UTF-8
282
3.03125
3
[ "MIT" ]
permissive
require "cpf_cnpj" module Validator def validate_cpf(cpf) if CPF.valid?(cpf) true else false end end end class Client include Validator end client = Client.new cpf = '00000000000000' result = client.validate_cpf cpf puts "Resultado: #{result}"
true
e632e255957fa1b83afe07ea9871b1b549d80b26
Ruby
astounding/filesafe
/test/test_cli.rb
UTF-8
1,076
2.859375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # encoding: ASCII-8BIT require 'test/unit' require 'digest/sha2' require_relative '../lib/filesafe.rb' class FileSafeCLITest < Test::Unit::TestCase FILESAFE = File.join(File.dirname(__FILE__), '..', 'bin', 'filesafe') def setup ## Create a temporary file: @testfile = 'test.out' @pa...
true
3678d47e0885e23bf4999384e4e77d0ed50e5db1
Ruby
norm-framework/p4
/lib/norm_framework/steps.rb
UTF-8
890
2.96875
3
[ "MIT" ]
permissive
require 'singleton' module NormFramework class Steps include Singleton def self.add(pattern, &block) instance.add pattern, &block end def self.call(pattern) instance.call pattern end attr_reader :steps def initialize @steps = [] end def add(pattern, &block)...
true
f566cdf7318462d6849b0378c35759b18cf093c6
Ruby
svishniakov/thinking_ror
/lesson_07/route.rb
UTF-8
1,232
3.4375
3
[]
no_license
require_relative 'mixins' class Route include Mixins attr_reader :stations @@all_routes = [] def initialize(start_station, end_station) @stations = [start_station, end_station] validate! @@all_routes << self end def valid? validate! rescue => e puts e false end def add_sta...
true
1ac43f2ac288860cded67c13eb5f3d4d12385e81
Ruby
torvick/panel_rh
/app/services/destroy_session.rb
UTF-8
467
2.765625
3
[]
no_license
class DestroySession def initialize(args) @token = args[:current_user] end # Public Interface def self.send(*args) new(*args).send! end def send! HTTParty.delete(build_url, headers: build_headers, body: build_body.to_json) end def build_url ENV['URL_API'] + '/api/v1/sessions' end ...
true
89d74b5334bdecaf55a5d81d251476dd2a553da4
Ruby
wowenstine/Metis
/fizzbuzz.rb
UTF-8
149
3.3125
3
[]
no_license
(1..100).each do |i| fizzbuzz = "" fizzbuzz += "Fizz" if i % 3 == 0 fizzbuzz += "Buzz" if i % 5 == 0 puts fizzbuzz.empty? ? i : fizzbuzz end
true
e4da12e457b11aea8642d5b0541038b347fe7b01
Ruby
scervera/myblog
/vendor/bundle/ruby/2.1.0/gems/cells-3.11.2/test/rails/view_model_test.rb
UTF-8
5,176
2.546875
3
[ "MIT" ]
permissive
require 'test_helper' if Cell.rails_version >= 3.1 class Song < OpenStruct extend ActiveModel::Naming def persisted? true end def to_param id end end class SongCell < Cell::ViewModel def show render end def title song.title.upcase end def se...
true
a584730942f416b0e7e83fb6e6e226209e65df11
Ruby
marcwright/WDI_ATL_1_Instructors
/REPO - DC - Students/w01/d02/INSTRUCTOR/survey.rb
UTF-8
427
3.28125
3
[]
no_license
def prompt(query) puts query return gets.chomp.upcase end answer = prompt("What's your fav album?") puts answer prompt("What's the meaning of life?") # what is 'def' in the method above # what is 'end' in the method above # what is 'prompt' in the method above # what is '(query)' in the method above # what is 'qu...
true
3c9726aea7a84a2a1318887a23369812ac6c43d9
Ruby
spokesoftware/aws_cloud_search
/lib/aws_cloud_search/document_batcher.rb
UTF-8
773
2.546875
3
[ "MIT" ]
permissive
require "json" require "aws_cloud_search" module AWSCloudSearch # Convenience method that will allow continuous batch additions and will chunk to a size threshold # and send requests for each chunk. class DocumentBatcher def initialize(cs) @cs = cs @batch = DocumentBatch.new end def add...
true
d084f60f665a6cd4638a89133d52986d393b2aef
Ruby
emiltin/healing
/lib/structure/resources/execute.rb
UTF-8
604
2.609375
3
[]
no_license
module Healing module Structure class Execute < Resource def initialize parent, name, command, options={} super parent, options.merge(:name=>name, :command => command) end def heal describe_name run options.command true end def ref "#...
true
f1d83ecc2b4a1ae02b4672ed144fea25b647d35d
Ruby
mbrown78/LS_Programming_Foundations
/Lesson_3/Practice_Problems_Easy_1/Q6.rb
UTF-8
350
3.546875
4
[]
no_license
# Starting with the string famous_words = "seven years ago..." # show two different ways to put the expected "Four score and " in front of it. # first add = 'Four score' phrase = add + " " + famous_words p phrase # second "Four score and " + famous_words # third famous_words.prepend("Four score and ") # fourth "Fou...
true
e47a32bfa97afe711208de8ec33533aff190d39d
Ruby
sirovenmitts/walkscore
/spec/result_spec.rb
UTF-8
1,075
2.515625
3
[ "MIT" ]
permissive
require 'uri' require 'spec_helper' # The result object is mostly just a value object, but there # are some actual data transformations, so I'll only test those # methods. describe Walkscore::Result do let(:result) do client = Walkscore::Client.new 'valid key' VCR.use_cassette 'valid request' do # Coordinates ...
true
857e0fbc7e8a069dd5456ca203103a2684bdf634
Ruby
dsandilla91/ruby-methods-readme-onl01-seng-pt-050420
/lib/example.rb
UTF-8
389
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
phrase = "Hello World!" puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase def say_hello_world_ten_times phrase = "Hello World!" puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase puts phrase pu...
true
bdd7ac5732997835d68d76d411e0b80418beda8b
Ruby
tariq87/slacktest
/jumbo.rb
UTF-8
2,069
2.515625
3
[]
no_license
#!/usr/bin/env ruby require_relative 'mylib' hosts = [] options = {} OptionParser.new do |opts| opts.banner = "Usage: jumbo.rb -i hostFile -f configFile" opts.on("-i","--inventory=file", "Host File Path") do |file| options[:host] = file end opts.on("-f", "--conf=conf", "Config File Location") do |conf| opti...
true
1e196b6d48bb41a3e02ca4cf2a01e2c54105eb6d
Ruby
NB28VT/Learn-To-Program-Challenges
/name.rb
UTF-8
130
2.953125
3
[]
no_license
puts 'Hello there, and what\s your name?' name = gets.chomp puts 'Your name is ' + name puts 'Pleased to meet you, ' + name + '?'
true
069d91da7d7c650eb7fdf60490145c203f8f1c6c
Ruby
sabman83/box-office
/get_imdb_id.rb
UTF-8
1,756
2.921875
3
[]
no_license
require 'net/http' require 'pry' require 'sqlite3' require 'json' base_search_uri = 'https://api.themoviedb.org/3/search/movie' search_uri = URI(base_search_uri) $api_key = '424b564a6178750b94a5c1158a4fff0d' $db = SQLite3::Database.new "box-office" #get list of movie names movies = $db.execute('SELECT name from par...
true
8e3fa443285001db3bf4e87e0fc9b86cfa3978d0
Ruby
crismali/Old-Tic-Tac-Toe
/play.rb
UTF-8
536
3.34375
3
[]
no_license
require './setup.rb' require './get_lines.rb' require './victory_checks.rb' require './human_player.rb' require './computer_player.rb' require './game.rb' tictactoe = Game.new dont_want_to_play_again = false until dont_want_to_play_again puts "Would you like to play again? (1 for yes, 2 for no)" input = gets.c...
true
d1577a075a46a4d331ad30b7d5a65f665577e040
Ruby
grosser/zendesk_api_client_rb
/lib/zendesk/actions.rb
UTF-8
2,652
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Zendesk module Read # Finds a resource by an id and any options passed in. # A custom path to search at can be passed into opts. It defaults to the {DataResource.resource_name} of the class. # @param [Client] client The {Client} object to be used # @param [Number] id The id to GET # @par...
true
0a2574aec703f6b1f4c2ccec6597352e0e103ba4
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/difference-of-squares/b1f18975fe12480897cdbb3dd2c59296.rb
UTF-8
329
3.703125
4
[]
no_license
class Squares def initialize(number) @number = number end def sum_of_squares sum = 0 (1..@number).to_a.each { |n| sum += (n*n) } sum end def square_of_sums square = 0 (1..@number).to_a.each { |n| square+= n } square**2 end def difference square_of_sums - sum_of_squares ...
true
9f5269f3e7ee24460619ed84ae1b4b0241402ac6
Ruby
vincepaoloclemenia/rb4
/app/models/dashboard.rb
UTF-8
1,944
2.890625
3
[]
no_license
class Dashboard < ActiveRecord::Base def self.populate_dashboard brands = Brand.all date = Date.today - 1 brands.each do |brand| brand.branches.each do |branch| @customer_count = Sale.get_customer_count(branch, date) @purchase_total = Purchase.get_total_purchases_per_branch(branch, date) @sales_t...
true
72b2e2e880ab8be76f78a86ebf847a031eee0c43
Ruby
GRGSIBERIA/Pixiv
/lib/pixiv/fun/stats/hot.rb
UTF-8
1,433
2.75
3
[]
no_license
=begin ホットさを調べるためのモジュール =end module Pixiv module Fun module Stats class Hot # タグからホットさの検索をかける # @param client [Pixiv::Client] クライアント # @param tag_name [String] 検索対象のタグ # @return [Float] log10した検索結果 def self.Tag(client, tag_name) search_result = client.search.tag(tag_name, {...
true
eeb0668f130b9e60a991bdc87212bf94489bf182
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/point-mutations/7e64d70493bf4e6ea6014d6e19b20d53.rb
UTF-8
894
3.96875
4
[]
no_license
class DNA def initialize strand @strand = strand end def hamming_distance other_strand comparator.hamming_distance strand, other_strand end private def strand @strand end def comparator @comparator ||= StrandComparator.new end end class StrandComparator def hamming_distance str...
true
cc98fd233ebf4ab9c797c636275d972a70c5a458
Ruby
DorianCBrwn/LaunchSchoolDCB
/RB101/small_problems/Easy_7/multiply_lists.rb
UTF-8
1,106
4.6875
5
[]
no_license
# Multiply Lists =begin Problem: Write a method that takes two Array arguments in which each Array contains a list of numbers, and returns a new Array that contains the product of each pair of numbers from the arguments that have the same index. You may assume that the arguments contain the same number of elements. E...
true
ce19277ea9a59449de321a2cebf2b52eac17a88e
Ruby
ChloePerreira/far_mar_finder
/lib/far_mar/market.rb
UTF-8
2,916
3.234375
3
[]
no_license
require 'io/console' require 'date' module FarMar class Market attr_accessor :id, :name, :address, :city, :county, :state, :zip def initialize(id, name, address, city, county, state, zip) @id = id @name = name @address = address @city = city @county = county @state = state...
true
74aa488c1fb3fdf71c099c582d8f5f3122623520
Ruby
devsilo/mailkiq
/app/models/concerns/sortable.rb
UTF-8
376
2.953125
3
[ "MIT" ]
permissive
module Sortable def sort_direction(column) name = column direction = :asc if column.start_with? '-' name = column.tr('-', '') direction = :desc end [name, direction] end def sort(column) name, direction = sort_direction(column) if column_names.include?(name) order...
true
33f059b0afca73ae83dcae2f25aa5154b0627fa4
Ruby
firechicago/advent-of-code
/Day-8-Problem-1/parse.rb
UTF-8
168
2.765625
3
[]
no_license
raw_data = File.readlines(ARGV[0]) require 'pry' result = 0 raw_data.each do |string| result += string.chomp.length result -= eval(string).length end puts result
true
9d5ffd4834c723c0f5ed13eba3a0b792547836a2
Ruby
chadlwilson/bamboo_cctray_proxy
/lib/bamboo/project_build_log_parser.rb
UTF-8
1,212
2.515625
3
[ "Apache-2.0" ]
permissive
require './model/project_build_log' require './model/project_build' module Bamboo class ProjectBuildLogParser def parse(plan, result) ProjectBuild.new(ProjectBuildResult.new(plan, result).to_hash) end private class ProjectBuildResult def initialize(plan, result) @plan = plan ...
true
e2810686cf5cd3471f1339192b64501fefde8a0f
Ruby
NANCYVALDEBENITO/E9CP1A1
/Ejercicio5.rb
UTF-8
1,100
3.78125
4
[]
no_license
class Morseable def initialize(number) @number = number end def morse # (0..9).each do |n| a = 0 a = if @number <= 5 '.' * @number + '-' * (5 - @number) else '-' * (@number - 5) + '.' * (5 - (@number - 5)) end # end a end def generate_hash dat...
true
dbff34a65e8172f132450f4fc5301777d730718f
Ruby
srfraser/adventofcode
/2020/19/ruby/1.rb
UTF-8
1,758
3.140625
3
[]
no_license
def process_rules(rule_id, rules_map, depth) if depth > 20 return "" end rstr = "(" rule = rules_map[rule_id] rule.split.each { |r| if r == "|" rstr += r elsif (Integer(r) rescue false) rstr += process_rules(r, rules_map, depth + 1) else return r[1] end } rstr + ")" e...
true
d09d00033087aa1656b7f0df390d47bed6dbe3ab
Ruby
XuVic/isspay_api
/spec/controllers/chatfuel/templates/init.rb
UTF-8
1,048
2.953125
3
[]
no_license
class Hash def same_key_structure?(other) outer = other.is_a?(Hash) && self.keys.map(&:to_sym).sort == other.keys.map(&:to_sym).sort return outer unless outer inner = self.keys.map do |k| if self[k].is_a?(Hash) self[k].same_key_structure?(other[k]) elsif self[k].is_a?(Array) && othe...
true
eae4b46d0db1a2402375901c949a58488882647c
Ruby
nagarjunaborra/ruby_files
/Ruby_files/ex1.rb
UTF-8
740
3.46875
3
[]
no_license
def no_space(a) puts a.gsub(/ +/, " ") end no_space("Ruby is a pure object oriented programming") no_space("a b c d e f g") no_space("tomorrow is a wednesday") def no_s(b) puts b.split.join(" ") end no_s("Ruby is a pure o...
true
3c4a329a16dda2cd49d9c16900432a4ef76c235f
Ruby
dillonhafer/fizz-buzz
/spec/fizz_buzz_spec.rb
UTF-8
1,453
3.53125
4
[]
no_license
require 'rspec' require 'fizz_buzz' describe FizzBuzz, "#valid?" do it 'fails for numbers less than 1' do fizz_buzz = FizzBuzz.new(0) expect(fizz_buzz.valid?).to eq(false) end it 'succeeds for numbers greater than 0' do fizz_buzz = FizzBuzz.new(1) expect(fizz_buzz.valid?).to eq(true) end end ...
true
c5770c72a357645831c7b0be5e8463e225235f9e
Ruby
phucledien/tudongdkhp
/dkhp.rb
UTF-8
835
2.515625
3
[]
no_license
require 'rubygems' require 'mechanize' class UITDKHP def initialize(id, pass, dsmalop) @a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } @home_page = @a.get('https://dkhp.uit.edu.vn/') @login_form = @home_page.form @login_form.fields[0].value = id @login_form.pass =...
true
66de5b47e7c17f21588d6f95d151cb878b9322f9
Ruby
vasyan/projecteuler
/01_multiples_of_3_and_5.rb
UTF-8
102
3.46875
3
[]
no_license
def main arr = (1..1000).select { |x| x % 3 == 0 || x % 5 == 0 } puts arr.inject(0, :+) end main
true
86fbf7acb8a4f31d63e11aa5cf74934c807d119c
Ruby
vsamaco/elophant
/lib/league_of_legends/items.rb
UTF-8
618
2.78125
3
[]
no_license
require 'json' require 'singleton' module LeagueOfLegends class Items include Singleton attr_accessor :items def initialize(file_name='items.json') load_items(file_name) end def get_name(item_id) @items[item_id] || nil end def get_id(item_name) @items...
true
df30f5df8cddee685e76099232df34a6f8d7fe4a
Ruby
alu0100505023/prct10
/lib/matriz.rb
UTF-8
3,054
3.390625
3
[ "MIT" ]
permissive
require 'matrix' require 'Fraccion.rb' require 'gcd' class Matriz attr_reader :m, :f, :c def initialize(m) @m=m @f=m.size @c=m[1].size end def initialize(f,c,m) @m=m @f=c @c=c end def +(ot...
true
0d248da652752b67288f69342b8327111a502b2b
Ruby
Yoomee/bta
/config/initializers/object_extensions.rb
UTF-8
187
2.578125
3
[]
no_license
class Object def in?(collection) collection.include?(self) end def metaclass class << self self end end def presence self if present? end end
true
7bf8730e814f3961367bbc5a4d92548dde9432d2
Ruby
rhi222/tech_camp
/lesson2/rubyQuiz/kadai2/question1.rb
UTF-8
431
4.03125
4
[]
no_license
class Dog # class variable @@type = "犬" def initialize(name, dog_type) # instance variable @name = name @dog_type = dog_type end def self.say puts "ワンワン" end def say_type puts "わたしは#{@@type}です" end def self_introduction puts "私の名前は#{@name}で種類は#{@dog_type}です" end end dog = Dog.new("マロン", "トイプ...
true
bb794287f61bde7f9e00dda4a18444ae08447736
Ruby
thebravoman/software_engineering_2015
/hm_count_words/B_12_Emiliqn_Gospodinov.rb
UTF-8
564
2.71875
3
[]
no_license
require_relative 'B_12_Emiliqn_Gospodinov/word_counter.rb' word = ARGV[0] if words == '-d' a = a + 1 result = WordCounter.parse_a_folder ARGV[1] else if words.start_with?('https://') or words.start_with?('http://') result = WordCounter.parsing_web_page words end end if words != '-d' if(words.include?(" ")) ...
true
0b248c80f36adb6463dbfe6102dd61d2ced35483
Ruby
RubyCamp/rc2016s_g6
/lib/info_window.rb
UTF-8
440
3
3
[]
no_license
class InfoWindow attr_writer :count def initialize(count) @font = Font.new(25) @count = count end def draw player = Director.instance.player Window.draw_font(10, 10, "残り時間: #{@count}", @font) Window.draw_font(200, 10, "ライフ: #{player.life.to_i}", @font) Window.draw_font(380, 10, "エサ: #{Director...
true
d35749e4e37d4ea70a2841b1f4fda582ea35047a
Ruby
skbkontur/logstash-input-http_file
/lib/logstash/inputs/http_file.rb
UTF-8
4,425
2.65625
3
[ "Apache-2.0" ]
permissive
# encoding: utf-8 require "logstash/inputs/base" require "logstash/namespace" require "stud/interval" require "socket" require "http" require "base64" require "stringio" class LogStash::Inputs::HttpFile < LogStash::Inputs::Base class Interrupted < StandardError; end config_name "http_file" default :codec, "plain...
true
626800a37d413e1cd8971cc9ca66ec2c1903970b
Ruby
krishnau2/piggy-bank
/app/models/wishlist_account.rb
UTF-8
1,105
2.703125
3
[]
no_license
class WishlistAccount < Account def total_deposit AllocationTransaction.total_deposit(self) end def total_withdrawal AllocationTransaction.total_withdrawal(self) end def net_amount total_deposit - total_withdrawal end def total_deposit_in_selected_bank(selected_bank_transaction_ids) ...
true
d14c2479038814b0bd3005cf4d8be18a0c7c0972
Ruby
12Starlight/App-Academy-Master
/AppAcademyFoundations/W2D1/Dave_Gagnat_blocks_project/lib/part_2.rb
UTF-8
929
3.28125
3
[]
no_license
# Build Main Method =begin # My Working Solution def all_words_capitalized?(words) # if words.any?(&:downcase) # return false # elsif words.all?(&:capitalize) # return true # end # true == words.all?(&:capitalize) words.all? do |word| words.include?(word.capitalize) end end =end def...
true
2b3b09d026a8e8778dbacb01afcf612dfac02374
Ruby
tomoasleep/yoda
/lib/yoda/has_services.rb
UTF-8
918
2.75
3
[ "MIT" ]
permissive
module Yoda module HasServices module ClassMethods # Register a service with the specified name # @params name [String] def service(name, &block) service_hub_class.register_service(name, &block) define_method(:"#{name}_service") { services.public_send(name) } end # @...
true
03bc4bebe0e4ddbf6a19a29c20cbe1437a766072
Ruby
shebesabrina/credit_check-1
/test/credit_check_test.rb
UTF-8
1,815
3.109375
3
[]
no_license
require './lib/credit_check' require './test/test_helper' require 'pry' class CreditCheckTest < Minitest::Test def setup @credit_check = CreditCheck.new(5541808923795240) end def test_it_exists assert_instance_of CreditCheck, @credit_check end def test_it_can_multiple_other_digit_from_right_most ...
true
91bc3268e09577d3f9a9ab9b45d87424c1a07928
Ruby
Huluk/rb-forecast
/geolocation.rb
UTF-8
869
3.109375
3
[]
no_license
require_relative 'json_api' class Coordinate attr_reader :longitude, :latitude def initialize(lat, long) @latitude = lat @longitude = long end end class Geolocation < JsonAPI URL = "https://maps.google.com/maps/api/geocode/json" attr_reader :language def initialize(options) @language = opti...
true
65f823ad73e309193afd2612cbf159c1cbefd170
Ruby
Lykos/cube_trainer
/lib/cube_trainer/utils/random_helper.rb
UTF-8
393
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module CubeTrainer module Utils # A few randomness related helper methods. module RandomHelper # Distort the given value randomly by up to the given factor. def distort(value, factor) raise ArgumentError unless factor.positive? && factor < 1 (value *...
true
57bb80987a1c2082f8730cf88cc468532cdec62a
Ruby
tylerseawell4/ruby
/4-5-2016/Product.rb
UTF-8
434
3.71875
4
[]
no_license
class Product def initialize(type, amount) @type=type @amount=amount end def type @type end def amount @amount end def sell puts "How many #{type}s do you want? I have #{amount} in stock." answer = gets.chomp.to_i if answer > @amount puts "I don't have enough" else puts "You purchased #{an...
true
674e657eb91e53d8a5ffae799c7d24e987370cab
Ruby
DeanHatch/scoreboard-api
/test/models/team_test.rb
UTF-8
1,075
2.578125
3
[]
no_license
require 'test_helper' class TeamTest < ActiveSupport::TestCase # test "the truth" do # assert true # end # test "teams fixtures are valid" do [:heat, :thunder, :lightning, :blizzard].each { |t| assert teams(t).valid? } newteam = Team.new() # no Competition or Grouping or Name assert ! newtea...
true
7beaa627df76605526218f69996f55fb68a9dda0
Ruby
Adush/uberspec
/spec/uberspec/parallel_spec.rb
UTF-8
1,806
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'spec/spec_helper.rb' describe Uberspec::Parallel do before(:each) do @watchr_script = mock('watchr', :watch => nil) @parallel = Uberspec::Parallel.watch(@watchr_script) end context "with only one match" do before(:each) do @parallel.stub(:matches).and_return(['one/match']) end ...
true
c5cab0f3051487bae5a3a5f25c8acd2677e64a14
Ruby
torihuang/phase-0
/week-4/errors.rb
UTF-8
5,909
4.21875
4
[ "MIT" ]
permissive
# Analyze the Errors # I worked on this challenge by myself. # I spent 1 hour on this challenge. # --- error ------------------------------------------------------- cartmans_phrase = "Screw you guys " + "I'm going home." # This error was analyzed in the README file. # --- error -------------------------------------...
true
68f1883e6ac82f6efff9e3db41e5b63348fd903c
Ruby
odongohcoder/teacher-tracker-rubyOO
/teacher_tracker_ui.rb
UTF-8
3,850
3.734375
4
[ "MIT" ]
permissive
require './lib/period' require './lib/student' require './lib/assignment' def welcome puts "Welcome to the Teacher Tracker!\n\n" menu end def menu choice = nil until choice == 'x' puts "Enter 'p' to add a period, 's' to add a student to a period, or 'a' to add an assignment to a student.\n" puts "Ente...
true
688ba65e9430d401e391af00309d5f4bb32c1e15
Ruby
acagirici/method-scope-lab-onl01-seng-pt-012220
/lib/catch_phrase.rb
UTF-8
52
2.59375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def catch_phrase (do) puts phrase end catch_phrase
true
49c030873ec41c37320e4d36c8dbbeb149dd969c
Ruby
cgalindo11/oo-tic-tac-toe-v-000
/lib/tic_tac_toe.rb
UTF-8
4,039
4.1875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe def initialize(board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]) @board = board end def board=(board) @board = board end def board @board end WIN_COMBINATIONS = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], ...
true
9e1f3f7fb45cf34c762ee0fefd44fc936f20eb9d
Ruby
mjago/CW
/lib/cw/reveal.rb
UTF-8
981
2.734375
3
[ "MIT" ]
permissive
# encoding: utf-8 module CW class Reveal < Tester def initialize @reveal_buf = '' puts 'Reveal mode:' end def print_test_advice ; print.print_advice('Test Words') ; end def print_failed_exit_words until stream.stream_empty? @reveal_buf += stream.pop[:value] + ' ' ...
true
59eea6fa3d3e3c110431ca6f3e9109365120caea
Ruby
psalaets/sendspot_scraper
/lib/sendspot_scraper/client.rb
UTF-8
956
2.875
3
[ "MIT" ]
permissive
require 'open-uri' module SendspotScraper # Sendspot client that retrieves route feed xml. class Client # Public: Create a new client. # # location_ids - Location ids or Array of location ids to check for new # routes. These should be the ids used in sendspot as 'gid', # ...
true
18d877529aaecb37e8fa3136925f71a41a148c52
Ruby
biancini/Puppet-Gluster
/garr/garrbox/lib/puppet/parser/functions/listbricks.rb
UTF-8
2,822
2.796875
3
[]
no_license
require 'openssl' require 'open-uri' require 'json' module Puppet::Parser::Functions newfunction(:listbricks, :type => :rvalue, :doc => <<-EOS This function generates a list of Gluster bricks by host or by volume interrogating a MySQL database. Paremeters to this function are: - the url_base to be used for querie...
true
6f75b9f989556218b7701f01059ef4b290cff8c6
Ruby
AnkurGel/Backup
/Project_Euler/25.rb
UTF-8
874
4.15625
4
[]
no_license
#Defining Fibonacci generator fibonacci=Enumerator.new do |yielder| a,b=1,1 while a yielder.yield a a,b=b,a+b end end #Adding specific_select filter to Enumerator class Enumerator def specific_select(&block) #which will expect a block and ofcource, enumerator will be passed as self ...
true
d162527a95bb3130d254950a0d2f247235ac3769
Ruby
mweems/space_attack
/lib/spaceship.rb
UTF-8
541
3.171875
3
[]
no_license
class Spaceship attr_reader :attack, :start_defense attr_accessor :defense, :fleet def initialize(attack=1, defense=1) @attack = attack @defense = defense @start_defense = defense end def to_s "#{self.class} - (attack:#{@attack} defense: #{@defense})" end def alive? @defense > 0 end def dead! ...
true
5a44b1ab3dc973d6157caa1092fd136f04a2ff4a
Ruby
cstatro/OO-mini-project-nyc-web-062419
/tools/console.rb
UTF-8
1,262
2.765625
3
[]
no_license
require_relative '../config/environment.rb' # seeding ingredients flour = Ingredient.new("flour") sugar = Ingredient.new("sugar") baking_soda = Ingredient.new("baking soda") butter = Ingredient.new("butter") eggs = Ingredient.new("eggs") vanilla = Ingredient.new("vanilla") # seeding users alex = User.new("Alex") coli...
true
3925ab9c14936dc359abfc597b97378b814fd5ee
Ruby
jakemeout/Flatiron-June-October-2020
/cli-applications-jukebox-nyc01-seng-ft-062220/lib/jukebox.rb
UTF-8
1,434
4.03125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def help puts "I accept the following commands:" puts "- help : displays this help message" puts "- list : displays a list of songs you can play" puts "- play : lets you choose a song to play" puts "- exit : exits this program" end def list(songs) songs_arr = songs songs_arr.each_with_index do |...
true
f8318e607c9bbea1e6cffab424c3549ab8f102e4
Ruby
Chee-Ho/ar_todos_19-Oct-2015
/app/controllers/controller.rb
UTF-8
870
3.15625
3
[]
no_license
class Controller def self.list tasks = Task.all TaskViews.show(tasks) end def self.add(todo) Task.create(description: todo) puts "Appended" + " " + "'#{todo}'" + " " + "to your TODO list..." end def self.delete(todo) if Task.exists?(todo) task = Task.find(todo) description = task.description ...
true
75db15a92b545172ae655ab87d5d0767f8b7c56d
Ruby
MichaelNaumov/exercism_solutions
/Exercism/ruby/sum-of-multiples/sum_of_multiples.rb
UTF-8
324
3.40625
3
[]
no_license
class SumOfMultiples def initialize(*factors) @factors = factors end def to(max) return 0 if @factors.delete(0) sum = 0 multiples = [] @factors.each do |factor| (factor...max).each do |step| multiples << step if step % factor == 0 end end multiples.uniq.sum end ...
true
cef346e9dafefcf7aa3b6ae6c196675c571ad7b0
Ruby
crichey/ActiveDocument
/test/integration/finder_test.rb
UTF-8
1,660
2.578125
3
[]
no_license
require "test/unit" $:.unshift File.join(File.dirname(__FILE__), "../../src", "lib") require 'rubygems' require 'test/unit' require 'ActiveDocument/finder' require 'ActiveDocument/active_document' class FinderTests < Test::Unit::TestCase class Book < ActiveDocument::Base config 'config.yml' end # Called b...
true
71ce006bf3a906bd66494b85f11596c93cdff95c
Ruby
jcat1504/learningrubypt2
/ex45.rb
UTF-8
164
2.828125
3
[]
no_license
def execute(block) block.call end execute { puts "Hello from inside the execute method!" } #Why does this have an error? #Because there's no & sign in (block)!
true
8fca3662def79b2dd3ee900dd48f004b3bfa5d92
Ruby
opener-project/core
/lib/opener/core/language_error.rb
UTF-8
535
2.75
3
[ "Apache-2.0" ]
permissive
module Opener module Core ## # Error class that can be used by components whenever they encounter an # unsupported language. # # @!attribute [r] language # @return [String] # class UnsupportedLanguageError < StandardError attr_reader :language ## # @param [String] l...
true
e407122b0b0f0710eceb8c8033df7e5cc11f1178
Ruby
mieko/coalesce
/lib/coalesce/combiner.rb
UTF-8
4,647
2.953125
3
[ "MIT" ]
permissive
module Coalesce class Combiner attr_reader :attribute, :with, :options, :compact def initialize(attribute, with: nil, compact: true, **options, &block) if with && block fail ArgumentError, 'cannot provide both :with and block' end # default to the block if given, or :array @w...
true
c7a62d5cad1b57a0ac2d1864faf1e4f0033f6d52
Ruby
zooniverse/caesar
/app/models/conditions/conjunction.rb
UTF-8
329
2.96875
3
[ "Apache-2.0" ]
permissive
module Conditions class Conjunction attr_reader :operations def initialize(operations) @operations = operations end def to_a ["and"] + @operations.map(&:to_a) end def apply(bindings) @operations.reduce(true) { |memo, operation| memo && operation.apply(bindings) } end ...
true
8e05f367cbe24453661c3882c2d9cee4c523e855
Ruby
quentincrida/Project1
/models/specs/wine_spec.rb
UTF-8
470
2.625
3
[]
no_license
require('minitest/autorun') require('minitest/reporters') require_relative('../wine') require('pry') MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new class TestWine < MiniTest::Test def test_can_create_new_wine wine_details = { "name" => "Syrah", "description" => "red", "stoc...
true
ab7b9a312aef8a0f6c8a8f2ea45c9d9ca3c45108
Ruby
srawlins/dvds_release_dates
/dvds_release_dates.rb
UTF-8
2,391
3.140625
3
[]
no_license
require 'nokogiri' require 'open-uri' require 'date' class DVDsReleaseDates attr_accessor :urls def initialize(url) @urls = [url] if url =~ /(\d+)\/(\d+)\/DVD-Releases-(\w+)-(\d+).html/ @year = $1.to_i @month = $2.to_i puts "Month: #{$3}, Month Number: #{$2}" end @titles = {} ...
true
295b5091ac7908541c5abd0c83e93b18f1b9da6e
Ruby
lydianblues/xbar
/examples/basic.rb
UTF-8
4,196
2.90625
3
[]
no_license
require 'active_support' require 'active_record' require 'xbar' require_relative 'helpers/server' module XBar module Examples # # This file demonstrates a number of XBar features, including # # * +reset+ to install a shard/mirror configuration # * ActiveRecord migration support # * xbar_estab...
true
c7c20146d5b11e1458f1eaed8557fe2ee4d62633
Ruby
johntalio/phase-0-tracks
/ruby/hashes.rb
UTF-8
2,018
4.1875
4
[]
no_license
# Allow the user to enter their information with gets.chomp puts "Please enter the following information:" puts "What is your client's first name?" # I will use variables such as "name" and "age" to capture the user's information. name = gets.chomp puts "What is your client's age?" # I must use get.to_i to ensure t...
true
07c8d98c344bf369edeec03bcbb72960e817315d
Ruby
seven1m/bible_ref
/spec/bible_ref/reference_spec.rb
UTF-8
13,166
3.28125
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- require_relative '../spec_helper' describe BibleRef::Reference do subject { BibleRef::Reference.new('John 3:16') } describe '#reference' do it 'returns the user-supplied reference' do expect(subject.reference).to eq('John 3:16') end context 'given a single chapter book' ...
true
1c280e46f5e4fbd47b465eb30afc8ee0b78a71e0
Ruby
owlerdev/owler-backend
/app/models/event.rb
UTF-8
1,074
2.515625
3
[]
no_license
class Event < ActiveRecord::Base # Settings for Geokit acts_as_mappable :default_units => :miles, :default_formula => :sphere, :lat_column_name => :lat, :lng_column_name => :lng before_save :default_values attr_accessible :name, :start_t, :address, :lat,...
true
d0f28447baa29e89e3e0c8ecfaac561c7ef381a0
Ruby
emilwall/gitflow-repo-report
/report_repository.rb
UTF-8
358
2.875
3
[]
no_license
require 'yaml' require_relative 'models/report.rb' class ReportRepository def self.latest load list.first end def self.list list = Array.new Dir.foreach('reports') do |item| next if item == '.' or item == '..' list.push item end list.sort.reverse end def self.load(name) YAML.load(File.read(...
true