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
2a07b8a44d2d69a0fd39f205ea2b11e24bfe2056
Ruby
sergiomauz/Microverse-Coding-Challenges
/Mandatory/041 - Sorting Algorithms - Advanced Quick Sort/AdvancedQuickSort.rb
UTF-8
719
4.3125
4
[ "MIT" ]
permissive
def partition(array, low_index, high_index) pivot = array[high_index] j = low_index for i in low_index...high_index if array[i] < pivot array[i], array[j] = array[j], array[i] j += 1 end end array[high_index], array[j] = array[j], array[high_index] j end def advanced_qu...
true
b90738c992d0bfd76341b1689d71731759da4a0e
Ruby
patrickmcgraw/barcodes
/spec/barcodes/symbology/code128_spec.rb
UTF-8
930
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Barcodes is a RubyGem for creating and rendering common barcode symbologies. # # Author:: Aaron Wright (mailto:acwrightdesign@gmail.com) # Copyright:: Copyright (c) 2012 Infinite Token LLC # License:: MIT License require 'spec_helper' require 'barcodes/symbology/code128' describe Barcodes::Symbology::Code128 d...
true
e659fe8265aa2a974ba2de91a22df65575a48ffc
Ruby
caruby/uom
/test/lib/uom/composite_unit_key_canonicalizer_test.rb
UTF-8
1,677
2.8125
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/../helper' require "test/unit" require 'uom/units' require 'uom/composite_unit_key_canonicalizer' class CompositeUnitKeyCanonicalizerTest < Test::Unit::TestCase def setup @canonicalizer = UOM::CompositeUnitKeyCanonicalizer.new end def test_product_product standard = [U...
true
a2cfbd326279f7733704ce6ab026d9dc4882011b
Ruby
meaghanjones/editable_dictionary
/spec/word_spec.rb
UTF-8
1,911
3.125
3
[ "MIT" ]
permissive
require('rspec') require('word') require('definition') describe(Word) do before() do Word.clear() end describe('#name') do it('returns the name of the word') do test_word = Word.new({:name => "huge"}) expect(test_word.name()).to(eq("huge")) end end describe('#id') do it('returns...
true
d34eeafb7cd866863ae383df1c46b90d8e4987f6
Ruby
artvinicius/APi-Crud-Ruby-Sinatra
/ApiCrudP2.rb
UTF-8
1,346
2.875
3
[]
no_license
require 'sinatra' require 'date' require 'time' listacnpjs = [] get '/api/empresas' do if listacnpjs.size == 0 status 404 else "Empresas existente na base: #{listacnpjs} em #{Time.now}" end end get '/api/empresas/:cnpj' do |cnpj| cnpjEmpresar = params['cnpj'] if listacnpjs.in...
true
5d7ee9f8e01d093ca406175315e5a7989123f1bc
Ruby
ianknauer/RubyCourse
/week1/calculator.rb
UTF-8
539
4.3125
4
[]
no_license
puts "Hello... i am a calculator. Please give me your first number" num1 = gets.chomp puts "Excellent, now give me your second number" num2 = gets.chomp puts "Now.. What would you like to do to it? 1) add 2) subtract 3) multiply 4)divide" operator = gets.chomp if operator == "1" solution = num1.to_i + num2.to_i elsi...
true
10d355baeaee1fb9b692178f7af648f9d6306937
Ruby
dbarabander/BEWD
/06_Sharing_Behavior/starter_code/code_demo_stdnt_inheritance.rb
UTF-8
1,099
3.296875
3
[]
no_license
#Sharing Behavior and Variables #TIME: 20 min # Create an employee class. class Employee attr_accessor :first_name, :last_name def initialize(first_name, last_name) @first_name=first_name @last_name=last_name end def full_name "#{@first_name} #{@last_name}" end end # A manager is contactable...
true
ff09cd57d86c71f37566aa45b48cdda667170c1a
Ruby
baloi/dev_sched
/scheduler.rb
UTF-8
12,870
2.640625
3
[]
no_license
require File.expand_path(File.dirname(__FILE__)) + '/./calendar' require 'rubygems' require 'dm-core' require 'dm-validations' require 'dm-sqlite-adapter' require 'dm-migrations' #DataMapper.setup :default, 'sqlite3::memory:' DataMapper.setup :default, "sqlite://#{ENV['HOME']}/projects/scheduler/web.db" class Schedul...
true
a8ed73c93659818fa63fcdb2b04123b8c1eed497
Ruby
vendetta546/codewars
/Ruby/Authored/CarPark.rb
UTF-8
1,282
3.1875
3
[]
no_license
def escape(carpark) result = [] level = 0; space = 0 carpark.each_with_index {|f, i| (level = i; space = f.index(2)) if f.index(2) != nil} begin if level == carpark.length - 1 if space != carpark[0].length - 1 result << "R" + (carpark[0].length - space - 1).to_s end space = carpar...
true
ec2777387f8681584860c1bacb12c63d6c684a17
Ruby
samvera/active_fedora
/lib/active_fedora/change_set.rb
UTF-8
2,663
2.65625
3
[ "Apache-2.0" ]
permissive
module ActiveFedora # a Hash of properties that have changed and their present values class ChangeSet attr_reader :object, :graph, :changed_attributes # @param [ActiveFedora::Base] object The resource that has associations and properties # @param [RDF::Graph] graph The RDF graph that holds the current ...
true
cef28dda2464da5bfbbb407876f8b0a2eac63279
Ruby
vsuhachev/ruslat
/exe/ruslat
UTF-8
1,590
3.359375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require "ruslat" require "optparse" options = { convert: :rus_lat, "typo-correct": true, "case-correct": true } OptionParser.new do |parser| parser.banner = "Usage: ruslat [options] [path]" parser.on("-R", "Convert RUS => LAT (default)") { options[:convert] = :rus_lat } parser.on("-L...
true
c9cc2a1b673daf9463393f3d350dfe8e4a576244
Ruby
nealbehr/PDQ
/lib/archive/pdq_values_aggregator.rb
UTF-8
7,231
2.53125
3
[]
no_license
module PdqValuesAggregator module_function # Settings ZILLOW_IND = true MLS_IND = false FIRST_AM = false # Pre-defined current metric names and usage metric_usage = ["Price Range", "MSA Check", 3.times.collect { "Liquidity" }, 11.times.c...
true
72256cee88c48ae56fec1007912c96f84a7a3ee3
Ruby
abadfish/crud-with-validations-lab-v-000
/app/models/song.rb
UTF-8
822
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song < ActiveRecord::Base validates :title, :artist_name, presence: true validates :title, uniqueness: { scope: [:release_year, :artist_name], message: "Title must be original if released by the same artist in the same year." } validates :released, inclusion: { in: [true, false] } with_options if: :re...
true
44e85ae261ada8a23f590de694ed8550abe24302
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/phone-number/a58e25d143e14bfcb9ffbd42c518793b.rb
UTF-8
829
3.765625
4
[]
no_license
class PhoneNumber def initialize(raw_number) @number = normalize(raw_number) end def number @number end def area_code @number[0..2] end def exchange @number[3..5] end def subscriber @number[6..9] end def to_s "(" + area_code + ") " + exchange + "-" + subscriber end ...
true
033cba301823906512aca3a158a24793b4ab2a91
Ruby
yingnierxiao/army_rs
/lib/boot/boot/helpers/ohm/ohm/collection/collection.rb
UTF-8
1,819
2.578125
3
[]
no_license
module Ohm module Collection include Enumerable def each if block_given? ids.each_slice(1000) do |slice| fetch(slice).each { |e| yield(e) } end else to_enum end end # Fetch the data from Redis in one go. def to_a fetch(ids) end d...
true
965ccd487c7c199be5e80d3f4c0dc40565438161
Ruby
hs89/RIT-Course-Sniper
/sniper.rb
UTF-8
2,778
3
3
[]
no_license
require 'mechanize' require 'highline/import' @myuser = ask("SIS Username: ") { |user| user.default = "sisuser" } @mypass = ask("SIS Password: ") { |pass| pass.echo = false } @count_attempts = 0 user_input = ask("Enter desired course number in format aaaa-bbb-cc: ") { |course| course.validate = /\d{4}-\d{3}-\d{2}...
true
a1067548e02d273c50b34ae64978e3d30405f4ec
Ruby
nazwr/NFLSCRAPER
/public/schedule_scraper.rb
UTF-8
1,091
2.78125
3
[]
no_license
require 'open-uri' require 'nokogiri' require 'pry' require 'rubygems' require 'json' game_week = 17 while game_week <= 17 doc = Nokogiri::HTML(open("http://scores.nbcsports.com/fb/scoreboard.asp?week=#{game_week}")) a = doc.css('a') array = [] a.each do |thing| if thing.text == "Box" array << thing ...
true
a2ba8d14ddc180c91e815081e85f038ac0f853f4
Ruby
Jonesyd/launchschool_exercises
/ruby_basics2/06_user_input/06_passwords.rb
UTF-8
150
3.1875
3
[]
no_license
PASSWORD = "SecreT" loop do puts "Please enter your password" break if gets.chomp == PASSWORD puts "Invalid passord!" end puts "Welcome!"
true
71fee5718953b05c5c33fc4dba6e7d89a02bcd0d
Ruby
Katee/certificates
/lib/delivery.rb
UTF-8
757
2.65625
3
[ "MIT" ]
permissive
# encoding:UTF-8 require_relative 'delivery/dry_run.rb' require_relative 'delivery/smtp.rb' require_relative 'delivery/aws.rb' # Represents available delivery options to send certificate. # Can be a dry-run (delivers to terminal), an AWS SES delivery # or an SMTP delivery module Delivery def self.configure_deliverie...
true
f10d9b3fdee0b3631f9f898f9c1931723d934235
Ruby
ryanvo/diceware-gen
/dicegen.rb
UTF-8
723
3.390625
3
[]
no_license
require_relative 'random_word_service' class Dicegen def initialize(random_word_service) @random_word_service = random_word_service end def generate(num_of_phrases, num_of_passwords) raise ArgumentError, 'num_of_phrases must be > 0' unless num_of_phrases.to_i > 0 raise ArgumentError, 'num_of_passwo...
true
d21048dd174e6e4e125d6c7fa0f3735d813ba860
Ruby
missamynicholson/airport_challenge
/lib/weather.rb
UTF-8
177
3.015625
3
[]
no_license
class Weather def stormy? random_outlook == :stormy end private def random_outlook rand_num = Random.new.rand(5) rand_num == 1 ? :stormy : :fine end end
true
2c48c23b3f72a8dac67faaa52ac1e4154e1dce68
Ruby
theOtherDanBrowne/evo_app
/app/controllers/population_controller.rb
UTF-8
2,701
2.640625
3
[]
no_license
class PopulationController < ApplicationController before_filter :get_creatures, :only=> [:index, :kill, :kill_random, :clone_random, :mutate_gnome] def get_creatures total_population = 100 #@population = Creature.order("id desc").limit(total_population).reverse @population = Creature.find(:all, :cond...
true
75af667d9e8b111435233ddae944efdb620263d3
Ruby
CanaceWong/Bank_challenge
/lib/bankaccount.rb
UTF-8
729
3.3125
3
[]
no_license
require 'date' require_relative './bankstatement' class Bankaccount DEFAULT_BALANCE = 0 attr_reader :balance, :transactions def initialize @balance = DEFAULT_BALANCE @transactions = [] end def deposit(deposits) @balance += deposits deposit_transaction = {date: Date.today.to_s, credit: deposit...
true
3958ff4a50623d6044df0f3a3796f3bd52ee3716
Ruby
kahu08/Ruby_Projects
/hand_game/lib/hand_game.rb
UTF-8
1,248
3.375
3
[]
no_license
class String define_method(:hand_game) do player1_score = 0.0 player2_score = 0.0 while true # puts "Lets play rock, paper, scissors" # player1 turn # puts "(player1)Do you choose rock, paper, or scissors?" # player1 = STDIN.gets.chomp # player2 turn # puts "(player2)...
true
cbe906dee473aa6540673b18824545b96b42eca3
Ruby
AnnaAguilar/registro_academico
/Exemplos/20-lambda.rb
UTF-8
251
3.046875
3
[]
no_license
def retorno_lambda lam = lambda { return } lam.call puts "Retorno na funcao retorno_lambda" end def retorno_proc proc = Proc.new { return } proc.call puts "Retorno na funcao retorno_proc" end retorno_lambda retorno_proc puts "Fim da execucao"
true
8e4f685fd9d01d6ef074f8ad32d689944845d10a
Ruby
CodeHunt101/flatiron-bnb-methods
/app/models/concerns/shared_methods.rb
UTF-8
911
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "active_support/concern" module SharedMethods extend ActiveSupport::Concern # included do # scope :public, -> { where(…) } # end # def is_public? # # your code # end module ClassMethods def highest_ratio_res_to_listings result = {} self.all.each do |city| res_a...
true
fbe9e70a3ce3a664f0e964ee76563da4e75e12cb
Ruby
JimHertzler/FindLongestPath-in-Ruby
/longestPath.rb
UTF-8
538
3.21875
3
[]
no_license
# What this script does: Find the Longest-Path, that is, the most characters. # Why would we want to do this? # Because it may still be possible to choke your archive tool by feeding it a very long path. # Running this Ruby-Script in your current-working-directory will show you the longest path. begin longestPath...
true
dae99e6498d61e4289d94f0f81b1ce0153651ddf
Ruby
mystix/google_apps
/lib/google_apps/atom/public_key.rb
UTF-8
640
2.5625
3
[ "MIT" ]
permissive
module GoogleApps module Atom class PublicKey < Document attr_reader :doc def initialize super(nil) @doc.root = build_root :publickey end # new_key adds the actual key to the PublicKey # XML document. # # new_key 'key' # # new_key retur...
true
5a9402f52378328b9d27737b45568d09c1711b88
Ruby
Al-Qallaf/Storma
/if - Copy.rb
UTF-8
1,203
3.078125
3
[]
no_license
#CREATE DATABASE IF NOT EXISTS `simpledb` /*!40100 DEFAULT CHARACTER SET utf8 */; #DROP TABLE IF EXISTS customers; class If @@theindex = 0 def initialize(tokens, index) puts 'if class' @@theindex = index + 1 case tokens[@@theindex] when "IF" puts 'If token' @@theindex = @@theindex + 1 c...
true
2a37456f4124c258492d2775fc882dab206ab81d
Ruby
ytsheep0808/prune
/lib/prune/p_objects/base.rb
UTF-8
775
2.53125
3
[ "MIT" ]
permissive
# coding:utf-8 module Prune module PObjects class Base include Errors # Indent. @@indent = 0 def space " " * @@indent end def indent! @@indent += 1 end def outdent! @@indent -= 1 end def value_to_s(value) case value ...
true
8b81eaa51de7234bd25c734f01f683b8f6be2cce
Ruby
aspsa/bloccit
/spec/factories/comment.rb
UTF-8
708
2.625
3
[]
no_license
# Checkpoint #60 - Testing Users # # Let's create a Comment factory as well. Factory Girl lets us define after(:build) behavior for factories. Let's use this to disable the :send_favorite_emails callback because we don't want our tests to try to send emails. # # This code is run after the comment is initialized and bef...
true
55be7dd596b6cc49a99b8cb3d0f49d9e151c6d66
Ruby
technowizard12/your_fortune_lp
/app.rb
UTF-8
526
2.59375
3
[ "WTFPL" ]
permissive
require 'sinatra' require 'fortune_gem' get '/edition/' do @fortune = FortuneGem.give_fortune({:max_length => 235}) etag Digest::MD5.hexdigest(@fortune + Time.now.utc.strftime('%l%p, %d %b %Y %Z')) #etag is the same if the same fortune is accessed within a minute #because, to be true to fortune, the program...
true
d3a88fc52de7e4adccabb247da37fbdaf75ab038
Ruby
santaux/colonel
/lib/colonel/job.rb
UTF-8
519
2.84375
3
[ "MIT" ]
permissive
module Colonel class Job attr_reader :id, :schedule, :command def initialize(schedule, command) @schedule = schedule @command = command increase_amount @id = @@amount end def self.clear_amount @@amount = 0 end def update(opts={}) @schedule = Parser::Sch...
true
13e34f7cdc69af32f637e8ae1f0cffa3a656db63
Ruby
mkrumholz/enigma
/lib/decrypt.rb
UTF-8
401
2.796875
3
[]
no_license
require 'date' require './lib/enigma' require './lib/keyable' enigma = Enigma.new message = File.read(ARGV[0]) details = if ARGV[3].nil? enigma.decrypt(message, ARGV[2]) else enigma.decrypt(message, ARGV[2], ARGV[3]) end File.write(ARGV[1], details[:decryption]) p "Creat...
true
622a78b2fb7df85207218f5207403ac6d6f13686
Ruby
zhanghqgit/Seven-Weeks-Series
/Seven-Web-Frameworks-In-Seven-Weeks/angularjs/app.rb
UTF-8
3,283
2.546875
3
[]
no_license
#--- # Excerpted from "Seven Web Frameworks in Seven Weeks", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. ...
true
17f4c0907f9a460f217ec2be292f48fbe9ee9d76
Ruby
shotakawasaki0806/furima-33505
/spec/models/user_spec.rb
UTF-8
4,958
2.53125
3
[]
no_license
require 'rails_helper' RSpec.describe User, type: :model do before do @user = FactoryBot.build(:user) end describe "ユーザー情報" do context '新規登録できるとき' do it "nickname、email、password、password_confirmation、first_name、last_name、first_kana、last_kana、birthdayが存在すれば登録できる" do expect(@user).to be_vali...
true
c1b38d7ed1e267a14409fb709ac3e2e43826a852
Ruby
Mossio/hashira-rails
/lib/hashira/rails/actions/rename_file.rb
UTF-8
2,560
2.703125
3
[ "MIT" ]
permissive
module Hashira module Rails module Actions private def rename_file(old_path, new_path, options = {}) action RenameFile.new(self, old_path, new_path, options) end class RenameFile def initialize(base, old_path, new_path, options = {}) @base = base @full...
true
b2ee7506c50305e542e95df3e166feb3296ec11b
Ruby
t4kemyh4nd/ruby_programs
/deaf_grandma.rb
UTF-8
224
3.390625
3
[]
no_license
command = gets.chomp while command != 'BYE BYE BYE' if command == command.upcase puts 'NO, NOT SINCE 1938' elsif command == 'BYE' puts "" else puts "HUH?! SPEAK UP, SONNY" end command = gets.chomp end puts 'BYE'
true
faac652bb1f4d4a02144b6197e7b22330aebcf67
Ruby
alegomez1/Kata-Challenges
/odd_or_even.rb
UTF-8
273
3.71875
4
[]
no_license
#https://www.codewars.com/kata/5949481f86420f59480000e7/train/ruby def odd_or_even(array) sum = 0 if array.length != 0 array.each do |i| sum += i end if sum%2 == 0 return "even" else return "odd" end else "even" end end
true
8342a37996d848406d5c312feebd9197da31c0e1
Ruby
ruizender/herencia_polimorfismo
/modulo.rb
UTF-8
1,846
2.90625
3
[]
no_license
module Habilidades module Volador def volar 'Estoy volandooooo!' end def aterrizar 'Estoy cansado de volar, voy a aterrizar' end end module Nadador def nadar 'Estoy nadando!' end def sumergir 'glu glub glub glu' end end module Ca...
true
734933edd35d3550f02c70d5aa42b227ff8c65ab
Ruby
alirezaandersen/kenny-schools
/test/models/student_test.rb
UTF-8
1,552
2.859375
3
[]
no_license
require 'test_helper' class StudentTest < ActiveSupport::TestCase def test_student_can_be_created ali = Student.new(first_name: "Ali", last_name: "Andersen", age: "30", current_score: "90") assert ali.save end def test_only_bottom_5_struggling_students_are_returned rachel = Teacher.create(first_na...
true
366a9fa7068d4a5224beed3903c3ac841d5fc641
Ruby
davout/temporality
/lib/temporality/time_span.rb
UTF-8
3,371
3.296875
3
[ "MIT" ]
permissive
module Temporality class TimeSpan include Comparable attr_accessor :starts_on, :ends_on def initialize(starts_on, ends_on, _options = {}) @starts_on = starts_on @ends_on = ends_on check! end def to_s "{ TS : [#{starts_on} | #{ends_on}]}" end def inspect t...
true
891ea21d1bae99958e5862666c38376c11209943
Ruby
fluent-code/leetcode
/src/0001.two-sum/test_two-sum.rb
UTF-8
178
2.71875
3
[ "MIT" ]
permissive
require 'test/unit' require_relative 'two-sum' class MyTest < Test::Unit::TestCase def test_ result = two_sum([2, 7, 11, 15], 9) assert_equal(result, [0, 1]) end end
true
eefe942f7cd3cc9f18c19ef0928a357940cf4f28
Ruby
brianpgerson/appacademy-prep
/w1/w1d1/exercises/lib/01_temperature.rb
UTF-8
110
3.3125
3
[]
no_license
def ftoc(faranheit) (((faranheit - 32)/9)*5) end def ctof(celsius) (((celsius.to_f/5).to_f*9).to_f+32) end
true
42849bb924709a0a5607d397439dc508afc89f01
Ruby
Avinashkaur/Ruby
/ex1.rb
UTF-8
228
3.65625
4
[]
no_license
def traverse_string pattern = /[a-z]/i puts "Enter the string" str = gets.chomp.downcase char_count = Hash.new(0) str.each_char do |c| char_count[c] += 1 if c =~ pattern end puts char_count end traverse_string
true
710d138236687ef049b203ef4e486ea2b5326eee
Ruby
kevinhylant/classpass_app
/models/scheduled_class.rb
UTF-8
1,959
2.765625
3
[]
no_license
class ScheduledClass < ActiveRecord::Base has_many :ratings, :class_name => "ClassRating" , :dependent => :destroy has_many :reservations , :dependent => :destroy has_many :users, :through => :reservations belongs_to :klass belongs_to :instructor has_one :activity_type, :through => :klass h...
true
ec68931810f0b228ac98e02ea518932a69b3d73f
Ruby
arvind0598/slcm-api
/parser.rb
UTF-8
3,448
2.65625
3
[ "MIT" ]
permissive
require 'nokogiri' class Parser def self.get_course_name(name) # name.split.map{|x| # if x.length > 3 || x == 'LAB' # x.capitalize # elsif Utils.map_roman_integer(x, :roman_to_int)[:success] # x.upcase # else # x.downcase # end # }.join(' ') name.strip e...
true
37f7250289fd37ce0846417b42c1d75c5595e330
Ruby
rhowell/happy_hash
/spec/happy_hash_spec.rb
UTF-8
860
2.875
3
[]
no_license
require 'happy_hash' describe Hash do context 'Given a normal hash with string keys' do let (:string_hash) { { 'keyA' => 'ValA' } } it 'returns a new hash with the keys as symbols' do string_hash.happy_hash.should == { key_a: 'ValA' } end end context 'Given a normal hash with string keys' do ...
true
8cb9377416c65000b870f886d2e01210708b92a9
Ruby
jmorton138/binary_search_trees
/lib/node.rb
UTF-8
226
3.171875
3
[]
no_license
class Node attr_accessor :data, :left_child, :right_child def initialize(data, left_child = nil, right_child = nil) @data = data @left_child = left_child @right_child = right_child end end
true
68b150bd27052723ae876b47eee7dd5b2e398265
Ruby
benyang00/RedmartSinatra
/controllers/categories.rb
UTF-8
924
2.578125
3
[]
no_license
class RedmartSinatra < Sinatra::Base # Controller get '/' do erb 'This is the home page' end # Detailed list of brands information get '/categories' do @categories = Category.all erb :"categories/index" end # Registration page to add new brands get '/categories/new' do @new_category = Ca...
true
5f65d8f2ee0ba2a85b6aff8e23f2b6194eb5aef0
Ruby
unceus/bub
/lib/slack_commands/take_command.rb
UTF-8
2,808
3.078125
3
[ "MIT" ]
permissive
require './lib/slack_commands/slack_command' # Supports `bub take staging 3 hours`, and a number of variants on that: # `bub take` # `bub take 1 hour staging` # `bub take staging until tomorrow` <- # TODO # # Admittedly, the componentize system is overkill here, but since we only have # two components (time and ...
true
b81bc0186b5f2c789be5ddcc0451b807e4c12183
Ruby
lbhopewell/ruby-objects-has-many-through-lab-dumbo-web-102918
/lib/artist.rb
UTF-8
387
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" class Artist @@all = [] attr_accessor :name def initialize(name) @name = name @@all << self end def self.all @@all end def new_song(name, genre) Song.new(name, self, genre) #binding.pry end def songs Song.all.select do |song| song.artist == self end end def genres genre_list = [] songs.sel...
true
3e7cbc982f1b5d4d08cf28a3f9728c5676263300
Ruby
rocketmade/katas
/life/ruby/board.rb
UTF-8
2,001
3.3125
3
[]
no_license
require './cells' class Board attr_accessor :hash NEIGHBOR_OFFSETS = [-1,0,1].product([-1,0,1]) - [[0,0]] attr_accessor :view_area def initialize data="", height: 40, width: 120 @key_map = {} self.hash = hash_from_string data hash.default = dead configure_view_area height, width end def...
true
df659f3da9cdca4832710e889f3a35b1342fe245
Ruby
xea/halo
/model/transaction.rb
UTF-8
857
2.796875
3
[]
no_license
# Encapsulates an arbitrary monetary transaction class Transaction include DataMapper::Resource property :id, Serial property :amount, Float, :required => true, :default => 0.0 # When was the transaction completed property :at, DateTime, :required => true, :default => DateTime.now property :v...
true
0944eb4e28b6ca685f32a3eb7e3ddbb2c173b285
Ruby
bradjp/report_practice_task
/lib/reports.rb
UTF-8
247
3.109375
3
[]
no_license
def reports(word) array = ['Red', 'Amber', 'Green'] results = word.gsub(' ','').split(',') hash = {} results.each do |result| if hash.has_key?(result) hash[result] += 1 else hash[result] = 1 end end hash end
true
aad0278adb6e9a5c4b11341b600cb471cad07465
Ruby
lukekedz/code_eval
/multiples_of_a_number.rb
UTF-8
210
2.984375
3
[]
no_license
File.open(ARGV[0]).each_line do |line| args = line.split(",") args.map! { |str| str.to_i } args.push(args[1]) while args[1] <= args[0] args[1] = args[1] + args[2] end print args[1] puts end
true
5cc48ea815ae54b338b603744df5ead865314b66
Ruby
epicodus/for-the-monarch
/cli/campaign_cli.rb
UTF-8
1,560
3.109375
3
[ "MIT" ]
permissive
def add_campaign header list_provinces whitespace puts "Where do you wish to send one of your loyal Knights?" whitespace province = Province.find(gets.chomp.to_i) whitespace list_knights puts "And who will carry your banner on high?" knight = Knight.find(gets.chomp.to_i) whitespace Campaign.new(...
true
410c327d0ae22b4f32ce39ba92f0ddfa550df04d
Ruby
iamabhishekt/leetcode-ruby-1
/5.longest-palindromic-substring.rb
UTF-8
1,000
3.75
4
[]
no_license
# -*- coding: utf-8 -*- # # @lc app=leetcode id=5 lang=ruby # # [5] Longest Palindromic Substring # # https://leetcode.com/problems/longest-palindromic-substring/description/ # # Given a string s, find the longest palindromic substring in s. You # may assume that the maximum length of s is 1000. # # Example 1: # # Inpu...
true
2324d2e31ec980dc326eb8ed93440bb6764f439d
Ruby
ifriedman08/aa-w1d5
/TicTacToeAI-master/skeleton/lib/tic_tac_toe_node.rb
UTF-8
1,338
3.625
4
[]
no_license
require_relative 'tic_tac_toe.rb' class TicTacToeNode attr_reader :board, :next_mover_mark, :prev_move_pos def initialize(board, next_mover_mark, prev_move_pos = nil) @board = board @next_mover_mark = next_mover_mark @prev_move_pos = prev_move_pos end def losing_node?(evaluator) if @board.ove...
true
ca0969b79a3d364d4ca5dbbb955d880e6c37dcb0
Ruby
colineckert/aa-classwork
/w5d3/AA_Questions/reply.rb
UTF-8
1,757
2.984375
3
[]
no_license
require_relative "database" require_relative "question" require_relative "user" class Reply attr_accessor :id, :body, :user_id, :question_id, :reply_id def self.find_by_id(id) reply = QuestionsDatabase.instance.execute(<<-SQL, id) SELECT * FROM replies WHERE id = ? ...
true
c2376f0da9fdfd34701f302192a8173b5255691d
Ruby
ossert/ossert
/lib/ossert/stats.rb
UTF-8
2,435
2.84375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'ossert/stats/base' require 'ossert/stats/agility_total' require 'ossert/stats/agility_quarter' require 'ossert/stats/community_total' require 'ossert/stats/community_quarter' module Ossert module Stats # @return [Numeric] specifies too long interval border for quarter ...
true
1692747292d9990108ab1f5fae978a2b6e0c98c2
Ruby
pshussain/Backup
/multi.rb
UTF-8
535
3.265625
3
[]
no_license
class String define_method('multi_gsub') do |pattern| str=self.split(//) pos=0 temp="" for pos in 0...str.length case str[pos] when pattern[0][0] temp<<str[pos].replace(pattern[0][1]) when pattern[1][0] ...
true
716fb2e893c181ccdab1ec0c0c002fc7a6bc36c1
Ruby
kopz9999/json-inflator
/spec/recycle_validator.rb
UTF-8
3,315
2.703125
3
[ "Apache-2.0" ]
permissive
require 'jsonpath' class RecycleValidator attr_accessor :decycled_hash, :recycled_hash, :reference_property, :values_property, :identifier_property, :json_root, :context, :mode, :parser def initialize( opts ) self.decycled_hash = opts[:decycled_hash] self.recycled_hash = opts[:recycled_hash] ...
true
bd548731ea3ce913c7660232a7891d39ea1923ba
Ruby
ochedenis/study
/my_own/compact.rb
UTF-8
322
3.171875
3
[]
no_license
# require 'pry' # require 'test/unit' # extend Test::Unit::Assertions def cmp(x) x2 = [] x.each {|y| if y !=nil x2 << y end } return x2 end p cmp([ "a", nil, "b", nil, "c", nil ]) #=> [ "a", "b", "c" ] # result = cmp([ "a", nil, "b", nil, "c", nil ]) # assert_equal result, [ "a", "b", "c" ]...
true
8f52e970857f66eaa40e0c5a1297674d481cae87
Ruby
Yuri-M-Dias/DynamicProgramming
/Ruby/rod_length_recursion.rb
UTF-8
534
3.59375
4
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- def bestPriceForRodLength(valueTable, length) if(length <= 0) return 0 end max = -1 (0...length).each do |i| max = [max, valueTable[i] + bestPriceForRodLength(valueTable, length - (i + 1))].max end return max end valueTable = [2, 3, 7, 8, 9, 10, 13, 15, 17, 19] puts "#{bestPriceForR...
true
275a1a5a5e9f1bf3c7c1c3835dde28340705a5a9
Ruby
and0x000/advent-of-code-2020
/day1/script.rb
UTF-8
765
3.015625
3
[]
no_license
# frozen_string_literal:true require 'benchmark' numbers = File.open('input').readlines.map(& :strip).reject(& :empty?).map { |x| Integer(x) } numbers_loop1 = numbers.dup Benchmark.bm do |x| x.report do while (number_1 = numbers_loop1.pop) numbers_loop2 = numbers_loop1.dup while (number_2 = number...
true
d6ae9532bc8e02729413bfe2954ca33b6408ed0f
Ruby
qranahan/learn-co-sandbox
/rubypractice/dog.rb
UTF-8
163
3.171875
3
[]
no_license
class Dog def initialize(name) @name = name end end dog1 = Dog.new("Fido") dog2 = Dog.new("FiFi") dog3 = Dog.new("Friendo") puts dog1 puts dog2 puts dog3
true
6cbd4d949c46ab98a972f17e76af13ab16b91fb4
Ruby
heathercreighton/sum17-ruby-day1
/rubypractice.rb
UTF-8
468
4.125
4
[]
no_license
# # Sends a message to our user # puts "What's your name?" # # gets user input and stores in variable 'name' # name = gets.chomp # #take the users input and add it to a string greeting # puts "Oh, hello " + name age = 35 mood = "happy" puts "When you turn " + age.to_s + "-years-old, you are still pretty young! And ...
true
3b8c0eee6ea57de3a963da1596f64f8d88c4b2e9
Ruby
Steenaire/params-app
/app/controllers/params_examples_controller.rb
UTF-8
1,976
2.671875
3
[]
no_license
class ParamsExamplesController < ApplicationController #Query parameters action: def query_parameters puts "params taken and outputted below" @name = params[:name].upcase @message = "" if @name[0] == "A" @message = "Hey, your name starts with the first letter of the alphabet!" end fi...
true
b2457649fdfaa86e396b3bd6479b60d51ef43407
Ruby
Noelryn/Ruby
/Dog.rb
UTF-8
184
3.5
4
[]
no_license
class Dog attr_accessor :breed, :name def initialize(breed, name) @breed = breed @name = name end def wag_tail puts "Tail wagging" end end
true
49bb6e4b6650f28ff7af6529dad6347e1eed23c5
Ruby
chet-k/DSA-Problems
/max_prod_word_lengths.rb
UTF-8
1,045
3.546875
4
[]
no_license
# @param {String[]} words # @return {Integer} ''' LC 318 https://leetcode.com/problems/maximum-product-of-word-lengths/ Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0. TAKEN FROM htt...
true
a4a8da083d887cb81212863efa872fe3e03556f6
Ruby
nicklombardi/wdi
/exampleCode/ruby/array_ex2.rb
UTF-8
315
3.796875
4
[]
no_license
students = ["student one", "student two", "student three"] students.each { |student| p student.capitalize} puts "___________" students.each do |student| unless student == "student one" p student.capitalize else p student end end puts "___________" 3.times do |x| puts "awesome #{x} times" end
true
b8a13f8efcbd93656d4998597a4eeddcc0f4b1c8
Ruby
scroniser/assignment_ruby_warmup
/rollDice.rb
UTF-8
144
3.46875
3
[]
no_license
def roll_dice(dice=1) total = 0 dice.times do |roll| total += (1 + rand(6)) end return total end #Test output: print roll_dice(4)
true
ef28fb9f4d139d345a6e462a4f5607de30995e5f
Ruby
ryanden2018/html_printer
/html_printer.rb
UTF-8
1,447
3.25
3
[]
no_license
#!/usr/bin/env ruby if !ARGV[0] || !ARGV[1] puts "Usage: ruby html_printer.rb infile outfile" exit end # read input file from arglist fin = File.new(ARGV[0],"r") contents = nil if fin contents = fin.read fin.close else puts "I/O error: file #{ARGV[0]} could not be read" exit end # split file into tokens ...
true
3b3051ca46a12aee91f3cff69f6392e5563747e2
Ruby
alessiosantocs/cool_work
/atp/test/unit/picture_test.rb
UTF-8
1,624
2.578125
3
[]
no_license
require File.dirname(__FILE__) + '/../test_helper' class PictureTest < Test::Unit::TestCase fixtures :pictures def setup @picture = Picture.find 1 end def test_should_create_picture p = create_picture() assert p.valid? end def test_count_my_fixtures assert_equal 3, Picture.count ...
true
59c311ab5c90b71e7f29254d4d12a3f6b3e4d966
Ruby
charliecorrigan/bon_appetit
/test/pantry_test.rb
UTF-8
5,368
3.1875
3
[]
no_license
require './lib/pantry' require './lib/recipe' require 'minitest/autorun' require 'minitest/pride' class PantryTest < Minitest::Test def test_it_exists pantry = Pantry.new assert_instance_of Pantry, pantry end def test_pantry_stock_attribute pantry = Pantry.new output = pantry.stock assert_e...
true
d030cbf82d4e2f93128e936cad5f488d842cf0e5
Ruby
mondok/hshtg
/lib/hshtg/storage/in_memory_store.rb
UTF-8
1,538
3.203125
3
[ "MIT" ]
permissive
# Public: Generic store for Hashtag objects. # This is a simple interface that could # be easily overridden with a distributed store if needed. module Hshtg module Storage class InMemoryStore def initialize @hash_tags = [] end # Public: Add tags to collection. # # *tags - ar...
true
2fca4b5b261db2cda706b4fbdf34dd8eec51648f
Ruby
leclercjul/tests-ruby
/lib/02_calculator.rb
UTF-8
607
3.546875
4
[]
no_license
def add (num1, num2) return (num1 + num2) end def add (num1, num2) return (num1 + num2) end def subtract (num1, num2) return (num1 - num2) end def sum (array) sum = 0 array.each do |b| sum += b end return sum end def multiply (x, y) return (x*y) end ...
true
c4b56458ed60c7ba6a3dbd73c17434f55d2a8fb3
Ruby
jdleesmiller/gemma
/lib/gemma/rake_tasks/plugin.rb
UTF-8
1,050
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Gemma class RakeTasks # # Plugins generate rake tasks based on the content of the gemspec. # # The intention is that the plugin processes the gemspec and sets # (intelligent) default values when it is created. The {RakeTasks} object # then calls {#create_ra...
true
a383467955478753f43fbe11a60b2eccdc43d1bd
Ruby
nschechter/opendirectoryfilefinder
/models/OpenDir.rb
UTF-8
2,337
2.703125
3
[]
no_license
require 'sinatra/activerecord' class OpenDir < ActiveRecord::Base TYPES = ['root', 'movie', 'tv', 'music'] MOVIE_TYPES = ['moving pictures', 'film', 'motion picture', 'features'] TV_TYPES = ['serie', 'tele', 'show', 'serial', 'video', 'anime', 'cartoon', 'animate'] MUSIC_TYPES = ['album', 'song', 'cassette', 'vin...
true
92967328885614619c4c6b35f48e6e35acafe830
Ruby
berniechiu/pagy
/lib/pagy/extras/compact.rb
UTF-8
3,230
2.53125
3
[ "MIT" ]
permissive
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/compact class Pagy # Add nav helpers for compact pagination module Frontend # Generic compact pagination: it returns the html with the series of links to the pages # we use a numeric input tag to set the page and the PagyCompact javascrip...
true
97653614a720ce72d2cc3c028dbbac361dbfcaa7
Ruby
chet-k/DSA-Problems
/ugly_number.rb
UTF-8
736
3.96875
4
[]
no_license
=begin Wups, should have recognized we do NOT need to factorize the whole entire thing. Would have been much better to just iteratively divide the number by 5, 3, and 2 etc. We don't need all those extra primes floating around in memory. https://leetcode.com/problems/ugly-number https://leetcode.com/submissions/d...
true
384f184e1be0b4f4d6b17f95e36ceefbf7a69646
Ruby
amclees/hyena
/tests/economy_tests.rb
UTF-8
3,985
3.03125
3
[]
no_license
# frozen_string_literal: false require 'simplecov' SimpleCov.start require_relative '../world/economy/currency_system.rb' require_relative '../world/economy/economy.rb' # Tests CurrencySystem including parsing and custom system definitions class TestCurrencySystem < Test::Unit::TestCase def test_value_storage ...
true
59792e8979b20f3342f1ac9ebcc0cb6ba154e088
Ruby
XFinger/citizen_reporting
/app/helpers.rb
UTF-8
921
3.09375
3
[]
no_license
#dev tool to print the shift_data hash module Helper def print_hash puts '________________________________________' @shift_data.each do |key, value| puts key + ' : ' + value.to_s puts value.class end puts '________________________________________' end # Helper to convert flo...
true
30f75f809168d92ecbfa9e3e4ea156d103848c23
Ruby
hattwj/sshakery
/lib/sshakery/auth_keys.rb
UTF-8
14,367
2.625
3
[ "MIT" ]
permissive
module Sshakery ## # == AuthKeys # The AuthKeys class is the main part of this gem and is responsible # for reading from and writing to an authorized_keys file. class AuthKeys # atomic writes require 'tempfile' require 'fileutils' # instance attributes ## # Attributes that help define the current...
true
5f0e0ab44b84e636ad0333fcd47b97b121a2dca9
Ruby
svanderbleek/cyrus
/test/data_store_test.rb
UTF-8
1,966
2.828125
3
[]
no_license
require 'test/unit' require 'date' require 'cyrus_data/data_store' module CyrusData class TestDataStore < Test::Unit::TestCase def setup @store = DataStore.new end def test_stores assert_equal 0, @store.data.size @store.store ['A', 'B', 'M', '1-1-1990', 'R'] assert_equal 1, @stor...
true
60e9b53107c50eea1eb7f0d8258e4397193fb77c
Ruby
rsieb/siroflow
/getmylocation.rb
UTF-8
2,408
2.71875
3
[]
no_license
#!/usr/bin/env ruby -KU require 'rubygems' require 'bundler/setup' require 'restclient' require 'growl' require 'json' # capture if in-flight #ssid = system("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I|grep \" SSID:\" | cut -c 18-") ssid = `/System/Library/PrivateFrameworks...
true
44503475ff4279f67dc9545b2b549879cbd4d313
Ruby
sajadtorkamani/ruby-katas
/spec/consecutive_spec.rb
UTF-8
434
3.15625
3
[]
no_license
# frozen_string_literal: true require_relative '../src/consecutive' describe 'consecutive' do it 'returns true if a and b appear consecutively in the list' do expect(consecutive([1, 6, 9, -3, 4, -78, 0], -3, 4)).to be true expect(consecutive([1, 3, 5, 7], 3, 1)).to be true end it 'returns false if a an...
true
4d4fb0da695308479262e6abc89e5b79482b0254
Ruby
automaticmode/active_workflow
/spec/lib/utils_spec.rb
UTF-8
7,520
2.84375
3
[ "MIT" ]
permissive
require 'rails_helper' describe Utils do describe '#unindent' do it 'unindents to the level of the greatest consistant indention' do expect(Utils.unindent(<<-MD)).to eq('Hello World') Hello World MD expect(Utils.unindent(<<-MD)).to eq("Hello World\nThis is\nnot indented") Hello...
true
3d74db0bab107fb243d563787112ad088f71aef8
Ruby
AlexQ6/Notes_App
/src/main.rb
UTF-8
675
2.875
3
[ "MIT" ]
permissive
require_relative "classes.rb" require_relative "help.rb" require "artii" require "tty-prompt" require "tty-file" require "tty-table" require "colorize" args = ARGV if args.empty? title = Artii::Base.new puts title.asciify("Terminal Notes").colorize(:light_blue) StartMenu.new else case args[0].downc...
true
e204e460149d90da573cd64d095f7b5411b062fc
Ruby
Yujian-Li/OOP-Practice-in-Ruby
/Random Walk/main.rb
UTF-8
1,221
3.84375
4
[]
no_license
require_relative 'kangaroo.rb' ##Counting attempts to hop over the border as valid hops. ##Checking home not as a point comparison (using ==) but member comparison one-by-one. ##Creating an instance variable even though the variable was only used in the current method and a local variable would suffice. class Main p...
true
8684b2b45c5d7867749a977752b5ccbc5f3c9701
Ruby
Rygel-XVI/test
/spec/rover_spec.rb
UTF-8
2,036
3.09375
3
[ "MIT" ]
permissive
RSpec.describe Socrata::Rover do it 'is defined' do expect(defined?(Socrata::Rover)).to be_truthy expect(Socrata::Rover).to be_a(Class) end it "initializes with a location and direction" do rover = Socrata::Rover.new(1, 1, "n") expect(rover.x).to eq(1) expect(rover.y).to eq(1) expect(...
true
0a5647d68c984ca199c6e317d13717f0f317709b
Ruby
brady-robinson/Object-Oriented-Programming
/other_oo_resources/6_tutorialspoint.rb
UTF-8
324
3.875
4
[]
no_license
class Box BOX_COMPANY = "123 Box Company" BOXWEIGHT = 10 def initialize(h,w) @height, @weight = h,w end def getArea @height * @weight end end box = Box.new(10, 20) a = box.getArea puts "The area of the box is #{a}" puts "The box comes from #{Box::BOX_COMPANY}" puts "The box weighs #{Box::BOXWEIG...
true
a7d64ca8dd55ace08772e057b648bcdfd1a61117
Ruby
oneworldcoders/live-katas
/kata-tennis/spec/tennis_spec.rb
UTF-8
2,549
2.953125
3
[]
no_license
require 'rspec' require 'tennis' RSpec.describe TennisScorer do let (:tennis_scorer) {TennisScorer.new} it 'assigns love-lovve scores when no play has been made' do expect(TennisScorer.new.score).to eq('love-love') end describe 'Tests to get player one scores' do it 'Assign points when player one ha...
true
5ebff209c3b9c72ca329f52653c2fcdd4ab81586
Ruby
karanvalecha/design_patterns.rb
/Facade/home_theatre_facade.rb
UTF-8
1,021
2.53125
3
[]
no_license
require_relative './amplifier.rb' require_relative './tuner.rb' require_relative './screen.rb' require_relative './popper.rb' require_relative './cd_player.rb' require_relative './dvd_player.rb' require_relative './projector.rb' require_relative './lights.rb' class HomeTheatreFacade attr_reader :amp, :tuner, :scree...
true
2c157fc03b53632997aac0a43a135a75a40e559d
Ruby
fernandokokocha/new_catan
/spec/helpers/turn_type_calcluator_spec.rb
UTF-8
9,384
2.53125
3
[]
no_license
# frozen_string_literal: true describe TurnTypeCalculator do shared_examples 'turn type calculator' do |turn, expected| let(:turn) { turn } it 'correctly calculates turn type' do expect(call).to be(expected) end end describe '#initial_turn?' do subject(:call) { TurnTypeCalculator.new(play...
true
d2f1a1fd94cb1745a35ab71643abd79dc30d27aa
Ruby
christeiro/pre-course
/intro/intro-exercises/exercise1.rb
UTF-8
208
4.4375
4
[]
no_license
# exercise1.rb # Use the each method of Array to iterate over [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and print out each value. arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] arr.each do |n| if n > 5 puts n end end
true
cae8a908f5b1e137a611e4d872f2ff5d8702a7be
Ruby
mathias/hackety-hack.com
/models/comment.rb
UTF-8
440
2.53125
3
[]
no_license
# Comments are an embedded document that's inside of a few different things: # content, programs, and maybe other stuff in the future. They're really # simple: Just some text, the person who said it, and their email address. The # author should be the slug. Having the email lets us show their avatar easily. class Comme...
true
2006aca7720fc048f5e3201578d508c3e1e510d4
Ruby
MichaelSlevin/birthday-app
/lib/birthday.rb
UTF-8
379
3.5
4
[]
no_license
require 'date' class Birthday attr_reader :date, :today def initialize(date, today=DateTime.now) date = DateTime.strptime(date, '%Y-%m-%d') @today = today @date = Date.new(@today.year,date.month,date.day) @date = @date.next_year if @date < @today end def today? @today == @date end de...
true
5f9bf4d728f36fa3966da07a33a96f50df4373b6
Ruby
gabrielwalker/codeeval
/sum_of_primes.rb
UTF-8
131
3.015625
3
[]
no_license
#!/usr/bin/ruby require 'prime' prime = Prime.take(1000) sum = 0 prime.each do |prime_num| sum += prime_num end puts sum
true