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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4d9770fb23dd4c4e1f2781bbd515d6c43388bed8 | Ruby | DanielSLew/Ruby_Small_Problems | /Foundations/medium1/rotation3.rb | UTF-8 | 1,299 | 4.375 | 4 | [] | no_license | # Write a method that takes an int as an arg
# Rotate to the left, keep first digit in place and rotate remaining nums
# keep first 2 digits in place and repeat
# keep first 3 digits in place and repeat
# Keep first 4 digits in place and repeat
# Resulting num is the max rotation
# Use rotate_rightmost_digits from last... | true |
e4ea2ca9dc4fc2c85daa1051e3f24fcaea091044 | Ruby | bapata/RUBY | /palindrome.rb | UTF-8 | 351 | 4.0625 | 4 | [] | no_license | #!/usr/bin/ruby
# Script to check if a given word is a palindrome
# Usage: ./palindrome.rb <word-to-test>
# Example: ./palindrome.rb bob # output: bob is a palindrome
# ./palindrome.rb bobo # output: bobo is not a palindrome
# Main starts here
word,= ARGV
puts "#{word} is " + (word == word.reverse() ? "a pal... | true |
0684301130f98021b495e08caeb16696c59fc6dd | Ruby | inga3000/sample_app | /spec/factories.rb | UTF-8 | 721 | 2.546875 | 3 | [] | no_license | # This will guess the User class
FactoryGirl.define do
sequence(:email) {|n| "inga_#{n}@abc.de" }
factory :user do
first_name "John"
last_name "Doe"
email { generate(:email) }
password "12345678aA"
admin false
end
# This will use the User class (Admin would have been gu... | true |
7aeb125314f900ae2dc40ce000aef5fd73cbd20e | Ruby | kathyonu/apotomoing_sequencers | /lib/singular.rb | UTF-8 | 1,134 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby -w
module Singular
include Textual
puts "Singular Module has included the Textual module" # for use in console
attr_accessor :sequencetext
attr_accessor :singular_sequence
attr_accessor :singular_sequenced
def singular_sequenced
@singular_sequenced = singular_sequencer(sequ... | true |
84daaa5093f116487a0b9a14ef2f7d204f2f3cfa | Ruby | shuto0125/projecteuler | /problem5/retry.rb | UTF-8 | 646 | 3.53125 | 4 | [] | no_license | def soinsu(n)
2.step(n - 1) do |i|
return [i , soinsu(n / i)] if(n % i == 0)
end
[1,n]
end
hash = {
# "1" => 0,
"2" => 0,
"3" => 0,
"5" => 0,
"7" => 0,
"11" => 0,
"13" => 0,
"17" => 0,
"19" => 0,
}
a = []
20.times do |i|
i += 1
soinsu = soinsu(i)
soinsu = soinsu.flatten
... | true |
e7afff218a082eff315ad741d411af050cfbe663 | Ruby | uri/inventory-backend | /app/models/item.rb | UTF-8 | 608 | 2.671875 | 3 | [] | no_license | class Item < ActiveRecord::Base
has_many :reservations, dependent: :destroy
belongs_to :category
# !!!
# Make sure that a user can pick up the item a bit
# before if it's not in use. E.g. let time
# DELTA be 10.minutes
def current_reservation
current_time = Time.now
self.reservations
.whe... | true |
d38d8d491dbe000ad1fb03f515e89c80ff5b879a | Ruby | aguinther/homework_assignments | /arrays/fizz_buzz_array.rb | UTF-8 | 290 | 3.90625 | 4 | [] | no_license | #!/usr/bin/env ruby
numbers = (1..100)
fizzbuzz = []
numbers.each do |num|
if num % 3 == 0 && num % 5 == 0
fizzbuzz.push('FizzBuzz')
elsif num % 3 == 0
fizzbuzz.push('Fizz')
elsif num % 5 == 0
fizzbuzz.push('Buzz')
else
fizzbuzz.push(num)
end
end
puts fizzbuzz
| true |
0ca39ca55014d6ccb629eab4be8ef96d586b6673 | Ruby | deogracia/Rails_01 | /db/seeds.rb | UTF-8 | 3,573 | 3.046875 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name =>... | true |
2f6a85be91b7daa9ad88d9aa4acbff08c84b17e9 | Ruby | jadefeng/Sinatra-WDI6 | /10-Sinatra/receipts/main.rb | UTF-8 | 979 | 3.21875 | 3 | [] | no_license | require 'pry'
require 'sinatra'
require 'sinatra/reloader'
get '/' do # Query to the internet
erb :new
end
post '/' do # Can post something to the server
@service_provided = params["service"].to_s
@cost_charged = params["cost"].to_s
db = File.new("database.txt", 'a+')
db.puts(@service_provided + ',' + @cost_... | true |
ffd81c1ba2de1fdc22c21d0da2da69306e089d79 | Ruby | danielwanja/onrails.org | /files/rails_log_monitor.rb | UTF-8 | 2,411 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# daemon to scrape response times from rails logs
require 'rubygems'
require 'file/tail'
require 'mongrel'
require 'yaml'
RAILS_ENV = ENV['RAILS_ENV'] || "production"
PORT = ENV['PORT'] || "8888"
IGNORE_PATTERNS = %r{heartbeat}.freeze
class Accumulator
def initialize
@values = Array.new()
... | true |
6ee522e4060f666efc66f0520365d625fb41bc8d | Ruby | jgt17/project_euler | /20s/problem_24.rb | UTF-8 | 752 | 3.453125 | 3 | [] | no_license | # frozen_string_literal: true
def fact(n)
(1..n).reduce(:*) || 1
end
def swap_with_first_el(arr, idx)
temp = arr[idx]
arr[idx] = arr[0]
arr[0] = temp
end
def move_to_front(arr, idx)
arr.prepend(arr.delete_at(idx))
end
# assumes array is lexicographically sorted
def nth_permutation_helper(arr, num)
retur... | true |
6da7d0187176d318aaca5b1963a90e082b9d096b | Ruby | slayfer-dev/Challenges-sol | /Programming/Codeabbey/128/pinkloyd.rb | UTF-8 | 322 | 3.3125 | 3 | [] | no_license | #Author pinkloyd
nums = ARGF.file.read.split("\n")[1..-1].map(&:split).map {|y| y.map(&:to_i)}
def factorial(num)
return 1 if num == 0
(1..num).inject(&:*)
end
def combinations_count(a)
n, k = a[0], a[1]
factorial(n) / (factorial(k) * factorial(n - k))
end
puts nums.map { |x| combinations_count(x) }.join(' '... | true |
ac2c70a04041395ac4792b7161bdca28a06e654f | Ruby | Mimi-12/prime-ruby-onl01-seng-ft-081720 | /prime.rb | UTF-8 | 193 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(num)
if num == 2
return true
end
if num <= 0 || num == 1
return false
end
(2..num-1). none? do |i|
num % i == 0
end
end
| true |
b2ebe4bffc0166b1fc266797b4f43f48b0c957cf | Ruby | georgiybykov/thinknetica_20 | /Lesson 7/cargo_railcar.rb | UTF-8 | 543 | 3.28125 | 3 | [] | no_license | require_relative 'railcar'
class CargoRailcar < RailCar
attr_reader :overall_volume, :booked_volume
def initialize(overall_volume = 95)
@type = 'cargo'
@overall_volume = overall_volume
@booked_volume = 0
validate!
end
def take_volume(volume)
return if volume > @overall_volume
@booke... | true |
4c00879ea766cfe5646e60a7c1f66281149e6ae7 | Ruby | natalieesk/Project-Euler-Challenges | /spec/Euler_16_spec.rb | UTF-8 | 128 | 2.703125 | 3 | [] | no_license | require 'Euler_16'
describe 'powersum' do
it 'sums the digits of the powernumber' do
expect(powersum(4)).to eq 7
end
end | true |
ccf538021bddfdc8bfb6bf01b1b8402473e16334 | Ruby | stevula/various-algorithms | /pi_to_the_nth_digit.rb | UTF-8 | 741 | 3.59375 | 4 | [] | no_license | require 'bigdecimal'
require 'bigdecimal/math'
# this is way too slow to be practical so I didn't use it
# def calculate_pi
# pi = 0
# 10_000_000.times do |i|
# pi += 4.0 / (1 + 4 * i) - 4.0 / (3 + 4 * i)
# end
# pi
# end
def valid_integer?(string)
string.to_i.to_s == string
end
puts ... | true |
3bb31ba71634181e564df223c831ac481960f6f8 | Ruby | lloydpick/echelon | /lib/echelon/parks/disneyland/disneyland.rb | UTF-8 | 1,042 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'json'
require 'net/http'
module Echelon
module Disneyland
class Disneyland < Park
attr_reader :json_data
def ride_list
json_data.keys.inject({}) { |a, e| a[e] = e; a }
end
def initialize
# fetch the json feed
url = 'http://dparks.uieme... | true |
d39716a57d70b350f655bcc19309680a0a9e41ea | Ruby | swaption2009/rbnd-toycity-part4 | /lib/analyzable.rb | UTF-8 | 787 | 3.265625 | 3 | [] | no_license | require 'colorize'
module Analyzable
# Your code goes here!
def average_price(products)
sum = 0
products.each do |product|
sum += product.price
end
return ( sum / products.count ).to_f.round(2)
end
def print_report(products)
report = Hash.new(0)
puts "Inventory Report"
produc... | true |
73c5b677d2132a86301659cee449dc34510499d4 | Ruby | Pikachoo/airport | /app/models/passenger.rb | UTF-8 | 463 | 2.640625 | 3 | [] | no_license | class Passenger < ApplicationRecord
belongs_to :flight
belongs_to :user
validates :flight_id, :user_id, presence: true
validates :flight_id, uniqueness: { scope: :user_id }
validate :flight_capacity, on: :create # 1) A flight has a fixed number of seats and if it is full then you should not be able to add a... | true |
c2d45f68e9957de22dac233cdb86b652412c5c99 | Ruby | MarkyMarkMcDonald/doc_doc | /lib/doc_doc.rb | UTF-8 | 2,080 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'doc_doc/version'
require 'doc_doc/horse_and_buggy'
require 'doc_doc/quarantine'
require 'doc_doc/house_call'
require 'doc_doc/patient'
require 'doc_doc/prescription'
require 'doc_doc/treatment'
require 'doc_doc/configuration'
module DocDoc
def self.prescription(config)
horse_and_buggy = HorseAndBuggy.ne... | true |
c26026a7c2c312745167ff0bdc7d52f38f622637 | Ruby | shawn0915/ruby_programming | /chapter_8/oop_sample.rb | UTF-8 | 255 | 3.421875 | 3 | [] | no_license | f = 3.14
p f.round #=> 3 四舍五入
p f.ceil #=> 4 进位
p f.to_i #=> 3 整数变换
# 封装 encapsulation
t = Time.now
p t.year
p t.month
p t.day
# 多态 polymorphism
obj = Object.new
str = "Ruby"
num = Math::PI
p obj.to_s
p str.to_s
p num.to_s
| true |
a7da5fd0df4b7f9def8843d95b1e239b9480e001 | Ruby | muzzi92/Boris-Bikes-Thurs | /spec/vans_spec.rb | UTF-8 | 224 | 2.53125 | 3 | [] | no_license | require 'bike.rb'
require 'vans.rb'
describe Vans do
#initialize vans as an array
#can it add bikes to the array
it "carries bikes in an array" do
expect(subject.bikes_on_board).to be_instance_of(Array)
end
end
| true |
5647af51b76702724e14db2bc41bc6464fc8ab2d | Ruby | maclarensg/challenge | /007-sudoku/main.2.rb | UTF-8 | 2,813 | 3.640625 | 4 | [] | no_license |
def advance_grid(grid, x, y)
if x < grid.size - 1
[(x + 1), y]
else
if y < grid.size - 1
[0, (y + 1)]
end
end
end
def check_row(grid, x, y, pick)
r = grid[y].uniq
r.each { |c| return true if r.count(pick.to_s) == 0 }
false
end
def check_col(grid, x, y, pick)
r = grid.transpose[x].... | true |
160aa7a50686aa07d99197f44562995afa1ddd07 | Ruby | sena-ji/app-academy-open | /ruby_curriculum/error_handling_funtime_project/user_script.rb | UTF-8 | 467 | 2.734375 | 3 | [] | no_license | require_relative 'super_useful'
# not sure why this was here since the specs for this project did not include
# instructions on what to do with this section -> fixed it anyways!
# problem was that the function takes in a integer that is a string and converts it to an integer
puts "'five' == #{convert_to_int('5')}"
f... | true |
2b251e5cea3e53137ad823e4756f849e61351b43 | Ruby | jcmorrow/fealty | /spec/lib/player_spec.rb | UTF-8 | 2,121 | 2.9375 | 3 | [] | no_license | require "spec_helper"
require "lib/cards"
require "lib/strategy"
require "lib/strategy_generator"
require "lib/player"
describe Player do
describe "#take_turn" do
it "buys cards" do
strategy = Strategy.new(
buy_priorities: [Cards::Gold, Cards::Gold],
play_priorities: [],
)
gold ... | true |
1292114e698df249dff06c6570e52fd47c82a1f3 | Ruby | XanderStrike/sqlite2mysql | /lib/sqlite2mysql/services/mysql.rb | UTF-8 | 1,466 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'mysql2'
class MysqlClient
def initialize(*args)
@client = Mysql2::Client.new(*args)
end
def recreate(name)
@client.query("DROP DATABASE IF EXISTS #{name}")
@client.query("CREATE DATABASE #{name}")
@client.query("USE #{name}")
end
def build_from_schema(schema)
schema.keys.each d... | true |
fab30aae26c5b1dd131be28210c459ecc49555ed | Ruby | qariane/phase-0-tracks | /ruby/hashes_skippers.rb | UTF-8 | 1,600 | 3.703125 | 4 | [] | no_license | #Prompt the designer/user for all of this information.
puts "This is the number one designer in the world, we are here to serve you . To get started please give us your client's informations"
# ask for all the information
puts "Please give us your client's name"
name = gets.chomp
puts "Please give us your client's age"... | true |
1f631dc313233478bc944f68179dc43ca9d2fe90 | Ruby | weareredshift/rs-components | /prep.rb | UTF-8 | 1,402 | 3.109375 | 3 | [] | no_license | usage = '''
Usage: ruby deploy.rb [version_bump_type] [message]
- bump_type - One of "major", "minor", "patch". Determines how to increment the version number.
- message - Quote-enclosed message describing version.
- commit_message - (Opt) Quote-enclosed commit message. If not given, will default to message.
'''
type ... | true |
97a2d032c4c224e43e59d65599a1bae602d2bde0 | Ruby | DenisColoma/tic_tac_toe | /lib/show.rb | UTF-8 | 609 | 3.03125 | 3 | [] | no_license | require_relative 'board'
require_relative 'boardcase'
class Show
def grid(board)
puts "The Grid"
puts ""
puts " 1 2 3".red
print "A".red
puts " #{board.case_arr[0]} | #{board.case_arr[1]} | #{board.case_arr[2]}".yellow
puts " --------+-------+--------".red
print "B".red... | true |
e08eca0fd58ec13d0fb6539941559eb2f779161d | Ruby | lsethi-xoriant/FandomRails4 | /lib/tasks/send_last_week_approved_comments.rake | UTF-8 | 2,239 | 2.625 | 3 | [] | no_license | #!/bin/env ruby
# encoding: utf-8
require 'rake'
desc "Send to a list of email addresses a random selection of 'max_comments' updated in the last 'days' days for selected tenant"
task :send_approved_comments, [:tenant, :emails, :days, :max_comments] => :environment do |t, args|
send_approved_comments(args[:tenant]... | true |
4b1966561fd0d46abb3a63fc53519d71dec08887 | Ruby | Parker-ygfert/Codewar | /codewar8/fake_binary.rb | UTF-8 | 487 | 3.96875 | 4 | [] | no_license | # 給予一組數字字串,若該字元小於 5 則結果為 '0';5 以上則結果為 '1',請回傳結果字串
def fake_bin(s)
new_s = ""
s.each_char do |char|
new_s += (char.to_i < 5) ? "0" : "1"
end
new_s
end
# p fake_bin '45385593107843568'
#* 參考解答
#* s.gsub(/[0-4]/,'0').gsub(/[5-9]/, '1')
#* s.split('').map{ |x| x.to_i < 5 ? 0 : 1 }.join
#* s.tr("123456789",... | true |
137f6fc833f67a854f8d1f4bb1e8a1b87c0bf1bb | Ruby | JEG2/riot | /test/context_test.rb | UTF-8 | 2,517 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'teststrap'
context "Reporting a context" do
setup do
a_context = Riot::Context.new("foobar") do
asserts("passing") { true }
asserts("failing") { false }
asserts("erroring") { raise Exception }
end
a_context.run(MockReporter.new)
end
asserts("one passed test") { topic.passe... | true |
70ae6723a1ee3b9f9b8e361c6c958c80eaa2aa6c | Ruby | ElAtrash/Ruby_Parser | /petsonic_parser.rb | UTF-8 | 3,235 | 3.15625 | 3 | [] | no_license |
require 'curb'
require 'nokogiri'
require 'csv'
class Parser
PRODUCTS_COUNT = '//span[@class="heading-counter"]'
PRODUCTS_URL = '//a[@class="product_img_link product-list-category-img"]/@href'
PRODUCT_IMAGE = '//img[@id="bigpic"]/@src'
PRODUCT_PRICE = './/span[@class="price_comb"]'
PRODUCT_SOLO_PRICE = '//s... | true |
c7f6278f1d5ca0c3b9434dc11682ce39148ff2f0 | Ruby | EdgarOrtegaRamirez/lita-poke | /lib/lita/handlers/poke.rb | UTF-8 | 9,963 | 2.546875 | 3 | [] | no_license | module Lita
module Handlers
class Poke < Handler
route(/(poke|pokemon) (\S*)$/i, :pokemon_info, command: true, help: {
"(poke|pokemon) <name>" => "information about a pokemon by ID or name",
})
route(/(poke|pokemon) (pic|photo) (\S*)$/i, :pokemon_pic, command: true, help: {
"(pok... | true |
f2f4b441644d92bfd0c3b3f1fe4a3ed864ff0ec2 | Ruby | alexstephane/ruby-project-alt-guidelines | /config/db/seed.rb | UTF-8 | 800 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../lib/customer.rb"
require_relative "../lib/movie.rb"
require_relative "../lib/redbox.rb"
#creating customer
alex_s=Customer.find_or_find_or_create_by(name: "Alex", username:"alex_steph")
rahel_p=Customer.find_or_create_by (name: "Rahel", username:"rahel20")
milina_j=Customer.find_or_create_by (name... | true |
2ab6458958ec35e52e592b62eae92f2e9ff1cd78 | Ruby | muydanny/Enigma | /lib/key.rb | UTF-8 | 315 | 2.984375 | 3 | [] | no_license | class Key
attr_reader :key,
:key_offset
def initialize(key = random_numbers)
@key = key
@key_offset = {
:A => key[0..1].to_i,
:B => key[1..2].to_i,
:C => key[2..3].to_i,
:D => key[3..4].to_i
}
end
def random_numbers
rand(11111..99999).to_s
end
end
| true |
048037ff27ca69b2ff7e1daa945bf69d3217381a | Ruby | nari19/AtCoder | /13x/133/b.rb | UTF-8 | 264 | 2.9375 | 3 | [] | no_license | n, d = gets.split.map(&:to_i)
x = n.times.map{ gets.split.map(&:to_i) }
count = 0
for hoge in (0...n).to_a.combination(2).to_a
fuga = 0
d.times{ |i| fuga += (x[hoge[0]][i] - x[hoge[1]][i]) ** 2 }
count += 1 if (fuga ** (1/2.0))%1 == 0
end
puts count | true |
f07e2126f0d4cf8e43c60f7a915cbfba39345c5d | Ruby | serioja90/aclize | /lib/aclize/acl/controllers_registry.rb | UTF-8 | 3,469 | 2.953125 | 3 | [] | no_license | # The policy adopted by Aclize is:
# 1. By default all the controllers and paths are denied
# 2. On rules conflict, the more restrictive rule will be used
# 3. When permit and deny rules have the same restriction,
# deny rule will be used
module Aclize
class Acl::ControllersRegistry
attr_reader :per... | true |
4835e47947a5b6f802005f230a66f9e435262742 | Ruby | disorder/toy-lisp-rb | /lisp.rb | UTF-8 | 20,609 | 3.59375 | 4 | [] | no_license | def debug(*args)
#print(*args, "\n")
end
def info(*args)
print(*args, "\n")
end
def is_ws(c)
return c =~ /\s/
end
def is_nl(c)
return (c == "\n" or c == "\r")
end
def is_comment(c)
# let's allow # and ; both for now but # breaks lisp syntax in editors
return (c == ';' or c == '#')
end
def is_sexp(c)
... | true |
6ac68b15e19fe397b5b853f1db72a449c9df1104 | Ruby | luciemonnier/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 1,194 | 3.25 | 3 | [] | no_license | require 'open-uri'
require 'json'
class GamesController < ApplicationController
def new
@letters = []
10.times { @letters << ('A'..'Z').to_a.sample }
end
def score
letters = params[:letters].split(' ')
word = params[:word]
if !in_the_grid?(word, letters)
not_in_the_grid(word)
elsif... | true |
00f090295234ebbb0a0b9ee7206f206e90e6349e | Ruby | AlexanderPetryakov/repository_1 | /Lesson_4/PassengerTrain.rb | UTF-8 | 309 | 3.078125 | 3 | [] | no_license | require_relative 'Train'
class PassengerTrain < Train
def initialize(number)
super
self.type = "Пассажирский"
end
def add_wagons(wagon)
if wagon.class == Coach
super
else
puts "Тип вагона не подходит типу поезда."
end
end
end | true |
5b9d0bfdcdfa0f9c8b70f4f020117361ca0fc210 | Ruby | drumguy16/phase-0 | /week-6/guessing-game/my_solution.rb | UTF-8 | 2,835 | 4.34375 | 4 | [
"MIT"
] | permissive | # Build a simple guessing game
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input:any integer for answer. any integer for guess
# Output: clues to whether your guess is high, low, or correct.
# Steps:
# define instace varible @answer to be answer argument p... | true |
8f6feb72e753a64b2966d9b9abf99c58fe713fc3 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/41b340cac824457d9a965832012591d2.rb | UTF-8 | 202 | 3.265625 | 3 | [] | no_license | module Hamming
def self.compute str1, str2
distance = 0
str1.chars.each_with_index do |c,i|
next if str2[i].nil?
distance += 1 unless c == str2[i]
end
distance
end
end
| true |
eb9de7ed524d84490ccc56d5f4ab9884f79e1bf4 | Ruby | Qooh0/cml_timer | /bin/cml_timer | UTF-8 | 271 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
=begin
$ cml_timer minutes
=end
require "bundler/setup"
require "cml_timer"
minutes = ARGV[0]
if minutes.nil?
puts 'Set minutes'
puts '$ cml_timer minutes'
exit 1
end
timer = ::CmlTimer::CmlTimer.new
timer.start(wait_time_second: minutes)
| true |
f58de2517019da40a4c6b5e0f87f68a1575fc6b2 | Ruby | ForwardFinancing/ach_client | /lib/ach_client/providers/soap/ach_works/account_type_transformer.rb | UTF-8 | 575 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | module AchClient
class AchWorks
##
# Transforms AccountTypes between AchClient class and the string
# that AchWorks expects
class AccountTypeTransformer < AchClient::Transformer
# 'C' means Checking, 'S' means Savings
# @return [Hash {String => Class}] the mapping
def self.transforme... | true |
48fb5f49085dff87f7f4ecc93e855c62db26bd58 | Ruby | GunioRobot/hcrepos | /rmagick/dropshadow.rb | UTF-8 | 2,363 | 3.0625 | 3 | [] | no_license | require 'RMagick'
class DropShadow
def initialize(config={})
@shadow_width = config[:shadow_width] || 10
@with_border = config[:with_border]
@with_frame = config[:with_frame]
@border_margin = config[:border_margin] || 0
@border_color = config[:border_color] || 'black'
@shadow_color = config[:... | true |
abc82156f61dda69f4b5de4a47ff9dfee792f136 | Ruby | PabloBlancoArg/rubytests | /Practica3/ejercicio4.rb | UTF-8 | 516 | 4.03125 | 4 | [] | no_license | # 4.-2520 es el número más chico que puede ser dividido por cada uno de los números del 1 al
#10 sin obtener resto. ¿Cual es el número más chico que puede ser dividido por cada uno de los
#números del 1 al 20?
def minimo_comun_divisor(minimo,maximo)
n = maximo
until (minimo..maximo).all? { |i| n % i == 0 }
... | true |
73a9e8f641dbb69f1b2524fdb5f982cb649cab1d | Ruby | majasli/W4D4 | /MusicAppProject/app/models/user.rb | UTF-8 | 1,795 | 2.765625 | 3 | [] | no_license | class User < ApplicationRecord
# cats 99
# https://github.com/appacademy/curriculum/blob/master/rails/projects/ninety_nine_cats_ii/solution/app/models/user.rb
# first rails app
# https://github.com/appacademy/curriculum/blob/master/rails/homeworks/rails-auth/solution/app/models/user.rb
validates :email, :p... | true |
e8b1401b89f0f28df6e7a5f9b8873be22a5edee2 | Ruby | tk0358/design_patterns_in_ruby | /chapter7_iterator/07_07.rb | UTF-8 | 199 | 2.859375 | 3 | [] | no_license | require 'pathname'
pn = Pathname.new('/mnt/c/Code/ruby/design_patterns_in_ruby/chapter7_iterator')
pn.each_filename{|file| puts("File: #{file}")}
pn.each_entry{|entry| puts("Entry: #{entry}")}
| true |
61a6034871a85d9f9026b28f0342c906a1f6fb9d | Ruby | PawelGedlek/Ruby-Laboratory | /lab2/prime.rb | UTF-8 | 350 | 3.75 | 4 | [
"MIT"
] | permissive | input_array = ARGV
def is_number?(x)
return Float(x) rescue false
end
def isPrime(x)
for i in 2..Math.sqrt(x)
if x % i == 0
return false
end
end
return true
end
input_array.each {
|x|
if is_number?(x) != false
puts "It is " + x + " prime? => " + isPri... | true |
3e93d3bac1e914448994e813cfc14c8a5dc015b4 | Ruby | bdfinlayson/textula | /textula | UTF-8 | 2,538 | 3.09375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'highline/import'
require_relative 'lib/environment'
menu_prompt = "1. Create New Game\n2. Open Existing Game\n3. Quit\n"
secondary_menu = "1. Add room\n2. Add Object\n3. Edit Room\n4. Edit Object\n5. Quit\n"
input = ARGV
if input.size == 1 and input[0] == 'start'
choose do |menu|
... | true |
f0cc49ad3f7b75d0c0f98a4c0ba7df1b5a970de6 | Ruby | Engron/formprocessor | /lib/required.rb | UTF-8 | 665 | 3.390625 | 3 | [
"MIT"
] | permissive | module FormProcessor
# Checks to make sure all required fields are present and accounted for.
class Required
# A String with the list of missing fields.
attr_reader :result
# Expects a Hash passed from Main.
def initialize(values)
@values = values
@result = String.new
run
end
private
def run
... | true |
e69b17fc1257d26e5b92c7f0f1b916ce59e8a615 | Ruby | cucumber/cucumber-ruby-wire | /lib/cucumber/wire/request_handler.rb | UTF-8 | 764 | 2.75 | 3 | [
"MIT"
] | permissive | module Cucumber
module Wire
class RequestHandler
def initialize(connection, registry = nil)
@connection = connection
@message = underscore(self.class.name.split('::').last)
@registry = registry
end
def execute(request_params = nil)
@connection.call_remote(self, @... | true |
e8490988e9839f57404ead44e7195be33c281385 | Ruby | nomi811/battleships_tech_test | /lib/ship.rb | UTF-8 | 646 | 3.34375 | 3 | [] | no_license |
class Ship
attr_accessor :hit_count
attr_reader :length, :name
def initialize(length, name)
@length = length
@name = name
@hit_count = 0
@placed = false
end
def self.aircraft_carrier
new(5, 'aircraft carrier')
end
def self.battleship
new(4, 'battleship')
end
def self.subm... | true |
82ac0119e427bba5a75fd67452db0163a057045f | Ruby | robertfromsms/square_array-atlanta-web-060319 | /square_array.rb | UTF-8 | 114 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each {|element| new_array.push(element*element)}
new_array
end
| true |
52e2a8138e09f4b41c99fa2f2b1197051e63e945 | Ruby | wintermeyer/old-rails-version-of-mehr-schulferien.de | /app/models/day.rb | UTF-8 | 1,184 | 2.671875 | 3 | [
"MIT"
] | permissive | class Day < ActiveRecord::Base
belongs_to :month, touch: true
has_many :slots, dependent: :destroy
has_many :events, through: :slots
# default_scope { order(value: :desc) }
after_validation :set_wday_any_position
# Validations
#
validates :value,
presence: true,
uniqueness: tr... | true |
8f2c38a3536b1bac1f3ff279e2ff395cd6bda05a | Ruby | mlipper/runt | /test/reyeartest.rb | UTF-8 | 4,164 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'baseexpressiontest'
# Unit tests for REYear class
# Author:: Matthew Lipper
class REYearTest < BaseExpressionTest
def test_ctor_one_arg
expr = REYear.new(11)
assert expr.start_month == 11, "Start month should equal 11"
assert expr.end_month == 11, "End month should equal 1... | true |
f559d1d5975a2f8d7591506929faae76af9fcbfe | Ruby | jsuabur/libro-de-actividades | /actividades/prog/files/ruby/mil-ejemplos/aplicaciones/morse/modulos/comprobacion_de_tipos.rb | UTF-8 | 1,813 | 3.03125 | 3 | [
"CC0-1.0",
"CC-BY-SA-3.0"
] | permissive | =begin
Fichero: comprobacion_de_tipos.rb
Autor: David Vargas <dvargas@canarias.org>
Versión: 0.1.0 20081214
Descripción: Módulo para comprobar la validez de los tipos de variables
=end
module ComprobacionDeTipos
def definir_reglas(inputs={}.freeze)
@definiciones_de_usuario ||={}
inputs.each do |tipo, regla|... | true |
62e51c1db7653a8ca286649afed0a66fd6a50be5 | Ruby | DukeMobileTech/rails_survey | /config/initializers/gruff.rb | UTF-8 | 3,722 | 2.609375 | 3 | [
"MIT"
] | permissive | Gruff::Base.class_eval do
# Draws horizontal background lines and labels
def draw_line_markers
return if @hide_line_markers
increment_scaled = @graph_height.to_f / (@spread / @increment)
# Draw horizontal line markers and annotate with numbers
(0..marker_count).each do |index|
y = @graph_top... | true |
376cb92cde2a757a66ddb1cd2a34f67fd88d393f | Ruby | torresga/launch-school-code | /exercises/101-109_small_problems/easy_2/retire.rb | UTF-8 | 1,742 | 4.65625 | 5 | [] | no_license | # PEDAC
# Goal: Build a program that displays when the user will retire and how many years she has to work till retirement.
# Identify expected input or Output
# Make requirements explicit
# Identify rules
# Create a mental model of the problem
#
# Input: An age, represented by a positive integer greater than 0. A des... | true |
e638403954d1511df8fc7f64cd70fba3d9bae671 | Ruby | bjoernalbers/aruba-doubles | /lib/aruba-doubles/double.rb | UTF-8 | 4,641 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module ArubaDoubles
class Double
# Keeps track of registered doubles.
@doubles = {}
class << self
attr_reader :doubles
# Setup the doubles environment.
def setup
patch_path
end
# Teardown the doubles environment.
def teardown
delete_all
rest... | true |
f7e8f78bcb6546ac180d33685253ff8c3c54dc9f | Ruby | spadin/bowling_game | /lib/game.rb | UTF-8 | 1,075 | 3.546875 | 4 | [] | no_license | module Bowling
class Game
def initialize
@current_index = 0
@rolls = Array.new(21) { 0 }
end
def roll(pins)
@rolls[@current_index] = pins
@current_index += 1
end
def score
score = 0
frame_index = 0
10.times do |frame|
if is_strike? frame_index
... | true |
f784a5de32ae92b60f0dfa122c345aa861dc5b69 | Ruby | alexperez2160/launch_school | /test_prep/more_ruby/anagram/anagram.rb | UTF-8 | 787 | 3.8125 | 4 | [] | no_license | class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(arr)
original_word_arr = word.downcase.split("")
result_array = []
# prelim checks to remove same words or words that aren't the same size
arr.delete_if{|new_word| new_word.size != word.size || new_wor... | true |
d939c3cab4b7b72bd0b110b234c063669e10dee9 | Ruby | ymgn/Intern_task | /app/controllers/users_controller.rb | UTF-8 | 4,283 | 2.5625 | 3 | [] | no_license | class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.all
end
# GET /users/1
# GET /users/1.json
def show
# ログイン中のユーザー
@current_user = current_user
# プロフィールを開かれているユーザー
us... | true |
d292326d9d68eaa5c87e91e585e70563ada0113b | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/785.is-graph-bipartite.rb | UTF-8 | 1,670 | 3.5625 | 4 | [] | no_license | #
# @lc app=leetcode id=785 lang=ruby
#
# [785] Is Graph Bipartite?
#
# https://leetcode.com/problems/is-graph-bipartite/description/
#
# algorithms
# Medium (47.59%)
# Total Accepted: 127.1K
# Total Submissions: 267K
# Testcase Example: '[[1,3],[0,2],[1,3],[0,2]]'
#
# Given an undirected graph, return true if and ... | true |
ca6fafcfa06ba0b196526751fffa2079a1ee11d9 | Ruby | ajensenwaud/bsdhorse | /bot.rb | UTF-8 | 3,026 | 2.96875 | 3 | [] | no_license | require 'cinch'
require 'open-uri'
require 'nokogiri'
require 'cgi'
class HelloBot
include Cinch::Plugin
USAGE = "Says hello"
match "hello"
def execute(m)
m.reply "Hello, #{m.user.nick} - how are you?"
end
end
class Echo
include Cinch::Plugin
match /echo (.*)/
USAGE = "Echoes text back to you. Ex... | true |
d2b629ba14891e50269c1f0b68d15fae3019ee30 | Ruby | sanledi-buli/Ruby | /array_test.rb | UTF-8 | 482 | 3.578125 | 4 | [] | no_license | class ArrayMix
ARRAY = [44,200,231,23333,773,975,3,89,92,77]
def array_list #list of array
ARRAY.each do |value|
puts value
end
puts "--------------------------------------------"
end
def array_sort_reverse
end
def ganjil
ARRAY.each do |value|
if value%2 != 0
puts value
end
end
end
def... | true |
36dd7b3820f38646b1ce46db38bf6855b0a4e2ec | Ruby | brnrdog/gcm_media | /app/models/course.rb | UTF-8 | 420 | 2.8125 | 3 | [] | no_license | class Course < ActiveRecord::Base
before_save :update_status
enum status: ["aprovado", "reprovado", "em recuperação"]
def get_avarage
(self.first_unity + self.second_unity + self.third_unity)/3.0
end
def update_status
if get_avarage < 3.0
self.status = 'reprovado'
elsif get_avarage < 5.0
... | true |
f8803fe57fa090668e3a6c9aa1d5083186e48699 | Ruby | justin071203/project-euler-largest-prime-factor-q-000 | /lib/largest_prime_factor.rb | UTF-8 | 276 | 3.5 | 4 | [] | no_license | # Enter your procedural solution here!
def is_prime?(n)
return false if n <= 1
(2..(Math.sqrt(n))).all? {|z| n % z != 0}
end
def prime_factors(n)
(1..(Math.sqrt(n))).select {|p| is_prime?(p) && n % p == 0}
end
def largest_prime_factor(n)
prime_factors(n).max
end
| true |
6725f0aec79c74b9b0be812fcfa77afb06290e02 | Ruby | glenjamin/see-less-ess-ess | /lib/see-less-ess-ess.rb | UTF-8 | 4,581 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'set'
require 'sass'
require 'nokogiri'
module SeeLessEssEss
class Extractor
def initialize(glob)
@glob = glob
@extracted = false
end
def css_classes
extract_if_needed
@css_classes
end
def html_tags
extract_if_needed
@html_tags
end
protected... | true |
fbccb83c22aa2b2ca774a5968c47bf536c5c60e6 | Ruby | skorfmann/search_quality | /lib/page_number.rb | UTF-8 | 169 | 2.671875 | 3 | [] | no_license | require 'singleton'
class PageNumber
include Singleton
def initialize
@count = 0
end
def next
@count += 1
end
def reset
@count = 0
end
end
| true |
ec7af77d6fd02f69e503a284f12679816e037902 | Ruby | 15jramirez/countdown-to-midnight-onl01-seng-pt-081720 | /countdown.rb | UTF-8 | 277 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def countdown (number)
while number!=0
puts "#{number} SECOND(S)!"
number-=1
end
return "HAPPY NEW YEAR!"
end
def countdown_with_sleep (number)
while number!=0
puts "#{number} SECOND(S)!"
sleep(1)
number-=1
end
retun "HAPPY NEW YEAR"
end
| true |
be5c5df953de12c6d4196385a4ec92764d318641 | Ruby | s-sasaki-0529/pankara_v2 | /app/models/validators/event_validators.rb | UTF-8 | 568 | 2.6875 | 3 | [] | no_license | class EventValidators < ActiveModel::Validator
def validate(record)
@record = record
if date_blank?
record.errors[:date] << '日付は必須です'
elsif date_invalid?
record.errors[:date] << '日付が不正な文字列です'
elsif date_future?
record.errors[:date] << '未来の日付は設定できません'
end
end
private
def ... | true |
a561d47d1ccad2531312651bd56324934ef762df | Ruby | zuozuo/shoes4 | /lib/shoes/text_block.rb | UTF-8 | 1,440 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'shoes/common_methods'
module Shoes
class TextBlock
include Shoes::CommonMethods
attr_reader :gui, :parent, :text
attr_accessor :font, :font_size, :width, :height, :left, :top
def initialize(parent, text, font_size, opts = {})
@parent = parent
@font = 'sans'
@font_size = ... | true |
41894e3be213b902c380db6c0f6aca90291c6418 | Ruby | jfhinchcliffe/CoderFactoryAcademy2016Notes | /Coderfactory_Notes/exercises/projects/hotel_booking/lib/menu.rb | UTF-8 | 1,231 | 3.234375 | 3 | [] | no_license | require './hotel_booking'
require './hotel'
require 'colorize'
def main_menu
exit = false
until exit
puts "Welcome to HotelBooker".blue
puts "==" * 12
puts "1. See all hotels 📔 "
puts "2. Book Hotel 🛌 "
puts "3. Add Hotel 🏠 "
puts "4. Settle Bill 💳 "
puts "5. Exit the program ❌ "
... | true |
bb8c4539e55b7f970faf32ca63761985fd719408 | Ruby | vzaffalon/checkout-api | /app/models/order_item.rb | UTF-8 | 350 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | class OrderItem < ActiveRecord::Base
belongs_to :order
belongs_to :item
validates_presence_of :item_id, :quantity
before_create :set_price
before_create :set_total_amount
def set_price
self.price = self.item.price
end
def set_total_amount
self.total_amount = self.pric... | true |
ea39d1ec21f169ff7d5e73f87ea5c39041782029 | Ruby | enginbulut/ruby-playground | /methods_and_conditionals/default_or_optional_parameters.rb | UTF-8 | 215 | 3.109375 | 3 | [] | no_license | def make_a_phone_call(number, international_code = 1, area_code = 646)
puts "Calling the number #{international_code}-#{area_code}-#{number}"
end
make_a_phone_call(123_456_789)
make_a_phone_call(123_456_789, 4)
| true |
d9bb894e8b33df4a7c0633dc4d037e5cba5c4d56 | Ruby | kidbrax/rets4r | /lib/rets4r/client/exceptions.rb | UTF-8 | 4,645 | 2.625 | 3 | [
"MIT",
"Ruby"
] | permissive | module RETS4R
class Client
# This exception should be thrown when a generic client error is encountered.
class ClientException < Exception; end
# This exception should be thrown when there is an error with the parser, which is
# considered a subcomponent of the RETS client. It also includes the XML d... | true |
670678fe12285ce895c10eb43fd36463f0b6ee17 | Ruby | mikekibz59/ruby-practice-codes | /number.rb | UTF-8 | 206 | 3.96875 | 4 | [] | no_license | class Number
def initialize(x)
x=@x
end
def even?
if @x %1==0 && @x.to_i.even?
puts "this is an even number"
else
puts "this is an odd number"
end
end
end
number=Number.new(5)
number.even? | true |
b04bf565b6a10327ed09794c44a8f1ce3cd006b4 | Ruby | jeremyevans/roda | /lib/roda/plugins/indifferent_params.rb | UTF-8 | 4,226 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
#
class Roda
module RodaPlugins
# The indifferent_params plugin adds a +params+ instance
# method which offers indifferent access to the request
# params, allowing you to use symbols to lookup values in
# a hash where the keys are strings. Note that while this
# all... | true |
6bfd73f1b19b314f66eb868d5a3fd0956673a765 | Ruby | raaynaldo/cli-applications-jukebox-wdc01-seng-ft-100520 | /lib/jukebox.rb | UTF-8 | 1,368 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add your code here
def help
puts "I accept the following commands:"
puts "- help : displays this help message"
puts "- list : displays a list of songs you can play"
puts "- play : lets you choose a song to play"
puts "- exit : exits this program"
end
def list(songs)
songs.each_with_index{ |val,index|
... | true |
ab525d9abce1b35b08b24bd3a1118092350de8ab | Ruby | willmomo/ry2kojima | /scripts/ruby/kanji.rb | UTF-8 | 428 | 3.046875 | 3 | [] | no_license | require 'kconv'
class String
def hex2bin
s = self
raise "Not a valid hex string" unless(s =~ /^[\da-fA-F]+$/)
s = '0' + s if((s.length & 1) != 0)
s.scan(/../).map{ |b| b.to_i(16) }.pack('C*')
end
def bin2hex
self.unpack('C*').map{ |b| "%02X" % b }.join('')
end
end
puts ARGV[0]
puts ARGV[0].match(/messa... | true |
b4fca8de6c6fdcb10858a2b93fd23b69e02c1389 | Ruby | mdr-uma/js-rails-as-api-rendering-different-content-types-using-rails-onl01-seng-pt-110319 | /app/controllers/birds_controller.rb | UTF-8 | 645 | 2.78125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class BirdsController < ApplicationController
def index
birds = Bird.all #now we are directly rending to josn in the same action, we no longer need to deal with instance variables.
# @birds = Bird.all
# render plain: "Hello #{@birds[3].name}"
# render 'birds/index.html.erb'
# render json: 'Remembe... | true |
3318eed3d0080ab3b1b9ad9b463599d286d93f6f | Ruby | jressey/polynomial_formatter | /polynomial.rb | UTF-8 | 750 | 3.546875 | 4 | [] | no_license | class Polynomial
@coefficient_list
PLUS = '+'
MINUS = '-'
def initialize(coefficients)
raise ArgumentError, 'Need at least 2 coefficients' unless coefficients.size > 2
@coefficient_list = coefficients
end
def to_s
return '0' if ! @coefficient_list.any? { |c| c != 0 }
@strang = String.new
@coefficien... | true |
0f6e6c3b00e52d0c8cffa86461b8be3a967d99f8 | Ruby | eiel/rurema_review | /Kernel_module_method/src/array.rb | UTF-8 | 283 | 3.015625 | 3 | [] | no_license | class ArraySample1
def to_a
[:to_a]
end
def to_ary
[:to_ary]
end
end
class ArraySample2
def to_a
[:to_a]
end
end
# to_aryが反応する
Array(ArraySample1.new) # => [:to_ary]
# to_aryが反応しない
Array(ArraySample2.new) # => [:to_a]
| true |
0299f090d9fcfd38dc8f72e89b1c072f7dccf1b9 | Ruby | Daikichi1223/furima-29351 | /spec/models/user_spec.rb | UTF-8 | 4,541 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
describe User do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録がうまくいく時' do
it "nicknameとemail、password、last_name、first_name、last_name_ruby、first_name_rubyとbirthdayが存在すれば登録できる" do
expect(@user).to be_valid
end
end
cont... | true |
461aae354ac04c98404742c7d6f9258f5d918386 | Ruby | SebastianEdwards/aggro | /lib/aggro/event_serializer.rb | UTF-8 | 361 | 2.71875 | 3 | [
"MIT"
] | permissive | module Aggro
# Public: Converts events to and from serialized data.
module EventSerializer
module_function
def deserialize(serialized)
Event.new(serialized[0], Time.parse(serialized[1]), serialized[2])
end
def serialize(deserialized)
[deserialized.name, deserialized.occured_at.iso8601,... | true |
d84cca4a4d678ae7cde6c1d2756193f4797522af | Ruby | dgutt17/movie_db_api | /app/services/batch_create/relationships/categorized_as.rb | UTF-8 | 1,636 | 2.578125 | 3 | [] | no_license | # require 'query_methods'
# require 'labels'
module BatchCreate
module Relationships
class CategorizedAs
include Neo4j::QueryMethods
include ImporterParsingMethods
attr_reader :movie_relationships, :tv_show_relationships
def initialize
@movie_relationships = []
... | true |
691fcea8ff7b6206f7133aca847c4a3b94f33166 | Ruby | Anchanto/mws | /lib/mws/errors.rb | UTF-8 | 591 | 2.515625 | 3 | [
"MIT"
] | permissive | module Mws::Errors
class Error < RuntimeError
end
class ServerError < Error
attr_reader :type, :code, :message, :details
def initialize(options)
@type = options[:type] || 'HTTP'
@code = options[:code]
@message = options[:message]
@details = options[:details] || options[:detail... | true |
6050156906b407c79c940e37d1b5caeaffe74490 | Ruby | YusukeYoshida8849/tbpgr_utils | /lib/open_classes/string/ascii_unicode_table.rb | UTF-8 | 877 | 3.078125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'open_classes/numeric/is_ascii'
require 'open_classes/string/justify_table'
require 'open_classes/string/ascii1_other2_size'
# String
class String
# get ascii_unicode_table
#
# === Example
#
# input
# 'aあb'
#
# result
#
# |char|ASCII|ascii2 |Unicode|
# | a | 97 |... | true |
6bb9e8ae4a1940e73d146bea93c4d93e0ba29179 | Ruby | nsivabalan/big-o | /ruby/src/sorting/heap_sort.rb | UTF-8 | 1,670 | 3.515625 | 4 | [] | no_license | require_relative '../common/array_utils'
module Sorting
class << self
def heap_sort(array, &comparator)
array = heapify_all(array, &comparator)
array.length.downto(2) do |length|
ArrayUtils.swap(array, 0, length - 1)
array = heapify(array, 0, length - 1, &comparator)
end
... | true |
dab8e793eef5ff1eed66b664dc7ba7003f4bfa78 | Ruby | codeisawesome/ruby_fundamentals1 | /exercise4.rb | UTF-8 | 165 | 3.203125 | 3 | [] | no_license | i = 1
while i < 100
if i % 15 == 0
puts "BitMaker"
elsif i % 3 == 0
puts "Bit"
elsif i % 5 == 0
puts "Maker"
else
puts i
end
i += 1
end
| true |
01bee56e78b6b4a3a7684586f8500c30644cef43 | Ruby | tb0yd/rebar | /lib/brer/erlang_process.rb | UTF-8 | 3,356 | 2.90625 | 3 | [] | no_license | require 'rubygems'
require 'socket'
require 'json'
module Brer
class ErlangTimeoutError < StandardError; end
class UnretraceableStateError < StandardError; end
class ErlangProcess
def initialize(name, target_class=nil)
raise ArgumentError.new if target_class.nil? && !block_given?
raise ArgumentEr... | true |
7825f5c1a2b77f37955346e78787a081d367d6df | Ruby | meganraec/square_array-v-000 | /square_array.rb | UTF-8 | 148 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | numbers = [1,2,3]
def square_array(array)
squared = Array.new
array.each {|n| squared << (n ** 2)}
return squared
end
square_array(numbers)
| true |
7398a41b1428ca5cfe56b4b73960bcc0dbb25da1 | Ruby | dawnhell/ruby-fake-name-generator | /generator.rb | UTF-8 | 4,257 | 3.125 | 3 | [] | no_license | def openLocaleFile fileName
data={}
i=0
File.readlines(fileName).map do |line|
arr=line.to_s.gsub("\n", "").gsub("\r", "")
data[i]=arr
i=i+1
end
return data
end
locale=ARGV[0]
puts locale
counter=ARGV[1].to_i
mistakeChance=ARGV[2] ? (ARGV[2].to_f >= 0 ? ARGV[2].to_f : (raise 'Number of mistakes m... | true |
3961e3d403929ea63d0a22b7c58834f02194476e | Ruby | aasimalee/my_books | /Full Stack Web Developer/11 - Programming with Ruby/06 - boolean-logic-and-boolean-operators/exercises-and-code/bool.rb | UTF-8 | 1,277 | 4.125 | 4 | [] | no_license | # File bool.rb
#
a = false
b = false
result = a && b # && if for boolean AND
puts "(#{a} AND #{b}) Result: #{result}" # is going to print that the result is false.
b = true
result = a && b
puts "(#{a} AND #{b}) Result: #{result}" # is going to print that the result is false.
a = true
result = a && b
puts "(#{a} AND #... | true |
17886dc2897d07533e27029371b953e27da05394 | Ruby | emanon001/atcoder-ruby | /abc036/b/main.rb | UTF-8 | 117 | 2.9375 | 3 | [] | no_license | N = gets.to_i
board = N.times.map { gets.chomp.chars }
board.transpose.each do |row|
puts row.reverse.join('')
end
| true |
17a5643d71fab7f556df0fba0ccd95a2d042be74 | Ruby | jackc/dailyprogrammer | /c328_subset_sum_automata/ruby/ssa.rb | UTF-8 | 3,188 | 3.3125 | 3 | [] | no_license | class World
attr_reader :cells, :width, :height
def initialize(width, height)
@cells = Array.new(width*height) { 0 }
@width = width
@height = height
end
def idx_from_coord(x, y)
x = x % width
y = y % height
y*width + x
end
def get(x, y)
cells[idx_from_coord(x, y)]
end
de... | true |
0f794729b5131367f3e7adcd6ed6cee63fa0a47e | Ruby | stevejk31/app_academy | /w3d2/question_like.rb | UTF-8 | 2,176 | 2.71875 | 3 | [] | no_license | require_relative 'questions_database'
require_relative 'user'
class QuestionLikes
def self.all
results = QuestionsDatabase.instance.execute('SELECT * FROM question_likes')
results.map { |result| QuestionLikes.new(result) }
end
def self.find_by_id(input_id)
reply_hash = QuestionsDatabase.instance.exec... | true |
eef081d3d05bfb88ead037c08072c60343588f05 | Ruby | jgnagy/antaeus-api | /lib/string.rb | UTF-8 | 714 | 3.5 | 4 | [
"MIT"
] | permissive | require 'base64'
# Monkey-patching the String class to include useful operations
class String
# Convert a string to a Base64 encoded version of itself
# @return [String]
def to_64
Base64.encode64(self).chomp.gsub("\n", '')
end
# Decode a Base64 encoded string
# @return [String]
def decode64
Base... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.