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
da7f55ac56e4bc0f79f917d79342f7e8b24911f9
Ruby
billwestfall/ruby
/miscellaneous/tarot/celtic.rb
UTF-8
310
2.8125
3
[]
no_license
#!/usr/bin/ruby $i = 0 while $i < 11 do print [ :"2", :"3", :"4", :"5", :"6", :"7", :"8", :"9", :"10", :Page, :Knight, :Queen, :King, :Ace ].sample print " " print [ :Swords, :Cups, :Coins, :Wands ].sample print " " puts [ :Natural, :Reversed ].sample $i +=1 end
true
b7c437f6d20de16ea86837da2254835dce3f101a
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/food-chain/35636a81d1db48f4b5bd91d3b184f9e9.rb
UTF-8
2,569
4.03125
4
[]
no_license
class FoodChainSong def initialize @verses = lyric_to_verses end def verse(idx) @verses[idx - 1].chomp end def verses(from, to) @verses[(from - 1) .. (to - 1)].join end def sing verses(1, @verses.length) end def lyric_to_verses lyric = <<-EOS I know an old lady who swallowed a ...
true
34d58a6fc1a6e055a9e0594579693110d7c6964e
Ruby
citronneur/nes
/lib/nes/cpu.rb
UTF-8
3,042
3.109375
3
[]
no_license
module Nes class AddressingMode Immediate = 0 Absolute = 1 end class CPU def initialize(memory) # memory @memory = memory # program counter @pc = 0x8000 # cpu flags @carry_flag = 0 @zero_flag = 0 @interupt_disable = 0 @decimal_mode_fl...
true
a437c6fd21325d59c5997a228fe846c63221d299
Ruby
bateso88/bank-tech-test
/spec/statement_spec.rb
UTF-8
1,168
2.515625
3
[]
no_license
# frozen_string_literal: true require 'statement' describe Statement do create_statment_instance_and_doubles_for_transaction_class_and_transaction context 'update' do it 'creates a new transaction after a deposit and updates balance' do expect(transaction_class).to receive(:new).with({ balance: 100, cr...
true
85f8eb2250d26865d6a8517989be94494be99905
Ruby
mazondo/harpoon
/lib/harpoon/auth.rb
UTF-8
2,214
2.703125
3
[ "MIT" ]
permissive
require "netrc" require 'fileutils' module Harpoon class Auth attr_reader :namespace def initialize(options = {}) @logger = options[:logger] if options[:namespace] @namespace = sanitize_namespace(options[:namespace]) else @namespace = "main" end end def destroy(key) if netrc && netrc[n...
true
355e459edb3e0a248416830507a18a92044b1afb
Ruby
ashleydavies/wiki
/wiki
UTF-8
400
2.875
3
[]
no_license
#!/usr/bin/ruby require 'open-uri' require 'json' def get_description(summary) search_string = URI::encode summary address = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=#{search_string}&utf8=&format=json" open(address) {|page| puts JSON.parse(page.read)["query"]["search"][0]["snip...
true
32a70141ffd4059226798141c1e30d5307de2d13
Ruby
vinnyjth/advent-of-code-2020
/day20.bak.rb
UTF-8
17,058
2.953125
3
[]
no_license
require './utils' class Tile attr_reader :id, :neighbors def initialize(data) @data = data @id = get_id @map = get_map @position @neighbor_result = {} end def get_id @data.split("\n")[0].split(" ")[1].gsub(":", "") end def get_map @data.split("\n")[1..-1].map { |r| r.split("")...
true
d9579f2fcc8722ddbdae7784baf9e0bbedb356d9
Ruby
inohiro/jubatus_yomiuri
/lib/utils/article_reader.rb
UTF-8
1,465
2.96875
3
[]
no_license
require 'parallel' require 'json' require 'nkf' module Utils class ArticleReader def initialize(rand_seed = nil) entries = JSON.parse(File.open(articles_path, 'r').read) srand rand_seed if rand_seed @articles = Parallel.map(entries, in_threads: 8) {|entry| Utils::Article.new(entry) ...
true
184e9707bbba07d6f09f182d6a6a4fa6b130ac05
Ruby
easing/evotest
/app/operations/build_status.rb
UTF-8
766
2.5625
3
[]
no_license
# frozen_string_literal: true # Разбирает ответ SSLTest и определяет состояние сертификата class BuildStatus # @param [TrueClass|FalseClass] valid # @param [String|nil] message # @param [OpenSSL::X509::Certificate|nil] cert # @return [[String, String]] [status_type, message] def self.call(valid, message, cer...
true
cc6295c2904f2153f5e4e4bc5645d6cc008120a5
Ruby
kayhide/motive_support
/motion/active_support/option_merger.rb
UTF-8
691
2.546875
3
[ "MIT" ]
permissive
require 'active_support/core_ext/hash/deep_merge' module ActiveSupport # Inherits from BasicObject avoiding undefs. class OptionMerger < BasicObject def initialize(context, options) @context, @options = context, options end private def method_missing(method, *arguments, &block) if arg...
true
f1fd1ab960e1e6e78b7dfa186393a87ce94f3738
Ruby
guozhaonan/sms-battleship
/battleship.rb
UTF-8
1,609
2.9375
3
[]
no_license
require 'sinatra' require 'sendgrid-ruby' grid = [['a1', 'b1', 'c1', 'd1', 'e1'], ['a2', 'b2', 'c2', 'd2', 'e2'], ['a3', 'b3', 'c3', 'd3', 'e3'], ['a4', 'b4', 'c4', 'd4', 'e4'], ['a5', 'b5', 'c5', 'd5', 'e5']] class Player attr_accessor :name, :ship def initialize(name...
true
988aeee86d93515f8500626f0ac13effc91fa771
Ruby
kinsona/prep_ruby_challenges
/problem_02.rb
UTF-8
507
4.375
4
[]
no_license
=begin 2. Factorial Write a method factorial which takes a number and returns the sum [correction: product!] of every number up to the current number multiplied together. =end def factorial(input_number) result = 1 if input_number >= 0 1.upto(input_number) { |input| result *= input } else result = "...
true
525837c3df98113f622da7a82fa448897829d13f
Ruby
learn-co-students/nyc-web-042020
/09-apis/bin/run.rb
UTF-8
487
3.546875
4
[]
no_license
require 'rest-client' require_relative '../config/environment' require 'pry' def welcome_user puts "Hello User what is your name?" user_name = gets.chomp user_name end def get_food puts "What is your favorite food?" fav_food = gets.chomp food = Food.find_or_create_by(name: fav_food) food ...
true
9ab8b9676d60e2720b6aec7067533f416dfb4d16
Ruby
leightkt/HikeSelector
/lib/models/hike.rb
UTF-8
686
2.75
3
[]
no_license
class Hike < ActiveRecord::Base # choices = ["Location", "Dog Friendly?", "Elevation Gain", "Difficulty", "Distance"] has_many :userhikes has_many :users, through: :userhikes def self.dog_friendly? self.where("dog_friendly = ?", true) end def self.elevation(gain) self.where("el...
true
da7b64bf8a802d1ff796899d1112261fe96a9e9f
Ruby
rebeccalauren/rubyHomework
/rubyHomework2/comments_fizzbuzz.rb
UTF-8
2,613
4.5
4
[]
no_license
#INSTRUCTIONS: Add comments to the following code. First add a comment describing the functionality in general, then comment each line describing it's function. def fizzbuzz(num) # This defines the variable "fizzbuzz" and explains in parenthesis what parameters can be passed into it. # In this case, there is only one ...
true
087ab6b8ba3cbafc4554220ae6730a27f6934359
Ruby
Domitillechenut/Domitillechenut
/reboot/interface.rb
UTF-8
874
4.03125
4
[]
no_license
#doit demander un nombre #un deuxieme # afficher le résultat #l'utilisateur doit pouvoir choisir l'opération require_relative "calculator" first_number = ask_for_a_number("first") if is_a_number?(first_number) puts "Give me the operation to do " operation = gets.chomp second_number = ask_for_a_number("second") ...
true
dd3de713d641d9e3ba33ffe2d295122947fb0e2a
Ruby
drstonebraker/ruby_alpha_course
/rspec_1/lib/03_simon_says.rb
UTF-8
484
3.796875
4
[]
no_license
def echo(message) message end def shout(message) message.upcase end def repeat(message, num_repeats=2) ((message + ' ') * num_repeats).strip end def start_of_word(word, sublength=1) word[0, sublength] end def first_word(sentence) sentence.split.first end def titleize(title) little_words = %w{a...
true
6b32b9b82e7ea616dde04d4c9d21a4bc7b647628
Ruby
timothy-m-moore/RubyPractice
/methods.rb
UTF-8
371
3.8125
4
[]
no_license
def sayMoo numberOfMoos puts 'moooooo...' * numberOfMoos end sayMoo 3 puts def doubleThis num numTimes2 = num * 2 puts num.to_s + ' doubled is ' + numTimes2.to_s end doubleThis 44 puts def littlePest var var = nil puts 'HAHA! I ruined your variable!' end var = 'You can\'t e...
true
c4da61602dfb3276083d5620ea637478f4e71e70
Ruby
blijblijblij/ruby-beautify2
/spec/binary_scenarios/overwrite.rb
UTF-8
59
2.703125
3
[ "MIT" ]
permissive
def ugly puts 'this' if true puts 'is ugly enough' end end
true
cfe98a2c6d61c6ef79c584d8ca0ef1de8e9477c1
Ruby
jedediah/MathStuff
/arithmetic.rb
UTF-8
12,453
3.171875
3
[]
no_license
require_relative 'expr' # require_relative 'numex' def _HZ(h=nil) x = NormalizedHash.new(0) x.merge!(h) if h x end def _bc0(e, k1, a, &block) k2 = e-k1 block[a, [k1, k2]] k3 = k1+1 _bc0(e, k3, (a * (e - k3 + 1)) / k3, &block) if k3 < k2 block[a, [k2, k1]] if k1 < k2 end def binomial_c...
true
3fdf443a5829de773d7d5ef090553823210324ec
Ruby
aasmolsky/sp_test
/lib/modules/error_handler_module.rb
UTF-8
709
2.640625
3
[]
no_license
module ErrorHandlerModule private def raise_error(error_code) raise errors(error_code) end def errors(error_code) AVAILABLE_ERRORS[error_code] || AVAILABLE_ERRORS[:unexpected_error] end AVAILABLE_ERRORS = { file_not_found: 'Log file was not found. Please put webserver.log file into the Root d...
true
f60433b8474a940b73fa100f78f82e048694c0df
Ruby
Zoraab/zng
/app/models/product.rb
UTF-8
861
2.515625
3
[]
no_license
class Product < ActiveRecord::Base validates_presence_of :sku validates_presence_of :title validates_presence_of :image validates_presence_of :color_id validates_presence_of :pattern_id validates_uniqueness_of :sku belongs_to :color belongs_to :pattern def self.filter_products(colors,patterns) fi...
true
2e5ce3e3d4683ce0448b2689ba7a769eeb1ccfce
Ruby
ManuOnline/Esercitazione_Gosu
/bullet.rb
UTF-8
2,475
3.25
3
[]
no_license
class Bullet attr_reader :x, :y, :radius def initialize(window, x, y, angle, speed = 5) @x = x @y = y @direction = angle @image = Gosu::Image.new('images/bullet.png') @radius = 3 @window = window @speed = speed end def move @x += Gosu.offset_x(@direction, @speed) @y += Gosu.offset_y(@direction,...
true
78e7f6774f18d7ed3604dd0763603703a05c0d10
Ruby
chrisjohnhopkins/banta
/spec/helpers/messages_helper_spec.rb
UTF-8
619
2.640625
3
[]
no_license
require 'rails_helper' # Specs in this file have access to a helper object that includes # the MessagesHelper. For example: # # describe MessagesHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # ...
true
341e0742dee70a9b76800f1563641ad257a1da3a
Ruby
johndavid400/Isotope11_traffic_lights
/traffic_lights.rb
UTF-8
1,799
3.046875
3
[]
no_license
# Isotope11 continous integration server Traffic-light # Ruby script to monitor json output from Jenkins CI-server, and output the status of projects to a Traffic-light. # If all builds are passing, the light is green. # If a job is currently building, the yellow light flashes. # If any job is failing, the red light...
true
3b2a2123cef96b52a10ce1f38320a10e80964c74
Ruby
RudiBoshoff/ruby-exercises
/connect_four/spec/player_spec.rb
UTF-8
587
3.15625
3
[]
no_license
require 'player' describe Player do before(:each) do @player1 = Player.new("\u26AA") # white @player2 = Player.new("\u26AB") # black end describe '#new' do it 'should return an instance of the class Player' do expect(@player1).to be_an_instance_of(Player) end context 'each player is a...
true
c9f28e069cda5ff774252be1a43a9ace7a6e429d
Ruby
pedromarce/passant
/spec/pieces/rook_spec.rb
UTF-8
718
2.75
3
[ "BSD-3-Clause" ]
permissive
require 'passant/board' describe Passant::Rook do describe "#moves" do it "should return linear moves from sw corner" do board = Passant::Board.new_empty r = Passant::Rook.new(board, a1) moves = r.moves.map{|m| m.to} moves.size.should == 14 ([a2, a3, a4, a5, a6, a7, a8, ...
true
d1e1c1fb09e2ebc2720ca1126b7ff3ac989398df
Ruby
materiari/hatch_calc
/app/models/week.rb
UTF-8
289
2.546875
3
[]
no_license
class Week < ActiveRecord::Base attr_accessible :ending, :starting, :week_number def self.current_week current = self.where("starting <= ? and ending >= ?", Date.today, Date.today) if(current.empty?) return 1 else current.first[:week_number] end end end
true
88f2f2f20f2715d914a122ad84f7971b812a8d86
Ruby
Sid-ah/hk-bc
/activerecord-jr-1-a-basic-orm-challenge/models/cohort.rb
UTF-8
2,551
2.734375
3
[]
no_license
class Cohort < Database::Model def self.all Database::Model.execute("SELECT * FROM cohorts").map do |row| Cohort.new(row) end end def self.create(attributes) record = self.new(attributes) record.save record end def self.where(query, *args) Database::Model.execute("SELECT * FRO...
true
6321f23199808093e87a6bcc74a02ff193b72a96
Ruby
xmisao/syobocal
/lib/syobocal/rss.rb
UTF-8
1,522
2.515625
3
[ "MIT" ]
permissive
module Syobocal module RSS def get(params = {}) parse(URI.open(url(params))) end def url(params = {}) "http://cal.syoboi.jp/rss.php" + Syobocal::Util.format_params(params) end def parse(rss) rss = REXML::Document.new(rss) result = Result.new channel = rss.elements...
true
f78d06cbb15c1e186116cdbfda9c23e7a2d69066
Ruby
alan-andrade/DiffieHellman-Ruby
/lib/dh/key.rb
UTF-8
566
3.203125
3
[]
no_license
module DH class Key attr_reader :public, :shared, :p, :g def initialize(p,g) @p = p @g = g @private = nil @public = nil @shared = nil end def generate_secret_key @private ||= rand(@p-2)+2 # para que genere numeros del 2 a p-1. generate_public_key ...
true
f0388c110ca95279362fcfedb6bd03a19724e1c5
Ruby
henry-doan/ruby_classes_modules_testing_winter20
/App.rb
UTF-8
360
3.453125
3
[]
no_license
require_relative 'Person' class App attr_accessor :person def initialize @person = init_person end def init_person puts 'What is your name?' name = gets.strip puts 'What is your age?' age = gets.to_i puts 'what is your email?' email = gets.strip @person = Person.new(name,...
true
796d297b647a57c0976215c7734cebbf265179b8
Ruby
sergelerator/dijkstra_shortest_path
/spec/dijkstra/node_spec.rb
UTF-8
4,391
2.953125
3
[]
no_license
require "spec_helper" describe Dijkstra::Node do it "should be" do subject.should be end context "bare instance" do subject {Dijkstra::Node.new} it "should be an instance of Dijkstra::Node" do subject.class.should eq(Dijkstra::Node) end end describe "set_label" do let(:visitor) {...
true
b6d3e3c89acdd0701bcbeb9543a706f60c7ee142
Ruby
bluespheal/etapa1
/semana1/lunes/pseudocodigo.rb
UTF-8
1,309
3.578125
4
[]
no_license
students = [[["Eliezer", 7], ["Mariam", 7], ["Deborah", 10], ["Harley", 7]], [["D'angelo", 10], ["Brittany", 8], ["Hubert", 7], ["Erling", 9]], [["Bradford", 7], ["Theodora", 10], ["Casandra", 9], ["Lindsay", 8]], [["Hilma", 10], ["Lina", 10], ["Isabell", 8], ["Urban", 9]]] def best_students(students) best_stude...
true
c0a393d4ddec0e47fe087632a9d1903bfb72675d
Ruby
swushanley/swushanley
/reboot/christmas-list/interface_2.rb
UTF-8
1,544
3.546875
4
[]
no_license
# Christmas list # 1. Welcome puts "🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 " puts "🎅 Welcome to your Christmas giftlist 🎅 " puts "🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 🎅 " puts # 2. Display menu (list / add / delete / mark ) giftlist = [] action = "add" until ...
true
e1acb13f680ba657df889c1236b30cc862bf5eaf
Ruby
TimothyREMY/Projet-commun
/exo_10.rb
UTF-8
163
3.1875
3
[]
no_license
puts "En quelle année es-tu né ?" print ">" year = gets.chomp.to_i number = 2022 - year number.times do |i| puts "en #{year +i} tu avais #{i} ans" end
true
8726baaae9ded8465eac27b038699d5efc88fc0b
Ruby
ar1hur/redis-coupons
/redis_coupons.rb
UTF-8
936
2.703125
3
[]
no_license
require 'redis' redis = Redis.new def gen_redis_proto(*cmd) proto = "" proto << "*"+cmd.length.to_s+"\r\n" cmd.each { |arg| proto << "$"+arg.to_s.bytesize.to_s+"\r\n" proto << arg.to_s+"\r\n" } proto end def create_code(excluded_chars, length) chars = (('A'..'Z').to_a + (0..9)....
true
47f681eb35c64b9a9964cf6c65889fbc32d28f2a
Ruby
nov/fb_graph
/lib/fb_graph/poke.rb
UTF-8
416
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module FbGraph class Poke include Comparison attr_accessor :from, :to, :created_time def initialize(attributes = {}) if from = attributes[:from] @from = User.new from[:id], from end if to = attributes[:to] @to = User.new to[:id], to end if attributes[:create...
true
b39d7f4e1df2752da9deb320bcf36260ee1b2836
Ruby
assunta09/phase-1-assessment-master
/part-3/water_bottle.rb
UTF-8
476
3.109375
3
[]
no_license
class WaterBottle attr_reader :capacity, :material def initialize(args = {}) @capacity = args.fetch(:capacity) { 2 } @material = args.fetch(:material) { "tin" } end def reserve @reserved = true end def end_reservation @reserved = false end def reserved? @reserved end def ava...
true
50267b05e8fa4a177220890d48ed678bbf954aa5
Ruby
Ad00M87/lunch_lady
/side_dish.rb
UTF-8
845
3.828125
4
[]
no_license
require 'pry' $side_dishes = {"Carrots": 1.75, "Mystery Yogurt": 1.00, "Beef Jerky": 0.50} class SideDish attr_accessor :name, :price def initialize(name, price) @name = name @price = price $side_dishes[@name.to_sym] = price end # def add # puts "What menu item would you like to add?" # n...
true
a3b0c415b3abef60a7a030b914a576882af7f5b0
Ruby
anon0mys/tdd_neighborhood
/lib/pet.rb
UTF-8
410
4
4
[]
no_license
class Pet attr_reader :name attr_accessor :food def initialize(name) @name = name @food = { 'kibble' => 5, 'treats' => 2 } end def eat_food(kind_of_food) if @food.values.sum == 0 puts "This is bad! #{@name} is totally out of food..." elsif @food[kind_of_food] == 0 puts "Oh no!! #...
true
355edb400352794c291836d029ddce6ed91911d7
Ruby
SarahMahovlich/TwO-O-Player-Math-Game
/game.rb
UTF-8
1,050
3.671875
4
[]
no_license
class Game attr_accessor :current_player, :player1, :player2 def initialize(player1, player2) @player1 = player1 @player2 = player2 @current_player = player1 end def start_game puts "New game started" while !(player1.score <= 0 || player2.score <= 0) do # start new round puts ...
true
a3d8ed40b2bc41d6dc8f7568cbb1e66c1370bc77
Ruby
1brian/semana8actividad1
/ejercicio1/sub2.rb
UTF-8
282
2.921875
3
[]
no_license
def string(*strings) file = File.open('saludo.html', 'w') do |f| f.write("<html>\n") f.write("<head>\n<title> Mi titulo</title>\n</head>\n") f.write("<body>\n") strings.each { |string| f.write("<p>#{string}</p>\n")} f.write("</body>\n") file.close end end
true
e839933d0293d4f28d83830f6567677a2ac66d3a
Ruby
niquepa/spree_custom_sizes
/app/models/spree/finishing_line_item.rb
UTF-8
2,635
2.65625
3
[ "BSD-3-Clause" ]
permissive
module Spree class FinishingLineItem < ActiveRecord::Base belongs_to :line_item belongs_to :finishing validates :price_multiplier, numericality: true validates :price_modifier, numericality: true validates :quantity, numericality: true before_validation :copy_price_multiplier before_val...
true
b1088bb634ee1803938deefd04b6a4dc18d489b4
Ruby
Lean-GNU/EjerciciosRuby
/Array/ejercicio-array5.rb
UTF-8
625
4.15625
4
[]
no_license
=begin Una empresa tiene dos turnos (mañana y tarde) en los que trabajan 8 empleados (4 por la mañana y 4 por la tarde) Confeccionar un programa que permita almacenar los sueldos de los empleados agrupados en dos arreglos. Imprimir los dos arreglos de sueldos. =end day = [] night = [] x = 1 y = 1 while x <= 5 pr...
true
394a11dedf7273ab2bb72cec9549375a2b6cee78
Ruby
snowyam/serial-hangman
/hangman.rb
UTF-8
3,128
4.0625
4
[]
no_license
# Serial Hangman require 'yaml' class Noose attr_accessor :word, :turn, :wrong_guesses, :word_progress def initialize(word, turn) @word = word @turn = turn @wrong_guesses = [] @word_progress = "" word.split("").each do |i| @word_progress << ("_") end end def turns_left @turn...
true
57515deee38df05e821c3de313e9325ee36f8a48
Ruby
lemonpaul/exchangeRate
/app/jobs/add_rate_job.rb
UTF-8
2,212
2.71875
3
[]
no_license
# Read data from JSON, put them in rates table, check all triggers class AddRateJob < ApplicationJob queue_as :default include ApplicationHelper USD = 0 EUR = 1 SELL = 0 BUY = 1 LOWER = 0 UPPER = 1 def new_hash require 'net/http' require 'json' response = Net::HTTP.get(URI('https://www.t...
true
c81f270ea6a68c6cd5bc9fe10cf056a1501530e5
Ruby
brianrip/enigma
/lib/enigma.rb
UTF-8
431
2.78125
3
[]
no_license
require_relative 'encrypt/encryptor' require_relative 'decrypt/decryptor' require_relative 'crack/cracker' class Enigma def encrypt(message = nil, key = nil, date = nil) Encrypt.new.encrypt_message(message) end def decrypt(message = nil, key = nil, date = nil) Decrypt.new.decrypt_message(message) end...
true
555e93a0e1fb6159e9b910477c20c30eb1ba01a1
Ruby
Colt/algorithms-ruby-lab
/solution/lib/randomarraygenerator.rb
UTF-8
236
2.921875
3
[]
no_license
module RandomArrayGenerator def self.generate_random_array(size, min, max) if size < 0 || min > max nil else if size == 0 [] else Array.new(size){ rand(min..max) } end end end end
true
31f38cd26349726696a7f3af908e5a4278aec635
Ruby
hihihippp/finite_machine
/lib/finite_machine/observer.rb
UTF-8
5,560
2.671875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# encoding: utf-8 require 'set' module FiniteMachine # A class responsible for observing state changes class Observer include Threadable # The current state machine attr_threadsafe :machine # The hooks to trigger around the transition lifecycle. attr_threadsafe :hooks # Initialize an Ob...
true
bcbf2c6da034942590e8ef19530adfc4ff9aa59a
Ruby
bodymindarts/bosh-aws-cpi-release
/src/bosh_aws_cpi/lib/cloud/aws/stemcell.rb
UTF-8
2,017
2.5625
3
[ "Apache-2.0" ]
permissive
module Bosh::AwsCloud class Stemcell include Helpers attr_reader :ami, :snapshots def self.find(region, id) image = region.images[id] raise Bosh::Clouds::CloudError, "could not find AMI '#{id}'" unless image.exists? new(region, image) end def initialize(region, image) @r...
true
33dc494942120c317ac9c4536d0eeee7bf1ab190
Ruby
tmtm/ruby-mysql
/lib/mysql/packet.rb
UTF-8
1,462
2.6875
3
[ "MIT" ]
permissive
# coding: ascii-8bit class Mysql class Packet # convert Numeric to LengthCodedBinary def self.lcb(num) return "\xfb" if num.nil? return [num].pack("C") if num < 251 return [252, num].pack("Cv") if num < 65536 return [253, num&0xffff, num>>16].pack("CvC") if num < 16777216 return ...
true
a3ec293c1f3f084785a0aaa3636655cde6a485bb
Ruby
fac/fa-harness-tools
/lib/fa-harness-tools/check_recent_deploy.rb
UTF-8
2,371
2.65625
3
[ "Apache-2.0" ]
permissive
module FaHarnessTools # CheckRecentDeploy only allows deployer to deploy commits with `deploy_tag_prefix` ahead of (and include) Nth most recent commit # with the give tag. # # For example if the commit history is like # # SHA 1 # SHA 2 - tag: production-deploy-1 # SHA 3 # SHA 4 - tag: production-depl...
true
ec8ddc398ae47b06d79a684ec378c1e270e037bb
Ruby
kuizor/server-todo
/clases/semana1/dia5/person.rb
UTF-8
574
3.71875
4
[]
no_license
require_relative "monkey" class Person < Monkey def initialize(name,last_name) @name = name @last_name = last_name end def name #getter @name end def name(name) @name = name end def full_name puts "Name: #{@name} y el Last_name: #{@last_name}" #[@name, @last_name].hoin(" ") #@name + " " + @l...
true
d7f5114529fd82f8a59edfc77424337f29fab0ff
Ruby
juliamji/phase-0-tracks
/ruby/shout.rb
UTF-8
656
4.5625
5
[]
no_license
# module Shout # # we'll put some methods here soon, but this code is fine for now! # def self.yell_angrily(words) # puts words + "!!!" + " :(" # end # def self.yell_happily(words) # puts "haha" + words + "~~~" + " :)" # end # end # Shout.yell_angrily("i'm so angry") # Shout.yell_happily("i'm so an...
true
0093c27bd9cc76c809af27e489b8f2e69816af47
Ruby
vedransehovic/badges-and-schedules-onl01-seng-pt-041320
/conference_badges.rb
UTF-8
1,051
4.3125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. names = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"] #defining an array - list of names def badge_maker(name) #method that takes a name and returns "Hello, my name is <name>" "Hello, my name is #{name}." end def batch_badge_creator (array) #defining a method that...
true
cb2fc600dc1e06becb5228e61d049585b62c0e5d
Ruby
BerilBBJ/scraperwiki-scraper-vault
/Users/E/elfPavlik/hackerspacesorg_-_active_labs.rb
UTF-8
2,678
2.90625
3
[]
no_license
# get page with list of spaces html = ScraperWiki.scrape("http://hackerspaces.org/wiki/List_of_Hacker_Spaces") # create nokogiri document require 'nokogiri' doc = Nokogiri::HTML(html) rows = doc.search('tr') # remove table header rows.shift # extract geo data raw_string = doc.search('script')[5].inner_text.match(/\...
true
741b587e649f99456157bf48233a797960a6912a
Ruby
jyan95/project-biddlers-respite
/app/models/player.rb
UTF-8
1,388
2.953125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Player < ActiveRecord::Base has_many :question_masters has_many :questions, through: :question_masters def self.new_user(username) Player.find_or_create_by(username: username, high_score: 0, streak: 0) end def self.validate(username) Player.find_by(username: username) end def stats de...
true
d6dd27f31f195c8c868ab3a145152adc0ecbb526
Ruby
med2rdf/cosmic
/lib/cosmic_rdf/parser/row.rb
UTF-8
1,129
2.734375
3
[]
no_license
# coding: utf-8 module CosmicRdf module Parser # Represents a tsv row class Row FORMATTERS = { s: ->(v) { v.present? ? v.to_s : nil }, i: ->(v) { v.present? ? v.to_i : nil }, f: ->(v) { v.present? ? v.to_f : nil }, b: ->(v) { v.present? && v.downcase.in?(%w[y yes]) }, ...
true
ed4fbfb6043b8c048e70d9b223f31b8c6ecef19f
Ruby
rgaidot/letsshop-mapper
/lib/letsshop_mapper/model/tree/tree.rb
UTF-8
959
2.71875
3
[ "Apache-2.0" ]
permissive
module LetsShopMapper module Model module Tree class Tree attr_reader :categories attr_reader :xml def initialize(tree = nil) @categories = [] parse(tree) if tree end def parse(tree) @xml = Nokogiri::XML(tree) if @xml....
true
c00c6e2c4529f0a3511b5bd7ca61c9fdc5c62b5d
Ruby
joealba/rampup_week_3
/class_leap_years.rb
UTF-8
1,690
3.875
4
[]
no_license
#!/usr/bin/env ruby require 'rspec' ####################################################### ## YOUR CODE def is_a_leap_year?(year) (year % 4 == 0) end def leap_years_between(start_year, end_year) end ####################################################### ## MAIN SECTION -- WHAT YOU WANT TO RUN # puts leap_year...
true
5417f5bf26d1660db05f3d78f324a573da0caba1
Ruby
Maria-L/Programme
/Aufgabe 5/clock_class_s1/lib/clock24.rb
UTF-8
1,617
2.765625
3
[]
no_license
def_class(:Clock24,[:hour24,:min,:sec]){ def invariant?() hour24.hour24? and min.min? and sec.sec? end def clock? true end #Convert a clock24 to clock_sec # #clock24_to_clock_sec ::= (clock) :: #Clock24 -> ClockSec # #Test {Clock24[0,0,0] => ClockSec[0], Clock24[1,2,3] => ClockSec...
true
a063bd9523636bc17727731a7278b8df2407b2a2
Ruby
BecauseOfProg/openweathermap-ruby
/lib/openweathermap/api.rb
UTF-8
3,620
3.265625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module OpenWeatherMap ## # The main API class. class API ## # The default lang to use across the program # @return [String] attr_reader :lang ## # The default unit system to use across the program # @return [String] attr_reader :units ## ...
true
ddc2715ba958dc60e9363d0c2c51b31302b2a876
Ruby
beatthem/yakvd
/storage/btree_storage.rb
UTF-8
1,118
3.171875
3
[]
no_license
# Balanced tree storage for Key-Value Database require 'binary_search_tree' require 'binary_search_tree_hash' require 'json' require_relative 'btree' require_relative 'base_storage' require_relative '../yakvd_constants' class BtreeStorage < BaseStorage # Using binary search tree to store values in RAM def initia...
true
7a32754f474bf48ad36824041d452b59649823b4
Ruby
NickSealer/singleton_pattern
/conexion.rb
UTF-8
384
2.859375
3
[]
no_license
class Conexion # Instancia que llama la creación de la clase Singleton @instance = new # Método privado de clase para la creación private_class_method = :new # Método estático que permite crear una subclase mientras mantiene sólo una instancia def self.get_singleton puts "Se realiza conexión con la in...
true
d819c21ff0e526680eef447be1a7a965983a3a90
Ruby
mayaugusto7/learn-ruby
/modulo10-strings-02/iterate_over_string_characters.rb
UTF-8
162
3.265625
3
[]
no_license
#"Hello world".each_char {|char| puts char} name = "Maycon" p name.split("") letters = name.chars letters.each {|letter| puts "#{letter} is awesome!"}
true
d3dcad6e60fbc5d97a1113263da2024fafe86d92
Ruby
solongtony/sbin
/ruby/gen_mac.rb
UTF-8
511
3.25
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby # Create MAC address formatted string: # xx:xx:xx:xx:xx:xx # where each x is a hexidecimal digit. # TODO: optionally take a seed value. # The seed could come from hashing the date and network interface, # then each interface would get a consistent value for a day. require 'securerandom' raw_ma...
true
3809f078cc7638a818dead91d596ff601d44c3b4
Ruby
gardenFiend138/classwork
/week_1/w1d2/projects_W1D2/Memory/Board.rb
UTF-8
957
3.765625
4
[]
no_license
require_relative "Card" class Board attr_accessor :grid def initialize(size = 4) @grid = Array.new(size) { Array.new(size) } end def count @grid.flatten.length end def deck deck = [] (count / 2).times do |value| 2.times { deck << Card.new(value) } end deck.shuffle end ...
true
7dcf4394bea10e0b3d4054686a5e5715b9e1d600
Ruby
samflores/apricot
/lib/apricot/seq.rb
UTF-8
3,370
2.78125
3
[ "ISC" ]
permissive
module Apricot # Every seq should include this module and define 'first' and 'next' # methods. A seq may redefine 'rest' and 'each' if there is a more efficient # way to implement them. # # 'first' should return the first item in the seq. # 'next' should return a seq of the rest of the items in the seq, or ...
true
dfb24d555a477b98d73a3d82fb9fa6714b132ea7
Ruby
sammarcus/kwk-l1-user-input-mini-lab-teachers-l1
/spec/trip_spec.rb
UTF-8
1,985
3.59375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'spec_helper' describe 'trip.rb prompts the user for the right information' do it 'outputs a welcome message that prompts the user for input' do allow($stdout).to receive(:puts) allow(self).to receive(:gets).and_return("California") expect($stdout).to receive(:puts).with(/where/i), "Make sure so...
true
32990381a6f72ace3ec7348657c090b7f5520b8f
Ruby
ke-pan/tealeaf_intro_blackjack
/deck.rb
UTF-8
692
3.578125
4
[]
no_license
require_relative "card" require_relative "utils" class Deck SUITS = ['spades', 'hearts', 'diamonds', 'clubs'] VALUES = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] ONE_DECK = VALUES.product(SUITS) include Utils attr_accessor :cards, :number def initialize(number=1) number = 1...
true
5205bd5dd2cda5dec631dd89426c83c35aca7634
Ruby
toggit/corona
/lib/corona/core.rb
UTF-8
5,930
2.53125
3
[]
no_license
require_relative 'log' require_relative 'config' require_relative 'snmp' require_relative 'db/db' require_relative 'model' require 'ipaddr' require 'resolv' module Corona class << self def new opts={} Core.new opts end def poll opts={} host = opts.delete :host raise CoronaError, '\'hos...
true
c3f2e9aae34637f93acc83a18e907afd3e666229
Ruby
dzintarsm/apimation_kurss
/features/step_definitions/2.majas_darbs_steps.rb
UTF-8
6,764
2.59375
3
[]
no_license
require 'rest-client' require 'test-unit' When(/^I create a new project$/) do login_positive #first login to generate a cookie @test_user.session_cookie.to_json project_name = (0...10).map { (65 + rand(26)).chr }.join #generate random project name project_payload = { :name => project_name, ...
true
76dc659b7e8890c55cc668fc5fae3d332d0f6c45
Ruby
Metal-Milonga/ruby-object-attributes-lab-v-000
/lib/person.rb
UTF-8
147
2.625
3
[]
no_license
class Person def name=(dog_name) @name = dog_name end def name @name end def job=(dog_job) @job = dog_job end def job @job end end
true
1ad49cf60c50ebb3e489eafb62f15001531a3714
Ruby
ken-phu-nti-johanneberg/Repetition-slutprov
/IL _och _filsystem/highest_and_lowest.rb
UTF-8
611
3.515625
4
[]
no_license
def highest_and_lowest() user_input = "" highest = 0 while user_input < "exit" user_input = gets.chomp if user_input == "q" user_input = "exit" elsif user_input.to_i > highest highest = user_input.to_i end puts "Det största talet just nu är ...
true
6e33370e540543380df7a2e3da5e68ffdd87dcf5
Ruby
eboskma/RPS
/players/mtnw_player.rb
UTF-8
1,369
3.0625
3
[]
no_license
require File.expand_path('../../lib/player.rb', __FILE__) class MTNWPlayer < Player attr_accessor :history_me attr_accessor :history_them def initialize(opponent) super @history_them = [] @history_me = [] end def choose if @history_them.size > 0 && @history_me.size > 0 if @history_th...
true
ce658fb765275296bbc63a1733b0e8cceabef60a
Ruby
KwonL/CTF-practice
/2018/hackover_CTF/who_knows_john_dows/user_repository/user_repo.rb
UTF-8
716
3.171875
3
[]
no_license
class UserRepo def initialize(database) @database = database @users = database[:users] end def login(identification, password) hashed_input_password = hash(password) query = "select id, phone, email from users where email = '#{identification}' and password_digest = '#{hashed_input_password}' lim...
true
19db1e74838c760da6f8520082944a79c098b31c
Ruby
bookeee/high_load_app
/spec/queries/concerns/serializable_spec.rb
UTF-8
967
2.578125
3
[]
no_license
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Serializable' do before do @test_class = Class.new @instance = @test_class.new @test_class.include(Serializable) end describe '#serialize' do it 'serializes given array' do array = [1, 2, 3, 4, 5] result = @instanc...
true
e29269d888a2d5ca1d850cd3acde767cd32fb084
Ruby
bubbadog/ruby_book
/methods/methods_exercises.rb
UTF-8
520
4.375
4
[]
no_license
=begin # 1. def greeting name puts "Howdy #{name}!" greeting("Justin") =end # 2. evaluate to 2, nil, "Joe", "four", nil # 3. =begin def multiply (x, y) return x * y end puts multiply(2,4) =end # 4. It will print nothing - the return stops the method from getting to the "puts words" line # 5. It returns words (Yipp...
true
e195d7155ae3244c28311868f5af0a4320c5e761
Ruby
adharmad/jruby-examples
/tryJavaEx.rb
UTF-8
329
3.203125
3
[]
no_license
# try exception handling in java # require 'java' include_class('java.lang.String') {|package,name| "J#{name}" } include_class('java.lang.Exception') {|package,name| "J#{name}" } begin s = JString.new('abc') c = s.charAt(10) puts c rescue JException => ex puts "Java exception #{ex.message...
true
e8b7a3f021cb407a679dfe35e800f30582593466
Ruby
claire-c/cc_w2_d1_homework
/sports_team/specs/sports_team_spec.rb
UTF-8
1,572
3.296875
3
[]
no_license
require('minitest/autorun') require_relative('../sports_team.rb') class TestTeam < MiniTest::Test def test_team_getter() team = Team.new("Dolphins", ["Player1", "Player2", "Player3"], "Coachy McCoachFace") assert_equal("Dolphins", team.team_name()) assert_equal(["Player1", "Player2", "Player3"], team.t...
true
fae2d07f91eca398f5bf09cf6765a94fbd50884c
Ruby
adamfortuna/miro
/lib/miro/dominant_colors.rb
UTF-8
4,415
2.515625
3
[ "MIT" ]
permissive
require 'shellwords' module Miro class DominantColors attr_accessor :src_image_path def initialize(src_image_path, image_type = nil) @src_image_path = src_image_path @image_type = image_type end def to_hex return histogram.map{ |item| item[1].html } if Miro.histogram? sorted...
true
d0b2fdb7e1960a5a26d4a698f1f71c8aa8b56bd2
Ruby
stesie/ruby-todoist-api
/lib/todoist/command.rb
UTF-8
568
2.578125
3
[ "MIT" ]
permissive
module Todoist class Command attr_accessor :type, :object, :temp_id, :uuid def initialize(type, object, temp_id = nil, uuid = nil) @type = type @object = object @temp_id = object.is_a?(Todoist::Resource) ? object.temp_id : temp_id @uuid = uuid || SecureRandom.uuid end def arg...
true
1dc614bae04dd01dc099addf4958093b8c005710
Ruby
temojin/rdf-n3
/lib/rdf/n3/reader.rb
UTF-8
18,183
2.640625
3
[ "MIT" ]
permissive
require 'treetop' Treetop.load(File.join(File.dirname(__FILE__), "reader", "n3_grammar")) module RDF::N3 ## # A Notation-3/Turtle parser in Ruby # # @author [Gregg Kellogg](http://kellogg-assoc.com/) class Reader < RDF::Reader format Format N3_KEYWORDS = %w(a is of has keywords prefix base true fal...
true
63a19dd30c6663e2c4f67963ada822ccef9702a4
Ruby
Tludi/tricalendar
/lib/simple_calendar/three_month_calendar.rb
UTF-8
240
2.703125
3
[]
no_license
module SimpleCalendar class ThreeMonthCalendar < SimpleCalendar::Calendar private def date_range beginning = start_date.beginning_of_month ending = start_date.end_of_month + 2.months (beginning..ending).to_a end end end
true
7fba2ff34905b2e41e23c7f46628ca45c8dede26
Ruby
bendyorke/stackshare
/rec_engine.rb
UTF-8
2,057
2.734375
3
[]
no_license
require_relative 'assert.rb' require_relative 'api.rb' module RecEngine @api = Api.new(ENV['STACKSHARE_ACCESS_TOKEN']) def recommend_for_tag tag_id stacks = @api.fetch_stacks tag_id recommend_for_stacks stacks end module_function :recommend_for_tag def recommend_for_stacks stacks tools = tools_...
true
a14fcf923263cc2d9ab9bcb837e7af4eb5c95d66
Ruby
harpreetsingh500/ruby_exercises
/ch_exercises/exercise_16.rb
UTF-8
195
2.875
3
[]
no_license
a = ['white snow', 'winter wonderland', 'melting ice', 'slippery sidewalk', 'salted roads', 'white trees'] new_a = [] a.each do |ele| new_a << ele.split end p new_a.flatten!
true
6f6bc5ea360dce86cae7979ce86e8f6a2910ebb5
Ruby
pdarden/library
/lib/seeders/categories.rb
UTF-8
399
2.5625
3
[]
no_license
module Seeders module Categories class << self def seed categories.each do |name| Category.find_or_create_by(name: name) do |category| category.name = name end end end def categories [ "Children", "Fiction", "N...
true
45305656debdc93523b2c895f3f4f7e6d36a9fd9
Ruby
bmaljai/ruby_review
/bank.rb
UTF-8
1,192
3.046875
3
[]
no_license
client_info = [] 5.times do hash = {} puts "enter first name" first_name = gets.chomp puts "enter last name" last_name = gets.chomp email = "" email_last = '' # until (email.include?("@") && email_last.include?(".com")) puts "enter email" email = gets.chomp email_test = ...
true
b9474ad1148e725f846fb54ee2a5966adc18e29d
Ruby
neosaurrrus/sinatra-mvc-lab-online-web-sp-000
/models/piglatinizer.rb
UTF-8
1,075
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class PigLatinizer # def initialize(phrase) # @words = phrase.split(" ") # end def piglatinize(phrase) @words = phrase.split(" ") return self.convert end def convert @converted_phrase = @words.map { |word| if get_starting_consonants(word).length == 0 ...
true
da18280f6465d721f27ed674b2ee6f3e6ffe7acd
Ruby
jbshipman/ruby-oo-relationships-practice-art-gallery-exercise-austin-web-012720
/app/models/gallery.rb
UTF-8
651
3.296875
3
[]
no_license
class Gallery attr_reader :name, :city @@all = [] def self.all @@all end def initialize(name, city) @name = name @city = city @@all << self end def paintings # all the paintings in specific gallery Paintings.all.select {|p| p.gallery == self} end def artists # all th...
true
d76bd2edee37d13bbe239966af249d174190ce40
Ruby
jonathanlofton/App-Academy
/W3/W3D2/question.rb
UTF-8
913
3.015625
3
[]
no_license
require_relative 'questions_database.rb' require 'sqlite3' class Question def self.find_by_id(id) data = QuestionsDatabase.instance.execute(<<-SQL, id) SELECT * FROM questions WHERE id == ? SQL data = data[0] Question.new(data) end def self.find_by_author_id(auth_...
true
c1e708e56170ee2d7eae5f936d4a03b88d12b0c9
Ruby
daisukhayash/HitAndBlow
/spec/digit_spec.rb
UTF-8
5,823
2.953125
3
[]
no_license
# -*- encoding: utf-8 -*- require (File.dirname(__FILE__) + '/spec_helper') require 'hitandblow/solver' describe HitAndBlow::Solver::Candidate::Digit do describe 'default' do it 'create an instance that has a set of 0-9 and default weight' do weight = 20.0 HitAndBlow::Solver::Candidate::Digit.defaul...
true
cd80a83fd0af2a669889d863108f94e2c8374a44
Ruby
archiloque/tyrano_dsl
/lib/tyrano_dsl/export_dsl/words/declare_character.rb
UTF-8
1,267
2.5625
3
[ "MIT" ]
permissive
require_relative 'call_parameter' require_relative 'base_word' class TyranoDsl::ExportDsl::Words::DeclareCharacter < TyranoDsl::ExportDsl::Words::BaseWord CALL_PARAMETERS = [ TyranoDsl::ExportDsl::Words::CallParameter.new( :character_name, String ), TyranoDsl::ExportDsl::Words:...
true
b504eb6f3cd73c52e6d6ad25f211fece4b4a4e46
Ruby
IMP1/blossom
/ruby_interpreter/objects/condition_expression.rb
UTF-8
3,727
3.171875
3
[ "MIT" ]
permissive
require_relative 'label_value_expression' class ConditionExpression include Visitable def variable? raise "Not implemented in this child class (#{self.class.name})." end def type raise "Not implemented in this child class (#{self.class.name})." end end class LiteralConditionExpr...
true
8f3f26a8ef3f70bb2c6b78d359cb0550fb2f752e
Ruby
kylemccurley/RB101_Programming_Foundations
/Lesson4_Ruby_Collections/Selection_And_Transformation/double_odd_numbers.rb
UTF-8
330
3.71875
4
[]
no_license
def double_odd_numbers(numbers) counter = 0 loop do numbers[counter] *= 2 if counter.odd? counter += 1 break if counter == numbers.size end numbers end my_numbers = [1, 4, 3, 7, 2, 6] p "My Numbers Pre-Mutation: #{my_numbers}" p "My Numbers Post-Mutation: #{double_odd_numbers(my_numbers)}" # => [2, 4, 6, ...
true
896350d1c9e0f099b8abac4051f07ad7487068aa
Ruby
dmaaron/Cucumber_lab
/features/step_definitions/multiply_steps.rb
UTF-8
588
2.515625
3
[]
no_license
require 'watir' browser = Watir::Browser.new url = "http://localhost:3000" Given(/^I visit the calculator page for multiply$/) do browser.goto "#{url}/multiply" end Given(/^I fill in '(\d+)' for 'm_first'$/) do |number| browser.text_field(:id=>"m_first").set number end Given(/^I fill in '(\d+)' for 'm_second'$/)...
true
1059db1e17faed4e55a2964141814711b02ac097
Ruby
alberto/rublo
/test/post_repository_test.rb
UTF-8
2,003
2.90625
3
[]
no_license
require_relative '../lib/post' require_relative '../lib/post_repository' require_relative '../lib/yaml_post_generator' require_relative 'test' require_relative 'post_factory' class PostRepositoryTest < Test def cannot_save_an_invalid_post repository = PostRepository.new([]) post = Post.new({}) begin ...
true
5e86fdf643123a4f117ddd6bd587626e859ffd06
Ruby
psalmdawg/farmerapp
/main.rb
UTF-8
5,055
2.734375
3
[]
no_license
require 'sinatra' require './db_config' require './models/item' require './models/user' require './models/message' require 'pg' enable :sessions helpers do def current_user User.find_by(id: session[:user_id]) end def logged_in? !!current_user end end after do ActiveRecord::Base.connection.close ...
true
395b50a731036b6d4667ae425161034d1bc5b733
Ruby
afolmert/daily-programmer
/137_easy_string_transposition/Ruby/worksafe_shit_only.rb
UTF-8
431
3.765625
4
[]
no_license
#!/usr/bin/ruby def to_put (string) arr = string.split(/\n/) arr.delete_at(0) y = arr.sort { |x, y| y.length <=> x.length } #Finds the longest word and places it first in array y arr.each do |x| x << " " * (y[0].length - x.length) end final = String.new for i in 1..y[0].length ...
true