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
f566f9bf71cb20703da079d1bf1e390ac89d2a15
Ruby
OmairRaza9/10.16-reinforce
/reinforce.rb
UTF-8
563
3.53125
4
[]
no_license
a = Hash.new (1..50).each do |number| if number % 2 == 0 && number % 7 == 0 a[number] = (number * 2) elsif number % 2 == 0 a[number] = (number + 1) elsif number % 7 == 0 a[number] = (number - 1) else a[number] = number end end puts a # # # if the number is divisible by 2 the value should be ...
true
c9d2f408d8c48083868e593d3afc409e3528f928
Ruby
grantneufeld/metriknit
/lib/metriknit/reader/json_reader.rb
UTF-8
676
2.671875
3
[ "MIT" ]
permissive
# encoding: utf-8 require_relative 'base' require 'json' module Metriknit module Reader # ABSTRACT CLASS # Read in a json data source class JsonReader < Base # Relies on `file` behaving like an (open) IO object - accepting `read`. def parse warnings = [] raw_json = file.read...
true
6dad56699e3a572c839e76acfb1bb4e2221bc7eb
Ruby
ay27/ay27_blog
/plugins/fancybox_tag.rb
UTF-8
992
2.671875
3
[]
no_license
#coding: utf-8 module Jekyll # Usage: # {% fancybox @filename [thumb:@thumb] [@title] %} # {% fancybox @filename [@title] %} class FancyboxTag < Liquid::Tag def initialize(tag_name, markup, tokens) # /(?<filename>\S+)(?:\s+(?<thumb>\S+))?(?:\s+(?<title>.+))?/i # /(?<filename>\S+)(?:\s+(?<ti...
true
773f4cb6a45bc748d18e5f8d9ab99281ce170bdb
Ruby
stewartdesoto/LaunchIntroductoryProgramming
/Basics/movies.rb
UTF-8
187
3.796875
4
[]
no_license
puts "As a hash" movies={StarWars: 1977, Matrix: 1999, ToyStory: 2002} movies.each {|name, year| puts year} puts "As an array" movies=[1977, 2002,1999] movies.sort.each {|year| puts year}
true
0d694165e038c0a7dba95128db35bcd0baaede48
Ruby
JiriStovicek/dev
/scripts/update_stocks.rb
UTF-8
1,388
2.8125
3
[]
no_license
require 'rubygems' require 'nokogiri' require 'open-uri' require 'google_drive' require 'logger' require_relative 'configuration' names = { "ČEZ" => "CEZ", "E4U" => "E4U", "ERSTE GROUP BANK AG" => "ERBAG", "FORTUNA" => "FOREG", "KOMERČNÍ BANKA" => "KOMB", "PEGAS NONWOVENS SA" => "PEGAS", "PHILIP MORRIS ...
true
de08ff72fa56548254f097d42e2dd2c13ef48a20
Ruby
jonnathan/flatiron-hs-summer-missing-labs
/freak-out-todo/freak_out.rb
UTF-8
435
4.09375
4
[]
no_license
#your code goes here my_age = 26 #get user input puts "What is your name?" user_name = gets.chomp puts "What is your age?" user_age_string = gets.chomp user_age_int = user_age_string.to_i #find age difference age_diff = my_age - user_age_int puts "" puts "OMG! NO WAY, GET OUT OF TOWN." puts "Are you #{user_name}?"...
true
ed5e04596ff6d9ad52d42c038b5f9c0b8cbc3f8a
Ruby
Shoshana01/Inheritance_Assignment
/people.rb
UTF-8
473
4.03125
4
[]
no_license
class Person def initialize(name) @name = name end def greeting return "Hi, my name is #{@name}." end end class Student < Person def learn return "I get it!" end end class Instructor < Person def teach return "Everything in Ruby is an Object." end end s...
true
aa564f19c17fb8aebe09976737d0f607f99e2874
Ruby
ddcaldwell87/launch_school
/intro_to_prog/basics/exe5.rb
UTF-8
181
3.15625
3
[]
no_license
# Introduction to Programming with Ruby book chapter Basics exercise 5. puts 5 * 4 * 3 * 2 * 1 puts 6 * 5 * 4 * 3 * 2 * 1 puts 7 * 5 * 4 * 3 * 2 * 1 puts 8 * 7 * 5 * 4 * 3 * 2 * 1
true
92ff1940ca4ea354642fa04e8628f1dee9657944
Ruby
wheatbox-dev/ruby_encryptor
/encryptor.rb
UTF-8
1,319
3.3125
3
[]
no_license
class Encryptor def cipher(rotation) characters = (' '..'z').to_a rotated_characters = characters.rotate(rotation) almost_there = Hash[characters.zip(rotated_characters)] almost_there.store("\n", "\n") almost_there end def encrypt_letter(letter, rotation) cipher_for_rotation = cipher(rot...
true
2ad8b5935bba39acf79993fb1a889c8321ed5fd3
Ruby
ismailakbudak/halisaa.com
/app/models/user_profile.rb
UTF-8
272
2.546875
3
[ "MIT" ]
permissive
class UserProfile < ActiveRecord::Base belongs_to :user validates_presence_of :first_name, :last_name def full_name [first_name, last_name].join(' ') end def self.by_letter(letter) where("last_name LIKE ?", "#{letter}%").order(:last_name) end end
true
734e1e285c7c97193095531469ace7154c25a638
Ruby
ptoomey3/divvy
/lib/divvy/parallelizable.rb
UTF-8
2,526
2.90625
3
[ "MIT" ]
permissive
module Divvy # Module defining the main task interface. Parallelizable classes must respond # to #dispatch and #process and may override hook methods to tap into the # worker process lifecycle. module Parallelizable # The main loop responsible for generating task items to process in workers. # Runs in t...
true
ea5648c4cab004d43b43eddd9ce89415e74004f0
Ruby
Oroko/countdown-to-midnight
/countdown.rb
UTF-8
180
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#write your code here def countdown(n) while n > 0 do puts "#{n} SECOND(S)!" n -= 1 end "HAPPY NEW YEAR!" end def countdown_with_sleep(number) sleep number end
true
2bd6beb89b09c3d08326c6191b68d8d3ea56866e
Ruby
ugoa/ugoaServer
/RubySnippets/MetaprogrammingRuby/RubyObjectModel.rb
UTF-8
330
3.0625
3
[]
no_license
puts class_instance = Class.new puts class_instance.class puts class_instance.class.superclass puts class_instance.superclass puts module_instance = Module.new puts module_instance.class puts module_instance.class.superclass puts module_instance.class.class #The following won't work. #puts module_instance.su...
true
9ef01fb6734e72953aa9066e5938d1b905800d39
Ruby
DMscotifer/rock_paper_scissors
/specs/game_spec.rb
UTF-8
692
2.9375
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require_relative("../game.rb") class GameTest < MiniTest::Test def setup() @game1 = Game.new("scissors", "rock") @game2 = Game.new("rock", "scissors") @game3 = Game.new("rock", "rock") @game4 = Game.new("rock", "paper") end def test_game() ...
true
0dce2438fe09456e14da5a72fd5e3f0e3944ec07
Ruby
leroidejesa/diy_dictionary
/spec/definition_spec.rb
UTF-8
2,622
2.96875
3
[ "MIT" ]
permissive
require('rspec') require('definition') require('word') require('pry') describe(Definition) do before() do Definition.clear() end describe("#word_class") do it("returns the class of word") do test_definition = Definition.new({ :word_class => "noun", :plural_form => "Cacti", :actual_definition => "a...
true
81ef789af92f94b30d7adbd43c0b4eecadeb9cf1
Ruby
go2rob/TicTacToe
/lib/tictactoe.rb
UTF-8
1,981
3.71875
4
[]
no_license
class TicTacToe attr_accessor :token1, :token2, :board def initialize(token1, token2) raise "Tokens cannot be the same." if token1 == token2 @token1 = token1 @token2 = token2 @board = Array.new(3) { Array.new(3) } @current_token = nil end def place(position, token) unless(@game_c...
true
267ba34022e081bb71b68ff7195a5906c0997ec1
Ruby
isildonmez/leetcode
/src/ruby/remove_duplicates.rb
UTF-8
488
3.5
4
[]
no_license
# def remove_duplicates(nums) # nums.uniq! # nums.length # end def remove_duplicates(nums) return nums.length if (nums.length <= 1) idx = 0 length = 0 while nums[idx] el = nums[idx] next_el = nums[idx+1] if (next_el) && (next_el == el) nums.delete_at(idx) else idx += 1 l...
true
1dab11c62713d0c65d1c9bd18d1f542e06daa7bc
Ruby
fanjieqi/LeetCodeRuby
/101-200/164. Maximum Gap.rb
UTF-8
190
3.265625
3
[ "MIT" ]
permissive
# @param {Integer[]} nums # @return {Integer} def maximum_gap(nums) return 0 if nums.length < 2 nums.sort!.map.with_index { |num, i| (i < nums.length - 1) ? nums[i+1] - num : 0}.max end
true
c03d03c35fe624bf1981f36efe0c3e713ac7a708
Ruby
vendetta546/codewars
/Ruby/8KYU/SumMixArray.rb
UTF-8
295
3.671875
4
[]
no_license
=begin Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers. Return your answer as a number. =end # My Solution def sum_mix(x) n = 0 x.each {|x| n += x.to_i} n end # Better Solution def sum_mix(x) x.map(&:to_i).inject(:+) end
true
88102f7a753c8bb67d4b148656a8644b2e7349de
Ruby
BlunderingBeluga/roguelike-tutorial
/src/menu.rb
UTF-8
3,630
3.375
3
[]
no_license
class MenuItem attr_accessor :x, :y attr_reader :name, :item def initialize(name, item = nil) @name = name @item = item if item end def hover?(x, y) return false unless @x and @y y == @y and x >= @x and x < @x + @name.size end def render(background = false) Terminal.print(@x, ...
true
f9e9f60f41f3e7771b471c32927cb276a2cddeac
Ruby
ronyv89/foursquared
/lib/foursquared/pages.rb
UTF-8
2,398
2.96875
3
[ "MIT" ]
permissive
module Foursquared # Pages module module Pages # Return the page with the given ID # @param [String] page_id ID of the page # @return [FOursquared::Response::User] def page page_id response = get("/pages/#{page_id}")["response"] @page = Foursquared::Response::User.new(self, response["us...
true
a8e2fd3f171a29817a826e8689fe14d7a95d8e78
Ruby
dastanabeuov/Ruby
/1-Osnovy-Ruby-polnaya-PO/lesson9/wagon.rb
UTF-8
1,072
3.046875
3
[]
no_license
# frozen_string_literal: true require_relative 'company_name.rb' require_relative 'exeption.rb' require_relative 'info.rb' require_relative 'validate' require_relative 'accessor' class Wagon include CompanyName include Exeption include Validation include Accessors @@wagons = {} attr_reader :number, :type,...
true
385f2b5efe07b0444dbb54bb98ff500bcc36397b
Ruby
FionaDL/ttt-with-ai-project-v-000
/lib/cli.rb
UTF-8
1,200
3.5
4
[]
no_license
class CLI def self.game_assign puts "Welcome to Tic-tac-toe!" puts "Would you like to play with 0, 1, or 2 players?" input = gets.strip if input == "0" puts "I will be X and I will be O!" game = Game.new(Players::Computer.new("X"), Players::Computer.new("O"), Board.new) game.play ...
true
bfd7a6b81113b99f9aae34979e8b56de74ae0525
Ruby
tomabr/Codility
/codility2-2-ruby.rb
UTF-8
385
3.3125
3
[]
no_license
# you can write to stdout for debugging purposes, e.g. # puts "this is a debug message" def solution(a) # write your code in Ruby 2.2 l=a.count-1 arr=[] loop do arr[a[l]-1] = a[l] l-=1 break if l<0 end if arr.count == a.count ...
true
2d1ff4b926648f0a06caa0043ccf7cf06244bcea
Ruby
mikeyduece/event_reporter
/test/commands_test.rb
UTF-8
465
2.609375
3
[]
no_license
require './test/test_helper' require './lib/commands' class CommandsTest < Minitest::Test attr_reader :q, :com def setup @q = Queue.new @com = Commands.new end def test_its_a_thing assert_instance_of Commands, com end def test_can_change_join_second_entry_into_one var = ("find first...
true
2885c0bb3d6d9cfe31d1841b925796a57b4cd72b
Ruby
bnjmnhndrsn/course_work
/checkers/spec/board_spec.rb
UTF-8
760
2.65625
3
[]
no_license
require 'spec_helper' require 'board' describe Board do let(:board){ Board.make_beginning_board } describe "#dup" do it "should return a different board object" do expect(board.dup.object_id).not_to eq(board.object_id) end it "should not change if dup is changed" do duped = b...
true
fec8a58fe4831356116942736dcbf87997940c81
Ruby
sorah/emony
/lib/emony/aggregators/histogram.rb
UTF-8
662
2.734375
3
[ "MIT" ]
permissive
require 'emony/aggregators/base' module Emony module Aggregators class Histogram < Base def initialize(*) super @data = Hash.new(0) end def result @data.to_a.sort_by(&:first) end def state @data end def key @options[:key] ...
true
2456d23151d444973f71a5e8ac1d9616a4721422
Ruby
nschulzke/rails-rpg
/spec/models/map_spec.rb
UTF-8
2,300
2.78125
3
[]
no_license
require 'rails_helper' RSpec.describe Map, type: :model do context "with a blank map" do before :each do @map = Map.create_blank(name: "Map", tile: Tile.first) end it "stores as a 2d integer array" do @map.map.each do |row| row.each do |tile| expect(tile).to be_an(Integer) ...
true
997f37382417ecb0c5533efff448a5d8c3509694
Ruby
reminate/abak_crossposting
/lib/abak_crossposting/facebook/statistics_collector.rb
UTF-8
1,014
2.78125
3
[ "MIT" ]
permissive
module AbakCrossposting module Facebook class StatisticsCollector class << self # Get likes, comments and reposts count for the given post # # Usage # AbakCrossposting::Facebook::StatisticCollector.get_stats("10203831233_535632366321", "ASEWawFADaAsasdHsaytrsrTAZD") ...
true
64ee6e565bbe76f13e9cddaa01b2e1a641bac04f
Ruby
bnv2103/NGS
/RNA_seq/convertGTF.rb
UTF-8
1,911
2.90625
3
[]
no_license
#!/usr/bin/ruby def main() infile = File.new("genes1.gtf", "r") outfile = File.new("genes.gtf", "w") count = 1 infile.each { |line| cols = line.chomp.split(/\t/) array_length= cols.length for key in 0...array_length-1 outfile.write cols[key]+ "\t" end info = cols[array_l...
true
4bf19c6e7a132de412fb77685a7e50a38b00a61a
Ruby
mpospelov/em-sqs-dispatcher
/lib/em-sqs/queue.rb
UTF-8
2,572
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module EM::SQS class Queue # Exceptions class RequestSizeExceeded < StandardError;end # Constans SEND_LIMIT_SIZE = 256.kilobytes.freeze WAIT_TIME_SECONDS = 20 # Long poll timeout POOL_SIZE = 10 attr_reader :url, :name def initialize(name) @url ||= SqsWorker::SQS_CLIENT.get_q...
true
02e295c617f64ea8dda113eb415044bd672cc3e3
Ruby
supreetha-hathwar/ruby_set2
/Polymorphism/polymorphism2.rb
UTF-8
989
4.1875
4
[]
no_license
# Create a class called Person. # Define three other classes i.e student, teacher and parent which should have all the properties of Person. # Define a method which introduces the person with his firstname, lastname, age, city and state. class Person def initialize(fname,lname,age,city,state) @fname=fname @lname=...
true
eece2dee9192bca94f5acd8252df5ccfa21ca0bd
Ruby
emenegro/retinator
/lib/retinator.rb
UTF-8
1,863
2.984375
3
[ "MIT" ]
permissive
require "mini_magick" require "colorize" require "fileutils" require_relative "retinator/version" require_relative "retinator/config" require_relative "retinator/utils" module Retinator class << self def generate(path, res) return false unless check_params path, res show_dimension_hint_if_needed path...
true
011a67f6b9abb67035a9dfe5b8d05cbcacedf2cf
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/proverb/97e4616dab7645b6af57bb00bf15765f.rb
UTF-8
652
3.40625
3
[]
no_license
class Proverb attr_reader :items, :qualifier def initialize(*items, qualifier: nil) @items = Array(items) @qualifier = qualifier end def to_s [item_messages, final_message].join("\n") end private def item_messages item_pairs.map do |missing_item, lost_item| "For want of a #{m...
true
201f48c5aecf1e2d8322e676268211d4f099cfba
Ruby
Baker221B/ruby-practice
/golf.rb
UTF-8
159
3.5625
4
[]
no_license
puts 'What is your handicap?' ans == gets.chomp.to_i if ans == 14 puts 'good for a beginner' if ans => 14 puts 'you\'re a #{gets.chomp.to_i}' end
true
81dcd8e606efba7371d6d0467192760c6d52982d
Ruby
dylanrhodius/learn-to-programme
/chocolates.rb
UTF-8
269
4.0625
4
[]
no_license
puts 'How many chocolates do you eat per day?' chocolates = gets.chomp puts 'And until what age do you think you will live?' age = gets.chomp eaten = chocolates.to_i * age.to_i puts 'You will then eat ' + eaten.to_s + ' chocolates in your lifetime. Wow!'
true
c55b35f9c40c2e3fe28ec276ad485dcd750ab806
Ruby
kariabancroft/advent-code
/three/three-p2.rb
UTF-8
1,303
3.546875
4
[]
no_license
require 'pry' def deliver(filename) file_data = read_file(filename) santa_data, robo_data = split_grid(file_data[0]) santa_grid = process_grid(santa_data) robo_grid = process_grid(robo_data) final_grid = santa_grid.merge(robo_grid) return final_grid.length end def split_grid(data) data_array = data.spl...
true
fe3aa41a36b5d8fa7e7bfc423bf6ade20403f845
Ruby
JeffBusterCase/Jpro
/lib/DG_MAIN2.rb
UTF-8
1,424
2.875
3
[]
no_license
#New version of DG_MAIN #Take out bug to know if a user file exist #Now use File.exit? file, avoiding the error # # # # => Login Page # # # def enter begin $enter = true while $enter 5.times {puts ""} puts " Qual é a sua conta?" ...
true
2646997ad7bd9b378c8f89a002e4aa556df74da1
Ruby
Titouax/ruby_basics_1
/exo_5.rb
UTF-8
351
3.546875
4
[]
no_license
def number_ask puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?" print "> " number = gets.chomp.to_i return number end def pyramid(floor) puts "Voici la pyramide :" floor.times { |j| print " " * (floor - (j+1)) print '*' * (j+1) puts '*' * j } end def perform pyr...
true
e6d771fcea61a3c56411fe22a14def3c3db9eacf
Ruby
jhulford/rex12
/lib/rex12/document.rb
UTF-8
3,820
3.296875
3
[ "MIT" ]
permissive
# methods for reading a full EDI file # # currently, the full text of the file is read into memory, # but if you use the block form of the methods, then the subsequent ruby objects # are created within the block loops so they can be garbage collected module REX12; class Document # Parse the EDI document from file ...
true
046ee790a24f2455c1945f1c478f11c3fc46a636
Ruby
dhartoto/intergalactic_converter
/lib/roman_numerals.rb
UTF-8
242
2.765625
3
[]
no_license
class RomanNumerals def self.create(args) galactic_numerals = args[:galactic_numerals].split(' ') note = args[:note] num = [] galactic_numerals.each do |string| num << note[string] end num.join('') end end
true
1cb85a64d6b21e9bac14f5dc8c065ce1da42f1ab
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/grains/3ba4a7b589144c76b193e3f1daacfc6d.rb
UTF-8
168
3.203125
3
[]
no_license
class Grains SQUARES = 64 def initialize() end def square(input) 2 ** (input - 1) end def total() SQUARES.times.map { |i| 2**i }.reduce(:+) end end
true
120ec27382e8b623ae95fa1cc0cf65fc1c9888b8
Ruby
h4hany/yeet-the-leet
/algorithms/Hard/1377.frog-position-after-t-seconds.rb
UTF-8
2,408
3.78125
4
[]
no_license
# # @lc app=leetcode id=1377 lang=ruby # # [1377] Frog Position After T Seconds # # https://leetcode.com/problems/frog-position-after-t-seconds/description/ # # algorithms # Hard (33.64%) # Total Accepted: 8.3K # Total Submissions: 24.8K # Testcase Example: '7\n[[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]]\n2\n4' # # Given...
true
fa7b37c3f7b6fa39021693892eb2ced12febee98
Ruby
alampros/markium
/bin/markium.AdiumPlugin/Contents/Resources/redcarpet_w.rb
UTF-8
545
2.75
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
#!/usr/bin/env ruby require 'rubygems' require 'redcarpet' require 'albino' require 'nokogiri' def markdown(text) options = [:fenced_code,:no_intraemphasis,:strikethrough,:gh_blockcode,:tables,:hard_wrap,:lax_htmlblock,:xhtml] html = Redcarpet.new(text, *options).to_html syntax_highlighter(html) end def synta...
true
aa7f4cfaa459ae6e735d5783f60ee0905d41bb4a
Ruby
peterxjang/test-contacts-api-app
/frontend.rb
UTF-8
4,509
3.0625
3
[]
no_license
require 'unirest' require 'pp' jwt = "" while true system "clear" puts "CONTACTS APP - Choose an option:" if jwt == "" puts "[7] Register (create a user)" puts "[8] Login" else puts "[1] Show all contacts" puts "[1.1] Show all contacts in a group" puts "[2] Show one contact" puts "[3] ...
true
40afe51121ac6e52afe2d1ef0f9caa20a8682d4b
Ruby
flatiron-lessons/oo-inheritance-code-along-web-071717
/lib/vehicle.rb
UTF-8
178
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Vehicle attr_accessor :wheel_size, :wheel_number def initialize(wheel_size, number) end def go "vrrrrrrrooom!" end def fill_up_tank "filling up!" end end
true
f2faef4b0272ab6b409146e980918308292028fc
Ruby
Maryka88/esercizi_test
/Ruby2_ex3.rb
UTF-8
1,127
3.90625
4
[]
no_license
class TodoList def initialize @list = [] end def add(item) @list << item end def remove(item) @list.delete(item) end def each @list.each { |p| yield p } end def length @list.length end def [](id) @list[id] end end class TodoItem # provid...
true
c43e5af421b921750d8febd19245fada477d23fc
Ruby
ebastien/redmine-gitolite
/app/models/gitolite_public_key.rb
UTF-8
1,935
2.515625
3
[ "MIT" ]
permissive
require 'open3' class GitolitePublicKey < ActiveRecord::Base unloadable STATUS_ACTIVE = 1 STATUS_LOCKED = 0 belongs_to :user validates_uniqueness_of :title, :scope => :user_id validates_uniqueness_of :identifier, :score => :user_id validates_presence_of :title, :key, :identifier scope :active, {:co...
true
a74261debe2c2f6414d231fa1ddebcbef245ed84
Ruby
pulkit21/ruby-experiments
/bubble.rb
UTF-8
176
3.328125
3
[]
no_license
def bubble(a) for i in 0..a.length-1 for j in 0..(a.length-i-2) if(a[j] > a[j+1]) a[j],a[j+1]=a[j+1],a[j] end end end puts a end b=[6,3,4,1,5,2] puts bubble(b)
true
5ad7793e7a2e7c01bb449e2e0a333452822c8fae
Ruby
ChickenProp/predictionbook
/spec/helpers/markup_helper_spec.rb
UTF-8
1,671
2.734375
3
[ "BSD-3-Clause" ]
permissive
require 'spec_helper' describe MarkupHelper do include MarkupHelper describe '#confidence_and_count' do it 'should return the number of wagers of a prediction' do prediction = double(Prediction, :wager_count=> 20).as_null_object confidence_and_count(prediction).should =~ /20/ end it 'shou...
true
fe996f84125981ac241f8b26356ee7a41e0694d6
Ruby
wildfauve/event_notification_v2
/lib/event_handlers/invoice_created_handler.rb
UTF-8
2,887
2.65625
3
[]
no_license
require_relative "../schemas/schema_catalogue" class InvoiceCreatedHandler include AutoInject["channel_handlers.channel_handler_factory", "values.invoice_created_value", "templates.template_factory", "schemas.schema_catalogue", "map...
true
efc843554a775763694000ff5d5abe69c2f5f93b
Ruby
praveenag/PythonChallengeRubyCode
/ocr.rb
UTF-8
588
3.5
4
[]
no_license
def read_file file = File.new("ocr", "r") text="" while (line = file.gets) text<<line end text end def parse_text(text) character_map={} text.each_char do |char| count = character_map[char.to_sym] if(count) existing_count = character_map[char.to_sym] character_map[char.to_sym] = existin...
true
ef967493e6cb1d2dd0e0819bfa768db27d528976
Ruby
floor114/easy_encoding
/lib/easy_encoding/huffman.rb
UTF-8
886
3.1875
3
[ "MIT" ]
permissive
require 'easy_encoding/node' require 'easy_encoding/base' module EasyEncoding class Huffman < Base def root @root ||= create_tree! end private def generate_codes! {}.tap { |res| root.walk { |node, code| res[node.symbol] = code unless node.merged? } } .sort_by { |_, value| value....
true
bcc1479c5ca84ab2a9eca857b30ef64b02637f44
Ruby
phelanjo/fermy
/spec/workflows/creates_recipe_spec.rb
UTF-8
1,681
2.59375
3
[]
no_license
require 'rails_helper' RSpec.describe CreatesRecipe do let(:creator) { CreatesRecipe.new( name: 'Recipe Kimchi', ingredients_string: ingredients_string) } describe 'initialization' do let(:ingredients_string) {''} it 'creates a recipe given a name' do creator.build expect(creator.recip...
true
31e6b4b2e696cb46495853d81ee27be649ca724d
Ruby
austinthecoder/fiveminuteruby
/lib/menu/url.rb
UTF-8
222
2.546875
3
[]
no_license
module Menu class Url def initialize(url, method = nil) self.url = url self.method = method end attr_accessor :url attr_writer :method def method @method ||= :get end end end
true
69070178db4ad4e220b87dc8b2e44af863866c23
Ruby
allysonwilson/classwork
/week_01/day_3/countries_hashes.rb
UTF-8
507
2.921875
3
[]
no_license
# countries = { # uk: { # capital: "London", # population: 1_000_000 # } # germany: { # capital: "Berlin", # population: 5_000_000 # } # } # # puts countries [:germany]{} avengers = { hulk:{ name: "Bruce Banner", attack_moves: { Smash: 1000, Roll: 500 } }, iron_...
true
58111edc269613951469e22943c03a9a920b374c
Ruby
aonoloki/rubyProject
/morpion.rb
UTF-8
2,984
3.9375
4
[]
no_license
class Board def initialize @board = Array.new(3) { Array.new(3, " ") } end def printInstructions puts "Choisir la case correspondant au numéro, et faire entrer pour jouer." puts "1 | 2 | 3", "---------", "4 | 5 | 6", "---------", "7 | 8 | 9" print "\n" end ...
true
88cd914a2a2b31733e0ae4785adc4fdbbebf7c45
Ruby
ajzajac/ttt-10-current-player-bootcamp-prep-000
/lib/current_player.rb
UTF-8
278
3.921875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn_count(board) turns = 0 board.each do |tile| if tile == "X" || tile == "O" turns += 1 end end turns end def current_player(board) if turn_count(board) % 2 == 0 "X" else "O" end end
true
98815482bbee263d3444aa2867b9ba9bc979f4ef
Ruby
freecode23/RubyProjects
/lecture/room_repository.rb
UTF-8
923
3.390625
3
[]
no_license
require 'csv' require_relative 'room' class RoomRepository def initialize(csv_file_path) @csv_file_path = csv_file_path @rooms = [] @next_id = 1 load_csv end def all @rooms end def add(room) room.id = @next_id @rooms << room @next_id += 1 save_to_csv # first we add ...
true
935a6a0d9b8eb198ca08da226842067c34eb22fc
Ruby
hiroshige02/Ruby-chap8
/lesson7.rb
UTF-8
298
3.78125
4
[]
no_license
puts "計算を始めます\n何回繰り返しますか?" x = gets.to_i i = 1 while x >= i do puts "#{i}回目の計算\n2つの値を入力してください" a = gets.to_i b = gets.to_i puts "a+b=#{a+b}\na-b=#{a-b}\na*b=#{a*b}\na/b=#{a/b}" i += 1 end puts "計算を終了します"
true
0c859172c8bace11dec6ddc7c01c5a1e8194af42
Ruby
moneybird/i18n-workflow
/lib/i18n/workflow/exception_handler.rb
UTF-8
3,448
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'ya2yaml' require 'active_support/core_ext/hash/deep_merge' require 'active_support/core_ext/hash/keys' require 'i18n' # This class handles exceptions for I18n. It has the following purpose: # # 1. It changes the <span class="translation_missing"> response for MissingTranslations...
true
eaf6cd433f9fdb9c1971f9a2c2c763313246dfba
Ruby
FeehAvelar/rubyPuro
/Aula04/Iteracoes/EachArray.rb
UTF-8
218
3.34375
3
[]
no_license
names = ["Felipe", "Angela", "Carlos", "Diego", "Mauricio"]; name = "Enzo"; array.each do |name| #prints all array values. Don't change #var name original values puts (name); end; puts (name);
true
06d9cfca9902a6329adc85a92bd8aecc0570951f
Ruby
drbrain/power_mitten
/lib/power_mitten/mitten.rb
UTF-8
3,019
2.65625
3
[]
no_license
## # The command line interface class PowerMitten::Mitten ## # Loads the configuration file from the +:configuration+ key in +options+ # (or ~/.power_mitten) if none is given) and merges the configuration there # into +options+. def self.load_configuration options file = options[:configuration]...
true
a0b971ecd9fb56a560a55b8bcfefcb10e686f6e1
Ruby
greatmaddyave/Project-Euler1
/fibonacci.rb
UTF-8
480
4.03125
4
[]
no_license
#By considering the terms in the Fibonacci sequence whose #values do not exceed four million, find the sum of the #even-valued terms. def fibonacci(num) total = 0 even_numbers= [1,2] while total <= 4000000 total = even_numbers[-2] + even_numbers[-1] even_numbers.push(total) end i = 0 ...
true
6202e4271ab72e9a5aa674f818886ac45e48ec17
Ruby
ericrobolson/MTG_Search
/service_templates/Artist.rb
UTF-8
556
3.09375
3
[]
no_license
# Eric Olson (c) 2016 require 'sqlite3' require 'json' DATABASE_LOCATION = '../databases/' cardInformationDb = DATABASE_LOCATION + 'CardInformation.db' class Artist @id @name def initialize(name) @name = name end def name return @name end def to_json if @id == nil @id = "123" end return '"...
true
534c0dd98010f287f1c2336d1ab3ea58c2d5ff94
Ruby
mutsey/ruby-object-initialize-lab-online-web-pt-081219
/lib/dog.rb
UTF-8
103
2.625
3
[]
no_license
lassie = Dog.new("Corgi") lassie.breed #=> "Corgi" lassie = Dog.new("Mutt") lassie.breed #=> "Mutt"
true
1b32a9de9dd4c1b5b9c542b438f6eba70483f317
Ruby
marcwright/WDI_ATL_1_Instructors
/REPO - Los Angeles 7-8/00-week/ruby_basics/loops/02_for.rb
UTF-8
260
3.734375
4
[]
no_license
# For loop syntax for variable [, variable ...] in expression [do] code end # Example for i in 0..5 puts "Value of local variable is #{i}" end # i in 0..5 will allow i to take values in the range from 0 to 5 (including 5) # maybe talk about .each
true
ca1cdb46bebed3bfcbb73e5cc9b64d345bc2c963
Ruby
tomski80/IntroToProg
/Chapter0/Chapter0-4.rb
UTF-8
88
3.15625
3
[]
no_license
# array excersises array = [1988,1990,2016,2013,2012] array.each { |date| puts date }
true
ba95e21de353bd533727ac1598f62e1097c6234f
Ruby
andrew/wwwd
/app/wizbit.rb
UTF-8
191
2.53125
3
[]
no_license
class Wizbit def quotes ['Ship it!', 'Maybe Mongodb?', 'Is it webscale?', 'I love Redis', 'Just use Rails', 'PHP sucks!', 'bundle update'] end def speak quotes.sample end end
true
f2007fe7456c6669ec27e8657de4653080aa884b
Ruby
aiywatch/Max-Value
/fizzbuzz.rb
UTF-8
579
3.984375
4
[]
no_license
def fizzbuzz(s, e) s.upto(e) do |i| puts "FizzBuzz" if i%5 == 0 && i%3 == 0 puts "Buzz" if i%5 == 0 puts "Fizz" if i%3 == 0 puts i if i%5 != 0 && i%3 != 0 # case # when i%5 == 0 && i%3 == 0 # puts "FizzBuzz" # when i%5 == 0 # puts "Buzz" # when i%3 == 0 # p...
true
384df48a885d8413033f57e5b263208f6e39f780
Ruby
empjustine/euler
/p0003.rb
UTF-8
244
3.40625
3
[]
no_license
require 'prime' # Largest prime factor # ==================== # # The prime factors of 13195 are 5, 7, 13 and 29. # # What is the largest prime factor of the number 600851475143 ? # # Answer: 6857 print 600851475143.prime_division.last.first
true
2bf383cf0c55d79004ddd84881fbd54a28bcba04
Ruby
mtsafer/Chess
/lib/player1.rb
UTF-8
598
3.171875
3
[]
no_license
require_relative "tokens/black_tokens" class Player1 attr_reader :tokens, :allegiance, :name def initialize @name = "Player1" @allegiance = "black" @pawns = [] (0..7).each { |n| @pawns << BlackPawn.new([ n , 1 ]) } @knights = [ BlackKnight.new([ 1, 0 ]), BlackKnight.new([ 6, 0 ]) ] @castles = [ BlackCast...
true
c4ebbb825642b5ee4b5f06dc7d978200fd270bf0
Ruby
scottzec/betsy
/test/models/category_test.rb
UTF-8
1,749
2.625
3
[]
no_license
require "test_helper" describe Category do it "can be instantiated" do expect(categories(:category1).valid?).must_equal true end it "will have the required fields" do cat = Category.first expect(cat).must_respond_to :name end describe "relationships" do it "can belong to a product" do ...
true
acac5179665cb7183d5044553f1849b6113420c0
Ruby
Benedict/logtoload
/main.rb
UTF-8
2,751
2.640625
3
[]
no_license
require 'net/http' require 'uri' LOG_FILENAME = ARGV[0] URL_LIST_FILENAME = ARGV[1] LOAD_TEST_XML_FILENAME = ARGV[2] PARAMS = "params" NO_PARAMS = "no_params" def read(filename) str = "" file = File.new(filename, "r") while line = file.gets str += line end return str end def xml_frag(url_type, i) ...
true
c6273b754aa974419763d84230bedd5d2c8366cc
Ruby
RMCornell/where_it_happens
/app/services/nytimes_articles_service.rb
UTF-8
524
2.515625
3
[]
no_license
class NytimesArticlesService attr_reader :connection def initialize @connection = Hurley::Client.new("http://api.nytimes.com/svc/search/v2/articlesearch.json") connection.header[:content_type] = "application/json" connection.query["api-key"] = ENV["nytimes_articles_api_key"] end def query_term(ter...
true
1088a0d12fabae7bbc3aa94d010fc2b5f85b7dec
Ruby
williamsilvacastro/nivelamento-aluno
/simulado/02-simulado.rb
UTF-8
1,099
4.28125
4
[]
no_license
# 2) Defina uma função chamada “negativos_positivos”, que deve receber um array de números e que deve retornar outro array com os seguintes 3 números: # 1. Na primeira posição, o percentual de números do array que são positivos # 2. Na segunda posição, o percentual de números do array que são zero # 3. Na última posiçã...
true
46aaad662842c74e053a337f667731a56f7e1087
Ruby
chapelle/golf_app
/golf_app_batch/lambda_function.rb
UTF-8
2,097
2.828125
3
[]
no_license
require 'google_maps_service' require 'rakuten_web_service' require 'aws-record' class GolfApp include Aws::Record integer_attr :golf_course_id, hash_key: true integer_attr :duration1 integer_attr :duration2 integer_attr :duration3 end module Area CODES = %w(8 11 12 13 14) end ...
true
f6f732513fbfd1c34d4762936a3afdcaee04d55d
Ruby
drothschild/phase-0
/week-4/good-guess/my_solution.rb
UTF-8
166
3
3
[ "MIT" ]
permissive
# Good Guess # I worked on this challenge [by myself, with: ]. def good_guess? (number) if number == 42 true else false end end # Your Solution Below
true
f39c62e4a0a893a66354c824e420351447d565ed
Ruby
Syntuition-Syntekh-Development/Spooky
/Math/floor.rb
UTF-8
166
3.265625
3
[]
no_license
def floor(*b,c ) array = *b num = c.to_i unless array.any?(String) == true array.each.map{|n| n.floor(num)} else p 'No strings are allowed' end end
true
7254e8491376d5d2a78f64079175f42d857cac84
Ruby
mcary/sensa-server
/spec/models/reading_spec.rb
UTF-8
1,547
2.609375
3
[]
no_license
require 'spec_helper' describe Reading do let :valid_attributes do { value: 6.5, sensor: Sensor.create!(name: "DO", unit: "%"), measured_at: Time.now, } end def attributes_without(key) valid_attributes.reject {|k,v| k == key } end it "creates" do Reading.create! valid_attr...
true
cdcd9666b02f957eb33a94f6dbbceaa2ddd84cac
Ruby
lisabardelli/katas
/count_letter/lib/count.rb
UTF-8
129
3.640625
4
[]
no_license
def count(string, letter) count = 0 (0...string.length).each do |i| count += 1 if string[i] == letter end count end
true
547e944f309db39ee0356c65db14788237cf8c20
Ruby
vickdayaram/object-relations-assessment-web-051517
/solution.rb
UTF-8
1,977
3.65625
4
[]
no_license
# Please copy/paste all three classes into this file to submit your solution! class Customer attr_accessor :first_name, :last_name @@all = [] def initialize(first_name, last_name) @first_name = first_name @last_name = last_name @@all << self end def full_name "#{first_name} #{last_name}" ...
true
3ced482bd5021bb2d57df4add3e000b864466d09
Ruby
jerrythemem/ruby_vernam_cipher
/decode.rb
UTF-8
575
3.3125
3
[]
no_license
# frozen_string_literal: true require './decode_convert' def decode(result, mask) puts 'Base is string or number?' answer = gets.chomp if answer == 'string' base_byte = result.to_i(2) ^ mask.to_i(2) convert_str(base_byte.to_s(2)) elsif answer == 'number' result.to_i(2) ^ mask.to_i(2) end end de...
true
3deb43b0f686913144502b8cacb0dff9cd913831
Ruby
MPaulina/AplikacjaASI
/db/seeds.rb
UTF-8
918
2.65625
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
6d09b0933543e3afc2211e6a45a50830ae1716e1
Ruby
sadiqmmm/trado
/app/models/delivery_service_price.rb
UTF-8
2,703
2.546875
3
[ "BSD-2-Clause", "MIT" ]
permissive
# DeliveryServicePrice Documentation # # The delivery_service_price table contains a list of available delivery prices for a type of delivery service. # Each with a description and price and dimension parameters. # == Schema Information # # Table name: delivery_service_prices # # id :integer ...
true
957187dfc276e1043dbac1bea7ede64a54316111
Ruby
singhanilk1959/rpl
/library_intro_4/bk/threadex.rb
UTF-8
7,843
3.40625
3
[]
no_license
#!/usr/bin/env ruby # # __END__ --------------------------- # Thread #1 is running here Thread.new { # Thread #2 runs this code } # Thread #1 runs this code --------------------------- # Wait for all threads (other than the current thread and # main thread) to stop running. # Assumes that no new threads are star...
true
6d70c7e429f7e10158b464cbaf6dac97d255d1ed
Ruby
rhivent/ruby_code_N_book
/book-of-ruby/ch12/alias_methods.rb
UTF-8
515
3.859375
4
[]
no_license
# The Book of Ruby - http://www.sapphiresteel.com module Happy def Happy.mood return "happy" end def expression return "smiling" end alias happyexpression expression end module Sad def Sad.mood return "sad" end def expression return "frowning" end alias sadexpression expression end class Person...
true
2b778c86693ef192053cbbd3a6ba249d9f93716c
Ruby
seattlerb/imap_processor
/lib/imap_sasl_plain.rb
UTF-8
1,125
2.546875
3
[ "MIT" ]
permissive
require 'net/imap' ## # RFC 2595 PLAIN Authenticator for Net::IMAP. Only for use with SSL (but not # enforced). class Net::IMAP::PlainAuthenticator ## # From RFC 2595 Section 6. PLAIN SASL Authentication # # The mechanism consists of a single message from the client to the # server. The client sends th...
true
427a272e2a59f80eaaff510cb7a636ff68110359
Ruby
eakmotion/RubyPracticeProblems
/permutation.rb
UTF-8
615
3.21875
3
[]
no_license
require 'spec_helper' def permutation?(a, b) return true if b.empty? return false if a.size < b.size a_list = a.split("") b_list = b.split("") b_list.each do |i| return a_list.include?(i) end end RSpec.describe "permutation?" do it "return true if B is a blank" do expect(permutation?("abc", ""))...
true
ee5c1545403d51bb130ed3d9b959a60141740d43
Ruby
yuheik/jira_issue_browser
/action/sprint_actions.rb
UTF-8
5,137
2.671875
3
[]
no_license
require_relative './base_actions' require_relative './analyzer' class SprintActions < BaseActions def self.init if @issues.nil? get_sprint_issues end reset calc_kpi end def self.reset @browsing_issues = @issues.dup list end def self.get_sprint_issues @params = input_que...
true
8a101818afec7209ff6c90aed2ffd04215917ffe
Ruby
toddt67878/Course_Ruby
/String I/Extract_Characters.rb
UTF-8
129
2.9375
3
[]
no_license
story = "Once upon a time in a land far, far away" p story.length p story[-3] p story[100] p story.slice(1,2) p story.slice(0)
true
f6bb46edcdc02cec8e874a8bf3ca881d03907a4d
Ruby
dmr41/ruby_methods_playground
/queue.ruby
UTF-8
1,171
3.96875
4
[]
no_license
class Queue def initialize @queue_data = [] end def add_to_queue(new_element) @queue_data.push(new_element) end def remove_from_front_of_queue @queue_data.shift end def remove_from_back_of_queue @queue_data.pop end def move_to_front_of_line(line_cutters) @queue_data.unshift(line_cutters) end ...
true
95cc47e911efb7dc785a80f0488677a1d0cf275e
Ruby
porusan/Euler
/025/025.rb
UTF-8
204
3.234375
3
[]
no_license
require './lib025' n1 = 1 n2 = 2 i = 4 fib = 3 keepGoing = true while keepGoing n1 = n2 n2 = fib fib = n1 + n2 i += 1 if numberOfDigits(fib) >= 1000 keepGoing = false end end puts i
true
83c8b92280aa1d2f15a1dd17bbf91dc8ea311f86
Ruby
eugenioLopezRamos/slika-photography
/app/controllers/static_controller.rb
UTF-8
5,316
2.59375
3
[]
no_license
class StaticController < ApplicationController def home redirect_to '/home' end def show if image_tabs.include?(params[:tab]) || params[:tab] === "homeTab" assign_images end render 'home' end def retrieve_posts if params[:slug] == "last" then @post= Post.last else @...
true
c31763e1de34fe95d5712206c1d92b44e9aef24e
Ruby
Lucx14/Exercism-Ruby
/resistor-color-duo/resistor_color_duo.rb
UTF-8
261
2.65625
3
[]
no_license
# frozen_string_literal: true # Resistor Duo module ResistorColorDuo BANDS = %w[black brown red orange yellow green blue violet grey white].freeze def self.value(pair) ( BANDS.index(pair[0]).to_s + BANDS.index(pair[1]).to_s ).to_i end end
true
d650527a07a928555b62b87ac471f95982b8f159
Ruby
sarakhandaker/ruby-enumerables-practice-the-bachelor-lab-seattle-web-030920
/lib/bachelor.rb
UTF-8
1,109
3.546875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def get_first_name_of_season_winner(data, given_season) name="" data.each{|season, season_hash| season_hash.each{ |cont_hash| name=cont_hash["name"] if cont_hash["status"]=="Winner" } if season==given_season } name.split(" ")[0] end def get_contestant_name(data, occupation) name="" data.each{...
true
ccc49a283c22dd2f060f1f49c0afda81bd846b03
Ruby
marcelovsk1/food-delivery-394
/app/controllers/sessions_controller.rb
UTF-8
790
2.90625
3
[]
no_license
require_relative '../views/employees_view' # user actions class SessionsController def initialize(employee_repository) @employee_repository = employee_repository @employees_view = EmployeesView.new end def sign_in # tell the view to ask the user for username username = @employees_view.ask_for('...
true
33fcd3a66e29d1c5686710329a6bebe2f35535be
Ruby
Jxx706/BM-CM
/app/models/user.rb
UTF-8
2,550
2.65625
3
[]
no_license
# == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(255) # last_name :string(255) # email :string(255) # created_at :datetime not null # updated_at :datetime not null # password_digest :strin...
true
2b4c0b19bc7f49c818c892178110fa444a3e0d4f
Ruby
pjb4752/tether
/lib/tether/types/symbol.rb
UTF-8
283
2.859375
3
[]
no_license
require 'tether/types/any' module Tether module Types class Symbol < Any def initialize(value) super(value.to_sym) end def to_s value.to_s end def self.from_chars(chars) self.new(chars.join) end end end end
true
755ba27db9612d7d8676cd6e07686495fd5a3e06
Ruby
mjacobus/field-service
/app/models/territory_map.rb
UTF-8
503
2.828125
3
[]
no_license
class TerritoryMap attr_reader :coordinates attr_reader :markers def initialize(coordinates:, markers: [], geolocation_service: GeolocationService.new) @markers = markers || [] @coordinates = coordinates || [] @geolocation_service = geolocation_service end def center if coordinates.empty? ...
true