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
6d19b0eadd900c95969be13073f7a47b50edae44
Ruby
JackMarx/jn_chicago_employees
/lib/jn_chicago_employees.rb
UTF-8
997
3.078125
3
[]
no_license
require "jn_chicago_employees/version" require 'unirest' module JnChicagoEmployees class Employee attr_reader :job_title, :department, :name, :salary def initialize(employee_api_info) @job_title = employee_api_info["job_titles"] @department = employee_api_info["department"] @name = employee...
true
357500961068268a763536a7a3dfb5cdc42c8408
Ruby
alakahakai/vector
/scripts/util/metadata/field.rb
UTF-8
7,033
2.703125
3
[ "Apache-2.0" ]
permissive
#encoding: utf-8 class Field # This classes was introduced to handle value grouping without breaking # the current Array API. # # We introduced "groups" for component options. For example, the # `influxdb_metrics` sink groups options by "v1" and "v2". This signals # which options are supported across each ...
true
321ba9c809d31468284a24869257d58be62461f9
Ruby
iamvery/advent-of-code-2019
/ruby/spec/space/simulation_spec.rb
UTF-8
2,715
3.109375
3
[]
no_license
require "point" require "space/simulation" RSpec.describe Space::Simulation do describe ".parse" do it "returns simulation created from data" do data = <<~DATA <x=-1, y=0, z=2> <x=2, y=-10, z=-7> <x=4, y=-8, z=8> <x=3, y=5, z=-1> DATA simulation = described_clas...
true
dc73ae41032fa6a6780c858baf564f7087d3addd
Ruby
medialy-dev/inin-document
/ruby/articles_array.rb
UTF-8
4,739
4.125
4
[]
no_license
############################################## # 配列の作り方 ############################################## # 空配列の作り方 hoge1 = [] p hoge1 # 初期値のある数値の配列の作り方 hoge2 = [1, 3, 5, 7] p hoge2 # 初期値のある文字列の配列の作り方 hoge3 = %w(a i u e o) p hoge3 # 初期値のあるシンボルの配列の作り方 hoge4 = %i(a i u e o) p hoge4 #################################...
true
a018e79cb56ab98d3fa08a0ec5f6be6470998cbe
Ruby
blambeau/icrb
/spec/full/test_integer.rb
UTF-8
872
2.53125
3
[ "MIT" ]
permissive
require 'spec_helper' module ICRb describe Integer do describe 'the literal IC' do it 'should not have accessors' do Integer.should_not respond_to(:literal) 1.should_not respond_to(:to_literal) end it 'should have the literal contract by default' do Integer.dress("12")...
true
8fdaeb3317f313bc4348a0078ca1b2743f1866d9
Ruby
hellozts4120/RubyOnRails-JHU
/1-Ruby summary/assignment-Calc-Max-Word-Freq/module2_assignment.rb
UTF-8
1,885
3.796875
4
[]
no_license
#Implement all parts of this assignment within (this) module2_assignment2.rb file #Implement a class called LineAnalyzer. class LineAnalyzer attr_reader :highest_wf_count, :highest_wf_words, :content, :line_number def initialize(content, line_number) @content = content @line_number = line_number ...
true
6a36eacd6108f5e7c333a57b4b86dafed5c52736
Ruby
Dpalazzari/codeChallenges
/Ruby/test/reverse_string_test.rb
UTF-8
932
3.1875
3
[]
no_license
require 'minitest/autorun' require 'minitest/emoji' require './lib/reverse_string' class ReverseStringTest < Minitest::Test def setup @reverse = ReverseString.new end def test_it_exists assert @reverse end def test_it_reverses_a_string_easy_method phrase = 'babooshka' result = @reverse.eas...
true
e798e786cae36d88c66a065cda70a97fcbce2530
Ruby
mujtaba-saboor/Ruby-calendar-event-scheduling
/event_details.rb
UTF-8
183
2.5625
3
[]
no_license
# event details class EventDetails attr_accessor :event_name, :date, :id def initialize(id, event_name, date) @id = id @event_name = event_name @date = date end end
true
7f04ba0c83f463ebdc33a1473dd3605d93d57b42
Ruby
alex-solo/ruby-problems
/chris-pine-book/13_cheat_method.rb
UTF-8
406
3.578125
4
[]
no_license
class Die def initialize @number_showing = 4 end def cheat puts "What side do you want?" input = gets.chomp.to_i if input > 6 puts "Error" else @number_showing = input end end def roll @number_showing = 1 + rand(6) end ...
true
b09c9f1689a29163e6f5e0c38dc8be0ab3475602
Ruby
ruby-concurrency/concurrent-ruby
/spec/concurrent/array_spec.rb
UTF-8
2,861
2.921875
3
[ "MIT", "Ruby" ]
permissive
require 'concurrent/array' module Concurrent RSpec.describe Array do let!(:ary) { described_class.new } describe '.[]' do describe 'when initializing with no arguments' do it do expect(described_class[]).to be_empty end end describe 'when initializing with argume...
true
398cf4eeec03304849aca5e6a998fb1eacc37d16
Ruby
CodingDojoDallas/ruby_dec_16
/Proctor_Brad/ruby_tdd/solar_system/solar_system_spec.rb
UTF-8
1,264
2.890625
3
[]
no_license
require_relative 'solar_system' RSpec.describe Planet do before do @planet = Planet.new end describe 'Planet Stuff' do it 'has method add_planet that sets new instance with a name, description, and population' do @planet.add_planet "Pluto", "round", 0 expe...
true
8379a871ec924752745a1cc0f6345739bda8f132
Ruby
yonnyquiceno/bowling_score_calculator
/spec/modules/checkable_spec.rb
UTF-8
3,322
2.578125
3
[]
no_license
# frozen_string_literal: true require 'spec_helper' describe Checkable do let(:dummy_class) do Class.new do extend Checkable end end describe '#strike?' do context 'when throwing is equal to 10' do it 'should return true' do expect(dummy_class.send(:strike?, 10)).to be true ...
true
496c0ce677bca68bdd94e81de38534dbea6f1e22
Ruby
testsvr01/first_rb_repro
/hw_seeds.rb
UTF-8
2,319
3.625
4
[]
no_license
selection = "" while selection != "0" puts "Welcome to my slug fest generator Enter a selection." puts "1. Enter your Fighters" puts "2. List Figthers" puts "3. List matchups" puts "0 exit" selection = gets.chomp if selection == "1" @team_array=[] puts "ent...
true
07e5970f0cfe69049a63419600b912ce6cdde1d5
Ruby
HortusHonu/oop
/Image.rb
UTF-8
278
3.171875
3
[]
no_license
class Image def initialize image = [] @image = image end def output_image image.each do |x| x.each do |cell| puts cell end end end end image = Image.new([ [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0] ]) image.output_image
true
63104929e77a6ecf7adca55c8d9a4815e72a30db
Ruby
EasyRPG/EV0001
/BotLog.rb
UTF-8
456
2.546875
3
[]
no_license
# EV0001 Bot - Copyright 2011 vgvgf class BotLog < Log def initialize super('') @file = 'botlog.txt' end def add_log(str, time = true) if time super(Time.new.strftime("[%Y-%m-%d %H:%M] ") + str) else super(str) end end def log_error(type, error) self.add_log("#{type} ERROR: #{error}") rescue n...
true
dca350722eb5a8f94b8a3a62563dc24c69caec10
Ruby
farisalasmary/kaldi-ruby-api
/speech_engine_wrapper_spec.rb
UTF-8
9,507
2.578125
3
[ "MIT" ]
permissive
require 'rspec' @root_folder = '/volume/rails' $LOAD_PATH << "#{@root_folder}/ruby_api" require 'engine_wrapper' #require 'engine_wrapper' RSpec.describe SpeechEngine do before do @root_folder = '/volume/rails' end describe 'wav_to_text' do it 'should return correct segmentations...
true
78237dc56a190d05e5d06ace75773ade0cf1987c
Ruby
NeuralNetworkingTechnologies/rann
/lib/rann/connection.rb
UTF-8
1,173
2.6875
3
[ "Apache-2.0" ]
permissive
require "securerandom" require "bigdecimal" require "bigdecimal/util" module RANN class Connection attr_accessor *%i( output_neuron input_neuron weight processed enabled id ) def initialize input_neuron, output_neuron, weight = nil @id = SecureRandom....
true
7f432f55620028d58bfc4d6df741fdfb1032d716
Ruby
dojorio/dojo-centro
/2009/20091021 - torre de hanoi - ruby/torre_de_hanoi.rb
UTF-8
278
2.859375
3
[]
no_license
def resolver(entradas) return "2 to c", "1 to c" if entradas == [1, 2, 0] return ["1 to b", "2 to c", "1 to c"] if entradas == [21, 0, 0] return [entradas[0].last " to c"] if entradas[0].to_s.length %2 ["1 to c"] end
true
c422922edf678a5a604f01c45111f9d801596f92
Ruby
cody-brock/ruby_course
/sandbox/ifelse-methods.rb
UTF-8
1,731
4.59375
5
[]
no_license
def multiply (first_num, second_num) first_num.to_f * second_num.to_f end def divide (first_num, second_num) first_num.to_f / second_num.to_f end def add (first_num, second_num) first_num.to_f + second_num.to_f end def subtract (first_num, second_num) first_num.to_f - second_num.to_f end def mod (first_num...
true
3148a73139390268f284b1c70ddd02bcdfc3ec6f
Ruby
ispmor/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
869
3.40625
3
[]
no_license
#write your code here def translate(text) words = text.split(" ") size = words.size count = 0 words.each do |i| if i[0] == 'a' || i[0] == 'e' || i[0] == 'i' || i[0] == 'o' || i[0] == 'u' i = i + "ay" elsif i[1] == 'a' || i[1] == 'e' || i[1] == 'i' || i[1] == 'o' || i[1] == 'u' ##wyjtek dla qu if i[...
true
1c417e7c58c09e0f1f693a65ed9483ff1974b00e
Ruby
hydroflux/programming-univbasics-nds-green-grocer-part-2-den01-seng-ft-120720
/lib/grocer_part_2.rb
UTF-8
2,517
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative './part_1_solution.rb' def apply_coupons(cart, coupons) # REMEMBER: This method **should** update cart cart.each do |cart_item| active_coupon = find_item_by_name_in_collection(cart_item[:item], coupons) if active_coupon != nil if cart_item[:count] >= active_coupon[:num] num_...
true
fddfcda447ad9a33d40d73d766ca90e29d650b54
Ruby
sourabh-ukkalgaonkar/ms_Word_pattren
/ms_word_pattern.rb
UTF-8
1,064
3.5
4
[]
no_license
# frozen_string_literal: true input = [ { id: 1, title: 'heading1', heading_level: 0 }, { id: 2, title: 'heading2', heading_level: 2 }, { id: 3, title: 'heading3', heading_level: 1 }, { id: 4, title: 'heading4', heading_level: 1 } ] class MsWordPattern def initialize(records) @records = records @mai...
true
81464de7fd9ce396af3271727397f13892401710
Ruby
TimPetricola/redactor
/spec/lib/redactor/rule_spec.rb
UTF-8
2,489
2.90625
3
[ "MIT" ]
permissive
require 'spec_helper' describe Redactor::Rule do it 'can be built with a regex' do rule = Redactor::Rule.new(:foo, /foo/) expect(rule.reason).to eq :foo expect(rule.regex).to eq(/foo/) end it 'can be built with a block' do rule = Redactor::Rule.new(:foo) { |input| input } expect(rule.reason)...
true
95f7d4d94047006daf340a9a060f44ff832c6d1e
Ruby
rezonant/crush
/lib/crush/functions.rb
UTF-8
3,646
2.640625
3
[ "MIT" ]
permissive
class Array def ls(*options) common_dir = true last_dir = nil self.entries.each do |x| unless x.kind_of? Crush::Entry common_dir = false break end if last_dir common_dir = (last_dir == x.parent.full_path) last_dir = x.parent.full_path else last_dir = x.parent.full_path end ...
true
64f97e9e7d9961fc8f668a127385f8831254614a
Ruby
riazmohamed/LaunchSchool_lesson4
/working_with_blocks/additional_exercises/ex6.rb
UTF-8
296
3.84375
4
[]
no_license
# ex6.rb flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) # my solution new_arr = flintstones.map do |name| name[0..2] # => Alternatively this name[0...3] could have worked too end p new_arr # given solution flintstones.map! do |name| name[0, 3] end p flintstones
true
983fffcf7cf30f3fa786a0214972f599fb72ae7f
Ruby
agent462/docface
/lib/docface/file_troll.rb
UTF-8
721
2.75
3
[ "Apache-2.0" ]
permissive
module DocFace class FileTroll def troll(dir) if File.directory?(dir) index = Array.new path = dir.gsub(/\\(?=\S)/, '/') Dir.glob(File.join(path, '**/*.{md,MD,markdown,mdown}')).each do |file| index << file end index else puts "The directory #...
true
c671d0028f394a16b2444d56734038b87ab8fa5a
Ruby
yoshida-eth0/async_enum
/test/async_enum_test/thread_pool_test.rb
UTF-8
510
2.671875
3
[]
no_license
require 'test_helper' class ThreadPoolTest < Test test 'pools can speed things up' do default_start = Time.now 500.times.async.each{ true } default_delta = Time.now - default_start rated_start = Time.now 500.times.async(10).each{ true } rated_delta = Time.now - rated_start as...
true
8d1091ff53a0b0a4ead1352b5b0e2dd7e734fb5b
Ruby
kkrmno/imgrb
/lib/imgrb/chunks/critical_chunks.rb
UTF-8
2,858
2.625
3
[ "MIT", "CC0-1.0" ]
permissive
module Imgrb module Chunks #Instances of this class represent IDAT chunks. This chunk contains #compressed image data. class ChunkIDAT include AbstractChunk, Critical, Public def self.type #:nodoc: "IDAT" end end #Instances of this class represent IHDR chunks. This chu...
true
ff1cb141977e33285b1c92462b08b7b543ee3f25
Ruby
nao58/ruby-tora-no-ana
/works/20140514/validator/method.rb
UTF-8
660
2.75
3
[]
no_license
# encoding: utf-8 class Validator::Method def self.custom setting, key_name, value setting.call key_name, value end def self.min_length setting, key_name, value "#{key_name}は#{setting}文字以上にしてください" unless setting <= value.size end def self.max_length setting, key_name, value end def self.regex...
true
1377f58b29a4b935284849595495a3fac8e24785
Ruby
DouglasAllen/Rails-projects
/using_script/Rit-master/config/initializers/monkeypatches.rb
UTF-8
174
2.5625
3
[ "MIT" ]
permissive
module QuantizeTime def quantized_to_hour self.change(:min => 0, :sec => 0) end end class Time include QuantizeTime end class DateTime include QuantizeTime end
true
d81770ea1653c0a4e4057ac71b639a69fe79608c
Ruby
richmit/ex-ruby
/hashOfArray.rb
UTF-8
2,516
4.03125
4
[]
no_license
#!/usr/local/bin/ruby ## # @file hashOfArray.rb # @author Mitch Richling <https://www.mitchr.me/> # @Copyright Copyright 2006 by Mitch Richling. All rights reserved. # @brief Building up a hash of arrays.@EOL # @Keywords ruby example hash array perl # @Std Ruby 1.8 # # A common Perl idio...
true
7a5c94ab6b6db5e91f93f87484c59fa06742504c
Ruby
colindeclue/adventofcode2019
/Day4/Day4.rb
UTF-8
1,186
3.28125
3
[]
no_license
def qualifiesPart2(toCheck) toCheck = toCheck.to_s decreasing = true hasDouble = false groupCount = 0 for i in 1..toCheck.length - 1 if toCheck[i] == toCheck[i-1] groupCount = groupCount + 1 else if groupCount == 1 hasDouble = true ...
true
c0a7798b55617834ae29318b8b4e48d9f8f3398c
Ruby
ThuyNT13/data_structures
/tests/spec/linked_list_spec.rb
UTF-8
3,282
3.4375
3
[ "MIT" ]
permissive
require_relative 'spec_helper' describe LinkedList do let(:my_list) { LinkedList.new } let(:empty_list) { LinkedList.new } before do my_list.add("thing_1") my_list.add("thing_2") my_list.add("thing_3") end describe '#add' do it 'adds an element to the end of the list' do my_list.add("...
true
6b6538cdf2478f3c49d2015fd8b3595c5ffaa6fa
Ruby
shoutout-team/shoutout-app-api
/app/services/app_logger.rb
UTF-8
756
2.609375
3
[ "MIT" ]
permissive
class AppLogger attr_accessor :logger def self.init(name = :app, custom_log_file_name = nil) new(name, custom_log_file_name).logger end def initialize(name, custom_log_file_name) @log_name = name.to_s @custom_log_file_name = custom_log_file_name create_log_file @logger = Logger.new(log_f...
true
ade3c984d4606a07c2d8b51c52e1ea2516c140ae
Ruby
santiagolv/rps_rcav
/app/controllers/game_controller.rb
UTF-8
2,155
2.640625
3
[]
no_license
class GameController < ApplicationController def user_plays_rock moves = ["Rock","Paper","Scissors"] @computer_move = moves.sample if @computer_move == "Rock" @img_url ="http://localhost:3000/assets/images/rock.png" elsif @computer_move =="Paper" @img_url="http://localhost:3000/assets/imag...
true
8de11b4898c094aed529884f14b48ffd9a105080
Ruby
1anchen/Code_Clan_Student
/specs/codeclan_student_spec.rb
UTF-8
916
2.984375
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require_relative("../codeclan_student") class TestCodeclanStudent < MiniTest::Test def setup @student = Student.new("David", 21) end def test_get_student__name new_student = @student assert_equal("David", new_student.get_student_name()) end def test_get...
true
ae290b05f5f5ca5ed335616497e1a9501fe3e424
Ruby
micahshute/rbtech
/spec/binary_tree_spec.rb
UTF-8
3,182
2.921875
3
[ "MIT" ]
permissive
RSpec.describe Rbtech::BinaryTree do let(:bt) do r = Random.new bta = Array.new(100) do r.rand(1000) end described_class.new(nodes: bta) end describe "#root" do it "returns the correct value" do expect(bt.root).to eq(bt.nodes.first) end end describe "#size" do i...
true
777a1bf16e482173b834079c1b46f6baf2428b3f
Ruby
webdevoir/eefio-api
/app/services/transaction_extractor_service.rb
UTF-8
4,479
2.75
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class TransactionExtractorService class << self def extract_transactions_from raw_block: puts "==> Extracting Transactions from RawBlock: #{raw_block.block_number}" # Work with just the RawBlock’s content JSON blob raw_block_content = JSON.parse(raw_block.content).with_indifferent_access ...
true
b0948ce88d5ebbc3c891442abf16dc56a8d2586c
Ruby
jasonleibowitz/coffeetalk_app
/spec/models/user_spec.rb
UTF-8
2,406
2.515625
3
[]
no_license
require_relative '../spec_helper.rb' describe User do before :each do @jason = User.new(first_name: "Jason", last_name: "Leibowitz", email: "leibo@gmail.com", dob: "1987-02-26", zipcode: "11201", admin: true, profile_pic: 'http://i.imgur.com/5z5NbX5.jpg', password: "hijesse", password_confirmation: "hijesse", ab...
true
4fc263549fa03bebab1a2588cadcff64bca65c38
Ruby
izumichika/practice
/practiceReviewApp.rb
UTF-8
1,545
3.671875
4
[]
no_license
def post_review(a_posts) post = {} puts "ジャンルを入力してください:" post[:genre] = gets.chomp puts "タイトルを入力してください:" post[:title] = gets.chomp puts "感想を入力してください:" post[:review] = gets.chomp line = "----------------------" puts "ジャンル : #{post[:genre]}\n#{line}" puts "タイトル : #{post[:title]}\n#{line}" puts "感想 ...
true
75b0874e1f0cb0f02b0cab6e176202feee6e6609
Ruby
h-z/positionable
/test/test_positionable.rb
UTF-8
4,475
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'active_record' #require "positionable" require 'helper' ActiveRecord::Migration.verbose = false ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") def setup_db ActiveRecord::Schema.define(:version => 1) do create_table :children do |t| t.column :po...
true
26448e779e997e4ea455c28aaba8516778634d00
Ruby
fcnaud/leetcode-train
/144_binary_tree_preorder_traversal.rb
UTF-8
240
3
3
[]
no_license
#!/usr/bin/ruby def travel(root, arr) if root arr.push(root.val) travel(root.left, arr) travel(root.right, arr) end end def preorder_traversal(root) ret = Array.new travel(root, ret) return ret
true
48dc24bc2f00db322610e38ad3f12a91ec4f4f21
Ruby
loganthomison/indivo_sample_surveys_app
/lib/basic_client/null_logger.rb
UTF-8
361
2.78125
3
[ "Apache-2.0" ]
permissive
class NullLogger # Class that implements the most popular parts of the Logger API, but just # throws away the messages. Allows us to log things without having to # check if @logger is set first. def initialize(*args) end def debug(msg) end def info(msg) end def warn(msg) end def error(msg) end def f...
true
eb87a78af28f864f3dae02dc11e69921385182d8
Ruby
mkneale/Oystercards1
/lib/oystercard.rb
UTF-8
598
3.390625
3
[]
no_license
class Oystercard MAXIMUM_BALANCE = 90 MINIMUM_FARE = 1 attr_accessor :balance, :journey def initialize @balance = 0 @journey = false end def top_up(amount) fail ("Maximum balance of 90 exceeded") if amount + balance > MAXIMUM_BALANCE @balance += amount end def deduct_money(fare) ...
true
a8dbd2805f8f2afc67506e70fea693f0206e1a80
Ruby
L-A-Davis/OO-mini-project-web-112017
/tools/console.rb
UTF-8
3,047
2.609375
3
[]
no_license
require_relative "../config/environment.rb" matt = User.new("matt") alison = User.new("alison") avi = User.new("avi") carrot_cake = Recipe.new("carrot_cake") pumpkin_pie = Recipe.new("pumpkin_pie") coffee = Recipe.new("coffee") ice_cream = Recipe.new("ice_cream") stir_fry = Recipe.new("stir_fry") carrot = Ingredien...
true
d90943e5ca0bb3a74947e7ba731339fe7ea9c34f
Ruby
roybapy/rails03
/script/sqlite/has_image.rb
UTF-8
690
2.609375
3
[]
no_license
#!/usr/bin/env ruby def has_img(c1, c2) puts c1 puts c2 begin db=SQLite3::Database.new("db/development.sqlite3") puts "database started" rs=db.execute("SELECT city FROM cityimg where city='#{c2}'") puts rs if rs[0] != nil rs0=db.execute("SELECT thumb FROM cityimg where city='#{c2}'") db.execute"update topdeals ...
true
ebfd74f3a1304da4fddfd3933dcd06a21adab1da
Ruby
TomasMacikas/RubyApp
/specOld/instance_checker_spec.rb
UTF-8
2,048
2.78125
3
[]
no_license
require 'spec_helper' describe InstanceChecker do context 'initial data ' do let(:number1) { described_class.new(10_000) } let(:number2) { described_class.new(100) } let(:float1) { described_class.new(1.3) } let(:nil1) { described_class.new(nil) } let(:string1) { described_class.new('string') } ...
true
d2f825618694103fe1c0757e7c0c1b49685ee74e
Ruby
steveoro/goggles_core
/app/models/edition_type.rb
UTF-8
1,320
2.5625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'drop_down_listable' require 'localizable' class EditionType < ApplicationRecord include DropDownListable include Localizable validates :code, presence: { length: { maximum: 1 }, allow_nil: false } validates :code, uniqueness: { message: :already_exists } # ----------...
true
f3603e97e9abd54dd693ffd4f73ab0fce123a6db
Ruby
gogolqx/nand2tetris-4
/jf647/10/jack_lexer.rb
UTF-8
2,761
2.796875
3
[]
no_license
require 'rltk' module Jack class Lexer < RLTK::Lexer # ignore whitespace rule(/\s/) # line comments rule(/\/\/.*/) { push_state(:linecomment) } rule(/./, :linecomment) rule(/\n/, :linecomment) { pop_state } # block comments rule(/\...
true
e80edae79a241444d058b0fae9c9aab04993c5f9
Ruby
basu0001/first-pr-Hacktoberfest--2019
/codes/algorithms/merge_sort/ruby/merge_sort.rb
UTF-8
629
4.0625
4
[ "MIT" ]
permissive
def sort(numbers) return numbers if numbers.size <= 1 arr_len = numbers.size half_size = (arr_len / 2).round left_array = numbers.take(half_size) right_array = numbers.drop(half_size) sorted_left = sort(left_array) sorted_right = sort(right_array) merge(sorted_left, sorted_right) end def merge(lef...
true
38bc57e897fb5231bbc05b48939008aba110d64e
Ruby
RabbitLee/IntSig_activity_2
/code/Index.rb
UTF-8
1,211
2.671875
3
[ "MIT" ]
permissive
module Index def Index.getNameFromUrl(argvString) if pattern=/\(name=(.*?)\)/.match(argvString) return pattern[1] else return 'nil' end end def Index.getPhoneFromUrl(argvString) if pattern=/\(phone=(.*?)\)/.match(argvString) return pattern[1] else return 'nil' end end def Index.getEma...
true
e742ef836aabc9dd3ed7f32e0e256cc660a7bc61
Ruby
streeter/dash-snippets
/Rakefile
UTF-8
4,921
2.6875
3
[ "MIT" ]
permissive
require 'sqlite3' require 'toml-rb' require 'dotenv' require 'logger' require 'fileutils' Dotenv.load ENV['LOG_LEVEL'] ||= 'INFO' raise ArgumentError, 'ENV["DASH_SNIPPET_PATH"] is required' unless ENV['DASH_SNIPPET_PATH'] namespace :dash do TOML_PATH = './snippets' DUMP_PATH = './snippets' SNIPPET = 'snippet' ...
true
ded1af5f6e89fef48cd574bed16377cf3eb39f39
Ruby
LeipeLeon/optocht_kop
/app/helpers/application_helper.rb
UTF-8
2,081
2.78125
3
[]
no_license
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def distance_of_time_in_dutch(from_time, to_time = Time.now, include_seconds = false) from_time = Time.now if from_time.blank? from_time = from_time.to_time if from_time.respond_to?(:to_time) to...
true
619360c540f7826aff1ea58ad7a19efc5e692bf5
Ruby
zacharytwhite/project-euler-solutions
/project_euler_rb/problem_052.rb
UTF-8
656
3.515625
4
[]
no_license
# It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. # Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. i = 1 ans = [] loop do pan = (2*i).to_s.split('') multis = [] if pan.uniq.lengt...
true
be313df83e14511b25dd8cc962625a1a66c7f572
Ruby
learn-co-students/nyc-clarke-web-100719
/18-sessions-cookies/app/controllers/trivia_controller.rb
UTF-8
747
2.703125
3
[]
no_license
class TriviaController < ApplicationController def random trivia_api = TriviaApi.new @trivia_question = trivia_api.get_random_question @choices = @trivia_question["incorrect_answers"] @choices.push(@trivia_question["correct_answer"]) session[:correct_answer] = @trivia_question["correct_answer"] ...
true
44f8f8852abd54bc8a3a1de6287b215aaa4c2a95
Ruby
marco-beduschi/tic-tac-toe
/player.rb
UTF-8
245
2.59375
3
[]
no_license
# frozen_string_literal: true require './base_character.rb' class Player < BaseCharacter def initialize(game, marker) @view = game.view super end private def choose_square @board.get_square(@view.get_input - 1) end end
true
478e977500b6dd5147995957dc8613331c68173d
Ruby
dallinder/ls_small_pbs_round2
/adv/2.rb
UTF-8
862
3.421875
3
[]
no_license
def star(num) stars = '*' spaces = ' ' tracker = ((num - 1) / 2 ) - 1 tracker.downto(0) do |countd| puts "#{stars}#{spaces * countd}#{stars}#{spaces * countd}#{stars}".center(num) end # puts "#{stars}#{spaces * 2}#{stars}#{spaces * 2}#{stars}".center(num) # puts "#{stars}#{space...
true
9fb79ca88817b6d52dbc07dc7b9c9d4c67be4004
Ruby
horiaradu/dense-ranges-merger
/lib/ranges/node.rb
UTF-8
343
3.046875
3
[ "MIT" ]
permissive
class Ranges::Node attr_accessor :start, :finish def initialize(start:, finish:) raise ArgumentError if finish < start @start = start @finish = finish end def ==(other) other.is_a?(Ranges::Node) && start == other.start && finish == other.finish end def <=>(other) start <=>...
true
beea3dfff3e77abd8bfe5eb70d76a841bf95006f
Ruby
marksweston/acts_as_raytracer
/lib/acts_as_raytracer/transform.rb
UTF-8
1,005
3.015625
3
[]
no_license
class Transform attr_accessor :transform_matrix def initialize_from_matrix(matrix) @transform_matrix = matrix end def *(multiplicand) case multiplicand when Point, Vector return transform_point_or_vector(multiplicand) when Transform return self.class.new_from_matrix(self.transform_...
true
71e9e545332da87fde6ae9415f0e038219c2d133
Ruby
vishallama/assignment_recursion_sprint
/palindrome/# palindrome_i.rb
UTF-8
130
3.546875
4
[]
no_license
# palindrome_i.rb def palindrome_i(str) holder = "" str.chars.reverse_each { |char| holder << char } str == holder end
true
7e744c0d0c981924444e2bd7c9c23bbc8d11e3ca
Ruby
alinan-vn/ruby-oo-self-cash-register-lab-chicago-web-111819
/ignore_this_turbo.rb
UTF-8
384
3.96875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Snail attr_accessor :name, :speed def initialize(name, speed) @name = name @speed = speed end def speed_up(boost) @speed += boost end end binding.pry turbo = Snail.new("Turbo", 200) puts turbo.name # should print "Turbo" puts turbo.speed # should ...
true
134f369bdfc7be1b587ede6511e14b94b8a60d27
Ruby
ivanadokic/programming-univbasics-4-array-concept-review-lab-dumbo-web-091619
/lib/array_methods.rb
UTF-8
179
3
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def find_element_index(array, value_to_find) array.index puts array end def find_max_value(array) array.find_max_value end def find_min_value(array) array.find_min_value end
true
b4be0024ffa72c459f775fcc653303301524387f
Ruby
jeremyevans/sequel
/lib/sequel/extensions/pg_multirange.rb
UTF-8
13,729
2.609375
3
[ "MIT" ]
permissive
# frozen-string-literal: true # # The pg_multirange extension adds support for the PostgreSQL 14+ multirange # types to Sequel. PostgreSQL multirange types are similar to an array of # ranges, where a match against the multirange is a match against any of the # ranges in the multirange. # # When PostgreSQL multirange ...
true
99b3c876e29225648429ec324fe71b41cda7648b
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/word-count/9513fb3818324c0a9d4be5b38b49baf9.rb
UTF-8
433
3.359375
3
[]
no_license
class Phrase def initialize(phrase) @phrase = phrase end def word_count WordCounter.new(words).count end private def words @phrase.split(/\W+/) end end class WordCounter def initialize(words) @words = words end def count @words.each_with_object(Hash.new(0)) do |word, counts...
true
e4fe3c5f62f7e703ffc3557878a3a3d2b5be10d7
Ruby
blm768/bookie
/bookie/lib/bookie/database/job.rb
UTF-8
6,266
2.875
3
[ "MIT" ]
permissive
require 'active_record' require 'bookie/database/lock.rb' require 'bookie/database/user.rb' require 'bookie/database/system.rb' module Bookie module Database ## #A reported job # #The various filter methods can be chained to produce more complex queries. # #===Examples # Bookie::Databas...
true
5569beb70fda4b7665a054b738b12e6ef19b906c
Ruby
devkmsg/daemon_runner
/lib/daemon_runner/session.rb
UTF-8
3,936
3
3
[ "MIT" ]
permissive
require 'diplomat' module DaemonRunner # # Manage distributed locks with Consul # class Session class SessionError < RuntimeError; end class CreateSessionError < SessionError; end include Logger class << self attr_reader :session def start(name, **options) @session = Sess...
true
f07100249b42e83b72bbd8b5d5d94d693ab8de04
Ruby
akhilkrishna57/misc
/ruby/heap_sort.rb
UTF-8
950
3.625
4
[]
no_license
def swap(a, i, j) a[i], a[j] = a[j], a[i] end def left_child(i) i * 2 + 1 end def right_child(i) i * 2 + 2 end def max_heapify(a, n, i) left = left_child(i) right = right_child(i) if left < n and a[left] > a[i] largest = left else largest = i end if right < n and a[right] > a[largest] ...
true
079c953271b01e2cff0445d618f5e8e624ecd2cd
Ruby
SettRaziel/wrf_forecast
/spec/forecast/measurand_text_spec.rb
UTF-8
554
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require "spec_helper" require "ruby_utils/statistic" require "wrf_forecast/threshold" require "wrf_forecast/text" describe WrfForecast::Text::MeasurandText do describe ".new" do context "given an array of data and some extreme values" do it "tries to initialize the abstract class but fails in the abstrac...
true
349e3571be74a7df987acd39d6a395fd9a4dca24
Ruby
restc/mypage_tools
/lib/mypage_tools/schedule_page.rb
UTF-8
2,213
3.140625
3
[ "MIT" ]
permissive
module MypageTools class SchedulePage # Expects the myPage schedule page as a Nokogiri HTML object def initialize page @page = page end # Return string containing the date the week begins, i.e. "Sep 14, 2013" # Matches from the raw_schedule_text using a regex # http://rubular.com/r/OjRZ0q6cko def wee...
true
dd27b43b4cede563207f449cf5459b1ab2a0e20c
Ruby
although2013/network
/elevator.rb
UTF-8
2,849
3.40625
3
[]
no_license
require 'set' class PeoplePool attr_accessor :mutex def initialize @pool = { f1: { up: [5,5,6,7,8,9,10,11,15,15,11,8,17], }, f4: { up: [12, 12], down: nil, }, f11: { up: [17], down: [1, 2], } } @mutex = Mutex.new end def ...
true
e44eeca41f281db57154786b51c5a73b1b8d6736
Ruby
robinwu9000/App-Academy-Work
/w3d2/items.rb
UTF-8
794
2.96875
3
[]
no_license
require_relative 'questions_db' class Item def self.db QuestionsDatabase::instance end def db self.class.db end def self.tbl_name raise NotImplementedError end def self.find_by_id(id) data = db.execute(<<-SQL, id) SELECT * FROM #{self.tbl_name} WHERE id = ? SQL ...
true
625d8a4feee25ffb753bfc7964efb5f875995bfc
Ruby
chemunoz/Ironhack
/Day Exercises/WEEK4/DAY2/shortener/app/models/link.rb
UTF-8
183
2.609375
3
[]
no_license
class Link < ActiveRecord::Base def self.short(chars) #result=(0..2).map { (97 + rand(26)).chr }.join Array.new(chars.to_i){[ *'a'..'z', *'A'..'Z'].sample}.join end end
true
930aa479cb531a8807c0787b76990938f8d4ec27
Ruby
SarahDrake01/ruby-class-variables-and-class-methods-lab-london-web-082619
/lib/song.rb
UTF-8
1,660
4.15625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song #Define your `Song` class such that an individual song is initialized with a name, artist and genre. #There should be an `attr_accessor` for those three attributes. attr_accessor :name, :artist, :genre @@count = 0 @@artists = [] @@genres = [] #Create a classe variable @@count. #I use...
true
03f6870368348529a7872846f78b0e44f7e075cd
Ruby
tulios/pong
/lib/pong/elements/ball.rb
UTF-8
2,555
2.703125
3
[]
no_license
# encoding: utf-8 module Pong class Ball < Chingu::GameObject include Gosu include Chingu trait :bounding_box, :debug => false traits :velocity, :collision_detection DEFAULT_MOVIMENT_UNIT = 4 attr_accessor :moviment_unit, :bar def initialize options = {} @bar = options.delete :b...
true
1ceaeaa0b71fb400043fa6e09b02eb4e52167173
Ruby
NightFeather/pixiv
/lib/pixiv/illust/manga.rb
UTF-8
758
2.59375
3
[]
no_license
require 'pixiv/downloader/task' require 'pixiv/string_template' module Pixiv module Illust class Manga < Base attr_reader :page_count, :images def download_meta template = '?user? - ?title?/?idx?' ctr = Pixiv::Downloader::Task.new [] @images.each_pair do |idx, image| filena...
true
9d33fb561c5d612acb622cd88d2e8fb03ffcfbc6
Ruby
abigoroth/kira-telegram-bot
/kira.rb
UTF-8
4,042
2.828125
3
[]
no_license
require 'telegram/bot' require "active_record" require 'date' require 'caxlsx' db_config_admin = { 'database' => 'kira', 'schema_search_path' => 'public', 'adapter' => 'postgresql', 'encoding' => 'utf-8', 'pool' => 5 } ActiveRecord::Base.establish_connection(db_config_admin) token = <token> class Expense...
true
524f35c2a024140303c866896aa537f4ef70c90e
Ruby
presto53/rfusefs
/spec/pathmapper_spec.rb
UTF-8
6,445
2.75
3
[ "MIT" ]
permissive
#Pathmapper is hard to test because it is difficult to mock Dir/Pathname/File etc... require "spec_helper" require "fusefs/pathmapper" require 'tmpdir' require 'pathname' class PMFixture attr_reader :tmpdir def initialize() @tmpdir = Pathname.new(Dir.mktmpdir("rfusefs_pathmapper")) pathmap(@tm...
true
36b4cfa7a1498a0db21f49880ea9e753df7a803b
Ruby
kbanana/ada
/student_acct_gen.rb
UTF-8
913
3.625
4
[]
no_license
#starting variables student_names = [] student_ids = [] student_emails = [] num_students = 5 # gets student names from the user and puts them in an array num_students.times do puts "Please enter a student name (FIRST LAST) >" student_names << gets.chomp.upcase end # generates random student ID numbers and puts th...
true
61a2a92d61d99f1130cbca78dca75ccab3ad2a25
Ruby
18F/identity-idp
/app/services/profanity_detector.rb
UTF-8
1,715
3.328125
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
# Detects profanity in a string, the list of profane words # comes from the profanity_filter gem for now module ProfanityDetector module_function # Calls a block until the result does not contain profanity # @yield block that generates a random value # @yieldreturn [String] string to check for profanity def ...
true
cdd3c59a305a386294b5bb51caebead0ff24ac02
Ruby
palhamel/Ruby_exercises
/interpolation.rb
UTF-8
219
3.625
4
[]
no_license
# Using String Interpolation # https://www.digitalocean.com/community/tutorials/how-to-work-with-strings-in-ruby my_name = "Arnie the Globetrotter" my_age = 78 output = "My name is #{my_name} and my age is #{my_age}." puts output
true
08667c55923f50242420789152f8e2b218e4f727
Ruby
lungla-gael/Binary-Search-Trees
/Tree.rb
UTF-8
835
3.453125
3
[]
no_license
require './Node.rb' class Tree attr_accessor :root def initialize(array) @root = build_tree(array.uniq) end def build_tree(array) res = {} array.each do |num| difference = (array.filter{|a| a < num}.count - array.filter{|a| a > num}.count).abs res[num] =...
true
d8329bb0434485ce7901e603d09457238c30abbf
Ruby
ogeidix/collaborative_editing
/app/insertion.rb
UTF-8
1,910
2.671875
3
[]
no_license
############################################################################### ## Insertion ############################################################################### ## represents the Insertion change and inherits the behaviour from the Change class ## See change.rb for help ## require_relative 'change' module...
true
ac705275cb89c67a9d7c2b8142c4564f49033546
Ruby
ppietrasik/weblog_parser
/lib/weblog_parser/unique_views_count.rb
UTF-8
730
2.671875
3
[]
no_license
# frozen_string_literal: true module WeblogParser class UniqueViewsCount def self.from_log_entries(log_entries) log_entries .group_by(&:webpage) .transform_values(&by_uniq_ip) .transform_values(&:count) .map { |webpage, unique_views| new(webpage, unique_views) } end ...
true
7f5e721800ae0d020cab84c4d042c3d4f75db8d1
Ruby
square-circle-triangle/her
/lib/her/model/orm.rb
UTF-8
5,563
2.796875
3
[ "MIT" ]
permissive
module Her module Model # This module adds ORM-like capabilities to the model module ORM # Initialize a new object with data received from an HTTP request # @private def initialize(single_data={}) # {{{ @data = {} cleaned_data = single_data.inject({}) do |memo, item| ...
true
df8a3eedebd481f47e1cf59fb359ac1b726bba62
Ruby
NaisHRT/Ruby-Exercices
/exo_08.rb
UTF-8
250
3.828125
4
[]
no_license
puts "Give me a number : " print "> " number = gets.chomp.to_i i = 0 while i < number number = number - 1 puts number end #demande un nombre à l'utilisateur, puis qui affiche un compte à rebours à partir de ce nombre, jusqu'à 0.
true
a1e28ad2cac7a5694fd99ca755d27230527f72e4
Ruby
itggot-elias-stenhede/standard-biblioteket
/dev/factorial.rb
UTF-8
122
3.015625
3
[]
no_license
def factorial(max) sum = 1 i = 1 while i < max i += 1 sum = sum * i end return sum end
true
6c9cb9fe1bfb8104540f6b4bf38f682044c6a93c
Ruby
DanL12186/ttt-3-display_board-example-bootcamp-prep-000
/lib/display_board.rb
UTF-8
261
2.640625
3
[]
no_license
# Define a method display_board that prints a 3x3 Tic Tac Toe Board def display_board spacer = " | | " lines = "-----------" puts spacer puts lines puts spacer puts lines puts spacer end #[[["|","|","|"], ["|","|","|"], ["|","|","|"]]]
true
86e9384c6f74f237b180ab2562b70d708e0fa0a3
Ruby
yuheik/leetcode
/21_merge_two_sorted_lists.rb
UTF-8
1,282
3.625
4
[]
no_license
#! /usr/bin/ruby # Definition for singly-linked list. class ListNode attr_accessor :val, :next def initialize(val) @val = val @next = nil end end def main(l1, l2) p l1 p l2 head = ListNode.new(-1) first = head while (l1 && l2) if (l1.val < l2.val) tmp = l1.next first.next = l...
true
81a6c5c9986996c3f2c50bc885a1a1003b68570a
Ruby
Icehawk78/payments_exercise
/app/models/loan.rb
UTF-8
393
2.5625
3
[]
no_license
class Loan < ActiveRecord::Base has_many :payments # Current Balance = Funded Amount - SUM(Payments) def balance self.payments.map(&:amount).reduce(self.funded_amount, :-) end def as_json(options={}) # Uncomment if you want to expose payments on the index/show endpoints for loans # super(include...
true
62a4a86ab8ff416057a810662e046900ea2b6ee5
Ruby
regru/reg_api2-ruby
/spec/lib/reg_api2/sym_hash_spec.rb
UTF-8
2,108
3
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- describe RegApi2::SymHash do let!(:hash) { RegApi2::SymHash.new } describe :new do it "should be kind of Hash" do expect(hash).to be_kind_of(Hash) end end describe :method_missing do it "should assign key" do hash.unique_key = "unique" expect(hash["un...
true
e649b39e4f0aa74ae16c540deab33eee404242bf
Ruby
murtala/RubyTraining
/If_Else.rb
UTF-8
197
3.234375
3
[]
no_license
x=1 if x>2 puts "x >2" elseif x ==1 #else if not else-if like in java puts "x =1" else puts "x<2" end # if can be used to check if something is true $debug=0 print "debug\n" if $debug
true
4d2851c67f651cf7c99f2de2fe9002099bf63e5a
Ruby
KarenSJW/ruby-automail
/mail_example.rb
UTF-8
663
2.5625
3
[]
no_license
#!/usr/local/bin/ruby require 'csv' require 'net/smtp' # 讀取csv _receiver = "" CSV.foreach("mail_headphone.csv") do |row| _mail = <<MESSAGE_CONTENT From: kevenkmupsy@gmail.com To: #{row[2]} Subject: headphone問卷發信測試 #{row[1]}你好 這是致伸科技的使用者經驗部門 請至以下連結填寫問卷:http://tinyurl.com/khdrgs9 在問卷開頭填入你專屬的代號#{row[0]}即可 最後別忘了在問卷最...
true
f372aedbd4e8c4547bdcffd64f3e2c31733fb96a
Ruby
eyelean7/primes
/spec/prime_spec.rb
UTF-8
271
2.859375
3
[]
no_license
require ("rspec") require ("prime") require ("pry") describe('Fixnum#prime') do it('returns primes up to a given number') do expect(5.prime()).to(eq('2 3 5')) end it('returns primes up to a given number') do expect(10.prime()).to(eq('2 3 5 7')) end end
true
45e590b10184e4c298924443f596b46c0afecf90
Ruby
conciergelive/is_taggable_rails3
/test/tag_test.rb
UTF-8
1,415
2.546875
3
[ "MIT" ]
permissive
require 'test_helper' class TagTest < Minitest::Test def teardown Tag.destroy_all end def test_association t = Tag.new if t.respond_to?(:association) assert_equal Tagging, t.association(:taggings).reflection.klass else assert_equal Tagging, t.taggings.proxy_reflection.klass end ...
true
5951518637818fa23411f331d8a1fee51cba6d98
Ruby
aldelcy/IronHack-Class
/Week 2/Day 1/Sinatra/lib/todolist.rb
UTF-8
479
3.46875
3
[]
no_license
class TodoList attr_reader :tasks def initialize @tasks = [] end def add_task(task) @tasks << task @tasks end def delete_task(task_id) @task_id = task_id @tasks.delete_if{ |item| item.id == @task_id} end def find_task_by_id(task_id) @task_id = task_id task_index = @tasks.find...
true
61c49f91b9c465bf5f7d9255150e9498f1d2eaf2
Ruby
hendricius/deliveries
/app/models/services/timetable.rb
UTF-8
4,283
3
3
[]
no_license
class Timetable # FIXME - Mit einbeziehen von TW durch zwei Zahlen in jedem Feld der Matrix. # Neue Bedingung Auftragszeit <= TW && kleinste tTT # FIXME - neue Methode für ein Fahrzeug - zwei Ordern betrachten, die beiden kürzesten und deren Einfluss auf die nächst schnellste attr_accessor :driver_order_times, :o...
true
ba6ef9500d65af1b801f15a3ba9b92ade17d221e
Ruby
swathinimmala/dijkstra
/spec/dijkstra_spec.rb
UTF-8
1,513
3.25
3
[]
no_license
require "spec_helper" require_relative '../dijkstra' describe "Dijkstra" do before(:all) do @matrix = [ [0, 7, 9, 0, 0, 14], [7, 0, 10, 15, 0, 0], [9, 10, 0, 11, 0, 2], [0, 15, 11, 0, 6, 0], [0, 0, 0, 6, 0, 9], [14, 0, 2, 0, 9, 0] ] end context "acce...
true
8a1a7aa791019abc8906bcdaa6a72edbb88c5ae7
Ruby
hn4ever/AloeBae
/app/models/product.rb
UTF-8
768
2.65625
3
[]
no_license
class Product < ApplicationRecord belongs_to :merchant has_and_belongs_to_many :categories has_many :reviews validates :name, presence: true, uniqueness: {case_sensitive: false} validates :price, presence: true, numericality: {greater_than: 0} validates :merchant, presence: true scope :available, -> {...
true
ab0fe00ab7f5bcad9398b035d41fccbc236e0a68
Ruby
testertina/Euler-3
/euler3.rb
UTF-8
951
4.0625
4
[]
no_license
require 'prime' class Euler3 def multiple_of(multiple, number) number / multiple end def highest_prime(number) all_primes = number.prime_division last_prime = all_primes.last # This will give us [6857, 1] # We only want the first one puts last_prime[0] # or last_prime.first end # def multiples_of(nu...
true
7f392b288ca45855a71e249a5ddc9e8efac161db
Ruby
fbado66/key-for-min-value-nyc04-seng-ft-071220
/key_for_min.rb
UTF-8
347
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# prereqs: iterators, hashes, conditional logic # Given a hash with numeric values, return the key for the smallest value def key_for_min_value(name_hash) smallest_value = 10000 name_hash.each do |key, value| if value < smallest_value smallest_value = value end end smallest_value name_hash.ke...
true