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
a2e8334abc06743d52c44f1204034cce1ccb3dec
Ruby
messente/messente-api-ruby
/lib/messente_api/models/error_title_omnichannel.rb
UTF-8
1,620
2.609375
3
[ "Apache-2.0" ]
permissive
=begin #Messente API #[Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any...
true
882250ba8229fcb06f8de1d7a00124a3c8d171fc
Ruby
enjoy-self-inquiry/vending_machine_prototype
/vending_machine.rb
UTF-8
2,098
4.0625
4
[]
no_license
class Vendor attr_accessor :sum puts "ๆ–™้‡‘ใ‚’ๅ…ฅใ‚Œใฆใใ ใ•ใ„ใ€‚" puts "ๆณจๆ„๏ผ‘๏ผš10ๅ††็މใ€50ๅ††็މใ€100ๅ††็މใ€500ๅ††็މใ€1,000ๅ††ๆœญใ—ใ‹ๅ—ใ‘ไป˜ใ‘ใพใ›ใ‚“ใ€‚" puts "ๆณจๆ„๏ผ’๏ผšใใ‚Œไปฅๅค–ใฎ็กฌ่ฒจใ‚„ใŠๆœญใ‚’ๅ…ฅใ‚ŒใŸๅ ดๅˆใฏใŠ่ฟ”ใ—ใ—ใพใ™ใ€‚" puts "ๆณจๆ„๏ผ“๏ผš่ค‡ๆ•ฐๅ›žใซๅˆ†ใ‘ใฆๆŠ•ๅ…ฅใงใใพใ™ใ€‚" puts "ๆณจๆ„๏ผ”๏ผšๆŠ•ๅ…ฅใŒ็ต‚ใ‚ใ‚Šใพใ—ใŸใ‚‰ใ€readyใจๅ…ฅๅŠ›ใ—ใฆไธ‹ใ•ใ„ใ€‚" puts "ใใ‚Œใงใฏใ€ใพใšๆŠ•ๅ…ฅๅ›žๆ•ฐใ‚’ๆ•™ใˆใฆใใ ใ•ใ„ใ€‚" def input_reimburse input_nums = gets.to_i puts "ใใ‚Œใงใฏใ€#{in...
true
b61a1678bf12d3f660b76572bbfef0e844e10c69
Ruby
carl1984r/anagram-detector-online-web-sp-000
/lib/anagram.rb
UTF-8
288
3.578125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Your code goes here! require 'pry' class Anagram attr_accessor :data def initialize(data) @data = data end def match(arr) var_2 = [] var = data.split("").sort var_1 = arr.collect {|x| x.split("").sort} var_1.each_with_index {|x, i| var_2 << arr[i] if x == var} var_2 end end
true
95139dc46d8b99ef6dbf71e5ed3c9d74989668cb
Ruby
tommyco/TSP-in-Ruby
/ga.rb
UTF-8
1,906
3.71875
4
[]
no_license
require_relative "./city" require_relative "./tour" require_relative "./population" class GA MutationRate = 0.1 TournamentSize = 5 def self.evolve(population) population.compute_all_distances population.find_best_tour # always enable elitism by saving best tour as the first new tour new_...
true
6e7bdd4b463e8cf75691d9eec729311a879b92cc
Ruby
jimeh/rubocopfmt
/spec/integration/list_incorrectly_formatted_files_spec.rb
UTF-8
1,933
2.578125
3
[ "MIT" ]
permissive
require 'spec_helper' require 'open3' RSpec.describe 'Integration: List incorrectly formatted files' do it 'prints list of incorrectly formatted files when passed -l flag' do input1_file = get_fixture_file(:basic1_input) output1_file = get_fixture_file(:basic1_output) input2_file = get_fixture_file(:basi...
true
1846dc8d5dc40833a29ea1c4ca82dad848d29026
Ruby
KanazawaIoT/seminar
/NTKanazawa/main.rb
UTF-8
1,124
2.71875
3
[]
no_license
# coding: utf-8 NAMESPACE = ENV['MYNAME'] || 'kato' DEVICE_ID = 'BME280' require 'rubygems' gem 'serialport','>=1.0.4' require 'serialport' require 'time' class AWSSender def initialize(device_id = DEVICE_ID) @device_id = device_id end def send_to_aws(metric_name, v, position) time = Time.now.xmlschema...
true
fcfada1648b7edceb120763a592506bdd03c2aea
Ruby
ziyue1118/biller
/app/models/rds_client.rb
UTF-8
3,800
2.78125
3
[]
no_license
class RdsClient def initialize @rds = RdsConnection.new end def close_connection @rds.close_connection end def save(bill) @rds.exec(create_bill_query(bill)) end def get_user_bills(username, start_time=nil, end_time=nil) if start_time.nil? || end_time.nil? || start_time == "" || end_tim...
true
8ea758dce4c9035cbf32f4fdbb204f3a30317874
Ruby
nachiket87/RubyAlgorithms
/06-InflightEntertainment/spec/main_spec.rb
UTF-8
782
3.046875
3
[]
no_license
# frozen_string_literal: true require '../main' require './spec_helper' describe 'In Flight Entertainment' do it 'should accept two arguments' do expect { can_two_movies_fill_flight?([2, 4], 1, 2) }.to raise_error(ArgumentError) end context 'movie_lengths = [2, 4], flight_time = 1 ' do it 'should retur...
true
e0a2dce699e5324f891bb32256fc1d661ce10bf5
Ruby
minutetominute/checkers
/board.rb
UTF-8
2,028
3.484375
3
[]
no_license
require "byebug" require "colorize" require "./checkers_helper" require "./piece.rb" class Board include CheckersHelper def initialize @squares = Array.new(8) { Array.new(8) } end def render square_color = :red row_index = 8 @squares.each_with_object("\n") do |row, board| board << (row_index).to_s ...
true
7be28e191ba74886ce343a55205e8fd01ef43fd8
Ruby
dxw/10000ft-scheduling-dashboard
/spec/helpers/schedules_helper_spec.rb
UTF-8
3,410
2.515625
3
[]
no_license
require 'rails_helper' RSpec.describe SchedulesHelper, type: :helper do describe 'project_classes' do it 'returns the project name' do project = Project.new(name: 'foo bar') result = project_classes(project: project) expect(result).to eq('foo-bar') end context 'when the project is inte...
true
073cdd74becb9cfb05229690ddd1217ae3ce75eb
Ruby
youchan/kanbanchan
/app/models/remote/fusen.rb
UTF-8
342
2.765625
3
[]
no_license
module Kanban class Fusen attr_reader :x, :y, :title, :id def initialize(manager, fusen) @manager = manager @id = fusen.id @x = fusen.x @y = fusen.y @title = fusen.title end def move(x, y) @x = x @y = y @manager.move(id, x, y) @manager.updated(se...
true
035e7278408701a49236050ae8a2e3090e1dc4cb
Ruby
James-P-D/RubyDump
/src/return_struct.rb
UTF-8
199
3.296875
3
[ "MIT" ]
permissive
require "ostruct" def get_open_struct() person = OpenStruct.new person.name = "james" person.age = 38 return person end def main() os = get_open_struct() puts(os.name) end main()
true
7ca06ef8b379f46cabbbbf5eb077564e2dbd858a
Ruby
GrumpyKitten-420/loadshedding-api
/lib/schedule.rb
UTF-8
179
3.203125
3
[]
no_license
class Schedule attr_reader :periods def initialize(periods) @periods = periods end def is_it_me_now?(zone) periods.any? { |p| p.is_this_me_now?(zone) } end end
true
164164e5f63cb7a54ca33d443d0e2c555b23e183
Ruby
drumnation/oxford-comma-web-0217
/lib/oxford_comma.rb
UTF-8
386
3.59375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def oxford_comma(array) # if the array only has 2 items just put an " and " between them if array.count < 3 string = array.join(" and ") else # if array has 3 or more insert "and " before the last item array.last.insert(0, "and ") # join all the elements together with a comma and a space strin...
true
fcf45d7d8c6b1c3923fd19fe0b404ca361c37967
Ruby
yusuketsuiki/euler
/14.rb
UTF-8
310
3.234375
3
[]
no_license
def getc(num) j = 0; while num != 1 if num % 2 == 0 num = num / 2 else num = num * 3 + 1 end j += 1 end return j end clist = {} for i in 1..1000000 p i clist[i] = getc(i) end clist.sort_by{|key, value| value}.each do|key, value| p "key:" + key.to_s() + " value:" + value.to_s() end
true
ecd83ee27821a9b109ec704585d9f804fe9eb8bc
Ruby
felixroeser/42195
/lib/42195/realm.rb
UTF-8
610
2.546875
3
[]
no_license
module MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMCXCV class Realm attr_accessor :name, :enabled, :users, :config def initialize(name, data, config=nil) @name = name @data = data @enabled = @data['enabled'] || false @users = @data['users'] || {} @config = config ...
true
c5a651cd001d341494bb509cad0ac288ea2ac3fa
Ruby
ga-wolf/wdi-16
/09-tdd/bank/spec/bank_spec.rb
UTF-8
1,407
3.3125
3
[]
no_license
require 'pry' require_relative "../bank" describe Bank do let(:bank) do Bank.new("RSpec Bank") end describe ".new" do it "should create a new instance of the Bank class" do expect( bank ).to_not eq nil end it "should be assigned a name as an instance variable" do expect( bank.name )...
true
aa80a35765d6db88ba6a0364da349a8c4f6544cf
Ruby
CargoSense/motion-sensoro
/lib/sensoro_beacon.rb
UTF-8
504
2.59375
3
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
class SensoroBeacon Properties = [:uuid, :major, :minor, :serial_number, :battery_level, :firmware_version, :temperature, :light, :accelerometer_count, :accuracy, :rssi, :model_name] Properties.each { |x| attr_accessor x } def <=>(obj) obj.is_a?(SensoroBeacon) ? serial_number <=> obj.serial_number : 1 end ...
true
ec795a6a68a69b2b168a471347117d80c523f375
Ruby
tiy-indy-bee-ror-feb16/course_notes
/week2/Tuesday/w2d1/coffee.rb
UTF-8
118
2.6875
3
[]
no_license
require_relative 'drinkable' class Coffee include Drinkable def initialize(name) super(name, 3) end end
true
76600da9b89a856b31211d1c027204079f5ef634
Ruby
deepakvig/instant-messaging
/app/models/message.rb
UTF-8
353
2.671875
3
[]
no_license
class Message < ApplicationRecord validates :body, presence: true def self.convert msg, dialect puts dialect data = case dialect when 'yoda' ConvertMessage.to_yoda msg when 'valley_girl' ConvertMessage.to_valley_girl msg when 'binary_code' ConvertMessage.to_binary_code msg ...
true
42f3c630f7d65f385ee4a47c8e377c31b7803157
Ruby
MarineGarden/zip-wish
/Happy Zip in Ruby 0.1.0/bud/bud_on.rb
UTF-8
415
3.15625
3
[]
no_license
require_relative "../stem/stem_on" require_relative "../bud/bud_off" class BudOn def self.proof(data) mask_off = StemOn.proof(data) possibility = "" for i in 1..mask_off.length - 1 possibility = mask_off.slice(mask_off.length - i, i) if(possibility) end end end...
true
f86cbeb6b39d4a9b6d369c4d00b9d6149ebe0aeb
Ruby
folkengine/evercraft_ruby
/lib/evercraft/elements/attribute_score.rb
UTF-8
810
2.953125
3
[]
no_license
module Evercraft class AttributeScore include Comparable attr_reader :value DEFAULT_VALUE = 10 MAX_MODIFIER = 10 MODIFIERS = [-5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9].freeze def initialize(value = DEFAULT_VALUE) intvalue = value....
true
a8617e7c43d6b6eb5672f62c4f87f0e9c6bb73e0
Ruby
cielavenir/paiza_solutions
/poh17/c2.rb
UTF-8
134
2.921875
3
[]
no_license
#!/usr/bin/ruby s=gets.chomp.chars.map(&:to_i) gets.to_i.times{ x,y=gets.split.map{|e|e.to_i-1} (x..y).each{|i|s[i]^=1} } puts s*''
true
50aaa1ac5c429a24e76f304cd53cb7c612fd4bf0
Ruby
attack/weather_object
/lib/weather_object/data/moon_phase.rb
UTF-8
678
2.734375
3
[ "MIT" ]
permissive
module WeatherObject module Data class MoonPhase < Percentage def to_s "#{percentage} (#{description})" end private def percentage sprintf "%.0f\%", (to_f * 100) end def description case to_f when 0 'new moon' when 0.0...0.25...
true
1e39fe2e7502deb076aa466dffd1db430e2b30e2
Ruby
blolol/wheaties-brain
/bin/wheaties-brain
UTF-8
1,813
2.828125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'bundler/setup' require 'brane' require 'cinch' require 'json' if ARGV.empty? warn 'usage: wheaties-brane path/to/config.json' exit 1 end module Wheaties class << self attr_accessor :brane, :config, :reply_pattern def command?(message) message.message.start_with? '.' ...
true
44cfab0cee9b5f0d4a72353b65cb5f899c245605
Ruby
HTTPArchive/hosts
/process.rb
UTF-8
2,992
2.640625
3
[ "MIT" ]
permissive
require 'yajl' require 'zlib' require 'open3' require 'nokogiri' require 'optparse' require 'domainatrix' ROOT_PATH = '/' WWW = 'www' matched = 0 res, options = {}, {} ARGV << "-h" if ARGV.empty? OptionParser.new do |opts| opts.banner = "Usage: process.rb [options]" opts.on('-a', '--alexa=file', 'Alexa input dat...
true
d89e5b4bf5a73dc09a1622a22c86cdd5f7ee573f
Ruby
sacckey/atcoder
/diverta2019/b.rb
UTF-8
163
2.9375
3
[]
no_license
r,g,b,n = gets.split.map(&:to_i) ans=0 0.upto(n) do |i| 0.upto(n) do |j| if n-r*i-g*j>=0 && (n-r*i-g*j)%b==0 ans = ans + 1 end end end puts ans
true
73c6c28703c9291f47f0f1778da65638af12e959
Ruby
jasnow/job-hunter
/matcher.rb
UTF-8
1,060
2.9375
3
[]
no_license
def matching_algorithm(parsed_requirements) detractors = ["advanced", "expert", "senior", "years"] my_skills = { "Ruby" => 0.87, # based on 13/15 here: https://gist.github.com/ryansobol/5252653 "Rails" => 0.65, "Git" => 0.69, # based on knowing 22/32 commands here: https://git-scm.com/docs "Javascri...
true
120b1d60cdb4d493024c270be65ce08024736d81
Ruby
jpaley95/Old-Api
/app/models/listing.rb
UTF-8
2,488
2.578125
3
[]
no_license
class Listing < ActiveRecord::Base ## Database Fields # t.integer "handle_id", null: false # t.integer "user_id", null: false # t.string "title", null: false # t.text "description" # t.integer "location_id" # t.integer "positions" # t.integer "category" # t.integer "hours" ...
true
b6e9c65d8eaddf9300250aca47d718d254efe9f5
Ruby
adigitalnative/actor_manager_backend
/app/models/state.rb
UTF-8
695
2.65625
3
[]
no_license
class State < ApplicationRecord has_many :search_states has_many :users, through: :search_states has_many :opportunities validates :name, presence: true, uniqueness: true # validates :search, presence: true, inclusion: [in: [true, false]] def self.to_scrape states = State.where(search: true) clea...
true
86dae67709a72e481b76ba7b05e2212ab48a79ae
Ruby
mojotron/algorithms-and-data-structures
/sorting_algorithms/insertion_sort.rb
UTF-8
606
4.125
4
[]
no_license
def insertion_sort(array) i = 1 # we start with assumption that first element is sorted, so we comparing with second until i == array.size # we check every element in array j = i # counter for inner loop, set to i we comparing elements from right to left in inner loop while j > 0 && array[j] < array[j - 1] ...
true
b873df4bb6260bc63cdedf58f80d0e320fab1a9a
Ruby
sunayna-ray/hw-acceptance-unit-test-cycle
/rottenpotatoes/spec/controllers/movies_controller_spec.rb
UTF-8
4,702
2.53125
3
[]
no_license
require 'rails_helper' describe MoviesController do describe 'Search movies by the same director' do let!(:movie_1) { FactoryBot.create(:movie, title: 'Star Wars', director: 'George Lucas') } let!(:movie_2) { FactoryBot.create(:movie, title: 'Blade Runner', director: 'Ridley Scott') } let!(:movi...
true
382220c25b871cbe40431feda569d7ced64849e9
Ruby
dburt/greek_sentence_generator
/sentence.rb
UTF-8
8,026
3.0625
3
[]
no_license
#!/usr/bin/ruby # -*- encoding: UTF-8 -*- # # Koine Greek simple sentence generator # # Corresponding to vocab and grammar from Duff's Elements of NT Greek 3rd ed. # chapters 3-5 # # Author: Dave Burt # Created: 7 Jan 2012 # $KCODE = 'UTF-8' $debug = false class Array; def random; self[rand size] end end # read a ca...
true
44eb6387acbb3634622ef8dc4a573219bbd9565c
Ruby
wasamasa/aoc
/2015/23.rb
UTF-8
3,700
3.90625
4
[ "Unlicense" ]
permissive
require_relative 'util' # --- Day 23: Opening the Turing Lock --- # Little Jane Marie just got her very first computer for Christmas # from some unknown benefactor. It comes with instructions and an # example program, but the computer itself seems to be # malfunctioning. She's curious what the program does, and would...
true
e527d769cb4fe83d034f9a1ccf5c551b32f0944c
Ruby
Kyvyas/rps-challenge
/lib/game.rb
UTF-8
530
3.3125
3
[]
no_license
require_relative './player' class Game attr_reader :player1, :player2 def initialize(player1, player2) @player1 = player1 @player2 = player2 end def result return "You have tied" if player1.choice == player2.choice case player1.choice when :rock player2.choice == :paper ? "Compu...
true
675afcf35bb3bdefd40bae06f81ffaffdf5b4bd2
Ruby
bernassolalisa86/rspec-fixture
/examples/detect_location_spec.rb
UTF-8
1,999
2.875
3
[ "Ruby" ]
permissive
require 'spec' require File.expand_path(File.join(File.dirname(__FILE__), '../lib/spec/fixture')) class Point def initialize x, y @x, @y = x, y end def detect_location return 'unknown' end def to_s "( #@x, #@y )" end end describe Point, "detect_location" do with_fixtures [:x, :y] => :locat...
true
a666f6aa6a7da4f3507623cb4f208b8733d887a2
Ruby
mtcameron5/launchschool_ruby_basics_exercises
/Strings/exercise_2.rb
UTF-8
122
3.234375
3
[]
no_license
# exercise_2.rb puts "It's now 12 o'clock." # Alternative String literal for double quotes (%Q) puts %Q(How are \"you\")
true
efc4ad9ef239e0c32ce3c005f30ca1ea4b9d791d
Ruby
stevepm/text-centering
/lib/center_file.rb
UTF-8
584
2.984375
3
[ "MIT" ]
permissive
require 'text_center' class CenterFile def initialize @directory = File.absolute_path("../../output/", __FILE__) @files = Dir.entries(File.absolute_path("../../data", __FILE__)).map do |file| file if file.end_with?('.txt') end.compact end def center_files Dir.mkdir(@directory) @files.e...
true
31340cb69110fc8367384fc582928d4caea11b7d
Ruby
Macpeters/himama
/app/models/clock_event.rb
UTF-8
349
2.53125
3
[]
no_license
class ClockEvent < ApplicationRecord belongs_to :user validates :clock_in_id, presence: true, unless: :clock_in scope :by_user, ->(user) { where(user: user) } def self.most_recent_event_for(current_user) ClockEvent.by_user(current_user).last end def in_or_out return 'In' if clock_in == tru...
true
652b0bf289d3654c7c56c8885f19eb6a6a87410f
Ruby
dfdemar/RubyWeaver
/RubyWeaver/Spider.rb
UTF-8
990
3.21875
3
[]
no_license
require_relative "NetworkConnection" require_relative "SpiderController" class Spider def initialize() @controller = SpiderController.new() @url_queue = [] @urls_seen = [] end def go(url) @urls_seen.push(url) process(url) end private def process(url) source = fetch_new_page(u...
true
db103a7223a61459f4c1104bf5c1f2293b4db9a9
Ruby
dreeke92/Atolo
/app/models/product.rb
UTF-8
1,768
2.65625
3
[]
no_license
class Product < ApplicationRecord mount_uploader :photo, PhotoUploader validates :name_en, presence: true, uniqueness: true validates :group, presence: true # validates :description_en, presence: true # validates :image, presence: true, uniqueness: true has_rich_text :rich_description_en has_rich_text :r...
true
42663359d272f7529e77f61dd348670b2e1956cf
Ruby
jacindaz/sorting_algo_practice
/sorting.rb
UTF-8
3,922
4.09375
4
[]
no_license
require 'pry' test_array = [6, 3, 20, 12, 10, 2, 100, 99, -45, -20, 30] def merge_sort(array) # Divide the unsorted array of size n, into n arrays of size 1 # Note that each array of size 1 is considered sorted # Combine two sorted small arrays into one sorted combined array with the following steps # Create a...
true
fd871ff7bc569e6bb2cd114b35acb90b2be56835
Ruby
kage1029/atcoder
/atcoderM-SOLUTIONS.rb
UTF-8
127
2.875
3
[]
no_license
n = gets.chomp.to_i ary = gets.split(" ").map(&:to_i) max = ary.max # min = ary.min if max = ary[0] puts 1000 exit end
true
d0d7695f84885790f2ad56566c0d9dbe02ed6e7e
Ruby
feidianbo/origin-server
/controller/app/rest_models/link.rb
UTF-8
822
2.703125
3
[ "Apache-2.0" ]
permissive
# Represents a link in the REST reply # @!attribute [r] rel # @return [String] Description of the operation # @!attribute [r] method # @return [String] HTTP method to use for this operation # @!attribute [r] href # @return [String] URI for this operation # @!attribute [r] required_params # @return [Array[Param]...
true
9217b94d5141b99f45cf02349726968b1db29cfd
Ruby
ganesh-sadanala/ruby_Excercises
/L4-ActiveRecord/todo.rb
UTF-8
1,325
2.984375
3
[]
no_license
require "active_record" class Todo < ActiveRecord::Base def due_today? due_date == Date.today end def self.overdue where("due_date<?", Date.today) end def self.due_today where("due_date=?", Date.today) end def self.due_later where("due_date>?", Date.today) end def to_displayable_s...
true
56c3909d7e4864eb9e50d80c5c5351ec06142114
Ruby
YulyKo/ruby-tasks
/task56.rb
UTF-8
212
3.21875
3
[]
no_license
a = 59 # height b = 56 # wight c = 7 # length x = 56 y = 56 def check_sides(a, b, x, y) if a <= x and b <= y puts 'it will cut out' else puts 'it will not cut out' end end check_sides(a, b, x, y)
true
ab9323feea35bd9b403273719fc76db74152ca1d
Ruby
linyows/stalkerr
/lib/stalkerr/extensions/string.rb
UTF-8
715
2.5625
3
[ "MIT" ]
permissive
require 'string-irc' module Stalkerr::Extensions module String def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name, false) ? constant.const_get(name) : c...
true
3f06a41c51bdd6dff441c10f6e86d36872feb974
Ruby
otmosina/game_of_life
/universe/size_upper.rb
UTF-8
724
3.15625
3
[]
no_license
module Universe class SizeUpper def self.call array array = array.dup zeros_row = array.first.size.times.inject([]) do |res, _| res << 0 end array.unshift zeros_row array.push zeros_row array.map! do |row| [0] + row + [0] end array e...
true
344e6c8314dec65a06b80221fda10bb34827774b
Ruby
jcstone3/revenuearchitects
/app/models/feedback.rb
UTF-8
630
2.515625
3
[]
no_license
class Feedback < ActiveRecord::Base attr_accessor :page validates_presence_of :subject, :message => "Please select subject" validates_presence_of :email, :message => "Email cannot be blank" validates_presence_of :comment, :message => "Comment cannot be blank" validates_format_of :email,:with => /^([^@\s]...
true
d18df23c2ab19a0ad9154364bda910e766ac85dc
Ruby
Studiosity/grover
/spec/grover/utils_spec.rb
UTF-8
8,602
2.8125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'spec_helper' describe Grover::Utils do describe '.squish' do subject(:squish) { described_class.squish string } context 'with an empty string' do let(:string) { '' } it { is_expected.to eq '' } end context 'with leading spaces' do let(:stri...
true
f60dcb51d3ea452587c586e2a0247f41ef8f8e88
Ruby
saberdhaouadi/RubyDev
/module1.rb
UTF-8
158
2.796875
3
[]
no_license
#!/usr/bin/env ruby module Analyze def self.break_words(stuff) # This function will break words words = stuff.split(' ') words end end
true
a2e8a4c7c88aecb3709fbf31358b549acefae3c8
Ruby
ordinaryzelig/fandango
/lib/fandango/theater.rb
UTF-8
1,523
3.015625
3
[]
no_license
module Fandango module Theater module_function def parse(item_node) hash = {} description_node = parse_description_node(item_node) hash[:name] = parse_name(item_node) hash[:id] = parse_id(item_node) hash[:address] = parse_address(description_node)...
true
c2886ce0e87863457ca88dfe23503def6737c320
Ruby
ambientcoder/tweetdb
/bot.rb
UTF-8
5,402
2.625
3
[]
no_license
# encoding: UTF-8 require 'rubygems' require 'twitter' require 'punkt-segmenter' require 'twitter_init' require 'variables' require 'markov' require 'htmlentities' require 'uri' require 'mongo' include Mongo class Tweet def self.create!(tweets) collection.insert(tweets) end def self.fetch # get all rows {...
true
07f5233028a2a385c9de23cd6d19d447dbf4ae2d
Ruby
bdevel/event-correlation-mock-generator
/lib/timed_event.rb
UTF-8
386
2.734375
3
[]
no_license
require_relative 'event' # This is for events that are triggered at a certain time # and date. class CorrelatedEvents::TimedEvent < CorrelatedEvents::Event include Comparable attr_accessor :trigger_time def initialize(feed, trigger_time) super(feed) @trigger_time = trigger_time end def <=>(...
true
2c55837423b284fabc53a385acb2a1efc0a830e5
Ruby
urayoshie/refactoring_sixth_sense
/player.rb
UTF-8
1,548
3.421875
3
[]
no_license
require "pry" require "csv" require "./character" require "./waylist.rb" require "./message" class Player include Message attr_reader :chosen_character def initialize(character_params) @characters = [] character_params.each do |param| @characters << Character.new(param) end end def show...
true
d0b4243bb195a29ea87513a3bf5aedde232d0cd5
Ruby
camwiese/RB101
/medium-2/exercise-7.rb
UTF-8
726
4.28125
4
[]
no_license
# wrtie a method that returns the number of friday the 13ths in a given year # input: integer (year) # output: integer (number of friday the 13ths) # question: how many friday the 13ths appear in a year? # assume: greater than 1752 # Details: # Any month starting with sunday will have a friday the 13th # At most th...
true
15d54980897bcc6dc1588d3233802587933eef9e
Ruby
chylirk/Ruby-Small-Problems
/Easy_8/madlibs.rb
UTF-8
635
4
4
[]
no_license
# i: user input for noun/verb/adverb/adjective # o: string interpolation into sentence # e: # Enter a noun: dog # Enter a verb: walk # Enter an adjective: blue # Enter an adverb: quickly # # Do you walk your blue dog quickly? That's hilarious! def prompt(string) puts "Enter a #{string}: " end syntax = %w(noun ver...
true
323ad6cb645ae40eb1b1c9e5c92327d2e1657e63
Ruby
folubode/mytweeetscope
/app/models/keyword.rb
UTF-8
1,510
2.75
3
[]
no_license
class Keyword < ApplicationRecord has_many :tweets, -> { order("tweet_created_at DESC") }, dependent: :destroy validates :word, uniqueness: true, on: :create def grab_twitts # grabing tweets for each keyword client = Twitter::REST::Client.new do |config| config.consumer_key = ENV["TWITTER_CONSUMER_K...
true
3815c9623c11a11e8212dadb24b5b4b27f30f2e7
Ruby
takaokouji/ver
/lib/ver/theme.rb
UTF-8
502
2.6875
3
[]
no_license
module VER class Theme < Struct.new(:colors) def initialize(colors = {}, &block) self.colors = colors instance_eval(&block) if block_given? end def on(match, color) colors[match] = Color[color] end alias []= on def [](name) colors.each do |match, color| case m...
true
00cfdaa633913361d1a06518547b70dc957655e7
Ruby
shezdev/codewars
/convert_string_to_array_8kyu.rb
UTF-8
246
4.03125
4
[]
no_license
# https://www.codewars.com/kata/convert-a-string-to-an-array/train/ruby def string_to_array(string) #your code here string.split # test with: puts "This is #{string.split}" end #My Test string_to_array("Robin Singh") #Should be ["Robin", "Singh"]
true
c7f73e51e561ec339f3c2fac06eb5b557af745f3
Ruby
trose618/reverse-each-word-dumbo-web-102918
/reverse_each_word.rb
UTF-8
175
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def reverse_each_word(sentence) a_sentence = sentence.split(" ") a_sentence = a_sentence.collect do |word| word.reverse end a_sentence.join(" ") end
true
08fd1558e1de0dc38a166c03a0b9fe9b670a3a10
Ruby
MikelSage/date_night
/test/tree_test.rb
UTF-8
6,829
3.3125
3
[]
no_license
require "minitest/autorun" require "minitest/pride" require "./lib/tree" require "pry" class TreeTest < Minitest::Test def test_default_root_node_is_nil tree = Tree.new assert_nil tree.root end def test_can_insert_node tree = Tree.new depth = tree.insert(50, 'Title') assert_instance_of No...
true
cafb2da6162ac89f7db0ff4799b06d50d72f234a
Ruby
glennmartinez/pulse
/app/models/csv_adapter/metrics_view.rb
UTF-8
1,456
2.96875
3
[]
no_license
require 'csv' module CSVAdapter class MetricsView def initialize(metric, project_metrics_data, week_range, projects_list) @metric = metric @metrics_data = project_metrics_data @week_range = week_range @all_projects = projects_list end def to_csv csv_stream do |csv| ...
true
a06973ad8c1f7ada628b95aa02067878576dd50f
Ruby
aeden/rsaml
/lib/xml_sig/signed_info.rb
UTF-8
887
2.515625
3
[]
no_license
module XmlSig #:nodoc: class SignedInfo attr_accessor :id attr_accessor :canonicalization_method attr_accessor :signature_method def references @references ||= [] end def validate raise ValidationError, "Canonicalization method is required" if canonicalization_method.nil? r...
true
0f3d06d156460458722db1598cdc0a7c7206aa76
Ruby
pikender/my_ruby_projects
/gol/spec/cell_spec.rb
UTF-8
2,882
2.96875
3
[]
no_license
require 'spec_helper' describe Cell do let(:cell_instance) {Cell.new(0,0)} let(:cell_instance_1) {Cell.new(0,0)} let(:neighbour_cell_instance) {Cell.new(1,1)} it "should properly initialize row, columns, cell state and neighbours row - columns" do cell_instance.should respond_to(:row) cell_instance.sh...
true
e3f7991866d3e0e30428e7b765be3cafb914078c
Ruby
UltimateCoder00/Codility-Challenges
/lib/Lesson 9 Maximum Slice Problem/MaxProfit/max_profit.rb
UTF-8
232
3.390625
3
[ "MIT" ]
permissive
def max_profit(a) return 0 unless a.any? max_profit = 0 lowest_price = a.first a.each do |price| lowest_price = [lowest_price, price].min max_profit = [max_profit, price - lowest_price].max end max_profit end
true
d542f17d4181c5d860759e6cce82ab47eed86fa5
Ruby
mowat27/blogger
/db/seeds.rb
UTF-8
653
2.5625
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 rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
4283e6d8ba1021d2ae94fe405df5a808d29b7dce
Ruby
microsoftgraph/msgraph-sdk-ruby
/lib/models/cross_tenant_access_policy_target.rb
UTF-8
5,698
2.671875
3
[ "MIT" ]
permissive
require 'microsoft_kiota_abstractions' require_relative '../microsoft_graph' require_relative './models' module MicrosoftGraph module Models class CrossTenantAccessPolicyTarget include MicrosoftKiotaAbstractions::AdditionalDataHolder, MicrosoftKiotaAbstractions::Parsable ## ...
true
475ef289335a5aaeb44044bc07b359a1d0902a2b
Ruby
akihitofujiwara/test
/lib/bubun.rb
UTF-8
410
2.671875
3
[]
no_license
require "bubun/version" module Bubun def partially_include m, *xs __define_methods :define_method, m, *xs end def partially_extend m, *xs __define_methods :define_singleton_method, m, *xs end def __define_methods type, m, *xs (xs[0].instance_of?(Hash) ? xs[0] : xs.flatten).map {|x, y| sen...
true
2e6fa7719732db33973892742363d1475e04cf77
Ruby
larrylawl/to-do-or-not-to-do
/app/helpers/application_helper.rb
UTF-8
220
2.734375
3
[]
no_license
module ApplicationHelper # Returns "checked" if object's completed attribute equals 1, # and "unchecked" otherwise. def get_status(object) if object.completed == 1 "checked" else "unchecked" end end end
true
8548f5e1bbf05ec65f33d02c4ff128c25d0179c9
Ruby
sykg1204yuki/Paiza
/practice/Pra02.rb
UTF-8
46
2.90625
3
[]
no_license
n = gets.to_i angle = (180*(n-2))/n puts angle
true
ddebb7ea41a472cffb5bbb19dd6f2a198aa3f510
Ruby
alexieze/thinknetica
/Lesson5/rail_station_company.rb
UTF-8
8,194
3.515625
4
[]
no_license
class RailStationCompany attr_reader :name, :stations, :trains, :routes def initialize(name) @name = name @stations = [] @trains = [] @routes = [] end def run() show_commands run_process end private def show_commands puts ' ะšะพะผะฐะฝะดั‹ ัƒะฟั€ะฐะฒะปะตะฝะธั ัั‚ะฐะฝั†ะธัะผะธ" ...
true
d3a7c84ddb1a6f3342a2ce912bb1b123a8e629f1
Ruby
JPeikert/cron_parser
/lib/time_expression_evaluator.rb
UTF-8
3,078
3.21875
3
[]
no_license
require "set" class TimeExpressionEvaluator ALLOWED_TIME_VALUES = { minute: 0..59, hour: 0..23, day_of_month: 1..31, month: 1..12, day_of_week: 0..6, } def initialize(time_expressions) validate_time_expressions(time_expressions) @time_expressions = time_expressions end def calcu...
true
97737acd26a4e2668f15884ea281b9b9e30c9271
Ruby
katheroine/languagium
/ruby/classes/constructors/constructor.rb
UTF-8
301
3.765625
4
[]
no_license
#!/usr/bin/ruby2.7 class Item def initialize puts "Constructor is running..." end # There is no destructor in Ruby. def action puts "Some action is performing..." end end puts "The object will be created now." thing = Item.new() thing.action() puts "The program will end now."
true
dd6e07374ff39216b6d39b8fb36e66394b4311a5
Ruby
michal-kosyk/calamari
/lib/calamari/timesheet_entries/entry.rb
UTF-8
1,065
2.828125
3
[ "MIT" ]
permissive
require_relative 'break_entry' require_relative '../shared/person' require_relative 'project_entry' module Calamari module TimesheetEntries class Entry attr_reader :id, :started, :finished, :started_time_zone, :finished_time_zone, :duration, :person, :breaks, :projects def initiali...
true
34fdc405f38b25ab8f06038923150480a1c938da
Ruby
basilpaul/chef-repo
/cookbooks/ruby/meth.rb
UTF-8
96
3.109375
3
[]
no_license
def hello_user puts "Enter your name" username = gets "Hello #{username}" end hello_user
true
a061dc57fd3dbe1e7ee669b8e3b76284f671c902
Ruby
markpackham/codeclan_wk02_d1
/specs/team_spec.rb
UTF-8
1,211
2.875
3
[]
no_license
require("minitest/autorun") require("minitest/reporters") Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new require_relative("../team") class TestTeam < MiniTest::Test def setup() @team = Team.new("Newts",['bob','gary'],'steve', 0) end def test_get_team_name assert_equal("Newt...
true
e5c1d546a528d345cab40af0943622e60496efd4
Ruby
njohnson7/coding-exercises-and-problems
/ruby/advanced/beer_song.rb
UTF-8
2,004
3.8125
4
[]
no_license
class BeerSong VERSES = { 0 => "No more bottles of beer on the wall, no more bottles of beer.\n" \ "Go to the store and buy some more, 99 bottles of beer on the wall.\n", 1 => "1 bottle of beer on the wall, 1 bottle of beer.\n" \ "Take it down and pass it around, no more bottles of beer on t...
true
28f4344b839297f33328a482f3b201a372ce6e84
Ruby
wdcunha/Nov-2017-Cohort
/ruby/day6/assignments/prime.rb
UTF-8
204
3.875
4
[]
no_license
print 'Enter a number: ' num = gets.to_i def isPrime(x) for i in 2..(x-1) if x%i == 0 return false end end return true end print "Your number #{num} is #{isPrime(num)} for prime \n"
true
3af2ff96608e5c1c11c2529e8b0fc6248b8f8517
Ruby
GoConflux/conflux-cli
/lib/conflux/command/global.rb
UTF-8
5,549
2.671875
3
[ "MIT" ]
permissive
require 'conflux/command/abstract_command' require_relative '../auth' require_relative '../langs' require_relative '../pull' require_relative '../api/bundles' require_relative '../api/users' require 'fileutils' require 'json' class Conflux::Command::Global < Conflux::Command::AbstractCommand def login Conflux::...
true
6d968c805e90556ad13991ffe7f98afee47ee3c0
Ruby
JoshCheek/project-euler
/066/066.5.rb
UTF-8
1,088
3.4375
3
[]
no_license
# https://projecteuler.net/problem=66 require 'bigdecimal' # Convergents of the continued fraction expansion of n def convergents(n) Enumerator.new do |y| first = n.floor n = 1 / (n-first) rest = [] loop do a = n.floor n = 1 / (n-a) rest.unshift a y << first + rest.reduce...
true
2a38af5a77907e6e6a0e1ea45656f231fd688124
Ruby
hansonw/consilium
/app/helpers/table_helper.rb
UTF-8
994
2.625
3
[]
no_license
module TableHelper def getPrimaryFieldsFromModel(model) primaryFields = [] # Recurse down the model until we find a section that has primary fields. begin isArray = model.is_a?(Array) && !model[0][:type].nil? && model[0][:type].is_a?(Array) isClass = model.is_a?(Class) model = model[0]...
true
2d391196103cddb47a854a4d947aae2f2f6a84b3
Ruby
jsuabur/libro-de-actividades
/actividades/prog/files/ruby/mil-ejemplos/code/rubygems-0.8.11/lib/rubygems/doc_manager.rb
UTF-8
3,074
2.53125
3
[ "CC0-1.0", "CC-BY-SA-3.0" ]
permissive
#--- # Excerpted from "Everyday Scripting in Ruby" # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/bmsft for more book information. #--- module Gem class DocumentError < Gem::Exception; end class DocManager include UserInteraction #...
true
90cd5468c458e464873db1be0db01539d4f4143b
Ruby
FernandoBasso/programming-how-to
/ruby/other/assignment/014a-getter-attr-accessor.rb
UTF-8
388
4.0625
4
[]
no_license
class Jedi attr_writer :skill attr_reader :skill attr_accessor :birthday def meth=(name) @name = name end def name @name end end jedi = Jedi.new # Using the โ€œsettersโ€. jedi.meth = 'Yoda' jedi.skill = 'The Force' jedi.birthday = 25 # Using the โ€œgettersโ€™. p jedi.name p jedi.skill p jedi.bir...
true
f053f14416a0672893ce340c0d338744d6aec396
Ruby
jamestunnell/musicality
/lib/musicality/composition/util/note_generation.rb
UTF-8
694
3.171875
3
[ "MIT" ]
permissive
module Musicality def make_note dur, pitch_group if dur > 0 Musicality::Note.new(dur,pitch_group) else Musicality::Note.new(-dur) end end module_function :make_note # Whichever is longer, rhythm or pitch_groups, is iterated over once while # the smaller will cycle as necessary. def make_notes rhythm, pi...
true
d6a51c80aeb63124bd22b6882e87dd4ecdb8d657
Ruby
Nguma/old_nuniverse
/lib/filter.rb
UTF-8
450
2.90625
3
[]
no_license
class Filter attr_reader :path, :service def initialize(service, path = nil) @path = path @service = service end def add(label,value = nil) Filter::Item.new(label,value, @path, @service) end class Item attr_reader :label, :value, :link def initialize(label, value, path, service) @label = label ...
true
4af38926cfba1a924f7bace14c6e841300fc51a2
Ruby
callen6/WDI_in_class_exercises
/class_example_deck.rb
UTF-8
822
3.890625
4
[]
no_license
class Deck def initialize @cards = [] @cards << Card.new("hearts", "ace") @cards << Card.new("hearts", "queen") @cards << Card.new("hearts", "king") @cards << Card.new("hearts", "jack") @cards << Card.new("hearts", "2") @cards << Card.new("hearts", "3") @cards << Card.new("hearts", "4") end def cards...
true
278a69fda279635de334134294ffe4fc9dc399fc
Ruby
alexejVasko/ruby
/lego.rb
UTF-8
381
3.78125
4
[]
no_license
character_name = "Joe Pretty fly " character_age = "34" puts character_name[0,9] puts " my age is: " + character_age puts "" puts " /|" puts " / |" puts " / |" puts " / |" puts "/____|" puts "" character_age = 4.4 puts character_name + character_age.to_s puts character_age.floor() puts char...
true
6d8006aaa7257f1620dc80a9819cd4387fc943d4
Ruby
thiagocaiubi/ruby-101
/sum.rb
UTF-8
169
3.8125
4
[]
no_license
puts "Enter a number:" first = gets.chomp puts "Enter another number:" second = gets.chomp sum = first.to_f + second.to_f puts first + " + " + second + " = " + sum.to_s
true
f5057689da4950fd2736fd8071bb87900a6cddb2
Ruby
kevpgoff/numcompress-ruby
/numcompress.rb
UTF-8
2,186
3.25
3
[]
no_license
PRECISION_LOWER_LIMIT = 0 PRECISION_UPPER_LIMIT = 10 #set_trace_func proc { |event, file, line, id, binding, classname| # printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname #} def compress(series, precision = 3) last_num = 0 result = "" if !series.kind_of?(Array) raise "Input list must be of type...
true
d7ce1c37fc48546d850741ad36cb37459f0666b8
Ruby
playup/dew
/lib/dew/password.rb
UTF-8
109
2.796875
3
[ "MIT" ]
permissive
class Password def self.random length=12 (0...length).map{ ('a'..'z').to_a[rand(26)] }.join end end
true
26c0663c00963d5fc438158bbd325bd165bd3b3b
Ruby
denmat/puppet_modules
/roles/lib/facter/roles.rb
UTF-8
2,117
2.625
3
[]
no_license
require 'facter' require 'open-uri' # access the amazon user-data meta-data to get the information about our host. # standard format is like the following: # node=<hostname> puppet=<master|client> mcollective=<master|client> domain=mylocal nameserver=172.19.1.10 # role=<provisioner|dbserver|webserver|nat|vpn_nat|bas...
true
be95a4ac04c544f39fe0e3573cdfd1be304bc7f0
Ruby
hipe/hipe-socialsync
/spec/spec_services-genned.rb
UTF-8
2,530
2.671875
3
[ "MIT" ]
permissive
# bacon spec/spec_services-genned.rb require 'hipe-socialsync' # You may not want to edit this file. It was generated from data in "services.screenshots" # by hipe-cli gentest on 2010-01-08 22:53. # If tests are failing here, it means that either 1) the gentest generated # code that makes tests that fail (it's not s...
true
1d1039c0f2bcf020329b74336ac4921dda4523cf
Ruby
taynarodrigues/automacao-do-ZERO-Full-Stack-com-foco-em-Ruby
/ruby/avancado/excecoes.rb
UTF-8
325
3.625
4
[]
no_license
# begin # #Devo conter alguma coisa # file = File.open('./ola.txt') # if file # puts file.read # end # rescue # #Obter um possรญvel erro # puts e.message # puts e.backtrace # end def soma(n1, n2) n1 + n2 rescue Exception => e puts e.message puts 'Erro ao executar a soma' #mensagem customizada end soma('10'...
true
064ae2486da7ed94123d7027b9ba70e4bdbf7011
Ruby
prromiz/ruby-coding
/count.rb
UTF-8
38
2.59375
3
[]
no_license
9.downto(1) {|n| p n} p " blastoff!"
true
3157714c9a6af45db240e38e9bd39485e499ec1b
Ruby
tamc/tem
/lib/tem.rb
UTF-8
1,290
3.375
3
[]
no_license
require_relative 'model' class Item def name self.class.to_s.downcase end alias :to_s :name end class Fuel < Item def setup(model) # Energy can be converted, but not created or destroyed model.constrain name, 0, 0 # Energy can enter the system, up to the limit of availability model.variabl...
true
4de5df9e5e2bda38996c993737e38addfd061c08
Ruby
meaganewaller/aoc
/2020/spec/day-11/puzzle_spec.rb
UTF-8
807
2.734375
3
[]
no_license
require 'spec_helper' require './day-11/puzzle' describe Puzzle do it "solves for part one for test input" do chart = File.readlines('./spec/day-11/input.txt').map(&:strip).map { |r| r.split("") } expect(Puzzle.part_one(chart)).to eql 37 end xit "solves for part one for input" do chart = File.readli...
true
da290bdaaedd02ebccd9fb941663b21f0febcd31
Ruby
MMcClure11/paint-dog
/lib/paint_dog.rb
UTF-8
1,946
4.1875
4
[]
no_license
class PaintDog def initialize @word = words.sample @lives = 7 @word_teaser = "" @word.first.size.times do @word_teaser += "_ " end end def words [ ["cricket", "A game played by gentlemen"], ["jogging", "We are not walking..."], ["celebrate", "Remembering special...
true
f3eaa136594edf05363d76083f2eaff26e9c4705
Ruby
masonforest/ar
/lib/far/cli.rb
UTF-8
694
2.90625
3
[ "MIT" ]
permissive
module Far class CLI def run(*args) @args = *args if File.directory?(subject) files_in_directory(subject).each {|file| execute(match, replacement, file)} else execute(match, replacement, subject) end end def self.run(*args) new.run(*args) end private...
true
67e9e44fe6c72a98db3d0d6e356d3ee0c60c5a28
Ruby
vinibr3/DCE9deNovembro
/app/helpers/escolaridades_helper.rb
UTF-8
431
2.671875
3
[]
no_license
module EscolaridadesHelper @@path = "#{Rails.root}/db/seeds/escolaridades" def self.populate file_path = "#{@@path}/escolaridades.csv" CSV.foreach(file_path,{headers: true}) do |row| save_escolaridade row[0] if !Escolaridade.exists?(nome: row[0]) end end private def self.save_escolaridad...
true