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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
845ccc10c34bb759ca20681a4f32c9b68ec0a87d | Ruby | codegorilla/lang2 | /BinaryExpression.rb | UTF-8 | 382 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'erb'
require_relative 'Expression'
class BinaryExpression < Expression
attr_reader :op, :left, :right
def initialize (op, left, right)
@op = op
@left = left
@right = right
end
def render ()
file = File.read("view/binary_expression.c.erb")
template = ERB.new(file, nil, trim_mode="... | true |
e420984a4014a67deb2eaa57bd9f1ff618ee9276 | Ruby | camerican/Help-Desk | /demos/isbndb/server.rb | UTF-8 | 596 | 2.75 | 3 | [] | no_license | # server.rb - Main Sinatra Application
require 'sinatra'
require 'net/http'
require 'uri'
require 'json'
get '/' do
erb :home
end
# handle search request & talk to the isbndb.com server
post '/' do
query_string = URI.encode_www_form({q: params[:q]})
data = Net::HTTP.get(URI.parse("http://isbndb.com/api/v2/json/... | true |
78be9f071f4b684eb22dd3cf51605306743660a9 | Ruby | gareth-smyth/journey_walker | /spec/journey_walker/helpers/class_builder.rb | UTF-8 | 1,108 | 2.640625 | 3 | [
"MIT"
] | permissive | # Builds SomeThing::SomeWhere::OSAdviser with some methods. May not be the best way to do this.
module ClassBuilder
def make_data_source_methods(os, install_method)
make_data_source_class
SomeThing::SomeWhere::OSAdviser.send(:define_method, 'os') { |capitalise = false| capitalise ? os.capitalize : os }
S... | true |
2904694c84253df8ec5fb2ebd747fdc1c2466c5c | Ruby | broothie/aa-projects | /W2D1/class_inheritance/class_inheritance.rb | UTF-8 | 544 | 3.609375 | 4 | [] | no_license | # class_inheritance.rb
class Employee
attr_reader :salary
def initialize(name, title, salary, boss)
@name = name
@title = title
@salary = salary
@boss = boss
end
def bonus(multiplier)
@salary * multiplier
end
end
class Manager < Employee
attr_reader :employee_list
def initialize(na... | true |
38a6bcf37668cd7f8185dc51380844bcd58336b0 | Ruby | pione/pione | /lib/rootage/exception.rb | UTF-8 | 2,680 | 2.921875 | 3 | [
"MIT",
"Ruby"
] | permissive | module Rootage
class Error < StandardError; end
class ScenarioError < Error; end
class CollectionError < Error; end
# OptionError is raised when the command option is invalid.
class OptionError < Error
def initialize(cmd, msg)
@cmd = cmd
@msg = msg
end
def message
'Option err... | true |
38e86186bb346940e23bf9bd6ddd8f4cca3769bc | Ruby | ludobesset/sofia | /figures/full.rb | UTF-8 | 626 | 2.953125 | 3 | [] | no_license | class Full < Figure
def initialize
super
@value2=0
@order=7
end
def set_value(newvalue)
if @value==0
@value=newvalue
else
if newvalue>@value
@value2=@value
@value=newvalue
else
@value2=newvalue
end
end
end
def set_value2(newvalue)
if newvalue>@value2
@v... | true |
cfa85a4d967c0c0ee12c3d63abe406383da907a6 | Ruby | panoysia/faculty-evaluation | /app/models/cce_scorer/training.rb | UTF-8 | 1,062 | 2.90625 | 3 | [] | no_license | =begin
(max 10 pts.)
check: :level and :category
=end
module CCEScorer
class Training
include CCEConstants::Training
FIVE_WORKING_DAYS = 5
def self.score(record)
# The arrays below represents the scoring table
# for the types of training (training or seminar):
#
# 1... | true |
47fc6ef3cc78a332acc826416feae179fabf0ceb | Ruby | aldavidson/graph-algorithms | /models/fifo_queue.rb | UTF-8 | 508 | 3.671875 | 4 | [
"MIT"
] | permissive | # queue.rb
#
# Minimal Queue implementation
#
class FiFoQueue
def initialize(size=0)
@items = Array.new(size)
end
def push!(*items)
@items += Array(items).flatten unless items.nil?
end
def pop!(number_of_items = 1)
popped = @items.take(number_of_items)
@items = @items[number_of_items..@items... | true |
87d5993622e18a4423bc5ecd3f7677454aea798b | Ruby | ayosec/css-sprites | /lib/css_sprites/generator.rb | UTF-8 | 4,258 | 2.515625 | 3 | [
"MIT"
] | permissive |
require 'RMagick'
module CSSSprites
module Generator
extend self
class BundleFile
cattr_accessor :file_count
self.file_count = 0
attr_accessor :file_name, :y
def initialize(mimetype)
@suffix = mimetype.gsub(/^.*\W/, '')
... | true |
bd6cd72e5081079dea9113cd665b2bccb672cc3f | Ruby | dionew1/battleship | /lib/validation.rb | UTF-8 | 4,039 | 3.015625 | 3 | [] | no_license | class Validation
def get_letters(split_coordinates)
split_coordinates.map do |coordinate|
coordinate[0]
end
end
def get_numbers(split_coordinates)
split_coordinates.map do |coordinate|
coordinate[1]
end
end
def detect_direction(split_coordinates)
letters = get_letters(split_... | true |
80c6f838d627e124c58857d3eff9fe4c0b04490f | Ruby | kevinthompson/advent-of-code | /2018/01-chronal-calibration/lib/chronal_calibrator/strategies/frequency.rb | UTF-8 | 443 | 2.703125 | 3 | [] | no_license | class ChronalCalibrator
module Strategies
class Frequency < Base
def result
i = 0
result = nil
frequency = 0
frequencies = []
while result.nil? do
frequency += values[i]
result = frequency if frequencies.include?(frequency)
i += 1
... | true |
12d1e74ae67714b995c32f4b831737971df1816d | Ruby | kenleezle/ruby-examples | /lib/choose.rb | UTF-8 | 437 | 2.984375 | 3 | [] | no_license | def count_choose(n,k)
return 1 if k == 0
return 1 if n == k
return n if k == 1
return choose(n-1,k) + choose(n-1,k-1)
end
def choose(n,k)
retval = Array.new
return [(1..n).to_a] if n == k
if k == 1 then
(1..n).each do | i | retval.push([i]) end
return retval
end
left = choose(n-1,k)
right = ... | true |
256c7b5498d8073479525ca13fa5017be9106394 | Ruby | seeflanigan/enums-exercises | /are_they_all_test.rb | UTF-8 | 2,441 | 2.953125 | 3 | [
"MIT"
] | permissive | gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
class AreTheyAllTest < Minitest::Test
# You get the first test for free... it's already passing.
def test_not_all_zeros
numbers = [0, 0, 0, 0, 1, 0, 0, 0]
all_zeros = true
numbers.each do |number|
all_zeros = false unless number.z... | true |
3dba5fa29316974bdcc7aba8720de1df1ca1e0dd | Ruby | sigielki/microstation | /spec/template_spec.rb | UTF-8 | 4,649 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'spec_helper')
require 'fileutils'
require 'digest/md5'
require 'microstation/template'
module TestHelper
def digest_for_path(file)
Digest::MD5.hexdigest(File.read(file))
end
def file_same?(p,p2)
digest_path(p) == digest_path(p2)
end
end
describe Microst... | true |
492379e9c295283b2e1c07b7f1892153135c86d5 | Ruby | getupcloud/origin-server | /common/lib/openshift-origin-common/utils/path_utils.rb | UTF-8 | 3,287 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | #--
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | true |
8f0e3635b2d0702a5a0c4f244f19a99c642eb543 | Ruby | bschrag620/anagram-detector-v-000 | /lib/anagram.rb | UTF-8 | 596 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(list_of_words)
self_dictionary = word_to_dictionary(@word)
match_list = []
list_of_words.each do | word |
if word_to_dictionary(word) == self_dictionary
match_list << word
... | true |
f5aaeb847ccf2957f02bbca9e9c773907ec67771 | Ruby | tdeo/advent_of_code | /2021/lib/15_chiton.rb | UTF-8 | 1,385 | 3.578125 | 4 | [] | no_license | # frozen_string_literal: true
require_relative '../../lib/priority_queue'
class Chiton
def initialize(input)
@input = input
@grid = @input.split("\n").map { _1.chars.map(&:to_i) }
@height = @grid.size
@width = @grid[0].size
end
def neighbours(i, j)
res = []
res << [i + 1, j] if i < @gri... | true |
814aff6f21ab1e420a0696b4aa9d7e47c74e5d55 | Ruby | wenbo/rubyg | /sample/CHAPTER05/087/regexp-start-with.rb | EUC-JP | 601 | 2.859375 | 3 | [] | no_license | errmsg = "Error: out of memory"
# \AפʸƬ̣ʸ
errmsg =~ /\AWarning/ # => nil
errmsg =~ /\AError/ # => 0
# ä˳ʸξRegexp.unionȼŸȤ߹碌ɽɬפ롣
errmsg =~ /\A#{Regexp.union("Error")}/ # => 0
# \zפʸνụ̈ʸ
errmsg =~ /memory\z/ # => 14
errmsg.match(/memory\z/) # => #... | true |
52bf6ef294743ed0c2b8b1fbf6e6f1453f61f567 | Ruby | eljago/webcinehorarios | /lib/core_ext/Array.rb | UTF-8 | 313 | 2.84375 | 3 | [] | no_license | class Array
def contains_hash_with_key_value? key, value
each do |hash|
return true if hash.has_key?(key) && hash[key] == value
end
false
end
def get_hash_with_key_value key, value
each do |hash|
return hash if hash.has_key?(key) && hash[key] == value
end
nil
end
end
| true |
413265e5e380ba334a614382bd6ab70b03ea71ad | Ruby | Loris1123/RbScheme | /lang/userspace.rb | UTF-8 | 572 | 3.0625 | 3 | [
"Beerware"
] | permissive | require_relative '../eval'
class UserspaceFunction
def initialize(name, function, parameter)
@name = name
@function = function
@parameter = parameter
@number_of_arguments = parameter.size
end
def name
@name.value
end
def parameter
@parameter
end
def function
@function
en... | true |
7b40017303c39f203142752d55b69922d411a142 | Ruby | nyamboga/MentorProgram | /app/models/introduction.rb | UTF-8 | 580 | 2.5625 | 3 | [] | no_license | class Introduction
def initialize(ask)
@ask = ask
end
def send_introduction
if @ask.type == "MentorAsk"
send_mentoring_introduction
else
send_pairing_introduction
end
end
private
def send_mentoring_introduction
NotificationMailer.introduce_mentee_to_mentor(@ask).deliver
... | true |
d2db4ea3febc91785914a291b612a66be9c81ff9 | Ruby | Ldeems/isbn_testing | /isbn_test.rb | UTF-8 | 2,466 | 2.859375 | 3 | [] | no_license | require "minitest/autorun"
require_relative "isbn_method.rb"
class Test_isbn < Minitest::Test
# def test_2_equals_2
# assert_equal(2,2)
# end
# def test_math_test_1
# assert_equal(true, math_function("0471958697"))
# end
# def test_math_test_1
# assert_equal(false, math_function("0471958691"))
# end
#... | true |
37da18acb4f578e5164f02d3c2c97bcf1deed325 | Ruby | RaphaelwHuang/Set-Game | /deck.rb | UTF-8 | 861 | 3.671875 | 4 | [] | no_license | # Author:: Sunny Patel, Kenton Steiner
# Creation Date:: 1/27
require_relative 'card'
class Deck < Card
# deck can only be read
attr_reader :deck
# Create a deck of 81 unique cards
def initialize
@deck = []
Card::NUMBERS.each do |number|
Card::SHAPES.each do |shape|
Card::SHADING... | true |
32c0d7639b53faab4ca7d6621d3a0b722089be6a | Ruby | jaredjames2020/sql-library-lab-online-web-pt-090919 | /lib/querying.rb | UTF-8 | 1,255 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"SELECT title, year FROM books WHERE series_id = 1 ORDER BY year ASC"
end
def select_name_and_motto_of_char_with_longest_motto
"SELECT name, motto FROM characters ORDER BY LENGTH(motto) DESC LIMIT 1"
end
def select_value_and_count_of_most_prolific_s... | true |
0a98a73d89e51aabacf5bb4874fc4c65e81c4fab | Ruby | moski/tweetsh | /lib/extend/twitter_oauth/user.rb | UTF-8 | 656 | 2.578125 | 3 | [
"MIT"
] | permissive | module TwitterOAuth
class Client
# Returns the 100 last friends
def friends_with_cursor(options = {})
# Equivalent to options.reverse_merge({:cursor => -1}) in rails
options = {:cursor => -1}.merge(options)
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
get("/statuses/friends.json?#{a... | true |
ab31f1654daed184a49e860bc5361f2551184399 | Ruby | jeremiahkellick/app-academy-w3d3-classwork | /URLShortener/bin/cli | UTF-8 | 984 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
begin
puts "Input your email:"
email = gets.chomp
user = User.find_by(email: email)
raise ArgumentError, "No user with that email" if user.nil?
rescue ArgumentError => e
puts e.message
retry
end
begin
puts "What do you want to do?"
puts "0. Create shortened URL"
puts "1. Visit sh... | true |
c302a651408304f323763511b89ba5bff2cc6fa7 | Ruby | John-Arboleda/HTML-linter | /lib/doc_analysis.rb | UTF-8 | 1,254 | 2.6875 | 3 | [] | no_license | require 'strscan'
require 'colorize'
module DocAnalysis
def doctype_tag?(parsed_doc)
doctype_regex = /^\s*<!DOCTYPE(\s*)(.*)(>)/
doctype_exist = parsed_doc.any? { |line| !line.check_until(doctype_regex).nil? }
return "#{'Error: '.colorize(:red)}DOCTYPE tag not found" unless doctype_exist
end
def htm... | true |
3e3c595766976f96d27e88819daddba4142fc1ca | Ruby | lukew244/boris-bikes | /spec/van_spec.rb | UTF-8 | 450 | 2.546875 | 3 | [] | no_license | require 'docking_station'
describe Van do
let(:bike) {double :bike}
it {is_expected.to respond_to :take}
it {is_expected.to respond_to :distribute}
it 'takes a bike' do
bike = Bike.new
docking_station = DockingStation.new
garage = Garage.new
bike.report
docking_station.dock(bike)
expec... | true |
082f3c72bcb0f127c4790732c835334d17009eb3 | Ruby | W3NDO/Linear-Programming | /pivot.rb | UTF-8 | 1,568 | 3.625 | 4 | [] | no_license | ### Code to pivot linear equations ###
# Definitely needs a GUI soon
#A couple steps to be followed#.
=begin
1. Get the system of equations from the user
i) Dependent variables
ii) independent variables
iii) Coefficients
2. Get the pivot point. It is a coefficient
3. Do the pivot logic
__ __ ... | true |
10335aee67a7e60524fc3c57f6214ab5310b1d96 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature686/whelper_source/17346.rb | UTF-8 | 369 | 3.234375 | 3 | [] | no_license | def combine_anagrams(words)
anagrams = Hash.new
words.each do |word|
if (word.length == 1) then
key = word.downcase
else
if key = word.downcase.chars.sort.join then
# do nothing
end
end
if anagrams.has_key?(key) then
anagrams[key].push(word)
else
anagrams[ke... | true |
368e25c72a49c425a88455668d7acefc405d093a | Ruby | tomprats/tomify-gem | /lib/tomify/constantly.rb | UTF-8 | 318 | 2.59375 | 3 | [
"MIT"
] | permissive | module Tomify
class Constantly
def initialize(methods)
methods.each do |key, value|
define_singleton_method(key) { value.constantize }
define_singleton_method("#{key}=") do |new_value|
define_singleton_method(key) { new_value.constantize }
end
end
end
end
end
| true |
031bb346006069d6cb2cddff7ad64d870d6f8b78 | Ruby | NataliaRamos/calculator | /calculator.rb | UTF-8 | 505 | 3.734375 | 4 | [] | no_license | class Calculator
attr_accessor :result
def initialize
@result = 0;
puts "Let's rock and roll"
end
def add(*arg)
if arg.class == Array
@result += arg.flatten.reduce(:+)
else
@result += arg
end
self
end
def subtract(*arg)
if arg.class == Array
@result -= arg... | true |
ca0f3cc2bdb53d790c948d2d2d625c9b478fb582 | Ruby | lovehandle/employee_scheduler | /lib/utilities.rb | UTF-8 | 179 | 2.78125 | 3 | [] | no_license | module EmployeeScheduler
module Utilities
def check_type(object , type )
raise "object needs to be of Type:: #{type.to_s}" unless object.is_a?(type)
end
end
end
| true |
c6b36ce7a48b29c202733abd88284c6166a7b0cb | Ruby | horoama/ororo_bot | /main.rb | UTF-8 | 1,158 | 2.8125 | 3 | [] | no_license | require 'twitter'
require 'json'
require 'pp'
class Ororo
def initialize
key_file=File.read("./key.json", :encoding => Encoding::UTF_8)
keys = JSON.load(key_file)
@client = Twitter::REST::Client.new do |config|
config.consumer_key = keys['key']
config.consumer_se... | true |
36586aff421aad06cc6fc346877cf6020b9725c5 | Ruby | DaveWillkomm/env_hash_config | /lib/env_hash_config.rb | UTF-8 | 693 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'env_hash_config/version'
require 'ostruct'
module EnvHashConfig
def self.create(options: ENV, array_options: [], boolean_options: [], default_options: {}, integer_options: [])
options = options.inject({}) { |h,(k,v)| h.tap { |h| h[k.downcase.to_sym] = v } }
options = array_options.inject(options) { ... | true |
3a2745e3a1686bb5f0e1c3c9859ff97eb9693d96 | Ruby | arejl/THPJ17 | /lib/player.rb | UTF-8 | 2,314 | 3.875 | 4 | [] | no_license | require "pry"
class Player
attr_accessor :name, :life_points
def initialize(given_name)
@name = given_name
@life_points = 10
end
def show_state
case
when @life_points <= 0
puts "#{@name} est KO !"
when @life_points == 1
puts "#{@name} a #{@life_points} point de vie"
else
... | true |
0d4c7c2e0fa86cb25b5b646434d1ea1cb7204764 | Ruby | Killian-Viquerat/RUBYTAN | /Classes/powerup.rb | UTF-8 | 1,070 | 2.859375 | 3 | [] | no_license | class Powerup
attr_accessor :position
def initialize(x,y)
@offset = 15
@heigth = 20
@width = 2
@position = Vector2.new(x,y)
@centercontent = @offset + @heigth/2
end
def draw
#cube
Gosu.draw_rect(@position.x+@offset,@position.y+@offset,@heigth,@... | true |
db60df65221a23021405b9ff8d772f6eb6ccec1d | Ruby | bcmhgsc/hgsc.bfast.pipe | /bin/automation_driver.rb | UTF-8 | 2,928 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Main automation framework.
#
# Author: Phillip Coleman
require 'optparse'
require 'ostruct'
require 'date'
require 'logger'
$: << File.join(File.dirname(File.dirname($0)), "lib")
require 'a_actions'
require 'helpers'
#require 'load_libs'
#
class App
VERSION = '0.0.1'
attr_reader :opt... | true |
05b3f833922792d6b57b987a6d3e84ea98133725 | Ruby | thestoneage/cloud | /lib/selector.rb | UTF-8 | 5,601 | 3.234375 | 3 | [] | no_license | require 'mutator'
class Selector
def initialize(args = {})
raise(ArgumentError) unless args.class == Hash
if args[:elite_size]
@elite_size = args[:elite_size]
raise(ArgumentError, ":elite_size must be an non negative Integer") unless (@elite_size.class == Fixnum and @elite_size >= 0)
else
... | true |
d805897c39df453e48380c8094e1d83595a3577a | Ruby | niennte/_ruby_game_refactoring | /game0c.rb | UTF-8 | 412 | 3.671875 | 4 | [] | no_license | action = nil
while true
puts "What would you like to do ('q': quit, 'p': plant, 'w': water, 'x': weed, 'r': rest)"
action = gets.chomp
case action
when 'q' then puts 'goodbye'
when 'p' then puts 'A new plant has grown.'
when 'w' then puts 'The soil is damp now, good.'
when 'x' then puts 'Got rid ... | true |
fb6d35b6d8fc6b8c0f69aa45c3292d06507c8e91 | Ruby | tiagopog/rabbitmq | /work_queue/new_task.rb | UTF-8 | 281 | 2.53125 | 3 | [] | no_license | # encoding: utf-8
require 'bunny'
conn = Bunny.new
conn.start
ch = conn.create_channel
q = ch.queue('task_queue', durable: true)
msg = ARGV.empty? ? "Hello World!" : ARGV.join(" ")
q.publish(msg, persistent: true)
puts "Queue: #{q.name}"
puts " [x] Sent '#{msg}'"
conn.close
| true |
c28d1f23f133d4226ea394f6198d449dcfedcb41 | Ruby | tdgs/MovieCollection | /lib/db_model_widget.rb | UTF-8 | 932 | 2.515625 | 3 | [] | no_license | # encoding: utf-8
require 'Qt'
class MyTextEdit < Qt::TextEdit
def initialize(parent = nil)
super(parent)
self.acceptRichText = false
end
def text
self.plainText
end
def text=(val)
self.plainText = val.to_s
end
end
module DataBaseModelWidget
attr_accessor :attributes
attr_accessor :ui
attr_ac... | true |
772603a6a1d9d7d0b7add85f4623e9ff6aa51c6d | Ruby | learn-co-students/sf-web-091619 | /02-intro-oo/account.rb | UTF-8 | 517 | 3.359375 | 3 | [] | no_license | require 'pry'
class Account
attr_reader :customer_id
attr_accessor :balance
@@all = []
def self.all
@@all
end
def initialize(customer_id, balance)
@customer_id = customer_id
@balance = balance
@@all << self
end
# def customer_id
# @customer_id... | true |
a20ed27e7bbf25c4e3c54d4e1e9de1f63a605c45 | Ruby | AlejandraValdivia/ruby-exercises-2 | /struct.rb | UTF-8 | 280 | 3.4375 | 3 | [] | no_license | Customer = Struct.new(:name, :email) do
def name_with_email
"#{name} <#{email}>"
end
end
# We can then create a new instance and iterate through the attributes:
customer = Customer.new("Sarah", "sara_rainbow@yahoo.ca")
customer.each_pair do |name, value|
puts "#{name} - #{value}"
end
| true |
e79d90fa3effce00c2e8798606034fe437be5922 | Ruby | chocoken517/chocoboty-line | /docomo.rb | UTF-8 | 960 | 2.75 | 3 | [
"MIT"
] | permissive | require 'docomoru'
class Docomo
def initialize(message)
@type = 'dialogue'
@type = 'knowledge' if message.match(/?$|\?$/)
@message = message
@client = Docomoru::Client.new(api_key: ENV['DOCOMO_API_KEY'])
@response = api
end
def api
return @client.create_dialogue(@message) if @type == 'dia... | true |
77111a25a0fa790d644461b30ba83f81e12c2946 | Ruby | NathaliaC/bank | /scripts/categorize_number/ui.rb | UTF-8 | 251 | 3.609375 | 4 | [] | no_license | def welcome
line
puts "Olá, seja bem vindo(a) a aula de números Esotéricos, Céticos e Primos!"
line
ask_number
end
def ask_number
puts "Informe um número"
answer = gets.strip
answer.to_i
end
def line(qtd=70)
puts "-" * qtd
end | true |
727c910f816359dfa294fe0e3a6efa11d565e7dc | Ruby | Pyro-tech/pyro | /lib/assets/Ruby復習問題_入門_中級/復習問題_中級編/80/82.rb | UTF-8 | 646 | 2.84375 | 3 | [
"MIT"
] | permissive | puts %{以下の空欄(a)~(c)を書き換えて、プログラムを完成させましょう。
---正解となる実行結果---
カレントディレクトリは C:/Users/tokunaga/Desktop/復習問題_中級編/80 です。
このフォルダにdat01.txtはありません。
---ここまで---}
# current_directory = Dir.(a).encode("UTF-8")
# puts "カレントディレクトリは #{current_directory} です。"
# SearchFile = "dat01.txt"
# files = Dir.(b)(SearchFile)
# if (c) == 0
# pu... | true |
85e8994d74d84ac10125b741e2e70174ae3eaacc | Ruby | melnock/oo-practice-with-melissa-and-york | /character.rb | UTF-8 | 327 | 2.96875 | 3 | [] | no_license |
class Character
attr_accessor :name, :finishing_move, :videogame, :player
@@all = []
def initialize(name, finishing_move)
@name = name
@finishing_move = finishing_move
@@all << self
end
def self.all
@@all
end
def delete_character
Character.all.delete_if{|char| char == self}
en... | true |
7372d067e6d55dfae8ee6a7f2824c37d7c49ae6b | Ruby | izzyjohnston/algo2 | /algo2/lib/graph4.rb | UTF-8 | 1,340 | 3.34375 | 3 | [] | no_license | class Graph4
attr_accessor :number_of_nodes, :raw_vertices
def initialize(filename, nodes)
self.number_of_nodes = nodes
self.raw_vertices = []
self.raw_vertices[0] = nil #hack to have 1st vertex start at one
i = 1
IO.foreach(filename) do |vertex|
vertex.slice!("\n")
vertex = ver... | true |
332eb8e659518ef85397204af7850522680fc54c | Ruby | mikewagner/project_euler_code | /0069/0069.rb | UTF-8 | 287 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'prime'
class Integer
def phi
result = self
primes = self.prime_division.map { |a| a.first }
primes.each do |prime|
result = result * (1 - (1/prime.to_f))
end
result.to_i
end
end
p (1..1000000).max_by { |i| i.to_f / i.phi }
| true |
889c029592b28932edf319ced1a0dc4397617189 | Ruby | gbarzola/programacion | /POO/S5/p2.rb | UTF-8 | 4,853 | 3.296875 | 3 | [] | no_license | # Una empresa de carga naviera requiere un programa que le permita calcular los costos de los envíos.
# Para ello existen dos categorías de envío: marítimos y ultramarítimos.
# En el caso de los envíos marítimos se consigna:
# -Código de envío
# -Razón social del cliente
# -Volumen métrico
# -Categoría de envío (pu... | true |
81bacbb0ce2260fd4b4781562db2ba939c380c08 | Ruby | DUSAEN052/badges-and-schedules-dumbo-web-career-010719 | /conference_badges.rb | UTF-8 | 570 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(arr)
output = []
arr.each do |name|
output.push(badge_maker(name))
end
return output
end
def assign_rooms(arr)
output = []
arr.each_with_index do |name, index|
output.push("Hell... | true |
9e3f04062a0a699d5190b6e55f79fc1de23bfc8b | Ruby | glsignal/ruby-wrapper | /examples/mill/mill | UTF-8 | 5,615 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'readmill'
require 'active_support/core_ext' # For to_param
OPTIONS = {
:id => 'CLIENT_ID',
:secret => 'CLIENT_SECRET',
:redirect_uri => 'REDIRECT_URI',
:endpoint => 'api.readmill.com',
:authorization_endpoint => 'readmill.com'
}
class SimpleToken
class << self
def code_ur... | true |
e1eacad6bd1be69977ce08a9f335d0a3694be03b | Ruby | hemokosa/poetry | /mind/LwtM/mind.rb | UTF-8 | 6,504 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'uri'
require 'json'
require 'date'
class MAIN
def initialize(src)
@src = src
@accum = 0
@mind = 50
@base = 50.0
@min = 10
@max = 20
@code = ""
@count = 0
@th = []
@tn = 0
@inc = 1
@com = "HhQqCcAaIiTtGgPp9Ff+-,.?<#,;!Ww _\n"
@step = 0
... | true |
718cbab3a00c295706ef5497cf44f55577c74af2 | Ruby | laurenyz/ruby-oo-relationships-practice-gym-membership-exercise-dc-web-012720 | /lib/gym.rb | UTF-8 | 461 | 3.234375 | 3 | [] | no_license | class Gym
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def memberships
Membership.all.select {|mem_obj| mem_obj.gym == self}
end
def lifters
self.memberships.map {|mem_obj| mem_obj.lifter}
end
def lifter_names
... | true |
43f174753214a85f5545e11ac0c71ad317f019de | Ruby | FawwazMayda/ProgateRuby | /RubyStudy-I/main.rb | UTF-8 | 283 | 3.203125 | 3 | [] | no_license | number = 48
# Tambahkan sebuah pernyataan bersyarat
if number%3==0 && number%5==0
puts "Ini adalah kelipatan dari 15"
elsif number%5==0
puts "Ini adalah kelipatan dari 5"
elsif number%3==0
puts "Ini adalah kelipatan dari 3"
else
puts "Ini bukan kelipatan dari 3 atau 5"
end | true |
f438c7077e9cdd02ff85f11890341014a9f2050a | Ruby | tatsuo98se/led_stick | /ruby/btn_handler.rb | UTF-8 | 749 | 2.609375 | 3 | [] | no_license | begin
require_relative './bcm2835'
rescue Fiddle::DLError
puts 'failed loading bcm2835.'
end
class ButtonHandler
def initializer
@stop = false
@t = nil
end
def handle_button_down
@last_state = 0
@t = Thread.new{
if BCM.bcm2835_init.zero?
puts 'failed to init bcm2835'
r... | true |
f5c96ff31e4bb8c1ba1a9102cf4cee644ccd765d | Ruby | it3s/meppit | /spec/presenters/counters_presenter_spec.rb | UTF-8 | 2,674 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
describe CountersPresenter do
let(:object) { double('object', geo_data_count: 1, followers_count: 2) }
let(:presenter) { CountersPresenter.new object: object, ctx: double('ctx', url_for: 'url', identifier_for: 'id#num') }
describe "#size_" do
it "default size is medium" do
expect... | true |
61914d2ec5ba0a1aa311eef21c28353872d58407 | Ruby | pintofran/Scala-and-Ruby-Practices | /ruby/spec/prueba_spec.rb | UTF-8 | 3,501 | 3.34375 | 3 | [] | no_license | require_relative "../lib/pila"
require_relative "../lib/invariantes"
require_relative "../lib/operaciones"
class Testing
attr_accessor :contador, :se_ejecuto_after, :se_ejecuto_before
before_and_after_each_call(
Proc.new {self.se_ejecuto_after = true},
Proc.new {self.se_ejecuto_before = true})
def... | true |
761bbadcd498bcb7690b70c79f4d2f511a24b555 | Ruby | mwagner19446/wdi_work | /w02/d04/INSTRUCTOR/gladiator/lib/arena.rb | UTF-8 | 639 | 3.34375 | 3 | [] | no_license | class Arena
def initialize(name)
@name = name
@gladiators = []
end
def name
return @name
end
def gladiators
return @gladiators
end
def add_gladiator(gladiator)
if gladiators.size < 2
gladiators << gladiator
end
end
def fight
beats = { "Trident" => "Spear", "Spear"... | true |
a25d8d2ba2224f63b5082e173830bf7ee3b2dbd8 | Ruby | guhemama/textbooks_exercises | /Working.with.Unix.Processes/chapter5.rb | UTF-8 | 618 | 3.4375 | 3 | [] | no_license | # Processes have file descriptors, which represent open files.
# On Unix, everything is a file (oh really?); they can also be called resources.
# A running process is aways assigned a file descriptor number, which die when the process dies.
# Print a resource in Ruby (IO class)
passwd = File.open('/etc/passwd')
puts p... | true |
14c2e9a4450ffd5ec1661125a4becad40dcf2fa5 | Ruby | kenkuts/project_euler | /problem18.rb | UTF-8 | 2,702 | 3.71875 | 4 | [] | no_license | =begin
Maximum path sum I
By starting at the top of the triangle below and moving to adjacent numbers on the row below,
the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
=end
def max_path_sum
triangle = "75 0 0 0 0 0 0 0 0 0 0 0 0 0 0
95 64... | true |
3983b7937363ec88f8e5aa8c1a696b0cb3f11054 | Ruby | medusa-project/simple-amqp-server | /lib/simple_amqp_server/config.rb | UTF-8 | 1,024 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'yaml'
module SimpleAmqpServer
class Config < Object
attr_accessor :config
def initialize(config_file)
self.config = YAML.load_file(config_file)
end
#use this to enable query of top level keys via a method call with args for further arguments. Return nil if
#the top level key is p... | true |
9630b6542bad5e29f580c0fe7137fc9dadc828ed | Ruby | rstrauss127/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 930 | 3.78125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class PigLatinizer
def initialize
end
def starts_with_a_vowel?(word)
if word.scan(/^[aeiou]|^[AEIOU]/) == []
return false
else
return true
end
end
def piglatinize(word)
if word.split(" ").length >1
words = word.split(" ")
return words.collect {|w| piglatinize(w)}.join(" ... | true |
d66be5aae438deed036d2fdee6ad1087b0798cfb | Ruby | njonsson/autoloaded | /lib/autoloaded.rb | UTF-8 | 2,922 | 2.71875 | 3 | [
"MIT"
] | permissive | # Eliminates the drudgery of handcrafting a Ruby Core library +autoload+
# statement for each Ruby source code file in your project.
#
# @since 0.0.1
module Autoloaded
autoload :Autoloader, 'autoloaded/autoloader'
autoload :Inflection, 'autoloaded/inflection'
autoload :LoadPathedDirectory, 'aut... | true |
78bf3ad2bfed9c4aa8042871cbe14f21ace556ce | Ruby | dpholbrook/ruby_small_problems | /small_problems/medium_1/5.rb | UTF-8 | 1,826 | 4.40625 | 4 | [] | no_license | =begin
input: integer
output: diamond
rules:
- input n is odd integer
- diamond is n tall and n wide
algorithm:
- print row n times
- first row
- blank = n/2
- blank
- blank * spaces + star + blank * spaces
- blank - 1
-
=end
def diamond(n)
blank = n/2
blank.downto(1) do |countdown|
... | true |
1814a4b56c3e2df42ce3193dd21d9b47612bbb53 | Ruby | windo/livecode | /practice/music/add_bassline.rb | UTF-8 | 1,396 | 2.546875 | 3 | [] | no_license | # Add a matching bassline to the lead.
#
# Concentrate on the melody/harmony/rythm.
set :random_seed, RANDOM_SEED
set :bpm, 60
live_loop :bassline do
with_synth :subpulse do
# Add bassline here!
end
sync_bpm :tock
end
# --- backing track below ---
live_loop :tock do
use_bpm get(:bpm)
if tick(:tock) ... | true |
70a5a307a265927dae75789b3877138dbd5712a2 | Ruby | josephecombs/app_academy_completed_exercises | /w1d1/towers.rb | UTF-8 | 696 | 3.765625 | 4 | [] | no_license | stacks = [[3, 2, 1], [], []]
puts "Welcome to Towers of Hanoi"
in_play = true
while in_play
p "Game state: " + stacks[0].to_s, stacks[1].to_s, stacks[2].to_s
puts "enter the tower to select discs from (0 1 or 2):"
from_stack = gets.chomp.to_i
puts "enter the tower to select discs from (0 1 or 2):"
to_stack... | true |
88eb7a7a5d5a8317fce9a13ded0327510a4feec7 | Ruby | silvaelton/web_entities | /engines/admin/app/models/admin/user.rb | UTF-8 | 948 | 2.546875 | 3 | [
"MIT"
] | permissive | module Admin
class User < ActiveRecord::Base
attr_accessor :password_confirmation
enum situation: ['ativo', 'inativo']
enum permission: ['master', 'editor', 'visualizador']
validates :first_name, :last_name, :situation, :permission, presence: true
validates :email, email: true, uniqueness: tr... | true |
1b65b9424f8958240fad1d932ec5bb411f126a71 | Ruby | sonchez/course_101 | /101_109_small_problems/easy_5/alphabetical_numbers.rb | UTF-8 | 496 | 4.03125 | 4 | [] | no_license | require 'pry'
NUMBER_ARRAY = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] +
['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'ninteen']
def alphabetic_number_sort(num_array)
final_array = []
final_array = num_array.sort {|wo... | true |
fec75759bfe2abe63a401c03d7847729fd79f2a3 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/combine_anagrams_latest/7716.rb | UTF-8 | 528 | 3.703125 | 4 | [] | no_license | input1 = ['a', 'A', 'Cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams', 'scream']
def combine_anagrams(words)
if words.size == 0
print "Array is Empty"
return []
end
output = {}
result = []
words.each do |word|
str = [word.chars.sort_by(&:downcase).join].to_s.downcase
if output.has... | true |
4c35f6326953754ce503257487750ab1bf2e0683 | Ruby | Jarrod-Alford/Small_Problems | /Easy_1/list_of_digits.rb | UTF-8 | 273 | 3.8125 | 4 | [] | no_license | def digit_list(num)
array = []
num_as_str = num.to_s
num_as_str.each_char { |digit| array << digit.to_i }
array
end
puts digit_list(12345) == [1, 2, 3, 4, 5]
puts digit_list(7) == [7]
puts digit_list(375290) == [3, 7, 5, 2, 9, 0]
puts digit_list(444) == [4, 4, 4]
| true |
68fd2a4c87427006f6d3713948ebb518e7f08faa | Ruby | 6764YU/stage | /sapin.rb | UTF-8 | 256 | 2.75 | 3 | [] | no_license |
def displaystars(nbs)
nbs.times do
print "*"
end
puts
end
displaystars 1
displaystars 3
displaystars 5
displaystars 7
displaystars 9
displaystars 11
displaystars 13
displaystars 15
displaystars 5
displaystars 5
displaystars 5
displaystars 5
| true |
1e29531e5034ba0fa03562500bc970820c69f625 | Ruby | nikhil-vytla/DevMatch | /app/controllers/contacts_controller.rb | UTF-8 | 1,835 | 2.75 | 3 | [
"MIT"
] | permissive | class ContactsController < ApplicationController
# GET request to /contact-us
# Show new contact form
def new
@contact = Contact.new # Creates a new Contact and stores it in the instance variable [@contact]
end
# POST request to /contacts
def create # By default, Rails uses the create action to sav... | true |
68e2dd8543126826a04056d9a85441d20cb1cd25 | Ruby | oceansize/XOX | /spec/game_spec.rb | UTF-8 | 2,474 | 3.265625 | 3 | [] | no_license | require 'game'
describe Game do
let(:game) { Game.new(grid) }
let(:grid) { double :grid, cells: (1..9).to_a }
let(:player_1) { double :player_1, marker: :x }
let(:player_2) { double :player_2 }
# add test for grid
it "knows when it's not ready to play" do
expect(game.ready?).to be false
end
it "ca... | true |
d796796e2ce70cc256f8f3ffb431d6ffd0940d84 | Ruby | StlMaris123/project | /app/helpers/assignments_helper.rb | UTF-8 | 808 | 2.90625 | 3 | [] | no_license | module AssignmentsHelper
def max_days assignment
assignment.due_date - assignment.start_date
end
def remaining_days assignment
if assignment.due_date.future?
distance_of_time_in_words(Time.zone.now, assignment.due_date)
else
0
end
end
def percentage_remaining assignment
if as... | true |
0d6d89095e31bd1fcfabf8ba215b48c671117a71 | Ruby | nelsonic/sfetlmap | /examples/google-drive.rb | UTF-8 | 504 | 2.515625 | 3 | [] | no_license | require 'pp'
require "rubygems"
require "google_drive"
require_relative '../lib/config' # http://stackoverflow.com/a/4965766/1148249
env = 'google'
conf = EtlMapping::Config::config # instanciates config method in lib/config.rb
gconf = conf[env] # pull out google creds
session = GoogleDrive.login(gconf["user"], gco... | true |
87bb44dfe468bd9c97286ed3c8ef4e690decc556 | Ruby | Golden-Gate-Coders/ruby_whirlwind_review | /2.rb | UTF-8 | 509 | 3.734375 | 4 | [] | no_license | # count = 0
# 11.times do
# puts count + 1
# count += 1
# end
# ============
# result = false
# if result != true
# puts "Result is not true"
# end
# unless result == true
# puts "Result is not true"
# end
# ============
sam_recipes = 11
sally_languages = 5
if ((sam_recipes > 10) && (sally_languages >... | true |
cfa2b7affd69846f8f588b9acb32cfeffaef2348 | Ruby | platanus/human_attributes | /spec/dummy/spec/lib/active_record_extension_spec.rb | UTF-8 | 13,747 | 2.859375 | 3 | [
"MIT"
] | permissive | require "rails_helper"
require "enumerize"
# rubocop:disable Lint/ConstantDefinitionInBlock
RSpec.describe "ActiveRecordExtension" do
after do
class Purchase < ApplicationRecord
humanizers.each do |method|
remove_method method
end
end
end
describe "#humanize" do
let(:purchase) { ... | true |
328d7070a7cb3f102a99d587e645b8150824340a | Ruby | RebeccaRoach/stacks-queues | /lib/queue.rb | UTF-8 | 1,280 | 3.84375 | 4 | [] | no_license | class Queue
def initialize
@list = []
@max_list = 20
@front = -1
@back = -1
end
def enqueue(element)
if @front == -1
@front = 0
@list[@front] = element
@back = 1
elsif @front == @back
raise ArgumentError, "Queue is full"
else
@list[@back] = element
... | true |
8e53879b64872c03e114ce92948bb7af17ff5c18 | Ruby | CapellutoY/Preparcour-THP | /preParJours/pour aller plus loin ruby/plusPetitNombre.rb | UTF-8 | 190 | 3.140625 | 3 | [] | no_license | nombres = [42, -1, -365, 467]
i = 0
j = 1
while i < nombres.length && j != nombres.length
if nombres[i] <= nombres[j]
j += 1
else
i += 1
j = 0
end
end
puts "#{nombres[i]}"
| true |
d493eed3fe9f6f6da5f7bf2972bc196660bc37ce | Ruby | msucorey/aawork | /W2D3/TDD/spec/TDD_spec.rb | UTF-8 | 3,017 | 3.703125 | 4 | [] | no_license | require 'rspec'
require 'TDD'
describe "TDD" do
describe "#my_uniq" do
subject(:array) { [1, 2, 1, 3, 3] }
let(:empty_array) { Array.new }
it "returns an array" do
expect(array.my_uniq).to be_an(Array)
end
it "returns an empty array if given an empty array" do
expect(empty_array.my_... | true |
836357b63b87f51dfed75e766d44aa1e2591b46b | Ruby | Kyle-Dornblaser/Project-Euler | /Ruby/problem4.rb | UTF-8 | 655 | 3.59375 | 4 | [] | no_license | def largest_palindrome_product(digits = 3)
largest = 0
min = ('1' + '0' * (digits -1)).to_i
max = ('9' * digits).to_i
count = 0
max.downto(min) do |i|
# prevent unnecessary loops
return largest if i * max < largest
max.downto(min) do |j|
product = i * j
if palindrome?(product) && produ... | true |
81eea53af71ff44d8f5e1940d30ac4c365873dd4 | Ruby | letmein/toy_robot | /test/test_game.rb | UTF-8 | 1,665 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
require "minitest/autorun"
require "stringio"
require_relative "../lib/game"
class TestGame < Minitest::Test
def test_play_acceptance_a
output = StringIO.new
input = StringIO.new <<~EOF
PLACE 0,0,NORTH
MOVE
REPORT
EOF
expected_output = <<~EOF
0, ... | true |
262961a5e84b4057d5dc9f7371383a0aa0d7c181 | Ruby | osuosl/iam | /scheduler.rb | UTF-8 | 3,851 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'rufus/scheduler'
require_relative 'collectors.rb'
require_relative 'environment.rb'
require_relative 'lib/util.rb'
# schedule class will only start a scheduler if one is not already running
# TODO: make this simpler for Rubocop's sake
class Scheduler
# rubocop:disable AbcSize, ... | true |
31e1dbdb347721bdbdce04cc8fbdaf47d05e53a2 | Ruby | RickCSong/rrope | /lib/rrope/node.rb | UTF-8 | 178 | 2.75 | 3 | [
"MIT"
] | permissive | module Rope
class Node
attr_reader :weight, :depth, :data
def +(other)
ConcatenationNode.new(self, other)
end
def to_s
data.to_s
end
end
end | true |
57ea041a74cb26d759da0837a0fd05899235821e | Ruby | johndewolf/teacher_grader | /Students.rb | UTF-8 | 343 | 3.21875 | 3 | [] | no_license | class Student
attr_reader :last_name, :first_name, :grades
def initialize(last_name, first_name, grades)
@last_name = last_name
@first_name = first_name
@grades = grades
end
def average_score
FinalGrade.new(@grades).calc_average_score
end
def letter_grade
FinalGrade.new(@grades).calc_... | true |
1ae88187dce97bacd022786496ab8710a1634cc8 | Ruby | kaledoux/ruby_small_problems | /Easy9/counting_up.rb | UTF-8 | 1,261 | 4.25 | 4 | [] | no_license | # Write a method that takes an integer argument, and returns an Array of all
# integers, in sequence, between 1 and the argument.
#
# You may assume that the argument will always be a valid integer that is greater
# than 0.
#
# Examples:
#
# sequence(5) == [1, 2, 3, 4, 5]
# sequence(3) == [1, 2, 3]
# sequence(1) == [1]... | true |
71515e555386abe2fa53a86405a1d098415c77ba | Ruby | itsmekhanh/leetcode | /is_palindrome.rb | UTF-8 | 268 | 3.734375 | 4 | [] | no_license | # determine whether an integer is a palindrome.
def is_palindrome(x)
if x < 0 || (x != 0 && x%10 == 0)
return false
end
reverse = 0
while reverse < x do
reverse = reverse*10 + x%10
x = x/10
end
return x == reverse || reverse/10 == x
end
| true |
756b9154b0743aa966fe5cc8d53a605d6204b4bd | Ruby | dcchuck/advent-of-code | /2018/day1.rb | UTF-8 | 255 | 3 | 3 | [] | no_license | input = File.open('day1input')
val = input.map { |e| Integer(e.gsub("\n", "")) }
ans1 = val.inject(0, :+)
puts ans1
start = 0
vals = []
ans2 = val.cycle do |e|
start += e
if vals.include?(start)
puts start
break
end
vals.push(start)
end
| true |
b7559e16c63c6cd5e1cf741cc0aa5542f13b8843 | Ruby | Catherine-Kim/coderbyte | /ABCheck.rb | UTF-8 | 250 | 3.296875 | 3 | [] | no_license | def ABCheck(str)
i = 0
j = 0
res = false
blank = Array.new
arr = str.split("")
arr.each do |x|
if(x == "a")
if arr[j + 4] == "b"
res = true
end
i += 1
end
j += 1
end
return res
end
| true |
3fb510b755ce5331d699a6481d01c4c79acba4ee | Ruby | Neilos/project_euler_ruby | /problem018/test_calculate018.rb | UTF-8 | 402 | 2.9375 | 3 | [] | no_license | require 'rspec'
require './calculate018'
describe Triangle do
describe "max_path_sum" do
it "should return the sum of values on the maximum path" do
triangle_array = [
[3],
[7, 4],
[2, 4, 6],
[8, 5, 9, 3]
]
tri = Triangle.new(triangle_array)
puts tri.calcul... | true |
d2f7607c35a36845fb8b179132a1662a63913997 | Ruby | kopylovvlad/easy_captcha | /lib/easy_captcha/controller_helpers.rb | UTF-8 | 2,963 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module EasyCaptcha
# helper class for ActionController
module ControllerHelpers
def self.included(base) #:nodoc:
base.class_eval do
helper_method :valid_captcha?, :captcha_valid?
end
end
# generate captcha image and return it as blob
def generate_captcha
if EasyCaptcha.ca... | true |
19a1ee5db8862d7b633ebcdfea376fb6f9a7e1e4 | Ruby | ljorgens/motion-firebase | /lib/firebase/fir_database_query.rb | UTF-8 | 4,572 | 2.671875 | 3 | [] | no_license | class FIRDatabaseQuery
# previously the 'key' method was called 'name'
def name
self.key
end
def on(event_type, options={}, &and_then)
and_then = and_then || options[:completion]
raise "event handler is required" unless and_then
raise "event handler must accept one or two arguments" unless and... | true |
ae9be3187e92bcdbff532fe4eced7fda477999cb | Ruby | ramontayag/ordered_tree | /lib/ordered_tree/instance_methods/destroy.rb | UTF-8 | 1,083 | 2.59375 | 3 | [
"MIT"
] | permissive | module OrderedTree
module InstanceMethods
module Destroy
## Destroy Methods
# sends immediate children to the 'roots' list, then destroy's self
def destroy_and_orphan_children
self.class.transaction do
orphan_children
self.destroy
end
end
# hands... | true |
e97622041deaa0140f5bf241049d12aeae0501ad | Ruby | CodingShawn/TOP-Ruby-Bubble-Sort | /bubble_sort.rb | UTF-8 | 332 | 3.515625 | 4 | [] | no_license | def bubble_sort(array)
swap_counter = -1
while swap_counter != 0 do
swap_counter = 0
for i in 0..((array.length) -2)
if array[i] > array[i + 1]
temp = array[i]
array[i] = array[i + 1]
array[i + 1] = temp
swap_counter = swap_counter + 1
end
end
end
return array
end
puts bubble_sort([4,3... | true |
8cc10382be0a4af4e41290311e0e1bf0686dd188 | Ruby | ahuff44/compiler-backdoor | /quine.rb | UTF-8 | 671 | 3.453125 | 3 | [
"MIT"
] | permissive | def escape(str)
str.chars.map do |chr|
case chr
when "\\"
"\\\\"
when "\""
"\\\""
when "\n"
"\\n"
else
chr
end
end.join
end
foo = ->(x){ x+"\nputs foo.call(\""+escape(x)+"\")" }
puts foo.call("def escape(str)\n str.chars.map do |chr|\n case chr\n when \"\\\\\"... | true |
9397e8bdec8b9eb0f56c9390c7ab88bab771a69b | Ruby | fhopecc/fhopecc | /project/master_paper/lib/windot.rb | BIG5 | 1,124 | 2.625 | 3 | [] | no_license | ## A front-end for WinGraphviz.DOT.
##
## Versrion: 1.0
## Author: Gary W. Lee
## Date: 2004-12-06 10:25:00
## ruby porting fhope@2006/8/24 U 02:24:20
## note by fhope@2006/8/8 W 09:44:25
## 1.w winGraphviz.dll
## 2.w ruby
## 3.copy this script 2 c:\ruby
## 4.you can type windot.py src.dot target.png
requir... | true |
a731fd6f44c337e4fe64c6967c6fe02b9446b47e | Ruby | diohabara/competitive_programming | /aoj/alds11b.rb | UTF-8 | 177 | 3.359375 | 3 | [] | no_license | def gcd(x, y)
if x < y
t = x
x = y
y = t
end
if y == 0
return x
else
r = x % y
gcd(y, r)
end
end
x, y = gets.split.map(&:to_i)
puts gcd(x, y)
| true |
1d2dce6965268fba253b9b9a704d0d2b13dc9609 | Ruby | BradleyJrichardson/mel-morning-challenges19 | /term_one/ruby/week_6/28_03_2019_class_csv_challenge/world_cities_class_and_challenge_details.rb | UTF-8 | 2,775 | 3.796875 | 4 | [] | no_license | require "csv"
require "pry"
# this is a class
class City
attr_reader :name, :country, :subcountry
def initialize(name, country, subcountry)
@name = name
@country = country
@subcountry = subcountry
end
end
csv_text = File.read('world-cities.csv')
csv = CSV.parse(csv_text, headers: tru... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.