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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e9d7b20a1eb9b833019406c01f19d4ecdbfc5dfc | Ruby | begin-again/code-puzzles | /Ruby/even-or-odd.rb | UTF-8 | 172 | 3.03125 | 3 | [
"Unlicense"
] | permissive | # Even Numbers
myfile = ARGV[0]
if File.exists?(myfile)
File.open(myfile) do |file|
file.each_line do |line|
puts line.to_i % 2 == 0 ? 1 : 0
end
end
end
| true |
5c1c0d9eae8fabb7c34430c51b84556e03ca23c9 | Ruby | phuzisham/parcel_calc | /lib/parcel.rb | UTF-8 | 767 | 3.171875 | 3 | [
"MIT"
] | permissive | class Parcel
def initialize(length,width,depth)
@length = length.to_i
@width = width.to_i
@depth = depth.to_i
# @weight = weight.to_i
end
def volume
volume = @length * @width * @depth
return volume
end
def cost_to_ship(distance,speed)
distance = distance.to_i
cost = volume/3... | true |
df3e8fbc6b8bef631ab1878206ba63034d5178f0 | Ruby | yhara/unbabel | /ruby/spec/spec_java.rb | UTF-8 | 454 | 2.65625 | 3 | [] | no_license | $LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
require 'unbabel'
describe "Unbabel" do
it "should call Java function" do
fib = Unbabel::Java.new((<<-EOD).unindent)
// fib :: Int -> Int
public static int fib (int x) {
switch(x){
case 0: return 0;
case 1... | true |
b4bf09ae8f2728569d54e372e4028aa6c6e4052e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/db31706d287242699db2b551a93fcccc.rb | UTF-8 | 427 | 3.46875 | 3 | [] | no_license | require 'prime'
class Raindrops
def self.convert(drop)
Raindrop.new(drop).make_noise()
end
end
class Raindrop
NOISES = {3 => "Pling",
5 => "Plang",
7 => "Plong"}
def initialize(drop)
@drop = drop
end
def make_noise
noise = ""
Prime.each(@drop) do |prime|
... | true |
cab0d063fa2454be3c378efa08450d4f4b9037f0 | Ruby | jimherz/devise_security_extension | /lib/devise_security_extension/models/secure_validatable.rb | UTF-8 | 2,661 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Devise
module Models
# SecureValidatable creates better validations with more validation for security
#
# == Options
#
# SecureValidatable adds the following options to devise_for:
#
# * +email_regexp+: the regular expression used to validate e-mails;
# * +password_length+: ... | true |
caec3c5551f5e1bcc194b7c6f62bd87701e53b61 | Ruby | perspectivezoom/urlshorten | /app/models/url.rb | UTF-8 | 478 | 2.578125 | 3 | [] | no_license | class Url < ActiveRecord::Base
attr_accessible :long_url, :short_id
has_many :clicks
before_save :prep_fields_for_save
def prep_fields_for_save
add_http
generate_short_id
end
def add_http
self.long_url = 'http://' + self.long_url unless self.long_url.start_with?('http')
end
def generate_shor... | true |
7a86eed05a8ddcaf665d8230da34367a4846c397 | Ruby | kutikina/LaunchSchool-Prep | /more_stuff.rb | UTF-8 | 1,245 | 4.40625 | 4 | [] | no_license | #Intro to Programming
#More Stuff
#Excercise 1
#Write a program that checks a series of stings for the letter 'lab'. If it does exist, print out the word.
puts "Excercise 1"
"laboratory" - "experiment" - "Pans Labyrinth" - "elaborate" - "polar bear"
def has_lab?(string)
if /lab/ =~ string
puts string
end
end... | true |
7794e2ba69fa10e41279fb74e54e457ea20a7cf8 | Ruby | dweverson/learn-ruby | /letter-to-alphabet-position.rb | UTF-8 | 280 | 3.171875 | 3 | [] | no_license | def alphabet_position(text)
alpha_array = ("a".."z").to_a
a_hash = {}
end_array = []
text = text.downcase.chars
alpha_array.each_with_index { |x, index| a_hash[x] = index + 1 }
text.each {|t| end_array << a_hash[t] if t =~ /[a-z]/}
return end_array.join(" ")
end
| true |
5162c46ce043e91325c1be6298d31546b80b596f | Ruby | Lili-Mae/programming-univbasics-3-build-a-calculator-lab-london-web-120919 | /lib/math.rb | UTF-8 | 444 | 3.8125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def addition(num1, num2)
sum = num1 + num2
puts sum
end
def subtraction(num1, num2)
sum = num1 - num2
puts sum
end
def division(num1, num2)
sum = num1 / num2
puts sum
end
def multiplication(num1, num2)
sum = num1 * num2
puts sum
end
def modulo(num1, num2)
sum = num1 % num2
puts sum
end
def square_root(num)
num =... | true |
8de701152e25ac6b3d073b560f7cf841e293e480 | Ruby | aswinsanakan/taskbox | /app/models/project.rb | UTF-8 | 1,809 | 2.6875 | 3 | [] | no_license | class Project < ActiveRecord::Base
has_many :tasks
has_many :project_categories
has_many :categories, through: :project_categories
belongs_to :client
belongs_to :user
validates :name, presence: true
# when arguments are passed for a method we use : before, and for options for the method we pass : after, the v... | true |
f90b4b7cadfffba3ff77fb99f351bc6e7d8c414c | Ruby | nettan20/trellis | /lib/trellis/utils.rb | UTF-8 | 8,107 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#--
# Copyright &169;2001-2008 Integrallis Software, LLC.
# All Rights Reserved.
#
# 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
# wit... | true |
5b29e9d9bcfb7cfd10cc9bfb70eed1f75739dea1 | Ruby | vincentericsson/SevenLanguages | /ruby/day2/print_array.rb | UTF-8 | 171 | 3.984375 | 4 | [] | no_license | a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
# Using each
(0..3).each{|i| puts "#{a[(4*i)..(4*i+3)]}"}
# Using each_slice
a.each_slice(4){|x| puts "#{x}"} | true |
15d9300d66e8c82a0fdac82a8942e40a24bd0455 | Ruby | mikesnchz/learning-ruby | /greeter.rb | UTF-8 | 343 | 3.96875 | 4 | [] | no_license | def greeter(name)
return "Hello, #{name}!"
end
def by_three?(x)
return x % 3 == 0
end
puts "Enter name:"
my_name = gets.chomp
output = greeter(my_name)
puts output
puts "Enter #:"
num = gets.chomp
output = by_three?(num.to_i)
puts output
<<<<<<< HEAD
end
=======
>>>>>>> 43ea0ee609d5c719de... | true |
33f39ce92392918b75899eeebbb6337d00195a37 | Ruby | Karibinn/karibinnV2 | /spec/system/booking_spec.rb | UTF-8 | 4,901 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require 'rails_helper'
# TODO: last sprint change. We're not booking, we're only asking for quotations.
# Sorry.
RSpec.describe 'Booking a trip' do
let!(:product1) do
create(:product,
:with_image,
title_en: 'Beautiful Villa',
specific: create(:prope... | true |
c0813f005a95d9f345a5a9033092c97852ecbce3 | Ruby | threez/rack-rpc | /lib/rack/rpc/endpoint/xmlrpc.rb | UTF-8 | 3,962 | 2.546875 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | require 'xmlrpc/server' unless defined?(XMLRPC::BasicServer)
require 'builder' # @see http://rubygems.org/gems/builder
# Monkey patch the xml writer for problems with double arrays
# Problem is filed as: http://jira.codehaus.org/browse/JRUBY-6670
class XMLRPC::XMLWriter::Simple
alias_method :unsave_element, :e... | true |
747737325090e23c63cbfbe9f27563de9926a64b | Ruby | nsikanikpoh/ruby_dev | /word.rb | UTF-8 | 120 | 2.8125 | 3 | [] | no_license | def valid_word?(word, characters)
word.chars.all? { |c| characters.delete_at(characters.index(c)) rescue nil }
end
| true |
335b22bbd7fbfe1633a76a863aad18c2b64c40d2 | Ruby | Gamoundo/ruby-oo-self-count-sentences-lab-nyc04-seng-ft-041920 | /lib/count_sentences.rb | UTF-8 | 365 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
if self.end_with?(".")
true
else
false
end
end
def question?
if self.end_with?("?")
true
else
false
end
end
def exclamation?
if self.end_with?("!")
true
else
false
end
end
def count_sentences
self.split(/[.?!]/).rejec... | true |
93519a19fa0a46d2fc116c1a22eea8ea8ebd960a | Ruby | bmnick/bbq | /app/helpers/tag_cloud_helper.rb | UTF-8 | 802 | 2.953125 | 3 | [] | no_license | module TagCloudHelper
def tag_cloud_for collection, sort_method, display_property
sorted = collection.sort_by(&sort_method).reverse
scores = score_array sorted
collection.map do |tag|
tag_output_for(tag, scores[tag.id], display_property)
end.join(" ")
end
def tag_output_for t... | true |
7a92e8840a1dee534df167c4f9724f162d9fd313 | Ruby | FelipeLozano/Teste_Livro_casa_codigo_Ruby | /TesteEncapsulamentoCapitulo9/lib/fatura.rb | UTF-8 | 307 | 3.078125 | 3 | [] | no_license | class Fatura
attr_reader :pagamentos , :valor
def initialize(cliente , valor)
@pagamentos=[]
@valor=valor
end
def adiciona_pagamento pagamento
@pagamentos << pagamento
valor_total = @pagamentos.map(&:valor).reduce(:+)
@paga=true if valor_total >= @valor
end
def paga?
@paga
end
end | true |
591ec24ec9dd3955105905ad32793ba762e3dcab | Ruby | zpalmquist/flashcards | /lib/round.rb | UTF-8 | 1,390 | 3.796875 | 4 | [] | no_license | require_relative 'deck'
require_relative 'guess'
require 'pry'
class Round
attr_reader :deck, :guesses
attr_accessor :current, :correct
def initialize(deck)
@deck = deck
@guesses = []
@current = 0
@correct = 0
end
def record_guess(response)
guess = Guess.new(current_card, re... | true |
ea7867fdc57d0237b4abba49dddebb40af85bc12 | Ruby | ejdelsztejn/sweater_weather | /app/poros/image.rb | UTF-8 | 353 | 2.671875 | 3 | [] | no_license | class Image
attr_reader :location,
:image_url,
:credit
def initialize(location, image_data)
@location = location
@image_url = image_data[:largeImageURL]
@credit = {
source: "pixabay.com",
author: image_data[:user],
logo: "https://pixabay.com/static/img/... | true |
6f45221a8080268739b49ab8a16635cbdc963c89 | Ruby | shalomchin/E_commerce-stripe | /app/models/cart.rb | UTF-8 | 1,066 | 2.703125 | 3 | [] | no_license | class Cart < ApplicationRecord
has_one :payment
has_many :line_items
has_many :products, through: :line_items
def total_price
total_price = 0
self.line_items.each do |qty|
total_price += qty.subtotal
end
total_price
end
# def update_inventory
# self.line_items.each do |item|
# ... | true |
9cf4cdcce1f4f6862c83d58b460f7abd9d6564e8 | Ruby | sinstein/rapid_share_mock_up | /app/models/attachment.rb | UTF-8 | 593 | 2.578125 | 3 | [] | no_license | class Attachment < ActiveRecord::Base
belongs_to :user
validates :name, presence: true, allow_nil: false
validate :file_format
def file_format
whitelist = ["pdf","png","jpg","jpeg","rb","txt","azw"]
if(!self.name.nil?)
ext = self.name.split('.')[-1]
end
if !whitelist.include? ext
e... | true |
a5fd25d4cf79546daedb4008d67dc0b249beaa19 | Ruby | Stephdajon/ruby_activity | /lesson_1/liskov.rb | UTF-8 | 832 | 3.28125 | 3 | [] | no_license | #liskov
class Liskov
def initialize(salary, num_of_days, number_of_hired, commission, deduction)
@salary = salary
@num_of_days = num_of_days
@commission = commission
@number_of_hired = number_of_hired
@deduction = deduction
end
def monthly_income
total_salary + total_commission
end
... | true |
e7c7a617aa3343a575edbde9fba8948fba72a782 | Ruby | gengogo5/atcoder | /typical90/t013.rb | UTF-8 | 4,541 | 3.390625 | 3 | [] | no_license | def array(n,ini=nil); Array.new(n) { ini } end
class PriorityQueue
attr_reader :heap
def initialize
# ヒープ配列
@heap = []
# 小さい順に優先度が高い
# [ノード番号,暫定距離]のペアで格納される
@comp = -> (x,y) { x[1] < y[1] }
end
def <<(new_one)
# 新規アイテムを末尾に入れる
@heap << new_one
# 末尾から上っていく
cur = @heap.s... | true |
9459ceb6bb4e7dbb6585e3abd963356728ebeb9b | Ruby | masakisanto/ecuacovid | /lib/ecuacovid/cargar_positivas.rb | UTF-8 | 918 | 2.796875 | 3 | [
"WTFPL"
] | permissive | require "ecuacovid/cliente"
require "ecuacovid/data"
module Ecuacovid
class CargarPositivas
attr_reader :datos
def initialize(options={})
@vista = options[:vista]
@cliente = options[:cliente] || Ecuacovid::Cliente.new
@datos = []
end
def grabar(registro)
(@datos ||= [])... | true |
282bae593820a5905a8c15b1f68d27ba057b566d | Ruby | noamdeul/redmine-issues | /get_issues.rb | UTF-8 | 1,961 | 2.90625 | 3 | [] | no_license | require 'httparty'
require 'json'
@config = JSON.load(File.read('config.json'))
def get_issues(project_id, type, key)
query = project_id ? { project_id: project_id } : {}
headers = {
'X-Redmine-API-Key' => @config['redmine_api_key']
}
response = HTTParty.get(
"http://#{@config['redmine_url']}/#{type}... | true |
a49943c3a816ed955ea38d2498a2e3fa2b97a5f1 | Ruby | JocelynDev/trainruby | /exo_methode.rb | UTF-8 | 330 | 3.5625 | 4 | [] | no_license | def convert_to_min(secondes)
return secondes / 60
end
def direBonjour(prenom)
return "Bonjour #{prenom} !"
end
def salutation(nom, prefix)
puts "#{prefix} #{nom} !"
end
def reorganiser_list(*nom)
nom = nom.to_s
puts nom.sort
end
puts direBonjour("jocelyn")
salutation("jocelyn", "Coucou")
reorgan... | true |
82b3a5d0279df051b13565dcfda06beb3c324921 | Ruby | mfioravanti2/maadi-ads | /lib/custom/analyzer/StatusComparison.rb | UTF-8 | 2,008 | 2.71875 | 3 | [] | no_license | # Author : Mark Fioravanti (mfioravanti@my.fit.edu)
# Florida Institute of Technology
# Course : CSE5400 Special Topics - High Volume Automated Testing
# Date : 01/18/2013
# File : comparison.rb
#
# Summary: This is a Comparison Analyzer which compares the results from
# multiple applications and ... | true |
46797a54da0c3b20b88ec6643ea00f0bdad31355 | Ruby | handofthecode/ruby-sinatra | /ruby_foundations/weekly_challenges/word_count.rb | UTF-8 | 257 | 3.5625 | 4 | [] | no_license | class Phrase
def initialize(words)
@words = words.downcase.gsub(/((\s'|'\s)|[^\w'\d]+)/, ' ').squeeze(" ").split
end
def word_count
result = {}
@words.each { |w| result.include?(w) ? result[w] += 1 : result[w] = 1 }
result
end
end | true |
ebe3cedc5f5c06521a424c9abfc697294a187bf8 | Ruby | eddieleeper/tableschema-rb | /lib/tableschema/constraints/pattern.rb | UTF-8 | 564 | 2.53125 | 3 | [
"MIT"
] | permissive | module TableSchema
class Constraints
module Pattern
def check_pattern
constraint = lambda { |value| value.match(/#{@constraints[:pattern]}/) }
if @field.type == 'yearmonth'
valid = constraint.call(Date.new(@value[:year], @value[:month]).strftime('%Y-%m'))
else
va... | true |
b7dd93d8f239c2f7905422eaee74ac3ecd75d2ee | Ruby | abarnes26/museo | /lib/curator.rb | UTF-8 | 503 | 3.234375 | 3 | [] | no_license |
class Curator
attr_reader :artists,
:museums,
:photographs
def initialize
@artists = []
@museums = []
@photographs = []
end
def add_museum(info)
@museums << Museum.new(info)
end
def add_artist(info)
@artists << Artist.new(info)
end
def add_ph... | true |
92cc27e8c98273667c2b6a5dbd4ef165c212c7b0 | Ruby | tauqeer-ahmad92/test_solution | /app/services/log_file_service.rb | UTF-8 | 1,795 | 3.078125 | 3 | [] | no_license | require 'open-uri'
class LogFileService
def process_log_file(file_url)
response = {}
open(file_url, 'r').each do |line|
_, timestamp, exception = line.split(' ')
time_value = Time.zone.strptime(timestamp.to_s, '%Q')
time_range = create_range(time_value.hour, time_value.min)
response... | true |
9c421afc560c6cce1503e23d67d7613908b0480c | Ruby | trollric/ruby_training | /lines.rb | UTF-8 | 265 | 3.71875 | 4 | [] | no_license | puts "you're Swell"
puts "you're \"Swell\""
myString = "...You can say that again..."
puts myString
puts myString
puts "Hello there, what's your name?"
name = gets.chomp
puts "Your name is #{name}? What a lovely name!"
puts "I am please to meet you, #{name}. :)"
| true |
fedf72fad1ad0c0479da963c10f97170977aa883 | Ruby | gizele22/Week-2-Challenge | /studentdirectory2.rb | UTF-8 | 1,118 | 3.25 | 3 | [] | no_license | old_sync = $stdout.sync
$stdout.sync = true
#require './lib/sudentdirectory.rb'
#Student Directory - Friday Challenge Week 2
#List of students enrollment
#List of input students details(name,gender,age)
puts "Student Directory"
puts "Press Enter To Begin Listing"
intro = gets.chomp
puts "Student Name"
nam... | true |
604848489c11312848e60aacd3db7a7df27ed778 | Ruby | pirainogi/ruby-oo-guided-youtube-exercise | /lib/youtube.rb | UTF-8 | 747 | 2.875 | 3 | [] | no_license | module Youtube
class Adapter
attr_accessor :results
attr_reader :keyword
def initialize(keyword)
@keyword = keyword
end
def get_videos_from_youtube
self.results = HTTParty.get(api_url)["items"]
create_videos
end
private
def create_videos
results.map do |vid... | true |
49db4a31bda6a31a7b6c1da32e6ad4bf2ddf2764 | Ruby | marloncarvalho/codility | /nesting.rb | UTF-8 | 305 | 3.40625 | 3 | [] | no_license | def solution(s)
return 1 if s.length == 0
return 0 if s.length.odd?
return 0 if s[0].eql? ')'
return 0 if s[s.length - 1].eql? '('
return 0 if s.count('(') != s.count(')')
return 1
end
#puts solution('()')
#puts solution('(')
#puts solution(')(')
#puts solution('')
puts solution('())()(()')
| true |
32a69fdf02d5388596292704b935a2747e5e0954 | Ruby | smoline/enumerable_testing | /enumerable_test.rb | UTF-8 | 5,629 | 3.328125 | 3 | [] | no_license | require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'lib/de_enumerable'
require_relative 'lib/book'
require_relative 'your_code_here'
describe "Enumerable" do
before(:all) do
@war_and_peace = Book.new("War and Peace", 1869, "Leo Tolstoy", 1225)
@h2g2 = Book.... | true |
33681ed9e6589fadb67541e43716c28241eb587d | Ruby | nptravis/oxford-comma-v-000 | /lib/oxford_comma.rb | UTF-8 | 388 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if (array.size < 3)
array.join(" and ")
else
[array[0..-2].join(", "), ", and ", array[-1]].join
end
end
# def join_all(join_with = ", ", connector = "and", last_comma = false)
# return self.to_s if self.empty? || self.size==1
# connector = join_with+connector if last_comma
# ... | true |
f36eb6a931eed11244f4fe26cd80fdd06870ee02 | Ruby | RayMPerry/kitchen-sink | /ruby/anagram_checker.rb | UTF-8 | 238 | 3.96875 | 4 | [] | no_license | print "Enter the first word: "
word1 = gets.chomp
print "Enter the second word: "
word2 = gets.chomp
is_anagram = word1.chars.sort == word2.chars.sort
puts "#{word1.upcase} and #{word2.upcase} are #{is_anagram ? '' : 'NOT '}anagrams."
| true |
259f094aa2d60ad29da3f4a196df7f2b549ec8c2 | Ruby | pguharay/ruby-repo | /countingsort.rb | UTF-8 | 670 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby -wKU
require_relative 'sort_util'
def countingsort(array)
countArray = Array.new(9,0);
sortedArray = Array.new(array.size, 0)
(0 .. array.size-1).each{|i|
countArray[array[i].to_i] = (countArray[array[i].to_i]).to_i + 1
}
(0 .. 8).each{|i|
countArray[i+1] = Integer(countArray[i+1]) + I... | true |
55219a3519042e4c8ba6f5d31e31e8d0b7c0ce7a | Ruby | jomi-se/aoc | /2017/spec/day3/part_2_spec.rb | UTF-8 | 869 | 2.921875 | 3 | [] | no_license | require "spec_helper"
require_relative "../../day3/part_2.rb"
describe "Day 3" do
let(:solver) { Day3::Part2 }
describe "puzzle" do
it "1st solution" do
expect(solver.run(1)).to eq(1)
end
it "2nd solution" do
expect(solver.run(2)).to eq(1)
end
it "3rd solution" do
expect(s... | true |
2a9ead386b5c3ae7d29c303b924f862be7a4466e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/b58fbee204f54e01908e5094ff7ac7df.rb | UTF-8 | 429 | 3.15625 | 3 | [] | no_license | class Complement
DNA_NUCLEOTIDES = "ACGT"
RNA_NUCLEOTIDES = "UGCA"
def self.of_dna(seq)
raise ArgumentError.new("Uracil (U) can't be found in DNA") if seq.match "U"
seq.tr(DNA_NUCLEOTIDES, RNA_NUCLEOTIDES)
end
def self.of_rna(seq)
raise ArgumentError.new("Thymine ... | true |
000b16de8316b2fb78eb61014a0976a5c03a7528 | Ruby | igorsimdyanov/ruby | /mixins/prepend.rb | UTF-8 | 400 | 3.46875 | 3 | [] | no_license | class Greet
def say(name)
"Greet#say: Hello, #{name}!"
end
end
module Greetable
def say(name)
"Greetable#say: Hello, #{name}!"
end
end
class Hello < Greet
prepend Greetable
def say(name)
"Hello#say: Hello, #{name}!"
end
end
hello = Hello.new
puts hello.say('Ruby') # Greetable#say: Hello, R... | true |
0c1b24bf7510e9edbf845f11763786756c6fe430 | Ruby | cristgl/Object-Oriented-Programming-and-Design | /Napakalaki-Ruby/lib/treasure_kind.rb | UTF-8 | 634 | 2.625 | 3 | [] | no_license | #encoding: utf-8
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module NapakalakiGame
module TreasureKind
ARMOR=:armor
HELMET=:helmet
ONEHAND=:onehand
BOTHHANDS=:bothhands... | true |
d8d6022417689d5f6a097491a07eb78dba45fa4f | Ruby | RyanSpittler/lrthw_exercises | /chapter_six/ex6.rb | UTF-8 | 1,095 | 4.5 | 4 | [] | no_license | # This assigns the Fixnum 10 to types of people.
types_of_people = 10
# This assigns a string with interpolation to x.
x = "There are #{types_of_people} types of people."
# This assigns the string "binary" to a variable of the same name.
binary = 'binary'
# This assigns the string "don't" to a variable.
do_not = "don't... | true |
b2dd70a5821491f32cd4c6ce5850884a260250c6 | Ruby | gchan/advent-of-code-ruby | /2020/day-13/day-13-part-2.rb | UTF-8 | 1,126 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
file_path = File.expand_path('day-13-input.txt', __dir__)
input = File.read(file_path)
buses = input.split("\n").last.split(?,)
ids = buses
.map.with_index { |id, idx| [id.to_i, idx] }
.reject { |id, _| id.zero? }
.sort.reverse
id, idx = ids.first
# Solve for the first bus, and time s... | true |
1f94888018c68ed5916f2cdff3d7a6d860b83bfb | Ruby | jkeiser/pathblazer | /lib/pathblazer/path_set/charset.rb | UTF-8 | 4,117 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | module Pathblazer
class PathSet
class Charset
# Ranges must be sorted and not intersecting.
def initialize(*ranges)
@ranges = Charset.init_ranges(ranges)
end
attr_reader :ranges
UNICODE_MAX = 0x10FFFF
UNICODE_MAX_CHAR = "\u10FFFF"
def ==(other)
other.is... | true |
691063132446b7c85290d8ae30c44c1db739c84b | Ruby | carolineartz/pairing_scheduler | /spec/services/project_sprint_pairing_scheduler_spec.rb | UTF-8 | 5,599 | 2.6875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe ProjectSprintPairingScheduler do
describe "#schedule!" do
let(:project) {
FactoryBot.create(
:project,
:with_sprints,
:with_engineers,
sprint_count: sprint_count,
engineer_count: engineer_count
)
}
let(:scheduler) ... | true |
314a7009dd31bb3efcaf1dc71441d82bfb2e0c66 | Ruby | pazguille/getting-started-with-ruby | /methods.rb | UTF-8 | 531 | 4.25 | 4 | [] | no_license | def friend(name)
puts "My friend is " + name + "."
end
def friend2(name)
puts "My friend is #{name}."
end
def add(a, b)
return a + b
end
# Splat arguments: "Hey Ruby, I don't know how many arguments there are about to be, but it could be more than one."
def what_up(greeting, *bros)
bros.each { |bro| puts "... | true |
5f2095d22dd9f46e73786dd839f02de1741d0e60 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/1506.rb | UTF-8 | 232 | 3.203125 | 3 | [] | no_license | def compute(a, b)
# Find the shorter of the strings
smallest = [a, b].min_by(&:length)
# Count the number of character-wise differences between a and b
smallest.split('').each_index.count { |i| a[i] != b[i] }
end | true |
b1b9718940ae014818b338596de49b74a8473997 | Ruby | beca-g/Process-Workshops | /LeapYear/spec/leapyear_spec.rb | UTF-8 | 539 | 2.6875 | 3 | [] | no_license | require './lib/leapyear'
describe '#leapyear' do
it 'checks if the year is divisable by 400' do
expect(leap_year?(2000)).to be true
end
it 'year is not divisable by 400 return false' do
expect(leap_year?(1970)).to be false
end
it 'checks if the year is divisable by 400' do
expect(leap_year?(190... | true |
d0e0911a8a5ee3d1b808e14ab79e40ac6b6de16a | Ruby | jennie-quinton/maths_problems | /src/ruby/travelling-salesman.rb | UTF-8 | 2,674 | 3.625 | 4 | [] | no_license | class TravellingSalesman
def initialize(nodes, startMatrix)
@nodes = nodes
@startMatrix = startMatrix
@shortestPath = []
@shortestDistance
@order = []
@matrix = createStartMatrix
@distance = 0
end
##
# shortest path function
# need to fix matr... | true |
eb2215942367ce4a682d52ff084ed91e89ae3e04 | Ruby | lafwind/My_LeetCode | /lib/two_sum.rb | UTF-8 | 197 | 3.25 | 3 | [] | no_license | def two_sum(numbers, target)
numbers.each_index do |i|
t = target-numbers[i]
if numbers.include?(t) && i != numbers.index(t)
return [i+1, numbers.index(t)+1].sort
end
end
end
| true |
a6b5a4e20996b47eebbb7a9a023b41be6c299ba6 | Ruby | RomanADavis/euler-solutions | /Ruby/euler3.rb | UTF-8 | 1,779 | 3.8125 | 4 | [] | no_license | arb = 600851475143
def prime? num
(2..Math.sqrt(num)).each do |j|
return false if num % j == 0
end
return true
end
largest = 1
(1...Math.sqrt(arb)).each do |i|
largest = i if prime? i if arb % i == 0
end
puts largest
# Does the same thing as prime? except recursively
def prime_rec? candidate, top=... | true |
a1c15f2ed13c081a3c7c0e75d941a9562803792c | Ruby | Istanful/safettp | /spec/safettp/guard_spec.rb | UTF-8 | 2,909 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe Safettp::Guard do
describe '#evaluate!' do
context 'when the guard is not safe' do
it 'raises an error' do
guard = described_class.new(stubbed_response)
allow(guard).to receive(:safe?).and_return(false)
evaluation = -> { guard.evaluate! }
... | true |
ca8f7322a2b5efa199ff769e3f1a237183c9c95c | Ruby | robzenn92/LUS | /sequence labeling/fst/fsa_generator.rb | UTF-8 | 752 | 2.75 | 3 | [] | no_license | @tag_count = "tag.count";
@token_tag_count = "token-tag.count";
@output_path = "out.txt";
@tags = [];
def count(lookup)
f = File.open(@tag_count, "r");
f.each_line do |line|
c, tag_found = line.split(' ')
@tags << tag_found
return ("%.2f" % c).to_f if(tag_found == lookup)
end
f.close
end
def read_token_tag_... | true |
4198a98e67ddd4f03f2108df7a6a9b3eaaf22a22 | Ruby | takkkun/multilang | /lib/multilang/slot.rb | UTF-8 | 1,978 | 3.21875 | 3 | [
"MIT"
] | permissive | require 'multilang/language_names'
module Multilang
class Slot
def initialize
@items = {}
end
# Register the object to the slot.
#
# @param [String, Symbol] language_spec the language specifier
# @param [Object] object object to register
# @yield called once at getting the object f... | true |
3e5911290202a2e2a39286b1e68a85a5c8b693f2 | Ruby | tellingeric/GlobalFlush | /app/controllers/bathrooms_controller.rb | UTF-8 | 2,986 | 2.5625 | 3 | [] | no_license | # Bathrooms Controller
# It controls all the pages are related to all the CRUD page for bathrooms
# log in is required for CUD, displaying is not required log in
class BathroomsController < ApplicationController
before_filter :require_user, :only => [:new, :create, :update, :edit, :destroy]
before_filter :is_admin,... | true |
2d95eeb7e3f2d81be5a7312d2072796d8778a320 | Ruby | PopulateTools/gobierto-etl-utils | /lib/file_uploader_service/local.rb | UTF-8 | 1,154 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
module FileUploaderService
class Local
FILE_PATH_PREFIX = "/tmp/"
attr_reader :file, :file_name
def initialize(file:, file_name:)
@file = file
@file_name = file_name
end
def call
upload || file_uri
end
def upload
upload! if !upload... | true |
cce663b40a87cc77e090ebbb293f1f31cc4c8d7d | Ruby | Justme0/leetcode | /019-remove-nth-node-from-end-of-list.rb | UTF-8 | 454 | 3.8125 | 4 | [] | no_license | class ListNode
attr_accessor :val, :next
def initialize(val)
@val = val
@next = nil
end
def delete_at(index)
fail unless index >= 1
p = self
(index - 1).times do
p = p.next
end
p.next = p.next.next
end
def size
size = 1
p = @next
while !p.nil?
p = p.next
size += 1
end
size
end... | true |
b5bf61e1f9437a4df6ae061910182cd42fd7e756 | Ruby | realbite/fuzzy_date | /features/support/fuzzy_steps.rb | UTF-8 | 976 | 2.578125 | 3 | [
"MIT"
] | permissive | Then(/^parse the following dates :$/) do |table|
table.hashes.each do |h|
f = FuzzyDate.parse(h["date"])
f.year.should eql( to_int(h["year"])) , "Invalid Year=#{f.year}!"
f.month.should eql( to_int(h["month"])) , "Invalid Month=#{f.month}!"
f.day.should eql( to_int(h["day"])) , "Invalid Day=#{f.da... | true |
bddfca61a7f99b357426ce48b0b6212f092a989d | Ruby | amatsukixgithub/atcoder | /ABC/ABC156/D.rb | UTF-8 | 264 | 3 | 3 | [] | no_license | # xCy
def c(x,y)
a=1
y.times do |i|
a*=x-i
end
b=1
y.times do |j|
b*=j+1
end
a/b
end
N,A,B=gets.chomp.split.map(&:to_i)
a=0
b=0
ans=[]
N.times do |n|
n+=1
ans.push(c(N,n))
end
ans[A-1]=0
ans[B-1]=0
puts ans.inject(:+) % (1000000000+7)
| true |
87117f87b1f77a0514293122ac1df44bb9af1a38 | Ruby | khris22/js-rails-as-api-custom-json-rendering-using-rails-online-web-pt-061019 | /app/controllers/birds_controller.rb | UTF-8 | 1,217 | 3.015625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class BirdsController < ApplicationController
def index
birds = Bird.all
# render json: birds
# slice works fine for a single hash, as with bird, it won't work for an array of hashes
# we can add in the only: option directly after listing an object we want to render to JSON
# render json: ... | true |
17286c6f7d18e46d77ba83edf9d40159f66950a0 | Ruby | rhivent/ruby_code_N_book | /book-of-ruby/ch9/ensure2.rb | UTF-8 | 347 | 3.375 | 3 | [] | no_license | # The Book of Ruby - http://www.sapphiresteel.com
f = File.new( "test.txt" )
begin
for i in (1..6) do
puts("line number: #{f.lineno}")
line = f.gets.chomp
num = line.to_i
puts( "Line '#{line}' is converted to #{num}" )
puts( 100 / num )
end
rescue Exception => e
puts( e.class )
puts( e )
ensure
f.close
... | true |
fa5a4dd725dda50384d323e1eafa5f48d5a4a86b | Ruby | ktrops/C3Projects--Shipping | /spec/models/shipping_rate_spec.rb | UTF-8 | 3,667 | 2.65625 | 3 | [] | no_license | require 'rails_helper'
require 'shipping_rate'
RSpec.describe ShippingRate do
let(:location1) { ShippingLocation.new(country: 'US', state: 'CA', city: 'Beverly Hills', zip: '90210') }
let(:location2) { ShippingLocation.new(country: 'US', state: 'WA', city: 'Seattle', zip: '98101') }
let(:package) { ActiveShippin... | true |
6f26d74317dc85715ae2c30f31087c7790d599bb | Ruby | rwilt/ruby-oo-object-relationships-has-many-through-nyc01-seng-ft-042020 | /lib/meal.rb | UTF-8 | 475 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Meal
attr_accessor :waiter, :customer, :total, :tip
# has access to customers, waiters, total and tip
#adding accessores for these instances allow
#to read and edit them.
@@all = []
#class method to store
#every instance of a meal.
def initialize(waiter, customer, total, tip =0)
@waiter = waiter
@customer = cus... | true |
a8c9abd0b84779cf9b4c6189ffae9a80848bd1ef | Ruby | jenshaw86/blood-oath-relations-seattle-web-051319 | /tools/console.rb | UTF-8 | 1,558 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
doggist = Cul... | true |
08bb3afc1808c668fd02fb4df7684cd7bce7b6f7 | Ruby | rishey/schedule | /helpers.rb | UTF-8 | 642 | 3.640625 | 4 | [] | no_license | def findFriday(date)
# checks if date is friday, if not checks to find the next
# friday and returns it.
until date.friday?
date += 1
end
date
end
def parseDate(dateString)
# checks to see if the date is in valid format, then checks to see
# if it is a valid date. if so, it returns a date object
da... | true |
7c8869f910462a46aede4048914f660af471f8c2 | Ruby | rarao/GoJekAssignment_SDET | /cleartriptestframework/api/flights/RoundTripBooking_spec.rb | UTF-8 | 1,730 | 2.53125 | 3 | [] | no_license | require_relative "../../spec_helper"
require_relative "../../payloads/geflightinfo_payload"
require_relative "../../utility/httptransport"
require_relative "../../validations/getflightinfo_validator"
require_relative "../../factories/resultsfactory"
require 'json'
describe "RoundTripTestSuite", :type => :api do
befo... | true |
a655d5e0e852f99587ba9efe6ce11abb8bb70ad6 | Ruby | codeworm96/risp | /src/function.rb | UTF-8 | 927 | 3.046875 | 3 | [] | no_license | require_relative 'interpreter.rb'
require_relative 'environment.rb'
require_relative 'kont.rb'
require_relative 'state.rb'
class Function
def eval_term(term, env)
lambda do |list|
Interpreter.eval(term, env,
lambda do |res|
list + [res]
end)
end
end
def eval_arg_list(arg... | true |
e43285efeb75e1843608e338b9af78a94f99e797 | Ruby | 4rchenix/rubycoast | /classes/help.rb | UTF-8 | 173 | 2.640625 | 3 | [] | no_license | class Help
attr_accessor :name, :desc, :usage, :tag
def initialize(name, desc, usage, tag)
@name = name
@desc = desc
@usage = usage
@tag = tag
end
end
| true |
d791bb82ef728c42143d47f91486eec36e991328 | Ruby | skwiens/Solar-System | /solar_system_wave3.rb | UTF-8 | 9,075 | 4.15625 | 4 | [] | no_license | # Define the class Solar System
class SolarSystem
attr_reader :planets, :age, :planet_names
# Initialize @planets as an array of planet instances
def initialize(planets)
@planets = planets
@num_of_planets = @planets.length
@age = 4600 #in million of years
@planet_names = planet_name_array
end
... | true |
4efc7de837639f789184cc5d34fc15c94f14eea4 | Ruby | machida4/pnglitch | /lib/pnglitch/base.rb | UTF-8 | 18,021 | 2.71875 | 3 | [
"MIT"
] | permissive | module PNGlitch
# Base is the class that represents the interface for PNGlitch functions.
#
# It will be initialized through PNGlitch#open and be a mainly used instance.
#
class Base
attr_reader :width, :height, :sample_size, :is_compressed_data_modified
attr_accessor :head_data, :tail_data, :compre... | true |
0372fd74df0711ab3fc73753cd157d0a64483631 | Ruby | msavoury/ruby-playground | /procs/ex1.rb | UTF-8 | 493 | 4.28125 | 4 | [] | no_license | #!/usr/bin/ruby
#Using the Proc constructor
double = Proc.new {|y| y * 2}
puts double.call(5)
#Using the lambda keyword
add2 = lambda {|x| x + 2}
puts add2.call(11)
#Using the -> operator
subtract4 = ->(x) { x - 4}
puts subtract4.call(40)
#the & operator
def use_block(param1, &block)
puts block.class if block_... | true |
75ce8438e24696fd70eb496ec5c835d5282779de | Ruby | jasirguzman123/hackerrank_weather | /config/initializers/hash.rb | UTF-8 | 312 | 3.03125 | 3 | [] | no_license | class Hash
def recursive_compact
each_with_object({}) do |(k, v), new_hash|
if v&.class == Hash
compacted_hash = v.recursive_compact
new_hash[k] = compacted_hash if compacted_hash.present?
elsif !v&.class.nil?
new_hash[k] = v
end
new_hash
end
end
end
| true |
5666e8261a3dd996b7872f27dc2729e2ae63e0b9 | Ruby | Suremaker/consul-deployment-agent | /tools/upload_to_artifactory.rb | UTF-8 | 1,718 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'uri'
require 'digest/md5'
artifactory_base_url = 'http://view.artifacts.ttldev/artifactory/'
artifactory_user = ENV['ARTIFACTORY_USER']
artifactory_password = ENV['ARTIFACTORY_PASSWORD']
if ARGV.length < 2
puts "Usage: #{File.basename(__FILE__)} <base_url_path> <file1> [file2] [file3] ... | true |
41c42b7c2b2e843ce2e1a01a595af9fca48917ad | Ruby | TylerBrock/books | /Practical Object Oriented Design in Ruby/chapter9/ex6.rb | UTF-8 | 1,621 | 3.109375 | 3 | [] | no_license | require 'minitest/autorun'
class Trip
attr_reader :bicycles, :customers, :vehicle
# this 'mechanic' argument could be of any class
def prepare(preparers)
preparers.each {|preparer| preparer.prepare_trip(self)}
end
end
# when every preparer is a Duke
# that responds to 'prepare_trip'
class Mechanic
def ... | true |
f63aeeb768091025ea8a0634ddd5cd52eb0f185c | Ruby | feiyu2016/feedbunch | /app/jobs/subscribe_user_job.rb | UTF-8 | 7,365 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ##
# Background job to subscribe a user to a feed and, optionally, put the feed in a folder.
#
# Its perform method will be invoked from a Resque worker.
class SubscribeUserJob
@queue = :subscriptions
##
# Subscribe a user to a feed and optionally put the feed in a folder
#
# Receives as arguments:
# - id... | true |
6027219a5d813be43ea7fa108e5c6dd5429c77e8 | Ruby | NobodysNightmare/sprit | /app/models/fuel.rb | UTF-8 | 284 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
class Fuel < ApplicationRecord
validates :name, presence: true
validates :unit, presence: true
# Whether or not this application is able to pull statistics about this fuel
# from an automated meter.
def meterable?
unit == 'kWh'
end
end
| true |
4308475d5d202492d74f4f0c49aed7b08e1012ed | Ruby | dkulback/backend_mod_1_prework | /section1/ex7.rb | UTF-8 | 353 | 4.28125 | 4 | [] | no_license | # Excercise 7 Asking Questions
print "How old are you? "
age = gets.chomp
print "How tall are you? "
height = gets.chomp
print "How much do you weigh? "
weight = gets.chomp
puts "So, youre #{age} old, #{height} tall and #{weight} heavy."
p "What is your name?"
name = gets.chomp
if name == "Darren"
puts "Hello Dar... | true |
1701573a95632bb87018d4d48fc50d95917d9b3d | Ruby | felipegruoso/univem-scraper | /scraper.rb | UTF-8 | 429 | 3.03125 | 3 | [] | no_license | # encoding: utf-8
require 'mechanize'
class Scraper
URL = "http://univem.edu.br/"
def self.run
Scraper.new.run
end
def initialize
@agent = Mechanize.new
end
def run
@agent.get URL
courses = @agent.page.parser.css('.nomecurso')
courses_name = courses.map do |cou... | true |
e3b6c7fa765993560062d792392096fc187859c0 | Ruby | jgonzalezd/advent_of_code_2016 | /day_6/day_6.rb | UTF-8 | 2,241 | 3.921875 | 4 | [] | no_license | require 'byebug'
# --- Day 6: Signals and Noise ---
#
# Something is jamming your communications with Santa. Fortunately, your signal is only partially jammed, and protocol in situations like this is to switch to a simple repetition code to get the message through.
#
# In this model, the same message is sent repeatedl... | true |
fe8addec78cb0102fd756d5f94d39574f47c9bc1 | Ruby | zendesk/Hermann | /lib/hermann.rb | UTF-8 | 833 | 2.671875 | 3 | [
"MIT"
] | permissive | module Hermann
def self.jruby?
return RUBY_PLATFORM == "java"
end
# Validates that the args are non-blank strings
#
# @param [Object] key to validate
#
# @param [Object] val to validate
#
# @raises [ConfigurationErorr] if either values are empty
def self.validate_property!(key, val)
if key.t... | true |
2817e39faf1e5bdde6256ea3a21720870af0e7d9 | Ruby | aforesti/hw1 | /part5_spec.rb | UTF-8 | 310 | 2.765625 | 3 | [] | no_license | require "rspec"
require "rspec/autorun"
require "./part5"
class Foo
attr_accessor_with_history :bar
end
describe Foo do
it "should has history" do
f = Foo.new
f.bar = 3
f.bar = :wowzo
f.bar = 'boo!'
f.bar_history.should eq [nil, 3, :wowzo, 'boo!']
end
end | true |
241f3dec0e2652c530c7ab6540aa9e57de661f47 | Ruby | perrinjack/oystercard_challenge | /spec/oystercard_spec.rb | UTF-8 | 1,869 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
require 'oystercard'
describe Oystercard do
let(:entry_station) { double(:entry_station) }
let(:exit_station) { double(:exit_station) }
let(:journey) { double(:Journey) }
let(:zero_card) { Oystercard.new }
let(:new_card) { Oystercard.new(10, journey) }
it 'starts with an em... | true |
8ece4f970b0cb9c75ccc6dd28d0f576d71a1bca3 | Ruby | bootstraponline/angular_webdriver | /lib/angular_webdriver/protractor/by_repeater_inner.rb | UTF-8 | 4,264 | 2.875 | 3 | [] | no_license | module AngularWebdriver
class ByRepeaterInner
attr_reader :exact, :repeat_descriptor, :row_index, :column_binding
# Takes args and returns wrapped repeater if the first arg is a repeater
#
# @param args [Array] args to wrap
def self.wrap_repeater args
if args && args.first.is_a?(self)
... | true |
b62d20fd9c8d1842dcbc2eea3d3a29f2981cf13d | Ruby | TabathaSlatton/collections_practice-onl01-seng-ft-081720 | /collections_practice.rb | UTF-8 | 1,006 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort.reverse
end
def sort_array_char_count(array)
array.sort do |a,b|
a.length <=> b.length
end
end
def swap_elements(array)
second = array[1]
third = array[2]
array[2] = second
array[1] = third
arra... | true |
ab7d01dfc406fd80027bdc9cf6c9376848a316d3 | Ruby | Vaa3D/vaa3d_tools | /released_plugins/v3d_plugins/open_fiji/Fiji.app/plugins/Examples/Plasma_Cloud.rb | UTF-8 | 6,271 | 3.375 | 3 | [
"MIT"
] | permissive | # This is a simple script showing how to create a "plasma cloud" in
# JRuby. This is *very* slow way of implementing this, but hopefully
# it's an instructive example. See this page for more details:
#
# http://fiji.sc/wiki/index.php/JRuby_Scripting
# ---------------------------------------------------------------... | true |
a6bd80071ef08a6ee4c5f7e44383fd0da8ee4ae3 | Ruby | seccabimmons/onboarding | /week_1/2_word_count.rb | UTF-8 | 455 | 3.875 | 4 | [] | no_license | # given an array of strings, return a Hash with a key for each different string,
# with the value the number of times that string appears in the array.
# wordCount(["a", "b", "a", "c", "b"]) → {"a": 2, "b": 2, "c": 1}
# wordCount(["c", "b", "a"]) → {"a": 1, "b": 1, "c": 1}
# wordCount(["c", "c", "c", "c"]) → {"c": 4}
... | true |
88081d10fea365484874bb9a0b91ead321e50b66 | Ruby | Pi-hils/process_review | /review_2/lib/filter.rb | UTF-8 | 527 | 3.28125 | 3 | [] | no_license | class Filter
DEFAULT_LOWEST = 40
DEFAULT_HIGHEST = 1000
def music_filter(sound_wave,lowest_filter=DEFAULT_LOWEST, highest_filter= DEFAULT_HIGHEST)
new_sound_wave = []
raise "no soundwave provided" if sound_wave == []
sound_wave.each do |freq|
if freq > highest_filter
new_sound_wave <... | true |
b121175941398ff3c9e05d94f5c96b7752140fef | Ruby | apriichiu/GSCC-Web | /vendor/gems/faraday-0.4.6/test/connection_app_test.rb | UTF-8 | 1,449 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
class TestConnectionApps < Faraday::TestCase
class TestAdapter
def initialize(app)
@app = app
end
def call(env)
[200, {}, env[:test]]
end
end
class TestMiddleWare
def initialize(app)
@app = app
end
... | true |
c66eafef2d179fc6e4f989b21444490dcce22e55 | Ruby | idealprojectgroup/ey-notifier | /spec/support/deploy.rb | UTF-8 | 135 | 2.546875 | 3 | [
"MIT"
] | permissive | class Deploy
def some_method(what)
# no-op
end
def callback(what)
some_method(what)
"some return value"
end
end
| true |
ba0c97b0616a10669d930bc787eb4fc806c3d730 | Ruby | moonmaster9000/board_app | /board/lib/board/use_cases/standups/archive_standup_use_case.rb | UTF-8 | 1,059 | 2.6875 | 3 | [] | no_license | module Board
module UseCases
class ArchiveStandupUseCase
class << self
def archivers
@archivers ||= []
end
def add_archiver(lambda)
archivers << lambda
end
end
def initialize(whiteboard_id:, observer:, date:, repo_factory:)
@repo_fact... | true |
02a781de989716ac9eb9b18d0a0969fe1bdc0dc6 | Ruby | ed-karabinus/project-euler-multiples-3-5-q-000 | /lib/multiples.rb | UTF-8 | 348 | 3.484375 | 3 | [] | no_license | # Enter your procedural solution here!
def collect_multiples(limit)
multiples = Array.new
index = 1
until index == limit
if index % 3 == 0 || index % 5 == 0
multiples << index
end
index += 1
end
multiples
end
def sum_multiples(limit)
sum = 0
collect_multiples(limit).each do |index|
... | true |
22b27c3a06b229b66b99165fe52a1af546b1cbf3 | Ruby | punjabdapunk/pinvaders | /lib/pinvaders/star.rb | UTF-8 | 789 | 2.953125 | 3 | [
"MIT"
] | permissive | module Pinvaders
class Star
attr_accessor :x, :y
def initialize(args={})
@vp = args[:vp]
@brake = default_brake
@height = default_height
@x = 0
@y = 0
@brake_count = @brake
@brush = Painter.new(@vp)
end
def default_brake
1
end
def default_hei... | true |
13dd4841a93e6fc58fec676501bafc2335c1b258 | Ruby | Alefuentes982/desafios-ciclos | /fuerza_bruta.rb | UTF-8 | 458 | 3.21875 | 3 | [] | no_license | puts "Ingrese password"
contraseña = gets.chomp
def descubre_metodo(contraseña)
arreglo = contraseña.chars
intentos= 0
cadena = ""
letra = "a"
if arreglo != letra
for i in ("a"..contraseña)
cadena += letra
letra = letra.next
i = 1
for j in (1..i)
intentos += j
end
... | true |
0793e53e0a25d7a1c4f98b1bce3663b824136e18 | Ruby | choplin/fluent-plugin-statsite | /lib/fluent/plugin/statsite/metric_format.rb | UTF-8 | 852 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | module Fluent
module StatsitePlugin
# This represent a key/value format of Metric
class MetricFormat
CONSTANT_VALUE = '\w+'
SUBSTITUTE = '\$\{\w+\}'
SUBSTITUTE_REGEXP = /\$\{(\w+)\}/
ELEMENT = "(?:#{CONSTANT_VALUE}|#{SUBSTITUTE})"
PATTERN = "#{ELEMENT}+"
def initialize(str... | true |
98d3d8fc8c02a270d267b7873d20b3d24d103d8d | Ruby | KellyAH/ruby_school | /play/var_pointer_ex01.rb | UTF-8 | 495 | 3.421875 | 3 | [] | no_license | a = "cat"
p a
p a.object_id
myarray = Array.new(3, a)
p myarray
p myarray.object_id
def get_array_contents(array)
print "-" * 8
puts "array contents:"
p array
puts "array contents ids:"
array.each {|item| p item.object_id}
end
get_array_contents(myarray)
print "-" * 8
puts "before mutation of var a:"
p ... | true |
658b845e017b24549994f12a317d98d90850c9a3 | Ruby | stennity8/ttt-with-ai-project-online-web-sp-000 | /lib/players/computer.rb | UTF-8 | 2,607 | 3.390625 | 3 | [] | no_license | module Players
class Computer < Player
WIN_COMBINATIONS = [
[0, 1, 2], #Top row
[3, 4, 5], #Middle row
[6, 7, 8], #Bottom row
[0, 3, 6], #First Column
[1, 4, 7], #Second Column
[2, 5, 8], #Third Column
[0, 4, 8], #Diagonal left to right
[2, 4, 6], #Diagonal right to... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.