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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
78c8151865705a43b154d4de3a885bd8999c39f1 | Ruby | hamza3202/repositext | /lib/kramdown/converter/html_repositext.rb | UTF-8 | 879 | 2.578125 | 3 | [
"MIT"
] | permissive | module Kramdown
module Converter
# Converts kramdown element tree to HTML fragments.
class HtmlRepositext < Html
# All ems are converted to spans
# @param el [Kramdown::Element]
# @param indent [Integer]
def convert_em(el, indent)
format_as_span_html(:span, el.attr, inner(el, ... | true |
f15b0f2f5dd08994f959c5af316d235765a426be | Ruby | BARK-STEEL/RESTaurant | /models/party.rb | UTF-8 | 1,587 | 2.921875 | 3 | [] | no_license | class Party < ActiveRecord::Base
has_many :item_orders
belongs_to :server
def self.calculate_receipt(orders)
total = 0
orders.each do |order|
total += order.food.price
end
total
end
def self.receipt(orders)
foods = Food.all
foodsHash = {}
foods.each do |food|
foodsHas... | true |
e0734ce91578afb0444e240eaf243595364f748f | Ruby | chrwog/phase-0 | /week-9/ruby-review-2/ruby_review.rb | UTF-8 | 1,530 | 4.4375 | 4 | [
"MIT"
] | permissive | # I worked on this challenge [by myself].
# This challenge took me [.5] hours.
# Pseudocode
# input: Array
# output: modified Array
# Steps:
# Using the values of the input array, change multiples of 3 to the string "Fizz" 5 to "Buzz" 15 to "FizzBuzz"
# Assign the array to a variable
# iterate through the array
# if... | true |
92122557ed8fefd7cbb7173a72617375191e0b28 | Ruby | Joecleverman/rack-responses-lab-noukod-000 | /app/application.rb | UTF-8 | 243 | 2.75 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Application
def call(env)
resp = Rack::Response.new
h,m = Time.now.strftime("%R").split(":")
if h.to_i < 12
resp.write "Good Morning!"
else
resp.write "Good Afternoon!"
end
resp.finish
end
end
| true |
e415d0553003a188e97ab4c44e775f52e58421de | Ruby | Ravencod/RubyVendredi | /exo_12.rb | UTF-8 | 117 | 3.46875 | 3 | [] | no_license | puts "Rentrer un nombre :"
print "> "
nombre = gets.chomp
i = 0
while (i <= nombre.to_i) do
puts i
i += 1
end | true |
f56dee3969ddbf88130e97247b4bfa2097a57f88 | Ruby | rmar8138/Culture_Crawl | /db/seeds.rb | UTF-8 | 4,592 | 3.0625 | 3 | [] | no_license |
# Create 40 Users with their own profiles
# Create 30 Locations
# Create 10 Crawls that have not passed yet
# Create 20 Crawls the have passed
# Make sure these crawls have between 1..3 locations from the 30 locations created
# Randomly assign these 30 crawls to the users (so that user may have multiple crawls)
# For ... | true |
a73c4785c59bf573ee417a45f590846893c8b914 | Ruby | Rashmibalkur/Airplplanes_seat_algorithm | /airplanes_seat_algorithm.rb | UTF-8 | 3,685 | 3.390625 | 3 | [] | no_license | require 'csv'
require 'byebug'
class Airplane
def get_seat_map seat_set
seat_set = seat_set.transpose
@main_seat = []
4.times do |no|
main_array = []
seat_set[0].each_with_index do |no_of_seats,index|
s_array = []
if no < seat_set[1][index]
no_of_seats.times... | true |
1421636230e2d232c34538a704fbec3c8bba28a1 | Ruby | mneudert/codeeval | /easy/beautiful-strings/rb.rb | UTF-8 | 351 | 3.328125 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
chars = line.strip.downcase.split('')
counts = Array.new(26, 0)
beauty = 0
chars.each do |char|
next if (97 > char.ord) || (122 < char.ord)
counts[char.ord - 97] += 1
end
counts.sort!.reverse!
(1..26).reverse_each do |n|
beauty += n * counts[(n - 26)... | true |
56e14d0d408b7464c111324856d0f6c1f14680ba | Ruby | gaelyn/snowy-pine-8251 | /spec/features/airlines/show_spec.rb | UTF-8 | 3,020 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'Airlines Show Page' do
before :each do
@airline = Airline.create!(name: "Frontier")
@flight_1 = @airline.flights.create!(number: "1234", date: "4/23/21", departure_city: "Denver", arrival_city: "Reno")
@flight_2 = @airline.flights.create!(number: "5678", date: "4/2... | true |
9794659df404071aa3a307351390ec469cbf9ef2 | Ruby | MorrisStranger/App_Academy | /Ruby/chess/test.rb | UTF-8 | 158 | 3.203125 | 3 | [] | no_license | def deep_dup(arr)
copy=[]
arr.each do |ele|
if !ele.is_a? Array
copy << ele
else
copy << deep_dup(ele)
end
end
copy
end
| true |
a9a341b6b6d1a131445fd6472ab3e60ec1907256 | Ruby | elfassy/btc_address_validator | /test/btc_address_validator_test.rb | UTF-8 | 714 | 2.65625 | 3 | [
"MIT"
] | permissive | require "test_helper"
class Validatable
include ActiveModel::Validations
attr_accessor :btc_address
validates :btc_address, btc_address_format: {message: "is invalid"}
end
class BtcAddressValidatorTest < ActiveSupport::TestCase
def setup
@model = Validatable.new
end
test "without address" do
as... | true |
eefac469a4d44b2ea32f67524ae4aa5c68a12159 | Ruby | DanielJWagener/app-academy-exercises | /software-engineering-foundations/tictactoe_project/v1/human_player.rb | UTF-8 | 478 | 3.8125 | 4 | [] | no_license | class HumanPlayer
attr_reader :mark
def initialize(mark)
@mark = mark
end
def is_i?(str)
str.to_i.to_s == str
end
def get_position
p "#{@mark.to_s}: Enter a position! (format: <num><space><num>)"
position_input = gets.chomp
raise "Invalid format: must be <num><space><num>" i... | true |
b07747a553acf9df36e6954860600f236f5293d4 | Ruby | yaqizhao/projet_THP | /Ruby/exo_15.rb | UTF-8 | 207 | 3.859375 | 4 | [] | no_license | puts "Bonjour, c'est quoi votre année de naissance ?"
birth_year = Integer(gets.chomp)
last_year = 2017
age = 0
for year in birth_year..last_year
puts "En #{year}, tu avais #{age} ans"
age += 1
end
| true |
b8490c2eba43e49c38cdd3818dfc24df857f40cb | Ruby | Ammar-alnatsheh/aA-Projects | /W1D2/Match 2 Memory Puzzle/card.rb | UTF-8 | 372 | 3.3125 | 3 | [] | no_license | class Card
attr_accessor :value, :face_up, :face_down
def initialize(value)
@value = value
@face_up = false
@face_down = true
end
def hide
@face_up , @face_down = @face_down, @face_up
end
def reveal
@face_up , @face_down = @face_down, @face_up
end
def ==(card)
card.value == ... | true |
e46080625b91afde2931f823fef413498808760b | Ruby | kstephens/tam | /lib/tam/log4r/tam_outputter.rb | UTF-8 | 1,012 | 2.515625 | 3 | [] | no_license | module TAM
module Log4r
class TamOutputter < ::Log4r::Outputter
# Additional data to add to the TAM::Record before logging it.
attr_accessor :hash_data
def initialize *args
super
@formatter = TamFormatter.new
@hash_data = { }
end
# TAM is already thread-safe... | true |
af86b1b34bbc93f5a1403af47910165f9199cc3e | Ruby | danielwestendorf/domainsbot | /lib/domainsbot.rb | UTF-8 | 1,439 | 2.78125 | 3 | [
"MIT"
] | permissive | # Simple API wrapper for the Domainsbot API
# Visit https://developers.domainsbot.com/docs for more information about the API
# Built for API v4
#
# Author:: Daniel Westendorf (daniel@prowestech.com)
# License:: MIT
require 'net/http'
require 'json'
class Domainsbot
@@api_key = nil
BASE_URI = 'https://api.do... | true |
87e18241b993d49dc0c21aef49481db85b10371c | Ruby | astoica1986/invoices | /web_service/app/models/base.rb | UTF-8 | 931 | 2.640625 | 3 | [] | no_license | class Base
attr_reader :reply_queue, :lock, :condition, :publisher
attr_accessor :response, :call_id
def initialize(reply_queue = '')
ch = BunnyClient.instance.channel
@publisher = ch.default_exchange
@reply_queue = ch.queue(reply_queue, :exclusive => true)
@lock = Mutex.new
... | true |
bd37feef0a186a2cf1e55d55457d2f7644d7e162 | Ruby | Ninad22/S4D2 | /S4D2/mini_jeu_POO/app_2.rb | UTF-8 | 2,479 | 3.46875 | 3 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
puts "------------------------------------------------------------"
puts " Bienvenue dans le jeu Kill me first or die dans ton POO ! "
puts " Le but du jeu est de ne pas se ch... dessus ! "
puts "--------------... | true |
1cf7905ca974018d4ecb7d242f0ef4d1b0a31f06 | Ruby | dantame/animal_quiz_redux | /spec/integration_spec.rb | UTF-8 | 1,746 | 3.015625 | 3 | [] | no_license | require 'animal_quiz_redux/console'
require 'animal_quiz_redux/main'
module AnimalQuizRedux
describe Main do
let(:console) { Console.new }
subject { described_class.new console }
context 'Integration test' do
it 'tests the game end to end vs the initial spec given' do
allow(console).to ... | true |
b4e1f7518afae433ba04364eaf06731eedd3ad50 | Ruby | islador/currency_conversion | /model/machine.rb | UTF-8 | 857 | 3.453125 | 3 | [] | no_license | require_relative 'change'
require_relative 'currency'
class Machine
def initialize
@change = Change.new()
@largest_currency = nil
end
attr_reader :change
attr_accessor :largest_currency
# make_change triggers the change calculation and outputs the results
def make_change(usd_float)
raise Argu... | true |
cf346145f403fccf1d810454d8eb0190d1724835 | Ruby | alirezaandersen/black_thursday | /lib/invoice_item_repository.rb | UTF-8 | 1,231 | 2.9375 | 3 | [] | no_license | require 'csv'
require 'invoice_items'
class InvoiceItemRepository
attr_reader :invoice_items
def initialize
@invoice_items = []
end
def load_data(filename)
data = CSV.open filename, headers: true, header_converters: :symbol
data.each do |row|
invoice_items << InvoiceItem.new({:id => row[:... | true |
24064ed9af120bf728ec1f68335435dcd50e9771 | Ruby | craigh44/FAAST | /spec/passenger_holder_spec.rb | UTF-8 | 496 | 2.765625 | 3 | [] | no_license | require "passenger_holder"
require "passenger"
require "station"
class PersonHolder; include PassengerHolder; end
describe PassengerHolder do
let(:holder) {PersonHolder.new}
let(:passenger) {Passenger.new}
let(:station) {Station.new}
it "should be able to accept passengers" do
holder.accept(passenger, station... | true |
fd144b8e777fcc0493a91cd058a85343231a4f71 | Ruby | chian88/challenges | /medium2/diamond.rb | UTF-8 | 760 | 3.96875 | 4 | [] | no_license | class Diamond
def self.make_diamond(letter)
size = (("A"..letter).to_a.size * 2 ) - 1 # 3 letter => 5 rows
down_index = size/2
up_index = size/2
diamond = ""
("A"..letter).each do |char|
string = ''
string = string.center(size)
string[up_index] = char
string[down_ind... | true |
1c30caff909da83300d5f34563653ad03930fc81 | Ruby | roman-zaharenkov/short_url | /app/services/track_link_click.rb | UTF-8 | 329 | 2.515625 | 3 | [] | no_license | class TrackLinkClick
def initialize(link, request)
@link = link
@request = request
end
def call
Click.create({ link: @link }.merge(request_params))
end
private
def request_params
{
user_agent: @request.user_agent,
ip: @request.remote_ip,
referer: @request.referer
}
... | true |
ac762279539b7f6154c74075e3b5158fa2d0f0a9 | Ruby | sjmiller609/sampleCode | /read-the-README/Ruby/get_json.rb | UTF-8 | 1,092 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Created: 10/8 Dalton Flanagan
#----------------------------------------
# Creates JSON file based on url and returns JSON file name
# Created: 9/29 by Steven Miller (empty method)
# Modified: 10/5 by Allen Yu (Implemented method to create JSON file)
# Modified: 10/6 by Allen Yu (Added dept)
# Mod... | true |
6ada5e69ed964edef7e1475674f8b2c16138d557 | Ruby | alexch/sentry | /lib/measure.rb | UTF-8 | 534 | 2.765625 | 3 | [
"MIT"
] | permissive | module Measure
def measure_dec(x)
"%02d" % (x.to_f % 1 * 100)
end
def measure_say(msg)
log = respond_to?(:logger) ? logger : Logger.new($stdout)
now = Time.now
log.info("#{now.strftime('%H:%M:%S')}.#{measure_dec(now)} #{msg}")
end
def measure(name)
start = Time.now
measure_say "--> s... | true |
d5bd43a25619233a919b51e3e38e8e5743fc4cd5 | Ruby | gomachan46/atcoder | /atcoder_beginners_selection/coins/main.rb | UTF-8 | 340 | 3.203125 | 3 | [] | no_license | a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
a_max = (x / 500)
b_max = (x / 100)
c_max = (x / 50)
a = a_max if a > a_max
b = b_max if b > b_max
c = c_max if c > c_max
result = 0
(0..a).each do |aa|
(0..b).each do |bb|
xx = (x - (500 * aa + 100 * bb))
result += 1 if (xx >= 0) && (xx / 50) <= c
e... | true |
4765af8be0dd46d4e5cec696d001e847add9e0e2 | Ruby | nabewise/bandicoot | /lib/bandicoot.rb | UTF-8 | 906 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'bandicoot/save_file'
require 'bandicoot/save_point_hash'
require 'bandicoot/context'
module Bandicoot
@@current = nil
def self.start(opts={})
raise AlreadyStartedError if Bandicoot.current
Bandicoot.push_context(opts)
begin
yield
ensure
Bandicoot.current.save_file.close
... | true |
d33050708c7e89464904f1e77e43633c075d8e92 | Ruby | cielavenir/procon | /yukicoder/tyama_yukicoder544.rb | UTF-8 | 142 | 3 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
N=gets.to_i
loop{
s=%w(1 2 3 4 5 6 8 9).sample(8).join.to_i
t=N-s
if !t.to_s.index('7')
puts '%d %d'%[s,t]
exit
end
}
| true |
adac21b53e6b8b47ee866c16b1b55b2b21708925 | Ruby | sbosley/euler | /old/problem1.rb | UTF-8 | 128 | 3.140625 | 3 | [] | no_license | def natural_sum
(1...1000).reduce(0) {|sum, n|
if (n % 3 == 0 || n % 5 == 0) then
sum + n
else
sum
end
}
end
| true |
6faf06ebcd2ee04fc417a5d6827871049b1050ff | Ruby | dianorlova/Ruby | /Ruby_practice/6-enumerators-and-blocks/enumerable/enum_for.rb | UTF-8 | 231 | 2.796875 | 3 | [] | no_license | array = (1..150).to_a
# array.each_slice(9){|sub_arr| p sub_arr.length}
enum = array.enum_for(:each_slice,56)
p enum.next # первый элемент итератора (массив из 56 эл-тов)
p enum.next
p enum.next | true |
627f63ef2c2dd4a4bfbb2b4c73ab4c0a01ac80ab | Ruby | PersephoneQueenOfFlowers/aa_classwork | /w2d1/monkey_patching_project/lib/array.rb | UTF-8 | 1,427 | 3.6875 | 4 | [] | no_license | # Monkey-Patch Ruby's existing Array class to add your own custom methods
class Array
def span
return nil if self.length == 0
return 0 if self.length == 1
sorted = self.sort
return sorted[-1] - sorted[0]
end
def average
return nil if self.length == 0
sum = self.inject{|acc,ele| acc + e... | true |
8be2a3dcd64450e66e5cbb8907b299241a5550a3 | Ruby | eduardopoleo/grokking | /merge_sort.rb | UTF-8 | 465 | 3.5 | 4 | [] | no_license | def merge_sort(a)
return a if a.length < 2
mid = a.length / 2
b = a[0...mid]
c = a[mid..-1]
b = merge_sort(b)
c = merge_sort(c)
merge(b, c)
end
def merge(a, b)
c = []
while !a.empty? && !b.empty?
if a[0] <= b[0]
e = a.delete_at(0)
else
e = b.delete_at(0)
end
c << e
end
while !a.empty?
... | true |
aadf4ec9522e9a299e31e25e1323d67bcca38129 | Ruby | reedlaw/game_of_life | /lib/render.rb | UTF-8 | 1,696 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'opengl'
require 'glu'
require 'glut'
require_relative 'grid'
include OpenGL
include GLU
include GLUT
OpenGL.load_dll('libGL.so', '/usr/lib')
GLU.load_dll('libGLU.so', '/usr/lib')
GLUT.load_dll('libglut.so', '/usr/lib')
GRID = Grid.new([59, 61], [59, 60], [60, 60], [60, 59], [61, 60])... | true |
c606091a926a8c29a363925219f2154999947211 | Ruby | Pierrebol/winee | /db/scraper.rb | UTF-8 | 2,490 | 2.828125 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
def fetch_wine_urls
urls = []
counter = 1
while counter < 6
url_general = "https://www.twil.fr/france.html?dir=desc&order=wine_note_avg&p=#{counter}"
doc = Nokogiri::HTML(open(url_general).read)
wines = doc.search(".no-text-decoration.no_focus")
wines.take(... | true |
5215573713d95b6251ab4922a3426b3f107789da | Ruby | 088haizi/launch-school-courses | /back_end_prep/loops_and_iterators/Q3.rb | UTF-8 | 77 | 3.59375 | 4 | [] | no_license | [1, 3, 5, 7].each_with_index do |n, index|
puts "#{index+1} \t #{n}"
end
| true |
b3ca00ae9c06087a6523e9dfee7c6a54426a3ad9 | Ruby | ULL-ESIT-LPP-1718/cocinero-alu0100888102 | /test/Cocinero_test.rb | UTF-8 | 1,217 | 2.796875 | 3 | [] | no_license | require 'lib/Cocinero'
require 'test/unit'
class TestPoint < Test::Unit::TestCase
def setup
@cocinero = Cocinero.new
end
def tests
assert_equal(0, @cocinero.anos)
assert_equal(0, @cocinero.experiencia)
assert_equal(0, @cocinero.contador)
assert_equal(:aprendiz, ... | true |
2f0a23a4d9b0dc9ba0cd5daa874bcf6028ef97b3 | Ruby | walidwahed/ls | /exercises/101-109_small_problems/additional_practice/medium2/02.rb | UTF-8 | 1,070 | 4.15625 | 4 | [] | no_license | # Now I Know My ABCs
# A collection of spelling blocks has two letters per block, as shown in this list:
# B:O X:K D:Q C:P N:A
# G:T R:E F:S J:W H:U
# V:I L:Y Z:M
# This limits the words you can spell with the blocks to just those words that do not use both letters from any given block. Each block... | true |
ca2ad84ebe275ddec2979f1a163c5e74212adf58 | Ruby | snukky/plerrex | /lib/plerrex/edited_text.rb | UTF-8 | 1,168 | 2.9375 | 3 | [] | no_license | module Plerrex
class EditedText
attr_reader :text, :new_text, :errors
attr_accessor :attributes
def initialize(text, new_text=nil, error_corrections=[], attributes={})
@text = text
@new_text = new_text
@attributes = attributes
raise ArgumentError,
"Third parameter s... | true |
f30ab4e0cb560a841bd6acb697a2381246766bba | Ruby | mlzhuyi/leetcode | /is_match.rb | UTF-8 | 176 | 2.671875 | 3 | [] | no_license | # @param {String} s
# @param {String} p
# @return {Boolean}
def is_match(s, p)
regexp=Regexp.new(p)
return false if s.empty? and not regexp=~s
s.sub(regexp,"").empty?
end | true |
cf0da44be73050ad2d9c78d62b82ea24b227ade5 | Ruby | mdp/rotp | /spec/lib/rotp/totp_spec.rb | UTF-8 | 9,009 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
TEST_TIME = Time.utc 2016, 9, 23, 9 # 2016-09-23 09:00:00 UTC
TEST_TOKEN = '082630'.freeze
TEST_SECRET = 'JBSWY3DPEHPK3PXP'
RSpec.describe ROTP::TOTP do
let(:now) { TEST_TIME }
let(:token) { TEST_TOKEN }
let(:totp) { ROTP::TOTP.new TEST_SECRET }
describe '#at' do
let(:token) { to... | true |
6116a8632f6d03d7dd837d3e728062c4ad621760 | Ruby | Richmj/rForRuby | /returnLastIndexOfCharacter.rb | UTF-8 | 308 | 3.796875 | 4 | [] | no_license | def last_index(str, char)
i = str.length - 1 # start from end of string
while i >= 0
if str[i] == char
return i
end
i -= 1
end
end
puts last_index("abca", "a") #=> 3
puts last_index("mississipi", "i") #=> 9
puts last_index("octagon", "o") #=> 5
puts last_index("programming", "m")#=> 7 | true |
6db3bdc6da5ff12eb26593fb62d71455745cb0d8 | Ruby | jb2718/ls-backend | /120/120_2/oo_rps/rps4/player.rb | UTF-8 | 1,908 | 3.515625 | 4 | [] | no_license | require './ai.rb'
require './score.rb'
require 'pry'
require 'yaml'
PERSONALITIES = YAML.load_file('personality_prefs.yml')
class Player
attr_accessor :name, :move, :score
def initialize
@score = Score.new
set_name
end
def display_score
coda = @score.value == 1 ? "point" : "points"
puts "#{na... | true |
06b8d22c859e490c209cfc06365aa5184a2c629a | Ruby | JayKhoury/Ruby-Exercises | /Methods/method_without_return.rb | UTF-8 | 206 | 3.328125 | 3 | [] | no_license | # Change the previous method in the file labeled return_in_method.rb
# so that it prints a word instead of printing nothing
#
def scream(words)
words = words + "!!!"
puts words
end
scream("jay") | true |
1df5660f5dcdb042d2d6287b290b25f34cb36568 | Ruby | abraao/KataWordWrap | /wrapper.rb | UTF-8 | 1,229 | 3.734375 | 4 | [
"MIT"
] | permissive | ##
# http://www.codingdojo.org/cgi-bin/index.pl?KataWordWrap
# You write a class called Wrapper, that has a single static function named
# wrap that takes two arguments, a string, and a column number. The function
# returns the string, but with line breaks inserted at just the right places to
# make sure that no l... | true |
7c92c5f54e0757651daa5021a0179f89eb86817a | Ruby | dankober/MoreEnumerables | /challenge.rb | UTF-8 | 1,004 | 4.0625 | 4 | [] | no_license |
def capitalize_each_string(input)
#implement your solution
return input.map { |e| e.capitalize }
end
def fetch_the_dog(input)
#implement your solution here
return input.select { |e| e == "dog" }
end
def no_dogs_allowed(input)
#implement your solution here
return input.select { |e| e != "dog" }
end
def c... | true |
fe3dbb363966b7b0f3392c6ee72ac15367b95f94 | Ruby | ritchiey/toy_robot | /bin/toy_robot | UTF-8 | 437 | 3.234375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "../lib/table"
require_relative "../lib/robot"
commands = File.read(ARGV.first).split("\n")
#. The application is a simulation of a toy robot moving on a square tabletop, of
#dimensions 5 units x 5 units.
table = Table.new(5,5)
robot = Robot.new(table)
commands.each do |com... | true |
52f322d4e8f427a77bd63ca56771abff96e89ee3 | Ruby | Ligator/olympia | /lib/sky_drop_x.rb | UTF-8 | 6,901 | 2.53125 | 3 | [] | no_license | class SkyDropX
require "uri"
require "net/http"
# Receives the origin and destiny zips and package specs.
# Returns a list of the packaging services with prices.
# Example of request:
# {
# "zip_from": "71317",
# "zip_to": "64000",
# "parcel": {
# "weight": 10,
# "height": 10,
# ... | true |
068d18a798749f76a3a7d749a754d1798b01e876 | Ruby | novakoda/chess | /lib/pawn.rb | UTF-8 | 1,283 | 3.5625 | 4 | [] | no_license | require_relative "board.rb"
class Pawn
attr_accessor :pos, :color, :parent, :children, :symbol
def initialize(pos = [0,0], color = "black", parent = nil, children = [])
@pos = pos
@color = color
@parent = parent
@children = children
@color == "black" ? @symbol = "♟" : @s... | true |
cb52983132758d26b3f3d43bb57b097dad7a2325 | Ruby | johns276/ritrack | /app/models/location.rb | UTF-8 | 1,496 | 2.671875 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: locations
#
# id :integer not null, primary key
# company :string(255)
# organization :string(255)
# address1 :string(255)
# address2 :string(255)
# city :string(255)
# state :string(255)
# zip :string(255)
# countr... | true |
2a6db33a9c187ce3be4c5d4298de608053b569bb | Ruby | Ashley-Westcott/dumbo-web-040119 | /04-one-to-many/runner.rb | UTF-8 | 583 | 2.859375 | 3 | [] | no_license | require 'pry'
require_relative 'tweet'
require_relative 'user'
coffee_dad = User.new("coffee_dad")
ariana_grande = User.new("ariana_grande")
p coffee_dad.username
coffee_dad.post_tweet "having coffee"
coffee_dad.post_tweet "drinking coffee"
apocalyptic_tweet = coffee_dad.post_tweet "The time of reckoning is upon us... | true |
670086f25308f0c90cdab55df641915395eb6d6d | Ruby | bgroveben/OdinProject | /ruby/RubyMonk/ruby_primer/kaprekars_number.rb | UTF-8 | 1,334 | 3.984375 | 4 | [] | no_license | =begin
Problem Statement
9 is a Kaprekar number since
9 ^ 2 = 81 and 8 + 1 = 9
297 is also Kaprekar number since
297 ^ 2 = 88209 and 88 + 209 = 297.
In short, for a Kaprekar number k with n-digits, if you square it and add the right n digits to the left n or n-1 digits, the resultant sum is k.
Find if a given numbe... | true |
bbbe5a81a143937478a26f52b89670350c29f1af | Ruby | aweber212/phase-0-tracks | /practice-assessments/week6-practice-assessment/dancer.rb | UTF-8 | 1,775 | 3.734375 | 4 | [] | no_license | class Dancer
attr_reader :names, :card, :dancers
attr_accessor :ages, :age
def initialize(names, ages, leap = false)
@dancers = []
@card = []
p "Initializing Dancer."
@names = names
@ages = ages.to_i
@leap = leap
@dancers = dancers.push(names, ages)
end
def name
p names
end
... | true |
1b72a38bd35ffab5d51b49ca8fbbd5b144aa5e5f | Ruby | Deoshor/thinknetica_deoshor | /module/main.rb | UTF-8 | 811 | 2.6875 | 3 | [] | no_license | require_relative './company.rb'
require_relative './instance_counter.rb'
require_relative './station.rb'
require_relative './route.rb'
require_relative './train.rb'
require_relative './passenger_train.rb'
require_relative './passenger_wagon.rb'
require_relative './cargo_train.rb'
require_relative './cargo_wagon... | true |
b00b06ee21770c56d18131b36b03601685a2d93e | Ruby | tacyas/pione | /lib/pione/model/block.rb | UTF-8 | 6,117 | 3.15625 | 3 | [
"MIT",
"Ruby"
] | permissive | module Pione::Model
# ActionBlock represents content script of action.
# @example
# Action
# echo "abc"
# End
# #=> ActionBlock.new(" echo \"abc\"")
class ActionBlock < BasicModel
attr_reader :content
# Creates a action block.
# @param [String] content
# action content of she... | true |
ba5db9408253d80d7cb918e3c8e9b5da3986050d | Ruby | somenugget/pivot-master | /lib/pivot/item.rb | UTF-8 | 617 | 3.15625 | 3 | [] | no_license | module Pivot
class Item
attr_accessor :assignee
attr_reader :name, :points
AVAILABLE_PROJECT_CODES = %w[EREC AZR].freeze
def initialize(name:, points:, assignee: nil)
@name = name
@points = points
@assignee = assignee
end
def +(another_item)
unless another_item.is_a?... | true |
af302c90475573a8c51c6c41e430447a3fda95ec | Ruby | whatalnk/cpsubmissions | /atcoder/ruby/chokudai_S001/chokudai_S001_k/1471541.rb | UTF-8 | 908 | 3.453125 | 3 | [] | no_license | # Contest ID: chokudai_S001
# Problem ID: chokudai_S001_k ( https://atcoder.jp/contests/chokudai_S001/tasks/chokudai_S001_k )
# Title: K. 辞書順で何番目?
# Language: Ruby (2.3.3)
# Submitted: 2017-07-30 03:27:38 +0000 UTC ( https://atcoder.jp/contests/chokudai_S001/submissions/1471541 )
n = gets.chomp.to_i
arr = gets.chomp.... | true |
941e64079f77a10bae0a86fa021f02fc9ec573a4 | Ruby | rrA12d9p/practice | /ruby/metro/trip.rb | UTF-8 | 944 | 3.5 | 4 | [] | no_license | class Trip
attr_reader :orig, :dest, :successful_paths
def initialize(orig, dest)
@orig = orig
@dest = dest
@successful_paths = []
end
def min_path_length
path_stop_lengths = @successful_paths.map {|path| path.length}
return path_stop_lengths.min
end
# check every connection of every connection
# if... | true |
c99695ab30c755e8973a6b88eab76764b9e1e615 | Ruby | imWildCat/turbo-rails | /app/helpers/turbo/frames_helper.rb | UTF-8 | 1,047 | 2.609375 | 3 | [
"MIT"
] | permissive | module Turbo::FramesHelper
# Returns a frame tag that can either be used simply to encapsulate frame content or as a lazy-loading container that starts empty but
# fetches the URL supplied in the +src+ attribute.
#
# === Examples
#
# <%= turbo_frame_tag "tray", src: tray_path(tray) %>
# # => <turbo-fr... | true |
79f21837fa58cf5babeb224666ef5fcf8eda86d6 | Ruby | adrian-lara/battleship | /lib/welcome_messages.rb | UTF-8 | 772 | 3.15625 | 3 | [] | no_license | module WelcomeMessages
def self.prompt_begin
puts "Would you like to (p)lay, read the (i)nstructions, or (q)uit?\n>"
end
def self.print_instructions
puts "Battleship is a guessing game for two players.\n" +
"Each player has a board presented as a grid.\n" +
"Each player places a fleet of two... | true |
e1c21eb37036ff459fbb92412ab453abb9353118 | Ruby | rtboudreau/ruby-intro-to-arrays-lab-seattle-web-career-021819 | /lib/intro_to_arrays.rb | UTF-8 | 375 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
[]
end
def array_with_two_elements
["BMC", "Canyon"]
end
def first_element(array)
array[0]
end
def third_element(array)
array[2]
end
def last_element(array)
array[-1]
end
def first_element_with_array_methods(array)
array.shift
end
def last_element_with_array_methods(array)
arra... | true |
913aeb4b23311a9cf580df8961fcd7f39750eaaa | Ruby | caughtclean/ar-exercises | /exercises/exercise_5.rb | UTF-8 | 336 | 2.59375 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
puts "Exercise 5"
puts "----------"
pp Store.sum(:annual_revenue)
pp Store.average(:annual_revenue).to_s
stores = Store.all
pp Store.where("annual_revenue > 10000... | true |
0c5b077169bf2793ed31164af1daece22148be00 | Ruby | Cisco-AMP/nexus_user_manager | /lib/nexus_user_manager/role.rb | UTF-8 | 1,377 | 2.8125 | 3 | [
"MIT"
] | permissive | module NexusUserManager
class Role
attr_accessor :name, :privileges
def initialize(role, privileges, role_checker, privilege_checker)
@name = role
@privileges = privileges.map do |privilege|
Privilege.new(privilege)
end
@role_checker = role_checker
@privilege_checker = p... | true |
71bf104fd4984d169555e24ca707af0d226d3b66 | Ruby | gravescpa/mined_minds_kata | /print_to_screen.rb | UTF-8 | 709 | 3.921875 | 4 | [] | no_license | # puts "This is a string that we want to print to the screen " * 100
# puts "This is a string that we want to print to the screen
# " * 100
# 100.times do
# puts This is a string that we want to print to the screen
# end
# 100.times do
# puts "1\n"
# end
x = 1
#while x <= 100
100.times do
if x % 15 == 0
... | true |
e2823cd9b5f73d96f1d3f08b397102257e74a83a | Ruby | RaminMammadzada/spree | /core/app/sorters/spree/products/sort.rb | UTF-8 | 1,283 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | module Spree
module Products
class Sort
def initialize(scope, params, current_currency)
@scope = scope
@sort = params[:sort]
@currency = params[:currency] || current_currency
end
def call
products = updated_at(scope)
products = price(products)
... | true |
3d429a972f6ca99bc1f6d9951831f493ebde0a8e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/9c089f493f2f45ac9bc3b9722337c8eb.rb | UTF-8 | 426 | 3.0625 | 3 | [] | no_license | class Bob
def hey(query)
return 'Woah, chill out!' if shout?(query)
return 'Fine. Be that way!' if silence?(query)
return 'Sure.' if query?(query)
return 'Whatever.'
end
def query?(query)
return !!(query.match(/\?\Z/))
end
def shout?(query)
return !!(query.match(/[A-Z]... | true |
0e9cb6bdf49b8cf0964b9ab0511302bc43b72bde | Ruby | violake/fiat | /app/services/validation/westpac_validation.rb | UTF-8 | 1,794 | 2.625 | 3 | [] | no_license | require_relative 'base_validation'
module Fiat
class WestpacValidation < BaseValidation
def self.check_columnname(column_names)
[:bank_account, :date, :narrative, :debit_amount, :credit_amount, :categories, :serial].inject([]) do |missing, column|
if column_names.include?(column) then missing els... | true |
48e6973ddd82a9ea2534f8fc72fb4687112ac21b | Ruby | ugoa/ugoaServer | /RubySnippets/RubyProjects/ThreadErrorHandling.rb | UTF-8 | 370 | 2.96875 | 3 | [] | no_license | Thread.abort_on_exception = true
threads = []
4.times do |number|
threads << Thread.new(number) do |i|
raise "Boom! " if i == 2
print "#{i}\n"
end
end
threads.each { |t| t.join }
#threads.each do |t|
# begin
# t.join
# rescue RuntimeError => ex
# puts "Save... | true |
f2fcf9bfd3ca6828127aa480ff7e175d6f8090ad | Ruby | jiren/mongokit | /examples/address.rb | UTF-8 | 275 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative 'common'
class Company
include Mongoid::Document
mongokit :address, :auto_increment
has_address(except: [:latitude, :longitude])
auto_increment :rank
end
Company.destroy_all
c = Company.create(city: 'Mumbai')
puts c.inspect
puts c.full_address
| true |
661a467f6874c4ff2a6b991a18f288e8146a74ab | Ruby | walidwahed/ls | /120-oop/lesson_4-exercises/medium1/05.rb | UTF-8 | 950 | 4.15625 | 4 | [] | no_license | # Question 5
# You are given the following class that has been implemented:
class KrispyKreme
def initialize(filling_type, glazing)
@filling_type = filling_type
@glazing = glazing
end
def type
base = @filling_type == nil ? 'Plain' : @filling_type
topping = @glazing == nil ? '' : "with #{@glaz... | true |
78a3c4df1d9a282182d90bd30e0c18bcc4533035 | Ruby | herniadlf/altojardin-api | /app/models/delivery.rb | UTF-8 | 406 | 2.515625 | 3 | [] | no_license | require_relative '../../app/models/user'
class Delivery < User
attr_accessor :user_id, :available, :occupied_quantity, :orders_done_today
CAPACITY = 3
def initialize(data = {})
super data
@user_id = data[:user_id]
@available = data[:available].nil? ? true : data[:available]
@occupied_quantity =... | true |
7b8b0a5b39f874fd774801f2973526014e79dc80 | Ruby | ronakvsoni/ruby-oo-relationships-practice-gym-membership-exercise-sea01-seng-ft-060120 | /tools/console.rb | UTF-8 | 548 | 3.03125 | 3 | [] | no_license | # You don't need to require any of the files in lib or pry.
# We've done it for you here.
require_relative '../config/environment.rb'
# test code goes here
soundarya = Lifter.new("Soundarya", 100)
danira = Lifter.new("Danira", 300)
akiko = Lifter.new("Akiko", 160)
twenty_four = Gym.new("24 Hour Fitness")
golds = Gym.... | true |
1224192e07f75faaafb59b8f3a35a1ac225cfe4b | Ruby | sdbondi/apartment | /lib/apartment/adapters/abstract_jdbc_adapter.rb | UTF-8 | 1,344 | 2.578125 | 3 | [
"MIT"
] | permissive | module Apartment
module Adapters
class AbstractJDBCAdapter < AbstractAdapter
# Drop the database
#
# @param {String} database Database name
#
def drop(database)
super(database)
rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError
raise Database... | true |
c927d4c316e0321c5437d2fb146d9ad0e7f7add1 | Ruby | nverno/dentry | /app/models/user.rb | UTF-8 | 852 | 2.640625 | 3 | [] | no_license | # user.rb ---
# Filename: user.rb
# Description: Models a user, email address must be unique for login
# Author: Noah Peart
# Created: Wed Dec 10 20:12:49 2014 (-0400)
# Last-Updated: Fri Dec 12 00:42:51 2014 (-0400)
# By: Noah Peart
#
class User < ActiveRecord::Base
# Users should have name, email, passw... | true |
c7d9c4b27936943471fa04b37893f26a0f23b7f6 | Ruby | BJSummerfield/Games | /war/model.rb | UTF-8 | 1,247 | 3 | 3 | [] | no_license |
require_relative "views.rb"
def deck(value: (1..13).to_a, suits:%w(Hearts Spades Dimonds Clubs), deck: nil)
@deck = Array.new(suits.count,(1..13).to_a).flatten
end
def shuffle(deck)
@deck = deck.shuffle
end
def deal(deck)
@deck = deck.each_slice(26).to_a
@p1 = @deck[0]
@p2 = @deck[1]
end
def play
if @p1... | true |
40184ff670a8f95717974d7472a40217957a02c0 | Ruby | midnightmonster/rails-utils | /snowdrift.rb | UTF-8 | 2,555 | 3.390625 | 3 | [] | no_license | # Copyright 2021 Joshua Paine
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
... | true |
167a0e093e34d9cdbbec8eecb76d06bcb869e688 | Ruby | johnmcconnell/json_client | /lib/json_client/request_without_body.rb | UTF-8 | 309 | 2.5625 | 3 | [
"MIT"
] | permissive | module JsonClient
class RequestWithoutBody < Request
def fetch(request)
if methods.include? request.method
execute!(request)
else
fail "#{request.method} must be in #{methods}"
end
end
protected
def methods
%w(GET DELETE POST PUT)
end
end
end
| true |
cf8dc386f831f1848e8e43e4fcd7e310b6f53f28 | Ruby | BenHaugen/reverse-each-word-seattle-web-career-012819 | /reverse_each_word.rb | UTF-8 | 255 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
new_array = string.split(" ")
array = []
new_array.each do |word|
array.push(word.reverse)
end
return array.join(" ")
end
def reverse_each_word(string)
string.split(" ").collect{ |word| word.reverse}.join(" ")
end | true |
4cf99dc84c603cc60af14f188201e52bae980048 | Ruby | wedesoft/linalg | /lib/linalg/iterators.rb | UTF-8 | 4,659 | 3.5 | 4 | [
"MIT"
] | permissive | #
# Copyright (c) 2004-2008 by James M. Lawrence
#
# See LICENSE
#
module Linalg
#
# <tt>Enumerable</tt>s and <tt>Enumerable</tt>-like
# methods for matrices.
#
# For blocks which yield <tt>i,j</tt> indexes, the visitation is
# always in column-major order -- that is, +i+ changes faster than +j+... | true |
34d63fd53febb259e6411b552b8f808424e1cdf4 | Ruby | vdaubry/photo-scrapper | /websites/tumblr/tumblr_helper.rb | UTF-8 | 2,272 | 2.625 | 3 | [
"MIT"
] | permissive | require 'byebug'
module TumblrHelper
def single_photo_xpath
'//div[@class="media"]//a'
end
def direct_images_xpath
'//div[@class="media"]//img[not(parent::a)]'
end
def direct_images_urls
doc = @current_page.parser
doc.xpath(direct_images_xpath).map {|img| img[:src]}
end
def single_pho... | true |
e6b59167485bb4784900c5424adb324c6e6a31a4 | Ruby | danbriechle/brownfield-of-dreams | /app/models/follower.rb | UTF-8 | 380 | 2.71875 | 3 | [] | no_license | class Follower
attr_reader :url, :name, :uid
def initialize(gh_response)
@url = gh_response["html_url"]
@name = gh_response["login"]
@uid = gh_response["id"]
end
def self.generate(gh_response)
JSON.parse(gh_response.body).map do |object|
Follower.new(object)
end
end
def is_user?
... | true |
3468ef13ffd67d7a50e7f9c8bf7a3b273c1138ca | Ruby | paulyeo21/ruby_concurrency | /rate_limiting_using_token_bucket_filter.rb | UTF-8 | 2,055 | 4.25 | 4 | [] | no_license | # Implement rate limiting using a naive token bucket filter algorithm.
#
# - Imagine you have a bucket that gets filled with tokens at the rate of 1 token per second. The bucket can hold a maximum of N tokens. Implement a thread-safe class that lets threads get a token when one is available. If no token is available, t... | true |
ac58fadbe2855e7188ae0b7834ab38a0f244817e | Ruby | croucherfoundation/droom | /app/models/droom/mailing_list_membership.rb | UTF-8 | 5,782 | 2.703125 | 3 | [
"MIT"
] | permissive | # This class has the awkward job of giving access to the mailing list membership records stored in
# legacy mailman mysql tables. They're likely to be held in another database, and they have an extremely
# un-rails-like schema, so our main job is to translate between their and our conventions.
#
# This whole mechanism ... | true |
7dee203db865693778c8a6d929f08f528260404a | Ruby | kanety/findout | /lib/findout/postprocessor.rb | UTF-8 | 2,336 | 2.84375 | 3 | [
"MIT"
] | permissive | module Findout
class Postprocessor
def initialize(base)
@base = base
end
def run(root)
visit(root)
end
private
def visit(node)
if node.operation?
replace_operation(node)
end
node.children.each do |child|
if child.attribute? && missing_operation... | true |
f86826bd5c4fd67b4e6d3d83c82780f4baa18e7d | Ruby | danielxurbina/programming-univbasics-nds-green-grocer-nyc-web-021720 | /grocer.rb | UTF-8 | 2,714 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def find_item_by_name_in_collection(name, collection)
# Implement me first!
#
# Consult README for inputs and outputs
i = 0
while i < collection.length
if collection[i][:item] == name
return collection[i]
end
i += 1
end
end
def consolidate_cart(cart)
# Consult README for inputs and outputs
#... | true |
f021c8a818d264b1e38110297bdba8baf00c2a95 | Ruby | nab-velocity/ruby-sdk | /lib/velocity/velocity_connection.rb | UTF-8 | 1,426 | 2.671875 | 3 | [
"MIT"
] | permissive | require "base64"
require 'httparty'
require_relative "velocity_exception"
require_relative "velocity_processor"
require_relative "velocity_xml_creator"
include Velocity::VelocityException::VelocityErrors
include Velocity::VelocityException::VelocityErrorMessages
module Velocity
class VelocityConnection
attr_acce... | true |
debe52c6bd308d8e5aad392093509cc19c81ffce | Ruby | bbchui/Chess | /Chess/piece.rb | UTF-8 | 3,001 | 3.53125 | 4 | [] | no_license | require_relative 'board'
require_relative 'Slidable'
require_relative 'Steppable'
class Piece
attr_accessor :pos
attr_reader :symbol, :board, :color
def initialize(board, color, pos)
@symbol = :X
@pos = pos
@board = board
@color = color
end
def valid_moves(pos_movs)
new_movs = []
p... | true |
c321d6c636214a3b554f746e606840e38548e492 | Ruby | phurni/phitris | /game_components/fixed_tetromino.rb | UTF-8 | 1,857 | 2.609375 | 3 | [
"MIT"
] | permissive | module Phitris
class FixedTetromino < Tetrion
include Config
config tetrion_border: 0xFF181855, tetrion_background: 0xFF404850, tetrion_padding: 10
attr_accessor :tetromino
def initialize(options = {})
super(config.merge(options))
end
def inside_width
@inside_wi... | true |
61e5ef11a3b0511a11e17b3c3ce891214bc4b3f6 | Ruby | RomainAlexandre/vending_machine | /spec/lib/vending_machine_spec.rb | UTF-8 | 7,724 | 2.59375 | 3 | [] | no_license | require 'yaml'
RSpec.describe VendingMachine do
let(:initial_state) { YAML.load_file('./spec/fixtures/initial_state.yml') }
let(:described_instance) { described_class.new(**initial_state) }
describe '#select_item' do
subject { described_instance.select_item(item_id) }
context 'when item_id is invalid'... | true |
5b07d12e8aa7f2e3002acf5ad922dcf0740ac2e1 | Ruby | opsaaaaa/template_chips | /spec/string_helper.rb | UTF-8 | 198 | 2.5625 | 3 | [
"MIT"
] | permissive | module ChipStringHelper
def line_spacing
return /(^\s+|\s+$|\n)/
end
def clear_line_spacing
return self.gsub(line_spacing ,'')
end
end
class String
include ChipStringHelper
end
| true |
db477376aa191fe07be7074ea54257b3fc26d32f | Ruby | joscor90/patrones_y_ciclos_anidados | /numeros.rb | UTF-8 | 134 | 3.5 | 4 | [] | no_license | #Input variable
n = ARGV[0].to_i
#Loop
1.upto(n) do |i|
1.upto(i) do |j|
print "#{j}"
end
print " "
end
puts "\n" | true |
3a4c3e7a6db90161022f3b5d0d6350e5de4d9bed | Ruby | acosme/project-euler | /10-summation_of_primes.rb | UTF-8 | 454 | 4.21875 | 4 | [] | no_license | #The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#Find the sum of all the primes below two million.
def is_prime?(i)
return false if i <= 1
return true if i == 2
(2...i).each {|n|
if i % n == 0
return false
end
}
true
end
count = 0
sum_primes = 0
while count < 2... | true |
25fbfa7fed8af374d70429e28972705a19df0767 | Ruby | bitGnome/pp_lists | /create_price_list | UTF-8 | 708 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require 'fileutils'
require_relative 'lib/create_xml/price_list'
require_relative 'lib/create_xml/xml_builder'
if __FILE__ == $0
print "Name of price list: "
price_list_name = gets.chomp
print "Path to price list: "
price_list = gets.chomp
begin
price_list_file =... | true |
575b579564264eafdfcbe5bfdcfb20aa117c5526 | Ruby | lianaluci/badges-and-schedules-001-prework-web | /conference_badges.rb | UTF-8 | 453 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
attendees.collect do |i|
badge_maker(i)
end
end
def assign_rooms(attendees)
attendees.collect.each_with_index {|name, index| "Hello, #{name}! You'll be assigned to room #{index + 1}!" }
end
def printer(att... | true |
a57f91847c02de97d9878e8b6d8bb5550276a42a | Ruby | ajLapid718/CodeWars-Problems | /6Kyu Kata/Are_We_Alternate.rb | UTF-8 | 702 | 4.21875 | 4 | [] | no_license | # Create a function isAlt() that accepts a string as an argument and validates whether the vowels (a, e, i, o, u) and consonants are in alternate order.
# isAlt("amazon")
# // true
# isAlt("apple")
# // false
# isAlt("banana")
# // true
# Arguments consist of only lowercase letters.
def is_alt(s)
staging_area = []... | true |
6943086733b963af26a4c5cb6d9bd349ea41fa30 | Ruby | JudeQuintana/bugcrowd-challenge | /app/models/stats.rb | UTF-8 | 603 | 2.828125 | 3 | [] | no_license | class Stats
def self.generate_all
#grabbing all tags from all Entities in collection
tags_arr = Entity.all.map(&:tags).flatten.uniq
#for each uniq tag count all entities that contain it
tags_arr.each_with_object([]) { |tag, arr|
count = Entity.where("? = ANY (tags)", tag).count
arr << ... | true |
4b0dfdd185252a3ee5b6df62cb5d6c3917ae02eb | Ruby | bcoelh0/log_parcer | /specs/app_spec.rb | UTF-8 | 2,842 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
require "./app/app.rb"
require "./specs/spec_helper.rb"
RSpec.describe App do
describe "#main" do
context "using log file webserver_test" do
context "inputted params are correct" do
let(:file_path) { "./specs/data/webserver_test.log" }
let(:main) { App.main(fi... | true |
0052af8a12052b52e71107b9cb9f7385110ffcb9 | Ruby | ralewis85/ruby-adventure-game | /character.rb | UTF-8 | 902 | 4 | 4 | [] | no_license | # Parent class that describes all heros and monsters in the game
# Is used to store common variables and have a to_s method
class Character
attr_accessor :name, :cur_health, :max_health, :strength, :level
def initialize(name, health, strength)
# Default values that will be overwritten
@name = name
@leve... | true |
94024f230d5f73390613979ac504bf21067d9c5d | Ruby | Hesham-Elrehaimy/phase-0-tracks | /ruby/gps6/my_solution.rb | UTF-8 | 4,072 | 3.984375 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
#require_relative searches withing files only that are located within the same directory
#require searches out side of the scope in which the file the code which contain... | true |
f75ff6949d7dd2757f865dbda4e74b0ea966611a | Ruby | OliverJAsh/stringer | /fever_api.rb | UTF-8 | 3,623 | 2.53125 | 3 | [
"MIT"
] | permissive | require "sinatra/base"
require "sinatra/activerecord"
require "digest/md5"
require_relative "app/repositories/story_repository"
require_relative "app/repositories/feed_repository"
require_relative "app/commands/stories/mark_as_read"
require_relative "app/commands/stories/mark_as_unread"
require_relative "app/command... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.