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
f1704d6fccbeb164081052540b96eef4f8562bfd
Ruby
SadTigger/codewars
/7 Kyu/Float Precision/solution.rb
UTF-8
130
2.890625
3
[]
no_license
# Kata: # https://www.codewars.com/kata/5143d157ceb46d6a61000001 # Example: # Solution: def solution(value) value.round(2) end
true
1cb65bb2fec4de62ddb1becdd9c832b0b50ba741
Ruby
jltackett2/RubyBook
/Loops_Iterators/practice_each.rb
UTF-8
184
3.34375
3
[]
no_license
names = ['bob', 'joe', 'steve', 'janice'] x = 1 #names.each { |name| puts name.capitalize} # addiing functionality names.each do |name| puts "#{x}. #{name.capitalize}" x += 1 end
true
ac75d8ea347bf3ac9683a7d0ccb5198184586fdb
Ruby
frandorr/isw2-tp1
/entrada_agenda.rb
UTF-8
135
2.65625
3
[]
no_license
class EntradaAgenda attr_reader :nombre, :telefono def initialize nombre, telefono @nombre = nombre @telefono = telefono end end
true
f46eb6bcc918401f6f36e4c205444008138bd38f
Ruby
QPC-WORLDWIDE/rubinius
/benchmark/tiers/1/bm_so_random.rb
UTF-8
250
2.796875
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# from http://www.bagley.org/~doug/shootout/bench/random/random.ruby def gen_random(max, last, im, ia, ic) (max * (last = (last * ia + ic) % im)) / im end def Bench.run 1_000_000.times { gen_random(100.0, 42.0, 139968.0, 3877.0, 29573.0) } end
true
a85a74ab3cb9565953ce367c863cd1b05872d613
Ruby
noemargui/Ruby_Vendredi
/exo_16.rb
UTF-8
196
3.5
4
[]
no_license
puts "Quel âge as-tu cher utilisateur ?" user_age = Integer(gets.chomp) x = user_age y = 0 loop do if x > 0 puts "Il y a #{x} ans, tu avais #{y} ans." x = x - 1 y = y + 1 else break end end
true
c3aa37daad28747543e7f57f660d7c35f621aae2
Ruby
halostatue/minitar
/lib/archive/tar/minitar/posix_header.rb
UTF-8
7,737
2.625
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
# coding: utf-8 ## module Archive; end ## module Archive::Tar; end ## module Archive::Tar::Minitar; end # Implements the POSIX tar header as a Ruby class. The structure of # the POSIX tar header is: # # struct tarfile_entry_posix # { // pack/unpack # char ...
true
2380ec99b793d2d75fccfa5c3c086b1d9bd17892
Ruby
slockey/pickaxe-1.9
/Chapter2/controlStructures.rb
UTF-8
348
3.796875
4
[ "MIT" ]
permissive
today = Time.now # if/els if today.saturday? puts "It is Saturday" elsif today.sunday? puts "It is Sunday" else puts "Back to work" end # while idx = 0 idy = 0 while idx < 10 and idy < 100 printf("idx: %d idy: %d\n", idx, idy) idx += 1 idy += 10 end # statement modifier square = 4 square *= square whil...
true
fa5c8212c5af4401a3d03c1d3cb3dbe455e212ba
Ruby
Pluvie/italian-ruby
/lib/italian/ruby/metodi/date.rb
UTF-8
1,691
3.140625
3
[]
no_license
# frozen_string_literal: true require "date" class Date class << self ## # Restituisce la data di domani. def domani oggi + 1 end ## # Restituisce la data di ieri. def ieri oggi - 1 end end ## # Restituisce la data di oggi a due anni fa. def due_anni_fa s...
true
5f730798b74dcf760cd3dcd2bf453135b2b48327
Ruby
rgiannico/lederhosen
/lib/lederhosen/tasks/name.rb
UTF-8
779
2.859375
3
[ "MIT" ]
permissive
## # IDENTIFY CLUSTERS IN A TAXCOLLECTOR DATABASE # module Lederhosen class CLI desc "name", "identify representative reads in a TaxCollector database using BLAT" method_option :reps, :type => :string, :required => true method_option :database, :type => :string, :required => true metho...
true
bc1a698473c84137601b775486b9f355bb1347dd
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/b22701a59b7345c2a46f1ebca41ebe86.rb
UTF-8
589
3.5625
4
[]
no_license
class Bob def hey(input_message) @message = input_message if shouting? && has_letters? 'Woah, chill out!' elsif question? && not_multiline? 'Sure.' elsif silence? && not_multiline? 'Fine. Be that way!' else 'Whatever.' end end private attr_reader :message de...
true
57e801ed45786b5cfd18f73639d711f25816ed38
Ruby
KingGranger/badges-and-schedules-web-100817
/conference_badges.rb
UTF-8
504
3.75
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def badge_maker name "Hello, my name is #{name}." end def batch_badge_creator speakers badge_messages = [] speakers.each{|name| badge_messages << badge_maker(name)} badge_messages end def assign_rooms speakers rooms = [] speakers.each_with_index{|person, room| rooms << "Hello, #{person}! You'll be assigne...
true
941f98a0a5b8b76c1488c2c9ee2c42bd5f872c0e
Ruby
bethebunny/irc_bots
/panicbutt_helpers.rb
UTF-8
21,340
2.5625
3
[]
no_license
def testhelper() return 'This message is now different. Loading test helper seems to have worked' end $jeff_crisis_levels = {'critical' => {'text' => 'black', 'font' => 'Lucida Console', 'bg' => "\n background-image: url(//brianauron.info/img/...
true
58cfcb75d980381975772c5c5faad50c058f5bcf
Ruby
jutonz/chess
/pieces/knight.rb
UTF-8
740
3.125
3
[]
no_license
class Knight < ChessPiece def initialize super apply_knight_movement_pattern(:top, :left) apply_knight_movement_pattern(:top, :right) apply_knight_movement_pattern(:left, :top) apply_knight_movement_pattern(:left, :bottom) apply_knight_movement_pattern(:bottom, :left) apply_knight_moveme...
true
2a8acfbdc0e6f4b383965bcb4a1b58a500f6afa1
Ruby
asvinie057/Exos_lundi_2
/05_timer/timer.rb
UTF-8
585
3.71875
4
[]
no_license
def time_string (x) [x / 3600, x / 60 % 60, x % 60].map{|t| t.to_s.rjust(2,'0')}.join(':') end #[x / 3600, x / 60 % 60, x % 60] permet de savoir combien d'heure de minute et de seconde il y a dans x #calcul a faire dans l'ordre #1) x / 3600 = nombre d'heure dans x car 1h = 3600 s #2) x / 60 % 60 = nombre de minutes...
true
bc7d778311b688d3cae45ae8c1af4c3fc598f867
Ruby
tien-vu/ls-intro-programming
/flow_control/ex05.rb
UTF-8
565
4.5625
5
[]
no_license
def num_if(num) puts "EX 03" if num < 0 puts "Number is negative." elsif num <= 50 puts "Number is between 0 and 50." elsif num <= 100 puts "Number is between 0 and 100." else puts "Number is above 100" end end def num_case(num) puts "EX 05" case when num < 0 puts "Number is ne...
true
32eb375056b9f05502996a51e7b75459bfc12015
Ruby
indiejames/GeminiSK
/scripts/generate_base_templates.rb
UTF-8
2,118
2.625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # generates Xcode 4 project templates require 'erb' require 'find' require 'pathname' require 'fileutils' require 'optparse' # This hash will hold all of the options # parsed from the command-line by # OptionParser. options = {} optparse = OptionParser.new do|opts| # Set a banner, displ...
true
70c9ea93f0b7cbc5ffeac89c63554854fe7cd72d
Ruby
LucasBallestrino/moove-it-coding-challenge-LucasBallestrino
/unit_test/touch_test.rb
UTF-8
1,111
3.171875
3
[]
no_license
# Command touch test require_relative '../lib/RubyMemcachedClient' cache = RubyMemcachedClient.new('127.0.0.1', 11211) # The "touch" command is used to update the expiration time of an existing item without fetching it. # touch(key,exptime) cache.set("TheKey","some value") puts cache.get("TheKey") touch_result = cache....
true
341b063c210055599eb4626126e63898f82bf379
Ruby
dojorio/dojo-centro
/2018/20180307 - Sticker Collector Robot - ruby/problem.rb
UTF-8
339
2.53125
3
[]
no_license
def execution(arena, instructions) if (instructions == '' or !instructions.include?('F') or !arena[0].include?('*') or arena[0].include?('N') or arena[0].include?('S') ) return 0 end if arena[0].include?('*') and ( instructions.include?('F') and !instructions.include?('D') ) return 1 ...
true
61779522df730e0f1ff21fbfc1535012a5e5fd17
Ruby
Agilefreaks/challenges
/Ruby/lib/ch1/fraud_detection.rb
UTF-8
1,742
3.1875
3
[]
no_license
class FraudDetection def initialize @hash = {} @frauds = {} end def parse_email(email) email_split = email.downcase.split("@") username = email_split[0].gsub(".", "").gsub(/(\+.*)/, "") domain = email_split[1] "#{username}@#{domain}" end def parse_address(address) address.downca...
true
dead5c32ac2d164ffd601617e45e66817bf3bf62
Ruby
al-walker/course-101
/lesson_3/exercises_medium_3.rb
UTF-8
6,256
3.625
4
[]
no_license
# Question 1 # Ruby re-uses objects when values are the same (same object == same object_id) # Ruby does not change the id based on position inside or outside of blocks # Changing values forces Ruby to create new objects and refer to them with the original names. # Ruby re-uses the objects under the hood when it can, ...
true
b1822501fab85ba0ae1ec7f805b8f65ccfedc9f4
Ruby
tpickett66/Project-Euler-Solutions
/bin/101-150/p119
UTF-8
546
3.34375
3
[]
no_license
#!/usr/bin/env ruby # encoding: UTF-8 $:.unshift(File.dirname(__FILE__) + '/../../lib') unless $:.include?(File.dirname(__FILE__) + '/../../lib') # The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this propert...
true
b1be696711a93bbb1007e8d643dcae8815c1562d
Ruby
codeship/inline_svg
/spec/inline_svg_spec.rb
UTF-8
2,847
2.578125
3
[ "MIT" ]
permissive
require_relative '../lib/inline_svg' class MyCustomTransform def self.create_with_value(value); end def transform(doc); end end class MyInvalidCustomTransformKlass def transform(doc); end end class MyInvalidCustomTransformInstance def self.create_with_value(value); end end describe InlineSvg do describe "...
true
e546bd08f60f72eb4d32890a8301251d253a91c9
Ruby
ojlamb/battleships-grid
/lib/board.rb
UTF-8
367
3.265625
3
[]
no_license
require_relative "grid" class Board attr_reader :ships, :grid def initialize @grid = Grid.new end def convert_coordinates(coords) x,y = coords.scan(/\d+|\D+/) [[x.ord - 65],[y.to_i - 1]] end def place_ship(ship,coordinate,direction) converted = convert_coordinates(coordinate) cell = grid.find_cell(co...
true
02b59f3b6ef817e32fdc75d034b7ef6750176259
Ruby
shimetoya/task9
/railway_station.rb
UTF-8
1,361
3.21875
3
[]
no_license
class RailwayStation attr_accessor :station attr_accessor :counte attr_accessor :car attr_accessor :cars @@count = [] @@counter = 0 def self.all @@count end def initialize(station) @station = station @current_station = station @trains = [] validate! @@count << self end de...
true
8a52ccd6e69a08e527bbe8bbc4971ab91a566c5b
Ruby
michaeledgar/amp_complete
/amp-git/lib/amp-git/encoding/binary_delta.rb
UTF-8
6,768
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
################################################################## # Licensing Information # # # # The following code is licensed, as standalone code, under # # the Ruby License, unless otherwise directed withi...
true
61e7c61bf587f3aa5e2c4bb20d1cb7d3daa45104
Ruby
oliviam20/exercises
/example/example.rb
UTF-8
155
3.125
3
[]
no_license
puts "Hello World" def greeting(name) puts "Hello #{name}" puts "Hello #{name}" puts "Hello #{name}" puts "Hello #{name}" end greeting("olivia")
true
aa7f8a40672afdb7c708838c025f20bf3e326bb7
Ruby
RebekkaRove/RebekkaRove
/Undervisning Rocketlab/OOP - Day 1/debugging.rb
UTF-8
158
3.234375
3
[]
no_license
def full_name(first, last) first_cap = first.capitalize last_cap = last.capitalize return "#{first_cap} #{last_cap}" end p full_name("bruce", "waYne")
true
f54db9c34d6b3e35f0244684b832ef11039dd4f2
Ruby
DeclanBU/OOP2-Project-2014
/vendor/bundle/ruby/2.3.0/gems/gibbler-0.8.9/try/18_proc_try.rb
UTF-8
855
2.875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'gibbler' class ::MyProc < Proc; end ## Proc.new can gibbler Proc.new() { }.gibbler #=> '12075835e94be34438376cd7a54c8db7e746f15d' # Proc can gibbler Proc.gibbler #=> '8640f7abcbcb80e3825ed827bf36819e26119e16' ## proc can gibbler proc {}.gibbler #=> '12075835e94be34438376cd7a54c8db7e746f15d' # l...
true
494360da51af447c72b6a38ec50830b43c66e891
Ruby
RenschS/AT-BA
/meg_flurry_analytics.rb
UTF-8
2,736
2.59375
3
[]
no_license
require 'logger' require 'httparty' require 'active_support/all' class MegFlurryAnalytics class InvalidCredentials<StandardError; end attr_reader :api_access_code, :iphone_api_key, :ipad_api_key, :android_api_key, :logger,:iphone_data def initialize(options) @api_access_code = o...
true
af02071857308e1758126258c742c0a339b392d6
Ruby
Mousaab-t/exo_ruby
/exo_14.rb
UTF-8
142
3.546875
4
[]
no_license
puts 'choisi un nombre?' print">" number = gets.to_i loop do puts "#{number}" number -= 1 if number == 0 puts number break end end
true
c55c11801bebeaaaa093bc04d0851f63793c0860
Ruby
schmurfy/drone
/specs/utils/exponentially_decaying_sample_spec.rb
UTF-8
3,648
2.578125
3
[ "MIT" ]
permissive
require File.expand_path('../../common', __FILE__) require 'drone/utils/exponentially_decaying_sample' include Drone describe 'Exponentially Decaying Sample' do before do Drone::init_drone(nil, Storage::Memory.new) end describe "A sample of 100 out of 1000 elements" do before do @population = (...
true
864f97dc811c8341a5c0bca00500b560c758593f
Ruby
willguv/rummager
/lib/govuk_search_presenter.rb
UTF-8
1,305
2.90625
3
[]
no_license
require "result_set_presenter" # Presents a combined set of results for a GOV.UK site search class GovukSearchPresenter STREAM_TITLES = { "top-results" => "Top results", "services-information" => "Services and information", "departments-policy" => "Departments and policy" } # The `result_sets` hash...
true
c910d87002eed75da0f3cdad56eecebb7d5675c9
Ruby
GooseGame/legendary_oop_on_Ruby
/second lab/second task/html_decode.rb
UTF-8
1,325
2.859375
3
[]
no_license
load "stdFunc/init.rb" class Html def htmlDecode(line)#обрабатываем строку за 1 проход цикла outLine = String.new ignoreIterations = 1 for i in 0..line.size if ignoreIterations != 1 #пропуск ненужных итераций ignoreIterations-=1 next end if line[i...i+'&quo...
true
c3b92766d83eb12f1fe731ecdbf14fa910ef00fe
Ruby
dmytro/openvpn_cert_nagios
/lib/openvpn_cert_nagios/shell.rb
UTF-8
457
2.71875
3
[ "MIT" ]
permissive
class CertCheck ## # Execute shell commands. Simple popen3 wrapper, that returns either # STDOUT or exit status, and aborts on non zero status. # class Shell def self.exe(cmd) Open3.popen3({"PATH" => "/usr/bin:/bin:/usr/sbin:/sbin"}, cmd) do |stdin, stdout, stderr, process| stdin.close ...
true
44698b3b9c665a8df506a9db753922039b769d23
Ruby
DCUnit711/ep
/GEM_HOME/gems/win32console-1.3.2-x86-mingw32/test/test_title.rb
UTF-8
227
3.046875
3
[ "Artistic-2.0" ]
permissive
#!/usr/bin/env ruby require "Win32/Console" a = Win32::Console.new() title = a.Title() puts "Old title: \"#{title}\"" a.Title("This is a new title") title = a.Title() puts "I just changed the title to '#{title}'" sleep(5)
true
b854ed78493f7893513e0414e5e6ed797629c43f
Ruby
al0cam/Stocks
/stocks.rb
UTF-8
548
3.671875
4
[]
no_license
#frozen_string_literal: true require 'pry' def stock_calculation(stocks) current_profit = 0 buy_day = 1 sell_day = 0 for i in 0...stocks.length do for j in i...stocks.length do if stocks[j] - stocks[i] > current_profit buy_day = i sell_day = j current_...
true
44f8d5035d52d53cfa5ee3d007a3d977249ad551
Ruby
bellvelo/Multiple-Classes-Exercise
/bear.rb
UTF-8
303
3.109375
3
[]
no_license
class Bear attr_reader :name def initialize(name, type) @name = name @stomach = [] end def fishes_eaten return @stomach end def stomach_contents return @stomach.count end def eat_fish(fish) @stomach << fish end def roar return "RRRRROOOOOAAAAAARRRRR!!!!!" end #this is the end end
true
bc7108a342f5fb7087f2b91cd5786ade67ff01df
Ruby
doverh/TicTacToeBidimensional
/game.rb
UTF-8
2,320
3.671875
4
[]
no_license
class Game # allow read && write attr_accessor :board_table def initialize(board) @board_table = board end # def playhuman(board_table,position,player1,player2,turn) # #Check if player X turn player 1 plays # if turn == 'X' # #Check if there any move left # if board_table.result...
true
eb1265d4cec5822982c7e0fa8909a0fdb37f2044
Ruby
collabnix/dockerlabs
/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.5/lib/active_support/core_ext/string/output_safety.rb
UTF-8
12,638
3.046875
3
[ "Apache-2.0", "MIT" ]
permissive
# frozen_string_literal: true require "erb" require "active_support/core_ext/kernel/singleton_class" require "active_support/core_ext/module/redefine_method" require "active_support/multibyte/unicode" class ERB module Util HTML_ESCAPE = { "&" => "&amp;", ">" => "&gt;", "<" => "&lt;", '"' => "&quot;", "'" => ...
true
d922674853b867a5ddff1e96f054b8197a8899b9
Ruby
osake/slackmud
/app/models/spells/spell_create_beer.rb
UTF-8
587
2.609375
3
[]
no_license
class SpellCreateBeer < GameCommandBase def initialize(game) super(game) @beer = beer_to_create end def perform room.inventory.items << @beer slack_messenger.msg_room(room.slackid, message_to_room) I18n.t 'game.spell_create_beer.success', beername: @beer.shortdesc end private d...
true
1ab6bf758bc969ab7d1a85bba18c89e44a06a4eb
Ruby
MagneticRegulus/120_oop
/lesson_1/2_classes_objects_1.rb
UTF-8
495
3.765625
4
[]
no_license
class MyCar attr_accessor :year, :color, :model, :speed def initialize(y, c, m) self.year = y self.color = c self.model = m self.speed = 0 end def speed_up(n=5) @speed += n end def brake(n=5) @speed -= n self.speed = 0 if speed < 0 end def turn_off self.speed = 0 en...
true
e6245d5750813776f84c4f985a3460068d8a67a8
Ruby
quintel/etflex
/app/models/inputs/many_to_one_input.rb
UTF-8
1,271
2.921875
3
[]
no_license
class ManyToOneInput < Input attr_accessor :inputs, :target, :formula def initialize(key, definition) super key, definition @formula = definition["formula"] @inputs = [] definition["inputs"].each do |input_definition| # TODO: Find a way to make this better input_definition["type"] = ...
true
be2d10aacde24450f4f48e7a950d64312356fced
Ruby
kayvee/rubypokeraa
/card.rb
UTF-8
5,407
2.78125
3
[]
no_license
require 'colorize' class Card IMAGE = { S14: " #{"\u2660".encode("utf-8")} A ".colorize(:color => :black, :background => :white), S2: " #{"\u2660".encode("utf-8")} 2 ".colorize(:color => :black, :background => :white), S3: " #{"\u2660".encode("utf-8")} 3 ".colorize(:color => :black, :background => :whit...
true
7cac4bdb2607443c2ba6ba5a99871d2e5d09830b
Ruby
krbrewer/advent-of-code-2020
/day3/part2.rb
UTF-8
389
3.09375
3
[]
no_license
file_data = File.read("day3.txt").split trees = [0, 0, 0, 0, 0] file_data.each_with_index do |line, i| x = [i % line.length, (i * 3) % line.length, (i * 5) % line.length, (i * 7) % line.length, i % 2 === 0 ? -1 : i % line.length] x.each_with_index do |slope, j| if slope >= 0 and line[slope] === "#" ...
true
48bfb615641075c871841fb26734e7abb8dd7a84
Ruby
gsterndale/GUnit
/lib/gunit/groundwork.rb
UTF-8
791
2.625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module GUnit class Groundwork attr_writer :message attr_accessor :task # Groundwork.new("my message") # Groundwork.new("my message") { @foo.bar() } # Groundwork.new() { @foo.bar() } def initialize(*args, &blk) self.message = args[0] self.task = blk if blk end d...
true
db4ef51849ff82d2fa2b6d26ab84c25b801615f8
Ruby
matt6390/card-capstone-client
/views/comments_views.rb
UTF-8
594
2.640625
3
[]
no_license
module CommentsViews def comment_show_view(comment) # p comment puts puts "=" * 50 puts "Comment From: #{comment["user"]["name"]}" puts "On Card: #{comment["card_id"]}" puts "At: #{comment["created_at"]}" puts "-" * 50 puts "#{comment["text"]}" puts end def comments_index_view...
true
c0ee9c787cdc9f7eef5565ac001baacca6a634b7
Ruby
MarquesThiago/exercicios_ruby
/Ruby/loop/exercicios.rb/calculadora.rb
UTF-8
1,084
4.25
4
[]
no_license
loop do puts "Digite uma das opções a seguir para:" puts "0 - somar " puts "1 - subtrair" puts "2 - multiplicar" puts "3 - dividir" puts "4 - sair" puts "digite uma opção: " option = gets.chomp.to_i v1, v2 = 0 if option <= 4 && option > -1 puts "digite o pr...
true
4a45df9126b119ad76ed217895ac78233448fe1e
Ruby
fantasyalebar/MOOCademy
/html test/test-ruby/exo_11.rb
UTF-8
85
3
3
[]
no_license
puts "combien de fois ?" number = gets.chomp puts "Salut, ça farte " * number.to_i
true
e4582d10fbca7c2d967b3fa25fd530bf6d3cf2cb
Ruby
Hal9000/livetext
/imports/livemagick.rb
UTF-8
3,894
2.890625
3
[]
no_license
require 'rmagick' module Livemagick # FIXME auto-mangle names include ::Magick def image(args = nil, body = nil) xx, yy, bg = api.args xx, yy = xx.to_i, yy.to_i @image = Image.new(xx,yy) { self.background_color = bg } api.optional_blank_line end def canvas(args = nil, body = nil) colo...
true
1c9739f90c57687e491f36208500973e43254f15
Ruby
wahl77/WDI_Fandangr
/app/models/movie.rb
UTF-8
1,015
2.53125
3
[]
no_license
class Movie < ActiveRecord::Base attr_accessible :description, :name, :duration, :plot, :rating has_many :schedules has_many :reservations, through: :schedules validates :name, presence:true, uniqueness:true validates :duration, presence:true, numericality:{greater_than:0} before_save :update_dura...
true
ebb02dbba82a1b637a67a7c7bd8acbe068ca484f
Ruby
RikeyChen/W2D5-Classwork
/Hash Map LRU Cache/lib/p02_hashing.rb
UTF-8
525
3.171875
3
[]
no_license
# class Fixnum # # Fixnum#hash already implemented for you # end # # class Array # def hash # current_xor = self[0] # self.each_index do |i| # current_xor = current_xor ^ self[i+1] unless i == self.length - 1 # end # # current_xor.hash # end # end # # class String # def hash # end # e...
true
ab9b73952c50924edd57231e990d92c08e574268
Ruby
dgrosenblatt/gatsbee
/app/models/amazon_api.rb
UTF-8
1,605
2.515625
3
[]
no_license
class AmazonApi def self.item_search(book) request = Vacuum.new request.associate_tag = ENV["ASSOCIATE_TAG"] response = request.item_search(query: { "Keywords"=>book.title, "SearchIndex"=>"Books" }) results = response.parse["ItemSearchResponse"]["Items"]["Item"].try(:first) if results.nil? r...
true
5237f49f4cef8e2cb53e93a9c95ff918449f7537
Ruby
konradrog/Ruby_Introduction
/Zadania_przerwa_01/complementarydna.rb
UTF-8
207
3.140625
3
[]
no_license
def complementary_DNA(input_DNA) input_DNA.tr('ATCG', 'TAGC') end puts complementary_DNA("ATTA") #=> "TAAT" puts complementary_DNA("CGGC") #=> "GCCG" puts complementary_DNA("ACGTTAGTTA") #=> "TGCAATCAAT"
true
2d3bee316bb255c45d4b0a1a7524e1c35d8d8f2f
Ruby
bennie/bootstrap-all-the-things
/bootstrap-all-the-things.rb
UTF-8
1,521
2.765625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require "highline/import" ## Gather username, password and input filename username = ARGV[0] password = ARGV[1] filename = ARGV[2] filename = ask('Filename: ') unless filename; abort("#{filename} is not a file") unless File.exist?(filename) username = ask('Username: ') unless username; while ...
true
09e70bd9f747866f4b2ab63b3ed22f82804cf76c
Ruby
Certora/CertoraProverSupplementary
/Tutorials/Challenge/Borda.spec
UTF-8
4,949
2.75
3
[]
no_license
pragma specify 0.1 methods { init_state() points(address) returns uint256 envfree vote(address,address,address) voted(address) returns bool envfree winner() returns address envfree } definition MAXINT() returns uint256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /* After voting, a us...
true
09fc543a4aada85aaa1c6334a884fe52f378ea82
Ruby
marloncarvalho/codility
/oddoccurencesinarray.rb
UTF-8
71
2.734375
3
[]
no_license
def solution(a) a.reduce :^ end puts solution([9,3,9,3,9,7,9,7,10])
true
1dffe9a793118740aa59521c1e88f696f5edaa40
Ruby
des1991/thinknetica
/Lesson8/main.rb
UTF-8
3,196
3.53125
4
[]
no_license
require_relative 'train.rb' require_relative 'passenger_train.rb' require_relative 'cargo_train.rb' require_relative 'wagon.rb' require_relative 'passenger_wagon.rb' require_relative 'cargo_wagon.rb' require_relative 'route.rb' require_relative 'station.rb' require_relative 'menu.rb' class RailRoad include Menu a...
true
d49d127ce737b8676d59514f0613b83c40f2fc29
Ruby
dnguye2/slack-cli
/lib/slack.rb
UTF-8
1,666
3.28125
3
[]
no_license
# !/usr/bin/env ruby require 'httparty' require 'dotenv' require 'table_print' require_relative 'workspace' Dotenv.load def get_user_choice puts "\n" puts "Welcome to the Ada Slack CLI!" print "Please select one of the options: (1) list users (2) list channels (3) select user (4) select channel (5) d...
true
52af792288abec89f052e5f1166a9925d9ad67e5
Ruby
mrjaimisra/Chisel
/lib/chisel.rb
UTF-8
238
3.15625
3
[]
no_license
require '../lib/chiseler' class Chisel attr_reader :input, :output def initialize input = File.read(ARGV[0]) html = Chiseler.new(input).to_html File.write(ARGV[1] + '\n', html) puts "Converted" end end Chisel.new
true
b9e9d50c5f7e01624dabe6cd03508cfc6865e018
Ruby
novelys/validates_siret
/lib/validates_siret.rb
UTF-8
612
2.671875
3
[ "MIT" ]
permissive
# Siret Validation Model helper require "rails/active_support/concern" require 'siret' module ValidatesSiret extend ActiveSupport::Concern module ClassMethods # Method to validate in the receiving model that the value is a valid SIRET Number def validates_siret(*attr_names) configuration = attr...
true
324edcd2b66ae886967e0fcc34a4723266bf4e05
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/raindrops/996572124db844deaa18782650a152f0.rb
UTF-8
267
3.203125
3
[]
no_license
class Raindrops RAINDROPS = {3 => "Pling", 5 => "Plang", 7 => "Plong" } def self.convert(number) conversion = "" RAINDROPS.each { |prime, sound| conversion += sound if number % prime == 0 } conversion.empty? ? number.to_s : conversion end end
true
c29fe6f3e82e93ff0ade5c9eafc2222a3709bc42
Ruby
avysbf/app-academy-open-2020
/sw engineering foundations/startup_project/lib/startup.rb
UTF-8
1,432
3.65625
4
[]
no_license
require "employee" class Startup attr_reader :name, :funding, :salaries, :employees def initialize (name, funding, salaries) @name, @funding, @salaries = name, funding, salaries @employees = [] end def valid_title?(title) self.salaries.key?(title) end def >(start_up)...
true
a0da45d8a0564a22ebcaf56f063ec2d90047434c
Ruby
mchll05/cc_w4_d2_hmk
/models/rock_scissors_paper.rb
UTF-8
756
3.140625
3
[]
no_license
class Rock_Scissors_Paper def initialize end def rock_wins return "rock wins" end def scissors_wins return "scissors wins" end def paper_wins return "paper wins" end def draw return "tie, try again" end def winner_winner_chicken_dinner(hand1, hand2) if hand1 == "rock" && hand...
true
c9df27532be37ced211ca7159372bca21b680c29
Ruby
urbanautomaton/drunken_bishop
/spec/drunken_bishop_spec.rb
UTF-8
3,148
3.203125
3
[]
no_license
require 'spec_helper' require 'drunken_bishop' RSpec.describe DrunkenBishop do subject { described_class.new(hash) } describe '#moves' do context 'for a 128-bit hash' do let(:input) { 'thish ish good sherry' } let(:hash) { Digest::MD5.hexdigest(input) } it 'returns 64 moves' do expe...
true
e7bf31cc5b3c34675dbe78ba8746ad85ae81b53a
Ruby
gcrk/seir41-homework
/Mai (Chi) Nguyen/week-04/SQL-web-app/main.rb
UTF-8
1,206
2.625
3
[]
no_license
require 'sinatra' require 'sinatra/reloader' require 'sqlite3' get '/' do erb :home end ## INDEX get '/food' do @food = query_db "SELECT * FROM food" erb :food_index end ## NEW PAGE get '/food/new' do erb :food_new end ## CREAT post '/food' do query_db "INSERT INTO food (name, country, image) VALUES ('#{p...
true
58d0aa28632b85eed3d42190ccf008ad4cc37e73
Ruby
evansenter/rna_scripts
/nussinov/nussinov_count.rb
UTF-8
1,477
3.578125
4
[]
no_license
module Rnabor class NussinovCount MIN_LOOP_SIZE = 3 INT_CODES = { "A" => 2, "U" => 3, "G" => 4, "C" => 5 } BASE_PAIRINGS = %w|au ua cg gc gu ug|.map(&:upcase).map { |bp| bp.split(//).map { |i| INT_CODES[i] } }.map(&:sort).uniq.map { |i, j| (2 ** i) * (3 ** j) } at...
true
77059d88e4c65f7647ff3276a59b7817d53a84df
Ruby
angelmore/ISW2
/05-PortfolioTreePrinter/Ejercicio/withdraw_from_transfer.rb
UTF-8
526
2.75
3
[]
no_license
require './transaction' class WithdrawFromTransfer < Transaction def initialize(transfer) @transfer = transfer end def self.register_for_on(amount, transfer) transaction = self.new(transfer) transfer.fromAccount.register(transaction) transaction end def transfer_amount -value end ...
true
e952d81f56ee11c83ef6c2c97eb660d6422316f6
Ruby
JzGo/apartment-app
/apartment-api/spec/requests/apartments_spec.rb
UTF-8
2,181
2.703125
3
[]
no_license
require 'rails_helper' describe "Apartments API" do let(:user){ User.create name: 'Bob', email: 'bob@bobber.com', password: 'secret'} it "gets a list of Apartments" do Apartment.create(address_1: '123 where am i', city: 'someplace', postal_code: '12312', state: 'over here', country: 'where', contact_name: use...
true
66e7bce4c76d99008ce7b58f7f0c10af6592f8b1
Ruby
calabash/ios-webview-test-app
/CalWebViewApp/features/support/wait_options.rb
UTF-8
1,989
2.546875
3
[ "MIT" ]
permissive
require 'calabash-cucumber/wait_helpers' module WebViewApp module WaitOpts include Calabash::Cucumber::WaitHelpers # a convenience function for passing wait options to a wait_for* function # @return [Hash] default wait options # # pass this to your wait_for_* functions # # @param [Strin...
true
b0a1f0b520506f926ee2d0b650ac19c0113e3f81
Ruby
solibl/phase-0-tracks
/ruby/gps6/my_solution.rb
UTF-8
4,330
3.75
4
[]
no_license
# Virus Predictor # I worked on this challenge [with: Matthias]. # We spent [2] hours on this challenge. # EXPLANATION OF require_relative # Require relative will pull the file needed for the code for this file. # Require looks through the paths to find the file needed such as a gem or library. require_relative 'stat...
true
1e5bad4a6a47fe0fce8174d9fdce67ff66127589
Ruby
dongfeng676/mini-rack-learn
/example1/tcp_client.rb
UTF-8
152
3.0625
3
[]
no_license
require 'socket' # Opens a TCP connection. tcp_socket = TCPSocket.new 'localhost', 5678 while data = tcp_socket.gets puts data end tcp_socket.close
true
e8ab784d8498b4b898b9b11fc6d67e9401706926
Ruby
raphyduck/crypto_trader
/app/speak.rb
UTF-8
688
2.96875
3
[ "MIT" ]
permissive
class Speaker def self.ask_if_needed(question, no_prompt = 0, default = 'y') ask_if_needed = default if no_prompt.to_i == 0 self.speak_up(question) ask_if_needed = STDIN.gets.strip end ask_if_needed end def self.speak_up(str) puts str $logger.info(str) $email_msg += str +...
true
a5c9fa70f072b73e4dc9532391d4abd0e8df3308
Ruby
GaelMe/ruby_semaine2_jour2
/1_Ruby_Partie_1/1_programmes/5_print.rb
UTF-8
128
2.671875
3
[]
no_license
print "Bonjour, monde !" print "Je le redis un seconde fois, Bonjour Monde !" print "C'est cool de parler, allez, je m'en vas !"
true
789bf9ca1fd301e8c0e4ebbb51bd5d2ad70f17b4
Ruby
ja-laporte/launch-school
/LS_Prep/Arrays/notes.rb
UTF-8
129
3.859375
4
[]
no_license
# is the flatten destructive? array = [1,2,[3,4,5],[6,7]] puts array.flatten # My answer- No it is not. Original array returned.
true
bdc6c9a73a69905177838127ac34604504f07afa
Ruby
Marin-b/KiteSafe
/app/models/spot.rb
UTF-8
754
2.578125
3
[]
no_license
class Spot < ApplicationRecord belongs_to :user has_many :reviews, dependent: :destroy has_many :weather_conditions, dependent: :destroy has_many :advices, dependent: :destroy has_many :photos, dependent: :destroy has_one :difficulty_level, dependent: :destroy # after_create :api_call validates :latitud...
true
5cfff24b372fec4bc4d2fa4130889a2921a1a8e4
Ruby
JoshCheek/project-euler
/066/066.6.rb
UTF-8
1,300
3.5
4
[]
no_license
# https://projecteuler.net/problem=66 require 'bigdecimal' def solution(d) precision, sqrt = 0, Math.sqrt(d) # first use a float b/c it's way the fuck faster loop do first = sqrt.floor n = 1 / (sqrt-first) rest = [] # continued fractional expansion of the sqrt of d # all solutions can be fou...
true
cd71067ee7ce730d1a6a298a8e9931017816b68c
Ruby
ANorwell/InterviewStreet
/kdifference/kdifference.rb
UTF-8
722
4.09375
4
[]
no_license
#A class to find the number of numbers that differ by K in a list of (unique) #integers. class KDifference #Reads input from STDIN def initialize @n, @k = STDIN.readline.split.map{ |x| x.to_i } @numbers = [] STDIN.each(sep=' ') do |num| @numbers << num.to_i end @numbers.sort! end #Cou...
true
b127c47eda17ae811fb0440dde4dddfadd30131d
Ruby
fumitaka1889/before_rails
/DIVE/task/ruby/janken.rb
UTF-8
2,017
4.25
4
[]
no_license
class Player def hand puts "数字を入力してください。" puts "0:グー, 1:チョキ, 2:パー" input_hand = gets.chomp while true if input_hand == "0" || input_hand == "1" || input_hand == "2" return input_hand.to_i else puts "0〜2の数字を入力してください。" input_hand = gets.chomp end end end ...
true
58c41be83f87e69cee3cc9ffde9a405751efba0f
Ruby
mahendrapamidi/ttt-5-move-rb-cb-gh-000
/bin/move
UTF-8
280
2.96875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#!/usr/bin/env ruby require_relative '../lib/move.rb' # Code your CLI Here puts "Welcome to Tic Tac Toe!" board=[" "," "," "," "," "," "," "," "," "] puts "Where would you like you go?" input=gets.strip() number=input_to_index(input) move(board,number,) display_board(board)
true
e8bc154b84238d828f2d7607f3bd76adc11b6cc9
Ruby
chris-arsenault/cellular-automata
/cell_grid.rb
UTF-8
877
3.34375
3
[]
no_license
class CellGrid attr_reader :width, :cells def initialize(width, locality = 1) @locality = locality if width %2 == 0 width += 1 end @width = width @cells = [] @cells.push(Array.new(@width) { '0' }) @drawn = {} end def height @cells.length end def local_state(column) ...
true
8b525902675347432d70446142e942210b8a8d0c
Ruby
ecargiohc/operators-seattle-web-062419
/lib/operations.rb
UTF-8
181
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def unsafe?(speed) if speed == 50 return false elsif speed > 60 return true else return true end end def not_safe?(speed) speed == 50 ? false : true end
true
24eea29e33f482a8c63e63dcf418fa926f6df932
Ruby
wedgey/W1D4
/candidates/main.rb
UTF-8
1,870
3.59375
4
[]
no_license
# This is the main entrypoint into the program # It requires the other files/gems that it needs require 'pry' require './candidates' require './filters' ## Your test code can go here def get_input puts "Please put an input." gets.strip end def greenify(string) "\e[32m#{string}\e[0m" end def redify(string) "\e[...
true
0e5d1bf2b95a6753caaf9ec6e578b0706a5e86ff
Ruby
alphagov/rails_translation_manager
/test/rails_translation_manager/yaml_writer_test.rb
UTF-8
1,401
2.71875
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
require "test_helper" require "rails_translation_manager/yaml_writer" module RailsTranslationManager class DummyWriter include YAMLWriter end class WriterTest < Minitest::Test def setup @output_file = Tempfile.new('fr') end def teardown @output_file.close @output_file.unlink ...
true
8de3cf05d28e2baf57826b12997b5a08f6505010
Ruby
heatseeknyc/heatseeknyc
/spec/concerns/timeable_spec.rb
UTF-8
766
2.9375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'spec_helper' include Timeable::InstanceMethods describe Timeable do it 'can make a pretty date' do datetime = DateTime.new(2014,1,2) expect(pretty_date(datetime)).to eq("Jan 2, 2014") end it 'can make a pretty time' do time = Time.new(2002, 10, 31, 2, 2, 2) expect(pretty_time(time)).to ...
true
393e2572afa0f98047ce3c36c04cdfb61cc42e33
Ruby
agilasverige/agilasverige_site
/app/lib/day.rb
UTF-8
244
3.5
4
[]
no_license
class Day attr_reader :name def initialize(name) @slots = {} @name = name end def add_slot(time, room_1_slot, room_2_slot) @slots[time] = [room_1_slot, room_2_slot] end def slot_at(time) @slots[time] end end
true
264ed7f6b6612dc91a39bd916a5d8f0f2e66332d
Ruby
jodar/exercicios_algoritmos
/exercicios_arthur/folha_15/ex_15_6-1.rb
UTF-8
177
3.4375
3
[]
no_license
a = [3, 7, 10, 2, 1, -1] b = [] a.each do |item| if item > 1 b.push item end end a.clear b.each do |item| if item > 5 a.push item end end print a.inject(:+)
true
8dcaaca2416a948483a8429eb31a73c2d4cbd266
Ruby
YourMechanic/redis_utility
/lib/redis_utility.rb
UTF-8
6,369
2.625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'redis_utility/version' require 'yajl' require 'json' require 'multi_json' # rubocop:disable Metrics/ModuleLength # module RedisUtility namespace for redis methods module RedisUtility extend self KEY_BATCH_SIZE = 1000 # Imports a line-by-line json string def im...
true
1a2633cae3f84e75f767ccf246c93e1b2e3023dc
Ruby
xavier/exercism-assignments
/ruby/prime-factors/prime_factors.rb
UTF-8
284
3.015625
3
[]
no_license
module PrimeFactors require 'prime' def self.for(n) primes = Prime.instance.to_enum factors = [] while n > 1 divisor = primes.next while n > 1 && (n % divisor).zero? factors << divisor n /= divisor end end factors end end
true
d130292c436febe603c68e68e5d326ae46204cd3
Ruby
jwrobes/streaks-api
/app/serializers/serializable_habit.rb
UTF-8
450
2.53125
3
[]
no_license
# Serializers define the rendered JSON for a model instance. class SerializableHabit < JSONAPI::Serializable::Resource type :habits # Add attributes here to ensure they get rendered, .e.g. # # attribute :name # # To customize, pass a block and reference the underlying @object # being serialized: # # ...
true
2b63ccf1bcee17ddba68d8c3e9d37287a4d9b78b
Ruby
jorgeyp/quizzer
/lib/quizzer/quizzer.rb
UTF-8
832
2.765625
3
[ "MIT" ]
permissive
require_relative('options') require 'json' require 'open-uri' module Quizzer class Quizzer def initialize(assessment, quizz, scores) @assessment = assessment @quizz = quizz @scores = scores p assessment p quizz p scores end end class Main def initialize(argv...
true
e035c5c0321815734920c16c0dab055f3b16f652
Ruby
tom24d/footsteps
/Ruby/Pokemon.rb
UTF-8
1,239
3.625
4
[]
no_license
# encoding: UTF-8 class Monster def initialize(name,index,hp,attack) @index = index @name = name @hp = hp @attack = attack end def fightWith(monster) if @attack<monster.attack then elsif @attack>monster.attack then else end end attr_accessor :hp attr_accessor :at...
true
f655d54d64eef49e67f87d2ef7378a9177f379f8
Ruby
Itokiana/startup_tech
/db/seeds.rb
UTF-8
835
2.53125
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
ccc7c0ff8a7f02e1b8c2b7ebdeecbd9027892a78
Ruby
bogado/CopyPasteKiller
/ruby/src/chunk.rb
UTF-8
844
3.265625
3
[]
no_license
require "src/all" class InvalidChunk < RuntimeError end class Chunk include StrS attr :line attr :size def to_s return "#{line}(#{@size})" end def initialize(line, size) if (line + (size - 1) == nil) raise InvalidChunk.new("chunk invalido") end @line = line @size = size end def ==(chunk) r...
true
d15ea5b01ba0d8f8c0a0c3d631e30fb2a885a3be
Ruby
TedsTech/BeginningRuby
/final_Assigbment.rb
UTF-8
2,581
4.125
4
[]
no_license
#Create a parent class Account which has two child accounts, # Checking and Savings.Display the account balance on Checking and Savings account. # Use instance variables, class variables that you have learned. # Use the class variables to find the number of accounts for the customer. class Account @@no_of_accts = 0 ...
true
93087c1a9a32e3e30d88065d03b47e076321d8e0
Ruby
wb4r/TeaLeaf-PrepCourseExercises
/C-methods-6.rb
UTF-8
360
2.75
3
[]
no_license
=begin What does the following error message tell you? ArgumentError: wrong number of arguments (1 for 2) from (irb):1:in `calculate_product' from (irb):4 from /Users/username/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>' /////////////////////////// It states that within the method calculate_product the...
true
c67cf348a9a79e4ccba40482ba3e8b714a092cb8
Ruby
dantrovato/launch-school
/exercises/ruby_basics/strings/1.create_string.rb
UTF-8
50
2.609375
3
[]
no_license
string = String::new string << 'fava' puts string
true
dc34d75f4d55d9ed0a5faf538ed3ede0af55fb30
Ruby
shiva10/DaVinci_Android_Shiva
/lib/em-http/request.rb
UTF-8
386
2.734375
3
[]
no_license
module EventMachine class HttpRequest @middleware = [] def self.new(uri, options={}) uri = uri.clone connopt = HttpConnectionOptions.new(uri, options) c = HttpConnection.new c.connopts = connopt c.uri = uri c end def self.use(klass, *args, &block) @middleware << klass.new(*args, &bl...
true
8bc6a1351fe2dcaee019814c9b80df45be4459ac
Ruby
isabelatreinar/curso_ruby
/pedra_papel_tesoura.rb
UTF-8
859
3.609375
4
[]
no_license
require_relative 'jogadas.rb' class PedraPapelTesoura def jogar i = 0 pj1 = 0 pj2 = 0 while i <= 2 puts 'Digite sua escolha:' puts '[1] Pedra' puts '[2] Papel' puts '[3] Tesoura' puts 'JOGADOR 1' ...
true
e3b77731042bc1b4ad51e562fda8a5ecf1c7d446
Ruby
Flakster/Algorithms-and-data-structures
/sets-maps-pairs.rb
UTF-8
364
3.453125
3
[ "MIT" ]
permissive
def find_pairs(array, k) result = [] map = {} array.each_with_index do |e,i| map[e].nil? ? map[e] = [i] : map[e] << i if !map[k-e].nil? result << [k-e, e] end end result end #p find_pairs([1, 9, 11, 13, 2, 3, 7], 12) # => [[1, 11], [9, 3]] p find_pairs([17, -20, 21, -3, 33, 10, 6, -11, 19,...
true
b1373bfec0e2aa0cead07d809d1986bb8b300480
Ruby
ToddRizley/shopping_cart
/shopping_cart_backend/app/models/product.rb
UTF-8
487
2.578125
3
[]
no_license
class Product < ApplicationRecord has_many :carts has_many :users, through: :carts def prepare_inventory product_list = [] Product.all.each do |prod| if product_list.detect {|pr| pr.keys[0] == prod["title"] } product_list.select {|pr| pr.keys[0] == prod["title"] }[0][prod.title][:quant...
true