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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
edeb98f060b1956f2ba81b8f34dc851066a55538 | Ruby | lucanioi/exercism-ruby | /rna-transcription/rna_transcription.rb | UTF-8 | 373 | 3.15625 | 3 | [] | no_license | module Complement
InvalidNucleotide = Class.new(StandardError)
COMPLEMENTS = {
'G' => 'C',
'C' => 'G',
'T' => 'A',
'A' => 'U'
}.freeze
module_function
def of_dna(dna)
dna.chars.map(&method(:find_complement)).join
end
def find_complement(nucl)
COMPLEMENTS.fetch(nucl) do
ra... | true |
d8c5e3a9308e7c313140efdf803dfba813a78331 | Ruby | jerryjcchang/dc-web-080519 | /25-Rails-Code-Challenge-Review/tree_tracker/app/models/tree.rb | UTF-8 | 746 | 2.671875 | 3 | [] | no_license | class Tree < ApplicationRecord
has_many :sightings
has_many :users, through: :sightings
validates_presence_of :common_name, :binomial_name, :leaf_image, :category
validates :category, :inclusion => %w(deciduous evergreen)
# validates :etymological_fact, length: { minimum: 30, too_uninteresting: "NOT... | true |
51b3da03f16fa04374c793cb753fc7427ab391d8 | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/1552.magnetic-force-between-two-balls.rb | UTF-8 | 1,553 | 3.484375 | 3 | [] | no_license | #
# @lc app=leetcode id=1552 lang=ruby
#
# [1552] Magnetic Force Between Two Balls
#
# https://leetcode.com/problems/magnetic-force-between-two-balls/description/
#
# algorithms
# Medium (46.72%)
# Total Accepted: 8.1K
# Total Submissions: 17.4K
# Testcase Example: '[1,2,3,4,7]\n3'
#
# In universe Earth C-137, Rick... | true |
51b66a46e678ca2d1f249786f0a2fbd0f257b67c | Ruby | jdleesmiller/finite_mdp | /lib/finite_mdp/vector_valued.rb | UTF-8 | 881 | 3.484375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
#
# Define an object's hash code and equality (in the sense of <tt>eql?</tt>)
# according to its array representation (<tt>to_a</tt>). See notes for {Model}
# for why this might be useful.
#
# A class that includes this module must define <tt>to_a</tt>.
#
# @example
#
# class MyPoint
# ... | true |
b4ce9006f502ba46f8704b1db70a6b4b0db14b08 | Ruby | morrxy/ltp | /7/99bottles.rb | UTF-8 | 570 | 4.09375 | 4 | [] | no_license | S1 = ' bottles of beer on the wall, '
S2 = ' bottles of beer.'
S3 = 'Take one down and pass it around, '
S4 = ' of beer on the wall.'
S5 = 'No more bottles of beer on the wall, no more bottles of beer.'
S6 = 'Go to the store and buy some more, 99 bottles of beer on the wall.'
n = 99
while true
if n ==... | true |
fa46be047bb84ec206e7e28283b7bd35995688e4 | Ruby | caporta/school-domain-querying-001 | /lib/course.rb | UTF-8 | 2,245 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Course
attr_accessor :id, :name, :department_id
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS courses (
id INTEGER PRIMARY KEY,
name TEXT,
department_id INTEGER
)
SQL
DB[:conn].execute(sql)
end
def self.drop_table
sql = "DROP TABLE IF EXISTS cour... | true |
0fa9f42e4083bcc571c46c63dc582d47b546392e | Ruby | CharlesGBraga/Exemplo01Rspec | /spec/composicao/composicao_spec.rb | UTF-8 | 1,305 | 3.109375 | 3 | [] | no_license | describe 'Charles G. Braga' do # Instanciando o a String Charles G. Braga
it { is_expected.to start_with('Charles').and end_with('Braga') } # É esperado iniciar com Charles e terminar com Braga
it { expect(fruta).to eq('banana').or eq('uva').or eq('melancia')} # É esperado que seja igual a banana ou uva ou melancia... | true |
8fb819989db48d1dbace167147b1d6214e8bbe95 | Ruby | mdwrigh2/hacker_cup | /studious_student/study.rb | UTF-8 | 938 | 3.546875 | 4 | [] | no_license | class LexiString
attr_accessor :str
def initialize str
@str = str
end
def <=> other
i = 0
while(i < other.str.size and i < @str.size) do
if other.str[i] > @str[i]
return -1
end
if other.str[i] < @str[i]
return 1
end
i += 1
end
largerString ... | true |
2a7d30b39f5f2d200df3ec555037c1e040c8b9c0 | Ruby | mprostko/advent-of-code-2020 | /day05.rb | UTF-8 | 584 | 3.453125 | 3 | [] | no_license | data = []
File.readlines('day5.input').each do |line|
data << line
end
def bp(sides, arr)
return arr[0] if arr.size < 2
side = sides.shift
if side == 'F' || side == 'L'
return bp(sides, arr[0..(arr.size/2 - 1)])
else
return bp(sides, arr[(arr.size/2)..-1])
end
end
def seat_id(seat)
seat = seat.s... | true |
08bb3a67d0c0a41354a41eca516763e6d3813253 | Ruby | OrMtnMan/My_Ruby | /RB101-109/Lesson_6/blackjack.rb | UTF-8 | 6,666 | 3.96875 | 4 | [] | no_license | SUITS = %w(clubs diamonds hearts spades)
VALUES = %w(2 3 4 5 6 7 8 9 10 jack queen king ace)
WELCOME_TEXT = 'Welcome to Connor\'s Blackjack Table!'
MAIN_MENU = 'Press [1] to play, [0] to exit'
NEXT_HAND = 'Play next hand? Press [1] to play, [0] to exit'
START_AGAIN = 'Do you wish to play again? Press [1] to play, [0] t... | true |
6d79cd0f697f9844197a0db427aeefe1ba975f5f | Ruby | kwdavidlau/LHL_Programs | /warcraft3/lib/peasant.rb | UTF-8 | 199 | 2.6875 | 3 | [] | no_license | class Peasant < Unit
attr_reader :health_points, :attack_power
def initialize(health_points = 35, attack_power = 0)
@health_points = health_points
@attack_power = attack_power
end
end
| true |
9726e917e6dcb0092ffa204fb739ef0c622969d0 | Ruby | kontena/kontena | /test/spec/support/shell.rb | UTF-8 | 1,181 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | module Shell
class Error < StandardError
def initialize(cmd, code, output)
@cmd = cmd
@code = code
@output = output
end
def message
"command failed with code #{@code}: #{@cmd}\n#{@output}"
end
end
# @param [String] cmd
# @param [Hash] opts
# @return [Kommando]
def r... | true |
e2ca2fdf1acabdbe08b6c1d2cb45e4b1f52040ab | Ruby | lvl-up/clockon | /helpers/rack/runner.rb | UTF-8 | 1,317 | 2.65625 | 3 | [] | no_license | require 'childprocess'
require 'tempfile'
require 'wait'
module Rack
class Runner
attr_accessor :port, :log
def initialize config_ru, options={}
@options= options
@config_ru = config_ru
end
def run
directory = ::File.dirname(@config_ru)
@log = Tempfile.new('application_log'... | true |
ed74fe0a14f86150683d3d65b4abc881bbd3b60b | Ruby | michelemendel/misc | /projects/midi/src/timed_track.rb | UTF-8 | 2,683 | 2.6875 | 3 | [] | no_license | #
# From Ruby Cookbook
#
require 'pp'
require 'midilib'
require 'midilib/io/seqreader'
require 'midilib/io/seqwriter'
require 'midilib/consts'
include MIDI
#
class TimedTrack < MIDI::Track
MIDDLE_C = 60
#
def initialize(channel, song)
super(song)
@channel = channel
@time = 0... | true |
89f780f91483f06e575508e70a4c9a9787ed9ef5 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/difference-of-squares/956b38d9b8b24ae9b46256f92a2799ba.rb | UTF-8 | 274 | 3.4375 | 3 | [] | no_license | class Squares
def initialize num
@num = num
end
def square_of_sums
return (@num*(@num+1)/2)**2
end
def sum_of_squares
return (@num*(@num+1)*(2*@num+1)/6)
end
def difference
return Squares.new(@num).square_of_sums - Squares.new(@num).sum_of_squares
end
end
| true |
24c827d16d00a04bf510a47421f13b0314c4d5b8 | Ruby | DrDhoom/RMVXA-Script-Repository | /Mr. Bubble/Special Systems/Bubs - Dismantle Items.rb | UTF-8 | 53,717 | 2.828125 | 3 | [
"MIT"
] | permissive | # ╔═══════════════════════════════════════════════════════╤══════╤═══════════╗
# ║ Dismantle Items │ v1.3 │ (4/27/13) ║
# ╚═══════════════════════════════════════════════════════╧══════╧═══════════╝
# Script by:
# Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
#------------... | true |
5c9ae79481097f336c582e0540024cf3d2e65f4e | Ruby | jeffolen4/eliza | /phrase_list.rb | UTF-8 | 3,128 | 3.1875 | 3 | [] | no_license |
module Liza
class Phrase
attr_accessor :phrase
def initialize ( phrase )
@phrase = phrase
@responses = []
end
# def inspect
# puts "Phrase:\t #{@phrase}"
# count=1
# @responses.each do |response|
# puts "Response #{count.to_s}:\t #{response}"
# count +... | true |
a6bb524b3c536ba764b2c446345601d4985fb074 | Ruby | n-ina/training | /HeadFirst/4_Factory/main.rb | UTF-8 | 219 | 3.125 | 3 | [] | no_license | require './pizza_store.rb'
ny_store = NYPizzaStore.new
chicago_store = ChicagoPizzaStore.new
a = ny_store.order_pizza('Cheese')
p 'A ordered ' + a.name
b = chicago_store.order_pizza('Cheese')
p 'B ordered ' + b.name
| true |
006d843c474f0dd387a0554225370a7e0b425bc8 | Ruby | itggot-theo-wiik/gymnasiearbete | /models/quote.rb | UTF-8 | 169 | 3.015625 | 3 | [] | no_license | class Quote
def self.random()
quotes = ["Du kan göra allt om du vill.", "Ge aldrig upp!", "Imorgon är en ny dag!"]
return quotes.sample
end
end | true |
0aa47dec5d89b38096ce1f863ec8b75dc0514757 | Ruby | brettbevers/aiml-engine | /lib/aiml/tags/match_set.rb | UTF-8 | 1,041 | 2.5625 | 3 | [
"MIT"
] | permissive | module AIML
module Tags
class MatchSet < Base
def initialize(graph_master=nil)
@graph_master = graph_master
@body = []
end
def ==(other)
other.is_a?(AIML::Tags::MatchSet) && self.body == other.body
end
alias_method :eql?, :==
def hash
body.has... | true |
2be6c8aefbe033bc1e0a7dd4c56dff52d714a37d | Ruby | Rianasoa/MorpionRuby | /lib/application.rb | UTF-8 | 457 | 2.921875 | 3 | [] | no_license |
$:.unshift(File.expand_path'/home/dev/Documents/THP5/MorpionRuby/lib', __FILE__)
require 'game'
require 'board'
class Application
def perform
# TO DO : méthode qui initialise le jeu puis contient des boucles while pour faire tourner le jeu tant que la partie n'est pas terminée.
puts "HEY Bienvenu dans not... | true |
c2491ffc9ab3da50b728513027c0253823aae655 | Ruby | zendesk/stronger_parameters | /lib/stronger_parameters/constraints/string_constraint.rb | UTF-8 | 1,034 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'stronger_parameters/constraint'
module StrongerParameters
class StringConstraint < Constraint
attr_reader :maximum_length, :minimum_length
def initialize(options = {})
@maximum_length = options[:maximum_length] || options[:max_length]
@minimum_length = opti... | true |
e4d5be5d9fa3c5564cc6554370d0dc2c14ebbd5d | Ruby | MichaelAldaba/random | /tictactoe/third_iteration/lib/console.rb | UTF-8 | 7,367 | 3.34375 | 3 | [] | no_license | class Console
FIRST_DEFAULT_MARKER = "X".freeze
SECOND_DEFAULT_MARKER = "O".freeze
VS_COMPUTER = "Vs. Computer".freeze
VS_HUMAN = "Vs. Human".freeze
COMPUTER_MODE = "Computer Mode".freeze
MARKER_SELECT = "Marker Select".freeze
RETURN = "Return to Main Menu".freeze
HUMAN_TYPE = "H".freeze
COMPUTER_TYPE... | true |
4342317bbf4f14d0891e97033934c59353e48a93 | Ruby | zach-cullen/national-parks-explorer | /lib/national_parks_explorer/state.rb | UTF-8 | 912 | 3.171875 | 3 | [
"MIT"
] | permissive | class NPExplorer::State
attr_accessor :parks
attr_reader :name, :code
@@all = []
def initialize(state_name, state_code)
@name = state_name
@code = state_code
@parks = []
self.save
end
def save
@@all << self
end
def parks
NPExplorer::Park.all.select {|park| park.states.include... | true |
e491d15fd84570dfad2cfeb790b90be4466452a6 | Ruby | jonsnyder01/thesis_wikipedia | /lib/jaccard_index.rb | UTF-8 | 796 | 3.375 | 3 | [] | no_license |
module JaccardIndex
def self.call(v1, v2)
intersection = 0
union = 0
i1 = 0
i2 = 0
while i1 < v1.size && i2 < v2.size
x1 = v1[i1]
x2 = v2[i2]
if x1 == x2
# true positive
i1 += 1
i2 += 1
intersection += 1
union += 1
elsif x1 > x2
... | true |
eb296afa979ae157f43325a1755691ac7edbfe6d | Ruby | cfitz/aat-plugin | /frontend/models/sparql_query.rb | UTF-8 | 769 | 2.515625 | 3 | [] | no_license | require 'uri'
class SparqlQuery
def self.term_search(query_string)
new(query_string)
end
def self.lccn_search(lccns)
new(lccns.join(" "), ['local.LCCN'])
end
def initialize(query_string, limit = 25 )
@query = build_query(query_string, limit)
end
def query_string
@query
end
def... | true |
20f89a67bf6b892eaf38ebd4e36f3c693bb14e2d | Ruby | jjmora/THP-Day2_Ruby_Exercises | /exo_10.rb | UTF-8 | 279 | 4.125 | 4 | [] | no_license | puts "Hello, what's your year of birth?"
print "> "
user_year_of_birth = gets.chomp.to_i
age = 2017 - user_year_of_birth
if age > 1
puts "In 2017 you were #{age} years old"
elsif age == 0
puts "Hurray! You've been born in 2017!"
else
puts "You didn't exist in 2017!"
end
| true |
a4e6888a929c5c7100b1e5dc2034fb78e41bfd44 | Ruby | andysher/solved-programs | /ComputerVSHuman_MatchStick_Game.rb | UTF-8 | 927 | 3.796875 | 4 | [] | no_license | def comp_picks()
if $n==2
return 1
elsif $n==3
return 2
elsif $n==4
return 3
elsif $n>4
if ($n-6)>5 or ($n-2==7)
return 3
elsif (($n-5)>5 or ($n-1==8))
return 2
else
return 1
end
end
end
puts "\n\n****MatchStick Game****\n\n"
printf "Enter number of matchsticks : "
$n = gets.to_i
while ... | true |
bf16d56f91f4b037178336caf07312e0340e7e58 | Ruby | trivett/BEWD-NYC | /thiago_couto/class5/students_class_with_initialize.rb | UTF-8 | 427 | 3.65625 | 4 | [] | no_license | class Student
attr_accessor :name, :major, :gpa
def initialize(name, major, gpa)
@name = name
@major = major
@gpa = gpa
end
def to_s
"#{ @name } majors in #{ @major }. GPA: #{ @gpa }"
end
end
alice = Student.new("Alice", "Math", "A")
bob = Student.new("Bob", "Music", "C")
carlos = Student.n... | true |
e5f57e903fd16c37e568899a9af337183895fbcc | Ruby | araipiyo/egalite | /test/test_helper.rb | UTF-8 | 10,787 | 2.5625 | 3 | [
"MIT"
] | permissive | $LOAD_PATH << File.dirname(__FILE__)
$LOAD_PATH << File.join(File.dirname(__FILE__), '..')
require 'rubygems'
require 'test/unit'
require 'egalite'
require 'rexml/xpath'
require 'rexml/document'
module XPathTestingHelper
def to_doc(text)
REXML::Document.new(StringIO.new(text))
end
def asser... | true |
62ca44580583982a48d421c0e797b4f19c7c9278 | Ruby | lauradarlak/anagram-detector-v-000 | /lib/anagram.rb | UTF-8 | 340 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
require 'pry'
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(anagram_a)
match_a = []
anagram_a.each do |anagram|
anagram = anagram.split("")
if anagram.sort == @word.split("").sort
match_a << anagram.join
else match_a
end
en... | true |
ddd583ef1a40e2e2d97dc85d5b1275b045aa3e3e | Ruby | neddy/Launch-School | /Exercises/Challenges(Round_2)/Easy_2/ex_3/beer_song.rb | UTF-8 | 1,200 | 4.34375 | 4 | [] | no_license |
class BeerSong
def initialize
@lyrics_array = []
build_lyrics
end
def verse(n)
@lyrics_array[n]
end
def verses(finish, start)
@lyrics_array[start..finish].reverse.join("\n")
end
def lyrics
@lyrics_array.reverse.join("\n")
end
private
def build_lyrics
@lyrics_array << ... | true |
cb76355cf4b8b07b90685a1069ec5b23fc3a6e56 | Ruby | jbrinkley/puppet-marshall | /lib/puppet/marshall/mod/git.rb | UTF-8 | 2,535 | 2.734375 | 3 | [] | no_license | require 'puppet/marshall'
module Puppet::Marshall
class Mod::Git < Mod
def fetch
@target = File.join(@settings.repository,
'modules', 'marshall', @name)
@fetched = open_or_clone(@source, @target)
true
end
def implied_environm... | true |
f28be8ef99b24bfda21543b741782858ab704a6f | Ruby | hhoopes/exercism | /ruby/collatz-conjecture/collatz_conjecture.rb | UTF-8 | 244 | 3.234375 | 3 | [] | no_license | class CollatzConjecture
def self.steps(num)
raise ArgumentError if num < 1
steps = 0
while num > 1
num = num % 2 === 0 ? num / 2 : num * 3 + 1
steps += 1
end
steps
end
end | true |
8068fb75c52488968329f494898fd793aff0d781 | Ruby | stanloo/launch-school | /101_course/lesson2/rps_bonus.rb | UTF-8 | 3,472 | 4.09375 | 4 | [] | no_license | ### Rock Paper Scissors (bonus features)
### Forethoughts
=begin
## Rules of the game
http://www.samkass.com/theories/RPSSL.html
## Data structure
- save decisions in a hash to be able to check if user input is "1"/"2"/"3"...
--- also, array would start at index 0 and we want to start at 1
# CHOICES
'1' => 'rock',... | true |
43543d23e86067586a5cebc403b421186481a05b | Ruby | lonelyelk/advent-of-code | /spec/2022/07/day07_lib_spec.rb | UTF-8 | 1,170 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative "../../../2022/07/lib"
RSpec.describe Year2022::Day07 do
include described_class
let(:input) do
%($ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
584 i
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.... | true |
ec9138dbe8fb4f66ddb8b4261c6fe4cd85145149 | Ruby | rayning0/rubyquiz | /spec/title_case_spec.rb | UTF-8 | 502 | 2.796875 | 3 | [] | no_license | require 'spec_helper'
require 'title_case'
describe TitleCase do
let(:t) { TitleCase.new }
describe '#title_case' do
it 'convert a string into title case, given an optional list of exceptions (minor words)' do
expect(t.title_case('a clash of KINGS', 'a an the of')).to eq('A Clash of Kings')
expect... | true |
2dc03745831cf8a25ed9c624df6eca6b978f4e46 | Ruby | ShisiJu/notes | /ruby/ruby-class.rb | UTF-8 | 327 | 3.265625 | 3 | [] | no_license | class Car
attr_accessor :name
CONST = ['01' , '02'].freeze
@@foo = 1
def p_foo
puts @@foo
end
def initialize(name)
@name = name
end
def self.edit_const
CONST.push '03'
end
end
bmw = Car.new('bmw')
benz = Car.new('benz')
puts bmw.name
puts benz.name
bmw.p_foo
Car.edit_const
puts Car:... | true |
a5306a87940b3cf3e52d54041905b6628b38fbb7 | Ruby | PhilippePerret/ProximityNew | /lib/required/_then/ExtraitTexte/ExtraitTexte.rb | UTF-8 | 20,174 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
require 'tempfile'
require_relative '../Page'
class ExtraitTexte
DEFAULT_NOMBRE_ITEMS = 400 # c'est de toute façon le nombre de lignes qui importe
# ---------------------------------------------------------------------
#
# INSTANCE
#
# -------------------------------------------------------------... | true |
89e7dbf418567886c0e991d48ee671e5cb41eec6 | Ruby | bavarianrhino/oo-kickstarter-atlanta-web-career-121018 | /lib/backer.rb | UTF-8 | 577 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require_realitive "./project.rb"
class Backer
attr_accessor :name, :backed_projects
def initialize (name)
@name = name
@backed_projects = []
end
def back_project(project)
@backed_projects << project
project.backers << self
end
end
# bob = Backer.new("Bob")
# awesome_project ... | true |
a40874d83daee2f1a9167f7c334706009dcb6b06 | Ruby | Giagnus64/OO-mini-project-dumbo-web-071519 | /app/models/User.rb | UTF-8 | 1,741 | 3.265625 | 3 | [] | no_license | class User
@@all = []
attr_accessor :name
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def recipe_cards
RecipeCard.all.select do |recipe_card|
recipe_card.user == self
end
end
def recipes
... | true |
17a32f228f24b050251cfc84bd9d524bc1e54ba5 | Ruby | ethan-gustafson/ruby-js-algorithms | /Ruby_Blanks/ruby_blanks.rb | UTF-8 | 1,713 | 4.53125 | 5 | [] | no_license | #!/usr/bin/env ruby
# This is a fill-in-the-blank game.
# Example: "I decided to ______ a ______ party for my ______ ______."
# blanks = ['adjective', 'adjective', 'noun', 'verb']
# We will ask the user to give us two adjectives, a noun and a verb for the blank words in the sentence.
# We will record the users inp... | true |
5f69c8e62f8dc36c6ac3e05bbd3e9faf316cb25a | Ruby | andreydro/learn-ruby | /app/methods.rb | UTF-8 | 292 | 3.015625 | 3 | [] | no_license | def hello_world(family_name="", first_name="")
greeting = "Hello world\n"
if family_name != "" && first_name != ""
greeting += "My name is #{first_name} #{family_name}"
end
greeting
end
puts hello_world("Snitko","Roman")
#send_via_email hello_world
#send_over_http hello_world
| true |
91b388e443b38ea4eb4db5e4c97729ed1ceae291 | Ruby | etdev/algorithms | /0_code_wars/share_prices.rb | UTF-8 | 196 | 2.875 | 3 | [
"MIT"
] | permissive | # http://www.codewars.com/kata/5603a4dd3d96ef798f000068/
# --- iteration 1 ---
def share_price(invested, changes)
"%.2f" % changes.reduce(invested) { |acc, el| acc += (acc * el.fdiv(100)) }
end
| true |
a793ad35efcaef48401e1e60d6f0c13117934659 | Ruby | timhabermaas/cubemania | /spec/lib/humanizeable_spec.rb | UTF-8 | 1,127 | 2.921875 | 3 | [] | no_license | require "humanizeable"
class Dummy
extend Humanizeable
attr_accessor :blub
humanize :blub => :time
end
describe Humanizeable do
subject { Dummy.new }
it { should respond_to(:human_blub) }
describe "#human_attribute" do
let(:dummy) { Dummy.new }
context "when not passed a spacer" do
subje... | true |
c219997338e9348c84ae4fb1cf92d4ba1b947a3a | Ruby | Kvothe100/phase-0-tracks | /ruby/week6/dance_league.rb | UTF-8 | 923 | 3.296875 | 3 | [] | no_license | class Dancer
attr_accessor :arr, :age, :name
def initialize(arr)
@arr = arr
@name = name
@age = age
end
def name(name,age)
@name
end
def age(name,age)
@age
end
def age(name, age)
@age
end
def pirouette
puts "*twirls"
end
def bow
puts "bows to partner."
end
def leaps
puts "Leaps in the ai... | true |
2d399670af98ccf5c92a98800f8c786f44102b52 | Ruby | kwikiel/lsruby | /variables/variables5.rb | UTF-8 | 199 | 3.3125 | 3 | [] | no_license | #First program will return 3 with no errors
#
#
#
#x = 0
#3.times do
# x += 1
#end
#puts x
#Second program will return error because x is not defined
y = 0
3.times do
y += 1
x = y
end
puts x
| true |
cd9e706dbe772528d95ee7ce8d72872d2f1e691c | Ruby | hanrattyjen/Learning-Ruby | /sentence.rb | UTF-8 | 407 | 3.890625 | 4 | [] | no_license | sentence = []
# Type as many words as we want
puts "Please type one word per line, followed by Enter. If you press Enter twice, program will exit."
# one word per line, continuining until we just press enter on an empty line
while true
word = gets.chomp
if word == ""
break
end
sentence.push word
end
# Repeats ... | true |
f4a3c91c081992ea3c2ce84e67504e6387ca180e | Ruby | wxq92109/JOB | /第五次任务/《Ruby基础教程》示例程序/file_open.rb | UTF-8 | 131 | 2.546875 | 3 | [] | no_license |
class File_open
File.open("D:/rubytest.txt").each_line do |file|
file.each_line do |line|
print line
end
end
end | true |
e69c1f8aa4fec12fba3725b7405e0d81dac598e6 | Ruby | hmartinez69/thp-s2-d2-exercices_ruby | /exo_02.rb | UTF-8 | 91 | 3.375 | 3 | [] | no_license | puts "Quel est votre prénom ?"
print "> "
name = gets.chomp
puts "Bonjour, " + name + " !" | true |
887eb0c6941d0be6559f86ba88878be4c3913a2d | Ruby | vbmendes/ruby_koans | /koans/triangle.rb | UTF-8 | 1,140 | 4.125 | 4 | [
"MIT"
] | permissive | # Triangle Project Code.
# Triangle analyzes the lengths of the sides of a triangle
# (represented by a, b and c) and returns the type of triangle.
#
# It returns:
# :equilateral if all sides are equal
# :isosceles if exactly 2 sides are equal
# :scalene if no sides are equal
#
# The tests for this meth... | true |
ea74aa56173be16043f53e6a9d35afcb9f805525 | Ruby | gabrie30/Practice | /CoderByte/First_Factorial.rb | UTF-8 | 547 | 4.125 | 4 | [] | no_license | # Using the Ruby language, have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it (ie. if num = 4, return (4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 18.
# Use the Parameter Testing feature in the box below to test your code with different ar... | true |
e2df6bfc4317cf350325e3187c6dcc44ee94ac54 | Ruby | mackenco/Searches | /recursive_binary_search.rb | UTF-8 | 672 | 3.5625 | 4 | [] | no_license | def binary_search(arr, target)
target_index = arr.length/2 - 1
if arr[target_index] == target
temp = target_index
elsif arr.length == 1
temp = nil
else
if arr[target_index] > target && !binary_search(arr[0..arr.length/2], target).nil?
temp = binary_search(arr[0..arr.length/2], target)
elsi... | true |
72729789d08b62ca98d8898004184a79c2a7a196 | Ruby | AnnaMontoya/credit_check | /credit_check.rb | UTF-8 | 696 | 3.203125 | 3 | [] | no_license | card_number = "4929735477250543"
card_number.to_s.chars.map(&:to_i)
card_number = card_number.to_s.chars.map(&:to_i)
count = 0
card_number = card_number.reverse.map do |num|
if count.odd?
count += 1
(num * 2)
else
count += 1
num
end
end
def digit_sum(card_number)
card_number.map ... | true |
0b883936812eea5831f5ffe4034826f8b69747cb | Ruby | Mizuki-Niiyama/design-35359 | /spec/models/company_spec.rb | UTF-8 | 7,162 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Company, type: :model do
before do
@company = FactoryBot.build(:company)
end
describe 'ユーザー新規登録' do
context '新規登録できる場合' do
it '全て存在すれば登録できる' do
expect(@company).to be_valid
end
it 'passwordとpassword_confirmationが6文字以上であれば登録できる' do
... | true |
fa17159886879767587643a2c76296e451945b8f | Ruby | TheBlanc/film-recomendations | /exercise2.rb | UTF-8 | 3,373 | 3.625 | 4 | [] | no_license | documentary = "Icarus"
drama = "Gone Girl"
comedy = "Superbad"
dramedy = "Stranger than Fiction"
mockumentary = "This is Spinal Tap"
docudrama = "Hearts of Darkness"
docudramedy = "Birdman"
book = "A BOOK INSTEAD! How about, Harry Potter?"
choice = "incomplete"
puts "\nHey, friend. I want to reccomend you a movie bas... | true |
60596c3c134d977e8cf696256a463b8db50f2ef0 | Ruby | my-nguyen/hackerearth.com | /lets_begin.rb | UTF-8 | 764 | 3.859375 | 4 | [] | no_license | def process number
# special case when number is 1
if (number == 1)
return -1
else
# with the single-digit prime numbers as: 2, 3, 5, 7
# take the division by the largest single-digit prime number (7)
division = number / 7
# examine the remainder of the division,
case number % 7
when 0... | true |
916d2818bcaf30065541f9cfe1dee90a760a5224 | Ruby | cosine/record_parser | /spec/lib/record_parser/json_formatter_spec.rb | UTF-8 | 1,439 | 2.609375 | 3 | [] | no_license | require "spec_helper"
describe RecordParser::JsonFormatter do
describe ".jsonify" do
it "creates proper JSON for a Record" do
record = RecordParser::Record.new(["Last", "First", :male, "green", Date.new(1999, 11, 3)])
expect(RecordParser::JsonFormatter.jsonify(record)).to eq('{"last_name":"Last","fir... | true |
3bb73fd9da58289a1c3ac0a47b614d0d02a1591b | Ruby | talsafran/tabgrab | /lib/ultimate_guitar/artist_letter_page.rb | UTF-8 | 554 | 2.734375 | 3 | [] | no_license | module UltimateGuitar
class ArtistLetterPage
attr_reader :letter, :page
def initialize(letter, page = 1)
@letter = letter
@page = page
end
def artists
@artists ||= fetch_artists
end
def url
"http://www.ultimate-guitar.com/bands/#{@letter}#{@page if @page > 1}.htm"
... | true |
d2b1f2f06865d3975cb16a802757395bb46f0972 | Ruby | Pldare/SCRF | /核心/内核扩展/String.rb | UTF-8 | 447 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -w
# encoding: UTF-8
class String
def 字符串;'"' << 字符串化 << '"' end
def 编码变动(原编码,现编码);self.识别为(原编码).编码为(现编码) end
def 中文长度;长度 + 编码为('utf-8').扫描(/[\u4E00-\u9FA5]/).大小 end
def 填充(长度, 填充符 = ' ');中文长度 < 长度 ? self + (填充符 * (长度 - 中文长度)) : self end
def 中文?;self =~ /^[\u4e00-\u9fa5]+$/ end
end | true |
4bc3bcbf12d87128195cebe547fa3d9c15b36c6d | Ruby | CodingDojoDallas/ruby_dec_16 | /Tan_ShinYi/2. OOP/string.rb | UTF-8 | 416 | 3.75 | 4 | [] | no_license | class String
def my_reverse
word = self.split("")
r = (word.length-1)..0
new_word = ""
r.first.downto(r.last).each { |i| new_word += word[i] }
new_word
end
def my_reverse!
reverse = self.my_reverse.split("")
for i in 0...reverse.length
self[i] = reverse[i]
end
self
en... | true |
1b20852aa397772d6da7494ced27a9f3a5b7f294 | Ruby | sravanpsk/mysql | /Ruby/negationwith.rb | UTF-8 | 56 | 2.625 | 3 | [] | no_license | puts !false
a = "apple"
if a != "anana"
puts "no"
end
| true |
3d6e027e1857ee47eb9892b5e94d4eb7f8a56107 | Ruby | Shelvak/nebula-game | /server/lib/app/models/tile.rb | UTF-8 | 4,248 | 2.546875 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | # Base class for Tile::* classes.
class Tile < ActiveRecord::Base
include Parts::WithLocking
include FastFind
def self.fast_find_columns
{:id => :to_i, :x => :to_i, :y => :to_i, :kind => :to_i}
end
# Not stored in database.
VOID = -1
# Only metal extractors can be built on these
ORE = 0
# Only g... | true |
f54f8ff1e423bd995844cfed0df2efaa893e25a6 | Ruby | Icehawk78/SagradaRails | /db/seeds.rb | UTF-8 | 2,008 | 2.609375 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
55e67e0ebd2db0b405aaa1bd745e52ff5aa55c9b | Ruby | samuelvary1/fields_of_peril | /lib/room.rb | UTF-8 | 296 | 2.703125 | 3 | [] | no_license | class Room
attr_accessor :header, :title, :first_time_message, :description, :details, :items, :rooms, :access_points, :been_before, :characters
attr_writer :starting_location
def has_room_to_the?(direction)
rooms.key?(direction)
end
def starting_location?
@starting_location
end
end
| true |
6136a54db47a7ad720730818554a8a01884447f7 | Ruby | MichaelMoravetz/parrot-ruby-ruby-apply-000 | /parrot.rb | UTF-8 | 83 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def parrot(string = "Squawk!")
squawk = string
puts string
return squawk
end
| true |
1e3d7825f229bc4241e0cdbc3f22e45938dea7d3 | Ruby | mevanoff24/playground | /graph/two_dijkstras.rb | UTF-8 | 808 | 3.28125 | 3 | [] | no_license |
class Maze
attr_accessor :nodes, :connections
def initialize(nodes, connections)
@nodes = nodes
@connections = connections
end
def initial_distances(goal)
distance = [nil]* nodes.length
distance[nodes.index(goal)] = 0
distance
end
def closest(nodes,distances)
nodes.min_by{ |node| distances[nodes.... | true |
16fea6596ba411f8f170cdd42af35c8b62d4aacb | Ruby | clamilala/expenses_app | /app/controllers/spreadsheets_controller.rb | UTF-8 | 1,817 | 2.546875 | 3 | [] | no_license | class SpreadsheetsController < ApplicationController
def index
# ユーザーに紐づく収入分類を取得
@income_classifications = IncomeClassification.where(user_id: current_user.id, list_sgn: true).order(order_seq: :asc)
# ユーザーに紐づく支出分類を取得
@pay_classifications = PayClassification.where(user_id: current_user.id, list_sgn: ... | true |
3b7462fd69ac153443bce074bc1deb4c274f0c50 | Ruby | davidesantangelo/secrypto | /lib/crypto.rb | UTF-8 | 909 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'openssl'
require 'digest'
class Crypto
def self.encrypt(data, key)
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
cipher.encrypt
cipher.key = key = Digest::SHA256.digest(key)
random_iv = cipher.random_iv
cipher.iv = Digest::SHA256.digest(random_iv + key)[0..15]
encrypted = ciphe... | true |
46d2a3c5458531ccb2377b93aad67a65860bc586 | Ruby | ver2point0/ruby-way | /1.5-training-intuition/perspectives-in-programming.rb | UTF-8 | 3,790 | 4.25 | 4 | [] | no_license | # There is not boolean type in Ruby. TrueClass and FalseClass are distinct classes
# Their only instantiations are true and false
# Many Ruby operators are similar or identical to C
# Two notable ones are ++ and --, they are not available in Ruby
# neither in "pre" or "post" forms
# Ruby's modulus behavior
# puts (5 ... | true |
a149d6fc07b28411d83d295d243614c3b95cd6a1 | Ruby | Mary-Castaneda/Learn_to_Program | /dictionary_sort.rb | UTF-8 | 967 | 3.984375 | 4 | [] | no_license | def sort some_array
my_sort some_array, [], []
end
def my_sort some_array, sorted_array, capital_array
some_array.each do |item|
if item == item.capitalize
capital_array.push(item)
some_array.delete(item)
end
end
while some_array != []
sorted_array.push(s... | true |
f2576aa2100cc7cb5b9553c020394388b084551c | Ruby | rabbykhairul/Chess_game | /Chess_pieces/slideable_module.rb | UTF-8 | 1,146 | 3.375 | 3 | [] | no_license | module Slideable
HORIZONTAL_DIRECTIONS = [
[ 0, 1 ],
[ 0, -1 ]
]
VERTICAL_DIRECTIONS = [
[ 1, 0 ],
[ -1, 0 ]
]
DIAGONAL_DIRECTIONS = [
[ 1, -1 ],
[ 1, 1 ],
[ -1, -1 ],
[ -1, 1 ]
]
def find_moves(directions)
moves = []... | true |
bcbb8bd840d5728678043851d7545c8b0ad809a7 | Ruby | parm530/my-select-001-prework-web | /lib/my_select.rb | UTF-8 | 286 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
# your code here!
temp_array = []
i = 0
i_t_a = 0 #index of temp array
while (i < collection.size)
condition = yield collection[i]
if(condition == true)
temp_array[i_t_a] = collection[i]
i_t_a += 1
end
i += 1
end
temp_array
end
| true |
b16c390a6842c04fc78cd94c8b0195b19ba624b9 | Ruby | merbjedi/merb_wheels | /lib/merb_wheels/helpers/tag_helpers.rb | UTF-8 | 1,384 | 2.703125 | 3 | [
"MIT"
] | permissive | module MerbWheels #:nodoc:
module Helpers #:nodoc:
module TagHelpers
# Returns a CDATA section with the given +content+. CDATA sections
# are used to escape blocks of text containing characters which would
# otherwise be recognized as markup. CDATA sections begin with the string
# <tt><![... | true |
80109f822ea5747bd0a3d8e70c402e39ef961ae4 | Ruby | djberg96/html-table | /spec/body_spec.rb | UTF-8 | 3,017 | 3.0625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | ############################################
# body_spec.rb
#
# Test suite for the HTML::Table::Body class.
############################################
require 'rspec'
require 'html/table'
RSpec.describe HTML::Table::Body do
before do
@table = HTML::Table.new
@tbody = described_class.new
end
example 'c... | true |
9ee5a108192f4e6c09caad49adb51cb2d1acba61 | Ruby | NB28VT/Meetups-in-Space | /db/seeds.rb | UTF-8 | 909 | 2.515625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Example:
#
# Person.create(first_name: 'Eric', last_name: 'Kelly')
Meetup.create(title: "Kickin\' ASS and taki... | true |
5b92bcb7ce60f43d547145c133dc466dc4edeeea | Ruby | kleopatra999/heirloom | /lib/heirloom/cli/formatter/catalog.rb | UTF-8 | 1,557 | 2.65625 | 3 | [
"MIT"
] | permissive | module Heirloom
module CLI
module Formatter
class Catalog
def initialize(args)
@catalog = args[:catalog]
end
def detailed_format(args)
@name = args[:name]
@region = args[:region]
filter_by_name
details
end
def... | true |
c33de9d20fadfed5b951f682f87b40dfb931cc1f | Ruby | DomainTools/api-ruby | /lib/domain_tools/xml_parser.rb | UTF-8 | 747 | 2.8125 | 3 | [
"MIT"
] | permissive | module DomainTools
class XMLParser
def self.parse(source)
require 'rexml/document'
doc = REXML::Document.new(source)
root_node = doc.elements.first
data_node = root_node.elements.first
hash = self.parse_node({},data_node)
end
def self.parse_node(hash,nod... | true |
f8b2bc15695444a6399442ae35a01654d36d00dc | Ruby | sekiya93/ProgramTracing | /exam/ruby_code/r005.rb | UTF-8 | 99 | 3.0625 | 3 | [] | no_license | def r005(i, a)
if i == 0 then
return a[0]
else
return r005(i-1, a) + a[i]
end
end
| true |
3c5a9233c4a604121e245afa69bf72f8c6ec092c | Ruby | chedabob/colours-compiler | /script.rb | UTF-8 | 3,584 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/ruby
require 'json'
inputFileName = "colours.json"
outputHeaderFileName = "Colours.h"
outputSourceFileName = "Colours.m"
outputXMLFileName = "colors.xml"
headerTemplateFileName = "Template.h"
sourceTemplateFileName = "Template.m"
xmlTemplateFilename = "Template.xml"
def isHex (stringForCheck)
return ... | true |
20d07a65ef6dffa9551cd0566acdf4d35c5cd420 | Ruby | uybinh/exercism | /ruby/robot-name/robot_name.rb | UTF-8 | 439 | 2.96875 | 3 | [] | no_license | class Robot
@@history = Hash.new
@@names = [*('AA000'..'ZZ999')]
def self.forget
@@history = Hash.new
end
attr_reader :name
def initialize
reset
end
def reset
@name = new_name
end
private
def generate_name
index = rand(@@names.length)
@@names[index]
end
def new_name
... | true |
22a06e64bebe1c563d8b061b96a2f8737e0d16be | Ruby | bbqfast/clipita | /app/models/clip.rb | UTF-8 | 1,376 | 2.5625 | 3 | [] | no_license | require Rails.root.to_s + '/UniqueClip.rb'
class Clip < ActiveRecord::Base
before_save :check_name
def check_name
if name.nil?
raise 'null name error'
end
end
def as_json(options={})
super( :methods =>[:updated_js] )
end
def updated_js
# x 1000 to make it javascript compliant
updated... | true |
45f2c1b38eaec835afa15165cbc89b8aa0a0abbb | Ruby | sjlee3157/string_reverse | /lib/string_reverse.rb | UTF-8 | 330 | 3.71875 | 4 | [] | no_license | # def swap(a, b)
# c = a
# a = b
# b = c
# end
#
# T: O(n)
# S: O(1)
def string_reverse(my_string)
return nil if my_string.nil?
n = my_string.length
i = 0
j = n-i-1
while i < j do
memo = my_string[i]
my_string[i] = my_string[j]
my_string[j] = memo
i = i+1
j = j-1
... | true |
498ff6896af308d57c8c84d6ff3bc8dfce425115 | Ruby | justineshaw/ttt-game-status-cb-gh-000 | /lib/game_status.rb | UTF-8 | 1,743 | 4.09375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [ # 3 vertical, 3 horizontal, 2 diagnol
[0, 1 , 2],
[3, 4 , 5],
[6, 7 , 8],
[0, 3 , 6],
[1, 4 , 7],
[2, 5 , 8],
[2, 4 , 6],
[0, 4 , 8],
]
def ... | true |
227c44c9e9886765e3f13dd57cf20e4fae7d7daa | Ruby | amelieoller/procedural-ruby-code-challenge | /spec/show_spec.rb | UTF-8 | 2,864 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../lib/show.rb"
describe "show" do
# Array of show hashes, where each show has a name and a rating.
let(:shows) {
[
{
name: "Friends",
rating: 8
},
{
name: "Rick and Morty",
rating: 10
}
]
}
# Write a method that returns the number of shows in your array
cont... | true |
d9f90b22286c42b8832f753dcc7eab98495c9f64 | Ruby | gengogo5/atcoder | /ABC/abc148/ABC148_A.rb | UTF-8 | 79 | 2.859375 | 3 | [] | no_license | A = gets.to_i
B = gets.to_i
ans = "123"
puts ans.delete(A.to_s).delete(B.to_s) | true |
aa9191a3d1666f64851130e249f4bb647eb41da4 | Ruby | charlesghost/sparta_api_testing | /spec/postcode_spec.rb | UTF-8 | 9,760 | 2.78125 | 3 | [] | no_license | require 'spec_helper'
describe Postcodesio do
context 'requesting information on a single postcode works correctly' do
before(:all) do
@postcodesio = Postcodesio.new
@response = @postcodesio.get_single_postcode('b601ja') #input a postcode
@uk_countries = ['England','Wales','Scotland','Northen... | true |
9bee7e5af592385a708eed78baa3f1ab75cb40e7 | Ruby | vporta/learningRuby | /Ranges/ranges.rb | UTF-8 | 2,157 | 4.53125 | 5 | [] | no_license | # Define a method, #alphabet_slice(range), that accepts a range of integers as an argument. Use the range to slice a string of characters representing the alphabet. Remember, the String#slice method can accept a range as an argument!
# alphabet_slice((0..3)) # ==> "abcd"
# alphabet_slice((0...3)) # ==> "abc"
# ... | true |
5a4d9ade47f066b2163b976e15e9e469dfa61f35 | Ruby | phoenix-legend/stocks | /app/models/stock_bak.rb | UTF-8 | 8,433 | 2.640625 | 3 | [] | no_license | class StockBak < ActiveRecord::Base
require 'rest-client'
require 'pp'
STATUS = ['垃圾', '不考虑', '好', '未知']
#获取靠谱股票推荐,需要符合以下条件:
# 1. 10年高价是10年低价的3倍以上。
# 2. 当前价格达到buy_price 上下10%左右。
# 3. 当前价格达到best_price 上下10%左右。
# #
# Stock.get_useful_stock
def self.get_useful_stock
recommend_stocks = []
very... | true |
f3cf5dcdfa8c7769c7186e298d0c6486f0ac713f | Ruby | pdg137/pi-maze-solver | /pi/robot.rb | UTF-8 | 1,535 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
system("echo #{Process.pid} > /var/run/robot.pid")
$stdout.sync = $stderr.sync = true
require_relative 'lib/a_star'
require_relative 'lib/looped_maze_solver'
a_star = AStar.new
def do_maze_solving(a_star)
solver = LoopedMazeSolver.new(a_star)
a_star.set_leds(false, false, true)
sleep(0.5)
... | true |
7a6811964fb373b00174d4e01bc2c15b81767cfc | Ruby | kafunk/project_cli_connect_four | /connect_four/game.rb | UTF-8 | 1,274 | 3.671875 | 4 | [] | no_license | class Game
attr_reader :over
def initialize
@player_one = nil
@player_two = nil
@current_player = nil
@board = Board.new
end
def welcome
puts "Welcome to a new game of Connect Four!"
end
def get_names
puts "Player One, what is your name?"
print "> "
@player_one = Player.n... | true |
591354f827b33698a7772e2a0a2eaca2fd9f3725 | Ruby | zfv200/badges-and-schedules-prework | /conference_badges.rb | UTF-8 | 627 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | con_speakers = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(array)
badges = []
array.each do |i|
badges.push(badge_maker(i))
end
return badges
end
def assign_rooms(array)
rooms = []
room_number = 1
... | true |
9386699aec66a5bf0ab9b9e75c718287e8fa6b04 | Ruby | benrodenhaeuser/exercises | /ruby_foundations/0206.rb | UTF-8 | 250 | 3.828125 | 4 | [] | no_license | def each_with_index(list)
index = 0
while index < list.length
yield(list[index], index)
index += 1
end
list
end
result = each_with_index([1, 3, 6]) do |value, index|
puts "#{index} -> #{value**index}"
end
puts result == [1, 3, 6]
| true |
6d87bb446d77dd772f688c9f0fad64883ff92793 | Ruby | emanuelegorga/bank_tech_test_ruby | /lib/bank_account.rb | UTF-8 | 886 | 3.484375 | 3 | [] | no_license | require_relative 'transaction'
require_relative 'transactions_history'
require_relative 'statement'
require 'date'
class BankAccount
attr_reader :balance, :transactionsHistory
def initialize(transactionsHistory = TransactionsHistory.new, statement=Statement.new)
@transactionsHistory = transactionsHistory
... | true |
c0d24299cb6ee900ca740a69c044a6f9aac54036 | Ruby | inasacu/thepista | /httparty/ruby/1.9.1/gems/moped-1.5.2/lib/moped/bson/max_key.rb | UTF-8 | 1,253 | 3.0625 | 3 | [
"MIT"
] | permissive | module Moped
module BSON
# Represents the maximum key value in the database.
class MaxKey
class << self
# Check equality on the object.
#
# @example Check equality.
# object == other
#
# @param [ Object ] other The object to check against.
#
... | true |
64cb119b127eb5e08fddf854551496a242234e5d | Ruby | preetness/phase-0-tracks | /databases/sql_project/employees.rb | UTF-8 | 8,900 | 3.3125 | 3 | [] | no_license | require 'sqlite3'
require 'faker'
require 'colorize'
### BUSINESS LOGIC ###
db = SQLite3::Database.new('accounting.db')
employee_table = <<-SQL
CREATE TABLE IF NOT EXISTS employees (
id INTEGER PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255),
wage INT,
title VARCHAR(255),
last_four_ssn INT... | true |
3d237fe8fc711a1fc9c7d0cc16a315de52c1d9a6 | Ruby | mmanousos/pipeline-test | /producer/src/value_producer.rb | UTF-8 | 1,266 | 2.984375 | 3 | [] | no_license | require 'avro_turf'
require 'avro_turf/messaging'
require 'date'
require 'kafka'
require 'timeloop'
# connects to the local Kafka instance
# kafka = Kafka.new(["localhost:9092"])
kafka = Kafka.new(["broker:29092"])
# You need to pass the path to the avro schema file
# avro = AvroTurf::Messaging.new(registry_url: "htt... | true |
63c806fd3f6badd2fd49fd9cf7facee64cedbb1a | Ruby | Sabirinmunye/spartaClasswork | /homework/week4d3/rootsAndControllers/controllers/videos_controller.rb | UTF-8 | 1,383 | 2.53125 | 3 | [] | no_license | class VideosController < Sinatra::Base
$videos = [{
id: 0,
title: "smokey eye",
content: "first video",
url: "dF_iBT4KgvM"
},
{
id: 1,
title: "glitter eye",
content: "this is the second video",
url: "w3p3dBhQYko"
},
{
id: 2,
title: "cut crease",
content: "this is the thir... | true |
8383f7adfc92c3359e9fd70cc4a6f7256c41a234 | Ruby | rcsheets/dbbackup | /backup.rb | UTF-8 | 2,089 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'tempfile'
require 'time'
# Cross-platform way of finding an executable in the $PATH.
#
# which('ruby') #=> /usr/bin/ruby
#
# Function based on code found at http://stackoverflow.com/a/5471032/221689
def which!(cmd)
found = which(cmd)
throw "I could not find #{cmd}" if found.nil?
f... | true |
910eace3022d2582e513ccc3a14673386aa75095 | Ruby | RealSavvy/realsavvy-gem | /lib/real_savvy/document.rb | UTF-8 | 1,051 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'real_savvy/meta'
require 'real_savvy/resource'
class RealSavvy::Document
attr_reader :document
def initialize(document, status: nil)
@document = document
@status = status
end
def data
@data ||= self.class.process_resources(document['data'], self)
end
alias results data
def resul... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.