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
e765d0fe586b49b4a84f5ae426e18ba1baa0e9f9
Ruby
tatakau-kappa/kappa_api
/lib/external_provider/adapter_store.rb
UTF-8
904
2.75
3
[]
no_license
require 'external_provider/adapters' module ExternalProvider class AdapterStore class NotImplementedAdapter < StandardError; end # @param [String, Symbol] provider # @param [Class, String] klass def register(provider, klass) adapters[provider] = klass.to_s end # @raise [NotImplemented...
true
40d9e0a0c44359b9b8047b0f0258d25cd9ae07b9
Ruby
GSmes/ruby-exercises
/command-query/drops.rb
UTF-8
119
2.875
3
[ "MIT" ]
permissive
class Drops def initialize @drips = 0 end def count @drips end def drip @drips += 1 end end
true
fe628973e62110c686068cd1ddddc9ea2ce17b0f
Ruby
jatin-baweja/ruby-exercise
/exercise18/lib/sum_time.rb
UTF-8
1,080
3.5625
4
[]
no_license
require_relative "string" def get_adjusted_time_and_extra(time1, time2, extra = 0, adjuster = 60) total = Integer(time1) + Integer(time2) + extra return (total % adjuster).to_s.rjust(2, '0') , total / adjuster end def add_and_adjust_time(time1, time2) total_time = [] total_time[2], extra_minute = get_adjusted_t...
true
74f50674a456778e29a923d431f34f937cdbbd60
Ruby
AlvaroTovarDev/sei40
/week8/recursion/countdown.rb
UTF-8
1,184
4.625
5
[]
no_license
# iterative version def countdown( n=8 ) while n >= 0 puts n # Do something each iteration that gets us # incrementally closer to getting out of # this loop: n = n - 1 sleep 0.3 # drama end # while puts "Blast off!" end #countdown # actually run the above function # countdown() ...
true
2d95a947336c67a01e37aca6b50fdb7782cbc306
Ruby
Henry1776/ejercicios_ruby_henry
/22_methods2.rb
UTF-8
246
3.203125
3
[]
no_license
def say_hello(name,last_name="rojas") #ESTO ES UN PARAMETRO POR DEFECTO. horoscope = "capricornio" "hola#{name.capitalize} #{last_name.capitalize}, pura vida #{horoscope}" end puts say_hello("james", "hetfield") puts say_hello ("james")
true
6610c2df8c0aff335b0989055c1b91798274a36c
Ruby
elan0baharie/tamagotcha
/lib/tamagotchi.rb
UTF-8
1,962
3.296875
3
[]
no_license
class Tamagotchi @@tamagotchi = [] def initialize (name) @name = name @food = 10 @sleep = 10 @activity = 10 @creation_time = Time.new() @id = @@tamagotchi.length() + 1 end def food_level @food end def id @id end def time @creation_time end def name @name...
true
36bef0a1aa4c92b23169184e666c9cc2c13bbb22
Ruby
TheObtuseAutodidact/SuperFizz
/super_fizz.rb
UTF-8
1,921
4.375
4
[]
no_license
# In this assignment you'll implement an algorithm that is actually used in some programmer interviews. And the really shocking part is that some people fail it! This is an extension of the FizzBuzz problem. Write an implementation of the following algorithm. # # Iterate through the numbers 0 through 1000 and for each ...
true
eb4e8488d5f6f9585ac68e2a51b8306ec827b727
Ruby
ActiveCampaign/queueing_rabbit
/lib/queueing_rabbit/misc/inheritable_class_variables.rb
UTF-8
596
2.578125
3
[ "MIT" ]
permissive
module QueueingRabbit module InheritableClassVariables def inheritable_variables(*args) @inheritable_variables ||= [:inheritable_variables] @inheritable_variables += args end def inherited(subclass) @inheritable_variables ||= [] @inheritable_variables.each do |var| i...
true
93d29d3d2bb506c6f6bf0799d81442a68fc708d0
Ruby
rails/rails
/actioncable/test/channel/base_test.rb
UTF-8
8,210
2.65625
3
[ "MIT", "Ruby" ]
permissive
# frozen_string_literal: true require "test_helper" require "minitest/mock" require "stubs/test_connection" require "stubs/room" class ActionCable::Channel::BaseTest < ActionCable::TestCase class ActionCable::Channel::Base def kick @last_action = [ :kick ] end def topic end end class Bas...
true
6491c7ec57ba96cde3a24f5550c17d3651ec8c5f
Ruby
NancyKo/learn-to-program
/chapter_10/problem_2.rb
UTF-8
2,023
4.5
4
[]
no_license
def sort(some_array) # This "wraps" recursive_sort. recursive_sort(some_array, []) end def recursive_sort(unsorted_array, sorted_array) # Your fabulous code goes here. sorted_array = [] until unsorted_array.length == 0 sorting_word = unsorted_array.min(1).pop index = unsorted_array.find_index(sorting_word...
true
3adebb997f7e4ca5f9dd4a6592482ccc9495975b
Ruby
GuiRokk/CodeSaga
/2saga-lib/array-odd-even/lib/arrays.rb
UTF-8
316
2.859375
3
[]
no_license
class Arrays def self.converte_impares_por(lista, numero) impares = lista.select(&:odd?) multiplo = impares.map{|e| e*numero} res=[impares,multiplo] end def self.converte_pares_por(lista, numero) pares = lista.select(&:even?) multiplo = pares.map{|e| e*numero} res=[pares,multiplo] end end
true
4233af439b55501e10bed09bd086b0e95e880f1b
Ruby
rodloboz/lecture-243
/api_demo.rb
UTF-8
414
3.203125
3
[]
no_license
require 'json' require 'open-uri' require 'byebug' # TODO - Let's fetch name and bio from a given GitHub username BASE_URL = 'https://api.github.com' puts "What's your Github username?" username = gets.chomp url = "#{BASE_URL}/users/#{username}" # open(url).read => String serialized_user = open(url).read user = JS...
true
99397fe082fa5147ebf1520ff0ef056e45cbca5c
Ruby
neyo666/exam2
/src/commands/isbn_search_command.rb
UTF-8
426
3.296875
3
[]
no_license
require_relative 'user_command' class ISBNSearchCommand < UserCommand def initialize (data_source) super (data_source) @isbn = '' end def title 'ISBN Search' end def input puts title print "Enter an ISBN? " @isbn = STDIN.gets.chomp end def execute result = @data_source.is...
true
b46a8140460f0d58565a2898406322bfe27dc89a
Ruby
linrock/yclist
/web/app/models/cohort_records.rb
UTF-8
626
3.171875
3
[ "MIT" ]
permissive
# For reading/writing records for one cohort class CohortRecords def initialize(cohort) @cohort = cohort end def company_rows_from_file TextDataFileLoader.new.get_cohort(@cohort) end def rewrite!(company_rows = nil) company_rows ||= company_rows_from_file TextDataFile.new(cohort_filename)....
true
b5c648f40940d47242e128190bf25ee553655a84
Ruby
jgonera/wabbitholes
/lib/mediawiki/extractor.rb
UTF-8
359
2.546875
3
[]
no_license
require "nokogiri" module Mediawiki class LinkExtractor def initialize(html) @doc = Nokogiri::HTML(html) @doc.css('.hatnote, .infobox, .metadata, .thumb').remove end def wikilinks links = {} @doc.css('a[href^="/wiki/"]').each do |link| links[link["title"]] = true e...
true
5ec909a6743bd5cdf0ed0a627973fc1a24f28906
Ruby
dlugo06/practice
/sort_bits.rb
UTF-8
308
3.5625
4
[]
no_license
def sort_in_place(arr) left = 0 right = arr.length - 1 while left < right left += 1 while arr[left] == 0 right -= 1 while arr[right] == 1 if left < right arr[left], arr[right] = arr[right], arr[left] end end p arr end arr = [1,0,0,0,1,1,0,0,1,1,0,1,0,1] sort_in_place(arr)
true
d78705149f6cac34401d65ce1452def892724bd8
Ruby
bfrey08/night_writer
/lib/night_writer.rb
UTF-8
1,367
3.6875
4
[]
no_license
require './lib/message.rb' require './lib/library.rb' class NightWriter attr_reader :lib, :english_msg def initialize(input_file, export_file) @english_msg = Message.english(input_file, self) @lib = Library.new end def translate #Iterate over english_msg (array) and find + replace each element...
true
0ed1a00ca506985c83f1c6e769067b621992209c
Ruby
flowcommerce/solidus
/.pryrc
UTF-8
776
2.609375
3
[ "MIT" ]
permissive
require 'awesome_print' require 'clipboard' # nice object dump in console Pry.print = proc { |output, data| out = if data.is_a?(Hash) JSON.pretty_generate(data).gsub(/"(\w+)":/) { '"%s":' % $1.yellow } else data.ai end output.puts out } class Object # copy data to memory def cp data data = JS...
true
5d7d68e741afd42eb6dc11fd4672c1f8393aa121
Ruby
Akalaimakalai/Thinknetica
/lesson-04/test.rb
UTF-8
252
3.0625
3
[]
no_license
class Test def find_train puts "Введите номер поезда." number = gets.chomp.to_i break if number == 0 train = number return train if train puts "Нет такого поезда." find_train end end
true
c6fddb64fbe39a13f8e6f329fdd844b4847c2ab4
Ruby
chriskay25/square_array-online-web-prework
/square_array.rb
UTF-8
127
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def square_array(array) sq_array = [] array.each do |i| square = i ** 2 sq_array.push (square) end sq_array end
true
5d11274633e85786f936cabde789d71ffeacd40a
Ruby
rootstrap/rs-code-review-metrics
/app/services/builders/chartkick/planned_to_done_average_data.rb
UTF-8
1,037
2.65625
3
[]
no_license
module Builders module Chartkick class PlannedToDoneAverageData < Builders::Chartkick::ProductData def build_data(metrics) @count = 0 @values = values(metrics) return if @values.empty? percentage = (@values.values.inject(:+) * 100) average = percentage.round / @coun...
true
6901449185ea43b22bbcfc6ce33877efb29f1f51
Ruby
ryuchan00/atcoder
/abc071/D.rb
UTF-8
128
2.828125
3
[]
no_license
# https://atcoder.jp/contests/abc071/tasks/arc081_b MOD = 1000000007 N = gets.to_i Ss = Array.new(2) { gets.chomp } puts ans
true
285df7163cc3e6d1bf8c027478b5ebc37fb6b46f
Ruby
zzondlo/chef-console
/lib/chef/resource.rb
UTF-8
958
2.65625
3
[]
no_license
class Chef::Resource attr_reader :name def self.all collection = [] client.get(resouce_path).each do |resouce_name, resouce_url| collection << resouce_class.new(resouce_name, resouce_url) end collection.sort{ |a, b| a.name <=> b.name } end def self.fetch(name) client.get(resouce_pa...
true
b631bb5565ef668c0ac776168b73f37cb8b50086
Ruby
turuthivic/cryptocurrencies_graphs
/app/controllers/currencies_controller.rb
UTF-8
669
2.53125
3
[]
no_license
require "#{Rails.root}/lib/currencies/currency_client.rb" class CurrenciesController < ApplicationController def show @currencies = params[:id] ? params[:id].downcase : '' case @currencies when !Currency.currency_types.include?(@currencies) @currencies = {} else @currencies = set_currencies(@currenci...
true
c096623a17722c3c64fa5cde9238f1090c2ee2a1
Ruby
stpn/libxml-xmlrpc
/test/test_parser_good.rb
UTF-8
3,687
2.828125
3
[]
no_license
require 'test/unit' require 'xml/libxml/xmlrpc/parser' require 'stringio' class TestParserGood < Test::Unit::TestCase def setup @libxml_class = Object.const_defined?("LibXML") ? LibXML::XML : XML end def test_constructor assert_raise XML::XMLRPC::ParserError do XML::XMLRPC::Pa...
true
731d21f1d67152e9ade8000dcabae21d2fcb9ae8
Ruby
JackBShelley/phase-0-tracks
/ruby/solo.rb
UTF-8
2,110
4.5
4
[]
no_license
# define class smeagol # create initialize method with age, location, and persona # about method to print location, age, and persona #allegiance method to randomly change smeagol's alliance # ring location, takes argument. if ring location and smeagol are the same, he becomes gollum #catchphrase method that prints smea...
true
402db45e542bd2ab114747e34450dbcaab8e7b4e
Ruby
VictoriaVasys/credit_check_recheck
/test/card_processor_test.rb
UTF-8
2,064
2.921875
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/card_processor' class CardProcessorTest < Minitest::Test def test_it_exists card_processor = CardProcessor.new(5541808923795240) assert_instance_of CardProcessor, card_processor end def test_card_digits_returns_array_of_card_nu...
true
73b3057ae067764c6e817b3236f77a7fd731ca12
Ruby
NicolePell/backgammon
/spec/unit/point_spec.rb
UTF-8
1,774
3.203125
3
[]
no_license
require 'point' describe Point do let(:point) { Point.new } let(:red) { double :checker, colour: :red } let(:black) { double :checker, colour: :black } context 'when initialized' do it 'is unoccupied' do expect(point.status).to be :empty end end context 'holding checkers' do before(:e...
true
1d4ded321df8c3d86838098a50a417b53396dbfa
Ruby
taw/magic-search-engine
/indexer/lib/patches/patch.rb
UTF-8
1,368
2.78125
3
[ "MIT" ]
permissive
class Patch def initialize(cards, sets, decks) @cards = cards @sets = sets @decks = decks end def each_card(&block) @cards.each(&block) end def each_printing(&block) @cards.each do |name, printings| printings.each(&block) end end def each_set(&block) @sets.each(&block)...
true
d6b6d8a04d72c889f526c72ebec4c7c2b426cf0c
Ruby
by2-be/task_reporter
/lib/task_reporter.rb
UTF-8
620
2.59375
3
[ "MIT" ]
permissive
require "task_reporter/version" require "task_reporter/twitter" require "singleton" require "task_reporter/reporter" require "task_reporter/task" module TaskReporter class NullLogger def method_missing(method, *args) puts "warning: called logger without a logger available" puts " Logger #{method}:...
true
e008e86c7fd3f14694e3eed6e1c1b668dbfbc158
Ruby
CanadianCommander/rbtgen
/lib/schema/generator/schema_generator_service.rb
UTF-8
2,129
2.78125
3
[]
no_license
module Schema module Generator # used to generate schema map files from an existing Oscar / Juno database class SchemaGeneratorService attr_accessor :mysql_client, :limit_tables # ---------------------------------------------------------- # Public Methods # --------------------------...
true
117326a96e815041aa3968e22c6536d887d7e718
Ruby
ttyigrs/practice-ruby
/lesson6.rb
UTF-8
243
3.21875
3
[]
no_license
total_price = 200 if total_price > 100 puts "みかんを購入。所持金に余りあり。" elsif total_price == 100 puts "みかんを購入。所持金は0円" else puts "みかんを購入することはできません。" end
true
644c406dcd2cb1d4365b788187b8ac27ea28fc63
Ruby
github/codeql
/ruby/ql/test/library-tests/frameworks/http_clients/NetHttp.rb
UTF-8
486
2.703125
3
[ "MIT" ]
permissive
require "net/http" uri = URI.parse("https://example.com") Net::HTTP.get(uri) resp = Net::HTTP.post(URI.parse(uri), "some_body") resp.body resp.read_body resp.entity req = Net::HTTP.new("https://example.com") r1 = req.get("/") r2 = req.post("/") r3 = req.put("/") r4 = req.patch("/") r1.body r2.read_body r3.entity r...
true
4b375e03a5932a123caef64c9dec83b6d6f51417
Ruby
sparklemotion/nokogiri
/lib/nokogiri/xml/parse_options.rb
UTF-8
7,368
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LicenseRef-scancode-other-copyleft", "LGPL-2.1-only", "X11", "GPL-1.0-or-later", "MPL-2.0", "LicenseRef-scancode-x11-xconsortium-veillard", "LicenseRef-scancode-warranty-disclaimer", "Zlib", "AGPL-3.0-only", "LGPL-2.0-o...
permissive
# coding: utf-8 # frozen_string_literal: true module Nokogiri module XML # Options that control the parsing behavior for XML::Document, XML::DocumentFragment, # HTML4::Document, HTML4::DocumentFragment, XSLT::Stylesheet, and XML::Schema. # # These options directly expose libxml2's parse options, whic...
true
416d83723946de8df9049de6bc9ab142b73b7ff6
Ruby
WodaKyon/RGSS
/Game Scripts/世紀之卡(Carte-De-Sentinelle)/Scripts/054 - Window_Base.rb
UTF-8
24,917
2.625
3
[ "Apache-2.0" ]
permissive
#encoding:utf-8 #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ #  游戲中所有窗口的父類 #============================================================================== class Window_Base < Window #---...
true
200caaf2c319565abb5a1ebb7d83e2d371cb23a7
Ruby
franckverrot/blake2
/lib/blake2.rb
UTF-8
832
3.0625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'blake2_ext' require 'blake2/key' class Blake2 def self.hex(input, key = Blake2::Key.none, out_len = 32) check_if_valid!(input, key, out_len) Blake2.new(out_len, key).digest(input, :to_hex) end def self.bytes(input, key = Blake2::Key.none, out_len = 32) check_if_valid!(input, key, out_len) ...
true
60fb093b9d0653ad03abbba72440339edb7de5a5
Ruby
jeff-flatiron-bootcamp/advanced-hashes-hashketball-seattle-web-012720
/hashketball.rb
UTF-8
5,207
3.15625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def game_hash main_hash = {:home => {:team_name => "", :colors => [], :players => []}, :away => {:team_name => "", :colors => [], :players => []}} home_head_data = {:side => "home", :team_name => "Brooklyn Nets", :colors => ["Black", "White"]} away_head_data = {:side => "away", :team_name => "Charlotte Horne...
true
f61e90fe0be0f46877c7953ead1b40dae092b3e7
Ruby
Benauld/Oystercard2
/Lib/journey_log.rb
UTF-8
676
2.96875
3
[]
no_license
require_relative 'journey' class JourneyLog attr_reader :journey_log def initialize(journey_class) @journey_class = journey_class @journey_log = [] end def in_journey? if @journey_log == [] false else p "journey lon in in journey" p @journey_log !@journey_log.last.com...
true
f0b4c032d38b74fe1cef2c3e6d56759af6cd1ea3
Ruby
bebcovi/interview-app
/core/banking.rb
UTF-8
508
2.671875
3
[]
no_license
require "./core/plaid_gateway" require "./core/company_data" module Banking extend self def find_plaid_user(public_token) user = PlaidGateway.find_user(public_token) fill_transactions_with_company_data(user) user end private def fill_transactions_with_company_data(user) transactions = user...
true
e8d83145577d00e8c21770a45d5649f6c15d50a1
Ruby
noahgibbs/statuesque
/test/simple_description_test.rb
UTF-8
901
2.5625
3
[]
no_license
require "test_helper" class SimpleDescriptionTest < Scope::TestCase context "A simple world" do setup do @world = Statuesque::World.new @world.adj_subtype :red, :scarlet, :maroon, :fuchsia @world.adj_subtype :small, :tiny @world.adj_subtype :colored, :red, :green @world.adj_synonyms...
true
ddfc2704f7fdfa2c272bfb257727b3930e6aea88
Ruby
svenfuchs/taka
/lib/taka/dom/html/table_row_element.rb
UTF-8
1,052
2.53125
3
[ "MIT" ]
permissive
module Taka module DOM module HTML module TableRowElement def rowIndex parent_table = self.parent while parent_table.name != 'table' parent_table = parent_table.parent end parent_table.rows.each_with_index do |row, i| return i if row =...
true
583c122a95bf24a676ced0809868553b861b12a4
Ruby
Samkiroko/Ruby_udemy_course
/module_mixins.rb
UTF-8
3,233
4.125
4
[]
no_license
# what is a module? # A module is toolbox or container of methods and constants # module methods and constants can be used as needed # modules creates namespaces for methods with the same name # modules connot be used to creat instances # modules can be mixis into classes to add behavior module LengthConversions WEB...
true
ed093083825375e9622565f65f40491adfa549c3
Ruby
dpmontooth/rb101
/small_problems/medium_1/rotation_2.rb
UTF-8
652
4.125
4
[]
no_license
# problem: write method to rotate last n digits of a number # input: two integers as parameters - 1st is number and 2nd is number of digits # to rotate # # output: number with last n digits rotated # # assumptions: n is always a positive integer # # ------algorithm------ # define method to accept two integers as argum...
true
c3c02596bfa6d262206d56df1cc1b89ff7f29af5
Ruby
tdeo/advent_of_code
/2019/test/01.rb
UTF-8
491
2.875
3
[]
no_license
# frozen_string_literal: true require 'minitest/autorun' require_relative('../lib/01_the_tyrannyofthe_rocket_equation') describe TheTyrannyoftheRocketEquation do before { @k = TheTyrannyoftheRocketEquation } def test_part1 assert_equal(2 + 2 + 654 + 33_583, @k.new('12 14 1969 100756').part1,) end def te...
true
296968123b9f4a88146183e1fe0faaa9e8259d84
Ruby
relaton/relaton-ieee
/lib/relaton_ieee/xml_parser.rb
UTF-8
1,889
2.640625
3
[ "MIT" ]
permissive
module RelatonIeee class XMLParser < RelatonBib::XMLParser class << self private # Override RelatonBib::XMLParser.item_data method. # @param item [Nokogiri::XML::Element] # @returtn [Hash] def item_data(item) # rubocop:disable Metrics/AbcSize data = super ext = item....
true
247a4c0334ec14954c74765db4c996d18ec400f8
Ruby
cheezenaan/procon
/atcoder/abc168/d.rb
UTF-8
425
2.90625
3
[]
no_license
n, m = gets.split.map(&:to_i) graph = Array.new(n + 1) { [] } m.times do a, b = gets.split.map(&:to_i) graph[a].push(b) graph[b].push(a) end dist = Array.new(n + 1, -1) dist[1] = 0 que = [] que.push(1) ans = Array.new(n + 1, -1) until que.empty? v = que.shift graph[v].each do |nv| next if dist[nv] ...
true
27ebf734f972f8ab6ad3743567fda094367530f0
Ruby
SeanLuckett/project_surveyor
/app/helpers/multi_choice_question_helper.rb
UTF-8
276
2.59375
3
[]
no_license
module MultiChoiceQuestionHelper def decorate_questions(questions) questions.map { |q| MultiQuestionDecorator.new(q) } end def selected_answer?(question, answer) if question.selected_answers question.selected_answers.include? answer.body end end end
true
928d3bc7715f2555ba6a41b44c8e5f90cc0b2c9f
Ruby
YWHo/ruby_language
/c014.0_hash_variable.rb
UTF-8
281
3.34375
3
[]
no_license
#!/usr/bin/ruby hsh = colors = { "red" => 0xf00, "green" => 0x0f0, "blue" => 0x00f } hsh.each do |key, value| print key, " is ", value, "\n" end puts "-------------------" H = Hash["a" => 100, "b" => 200] puts "#{H['a']}" puts "#{H['b']}"
true
873d362020b69ac0d824cd1b8f755a59b94baf7e
Ruby
olichwiruk/katas
/codekata/09-checkout/20200517/lib/money.rb
UTF-8
236
3.25
3
[]
no_license
# frozen_string_literal: true class Money attr_reader :amount def initialize(amount) @amount = amount end def eql?(other) amount == other.amount end def add(item_price) @amount += item_price.amount end end
true
2826769d8b7812d56c8eef20f1a13c3e0ca836e8
Ruby
infinitered/cdq
/spec/helpers/thread_helper.rb
UTF-8
441
2.6875
3
[ "MIT" ]
permissive
module Bacon class Context # Executes a given block on an async concurrent GCD queue (which is a # different thread) and returns the return value of the block, which is # expected to be either true or false. def on_thread(&block) @result = false group = Dispatch::Group.new Dispatch::...
true
a006d6715d43ed5af2cf16cc2a370122c95047b9
Ruby
dolphin-robot-hands/sample_app
/app/helpers/sessions_helper.rb
UTF-8
776
2.53125
3
[]
no_license
module SessionsHelper # Logs in the given user. def log_in(user) session[:user_id] = user.id end # Returns the current logged-in user (if any). def current_user @current_user ||= User.find_by(id: session[:user_id]) end def logged_in? !current_user.nil? end # Logs out the current user. def log_out session.d...
true
7b544c4e4949888c0dcddeef17da75ecac8b10b7
Ruby
achhetr/medical-ticketing
/views/base_views.rb
UTF-8
253
3.390625
3
[ "MIT" ]
permissive
class BaseViews def display(prompt) puts prompt end def user_input(prompt) puts prompt print "=> " gets.chomp end def list_arr(arr) arr.each_with_index do |item, index| puts "#{index + 1}. #{item}" end end end
true
282c1a4b683129c0e71415c04ab7f0138c9fe5b7
Ruby
linyahu/module-one-final-project-guidelines-nyc-web-career-010719
/db/seeds.rb
UTF-8
9,349
3
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative '../config/environment' # Character.destroy_all # House.destroy_all # CharacterHouse.destroy_all # # c1 = Character.create(name: "c1") # c2 = Character.create(name: "c2") # # h1 = House.create(name: "h1") # h2 = House.create(name: "h2") # # ch1 = CharacterHouse.create(name: "ch1", character: c1, house...
true
7250fd8851d7ef68c4097c9e4153cc18b2cb757f
Ruby
ianfixes/nmea_plus
/lib/nmea_plus/message/nmea/vwt.rb
UTF-8
1,226
2.71875
3
[ "Apache-2.0" ]
permissive
require 'nmea_plus/message/nmea/base_nmea' module NMEAPlus module Message module NMEA # VWT - True Wind Speed and Angle # # True wind angle in relation to the vessel's heading and true wind speed # referenced to the water. True wind is the vector sum of the Relative # (Apparent) win...
true
79b519138fe82fef50248198e000e4caf76ca16d
Ruby
hallbergandrew/Doctor_Office_data
/doctors_office.rb
UTF-8
2,425
3.484375
3
[]
no_license
require 'pg' require './lib/doctor_list.rb' require './lib/patient_list.rb' DB = PG.connect({:dbname => 'office'}) def main_menu puts '*~The Database~*' "\n\n" puts 'Press 1 to add a patient.' puts 'Press 2 to see the patient list.' puts 'Press 3 to add a doctor.' puts 'Press 4 to see the doctor list.' ...
true
8108455e4988d1517b0875fef8b624fb808e3fd7
Ruby
jfleschler/rcp-fb
/app/models/step.rb
UTF-8
1,107
2.875
3
[]
no_license
require 'integer_to_word' class Step include Mongoid::Document field :step_num, :type => Integer field :note, :type => String belongs_to :recipe has_many :associations, :dependent => :destroy #has_many :ingredients, :through => :associations before_destroy :renumber_remaining scope :o...
true
9ce3f22fc31c123344f230a3eda0eb2856fef982
Ruby
Arique1104/colorado_lottery
/lib/contestant.rb
UTF-8
587
3.140625
3
[]
no_license
class Contestant attr_reader :full_name, :age, :state_of_residence, :spending_money, :game_interests def initialize(contestant_info) @full_name = "#{contestant_info[:first_name]} #{contestant_info[:last_name]}" @age = contestant_info[:age] @state_of...
true
e8f622b0444998e1f0c6651fdd1130d467c5dac2
Ruby
atl-code-immersion/ruby-winter17
/hash_example.rb
UTF-8
631
3.828125
4
[]
no_license
puts "Tell us about yourself..." profile = {} puts "What's your name?" profile["Name"] = gets.chomp puts "What's your age?" profile["Age"] = gets.chomp puts "What city did you grow up in?" profile["Hometown"] = gets.chomp puts "What's your favorite food?" profile["Favorite Food"] = gets.chomp # profile = {"Name"=...
true
0495c058eeb5be81e8bae777d87d9c04e1e17baf
Ruby
lazarentertainment/active_attr
/spec/unit/active_attr/typecasting/time_typecaster_spec.rb
UTF-8
1,383
2.625
3
[ "MIT" ]
permissive
require "spec_helper" require "active_attr/typecasting/time_typecaster" module ActiveAttr module Typecasting describe TimeTypecaster do subject(:typecaster) { described_class.new } describe "#call" do it "returns nil for nil" do typecaster.call(nil).should equal nil end ...
true
fbb20158928fb864579b0fe74a09c969afbdef04
Ruby
machty/emberspective
/app/models/status_node.rb
UTF-8
4,547
2.515625
3
[]
no_license
require 'yaml' class StatusNode include ActiveModel::Serialization attr_accessor :name, :description, :author, :updated_at, :children, :version, :latest_child_version def attributes { 'name' => name, 'description' => description, 'author' => author, 'updated_at' => updated_at, ...
true
c2b549bedd7c60c91a5f1ef8501b76949d0ec9a7
Ruby
bustle/realtime-model
/lib/realtime_model/result_set.rb
UTF-8
1,731
2.6875
3
[ "MIT" ]
permissive
module RealtimeModel class ResultSet include Enumerable attr_accessor :buffer attr_accessor :key attr_accessor :min_buffer_size attr_accessor :max_buffer_size def each if @buffer cursor = 0 buffer_size = @min_buffer_size begin results = redis_result_s...
true
910bc628e2047bb039eaf4ba93350eb0658fed7a
Ruby
mdub/dotfiles
/bin/wordle-cheat
UTF-8
630
3
3
[]
no_license
#! /usr/bin/env ruby require "clamp" Clamp do parameter "PATTERN", "word pattern" do |arg| Regexp.new("^#{arg}$") end parameter "[INCLUDED]", "other included letters", default: "" parameter "[EXCLUDED]", "excluded letters", default: "" def execute File.new("/usr/share/dict/words").each_line do |...
true
a7c7402ea60862066a87c213abf570d0a49b944d
Ruby
xwjdsh/ruby-examples
/constants/constants.rb
UTF-8
668
4
4
[ "MIT" ]
permissive
class Class1 # A constant doesn’t require any special symbol or syntax to declare, # just make the first letter an uppercase letter, valid constants: ABC = "ABC" Goo = "Goo" end puts Class1::ABC # constant can change because variables in Ruby are not containers, they are simply pointers to objects. Class1::G...
true
98c698e54a8e1fa468b44d2b10f6be7ac24b2dde
Ruby
richweiss/volleypong_gosu
/ball_class.rb
UTF-8
505
2.625
3
[]
no_license
class Ball < GameObject WIDTH = 25 HEIGHT = 25 attr_reader :v def initialize(x, y, v) @image = Gosu::Image.new("img/pangolin_0.png") super(x, y, WIDTH, HEIGHT) @v = v end def reflect_horizontal v[:x] = -v[:x] end def reflect_vertical v[:y] = -4 end def update self.x +=...
true
1d6e8f2109cecb6d4fdf87deaeff3a57db858009
Ruby
april-guerin/kwk-l1-ruby-strings-kwk-students-l1-omaha-072318
/invitation.rb
UTF-8
625
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Code your prompts here! # Try starting out with puts'ing a string. puts"Hi, you've been invited to a party! What is your name?" puts "What is the guest's name?" guest_name = gets.chomp.capitalize puts "What is the party's name?" party_name = "Best Halloween Party Ever" puts "What will be the date?" da...
true
89b9640d447f3b77ee628a6abc9785544c1faa62
Ruby
Jasonbhaas/jason.haas.jasonbhaas
/d3/invert.rb
UTF-8
231
3.125
3
[]
no_license
list = {"jason" => "12/29/1993", "aaron" => "1/21/1990", "ryan" => "9/16/1991"} def invert(list) list.keys.each do |key| val = list["#{key}"] list.delete("#{key}") list[val] = "#{key}" end puts "#{list}" end invert(list)
true
49385beb555bce4c7241d046c20de700d4c62336
Ruby
christphrd/ttt-3-display_board-example-bootcamp-prep-000
/lib/display_board.rb
UTF-8
272
3.09375
3
[]
no_license
# Define a method display_board that prints a 3x3 Tic Tac Toe Board def display_board vertical_space = " | | " horizontal_space = "-----------" puts vertical_space puts horizontal_space puts vertical_space puts horizontal_space puts vertical_space end
true
ebcd4b16d01faed4962ed32c01e8e46254d38a5c
Ruby
dladowitz/set_class
/lib/dset.rb
UTF-8
952
3.515625
4
[]
no_license
require 'pry' class DSet def initialize(array = []) @hash = Hash.new(false) self.merge(array) end def length @hash.length end def add(element) @hash[element] = true end def include?(element) @hash[element] ? true : false end def delete(element) @hash[element] = false end...
true
5e3c19eae920fc151f9a0e526728bf9891f85d91
Ruby
OkayAtay/myBestTea
/lib/tea.rb
UTF-8
606
2.9375
3
[ "MIT" ]
permissive
require 'pry' require 'open-uri' require 'net/http' class Tea attr_accessor :name, :description, :preparation, :subtypes @@all = [] def initialize(name = nil, url=nil) @name = name @url = url @@all << self end def self.all @@all end def self.create_by_url(name) end def self.print_al...
true
dbb3e518b69f498578ca95089c5fa3a16aa2c879
Ruby
alistairkung/pragmaticruby
/ch12/conditional_variables.rb
UTF-8
425
3.0625
3
[]
no_license
mutex = Mutex.new cv = ConditionVariable.new a = Thread.new do mutex.synchronize do puts "A: I have critical section, but will wait for CV" cv.wait(mutex) puts "A: I have critical section again! I rule!" end end puts "Later" b = Thread.new do mutex.synchronize do puts "B: Now I am critical, but...
true
af0ea8db96773a9215fd6540092ad299a8961584
Ruby
anthonygiuliano/launch-school
/120-object-oriented-programming/oo-exercises/easy-1/ex1.rb
UTF-8
230
3.375
3
[]
no_license
# Which of the following are objects in Ruby? If they are objects, how can you # find out what class they belong to? true.class # => TrueClass "hello".class # => String [1,2,3,"happy days"].class # => Array 142.class # => Fixnum
true
5886fe1390ce5ee55b7606b5676b1c300657b7ca
Ruby
hoshito/AtCoder
/AtCoder Beginner Contest 133/main_a.rb
UTF-8
92
2.96875
3
[]
no_license
n,a,b = gets.chomp.split(" ").map(&:to_i) if a * n < b then puts a * n else puts b end
true
1f743b274cd57419a33d2616996669a0bea21758
Ruby
BrandonJAllison/ruby_practice
/stringInput.rb
UTF-8
546
4.46875
4
[]
no_license
puts "What is your first name?" first_name = gets.chomp puts "What is your last name" last_name = gets.chomp full_name = "#{first_name} #{last_name}" length = full_name.length() puts "Your full name is #{full_name}" puts "Your name reverse is #{full_name.reverse()}" puts "Your name is #{length} characters long" puts "...
true
e7bc14b7d3bb8d80c083eaf08a8bdcb5135566a2
Ruby
bdougie/ruby_session_examples
/bug.rb
UTF-8
290
4.03125
4
[]
no_license
# the problem is return the wrong answer, set a breakpoint to find out what is wrong def powers_of_two(n) new_arr = [] (0..n).to_a.each_with_index do |x, i| # set a print to see what's happening # p i new_arr.push(2*i) end new_arr end puts powers_of_two(2) # [1,2,4]
true
6d19dc82eda9d2ff73b90f30caa4f249e22b9de7
Ruby
gypsydave5/csv-file-renamer
/csv_reader_class.rb
UTF-8
5,305
2.984375
3
[]
no_license
#!/usr/bin/ruby require 'fileutils' class File_rename_csv require 'csv.rb' attr_accessor :seperator, :test_braces, :read_extension, :write_extension, :array_of_files, :space_replacement, :filename_format, :headers, :target_directory, :file_rename_map attr_reader :filename_format_array def initialize(csv_f...
true
76db521d053235693c0a066a637b684c579e1847
Ruby
cheezedigital/projects
/ruby_stuff/friends.rb
UTF-8
161
2.90625
3
[]
no_license
require 'yaml' my_array = [ {name: 'Justin', age: 32} {name: 'Lia', age: 26} ] File.new("friends.yml", "w+") do |new_file| f.write(my_array.to_yaml) end
true
48269445e445c126e687a2db120ada142e969934
Ruby
matthewlee07/MoreDrillsWithRSpec
/lib/fizzbuzz.rb
UTF-8
391
3.921875
4
[]
no_license
class SuperFizzBuzz def run(input) case 0 when input%15 "FizzBuzz" when input%5 "Buzz" when input%3 "Fizz" else input end end end #You don't necessarily need to execute this script to complete this challenge, but how would you "run" this method (pun intended) so that...
true
bb223e08c57dd7bdc7179d1e54571879dd0ad4d0
Ruby
jpastuszek/unicorn-cuba-base
/lib/unicorn-cuba-base/stats.rb
UTF-8
665
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'raindrops' module Stats class MyStruct < Raindrops::Struct def self.new(*members) klass = super(*members) str = '' # add support to increment by more than 1 members.map { |x| x.to_sym }.each_with_index do |member, i| str << "def incr_#{member}(v = 1); @raindrops.incr(#{i}, v); end; " s...
true
95331797b601249277125d17fe89de6b213d2197
Ruby
ThinkSalat/aA-Projects
/W1D5/tic_tac_toe_ai/lib/tic_tac_toe_node.rb
UTF-8
1,403
3.390625
3
[]
no_license
require_relative 'tic_tac_toe' class TicTacToeNode #next_mover_mark = current player attr_accessor :board, :next_mover_mark, :prev_move_pos def initialize(board, next_mover_mark, prev_move_pos = nil) @board, @next_mover_mark, @prev_move_pos = board, next_mover_mark, prev_move_pos end def losing_no...
true
dc79568d808ac8299f32e8ec7887ca159e5045ad
Ruby
chetan/puppet-custom_type_examples
/append/lib/puppet/type/append_if_no_such_line.rb
UTF-8
890
2.765625
3
[]
no_license
Puppet::Type.newtype(:append_if_no_such_line) do @doc = "Ensure that the given line is defined in the file, and append the line to the end of the file if the line isn't already in the file." newparam(:name) do desc "The name of the resource" end newparam(:file) do desc "The file t...
true
4cc6586d72bb2821e30f1de63ab936e207feb149
Ruby
GertjanF/New-Women-Writers
/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
UTF-8
1,653
2.734375
3
[ "MIT" ]
permissive
# # Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands. # # This file is part of New Women Writers. # # New Women Writers is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundat...
true
82d4efcc5748157168594d720840356c15f7aa02
Ruby
ELBootcamp/RubyCamp2018
/3-12-2018/monika/lcd/lib/lcd_digit.rb
UTF-8
756
3.59375
4
[]
no_license
require 'byebug' class LcdDigit DIGITS = { 0 => '._.|.||_|', 1 => '.....|..|', 2 => '._.._||_.', 3 => '._.._|._|', 4 => '...|_|..|', 5 => '._.|_.._|', 6 => '._.|_.|_|', 7 => '._...|..|', 8 => '._.|_||_|', 9 => '._.|_|..|' }.freeze def build(number) (raise ArgumentErro...
true
af942225104f182a4a4df68fc6b1910ef7b20501
Ruby
harrybournis/capstoneED-api
/app/models/project_evaluation_point.rb
UTF-8
1,072
2.796875
3
[]
no_license
# Historical Data for all points gained through submitting project evaluations. # # @!attribute [r] points # @return [Integer] The points awarded for this instance. # # @!attribute [r] date # @return [DateTime] The date that the points were awarded. # # @!attribute [r] student_id # @return [Integer] The id of the...
true
031dc346378adcf1bef92f6bc5d1c23586d41751
Ruby
abbieneufeld/RB101
/small_problems/medium_1/4.rb
UTF-8
1,129
3.984375
4
[]
no_license
def lights_on(n) array_on =[] lights_hash = Hash.new for i in (1..n) lights_hash[i] = false end for i in (1..n) lights_hash.each_key do |key| if key % i == 0 lights_hash[key] = !lights_hash[key] end end end lights_hash.each do |key, value| if value == true ...
true
529e59e89b512fe507a04815a1dff771ca95d27c
Ruby
djpinchevski/small_problems
/01_easy/06_reverse_it_part2.rb
UTF-8
866
4.71875
5
[]
no_license
=begin Reverse It (Part 2) Write a method that takes one argument, a string containing one or more words, and returns the given string with all five or more letter words reversed. Each string will consist of only letters and spaces. Spaces should be included only when more than one word is present. Examples: puts re...
true
78df6353c82ca58062284e7dc9609a04c9d36d72
Ruby
Tybosis/leet_code
/lib/gcd.rb
UTF-8
305
3.734375
4
[]
no_license
# given two positive integers, write a program that returns the greatest # common divisor of the two integers. # def greatest_common_divisor(x, y) first = [x, y].max second = [x, y].min return first if second == 0 rem = first - (first / second) * second greatest_common_divisor(second, rem) end
true
9798836e1a504c4b3e069bb7f67234f881f629e0
Ruby
norskbrek/ruby-foundations
/small_problems/03_easy2/02.rb
UTF-8
393
3.984375
4
[]
no_license
def prompt(message) puts "--> #{message}" end prompt("Enter the length of the room in meters: ") length = gets.chomp.to_f prompt("Enter the width of the room in meters: ") width = gets.chomp.to_f area_in_meters = (length * width).round(2) area_in_feet = (area_in_meters * 10.7639).round(2) prompt("The area of the...
true
59097b9da29e99c66d461b9a35098f35eaf95c37
Ruby
eldibenedetto/ruby-intro-to-arrays-lab-prework
/lib/intro_to_arrays.rb
UTF-8
472
3.578125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def instantiate_new_array my_new_array = [] end def array_with_two_elements my_two_array = [0, 1] end def first_element(first_element) my_first_element = first_element[0] end def third_element(third_element) my_third_element = third_element[2] end def last_element(array) array.last end def first_element_...
true
88d5158ee09815569c982ecfac2b28c536d5ab15
Ruby
showwin/AtCoder
/abc009/C.rb
UTF-8
382
2.734375
3
[]
no_license
n,k = gets.chomp.split(" ").map { |s| s.to_i } s_o = gets.chomp s_a = s_o.split("") results = [] indexs = [] n.times do |i| indexs << i end cmb = indexs.combination(k).to_a cmb.each do |is| tmp = s_a.clone a = [] is.each do |i| a << s_a[i] end a.sort! is.each_with_index do |i, idx| tmp[i] = a[id...
true
85629b8c3f218d1da91e9ff7796a6ba1270cbb9e
Ruby
nardiyansah/Hackerrank-Solution
/Ruby/plus_minus.rb
UTF-8
394
3.875
4
[]
no_license
def plusMinus(arr) # Write your code here length = arr.length positive = 0 negative = 0 zero = 0 for i in arr do if i > 0 then positive += 1 end if i < 0 then negative += 1 end if i == 0 then zero += 1 end end puts (positive.to_f/length).round(6) put...
true
62a7c1d48ceefa5a7afc955c07e5e49623b45fc2
Ruby
kaylafowler/cinema_db_homework
/models/customer.rb
UTF-8
2,052
3.28125
3
[]
no_license
require_relative('../db/sql_runner.rb') class Customer attr_reader(:id) attr_accessor(:funds, :name) def initialize(options) @id = options['id'].to_i() @name = options['name'] @funds = options['funds'].to_i() end def save() sql = "INSERT INTO customers ( name, funds ) ...
true
58313258f8e85a402d6022a2ee8d1f3946ac9e12
Ruby
prandy87/THPRubyBasics1
/password.rb
UTF-8
438
2.84375
3
[]
no_license
def define_password puts "Choisissez un MDP" print ">" @user_password = gets.chomp end def pass_verif(define_password) puts "veuillez confirmer MDP" print ">" password = gets.chomp while password != @user_password puts "veuillez confirmer MDP" print ">" passwo...
true
3a9d90df5c44e32bf3071e844314c275a02d9be9
Ruby
GIFORTRESS/training
/ifstatement.rb
UTF-8
730
4.34375
4
[]
no_license
# If Statement #A structure we can use in ruby in order to help our programms makes decisions # if Statement makes our programms a little bit smarter # Note the first part of if Statement accepts true options ismale = false isTall = false # if ismale # puts "You are Male!" # else # puts "You are not Male!" # en...
true
711981ee7bfa29efcca0b92c68694bdcbfeb3a53
Ruby
patrick-fulghum/TerminalChess
/lib/display.rb
UTF-8
2,354
3.3125
3
[]
no_license
require 'colorize' require 'byebug' require_relative 'board.rb' require_relative 'cursor.rb' class Display attr_accessor :cursor, :board def initialize(board) @cursor = Cursor.new([6, 4], board) @board = board end def determine_coloring(position, piece) if position == @selectedPosition prin...
true
7435ddde7e82bd33d8417aa189fb691f72c13c8a
Ruby
tiwi/mathematical-formulas
/strategies/smart_eval.rb
UTF-8
483
2.921875
3
[ "MIT" ]
permissive
require './strategies/base' module Strategies class SmartEvalStrategy < Base VALID_EXPRESSION = /\A[0-9\.\+\-\*\/\(\)]*\z/ def evaluate(formula, variables) expression = formula.downcase variables.each do |key, value| expression.gsub!(key.downcase, value) end validate(expressi...
true
3a020f66cfa1cfe475c117720530fdab45503253
Ruby
SAMTHP/Exercices
/exo_11.rb
UTF-8
124
3.265625
3
[]
no_license
puts "Ecris un nombre :" nombre = gets.chomp.to_i a = 1 while a <= nombre do puts " Salut ça farte ? #{a}" a = a + 1 end
true
3d86784119039f9923d669528f10347ea5370464
Ruby
Javran/Thinking-dumps
/7-lang-in-7-wk/ch2-ruby/day-2-try-2_3_7.rb
UTF-8
526
3.859375
4
[]
no_license
#!/usr/bin/env ruby puts 'begin' <=> 'end' # -1 puts 'same' <=> 'same' # 0 a = [6,2,3,4,1] puts a.to_s puts a.sort.to_s puts a.any? { |i| i > 6 } # false puts a.all? { |i| i > 0 } # true # hello map! I've found you! puts a.collect{ |i| [i,i*2] }.to_s # hello filter! puts a.select{ |i| i%2 == 0 }.to_s puts a.max ...
true
1d936b663a971712b770e2b6f3e9eda575ea1497
Ruby
joubin/gitlabhq
/scripts/docs_screenshots.rb
UTF-8
1,423
2.703125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "CC-BY-SA-4.0" ]
permissive
#!/usr/bin/env ruby # frozen_string_literal: true require 'png_quantizator' require 'open3' require 'parallel' require_relative '../tooling/lib/tooling/image' generator = ARGV[0] milestone = ARGV[1] unless generator warn('Error: missing generator, please supply one') abort end unless milestone warn('Error: m...
true
ee66f0fa4c416efa0167b4b876228f9062452ad7
Ruby
richquick/actorsuniversity
/app/controllers/admin/education_assignments_controller.rb
UTF-8
3,601
2.578125
3
[]
no_license
# TECHDEBT - this whole controller was built to handle all the various # different assignments of e.g. course to user, user to group, lesson to # course, course to group. As a result, it's almost certainly fewer lines of # code, but probably overly complex. And definitely now breaking SRP # # In adding in slight diff...
true
3ba30cfdc8ed3e6fc38a9464e959b3e0534b1c77
Ruby
chris-dalrymple/curly-eureka
/project-euler/algorithms/problem3.rb
UTF-8
2,432
3.921875
4
[]
no_license
#!/usr/bin/ruby class Algorithm def sieve_init(target_number) prime_array = Array.new range = (2..target_number) range.each do |count| prime_array.push count end return prime_array end def sieve_of_eratosthenes(target_number) init_array = sieve_init(target_number) init_array.e...
true