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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8985a206172c94d9ed96ae208f1b398a803a621d | Ruby | jes708/app-academy-jump-start | /12_rpn_calculator/rpn_calculator.rb | UTF-8 | 894 | 3.75 | 4 | [] | no_license | class RPNCalculator
def initialize
@stack = []
end
def push(num)
@stack.push(num)
end
def plus
error
@stack.push(@stack.pop + @stack.pop)
end
def minus
error
@stack.push(-(@stack.pop - @stack.pop))
end
def times
error
@stack.push(@stack.pop * @stack.pop)
... | true |
18a4e5a0d19bd3a3cedcaba66b3680838193e8c1 | Ruby | fme2525/kata | /TDD_Book/prime_factor_test.rb | UTF-8 | 1,151 | 3.671875 | 4 | [] | no_license | require 'minitest/autorun'
require 'prime'
require_relative 'eratosthenes_test'
class PrimeFactor
def initialize(number)
@number = number
end
def calculate
result = []
current_prime = 2
until Prime.prime?(@number)
if @number % current_prime == 0
result << current_prime
@num... | true |
e056c1f3a0969da95dda5e9c2d242023edf6f7fb | Ruby | arusso/snippets | /get_kernels.rb | UTF-8 | 922 | 3 | 3 | [] | no_license | # This code will take a list of hosts, as returned by a puppet api query
# and gather the kernel version it is running, placing the output in 2 files:
#
# host-kernels.csv : lists each host adjacent to the kernel version
# kernel-counts.csv : lists each kernel version adjacent to the number of times
# ... | true |
1b3dac25db362ebe2677fb852812190b9cd9e1c3 | Ruby | dalehamel/linecook | /lib/linecook-gem/util/downloader.rb | UTF-8 | 2,042 | 2.578125 | 3 | [] | no_license | require 'open-uri'
require 'fileutils'
require 'securerandom'
require 'zip'
require 'ruby-progressbar'
require 'linecook-gem/image/crypt'
module Linecook
module Downloader
LOCK_WAIT_TIMEOUT = 180
def self.download(url, path, encrypted: false)
acquire_lock(path)
FileUtils.mkdir_p(File.dirname(p... | true |
2f21aa5612aeb085257c3b8fcd9836f91817e7d5 | Ruby | jessewoo/TestingFramework | /rcsb_testing_recipe/features/step_definitions/check_steps.rb | UTF-8 | 5,509 | 2.609375 | 3 | [] | no_license | And (/^check element by "([^"]*)" "([^"]*)", value "([^"]*)" "([^"]*)"$/) do |selector_type, selector_name, num_operator, num_value|
if "#{selector_type}" == "href"
@element_value = @browser.link(:href => "#{selector_name}").text.gsub(/\D/, '')
else
@element_value = @browser.element(:"#{selector_type}" => ... | true |
b7498058cc2a427f1cb6ac52a4baf0ab003778e2 | Ruby | jpkim921/app-academy-coding-test-2 | /06_word_unscrambler.rb | UTF-8 | 215 | 3.234375 | 3 | [] | no_license | def word_unscrambler(str, words)
annagrams = Array.new
words.each do |word|
if str.split("").sort == word.split("").sort
annagrams.push(word)
end
end
return annagrams
end
| true |
abaae72feeba7e42acba405240e6baa0f9127777 | Ruby | jamesprogers/phase-0-tracks | /ruby/vampires.rb | UTF-8 | 1,496 | 3.875 | 4 | [] | no_license | puts "How many employees will be processed?"
employees=gets.chomp.to_i
index = 0
until index == employees
puts "What is your name?"
name=gets.chomp
puts "How old are you?"
age=gets.chomp.to_i
puts "What year were you born?"
year=gets.chomp.to_i
puts "Our company cafeteria serves garlic bread. Should ... | true |
9193808aaf24a6023ca319fa88da04dfcb90d44a | Ruby | kaytabro/furima-35915 | /app/models/buy_add.rb | UTF-8 | 1,023 | 2.515625 | 3 | [] | no_license | class BuyAdd
include ActiveModel::Model
attr_accessor :post_number, :prefecture_id, :municipalities, :address, :building, :phone_number, :item_id, :user_id, :token, :price
with_options presence: true do
validates :post_number, format: {with: /\A[0-9]{3}-[0-9]{4}\z/, message: "is invalid. Include hyphen(-)"}... | true |
47082c79f7efd8573d911bf90084228d4a945edc | Ruby | sgrant0225/oo-barking-dog-onl01-seng-pt-021020 | /lib/dog.rb | UTF-8 | 184 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
def name= (dogs_name)
@this_dogs_name = dogs_name
end
def name
@this_dogs_name
end
end
fido = Dog.new
fido.name = "Fido"
class Dog
def bark
puts "woof!"
end
end | true |
ddab4e48aef15e0d6407e26af3d938d93ec0616b | Ruby | oduolaakeem/codility | /spec/codility/stacks_and_queues/fish_spec.rb | UTF-8 | 702 | 2.953125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "codility/stacks_and_queues/fish"
module Codility
module StacksAndQueues
RSpec.describe Fish do
it "returns the number of fish that stays alive" do
a = [4, 3, 2, 1, 5]
b = [0, 1, 0, 0, 0]
expect(Fish.solution(a, b)).to eql(2)
end
context "f... | true |
89bc73c4b71c32b59f42b9ddef9d67cb8be6304e | Ruby | my-study-area/weekcodepoliticos2 | /app/helpers/ranking_helper.rb | UTF-8 | 215 | 2.546875 | 3 | [
"MIT"
] | permissive | module RankingHelper
def get_ordinal_rating(page, index)
return get_order(page, index) - 25 unless page < 2
get_order(page, index)
end
def get_order(page, index)
(page * 25) + 1 + index
end
end
| true |
dd163bc1786df59afb9ec6e5552a81b809cf4c06 | Ruby | Epictetus/heroku-backup-orchestrator | /test/pages_array_test.rb | UTF-8 | 1,374 | 2.765625 | 3 | [
"MIT"
] | permissive | class PaginatableArrayTest < Test::Unit::TestCase
include HerokuBackupOrchestrator
def test_should_have_default_pages_size_of_10
pages = PaginateableArray.new
assert_equal(10, pages.page_size)
end
def test_should_return_number_of_pages
pages = PaginateableArray.new
assert_equal(0, pages.nr... | true |
3e8131d239a7c0b736dd40e3d38ef7a7400c5281 | Ruby | Wiggerand/BognerEuP | /ruby/Aufgaben/06_uebung_bank.rb | UTF-8 | 1,844 | 4.125 | 4 | [] | no_license | #Einrichten einer Kundenklasse.
#Eine Klasse customer soll eingerichtet werden.
#Beim Anlegen eines Customer-Objektes muss als notwendiger Parameter eine Kontonummer (Instanzvariable bank_account) eingegeben werden.
#Optional kann auch der Nachname des Kunden (lastname) eingegeben werden.
#Erstellen Sie SET und GET -... | true |
fa3cf84c1ec66267b325e5f95681386344ea861e | Ruby | kijimaD/well-grounded-rubyist | /CH7/3plus.rb | UTF-8 | 131 | 3.484375 | 3 | [] | no_license | obj = Object.new
def obj.+(other_obj)
"Try to add something to me, eh?"
end
puts obj + 100
# integer 100 as the single argument.
| true |
269560e7849fad452547106baf210dec861cd043 | Ruby | general-CbIC/ruby-heap | /lib/Heap/heap_template.rb | UTF-8 | 915 | 3.359375 | 3 | [
"MIT"
] | permissive | module Heap
# Heap Template
class HeapTemplate
attr_reader :elements
def add(element)
if element.is_a? Array
element.each do |el|
@elements.push el
swim_up(count)
end
elsif defined? element.elements
add element.elements
else
@elements.pu... | true |
60e4d28c098113d10653c31d85e06e59df967209 | Ruby | tbpgr/codeiq_answers | /q1263/fizzbuzz_matthew.rb | UTF-8 | 805 | 3.234375 | 3 | [] | no_license | # マシュー社交辞令モジュール
module ForMatthewPoliteness
# 本音
module RealIntention
HATE = '大嫌い'
STAY_AWAY = '近寄らないで'
end
# 建前
module Tatemae
# 建前マッピングに本音を与えると建前を得られる
TATEMAE_MAPPING = {
RealIntention::HATE => '大好き',
RealIntention::STAY_AWAY => '抱いて!',
}
end
end
FMP = ForMatthewPolitenes... | true |
e2219709385c88c83b74260a1af57a54f493f4a0 | Ruby | kingomarnajjar/weeks1to2 | /Example/gender & temp.rb | UTF-8 | 279 | 3.5 | 4 | [] | no_license | puts "what is your gender?"
random = gets.chomp.to_i
if female == "female"
puts "what is temp?"
if "female" above 20 = "wear dress"
if random <= 20
puts "wear shorts!"
else random > 20
puts "wear pants!"
end
male = "wear shorts!" "wear pants!"
def gender(male, female)
| true |
05c09a8415adc31719c2167b16c9481865fdb794 | Ruby | lgrains/stash | /spec/models/fabric_spec.rb | UTF-8 | 576 | 2.84375 | 3 | [] | no_license | describe Fabric do
describe "#name" do
let(:treated) { false }
let(:treatment_method) { nil }
subject { Fabric.new(fabric_type: "cotton", color: "orange", pattern: "flowered", treated: treated, treatment_method: treatment_method) }
its(:name) { should eq("orange flowered cotton".titleize) }
its(... | true |
e4ede5ac14e743e723007559d276b7987b81bd53 | Ruby | SeanTAllen/Odds-and-ends | /testers/nate/selector_test.rb | UTF-8 | 172 | 2.625 | 3 | [] | no_license | require 'rubygems'
require 'hpricot'
require 'nokogiri'
h = Hpricot::XML( "<div id='foo'> hello <p>goodbye</p></div>" )
h.search( "#foo > *").append("<h1>hi</h1>")
puts h
| true |
084993673f77f7887250b2090e7a0922d4fa6e4d | Ruby | dupjpr/ruby | /logic.rb | UTF-8 | 415 | 3.390625 | 3 | [] | no_license | def alive?(player_name, points)
(player_name == "ikk" && points > 30) || (player_name == "gut" && points > 10)
end
player_name = "ikk"
points = 40
alive?(player_name, points)
# def alive?(a,b)
# if a == "ikk" && b > 30
# true
# elsif a == "gut" && b > 10
# true
# els... | true |
2fa02a23e205e8a9f78f386d64b4df07d5f52e11 | Ruby | rsliter/bookstore | /lib/price_manager.rb | UTF-8 | 1,397 | 3.71875 | 4 | [] | no_license | require "book_sets_manager"
class PriceManager
COST_OF_BOOK = 8
DISCOUNT_PER_BOOK = 0.05
AMOUNT_OF_BOOKS_FOR_FIRST_DISCOUNT = 3
def initialize books
@sets_manager = BookSetsManager.new(books)
end
def price
unbalanced_price = calculate(@sets_manager.unbalanced_sets)
ba... | true |
6cf70f705e616ea2c9dbbc1de0596c4ca95e1e38 | Ruby | makzan/modern-web-design | /fetch_basecamp.rb | UTF-8 | 2,416 | 2.90625 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'rest_client'
def clean_formatted_content(content)
# clean elements
content = content.gsub(/<br>/,"\n").gsub(/<\/?div>/,"")
# a href
# content = content.gsub(/<\/a>/,"").gsub(/<a[^>]*>/,"")
content = content.gsub(/<a class="autolinked".*>(.*)<\/a>/,'\1')
# st... | true |
a6232ee049808a646fdcfaec2d7dda3f12d0dac2 | Ruby | moritzh/multiocr | /lib/multiocr/recognizer.rb | UTF-8 | 1,482 | 2.96875 | 3 | [] | no_license | require 'tempfile'
module MultiOCR
class Recognizer
attr_accessor :threshold, :lang, :file, :average_confidence, :text, :img
def initialize(file, threshold = 0.6, lang = "eng")
@threshold = threshold
@lang = lang
@average_confidence = 0
@text = ""
end
def run
... | true |
1606501d2896324796577bd17051d87bea20669f | Ruby | mjara93/EjerciciosRubyFiles | /Files_ejercicio2.rb | UTF-8 | 161 | 3.09375 | 3 | [] | no_license | def contador()
file = File.open('peliculas.txt','r')
content = file.readlines
file.close
return content.count
end
cantidad = contador()
puts cantidad
| true |
e74f702327071eb2546faadd21854aae14b61dec | Ruby | chanhpark/news-aggregator | /server.rb | UTF-8 | 787 | 2.890625 | 3 | [] | no_license | require 'sinatra'
require 'csv'
def read_articles_from(filename)
articles = []
CSV.foreach(filename, headers: true) do |row|
articles << {
title: row['title'],
description: row['description'],
url: row['url']
}
end
articles
end
def save_article(filename, title, description, url)
... | true |
dde585ef59d8dbb772768fd58168c65e0ab626f6 | Ruby | xiaoronglv/Practice-Golang | /tcp-echo-server/client.rb | UTF-8 | 141 | 2.734375 | 3 | [] | no_license | require 'socket'
socket = TCPSocket.open("localhost",9999)
1000.times do |i|
socket.write("#{i}\n")
end
1000.times {puts socket.gets}
| true |
95bb367999a829f666311a173d615fc95c481062 | Ruby | zhbanton/wdi_1_ruby_hw_auto_sales | /bin/car_lot_test.rb | UTF-8 | 962 | 2.75 | 3 | [] | no_license | require_relative "../lib/car_lot.rb"
cars = [ UsedCar.new("Toyota", "Highlander", 2006, 35000, 100050, damages: [Damage.new("Fender Bender", 500), Damage.new("Scuffed Hubcap", 500)], markup: 100),
UsedCar.new("Honda", "CRV", 2003, 25000, 81050),
UsedCar.new("Toyota", "Corolla", 2006, 35000, 100050, d... | true |
5ca97f5e3aee8241433e0dccef9b3b2cc08f5ea0 | Ruby | fuji-nakahara/nlp100 | /src/17.rb | UTF-8 | 381 | 3.3125 | 3 | [
"MIT"
] | permissive | # 1列目の文字列の種類(異なる文字列の集合)を求めよ.
# 確認にはsort, uniqコマンドを用いよ.
require 'csv'
file_path = File.expand_path('../data/hightemp.txt', __dir__)
res = CSV.read(file_path, col_sep: "\t").map { |row| row[0] }.uniq.sort
raise 'Failed!' if res != `cut -f 1 #{file_path} | sort | uniq`.lines(chomp: true).sort
puts res
| true |
faf9b134a27bb5ff9392314adb0863558a33c35e | Ruby | mustafamhasan/libsnmp | /mibs-resource-xml-generator.rb | UTF-8 | 676 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | require 'yaml'
complete_mib_list = {}
for file in ARGV
mibs = []
YAML::load_documents(File.open(file)){ |mib| mibs << mib }
mibs.each do |e|
e.each do |k,v|
complete_mib_list[v.strip] = k.strip
end
end
end
h = complete_mib_list
sorted = h.keys.sort_by {|s| s.to_s}.map {|key| [key, h[key]] }
puts '<?xm... | true |
c85b9f88842175f98db4bd12343a6dfa25de7c58 | Ruby | scorp/quakespotter.org | /Quakespotter.app/lib/quake.rb | UTF-8 | 3,791 | 2.9375 | 3 | [] | no_license | # Plotting longitude and latitude on a globe:
# x = r * cos(lat) * sin(long)
# y = r * sin(lat)
# z = r * cos(lat) * cos(long)
# where r is radius, lat is latitude and long is longitude
class Quake
class << self
attr_accessor :image, :selected_image, :overlay_image
end
HORIZON_Z = 120
TIME_FORMAT = ... | true |
29427338d2a386f3b450f59c965b76a576d45bf7 | Ruby | tnodland/book_club | /app/models/book.rb | UTF-8 | 1,138 | 2.59375 | 3 | [] | no_license | class Book < ApplicationRecord
has_many :author_books, dependent: :destroy
has_many :authors, through: :author_books, dependent: :destroy
has_many :reviews, dependent: :destroy
validates_presence_of :title
validates_presence_of :page_count
validates_presence_of :year
def average_rating
if reviews.co... | true |
7d9b748ac185c1584710ba74aa53900223a87adb | Ruby | dpmontooth/rb101 | /small_problems/easy_1/list_of_digits.rb | UTF-8 | 583 | 4.28125 | 4 | [] | no_license | # write method that takes one argument (positive integer), and returns list of
# digits in the number
# input: positive integer
# output: array containing list of each integer in original number
# algorithm
# define method taking in one positive integer as parameter value
# split given integer into array of component... | true |
2ee8b8bec97b9ab315898fed0e1fd09afb0a8fe4 | Ruby | marissazhang/Un-Fav | /twitter.rb | UTF-8 | 807 | 3.03125 | 3 | [] | no_license | require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "consumer key here"
config.consumer_secret = "consumer secret here"
config.access_token = "access token here"
config.access_token_secret = "access token secret here"
end
for fav in client.favor... | true |
ae99eabccdb0f22aaaca4c46d175e50cbdf7f02f | Ruby | DrXyclo/artist-song-modules-online-web-sp-000 | /lib/zCodeBase.rb | UTF-8 | 1,281 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
extend Memorable
extend Findable
attr_accessor :name
attr_reader :artist
@@songs = []
def initialize
@@songs << self
end
def self.all
@@songs
end
def artist=(artist)
@artist = artist
end
def to_param
name.downcase.gsub(' ', '-')
end
end
require '... | true |
879115f7944d69b388573a90db484637d7c34832 | Ruby | tiy-hou-q2-2015-rails/Day-6 | /ivars.rb | UTF-8 | 508 | 3.359375 | 3 | [] | no_license | class Widget
attr_accessor :sku
def initialize(sku)
self.sku = sku
self.stopped = true
@stopped = true
end
def start
self.stopped = false # calls `self.stopped=`
stopped = true #local
end
def stop
name = "YOLO" # local
self.stopped = true
end
def stopped # getter
ret... | true |
3d5bd3232ef9b2eaaeb236ff6773f2cc7ec738f4 | Ruby | CodeCoreYVR/class_demos_bootcamp_march_2021 | /ruby_methods_blocks_lambdas/what_is_it.rb | UTF-8 | 220 | 3.515625 | 4 | [] | no_license | def what_is_it (thing)
if [String,Array,Integer].include? (thing.class)
thing.class
else
"Something else"
end
end
p what_is_it "string"
p what_is_it 4
p what_is_it [1,2,3]
p what_is_it 5.0
| true |
15aead0745e34755722ef243e6a4fb0e89d24ac4 | Ruby | MsJennyGiraffe/final_chisel | /test/strong_test.rb | UTF-8 | 751 | 2.96875 | 3 | [] | no_license | #3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
#is there anything else should I be testing for in unit testing?
require 'minitest/autorun'
require_relative '../lib/strong'
class HeaderTest < Minitest::Test
def setup
@strong = Strong.new
end
def test_creates_opening_and_closing_strong_tags
assert_... | true |
e88d0641ee70d7900d56c5c942c4a340014b3e3c | Ruby | JoePShoulak/Winometer | /lib/simulate_helper.rb | UTF-8 | 8,263 | 3.421875 | 3 | [] | no_license | require 'json'
# The algorithm
def algorithm(subgame1, subgame2)
return (subgame1.points - subgame2.points).abs
end
# Misc.
def clear_line
print "\r" + " "*100 + "\b"*100
end
# Classes
class CLI
def initialize
@args = Hash.new
if ARGV.empty?
puts "Error: No arguments"
exit
end
en... | true |
d0067ddc75e56b42a8bedde8543cf47c74cb5025 | Ruby | doubleday/daff-rb | /lib/lib/sys/io/file_output.rb | UTF-8 | 527 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
module Sys
module Io
class FileOutput < ::Haxe::Io::Output
def initialize(f)
@__f = f
end
protected
attr_accessor :__f
public
def write_byte(c)
@__f.putc(c)
end
def write_bytes(b,p,l)
... | true |
3070a098335b1f9260d4ce17defd04e5c6f7aa26 | Ruby | showma0734/atcoder_beginner150 | /A.rb | UTF-8 | 373 | 3.578125 | 4 | [] | no_license | def valid?(k,x)
return false unless [k,x].all?{|obj| obj.is_a?(Integer)}
return false if k < 1 || k > 100
return false if x < 1 || x > 10**5
true
end
def fifty_yen(k,x)
return nil unless valid?(k,x)
if k*500 >= x
"Yes"
else
"No"
end
end
puts fifty_yen(5,1000) == "Yes"
puts fif... | true |
0f375d32c98489656bac061ff66376e58873848a | Ruby | songyot11/somsri | /lib/tasks/create_payroll.rake | UTF-8 | 1,431 | 2.546875 | 3 | [] | no_license | desc "This task is called by the Heroku scheduler add-on"
namespace "payroll" do
namespace "generate" do
task :on, [:month, :year] => :environment do |t, args|
create_payroll(args.month, args.year)
end
task :now => :environment do
create_payroll
end
end
end
def create_payroll(month=D... | true |
cc01965a39ce7d3ce29755664c34bb62e1753b72 | Ruby | collabital/platforms-yammer | /lib/platforms/yammer/configuration.rb | UTF-8 | 2,423 | 2.609375 | 3 | [
"MIT"
] | permissive | module Platforms
module Yammer
# Configuration pattern for Rails, allows defaults and initializers to
# override those defaults.
# @see https://stackoverflow.com/a/24151439 Stack Overflow
class << self
# Get the configuration
# @return [Configuration] the current configuration
def ... | true |
552a4925f161a5d7b81247b0dcb418964dba8264 | Ruby | carrollm2/ttt-with-ai-project-online-web-sp-000 | /lib/players/computer.rb | UTF-8 | 318 | 2.96875 | 3 | [] | no_license | require_relative '../player.rb'
class Players::Computer < Player
def move(board)
valid_moves = []
board.cells.each_with_index do |cell, index|
if cell == " "
position = index + 1
valid_moves << position.to_s.strip
end
end
valid_moves
valid_moves.sample
end
end
| true |
a115052ad8cd81c7267aaefa2b66f27c5a115a25 | Ruby | adolfoggc/ecommerce | /db/seeds.rb | UTF-8 | 2,473 | 2.703125 | 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
a4a09d389644122432999f42e87d593202f990a0 | Ruby | chaos0x8/imap-helper | /test/imap-helper/TestImapDate.rb | UTF-8 | 797 | 2.796875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'test/unit'
require 'mocha/setup'
require 'shoulda'
require_relative '../../lib/imap-helper/ImapDate'
class TestImapDate < Test::Unit::TestCase
context('TestImapDate') {
should('fail to create date with new') {
assert_raise(NoMethodError) {
ImapHelper::ImapDate.new(Dat... | true |
4f74dca8ff3144a28211323041a4aa36c93b3656 | Ruby | bger/csv_cat | /lib/csv_cat/table.rb | UTF-8 | 403 | 2.921875 | 3 | [] | no_license | module CsvCat
class Table
attr_reader :printer
# @params file_path [String]
#
def initialize(file_path)
@file = File.open(file_path)
end
# Prints ASCII table based on data from given file
#
def print
printer = CsvCat::Printer.new(
parser: CsvCat::Parser.new(file)
... | true |
9d8d5a6173e27a5bff7d6903172908baebd491e3 | Ruby | rajanjamu/dsa | /merge_sort.rb | UTF-8 | 1,686 | 4.375 | 4 | [] | no_license | # SORTING ARRAY USING MERGE-SORT ALGORITHM
# AUTHOR: RAJAN GUPTA
# CREATED: 1 DEC 2014
# UPDATED: 1 DEC 2014
# Merge-Sort function
def merge_sort(inArray)
if inArray.length > 1
# Split array using split function
splitArray = split(inArray)
# Returns sorted array if array.len > 1
return merge(merge_sort(splitA... | true |
7fa9f4adbfc951c97f587dd4315a42f1457047ef | Ruby | fullfabric/occupier | /lib/occupier/tenant.rb | UTF-8 | 2,412 | 2.859375 | 3 | [] | no_license | module Occupier
# @api public
class Tenant
attr_reader :handle
def initialize(handle, connection)
raise ::Occupier::InvalidTenantName.new(handle) unless Tenant.is_valid?(handle)
@handle = handle
@connection = connection
@environment = connection.environment
end
de... | true |
7ac1d6e1337d60835818f6aa99c926af21c0f99e | Ruby | DiegoLorca/week10_activity19 | /ejercicio3.rb | UTF-8 | 1,119 | 4.03125 | 4 | [] | no_license | # Se tiene la clase Vehicle que recibe como argumento un modelo y un año. El método engine_start enciende
#el vehículo.
class Vehicle
def initialize(model, year)
@model = model
@year = year
@start = false
end
def engine_start
@start = true
end
end
class Car < Vehicle
@@contador = 0
def in... | true |
01eaaa04c6ca08e7c67882ae7147ffe8ff739a58 | Ruby | waspcojp/folloger-libs | /libs/folloger_client_base.rb | UTF-8 | 512 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'rubygems'
require 'uri'
module Folloger
MAX_RETRY = 5
class Base
def set_timeout(open_timeout, read_timeout = open_timeout)
@open_timeout = open_timeout
@read_timeout = read_timeout
end
def set_retry(max_retry)
@max_retry = max_retry
end
private
def set_location(arg... | true |
8bc40c3f1ea9cca1b4181bebbad1e532f0c51846 | Ruby | AlMamun-CSE/competitive_programming | /Interview Street/Going Office/gen.rb | UTF-8 | 440 | 3.296875 | 3 | [] | no_license | n = 30
m = rand(n * (n - 1) / 2) + 1
puts "#{n} #{m}"
edges = []
m.times do
u = rand(n)
v = rand(n)
while u == v or edges.index([u, v]) or edges.index([v, u])
u = rand(n)
v = rand(n)
end
edges << [u, v]
w = rand(1000) + 1
puts "#{u} #{v} #{w}"
end
u = rand(n)
v = rand(n)
while u == v
u = rand... | true |
e8f1a7783cd0a7a9661e3f6790a894ae7ac9707c | Ruby | rwz/counterfeit | /lib/counterfeit/active_record.rb | UTF-8 | 1,319 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'active_support'
module Counterfeit
module ActiveRecord
extend ActiveSupport::Concern
module ClassMethods
def has_counterfeit(attr, options={})
options = options.with_indifferent_access
default_currency = options.delete(:currency).try(:to_s).try(:upcase)
... | true |
d0a78438828f92ccfbac1669f89e6889f8590b7f | Ruby | amatsuda/activesupport-refinements | /lib/active_support/refinements/core_ext/object/acts_like.rb | UTF-8 | 512 | 2.703125 | 3 | [
"MIT"
] | permissive | module ObjectExt; end; module ObjectExt::ActsLike
refine Object do
# A duck-type assistant method. For example, Active Support extends Date
# to define an acts_like_date? method, and extends Time to define
# acts_like_time?. As a result, we can do "x.acts_like?(:time)" and
# "x.acts_like?(:date)" to do duck-typ... | true |
5af01e7255750d9ebf0e1472c887ff3e6a870237 | Ruby | IgorTIV/refund_protect | /lib/refund_protect/base_validations.rb | UTF-8 | 1,457 | 2.875 | 3 | [
"MIT"
] | permissive | module RefundProtect
module BaseValidations
attr_reader :errors
def valid?(recheck = false)
if recheck || !@errors.is_a?(Hash)
@errors = Hash.new
run_validations
end
@errors.keys.empty?
end
def invalid?(recheck = false)
!valid?(recheck)
end
def run_v... | true |
68e79e4b2aa55e4dd2294e123e4b77754fb5b851 | Ruby | creasty/delta_test | /lib/delta_test/git.rb | UTF-8 | 3,404 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'open3'
require 'shellwords'
module DeltaTest
class Git
attr_reader :dir
def initialize(dir)
@dir = Pathname.new(dir)
end
###
# Check if in git managed directory
#
# @return {Boolean}
###
def git_repo?
_, _, s = exec(%q{rev-parse --is-inside-work-tree}) resc... | true |
9ef0ae69d127d50fec4cac20beed13605b5e433a | Ruby | rshea303/sales_engine | /lib/invoiceitem.rb | UTF-8 | 901 | 2.75 | 3 | [] | no_license | require 'bigdecimal'
require_relative 'support'
class InvoiceItem
include Support
attr_reader :id,
:item_id,
:invoice_id,
:quantity,
:unit_price,
:created_at,
:updated_at,
:repository,
... | true |
5395031c0a5c173151f68e3ead2ddb0aecf5e8e0 | Ruby | AbbyTunes/app-academy-exercise | /W5D2/memory puzzle/card_practice.rb | UTF-8 | 661 | 4.03125 | 4 | [] | no_license | # Card
# -# An instance variable for (a..z).to_a.sample
# - Display card information ( facedown or faceup )
# - hidden - face down
# - revealed - faced up
# - to_s # show letter
# - == (compare two instance)
class Card
attr_reader :num
attr_accessor :facedown
def initial... | true |
d06e3d3f5a89b147e8e1da1a0bdff749bba06047 | Ruby | DetectiveAzul/cc_w2_weekend_homework | /start_point/specs/song_spec.rb | UTF-8 | 483 | 3.09375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative '../song'
class SongRoom < MiniTest::Test
def setup()
@song01 = Song.new("You Give Love a Bad Name")
@song02 = Song.new("Rock You Like a Hurricane")
@song03 = Song.new("Put a Ring on It")
@song04 = Song.new("Bad Romance")
@song05 ... | true |
e9c718d2f7b2d4c8d4f4ac5cfea57677189ca7e1 | Ruby | mr-shimizu/Ruby-Algorithm | /Hit&Blow.rb | UTF-8 | 933 | 3.921875 | 4 | [] | no_license | N = 4 #桁数
arr = [*1..9]
ans =[]
hit = 0
i = 0 #count times of answer
j = 0 #count index
N.times do
num = arr[rand(arr.index(arr.max))]
ans.push(num)
arr.delete(num)
end
puts "Enter #{N} digits number except 0.\nIf the Number is only correct, it’s Blow.\nIf the number and the digit are correct, it’s Hit."
while hi... | true |
5520af61e6883cb310482397a7478e393a587a51 | Ruby | oanhcodes/phase-0 | /week-6/nested_data_solution.rb | UTF-8 | 3,330 | 4 | 4 | [
"MIT"
] | permissive | # RELEASE 2: NESTED STRUCTURE GOLF
# Hole 1
# Target element: "FORE"
array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]]
# attempts: 1
# ============================================================
p array[1][1][2][0]
# ============================================================
# Hole 2
# Target elemen... | true |
693874285ced0f8618255b69d27338409ed9b620 | Ruby | AyedhSh/ruby-class-variables-and-class-methods-lab-re-coded-000 | /lib/song.rb | UTF-8 | 965 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
@@count = 0
@@genres =[]
@@artists =[]
attr_accessor :name, :artist , :genre
# ----------------------------------------
def initialize(name,artist,genre)
@name = name
@artist = artist
@genre = genre
@@count += 1
@@artists << artist
@@genres << genre
end
# ---------------------... | true |
1a5caea3254d2b268f90cceafb03e68cacd423ff | Ruby | 33marvil/CodeaCamp | /Fase 1/Semana 4/Miercoles 16-mar/torteria copy.rb | UTF-8 | 4,779 | 3.265625 | 3 | [] | no_license | #Creacion clase tortas
class Tortas
#el usuario podra ver los valores de las siguientes variables
attr_accessor :time_cook, :torta, :num_tortas, :type_torta
#metodo que inicizializara estas varibles
#cada vez que se cree un objeto de la clase tortas debe tener
#tipo de torta y tiempo a cocinar
def initializ... | true |
6ca730f88769a903e032dc01c8f81de870de983d | Ruby | mom0tomo/ruby-book | /lib/proc.rb | UTF-8 | 1,151 | 4.40625 | 4 | [] | no_license | # ブロックではなく、1個のProcオブジェクトを引数として受け取る(&を付けない)
def greeting(arrange_proc)
puts'おはよう'
text = arrange_proc.call('こんにちは')
puts text
puts 'こんばんは'
end
# Procオブジェクトを普通の引数としてgreetingメソッドに渡す(&を付けない)
repeat_proc = Proc.new{| text|text*2 }
greeting(repeat_proc)
# おはよう
# こんにちはこんにちは
# こんばんは
# 3種類のProcオブジェクトを受け取り、それぞれのあいさつ文... | true |
9a84f6ffb2ccda6d87f4f98df438d4ed00fd207a | Ruby | guvd/Hanoi | /spec/screen_spec.rb | UTF-8 | 439 | 2.75 | 3 | [] | no_license | require './spec/spec_helper'
require './lib/screen'
describe Screen do
it "given an array should return the tower" do
screen = Screen.new
rod = [3,2,1]
rod_output = [
[" ", " ", "_", "|" , "_", " ", " "],
[" ", "_", "_", "|" , "_", "_", " "],
[... | true |
f08ad8f88d4225cecb2c4693dd093e5518874b2f | Ruby | hthmkhlf/teachyourselfcs | /ruby/yam.rb | UTF-8 | 487 | 3.390625 | 3 | [] | no_license | require 'yaml'
class Person
attr_accessor :name, :age
end
def yamlize
fred = Person.new
fred.name = "Fred Bloggs"
fred.age = 45
laura = Person.new
laura.name = "Laura Briggs"
laura.age = 23
test_data = [fred, laura]
puts test_data.to_yaml
end
def load_yaml
yaml_string = <<END_OF_DATA
---
- !ru... | true |
894c22401f916bc75f4212420cfc557f24867271 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/1584133312504029a6c65bc31853a269.rb | UTF-8 | 291 | 3.515625 | 4 | [] | no_license | class Phrase
attr_reader :sentence
def initialize( sentence )
@sentence = sentence.downcase
end
def split_into_words
sentence.scan(/\w+/)
end
def word_count
split_into_words.each_with_object(Hash.new(0)) do |word, hash|
hash[word] += 1
end
end
end
| true |
686b10dc10dedc64f188795213592dfd5b2e71d7 | Ruby | fenmarel/project_euler | /025_1000-digit Fibonacci number/euler25.rb | UTF-8 | 776 | 3.953125 | 4 | [] | no_license | # The Fibonacci sequence is defined by the recurrence relation:
#
# Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
# Hence the first 12 terms will be:
#
# F1 = 1
# F2 = 1
# F3 = 2
# F4 = 3
# F5 = 5
# F6 = 8
# F7 = 13
# F8 = 21
# F9 = 34
# F10 = 55
# F11 = 89
# F12 = 144
# The 12th term, F12, is the first term to contain ... | true |
b063935c74ed9056482c0184d6772f90d73c7291 | Ruby | l0nglive/my-first-repo | /ruby/return.rb | UTF-8 | 127 | 3.4375 | 3 | [] | no_license | def multiply(a, b)
a*b
end
puts multiply(1,2)
def scream(words)
words = words + "!!!!"
puts words
end
scream(1.to_s) | true |
9a8f75314bdc1b65df2b372d02bd919ae7602e4a | Ruby | johnmosesman/its_my_day | /app/models/texter.rb | UTF-8 | 476 | 3.078125 | 3 | [] | no_license | require 'twilio-ruby'
class Texter
def self.text_ethan
# put your own credentials here
account_sid = ENV["TWILIO_ACCOUNT_SID"]
auth_token = ENV["TWILIO_AUTH_TOKEN"]
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token
names = %w(Dennis Tami J... | true |
59b0c259ac7e5a01826a724904dba8d119db2199 | Ruby | deepcerulean/dedalus | /lib/dedalus/view_traversal.rb | UTF-8 | 6,305 | 2.6875 | 3 | [
"MIT"
] | permissive | module Dedalus
class ViewTraversal
include Geometer::PointHelpers
include Geometer::DimensionHelpers
def initialize(&blk)
instance_eval(&blk)
end
def on_atom(&blk)
@atom_callback = blk
end
def on_molecule(&blk)
@molecule_callback = blk
end
def on_element(&blk)... | true |
88806f2959a0aa68814d03e27fe4153f62cfbaa9 | Ruby | jamis/chaussettes | /lib/chaussettes/effect/fade.rb | UTF-8 | 830 | 2.75 | 3 | [
"MIT"
] | permissive | module Chaussettes
module Effect
# Represents a fade effect
class Fade
TYPE_MAP = {
nil => nil,
:h => 'h', 'h' => 'h', :half_sine => 'h',
:l => 'l', 'l' => 'l', :log => 'l', :logarithmic => 'l',
:p => 'p', 'p' => 'p', :parabola => 'p', :inverted_parabola => 'p',
... | true |
4d48ea2593ad1b485e1cfbcd634eb09fc4d36fe0 | Ruby | dropofwill/ballin-adventure | /inversions_merge_sort.rb | UTF-8 | 2,245 | 3.765625 | 4 | [
"Unlicense"
] | permissive | require_relative 'deep_dup'
class Array
# Run merge_sort non-destructively to get inversions
# This runs in O(nlogn) which is better than finding
# inversions naively O(n^2) so while the sort may semm
# wasteful it turns out to be the most efficient way to
# count the inversions.
def inversions
@inver... | true |
fdd27e5ec2a4305e931594865a3b3bd8c6e5fce4 | Ruby | sjhaws/week1 | /contact_list.rb | UTF-8 | 2,226 | 3.640625 | 4 | [] | no_license | User_input = "> "
contact_list = [
{name: "Bob", email: "bob@rminc.com", phone: 8013550200},
{name: "Jill", email: "jill@rminc.com", phone: 8013550201},
{name: "Ken", email: "ken@rminc.com", phone: 8013550202}
]
puts "Welcome to your contact list"
while true
puts "-" * 20
puts "1. Add contact to li... | true |
7a26a899d63bf763fdaec960bce14ea51d3e0249 | Ruby | sgnh/advent-of-code-2018 | /1/2.rb | UTF-8 | 208 | 3.078125 | 3 | [] | no_license | input = File.readlines('./input.txt').map(&:to_i)
frequency = 0
frequencies = {}
input.cycle do |f|
frequency += f
break if frequencies.key? frequency
frequencies[frequency] = nil
end
puts frequency
| true |
5b0f290ee2282e4fab101ac19f3ae32d04aff9e8 | Ruby | ajm188/tattle | /lib/tattle/parser/ast/node.rb | UTF-8 | 2,309 | 3 | 3 | [
"MIT"
] | permissive | require 'parser'
module Parser
module AST
class Node
closures = [:module, :class, :defs, :def, :block]
closures.each do |sym|
define_method "#{sym}_body" do
children.last
end
end
node_types = closures +
[:begin, :lvasgn, :ivasgn, :cvasgn, :send] + # prog... | true |
df984d8b09e34a543d773d48bfd11e6a944860f1 | Ruby | trample/JBS_2012_Homework | /W1/PA1/movie_data.rb | UTF-8 | 2,591 | 3.84375 | 4 | [] | no_license | #movie_data
#Tom Ma
#2012 June 2
#Purpose: to create a class which can give a popularity list for the movies and similarity list for the users
class MovieData
#load data by STDIN
def load_data
@list = STDIN.readlines.collect{|x| x.split[0..2]}
end
#generate a popularity list by the adding the ratings of eac... | true |
1ac886ab1bf43cc559b1fa119cc521a332d85751 | Ruby | suhovius/Daemons-Master | /multi_conn_srv.rb | UTF-8 | 882 | 2.765625 | 3 | [] | no_license | #server receive a file from client
require 'socket'
CHUNK_SIZE = 4096 # bytes (4Kb)
full_base_path = File.dirname(File.expand_path(__FILE__))
connections_count = 0
port = Integer(ARGV[0]) # socket's port
pid_file = ARGV[1] || "daemon.pid" # full path to pid file
File.open(pid_file, 'w') { |file| file.write Process.p... | true |
1d4f4694035ddcb4e9a17bca12e4029e854a92ff | Ruby | dpette/RabbitManager | /app/models/baby_rabbit.rb | UTF-8 | 467 | 2.796875 | 3 | [] | no_license | class BabyRabbit < Rabbit
validate :validate_cage
MIN_AGE = 0
MAX_AGE = 35
def baby_rabbit?
true
end
# def can_become_classes
# c_b_c = super
# end
def self.allowed_cage_type
MotherhoodCage
end
def self.min_age
0
end
def self.max_age
35
end
# private
# def val... | true |
ecf11cac3ad179779a9c953191d2cfd12050f9c5 | Ruby | Flare2B/YEARepo | /Battle/Visual_Battlers.rb | IBM866 | 25,871 | 2.609375 | 3 | [
"MIT"
] | permissive | #==============================================================================
#
# Yanfly Engine Ace - Visual Battlers v1.01
# -- Last Updated: 2012.07.24
# -- Level: Easy
# -- Requires: n/a
#
# Modified by:
# -- Yami
# -- Kread-Ex
# -- Archeia_Nessiah
#==============================================================... | true |
62f1f852eeceb7bd13acb58ae30563776de24cc9 | Ruby | emergent/ProjectEuler | /Ruby/problem032.rb | UTF-8 | 533 | 3.5 | 4 | [
"Unlicense"
] | permissive | #! /usr/bin/env ruby
=begin
Problem 32 - Project Euler
http://projecteuler.net/index.php?section=problems&id=32
=end
def pandigital_product(cs)
product = cs[5, cs.size].join.to_i
pp =
(1..3).map {|i|
cs[0, i].join.to_i * cs[i, 5-i].join.to_i
}.select { |m| m == product }
.to_... | true |
167fd6c019d5633da9d02175ecd4a01a1fa015f7 | Ruby | Cileos/shiftplan | /app/models/notification/klass_finder.rb | UTF-8 | 2,060 | 2.875 | 3 | [] | no_license | class Notification::KlassFinder
attr_reader :notifiable, :recipient
def find(notifiable, recipient)
@notifiable = notifiable
@recipient = recipient
case notifiable
when ::Post
Notification::Post
when ::Comment
find_klass_for_comment
end
end
private
def find_klass_for... | true |
3f0350ac8fd8d56f439034764d064d35323a924d | Ruby | Jaspion/Kilza | /lib/jaspion/kilza/class.rb | UTF-8 | 3,555 | 3.015625 | 3 | [
"MIT"
] | permissive | module Jaspion
module Kilza
# Represents one single object class
module Class
# Class name
attr_accessor :name
# Array with all class properties
attr_accessor :properties
# Initializes a Class object
#
# @param name [String] Class Name
def initialize(name)
... | true |
21f3491b81575be8144f5ca8a6402e3265a3890f | Ruby | oxywtf/ogden | /lib/og/model/revisable.rb | UTF-8 | 2,583 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | module Og::Mixin
# Revision support for Og-managed classes.
#
# class Article
# is Revisable
# attr_accessor :body, String, :revisable => true
# attr_accessor :title, String
# end
#
# Generates the Revision class:
#
# class Article::Revision
#
# article.revisions
#
# article.revise do |a|
# a.title = 'hello'
#... | true |
1d21258249493487b81f740d13e00caf590531b8 | Ruby | eewang/flatiron-students | /other/student_scraper_data.rb | UTF-8 | 17,886 | 2.96875 | 3 | [] | no_license | require 'sqlite3'
db = SQLite3::Database.new("students.db")
rows = db.execute <<-SQL
CREATE TABLE students (
id INTEGER PRIMARY KEY autoincrement,
name text,
tagline text
);
SQL
class Student
attr_accessor :name, :tagline
# @@db = SQLite3::Database.new "students.db"
@@student_list = []
def i... | true |
663ad9a18e1fe96be30872a35f20231b72e4370f | Ruby | drexel-ue/aA-homeworks | /W7D3/spec/lru_cache_spec.rb | UTF-8 | 1,418 | 3.296875 | 3 | [] | no_license | require 'lru_cache'
describe 'LRUCache' do
describe '#initialize' do
subject(:cache) { LRUCache.new(4) }
it 'should initialize an LRUCache with an empty array and set the max element number' do
expect(cache.show).to eq([])
end
end
describe '#add' do
subje... | true |
dcdf328d3a9a73c0f2b1be930167801343dc0886 | Ruby | TaylorOD/actualize_course | /pre_work/week_5/war.rb | UTF-8 | 2,193 | 3.984375 | 4 | [] | no_license | #fun way to get the game started. Asks the user if they want to play before declaring war
puts "Want to play war?"
input = gets.chomp.downcase
if input == "yes"
puts "WAR!"
end
#actaual code for war
player_A = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]
player_B = [1, 1... | true |
4d91cde708accd35844f3c0e1639a27a5026ca8b | Ruby | sweetyBThareja/rubyCode | /ruby_project/maximum.rb | UTF-8 | 860 | 4.0625 | 4 | [] | no_license | #maximum of three numbers
#Using initialize method
class Max
def initialize
@a = 10
@b = 20
@c = 50
end
def max_number
if @a > @b && @a > @c
max = @a
elsif @b > @c
max = @b
puts max
else
max = @c
puts max
end
puts "maximum number is #{max}"
end
#Us... | true |
9525993fa9bc7a9cbb320624285ba83ad6bb8af7 | Ruby | goodrobots/maverick | /manifests/puppet-modules/grafana/lib/puppet/functions/grafana/get_sub_paths.rb | UTF-8 | 1,077 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license",
"Apache-2.0"
] | permissive | # == Function get_sub_paths
#
# This function receives an input path as an input parameter, and
# returns an array of the subpaths in the input, excluding the input
# path itself. The function will attempt to ignore any extra slashes
# in the path given.
#
# This function will only work on UNIX paths with forward slash... | true |
db75c88fcea9553540dbb2149dd403ed0f18f398 | Ruby | mstksg/Emerge | /lib/emerge/command_data.rb | UTF-8 | 4,212 | 2.65625 | 3 | [] | no_license | module Command_Data
@@POSSIBLE_COMMANDS = [:move,:wait,:turn,:stop,:emit_energy,:multiply_speed,
:set_speed,:shoot_spike,:if]
@@COMMAND_WEIGHTS = { :move => 1.5 ,
:wait => 1.0 ,
:turn => 1.0 ,
... | true |
703bd83520a8bd4777873168d8eeef0734b3836b | Ruby | gh05t-4/ceasar-cipher-ruby | /ceasar.rb | UTF-8 | 1,283 | 4.09375 | 4 | [] | no_license | #!/usr/bin/env ruby
# defination of ceasar_cipher method
def ceasar_cipher(input, key)
enc_s = "" # variable to store encrypted string
# for each character in input shift the character
# with key if it is a alphabet
input.each_char do |char|
if ('A'..'Z').include?(char) # Check for upcase
if (char.o... | true |
e904f17d3c01f93b66d7821eca28c33528b9a982 | Ruby | Lewington-pitsos/launch_prep | /11_excercises/excercise_3.rb | UTF-8 | 71 | 3.078125 | 3 | [] | no_license | a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
w = a.select { |i| i.odd?}
puts w
| true |
8970c610fa6eba38a38773e3e35273f30f8a8bd7 | Ruby | mx98829/123 | /Lesson_4/test36.rb | UTF-8 | 2,065 | 4.125 | 4 | [] | no_license | # Lucy loves to travel. Luckily she is a renowned computer scientist and gets to travel to international conferences using her department's budget.
# Each year, Society for Exciting Computer Science Research (SECSR) organizes several conferences around the world. Lucy always picks one conference from that list that is... | true |
27e94ed869d5d6c8b2b686e4feb5d67c363b3d71 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/00982c4cdc7c4f5daf52c720017f9768.rb | UTF-8 | 323 | 3.609375 | 4 | [] | no_license | class Bob
def hey(message)
case message.strip
when /^\s*$/
'Fine. Be that way!'
when lambda { |m| letters = m.gsub(/[^a-zA-Z]/, ''); !letters.empty? && (letters == letters.upcase) }
'Whoa, chill out!'
when lambda { |m| m[-1] == '?' }
'Sure.'
else
'Whatever.'
end
end
e... | true |
a651180a392d663e0161349f691000cca0b85d71 | Ruby | smirza89/address-bloc | /address-bloc/controllers/menu_controller.rb | UTF-8 | 4,012 | 3.796875 | 4 | [] | no_license | require_relative '../models/address_book'
class MenuController
attr_reader :address_book
def initialize
@address_book = AddressBook.new
end
def main_menu
puts "Main Menu - #{address_book.entries.count} entries"
puts "1 - View all entries"
puts "2 - Create an entry"
puts "3 - Search for an entry"
pu... | true |
542cc0f1f45c3e71a90d91531b38644163d60e08 | Ruby | ongaeshi/fude2 | /color_kind.rb | UTF-8 | 1,210 | 3.125 | 3 | [] | no_license | require "./fude"
oneshot do
@i = 0
@text = "色番号のサンプルです。"
yld 120
@text = ""
1.upto(16) do |e|
@i = e
yld 8
end
yld 120
end
draw do
cls
tile(@i)
print(@text, 32, 128 - 8, 7)
end
def tile_n(x, y, n)
x *= 64
y *= 64
rectfill x, y, 64, 64, n
c = n >= 6 ? ... | true |
9f888b9632ddce654766500c70fe231f45f3bbed | Ruby | KahramanAtilla/Day1THP | /exo_21.rb | UTF-8 | 372 | 3.21875 | 3 | [] | no_license | puts "Salut, bienvenue dans ma super pyramide ! Combien d'etages veux-tu ?"
print ">"
nb = gets.chomp
nb = nb.to_i
nbchar = nb
noQ = nbchar
q = 1
if nb <= 25 && nb >= 1
while nb > 0
nbchar = noQ -q
nbchar.times do
print " "
end
q.times do
print "#"
end
puts "\n"
q = q + 1
nb = nb - 1
e... | true |
817aad06e71122c95d0006099272eab1235d81e0 | Ruby | klavinslab/protocols_aquarium_1_0 | /cloning/gel/GelPurify.rb | UTF-8 | 3,712 | 2.71875 | 3 | [] | no_license | #This protocol purifies gel slices into fragment stocks
needs "aqualib/lib/standard"
needs "aqualib/lib/cloning"
class Protocol
include Standard
include Cloning
def debug
false
end
def arguments
{
gelslice_ids: [27327, 27328]
}
end
def main
slices=input[:gelslice_ids]
slice_number = slices.len... | true |
5fb44fd3d8a8be5965c7a4cf2efb783977a0df40 | Ruby | michael-danello/RB101 | /easy6/letter_counter.rb | UTF-8 | 537 | 3.859375 | 4 | [] | no_license | def letter_case_count(string)
l_hash = {}
l_hash[:lowercase] = string.count("a-z")
l_hash[:uppercase] = string.count("A-Z")
l_hash[:neither] = string.length - (l_hash[:lowercase] + l_hash[:uppercase])
l_hash
end
puts letter_case_count('abCdef 123') == { lowercase: 5, uppercase: 1, neither: 4 }
puts letter_c... | true |
a610ebde10c3b8665079c26d722855f3b4246e38 | Ruby | suzshiro1024/statistics_visualizer | /src/batting_stats.rb | UTF-8 | 2,595 | 3.1875 | 3 | [] | no_license | class BattingStats
def initialize(tpa,ab,h,wb,tb,hr,rbi,bb,ibb,hbp,so,sb,cs,sh,sf,dp)
@tpa = tpa # Total Place Appearance
@ab = ab # At Bat
@h = h # Hit
@wb = wb # Two-Base Hit
@tb = tb # Three-Base Hit
@hr = hr # Home Run
@rbi = rbi ... | true |
edea3dd03b1113411761b61f2cc72e4587afcefe | Ruby | JacobNinja/codeminer | /lib/codeminer/expressions/block_expression.rb | UTF-8 | 306 | 2.78125 | 3 | [] | no_license | module CodeMiner
class BlockExpression < Expression
attr_reader :body, :params, :value
def initialize(body, params, src)
@body = body
@params = params
@src = src
end
def type
:block
end
def each
[@params, *Array(@body.each)]
end
end
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.