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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1d60d69cba68521a8ecb69c79a4366c87100342e | Ruby | Marji712/cs361-final-exam | /road_bike.rb | UTF-8 | 411 | 3.421875 | 3 | [] | no_license | require_relative 'luggage'
class RoadBike
attr_accessor :luggage, :daily_rate, :total_price
def initialize
@luggage = [Luggage.new(3), Luggage.new(3)]
@daily_rate = 15
end
def clean
puts "Cleaning..."
end
def lubricate_gears
puts "Lubricating gears..."
end
def total_price
@tota... | true |
92b60bf6d694ee2d1df6bdb183012bacd1670a05 | Ruby | evilstreak/adventofcode-2019 | /06/one.rb | UTF-8 | 154 | 2.59375 | 3 | [] | no_license | require_relative 'orbit'
input = $stdin.read.split(/\n/)
orbit_map = OrbitMap.new(input)
puts "Orbit count checksum: ", orbit_map.orbit_count_checksum
| true |
488b173e5e3df4b74a1b3627bcc087cc7500e38a | Ruby | Brothman/Classwork | /chess2/slideable_pieces.rb | UTF-8 | 1,415 | 3.53125 | 4 | [] | no_license | require_relative "piece"
require 'byebug'
module Slideable
def moves
#debugger
result = []
self.class::OFFSETS.each do |offset|
multiplier = 0
loop do
multiplier += 1
new_position = calculate_position(offset, multiplier)
if !board.in_range?(new_position)
brea... | true |
1281d18e70f91375c0985bca7e6d8514eaf4870a | Ruby | richpryce/bowling-challenge | /spec/bowling_v2_spec.rb | UTF-8 | 867 | 2.859375 | 3 | [] | no_license | require 'bowling_v2'
describe Bowling_v2 do
before(:each) do
@game = Bowling_v2.new
end
it 'scores 0 when all 0s' do
20.times{@game.roll(0)}
expect(@game.score).to eq 0
end
it 'scores 20 when rolled 1s' do
20.times{@game.roll(1)}
expect(@game.score).to eq 20
end
it 'score a spare' do
... | true |
9cb3308c12a4595d35d53d56937c81d7fcc182e1 | Ruby | starjason/vimeat | /helpers/vimeathelpers.rb | UTF-8 | 2,805 | 2.640625 | 3 | [
"MIT"
] | permissive | module VimEatHelpers
def today_json_file
date_str = `date "+%Y%m%d"`.chop!
"jsons/#{date_str}.json"
end
def read_or_create_today(blackbox_id = nil)
file_name = today_json_file
if !FileTest.exists?(file_name)
i = 0
list = Array.new(4) { Hash.new }
all_r = JSON.parse(get_j... | true |
777830d3aa65422571583f8e4bb1516447529345 | Ruby | gadial/Permutations | /lib/permutator.rb | UTF-8 | 2,085 | 3.421875 | 3 | [] | no_license | require 'polyominoes'
require 'permutations'
class Permutator
def initialize(name)
@name = name
end
def to_s
@name
end
def inspect
to_s
end
def disallowed_permutations
Permutation.all(4) - standard_polyominoes[4].collect{|p| permute(p)}.sort
end
def disallowed_permutations_count_fails... | true |
9f5e73fcd0f71bb5c2c47d1e497b4564919dba68 | Ruby | Tayyab12308/Stockflow | /app/models/transaction.rb | UTF-8 | 1,661 | 2.796875 | 3 | [] | no_license | # == Schema Information
#
# Table name: transactions
#
# id :bigint not null, primary key
# user_id :integer not null
# ticker_symbol :string not null
# transaction_amount :decimal(10, 2) not null
# stock_count :integer not null
# tran... | true |
927a08fb5249464bc87badb19be993f4c4639db6 | Ruby | khamiltonuk/planner | /spec/models/member_spec.rb | UTF-8 | 3,399 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Member do
context 'mandatory attributes' do
context 'validations for a logginable member' do
context 'presence' do
it '#name' do
member = Fabricate.build(:member, can_log_in: true, name: nil)
expect(member).to_not be_valid
expect(member)... | true |
fae03b2297bfc4aac64cf9ff7ae68bb1694cd940 | Ruby | supratim/RubyTutorials | /awsimple.rb | UTF-8 | 485 | 2.953125 | 3 | [] | no_license | require 'rubygems'
require 'simple_record'
SimpleRecord.establish_connection('AKIAJTWRZPPVORZWPQYA','Yx7I3l5hqRTaylOJqxXKw5d5g4+UM0yIAkaqbuBq')
class MyModel < SimpleRecord::Base
has_strings :name
has_ints :age
end
# it section is working to get the data pushed to aws smipledb
#mm = MyModel.new
#mm.name="Roma... | true |
43c8cc3fc79d17609737023837286d4de93cac3f | Ruby | gahenton/intro2programming | /Arrays/exercise1.rb | UTF-8 | 242 | 4.125 | 4 | [] | no_license | # this was fun
arr = [1, 3, 5, 7, 9, 11]
puts "Pick a number to check if it's in the array."
number = gets.chomp.to_i
if arr.include?(number)
puts "#{number} is in the array."
else
puts "#{number} is not in the array."
end
| true |
881855db8fa84362f9686fba230755e8ab936950 | Ruby | muffatruffa/launch_school_ruby_challenges | /advanced1/bowling.rb | UTF-8 | 4,913 | 3.375 | 3 | [] | no_license | class Game
attr_reader :frames
def initialize
@closed = false
start_frames
end
def roll(knocked_pins)
if knocked_pins < 0 || knocked_pins > 10
raise RuntimeError, 'Pins must have a value from 0 to 10'
end
if closed?
raise RuntimeError, 'Should not be able to roll after gam... | true |
3dd3c36899d7118389930c51ba288435033ea4dc | Ruby | lsylvain1726/launchschool_foundations | /small_problems/easy1/exercise10.rb | UTF-8 | 733 | 4.71875 | 5 | [] | no_license | # exercise10.rb
# method takes two arguments
# argument one is a positive integer
# argument two is a boolean
# calculates the bonus for a given salary
# if boolean is true the bonus should be half of the salary
# if the boolena is false the bonus should be 0
# if true bonus is num / 2
# if false bonus is 0
def calc... | true |
4876979b9f6d6123f8fa081b7692994f87331eea | Ruby | averysoren/ls-core-curriculum | /ruby_book/the_basics/exercise6.rb | UTF-8 | 48 | 2.796875 | 3 | [] | no_license | puts 3.3 * 3.3
puts 10.2 * 10.2
puts 12.7 * 12.7 | true |
8640fa73053095b08cfa3ecab03a4215f80118e1 | Ruby | loosechippings/seven-languages | /ruby/open-class-test.rb | UTF-8 | 150 | 3.828125 | 4 | [] | no_license | class Fixnum
def foo
self.times {puts "foo"}
end
def even?
(self.remainder 2)==0
end
end
3.foo
5.times {|i| puts "#{i} is even" if i.even?} | true |
45ea7b6681fea2b55cdaf0e8a217c871d5d278c0 | Ruby | kihaya/lgtmit | /lib/lgtmit/compositer.rb | UTF-8 | 955 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Lgtmit
class Compositer
require "pathname"
attr_accessor :file_name, :image
POS = "0, 0"
TEXT = "LGTM"
COLOR = "#ffffff"
GRAV = "center"
FMT = "png"
P_SCALE = 3
def initialize(file_name)
@file_name = file_name
@image = MiniMagick:... | true |
716fc3dd9ebd2e860ab9a74c88bdb565eeec651c | Ruby | bingyang-hu/App_Academy-_Full_Stack | /Intro/Enumerables & Ranges/First_In_Array.rb | UTF-8 | 515 | 4.71875 | 5 | [] | no_license | #Write a method first_in_array that takes in an array and two elements,
#the method should return the element that appears earlier in the array.
def first_in_array(arr, el1, el2)
index1=arr.index(el1)
index2=arr.index(el2)
# puts index1
# puts index2
if index1<=index2
return arr[index1]... | true |
a485919797e5603fb2704bacd911600536301f1c | Ruby | RyanScottLewis/mruby-termui | /mrblib/term_ui/application.rb | UTF-8 | 4,453 | 2.84375 | 3 | [] | no_license | module TermUI
# A TUI application.
# Should only ever have 1 instance per thread.
class Application
class << self
def run
new.run
end
end
include HasChildren
include HasEvents
def initialize(attributes={})
super
Termbox.ini... | true |
8f8ebe6b301ed2dc828b9659d77f55d46e373c28 | Ruby | syfo/the_force | /test/unit/test_memoize.rb | UTF-8 | 1,041 | 3.375 | 3 | [
"MIT"
] | permissive | require 'the_force/memoize'
class Memoizer
def initialize
@value = 1
@other = 2
end
def inc
@value +=1
end
def meth
3
end
attr_memoize :a do
@value
end
attr_memoize :test_instance_variable_access do
@other
end
attr_memoize :test_instance_method_access do
... | true |
0b4aecd4dd3a196a9c5bf1772e7b78647d08f75a | Ruby | JFVF/cucumber_022015 | /Jimmy/Session14/features/step_definitions/practice_daily_tasks.steps.rb | UTF-8 | 1,278 | 2.71875 | 3 | [] | no_license | Given(/^I waked up$/) do
end
And(/^I took a shower$/) do
end
And(/^I brushed my teeth$/) do
end
Given(/^I am ready to go to work$/) do
end
And(/^my children are ready to go to the kindergaten$/) do
end
And(/^I am not in the kidergarten$/) do
end
And(/^my children are not in the kindergarten$/) do
... | true |
ec48ed3e0b08d80b081d7eca979445c52cd41fb8 | Ruby | zverok/bloxl | /lib/bloxl/builder.rb | UTF-8 | 1,621 | 3.09375 | 3 | [] | no_license | module BloXL
class Builder
def initialize(sheet)
@sheet = sheet
@r, @c = 0, 0
@max_r, @max_c = 0, 0
end
def table(data, options = {})
data.is_a?(Array) && data.each{|r| r.is_a?(Array)} or
fail ArgumentError, "Not a 2D array: #{data.inspect}"
data.each_with_index do ... | true |
c08a59b7b18cdcc412438fb7b4baa4d382e9975e | Ruby | jorgeperis/ironhack | /Week_2/extra/life.rb | UTF-8 | 1,574 | 3.703125 | 4 | [] | no_license | require 'pry'
class Cell
attr_reader :state
def initialize(state, neighbours)
@state = state
@neighbours = neighbours
end
def regenerate
return 1 if ((@neighbours.reduce(:+) == 2) || (@neighbours.reduce(:+) == 3)) && @state == 1
return 1 if (@neighbours.reduce(:+) == 3) && @state == 0
retu... | true |
b6d7be5dfccbb23a5c981217cef4ac51cde16b1c | Ruby | Loulou0070226/Exosruby2 | /exo_05.rb | UTF-8 | 230 | 3.703125 | 4 | [] | no_license | puts "Give me a number"
user_number = gets. to_i
#Ici il faut préciser combien de fois sera répéter la phrase selon le nombre donné par l'utilisateur
user_number.times do "Salut, ça farte ?"
puts 'Salut, ça farte ?'
end | true |
62bb2a5d87cec148f01e156eefc9c42474511a74 | Ruby | MiroslavCsonka/lamep | /lib/lamep/Expressions/greater_than.rb | UTF-8 | 254 | 2.65625 | 3 | [
"MIT"
] | permissive | class GreaterThan < Arity2Operators
Operator.register('>', GreaterThan, 8)
def to_sql
"(#{@left.to_sql} > #{@right.to_sql})"
end
def evaluate(attributes={})
@left.evaluate(attributes).to_i > @right.evaluate(attributes).to_i
end
end
| true |
b4a27852fd6682abfbd0274c48593b6a43d0606a | Ruby | jaleszek/notes_api | /app/models/note/storage.rb | UTF-8 | 653 | 2.9375 | 3 | [] | no_license | require 'fileutils'
class Note
class Storage
DEFAULT_DIR = "./storage"
def initialize(dir = DEFAULT_DIR)
@current_dir = dir
unless File.directory?(@current_dir)
FileUtils.mkdir_p(@current_dir)
end
end
def write(content)
id = new_filename
File.wr... | true |
c146f0fc1b83b6602a2cfe3c296127b0135b44b4 | Ruby | mizukami234/attr_value_object | /lib/attr_value_object.rb | UTF-8 | 758 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'attr_value_object/version'
require 'active_support/core_ext/string'
module AttrValueObject
def attr_value_object(name, options = {})
klass = Object.const_get(options.fetch(:class_name, name.to_s.camelize))
define_method(name) do
mappings = methods.map { |m| m.match(/\A#{name}_([0-9a-z_]+)\z/).try ... | true |
452ca475b5face4ffc6306656c1f8e3d0e374da8 | Ruby | Jamalp/calculator | /calculator.rb | UTF-8 | 2,073 | 4.375 | 4 | [] | no_license | def get_two_numbers
puts "whats the first number?"
num1 = gets.chomp.to_f
puts "whats the second number?"
num2 = gets.chomp.to_f
return num1, num2
end
def add(num1, num2)
return num1+num2
end
def subtract(num1, num2)
return num1 - num2
end
def divide(num1, num2)
return num1 / num2
end
def multiply... | true |
df0899c8c25a25dee7b9aca76c2c31e74d73bd51 | Ruby | garybernhardt/rubies | /spec/rubies/environment_spec.rb | UTF-8 | 2,059 | 2.65625 | 3 | [
"MIT"
] | permissive | require "rubies"
module Rubies
describe Environment do
describe "constructed from a Unix environment" do
it "translates Unix environment keys to our keys" do
env = Environment.from_system_environment(
"PATH" => "path",
"GEM_HOME" => "/gem/home",
"GEM_PATH" => "/gem/pat... | true |
00d03bb3d54e9a28cc1ba10c65dc901efab2e925 | Ruby | pixelastic/pdf | /bin/pdf-explode | UTF-8 | 559 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'ruby-progressbar'
require_relative '../lib/pdf_helper'
# Extract a pdf into several pages
class PdfExplode
include PdfHelper
def initialize(*args)
@input = args[0]
end
def run
page_count = page_count(@input)
progress = ProgressBar.create(
title: 'Exploding',
... | true |
7f2985522c8ca260f2312800128ff2704f8a4038 | Ruby | Airess/Skillcrush | /if_statements.rb | UTF-8 | 120 | 3.859375 | 4 | [] | no_license | #if statements
y = 8
if y >= 9
puts "Yes y is greater than or less than 7"
else puts "Nope it's less than"
end | true |
8ff6ebd87fddf5e2fd426e40b6ea4bdb4be30d06 | Ruby | maxcal/windsong | /app/mailers/station_mailer.rb | UTF-8 | 1,529 | 2.53125 | 3 | [] | no_license | class StationMailer < ActionMailer::Base
default from: "from@example.com"
attr_accessor :user
attr_internal :event
# @param [User] user
# @param [Event] event
# @return [Mail]
def online(user, event)
@station = event.station
message = mail(
to: user.email,
subject: "#{event.stati... | true |
e1e8115f8de8ac20738c9663db72afec04335d16 | Ruby | allensoberano/lauchschool_backend | /excercises/loops_1.rb | UTF-8 | 1,163 | 4.5 | 4 | [] | no_license | #1.
loop do
puts 'Just keep printing...'
break
end
#2.
loop do
puts 'This is the outer loop.'
loop do
puts 'This is the inner loop.'
break
end
break
end
puts 'This is outside all loops.'
#3.
iterations = 1
loop do
puts "Number of iterations = #{iterations}"
iterations += 1
break if iter... | true |
0bc8d0cf979458760b8a166c7c7181c1936857cb | Ruby | AVGP/heroku-build | /lib/heroku/build.rb | UTF-8 | 1,768 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'heroku/command/base'
require "net/https"
require "json"
require_relative 'source'
PLUGIN_VERSION="1.0.2"
class Heroku::Command::Build < Heroku::Command::BaseWithApp
def index
tarball_path = args.shift
version = args.shift
# Not all params present? Show usage, exit.
if tarball_path.nil? ||... | true |
4410ff199fbcaeb547317971d56ae5d108bab431 | Ruby | EliseFitz15/golfer_handicap | /calculate.rb | UTF-8 | 398 | 2.90625 | 3 | [] | no_license | require 'csv'
require_relative 'round'
require_relative 'handicap'
rounds = CSV.readlines('rounds.csv', headers: true)
golfers_rounds = []
rounds.each do |round|
round_date = Date.strptime(round['DATE'], "%m/%d/%Y")
golfers_rounds << Round.new(round_date, round['SCORE'], round['RATING'], round['SLOPE'])
end
golf... | true |
13d2b2a420d23cb3acd18a390895228760b289dc | Ruby | amenning/Design_Patterns_GOF_In_Ruby | /Structural_Patterns/object_structural/adapter/text_shape.rb | UTF-8 | 570 | 3.140625 | 3 | [] | no_license | require_relative 'shape.rb'
require_relative 'text_manipulator.rb'
require_relative 'point.rb'
class TextShape
include Shape
def initialize(text_view)
@text_view = text_view
end
def bounding_box(bottom_left = nil, top_right = nil)
bottom, left = @text_view.get_origin
width, height = @text_view.ge... | true |
fed299a3f9b051e24cd613a006244e9e089addb7 | Ruby | ShadowMomo/Smomo-RGSS-Scripts | /Lempel Ziv Welch Encoding.rb | UTF-8 | 2,082 | 3.328125 | 3 | [
"MIT"
] | permissive | #=============================================================================
# ** Lempel Ziv Welch Encoding
# Implementator: Shadow Momo
#-----------------------------------------------------------------------------
# Compressor: LZW.com(somestring, spliter = "#")
# Decompressor: LZW.dec(somecode, spliter = "#")
... | true |
b3afa3fb01aecdcc67f570d8820ff2e344b647d9 | Ruby | jm-maniego/shopping_cart | /test.rb | UTF-8 | 1,373 | 2.734375 | 3 | [] | no_license | require './shopping_cart'
require 'test-unit'
class ShoppingCartTest < Test::Unit::TestCase
def setup
@pricing_rules = []
three4two_rule = NForNPricingRule.new(3, 2, 'ult_small')
bulk_discount_rule = BulkDiscountPricingRule.new('ult_large')
@pricing_rules.push(three4two_rule)
@pricing_rules.push... | true |
ae54239e7891486b0c5f66faf07a9c0bf675399c | Ruby | garet-rich/toy_server | /lib/server.rb | UTF-8 | 949 | 3.09375 | 3 | [] | no_license | require 'socket'
class Server
def initialize()
@server = TCPServer.new(9292)
loop do
read_request()
path_route(@request_lines[0])
@connection.close
end
end
def read_request()
@connection = @server.accept
@request_lines = []
... | true |
d2a8776236c0ddb5a1b352d81d1adaab0c618d7a | Ruby | rayrowe125/DevPoint | /rps.rb | UTF-8 | 1,479 | 3.828125 | 4 | [] | no_license | @Wins = 0
@Losses = 0
@Ties = 0
def game
continue = true
while continue == true
puts "choose rock, paper, or scissors"
user1 = gets.chomp
choices = ["rock", "paper", "scissors"]
comp = choices.sample
puts "computer chooses #{comp}"
if user1 == "rock" #USER CHOOSES ROCK
if... | true |
acdafe074427a2be182ed4f0f2b343c2affca399 | Ruby | Arkham/metaprog-examples | /codeception/checked_attributes_fourth.rb | UTF-8 | 859 | 3.21875 | 3 | [] | no_license | require 'test/unit'
module AttrChecked
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def attr_checked(attribute, &block)
define_method attribute do
self.instance_variable_get "@#{attribute}"
end
define_method "#{attribute}=" do |value|
raise ... | true |
64b06fd9ef08fbe324b832685e7063f2499736bc | Ruby | SilverPhoenix99/ducktape | /lib/ducktape/expression/binary_op_exp.rb | UTF-8 | 861 | 2.625 | 3 | [
"MIT"
] | permissive | module Ducktape
module Expression
module BinaryOpExp
attr_reader :left, :right
attr_reader :owner
def initialize(left, right)
@left, @right = left, right
end
def owner=(o)
@owner, left.owner, right.owner = [o]*3
end
def bind(src, type, qua... | true |
b33e66397235390894b5abdb981527ae43f37fbe | Ruby | r7kamura/plz | /lib/plz/error_command.rb | UTF-8 | 299 | 2.96875 | 3 | [
"MIT"
] | permissive | module Plz
class ErrorCommand
# @param error [Plz::Error] Error to show error message to user
def initialize(error)
@error = error
end
# Logs out error reason and usage, then exits with error code 1
def call
puts "Error: #{@error}"
exit(1)
end
end
end
| true |
15b23595779b8f3973d1d33721fdf3ac1c50cd45 | Ruby | chrisgillis/serif | /lib/serif/markup_renderer.rb | UTF-8 | 734 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Serif
class MarkupRenderer < Redcarpet::Render::SmartyHTML
def block_code(code, language)
# bypass it all to avoid sticking highlighting markup on stuff with no language.
#
# note that we add a new line after the initial ``` but not before the closing
# ``` because otherwise it introduces an ex... | true |
41ee5b247562fdd3c091f27086dc7dc2fecfaa58 | Ruby | tono77/presencial18 | /curso.rb | UTF-8 | 1,128 | 3.671875 | 4 | [] | no_license | require 'date'
class Course
attr_accessor :name, :start_date, :end_date
def initialize(name, start_date, end_date)
@name = name
@start_date = Date.parse(start_date)
@end_date = Date.parse(end_date)
end
def start_course(date)
@start_date < date ? true : false
end
def end_course(date)
... | true |
e6b25089a9c960b0e1096aaad4c1a2f2be77ddcf | Ruby | Jberma23/Mod_1_project | /app/models/organization.rb | UTF-8 | 2,307 | 2.84375 | 3 | [
"MIT"
] | permissive | class Organization < ActiveRecord::Base
has_many :departments
has_many :sectors, through: :departments
has_many :jobs
def org_salary_int(value)
num = value.remove("$", ",")
num.to_i
end
def avg_sal_org
org_sal = 0
self.jobs.each do |job|
z = []
... | true |
3104f461d91c990f4e303313b28f314341dbb25e | Ruby | Jeantirard/TheHackingProject2018 | /semaine0/Jeudi/exo_05.rb | UTF-8 | 1,710 | 3.75 | 4 | [] | no_license | #Opérateur qui permet l'interpolation à l'intérieur des chaînes de caractères.
#Affiche le texte qui est entre les ("...")
puts "On va compter le nombre d'heures de travail à THP"
#Affiche le texte qui est entre les ("..."), calcule ce qui est entre #{} puis il affiche le resultat.
puts "Travail : #{10 * 5 * 11}"
#A... | true |
aa375153a7c54644e6e455e2fc18186f39583e0c | Ruby | jengsala/saveflap | /vendor/bundle/ruby/2.5.0/gems/trailblazer-activity-0.5.2/lib/trailblazer/circuit.rb | UTF-8 | 2,847 | 2.984375 | 3 | [] | no_license | module Trailblazer
# Running a Circuit instance will run all tasks sequentially depending on the former's result.
# Each task is called and retrieves the former task's return values.
#
# Note: Please use #Activity as a public circuit builder.
#
# @param map [Hash] Defines the wiring.
# @param stop... | true |
5899176246523a1dec5d3edefd59991e913c4795 | Ruby | nmcolome/headcount | /lib/district_repository.rb | UTF-8 | 1,281 | 2.96875 | 3 | [] | no_license | require_relative 'repository_module'
require_relative 'district'
require_relative 'enrollment_repository'
require_relative 'statewide_test_repository'
require_relative 'economic_profile_repository'
class DistrictRepository
include Repository
attr_reader :districts,
:enrollment_repository,
... | true |
c25e11358397d76f3ae11649b1befd0dd3f1b62c | Ruby | cdadar/kindle | /bin/notes_for_book.rb | UTF-8 | 543 | 3 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'kindle'
unless ARGV[0] && File.exists?(ARGV[0])
puts "ERROR: need file"
exit(-1)
end
unless ARGV[1]
puts "ERROR: need a book name"
exit(-1)
end
search_for = Regexp.new(Regexp.escape(Regexp.escape(ARGV[1])), Regexp::IGNORE... | true |
6d8f00c56bf3a3c5d5dd64c9e386d8f0e7fb1e4f | Ruby | onahump/Course-Ruby-On-Rails | /Ejemplos/listas.rb | UTF-8 | 1,510 | 3.875 | 4 | [] | no_license | equipos = ["Cruz-Azul" , "Real Madrid", "Manchester United", "Galatasaray", "Porto"]
puts "Lista de equipos"
puts equipos
puts "Mostrando el equipo en la posicion 4"
puts equipos[3]
puts "Mostrando el equipo en la posicion 2"
puts equipos.fetch(1)
puts "Mostrando el equipo en la posicion 11 y si no existe enviamos ... | true |
7abc79e8f1e0d5df2e7931c5ebe30833d0204fb5 | Ruby | completelynovel/money_badger | /lib/money_badger/core_extensions.rb | UTF-8 | 2,277 | 3.078125 | 3 | [
"MIT"
] | permissive |
require 'bigdecimal'
module MoneyBadger
module StringExtensions
def to_money(options = {})
# Get the currency
if options[:currency]
currency = options[:currency]
else
matches = scan(/([A-Z]{2,3})/)
currency = matches[0] ? matches[0][0] : Money.default_currenc... | true |
f54e06155063f58cf81f2f8d51a8fd1de0a09383 | Ruby | tatsuo98se/mini4pi_receiver_ruby | /client.rb | UTF-8 | 232 | 2.859375 | 3 | [] | no_license | require "socket"
begin
#localhostの20000ポートに接続
socket = TCPSocket.open("localhost",20000)
rescue
puts "TCPSocket.open failed :#$!"
else
loop do
msg = socket.write "1\n"
sleep 1
end
socket.close
end
| true |
f9a96a8553ccdff1771c0cba955689e5c7a4b664 | Ruby | andersonar2004/gosu_pong | /main.rb | UTF-8 | 3,636 | 3.15625 | 3 | [] | no_license | require 'gosu'
require 'forwardable'
class Ball
extend Forwardable
def_delegators :@block, :x, :y
def initialize
@block = Block.new(Block::BLOCK_SIZE, Block::BLOCK_SIZE)
@direction_x = 10
@direction_y = 2
@pong = false
end
def draw
@block.draw
end
def move(paddle)
@block.x += ... | true |
1bf16e68e51c0d359d22f8141ad1ba9e76f7655a | Ruby | FireGoblin/foodierecs | /make_index.rb | UTF-8 | 537 | 2.96875 | 3 | [] | no_license | f = File.new("restaurants.txt", "w")
restaurant = Array.new
Restaurant.all.each do |i|
restaurant[restaurant.count] = i
end
restaurant = restaurant.sort_by &:formatted_name
last_name = ""
index = 1
restaurant.each do |x|
if(x["formatted_name"] == last_name)
index += 1
else
index = 1
end
if(index == 1)
... | true |
0ddcd0bcf9453a0ce423703613274097c723c09b | Ruby | sunnysun09/balance_checking_page_object | /features/support/pages/Login_Page.rb | UTF-8 | 1,157 | 2.640625 | 3 | [] | no_license | require_relative '../lib/Common.rb'
class Login_Page
include PageObject
include PageObject::PageFactory
page_url('C:/Users/test/balance_checking_new/features/login.html')
h1(:login_line, :text => 'Login page for balance detail checking')
text_field(:login_user, :name => 'fname')
text... | true |
901039fb4fdfc967b704674aa6c63523d0901abb | Ruby | LUKERHYS/Planets_lab_W2_D4 | /start_point/star_system.rb | UTF-8 | 1,460 | 3.390625 | 3 | [] | no_license | class StarSystem
attr_reader :name, :planets
def initialize(name, planets)
@name = name
@planets = planets
end
def planet_names()
return @planets.map {|planet| planet.name}
end
def get_planet_by_name(planet_name)
#binding.pry
return @planets.find {|planet| planet.name == planet_name}
end
... | true |
f4883df47c82901e481324b32723b2fcfd72da76 | Ruby | PieterJanDelbecke/terminal_app | /tests/test.rb | UTF-8 | 2,046 | 3.234375 | 3 | [] | no_license | require './models/game'
require './views/games/challenge'
require './views/games/index'
require 'minitest/autorun'
describe "when first created" do # Testing when a new instance of the Game class get initiated.
it "game.name is empty" do # It tests if the instance v... | true |
5735b06f077221c8161f195b3f686d33ab81564c | Ruby | Kreyren/benchmarks | /matmul/matmul.rb | UTF-8 | 1,232 | 3.125 | 3 | [
"MIT"
] | permissive | # Writen by Attractive Chaos; distributed under the MIT license
require 'socket'
def matmul(a, b)
m = a.length
n = a[0].length
p = b[0].length
# transpose
b2 = Array.new(n) { Array.new(p) { 0 } }
n.times do |i|
p.times do |j|
b2[j][i] = b[i][j]
end
end
# multiplication
c = Array.new(m... | true |
5dc7b2cf751e94bed2289307b35ef623ddc5a1eb | Ruby | lfrancoeur/Ruby | /Return_Values_2.rb | UTF-8 | 231 | 3.359375 | 3 | [] | no_license | def nothing
end
p nothing #returns nil
def return_string
"What will be the return value here?"
end
p return_string
def return_guess
puts "What will be the return value here?" #this will return nil always
end
p return_guess
| true |
bab9fdcee9550402c8a0611a96a25f6f8ea8a266 | Ruby | CodeForFunFun/mobile-secrets | /lib/mobile-secrets.rb | UTF-8 | 4,107 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'src/secrets_handler'
require "dotgpg"
module MobileSecrets
class Cli
def header
"Mobile Secrets HELP:
##############################################################################################################################
## %# #%%%( ##% ,%%% (%%/ *%... | true |
5096a14f6fc12ad87e723ba42803ebabaff31098 | Ruby | YinnyF/codewars | /Ruby/7KYU/credit-card-mask.rb | UTF-8 | 198 | 2.6875 | 3 | [] | no_license | =begin
https://www.codewars.com/kata/5412509bd436bd33920011bc
=end
# my solution
def maskify(cc)
cc.length <= 4 ? cc : "#" * (cc.length - 4) + cc[-4..-1]
end
# solution uses string mathematics
| true |
3a0a0ece6a49fa2ba4d056d34c0785e425b85295 | Ruby | TheObtuseAutodidact/homework_module1 | /homework2/more_strings_and_arrays.rb | UTF-8 | 3,409 | 4.65625 | 5 | [] | no_license | # 1. Using Variable Method Arguments
#
# Write a method that takes any number of arguments, and prints the value of the first and last arguments, ignoring any middle ones.
#
# For example, using this method from IRB or Pry might look like:
#
# variable("first", "second", "third")
# first
# third
# nil
def first_and_la... | true |
e1b7f43a82455a697f8f8c656cdd744b3ea26bd4 | Ruby | yukimura1227/librarian | /app/models/book.rb | UTF-8 | 1,631 | 2.578125 | 3 | [
"MIT"
] | permissive | # model for books
class Book < ApplicationRecord
include Utility::Slack
RENTAL_LIMIT_DAYS = 30
belongs_to :order
belongs_to :user, optional: true
has_one :last_rental_operation, -> { order(id: :desc) }, class_name: 'Operation::Rental'
has_many :rental_operations, class_name: 'Operation::Rental'
scope :re... | true |
8634da83f01e580009e9e136b687da7f0596c499 | Ruby | hx/epi | /lib/epi/configuration_file.rb | UTF-8 | 1,397 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require 'forwardable'
require 'pathname'
require 'digest'
module Epi
class ConfigurationFile
extend Forwardable
include Exceptions
attr_reader :path, :job_descriptions
delegate [:exist?, :binread] => :path
def initialize(path)
@job_descriptions = {}
@path = Pathname path
end
... | true |
a63bae67e65e85b430631d289b418e447730a7d2 | Ruby | MdRashidReza/cuddly-goggles | /20p.rb | UTF-8 | 342 | 3.875 | 4 | [] | no_license | #Programing for string manipulation
$KCODE ='a'
x,y,z =12, 13, 15
puts "The value of x is #{x}"
puts "The value of y is #{y}"
puts "The value of z is #{z}"
puts %q{Ruby is Fun.}
puts %Q{Ruby is\b Fun\n.}
str1= String.new("seedOlabs")
str2=str1.capitalize
puts "#{str2}"
str3=str1.downcase
puts "#{str3}"
str4=str3.r... | true |
36a0a186aafbc5043e160d3b9653bb4b75fa3554 | Ruby | VirtualLindsey/hotel | /specs/daterange_spec.rb | UTF-8 | 723 | 2.6875 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../lib/daterange'
describe "DateRange" do
describe "initialize" do
it "checks initialize" do
start_date = Date.new(2017,1,1)
end_date = Date.new(2017,1,3)
date = DateRange.new(start_date, end_date)
date.must_respond_to :start_date
date.start_... | true |
22f9975d48037a1272dc26b2e48ade8198b06ef7 | Ruby | ZeusPerez/fraud-detection-ruby | /lib/fraud_radar.rb | UTF-8 | 358 | 2.671875 | 3 | [] | no_license | class FraudRadar
def initialize(file)
@file = file
end
def check
orders = FileParser.new(@file).parse
normalized_orders = OrderNormalizer.new(orders).normalize
email_frauds = EmailChecker.new(normalized_orders).detect
address_frauds = AddressChecker.new(normalized_orders).detect
(email_fr... | true |
84a13572c36e613b559585c211326ad4d1b13559 | Ruby | lehnerchristian/ScalableWebArchitectures | /lib/LocationManagement/location_management_system.rb | UTF-8 | 1,122 | 2.515625 | 3 | [] | no_license | require 'grape'
require_relative '../filter_helper'
require_relative '../client'
class LocationManagementSystem < Grape::API
version 'v1', using: :header, vendor: 'project'
format :json
locations = []
id = 1
size = locations.length
helpers do
def authenticate!
status = FilterHelper.auth_helper(Client, en... | true |
acb4af30f8cb520dc3ac512aaa88f6be14b9fda2 | Ruby | mkim4247/keys-of-hash-dc-web-100818 | /lib/keys_of_hash.rb | UTF-8 | 412 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Hash
def keys_of(*arguments)
arr = []
self.each do |key, val|
arguments.each do |value|
if value == self[key]
arr << key
end
end
end
arr
end
end
#return array with every key from hash whose value matches the values given as an argument
# test is calling .keys_of... | true |
1ad5a3a52dc20d4300d29df1f1ed6a38c86569bc | Ruby | jdixon3/RB101_Lesson_2 | /precedence.rb | UTF-8 | 787 | 4.09375 | 4 | [] | no_license |
# array = [1, 2, 3]
# mapped_array = array.map { |num| num + 1 }
# mapped_array.tap { |value| value }
# mapped_and_tapped = mapped_array.tap { |value| p 'hello'}
# p mapped_and_tapped
# regex practice/examples....
# if "Do you like dogs?".match(/cats/)
# puts "match found!"
# else
# puts "invalid entry, pl... | true |
bc11756adda019729a8e3f99efc28e90c6f9b281 | Ruby | kfili/codewars | /8kyu-difficulty-level/even-or-odd/problem.rb | UTF-8 | 205 | 4 | 4 | [] | no_license | # https://www.codewars.com/kata/even-or-odd/train/ruby
# Create a function that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers.
def even_or_odd(number)
end
| true |
f905bfb705c5c9520e42e1f6ec1de4e9e5a8a1ed | Ruby | excellence/nebula | /app/helpers/application_helper.rb | UTF-8 | 764 | 2.703125 | 3 | [] | no_license | # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# All top-level headings on pages should use this helper like so:
# %h1=title "Some Title"
# This sets the <title> tag appropriately in the head of the page.
def title(text)
@title = text
retur... | true |
99e0f4bad3ccb0960f12ab943cfbc5f338a2c1d6 | Ruby | fizx/scripts | /bin/median | UTF-8 | 110 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby
arr = []
while line = STDIN.gets
arr << line.to_f
end
arr.sort!
puts arr[arr.length / 2] | true |
7b54b1703f30bdca287e86b69442ad8d33c15245 | Ruby | icleversoft/readpoint | /lib/readpoint/npcategory.rb | UTF-8 | 323 | 2.59375 | 3 | [
"MIT"
] | permissive | module Readpoint
class Npcategory
attr_reader :cat_id, :cat_name, :parent_id, :parent_name
def initialize( category )
@cat_id = category[:@cat_id].to_i
@cat_name = category[:@cat_name]
@parent_id = category[:@cat_parent_id].to_i
@parent_name = category[:@cat_parent_name]
end
end
... | true |
a81529405bafd7fc0a7fa08ff07663b005e3126d | Ruby | davidtdang/rails-practice-add-rspec | /spec/features/events_spec.rb | UTF-8 | 2,267 | 2.71875 | 3 | [] | no_license | require 'rails_helper'
feature 'CRUDing events' do
### CREATE
scenario 'User can create an event' do #scenario, create, description is ( SET UP)
visit root_path #visit, click_on, fill_in are things the USER would be doing that test simulates (DO THE THING)
click_on "New Event"
fill_in "Descri... | true |
f2ed2f687aa12aa3b9ed9f2fc92646242126cd5e | Ruby | dr3amak3r/RubyRESTSRiRProject | /test_person4.rb | UTF-8 | 2,309 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
require "test/unit"
load 'person4.rb'
# @author Kamil Różański
class TestCompileFunction < Test::Unit::TestCase
# sprawdzanie czy zapisana została paczka zip po przez porównanie ścieżek wzglednych
def test_zip_it
server = Person4.new()
path = "#{File.expand_path(__FILE__)}"
path = pa... | true |
99a639d71d0790c03d3f5c38cfeafe0b0c58176d | Ruby | mashedkeyboard/zxcvbn-ruby | /lib/zxcvbn/data.rb | UTF-8 | 847 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'json'
require 'zxcvbn/dictionary_ranker'
module Zxcvbn
class Data
def initialize
@ranked_dictionaries = DictionaryRanker.rank_dictionaries(
"english" => read_word_list("english.txt"),
"female_names" => read_word_list("female_names.txt"),
"male_names" => read_word_lis... | true |
ee78864dd5135b43cfa54b45505db9c57b99c061 | Ruby | callahanrts/dbmgr | /test/helpers/mysql_helper.rb | UTF-8 | 986 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'mysql2'
class MySQLHelper
DB_NAME = "dbmgr_test"
def initialize names
initialize_database
insert_users names
end
def truncate
mysql_client(DB_NAME).query "TRUNCATE TABLE users"
end
def drop
mysql_client(DB_NAME).query "DROP DATABASE IF EXISTS dbmgr_test"
end
def num_users
... | true |
afa6a4b90d6552c13cb3e2561fea251b7e8bce2d | Ruby | tiago972/git-thp | /D04/lib/02_password.rb | UTF-8 | 474 | 3 | 3 | [] | no_license | def signup
puts "Enregistre un mot de passe"
print "> "
password = gets.chomp
return password
end
def login(password)
puts "Quel est ton mot de passe ?"
print "> "
login_try = gets.chomp
if login_try == password
welcome_screen
else
puts "Error fatal du système DOS, retente ta chance, born loser"
login(... | true |
7d78c1b15a1da910007381d41fdbefbd36696069 | Ruby | danilpanshin/metaprogramming | /train.rb | UTF-8 | 1,862 | 3.28125 | 3 | [] | no_license | require_relative 'company_manufacturer'
require_relative 'valid'
require_relative 'instance_counter'
require_relative 'wagon'
require_relative 'accessors'
require_relative 'validation'
class Train
include CompanyName
include Exceptions
include InstanceCounter
include Validation
extend Acessors
attr_reade... | true |
401f087c20453299860e4b514cab77665e5dc4d1 | Ruby | BJSummerfield/Practice-App | /app/controllers/api/sample_pages_controller.rb | UTF-8 | 772 | 2.578125 | 3 | [] | no_license | class Api::SamplePagesController < ApplicationController
def fortune_method
fortune = ["You will die", "You'll be happy", "Eat more"]
fortune = fortune.shuffle
@message = fortune[0]
render 'fortune.json.jbuilder'
end
def lotto_method
@lotto = []
6.times do
number = rand(1..60)
... | true |
10a2c383cb10034570de9421f82728b5633ec5d9 | Ruby | atsutsumi/mrs_server_f | /lgdisit/spec/lgdisit/net/mail_message_spec.rb | UTF-8 | 2,092 | 2.515625 | 3 | [] | no_license | require "spec_helper"
describe Lgdisit::Net::MailMessage do
let(:to_mail_address) { [double("to_mail_address1"),double("to_mail_address2")] }
let(:from_mail_address) { double("from_mail_address") }
let(:mail_subject) { double("subject") }
let(:mail_body) { double("body") }
context "creating an instance" do
con... | true |
495e981e3c43c1706fc950ea45fa1735fff94161 | Ruby | onewland/carmen-sandiego | /lib/carmen_sandiego.rb | UTF-8 | 3,687 | 2.828125 | 3 | [] | no_license | require 'httparty'
=begin
CarmenSandiego makes searching GeoAPI not suck for Ruby.
d = CarmenSandiego::Detective.new('api key goes here')
spots = d.search do |q|
q.radius 1
q.radius_unit :km
q.lat 27.93547
q.lng -82.50429
end
=end
module CarmenSandiego
class QueryBuilder
def initialize
@resul... | true |
1974c7720008511bf00636922c6946822f150a1c | Ruby | Serenity911/week2-ruby-hw-Karaoke | /specs/room_spec.rb | UTF-8 | 2,984 | 2.875 | 3 | [] | no_license | require("minitest/autorun")
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require("pry")
# binding.pry
require_relative("../room")
require_relative("../customer")
class RoomTest < MiniTest::Test
def setup
@room1 = Room.new("The blue room", 2, 10)
@customer1 =... | true |
4ae93c5443a9d506823a0676363294d6a59df500 | Ruby | tcrane20/AdvanceWarsEngine | /Advance Wars Edit/Scripts_Old/[163]CO_Grimm.rb | UTF-8 | 1,626 | 3.015625 | 3 | [] | no_license | ################################################################################
# Class Grimm
# Army: Yellow Comet Power Bar: x x x X X X
#
# - 130/90 Units
# - 120/80 Units during other player turns
#
# Power: Knuckle Duster
# - 160/90 Units
# - 140/80 Units during other player turns
#
# Super Power: Haym... | true |
c673d549819c42e5bb73913182c37ea7efa5edc6 | Ruby | GiuseppeIbba/wk02_day05_weekendHW_CCC | /room.rb | UTF-8 | 779 | 3.140625 | 3 | [] | no_license | class Room
attr_reader :genre, :guests, :playlist
def initialize(genre, guests, playlist)
@genre = genre
@guests = guests || []
@playlist = playlist || []
end
def available()
if @guests.length == nil
end
end
def guest_in(check_in_guest)
@guests << check_in_guest
end
... | true |
601d13d680200a167f87363fc2521ea46349157a | Ruby | nigelr/brisruby_rspec_intro | /calc_spec.rb | UTF-8 | 1,183 | 3.34375 | 3 | [] | no_license | require 'rspec'
class Calc
attr_reader :accumulator
def initialize x
@accumulator = x
end
def increment
@accumulator += 1
end
def accumulator_zero?
accumulator == 0
end
end
describe Calc do
describe '#accumulator_zero?' do
it 'is zero' do
new_calc = Calc.new(0)
expect(ne... | true |
399aafeaf52852a13b49fce3915204a7eb9a5194 | Ruby | pducks32/intergrala | /lib/intergrala/equation_solver.rb | UTF-8 | 1,356 | 2.78125 | 3 | [
"MIT"
] | permissive | module EquationSolver
@@normalize_mappings = {"dependentVariable" => "dependent",
"independentVariable" => "independent",
"integrationMethod" => "method",
"upperBound" => "upper_bound",
"lowerBound" => "lower_boun... | true |
87347bf2c8f7ab1eefbf6b615eb17f804cef51e8 | Ruby | leggetter/leggetter.co.uk | /_plugins/header.rb | UTF-8 | 511 | 2.703125 | 3 | [] | no_license | class Jekyll::MarkdownHeader < Jekyll::Converters::Markdown
def convert(content)
result = super.gsub(/<h(\d)>(.*?)<\/h(\d)>/){
|h| "<h#{$1} id=\"#{self.parameterise($2)}\"><a href=\"##{self.parameterise($2)}\">#{$2}</a></h#{$1}>"
}
# result = super.gsub(/<h(\d)>(.*?)<\/h(\d)>/, '... | true |
62083b6d47d7d4d264baf102dc3b0e25359c8441 | Ruby | albertobraschi/search_engine_position | /spec/search_engine_position_spec.rb | UTF-8 | 2,698 | 2.703125 | 3 | [] | no_license | require File.join(File.dirname(__FILE__), '/../lib/search_engine_position')
describe SearchEnginePosition do
describe "with no site and no keyword" do
it "should complain" do
lambda { SearchEnginePosition.new }.should raise_error(ArgumentError)
end
end
describe "with no search_engine and no ... | true |
8bb881f0e6c6e4ff458fb7cbd2bbc2d353ceb91b | Ruby | tilljoel/bgc-account | /lib/bgc/account/bankgiro.rb | UTF-8 | 1,280 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
require 'active_model'
require 'bgc/account/base'
require 'bgc/account/validations'
require 'bgc/account/checksum/checksum'
require 'bgc/account/data/revoked_fundraising'
module BGC::Account
# Bankgirot is a proprietary clearing system in Sweden used for
# transactions such as bill payments. It ... | true |
4ababfe035ebcda5f0d4f44b7914609b632fb16d | Ruby | jeremyevans/roda | /lib/roda/plugins/render.rb | UTF-8 | 33,773 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
require "tilt"
class Roda
module RodaPlugins
# The render plugin adds support for template rendering using the tilt
# library. Two methods are provided for template rendering, +view+
# (which uses the layout) and +render+ (which does not).
#
# plugin :render
... | true |
7706cda9466d67d4e3eb032b806320b6981000ec | Ruby | madlad33/Ruby-OOP | /Managing Dependencies/dependent_code.rb | UTF-8 | 426 | 3.625 | 4 | [
"MIT"
] | permissive | class Gear
attr_reader :chainring, :cog, :rim, :tire
def initialize(chainring,cog,rim,tire)
@chainring = chainring
@cog = cog
@rim = rim
@tire = tire
end
def gear_inches
ratio * Wheel.new(rim,tire).diameter
end
def ratio
chainring/cog.to_f
end
end
class Wheel
attr_reader :tire, :rim
def initialize(rim,tire)
@... | true |
5f39950e4d24d681e467dd94a440b1154667990c | Ruby | achhetr/medical-ticketing | /repositories/base_repository.rb | UTF-8 | 1,244 | 3.4375 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'pry-byebug'
class BaseRepository
def initialize(file_path)
@file_path = file_path
@elements = []
@next_id = 1
load_csv if File.exists?(@file_path)
end
# create element and add into array
def create(element)
# binding.pry
element.id = @next_id
@next_id += 1
... | true |
e84546d6be23793de530bed3f92f8a124ad9215c | Ruby | kfukai23/CookListy | /db/fixtures/recipes.rb | UTF-8 | 360 | 2.609375 | 3 | [] | no_license | require 'csv'
csv = CSV.read('db/fixtures/recipe.csv')
csv.each_with_index do |rt, i|
next if i === 0
recipe_name = rt[0]
memo = rt[1]
user_id = rt[3]
administrator_id = rt[4]
Recipe.seed do |s|
s.id = i
s.recipe_name = recipe_name
s.memo = memo
s.user_id = user_id
s.admi... | true |
ab1a9bce53f6b8197d2629c7a6e39d2211c0b73d | Ruby | hallacy/projectEuler | /p097.rb | UTF-8 | 1,240 | 3.4375 | 3 | [] | no_license | powers2 = []
curNum = 2
resolution = 6
while !powers2.include? curNum
#puts powers2.size
powers2 << curNum
curNum *= 2
#truncate to last 10 digits
#puts "curnum: #{curNum}"
if curNum.to_s.chars.to_a.size < resolution
length = curNum.to_s.chars.to_a.size
curNum = curNum.to_s[-leng... | true |
4592b7ed5ca6ab80c46abd05bd35a46636376bb0 | Ruby | willcurry/Ruby-CoinChangerKata | /CoinChanger.rb | UTF-8 | 225 | 3.4375 | 3 | [] | no_license | class CoinChanger
COINS = [20, 10, 5, 2, 1]
def change_coin(money)
change = []
COINS.each do |coin|
while money >= coin do
change << coin
money -= coin
end
end
change
end
end
| true |
e18e8ddbcf016e6474ad3685e0cc9fed9f6779dd | Ruby | abates/datafile | /spec/datafile/columns_spec.rb | UTF-8 | 1,197 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
describe Datafile::Columns do
test_hash = {
"c1" => {
name:"c1",
type:"string",
},
"c2" => {
name:"c2",
type:"string",
}
}
test_json = '{"c1":{"name":"c1","type":"string"},"c2":{"name":"c2","type":"string"}}'
it 'ensures column name matches column... | true |
4bb52bf1fc957410fd7a2c13df35738ad3aa3c91 | Ruby | Jacobus-afk/ruby-chess | /spec/game_spec.rb | UTF-8 | 959 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require './lib/game'
describe Game do
subject(:game) { described_class.new }
context 'when instantiating class' do
it 'valid_move is false' do
expect(game.instance_variable_get(:@valid_move)).to be false
end
it 'adds a board class instance' do
expect(game.ins... | true |
d8d67ed52be9745d9e4f9863cba3253d778d7bd5 | Ruby | nishimat/Euler | /p061.rb | UTF-8 | 990 | 3.1875 | 3 | [] | no_license | #
# https://projecteuler.net/problem=61
#
def check_shift( oldset, blist, newset )
oldset.each{ |n|
blist.each{ |b|
if n[ -1 ] % 100 == b / 100
newset << [ n, b ].flatten
end
}
}
end
lists = Array.new( 6 ){ Array.new }
num = Array.new
n = 1
loop do
num[ 0 ] = n * ( n + 1 ) / 2
num[ 1 ] = n ** 2
n... | true |
675505766b3ffac5116863a190b0550eaff3a82a | Ruby | vishnucs666/exercises | /pan.rb | UTF-8 | 365 | 4 | 4 | [] | no_license | # program to find pangram
class Pan
def pa(kkk)
s = kkk.scan(/\w/)
h = {}
s.each do |x|
x = x.downcase if x == x.capitalize
h[x] = x
end
can(h)
end
private
def can(hhh)
s = hhh.length
if s == 26
puts 'its a pangram'
else
puts 'its not a pangram'
end
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.