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
dc48c7a640260e50b40884d83df901ccf75f8f33
Ruby
iancanderson/ormivore
/app/converters/account_sql_storage_converter.rb
UTF-8
752
2.546875
3
[]
no_license
module App class AccountSqlStorageConverter STATUS_MAP = Hash.new { |h, k| raise ArgumentError, "Status #{k.inspect} not known" }.update( active: 1, inactive: 2, deleted: 3 ).freeze REVERSE_STATUS_MAP = Hash.new { |h, k| raise ArgumentError, "Status #{k.inspect} not know...
true
2abbf5ad4639a7aa4da0a232d30795465ada485e
Ruby
javieku/shortest-paths-revisited-np-complete-problems-coursera
/week3/tsp.rb
UTF-8
2,536
3.765625
4
[]
no_license
require 'singleton' FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) FIXNUM_MIN = -(2**(0.size * 8 - 2)) class TravellingSalesmanHeuristic attr_reader :cost attr_reader :path def execute(input) cities = input.clone current_city = cities.shift @cost = 0 @path = [] path.push(current_city) start = T...
true
9114a27f837079f9d22f7751f459110c350c1cb9
Ruby
eliottealderson/Week_3_Morpion
/class_tableau.rb
UTF-8
3,605
3.171875
3
[]
no_license
#3ème partie : # Maintient l'état du tableau de jeu require_relative 'class_joueur' class Tableau # Initialiser def initialize # Configuration de la structure de données à vide @tableau = Array.new(3){Array.new(3)} end # retourne_etat_du_tableau def retour...
true
f19e166181fd872bc656370bd79b6e9d7b20502b
Ruby
Zhann/Dinklebot
/lib/plugins/subchecker.rb
UTF-8
1,399
2.796875
3
[]
no_license
require 'cinch' require 'snoo' # This class needs refactoring! # original source: i # https://gist.githubusercontent.com/makzu/4166608/raw/caeb58500a4d4496ec41bb9114f6d05f7587e116/subchecker.rb class SubChecker include Cinch::Plugin def initialize(*args) super @reddit = Snoo::Client.new listings = get...
true
40402314f91db8a673298318349df3806e088064
Ruby
kalifs/notonthehightstreet
/specs/app/product_spec.rb
UTF-8
371
2.65625
3
[]
no_license
require 'minitest/autorun' require 'product' describe Product do def product @product ||= Product.new(code: 'the_code', name: 'the name', price: 9.99) end it 'has code' do assert_equal('the_code', product.code) end it 'has name' do assert_equal('the name', product.name) end it 'has price' ...
true
11c403af378e44200a2187d667ddaeebc25d429c
Ruby
enowmbi/Ruby-Exercises
/exponentiation.rb
UTF-8
162
3.578125
4
[]
no_license
=begin Exponentiation x^n = x * x^n-1 =end def pow(x,n) return 1 if n == 0 return x * pow(x,n-1) end puts pow(2,10) puts pow(3,10) puts pow(5,10)
true
aaead7bdcef3971e66eeab4897495e4069767c0c
Ruby
massun1999/fourth-wave
/spec/models/user_spec.rb
UTF-8
7,080
2.546875
3
[]
no_license
require 'rails_helper' RSpec.describe User, type: :model do before do @user = FactoryBot.build(:user) end describe 'ユーザー新規登録' do context '新規登録ができる時' do it "全ての項目が正しく入力されている時" do expect(@user).to be_valid end end context '新規登録ができない時' do it "nicknameが空のとき" do @u...
true
82b333d7d30ca6f89358d99df3dc22ac8e3a0b3f
Ruby
lshimokawa/activegraph
/spec/unique_class.rb
UTF-8
700
2.71875
3
[ "MIT" ]
permissive
module UniqueClass @counter = 1 class << self def _unique_random_number "#{Time.now.year}#{Time.now.to_i}#{Time.now.usec.to_s[0..2]}".to_i end def set(klass, name = nil) name ||= "Model_#{@counter}_#{_unique_random_number}" @counter += 1 klass.class_eval <<-RUBY def sel...
true
d3e53296669834ed278188129edefd593a114a19
Ruby
MAWAAW/rogue-like
/carte/Coord.rb
UTF-8
451
3.3125
3
[]
no_license
#== Définition de la classe coord pour la gestion des cases dans une matrice class Coord @coordX @coordY attr_accessor :coordX, :coordY private_class_method :new #=== redéfinition de initialize def initialize(x,y) @coordX,@coordY = x,y end #=== Constructeur de coord def Coord.c...
true
213fec00e9e02e48a4e0574f20cf47fda2b9d4d0
Ruby
Joewebsta/futbol
/lib/league_statistics.rb
UTF-8
2,279
2.8125
3
[]
no_license
module LeagueStatistics def count_of_teams teams.count end def best_offense best_offense_id = avg_goals_per_game_by_team(game_teams).max_by { |_id, goals| goals }[0] team_name_by_id[best_offense_id] end def worst_offense worst_offense_id = avg_goals_per_game_by_team(game_teams).min_by { |_id...
true
0fcb3222999eb9d4e9dd0f47367ffd76614ed4cf
Ruby
renatobiohazard/JogoRuby
/Game/jogmaquina.rb
UTF-8
449
2.75
3
[]
no_license
require 'gosu' require 'Gerar_cartas' class Jogmaquina def initialize (window) @calculo=0 @maior=0 @mjogada=Gerar_cartas.new(self) end def calcular(cal) if(cal[0]>cal[1] and cal[0]>cal[2]) then @maior=cal[0] @mjogada.jogadamaquina(@maior) elsif (cal[1]>cal[0] and cal[1]>cal[2]) then @maior=cal[1] @mjogada.j...
true
bfe4573981bbb4520fa41f0f8343699412eb729c
Ruby
marlonmarcos21/alpha7
/app/lib/hacker_news_request.rb
UTF-8
735
2.5625
3
[]
no_license
class HackerNewsRequest attr_reader :net_http, :uri ENDPOINT = 'http://hn.algolia.com/api/v1/search_by_date'.freeze def initialize(**args) args.reverse_merge!( hitsPerPage: 10, # limited to 10 so pagination can be used, only has 13 results, default was 20 restrictSearchableAttributes: 'url', ...
true
fa35e4e2b8ea2a75759d159ed3223b20b3ab5c24
Ruby
laurenkruczyk/Dive_In
/dive_in/spec/features/visitor_search_for_divesite_spec.rb
UTF-8
1,240
2.515625
3
[]
no_license
require 'spec_helper' feature 'visitor can search for a divesite based on his preferences', %Q{ As an unauthenticated user I can search for a divesite based on certain criteria So I can find the perfect place to dive } do #Acceptance Critera #A visitor can search for a divesite given: #1. Category 2. Month 3. C...
true
cfd0aced5d4a4c41ca4a273a26dee9c42d38dcfc
Ruby
cmirnow/Tic-Tac-Toe-AI-with-Neural-Network
/bin/starting.rb
UTF-8
443
2.59375
3
[ "MIT" ]
permissive
require_relative './game.rb' puts ' ' puts '********* MASTERPRO.WS PROJECT ***********' puts 'Welcome to Tic Tac Toe with Artificial Intelligence!' puts '--------------------------------' puts 'Loading data...' puts 'Please wait.' puts ' ' class Starting Array_of_games = CSV::WithProgressBar.read('ss.csv').each.to_a...
true
67648a2b943e6842f3770989b6d9a569a1b7b83f
Ruby
alxersov/bootcamp
/task-03/notes.rb
UTF-8
1,269
3.515625
4
[]
no_license
FILE_NAME = 'notes.txt' def help_command puts %{ Available commands: -a or --add adds an item into the list -l or --list displays the list -r or --remove removes the n-th note from the list -c or --clear clears the list -h or --help shows list of availa...
true
5dd870bf60b96358cff8e6c6dd104e0b36b7f1d1
Ruby
russellschmidt/bloc_works
/lib/bloc_works/router.rb
UTF-8
654
2.578125
3
[ "MIT" ]
permissive
module BlocWorks class Application def controller_and_action(env) # this just returns elements no. 2, 3 & assigns to variables # then adjusts to proper naming conventions # this becomes a reference to the ExampleController class # not just the string 'ExampleController' _, controller, action, _ = ...
true
409ffbd4602375258b57debc4023fcc883da2bb8
Ruby
cankayakubra/RubyProject
/ortas.rb
UTF-8
1,836
3.46875
3
[ "Apache-2.0" ]
permissive
class Orta <<<<<<< HEAD def initialize a @a = a end def oyunabasla ran=rand(0..1) if ran==1 sira=1 @a.yazdir("PC basliyor") else sira=2 @a.yazdir("Oyuncu basliyor") ======= def initialize @ran = nil @b = nil @sira = nil @cev=nil @isim=nil end def oyunabasla @a.yazdir("Kullani...
true
8dfb96f79e4b8d144ccdf972b82f29eb46183674
Ruby
moresmiles/ttt-10-current-player-v-000
/lib/current_player.rb
UTF-8
219
3.3125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn_count(board) counter = 0 board.each do |count| if count == "X"||count == "O" counter += 1 end end counter end def current_player(board) if turn_count(board) % 2 == 0 "X" else "O" end end
true
fc99a2a2839fd53c5fa51d152f3eb8987387f877
Ruby
montch/adjective_animal
/spec/adjective_animal_spec.rb
UTF-8
1,927
3.609375
4
[ "MIT" ]
permissive
require 'spec_helper' describe AdjectiveAnimal do it "creates a name using adjective_animal" do adjective_animal = AdjectiveAnimal.new expect(adjective_animal.adj.length).to be > 0 expect(adjective_animal.ani.length).to be > 0 end it "creates a name using the same starting letter as the symbol or...
true
0d07a89ef026c2af403a145355d4ea48f9d7fcce
Ruby
cbonnet99/xero_gateway
/lib/xero_gateway/phone.rb
UTF-8
1,306
2.828125
3
[ "ISC" ]
permissive
module XeroGateway class Phone attr_accessor :phone_type, :number, :area_code, :country_code def initialize(params = {}) params = { :phone_type => "DEFAULT" }.merge(params) params.each do |k,v| self.instance_variable_set("@#{k}", v) ## create and initialize an in...
true
cc1a00439379afb2df9661de9767f14edb0ae5ff
Ruby
nakaaza/AtCoder
/practice/practice_contest/B.rb
UTF-8
78
2.984375
3
[]
no_license
n = gets.to_i q = gets.chomp.to_i arr = ('A'..'Z').to_a.slice(0, n) puts arr
true
df86ed14a5dd70a3131f4d626224222f1eb939f6
Ruby
surfer8137/KataBankOCR
/lib/accountmanager.rb
UTF-8
281
2.828125
3
[]
no_license
require_relative 'checksum.rb' class AccountManager class << self def check(number) valid = Checksum.calculate(number) return number + ' ILL' if valid == -1 return number + ' ERR' if valid != 0 return number if valid == 0 end end end
true
313f0b6af26567ecb0224cbc0cbb29a58f550105
Ruby
kennyfrc/puzzlenode-solutions-1
/13_chess_validator/lib/rules/move_validator.rb
UTF-8
769
2.953125
3
[]
no_license
require 'rules/rulebook' class MoveValidator def initialize(move) @move = move end def valid? valid_movement? && valid_path? && destination_ok? && !check? end def valid_movement? raise "#valid_movement? must be defined by subclasses" end def valid_path? @move.board.unobstructed_path_be...
true
6b521132caab283d4e198d588d7d7b681f366c4a
Ruby
macosgrove/toy-robot
/lib/toy_robot.rb
UTF-8
924
3.25
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative "factory" # Entry point. Responsible for calling the Factory to initialise the system, then running the input loop. class ToyRobot attr_accessor :verbose, :reporting, :mapping, :output def initialize(input_stream, output_stream) @input = input_stream @output...
true
dd3265568a8bd8a8a1e2c56680de945959ede8b2
Ruby
AMaleh/glimmer-dsl-swt
/samples/elaborate/tic_tac_toe/board.rb
UTF-8
3,915
3.359375
3
[ "MIT" ]
permissive
# Copyright (c) 2007-2021 Andy Maleh # # 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, # d...
true
2a8bb3069ab18e285ffea2675fb217535156f6f9
Ruby
lychees/em-midori
/lib/em-midori/core_ext/promise.rb
UTF-8
1,336
3.203125
3
[ "MIT" ]
permissive
## # Meta-programming String for Syntactic Sugars # Referenced from {Qiita}[http://qiita.com/south37/items/99a60345b22ef395d424] class Promise # @param [Proc] callback an async method def initialize(callback) @callback = callback end # Define what to do after a method callbacks # @param [Proc] resolve wh...
true
1ade3b66e234349c28f66a6b1f782d7e8dbafa1b
Ruby
sharat94/family_tree_sharat
/bin/family_tree
UTF-8
1,380
3.59375
4
[]
no_license
#!/usr/bin/env ruby require './lib/person' require './lib/kingdom' while true # STDIN puts "Please enter the selection:" puts "1. Find relatives" puts "2. Add new family member" puts "3. Find maximum number of girl daughters" puts "4. Find the relation" input = gets.strip case input.to_i when 1 puts...
true
2e19be462928047f9737e79d96bc8cebad61eb53
Ruby
Lebeil/RubyExo
/exo_20.rb
UTF-8
609
3.828125
4
[]
no_license
puts "merci de saisir un nombre entre 1 et 25 :" chiffre = gets.chomp.to_i if chiffre > 0 && chiffre < 25 chiffre.times do |i| num = i + 1 num.times do |i| print "#" end puts end else puts "Attention entre 0 et 25, recommence !" end ###### EN VERSION "WHILE" ####### # puts "merci de sais...
true
ef4ba6da03317b562032a14e82d6f46f01c4195e
Ruby
sparklemotion/nokogiri
/test/xml/test_attr.rb
UTF-8
4,517
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LicenseRef-scancode-other-copyleft", "LGPL-2.1-only", "X11", "GPL-1.0-or-later", "MPL-2.0", "LicenseRef-scancode-x11-xconsortium-veillard", "LicenseRef-scancode-warranty-disclaimer", "Zlib", "AGPL-3.0-only", "LGPL-2.0-o...
permissive
# frozen_string_literal: true require "helper" module Nokogiri module XML class TestAttr < Nokogiri::TestCase def test_new 100.times do doc = Nokogiri::XML::Document.new assert(doc) assert(Nokogiri::XML::Attr.new(doc, "foo")) end end def test_new_...
true
cecbc090ce6b7e1acbfc9b12b2874a7dc12d5c5d
Ruby
ese-varo/rubyDojo
/hackerrank/jumping-on-clouds.rb
UTF-8
276
3.3125
3
[]
no_license
def jumping_on_clouds(c) required_jumps = 0 pos = 0 p c puts pos while pos < c.length - 1 (pos + 2 < c.length) && c[pos + 2].zero? ? pos += 2 : pos += 1 required_jumps += 1 puts pos end required_jumps end puts jumping_on_clouds([0, 0, 0, 1, 0, 0])
true
59fbb99257caaad67eb2da1ad1130febb5fbd6d3
Ruby
Sravya9K/class_topics
/app/models/book.rb
UTF-8
469
2.546875
3
[]
no_license
class Book < ActiveRecord::Base self.per_page = 3 validates :name, uniqueness: true validates :author, presence: true #validates :cost, numericality: true validates :name, length: { minimum: 3, message: " - Please enter minimum 3 chars for book name"} before_save :merge_book_name after_destroy :merge_book_name...
true
dbf0c26da5eb008c7e68dd74d12870d57572618a
Ruby
justinhwu/alphabetize-in-esperanto-dc-web-career-040119
/lib/alphabetize.rb
UTF-8
192
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
ESPERANTO_ALPHABET = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz" def alphabetize(arr) # code here arr.sort_by do |a| a.split("").map do |b| ESPERANTO_ALPHABET.index(b) end end end
true
637a075331ad382460a0e7a823d8a78b48faa7b1
Ruby
dasch/ruby-bencode
/test/benchmark/encoding.rb
UTF-8
226
2.53125
3
[ "MIT" ]
permissive
$:.unshift(File.dirname(__FILE__)+"/../../lib") require 'benchmark' require 'bencode' Benchmark.bmbm do |x| x.report("Encoding an array of integers") do 100.times do ((1..50).to_a * 100).bencode end end end
true
ef7e993fda554f39fa57bc87bf0889496865ab80
Ruby
tomwot/CodeIQ
/triangle_calc/trunk/triangle_calc.rb
SHIFT_JIS
2,082
3.28125
3
[]
no_license
#encoding: Windows-31J # CodeIQFuwFOp`H񓙕ӁHv # https://codeiq.jp/ace/nabetani_takenori/q1097 # ^ꂽOp`̎ނ𓚂B # wȂ̂ŗ]藝͖{͈Ⴄނ̎Op`ɕނ”\B # ܂ł͍lȂB def pick_num(source, prm) prm.map do |pr| if (answer = (source.find{|s| s[/#{pr}/] || s[/#{pr.reverse}/]})) answer[/\d+/].to_f else nil en...
true
2e5b601010011faa84160076e3d1e6b1e8d68c13
Ruby
smunozmo/oop-school-library
/main.rb
UTF-8
917
3.734375
4
[]
no_license
require './app' puts "\nWelcome to School Library App!".yellow # rubocop:disable Metrics/CyclomaticComplexity def main app = App.new loop do puts puts 'Please choose an option by entering a number:'.yellow puts '1 - List all books'.green puts '2 - List all people'.green puts '3 - Create a per...
true
a04764de7133aeeafbb33e6d9e36b5029aeb04df
Ruby
wallacecnzto/ruby_codes
/ruby_codes/list.rb
UTF-8
77
2.765625
3
[]
no_license
names = ["wallace", "val", "aristotelina"] for name in names puts name end
true
6251bf71bddbcd316f984cce32a80ee3812596e5
Ruby
randyleighton/address-book-ruby
/lib/contact.rb
UTF-8
871
3.109375
3
[]
no_license
class Contact @@all_contacts = [] def Contact.all @@all_contacts end def Contact.clear @@all_contacts = [] end def save @@all_contacts << self end def initialize(name) @name = name @phone_numbers = [] @addresses = [] @emails = [] end def add_email_address(address) ...
true
002b3805928e430037dcff1f85e3fc26aca84bc9
Ruby
sullivant/euler
/ruby/34.rb
UTF-8
201
3.375
3
[]
no_license
require 'euler.rb' curious = Array.new() 3.upto(1000000) do |n| sumDigFactors = (n.to_s.split(//).collect{|d| d.to_i.factorial}).sum curious << n if n == sumDigFactors end puts curious.join("|")
true
b0766db19e45f9fd75aa602c4680a9b388912265
Ruby
thiagofb84jp/automation-project
/XX - Backup Project/xx_backup/ruby_rails/xx_archives/exercicios-ruby-2/1 - estrutura-sequencial/18-tamanho-arquivo-download.rb
UTF-8
532
3.890625
4
[]
no_license
#1.18 Faça um programa que peça o tamanho de um arquivo para download (em MB) e #a velocidade de um link de Internet (em Mbps), calcule e informe o tempo #aproximado de download do arquivo usando este link (em minutos). puts "Qual o tamanho do arquivo para download (em MB)?" tamArquivo = gets.to_i puts "Qual a veloci...
true
30f83a4b8ab247dd275faa906241f8abb64cb581
Ruby
bkingon/earthquakes
/app/services/map_marker_attributes.rb
UTF-8
505
2.796875
3
[]
no_license
class MapMarkerAttributes def initialize(earthquake) @earthquake = earthquake end def time Time.at(earthquake['properties']['time'] / 1000).to_datetime.strftime('%B %d, %Y - %I:%M%p') end def latitude earthquake['geometry']['coordinates'][1] end def longitude earthquake['geometry']['coo...
true
7b9a92a0256a8a289bc871611cbcee3c8201f439
Ruby
lean4728/scraping_app2
/app/models/scraping4.rb
UTF-8
3,050
2.890625
3
[]
no_license
require 'mechanize' HTTPS = "https:" LINK_0 = "//music.j-total.net/sp/as/" LINK_2_DIR = "//music.j-total.net/dbsp/" ERRMSG_GET_LINK = "GETリクエストエラー発生" XPATH_LINK_0 = "/html/body/table[4]/tr/td/div/a" XPATH_LINK_1 = "/html/body/ul[3]/li/a" XPATH_LINK_2 = "/htm...
true
e7f71dd2e68d98d64996bd07c97fba562a607117
Ruby
toddt67878/Course_Ruby
/ArrayII/Remove_Array_Items_that_Exist_in_Another_Array.rb
UTF-8
223
3.640625
4
[]
no_license
a = [1,1,2,2,3,4,5] b = [1, 2, 3] def custom_subtraction(arr1, arr2) final = [] arr1.each { |value| final << value unless arr2.include?(value) } final end p custom_subtraction(a, b) p ["a", "a", "b"] - ["a", "c"]
true
1566dd7bb3ebd2ebb9228c89a687ce84ec1e1275
Ruby
nick-over/swap
/Translator/models/lang_value.rb
UTF-8
406
3.28125
3
[]
no_license
# frozen_string_literal: true # Languages module module LangValue ENG = 'английский' RUS = 'русский' def self.all_langs [ENG, RUS] end def self.get_lang_by_match(match) if !match.match(/[а-яА-Я ёЁ]/).nil? RUS else ENG end end def self.get_another_lang(lan...
true
eacb752235488b12e21845764fb3452d629e028c
Ruby
Atnevon/ruby_programs
/2015-08-10/finals/dice_game_example.rb
UTF-8
522
4.21875
4
[]
no_license
def roll dice_array = [1, 2, 3, 4, 5, 6] first_roll = dice_array.sample second_roll = dice_array.sample total = first_roll + second_roll return total end user_score = 0 comp_score = 0 while true user_roll = roll comp_roll = roll if user_roll == comp_roll puts "Tie" elsif user_roll > comp_roll user_scor...
true
5bc9b2701f9e0e4ce059c886ded55bd9a60f1654
Ruby
Crosse/aoc2020
/day01_b.rb
UTF-8
367
3.015625
3
[]
no_license
#!/usr/bin/env ruby input = File.read("input/day01") input.each_line do |x| xi = x.to_i input.each_line do |y| yi = y.to_i input.each_line do |z| zi = z.to_i if (xi + yi + zi) == 2020 then puts "x=#{xi}, y=#{yi}, z=#{zi}, x*y*z=#{xi*yi*zi}" ...
true
ceacdebcaf1401a796dfb13b9af82906ac002bff
Ruby
Kadaverin/library_home_task
/f.rb
UTF-8
4,654
3.296875
3
[]
no_license
# $LOAD_PATH.unshift( File.join( File.dirname(__FILE__), 'library' ) ) $:.unshift File.dirname(__FILE__) require 'faker' require 'Human' class Author < Human attr_accessor :biography def initialize(name, biography) @biography = biography super(name) end end class Reader < Human attr...
true
2f2999a38937419a4766085142a7658e7cc8af90
Ruby
keldonia/poker
/exercises/lib/towers_of_hanoi.rb
UTF-8
864
3.53125
4
[]
no_license
class TowersOfHanoi attr_reader :towers, :winset def initialize(towersize) @winset = (1..towersize).to_a.reverse @towers = {1 => @winset, 2 => [], 3 => []} end def move(from_tower, to_tower) if !towers[from_tower].empty? && !towers[to_tower].empty? && towers[to_tower].last < towers[from_t...
true
376039b9711e1915c828d3e0f7a6c7524d7e661b
Ruby
justinkizer/a-A-Daily-Projects
/W1D3/fibonacci.rb
UTF-8
519
4.125
4
[]
no_license
def fib_r(n) return nil if n < 1 return [1] if n == 1 return [1,1] if n == 2 array = fib_r(n - 1) new_element = array[array.length - 2] + array[array.length - 1] array << new_element end def fib_i(n) return nil if n < 1 return [1] if n == 1 return [1,1] if n == 2 array = [1,1] for i in 3..n do ...
true
908748b34c9c983b00d40fbfe75512d8f7e2203c
Ruby
GTi-Jr/sistema-hotel-fluxo
/app/helpers/transaction_helper.rb
UTF-8
453
2.734375
3
[]
no_license
module TransactionHelper class << self #Verificar se o produto não tem um preço definido #Exemplo: hospedagem #Se não tiver um preço: pegar o preço da tabela de transações e dividir pela quantidade #Objetivo: obter o preço unitário de produtos que não tem um valor definido def priceNull(priceUnit,pric...
true
7fedbb07488f46d863b4b1c39b1472fb75eb05cb
Ruby
allforkedou/nextacademyMY
/week1/chessboard.rb
UTF-8
770
2.90625
3
[]
no_license
chessboard = Array.new(8){Array.new(8)} first_line = ['Rook', 'Knight', 'Bishop', 'Queen', 'King', 'Bishop', 'Knight', 'Rook'] second_line = ['Pawn']*8 for i in 0..7 #complete first line chessboard[0][i] = 'B '+ first_line[i] chessboard[7][i] = 'W '+ first_line[i] #complete second line chessboard[1][i] = 'B...
true
54f16e23061bcfc11d6f87a99d2624a3d6913472
Ruby
gpclaridge/smart-answers
/test/unit/calculators/country_name_formatter_test.rb
UTF-8
2,148
2.609375
3
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
require_relative '../../test_helper' require 'gds_api/test_helpers/worldwide' module SmartAnswer::Calculators class CountryNameFormatterTest < ActiveSupport::TestCase include GdsApi::TestHelpers::Worldwide context '#definitive_article' do setup do @formatter = CountryNameFormatter.new en...
true
ea5181c24b36c3c43e87c55e116622a18fc9ca25
Ruby
Sufl0wer/summer-2019
/3634/2/helpers/save_files.rb
UTF-8
878
2.578125
3
[]
no_license
require_relative 'image_loader' class SaveFiles attr_reader :session, :session_key, :payload def initialize(session, session_key) @session = session @session_key = session_key end def path @path ||= "public/#{session_key}/#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}" end def save_files FileU...
true
8395ebb577ea040c6ae20f5e5eefb27fbec326ff
Ruby
kako-jun/Materiaroom
/ruby/rename_by_exif.rb
UTF-8
4,808
2.53125
3
[ "MIT", "CC-BY-3.0" ]
permissive
# -*- coding: utf-8 -*- require 'kconv' require 'fileutils' require 'exifr' class RenameByExif def initialize() end def run( *args ) # 引数をチェック if ARGV.size == 0 || ARGV.size > 2 then babel() puts 'Usage: ' + $PROGRAM_NAME + ' [src_dir_path] ([dst_dir_path])' exit end # -U 付きで...
true
0cddd4b284f0be7e45e711e07602807342836fd2
Ruby
BriOD/-sinatra-assessment-cash-game-tracker
/app/models/user.rb
UTF-8
310
2.703125
3
[ "MIT" ]
permissive
class User < ActiveRecord::Base validates_uniqueness_of :username has_many :sessions has_secure_password def total_profit #this method will display a users total profit. won = [] self.sessions.each do |session| won << session.amount_won.to_i end won.inject(0, :+) end end
true
09f21d4eb469303750f43514a80fd8530db5006c
Ruby
kgdskc/sample_app
/ruby/lesson6.rb
UTF-8
499
3.265625
3
[]
no_license
total_price = 100 if total_price > 100 puts "みかんを購入。所持金に余裕あり" end if total_price == 100 puts "みかんを購入。所持金は0円" end if total_price < 100 puts "みかんを購入することができません。" end # if total_price > 100 # puts "みかんを購入。所持金に余りあり。" # elsif total_price == 100 # puts "みかんを購入。所持金は0円。" # else # puts "みかんを購入することができません。" # end
true
8e40796b1c0ba4a0381ab1f736298376b88a2875
Ruby
Askaks01/furima-31061
/spec/models/user_spec.rb
UTF-8
4,134
2.609375
3
[]
no_license
require 'rails_helper' describe User do before do @user = FactoryBot.build(:user) end describe 'ユーザー新規登録' do context 'ユーザー新規登録がうまくいくとき' do it 'nickname,email,password,password_confirmation,last_name,first_name,last_kana,first_kana,birthdayが存在すれば登録できる' do expect(@user).to be_valid end ...
true
a2ab305baff4caff1195359d01824e5c4b3aad15
Ruby
shamimevatix/activeadmin-3rd-level-menu
/active_admin_nested_menu.rb
UTF-8
5,236
2.609375
3
[]
no_license
module ActiveAdmin # Each Namespace builds up it's own menu as the global navigation # # To build a new menu: # # menu = Menu.new do |m| # m.add label: 'Dashboard', url: '/' # m.add label: 'Users', url: '/users' # end # # If you're interested in configuring a menu item, take a look ...
true
26b78e804b8c403c1cf56dbe5844e1f6527f9cd6
Ruby
Ckath/yossarian-bot
/plugins/user_points/user_points.rb
UTF-8
2,214
2.890625
3
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
# frozen_string_literal: true # user_points.rb # Author: William Woodruff # ------------------------ # A Cinch plugin that provides points for users for yossarian-bot. # ------------------------ # This code is licensed by William Woodruff under the MIT License. # http://opensource.org/licenses/MIT require "yam...
true
1d28c884c487392a034d8a49068879d1ddfbbb6d
Ruby
rawerner/Hip-Publisher
/test/test_importing_songs.rb
UTF-8
1,720
2.796875
3
[]
no_license
require_relative 'helper' require_relative '../lib/importer' class TestImportingSongs < HipPublisherTest def import_data Importer.import("test/sample_songs.csv") end def test_the_correct_number_of_songs_are_imported import_data assert_equal 5, Song.all.count end def test_songs_are_imported_full...
true
fad4572122609aba74c4368a3a14d939bce0c9f3
Ruby
Capstory/email_testing
/app/helpers/test_program_visits_helper.rb
UTF-8
513
2.625
3
[]
no_license
module TestProgramVisitsHelper def version_filter(visits_array, test_version_sought) filtered = visits_array.select do |v| v.test_version.to_i == test_version_sought end return filtered end def phaseline_filter(visits_array, phaseline_sought) filtered = visits_array.select do |v| case phaseline_sought...
true
7248716c5bc89c64660888c82ca4c04a97b58c93
Ruby
kikitux/vault-sampleapp-ruby
/app.rb
UTF-8
979
2.671875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # -*- mode: ruby -*- # vi: set ft=ruby : # Sample app # Uses the vault client tools to: # - connect to vault # - read and print the value of an existing secret (secret/hello) # load libraries require "vault" require "mysql" # load vault-token vaulttokenfile = File.read '/vagrant/vault-token' vau...
true
410381eb68746f4d9ca11fc0064345a3a9bfcf43
Ruby
Hack-Slash/fortune
/app/controllers/fortunes_controller.rb
UTF-8
699
2.65625
3
[]
no_license
class FortunesController < ApplicationController @@page_count = 0 def tell_your_fortune # make an array of fortunes fortunes = ["You will be rich", "You will be a happy person", "Not as nice of a prediction"] # pick a random one fortunes.shuffle! @prediction = fortunes[1] # show that to the ...
true
ba529a82f52fc6d337ba54b502f05c02ab274669
Ruby
LeoVergara1/cursoRubyOnRails
/Bloques en ruby/block3bloque.rb
UTF-8
209
3.71875
4
[]
no_license
def suma(n1,n2, &bloque) puts "Hola desde nuestra funcion" resultado = n1 + n2 bloque.call resultado end suma(6,5) do |resultado| puts "El resultado de nuestra operación es #{resultado}" end
true
1fd58bcb7b218a176975df0a662ff76b1f37884e
Ruby
Merkrow/tasks
/count.rb
UTF-8
432
3.46875
3
[]
no_license
def beauty(s) arr = [] a = s.downcase.split('').sort() l = a.size-1 prev = 0 max = 26 sum = 0 for i in 0..l if a[i] != prev arr.push(1) else arr[arr.size-1] += 1 end prev = a[i] end a = arr.sort().reverse() l = a.length-1 for i in...
true
0144fc924bd3afc01c1e4286e94d9cea3b0bce85
Ruby
michelleamazinglin/aA-classworks
/W3D2/memory_puzzle_annotated/card.rb
UTF-8
2,371
4.40625
4
[]
no_license
# difference between shuffle and shuffle! # shuffle! 改变原来的array # shuffle 不改变原来的array ###### https://ruby-doc.org/core-2.7.0/Array.html#method-i-shuffle # a = [ 1, 2, 3 ] #=> [1, 2, 3] # a.shuffle #=> [2, 3, 1] # a #=> [1, 2, 3] # a = [ 1, 2, 3 ] #=> ...
true
eeec6fd8e093178c8d017e8b8dd84f359751ea59
Ruby
oreeve/chillow
/lib/modules.rb
UTF-8
126
2.59375
3
[]
no_license
module Modules def remove_one @space += 1 @objects.pop end def full? @space == 0 ? true : false end end
true
904dfbec29c8829afb5dcd8f97736a5ff1649d68
Ruby
SurendraSapkale/Terminal_APP
/src/classes/testfile.rb
UTF-8
685
2.828125
3
[]
no_license
File.open("dairy.txt", "r") input_lines = File.readlines("dairy.txt") output_lines = Array.new(0) input_lines.map do |line| line_contents = line.split if line_contents[0] == "Milk" add_quantity = line_contents[1].to_i + 2 line_contents[1] = add_quantity output_lines << line_contents.join(' ') else ...
true
dc20027524035b8926e6be464d2854a59af875bd
Ruby
julioprotzek/iddd_ruby
/test/domain/identity/full_name_test.rb
UTF-8
3,392
2.828125
3
[]
no_license
require './test/test_helper' class FullNameTest < IdentityAccessTest FIRST_NAME = 'Zoe' LAST_NAME = 'Doe' MARRIED_LAST_NAME = 'Jones-Doe' WRONG_FIRST_NAME = 'Zeo' test '#with_changed_first_name' do name = FullName.new( first_name: WRONG_FIRST_NAME, last_name: LAST_NAME ) name = name....
true
9969d8bf3649fe441275579865a72d3ab6ff9cf9
Ruby
scheibo/dat.rb
/bin/test
UTF-8
1,027
2.671875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require '../lib/dat' include Dat require 'pp' d = Dict.new l = Logic.new(d) g = LogGame.new(:players => ['p1', 'p2']) def to_dict_entry(word, from) str = "#{word.clone} {#{from}}" str << (word.type ? " (" << word.type << ") " : " ") str << word.definition.strip << " " unless word.definition.s...
true
3304bb59352e19262b11dc867f2b5b631fa30736
Ruby
mwagner19446/wdi_work
/w03/d01/Zack_Stayman/grammys/lib/grammy.rb
UTF-8
963
3.703125
4
[]
no_license
require "pry" class Grammy @@Grammys = [] def initialize(year, category, winner) @year = year @category = category @winner = winner @@Grammys << self end def year return @year end def category return @category end def winner return @winner end def to_s retur...
true
f380585e2257819dcad2371f7fea8339019b6bcb
Ruby
rgilbert82/Data-Structures
/binary_tree_test.rb
UTF-8
1,961
2.90625
3
[]
no_license
require 'minitest/autorun' require 'minitest/reporters' Minitest::Reporters.use! require_relative 'binary_tree' class BinaryTreeNodeTest < Minitest::Test def setup @left = BinaryTreeNode.new @right = BinaryTreeNode.new @tree = BinaryTreeNode.new(@left, @right) end def test_children assert @tree....
true
0810a90f5269d55b26dcfca0a4f792e544119049
Ruby
dallinder/ls_small_pbs_round2
/med_1/5.rb
UTF-8
268
3.671875
4
[]
no_license
def diamond(number) 1.upto(number) do |num| if num.odd? puts ('*' * num).center(number) end end (number - 2).downto(0) do |num| if num.odd? puts ('*' * num).center(number) end end end diamond(3)
true
08f7584032ed6cef89b58929d09020b2b63c12ce
Ruby
M1ckmason/teth
/lib/teth/minitest.rb
UTF-8
3,773
2.578125
3
[ "MIT" ]
permissive
require 'minitest/autorun' require 'ethereum' require 'teth/configurable' module Teth class Minitest < ::Minitest::Test extend Configurable include Ethereum option :contract_dir_name, 'contracts' option :account_num, 10 option :print_events, false option :print_logs, true def setup ...
true
fb5c6218bdac840b5d7954688f28bba6a8f66261
Ruby
ojab/iodine
/exe/iodine
UTF-8
3,574
2.625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'rack' require 'iodine' module Iodine # The Iodine::Base namespace is reserved for internal use and is NOT part of the public API. module Base # Command line interface. The Ruby CLI might be changed in future versions. module CLI def print_help puts <<-EOS Iodine...
true
ba1bb3bf7c6a897de1a58dd590809dae353a4054
Ruby
reidmv/control-repo-2
/site-modules/pe_infrastructure/lib/puppet_x/puppetlabs/meep/scope.rb
UTF-8
1,350
2.671875
3
[ "Apache-2.0" ]
permissive
module PuppetX::Puppetlabs::Meep # A hash that handles stripping the root '::' namespace from scope lookup # requests (for facts) for hiera so that it can find both 'somekey' and # '::somekey'. # # For the purposes of a hiera lookup, this class is functionally equivalent # to a Puppet::Parser::Scope, since ...
true
909e1f86b87f5f25f23f4eb1e2a28d2ccb383d51
Ruby
harlemtraveler/Final-Project
/scripthub/lib/tasks/import.rake
UTF-8
863
3.0625
3
[]
no_license
require 'csv' namespace :import do # My table is called "users" and class/model called "User" # desc is just a description desc "Import users from csv " # :environment is important here! task users: :environment do # intializes an empty array for your table users = [] # the below variable makes ...
true
78f15d851d00a18672b33084a2a14eb84d10b282
Ruby
stefaniacardenas/rebuilding-rails
/runways/erb_test.rb
UTF-8
264
2.921875
3
[ "MIT" ]
permissive
require "erubis" template = <<TEMPLATE HELLO! This is a template It has <%= whatever %> TEMPLATE eruby = Erubis::Eruby.new(template) # The .src says give me the code for this template puts eruby.src puts "=============" puts eruby.result(:whatever => "ponies!")
true
a8cb9be8bb85f70381ee1669521766172d0c7082
Ruby
jeromeall/w2d1
/employee.rb
UTF-8
576
3.40625
3
[]
no_license
class Employee attr_accessor :name, :title @@employee_count = 0 def initialize(name, title, boss) # name, id, title, salary, boss, dept, vacation_days @name = name @title = title @@employee_count += 1 # @id = id # @title = title # @salary = salary @boss = boss # @dept = dept # @vacation_days = ...
true
8feb429b5cc36ac65828212d7c3d63b284684cc6
Ruby
paulipayne/reverse-each-word-v-000
/reverse_each_word.rb
UTF-8
177
3.453125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(sentence) word_array = sentence.split(" ") reverse_array =[] word_array.collect {|word| reverse_array << word.reverse} reverse_array.join(" ") end
true
0c7a87975a3b961bd16ed336a3f6b984dec54e4f
Ruby
risingh1981/AppAcademy
/Intro to Programming/pickPrimes.rb
UTF-8
471
4.53125
5
[]
no_license
def pick_primes(numbers) primes = numbers.select { |num| is_prime(num) } return primes end # is_prime returns true is prime, false if not prime def is_prime(num) if num < 2 return false end (2...num).each do |ele| if num % ele == 0 return false end end...
true
77c68c3ebb85be69549c2c027d2f97622cf48485
Ruby
cavalle/eventwire
/lib/eventwire/middleware/logger.rb
UTF-8
829
2.546875
3
[ "MIT" ]
permissive
module Eventwire module Middleware class Logger < Base def initialize(app, config) super(app) @config = config end def subscribe(event_name, handler_id, &handler) @app.subscribe event_name, handler_id do |data| begin logger.info "Starting to p...
true
4b8b833ba1df85856df1d1b4fd17ed5e0fe6bc69
Ruby
YashUppal/appAcademy
/Ruby/Reference/memory_puzzle_project/memory_puzzle_game_1.1/board.rb
UTF-8
3,407
3.78125
4
[]
no_license
require_relative 'card.rb' class Board attr_reader :grid, :alphabets, :bomb_count def initialize(size,bombs=false) @grid = Array.new(size) { Array.new(size) } # grid of size x size @alphabets = ("A".."Z").to_a if bombs @bomb_count = size / 2 else @bomb_count = 0 end end de...
true
3376a04410ee589609b2142fed7116b4329a4b4d
Ruby
kacy/hipchat-emoticons
/app.rb
UTF-8
1,627
2.609375
3
[ "MIT" ]
permissive
# By Henrik Nyh <henrik@nyh.se> 2011-07-27 under the MIT license. # See README. require "set" require "rubygems" require "bundler" Bundler.require :default, (ENV['RACK_ENV'] || "development").to_sym set :haml, :format => :html5, :attr_wrapper => %{"} set :views, lambda { root } get '/' do # Cache in Varnish: http...
true
ab69a679da7877d408d3c68c2e3cca34a686200b
Ruby
papapabi/exercism.io
/ruby/clock/clock.rb
UTF-8
535
3.0625
3
[]
no_license
class Clock attr_reader :hours, :minutes def initialize(hours, minutes) @minutes = minutes % 60 @hours = (hours + minutes / 60) % 24 end def self.at(hours, minutes) new(hours, minutes) end def to_s format('%02d:%02d', hours, minutes) end def +(mins) self.class.new(hours, minutes ...
true
7a105dff404d844023db065222777d4e51f95097
Ruby
marijastojanovic5/ruby-project-guidelines-dc-web-120919
/db/seeds.rb
UTF-8
1,608
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
Reader.destroy_all Book.destroy_all Checkout.destroy_all Genre.destroy_all 50. times do Reader.create(name: Faker::Name.unique.name) end 50. times do Book.create(title: Faker::Book.title, author: Faker::Book.author, genre_id: rand(1..10)) end Genre.create(id:1,name: "SiFi") Genre.create(...
true
55a4bed5acc1ac029eb9a6daffefaf1243589513
Ruby
aliyamerali/dealership_2103
/lib/dealership.rb
UTF-8
1,004
3.484375
3
[]
no_license
class Dealership attr_reader :inventory, :total_value, :details def initialize(name, address) @name = name @address = address @inventory = [] @total_value = 0 end def inventory_count @inventory.length end def add_car(car) @total_value += car.total_cost @inventory << car end ...
true
92dc14eb40ec6defa1c1dff66e0e036f91f08ae3
Ruby
steveax/beaker-windows
/lib/beaker-windows/registry.rb
UTF-8
8,778
2.984375
3
[ "Apache-2.0" ]
permissive
module BeakerWindows module Registry # Get the data from a registry value. # # ==== Attributes # # * +hive+ - A symbol representing the following hives: # * +:hklm+ - HKEY_LOCAL_MACHINE. # * +:hkcu+ - HKEY_CURRENT_USER. # * +:hku+ - HKEY_USERS. # # ==== Returns # ...
true
b6e3cae67f977c78a4a175aed0ea3e188109b799
Ruby
fronx/reincarnation
/lib/reincarnation.rb
UTF-8
672
2.71875
3
[ "MIT" ]
permissive
require 'active_support' class Module def included(base) bases << base end def bases @bases ||= [] end def poke_bases(m) bases.each do |b| b.module_eval do include(m) poke_bases(m) end end end def name_without_namespace name.gsub(/.*::/, '') end def...
true
1661be0078fd275857dc73a97345f8f714870bd5
Ruby
loschtreality/App_Academy
/In_Class/TDD/spec/array_spec.rb
UTF-8
1,806
3.65625
4
[]
no_license
require 'array' require 'rspec' describe Array do subject(:array) { Array.new } describe "#my_uniq" do let(:duplicates) { [1,1,2,2,3] } it "should return an array" do expect(duplicates.my_uniq).to be_a(Array) end it "should return only unique values" do expect(duplicates.my_uniq).to eq...
true
7e553d41d93a4778595c3577cc35fe77661bfb0b
Ruby
rsoemardja/Codecademy
/Ruby/Learn Ruby/Looping/Loops & Iterators/The .each Iterator.rb
UTF-8
263
4.0625
4
[]
no_license
# You can use the {} syntax like this object.each { |item| # Do something } # or use the do keyword instead of {} object.each do |item| # Do something end #Example of the .each Iterator array = [1,2,3,4,5] array.each do |x| x += 10 print "#{x}" end
true
a4621d76c0e60c88da0587ca626e0292df3916f1
Ruby
Haira505/Pythoncode
/ruby/mainpunto.rb
UTF-8
184
3.640625
4
[]
no_license
load "punto.rb" #creamos los objetos y llamamos a sus metodos pa = Punto.new(3,4) pb = Punto.new(0,0) print"pa: #{pa.getx()}, #{pa.gety()} \n" print"pb: #{pb.getx()}, #{pb.gety()} \n"
true
4e12ac666552632f26dd6a5d4cd2babe2a158a66
Ruby
Jesrogers/ruby-projects
/rspec_testing_intro/spec/calculator_spec.rb
UTF-8
600
3.03125
3
[]
no_license
require './lib/calculator' describe Calculator do describe "#add" do it "returns the sum of two numbers" do calculator = Calculator.new expect(calculator.add(5, 2)).to eql(7) end it "returns the sum of more than two numbers" do calculator = Calculator.ne...
true
6706d1353a3d81671486a0e729a251bcd6e03da1
Ruby
ryanmax/searchworks_traject_indexer
/spec/lib/utils_spec.rb
UTF-8
1,314
2.78125
3
[ "Apache-2.0" ]
permissive
require 'spec_helper' require 'utils' describe Utils do describe '.balance_parentheses' do it 'works' do expect(described_class.balance_parentheses('abc')).to eq 'abc' expect(described_class.balance_parentheses('a(bc')).to eq 'abc' expect(described_class.balance_parentheses('a(b)c')).to eq 'a(b...
true
893640f1ae978ce777d29d6c021c2639583b8624
Ruby
manusajith/codejam-google-2012
/Round_1C/Box_Factory/box_factory_small.rb
UTF-8
1,649
2.96875
3
[]
no_license
# Copyright 2012 Manu S Ajith <neo@codingarena.in> # Ruby Kitchen Technosol Pvt Ltd ( http://rubykitchen.in) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the Licens...
true
00a773d7c153ecf1a94d966dac2429d0bd9a3931
Ruby
gangelo/Splattr
/lib/people/female.rb
UTF-8
244
2.71875
3
[]
no_license
# To change this template, choose Tools | Templates # and open the template in the editor. require 'base/base_creature' require 'modules/gender' class Female < BaseCreature def initialize(name,age) super Gender::FEMALE,name,age end end
true
a3092875f79436ec0145d12dbd80c0333d7b3a6f
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/f38d82ed311d449bb2f7086138118806.rb
UTF-8
412
3.65625
4
[]
no_license
class Bob def hey(content) message = Message.new(content) return 'Fine. Be that way!' if message.silent? return 'Woah, chill out!' if message.shouted? return 'Sure.' if message.question? 'Whatever.' end end class Message < String def question? self.end_with?("?") end def shouted? ...
true
2d3d96efee0462e8551f68a97a319c1b3065edbb
Ruby
deltamualpha/shamwow
/shamwow.rb
UTF-8
4,779
3.171875
3
[]
no_license
#!/usr/local/bin/ruby def chunker(string, chunk_size) return (string.length / chunk_size).times.collect { |i| string[i * chunk_size, chunk_size] } end # treat all numbers as if they are 32-bit integers def ror(num, shift) (((num >> shift) | (num << (32-shift))) & ((2 ** 32) - 1)) end def lor(num, shift) (((num...
true
b45169be75209f12a62d4559e87baec3b3efcdc7
Ruby
gmacdougall/advent-of-code
/2020/02/part2.rb
UTF-8
227
2.984375
3
[]
no_license
#!/usr/bin/env ruby puts( ARGF.read.lines.count do |line| range, char, pass = line.split(' ') p1, p2 = range.split('-').map(&:to_i) char.gsub!(':', '') (pass[p1 - 1] == char) ^ (pass[p2 - 1] == char) end )
true
0cd33b1cfb54fcc972d17edac1d067d8714205b8
Ruby
dkoslow/blog_scraper
/blog_scraper.rb
UTF-8
504
3.03125
3
[]
no_license
require 'open-uri' require 'rubygems' require 'nokogiri' class Scraper def self.scrape(web_page) page = Nokogiri::HTML(open(web_page)) count = 1 page.css('div#content_inner > *').each do |element| if element.matches?('h2') puts "#{count}. #{element.text} \n\n" count += 1 elsi...
true
cb0f9f6a0cc4324bd36e4cbdf80f9951ab1ec38b
Ruby
justinetroyke/who-you-know-backend
/spec/requests/api/v1/cards/cards_request_spec.rb
UTF-8
3,430
2.6875
3
[]
no_license
require 'rails_helper' describe "Cards API" do describe "User has at least 30 unsorted, 8 easy, 8 medium and 8 hard cards" do before :each do @user = create(:user) card = create(:card) 35.times do |num| UserCard.create!(user_id: @user.id, card_id: card.id) end 10.times do ...
true