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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5e30a0c5f27ba4b4bf37d0c22b54da07f68d0785 | Ruby | mario21ic/ruby-ejercicios-poo | /enunciado_04/test/trabajador_test.rb | UTF-8 | 713 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require './trabajador'
class MiPrimerTest < Test::Unit::TestCase
def setup
@mario = Trabajador.new(44489174, "Mario", "Inga", 250, "planilla")
end
def teardown
@mario = nil
end
def test_sueldo_planilla
@mario.tipo = "planilla"
assert_equal @mario.calcu... | true |
43a843764425af82215504e386b62e82e05c6f84 | Ruby | leahnp/mergesort | /mergesort.rb | UTF-8 | 625 | 3.84375 | 4 | [] | no_license | def mergesort(a)
# base case
return a if a.length <= 1
# split array
left, right = split_array(a)
# recursive case
combine(mergesort(left), mergesort(right))
end
def split_array(a)
middle = a.length / 2
left = a[0...middle]
right = a[middle..-1]
return left, right
end
def combine(a, b)
result =... | true |
ebb45e21316a1e87a2d59f70cc7d338e01ba8187 | Ruby | leovcunha/ruby-projects | /2.ruby/ghost/game.rb | UTF-8 | 3,189 | 3.75 | 4 | [] | no_license | require_relative 'player.rb'
require 'set'
class Game
def initialize(players, dictionary)
raise ArgumentError if players.any? {|el| el == ""} || players.empty?
@players = players.map {|pl| Player.new(pl)}
@current_player = @players[0]
@previous_player = @players[-1]
@fragmen... | true |
fda69778a1a0bb19305918a17762b22a574ccc7e | Ruby | FreeBreadsticks/ruby-music-library-cli-v-000 | /lib/music_library_controller.rb | UTF-8 | 1,470 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MusicLibraryController
attr_accessor :path
def initialize(path = './db/mp3s')
MusicImporter.new(path).import
end
def call
puts "Yo what up?"
input = gets.downcase
case input
when "list songs"
n=0
Song.all.each do |song|
puts "#{n+=1}. #{song.artist.n... | true |
e5408b6f1db73aa2b86e4e8d4238f406b0c321dc | Ruby | TetianaFilonenko/homework3 | /tmp40/sandbox40/library_manager_spec.rb | UTF-8 | 4,613 | 2.75 | 3 | [] | no_license | require './library_manager.rb'
describe LibraryManager do
let!(:stendhal) { Author.new(1783, 1842, 'Stendhal' ) }
let!(:nietzsche ) { Author.new(1844, 1900, 'Friedrich Nietzsche' ) }
let!(:leo_tolstoy) { Author.new(1828, 1910, 'Leo Tolstoy' ) }
let!(:some_author) { Author.new(1828, 1910, 'Some Author' ) }
l... | true |
291706d22645905bf60b067cf21e3c984accb1e3 | Ruby | manhngg/e-shop | /app/models/cart.rb | UTF-8 | 762 | 2.90625 | 3 | [] | no_license | class Cart < ApplicationRecord
has_many :cart_items
def add_product(product_params)
current_item = cart_items.find_by(product_id: product_params[:product][:product_id])
if current_item
current_item.quantity += product_params[:product][:quantity].to_i
current_item.save
else
new_ite... | true |
1c23ff94d7a1a45f634b1bc32de17dbc09b7bed2 | Ruby | rrosenb12/ruby-oo-relationships-practice-boating-school-exercise-nyc01-seng-ft-060120 | /app/models/student.rb | UTF-8 | 815 | 3.21875 | 3 | [] | no_license | class Student
attr_accessor :first_name
@@all = []
def initialize(first_name)
@first_name = first_name
@@all << self
end
def self.all
@@all
end
def add_boating_test(name, status, instructor)
BoatingTest.new(self, name, status, instructor)
end
... | true |
c846785c1ca7eb3ccc8ec92a8e10eac00b58fc62 | Ruby | Solumin/RubyBackups | /bin/rubybackup | UTF-8 | 819 | 2.796875 | 3 | [] | no_license | #!ruby
require "thread"
require_relative "../lib/rubybackup"
good_files = RubyBackup::FileGatherer.gather
groups = RubyBackup::FileGroup.group(good_files)
puts "#{groups.keys.length} file groups"
puts "Do you want to compress and upload the test file to S3? (Y/N)"
if STDIN.gets.match(/^[Yy]/)
RubyBackup::S3Upl... | true |
1770cfb8a0ec52fc06700ae791f00c878aadac33 | Ruby | shabbirsaifee92/rspec-course | /spec/before_and_after_hooks.rb | UTF-8 | 274 | 2.65625 | 3 | [] | no_license | RSpec.describe 'before and after hooks' do
before(:context) do
puts 'hola'
end
after(:context) do
puts 'bye'
end
it 'is just a random example' do
expect(5+4).to eq(9)
end
it 'is just another random example' do
expect(3-2).to eq(1)
end
end | true |
21562f311f365ae6ac14926a06bb7c843f44cc0c | Ruby | abraxaslee/LeetCode | /122.rb | UTF-8 | 319 | 3.6875 | 4 | [
"MIT"
] | permissive | # 122. Best Time to Buy and Sell Stock II
# 198 / 198 test cases passed.
# Status: Accepted
# Runtime: 40 ms
# @param {Integer[]} prices
# @return {Integer}
def max_profit(prices)
profit = 0
for i in 1...(prices.length)
profit += prices[i] - prices[i-1] if prices[i] > prices[i-1]
end
profit
end
| true |
c5d933abe642077a1b634bf3ffc6571b5f428840 | Ruby | twmills/amazon_merchant | /lib/amazon_merchant/string.rb | UTF-8 | 152 | 2.625 | 3 | [
"MIT"
] | permissive | module AmazonMerchant::String
def self.camelize(string)
string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
end | true |
c10f664933bf82bb2b2dd0dfb869503c21b8190b | Ruby | laOLIVAesVERDE/kids_village | /db/seeds.rb | UTF-8 | 1,979 | 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 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 |
ef37944a4ff95dda2e12078e5d72238c84f340a8 | Ruby | rbabamusta/rubybasicfunctions | /rubybasicfunctions.rb | UTF-8 | 611 | 3.71875 | 4 | [] | no_license |
def addAmerica(n)
puts n + " Only in America!"
end
addAmerica("I ate my cousins")
a = [1, 8, 7, 8, 100, -91824, 200]
def max(array)
maxnumber = array[0]
for element in array
if element > maxnumber
maxnumber = element
end
end
maxnumber
end
def keyvalue(arg1, arg2)
hash = {}
for element in 0..arg1.l... | true |
5c0a4a43edf3f1580dc41a1647701ba54f35d949 | Ruby | popmedic/popmedia | /server/requires/crate.rb | UTF-8 | 6,611 | 2.578125 | 3 | [] | no_license | require 'mongrel'
require 'json'
require 'cgi'
require_relative './image.rb'
class CrateItem
def initialize(name, info, href, stream, image, kind)
@hash = {
"name" => name,
"info" => info,
"href" => href,
"stream" => stream,
"ima... | true |
5e23c8c766439a1c7d09de1cdbb6dea129743f6e | Ruby | CountCulture/twfy_local_parser | /test/unit/helpers/application_helper_test.rb | UTF-8 | 3,752 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
context "link_for helper method" do
should "return nil by default" do
assert_nil link_for
end
should "return link for item with object title for link text" do
obj = stale_factory_object(:committee) # poss better wa... | true |
62d2d9987b417b53b1332a379b49c8acfe2d8979 | Ruby | nistude/codekata | /00-roman_numerals/lib/roman_numeral_converter.rb | UTF-8 | 711 | 3.859375 | 4 | [] | no_license | module RomanNumeralConverter
def to_roman(number)
roman = []
if number < 4
number.times { roman << 'I' }
elsif number == 4
roman << 'IV'
elsif number < 9
roman << 'V'
roman << to_roman(number - 5)
elsif number == 9
roman << 'IX'
elsif number < 40
roman << '... | true |
b41e84aa5ed1d1261974b701acf9c5017c42b7fd | Ruby | Adilza/cursobrunobatistaudemy_Dil2018 | /tests_2018/features/step_definitions/primeiro_cenario.rb | UTF-8 | 281 | 3.171875 | 3 | [] | no_license | # You can implement step definitions for undefined steps with these snippets:
Quando("eu somo {int} + {int}") do |valor1, valor2|
@soma = valor1 + valor2
end
Então("o resultado tem que ser {int}") do |resultado|
expect(@soma).to eq resultado
puts @soma
puts resultado
end | true |
9d579da5f6c43e61ff26aa3a5645f2582baba7b7 | Ruby | killy971/project-euler | /ruby/023.rb | UTF-8 | 493 | 3.609375 | 4 | [] | no_license | #!/usr/bin/ruby1.9
# vim:set ts=2 sw=2:
class Integer
def abundant?
(1..(self / 2)).select {|i| self % i == 0}.inject(0) {|s, e| s + e} > self
end
def sum_of_two_abundants?
return false if self < 24
a = self - 11
while a > self / 2 - 1
a -= 1
next if !$abundants[a]
next if !$abundants[self - a]
... | true |
fb43d4e27cdb1f2fdcb3d7a80b35a67afb31637c | Ruby | flyerhzm/rails_best_practices | /lib/rails_best_practices/lexicals/remove_tab_check.rb | UTF-8 | 752 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module RailsBestPractices
module Lexicals
# Make sure there are no tabs in files.
#
# See the best practice details here https://rails-bestpractices.com/posts/2011/07/04/remove-tab/
class RemoveTabCheck < Core::Check
interesting_files ALL_FILES
url 'https://r... | true |
375e39a50d5eb75b7893e2162f6ae61484878f03 | Ruby | brandallk/ttt-8-turn-bootcamp-prep-000 | /lib/turn.rb | UTF-8 | 1,515 | 4.4375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def display_board(board)
# Convert board elements to board cells with added whitespace
cells = []
i = 0
while i <= 8
cells[i] = " #{board[i]} "
i += 1
end
# Construct the board's 3 rows
row_1 = "#{cells[0]}|#{cells[1]}|#{cells[2]}"
row_2 = "#{cells[3]}|#{cells[4]}|#{cells[5]}"
row_3 = "#... | true |
9934adc6086487fa3737c1d9dcb1aae42d80d202 | Ruby | baothi/dinosys_test | /app/controllers/home_controller.rb | UTF-8 | 1,231 | 2.671875 | 3 | [] | no_license | class HomeController < ApplicationController
def show
@data = handle_export_data
respond_to do |f|
f.json { render json: @data }
f.html { }
end
end
def total
@total = {}
Category.all.each do |cat|
expenses = cat.expenses
@total[cat.name] = (expenses.sum(:tax_amount).... | true |
405ae4b25ed7baf2634194fed9895d63f2cd9737 | Ruby | jaymarquis/steam_hlds_log_parser | /examples/example-1.rb | UTF-8 | 443 | 2.625 | 3 | [
"MIT"
] | permissive | require "rubygems"
require "steam_hlds_log_parser"
# Your displayer Class is what you will do with your data
class Formatter
def initialize(data)
# will 'puts' the translated content, using built-in Displayer
SteamHldsLogParser::Displayer.new(data).display_translation
end
end
# Setup the Client to use the... | true |
c82fdb564fac5d94f25ba3a028e5317a3a7306fe | Ruby | krainboltgreene/scripts | /ostruct.rb | UTF-8 | 1,249 | 3.078125 | 3 | [] | no_license | require 'benchmark'
class ArgsNode
attr_accessor :pre
end
class Pre
attr_accessor :child_nodes
end
class MultipleAsgn19Node
end
class MultipleAsgn18Node
end
class ANode < MultipleAsgn19Node
end
class BNode < MultipleAsgn18Node
def name
self.class.name
end
end
pre = Pre.new
args_node = ArgsNode.new
no... | true |
0b75a033dfe2033296cf9ae3f27d4207bf690f6d | Ruby | toddt67878/udemy-learn-to-code-with-ruby | /MODULES_AND_MIXINS/4. the_math_module.rb | UTF-8 | 470 | 3.421875 | 3 | [] | no_license | =begin
apart from creating custom modules, Ruby has also built-in ones. Some of them
have to be called to the file by require command, and some of them are
imported automatically e.g. math module is automatically available. It gives
us the access to a bunch of constants and methods relating to the various
methematical ... | true |
5c8a052563df72aafe762cdaa8ff2c4887083a14 | Ruby | openstax/swerve | /swerve/site_repo.rb | UTF-8 | 1,702 | 2.859375 | 3 | [
"MIT"
] | permissive | class SiteRepo
attr_reader :github_path
def initialize(clone_parent_dir, github_path)
@clone_parent_dir = clone_parent_dir
@github_path = github_path
end
def cloned?
File.directory?(clone_dir) && !(Dir.entries(clone_dir) - %w{ . .. }).empty?
end
def download
Swerve.log_part("Downloading ... | true |
faef56bddf9701317bb76f58554ed6ef81773ada | Ruby | akakikuumeri/Ruby-graphics-demo | /bmi.rb | UTF-8 | 109 | 2.796875 | 3 | [] | no_license | #get bmi
def bmi(height, weight)
weight / (height/100.0) ** 2 # ** is the same as ^ in other languages
end
| true |
92ab71661a18abb0004eacc74364c7b8491da535 | Ruby | cristinaocanamanzano/bank | /lib/bank_account.rb | UTF-8 | 916 | 3.625 | 4 | [] | no_license | require 'date'
require_relative 'statement_printer'
class BankAccount
attr_reader :balance, :transactions
def initialize
@balance = 0.00
@transactions = []
end
def add_deposit(amount)
update_balance('deposit', amount)
add_transaction('deposit', two_decimals(amount), ' ')
end
def add_with... | true |
77f819280cdfe394e50088284a1cb474866c2926 | Ruby | chrismo/checkups | /lib/checkups/notification_timer.rb | UTF-8 | 1,102 | 3.078125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Checkups
class NotificationTimer
def initialize(frequency, status)
@frequency = frequency
@status = status
end
def now?
case @status
when :warning, :error
true
else
case @frequency
when :always
true
... | true |
8a1fa751a0638bdbda9f4bbff3ba4c6582f25bf5 | Ruby | weimingtom/RPGMakerDefaultScripts | /rpgmaker-vxace.zh-tw/Game_Pictures.rb | UTF-8 | 450 | 2.859375 | 3 | [] | no_license | #encoding:utf-8
#
# 包裝了圖片數組的外殼。本類在 Game_Screen 類的內定使用。地圖圖塊圖像和戰鬥圖
# 像另行處理。
#
class Game_Pictures
#
# 初始化物件
#
#
def initialize
@data = []
end
#
# 取得圖片
#
#
def [](number)
@data[number] ||= Game_Picture.new(number)
end
#
# 迭代
#
#
def each
@data.compact.each {|picture| yield pi... | true |
7ac8fbd8945ee600bb965336baabcaee938cd993 | Ruby | RobertRodes/RB101 | /small_problems/advanced_1/ex_7.rb | UTF-8 | 498 | 3.515625 | 4 | [] | no_license | def merge(arr1, arr2)
a1 = arr1.clone
a2 = arr2.clone
merged_array = []
until a1.empty? && a2.empty?
c_val = (a1 + a2).min
merged_array.push(c_val)
a1.include?(c_val) ? a1.shift : a2.shift
end
merged_array
end
a = [1, 5, 9]
p a[0].object_id
b = [2, 6, 8]
p merge(a, b)
p a[0].object_id
p a
p ... | true |
e0c39c82f20cf5edd8016dae8c34eb56291ff125 | Ruby | pradyotd/practice_programming | /CodeEval/ruby/delta_time.rb | UTF-8 | 537 | 3.296875 | 3 | [] | no_license | #\d{2}:\d{2}:\d{2}
time_str = "14:01:57"
def time_from_str(time_str)
match_grp = /(\d{2}):(\d{2}):(\d{2})/.match(time_str)
if match_grp then
ret = match_grp[1].to_i * 60 * 60 +
match_grp[2].to_i * 60 +
match_grp[3].to_i
return ret
end
end
def diff_time(time1, time2)
d = (time1 - time2).abs
mins, secs ... | true |
2dcd1c7a6eb435fbf3b8980f5a149b1c98e2deb3 | Ruby | camtheman256/lesson1 | /spec/models/sort_spec.rb | UTF-8 | 208 | 2.59375 | 3 | [] | no_license | require 'spec_helper'
describe Sort do
it 'should sort an array' do
correct = [1,2,3,4,5,6,7,8]
sort = Sort.new
result = sort.bubble(correct.shuffle)
result.should == correct
end
end | true |
091040f7db2d0d73990fd86bf2c034092cdab875 | Ruby | garagelab/boletin-sociedades | /lib/sociedad.rb | UTF-8 | 1,769 | 3.078125 | 3 | [] | no_license | # encoding: UTF-8
require_relative "core_ext"
require_relative "palabra"
require_relative "persona"
class Sociedad
attr_accessor :razon_social
attr_accessor :tipo_social
attr_accessor :fecha_aparicion
attr_accessor :text
STOPWORDS = %w(de la)
PREFIXES = %w(Abogado Presidente Escribano)
MAX_DISTANCE = 5
... | true |
96b78781d60348fc8dade5a21977383d8f8ed949 | Ruby | ayva/assignment_data_structures | /stack.rb | UTF-8 | 497 | 3.625 | 4 | [] | no_license | class Stack
attr_reader :arr
def initialize
@arr=[]
end
def push(el)
@arr[@arr.length]=el
end
def pop
@arr=@arr[0..@arr.length-2]
end
def peak
@arr[@arr.length-1]
end
def empty?
@arr[0] == nil
end
def size
i=0
until @arr[i]==nil
i+=1
end
i
end
... | true |
0cec76e52d3b37a32ebc40c50293a54734b5cf11 | Ruby | MislavGunawardena/Back-End-Lesson01 | /excercises/small_problems/easy8/8_double_char2.rb | UTF-8 | 550 | 3.6875 | 4 | [] | no_license | def consonant?(chr)
!!chr.match(/[a-z]/i) && !!chr.match(/[^aeiou]/i)
end
def double_consonants(string)
doubled_consonant_string = ''
string.each_char do |chr|
if consonant?(chr)
doubled_consonant_string << chr << chr
else
doubled_consonant_string << chr
end
end
doubled_consonant_s... | true |
cba3d462cf152aba602357446a6c0fd109afad29 | Ruby | bisraeli/sinatra-to-do-homework | /main.rb | UTF-8 | 1,904 | 2.875 | 3 | [] | no_license | require 'pry'
#for debugging
require 'sinatra'
#sinatra is the code-glue that link ruby to html
require 'pg'
#gem
require 'sinatra/reloader' if development?
#if development is optional? :means what
# index
get '/' do
#this prints to sinatra's server
puts "LET'S TAKE A LOOK AT WHAT YOU HAVE TO DO!"
erb :todos... | true |
e886f8c29012a1ec49fe87636a5b2c8d470170c4 | Ruby | Colt/hogwarts | /app/controllers/students_controller.rb | UTF-8 | 511 | 2.6875 | 3 | [] | no_license | class StudentsController < ApplicationController
def index
@students = Student.all
end
def show
@student = Student.find(params[:id])
end
def new
@student = Student.new
end
def create
# Create new student
@student = Student.create(params[:student])
# add student to result of sort... | true |
ede3a57a18a5574500b4b9f32f942e4959984e36 | Ruby | lilbitner/programming-univbasics-4-array-concept-review-lab-denver-web-010620 | /lib/array_methods.rb | UTF-8 | 314 | 3.1875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
while array[counter] do
puts array.index[(array[counter])]
counter +=1
end
def find_max_value(array)
while array[counter] do
puts array.max
counter +=1
end
def find_min_value(array)
while array[counter] do
puts array.min
counter +=1
end
| true |
643cafa00273c6bb75ca2ca3ba3353ba9d4583df | Ruby | RichardReed/RetirementCalc | /spec/AgeYear_spec.rb | UTF-8 | 1,870 | 2.78125 | 3 | [] | no_license | require_relative 'spec_helper'
module AgeYear
describe "is_age," do
describe "converts birth_year to age," do
context "with birth year of 1960," do
before (:each) do
config_file = ConfigFile.new
config_file.set_config_override ({ "birth_year" => 1960 })
config_file.con... | true |
f1ee7f34194253e4615a985a550badc81d6f4702 | Ruby | beersheep/PRS_Game | /PRS_game.rb | UTF-8 | 1,243 | 4.15625 | 4 | [] | no_license | require 'pry'
CHOICES = {'p' => 'Paper', 'r' => 'Rock', 's' => 'Scissors'}
def display_welcome_message
puts "=> Welcome to the Paper, Rock, Scissors Game!"
end
def print_choice(who, move)
case move
when "p"
puts "=>#{who} chose Paper!"
when "r"
puts "=>#{who} chose Rock!"
when "s"
puts "=>#{wh... | true |
f1827dea17e78d6dd75e61e2a792a28523619d12 | Ruby | avondohren/AoC_2016 | /Day3.rb | UTF-8 | 760 | 3.6875 | 4 | [] | no_license | def check(a,b,c)
return false if (a + b) <= c
return false if (a + c) <= b
return false if (b + c) <= a
true
end
def main(question)
file = File.new("/Users/andy/Sites/AoC_2016/input/Day3.txt", "r")
lines = []
while (line = file.gets)
lines << line
end
file.close
data = lines.map { |i| i.split.collect! {... | true |
53da0d22f4ffc07fc597af49caef5c7b15adf4c4 | Ruby | a-G-a-o/RB101 | /small_problems/easy_8/4.rb | UTF-8 | 3,161 | 4.46875 | 4 | [] | no_license | =begin
Write a method that returns a list of all substrings of a string that are palindromic.
That is, each substring must consist of the same sequence of characters forwards as it does backwards.
The return value should be arranged in the same sequence as the substrings appear in the string.
Duplicate palindr... | true |
eadaced7824d2c2c1e5c236342b52e938fb4ad9b | Ruby | kw-8/aa_classwork | /week 5/D1/hash_map_and_lru_cache/lib/p01_int_set.rb | UTF-8 | 1,962 | 3.703125 | 4 | [] | no_license | class MaxIntSet
attr_reader :store
def initialize(max)
@max = max
@store = Array.new(max) {false}
end
def insert(num)
raise "Out of bounds" if num < 0 || num > @max - 1
@store[num] = true
end
def remove(num)
raise "Out of bounds" unless is_valid?(num)
@store[num] = false
end
d... | true |
94ba57e530110096e1327d1b2b9730ba9a251c9f | Ruby | zachholcomb/futbol | /lib/league_stat.rb | UTF-8 | 1,928 | 2.8125 | 3 | [] | no_license | require_relative 'stat'
class LeagueStat < Stat
def initialize(game_collection, team_collection, game_team_collection)
super(game_collection, team_collection, game_team_collection)
end
def count_of_teams
stats_by_team.keys.size
end
def best_offense
stats_by_team.max_by { |team_id| team_id... | true |
081a3bdc86583b2f32c78c5cc00ac7094abe7bc3 | Ruby | cyr-kov/ruby_school | /l5/l5appa.rb | UTF-8 | 86 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | s1="-\\|/"
100000.times do |c1|
500.downto(1) {|c2| print "#{s1[(c1%4)]}\r"}
end | true |
6269082e239249021c16a05beadda1fd0ac877b1 | Ruby | bugcrowd/open_api_parser | /lib/open_api_parser/specification/root.rb | UTF-8 | 1,216 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module OpenApiParser
module Specification
class Root
attr_reader :raw
def initialize(raw)
@raw = raw
end
def endpoint(path, request_method)
uri = URI.parse(path)
requested_path = uri.path.gsub(/\..+\z/, '')
matching_path_det... | true |
9d57e5247fed3c29f30b264d4ad2cdbf9c7d8f28 | Ruby | pitr-ch/isy-playground | /chat/chat/model/room.rb | UTF-8 | 801 | 2.625 | 3 | [
"MIT"
] | permissive | module Chat
module Model
class Room
include Hammer::Core::Observable
observable_events :message
attr_reader :messages
attr_accessor :name
def initialize(name = nil)
@name = name
@messages = []
end
def valid?
@name.present?
end
d... | true |
f31d6f192fb558413d95cfb3fe19bda661d4de03 | Ruby | terciodemelo/manageiq | /lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb | UTF-8 | 327 | 2.53125 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module MiqAeMethodService
class MiqAeServiceGenericObject < MiqAeServiceModelBase
private
def method_missing(method_name, *args)
object_send(method_name, *args)
end
def respond_to_missing?(method_name, include_private = false)
@object.respond_to?(method_name, include_private)
end
e... | true |
67c8b382871dbee9a12926a7fadeb74a214ed01d | Ruby | alveraboquet/inkcite | /lib/inkcite/uploader.rb | UTF-8 | 6,260 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'net/sftp'
require 'stringio'
module Inkcite
class Uploader
def self.upload email
times = []
Dir.glob(File.join(email.path, '*.{html,tsv,txt,yml}')).each do |file|
times << File.mtime(file).to_i
end
local_images = email.image_dir
if File.exist?(local_images)
... | true |
79fdf8c64f08fd1b114aa470b5ea49f4c264bfeb | Ruby | vikashvikram/algorithms_in_ruby | /assignment/bfs_shortest_distance.rb | UTF-8 | 669 | 3.09375 | 3 | [] | no_license | require_relative "./list_graph"
VERTEX_COUNT = 200
INPUT_FILE = 'kargerMinCut.txt'
graph = UndirectedGraph.new(VERTEX_COUNT)
input = File.readlines(INPUT_FILE)
input.each do |each_vertex|
line = each_vertex.chomp.split("\t").map(&:to_i)
node1 = graph.vertex(line.shift)
line.each do |label|
node2 = graph.vertex(lab... | true |
456f6fccdc1c287ba02f458701d1f7f84844b4f9 | Ruby | camertron/nfs-rb | /lib/nfs/server.rb | UTF-8 | 713 | 2.53125 | 3 | [
"MIT"
] | permissive | module NFS
class Server
attr_reader :dir, :host, :port, :protocol
def initialize(dir:, host:, port:, protocol:)
@dir = dir
@host = host
@port = port
@protocol = protocol
@handler = Handler.new(FileProxy.new(dir))
@server = server_class.new(@handler.programs, port, host)
... | true |
0f3ac9eacad050ca2473e7b3dd35a78b3539047e | Ruby | aparra/playing-ruby | /regex/regex.rb | UTF-8 | 69 | 2.65625 | 3 | [] | no_license | puts /rio/ =~ "sao paulo"
puts /rio/ =~ "rio de janeiro e sao paulo"
| true |
8d2b60ef13b22a35b961dc5c04037443369b884c | Ruby | sajg1/wk1_weekend_homework | /pet_shop.rb | UTF-8 | 2,025 | 3.515625 | 4 | [] | no_license | def pet_shop_name(shop_name)
return shop_name[:name]
end
def total_cash(cash)
return cash[:admin][:total_cash]
end
def add_or_remove_cash(pet_shop, deposit)
pet_shop[:admin][:total_cash] += deposit
return pet_shop
end
def pets_sold(pet_shop)
return pet_shop[:admin][:pets_sold]
end
def increase_pets_sold(p... | true |
59a020cda4c23841f5803d7c28f8970db6905823 | Ruby | phamonyut/learn_ruby | /part_1/array_1.rb | UTF-8 | 250 | 3.390625 | 3 | [] | no_license | arr1 = [1,200,'a']
arr2 = [1,200,'a']
p arr1 == arr2
arr = [2,1.3,44,0.5]
p arr.sort
p [10, 20, 30].map { |i| (i*0.1)+i }
p ['b', 'c', 'j'].map { |i| i + 'ox' }
arr = [10, 20, 30]
arr.each_with_index do |a, i|
arr[i] = (a * 0.1) + a
end
p arr
| true |
43651106d5895f00cddd523415041e4381019da6 | Ruby | KristinS16/TechTalent | /Ruby_basics/product.rb | UTF-8 | 179 | 3.09375 | 3 | [] | no_license | class Product
def initialize(sku, item_name, price, quantity)
@sku = sku
@item_name = item_name
@price = price
@quantity = quantity
end
end
my_product = Product.new() | true |
15d1779dcce9bd157b084f656a5a2e3a3009be9a | Ruby | Reasoning123/471 | /Lab1_Cardenuto/a.rb | UTF-8 | 67 | 2.828125 | 3 | [] | no_license | #!/usr/bin/ruby
prod = 1
1.upto(5){|n| prod = prod *n}
puts prod
| true |
470130aedc5621c65629bad22c8bca11c42edcca | Ruby | click2cloud-admin/mjs | /lib/mjs/java_script_context.rb | UTF-8 | 18,551 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'mjs/utils'
#
# This file is almost derived from prototype_helper.rb of RoR
#
module Mjs
class JavaScriptContext #:nodoc:
######################################################################
### define :each method for Rack::Response
### because Merb::Rack::StreamWrappe... | true |
fcb40d6126c16fc4496fa224f6d7920883aaed9a | Ruby | omundu/sinatra_template | /models/greeter.rb | UTF-8 | 164 | 3.703125 | 4 | [] | no_license | class Greeter
def initialize(name = "World")
@name = name
end
def hello
"Hello, #{@name}!"
end
def goodbye
"Goodbye, #{@name}!"
end
end
| true |
d4c8a2f0c385b48e546a6f841adeff9df34446f1 | Ruby | nettan20/dm-tokyo-cabinet-adapter | /spike/test1.rb | UTF-8 | 2,584 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'tokyocabinet'
include TokyoCabinet
`rm data/*db`
data = "data/"
User = Struct.new(:name, :age)
tom = [1, User.new('Tom', 33)]
peter = [2, User.new('Peter', 34)]
Post = Struct.new(:title, :user_id)
post1 = [3, Post.new('Good Morning', tom[0])]
post2 = [4, Post.new('Good Evening', peter[0])]
post3 = [5, Pos... | true |
17385ee5e249e1249c56ec6bcb8dcccb35338b35 | Ruby | atzkey/rubyflow | /main.rb | UTF-8 | 2,108 | 2.65625 | 3 | [] | no_license | require 'pry'
require 'matrix'
require 'rubyflow'
require 'test/unit/assertions'
include Test::Unit::Assertions
def assert_almost_equal(x, y, epsilon = 1e-5)
assert (x - y).all? { |x| x.abs < epsilon }
end
def test_basic
w, x, y, z = Input.new, Input.new, Input.new, Input.new
f = Mul.new(Add.new(w, x, y), x,... | true |
672f06685a5ad7f67d8fe6078cad32b884019414 | Ruby | johno/iz | /lib/iz/mac.rb | UTF-8 | 386 | 2.90625 | 3 | [
"MIT"
] | permissive | module Iz
class Mac
REGEX = /^(([0-9A-Fa-f]{2}[:\.-]){5}([0-9A-Fa-f]{2}))|([0-9A-Fa-f]{12})|(([0-9A-Fa-f]{4}[:\.-]){2}([0-9A-Fa-f]{4}))$/
attr_accessor :value
def initialize(mac)
self.value = mac
end
def valid?
!!Iz::Mac.is_mac?(value)
end
def self.is_mac?(value)
retu... | true |
b702133ccb2e7290cc1fe115af64d18b907f33b2 | Ruby | rterrabh/rdf | /dataset/rails/activerecord/lib/active_record/type/mutable.rb | UTF-8 | 315 | 2.515625 | 3 | [
"MIT",
"Ruby"
] | permissive | module ActiveRecord
module Type
module Mutable # :nodoc:
def type_cast_from_user(value)
type_cast_from_database(type_cast_for_database(value))
end
def changed_in_place?(raw_old_value, new_value)
raw_old_value != type_cast_for_database(new_value)
end
end
end
end
| true |
fe72fa7543f0a1957ec50c142b69d18038585615 | Ruby | okhlybov/finita | /lib/finita/equation.rb | UTF-8 | 3,734 | 2.640625 | 3 | [] | no_license | require "symbolic"
require "finita/common"
require "finita/symbolic"
require "finita/domain"
module Finita
class Decomposition < Hash
def initialize(expression, unknowns)
super()
@expression = expression
@unknowns = unknowns
decompose
end
def linear?; @linear end
private
... | true |
0451ee6ffa524c45ba03c6b36315b6f2875d9a83 | Ruby | chiakimz/week1_BorisBikes | /week1_BorisBikes/spec/DokingStation_spec.rb | UTF-8 | 682 | 2.96875 | 3 | [] | no_license | require "docking_station_class"
require "bike_class"
describe DockingStation do
#it { is_expected.to respond_to "release_bike" }
describe "#release_bike" do
it "releases docked bikes" do
#bike = Bike.new
# subject.dock(bike)
# expect(subject.bike).to eq bike
expect { subject.release_bike }.to rais... | true |
f7c95d52baa644380022aff0d7d0b17dbb18467e | Ruby | msmukherji/triangletest | /Class/dog_objects/dog.rb | UTF-8 | 943 | 3.734375 | 4 | [] | no_license | require 'minitest/autorun'
class Dog
def initialize name, person_who_owns=nil
# (default nil specified for person_who_owns if they don't have an owner; if nothing is passed in here, it gets nil)
@name = name
# @owner = "james"
# ^^this would make every dog's owner james=>
@owner = person_who_owns
# @hap... | true |
01ab281b7fd41de8c3aea7b67c32e7226ee7cbaa | Ruby | darrenhaken/admix | /lib/admix/utils/backfill_date_calculator.rb | UTF-8 | 686 | 3.484375 | 3 | [
"MIT"
] | permissive | require 'date'
require 'holidays'
class BackfillDateCalculator
DATE_FORMAT = "%d/%m/%Y"
def initialize(start_date, end_date)
@start_date = Date.parse(start_date, DATE_FORMAT)
@end_date = Date.parse(end_date, DATE_FORMAT)
end
def dates_excluding_weekends_and_holidays
days_in_range = (@start_date ... | true |
5cfd9923ac8be254d9b9b9841ec02362b10d5dba | Ruby | hitoshi-w/codewars | /4kyu/smallest_possible_sum.rb | UTF-8 | 1,658 | 4.125 | 4 | [] | no_license | # Description
# Given an array X of positive integers, its elements are to be transformed by running the following operation on them as many times as required:
#
# if X[i] > X[j] then X[i] = X[i] - X[j]
#
# When no more transformations are possible, return its sum ("smallest possible sum").
#
# For instance, the succes... | true |
ace7ebe06f45e56766ead32494023f5936a8dece | Ruby | xsimov/ToDo-in-Sinatra | /lib/todo.rb | UTF-8 | 667 | 2.875 | 3 | [] | no_license | require 'pry'
require 'sinatra'
require 'pstore'
class ToDo
attr_accessor :task
def initialize(item)
@task = item
add(self)
end
def add(tdObject)
storeFile.transaction do
storeFile[:superList] << tdObject
end
end
def self.delete(item)
storeFile.transaction do
storeFile[:superList... | true |
12bfaccc8b79f8a40ffd912f4003652d26962d44 | Ruby | marcindrozd/oo_blackjack | /blackjack.rb | UTF-8 | 4,553 | 4.03125 | 4 | [] | no_license | # Object Oriented Blackjack
class Deck
attr_reader :deck
VALUES = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
SUITS = ["D", "H", "C", "S"]
def initialize
@deck = []
VALUES.each do |value|
SUITS.each do |suit|
@deck << Card.new(value, suit)
end
end
@d... | true |
65f5eb0236da141a128f1096d6920b475c83de87 | Ruby | lor104/crm-assignment | /contact.rb | UTF-8 | 3,362 | 3.65625 | 4 | [] | no_license | class Contact
attr_reader :id
attr_accessor :first_name, :last_name, :email, :note, :full_name
@@contacts = []
@@id = 1
# This method should initialize the contact's attributes
def initialize(first_name, last_name, email, note='N/A')
@first_name = first_name
@last_name = last_name
@email = em... | true |
4d399ae6e52844be5e500fcab4d193380705f424 | Ruby | aziobrow/battleship2 | /test/coordinates_test.rb | UTF-8 | 4,379 | 3.140625 | 3 | [] | no_license | require_relative 'test_helper'
require './lib/game_board'
require './lib/coordinates'
class CoordinatesTest < Minitest::Test
def test_it_initializes_with_coordinates_and_a_game_board
coordinates = Coordinates.new(['C3', 'C4'])
assert_instance_of Coordinates, coordinates
assert_equal ['C3', 'C4'], coord... | true |
ce37703408a32b4737178dfc393a695513aa66c9 | Ruby | uralteszinn/MyConfig | /scripts/playlistGenerator | UTF-8 | 1,441 | 3.0625 | 3 | [] | no_license | #!/bin/ruby
# Just run 'playlistGenerator' in the shell!
# Path to directories contain the last slash!
def getHomeDir
`echo $HOME`.chomp + "/"
end
def getMusicLibraryDir
res = ""
str = `cat "#{getHomeDir}.mpd/mpd.conf" | grep music_directory`
str.each_line do |line|
if line =~ /^\s*music_directory\s+[^\... | true |
f41967ce83afddc288ab0844a7ffac86ccc36531 | Ruby | victorsu/box | /updateFolder.rb | UTF-8 | 800 | 2.59375 | 3 | [] | no_license | require "rest-client"
require "json"
folder_name = 'vsu_test_folder2'
body = {
"name" => folder_name,
"parent" => {
"id" => "0"
}
}
response = RestClient.post(
"https://api.box.com/2.0/folders",
JSON.generate(body),
{:authorization => "Bearer " << "vuHZfrznM2vxd7wGUHEpe88FX4pQE... | true |
3824a206d1b2e5bbace82026c2d0ed5b4733dc7b | Ruby | telegraham/OO-mini-project-world-cup | /app/models/Player.rb | UTF-8 | 264 | 3.25 | 3 | [] | no_license | class Player
attr_reader :name, :team
def initialize(name, team)
@name = name
@team = team
end
ALL = []
def self.all
ALL
end
def matches_played
Match.all.select do |match|
match.teams.include?(self.team)
end
end
end
| true |
c3b068f0c3e04f008016d4f663f4b7c7f4889782 | Ruby | huangw/dev_flow-gem | /lib/dev_flow/command/base.rb | UTF-8 | 1,870 | 2.59375 | 3 | [
"MIT"
] | permissive | require_relative '../helpers'
# Develop Flow Management Tool Based on Git
module DevFlow
# Name space for command handlers
module Command
# Common operations for all command
class Base
include DevFlow::Helpers
include DevFlow::GitConfig
attr_reader :args, :options, :dir, :git
# Re... | true |
d340456851f7de9d9a6738caf2f515aff05ea45c | Ruby | doug7410/punch-clock | /app/helpers/application_helper.rb | UTF-8 | 908 | 2.515625 | 3 | [] | no_license | module ApplicationHelper
def format_datetime(dt)
if dt
dt.strftime("%l:%M:%S%p %Z on %B %d, %Y")
end
end
def punch_in_date(punch_created_at)
punch_created_at.strftime("%B %d, %Y")
end
def punch_in_time(punch_created_at)
punch_created_at.strftime("%l:%M:%S%p")
end
def punch_out_... | true |
67ee714e32705d3e2670daf5e6d6e2c0c4ea6c3a | Ruby | dhserver/desafios | /ciclos_y_metodos/pares.rb | UTF-8 | 91 | 2.984375 | 3 | [] | no_license | a = ARGV[0].to_i
i = 0
suma = 0
while i < a
i += 2
suma += i
end
puts suma | true |
4e5ed2f8138986f86e52f9c1220ff7d8e19061d3 | Ruby | genometools/genometools | /testdata/gtruby/style_serialize.rb | UTF-8 | 1,139 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"BSD-2-Clause",
"LicenseRef-scancode-mit-old-style",
"Zlib",
"MIT",
"BSD-3-Clause",
"bzip2-1.0.6"
] | permissive | #
# Copyright (c) 2010 Sascha Steinbiss <steinbiss@zbh.uni-hamburg.de>
# Copyright (c) 2010 Center for Bioinformatics, University of Hamburg
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this perm... | true |
7d895d9eacb6366058d89f17bd83c74702b1b08d | Ruby | gkillick/mylog | /app/helpers/athletes_helper.rb | UTF-8 | 772 | 2.71875 | 3 | [] | no_license | module AthletesHelper
def format_hhmm(hours)
minutes = (hours * 60).to_i
"%d:%.2d" % [minutes / 60, minutes % 60]
end
def plot_hours_graph(athlete)
data = []
x_axis_labels = []
7.downto(0) do |number|
data << athlete.log_entries.total_hours_for(number.days.ago)
x_axis_labels << ... | true |
204743577a0a17f3abca61ce68775c89d778aac3 | Ruby | try4code/workout-problems | /reverse.rb | UTF-8 | 216 | 4.03125 | 4 | [] | no_license | #Reverse a String
def reverse(string)
rev,i="",0
while i < string.length
rev = string[i] + rev
i += 1
end
rev
end
puts "enter string to reverse"
a = gets.chomp
puts "reverse string is --- \"#{reverse(a)}\" " | true |
16ad3ef5159512700179584b6fc997db173bb8c1 | Ruby | calopez/Ruby-Learning | /proc_class/procs_and_blocks.rb | UTF-8 | 2,457 | 4.28125 | 4 | [] | no_license | # Procs and blocks and how they differ
[1,2,3].each { |x| puts x * 10 }
# A method can capture a block, objectified into a proc,
# using the special parame- ter syntax:
def call_a_block(&block)
block.call
end
call_a_block { puts "I'm the block ... or Proc .. or something.." }
# But it’s also possible for a proc... | true |
9bff8e09acc676a8862fbad08a227fa77872d718 | Ruby | skiz/rss_reader | /lib/rss_reader/entry.rb | UTF-8 | 328 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module RssReader
class Entry
attr_accessor :elements
def initialize(attrs={})
@elements = attrs
@elements.each_key do |method_name|
(class << self; self; end).class_eval do
define_method method_name do
@elements[method_name]
end
end
end
end
... | true |
249f295256525f4a201171fa78daad187bdaf19c | Ruby | KeisukeMurata4210/Object-Oriented_Design_in_Ruby | /1st_time/chapter_9/codes/3-1.rb | UTF-8 | 993 | 3.234375 | 3 | [] | no_license | # ダックタイプを使う前
class Mechanic
def prepare_bicycle(bicycle)
# ...
end
end
class TripCoordinator
def buy_food(customers)
# ...
end
end
class Driver
def gas_up(vehicle)
# ...
end
def fill_water_tank(vehicle)
# ...
end
end
class Trip
attr_reader :bicycle, :customers, :vehicle
def prep... | true |
ab6db5d1584cd8cec933ffe0632e90a93bca481c | Ruby | lentg/huanarle | /lib/easy_executer/do_it_times.rb | UTF-8 | 873 | 2.671875 | 3 | [] | no_license | # coding: utf-8
module EasyExecuter
module DoItTimes
extend ActiveSupport::Concern
included do
end
private
def do_it_once(task_title, &block)
unless Executer.executed_once_a_day_task?(task_title)
Executer.create_once_a_day_task(task_title)
yield
end
end
def ... | true |
70c143e2b904e7786aff0021e28c88d42dc0b741 | Ruby | BC-MAY-21-ROR/kata-02-el-juego-de-la-vida-dia-04-k02-t02-d04 | /src/cell.rb | UTF-8 | 394 | 3.421875 | 3 | [] | no_license | # frozen_string_literal: true
class Cell
attr_accessor :position, :alive_neighbours, :state
def initialize(state, position, alive_neighbours: 0)
@state = state
@position = position
@alive_neighbours = alive_neighbours
end
def live!
@state = :alive
end
def die!
@state = :dead
end
... | true |
c1677e05bb5214f1b23d744de2339c12e3852505 | Ruby | copiousfreetime/keybox | /spec/kpg_app_spec.rb | UTF-8 | 4,049 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'keybox/application/password_generator'
describe "Keybox Password Generator Application" do
it "nil argv does nothing" do
kpg = Keybox::Application::PasswordGenerator.new(nil)
kpg.error_message.must_be_nil
end
it "invalid options set the error message, exit 1 and have outp... | true |
f936875071b230c6fc9163e2e43c5e98b5ee08f1 | Ruby | deiga/SaaS | /Homework 1/part3.rb | UTF-8 | 316 | 3.40625 | 3 | [] | no_license | def combine_anagrams(words)
anagrams = Hash.new
words.each do |word|
anagram_key = word.downcase.chars.sort.join
anagrams[anagram_key] ||= Array.new
anagrams[anagram_key] << word
end
anagrams.values
end
puts combine_anagrams(['cars', 'for', 'potatoes', 'racs', 'four', 'scar', 'creams', 'scream']).inspect | true |
6fa274d7da9673d88e53d23aaa9ea96c4cd2ea34 | Ruby | jjingob/recalls | /lib/recalls.rb | UTF-8 | 1,508 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require ::File.expand_path('../recalls/version', __FILE__)
require ::File.expand_path('../recalls/configuration.rb', __FILE__)
require ::File.expand_path('../recalls/client', __FILE__)
module Recalls
extend Configuration
# Alias for Recalls::Client.new
#
# @return [Recalls::Client]
def self.client(options={... | true |
96d279e30b8e94f0586ae2b9cac9608ac1e45111 | Ruby | ealwafai/mastermind | /lib/messages.rb | UTF-8 | 3,439 | 3.6875 | 4 | [] | no_license | class Messages
def welcome_message
puts "\nWelcome to MASTERMIND \n\nWould you like to (p)lay, read the (i)nstructions, or (q)uit?\n"
end
def instructions_message
file = File.open("./data/instructions.txt")
instructions = file.read
puts instructions
file.close
end
def restart_message
... | true |
a286fe12d52b91e5cd27923ca52cfe131540f622 | Ruby | hermetique/Duck-language | /spec/lists/messages/push_message_spec.rb | UTF-8 | 1,090 | 2.890625 | 3 | [] | no_license | #encoding: utf-8
require_relative '../../spec_helper'
describe "List" do
describe "the :push message for Lists" do
it "should be something a List recognizes" do
List.recognized_messages.should include(:push)
end
it "should produce a closure looking for another List" do
grabby = List.new.push... | true |
8f7c3aa6d5122b163ffc4f4566cba98279b3a091 | Ruby | bc-nogueira/ez-estagios | /db/seeds.rb | UTF-8 | 6,941 | 2.625 | 3 | [] | no_license | # Cria empresas novas em diferentes estados de validações, com suas contas
sti = Empresa.new({ nome: 'STI', cnpj: '87.854.813', endereco: 'Valonguinho' })
Account.create({ email: 'sti@gmail.com', password: '123456', perfil: sti })
uff = Empresa.new({ nome: 'UFF', cnpj: '12.442.268', endereco: 'Reitoria',
... | true |
765017ad72db2ddfdecc3355a87307a0f5a6f2f0 | Ruby | BBQlettuce/chess | /chess/steppingpiece.rb | UTF-8 | 777 | 3.375 | 3 | [] | no_license | require_relative 'piece'
class SteppingPiece < Piece
KNIGHT_STEPS = [
[-1, -2], [-1, 2], [1, -2], [1, 2],
[-2, -1], [-2, 1], [2, -1], [2, 1]]
KING_STEPS =
[[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
def moves(board)
moves = []
move_dirs.each do |(x,y)|
new_x... | true |
c84403bf49a3db184967e39e3647f3685bf63cfa | Ruby | ckagana/LaunchAcademy-Challenges | /smart-vending-machine/test.rb | UTF-8 | 42 | 2.875 | 3 | [] | no_license | num = gets.chomp
puts num.index('1').nil? | true |
fb17946b0c4b797987de0a0630a34999a7e87f85 | Ruby | mikez321/flash_cards | /flashcard_runner.rb | UTF-8 | 571 | 3.359375 | 3 | [] | no_license | require './lib/card'
require './lib/deck'
require './lib/round'
require './lib/turn'
require './lib/card_generator'
card1 = Card.new("What is larger? A llama or an alpaca? ", "Llama", :Animals)
card2 = Card.new("Who paints happy trees?", "Bob Ross", :Pop_Culture)
card3 = Card.new("How many chains are in a furlong?", ... | true |
4557c61099b40171ee0110bcd8de6eb58dd45b96 | Ruby | h-z/aoc2020 | /day1.rb | UTF-8 | 230 | 3.125 | 3 | [] | no_license | file = File.open("input1.txt")
xs = file.readlines.map(&:chomp).map(&:to_i)
x = xs.combination(2).select {|x| x.sum == 2020 }.first
puts x.first*x.last
x = xs.combination(3).select {|x| x.sum == 2020 }.first
puts x[0]*x[1]*x[2]
| true |
34968eecc52f8790d236d79241017335fcedc1c7 | Ruby | jamiepg1/segmentations | /BOM/internal/inventory/url_splitter.rb | UTF-8 | 594 | 2.796875 | 3 | [] | no_license | #!/usr/bin/ruby
#~ require 'uri'
#~ require 'domainatrix'
#~ require 'fileutils'
#~
#~ class URLSplitter
#~
#~ def parse(url)
#~ url = url.chomp.strip.chomp("/")
#~
#~ uri = Domainatrix.parse(url)
#~
#~ filename = (url.gsub("https://","").gsub("http://","").gsub("/","_").gsub("?","_").gsub(":","").gsub("__","_"... | true |
3c24209aa11b8d74975b47fdb8e37a68b2698262 | Ruby | tkahng/SpeckleRuby | /speckle_ruby_core/speckle_stream.rb | UTF-8 | 2,169 | 2.625 | 3 | [
"MIT"
] | permissive | class SpeckleStream < ResourceBase
attr_accessor :streamId # "string",
attr_accessor :name # "string",
attr_accessor :objects # [],
attr_accessor :layers # [],
attr_accessor :baseProperties # {},
attr_accessor :globalMeasures # {},
attr_accessor :isComputedResult # false,
attr_accessor :viewerLayers # [... | true |
dde395f69948ea96ef31e62e16d22da3702503a5 | Ruby | tonywok/realms | /lib/realms/cards/card.rb | UTF-8 | 3,265 | 2.625 | 3 | [
"MIT"
] | permissive | require "equalizer"
module Realms
module Cards
class Card
include Dsl
include Brainguy::Observable
module Factions
ALL = [
BLOB = :blob,
TRADE_FEDERATION = :trade_federation,
MACHINE_CULT = :machine_cult,
STAR_ALLIANCE = :star_alliance,
]... | true |
34782886ff21f832fda352ef3f4c08f05ec30725 | Ruby | DavidBates/adventofcode1-1 | /day1_1.rb | UTF-8 | 1,309 | 3.28125 | 3 | [] | no_license | def turn_left cur_direction
case cur_direction
when 0
return 270
when 90
return 0
when 180
return 90
when 270
return 180
end
end
def turn_right cur_direction
case cur_direction
when 0
return 90
when 90
return 180
when 180
return 270
when 27... | true |
e52ab0934989cc8b91ede1b7d04e20735e99d6dd | Ruby | eZii-jester-data/brainz | /examples/sign.rb | UTF-8 | 834 | 3.640625 | 4 | [
"MIT"
] | permissive | require 'brainz'
# SIGN function
brainz = Brainz::Brainz.new
brainz.teach do |iteration, error|
that(1).is(1)
that(10).is(1)
that(90).is(1)
that(-1).is(-1)
that(-20).is(-1)
that(-4).is(-1)
that(0).is(0)
p "error_rate = #{'%.3f' % error || 0 } after #{iteration} iterations"
end
(-100..100).each do |t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.