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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d2802a42156deb4a0310de5975de31cd3c30b2bb | Ruby | katemorris/enigma | /test/enigma_test.rb | UTF-8 | 3,809 | 3 | 3 | [] | no_license | require './test/test_helper'
require 'date'
require './lib/enigma'
class EnigmaTest < Minitest::Test
def setup
@enigma = Enigma.new
end
def test_it_can_return_shift_breakdown
expected = { A: 3, B: 0, C: 19, D: 20 }
assert_equal expected, @enigma.get_shift('02715', '040895')
end
def test_it_can_... | true |
e9db33c023d6501e99bcd1ab5e302cfb62365cb4 | Ruby | peterylai/exercism | /ruby/phone-number/phone_number.rb | UTF-8 | 509 | 3.359375 | 3 | [] | no_license | class PhoneNumber
attr_reader :number
INVALID = '0'*10
def initialize(input)
@number = clean(input)
end
def area_code
number[0..2]
end
def to_s
"(#{area_code}) #{number[3..5]}-#{number[6..9]}"
end
private
def clean(input)
return INVALID if /[^\d\s().-]/.match(input)
number ... | true |
519a8734be15cf8291bc7afaf75a9fe49fbed512 | Ruby | daudfarzad/programming-univbasics-nds-nds-to-insight-understand-lab-nyc-web-030920 | /lib/nds_explore.rb | UTF-8 | 280 | 2.75 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def pretty_print_nds(nds)
# Change the code below to pretty print the nds with pp
nil
pp nds
end
def print_first_directors_movie_titles
i = 0
movies = directors_database[0][:movies]
while i < movies.count do
puts movies[i][:title]
i += 1
end
end | true |
ccc065298ef5bd4aa92f291da6021932c7e0addc | Ruby | brianleeanderson19/Create-a-file-Error-Handling | /error-handling-lessons/basic_error_handling.rb | UTF-8 | 81 | 2.78125 | 3 | [] | no_license | begin
puts nil + 10
rescue StandardError => e
puts "Error occurred: #{e}"
end | true |
f9ec7b0b111cb9cfa5732afe955ac9639d858f57 | Ruby | ng00455391/watir_scripts | /watir_test.rb | UTF-8 | 643 | 2.53125 | 3 | [] | no_license | #! /home/nagaraj/.rbenv/shims/ruby
require './assertions.rb'
require './homepage.rb'
homepage = Homepage.visit
assert(' \'the index has Body Tag included\'') { homepage.body.exists? }
assert(' \'the index page has navigation bar\'') { homepage.nav_bar.exists? }
assert(' \'the page has h1\'') { homepage.h1.exists? }... | true |
e3cf5ed3304ea09e5705101f606d686fbfa52aa0 | Ruby | mackacavs/FizzBuzz | /spec/fizzbuzz_spec.rb | UTF-8 | 462 | 2.796875 | 3 | [] | no_license | require 'fizzbuzz'
describe 'fizzbuzz' do
it 'expects fizz' do
expect(fizzbuzz(3)).to eq 'fizz'
end
it 'FizzBuzz fizz' do
expect(fizzbuzz(5)).to eq 'buzz'
end
it 'expects fizzbuzz' do
expect(fizzbuzz(15)).to eq 'fizzbuzz'
end
it 'expects 2' do
expect(fizzbuzz(2)).to eq 2
end
it 'e... | true |
8e3f8932f468b0fef13294c1d5f77b9f16aebcc9 | Ruby | Sgtpluck/ltp_5_6 | /number.rb | UTF-8 | 156 | 3.59375 | 4 | [] | no_license | puts "Hey there! What's your favorite number?"
num = gets.chomp
num = num.to_i + 1
puts "Have you considered " + num.to_s + "? It's even bigger and better!" | true |
c6cc4e8ad1084daea68be6005fce38024febdba9 | Ruby | CLandel89/freeworld | /dist/dyn/subclasses/instance-sp.rb | UTF-8 | 834 | 2.75 | 3 | [] | no_license | class InstanceSp < Instance
attr_reader :players
def initialize
super
player = Player.new 0,0,0,100,200
@players = [player]
end
end
def start_instance_sp world
instance = InstanceSp.new
Database.open_world world
wp = 'std'
wn = 'fence_grey_ugly'
#w1-w3: U-shaped thin wall around the player
... | true |
22c49efc7473f286737c53caf7c23656cd5d9199 | Ruby | hamza15/collections_practice-onl01-seng-pt-072720 | /collections_practice.rb | UTF-8 | 793 | 3.90625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(values)
values.sort
end
def sort_array_desc(values)
values.sort.reverse
end
def sort_array_char_count(values)
values.sort_by do |value|
value.length
end
end
def swap_elements(values)
a = values[1]
b = values[2]
values[2] = a
values[1] = b
values
end
def reverse_array(values)... | true |
d65a5d29dac5e49906954f01f84d33e8742422f6 | Ruby | meyerhoferc/battleship | /lib/messages.rb | UTF-8 | 2,956 | 3.28125 | 3 | [] | no_license | module Messages
def self.begin_game
"\nWelcome to BATTLESHIP"
end
def self.beginning_prompt
"\nWould you like to (p)lay, read the (i)nstructions, or (q)uit?"
end
def self.instructions
"""
\nWhen prompted, select coords where you would like to place the ship.
\nYou will enter the coordina... | true |
ba6d9b7f41c5f984c8bcd28f4a2484e1f0cdffbe | Ruby | chitreshgoyal1/assignments | /hackerrankrspec-master/save_princess/spec/saverbot_spec.rb | UTF-8 | 1,611 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
require_relative '../lib/saverbot.rb'
module Kernel
def capture_stdout
out = StringIO.new
$stdout = out
yield
out
ensure
$stdout = STDOUT
end
end
describe '#display_path_to_princess' do
it 'test display path to princess can output path for 3 x 3 grid' do
out = cap... | true |
9e74b40f5721b62cdcbc7b4153e6898274407f07 | Ruby | redpaw/ProjectEuler | /Problem 15.rb | UTF-8 | 217 | 2.890625 | 3 | [] | no_license | factorial40 = 1
factorial20 = 1
for i in 1..40
factorial40 = factorial40*i
if i < 21 then
factorial20 = factorial20*i
end
end
puts factorial40
puts factorial20
puts factorial40/(factorial20*factorial20)
| true |
651450c799434418ab930b427f040db7b9c57f95 | Ruby | zm1th/roolz | /lib/rool/include.rb | UTF-8 | 235 | 2.5625 | 3 | [] | no_license | # The operand is any value that can be in an array.
# The data_key should point to a part of the dataset that has an array in it.
# The rule checks whether the array includes the operand.
module Rool
class Include < Basic
end
end
| true |
aa32ed1aafdffc2890abe753998449619e6a69cf | Ruby | coding-sue-true/sparta-testing-api | /postcodesio_super_class/spec/single_postcode_spec.rb | UTF-8 | 5,402 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
describe Postcodesio do
context 'requesting information on a single postcode works correctly' do
before(:all) do
@postcodesio = Postcodesio.new.single_postcode_service
@postcodesio.get_single_postcode('se96rj')
end
it "Should respond with a status message of 200" do
... | true |
bde00f5ca80688fde10307ebb7fce52edfa2c3b2 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/9eb6b5dc57414e898d5af0e95b45b962.rb | UTF-8 | 337 | 3.5 | 4 | [] | no_license | class Phrase
attr_accessor :phrase
attr_accessor :word_count
def initialize(word)
self.phrase = word
self.word_count = {}
process_count
end
private
def process_count
self.phrase.split(/[^\w']+/).each do |w|
self.word_count[w.downcase] ||= 0
self.word_count[w.downcase] += 1
... | true |
70d2b8a11ceea342351971ee836e59c2319c5d3c | Ruby | karlentwistle/ruby_home | /examples/motion_sensor.rb | UTF-8 | 1,754 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | require "ruby_home"
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
motion_sensor = RubyHome::ServiceFactory.create(:motion_sensor,
motion_detected: false, # required
name: "motion sensor", # optional
status_low_battery: 0, # optional
status_tampered: 0, # optional
status_faul... | true |
512b3725ce2c0869ba7c0f7d19ef204e87c06c1b | Ruby | compwron/wiki_maker | /lib/wiki_person.rb | UTF-8 | 538 | 3.203125 | 3 | [] | no_license | class WikiPerson
def initialize(person)
@page_text = create_text(person)
end
def create_text(person) # need to parse bith date in order to put it in this format.
markup = "{{Infobox person
| name = #{person.name}"
if (!person.born.nil?) then
markup += "\n| birth_date = {{Birth date|#{person.born.yea... | true |
620df07f13ae4876c30555e3b8d093a987840362 | Ruby | GordonBain/snakes_and_ladders | /Ladders.rb | UTF-8 | 191 | 2.734375 | 3 | [] | no_license | class Ladders
def initialize(number, bottom_step, top_step)
@number = number
@bottom_step = bottom_step
@top_step = top_step
end
def top_step
return @top_step
end
end | true |
bac33b8a96fdf00cd009c33b89cae5e939d985d6 | Ruby | learn-co-students/houston-se-060120 | /07-associations-2/models/Dog.rb | UTF-8 | 390 | 3.921875 | 4 | [] | no_license | class Dog
attr_accessor(:name, :breed, :owner)
@@all = [] # [ tilly, lilly ]
def Dog.all
return @@all
end
def initialize(name, breed, owner)
self.name = name # String
self.breed = breed # String (for now)
self.owner = owner # Owner Object (scott)
@@all.pu... | true |
d72fb5eff82558f4e662819ca4f4ed3a348a6bc6 | Ruby | ulizko/api_flashcards | /app/controllers/api_flashcards/api/v1/trainer_controller.rb | UTF-8 | 1,465 | 2.53125 | 3 | [
"MIT"
] | permissive | module ApiFlashcards
module Api
module V1
class TrainerController < ApiFlashcards::Api::ApiController
before_action :find_card, only: :review_card
# Handles a GET request /api/v1/trainer
# Show all not reviewed cards ordered by id
#
# @return [JSON] list of cards con... | true |
d407110ffe903d1e22c3f4f55e2002d53168d518 | Ruby | lucasefe/opi | /lib/opi/parser.rb | UTF-8 | 441 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'yomu'
require 'ostruct'
require_relative 'credit_card_parser'
require_relative 'statement_parser'
module Opi
# Parser
module Parser
module_function
def process(text)
title = text.split("\n")[1].strip
if title == "VISA" || title == "RESUMEN DE CUENTA"
parser = CreditCard... | true |
8bcc029e43a627d526c759006d0014c02df63044 | Ruby | dnuffer/dpcode | /ruby/sample/profile_sample.rb | UTF-8 | 1,378 | 3.453125 | 3 | [] | no_license | require 'test/unit/assertions'
class Array
def sample1(n, pdf = nil)
if pdf
max_prob = pdf.max
else
pdf = Array.new(size, 1.0 / size)
max_prob = 1.0 / size
end
index = (rand * size).to_i
beta = 0.0
Array.new(n) do
beta += rand * 2.0 * max_prob
while beta > pdf[... | true |
ac5754dbb10b6b5d5896395f9658ae14fb50ba99 | Ruby | dolzenko/reflexive | /lib/reflexive/methods.rb | UTF-8 | 4,878 | 2.796875 | 3 | [
"MIT"
] | permissive | require "reflexive/core_ext/kernel/singleton_class"
require "reflexive/core_ext/module/reflexive_instance_methods"
module Reflexive
class Methods
def initialize(klass_or_module, options = {})
@klass_or_module = klass_or_module
@ancestor_name_formatter = options.fetch(:ancestor_name_formatter,
... | true |
42596e76472c7cbc9d01464fb4e3e27b09bd1e77 | Ruby | Colinsmix/Financial-Tracker | /tracker.rb | UTF-8 | 915 | 2.90625 | 3 | [] | no_license | require 'pry'
require 'csv'
require_relative 'customer'
require_relative 'transaction'
require_relative 'bank'
require_relative 'transaction_reader'
require_relative 'overdraft'
require_relative 'account'
colin = Customer.new('Colin','Shields',Account.new(TransactionReader.get_transactions('transactions.csv')))
colin.... | true |
fe38d4ae9f9a976c3715f4418b4d2f3a3ad06955 | Ruby | lomlo/boris-bikes | /spec/van_spec.rb | UTF-8 | 2,607 | 2.796875 | 3 | [] | no_license | require 'van'
require 'docking_station'
describe Van do
let(:dock) {double(:dock)}
# describe '::new' do
# it {should be_instance_of(Van)}
# it 'should start being empty' do
# expect(subject.bikes).to eq []
# end
# end
describe '#collect_bikes_from_dock(dock)' do
it {should respond_to(:co... | true |
06e3088e586a755b166e59a75d17629f12f12838 | Ruby | dalzinho/Codeclan-Work | /w2/day_1/lab/Library.rb | UTF-8 | 1,985 | 3.796875 | 4 | [] | no_license | class Library
def initialize(library_array)
@books = library_array
end
def list_all_texts
list_of_books = []
for book in @books
list_of_books << "Title: #{book[:title]}\tLoaned to: #{book[:rental_details][:student_name]}\tDue: #{book[:rental_details][:date]}"
end
return list_of_bo... | true |
2f997ffe9cd74fadb72e5a28895da788bb9e1f0c | Ruby | aconstandinou/course-101-programming-foundations | /lesson_6/tic_tac_toe.rb | UTF-8 | 4,941 | 3.953125 | 4 | [] | no_license | require 'pry'
FIRST_MOVE = ['player', 'computer', 'choose']
INITIAL_MARKER = ' '
PLAYER_MARKER = 'X'
COMPUTER_MARKER = 'O'
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows
[[2, 5, 8], [1, 4, 7], [3, 6, 9]] + # cols
[[1, 5, 9], [3, 5, 7]] # diagonals
def prompt(msg)
puts "=... | true |
ed7ffcc474b42d06decf54300799c212a85d66c9 | Ruby | conorburke/phase-0-tracks | /ruby/puppy_methods.rb | UTF-8 | 1,297 | 4.0625 | 4 | [] | no_license | class Puppy
def initialize
puts "Initializing new puppy instance..."
end
def fetch(toy)
puts "I brought back the #{toy}!"
toy
end
def speak(time)
time.times do |time|
puts "Woof!"
end
end
def roll_over
puts "*rolls over*"
end
def dog_years(year)
year *= 7
end
de... | true |
ebe43f8e32f55f12ba6d8fbcc34d5894491605a4 | Ruby | g-gagnon/aoc-2018 | /day1/part2.rb | UTF-8 | 260 | 2.828125 | 3 | [] | no_license | input = File.read('input1.txt')
history = Set[0]
memo = 0
result = nil
until result
input.each_line.map(&:to_i).detect do |line|
memo += line
result = memo if history.include? memo
history.add(memo) if result.nil?
result
end
end
p result | true |
75ac72cfbd5b3caf9e928245646358bafad9f836 | Ruby | katyasharova/web-6-7-labs | /Lab6/part3/user.rb | UTF-8 | 443 | 3.84375 | 4 | [] | no_license | # frozen_string_literal: true
require './main'
puts 'input a and b'
a = gets.to_f
b = gets.to_f
root_f1 = root(a, b) { |x| (x**2 + Math.sin(x / 2)) }
root_f2 = root(a, b, &->(x) { Math.atan(x) + x - 1 })
puts "the minimum root of the function f(x) = sin(x / 2) + x^2 on the interval [#{a}, #{b}] " + print_root(roo... | true |
ac78ac41137aaccc9b3cdbd782a124ead407d76f | Ruby | lisbethmarianne/sorting | /insertion_sort.rb | UTF-8 | 938 | 4.1875 | 4 | [] | no_license | # Insertion Sort
# 1. First number is sorted
# 2. Take out unsorted item and compare to sorted items beginning with biggest number, increase index of sorted number if unsorted number is smaller then sorted number, otherwise insert unsorted number
# 3. Take next unsorted item and so on
require "minitest/autorun"
def i... | true |
3b0a3eca53472411fc3a6ac75088cb82392279ed | Ruby | quintel/etlocal | /app/services/csv_importer/schema.rb | UTF-8 | 1,445 | 2.84375 | 3 | [
"MIT"
] | permissive | class CSVImporter
# Describes the headers provided in the data CSV file and decides which
# headers are mandatory depending on whether new regions are being created.
class Schema
# Internal: The list of headers specified in the CSV file.
attr_reader :provided_headers
# Public: Creates a new Schema.
... | true |
bc0a2dfd888ec932c93ffa97aa29516326f540b3 | Ruby | ludwiggj/ruby-pickaxe | /ch07-regular-expressions/16_conditional_groups.rb | UTF-8 | 4,239 | 3.515625 | 4 | [] | no_license | # Say you were validating a list of banquet attendees:
# Mr Jones and Sally
# Mr Bond and Ms Moneypenny
# Samson and Delilah
# Dr Jekyll and himself
# Ms Hinky Smith and Ms Jones
# Dr Wood and Mrs Wood
# Thelma and Louise
# The rule is that if the first person in the list has a title, then so should the second. This ... | true |
1a7a4af4d448e5eb058d2576d481486fa655d7b2 | Ruby | merunga/ejemplo-scraping-datosperu | /crawl.rb | UTF-8 | 1,049 | 2.875 | 3 | [
"MIT"
] | permissive | require 'harvestman'
base_url = "http://www.datosperu.org/" # papina principal
crawl_url = base_url+"ep-otras-asociaciones-ncp-91993-pagina-*.php" #plantilla se paginas a visitas
Harvestman.crawl crawl_url, (1..2) do # vamos a visitar solo las paginas 1 y 2:
# http://datosperu.org/ep-otras-asociaciones-ncp-91993-pagi... | true |
9d4616b82ca2c7a54888c811c5b3cdaad4478f07 | Ruby | mriddle/dotfiles | /shell/scripts/check_rails_dependencies | UTF-8 | 2,650 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'bundler/setup'
require 'optparse'
require 'rainbow'
require 'set'
class RailsBumpHelper
RAILS_DEPENDENCIES = ["actioncable", "actionmailbox", "actionmailer", "actionpack", "actiontext", "actionview", "activejob", "activemodel", "activerecord", "activestorage", "activesupport", "railties"... | true |
b2597c797961957b8b4c14d5a1804de1d742e89e | Ruby | mindreframer/elasticsearch-stuff | /github.com/pawelrychlik/duplitector/lib/duplitector/test_data.rb | UTF-8 | 673 | 3.09375 | 3 | [] | no_license | require_relative 'org_helper'
class TestData
def initialize(log)
@log = log
end
def read_organizations(filename, n = nil)
def limits_exceeded(counter, n)
!n.nil? && counter >= n
end
def prepare_test_data(filename)
file = File.new(filename, 'r')
# skip headers:
file.get... | true |
a9857a68773056ce9136c64c7b356fb8934c8567 | Ruby | fcastellanos/miniparser | /lib/miniparser.rb | UTF-8 | 3,081 | 3.5 | 4 | [
"MIT"
] | permissive | require 'miniparser/version'
require 'ostruct'
class Miniparser
attr_accessor :config_file,
:return_type
def initialize config_file, return_type = :open_struct
@config_file = config_file
@return_type = return_type
end
def parse
if File.readable? config_file
import_file
e... | true |
f2c2d7f5d9dbc4ed698c5e8d767648c6d9af4c87 | Ruby | AgileTrossDev/nacap | /cache_app/app/controllers/cache_manager.rb | UTF-8 | 657 | 2.59375 | 3 | [] | no_license | # Wraps an instance of a cache and makes it a singleton
# TODO: Fix loadpath
require 'singleton'
require_relative '../../../lib/cache'
require_relative '../../../lib/db_mgr'
class CacheManager
include Singleton
def initialize
# TODO: Make configurable/Pull from environment
db = DbMgr.new('nacap_demo... | true |
9c8f13f9704c7c2f81b5b19d1d5190bffc6eaee2 | Ruby | Shopify/semian | /examples/colors.rb | UTF-8 | 1,037 | 2.96875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class String
def black; "\e[30m#{self}\e[0m" end
def red; "\e[31m#{self}\e[0m" end
def green; "\e[32m#{self}\e[0m" end
def brown; "\e[33m#{self}\e[0m" end
def blue; "\e[34m#{self}\e[0m" end
def magenta; "\e[35m#{self}\e[0m... | true |
972ad5a1b308c04e4b3048495b441b289a8b7553 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/5de488fd705b49238e7a03c9e2946b99.rb | UTF-8 | 308 | 3.890625 | 4 | [] | no_license | class Hamming
def self.compute(strand1,strand2)
distance = 0
@strand1 = strand1.chars
@strand2 = strand2.chars
@c = 0
while @c < strand1.length && @c < strand2.length
if strand1[@c] != strand2[@c]
distance += 1
end
@c += 1
end
distance
end
end
puts Hamming.compute("abc","adc")
| true |
a843e83cb8ec85702fdfe71ada4479286293bbd2 | Ruby | andreybakanovsky/homeworks-2021 | /HW03/Pavel_Shalyga/pavel_shalyga_hw_03_t_02.rb | UTF-8 | 980 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
DATE = %r{\d+/[A-z]+/\d+:+\d+:+\d+:+\d+\s+\+\d+}.freeze
FROM = /^\d+\.\d+\.\d+\.\d+/.freeze
TO = %r{/\w+/\w+/\w+}.freeze
FORMAT = %r{^\d+\.\d+\.\d+\.\d+ - - \[\d+/[A-z]+/\d+:+\d+:+\d+:+\d+\s+\+\d+\] "POST /\w+/\w+/\w+ HTTP/1\.1"}.freeze
def task2(input_string)
lines_array = input_strin... | true |
3aa9d1ebba03eeb0d94f27c3fc84f347307cc65a | Ruby | mmrobins/Greplin-Challenge | /lvl2.rb | UTF-8 | 1,091 | 4.25 | 4 | [] | no_license | class Integer
# Sieve of Eratosthenes
def primes_less_than
numbers_to_test = (3..self).step(2).map {|x| x}
primes = []
i = 1
# only need to test to the sqrt of the number since nothing larger than the sqrt could possibly divide
while i < Math.sqrt(self)
i = numbers_to_test.shift
prim... | true |
30dcf3ef54c7ab99a95bc4e98d2c1de61372f8b5 | Ruby | roseliux/daily-coding-problem | /problem_3.rb | UTF-8 | 1,081 | 3.6875 | 4 | [] | no_license | # This problem was asked by Google.
# Given the root to a binary tree, implement serialize(root), which serializes the tree into a string,
# and deserialize(s), which deserializes the string back into the tree.
# For example, given the following Node class
# class Node:
# def __init__(self, val, left=None, right... | true |
2c3e34f86c6068adb661fbca1765c52a73f1784a | Ruby | progmas/birthday-paradox | /app/helpers/application_helper.rb | UTF-8 | 528 | 2.609375 | 3 | [] | no_license | module ApplicationHelper
def generate_date(quantity)
generated_dates = []
quantity.times do
generated_dates << rand(Date.new(1900, 1, 1)..Date.new(2100, 12, 31))
end
result_days = Array.new(7, 0)
generated_dates.each do |day|
result_days[day.wday] = result_days[day.wday].to_i + 1
... | true |
e38032e8e81dc6ed99dc30b11996c621df8766fe | Ruby | boudejo/lookatrails | /vendor/plugins/app_config/lib/app_config.rb | UTF-8 | 1,224 | 2.9375 | 3 | [] | no_license | require 'erb'
require 'yaml'
class AppConfig
def initialize(file = nil)
@sections = {}
@params = {}
use_file!(file) if file
end
def use_file!(file)
begin
hash = YAML::load(ERB.new(IO.read(file)).result)
@sections.merge!(hash) {|key, old_val, new_val| (old_va... | true |
7ea33671f8537973443839bf95aaa54476a1be46 | Ruby | nicolecpeoples/intro_to_ruby | /fundamentals/demos/arrays.rb | UTF-8 | 387 | 3.640625 | 4 | [] | no_license | #array functions
[]
a = ["Matt", "Nicole", "Kyle", "Caitlin", "Jewel"]
b = [5,7,3,4,8,5,6,9,1,3,1,4]
c= ["Nicole", 9]
# puts a[3]
# puts a+ b
# puts (a + b).join(" ")
# puts (a+b).to_s
# puts (a+b) -c
# puts b.class
# puts b.shuffle.join("-")
a.delete("Kyle")
puts a
puts a.length
#push
#pop
#join
#reverse
#shuffle
... | true |
73de259ff0dc4951aec312d9a246a62c422469b6 | Ruby | morszczuk/advent-of-code | /solutions/aoc_2022/day_4/puzzle_4.rb | UTF-8 | 347 | 2.609375 | 3 | [] | no_license | module Aoc2022
module Day4
class Puzzle4 < ::Aoc::PuzzleBase
def initialize
@pairs = []
end
def solve
raise 'Not defined'
end
def handle_input_line(line, *_args)
@pairs << line.split(',').map { |s| s.split('-').map(&:to_i) }
end
def unit_tests
... | true |
841b44d906f6103bcda77bae7a230dff9a74c0fe | Ruby | deep-cover/deep-cover | /core_gem/spec/has_child_spec.rb | UTF-8 | 2,716 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'spec_helper'
module DeepCover
module Node::Mixin
class Parent
attr_reader :children
include HasChild
# Make all private methods public for testing purposes
class << self
public(*HasChild::ClassMethods.private_instance_methods(false)... | true |
e78e7f78336c98b9fed58534ee812ed3cfacc884 | Ruby | santiagosendon/todo-ruby-basics-dumbo-web-082718 | /lib/ruby_basics.rb | UTF-8 | 340 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
num1 = 12 / num2= 2
end
def assign_variable(value)
value = "Bob"
end
def argue(argue)
argue
end
def greeting(greeting, name)
end
def return_a_value
value = 'Nice'
end
def last_evaluated_value
return value = "expert"
end
def pizza_party(toppings ='cheese')
puts topping = 'pepp... | true |
b7bee11b7063cafd129a21537cf849371fde99a1 | Ruby | gaotongfei/madan | /lib/madan/file_parser.rb | UTF-8 | 313 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'pry'
module Madan
class FileParser
ALLOWED_EXTENSIONS = %w(.md .markdown)
def initialize(path)
@path = path
@md = Madan::MdUtils.new
end
def parse
contents = ""
if File.file?(@path)
contents = File.read(@path)
end
contents
end
end
end | true |
dbd2003438c48df3892dc35381a7fb939d6ad341 | Ruby | tadeusrox/euler_project | /champernowne.rb | UTF-8 | 224 | 3 | 3 | [] | no_license | digit = ""
i = 1
size = 1
while digit.length < 1000000
digit += i.to_s
i += 1
end
puts i
puts digit[0].to_i * digit[9].to_i * digit[99].to_i * digit[999].to_i * digit[9999].to_i * digit[99999].to_i * digit[999999].to_i | true |
450c7aeacd467be207e18265a422621fe553dc07 | Ruby | Scott-Borecki/enigma | /spec/cracker_spec.rb | UTF-8 | 4,561 | 3.203125 | 3 | [] | no_license | require 'date'
require_relative 'spec_helper'
require_relative '../lib/cracker'
require_relative '../lib/key'
require_relative '../lib/key_cracker'
require_relative '../lib/offset'
RSpec.describe Cracker do
before :each do
@cracker = Cracker.new('vjqtbeaweqihssi', '291018')
@cracker1 = Cracker.new('wbtrcxduf... | true |
b5965f6ef4bd0d907442ba2774ba4dc9612514d8 | Ruby | mikevanholst/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 598 | 3.8125 | 4 | [] | no_license | def echo(input)
input
end
def shout(input)
input.upcase
end
def repeat(input, num = 2)
output = input
(num -1).times do
output = output + " " + input
end
return output
end
def start_of_word(input,n)
input[0,n]
end
def first_word(input)
input.split( " ")[0]
end
def titleize(input)
# return "Jaws... | true |
6554c5f43fe51ec7bfc7fbc858ea61d28cabf3ee | Ruby | louissalin/event_source | /lib/event_source/event_repository.rb | UTF-8 | 2,537 | 2.625 | 3 | [
"MIT"
] | permissive | require 'sequel'
module EventSource
class EventRepository
extend EventSource::MemoizeInstance
attr_reader :db
def initialize(options)
if options[:in_memory]
@db = Sequel.sqlite
init_in_memory_schema
end
if options[:connect]
con = options[:connect][:connection... | true |
50aa7299cde955e74bb5f883b937fb59a20aa450 | Ruby | DovileSand/takeaway-challenge | /spec/restaurant_spec.rb | UTF-8 | 1,359 | 3.046875 | 3 | [] | no_license | require 'restaurant'
describe Restaurant do
subject(:restaurant) {described_class.new(menu: menu, order: order, sms: sms, config:{})}
let(:menu) {double(:menu, print: printed_menu)}
let(:order) {instance_double("Order", total: 15.50)}
let(:sms) {instance_double("Sms", deliver: nil)}
let(:printed_menu) {"Chi... | true |
ff7f8ee131fb721bc217fa826ef3722ff21d2ff8 | Ruby | rahulshinde100/data | /Rahul/untitled folder 2/Rspec/Testapp/spec/models/student_spec.rb | UTF-8 | 730 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Student, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# describe Student do
# it "is valid with a name, class and age" do
# student = Student.new(name: "dhanashri",classs: "MCA" , age: "23")
# expect(student).to be_valid
# end
#... | true |
a58ac5c1703a7857b5db62c997347fb181a9e5ef | Ruby | jduff/spaceship | /behaviors/evade.rb | UTF-8 | 459 | 2.59375 | 3 | [] | no_license | class Evade < Flee
def initialize(target)
super(target)
@pursuing_vehicle = target
end
def calculate(time, object)
to_pursuer = Vector2d(@pursuing_vehicle) - Vector2d(object)
pursuer_vel = Vector2d.new(@pursuing_vehicle.vel_x, @pursuing_vehicle.vel_y)
look_ahead_time = to_pursuer.len... | true |
a0d7146692aa50d3e3c645b38cdf5d6507c016d7 | Ruby | felipekari/D011_Arreglos_y_Archivos | /grafico.rb | UTF-8 | 217 | 3.265625 | 3 | [] | no_license | data = [5, 3, 2, 5, 10]
def chart(arr)
arr.each do |l|
puts "|" + "**" * l
end
puts ">" + "--" * arr.max
arr.max.times do |n|
print " #{n+1}"
end
print ""
end
puts chart(data) | true |
3a204fbd1a2e158928b0a750beb474f04a305654 | Ruby | Meridion87/E6CP1A1 | /2 ciclos/ejercicio3.rb | UTF-8 | 158 | 3.78125 | 4 | [] | no_license | # Mostrar todos los divisores del número 990 con:
# while, for, times.
i = 1
while i <= 900
puts "#{i} es divisor de 990" if 900 % i == 0
i += 1
end
| true |
f12b63be15ffe6b1b30684f3d181a0507a00456a | Ruby | JureStabuc/Mariboring | /friends.rb | UTF-8 | 604 | 3.40625 | 3 | [] | no_license | def friends
puts "You're a good friend."
puts "The gang awaits you with a female company."
puts "But the girls want to dance"
puts "Go inside to speak to the DJ or hang outside?"
prompt()
next_action = gets.chomp()
if next_action.include? "speak"
return :inside
elsif n... | true |
1c9cb3f2eb292c8262aa31ee1595dd29832a1101 | Ruby | AgileInstitute/labs-ruby-rspec | /MessTrek/lib/untouchables/web_gadget.rb | UTF-8 | 279 | 3.578125 | 4 | [
"MIT"
] | permissive | class WebGadget
def initialize(stuff)
@stuff = stuff
end
def parameter(parameter_name)
variable(parameter_name)
end
def variable(variable_name)
@stuff[variable_name]
end
def write_line(message)
puts(message)
end
end
| true |
bbcbed6c36415e76eedb2307ae2f46167bf73108 | Ruby | kchien/kindle-your-highlights | /lib/kindle-your-highlights.rb | UTF-8 | 5,404 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'mechanize'
require 'nokogiri'
require 'erb'
require 'date'
require 'kindle-your-highlights/kindle_format'
class KindleYourHighlights
attr_accessor :highlights, :books
DEFAULT_PAGE_LIMIT = 1
DEFAULT_DAY_LIMIT = 365 * 100 # set default as 100 years
DEFAULT_STOP_DATE ... | true |
7f23f951f48808ef844dbd26f53643af94e97528 | Ruby | ygorshenin/nacloud | /prototype/lib/algo/glpk_mdmknapsack.rb | UTF-8 | 5,917 | 3.046875 | 3 | [] | no_license | # Author: Yuri Gorshenin
# Algorithm solves Multidimensional Multiple Knapsack problem with GLPK.
# Algorithm generates two files for model and data, then calls glpsol utility.
# After that, script parses output file and retrieves allocation
# Model file looks like:
# set Items;
# set Dimensions;
# set Knapsacks;
# ... | true |
90866d8dfe82ee5b1ec6d0fb4802829ef35f0ab4 | Ruby | kylecoberly/hayk-assessment-the-bachelor | /lib/bachelor.rb | UTF-8 | 2,305 | 3.953125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry';
#Helper Method => Returns the season array after given the entire data structure and season.
def find_correct_season (data, season)
data.select { |data|
data.to_s === season;
}
end
def collect_contestants (data)
all_contestants = [];
data.map { |season, contestants|
contestants.map {... | true |
8757b329c69baff6da27ed55b4fa878339c89a9b | Ruby | liccoCode/elcuk3 | /rubys/sellingrecord.rb | UTF-8 | 514 | 2.625 | 3 | [] | no_license | require "active_support/core_ext"
# 1. 设置时间天数
Time::DATE_FORMATS[:date] = "%Y-%m-%d"
def recaculate_records(begin_date, times)
times ||= 3
times.times do |i|
cmd = "curl http://localhost:9000/login/job?date=#{(begin_date + i.days).to_s(:date)}"
`#{cmd}`
end
end
# 前 30, 29, 28 天
start = Time.now - 30.day... | true |
03f41762f83dd271b3804fd22216444aafb5acd9 | Ruby | techtronics/necromancy | /spec/necromancy_spec.rb | UTF-8 | 673 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'necromancy'
class TestStr < String
def f
TestStr.new upcase
end
def g(x)
TestStr.new self + x
end
end
describe Necromancy do
let(:l) { described_class.new }
shared_examples_for "a Necromancy" do
example { proc(&l.f).(r).should == r.f }
example { proc(&l.g(x)).(r).should == r... | true |
96b2d975223d75e963da13ad8500d9f560628d8f | Ruby | AJAYJAITWAL/Ruby_programs | /advance/untill_statments.rb | UTF-8 | 214 | 3.484375 | 3 | [] | no_license | # Define untill statement
i = 0
until i>5 do # This statement is apposite to while so condition in false then you will run but the condition is false the loop is over
print i," "
i+=1
end
puts " " | true |
935d16be4cf857bc42b20e47d3c4a8d14246b1a4 | Ruby | cornet/nanoc-by-lifepillar | /commands/create-post.rb | UTF-8 | 1,233 | 2.828125 | 3 | [] | no_license | usage 'create-post <title>'
aliases :post
summary 'Create a new blog post'
description 'Create a new blog post.'
option :a, :author, 'author name', :argument => :optional
option :f, :filename, 'file name (without suffix)'
flag :m, :md, 'append .md suffix (Markdown)'
flag :M, :mmd, 'append ... | true |
bee4cce906c0e74ae11fefb1b350a3ca1075db5c | Ruby | d-atkins/date_night | /lib/node.rb | UTF-8 | 397 | 3.46875 | 3 | [] | no_license | class Node
attr_reader :info
attr_accessor :left_child, :right_child
#TO DO: refactor score/title into a single hash (one element)
def initialize(score, title)
@info = {title: title, score: score}
end
def set_child(child)
if child.info[:score] < info[:score]
@left_child = child
elsif chi... | true |
b5a733d27434dec94b3e724f7fe0dc89a7ecf76a | Ruby | DanL12186/cli-new-movies | /lib/new_movies/cli.rb | UTF-8 | 1,832 | 3.453125 | 3 | [] | no_license | class NewMovies::CLI
def call
NewMovies::Movie_Scraper.namescrape #was handled by the @@all ||= scrape in the example. Probably shouldn't *really* have this here, but...
movie_list #x. Movie (Genre)
display_movie_details
puts "\nGoodbye!"
end
def movie_list
puts
puts "############### Mo... | true |
77eb47d2f1942f59c0ef78da525aff611d18ef3a | Ruby | kkavita92/advent-of-code | /2017/ruby/day2/day2_part1.rb | UTF-8 | 231 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
file_path = File.expand_path("../spreadsheet_input.txt", __FILE__)
input = File.read(file_path)
p input.split("\n")
.map{ |row| row.split("\t").map(&:to_i) }
.map { |row| row.max - row.min }
.reduce(:+)
| true |
f3fcd8ab7308e9de5bcbede374db7561b29d4109 | Ruby | jraiford1/conrad_filer | /lib/conrad_filer/rule.rb | UTF-8 | 804 | 2.671875 | 3 | [] | no_license | require 'conrad_filer/db'
require 'inotify'
module ConradFiler
# A rule describes an action to perform on a file that matches one of its defined id types
class Rule
attr_accessor :db_rec
def initialize(db, a_hash)
@db_rec = a_hash
end
def get_watch_job_names
@db_rec['WATCH_JOBS']
... | true |
bfbc115df017bcedda1f50e096790db21589d3d7 | Ruby | ebologger/algorithm | /hackerrank/challenges/ruby_solutions/solutions/fairy_chess.rb | UTF-8 | 2,058 | 2.875 | 3 | [] | no_license | MODULO = 1000000007
time1 = 0
time2 = 0
time3 = 0
def deep_copy(array)
aaa = Time.now
return Marshal.load( Marshal.dump(array) )
time2 += Time.now - aaa
end
File.open('C:\projects\algorithm\hackerrank\challenges\ruby_solutions\input.txt', 'r') do |f1|
t = f1.gets.strip.to_i
t.times do
aaa = Ti... | true |
6e4a435acdad582f4b01aeb901a042b6b00d99d4 | Ruby | etdev/algorithms | /0_code_wars/left_and_right.rb | UTF-8 | 370 | 3.765625 | 4 | [
"MIT"
] | permissive | # http://www.codewars.com/kata/left$-and-right$/
# --- iteration 1 ---
def left(str, i = nil)
if i.nil?
return str[0]
elsif i.is_a?(String)
return str.split(i).first
elsif i > 0
return str[0...i]
elsif i < 0
return str[0...(str.size + i)]
end
""
end
def right(str, i = nil)
left(str.revers... | true |
aa5e250610293c63062c484b16ecbbc9d03ad63d | Ruby | bandilaxmangoud/UnitTest | /lib/helpers/my_helper.rb | UTF-8 | 202 | 2.546875 | 3 | [] | no_license | module MyHelper
end
class Array
# array filter extension
def filter(hash)
name_sym = hash.keys.first.to_sym
result = self.find { |item| item[name_sym] == hash[hash.keys.first] }
end
end
| true |
f2822136f030a325a90654a0f0d9e48aa5ae4e90 | Ruby | NirvairGill/Ruby-book-codes | /Exercises/Exercise_13.rb | UTF-8 | 343 | 3.71875 | 4 | [] | no_license | #Using the hash you created from the previous exercise, demonstrate how you would access Joe's email and Sally's phone number?
contacts = {"Joe Smith"=>["joe@email.com", "123 Main st.", "555-123-4567"], "Sally Johnson"=>["sally@email.com", "404 Not Found Dr.", "123-234-3454"]}
# Joe's Email:
p contacts["Joe Smith"][0... | true |
8130e5a90e9c6a82d7a5f4990c908ced59565486 | Ruby | grandison/my_active_record | /lib/my_active_record/base.rb | UTF-8 | 1,449 | 2.546875 | 3 | [] | no_license | require 'rubygems'
require 'active_support/all'
require 'my_active_record/associations'
module MyActiveRecord
class Base
extend ActiveSupport::DescendantsTracker
extend Associations
def initialize(params = {})
params.each do |key, value|
self[key] = value
end
self
end
... | true |
0848eadcb9f66bbe434fe4485f3b4ee26c2fea1b | Ruby | snehaso/card-game | /src/dealer.rb | UTF-8 | 806 | 3.5 | 4 | [] | no_license | class Dealer
def initialize player1, player2
@player1 = player1
@player2 = player2
end
def distribute stack
stacks = stack.split_into_two
@player1.assign_stack(stacks.first)
@player2.assign_stack(stacks.last)
end
def find_winner
saved_cards = []
while (!@player1.cards_finished? ... | true |
88e55dd2ee692d56aab50f87e4580c664b7f9bd9 | Ruby | xarses/fuel-library | /deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb | UTF-8 | 4,194 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | require 'pp'
require 'timeout'
require 'net/http'
require 'open-uri'
require 'uri'
Puppet::Parser::Functions::newfunction(:url_available, :doc => <<-EOS
The url_available function attempts to make a http request to a url and throws
a puppet error if the URL is unavailable. The url_available function can take
up to tw... | true |
dba2c241ef536436f67964f273d4fb41c0119bae | Ruby | blablo/corobook | /app/models/group.rb | UTF-8 | 446 | 2.515625 | 3 | [] | no_license | class Group < ActiveRecord::Base
attr_accessible :name
has_many :users
def add_to_group(user, role = 1)
usergroup = UserGroup.new(:user_id => user.id, :group_id => self.id)
if self.user_groups.empty?
usergroup.role = 9
else
usergroup.role = role
end
if !has_user?(user)
use... | true |
f901067d939c40c66f9d317d35faa01306539ecc | Ruby | masayasviel/algorithmAndDataStructure | /from51to100/ABC65/mainA.rb | UTF-8 | 150 | 3.21875 | 3 | [] | no_license | x, a, b = gets.chomp.split(" ").map(&:to_i)
if b - a <= 0 then
puts "delicious"
elsif b- a <= x then
puts "safe"
else
puts "dangerous"
end | true |
5f54c3514a7ecd95fbdd697f12171c38f5cbf32d | Ruby | Maudulus/fibonacci | /fibonacci.rb | UTF-8 | 532 | 3.5625 | 4 | [] | no_license | require 'benchmark'
def fibonacci(nth_number)
previous_number = 0
prev_holder = ""
fibonacci = 1
(nth_number - 1).times do |double_number_size|
prev_holder = fibonacci
fibonacci += previous_number
previous_number = prev_holder
end
puts fibonacci
end
puts Benchmark.measure { fibonacci(10... | true |
008c6ca198760e5df6ca3e6cb565ad55b5283880 | Ruby | davidrajnus/Algorithms-In-Ruby | /fromlast/linkedlist.rb | UTF-8 | 2,450 | 3.640625 | 4 | [] | no_license | # Implement classes Node and Linked Lists
# See 'directions' document
class Node
attr_accessor :data, :next
def initialize(data, next_int = nil)
@data = data
@next = next_int
end
end
class LinkedList
attr_accessor :head
def initialize
@head = nil
end
def insertFirst(data)
self.hea... | true |
be0286f49961152748907498f6739763201dea98 | Ruby | mech/filemaker-ruby | /lib/filemaker/model/relations/proxy.rb | UTF-8 | 1,578 | 2.640625 | 3 | [
"MIT"
] | permissive | module Filemaker
module Model
module Relations
# A proxy is a class to send all unknown methods to it's target. The
# target here will be the eventual associated model.
class Proxy
instance_methods.each do |method|
undef_method(method) unless
method =~ /^(__.*|send|... | true |
b4c386ffacc772abc41fda12f09099abb0168108 | Ruby | chaitanya2ivvala/zendriix | /edit_this_file.rb | UTF-8 | 323 | 3.28125 | 3 | [] | no_license | class HelloWorld
def initialize(name)
@name = name.capitalize
end
# working here
def say_hi
puts " from alex Hello #{@name}!"
end
# TODO: Remove this comment and the method below.
def say_bye
puts " From alex Good-bye #{@name}!"
end
def bob_function()
puts "Hello #{@name}!"
end
e... | true |
1bec45ccfe9286dd76c3365ce0c79b02204d354c | Ruby | meine-buecherei/meine-buecherei.github.io | /src/db_extract.rb | UTF-8 | 6,230 | 2.640625 | 3 | [] | no_license | # TOP 100-Listen aus der Datenbank extrahieren und als JSON-Dateien für den Zugriff durch die App generieren
require 'yaml'
require 'json'
require 'odbc_utf8'
require 'dbi'
# Datensatz in Hash umwandeln (Attributnamen wie in der App)
def row2book(row)
media_type = case row['mcode']
when 1
'book'
wh... | true |
5098be9b2b188af26f738bdc51acd0565c47936d | Ruby | ohboyd/code_challenges | /18_palindrome.rb | UTF-8 | 1,210 | 4.34375 | 4 | [] | no_license | # Palindrome Substrings
# Given a string, write a method to count the palindromic substrings.
# Example 1
# Input: "abc"
# Output: 3
# Explanation: Three palindromic strings: "a", "b", "c".
# Example 2
# Input: "aaa"
# Output: 6
# Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
# solution ... | true |
99666d4c5ea2808a9dea562c9ee2d518cf813539 | Ruby | dextermoran/phase-0 | /week-6/pairing/nested_data_solution.rb | UTF-8 | 2,048 | 3.984375 | 4 | [
"MIT"
] | permissive | # RELEASE 2: NESTED STRUCTURE GOLF
# Hole 1
# Target element: "FORE"
array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]]
#3 attempts:
# ============================================================
#array.each { |x| puts x}
p array[1][1][2][0]
# ============================================================... | true |
bdc54f4fdd3436f0723beecb9af90099816cdb4c | Ruby | popmedic/popmedia | /server/requires/cfg.rb | UTF-8 | 730 | 2.765625 | 3 | [] | no_license | require "rexml/document"
class Cfg
def initialize cfgpath
@cfgpath = cfgpath
f = File.new @cfgpath
@xml = REXML::Document.new f
if(@xml == nil)
raise "UNABLE TO OPEN \"%s\" (%s)" % [@cfgpath, self.class.name]
end
f.close
end
def xml
return @xml
end
def get(key, dflt='')
key = "/configuration/" ... | true |
b7a35c1d980aa5258a3de65025fb8f66915e0054 | Ruby | GunioRobot/soap4rUI | /test/unit/tc_loading_saving.rb | UTF-8 | 7,079 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'test/unit'
require 'mocha'
require File.dirname(File.expand_path(__FILE__)) + '/../../lib/sinatra_app_helpers'
class TC_LoadingSaving < Test::Unit::TestCase
def setup
@client_folder = Dir.pwd + "/test/fixtures/client_namespace"
@test_client_folder = Dir.pwd + "/test/fixtures/t... | true |
1f2a7331b94150b0e8836415db0b78d4e6769b8c | Ruby | drumguy16/phase-0 | /week-4/good-guess/my_solution.rb | UTF-8 | 164 | 3.1875 | 3 | [
"MIT"
] | permissive |
# Good Guess
# I worked on this challenge [by myself, with: ].
def good_guess?(integer)
if integer == 42
p true
else
p false
end
end
# Your Solution Below | true |
1a83a30ce48d18ddd291f5cde270b478f6e9a69f | Ruby | aimzatron/linked_list | /specs/link_spec.rb | UTF-8 | 1,507 | 3.046875 | 3 | [] | no_license | require './link'
describe Link do
before(:each) do
@link = Link.new('a')
end
it "stores a value" do
expect(@link.value).to eq 'a'
end
it "adds an element" do
b = @link.add('b')
expect(b.head).to eq @link
expect(@link.tail).to eq b
end
it "returns the tail e... | true |
a764c8a40ef90e5e0e54a5b20161ddb5ac5e0e5b | Ruby | ayanko/async-http | /lib/async/http/body/slowloris.rb | UTF-8 | 2,764 | 2.515625 | 3 | [
"MIT"
] | permissive | # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to us... | true |
5f9aca499d279005f84147d1e1b4e16ef8aefaeb | Ruby | boberetezeke/acts_with_metadata | /lib/acts_as_metadata_crud_controller.rb | UTF-8 | 19,696 | 2.609375 | 3 | [
"MIT"
] | permissive | module ActionController
class Base
#
#
# acts_as_metadata_crud_controller
#
# Basic Usage:
#
# class WidgetController < ActionController::Base
# acts_as_metadata_crud_controller Widget
# end
#
# Extended Usage (modifications of basic functionality
#
# Its functionality can be extended by... | true |
155cace78b1379739db2831c79e915273f14a93a | Ruby | lorenzocovarrubiasjr/apples-and-holidays-v-000 | /lib/holiday.rb | UTF-8 | 2,177 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
holiday_supplies = {
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
:summer => {
:fourth_of_july => ["Fireworks", "BBQ"]
},
:fall => {
:thanksgiving => ["Turkey"]
},
:spring => {
:memorial_day => ["BBQ"]
}
}
def second_supply_for_four... | true |
3bbcc8dc2c31596e8fd5ce3cf7aac3b6df97045c | Ruby | drhenner/angel_deck | /lib/tasks/add_country_states.rake | UTF-8 | 1,950 | 2.953125 | 3 | [
"MIT"
] | permissive | # adds a coutries' specific states or provinces to the DB
# Look in Rails.root + "db/seed/international_states for the countries you can add.
#
# @usage rake db:add_states country=brazil
namespace :db do
task :add_states => :environment do
unless ENV.include?("country")
puts 'you need to add a country para... | true |
ac2c58fdb391a38b63a4644e26e36386c2c18c44 | Ruby | kknd113/code | /medium/rotated_array_search.rb | UTF-8 | 908 | 3.9375 | 4 | [] | no_license | # Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
#
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
#
# You are given a target value to search. If found in the array return its index, otherwise return -1.
#
# You may assume no duplicate exists in the array.
# @par... | true |
8648a30194d74ddeef89cfca065352045a29dd75 | Ruby | eedrummer/hData-ruby-parser | /lib/section_base.rb | UTF-8 | 1,694 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | class SectionBase
attr_accessor :information_source, :narrative
# Adds a namespace and prefix to Nokogiri, also used
# to record the main namespace of an hData section
def self.section_namespace(prefix, uri)
@section_namespace_prefix = prefix
@section_namespace_uri = uri
namespace(prefix, uri)
... | true |
90247c8984ef1eba1298d739cd1ca4879002a937 | Ruby | rryand/mastermind_ruby | /modules/colorize_text.rb | UTF-8 | 334 | 2.84375 | 3 | [] | no_license | module ColorizeText
COLORS = {
"1" => "\e[44m 1 \e[0m",
"2" => "\e[41m 2 \e[0m",
"3" => "\e[43m 3 \e[0m",
"4" => "\e[42m 4 \e[0m",
"5" => "\e[45m 5 \e[0m",
"6" => "\e[46m 6 \e[0m",
"*" => "\e[104m \e[30m* \e[0m",
"!" => "\e[104m \e[30m! \e[0m"
}
def colorize(string)
COLORS[str... | true |
8bcb30de5c56a2cbd6bcc660a6e557922599ea83 | Ruby | soundsnick/rate-bot | /controllers/Notification.rb | UTF-8 | 1,099 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'cgi'
require_relative '../db/ORM'
require_relative './Controller'
require_relative '../models/User'
require_relative '../models/History'
class Notification < Controller
# description: HTTP service controller that handles XHR and sends notification to user
def self.add(bot, token, email, text)
if not... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.