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
2cc8a1d199d8328f0bf80273b25418b388e83c51
Ruby
apohllo/rlp-grammar
/lib/rlp/grammar/compound_value.rb
UTF-8
560
2.78125
3
[]
no_license
# encoding: utf-8 require 'rlp/grammar/value' module Rlp module Grammar # Class representing compound values, such as 'm1.m2.m3'. class CompoundValue < Value has_many :values def initialize(*args) super(*args) if args[0].is_a?(Hash) if args[0][:values] self....
true
00f81c94c51a5045c90b01a8ffb6d37b8c81abf9
Ruby
anilrayamajhi/learnPractice_BookReviewSite_rails
/app/controllers/books_controller.rb
UTF-8
1,174
2.609375
3
[]
no_license
class BooksController < ApplicationController before_action :find_book, only: [:show, :edit, :update, :destroy] #before_action will run first and only render things inside find_book private method with find, edit and destroy action; this help to code dry by not repeting code over and over again by simply pointing t...
true
05a8f8172c5a43cb9b00b40c7d84080f0ac61d4f
Ruby
Apololo/RoR-Ruby-Basics
/1Lesson/29_task.rb
UTF-8
171
3.015625
3
[]
no_license
#87. Дан целочисленный массив. Найти все четные элементы. ar =[ 5, 6, 4, 8, 4, 2, 12, 3 ] p ar.select{|element| element.even?}
true
4a1b4c98f25b2806250ecca6da10239f5cab0a3f
Ruby
W-Mills/ruby-exercises
/Code Challenges/Easy/sieve_of_eratosthenes.rb
UTF-8
2,964
4.59375
5
[]
no_license
# Sieve of Eratosthenes # Write a program that uses the Sieve of Eratosthenes to find all the primes from 2 up to a given number. # The Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e. not prime) the multiples...
true
284135463e7dc6ec21c26fed01537296db32540e
Ruby
prokizzle/oknamechanges
/app/models/profile.rb
UTF-8
1,528
2.609375
3
[]
no_license
# OKCupid profile page parser class Profile require 'nikkou' def self.parse(result) return { inactive: true, message: result[:error] } if result[:inactive] html = build_page(result) { a_list_name_change: name_change(result, html), handle: ajax_field('basic_info_sn', html), intended_handle: ...
true
89eb974a61eafce375e151f86993f360a0e3f35f
Ruby
radvc/hello_crush
/lib/hello_crush/give.rb
UTF-8
237
3.203125
3
[ "MIT" ]
permissive
module HelloCrush class Give def initialize(name) @name = name end def for_you "#{@name} #{randomg_thing} for you." end private def randomg_thing HelloCrush::THINGS.sample end end end
true
fe563233c2b72d9a1b4210296ecdfc6aa2b2bf21
Ruby
elmrabet/TopoMaker
/Interface.rb
UTF-8
780
2.671875
3
[]
no_license
class Interface #confname is the name of the interface in the input file #nodename is the hostname of the node associated to this interface #realname is the name like eth0 #kavlan is an Object Vlan attr_accessor :nodename, :ip, :netmask, :kavlan, :realname attr_reader :confname, :device def initialize...
true
dae38030389c33bfe290099d7bd6c2187547e7c4
Ruby
iFytil/Battleships
/app/models/move.rb
UTF-8
17,805
2.65625
3
[]
no_license
class Move < ActiveRecord::Base validates_inclusion_of :kind, :in => [ "Move", "Cannon", "Rotate", "Radar", "Repair", "Mine", "Torpedo", "Kamikaze" ] belongs_to :ship belongs_to :game after_create do |move| # Associate game with ship move.game_id = ship.game_id # Default message move.messag...
true
f5d78fc8be1131bb52e60b268b90790628572b49
Ruby
iCarrrot/Studies
/Object programming/l8/z1.rb
UTF-8
1,121
3.703125
4
[ "MIT" ]
permissive
class Fixnum def prime? if self<=1 return false end if self%2 == 0 && self !=2 return false elsif self ==2 return true end i=3 while i*i<=self do if self%i==0 return false end i+=2 end return true end def ack(y) if self ==0 return y+1 elsif y==0 return (self-1).ack...
true
50fc60e90dd05faf53b8e1d2017bee48daf4fc8a
Ruby
joaozeni/SumOneChallenge
/lib/twitterCrawler/myCrawler.rb
UTF-8
1,195
3.03125
3
[]
no_license
require 'twitter' require 'rest-client' require 'dotenv' Dotenv.load class MyCrawler attr_reader :client, :status, :filterThread def initialize @client = Twitter::Streaming::Client.new do |config| config.consumer_key = ENV['CONSUMER_KEY'] config.consumer_secret = ENV['CONSUMER...
true
9c6f3cb6016140db9e4783f3071e25807fdb7d69
Ruby
mark-c-81/rails-yelp-mvp
/db/seeds.rb
UTF-8
931
2.8125
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). # puts "Cleaning database..." Restaurant.destroy_all puts "Creating restaurants..." dishoom = { name: ...
true
f85c528b99753298f7d284d85f6f3d63261ee730
Ruby
kiela/fc-reminder
/lib/fc-reminder/gateways/twilio.rb
UTF-8
730
2.609375
3
[ "BSD-3-Clause" ]
permissive
require 'twilio-ruby' module FCReminder module Gateways class Twilio < Base def client @client ||= ::Twilio::REST::Client.new( config[:account_sid], config[:auth_token] ) end def send(recipient, data) client.account.messages.create( from: c...
true
8445a44c37961dfdd6a13bfb22b642f738b88afc
Ruby
chrisschwer/wahlomat-visualization
/render.rb
UTF-8
1,557
2.875
3
[ "MIT" ]
permissive
#!/usr/bin/ruby require 'csv' require 'gv' G = Gv.graph("G") N = Gv.protonode(G) E = Gv.protoedge(G) Gv.setv(G, 'rankdir', 'LR') Gv.setv(G, 'outputorder', 'edgesfirst') Gv.setv(N, 'shape', 'ellipse') Gv.setv(N, 'margin', '.04') Gv.setv(N, 'fontsize', '11') Gv.setv(N, 'style', 'filled') Gv.setv(N, 'fillcolor', '#ffff...
true
e80656c84ef619a14b99b7850c69c88c04bba87e
Ruby
rishijain/dragoneggs
/components/basket.rb
UTF-8
255
2.828125
3
[]
no_license
class Basket attr_accessor :x, :y, :w, :h def initialize(window, x, y) @x = x @y = y @w = 10 @h = 20 @image = Gosu::Image.new(window, 'basket.png', false) end def draw @image.draw(@x, @y, 1) end def update end end
true
5a67f9981c39606a8918a61bcf4b3a43416f787f
Ruby
mwagner19446/wdi_work
/w03/d01/INSTRUCTOR/grammys/spec/grammy_spec.rb
UTF-8
2,920
3.40625
3
[]
no_license
require_relative "../lib/grammy" require "spec_helper" describe Grammy do describe "::all" do it "returns all of the instances" do Grammy.clear pop_album = Grammy.new(2014, "Best Pop Vocal Album", "Unorthodox Jukebox by Bruno Mars") dance_recording = Grammy.new(2014, "Best Dance Recording", "C...
true
0384ff948bf0c57580a7fc957982685839c49107
Ruby
trobb10/toy_app
/test/poop/learn_spec.rb
UTF-8
441
2.703125
3
[]
no_license
require 'ruby.rb' describe Learn do context "When testing the Learn class" do it "should not have any vowels" do learn = Learn.new str = “bcdfg” count = learn.countVowels str expect(countVowels).to eql 0 end it "should have some vowels", vowels: true do learn = Learn.new ...
true
8a6a09209f8b85bca7bb95c6132b96ca44bb724f
Ruby
ylumbangaol/Progate
/Ruby/ruby_study_4/page6/index.rb
UTF-8
471
3.9375
4
[]
no_license
class Menu attr_accessor :name attr_accessor :price end menu1 = Menu.new menu1.name = "Pizza" puts menu1.name menu1.price = 8 puts menu1.price # Assign an instance of Menu to the menu2 variable menu2 = Menu.new # Assign "Sushi" to the name of the menu2 instance menu2.name = "Sushi" # Print the name of the men...
true
566a3f539b46750f73d1bfe7ca8b2ed2a43d7243
Ruby
aiya000/workspace
/Ruby/Fundament/Notate/Method/transfer_iterator.rb
UTF-8
224
3.515625
4
[]
no_license
# has iterator like values def f yield 10 yield 20 yield 30 end # transfer iterator block to 'f' def g(&block) # If you want to know more, f(&block) # read './higher_method.rb' end # g{|n| puts n}
true
596e6b06869e23a9b68e6b7f955a76d475aaad55
Ruby
917391/image_blur
/image_blur_3.rb
UTF-8
2,681
3.609375
4
[]
no_license
class Image attr_accessor :image def initialize(image) @image = image end def output_image rowstring = "" image.each do |x| rowstring = "" x.each do |pixel| rowstring += pixel.to_s end ...
true
ba3d947e7166b07179a00206bb53382ec7393eb7
Ruby
fredster7474/homework1
/main.rb
UTF-8
897
3.484375
3
[]
no_license
# main.rb system "clear" require 'json' def read_contacts contacts_json = File.read("contacts.json") return JSON.parse(contacts_json, { symbolize_names: true }) end array = read_contacts #1 def contact_phone_and_name(contacts) phone_and_name = contacts.map{ |contact| { contact[:name] => contact[:phone] } } ...
true
3f0b6f8bed8ac6c8062797aaa9eeb7d34f0d1282
Ruby
casp3rus/100DaysOfAlgo
/079WaterArea/water_area.rb
UTF-8
616
3.484375
3
[ "MIT" ]
permissive
# Solution 1 # O(n) time / O(n) space def water_area(heights) maxes = Array.new(heights.length, 0) left_max = 0 (0...heights.length - 1).each do |i| height = heights[i] maxes[i] = left_max left_max = [left_max, height].max end right_max = 0 (heights.length - 1...0).each do |i| height = he...
true
092647eb0ea183afe6ac8267c192199aa1d31489
Ruby
jthigpen/SimCheez
/moderator.rb
UTF-8
751
2.53125
3
[]
no_license
require 'rubygems' load './simcheez.rb' class ModeratorMessageHandler < MessageHandler def asset_created(msg) if Random.rand > 0.5 puts "Moderating Asset Approved: #{msg.asset_id}" publish(AssetApprovedMessage.new(msg.asset_id)) else puts "Moderating Asset Denied: #{msg.asset_id}" p...
true
102e5414191b5e7dd99b0e4033c3a6f52f476efe
Ruby
bryanco1966/Jungle_beat
/test/test_node.rb
UTF-8
391
2.703125
3
[]
no_license
require "minitest/autorun" require "minitest/pride" require "./lib/node" require "pry" class NodeTest < Minitest::Test #Whant to make sure you are bringing in a new node that has a string component and a #il marker def test_data node = Node.new("plop") assert_equal "plop", node.data end def test_next_ni...
true
088c74fc07e96536775c0a918215ff1f63c7bbdd
Ruby
akubaisi/HW2
/spec/models/visit_spec.rb
UTF-8
2,680
2.8125
3
[]
no_license
require 'spec_helper' describe Visit do before(:each) do before(:each) do #look at factory, is there any visit here? No, so we create a visit factory (found below #at factories ...) @owner = FactoryGirl.create(:owner) @puss = FactoryGirl.create(:pet, :owner => @owner, :name => "Puss") @boots = FactoryGirl.cre...
true
95f684fc325092410a68f91781c95b73112adda4
Ruby
ucarion/onyx
/test/test_board.rb
UTF-8
6,450
3.046875
3
[]
no_license
require_relative 'test_helper' class MoveTest < Onyx::TestCase def setup @board_to_s = <<-BOARD 1 2 3 4 5 6 7 8 +---+---+---+---+---+---+---+---+ h | r | n | b | q | k | b | n | r | h +---+---+---+---+---+---+---+---+ g | p | p | p | p | p | p | p | p | g +---+---+---+---+---+--...
true
aa62fd84eeaa358af21f0cf1daa8c721c594f145
Ruby
AneesShaik/ruby
/chapter_8/exercise_1.rb
UTF-8
1,735
4.34375
4
[]
no_license
def english_number(number) if number < 0 return "Please enter a number that isn't negative." end if number == 0 return "zero" end num_string = "" ones = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] tens = ['Ten', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seve...
true
56cdfc8fe34c8a917fbce43c78ad3cc2b50122e2
Ruby
EmilyAnne39/ruby_practice
/repeat.rb
UTF-8
113
2.703125
3
[]
no_license
while true input = gets.chomp puts input if input == 'I am a dummy' break end end
true
3b4bad8e8daf713c4ebfd01cb13e3c87b57c0853
Ruby
malevolentninja/Codeacademy
/Ruby/8. Blocks-ProcsAndLambdas/Blocks,ProcsAndLambdas.rb
UTF-8
514
3.421875
3
[]
no_license
# 1. You Know this! # 2. Collect 'Em All # 3. Learning to Yield # 4. Yielding With Parameters # 5. Try It Yourself! # 6. Keeping Your Code DRY # 7. Proc Syntax # 8. Why Procs? # 9. Creat Your Own! # 10. Call Me Maybe # 11. Symbols, Meet Procs # 12. The Ruby Lambda # 13. Lambda Syntax # 14. Lambdas vs. Procs # 15. N...
true
862c9e437e57fd27b461bc6715963955d020cfc1
Ruby
k3ntako/super-tic-tac-toe
/spec/lib/input_validator_spec.rb
UTF-8
4,804
2.890625
3
[]
no_license
require_relative '../../lib/input_validator' RSpec.describe InputValidator do let(:ui) do cli = CLI.new UserInterface.new(cli) end let(:game_messenger) { GameMessenger.new(user_interface: ui, message_generator: GameMessage.new) } let(:input_validator) { InputValidator.new } let(:board) { Board.new(wi...
true
b10ebe475390a2246c0be3493f2032fd5ff35f5e
Ruby
hamxiaoz/cmd
/lib/cmd.rb
UTF-8
16,433
3.03125
3
[ "MIT" ]
permissive
READLINE_SUPPORTED = (require 'readline'; true) rescue false require 'abbrev' # A simple framework for writing line-oriented command interpreters, based # heavily on Python's {cmd.py}[http://docs.python.org/lib/module-cmd.html]. # # These are often useful for test harnesses, administrative tools, and # prototypes th...
true
d2c5785ad6192a1f76cae57e6a19b9857e04d139
Ruby
vinbarnes/presentation_testing_why_dont_we_do_it_like_this
/src/fab/fab.rb
UTF-8
208
3
3
[]
no_license
require 'fabrication' class Dog attr_accessor :head, :tail def to_s "<Dog head:#{head}, tail:#{tail}>" end end Fabricator(:dog) do head "HEAD" tail "TAIL" end dog = Fabricate(:dog) puts dog
true
dce4a26758c7eba043cc145aa219891e81048e98
Ruby
davegregg/first_app
/filler.rb
UTF-8
609
3.03125
3
[]
no_license
require 'ffaker' class Filler @@new_lipsum = -> { FFaker::HTMLIpsum.body } @@new_name = -> { FFaker::Name.first_name } @@static_lipsum = @@new_lipsum.call @@welcome = 'We welcome you. Join us. Leave all aseity behind. ' + 'Be one with the Oneness in which all is naught.' class << self d...
true
808e57df3a1fb553f3625c1cafa0cf743ab8e568
Ruby
mmclead/realtorminis
/app/models/site.rb
UTF-8
2,222
2.5625
3
[]
no_license
class Site < ActiveRecord::Base include AwsConnection belongs_to :listing belongs_to :user has_many :custom_domain_names, through: :listing validates_presence_of :listing validates_presence_of :site_code before_validation :listing_must_be_paid_for before_save :upload_to_aws def active_status ...
true
d02ed6b82dac98bae0a4dae10044d05fb5402763
Ruby
walidwahed/ls
/120-oop/lesson_4-exercises/easy3/07.rb
UTF-8
851
4.28125
4
[]
no_license
# Question 7 # What is used in this class but doesn't add any value? class Light attr_accessor :brightness, :color def initialize(brightness, color) @brightness = brightness @color = color end def self.information return "I want to turn on the light with a brightness level of super high and a co...
true
9a41c9baf34e056567cbdf7abeb8ec7ef018da2f
Ruby
gsamokovarov/rspec-xunit
/test/rspec/xunit/assertions_test.rb
UTF-8
1,531
2.59375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'test_helper' RSpec.case RSpec::XUnit::Assertions do test 'assert_truthy' do assert_truthy true end test 'assert_falsy' do assert_falsy false end test 'assert_nil' do assert_nil nil end test 'assert_eq' do assert_eq true, true assert_not_eq tr...
true
f543805b0e8b10435cf53d39a0f8f2d88dd93c7c
Ruby
dexterfgo/bcap_bake_my_day
/lib/bake_my_day/item.rb
UTF-8
254
3.21875
3
[ "MIT" ]
permissive
class Item attr_reader :code, :description attr_accessor :packages def initialize(code, desc) @code = code @description = desc @packages = Hash.new end def add_package_for_code(quantity, price) @packages.store(quantity, price) end end
true
61e791a4a39454ae88e16b30729faea270720fa4
Ruby
salomekbg/dice-roll-ruby-001-prework-web
/dice_roll.rb
UTF-8
86
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
=begin def roll rand(1..6) end =end def roll [1, 2, 3, 4, 5, 6].sample end roll
true
f76e69497d924364d76771e0f5f95be441f70125
Ruby
notCalle/seb2csv
/lib/seb2csv/sebank.rb
UTF-8
904
2.8125
3
[ "MIT" ]
permissive
require 'roo' require 'ostruct' require 'yaml' require 'csv' class SEB2CSV class SEBank def initialize(files, out = STDOUT, options = SEB2CSV::DEFAULTS["sebank"]) header = options.reduce([]) do |all, item| key, value = item.flatten all << key end rowitems = options.reduce([]) d...
true
0f445a92b69df99bf5da16b9ce345db0b23315a9
Ruby
alex-choy/a-A_notes
/01_week/03_day/nauseating_numbers/lib/03_nauseating_numbers.rb
UTF-8
2,593
3.6875
4
[]
no_license
require_relative "02_nauseating_numbers" ############################## ##### Matrix Addition Reloaded # def matrix_addition_reloaded(*matricies) # return nil if !right_matrix_size?(matricies) # res = [] # m_col_len = matricies[0].length # m_row_len = matricies[0][0].length # done in this order to go through e...
true
a381aa94181d73a183b166124044df9d7f06942c
Ruby
sp0gg/exercism
/ruby/proverb/proverb.rb
UTF-8
692
3.828125
4
[]
no_license
# Write your code for the 'Proverb' exercise in this file. Make the tests in # `proverb_test.rb` pass. # # To get started with TDD, see the `README.md` file in your # `ruby/proverb` directory. class Proverb attr_reader :words, :qualifier def initialize(*words, qualifier: nil) @words = words @qualifier = q...
true
40384fd1d902ccfc2b324362f0b3691eb750b500
Ruby
Charliebr73/airport
/lib/test.rb
UTF-8
190
3.1875
3
[]
no_license
def weather @weather_status = 1 * rand(10) if @weather_status < 7 puts "weather is sunny. Airport is open." else puts "weather is stormy. Airport is closed." end end weather
true
29ebb3f0f636a8b91b1a4322da26d0068040c9c3
Ruby
colleenmcguckin/ethnio-js
/app/pdfs/pdf_lead_sheet.rb
UTF-8
1,588
2.546875
3
[]
no_license
class PdfLeadSheet < Prawn::Document def initialize(id) song = Song.find_by(id: id) logo = "#{Rails.root}/app/assets/images/notebook-nav-icon.png" previous_chord = "" beat_unit = song.time_signature.beat_unit counter = 0 super(left_margin: 40) image logo, :scale => 0.5 move_down 8 text...
true
7d35a116ca36d346f6ac1f936f21ecf7a16bea82
Ruby
terry90/doc-bot
/plugins/facebook_share_plugin.rb
UTF-8
521
2.796875
3
[ "MIT" ]
permissive
require 'uri' require 'social_shares' class FacebookSharePlugin < DocBotPlugin def get_share(url) SocialShares.facebook url end def msg(opts) message = opts[:data].text my_turn?(message) or return nil ret = '' urls = URI.extract(message) shares = [] urls.each do |url| shar...
true
8a41a2ad467cfc1fce71c17fb52319dacf11624f
Ruby
yir17/desafios
/3solo_pares.rb
UTF-8
276
3.921875
4
[]
no_license
=begin Crea un programa llamado solo_pares.rb que muestre los primeros n números pares, donde n es ingresado por el usuario. Uso: ruby solo_pares.rb 5 0 2 4 6 8 =end number = ARGV[0].to_i i = 0 while (i < number *2) if i.even? puts i end i += 1 end
true
4b51f6f48422f6b1a023d282d4ea22eedd9d6533
Ruby
olleolleolle/wlang
/lib/wlang/errors.rb
UTF-8
2,270
3.125
3
[ "MIT" ]
permissive
module WLang # Main error of all WLang errors. class Error < StandardError # The parser state whe this error has been raised attr_accessor :parser_state # Optional cause (other lower level exception) attr_accessor :cause # Creates an error instance with a given parser state ...
true
9ccd9918cd23c844a78890a4530686309e3cb8cb
Ruby
gosaleskick/pipedrive
/spec/support/token_ar.rb
UTF-8
1,120
2.640625
3
[ "MIT" ]
permissive
# frozen_string_literal: true class TokenAR # decrypted string: access_token ENCRYPTED_ACCESS_TOKEN = "\xEB\x0EZZ>\xFC,T\xF0\xE0\xD7Y\x99\xAD\xE4\xACu^\x10\x1E@\x86L\xEE^\xA6\x96R\xD3I\x95y\x8D\x97\xC79\x1E\xA3\xF4\xB3\xC99\x9C\xC42\v\x90?\n\xB6|\x8B" # decrypted string: refresh_token ENCRYPTED_REFRESH_TOKEN =...
true
cb6e562931b86c3f7f3ec9298ae829f11c8843bc
Ruby
luis-novoa/group-buying
/app/models/order.rb
UTF-8
1,111
2.5625
3
[]
no_license
class Order < ApplicationRecord before_validation :check_city, :calculate_total after_save :update_parent_purchase validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 } validates :total, presence: true, numericality: { greater_than: 0 } validates :delivery_city, presence:...
true
6d64bbdb729b2df076a4c75265b557edff0dc5e6
Ruby
shaheenniaz582/week_3_Day_3_Home_work
/db/console.rb
UTF-8
384
2.671875
3
[]
no_license
require('pry') require_relative('../models/artist.rb') require_relative('../models/album.rb') Artist.delete_all() Album.delete_all() artist1 = Artist.new({'name' => 'ABC'}) artist2 = Artist.new({'name' => 'XYZ'}) artist1.save() artist2.save() album1 = Album.new({ 'artist_id'=> artist1.id, 'title' => 'aassdsddf',...
true
dd828596b6eb284f159038fee31a0975c9429ef4
Ruby
Zamliy/IhsanPrepCourse
/exerciseex9.rb
UTF-8
173
3.53125
4
[]
no_license
# exerciseex9.rb h = {a:1, b:2, c:3, d:4} h[:b] h[:e] = 5 # one line version h.delete_if { |k, v| v < 3.5} #multi line version h.delete_if do |k, v| v < 3.5 end
true
18dac5ad06d5eab67d6d3ed6c72624c6227a8fdb
Ruby
mvillegasm/validar_edad
/validar_edad.rb
UTF-8
139
2.90625
3
[]
no_license
def validar_edad edad = rand(99) puts edad if edad >= 18 puts "es mayor" else puts "es menor" end end puts validar_edad
true
ee0f0413c6ce8ce95d29c197c94719d0d23c5164
Ruby
bricearby91/exercices-Ruby
/exo_20.rb
UTF-8
166
3.0625
3
[]
no_license
puts "Salut, combien d'étages veux-tu ?" print "> " nb = gets.chomp.to_i puts "Voici la pyramide : " nb.times do |i| (i+1).times do print "#" end puts "" end
true
b6f62750570342ce6ffd2210525f9dda8acaa861
Ruby
knu/more-dash-docsets
/generators/_gen_puppet.rb
UTF-8
5,927
2.75
3
[ "MIT" ]
permissive
require File.join(File.dirname(__FILE__), 'Dash.rb') dash = Dash.new({ :name => 'Puppet', :display_name => 'Puppet 3.2', :docs_root => 'puppetdocs-latest', :icon => File.join('icon-images', 'puppetlabs.png') }) # so dive can get at it recursively.. $dash = dash # this is ho...
true
4c85cde6ef1fbcd56d9f7e150d8ebc9151405758
Ruby
francois/family_budget
/lib/number_to_words.rb
UTF-8
1,666
3.765625
4
[ "MIT" ]
permissive
module NumberToWords extend self SINGLES = %w(zero one two three four five six seven eight nine) TEENS = %w(ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen) TENS = %w(twenty thirty fourty fifty sixty seventy eighty ninety) HUNDREDS = %w(hundred thousand) def number_...
true
fc11443fed487d6a4a8ef17cc309c99d2a5965c4
Ruby
leesheppard/WDI_SYD_7
/week-01/day-02/calculator.rb
UTF-8
860
3.625
4
[]
no_license
require 'rainbow' # A user should be given a menu of operations # A user should be able to choose from the menu def menu gets.chomp end # A user should be able to enter numbers to perform the operation on # A user should be shown the result def basic_calc print "(a)dd, (s)ubtract, (m)ultiply, (d)ivide: " opera...
true
f7abc7b76e41bc76d7f804fc50c08fc2c5670aa2
Ruby
Dale-R-Harrison/RB101
/small_problems/easy6/halvsies.rb
UTF-8
326
3.984375
4
[]
no_license
def halvsies(array) half = 0 if array.size.odd? half = array.size / 2 + 1 else half = array.size / 2 end first_array = array.slice(0, half) second_array = array.slice(half, array.size - half) [first_array, second_array] end p halvsies([1, 2, 3, 4]) p halvsies([1, 5, 2, 4, 3]) == [[1, 5, 2], [4...
true
5353f5f10a83d29a0710f36cbd230f694e718af3
Ruby
MIKEALGEE/lab_imdb
/console.rb
UTF-8
1,008
2.59375
3
[]
no_license
require_relative( 'models/actor' ) require_relative( 'models/movie') require_relative( 'models/role') require( 'pry' ) Role.delete_all Actor.delete_all Movie.delete_all actor1 = Actor.new({ 'first_name' => 'Robert', 'last_name' => 'Downey' }) actor1.save() actor2 = Actor.new({ 'first_name' => 'Chris',...
true
3e49a24dd2679de5979ec47e38e919f7f42687d6
Ruby
mgidea/echo
/copy5.rb
UTF-8
1,165
3.640625
4
[]
no_license
statements = [] def puts_ordered_statements(statements) statements.each_with_index do |statement, index| if index == 0 puts "You said: #{statement}" elsif index == statements.size - 1 puts "Finally you said: #{statement}" else puts "Then, you said: #{statement}" end end puts "Ph...
true
30bd5e5dbc31a7082745f9497ef2b5b2a4b73eac
Ruby
rohitpaulk/rechargery.com
/spec/models/user_spec.rb
UTF-8
2,010
2.640625
3
[]
no_license
require_relative '../spec_helper' describe User do it "has a valid factory" do FactoryGirl.create(:user).should be_valid end describe "validations" do it "is invalid without a name" do FactoryGirl.build(:user, name: nil).should_not be_valid end it "is invalid without a password" do ...
true
9428595347baf13cd0cb24089fb7ea18e12a6d98
Ruby
amclelland/Ruby-Files
/1_Easy/wordReverse.rb
UTF-8
51
2.828125
3
[]
no_license
puts "My dog has fleas".split.reverse.join(" ")
true
702d1deb17cff4c387ea9fb0500832aed1ef96bb
Ruby
bneuman-dev/project_euler
/spec/p5_spec.rb
UTF-8
310
2.609375
3
[]
no_license
require 'spec_helper' require_relative '../lib/p5' describe "#lowest_divisible_by_all_of_range" do it "works for example case" do expect(lowest_divisible_by_all_of_range(1, 10)).to eq 2520 end it "works for 1-20 case" do expect(lowest_divisible_by_all_of_range(1, 20)).to eq 232792560 end end
true
d99e8c9a18de1356c5e122632d11c1f6d5b72275
Ruby
aikyo02/ruby_exercise
/chapter10/execise1.rb
UTF-8
254
3.59375
4
[]
no_license
def clock(&block) hour_24 = Time.now.hour # 0-23時を1-12時に変換 if hour_24 % 12 == 0 hour = 12 else hour = hour_24 % 12 end hour.times {yield} end count = 0 clock do count += 1 puts "#{count}回目の呼び出し" end
true
cf330488e5ce638b626388060fa5b25a929e829e
Ruby
nitanshu1808/ruby_design_pattern
/pattern_programming/full_pyramid.rb
UTF-8
311
3.59375
4
[]
no_license
#Program to print full pyramid class FullPyramid def self.print_pyramid (0..4).to_a.reverse.each_with_index do |item, index| #loop for printing spaces (1..item).each {print " "} #loop for print * (1..(2*index+1)).each {print "*"} #New Line puts "" end end end FullPyramid.print_pyramid
true
c944949b3d12cf3a1e0fba06736083b5a423cfda
Ruby
aldesantis/handshaker
/spec/handshaker/transaction/shared.rb
UTF-8
6,765
2.609375
3
[ "MIT" ]
permissive
# frozen_string_literal: true RSpec.shared_examples 'transaction basics' do describe 'initialization' do it 'sets steps' do expect(subject.steps).to eq(steps) end end describe '#step_for' do context 'for existing party' do it 'returns correct step' do expect(subject.step_for(sell...
true
690873c90dd5fed61acf90a49690019e827ab506
Ruby
FiddlersCode/kata
/Range_Extraction/lib/range_extraction.rb
UTF-8
162
3.15625
3
[]
no_license
def solution(list) array.each do |n| if array[n] == n + 1 end array[1, 3, 4, 5, 6, 9] returns "1, 3-6, 9" if 3 + 1 == 3 && 3 + 2 == 5 add to array
true
057773f448562fd068b9c8a9d28d4d0d36d1a70d
Ruby
JulJen/endangered-species-cli-app
/lib/endangered_species/cli.rb
UTF-8
5,519
3.6875
4
[ "MIT" ]
permissive
# CLI controller - user interaction class EndangeredSpecies::CLI # Main / general user input def call puts "" puts "Welcome! Learn about World Wildlife Fund's conservation of species and the environment!" sleep 1 puts "" puts "..." puts "" puts "...please wait one moment..." puts ""...
true
684d3ab44daa33af2d67c1e640e601ede2515616
Ruby
jessicaw9494/05-caesar-cipher-lab
/lib/caesar.rb
UTF-8
2,226
3.9375
4
[]
no_license
$array_abc_low = [*?a..?z] #these are arrays $array_abc_up = [*?A..?Z] #$ makes it a global variable/ visible for all methods def caesar_encode(string, offset) string.split("").map do |character| #.map goes through array and creates a new array if $array_abc_low.include?(character) #checks if a letter is in ...
true
9348832384478a1159f40acfc5a4cd6b1eb7e22f
Ruby
mandreko/projecteuler
/problems/problem044.rb
UTF-8
851
3.75
4
[]
no_license
# Euler 44 # http://projecteuler.net/index.php?section=problems&id=44 ## Pentagonal numbers are generated by the formula, Pn=n(3n-1)/2. The first ten pentagonal numbers are: # # 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... # # It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 - 22 = 48, is n...
true
a72c13e06275094f89de7ead1c982d3e6f7a727e
Ruby
sds/overcommit
/lib/overcommit/hook/pre_commit/es_lint.rb
UTF-8
1,301
2.53125
3
[ "MIT", "CC-BY-3.0" ]
permissive
# frozen_string_literal: true module Overcommit::Hook::PreCommit # Runs `eslint` against any modified JavaScript files. # # Protip: if you have an npm script set up to run eslint, you can configure # this hook to run eslint via your npm script by using the `command` option in # your .overcommit.yml file. Thi...
true
f20251882ba227451ce0de413ce49e458618c4eb
Ruby
cleblanc87/asteroids
/game_object.rb
UTF-8
643
2.90625
3
[]
no_license
class GameObject attr_reader :aabb def initialize window @posX = 0 @posY = 0 @rotation = 0 load_assets window @aabb = AABB.new @aabb.update @posX, @posY, @image.width, @image.height end def load_assets window end def update window @aabb.update @posX, @posY, @image.width, @imag...
true
661b12ae13bd575a927a3f1971f1163cd9aad407
Ruby
msjlwhite/RubyPractice
/leetCode_Practice.rb
UTF-8
440
3.484375
3
[]
no_license
# def return_this(arg) # arg # end # puts return_this("return me, please") # def pitter_putter(arg) # puts arg # end # pitter_putter("patter") # def nihilist(arg) # return nil # arg # end # nihilist("Nietzsche").to_s # def cat # "Cat" # end # cat def cat "Cat" end...
true
5c4cc5ad82f44f2cf396959e6138245d9c3132b9
Ruby
elentras/common_scopes
/lib/common_scopes/by_datetime.rb
UTF-8
1,493
2.640625
3
[ "MIT" ]
permissive
module CommonScopes::ByDatetime # module ClassMethods def self.scopes_for_attr(model, key) # NOTE: Find a cleaner way to extend models, I hate to use `eval` methods... arel_key = model.arel_table[key.to_sym] model.instance_eval do # Add a scope :by_[attribute name]_greater t...
true
0d4ebacf7f7afeccf359c1f2e0115ded41590b95
Ruby
andydna/bin.rb
/exe/bin.rb
UTF-8
859
2.796875
3
[]
no_license
#!/usr/bin/env ruby class << ((bin = Struct.new(:rb).new).rb = Object.new) def do_stuff complain_unless_argv open_in_editor if already_a_thing? write_skeleton make_executable open_in_editor end def complain_unless_argv (puts "!ARGV.first"; abort) unless name_of_bin end def open_in_...
true
c26d2b8cb7049af54ba484e62561bcb6b9a5ea4a
Ruby
wakanapo/pikachu
/pikachu_lang.rb
UTF-8
265
2.515625
3
[]
no_license
#!/usr/bin/env ruby # coding: utf-8 require 'r-fxxk' class Pikachu < Brainfuck nxt 'ピカ ' inc 'ピカチュー ' prv 'ピ ' dec 'ピッ ' opn 'ピィ ' cls 'ピカァ ' put 'ピッカ ' get 'ピーカー ' end puts Pikachu.new.fuck(ARGF.read)
true
f3d093b8937f676318af56d856bfff6aaaca9fe7
Ruby
Alacrity01/contacts_app
/db/seeds.rb
UTF-8
1,328
2.640625
3
[]
no_license
# 1000.times do # first_name = Faker::Name.first_name # last_name = Faker::Name.last_name # contact = Contact.new( # first_name: first_name, # middle_name: Faker::Name.middle_name, # last_name: last_name, # email: F...
true
ec118457fbfc76204683869d1a10f4743464b1c7
Ruby
aag1091/html-schema
/lib/html-schema/attribute.rb
UTF-8
1,113
2.671875
3
[ "MIT" ]
permissive
class HTMLSchema class Attribute < HTMLSchema::Object attr_accessor :type, :value, :options, :required def initialize(name, options = {}, &block) @_name = name @value = options @parent = options[:parent] @as = options[:as] || name @classes = Array(as...
true
6625daeea418a66565609d5d37ed5d52a6f3716c
Ruby
jhorber95/ruby_tutorial
/section_11/146_the_sample_method.rb
UTF-8
97
2.75
3
[]
no_license
flavors = %w[chocolate vanilla strawberry] # this method return random values p flavors.sample(2)
true
23819743b0a1e764300e56f77b2d2d002fd34bbe
Ruby
dskim/moneybookers
/lib/moneybookers/request.rb
UTF-8
946
2.671875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "net/http" module Moneybookers module Request class << self def post(path, params={}) http.post(URI.parse(path).path, prepare_params(params), headers) end def get(path, params={}) http.get(path_with_params(path, params), headers) end def http uri =...
true
5f74f8b0915007b00c98489700bcdf847489dbb1
Ruby
gargtushar/battleship
/spec/ship_spec.rb
UTF-8
1,675
2.859375
3
[]
no_license
require 'spec_helper' require 'byebug' describe Ship do let(:ship_type) { ShipType.new("Q", 2)} let(:ship) { Ship.new("Vikrant", ship_type, 1, 2, 'A2') } let(:ship1) { Ship.new("Vikrant", ship_type, 1, 2, 'A2') } let(:battle_field) { BattleField.new(5, 'E', "Monkey D Luffy") } let(:start_row) { 'A' } l...
true
cc66ea82812ce399d7578a65ab38553a5989a2af
Ruby
julianchurchill/vim-ruby-refactor
/spec/rubyrefactorer_spec.rb
UTF-8
4,760
2.96875
3
[]
no_license
require 'rubyrefactorer.rb' module VIM class Buffer def self.current nil end def initialize @lines = [] end def count @lines.size end def append index, content @lines.insert rebase( index ) + 1, content end def []= index, content @lines[rebase ind...
true
595331ece9ef9bc8dd75623f37a482b754c49a5a
Ruby
philnash/ruby-whatsapp-bots
/location/bot.rb
UTF-8
1,216
2.796875
3
[ "MIT" ]
permissive
require "sinatra/base" class LocationBot < Sinatra::Base use Rack::TwilioWebhookAuthentication, ENV['TWILIO_AUTH_TOKEN'], '/bot' post '/bot' do response = Twilio::TwiML::MessagingResponse.new if params["Latitude"] && params["Longitude"] dark_sky = DarkSky.new(ENV['DARK_SKY_API_KEY']) forecast...
true
d7443beac387c76498855addd35919877ee35846
Ruby
Hamumayo55/Rails5_tutorial
/vendor/bundle/ruby/2.6.0/gems/async-io-1.25.0/spec/addrinfo.rb
UTF-8
256
2.765625
3
[ "MIT" ]
permissive
# This is useful for specs, but I hesitate to monkey patch a core class in the library itself. class Addrinfo def == other self.to_s == other.to_s end def != other self.to_s != other.to_s end def <=> other self.to_s <=> other.to_s end end
true
821896c082f7dea43e6f28776db886f340926068
Ruby
TheSpartan1980/site_prism
/lib/site_prism/waiter.rb
UTF-8
656
2.53125
3
[ "BSD-3-Clause" ]
permissive
# frozen_string_literal: true module SitePrism class Waiter def self.wait_until_true(wait_time = Capybara.default_max_wait_time) start_time = Time.now loop do return true if yield break if Time.now - start_time > wait_time sleep(0.05) end raise SitePrism::Timeou...
true
ca27bbef037f4f72869a422c26ae083ecdf48981
Ruby
akshatpradhan/spoutlets
/app/helpers/entries_helper.rb
UTF-8
1,147
2.546875
3
[ "MIT" ]
permissive
module EntriesHelper def width_for(emotional_state) emotional_state.to_i * 20 end def like_status_for(entry, user) return "No one else knows the feeling." if entry.likes == 0 out = [] if entry.likes == 1 if entry.liked?(user) out << "You know" else out << "Another per...
true
c713eb596027ec909ef55eefbeb4c4bd9c10151c
Ruby
alexfjclements/spending_tracker
/models/transactionpresent.rb
UTF-8
280
2.78125
3
[]
no_license
class TransactionPresent attr_reader :id, :name, :amount, :label, :time_stamp def initialize(options) @id = options['id'] @name = options['name'] @amount = '£' + options['amount'] @label = options['label'] @time_stamp = options['time_stamp'] end end
true
09c572bbd812da70def8c10600f107b209cb3150
Ruby
PopularDemand/assignment_rspec_secrets
/spec/secret_spec.rb
UTF-8
1,281
2.515625
3
[]
no_license
require 'rails_helper' describe Secret do context 'valid data provided' do let(:secret) { build(:secret) } it 'passes title validation' do secret.title = 'title' expect(secret).to be_valid end it 'passes body validation' do secret.body = 'body' expect(secret).to be_valid ...
true
43edffa23b412576ff00f44ed63aabf5abe48499
Ruby
Oscar-Santos/backend_mod_1_prework
/section3/exercises/exe32_loops_n_arrays.rb
UTF-8
2,131
4.46875
4
[]
no_license
# Study Drills # 1) Take a look at how you used (0..5) in the last for-loop. Look up Ruby's "range operator" (.. and ...) online to see what it does. the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] elements = [] (0...5).each do |i| # H...
true
7955fe5aff6da562d0d883fe3d250cc8d500cca0
Ruby
amartyushov/Experiments
/ruby/basic_syntax.rb
UTF-8
3,838
3.546875
4
[]
no_license
full = lambda {|first, second| first + " " + second} p full.call("my", "lamda") p '-----------------------------------------------------------' yourProc = Proc.new {|first, second| first + " " + second} p yourProc.call("my", "proc") p '-----------------------------------------------------------' def method p 'met...
true
e5a02c51414fcd203e3c84910e52e64f01dbd469
Ruby
npazarkoskiktmk/Ruby-exercises
/Truthiness/ex9.2.rb
UTF-8
681
3.4375
3
[]
no_license
objects = [true, false, 0, 1, "", [], Object.new, Class.new, Module.new] obj_length=objects.length table= Array.new(obj_length+1) { Array.new(obj_length+1)} max_length=objects.max_by{|obj| obj.to_s.length}.to_s.length p max_length for i in 0..obj_length for j in 0..obj_length if i==0 && j==0 ...
true
50e1e60070f25c16aa045fa2609dbd26b9c96a59
Ruby
minamalaj/ruby-oo-self-cash-register-lab-london-web-030920
/lib/cash_register.rb
UTF-8
821
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class CashRegister attr_accessor :total, :discount, :new_array def initialize(discount = 0) @total = 0 @discount = discount @new_array = [] end def add_item(title, price, quantity = 1) item = { title: title, price: price, quantity: quantity } @new_array << ite...
true
9964db7f4ec0bd1cf10ed1f7b7bed0ca115a3df2
Ruby
robotarmy/dollar_user
/Script/dur
UTF-8
795
3.03125
3
[]
no_license
#!/usr/bin/env ruby puts "Dur!" if ARGV.first.nil? puts 'Dur!!!!!!!! Dur!! Dur needs file path' exit end file = ARGV.first unless File.exist? file puts 'Dur!! Dur Sad. Dur cannot see file :(' exit end file = ARGV.shift puts "Dur! Dur! Dur Happy with file!!" if ARGV.first.nil? puts 'Dur!!!!!!!! Dur!! Dur need...
true
97eefd15788ac89758ad9de13f9c6f3871bf21d5
Ruby
markryall/chicanery
/lib/chicanery/semaphore.rb
UTF-8
1,865
2.703125
3
[ "MIT" ]
permissive
require 'chicanery/site' require 'date' require 'json' module Chicanery module Semaphore def self.new *args Semaphore::Server.new *args end def semaphore *args server Semaphore::Server.new *args end class Server < Chicanery::Site def jobs jobs = {} response = ...
true
9a105508d97c0ee8bdd5ee18c1786154418a7a98
Ruby
udzura/mruby-pocs
/mruby-poc-1/test/mrb_pocpoc.rb
UTF-8
261
2.65625
3
[ "MIT" ]
permissive
## ## PocPoc Test ## assert("PocPoc#hello") do t = PocPoc.new "hello" assert_equal("hello", t.hello) end assert("PocPoc#bye") do t = PocPoc.new "hello" assert_equal("hello bye", t.bye) end assert("PocPoc.hi") do assert_equal("hi!!", PocPoc.hi) end
true
bd821ce8e838fac6e91a220b07722c39e0002212
Ruby
Premti/debugging-practice-using-pry-london-web-030920
/lib/pry_debugging.rb
UTF-8
63
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def plus_two(num) new_num = num + 2 new_num end
true
e6d83dca1a5a26783f15c92d723df1dcb599b927
Ruby
johnglynn/Ironhack
/IH_Week_1/IH_Week1_Day2/lib/car.rb
UTF-8
133
2.734375
3
[]
no_license
class Car def initialize(sound, capacity) @sound = sound @capacity = capacity end def drive puts @sound end end
true
a29dbd459a3f9b5ec407cc2b3ca9b372cb1114d6
Ruby
kaikoma-soft/raspirec
/src/views/rsv_list.rb
UTF-8
2,722
2.59375
3
[ "Apache-2.0" ]
permissive
#!/usr/local/bin/ruby # -*- coding: utf-8 -*- # # 予約一覧 # class ReservationList def initialize( ) @autoRsv = {} # 自動予約のIDリスト end def getData() reserve = DBreserve.new() programs = DBprograms.new filter = DBfilter.new now = Time.now.to_i DBaccess.new().open do |db| ...
true
73a7cb1105413dbb1414035034f6506d137d2e7d
Ruby
men32z/coding-challenges
/replit/33-simple-quick-sort.rb
UTF-8
492
3.8125
4
[]
no_license
def simple_quicksort(array) # write your code here return if array.length < 1 val = array[0] left = [] rigth = [] (array.length - 1).times do |i| if array[i + 1] < val left.push(array[i + 1]) else rigth.push(array[i + 1]) end end fin = ((simple_quicksort(left)||[]) << val).concat (simp...
true
a861d73176e1ebc14cfba0c6ad67e86a9d0ac975
Ruby
nghiemj/ttt-7-valid-move-v-000
/lib/valid_move.rb
UTF-8
316
3.15625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# code your #valid_move? method here def position_taken?(board, index) if board[index] == " " || board[index] == "" || board[index] == nil return false end return true end def valid_move?(board, index) if index.between?(0,8) && !position_taken?(board, index) return true else return false end end
true
cc37c114224b40b2603e83ecc2715219c7fc44d9
Ruby
lcrepet/AdventOfCode2017
/day_eight/end_max_value.rb
UTF-8
787
2.984375
3
[]
no_license
require_relative 'parser' require_relative 'register' instructions_str = ARGV.first.split(";") parser = Parser.new instructions = instructions_str.map { |instruction_str| parser.parse_instruction(instruction_str) } registers = {} instructions.each do |instruction| register = registers[instruction.register_name] ...
true
4acee61cc9285289288127eb8c25bd820ae01665
Ruby
tilmitt11191/mtg
/lib/util/price_manager.rb
UTF-8
758
3.046875
3
[]
no_license
require "logger" require 'date' require '../../lib/util/card.rb' require '../../lib/util/price.rb' class Price_manager @log @card @relevant_price #Class Price @highest_price #Class Price @lowest_price #Class Price attr_accessor :card, :relevant_price, :highest_price, :lowest_price def ini...
true
1263266a4bfa270256f137aa4c23177ce6e612a5
Ruby
thomas-yancey/phase-0
/week-4/variable-methods.rb
UTF-8
1,956
3.84375
4
[ "MIT" ]
permissive
def full_name_greeting puts "What is your first name?" first_name = gets.chomp puts "What is your middle name?" middle_name = gets.chomp puts "What is your last name?" last_name = gets.chomp "Hello #{first_name} #{middle_name} #{last_name}!" end puts full_name_greeting def bigger_better_fa...
true