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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26bf8db70ccebd3548310bafbd7830c6ec689542 | Ruby | Mcas4150/Mcas4150 | /reboot/calculator/interface.rb | UTF-8 | 394 | 3.515625 | 4 | [] | no_license | require_relative "calculator"
puts "hello welcome to the calculator"
first_number= nil
loop do
puts "Enter a first number:"
first_number = gets.chomp
break if first_number == ""
puts "Enter a second one:"
second_number = gets.chomp.to_i
puts "Which operation [+ , - , * , /]"
operator = gets.chomp
pu... | true |
d882c852ee00488bc6a04305ef2094a88c51dad7 | Ruby | thelmaboamah/ruby-method-drills | /starter-code/arguments.rb | UTF-8 | 965 | 3.828125 | 4 | [] | no_license | #########################
#### USING ARGUMENTS ####
#########################
#say_hello
# returns 'hello'
def say_hello
"hello"
end
#echo
# returns the input string
def echo (str)
str
end
#eddie_izzards_height
# calculates and returns Eddie Izzard's height
# takes in the height of heels he's wearing (def... | true |
9ed5c646264cc95a02d435f083bcf675f42ba838 | Ruby | j31/rails-longest-word-game | /app/controllers/longest_word_controller.rb | UTF-8 | 1,041 | 2.765625 | 3 | [] | no_license | class LongestWordController < ApplicationController
def game
grid_size = params[:size]
@grid = (0...grid_size.to_i).map { (65 + rand(26)).chr }
end
def score
start = params[:start].to_i
stop = Time.now.to_i
grid = params[:grid].split(',')
@attempt = params[:guess]
# calculate elaps... | true |
908f343fd5cd224d659702e8ae66e10d7b119cf2 | Ruby | meetri/railstest | /vendor/plugins/cancan/lib/cancan/model_adapters/mongoid_adapter.rb | UTF-8 | 1,835 | 2.53125 | 3 | [
"MIT"
] | permissive | module CanCan
module ModelAdapters
class MongoidAdapter < AbstractAdapter
def self.for_class?(model_class)
model_class <= Mongoid::Document
end
def database_records
@model_class.where(conditions)
end
def conditions
if @rules.size == 0
false_query
... | true |
487980e2e4c21e7d68b2c06bd2e399ddc7159642 | Ruby | suhas2603/automation-gilded-rose | /lib/google_shopping.rb | UTF-8 | 1,098 | 2.65625 | 3 | [] | no_license | require 'capybara/dsl'
class GoogleShopping
include Capybara::DSL
def verify_search(string)
elements = all('div.pslline')
case "string"
when 'marmite'
elements.each do |element|
unless element.text =~ /Marmite/
fail
end
end
end
end
def verify_... | true |
a4ff910dcb964e17dc61de734ba52366cd905e4e | Ruby | cloneko/quiz | /main.rb | UTF-8 | 1,037 | 2.75 | 3 | [] | no_license |
pwd = File.dirname(__FILE__)
$LOAD_PATH << pwd
require "readline"
require 'Quiz/CsvQuestion.rb'
require 'Quiz/FileScoreManager.rb'
# Username Check
username = ENV['LOGNAME'] == '' ? '' : ENV['LOGNAME']
if(username == '')
then
print 'Prease input your name: '
Readline.readline
end
#q = CsvQuestion.new(pwd + '... | true |
40166173c39c0de604b7a27f98c3962fdd4039bd | Ruby | kawaura-dai/furima-29631 | /spec/models/item_spec.rb | UTF-8 | 2,883 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
user = FactoryBot.create(:user)
@item = FactoryBot.build(:item, user_id: user.id)
end
describe '出品確認' do
it '空白がないと出品可' do
expect(@item).to be_valid
end
it 'imageがないと出品不可' do
@item.image = nil
@item.vali... | true |
dc2bb3bf11b78a500ae995922a36ae1a5dc842ea | Ruby | dam354/intro_to_ruby | /09. Exercises/03.rb | UTF-8 | 283 | 4.3125 | 4 | [] | no_license | # Use the each method of Array to iterate over [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
# and print out each value
# but only print out values greater than 5.
test_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
odd_array = []
odd_array = test_array.select do |num|
num.odd?
end
puts odd_array | true |
fbf2db2c489adf5e3fa0856d9ac393c4c5119140 | Ruby | woobaik/Alorithm_Practice | /hackerrank/time_conversion.rb | UTF-8 | 300 | 3.125 | 3 | [] | no_license | def timeConversion(s)
arr = s.split(':')
if arr.last[2..-1] == 'AM' && arr.first == '12'
arr[0] = '00'
elsif arr.last[2..-1] == 'PM' && arr.first == '12'
arr[0] = '12'
elsif arr.last[2..-1] == 'PM'
arr[0] = arr[0].to_i + 12
end
arr.join(':')[0...-2]
end | true |
d1c1bd5667ae75c77511ba964d21978c2b183998 | Ruby | Team-Tomato/Learn | /sreehariharan/fetchdatafromapi.rb | UTF-8 | 930 | 3.015625 | 3 | [] | no_license | require 'net/http'
require 'json'
url = 'https://teamtomato.herokuapp.com/api/v1/question'
req = URI(url)
response = Net::HTTP.get(req)
result=JSON.parse(response)
=begin
result.each do |data|
puts "id:#{data['id']}, shortForm:#{data['shortForm']}, staffname:#{data['staff']}, subjectname:#{data['subjectName']}, Url:#{... | true |
f15f2f6ea8fc0872e4e3f8466136b54df402a079 | Ruby | joshski/gdocs-features | /lib/remote_features/dialogue.rb | UTF-8 | 793 | 2.71875 | 3 | [] | no_license | require 'feature_diff'
module RemoteFeatures
class Dialogue
def initialize(input, output, local_store, remote_store)
@input, @output, @local_store, @remote_store = input, output, local_store, remote_store
end
def start
diff = FeatureDiff.new(@local_store, @remote_store)
differences... | true |
7a457660d36b3238ad8e66381c73a1a6030e5795 | Ruby | eva-barczykowska/Ruby | /Overwrite_to_s_Method.rb | UTF-8 | 650 | 3.390625 | 3 | [] | no_license | class Gadget
def initialize
@username = "User #{rand(1..100)}"
@password = "topsecret"
@production_number = "#{("a".."z").to_a.sample} - #{rand(1..99)}"
end
def to_s
"Gadget #{@production_number} has the username #{@username}"
end
end
phone = Gadget.new
#puts phone.methods
puts
puts
puts... | true |
12ab644a48b431bd51d475d2ba60e0b001d87cea | Ruby | anders1216/countdown-to-midnight-prework | /countdown.rb | UTF-8 | 300 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def countdown(num_secs)
while num_secs > 0
puts "#{num_secs} SECOND(S)!"
num_secs -= 1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(num_secs)
sleep(5)
while num_secs > 0
puts "#{num_secs} SECOND(S)!"
num_secs -= 1
end
"HAPPY NEW YEAR!"
end
| true |
f8979634da4fc2c63894422b26dca863da8ea074 | Ruby | pawel2105/exercism-challenges | /ruby/sieve/sieve.rb | UTF-8 | 218 | 3.03125 | 3 | [] | no_license | require 'prime'
module BookKeeping
VERSION = 1
end
class Sieve
def initialize num
@num = num
end
def primes
primes_array = []
Prime.each(@num) { |p| primes_array << p }
primes_array
end
end | true |
3a5399d31c86a025767450a898f8a3dd257ef907 | Ruby | azimux/ax_lib | /lib/azimux/css_val.rb | UTF-8 | 1,223 | 3.109375 | 3 | [
"MIT"
] | permissive | module Azimux
class CssVal
attr_reader :magnitude, :units
public
def initialize(*vals)
if vals.size == 1
c = to_css_val(vals[0])
vals = [c.magnitude, c.units]
end
@magnitude, @units = vals
end
def to_s
magnitude.to_s + units
end
def self.extract_... | true |
8078fc61467cf6ba828e673ae2eb251f6f59749a | Ruby | SarvarKh/Customized-Linter | /bin/main.rb | UTF-8 | 693 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'cli-colorize'
require_relative '../lib/error_scanner'
# JS linter class with multiple linter check methods
class JSLinter
def initialize(file)
@file = file
puts 'JS_Linter is being initialized... '
@error_scanner = ErrorScanner.new(@file)
end
# process the linter test
def process
puts... | true |
40e0ee17be1adfbeb641449ab39143bc078becb4 | Ruby | BarnabeD/MaSeance-Scrapper | /scrapper_list.rb | UTF-8 | 1,716 | 2.9375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'json'
# require_relative 'scrapper_personnal'
def list_scrapper(card)
array = []
search_name = card.search('.CardSearch-name')
name_array = name_scrapper(search_name)
raw_job = card.search('.CardSearch-job').text
adress_arr = adress_scrapper(card)
array << {
... | true |
c51c6051e80bfcff365ae95777664286003866cf | Ruby | PhilippePerret/bin-vite-faits | /lib/modules/videos/crop.rb | UTF-8 | 9,150 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
=begin
Module de raccourcissement des vidéos et des sons
Ajout de nouveaux fichiers
--------------------------
Pour ajouter de nouveaux fichiers, on doit définir
- une lettre pour les choisir
- ajouter ses données à la constante DATA_CROPPABLE_FILES
ci-dessous, tout le reste ser... | true |
bf5ba04c170e2a4fb26563535d6044fe266408af | Ruby | svslight/ruby-basics | /lesson2/day_year.rb | UTF-8 | 500 | 3.828125 | 4 | [] | no_license | print 'Введите число: '
day = gets.to_i
print 'Введите номер месяца: '
month = gets.to_i
print 'Введите год: '
year = gets.to_i
if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
days_in_february = 29
else
days_in_february = 28
end
days_in_month = [31, days_in_february, 30, 31, 30, 31, 30, 31, 30, 31, 30]
... | true |
474e3dd13025bb35fd88e97a99d52b366e8668f2 | Ruby | tani8/survey_chimp | /app/helpers/sessions.rb | UTF-8 | 263 | 2.546875 | 3 | [
"MIT"
] | permissive | helpers do
def login(creator)
session[:id] = creator.id
end
def logout
session[:id] = nil
end
def logged_in?
!current_creator.nil?
end
def current_creator
@current_creator ||= Creator.find(session[:id]) if session[:id]
end
end
| true |
565aa1d86d92837a0d8e187a0777038a5e3bc9ad | Ruby | ahcarlos/Seguridad-Sistemas-Informaticos-1617 | /practica-10/main.rb | UTF-8 | 1,086 | 2.90625 | 3 | [] | no_license |
loop do
puts
puts '-----Menú con las prácticas de Seguridad en Sistemas Informáticos-----'
puts 'Las prácticas incluyen las modificaciones'
puts 'Opciones soportadas:'
puts '[0].Salir'
puts '[1].Vernam'
puts '[2].Vigenere'
puts '[3].RC4'
puts '[4].A5/1'
puts '[5].Algoritmo Rijndael'
puts '[6].Alg... | true |
ac57f8361596c652e894f47c54547074c4ef99b4 | Ruby | johneckert/GOTApi | /app/models/character.rb | UTF-8 | 1,405 | 3.078125 | 3 | [] | no_license | class Character < ApplicationRecord
def self.dead_by_gender
dead_characters = Character.where(dead: true)
gender_split = {male: 0, female: 0 }
dead_characters.each do |char|
if char.gender == "Male"
gender_split[:male] += 1
elsif char.gender == "Female"
gender_split[:female] +... | true |
2425a2063c3066d1f0d8e05891e9a735ee12dd41 | Ruby | fred75013/tic_tac_toe | /lib/app/game.rb | UTF-8 | 2,821 | 3.484375 | 3 | [] | no_license | class Game
attr_accessor :player_1, :player_2
def initialize
system('clear')
puts " ========================= WELCOME ========================= ".light_blue.bold
puts "| |".light_blue.bold
puts "| T I C ░ T A C ░ T O E ... | true |
0db410872d6a4d5f483bad3c89e986e9dcbfc3f1 | Ruby | Cheng0315/swift-kart | /app/helpers/items_helper.rb | UTF-8 | 2,554 | 2.75 | 3 | [
"MIT"
] | permissive | module ItemsHelper
#find quantity if items in cart
def item_quantity(item, cart)
@cart_item = CartItem.find_by(cart_id: cart.id, item_id: item.id)
@cart_item.quantity
end
#find status of an item
def item_status(item, cart)
@cart_item = CartItem.find_by(cart_id: cart.id, item_id: item.id)
if... | true |
c85bd543d4b7973ece0303ae07e6dcc5d17bd9b5 | Ruby | LukasErekson/OdinRubyProjects | /mastermind/code_error.rb | UTF-8 | 323 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Problem with proposed code for MasterMind.
class CodeError < RangeError
def initialize(required_length = 4, valid_colors = %w[R O Y G B I V])
super("A code sequence is a string of #{required_length} color "\
"characters from the following list: #{valid_colors}.")
end
e... | true |
743bba4900e9540f907106a0d4361727d2745389 | Ruby | Rounded/CodeBase | /ruby/google.rb | UTF-8 | 2,423 | 2.703125 | 3 | [] | no_license | class Google
class Authorization
def self.build_auth_url(return_url)
# The URL of the page that Google should redirect the user to after authentication.
return_url = return_url
# Indicates that the application is requesting a token to access contacts feeds.
scope_param = "http://www.google.com/m8/feeds/... | true |
2611757ad4669fd30369b5bdf598e26e65b7ee3a | Ruby | aabbcc456aa/lovelou | /vendor/plugins/ruby/1.9.1/gems/sass-3.1.16/vendor/listen/lib/listen/directory_record.rb | UTF-8 | 7,920 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'set'
require 'find'
require 'pathname'
require 'digest/sha1'
module Listen
# The directory record stores information about
# a directory and keeps track of changes to
# the structure of its childs.
#
class DirectoryRecord
attr_reader :directory, :paths, :sha1_checksums
# Default paths' beg... | true |
670e865f9a35dad67e9889aec4ee942b97849d5e | Ruby | ernsykamethelus/countdown-to-midnight-onl01-seng-pt-081720 | /countdown.rb | UTF-8 | 1,002 | 4.59375 | 5 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #Fork and clone this lab.
#Open it in your IDE and run the test suite. You'll be coding your solution in countdown.rb
#Write a method that takes in an integer argument and uses a while loop to countdown from that integer to 0, outputting "#{number} SECOND(S)!" in each iteration of the loop. The method should return "HA... | true |
d7c3d54d50dfc9fef2f78ccaea3b03557d1ccf50 | Ruby | Hirosvk/99cats | /app/models/cat_rental_request.rb | UTF-8 | 1,823 | 2.703125 | 3 | [] | no_license | require 'byebug'
class CatRentalRequest < ActiveRecord::Base
STATUS = ["Pending", "Approved", "Denied"]
validates :status, inclusion: STATUS
validates :status, :cat_id, :start_date, :end_date, presence: true
after_initialize :set_status
validate :valid_request
belongs_to :cat,
primary_key: :id,
f... | true |
b8ebb42118577c62c670c3ebd0c1800769d930f9 | Ruby | kellyarwine/mastermind_more_novice | /lib/secret_code_generator.rb | UTF-8 | 189 | 2.890625 | 3 | [] | no_license | class SecretCodeGenerator
def secret_code
code = []
5.times do
code << available_symbols.sample
end
code
end
def available_symbols
["b", "g", "r", "y", "p", "o"]
end
end | true |
9cbbec3423b7ca1034a045ae6920d5289febdc4c | Ruby | codeforamerica/michigan-benefits | /app/services/feedback_ratings_calculator.rb | UTF-8 | 597 | 2.71875 | 3 | [
"MIT"
] | permissive | class FeedbackRatingsCalculator
def initialize(applications)
@apps_with_feedback = applications.where.not(feedback_rating: "unfilled")
end
def percentage(category)
apps_of_type = apps_with_feedback.where(feedback_rating: category)
((apps_of_type.count.to_f / apps_with_feedback.count.to_f) * 100).rou... | true |
4989cea5ee0e2518a4af1059f854be5bda8d0460 | Ruby | BinaryBlitz/sportup | /app/models/vote.rb | UTF-8 | 996 | 2.515625 | 3 | [] | no_license | # == Schema Information
#
# Table name: votes
#
# id :integer not null, primary key
# user_id :integer
# event_id :integer
# voted_user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Vote < ApplicationRecord
belongs_to :u... | true |
3e57df9092c8d6ecd0f014a9fae64bb163bd5243 | Ruby | radiospiel/simple_cache | /lib/simple_cache.rb | UTF-8 | 3,579 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "uri"
require "expectation"
module SimpleCache
end
require_relative "simple_cache/marshal"
require_relative "simple_cache/memcached_store"
require_relative "simple_cache/pg_store"
require_relative "simple_cache/sqlite_store"
require_relative "simple_cache/redis_store"
require_relative "simple_cache/null_stor... | true |
a9d2e7822a35b9a180e5a9dd8f921bba8e9ea53e | Ruby | AmilMasic/fine_woodworking | /lib/fine_woodworking/scraper.rb | UTF-8 | 1,201 | 3.140625 | 3 | [
"MIT"
] | permissive | class FineWoodworking::Scraper
def self.scrape_articles
#scraping the articles starts here
#using each because the articles have the same class hp__featured__story
# @@articles = []
doc = Nokogiri::HTML(open("https://www.finewoodworking.com/"))
doc.css(".hp__featured__story").each do |article|
... | true |
a95232abe343d3d1fcedf4c8303dce24d3ce62a9 | Ruby | shurique/reserv_test | /app/models/reservation.rb | UTF-8 | 609 | 2.578125 | 3 | [] | no_license | class Reservation < ActiveRecord::Base
validates_presence_of :start_time, :end_time, :table
validate :double_reservation?, on: [:create, :update]
scope :overlap, lambda { |new_reservation|
where(table: new_reservation.table)
.where.not(id: new_reservation.id)
.where('(start_time <= ?) AND (? <= ... | true |
b11189b1310d0264efcb6653649f4cd931155c2c | Ruby | jbe/vocco | /lib/vocco/generator/source_file.rb | UTF-8 | 1,598 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
class Vocco::Generator::SourceFile
require 'vocco/generator/source_file/html_template'
NOTE_FORMATS = '.{textile,md,mkd,markdown,rdoc}'
def initialize(file, generator)
@file = file
@gen = generator
end
attr_reader :file # full file path
# full dirname
def dirname
File.dirna... | true |
3d5aa32282cf6c1ac7667743cc296ec086a75737 | Ruby | katalkinaviktoria/project | /app/models/person.rb | UTF-8 | 1,611 | 2.828125 | 3 | [] | no_license | class Person < ActiveRecord::Base
has_one :student, dependent: :destroy
accepts_nested_attributes_for :student
has_one :workman, dependent: :destroy
accepts_nested_attributes_for :workman
has_one :relative, dependent: :destroy
accepts_nested_attributes_for :relative
has_one :guest, dependent: :destroy
... | true |
301511704610859040b60a59a7e01f7d7ee46639 | Ruby | noscripter/githubranking | /lib/loggable.rb | UTF-8 | 204 | 2.5625 | 3 | [
"MIT"
] | permissive | module Loggable
private
def logger
@logger ||= Logger.new(log_filename)
end
def log_filename
klass_name = File.basename(self.class.to_s.underscore)
"log/#{klass_name}.log"
end
end
| true |
3d1bd14e481475ee9932156fc7b602a776834eb7 | Ruby | ikiru/rubybasic | /basic_13.rb | UTF-8 | 525 | 4.21875 | 4 | [] | no_license | # Print 1-255
(1..250).each { |n| puts n }
# Print odd numbers between 1-255
(1..250).step(2) { |n| puts n }
# Print Sum
# 0.upto(250) {|i| print "new number: " i."Sum: " i.to_s + (i-1).to_s }
# Iterating through an array
array = [1, 3, 5, 7, 9, 11, 13]
array.each { |x| puts x }
# find max
x = [1, 3, 5, 7, 9, 11, 1... | true |
61f1b44af03a20b264bdb4b2ca3f08d04c75863e | Ruby | rrrhys/rails_blog | /app/helpers/application_helper.rb | UTF-8 | 645 | 2.5625 | 3 | [] | no_license | module ApplicationHelper
def sign_in(user)
#save the remember token in the cookie
cookies.permanent[:remember_token] = user.remember_token
logger.debug "User #{user.name}"
logger.debug "Storing token #{user.remember_token}"
self.current_user = user
end
def sign_out
self.current_user = nil
cookies.del... | true |
0b2fd1239dd35f32f7486bf0cc8bed8b52056470 | Ruby | anjackson/hansard | /app/models/office.rb | UTF-8 | 2,361 | 2.53125 | 3 | [] | no_license | class Office < ActiveRecord::Base
before_validation_on_create :populate_slug
has_many :office_holders, :order => "start_date asc", :dependent => :destroy
acts_as_slugged
acts_as_string_normalizer
acts_as_duplicate_retryer
acts_as_id_finder
ONE_HOLDER_OFFICES = ['Prime Minister',
... | true |
4f15c45c183562010ef4e051619baaf5f61635d5 | Ruby | aftermathew/uwruby-spring-quarter | /apache_log_processor/test/test_apache_log_processor.rb | UTF-8 | 2,558 | 2.65625 | 3 | [
"MIT"
] | permissive | require "test/unit"
require "apache_log_processor"
require 'fileutils'
class ApacheLogProcessor
def puts blah
end
end
class Resolv
def self.getname ip
ip== '127.0.0.0' ? nil : 'www.example.com'
end
end
class TestApacheLogProcessor < Test::Unit::TestCase
def setup
@alp = ApacheLogProcessor.new 'te... | true |
441c7088801c26d1df87a688a44516ff79ef9af7 | Ruby | kunashir/tlaw | /examples/experimental/omdb.rb | UTF-8 | 1,836 | 2.609375 | 3 | [
"MIT"
] | permissive | require_relative '../demo_base'
#http://docs.themoviedb.apiary.io/#reference/movies/movielatest
class OMDB < TLAW::API
define do
base 'http://www.omdbapi.com'
param :api_key, field: :apikey, required: true
SPLIT = ->(v) { v.split(/\s*,\s*/) }
shared_def :imdb do
post_process('imdbRating', &:t... | true |
3873f6fdbdd20c8c9b841a2b48a9f970391aa148 | Ruby | zarnautovic/software-sauna-code-challenge | /spec/find_path_spec.rb | UTF-8 | 812 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require './services/find_path'
require './constants'
describe 'FindPath' do
let(:input) { get_input('./maps/ASCII-MAP-3.txt') }
let(:no_start_input) { get_input('./maps/ASCII-MAP-no-start.txt') }
let(:no_finish_input) { get_input('./maps/ASCII-MAP-no-finish.txt') }
describe '.call... | true |
3e0286796fdf2c3facf5b7a708fa5a006f93fa66 | Ruby | SoldierCoder/rspec-fizzbuzz-q-000 | /fizzbuzz.rb | UTF-8 | 178 | 3.859375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(number)
s = nil
if ((number % 15) == 0)
s = "FizzBuzz"
elsif ((number % 3) == 0)
s = "Fizz"
elsif ((number % 5) == 0 )
s = "Buzz"
end
s
end
| true |
8eb3b935c54382ae76d5cdf2cb04675e7fe2f354 | Ruby | yoikosugi/cherry | /section7/782.rb | UTF-8 | 1,284 | 3.640625 | 4 | [] | no_license | # class Product
# NAME = 'A product'
# SOME_NAMES = ['Foo', 'Bar', 'Baz']
# SOME_PRICES = { 'Foo' => 1000, 'Bar' => 2000, 'Baz' => 3000}
# end
# # 再代入をしなくてもミュータブルなオブジェクトであれば定数の値を変えることができる
# Product::NAME.upcase!
# p Product::NAME
# Product::SOME_NAMES << 'Hoge'
# p Product::SOME_NAMES
# Product::SOME_PRICES['Ho... | true |
9d1c32a74a08a92d02d2ddfbb6b448b44102e376 | Ruby | sreekantht/xls-sprint-metrics | /metric.rb | UTF-8 | 2,173 | 3.046875 | 3 | [] | no_license | require "date"
class Metric
def initialize (name, description, field, aggregation, day)
@name = name
@description = description
@field = field
@aggregation = aggregation
@day = day
end
def name= name
@name = name
end
... | true |
02a1d5a056e8c60b9ca9d9e2a31e54d6a43808aa | Ruby | fernandohur/taxigol-server | /test/unit/taxi_test.rb | UTF-8 | 4,266 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class TaxiTest < ActiveSupport::TestCase
# GIVEN there are 0 taxis
# THEN calling get_or_create will create a taxi
test 'Given that there are no taxis in the DB Calling get_or_create creates a new taxi' do
taxi = Taxi.get_or_create('ABC123')
assert_equal taxi.installation_id, 'AB... | true |
ec898f7e8d9968b0a3bd6762cc09a45ad593f19a | Ruby | amlydu/tip_calc | /tip_calculator.rb | UTF-8 | 2,059 | 3.921875 | 4 | [] | no_license | #ask for user information
#give correct answer
class TipCalculator
def intro
puts """
Let's get.....
$$\\ $$$$$$$$\\ $$\\ $$\\
$$$$$$\\ \\__$$ __|\\__| $$$$$$\\
$$ __$$\\ $$ | $$\\ $$$$$$... | true |
831baa09e0a12b3a708f310c669ecdb7691fa622 | Ruby | marinavega/realty-bites | /app/services/scraper.rb | UTF-8 | 1,919 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
require 'httparty'
require 'nokogiri'
require 'byebug'
require_relative 'base_scraper'
# Draft version
# TODO:
# * Refactor
# * Extract shared logic to BaseScraper
# * Validate if link is supported
class Scraper
attr_accessor :parsed_data
def initialize(link)
@parsed... | true |
fd4ecf640647cf01e22b439657b6fb67540f3740 | Ruby | stroughk/array-CRUD-lab-online-web-prework | /lib/array_crud.rb | UTF-8 | 919 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def create_an_empty_array
[]
end
def create_an_array
puts create_an_array["one","two","three","four"]
end
def add_element_to_end_of_array["one","two","three","four"]
puts add_element_to_end_of_array.push("five")
end
def add_element_to_start_of_array["one","two","three","four"]
puts add_element_to_start_of_a... | true |
be1c46a0857d1df9819c90d3fa26b3eb25488e8c | Ruby | davidgibb15/hockey_app | /db/cumu.rb | UTF-8 | 1,639 | 2.734375 | 3 | [] | no_license | require 'csv'
games=CSV.read('alligames.csv')
games.sort_by!{|game| game[3]}
cumulativeGames=[]
(0..81).each do
cumulativeGames.push([])
end
Player.all.to_a.each do |p|
lg=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
i=0
games.each do |g|
if g[0] == p.name
zero=g[0]
one=g[1]
two=g[2]
three=g[3]
four=g[4]
... | true |
30b7360fba107b16588783fd73a5eae55fc868f6 | Ruby | EECS448-KitchenUtensils/Skeddit | /app/controllers/events_controller.rb | UTF-8 | 2,156 | 2.5625 | 3 | [] | no_license | # Provides actions for /events and /events/:id
class EventsController < ApplicationController
before_action :authenticate_user!, :only => [:new, :create]
# Create an instance var of all of the events for use in the events#index page
# PRE:: None
# POST:: None
def index
@events = Event.all
@admin_even... | true |
3349e98458396e18258d96bb29b37df0e2849b2c | Ruby | PADDY202/Practical | /Curling_test.rb | UTF-8 | 420 | 2.5625 | 3 | [] | no_license | require 'test/unit'
require_relative 'agency'
require_relative 'curler'
class MyTest < Test::Unit::TestCase
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
@curlerm = [Curler.new("tom", 9, 4)]
@curlerf = [Curler.new("Olivia", 7, 6)]
@agent = Agency.new... | true |
11e42c1019ea2280189c6c59d60f9d3e41c6c639 | Ruby | rubenpazch/ruby-algorithms | /recursion/NQueenProblem.rb | UTF-8 | 963 | 3.25 | 3 | [] | no_license | $N = 4
$ld = Array.new(30)
$rd = Array.new(30)
$cl = Array.new(30)
def safe?(arr, row, col)
(0..col - 1).each do |x|
return false if arr[row][x] == 1
end
r = row
s = col
r.downto(0) do |m|
return false if arr[m][s] == 1
s -= 1
end
j = row
k = col
j.downto(0) do |m|
return false if ... | true |
663fc452c9441a4fc36b07b8d3313622d64d5d83 | Ruby | kolba8/Ruby-introduction | /ruby-introduction/pesel.rb | UTF-8 | 1,171 | 3.5625 | 4 | [] | no_license | #!/usr/bin/env ruby
require "date"
if ARGV.length != 1
puts "This program need exactly 1 parameter"
exit
elsif ! (ARGV[0].chars.all? { |c| "0123456789".include?(c) })
puts "Parameter should be a number"
exit
elsif ARGV[0].length != 11
puts "Usage ./args 12345678901"
exit
end
pesel = []
pesel_string = ARGV... | true |
5e65f6606d19206f871e70b62274b4df28edbf9e | Ruby | greganswer/mgit_rb | /lib/issue.rb | UTF-8 | 1,384 | 3.046875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Issue stores the data for the current issue.
class Issue
attr_accessor :id
class << self
# Create an issue from the branch name. Uses O(n) time and space.
def from_branch(name)
parts = name.to_s.split('-')
parts.each_with_index do |value, index|
next unl... | true |
1da853087b81d4f3c77403e694b99115cb6f936f | Ruby | ashassan/Hashmap-Questions | /lib/palindrome_permutation.rb | UTF-8 | 272 | 3.46875 | 3 | [
"MIT"
] | permissive |
def palindrome_permutation?(string)
hash = {}
results = []
string.each_char do |letter|
hash[letter] ? hash[letter] += 1 : hash[letter] = 1
end
string.each_char do |letter|
results << letter if hash[letter].odd?
end
return results.length <= 1
end
| true |
42e3958e1fefb82addf2ead0c809aa4827c41c6b | Ruby | rorprjin/freeukgenealogy | /arrayassign.rb | UTF-8 | 71 | 2.90625 | 3 | [] | no_license | names = Array.new(4,"mac")
puts "Values of names in the array #{names}" | true |
40e07c241ecf40e5bd265fc4cbedbb8ef09a954d | Ruby | aveaus/Code | /dispatcher/app/controllers/properties_controller.rb | UTF-8 | 2,025 | 2.796875 | 3 | [] | no_license | class PropertiesController < ApplicationController
def index
@hour = params[:hour] || Time.new.hour
@hour = @hour.to_i
@properties = Property.find_active_properties(@hour)
# Reduce overlapping properties
@normalized_properties = normalize_properties_on_weight(@properties)
end
# GET
def fin... | true |
3277e038495d725962e81f69a49ea22dc3f3086a | Ruby | LuckyGStar/toptutoring | /bin/auto_deploy_uninstall.rb | UTF-8 | 1,614 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
USER_DIRECTORY = `cd ~; pwd`.chomp.freeze
PATH_TO_LAUNCH_LIB = (USER_DIRECTORY + "/Library/LaunchAgents").freeze
PATH_TO_LAUNCH_PROGRAM = (PATH_TO_LAUNCH_LIB + "/auto_deploy.rb").freeze
PATH_TO_LAUNCH_PLIST = (PATH_TO_LAUNCH_LIB + "/com.toptutoring.auto.deploy.plist").freeze
def display(message)
... | true |
14fefc77a66b1f74f49a517a937d927894540b5f | Ruby | caseydailey/LRTHW | /read-write/ex16.rb | UTF-8 | 1,185 | 4.25 | 4 | [] | no_license |
=begin
in the previous exercise, i learned how to to open and read a file
here are a few cool commands i need to learn more about:
close -- closes the file (this is like 'save' in the editor)
read -- read the contents of the file You can assign the result to a variable.
readLine -- reads just one lin... | true |
a64313c5c473068e4a85747f72edf82e22af2894 | Ruby | CouldbeIDK/Space-Invaders | /sitest.rb | UTF-8 | 624 | 2.578125 | 3 | [] | no_license | require_relative 'BunnyInvadersClasses'
require 'test/unit'
class GameWindow < Gosu::Window
end
class Testing < Test::Unit::TestCase
def setup
@game = Game.new(GameWindow.new(2 , 2 , false))
end
def test_game
assert_equal(4, @game.invaders.count , "Error: spawnInvaders.")
assert_equal(false, @game.victor... | true |
de2e2383fbf6c8bcb78eb0605bbce9c77dd20b40 | Ruby | suburi/otozukuri | /nokogiri_graph.rb | UTF-8 | 1,737 | 2.609375 | 3 | [] | no_license | require 'coreaudio'
require 'byebug'
require 'matrix'
require 'tkextlib/tcllib/plotchart'
require_relative './filter'
include Tk::Tcllib::Plotchart
include Filter
# (1..50).each do |i|
# phase = STANDARD_PITCH * 2 * Math::PI / CoreAudio.default_output_device.nominal_rate
# waves << (0...PLAY_TIME*CoreAudio.default... | true |
9744ebb0142e282c571d4fcd48df432afafbe2ed | Ruby | JavierRMota/SWArch | /adapter/src/adapter_test.rb | UTF-8 | 1,350 | 2.703125 | 3 | [] | no_license | # File name: adapter_test.rb
# Adapter Pattern
# Date: 13-abr-2020
# Authors:
# A01372812 José Javier Rodríguez Mota
# A01379228 Adrián Méndez López
# File: adapter_test.rb
require 'minitest/autorun'
require './simple_queue'
require './queue_adapter'
#A class that tests queue_adapter.rb.
class Queu... | true |
834aa389c20e520a3749fee97d51c12e6cbdd4e6 | Ruby | billeisenhauer/reverse_geocoder | /spec/geocoder_spec.rb | UTF-8 | 2,004 | 2.59375 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/spec_helper.rb'
class TestGeocoder
include ReverseGeocoder::Geocoder
end
describe 'Geocoder Validations' do
it "should reject invalid latitude" do
lambda do
TestGeocoder.geocode(180,180)
end.should raise_error(ArgumentError, "Latitude 180 is invalid, try -90 t... | true |
ab04d0c4b617458c06b6bf7448d945187f488a01 | Ruby | 1987suhaib/badges-and-schedules-re-coded-000 | /conference_badges.rb | UTF-8 | 817 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
# Write your code here.
names = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def conference_badges(array)
# your code here
c=0
array.each do |e|
puts "Hello, my name is #{e}."
end
end
def badge_maker(name)
return "Hello, my name is "+ name+"."
end
def batch_... | true |
a7f08b764e84902919db1a166351b81f14e5f41e | Ruby | raonirenosto/iron-island | /places/place.rb | UTF-8 | 282 | 2.8125 | 3 | [] | no_license | class Place
def avaliable_places
return []
end
def avaliable_place_by_symbol symbol
avaliable_places.each do |place|
if place.symbol == symbol
return place
end
end
return nil
end
def avaliable_commands
[ :help, :exit ]
end
end
| true |
de29f1f485c971a3a02adce29813846ab48b6c15 | Ruby | colintalex/potluck | /lib/dish.rb | UTF-8 | 147 | 2.953125 | 3 | [] | no_license | class Dish
attr_reader :dish_name, :category
def initialize(dish_name, category)
@dish_name = dish_name
@category = category
end
end
| true |
d5ea7336bf8b7fad5308dfa3ced04d18cb24e82f | Ruby | Hello-Maja/JavaRacer2 | /app/controllers/index.rb | UTF-8 | 1,289 | 2.578125 | 3 | [] | no_license | # GET ===================================
get '/' do
erb :index
end
get '/start/:player1/:player2' do
@p1 = Player.find(params[:player1])
@p2 = Player.find(params[:player2])
@player1 = @p1.nickname
@player2 = @p2.nickname
erb :index
end
get '/end' do
erb :index
end
# POST =============================... | true |
94da8a380b4c7b8746ef1decc6f25f2c608067f3 | Ruby | clairedupuich/6-exo-ruby | /.history/exo_4_20201112212148.rb | UTF-8 | 6,832 | 3.625 | 4 | [] | no_license | ## exo 4 - Calcul de la moyenne 计算平均值
# Un instituteur souhaite pouvoir aller plus vite en saisissant les notes de ces élèves et en obtenir le nombre est la moyenne pour le trimestre.
# Pour cela, Albert qui a suivi une formation dans l’informatique, il y a fort longtemps, lui a proposé de l’aider. Malheureusement, l... | true |
72885effc2dbc99759fcb9e19efb632df9d9d846 | Ruby | lskeilty/ripe_tomatillo | /db/seeds.rb | UTF-8 | 2,116 | 2.53125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
Category.destroy_all
Film.destroy_all
User.destroy_all
Comment.destroy_all
Rating.destro... | true |
445934b94b3a09999b968d4cd2d20d6f026bb287 | Ruby | veloblank/streak-cli-app | /lib/scraper.rb | UTF-8 | 2,159 | 2.734375 | 3 | [
"MIT"
] | permissive | class Scraper
ESPN = "http://streak.espn.com/en/"
def self.scrape_page
@doc = Nokogiri::HTML(open(ESPN))
@doc.css("div .matchup-container")
end
def self.scrape_props
props = scrape_page
props.each.with_index(1) do |p, index|
prop = Prop.new
prop.prop_id = index
prop.title = ... | true |
0be1cf3799ad567479b842c006a0585d4a1214bd | Ruby | mwakipesile/launch-school-solutions | /intro-to-programming/flow_control.rb | UTF-8 | 1,063 | 4.3125 | 4 | [] | no_license | #Solution to Flow Control exercises
#1 false, false, false, true, true
#2
def to_upper(str)
str.upcase if str.length > 10
end
#3
def user_number
puts "Please enter a number between 0 and 100"
number = gets.chomp.to_i
if number < 0
puts "Invalid number."
user_number
elsif number <=... | true |
97ab56334d05834d9686589db89269d52f7b6446 | Ruby | woodhull/ruby-actblue | /lib/actblue/active_blue.rb | UTF-8 | 4,610 | 2.734375 | 3 | [] | no_license |
module ActBlue
ACTBLUE_VERSION = "2007-10-1"
ACTBLUE_URL = ENV['ACTBLUE_URL'] || "https://secure.actblue.com"
module ActiveBlue
include HTTParty
format :xml
base_uri "#{ACTBLUE_URL}/#{ACTBLUE_VERSION}"
basic_auth ENV['ACTBLUE_USER'], ENV['ACTBLUE_PASS'] if (ENV['ACTBLUE_USER'] && ENV['ACTBL... | true |
49a578e39d18e78cc2d0aafb84835ac94846008f | Ruby | cscov/algorithm-exercises | /Heaps/Carolyn_Scoville_Algorithms3/lib/heap.rb | UTF-8 | 2,139 | 3.578125 | 4 | [] | no_license | require 'byebug'
class BinaryMinHeap
attr_reader :store, :prc
def initialize(&prc)
@store = []
end
def count
@store.length
end
def extract
# debugger
root = self.peek
@store[-1], store[0] = store[0], store[-1]
@store.pop
BinaryMinHeap.heapify_down(@store, 0, @store.length)
... | true |
705665ba10d9b3d1c0951d2f39ac943f31fb820e | Ruby | zephirworks/ruby-perl | /lib/perl/rack.rb | UTF-8 | 1,071 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'perl'
require 'perl/interpreter'
module Perl
class Rack
def initialize(filename)
@interpreter = Perl::Interpreter.new
@app = @interpreter.load(filename)
end
def call(env)
@interpreter.call(@app, {:ref => clean_env(env)}, :scalar) do |ret|
value = ret.deref.value # Arra... | true |
e3a4357cef99f07f3a214dfdbbdfa05b08648ef2 | Ruby | doryphores/stock_ticker | /run | UTF-8 | 646 | 2.609375 | 3 | [] | no_license | #! /usr/bin/env ruby
require File.expand_path('./lib/process_manager', __dir__)
BUS = Bus.new
Thread.abort_on_exception = true
thread = Thread.new do
ProcessManager.new(BUS).run
end
BUS.publish(Messages::PositionAcquired.new(100))
while input = ARGF.gets do
input.each_line do |line|
case line.chomp
wh... | true |
2a72707643bc14573cf06c25aa110a9bf5f1ecc3 | Ruby | dcrosby42/object_diff | /lib/object_diff/strategy/array_strategy.rb | UTF-8 | 611 | 2.625 | 3 | [] | no_license | module ObjectDiff
module Strategy
class ArrayStrategy
def applies_to(a,b)
Array === a and Array === b
end
def execute(a_arr,b_arr)
left = a_arr.clone
short = b_arr.length - left.length
if short > 0
left += [nil]*3
end
diffs = {}
... | true |
b6930244289076049ac0c4692ffd5e94f2bcdbc6 | Ruby | jetrockets/corelogic-ruby | /lib/corelogic/error.rb | UTF-8 | 1,081 | 2.671875 | 3 | [
"MIT"
] | permissive | module Corelogic
class Error < StandardError
attr_reader :code
BadRequest = Class.new(self)
Unauthorized = Class.new(self)
Forbidden = Class.new(self)
NotFound = Class.new(self)
InternalServerError = Class.new(self)
TooManyRequests = Class.new(self)
ERRORS_MAP = {
400 => Corelo... | true |
e18ed634fe861d73a36b13cea9274ad807e720a0 | Ruby | gpedro/arena-rpg-s05e01 | /lib/personagem.rb | UTF-8 | 194 | 3.0625 | 3 | [] | no_license | class Personagem
attr_accessor :nome, :arma, :hp, :x, :y
def initialize(nome, arma, hp, x, y)
@nome = nome
@arma = arma
@hp = hp
@x = x
@y = y
end
def atacar(personagem)
end
end
| true |
fcbd9d63df52a12df76b440defabc1a9a06dc767 | Ruby | thesteady/warmup-exercises | /07-psychology-test/psychology.rb | UTF-8 | 1,016 | 3.453125 | 3 | [] | no_license | require 'highline/import'
class Questionairre
def initialize
@counter = 0
end
def random_question
if @counter <10
#options = [loves, feeling, wants_candy, fav_teach, pizza, fart, ugly, your_mom, coffee, color]
options.sample
@counter +=1
else
"Goodbye!"
end
end
def... | true |
19f0d620c5f19e57cd00e44364ef46bff6528f4a | Ruby | jordansissel/experiments | /ruby/jruby-netty/time/time-client.rb | UTF-8 | 1,934 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# The "1.7.2 - First Solution" in the netty guide for Time Client
require "java"
require File.join(File.dirname(__FILE__), "..", "netty-3.2.4.Final.jar")
class TimeClientHandler < org.jboss.netty.channel.SimpleChannelHandler
class << self
include org.jboss.netty.channel.ChannelPipelineFact... | true |
c46fb6e7f5fbe3aa79e2209d32107b87a4d3b4c6 | Ruby | aramsalimi91/Payback | /app/helpers/application_helper.rb | UTF-8 | 572 | 2.515625 | 3 | [] | no_license | module ApplicationHelper
def flash_error
if msg = flash[:error]
content_tag(:div, msg, class: "alert alert-error")
end
end
def flash_success
if msg = flash[:success]
content_tag(:div, msg, class: "alert alert-success")
end
end
# Format a string timestamp, ex: 7 Oct 2011
def re... | true |
b4d342454ba29c54099d1f9c39e5a8560a698d13 | Ruby | tigershen23/reed | /lib/tasks/populate_genres.rake | UTF-8 | 991 | 2.59375 | 3 | [] | no_license | namespace "populate_genres" do
desc "Populate Genre table with list of genres"
task :execute => [:environment] do
genres = []
now = Time.now
GenreList::GENRES.each do |genre|
genres.push "( '#{genre}', '#{now}', '#{now}' )"
end
sql = "INSERT INTO genres (name, created_at, updated_at)
... | true |
67b9d7e394ba98c9bee6b5bca1507f3b560619b4 | Ruby | myles/talks.mylesb.ca | /_plugins/mark_old_post_tag.rb | UTF-8 | 2,188 | 2.984375 | 3 | [] | no_license | # Mark Old Posts Liquid Tag
#
# A liquid tag for Jekyll sites to mark old posts as deprecated
#
# Usage:
# {% mark_old_posts <time_ago_in_words|date> %}
#
# Example:
# {% mark_old_posts 6 months ago %}
# {% mark_old_posts 1 year ago %}
# {% mark_old_posts 01/01/2012 %}
#
# Requires:
# chronic gem: s... | true |
c27319f775f4907668c6db2dbaae66bfdd8a8d87 | Ruby | randyjap/chess | /board.rb | UTF-8 | 3,542 | 3.609375 | 4 | [] | no_license | class Board
attr_accessor :grid
STARTING_POSITIONS = { :rook => [[0, 0], [0, 7], [7, 0], [7, 7]],
:knight => [[0, 1], [0, 6], [7, 1], [7, 6]],
:bishop => [[0,2],[0,5],[7,2],[7,5]],
:queen => [[0,3],[7,3]], :king => [[0,4],[7,4]] }
def initial_board
grid = Array.new(8){ Array.new(8) }
STARTIN... | true |
ad389b0162ea5e49b0fc07847b18c5d8148af76f | Ruby | rranshous/chatbrige | /subscription_manager.rb | UTF-8 | 6,260 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'sinatra'
require 'json'
require 'docker'
require 'uri'
require 'pry'
$stdout.sync = true
DOCKER_IMAGE_NAME = ENV['DOCKER_IMAGE_NAME']
puts "docker_image_name: #{DOCKER_IMAGE_NAME}"
def log msg
puts msg
msg
end
module Subscription
POSSIBLE_OPTIONS = %w{ api_key room sender target ... | true |
5bdedc20e7a5b090c085fb82c33aa9a0906261f3 | Ruby | coreycartercodes/backend_module_0_capstone | /day_1/exercises/ex5.rb | UTF-8 | 641 | 3.796875 | 4 | [] | no_license | name = 'Corey R. Carter'
age = 33
height = 71 # inches
weight = 220# lbs
eyes = 'Brown'
teeth = 'White'
hair = 'Black'
puts "Let's talk about #{name}."
puts "He's #{height} inches tall."
puts "He's #{weight} pounds heavy."
puts "Actually that's not too heavy."
puts "He's got #{eyes} eyes and #{hair} hair."
puts "His t... | true |
463af216266e99305aff9e4dff19889b7405315a | Ruby | Kevinw3i/5xR | /Ruby/RubyHomework/ruby0710.rb | UTF-8 | 3,028 | 3.65625 | 4 | [] | no_license | # ============================================
# Quest1
# p [1, 2, 3, 4, 5].my_map { |x| x * 2 }
# 印出 [2, 4, 6, 8, 10]
# ============================================
class Array
def my_map
result = []
self.each do |i|
result << yield(i)
end
return result
... | true |
d5d6ca148b31f80a3eaf271f14d5012b050ff0f1 | Ruby | yoshitokamizato/ike_sample | /practice_each.rb | UTF-8 | 384 | 4.0625 | 4 | [] | no_license | # 繰り返し処理
# 配列
numbers = [5 , 6 , 7 , 8]
numbers .each do |number|
puts "#{number} + 1"
end
#省略形
numbers.each { |number| puts "#{number} + 1"}
scores = [10,20,30,40,50,60,70,80,90]
sum = 0
scores.each do |score|
sum = sum + score
puts "現在のスコア"
puts score
puts "スコアの合計"
puts sum
end
puts "9回の平均点"
puts ... | true |
3d06a6e8df399679ed9f92b70de424da324e5845 | Ruby | envylabs/keymaster | /lib/gatekeeper.rb | UTF-8 | 9,861 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env ruby
# ==Usage
# Load and maintain all users for the 'envy-labs' project:
# PROJECT=envy-labs ruby gatekeeper.rb
# Normally, this would be done from a cron task:
# */5 * * * * PROJECT=envy-labs /root/gatekeeper.rb &>/dev/null
#
ENV['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bi... | true |
1ba66b2fc621501601bbb0b329b00e293e33e74f | Ruby | DanielFasel/Saaga | /app/controllers/services/validate_language.rb | UTF-8 | 406 | 2.53125 | 3 | [] | no_license | # This Service Validate the language (Meaning if the translator has completed or still needs to complete the translations for a langauge)
module Services
class ValidateLanguage
def initialize(languageId, value)
@language = Language.find_by(id: languageId )
@value = value
end
def call
@l... | true |
b5e4925934b57204f14a2eaa250634223c493f5f | Ruby | naiduv/codecrawl | /code/CBC.rb | UTF-8 | 13,878 | 3.296875 | 3 | [] | no_license | ###############################################
# Cipher Block Chaining: Encryption and Decryption Module #
# Author: Mukul Sharma #
# Date: 09/09/2008 #
###############################################
=begin rdoc
Cipher Block Chaining: Encryption and Decryption Module
=== Algorithms
... | true |
2f8ec8464f39ed8bd49c1eb768b1679d5e22895f | Ruby | kenchan/competitive_programming | /atcoder/code-festival-2015-qualb/D.rb | UTF-8 | 208 | 2.921875 | 3 | [] | no_license | # https://atcoder.jp/contests/code-festival-2015-qualb/tasks/codefestival_2015_qualB_d
N = gets.to_i
Ss = Array.new(N)
Cs = Array.new(N)
N.times do |i|
Ss[i], Cs[i] = gets.split.map(&:to_i)
end
puts ans
| true |
0bcc0c992d550ae1813f6f5a80ff5ed8b2b5fe5b | Ruby | hannahhall/ruby-bangazon-cli | /db/interface.rb | UTF-8 | 697 | 2.6875 | 3 | [] | no_license | class Interface
attr_accessor :filename
@@filename = 'db/bangazon.sqlite3'
def self.filename= (filename)
@@filename = filename
end
def self.filename
@@filename
end
def create(cmd)
begin
db = SQLite3::Database.new @@filename
db.execute cmd
id = db.last_insert_row_id
r... | true |
28f3ad84fd1f614bd50164621a9ec4193172c6a9 | Ruby | CKHere/BoxRelay | /box_client.rb | UTF-8 | 638 | 3.046875 | 3 | [] | no_license | #!/usr/bin/ruby
require 'socket'
# establish ongoing connection
id=ARGV.first.to_i
port=3000 + id
clientSession = TCPSocket.new( "localhost", port )
puts "log: starting connection at port: " + port.to_s
#wait for messages from the server
while !(clientSession.closed?) &&
(serverMessage = clientSession.gets)
## le... | true |
b69c03899363365a2e23f3f55145a2bd89bfd069 | Ruby | quintel/etlocal | /app/lib/dataset_source/key_map.rb | UTF-8 | 1,181 | 3.21875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module DatasetSource
# Helper module for mapping human-readable keys used in dataset GQL to the keys used in the
# source CSV.
module KeyMap
# Creates a Proc KeyMap where each input key is also the output key.
#
# For example:
# map = KeyMap.identity
# map.ca... | true |
6afc12a45ecf8dc7a9da9b7e3f18cbc6c072c4c1 | Ruby | fictionalparakeets/rb101 | /small_problems_exercises/easy_5/midnight.rb | UTF-8 | 1,667 | 4.34375 | 4 | [] | no_license | # After Midnight (Part 1)
=begin
The time of day can be represented as the number of minutes before or after midnight.
If the number of minutes is positive, the time is after midnight.
If the number of minutes is negative, the time is before midnight.
Write a method that takes a time using this minute-based format an... | true |
c78dba37b6efca2edcfe33f5589ecf4fc57ce392 | Ruby | annapetry/AppAcademyNotes | /w1/w1d4/rec.rb | UTF-8 | 2,633 | 3.40625 | 3 | [] | no_license | def non_it_range num1, num2
return [] if num1 <= num2
(num1..num2).each_with_object([]) {|el, obj| obj << el }
end
##################non-recursive##############################
def rec_range num1, num2
return [] if num1 > num2
[num1] | rec_range(num1 + 1, num2)
# num1
end
def expo1(base, pow)
retu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.