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
918d64caa1d85e889bbaf3395f83f0046a8d419b
Ruby
alexako/ProjectEuler
/43.rb
UTF-8
931
3.796875
4
[]
no_license
def hasProperty(num) # Splices for i in 1..$div.length puts "#{num[i]}, #{num[i+1]}, #{num[i+2]} div #{$div[i-i]}" if num[i+2] unless ((num[i] + num[i+1] + num[i+2]).to_i % $div[i-1] == 0) return false end end end return true end #Get all ...
true
9c4422e382b0bb9cbd18a1e06558f9d1d1c76a01
Ruby
Walker-TW/oyster
/spec/oystercard_spec.rb
UTF-8
1,595
2.828125
3
[]
no_license
require 'oystercard' describe Oystercard do let(:entry_station) { double(:entry_station) } let(:exit_station) {double(:exit_station)} it describe " Oystercard created with a default 0 balance" do expect(subject.balance) .to eq(0) end it describe "Top-up a card with a new balance" do expect(subject.to...
true
8b9157ef5f0f9be6165dc4ed4fbc5c3819ea8bd6
Ruby
arnau/Nutils
/lib/nutils/filters/yuicompressor.rb
UTF-8
1,229
2.734375
3
[ "MIT" ]
permissive
# encoding: utf-8 module Nutils module Filters # @author Arnau Siches # # @version 1.2.1 # # @note Requires «yui-compressor» class YuiCompressor < Nanoc::Filter identifier :yuicompressor type :text # Compress the content with [YUI Compressor](http://developer.yahoo.c...
true
0422c4ef7304d7fe56f1285fe20633f302adf1fe
Ruby
andrewr224/chess
/spec/chess_spec.rb
UTF-8
14,798
3.15625
3
[]
no_license
require 'chess' RSpec.describe "Chess" do let(:game) { Chess.new } let(:board) { game.board } let(:white) { game.players.first } it "is a Chess game" do expect(game).to be_instance_of Chess end it "has a board" do expect(game.board).to be_instance_of Board end it "has two players" do exp...
true
b66be5b9d3f97668975677a73b533a463a5b83ed
Ruby
Yash-Soni/ally_html
/final html css/web.rb
UTF-8
226
2.796875
3
[]
no_license
# require 'httparty' # require 'json' # response = HTTParty.get("https://jsonplaceholder.typicode.com/users") # result = JSON.parse(response.body) # puts result[0].each{|k,v| puts v} ('a'...'f').each do |x| print x end
true
f6144dd599a7b2a0eaf0c3dddf3240a42cc3ab1c
Ruby
dendden/myCodewars
/8kyu/tip_calc.rb
UTF-8
366
3.671875
4
[]
no_license
def calculate_tip(amount, rating) ratings = { "terrible" => 0, "poor" => 0.05, "good" => 0.1, "great" => 0.15, "excellent" => 0.2 } rate = rating.downcase puts rate puts ratings.include? rate if ratings.include? rate (amount * ratings[rate]).ceil else "Rating not recognised" ...
true
ec9e9231969328e8dadba1a03559ff5f5bc375f9
Ruby
ivanyapeter/WDI4_homework
/Ivan_Yapeter/04-ruby/ruby_intro/happitails/main.rb
UTF-8
3,280
3.828125
4
[]
no_license
require 'pry' require './animal.rb' require './client.rb' $Shelter = { animals: [], clients: [] } animal1 = Animal.new('Cow', 'Kikin', 5, 'Female', ) animal2 = Animal.new('Octopus', 'Tristan', 5, 'Male') animal3 = Animal.new('Monkey', 'Chad', 5, 'Unknown') client1 = Client.new('Frank', 2, 40, 0) client2 = Client...
true
0133dc394073ecd2d77482c35f0434d316623790
Ruby
akoltun/tree_struct
/spec/nested_tree_struct_spec.rb
UTF-8
3,036
2.828125
3
[ "MIT" ]
permissive
RSpec.describe 'Nested TreeStruct' do shared_examples 'nested TreeStruct' do it 'has assigned values' do expect(tree_struct.name).to eq 'Ferrari' expect(tree_struct.year).to eq 1950 expect(tree_struct.car.model).to eq '340 F1' expect(tree_struct.car.driver).to eq 'Ascari' expect(tree...
true
a794479b5cc40d104535cf490882e912b4d29870
Ruby
karlwitek/launch_school_rb101
/main_review/video_exercises/common_chars.rb
UTF-8
3,262
4.78125
5
[]
no_license
# Given an array of strings made only from lowercase letters, return an array of all # characters that show up in all strings within the given array (including duplicates) # For example, if a character occurs 3 times in all strings but not 4 times, you need # to include that character 3 times in the final answer. # Ex...
true
0750582d50f70b8f70060cc1ebd0b346a1c67e8c
Ruby
simokh/cli_project-
/lib/state_population_cli/cli.rb
UTF-8
9,278
3.34375
3
[ "MIT" ]
permissive
# class Cli # def start # header # user_name # thank_you_message # sleep 1 # Api.quotes_get # # original_screen # # ask_user_again # end # def original_screen # selection_options # sleep 0.5 # making_selection_1...
true
f671d39f41ae28f868bd30dcf94b18218885eb6f
Ruby
rranshous/imgcompare_service
/lib/saver.rb
UTF-8
532
2.890625
3
[]
no_license
class Saver attr_accessor :save_root def initialize save_root self.save_root = save_root end def load name file_path = path_for name if File.exists? file_path bin_rep = File.open(file_path, 'rb') {|fh| fh.read } Marshal.load bin_rep else nil end end def save name, ...
true
89c01e96da29513a2c7477e128ea1b3d13c63578
Ruby
ErikMejerHansen/Ohm-connect
/02_more_buttons.rb
UTF-8
878
2.9375
3
[]
no_license
require 'serialport' require 'net/http' #params for serial port port_str = ENV['ARDUINO_PORT'] baud_rate = 9600 data_bits = 8 stop_bits = 1 parity = SerialPort::NONE if !ENV['OHM_SERVER'] puts 'OHM_SERVER env. variable not set!' exit -1 end if !ENV['TEAM_ID'] puts 'TEAM_ID env. variable not set!' exit -1 end ...
true
e300f7f31b278c1698d1d78b5b40a1aad625407e
Ruby
gglin/project-euler
/ruby_oo/006.rb
UTF-8
697
4.5
4
[]
no_license
# The sum of the squares of the first ten natural numbers is, # 1^2 + 2^2 + ... + 10^2 = 385 # The square of the sum of the first ten natural numbers is, # (1 + 2 + ... + 10)^2 = 55^2 = 3025 # Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 ...
true
de37a0016902659b7618e31a34b669c367f88318
Ruby
ryanmcgarvey/Ryan-goes-to-training
/rails2_studio/code/background/dj/lib/long_runner.rb
UTF-8
189
3.046875
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
class LongRunner def initialize(message) @message = message end def do_hard_work puts "STARTING #{@message}" # work work work... sleep 3 puts "ENDING" end end
true
38144ea416463fb9a3974cc33f765daf403098fc
Ruby
o3o3o/execise
/ruby/rubywarrior/mike-intermediate/player.rb
UTF-8
500
3.21875
3
[]
no_license
class Player def initialize end def have_a_rest? @warrior.health end def play_turn(warrior) @direct=warrior.direction_of_stairs @warrior = warrior p "FEEL: #{warrior.methods} #{warrior.__id__} #{warrior.feel.methods}" if warrior.feel(@direct).enemy? ...
true
1dd73bbad3700509db039622a80f8df5bebe276b
Ruby
mateuszstacel/Bank-tech-test
/spec/unit-tests/statement_spec.rb
UTF-8
1,241
3.109375
3
[]
no_license
require 'statement' describe Statement do subject(:statement) { Statement.new } describe '#transactions_history' do it { is_expected.to respond_to :statement } it 'expect transactions_history to be array' do expect(statement.transactions_statement).to eq [] end it 'expect transactions_histo...
true
84b524d137fed2fbac64649812bb2fb6cd2b911d
Ruby
imharrypark/coderbyte_solutions
/medium/prime_checker.rb
UTF-8
158
3.21875
3
[]
no_license
def prime_checker(num) return true if num == 1 return true if num == 2 root = Math.sqrt(num) (2..root).to_a.any?{|n| num % n == 0} ? false : true end
true
6fe56ca70909ea28f71df00bdff25e70dcfca1f5
Ruby
WeTransfer/fourtrack
/lib/fourtrack/player.rb
UTF-8
909
2.78125
3
[ "MIT" ]
permissive
class Fourtrack::Player def initialize(io) @io = io end def readlines [].tap {|o| each_line{|line| o << line }} end def each_line(&blk) # https://github.com/exAspArk/multiple_files_gzip_reader # https://bugs.ruby-lang.org/issues/9790 loop do break if @io.eof? zr = Zlib::Gzip...
true
740ada9ce78eca95d33b18dbb54361f2a0fb29c2
Ruby
qbl/insinyur-online-replit-lab
/fundamental-cs-series/episode-003/sort.rb
UTF-8
1,454
3.671875
4
[]
no_license
def sort(input_array) insertion_sort(input_array) end def bubble_sort(input_array) unsorted_until_index = input_array.size - 1 while unsorted_until_index > 0 do i = 0 while i < unsorted_until_index do if input_array[i] > input_array[i + 1] input_array[i], input_array[i + 1] = input_arra...
true
42d4dd2c5b564294447a0a2960df38e4d6b4b576
Ruby
princelab/mspire-mascot-dat
/lib/mspire/mascot/dat/index.rb
UTF-8
3,171
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'json' module Mspire module Mascot class Dat # makes a byte index (not line index) class Index INDEX_EXT = '.byteindex' class << self def index_filename(file) file + INDEX_EXT end end # the hash holding the start byte for eac...
true
3cbf4f96e422be81bd1f7fb7825d4915bb3c9da4
Ruby
ArpanMaheshwari144/Complete-Ruby-Programming
/tut32.rb
UTF-8
207
3.28125
3
[]
no_license
# Next and Redo Statements for i in 0..5 if i < 2 next end puts "Value of i = #{i}" end # for i in 0..5 # if i < 2 # puts "Value of i = #{i}" # redo # end # end
true
424989f396a44efb9afab1ec7a67631f07adef84
Ruby
lsegal/yard
/lib/yard/templates/helpers/uml_helper.rb
UTF-8
1,465
2.765625
3
[ "LicenseRef-scancode-free-unknown", "MIT", "GPL-2.0-only", "Ruby", "BSD-2-Clause" ]
permissive
# frozen_string_literal: true module YARD module Templates::Helpers # Helpers for UML template format module UMLHelper # Official UML visibility prefix syntax for an object given its visibility # @param [CodeObjects::Base] object the object to retrieve visibility for # @return [String] the U...
true
4d8f4911d479029d76bbe9448072334abb0972b9
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/difference-of-squares/69fda975546e4f77a1e858b8f39c125e.rb
UTF-8
290
3.65625
4
[]
no_license
class Squares attr_reader :numbers def initialize(number) @numbers = (1..number) end def square_of_sums numbers.reduce(:+)**2 end def sum_of_squares numbers.reduce{|sum, digit| sum + digit**2} end def difference square_of_sums - sum_of_squares end end
true
74f2a1f31b33cca25b8dd47f964b9bac795a03f2
Ruby
VictorOlimpio/trabalho-siscomp
/algorithm/lfu_subst.rb
UTF-8
1,475
3.1875
3
[]
no_license
module Algorithm class LfuSubst # Escolher o 'menos frequentemente utilizado' para remover. # Tb pode ser traduzido para, escolher o menor valor de um vetor, desde que os proximos caches hits incrementem # o valor buscado. Ou seja. Cada vez que ele for utilizado aumentar o contador de uso dele. Quando u...
true
7b664acc5a242fb36b3f91a6db7888f9cc1050d8
Ruby
estherkimyunjung/learn-co-sandbox
/greeting.rb
UTF-8
161
3.078125
3
[]
no_license
def greeting puts "Hello World" end greeting greeting greeting greeting greeting def say_greeting_five_times 5.times{greeting} end say_greeting_five_times
true
7c2711f53508db24718688432472d91c9e4b0e2b
Ruby
fwibaux/DINJA
/db/seeds.rb
UTF-8
20,952
3.234375
3
[]
no_license
OrderItem.destroy_all Order.destroy_all Dose.destroy_all Ingredient.destroy_all Recipe.destroy_all dummy_instructions = "Set the oven to 400°F. Rinse and dry the parsley and lettuce. Cut the top leaves away from the stems of the parsley and add to the work bowl of a food processor. Measure out 2 teaspoons of the cor...
true
57088708b4dea4ff6b664d2afa4710d83212d89d
Ruby
watashi/AlgoSolution
/codeforces/ac/0/010/B.tle.rb
UTF-8
392
2.65625
3
[]
no_license
n, k = gets.split.map(&:to_i) m = k / 2 a = Array.new(k){?0 * k} gets.split.map(&:to_i).each do |w| d, x, y = 9e9 0.upto(k - 1) do |i| 0.upto(k - w) do |j| next if a[i][j, w] != ?0 * w t = w.times.map{|k| (i - m).abs + (j + k - m).abs}.inject(&:+) d, x, y = t, i, j if t < d end end if d == 9e9 p -1 ...
true
eda666ecfcfcccc5a8241854c988697d2bd5c6f1
Ruby
joeletizia/BattleShip
/app/extras/battleshipIntelligence.rb
UTF-8
1,574
3.15625
3
[]
no_license
module BattleShip class ArtificialIntelligence def self.Infer_Next_Shot(shot_array, board) case correct_shot_count(shot_array) when 0 #random open_pegs = board.unknown open_pegs[rand (0...open_pegs.length)] when 1 #guess a new direction last ...
true
ddbb03c5b1e5d7f2c4c9bf787eb3113d47857122
Ruby
RubiesOnDaCloud/FancyRepositoryName
/07_words.rb
UTF-8
140
3.703125
4
[]
no_license
words = [] begin print "Enter a word: " word = gets.chomp words.push(word) end until word.empty? words.pop puts words.sort.join(', ')
true
9db7e486d5d52a0a2a81a72baaf13c912059ee93
Ruby
Michaelschats/Oystercard-Challenge
/lib/oystercard.rb
UTF-8
865
3.296875
3
[]
no_license
class Oystercard MAXIMUM_BALANCE = 90 MINIMUM_BALANCE = 1 attr_reader :balance, :entry_station, :exit_station, :trip_history def initialize @balance = 0 @entry_station = nil @exit_station = nil @trip_history = [] end def top_up(value) raise "Maximum Balance of #{MAXIMUM_BALANCE} Reached" if (@balance + ...
true
498f4d0f24c5272b34cbfe21ce30b68c34bde59e
Ruby
caruby/tissue
/lib/catissue/domain/specimen_array.rb
UTF-8
1,866
2.578125
3
[ "MIT" ]
permissive
module CaTissue class SpecimenArray # @quirk caTissue the superclass Container occupied_positions does not apply to SpecimenArray. remove_attribute(:occupied_positions) # Initializes this instance's child storage types from the given type. # # @param [<StorageType>] the type to set def spe...
true
d5215cbf13e45547e25645f1e6659953f64a1bf7
Ruby
jfalameda/thumbnail-generator
/thumbnails_generator.rb
UTF-8
2,757
3.671875
4
[]
no_license
# This script generates thumbnails of all the images of a specified directory # it will place all the resized images on the given directory, in case missing they will be placed on %images_dir%/output # Author: José Fernández Alameda # Email: jose (at) alamedanet.es # # # Command line arguments # # Arguments # -i /path/...
true
728b096bab54a3d7b4ec1a662b2e93c42897007e
Ruby
charlescui/planet-wars
/lib/planet-wars/objects/health_bar.rb
UTF-8
871
2.84375
3
[]
no_license
class HealthBar < Chingu::GameObject def setup @ship = Ship.all.first self.x = $window.width-(30*5) self.y = 30*12 self.zorder = 999 @tick = 0 @max_tick = 10 end def update self.factor = 10 @image = update_image if @tick >= @max_tick @tick = 0 if @tick >= @max_tick @tic...
true
ef5a43c4e6077102126be61b7816570141726480
Ruby
Rodolpho25/teste01
/simulado/ex2.rb
UTF-8
1,786
3
3
[]
no_license
class Usuario def initialize(email, senha) @email = email @senha = senha end def trocarSenha(novaSenha) novaSenha = novaSenha case senha when Usuario @novaSenha << senha end end end module Pagina def Pagina.naPagina(obj) ...
true
c7e728e3f34c3bfb789e49789b604a76d2af6086
Ruby
sophiataskova/ruby-intro
/01_ruby/03_web/duck.rb
UTF-8
1,467
3.078125
3
[]
no_license
require 'open-uri' require 'json' BASE_URL = "http://api.duckduckgo.com/?format=json&pretty=1&q=" # remote API url query = "web services" # query string query_url = BASE_URL + URI.escape(query) # putting the 2 together puts " ==============...
true
3cbca11652138cf93638217b9524c3066c9d2778
Ruby
jcmuller/msewage-importer
/lib/msewage-importer/importers/base.rb
UTF-8
1,149
2.546875
3
[ "MIT" ]
permissive
module Msewage::Importer module Importers class Base class << self def type(*file_types) file_types.each do |file_type| Importers::Base.importers[file_type] = self end end def factory(file_name) #load_importers importers.each_pair ...
true
e6d3d158b02072fc09b84f856c356f32e336e1f8
Ruby
timbolaj/Codewars-Practice
/Ruby/count_chars.rb
UTF-8
285
3.9375
4
[]
no_license
# Count all individual characters in a string returned in an object # eg 'abba' => {'a': 2, 'b': 2} def count_chars(s) counter = {} s.split("").each do |letter| if counter[letter] counter[letter] += 1 else counter[letter] = 1 end end return counter end
true
1d4881f7563c1c3ad1dd0cd448711e81a5089adf
Ruby
samycici/crop_selenium_screenshot
/crop_element.rb
UTF-8
1,178
2.71875
3
[]
no_license
require 'capybara' require 'selenium-webdriver' require 'chunky_png' require 'os' URL = ARGV[0] SELECTOR = ARGV[1] # chromedriver Capybara.register_driver :selenium do |app| caps = Selenium::WebDriver::Remote::Capabilities.chrome( 'chromeOptions' => { "args" => [ "--window-size=1600,1300"] } ) C...
true
085437aa94fba67bef6a0da32f18c8bb6b0b8da9
Ruby
quinqu/video-store-api
/test/controllers/rentals_controller_test.rb
UTF-8
3,066
2.546875
3
[]
no_license
require "test_helper" describe RentalsController do describe "check out" do it "will create a rental" do customer = customers(:shelley) customer.save video = videos(:vid1) video.save rental_data = { customer_id: customer.id, video_id: video.id } ...
true
bfa07a881f9b5c6287d15483114f80949bec644e
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/crypto-square/e57a542f7679481ba6ae4b6fa91182f0.rb
UTF-8
461
3.125
3
[]
no_license
class Crypto def initialize(text) @text = text end def normalize_plaintext @text.downcase.gsub(/[^a-z0-9]/, '') end def size Math.sqrt(normalize_plaintext.length).ceil end def plaintext_segments normalize_plaintext.scan(/.{1,#{size}}/) end def ciphertext plaintext_segments.map ...
true
8a280b9a358f23766497ca2f1b3731b713bc6650
Ruby
desperatethelark/ruby-chip
/lib/components/program_counter.rb
UTF-8
221
2.5625
3
[]
no_license
# for keeping track of the current program instruction to be executed class ProgramCounter < RubyChip::Component def self.default_state 0x200 end def state=(new_state) @state = new_state % 0x1000 end end
true
59c47424915a1cfe1cd89853d0ae5da3a9627e84
Ruby
fcnaud/leetcode-train
/572_subtree_of_another_tree.rb
UTF-8
1,519
3.875
4
[]
no_license
# Definition for a binary tree node. # class TreeNode # attr_accessor :val, :left, :right # def initialize(val) # @val = val # @left, @right = nil, nil # end # end # @param {TreeNode} s # @param {TreeNode} t # @return {Boolean} def pre_travel(root, arr) return if !root arr << root.val...
true
78740d8d82970f281b5156b2814e1232caa2664b
Ruby
croudcare/object_attorney
/spec/object_attorney/user_form_spec.rb
UTF-8
2,052
2.515625
3
[ "MIT" ]
permissive
require "spec_helper" describe UserForm do it "1. Creating a 'User' using 'UserForm'." do params = { user: { email: 'email@gmail.com', terms_of_service: true } } user_form = UserForm.new(params[:user]) save_result = user_form.save save_result.should == true User.all.count.should == 1 end ...
true
922795637610c35c9a7478a01a17beb67fdb6d56
Ruby
isaacsanders/mini_java_compiler
/lib/simple_lexer.rb
UTF-8
301
3.296875
3
[ "MIT" ]
permissive
class SimpleLexer def run(input) input.split(/(\d+|\+|\-)/).reduce([]) do |tokens, pretoken| case pretoken when /\d+/ tokens << pretoken when "+" tokens << "plus" when "-" tokens << "minus" when '' tokens end end end end
true
ab1fb0d8557c1ecff0953a83ddf13041ee69602f
Ruby
billyhw/mathGame
/question.rb
UTF-8
917
4.09375
4
[]
no_license
# Question: relevant Info: # Create a question and check the supplied answer. # need a function to generate two random integers. class MathGame::Question # Question: relevant Info: # create questin, check answer # need function to generate two random integers attr_reader :int_A, :int_B def initialize @int_A ...
true
86d3a02b756f531bb13cb2562d452f05823e4d7d
Ruby
develaper/kant-comerce
/lib/basket/checkout.rb
UTF-8
1,425
3.328125
3
[]
no_license
require "./lib/pricing_rules/pricing_rule" class Checkout attr_accessor :items, :pricing_rules def initialize(pricing_rules=[]) @pricing_rules = pricing_rules validate! unless @pricing_rules.empty? @items = initialize_pricing_rules end def scan(item) if new_product?(item.code) @items[ite...
true
a214b0ef83cf6ddfc48c4c18483fd72e08791279
Ruby
yiyi1026/projecteuler_ruby
/hackerrank/grid_search.rb
UTF-8
809
3.296875
3
[]
no_license
g = ["123412", "561212", "333634", "781288"] p = ["12", "12"] def ceil_match(g,p) r1, c1 = g.length, g[0].length r2, c2 = p.length, p[0].length r1_idx = 0 arr = [] while r1_idx < r1 g_row = g[r1_idx] p_row = p[0] if g_row.include?(p_row) (c1-c2+1).times do |i| if g_row[i.....
true
6fda49d16bfe52ee52d4d09568b1ab7a1f63398b
Ruby
distler/heterotic_beast
/stories/steps/ra_resource_steps.rb
UTF-8
5,934
2.875
3
[ "MIT" ]
permissive
# The flexible code for resource testing came out of code from Ben Mabey # http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ steps_for(:ra_resource) do # # Construct resources # # # Build a resource as described, store it as an @instance variable. Ex: # "Given a user with...
true
4befbdee95d5852c9cbc93c2c39fe5984f0c8ab0
Ruby
JustWyoming/rio_grande_lab
/lib/DigitalItem.rb
UTF-8
651
3.296875
3
[]
no_license
require_relative '../lib/Item' class DigitalItem < Item attr_reader :quantity, :ship_price_per_oz attr_accessor :name, :price, :description def initialize name, price, weight=-1 @name = name @price = price @quantity = 1 @description = "" @weight = -1 @ship_p...
true
905c2325acc3f9228c959c7a9523929116d32fed
Ruby
kristru/address-bloc
/address_bloc.rb
UTF-8
260
2.640625
3
[]
no_license
require_relative 'controllers/menu_controller' #this creates a new MenuController at start menu = MenuController.new #this clears the command line system "Clear" puts "Welcome to AddressBloc!" #this calls MenuController method menu to display menu.main_menu
true
9442429db6ab9650fb6cc5369088ba7407b2543e
Ruby
vitorfreire/COMMWEB
/app.rb
UTF-8
5,044
2.65625
3
[]
no_license
require 'sinatra' get '/form' do myHTML = <<-RSTUFF <html> <head> <head> <style type="text/css"> .form_style { font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size: 14px; font-weight: 200; font-height: 200; font-variant: small-caps; text-transform: lowercase; } ...
true
411ce5ec5cc5d104d90e3bb53743c4cb03787a8a
Ruby
mskhokhar/aA-classworks
/W4D3/Chess/queen.rb
UTF-8
275
2.703125
3
[]
no_license
require_relative "piece.rb" require_relative "slideable.rb" class Queen < Piece include Slideable def initialize(color,board,pos) super end def symbol color end protected def move_dirs DIAGONAL_DIRS.concat(HORIZONTAL_AND_VERTICAL_DIRS) end end
true
4b7df44844d89ca41982584088ab6e784c228430
Ruby
taekeun/coding-practice
/HackerRank/Algorithms/Implementation/PickingNumbers/test.rb
UTF-8
1,030
3.78125
4
[]
no_license
# https://www.hackerrank.com/challenges/picking-numbers/problem # > ruby test.rb require 'test/unit' def picking_numbers(numbers) sorted_numbers = numbers.sort unique_numbers = sorted_numbers.uniq max = 0 unique_numbers.each do |n| len = length_of_subarray(n, sorted_numbers) max = len if len > max ...
true
8e86816eb2d20c839f16bf46f216bc28de1005ac
Ruby
OutWooods/mars-rover
/spec/unit/location_printer_spec.rb
UTF-8
1,186
3.140625
3
[]
no_license
require './src/location_printer.rb' describe LocationPrinter do describe 'print' do it 'calls location on all robots' do robot1 = double('robot') robot2 = double('robot') printer = LocationPrinter.new expect(robot1).to receive(:location).and_return({}) expect(robot2).to receive(:lo...
true
abf7a6e3000aa3b06332d6a62dfe37c19801597f
Ruby
sgibson47/upcoming_movies_in_the_park
/lib/upcoming_movies_in_the_park/super.rb
UTF-8
388
2.5625
3
[ "MIT" ]
permissive
module UpcomingMoviesInThePark::Super module InstanceMethods def save self.class.all << self end end module GateParkInstanceMethods def add_showing(showing) self.showings << showing end def list_showings self.showings.each_with_index {|showing, i| pu...
true
79d953fc74a76c1e7692305bdade7cf2d6a7c49e
Ruby
spinosa/pitneybowes-shipping-api-ruby
/test/tc_address.rb
UTF-8
1,393
2.5625
3
[ "MIT" ]
permissive
# # Copyright 2016 Pitney Bowes Inc. # # Licensed under the MIT License (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of the License # in the LICENSE file or at # https://opensource.org/licenses/MIT # # Unless required by applicable law or agreed to in ...
true
2ace63412438dce5542301003d9e5a9943410afa
Ruby
ealden/recordrecon
/lib/recordrecon/record_matcher.rb
UTF-8
1,279
2.671875
3
[]
no_license
module RecordRecon class RecordMatcher def self.match path book = Spreadsheet::Workbook.new sheet = book.create_worksheet new.match(true).each_with_index do |result, i| sheet.row(i).concat result end book.write path end def match header = false records = Reco...
true
ae8b3554895c6aac7486864f049cfa2b916a02be
Ruby
riazmohamed/basic_ruby_projects
/bubble_sort/bubble_sort.rb
UTF-8
645
3.921875
4
[]
no_license
def bubble_sort(arr) sorted_array = arr for i in 0...(arr.length) do (arr.length - 1).downto(i + 1) do |j| current_number = arr[j] next_number = arr[j - 1] swap(sorted_array, j, j-1) if next_number > current_number end end sorted_array end def swap(array, a, b) temp = array[a] arr...
true
28c48d066d17a11c316fc9993eb38c8e184a7481
Ruby
FrederikNS/advent-of-code
/ruby/2021/10/part1.rb
UTF-8
1,371
3.125
3
[]
no_license
require 'pry' module Y2021 module Day10 module Part1 def self.read_input File.readlines('2021/10/puzzle-input.txt').map(&:chomp) end def self.parse_input raw raw.map {|line| line.chars} end def self.find_syntax_er...
true
82e40e5d66451c67b0d597edbdf8be5f855d5700
Ruby
rambleraptor/soryo
/lib/commands/command.rb
UTF-8
1,063
2.5625
3
[]
no_license
require 'yaml' require 'pathname' module Soryo class Command attr_reader :config def self.descendants descendants = [] ObjectSpace.each_object(singleton_class) do |k| descendants.unshift k unless k == self end descendants end...
true
fccddfcaacd98f3bf7b65142c4034cddf81a451b
Ruby
ehowe/rpn_calculator
/spec/main_spec.rb
UTF-8
1,228
2.84375
3
[]
no_license
# frozen_string_literal: true require 'spec_helper' describe Rpn::Main do describe '.process' do let(:number1) { SecureRandom.random_number(100) } let(:number2) { SecureRandom.random_number(100) } {'addition' => '+', 'subtraction' => '-', 'multiplication' => '*', 'division' => '/'}.each do |operation, ...
true
f8ec0ddd34971927c2a4636d67a0147b6ab8386d
Ruby
sphjlin/CS1632-D2
/location_relation_test.rb
UTF-8
7,649
2.71875
3
[]
no_license
require_relative 'location' require_relative 'location_relation' require 'minitest/autorun' # This class is set up to test location generation as well as their methods class LocationRelationTest < Minitest::Test # This method initializes a new location relation to be tested def setup @locations = LocationRela...
true
ec4bb1a03d4d11e263e6035b2541e44a6c24d095
Ruby
CSC667server/WebServer
/http/request.rb
UTF-8
1,784
3.5625
4
[]
no_license
class Request attr_reader :stream, :method, :identifier, :query attr_reader :version, :header, :body def initialize(socket) @stream = socket_to_s(socket) @headers = {} end def parse() # break stream into 3 parts request_line = seperate_request_line headers = seperate_headers @body = seperate_body ...
true
e515361d7532685b4173429d6776fc59999ecaab
Ruby
tijn/virginity
/lib/virginity/dir_info.rb
UTF-8
2,505
2.953125
3
[ "MIT" ]
permissive
require 'virginity/bnf' require 'virginity/dir_info/line_folding' require 'virginity/dir_info/content_line' require 'virginity/dir_info/query' require 'virginity/vcard21/reader' $KCODE = 'U' unless defined? Encoding::UTF_8 module Virginity # see rfc 2425, MIME Content-Type for Directory Information. # # Basic...
true
044cdc6553b149a7bde422b6ecff8af256d08d4f
Ruby
kbence/jenkins-dashboard
/lib/cache.rb
UTF-8
487
3.1875
3
[]
no_license
class Cache def initialize(timeout = 60) @timeout = timeout @cache = {} end def get(key, &block) return @cache[key][:value] if valid?(key) value = block.call set(key, value) end private def set(key, value) @cache[key] = { :expires => @timeout + Time.new.to_i, :v...
true
5bb31923bc0a9097042a01d3d2bbb5af6ebce63f
Ruby
marckm/firsthandonruby
/ruby_lang/1-hellowork.rb
UTF-8
104
3.109375
3
[ "MIT" ]
permissive
class Hello def say_hello() puts "Hello World from Ruby" end end hello = Hello.new hello.say_hello
true
5ffd3f2587344f1249d99b51bfb7fafd99873858
Ruby
asdqwex/ruby-practice
/v2/5.rb
UTF-8
295
3.578125
4
[]
no_license
####5. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. ####What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? num = 20 until (1..20).all?{ |i| num % i == 0 } num +=20 end puts num
true
8d799594d2bf661cd61d9c92c50458d485ee9600
Ruby
supportleap/beacon
/test/models/status_test.rb
UTF-8
591
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'test_helper' class StatusTest < ActiveSupport::TestCase test ".default_message_for returns message for level" do assert_equal "Everything operating normally.", Status.default_message_for("green") assert_equal "We're investigating increased error rates.", Status.default...
true
2b72ac3b70584d7eacbdddbfdffa096040021809
Ruby
gengogo5/atcoder
/ABC/abc240/ABC240_D.rb
UTF-8
525
3.140625
3
[]
no_license
N = gets.to_i a = gets.split.map(&:to_i) st = [] N.times do |i| if i == 0 || st.size == 0 st << [a[i],1] else # 連続した場合 if a[i] == st[-1][0] && a[i] # 先頭要素に書かれた連続個数+1とともにpush st << [a[i], st[-1][1] + 1] # kが書かれたボールがk個連続したら if a[i] == st[-1][1] # 個数分取り出す (st[-1][1...
true
a5f3dee56f286114233cc6f84bd6a70935537d2f
Ruby
anithri/toy
/spec/toy_spec.rb
UTF-8
1,201
2.515625
3
[ "MIT" ]
permissive
require 'spec_helper' describe Toy do context "Integration Tests" do subject { Toy } it { subject.should eq Toys::MasterToy.instance } it {subject.containers.should match_array [:array,:hash,:value]} it {subject.generators.should match_array [:fixnum,:symbol,:sym,:s,:string,:rand_range,:symbols]} ...
true
0946a683d78b837895373cf9801a37e658fa8a4f
Ruby
walidwahed/ls
/101-programming-foundations/lesson_4/exercises_methods_and_more/04.rb
UTF-8
351
3.796875
4
[]
no_license
# Exercise 4 # What is the return value of each_with_object in the following code? Why? ['ant', 'bear', 'cat'].each_with_object({}) do |value, hash| hash[value[0]] = value end # since we are passing each_with_object a hash as an argument, we are going to get a hash # it will be filled as 'a' = >'ant', etc, since w...
true
70fa0560c44c7ddd9eab9663afe630188b15621f
Ruby
ShawkBawks/-MathGame
/players.rb
UTF-8
724
3.75
4
[]
no_license
class Player attr_accessor :name, :score #sets player name and score def initialize(name) @name = name @score = 3 end #Lowers player score when wrong answer supplied def wrong_answer @score -= 1 end #Triggers game over when score is 0 def lose @score == 0 end #Creates new Que...
true
5a925524f36a88f23adb32f229ed805bf3f34755
Ruby
emono/contribution_count
/lib/contribution_count/client.rb
UTF-8
1,502
2.71875
3
[ "MIT" ]
permissive
module ContributionCount class Client class NoAccountError < StandardError; end class NoDataError < StandardError; end attr_reader :url URL = "https://github.com/users/" def initialize(account_name) @url = URL + account_name + "/contributions" end def today today = Date.today...
true
8c31bdbb0bd48de02281302470bdb0d2dc8d3b67
Ruby
paigekellydev/MyCue
/backend/app/applicaiton.rb
UTF-8
2,804
2.921875
3
[]
no_license
require 'pry' require 'json' class Application def call(env) resp = Rack::Response.new req = Rack::Request.new(env) # if req.path.match(/login/) && req.post? # body = JSON.parse(req.body.read) # user = User.find_by username: body["username"] # if user # return [ # ...
true
ea65a7e4258dd1a714edfef005151dd76977f620
Ruby
idl3/geometric-sequencing-filter
/lib/geometric_sequence.rb
UTF-8
874
2.890625
3
[ "MIT" ]
permissive
require 'geometric_sequence/helper' require 'geometric_sequence/core_ext' module GeometricSequence class Geometric include GeometricSequence::Helper attr_reader :choices, :pk def initialize @choices = {} @pk = nil end def set_choices(choices) if choices.class == Array @...
true
e0f9cc0ff5b178d513916ea0b6f8a1d9c5bec078
Ruby
melzreal/array-CRUD-lab-v-000
/lib/array_crud.rb
UTF-8
612
3.984375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def create_an_empty_array cats = [] end def create_an_array cats = ["mario", "takahata", "yumi", "coby"] end def add_element_to_end_of_array(array, element) array.push("#{element}") end def add_element_to_start_of_array(array, element) array.unshift("#{element}") end def remove_element_from_end_of_array(arr...
true
1b628e8bfc502961e54b3e0565ae03cc93919ba5
Ruby
jdsutherland/refactoring-exercises
/extract-value-object/spec/score_spec.rb
UTF-8
1,132
3.203125
3
[]
no_license
require 'spec_helper' describe Score do context "implements equality" do it 'detects equal scores' do score1 = Score.new(90) score2 = Score.new(90) expect(score1).to eq score2 end end context "invalid arguments" do it 'errors on negative score' do score = -1 expect { ...
true
92c4d1834f42517ede3c8db93480e489540561ea
Ruby
SamuSan/Ruby_Higher_Lower
/lib/game.rb
UTF-8
583
3.875
4
[]
no_license
class Game attr_reader :turns, :max_turns def initialize(number_of_turns, secret_number) @secret_number = secret_number @max_turns = number_of_turns @turns = 0 @won = false end def in_progress? remaining_turns > 0 && !won? end def remaining_turns @max_turns - @turns end def s...
true
4b176718c2faa5beb6f07c1b9495dfff3ade8e56
Ruby
DAMS-Bale/flippd
/app/routes/quiz.rb
UTF-8
1,104
2.640625
3
[]
no_license
class Flippd < Sinatra::Application get '/quiz/:id' do @quiz = Quiz.get(params[:id]) erb :quiz end post '/quiz/:id/mark' do # Get the answers from the form @answers = extract_post_data(params) quiz = Quiz.get(params[:id]) @results = quiz.mark(@answers) # Only save if logged in. i...
true
1d308f22a27157d1fbec827b1483fd2c6b4640d4
Ruby
jeremymichel/Prefixr-Gem
/lib/prefixr.rb
UTF-8
1,377
3.265625
3
[]
no_license
require "uri" require "net/http" class Prefixr def initialize(args) @url = URI.parse "http://prefixr.com/api/index.php" @input = args[0] @output = args[1] unless @input puts "\n$ prefixr [input file] [output file]" puts "- If no output file is specified input file will be overwritten." puts "- If a d...
true
62ff2610068b46f4af33667831bec8203636c31a
Ruby
ismailj27/school-domain-online-web-sp-000
/lib/school.rb
UTF-8
548
3.453125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code here! class School attr_accessor :school, :roster attr_reader :name def initialize(name) @name = name @roster = {} end def add_student(s_name, s_grade) if @roster[s_grade] @roster[s_grade] << s_name else @roster[s_grade] = [] @roster[s_grade] << s_name en...
true
e174fa39c4475fbe816a33b237a8fe706a35f790
Ruby
cedric-joaquin/CLI-Project
/lib/category.rb
UTF-8
352
3.265625
3
[ "MIT" ]
permissive
class Category attr_reader :name @@all = [] def initialize(category) @name = category.capitalize @@all << self @@all = @@all.sort_by{|cat| cat.name} end def self.select(index) self.all[index].name end def self.all @@all end def self.clear ...
true
7a89c2ce44691eb2fa23a4fb39766429994153cc
Ruby
m-negishi/ruby_training
/TeachYourselfRuby/section6/6.2.1.rb
UTF-8
1,627
4.40625
4
[]
no_license
# keyをシンボル(文字列)としてhash生成 japanese_months = { '1': '睦月', '2': '如月', '3': '弥生', '4': '卯月', '5': '皐月', '6': '水無月', '7': '文月', '8': '葉月', '9': '長月', '10': '神無月', '11': '霜月', '12': '師走' } (1..12).each do |month| # 数値をシンボルに変換するために一度文字列に変換 month_symbol = month.to_s.intern puts "#{month}月は #{japanese_months[month_symbol...
true
04f2bee1e6933e298f53debf1c8a522b3a5b9b15
Ruby
derekjmaloney/ruby-objects-has-many-through-lab-v-000
/lib/song.rb
UTF-8
151
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :genre, :artist def initialize(name, genre) @name = name self.genre = genre genre.add_song(self) end end
true
e8e08a5eb44033997dfffa8aa3f0f8a797649f75
Ruby
broothie/advent-of-code
/2018/day7/one.rb
UTF-8
1,816
3.5625
4
[]
no_license
require 'set' input = <<-INPUT Step C must be finished before step A can begin. Step C must be finished before step F can begin. Step A must be finished before step B can begin. Step A must be finished before step D can begin. Step B must be finished before step E can begin. Step D must be finished before step E can b...
true
4143dbb87e1c71ba9a8475281f9e81a1c71147b2
Ruby
tgray017/ttt-with-ai-project-v-000
/lib/players/computer.rb
UTF-8
1,357
3.375
3
[]
no_license
module Players class Computer < Player attr_reader :game def corner_move(board) corners = ["1", "3", "7", "9"] corners.shuffle.detect {|corner| !board.taken?(corner)} end def winning_move(board) winning_combination = game.almost_won? winning_combination.detect {|position|...
true
18efc083082dfc0e84e4ad0f619fb335c6b6aaa9
Ruby
mscheel/todo_list
/lib/task.rb
UTF-8
345
3.21875
3
[]
no_license
class Task # : signifies symbol, one location in memory entire time attr_accessor :title attr_accessor :priority attr_accessor :completed def initialize(title, priority = 10) self.title = title self.priority = priority self.completed = false end def complete?() completed end def complete self.c...
true
e5850224075b33804d19f720fdee14fc07bd5d09
Ruby
XingyuLu/mazes
/Maze.rb
UTF-8
5,496
3.890625
4
[]
no_license
require 'set' #Xingyu Lu #Maze #this class represents a cell in the maze class Point attr_reader :x, :y, :prev #this cell contains its coordinates and its previous cell in the route def initialize(x,y) @x = x @y = y @prev = nil end def setPrev(p) @prev = p end def to_S "(#{x}, #{y}...
true
04cc6c28ba2b8fd81241c6fa36a6751227d6f589
Ruby
deanwilson/puppet-ip_in_range
/lib/puppet/parser/functions/ip_in_range.rb
UTF-8
1,854
3.09375
3
[ "Apache-2.0" ]
permissive
module Puppet::Parser::Functions require 'ipaddr' newfunction(:ip_in_range, type: :rvalue, arity: 2, doc: "ip_in_range returns true if the ipaddress is within the given CIDRs usage: ip_in_range(<IPv4 Address>, <IPv4 CIDR>) $valid_ip = ip_in_range('10.10.10.53', '10.10.10.0/24') # $valid_ip == true ...
true
e799ac1d90e6dc5ac051b4b5ad27a2ba45dcc394
Ruby
AJ8GH/bookmark-manager
/spec/unit/user_spec.rb
UTF-8
752
2.515625
3
[]
no_license
describe User do describe '.create' do it 'creates a new user' do user = described_class.create(email: 'test@test.com', password: 'Password123') expect(user.email).to eq 'test@test.com' end it 'passes the password through BCrypt before storing it' do expect(BCrypt::Password).to receive(...
true
cb22420769ff5e6fd899669ea6dbab80912aab46
Ruby
InhamulHassan/Maze_Runner
/app/helpers/rec_back.rb
UTF-8
2,844
3.609375
4
[]
no_license
# -------------------------------------------------------------------- # Recursive backtracking algorithm for maze generation. Requires that # the entire maze be stored in memory, but is quite fast, easy to # learn and implement, and (with a few tweaks) gives fairly good mazes. # Can also be customized in a variety of ...
true
c655e0a220ae019622a79eda26884fdd2642e4da
Ruby
thegoodgood/ggbackend
/app/models/list.rb
UTF-8
725
2.53125
3
[ "MIT" ]
permissive
class List < ApplicationRecord def new # twitter_api = ApiTwitter.new new_list = ApiTwitter.new_list(name) end def add_single_member(list_name, members_array=[]) # list_id = List.where(name:list_name).map(&:id_str)[0].to_i # slug = List.where(name:name).map(&:slug)[0] # list_id = List.fi...
true
ebc2e8f09f435d319b6b96493a6c7a180cf5db2d
Ruby
hannah/shapes
/lib/right_triangle.rb
UTF-8
312
3.65625
4
[]
no_license
class RightTriangle def initialize(height, width) @height = height @width = width end attr_reader :height attr_reader :width def hypotenuse Math.sqrt(height ** 2 + width ** 2) end def perimeter height + width + hypotenuse end def area (height + width).to_f/2 end end
true
4034c2e9e92e7fd67955b69c196418db90e6347a
Ruby
solds-zz/intro-to-programming
/chapter3/name.rb
UTF-8
207
3.65625
4
[]
no_license
print "Enter your first name: " first_name = gets.chomp print "Enter your last name: " last_name = gets.chomp full_name = "#{first_name} #{last_name}" puts "Hello, #{full_name}!" 10.times { puts full_name }
true
cd5fe4567f82ed92b4c19d7f7259d297b9e30a01
Ruby
davibschilling/simple_ruby_tests
/spec/calculator/calculator_spec.rb
UTF-8
1,265
3.484375
3
[]
no_license
# importa a classe que será testada require 'calculator' # declara a classe a ser testada # describe Calculator do # Instancia uma variável com o SUBJECT para utilizar nos testes # subject(:calc) { described_class.new() } # ooooooooooouuuuuuu # declara a classe a ser testada como uma string de descrição descri...
true
106dd8b33317724ff48640c9ec874933e33a4d0e
Ruby
Telixia/leetcode-3
/Medium/1637-Widest Vertical Area Between Two Points Containing No Points/Sort.rb
UTF-8
236
3.046875
3
[]
no_license
# @param {Integer[][]} points # @return {Integer} def max_width_of_vertical_area(points) ret = 0 points.sort_by! { |p| p[0] } (1...points.length).each do |i| ret = [ret, points[i][0] - points[i - 1][0]].max end ret end
true
224f82ec73332548a24b143ec5b2352efb6bba8f
Ruby
ericsaboia/advernote
/export.rb
UTF-8
818
2.609375
3
[]
no_license
require "digest/md5" require 'evernote_oauth' require_relative 'page' # initialize dependencies authToken = 'your developer token' if authToken == "your developer token" puts "Please fill in your developer token" puts "To get a developer token, visit https://sandbox.evernote.com/api/DeveloperToken.action" exit(...
true
6d1f568b2997d1d6d0befded4a7adf3cab8726c4
Ruby
nequalszero/homeworks
/W1D3/recursive_exercises.rb
UTF-8
1,174
4.125
4
[]
no_license
# Write a function sum_to(n) that uses recursion to calculate the sum from 1 to n (inclusive of n). def sum_to(n) return nil if n < 1 return 1 if n == 1 n + sum_to(n-1) end # Test Cases # p sum_to(5) # => returns 15 # p sum_to(1) # => returns 1 # p sum_to(9) # => returns 45 # p sum_to(-8) # => returns n...
true
2de833efc88c2f52755e2fc151172040a584fadf
Ruby
MinerBoe/car
/0.rb
UTF-8
228
3.03125
3
[]
no_license
require './car' require './trip' mustang = Car.new("Ford", "Mustang", 30, 15.5) trip = Trip.new("Denver", "Los Angeles", 1016) trip2 = Trip.new("Denver", "New York", 1778) puts trip.gasCost(mustang) puts trip2.gasCost(mustang)
true
dc470d6d7ce760b2190af4060d85fdf8cd5d27fa
Ruby
i-d-o/lib_agregator
/lib/chtyvo_importer.rb
UTF-8
2,444
2.875
3
[]
no_license
class ChtyvoImporter attr_accessor :data, :authors, :genres, :tags def initialize # ActiveRecord::Base.logger.level = 1 @authors = {} @genres = {} @tags = {} end def import @data = JSON.parse open('public/Chtyvo/data_2017_06_23.json').read data.each_with_index do |entry, i| begi...
true