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
2c39b56cc51004e226a08fe03e0fc4dbfea76b17
Ruby
Shomeless99/Control-escolar-en-Ruby-3.0
/PROYECTO/views/maestros.rb
UTF-8
6,504
2.625
3
[]
no_license
require 'fox16' include Fox require_relative './../database/obtener' require_relative './../database/guardar' require_relative './login' class VentanaMaestros < FXMainWindow @user = nil def initialize(app, user) @user = user super(app, "Maestros", :width => 1000, :height => 660, :x =>...
true
4c3a2e406bae9e9096a30b263e6b66a3cd927797
Ruby
mrhead/advent-of-code-2017
/day3.rb
UTF-8
1,154
3.75
4
[ "MIT" ]
permissive
# http://adventofcode.com/2017/day/3 def distance(position) return 0 if position == 1 square_size = Math.sqrt(position).ceil if square_size.even? square_size += 1 end max_distance = square_size - 1 min_distance = (square_size / 2).floor max_number_in_square = square_size ** 2 min_number_in_squa...
true
b9545c19a0b450b12d919d928dcbb0de4e46656d
Ruby
jsteenb2/better_home
/app/helpers/application_helper.rb
UTF-8
121
2.53125
3
[]
no_license
module ApplicationHelper def get_commute(distance, speed) ((distance.to_f / speed.to_f) * 60).round(2) end end
true
d9ca16264046ea183beddcc21099f905c823cee9
Ruby
realms-ai/gre_learning
/lib/tasks/meta_data.rake
UTF-8
1,088
2.515625
3
[]
no_license
namespace :meta_data do desc "Add new words" task :add => :environment do exec "rake db:seed && rake meta_data:fetch && rake meta_data:extract && rake meta_data:update_unextract" end desc "This task fetch meta data from oxford API!" task :fetch => :environment do # FetchMetaDataJo...
true
af2afa628c7b2486bc237d991e766877f1085995
Ruby
spectre6000/console_chess
/lib/console_chess/space.rb
UTF-8
2,740
3.234375
3
[]
no_license
module ConsoleChess class Space attr_reader :token, :position, :call_sign, :available_moves, :move_count def initialize(column, row, color, board, move_count = 0) @column = column @row = row @color = color @board = board @token = "_" set_token @position = "#{@colum...
true
2ef21a0d27e0cc4d80bcb55cd44a052bb6e2d491
Ruby
ryan-allen/tango
/spec/working_directory_spec.rb
UTF-8
1,304
2.890625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'derp' module Derp describe WorkingDirectory do before do stub_class = Class.new do include WorkingDirectory end @stub = stub_class.new # Make doubly sure we reset the working directory after each test. @original_directory = Dir.getwd end after do ...
true
2b999aa71919184f6f9bb851d266c5cbda36af9b
Ruby
TIY-DC-ROR-2015-Jan/fracking-scraper
/app/models/weather.rb
UTF-8
1,186
2.921875
3
[]
no_license
class Weather include HTTParty base_uri "http://thefuckingweather.com/" def self.find_one_class doc, klass selector = ".#{klass}" hits = doc.css selector raise "Expected 1 match for '#{selector}', got #{hits.count}" unless hits.count == 1 hits.first end def self.throttle interval now = T...
true
9f11258512d0f680bef2e9219c5e0d2fa788938b
Ruby
papapabi/exercism.io
/ruby/difference-of-squares/difference_of_squares.rb
UTF-8
303
2.90625
3
[]
no_license
class Squares attr_accessor :square_of_sum, :sum_of_squares def initialize(n) @n = n @sum_of_squares = (1..n).map { |i| i**2 }.reduce(:+) @square_of_sum = (1..n).reduce(:+)**2 end def difference square_of_sum - sum_of_squares end end module BookKeeping VERSION = 4 end
true
e538740ff5210b5cd2f7beef56b2f4554840b5fd
Ruby
wengong/keys-of-hash-001-prework-web
/lib/keys_of_hash.rb
UTF-8
308
3.265625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Hash def keys_of(*arguments) xyz=Array.new self.collect do |i,g| arguments.collect do |z| if z.class == Array if g==z.join or g==z.join.to_i xyz << i end elsif g==z xyz << i end end end return xyz end end
true
f42ba455fe9ccbdcc565a73a005cd13d24faddf1
Ruby
MikeCobra/advent
/spec/advent_spec.rb
UTF-8
5,676
2.53125
3
[]
no_license
ENV['RACK_ENV'] = 'test' require 'rspec' require 'rack/test' require 'json' require 'advent' describe 'The Advent App' do include Rack::Test::Methods def app Sinatra::Application end describe '/day1/' do context 'when given a floor route' do it "returns the route" do route = '(())))' ...
true
d85962509ce6c69f5f3aa7ac1be71c865ab0a5dc
Ruby
fanjieqi/LeetCodeRuby
/1601-1700/1621. Number of Sets of K Non-Overlapping Line Segments.rb
UTF-8
156
2.890625
3
[ "MIT" ]
permissive
MOD = 10**9 + 7 # @param {Integer} n # @param {Integer} k # @return {Integer} def number_of_sets(n, k) (1..(n+k-1)).to_a.combination(2*k).size % MOD end
true
428151e66dc91a49503621e6cf0387ced76dd1e6
Ruby
ryanflach/headcount
/test/statewide_test_test.rb
UTF-8
5,853
3.125
3
[]
no_license
require_relative 'test_helper' require_relative '../lib/statewide_test' class StatewideTestTest < Minitest::Test def test_it_initializes_with_a_hash_of_test_data st = StatewideTest.new({:name => "Colorado"}) assert_instance_of StatewideTest, st end def test_it_returns_its_name_upcased st = Statewide...
true
66e59616ddca11a7d182f71add1f4f9fef702cad
Ruby
Taishikun0721/janken
/user.rb
UTF-8
444
3.359375
3
[]
no_license
require_relative 'hand' class User include Handsable attr_reader :name, :hand def initialize(name) @name = name @hand = hand_initializer end def correct_hand? hand.valid? end def choose_hand! self.hand.name = gets.chomp return hand.name if correct_hand? re_choose_hand! end def re_choose_hand...
true
02116b87c23c71bb43d242e18a44c4c8c2d71e1f
Ruby
antonhalim/pg-playlister-on-activerecord-bk-002-public
/spec/models/song_spec.rb
UTF-8
1,127
2.8125
3
[]
no_license
describe 'Song' do before(:each) do @song = Song.create(name: "Smells Like Teen Spirit") end it 'has a name' do expect(Song.where(name: "Smells Like Teen Spirit").first).to eq(@song) end it 'has a genre' do genre = Genre.create(name: "Rock") @song.genre = genre @song.save expect(S...
true
1482ee9d1e4c6dc8a3faf0befcfcedadc9fba3b2
Ruby
annaship/Ruby-scripts
/test1.rb
UTF-8
231
3.171875
3
[]
no_license
#!/usr/bin/ruby -p while $stdin.gets # reads from STDIN unless (/\d/) $stderr.puts "No digit found." # writes to STDERR end puts "Read: #{$_}" # writes to STDOUT end
true
c47b04205c13f62defabdd6beded6eb07d93beea
Ruby
PHronek/ruby-task_manager
/lib/task_manager/task.rb
UTF-8
212
2.8125
3
[ "MIT" ]
permissive
module TaskManager class Task # Creates new task # @param name [String] new task name # @return [Hash] hash containing task values def self.new(name) {:name => name} end end end
true
fa38315cda5aea3551757cf1a1b5d646c395c2b4
Ruby
HELENE-AUERBACH/LN_The-Hacking-Project-ln-the-gossip-project-Facebook-style
/app/controllers/comments_controller.rb
UTF-8
5,026
2.578125
3
[]
no_license
class CommentsController < ApplicationController before_action :authenticate_user, only: [:new, :create, :edit, :update, :destroy] def index # Méthode qui récupère tous les commentaires et les envoie à la view index (index.html.erb) pour affichage @comments = Comment.all puts "$" * 60 puts "Voici l...
true
92096003bc62c0661549d8510b7802ff88b6d21f
Ruby
NikitaNazarov1/homeworks
/HW_05/Nikita_nazarov/mentor.rb
UTF-8
1,171
3.0625
3
[]
no_license
require_relative 'homework' require_relative 'human' # class mentor class Mentor < Human attr_accessor :notification, :subscribes, :notif_arr def initialize(_fullname) @notification = [] @subscribes = [] @notif_arr = [] super end def subscribe_to_student(student) if subscribes.to_s.include?...
true
f2d3f34432bf9fe7c1c6ba644c1262faf294af21
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/filtered-submissions/353941cba9c54f13b2c0b2b0bf4f33a9.rb
UTF-8
159
3.234375
3
[]
no_license
def compute(left, right) if left.length > right.length left, right = right, left end left.chars.zip(right.chars).count {|a| a[0]!=a[1]} end
true
47289001a44b4d72db7c0f678ca1a2aeb723ced5
Ruby
freecores/vg_z80_sbc
/rtl/psf2coe.rb
ISO-8859-1
1,352
3.140625
3
[]
no_license
#!/usr/bin/ruby # Translate PSF (PostScript Font) files to XilinX COE file format # for embbed a console font into a ROM (Xilinx read-only BRAM) # # 2007 Javier Valcarce Garca, <javier.valcarce@gmail.com> # $Id: psf2coe.rb,v 1.1 2008-12-01 02:00:10 hharte Exp $ # Read header and retrieve font information #...
true
0ecc77a2e82439323b5b84eed68ce1ead24584ca
Ruby
agornich/Poradnia
/app/models/visit.rb
UTF-8
1,159
2.59375
3
[]
no_license
class Visit < ActiveRecord::Base belongs_to :patient belongs_to :employee belongs_to :office belongs_to :workshop validates :start_at, presence: true validates_presence_of :patient_id validate :compare_date validate :compare_office validate :compare_patients validate :new_visit_date_ca...
true
b7f05b3562c4cc77683601c50d4dbf06ee875ea3
Ruby
wenbo/rubyg
/sample/CHAPTER08/176/range.rb
EUC-JP
1,677
3.515625
4
[]
no_license
# 1ʾ4ʲϰϤ롣 r1 = 1..4 # => 1..4 # ǽǤ1ȺǸǤ4ޤࡣ [r1.first, r1.last, r1.exclude_end?] # => [1, 4, false] [r1.begin, r1.end] # => [1, 4] # 󲽤롣 r1.to_a # => [1, 2, 3, 4] # פ롣ԤRuby 1.8.7ʹߤΤߡ r1.inject{|s,x| s+x} # => 10 r1.inject(:+) # => 10 # 1ʾ4̤ϰϤ롣 r2 = 1...4 # => 1...4 # ǽǤ1Ⱥ...
true
03d8b0c70f1a779341cc0f0cc2f65c5499454ffb
Ruby
last/last-representers
/lib/last/representers/subject.rb
UTF-8
2,802
3
3
[]
no_license
module Last module Representers class Subject class UnknownKindError < StandardError; end STRATEGIES = {summary: 0, detail: 1, full: 2}.freeze VALID_KINDS = [:property, :relationship].freeze attr_reader :name attr_reader :strategy attr_reader :primitives # @param name [Symbol] # @param kind [Symbol...
true
93e451795555821c8cc277f58c72693d2026dcf1
Ruby
UoA-eResearch/figshare_gen_xml_from_ldap
/rlib/get_user_attributes.rb
UTF-8
4,738
2.8125
3
[ "MIT" ]
permissive
# @param ldap [NET::LDAP] LDAP file descriptor open to to UoA LDAP # @param attributes [Hash] pairs of <LDAP attribute> => <Output attribute name in Hash> # @return [Hash] Single users LDAP record, with just the attributes requested def get_user_attributies(ldap:, upi:, attributes:) response = {} filter = Net::L...
true
76fea3fb9d2eae068a50f5cf72914ee42b2dfd8e
Ruby
prodoelmit/flightsearch
/app/models/airport.rb
UTF-8
1,287
2.859375
3
[]
no_license
require 'net/http' class Airport attr_accessor :code, :name, :cityCode, :cityName, :countryCode, :countryName, :latitude, :longitude, :stateCode, :timeZone def initialize(obj = nil) unless obj.nil? self.code = obj["airportCode"] self.name = obj["airportName"] self.cityCode = obj["cityCode"]...
true
aaa8862627e5d9c73b813767e35853e4fb08f7c2
Ruby
ieric01/Weather-Command-Line
/app/models/output.rb
UTF-8
311
2.71875
3
[]
no_license
class Output def self.print_help_menu puts "☀︎ Type 'search' to search" puts "☀︎ Type 'history' to see your search history" puts "☀︎ Type 'help' to view this menu again" puts "☀︎ Type 'exit' to exit" end # def self.print_city_name # puts "Enter your city:" # end end
true
9498dcad7d8e5dbbe9a754d55bce55659d21a23e
Ruby
railsbridge/bridge_troll
/app/models/level.rb
UTF-8
979
2.5625
3
[ "MIT" ]
permissive
# frozen_string_literal: true class Level < ApplicationRecord COLORS = %w[blue green gold purple orange pink].freeze default_scope { order(:num) } belongs_to :course, optional: true validates :num, presence: true, inclusion: { in: (1..5), message: 'Mu...
true
683ad7467f13c308793c706e2f02bbe1077452a8
Ruby
ptotem/LHC
/lib/tasks/import_users.rake
UTF-8
1,386
2.5625
3
[]
no_license
namespace :data do desc "import data from files to database" task :import_users => :environment do users_array = ["Nilesh", "Deepak", "Rakesh", "Swapnil", "Amol", "Rushabh", "Sachin", "Satya"] gender_array = [true, false] smoking_demographic_array = ["Never", "Often", "Socially"] drinking_demograp...
true
4b29b2aa8f175bca744767ab2491448c6384db52
Ruby
jonnybl915/parsing_with_ruby
/method_args.rb
UTF-8
674
3.265625
3
[]
no_license
class MyFile def self.write(to_file, contents) puts "path is #{to_file}, contents is #{contents}" end #Mirroring CSV foreach def foreach(path, headers: false, other: 15, req:) puts "path=#{path}, headers=#{headers}, other=#{other}, req=#{req}" end end f = MyFile.new f.foreach('asdf') f.foreach('asd...
true
bc7ad3034defec4b1ac0084c13ef8b3d3494fe3d
Ruby
alu0100622492/prct11
/lib/prct07/simple_expec.rb
UTF-8
903
3.125
3
[ "MIT" ]
permissive
#===Class SimpleExpec #* def initialize, def to_html, def <=, def >=, def to_s require 'pry' module Prct07 class SimpleExpec < Prct07::Preg attr_accessor :verd, :distractor def initialize(args) super(args[:text]) @verd = args[:verd] raise ArgumentError, 'Specify :right' unless @verd @distractor = args[:...
true
a49c1bcd4fb966367373e109b645816a8f1c5dc4
Ruby
dz-s/zold
/lib/zold/node/farm.rb
UTF-8
4,623
2.640625
3
[ "MIT" ]
permissive
# Copyright (c) 2018 Yegor Bugayenko # # 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 without limitation the rights # to use, copy, modify, merge, publish, dis...
true
56e1032de4f5e064f4817b710f9dc57f931226a5
Ruby
iulia0103/example
/shop/category.rb
UTF-8
170
2.625
3
[]
no_license
require "./product" class Category attr_accessor :name attr_accessor :products def initialize(name, products) @name = name @products = products end end
true
4fa5e5749682f032b4f74c8f4d695fed2ea18f6e
Ruby
mhcrnl/2017
/Ruby/Actiuni/sanatate.rb
UTF-8
895
3.28125
3
[]
no_license
#!/usr/bin/ruby -w class Sanatate @@inregistrare = 0 # attr_accessor - citeste si scrie variabilele din classa attr_accessor :nume, :prenume, :data, :greutate #...........................................Constructor def initialize(nume, prenume, data, greutate) @nume = nume @prenume = prenume @data = data ...
true
21aa4efebf2a2df3bf85319fa87ab845af61d5e4
Ruby
Uzmani/uslloyd_url_shortener
/app/models/url.rb
UTF-8
532
2.5625
3
[]
no_license
class Url < ActiveRecord::Base validates :short_url, uniqueness: true validates :long_url, format: { with: /http.?:\/\/.*/, message: "only URLs starting with http:// or https://" } validates :long_url, presence: true before_save :generate_short_url def generate_short_url until false # range = [...
true
d0c8136c7fcaba9a31d9e54573bb90c356c70512
Ruby
codesthq/cody_the_game
/app/services/submission_authorizer.rb
UTF-8
379
2.625
3
[]
no_license
class SubmissionAuthorizer class SubmissionUnauthorized < StandardError; end attr_reader :current_session def initialize(current_session) @current_session = current_session end def authorize!(submission) raise SubmissionUnauthorized unless authorized?(submission) end def authorized?(submission...
true
ebfaf6ca77e23d660d8fcd33c56d5e1705987b43
Ruby
kevinortizfis/regex-lab-online-web-sp-000
/lib/regex_lab.rb
UTF-8
388
3.203125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def starts_with_a_vowel?(word) word.match?(/\b[aeiou]/i) end def words_starting_with_un_and_ending_with_ing(text) text.scan(/\w+ing/) end def words_five_letters_long(text) text.scan(/\b\w{5}\b/) end def first_word_capitalized_and_ends_with_punctuation?(text) text.match?(/[A-Z]\w+(\b\S\s)/) end def valid_ph...
true
a936061d6f7c4d1d67e0370eecb67c429ad39499
Ruby
cielavenir/procon
/codeeval/tyama_codeeval65_stage2.rb
UTF-8
185
2.890625
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby #pipe from tyama_codeeval65_stage1.c h={} while gets h[$_.chomp]=1 end puts '#!/usr/bin/ruby' print 'h=' p h puts 'while gets do puts h[$_.chomp] ? "True" : "False" end'
true
65b9d9efab4fece7f176a5e900d2d0275812c529
Ruby
IsaacVerm/gouden_11
/requests/player_request.rb
UTF-8
4,311
2.859375
3
[]
no_license
require_relative './request' require_relative '../payload_builder/player_payload_builder' require_relative '../models/player' class PlayerRequest < Request PLAYER_VALUES_XPATH_IND = {:price => "4", :goal => "5", :assist => "6", :...
true
9188b204366896f4b396c01dd4577419338a7689
Ruby
J2525/ruby-aoj
/itp1/itp1_2_A.rb
UTF-8
142
3.328125
3
[]
no_license
def compare(a, b) return "a < b" if a < b return "a > b" if a > b "a == b" end x, y = ARGV[0].to_i, ARGV[1].to_i puts compare(x, y)
true
87063183b0f0788238167f32690076677c64ad4c
Ruby
Montedeveloppino/THP_WK_DAY_2
/lib/exo_01.rb
UTF-8
125
3.234375
3
[]
no_license
arr = [1, 2, 3, 4, 5, 6, 7, 9, 10] while i < 10 for i in 0..10 do |a| a % 3 == 0.true? end end puts arr
true
0a61758a1549082c85818fa62f062ab732a9b2f4
Ruby
thyonline/study
/yin/rubysonar-master/tests/inheritance.test/test1.rb
UTF-8
204
3.484375
3
[ "BSD-3-Clause" ]
permissive
class A def initialize @x = 42 end attr_accessor :x end o1 = A.new puts o1.x class B < A def initialize super @y = 43 end attr_accessor :y end o2 = B.new puts o2.x puts o2.y
true
c026e5342241ff3cb988676ffd1d24d57b8947a4
Ruby
stanbond/App-Academy-Bootcamp
/W7D2_RUBY/anagrams.rb
UTF-8
1,435
3.65625
4
[]
no_license
def first_anagram(string, target) chars = string.split("") combos = permutations(chars) combos.map! { |combo| combo.join } combos.uniq! combos.include?(target) end def permutations(arr) return [arr] if arr.length == 1 perm = [] first_value = arr.first rem = permutations(arr.drop(1)) (0..arr.length ...
true
6fb07630b45ab209c6bef7f48ba7bbdf72c0e1e4
Ruby
ritchiea/AiOP
/aiop.rb
UTF-8
1,437
2.6875
3
[ "MIT" ]
permissive
require 'twitter' #require 'dotenv' class TwitterClient attr_accessor :data, :results def initialize #Dotenv.load @client = Twitter::REST::Client.new do |config| config.consumer_key = ENV['CONSUMER_KEY'] config.consumer_secret = ENV['CONSUMER_SECRET'] end end def search(di...
true
ae7e399fc0b31ac5872e357ddb110bb5a99ee7ac
Ruby
joestephens/bank_tech_test
/lib/printer.rb
UTF-8
882
3.859375
4
[]
no_license
class Printer def self.output(statement) puts("date || credit || debit || balance") balance = 0 output = [] statement.transactions.each do |transaction| date = transaction[0] amount = transaction[1] balance += amount output << [date, credit(amount), debit(amount), format(ba...
true
85b36fe7b14e910c0aefbd9283c20e7a6176039f
Ruby
ckolderup/botter-heaven
/bots/fifty-shades/app.rb
UTF-8
2,623
2.6875
3
[]
no_license
require 'tempfile' require 'twitter' require 'tempfile' require 'rmagick' require 'ostruct' require 'discordrb/webhooks' require_relative '../../lib/options' require_relative '../../lib/mastodon' require_relative '../../lib/env' include Magick Options.read mastodon = MastodonPost.new('https://botsin.space', Env['MAS...
true
54a81a4c3db6b8d3aa7dda6eb645f1e6a3fe3512
Ruby
Hughes0687/Backend
/task_manager2/lib/taskmanager.rb
UTF-8
1,146
2.65625
3
[]
no_license
require 'pg' module TM class DB def initialize @db = PG.connect(host: 'localhost', dbname: 'task_manager_db') end def self.db @__db__ ||= DB.new end end end require_relative 'taskmanager/task.rb' require_relative 'taskmanager/project.rb' require_relative 'taskmanager/client.rb' ...
true
5ae062a6bffd324067ee1851b5ade93ee359637c
Ruby
Adrianrp/jt_3
/app/helpers/static_pages_helper.rb
UTF-8
171
2.578125
3
[]
no_license
module StaticPagesHelper # Receives a Image hash and returns the URL of that image def give_me_image(image) image.each do |image| return image.image end end end
true
9aac8b949787671efb7f82e236610b701b02b366
Ruby
saceandro/info_science
/src/4th/ex06.rb
UTF-8
1,388
2.6875
3
[]
no_license
#!/usr/bin/env ruby $hanoi_0__ = "" $hanoi_1__ = "from A to B; " $hanoi_2__ = "from A to C; from A to B; from C to B; " $hanoi_3__ = "from A to B; from A to C; from B to C; from A to B; from C to A; from C to B; from A to B; " $hanoi_4__ = "from A to C; from A to B; from C to B; from A to C; from B to A; from B to C; ...
true
ce49db4ef5212eb23f8d01ceca603a7b1235909c
Ruby
momchianev/test
/study/30.rb
UTF-8
118
3
3
[]
no_license
# for from 0 .. 50 for n in 0 .. 50 do print n b = gets if b.to_i != n**2 break end end
true
269e4eaf7697ea4812e2da13a554d4d8eeffce3d
Ruby
Melrt/rails-mister-cocktail
/db/seeds.rb
UTF-8
1,296
2.609375
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
efb38497a45659f5d661d2056fa1d91588daa2f5
Ruby
sonikishan/RubyMonk
/length_finder.rb
UTF-8
306
3.6875
4
[]
no_license
def length_finder(input_array) l_array = [] input_array.each do |index, value| l_array << v.length end return l_array end def length_finder1(input_array) input_array.map { |value| value.length } end p length_finder1(['I','am','genius']) p length_finder1(['things','are','','awesome'])
true
99923881aaa68937ccc7c9a67e7fdd1ca0397676
Ruby
f1nesse13/SQL-Notes
/ORM/plays_ORM.rb
UTF-8
3,073
3.65625
4
[]
no_license
require 'singleton' # assures we only have one instance of our DB at any one time require 'sqlite3' class PlayDBConnection < SQLite3::Database include Singleton def initialize super('../SQL models/plays.db') # calls our Parent method and passes our DB file in self.type_translation = true # mak...
true
c083f59d79ae5f42810ce7620aff6efe03d91945
Ruby
KG700/ruby-kickstart
/session1/challenge/6_string.rb
UTF-8
657
4.5625
5
[ "MIT" ]
permissive
# You'll get a string and a boolean. # When the boolean is true, return a new string containing all the odd characters. # When the boolean is false, return a new string containing all the even characters. # # If you have no idea where to begin, remember to check out the cheatsheets for string and logic/control # # od...
true
0731093b1595138617ed0451bcf58ac32444ba94
Ruby
Shuotong/sp15-hw2
/app/controllers/concerns/foobar.rb
UTF-8
185
3.25
3
[]
no_license
class Foobar def self.baz(list) l = [] for x in list l.push(x.to_i + 2) end l = l.select {|x| x%2==0} l = l.uniq l = l.delete_if{|num| num > 10} l.inject(:+) end end
true
4e909d537d5ac6d124278213346987f86f76576b
Ruby
Spin42/comptaline
/lib/comptaline/exporter.rb
UTF-8
982
2.90625
3
[ "MIT" ]
permissive
module Comptaline class Exporter def initialize @entries_buffer = [] end def concat(entries) @entries_buffer.concat(entries) end def push(entry) @entries_buffer.push(entry) end def flush!(options = {}) return "" unless @entries_buffer.size > 0 csv = CSV.ge...
true
6442f5dd8352e465cd3ea36c2808e609816d65d4
Ruby
jeffnv/aa_work
/w1/W1D2/classes/ttt/board.rb
UTF-8
1,989
3.765625
4
[]
no_license
class Board attr_reader :game_rows def initialize @game_rows = [[:b, :b, :b],[:b, :b, :b],[:b, :b, :b]] end def mark(coord, mark) @game_rows[coord[0]][coord[1]] = mark end def space_blank?(coord) @game_rows[coord[0]][coord[1]] == :b end def display @game_rows.each do |row| p ro...
true
871c0757c8c7c2c76c6b24a0bf816f96b0b5394d
Ruby
nicinabox/boxcar
/lib/boxcar/command/base.rb
UTF-8
3,173
2.59375
3
[ "MIT" ]
permissive
require 'yaml' require 'gabba' require 'boxcar/helpers' class Boxcar::Command::Base attr_reader :args attr_reader :options def initialize(args=[], options={}) @args = args @options = options analytics = YAML.load_file("#{Boxcar::App.settings.root}/analytics.yml") @gabba = ::Gabba::Gabba.new(ana...
true
892cdff2c5caf05f47e92be16ba2425448f75bd5
Ruby
natigajardo/Unidad-2-introduccion-a-ruby
/unidad2/desafios clase 2/desafios parte 2/patrones.rb
UTF-8
2,030
3.78125
4
[]
no_license
n = ARGV[0].to_i def letra_o(n) #arriba n.times do print "*" end print "\n" #medio (n - 2).times do print "*" (n - 2).times do print " " end print "*" print "\n" end #abajo n.times do print "*" end print "\n" end print "\n\n" # IDEA: Letra I def letra_i(n) ...
true
2ba2fc7d6dff6ab67b23dcc38aa860952c19f5a3
Ruby
zerowidth/golem
/lib/golem/client.rb
UTF-8
925
2.796875
3
[ "MIT" ]
permissive
module Golem class Client < EM::Connection def self.proxy(host, port, server_host, server_port) EM.run do puts "listening for connection on #{host}:#{port}" EM.start_server(host, port, self, server_host, server_port) trap("TERM") { EM.stop } trap("INT") { EM.stop } en...
true
d8c2cdc87770e4ef54cd9a9489752374c7081dca
Ruby
yona523/web_app
/janken.rb
UTF-8
838
4.125
4
[]
no_license
def janken puts "最初はグー、じゃんけん..." puts "[0]:グー\n[1]:チョキ\n[2]:パー" player_hand = gets.to_i #自分の手の数値を入力 if player_hand < 0 || 2 < player_hand then puts "無効な値です" return true end program_hand = rand(3) #ランダムに数値が返される jankens = ["グー", "チョキ", "パー"] puts "あなたの手:#{jankens[player_hand]}, わたしの手:#{jankens[p...
true
a3cca49b154b6a546d3fd8156b44475e17fa94c3
Ruby
bertolami/programming_challenges
/tower_of_basel/tower_of_basel.rb
UTF-8
4,140
3.234375
3
[]
no_license
#/usr/bin/ruby def log string puts "- #{string}" end class Block attr_reader :x, :y, :z def initialize(x, y, z) @x = x ; @y = y; @z = z end def Block::positionable_blocks x,y,z set = [] set << block_with_x_larger_than_y(x, y, z) set << block_with_x_larger_than_y(x, z, y) set << b...
true
d26843237cf210cabc450e65a3567ea4ae65219b
Ruby
Bohurtadop/Mock-Nequi-Project
/Ruby Files/GoalsMenu.rb
UTF-8
2,208
2.671875
3
[]
no_license
load 'GoalsGraphics.rb' load 'GoalsDatabase.rb' load 'InputMenu.rb' class GoalsMenu def initialize @goalsGraphics = GoalsGraphics.new @DB = GoalsDatabase.new @input = InputMenu.new end def goalsMenu(data) @DB.updateStatusGoals @accountId = @DB.getAccountId(data) @fullname...
true
1ba68ed50682a9fdfb65fff6634cbd67215f80fc
Ruby
joaovic030/RoR
/lexico.rb
UTF-8
1,481
3.625
4
[]
no_license
# - identificadores (padrão descrito no slide 06) # - palavra reservada: if # - comentários (padrão descrito no slide 11) # - operador de atribuição: = # - operadores aritméticos: +, -, *, / # - parêntes: ( ) # - chaves: { } # - operadores relacionais (padrão descrito...
true
6ae22531850aa23c8392e74e6d8765c8c71e8dcc
Ruby
katomanzu0923/furima_29339
/spec/models/user_spec.rb
UTF-8
3,975
2.625
3
[]
no_license
require 'rails_helper' describe User, type: :model do before do @user = FactoryBot.build(:user) end describe 'ユーザー新規登録' do context '新規登録がうまくいくとき' do it 'nicknameとemailとpasswordと、lst_nameとfirst_name、last_name_kanaとfirst_name_kana、birth_dayが存在すれば登録できる' do expect(@user).to be_valid end ...
true
d7ed2ad451a16db1198e5904f3dc056bef40b312
Ruby
drincruz/ruby_appointment_scheduler
/app/controllers/appointments_controller.rb
UTF-8
2,387
2.8125
3
[ "MIT" ]
permissive
class AppointmentsController < ApplicationController require 'set' def create return ok_response("Error scheduling an appointment, time slot is unavailable") if unavailable? @appointment = Appointment.create!(clean_params) success_response("Successfully created appointment", :created) rescue Standar...
true
66f4c110bbb45384d77cb9617d9f7cf3aec49611
Ruby
zmyao88/yelpClone
/spec/models/review_spec.rb
UTF-8
3,222
2.546875
3
[]
no_license
require 'spec_helper' describe Review do context "associations" do it { should belong_to(:user) } it { should belong_to(:business) } it { should have_many(:photos) } it { should have_many(:business_features) } it { should have_many(:review_votes) } it { should have_many(:votes) } it { should have_ma...
true
517fa58001592691fd7c5cd489bf799a6ab8555d
Ruby
austinbourdier/blogosphere
/db/seeds.rb
UTF-8
606
2.5625
3
[]
no_license
require_relative '../app/models/post' require_relative '../app/models/tag' require_relative '../app/models/user' require 'faker' 5.times do User.create({username: Faker::Name.name, password: 'password',logged_in: false}) end 10.times do Post.create({title: Faker::Company.catch_phrase, content: Faker::L...
true
0220c8bdd568f3bee0a267585958ebff563a71b4
Ruby
RubyCamp/rc2015s_g2
/defence.rb
UTF-8
1,888
2.953125
3
[]
no_license
require 'dxruby' require_relative 'ev3/ev3' class Carrier #インスタンス変数 LEFT_MOTOR = "A" RIGHT_MOTOR = "D" CENTOR_ARM = "B" PORT = "COM3" wheel_motors = [LEFT_MOTOR,RIGHT_MOTOR] #アクセサメソッド attr_reader :distance #初期化 def initialize @brick = EV3::Brick.new(EV3::Connections::Bluetooth.new(PORT)) @brick.connec...
true
07266b471d1b79411391a22be043330a7c828e7c
Ruby
krazyito65/Advent-Of-Code
/2019/8.rb
UTF-8
789
2.734375
3
[]
no_license
# frozen_string_literal: true require_relative 'util/shared_functions.rb' input = get_string(File.absolute_path(__FILE__)) input = format('%05<n>d', n: input).scan(/\d/).map!(&:to_i) layers = [] dimensions = 25 * 6 layers.push(input.shift(dimensions)) until input.empty? zeros = [] image = Array.new(dimensions, 2) ...
true
57de8e2668f1d9007a33ce4273af821c71d63d32
Ruby
mindaslab/ilrx
/send.rb
UTF-8
140
3.5
4
[]
no_license
class Person attr_accessor :name def speak "Hello I am #{@name}" end end p = Person.new p.name = "Karthik" puts p.send(:speak)
true
e421abd37f306147361e1ed2abf450d7bdad578c
Ruby
innervisions/RB130
/01_blocks/each.rb
UTF-8
151
3.609375
4
[]
no_license
def each(array) idx = 0 while idx < array.size yield(array[idx]) idx += 1 end array end each([1, 5, 'hello', 'guy']) { |el| puts el }
true
388bbf149d76e22b773b5d16976f46f01ba93f85
Ruby
evillarbarrera/marvelproject
/app/models/battle.rb
UTF-8
943
2.703125
3
[]
no_license
class Battle < ApplicationRecord belongs_to :people , optional: true belongs_to :characters , optional: true after_save :update_person_point def self.resultado random_boolean = [true, false].sample end def self.fecha fecha = Time.now.to_date end def self.getCharacterBattle personaje = Battle....
true
b13344b1ff8ce2ddcbb7a6cfe782f97b1d81955c
Ruby
oscos/launch_school
/rb100/intro_ruby_round_two/flow_control/ex02.rb
UTF-8
522
3.9375
4
[]
no_license
# Launch School - Intro to Ruby # Flow Control - ex02.rb # Answered On 07/20/2020 # Resources: https://www.rubyguides.com/2015/03/ruby-random/ def generate_code(number) charset = Array('A'..'Z') + Array('a'..'z') Array.new(number) { charset.sample }.join end def name_upcase(name) name.length > 10 ? name.upca...
true
5296ffcfa6fa851231a4e8f47cf158a857a0c459
Ruby
Dmitry173/1_lesson
/triangle.rb
UTF-8
628
3.828125
4
[]
no_license
puts "Введите первую сторону треугольника" a = gets.chomp.to_f puts "Введите вторую сторону треугольника" b = gets.chomp.to_f puts "Введите третью сторону треугольника" c = gets.chomp.to_f sides = [a, b, c] gipotenuza = sides.max sides.delete(gipotenuza) katet = sides if c == a && c == b pu...
true
ba1e673c58bf2f0d371be0b3e82c666bf3c5f1ea
Ruby
lsegal/ruby_correct
/examples/ruby_esc/array.rb
UTF-8
818
2.921875
3
[]
no_license
# @local [Array<Fixnum>] x def array_test x = [] assert x.size == 0 assert x[0] == nil x.push 1 assert x.size == 1 assert x[0] == 1 assert x[1] == nil x.pop assert x.size == 0 end def array_test2 x = [] assert x.size == 0 x.push 1 assert x[0] == 1 assert x.size == 1 x.push 2 assert x[0]...
true
a5df6bfcb5d54363e9beab11e14240edd2660b13
Ruby
victorarias/primes-multiplication-table
/lib/multiplication_table.rb
UTF-8
478
2.921875
3
[]
no_license
require "multiplication_table/times" require "multiplication_table/renderer" class MultiplicationTable DEFAULT_NUMBER_OF_PRIMES = 10 def self.render(primes) MultiplicationTable.new(primes).render end def initialize(primes) @primes = primes end def header primes end def calculate @ca...
true
46f26c11669c3922138e0937a32aa06e878c1f04
Ruby
csaden/rbnd-toycity-part4
/lib/analyzable.rb
UTF-8
627
3.171875
3
[]
no_license
require_relative 'count_by' module Analyzable create_count_by_methods "brand", "name" def average_price products (products.inject(0){|sum, product| sum + product.price.to_f}/products.size).round(2) end def print_report products out = "Average Price: $#{average_price products}\n" out += "Inventory...
true
789abaf3944a7e7777a4ba7f27c63d1f5e5b2816
Ruby
robert-damoc/Advent-of-Code
/2015/day1.rb
UTF-8
391
3.53125
4
[]
no_license
file = open 'input1' $input = file.read.gsub("\n", '') file.close def f1 output = 0 $input.split('').each do |c| output += 1 if c == '(' output -= 1 if c == ')' end puts output end def f2 output = 0 $input.split('').each_with_index do |c, i| output += 1 if c == '(' output -= 1 if c == '...
true
3fa6891ec8e1dbccdf1688ce75a98537325f6f9a
Ruby
swiftype/low_card_tables
/lib/low_card_tables/low_card_table/row_manager.rb
UTF-8
36,105
2.515625
3
[ "MIT" ]
permissive
require 'active_support' require 'activerecord-import' require 'low_card_tables/low_card_table/cache' require 'low_card_tables/low_card_table/table_unique_index' require 'low_card_tables/low_card_table/row_collapser' module LowCardTables module LowCardTable # In many ways, the RowManager is the beating heart of ...
true
22d9d0970d578f6dc53637c44b719d760e179d75
Ruby
rodolfobandeira/ruby-studies
/sorting_hash_group/shot_version.rb
UTF-8
270
2.78125
3
[]
no_license
require 'byebug' my_hash = { 'category' => 'clothes', 'size' => { 'L' => 5, 'M' => 10, 'S' => 9, 'EXTRA' => 88, 'XL' => 1, 'XS' => 4 } } correct_size_order = %w(XS S M L XL) byebug puts correct_size_order
true
0014ef5902de991f71960cb6dcddfe9213821933
Ruby
benben/gc_stat
/generate.rb
UTF-8
1,496
2.71875
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'gruff' require 'nokogiri' gpx_files = Dir.new(".").entries.reject!{|name| !(name =~ /(\.gpx)/)} data = {} def cleanup_namespaces(xml) protected_ns = %w( soapenv ) xml.traverse do |el| next unless el.respond_to? :namespace if (ns=el.namespace) && !...
true
06d010b52df5e258c716ec6f035189398563ae63
Ruby
LearnCo-humdrum/array-CRUD-lab-001-prework-web
/lib/array_crud.rb
UTF-8
668
3.984375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def create_an_empty_array return array = [] end def create_an_array return array = ["Jenna", "Marie", "Rajani", 27] end def add_element_to_end_of_array(array, element) return array.push(element) end def add_element_to_start_of_array(array, element) return array.unshift(element) end def remove_element_from_e...
true
76df799dc5d03d82d6089a1745395dbda65af9a0
Ruby
zakkoltun/launch_school_prep
/loops/ex3.rb
UTF-8
128
3.375
3
[]
no_license
x = ["zero", "one", "two", "three"] x.each_with_index do |value, index| puts "index: " + index.to_s + ", value: " + value end
true
23cdfcfbb0aa391806225f475140a08da12cd226
Ruby
yswallow/atcoder
/14/takoyaki.rb
UTF-8
48
3.21875
3
[]
no_license
num = gets.to_i puts num%2==0 ? "Blue" : "Red"
true
4383f159254876c10bd00ae8f6c619646e219f38
Ruby
rbUUbr/rubizza-slides
/examples/bad_code_example.rb
UTF-8
738
3.875
4
[]
no_license
# service object without state holding class MakeGreet def self.call puts 'I made super greet!' end end MakeGreet.call # => I made super greet! # service object that contains some logic class RecalculateArray attr_accessor :numbers_array def self.call(numbers_array) new(numbers_array).call end d...
true
05662fb5bded6fb23b10742665d17018a517d43a
Ruby
rock-doves-2014/Flash-Cards
/source/model.rb
UTF-8
1,378
3.625
4
[]
no_license
require "pry" #==========================PARSER======================= require "csv" module CSVParser def import(file) CSV.read(file, headers:true, header_converters: :symbol).map {|row| row.to_hash} end def export(filename, data) CSV.open(filename, 'wb') do |csv| csv << data.first.keys da...
true
002343245a8dd01c783e449783d20e6acac7a014
Ruby
jmromer/vendtriloquist
/app/menus/application_menu.rb
UTF-8
1,778
2.859375
3
[]
no_license
# coding: utf-8 # frozen_string_literal: true require "readline" class ApplicationMenu def initialize(source: nil, decorator: nil, printer:) self.decorator = decorator self.out = printer self.source = source self.selected_option = [] self.input = nil end def read loop do raise Ret...
true
92f7f418608f75270ca6831c888f08d7fd0b8c16
Ruby
fugumagu/the_odin_project
/substrings/substrings.rb
UTF-8
392
3.75
4
[]
no_license
def substrings(phrase, dictionary) word_tally = Hash.new low_phrase = phrase.downcase dictionary.each do |w| count = low_phrase.scan(w).length word_tally[w] = count if count > 0 end puts word_tally end dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","s...
true
ab2107658010bb8cf15061650ad2316bd181594f
Ruby
dendiflet/thp_s1_j
/lib/03_stairway.rb
UTF-8
1,560
3.625
4
[]
no_license
$arrayresultats = [] #sinitialisation de l'array chaque valeur est : nombre de lancés pour arriver a la marche 10 def initialisation $position_actuelle = 0 $nbdd = 0 #test # puts $position_actuelle # puts $nbdd end def jetde rand(1..6) end def montee $position_actuelle = $position_actuelle + 1 puts " ...
true
ed4079deb199e64db0e5ab18b08768a2e6b6d4c2
Ruby
scliff6262/vending
/app/models/Inventory.rb
UTF-8
707
2.546875
3
[ "MIT" ]
permissive
class Inventory < ApplicationRecord belongs_to :product belongs_to :machine validate :product_quantity_cannot_exceed_its_limit validate :machine_cannot_have_over_six_different_products def product_quantity_cannot_exceed_its_limit limit = self.product.limit quantity = self.class.where(product_id: self...
true
c2294dabb2fbecfef3b01d8481512a0b3e08f901
Ruby
oojewale/genie-api
/db/seeds.rb
UTF-8
740
2.53125
3
[]
no_license
class Seed def create_staff 5.times do |staff| staff = Staff.new staff.name = Faker::Name.name staff.email = Faker::Internet.email staff.phone = Faker::PhoneNumber.phone_number staff.save end end def create_user 5.times do |staff| user = User.new user.firstna...
true
1f4ee821eed47b990e29660c4955a3a9a9dc5c28
Ruby
reillywj/170_subscription_manager
/html_helper.rb
UTF-8
488
3.140625
3
[]
no_license
module HTML class Tag attr_reader :tag, :text def initialize(tag, text = '', attributes = {}) @tag = tag @attributes = attributes @text = text end def attributes return_string = '' @attributes.each do |key, value| return_string += " #{key}='#{value}'" end ...
true
128d154e95cfee16c92c844b353436008aa41613
Ruby
Marta2909/Camp2018
/zadanie 1/lib/to_do_list_element.rb
UTF-8
295
2.734375
3
[]
no_license
module ToDo class ToDoListElement def [](number) case number when 0 @title when 1 @status end end def []=(number, value) case number when 0 @title = value when 1 @status = value end end end end
true
fc074cc06e86f11a8431b9e32849a26b98385cb3
Ruby
jasonpgignac/active_wmi
/lib/active_wmi/base.rb
UTF-8
30,992
2.765625
3
[]
no_license
require 'active_wmi/connection' require 'cgi' require 'set' module ActiveWmi # ActiveWmi::Base is the main class for mapping Windows WMI resources as # models in a Rails application. # == Mapping # # Active WMI objects represent your WMI resources as manipulatable Ruby # objects. To map resources to Ruby...
true
8b2c7b0001a0cce6f9ee6d34202087670c120d8c
Ruby
AyedhSh/ruby-music-library-cli-re-coded-000
/lib/Song.rb
UTF-8
1,122
2.953125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song extend Concerns::Findable attr_accessor :name, :artist, :genre @@all = [] def initialize(name, artist = nil, genre = nil) @name = name self.artist = artist if artist self.genre = genre if genre end def self.all @@all end def self.destroy_all self.all.clear end def save @@all << self end def self.create...
true
ec539e1896a966d2c1424799a09065c46651faa1
Ruby
musik/ndrc
/app/models/city.rb
UTF-8
627
2.65625
3
[]
no_license
# -*- encoding: utf-8 -*- class City < ActiveRecord::Base attr_accessible :name, :province_id, :level, :zip_code, :pinyin, :pinyin_abbr belongs_to :province has_many :districts, dependent: :destroy def short_name @short_name ||= name.gsub(/市|自治州|地区|特别行政区/,'') end def brothers @brothers ||= City...
true
c06dbe4a44df694e3b9ac9b2ad54e36eeb431332
Ruby
Dom-Mc/ruby-inheritance-lab-v-000
/lib/student.rb
UTF-8
170
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Student < User attr_accessor :knowledge def initialize @knowledge = [] end def learn(type_of_knowledge) knowledge << type_of_knowledge end end
true
a59a1ea5e780081a3a7588a6e5b9dd5bc83453a2
Ruby
LeDeep/blackjack2
/lib/deck.rb
UTF-8
418
3.375
3
[]
no_license
class Deck def initialize @cards = (0..51).to_a.shuffle.collect { |id| Card.new(id) } end def hit @cards.pop end def deal(house, players) (1..2).each_with_index do |index| players.each {|player| player.add_card_to_hand(self.hit)} if index == 2 house.add_card_to_hidden(self...
true
9fb774bce0ed2e70d0a6cf04bb5c011dd9f037b8
Ruby
shakeelrauf/island_dropper
/app/controllers/concerns/query_builder.rb
UTF-8
2,660
2.5625
3
[]
no_license
module QueryBuilder def build_query(dropoff, pickup, items) items_r = resonse_items(items) query = { "apiKey": ENV["GETSWIFT_API_KEY"], "booking":{ "pickupDetail": { "name": "#{pickup.first_name.to_s } "+ "#{ pickup.last_name.to_s}",...
true
6ea8cd62545b916cf3179bf1512157db7803d7d6
Ruby
shinokada/ioi-jp
/2014/2014-ho/problem2014-practice/lib/darts.rb
UTF-8
277
2.71875
3
[]
no_license
class Darts def self.maxpoint(file_name) file = File.new(file_name, 'r').each_line.map(&:strip) n, m = file.shift.split.map(&:to_i) file.map(&:to_i).repeated_combination(n).to_a.map{ |e| e.inject(:+) }.sort .reject{ |e| e > m } .pop end end
true