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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1cc2d1f3bc8805f35de8de3b3e0934a5a507e6af | Ruby | skyraseal/cp-learn-to-program | /ch7/leapyears.rb | UTF-8 | 738 | 4.0625 | 4 | [] | no_license | ### Receive input ###
while true
puts "Welcome to the leap year calculator. Please input the starting year:"
first_year = gets.chomp.to_i
puts "Please input the ending year:"
last_year = gets.chomp.to_i
if last_year >= first_year
break
else
puts "Invalid entries: Your ending year must be later than... | true |
6d02666b2bdffa0eefe063b77204614fecf41bab | Ruby | matbat99/medium_scraper_reader | /post.rb | UTF-8 | 262 | 2.828125 | 3 | [] | no_license | class Post
attr_reader :path, :author, :title, :text_body, :read
attr_writer :read
def initialize(path, author, title, text_body, read = false)
@path = path
@author = author
@title = title
@text_body = text_body
@read = read
end
end
| true |
3b501ea245403a6d9639a3a5965eefe704dcc960 | Ruby | alphagov/content-publisher | /app/services/withdraw_document_service.rb | UTF-8 | 1,745 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | class WithdrawDocumentService
include Callable
def initialize(edition, user, public_explanation:)
@edition = edition
@public_explanation = public_explanation
@user = user
end
def call
edition.document.lock!
check_withdrawable
withdrawal = build_withdrawal
update_edition(withdrawal)... | true |
1452c7cab641dce80c912c0d5b07195df605071d | Ruby | zhchsf/jd_pay | /lib/jd_pay/util/des3.rb | UTF-8 | 1,703 | 2.921875 | 3 | [
"MIT"
] | permissive | module JdPay
module Util
# 京东支付 des3 加解密,掺杂了京东自定义的一些位转移逻辑
class Des3
def self.encrypt(source, base64_key)
key = Base64.decode64(base64_key)
transformed_source = transform_source(source.bytes)
des = OpenSSL::Cipher::Cipher.new('des-ede3')
des.encrypt
des.key = key... | true |
7e34abe67940190d31931e49931b862cc9d6e516 | Ruby | codystair/ruby_small_problems | /Easy_8/03.rb | UTF-8 | 845 | 4.34375 | 4 | [] | no_license | =begin
input: string
output: array
rules:
- will return array of all substrings in array
- substrings will always begin with first character of string
- subs should be in order from shortest to longest
examples:
substrings_at_start('abc') == ['a', 'ab', 'abc']
substrings_at_start('a') == ['a']
substrings_at_start('xyz... | true |
2c2ba8c3f4a57d38ae0ee324c070911ac5e274d2 | Ruby | ftt9282/chess | /lib/chess/queen.rb | UTF-8 | 552 | 3.625 | 4 | [] | no_license | module Chess
class Queen < Piece
attr_reader :color, :symbol
attr_accessor :position
# grab the attributes from Piece class and assign symbol
def initialize(color, position)
super
@color == "white" ? @symbol = "♕" : @symbol = "♛"
end
# lists all moves and then returns the o... | true |
fd07e784ddbc176a412f675449ff0e5fcef16f91 | Ruby | bmitchellblurb/flux-hue | /lib/flux_hue/discovery/ssdp.rb | UTF-8 | 1,459 | 2.515625 | 3 | [
"MIT"
] | permissive | module FluxHue
module Discovery
# Helpers for SSDP discovery of bridges.
module SSDP
def ssdp_scan!
setup_ssdp_lib!
Playful::SSDP
.search("IpBridge")
.select { |resp| ssdp_response?(resp) }
.map { |resp| ssdp_extract(resp) }
end
# Loads the Play... | true |
730f65e7a373dd8fd4d09d5623118065a2f2a7d1 | Ruby | mkrahu/launchschool | /exercises/small_problems/vers3/easy_2/sum_prod_consec_integers.rb | UTF-8 | 674 | 4.40625 | 4 | [] | no_license | # sum_prod_consec_integers.rb
# Launch School 101-109 Small Problems Exercises (3rd time through)
print 'Please enter an integer greater than 0: '
num = $stdin.gets.chomp.to_i
loop do
print "Enter 's' to compute the sum, 'p' to compute the product: "
operation = $stdin.gets.chomp
if operation.downcase == 's'
... | true |
7bed3666621233d6c78263b9bbbd3fb51d9a610b | Ruby | JacobNinja/codeminer | /test/matchers/colon3_assign_matcher.rb | UTF-8 | 391 | 2.78125 | 3 | [] | no_license | class Colon3AssignMatcher < Matcher
def initialize(colon3_matcher, body_matcher, src)
@colon3_matcher = colon3_matcher
@body_matcher = body_matcher
@src = src
end
def type
:colon3_assign
end
def assert(exp)
assert_equal type, exp.type
@colon3_matcher.assert(exp.receiver)
@body_m... | true |
70266621e08816e3dcc06b2cdf3bb8e86cf6e63a | Ruby | aarias89/phase-0-tracks | /ruby/puppy_methods.rb | UTF-8 | 1,444 | 4.125 | 4 | [] | no_license | class Puppy
def fetch(toy)
puts "I brought back the #{toy}!"
toy
end
def speak(n)
n.times {print "Woof!"}
end
def roll_over
print "*rolls over*"
end
def dog_years(i)
age=9*i
p age
end
def mail_man
puts "*chases mailman around the block*"
end
def initialize
puts "I... | true |
56602890f4548e101639bb420a27a193dd4d5d55 | Ruby | jan-czekawski/introduction-to-programming-exercises | /regex/quantifiers/ex_4.rb | UTF-8 | 1,042 | 3.671875 | 4 | [] | no_license | # Write a regex that matches any line of text that contains nothing but a
# URL. For the purposes of this exercise, a URL begins with http:// or https://,
# and continues until a whitespace character or end of line is detected.
# Test your regex with these strings:
# http://launchschool.com/
# https://mail.google.com/... | true |
cb96e2719c5478551aeebe8dcace38bd6febd561 | Ruby | Dflexcee/Bubble_sort | /bubble_sort.rb | UTF-8 | 542 | 3.453125 | 3 | [] | no_license | def bubble_sort(arr)
idx = 0
while idx < arr.length
arr.each do |x|
a = arr.index(x)
y = arr.index(x) + 1
next unless y < arr.length && x > arr[y]
arr[a], arr[y] = arr[y], arr[a]
end
idx += 1
end
arr
end
def bubble_sort_by(arr)
loop do
flag = false
arr.each_with_i... | true |
b84aa4c520604380fe3c21c51ae5f6fdd5d25b32 | Ruby | bmquinn/riiif | /app/services/riiif/image_magick_info_extractor.rb | UTF-8 | 366 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | module Riiif
# Get height and width information using imagemagick to interrogate the file
class ImageMagickInfoExtractor
def initialize(path)
@path = path
end
def extract
height, width = Riiif::CommandRunner.execute("identify -format %hx%w #{@path}").split('x')
{ height: Integer(heigh... | true |
69fc07fa80708bb7df49ece910a1be7d46c0f281 | Ruby | dgarwood/exercism_solutions | /ruby/hamming/hamming.rb | UTF-8 | 241 | 2.671875 | 3 | [] | no_license | module Hamming
def self.compute(source, diff)
raise ArgumentError, "strands not same length" unless source.length == diff.length
(0...source.length).count{ |i| source[i] != diff[i] }
end
end
module BookKeeping
VERSION = 3
end
| true |
dc00154a7b425ec1eb5d616ae47e7d6f5a9b3cfc | Ruby | alexappelt/rubybasico | /for.rb | UTF-8 | 85 | 3.140625 | 3 | [] | no_license |
fruits = ['Maça' , 'Morango' , 'Banana']
for fruit in fruits
puts fruit
end | true |
fb39352b424a5d53b9b8ce17d0cd9ed81ecb545e | Ruby | 3scale/apisonator | /lib/3scale/backend/storage_async/client.rb | UTF-8 | 5,982 | 2.671875 | 3 | [
"Apache-2.0",
"Python-2.0",
"Artistic-2.0",
"LGPL-2.0-or-later",
"MIT",
"BSD-3-Clause",
"GPL-2.0-or-later",
"Ruby",
"BSD-2-Clause"
] | permissive | require 'async/io'
require 'async/redis/client'
module ThreeScale
module Backend
module StorageAsync
# This is a wrapper for the Async-Redis client
# (https://github.com/socketry/async-redis).
# This class overrides some methods to provide the same interface that
# the redis-rb client pr... | true |
bf03de93951c1d72673ae3d39f9b109fea1ba45a | Ruby | JeremyFSD/Ruby_Programming_Book | /4_flow_control/5_flow_control.rb | UTF-8 | 320 | 3.859375 | 4 | [] | no_license | puts "Type a number between 0 and 100"
number = gets.chomp.to_i
number = case
when number > 101
puts "Type a number BETWEEN 100 and 0"
when number < -1
puts "Type a number greater than 0"
when number < 50
puts "that number is between 0 and 50"
else number > 50
puts "that number is bewteen 51 and 100"
end | true |
294b4c41de2111bd1ebab0639b5db28462599e3c | Ruby | chet-k/AppAcademy-Open-Work | /0-Foundations/07-Class-Monkey-Patching/monkey_patching_project/chet_monkey_patching_project/lib/array.rb | UTF-8 | 1,410 | 3.53125 | 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
self.max - self.min
end
def average
return nil if self.length == 0
1.0 * self.sum / self.length
end
def median
sorted_temp = self.so... | true |
266e7d13f636445ff20bc2e4c3fbee29ad9128f7 | Ruby | se3000/bter-ruby | /examples/trade.rb | UTF-8 | 500 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'bter'
bt = Bter::Trade.new
#supply your key and secret
bt.key = "my key"
bt.secret = "my secret"
#enable logging , off by default
bt.logging :on
#your funds
puts bt.get_info
#your orders
puts bt.active_orders
#supply an order id and get its status
puts bt.order_status(123456)
#cancel and order with its ... | true |
15d1f7d2094d18ee9b173aa0d6f9ed6649cf6361 | Ruby | jedbr/towers_of_hanoi | /hanoi.rb | UTF-8 | 2,018 | 3.484375 | 3 | [] | no_license | require_relative 'hanoi/peg.rb'
# Class solving instance of Towers of Hanoi problem for 3 and 4 pegs.
class Hanoi
include Math
attr_reader :pegs, :moves
Disk = Struct.new(:size)
def initialize(number_of_disks, number_of_pegs)
@pegs = []
@number_of_disks = number_of_disks
@moves = 0
number_of_... | true |
4f3352a45ceaf688a7dc322a110b86f2c3ca35e5 | Ruby | RobertoM80/Introduction_to_ruby_and_wb | /lesson_1/calculator_v2.rb | UTF-8 | 1,075 | 3.9375 | 4 | [] | no_license | #1. ask user for input number one and store it
#2. ask user for input number two and store it
#3. ask user for input operator and store it
#4. if inputs are not number, has spaces ask again for an apropriate input
# => else continue
#5. calculate results and display
#
#
def ask words
puts words
end
def re_ask w... | true |
23a51441d7dd1cf140ed752261d33b47284b865c | Ruby | ashtrail/tsp | /LK_agent.rb | UTF-8 | 769 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'src/parser'
require_relative 'src/greedy_solver'
require_relative 'src/LKOptimizer'
require_relative 'src/timer'
# init
total_time = 30
safety_time = 2
time = Timer.new
time.start()
solver = GreedySolver.new
lk = LKOptimizer.new
solution = []
# parse file
begin
graph = Pars... | true |
7ecc4e59a7c947d5d158987bd0946c12eeb492f3 | Ruby | frc-862/attendance | /scripts/attendance_log.rb | UTF-8 | 1,008 | 2.78125 | 3 | [
"MIT"
] | permissive |
class AttendanceLog
def initialize(fname = File.absolute_path(File.dirname(__FILE__) + "/../attendance.log"))
@fname = fname
end
def append(op, ip, *value)
File.open(@fname, "a") do |out|
out.puts("#{Time.now} #{op.to_s.ljust(5)} #{ip.to_s.ljust(15)} #{value.join("\t")}")
end
end
def pr... | true |
4cfb6248853779f9ae425cfcf21e64ddbaf095e4 | Ruby | SettRaziel/ruby_visualization | /lib/output/data_output/dataset_output.rb | UTF-8 | 1,097 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module DataOutput
# Parent class for data output and delta output
class DatasetOutput < BaseOutput
private
# @return [VisMetaData] the meta data for this output
attr :meta_data
# prints the meta information consisting of dataset name and informations
# of the different dimensions
def prin... | true |
b053f5f40a433508a65aa3fee6ec8168f3620297 | Ruby | Lunairi/42-Atlantis-Chatterbot-Auditing | /src/userinfo.rb | UTF-8 | 1,928 | 2.90625 | 3 | [] | no_license | require 'slack-ruby-client'
require 'rubygems'
require 'write_xlsx'
# Class that helps to search user and create and update doc
class UserInfo
def initialize_vars
@row = 0
@col = -1
puts 'Userinfo search called'
end
def upload_file(client)
client.files_upload(
channels: '#general',
a... | true |
b76d3984d5a3649b9237885b638f318517f7cc6d | Ruby | cldwalker/lightning | /lib/lightning/util.rb | UTF-8 | 2,098 | 2.75 | 3 | [
"MIT"
] | permissive | module Lightning
module Util
extend self
if RUBY_VERSION < '1.9.1'
# From Ruby 1.9's Shellwords#shellescape
def shellescape(str)
# An empty argument will be skipped, so return empty quotes.
return "''" if str.empty?
str = str.dup
# Process as a single byte seque... | true |
78769ac2000995bf1dc56beffc24eabf8343a8dd | Ruby | billyacademy/class_prac | /deck.rb | UTF-8 | 348 | 3.5 | 4 | [] | no_license | class Deck
SUITS = ["Spades", "Clubs", "Hearts", "Diamonds"]
VALUES = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
attr_reader :deck
def initialize
@deck = []
SUITS.each do |suit|
VALUES.each do |value|
@deck << Card.new(suit, value)
end
end
@deck.shuffle!
end
def d... | true |
385843d4a2dc6fddde3f05c98327b536a172abee | Ruby | saidmaadan/masma_game | /lib/masma_game/next_game.rb | UTF-8 | 520 | 2.84375 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | require_relative 'die'
require_relative 'player'
require_relative 'hoard_store'
require_relative 'loaded_die'
module MasmaGame
module NextGame
def self.next_player(p)
die = Die.new
case die.roll
when 1..2
p.blam
when 3..4
puts "#{p.name} was skipped."
else
p.w... | true |
a1a466a0a84e66065b17201dcd26dc1fe89940fe | Ruby | ngeballe/ls120-lesson3 | /review/variable_scope/5_class_variables.rb | UTF-8 | 515 | 3.84375 | 4 | [] | no_license | class Person
@@total_people = 0 # initialized at the class level
def self.total_people
@@total_people # accessible from class method
end
def initialize
@@total_people += 1 # mutable from instance method
end
def total_people
@@total_people # accessible from instance method... | true |
87ea66aed34812cfc8f793919849b9d36085ba62 | Ruby | reteshbajaj/learn_to_program | /challenge9.rb | UTF-8 | 544 | 3.3125 | 3 | [] | no_license | #challenge9.rb
def ask question
while true
puts question
reply = gets.chomp.downcase
until (reply == "yes" || reply == "no")
puts "please answer yes or no ma'am!!"
puts question
reply = gets.chomp.downcase
end
if (reply == "yes" || reply == "no")
if reply == "yes"
puts "yes entered"
... | true |
e9cc58ad3948c35a1f78bab4ae12579528450427 | Ruby | creinken/ruby-collaborating-objects-lab-onl01-seng-ft-032320 | /lib/song.rb | UTF-8 | 594 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
#### Attributes ####
attr_accessor :name, :artist
@@all = []
#### Instance methods ####
def initialize(name)
@name = name
@@all << self
end
def artist_name=(name)
if self.artist == nil
self.artist = Artist.find_or_create_by_name(name)
else
self.artist = A... | true |
590dbc577bf4be23d5150c79f10c63ee5e3294bb | Ruby | KirilKostov/task_2 | /song.rb | UTF-8 | 156 | 3.03125 | 3 | [] | no_license | class Song
attr_reader :name, :artist, :album
def initialize(name, artist, album)
@name = name
@artist = artist
@album = album
end
end | true |
c2ec34265995a8d0c586a6a4fc3e3234f54a50ce | Ruby | andrewkjankowski/debug-me-001 | /runner.rb | UTF-8 | 772 | 3.859375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative './jukebox.rb'
def run
puts "Welcome to Ruby Console Jukebox!"
prompt
command = get_command
while command.downcase != "exit" do
run_command(command.downcase) unless command.downcase == "exit"
prompt
command = get_command
end
end
def prompt
puts "Enter a command to continue. Ty... | true |
21ccd5774f1e5e3809d7c346b145232d9b0e4154 | Ruby | kad3nce/env_vars_validator | /lib/env_vars_validator.rb | UTF-8 | 843 | 2.671875 | 3 | [
"MIT"
] | permissive | class EnvVarsValidator
@@last_error = nil
def self.last_error
@@last_error
end
def self.source_from_ruby_files(starting_dir)
Dir.glob(File.join(starting_dir, '**', '*.rb')).
reject { |file_path| file_path.include?('vendor') }.
map { |file_path| File.read(file_path) }.
join("\n")
en... | true |
fc4e8cbe507a8ee847b1d2febaa75e106e18a079 | Ruby | VKuzmich/ruby-exercice-files | /cases.rb | UTF-8 | 796 | 3.609375 | 4 | [] | no_license | puts "Dates of week"
puts "Write the number from 1 to 7 "
ch=gets.to_i
case ch
when 1
puts "Monday"
when 2
puts "Tuesday"
when 3
puts "Wednesday"
when 4
puts "Thursday"
when 5
puts "Friday"
when 6
puts "Saturday"
when 7
puts "Sunday"
else
puts "you wrote wrong number"
end
puts "What is the type of your... | true |
bb848652d381b56622e1a3ffe8fd9b323af08a6e | Ruby | mekimball/craft_2108 | /spec/person_spec.rb | UTF-8 | 1,128 | 3.046875 | 3 | [] | no_license | require './lib/person'
require './lib/craft'
RSpec.describe Person do
before(:each) do
@person = Person.new({ name: 'Hector',
interests: %w[sewing millinery drawing] })
end
it 'exists' do
expect(@person).to be_a(Person)
end
it 'has attributes' do
expect(@person.name).... | true |
91ef48ce4868fb5acbc8d091dc1057d218c1d046 | Ruby | Rmole57/intro-to-programming-ruby-exercises | /flow_control/ex5.rb | UTF-8 | 1,530 | 4.75 | 5 | [] | no_license | # Exercise 5 (Exercise 3 program, refactored using a case statement wrapped in a method)
=begin
NOTE: I decided to use a case statement with an argument. Using a case statement without
an argument would mean I would have to provide each 'when' clause with a condition that
evaluates to a boolean. Then the case statemen... | true |
6f7dc7d5c5f0dda70ae832c9459307db33c45700 | Ruby | Teshager21/online-sales-data-scrapper | /lib/page_parser.rb | UTF-8 | 549 | 2.875 | 3 | [] | no_license | require 'httparty'
require 'nokogiri'
class PageParser
attr_reader :parsed_page, :unparsed_page
def parse_page
@parsed_page = Nokogiri::HTML(@unparsed_page.body)
end
def filter_by_class(css_class, parsed_page = @parsed_page)
parsed_page.css(css_class)
end
def initialize(url)
try = 3
@pars... | true |
f30929c96382ad435d1d476d7c6b8a8ffe0c5089 | Ruby | Argonus/algorithms | /coursera_algorithms/course_1/week_3/quick_sort.rb | UTF-8 | 2,574 | 3.515625 | 4 | [] | no_license | module Course1
module Week3
class QuickSort
attr_reader :comparasions
def initialize(array, manner = :random)
@array = array
@a_length = array.size
@comparasions = 0
@manner = manner
end
def sort!
return @array if @a_length <= 1
quicksort(... | true |
0064081612cee96f190ab29631e4693f1061c7f4 | Ruby | ismk/phase_0_unit_2 | /week_5/4_boggle_board/my_solution.rb | UTF-8 | 1,347 | 4.53125 | 5 | [] | no_license | # U2.W5: A Nested Array to Model a Boggle Board
# I worked on this challenge [by myself].
boggle_board = [["b", "r", "a", "e"],
["i", "o", "d", "t"],
["e", "c", "l", "r"],
["t", "a", "k", "e"]]
# Part 1: Access multiple elements of a nested array
# Pseudocode
# Init... | true |
8f55324ad99fc954c8bca765714e191ea9790bc1 | Ruby | Laner12/random_res | /app/services/current_location_service.rb | UTF-8 | 402 | 2.640625 | 3 | [] | no_license | class CurrentLocationService
def initialize
@_connection = Faraday.post("https://www.googleapis.com/geolocation/v1/geolocate?key=#{ENV['GOOGLE_API_KEY']}")
end
def get_location
response = connection
parse(response.body)
end
private
def parse(response)
JSON.parse(response, symbolize_n... | true |
05f6109753342619583c713147496d7203158f6a | Ruby | aurora-a-k-a-lightning/gaku_admin | /lib/tasks/admin_user.rake | UTF-8 | 2,783 | 2.5625 | 3 | [] | no_license | require 'highline/import'
namespace :gaku do
desc "Create admin username and password"
task generate_admin: :environment do
if Gaku::User.admin.empty?
create_admin_user
else
puts 'Admin user has already been previously created.'
if agree('Would you like to create a new admin user? (yes/no)')
... | true |
6fb9e94bf4d3e526a519df75a0a886c9047eec25 | Ruby | Ghrind/roguelike | /lib/roguelike/field_of_view.rb | UTF-8 | 2,409 | 3.21875 | 3 | [
"MIT"
] | permissive | # Taken from http://www.roguebasin.com/index.php?title=Ruby_shadowcasting_implementation
module ShadowcastingFieldOfView
# Multipliers for transforming coordinates into other octants
@@mult = [
[1, 0, 0, -1, -1, 0, 0, 1],
[0, 1, -1, 0, 0, -1, 1, 0],
[0, 1, 1, 0, 0, -1, -1, 0],
[1, 0,... | true |
9a0ddc0e59aff0b738b77b74acdb7f752c29c5db | Ruby | kraila/blackjack | /blackjack.rb | UTF-8 | 518 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
Dir[File.join('lib', '**', '*.rb')].each do |file|
require_relative file
end
def play_new
blackjack = Game.new
blackjack.begin_blackjack!
blackjack.display_player_hand
blackjack.prompt_hit_or_stand
blackjack.compare_scores
play_again?
end
def play_again?
print "Play again? (Y/N): "... | true |
e54653f20c97870fcdb17f2b3be747268a2cae76 | Ruby | MrJaba/IPRUG-Sept-HigherOrderRuby | /currying.rb | UTF-8 | 707 | 4.0625 | 4 | [] | no_license | #Ruby 1.8
def scale_number(x, factor)
x * factor
end
def scale_factory(factor)
lambda{|x| x * factor}
end
scale_3 = scale_factory(3)
1.upto(10) do |x|
puts scale_number(x, 3)
end
1.upto(10) do |x|
puts scale_3.call(x)
end
#Ruby 1.9
# scale = lambda{|factor, x| x * factor }
# scale_3 = scale.curry[3]
... | true |
6d2276319bf012e82048f5d2f361b2f85424004a | Ruby | buchheimt/golf-links | /spec/features/course_features_spec.rb | UTF-8 | 6,953 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative "../rails_helper.rb"
describe "Course Features", type: :feature do
describe "Course#index", type: :feature do
before :each do
Course.create(
name: "Augusta National GC",
description: "Home of the Masters",
location: "Augusta, GA"
)
end
let(:course) {... | true |
0d35beaefd404ebc6f76ea9d3a259f77f8c2bde7 | Ruby | ScottDuane/chess | /game.rb | UTF-8 | 1,596 | 3.5625 | 4 | [] | no_license | require_relative 'player.rb'
require_relative 'Display.rb'
require_relative 'Board.rb'
require_relative 'humanplayer.rb'
require_relative 'computerplayer.rb'
class Game
attr_reader :display, :board, :current_player
def initialize(board)
@board = board
@display = Display.new(board, self)
@current_play... | true |
638675594b34bd91d517d740232d5a7d25c15989 | Ruby | calvinsettachatgul/thai_trainer | /vowels_test.rb | UTF-8 | 404 | 3.203125 | 3 | [] | no_license | require 'io/console'
# input = STDIN.getch
@first_consonants = "กขฃคฅฆงจฉชซ"
@second_consonants = "ฌญฎฏฐฑฒณดตถ"
@third_consonants = "ทธนบปผฝพฟภม"
@fourth_consonants = "ยรลวศษสหฬอฮ"
@first_vowels = "ะาเแ ิ ี ุ ู"
@tones = " ่ ้ ๊ ๋ ็ ํ ์"
p @first_vowels.split(" ")
p @tones.split(" ")
| true |
d8030fc6d38509372742db880aead435d5e03802 | Ruby | stallpool/lazac | /samples/test.rb | UTF-8 | 1,040 | 3.1875 | 3 | [
"MIT"
] | permissive | a = ""
b = 1
puts a.\
\
class
puts a + if b == 1 then "x" else "y" end
=begin
hello world end =begin =end
=end
def a(x)
puts x
# this is comment ? =begin =end
end
=begin again
=end 1
def b?
puts "wojofiewf"
y = 1
z = if y == 1 then y+1 else y+2 end
z = z + ( if y == 1 then 3 else 9 end ) + 2 \
... | true |
3e7dee9879a32a3c5f01f641bb02bb6614ae4c41 | Ruby | alejoFinocchi/back-up | /Ruby/Ruby/Ruby/p4/ej5/manejoDeArgumentos.rb | UTF-8 | 662 | 2.8125 | 3 | [] | no_license | require 'sinatra'
get '/' do
lista todos los endpoints disponibles (sirve a modo de documentación)
end
get '/mcm/:a/:b' do
calcula y presenta el mínimo común múltiplo de los valores numéricos
end
get 'mcd/:a/:b' do
calcula y presenta el máximo común divisor de los valores numéricos
end
get '/sum/*' do
calcula la ... | true |
79d9c0113cd55d8bca018622bc7da030b1610571 | Ruby | vmwhoami/travod | /app/controllers/concerns/scraping_module.rb | UTF-8 | 1,600 | 2.578125 | 3 | [] | no_license | module ScrapingModule
extend ActiveSupport::Concern
def format_target_languages(target_languages)
target_languages.join(' / ')
end
def check_url(url)
return true if url.include? 'https://www.proz.com/'
false
end
def scrapp_page(url)
unparsed = HTTParty.get(url)
doc = Nokogiri::HTML(u... | true |
b00ef22840d5e8b88fc62589f88892a76d7813a0 | Ruby | Maghamrohith/ruby-programs | /greeting.rb | UTF-8 | 323 | 3.359375 | 3 | [] | no_license | class Person
attr_accessor :first_name,:last_name
def initialize(details)
@first_name = details[:first_name]
@last_name = details[:last_name]
end
def details
puts "hello,#{first_name}#{last_name}"
end
end
p1=Person.new({:first_name=> "rohith",:last_name=> "kumar"})
p1.deta... | true |
a33c7a6245f17c469889757b8935b303d9471b16 | Ruby | Jauny/connect_four | /lib/connect_four/twitter_player.rb | UTF-8 | 2,782 | 3.09375 | 3 | [] | no_license | require 'tweetstream'
class TwitterPlayer
attr_reader :name, :twitter, :piece, :random_tag, :id
def initialize(options={}, tag)
@name = options[:name]
@twitter = options[:twitter]
@piece = options[:piece]
@id = options[:id]
@random_tag = tag
end
def self.from_twitter
@random_tag = (('a... | true |
6854d29249fb961800ef25dd7c3aae39766c29f0 | Ruby | flipsasser/maintain | /spec/integer_spec.rb | UTF-8 | 809 | 2.890625 | 3 | [
"MIT"
] | permissive | # Tests on integer-specific functionality
require 'spec_helper'
require 'maintain'
describe Maintain do
before :each do
class ::MaintainTest
extend Maintain
end
end
describe "integer" do
before :each do
MaintainTest.maintain :kind, integer: true do
state :man, 1
state :w... | true |
9ab953a10251c404389ea4b497a4ee0c5c9680cb | Ruby | magoosh/browser-timezone | /lib/browser-timezone/instance_methods.rb | UTF-8 | 589 | 2.546875 | 3 | [] | no_license | module BrowserTimezone
module InstanceMethods
protected
# Internal: Sets the Time class's default zone to the value returned by browser_timezone
# This method should be called as a before_action
def set_timezone_from_browser_cookie
Time.zone = browser_timezone || 'UTC'
end
# Internal: ... | true |
fb47bca663c9fd699ca5cf03e2597fc27fa3fb16 | Ruby | tungtung233/math_game | /main.rb | UTF-8 | 608 | 3.296875 | 3 | [] | no_license | require './player'
require './active_player'
require './math_question'
def start
Math_logic.new_question
if (P1.lives != 0 && P2.lives != 0)
puts "----- NEW TURN -----"
Current_player.change_active_player
Math_logic.change_numbers
start
else
string = "wins with a score of"
if (P1.lives ... | true |
b2b7a368b34fcba73b959b564edccf6c16a90bfe | Ruby | vconcepcion/level_up_exercises | /art/app/models/show_recommender.rb | UTF-8 | 662 | 2.671875 | 3 | [
"MIT"
] | permissive | class ShowRecommender
def initialize(user = nil)
@user = user
end
def recommendations
return [] unless Review.beloved.by(@user).exists?
cool_people(beloved_shows(@user)).inject([]) do |recommendations, user|
recommendations += beloved_shows(user)
(recommendations - beloved_shows(@user))... | true |
54d3e4ce3ace38112d8730d1637105adbb9cf060 | Ruby | flipstone/codiphi | /engine/examples/functional/transform_spec.rb | UTF-8 | 9,116 | 2.515625 | 3 | [] | no_license | require_relative '../spec_helper.rb'
module Codiphi
describe Transform do
describe "matching_named_type" do
it "yields proper hash reference to passed block" do
indata = {
"fum" => [{
Tokens::Name => "baz",
Tokens::Type => "fum"
}]
}
yiel... | true |
f484ee7f5a083a4be5125db971bcbe7e92235cd1 | Ruby | mbalbera/OO-mini-project-nyc-web-080519 | /app/models/User.rb | UTF-8 | 859 | 3.25 | 3 | [] | no_license | class User
attr_accessor :recipe_cards
@@all = []
def initialize(recipe_cards, allergies)
@recipe_cards = recipe_cards
@allergies = allergies
@@all << self
end
def self.all
@@all
end
def recipes
recipe_cards.select { |r_c| r_c.recipe }
end
... | true |
a310c3cb061f91f1c911e4a413c0248762f7d85a | Ruby | ebertolazzi/pins-mruby-pure-regexp | /test/regexp.rb | UTF-8 | 3,274 | 2.6875 | 3 | [
"MIT"
] | permissive | assert('PureRegexp.compile') do
assert_false PureRegexp.compile("((a)?(z)?x)") === "ZX"
assert_true PureRegexp.compile("((a)?(z)?x)",
PureRegexp::IGNORECASE) === "ZX"
assert_false PureRegexp.compile("z.z", PureRegexp::IGNORECASE) === "z\nz"
end
assert('PureRegexp#match') do
assert_nil PureRegexp.compile("z... | true |
3eb7cf91ab0282ba806e82b6e51e31ea78c0a87b | Ruby | denistsuman/csv-ping | /app/checker/remote.rb | UTF-8 | 1,907 | 2.875 | 3 | [] | no_license | require 'json'
# A class to check http availability using requests from a remote service (check-host.net currently).
class Checker::Remote < Checker
REQUEST_BASE = 'https://check-host.net/check-http?host={URL}'
RESULT_BASE = 'https://check-host.net/check-result/{ID}'
KYIV_HOST = 'ua2.node.check-host.net'
ATTE... | true |
2af0864f1d04fadaa66b860272f3a894245c0c46 | Ruby | ddollar/sinatra-cli | /lib/sinatra/cli/command.rb | UTF-8 | 3,214 | 2.828125 | 3 | [] | no_license | require "sinatra/cli"
class Sinatra::CLI::Command
attr_reader :group, :banner, :description, :name
def initialize(group, banner, description, &block)
@group = group
@banner = banner
@description = description
@name = banner.split(" ").first
instance_eval &block
end
## accessors ###########... | true |
51480365d062494cf343b45508afb07cbfcc1e9c | Ruby | jinx/core | /lib/jinx/helpers/set.rb | UTF-8 | 380 | 3.15625 | 3 | [
"MIT"
] | permissive | require 'set'
class Set
# The standard Set {#merge} is an anomaly among Ruby collections, since merge modifies the called Set in-place rather
# than return a new Set containing the merged contents. Preserve this unfortunate behavior, but partially address
# the anomaly by adding the merge! alias to make it clear... | true |
a1ae180c774763c73565c169a486083a4cc84c89 | Ruby | deepak-webonise/Ruby | /meta_programming/metaprogram.rb | UTF-8 | 936 | 3.265625 | 3 | [] | no_license | #/usr/bin/ruby -w
require "csv.rb"
#CSV file path
file_path = "states.csv"
#csv file parsing options
csv_options = {:headers => true,:col_sep => ",",:header_converters => :symbol,:converters => :all}
#CSV file reading and storing in csv_content
csv_content = CSV.read(file_path, csv_options)
#Extracting class name f... | true |
b8631f0ab94b0b6abd1e9883e4a7ad4a87f91fdd | Ruby | pcylo/xkomer | /apps/web/services/fetch_current_offer.rb | UTF-8 | 2,293 | 2.671875 | 3 | [] | no_license | class FetchCurrentOffer
def initialize
@page = load_page
@repository = OfferRepository.new
@current_name = get_by_selector(ENV['NAME_SELECTOR'])
@current_old_price = get_by_selector(ENV['OLD_PRICE_SELECTOR'])
@current_new_price = get_by_selector(ENV['NEW_PRICE_SELECTOR'])
@current_dis... | true |
dd7920ddea9b507ecd39dd3b68d6ed236c730d2a | Ruby | bosskey59/tweet-shortener-houston-web-071618 | /tweet_shortener.rb | UTF-8 | 1,082 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def dictionary(word)
dictionary={
"hello": "hi",
"to":"2",
"two": "2",
"too": "2",
"for": "4",
"four": "4",
"be": "b",
"you": "u",
"at": "@",
"and": "&"
}
dictionary.each do |key, value|
if word == key.to_s || word == key.to_s.capitalize
r... | true |
19be2ce496d8e5856247c8871c8d698b8e5f964b | Ruby | jaysoko/my-select-online-web-prework | /lib/my_select.rb | UTF-8 | 67 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
collection.select { |i| yield(i) }
end
| true |
56b627be85c0e473f67b9d1282db52ce88c52de2 | Ruby | Madh93/advent-of-code-2017 | /lib/aoc2017/day06/memory_reallocation.rb | UTF-8 | 1,765 | 3.0625 | 3 | [
"MIT"
] | permissive | module Aoc2017
module Day06
class << self
def memory_reallocation(filename)
# Get absolute pathname
file = File.join(File.dirname(__FILE__), filename)
# Store memory banks in an array
banks = File.read(file).split.map(&:to_i)
states = []
cycles = 0
... | true |
2e1381af369b6f298cb989165b326f8a990766e8 | Ruby | Xavier-J-Ortiz/blocitoff | /db/seeds.rb | UTF-8 | 719 | 2.5625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
540e709f9ef287b75bb110fa921683d88a12fe6f | Ruby | globewalldesk/practice | /montyhall2.rb | UTF-8 | 1,196 | 3.984375 | 4 | [] | no_license | #!/usr/bin/env ruby -w
class Array
def choice
self.shuffle.first
end
end
class MontyHall
def initialize
@doors = ['car', 'goat', 'goat'].shuffle
end
def pick_door
return rand(3)
end
def reveal_door(pick)
available_doors = [0, 1, 2]
available_doors.delete(pick)
available_doors.de... | true |
ed73ee1a33f81f9c7417a0f755b056aac5b6a313 | Ruby | draftcode/git-panini | /lib/git/panini/real_repository.rb | UTF-8 | 4,569 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'rugged'
module Git
module Panini
class RealRepository
attr_reader :path
def initialize(path)
@path = path.expand_path
end
def panini_name
"panini:#{path.basename('.git')}"
end
def ==(other)
path == other.path
end
alias :eql? :==
... | true |
e4ff6f1300de5e709473dce17c65fca978b2c2a1 | Ruby | hashtegner/my-exercism-io | /ruby/binary/binary.rb | UTF-8 | 313 | 3.171875 | 3 | [] | no_license | module BookKeeping
VERSION = 2
end
class Binary
attr_reader :string
def initialize(string)
raise ArgumentError if string.match(/\D|[2-9]/)
@string = string
end
def to_decimal
string.chars.reverse.map.with_index do |char, index|
char.to_i * (2 ** index)
end.reduce(:+)
end
end
| true |
b8fc51443442117346df07dff2718aec087af256 | Ruby | gbs4ever/sql-library-lab-online-web-ft-011419 | /lib/querying.rb | UTF-8 | 1,235 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"SELECT books.title, books.year FROM Books WHERE series_id = 1 ORDER BY year;"
end
def select_name_and_motto_of_char_with_longest_motto
"SELECT Characters.name , Characters.motto FROM Characters ORDER BY length(motto) DESC LIMIT 1;"
end
def select... | true |
e0b95737c4dc46a6c11ff9a4155f7acbd4fc00fa | Ruby | linuxsable/rread | /app/models/activity.rb | UTF-8 | 1,963 | 2.609375 | 3 | [] | no_license | class Activity < ActiveRecord::Base
attr_accessor :user_name, :user_avatar, :target_name
belongs_to :user
belongs_to :target, :polymorphic => true
# Activity Types
ARTICLE_LIKED = 1
ARTICLE_READ = 2
SUBSCRIPTION_ADDED = 3
FRIENDSHIP_ADDED = 4
BLOG_LIKED = 5
def self.batc... | true |
102294239406f4df82792552110e6da988933f1a | Ruby | hugobast/dentsubos-pool | /spec/temperature_store_spec.rb | UTF-8 | 858 | 2.90625 | 3 | [] | no_license | require 'json'
require_relative '../lib/temperature_store'
class TestClock < DateTime
def now
self
end
end
describe TemperatureStore do
after do
Redis.new.del(:test)
end
it "saves temperatures and conditions" do
clock = TestClock.new(2012, 8, 17, 11, 34)
temperatures = {pool: 79, outside: ... | true |
0533f1e8b7ddc6ad17cef5cfe5dfdf74d08dec34 | Ruby | Wendyv510/square_array-onl01-seng-pt-100619 | /square_array.rb | UTF-8 | 155 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array=[9,10,16,25]
square_array.each do |numbers|
puts "#{number} **"
end
def square_array=[1,2,3]
square_array.collect{|x| (x**)}
end
| true |
9d93fbf900f1c4927a2d8bcc8469bb91b3c699c9 | Ruby | sato-s/EnhancedPrompt | /lib/enhanced_prompt/token/token.rb | UTF-8 | 2,421 | 2.640625 | 3 | [
"MIT"
] | permissive | require_relative './emoji_writable'
class EnhancedPrompt::Prompt
# Responsible for delegating instructions to proper instance.
# And convert into proper string after receiving Integer, AddrInfo or something else
class Token
include EmojiWritable
# Delegating to Network resource
def ipv4
_netwo... | true |
c34255214c7ebd63ea7263aa96e2c8e12dd0eb82 | Ruby | veliancreate-zz/Ruby-School | /new ruby/hmmm.rb | UTF-8 | 1,469 | 2.859375 | 3 | [] | no_license | single_num = ones_method(thousands_mod, places)
tens_num = tens_method(thousands_mod, places)
hundreds_num = hundreds_method(thousands_mod, places)
if thousands_mod == 0
if thousands_div >= 100
return_string = hundreds_thou + " thousand"
elsif thousands_div < 100 && thousands_div >= 10
return_string = te... | true |
ebc30863f458105e5e9cd626404449ffc5ce6f36 | Ruby | kentgray/Portfolio-KentGray | /Ruby/Practice Apps/numofmoos.rb | UTF-8 | 113 | 3.171875 | 3 | [] | no_license | def sayMoo numberOfMoos
puts 'mooooooo...'*numberOfMoos
'yellow submarine'
end
x = sayMoo 2
puts x
| true |
303a2f06c5b554bdf56664c440429f8d153c7379 | Ruby | marcelomst/ethereum_voting_example | /app/services/vote_service.rb | UTF-8 | 425 | 2.640625 | 3 | [] | no_license | class VoteService
def initialize(key, meals, address = nil)
@key = key
@address = address || Voting.last.contract_address
@meals = meals
end
def call
vote
end
private
def vote
voting_contract = Contract::GetService.new(@address).call
signed_voting_contract = Contract::SignService.... | true |
eff59720907d6fa7a62c64e3a531b71660bee0c4 | Ruby | Tempate/Advent-of-Code-2020 | /day7/main.rb | UTF-8 | 1,256 | 3.625 | 4 | [] | no_license | file = File.open("input.txt")
$lines = file.readlines.map(&:chomp)
def parse_input()
bags = {}
entry_pattern = Regexp.compile('^(.+) bags contain (.+)\.$')
items_pattern = Regexp.compile('^(\d+) (.+) (bag|bags)$')
$lines.each do |line|
name, items = entry_pattern.match(line)[1..2]
b... | true |
5184e23654e1c131c8b99f15f23c6d9b617b297f | Ruby | superhighfives/fox-server | /lib/gif_cache.rb | UTF-8 | 329 | 3.09375 | 3 | [
"CC-BY-4.0",
"CC-BY-3.0"
] | permissive | class GifCache
def initialize(memcached_client)
@client = memcached_client
end
def get(lyric)
@client.get cache_key(lyric)
end
def set(lyric, gif)
@client.set cache_key(lyric), gif
end
def delete(lyric)
@client.delete cache_key(lyric)
end
def cache_key(lyric)
lyric.id.to_s
... | true |
69481716e41dbbcdffeddd17bdf634b927b5f47a | Ruby | SupernovaTitanium/Ruby-example | /ex39_test.rb | UTF-8 | 1,153 | 3.921875 | 4 | [] | no_license | require './dict.rb'
#create a mapping of state to abbreviation
states=Dict.new()
Dict.set(states,'Oregon','OR')
Dict.set(states, 'Florida', 'FL')
Dict.set(states, 'California', 'CA')
Dict.set(states, 'New York', 'NY')
Dict.set(states, 'Michigan', 'MI')
# create a basic set of states and some cities in them
cities = Di... | true |
c06a327d550e4eeb6c80cf5d04c64d26217b7881 | Ruby | solyarisoftware/blomming_api | /blomming_api/lib/blomming_api/oauth_endpoint.rb | UTF-8 | 2,581 | 2.59375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'multi_json'
require 'rest_client'
module BlommingApi
module OauthEndpoint
#
# authentication request
#
# => to get initial OAuth access token:
#
# authenticate :initialize
#
# => to get refresh token in case of OAuth access token expire... | true |
35852f97dc2de0f91e162e91e3e7f301ec5b0df9 | Ruby | ethanjurman/GWACI | /Grid.rb | UTF-8 | 1,167 | 4.0625 | 4 | [] | no_license | #Class: Grid, class that represents a board of a givin size
class Grid
def initialize(name, sizeX=8, sizeY=8)
#name: name of the board
#sizeX: size of the X axis (a..z); defaults to 8
#sizeY: size of the Y axis (1..26); defaults to 8
@name = name
@sizeX = sizeX
@siz... | true |
29c012ad336afd16d816e23a8a20fce3d2e003d0 | Ruby | chintas1/badges-and-schedules-001-prework-web | /conference_badges.rb | UTF-8 | 469 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
(1..(attendees.size)).collect{|i| badge_maker(attendees[i-1])}
end
def assign_rooms(speakers)
(1..(speakers.size)).collect{|i| "Hello, #{speakers[i-1]}! You'll be assigned to room #{i}!"}
end
def p... | true |
bd6741b1d1d37d2009a93ba0f055de152aefa02f | Ruby | thomaspouncy/Fred | /lib/fred/body_types/nxt_body.rb | UTF-8 | 914 | 2.578125 | 3 | [] | no_license | require 'ruby_nxt'
class NXTBody < Body
DEFAULT_TOUCH_PORT = 1
DEFAULT_COLOR_PORT = 3
DEFAULT_ULTRASONIC_PORT = 4
attr_reader :nxt
# Tell ruby-nxt to give us bluetooth details
$DEBUG = true
def initialize(touch_port = DEFAULT_TOUCH_PORT,color_port = DEFAULT_COLOR_PORT,ultrasonic_port = DEFAU... | true |
dfe9f8860f958f21c15529900c966b6e38aa8c49 | Ruby | yohei-ota/furima-36556 | /spec/models/user_spec.rb | UTF-8 | 6,007 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe "ユーザー新規登録" do
context "新規登録できるとき" do
it "全ての項目が存在すれば登録できる" do
expect(@user).to be_valid
end
it "passwordとpassword_confirmationが6文字以上で英数字混合なら登録できる" do
@user... | true |
3d41b0a9bc1618518ef851a0377590bd96772d73 | Ruby | koenhandekyn/adventofcode | /2019/d04/secure_container.rb | UTF-8 | 795 | 3.375 | 3 | [] | no_license | def assert_eq(v1, v2)
raise "expected #{v2}, but got #{v1}" unless v1 == v2
end
lower = 206938
upper = 679128
candidates =
(0..9).map do |d1|
(d1..9).map do |d2|
(d2..9).map do |d3|
(d3..9).map do |d4|
(d4..9).map do |d5|
(d5..9).map do |d6|
[d1,d2,d3,d4,d5,d6].join("")
end
en... | true |
f9e7aef924d9a36c5f3b684ee33e4600a5c39cdf | Ruby | leafy-metrics/leafy | /spec/meter_spec.rb | UTF-8 | 878 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | require 'leafy/core/meter'
RSpec.describe Leafy::Core::Meter do
let(:clock) do
clock = Leafy::Core::Clock.new
def clock.tick
@ticks ||= [0, 0] + [10000000000] * 10
@ticks.shift
end
clock
end
let(:meter) { Leafy::Core::Meter.new(clock) }
it 'starts out with no rates or coun... | true |
5f7826b77a579a325a83ad90ec3411094a62728b | Ruby | kevinfalank-devbootcamp/web_flashcards | /app/controllers/user.rb | UTF-8 | 1,328 | 2.546875 | 3 | [] | no_license | post '/login' do
#Validates username/password. Redirects to /decks if successful.
# params[:login].inspect
user_id = User.login(params[:login])
if user_id > 0
session[:user_id] = user_id
redirect to '/decks'
else
redirect "/"
end
end
post '/users/create' do
#Generates user from form input.
#S... | true |
de8837db04c3f46c7ee3c364886bca6d2e78807a | Ruby | zklamm/ruby-small-problems | /exercises/second_pass/easy_01/04.rb | UTF-8 | 779 | 4.5625 | 5 | [] | no_license | # Write a method that counts the number of occurrences of each element in a given array.
# input: array
# output: print the count of each element
# assume:
# examples: given
# logic: iterate thru array and create a hash containing elements as keys and instances
# as a count
def count_occurrences(ary)
count =... | true |
8072dc36c9265b27b86176bd0ece368229d19f2d | Ruby | pjfitzgibbons/config-reader | /spec/config_reader_spec.rb | UTF-8 | 2,895 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'config_reader'
describe ConfigReader do
let(:sample) {
'
# This is what a comment looks like, ignore it
# All these config lines are valid
host = test.com
server_id=55331
server_load_alarm=2.5
user= user
# comment can appear here as well
verbose =true
test_mode = on
debug_mode = of... | true |
58e787d20add47cf8c32051627221b03b0c178c8 | Ruby | waterfield/testables | /lib/scope_machine.rb | UTF-8 | 807 | 3.109375 | 3 | [
"MIT"
] | permissive | # The +state_machine+ gem is really cool, but I kind of wish
# each of the defined states would make a scope. So if you
# had for instance :queued and :finished as states, you would
# be able to do
#
# Model.queued # => Model.where(state: 'queued')
#
# This module makes that happen by putting an after filter
# o... | true |
5259c41ab797dd9ac7ed472b6f0feab1a70cdf6b | Ruby | juanger/typing_trainer | /lib/typing_trainer/level_generator.rb | UTF-8 | 1,395 | 3.484375 | 3 | [
"MIT"
] | permissive | require 'contemporary_words'
require "typing_trainer/level"
require "typing_trainer/keyboard_layout"
class TypingTrainer::LevelGenerator
SENCENCES_PER_LEVEL = 3
WORDS_PER_SENTENCE = 8
def self.generate(level: nil, letters: nil, layout: nil)
throw "You need to specify a layout" unless layout
throw "No l... | true |
c4a61585a56c07f30550938c474c91b036822a19 | Ruby | aljurgens/ruby_exercises | /euler.rb | UTF-8 | 153 | 3.5625 | 4 | [] | no_license | puts 'Sum of all multiples of 3 or 5 below 1000:'
sum = 0
i = 0
while i < 1000
if i % 3 == 0 || i % 5 == 0
sum += i
end
i += 1
end
puts sum
| true |
5849c5f4d98e139af1ee2692736a2c850519253d | Ruby | evelinawest/learn_to_program_book | /Chapter6/rand.rb | UTF-8 | 109 | 2.671875 | 3 | [] | no_license | puts rand
puts rand
puts rand (10)
puts rand (100)
puts rand (1)
puts rand (1)
puts rand (1)
puts rand (1.0)
| true |
369c3ba626c7e7f475c6de6af66938153ea25938 | Ruby | walterio212/aydoo2017ruby-TpFinal | /Calendario/spec/validador_calendario_spec.rb | UTF-8 | 976 | 2.578125 | 3 | [] | no_license | require 'rspec'
require_relative '../model/calendario'
require_relative '../model/validador_calendario'
require_relative '../model/calendario_nombre_existente_error'
require_relative '../model/calendario_sin_nombre_error'
describe 'ValidadorCalendario' do
it 'crearCalendario nombre existente error' do
persist... | true |
5aa765e4ba5580121fdf590c21d567f01519258f | Ruby | ejf89/the-bachelor-todo-web-040317 | /lib/bachelor.rb | UTF-8 | 734 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def get_first_name_of_season_winner(data, season)
winner = ""
data[season].each do |stats, value|
if stats["status"] == "Winner"
winner = stats["name"].split(" ")[0]
end
end
winner
end
def get_contestant_name(data, occupation)
name = ""
data.eac... | true |
c07d0a2f01221f4cdfaee0552b39a4120cc09bc6 | Ruby | wlffann/black_thursday | /test/items_price_analyst_test.rb | UTF-8 | 1,326 | 2.84375 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/items_price_analyst'
class ItemsPriceAnalystTest < Minitest::Test
attr_reader :engine, :analyst
def setup
@engine = SalesEngine.from_csv({:items => './test/assets/test_items.csv',
:merchants => './test/assets/test_m... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.