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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
819e30935d91a5b35ae7fd076d53439a1d0cf812 | Ruby | mariomanzoni/Enterprise-Recipes-with-Ruby-and-Rails | /code/testing/rspec/rspecmocks/vendor/plugins/rspec/lib/spec/extensions/class.rb | UTF-8 | 940 | 3.171875 | 3 | [
"MIT"
] | permissive | #---
# Excerpted from "Enterprise Recipes for Ruby and Rails",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose... | true |
afae3c4eb8cb42b7735bbee827cca31163b5d2e2 | Ruby | IrinaKudashkina/ruby_base | /Lesson01/quadratic_equation.rb | UTF-8 | 668 | 3.515625 | 4 | [] | no_license | print "Коэффициент a = "
a = gets.chomp.to_f
print "Коэффициент b = "
b = gets.chomp.to_f
print "Коэффициент c = "
c = gets.chomp.to_f
d = b ** 2 - 4 * a * c
puts "Квадратное уравнение #{a}*x^2 + #{b}*x + #{c} = 0"
puts "Дискриминант равен #{d}"
if d > 0
puts "Первый корень уравнения равен #{(- b + Math.sqrt(d)) / (2... | true |
f5e2d66ae7affb3c28f4582d2d7fcc885a97a7dc | Ruby | vietwow/algorithms-for-fun | /robot_movements.rb | UTF-8 | 499 | 3.578125 | 4 | [] | no_license | #get number of possible moves from 0,0 to n,n
#currently restricts robot to right and down moves only
#next step - allows up,down,left,right movements with no revisits
def get_num_movements(n)
matrix = Array.new(n){Array.new(n){0}}
matrix.each_with_index do |row, y|
row.each_with_index do |val, x|
if y =... | true |
bb510df7e9cf76db7afd5a5f87deb82e7f8da026 | Ruby | nofxx/git-issues | /lib/git-issues/login_helper.rb | UTF-8 | 2,619 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | require 'highline/import'
require 'parseconfig'
require 'zlog'
module LoginHelper
Log = Logging.logger[self]
def config_file
@config_file ||= "~/.git-issues.conf"
end
def oauth_token
@oauth_token ||= get_secret("Enter OAuth consumer secret: ", "oauth-token")
end
def oauth_consumer_key
@oauth... | true |
3bbf5f9bf61c45c746c112c05448102f713eeb89 | Ruby | xtrombone/billboard-top-100-gem | /lib/track.rb | UTF-8 | 220 | 2.734375 | 3 | [
"MIT"
] | permissive | class Track
attr_accessor :title
attr_accessor :artist
attr_accessor :rank
attr_accessor :cover
def initialize(title, artist, rank, cover)
@title = title
@artist = artist
@rank = rank
@cover = cover
end
end | true |
e7b3919c2c64243a6b02fd203bdc23ed296907dc | Ruby | david-bermudez1102/list-best-rated-movies-cli-gem | /lib/list_best_rated_movies/scraper.rb | UTF-8 | 4,464 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
class ListBestRatedMovies::Scraper
attr_accessor :genre, :year
def scrape_genres
genres_data = url("https://www.rottentomatoes.com/top/bestofrt/top_100_horror_movies/") #Where we are obtaining our genres from
genres_data.css("div.btn-group.btn-... | true |
fa4533bdd77152683d12bbebdb20f44987e138cc | Ruby | lmullen/dissertations-data | /csv2df.rb | UTF-8 | 4,375 | 2.734375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Convert CSVs generated from Proquest MARC files into useable CSV to read
# as a dataframe in R.
# Lincoln A. Mullen | lincoln@lincolnmullen.com | http://lincolnmullen.com
# MIT License <http://lmullen.mit-license.org/>
require "csv"
dataframe = Array.new
current_id = "AAI0000059"
current_rec... | true |
571d6f1a57bfb7d1a5bbba1de173a2f888290c9e | Ruby | trizen/sidef | /scripts/RosettaCode/hash_join.sf | UTF-8 | 693 | 3.515625 | 4 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Hash_join
#
func hashJoin(table1, index1, table2, index2) {
var a = Arr.new;
var h = Hash.new;
# hash phase
table1.each { |s|
h{s[index1]} := [] -> append(s);
};
# join phase
table2.each { |r|
a += h{r[index2]}.map{[_,r]}... | true |
0a4911a4507abded04f5762c44c345c018270b7d | Ruby | mitchellhenke/api-gem | /lib/bandsintown/artist.rb | UTF-8 | 6,888 | 3.015625 | 3 | [
"MIT"
] | permissive | module Bandsintown
class Artist < Base
attr_accessor :name, :mbid, :events, :upcoming_events_count, :image_url, :thumb_url
def initialize(options = {})
@name = options[:name]
@mbid = options[:mbid]
@image_url = options[:image_url]
@thumb_url = options[:thumb_url]
@bandsintown_ur... | true |
f657c24c2c31b8b12a796191e9049c8c5fb98519 | Ruby | github/licensed | /lib/licensed/ui/shell.rb | UTF-8 | 1,251 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # frozen_string_literal: true
require "thor"
module Licensed
module UI
class Shell
LEVELS = %w(silent error warn confirm info debug)
def initialize
@shell = STDOUT.tty? ? Thor::Base.shell.new : Thor::Shell::Basic.new
@level = ENV["DEBUG"] ? "debug" : "info"
end
def debug... | true |
7a276c647862287026820175c7179f560e82e106 | Ruby | AlexBaranosky/EmailOMatic | /src/reminder/email_history.rb | UTF-8 | 689 | 2.90625 | 3 | [] | no_license | require 'date'
require 'yaml'
require File.dirname(__FILE__) + '/../../src/extensions/enumerable_extensions'
class EmailHistory
HISTORY_FILE = File.dirname(__FILE__) + '/../../resources/email_history.yaml'
def initialize
@history = YAML.load_file HISTORY_FILE
end
def num_reminders_already_sent_today
... | true |
c4e2ef825cd3bf5a83f655291813507f12d7ffdf | Ruby | ihsaneddin/op3nbuild-ecommerce | /lib/encryption/AES256CBC/encryptor.rb | UTF-8 | 926 | 2.875 | 3 | [
"MIT"
] | permissive | require 'openssl'
module Encryption
module AES256CBC
class Encryptor
def initialize plaintext
@plaintext = plaintext
@iv, @ciphertext = encrypt
end
def plaintext
decrypt
end
def ciphertext
@ciphertext
end
protected
def encrypt
... | true |
b5fb6a782b53bfbff1e0dbe33733c6e3f9994e69 | Ruby | learn-co-students/crowdfunding-sql-lab-001 | /lib/sql_queries.rb | UTF-8 | 923 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts
"Write ... | true |
7f608501bf392cd51c60649d1633648f3199c4b9 | Ruby | drycpp/machinery | /ffi/ruby/machinery.rb | UTF-8 | 1,685 | 2.625 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
# This is free and unencumbered software released into the public domain.
require 'ffi' # @see https://rubygems.org/gems/ffi
##
# Ruby FFI for the `libmachinery` native library.
#
# @see http://machinery.dryproject.org/
module Machinery extend FFI::Library
ffi_lib ['machinery', 'libmachinery.so.... | true |
645a7cb1add2cf6e63d3b25a2d59dedc61de8afb | Ruby | janegreene/bloody_hogwarts | /spec/features/students/index_spec.rb | UTF-8 | 2,797 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe "students index page", type: :feature do
it "can see all students and their information" do
@harry = Student.create(name: "Harry Potter", age: 14 , house:"Griffindor")
@hermoine = Student.create(name: "Hermoine Grainger", age: 14 , house:"Griffindor")
@ron = ... | true |
5ef017177a9117251cf3bd0d92418d55c68b77ac | Ruby | raiet13/sinatra-logging-in-and-out-v-000 | /app/helpers/helpers.rb | UTF-8 | 214 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Helpers
def self.current_user(session_hash)
User.find(session_hash[:user_id])
end
def self.is_logged_in?(session_hash)
if session_hash[:user_id]
return true
end
false
end
end
| true |
c20336d57d9c192c002527669a8d92c8cac9c736 | Ruby | hallbergandrew/byhand-base-number-converter | /lib/byhand_convertor.rb | UTF-8 | 1,072 | 3.9375 | 4 | [] | no_license | def binary(string)
final_number = 0
numbers = string.reverse.split("").collect {|x| x.to_i}
numbers.each_with_index do |number, index|
final_number += number * (2 ** index)
end
final_number
end
def trinary(string)
final_number = 0
numbers = string.reverse.split("").collect {|x| x.to_i}
numbers... | true |
76e85647c196be69e4a8a9f2b8999aeeeef13bfc | Ruby | toptal/pact_broker-client | /lib/pact_broker/client/colorize_notices.rb | UTF-8 | 666 | 2.734375 | 3 | [] | no_license | require 'term/ansicolor'
module PactBroker
module Client
class ColorizeNotices
def self.call(notices)
notices.collect do | notice |
colorized_message(notice)
end
end
def self.colorized_message(notice)
color = color_for_type(notice.type)
if color
... | true |
14b81b3e11e0e22c031b3bd9798428743a1290f6 | Ruby | prnvsan/LearnRuby | /ex8.rb | UTF-8 | 487 | 3.34375 | 3 | [] | no_license | formatter = "%{first} %{second} %{third} %{fourth}"
puts formatter % {first: 1, second: 2, third: 3, fourth:4}
puts formatter % {first:"one",second: "two",third:"three",fourth:"four"}
puts formatter % {first:true,second:false,third:true,fourth: false}
puts formatter % {first: formatter,second:formatter,third:formatter... | true |
4c7d67e86c377e5eb6f10ff6a028ad5b5ef7341d | Ruby | dimitras/time_series_analysis | /scripts/identify.genetype.rb | UTF-8 | 904 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
#Merge the two filtered gene lists according to common genes.
ifile1 = ARGV[0] # scripts/Mus_musculus.NCBIM37.63.gtf
ifile2 = ARGV[1] # Brain/DE.w.limma.voom/Sleep.vs.SleepDep.w_LimmaVoom_DEG_results.txt
genelibrary = {}
File.open(ifile1,"r").each_line do |line|
line.strip!
genetype = line.spli... | true |
cea82a56756904d7352f4c1fb2f5ca6cbe9dbd4c | Ruby | kaekasui/cryuni_sim | /db/seeds.rb | UTF-8 | 5,557 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
require 'csv'
def save_and_print(target, key_name)
return unless target.changed?
target_changes = target.changes
target.save
puts "-- #{target.class.name}: #{key_name}, #{target_changes}"
end
# 英雄
CSV.foreach('db/seeds/heros.csv') do |row|
hero = Hero.find_or_initialize_by(nam... | true |
536e448f47ba1f28f6e827918948bd7d79222891 | Ruby | nvnogomes/peuler | /052.rb | UTF-8 | 618 | 3.71875 | 4 | [] | no_license |
# Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits in some order.
# 142857
class Euler52
def initialize(c=6,m=1000000)
@MAX = m
@cycles = c
end
def solve
1.upto(@MAX) do |number|
return number if equal_products(number)
end
end
def equal_product... | true |
1e67028f6e037f0cc299fd97b63bf8533aa5f169 | Ruby | KoluaTsyrul/study-ruby | /study_ruby/file.rb | UTF-8 | 396 | 2.6875 | 3 | [] | no_license | def create_folder
Dir.mkdir 'file' unless Dir.exist? 'file'
Dir.chdir 'file'
end
def create_file
File.open("input.txt", "w+") { |f| f.write "#{Time.now} - User logged in\n" }
end
def remove_dir
File.delete('/Users/mtsyr/Documents/cucumber-ruby/study_ruby/file/input.txt')
Dir.delete('/Users/mtsyr/Documents/c... | true |
8fb98b40089ddc0f16ea536670afedcffca0cb7d | Ruby | stvadim9/Ruby_Math_Tasks | /ProgrammingTasksRuby/6/numb136v.rb | UTF-8 | 119 | 2.609375 | 3 | [] | no_license | #v
def task136v(n, a)
for i in 1..n
a += a.abs
puts "a#{i} = #{a}"
end
puts "v) #{a}"
end
task136v(8, 6)
| true |
03e416b256c5e795a649f33f770fbff032e270b3 | Ruby | jgodoyco/Ironhack | /Curso/Module2/fizzBuzz.rb | UTF-8 | 250 | 3.515625 | 4 | [] | no_license | class FizzBuzz
def testNumber(number)
test=number
if (number % 3 == 0)
test = "fizz"
end
if (number % 5 == 0)
test = "buzz"
end
if ((number % 5 == 0)&&(number % 3 == 0))
test = "fizzbuzz"
end
return test
end
end
| true |
c57220513fcee37bfb43ab53c8452e5c8ba88b91 | Ruby | RiNZL3R1/Ruby | /global_degiskenler.rb | UTF-8 | 565 | 3.40625 | 3 | [] | no_license | puts " 1. #{$isim} 1. " #kayıtli deger olmadıgı icin bos
$isim ="aybo"
puts " 2. #{$isim} " #kayitli deger oldugu icin kaydı yazdırır
puts "atamadana once: #{$global_degisken}"
class Test
def yazdir
$global_degisken=1
puts "test icindeki deger :#{$global_degisken}"
end
end
class Degiri_bir_arttir
def yaz... | true |
efd4f7142c9fab9095dfa39f0d273e938050a8ad | Ruby | stephqwu/CoderByte-1 | /Medium/33.MaxSubArray/solve.rb | UTF-8 | 340 | 3.25 | 3 | [] | no_license | FIXNUM_MIN = -(2**(0.size * 8 -2))
def MaxSubarray(arr)
best_sum = FIXNUM_MIN
(0..arr.length-2).each do |i|
current_sum = arr[i]
(i+1..arr.length-1).each do |j|
current_sum += arr[j]
best_sum = current_sum if current_sum > best_sum
end
end
best_sum
end
# keep this function call here
puts MaxSu... | true |
020c5a4cbfa105d565e6f04d6ebb068cc298259a | Ruby | papapabi/project-euler | /36.rb | UTF-8 | 415 | 3.890625 | 4 | [] | no_license | require 'benchmark'
UPPER_BOUND = 1000000
def palindromic_numbers(n)
numbers = []
1.upto(n) do |i|
numbers << i if i.to_s.reverse == i.to_s and i.to_s(2).reverse == i.to_s(2)
end
return numbers
end
time = Benchmark.measure do
puts 'The sum of all palindromic numbers in base 2 and 10 < 1,000,000'\
" i... | true |
d677898701d5b816e8658718ed9c3f54129b2120 | Ruby | mpogran/recipes | /app/models/ingredient.rb | UTF-8 | 568 | 2.53125 | 3 | [] | no_license | class Ingredient
include ActiveModel::Model
include ActiveModel::Serializers::JSON
# Attributes
attr_accessor :name, :category, :quantity, :modifier, :description
# Validations
validates :name, presence: true
def attributes=(hash)
hash.each do |key, value|
send("#{key}=", value)
end
end... | true |
11471fae57ccfd33aa6b21ad2d653c9b71f3ec17 | Ruby | alphagov/e-petitions | /app/helpers/date_time_helper.rb | UTF-8 | 1,898 | 2.671875 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | module DateTimeHelper
WAITING_FOR_KEYS = Hash.new(:other).merge(0 => :zero, 1 => :one)
TO_BE_DEBATED_KEYS = Hash.new(:other).merge(0 => :today, 1 => :tomorrow)
def short_date_format(date_time)
date_time && date_time.strftime("%-d %B %Y")
end
def short_date_time_format(date_time)
date_time && date_ti... | true |
970bfb719e4b83a1581daebee46396112c9edcc6 | Ruby | itmaster921/RubyOnRailsDev | /app/services/mixpanel_tracker.rb | UTF-8 | 2,425 | 2.671875 | 3 | [] | no_license | # Handles statistics tracking using mixpanel
class MixpanelTracker
def self.tracker
@tracker ||= Mixpanel::Tracker.new(ENV['MIXPANEL_TOKEN'])
end
def self.credit_card(user)
tracker.track(user.id,
'Credit Card added by User',
time_form_signup: (Time.now.utc - Time.parse... | true |
2565689b02a8a20dec5f604607612b8ef453bd99 | Ruby | maxiappleton/ruby-problems | /120_mortgage_calculator.rb | UTF-8 | 1,378 | 3.828125 | 4 | [] | no_license | # Mortgage Calculator
def prompt(message)
Kernel.puts("=> #{message}")
end
prompt("Welcome to the mortgage calculator! Please input the necessary information when prompted.")
# Collect user input
loan_amount = nil
prompt("Please enter the loan amount (rounded to the nearest dollar): ")
loop do
loan_amount = Kern... | true |
9e8390f308309c54529526556c0e636911ac4bff | Ruby | amerdidit/members | /app/member_languages.rb | UTF-8 | 1,295 | 3.03125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'redis'
require File.expand_path('../../config/environment', __FILE__)
# = MemberLanguages
#
# MemberLanguages encapsulates the logic of returning the languages of a
# specific member to the user. The data must be retrieved from the Github API
# previous to running this command.
c... | true |
6a7813a92634e62140a618eaab17343e81cb278c | Ruby | sorankov/UNT | /bone.rb | UTF-8 | 504 | 3.0625 | 3 | [] | no_license | # coding: utf-8
class Bone < Sprite
def initialize(x,y,img,angle)
super(x,y,img)
@angle = angle
end
def update
self.x -= 3
self.angle = @angle
if self.y >= Window.height - self.image.height
self.vanish
end
end
# 他のオブジェクトから衝突された際に呼ばれるメソッド
def hit
if $hp ... | true |
8fd7097e847a68493d09ca2d88d31a61c6177aac | Ruby | puravin/physics-lab-booking-project | /Project/test/unit/experiment_test.rb | UTF-8 | 693 | 2.546875 | 3 | [] | no_license | require File.expand_path("../../test_helper", __FILE__)
class ExperimentTest < ActiveSupport::TestCase
test "won't create without name given" do
experiment = Experiment.new
assert !experiment.save, "saved experiment without critical information"
end
test "won't create if exp_num is not a number" do
experime... | true |
f29dd03e52a367fb83f140a8ecee4ee72c6459c9 | Ruby | shingkid/basic-encryption | /substitution.rb | UTF-8 | 850 | 3.8125 | 4 | [] | no_license | load 'utility.rb'
def enSubstitute(plain, keyword)
shift = keyword
('a'...'z').each do |ch|
if !keyword.include?(ch)
shift += ch
end
end
shift = alphabet[k...26] + alphabet[0...k]
cipher = ""
# For each letter, search for index and add 97.
for i in 0...plain.le... | true |
41fdf557a16644a78b3a653e354950b5c58a424f | Ruby | tomgiagtz/reverse-each-word-dc-web-091718 | /reverse_each_word.rb | UTF-8 | 163 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
array = string.split(" ")
output = ""
array.collect {|w| output << w.reverse + (w == array.last ? "" : " ")}
return output
end | true |
23c37edf7504c6514a74733f283f6b5dcc9bb655 | Ruby | johnmc321/RepoFromHome | /pine6.1.rb | UTF-8 | 1,074 | 4.0625 | 4 | [] | no_license | v1 = "navan"
v2 = "dlroW"
puts v1.reverse
puts v2.reverse
puts "What is your first name?"
first_name = gets.chomp
puts ""
puts "What is your second name?"
second_name = gets.chomp
puts ""
puts "What is your surname?"
surname = gets.chomp
puts ""
puts "So, your full name is #{first_name} #{second_name} #{surname}?"
#f... | true |
2a245cf1dc5b8ae5d904d49c33e228ec753fa404 | Ruby | AdamBrownBB/guided-module-one-final-project | /lib/command_line.rb | UTF-8 | 1,864 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CommandLine
def greet
# puts "What do you fancy?".colorize(:light_blue)
def header
doc = <<-'TIME'
_ _ _ _ _ ___ ____
| || || | | _ | | / __) ... | true |
59b4b856d9a7802cb39c37d9ab74f331413d8403 | Ruby | ktym1/LRTHW | /ex12.rb | UTF-8 | 561 | 3.96875 | 4 | [] | no_license | print "Give me a number: "
number = gets.chomp.to_i
bigger = number * 100
puts "A bigger number is #{bigger}."
print "Give me another number: "
another = gets.chomp
number = another.to_i
smaller = number / 100
puts "A smaller number is #{smaller}."
print "Will you give me money?"
answer = gets.chomp
print "How abo... | true |
f92742d188406b3d7a1a5552c79a756856077fb3 | Ruby | Maggie1294/launch | /test-flight/spec/lib/airplane_spec.rb | UTF-8 | 5,091 | 3.109375 | 3 | [] | no_license | require_relative "../../lib/airplane"
describe Airplane do
let(:my_plane) { Airplane.new("cesna", 10, 150, 1000) }
describe "#initialization" do
context 'when plane is made' do
it 'its type is cesna' do
expect(my_plane.type).to eq("cesna")
end
it 'its wing_loading is 10' do
e... | true |
0f909f6c28d2db086f18e96864695d452793803b | Ruby | takayuki-ochiai/CodePractice | /RubyPractice/Refactoring/dynamic_method_definition.rb | UTF-8 | 1,002 | 3.515625 | 4 | [] | no_license | # def failure
# self.state = :failure
# end
# def error
# self.state = :error
# end
# def success
# self.state = :success
# end
%i(failure error success).each do |method_name|
define_method method_name do
self.state = method_name
end
end
#こんなメソッドを定義する方法もある
class Class
def def_each(*method_names, &bl... | true |
37083c90b49fdb0901320247c99828f35d7c72d0 | Ruby | katymccloskey/SET-game | /app/models/deck.rb | UTF-8 | 1,356 | 3.25 | 3 | [
"MIT"
] | permissive | class Deck < ApplicationRecord
belongs_to :game, dependent: :destroy
has_many :cards
def draw_cards(number)
shuffled_cards = self.cards.to_a.shuffle!
shuffled = shuffled_cards.slice!(0, number)
delete_cards(shuffled)
return shuffled
end
def delete_cards(card_array)
self.cards -= card_a... | true |
51772230967a69d5429b82edf2b3a30781f08f67 | Ruby | lymanwong/Ruby-Stuff | /algorithms/delete_repeats/delete_repeats.rb | UTF-8 | 860 | 4.15625 | 4 | [
"MIT"
] | permissive | =begin
Given a string whicn only contains lowercase. You need to delete the repeated letters leaving only one, and try to make the lexicograpical order of new string is smallest
bcabc => abc
cbacdcbc => acdb
=end
class Dedupe
def initialize(string)
@string = string.split()
@counts = Hash.new 0
end
def ... | true |
50e8ae23535427e261b6169c511e12ebed6109a6 | Ruby | chris-schwartz/ruby_design_patterns | /proxy-pattern/original_code/BankAccountVirtualProxy.rb | UTF-8 | 866 | 2.859375 | 3 | [] | no_license | # This demonstrates a 'lazy' proxy. The bank account is not created until
# it is needed. To avoid forcing the responsibility of creating a bank aount
# on
# This demonstrates the use of a proxy for 'lazy' loading. Here the BankAccount is not created until it has to be used
# A creation block is passed to the constr... | true |
e1418fd76f727c3894fde5e967a1533ad7652a41 | Ruby | sizzlelab/aaltoapps | /app/models/markdown_helper.rb | UTF-8 | 916 | 2.640625 | 3 | [
"MIT"
] | permissive | # Helper for models with data in Markdown format
module MarkdownHelper
module ClassMethods
# Creates a method that returns parsed HTML for each field.
def markdown_fields(*fields)
fields.each do |field|
define_method("#{field}_html") { |*args| markdown_field_as_html field, *args }
end
... | true |
c9af5eb346fc603fbda048f8b5d582d839c35baf | Ruby | ongaeshi/fude | /raylib.rb | UTF-8 | 8,609 | 2.71875 | 3 | [] | no_license | module Raylib
# slower patch: https://github.com/raysan5/raylib/issues/922
alias clear_background_org clear_background
def clear_background(color)
draw_sphere(Vector3.init(0, 0, 0), 0, WHITE)
clear_background_org(color)
end
class Vector2
def self.init(x, y)
o = Vector2.new
... | true |
43c6e3016e07501dd2fdc786faba202e6f5a2759 | Ruby | sandagolcea/Ruby | /kickstart/session1/challenge/7_string.rb | UTF-8 | 637 | 3.90625 | 4 | [] | no_license | # given a string, return the character after every letter "r"
#
# pirates_say_arrrrrrrrr("are you really learning Ruby?") # => "eenu"
# pirates_say_arrrrrrrrr("Katy Perry is on the radio!") # => "rya"
# pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr"
def pirates_say_arrrrrrrrr(string)
let... | true |
4ee9123af798d98b507cd4acf462ca753635b762 | Ruby | sadayasu825/mypazzle | /paiza/ruby/B/B011.rb | UTF-8 | 340 | 3.09375 | 3 | [] | no_license | # 標準入力から値を取得してinput_lineに入れる
ipt = gets.chomp.split.map!(&:to_i)
N = ipt[0]
tar = ipt[1]
hash = {}
i = 0
until (N * 2 * i) >= tar do
N * 2 * i
i += 1
end
start = N * 2 * (i - 1) + 1
N.times do |j|
hash[start + j] = start + N * 2 - 1 - j
end
p (tar < start + N) ? hash[tar] : hash.key(tar)
| true |
05b193fcb3602e8d400c5026a3e0c00d59afc198 | Ruby | gylmar/ruby_graph | /graph.rb | UTF-8 | 9,383 | 3.6875 | 4 | [] | no_license | #!/usr/bin/ruby
require './priorityQ.rb'
# Graph class manages nodes, edges and their relations
#
# Attributes:
# @nodes - Hash that maps a (unique) element to the node that
# contains the element.
# @edges - Hash that takes in a Node element as input
# and returns a list of Edges cor... | true |
bfaa9b366847a4a73999079a1fa036d6670a8307 | Ruby | MadayAlcala/Ruby-Training | /Slide2/to_f.rb | UTF-8 | 136 | 3.75 | 4 | [] | no_license | print "Give me a number:"
number = gets.chomp.to_f
double = number + number
puts "The double of the number #{number.to_i} is #{double}"
| true |
9e86f3a424a310c33c99d268aad0cd6eb56e6f97 | Ruby | mikedao/minitest_playground | /test/assertions_test.rb | UTF-8 | 6,178 | 3.03125 | 3 | [] | no_license | require_relative 'test_helper'
# These tests are designed fo fail
# use the -n flag (see test/filtering_test.rb)
# to scope the suite invocation to just the one you're fixing
# If you need a more detailed explanation of any of these methods
# look at the docs: http://rdoc.info/gems/minitest/Minitest/Assertions
class... | true |
e975b4c17808213428695030f3d200dc1e45d250 | Ruby | alicia0408/patrones_anidados | /letra_i.rb | UTF-8 | 183 | 2.90625 | 3 | [] | no_license | n = ARGV[0].to_i
n.times do |i|
print "*"
end
print "\n"
(n-2).times do
print " "
(n-4).times do
print "*"
end
print "\n"
end
n.times do |i|
print "*"
end
print "\n" | true |
e63bd66bd54a9b035be691a088fd197754162d58 | Ruby | partkyle/euler-rb | /problem05.rb | UTF-8 | 198 | 3.265625 | 3 | [] | no_license | n = 0
while true
n += 20
found = true
(1..21).each do |i|
if n % i != 0
found = false
break
end
end
puts n if n % 1000000 == 0
break if found
end
puts n
# 232792560 | true |
94ef85aedb4c9c64b1eaf73bfb0070863dad1f80 | Ruby | camsys/transam_core | /app/calculators/weighted_average_condition_rollup_calculator.rb | UTF-8 | 1,016 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | # --------------------------------
# # NOT USED see TTPLAT-1832 or https://wiki.camsys.com/pages/viewpage.action?pageId=51183790
# --------------------------------
class WeightedAverageConditionRollupCalculator < Calculator
# Calculates the last year for service given the asset sub type and the date the asset was... | true |
d496081ee739527efb03d1cbdd605cd016ed6d48 | Ruby | jeyavelnkl/jel_apps | /timetest.rb | UTF-8 | 491 | 3.546875 | 4 | [
"MIT"
] | permissive | module Welcomedog
class Greeting
def process(hour_of_clock)
greet(hour_of_clock)
end
private def greet(hour_of_clock)
if hour_of_clock >= 6 && hour_of_clock <= 11
"Good Morning"
elsif hour_of_clock >= 12 && hour_of_clock <= 16
"Good Afternoon"
elsif hour_of_clock >... | true |
be1dd51f7eeaf96eb4d22ec66fc345d0d58922d4 | Ruby | burz/feck | /src/environment.rb | UTF-8 | 377 | 2.6875 | 3 | [
"MIT"
] | permissive | class Value
attr_accessor :value, :type_object
def initialize(value, type_object)
@value = value
@type_object = type_object
end
end
class Environment
attr_accessor :values
def initialize(scope)
@values = {}
scope.names.each do |x|
@values[x] = Value.new nil, NilSingleton.instance
... | true |
2183f770b4e422a5dc1b53543c61ceab3d2af9a3 | Ruby | JosephM2425/apiNasaRovers | /nasarovers.rb | UTF-8 | 1,212 | 3.140625 | 3 | [] | no_license | #url = "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos"
#TOKEN = "b0mZGNk49RQdL2RULbRzvj43QWK6n9HdKcWd4KW4"
require "uri"
require "net/http"
require "json"
def request(url, token)
url = URI("#{url}?sol=1000&api_key=#{token}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true... | true |
d0972c351ee322d5b60d4cb05b8c74a7877eefb0 | Ruby | Pklong/geralf | /lib/session.rb | UTF-8 | 337 | 2.609375 | 3 | [] | no_license | require 'json'
class Session
APP = '_geralf'.freeze
def initialize(req)
@store = (req.cookies[APP] ? JSON.parse(req.cookies[APP]) : {})
end
def [](key)
@store[key]
end
def []=(key, val)
@store[key] = val
end
def store_session(res)
@store[:path] = '/'
res.set_cookie(APP, @store.to... | true |
f676c83d83e97c15433b23aa4526914bfdb712dd | Ruby | 3point14guy/flix-with-testing | /app/models/user.rb | UTF-8 | 739 | 2.640625 | 3 | [] | no_license | class User < ApplicationRecord
has_secure_password
validates :name, presence: true
validates :email, presence: true,
uniqueness: { case_sensitive: false },
format: /\A\S+@\S+\z/
validates :password, length: { minimum: 10, allow_blank: true }
validates :username, unique... | true |
86dae068c422c833c0e5c80bd099e1b40ffa062c | Ruby | warrenshen/blockterm | /server/app/helpers/auth.rb | UTF-8 | 158 | 2.546875 | 3 | [] | no_license | class Auth
attr_reader :auth_token
attr_reader :user
def initialize(user, auth_token)
@auth_token = auth_token
@user = user
self
end
end
| true |
b3806804aebdde757b304478d0a6dd907947e27a | Ruby | sevab/BattleshipSinatra | /game.rb | UTF-8 | 1,742 | 3.390625 | 3 | [] | no_license | require './grid_refactored'
class Game
#attr_reader :player1, :player2
def initialize(player1, player2)
@player1 = player1
@player2 = player2
@players = {@player1 => Grid.new, @player2 => Grid.new}
@turn = player2
end
def own_grid(player) #will conflict with attr_reader :players
@players[... | true |
1aa97901b165ec5ec10dd1e9d64594532b16173c | Ruby | team-umlaut/umlaut | /app/service_adaptors/elsevier_cover.rb | UTF-8 | 1,556 | 2.640625 | 3 | [
"MIT"
] | permissive | # Elsevier provides publically available and linkable sample cover images
# for journals they publish. Thanks Elsevier! This service does nothing
# more than take an ISSN and look for a match from Elsevier.
class ElsevierCover < Service
require 'open-uri'
def service_types_generated
return [ServiceTypeValue[... | true |
acf50d24ddcec8f654b97e96fdddc6c8f0c01197 | Ruby | ErikSchierboom/exercism | /ruby/nth-prime/nth_prime.rb | UTF-8 | 386 | 3.609375 | 4 | [
"Apache-2.0"
] | permissive | module Prime
def self.nth(number)
raise ArgumentError if number.zero?
primes = [2, 3]
current = 6
while primes.size < number
primes << current.pred unless primes.any? { |prime| (current.pred % prime).zero? }
primes << current.succ unless primes.any? { |prime| (current.succ % prime).zero?... | true |
24c3d2e2ec6fb80663bd1dda0915e8d3cbcaaccf | Ruby | joeldevel/ruby-language | /variables_and_constants.rb | UTF-8 | 520 | 4.3125 | 4 | [] | no_license | # by convention a constant is uppercase
PRICE = 145.6
puts "price is #{PRICE}"
# The constant can be changed, but Ruby will warning us
PRICE = 0
puts "price is #{PRICE}"
# Declare and initialize a variable
cat_name = "Poti"
cat_age = 30
puts "#{cat_name} is #{cat_age}"
#type of the variable
puts "cat_name is of t... | true |
afc00d84f489c7fc31fd853a585da8b25f4ec179 | Ruby | chunkyguy/AdventOfCodeSolutions | /Day5/day5.rb | UTF-8 | 552 | 3.640625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
def isNice(s)
# doesn't contains any of these strings
["ab", "cd", "pq", "xy"].each { |invalid| return false if s.include? invalid }
# build table
table = Hash.new(0)
s.each_char do |ch|
table[ch] += 1
end
# has at least 2 vowels
return false if ["a", "... | true |
fe796868fa0ee1965126a4c26acf5bc6d5dbf41e | Ruby | hamling-ling/NumericalResearches | /TouchTrace/extract.rb | UTF-8 | 1,381 | 3.25 | 3 | [] | no_license | # -*- coding: utf-8 -*-
class PointData
def initialize(t, n, x, y)
@t = t
@n = n
@x = x
@y = y
end
attr_accessor:t
attr_reader:n
attr_reader:x
attr_reader:y
end
if(ARGV.length == 0) then
puts "error need filename"
exit 1
end
filename = ARGV[0]
if not File.exist?(filename) then
pu... | true |
e9ae765c302e58ecc13c5475c62d61a4e7642153 | Ruby | masui/RotateImage | /rotate.rb | UTF-8 | 1,104 | 3.046875 | 3 | [] | no_license | def make_rotated(image, degree)
cmd = "convert #{image} -rotate +#{degree} rotated.png"
puts cmd
system cmd
s = `file rotated.png`
s =~ /(\d+)\s+x\s+(\d+)/
width = $1.to_i
height = $2.to_i
puts "#{image} width=#{width}, height=#{height}"
centerx = width / 2
centery = height / 2
size = 540
po... | true |
afe813c1c8f6fcdfd13e4ac15f64062178af8b4a | Ruby | Mark-Ball/codewars | /ruby/6th_kyu/rect_into_sq.rb | UTF-8 | 276 | 3 | 3 | [] | no_license | def sqInRect(lng, wdth)
return nil if lng == wdth
result = []
while [lng, wdth].min > 0
result.push([lng, wdth].min)
if lng > wdth
lng = lng - wdth
else
wdth = wdth - lng
end
end
return result
end | true |
9a7116607d3fc4dc14942c63f763a77657ccd3ae | Ruby | joshuaburkhart/DEET | /test/FastaParserTest.rb | UTF-8 | 4,931 | 2.546875 | 3 | [] | no_license | require 'test/unit'
require_relative '../lib/FastaParser'
require_relative '../lib/Sequence'
class SequenceTest < Test::Unit::TestCase
V_FASTA_N = "valid_fasta.fasta"
I_FASTA_N = "invalid_fasta.fasta"
def setup
valid_fasta_contents = <<EOS
>sample_seq_id
ATCTATCG
TTTGGGA
TTTTTTTT
>sample_seq_id2
at... | true |
e7760cf7a30f7badda48eedba7bd183fa04267ed | Ruby | LauraKirby/fun_code | /rubyc/lib/battleship.rb | UTF-8 | 3,838 | 3.75 | 4 | [] | no_license | # # square map of N rows,
# # The positions of ships are given as a string S,
# # containing pairs of positions describing respectively
# # the top-left and bottom-right corner cells of each ship.
# # Ships' descriptions are separated with commas.
# # The positions of hits are given as a string T,
# # containing posi... | true |
adfdb41b7a27720f4df1c375b8c6b3fdb0128e72 | Ruby | gotascii/crags | /lib/ext/attr_chain.rb | UTF-8 | 411 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module AttrChain
def chained_attr_accessor(*names)
names.each do |name|
define_method :"#{name}" do | *args |
return instance_variable_get(:"@#{name}") if args.length == 0
if args.length == 1
instance_variable_set(:"@#{name}", args[0])
return self
end
raise Arg... | true |
8719e876a61cafc04c51a6aa09cff6dae9775c98 | Ruby | webclinic017/finginie | /app/decorators/fixed_deposit_details_decorator.rb | UTF-8 | 457 | 2.90625 | 3 | [] | no_license | class FixedDepositDetailsDecorator
def initialize(fd_details)
@fd_details = fd_details
end
def self.custom_decorate(fd_details)
new(fd_details)
end
def top_five_public_sector
@fd_details.select {|fd_detail| fd_detail.sector == "public" || fd_detail.sector == "PUBLIC"}.take(5)
end
def top_f... | true |
702f89175d3459f66ea86a9b53b2859536b83c77 | Ruby | odremaer/rails-app | /app/services/rules/badge_category_rule_service.rb | UTF-8 | 776 | 2.53125 | 3 | [] | no_license | module Rules
class BadgeCategoryRuleService < AbstractRuleSpecification
def satisfies?
amount_of_tests_that_user_passed_succesfully_with_certain_category(@user, @test) %
tests_with_certain_category(@parameter) == 0
end
private
def amount_of_tests_that_user_passed_succesfully_with_certain... | true |
85e09e2b753e79d063837d325c77a7138d4ef9d7 | Ruby | megharastogi/online_store | /spec/helpers/association_helper.rb | UTF-8 | 1,133 | 2.703125 | 3 | [] | no_license | # modulraize it so that variable_name need not be passed again n again
def verify_belongs_to variable_name, *associations
associations.each do |association|
it "should belong to a #{association}" do
variable = instance_variable_get("@#{variable_name}")
variable.should belong_to(association)
end
... | true |
58cbfecf06ee7ff274cae550647ddcb011fdec23 | Ruby | kkaempf/usbmon | /lib/usbmon/control.rb | UTF-8 | 1,118 | 2.578125 | 3 | [
"Ruby"
] | permissive | class ControlIn
attr_reader :port, :length, :data
def initialize stream
ci = stream.next UsbMon::Submission, "Ci"
@port = ci.wValue
result = stream.next UsbMon::Callback, "Ci"
raise "Mismatch length S:Ci/C:Ci" unless ci.dlen == result.dlen
@length = result.dlen
@data = result.data
return... | true |
af0881d93da68ae5b06bf8f03f0c31bcbe63e64d | Ruby | KimberlyBaker/cli_makeup | /lib/api.rb | UTF-8 | 729 | 2.890625 | 3 | [] | no_license | class API
def self.fetch_lipstick
url = "http://makeup-api.herokuapp.com/api/v1/products.json?brand=covergirl&product_type=lipstick"
uri = URI(url)
response = Net::HTTP.get(uri)
hash = JSON.parse(response)
array_of_lipstick = hash[1]
# name
# produ... | true |
420ccf2169542d6f9a9f0037d0ca1c62cae6e9d7 | Ruby | yossaj/IMDB_ripoff | /start_code/models/casting.rb | UTF-8 | 1,096 | 3.109375 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class Casting
attr_reader :id, :star_id, :movies_id
attr_accessor :fee
def initialize(options)
@star_id = options["star_id"].to_i
@movie_id = options["movie_id"].to_i
@fee = options["fee"].to_i
@id = options["id"].to_i if options["id"]
end
def save()
... | true |
5ff0006d8c60b1da94336bf607d6edd384857bc0 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/7eb202c0ff0b48e7867fb9a18569dccb.rb | UTF-8 | 649 | 3.90625 | 4 | [] | no_license | class Anagram
attr_reader :text_letters
private :text_letters
def initialize(text)
@text_letters = to_letters(text)
end
def match(words)
words.select { |word| is_valid_anagram?(word) }
end
private
def is_valid_anagram?(word)
word_letters = to_letters(word)
return false if exactly_sa... | true |
6fb46477b8913fccae892a73566c5a9445909d3f | Ruby | AlbinaZakirova1804/my-collect-dumbo-web-111918 | /lib/my_collect.rb | UTF-8 | 209 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect
array = ["Tim Jones", "Tom Smith", "Jim Campagno"]
string = array.join(' ')
array = string.split(',')
i = 0
while i < array.length
new_array << yield array[i]
i ++ =1
end
new_array
end
| true |
f1e8fa90ddb23293d7cd9dd08dce88273439d38d | Ruby | itiut/sutra-copying | /perfect-ruby/c10/li10.02.rb | UTF-8 | 455 | 2.796875 | 3 | [] | no_license | class ParentClass
def super_public_method; end
private
def super_private_method; end
protected
def super_protected_method; end
end
class ChildClass < ParentClass
def public_method; end
private
def private_method; end
protected
def protected_method; end
end
child = ChildClass.new
def child.sin... | true |
90e6193386d183b3d23ebe763451401890941e93 | Ruby | lylyanne/W2D2-W2D3 | /rook.rb | UTF-8 | 278 | 2.75 | 3 | [] | no_license | require_relative './sliding_pieces.rb'
class Rook < SlidingPiece
def move_dirs
ORTHOGONALS
end
def symbol
color == :white ? '♖'.colorize(:white) : '♜'.colorize(:black)
# :r
end
end
# board = Board.new
# r = Rook.new([4,4],:white, board)
# p r.moves
| true |
72e82527a0943afb66f4c6f184a36a360d802505 | Ruby | portatlas/phase-0 | /week-5/calculate-mode/my_solution.rb | UTF-8 | 3,271 | 3.90625 | 4 | [
"MIT"
] | permissive | # Calculate the mode Pairing Challenge
# I worked on this challenge [by myself, with: Andrew ]
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.
# 0. Pseudocode
# What is ... | true |
e2e97e94aecc58d46f4fba05d297c4635b7d0e4a | Ruby | jvshahid/bosh-windows-stemcell-builder | /spec/packer/config/provisioner_slices/test_provisioner.rb | UTF-8 | 1,457 | 2.828125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class TestProvisioner
attr_accessor :command, :source, :destination, :provisioner_type
def self.new_file_provisioner(source, destination)
provisioner = new
provisioner.provisioner_type = :file
provisioner.source = source
provisioner.destination = destination
provisioner
end
def self.new_po... | true |
de71a44babc114b981f2eccd2ffa3d43e26f5da7 | Ruby | aclemons/hangman-ruby | /spec/interaction_spec.rb | UTF-8 | 3,252 | 2.8125 | 3 | [
"MIT"
] | permissive | #
# Copyright (C) 2016 Powershop New Zealand Ltd
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, ... | true |
6ceca8f16809fba9687d87f63cd8d6eb507c1cf1 | Ruby | satoyos/PTA-EventAttendance | /spec/peer_spec.rb | UTF-8 | 4,485 | 3.046875 | 3 | [] | no_license | require_relative '../peer'
describe 'Peer' do
describe '初期化' do
let(:peer){Peer.new('セ・リーグ')}
it 'should be a valid object' do
expect(peer).not_to be nil
expect(peer).to be_a Peer
end
it '名前が正しく設定されている' do
expect(peer.name).to eq 'セ・リーグ'
end
it '初期化時には、学級の数はゼロ' do
expe... | true |
b91d46c2886308096aba6965218839916496fda8 | Ruby | minkeesung/phase-0-tracks | /ruby/guessword/guesswordspec.rb | UTF-8 | 232 | 2.5625 | 3 | [] | no_license | require_relative 'classguessword'
require_relative 'driverguessword'
describe WordGame do
let(:wordGame) { WordGame.new }
it "guesses the word" do
expect(wordGame.word_equal("bob")).to eq "bob"
end
end
| true |
d8119ca30b1b6293fe965f16291e82f906c1bdfe | Ruby | duritong/puppet-gitosis | /files/hooks/update-ssh-keys | UTF-8 | 1,317 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Script by Camillo Bruni, Oscar Nierstrasz, Niko Schwarz, 2010
# This script checks whether any incoming commit
# has invalid ssh keys in the keydir directory. That is useful
# for gitosis-admin repositories, as gitosis crashes hard
# if faulty keys reside in the keydir.
# Install it in .git/ho... | true |
ed16adfb4892a4dac58dc4781dca52cf32855b52 | Ruby | al-0989/An-s_blog | /spec/controllers/posts_controller_spec.rb | UTF-8 | 9,140 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe PostsController, type: :controller do
let!(:user) {FactoryGirl.create(:user)}
let!(:user_1) {FactoryGirl.create(:user)}
# use this to create valid posts. Since we did not define a user here, the
# factory will just automatically generate one for us.
let!(:valid_post) {F... | true |
b265e681058055caef3f96a039156886161435d9 | Ruby | taw/magic-search-engine | /search-engine/lib/condition/condition_layout.rb | UTF-8 | 200 | 2.703125 | 3 | [
"MIT"
] | permissive | class ConditionLayout < ConditionSimple
def initialize(layout)
@layout = layout.downcase
end
def match?(card)
card.layout == @layout
end
def to_s
"layout:#{@layout}"
end
end
| true |
fcc5d7b54cd34b077653a829744064d2f7e3879c | Ruby | scratchglory/ruby-objects-has-many-through-lab-online-web-pt-051319 | /lib/doctor.rb | UTF-8 | 968 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | =begin
Doctor
#name
has a name
#new
initializes with a name and adds itself to an array of all doctors
#new_appointment
given a date and a patient, creates a new appointment (FAILED - 1)
#appointments
has many appointments (FAILED - 2)
#patients
has many patients, through appointments (F... | true |
d88c207fbc23d3d01fd0263f2c6a7a9dfd0bb107 | Ruby | NaisHRT/Ruby-Exercices | /exo_15.rb | UTF-8 | 367 | 3.4375 | 3 | [] | no_license |
puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?"
nombre = gets.chomp.to_i
y=0
while y < nombre
y = y + 1
puts "#" * y
end
#Construis un programme exo_15.rb qui va demander à l'utilisateur un nombre entre 1 et 25 et qui va sortir une pyramide à descendre d'autant... | true |
38766c76d5f14f145fd38642c7eb76ecb4ac8781 | Ruby | amarjerome87/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 284 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def reverse_each_word(string)
new_array = []
string.split.each {|word|new_array << word.reverse}
return new_array.join( " " )
end
def reverse_each_word(string)
array_new = []
string.split.collect do |word| array_new << word.reverse
end
return array_new.join( " ")
end
| true |
8c1088de992ee07c3f602a907d073e121dd0145e | Ruby | cspriggs220/NSS-Cal | /cal.rb | UTF-8 | 995 | 3.375 | 3 | [] | no_license | require './cal_integration'
require './cal_year'
# month = ARGV[0].to_i
# year = ARGV[1].to_i
# cal = CalMonth.new(month, year)
# cal_year = CalYear.new(ARGV[0].to_i)
# if ARGV[1].nil?
# puts cal_year.format_year
# else
# puts cal.format_calendar
# # else ARGV[0].nil? && ARGV[1].nil?
# # puts current month
# ... | true |
8763e33fc91fd5bc3a872344ad244d3aa1350b10 | Ruby | evansinho/Algorithms-DataStructures | /slidding_maximum.rb | UTF-8 | 145 | 3.09375 | 3 | [] | no_license | def sliding_maximum(k, array)
i = 0
arr = []
while i <= array.length - k
arr.push(array[i..i + (k - 1)].max)
i += 1
end
arr
end | true |
dd99683202aa2e5c58362516e2cdcc68a17520be | Ruby | guidance-guarantee-programme/pension_guidance | /spec/lib/income_tax_calculator_spec.rb | UTF-8 | 4,033 | 2.578125 | 3 | [
"MIT"
] | permissive | RSpec.describe IncomeTaxCalculator do
describe '.personal_allowance_for' do
subject(:personal_allowance) { described_class.personal_allowance_for(income: income) }
let(:income) { 0 }
context 'when £100,000 and below total income' do
let(:income) { 100_000 }
it { is_expected.to eq(12_570) }
... | true |
17f6c695b9703487e9d94a894f98a52b09c8172b | Ruby | ongaeshi/milkode | /lib/milkode/cdstk/milkode_yaml.rb | UTF-8 | 2,617 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
#
# @file
# @brief
# @author ongaeshi
# @date 2012/02/21
require 'yaml'
require 'milkode/cdstk/package'
require 'milkode/common/util'
module Milkode
class MilkodeYaml
MILKODE_YAML_VERSION = '0.2'
EMPTY_YAML = <<EOF
---
version: '#{MILKODE_YAML_VERSION}'
contents: []
EOF
attr... | true |
0888fba6710ee1828a44518f5b25f4ef47676b03 | Ruby | whitneysteve/code-samples | /101/ruby/test/hash_table.rb | UTF-8 | 1,267 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../hash_table'
require 'minitest/autorun'
class HashTableTest < Minitest::Test
KEY1 = 'KEY1'
KEY2 = 'KEY2'
VALUE1 = 'VALUE1'
VALUE2 = 'VALUE2'
def test_it_should_add_elements
hash = HashTable.new(10)
hash.put(KEY1, VALUE1)
hash.put(KEY2, VALUE2)
... | true |
7636cf71726bf97d729b9c4312cf2ed5f13b3317 | Ruby | eriq-augustine/augustine-nips17 | /scripts/parse.rb | UTF-8 | 6,998 | 2.8125 | 3 | [] | no_license | # General file parsing utilities specific to PSL and Tuffy.
module Parse
EVAL_OUTPUT_FILENAME = 'out-eval.txt'
NUM_REGEX = '-?\d+(?:\.\d+)?'
MAE = 'mae'
MSE = 'mse'
ACCURACY = 'accuracy'
ERROR = 'error'
POSITIVE_CLASS_PRECISION = 'positiveClassPrecision'
POSITIVE_CLASS_RECALL = 'positiveClass... | true |
e5e738a75b47550f0f4570bc75f655e6949b4687 | Ruby | quintel/etengine | /app/helpers/button_helper.rb | UTF-8 | 1,305 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # frozen_string_literal: true
# Provides a helper method for creating CSS classes for buttons and button-like elements.
module ButtonHelper
BASE_CLASSES = %w[button].freeze
COLORS = {
gray: %w[button-gray],
primary: %w[button-primary],
success: %w[button-success],
warning: %w[button-warning],
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.