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
29ce09599beabf990cc2e65ab4d505eda3ffe8f1
Ruby
Mattens15/Inline-LASESI
/vendor/bundle/gems/bcrypt-3.1.7/spec/bcrypt/engine_spec.rb
UTF-8
3,373
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper")) describe "The BCrypt engine" do specify "should calculate the optimal cost factor to fit in a specific time" do first = BCrypt::Engine.calibrate(100) second = BCrypt::Engine.calibrate(400) second.should > first end end de...
true
fde0377f96b7b40ff01a828928836003e86f5a25
Ruby
saramic/learning
/workshop/fp_patterns/tail_recursion/lib/demo.rb
UTF-8
213
3.203125
3
[ "Unlicense" ]
permissive
module Demo def sum_recursive(up_to) up_to == 0 ? 0 : up_to + sum_recursive(up_to - 1) end def sum_tail_recursive(up_to, acc) up_to == 0 ? acc : sum_tail_recursive(up_to - 1, acc + up_to) end end
true
b7e3aa6bd107af659308ae5ae41d5f8fc36d92e9
Ruby
felipegruoso/spotify-api
/lib/spotify/models/track.rb
UTF-8
1,540
2.96875
3
[ "MIT" ]
permissive
module Spotify module Models class Track attr_reader :artists, :available_markets, :disc_number, :duration_ms, :explicit, :external_urls, :href, :id, :is_playable, :linked_from, :name, :preview_url, :track_number, :type, :uri # # Sets the arguments to its variables. # ...
true
39001b52d3bd28054ca482b3f7e82d10d2c2f414
Ruby
apoex/squid
/lib/squid/settings.rb
UTF-8
911
2.703125
3
[ "MIT" ]
permissive
require 'squid/config' module Squid # @private module Settings # For each key, create an attribute reader with a settings value. # First, check if an option with the key exists. # For example: {formats: [:currency]} ->> [:currency] # Then, check is an option with the singular version of the key exi...
true
8a610f1320810deece7f545440a07d4be7743550
Ruby
thebmo/ruby_junk
/assert_test.rb
UTF-8
359
2.609375
3
[]
no_license
# Assertion Tests require "test/unit" require_relative "dragons" include Test::Unit::Assertions d = Dragon.new("BMO") b = BlueDragon.new("Juju") assert_equal("blue", b.color, failure_message = "first dragon color") assert_equal("non -", d.color, failure_message = "second dragon color") assert(b.armor > 0, failure_m...
true
6778d3c3fcbf774f7d61edf2b44670b74f991668
Ruby
vuxe/codility
/GenomicRangeQuery_62.rb
UTF-8
562
3.375
3
[]
no_license
# you can write to stdout for debugging purposes, e.g. # puts "this is a debug message" def solution(s, p, q) # write your code in Ruby 2.2 factor = nil arr = [] i = 0 res = [] for i in 0...s.length do case s[i] when 'A' arr << 1 when 'C' arr << 2 when 'G' arr << 3 ...
true
881970914742200f86d0a33f32e8bcbf72de7970
Ruby
RuffWorksTech/RB101-Programming-Foundations
/lesson_4/selection_and_transformation.rb
UTF-8
2,258
4.34375
4
[]
no_license
### Given the produce hash, write a method `select_fruit` that selects the key-value pairs whose value is `'Fruit'` ### # def select_fruit(produce_hash) # produce_hash.select { |k, v| v == 'Fruit' } # end # produce = { # 'apple' => 'Fruit', # 'carrot' => 'Vegetable', # 'pear' => 'Fruit', # 'broccoli' => 'V...
true
23b8cf6b6db62d8d1e98ce6cc09d45f12055c743
Ruby
fantasygame/dungeon_explorer
/spec/models/character_spec.rb
UTF-8
877
2.515625
3
[]
no_license
require 'rails_helper' RSpec.describe Character, type: :model do subject(:character) { build(:character) } describe '#level' do context 'character has 0 experience' do it 'returns 1st level' do character.experience = 0 expect(character.level).to eq 1 end end context 'chara...
true
5a9cd7d898df75c009abc0a7c8584471aaf97741
Ruby
tom-james-watson/voyagefound
/data_converter/page_hierarchy.rb
UTF-8
2,693
2.984375
3
[]
no_license
class PageHierarchy # Expects an xml filename. The xml doc should have one child, and that child # should have all pages as immediate children. def self.from_xml_file(xml_doc) @whatever doc = File.open('enwikivoyage-latest-pages-articles.xml') { |f| Nokogiri::XML(f) } page_hierarchy = new(doc.childr...
true
3425c05db311046753b44d4d28eb8775b04fc40f
Ruby
daifu/CodeEval
/angry_children/angry_children.rb
UTF-8
1,500
3.96875
4
[ "MIT" ]
permissive
# Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has N packets of candies and would like to distribute one packet to each of the K children in the village (each packet may contain different number of candies). To avoid a fight between the children, he would like to pick K out of N packets...
true
3d850c29495601c605e92fa922c9c34fe3032e7d
Ruby
andriiginting/Line-distance-ruby
/lib/square.rb
UTF-8
231
2.90625
3
[]
no_license
module Geometry class Square < Rectangle def initialize(x_offset, y_offset,length) super(x_offset,y_offset,length,length) @x_offset = x_offset @y_offset = y_offset @length = length end end end
true
912cf21aebe0e2800b1f4f8bf1f09a185d9da659
Ruby
ck3g/nevermissyourmovie
/app/services/create_movie.rb
UTF-8
250
2.515625
3
[]
no_license
class CreateMovie attr_reader :movie def initialize(options = {}) @movie = Movie.new options end def save save_result = @movie.save if save_result MovieInfoWorker.perform_async @movie.id end save_result end end
true
6c3b21eb799d733b245dd47c9e9140e28d78bbb6
Ruby
AlabushevEvgeniy/viselitsa
/viselitsa.rb
UTF-8
652
2.703125
3
[]
no_license
if Gem.win_platform? Encoding.default_external = Encoding.find(Encoding.locale_charmap) Encoding.default_internal = __ENCODING__ [STDIN, STDOUT].each do |io| io.set_encoding(Encoding.default_external, Encoding.default_internal) end end require_relative "lib/game.rb" require_relative "lib/result_printer.rb...
true
9e27067486093de1a942e2b07172110153f50f9d
Ruby
RubyGameCode/Text-Based-Rpg
/Testing chunks of code.rb
UTF-8
795
3.296875
3
[]
no_license
require "Part 2, after character creation" require "Page that has some methods to be used frequently" two_way_dialogue("option 1: prepare to attack whomever may be on the other side of that door", "option 2: Cower in the corner") cell_action_option_2 = gets.chomp if cell_action_option_2.include?("1") dialogu...
true
d04fa8af86a113b62a4af961c8cd38070789d928
Ruby
jasminenoack/in-progress
/Minesweeper_rails-master/app/models/board.rb
UTF-8
1,088
2.796875
3
[]
no_license
class Board < ActiveRecord::Base has_many( :tiles, class_name: "Tile", foreign_key: :board_id, primary_key: :id ) def self.setup_beginner! board = Board.create(alive: true, columns: 9, rows: 9, bombs: 10) num_tiles = board.rows * board.columns num_tiles.times do |i| Tile.create...
true
906061c6a7c8fe31902e928317e55ee62954427a
Ruby
takumirie/log-note
/logging.rb
UTF-8
855
3.15625
3
[]
no_license
# ver 1.0.0 # instruction. # # Please use this program with 'ruby'! not 'pry' or 'irb'. # # Developed by Takumi irie. # https://github.com/takumirie. # # Please make sure this program is my practice of studying Ruby. # If you have a time? give me a advice or comment! # # Feel free to edit, and share. require 'date'...
true
c34e937a5e4fccb7a367c61ed4fa86afa3fe9716
Ruby
alonhartal/payday
/lib/payday/line_itemable.rb
UTF-8
418
2.890625
3
[ "MIT" ]
permissive
# Include this module into your line item implementation to make sure that Payday stays happy # with it, or just make sure that your line item implements the amount method. module Payday::LineItemable # Returns the total amount for this {LineItemable}, or +price * quantity+ def amount_no_tax price * quantity ...
true
b4efc0ee396134b260ca09a1a2c504be8784dd12
Ruby
obrie/neptune
/lib/neptune/partitioner/hashed.rb
UTF-8
489
2.59375
3
[ "MIT" ]
permissive
require 'zlib' module Neptune module Partitioner # Partitions keys using a consistent hash function based on the total # number of partitions class Hashed # Generates the hashed partition index. This will use all partitions # even if some are not available to ensure that those messages are ...
true
b1fa4aef19f2c75730076b1bc7eca904f29a60f4
Ruby
katiekeel/job-tracker-base
/spec/models/tag_spec.rb
UTF-8
1,463
2.640625
3
[]
no_license
require 'rails_helper' RSpec.describe Tag, type: :model do describe "validations" do context "invalid attributes" do it "is invalid without a name" do tag = Tag.new() expect(tag).to be_invalid end it "has a unique name" do tag_1 = Tag.create(name: "Tag 1") tag_2...
true
0fc68205c98ec68c44072a0e59ad03c4c8ab44b4
Ruby
CareGuide/ramparts
/lib/ramparts/parsers/phone_parser.rb
UTF-8
3,575
3.109375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative '../helpers' # Parses text and attempts to locate phone numbers class PhoneParser # Counts the number of phone number instances that occur within the block of text def count_phone_number_instances(text, options) raise ArgumentError, ARGUMENT_ERROR_TEXT unless tex...
true
ffcf418dc72b73f29d1ee7c5c0a7debf093d8e86
Ruby
jfdelaluz/LearningRuby
/Variables.rb
UTF-8
330
3.828125
4
[]
no_license
class Variables def initialize() end def tipo_variables() #Variables Strings en Ruby saludo = "Hola Mundo desde Ruby" #Variables Int en Ruby valorUno = 1 valorDos = 2 #Variables Float en Ruby valorTres = 2.2 puts valorUno + valorDos + valorTres end end objeto = Variables.new() objeto.tipo_variab...
true
0463d1800fa5571ffbbe9e4dc951447a1e289f27
Ruby
aleksanderbrymora/sei-36
/harish_ramesh/4week/9march/class/rough/games.rb
UTF-8
676
4.0625
4
[]
no_license
def magic_question print "Ask me a question: " @question = gets.chomp end @answers = [" It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it."] def magic_eight magic_question() if @question.size > 5 puts @answers[rand(@answers.length)] else puts "Tha...
true
414ba248d04908629f88a4235c88cd44bf37d9f0
Ruby
ahmedelmahalawey/sablon
/lib/sablon/context.rb
UTF-8
962
2.6875
3
[ "MIT" ]
permissive
module Sablon # A context represents the user supplied arguments to render a # template. # # This module contains transformation functions to turn a # user supplied hash into a data structure suitable for rendering the # docx template. module Context class << self def transform_hash(hash) ...
true
8d5f3d6bc5dffbb82f054ee6052a89cb674847fb
Ruby
tekt8tket/back_to_the_timezone
/lib/back_to_the_timezone.rb
UTF-8
1,436
2.828125
3
[ "MIT" ]
permissive
module BackToTheTimezone extend ActiveSupport::Concern # This loads the methods in ClassMethods and InstanceMethods sub modules into any class that includes this class module ClassMethods # Usage in model definition as follows, ex: # shift_timezone :legacy_registered_at, :legacy_timezone => 'Eastern Time (US & C...
true
fe2b33944e076cb4c42e5e19413a8fab029cf07d
Ruby
starksm64/node.x
/src/main/ruby/core/shared_data.rb
UTF-8
3,611
2.53125
3
[]
no_license
# Copyright 2002-2011 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use # this file except in compliance with the License. You may obtain a copy of the # License at http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agree...
true
411f517b0a8d8ea71b51d0eac070a5d081e14bf8
Ruby
gyan88singh/timecard_new
/app_BKP13thMar18/helpers/application_helper.rb
UTF-8
618
2.53125
3
[]
no_license
module ApplicationHelper def showdatetime(mydatetime) if mydatetime strdatetime=mydatetime.to_time.strftime("%d-%m-%Y %I:%M %P") else strdatetime="" end return strdatetime end def showtime(mydatetime) if mydatetime strdatetime=mydatetime....
true
518460efd5fe59f56895c09111e7fc25308395b8
Ruby
Satkar/entertainment_platform
/app/models/user.rb
UTF-8
1,384
2.5625
3
[]
no_license
# This class represents a user in the system class User < ApplicationRecord validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }, presence:true, uniqueness: true has_many :library_items, dependent: :destroy after_commit :flush_cache # cache the result def self.fetch_and_cache Rails.cache.fetch(...
true
945a98371827682148e7ec7cc12df2cffc557c3e
Ruby
debzow/ruby_exercices_week_0
/exo_12.rb
UTF-8
120
3.203125
3
[]
no_license
puts "Donnes moi un nombre !!!!" print ">" loopNumber = gets.chomp.to_i i=1 loopNumber.times do puts i i += 1 end
true
94f2329e71b1d97b2ea8dc7eaeb93f16c963af65
Ruby
flyerhzm/rails_best_practices
/lib/rails_best_practices/reviews/use_query_attribute_review.rb
UTF-8
5,206
3.09375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module RailsBestPractices module Reviews # Make sure to use query attribute instead of nil?, blank? and present?. # # See the best practice details here https://rails-bestpractices.com/posts/2010/10/03/use-query-attribute/ # # Implementation: # # Review proce...
true
5485a7e64433c6a7b4e87e39235cb23771c7af8e
Ruby
Noirbot/TicTicToeAgents
/GameDriver.rb
UTF-8
3,322
3.671875
4
[]
no_license
require "./TTTGame.rb" require "./RandomTTTPlayer.rb" require "./SmartTTTPlayer.rb" # Adding a method to the global String class to check if a string represents an integer. class String def is_i? !!(self =~ /^[-+]?[0-9]+$/) end end # If there are no arguments, give help. if ARGV.length == 0 puts("Help...
true
dd6652ae5ca59071c73dac6b2ac1db86aaec001f
Ruby
austinoso/ruby-oo-complex-objects-school-domain-sfo-web-012720
/lib/school.rb
UTF-8
481
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class School attr_accessor :roster def initialize(school_name) @name = school_name @roster = Hash.new{|h,k| h[k] = []} end def add_student(name, grade) @roster[grade] << name end def grade(grade) @roster[grade] end def sort sorted_rost...
true
0ba54649b24fed1d4a2c8caca1ceeac450dea1ae
Ruby
motonari728/donno
/lib/tasks/sample_data.rake
UTF-8
778
2.75
3
[]
no_license
require 'securerandom' namespace :db do desc "Fill database with sample data" task populate: :environment do #populate: データを入れる,入植させる make_rooms make_users make_microposts end end def make_rooms 10.times do |n| room_name = Faker::Name.name Room.create!( room_name: room_name ) end end def make_users ...
true
5035298fef7cb81a9b023221042856cfe958b7b2
Ruby
gurgeous/scripto
/lib/scripto/run_commands.rb
UTF-8
2,553
3.03125
3
[ "MIT" ]
permissive
require "English" require "shellwords" module Scripto module RunCommands # The error thrown by #run, #run_capture and #run_quietly on failure. class RunError < StandardError end # Run an external command. Raise RunError if something goes wrong. The # command will be echoed if verbose?. # ...
true
da4d5fc057fd07c55254bfab5d2e1c87c0c7607f
Ruby
sgneha/chitter-challenge
/lib/peep.rb
UTF-8
254
2.71875
3
[]
no_license
class Peep attr_reader :id, :text, :timestamp, :updatedtime, :user_id def initialize(id, text, timestamp, updatedtime, user_id) @id = id @text = text @timestamp = timestamp @updatedtime = updatedtime @user_id = user_id end end
true
ed1923d31fae5442054ee142790ad4a07229a44b
Ruby
simonewebdesign/expression-parser
/main.rb
UTF-8
291
3.625
4
[]
no_license
require './evaluator.rb' # This program calculates the value of an expression # consisting of numbers, arithmetic operators, and parentheses. print 'Enter an expression: ' expression = gets evaluator = Evaluator.new expression result = evaluator.get_expression_value puts "=> #{result}"
true
91a0358896d012a033a5d882501260df4d332178
Ruby
micktaiwan/weewar-bot-platform
/specs/goals_tests.rb
UTF-8
498
2.875
3
[]
no_license
require File.dirname(__FILE__) + '/../lib/goal' class MyClass def initialize @some_value = 2 end def set_action(goal) goal.set_action(method(:test_action)) end def test_action @some_value end end describe "Goal" do before(:all) do @goal = Weewar::Goal.new(:test) @plan = Weew...
true
e987253df2db83e7e54cb2cff3ba9b22cf6448bb
Ruby
ricocaldeira/domr
/bin/domr
UTF-8
173
2.65625
3
[]
no_license
#!/usr/bin/env ruby require 'domr' # Check for empty query if !ARGV[0] arg = '' else arg = ARGV[0] end # Perform the search if !Domr.search(arg) exit 1 else exit 0 end
true
1d84d1558f20adfd4611d594142e59eccbc1370a
Ruby
kaleemullah/being_lucky
/being_lucky.rb
UTF-8
307
3.53125
4
[]
no_license
require_relative 'die' class BeingLucky attr_reader :dice def initialize(dice) @dice = dice end def score score = 0 (1..6).each do |num| count = dice.count(num) # calculate each die score and add it score += Die.new(num, count).score end score end end
true
4c3c80a8ece9bda975e9cd56dd3304328414065f
Ruby
shaunagm/bridge_troll
/app/services/omniauth_providers.rb
UTF-8
2,019
2.71875
3
[]
no_license
module OmniauthProviders def self.provider_data [ { key: :facebook, name: 'Facebook', icon: 'fa-facebook-square' }, { key: :twitter, name: 'Twitter', icon: 'fa-twitter-square' }, { key: :github, name: 'Github', i...
true
a23f6cc7943b6a14abb56f91f5d84afd9f87f5fa
Ruby
reneecruz/blood-oath-relations-dumbo-web-080519
/app/models/cult.rb
UTF-8
2,016
3.6875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Cult attr_accessor :name, :location, :founding_year, :slogan @@all = [] def initialize(name, location, founding_year, slogan) @name = name @location = location @founding_year = founding_year @slogan = slogan @@all << self end def oaths BloodO...
true
8ed9d6c985c5e8d3d5fb54e48bde050a3aecaa31
Ruby
zeade/minesweeper
/lib/minesweeper/solver.rb
UTF-8
4,789
3.28125
3
[ "Apache-2.0" ]
permissive
require 'benchmark' module Minesweeper class Solver attr_accessor :board, :wins, :losses, :solve_time # Run from class wrapper def self.run(tries: 100_000, debug: false) solver = self.new(debug: debug) solver.solve(tries: tries) end def initialize(size: 10, mines: 10, debug: false) ...
true
a74b7e66b8ee740db091e82a1071cdbe494bc68e
Ruby
L-codes/ctf-scripts
/misc/encoder/base92.rb
UTF-8
1,757
3.4375
3
[]
no_license
#!/usr/bin/env ruby # # Author L # base92 encode/decode # class Base92 def self.decode(str) return '' if str == '~' bitstr = '' str.chars.each_slice(2) do |x,y| if y n = base92_ord(x)*91 + base92_ord(y) bitstr += '%013b' % n else n = base92_ord(x) bitstr += '...
true
fe527f69f2103475cd744eb7f4463dd35383b280
Ruby
geoffreyadebonojo-zz/super_sports_games-new
/super_sports_games-master/runner.rb
UTF-8
1,068
4.09375
4
[]
no_license
# Create a program that allows a User to interact with the Games through the command line # Upon starting the program, the User should enter the year for the games # The User can then create new Events and get a Summary of the Events require 'pry' require './lib/games' def create_new_games p "What year are the gam...
true
77a0f92a618b8fb83655099999de9e772c84c2be
Ruby
AnanthSrinivasan/CodeChallenges
/Translator/MetalObject.rb
UTF-8
299
2.6875
3
[ "MIT" ]
permissive
# MetalObject will hold the values of various metal # present in the configuration. # silver - silver value # gold - gold value # iron - iron value class MetalObject # attr_accessor :silver # attr_accessor :gold # attr_accessor :iron attr_accessor :type attr_accessor :value end
true
aaab92012afc8488c624cf62e888c40be3187c93
Ruby
petertseng/exercism-problem-specifications
/exercises/food-chain/verify.rb
UTF-8
1,285
3.234375
3
[ "MIT" ]
permissive
require 'json' require_relative '../../verify' ANIMALS = [ [:horse, 'She\'s dead, of course!'], [:cow, 'I don\'t know how she swallowed a cow!'], [:goat, 'Just opened her throat and swallowed a goat!'], [:dog, 'What a hog, to swallow a dog!'], [:cat, 'Imagine that, to swallow a cat!'], [:bird, 'How absurd ...
true
f1882ea6502144708eea630d9a8adcf6db14df73
Ruby
TashfeenRao/tic-tac-toe
/spec/game_spec.rb
UTF-8
4,051
3.109375
3
[]
no_license
# frozen_string_literal: true require_relative '../lib/board' require_relative '../lib/game_status' require_relative '../lib/player' RSpec.describe 'GameStatus' do let(:board) { Board.new } let(:plyr) { Player.new } let(:game) { GameStatus.new } let(:display) { TicTacToe.new } let(:win) { [[0, 1, 2], [3, 4,...
true
8370a5e815953764c157487042c16faf59613717
Ruby
tera911/merrychacha
/loaddata.rb
UTF-8
4,425
2.734375
3
[]
no_license
#!/usr/bin/ruby # encoding: utf-8 require "csv" require "Base64" # パスを指定してcsvをロードする def loadCSV(filename) csv = CSV.read(filename, encoding: "SJIS:UTF-8") return csv end # CSVを書き込む def writeCSV(arr, filename) CSV.open(filename, 'w') do |writer| arr.each{|row| writer << row} end end # CSV用の配列から文字を検索する def searc...
true
e0e40e2b74666dd90a3f3f66f1221a4d16427d9d
Ruby
vitormd/RubyAlgorithms
/spec/exercise_12_spec.rb
UTF-8
656
3.078125
3
[]
no_license
require_relative '../exercises/exercise_12' describe Array do context 'self each' do it 'execute the block then, return equal the argument' do #Arrange array = [1,2,3,4,5] #Act result = array.each { |x| x + 1 } #Assert expect(result).to eq([1,2,3,4,5]) end it 'execute...
true
570078950fa15851e82db20a6f7b0bc1eca7223e
Ruby
isabella232/appoxy_rails
/lib/sessions/shareable.rb
UTF-8
7,135
2.515625
3
[]
no_license
require 'aws' require 'simple_record' module Appoxy module Sessions module Shareable # Call this method on your Sharable object to share it with the person. # returns: a hash with :user (the user that the item was shared with), :ac (activation code that should be sent to the user) # o...
true
e29d7abb7b261b0b773806ce348d25d979322906
Ruby
htphan/codecreep
/lib/codecreep/github.rb
UTF-8
1,034
2.84375
3
[ "MIT" ]
permissive
require 'httparty' require 'pry' module Codecreep class Github include HTTParty base_uri 'https://api.github.com' basic_auth ENV['GH_USER'], ENV['GH_PASS'] def get_user(username) self.class.get("/users/#{username}") end def follower_page(username, page) self.class.get("/users/#{...
true
ed4526999893f97ef77f17d9fbef9939cbb13099
Ruby
JordanFaust/dotfiles
/eventable/lib/eventable/worker/pool.rb
UTF-8
1,000
2.53125
3
[]
no_license
require 'concurrent' require 'logger' module Eventable module Worker class Pool attr_accessor :store def initialize(params = {}) @pool = Concurrent::FixedThreadPool.new(params[:threads] || 5) @store = Concurrent::Map.new() @task = nil @signal = Proc.new {} @ca...
true
8162dddda0d3c2688179af21caeac6ca066ebdda
Ruby
mozamimy/toolbox
/ruby/search_ec2_missing_tag/search_ec2_missing_tag.rb
UTF-8
732
2.546875
3
[ "CC0-1.0" ]
permissive
#!/usr/bin/env ruby require 'aws-sdk-ec2' tag_key = ARGV[0] ec2 = Aws::EC2::Client.new results = [] ec2.describe_instances.reservations.each do |reservation| results << reservation.instances.select do |instance| instance.tags.all? { |tag| tag.key != tag_key } end end results.flatten! if results.size < 1 ...
true
b90cbc9a419f8401a52796c2a6c978f965fab9f5
Ruby
IvanKhoteev/polyglot
/app/interactions/phrases/create.rb
UTF-8
1,451
2.546875
3
[]
no_license
module Phrases class Create < ActiveInteraction::Base object :word hash :ru do string :present_i string :present_you string :present_we string :present_they string :present_he string :present_she string :past_i string :past_you string :past_we string...
true
1f43efd56d50e5936487e19549775e0c972204c9
Ruby
kohkb/atcoder
/abc051_100/abc099/b.rb
UTF-8
95
2.953125
3
[]
no_license
a, b = gets.chomp.split.map(&:to_i) h = 0 (b - a - 1).downto(1) do |i| h += i end p h - a
true
6b1d7ab2c5ccdc3a0ca92ca848d3d1c53a405895
Ruby
xingzo/trivia-game
/db.rb
UTF-8
732
3.015625
3
[]
no_license
# Database Configuration # ====================== # Documentation: https://deveiate.org/code/pg/PG.html # Use this module to: # - Connect to the adventure database # - CRUD operations (CREATE, SELECT, UPDATE, DELETE) # require 'pg' def connection PG::Connection.new(dbname: 'trivia') end def add_table(questions) c...
true
4d6f41bf0ef3ae3737c73e9d75b0bac617487284
Ruby
c-amos/ttt-10-current-player-ruby-intro-000
/lib/current_player.rb
UTF-8
411
3.109375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# require_relative '../spec/current_player_spec.rb' def turn_count(board) counter = 0 for member in board if member == "X" counter += 1 end if member == "O" counter += 1 end end counter end def current_player(board) counter = turn_count(board) if counter % 2 == 0 current_pl...
true
8f1b90a635688e03e634112a1b15944c1f9f04ca
Ruby
under-os/under-os
/gems/under-os-ui/spec/under_os/page/stylesheet_spec.rb
UTF-8
2,454
2.546875
3
[ "MIT" ]
permissive
describe UnderOs::Page::Stylesheet do before do @stylesheet = UnderOs::Page::Stylesheet.new end describe '#initialize' do it "should make an empty stylesheet" do @stylesheet.rules.should == {} end it "should allow initialize with some rules" do stylesheet = UnderOs::Page::Stylesheet....
true
d806ce417a5ff4a8bf4029bd097f948bdcf37d48
Ruby
wlcreate/ruby-oo-fundamentals-object-attributes-lab-nyc04-seng-ft-071220
/lib/dog.rb
UTF-8
206
3.15625
3
[]
no_license
class Dog def name @name end def name=(name_arg) @name = name_arg end def breed @breed end def breed=(breed_arg) @breed = breed_arg end end
true
f4aa2bc216ecd015868cc18e516311117711a675
Ruby
zhangbay/guideproject
/blog/spec/string_calculator_spec.rb
UTF-8
318
2.796875
3
[]
no_license
require "string_calculator" describe StringCalculator do context "two numbers" do it "given 2,4" do expect(StringCalculator.add("2,4")).to eql(6) end end context "given '17,100'" do it "returns 17" do expect(StringCalculator.add("17,100")).to eql(117) end end end
true
eedd70a18dc85ef78fe277301ba5f875134bd0f3
Ruby
angeljolon/learn-co-sandbox
/arrays.rb
UTF-8
392
3.953125
4
[]
no_license
#create an Array a = ["Ruth", "Lilly", "Bicondova","Romeo", "Dicaprio", "John"] # puts a[0] # puts a[3] # #extracting ALL elements of an array # puts a # a.push("Pratt") # a << "Zac" # puts a #removing elements from an array # a.delete_at(0) # puts a #size the array # puts a.size #changing an element # puts a...
true
65a2d58cbc3c4764c5dd9c2617b5dc24c33cffdb
Ruby
hhofner/Scripts
/secret_santa.rb
UTF-8
1,979
2.9375
3
[]
no_license
require 'mail' # Secret Santa # names of all participants friends = Array.new participants = Array.new secret_santas = Array.new emails = Hash.new # secret santa assignments ss_mappings = Hash.new name = 'temp' email = 'temp' print 'Enter Name and Email: ' while user_input = gets.chomp splitted_inpu...
true
bb0fc03014f6a90c6ab78b93fdab5e22a550b547
Ruby
socketry/async-http
/lib/async/http/proxy.rb
UTF-8
3,531
2.609375
3
[ "MIT" ]
permissive
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2019-2023, by Samuel Williams. require_relative 'client' require_relative 'endpoint' require_relative 'body/pipe' module Async module HTTP # Wraps a client, address and headers required to initiate a connectio to a remote host using the...
true
1570739f17a216087d7624cd44a7c0a636ec3a01
Ruby
prs148/chessmate
/app/models/queen.rb
UTF-8
209
3
3
[]
no_license
class Queen < Piece def valid_move?(x, y) super(x, y) && (x_position == x || y_position == y || x + y == x_position + y_position || x - y == x_position - y_position) end end
true
c48eac5069f4afc225bdff27981214998394b054
Ruby
mkenane/looping-for-prework
/for.rb
UTF-8
86
2.875
3
[]
no_license
def using_for checklist = 1..10 for item in checklist puts "Wingardium Leviosa" end end
true
c9d6f00c808699026272e595ebb7350f56541007
Ruby
kazutxt/Sample
/rb/dirのtree.rb
SHIFT_JIS
1,150
2.984375
3
[]
no_license
#dirtree def dirs(path = Dir.pwd ,depth = []) # JgfBNg̈ړ Dir.chdir(path) #p lastdir # . .. ȊÔׂẴt@Czɂ lists = Dir.glob("./*") if(depth.size == 0) print "/--+\n" else print File.basename(path) + "\n" end # ‚̗vfƂi܂./tĂ) lists.size.times{ |i| # ./菜 data = lists[i].slice!(2..-1) # sԂ̐ depth.e...
true
83957dd0d703a0baf14d13d0000be0d26d211ce4
Ruby
kiizerd/chess
/spec/event_bus_spec/event_bus_spec.rb
UTF-8
2,314
2.84375
3
[]
no_license
require_relative '../../lib/event_bus/event_bus' describe EventBus do describe "#get_event" do context "given token matches existing event" do let(:new_event) { Event.new :new_event } before { EventBus.events << new_event } it "returns event object" do event = EventBus.get_event :new_...
true
afb18b00771bd7d8ce570247eca9c7ee9f06ba61
Ruby
loych03/ruby-advanced-class-methods-lab-dumbo-web-100818
/lib/song.rb
UTF-8
1,159
3.25
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Song attr_accessor :name, :artist_name @@all = [] def self.all @@all end def save self.class.all << self end def self.create song= Song.new song.save song end def self.new_by_name(name_song) song = self.new song.name = name_song song end def self.create_by_name(name_song) ...
true
ecdaa5b0b50957b6be85c80b89161bc0a6ec3cc5
Ruby
COASST/coasst-old
/app/models/name.rb
UTF-8
401
3.671875
4
[]
no_license
class Name attr_reader :first_name, :middle_initial, :last_name def initialize(first_name, middle_initial, last_name) @first_name = first_name @middle_initial = middle_initial @last_name = last_name end def to_s [ @first_name, @middle_initial, @last_name ].compact.join(" ") end ...
true
9c116f9310cbde131c22d7c0afc6c818c9b3a9c4
Ruby
ajgosling/App_Academy_Review
/Alpha_Curriculum/rspec_exercises/rspec_exercise_1/lib/part_2.rb
UTF-8
811
3.609375
4
[]
no_license
def hipsterfy(word) i = word.length - 1 vowels = "aeiou" while i >= 0 if vowels.include?(word[i].downcase) return word[0...i] + word[i + 1..-1] end i -= 1 end return word end def vowel_counts(str) vowel_hash = Hash.new(0) vowels = "aeiou" str.each_...
true
c7d541e00add0a9c670bbe6b2cda5761cf8791e9
Ruby
donal/mobile-auth
/v3/consumer_middleware.rb
UTF-8
877
2.53125
3
[]
no_license
require 'rack' class ConsumerMiddleware def initialize(app, options = {}) @app = app end def call(env) puts "consumer_password" # valid = true # unless env['REQUEST_METHOD'] == 'POST' && env['PATH_INFO'].match(/\/(session|users)/) # # TODO check consumer # # get the consumer_key fro...
true
d28cb955227bfaa2019cbd7dbc9e37a4451ae523
Ruby
iarunpaul/Ruby-Object-Relationships
/Classes/cinema.rb
UTF-8
254
3.359375
3
[]
no_license
class Cinema attr_accessor :name, :location def initialize(name, location) @name = name @location = location @movies = [] end def add_movie(movie) @movies << movie movie.cinema = self end end
true
7dc3213cdb20ef823b743125bf1ddd5599b2898d
Ruby
JohnLoza/black-brocket
/app/models/concerns/searchable.rb
UTF-8
1,224
2.640625
3
[]
no_license
require 'active_support/concern' module Searchable extend ActiveSupport::Concern class_methods do # search for key_words in certain fields # available options, key_words = String, fields = Array and joins = Hash def search(options={}) # not search anything if there are no key_words or fields to...
true
1535d646c2614db5f4d456457e28323bc6cb092c
Ruby
Dahie/blight-music-video
/lib/image_placement_helpers.rb
UTF-8
367
2.6875
3
[]
no_license
module ImagePlacementHelpers def middle_x(image) x - image.width / 2.0 end def middle_y(image) y - image.height / 2.0 end def left middle_x(animation.image) end def right left + animation.image.width * x_factor end def top middle_y(animation.image) end def bottom top ...
true
d97a218098a1418f8b9e53058cda76999f0d1d04
Ruby
ErikaNana/MyGrades
/app/models/assignment.rb
UTF-8
616
2.671875
3
[]
no_license
class Assignment < ActiveRecord::Base attr_accessible :title #list of fields that you want to be accessible attr_accessible :description attr_accessible :user_id attr_accessible :grade attr_accessible :dueDate def self.build_from_csv(row, params) row.compact! #take out nil values, figur...
true
c9e8bac999fa90f0555604770ada41f7d30f9a16
Ruby
fanjieqi/LeetCodeRuby
/1301-1400/1359. Count All Valid Pickup and Delivery Options.rb
UTF-8
141
2.953125
3
[ "MIT" ]
permissive
MOD = 10**9 + 7 # @param {Integer} n # @return {Integer} def count_orders(n) (2..n).inject(1) { |ans, i| ans * (2 * i * i - i) % MOD } end
true
5ebe7d8ab5ccce716cf105100ab8e3221ab1b93e
Ruby
sabtain93/rb_101_small_problems
/medium_2/04.rb
UTF-8
2,409
4.625
5
[]
no_license
=begin # Problem: - Input: a string - Output: Boolean - true if all the parentheses in the string argument are properly balanced i.e. occur in matching () pairs - return true if there are no parenthesis in the input string - false if the parentheses in the string are not balanced # Examples: balanced?('What ...
true
439bef72a522732ae27421fe68977e07056267c8
Ruby
0308199710520/oystercard2
/lib/oystercard.rb
UTF-8
1,204
3.375
3
[]
no_license
require_relative "./journey" class Oystercard attr_reader :balance, :journey MAX_BALANCE = 90 MIN_CHARGE = 1 def initialize(balance: 0, journey: Journey.new) @balance = balance @journey = journey end def top_up(amount) fail "Can't top up, would take balance over #{MAX_BALANCE}" if max_balan...
true
eec38c9c0534f0346072f1c8d9dd8802ebb23311
Ruby
diogoribeiro/sample_app
/spec/models/user_spec.rb
UTF-8
5,688
2.703125
3
[]
no_license
# == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(255) # email :string(255) # created_at :datetime # updated_at :datetime # require 'spec_helper' describe User do before(:each) do @attr = { :name=> "Joao bobo", :ema...
true
dc9d725dbee3dc645f48977943f8e48f46e41ec8
Ruby
Agatov/happymama
/app/models/groop.rb
UTF-8
290
2.65625
3
[]
no_license
class Groop < ActiveRecord::Base belongs_to :workshop belongs_to :place validates :workshop_id, presence: true validates :place_id, presence: true def seats_available if total_seats and reserved_seats total_seats - reserved_seats else nil end end end
true
08402e7d967b5fa89bd30b13a8ebc2382b03d5b5
Ruby
dcaba/personal-training
/codewars/pig.rb
UTF-8
228
3.421875
3
[]
no_license
def pig_it text words = text.split " " words.map! do |word| if word.downcase.gsub(/[^a-z0-9\s]/i, '') == "" word else word[1..word.size] + word[0] + 'ay' end end words.join " " end puts pig_it "Test example !"
true
0bc9402f7efd7317b7595e9636b75173539dbd96
Ruby
vinnyalfieri/lectures-and-videos-web-615-public
/search_youtube/youtube.rb
UTF-8
332
2.609375
3
[]
no_license
require 'open-uri' require 'nokogiri' require 'pry' puts "What would you like to see?" query = gets.strip html = open("https://www.youtube.com/results?search_query=#{query}").read doc = Nokogiri::HTML(html) href = doc.search("h3.yt-lockup-title a.yt-uix-tile-link").first.attr("href") system("open https://youtube....
true
08ebea1856130ed26d9733fcbd42606237d97eb1
Ruby
Erol/active_model_validations
/spec/active_model_validations/maximum_validator_spec.rb
UTF-8
758
2.65625
3
[ "MIT" ]
permissive
require 'spec_helper' class MaximumValidatorModel < OpenStruct include ActiveModel::Validations validates :value, maximum: { value: 0, message: 'must not be higher than the maximum value' } end RSpec.describe MaximumValidator do it 'allows an equal value' do model = MaximumValidatorModel.new(value: 0) ...
true
32ad4e32816fb11bcf56dc80fca0d747a66c8980
Ruby
timetwister4/nanotwitter
/client_lib/clientlib_test.rb
UTF-8
3,481
2.6875
3
[ "MIT" ]
permissive
require_relative '../test/test_helper.rb' require 'byebug' require_relative '../models/user.rb' require_relative '../models/tweet.rb' require_relative '../clientlib.rb' tweet_id1, tweet_id2 = 0 include Rack::Test::Methods #if env == "test" # puts "starting in test mode" # User.destroy_all # Twe...
true
246d4104828909860ba6e72bfc644e7f2fb77c57
Ruby
mberrueta/statistic_calcs
/lib/statistic_calcs/distributions/base.rb
UTF-8
1,711
2.828125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'statistic_calcs/helpers/alias_attributes' require 'gsl' require 'pry' module StatisticCalcs module Distributions class Base include StatisticCalcs::Helpers::AliasAttributes attr_accessor :mean, :variance, :standard_deviation, :median, :skew...
true
0324ed529200b73ba3705b2f49896f1e5de733f8
Ruby
RutarAndriy/Ruby_Learning
/Lesson_15/Libraries.rb
UTF-8
657
3.203125
3
[ "MIT" ]
permissive
# Підкючення бібліотеки <io-console> require "io/console" puts "Використання бібліотеки \"io-console\"" puts "\n" puts "Незахищене поле ввделення тексту" text_1 = STDIN.gets.chomp puts "\n" puts "Захищене поле ввделення тексту" # Використання бібліотеки для приховування введеного тексту text_2 = STDIN.noecho(&:get...
true
32a5df0906b3d9e313d938a7569302eed1755537
Ruby
vikram7/connect_four_v2
/play_connect_four.rb
UTF-8
424
3.09375
3
[]
no_license
#!/usr/bin/env ruby require './game.rb' require './board.rb' require './player.rb' # gameplay: game = Game.new board = Board.new(game) player1 = game.set_player_type(1, "o") player2 = game.set_player_type(2, "x") game.setup_turn_queue(player1, player2, board) while board.check_for_winner == false board.display...
true
f6c776b585ac5c97f0ddddb7baae6aaf6e9b6dad
Ruby
CodingDojoDallas/ruby_dec_16
/Woodall_Robert/assignments/ruby_fundamentals/basic13.rb
UTF-8
1,385
4.3125
4
[]
no_license
# print 1-255 # (1..255).each { |i| puts i } # print odds 1-255 # (1..255).each { |i| puts i if i % 2 != 0} # print sum #sum = 0 #(1..255).each { |i| puts "New number: #{i}, Sum: #{sum += i}" } # following won't work for some reason # (1..255).inject(0) { |sum, i| puts "New number: #{i}, Sum: #{sum + i}" } # iterate...
true
99ab429b78ad1119b8dd826aa3852cbe20866ef3
Ruby
Hostile359/MarginalValera
/lib/saver.rb
UTF-8
693
3.328125
3
[]
no_license
require 'json' class Saver def self.read_stats(filename) file = File.read(filename) JSON.parse(file) end def self.save_stats(stats, filename) file = File.open(filename, 'w') file.write(JSON.dump(stats)) file.close end def self.saver(stats, choice) filename = '' loop do put...
true
25b5def53193fb7fc9395409416c70e495634da5
Ruby
rennex/hellbender
/irc.rb
UTF-8
4,260
2.734375
3
[]
no_license
require "socket" require "yaml" require "logger" require_relative "loggerformatter" require_relative "util" require_relative "message" module Hellbender class IRC include UtilMethods attr_reader :config, :log, :connected def initialize(config = {}) @config = config @connected = false ...
true
0e58c6f8c434506a14046597c6bb3a6001d572f5
Ruby
cha63506/bus-scheme
/lib/eval.rb
UTF-8
908
2.84375
3
[]
no_license
module BusScheme class << self # Parse a string, then eval the result def eval_string(string) eval(parse("(begin #{string})")) end # Eval a form passed in as an array def eval(form) # puts "evaling #{form.inspect}" if (form.is_a?(Cons) or form.is_a?(Array)) and form.first ...
true
228b91be40dc0d5f48130e399e2fa966f6a96cb1
Ruby
airservice/grape-apiary
/lib/grape-apiary/route.rb
UTF-8
1,303
2.546875
3
[ "MIT" ]
permissive
module GrapeApiary class Route < SimpleDelegator # would like to rely on SimpleDelegator but Grape::Route uses # method_missing for these methods :'( delegate :route_namespace, :route_path, :route_method, to: '__getobj__' def route_params @route_params ||= begin __getobj__.route_params....
true
ce97ece08f067837c3769443d77f3d39e8a78a3b
Ruby
fieldstyler/war_or_peace
/test/player_test.rb
UTF-8
876
3.125
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/card' require './lib/deck' require './lib/player' class PlayerTest < Minitest::Test def setup @card1 = Card.new(:diamond, 'Queen', 12) @card2 = Card.new(:spade, 'Ace', 14) @card3 = Card.new(:heart, '3', 3) @cards = [@card1, @card2, @c...
true
2a3838b0a9a71aba89ebbf36cab0763e1c76778d
Ruby
yogodoshi/slackbot-therock
/app/services/slack_api.rb
UTF-8
427
2.515625
3
[]
no_license
class SlackAPI def initialize @channel_id ||= ENV['SLACK_CHANNEL_ID'] @client ||= Slack::Web::Client.new end def usernames_list usernames_list = [] channel_users_ids.each do |user_id| usernames_list << "@#{@client.users_info(user: user_id)['user']['name']}" end usernames_list en...
true
182a16781e787329a66839de09f97b5945cb5070
Ruby
jonny-gates/react-udemy-exercises
/workshops/conditional-flow/voting_age.rb
UTF-8
140
3.609375
4
[]
no_license
puts "What's your age?" age = gets.chomp.to_i if age >= 18 # code to be executed puts "You can vote!" else puts "You can't vote" end
true
3aa56fab1685d7b03e1f6fdbe8a94f95aeed24db
Ruby
csipsz/ruby-enumerables-hash-practice-nyc-pigeon-organizer-lab-atl01-seng-ft-051120
/nyc_pigeon_organizer.rb
UTF-8
458
3.0625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def nyc_pigeon_organizer(data) pigeon_list = {} data.each do |color_gender_lives, info| info.each do |info, list| list.each do |bird| if pigeon_list[bird] == nil pigeon_list[bird] = {} end if pigeon_list[bird][color_gender_lives] == nil pigeon_list[bird][color...
true
a269b7a2e904186e8b142ac87c210ed06fde3770
Ruby
bergenrb/RubyNuby
/archaic/videre-med-ruby-kurs/code/traad_mutex1.rb
ISO-8859-15
682
3.375
3
[]
no_license
## <CODE> require 'thread' $delt_teller = 0 $mutex = Mutex.new # Lag ti trder som ker den delte telleren # gradvis tjuefem ganger. traader = (1..10).collect do Thread.new do 25.times do |i| $mutex.synchronize do ### Synkronisert gammel_verdi = $delt_teller # kodebit. ...
true
384e691239c0d2387d82c6336c7c6dd3813fe518
Ruby
amitrathore/hbase-migrations
/lib/hbase_migrations/hbase_commands.rb
UTF-8
8,207
2.71875
3
[]
no_license
=begin HBASE SURGERY TOOLS: close_region Close a single region. Optionally specify regionserver. Examples: hbase> close_region 'REGIONNAME' hbase> close_region 'REGIONNAME', 'REGIONSERVER_IP:PORT' compact Compact all regions in passed ta...
true
45acca659cda3a419ef094037e48f88e1897599c
Ruby
avioli/opal
/corelib/error.rb
UTF-8
688
2.65625
3
[ "MIT" ]
permissive
class Exception def initialize(message = '') `Error.captureStackTrace(self, self.m$raise);` @message = message end def ==(*) raise NotImplementedError, 'Exception#== not yet implemented' end def backtrace @backtrace ||= `VM.backtrace(self)` end def awesome_backtrace @backtrace ||= `...
true
d8d6ca08ccae82cf6759ead9de56e72eb7e890d8
Ruby
Videmor/FundamentosRuby
/clase3/log/_ejem1.rb
UTF-8
149
3.4375
3
[]
no_license
def bienvenido(nombre) "Bienvenido #{nombre}" end puts 'Cual es tu nombre?' captura = gets.chomp resultado = bienvenido(captura) puts resultado
true
9d584dee37f684303bfb748ec47d11be4e3bc78c
Ruby
CaptainSpectacular/pos_web_app
/app/presenters/card_presenter.rb
UTF-8
195
2.578125
3
[]
no_license
class CardPresenter def initialize(card) @card = card end def name @card.name end def image @image ||= @card.image end def price @price ||= @card.price end end
true