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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3ceacc50c9b9f971dc9bddde39ef0bd3079f2f7f | Ruby | rl-interpretation/understandingRL | /go/go_puzzles/puzzle.rb | UTF-8 | 5,260 | 3.375 | 3 | [
"MIT"
] | permissive | # Convert a Puzzle from Online Go Server [https://online-go.com/puzzles] to SGF.
require 'httparty'
class Puzzle
include HTTParty
base_uri 'https://online-go.com/api/v1/puzzles/'
attr_accessor :id, :name, :description, :initial_state_white, :initial_state_black, :game_size, :tree, :initial_player, :source
de... | true |
daa7797ffc60f75408e0650a01cb999acd292a57 | Ruby | learn-co-students/nyc-web-071519 | /06-oo-mini-project-review/tools/console.rb | UTF-8 | 1,490 | 2.515625 | 3 | [] | no_license | require_relative '../config/environment.rb'
recipe1 = Recipe.new("Recipe 1")
pizza = Recipe.new("Pizza")
pb_and_j = Recipe.new("PB&J")
pie = Recipe.new("Pie")
brownies = Recipe.new("Brownies")
plain_kale = Recipe.new("Just a head of kale.")
taytay = User.new("Taylor Swift")
gordo = User.new("Gordon Ramsey")
simba = U... | true |
a74e4d6669231e76fcf17fabf89ba4496186fc86 | Ruby | EGMartins/monitoring | /online_assigner.rb | UTF-8 | 705 | 2.765625 | 3 | [] | no_license | require 'redis'
require 'json'
class OnlineAssigner
extend Forwardable
DEFAULT_EXPIRATION_TIME = 28860
def_delegators :@data, :equipment_id, :t1, :t2, :ttl
def initialize(data)
@data = OpenStruct.new(data)
end
def self.call(data)
new(data).call
end
def call
return unless data
key ... | true |
07ca39a0b640daae05bf0e2af81d4b56e9a3925f | Ruby | itggot-julia-ekeblad/standard-biblioteket | /lib/square_num.rb | UTF-8 | 187 | 4.0625 | 4 | [] | no_license | # Public: Returns the number squared.
#
# num - Your desired number, an Integer.
#
# square_num(7)
# # => 49
#
# Returns the number squared.
def square_num(num)
return num*num
end | true |
1b49f7da5eb159abbfb3f7f5ca254acbcc66244a | Ruby | noobjey/sales_engine | /lib/invoice_item_repository.rb | UTF-8 | 3,368 | 2.859375 | 3 | [] | no_license | require_relative 'load_file'
require 'date'
require_relative 'invoice_item'
class InvoiceItemRepository
attr_accessor :sales_engine,
:invoice_items
include LoadFile
def initialize(sales_engine)
@sales_engine = sales_engine
@invoice_items = []
end
def load_data(path)
file ... | true |
bd2d5ae7686171c71da17b23ed3dc7b6954dea43 | Ruby | milevy1/ruby-exercism | /series/series.rb | UTF-8 | 282 | 3.328125 | 3 | [] | no_license | class Series
attr_reader :int_series
def initialize(int_series)
@int_series = int_series
end
def slices(n)
raise ArgumentError if n > int_series.length
int_series.each_char
.each_cons(n)
.map { |sequence| sequence.join }
end
end
| true |
5e241ee412b193f003e32b8eddc7e95f379bb868 | Ruby | debkwon/rampup | /number_guessing.rb | UTF-8 | 576 | 4.0625 | 4 | [] | no_license | def answer
answer = rand(100)
number_guesses = 5
while number_guesses >0
puts "I have chosen a random number. See if you can guess it!
What is your guess?"
guess = gets.chomp
if guess == answer
puts "Congratulations! You got it!"
break
elsif guess > answer
number_guesses-=1
puts "That was... | true |
bb5c1470a1aa80fb2a24abaeb2c0458c561b1b37 | Ruby | vaadin-miki/VSinatra | /data/person.rb | UTF-8 | 738 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | # these are models for test environment
require 'vaadin/jsonise'
class Person
attr_accessor :first_name, :last_name, :city, :country, :id, :year
include Jsonise
json_virtual_attributes :display_name
# @return [Person] that has the given id, or nil
def self.find_by_id(id)
find_all.find {|x| x.id.to... | true |
f7eb692a38e3d2c9730252cb5403e551f98f1c64 | Ruby | rajeshsurana/Ruby-Portfolio | /LearningPoint/Queue.rb | UTF-8 | 518 | 4.0625 | 4 | [] | no_license | =begin
Queue using array
=end
class Queue
def initialize
@elements = []
end
def enqueue(num)
@elements.push num
end
def dequeue
@elements.shift
end
def length
@elements.length
end
def display
p "Oldest element: #{@elements.join("<--")} :Newest element"
end
end
q = Queue.new
p "Enqueuing 10 #{q... | true |
afbedb58ad2b0ac2263d023c22d5a6c1a441a325 | Ruby | gglin/project-euler | /ruby_all/246.rb | UTF-8 | 884 | 3.390625 | 3 | [] | no_license | # Problem 246: Tangents to an ellipse
# http://projecteuler.net/problem=246
#
# A definition for an ellipse is:
# Given a circle c with centre M and radius r and a point G such that d(G,M)<r, the locus of the points that are equidistant from c and G form an ellipse.
#
# The construction of the points of the ellipse ... | true |
449ff9e71882727b68addd3549a0d954f4690544 | Ruby | ql/phony | /lib/phony/national_splitters/default.rb | UTF-8 | 429 | 2.546875 | 3 | [
"MIT"
] | permissive | module Phony
module NationalSplitters
# TODO Default = Fixed.new(...)?
#
class Default < DSL
def self.instance_for
@instance ||= new
end
def split national_number
[national_number]
end
def plausible? rest, size, hints = {}
true
end... | true |
0727f1181c74a85e7575bac5eb237cfc8cfa60d4 | Ruby | innervisions/object-oriented-programming | /06_easy_2/07.rb | UTF-8 | 2,781 | 4.03125 | 4 | [] | no_license | # 07 - Pet Shelter
class Pet
def initialize(species, name)
@species = species
@name = name
end
def to_s
"a #{@species} named #{@name}"
end
end
class Owner
attr_reader :name, :number_of_pets
def initialize(name)
@name = name
@number_of_pets = 0
end
def adopt_pet
@number_of_pet... | true |
8b9bb7c0451ff44c9e7711cb8dca0cad7eaa27de | Ruby | Slouch07/Ruby_Basics | /Strings/Goodbye_not_Hello.rb | UTF-8 | 299 | 4.09375 | 4 | [] | no_license | # Q: Given the following code, invoke a destructive method on greeting so that Goodbye!
# is printed instead of Hello!.
greeting = 'Hello!'
puts greeting
# My A:
greeting.sub!('Hello', 'Goodbye')
puts greeting
# LS: A
# greeting = 'Hello!'
# greeting.gsub!('Hello', 'Goodbye')
# puts greeting | true |
525501d68ad5192bd90cdd5d0b4ed03987e21ddd | Ruby | AnneV/TorballProject | /torball/db/populate/02_page.rb | UTF-8 | 32,109 | 2.53125 | 3 | [] | no_license | # Page d'accueil
Page.create(:id => 1,
:published => true,
:home => true,
:title => "Site officiel de la commission TORBALL de la Fédération
Française Handisport",
:content => "<p>Que vous connaissiez ou non l'un de ces deux seuls
sports d'équipe ... | true |
8f299dd39f89e4525aa50c2cd7b307599e6583f4 | Ruby | baweaver/matchable | /benchmarks/dynamic_vs_generated_benchmark.rb | UTF-8 | 2,880 | 3.1875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -W0
require 'matchable'
require 'benchmark/ips'
class PersonMacro
include Matchable
deconstruct :new
deconstruct_keys :name, :age
attr_reader :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
class PersonDynamic
VALID_KEYS = %i(name age)
attr_reade... | true |
2ca32ba7e7dbd9c07d6c89b9e7f556607bdcad14 | Ruby | npendery/blackjack | /deck.rb | UTF-8 | 536 | 3.6875 | 4 | [] | no_license | require_relative "card"
require_relative "hand"
require "pry"
SUITS = ["♠", "♥", "♦", "♣"]
VALUES = ["2","3","4","5","6","7","8","9","10","J","Q","K","A"]
class Deck
attr_reader :stack
def initialize
@stack = []
SUITS.each do |suit|
VALUES.each do |value|
@stack << Card.new(value, suit)
... | true |
1929ce4cc29b1e9df77517bcd75de29692dfb1cb | Ruby | mojoD/hack-spi | /sf2spi/sf2spi.rb | UTF-8 | 57,208 | 2.984375 | 3 | [] | no_license | #! /usr/bin/env ruby
#
# usage: sf2SonicPi0.rb -options [SoundFontFile] [OutputDirectory]
#
# This program reads in a soundfont file that has sound font information in it. It runs a program called sf2comp.exe which decompiles a soundfont file and puts into an structured file that is human readable.
# This pro... | true |
546cf183c9d259b7a26f67d624dd26e4f40b6570 | Ruby | timoxman/battleships | /spec/board_spec.rb | UTF-8 | 1,513 | 3.265625 | 3 | [] | no_license | require 'board'
describe Board do
context 'begin a new game' do
let(:ship1) { double :ship, length: 2, location: [2,5] }
it 'allows a ship to be placed anywhere on a board (UB1)' do
board1 = Board.new(3)
board1.place_ship(ship1,2,"V")
#subject.place_ship(ship) - when to use subject?
... | true |
11ac34ccf1af6966c1d990097215f0d8564c0aeb | Ruby | agm1988/restaurants | /app/services/restaurants_search_service.rb | UTF-8 | 459 | 2.515625 | 3 | [] | no_license | module RestaurantsSearchService
def self.call(params)
restaurants = if params[:search].present?
Restaurant
.open
.where('name ilike :query OR description ilike :query OR cousine ilike :query',
query: "%#{params[:search][:... | true |
6affbbdf12e6a4e3949190b850a91d7e12eb2252 | Ruby | sshruti002/rspec | /03_simon_says/simon_says.rb | UTF-8 | 514 | 3.78125 | 4 | [] | no_license | def echo a
return a
end
def shout a
return a.upcase
end
#def repeat text
#print text," ",text
#end
def repeat(input, n=2)
([input] * n).join ' '
end
def start_of_word (word,n)
return word[0,n]
end
def first_word(word)
x=word.split(' ')
return x[0]
end
def titleize(sentence)
small_words = %w[on the and over]... | true |
c7a6f69efffad40acb6ea054ba2667d3bfd57027 | Ruby | nickcen/leetcode | /p557.rb | UTF-8 | 115 | 3.109375 | 3 | [] | no_license | def reverse_words(s)
s.split(' ').map(&:reverse).join(' ')
end
puts reverse_words("Let's take LeetCode contest") | true |
b927948bbaecf683025192a4b77b078829021a36 | Ruby | Combos93/hooked_human | /main.rb | UTF-8 | 810 | 2.59375 | 3 | [] | no_license | if Gem.win_platform?
Encoding.default_external = Encoding.find(Encoding.locale_charmap)
Encoding.default_internal = __ENCODING__
[STDIN, STDOUT].each do |io|
io.set_encoding(Encoding.default_external, Encoding.default_internal)
end
end
current_path = '/' + File.dirname(__FILE__)
require_relati... | true |
d8a1823c3f130024fba95854a671a225ef6b13e6 | Ruby | markfranciose/drops_of_knowledge | /practice/algos/rect_functions/rectangle.rb | UTF-8 | 565 | 3.8125 | 4 | [
"MIT"
] | permissive | class Rectangle
attr_reader :width, :height
def initialize(args = { })
@width = args.fetch(:width, 1)
@height = args.fetch(:height, 1)
end
def area
width * height
end
def perimeter
(height * 2) + (width * 2)
end
def diagonal
Math.sqrt((height^2) + (width^2))
end
def is_squa... | true |
ab14e0be12872d5cab61f7a56e02aa20da4a608d | Ruby | kaityo256/mhs_graph | /mhs_graph.rb | UTF-8 | 4,374 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'graphviz'
$max = 7
$MAX_TRIAL = 10000
class Integer
def to_b
s = ""
v = self
$max.times{|i|
s = (v&1).to_s + s
v = v >> 1
}
s
end
def to_a
v = self
r = []
$max.times do |i|
if (1<<($max-i-1)) & v !=0
r.push ($max-i)
end... | true |
f33cac8de73071613419da3180b7607e8afae230 | Ruby | sergeytdl/git | /git_app.rb | UTF-8 | 178 | 2.6875 | 3 | [] | no_license | puts 2 + 2 + 2
print "This is for Github"
print "jjjjjjjjjjjjjjj"
print "good!"
name = gets.chomp
puts "Your name is #{name}"
puts "cccccccccccccccccccccccccccccccccb"
#1jhgvbn
| true |
4d6b6de1c81a5a64274aa6f0ee843d62991cf73d | Ruby | elpadrinoIV/blackjack | /test/estadistica/test_estadistica.rb | UTF-8 | 1,167 | 2.765625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../helper.rb'
require 'calculador_estadisticas'
class TestEstadistica < Test::Unit::TestCase
def setup
@calculador_estadisticas = Estadistica::CalculadorEstadisticas.new
end
def teardown
# nada...
end
def test_media_aritmetica
valores = [2, 2, 2, 3, 4, 5, 7, 7, 7, 7, ... | true |
e3df2ae38abe330bcf46e8218ce8bfb2baf8e2f6 | Ruby | justindelatorre/rb_101 | /small_problems/easy_8/easy_8_4.rb | UTF-8 | 1,952 | 4.59375 | 5 | [] | no_license | =begin
Write a method that returns a list of all substrings of a string. The returned
list should be ordered by where in the string the substring begins. This means
that all substrings that start at position 0 should come first, then all
substrings that start at position 1, and so on. Since multiple substrings will
occ... | true |
987da4700828df5d9fc94f8b8c67ee2399a34232 | Ruby | laker914/dsp | /lib/xml_helper.rb | UTF-8 | 1,471 | 2.921875 | 3 | [] | no_license | module XmlHelper
# This function helps you escape special characters in XML attribute values
# Here, we have escaped only single quotes for xml attribute values
# You can escape other characters which might be causing issues as xml attribute values
def XmlHelper.escape_xml_attribute_values(string_to_escape,for_... | true |
6ed1052dd71d8ff965f7edf3a3b94c805a2380d3 | Ruby | YanhaoYang/pgslice | /exe/pgslice | UTF-8 | 1,854 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "thor"
require "pgslice/commands"
class PgSliceCommand < Thor
def self.exit_on_failure?
true
end
class_option :url, type: :string, desc: "A PostgreSQL connection string"
desc "prep TABLE COLUMN PERIOD", "prepare the TABLE with specified column and period"
def prep(table, co... | true |
16f7909d67e05921538a16c57eee84a0115d0f04 | Ruby | IdahoEv/eclipse_sim | /lib/eclipse_sim/match_runner.rb | UTF-8 | 3,142 | 2.953125 | 3 | [] | no_license | module EclipseSim
class MatchRunner
attr_accessor :verbose
def initialize
@rounds = 0
@fleets = []
end
def set_fleets(fleet_array)
@fleets = fleet_array
end
def reset
@fleets.each(&:reset_damage!)
@rounds = 0
end
def run
while(true) do
ex... | true |
d1ff5bc937a77e6cdef06bdfbada936abc178d74 | Ruby | webpolis/arke | /lib/arke/exchange/base.rb | UTF-8 | 921 | 2.65625 | 3 | [] | no_license | module Arke::Exchange
# Base class for all exchanges
class Base
attr_reader :queue, :min_delay, :open_orders, :market
attr_accessor :timer
def initialize(opts)
@market = opts['market']
@driver = opts['driver']
@api_key = opts['key']
@secret = opts['secret']
@queue = ... | true |
697eaeeb003b6b18840880d41552875dac95e233 | Ruby | aidamanna/appetype | /spec/models/user_invitation_spec.rb | UTF-8 | 667 | 2.578125 | 3 | [
"MIT"
] | permissive | describe UserInvitation do
describe 'Validations' do
subject { described_class.new(token: 'aBCdeFg', email: 'emma@appetype.com') }
it 'is valid with valid attributes' do
expect(subject).to be_valid
end
it 'is not valid without a token' do
subject.token = nil
expect(subject).not_to ... | true |
bd19b5d85889ece63eb06ed097c8971640248883 | Ruby | anniebeee/TIL | /Rubester/hello.rb | UTF-8 | 91 | 2.875 | 3 | [] | no_license | class SampleCode
def run
puts "Hello, annnnnnie."
end
end
s = SampleCode.new
s.run | true |
8c6d48dada8e50b1d7d989a1720f94b7d7e43e72 | Ruby | danielsperling/moviematcher | /db/seeds.rb | UTF-8 | 151 | 2.53125 | 3 | [] | no_license | User.destroy_all
Movie.destroy_all
Genre.destroy_all
scrape = Scraper.new
movies = scrape.scraper
Movie.create_movies(movies)
puts 'Movies Generated'
| true |
ba527b4aeb6d83ea980a95489b88a8ab2a4b1d3f | Ruby | wdevauld/colour | /spec/support/color_representation.rb | UTF-8 | 2,855 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'rspec'
green = StandardColoursRGB.green
shared_examples "every colour representation", :shared => true do
it "should convert to RGB" do
green.should respond_to(:to_rgb)
green.to_rgb.g.should eql(1.0)
green.to_rgb.b.should eql(0.0)
green.to_rgb.r.should eql(0.0)
end
... | true |
f5bb74dedf0a0f76fc655c47f59f20b91e1e90d7 | Ruby | angelikatyborska/quoridor-server | /lib/quoridor/lobby/room.rb | UTF-8 | 1,767 | 2.921875 | 3 | [] | no_license | require_relative '../errors'
require_relative '../game'
module Quoridor
module Lobby
class Room
attr_reader :id
attr_reader :players
attr_reader :game
attr_reader :owner
attr_reader :capacity
# TODO: add a description/name
# TODO: add invitation-only joining
def i... | true |
0b7915f1618163ea78919acf1110b407a9e77fd8 | Ruby | HoffsMH/sales_engine_sql | /lib/sales_engine.rb | UTF-8 | 2,458 | 2.90625 | 3 | [] | no_license | require_relative 'customer_repository'
require_relative 'invoice_repository'
require_relative 'transaction_repository'
require_relative 'invoice_item_repository'
require_relative 'merchant_repository'
require_relative 'item_repository'
require_relative 'repository'
require 'sqlite3'
require 'pry'
class SalesEngine
... | true |
4dead91a478e1b55391fedb96ba9891a95dbbdc2 | Ruby | BDTurc/Cosi227B | /ruby_scripts/Validate.rb | UTF-8 | 5,258 | 2.578125 | 3 | [] | no_license | class Validate
def initialize
#filterBadHits
filterBadWorkers
end
def automaticReject(badHash)
contents = File.open("results_clean0429")
rejectfile = File.open("rejectFile.txt", "w")
contents.each_line do | line |
assignmentId, workerId, hitId, imgOne, imgTwo, ansOne, imgThree, imgFour, ansTw... | true |
6089f5f578e10ea825683223ae139f951d3e6651 | Ruby | slillibri/Diggr | /app/processors/link_processor.rb | UTF-8 | 1,807 | 2.578125 | 3 | [] | no_license | class LinkProcessor < ActiveMessaging::Processor
require 'net/http'
subscribes_to :links
publishes_to :dead_letter
def on_error(err)
if (err.kind_of?(StandardError))
logger.error "ApplicationProcessor::on_error: #{err.class.name} rescued:\n" + \
err.message + "\n" + \
"\t" + err.back... | true |
1323ef13681af86630458024677f5752d9d2504a | Ruby | dereckrx/design-patterns | /dependancy_injection.rb | UTF-8 | 561 | 3.0625 | 3 | [] | no_license | # http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming
class A
end
# method 1
# Factory method with default param. Bad for APIs because
# now you must document the default param.
class B
def new_client(with=A)
with.new
end
end
# Method 2 as
# In tests, subclass B2 (or stub) to return the ... | true |
29fd704d974bcba75dafabf4afcd4c47d5623ee3 | Ruby | IGetEmotional/snp_ruby_tasks | /task_9.rb | UTF-8 | 1,540 | 3.578125 | 4 | [] | no_license | =begin
Необходимо разработать метод connect_hashes(hash1, hash2), который соединит
два переданных хеша, значениями ключей в которых являются числа, и вернет
новый хэш, полученный по следующим правилам:
• приоритетными являются ключи того хэша, сумма значений ключей
которого больше (если суммы значений ключей будут... | true |
c801a77ebd3380d01cdaa485afe03bd07d162ae1 | Ruby | thl/active_resource_extensions | /lib/active_resource_extensions/extensions/translation.rb | UTF-8 | 3,107 | 2.703125 | 3 | [
"MIT"
] | permissive | module ActiveResourceExtensions
module Extensions
module Translation
extend ActiveSupport::Concern
included do
end
module ClassMethods
# Returns the base AR subclass that this class descends from. If A
# extends AR::Base, A.base_class will return A. If B desce... | true |
171a12f8a2a3a266b2b6dc8a21447b65df78fb41 | Ruby | sandrahgm/Programacion | /Quiz/Quiz/app/models/question.rb | UTF-8 | 373 | 3.015625 | 3 | [] | no_license | class Question < ActiveRecord::Base
has_many :choices
def uncorrect
choices.each {|c| c.correct = false }
end
def answer
uncorrect
choices.select {|c| c.correct}[0]
end
def answer= choice
if !answer.nil?
answer.correct = false
end
if choices.include? choice
choice.correct = true
else
choi... | true |
3e26c67f4d87efde4c052eb41ab90e5b4da411d2 | Ruby | stanvandepoll/RB101 | /small_problems/medium_1/6.rb | UTF-8 | 581 | 3.34375 | 3 | [] | no_license | def minilang(commands_string)
stack = []
register = 0
commands_string.split.each do |command|
case command
when 'PUSH' then stack.push(register)
when 'ADD' then register += stack.pop
when 'SUB' then register -= stack.pop
when 'MULT' then register *= stack.pop
when 'DIV' then register /= s... | true |
73edb10448a22f148a531e4897e7d221cc76c937 | Ruby | Atsuroh/furima-32582 | /spec/models/item_spec.rb | UTF-8 | 3,040 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品出品機能' do
context '商品出品登録がうまくいくとき' do
it "記入欄の全てが存在すれば登録できる" do
expect(@item).to be_valid
end
end
context '商品出品登録がうまくいかないとき' do
it "商品画像が必須であること" do
... | true |
93b90ea412f6e74a919e194ebf90fbe94156f7eb | Ruby | superchell/rails-optimization-task1 | /work_performance_spec.rb | UTF-8 | 1,057 | 2.5625 | 3 | [] | no_license | require 'rspec-benchmark'
require_relative 'task-1'
RSpec.configure do |config|
config.include RSpec::Benchmark::Matchers
end
def generate_data_file(x = 1)
data = File.read(DATA_FILE)
data_file = File.open('data_samples/test_data.txt', 'w+')
x.times do
File.write(data_file, "#{data}", mode: 'a')
end
... | true |
88599f062480f4e21c8f637e1a695df34233c9b9 | Ruby | Deluxe-Soft/Practices_RUBY | /zad3_2_patryk.rb | UTF-8 | 2,397 | 3.84375 | 4 | [] | no_license |
class Classes
include ObjectSpace
attr_accessor :hour, :people, :name
attr_accessor :classroom
def initialize (hour, surname, name)
@name=name
@hour=hour
@people = Array.new
@people <<surname
end
def add_classroom(classroom)
@classroom = classroom
end
def remove_classroom(classro... | true |
55348e7ddfc2b906522076b6c16ea799d8b4f071 | Ruby | jrkroymann10/hangman | /lib/HangMan.rb | UTF-8 | 1,198 | 3.609375 | 4 | [] | no_license | require_relative 'GameDisplay.rb'
require_relative 'HumanGuesser.rb'
require 'io/console'
require 'yaml'
require 'pry'
class HangMan
attr_accessor :turns, :history, :guesser, :game_display
def initialize
@guesser = HumanGuesser.new
@game_display = GameDisplay.new
@turns = 12
end
def game
while... | true |
09c3d9c1649abb47b62f109502ee54df7f3623cc | Ruby | nicky-isaacs/sample-ruby-connector | /src/thin_connector/stream/gnip_stream.rb | UTF-8 | 2,647 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'eventmachine'
require 'em-http-request'
require 'json'
require 'yajl'
require 'byebug'
require_relative './stream_helper.rb'
module ThinConnector
module Stream
class GNIPStream < Stream::Base
include ThinConnector::Stream::StreamHelper
EventMachine.threadpool_size = 3
attr_accessor ... | true |
0a3cf4f2306c3608f40919ba393345ac1940140b | Ruby | jamesarosen/constellation | /lib/constellation.rb | UTF-8 | 2,925 | 2.75 | 3 | [
"MIT"
] | permissive | module Constellation
class ParseError < StandardError
def initialize(file)
super("Could not parse #{file}. Try overriding #parse_config_file")
end
end
def self.enhance(klass)
klass.extend Constellation::ClassMethods
klass.env_params = {}
klass.send :include, Constellation::InstanceMeth... | true |
f8155bae5563fa3f9bc5b2b8a58df875dad2645b | Ruby | coreymartella/project_euler | /p025.rb | UTF-8 | 537 | 3.765625 | 4 | [] | no_license | load 'common.rb'
def p25(n=1000)
a,b,iters=1,1,2
while true
a,b,iters=b,a+b,iters+1
return iters if b>=10**(n-1)
end
end
# The Fibonacci sequence is defined by the recurrence relation:
# Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
# Hence the first 12 terms will be:
# F1 = 1
# F2 = 1
# F3 = 2
# F4 = 3
# F5 ... | true |
951112b77d15904dbd01b6bc8e1936daba0a96b1 | Ruby | anjana-nair/kitchenstore | /spec/sample_spec.rb | UTF-8 | 356 | 2.953125 | 3 | [] | no_license | describe "String" do
describe "creation of a new object" do
it "will return an empty string when given no arguments" do
expect(String.new).to eq("")
end
it "will return the specified string when given as argument" do
expect(String.new("anjana")).to eq("anjana")
e... | true |
da218335cfc6afc9429a62b667156769ac2e1560 | Ruby | anginblu/ruby-objects-has-many-through-lab-v-000 | /lib/song.rb | UTF-8 | 533 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :genre, :artist
def initialize(name, genre)
@name = name
@genre = genre
genre.songs << self
end
def genre=(genre)
raise AssociationTypeMismatchError, "Genre class is expected" if !genre.is_a?(Genre)
@genre = genre unless self.genre == genre
end
def arti... | true |
783be159b8fcc96758dc2224535f9c0cddd8c0fd | Ruby | rosariogarcia/qadev_v012016 | /Rosario/cucumber/features/step_definitions/tictactoe.rb | UTF-8 | 621 | 2.84375 | 3 | [] | no_license | Given(/^a board like this:$/) do |table|
# table is a Cucumber::Core::Ast::DataTable
@board = table.raw
puts @board
end
When(/^player (x|y) plays in row (\d+), column (\d+)$/) do |player, row, col|
row,col = row.to_i, col.to_i
@board[row][col] = player
end
Then(/^the board should look like this:$/) do |expe... | true |
5c8875effead83eea2f189f2294a40678152804f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/ceb80247ea1b434c903ee94fdd085478.rb | UTF-8 | 149 | 3.390625 | 3 | [] | no_license | class Hamming
def self.compute(s1, s2)
s1.chars.zip(s2.chars).inject(0) do |distance, (c1, c2)|
distance + (c1 == c2 ? 0 : 1)
end
end
end
| true |
c6fd3a88fcde5272b5055feb86da605f42895306 | Ruby | DuncanYe/note | /ruby_lesson/execise/ex15.rb | UTF-8 | 442 | 3.640625 | 4 | [] | no_license | filename = ARGV.first
prompt = "> " #給prompt定義
txt = File.open(filename) #給txt定義
puts "Here's your file: #{filename}"
puts txt.read()
puts "Type the filename again: " #再輸入一次文件名稱,
print prompt #放上符號>提示從這裡輸入 prompt = "> "
file_again = STDIN.gets.chomp() #取得使用者輸入的資訊
txt_again =... | true |
3a2d6220bba11c0dd2f76f2a5a8a53773cee2229 | Ruby | hir-ishikawa/ruby-samples | /loop.rb | UTF-8 | 226 | 2.953125 | 3 | [] | no_license | i = 0
loop do
puts "hoge #{i}"
break if i > 100
i += 1
end
puts "exit"
puts "============"
i=0
loop do
if i % 3 == 0
i += 1
next
end
p i
break if i > 100
i += 1
end
puts "============"
100.times do |i| p i end
| true |
970417e8cc3e9a53f9ad3970652819576595a691 | Ruby | sinharahul/chesstournament | /test/models/schedule_test.rb | UTF-8 | 1,066 | 2.78125 | 3 | [] | no_license | require 'test_helper'
require 'schedule/schedule'
class ScheduleTest < ActiveSupport::TestCase
=begin
test "the truth" do
assert true
tm=TournamentModel.new(create_players,1)
puts "Master schedule=#{tm.splitandschedule}"
end
=end
test "create 7 player tournament" do
assert true
... | true |
17ca7002432c7b551867cb525bd25569c629282d | Ruby | cole9708/lego | /features/support/lib/helpers/yaml_manager.rb | UTF-8 | 396 | 2.625 | 3 | [] | no_license | require 'yaml'
class YamlManager
class << self
attr_accessor :project_root
end
self.project_root = File.join(__dir__, '../../../')
def self.load_config_yml(file_name)
load_yaml_file_in_dir('config', file_name)
end
def self.load_yaml_file_in_dir(dirname, yaml_file_name)
yml = YAML.load_file(F... | true |
e3c76ed5f7ad77208a0c3570ff4cd012c6bfd5f5 | Ruby | micktaiwan/generic_game_server | /chat/chat_display.rb | UTF-8 | 785 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
require './chat_client.rb'
class ChatDisplay < ChatClient
def intialize(name)
super(name)
end
def connect_to_table(name)
super(name)
t = get_local_table(name)
raise "#{name} does not exist" if not t
@subscriber = @context.socket(ZMQ::SUB)
@subscriber.connect("tcp:/... | true |
4cb69961fe1b30d74c07a33256cb991033cbcd63 | Ruby | anztrax/learn-ruby | /chap1/test.rb | UTF-8 | 470 | 3.15625 | 3 | [] | no_license | #!/usr/bin/ruby -w
puts "Hello, Ruby!";
print <<EOF
This is the first way of creating
this is multiple document line
EOF
print <<`EOC`
echo hi there
echo lo there
EOC
print <<"foo", <<"bar"
I said foo
foo
I said bar
bar
#ruby is weird language, but the creator is mad and smart enough to justify his action
=... | true |
e9b42970887c24dbb5e3d003ebaa59991fe04795 | Ruby | SRBusiness/VideoStoreAPI | /db/seeds.rb | UTF-8 | 1,057 | 2.59375 | 3 | [] | no_license | JSON.parse(File.read('db/seeds/customers.json')).each do |customer|
Customer.create!(customer)
end
JSON.parse(File.read('db/seeds/movies.json')).each do |movie|
Movie.create!(movie)
end
# require 'date'
# JSON.parse(File.read('db/seeds/customers.json')).each do |customer|
# this_customer = Customer.new
# thi... | true |
4ced007ebafffd528b7b321cfad35ef94162276b | Ruby | ThroughTheNet/date_scopes | /lib/date_scopes.rb | UTF-8 | 2,752 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'active_record'
module DateScopes
module ClassMethods
# Adds a number of dynamic scopes and a virtual accessor to your model.
# Functionality is detailed more fully in the {file:README.markdown README} for this gem, but a brief demo is given here:
# @example
# class Post < ActiveReco... | true |
3acdf01e4904f1b49ed0cab2d638329fa56753f6 | Ruby | gongo/sql_designer_generator | /lib/sql_designer_generator/xml/column.rb | UTF-8 | 677 | 2.6875 | 3 | [
"MIT"
] | permissive | module SqlDesignerGenerator
module XML
class Column
attr_reader :column
def initialize(column)
@column = column
end
def print
header + type + default + footer
end
def header
name = column.name
null = column.null ? '1' : '0'
"<row name=... | true |
d632d34125fff37bf3f8b3e95641e9b0b035da1f | Ruby | Haushoffer/mundoWumpus | /spec/bin/cave_spec.rb | UTF-8 | 1,838 | 3.15625 | 3 | [] | no_license | require "./lib/cavern.rb"
require "./lib/cave.rb"
describe Cave do
it 'devuelve el numero de caverna' do
cave = Cave.new(nil,nil,nil,nil,10)
expect(cave.caveNumber).to eq(10)
end
it 'devuelve el numero 10 de caverna superior vecina' do
caveTop = Cave.new(nil,nil,nil,nil,10)
cave = Cave.new(caveTop,nil,nil... | true |
51c5a71570b6854f4fcc8b5da8e9bfe57e2e9018 | Ruby | tecnologiaenegocios/tn_pdf | /lib/tn_pdf/configuration.rb | UTF-8 | 4,696 | 2.515625 | 3 | [] | no_license | require 'yaml'
module TnPDF
class Configuration
class << self
attr_accessor :image_loader
def [](property, call_procs: true)
(hash, key) = filter_property(property)
value = hash[key]
if call_procs && value.kind_of?(Proc)
value.call
else
value
... | true |
7f6766d01e1e871366ecc4837ccf0cfb9bb9fda7 | Ruby | SoftwareProj2021/foodlab | /vendor/plugins/rspec/lib/spec/story/step_matchers.rb | UTF-8 | 1,549 | 2.65625 | 3 | [
"MIT"
] | permissive | module Spec
module Story
class StepMatchers
def self.step_matchers
@step_matchers ||= StepMatchers.new(false)
yield @step_matchers if block_given?
@step_matchers
end
def initialize(init_defaults=true)
@hash_of_lists_of_matchers = Hash.new {|h, k| h[k] = []}... | true |
38cf62f5f4755017589101a21ace496dd27dc0a9 | Ruby | BilelTL/learn_ruby | /05_book_titles/book.rb | UTF-8 | 132 | 2.78125 | 3 | [] | no_license | class Book
attr_accessor :title
def initialize(title = "book")
@title = title.capitalize # ne fonctionne pas
end
end
| true |
799fde748c10e471264b17bd18fb3776e6a176a6 | Ruby | CodingSensei19/programming-univbasics-4-square-array-online-web-prework | /lib/square_array.rb | UTF-8 | 689 | 3.109375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
# your code here
#create my new array to this assignment
myArray = [] my_array = []
# each iterator returns all the elements of an array or a hash # each iterator returns all the elements of an array or a hash
# do loop # do loop
# value in the pipes is a placeholder # n an elemen... | true |
af96af0f6faa6be92f6ab115945d1ab21dc67a2d | Ruby | amarske12/hello-ruby | /exercises/8.rb | UTF-8 | 688 | 4 | 4 | [] | no_license | # EXERCISE
# Create a "shared" shopping list with a friend
# Create two data structures - one for your list of stuff, and one
# for your friend, e.g. you want milk, eggs, and bacon, and
# your friend wants beer, cookies, and apples.
# Programmatically combine the two arrays into a single list,
# sort the result (alphab... | true |
57580926b3d24530195760b0d714e684bdc54c59 | Ruby | TomoMayumi/contest | /atcoder/abc067_d.rb | UTF-8 | 399 | 3.109375 | 3 | [] | no_license | n=gets.to_i
r=(1..n-1).map{gets.split.map(&:to_i)}
state=[1]+[0]*(n-2)+[2]
root=(r+r.map{|a,b|[b,a]}).group_by{|a,b|a}.sort_by{|k,v|k}.map{|k,v|v.map{|a,b|b-1}}
fen=root[0]
snu=root[-1]
while fen[0]||snu[0]
fen=fen.select{|i|state[i]==0}.flat_map{|i|state[i]=1;root[i]}
snu=snu.select{|i|state[i]==0}.fla... | true |
79ccb8a140eba9ad317f3c73e8a176338c1dc553 | Ruby | abigezunt/ga-spiral-path-quiz | /quiz.rb | UTF-8 | 1,029 | 3.9375 | 4 | [] | no_license | # Your code goes here
# require 'pry'
# array = [[11, 12, 13, 14, 15, 16],
# [24, 25, 26, 27, 28, 17],
# [23, 22, 21, 20, 19, 18]]
# array = [[11, 12, 13, 14, 15, 16, 17],
# [26, 27, 28, 29, 30, 31, 18],
# [25, 24, 23, 22, 21, 20, 19]]
# array = [[11, 12, 13, 14, 15],
# ... | true |
c7da24b6ae2c0241929ddbdc902b3258e1b9a59f | Ruby | herecomesjaycee/oystercard | /spec/Oystercard_spec.rb | UTF-8 | 1,797 | 2.859375 | 3 | [] | no_license | require 'oystercard'
describe Oystercard do
subject(:card){described_class.new}
let(:entry_station) {double :station}
let(:exit_station) {double :station}
let(:test_station) {double :station, :station_key => {"Bank" => 1}}
let(:journey) {double:journey}
describe 'New instance' do
it 'should have a balance of 0' do... | true |
7cfc912f2a8d7cf0e2217a61c7cc6e6752be9da0 | Ruby | catier101/maps | /newLoc.rb | UTF-8 | 562 | 3.890625 | 4 | [] | no_license | class Geocode
def initialize
@lat = "unknown"
@long = "unknown"
end
def getloc
puts "What would you like the location of?"
@locname = gets.chomp
end
def searchloc(address) #LINK: https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple
address = @locname.... | true |
d3061a0509b0c1c8ea1676495a002a034ad4ae2c | Ruby | cfdair/project_euler | /10/b/solution.rb | UTF-8 | 775 | 3.28125 | 3 | [] | no_license | #!/bin/usr/ruby
$LOAD_PATH.unshift(__dir__ + '/../../helpers')
require 'prime_helper'
# Description
class Solution
def run(upper_limit:)
primes_below_limit(upper_limit).inject(:+)
end
def primes_below_limit(upper_limit)
sieve = create_sieve(upper_limit)
primes = []
sieve.each_with_index do |is_... | true |
7a81fce8f278f2f7b36a1e9c1f3b0f4487e602fa | Ruby | cluster/ticketee | /spec/models/user_spec.rb | UTF-8 | 1,225 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
describe User do
it "needs a password and confirmation to save" do
u = User.new(name: "steve")
u.save
expect(u).to_not be_valid
u.password = "password"
u.email = "titi@toto.fr"
u.password_confirmation = ""
u.save
expect(u).to_not be_valid
u.password_confi... | true |
e7e43c758ae062c53d2745d25d32dda210c5bdf1 | Ruby | i-galimov/practice_ruby | /def_sum.rb | UTF-8 | 451 | 3.671875 | 4 | [] | no_license | # Ваша задача написать метод, имеющий два параметра, второй из которых по умолчанию равен 10. Метод должен выводить сумму двух аргументов, переданных в него. После написания метода, вам нужно вызвать его с одним аргументом - x.
def sum(a=10, b=10)
puts a + b
end
sum(x)
| true |
e4b8053c0d578d332d6402c84fdb94ebdce3783c | Ruby | BooneTeam/BeginningRuby | /numshuffle.rb | UTF-8 | 744 | 3.40625 | 3 | [] | no_license | def number_shuffle(number)
length = number.to_s.length
spot = length
number_arrays = number.to_s.split("").to_a.permutation.to_a.flatten
total = number_arrays.length
while spot <= total + total
number_arrays = number_arrays.insert(spot,",")
spot += length + 1
end
number_array = number_arrays.join.split... | true |
125b9defc750aa158070a2cc2b198019332cee4c | Ruby | takaxyz/atcoder | /caddi/2018/C.rb | UTF-8 | 146 | 3.0625 | 3 | [] | no_license | require 'prime'
N,P=gets.chomp.split.map(&:to_i)
ans=1
Prime.prime_division(P).each do |a,b|
next if b < N
ans *= (a ** (b/N))
end
puts ans
| true |
9b82256de00371f11212b62ed09eb25b60d5f380 | Ruby | sesvxace/test-case | /lib/extensions/stubs.rb | UTF-8 | 3,283 | 2.6875 | 3 | [
"MIT"
] | permissive | #--
# Test Case: Stubs by Solistra
# =============================================================================
#
# Summary
# -----------------------------------------------------------------------------
# This script provides the ability to generate method stubs which will return
# the passed value you give to t... | true |
d873d3d780ee8d331f2a3831551e508cd7112ad4 | Ruby | stephan-nordnes-eriksen/ruby_ship | /bin/shipyard/win_ruby/lib/ruby/gems/2.1.0/gems/bundler-1.7.2/lib/bundler/cli/inject.rb | UTF-8 | 954 | 2.71875 | 3 | [
"MIT"
] | permissive | module Bundler
class CLI::Inject
attr_reader :options, :name, :version, :gems
def initialize(options, name, version, gems)
@options = options
@name = name
@version = version
@gems = gems
end
def run
# The required arguments allow Thor to give useful feedback when the arg... | true |
1f708eb667a48b291ba909382eb1b74f4b9fe1ea | Ruby | evansenter/waves | /app/models/artist.rb | UTF-8 | 1,756 | 2.625 | 3 | [] | no_license | class Artist < ActiveRecord::Base
has_many :similarities, :dependent => :destroy
validates_presence_of :name, :mbid
validates_uniqueness_of :mbid, :allow_blank => true
class << self
def retrieve(duration = 1.day, interval = 1.second, display_stats = false)
Rails.logger.silence do
start_t... | true |
03e61ac2c9260915d110536e363671a1871996cb | Ruby | ljr5102/advent-code-2018 | /day_11/highest_power.rb | UTF-8 | 1,583 | 3.359375 | 3 | [] | no_license | def highest_power(grid_serial_number = 0, size = 3, grid = nil)
square_power = {}
grid ||= power_grid(grid_serial_number)
grid.each_index do |y_idx|
break if grid[y_idx + (size - 1)].nil?
grid[y_idx].each_index do |x_idx|
break if grid[x_idx + (size - 1)].nil?
sum = 0
grid[y_idx..(y_idx ... | true |
5c1b339157c776997679794d1d889d8125448814 | Ruby | ericovinicosta/pdti-ruby-respostas-exercicio02 | /resposta03_case.rb | UTF-8 | 314 | 4.15625 | 4 | [] | no_license | #Faça um Programa que verifique se uma letra digitada é "F" ou "M".
# Conforme a letra escrever: F - Feminino, M - Masculino, Sexo Inválido
print "Digite M ou F: "
informacao_sexo = gets.chomp.downcase
case informacao_sexo
when 'f'
puts 'Feminino'
when 'm'
puts 'Masculino'
else
puts 'Sexo Inválido'
end | true |
90173271b6d81b36928cdac0344da6680883b1fe | Ruby | XiaoA/tealeaf-precourse | /07_arrays/mutate_test.rb | UTF-8 | 290 | 3.921875 | 4 | [] | no_license | # 07_arrays/mutate_test.rb
# This program demonstrates how the *pop* method is destructive, while the *select* method is not.
def mutate(arr)
arr.pop
end
def not_mutate(arr)
arr.select { |i| i >3 }
end
a = [1, 2, 3, 4, 5, 6]
mutate(a)
not_mutate(a)
puts a
| true |
9a62465c3849e9cb9a8867f618be909ffa8dc1c3 | Ruby | priscillashort/bend_bike_shop | /inventory.rb | UTF-8 | 776 | 3.34375 | 3 | [] | no_license | require_relative 'road_bike'
require_relative 'mountain_bike'
require_relative 'tricycle'
require_relative 'flatwater_kayak'
require_relative 'whitewater_kayak'
class Inventory
attr_reader :items
def initialize(items=[])
@items = items
end
def to_s
"Inventory with items: #{items.map{|i|i.to_s}}"
... | true |
abd2559a5b0244214335ae95961aa658c54ec633 | Ruby | steve-c-thompson/market_st_apartments | /lib/building.rb | UTF-8 | 701 | 3.5625 | 4 | [] | no_license | class Building
attr_reader :units
def initialize
@units = []
end
def add_unit(apt)
@units.push(apt)
end
def average_rent
total_rent = calc_total_rent
if(total_rent == 0)
return total_rent
end
total_rent / @units.count
end
def total_annual_rent
12 * calc_total_rent
... | true |
3e709c2908867a6ec507e54ba80e6afb8fbaf577 | Ruby | bmcdonald05/ruby-spring16 | /hangman.rb | UTF-8 | 1,259 | 4.09375 | 4 | [] | no_license |
def intro
puts "Lets play a game of Hangman"
puts "You have to guess letters and find out the word I am thinking of"
puts "If you guess 6 letters that are NOT in the word, you lose!"
puts "Let us begin!"
end
def get_word
dictionary = %w[man word apple daily person lamb lion fact false carrot lemon lime carry sho... | true |
fb9611affefff30170eb00645f57d442497a1f3d | Ruby | mmejiadeveloper/RubyScrapPratices | /BolivianNewsScraper/lib/test.rb | UTF-8 | 5,492 | 2.953125 | 3 | [] | no_license | require "HTTParty"
require "Nokogiri"
require 'csv'
require 'digest'
require 'pp'
require "awesome_print"
class Scrapper
attr_writer :strategy
def initialize(strategy)
@strategy = strategy
end
def chageStrategy(strategy)
@strategy = strategy
end
def getScrapedData
@strategy.getORawObject
end
def writ... | true |
58c18b60f07cbc16dcda7e5fd9773d12c12c31ce | Ruby | openc/openc_bot | /lib/openc_bot/templates/lib/company_fetcher_bot.rb | UTF-8 | 4,552 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "openc_bot"
require "openc_bot/company_fetcher_bot"
# you may need to require other libraries here
#
# require 'nokogiri'
# uncomment (and line further down) to get Date helper methods. (Also available csv and text helpers)
# require 'openc_bot/helpers/dates'
module MyModule
... | true |
e28436d7340d409345b8e7b33280126a3ded8274 | Ruby | malagon91/rails-social-network | /app/models/user.rb | UTF-8 | 1,022 | 2.53125 | 3 | [] | no_license | class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,:omniauthable, :omniauth_providers =>[:facebook]
#creo... | true |
e6de7524128c9ae7beea96799ff1fac4fe7c5882 | Ruby | kent0322/furima-36063 | /spec/models/item_spec.rb | UTF-8 | 5,267 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
context '商品出品ができる時' do
it '全てのカラムに正常値があれば登録できる' do
expect(@item).to be_valid
end
end
context '商品出品ができない時' do
it "商品画像を1枚つけることが必須で... | true |
0ac9a7411a5b3b945adb07825472ef5f4f2de7d8 | Ruby | Kiitaan/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 423 | 3.484375 | 3 | [] | no_license | #write your code here
def echo(politesse)
"hello"
return politesse
end
def echo(politesse)
"bye"
return politesse
end
def shout(politesse)
return politesse.upcase
end
def repeat(text, *i)
if i.size < 1
result = "#{text}" " #{text}"
else
i = 3
w = i - 1
return (text + " ") * w + text
end
end
def start... | true |
a7eb289c2cca5d385c653f1309225decbf0f5ac3 | Ruby | tstaros23/backend_mod_1_prework | /section1/ex4.rb | UTF-8 | 1,712 | 4.03125 | 4 | [] | no_license | # Define "cars" variable so there are 100 cars
cars = 100
# Define "space_in_a_car" variable so it is 4.0 floating point
space_in_a_car = 4.0
# Define "drivers" variable so there are 30 drivers
drivers = 30
# Define "passengers" variable so that there are 90 passengers
passengers = 90
# Define "cars_not_driven" so that... | true |
0ce4bf296887d75620f0eaa911a17dd1f8c820cf | Ruby | andresmauricio/basic_ruby | /06-local-variables_2.rb | UTF-8 | 344 | 3.515625 | 4 | [] | no_license | my_variable = "food"
my_variable.split("").each_with_index do |char, i|
puts"The character in string '#{my_variable}' at index #{i} is #{char}"
end
def some_method
puts "you cant use #_{my_variable} generate error"
end
some_method
overshadowed = "sunlight"
["darkness"].each do |overshadowed|
puts overshadowe... | true |
62c6ed3f3874311e4bc790da1691a48782672b18 | Ruby | larryzhao/ruby-zip-test | /zip_test.rb | UTF-8 | 1,778 | 2.671875 | 3 | [] | no_license | require 'zip/zip'
require 'zipruby'
require 'pry'
base_path = '/Users/larry/Braavos/ruby-zips/'
files_dir = File.join(base_path, 'files')
zips_dir = File.join(base_path, 'zips')
files = []
Dir.foreach(files_dir) do |item|
next if item == '.' or item == '..'
files << File.join(files_dir, item)
end
# system
GC:... | true |
39d4fb2d76eb63ab680985a5c32b886176fce611 | Ruby | jljardon/sql-crowdfunding-lab-v-000 | /lib/sql_queries.rb | UTF-8 | 1,741 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
219225eb16f1e43b999a4658573004d06a930196 | Ruby | kiloecho7/random_scripture | /app/helpers/random_scripture_generator.rb | UTF-8 | 3,200 | 3.015625 | 3 | [] | no_license | require 'net/http'
class RandomScriptureGenerator
#@@ot = ['gen', 'ex', 'lev', 'num', 'deut', 'josh', 'judg', 'ruth', '1-sam', '2-sam', '1-kgs', '2-kgs', '1-chr', '2-chr', 'ezra', 'neh', 'esth', 'job', 'ps', 'prov', 'eccl', 'song', 'isa', 'jer', 'lam', 'ezek', 'dan', 'hosea', 'joel', 'amos', 'obad', 'jonah', 'micah'... | true |
ab227bab57d823fcad637e2e4e751ac34e08ed9e | Ruby | cyber-dojo-retired/singler | /server/src/rack_dispatcher.rb | UTF-8 | 2,429 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative 'client_error'
require_relative 'well_formed_args'
require 'json'
# Rack calls singler.kata_create() in threads so in
# theory you could get a race condition with both
# threads attempting a create with the same id.
# Assuming id generation is reasonably well behaved
# (random and large alphabet) this... | true |
7c0dbce6ce8949e3bb97965448c2268fef7b3520 | Ruby | straypacket/geo-walk | /importer.rb | UTF-8 | 4,223 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'rgeo'
require 'rgeo-shapefile'
require 'mongo'
conn = Mongo::Connection.new("localhost", 27017, :pool_size => 100, :pool_timeout => 5)
db = conn['roadsimulator']
indexes = ['head','tail']
# Parse train line shapefile
col = db['train_lines']
RGeo::Shapefile::Reader.open('data/N05-12_RailroadSection2.shp') do ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.