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
7a660cb7f648a0cda27b125e62b73912cbb9c62f
Ruby
kryzhovnik/backup_kr
/lib/runner.rb
UTF-8
1,398
2.5625
3
[]
no_license
class Backup class Runner attr_reader :notifier, :storage def initialize(setup) @setup = setup @notifier = @setup.notifier.new @storage = @setup.storage.new end def run @dir = prepare_dir run_databases run_archives @compressed = run_compression save_to...
true
d3c78236bb99d38d2c92c0f80cbf90024a9cfc76
Ruby
junInUK/tour_agency_week5_project
/models/booking.rb
UTF-8
1,481
3.3125
3
[]
no_license
require_relative("../db/sql_runner.rb") class Booking attr_reader :id attr_accessor :tour_id, :tourist_id, :booking_date def initialize(booking) @id = booking['id'].to_i if booking['id'] @tour_id = booking['tour_id'].to_i @tourist_id = booking['tourist_id'].to_i @booking_date = ...
true
7dec57f5d685c83cc8dd07f5d57ed3fb7d609886
Ruby
makimoto/exception_notification-fluent_logger_notifier
/lib/exception_notifier/fluent_logger_notifier.rb
UTF-8
1,760
2.640625
3
[ "MIT" ]
permissive
require "fluent-logger" module ExceptionNotifier class FluentLoggerNotifier attr_accessor :logger, :template class ConfigurationError < Exception;end def initialize(options) @template = options.delete(:template) raise ConfigurationError, "`template` key must be set" unless @template l...
true
34f09800919586a9f586a9437f846f2e153bc259
Ruby
lucalan66/ruby-intro
/challenges/ruby/11-simple-substrings/my_solution.rb
UTF-8
164
2.890625
3
[]
no_license
# Simple Substrings # Tu solucion abajo: def welcome(address) if address.include? 'CA' 'Welcome to California' else 'You should move to California' end end
true
4483e3d45128118f08fd3d82a7a2b548e4217001
Ruby
jubishop/datacache
/lib/datacache.rb
UTF-8
975
2.9375
3
[ "MIT" ]
permissive
require 'concurrent' require 'core' require 'duration' class DataCache attr_reader :timeout def initialize(timeout = 60.seconds) @timeout = timeout @cache = Concurrent::Hash.new @store_times = Concurrent::Hash.new end def fetch(key, value = nil, &block) return @cache.fetch(key) if fresh?(key)...
true
4ba08a5fc581f0c52497a4fd26488d06cbd0f5ff
Ruby
TinQk/THP
/week_0/ruby/exo_11.rb
UTF-8
124
3.296875
3
[]
no_license
puts "Salut, donne moi un nombre pas trop grand ;)"; nb = Integer(gets.chomp); nb.times do puts "Salut, ça farte ?"; end
true
c36cd7c8bd4314d97059651965fa07afc1bdc927
Ruby
cielavenir/procon
/codeeval/tyama_codeeval55.rb
UTF-8
843
3.234375
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby #corpus is changeable corpus=<<EOM Mary had a little lamb its fleece was white as snow; And everywhere that Mary went, the lamb was sure to go. It followed her to school one day, which was against the rule; It made the children laugh and play, to see a lamb at school. And so the teacher turned it out,...
true
992bb504a519085a319cb1a922d8a2c4ecdf5542
Ruby
finleysa/Cal
/cal
UTF-8
1,445
3.421875
3
[]
no_license
#!/usr/bin/env ruby $LOAD_PATH << "lib" require 'zellers' require 'month_convert' require 'month' require 'year' ## Print this month if ARGV.length == 0 month = Time.now.strftime("%m").to_i year = Time.now.strftime("%Y").to_i zeller = Zellers.new(month, year) ## Year method elsif ARGV.length == 1 year = ARGV...
true
f22f2bb35958b2a869c41216914e037017d92baf
Ruby
sophiav/phase-0-tracks
/ruby/gps6/my_solution.rb
UTF-8
5,871
3.84375
4
[]
no_license
# Virus Predictor # I worked on this challenge [by myself, with: Jessica Ellison]. # We spent [1] hours on this challenge. # EXPLANATION OF require_relative # Require is used in an absolute path and require_relative is used to require a file relative to the file we're loading from. require_relative 'state_data' cla...
true
90c2d5967dc99d689dd7df6e4a1ed92f44adf4da
Ruby
sankeerth1/hw-ruby-intro
/lib/ruby_intro.rb
UTF-8
1,097
3.96875
4
[]
no_license
# When done, submit this entire file to the autograder. # Part 1 def sum arr arr.inject(0, :+) end def max_2_sum arr arr.max(2).inject(0, :+) end def sum_to_n? arr, n (0..arr.length-1).any? do |i| arr[i+1..-1].any? { |j| j + arr[i] == n } end end # Part 2 def hello(name) v = "Hello, " + name ...
true
85d48417d859a91d47f1374b3ec830b0bb389af7
Ruby
masonleung/photo-upload-server
/lib/algorithm.rb
UTF-8
2,289
3.15625
3
[]
no_license
require 'RMagick' class Algorithm HI_RESOLUTION = 10000 MED_RESOLUTION = 5000 LO_RESOLUTION = 2500 POOR_RESOLUTION = 1250 GRID_NUMBER = 10 def initialize file @im = ImageList.new file end def calculate_photo_quality grid_sampling end private def grid_sampling height, width = @im.r...
true
a664d30f990997b5f6583680a25659e83b1602f9
Ruby
talhaanees/67-252
/GPA Calculator/controller.rb
UTF-8
1,973
2.78125
3
[]
no_license
require 'sinatra' require_relative 'db.rb' get '/' do redirect to '/home' end get '/home' do db = DBHandler.new @CourseCount = db.count erb :application do erb :home end end get '/add' do erb :application do erb :add end end post '/add' do db = DBHandler.new db.creat...
true
100cac2758cbd58220a395d808d2e633e37fcd4a
Ruby
adamhake/arwen
/lib/arwen/url.rb
UTF-8
1,233
2.703125
3
[ "MIT" ]
permissive
# frozen_string_literal: true class Arwen # Models the sitemap <url> schema definition according the sitemap.org protocol # # @see https://www.sitemaps.org/protocol.html#urldef class Url # @return [string] <loc> schema value attr_accessor :url # @return [string] <lastmod> schema value attr_acc...
true
efa31fc79b7a6510242f9fac934428f75301bc58
Ruby
dryruby/openxr.rb
/lib/openxr/session.rb
UTF-8
1,724
2.515625
3
[ "Unlicense" ]
permissive
# This is free and unencumbered software released into the public domain. require_relative 'api' require_relative 'handle' require_relative 'result' ## # An OpenXR session handle. # # @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#session class OpenXR::Session < OpenXR::Handle extend OpenXR...
true
55bc9a42423a68fd05941240a3a6dbc60e3b15e2
Ruby
soroz30/codewars
/generate.rb
UTF-8
147
3.078125
3
[]
no_license
def generate(length) (1..length).map {|i| rand(2)}.join('') end ############ def generate(length) Array.new(length) { ["0", "1"].sample } end
true
3bd5200c04bce7835b740d171af6c592d250e537
Ruby
ryannamgung/oo-banking-nyc-web-062518
/lib/transfer.rb
UTF-8
1,145
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" class Transfer # your code here attr_accessor :status, :last_amount, :last_sender, :last_receiver attr_writer :count attr_reader :sender, :receiver, :amount def initialize(sender, receiver, amount) @sender = sender @receiver = receiver @amount = amount @status = "pending" @co...
true
458c247e1a64a5d017557a4115d79c254152d702
Ruby
JoshuaHinman/101
/smallProblems/easy8/repeater2.rb
UTF-8
261
3.421875
3
[]
no_license
CONSONANTS = %w(b c d f g h j k l m n p q r s t v w x y z) def repeater(string) double = '' string.split('').each do |ch| double << ch if CONSONANTS.include?(ch.downcase) double << ch end end double end p repeater("This is test #2!")
true
845805fe7dcc520b837ae7e8e235aa0abb3cfe47
Ruby
austbuhl/AR-Environment-Skeleton
/app/models/student.rb
UTF-8
296
2.765625
3
[]
no_license
class Student < ActiveRecord::Base has_many :grade_levels has_many :teachers, through: :grade_levels def full_name "#{first_name} " + "#{last_name}" end def self.all_in_grade(grade) Student.all.select {|students| students.grade_level == grade } end end
true
797b930e1a71f882fa46f5af7914ad67b81afc60
Ruby
greatmaddyave/App-Academy-Challenges
/tutorial/histogram.rb
UTF-8
294
3.703125
4
[]
no_license
puts "Write a string" text = gets.chomp.downcase words = text.split(" ") frequency = Hash.new(0) words.each {|item| frequency[item] += 1 } frequency = frequency.sort_by { |item, amount| item.length} frequency.reverse! frequency.each do |item, amount| puts item + " " + amount.to_s end
true
2abd7ca55ba9035b9a4f445b34836dfb183137c3
Ruby
Arockne/phase-3-enumerables-debugging
/reverse_each_word.rb
UTF-8
293
4.21875
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'pry' #split the string between spaces #reverse each word add it to a new array #join the array of words on a space #return the reversed sentence def reverse_each_word(sentence) sentence.split(' ').map(&:reverse).join(' ') end puts reverse_each_word("Hello there, and how are you?")
true
e7ff176e9423be61ff1858ac1048e79d48688dea
Ruby
rkyadav-ncsu/autometareviews0.1
/unit/automated_metareview/graph_generator_test.rb
UTF-8
10,010
2.8125
3
[]
no_license
require 'test/unit' require 'text_preprocessing' require 'graph_generator' gem 'stanford-core-nlp', '=0.3.0' require 'stanford-core-nlp' require 'ffi/aspell' require 'engtagger' class GraphgeneratorTest < Test::Unit::TestCase attr_accessor :pos_tagger, :core_NLP_tagger, :tc, :instance def setup @pos_tagger =...
true
3658a6f582ec2aa964593dd862056fa9d4f68099
Ruby
at-dypham/class_excercises
/Exersise demo/menu.rb
UTF-8
1,103
3.046875
3
[]
no_license
require_relative 'lib/error.rb' require_relative 'lib/mysql_adapter.rb' require_relative 'service/football_service.rb' require_relative 'menu_block.rb' class Menu attr_accessor :sqladapter include FootballService include MenuBlock def initialize @sqladapter = FootballSQL.new end def show_menu(block=main_menu_...
true
a3b94ca303794ee6b759f9bd9fae0b1e6ecfc9a8
Ruby
kpvarma27/FSHS-app
/app/models/venue.rb
UTF-8
1,634
2.515625
3
[]
no_license
class Venue MANAGED_VENUES_URL = "https://api.foursquare.com/v2/simulate/venues/managed" VENUE_URL = "https://api.foursquare.com/v2/" def self.fetch(user_session) Rails.logger.info "Fetching managed venues from #{MANAGED_VENUES_URL} in as session #id: #{user_session.id}" request = Typhoeus...
true
3e83ceb0e458bce720a176cb00578f92fc21e1de
Ruby
narayana1208/git-review
/lib/git-review/internals.rb
UTF-8
1,125
2.84375
3
[ "MIT" ]
permissive
module GitReview module Internals private # System call to 'git'. def git_call(command, verbose = debug_mode, enforce_success = false) if verbose puts puts " git #{command}" puts end output = `git #{command}` puts output if verbose and not output.empty? ...
true
1bcd251a8fe025e62377905b306a5a528625ae57
Ruby
rleber/bun
/lib/bun/file/unpacked.rb
UTF-8
13,041
2.59375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # -*- encoding: us-ascii -*- require 'date' module Bun class File < ::File class UnknownFileTypeError < RuntimeError; end class UnexpectedTapeTypeError < RuntimeError; end class InvalidInputError < RuntimeError; end class CantExpandError < RuntimeError; end class CantDecodeE...
true
ad2e2bf8932dd88f62f9ef0022fd701dff604245
Ruby
lucasosouza/apps
/Ruby/sentiment analysis/analyzer.rb
UTF-8
407
2.8125
3
[ "MIT" ]
permissive
require 'open-uri' require 'json' API_KEY = "b0242e0e-5ea4-4a35-a5b8-300e01bcaef1" def get_sentiment(sentence) open("https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=#{API_KEY}&text=#{sentence.gsub(' ', '%20')}").read end File.readlines("phrases.csv").each do |line| analysis = JSON.parse get_se...
true
759fbad908ec0188d83745920f9c94b1ccf5a55c
Ruby
rvion/school-mega-repo
/app5-ai-final-project/main.rb
UTF-8
6,556
2.65625
3
[]
no_license
Emplacement = Struct.new(:id, :x, :y) # liste des villes et de leur positions géographiques Route = Struct.new(:l1, :l2, :dist) # liste des routes entre deux nodes l1 et l2 et distance Camion = Struct.new(:id, :emplacement_id) # liste des camions et de leur position initiale Mission = Struct.new(:id, :from, :to) # list...
true
213fa8958dec889bc5908492ee02a8037cfec8d0
Ruby
alepharchives/etl-ruby
/src/lib/etl/integration/engine/dsl/lang/matches_expression.rb
UTF-8
1,713
2.65625
3
[ "LicenseRef-scancode-public-domain" ]
permissive
#!/usr/bin/env ruby require 'rubygems' module ETL module Integration module Engine module DSL module Lang # A regex pattern matching expression class MatchesExpression < Expression def initialize(match_pattern, underlying_expression) validate_arguments(binding()) assign_match...
true
02acc37338d0c2f9216a297326fdee00b070b43c
Ruby
nsharmagrepruby/assignments
/sales_tax/even_odd.rb
UTF-8
235
3.640625
4
[]
no_license
class EvenOdd def initialize(number) @number = number end def is_even? if number % 2 == 0 true else false end end attr_accessor :number end evenodd = EvenOdd.new(4) puts evenodd.is_even?
true
11f00d3fec58e23e279cb5630db556a289c6fb2c
Ruby
zacharydenton/labs.zacharydenton.com
/plugins/processingjs.rb
UTF-8
568
2.625
3
[ "MIT" ]
permissive
# A Liquid tag for Jekyll sites that allows embedding processing.js sketches. # It fetches the script source and embeds it in the page, so you don't have to # worry about cross-site scripting security issues. # # by: Zach Denton # # Example usage: {% processingjs /plasma.pde %} module Jekyll class ProcessingJsTag < ...
true
28f4c9fba766970b50eb1a5e334669450eac14de
Ruby
Maliasdad09/intro-to-tdd-rspec-and-learn-bootcamp-prep-000
/current_age_for_birth_year.rb
UTF-8
53
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def current_age_for_birth_year(age) 2016 - age end
true
384e9cd7f278948d6ad03a7e33456b00ad691a67
Ruby
Kirill-Stulov/RoR_from_zero_dev
/CodeAcademy/OLD/cycle_for_while.rb
WINDOWS-1251
777
3.125
3
[]
no_license
# for , while - # c:\TEMPO\1. Ruby on Rails c (2015) []\ 02. Ruby. 2\ 02. Ruby. 2\ # 00:48:00 range = (1..5) for index in range # index , puts index # index range end ########################################## index = 0 while index < 5 do puts index index += 2 e...
true
f055282b89bd95c6b44c655e5e05e7c33ce6f8cf
Ruby
ky-s/snake_game
/lib/snake_game/key_prompt.rb
UTF-8
1,224
3.296875
3
[]
no_license
require 'io/console' class SnakeGame module KeyPrompt module_function # 入力受付ループをします。 # block を渡して使用します。 # # KeyPrompt.loop do |input| # ... # end # # block には、入力されたキー情報が与えられます。 # # 特殊入力対応 # - Control+c が入力されたらループをやめて停止 # - Arrow Key の入力を変換して返却 # '\e[A' => ...
true
0870cc7364b379c2bb22454b9f2a10a8fc702d63
Ruby
shortboard/mars_rover
/plateau.rb
UTF-8
2,238
4.03125
4
[]
no_license
require_relative 'rover' # Public: The Plateau class contains an array of rovers within it's dimesions. # These can be sent instructions to move around the plateau. # class Plateau # Public: Gets/Sets attributes height, width and rovers attr_accessor :height, :width, :rovers # Public: Initilizer for the plateau cla...
true
2690a9ffe55cbfe80b0275e7c43aa291ac4ab69c
Ruby
KonstantinFaleev/rubyschool
/Projects/lesson6/app13.rb
UTF-8
40
2.625
3
[]
no_license
100000.times { print rand(30..120).chr }
true
6d91e411d00511545a4a9ef7b2c7842e8cd9c038
Ruby
mful/blck_box
/app/services/groups/create_group.rb
UTF-8
3,013
2.625
3
[]
no_license
module Groups # TODO: extract a ContactsCleaner class class CreateGroup def self.create(group, params, current_user) new(group, current_user).create params end def initialize(group, current_user) @group = group @current_user = current_user end def create(params) @cont...
true
56d9bf3e20dd1ef39d3c2e0e559599d819b0e905
Ruby
expectedbehavior/rails_templates
/templates/lib/test_unit_slow.rb
UTF-8
540
3.078125
3
[]
no_license
# -*- coding: utf-8 -*- module Test module Unit class Slow attr_reader :test_name, :message def initialize(test_name, time_taken) @test_name = test_name @time_taken = time_taken @message = "Too Slow" end def single_character_display "☻" end ...
true
3cdaeb549c02e5ce7015fa0b27e59824ad166a4e
Ruby
coalest-zz/launch_school
/rb_101/lesson_6/21.rb
UTF-8
6,020
3.59375
4
[]
no_license
DECK = { '2' => 4, '3' => 4, '4' => 4, '5' => 4, '6' => 4, '7' => 4, '8' => 4, '9' => 4, '10' => 4, 'Jack' => 4, 'Queen' => 4, 'King' => 4, 'Ace' => 4 } VALUES = { '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, '10' => 10, 'Jack' => 10, 'Queen' => 10, ...
true
e6eaa02ba3df1a8763a7c487678a370c2e44a926
Ruby
jdjkelly/GoL
/1.rb
UTF-8
1,209
3.859375
4
[]
no_license
require 'set' class Game def initialize(board, steps) @board, @steps = Board.new(board), steps self.play end def play 1..@steps.times do self.next end @board.to_s end def next @board.next! end end class Cell end class Board def initialize(board) @cells = board e...
true
f2743b2deb03dc41ba1809922a5f4423a7d0d345
Ruby
Brian-Boyd/TheIronYard
/01week-day1/hangman.rb
UTF-8
3,952
4.46875
4
[]
no_license
# Hangman Exercise - Welcome Screen # STEPS: # 1) Load text file with words # 2) Determine the amount of guesses by multiplying word length by 1.7 # 3) Create an array of the alphabet to choose from # 4) Display board with _ for every letter of word # 5) Build an array to store correctly guest letters and replace the ...
true
4aae114da4374a47392388ddfc1168e663a6859a
Ruby
jcasimir/simulating_hardware
/lib/gates/and_multibit.rb
UTF-8
663
3.046875
3
[]
no_license
require './lib/gates/and' module Gates class AndMultibit attr_reader :size attr_accessor :input_a, :input_b include Helpers::Signals def initialize(bit_size) @size = bit_size end def output Helpers::Binary.from_bits output_bits end private def output_bits gate...
true
7f1ee5fc0d8ef0d7a825db47465787c4d38bc884
Ruby
sunitparekh/data-anonymization
/lib/core/fields_missing_strategy.rb
UTF-8
671
2.640625
3
[ "MIT" ]
permissive
module DataAnon module Core class FieldsMissingStrategy include Utils::Logging def initialize table_name @table_name = table_name @fields_missing_strategy = [] end def missing field_name return if @fields_missing_strategy.include? field_name @fields_missi...
true
0a25e23116c62722a6cbec93f0e0497c80630b63
Ruby
boris/legacy
/aws-tools/ecs-bulk_service_delete.rb
UTF-8
757
2.96875
3
[]
no_license
require 'aws-sdk-ecs' require_relative 'profile' class Service def bulk_delete c = Login.new ecs = Aws::ECS::Client.new(region: "#{ENV['region']}", credentials: c.get_credentials) # Set vars service = "" list = Array.new # Ask questions printf "Cluster: " cluster = STDIN.gets.chomp printf "\033[93mWhic...
true
3c4c5a49a760e7f60e36e8cf192aee85d12d9ca2
Ruby
dgf1979/epicodus-week2_code_review
/app.rb
UTF-8
1,039
2.765625
3
[ "Unlicense" ]
permissive
require('sinatra') require('sinatra/reloader') require('./lib/word') require('./lib/definition') also_reload('lib/**/*.rb') require('pry') get('/test') do @test_var = "Sinatra OK" erb(:test) end #redirect root route to /words route get('/') do redirect to('/words') end #reset/clear app get('/reset') do Word....
true
6b470625dfd6ea59c2b9d1e15ce8f31888e7b7e0
Ruby
TulioFonseca/Trabalho-de-Redes
/4_Fisica/Servidor/receiver.rb
UTF-8
1,273
2.734375
3
[]
no_license
require 'socket' require 'benchmark' require_relative "../Utils/lerArquivo" require_relative "../Utils/mac" require_relative "Configuracoes" require_relative "../Comunicacao/Enviar" SIZE = 1024 * 1024 * 10 arquivo = Arquivo.new pdu = arquivo.lerArquivo("Configuracoes/configuracoes.txt") arquivoDeConfiguracao = arqu...
true
1fb68388eb42f91d9d46fdcb69c9c74b4c79ef0b
Ruby
azuwis/ddime-tools
/dmg2txt.rb
UTF-8
689
3.125
3
[]
no_license
#!/usr/bin/ruby file = ARGV[0] code = ARGV[1] text = ARGV[2] data = File.open(file, 'rb').read() pattern = code + (text.size * 3).chr + text offset = data.index(pattern.force_encoding('ASCII-8BIT')) - 5 index = offset loop do weight = data[index..index+1] index = index + 2 weight = weight.unpack('S')[0] ind...
true
ddd5563b6a74b11b258ef35efc8a26ec73fc4eb3
Ruby
brandonbaah/weekend_work_three
/oop/tv_and_remote.rb
UTF-8
668
3.578125
4
[]
no_license
# In this exercise, you will be creating two classes AND the driver code to test them. # You will create a Tv class and a Remote class. # The Tv class will have the attributes: power, volume, and channel. # The Remote class will have just one attribute: tv. This will represent which tv it # actually controls. # The...
true
b90ff2bd8d80a05bc15b9ad162f8243513df285b
Ruby
Missye/Ruby-practice
/imperial_to_metric.rb
UTF-8
390
3.890625
4
[]
no_license
# a = 72 # puts a.to_i * 2.54 puts "What is your name?" user_name = gets.chomp height_in = 60 weight_lbs = 130 in_to_cm = 2.54 lbs_to_kg = 0.45 def in_to_cm (height) height_cm = height_in * in_to_cm end weight_kg = weight_lbs * lbs_to_kg in_to_cm(height_in) puts "Hello " + user_name + ", your height in cm is ...
true
b6ee0124614d3f2282fd80bdc41ef8daadbf75e3
Ruby
davefogo/ideapp
/app/models/factura_search.rb
UTF-8
680
2.6875
3
[]
no_license
class FacturaSearch attr_reader :fecha_de_expedicion_from, :fecha_de_expedicion_to def initialize(params) params ||= {} @fecha_de_expedicion_from = parsed_fecha_de_expedicion(params[:fecha_de_expedicion_from], 7.days.ago.to_date.to_s) @fecha_de_expedicion_to = parsed_fecha_de_expedicion(params[:fecha...
true
15930840745338af2daf87d028e78c3c826444e7
Ruby
bturnbull/orstrings-petition
/app/lib/confirmation_confirmer.rb
UTF-8
593
2.515625
3
[]
no_license
class ConfirmationConfirmer attr_accessor :ip, :confirmation, :confirmed_at def initialize(opts = {}) self.ip = opts[:ip] self.confirmation = opts[:confirmation] self.confirmed_at = opts[:confirmed_at] end def confirmed_at @confirmed_at ||= Time.now end def confirm unless co...
true
92be01ccd7dffb14e4b946264112edceb0ffc7d4
Ruby
michaelpmattson/party_bus_2107
/lib/bus.rb
UTF-8
460
3.703125
4
[]
no_license
class Bus attr_reader :name, :capacity, :passengers def initialize(name, capacity) @name = name @capacity = capacity @passengers = [] end def add_passenger(name) @passengers << name end def yell_at_passengers @passengers.map { |passenger| passenger.upcase } end def number_of_pass...
true
90750c4ad1aa4817637089c4538002e5a103a2d9
Ruby
cogma/Introduction-to-Algorithms
/allcode/request.rb
UTF-8
619
2.75
3
[]
no_license
class Request attr_accessor("title", "next") def initialize(t) self.title = t self.next = nil end end def delete_request(r,t) if r.title == t r.next else r.next = delete_request(r.next, t) r end end def make_cycle(list) last = last_request(list) last.next = list list end def l...
true
564d9df291eeb140aa73c0dd86a3dc724fbbd11c
Ruby
gnappo1/badges-and-schedules-uci-online-web9-pt-093019
/conference_badges.rb
UTF-8
584
3.9375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def badge_maker(name) "Hello, my name is #{name}." end def batch_badge_creator(people) #sentences = [] people.collect {|person| badge_maker(person)} #sentences end def assign_rooms(people) sentences = [] people.each.with_index(1) {|person, i| sentences << "Hello, #{perso...
true
b1cea5ee46b2afb902c4ad1171081a313550bc68
Ruby
croby/flexmls_api
/spec/unit/flexmls_api/models/open_house_spec.rb
UTF-8
1,159
2.53125
3
[ "Apache-2.0" ]
permissive
require './spec/spec_helper' require 'time' describe OpenHouse do subject do OpenHouse.new( 'ResourceUri'=>"/v1/listings/20060412165917817933000000/openhouses/20101127153422574618000000", 'Id'=>"20060412165917817933000000", 'Date'=>"10/01/2010", 'StartTime'=>"09:00:00-07:00", 'EndT...
true
d69e82f463467600c993e2c09568e1b77e937c0d
Ruby
Piyoshi/Programming
/RubyProgramming/wc.rb
UTF-8
764
3.296875
3
[]
no_license
ltotal = 0 # 行数の合計 wtotal = 0 # 単語数の合計 ctotal = 0 # 文字数の合計 ARGV.each{|file| begin input = open(file) # ファイルを開く(A) l = 0 # file内の行数 w = 0 # file内の単語数 c = 0 # file内の文字数 while line = input.gets do l += 1 c += line.size line.sub!(/^\s+/, "") # 行頭の空白を削除 ary = line.split(/\s+/...
true
c05b8d93c09bce7fd1d685227c131db706787bd7
Ruby
lofic/tips
/Rakefile
UTF-8
3,545
2.65625
3
[]
no_license
require 'rubygems' require 'nokogiri' require 'fileutils' require 'thread' NUM_THREADS = 16 subheader_link = "http://lofic.github.io/tips/[lofic.github.io/tips]" project_link = "https://github.com/lofic/tips/[> give me a star here <]" html_folder = "./html" # Where you generate your html files txt_folder = "./txt" #...
true
ad44bf0c0a2e80bd94b35ea7bb6a362a7ebc8628
Ruby
adavia/no_name
/app/models/order_item.rb
UTF-8
700
2.78125
3
[]
no_license
class OrderItem < ApplicationRecord belongs_to :product validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 1 } validate :product_in_stock before_create :decrement_product_stock before_destroy :increment_product_stock def product_in_stock if quantity if product && (pr...
true
94df18116153dda5f8278bd7b7082bb7b096b1c7
Ruby
filipebarcos/rnake
/lib/models/snake.rb
UTF-8
507
3.296875
3
[]
no_license
class Snake def initialize (window) @window = window @image = Gosu::Image.new(@window, 'media/images/snake.png') @x = @y = @vel_x = @vel_y = @angle = 0.0 end def warp(x, y) @x, @y = x, y end def turn_left @angle -= 2.0 end def turn_right @angle += 2.0 end def move @x ...
true
2b6fae42b69ac0e9eaa138fc7e3930adeba95938
Ruby
47colborne/dojo
/ruby/linked_list_20170922/lib/linked_list.rb
UTF-8
623
3.609375
4
[]
no_license
class LinkedList def initialize @head = nil end def append(value) if @head.nil? @head = Node.new(value) else append_to(@head, value) end end def get(index) current_node = @head current_index = 0 while current_node if index == current_index return curren...
true
d0bb0655906ede5984c7188cef4ee35992b65fce
Ruby
CarlosMontilla/codeeval
/easy/matrixRotation/main.rb
UTF-8
608
3.421875
3
[]
no_license
#! /usr/bin/env ruby # Solves the codeeval challenge: https://www.codeeval.com/open_challenges/178/ # Programmed by: Carlos Montilla include Math def rotate90(matrix, nrow, ncol) if matrix.length == 0 return [] else elements = [] (0...nrow).reverse_each do |i| elements.push(matrix[i*ncol]) ...
true
b06e2891b4c521839abbbb588583a0375310d26a
Ruby
lebichmar/FIT4H_EuP
/ruby/code/aufgabe05.rb
UTF-8
856
3.828125
4
[]
no_license
class Player attr_reader :health attr_accessor :score def initialize(pname, phealth=100) @name = pname @health = phealth end def to_s #hier werden keine Variablen übergeben, da Instanzvariablen "Mein Name ist #{@name} mit einem Wert #{@health} um #{time} mit einem Wert von #{score}." end def ...
true
54b4daaeb8704f362476f3434574f5bf688d64fc
Ruby
hdaniel1/ruby-class-variables-and-class-methods-lab-dc-web-career-040119
/lib/song.rb
UTF-8
717
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_reader :name, :artist, :genre @@count = 0 @@artists = [] @@genres = [] def initialize(name, artist, genre) @name = name @artist = artist @genre = genre @@count +=1 @@artists << artist @@genres << genre end def self.count @@count end def self.artists @...
true
114afa5b33028521f1491ffb6cc41ed822860d13
Ruby
kain/puppet-ssh
/lib/puppet/parser/functions/ssh_keygen.rb
UTF-8
2,775
2.578125
3
[ "Apache-2.0" ]
permissive
# Takes a Hash of config arguments: # Required parameters: # :name (the name of the key - e.g 'my_ssh_key') # Optional parameters: # :type (the key type - default: 'rsa') # :dir (the subdir of /var/lib/puppet/modules_data to store the key in - default: 'ssh') # :size (the key size - default...
true
a3a6db406f31bf0ca2fef33113a190b1c46aa149
Ruby
Ohnao/pair_pro_class
/special_month/special_month.rb
UTF-8
1,004
3.875
4
[]
no_license
require "date" class SpecialMonth attr_accessor :year, :month def initialize(year, month) @year = year @month = month end def first_day beginning_datetime = Date.new(@year, @month) beginning_datetime.prev_day(beginning_datetime.wday) end def last_day end_datetime = Date.new(@year,...
true
3f3e5771c55d07cf7e3be6a1600cbfee98eab9dc
Ruby
Madeline-Stark/Top-Movies
/Top-Movies-CLI/lib/top_movies/movies.rb
UTF-8
1,094
3.40625
3
[ "MIT" ]
permissive
module TopMovies class Movies attr_accessor :title, :date @@all = [ ] def initialize(movie_hash) movie_hash.each {|key, value| self.send(("#{key}="), value)} @@all << self end def self.create_from_collection(movie_hash) movie_hash.each do |movie| movie = self.new(movie) end end def self...
true
e43a31d3b2e18cd4d17a35c02b22fb89f04b4360
Ruby
cmaher92/launch_school
/exercises/practice_problems/4.12/4.rb
UTF-8
117
3.734375
4
[]
no_license
# What is returend? return_value = for number in [1, 2, 3] puts number end return_value == [1, 2, 3] # => [1, 2, 3]
true
81a62ee9bd33435d6bd49dfaad19ecf82b86ae37
Ruby
samalves/expenseTracker
/scanner.rb
UTF-8
1,151
4.09375
4
[]
no_license
# Simple scanner that iterate through all the characters # in the given source code. # # Use the class' char method to get the initial character # of source code. # # Uset the next method to the next character. # class Scanner # Initializes scanner to the first character # in the source code. def initialize filena...
true
741bbd4591489aac2cf1aaf23f29c646acb6fd55
Ruby
neanias/aoc
/2020/ruby/spec/day2_spec.rb
UTF-8
454
2.5625
3
[]
no_license
# frozen_string_literal: true require "day2" RSpec.describe Day2 do let(:problem_input) { generate_input_path(described_class.name.downcase) } subject(:day_2) { described_class.new(problem_input) } describe "#part_1" do it "finds the right number of passwords" do expect(day_2.part_1).to eq(2) end...
true
c5b46d219e56880eb172686439b80181450b399b
Ruby
andrewslotin/lunch
/app/models/vote.rb
UTF-8
724
2.515625
3
[]
no_license
# -*- encoding : utf-8 -*- class Vote include Mongoid::Document field :vote, type: Integer field :created_on, type: Date, default: -> { Time.zone.now.to_date } belongs_to :user belongs_to :place validates :user, uniqueness: { scope: :created_on } validates :vote, inclusion: { in: [-1, 1, nil]} scop...
true
b100a04ac4be93840dd6f057196892eecd4091c9
Ruby
seairy/Heather
/app/helpers/application_helper.rb
UTF-8
9,602
2.578125
3
[]
no_license
module ApplicationHelper def te_employee_title title case title when :assistant then '助教' when :instructor then '讲师' when :associate_professor then '副教授' when :professor then '教授' end end def te_employee_spouse spouse case spouse when :unmarried then '未婚' when :not_accompanied...
true
53ad4d8869a9685aa188690c08c5a813a63fa19d
Ruby
yasu0408/ruby_task
/02_01.rb
UTF-8
78
2.859375
3
[]
no_license
names = ["田中", "佐藤", "佐々木", "高橋"] names << "斎藤" p names
true
afdead666b13f47192e648907df9f9c1a898b256
Ruby
krainboltgreene/intrinsic
/lib/intrinsic/intrinsicism.rb
UTF-8
1,184
2.65625
3
[ "MIT" ]
permissive
require_relative 'intrinsicism/coercion' require_relative 'intrinsicism/validation' module Intrinsic module Intrinsicism attr_reader :properties, :defaults def property(name, type = String, options = {}) @properties ||= [] @defaults ||= {} check_types_for name, type, options define_...
true
9dd21481afc2964bd20c6d3760059ea0cf5c1312
Ruby
klpk011/programming-exercise
/20-sorting.rb
UTF-8
353
3.84375
4
[]
no_license
# 承上题,请排序并去除重复的数字 # Hint: 可用 arr.sort 排序,和 arr.uniq 去除重复 def filter_even(arr) result = [] arr.each do |a| if a % 2 == 0 result.push(a) end end return result.sort.uniq end arr = [7, 68, 42, 46, 9, 91, 77, 46, 86, 1] puts "#{filter_even(arr).to_s}" # 应该是 [42, 46, 68, 86]
true
b21d204c996a6d0f553857cd74ece9a07cb95638
Ruby
MeaganMestre/Special-Projects
/MeaganMuldoon.rb
UTF-8
762
3.46875
3
[]
no_license
class Fruit1 attr_accessor :color, :shape, :bites, :dressing def initialize @bites = 5 end def eat! @bites = [@bites - 1,0].max end def fruit true end def seeded? seeds === true end def self.attributes=(obj) @@attributes = obj end def self.attirbute(type, value) @@attributes ||= ...
true
5bc285dee57b5026a819fb9ab7ffea026e9361d3
Ruby
mark-a-dev/jumpstart
/1-week/2-day/w1d2-warmup.rb
UTF-8
1,344
4.75
5
[]
no_license
# Puts While/Each # ---------------------------------------- # Write a method, #puts_while, that accepts an array as an argument and will puts # every element in the array. Do this using a while loop. require "pry" vowels =["a", "e","i","o","u"] def puts_while (array) i = 0 while i < (array.length) puts arra...
true
b9b685e893746c3018640b619cb131e526648750
Ruby
bainjen/learn_ruby
/launch_school/09_using_super.rb
UTF-8
1,006
4.5
4
[]
no_license
# example 1 class Animal def speak "Hello!" end end class GoodDog < Animal def speak super + " from GoodDog class" end end sparky = GoodDog.new sparky.speak # => "Hello! from GoodDog class" #example 2 with initialize class Animal attr_accessor :name def initialize(name) @name = name...
true
9c6417027c525043798acfe744ef21c58dc69967
Ruby
MishaConway/binary_search_frequency
/lib/binary_search_frequency/binary_search_frequency.rb
UTF-8
1,392
3.609375
4
[ "MIT" ]
permissive
module BinarySearchFrequency def binary_frequency number left_index = left_binary_search(number, 0, size - 1) if left_index right_index = right_binary_search(number, left_index, size - 1) right_index - left_index + 1 else 0 end end def bfrequency number binary_frequency num...
true
4cd20320d51a245be1b0d6564948e53c6bcc17d5
Ruby
lockemind/the_odin_project
/ruby/pine_exercices/word_sorter.rb
UTF-8
188
3.015625
3
[]
no_license
puts 'Speak away! (one word per line please)' input = 'start' list_to_sort = Array.new until input.to_s.empty? do input = gets.chomp list_to_sort << input end puts list_to_sort.sort
true
cf0a9887bdc652bfcdf0085924a47a3fbb6fe0bf
Ruby
seanwbrooks/blackjack
/lib/hand.rb
UTF-8
544
3.5625
4
[]
no_license
class Hand attr_reader :hand_of_cards def initialize @hand_of_cards = [] end def add_card(card) @hand_of_cards.push(card) end def calculate elevens = 0 total_score = 0 @hand_of_cards.each do |card| if card.ace? elevens += 1 total_score += 11 elsif card.face...
true
ea48166e2d9dad9ebab772dd5faebb779ece4b98
Ruby
KerryKDiehl/test-first-ruby
/spec/14_array_extensions_spec.rb
UTF-8
2,638
3.90625
4
[]
no_license
# # Array Extension # # # Topics # # * objects, methods, classes # * reopening classes require "14_array_extensions" # we don't call it "array.rb" since that would be confusing describe Array do describe "#sum" do it "has a #sum method" do expect([]).to respond_to(:sum) end it "should be 0 for an...
true
038a4a53cfe5181695d5fcc95238886a29117577
Ruby
efueger/inquisition
/lib/inquisition/lol_dba/missing_index.rb
UTF-8
636
2.609375
3
[ "MIT" ]
permissive
module Inquisition module LolDba class Columns def initialize(columns) @columns = Array(columns) end def to_s @columns.map do |column| "`#{column}`" end.join(', ') end end class MissingIndex def initialize(table:, columns:) @table =...
true
d40df692109654745e98004d639515eea483a1fb
Ruby
J-Y/RubyQuiz
/ruby_quiz/quiz87_sols/solutions/Alex Nedelcu/negative_sleep.rb
UTF-8
1,154
3.265625
3
[ "MIT" ]
permissive
class Computation def initialize(&computation) @comp = [] @comp << computation @rev = 0 end def run @comp.each do |runnable| if runnable.kind_of? Computation runnable.run else runnable.call end end ...
true
a5b80c5787bb0ea11450648cb3ae77fd78add239
Ruby
TheBlackArroVV/traveler_api
/app/services/trip_service.rb
UTF-8
593
2.609375
3
[]
no_license
class TripService attr_reader :errors, :trip def initialize(user, trip = {}) @trip = trip @user = user @errors = [] end def create(params) ActiveRecord::Base.transaction do @trip = Trip.new(params.merge(user: @user)) if @trip.save Membership.create(user: @user, trip: @trip...
true
77974907a2677d13f60c3269f28ebc02ffad1726
Ruby
headius/bench2018
/bench_kwargs.rb
UTF-8
143
3.046875
3
[]
no_license
def foo(a:1) a end (ARGV[0] || 20).to_i.times { t = Time.now i = 0 while i < 10_000_000 i+=foo(a: 1) end puts Time.now - t }
true
49ee241182a40adff41ae9b2f7de6dd5ea256d16
Ruby
pierre-bedouret/rails-garden-manager
/db/seeds.rb
UTF-8
1,297
2.890625
3
[]
no_license
puts "Cleaning database" Garden.destroy_all # if Rails.env.development? puts "All gardens destroy" Plant.destroy_all # if Rails.env.development? puts "All plants destroy" garden_names = [ "French garden", "My Cute Balcony", "English garden", "Flowered patio", "Garden in Japan", "Walk among flowers" ] plant...
true
e73a1eba627587e59787ffa3e4f792a89358eaae
Ruby
erodxd/apis-and-iteration-dumbo-web-career-031119
/bin/run.rb
UTF-8
294
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#!/usr/bin/env ruby require_relative "../lib/api_communicator.rb" require_relative "../lib/command_line_interface.rb" welcome character = get_character_from_user show_character_movies(character) # puts a wlecome # save requested character to a variable # show the movies the character is in
true
c16903e41f2d86abdc7030219d49ce63be310753
Ruby
liaa2/wdi29-homework
/yianni_moustakas/week4/tuesday/array-exercises.rb
UTF-8
901
4.71875
5
[]
no_license
# ### 1. Create an array of the days of the week # - Create a variable named `days_of_the_week` as an array of the following: # - Monday # - Tuesday # - Wednesday # - Thursday # - Friday # - Saturday # - Sunday # puts "Array of days of the week" days_of_the_week = ["Monday", "Tuesday", "Wed...
true
5805b80ce7b235eacb1975c150533c21ad903f9f
Ruby
takaram/benchmark-test
/tarai/tarai.rb
UTF-8
166
3.4375
3
[]
no_license
def tarai(x, y, z) if x <= y y else tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y)) end end puts tarai(13, 5, 0)
true
2914e7f7c665bdcce06bb9a156e477c89d0ebf63
Ruby
matt-wallis/iphoneutils
/lib/iphoneutils/cli.rb
UTF-8
1,851
3.03125
3
[]
no_license
require "thor" require "iphoneutils/copy/recordings" module Iphoneutils module Subcommands class Copy < Thor desc "recordings SOURCE TARGET", "Copies recordings from iPhone" long_desc <<-LONGDESC Copies .m4a files from the Recordings directory on the iPhone, and renames them using the name that...
true
2501659efe09016a61fa4b96915bb76bc9c87cc6
Ruby
Flup-/lorem2
/app.rb
UTF-8
538
2.53125
3
[]
no_license
require 'sinatra' require 'dinosaurus' Dinosaurus.configure do |config| config.api_key = 'cecaa270c7146d8be41da5647bef0b93' end get "/" do redirect "ipsum.html" end post "/" do topic = params['topic'] @words = Dinosaurus.synonyms_of (topic) @content = '' params[:number].to_i.times do @content += '<p>...
true
f32cf9ebca2a94db2f856cce7cd2e936864732ed
Ruby
Jenietoc/Ruby_kommit_course
/Hashes II/Create_Hash_with_Default_Value.rb
UTF-8
268
2.65625
3
[]
no_license
fruit_prices = {banana: 1.05} p fruit_prices[:orange] p fruit_prices[:grape] fruit_prices = Hash.new(0) fruit_prices[:banana] = 1.05 p fruit_prices[:orange] p fruit_prices[:grape] fruit_prices.default = 'Not found' p fruit_prices[:orange] p fruit_prices[:grape]
true
fea3616e6b3c197864244a101a139a7d7bdd265d
Ruby
skhanna1011/practice-programs
/wd-june/ruby/array-palli.rb
UTF-8
258
3.21875
3
[]
no_license
nums = [1,2,3,4,3,2,1] length = nums.length index = nil nums.each.with_index do |item, i| sum_left = nums[0..i-1].inject(:+) sum_right = nums[i+1..length-1].inject(:+) index = i if sum_left == sum_right end if index.nil? puts -1 else puts index end
true
041f66e451b76ae0723f22f3bd14740067508154
Ruby
bublanina/masterlanguage
/vendor/bundle/ruby/1.9.1/gems/erubis-2.6.6/test/data/users-guide/example3.rb
UTF-8
363
2.59375
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- require 'erubis' input = File.read('example3.eruby') eruby = Erubis::EscapedEruby.new(input) # or Erubis::XmlEruby puts "----- script source ---" puts eruby.src # print script source puts "----- result ----------" list = ['<aaa>', 'b&b', '"ccc"'] puts eruby.re...
true
8e31db8f92a510c3826db730c3be24834884b7a7
Ruby
care0717/pro_con
/atcoder/abc/112/D.rb
UTF-8
863
3.203125
3
[]
no_license
def s() gets().chomp end def i() gets.to_i end def li() gets.split.map(&:to_i) end def ili() n = gets.to_i as = gets.split.map(&:to_i) [n, as] end class Array def sum total = 0 self.each do |item| total += item end total end end def solve(pos,m) x, y = pos query = "" if x < ...
true
c19454d2b5a8d80d8fe003c123f5b1f8d9ae2aff
Ruby
gregorl82/Ruby_Cinema_Booking_System
/console.rb
UTF-8
1,933
2.9375
3
[]
no_license
require('pry') require_relative('models/customer.rb') require_relative('models/film.rb') require_relative('models/ticket.rb') require_relative('models/screening.rb') Ticket.delete_all() Screening.delete_all() Customer.delete_all() Film.delete_all() # Customers customer1 = Customer.new( { 'name' => 'Jennifer Wi...
true
ccc4fda6cb541c872b6230882a2dfde85ef1764e
Ruby
thales-mro/ruby-basic
/method_calls.rb
UTF-8
388
4.5
4
[]
no_license
puts "Calling a method with \"!\" in the end modifies the value of current variable, instead of assigning another variable. Example: " name = "Thales Oliveira" puts "name: #{name}" name2 = name.upcase puts "It assigns name2 variable value to upcase value of name, but name remains unchanged." puts "name: #{name}, na...
true
518d939fd2fb36a484cb477e582da88e271ed822
Ruby
NZOI/nztrain
/lib/ext/string.rb
UTF-8
142
3
3
[]
no_license
class String def shorten if self.size > SHORTEN_LIMIT return self[0,SHORTEN_LIMIT] + "..." end return self end end
true
6c73d155912b6087d4969f2fe65c39436d853790
Ruby
ghemsley/coffeefinder
/lib/coffeefinder.rb
UTF-8
581
2.640625
3
[ "MIT" ]
permissive
module Coffeefinder cli = CLI.new print "Obtaining geolocation data for IP address#{cli.ip_address != '' ? " #{cli.ip_address}" : ''}... " cli.geoip = GeoIP.new(cli.ip_address) print "Obtained!\n" print 'Authenticating with Yelp... ' cli.yelp = Yelp.new({ latitude: cli.geoip.latitude...
true
ffb357d80e9b5d217f94fb048170bc673cd4d063
Ruby
pamgriffith/designblog
/_plugins/category_nav.rb
UTF-8
1,114
2.96875
3
[]
no_license
# From http://stackoverflow.com/questions/28331879/jekyll-next-and-previous-links-with-different-categories # Modified to work with multiple categories module Jekyll class WithinCategoryPostNavigation < Generator def generate(site) site.categories.each_pair do |category, posts| posts.sort! { |a,b| ...
true
f2e1dc53bd515fd31857a6a3338d9cf45fedfecb
Ruby
watachan7/Ruby_LSP_GDY
/src/StrideData.rb
UTF-8
962
2.65625
3
[]
no_license
require 'dxruby' require_relative './GraphicsLoader.rb' class StrideData def initialize @alpha = 255 @strideData = Graphics::STRIDEDATA @dataHpImage = Graphics::DATAHP @mainWeapon = Graphics::MAINWEAPON @subWeapon = Graphics::SUBWEAPON @weaponSelector = Graphics::WEAPONSELECTOR # 体力 ...
true