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
22e931f74c92b59acb40ff08241fb7d873a85fde
Ruby
DimaSamodurov/completeness
/test/completeness_test.rb
UTF-8
4,780
3.171875
3
[]
no_license
require_relative 'minitest_helper' class Profile attr_accessor :first_name, :last_name, :email, :phone, :addresses include Completeness self.define_completeness( { first_name: { :if => 'present?', weight: 20 }, last_name: { weight: 20 }, # used default :if ...
true
d93746dbe98b3a2371d2b865bc013ac915f17b9b
Ruby
Hal9000/runeblog
/empty_view/config/exper/gen_svg.rb
UTF-8
1,297
3.265625
3
[]
no_license
width = 550 title = "My Stuff" # 13 -> 58, 8 -> 13/8 * 58 sub = "I always wanted a place for it" # 22 -> 24, 31 -> 15 tlen, slen = title.length, sub.length tfont = 58 sfont = 18 =begin .svg_titles title style: bold size: 20px face: sans-serif color: white title2 italic 10px sans-serif width 550 hei...
true
0a77e2abfe3fa6ec49b3e60a1cefa27ef1e029b4
Ruby
CapSens/codecom
/lib/capsens/runner.rb
UTF-8
13,185
2.75
3
[ "MIT" ]
permissive
require 'yaml' require 'ostruct' require 'active_support/inflector' module Capsens module Codecom class Runner attr_accessor :configuration # Describe here what the method should be used for. # Remember to add use case examples if possible. # # @author Yassine Zenati # ...
true
516724a2a974f46aa9ec8b05f0cd4bb65c1d34b9
Ruby
shantiii/bakarpg
/lib/rpgchat/dierolls.rb
UTF-8
2,392
3.125
3
[]
no_license
require 'parslet' require 'securerandom' module RPGChat module DieRolls class DieParser < Parslet::Parser # Character Classes rule(:digitnz) { match['1-9'] } rule(:digit) { match['0-9'] } rule(:space) { match['\s'] } rule(:space?) { space.maybe } rule(:operator) { match['-+*']...
true
1a133821c19b32dd1d99d7df1a2545c022cf8f57
Ruby
hopsoft/key_store
/lib/key_store/key.rb
UTF-8
1,017
2.78125
3
[ "MIT" ]
permissive
require "forwardable" module KeyStore class Key extend Forwardable def_delegators :KeyStore, :store, :exists? attr_reader :name, :roles attr_accessor :notes alias_method :to_s, :name def initialize(name, roles: nil, notes: nil) @name = name.to_s if exists?(name) set_rol...
true
d7f2d99a3a8c5a2ec3f7e07c5e28da58f1eaced3
Ruby
learn-co-students/seattle-web-091619
/08-intro-to-orms/app/models/reader.rb
UTF-8
674
3.171875
3
[]
no_license
class Reader attr_accessor :name, :age, :fave_book # we won't be using this anymore. # @@all that we will now refer to is the SELECT * FROM table # @@all = [] def initialize(name, age, fave_book, id=nil) @name = name @age = age @fave_book = fave_book end #Create def self.new_table DB[...
true
071c8ec1afd0febd118c9c2223755599675a88a2
Ruby
jackmcc08/makers-wk4-student-directory
/directory_alt_exercises.rb
UTF-8
6,327
4
4
[]
no_license
#Exercises 1 through 12 complete, exercise 11 is in a different file (spell_check.txt) # let's put all students into an array # commenting out existing students array to replace with user input array students_november_cohort = [ {name: "Dr. Hannibal Lecter", cohort: :november}, {name: "Darth Vader", cohort: :nov...
true
afa11457f6ab120e4c4977c21edff4909f875a59
Ruby
jknichel/kit_info
/lib/typekit_menu_io.rb
UTF-8
4,587
3.515625
4
[]
no_license
require 'tty-prompt' # A class for handling IO with for Typekit API command line applications. It # wraps a few methods from tty-prompt to expose them to other classes that use # this class. However, it also has a few methods that prompt the user for input # related to Typekit API request payloads, formats that input...
true
85bbd31b8de9ebccf65a62831acf896b467bcd82
Ruby
simonjamain/designexporter-plugin-multipage
/multipage.rb
UTF-8
2,736
2.90625
3
[]
no_license
require 'nokogiri' require 'fileutils' require 'shellwords' require 'tempfile' def multipage (sourceFileName, outputFileName) #load source file svgSource = Nokogiri::XML(File.read(sourceFileName)) svgAllLayers = svgSource.xpath('//svg:g[@inkscape:groupmode="layer"]') tmpPdfFiles = [] pageNumber...
true
dd72fcae8644eb5d5383b11c53b4c07a1ba5dbbb
Ruby
Kite0301/atcoder
/Beginner/041/a.rb
UTF-8
23
2.875
3
[]
no_license
puts gets[gets.to_i-1]
true
7d37a2bfd258574d220a3d7130393b6902485435
Ruby
odeta/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
663
3.921875
4
[]
no_license
#write your code here class String def first_letter self[0, 1] end end $vowels = ['a', 'e', 'i', 'o', 'u'] def translate s words = s.split.map do |word| if vowel? word.first_letter word + "ay" elsif not vowel? word.first_letter current = word.first_letter i = 1 start_of_word...
true
cd77d3f177581e53ce338f014ed5ab811e8cd028
Ruby
Lokideos/ruby-think-project
/lesson-2/hw-les-2/fill-array-with-numbers.rb
UTF-8
824
4.21875
4
[]
no_license
=begin Lokideos, Thinknetica RoR courses, lesson-2, task-2 Program "Fill array with numbers" This program will fill an array with numbers >= 100 & <= 10 with increment equal to 5. =end exit_check = "" until exit_check == "exit" #Initialize puts "Greetings! This program will create an array and fill it with numbe...
true
4057fd10b75bbc6604608461ccf5b48170429e84
Ruby
axenictech/ruby-programming
/prateema/27_july_2014/Shop_now.rb
UTF-8
5,034
3.03125
3
[]
no_license
#Where is the comments ?? require 'mysql' require "terminal-table" class Shop def initialize begin @conn=Mysql.connect("localhost","root","mysql") @conn.query("create database if not exists\ prateema") @conn.query("use prateema") @conn.query("create table if not exists\ i...
true
e8de6459b8cd05504d05ac5870ec8cce46e35f80
Ruby
julesmartin76000/phase-0-tracks
/ruby/gps2_2.rb
UTF-8
2,240
4.40625
4
[]
no_license
# Method to create a list # input: string of items separated by spaces (example: "carrots apples cereal pizza") # steps: # create a new hash # set default quantity : 1 # print the list to the console [can you use one of your other methods here?] # output: [what data type goes here, array or hash?] : hash # Me...
true
dd0a50b1c5482040d026f643363f5a0a88dc28ad
Ruby
harhogefoo/yukicoder_ruby
/n394.rb
UTF-8
137
3.15625
3
[]
no_license
s = gets.chomp.split(" ").map(&:to_i) s.sort! s.delete_at(0) s.delete_at(s.length-1) puts sprintf("%.2f", s.inject(:+) / s.length.to_f)
true
ce67794264ffc90c69dec59e583c90fb4b7fcb80
Ruby
ihzarizkyk/LearnRuby
/app/kalkulator.rb
UTF-8
357
3.34375
3
[]
no_license
puts "KALKULATOR SEDERHANA" puts "Masukkan Angka Pertama : " bil1 = gets.to_i puts "Masukkan Angka Kedua : " bil2 = gets.to_i puts("Hasil Penjumlahan bilangan : #{bil1+bil2}") puts("Hasil Pengurangan bilangan : #{bil1-bil2}") puts("Hasil Pembagian bilangan : #{bil1/bil2}") puts("Hasil Perkalian bilangan : #{bil1*bil2...
true
7d4dfb263f1ae5963d4f02e6417a509988cef9bc
Ruby
akiellor/gemjars-deux
/lib/gemjars/deux/index.rb
UTF-8
3,010
2.578125
3
[ "MIT" ]
permissive
require 'gson' require 'multi_json' require 'thread' require 'set' require 'digest/md5' module Gemjars module Deux class Index include Enumerable class In include Enumerable def initialize store @store = store end def each channel = @store.get("i...
true
24d45e6d547d4ce03e330f04807d26fcf1174b35
Ruby
uranussg/aA_classwork
/W2D3/mastermind_project/lib/mastermind.rb
UTF-8
446
3.5
4
[]
no_license
require_relative "code" class Mastermind def initialize(length) @secret_code = Code.random(length) end def print_matches(code) puts @secret_code.num_exact_matches(code) puts @secret_code.num_near_matches(code) end def ask_user_for_guess puts "Enter a code" ...
true
3e3bcc573ba51c48513faca2cddf8f9886b6aee6
Ruby
potenza/tracksimply
/test/models/import_test.rb
UTF-8
1,829
2.6875
3
[]
no_license
require 'test_helper' class ImportTest < ActiveSupport::TestCase setup do imports(:one).file.store!(File.open("test/fixtures/files/adwords.csv")) end test "requires file" do import = Import.new import.valid? assert_equal ["can't be blank"], import.errors[:file] end test "#to_s returns name"...
true
c60a591bce8f6d8255fc151685b61a950a37ba05
Ruby
doreymiller/ruby_basic_exercises
/return/bld.rb
UTF-8
201
3.46875
3
[]
no_license
# bld.rb =begin What will the following code print? Why? Don't run it until you've attempted to answer. def meal return 'Breakfast' end puts meal =end def meal return 'Breakfast' end puts meal
true
7523d2fe0a89ed58a3ba732a275ac88c50f842e8
Ruby
kunal8607/Ruby-
/recur.rb
UTF-8
360
3.234375
3
[]
no_license
str=" RUBY parses a file by looking for <br/> one of the special tags that tells it to start interpreting the text as RUBY code. The parser then executes all of the code it finds until it runs into a RUBY closing <br/> tag." arr=str.split() i=0 def recursion(i,arr) if(!(arr[i]==nil)) puts(arr[i]) i=i+1 recurs...
true
7023a33d8b4acb89a1f8c6002bd3efcb4fc59b66
Ruby
johankardell/SoftwareCraftmanship
/SmallKatas/PerfectNumbers/Ruby/PerfectNumberCalculatorTest.rb
UTF-8
3,015
3.4375
3
[]
no_license
require "test/unit" require "./PerfectNumberCalculator" class TestPerfectNumbers < Test::Unit::TestCase def testFourIsNotAPerfectNumber # Arrange perfectNumberCalculator = PerfectNumberCalculator.new # Act actual = perfectNumberCalculator.IsPerfectNumber(4) # Assert ...
true
c0441123146be9b92f802fe929f5f173be52688d
Ruby
YuukiMAEDA/AtCoder
/Ruby/ABC/A/21A.rb
UTF-8
79
2.59375
3
[]
no_license
n=gets.to_i ans=[] ans.push(1) if n.odd? ans+=[2]*(n/2) puts ans.size puts ans
true
199a5e0bb397e4287dfa9490b962eb80edd5807a
Ruby
dfurstein/StandCoffee
/app/models/article.rb
UTF-8
915
2.71875
3
[]
no_license
class Article < ActiveRecord::Base attr_accessible :twitter_id, :site, :url, :title, :photo_url, :description, :published_at, :is_active def self.add_article(twitter_id, site, url, title, photo_url, description, published_at) article = Article.new article.twitter_id = twitter_id arti...
true
d18755586ec229fa7505cba01a0d5499d0bc4430
Ruby
fcofdez/biimail
/app/models/repositories/databases/documents.rb
UTF-8
959
2.71875
3
[]
no_license
require 'mongo' module Repositories module Databases class Documents def initialize(db = "emails", collection = "emails") @client = Mongo::MongoClient.new @records = @client.db(db).collection(collection) end def save(email) @records.insert(email.to_hash) end ...
true
b33daaae3a519ab1a59a9a9fefa8982df552548b
Ruby
chunky56/project_euler
/p010.rb
UTF-8
427
3.984375
4
[]
no_license
require 'prime' def sum_of_primes(num) return get_primes(num).reduce(:+) end def sum_of_primes_2(num) Prime.each(num).reduce(:+) end def get_primes(num) primes = [] (2..num).each do |i| primes << i if is_prime?(i) end return primes end def is_prime?(num) (2..Math.sqrt(num)).each do |i| return ...
true
f986c8e845dc46cb9e2662b4bbd12427f6aa66e7
Ruby
authify/authify-api
/lib/authify/api/models/apikey.rb
UTF-8
1,486
2.546875
3
[ "MIT" ]
permissive
module Authify module API module Models # Additional, revocable user access class APIKey < ActiveRecord::Base self.table_name = 'apikeys' include Core::SecureHashing extend Core::SecureHashing include JSONAPIUtils attr_reader :secret_key validates_pres...
true
2a454aa004cf77d9c34253bb9cd50792218baa1e
Ruby
LimitToInfinity/ruby-enumerables-practice-hash-collections-exercise
/collections_practice.rb
UTF-8
2,846
3.484375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def begins_with_r(strings) strings.all? do |string| string.start_with?("r") end end def contain_a(strings) strings.select do |string| string.include?("a") end end def first_wa(strings_and_symbols) strings_and_symbols.find do |string_or_symbol| string_or_symbo...
true
20760a53d530ec195cbf8c06b5016a93a11765a6
Ruby
Atar97/aA-Alpha-Course-completed
/Austin_Cotant-online-battleship/lib_extensions/battleship.rb
UTF-8
2,294
3.921875
4
[]
no_license
require_relative 'ship.rb' require_relative 'board.rb' require_relative 'battleship.rb' require_relative 'ship.rb' require 'byebug' class BattleshipGame attr_reader :boards, :players def initialize(player1 = HumanPlayer.new, player2 = ComputerPlayer.new) # I add the nil so that I can change the active player ...
true
46618d56907203b8b9b5513055c2097b9d8990a4
Ruby
yuehanh/aa_classwork
/W2/W2D5/todoboard/list.rb
UTF-8
3,004
3.4375
3
[]
no_license
require_relative './item.rb' class List attr_accessor :label def initialize(label) @label = label @items = [] end def add_item(title, deadline, description="") if Item.valid_date?(deadline) @items << Item.new(title, deadline, description) return true ...
true
7adb4df4448005d81705267bc0e8cabf7a5a02df
Ruby
rnhurt/google_anymote
/lib/google_anymote/pair.rb
UTF-8
5,443
3.1875
3
[ "MIT" ]
permissive
require "google_anymote/version" require 'socket' require 'openssl' ## # Module that understands the Google Anymote protocol. module GoogleAnymote ## # Class to send events to a connected GoogleTV class Pair attr_reader :pair, :cert, :host, :gtv ## # Initializes the Pair class # # @param [Ob...
true
b8fba227ca8556b32ed1999ffa03abad23f29e26
Ruby
marwahaha/ozpics
/app/models/line_item.rb
UTF-8
365
2.53125
3
[]
no_license
class LineItem < ApplicationRecord belongs_to :photo attr_accessor :amount @@amount = 0 def self.refresh @@amount = 0 end def self.show_amount @@amount end def self.total_price(buyer) line_items = LineItem.where(buyer_id: buyer.id, complete: false) @@amount = line_items.to_a.sum { |l...
true
8481ffe7055fe45083bc8a38b7400b88e1aae41e
Ruby
b-random/ruby_projects
/code.chal/lesson22.rb
UTF-8
137
3.65625
4
[]
no_license
puts "Degrees in celcius:" c = gets.chomp.to_i fahr = (c * 9)/5 + 32 convert = "...is #{fahr} degrees fahrenheit!" puts convert
true
5bd87557fbbb5f0cfce6a984dfb31fb0c304a33f
Ruby
balalnaeem/challenges
/medium_1/pig_latin/practice_regex.rb
UTF-8
152
2.8125
3
[]
no_license
def parse_for_consonant(word) consonant_split = /\A([^aeiou]*qu|[^aeiou]+)([aeiou].*)\z/.match(word) [consonant_split[1], consonant_split[2]] end p
true
8e877a80f753acc670835507fd02457181f3e48c
Ruby
tonyta/ChrisPineRuby
/IsPrimeAA.rb
UTF-8
539
4.21875
4
[]
no_license
def is_prime?(num) i = 2 while i < num is_divisible = ((num % i) == 0) if is_divisible # divisor found; stop and return false! return false end i += 1 end # no divisors found true end puts puts 'Come, check and see if your number is prime!' print 'What is your number? ' num = ...
true
7e95a2d2e524a435caa62e4be2499010fa3e9b24
Ruby
tied/DevArtifacts
/master/WCRS_SourceCode/Chap 2 - Website Scripting/rssParser.rb
UTF-8
748
3.09375
3
[ "MIT" ]
permissive
require 'rss/1.0' require 'rss/2.0' require 'open-uri' # location of rss feed source = "http://nostarch.com/blog/?feed=rss2" content = "" open(source) do |s| content = s.read end #contect now contains the rss feed data rss = RSS::Parser.parse(content, false) #customize how the information is presented print...
true
3e46e36052080dfcb16edd49a6552d622797f309
Ruby
EphraimFriedman/algorithm_practice
/linked_list.rb
UTF-8
1,341
3.484375
3
[ "MIT" ]
permissive
require 'pry' class Node attr_reader :value attr_accessor :next def initialize(value) @value = value @next = nil end end class Linked_List attr_accessor :head, :tail, :size def initialize @head @tail @size = 0 end def push(v) node = Node.new(v) self.head = node...
true
80f0661421fc73b7af12a0c3fa320ede71cf80fd
Ruby
gabriel-wilkes/Launch-School-Exercises
/101/Small-Problems/Easy-3/5.rb
UTF-8
63
3.125
3
[]
no_license
def square(x) x * x end p square(5) == 25 p square(-8) == 64
true
efc89857d04172bebcfa8e188009426505c18a31
Ruby
hechien/Polestar-Astrology
/lib/tasks/create_lunar_dates_json.rake
UTF-8
1,160
2.640625
3
[]
no_license
# encoding: utf-8 require 'rubygems' require 'rake' require 'execjs' require 'csv' namespace :astro do desc "Add hour and year to people" task :date_json => :environment do File.open(Rails.root.join(*%w(app assets javascripts cal_convert.js.coffee)), 'a') {|file| file.write("\n @date_table = [\n") ...
true
e8255804877f5d65f33264e3e56320db92ddfb84
Ruby
alexbutirskiy/sea_battle
/lib/sea_battle/board.rb
UTF-8
5,254
3.78125
4
[]
no_license
require_relative 'cell' require_relative 'ship' class BoardSizeError < RuntimeError; end class OutOfBoardError < RuntimeError; end class ShipSizeError < RuntimeError; end class NotRoomError < RuntimeError; end # class Board describes game board class Board include Direction include State attr_accessor :playe...
true
49a42ec28a2d04772a8baee45af9b8868e049b62
Ruby
pung-project/pir-test
/client_master.rb
UTF-8
1,904
2.5625
3
[]
no_license
#!/usr/bin/env ruby require 'optparse' options = {:server_addr => "127.0.0.1:12345", :sys => "seal", :exp => "dc", :n => 2**16, :d => 2, :a => 16, :t => 20, :c => 1, :i => 10} OptionParser.new do |opts| opts.banner = "Usage: client_master.rb [options]" opts.on("-h", "--host ADDR", "specify server ad...
true
0820175fda00c72283ad7f3e0b1047f54f05afca
Ruby
RobertoBarros/batch_503_food_delivery_day_two_complete
/app/controllers/meals_controller.rb
UTF-8
562
2.96875
3
[]
no_license
require_relative '../views/meals_view' class MealsController def initialize(meal_repository) @meal_repository = meal_repository @view = MealsView.new end def add # Ask user meal name name = @view.ask_name # Ask user meal price price = @view.ask_price # create new meal new_meal = ...
true
34a6ea81a7f905a8dce3dce4f3458462fbb8e138
Ruby
bashantad/bracket_checker
/spec/bracket/validator_spec.rb
UTF-8
1,322
3.078125
3
[]
no_license
require './lib/bracket/validator' module Bracket RSpec.describe Validator do include Validator describe "#is_properly_closed?" do context "When odd number of brackets are passed" do it "returns false" do input_string = "[ 4 * (2 + 3) " expect(is_properly_closed?(input_str...
true
09f620723aa3090beebe86159e82faef78df5bbd
Ruby
MsgLosers/dns_record_history
/lib/dns_records.rb
UTF-8
1,849
2.796875
3
[ "MIT" ]
permissive
require 'resolv' require 'yaml' require './lib/postgres' # Track a DNS record class DNSRecords attr_accessor :fqdn, :record_types, :records def initialize(fqdn, record_types = [Resolv::DNS::Resource::IN::A, Resolv::DNS::Resource::IN::MX]) @fqdn = fqdn @record_types = record_types @resolver = Resolv::D...
true
a0307dc984c1c9a0d7c6eddabb93a367e1b2d6c8
Ruby
raspygold/advent_of_code
/2017/01/part1.rb
UTF-8
236
3.125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby file_path = File.expand_path("../input", __FILE__) input = File.read(file_path) digits = input.strip.split("").map(&:to_i) sum = 0 (digits << digits[0]).each_cons(2) do |a,b| sum += a if a == b end puts sum
true
0116024a2a66572652592a86324fdd940435ede4
Ruby
Rasit1/Exercices-Ruby
/exo_13.rb
UTF-8
112
3.0625
3
[]
no_license
puts "Votre année de naissance?" print ">" anneeUser = gets.chomp for i in (anneeUser.to_i..2018) puts i end
true
ac2db895321876cea4e49f2b275806c37564ee25
Ruby
topofocus/active-orient
/lib/model/the_record.rb
UTF-8
7,830
2.765625
3
[ "MIT" ]
permissive
module ModelRecord ############### RECORD FUNCTIONS ############### def to_s to_human end ############# GET ############# def from_orient # :nodoc: self end # Returns just the name of the Class def self.classname # :nodoc: self.class.to_s.split(':')[-1] end =begin flag whether a property...
true
b3c654cc96d2842916a2c6212db9fc1ac37be17f
Ruby
nitrado/ruby-openstack
/lib/openstack/compute/server.rb
UTF-8
15,625
2.640625
3
[ "MIT" ]
permissive
module OpenStack module Compute class Server require 'openstack/compute/metadata' attr_reader :id attr_reader :name attr_reader :status attr_reader :progress attr_reader :accessipv4 attr_reader :accessipv6 attr_reader :addresses attr_reader :hostId attr_reader...
true
0ee14ed613ce7d818ae1c6652fbf1fdf515c0b30
Ruby
DanBurbach/Favorite_Things
/spec/favorite_things_spec.rb
UTF-8
315
2.640625
3
[ "MIT" ]
permissive
require('item') require('rspec') describe(Item) do describe('.mySort') do it('sorts our list of items by rank') do new_item = Item.new("pizza", 8).save new_item = Item.new("burrito", 1).save new_item = Item.new("cheeze block", 2).save expect(Item.mySort).to(eq("")) end end end
true
2f046a716fa8b37b2683f105899ecf08fc688b91
Ruby
lisswart/phase-3-ruby-oo-object-relationships-has-many-through-lab
/lib/genre.rb
UTF-8
680
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" require_relative "./song.rb" require_relative "./artist.rb" class Genre attr_accessor :name @@all =[] def initialize(name) @name = name @@all << self end def self.all @@all end def songs Song.all {|song| song.genre == self} end def a...
true
4a102ec24e28d3a053caf0770ed79ddadbb1d07d
Ruby
nashsibanda/app_academy_open
/Ruby/Reference/Sudoku/player.rb
UTF-8
177
3.765625
4
[]
no_license
class Player def input puts "Change a number. Example: to change the number at spot [3, 5] to 7, enter '3,5,7'." return gets.chomp.split(",").map(&:to_i) end end
true
ee7be60a126eb76068b541e9d3ace7c25bf7a480
Ruby
Santiag0C/backend_prework
/day_7/10_little_monkeys.rb
UTF-8
333
3.8125
4
[]
no_license
print "how many monkey jumping on the bed would you like: " def monkey(numberm) puts "#{numberm} little monkey jumping on the bed, He fell off and bumped his head, Mama called the doctor and the doctor said, Get those monkeys right to bed!" end x = gets.chomp monkey(x) #if monkey == "0" # puts "there is not monke...
true
8078e99221c6eec4714ce7ccb9c68cb86bb0652d
Ruby
abrissette/concatfinder
/concat_app.rb
UTF-8
1,507
3.015625
3
[]
no_license
require 'concat_finder' require 'benchmark' filename = ARGV[0] report = String.new program_stats = Benchmark.measure do if (ARGV.size == 0) or (!File.exists?(ARGV[0])) then abort("please provide a valid file name") end File.open(filename,"r") do | file | c...
true
13c4fa6822597b847e947b62b02e3b6e13a5eac4
Ruby
jagaapple/string_foundation.rb
/spec/string_foundation/is_spec.rb
UTF-8
1,890
2.984375
3
[ "MIT" ]
permissive
# ============================================================================== # SPEC - STRING FOUNDATION - IS SPEC # frozen_string_literal: true # ============================================================================== describe "[ Is Methods ]" do let(:string) { "string" } let(:expected_symbol) { :string ...
true
4470b984ea060ca10b656876a78679040b86fb7a
Ruby
3apy6a/homeworks
/huor_in_year.rb
UTF-8
134
2.96875
3
[]
no_license
p " Task one: how many hours in a year?" YEAR = 365.242199 #namber of days in a year DAY = 24 #number of hours in a day p YEAR*DAY
true
f3caaef9e43a55b7207cd2d07d8960dfbbe90689
Ruby
AbhijayGhadyale/RubyCapybaraFrameworkAll
/framework/custom_capybara/common_text_box_controls.rb
UTF-8
1,496
2.90625
3
[]
no_license
module CommonTextBoxControls class << self include Capybara::DSL def enter_text (locator, locator_type, text_string) begin case locator_type when 'css' find(:css, locator).set(text_string) $LOG.info "#{text_string} entered in #{locator}" when 'xpath' ...
true
a79a21ad6a53f1436bc75830546dc81e4017bfe5
Ruby
kimsuelim/naver-sdk-ruby
/lib/naver/voice.rb
UTF-8
921
2.671875
3
[ "MIT" ]
permissive
module Naver # :nodoc: # Naver Voice API class Voice < Client class << self # 음성합성(Beta) # @param speaker [String] 음성 합성할 목소리 설정: ( mijin:미진(한국어, 여성), jinho:진호(한국어, 남성), clara:클라라(영어, 여성), matt:매튜(영어, 남성), yuri:유리(일본어, 여성), shinji:신지(일본어, 남성), meimei:메이메이(중국어, 여성)) # @param speed [Integer] -5 ...
true
4006ff0b658344fa8baf73bb4de4fa2101445620
Ruby
dannysperry/ruby
/Programs/psych.rb
UTF-8
399
3.546875
4
[]
no_license
def ask question puts question reply = gets.chomp.downcase if reply == 'yes' true elsif reply == 'no' false else puts 'Please answer "yes" or "no".' ask question end end main = ask 'Do you wet the bed?' ask 'Are you 3?' ask 'Do you have a dog?' ask 'Is your dog a boy?' if main == true ...
true
467ae4af97b53fb1edd9601144a6c53a6b8ebe9b
Ruby
seona-yu/crud
/app/controllers/home_controller.rb
UTF-8
1,650
3.28125
3
[]
no_license
class HomeController < ApplicationController def index @posts=Post.all end def new end def create @post = Post.new @post.title = params[:title] @post.content = params[:text] @post.save redirect_to '/' end def show @post =Post.find(params[:post_id]) end def des...
true
432ce2aca6359efe2d3730b1e51ec453a2556803
Ruby
ilya-burinskiy/Ruby
/Railway/command_executor.rb
UTF-8
6,017
3
3
[]
no_license
# frozen_string_literal: true require_relative 'train/train' require_relative 'carriage/carg_carriage' require_relative 'carriage/passenger_carriage' class CommandExecutor def decode_command(command) case command when 1 :create_station when 2 :create_train when 3 :create_route ...
true
a3b55006ec251f9d3e8bb7c21f91787ded599452
Ruby
CodingDojoOnline-Ruby-1/JoyAlvarez
/hashes.rb
UTF-8
1,263
4.3125
4
[]
no_license
# Exercises from platform x = {"first_name" => "Coding", "last_name" => "Dojo"} puts x["first_name"] , x["last_name"] puts "Your last name is Dojo" if x["last_name"].eql? "Dojo" y = {:first_name => "Melanie", :last_name => "Smith"} puts "Y is ", y puts y[:first_name], y[:last_name] puts "Deleting :first_name" y.del...
true
393c595ab0d694d9c4138d37c9f93717a98d66a1
Ruby
George-Hudson/enigma
/lib/decrypt.rb
UTF-8
1,213
3.265625
3
[]
no_license
require './lib/offset_calculator' require './lib/rotation_calculator' require './lib/string_decryptor' class Decrypt attr_reader :read_file, :write_file, :key, :date def initialize(read_file, write_file, key, date = nil) @read_file = read_file @write_file = write_file @key = key @date = date ...
true
9077fe4032aaa6585722471ace1a1a119ce799c1
Ruby
KKisly/ITA
/HW_18/lib/script_18_08.rb
UTF-8
796
3.40625
3
[]
no_license
# Script = script_18_08.rb # Description = command line optiones using "trollop" # Name = Konstantin Kisly # EMail = kisly.k@gmail.com require 'trollop' word = [] opts = Trollop::options do opt :first, "first", :short => "-a", :type => :strings opt :second, "second", :short => "-b", :type => :strings opt :third, "th...
true
bb2bcf40876da449076fb06461904dc1dba8c5c8
Ruby
cctiger36/command_timer
/lib/command_timer/parser.rb
UTF-8
754
2.921875
3
[ "MIT" ]
permissive
require "yaml" module CommandTimer class Parser def self.parse(yml_path) yml_path += ".yml" unless yml_path.end_with?('.yml') yml = YAML.load_file(yml_path) commands = [] yml.each do |cell| data = cell[1] command = Command.new data.each do |k, v| if ['con...
true
48dc4ff4582ac6db3fdaa6fd49d8abcfd8ea0a84
Ruby
gotunandan/keyserver
/keyserver.rb
UTF-8
944
2.734375
3
[]
no_license
require './myserver' class KeyServer < Sinatra::Application my_server = MyServer.new get '/gen' do my_key = my_server.gen if my_key "Key generated successfully #{my_key}" else "Failed to generate key" end end get '/get' do my_key = my_server.get if my_key "Key recei...
true
293c6e35373a2ac0eafebcf90801a4706fe3283d
Ruby
jarijokinen/tesla-cli-ruby
/lib/tesla/cli.rb
UTF-8
1,325
3.078125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'io/console' require 'pp' require 'thor' require 'tesla/auth' require 'tesla/vehicle' module Tesla class Cli < Thor desc 'login', 'Log in to your Tesla Account' def login print 'Email: ' email = STDIN.gets.chomp print 'Password: ' password = STDIN.noecho(&:gets).chomp ...
true
a990d89384bc7034482f11f24df3a1d05f59b59e
Ruby
joelvh/rack-cloudflare
/lib/rack/cloudflare/headers.rb
UTF-8
4,035
2.609375
3
[]
no_license
# frozen_string_literal: true require 'json' module Rack class Cloudflare class Headers # See: https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers- NAMES = %w[ HTTP_CF_IPCOUNTRY HTTP_CF_CONNECTING_IP HTTP_CF_RAY H...
true
de9d1f3b9e9790c7379ada4980335c1a9ec7ee95
Ruby
andrewaganad/work
/lesson_3/hard_1/exercise_four.rb
UTF-8
415
2.890625
3
[]
no_license
def dot_separated_ip_address?(input_string) dot_separated_words = input_string.split(".") counter = 4 while dot_separated_words.size > 0 && counter > 0 do word = dot_separated_words.pop break unless is_an_ip_number?(word) counter -= 1 end dot_separated_words.empty? && counter == 0 end # Post...
true
2bc757eac186b3d63801aa27cf1f3b9c1367422a
Ruby
emad-elsaid/rubyfunctions
/src/app/models/code.rb
UTF-8
624
3.046875
3
[]
no_license
class Code attr_reader :code def initialize(code) @code = code.to_s @valid = true parse_code end def valid? @valid end def functions return [] unless @valid @functions ||= extract_functions(@ast) end private def parse_code @ast = RubyVM::AbstractSyntaxTree.parse(@code...
true
8c18a23709fe211fb07d18bfdc5b9153563672fe
Ruby
pariser/wedding-registry-scraper
/lib/wedding_registry_scraper/registries/zola.rb
UTF-8
1,562
2.640625
3
[ "MIT" ]
permissive
class WeddingRegistryScraper::Registries::Zola < WeddingRegistryScraper::Registry @display_name = "Zola" @domain = "zola.com" private def get_products(doc) doc.css('#all-panel .product-tile') end def get_name(product) product.css('.single-product-name').text.strip end def get_sku(product) sk...
true
10c0b8c8f0d942f27e5c3a83ede8c0df624b0a32
Ruby
lucastdcj/tobi
/public/problems/74/sols/test_sols.rb
UTF-8
1,343
2.734375
3
[]
no_license
require "../config.rb" sols = [ { :autor => '100pts', :arquivo => '100pts.cpp' }, ] oficial = 0 puts "Compilando soluções do problema #{$name}." sols.each do |s| puts " #{s[:autor]}" system "g++ #{s[:arquivo]} -o #{s[:autor]}" end puts "Gerando saída oficial." Dir.glob(File.join('../tests/test**', 'in*'))...
true
a50cf0ddf0a3fd6b7799f82c3011412a696b4c5c
Ruby
hjung1018/badges-and-schedules-onl01-seng-ft-072720
/conference_badges.rb
UTF-8
550
3.84375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def badge_maker(name) return "Hello, my name is #{name}." end def batch_badge_creator(attendees) badge = [] attendees.each do |name| badge << "Hello, my name is #{name}." end badge end def assign_rooms(name) room = [] name.each.with_index(1) do |person, index| room << "Hello...
true
11b08188f298a83282674d3f565f87a3bff263da
Ruby
jeffmcfadden/railsconf-2017-schedule
/scrape_schedule.rb
UTF-8
802
2.703125
3
[]
no_license
require 'nokogiri' require 'open-uri' require 'yaml' doc = Nokogiri::HTML(open( 'http://railsconf.com/schedule') ) events = [] ['#tuesday', '#wednesday', '#thursday'].each_with_index do |day, i| start_time = Date.parse( "2017-04-25" ).to_time + (i * 86400) end_time = Date.parse( "2017-04-25" ).to_time + (i * ...
true
553b8fd08173e51c2090671385808d959b5fe4f2
Ruby
slin12/oxford-comma-prework
/lib/oxford_comma.rb
UTF-8
174
2.984375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def oxford_comma(array) return array[0] if array.length == 1 return array.join(" and ") if array.length == 2 last = array.pop array.join(", ") << ", and #{last}" end
true
811a80dea9f36ba5fc3b560e236aa201c93826f4
Ruby
Evon1/StorageDirectory
/app/models/us_city.rb
UTF-8
446
2.78125
3
[]
no_license
class UsCity < ActiveRecord::Base def self.states all(:select => 'DISTINCT state', :order => 'state').map(&:state) end def self.states_by_letter(a) all(:select => 'DISTINCT state', :conditions => "LOWER(state) LIKE '#{a.downcase}%'", :order => 'state').map(&:state) end def self.cities_of(stat...
true
264a6f51ae1c1ef79587122742550f988b965ae7
Ruby
fupuchu/exercism-code-samples
/ruby/diamond/diamond.rb
UTF-8
392
2.9375
3
[ "MIT" ]
permissive
class Diamond def self.make_diamond(target) rows = [] width = target.hex - "A".hex ("A"..target).each_with_index do |letter, length| row = " " * (width - length) row += letter row += " " * (length) row += row[0..-2].reverse + "\n" rows << row end rows << rows[0..-2...
true
a9494db4ec6b53d2f72847400525db1e5b53bd7a
Ruby
SelenaSmall/Counter
/tabs.rb
UTF-8
581
3.3125
3
[]
no_license
#!/usr/bin/ruby class CreateTabs attr_reader :tab_number @@no_of_tabs = 0 @@sotre_tab_number = {} def intialize @tab_number=tab.number @@no_of_tabs +=1 @@store_tab_number[@tab.number] ||= 0 @@store_tab_number[@tab.number] +=1 end def total_number_of_tabs puts "Number of tabs:" @@no_of_tabs = g...
true
bbe0a012d0f6c063f718eb6339742fb70b356b20
Ruby
egamasa/study
/ruby-cherry-book/Section6/6-5-6_match_method.rb
UTF-8
414
3.34375
3
[]
no_license
### match? メソッド ### # Ruby 2.4以降 # 組み込み変数やRegexp.last_matchの返り値を書き換えないので高速 # マッチすればtrueを返す p /\d{3}-\d{4}/.match?('123-4567') #=> true # 組み込み変数やRegexp.last_matchでは取得できない p $~ #=> nil p Regexp.last_match #=> nil # 文字列と正規表現の入れ換えはOK p '123-4567'.match?(/\d{3}-\d{4}/) #=> true
true
d56a1e7b9964ff8fdfb6e4681222706326d2deff
Ruby
er1d0n/testapp
/app/controllers/lesson_controller.rb
UTF-8
1,736
2.640625
3
[]
no_license
class LessonController < ApplicationController def step1 render plain: "こんにちは、#{params[:name]}さん" end #paramsでコントローラ名とアクション名を呼び出す def step2 #render 直接文字列を送信 render plain: params[:controller] + "#" + params[:action] end #redirect_toメソッドでstep3を表示するとstep4にリダイレクトされる def step3 redirect_to action:...
true
02212fa177993dbb30f2609ae3960f20a1ad6a36
Ruby
rodgerbenham/morseogen
/morse.rb
UTF-8
349
3.703125
4
[]
no_license
class Morse attr_accessor :code, :duration def initialize(options = {}) @code = options[:code] @duration = options[:duration] || calculate_duration(@code) end def calculate_duration(str) result = 0 str.each_char do |c| result += 1 if c == " " || c == "·" result += 3 if c == "—" ...
true
c9ff9c25a3d4af2dfb9809290a9bdb686b92dfa3
Ruby
glv/smithereen
/spec/smithereen/parser_spec.rb
UTF-8
14,013
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require File.dirname(__FILE__) + '/../spec_helper' require 'smithereen/parser' describe Smithereen::Parser do Parser = Smithereen::Parser class MockGrammar < Smithereen::Grammar; end describe "instance methods" do subject do Parser.new(MockGrammar.new, :foo) end describe "#initialize"...
true
c94b8d3f8d5eb4ce603ff64f99ebd8271c8d2505
Ruby
dallinbjohnson/coding_folder
/ruby/games/testGame.rb
UTF-8
410
2.59375
3
[]
no_license
require 'gosu' class GameWindow < Gosu::Window def initialize(width, height, fullscreen) super(width, height, fullscreen) @background = Gosu::Image.new("blueswearldots.jpg", :tileable => false) end def button_down(button) close if button == Gosu::KbEscape end def update end def draw @background.d...
true
8d9175d282ba14ffa551f7ba5aa6b3d025370beb
Ruby
synopia/jfcrawler
/crawl.rb
UTF-8
3,455
2.78125
3
[]
no_license
require 'rubygems' require 'nokogiri' require 'open-uri' require 'optparse' require 'benchmark' require 'zip/zip' require 'pp' require "curses" require './jfcrawler' require './workers' require './display' options = {} optparse = OptionParser.new do |opts| opts.banner = 'Usage: crawl.rb [options] url' opts.on( '...
true
4a2734cc44b9937ceb70cfa2ab311add1929680a
Ruby
JLBrigham/checkout
/spec/shop_spec.rb
UTF-8
1,414
2.875
3
[]
no_license
require './lib/shop' describe Shop do let(:shop) {Shop.new} it 'should respond to the method checkkout' do expect(shop).to respond_to(:checkout).with(1).argument end describe '.checkout' do it 'returns 50 when given A as an argument' do expect(shop.checkout('A')).to ...
true
641eac5175d4e11efed057930db20125abf5906f
Ruby
OlegVoloshin/sample-blog
/spec/models/article_spec.rb
UTF-8
1,106
2.53125
3
[]
no_license
require "rails_helper" describe Article do describe "validation" do #разбили на подгруппы тесты для понимания что тестируем it {should validate_presence_of :title} it {should validate_presence_of :text} end describe "assosiations" do it {should have_many :comments} end describe "validate leng...
true
8c7b512d3b499eb3af678a64afdcdcfd197c71f7
Ruby
bleavitt92/Launch-School
/assessment_studying/watch_others_code.rb
UTF-8
1,727
4.5625
5
[]
no_license
# calculate if a number is prime # input: number # output: boolean # determining if an integer is a prime def is_prime?(n) return false if n == 1 (2..n-1).each do |divisor| return false if n % divisor == 0 end true end # write a method that will take an array of numbers, and only return those that are pri...
true
a7457316e155fe332a0b120130f463af5f21b3d5
Ruby
sccp2017/defective-project
/src/03_function/nest_sum_demo.rb
UTF-8
186
3.203125
3
[]
no_license
# hint: use .class def nest_sum(arr) if arr.empty? 0 else head , *tail =arr (if head.class == Array nest_sum(head) else head end) + nest_sum(tail) end end
true
a003fe63206472da629be4d601248c0f8fce8366
Ruby
ppibburr/beaglebone-nunchuck
/lib/nunchuck/xinput/keypad.rb
UTF-8
2,034
2.828125
3
[]
no_license
require "nunchuck/device" require "nunchuck/xinput/device" module Nunchuck class KeyPad < Device include X11InputDevice DEFAULT_MAP = { :z => 41, # f :c => 42, # g :left => 43, # h :right => 44, # j :up => 45, # k :down => 46 # l } # A loop ...
true
485e5f7a97c873c9bc54f81c299582ec6e941720
Ruby
nickborromeo/code-kata
/twin-primes/twin_primes.rb
UTF-8
628
3.921875
4
[]
no_license
def twin_prime(limit) primes = [] twin_primes = [] non_primes = /^1?$|^(11+?)\1+$/ # regex to determine if number is not primeclear #Find the primes in the limit given 0.upto(limit) do |num| primes << num unless non_primes.match(("1" * num)) end # Loop to determine the twin primes. for ...
true
c4e7683065b9571cb01f1a7e51bfd1905b8c2d44
Ruby
tiwillia/rhc
/lib/rhc/commands/scp.rb
UTF-8
3,819
2.625
3
[ "Apache-2.0" ]
permissive
require 'rhc/commands/base' require 'rhc/scp_helpers' module RHC::Commands class Scp < Base suppress_wizard summary "SCP a file to or from your application" description <<-DESC Transfer files to and from your applications using SCP. This will transfer files to and from your primary gear (t...
true
ae4d7f4f0cbcae7e1c1d9127b7dfc89d3ccaf62d
Ruby
jjong7345/rubyexercise
/Ch10/sorting1_dictionary.rb
UTF-8
560
3.40625
3
[]
no_license
arr = ["a", "photo", "Image", "a", "Jpg", "gif", "Movie", "sound", "photo"] def sort arr #This warps recursive_sort recursive_sort arr, [] end def recursive_sort unsorted_arr, sorted_arr if unsorted_arr.length == 0 return sorted_arr end smallest = unsorted_arr.pop still_unsorted = [] unsorted_arr.each do |...
true
a3b39c37f7306fbb3d584c1cbf5aeaebb40086c4
Ruby
contactually/motion-spec
/spec/motion-spec/matchers/be_a_spec.rb
UTF-8
1,409
2.640625
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- describe 'Matcher::BeA' do class SpecialString < String end it 'be_a passes when class is in the inheritance chain' do expect(SpecialString).to be_a String end it "be_a passes when object's class is in the inheritance chain" do expect(SpecialString.new).to be_a String en...
true
2fdd3bcb66da3d0cc5b2b06d3071f7dd4f51f45b
Ruby
yearswriter/launchschool
/codewars/cool_things.rb
UTF-8
320
3.09375
3
[]
no_license
def disemvowel(str) vowels = { a: '', o: '', i: '', u: '', e: '' } str.gsub(/[aoiue]/i,vowels) end def disemvowel(str) str.gsub /[aoiue]/i,'' end def digital_root(n) local = 0 local += n.digits.reduce(:+) if local.digits.size < 2 return local else digital_root(local) end end
true
0515172069e0822113a5e3c1de2127c7dc2a30c0
Ruby
jtprince/home_teach
/lib/home_teach/household.rb
UTF-8
512
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'home_teach/contactable' module HomeTeach class Household include Contactable # a list of the heads of household attr_accessor :heads_of_household # list of all individuals in the house (including heads_of_household) attr_accessor :individuals # this should always match the first hea...
true
3952e4c11cfd94f65b1668f7731e25087f5edfd1
Ruby
enzo9214/E9CP1A2
/2.rb
UTF-8
1,016
3.4375
3
[]
no_license
require 'date' class Course def initialize(nombre, fecha_inicio, fecha_termino) @nombre = nombre @fecha_inicio = Date.parse(fecha_inicio) @fecha_termino = Date.parse(fecha_termino) end def consultaPrevio(fecha = Date.today) if fecha > Date.parse('2018-12-25') raise ArgumentError, 'Fecha po...
true
a43597a3e7a6c1153a2d08153dfebfdfd0f0e43c
Ruby
mcwaller422/Intro_to_Ruby
/TheBasics/ex3.rb
UTF-8
361
4.25
4
[]
no_license
#write a program that uses a hash to store a list of movie titles with the year they came out. #use puts command to make your program print out the year movie_year = { the_matrix: 1999, grandmas_boy: 2006, brave: 2012, frozen: 2013 } puts movie_year[:the_matrix] puts movie_year[:grandmas_boy] puts mo...
true
e3c41971b723cd481d3b9cfcb5a948c521ffe611
Ruby
snehaso/coloring_service
/color.rb
UTF-8
389
3.46875
3
[]
no_license
class Color SEMAPHORE_COLOR_PALATE = %w(red blue green) def initialize(color_scheme = 'black_on_white') @color_scheme = color_scheme end def words_to_html(words) words.collect { |w| convert(w) } end private def convert(word) return "<span class=#{SEMAPHORE_COLOR_PALATE.sample}>#{word}</span...
true
3fe30c9adcab49217454e1e26582da31411d4532
Ruby
DiegoCarrilloS/emprendedor
/emprendedor2.rb
UTF-8
450
2.828125
3
[]
no_license
precio_venta = ARGV[0].to_i usuarios = ARGV[1].to_i usuarios_premium = ARGV[2].to_i usuarios_gratuitos = ARGV[3].to_i gastos = ARGV[4].to_i calculo = (precio_venta * (usuarios + 2*usuarios_premium + 0*usuarios_gratuitos)) - gastos impuestos = 0.35*calculo if calculo > 0 utilidades = calculo-impuestos puts "La...
true
bb5c04e8205d0bb315d862b9f04793111fd4a03b
Ruby
jdagley77/read_my_feelings
/app/models/user.rb
UTF-8
848
2.984375
3
[]
no_license
class User < ActiveRecord::Base include BCrypt validates :full_name, presence: true validates :email, uniqueness: true, presence: true # These are virtual attributes, aka getter and setter # methods for something that ISN'T in our db table def password=(new_password) @raw_password = new_password @pa...
true
a024e201b4764a94232a0076a12f8b476b66c069
Ruby
coopermr/people
/people.rb
UTF-8
451
3.84375
4
[]
no_license
class Person attr_reader :first_name def initialize(first_name) @first_name = first_name end def greeting puts "Hi, my name is #{first_name}." end end class Student < Person def learn puts "I get it!" end end class Instructor < Person def teach puts "Everything in Ruby is an Object." end end chris =...
true