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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30173c6299e7cb979529ff5b0159b721f7d9d582 | Ruby | elanthia-online/urnon | /lib/urnon/util/synchronized-socket.rb | UTF-8 | 409 | 2.875 | 3 | [
"BSD-3-Clause"
] | permissive | class SynchronizedSocket
def initialize(o)
@delegate = o
@mutex = Mutex.new
self
end
def puts(*args, &block)
@mutex.synchronize {
@delegate.puts *args, &block
}
end
def write(*args, &block)
@mutex.synchronize {
@delegate.write *args, &block
}
end
def meth... | true |
6f9bf7fbb0ed6af61bb7a9f6fa008298adf28ef4 | Ruby | fbenton93/guessing-cli-nyc-web-080618 | /guessing_cli.rb | UTF-8 | 433 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def run_guessing_game
number = rand(1..6)
response = nil
while true
puts "Guess a number between 1 and 6."
user_input = gets.chomp
if user_input == "exit"
puts "Goodbye!"
break
elsif user_input.to_i == number
response = true
else
response = false
end
end
if res... | true |
dff1cb73d329b8e20089a3ba1d2b12c479b48895 | Ruby | JustinTArthur/engineyard-serverside | /lib/vendor/dataflow/spec/by_need_spec.rb | UTF-8 | 1,405 | 2.578125 | 3 | [
"MIT"
] | permissive | require "#{File.dirname(__FILE__)}/spec_helper"
describe 'A by_need expression' do
describe 'when a method is called on it' do
it 'binds its variable' do
local do |x, y, z|
Thread.new { unify y, by_need { 4 } }
Thread.new { unify z, x + y }
Thread.new { unify x, by_need { 3 } }
... | true |
d408b8d94bfd0fb13a159b647e5cdaf24f2bcd02 | Ruby | mgreg90/Gilded-Rose-Ruby | /lib/gilded_rose.rb | UTF-8 | 362 | 3.015625 | 3 | [] | no_license | require 'pry'
require_relative 'gilded_rose/item'
class GildedRose
attr_accessor :item
def initialize(name:, days_remaining:, quality:)
@item = Item.create(name, days_remaining, quality)
end
def tick
item.tick
end
def name
item.name
end
def days_remaining
item.days_remaining
end
... | true |
5118d1e7d42e54f6eaf28d81603484c4cb59e281 | Ruby | avni510/time_logger | /spec/console/console_ui_spec.rb | UTF-8 | 11,934 | 2.640625 | 3 | [] | no_license | require "spec_helper"
module TimeLogger
module Console
describe ConsoleUI do
let(:mock_io_wrapper) { double }
let(:console_ui) { ConsoleUI.new(mock_io_wrapper) }
describe ".puts_space" do
it "displays a space" do
expect(mock_io_wrapper).to receive(:puts_string).with("")
... | true |
66a0b877402772db0d0e48828a341fe88016315b | Ruby | amree/tueetion | /app/models/payment.rb | UTF-8 | 1,013 | 2.703125 | 3 | [] | no_license | class Payment < ActiveRecord::Base
belongs_to :bill
belongs_to :user
validates :paid_at, presence: true
validates :amount, presence: true
validates :amount, numericality: true
validate :less_than_bill_balance, if: "amount.present? && amount >= 0"
validate :paid_at_should_not_be_from_the_future, if: "pai... | true |
6346f5de203248ea7983ea5e6ce008a0774f3641 | Ruby | meh/ruby-cmus | /bin/cmus-remote.rb | UTF-8 | 2,749 | 2.609375 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'cmus'
require 'optparse'
options = {}
OptionParser.new do |o|
o.on '--server SOCKET', 'connect using SOCKET instead of ~/.cmus/socket' do |value|
options[:server] = value
end
o.on '--version', 'display version information and exit' do
puts "cmus-remote.rb for #{Cmus.version}"
e... | true |
f2ba2cda0582fafed0ceb8fd6b539f79da1fd55d | Ruby | gwenh11/LS_core | /ruby_exercises/120/easy_2/10_nobility.rb | UTF-8 | 3,276 | 4.34375 | 4 | [] | no_license | =begin
Now that we have a Walkable module, we are given a new challenge.
Apparently some of our users are nobility, and the regular way
of walking simply isn't good enough. Nobility need to strut.
We need a new class Noble that shows the title and name when walk is called:
byron = Noble.new("Byron", "Lord")
... | true |
dd45b423d7477ee405c5ddcc011cbfafc54ffb88 | Ruby | SephoraM/LS-ruby-basics | /variable_scope/ex111.rb | UTF-8 | 335 | 3.859375 | 4 | [] | no_license | # What will the following code print, and why?
a = 7
array = [1, 2, 3]
def my_value(ary)
ary.each do |b|
a += b
end
end
my_value(array)
puts a
#=> an error because you can't use the += method on an uninitialized variable
# because that variable would have a nil value and += is not a method that
# is ava... | true |
acc8cd0e1ad169e3e68a0a8ab6dc4a78701d49eb | Ruby | patrickmult/ruby_sandbox | /drills/the_hard_way/ex09.rb | UTF-8 | 247 | 3.203125 | 3 | [] | no_license | days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
puts "Here are the days: #{days}"
puts "Here are the months: #{months}"
puts """
Inside three double quotes
We type as many new lines as we like.
Line 3
"""
| true |
f3659c6ca2ea4d07ec539273ccfbcbdc19c8db81 | Ruby | vecchp/sevenlanguages | /Ruby/Day 1/day1.rb | UTF-8 | 227 | 3.859375 | 4 | [] | no_license | # Print String Hello World
puts 'Hello World'
# Index of Ruby
'Hello, Ruby'.index('Ruby')
# Print name 10 Times
(0..9).each{|x| puts "Paul"}
# Print Sentence from 1 to 10
(1..10).each{|x| puts "This is sentence number #{x}"} | true |
90e0f586663c78403021e20b78fea98f82989d3e | Ruby | emezac/Temperature | /TemperatureModel.rb | UTF-8 | 708 | 3.421875 | 3 | [] | no_license | class TemperatureModel
def initialize
@listeners = []
end
def add_listener(listener)
@listeners << listener
end
def upF(temp)
@temp = temp
@temp += 1
@listeners.each {|l| l.faranheit_changer(@temp) }
end
def downF(temp)
@temp = temp
@temp -= 1
@listen... | true |
0748ba8a2639f3670f57de611e409d62bd5e5baa | Ruby | BrentonEarl/Generate-slack-required | /lib/slack-required.rb | UTF-8 | 2,122 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'find'
class SlackRequired
def initialize(configuration_file)
@repository = IO.readlines(configuration_file)[1].strip!
@includedFileExtensions = IO.readlines(configuration_file)[3].chomp.split(",")
@excludedFileNames = IO.readlines(configuration_file)[5].chomp.split(",")
... | true |
39c40202045828e9749952597ec9a83f30dc7ec3 | Ruby | igorsimdyanov/gb | /part2/lesson3/yield_self.rb | UTF-8 | 162 | 3.109375 | 3 | [] | no_license | hello = 'Hello, %s!'.yield_self do |str|
print 'Пожалуйста, введите имя '
format(str, gets.chomp)
end
puts hello
| true |
9d1d115946505f01ba8c438b542415ae2e118bcb | Ruby | yurifrl/curly | /lib/curly/compiler.rb | UTF-8 | 5,165 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | require 'curly/scanner'
require 'curly/component_compiler'
require 'curly/component_parser'
require 'curly/error'
require 'curly/invalid_component'
require 'curly/incorrect_ending_error'
require 'curly/incomplete_block_error'
module Curly
# Compiles Curly templates into executable Ruby code.
#
# A template must... | true |
af00e2615974169e9241ef78fbfb623fa3cce14d | Ruby | chad/rubinius | /lib/rbyaml/util.rb | UTF-8 | 363 | 3 | 3 | [
"MIT"
] | permissive | class Object
def __is_str; false end
def __is_sym; false end
def __is_a; false end
def __is_int; false end
end
class String
def __is_str; true end
end
class Symbol
def __is_sym; true end
end
class Array
def __is_a; true end
end
class Integer
def __is_int; true end
end
class Fixnum
def __is_ascii_... | true |
813dc9ff03ef1aac4fb866e1857349e6bea3b8da | Ruby | jerrifel/ruby_book | /methods/exercise_5.rb | UTF-8 | 145 | 3.703125 | 4 | [] | no_license | #exercise_5.rb
def scream(words)
words = words + "!!!!"
return puts words
end
scream("Yippeee")
# what does it return now? => returns nil
| true |
725c8a3a83ebaad3ce5b8adf46540babfd503f2c | Ruby | teddythetwig/origin-server | /controller/app/controllers/members_controller.rb | UTF-8 | 7,941 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | class MembersController < BaseController
def index
render_success(:ok, "members", members.map{ |m| get_rest_member(m) }, "Found #{pluralize(members.length, 'member')}.")
end
def create
authorize! :change_members, membership
errors = []
warnings = []
singular = params[:members].nil?
ids,... | true |
260f9f83b81701967e50f6953baa91ad0ef968b5 | Ruby | KeithYJohnson/codility | /cyclic_rotation/cyclic_rotation.rb | UTF-8 | 323 | 3.515625 | 4 | [] | no_license | # https://codility.com/programmers/lessons/2-arrays/cyclic_rotation/
def solution(a, num_times)
rotated_a = [nil] * a.length
a.each_with_index do |e, idx|
new_index = (idx + num_times) % a.length
rotated_a[new_index] = e
end
rotated_a
end
a = [3, 8, 9, 7, 6]
a_solution = [9, 7, 6, 3, 8]
p solution a,... | true |
5df0300784ed016c64c98ec0877d6dc46a91de8a | Ruby | larrykas/project-5 | /while_until.rb | UTF-8 | 183 | 3.078125 | 3 | [] | no_license | a = 1
a *= 2 while a < 100
a -= 10 until a < 100
# a → 98
puts a
$i = 1
$num = 6
begin
puts("This is day #$i" )
$i +=1
end while $i < $num
puts "Thank you all for coming."
| true |
bfefc71d62a395b3c441c447ac28bfbac7c57546 | Ruby | artemisxen/Boris-Bikes | /spec/garage_spec.rb | UTF-8 | 545 | 2.65625 | 3 | [] | no_license |
require 'Garage'
describe Garage do
subject { Garage.new }
let(:bike) { double(:bike, :fix => true, :working? => true)}#Individual bike
let(:broken_bike) { double(:bike, :working? => false, :fix => true)}
it "Garage should make all stored bikes working when fix_bikes method is called" do
subject.store(bike)
s... | true |
bb1c245bd7f201045c1f04999fa01ecfaefc323b | Ruby | ManageIQ/manageiq | /app/models/account.rb | UTF-8 | 4,494 | 2.578125 | 3 | [
"BSD-2-Clause",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Account < ApplicationRecord
belongs_to :vm_or_template
belongs_to :host
include RelationshipMixin
self.default_relationship_type = "accounts"
def self.add_elements(parent, xmlNode)
user_map = add_missing_elements(parent, xmlNode, "accounts/users", "user")
add_missing_elements(parent, xmlNode, ... | true |
8b6eac140ed20f8b00bc3f82de793668e0892b6b | Ruby | niquola/famili | /spec/famili_spec.rb | UTF-8 | 9,106 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require "uuid"
describe Famili do
before :all do
TestDbUtils.ensure_schema
end
after :all do
TestDbUtils.drop_database
end
class User < ActiveRecord::Base
has_many :articles
validates_presence_of :login
def full_name
"#{last_name}, #{first_name}"
end
... | true |
504e2e6dc2dcc36be625110072d8d49923dd723a | Ruby | rokn/Count_Words_2015 | /fetched_code/ruby/suggest_spec.rb | UTF-8 | 920 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
RSpec.describe TTY::Prompt, '#suggest' do
let(:possible) { %w(status stage stash commit branch blame) }
subject(:prompt) { TTY::TestPrompt.new }
it 'suggests few matches' do
prompt.suggest('sta', possible)
expect(prompt.output.string).
to eql("Did you mean one of these?\n ... | true |
d8a48bf3c9843faa00ee915ec643ad9062c95d56 | Ruby | gilmae/AdventureCapital | /lib/adventure_capital/challenge.rb | UTF-8 | 1,441 | 3.203125 | 3 | [
"MIT"
] | permissive | module AdventureCapital
class Challenge
attr_accessor :targets, :level, :damage#, :themes
def initialize
@targets = {}
@themes = []
end
def generate level
@level = level
abilities = Abilities::ALL_ABILITIES.clone + @themes
abilities.delete :health
create_target abiliti... | true |
cff1df592d0e1a507e07c0ad99bda40c5fb8c40c | Ruby | KirillUsoltsev/rubylovo | /plaforms_controller.rb | UTF-8 | 483 | 2.546875 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | require "serialport"
require "websocket-eventmachine-client"
require "json"
serial = SerialPort.open("/dev/cu.usbmodem1431")
EM.run do
ws = WebSocket::EventMachine::Client.connect(:uri => "ws://0.0.0.0:1666")
ws.onopen do
puts "Connected"
end
EM.defer do
while data = serial.gets(";")
raw = data... | true |
e8744a8baa41e7e1ca756339b53190218b8dfbfe | Ruby | tayjohno/project-euler-ruby | /solutions/023.rb | UTF-8 | 1,944 | 3.6875 | 4 | [] | no_license | # frozen_string_literal: true
require './lib/taylor_math.rb'
#####################
# Problem 23 #
# ----------------- #
# Non-Abundant Sums #
#####################
class TwentyThree
def initialize(max = 28_123)
@max = max
end
def solve
a = (0..@max).to_a
i = j = 0
all_abundant_numbers = ... | true |
2623718ccd291ab100215b4102cedd4405543a6f | Ruby | bensek/Ruby-Programming | /Chapt3/solutions3.rb | UTF-8 | 2,129 | 4.40625 | 4 | [] | no_license | # [ CHAPTER 3 SOLUTIONS]
# 1. We can manipulate Strings with strings, integers with integers, floats with floats and integers with floats.
# 2.
puts "********************* ( 2 )***************************"
x = 5
y = 3
z = 8
c = x/y*z + y
puts "2) The value of c without parentheses is #{c}" # c = 11
c ... | true |
9537c1b1c3173c2145ddfca48125f01722d81e0b | Ruby | rajanjamu/codeastra | /problem10_v5.rb | UTF-8 | 551 | 4.15625 | 4 | [] | no_license | # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
# Find the sum of all the primes below two million.
# Remove multiples of 2,3,5,7...
limit = 200000
list = (2..limit).to_a
boolean = Array.new
(0...list.length).each do |item|
boolean << 1
end
(0...list.length-1).each do |i|
if (boolean[i] == 1)
prime = lis... | true |
14689e2e3b6a6f57e96455194d63c34bf9426422 | Ruby | ist420/ist420 | /app/models/client.rb | UTF-8 | 274 | 2.71875 | 3 | [] | no_license | class Client < ActiveRecord::Base
validates :name, presence: true
has_many :timestamps
validates :name, uniqueness: true
def sum_hours
sum = 0.0
self.timestamps.each {|t| sum += t.duration[:total]/60/60 }
sum.round(2)
end
end
| true |
897cdb3759cee2536a96d45443e174c23963a508 | Ruby | fishkel-truelogic/carrito | /carritoBack/item.rb | UTF-8 | 243 | 3.03125 | 3 | [] | no_license | require 'json'
class Item
attr_accessor :nombre
attr_accessor :precio
def initialize(nombre, precio)
self.nombre = nombre
self.precio = precio
end
def getJson()
return {:nombre => self.nombre , :precio => self.precio}.to_json
end | true |
d7b3e06bd9d3ad836fee9b47f1f4fdf514cea127 | Ruby | francisluong/zz_ruby_netdev_interaction | /scratch/030.secret.rb | UTF-8 | 148 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'highline/import'
secret = ask("What's your secret? "){|a| a.echo = false}
puts "I'm telling your secret: #{secret}"
| true |
d1bd1571422919b8bc65f6a1683cbae14b6a9299 | Ruby | matherton/depot | /app/helpers/store_helper.rb | UTF-8 | 668 | 2.96875 | 3 | [] | no_license | module StoreHelper
#attempt to convert $ to £ but did not work here - think changing app/locales/en.yml did
#number_to_currency(1234567890.50) > #=> $1,234,567,890.50 number_to_currency(1234567890.506) > #=> $1,234,567,890.51
#number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "") > ... | true |
221d4924e45b794669ec56d228c635bfecb973b1 | Ruby | nmbits/ruby-fiddle-fuse | /lib/ffuse/filesystem/abstract_filesystem.rb | UTF-8 | 3,174 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'ffuse/filesystem'
module FFUSE
module Filesystem
class AbstractFilesystem
def lookup(path)
if path == '/'
return root, "."
end
inode = root
name = nil
loop do
m = /\/([^\/]+)/.match path
name = m[1]
path = m.post_match... | true |
4aae4e8443be4fde353d3f0b0d43a343a564fe35 | Ruby | adorableio/cryptid.rb | /lib/cryptid/client.rb | UTF-8 | 939 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'json'
require 'excon'
module Cryptid
class Client
attr_writer :conn, :tracker_id
def initialize(options={})
@conn = options[:conn] if options[:conn]
if options[:tracker_id]
@tracker_id = options[:tracker_id]
else
@tracker_id = Cryptid.configuration.tracker_id
... | true |
580372cddca764beb5f6ea53ecd77ce3190e14e2 | Ruby | jimmy2822/niu-class-materia | /exercise/ex_1_group_by.rb | UTF-8 | 179 | 2.921875 | 3 | [] | no_license | people = { jimmy: 'teacher', bill: 'doctor', alex: 'doctor',
tina: 'driver', sam: 'singer', tim: 'actor', bob: 'singer' }
puts people.group_by { |k,v| v == 'singer' }
| true |
de2b2860479ef7c0855e2ecec896d9beedafe2bb | Ruby | jorgejuanp/ruby-testing-rspec | /lexiconomitron.rb | UTF-8 | 284 | 3.1875 | 3 | [] | no_license | class Lexiconomitron
def eat_t(input)
input.downcase.delete "t"
end
def shazam(input)
output = input.map do |word|
eat_t(word.reverse)
end
[output.first, output.last]
end
def oompa_loompa(input)
input.delete_if {|word| word.length > 3}
end
end
| true |
5560707337e62479c55c7515f80980fbd2120691 | Ruby | DevinPierce/emoticon-translator-nyc-web-060418 | /lib/translator.rb | UTF-8 | 757 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'yaml'
def load_library(file_path)
emoticons_raw = YAML.load_file(file_path)
translation_hash = {'get_meaning' => {}, 'get_emoticon' => {}}
emoticons_raw.each_pair do |meaning, emot_array|
translation_hash['get_meaning'][emot_array[1]] = meaning
translation_hash['get_emoticon'][emot_array[0]] = e... | true |
8a7772af2d43c2a6dbd592eef67b2dec1db60625 | Ruby | harrie429/ruby-challenges | /oop2.rb | UTF-8 | 584 | 3.65625 | 4 | [] | no_license | class Ferret
@@total_ferrets = 0
def initialize
@@total_ferrets += 1
end
def self.current_count
puts "there are currently #{@@total_ferrets} instances of my Ferret class."
end
def set_name=(ferret_name)
@name = ferret_name
end
def get_name
return @name
end
def owner_name=(owner_name)
@ow... | true |
06871580f12e6fbe476435024ed70c1462baacc5 | Ruby | kaktusyaka/marketing_opt_in_api | /lib/mark_opt_in_api.rb | UTF-8 | 1,247 | 2.703125 | 3 | [
"MIT"
] | permissive | require "mark_opt_in_api/version"
module MarkOptInApi
require 'httparty'
class Configuration
attr_accessor :host, :port
def initialize
self.host = 'localhost'
self.port = 3000
end
end
def self.configuration
@configuration ||= Configuration.new
end
def self.configure
yi... | true |
580926212d5681e0b45e83c93b1fd9e49b6226e8 | Ruby | kylebennett-sage/AdventOfCode2020 | /day_2.rb | UTF-8 | 3,368 | 4.0625 | 4 | [] | no_license | #day_2.rb
# --- Day 2: Password Philosophy ---
# Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via toboggan.
# The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wrong with our computers; we can't log in!" You ask if you... | true |
e7aa81792382d0ac08ce56f356d29790c94a503a | Ruby | jastack/toy_problems | /interview_prep/get_different_number.rb | UTF-8 | 2,548 | 4.3125 | 4 | [] | no_license | # Ok, this question comes from pramp
# Given an array arr of unique nonnegative integers, implement a function
#get_different_number that finds the smallest nonnegative integer that is NOT in the array.
# solve first for case when not allowed to modify the input arr, then when
# you can.
#
# Other notes:
# Not ordered... | true |
23ff3cbc37e6a5d37bcc4a3d07a8127a8c607328 | Ruby | mochetts/better_settings | /spec/better_settings/better_settings_spec.rb | UTF-8 | 3,984 | 2.875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'support/settings'
describe BetterSettings do
def new_settings(value)
Settings.new(value, parent: 'new_settings')
end
it 'should access settings' do
expect(Settings.setting2).to eq 5
end
it 'should access nested settings' do
expect(Settings.setting1.setting1_child)... | true |
f8a52a20cf75cc52d6e4582c7d4c703477cdb5bf | Ruby | BaobabHealthTrust/mnch-hotline | /application/app/helpers/report_helper.rb | UTF-8 | 9,968 | 2.59375 | 3 | [] | no_license | module ReportHelper
## The following functions will generate table cells for Tips Activity Report
def pregnancy_data_cell(content_type)
if (content_type.capitalize == "All" || content_type.capitalize == "Pregnancy")
content_type.capitalize == "Pregnancy" ? colspan = '4': colspan = '2'
table_cell... | true |
4ebdc2d3fc903fb9b93b00be12d7e37598f3b59d | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz61_sols/solutions/Joby Bednar/dice.rb | UTF-8 | 431 | 3.703125 | 4 | [
"MIT"
] | permissive | class Array
def to_dice
logic = [
lambda{|n| '+-----+ '},
lambda{|n| (n>3 ? '|O ' : '| ')+(n>1 ? ' O| ' : ' | ')},
lambda{|n| (n==6 ? '|O ' : '| ')+
(n%2==1 ? 'O' : ' ')+(n==6 ? ' O| ' : ' | ')},
lambda{|n| (n>1 ? '|O ' : '| ')+(n>3 ? ' O| ' : ' | ')}
]
str=''
5.times {|row|
self.eac... | true |
28b44bfa52a2782c4db06b645107229bb8e9b249 | Ruby | yuqiqian/ruby-leetcode | /111_min_depth_BT.rb | UTF-8 | 307 | 3.265625 | 3 | [] | no_license | def min_depth(root)
if root == nil
return 0
elsif root.left == nil && root.right == nil
return 1
elsif root.left == nil
return 1 + min_depth(root.right)
elsif root.right == nil
return 1 + min_depth(root.left)
else
return 1 + [min_depth(root.left), min_depth(root.right)].min
end
end
| true |
a5159f044e569c55a1a2c786a91a09657cad96c8 | Ruby | ElzMoore13/TwO-O-Player-Math-Game | /Question.rb | UTF-8 | 988 | 3.765625 | 4 | [] | no_license | class Question
def initialize(curr_player)
@curr_player = curr_player
@question
@correct_answer
@player_guess
end
def rand_num(min, max)
rand(max) + min
end
def make_question
num_1 = rand_num(1, 20)
num_2 = rand_num(1, 20)
if rand(10) % 2 == 0
operator = 'plus'
... | true |
50609c7c2c69ff7d090fc1b0202f853c2827a36d | Ruby | astrowalls/proyectos | /Ruby/prueba.rb | UTF-8 | 66 | 3.1875 | 3 | [] | no_license | puts"escriba un numero"
a = gets.chomp
a = a.to_i
3.times{puts a}
| true |
bf2302a191736aa2885bbf248f441055a7c40ee4 | Ruby | Progressbar/transactions | /lib/fio_bank_mail.rb | UTF-8 | 2,254 | 2.75 | 3 | [] | no_license | # encoding: utf-8
class FioBankMail < IncomingMail
def default
@data = parse_body @message.body.to_s.force_encoding('UTF-8')
@data[:raw] = ::Base64.strict_encode64(@message.to_s)
@data[:realized_at] = @message.date || DateTime.now
self
end
def data
@data
end
def income?
@message.s... | true |
1ba4660f496dbc7fad4ab08ddf0b23ca8d0692cf | Ruby | Sheikh-Inzamam/AppAcademy-1 | /w1d1/myeach.rb | UTF-8 | 140 | 3.515625 | 4 | [] | no_license | class Array
def my_each
self.count.times { |index| yield(self[index]) }
self
end
end
a = [1, 2, 3].my_each { |k| puts k }
p a | true |
2ade37194c2e1cf3a4c3470638d53f8b94b83058 | Ruby | simlegate/nebulas.rb | /spec/nebulas/account_spec.rb | UTF-8 | 2,057 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'base64'
RSpec.describe Nebulas::Account do
let(:private_key){
"3d55e39c7267b64cedce79519ff790c13e7d24f5ad17308a48a76cc9d5cf18de"
}
let(:address) {
"n1FJ17N3PxrCJkQ5Yj5pPktfde9QxZD9NkM"
}
let(:account) {
account = Nebulas::Account.new(private_key)
}
describe "#initialize" do
it "ge... | true |
9a733ee4ad47039b5d471981905a210de5436016 | Ruby | hswick/sandoz_demo | /example_sketches/demo1.rb | UTF-8 | 769 | 2.9375 | 3 | [] | no_license | defsketch do
n = 30
setup do
size 600, 600
@x = width / 2 + random(-width/4, width/4)
@y = height / 2 + random(-height/4, height/4)
range = (0..n).to_a
@vals = range.select { |n| n.even? }
@vals2 = range.select { |n| n.odd? }
end
r = 30
speed_x = 3
speed_y = 1
draw do
background 0, 0, 0
@v... | true |
aaedb3cf41dcc6cfbf51b3cfaca89faf60b38c19 | Ruby | amorobert/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 2,122 | 4.1875 | 4 | [] | no_license | #Release 1
#declare and populate an hash
students = {"Bob" => "Computer Science", "Caitlin" => "Political Ecology", "Anita" => "Interior Design"}
#iterate through hash with .each
students.each do |name, major|
puts name
end
#modify hash with .map
modified_students = students.map do |name, major|
major... | true |
98a0a67d824ad0b4f693b3e5b7f16601090a1308 | Ruby | ismcodes/tcpserver | /tcp_server_spec.rb | UTF-8 | 1,202 | 2.53125 | 3 | [] | no_license | require 'rspec'
require_relative 'tcp_server'
#require 'httparty'?
RSpec.describe "TCP implementation" do
before :all do
# will this just stay running? does it need to be threaded separately?
@tcp = IsaacTCP.new
# not server because @tcp has a server instance variable within
# @tcp.start
end
de... | true |
f97ab34ab7517d821e4b06f0965b7b60f0100223 | Ruby | mikerodrigues/rtcbx | /lib/rtcbx.rb | UTF-8 | 3,755 | 3.015625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'coinbase/exchange'
require 'rtcbx/orderbook'
require 'rtcbx/candles'
require 'rtcbx/trader'
require 'rtcbx/version'
require 'eventmachine'
class RTCBX
# seconds in between pinging the connection.
#
PING_INTERVAL = 2
# The Coinbase Pro product being tracked (eg. "BTC-USD... | true |
8df45780f9c39955bdffd93372eb57f901f36140 | Ruby | eturino/eapi | /lib/eapi/list.rb | UTF-8 | 4,174 | 2.625 | 3 | [
"MIT"
] | permissive | module Eapi
module List
include Comparable
include Enumerable
extend Common
module ClassMethods
def is_multiple?
true
end
end
def self.add_features(klass)
Eapi::Common.add_features klass
klass.extend(ClassMethods)
klass.include(Eapi::Methods::Properties:... | true |
3502594dcfb2139fde9a2f1d79d9bfa86dccb237 | Ruby | bdezonia/ian | /analyses/IDM.rb | WINDOWS-1250 | 2,692 | 2.90625 | 3 | [
"MIT"
] | permissive |
require InstallPath + 'AnalysisType'
require InstallPath + 'OutputSummary'
class Analysis
def initialize(engine,options,image,distUnit,areaUnit,args)
@image = image
@options = options
end
def run
backGround = -1
setting = @options.find("Background")
backGround = setting.dig_t... | true |
e1302444bcb37021f3d967bca2f59f77a6c1239f | Ruby | AllonsyThor/WDI | /happy_new_year.rb | UTF-8 | 123 | 3.21875 | 3 | [] | no_license | seconds_left = 10
while seconds_left > 0
puts(seconds_left)
seconds_left = seconds_left - 1
end
puts ("Happy New Year!") | true |
f2449622693521fc8303953cd55d68bb5cc11c4c | Ruby | oh2gxn/advent_of_code | /2019/spec/rocket_module_spec.rb | UTF-8 | 626 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../fuel_counter_upper'
RSpec.describe RocketModule do
let :subject { described_class.new(mass) }
context 'with mass of 14' do
let :mass { 14 }
it 'requires 2 units of fuel' do
expect(subject.fuel_required).to eq(2)
end
end
context 'with mass ... | true |
084a877b8636ca380accd1f0778d1cc7cb7933d6 | Ruby | hollyglot/code-exercises | /ruby-exercises/sketching_examples/product/ratings_calculation.rb | UTF-8 | 1,999 | 2.578125 | 3 | [] | no_license | require_relative '../sketches_init'
main_title 'Calculate Ratings'
log = Telemetry::MongoidLog
log.clear!
Benchmark.bmbm do |x|
x.report do
def update_rating(product)
rates = []
puts product.ratings.where(rater_type: 'Subscriber').to_a
puts "\n---------------------------------------------\... | true |
7ab5697f3d4191b5a6f5bba2201a19524f64f7b2 | Ruby | Linzeur/codeable-exercises | /week-4/day-1/Brayan/Miniassigment/Exercises4.rb | UTF-8 | 320 | 3.203125 | 3 | [] | no_license | class HolidayPriorityQueue
def initialize
@list = []
end
def addGift gift
@list << gift
@list.length
end
def buyGift
return "" if @list.length == 0
gift = @list.min {|val1, val2| val1["priority"] <=> val2["priority"]}
@list.delete_at(@list.index(gift))
gift["gift"]
end
end | true |
cef34f137f9b95ae7f556ec5637bd8dc0ae76090 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/4e98469217e547ad8c3285c2148f83aa.rb | UTF-8 | 207 | 3.125 | 3 | [] | no_license | class Hamming
def self.compute(strand_1, strand_2)
dif = 0
[strand_1.length, strand_2.length].min.times do |i|
dif += 1 unless strand_1[i] == strand_2[i]
end
return dif
end
end
| true |
2f8804ba08171d77c6aa5f959ed13a55c74a3786 | Ruby | kentakodama/aa_prep | /Methods/review.rb | UTF-8 | 18,938 | 4 | 4 | [] | no_license |
p "review these problems"
def FormattedDivision(num1,num2)
#float divide
quot = num1.fdiv(num2)
return "#{quot.to_s}" if quot < 1
num_array = quot.to_s.split(".")
decimal = num_array.last
integers = num_array.first.split("")
threes = []
while integers.length > 0
las... | true |
972cd68dae6f309021561cedcc2be81116182723 | Ruby | vrybas/git-pcheckout | /lib/git-pcheckout/handle_branch.rb | UTF-8 | 887 | 2.875 | 3 | [
"MIT"
] | permissive | class HandleBranch < Struct.new(:branch)
def initialize(branch)
self.branch = branch
end
def perform
if branch_exists_locally?
checkout_local_branch && pull_from_origin
else
fetch_from_origin && checkout_and_track_branch
end
end
private
def branch_exists_locally?
retur... | true |
c485e30c54cf4fc47bfc0c00cb8907858474e967 | Ruby | aliceFung/assignment_sinatra_blackjack | /helpers/blackjack.rb | UTF-8 | 2,233 | 3.578125 | 4 | [] | no_license | class Blackjack
attr_reader :game
SUITS= ["Hearts", "Clubs", "Spades", "Diamonds"]
def initialize(state = nil)
if state
@game = state
@deck = @game[0]
@hand = @game[1]
@dealer = @game[2]
else
@deck = generate_deck
@hand, @dealer = [], []
@game = [@deck, @hand, ... | true |
05177f1125c1314e5f465451404b87ecedeac6bc | Ruby | kitop/suntimes | /parse.rb | UTF-8 | 1,091 | 2.59375 | 3 | [] | no_license | require 'bundler'
Bundler.require(:parser)
require 'open-uri'
require 'nokogiri'
require 'oj'
city = ARGV[0] || 51 # Buenos Aires
year = ARGV[1] || Date.today.year - 1
url = "http://www.timeanddate.com/worldclock/astronomy.html?n=%{city}&month=%{month}&year=%{year}&obj=sun&afl=-11&day=1"
days = []
(1..12).each do... | true |
afc0529f8e59c52395b410abfab5fa64542118cc | Ruby | Ronalechat/wdi17-homework | /ron_tan/week_04/calculator.rb | UTF-8 | 2,329 | 4 | 4 | [] | no_license | def get_user_choice
puts "(+) - Addition"
puts "(-) - Subtraction"
puts "(*) - Multiply"
puts "(/) - Divide"
puts "(**) - Exponent"
puts "(sr) - Square root"
puts "(q) - Quit"
print "Enter your selection: "
selection = gets.chomp
# if selection = '+'
# calculate =
end
def addition
print "Wh... | true |
2c3ee4e803460f726b002ffcd69585b560b4d521 | Ruby | caueguedes/RubySandBox | /Metaprogramming Ruby 2/1.2 Mondeay The object model.rb | UTF-8 | 3,878 | 3.53125 | 4 | [] | no_license | ## Refinements
module StringExtensions
refine String do
def reverse
"esrever"
end
end
end
module StringStuff
using StringExtensions
"my_string".reverse # => "esrever"
end
# ##Method Execution
# class MyClass
# def testing_self
# @var = 10
# my_method()
# self
# end
#
# def my_m... | true |
a1425ff447feaddf6077caf97db05188c9361383 | Ruby | AnnaErshova/playlister-rb-web-0615-public | /lib/artist.rb | UTF-8 | 536 | 3.3125 | 3 | [] | no_license | class Artist
attr_accessor :name, :songs, :genres
@@artists = Array.new
def initialize
@songs = Array.new
@genres = Array.new
@@artists << self
end
def add_song(song)
@songs << song
@genres << song.genre
song.artist = self
song.genre.add_artist(self) unless song.genre == nil # ... | true |
ec0fbdd2704d043693d14d05db7a98c7f890a49f | Ruby | eregon/Classes | /math/fixnum.rb | UTF-8 | 676 | 2.75 | 3 | [] | no_license | class Fixnum
# Lazy evaluation for: n * lambda { do_something_expensive }
# Short-circuit if n == 0 (and then n is of course a Fixnum)
# This is of course a very bad idea to re-define Fixnum * ...
# alias :_old_mul :*
# def * o
# if Proc === o
# return 0 if self == 0
# self * o.call
# else... | true |
1d37a2a103c067092f7e65d6a8abe4e7dd17db47 | Ruby | Aldo510/Quora | /app/helpers/user.rb | UTF-8 | 320 | 2.65625 | 3 | [] | no_license | #Helpers para que sea mas facil saber que usuario esta en la session
helpers do
#Metodo para saber que usuario es
def current_user
if session[:user_id]
@current_user ||= User.find_by_id(session[:user_id])
end
end
#Metodo para saber si esta logeado
def logged_in?
!current_user.nil?
end
end | true |
0ce276a7e40335605084539573413dc8d4dbd1c5 | Ruby | sunatthegilddotcom/buildpacks-ci | /spec/lib/safe_execution_spec.rb | UTF-8 | 3,998 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # encoding: utf-8
require 'spec_helper'
require_relative '../../lib/safe_execution'
describe SafeExecution do
include described_class
before do
allow(SafeExecution::Exiter).to receive(:exit_now)
end
describe '#exit_with_message' do
it 'prints a message' do
expect { exit_with_message 'Oh noooo' ... | true |
48f1f8f2cb7d5efc5743dfc7bf6ebee5299733e9 | Ruby | jesslns/chitter-challenge | /lib/user.rb | UTF-8 | 2,022 | 2.953125 | 3 | [] | no_license | # require 'bcrypt'
require 'pg'
require_relative 'database_connection'
class User
attr_reader :id, :name, :email, :username, :password
def initialize(id:, name:, email:, username:, password:)
@id = id
@name = name
@email = email
@username = username
@password = password
end
def self.all
... | true |
088b56bb99c00f31e5ce75918965a842bc5f8f34 | Ruby | oggy/looksee | /lib/looksee/columnizer.rb | UTF-8 | 2,107 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Looksee
module Columnizer
class << self
#
# Arrange the given strings in columns, restricted to the given
# width. Smart enough to ignore content in terminal control
# sequences.
#
def columnize(strings, width)
return '' if strings.empty?
num_columns = ... | true |
5b1e4c5a264a7aa0ce149fbdf890f170307efa96 | Ruby | shwe-yuji/atcoder | /ABC161.rb | UTF-8 | 579 | 3.046875 | 3 | [] | no_license | # 問題1
nums = gets.split(" ").map(&:to_i)
nums[0], nums[1] = nums[1], nums[0]
nums[0], nums[2] = nums[2], nums[0]
puts "#{nums[0]} #{nums[1]} #{nums[2]}"
# 問題2
n, m = gets.split(" ").map(&:to_i)
vote = gets.split(" ").map(&:to_i)
rate = 1 / (4 * m).to_f
vote_all = vote.inject(:+)
border = rate * vote_all
judge = []
vot... | true |
d0e65bfd8e1930f195034a628e5dc6a9a7c003f7 | Ruby | johnisaac/notionhub | /lib/rating_logic.rb | UTF-8 | 3,991 | 3.390625 | 3 | [] | no_license | # ModuleName: RatingLogic
# Purpose: to be included in all the models which needs rating
# Created: 10/12/2010
# Author: John Felix
# Methods:
# => id_value
# => increase_rating(object_id, user_id)
# => decrease_rating(object_id, user_id)
# => insert_rating(object_id, user_id, rating, type_detail)
# => update_rating(o... | true |
f5d96a11113e3cfb0b579ca1fe03ccad9450f481 | Ruby | mouchtaris/rubylib | /util/refinements/deep_freeze.rb | UTF-8 | 972 | 3.015625 | 3 | [] | no_license | module Util
module Refinements
module DeepFreeze
extend Util::Refiner
# "Deeply" freeze this object by calling {#deep_freeze}
# on all instance variables, elements or values.
#
# @return this object frozen
refinement target: ::Object, as: :deep_freeze, method:
def deep_freeze_for_Object
for var in i... | true |
1fc23ce6b269e66c0caf1ce86fda8f68a1063ad1 | Ruby | gregDrizagit/oo-counting-sentences-web-103017 | /lib/count_sentences.rb | UTF-8 | 373 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
new_arr = self.split(" ")
arr = new_arr.select do |item|
item.end_with?("." , "?", "!")
end
arr.l... | true |
e2ff27301e9bc3352231aa4178c21c6785498f4f | Ruby | OneEyedEagle/EAGLE-RGSS3 | /Event System/呼叫指定事件.rb | UTF-8 | 13,677 | 2.671875 | 3 | [
"MIT"
] | permissive | #==============================================================================
# ■ 呼叫指定事件 by 老鹰(https://github.com/OneEyedEagle/EAGLE-RGSS3)
# ※ 本插件需要放置在【组件-通用方法汇总 by老鹰】之下
#==============================================================================
$imported ||= {}
$imported["EAGLE-CallEvent"] = "1.2.2"
#==========... | true |
4c3b7aa85883dc9b263fa104cc830995c4a42c59 | Ruby | ngodi/rest-client | /bing_search.rb | UTF-8 | 783 | 2.75 | 3 | [] | no_license | require 'rest-client'
class Bing
attr_accessor :search_query, :search_results
URL = "https://www.bing.com/search"
def initialize(search_query)
@search_query = earch_query
end
def remove_spaces
@search_query.gsub!(/\s/, '+')
end
def search
remove_spaces
@search_results = RestClient.get... | true |
5ece9a6f4c8b2270e1746a8de0a1975a8f809e1f | Ruby | Jacob-Brink/214 | /projects/08/script.rb | UTF-8 | 8,361 | 3.578125 | 4 | [] | no_license | Script started on 2020-04-15 17:04:04-0400
]0;jacob@DESKTOP-TMA4I98: ~/214/projects/08/ruby[01;32mjacob@DESKTOP-TMA4I98[00m:[01;34m~/214/projects/08/ruby[00m$ cat temp_tester.rb
# temp_tester.rb tests class Temperature and its operations
#
# Begun by: Dr. Adams, for CS 214 at Calvin College.
# Completed by: J... | true |
8124cef415699095ed51e18d72b7d4df317b1d12 | Ruby | mainangethe/learn-to-code-w-ruby-bp | /old_sections/float_methods.rb | UTF-8 | 231 | 3.1875 | 3 | [] | no_license | p 10.5.to_i
p 10.5
#floor method
p 10.5.floor
p 10.5.ceil
#round method
p 10.345.round(2)
p 10.34554.round
p 3.6.round
p 3.4.round
#abs method
# always going to be positive
#distance from zero
p 35.67.abs
p -10.abs
p 304.abs
| true |
c9fd546f7254f872d01e24dff8e8c201e8772b19 | Ruby | devery512/ruby_fun | /ruby_methods/classes.rb | UTF-8 | 3,937 | 4.125 | 4 | [] | no_license | class Dog
def initialize(name,health,stamina,strength)
@name = name
@health = health
@stamina = stamina
@strength = strength
end
def bark
puts "Woof Woof! The dog barks!"
@stamina -= 5
@strength += 3
end
def fetch
puts "The dog fetchs the ball"
@stamina -=7
end
end
class Fox
... | true |
b8bc13ae47d1a8e086b2b247858ec040363e06de | Ruby | votiakov/expert-octo-memory | /app/models/promotion.rb | UTF-8 | 955 | 2.6875 | 3 | [] | no_license | # == Schema Information
#
# Table name: promotions
#
# id :integer not null, primary key
# kind :string not null
# value :float
# code :string
# can_combine :boolean default(FALSE)
# quantity :integer
# created_at :datetime not null
# updated_... | true |
7fd5026db630d1561df480c1fd6f4ca9d9d1f398 | Ruby | mbarrins/module-one-final-project-guidelines-london-web-051319 | /app/models/event.rb | UTF-8 | 916 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Event < ActiveRecord::Base
has_many :user_events
has_many :users, through: :user_events
has_many :reviews
has_many :event_dates
belongs_to :segment
belongs_to :genre
belongs_to :sub_genre
def average_rating
(self.reviews.inject(0){|sum, review| sum + review.rating}/se... | true |
4571fdb41486696a0a43209563fc588b4db322d5 | Ruby | MaximeAlexandre/Exercism | /ruby/difference-of-squares/difference_of_squares.rb | UTF-8 | 261 | 3.734375 | 4 | [] | no_license | class Squares
attr_reader :square_of_sum, :sum_of_squares
def initialize(number)
@square_of_sum = (1..number).sum ** 2
@sum_of_squares = (1..number).map { |digit| digit ** 2 }.sum
end
def difference
square_of_sum - sum_of_squares
end
end | true |
8213ad7210c80ac5068ed898bab72f7c22c17077 | Ruby | muhenge/Tic-tac-toe | /lib/validation.rb | UTF-8 | 455 | 3.609375 | 4 | [] | no_license | class Validation
attr_reader :token
attr_accessor :user_input
def initialize
@user_input = user_input
@token = [1, 2, 3, 4, 5, 6, 7, 8, 9]
end
def valid?
(1..9).each do |x|
return true if x == @user_input
end
false
end
def avaliable?
%w[x o].each { |x| return false if @tok... | true |
c6e89e780ccb496068646fbb488ccae5fa059a5d | Ruby | mlainezb/G7-GuiaRuby | /Ejercicio3.rb | UTF-8 | 158 | 3.609375 | 4 | [] | no_license | # 3 Crear un método para eliminar todos los números pares del arreglo.
array = [1,2,3,9,1,4,5,2,3,6,6]
array.delete_if {|array| array % 2 == 0 }
puts array | true |
c0a10847c8b443eab3f92cb08e58eeb2742d7cfd | Ruby | KarlHeitmann/project-euler | /01-25/problema22-executor.rb | UTF-8 | 785 | 3.171875 | 3 | [] | no_license | require 'awesome_print'
require 'byebug'
require 'rubygems'
require 'json'
POSICIONES = { 'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13, 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => ... | true |
5e40c55e3ee8e78f866eedd57e748cbbc65298af | Ruby | keshav-c/algo | /basic-DS/07-balanced-brackets/main.rb | UTF-8 | 1,530 | 3.96875 | 4 | [] | no_license | class Node
attr_accessor :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
end
end
class Stack
attr_accessor :top
def initialize()
@top = nil
end
def push(bracket)
node = Node.new(bracket)
i... | true |
3426c55e95d23cca5265391b0b36dc0ed7ce7fb2 | Ruby | ninkibah/icu_ratings_app | /app/presenters/icu_ratings/war.rb | UTF-8 | 3,942 | 2.890625 | 3 | [
"MIT"
] | permissive | module IcuRatings
class WAR
Row = Struct.new(:player, :icu, :fide, :average)
def initialize(params)
@maximum = 50
@gender = params[:gender]
if params[:method] == "war"
@rating_weight = [0.2, 0.3, 0.5]
@type_weight = { icu: 0.6, fide: 0.4 }
else
@rating_weight ... | true |
3a3dfc0c0a8f6a577347bae549607182614c0cdc | Ruby | kapilchouhan99/boggle_game_rails_react | /app/controllers/boggle_controller.rb | UTF-8 | 1,223 | 2.640625 | 3 | [] | no_license | class BoggleController < ApplicationController
def index
end
def create
Score.create!(name: params[:name], score: params[:score])
end
def check_word
@response = DICTIONARY.include?(params[:word])
respond_to do |format|
format.json { render json: { response: @response } }
end
end
... | true |
aa9b6208ef97a90783f6e954d92174a151c70948 | Ruby | gregmoreno/lingpipe | /demos/tutorial/posTags/run_medpost.rb | UTF-8 | 1,705 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'lingpipe'
require 'java'
require 'pathname'
filename = Pathname(__FILE__).dirname + '../../models/pos-en-bio-medpost.HiddenMarkovModel'
model = Java::java.io.File.new(filename.to_s) # NOTE: Ruby file != java.io.File
hmm = LingPipe::AbstractExternalizable.readObject(model);
decoder = LingPipe::HmmDecoder.new(h... | true |
61f6ccf8f75cb5c1d8f0cfcdc41d8602ee636bed | Ruby | BetimShala/Algorithmic-Problem-Solving | /hackerrank/BirthdayChocolate.rb | UTF-8 | 421 | 3.125 | 3 | [] | no_license | def solve(n, s, d, m)
# Complete this function
counter=0
if n==s.length
for i in 0...s.length
res=[*s[i,m]].inject(:+)
if res==d
counter+=1
end
end
end
return counter
end
n = gets.strip.to_i
s = gets.strip
s = s.split(' ').ma... | true |
5612f5ed17f2d9f28f4b5eff1f42627671b06b0b | Ruby | ILYAKOINOV/Lesson24 | /app.rb | UTF-8 | 1,383 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
get '/' do
erb "Hello! <a href=\"https://github.com/bootstrap-ruby/sinatra-bootstrap\">Original</a> pattern has been modified for <a href=\"http://rubyschool.us/\">Ruby School</a>"
end
get '/about' do
@error = 'something wrong!'
erb :about
end
get... | true |
56be87080709ee85540bcf31501f553ce137bad9 | Ruby | amd61/week_2_day_1_homework | /specs/student_spec.rb | UTF-8 | 769 | 3.046875 | 3 | [] | no_license | require("minitest/autorun")
require ("minitest/rg")
require_relative ("../student")
class TestStudent < Minitest::Test
def setup
@daniel = Student.new("Daniel", 1)
@arlene = Student.new("Arlene", 12)
end
def test_student_get_name
assert_equal("Daniel", @daniel.student_name)
end
def test_studen... | true |
bc47413550bba536021ffa3c00dc28d3919f91e7 | Ruby | aliyamerali/ruby-exercises | /initialize/lib/monkey.rb | UTF-8 | 199 | 2.859375 | 3 | [] | no_license | class Monkey
attr_reader :name, :type, :favorite_food
def initialize(array_of_info)
@name = array_of_info[0]
@type = array_of_info[1]
@favorite_food = array_of_info[2]
end
end
| true |
58c23680754204cdeff135483f2634040e30edec | Ruby | ivanmalor/Nimgame | /lib/player.rb | UTF-8 | 1,556 | 3.625 | 4 | [] | no_license |
class Player
@@players = {}
attr_accessor :given_name, :family_name
attr_reader :username, :games_played, :games_won
def self.add
puts "\nEnter username\n\n"
username = gets.chomp
while username_exist?(username)
puts "\nThe player already exist. Please use a different username\n\n"
us... | true |
4f03374036a05179de475ccd25ff0bd9f606f5be | Ruby | ilkerinanc/voicev4 | /test/unit/survey_test.rb | UTF-8 | 649 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class SurveyTest < ActiveSupport::TestCase
def test_should_be_valid
assert !Survey.new.valid?
end
test "should not save survey without name" do
survey = Survey.new
survey.name = nil
assert !survey.save, "Saved the survey without a name"
end
test "should not save survey... | true |
91945491c2344aed0e42ed56e024c7c3d272649e | Ruby | eladmeidar/diakonos | /lib/diakonos/buffer-management.rb | UTF-8 | 1,684 | 2.53125 | 3 | [
"MIT"
] | permissive | module Diakonos
class Diakonos
attr_reader :buffer_current
# @param [Buffer] the Buffer to switch to
# @option opts [Boolean] :do_display
# Whether or not to update the display after closure
# @return [Boolean] true iff the buffer was successfully switched to
def switch_to( buffer, opts = {... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.