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
de1b7cfb173f9daac4a02aff393640f93e509cb6
Ruby
vishwasjois/glucodes
/test/unit/math_test.rb
UTF-8
2,751
2.828125
3
[]
no_license
require File.dirname(__FILE__) + '/../test_helper' module MathTest class Mean < ActiveSupport::TestCase test 'should return 2.0 when sent with 2' do actual = Math.mean(2) assert_equal 2.0, actual assert_instance_of Float, actual end test 'should return 2.0 when sent with 2....
true
e3fc830f6e23a8eccf71853f588923133b066c56
Ruby
Putterhead/Learn-Ruby-The-Hard-Way
/ex12.rb
UTF-8
888
4.90625
5
[]
no_license
# So the string below is asking for the input of a number # The input is then assigned the variable number and converted to an integer print "Give me a number: " number = gets.chomp.to_i # The variable bigger is assigned to the variable number (which is multiplied by 100) # and then a string is printed with the variabl...
true
32fa72384ca429f1ec93d8a6aece8ea15dbd62d3
Ruby
RSRBX07/exo-Ouissem
/lib/test.rb
UTF-8
679
2.84375
3
[]
no_license
require "./vehicle/vehicle.rb" require "./vehicle/plane.rb" my_plane = Plane.new "Lille" ## oubien #my_plane_2 = Plane.new #my_plane_2.set_position "Lille" puts "Position actuelle >>>>>> " + my_plane.position puts "etat 1 : " + my_plane.state + " --- roue sorties :" + my_plane.wheel_out my_plane.take_off puts ...
true
30bbf46a3c30b4fc642b6920ece7c1183b44f215
Ruby
mac718/Launch_School
/small_problems/easy_8/all_substrings.rb
UTF-8
572
3.359375
3
[]
no_license
def substrings(str) substring_arr = [] start_index = 0 loop do end_index = start_index loop do substring_arr << str[start_index..end_index] end_index += 1 break if end_index == str.length end start_index += 1 break if start_index == str.length end substring_arr end ...
true
927ad4a74fbc0340b4437dd28d3467a31aab4052
Ruby
adamgeorgeson/companies_house
/lib/companies_house/config.rb
UTF-8
510
2.5625
3
[]
no_license
# Wrapper for interacting with Companies House API module CompaniesHouse # Configuration loading module Config mattr_accessor :private_key, :base_uri # Load config from supplied hash # # @param config_hash [Hash] configuration def self.configure_from_hash(config_hash) configure(config_has...
true
e9cb12597550734ea84676e902781233752dd104
Ruby
renanvy/roman_numerals
/lib/roman_numeral.rb
UTF-8
528
4
4
[]
no_license
class RomanNumeral TABLE = { "I" => 1, "V" => 5, "X" => 10, "L" => 50, "C" => 100, "D" => 500, "M" => 1000 } def convert(symbol) acumulator = 0 the_right_number = 0 symbol.split("").reverse.each do |s| current = TABLE[s] multiplier = 1 multiplier = -1 ...
true
2acbb69cc9b3f793c38ff7719828f56630cf2f35
Ruby
matao0214/Demo
/1949.rb
UTF-8
37
2.71875
3
[]
no_license
a=gets.chomp.split('') puts a.count
true
de4bef2a3dba70ce3a323ab67be9d2dd5748bb2c
Ruby
hoshito/AtCoder
/Q日ABC精進 #1/main_d.rb
UTF-8
972
3.21875
3
[]
no_license
h,w = gets.chomp.split(" ").map(&:to_i) aa_arr = h.times.map{gets.chomp.split(" ").map(&:to_i)} odd_arr = [] aa_arr.each_with_index do |a_arr, i| a_arr.each_with_index do |a, j| odd_arr << [i+1, j+1] if a % 2 == 1 end end result_n = 0 result_arr = [] odd_arr.each_slice(2) do |(y1, x1), (y2, x2)| next if y2....
true
5b4f1804c3403243a61b99d9c53e269f497c4566
Ruby
adamjbrowner/learn_to_program
/ch12-new-classes-of-objects/one_billion_seconds.rb
UTF-8
87
2.609375
3
[]
no_license
born = Time.gm(1992, 9, 7, 16) billion_seconds = born + 1000000000 puts billion_seconds
true
40d745e499db83225cf749de683700f3ac3539cf
Ruby
GoBeromsu/TIL
/Ruby_on_Rails/Coderbyte/easy/palindrome.rb
UTF-8
151
3.34375
3
[ "MIT" ]
permissive
def Palindrome(str) str = str.downcase.split(' ').join if str == str.reverse return 'true' else return 'false' end end
true
9aa518971fbc0307c3b6c6d8071c6050fdcc3c9e
Ruby
jmorc/Mighty-Meta-ORM
/lib/sql_object.rb
UTF-8
2,408
2.875
3
[]
no_license
require_relative 'db_connection' require 'active_support/inflector' require_relative 'pluralize_fix' class SQLObject def self.columns column_query = DBConnection::execute2(<<-SQL) SELECT * FROM #{self.table_name} SQL symbols = column_query.first.map { |el| el.to_sym } end def self.finalize! ...
true
14939b242531431f53102497acaaeeb656afa9bc
Ruby
pdoise/receta
/db/seeds.rb
UTF-8
22,877
2.703125
3
[]
no_license
Recipe.delete_all Recipe.create([ { name: "Chicken and Sausage Jambalaya", contributor: "Phillip", instructions: "Serving size: 6 Ingredients: 1 lbs smoked sausage sliced to 1/4 inch rounds 1 lbs chicken breast strips cubed 1 white onion chopped 4 cloves of garlic minced 1 1/2 cup uncooked white rice ...
true
99f5c1c304ff26b564345b0e7f723d16d1f4a9c9
Ruby
kaleflatbread/OO-mini-project-nyc-web-051418
/app/models/RecipeCard.rb
UTF-8
503
3.015625
3
[]
no_license
require 'pry' class RecipeCard attr_accessor :date, :rating, :user, :recipe, :recipe_card_title ALL = [] def initialize(recipe_card_title, recipe, date, rating, user) @recipe_card_title = recipe_card_title @date = date @rating = rating @user = user @recipe = Recipe.new(recipe_card_title, s...
true
a0a8eb35f77ee03131120e30bcb51a5fe07c0da7
Ruby
mikedao/feed_engine
/app/services/nytimes_service.rb
UTF-8
695
2.671875
3
[]
no_license
class NytimesService attr_reader :connection def initialize @connection = Faraday.new(url: "http://api.nytimes.com/svc/topstories/" + "v1/home.json?api-key=#{ENV['NYTIMES_KEY']}") end def articles response_body = parse(connection.get) articles_data = response_body["...
true
97726e66df7fd9eb0c446a0a0d378c2ba3aaf591
Ruby
MalachiCoberley/AA_Classwork
/W6/D4/RoutesAndControllers/app/controllers/users_controller.rb
UTF-8
1,535
2.65625
3
[]
no_license
require 'byebug' # users GET /users(.:format) users#index # POST /users(.:format) users#create # new_user GET /users(.:format) users#new # edit_user GET /users/:id/edit(.:format) users#...
true
4e7f008b2054e6d39e3cc4d1a7a0e26e2b7c2f13
Ruby
sabifly/Kbot
/ToyaBot/Kbot.rb
UTF-8
2,688
3.375
3
[]
no_license
require 'discordrb' require 'csv' class Kbot # 初期化 def initialize # botの定義 @bot = Discordrb::Bot.new token: 'X', client_id: 0 # CSVファイル読み込み @csv_data = CSV.read('./words.csv', headers: true) # 最終行番号 @last_line_no = @csv_data.size # スリープの状態 @is_sleep = false # イベント格納用ハッシュ @event_has...
true
6ad7b29d96d581e3501b38cf4d9b19288dcc4a9b
Ruby
jjjjjuniiiii/coderbyte
/LetterChanges.rb
UTF-8
108
2.609375
3
[]
no_license
def LetterChanges(str) a=str.tr('a-y', 'b-z') b=a.tr('aeiou', 'AEIOU') return b end
true
f5bf000d66993e71701e5264c0ba7699a9d6ae87
Ruby
heydanhey/weekend_work
/palindrome2.rb
UTF-8
822
4.5
4
[]
no_license
# Complete the method called palindrome? which should accept a string as a parameter and return a boolean indicated whether the string is a palindrome. A palindrome is a word that reads the same both forwards and backwards. Examples: eye, madam, racecar def palindrome?(string) mid = string.length / 2 i = 0 ...
true
67a1a5510412313da76b4a1f5c927f04233dcb1b
Ruby
vantran/premailer-rails3
/spec/fixtures/message.rb
UTF-8
1,967
2.578125
3
[ "MIT" ]
permissive
require 'mail' module Fixtures module Message extend self HTML_PART = <<-HTML <html> <head> </head> <body> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exerci...
true
841f522df937c0edbac5c2083afcd14486a47294
Ruby
snawar92/db
/examples/indexes.rb
UTF-8
4,313
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'async' require_relative '../lib/db/client' require 'db/postgres' # Create the client and connection pool: client = DB::Client.new(DB::Postgres::Adapter.new(database: 'test')) def create_schema(session) session.clause("DROP TABLE IF EXISTS").identifier(:things).call session.clause("CR...
true
459f1882ee01c9bf47584397071f73e2d2bde1e6
Ruby
katherine-walendzik/whitney_exhibitions
/lib/whitney_exhibitions/scraper.rb
UTF-8
1,539
3.09375
3
[ "MIT" ]
permissive
class WhitneyExhibitions::Scraper def self.scrape_exhibitions doc = Nokogiri::HTML(URI.open("https://whitney.org/exhibitions")) list_one = doc.css("div.exhibitions__list h2") list_two = doc.css("div.exhibitions__list h3") edit = list_two.collect{|e| e.text} list_two_edit = edi...
true
ff9e238043a776bf21bff7cc275669345b0e3393
Ruby
ddk50/BPlusTree
/lib/b_plus_tree/tree.rb
UTF-8
1,445
3.125
3
[ "MIT" ]
permissive
class BPlusTree::Tree def initialize(size) @root = BPlusTree::Page::Internal.new(size) leaf = BPlusTree::Page::Leaf.new(size) @root.insert(0, leaf) end def insert(key, value) leaf, path = @root.search_leaf(key) # path = [(internal1, internal2, ...) root] result = nil if leaf.can_insert?(...
true
1819bd6814e4bb01d372b40df5f32cc395bee349
Ruby
deikdesign/css-linter
/lib/rules/spaces_comma.rb
UTF-8
194
2.859375
3
[]
no_license
class SpacesComma MESSAGE = 'Commas cannot be preceeded by a space'.freeze def analyze(line, _index, _total, _context) return (line =~ /[^ ],/) if line.include? ',' true end end
true
03252867148902697b8714abc3a7201cc7565ad9
Ruby
javs-perez/es_web_app
/spec/models/project_spec.rb
UTF-8
921
2.515625
3
[]
no_license
require 'spec_helper' describe Project do it "is invalid without a user_id" do FactoryGirl.build(:project, user_id: nil).should_not be_valid end it "is invalid without status been in ['Approved', 'New', 'Pre-funding', 'Funding']" do FactoryGirl.build(:project, status: "Not-Approved").should_not be_valid en...
true
bcbdc7e00fbfe8019a7042b24809f62c2dbd5910
Ruby
dcmorais/uri_problems
/beginner/1016.rb
UTF-8
99
3
3
[]
no_license
distance = gets.to_f #km X = 60 #km/h Y = 90 #km/h puts sprintf("%i minutos", distance/(Y-X)*60)
true
78a87e7953200f6279a727034fe01ee1047ce875
Ruby
h4hany/yeet-the-leet
/algorithms/Easy/581.shortest-unsorted-continuous-subarray.rb
UTF-8
997
3.6875
4
[]
no_license
# # @lc app=leetcode id=581 lang=ruby # # [581] Shortest Unsorted Continuous Subarray # # https://leetcode.com/problems/shortest-unsorted-continuous-subarray/description/ # # algorithms # Easy (31.15%) # Total Accepted: 132.3K # Total Submissions: 424.8K # Testcase Example: '[2,6,4,8,10,9,15]' # # Given an integer ...
true
d0691261a4784dc4ec42d1ed36d50059159e77be
Ruby
Michaelschats/Bank_Tech_Test
/lib/statement.rb
UTF-8
488
3.03125
3
[]
no_license
# frozen_string_literal: true require_relative './transactions' class Statement def print_statement(transactions) @transactions = transactions columns print_transactions end private def columns print 'date || credit || debit || balance' end def print_transactions @transactions.each ...
true
6ce034c4cd52b13281bcfa07e4bf6c0dcde5b0c3
Ruby
mattpitner/square_array-online-web-ft-081219
/square_array.rb
UTF-8
133
3.421875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
array = [1,2,3] def square_array(array) arr=[] array.each do |number| arr.push(number * number) end return arr end
true
80c7a691ba8d14375687aab7744d160a0ff348d4
Ruby
NerdDiffer/backpack_tf
/lib/backpack_tf/price/item_price.rb
UTF-8
4,070
3
3
[]
no_license
module BackpackTF module Price # Price for an individual item. # This lives inside the `@prices` hash of a BackpackTF::Item object. class ItemPrice KEYNAME_DELIMITER = '_'.freeze class << self # @return [Array<Symbol>] maps quality integers to quality names # see: https://...
true
606f7f784b1630dd52f2dfe88b729700519d9c1e
Ruby
jamierumbelow/revisionhub
/app/models/gittastic.rb
UTF-8
1,400
3.40625
3
[]
no_license
# Gittastic # # A really little and lightweight Ruby wrapper # to the Git interface. # # by Jamie Rumbelow # http://jamierumbelow.net class Gittastic # Accessible attributes attr_accessor :path, :cmd # Create a new Gittastic instance. # # path - The String path to the root directory # o...
true
600463ff03ec1f81bd55e1e13db0ca37a0da56aa
Ruby
alexbrinkman/543-ruby
/lib/board.rb
UTF-8
2,255
3.609375
4
[ "MIT" ]
permissive
module Game543 class Board def initialize(position = nil) @position = position || initial_board end def move(row, num) row = row.to_i num = num.to_i validate_move(row, num) update_board(row, num) end def winner? total_pieces_left == 1 end def availab...
true
9635765858b0ac81858e9f455e0e52e0c52c13e3
Ruby
aungaungNMK/ruby_learning_for_gold
/hashvaue_for_multiple_expression.rb
UTF-8
138
2.75
3
[]
no_license
def hasValue(x) case x when nil,[], "", 0 #if nil == x || []===x || ""=== x || 0===x then false else true end end
true
b6985039c052c65f556e522cb70c410343de80d9
Ruby
tatey/aviary
/lib/aviary/image_host/flickr.rb
UTF-8
1,493
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Aviary class ImageHost::Flickr < ImageHost before :create, :set_meta matches /flic\.kr\/p\/(\w+)/ matches /flickr\.com\/photos\/\w+\/(\d+)/ # Get and set the API key. Passing an argument sets the # API key. Passing nothing gets the API key. # # Returns api key. def self...
true
0d7a03c8901435febb4cc2569c220c6bcf0db7f1
Ruby
rafa2000/olelo
/plugins/security/acl.rb
UTF-8
2,430
2.59375
3
[]
no_license
description 'Access control lists' class Olelo::Resource # Resource must be readable and parents must recursively be readable def readable?(user) access?(:read, user) && (root? || parent.readable?(user)) end # New resource is writable if parent is writable # Existing resource is writable if resource is ...
true
11d16497c365e6ca8754768cf32d47548198b5ee
Ruby
neddy/Launch-School
/Exercises/101-109_Small_Problems/12_Medium/ex_10.rb
UTF-8
578
4.375
4
[]
no_license
# ex_10.rb # Sum Square - Square Sum # Write a method that computes the difference between the square of the sum of the first n positive integers and the sum of the squares of the first n positive integers. # # Examples: def sum_square_difference(number) sum_square = (1..number).reduce(:+) ** 2 sqaure_sum = (1..nu...
true
3a4505a94af308f8fd306fd55473ff86f9ca5432
Ruby
akshay-vishnoi/Deal-Hound
/spec/models/address_spec.rb
UTF-8
2,042
2.640625
3
[]
no_license
require 'spec_helper' module AddressSpecHelper def valid_address_attributes { :pincode => 110007, :city => "Delhi", :state => "Delhi", :street => "Kamla nagar" } end end describe Address do include AddressSpecHelper before do @address = Address.create(valid_addre...
true
e7374ae97b97632d11af8b43fd6604f21a9420d2
Ruby
racoll/learn-to-program
/chapter_11/yaml.rb
UTF-8
338
2.9375
3
[]
no_license
require 'yaml' test_array = [["eggs", "bacon", "42"],["hammer", "nails", 42]] test_string = test_array.to_yaml filename = "RimmerTShirts.txt" File.open filename, "w" do |f| f.write test_string end read_string = File.read filename read_array = YAML::load read_string puts(read_string == test_string) puts(read_arr...
true
6ceac12b84000c31e710a337980dfbb5bcda0b19
Ruby
sebastianalamina/MyP_2020-1_Proyecto3
/test/TestMovimientos.rb
UTF-8
4,553
3.46875
3
[]
no_license
require_relative "../code/Pieza" require_relative "../code/Posicion" require "test/unit/assertions" include Test::Unit::Assertions class TestMovimientos #Método para probar los movimientos compuestos por saltos hacia la derecha y/o hacia arriba #de diferentes magnitudes. def self.testDerechaArriba(pieza, salt...
true
bf784b9d078a6d386e0f141fc682bd075e8515b6
Ruby
floresviv/deli-counter-001
/deli_counter.rb
UTF-8
1,302
4.4375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#CREATE the take_a_number method (accepts 2 arguments(katz_deli, string of "name") # Should add name(s) to END of empty or populated array # puts "Welcome, (name). You are number (num) in line." def take_a_number(katz_deli, name) katz_deli.push(name) index = katz_deli.index(name) index += 1 puts "Welcome,...
true
decc91b3fa16f76cbcfde3dfa203ad65644b3225
Ruby
masayasviel/algorithmAndDataStructure
/from51to100/ABC61/mainB.rb
UTF-8
179
3.21875
3
[]
no_license
n, m = gets.chomp.split(" ").map(&:to_i) ans = Array.new(n, 0) m.times do a, b = gets.chomp.split(" ").map(&:to_i) ans[a-1] += 1 ans[b-1] += 1 end puts ans.join("\n")
true
989407843493ce674fb711f40c42a1c21cc7e7f1
Ruby
angieappiah/ruby-object-attributes-lab-onl01-seng-ft-012120
/lib/person.rb
UTF-8
187
2.578125
3
[]
no_license
class person def initialize (name) @name=name end def person=(name) @name=name end def initialize (job) @job=job end def ' #{@name} #{@job}'.strip end
true
34a421521948b62131a13c0516b7a2affe0a15d4
Ruby
habypsow/Solar-System
/solar_system.rb
UTF-8
1,751
3.828125
4
[]
no_license
require 'colorize' class Planet attr_accessor :name, :diameter, :mass, :moons, :rings, :rotation, :distance_from_the_sun def initialize (name,diameter,mass,moons,rings,rotation,distance_from_the_sun) @name = name @diameter = diameter @mass = mass @moons = moons @rings = rings @rotation = ro...
true
651f0fc1533d9aa4f1d80e66e4c779ab992fcdc9
Ruby
Elise000/week_1_day_3
/prime.rb
UTF-8
630
3.703125
4
[]
no_license
require 'byebug' # def prime_factors(num) # divider = 2 # array = [] # until num == 1 # if num % divider == 0 # num /= divider # array << divider # else # divider += 1 # end # end # p array # end def prime_factors(num) divider = 2 array = [] until nu...
true
f19bb883a81f2f006d7641dda4bd6e10d91263b8
Ruby
chriscoates/ruby-kickstart
/session2/3-challenge/3_array.rb
UTF-8
1,951
4.4375
4
[ "MIT" ]
permissive
# Write a method named every_other_char for strings that, # returns an array containing every other character # # example: # "abcdef # => "aceg" # "".every_other_char # => "" class String #Uses the String class def every_other_char #Defines the metho...
true
7dcc0d43dfc53eaeeb173019b154044b9108519c
Ruby
JaredRoth/headcount
/test/enrollment_repository_test.rb
UTF-8
2,226
3.140625
3
[]
no_license
require_relative 'test_helper' require_relative '../lib/enrollment_repository' require_relative '../lib/district_repository' class EnrollmentRepositoryTest < Minitest::Test dr = DistrictRepository.new dr.load_data({ :enrollment => { :kindergarten => "./data/Kindergartners in full-day program.csv", ...
true
00f798c6cf097fa9377825118754911c46f567e8
Ruby
DennyWu908/phase-0-tracks
/ruby/santa.rb
UTF-8
2,020
3.609375
4
[]
no_license
class Santa attr_reader :ethnicity attr_accessor :gender def initialize(gender,ethnicity,accent,nationality) puts "Initializing Santa instance..." @gender = gender @ethnicity = ethnicity @accent = accent @nationality = nationality @reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer",...
true
47056744a87ec4a0482b22eb16f71e16b0abcc6b
Ruby
samidm13/Bank_account
/spec/bank_account_spec.rb
UTF-8
1,249
3.390625
3
[]
no_license
# I would like to view my balance # I would like to deposit money in my account # I would like to withdraw money from my account require 'bank_account' describe BankAccount do it 'can create instance of a bank account' do bank_account = BankAccount.new expect(bank_account).to be_kind_of(BankAccount) end ...
true
35b30d39069c3bd75e5fc95ab6c76f24b68c95c7
Ruby
danwagnerco/fizzbuzz
/test/fizzbuzz_iterator_test.rb
UTF-8
1,221
2.890625
3
[]
no_license
require "test_helper" require "fizzbuzz_iterator" describe FizzbuzzIterator do describe "initialized without a starting value" do let(:iterator) { FizzbuzzIterator.new } it "outputs sequential Fizzbuzz values starting at 1" do iterator.next.must_equal "1" iterator.next.must_equal "2" itera...
true
6c9de9f60d4dd9c41ee7477e8406395efd7a0a62
Ruby
y-masaya/fish-market
/db/seeds.rb
UTF-8
2,927
2.640625
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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
true
5e6dff55d096069ece240cc0f6a205815df02d42
Ruby
krystian-wojtas/OCR
/aipo/FImg4R/FImg4R_Ocr.rb
UTF-8
725
2.625
3
[]
no_license
require 'FImg4R_Core' class FImg4R attr_reader :prj_h, :prj_v def projection_horizontal() @prj_h = Array.new(@s.o[:rows], 0) iteruj :channels => :monocolor do |r, c| #p r.to_s + ' ' + c.to_s #"19 27" #"19 28" #"19 29" if @vchb[r][c] < @QR/2 @prj_h[r] = @prj_h[r...
true
46b4db25e14f1fc66945c630ee9e1674ad64b01c
Ruby
gabrie30/Practice
/Interesting_Programs/menu.rb
UTF-8
659
3.671875
4
[]
no_license
class Menu attr_reader :quit def initialize( *menu_choices ) @menu_choices = menu_choices @quit = @menu_choices.length end def get_menu_choice @menu_choices.each_with_index do |item,index| puts "#{index+1}. #{item}" end print "Enter your choice: " user_choice = gets.to_i re...
true
b12dcbd0c278bd236bf37fde6d182c4ac28c9413
Ruby
ryota-ka/twterm
/lib/twterm/key_mapper.rb
UTF-8
3,584
2.828125
3
[ "MIT" ]
permissive
require 'toml-rb' require 'singleton' require 'twterm/app' require 'twterm/key_mapper/abstract_key_mapper' require 'twterm/key_mapper/app_key_mapper' require 'twterm/key_mapper/cursor_key_mapper' require 'twterm/key_mapper/general_key_mapper.rb' require 'twterm/key_mapper/no_such_command' require 'twterm/key_mapper/no...
true
abce9a3773f2809de61efb0e86aba3c9087e4a47
Ruby
MAGNUM81/RubyChess
/OODRubyChess/tests/position_test.rb
UTF-8
1,650
3.078125
3
[]
no_license
# frozen_string_literal: true require './helpers/test_helper' require './OODRubyChess/src/position' # this shiny device unit tests the Position class class PositionUnitTests < Minitest::Test def setup @some_random_position = Position.new(rand(-10..10), rand(-10..10)) @some_pp_position = Position.new(58, 30)...
true
99b5f11ac9748aea3789facf7e8f94eeb39f5152
Ruby
miftahafina/learn-ruby-the-hard-way
/ex19.rb
UTF-8
953
4.03125
4
[]
no_license
def cheese_and_crackers cheese_count, boxes_of_crackers puts "You have #{cheese_count} cheeses!" puts "You have #{boxes_of_crackers} boxes of crackers!" puts "Man that's enough for a party!" puts "Get a blanket. \n\n" end puts "We can just give the function number directly:" cheese_and_crackers 20, 30 puts ...
true
f04e84fe852a82df57abbb9b529272c30c733cb2
Ruby
mxenabled/rubiks
/lib/rubiks/mondrian/cell_set.rb
UTF-8
4,087
2.71875
3
[ "MIT" ]
permissive
require 'rubiks/mondrian/member' module ::Rubiks module Mondrian class CellSet def initialize(raw_cell_set) @raw_cell_set = raw_cell_set end def to_s "#<#{self.class}>" end def inspect axes_strings = [] axes_strings << "column_axis=#{axis_string(c...
true
1a9196a1bcb1860dbecc373cb94a85ed693c54f9
Ruby
sleeperbus/Ordin
/tic_tac_toe_2/spec/player_spec.rb
UTF-8
654
3.03125
3
[ "MIT" ]
permissive
# spec/player.rb require "spec_helper" module TicTacToe2 describe Player do context "#initialize" do it "raises error if there is no initial parameters" do expect { Player.new({}) }.to raise_error end it "does not raise error if there is input parameters" do expect { Player.new({name: "Hojoon"...
true
e07d7bc0a3741cff2d063c320b7e52c1276f1d83
Ruby
Jon2041/ruby_basic_exercises
/user_input/passwords.rb
UTF-8
427
3.078125
3
[]
no_license
users = {"Jon" => "It_is_@_sEcr3t!", "mary" => "poodles", "admin" => "seCR3t"} loop do puts ">> Please enter your user name:" name_try = gets.chomp unless users.has_key?(name_try) puts ">> User name not found. Try again!" next end puts ">> Please enter your password:" attempt = gets.chomp break i...
true
52e18e0dd2a42eccad9662851385ca86fa9ccaaa
Ruby
SameerKhan-Dev/Ruby_OOP_Practice
/comments.rb
UTF-8
614
3.59375
4
[]
no_license
class Comments def game_start "Welcome to the Number Game Competition!" end def player_win(id, score) "Player #{id} wins with a score of #{score}/3" end def correct_answer "YES! You are correct." end def wrong_answer "Seriously? No!" end def new_turn "----- NEW TURN -----" ...
true
317a98330e3c6ef13bf89ff4fbc440592e39f7f3
Ruby
jm/asciidoctor
/test/list_elements_test.rb
UTF-8
1,832
2.671875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'test_helper' context "Bulleted lists (:ulist)" do context "Simple lists" do test "dash elements with no blank lines" do output = render_string("Blah\n====\n- Foo\n- Boo\n- Blech") assert_xpath '//ul', output, 1 assert_xpath '//ul/li', output, 3 end test "dash elements with bla...
true
cefb13d95225c33f5b56b5e8ab1eb5b766382c13
Ruby
mongodb/mongoid
/lib/mongoid/matchable.rb
UTF-8
688
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true # rubocop:todo all module Mongoid # This module contains all the behavior for Ruby implementations of MongoDB # selectors. module Matchable extend ActiveSupport::Concern # Determines if this document has the attributes to match the supplied # MongoDB selector. Used for...
true
dfe7c739d42c845040344f14230a03ca9804d745
Ruby
lpil/learning
/ruby/codeabbey/020_collatz_sequence.rb
UTF-8
250
2.890625
3
[]
no_license
#!/usr/bin/env ruby # encoding: utf-8 x = ARGF.file.read.split("\n")[1].split(' ').map { |e| e.to_i } x.map! do |e| chain = [e] until chain.include? 1 e = e.even? ? e / 2 : e * 3 + 1 chain << e end chain.size - 1 end puts x.join ' '
true
dc867a3710f5edc87dea958ebcfe76904107efa9
Ruby
eslcomputertraining/nokogiri
/always_three_refactored_3lines.rb
UTF-8
105
3.34375
3
[]
no_license
puts "What is your number?" user_num = gets.chomp.to_i puts "the result is #{user_num+5*2-4/2-user_num}."
true
6a96c8bf01d9f53d16074f835a5ecbecc3fbfa5e
Ruby
TheObtuseAutodidact/enigma
/test/enigma_test.rb
UTF-8
1,433
3.046875
3
[]
no_license
require 'minitest' require 'minitest/autorun' require './lib/offsets_calc.rb' require './lib/enigma' class EnigmaTest < Minitest::Test def test_it_exists assert Enigma end def test_an_instance_is_an_object_of_class e = Enigma.new assert e.is_a?(Enigma) end def test_it_instantiates_with_a_numer...
true
1cdc637ec72a8d88a618bd3a35b8bb2f933c313d
Ruby
araneforseti/heimdallr-viz
/vendor/cache/ruby/2.6.0/gems/rmagick-2.16.0/examples/image_opacity.rb
UTF-8
739
2.71875
3
[ "MIT" ]
permissive
# Ccreate a semi-transparent title for an image. require 'rmagick' include Magick puts <<END_INFO This example uses a semi-transparent background color to create a title. View the resulting image by entering the command: display image_opacity.miff END_INFO balloons = Image.read('../doc/ex/images/Hot_Air_Balloons_...
true
f9c5c60c467b8e1eb2186090c1c039c1200c8091
Ruby
cjavdev/euler
/lib/4.rb
UTF-8
548
3.734375
4
[]
no_license
def is_pallindrome?(num) s = num.to_s (s.length == 5 && s[0] == s[-1] && s[1] == s[-2]) || (s.length == 6 && s[0] == s[-1] && s[1] == s[-2] && s[2] == s[3]) end def check_three_digit biggest = 12321 set = [] 900.upto(999) do |x| 900.upto(999) do |y| prod = x * y if is_pallindrome?(prod) ...
true
248c29850e7f9e500481df2b03b8a20aff18dace
Ruby
bl00dymarie/faraday_tutorial
/8.agent.rb
UTF-8
436
2.671875
3
[]
no_license
#!/usr/bin.ruby require 'faraday' con = Faraday.get do |r| r.url 'http://localhost:4567/agent' r.headers[ 'User-Agent' ] = 'Ruby script' end puts con.body # The server responded with the name of the agent that we have sent with the request. # require 'faraday' # # con = Faraday.new # # res = con.get do |req| ...
true
73128900408b08ec6ce517edf887d2518d0cf58d
Ruby
directededge/directed-edge-bindings
/Ruby/lib/directed_edge/database.rb
UTF-8
5,304
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
# Copyright (C) 2012-2016 Directed Edge, Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the followin...
true
daf56e28ed5ce9917b8882823a8f39797e3b60b3
Ruby
amart404/ruby-enumerables-hash-practice-green-grocer-lab-denver-web-82619
/grocer.rb
UTF-8
1,485
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def consolidate_cart(cart) # code here hash = {} cart.each do |item_hash| item_hash.each do |name, price_hash| if hash[name].nil? hash[name] = price_hash.merge({:count => 1}) else hash[name][:count] += 1 end end end hash end def apply_coupons(cart, coupons) # code ...
true
ad6c415d2dd8e038fce93e1f96dd836afdca8d3b
Ruby
dherod/LWF_CodeSample_Ruby
/lwf.rb
UTF-8
277
3.21875
3
[]
no_license
# Convert hex strings to UTF-8 strings # First hex string hexnumber1 = "5765204d616b652054756d6d69657320486170707921" puts [hexnumber1].pack("H*") # More complex hex string hexnumber2 = "e299a5205765204d616b652054756d6d792048617070792120e299a5" puts [hexnumber2].pack("H*")
true
c1e9ae1e237f9000cd005ecb6dda933fcc171b53
Ruby
krestenkrab/hotruby
/modules/vm-shared/rb/test/basic/Array.rb
UTF-8
2,094
2.9375
3
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
require 'test/unit/testcase' require 'test/unit/testresult' #require 'test/unit' class ArrayTest < Test::Unit::TestCase def test_empty assert_equal([], Array.new) end def test_size assert_equal([], Array.new(0)) assert_equal([nil], Array.new(1)) assert_equal([nil,nil], A...
true
546de0f2614e5b024d2b4d63f8bbea2582aa964b
Ruby
tulibraries/cob_index
/lib/cob_index/macros/wrapper.rb
UTF-8
1,219
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module CobIndex::Macros::Wrapper START_MATCHER = "matchbeginswith" END_MATCHER = "matchendswith" def wrap_begin_end(*args) lambda do |record, accumulator, context| accumulator.map! { |v| self.flank v } end end def first_word_matcher(string = "", start_matcher =...
true
1d910cc36686b603030702b3baf29aed1af6d7e2
Ruby
Lykos/SquirrelDB
/spec/storage/raw_util_spec.rb
UTF-8
1,723
2.9375
3
[]
no_license
require 'storage/raw_util' include SquirrelDB::Storage include RawUtil describe RawUtil do it "extract_int should be left invertible" do string = "asdasfasdfasfasd".force_encoding(Encoding::BINARY) encode_int(extract_int(string), string.length).should eq(string) end it "encode_int should be left inv...
true
ac35fc0887ec4a56cbe25a9c71cd531243f03db6
Ruby
kensei1016/bookers2-debug
/app/models/book.rb
UTF-8
955
2.578125
3
[]
no_license
class Book < ApplicationRecord belongs_to :user has_many :favorites, dependent: :destroy has_many :book_comments, dependent: :destroy #バリデーションは該当するモデルに設定する。エラーにする条件を設定できる。 #presence trueは空欄の場合を意味する。 validates :title, presence: true validates :body, presence: true, length: {maximum: 200} def self.search(keyword...
true
cde9e56b0779f5bfaa678d665678c57749be199e
Ruby
alexReshetnyak/ruby-essential-beginning
/41_mixins/mixin_part.rb
UTF-8
1,241
3.546875
4
[]
no_license
module Purchaseable def purchase(item) "#{item} has been purchased!" end end module Announcer def who_i_am "The name of this class is #{self}" end end class Dog extend Announcer # * add methods from Announcer module to class (static methods) end class Cat extend Announcer # * add...
true
cb5af4d0f3074409ba6202e4e501618cde48f803
Ruby
jeremyf/project-euler
/problems/014-collatz.rb
UTF-8
1,075
3.796875
4
[ "Apache-2.0" ]
permissive
# Creating a global cache @cache = {1 => 1} # With recursion, we'll be walking to the end of sequence to determine n's total length # As we then walk backwards with the answer for the original n, we cache the intermediary # answers for numbers in that sequence. # # To get the length of 4, we go 4 -> 2 -> 1 # As we wal...
true
3efcd265ffc6d24f6c25b8a200318d55d3b2c4ea
Ruby
pbbrown1112/OO-Animal-Zoo-houston-web-051319
/lib/Zoo.rb
UTF-8
1,150
3.578125
4
[]
no_license
class Zoo @@zoos = [] def initialize(name, location) @name = name @location = location @@zoos << self end #Getter def name @name end def location @location end #End Getter #Setter def name=(name)...
true
79579c4c2502005e4e21ca1663e1d4e439ae16fd
Ruby
DevSquads/Hello_world_multilingual_rails
/spec/controllers/missions_controller_spec.rb
UTF-8
6,581
2.609375
3
[]
no_license
require 'rails_helper' require 'locale_helpers' RSpec.describe MissionsController, type: :controller do before(:each) do reset_locale 'en_test' request.headers["LANG"] = "en_test" end # This should return the minimal set of attributes required to create a valid # Mission. As you add validations to M...
true
9ce1ef4ced4e5631ff323a0b6b685df7b73a5fb2
Ruby
shadowbq/Stumbles_training
/XML/Scanners/nessus - xml.rb
UTF-8
1,112
2.609375
3
[]
no_license
#!/usr/local/bin/ruby -w require "rexml/document" file = File.new( "nessus-09.14.07-cred_full.xml" ) document = REXML::Document.new file #cves = Array.new #REXML::XPath.each( document, "//desc") do |description| # description.text.scan(/CVE-\d{4}-\d{4}/) do |match| # cves.push(match.to_s) # end #end #puts cves...
true
8d16bb08d0972490b0310d65455fc8584d12b111
Ruby
etienneCharignon/AOC2020
/lib/passport_validator.rb
UTF-8
910
2.90625
3
[]
no_license
class PassportValidator RULLS = { 'byr'=> Proc.new {|value| (1920..2002).member?(value.to_i)}, 'iyr'=> Proc.new {|value| (2010..2020).member?(value.to_i)}, 'eyr'=> Proc.new {|value| (2020..2030).member?(value.to_i)}, 'hgt'=> Proc.new {|value| (value.end_with?('cm') && (150..193).member?(value.to_i)) ...
true
45012dd511301d3e7325c2ab07c52a8a2b33ed26
Ruby
jamessct/CodeClanLaptopCopies
/inheritance/specs/person_spec.rb
UTF-8
255
2.765625
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../person') class PersonTest < Minitest::Test def setup @person = Person.new("James", "Scott") end def test_person_can_talk assert_equal("James Scott", @person.talk) end end
true
74592093ce0e8728ddb0078e8f8790aa3d152d26
Ruby
NickSpangler/amazing-race-cli
/lib/scraper.rb
UTF-8
4,434
2.859375
3
[ "MIT" ]
permissive
require_relative "./environment" class Scraper def self.scrape_season_page(season_page_url) doc = Nokogiri::HTML(open(season_page_url)) season = {} season[:title] = doc.css("#PageHeader > div.page-header__main > h1").text season[:about] = doc.css("#mw-content-text > p:nth-child(3)"...
true
3ace7cada08b8a5567be42ea03a0ba5a11064b26
Ruby
Bykanir/ruby_lessons
/Lesson_14/station.rb
UTF-8
371
3.328125
3
[]
no_license
class Station attr_reader :trains, :name # геттер списка поездов def initialize(name) @name = name @trains = [] end def add_train(train) # добавление поездов на станцию trains << train end def send_train(train) # отправление поездов trains.delete(train) end end
true
bb61a63bfbec63bf921a18d1038a5f17517ac8f0
Ruby
cycloped-io/cycloped-io
/category-mapping/utils/article_coverage.rb
UTF-8
2,296
2.765625
3
[]
no_license
#!/usr/bin/env ruby # encding: utf-8 require 'bundler/setup' require 'rlp/wiki' require 'irb' require 'set' require 'progress' require 'csv' require 'slop' require 'colors' options = Slop.new do banner "#{$PROGRAM_NAME} -d db -f mapping.csv [-F 1] [-i n|i]\n" + "Compute article coverage based on category mappin...
true
e5b2ba1b8c2e274899bbb7ff0549dda891fa9a7a
Ruby
kimikato/kyo-ha-nani
/message.rb
UTF-8
2,165
2.8125
3
[]
no_license
#/usr/bin/env ruby # -*- encoding: utf-8 -*- require 'wikipedia' require 'date' require 'open_jtalk' Wikipedia.Configure { domain 'ja.wikipedia.org' path 'w/api.php' } today = Date.today.strftime("%-m月%-d日") today_message_file = "message_#{Date.today.strftime("%Y%m%d").to_s}.wav" page = Wikip...
true
a23b6f15d404a0e7fdce5e96f7c51a3cebe04732
Ruby
NicoleLatifi/TuringTechChallenges
/recur.rb
UTF-8
482
4.25
4
[]
no_license
# method that counts down from n until we get to 0 # run with command: ruby recur.rb # def countdown(num) # if num < 0 #base case, get me out of this method call when... # return #this stops the method # end # # p num #recursive case # countdown(num - 1) # end # # countdown(8) #if you change this to 5000, ...
true
f436157982d3e34b0d1eb7b54dff56feee790451
Ruby
fade2black/graphsrb
/lib/graphsrb/node.rb
UTF-8
451
3.453125
3
[ "MIT" ]
permissive
#This class represents a single entry in a adjacency list. class Graphsrb::Node attr_reader :vertex, :weight #Creates a new node def initialize(vertex_id, args={}) @vertex = Graphsrb::Vertex.new(vertex_id) @weight = args.fetch(:weight, 1) end #Updates weight def update_weight(w) @weight = w ...
true
4123a5bb7f0d6886191434d096db31e35bf23200
Ruby
johnfig/instagram_ish
/app/controllers/photos_api_controller.rb
UTF-8
898
2.53125
3
[]
no_license
class PhotosApiController < ApplicationController # GET /photo_api # Array of Hashes to be iterated over def index @photos = Photo.all array = @photos.map do |photo| photo_push = { id: photo.id, name: photo.name, user_name: photo.user.full_name, photo: photo.photo.url }...
true
1d2a333aba69f06a6d3b4564e5e33f973cf85f0b
Ruby
Dujota/Ruby-comprehensive-examples-for-students
/IO_DataStorage/stringAsFile.rb
UTF-8
256
3.1875
3
[]
no_license
require 'stringio' text = "abcdefghijkl\nABC\n123" puts text ios = StringIO.new(text) ios.seek(5) ios.puts("xyz") puts ".seek(5) and .puts(\"xyz\") offset --> #{ios.tell}:\"#{ios.getc}\"" puts ios.string.inspect ios.ungetc(?w) puts ios.string.inspect
true
112dd46782e2c47f5780d56f01ff1effb38232db
Ruby
clairgriffiths/exercises
/08_pizza_party/pizza_party_challenge_2.rb
UTF-8
476
4.03125
4
[]
no_license
# CHALLENGE # Create a variant of the program that prompts for the number of people and the number of pieces each person wants and calculates how many full pizzas you need to order def order_pizzas p "How many people are there?" people = gets.chomp p "How many slices does each person want?" slices = gets.chom...
true
72004f4a819a44dbce36910e50fed7b340446eb7
Ruby
matthewchoat/ruby-challenges
/cats.rb
UTF-8
270
3.796875
4
[]
no_license
def likecats(cats) if cats == "yes" return "That's nice for you." elsif cats == "no" return "Me either." else return "You're an odd one..." end end puts "do you like cats?" cats = gets.chomp puts "#{likecats(cats)}"
true
d6e979ffe351d919845209913d6a596fefbbb1ba
Ruby
kristian-welsh/virtus-web-scraper
/main.rb
UTF-8
2,143
3.1875
3
[]
no_license
class INS @@find_first = "FF" @@remove = "R" def self.find_first @@find_first end def self.remove @@remove end end class GalleryDownloader def initialize() @funcs = {INS.find_first => :find_first_element, INS.remove => :remove_element} @g_ins = [] @i_ins = [] end def add_gallery_instruction in...
true
a00e57a6beffc32bb5530df815877101303992ce
Ruby
groteck/lita-keepalive
/lib/lita/handlers/keepalive.rb
UTF-8
905
2.578125
3
[ "MIT" ]
permissive
module Lita module Handlers class Keepalive < Handler config :url, required: true, type: String config :minutes, required: true, type: Integer config :end_hour, required: false, type: Integer http.get '/ping' do |request, response| response.body << "pong" end def work...
true
7d3bd83b3d347858059524524a001599bfc6ecc1
Ruby
jm-rives/fire_hose_project
/FHP_EOex3.rb
UTF-8
300
2.859375
3
[]
no_license
# FHP_EOex3.rb (EO = end of exercise) # from www.thefirehoseproject.com # developed by Joanna M. Rives jm-rives.github.io puts "Please enter the number of inches you would like to convert to centimeters: " inches = gets.chomp.to_f puts inches # print debuggin' centimeters = inches * 2.54 puts centimeters
true
75e19cea362c72c76cf9f051bf50c1f20b858d22
Ruby
bryanvaz/hubscreen
/spec/lib/hubscreen/config_spec.rb
UTF-8
1,956
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# Based on [hubspot-crm gem](https://github.com/adimichele/hubspot-ruby) describe Hubscreen::Config do describe "#configure" do let(:config){ {hapikey: "demo", base_url: "http://api.hubapi.com/v2", portal_id: "62515"} } subject{ Hubscreen::Config.configure(config) } it "changes the hapikey config...
true
175d430b6ab74c3b935261886609e1eccbc002e5
Ruby
franzen/babelphish
/test/binaryTree_test/ruby_test/ruby_test.rb
UTF-8
2,306
2.90625
3
[ "MIT" ]
permissive
require_relative 'test_binaryTree.rb' require 'minitest/autorun' # # Responsible for testing Binary Tree structure # class TestBinaryTree < MiniTest::Unit::TestCase # # Compare objects after serialize and deserialize operations # def test_BinaryTree puts "Test Binary Tree" binaryTree_ser = buildTree ...
true
ddad807f88561b517601750aa2be506ec981b311
Ruby
kirkmernett/Learning-Ruby
/roman_to_integer_spec.rb
UTF-8
462
2.828125
3
[]
no_license
require "lib/roman_to_integer" describe "roman_to_integer tests" do it "should return 1999" do roman_to_integer('mcmxcix').should == 1999 end it "should return 2387" do roman_to_integer('mmccclxxxvii').should == 2387 end it "should return 1999" do roman_to_integer('mdcccclxxxxviiii').should == 1999 end it...
true
80fac829e7f17c1d95587acc776ad3bce2f4fe32
Ruby
muzammilafsar/Beryl
/ruby/unless.rb
UTF-8
52
2.796875
3
[]
no_license
x=10 unless x>20 puts x end puts "abcd" unless x<5
true
89e1b5f2d08546b1476b489acb0a5625f1499296
Ruby
kirubel/codech1
/image_test.rb
UTF-8
415
2.6875
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './image' describe Image do # describe '.new' do # it 'this is an example! change me' do # assert_equal 2+2,4 # assert_output ("Hello\n"){puts "Hello"} # end # end describe "#output_image" do it 'outputs an image' do image=Ima...
true
3a3e0d1bee342f832193cab0dba244cf77d46e0e
Ruby
rjc59/RPN-Interpreter
/rpn_test.rb
UTF-8
3,745
3.46875
3
[]
no_license
require 'simplecov' SimpleCov.start require 'minitest/autorun' require_relative 'rpn_calc' class RPNTest < Minitest::Test def setup @rpn = RPN::new() end # Test that pushing a token to the stack works def test_push token = 1 @rpn.push(token) assert_equal 1, @rpn.pop end # Test that popp...
true
eba871854ea5e151e09259e2f5c7de63dcb9dcb1
Ruby
LeandroSNunes/studies-ruby
/metaprogramming/03_variavel_instancia_class.rb
UTF-8
440
3.734375
4
[]
no_license
# variaveis de instancias denotadas: # @my_var # variaveis de class, denotadas: # @@my_var class Car @@num_roda = 4 # variavel de class inserida na SingletonClass def self.num_roda @@num_roda # variaveis de classe nao sao acessadas diretamete, é preciso criar um metodo end def initialize @num_porta...
true