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
a3568298d72bcb6ee2a1fd16ad9cdddbd0256b7f
Ruby
xord/reflexion
/xot/test/test_bit_flag.rb
UTF-8
1,963
2.90625
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- require_relative 'helper' class TestBitFlag < Test::Unit::TestCase include Xot::BitUtil def flag(*args, &block) bf = Xot::BitFlag.new(*args, &block) bf.flag :bit1, bit(1) bf.flag :bit2, bit(2) bf.flag :bit3, bit(3) bf.flag :bit5, bit(5) bf.flag :all, bit(1, 2, ...
true
2320c6aae9a6c3c1768aecf10102a6b3bb6ab50a
Ruby
CitizenofWorld/WDI_13_HOMEWORK
/Jessica Sole/wk04/3-wed/monkey/monkey.rb
UTF-8
335
3.890625
4
[]
no_license
class Monkey def initialize(name, species) @name = name @species = species @foods_eaten = [] end def name return @name end def species return @species end def eat(food) @foods_eaten.push food end def introduce puts "Hi my name is #{@name}. I am a #{@species}. I had #{@foods_eaten} for bru...
true
c975262e13e6ce1032ed047625014d6bd370de70
Ruby
cheaphunter/stackskills-dl
/lib/utilities.rb
UTF-8
376
2.84375
3
[ "MIT" ]
permissive
class Utilities class << self def escape_chars(string) string.tr('(', '-').tr(')', '-').tr(' ', '_').tr("\\", "-").tr("/", "-").tr(":", "-").tr("*", "-").tr("?", "-").tr("<", "-").tr(">", "-").tr("|", "-").tr("\"", "-").tr("&", "and") end def mkchdir(dir) system 'mkdir', '-p', dir Dir....
true
8d56bf311b097a62fe2bf69c28200af96ee832d9
Ruby
scy0626/kakaobot_maple
/app/controllers/kakao_controller.rb
UTF-8
1,322
2.515625
3
[]
no_license
class KakaoController < ApplicationController def keyboard @msg = {type: "buttons", buttons: ["소개", "가입문의", "거래"]} render json: @msg, status: :ok end def message @result = params[:content] if @result.include? "소개" or @result.include? "순하리" @msg = { message: ...
true
8fed65f5cb655da3726c31d84b72f9149c4426e1
Ruby
Mattieuga/CodeNow-May2014
/makeal/colors_bella.rb
UTF-8
594
3.5
4
[]
no_license
require 'colorize' require 'win32console' puts "Codenow".colorize(:blue) colors_list= [:red, :green, :blue, :yellow, :magenta, :cyan, :white] #ask user for message puts "Say Something" user_message=gets.chomp #print user message in color round=0 begin letters_printed = 0 user_message.each_char do |character| print c...
true
6a81afb3b8a2c2d2bf538f360674017ef469ab21
Ruby
vanakenm/tdd-examples
/v3-play/src/game.rb
UTF-8
154
3.34375
3
[]
no_license
class Game attr_reader :pieces def initialize @pieces = 0 end def empty? pieces == 0 end def play(x, y) @pieces += 1 end end
true
56068030a9fd15412a427f88a8f6a24ba3f3b1b8
Ruby
imranariffin/coding-practice
/125/cg_125_easy.rb
UTF-8
450
3.53125
4
[]
no_license
# @param {String} s # @return {Boolean} def is_palindrome(s) return true if s.empty? i1 = 0 i2 = s.length - 1 while i1 < i2 if i1 < s.length && !(s[i1] =~ /[A-Za-z0-9]/) i1 += 1 next end if i2 >= 0 && !(s[i2] =~ /[A-Za-z0-9]/) i2 -= 1 ...
true
d065784f21419d91c3a3ccbbf1133e25cbde8b76
Ruby
errnox/some-ruby-things
/launchcli/launchcli
UTF-8
874
3.125
3
[]
no_license
#!/usr/bin/env ruby class Launchcli def initialize() @choices = []; @commands_file_name = '.launchcli' @commands_file_location = Dir.home + '/' + @commands_file_name @options = read_commands_file() @separator = '-' * 75 end public def run() print("Search: ") search_string = gets ...
true
f84350031639e3fa9e33ce66869778a3313d0bca
Ruby
DerekYu177/testbed
/ping.rb
UTF-8
2,600
3.03125
3
[]
no_license
require "descriptive_statistics" def block_into_small_arrays(input) arr = [] input.each_line do |line| arr << line end arr end def find_time_in_each_line(array) data_set = [] array.each do |line| break unless time_without_time = line.match(/time=\d*.\d*/) time_with_time = time_without_time[0]....
true
d481501a9f456759851862ae32650bade08e8ee0
Ruby
akr/webapp
/sample/query.cgi
UTF-8
1,195
2.53125
3
[ "BSD-3-Clause" ]
permissive
#!/usr/bin/env ruby require 'webapp' require 'pathname' Template = <<'End' <html> <head> <title>query sample</title> </head> <body> <form _attr_action="webapp.make_relative_uri"> Menu: <select name=menu multiple> <option selected>mizuyoukan</option> <option>anmitsu</option> ...
true
079dca776f6a2ab418c0c817e479568bdd10e7b4
Ruby
blahutka/terminitor
/lib/terminitor/abstract_capture.rb
UTF-8
1,158
2.859375
3
[ "MIT" ]
permissive
module Terminitor # This AbstractCapture defines the basic methods that the Capture class should inherit class AbstractCapture # Generates .term file from settings of currently opened terminal windows and tabs def capture_settings capture_windows.inject("") do |config, w| config << generate_ob...
true
6023173450f9dfb643de3dc608dbb85fc6bca750
Ruby
benedictkohtc/WDI-Project3-WhereWork
/lib/tasks/seed_from_google_places.rake
UTF-8
5,445
2.59375
3
[]
no_license
# normally, use rails db:seed instead of running this task, # this task is only for getting new data from Google Places from scratch. # populates locations from Google Places # makes random values for some fields # will get photos and upload them to Cloudinary also, # so you need valid Cloudinary account data in confi...
true
3815a950ea0ff84af70afb9028553927170be2ed
Ruby
gemcfadyen/Apprenticeship-RubyRackWebTicTacToe
/lib/ttt_controller.rb
UTF-8
1,501
2.71875
3
[]
no_license
require 'game_parameters' require 'player_options' require 'web_ttt' require 'board_adapter' require 'players' class TTTController def self.call(env) route = env['REQUEST_PATH'] request = Rack::Request.new env if route == '/favicon.ico' default_success_response elsif route == '/' show_p...
true
d02a9e8454024e86ec63c08988b18f7f7951e318
Ruby
hwalborn/project-euler-largest-palindrome-product-web-0217
/lib/oo_largest_palindrome_product.rb
UTF-8
334
3.25
3
[]
no_license
# Implement your object-oriented solution here! class LargestPalindromeProduct def answer max = 0 (900..999).each do |num_1| (900...num_1).each do |num_2| if((num_1 * num_2).to_s.split('') == (num_1 * num_2).to_s.split('').reverse) max = num_1 * num_2 end end end ...
true
82d327165494533eeadc864ad5fa56eee3bf0faf
Ruby
TheJefe/gplan
/lib/printer.rb
UTF-8
2,910
2.953125
3
[]
no_license
require 'haml' class Printer def html stories $stories = stories file_path = File.expand_path('../../templates/template.html.haml', __FILE__) template = File.read(file_path) engine = Haml::Engine.new(template) File.write 'releasenotes.html',engine.render end def print stories dependenci...
true
c2b9d9aadcca6d5d18e3efaab9f425046867e75b
Ruby
AliYous/Mini-Jeu-POO
/lib/player.rb
UTF-8
2,560
3.859375
4
[]
no_license
#------------------------------------------------------------ CLASS ------------------------------------------------------------ class Player attr_accessor :name, :life_points def initialize(name) @name = name @life_points = 10 end #Affiche l'état de pdv actuel du player sur lequel la méthode est app...
true
4b0015153be6000a5e06cc75587287f5560e2152
Ruby
townie/sorting_alogrithims
/merge_sort.rb
UTF-8
1,576
3.734375
4
[]
no_license
require 'benchmark' def merge_sort(array) return array if array.length <= 1 left = array.shift(array.length/2) right = array left = merge_sort(left) right = merge_sort(right) sorted_list = [] until left.empty? && right.empty? if left.empty? sorted_list<<right.shift elsif right.empty? ...
true
cc89b5bb9c6470a433dc25656d24e1c8bc76c314
Ruby
dileep-g/Cord-Cutter
/app/helpers/webparser/parser.rb
UTF-8
2,172
3.03125
3
[]
no_license
require 'webdrivers' require 'watir' require 'nokogiri' require 'htmlentities' module WebParser def WebParser.parse_page(url) # load all channels from database channels_in_db = [] Channel.all.each do |channel| channels_in_db << channel.name.delete(' ').downcase end ...
true
0d8acd21359d3ba6707c0b8948d4fc94b77fe848
Ruby
Takhmina175/tic-tac-toe-game
/lib/players.rb
UTF-8
228
3.0625
3
[ "MIT" ]
permissive
class Player attr_accessor :curr_player def self.input_range?(input) input.negative? || input > 8 end def self.switch_input(curr_input = 'X') if curr_input == 'X' 'O' else 'X' end end end
true
abf6e3a52044f62aa68545b3c8d5d768907c431d
Ruby
keeks5456/ruby-enumerables-cartoon-collections-lab-part-2-sfo01-seng-ft-060120
/cartoon_collections.rb
UTF-8
507
3.25
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'pry' def square_array(array) array.map do |squared| squared * squared end end def summon_captain_planet(planeteer_calls) planeteer_calls.collect{ |calls| "#{calls.capitalize}" + "!"} end def long_planeteer_calls(planeteer_calls) planeteer_calls.any? do |elements| elements.length > 4 end end def fin...
true
24244b16af51d699517ceea002c74125e1f67679
Ruby
emarquez26/exerciseRuby
/Forkme/e1_rubycalculator.rb
UTF-8
2,216
4
4
[]
no_license
puts "-------------Bienvenido a la calculadora-------------" resp="si" while resp=="si" def menu puts "1.- sumar" puts "2.-restar" puts "3.-multiplicar" puts "4.-dividir" puts "5.-Raiz cuadrada" puts "6.-Factorial" puts "7.Exponencia" puts "" puts "Digite opcion a escojer para real...
true
ec24c25c1fc477def6be8391a7a6e4fa9c4f84bc
Ruby
igorpertsev/rest_api
/spec/commands/contracts/bulk_import_spec.rb
UTF-8
2,917
2.53125
3
[]
no_license
require 'rails_helper' RSpec.describe Contracts::BulkImport do let(:customer) { create(:customer, password: '123test') } describe '#call' do subject { described_class.call(customer.id.to_s, params) } context 'valid parameters' do let(:params) do [ { price: Faker::Nu...
true
c4cf781ce60d6edcf0e1d8b7d123b25a46511a41
Ruby
JoeQuattrone/j_travel
/app/models/hotel.rb
UTF-8
2,490
2.765625
3
[]
no_license
require 'nokogiri' require 'open-uri' require 'rest-client' require 'net/http' require 'json' class Hotel < ApplicationRecord has_many :users, through: :visits has_many :visits validates :name, uniqueness: true, presence: true validates :address, presence: true validates :image_url, presence: true valid...
true
4e0ed001e2f5453af330049ef422d2eb5cab39a0
Ruby
thnukid/facebook_data_analyzer
/classes/analyzeables/analyzeable.rb
UTF-8
2,178
3.015625
3
[]
no_license
class Analyzeable def self.parse raise "needs to be implemented by concrete class" end GROUP_BY = [].freeze COUNT_BY = [].freeze def initialize(threads_supported: nil, processes_supported: nil, parallel: false) # Grouped by is weird and needs a hash for each GROUP_BY, hash for each unique group, and...
true
65d5d0c9420ccd177e599e2c61ce6ad9d0276dff
Ruby
Mizar999/Game-of-Life---Gosu
/test/test_rect.rb
UTF-8
1,709
3.046875
3
[]
no_license
file = "../lib/rect.rb" begin require_relative file rescue NotMethodError require file end require "test/unit" class TestRect < Test::Unit::TestCase def setup @rect = Rect.new end def test_initialize assert_not_nil(@rect) end def test_width_and_height assert_width_and_height(0, 0) set_...
true
794d9dc9d4b9b1ab756ec1199ec2fac8f0fd8d64
Ruby
cyberarm/battleship
/lib/ship.rb
UTF-8
2,426
2.9375
3
[]
no_license
module Battleship class Ship include CyberarmEngine::Common attr_accessor :angle, :position, :grid_position def initialize(options = {}) puts self.class @options = options @angle = options[:angle] @angle ||= 0 @position = options[:position] @position ||= CyberarmEn...
true
bcb399cc497c9d4b14b65143c8f511ce01ce9732
Ruby
cowalla/GoalsApp
/app/models/user.rb
UTF-8
813
2.515625
3
[]
no_license
class User < ActiveRecord::Base attr_accessible :username, :password before_validation :reset_session_token validates :username, :password_digest, :session_token, :presence => true has_many :goals has_many :cheers def self.find_by_credentials(username, password) user = User.find_by_username(username) ...
true
97196b96f207304056814ec0face2c8a315c7e82
Ruby
kevincai79/phase-0-tracks
/ruby/shout.rb
UTF-8
915
4.125
4
[]
no_license
=begin module Shout def self.yell_angrily(words) words + "!!!" + " :(" end def self.yelling_happily(words) words + "! " + words + "! " + words + "!" end end puts Shout.yell_angrily('No') puts Shout.yelling_happily('Hurray') =end module Shout def yell_angrily(words) words + "!!!" + " :(" end...
true
2fff963881cca1947f6e4500b8e7a2360061e375
Ruby
elizabethcsw/oystercard_challenge
/spec/journeylog_spec.rb
UTF-8
2,174
2.703125
3
[]
no_license
require 'journeylog' # require 'journey' describe JourneyLog do let(:station1) { double :station1 } let(:station2) { double :station2 } let(:journey) { double :journey } let(:journey_c) { double :journey_c } subject { described_class.new(journey_c) } before do allow(journey).to receive(:in).and_retur...
true
80e449664c642821b0e092875c3041a63ba01c5e
Ruby
alishersadikov/jungle-beat
/lib/linked_list.rb
UTF-8
2,970
3.546875
4
[]
no_license
class LinkedList attr_reader :head, :valid, :valid_beats def initialize @head = nil @valid_beats = %w| blop boop bop dah dee deep ding ditt doo doom doop dop hoo la na oom plop shi shu suu tee woo | @valid = false end def valid?(sound) if @valid_beats.include?(sound) @valid = true else...
true
38b79c73b9d033b6595c07201e811f12bf8d8464
Ruby
theyworkforyou/shineyoureye-sinatra
/lib/factory/person.rb
UTF-8
847
2.53125
3
[]
no_license
# frozen_string_literal: true require_relative '../ep/person' require_relative '../membership_csv/person' module Factory class Person def initialize(mapit:, baseurl:, identifier_scheme:) @mapit = mapit @baseurl = baseurl @identifier_scheme = identifier_scheme end def build_ep_person(p...
true
9e8a5a49bf92253ff5b0c97b03bef69ba51b3446
Ruby
chef/mixlib-versioning
/spec/support/shared_examples/behaviors/sortable.rb
UTF-8
1,292
2.53125
3
[ "Apache-2.0" ]
permissive
# # Author:: Seth Chisamore (<schisamo@chef.io>) # Copyright:: Copyright (c) 2013-2018 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
true
eff6ded72ec990688690b3664fa2b41ed6c791c9
Ruby
shoma07/sqlite3_extend_function
/lib/sqlite3_extend_function/functions/mod.rb
UTF-8
586
2.6875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module SQLite3ExtendFunction module Functions # SQLite3ExtendFunction::Functions::Mod module Mod class << self # @param [Integer, Float] y # @param [Integer, Float] x # @return [Integer] # @raise [SQLite3::SQLException] def call(y, x...
true
4d24806d712c2ae0ad2b8f0aaaafacf7cb184ecd
Ruby
aastronautss/full-stack-preparatory-notes-and-exercises
/100/1_introduction_to_programming/1_the_basics/1.rb
UTF-8
52
2.828125
3
[]
no_license
first = "Tyler " last = "Guillen" puts first + last
true
e59d48756087c83b4f705dbd749eef9f56a68ce5
Ruby
mrfinch/rb_server_client
/processes/server.rb
UTF-8
1,885
3.15625
3
[]
no_license
# TODO: on close of connection send user disconnected require 'socket' require 'pry' @clients = [] server = TCPServer.new('localhost', 2000) def listen server loop { client = server.accept puts "Client accepted at #{Time.now}" thr = Thread.new(client) do username = nil client.puts 'Enter y...
true
7a8c5b02b3c45a536419b64b27679a2194e9fa38
Ruby
choroba/perlweeklychallenge-club
/challenge-213/roger-bell-west/ruby/ch-1.rb
UTF-8
467
3.34375
3
[]
no_license
#! /usr/bin/ruby require 'test/unit' def funsort(l0) l = l0.sort a = [] b = [] l.each do |k| if k % 2 == 0 then a.push(k) else b.push(k) end end a.concat(b) return a end class TestFunsort < Test::Unit::TestCase def test_ex1 assert_equal([2, 4, 6, 1, 3, 5], funsort([1, 2, ...
true
6262bee4f11f81481c2a0111d3ea20162ec6bca2
Ruby
coolbuc123/inHome
/kbutils/crawling/infomax.rb
UTF-8
2,653
2.578125
3
[]
no_license
=begin a = [1, 3, 5] File.open('www', 'w'){ |f1| f1.puts 'asdasd' f1.puts '1111111111' f1.puts a } =end require 'watir' #add1 = 'https://news.einfomax.co.kr/news/articleView.html?idxno=4073883' browser1 = Watir::Browser.new :firefox #browser1.goto add1 #next_page1 = browser1.div(id: 'article-view-content-div...
true
b15a7972182ed978b8884d4f439e1af2c8d9d9d5
Ruby
pawelduda/codeeval-ruby-solutions
/moderate/76.rb
UTF-8
679
3.703125
4
[]
no_license
# https://www.codeeval.com/browse/76/ def parse_input(input) input = input.split(',') { original: input[0], rotated: input[1] } end class String def is_rotation_of?(another_string) original_length = self.length - 1 doubled_self = self * 2 (0..original_length).each do |rotation| retu...
true
911d23645638f7f99e8433355468455554ea5011
Ruby
MasonHolland/module_3_test
/spec/requests/api/v1/item_records_spec.rb
UTF-8
3,593
2.71875
3
[]
no_license
require 'rails_helper' # When I send a GET request to `/api/v1/items` # I receive a 200 JSON response containing all items # And each item has an id, name, description, and image_url but not the created_at or updated_at RSpec.describe "items requests" do it "index returns all items" do item_1 = Item.create(name...
true
7f6036454c90a492eaa9c0f00c7eb60674f93374
Ruby
NorCalDavid/AppleIIeTeam_SudokuChallenge
/sudoku_solver_pseudocode.rb
UTF-8
840
3.328125
3
[ "MIT" ]
permissive
# Input: String of numbers and underscores representing sudoku board.n (incomplete board) # Output: String of numbers complete with no underscores. (filled board) # RCG - Row, Column, Grid # Steps: # Initial Pass # P-Code: # 0. Create Classes: Cell, (Board, Row, Column, Grid) # 1. Populate 3D array with the in...
true
29b23dc66c35723f5c3f776e438bc4d859732647
Ruby
di-stars/suseviclient
/vnc.rb
UTF-8
1,240
2.578125
3
[]
no_license
#!/usr/bin/env ruby #This is optional addon to suseviclient.sh. #It enables us to pass keystrokes to VM and automate custom scenarios #To use it you have to install ruby-vnc: #gem install ruby-vnc require 'rubygems' require 'net/vnc' if ARGV[0] == nil or ARGV[0] == '--help' puts "Usage: ./vnc.rb <server> <port> ...
true
6ea4e296a36249f2f4e481e7b15c494711e0eb0a
Ruby
kawakami-o3/PLC
/scm2asm/tests-1.9.2.rb
UTF-8
3,013
3.046875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require "./bootstrap" run_all "vectors", { '(vector? (make-vector 0))' => "#t", '(vector-length (make-vector 12))' => "12\n", '(vector? (cons 1 2))' => "#f\n", '(vector? 1287)' => "#f\n", '(vector? ())' => "#f\n", '(vector? #t)' => "#f\n", '(vector? #f)' => "#f\n", '(pair? (make-vec...
true
807e90c295082d6eb8a318ff9436a73c8a5e3ab6
Ruby
theand/our-boxen
/.bundle/ruby/2.0.0/gems/puppet-lint-0.3.2/lib/puppet-lint/plugins/check_strings.rb
UTF-8
3,035
2.65625
3
[ "MIT" ]
permissive
class PuppetLint::Plugins::CheckStrings < PuppetLint::CheckPlugin # Public: Check the manifest tokens for any double quoted strings that don't # contain any variables or common escape characters and record a warning for # each instance found. # # Returns nothing. check 'double_quoted_strings' do tokens....
true
15aeb7a004cb994c8151ff71006eec0d60618c80
Ruby
The-Speck/W2D4-Big-O
/windowed_range.rb
UTF-8
528
3.484375
3
[]
no_license
def windowed_max_range(arr, window_size) current_max = arr.first (0...arr.length - window_size+1).each do |idx| value = arr[idx, window_size].minmax.inject(:-).abs current_max = (value > current_max ? value : current_max) end current_max end p windowed_max_range([1, 0, 2, 5, 4, 8], 2) #== 4 # 4, 8 p...
true
5c63fac5750286455c832bcf8a4fa6d3176637fd
Ruby
teckjon/bloccit
/app/helpers/posts_helper.rb
UTF-8
350
2.53125
3
[]
no_license
module PostsHelper def user_is_authorized_for_post?(post) current_user && (current_user == post.user || current_user.admin?) end def render_censored_title(post) output = post.title if post.id % 5 == 0 output = "<strong>#{post.censored_title}</strong>" end ...
true
e743adfb2babddbd30b99b01e7e06627b78d5f1d
Ruby
ztbrown/photographer_scheduler
/app/models/entities/mimic.rb
UTF-8
311
2.640625
3
[]
no_license
module Entities # Include in ActiveRecord models to mimic Biz models. module Mimic def data self end def entity? false end def ==(other) if other.respond_to?(:entity?) && other.entity? self == other.data else super end end end end
true
a186a3f5d195302462a86c6b1485d69d06ea3f0b
Ruby
tbilous/task_JetThoughts
/lib/assignment/justifier.rb
UTF-8
2,166
3.203125
3
[]
no_license
require 'ostruct' module Assignment module Justifier extend self @@KNOWN_VERSIONS_REGEX = /v[12]/ @@SPACES_REGEX = /\s+/ def justify(input_str, n, version = 'v1') raise_if_argument_error(input_str, n, version) version == 'v1' ? justify_v1(input_str, n) : justify_v2(input_str, n) en...
true
468900cb9d6bad033335bca2abebc055b2a80631
Ruby
wilsonokibe/BasicRuby
/highlight_search_result/lib/string.rb
UTF-8
222
2.875
3
[]
no_license
class String def highlight_match(search_word) counter = 0 pattern = /(#{search_word})+/i gsub!(pattern) do |match| counter += 1 match = "(#{match})" end return counter, self end end
true
d80205138d6bfbf35a9701f2f62bc00294b07115
Ruby
justindelatorre/rb_101
/small_problems/easy_9/easy_9_7.rb
UTF-8
809
4.59375
5
[]
no_license
=begin Write a method that takes a first name, a space, and a last name passed as a single String argument, and returns a string that contains the last name, a comma, a space, and the first name. Inputs: - string Outputs: - string Requirements: - output string must follow format of "#{last_name}, #{first_name}" Cla...
true
c06d99a75956352c6c631fa38775e258bce14240
Ruby
danowar2k/unicode_utils
/test/test_unicode_6_0_0.rb
UTF-8
1,403
2.640625
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
# encoding: utf-8 require "test/unit" require "unicode_utils" # Tests behaviour in Unicode 6.0.0 that wasn't in the previously # supported standard. That means each one of these assertions fails # with UnicodeUtils 1.0.0. class TestUnicode_6_0_0 < Test::Unit::TestCase def test_char_name assert_equal "CYRILLIC...
true
4187aa563a4f8ea3e1da5196822afc8083c16d60
Ruby
markthomas93/negabaro.github.io
/_posts/backend/ruby_on_rails/rails/loop/each_with_index/1.ruby
UTF-8
109
3.203125
3
[ "MIT" ]
permissive
array = ["sana", "dahyun", "jihyo"] array.each_with_index do |element, index| p "#{index}:#{element}" end
true
23008288ee5c20398c070170edd570b7bff62b91
Ruby
riderjensen/sideProjects
/Ruby/zenRuby.rb
UTF-8
1,083
4.59375
5
[]
no_license
#different ways to write if statement puts "I'm not writing code!" unless true #different way to write if statement with an else print true ? "true" : "false" #shortened switch statment puts "Hello there!" greeting = gets.chomp case greeting when "English" then puts "Hello!" when "French" then puts "Bo...
true
1d7c200ee18cbb41781e4e21ff9b40c01d8873c2
Ruby
nktaushanov/rucomasy
/spec/core/executors/runnable_spec.rb
UTF-8
2,337
2.515625
3
[]
no_license
require 'fileutils' require './core/rucomasy' require './spec/rspec/compilation_helper' module Rucomasy RSpec.configure do |c| c.include CompilationHelper end describe Runnable do def random_subdir(dir = File.dirname(__FILE__)) File.join dir, random_dirname end before(:each) do @fir...
true
ea2f91ea11f5f0762ea1e78e489aad6811d44f43
Ruby
jtahstu/iCode
/Ruby/Test/begin.rb
UTF-8
619
3.609375
4
[]
no_license
#!/usr/bin/ruby puts "This is main Ruby Program" END { puts "Terminating Ruby Program" } BEGIN { puts "Initializing Ruby Program" } #指数算术 puts 2**(1/4)#1与4的商为0,然后2的0次方为1 puts 16**(1/4.0)#1与4.0的商为0.25(四分之一),然后开四次方根 #!/usr/bin/ruby -w puts 'escape using "\\"'; puts 'That\'s right'; #您...
true
840414fd7041d57423153fd0fb2f6cad0c2aefb3
Ruby
tjroeder/craft_time_2110
/lib/person.rb
UTF-8
486
3.203125
3
[]
no_license
class Person attr_reader :name, :interests, :supplies def initialize(info) @name = info[:name] @interests = info[:interests] @supplies = {} end def add_supply(name, quantity) @supplies[name] ||= 0 @supplies[name] += quantity end def can_build?(craft) craft.supplies_required.each_p...
true
ce478e41ee18bde3702e3ba8463194bbbadb005c
Ruby
ishikota/PokerServer
/spec/poker_engine/seats_spec.rb
UTF-8
1,661
2.671875
3
[]
no_license
require 'rails_helper' RSpec.describe Seats do let(:seats) { Seats.new } let(:player) { double("player") } describe "#sit_down" do it "should set player" do seats.sitdown(player) expect(seats.players).to include(player) end end describe "#size" do it "should return the number of ...
true
76daad774cc99242ed628c637d7618bb6f73dce9
Ruby
juanarbol/ruby
/vectores.rb
UTF-8
384
3.46875
3
[]
no_license
puts "Digite el tamanho de los vectores" n = gets.chomp.to_i vector1 = [] vector2 = [] for j in(0 ...n) puts "LLenando vector1 indice #{j}" vector1[j] = gets.chomp.to_f end for j in(0 ...n) puts "LLenando vector2 indice #{j}" vector2[j] = gets.chomp.to_f end c1 = vector1.reduce(:+) c2 = vector...
true
71f42098c94c55b9ae17812afdb5b337eb069193
Ruby
imathis/wordrush
/app/models/turn.rb
UTF-8
1,298
2.828125
3
[]
no_license
class Turn < ApplicationRecord belongs_to :round belongs_to :player belongs_to :game has_many :plays, dependent: :destroy has_many :words, through: :plays # length in seconds (add a couple of seconds to account for load time) def time_limit 62 end def new? plays.empty? end def time_elap...
true
bc2d6c7c2e06557c3d27d1cc8b31ab1fcc5e1aa1
Ruby
drproteus/chess
/pieces/vector_sum.rb
UTF-8
132
3.375
3
[]
no_license
def vector_sum(vectors) result = [0,0] vectors.each do |vec| result[0] += vec[0] result[1] += vec[1] end result end
true
626d1f53002ac96321fa8f5577d881b60df185e1
Ruby
mdippery/usaidwat
/lib/usaidwat/client.rb
UTF-8
1,549
2.546875
3
[ "MIT" ]
permissive
require 'usaidwat/service' require 'usaidwat/ext/time' module USaidWat module Client class ReachabilityError < RuntimeError def initialize(msg = nil) super(msg || 'Reddit unreachable') end end class NoSuchUserError < StandardError; end class BaseRedditor attr_reader :usern...
true
bd71745deec3370de93820895ed92350614ca3e0
Ruby
alwikah/oop-food-delivery
/app/controllers/employees_controller.rb
UTF-8
301
2.546875
3
[]
no_license
class EmployeesController attr_reader :employees_repository, :view def initialize(view) @view = view @employees_repository = EmployeesRepository.new end def index employees = employees_repository.all employees.each do |employee| view.display employee end end end
true
f46ad0bfce98292f780e030dc9bed8a27bca25e6
Ruby
enowmbi/algorithms
/first_recurring_character.rb
UTF-8
178
3.5
4
[]
no_license
def first_recurring_character(arr) char_hash = {} arr.each do |char| if char_hash.has_key?(char) return char else char_hash[char] = 1 end end end
true
aa808f3619c09fad4c367d0c3a37d37a41124cd3
Ruby
interfirm/rails-tutorial-2020
/app/helpers/datetime_helper.rb
UTF-8
412
2.53125
3
[]
no_license
module DatetimeHelper def message_datetime(datetime:) logger.debug(datetime) today = DateTime.now.beginning_of_day if today <= datetime datetime.strftime('%R') elsif today.yesterday <= datetime datetime.strftime('昨日 %R') elsif today.beginning_of_year <= datetime datetime.strftim...
true
dc4360e59b90769afd4e83ae674fcf63f77de3a2
Ruby
ajshemi/oo-meowing-cat-dumbo-web-111819
/lib/meowing_cat.rb
UTF-8
103
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
## code your solution here. require 'pry' class Cat attr_accessor :name def meow puts "meow!" end end
true
5339d9c5affe0ae1a1ad67370cae724d1bc8836b
Ruby
drumovski/Coder_Academy_Term_1_and_2
/week6/strict.rb
UTF-8
1,377
4.15625
4
[]
no_license
# Is it in the array strict mode # Arrays can store all different data types. # These arrays can get quite large and it can get # quite difficult to keep track of what is in them. # Sometimes, we want extra flexibility in an array search, # and want control over casing. # Create a function that will take a string...
true
5f8277de31f6694019f8861b7ecd68fe3c419c96
Ruby
jfeng702/JS-Exercises
/cracking/arraystring/one_away.rb
UTF-8
638
3.9375
4
[]
no_license
# pale, ple => true # pales, pale => true # pale, bake => false def one_away(str1, str2) return false if str1.length - str2.length > 1 i = 0 j = 0 one_fail = false while i < str1.length || j < str2.length if str1[i] == str2[j] i += 1 j += 1 elsif str1[i] != str2[j] return false if o...
true
cb71ed27b7699a563931c3d27d9a27c001665a17
Ruby
iangrubb/oo-cash-register-nyc-web-062419
/lib/cash_register.rb
UTF-8
910
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class CashRegister def initialize(discount = 0) @total = 0 @discount = discount @items = [] @transactions = [] end attr_accessor :discount attr_accessor :total def items @items end def add_item(title, price, quantity=1) @total += pr...
true
b6ef3b9a42be0351a67fea06a503df7144e01d34
Ruby
EricRicketts/LaunchSchoolPrepAndSupplements
/IntroductionToRegularExpressions/character-class-shortcuts/exercises.rb
UTF-8
1,637
3.328125
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require 'byebug' class Exercises < Minitest::Test def test_exercise_one str = "reds and blues" + "\n" + "the lazy cat sleeps" my_regex = /\s\w{3}\s/ assert_equal(3, str.scan(my_regex).length) end def test_exercise_two str = "Doc in a big red b...
true
29ac79f9bf1f2e57cffb921b8ab46f327262b626
Ruby
dan-f/coop-site
/lib/tasks/coop.rake
UTF-8
970
2.71875
3
[]
no_license
namespace :coop do desc "Populate database with list of coops" task create_coops: :environment do coops = ["Brown Bag", "Fairchild", "Harkness", "Keep", "Old Barrows", "Pyle", "Tank", "Third World"] coops.each do |coopName| coop = Coop.new({ name: coopName }) if coop.save puts "Co-op #{c...
true
cee0df0adb8e69cb3c21b73067c009a50a3ec750
Ruby
esumbar/passphrase
/spec/passphrase/passphrase_spec.rb
UTF-8
4,268
3.171875
3
[ "MIT" ]
permissive
require "passphrase" module Passphrase RSpec.shared_examples "Passphrase object" do it "responds to attribute reader method passphrase()" do expect(@passphrase).to respond_to(:passphrase) end it "responds to attribute reader method number_of_words()" do expect(@passphrase).to respond_to(:num...
true
cb235fd325c9e0fbb10eaf23b210d4a6455b37ce
Ruby
matadon/postinius
/lib/postinius/mime_type.rb
UTF-8
1,209
2.796875
3
[ "Apache-2.0" ]
permissive
module Postinius class MimeType include_class javax.mail.internet.ContentType # # Utility constructor; hands back the object if it's an address, # builds a new one if not. Helps us avoid needless object # churn. # def self.create_from(type) return(type) if address.is_a?(self) return(self.new(typ...
true
59545ece66c13dc0a70c1cc21f6786be737380a6
Ruby
UladKonop/TEST_TASK_Lunar_dinner
/table.rb
UTF-8
457
2.984375
3
[]
no_license
# frozen_string_literal: true require_relative('instance_counter') class Table include InstanceCounter attr_reader :id, :history, :people def initialize(seats_amount) @id = register_instance @seats_amount = seats_amount @history = [] @people = [] end def people=(person) @people << per...
true
e5d05b60a3b66966d2e8baccc23534ffcf076f3d
Ruby
kanderson38/dynamic-programming
/lib/max_subarray.rb
UTF-8
350
3.359375
3
[ "MIT" ]
permissive
# Time Complexity: O(n) where n is the number of items in the array # Space Complexity: O(1) def max_sub_array(nums) return 0 if nums == nil return nil if nums.length == 0 max_sum = nums[0] sum = 0 nums.length.times do |i| sum = [nums[i], sum + nums[i]].max if sum > max_sum max_sum = sum e...
true
c35cc423f4b44fcad4b7c16b7334f9bde6fdea95
Ruby
PlasticLizard/wonkavision
/lib/wonkavision/plugins/analytics/cellset.rb
UTF-8
4,116
2.671875
3
[ "MIT" ]
permissive
require "set" module Wonkavision module Analytics class CellSet attr_reader :axes, :query, :cells, :totals, :aggregation def initialize(aggregation,query,tuples) @axes = [] @query = query @aggregation = aggregation @cells = {} @measure_names = Set.new ...
true
1f79fce8b3910b35f4453ecb6e90c77c8ee3f91f
Ruby
shterev/Core-Ruby-1
/week0/1-standard-types/solution.rb
UTF-8
1,450
4.03125
4
[ "MIT" ]
permissive
def histogram(string) hash = {} string.each_char { |s| hash[s] = hash.key?(s) ? hash[s] + 1 : 1 } hash end def prime?(n) (1..n - 1).each { |i| return false if i % n == 0 } true end def ordinal(n) case n = n.to_s when n.end_with?('1') then "#{n}st" when n.end_with?('11') then "#{n}th" when n.end_wi...
true
ce5ac6578f93818c5c16a2b2c4389b67f8d3a131
Ruby
rueki/Ruby
/flow_control/ex2.rb
UTF-8
185
3.921875
4
[]
no_license
def change_caps(letters) if letters.length > 10 puts letters.upcase else puts letters end end puts "What would you like to say?" answer = gets.chomp change_caps(answer)
true
127d0ec6c7cd793a3857df00ad5ac47408c9ebb4
Ruby
zhangst23/tutorial
/Ruby/IntroToRuby/Ruby 学习笔记.rb
UTF-8
8,436
4.09375
4
[]
no_license
Ruby 学习笔记.rb 1. 在 Ruby 中定义类 class Customer end # Ruby 提供了四种类型的变量: # 局部变量:局部变量是在方法中定义的变量。局部变量在方法外是不可用的。在后续的章节中,您将看到有关方法的更多细节。局部变量以小写字母或 _ 开始。 # 实例变量:实例变量可以跨任何特定的实例或对象中的方法使用。这意味着,实例变量可以从对象到对象的改变。实例变量在变量名之前放置符号(@)。 # 类变量:类变量可以跨不同的对象使用。类变量属于类,且是类的一个属性。类变量在变量名之前放置符号(@@)。 # 全局变量:类变量不能跨类使用。如果您想要有一个可以跨类使用的变量,您需要定义全局变量。全局变量总...
true
25c0082d912a0f82381e71710edc0faf80c0b15b
Ruby
aamannai/Semester4_IS
/phase2.6/app/models/curriculum.rb
UTF-8
941
2.5625
3
[]
no_license
class Curriculum < ApplicationRecord #Relationships has_many :camps #Required validates_presence_of :name validates_presence_of :min_rating validates_presence_of :max_rating #Format validates :name, format: { with: /\A[a-zA-Z]+\z/} validates :min_rating, numericality: {:...
true
03544a21768b9058934a203b1288f7caf84eb582
Ruby
andyxhadji/monsterfinder
/app/models/profile_builder.rb
UTF-8
315
2.703125
3
[]
no_license
class ProfileBuilder attr_accessor :user attr_accessor :spots def initialize(user, spots) self.user = user self.spots = spots end def render { user: user, monsters: MonsterBuilder.new(spots).render, totalVotes: spots.map(&:total_vote_count).inject(0, &:+) } end end
true
f94c040048b7b200aded24334356aa04ea10f95f
Ruby
mamaadee/phase4
/app/models/credit_card_type.rb
UTF-8
212
3.125
3
[]
no_license
class CreditCardType #getter attr_reader :name, :pattern #initializer def initialize(name, pattern) @name, @pattern = name, pattern end def match(number) number.to_s.match(pattern) end end
true
140bd1beaaf5e21b4895f1799444088c56222b1a
Ruby
urbantumbleweed/urbantumbleweed
/w01/d04/Alexandra_Shook/temperature.rb
UTF-8
1,060
5.375
5
[]
no_license
# ### Celsius Temperature Converter # - Create a new file called temperature.rb # - Write `convert_to_fahrenheit` and `convert_to_kelvin` methods that will each take a temperature in Celsius as a parameter and return the converted temperature. # - Once you have these methods written, a program that does the following: ...
true
75f1f0756858ab90358a72aa3a444cad00aa1f8f
Ruby
thewmking/adv-ruby-building-blocks
/lib/bubble-sort.rb
UTF-8
822
4.53125
5
[]
no_license
#for each element in the list, compare it and the element directly to its right. #if out of order, swap elements. repeat. def bubble_sort(array) n = array.length - 1 loop do swapped = false (n).times do |i| if array[i] > array[i+1] array[i], array[i+1] = array[i+1], array[i] swapped ...
true
0c548b69f769f12ec3d8de8a4a8d0573b7887f58
Ruby
DmytroVasin/urlify
/test/urlify_test.rb
UTF-8
1,744
2.90625
3
[ "BSD-3-Clause" ]
permissive
#!/usr/bin/env ruby # encoding: UTF-8 lib = File.expand_path('../../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require 'test/unit' require 'urlify' class String include URLify end class URLifyTest < Test::Unit::TestCase def setup @philosopher = "Søren Kierkegaard" @biography = "Boyd: T...
true
ed24466608b138b16be9a4d0e478d15bd24ed762
Ruby
crisweber/corpus-processor
/lib/corpus-processor/processor.rb
UTF-8
893
3.34375
3
[ "MIT" ]
permissive
# The entry point for processing corpus. # # @example Simple use with default configuration. # CorpusProcessor::Processor.new.process('<P>Some text</P>') # # => "Some\tO\ntext\tO\n.\tO\n"" class CorpusProcessor::Processor # @param categories [Hash] the categories extracted with {Categories}. # @param parser [#...
true
e9326e4c2bbb1ae226bcfa02cab6a42dff6af60d
Ruby
jleo3/agile_software_development
/refactoring/lib/generate_primes_v1.rb
UTF-8
1,714
4.34375
4
[]
no_license
# This class gneerates prime numbers up to a user-specified # maximum. The algorithm used is the Sieve of Eratosthenes. # <p> # Eratosthenes of Cyrene, b. c. 276 BC, Cyrene, Libya -- # d. c. 194, Alexandria. The first man to calculate the # circumference of the Earth. Also known for working on # calendars with leap ...
true
c23bdd1c56d84ee9269240ae0b43d3e884d71ab2
Ruby
najwa/RubyLearning
/Week 3/Exercises/ex06_deaf_grandma.rb
UTF-8
918
4.28125
4
[]
no_license
# Write a Deaf Grandma program. Whatever you say to grandma (whatever you type in), she should respond with HUH?! SPEAK UP, SONNY!, unless you shout it (type in all capitals). If you shout, she can hear you (or at least she thinks so) and yells back, NO, NOT SINCE 1938! To make your program really believable, have gran...
true
85f61b76d850b27313467c2b1bad97a18f9e6dcc
Ruby
Dmitry-White/HackerRank
/30 Days of Code/Ruby/day_2.rb
UTF-8
692
3.78125
4
[ "MIT" ]
permissive
=begin Created on Sun Jul 11 15:04:17 2017 @author: Dmitry White =end =begin TODO: Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal'...
true
9570f7b885fdeee47c42e17b23490664d85ab514
Ruby
isaacagutey/flix
/spec/models/video_spec.rb
UTF-8
2,402
2.71875
3
[]
no_license
require 'spec_helper' describe Video do it "saves itself" do video = Video.create(title:"New Video", description:"some description") expect(Video.first.id).to eql(video.id) end it { should have_many(:categories) } it { should validate_presence_of(:title) } it { should validate_presence_of(:descri...
true
3561b6747f863a690524b7e7a0cde4e7d170993e
Ruby
jamesmacaulay/comp4106
/code/a1/decision_tree.rb
UTF-8
1,091
2.546875
3
[]
no_license
$LOAD_PATH.unshift File.dirname(__FILE__) require 'rubygems' require 'active_support' require 'tree' require 'lib/math_ext' require 'lib/tree_ext' module DecisionTree def self.subset(set, attribute, attribute_value) set.select {|example| example[attribute] == attribute_value} end def self.probability(set...
true
a802abc1526098c0de8277890e3e11395c3206f9
Ruby
team-ramrod/treva
/leros/asm/sim/leros_sim.rb
UTF-8
5,352
3.15625
3
[]
no_license
#!/usr/bin/env ruby require 'readline' $NUM_REGISTERS = 1000 $print_steps = false if ARGV.length > 0 $print_steps = true end class Treva attr_accessor :pc, :registers def initialize file, io = nil @accu = 0 @io = io @registers = Array.new($NUM_REGISTERS, 0) @pc = 0 ...
true
ee8625fb207dacd0cbd8b2dc1be0c97712cb0c09
Ruby
TakehiroKatayama/RubyStart
/Chapter2/two.rb
UTF-8
109
3.1875
3
[]
no_license
coffee = 400 espresso = 100 puts "コーヒー:#{coffee}円" puts "合計:#{coffee + espresso * 2}円"
true
451dd3a85fa710793408dffcb43a72a581d2b7ae
Ruby
ChenLiZhan/sight_advisor
/lib/comment_combine.rb
UTF-8
619
3.015625
3
[]
no_license
require 'csv' arr_of_arrs = CSV.read("sight.csv") arr_of_arrs.shift adjust_ary = arr_of_arrs.map do |ele| ele[1].gsub!(/[“”]/,'') [ele[0],"#{ele[1]}。#{ele[2]}"] end place_ary = arr_of_arrs.map do |e| e[0] end.uniq h = Hash.new place_ary.each do |place| h[place] = '' end h.each do |key, value| ...
true
83246ca7b5f8623dd7214030b3bc201086bcb93a
Ruby
narissa-hajratalli/coding-challenges
/ruby_practice/oop-ruby.rb
UTF-8
1,341
4.34375
4
[]
no_license
# Reference: https://www.youtube.com/watch?v=n_lvik2UYZg&list=PLY6oTPmKnKbZp8Kh6jS5A6j-6H2kGY12e&index=9&t=0s # Class is just a way that we construct an object in OOP #creating the definition of a dog class Dog #### CLASS VARIABLES #### @@totalDogs = 0 #These are specific to the class #### CONSTRUCTOR - always ...
true
33c92ddfebb4ef392a90fe6c3c79cd8551d60989
Ruby
chtompkins026/prime-ruby-online-web-sp-000
/prime.rb
UTF-8
85
3.171875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime?(num) return false if num < 2 (2...num).none? {|i| num % i ==0} end
true
8ba30748882ba910e8c88708e92be4783895fd44
Ruby
shogo-tksk/at_coder
/abc148/a.rb
UTF-8
46
2.84375
3
[]
no_license
puts (%w(1 2 3) - [gets.chomp, gets.chomp])[0]
true
ad6483cf1bb856f7df30d91c032f1b6bba937afd
Ruby
LMulvey/RubyMathGame
/player.rb
UTF-8
221
2.828125
3
[]
no_license
module MathGame class Player attr_accessor :name attr_accessor :lives def initialize(params = {}) @name = params.fetch(:name, false) @lives = 3 end end end
true
5a92c969c462389eb9d5cc37d3a7da0b1146a9c2
Ruby
cjohansen/juicer
/lib/juicer/command/install.rb
UTF-8
1,750
2.828125
3
[ "MIT" ]
permissive
require "juicer/command/util" require "cmdparse" require "pathname" module Juicer module Command # Installs a third party library so Juicer can use it. # class Install < CmdParse::Command include Juicer::Command::Util # Initializes command # def initialize(io = nil) super...
true
8f0fc8677358f86b4a21e600f0fd9ca9c10c23b5
Ruby
kickaha2019/twine
/Element.rb
UTF-8
2,124
2.953125
3
[]
no_license
=begin Element.rb Base class definitions =end class Element attr_reader :parent, :file, :lineno, :debug def initialize( parent, indent, file, lineno) @parent = parent @indent = indent @file = file @lineno = lineno @debug = false end def add_after( indent, args, ...
true
0887631a0cb6a6fc3651db572c350f7d9075d1d3
Ruby
madleech/console
/lib/console.rb
UTF-8
3,610
2.546875
3
[ "MIT" ]
permissive
# frozen_string_literal: true # # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including witho...
true
d2095dfded1bd8d043a85aa380f02a7963562744
Ruby
mariaclrd/ruby-nos
/spec/ruby_nos/list_spec.rb
UTF-8
1,485
2.671875
3
[ "MIT" ]
permissive
require "spec_helper" describe RubyNos::List do subject{List.new} let(:element) {double("element", uuid: "12345")} before do subject.add(element) end describe "#add" do it "adds an element to the list" do expect(subject.list.count).to eq(1) expect(subject.list.first).to eq({element.uuid...
true