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
66eab29484f0c57acabeaec08ee225676ef28633
Ruby
twill14/launchschool-practice-exercises
/exercise_four/say.rb
UTF-8
274
3.71875
4
[]
no_license
=begin Original def say(words) puts words end say("hello") say("goodbye") say("wazzzup!") =end # refeactored def say(words = "hello") puts words + '.' end say() say("hello") say("George") def some_method(number) number = 7 end a = 5 some_method(a) puts a
true
79d1eea2b886167d7a405d09c4a929b1caa5b87c
Ruby
strickvl/exercism
/ruby/pangram/pangram.rb
UTF-8
192
3.3125
3
[]
no_license
class Pangram def self.pangram?(string) string_chars = string.downcase.chars.select do |char| char.match(/[a-z]/) end.uniq string_chars.size == 26 ? true : false end end
true
861ca04845b50c3d3f3c607e5ec90fe2b0d9c560
Ruby
dbrock/fcshd
/lib/fcshd/logger.rb
UTF-8
461
2.90625
3
[ "MIT" ]
permissive
module FCSHD class Logger def initialize(output) @output = output end def log(message) for line in message.lines @output.puts "#{File.basename($0)}: #{line.chomp}" end end def dump(output) @output.puts output.chomp end def error(message) for line in...
true
793d29341b08c839299cb133019aed40dc20b2bb
Ruby
phsoares-ita/leetcode
/solutions/169_majority_element/spec/solution_spec.rb
UTF-8
496
3.28125
3
[]
no_license
require 'spec_helper' require 'byebug' # @param {Integer[]} nums # @return {Integer} def majority_element(nums) occurrences = {} nums.each do |num| occurrences[num] ||= 0 occurrences[num] += 1 end occurrences.max_by { |_, v| v }.first end describe 'solution' do it { expect(majority_element([10])).to...
true
1043699eb66325c74562590c35740e2ebc339036
Ruby
yunakajimayu/freemarket_sample_61c
/app/models/delivery.rb
UTF-8
1,332
2.5625
3
[]
no_license
class Delivery < ApplicationRecord belongs_to :item,optional: true validates :delivery_day,presence: true validates :postage_bearer,presence: true validates :delivery_method,presence: true validates :delivery_area,presence: true enum delivery_day: { 1〜2日で発送: 1, 2〜3日で発送: 2, 4〜7日で発送: 3 } enum ...
true
e49cbf91567a159d90cec710a4b69cc39f1de285
Ruby
kazuaking/iconik
/lib/iconik/i_tunes.rb
UTF-8
1,214
2.609375
3
[ "MIT" ]
permissive
require 'iconik/store' module Iconik class ITunes < Iconik::Store attr_reader :scraping, :country def initialize(url, scraping: false, country: nil) @scraping = scraping @url = url @country = country end def pluck_icon country_params = country ? "&country=#{country}" : "&cou...
true
4512c447198954c3f95106015bc73e0b3195718f
Ruby
x37v/composition_gallery_2014
/xnormidi.rb
UTF-8
2,081
2.8125
3
[]
no_license
class XNORMIDI def initialize @funcs = Hash.new end SYSEX_BEGIN = 0xF0 SYSEX_END = 0xF7 STATUSMASK = 0x80 CHANMASK = 0x0F CC = 0xB0 NOTEON = 0x90 NOTEOFF = 0x80 AFTERTOUCH = 0xA0 PITCHBEND = 0xE0 PROGCHANGE = 0xC0 CHANPRESSURE = 0xD0 CLOCK = 0xF8 TICK = 0xF9 START = 0xFA CONTIN...
true
4055b46114150466ff226a39869df22d8e887bfb
Ruby
indifferentalex/ian
/app/models/phrase.rb
UTF-8
14,383
2.796875
3
[]
no_license
class Phrase attr_accessor :parole, :soggetti, :predicati, :complementi, :intento, :raw, :gruppi def initialize(sentence) self.raw = sentence self.parole = [] cmd = 'echo "' + sentence + '" | /Users/alexvlasov/Code/tree-tagger/cmd/tree-tagger-italian' # /home/deployer/downloads/cmd/tree-tagger-italian-utf8' ...
true
4df94ff0b8098aa5bc48873652410e7c24c52c0c
Ruby
garyferns/object_oriented_programming
/Rover.rb
UTF-8
1,837
4.84375
5
[]
no_license
# Exercise 2 - Mars Rover!! #Gets the plateau size print "Enter plateau size: " plateau = gets.chomp.split.map {|x| x.to_i } max_x = plateau[0] max_y = plateau[1] puts "#{max_x}, #{max_y}" # Gets the initial coordinates print "Enter Initial Coordinates and Direction: " initial_coords = gets.chomp.split x = init...
true
20c0d13877402fc2090f1cbdf413bbe80588d10c
Ruby
agilous/objects-on-rails
/spec/models/post_spec.rb
UTF-8
1,056
2.578125
3
[]
no_license
require 'minitest/autorun' require_relative '../../app/models/post' describe Post do before do @it = Post.new end it "should start with blank attributes" do @it.title.must_be_nil @it.body.must_be_nil end it "should support setting attributes in the initializer" do it = Post.new(:title => "m...
true
9dec23398dd058f4b527e892dc4725001def226a
Ruby
crn-caro/cards
/test.rb
UTF-8
8,055
3.46875
3
[]
no_license
require './cards' DEBUG = true def unequal_decks(deck, expected_deck) deck.each_with_index do |card, i| return true if card != expected_deck[i] end return false end def test_round(example, deck, card_1_index, card_2_index, expected_deck, expected_deck_size, expected_card_1_index, expected_card_2_...
true
ab9f6d45641b3ba1e0b5f240b1e690b7282303bd
Ruby
shinyjiggly/terrible-game-2
/Lunatic_Nautilus/Scripts/Advanced_Weapons.rb
UTF-8
4,336
3.0625
3
[]
no_license
#============================================================================== # Advanced Weapons # By Atoa #============================================================================== # This script allows you to create an Advanced Weapon system. # You can change the status that is the base for weapon damage. # You...
true
20ea5ba058c386db4caa72766feab0ad456a778d
Ruby
Leperkhanh/ruby-instance-variables-lab-onl01-seng-pt-041320
/lib/dog.rb
UTF-8
122
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Dog def name=(input) @this_dogs_name = input end def name @this_dogs_name end end
true
ed4ffb013ecaa802faaf9892cdfde69e7619eee3
Ruby
flipsasser/maintain
/lib/maintain/backend.rb
UTF-8
2,016
2.875
3
[ "MIT" ]
permissive
require 'maintain/backend/base' module Maintain module Backend class << self def add(name, owner) classes[name.to_sym] = owner # Dig through the constant name to find if it exists modules = owner.split('::') if Object.const_defined?(modules.first) && owner = Object.const_get...
true
c2576175eeba3547305e51c5921016685b7934bc
Ruby
gavinheavyside/accumulators
/lib/accumulators/mean.rb
UTF-8
591
3.546875
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Accumulators class Mean attr_reader :count, :mean def initialize @count = 0 @mean = 0.0 end def add(rhs) if rhs.is_a? Numeric value_to_add = rhs.to_f @mean = @mean + (value_to_add - @mean)/(@count + 1) @count += 1 elsif rhs.is_a? Accumulators::...
true
fcd2c71566a9f509b5f28e4c16bb53c0691154d0
Ruby
slayzx/osmonitor
/src/osmonitor/core.rb
UTF-8
863
2.625
3
[]
no_license
class Array # define an iterator over each pair of indexes in an array def each_pair_index (0..(self.length-1)).each do |i| ((i+1)..(self.length-1 )).each do |j| yield i, j end end end # define an iterator over each pair of values in an array for ...
true
59f658e972954b37b88d6635783379fbe7462671
Ruby
sibevin/random_token
/test/get/test_seed.rb
UTF-8
2,455
2.9375
3
[ "MIT" ]
permissive
require 'minitest/autorun' require "random_token" class TestSeed < Minitest::Test def test_get_should_create_a_random_with_alphabets_only length = 10000 token = RandomToken.get(length, :seed => :a) assert_match(/^[A-Za-z]*$/, token) token = RandomToken.get(length, :seed => :alphabet) assert_match...
true
4cd4389bb4473f079cb35beafde67e168979e3b5
Ruby
terunrun/RailsTutorial
/test/integration/users_login_test.rb
UTF-8
3,497
2.625
3
[]
no_license
require 'test_helper' class UsersLoginTest < ActionDispatch::IntegrationTest # 8.2.4 テスト用ユーザーをfixture(user.yml)より設定 def setup @user = users(:michael) end # 無効なログイン情報でログインし、正しい画面が表示されているかをテスト test "login with invalid information" do get login_path assert_template 'sessions/new' # ログイン画面へPOSTア...
true
0f190b100c0da6bafc18f07302720fda98322e64
Ruby
DiwthL83/ruby-toy__find-only-unique-elements
/lib/unique_elements.rb
UTF-8
416
3.859375
4
[]
no_license
# This method takes an array of elements (these might be strings, integers, floats, or a # combination of the above), and returns an array of the elements that appear once and only # once. def find_unique_elements(arr) counts = Hash.new 0 arr.each do |ele| counts[ele] += 1 end counts.delete_if {|key, value| val...
true
ba6e27c435a30bf9a53aa17a7bd9bb4920a2f01d
Ruby
tkentt/stardew_toolkit
/app/helpers/calendars_helper.rb
UTF-8
203
2.96875
3
[]
no_license
module CalendarsHelper def year(day) 1 + day / 112 end def season(day) case day % 112 when 1..28 "Spring" when 29..56 "Summer" when 57..84 "Fall" else "Winter" end end end
true
8264ab1500d549f3dd7b819daa608a39a7f691a5
Ruby
eddy-luque/ProyectoFinalUPC
/Controller/ControllerAlumno.rb
UTF-8
1,364
2.578125
3
[]
no_license
require_relative '../Factory/FactoryPreguntaConRespuesta' require_relative '../Factory/FactoryExamen' require_relative '../Factory/FactoryAlternativa' class ControllerAlumno attr_accessor :vista, :modelo, :modeloAdm def initialize(vista, modelo, modeloAdm) @vista, @modelo, @modeloAdm = vista, modelo, modeloAdm end...
true
3bea99d3ae6a3b5f56ce590b964093f2891d3410
Ruby
enova/trende
/app/models/location.rb
UTF-8
750
2.78125
3
[ "MIT" ]
permissive
class Location < ActiveRecord::Base attr_accessible :city, :lat, :long has_many :events def self.bound_lat(south, north) where(:lat => south..north) end def self.bound_long(west, east) if (west.to_f>east.to_f) where("long > ? or long < ?",west,east) else where(:long => west..east) ...
true
07b6c3fdd307e1f54a97875261f9d5c2ad3931f5
Ruby
juanlb/cuento_tengo
/lib/c_t_functions.rb
UTF-8
2,739
2.671875
3
[]
no_license
# To change this template, choose Tools | Templates # and open the template in the editor. class CTFunctions def self.get_date_since_mes_actual mes = DateTime.strptime("28-#{Time.now.month}-#{Time.now.year}", "%d-%m-%Y").beginning_of_month + 35 val = mes.beginning_of_month cond = " AND (created_at < ?) ...
true
725e7d9e4db6b83ac8b00ee518e6031684559e6c
Ruby
Madh93/codewars_rb
/spec/lib/kata/kyu7/you_are_a_square_spec.rb
UTF-8
363
2.71875
3
[ "MIT" ]
permissive
require 'spec_helper' describe Kata::Kyu7 do it 'Really is a square of squares?' do Kata::Kyu7.you_are_a_square(-1).must_equal(false) Kata::Kyu7.you_are_a_square(3).must_equal(false) Kata::Kyu7.you_are_a_square(4).must_equal(true) Kata::Kyu7.you_are_a_square(25).must_equal(true) Kata::Kyu7.you_ar...
true
4c3b05f240ee25dd9dbd136993810be9b35d1763
Ruby
dingtianyang/hw-ruby-intro
/lib/ruby_intro.rb
UTF-8
1,599
3.953125
4
[]
no_license
# When done, submit this entire file to the autograder. # Part 1 def sum arr ans = 0; arr.each { |num| ans += num; } return ans; end def max_2_sum arr if arr.size == 0 return 0 elsif arr.size == 1 return arr[0] else max = -Float::INFINITY secMax = ...
true
1ec7df0e214aa4ee532ccb87c60115ba0a85d5bd
Ruby
mgn200/imdb_playfield
/lib/imdb_playfield/new_movie.rb
UTF-8
365
2.953125
3
[]
no_license
module ImdbPlayfield # Class for movies that were made in 2000 or after. # @see MovieCollection#parse_file class NewMovie < ImdbPlayfield::Movie # @return [String] title and amount of years passed def to_s years_passed = Date.today.year - @year "#{@title} - новинка, вышло #{years_passed} лет н...
true
2437d9284983bfb3b58db0de1c45b2bc66d8be9c
Ruby
jrobertson/novowels
/lib/novowels.rb
UTF-8
183
3.109375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # file: novowels.rb class NoVowels def self.compact(s) s.gsub(/(\B)(\w+)(\B)/) do |x| "%s%s%s" % [$1,($2).gsub(/[aeiou]/i,''),$3] end end end
true
75614d020b272e2f30eeac3418c2bf0167f6e197
Ruby
ralphreid/WDI_LDN_3_Work
/ralphreid/w2d1/classwork/exceptions/examples/example_5.rb
UTF-8
590
3.5
4
[]
no_license
require 'rainbow' #get the path to our file filename = File.dirname(__FILE__) + '/file_parsing/data.csv' #open a file handle f = File.open filename puts "opened file handle for #{filename}" begin puts "doing some (potentially buggy) processing on #{filename}" f.readlines.count / 0 # this is just stupid.....our mi...
true
910d0a2c48e1b8dab7aa84b9d28ed942aefaf38b
Ruby
Mjle/appacademyprep
/Homework/test-first-ruby/lib/08_book_titles.rb
UTF-8
721
3.390625
3
[]
no_license
# Michael Le @ le.michael6@gmail.com # 08_book_titles.rb # use respective spec.rb to see success/ failures in code # can be found in /spec/ # # bundle exec rspec spec/08_book_titles_spec.rb # class Book attr_reader :title def title=(some_title) little_words = ["in", "an", "yet", "for", "or", "so", "and", "...
true
7b6a640b79617a7303739911a5849779f19e8f85
Ruby
amanzan1/hotel
/lib/administrator.rb
UTF-8
1,771
3.8125
4
[]
no_license
class Administrator attr_reader :room, :reservations,:list_rooms def initialize() @guests = [] #list_rooms in an array of room instances @list_rooms = [] #reservations is an array of reservation instances @reservations = [] for i in 0..19 @list_rooms.push(Room.new({number: i ...
true
50cc45352ba5175bece869d8532e12e4d825285f
Ruby
RyanMacG/tic-tac-toe
/lib/game.rb
UTF-8
211
2.96875
3
[]
no_license
class Game attr_reader :players, :last_player def initialize @players = { player_1: { marker: 'x' }, player_2: { marker: 'o'} } @last_player = nil end def current_player :player_1 end end
true
303309c916e683c6bad3c9e5e19ac3807736485a
Ruby
amckemie/algorithms
/sorting/spec/sort_spec.rb
UTF-8
2,468
3.421875
3
[]
no_license
require 'rubygems' require 'rspec' require_relative '../sort.rb' describe 'Sort' do describe '.selection_sort' do context 'when the argument is empty' do it "returns an empty array" do expect(Sort.selection_sort([])).to eq([]) end end context 'when negative numbers are included' do ...
true
9e14d8c6d3a1c788243407ca4e22ca6e1a5844da
Ruby
jhallbachner/magic-search-engine
/lib/card.rb
UTF-8
4,210
2.703125
3
[]
no_license
# This class represents card from index point of view, not from data point of view # (thinking in solr/lucene terms) require "date" require_relative "ban_list" class Card attr_reader :data, :printings attr_writer :printings # For db subset attr_reader :name, :names, :layout, :colors, :mana_cost, :reserved, :typ...
true
71cea383447e9ca18a49a7d5d1e49c6bf6cc58fd
Ruby
percyliang/sempre
/pull-dependencies
UTF-8
14,691
2.609375
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby # SEMPRE depends on several library/data files into |lib|. Run this script to # copy those dependencies to your local directory. This allows you to run # SEMPRE from anywhere. This file consists of a set of modules (which loosely # correspond to the code modules). # # The master copy of these de...
true
4c5edab068a22ca9c5c82e94b7524816112b9e73
Ruby
StefanoPruna/Ruby
/fibonacci.rb
UTF-8
320
3.84375
4
[]
no_license
def nth_fibonacci(count) # Your code goes here n = 0 m = 1 x = 0 if count > 0 while x < (count-1) do #puts n n, m = m, n + m x += 1 end else puts "Please enter a positive integer" end puts n #return n end nth_fibonacci(15)
true
fb6567374f25bb8f535fd4d9cc9e5c042bba1688
Ruby
johnboyes/hotcustard-payments
/sinatra/hcmoney_helper.rb
UTF-8
790
2.625
3
[]
no_license
require 'sinatra/base' # Extending the main Sinatra module module Sinatra # Sinatra helper class module HCMoneyHelper def current_user !session[:facebook_name].nil? end def might_pay_in_aus?(person) australia_payers.include? person end def number_of_payment_items_for(transaction) ...
true
bae416e5639a2cbb4577d9a4cd20f728d46fa0fb
Ruby
alexamy/thinknetica-ror
/basics/03_basics_part_2/6_purchases.rb
UTF-8
725
3.578125
4
[]
no_license
purchases = {} loop do print 'Enter product label: ' label = gets.chomp.to_sym break if label == :стоп print 'Enter unit price: ' unit_price = gets.chomp.to_f print 'Enter product quantity: ' quantity = gets.chomp.to_f if purchases[label].nil? purchases[label] = { unit_price: unit_price, quanti...
true
25851a4d7f4810db39b3ffa8b99d5b4aaac09177
Ruby
trample/JBS_2012_Homework
/W2/L2/regexp_test.rb
UTF-8
444
3.1875
3
[]
no_license
puts "enter a line: " line = "my phone number is 9969259" cell = line[/\d+[\s\d-]+/] if cell != nil if cell.size > 6 puts "the line contains valid US phone number:" puts "the number: "+cell end end cosnum = line[/\w+\s\d+[abj]+/] if cosnum != nil puts "the line contains a Brandeis Course Number: " puts "Cour...
true
7e693f78394b02a3c439d54a7d1c7a6da3d0dce3
Ruby
cheryljensen/array-CRUD-lab-onl01-seng-pt-070620
/lib/array_crud.rb
UTF-8
827
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def create_an_empty_array [] end def create_an_array planets = ["Mercury", "Venus", "Earth", "Mars"] end def add_element_to_end_of_array(array, element) planets = ["Mercury", "Venus", "Earth", "Mars"] planets << "arrays!" end def add_element_to_start_of_array(array, element) planets = ["Mercury", "Venus", ...
true
b409310e2fe438ad7bf1ca33dddb50e185d2a570
Ruby
RyanRiddle/rudb
/lib/transaction/commit_log.rb
UTF-8
2,384
3.078125
3
[]
no_license
class INVALID end class IN_PROGRESS def self.do_the_needful actives, id actives.push id end end class COMMITTED def self.do_the_needful actives, id actives.delete id end end class ABORTED def self.do_the_needful actives, id actives.delete id end end class CommitLog ...
true
b705b2d1d9f019abf4493d3f8c89ba28b181d2a0
Ruby
loganmeetsworld/advent-of-code
/2016/day-20/solution.rb
UTF-8
410
2.828125
3
[]
no_license
input = File.open("./input.txt").read.split("\n").map{|x| [x.split('-')[0].to_i, x.split('-')[1].to_i]}.sort_by{|x| x[0]} last_max = input[0][1] last_min = input[1][0] input.each_with_index do |x, i| if last_min - last_max >= 2 puts 'Part 1: ' + (last_min - 1).to_s break end last_max = input[i][1] las...
true
dbb4884a52b0619be956f0aafb28a0b8c208075f
Ruby
drewkles/Inscribed-Polygon
/main.rb
UTF-8
808
3.40625
3
[]
no_license
# Inscribed Polygon Calculator # by Andrew Elkins require 'sinatra' class IPcalculator attr_accessor :solved, :num_sides, :side_length def initialize(num_sides) @num_sides = num_sides.to_i calculate end # Formula for side (2 * cos[((n-2)* pi)/ (2 * n)] def side_length top = (@num_sides - 2) * Math::PI a...
true
e8eb6b7088294888bc6db08044ca3be8ef8002fe
Ruby
ramigg/arvut_system
/app/models/cache.rb
UTF-8
962
3.140625
3
[ "MIT" ]
permissive
# This is generic cache mechanism to store and retrieve data from DB # Each entry is described using the following fields: # * content_type - (string) describes model/class/kind of an object # * content_uid - (string) unique ID of an entry # * language_id - (numeric) ID of a language the entry belongs to # Content...
true
95282b58e98950356a95cf66f98753395914b661
Ruby
andy139/aa_classwork
/W4D4/poker_project/lib/deck.rb
UTF-8
296
3.25
3
[]
no_license
require_relative 'card.rb' class Deck SUITS = ["H","S","C","D"] def self.add cards = [] (1..13).each do |num| SUITS.each do |suit| cards << Card.new(num, suit) end end cards end attr_reader :cards def initialize @cards = Deck.add end end
true
183f9bc59db0c93ebdad6c886f65620b0729064c
Ruby
julia-terry/Ruby
/ArraySums.rb
UTF-8
952
4.21875
4
[]
no_license
#function to find the sum of all the numbers in arr def sum arr arrSum = 0 for x in arr arrSum+=x end return arrSum end #function to find the sum of an arr with 0, 1, or 2 numbers in it def max_2_sum arr larSum = 0 if arr.length == 0 larSum = 0 elsif arr.length == 1 larSum = arr[0] else ...
true
4d072cfccb6eaa155a4d8a0f07cd8de56bec0e5d
Ruby
alu0100606171/prct07
/spec/fraccion_spec.rb
UTF-8
3,564
3.4375
3
[]
no_license
# File: fraccion_spec.rb require "fraccion.rb" describe Fraccion do before :each do @frac = Fraccion.new(1,2) end it "Debe existir un numerador" do @frac.num.should eq(1) end it "Debe existir un denominador" do @frac.den.should eq(2) end it "Debe de estar en su ...
true
32abae2ba94201bb916a3d85563b315f4775e717
Ruby
joshleichtung/phase-0-tracks
/ruby/iteration_drill.rb
UTF-8
5,694
3.5
4
[]
no_license
# Array Drills zombie_apocalypse_supplies = ["hatchet", "rations", "water jug", "binoculars", "shotgun", "compass", "CB radio", "batteries"] # 1. Iterate through the zombie_apocalypse_supplies array, # printing each item in the array separated by an asterisk # ---- zombie_apocalypse_sup...
true
54a721ca1af3028cc4cbefa69c4a9322203fcf53
Ruby
scriberty/calcentral
/app/models/calendar/queued_entry.rb
UTF-8
4,174
2.640625
3
[ "LicenseRef-scancode-warranty-disclaimer", "ECL-2.0" ]
permissive
module Calendar class QueuedEntry < ActiveRecord::Base CREATE_TRANSACTION = 'C' UPDATE_TRANSACTION = 'U' DELETE_TRANSACTION = 'D' self.table_name = 'class_calendar_queue' attr_accessible :year, :term_cd, :ccn, :multi_entry_cd, :event_data, :event_id, :transaction_type # Transient attribute...
true
5d121e13a276c61eb05c1805e2509269c29a55da
Ruby
jonmorehouse/backlog
/lib/backlog/archive.rb
UTF-8
864
2.953125
3
[]
no_license
require 'chronic' module Backlog class Archive def initialize(args, date) @args = args @date = date end def execute! # our cli parser will always try to guess a legitimate date if @date == nil or @date.date == Date.today archive_all else ar...
true
04683657b48227b85bbbb19d8abb249d8c857e1a
Ruby
stephancom/battleship
/spec/grid_spec.rb
UTF-8
6,196
2.75
3
[ "MIT" ]
permissive
RSpec.describe Grid do describe 'creating a grid' do it 'should create 10x10=100 new Cells' do expect(Cell).to receive(:new).exactly(100).times.and_call_original Grid.new end end describe 'the grid' do let(:coords) { ('A'..'J').to_a.product((1..10).to_a).map(&:join).map { |str| Coordinate....
true
9627e442197565644bdd14fc031ce32df72bfbb0
Ruby
EdenServers/minecraft-jsonapi
/test/test_minecraft-jsonapi.rb
UTF-8
1,094
2.78125
3
[ "MIT" ]
permissive
require 'test/unit' require 'minecraft-jsonapi' class MinecraftJSONAPITest < Test::Unit::TestCase def api @api ||= Minecraft::JSONAPI.new(username: "admin", password: "12345", salt: "mmm") end def test_create_new_shortcut assert_equal Minecraft::JSONAPI::JSONAPI, api.class end def test_map_to_array assert...
true
0a1794d458bc8f397f698188a150c72f17095986
Ruby
stephenh71/Week2_Day1_Homework
/Part_B/specs/Part_B_spec.rb
UTF-8
1,057
3.09375
3
[]
no_license
require ('minitest/autorun') require ('minitest/rg') require_relative ('../Part_B') class TestTeam < Minitest::Test def setup @team = Team.new("Ayr United",["John","Bob"],"Ian McCall", 0) end def test_name result = @team.name() assert_equal("Ayr United", result) end def test_players result = @team.pla...
true
7044d66586d5d9200cb207ddd86afaf3b5f69640
Ruby
think41c/exercism_ruby_accumulate
/accumulate.rb
UTF-8
167
2.9375
3
[]
no_license
class Array def accumulate accumulator = [] each do |user_array_element| accumulator << yield(user_array_element) end accumulator end end
true
9fce40201cf9330027c0ea7b9e6061d86098bd03
Ruby
derrick-long/Launch_Projects
/fizz-buzz/geometry_greeting/geometry_greeting.rb
UTF-8
323
4
4
[]
no_license
def greeting(name, language = nil) random_greetings = ["Hi", "Yo", "Salutations", "Howdy"] if language == 'spanish' puts "Hola #{name}!" elsif language == 'italian' puts "Ciao #{name}" elsif language == 'french' puts "Bonjour #{name}!" else puts "#{random_greetings.sample} #{name}!" end e...
true
31f254cdd066d663ee0d4a866d1030d984c36249
Ruby
SuperLazyDog/Algorithm-Practise
/Test/paiza/a011.rb
UTF-8
1,087
3
3
[]
no_license
lines = readlines @d, @count = lines.shift.split(' ').map { |i| i.to_i } @steps = lines.map { |l| l.to_i } @path = [] def get_path(steps, path=[], i=0, cur=0) # puts "steps: #{steps}, cur: #{cur}, path: #{path.to_s}, i: #{i}, steps[i]: #{steps[i]}" if i >= steps.count if cur <= @d && cur >= -@d # puts pa...
true
237e812c96daf2be94ac078a754091d4d98f7d8a
Ruby
addisoncole/hotel
/lib/room.rb
UTF-8
180
2.65625
3
[]
no_license
module Hotel class Room attr_reader :room_number, :reservations def initialize(room_number) @room_number = room_number @reservations = [] end end end
true
bdd22e2a5f5cc168bf2099eed4a016cca56dd0ca
Ruby
Overseer009/TwO-O-Player_Math_Game
/questions.rb
UTF-8
201
3.578125
4
[]
no_license
class Question def initialize @num1 = rand(1...20) @num2 = rand(1...20) end def equation "what does #{@num1} plus #{@num2} equal?" end def result @num1 + @num2 end end
true
683147f389c075f03e4d9bcd91d53abfdd2bbf93
Ruby
jalquisola/conic
/spec/lib/dailymile_spec.rb
UTF-8
4,112
2.703125
3
[ "MIT" ]
permissive
require "spec_helper" require "dailymile" describe Dailymile, "create_msg" do it "returns json message for dailymile api - run" do s = Dailymile.create_entry("run 2km 15mins good sample message") s["message"].should eq("sample message") s["workout"]["activity_type"].should eq("running") s["workout"]...
true
fbfc1124bddb0626115d1e6043dab74bfcf85cc4
Ruby
Lippins/ruby_building_blocks
/substrings.rb
UTF-8
434
3.734375
4
[]
no_license
def substrings(text, array) result = Hash.new array.each do |word| if text.downcase.include?(word.downcase) result[word] = text.downcase.scan(word.downcase).count end end result end dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partne...
true
ff3b04e8f60e4b70ddec7f63fce4cb369ec3e1e9
Ruby
ivana/smokefreebars
/app/models/foursquare_location_sync.rb
UTF-8
846
2.78125
3
[]
no_license
class FoursquareLocationSync attr_reader :fsq_locations, :location_model def initialize fsq_locations, location_model @fsq_locations = fsq_locations @location_model = location_model end def sync! add_missing_locations delete_stale_locations end private def add_missing_locations ex...
true
b25aaa6f92083cd440575e2cff06d91a5f778155
Ruby
YanezDiego/ruby-collaborating-objects-lab-v-000
/lib/song.rb
UTF-8
347
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_accessor :name, :artist def initialize(name) @name = name end def self.new_by_filename(file_name) song_file = file_name.split (" - ") song = self.new(song_file[1]) artist = Artist.find_or_create_by_name(song_file[0]) song.artist = artist artist.add_song(...
true
82c4e22762fdf2e8df504d92e0f8e5c42c7b65e3
Ruby
smartlyio/heaven
/app/receivers/lock_receiver.rb
UTF-8
936
2.6875
3
[ "MIT" ]
permissive
# A class to handle incoming lock/unlock webhooks class LockReceiver attr_reader :data def initialize(data) @data = data end def run! if locker.lock? Resque.enqueue(Heaven::Jobs::EnvironmentLock, lock_params) elsif locker.unlock? Resque.enqueue(Heaven::Jobs::EnvironmentUnlock, lock_par...
true
5bd721dbe3daaf23815f279cba94ce966e4ae1f0
Ruby
fgoll/learn
/compilers/ruby/syntactic-analysis.rb
UTF-8
5,708
3.46875
3
[]
no_license
# 语法分析 # lexical class LexicalAnalyzer < Struct.new(:string) GRAMMAR = [ { token: 'i', pattern: /if/ }, # if 关键字 { token: 'e', pattern: /else/ }, # else 关键字 { token: 'w', pattern: /while/ }, # while 关键字 { token: 'd', pattern: /do-nothing/ }, # do-nothing 关键字 { token: '(', pattern: /\(/ }, # 左...
true
9165bfa617e9e6e70419d99c721256087d412bc6
Ruby
randypiper/gax-ruby
/lib/google/gax/configuration/derived.rb
UTF-8
5,540
2.578125
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Copyright 2019, Google LLC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the fo...
true
f36c2fbcf9084f1b5d1841895eecb59d1f579c40
Ruby
valetedo/applicazioni-web-2012
/Lezione09.risolto/tuitter/app/models/category.rb
UTF-8
345
2.734375
3
[]
no_license
class Category < ActiveRecord::Base attr_accessible :name def to_s self.name end def Category.find_or_create_by_name(name) category = Category.find_by_name(name) if !category category = Category.create!(:name => name) end end def find_by_name(name) Category.where("name = ?...
true
d6df5baebd1d8714726627c4caa02747412c62e6
Ruby
Brayan9105/Ruby
/algorithms/codewars/8kyu/AreaOrPerimeter.rb
UTF-8
582
4.3125
4
[]
no_license
=begin You are given the length and width of a 4-sided polygon. The polygon can either be a rectangle or a square. If it is a square, return its area. If it is a rectangle, return its perimeter. area_or_perimeter(6, 10) --> 32 area_or_perimeter(4, 4) --> 16 Note: for the purposes of this kata you will a...
true
31a7e9bf1c4a14ab9f2099ab35f7fbdfae30839d
Ruby
jesperronn/faker_extension_da
/lib/faker_da/phone_number.rb
UTF-8
416
2.65625
3
[ "MIT" ]
permissive
module Faker class PhoneNumber class << self def da_phone_number Faker.numerify(Phone_formats.rand) end def da_cellphone_number Faker.numerify(Cellphone_formats.rand) end end Phone_formats = [ '3### ####', '4### ####', '6### ####', ...
true
aa87b1d5618dc2bb075c9499467476920b64e43c
Ruby
juliend2/joplin-to-gephi
/main.rb
UTF-8
1,677
2.78125
3
[]
no_license
require 'sqlite3' require 'sequel' require 'pp' DB = Sequel.sqlite("#{ENV['HOME']}/.config/joplin-desktop/database.sqlite") ds = DB[<<-EOSQL] SELECT * FROM notes EOSQL def xml(nodes, edges) edge_id = -1 <<-EOXML <?xml version="1.0" encoding="UTF-8"?> <gexf xmlns="http://www.gexf.net/1.2draft" version="1.2"> ...
true
9af5bcbc0a65d820f884db403cf92503a1ac8516
Ruby
ChrisHarte/dotfiles
/.irbrc
UTF-8
5,668
2.59375
3
[]
no_license
#!/usr/bin/ruby # load libraries require 'rubygems' rescue nil require 'wirble' require 'irb/completion' require 'irb/ext/save-history' alias q exit class Object # list methods which aren't in superclass def local_methods(obj = self) (obj.methods - obj.class.superclass.instance_methods).sort end end IRB....
true
4e98142073ae8eb286ff0c7b86e1c2bf6f568b8f
Ruby
bossiernesto/miniCurl
/src/test.rb
UTF-8
53
2.515625
3
[ "BSD-3-Clause" ]
permissive
puts ARGV.length ARGV.each do |a| puts a end exit
true
2c766caba0836e521dd7f90f649d58b700e2132b
Ruby
hatappi/rails-red-chainer
/app/models/red_chainer/log.rb
UTF-8
462
2.75
3
[]
no_license
module RedChainer class Log < Struct.new(:epoch, :iteration, :main_loss, :main_accuracy, :elapsed_time) def self.parse(row) self.new(row['epoch'], row['iteration'], row['main/loss'], row['main/accuracy'], row['elapsed_time']) end def self....
true
5012c1d1ab948d879b2e0e37de18002e72c607ba
Ruby
Najaf/alis-jekyll-plugins
/generators/archive.rb
UTF-8
1,255
2.640625
3
[]
no_license
module NajafAliGenerators class ArchivePage < Jekyll::Page def initialize(site, posts, periods) @layout = 'archive' @site = site @posts = posts @dir = '' @name = 'archive.html' @url = @name @periods = periods halt_on_layout_error unless layout_available? end ...
true
a0cc8eda11fa5ef142dcf33a541ebd3faf622d29
Ruby
Manoj5ingh/crop_management
/lib/address/state.rb
UTF-8
709
3.34375
3
[]
no_license
require 'address/district.rb' module Address class State attr :name, :districts def initialize(name, districts=Set.new) @name = @name @districts = Hash.new districts.each do |district| @districts[district.name] = district end end def insert_district(district_name) ...
true
15847e7bf3f442189667c514e4637e661419ea01
Ruby
quinHD/IronHack
/2-TDD/CheckSpellOut/CheckSpellOut.rb
UTF-8
2,465
3.71875
4
[]
no_license
class CheckSpellOut def initialize @to_19_array=[ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "teen", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eigteen", "nineteen" ] @to_tens_...
true
71cd3033af6026f1f2caf6f5cd58262babce96be
Ruby
paulieborg/toy_robot
/lib/report.rb
UTF-8
210
3.078125
3
[]
no_license
class Report def execute(state) current_location = state.location current_direction = state.direction puts "Output: #{current_location[:x]},#{current_location[:y]},#{current_direction}" end end
true
f17ab9e158d53f3081c9b17bfa3a9346f4547bd9
Ruby
Jarrod-Alford/Introduction_to_Programming
/Hashes/print_keys.rb
UTF-8
123
3.0625
3
[]
no_license
this_hash = {first: 'a', second: 'b', third: 'c'} this_hash.each { |key, val| puts key } #Or... puts puts this_hash.keys
true
e232ea330a1f0e543511c9d831e1c8d44e46567e
Ruby
CDacres/ruby_tdd_unit_testing
/project_euler/problem_1/problem_1.rb
UTF-8
584
3.625
4
[]
no_license
class EulerProblem1 attr_accessor :prob1_array def initialize @prob1_array = [] end def divisible_by?(num1, number_divisible_by) num1 % number_divisible_by == 0 end def iterator(range_from, range_to) (range_from...range_to).each do |i| if divisible_by?(i, 3) == true @prob1_arra...
true
16914f116eac0655b2307ca4d72e3a981473da49
Ruby
amandeep1420/ruby-basics-exercises
/11_arrays/9_fn_p2.rb
UTF-8
263
3.484375
3
[]
no_license
# my answer: favorites = [['Dave', 7], ['Miranda', 3], ['Jason', 11]] p favorites.flatten # 100% correct - they just assigned the flatten to a new variable and printed that variable. # remember, flatten! can be used to modify the original array if so desired.
true
3ec607e0949c17e4e9d8df9f24ea0c53c505d034
Ruby
ChrisMaddock/api-md-to-xml
/prog.rb
UTF-8
2,649
2.828125
3
[]
no_license
require 'nokogiri' require 'cgi' require 'net/http' require 'uri' require 'final_redirect_url' def resolveLinks(captures) if captures.length > 3 puts "more than one link" end title = captures[1] link = captures[2] if title.start_with?("!INCLUDE") return nil end # Redirec...
true
39f644ab56ca8b3fa42c97abe8fb7d4d4ab74a6f
Ruby
itsmekhanh/leetcode
/can_win_nim.rb
UTF-8
270
3.734375
4
[]
no_license
#can_win_nim(n) - determine whether or not you can win the game of nim given the #number of stones. You will always pick first. def can_win_nim(n) if n < 4 return true end target = n-4 return !(target % 2 == 0 || target % 3 == 0 || target % 5 == 0) end
true
b3c8224539757591932450d987a216cb5e2aea02
Ruby
a-thom/advent-of-code
/2018/day02/spec.rb
UTF-8
620
2.96875
3
[]
no_license
# frozen_string_literal: true require_relative 'solution.rb' describe 'calculate_checksum' do it 'returns product of double and triple string counts' do result = calculate_checksum(%w[ababa aaabbb cdcdx asdjx]) expect(result).to eq(4) end end describe 'find_winner' do it 'returns the matching part of ...
true
d3182f631f15af57fdd9fac540adf99002f7f636
Ruby
dlangsam/Ironhack
/Week1/SharingBehavior/lib/vehicles.rb
UTF-8
373
3.328125
3
[]
no_license
class Car def initialize @wheels = 4 end def make_sound puts "Vroom vroom" end def count_wheels @wheels end end class Ship def initialize @wheels = 0 end def make_sound puts "Hoooonk hooonk" end def count_wheels @wheels end end class Bike def initialize @wheels = 2 end def make_sound pu...
true
0fd5acf5d3d9779c3b802dd4d90f2e6b8821800c
Ruby
ramf/Codecademy
/ruby/3. Looping with Ruby/6.redacted/e.control.flow.rb
UTF-8
888
4.40625
4
[]
no_license
=begin Control Flow Know-How Good! There were two problems with our output, though: we didn't have spaces between our words, and our program didn't actually replace the word we wanted to redact with the word "REDACTED". if var == 10 print "Variable is 10" else print "Variable is something else" end We can fix...
true
223ebbdaeead70ebc0d9dad7c3ae4cfffe265fa3
Ruby
RiverGlide/sample_app_2nd_ed
/features/support/sampleapp/advisor.rb
UTF-8
463
3.1875
3
[]
no_license
module SampleApp class Advisor def initialize from_advisories @from_advisories = from_advisories end def list_of problems problems.split ', ' end def number_of problems list_of(problems).size end def advice_for problems advisories = list_of(problems).inject([]) ...
true
c4923d9d3174e234b7c6566de76595af77b0c615
Ruby
castor4bit/leetcode
/contests/Weekly_Contest_174/5328.The_K_Weakest_Rows_in_a_Matrix/test_5328.rb
UTF-8
585
2.765625
3
[]
no_license
require 'test/unit' require './5328' class LeetCodeSolutionTest < Test::Unit::TestCase def test_5328 mat = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]] k = 3 assert_equal [2, 0, 3], k_weakest_rows(mat, k) mat = [[1, 0, ...
true
ca742d3cd8a17c0b03d050fb3c9f583e825b678a
Ruby
albertbahia/wdi_june_2014
/w03/d02/ranjan_agarwal/poke_hw/lib/trainer.rb
UTF-8
323
2.859375
3
[]
no_license
require_relative('./pokemon.rb') class Trainer < ActiveRecord::Base has_and_belongs_to_many :pokemon def whos_that_trainer "ID: #{id} Name: #{name} Ages: #{age} Hometown: #{hometown}." end def choose_pokemon selected_pokemon.each { |pokemon| self.pokemons << pokemon } if self.pokemons.count < 6 end e...
true
9a06f09422197448dd82cb8b3090ba117dcd223b
Ruby
yumojin/Example-Sketches
/samples/processing_app/topics/animation/animated_sprite.rb
UTF-8
1,398
3.421875
3
[ "MIT" ]
permissive
# # Animated Sprite (Shifty + Teddy) # by James Paterson, rubified by Martin Prout. # # Hold down the mouse button to change animations. # Demonstrates loading, displaying, and animating GIF images. # It would be easy to write a program to display # animated GIFs, but would not allow as much control over # the display ...
true
cb27771c9ab969144349661ed4b8fbdc566380fe
Ruby
damyvv/Advent-of-code-2019
/challenge6/main.rb
UTF-8
785
3.234375
3
[]
no_license
require './aoc_input' include AOCInput orbits = {} INPUT.each { |orbit| orbits.merge!([orbit.split(')').reverse].to_h) } numOrbits = 0 orbits.each_pair do |key, value| while orbits.has_key?(key) key = value value = orbits[key] numOrbits += 1 end end transfers_needed = 0 you = orbits...
true
b6b0b731378b5a2c21ac71f9001b20eae3ea7a5d
Ruby
mjvsha/collections-iteration
/ex7.rb
UTF-8
1,808
4.3125
4
[]
no_license
#Output the message "I will not skateboard in the halls" 20 times. #HIGHLIGHT AND COMMAND Q MARK IN ORDER TO COMMENT IT OUT 20.times do puts "I will not skateboard in the halls" end skateboard = [] =begin skateboard = 20.times do puts "I will not skateboard in the halls" end puts skateboard =end #^^^ HOW COME THAT D...
true
c01d1a8291f1f78e3e01996515be2e260542adda
Ruby
CSalois114/project_knight_moves
/knight_moves.rb
UTF-8
1,519
3.765625
4
[]
no_license
class Square attr_accessor :children, :parent attr_reader :coord def initialize(coord) @coord = coord @children = [] @parent = nil end end class Board attr_reader :squares_hash def initialize @squares_hash = {} (1..8).each {|x| (1..8).each {|y| squares_hash[[x,y]] = Square.new([x, y]...
true
e358e4257a20a4a4bb60ab9d370e06c6daeb1b7c
Ruby
NullVoxPopuli/authorizable
/lib/authorizable/model.rb
UTF-8
1,210
2.640625
3
[ "MIT" ]
permissive
module Authorizable # this should be included on the 'User' model or whatever # is going to be performing action that need to be # authorized module Model extend ActiveSupport::Concern included do # set up our access to the permission checking after_initialize :permission_proxy end ...
true
a2aec08aad44f8ad4f1cc2a5f24b245385b59185
Ruby
prasetiady/practice
/hackerrank/algorithms/implementation/save_the_prisoner.rb
UTF-8
157
2.875
3
[]
no_license
T = gets.to_i T.times do |t_i| n,m,s = gets.strip.split.map(&:to_i) m += s - 1 if m > n m = (m%(n)) end if m == 0 m = n end puts m end
true
3b6e193ddde86db80390e6964b531a0d4ba6ba77
Ruby
Marcodredd/Small_Problems_Exercise
/double_doubles.rb
UTF-8
829
4.4375
4
[]
no_license
# A double number is a number with an even number of digits whose left-side digits are exactly # the same as its right-side digits. For example, 44, 3333, 103103, 7676 are all double numbers. # 444, 334433, and 107 are not. # Write a method that returns 2 times the number provided as an argument, unless the argument...
true
46de63a2420222f78c63fc349bcce4118b3e8333
Ruby
shun713/task_2-5
/lesson5.rb
UTF-8
65
2.796875
3
[]
no_license
subjects = ["国語","数学","理科","社会"] puts subjects[2]
true
93f7a70f3b79c335ab32e9f572934ec1e4830c92
Ruby
aleksacastle/lu-air
/app/controllers/scrapers_controller.rb
UTF-8
609
2.515625
3
[]
no_license
class ScrapersController < ApplicationController def new @scraper = Scraper.new end def create @scraper = Scraper.new(scraper_params) airbnb_price(@scraper) render "show" end private def airbnb_price(scraper) airbnb = scraper.get_airbnb @airbnb_price = airbnb[:price] @c...
true
f835ba662cd49afc785a155c489d4094b5dcf339
Ruby
JoeStanton/baseline-agent
/bin/runner.rb
UTF-8
886
2.890625
3
[]
no_license
require_relative '../commands/main' class Runner # Allow everything fun to be injected from the outside while defaulting to normal implementations. def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kerne...
true
ad92b6731f537bdb51927f3ae8479f788c98ea3b
Ruby
GuillermoRegodon/rubygem-metronome-odd
/lib/metronome-odd/parse_line.rb
UTF-8
785
2.796875
3
[]
no_license
module ParseLine class Line @@line_regexp_hash = nil @help = false def remove_separators @line = @line.gsub(/\s+/, "") end def initialize(line) if @@line_regexp_hash.nil? @@line_regexp_hash = Hash.new([/^$/,/^$/]) end @line = line end def Line.add_command...
true
f688f0dd76dff42a7732ec4f5840c62108eaee46
Ruby
harrystech/kontrast
/lib/kontrast/page_test.rb
UTF-8
856
2.625
3
[ "MIT" ]
permissive
require 'uri' require 'rack' module Kontrast class PageTest < Test attr_reader :width, :url_params def initialize(prefix, name, path, headers: {}, url_params: {}) super(prefix, name, path, headers) @width = prefix @url_params = url_params # Re-defi...
true
d1bb716283ffd39dc4eb8581ff1fd420908ec944
Ruby
michermd/my-select-dumbo-web-060418
/lib/my_select.rb
UTF-8
165
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_select(array) idx = 0 select = [] while idx < array.length if yield(array[idx]) select << array[idx] end idx += 1 end select end
true
7920043eadec2becc916876fd2108cd7ab966590
Ruby
djloow/parser
/greenalco/parser.rb
UTF-8
907
2.9375
3
[]
no_license
require 'open-uri' require 'csv' require 'nokogiri' class Parser attr_accessor :url, :tag, :doc, :headers, :catalog def initialize @tag = Hash.new @url = 'http://greenalco.ru' @tag[:main_category] = '.box-category ul li a' @doc = Nokogiri::HTML(open(url)) @headers = %w(name paramsynonym catego...
true