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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ace0198b65746a328ddd71c876a2a586eb8860a4 | Ruby | svkmax/hour_refactoring | /controllers/promo_messages_controller.rb | UTF-8 | 3,356 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
# in general luck of guards for each method in controller
# check required params for method and generate user message.
# params without daddy object(promo_message)
# rails way is require promo_message object in params
# so it will be promo_message[:date_from], promo_message[:date_to]
# p... | true |
a1ce32340de2058f8dde2307a15a5aa8599b0360 | Ruby | mwagner19446/wdi_work | /w01/d04/Jennifer_Gapay/file_io.rb | UTF-8 | 705 | 3.203125 | 3 | [] | no_license | # File.open("README.md", "r") do |f|
# puts "Hello #{f.gets}!"
# end
f = File.new("README.md", "r")
puts "Hello #{f.read}!"
f.close
# f = File.new("README.md", "r")
# puts "Hello #{f.gets.chomp}!"
# puts "Hello #{f.gets.chomp}!"
# puts "Hello #{f.gets.chomp}!"
# f.close
# f = File.new("README.md", "r")
# puts "Hel... | true |
54747dee5c05d61e263d86e055d715461ddbb72d | Ruby | lkriffell/battleship | /test/ship_test.rb | UTF-8 | 712 | 3.1875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/ship'
class ShipTest < Minitest::Test
def test_ship_exists
ship = Ship.new("Cruiser", 3)#The 3 refers to length
assert_instance_of Ship, ship
end
def test_ship_has_health
ship = Ship.new("Cruiser", 3)
assert_equal 3, ship.healt... | true |
47441cf75b6089f50fdcbba1badfbb8ed61eae39 | Ruby | hasyung/Hrms | /app/models/night_record.rb | UTF-8 | 322 | 2.75 | 3 | [] | no_license | class NightRecord < ActiveRecord::Base
def is_invalid
(self.shifts_type == "两班倒" && self.night_number > 16) || (self.shifts_type == "三班倒" && self.night_number > 11) || (self.shifts_type == "四班倒" && self.night_number > 8)
end
def calc_amount
self.night_number * self.subsidy.to_f
end
end
| true |
7d8e6fe08063f08187b498ea7e50e9948d85b707 | Ruby | aaanu/exercism_ruby | /difference-of-squares/difference_of_squares.rb | UTF-8 | 640 | 3.96875 | 4 | [] | no_license | =begin
Write your code for the 'Difference Of Squares' exercise in this file. Make the tests in
`difference_of_squares_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/difference-of-squares` directory.
=end
class Squares
def initialize(num)
@num = num
end
def square_o... | true |
714a691359685c67a4c27cf23a6ea421d2574365 | Ruby | taka12natu/sdgs | /lib/translation.rb | UTF-8 | 684 | 2.8125 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'json'
module Translation
class << self
def translate_to_japanese(context)
url = URI.parse('https://www.googleapis.com/language/translate/v2')
params = {
q: context,
target: "ja", # 翻訳したい言語
source: "en", # 翻訳する言語の種類
key:... | true |
c74d1fd721d58d50298289150bd59c0b54a5dd40 | Ruby | Shender012/week2 | /child.rb | UTF-8 | 84 | 3.40625 | 3 | [] | no_license | print "Enter child's age "
age = gets.chomp.to_i
puts "Are we there yet? " * age | true |
e00999b5e07069cad8047dbf9daf50ba47d757e4 | Ruby | funmia/student-directory | /directory.rb | UTF-8 | 3,862 | 4.03125 | 4 | [] | no_license | require 'csv'
COHORT_LIST =[:january,:february,:march,:april,:may,:june,:july,:august,:september,:october,:november,:december]
@students = [] #an empty array accessible to all methods
def print_menu
# print the menu and ask the user what to do
puts "1. Input the students"
puts "2. Show the students"
puts "3. ... | true |
9d8c116c21732bb9217eb2d73053a46047bb1e3c | Ruby | textchimp/wdi19-homework | /daniel_ting/week_05/wednesday/warmup.rb | UTF-8 | 146 | 3.203125 | 3 | [] | no_license | def cipher(string)
string.downcase.split("").each do |char|
print (122 - (char.ord - 97)).chr
end
puts
end
cipher 'test'
cipher 'gvhg'
| true |
892b03ad283eeefe70f2939ae3bdc098175686c5 | Ruby | bubbaspaarx/simple-blackjack-cli-london-web-060418 | /lib/blackjack.rb | UTF-8 | 1,562 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
# code #welcome here
puts "Welcome to the Blackjack Table"
end
def deal_card
# code #deal_card here
return rand(1..11)
end
def display_card_total(card_total)
# code #display_card_total here
puts "Your cards add up to #{card_total}"
end
def prompt_user
# code #prompt_user here
puts "Type '... | true |
ea07518ee0a2de1df08e01e53a39f2b152466f7f | Ruby | resputin/the_odin_project | /Ruby/testing/time_travel/spec/caesar_cipher_spec.rb | UTF-8 | 1,039 | 3.46875 | 3 | [] | no_license | require "caesar_cipher"
describe ".caesar_cipher" do
context "given out of bounds letters" do
it "returns same letter" do
expect(caesar_cipher(",", 5)).to eq(",")
end
it "handles spaces" do
expect(caesar_cipher(" ", 5)).to eq(" ")
end
end
context "given lowercase letters" do
it... | true |
1dba845b2cd616a633cab7932d86e6737382e119 | Ruby | wenbo/smart_ruby_codes | /threads/thread_current.rb | UTF-8 | 258 | 3.140625 | 3 | [] | no_license | # coding: utf-8
# 线程变量
count = 0
threads =[]
10.times do |i|
threads[i] = Thread.new do
sleep(rand(0.1))
Thread.current["myvalue"] =count #将值赋给当前变量
count += 1
end
end
threads.each { |t| t.join; puts t["myvalue"] }
| true |
7efff2578030528b6147f906a90eca3ceb2a06a3 | Ruby | RatheN/pl_table_cli | /lib/cli.rb | UTF-8 | 2,918 | 3.453125 | 3 | [
"MIT"
] | permissive | class CLI
def run
welcome
setup
prompt_for_table
team_selection
end_prompt
end
def welcome
puts "\n\n----------------------------------------"
puts "Welcome to the 2018/19 Premier League Table."
puts "View different sections of the table and find more information on your favorite ... | true |
7a2002aa7fd342ddcc09ad6947327feff20cf8d1 | Ruby | chef/license-acceptance | /components/ruby/spec/license_acceptance/strategy/prompt_spec.rb | UTF-8 | 3,847 | 2.546875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-proprietary-license"
] | permissive | require "spec_helper"
require "license_acceptance/strategy/prompt"
require "license_acceptance/product"
require "tty-prompt"
RSpec.describe LicenseAcceptance::Strategy::Prompt do
let(:output) { StringIO.new }
let(:config) do
instance_double(LicenseAcceptance::Config, output: output)
end
let(:acc) { License... | true |
5dbbb063aa404b79caa026f2d52f2ef8ed06d45d | Ruby | wsierradev/Launch-Academy-2017 | /challenges/odd-numbers/lib/odd_numbers.rb | UTF-8 | 163 | 2.59375 | 3 | [] | no_license | # Wasn't sure if I was supposed to work from the test file or not so I worked from the file in the lib folder.
odd = 1
while odd < 100 do
puts odd
odd += 2
end
| true |
e7a0af8f8db4575706afa01fbf4e9f783525c3b5 | Ruby | claracodes/interview-prep | /solutions/single_number.rb | UTF-8 | 761 | 4.25 | 4 | [] | no_license | # Brute force with #count
# O(n^2) time and O(1) space
def single_number(num)
num.each do |n|
return n if num.count(n) == 1
end
end
# Tally
# O(n) time and O(n) space
def single_number(nums)
nums.each_with_object(Hash.new(0)) { |n, h| h[n] += 1 }
end
# XOR operator or bitwise operator
# O(n) time and O(1) ... | true |
d6c082ca972bc8cbfde4ca692c24d030abcb69bc | Ruby | svenfuchs/memoize | /spec/memoize_spec.rb | UTF-8 | 478 | 2.984375 | 3 | [
"MIT"
] | permissive | describe Memoize do
let(:const) do
Class.new do
include Memoize
def count
@count ||= 0
@count += 1
end
memoize :count
prepend Module.new {
attr_reader :called
def count
@called ||= 0
@called += 1
super
end
... | true |
80795110a624a407b6c4173110cff3d790c81c68 | Ruby | zendesk/em-http-request | /spec/stub_server.rb | UTF-8 | 993 | 2.515625 | 3 | [
"MIT"
] | permissive | class StubServer
module Server
attr_accessor :keepalive
def receive_data(data)
if echo?
send_data("HTTP/1.0 200 OK\r\nContent-Length: #{data.bytesize}\r\nContent-Type: text/plain\r\n\r\n")
send_data(data)
else
send_data @response
end
close_connection_after_wri... | true |
c48bf84f63ab7fc64a3149ee2dabf3dfb34f0207 | Ruby | kremso/tmzone | /lib/tort/default_search.rb | UTF-8 | 760 | 2.625 | 3 | [] | no_license | require 'tort/external_search'
require 'tort/downloader'
require 'tort/parallel_hits_fetcher'
require 'tort/page_search'
module Tort
class DefaultSearch
def initialize(engine_name, list_parser, mark_parser, instructions_factory)
@engine_name = engine_name
@list_parser = list_parser
@mark_parser... | true |
3462a38c7d8ad4cd6b8dadf64116455f70359d81 | Ruby | thebravoman/software_engineering_2015 | /hm_count_words/B_12_Emiliqn_Gospodinov/word_counter/folder_parser.rb | UTF-8 | 447 | 2.609375 | 3 | [] | no_license | require_relative 'file_parser'
module WordCounter
class FolderParser
def parse_folder folder
directory = folder.gsub("\n",'')
directory.insert(directory.size, '/**/*.*')
Dir.glob(directory).each do |file|
result = FileParser.new.parse_file file
if ARGV[2] == 'csv' or ARGV[2] == nil
result.to_c... | true |
dff411b841a9481b2881fc2a897cac01e612fb3b | Ruby | Shadowssong/Battle-muffin | /lib/battle-muffin/character_profile/character.rb | UTF-8 | 2,200 | 2.796875 | 3 | [
"MIT"
] | permissive | require_relative 'achievements'
require_relative 'appearance'
require_relative 'audit'
require_relative 'feed'
require_relative 'guild'
require_relative 'hunter_pets'
require_relative 'items'
require_relative 'mounts'
require_relative 'pet_slots'
require_relative 'pets'
require_relative 'progression'
require_relative '... | true |
66a34d0e6582d30b9efdbf56daf5b544c273bc61 | Ruby | clodiap/CodeWars | /spec/CountCharacters_spec.rb | UTF-8 | 502 | 2.96875 | 3 | [] | no_license | require_relative '../lib/CountCharacters'
describe "ordered_count" do
it "Count the number of occurrences of each character and return it as a list of tuples in order of appearance" do
expect(ordered_count("abracadabra")).to eq([['a', 5], ['b', 2], ['r', 2], ['c', 1], ['d', 1]])
expect(ordered_count("aaaabbc... | true |
3e24898859ba8ad5252705b8121b8fb2c0f87d77 | Ruby | ashamani9/Ruby | /AverageArray.rb | UTF-8 | 187 | 3.328125 | 3 | [] | no_license | # Calculate Average Value of Array Elements
num= Array[23,12,14,23,22,34,12,45,67,89]
sum=0
num.each { |b| sum += b }
average = sum / num.length
puts "The average is : #{average}" | true |
7bc25b0997048060921f03bf3488f94d8ef6a4b2 | Ruby | derrick-long/Launch_Projects | /optimal-guesser/guess_number.rb | UTF-8 | 1,055 | 4.09375 | 4 | [] | no_license | require 'pry'
# def median(array)
# sorted = array.sort
# mid = (sorted.length - 1)/2.0
# (sorted[mid.floor] + sorted[mid.ceil]) / 2
# end
def guess_number(min, max)
# You can call the `check` method with a number to see if it
# is the hidden value.
#
# If the guess is correct, it will return 0.
# If... | true |
2516dc7195b8250c16d7c9d9cfe0c42e765e476b | Ruby | kaninfod/pt_api | /db/migrate/20170814150419_add_hamming_function.rb | UTF-8 | 684 | 2.515625 | 3 | [] | no_license | class AddHammingFunction < ActiveRecord::Migration[5.1]
def change
ActiveRecord::Base.connection.execute <<-SQL
CREATE FUNCTION `HAMMINGDISTANCE`(A BINARY(32), B BINARY(32)) RETURNS int(11)
DETERMINISTIC
RETURN
BIT_COUNT(CONV(HEX(SUBSTRING(A, 1, 8)), 16, 10) ^CONV(HEX(SUBST... | true |
a51032a63f44200427c88feb8ab1996281509133 | Ruby | thomaswhyyou/pepperjam | /lib/tasks/scraper.rake | UTF-8 | 8,809 | 2.8125 | 3 | [] | no_license | require 'csv'
namespace :scraper do
desc "Scrape pepperjamnetwork.com for program info and scan for bidding policy"
task pepperjam: :environment do
time_start = Time.now
start_point = 0
# Initiate a ICONV object to convert/uniform encodings to utf-8
encoding_converter = Iconv.new('UTF-8', 'LATIN1'... | true |
56bff0fd648faa2f7500548a78eda34a52455761 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/meetup/45b03a5813a2419ba4bc733a8c2f9bfc.rb | UTF-8 | 1,495 | 3.453125 | 3 | [] | no_license | module TimeTricks
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def days_in_month(month, year = Time.now.year)
return 29 if month == 2 && Date.gregorian_leap?(year)
COMMON_YEAR_DAYS_IN_MONTH[month]
end
end
class Meetup
include TimeTricks
DAYS = {
sunday: 0... | true |
86aca1719fd794768f01603f2e463abb18a0ebbc | Ruby | adamberman/learning_sql | /Question.rb | UTF-8 | 1,708 | 2.90625 | 3 | [] | no_license | require './QuestionsDatabase.rb'
require './Reply.rb'
require './QuestionFollower.rb'
require './QuestionLike.rb'
require './SaveModel.rb'
class Question
include SaveModel
def self.all
questions = QuestionsDatabase.instance.execute('SELECT * FROM questions')
questions.map {|question| User.new(questio... | true |
4d6986c67e1a98702303d0a09b96003bcddbc14a | Ruby | cowboyd/baseline | /spec/baseline_spec.rb | UTF-8 | 1,648 | 2.703125 | 3 | [] | no_license |
require File.dirname(__FILE__) + '/../lib/baseline.rb'
include Baseline
describe Baseline do
it "can parse a simple option" do
Parser.new.tap do |p|
p.option do |o|
o.name = "v"
end
p.parse("-v 1.9").tap do |options|
options[:v].should == "1.9"
end
end
end
... | true |
035b371991812ac6481a23b22f92ec91a22ba00b | Ruby | sa2taka/rootine | /vendor/bundle/ruby/2.6.0/gems/ruby-graphviz-1.2.4/lib/graphviz/utils/colors.rb | UTF-8 | 29,683 | 3.046875 | 3 | [
"MIT",
"GPL-2.0-only",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later"
] | permissive | require 'graphviz/core_ext'
class GraphViz
module Utils
class Colors
HEX_FOR_COLOR = /[0-9a-fA-F]{2}/
RGBA = /^(#{HEX_FOR_COLOR})(#{HEX_FOR_COLOR})(#{HEX_FOR_COLOR})(#{HEX_FOR_COLOR})?$/
attr_reader :r, :g, :b, :a
attr_reader :h, :s, :v
def initialize
... | true |
078c4a89f7ba0b683f4668c4559a0ab8a4aa8ccd | Ruby | lrnzgll/Design-Patterns | /observer-pattern/v1/delivery_driver.rb | UTF-8 | 146 | 2.78125 | 3 | [] | no_license | class DeliveryDriver
def update(pizza)
puts "New status update for pizza #{pizza.style}"
puts "The pizza is #{pizza.status} "
end
end
| true |
69a6c0c754d7894733d8843dfecd92857e68eaf9 | Ruby | jzntam/CodeCore_Alumni | /spec/controllers/cohorts_controller_spec.rb | UTF-8 | 3,685 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe CohortsController, type: :controller do
let(:cohort) { create(:cohort) }
let(:cohort_1) { create(:cohort) }
let(:user) { create(:user) }
describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
end... | true |
d520eaf70fc0293d47033ab119c17adc7c215820 | Ruby | DianaE620/Torteria | /torteria.rb | UTF-8 | 4,128 | 3.171875 | 3 | [] | no_license | $pan = 60
$aguacate = 30
$mayonesa = 30
class Torta
@@numero_tortas = 0
def initialize(extras)
@pan = 2
@aguacate = 1
@mayonesa = 1
@@numero_tortas += 1
"Torta numero: #{@@numero_tortas}"
p Torta.bodega
end
def self.bodega
$pan -= 2
$aguacate -= 1
$mayonesa -... | true |
7261cb7d36a561042e9785349dd5d8ef43181d4b | Ruby | mcinello/object_oriented_programming | /player.rb | UTF-8 | 965 | 3.796875 | 4 | [] | no_license | class Player
def initialize
@gold_coins = 0
@health_points = 10
@lives = 5
end
#answer 6
def level_up #works
@lives += 1
return @lives
end
#answer 7
def collect_treasure #works
@gold_coins += 1
if @gold_coins % 10 == 0
Player.new.level_up
return level_up
end
en... | true |
1e41a91e52a1a8365e60bfa62597a93a5c9c5b85 | Ruby | halhelms/ruby-stuff | /ARGF.rb | UTF-8 | 262 | 3.0625 | 3 | [] | no_license | KEYS = ( 'a'..'z' ).to_a
VALUES = KEYS.rotate( 13 )
CYPHER = Hash[ KEYS.zip( VALUES ) ]
def sekrit( text )
text.downcase.chars.map{ |char| CYPHER[ char ] || char }.join
#text
end
ARGF.each_line do |line|
print "#{ARGF.path}: #{ sekrit( line ) }"
end | true |
3a9056ba11f47c500a844709dc1ae197ab3b6868 | Ruby | Freeman1524/learnrubythehardway | /ex4.rb | UTF-8 | 978 | 3.6875 | 4 | [] | no_license | cars = 100 # amount of cars
space_in_a_car = 4.0 # how many people car can hold
drivers = 30 # amount of drivers
passengers = 90 # amount of passengers
cars_not_driven = cars - drivers # cars not being driven
cars_driven = drivers # cars being driven
carpool_capacity = cars_driven * space_in_a_car # how many people can... | true |
4f8d57aeb52eefbf90f3f43eac354c43701f0571 | Ruby | X140Yu/algorithm-solutions | /LeetCode/69.sqrtx.rb | UTF-8 | 1,041 | 3.5625 | 4 | [
"MIT"
] | permissive | # [69] Sqrt(x)
#
# https://leetcode.com/problems/sqrtx/description/
#
# * algorithms
# * Easy (29.32%)
# * Source Code: 69.sqrtx.rb
# * Total Accepted: 281.2K
# * Total Submissions: 949.8K
# * Testcase Example: '4'
#
# Implement int sqrt(int x).
#
# Compute and return the square root of x, where x is gu... | true |
e85e7e2d2997d177186cebe1bec02cd3c3a92662 | Ruby | fossabot/rightcert | /lib/rightcert/certificate_cache.rb | UTF-8 | 1,345 | 3.1875 | 3 | [
"MIT"
] | permissive | module RightCert
# Implements a simple LRU cache: items that are the least accessed are
# deleted first.
class CertificateCache
# Max number of items to keep in memory
DEFAULT_CACHE_MAX_COUNT = 100
# Initialize cache
def initialize(max_count = DEFAULT_CACHE_MAX_COUNT)
@items = {}
@l... | true |
1eb67509fa20be48dac0e2b523e6bc67953899f0 | Ruby | skoba/mml-ruby | /spec/mml/insurance_client_spec.rb | UTF-8 | 1,296 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | describe MML::InsuranceClient do
let(:name) { MML::Name.new(repCode: 'A', fullname: 'Shinji KOBAYASHI')}
let(:address) { MML::Address.new(repCode: 'A', addressClass: 'business', tableId: 'MML0025', full: '506, Dept. 9, Kyoto Research Park (KRP), Awata-cho 91, Chudoji, Shimogyo-ku, Kyoto-city')}
let(:phone) { M... | true |
a6b64c7494a9ae11a0232a78678f6012b561477d | Ruby | billc2021/DojoAssignments | /04RAILS/02OOP/exercise_files/03bMammalClass.rb | UTF-8 | 365 | 3.921875 | 4 | [] | no_license | class Mammal
def initialize
puts "I am alive"
end
def breath
puts "Inhale and exhale"
end
def who_am_i
# printing the current object
puts self
end
end
my_mammal = Mammal.new # => "I am alive"
my_mammal.who_am_i # => #<Mammal:0x007f9e86025dd8>
my_mammal.who_am_i.breath # => undefined met... | true |
869dd4d148b318f560dc666a9b1c010d573aeeaf | Ruby | akhitrykh/traning | /test_puppies/features/support/pages/shopping_cart_page.rb | UTF-8 | 1,262 | 3 | 3 | [
"Unlicense"
] | permissive | class ShoppingCartPage
include PageObject
NAME_COLUMN = 1
SUBTOTAL_COLUMN = 3
LINES_PER_PUPPY = 6
button(:proceed_to_checkout, :value => 'Complete the Adoption')
button(:continue_shoping, :value => 'Adopt Another Puppy')
table(:cart, :index => 0)
cell(:cart_total, :class => 'total_cell')
... | true |
d7e33acee65549f4511ae6d286427409949444fe | Ruby | DaveKeith/planeswalkr | /app/models/card.rb | UTF-8 | 1,520 | 2.5625 | 3 | [] | no_license | class Card < ActiveRecord::Base
belongs_to :card_set
validates_presence_of :name, :multiverse_id, :type, :card_set_id
validates :multiverse_id, uniqueness: true
# include PgSearch
# pg_search_scope :search_by_name, :against => :name
# pg_search_scope :search_by_mana_cost, :against => :mana_cost
IMAGE_B... | true |
2f56508405797dc9bf68409b2c6d27053e214236 | Ruby | AnKiTKaMbOj18/LearnRubyWithExamples | /3.datatypes.rb | UTF-8 | 1,647 | 4.375 | 4 | [
"MIT"
] | permissive | # Data types represents a type of data such as text, string, numbers, etc.
# There are different data types in Ruby:
# Numbers , Strings , Symbols , Hashes , Arrays , Booleans
#Numbers - Integers and floating point numbers come in the category of numbers
#Intergers - 2 , 3 , 4 etc
num1 = 2;
num2 = 3;
puts nu... | true |
7fb94b6c0ff94104dea8568a75161c6ae515033b | Ruby | guosamuel/rateMyInstructor-backend | /app/models/student.rb | UTF-8 | 550 | 2.546875 | 3 | [] | no_license | class Student < ApplicationRecord
has_secure_password
has_many :reviews
has_many :instructors, through: :reviews
validates :first_name, presence: true
validates :last_name, presence: true
validates :password_digest, presence: true
validate :unique_full_name
def unique_full_name
student = Student... | true |
993df1c12f9344d8a36db84456f4706aad890842 | Ruby | Vawx/code_wars_kata | /non_code_wars/lib/06_performance_monitor.rb | UTF-8 | 710 | 3.25 | 3 | [] | no_license | # Measure gap of time
def measure( testCount = 0 )
start = Time.now # start time before yields
if testCount == 0
yield if block_given? # if testCount is 0, yield to block
else
testCount.times do yield( ) # for every testCount, yield to block
end
end
finish = Time.now # finish t... | true |
8f8379b2f569b85c0b618ee12b00dd1b95098dfc | Ruby | kenkeiter/timely-ruby | /benchmarking/stress.rb | UTF-8 | 1,114 | 2.546875 | 3 | [
"MIT"
] | permissive | require "benchmark"
require "timely"
unless RUBY_PLATFORM =~ /java/i
require 'hiredis'
timely = Timely::Connection.new(:driver => :hiredis)
else
timely = Timely::Connection.new
end
ITERATIONS = 100
Benchmark.bm(42) do |x|
series_name = (0...8).map{65.+(rand(26)).chr}.join
x.report "Insert 10k records" do
... | true |
8d29e55c7efed7c9ebfcb8d7bdce5ee3b8c50deb | Ruby | ryogrid/hirameitter | /lib/scraper/.svn/text-base/microformats.rb.svn-base | UTF-8 | 2,421 | 2.71875 | 3 | [] | no_license | require "time"
module Scraper
module Microformats
class HCard < Scraper::Base
process ".fn", :fn=>:text
process ".given-name", :given_name=>:text
process ".family-name", :family_name=>:text
process "img.photo", :photo=>"@src"
process "a.url", :ur... | true |
84736f8e2d2dec302db68ab9391a36fbd31da335 | Ruby | rafinulman/api_projects | /coords_to_weather.rb | UTF-8 | 995 | 3.640625 | 4 | [] | no_license | require 'open-uri'
require 'json'
puts "Let's get the weather forecast for your location."
puts "What is the latitude?"
the_latitude = gets.chomp
puts "What is the longitude?"
the_longitude = gets.chomp
# Now look up the weather at the lat-long
# Create a new URL
weather_URL = "https://api.forecast.io/forecast/4... | true |
edcb5f38f4b22904f6c24a1c5c5020ffc4886c1a | Ruby | fuzzylita/activerecord-validations-lab-v-000 | /app/models/post.rb | UTF-8 | 505 | 2.984375 | 3 | [] | no_license | require 'pry'
class Post < ActiveRecord::Base
def clickbaity?
clicky = ["Won't Believe", "Secret", "Top
[number]", "Guess"]
unless !self.title.nil? && clicky.any? {|word| self.title.include?(word)}
errors[:title] << 'Title not Clickbaity Enough'
end
end
validates :title, presence: true
... | true |
d8d179babd642563eb7d88488509dcc462b6b22a | Ruby | j-resilient/sudoku | /Game.rb | UTF-8 | 1,736 | 3.65625 | 4 | [] | no_license | require_relative 'Board.rb'
require 'byebug'
class Game
def initialize
@board = Board.new
end
def play
until @board.solved?
# debugger
@board.render
position, value = get_input
@board.update_tile(position, value)
end
@board.r... | true |
f6775dcc8bbf1ed2a333a207118caaa6fd99b64c | Ruby | amcritchie/g3-assessment-week-7 | /application.rb | UTF-8 | 1,274 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'sinatra/base'
require 'gschool_database_connection'
require "rack-flash"
require './lib/country_list'
require_relative "lib/message_list"
class Application < Sinatra::Application
enable :sessions
use Rack::Flash
def initialize
super
@database_connection = GschoolDatabaseConnection::DatabaseCon... | true |
e4cad4c287e09c3c15164a16b846005f287d6097 | Ruby | vanekpe8/MI-RUB-Homeworks | /Uloha4/lib/InputLoader.rb | UTF-8 | 2,133 | 3.625 | 4 | [] | no_license | #This module contains tools to handle input of this application. That includes parsing command line arguments or reading data file
module Input
#This class handles file reading
class InputLoader
#Creates new instance of InputLoader, given a file to read
def initialize(file)
@file = file
end
... | true |
89676cfa30a39104949c4b4f16a73039275d2873 | Ruby | Trishthedish/list-implementations-cont | /lotto.rb | UTF-8 | 911 | 3.84375 | 4 | [] | no_license | require './array-list.rb'
require './linked-list.rb'
require 'awesome_print'
class Lotto
def initialize
@ticket = ArrayList.new
while @ticket.size < 5
auto_num = rand(55) + 1
if !@ticket.include?(auto_num)
@ticket.add(auto_num)
end
end
end
def display_ticket
@ticket.sort... | true |
bcdd2c2b59ff1d9eadea2363b766c56a568a8cca | Ruby | elledouglas/Georgie | /base/generator.rb | UTF-8 | 809 | 2.84375 | 3 | [] | no_license | class Generator
def self.invoke(command)
send(command.slice(2..-1).gsub('-', '_'))
end
def self.reset_exercises
destroy_exercises
create_exercises
end
def self.destroy_exercises
Dir.glob('episode-*').each do |folder|
puts "Removing #{folder}"
FileUtils.rm_r folder
end
end
... | true |
88907c16254a596f6c0d76dcc791e5b86c989b61 | Ruby | maximkoo/ruby-repo | /api.rb | UTF-8 | 357 | 2.65625 | 3 | [] | no_license | require "Win32API"
message = "This is a sample Windows message box generated using Win32API"
title = "Win32API from Ruby"
api = Win32API.new('user32', 'MessageBox',['L', 'P', 'P', 'L'],'I')
api.call(0,message,title,0)
x1=5
x2=10
isVert=true
#puts a
puts (233+(357-353)*(231-233).fdiv(372-353)).rou... | true |
a03c196a222df09aa4c6f8a5630ecdb2bf929b2c | Ruby | fisherman1234/cuisine | /app/models/recipe.rb | UTF-8 | 1,455 | 2.5625 | 3 | [] | no_license | class Recipe < ActiveRecord::Base
require 'open-uri'
require "net/http"
require "uri"
attr_accessible :difficulty, :preparation_time, :price, :cooking_time, :selection_id, :rating, :title, :instructions, :dish_type, :cost , :is_vegetarian , :picture_url , :marmiton_id, :ingredients
belongs_to :marmiton_sel... | true |
24a2546680db9c242e811c0220d932a2708d8e34 | Ruby | meh9184/coding-test-practice | /myrealtrip/practice.rb | UTF-8 | 905 | 4.46875 | 4 | [] | no_license | arr = [2,4,7,2,5]
# input / output
intput = gets.chomp()
puts intput
# if
if arr.length % 2 == 1
puts '홀수 개'
elsif arr.length % 2 == 0
puts '짝수 개'
else
puts '있을 수 없는 경우'
end
# for
for i in 0...5
puts "#{i}번째 값 = #{arr[i]}"
end
# while
i=0
while i < arr.length
puts "#{i}번째 값 ... | true |
d945bcd102ceb5ffff471a2d50e66ebed73e2557 | Ruby | sQilver/gizma | /test_script.rb | UTF-8 | 2,799 | 2.640625 | 3 | [] | no_license | require './initialize'
binding.pry
# options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'])
# driver = Selenium::WebDriver.for :firefox, options: options
# binding.pry
# driver.navigate.to 'https://www.youtube.com/feed/trending'
# binding.pry
# first_line_text = driver.find_element(xpath: "(//y... | true |
0874ce72376cc0aa0d18d0382ee4cfc5ff1dadb5 | Ruby | noahfeder/shootings_db | /app/controllers/people_controller.rb | UTF-8 | 1,006 | 2.5625 | 3 | [] | no_license | class PeopleController < ApplicationController
def index
build_query(params)
people = Person.where(@query).order(@order)
render json: people
end
private
def build_query(params)
return nil if !params || params.keys.length == 0
@query = {}
params.each do |key, value|
@query[key] =... | true |
116276fb1a47eaaa4ba57d7cddecad542d165351 | Ruby | MONAKA0721/cookpad-internship-2020-summer-pbl | /app/models/ingredient.rb | UTF-8 | 999 | 2.90625 | 3 | [] | no_license | class Ingredient < ApplicationRecord
MAX_NAME_LENGTH = 255
MAX_QUANTITY_LENGTH = 255
belongs_to :recipe
validates :name, presence: true, length: { maximum: MAX_NAME_LENGTH }
validates :quantity, presence: true, length: { maximum: MAX_QUANTITY_LENGTH }
def group_1
['ごはん', 'パン', 'じゃがいも',... | true |
75c9483667050109f2fd3a3d53e237d66538fed0 | Ruby | tohyongcheng/ga-examples | /day1/hashes_ex1.rb | UTF-8 | 183 | 3.546875 | 4 | [] | no_license | h = {0 => "Zero", 1 => "One", :two => "Two", "two" => 2}
# 1
h[1]
#2
h[:two]
#3
h["two"]
#4
h[3] = "Three"
#5
h[:four] = 4
is = {true => "It's true!", false => "It's false"} | true |
7fbe4cc2a6e62c383efc598f777d6f337fd45cf0 | Ruby | jamesscalise/key-for-min-value-online-web-pt-081219 | /key_for_min.rb | UTF-8 | 371 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
mKey = nil
mValue = nil
name_hash.each{|key, value|
if mKey
if value < mValue
mKey = key
mValue = value
end
else
mKe... | true |
4ba1fe0372a6669c910fb8b4e447bd1c1ea62e33 | Ruby | tsubasa00119/ruby_lesson | /index.rb | UTF-8 | 929 | 3.625 | 4 | [] | no_license | #料理注文サービス
require "./food"
require "./drink"
require "date"
puts "名前を入力してください"
name = gets.chomp
puts "#{name}さん、いらっしゃいませ"
puts "メニューはこちらです"
food1 = Food.new(name: "ピザ", price: 800,calorie:700)
food2 = Food.new(name: "すし", price: 1000,calorie:600)
drink1 = Drink.new(name:"コーラ",price:300,amount:400)
drink2 = Drink.new... | true |
d86e6a622e9bb32a4d9b680cc78f59f764f893ea | Ruby | ali/Euler | /Euler-18.rb | UTF-8 | 1,935 | 4.0625 | 4 | [] | no_license | # Project Euler - Problem #18 (and #67)
# Solved by Ali Ukani on Jan 1, 2012
# By starting at the top of the triangle below and moving to adjacent numbers on the row below, find the maximum total from top to bottom of a given triangle.
# http://projecteuler.net/problem=18
# http://projecteuler.net/problem=67
# This so... | true |
5008a42f7e5deafd7ab703a554b4b3ddc0651d80 | Ruby | CepCap/ThinkneticaRuby | /lesson6/passengers_train.rb | UTF-8 | 430 | 2.921875 | 3 | [] | no_license | require_relative 'train'
require_relative 'cargo_wagon'
require_relative 'passengers_wagon'
class PassengersTrain < Train
def hook_wagon(wagon)
if wagon.is_a? PassengersWagon
super
else
puts "Вагон не пассажирский."
end
end
def unhook_wagon(wagon)
if wagon.is_a? PassengersWagon
... | true |
06c00294374935d614965fab88e08deb42b051e6 | Ruby | ayva/prep_ruby_challenges | /overlap.rb | UTF-8 | 248 | 2.96875 | 3 | [] | no_license | def overlap(r1,r2)
return false if r1[0][0] >= r2[1][0] || r2[0][0] >= r1[1][0]
return false if r1[0][1] >= r2[1][1] || r2[0][1] >= r1[1][1]
return true
end
#overlap([[0,0],[3,3]],[[1,1],[4,5]])
#overlap([ [0,0],[1,4] ], [ [1,1],[3,2] ])
| true |
eb39e91495fbf87bdf9d1bd410f335e82f1d5e96 | Ruby | srikaanthtb/bank_tech_test | /lib/bank_account.rb | UTF-8 | 1,205 | 3.578125 | 4 | [] | no_license | # frozen_string_literal: true
require_relative './transaction'
require_relative './bank_statement'
class Bankaccount
attr_reader :transactions, :balance
def initialize(statement = Bankstatement.new, transaction = Transaction)
@transactions = []
@balance = 0
@statement = statement
@transaction ... | true |
83f09b335683f80baf2547f84af0cbb952f09844 | Ruby | id774/sandbox | /ruby/machine-learning/recommendation/recommendations.rb | UTF-8 | 6,120 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'awesome_print'
def critics
{
'Lisa Rose' => {
'Lady in the Water' => 2.5,
'Snake on the Plane' => 3.5,
'Just My Luck' => 3.0,
'Superman Returns' => 3.5,
'You, Me and Dupree' => 2.5,
'The Night Listener' => 3.0
},
'Gene Seymou... | true |
c85fef10ecbdcf6a3e5f4e893c2f47a15a367f78 | Ruby | Rayxan/Programming_UNB | /Software Engeneer/Homework1(answer to get ass example)/Homework1/Part6/part6b.rb | UTF-8 | 213 | 3.0625 | 3 | [] | no_license | class String
def palindrome?
string = self
string = string.downcase().gsub!(/\W+/i, '')
return string.reverse() == string
end
end
puts "Sator Arepo, tenet OpEra Rotas".palindrome?
| true |
149fdb21b02c684bea134cdf7883d4b926969e3f | Ruby | coderschool/advanced_ruby_lab_1 | /todo_m8.rb | UTF-8 | 2,321 | 3.84375 | 4 | [] | no_license | class Todo
include Enumerable
attr_reader :title, :tasks
def initialize(title)
@title = title
@tasks = []
end
def add_task(task)
@tasks << task
end
def each(&block)
@tasks.each(&block)
end
end
class Task
attr_reader :name
def initialize(name)
@name = name
end
# an empty d... | true |
fea1984eea768057dcea10cdbda3712b0c53b254 | Ruby | AlexFrz/ruby-peerprog | /exo_21.rb | UTF-8 | 182 | 3.21875 | 3 | [] | no_license | puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?"
n = gets.chomp
a = 1
while a.to_i <= n.to_i
puts ("*" * a.to_i).rjust(n.to_i)
a = a.to_i + 1
end | true |
61edb47ad363e68fb995300a19c5176e59c1e3d8 | Ruby | microverse-projects/advanced-building-blocks | /enumerable_methods/lib/enumerable_methods.rb | UTF-8 | 818 | 3.5 | 4 | [] | no_license | # Enumerable module
module Enumerable
def my_each
for i in self
yield(i)
end
self
end
def my_each_with_index
(0..length - 1).my_each do |x|
yield(self[x], x)
end
self
end
def my_select
arr = []
my_each do |x|
arr << x if yield(x)
end
arr
end
def... | true |
967abc32f3cab493da98696869982e541c3b5079 | Ruby | oneortwo/windchecker | /lib/image_picker.rb | UTF-8 | 527 | 3.046875 | 3 | [] | no_license | class ImagePicker
def pick(path)
sanity_check(path)
images = get_images(path)
return images.sample
end
def get_images(path)
images = Dir.entries(path)
images.delete_if { |x| x == '.' }
images.delete_if { |x| x == '..' }
images.delete_if { |x| x == '.DS_Store'}
images.delete_if { ... | true |
a986d2a24a7ac6b8b8a026ddf7905539bfda8531 | Ruby | sato11/everystudy | /twitter_migrator/main.rb | UTF-8 | 344 | 2.6875 | 3 | [] | no_license | require 'twitter'
require 'dotenv'
require 'forwardable'
require './client.rb'
require './app.rb'
app = App.new
f, n = app.f, app.n
loop do
app.menu
input = gets.chomp.to_i
puts # return
case input
when 1
app.list_friends(f)
when 2
app.list_friends(n)
when 3
break
else
puts app.send(:n... | true |
9c438323f6670ad10d5f4807d94535a6c97fe220 | Ruby | bother7-learn/playlister-sinatra-web-071717 | /app/models/artist.rb | UTF-8 | 364 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist < ActiveRecord::Base
has_many :songs
has_many :song_genres, through: :songs
has_many :genres, through: :song_genres
def slug
string = self.name.downcase
string.gsub!(/[()!@%&"]/,'')
array = string.split(" ")
array.join("-")
end
def self.find_by_slug(string)
self.all.find {|insta... | true |
daf502159ebc8ad532484739940591163a8e91c7 | Ruby | xDD-CLE/katas | /langstons_ant/samjones/lib/grid_navigable.rb | UTF-8 | 282 | 2.90625 | 3 | [] | no_license | module GridNavigable
attr_accessor :x, :y
def at(x, y)
self.x=x
self.y=y
self
end
def move_direction!(direction)
public_send(direction)
end
def north
self.y = y-1
end
def south
self.y = y+1
end
def east
self.x = x+1
end
def west
self.x = x-1
end
end
| true |
78b6160310edba2107d9c81a48b16961fe16c082 | Ruby | Buzonxxxx/ruby-practice | /Collections/array-2.rb | UTF-8 | 319 | 2.640625 | 3 | [] | no_license | #join
clients = ["iOS", "Android", "BE", "Web", "iOS Web"]
p clients
p clients.join(',')
p clients.join('-')
p clients.join('&')
#push\pop
#push on item
p clients.push("WebTV")
#multiple push
p clients.push("auHikari", "Chromecast")
#pop one item
p clients.pop
p clients
#pop last two items
p clients.pop(2)
p clients | true |
333ac295d0a6cdfe8a8145f1825493a9d84907ab | Ruby | halogenandtoast/alchemist | /lib/alchemist.rb | UTF-8 | 1,263 | 2.578125 | 3 | [
"MIT"
] | permissive | require "alchemist/conversion_table"
require "alchemist/measurement"
require "alchemist/compound_measurement"
require "alchemist/module_builder"
require "alchemist/configuration"
require "alchemist/library"
require "alchemist/conversion_calculator"
module Alchemist
autoload :Earth, "alchemist/objects/planets/earth"... | true |
e760e124d520fb3e461b59a3a1b26c88576b7000 | Ruby | concos/Ruby-Exercises- | /Ruby_Assignments.rb | UTF-8 | 622 | 4.0625 | 4 | [] | no_license | arr = [1,2,3,4,5,6,7,8,9,10]
arr.each {|x| puts x}
arr.each do |x|
if x >= 5
puts x
end
end
arr.select do |y|
if y % 2 != 0
puts y
end
end
arr << 11
puts arr
arr.unshift(0)
puts arr
arr.uniq
puts arr
# An array is an ordered type integer indexed collection of objects
# A hash is an unordered ... | true |
800f6b38e566fae78ae1ef821e7488ca11b84f18 | Ruby | a-chaudhari/ruby1459 | /handlers/nickname.rb | UTF-8 | 658 | 2.515625 | 3 | [] | no_license | def ERR_NICKNAMEINUSE(chunks, raw)
@nickname += '_'
self.write("NICK #{@nickname}")
emit(:self_new_nickname, @nickname)
end
def NICK(chunks, raw)
old_nick = chunks[0].split('!', 2).first
new_nick = chunks[2]
command = {
from: old_nick,
to: new_nick
}
if old_nick == @nickname
@nickname = n... | true |
a632d6e5aad55f4d6527110a0e0413ac63559abe | Ruby | Dizney23/oop_bank_account | /bank_account.rb | UTF-8 | 598 | 3.609375 | 4 | [] | no_license | class BankAccount
@balance = nil
def initialize(balance, name)
@balance = balance
if balance <= 200
raise ArgumentError.new "Error:Did not meet min balance!"
end
end
def balance
@balance
end
def deposit(deposit_amt)
@balance += deposit_amt
end
def withdraw(withdraw_amt)
@balance -= withdraw... | true |
307ce00da1d48d356eadddaf951505aa783df6ff | Ruby | IQ-SCM/switchboard | /bin/switchboard | UTF-8 | 738 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby -rubygems
require 'switchboard'
require 'switchboard/commands'
require 'optparse'
ARGV.clone.options do |opts|
# opts.banner = "Usage: example.rb [options]"
command = Switchboard::Commands::Default
command.options(opts)
cmd = []
argv = []
# force optparse into being a command parser
... | true |
0b2ade867fad28912e6ecbdf5a981a6d225ba3fb | Ruby | manheim/backupsss | /lib/backupsss.rb | UTF-8 | 2,450 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'aws-sdk'
require 'rufus-scheduler'
require 'backupsss/tar'
require 'backupsss/backup'
require 'backupsss/backup_dir'
require 'backupsss/backup_bucket'
require 'backupsss/janitor'
require 'backupsss/version'
require 'backupsss/configuration'
# A utility for backing things up to S3.
module Backupsss
# A Class... | true |
1a74a4552a6f17e1e54a5441bca84ad2700c3b9d | Ruby | csaunders/citation | /model/tag.rb | UTF-8 | 496 | 2.671875 | 3 | [] | no_license | class Tag < Sequel::Model
set_schema do
primary_key :id
String :name
index :name
end
create_table unless table_exists?
def self.normalize(tag)
tag.strip.downcase
end
def self.find_or_create_missing(tags)
tags = tags.sort.uniq
entries = order(:name).where(name: tags).all
tags.m... | true |
f7ccde806ab415334937a726624af87318bbb3f7 | Ruby | clearwater-rb/bowser | /opal/bowser/event_target.rb | UTF-8 | 1,346 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'bowser/event'
module Bowser
module EventTarget
# Add the block as a handler for the specified event name. Will use either
# `addEventListener` or `addListener` if they exist.
#
# @param event_name [String] the name of the event
# @return [Proc] the block to pass to `off` to remove this h... | true |
a916f99fca4157241100c6d3031ed28101ef2360 | Ruby | jacooobi/university_projects | /Algorytmy i Struktury Danych/Sorting/lib/merge_sort.rb | UTF-8 | 452 | 3.515625 | 4 | [] | no_license | require_relative 'shared'
def merge_sort(arr)
return false unless array_of_numbers?(arr)
return arr if arr.size <= 1
left = merge_sort arr[0, arr.size / 2]
right = merge_sort arr[arr.size / 2, arr.size]
merge(left, right)
end
def merge(left, right)
res = []
while left.size > 0 and right.size > 0
... | true |
d7f69b108e4cf6a399fc6d6c41b02d576f47c180 | Ruby | BJSummerfield/brighton_scrape | /brighton.rb | UTF-8 | 10,895 | 2.5625 | 3 | [] | no_license | require 'selenium-webdriver'
require 'csv'
require './.env.rb'
@driver = Selenium::WebDriver.for :chrome
@wait = Selenium::WebDriver::Wait.new(timeout: 120)
@driver.manage.timeouts.implicit_wait = 20
def runner
information_to_write = []
user_name = USER_NAME
company_id = COMPANY_ID
password = PASSWORD
logi... | true |
83f55089715052b7beb0c06732d91bcd780559e8 | Ruby | micko45/ruby_code | /ham_radio/api/access_qrz_api.rb | UTF-8 | 2,136 | 2.765625 | 3 | [] | no_license | #!/bin/env ruby
#Use qrz_api to connect to qz and get some info.
require "./qrz_api.rb"
require 'optparse'
require './adif_api.rb'
##############
#SetUP
##############
#Create hash required by qrz api
args = Hash[
:url => "http://xmldata.qrz.com/xml/current",
:agen => "mmg-1.0.1",
:user => "ei5hsb",
:pass =... | true |
1ea6312a29f7886e61b854e546b93976af83abbe | Ruby | Muffin1/MEDI6 | /Group Project/lib/admin.rb | UTF-8 | 4,815 | 3.234375 | 3 | [] | no_license | require 'person.rb'
require 'doctor.rb'
require 'receptionist.rb'
require 'md5'
require 'user_account.rb'
class Admin < Person
attr_accessor :id, :password
def initialize()
if(search_by_id(5000,"../csv/user.csv")==nil)
set_privileges(5000,MD5.hexdigest("admin"),"a")
end
end
def add_doctor(idNu... | true |
8975859917efb278e40a075d5543cd0acb529861 | Ruby | rmueck/aix-puppet | /lib/puppet/provider/download/suma.rb | UTF-8 | 6,620 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | require_relative '../../../puppet_x/Automation/Lib/Log.rb'
require_relative '../../../puppet_x/Automation/Lib/Suma.rb'
require_relative '../../../puppet_x/Automation/Lib/Nim.rb'
require_relative '../../../puppet_x/Automation/Lib/Utils.rb'
# ##############################################################################... | true |
315409b9cbe411132d5e87bef640a8a688dd1428 | Ruby | lnchambers/refugee_project_backend | /app/presenters/results_presenter.rb | UTF-8 | 1,802 | 2.96875 | 3 | [] | no_license | class ResultsPresenter < ApplicationController
def initialize(params)
@age = params[:age].to_i unless params[:age].nil?
@name = params[:name]
@gender = params[:gender]
@country_of_origin = params[:country_of_origin]
@group_size = params[:group_size].to_i unless params[:group_size].nil?
@count... | true |
1a83e760700283cb4ff6ca5934e7dce2c31d10aa | Ruby | cristianrennella/launchschool | /120/lesson_5/exercises.rb | UTF-8 | 350 | 3.125 | 3 | [] | no_license | # Game Description: Display the board. User make a choice. Computar make a choice. Update board.
# Until there are three choices in one row (horizontal or diagonal) and win / lose. Or tie.
# nouns: board, user, computer
# verbs: display, choice, evaluates
# nouns: game engine (evaluates), board (display, update), use... | true |
6c85cb1b2d5b6bb5976cc1151e9edf98e14c1a97 | Ruby | sunteya/wido.old | /plugins/lm2doc_converter.rb | UTF-8 | 994 | 2.53125 | 3 | [] | no_license | require "lm2doc"
module Jekyll
class MarkdownConverter < Converter
def matches_with_lm2doc_support(ext)
return false if @config['markdown'] == "lm2doc"
matches_without_lm2doc_support(ext)
end
alias_method_chain :matches, :lm2doc_support
end
class Lm2docConverter < Converter
... | true |
ea909b922e97c5ced7cd242d4c59382e0493e565 | Ruby | HarikrishnaBatta/tennis-scoreboard-ng | /lib/api_constraints.rb | UTF-8 | 972 | 2.8125 | 3 | [] | no_license | # Determine if a router request matches an api version number
class ApiConstraints
# * *Args* : options
# - +version+ -> number
# - Version number to match
# - +default+ -> Boolean
# - If request does not identify a version, default to +version+
def initialize(options)
@version = options... | true |
873cdecfc4a37cc7ee630b8e16302a9c369f92a1 | Ruby | fernandoamz/ConwayRB | /conway.rb | UTF-8 | 3,494 | 3.484375 | 3 | [] | no_license | class Conway
def muestras
pobladores = 15
celulas = [pobladores]
for i in 0...pobladores
celulas[i] = [pobladores]
for j in 0...pobladores
celulas[i][j] = rand(0..1)
end
end
return celulas
end
def buscarVecino... | true |
3d8f3453546b7debeb75275c46f1cbc5fa1d72b9 | Ruby | MDamjanovic/school_generator | /spec/models/student_spec.rb | UTF-8 | 2,036 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Student, type: :model do
it "expect to belong to school" do
t = Student.reflect_on_association(:school)
expect(t.macro).to eq(:belongs_to)
end
it "expect to belong to department" do
t = Student.reflect_on_association(:department)
expect(t.macro).to eq(:be... | true |
163cae146e03e0e3d95769359fd887ce653885f2 | Ruby | boost/safety_cone | /lib/safety_cone/filter.rb | UTF-8 | 1,760 | 2.546875 | 3 | [
"MIT"
] | permissive | module SafetyCone
# Module for Filtering requests and raise notices
# and take measures
module Filter
# Method to include to base class.
# This lets declare a before filter here
def self.included(base)
if Rails.version.to_i >= 5
base.before_action :safety_cone_filter
else
b... | true |
64f861c20ef9bdfea2b2b263044192ac1bfe0660 | Ruby | Andyagus/afpray | /lib/player.rb | UTF-8 | 1,939 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'open-uri'
class Player
def initialize(ping_url=nil)
if ping_url
logger.info("[player] set ping_url to #{ping_url}")
@ping_url = ping_url
end
@queue = []
@options = ""
@thread = nil
at_exit{
kill_thread
}
end
attr_reader :queue
attr_writer :options
def ... | true |
7f7ce3eee8b95a6bcf5682cae3cefab762fff87a | Ruby | LewisYoul/5_Battle | /spec/game_spec.rb | UTF-8 | 479 | 2.859375 | 3 | [] | no_license | require 'game'
describe Game do
let(:player1) { double(:player1, reduce_hp: true, name: true) }
let(:player2) { double(:player2, reduce_hp: true, name: true) }
let(:game1) { described_class.new(player1, player2) }
describe "#attack" do
context "when attacking" do
it "calls player.reduce_hp" do
... | true |
0b63eece89f6acd390ef0ef27064a8a26baf59b7 | Ruby | stickysidedown/LaunchSchool-Intro-to-Programming | /ruby_intro_book/other_stuff/exercise_1_other_stuff.rb | UTF-8 | 186 | 2.6875 | 3 | [] | no_license |
def ifLab(string)
if /lab/ =~ string
puts string
else
puts "No Lab"
end
end
ifLab("laboratory")
ifLab("experiment")
ifLab("Pans Labyrinth")
ifLab("elaborate")
ifLab("polar bear") | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.