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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d46fb0fc803d9d988670f7d7c408496809777f61 | Ruby | stevenb-nz/AdventOfCode2017 | /day18a.rb | UTF-8 | 1,312 | 3.25 | 3 | [
"MIT"
] | permissive | def day18(input)
lines = input.split("\n")
next_line = 0
registers = Hash.new
sounds = []
recovered_sounds = []
begin
this_line = lines[next_line].split(' ')
val1 = get_val(this_line[1],registers)
if ('a'..'z').include?(this_line[1]) then
reg = this_line[1]
end
if this_line.size > ... | true |
bd1940112e982f327057a8295d2e30e7d145dcce | Ruby | pratikmshah/phase-0 | /week-6/guessing-game/my_solution.rb | UTF-8 | 3,150 | 4.25 | 4 | [
"MIT"
] | permissive | # Build a simple guessing game
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: a guess on the ranomly generated number
# Output: 3 cases guess is high, low, or correct
# Steps:
# step1: Initialize game with random integer
# step2: create METHOD and chec... | true |
4e0398a7e9d9663ae6c822b2e82f02c0353a5c1a | Ruby | CodeMonkeySteve/fast_xor | /benchmark | UTF-8 | 515 | 3.140625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$: << File.dirname(__FILE__)+'/lib'
require 'benchmark'
require 'xor'
class String
def slow_xor!(other)
s = ''
other.each_byte.with_index { |b, i| s << (self[i].ord ^ b).chr }
replace(s)
end
require 'xor'
alias_method :fast_xor!, :xor!
end
a = ([255].pack('C')) * (2**17) # 12... | true |
d35e8437116e5b323592e0a538a7e619ff15225a | Ruby | marloncarvalho/hackerrank | /two_characters.rb | UTF-8 | 697 | 3.53125 | 4 | [] | no_license | def solution(s)
r = 0
a = s.split ''
u = a.uniq
return 0 if s.length == 1 || u.length == 1
return 2 if u.length == 2
# Vamos fazer todas as combinações possíveis de dois caracteres e manter esses
# dois caracteres, apagando os demais. Aí checamos se a string resultante
# segue a regra do exercício.
... | true |
231dd0d170392161b88aabd54187f7647019d22d | Ruby | L-Y/ruby_file | /socket-server.rb | UTF-8 | 343 | 2.625 | 3 | [] | no_license | #_*_ coding:UTF-8 _*_
require "socket"
port=2000
s = TCPServer.open(port)
=begin
loop {
client =s.accept
client.puts(Time.now.ctime)
client.puts "closing the connection,bye!"
client.close
}
=end
loop{
Thread.start(s.accept) do |client|
client.puts(Time.now.ctime)
client.puts "closing the connection.Bye!"... | true |
258c495674eae06ef6fce691fec41a2eb660cfa0 | Ruby | rossenhansen/Ruby | /087-8_Ways_to_create_Arrays.rb | UTF-8 | 463 | 3.9375 | 4 | [] | no_license | names = %w[Jack Jill John James] #Doesn't require quotes or delimiters but can't accept two word names
p names #=> ["Jack", "Jill", "John", "James"]
p Array.new(5) #=> [nil, nil, nil, nil, nil]
p Array.new(10, "Hello") #=> ["Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello"]
p Arra... | true |
dd6c4690a70f1304d97f9abddaaddb5f5617da63 | Ruby | rubidine/rbiz | /test/unit/customer_test.rb | UTF-8 | 1,041 | 2.640625 | 3 | [
"MIT"
] | permissive | context 'A new customer' do
setup do
Customer.delete_all
CartLib.activate_test_stubs
@customer = Customer.new(
:email => 'testie@localhost',
:passphrase => 'testie00'
)
end
specify 'should have a hashed passphrase' do
assert_not_equal 'testie0... | true |
d94e13974efe411fe28227eed511579d7676776a | Ruby | gmitrev/inactive_support | /spec/lib/hash_spec.rb | UTF-8 | 2,790 | 2.75 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'spec_helper'
require 'inactive_support/hash/delete_blank'
require 'inactive_support/hash/deep_delete_blank'
describe Hash do
describe '#delete_blank' do
it 'deletes nils' do
initial = {
id: 1,
name: nil
}
expected = {
id: 1
}
ex... | true |
77ac9efaad98f2bef642e8f543879d9c5d8f258b | Ruby | devscrapper/statupweb | /test/hashdomain.rb | UTF-8 | 562 | 2.78125 | 3 | [] | no_license | #function hash(d){
# var a=1,c=0,h,o;
# if(d){
# a=0;
# for(h=d["length"]-1;h>=0;h--){
# o=d.charCodeAt(h);
# a=(a<<6&268435455)+o+(o<<14);
# c=a&266338304;
# a=c!=0?a^c>>21:a
# }
# }
# return a
#}
def hashdomain(d)
a = 0
c =... | true |
267ce327cfdbf2fc5a7dbae0e9107edd5f08496b | Ruby | kunjut/notepad | /notepad.rb | UTF-8 | 603 | 3.09375 | 3 | [] | no_license | require_relative 'post'
require_relative 'link'
require_relative 'memo'
require_relative 'task'
puts 'Привет, я твой блокнот!',
'Что хотите записать в блокнот?'
choices = Post.post_types
choice = nil
until (1..3).include?(choice)
# until choice > 0 && choice <= choices.size
puts "\nВыберите цифру соответствую... | true |
4b4c1ed1b3974855c46e5d9c38fb46fa1682818e | Ruby | doboy/euler | /ruby/p058.rb | UTF-8 | 412 | 3.53125 | 4 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require 'prime'
def spiral_gen
end
def spiral_primes(under)
prime_count = 0
total_count = 0
i = 1
inc = 2
while true
1.upto(4) do
i += inc
sprial_num = i
if Prime.prime? sprial_num
prime_count += 1
end
total_count += 1
if prime_count / total_count.to_f < und... | true |
c3e80cd7b5c2ab8329c4abb370250ca9fc0e4639 | Ruby | xristocodos/compressiondemo | /compress.rb | UTF-8 | 2,130 | 3.828125 | 4 | [] | no_license | # compress text files
def compress
puts "Please enter the filename of text to compress?"
filename = gets.chomp
text = File.open(filename, "r"){|file| file.read}
text_stripped = text.gsub("\n", " ").gsub(",", "").gsub(".", "").gsub("...", "").gsub("!","")
puts "\n"
puts "Please enter compression factor (c... | true |
a77d9899ef567742faee8739b0bd08395d8838b5 | Ruby | Tan2Pi/rlox | /src/stmt.rb | UTF-8 | 1,969 | 2.875 | 3 | [] | no_license | class Stmt
class Visitor
def visit_expression_statement(stmt);end
def visit_print_statement(stmt);end
def visit_var_statement(stmt);end
def visit_block_statement(stmt);end
def visit_if_statement(stmt);end
def visit_while_statement(stmt);end
def visit_break_statement(stmt);end
def visit... | true |
9a8a05aa0fc82c8602272ff14e42973a37de6111 | Ruby | koenhandekyn/rails-whist-stimulus | /app/models/round.rb | UTF-8 | 1,994 | 2.90625 | 3 | [] | no_license | # == Schema Information
#
# Table name: rounds
#
# id :bigint(8) not null, primary key
# game_id :uuid
# score1 :integer
# score2 :integer
# score3 :integer
# score4 :integer
# roundtype :integer
# created_at :datetime not null
# updated_at :datetime not null
... | true |
e73ac4170d7212bce0c6703d4baf012497593d14 | Ruby | luqiuyuan/reactjs_course_backend | /test/test_helper.rb | UTF-8 | 4,419 | 2.765625 | 3 | [] | no_license | ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
def json_response
Active... | true |
0431803f4cd2ab5317cd045c6b7b09514b46eb93 | Ruby | GrahamMThomas/SudokuSolver | /sudoku_test.rb | UTF-8 | 3,973 | 3.015625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'sudoku_class'
require_relative 'sudoku_utils'
class SudokuTest < Minitest::Test
@@puzzle = Sudoku.zero(9)
@@puzzle.load_matrix_from_file('Puzzles/SudokuDefault.txt')
@@hard_puzzle = Sudoku.zero(9)
@@hard_puzzle.load_matrix_from_file('Puzzles/SudokuHard1.txt')
def... | true |
4e634ddf75ff86c53f126005ece37c82c2826bc4 | Ruby | omaroaburto/Curso-ruby | /15-clases/clases.rb | UTF-8 | 275 | 3.09375 | 3 | [] | no_license |
class Persona
attr_accessor :nombre, :edad
def aumentar_edad()
end
def definir_ciudad_nacimiento(a)
end
end
persona1 = Persona.new
persona2 = Persona.new
persona1.nombre = "juan"
persona2.nombre = "pedro"
puts persona1.nombre
puts persona2.nombre | true |
90b1b4c13a33548f3bc7e4e53bfbb377eaa035e8 | Ruby | nougu/Pitchfork | /lib/pf/cli/build.rb | UTF-8 | 1,000 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'thor'
module Pf
class CLI < Thor
desc "build [OPTIONS] (-|PATH)", "Build device stack from the YAML file"
option :"dry-run", :type => :boolean, :default => false, :desc => "Try to build device stack"
def build(file)
Pf.context(file, options) {
if opts[:"dry-run"]
puts "... | true |
3e940d63a85d1d27aa18972322b5c3308672a922 | Ruby | calebhearth/passivesupport | /spec/core_ext/hash/leaves_spec.rb | UTF-8 | 865 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'passive_support/core_ext/hash/leaves'
describe Hash do
describe "#leaves" do
it "returns an array containing a single value for a simple Hash" do
subject = { this: :that }
subject.leaves.should eq([:that])
end
it "returns all of the values when there are more ... | true |
e073d53e540c53993a98593fa82dae9d1b7fc7a9 | Ruby | pythonandchips/being-dynamic-in-ruby | /1_methods_return_value.rb | UTF-8 | 636 | 3.859375 | 4 | [] | no_license | class Zombie
def kill_human
return "I just want a hug"
end
def eat_human
"hmmm, tastes of chicken"
end
def infect_human hungry
if hungry
"Please welcome David Heinemeier Hansson"
end
end
end
zombie = Zombie.new
puts("kill human")
puts(zombie.kill_human)
puts("-------------------... | true |
c3eb98d754da0059f512d2e27b1b13f5f1ca454c | Ruby | alma-frankenstein/anagramsAndAntigrams | /ruby_script.rb | UTF-8 | 403 | 3.46875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require ('./lib/anagramChecker')
puts "Let's check for anagrams! Please enter a word"
word1 = gets.chomp
puts "Enter another word to compare"
word2 = gets.chomp
anaCheck = AnagramChecker.new(word1, word2)
puts " *************** "
puts anaCheck.all_together()
if anaCheck.all_together() == "... | true |
eef1a3b9d80f7d37264e01fdfbb886f13b7533f5 | Ruby | gPrado/mc747-portal | /app/models/address.rb | UTF-8 | 959 | 2.796875 | 3 | [] | no_license | class Address
attr_accessor :cep, :logradouro, :bairro, :localidade, :uf, :numero, :complemento
def initialize(params)
@cep = params[:cep]
@logradouro = params[:logradouro]
@bairro = params[:bairro]
@localidade = params[:localidade]
@uf = params[:uf]
@numero ... | true |
5de059e3183e23be70976a5e4510b32744d41e66 | Ruby | holywyvern/carbuncle | /gems/carbuncle-math/mrblib/matrix.rb | UTF-8 | 2,660 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | module Carbuncle
module Vectorizable; end
# A matrix is a table of numbers, in a 4x4 grid.
# Useful for doing some mathematical operations.
class Matrix
include Enumerable
# A line is a row or column of a matrix.
class Line
include Carbuncle::Vectorizable
attr_reader :matrix
def... | true |
cd429210d335cd1057dd379c4e7559b2e1f06d0c | Ruby | ttuffy/docker_design_pattern | /app/models/observer/other.rb | UTF-8 | 883 | 2.796875 | 3 | [] | no_license | class EmployeeObserver < ActiveRecord::Observer
def after_create(employee)
# 新しいemployeeレコードが生成されました。
end
def after_update(employee)
# employeeレコードが更新されました。
end
def after_destroy(employee)
# employeeレコードが削除されました。
end
end
########################################################################... | true |
b56b0d1bb09540b2ad3ebe7f42cb71d65559e15c | Ruby | Tmgree/Boris_Bikes_Challenge | /spec/docking_station_spec.rb | UTF-8 | 6,692 | 3.03125 | 3 | [] | no_license | require 'docking_station'
describe DockingStation do
describe '#release_bike' do
it 'responds to release_bike' do
expect(subject).to respond_to :release_bike
end
it 'must release a bike' do
bike=double(:bike, broken: false)
subject.dock(bike)
expect(subject.release_bike).to eq... | true |
e6887489208f97645980397a1e04b84e6e8727df | Ruby | lindellcarternyc/Launch-School----Intro-to-Programming | /hashes/exercises.rb | UTF-8 | 1,868 | 4.53125 | 5 | [] | no_license | # Exercise 1
# Given a hash of family members, with keys as the title and an array of names
# as the values, use Ruby's built-in select method to gather only immediate
# family members' names into a new array.
family = { uncles: ["bob", "joe", "steve"],
sisters: ["jane", "jill", "beth"],
broth... | true |
0febc4647ab50c07f4ceea9e2f908fdb927dc608 | Ruby | IrinaOvdii/ruby_codaisseur | /day-2/booleans.rb | UTF-8 | 854 | 4.53125 | 5 | [] | no_license | =begin
puts "Put your age:"
age = gets.chomp.to_i
if age < 18
puts "You can not drink your beer!"
elsif age > 50
puts "It's too late to dring a beer, sorry..."
else
puts "Take your beer!"
end
=end
puts "Welcome to Manipulating Your Strings!"
print "Let us know the string you want to modify: "
text = gets.cho... | true |
17b2c49b17f1f2629f69a32b67db5011df738e0d | Ruby | choihz/study-ruby | /Chapter 5/design.rb | UTF-8 | 4,364 | 3.34375 | 3 | [] | no_license | # 상속과 믹스인은 둘 다 코드를 한 곳에 모아놓고 그 코드를 다른 클래스들에서 효과적으로 재사용할 수 있게 해 준다. 언제 상속을 사용하고, 언제 믹스인을 사용하면 좋을까?
# 디자인에 관한 대부분의 질문에 대한 답이 그렇듯이 그건 상황에 달려 있다. 하지만 오랜 시간에 걸친 경험을 기반으로 프로그래머들은 상속과 믹스인을 선택하는 데 대한 일반적인 가이드라인을 제시하고 있다.
# 먼저 서브클래스화를 살펴보자. 루비에서 클래스는 타입이라는 개념과 연관이 있다. "cat"은 문자열이고 [1, 2]는 배열이라고 이야기하는 것은 자연스럽지만, 좀 더 엄밀하게 말하면 "c... | true |
16ed62c7240b4c086008588f25d0dae12fddacf4 | Ruby | liamzhang40/aA-projects | /W1D5/tree_node/lib/00_tree_node.rb | UTF-8 | 1,407 | 3.6875 | 4 | [] | no_license | class PolyTreeNode
# attr_reader :parent, :children, :value
def initialize(value)
@value = value
@parent = nil
@children = []
end
def add_child(node)
children << node
node.parent = self
end
def remove_child(node)
if children.include?(node)
children.delete(node)
node.pa... | true |
2db691d3f1250cec86bf8fc6ac408ea38db109cb | Ruby | kak79/prime-ruby-onl01-seng-ft-061520 | /prime.rb | UTF-8 | 151 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
if num < 2
return false
else
(2..num-1).to_a.all? {|possible_divisor| num % possible_divisor != 0}
end
end
| true |
08ed92ab8a608188863a93b46a439288e0cd8cb3 | Ruby | portableworld/FizzBuzz | /Ruby.rb | UTF-8 | 698 | 4.28125 | 4 | [] | no_license | #####
# Tested on Windows 7 32-bit
# With Ruby version 1.9.2p0 [i386-mingw32]
#####
# Create a loop that'll run 100 times,
# each time passing a number into the block
1.upto(100) do |num|
if (num % 3 == 0) && (num % 5 == 0)
# This tests whether the number passed in will divide into 3
# with no remainder and then... | true |
8761e162acb32949305802661bcc34f4aa21bf35 | Ruby | tigep37/RubyWork | /palindrome.rb | UTF-8 | 280 | 3.9375 | 4 | [] | no_license | def pal_check(word)
#the reverse function is case sensitive so downcase the word
lc_word = word.downcase
if lc_word == lc_word.reverse
puts "#{word} is a palindrome!"
else
puts "nah, #{word} is just regular"
end
end
pal_check("toot")
pal_check("ToOT")
pal_check("nope") | true |
5d323da3c293447c69be4e06aeff19764260ee1f | Ruby | nejcjelovcan/sswaffles | /lib/sswaffles/storage.rb | UTF-8 | 1,635 | 2.6875 | 3 | [
"MIT"
] | permissive | module SSWaffles
# Storage abstracts out different storage systems (S3, memory, disk, mongo)
# bucket_type:
# nil default S3 API is used (needs s3 instance as :s3 options)
# :Memory buckets are in-memory hashes of key=>value
# :Disk buckets are folders on disk with k... | true |
dbfe9ab3f6ef89375be87591b0e2853c1390b6e0 | Ruby | hamza3202/repositext | /spec/kramdown/parser/folio/helper.rb | UTF-8 | 1,255 | 2.78125 | 3 | [
"MIT"
] | permissive | # Provides helper methods for testing Folio parser
# Wraps xml_fragment in infobase tags
# @param [String] xml_fragment
def wrap_in_xml_infobase(xml_fragment)
%(<infobase>#{ xml_fragment }</infobase)
end
# Wraps xml_fragment in record tags
# @param [String] xml_fragment
def wrap_in_xml_record(xml_fragment)
wrap_i... | true |
48f6c226750d11a68ef6cd11fbb43a2645156c86 | Ruby | keyonce/ttt-5-move-rb-cb-gh-000 | /bin/move | UTF-8 | 346 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
require_relative '../lib/move.rb'
# Code your CLI Here
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
puts "Welcome to Tic Tac Toe!"
puts "Please enter 1-9:"
userInput = gets.strip # gets the user input and calls input_to_index
index = input_to_index(userInput)
move(board, index, char=... | true |
914e50cfd4b0b4cf4c3d330c8ec7ec353a4878a7 | Ruby | stevepolitodesign/po-notes | /test/models/user_test.rb | UTF-8 | 3,145 | 2.53125 | 3 | [] | no_license | require "test_helper"
class UserTest < ActiveSupport::TestCase
def setup
@plan = plans(:one)
@user = User.new(email: "user@example.com", password: "password", password_confirmation: "password", confirmed_at: Time.zone.now, plan: @plan)
end
test "should be valid" do
assert @user.valid?
end
test ... | true |
947b1351484392d0f2f641e7eabb17c14c680947 | Ruby | TamerL/credit_card_validator | /app/models/credit_card.rb | UTF-8 | 1,582 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
# to check the credit card numbers find the type and validate the digits
class CreditCard < ApplicationRecord
# before_save :check_number_errors
# skip_before_action :verify_authenticity_token
# protect_from_forgery prepend: true, with: :exception
belongs_to :card_type
belongs_t... | true |
c201206085655bd1a297eeb3d5543e4d4c3fce33 | Ruby | wichru/codesensei_course | /homework_1/highest_number.rb | UTF-8 | 153 | 3.390625 | 3 | [] | no_license | def highest_number(number)
number.to_s.split('').sort.reverse.join
end
puts highest_number(132)
puts highest_number(1464)
puts highest_number(165423)
| true |
25dd63a214bd21942d2c1b876eee3914ba1a2184 | Ruby | esauter5/Tealeaf | /RubyWebDev/blackjackV2.rb | UTF-8 | 6,455 | 3.8125 | 4 | [] | no_license | class Player
attr_accessor :name, :bank_roll, :hand, :bet, :status
def initialize(name, bank_roll)
@hand = Hand.new
@name = name
@bank_roll = bank_roll
@bet = 5
@status = 'active'
end
def hit_or_stay
if @hand.cards.size == 2
puts "Would you like to hit or stay or double down? (h/... | true |
824bccf15932e8992fb2e21dbf0b5f50264258f3 | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/calendar_sharing_message.rb | UTF-8 | 5,463 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class CalendarSharingMessage < MicrosoftGraph::Models::Message
include MicrosoftKiotaAbstractions::Parsable
##
# The canAccept pr... | true |
8efc2df205e56af2b2e2ad00e6692815997677ae | Ruby | jtb1137/trending-stocks-gem | /lib/trending-stocks-gem/cli.rb | UTF-8 | 1,436 | 3.3125 | 3 | [] | no_license | class TrendingStocksGem::CLI
def call
TrendingStocksGem::Scraper.new.build_stocks
puts ""
puts "----------- TODAYS TRENDING STOCKS -----------"
puts ""
menu
end
def menu
list_stocks
puts ""
puts "Which stock would you like to know more about?"
input = gets.strip
stock = TrendingStocksGem::S... | true |
e25b4d24125784f07402bec45789b8b9189f49f7 | Ruby | yubrew/projecteuler | /problem34.rb | UTF-8 | 202 | 3.640625 | 4 | [] | no_license | def factorial(n)
(1..n).inject(:*) || 1
end
max = 7 * factorial(9)
sum = 0
(10..max).each do |n|
if n == n.to_s.chars.map { |i| factorial(i.to_i) }.inject(:+)
puts n
sum += n
end
end
puts sum
| true |
d17a90a6a4fc9f2594a815310531bfac83ccf614 | Ruby | woolfayeee79/IT-212-Projects- | /Project2/bowling.rb | UTF-8 | 912 | 3.375 | 3 | [] | no_license | # Megan Woolschlager IT 212
# Project number 2
# submission date: 1/29/2018
require "./read-ragged-array"
require "./frame-score"
#read file name from keyboard
print "name of input file: "
input_file = gets.chomp
frames = read_ragged_array(input_file)
score = 0
for i in 1..10
# case of strike with next bal... | true |
f7659425852bf9f0bccf2f28c20d3f3ff56a61a0 | Ruby | angieappiah/method-scope-lab-onl01-seng-ft-012120 | /spec/catch_phrase_spec.rb | UTF-8 | 242 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "spec_helper"
describe "#catch_phrase" do
phrase = 'It's-a me, Mario!'
expect{catch_phrase}.to output("It's-a me, Mario!\n").to_stdout
end
def catch_phrase
phrase = " It's a me"
puts "#{phrase}", Mario!.
end
| true |
4fb02e81261eb16a8c2ea9429d15895daa264d7b | Ruby | levabd/nice-tv-dashboard | /jobs/jira_list_current_sprint_issues.rb | UTF-8 | 3,044 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'jira'
require 'net/http'
require 'json'
# Settings to configure:
# PROJECT: the project path/name
# RAPID_VIEW_ID: id for the rapid view board
# JIRA_CONFIG: credentials to access JIRA
# ISSUE_LISTS: a widget per entry for different statuses (see JIRA_STATUSES)
PROJECT = "WIP"
RAPID_VIEW_ID = 2
JIRA_CONFIG =... | true |
f12d75df75b7f19896a25cc406a7d25230f0a216 | Ruby | oriolgual/fizz_buzz_pro | /lib/fizz_buzzer.rb | UTF-8 | 809 | 3.40625 | 3 | [] | no_license | require 'buzz_rule'
require 'default_rule'
require 'fizz_rule'
require 'fizz_buzz_rule'
require 'meeek_rule'
require 'default_processor'
require 'even_string_processor'
require 'odd_number_processor'
class FizzBuzzer
attr_reader :number
def initialize(number)
@number = number
end
def to_fizz_buzz
pr... | true |
e1c08f10d5aa1f168eab3dd741fe89bff3639164 | Ruby | phifty/agraph | /lib/allegro_graph/proxy/query.rb | UTF-8 | 901 | 2.578125 | 3 | [] | no_license |
module AllegroGraph
module Proxy
# The Query class acts as proxy that bypasses SparQL and Prolog queries to the AllegroGraph server.
class Query
LANGUAGES = [ :sparql, :prolog ].freeze unless defined?(LANGUAGES)
attr_reader :server
attr_reader :resource
attr_reader :language
... | true |
832a2bbd0778e9e2cab0612cc442ca272839386f | Ruby | xsuchy/foreman_api | /lib/foreman_api/base.rb | UTF-8 | 3,714 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'rest_client'
require 'oauth'
require 'json'
require 'foreman_api/rest_client_oauth'
module ForemanApi
class Base
API_VERSION = "2"
attr_reader :client, :config
def initialize(config, options = {})
@client = RestClient::Resource.new(
config[:base_url],
{ :user => c... | true |
cd04661bb73ff6a28b9d9817bfa9d2abb7b56892 | Ruby | ben-altman/parrot-ruby-online-web-sp-000 | /parrot.rb | UTF-8 | 148 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `parrot` that outputs a given phrase and
# returns the phrase
def parrot (verbiage = "Squawk!")
puts "#{verbiage}"
verbiage
end
| true |
37a17039e891f8d535ae800509225a27312627e9 | Ruby | attribution/sequel-redshift | /lib/sequel/extensions/redshift_string_agg.rb | UTF-8 | 3,151 | 2.859375 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
#
# Please consider using patched `string_agg` extension, it properly handles all supported DB adapters
# including Redshift out of the box.
#
# The redshift_string_agg extension adds the ability to perform database-independent
# aggregate string concatentation on Amazon Redshift.
# Relat... | true |
c4ca1eb16ca7db0cea5a0a8b62f1fbb45bd4ab20 | Ruby | ianagbip1oti/advent-of-code-2020 | /ruby/day07.rb | UTF-8 | 45,332 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'set'
def parse_line(str)
bag, contains = str.split 'bags contain'
contains = contains.split(',').map do
words = _1.split
qty = words[0].to_i
color = words[1..2].join ' '
[color, qty]
end
[ bag.strip, contains.to_h ]
end
BAGS = DATA.map { parse_line _1 }.to_h
def select_containin... | true |
23535d09eecb2552b0ca9ce654720ae53f3c7c60 | Ruby | yuya-takeyama/flagship | /lib/flagship.rb | UTF-8 | 1,840 | 2.78125 | 3 | [
"MIT"
] | permissive | require "flagship/version"
require "flagship/context"
require "flagship/dsl"
require "flagship/feature"
require "flagship/features"
require "flagship/flagset"
require "flagship/flagsets_container"
module Flagship
class NoFlagsetSelectedError < ::StandardError; end
class << self
def define(key, options = {}, &... | true |
76c196b38c1654f2a6e13145c0b9025186de2ebf | Ruby | swistak35/polish-bank-to-qif | /konwertuj.rb | UTF-8 | 9,131 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'csv'
require 'bigdecimal'
require 'ostruct'
module Heuristics
class Heuristic
def call(entry)
if satisfied?(entry)
Result.new(result_account(entry), result_title(entry))
end
end
def result_title(entry)
entry.title
end
end
class AccountHeur... | true |
ac93858875316ebc75342c0534ebd5460902088b | Ruby | roykim79/react-rails-go-fish | /spec/models/go_fish_spec.rb | UTF-8 | 3,878 | 3.296875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe GoFish do
let(:player1) { Player.new('Jim', 1) }
let(:player2) { Player.new('Bob', 2) }
let(:game) { GoFish.new([player1, player2]) }
describe '#initialization' do
it 'has a deck' do
expect(game.deck).not_to be_nil
end
end
describe '#start' do
it '... | true |
345739a785fe03ae15d502724496e92fac1d5feb | Ruby | clirdlf/hc-reminders | /excel.rb | UTF-8 | 3,224 | 2.84375 | 3 | [] | no_license | #! /usr/bin/env ruby
# frozen_string_literal: true
require 'erb'
require 'optparse'
require 'pp'
require 'active_support'
require 'active_support/core_ext'
require 'mail'
require 'roo'
##
# Script for generating emails for Hidden Collections Grantees
#
# Author:: Wayne Graham (mailto:wgraham@clir.org)
# Copyright:: ... | true |
4ff6dc83e242341ecd23c86ce962d91cd539c3b6 | Ruby | drewemartin/temp_athena | /system/x_recycle_bin/tables/SCHOOL_START_DATES.rb | UTF-8 | 3,361 | 2.5625 | 3 | [] | no_license | #!/usr/local/bin/ruby
require "#{$paths.base_path}athena_table"
class SCHOOL_START_DATES < Athena_Table
#---------------------------------------------------------------------------
def initialize()
super()
@table_structure = nil
end
#------------------------------------------------... | true |
285b255be135617d75bd4e2503156976e0fb2243 | Ruby | nabe-pot/ruby-practices | /05.ls/ls.rb | UTF-8 | 3,879 | 3.046875 | 3 | [] | no_license | # frozen_string_literal: true
require 'optparse'
require 'etc'
# ハードリンク数・ユーザ・グループ・ファイルサイズ・作成時間取得
# @param [String] file_name
def get_hardlink(file_name)
"#{File.stat(file_name).nlink} "
end
def get_user(file_name)
"#{Etc.getpwuid(File.stat(file_name).uid).name} "
end
def get_group(file_name)
"#{Etc.getgrgid(F... | true |
9a427752b312f08fbf3abbca38ca33754d04d1c1 | Ruby | Cyfon7/Ciclos | /solo_pares2.rb | UTF-8 | 60 | 2.828125 | 3 | [] | no_license | numero = ARGV[0].to_i
for i in (1..numero)
puts i*2
end | true |
4660fae6c28e9859b74de7741f93eb6d42d419e9 | Ruby | m0h4x/eloquent-ruby | /chapter_20/module_inclusion_hook.rb | UTF-8 | 636 | 3.53125 | 4 | [] | no_license | # the module analog of inherited is included
module WritingQuality
def self.included(klass)
puts "Hey, I've been included in #{klass}"
end
def number_of_cliches
# omited...
end
end
# combination of class & instance methods mixed into a class as a unit.
module UsefulMethods
module ClassMethods
... | true |
3bfc35e92e9db789c44b446087382293576f52c3 | Ruby | sarcilav/google-docs-ruby | /model/state.rb | UTF-8 | 1,166 | 2.984375 | 3 | [] | no_license | class State
attr_accessor :id, :name, :cities
def initialize(id, name, cities)
@id = id
@name = name
@cities = cities
end
def to_s
"#{@name}\n\t\t#{@cities}"
end
def self.getState(key)
parse_instance(API::Gdocs.getSheet(key),key)
end
def get_totals
if @totales.nil?
@totale... | true |
b0b31e17ea0e61293ee0e4b68a08ec950c1cea29 | Ruby | ucsblibrary/geniza | /config/initializers/add_uploads_from_csv.rb | UTF-8 | 1,051 | 2.609375 | 3 | [] | no_license | require 'spotlight/add_uploads_from_csv'
class Spotlight::AddUploadsFromCSV
##
# Re-define the perform method so it will process an image that comes in
# as a file as well as images that come in via a url
def perform(csv_data, exhibit, _user)
encoded_csv(csv_data).each do |row|
# The CSV row must hav... | true |
4825b5ebc132c6ff0225ee6c947f97566ef7f105 | Ruby | aquach/advent-of-code | /2020/ruby/22/solve.rb | UTF-8 | 659 | 3.0625 | 3 | [] | no_license | require 'set'
if !true
a = File.readlines('sampleinput.txt').map(&:chomp)
else
a = File.readlines('input.txt').map(&:chomp)
end
if !true
def p(*args)
$a = args
end
at_exit { Kernel.p(*$a) }
end
a = a.slice_when { |f| f == '' }.to_a.map { |f|
if f.last == ''
f.pop
end
f
}
p1, p2 = a
p1.shift
... | true |
864116cd6a56e0337cf03878d477f05fd00fad80 | Ruby | prachyathit/befed-base | /lib/modules/omise_gateway.rb | UTF-8 | 672 | 2.671875 | 3 | [] | no_license | module OmiseGateway
Omise.api_key = ENV['omise_secret_key']
class << self
def create_charge(order, token)
charge = Omise::Charge.create({
amount: (order.total * 100).to_i,
currency: "thb",
card: token
})
if charge.paid
Rails.logger.info("Successfully paid by cr... | true |
51914b296133e40f05cd8e0185aa94c899183ded | Ruby | plantran/learn2shell | /games/admin_game.rb | UTF-8 | 3,488 | 3.125 | 3 | [] | no_license | module Games
# Contains all the methods and logic for the admin game part.
class AdminGame
require_relative '../helpers/custom_admin_system'
def initialize
@cs = Helpers::CustomAdminSystem.new
@admin_path = "#{__dir__}/../#{ENV['ADMIN_PATH']}/admin"
@root_path = "#{__dir__}/../#{ENV['ROOT... | true |
c73a4aab52e6f6ecdb1bc8f2b537e13fe9275e4b | Ruby | petertseng/exercism-problem-specifications | /exercises/beer-song/verify.rb | UTF-8 | 924 | 3.203125 | 3 | [
"MIT"
] | permissive | require 'json'
require_relative '../../verify'
def verse(n)
pre = "#{bottles(n).to_s.capitalize} on the wall, #{bottles(n)}."
post = ", #{bottles((n - 1) % 100)} on the wall."
mid = case n
when 0; 'Go to the store and buy some more'
when 1; 'Take it down and pass it around'
else 'Take one down and pa... | true |
d7505ad78b3bec0c0d4e340b50aecd5fb40d69be | Ruby | orhanna14/oo-tic-tac-toe | /spec/player_input_spec.rb | UTF-8 | 723 | 2.859375 | 3 | [] | no_license | require "spec_helper"
require_relative "../lib/player_input.rb"
require_relative "../lib/coordinates.rb"
require_relative "../lib/grid.rb"
require_relative "../lib/printer.rb"
RSpec.describe PlayerInput do
describe "#get_valid_coordinate" do
it "repeatedly asks for valid coordinate, returns the value when valid... | true |
43b82ad64da99c072b4ef3cab79a31f55f1cfa43 | Ruby | GuttermanA/spellbook-api | /lib/tasks/scheduled.rake | UTF-8 | 856 | 2.640625 | 3 | [
"MIT"
] | permissive | namespace :update do
desc "Checks if current Magic Sets match the https://api.magicthegathering.io sets. If not, seed cards from missing set."
task :seed_new_set => :environment do
puts "Checking for new set(s)"
new_sets = MagicSet.check_for_new_sets
if new_sets
new_sets_list = new_sets.join... | true |
05774a6a3751237eafe7df968cbb82bf9254c7d0 | Ruby | khamla719/phase-0 | /week-5/group-research-methods/my_solution.rb | UTF-8 | 2,098 | 4.3125 | 4 | [
"MIT"
] | permissive | # Research Methods
# I spent 2 hours on this challenge.
# Person 2: Modifying Existing Data
i_want_pets = ["I", "want", 3, "pets", "but", "only", "have", 2]
my_family_pets_ages = {"Evi" => 6, "Ditto" => 3, "Hoobie" => 3, "George" => 12, "Bogart" => 4, "Poly" => 4, "Annabelle" => 0}
def my_array_modification_method... | true |
3fbc2b9cc381e9dff0c311dd964965c7faaf1405 | Ruby | woobaik/Alorithm_Practice | /recursion/factorial.rb | UTF-8 | 574 | 4.0625 | 4 | [] | no_license | def factorial(num)
return 1 if num == 1
num * factorial(num -1)
end
# factorial(10)
def palindrome(str)
return true if str.length == 1 || str.length == 0
if str[0] == str[-1]
palindrome(str[1..-2])
else
false
end
end
def z_counter(n)
if n == 0
puts "nomore bottles of beer on the w... | true |
89ddacc405f50902b2ebe3b269578e9718e18023 | Ruby | sfroestl/onespark | /lib/tools/github/resources/org.rb | UTF-8 | 1,193 | 2.515625 | 3 | [] | no_license | ##
# The Org Model class
#
# this sub class represents a GitHubApi Org resource
#
# Author:: Sebastian Fröstl (mailto:sebastian@froestl.com)
# Last Edit:: 21.07.2012
class GitHubApi
# Represents a single GitHub Org and provides access to its data attributes.
class Org < Entity
attr_reader :avatar_url, :bil... | true |
8fe08d1992a88859293338708b22c6f3b13c07e3 | Ruby | rokn/Count_Words_2015 | /fetched_code/ruby/in_spec.rb | UTF-8 | 1,575 | 3.09375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
RSpec.describe TTY::Prompt::Question, '#in' do
subject(:prompt) { TTY::TestPrompt.new }
it "reads range from option" do
prompt.input << '8'
prompt.input.rewind
answer = prompt.ask("How do you like it on scale 1-10?", in: '1-10')
expect(answer).to eq('8')
end
it 'reads numbe... | true |
83b840b695035fc06c79ee4c8bd31995f60064b4 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/nth-prime/c8ada55a580d4c54a6b38817d8f11c0e.rb | UTF-8 | 519 | 3.8125 | 4 | [] | no_license | class Prime
def self.nth(number)
new.nth(number)
end
def nth(number)
raise ArgumentError, "must be greater than zero" unless number > 0
primes = (1..Float::INFINITY).lazy.select { |integer|
is_prime?(integer)
}.take(number).reduce([]) { |primes, prime| primes << prime }
primes[number ... | true |
dff0117ef15cdde20e83a9e34bf143387fd6fdff | Ruby | steve-c-thompson/RubyBattleship | /lib/battleship.rb | UTF-8 | 1,017 | 2.890625 | 3 | [] | no_license |
class Battleship
def self.run
b = Battleship.new
b.welcome
end
def initialize
end
def welcome
puts "Welcome to BATTLESHIP"
puts
options_list
end
def options_list
user_input = ""
options = ["p", "i", "q"]
until options.include?(user_input)
put... | true |
52600e08bda3dcf793acfc4d261ec3e5da222a74 | Ruby | iboard/yarb | /app/models/email_confirmation.rb | UTF-8 | 731 | 2.6875 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-"
# EmailConfirmations generates a random token for a user and email
# When confirmed! the attribute confirmed_at is set to now.
class EmailConfirmation
include Persistable
key_method :token
attribute :token, unique: true
attribute :email, unique: true
attribute :user_id, uniqu... | true |
1ef0f8782a3f18fa4c06d95b83dafdff5091157a | Ruby | RubyCamp/rc2013w_g4 | /lib/gameover.rb | UTF-8 | 371 | 2.640625 | 3 | [] | no_license | # encoding: utf-8
class Gameover < Scene
def initialize
@bg_img = Image.load("images/tokiojo_gameover.png")
end
def init(*args)
@score = args[0]
end
def play
if Input.keyPush?(K_RETURN)
Scene.delete_scene(:game)
game = Game.new
Scene.add_scene(:game, game)
Scene.set_scene(:ga... | true |
1ef9679d189ea3953e940015356552df7d5a4506 | Ruby | iliankostov/Sandbox | /Ruby/loops_and_iterators.rb | UTF-8 | 384 | 3.5625 | 4 | [] | no_license | counter = 1
until counter > 10
puts counter
counter += 1
end
puts "-------------------"
for num in 1..15
puts num
end
puts "-------------------"
i = 20
loop do
i -= 1
next if i % 2 == 1
puts "#{i}"
break if i <= 0
end
puts "-------------------"
array = [1,2,3,4,5]
array.each do |x|
x += 10
puts... | true |
8ef629f4b6c3346077798a25a910ec5213a47f68 | Ruby | PetePhx/basic-ruby | /small_problems/medium_2/05_triangle_sides.rb | UTF-8 | 688 | 4.25 | 4 | [] | no_license | # Triangle Sides
# Write a method that takes the lengths of the 3 sides of a triangle as
# arguments, and returns a symbol :equilateral, :isosceles, :scalene, or
# :invalid depending on whether the triangle is equilateral, isosceles, scalene,
# or invalid.
def triangle(a, b, c)
sides = [a, b, c].sort
return :inva... | true |
34c0c92a78ace3eb6d0f7ea97a39f89afb8b29e0 | Ruby | jchen623/tip_calculator | /tip_calculator.rb | UTF-8 | 409 | 3.171875 | 3 | [] | no_license | meal = 20
tax = 0.12
tip = 0.2
tax_value = meal*tax
meal_with_tax = meal+tax_value
tip_value = meal_with_tax*tip
total_cost = meal_with_tax+tip_value
puts "The pre-tax cost of your meal was $%.2f." % meal
puts "At %d%%, tax for this meal was $%.2f." % [tax*100, tax_value]
puts "For a %d%% tip, you should leave $%.2f.... | true |
db3102e1108330ecf74db627369a909cee18a43d | Ruby | gfcharles/euler | /ruby/euler034.rb | UTF-8 | 585 | 3.890625 | 4 | [] | no_license | #!/usr/bin/ruby
def factorialList(n)
(2..n).inject([1,1]) {|list, i| list << i * list.last}
end
def sum_of_digits?(n, factorials)
n == n.to_s.split(//).inject(0) {|sum, digit| sum += factorials[digit.to_i] }
end
def get_upper_bound(nineFactorial)
base = nineFactorial
digit_count = 2
upper_bound = 0
w... | true |
118faabb45f5ce432799402f5937c96e7125a80e | Ruby | mathildathompson/wdi_sydney_feb | /students/anne_homann/mtalab.rb | UTF-8 | 795 | 3.4375 | 3 | [] | no_license |
# nline: ['Times Square', '34th', '28th', '23rd', 'Union Square', '8th']
# is the new syntax used in Ruby
# old one is being used below
subway = {
"N_line" => ['Times Square', '34th', '28th', '23rd', 'Union Square', '8th'],
"L_line" => ['8th', '6th', 'Union Square', '3rd', '1st'],
"Six_line" => ['Grand Central... | true |
6575559233ac58d870a7f10bc01d9b8f89456339 | Ruby | rkstarnerd/LS | /Exercises/Easy_3/palindrome1.rb | UTF-8 | 55 | 2.734375 | 3 | [] | no_license | def palindrome?(object)
object == object.reverse
end
| true |
4b6e3eb1821337615247089812d8cfd88a24c517 | Ruby | karthick-soolapani/code-problems | /coderbyte/easy/q25_number_search.rb | UTF-8 | 745 | 4.40625 | 4 | [] | no_license | # Using the Ruby language, have the function NumberSearch(str) take the str parameter,
# search for all the numbers in the string, add them together, then return that final
# number. For example: if str is "88Hello 3World!" the output should be 91. You will
# have to differentiate between single digit numbers and multi... | true |
3648b21087f39d6a6165bd649e6d036c2f9592f4 | Ruby | TigerWolf/cherby | /spec/task_spec.rb | UTF-8 | 1,490 | 2.625 | 3 | [
"MIT"
] | permissive | require_relative 'spec_helper'
require 'cherby/task'
require 'cherby/journal_note'
module Cherby
describe Task do
context "Instance methods" do
before(:each) do
@task_xml = File.read(File.join(DATA_DIR, 'task.xml'))
end
describe "#id" do
it "returns the value from the TaskID fi... | true |
8bfc760a96f6b73d57d27db4a400b40d94be12c8 | Ruby | flood4life/health-practice | /app/services/health_checker.rb | UTF-8 | 889 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
class HealthChecker
Status = Struct.new(:healthy, :services, keyword_init: true)
Services = Struct.new(:mongodb, :redis, keyword_init: true)
def initialize
@mongodb_client = Mongoid.default_client
@redis_conn = RedisConnection.new.get
end
def status
services = serv... | true |
3b4d7bb082ea00dd1459f7139941ed1cfaae8176 | Ruby | jashmenn/poolparty | /test/lib/core/integer_test.rb | UTF-8 | 547 | 2.765625 | 3 | [
"MIT"
] | permissive | require "#{File.dirname(__FILE__)}/../../test_helper"
class IntegerTest < Test::Unit::TestCase
context "Integer" do
should "have months defined" do
# 60 seconds * 60 minutes * 24 hours * 30 days
assert_equal 60*60*24*30, 1.months
assert_equal 60*60*24*30*2, 2.months
assert_equal 60*60*24*... | true |
f3d952740905db0427d3e4d282f2a219fc483b0f | Ruby | cassar/skrol_basic | /lib/users/enrolment_manager.rb | UTF-8 | 1,515 | 2.640625 | 3 | [] | no_license | class EnrolmentManager
def initialize(enrolment)
@enrolment = enrolment
@course = enrolment.course
@course_manager = CourseManager.new(@course)
@existing_scores = @enrolment.user_scores.pluck(:word_id)
end
attr_reader :enrolment
attr_reader :course
attr_reader :course_manager
def next_word... | true |
a051617d9af5101db04c1dd0fe7e5dc05a786608 | Ruby | sciencehistory/chf-sufia | /lib/chf/reports/metadata_completion_report.rb | UTF-8 | 2,745 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | module CHF
module Reports
class MetadataCompletionReport
attr_reader :lookup, :published, :full, :totals
def initialize
@lookup = {
Rails.configuration.divisions[0] => :archives,
Rails.configuration.divisions[1] => :oral,
Rails.configuration.divisions[2] => :mus... | true |
7896cc8bafc318192e4c63c1f090a0c01cdf4349 | Ruby | lakshmananmurugesan/mesoketes_problem | /attack.rb | UTF-8 | 1,534 | 3.40625 | 3 | [] | no_license | class Attack
attr_accessor :attack_count
def initialize
@attack_count = 0
end
# Check if attack happened
def attacked? wall_strength, tribal_strength, direction
strength = 0
case direction
when "N"
strength = wall_strength.north_side
when "S"
strength = wall_strength.... | true |
ecc4f40e9990b9870adbb2b37bc320d54691d726 | Ruby | laarchambault/ruby-oo-self-cash-register-lab-atlanta-web-021720 | /lib/cash_register.rb | UTF-8 | 1,096 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class CashRegister
attr_reader :discount, :items
attr_accessor :total
def initialize(employee=nil)
@total = 0.0
@discount = employee
@items = []
@price_array = []
@last_transaction_items = []
@last_transaction_prices = []
end
def add_item(title, pr... | true |
7b74526917a5eb3c32c95cffbd2b9f210acfba09 | Ruby | jpheos/batch-481 | /05-Rails/03-Rails-restaurant-reviews/Livecode/parks_and_plants/db/seeds.rb | UTF-8 | 1,389 | 2.6875 | 3 | [] | no_license | puts 'Clean DB'
Garden.destroy_all
puts 'Seeds DB'
gardens = [
{
name: 'Jardin des plantes',
banner_url: 'https://images.unsplash.com/photo-1483809715206-0499044b5b69?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80'
},
{
name: 'Jardin du Luxembourg',
banner_url: 'https://images.unsplash.com/phot... | true |
42f19bc91ab76941daedb9999e913cc7affaf569 | Ruby | marioa7770/apples-and-holidays-onl01-seng-pt-061520 | /lib/holiday.rb | UTF-8 | 533 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
holiday_supplies = {
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
:summer => {
:fourth_of_july => ["Fireworks", "BBQ"]
},
:fall => {
:thanksgiving => ["Turkey"]
},
:spring => {
:memorial_day => ["BBQ"]
}
}
def second_supply_for_f... | true |
938a0ebf68d70917f47ef844ea9e3fadafb4bc2f | Ruby | equivalent/maze_magic | /lib/maze_magic/renderer/console_renderer.rb | UTF-8 | 491 | 2.796875 | 3 | [
"MIT"
] | permissive | module MazeMagic
module Renderer
class ConsoleRenderer
attr_reader :cells_grid
attr_writer :printer
def initialize(cells_grid:)
@cells_grid = cells_grid
end
def call
cells_grid.each do |row|
row.each do |cell|
printer.call(cell.to_console_print... | true |
078ecfd5131b65cfb968f7ce894a32cc89e23417 | Ruby | theIanMilan/avion | /rubyactivities/century_from_year.rb | UTF-8 | 399 | 3.609375 | 4 | [] | no_license | def centuryFromYear(year)
return 1 if year < 100
if year.to_s[-2..-1].to_i.between?(01,99)
year += 100
end
year.to_s[0..(year.to_s.length - 3)].to_i
end
p centuryFromYear(1705) == 18
p centuryFromYear(1900) == 19
p centuryFromYear(1601) == 17
p centuryFromYear(2000) == 20
p centuryFromYear(900) == 9
p ... | true |
85d70d545c1c7039780eeb2d0df8e889f67aa949 | Ruby | peter/rails101 | /code/ruby/exceptions.rb | UTF-8 | 466 | 2.578125 | 3 | [] | no_license | begin
raise(ArgumentError, "No file_name provided") if !file_name
content = load_blog_data(file_name)
raise "Content is nil" if !content
rescue BlogDataNotFound
STDERR.puts "File #{file_name} not found"
rescue BlogDataConnectError
@connect_tries ||= 1
@connect_tries += 1
retry if @connect_tries < 3
... | true |
da7ebc098175a95c6eb0da40799b0e88a9a00e19 | Ruby | shachsan/collections_practice-dumbo-web-102918 | /collections_practice.rb | UTF-8 | 579 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def sort_array_asc(arr)
arr.sort
end
def sort_array_desc(arr)
arr.sort.reverse
end
def sort_array_char_count(arr)
arr.sort_by{|ele|ele.length}
end
def swap_elements(arr)
new_arr = [arr[0]]+ (arr[1],arr[2] = arr[2], arr[1])
end
def reverse_array(arr)
arr.reverse
end
def kesha_maker(names)
names... | true |
f084a125705499333e447933435435059773d4fc | Ruby | AnnaAguilar/registro_academico | /registro.rb | UTF-8 | 280 | 3.3125 | 3 | [] | no_license | class Registro
attr_accessor :codigo
attr_accessor :nome
def initialize (codigo, nome)
@nome = nome
@codigo = codigo
end
#Compara o nome e codigo do curso
def == (outro)
@codigo == outro.codigo && @nome == outro.nome
end
end | true |
bff7d0c54d79f39581941c9175f5a60878da2aa9 | Ruby | bedwardsphoto/oo-email-parser-v-000 | /lib/email_parser.rb | UTF-8 | 405 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
require 'pry'
class EmailParser
def initialize(email_string)
@email_string=email_string
end
def parse
holder=@email... | true |
942aa54c82cdd0278c4c356e825bd70849e68761 | Ruby | lilyylarsen/ttt-1-welcome-rb-q-000 | /lib/welcome.rb | UTF-8 | 175 | 2.953125 | 3 | [] | no_license | # Edit this file to output "Welcome to Tic Tac Toe!"
# You can seeput what this file does by running:
# ruby lib/welcome.rb from your terminal.
puts "Welcome to Tic Tac Toe!"
| true |
356c19d7854cf0e0a83240dd3a0a8c5f1ed70971 | Ruby | pedz/Raptor | /app/models/ldap_user.rb | UTF-8 | 2,366 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#
# Copyright 2007-2011 Ease Software, Inc. and Perry Smith
# All Rights Reserved
#
#
# This is a class that fetches LDAP entries from Bluepages of type
# ibmPerson. The default key is uid which is the "employee number".
# Thus the following would find me:
#
# LdapUser.find('C-5UEV897')
#
... | true |
669a1e5d15f4bd0db1195e4e6e3f2b23117ac365 | Ruby | geebabygee/food-dev-livecode1 | /app/repositories/customer_repository.rb | UTF-8 | 912 | 3.0625 | 3 | [] | no_license | require_relative "base_repository"
require_relative "../models/customer"
class CustomerRepository < BaseRepository
private
def load_csv # From CSV strings ---> Ruby instances of element
csv_options = {headers: :first_row, header_converters: :symbol}
CSV.foreach(@csv_file, csv_options) do |row|
#row is now ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.