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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9efe0661ac26fb4cc9f63235b7b3a497400eeb15 | Ruby | lambyy/projects | /week2/w2d4/anagram.rb | UTF-8 | 1,238 | 3.5625 | 4 | [] | no_license | require 'byebug'
#time complexity O(n!)
def first_anagram?(string, match_string)
string_perms = string.chars.permutation(string.length).to_a
string_perms.include?(match_string.chars)
end
#time complexity O(n**2)
def second_anagram?(string, match_string)
# debugger
string_array = string.chars
match_array = m... | true |
d500a977dc3d65d432f4da73a63b08142add2c72 | Ruby | raphaelmro/saldo_ticket | /main.rb | UTF-8 | 819 | 2.84375 | 3 | [] | no_license | require 'rubygems'
require 'httparty'
require 'json'
require 'io/console'
require_relative 'utils.rb'
require 'colorize'
puts '** Consulta de saldo Ticket **'.red
puts 'Insira seu e-mail: '.yellow
email = gets.chomp
puts 'Insira sua senha: '.yellow
password = STDIN.noecho(&:gets).chomp
options = {:body =>
... | true |
5fbb2e32f959006c9d6f7f24458336cd4c71b53a | Ruby | domininik/codility | /07_lesson/nesting.rb | UTF-8 | 842 | 3.890625 | 4 | [
"MIT"
] | permissive | # https://codility.com/programmers/lessons/7-stacks_and_queues/nesting/
# Determine whether given string of parentheses is properly nested.
# Score: 100%
require 'test/unit'
class ParenthesesValidatorTest < Test::Unit::TestCase
def test_valid?
assert_equal(1, ParenthesesValidator.new.valid?('(()(())())'))
a... | true |
454ac7adfe62cd8a08f9ec27d4febcb7024855bc | Ruby | iamadalek/subroutine | /test/subroutine/base_test.rb | UTF-8 | 6,006 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
module Subroutine
class OpTest < TestCase
def test_simple_fields_definition
op = ::SignupOp.new
assert_equal [:email, :password], op._fields.keys.sort
end
def test_inherited_fields
op = ::AdminSignupOp.new
assert_equal [:email, :password, :priveleges], op._... | true |
8a3ab9e1c541c503b8535fe3723dabbfb94e23d5 | Ruby | vexorian/twitter-bot-template | /scheduler.rb | UTF-8 | 1,353 | 2.65625 | 3 | [] | no_license | require 'platform-api'
require_relative 'botconfig'
require_relative 'credentials'
heroku = PlatformAPI.connect_oauth(HEROKU_API_TOKEN)
current = heroku.formation.info(HEROKU_APP_NAME, HEROKU_PROCESS_TYPE)['quantity']
should = should_it_be_on()
mainten = heroku.app.info(HEROKU_APP_NAME)['maintenance']
if mainten
... | true |
9de1d08d0d0b03d163413d30fe403ddade89a601 | Ruby | demo-6th/Crawlers | /Dcard/get_post_content.rb | UTF-8 | 984 | 2.71875 | 3 | [] | no_license | def get_post_content(sleep_every, sleep_time)
table = CSV.parse(File.read("post_id.csv"), headers: false)
post_content = []
total_cut = 0
table.each do |line|
begin
if total_cut.modulo(sleep_every) == 0
sleep(sleep_time)
else
sleep(rand(0.5..1.2))
end
total_cut += 1
... | true |
26593d6b92abde0901094e86bf27e2ab607c3a0e | Ruby | chrabyrd/project_euler | /problem_3.rb | UTF-8 | 282 | 4.1875 | 4 | [] | no_license | # The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143?
def prime_factor(n, arr = [])
(2...n).each do |x|
arr << x if n % x == 0 && (2...x).all? { |i| x % i != 0 }
end
print arr[-1]
end
prime_factor(600851475143) | true |
90519a08bf26e1f21b4a3c56ea9eeb0c5273a3a4 | Ruby | tundeiness/coding_challenge | /hamming_weight.rb | UTF-8 | 189 | 3.34375 | 3 | [] | no_license | # @param {Integer} n, a positive integer
# @return {Integer}
def hamming_weight(n)
conv = n.to_s(2).split('')
count = 0
conv.each do |i|
count += 1 if i == '1'
end
count
end
| true |
c4ecf09cd0adc59e981749a4edbd577e17f2d279 | Ruby | pongsanti/mcotv3 | /lib/magick/convert.rb | UTF-8 | 1,071 | 2.6875 | 3 | [] | no_license | # convert op
class Convert
# convert ${FILE_PATH}/${IMG_NAME} -crop $CROP_GEO -colorspace gray -lat 10x10+5% -negate ${FILE_PATH}/${CROP_FILENAME}
def initialize(hash)
@file_suffix = hash[:suffix] || '_c'
@width = hash[:w] || 0
@height = hash[:h] || 0
@width_offset = hash[:wo] || 0
@height_offs... | true |
7a36ce3a29ae0db27799f1cb178319cc2b8b33a3 | Ruby | DavidChicharro/PDOO | /QytetetRuby/lib/especulador.rb | UTF-8 | 961 | 2.53125 | 3 | [] | no_license | # encoding: utf-8
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module ModeloQytetet
class Especulador < Jugador
attr_writer :fianza
def initialize(jugador, fianza)
... | true |
97644b2b4545e5959f1f01449e22888ad8965a00 | Ruby | rszumlakowski/pipgen | /ruby/spec/job_spec.rb | UTF-8 | 7,972 | 2.625 | 3 | [] | no_license | require 'spec_helper'
require 'support/factory_girl'
require 'job'
describe Job do
describe ".initialize" do
context "given an empty hash" do
it "returns an invalid job" do
expect{Job.new(EMPTY_JOB)}.to raise_error "Empty job definition"
end
end
context "given a job with just a name" do
befor... | true |
c17ffeaa631f5090567a4d09cf7d6c3c8bb7aa5c | Ruby | dnasko/biobin | /conversion/flaten_fasta.rb | UTF-8 | 1,640 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'getoptlong'
require 'parse_fasta'
## Copyright 2014 Daniel Nasko.
## License GPLv3+: GPU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
## This is free software: you are free to change and redistribute it.
## There is NO WARRENTY, to the extent permitted by law.
##
## Please a... | true |
9f0a40d9d3eb25c2868cfbeb4250e560bc257c31 | Ruby | induramesh/ruby-object-attributes-lab-bootcamp-prep-000 | /lib/dog.rb | UTF-8 | 195 | 3 | 3 | [] | no_license | class Dog
def name
@name
end
def name=(newname)
@name = newname
end
def breed
@breed
end
def breed=(geneticmutant)
@breed = geneticmutant
end
end | true |
fafe844d08405387124cbf2fbf2fbea5eb7f1095 | Ruby | tonycarballeira/excel_to_xml_converter | /helpers.rb | UTF-8 | 533 | 2.53125 | 3 | [] | no_license | module Helpers
def convert_excel(file_name)
@book = Spreadsheet.open('uploads/'+file_name)
@sheets = @book.worksheets
@rows = []
@sheets.each do |sheet|
sheet.each do |row|
@rows << row
end
end
@builder = Nokogiri::XML::Builder.new do |xml|
xml.root {
xml.records {
... | true |
a3c2a3d006959a64d84461256ddea17d28edbffc | Ruby | elanthia-online/daily_tasks | /play_net/rewards.rb | UTF-8 | 2,815 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "mechanize"
require_relative("./util/color.rb")
module Rewards
OUTCOMES = {
err: {color: :red, message: "✗ :error"},
claimed: {color: :green, message: "✓ :claimed"},
skip: {color: :pink, message: "✓ :skipped"},
}
def self.to_nokogiri(page)
Nokogiri::HTML(pag... | true |
e0ae81119af061414fc4528814602c7d0e191a4f | Ruby | Clem-svg/TicTacToe | /lib/app/game.rb | UTF-8 | 965 | 3.5625 | 4 | [] | no_license | # require 'colorize'
class Game
attr_accessor :player1, :player2
def initialize
puts ""
puts "*********************************************".colorize(:blue)
puts "* \u{1f349} *".colorize(:blue)
puts "* Bienvenue dans notre super Tic Tac Toe! *".colorize(:blue)
pu... | true |
6fb27e38aa1b84709343937b9edcbae15c5e30dc | Ruby | Codetig/QuoteQuiz | /tests/test_quote.rb | UTF-8 | 675 | 3.015625 | 3 | [] | no_license | require_relative '../quote'
require 'minitest/autorun'
class TestQuote < MiniTest::Test
def setup
@quote = Quote.new
end
def test_new_quote
refute_empty(@quote.get_quote, "There should be initial quotes.")
end
def test_identify_last_quote
cache = []
num = @quote.number_of_quotes
num.tim... | true |
a3b16c1b1e081fce9d2999e8a8adceadc928312c | Ruby | frankburke333/learn_ruby-1 | /00_hello/hello.rb | UTF-8 | 86 | 2.984375 | 3 | [] | no_license | def hello
return "Hello!"
end
def greet(greet)
return "Hello, #{greet}!"
end
| true |
4093814a556e595a2851b8bd625d15c29e33aa11 | Ruby | npentella/phase-0-tracks | /ruby/secret_agents.rb | UTF-8 | 1,648 | 4.15625 | 4 | [] | no_license | #ENCRYPT METHOD
def encrypt(password)
#Start index variable at 0
#While index is less than word length,
#advance corresponding letter one character, except `space`
index = 0
while index < password.length
if password[index] == "z"
password[index] = "a"
elsif password[index] != " "
password[index] ... | true |
d0b3be19b6dcdf6d95cfe8a0477c9dd0f05b7b2e | Ruby | newrelic/newrelic-ruby-agent | /lib/new_relic/agent/pipe_channel_manager.rb | UTF-8 | 8,879 | 2.703125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true
require 'base64'
module NewRelic
module Agent
#--
# Manages the registering and servicing of pipes used by child
# proce... | true |
49cc6d668e2950225f4d52dc9b9af2e739cfdccf | Ruby | andremedeiros/spyglass | /examples/window_events.rb | UTF-8 | 468 | 2.578125 | 3 | [
"MIT"
] | permissive | $LOAD_PATH.unshift('lib')
require 'spyglass'
include Spyglass
window = GUI::Window.new "Original"
card = Image.load File.expand_path('images/card.jpg', File.dirname(__FILE__))
window.on_click do |x, y|
puts "CLICKED: #{ x }, #{ y }"
end
window.on_double_click do |x, y|
puts "DOUBLE CLICKED: #{ x }, #{ y }"... | true |
2e2a0bf7e4ab4c92f8494298b54b9979d27fa6ce | Ruby | markglenfletcher/irwick | /lib/irwick/plugins/control_plugin.rb | UTF-8 | 1,021 | 2.625 | 3 | [
"MIT"
] | permissive | class ControlPlugin < IrcPlugin
def initialize(options = {})
@bot_name = options[:nick_name]
@bot_key = options[:command_key]
@owner = options[:owner]
end
def valid_command_message?(message)
control_command = control_command_breakdown(message)
if control_command &&
message_from_owner?(me... | true |
93de0345123a9086d71f22f17560301b11598aa5 | Ruby | Bodhisattva2-0/PrimeTable | /spec/lib/prime_generator_spec.rb | UTF-8 | 309 | 3.109375 | 3 | [] | no_license | require_relative '../../lib/prime_generator.rb'
require_relative '../../lib/sieve_of_eratosthenes.rb'
describe PrimeGenerator do
describe "primes" do
it "returns an array of primes" do
expect(PrimeGenerator.new(10, SieveOfEratosthenes).primes).to eq [2,3,5,7,11,13,17,19,23,29]
end
end
end
| true |
e643b2df3f33536da0194f27f4c1cf0d144d3998 | Ruby | instedd/mbuilder | /app/models/invalid_value_placeholder_solver.rb | UTF-8 | 312 | 2.515625 | 3 | [] | no_license | class InvalidValuePlaceholderSolver < PlaceholderSolver
def initialize(solver, invalid_value)
@solver = solver
@invalid_value = invalid_value
end
def piece_value(guid, trigger)
if guid == 'invalid_value'
@invalid_value
else
@solver.piece_value(guid, trigger)
end
end
end
| true |
921661932fedd30071c6222e7227ed5407430cb6 | Ruby | ECE485DDR3/FinalProject | /Ruby/MemControllerCPP.rb | UTF-8 | 10,922 | 2.53125 | 3 | [] | no_license | #!/usr/bin/ruby
class ParseCpuRequests
@request = Hash.new
$fileRequest = Array.new
$CpuClock = 0
$DRAMClock = 0
$count = 0
$CPUBuffer = Array.new
$goFetch = 1
$traceFile = Array.new
$prevCommands = Array.new
for i in 0..7
$prevCommands.push(Hash["ACT" => Float::INFINITY,
... | true |
31957b57a869b30f8fc2f58f1fc6e536a729075a | Ruby | AnthonyPAlicea/18xx | /lib/engine/game/g_1822_pnw/entities.rb | UTF-8 | 48,872 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # frozen_string_literal: true
module Engine
module Game
module G1822PNW
module Entities
COMPANIES = [
{
name: 'P1-The Olympian Hiawatha (5-Train)',
sym: 'P1',
value: 0,
revenue: 5,
desc: 'MAJOR, Phase 5. 5-Train. Once a company a... | true |
cb93cb751af9b6593528e64bc067377c4cf3aad9 | Ruby | tpham-netprotections/sa_course | /Shimaya/module_oriented/user_main.rb | UTF-8 | 909 | 3.296875 | 3 | [] | no_license | require('./data.rb')
require('./user_module.rb')
require('./authentication_module.rb')
@login == nil
# グローバル変数は定義したくない:モジュールの独立性の担保のため
def selection(input)
case input
when "1"
@members = User.signup(@members)
when "2"
@login = Authentication.login(@login)
when "3"
@login = Authentica... | true |
e7418216018d9a1c69b84ab18ee0e21250857c85 | Ruby | tim32503/5xruby | /0329/padding.rb | UTF-8 | 480 | 3.421875 | 3 | [] | no_license | def padding_zero(n, m = 6)
# 實作內容
# ----- 第一次解法 -----
# result = ""
# cnt = 1
# while cnt <= m - n.to_s.length
# result += "0"
# cnt += 1
# end
# return result + n.to_s
# ----- 第二次解法(查過method) -----
# n.to_s.rjust(m, "0")
"#{'0' * m}#{n}"[-m, m]
end
puts... | true |
1effce84d57b69b92b68b265c3427c72dbb9c757 | Ruby | arunrails20/Data-Structures-and-Algorithms-in-Ruby | /Sorting/BubbleSort.rb | UTF-8 | 872 | 4.375 | 4 | [] | no_license | def less(value1, value2)
return value1 < value2
end
def more(value1, value2)
return value1 > value2
end
def BubbleSort(array)
size = array.size
i = 0
while i < (size - 1)
j = 0
while j < size - i - 1
if more(array[j], array[j + 1])
# Swapping
temp = array[j]
array[j] = ... | true |
4ffb4956024eb4283e79b840b29142eb8cc66dbd | Ruby | sniper-fly/rails_quick_guide | /chapter1/various_expression.rb | UTF-8 | 826 | 4.21875 | 4 | [] | no_license | ### ニルガード
class Hoge
def initialize
# @children = [1, 2, 3]
end
def children_array
@children ||= []
end
end
# hoge = Hoge.new
# p(hoge.children_array.size)
### ボッチ演算子
object = nil
# object.name
# p(object&.name)
# %記法
ary1 = ['apple', 'banana', 'orange']
ary2 = %w(elen mikasa arumin)
# p(ary1)
# p(ary2)
ar... | true |
2dc42059752d1245e47fc7bd02e78d733ca853fd | Ruby | Papercloud/is_rateable | /spec/is_rateable_spec.rb | UTF-8 | 2,518 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe IsRateable do
it 'has a version number' do
expect(IsRateable::VERSION).not_to be nil
end
describe 'acts_as_rateable' do
before :each do
@user = User.create(name: 'The Great Danton')
@movie = Movie.create(title: 'The Prestige')
end
it 'calculates if any... | true |
2bc9918b3bed04ab523f60b31fee7e827d666500 | Ruby | akitaonrails/brazilian-rails | /brcep/lib/brcep/busca_endereco.rb | UTF-8 | 4,207 | 3.09375 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'net/http'
require 'rexml/document'
# Este recurso tem como finalidade encontrar um endereço através de um CEP, e
# para isso ele utiliza o web service da Bronze Business (http://www.bronzebusiness.com.br/webservices/wscep.asmx)
# e o web service do Buscar CEP (http://www.buscarcep.com.br). O... | true |
8323131907b4fb9fab8cc2a10d06ce683b6d78e7 | Ruby | deliveryhero/proteus | /lib/proteus/commands/untaint.rb | UTF-8 | 963 | 2.515625 | 3 | [
"MIT"
] | permissive | module Proteus
module Commands
module Untaint
def self.included(thor_class)
thor_class.class_eval do
desc "untaint", "Untaints an existing resource"
long_desc <<-LONGDESC
Untaints an existing resource
--resource The resource to untaint
LONGDESC... | true |
d155c5c29879b6d2a607898929c934cb4afc6ef7 | Ruby | KostRich/coderbyte | /12_Vowel Count.rb | UTF-8 | 70 | 2.890625 | 3 | [] | no_license | def VowelCount(str)
str.count "aeiou"
end
VowelCount(STDIN.gets)
| true |
41bce137dc53cfd8216c71a8a7b530e0a892a1ac | Ruby | veronica-prusenok/Addictive-Game | /level-1.rb | UTF-8 | 634 | 3.109375 | 3 | [] | no_license | def parse_data(*data)
[data[0],data[1],data[2], data[3..-1]]
end
def calc_point_poz(point, last_in_rows)
x, y = 0, 0
last_in_rows.each_with_index do |last_in_row, i|
if i != last_in_rows.size-1 && point.between?(last_in_row+1, last_in_rows[i+1])
x = i+1
y = ((last_in_rows[i]+1)..last_in_rows[i+1... | true |
b0fb087dcc91e3b63e1365373b410473cb01f855 | Ruby | cvilla714/all-about-ruby | /methods2.rb | UTF-8 | 1,741 | 3.796875 | 4 | [] | no_license | # frozen_string_literal: true
system 'clear'
def multiply_numbers(first_number, second_number)
first_number * second_number
end
def adding_numbers(first_number, second_number)
first_number + second_number
end
def substract_numbers(first_number, second_number)
first_number - second_number
end
def divide_numbe... | true |
ba6f49cbc381e8bea3f8e108dce85d16c5086483 | Ruby | gcrk/seir41-homework | /Yang Wu/week4/Monday/calculator.rb | UTF-8 | 2,718 | 4.4375 | 4 | [] | no_license | # # Calculator
#
# ### Explanation
# - You will be building a calculator. A calculator can perform multiple arithmetic operations. Your function should allow the user to choose which operation is expected, enter in the values to perform the operation on, and ultimately view the result.
#
# ### Specification:
# - A us... | true |
ab120615ae4a985859c1258e05db721d52224653 | Ruby | voidsatisfaction/Project-Euler-in-Ruby | /1.rb | UTF-8 | 244 | 3.671875 | 4 | [] | no_license | # variables
# functions
def mul_sum(n)
sum = 0
num = 999/n
for k in 1..num
sum += n * k
end
return sum
end
# main
sum3 = mul_sum(3)
sum5 = mul_sum(5)
sum15 = mul_sum(15)
answer = sum3 + sum5 - sum15
p "The answer is #{answer}" | true |
e206f261c8160a6ce71ec00f08fafe95ce3d8bc8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/space-age/86319066667a4727a574b333c4c2579b.rb | UTF-8 | 897 | 4.09375 | 4 | [] | no_license | #!/usr/bin/env ruby
# Exercism 26
# Space Age Calculator
class SpaceAge
def initialize(age)
@age = age
end
def seconds
@age
end
def on_earth
(@age / 31557600.0).round_to(2)
end
def on_mercury
(on_earth / 0.2408467).round_to(2)
end
def on_venus
(on_earth / 0.61519726).floor_t... | true |
d3a6ddac6935826be58d78938d13c346cc2f0477 | Ruby | sjwakeman/prime-ruby-v-000 | /prime.rb | UTF-8 | 510 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime? (n)
# Prime number is greater than 1
if n <= 1
false
# If n and 2 equal = true
#elsif n == 2
# true
else
# number generator range from 2 to n
# No number is divisible by 2 eliminating the population of numbers
# number is divisible by itself with nothing remaini... | true |
8e2bb4f0190fbe95acc20077fda81a0c23217821 | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/external_connectors_property.rb | UTF-8 | 14,223 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class ExternalConnectorsProperty
include MicrosoftKiotaAbstractions::AdditionalDataHolder, MicrosoftKiotaAbstractions::Parsable
##
... | true |
a7f62eabcc32719d619c958f0b664fd74b4ea2d0 | Ruby | colin-mosley/reading-errors-and-debugging-how-tests-work-atx01-seng-ft-071320 | /calculator.rb | UTF-8 | 214 | 2.609375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Add your variables here
first_number = 4
second_number = 8
sum = first_number + second_number
difference = first_number - second_number
product = first_number*second_number
quotient = first_number/second_number | true |
df73b7ea4ff049cde0bc69541ccfaa8b8b2acec2 | Ruby | anssilehtela/kata-bootstraps | /ruby/tictactoe/app/tictactoe.rb | UTF-8 | 2,165 | 3.671875 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'pry'
require_relative 'mylogger'
class Tictactoe
class InvalidInput < StandardError
end
def initialize
@board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
@moves = 9
@logger = Mylogger.new('TicTacToe')
end
def print
puts printable_board
@l... | true |
74f9298c113d5c99588b982409b72a93e94e6bad | Ruby | gaku/gpx | /lib/gpx/line.rb | UTF-8 | 892 | 3.46875 | 3 | [] | no_license | require 'gpx/vector'
module GPX
class Line
def initialize(p1, p2)
@p1 = p1
@p2 = p2
end
def length_squared
dx = @p1.x - @p2.x
dy = @p1.y - @p2.y
return dx * dx + dy * dy
end
def distance_to_point_squared(point)
# compute dot product between v and l
v = V... | true |
26c942f22907ef603fc0418cacaacb54df2a860a | Ruby | rohitcy/excercism.io | /queen-attack/queen_attack.rb | UTF-8 | 808 | 3.859375 | 4 | [] | no_license | class Queens
attr_accessor :white, :black
def initialize(positions = { })
@white = positions.fetch(:white) { [0,3] }
@black = positions.fetch(:black) { [7,3] }
raise ArgumentError if @white == @black
end
def attack?
(same_row? || same_column? || diagonal?)
end
def same_row?
@white[0]... | true |
4b5d9ad30f8f1bfc17cfe09fd220e263cd43cca6 | Ruby | drthomas21/WordPress_Tutorial | /wordpress_htdocs/services/image-service/vendor/jcupitt/vips/examples/generate_phpdoc.rb | UTF-8 | 8,682 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'vips'
# This file generates the phpdoc comments for the magic methods and properties.
# It's in Ruby, since we use the whole of gobject-introspection, not just the
# small bit exposed by php-vips-ext.
# Regenerate docs with something like:
#
# cd src
# ../examples/generate_phpdoc.rb ... | true |
8b7a4080602f58f012f09e3e1191daf808ba3377 | Ruby | kelvin8773/data-algorithm | /8-leetcode/001-two-sum.rb | UTF-8 | 284 | 3.6875 | 4 | [
"MIT"
] | permissive | # @param {Integer[]} nums
# @param {Integer} target
# @return {Integer[]}
def two_sum(nums, target)
comp = {}
nums.each_with_index do |x, idx|
return [comp[x], idx] if comp[x]
comp[target-x] = idx
end
end
p two_sum([3,2,7,11,15,4], 9)
# => [1, 2]
| true |
ac2cd7d340808d5fd9a21e838c3537ef4e28a28e | Ruby | germilasaintjean/ruby-objects-has-many-through-lab-noukod-000 | /lib/genre.rb | UTF-8 | 264 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class Genre
attr_reader :name, :genre
attr_accessor :song
@@all = []
def initialize (name)
@name = name
end
def songs
Song.all.select do |song|
song.genre == self
end
end
def artists
Song.all.collect do |song|
song.artist
end
end
end
| true |
997ce413895428bce0a21b02b1c8a8a3f3401fbd | Ruby | telzul/twitter_analyser | /app/models/sentiment_analyser/bigram_association_measures.rb | UTF-8 | 1,428 | 2.796875 | 3 | [] | no_license | class SentimentAnalyser::BigramAssociationMeasures
=begin
w1 ~w1
------ ------
w2 | n_ii | n_oi | = n_xi
------ ------
~w2 | n_io | n_oo | = n_xo
------ ------
= n_ix =n_ox TOTAL = n_xx
=end
def initialize(n_ii, n_xi, n_ix,n_xx)
@n_ii = n_ii
@n_xi ... | true |
c98fe69132dd499d01b6349ccc003a2f6be039ad | Ruby | SS-03-MAC/SS-03_MAC | /MAC/src/generate/SQL/generate_sql.rb | UTF-8 | 2,105 | 3 | 3 | [
"MIT"
] | permissive | require_relative '../hash_generator.rb'
require 'active_support/inflector'
module Generation
# This class alows us to generate SQL source files using an ERB template and
# hashes we create from parsing YAML files
class GenerateSQL
attr_reader :types
def initialize
@types = {
'MAC.User.Pass... | true |
f878a184bdb37a5e394f441db574a7093c3bb128 | Ruby | gnarmis/colby | /lib/colby/sequences.rb | UTF-8 | 619 | 2.703125 | 3 | [] | no_license | require 'hamster'
module Colby
module Core
def seq(data)
if data.is_a? Hamster::List
return data
elsif data.is_a? Array or data.is_a? Hamster::Vector
return list(*data)
elsif data.is_a? Hash
return list(*data.keys.to_a.zip(data.values.to_a))
elsif data.is_a? Hams... | true |
0903f25f4130e2407e884184ea3d89e0241f0833 | Ruby | TMerrick55/mined_minds_kata | /testmindminesfunction.rb | UTF-8 | 943 | 2.859375 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'minedminesfunctions.rb'
class TestMMfunctions < Minitest::Test
def test_one_equals_one()
assert_equal(1, get_mined_mines_result(1))
end
def test_two_returns_two()
assert_equal(2, get_mined_mines_result(2))
end
def test_three_equals_mined()
assert_equal("mined",... | true |
923e0e18b2dab6cc49f792dc8643b572cb91c5de | Ruby | possumtale/ruby-challenges | /always_three_again.rb | UTF-8 | 65 | 2.796875 | 3 | [] | no_license | num = gets.to_i
num = (((((num + 5) * 2) - 4) /2) - num)
puts num | true |
9761013591316bdd9f37d33a1943aeeb0abaeefa | Ruby | ipatriot/brussel_sprouts_oo | /code.rb | UTF-8 | 138 | 3.046875 | 3 | [] | no_license | #YOUR CODE GOES HERE
class Ingredient
def initialize(quantity, unit, name)
@quantity = quantity
@unit = unit
@name = name
end
end | true |
b8d1f09123ec26ff24952c67197f371e9f714cf9 | Ruby | DavidIvy003/rails-twitter-search | /spec/helpers/search_helper_spec.rb | UTF-8 | 803 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe SearchHelper do
describe 'valid' do
it 'empty query should return false' do
helper.valid('').should == false
end
it 'blank query should return false' do
helper.valid(' ').should == false
end
it 'real query should return true' do
helper.valid('hu... | true |
b97919ec16e18f3fa9b38ac7ca766bd4c0d2ff84 | Ruby | JupiterLikeThePlanet/goby | /lib/Entity/Monster/monster.rb | UTF-8 | 1,042 | 3.234375 | 3 | [
"MIT"
] | permissive | require_relative "../entity.rb"
class Monster < Entity
# @param [Hash] params the parameters for creating a Monster.
# @option params [String] :name the name.
# @option params [Integer] :max_hp the greatest amount of health.
# @option params [Integer] :hp the current amount of health.
# @option params [Integ... | true |
b0bcca717657c581d3f4a01638123035e84c47c0 | Ruby | ngyaomin/alphacamp | /contain_duplicates.rb | UTF-8 | 528 | 3.71875 | 4 | [] | no_license | =begin
Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
=end
def is_duplicate(array)
if array.uniq.length == array.length #actually can also do... | true |
0137ede803fcd051cbf69833e80c8c01bff01223 | Ruby | SanderVO/socialsearch | /app/models/resultobjects/facebook.rb | UTF-8 | 660 | 2.703125 | 3 | [] | no_license | class Facebook < Result
attr_reader :image, :user_image, :user_link
def initialize(info)
super(info['created_time'], get_content(info), info['from']['name'], get_url(info['id']))
@image = info['picture']
@user_link = get_url(info['from']['id'])
@user_image = get_user_picture(info['from']['id'])
e... | true |
1a8d8b0f99c3ae16986297ad63b7035d00416d0d | Ruby | brodiemadden/101-Foundations | /small_problems/easy_5/q6.rb | UTF-8 | 264 | 3.515625 | 4 | [] | no_license | # method takes a string with one or more space separated words
# returns a has that shows the number of words of different sizes
def word_sizes(words_string)
counts = Hash.new(0)
words_string.split.each do |word|
counts[word.size] += 1
end
counts
end
| true |
1991fe0ba27e9c1d8096a46f6b57f1a153a76c3a | Ruby | kaiheiongaku/rails-engine | /spec/facades/api/v1/merchants_facade_spec.rb | UTF-8 | 2,080 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
describe MerchantsFacade do
describe 'returns merchants' do
before :each do
create_list(:merchant, 50)
end
it 'returns merchants in groups of 20 starting on page 1 by default' do
merchants = MerchantsFacade.paginate
expect(merchants.count).to eq(20)
expect(... | true |
375a0fccedbd0a7d5bdb76e785a39e780d3336a5 | Ruby | Agkura/assignments | /w1d4/map.rb | UTF-8 | 652 | 3.546875 | 4 | [] | no_license | # Implementation of a map with arrays
class Map
def initialize
@array = Array.new { [] }
end
def assign(key, value)
found = @array.index { |entry| entry.include?(key) }
@array[found][1] = value if found
@array << [key, value]
end
def lookup(key)
(_, value) = @array.find { |entry| entry.... | true |
2ec4d3fb9b67b82e61e111950375fa58f2934cf8 | Ruby | cquinones100/rvc | /lib/rvc/component.rb | UTF-8 | 2,480 | 2.6875 | 3 | [
"MIT"
] | permissive | require './lib/rvc/base'
require './lib/rvc/required_local_not_defined'
require './lib/rvc/inline'
require './lib/rvc/javascript_function'
module Rvc
class Component
class << self
def render(base: nil, **args, &block)
component = new(base: base, block: block, **args)
render_string = compon... | true |
7cc10f174bdb2192ebdbf1bc61e4f3d81a655668 | Ruby | geemus/prototypes | /lexical.rb | UTF-8 | 1,218 | 3.203125 | 3 | [] | no_license | # option/required arguments
# use inline, but normally include something that makes it all noops, by overridding this you get the goods
# include a bin file that can parse/output this stuff
module Lexical
def self.included(other)
other.class_eval do
extend(Lexical::ClassMethods)
include(Lexical::Ins... | true |
698ad59e77b6406f70f9e5bf2b5b043271e539bd | Ruby | vdonskoy/checkers | /checkers.rb | UTF-8 | 6,426 | 3.375 | 3 | [] | no_license | class Board
attr_accessor :grid
def initialize
@grid = Array.new(8) {Array.new(8)}
end
def [](pos)
self.grid[pos[0]][pos[1]]
end
def []=(pos, piece)
self.grid[pos[0]][pos[1]] = piece
end
def board_fill
(0..7).each do |row|
(0..7).each do |column|
pos = [row,co... | true |
3f372272e2d0099face827757f766ffbbc22c635 | Ruby | Hsieh-Jia-Shiuan/Ruby_Homework | /HW_RPS_OOP.rb | UTF-8 | 3,262 | 3.953125 | 4 | [] | no_license | #Class
class Player
attr_accessor :name
def initialize(name)
@name = name
end
def finger_guess
end
end
class Human < Player
def finger_guess
input = gets.chomp.upcase
end
end
class Computer < Player
def finger_guess(array)
input = array.sample
end
end
class RPSGame
FINGER_GESTURE_A... | true |
af32ab5e8f5f9e286fa2f4b2af9ba3fcff240186 | Ruby | SaraChandler/MediaRanker | /app/controllers/sessions_controller.rb | UTF-8 | 743 | 2.515625 | 3 | [] | no_license | class SessionsController < ApplicationController
def login_page
@users = User.all
end
def login
@user = User.find_by_name(params[:name])
if @user
session[:user_id] = @user.id
flash[:success] = "You're logged in as existing user #{@user.name}"
redirect_to home_path
else
@... | true |
dbb7197c50eb76ba51d05df4f6744077657845a4 | Ruby | dediane/mini_jeu_POO | /lib/player.rb | UTF-8 | 2,487 | 3.9375 | 4 | [] | no_license | class Player
attr_accessor :name, :life_points
# @@enemies = Array.new
#initialize a player
def initialize(name)
@name = name
@life_points = 10
end
#show how manies life points the player has left
def show_state
if @life_points == 0
puts "#{@name} est mort."
else
puts "#{@na... | true |
4d48a84cf562b715e71d16a1b65858d2417a8b69 | Ruby | willwinberg/homeworks | /W2D4/octopus.rb | UTF-8 | 1,739 | 3.75 | 4 | [] | no_license | # start = Time.now
fishies = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish',
'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
def sluggo(le_fish)
da_longest = "?"
le_fish.each do |fish|
current_fish_length = fish.length
le_fish.each do |comparee|
if comparee.length > current_fish_length && comp... | true |
85bce0ca89baa6dbf3b091906603324d665d4fc8 | Ruby | Submoon/Hitman | /lib/Hitman/Commands/save_commands.rb | UTF-8 | 3,362 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'fileutils'
module SaveCommands
extend Discordrb::Commands::CommandContainer
#### => Quotes
# Quotes are saved in a file named quotes.txt at project's root
# They are linked to an ID which allows to manipulate them
#
####
QUOTE_FILE = File.join(File.dirname(__FILE__), '../../../quot... | true |
f60713c38fd26a7e21c8c012afef3caae50e018f | Ruby | ga-wdi-exercises/search_for_obi_wan | /the_search_for_obi_wan_solution.rb | UTF-8 | 1,012 | 3.265625 | 3 | [] | no_license | puts "Hello, I am C-3P0, human-cyborg relations. What's your name?"
name = gets.chomp
puts "It's a pleasure to meet you, #{name}. Have you ever met a protocol droid before?"
first_protocol_droid = gets.chomp
puts "#{first_protocol_droid}? How interesting, for someone from around these parts."
puts "I'm terribly sor... | true |
248661fd96e59f5a147ab48f0232ba1984c9b09d | Ruby | Jwarholic/phase-0-tracks | /ruby/shout.rb | UTF-8 | 611 | 4.15625 | 4 | [] | no_license | #module Shout
# def self.yell_angrily(words)
# words + "!!!" + " :("
# end
#
# def self.yelling_happily(words)
# words + " :) I am happy "
# end
#end
#Release 1 driver code
#puts Shout.yell_angrily("I AM MAD!")
#puts Shout.yelling_happily("I AM HAPPY")
#Release 3
module Shout
def yell_angrily(words)
puts... | true |
2e0fe310fb8f760449b13a555cd9f0f8e61b1c9a | Ruby | karki-anjan/materPayroll | /app/models/payroll.rb | UTF-8 | 1,037 | 2.578125 | 3 | [] | no_license | class Payroll < ApplicationRecord
# validates :period, presence: true
validates :start_period, presence: true
validates :end_period, presence: true
validate :end_is_after_start_period
has_many :payslips, inverse_of: :payroll, dependent: :destroy
after_create :create_payslips
before_save :update_id
de... | true |
577af842ccb4404c914a60662d4e4e019788079e | Ruby | FausSR/TallerRubyMooveIt | /test/connection_logic_spec.rb | UTF-8 | 2,647 | 2.5625 | 3 | [] | no_license | require 'rspec'
require 'socket'
require './lib/custom_hash/custom_hash'
require './lib/socket_connection/connection_logic'
describe CommandAdd do
before(:each) do
allow($stdout).to receive(:puts)
socket_address = 'localhost'
socket_port = 2000
@server = TCPServer.open(socket_port... | true |
570d75f4ce85399c2778155596cc238561f3616f | Ruby | fnando/kitabu | /spec/support/have_tag.rb | UTF-8 | 3,371 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Matchers
def have_tag(selector, options = {}, &block)
HaveTag.new(:html, selector, options, &block)
end
def have_node(selector, options = {}, &block)
HaveTag.new(:xml, selector, options, &block)
end
class HaveTag
attr_reader :options, :selector, :actual, :ac... | true |
1c6917c770ca2e2b8156798afa8a6b54eb35eabc | Ruby | antoniosb/caesar_cipher | /caesar_cipher_spec.rb | UTF-8 | 2,497 | 3.265625 | 3 | [] | no_license | require_relative 'caesar_cipher'
describe CaesarCipher do
describe '#encrypt' do
let(:message) { "What a String!" }
let(:factor) { 5 }
it 'receives a message and a shift factor as parameters' do
expect(CaesarCipher).to receive(:encrypt).with(message, factor)
CaesarCipher.encrypt message, fac... | true |
7e02b880f96a0271bc8e8aee47345d0f4ef6a032 | Ruby | luizpessanha/chain_responsibility | /lib/calculador_de_descontos.rb | UTF-8 | 231 | 2.546875 | 3 | [] | no_license | class CalculadorDeDescontos
def calcula(orcamento)
d1 = DescontoPorCincoItens.new
d2 = DescontoPorMaisDeQuinhentosReais.new
d3 = SemDesconto.new
d1.proximo = d2
d2.proximo = d3
return d1.desconta(orcamento)
end
end
| true |
598d7f280b6626daff84170c0fc31c14077257ad | Ruby | hertweckhr1/api-muncher | /test/lib/recipe_test.rb | UTF-8 | 1,976 | 2.65625 | 3 | [] | no_license | require 'test_helper'
describe Recipe do
it "cannot be initialized with less than 3 parameters" do
expect { Recipe.new }.must_raise ArgumentError
expect { Recipe.new("banana")}.must_raise ArgumentError
expect { Recipe.new("banana",
"https://www.edamam.com/web-img/66a/66a0a1eebe4a4143ceccb55b68b3e... | true |
fe8d8f785ce68470369c8bf8173a2a7ae7e99e4c | Ruby | thalathalaylah/stepmania_random_course_maker | /course_maker/course_maker.rb | UTF-8 | 1,610 | 2.796875 | 3 | [] | no_license | require 'erb'
require './course_maker/song'
module CourseMaker
class CourseSetting
VALS = [:target_level, :sample_number, :target_bpm_ranges, :course_name, :meter, :scripter]
def initialize(setting_hash)
VALS.each do |val|
if setting_hash[val]
eval("@#{val.to_s} = setting_hash[:#{va... | true |
199e45522709d437318ec43f007ce3ad3f6f84af | Ruby | lishulongVI/leetcode | /ruby/777.Toeplitz Matrix(托普利茨矩阵).rb | UTF-8 | 4,398 | 3.59375 | 4 | [
"MIT"
] | permissive | =begin
<p>A matrix is <em>Toeplitz</em> if every diagonal from top-left to bottom-right has the same element.</p>
<p>Now given an <code>M x N</code> matrix, return <code>True</code> if and only if the matrix is <em>Toeplitz</em>.<br />
</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</str... | true |
50436b75170bb5669bd43d7933d4188a235969e2 | Ruby | clemiraho/W02D04 | /lib/city_council.rb | UTF-8 | 1,269 | 2.921875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'pry'
PAGE_URL= "http://annuaire-des-mairies.com/val-d-oise.html" #page val d'oise donnée
@root = "http://annuaire-des-mairies.com" #page accueil France Mairies
puts "Please, Wait, it may be long........sorrey!"
puts "---------------------------------... | true |
61641abd53326aa73135d85af97dbae142320623 | Ruby | KevinKra/ruby-battleship | /lib/human_player.rb | UTF-8 | 1,110 | 3.6875 | 4 | [] | no_license | class HumanPlayer
attr_reader :ships
def initialize
@ships = []
end
def start_game(total_ships, board)
notify_start_game
place_ships(total_ships, board)
@ships = total_ships
end
def notify_start_game
print ">> Player:"
puts "\n You now need to lay out your two ships." + "\n The Cru... | true |
cd0ce02ace7c4600894878ebc460d054c3af0aff | Ruby | igorbelo/eagle_search | /lib/eagle_search/interpreter/filter.rb | UTF-8 | 1,492 | 2.703125 | 3 | [
"MIT"
] | permissive | module EagleSearch
class Interpreter::Filter
LOGICAL_OPERATORS = { and: :must, not: :must_not, or: :should }
def initialize(filters)
@filters = filters
end
def payload
@payload ||= generate_payload(@filters)
end
private
def generate_payload(filters)
payload = {}
... | true |
58719966b8d897d933f50661d3c3ac87bfac007f | Ruby | wiecklabs/port_authority | /lib/port_authority/models/user/search.rb | UTF-8 | 2,700 | 2.640625 | 3 | [] | no_license | class User
class Search
DEFAULT_PAGE = 1
DEFAULT_PAGE_SIZE = 100
attr_reader :page, :page_size
def initialize(page, page_size, options, query)
if (@page = page.to_i.abs) == 0
@page = DEFAULT_PAGE
end
if (@page_size = page_size.to_i.abs) == 0
@page_s... | true |
9144a4c7723f8282515038b56767e4449ea4025a | Ruby | Lo56/RepoJ11 | /calendar/lib/event.rb | UTF-8 | 1,057 | 3.03125 | 3 | [] | no_license | require "pry"
class Event
attr_accessor :start_date, :length, :title, :attendees
@@all_events = []
@@all_attendees = []
def initialize(event_to_save)
@event = event_to_save
@@all_events << self
@start_date = Time.parse
@length ... | true |
13d8eca4289775a092f90429479f16813511603a | Ruby | JoeStafford1986/weekend_homework_2 | /guest.rb | UTF-8 | 543 | 3.34375 | 3 | [] | no_license | class Guest
attr_reader(:name, :total_cash)
attr_accessor(:bar_tab)
def initialize(name, total_cash)
@name = name
@total_cash = total_cash
@bar_tab = 0
end
def check_can_afford(balance_to_pay)
if total_cash >= balance_to_pay
return true
end
return false
end
def make_payme... | true |
599766fb3f011a3f36a313fc230f2e752a85aa62 | Ruby | jessethebuilder/any_raffle | /spec/models/prize_spec.rb | UTF-8 | 1,907 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Prize, type: :model do
let(:prize){ build :prize }
describe 'Validations' do
# it{ should validate_presence_of :raffle_id }
it{ should validate_presence_of :name }
specify "Prize cannot be deleted once its raffle is active" do
prize.raffle = build(:raffle,... | true |
64aeeec52c4d895bd37b6f702d859f5c32d3a846 | Ruby | skwiens/betsy | /app/validators/expiration_date_validator.rb | UTF-8 | 699 | 2.546875 | 3 | [] | no_license | class ExpirationDateValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return if record.status == "pending"
if record.cc_expiration == nil
return record.errors[:cc_expiration] << 'expiration date can\'t be blank'
end
unless value =~ /\A(0[1-9]|1[0-2]|[1-9])\/(2... | true |
db9f4f2edd5a9d941383f2d59f6f4260d514eb76 | Ruby | derekgr/logstash | /lib/logstash/outputs/redis.rb | UTF-8 | 5,570 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | require "logstash/outputs/base"
require "logstash/namespace"
# send events to a redis database using RPUSH
#
# For more information about redis, see <http://redis.io/>
class LogStash::Outputs::Redis < LogStash::Outputs::Base
config_name "redis"
plugin_status "beta"
# Name is used for logging in case there are ... | true |
1665fa69c0d6f4b8dd99f1bd400821fe21e774ed | Ruby | artyom-ukhabin/AdviceMeAgain | /app/decorators/recommendations_decorators/recommended_personalities_decorator.rb | UTF-8 | 1,171 | 2.578125 | 3 | [] | no_license | module RecommendationsDecorators
class RecommendedPersonalitiesDecorator
PERSONALITY_TYPE = Personality::TYPE
#TODO: still think about better interface
def initialize
@collaborations_decorator =
RecommendationsDecorators::Shared::CollaborationsDecorator.new(PERSONALITY_TYPE)
@content_... | true |
50adab25e133216ba83d2f5355b889ee589dfca3 | Ruby | aos/ruby-studies | /meta/ch05-class_defs/module_trouble.rb | UTF-8 | 342 | 3.46875 | 3 | [] | no_license | module MyModule
def my_method; 'hello'; end
end
# When a class includes a module, it gets the module's
# instance methods -- not the class methods
# Define class methods by mixing them into the class's
# singleton class
# This is known as Class Extension
class MyClass
class << self
include MyModule
end
end... | true |
586b92f34a7cbad28b4387b843c7bcbc7bcd1bc5 | Ruby | btihen/East_Oriented_Code | /hex_rails_jim_weirich/features/pages/page_object.rb | UTF-8 | 270 | 2.671875 | 3 | [] | no_license | class PageObject
attr_reader :context, :app
def initialize(app, context)
@context = context
@app = app
end
def make_current_page
app.current_page = self
end
def method_missing(sym, *args, &block)
context.send(sym, *args, &block)
end
end
| true |
b510de5b043592614e253c0f1b11d19836734dd1 | Ruby | AI-comp/wpcs | /lib/populate_helper.rb | UTF-8 | 609 | 2.515625 | 3 | [] | no_license | module PopulateHelper
def solve_problems(attend, problems)
pcount = (1..problems.count).to_a.sample
problems.shuffle!
# Submit some wrong answers
problems.take(pcount).each do |p|
Problem::TYPES.each do |type|
(0..5).to_a.sample.times do
attend.submit(p, 'dummy', type)
... | true |
a20c994e45d1a227b84cda49e5d6ddf2f6c95e20 | Ruby | tabmedblog/blog | /_plugins/lowernospace.rb | UTF-8 | 468 | 2.59375 | 3 | [] | no_license | module Jekyll
class LowerNoSpace < Liquid::Tag
def initialize( tag_name, markup, tokens )
@markup = markup
end
# this is a tricky one
# the context contains the variable
# markup contains the name of the variable
# therefore context[ @markup ] is the value of the variable
def rende... | true |
c3aa7be14227e93cb8ab786cbeedeab8b2528ad6 | Ruby | davepgreene/homebrew-cask-tools | /lib/bct/cask/version.rb | UTF-8 | 1,215 | 2.75 | 3 | [
"MIT"
] | permissive | require 'versionomy'
module BrewCaskTools
module Casks
# Parent class for different types of Versions
class Version
DIR_BLACKLIST = ['.', '..', '.metadata'].freeze
def initialize(dir)
@dir = dir
end
def versions
@versions ||= latest? ? ['latest'] : all_versions.sort
... | true |
a27c14434d6f4d49b52317f148368a9e5d64c900 | Ruby | kinketsucom/Task2 | /simulate.rb | UTF-8 | 2,145 | 3.375 | 3 | [] | no_license | require File.dirname(__FILE__) + '/player'
require File.dirname(__FILE__) + '/team'
require File.dirname(__FILE__) + '/field'
require File.dirname(__FILE__) + '/hitcount'
#チーム設定
PlayerInfoA = {1 => { attack: 32, defense: 3},
2 => { attack: 11, defense: 4},
3 => { attack: 21, defense: 1},
... | true |
94a90c285395ddbb6dc151d30f242397660d1e75 | Ruby | jessramvi/LPP-prct05 | /racional.rb | UTF-8 | 2,475 | 3.96875 | 4 | [] | no_license | # Implementar en este fichero la clase para crear objetos racionales
require "./gcd.rb"
class Fraccion
# Inicializacion del objeto con argumentos tomados desde la terminal.
# Para obtener la expresion minima, se le hace el Maximo Comun Divisor
# y asi poder operar con la expresion reducida de los operandos.
#
... | true |
67f55185437728ea60652e759721d4a7bb1c41b1 | Ruby | erikwithuhk/reddit-comment-generator | /app/controllers/api/v1/words_controller.rb | UTF-8 | 1,113 | 2.734375 | 3 | [] | no_license | class Api::V1::WordsController < ApplicationController
def index
get_queries
if @page_number > 0
total_words = Word.all.length
total_pages = ((total_words - 1) / 10) + 1
if @page_number > total_pages
out_of_range_error(total_pages)
else
words = Word.all.limit(10).offset... | true |
f12704ac978b0afaaf4dfea38b61041ed287e0a5 | Ruby | kschnelker/practice-quote-middleware | /spec/quote_fetcher_spec.rb | UTF-8 | 966 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative "../quote_fetcher"
require 'rack'
class TestApp
def call(env)
@env = env
[200, {"Content-Type" => "text/html"}, ["OK"]]
end
end
describe QuoteFetcher do
let(:testapp) { TestApp.new }
let(:middleware) { QuoteFetcher.new(testapp) }
let(:request) { Rack::MockRequest.new(middleware) }
... | true |
b308c83343450862e94bb19c28169206ac66703e | Ruby | vandoan/brainteaser | /coins.rb | UTF-8 | 656 | 3.5 | 4 | [] | no_license |
def change(owed)
#coins
change = Array.new
if
owed/25 > 0
quarter = (owed/25).floor
remainder = owed - quarter*25
change.push(quarter)
owed = remainder
else
change.push(0)
end
if
owed/10 > 0
dime = (owed/10).floor
remainder = owed - dime*10
change.push(dime)
owed =... | true |
5f428c9f6d2e6eb632780a849ec4dba81f04895e | Ruby | ppalumbo17/CSCI400-Programming-Languages | /NIM/nimTest.rb | UTF-8 | 912 | 2.609375 | 3 | [] | no_license | #Peter Palumbo and Cody Watters
#NIM
#September 19, 2016
require 'test/unit'
require_relative "Nim"
class NimTester < Test::Unit::TestCase
def test_a_move
nim = Nim.new
nim.instance_variable_set(:@comp_type, "smart_computer_player")
nim.instance_variable_set(:@current_layout, [1,0,0,0] )
nim.send(:sma... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.