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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c7f0bea5d05c825ca0a43c19b3149c3643462798 | Ruby | kostyantyn/algorithms-ruby | /find_anagrams/spotlight.rb | UTF-8 | 980 | 3.109375 | 3 | [] | no_license | # encoding: UTF-8
class Spotlight
def initialize(word, file)
@file = file
@word = word
@chars = parse(word)
end
def parse(word)
word.each_char.inject({}) do |hash, char|
hash[char] = hash.has_key?(char) ? hash[char] + 1 : 1
hash
end
end
def seek
result = []
map... | true |
c6b35d5d79902102210f1b6c4071b9737a92cd5e | Ruby | libvips/ruby-vips | /lib/vips.rb | UTF-8 | 24,846 | 2.640625 | 3 | [
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"LGPL-2.1-or-later",
"MIT"
] | permissive | # This module provides an interface to the vips image processing library
# via ruby-ffi.
#
# Author:: John Cupitt (mailto:jcupitt@gmail.com)
# License:: MIT
require "ffi"
require "logger"
# This module uses FFI to make a simple layer over the glib and gobject
# libraries.
# Generate a library name for ffi.
#
#... | true |
0fe0b976f5fa5578e29950b7f4abfee9e0b16d7e | Ruby | egonSchiele/contracts.ruby | /lib/contracts.rb | UTF-8 | 8,583 | 2.859375 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require "contracts/attrs"
require "contracts/builtin_contracts"
require "contracts/decorators"
require "contracts/errors"
require "contracts/formatters"
require "contracts/invariants"
require "contracts/method_reference"
require "contracts/support"
require "contracts/engine"
require "cont... | true |
cdbe6294c2d5d6ed8c35241b7af9f87d7d3f5136 | Ruby | lilbake/tictactoe_app | /tictactoe/tictactoe_ruby/ttt_ai_game.rb | UTF-8 | 384 | 2.609375 | 3 | [] | no_license | require_relative "tictactoe_sai.rb"
require_relative "tictactoe_seq_sai.rb"
require_relative "human.rb"
def play_game (current_player, opponent, board)
move = current_player[:player_mode].get_move(board)
board = board_update(board, move -1, current_player[:marker])
if game_over?(board, current_player[:marker])
b... | true |
53eb9123524f710d933bcce1c010c7fc4584181a | Ruby | myYearOfCode/LaunchAcademy_Ignition | /infinite-questions/code.rb | UTF-8 | 161 | 3.515625 | 4 | [] | no_license | require 'pry'
input = nil
while input != "no"
puts('Can I get you anything? (type "no" to exit.)')
input = gets.chomp
binding.pry
end
puts("Okay, bye!")
| true |
354fa08061b6f1d97d587a0fcc7b379a6a17926b | Ruby | jcole356/app_academy_exercises | /w1d2/mixology.rb | UTF-8 | 375 | 3.390625 | 3 | [] | no_license | def remix(ingredients)
results = []
alcohols = []
mixers = []
ingredients.each do |pair|
alcohols << pair[0]
mixers << pair[1]
end
mixers.shuffle!
alcohols.each_with_index do |alcohol, i|
results << [alcohols[i], mixers[i]]
end
results
end
p remix([
["rum", "coke"],
[... | true |
d552ca3774fec443741a1c7993a9faeabb51e171 | Ruby | Hal9000/rubytext | /lib/color.rb | UTF-8 | 1,738 | 3.140625 | 3 | [] | no_license |
# Colors are 'global' for now
Black, Blue, Cyan, Green, Magenta, Red, White, Yellow =
:black, :blue, :cyan, :green, :magenta, :red, :white, :yellow
Colors = [Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]
# Handles color constants and fg/bg pairs
class RubyText::Color
Colors = ::Colors
# FIXME some s... | true |
51896fb4eb5433c20f561cd7dfa3a1236ef5bc0b | Ruby | mbrown78/LaunchSchool-Pre-Work | /exercises/ex_10.rb | UTF-8 | 169 | 2.828125 | 3 | [] | no_license | # hash values as arrays
hash = {countries: ['China', 'Australia', 'France']}
# array of hashes
array = [{country: 'China'}, {country: 'Australia'}, {country: 'France'}] | true |
9da1e846347a70a4dfdf12d0aebe0667853105ee | Ruby | xhan91/robot-app | /spec/18_robot_in_postion.rb | UTF-8 | 500 | 2.84375 | 3 | [] | no_license | require_relative 'spec_helper'
describe Robot do
before(:each) do
@@all_robots = []
end
describe "#Robot.in_position(x,y)" do
it "should return a list of robots in the position" do
robot1 = Robot.new
robot1.move_left
robot2 = Robot.new
robot2.move_left
expect(Robot.in_... | true |
ab014d3bd29f897a149977bfad929cf132f8a8a1 | Ruby | williamkeller/ld48-21 | /Escape.app/Contents/Resources/gosu/new.rb | UTF-8 | 2,331 | 2.765625 | 3 | [] | no_license | require 'gosu'
# Wrapper around Gosu 0.7 that provides the work-in-progress 0.8 interface
module Gosu
class Font
alias :initialize07 :initialize
def initialize *args
if args.first.is_a? Gosu::Window then
initialize07 *args
else
height = args[0]
options = args[1] || ... | true |
456f98b9b352f686034c16548981b246e0fccd6f | Ruby | scrabill/ruby-object-attributes-lab-online-web-pt-061019 | /lib/person.rb | UTF-8 | 190 | 2.765625 | 3 | [] | no_license | class Person
def name=(name) # Setter method
@name = name
end
def name # Getter/putter method
@name
end
def job=(job)
@job = job
end
def job
@job
end
end
| true |
d502dcb7bbf34604209b544e0a7c78f063b8191a | Ruby | JohnB/hairball | /sources/wordpress_archive_files.rb | UTF-8 | 1,414 | 3.0625 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
class WordpressArchiveFiles
attr_reader :year, :month, :day, :contents, :title
def self.sources(source_dir)
@@source_dir = source_dir
sources = []
year_format = File.join( File.expand_path(source_dir), '????')
Dir.glob(year_format).select {|y| y =~ /\d\d\d\d$/... | true |
6d2f4aa2940d137cb687d88462c5d25abd4a607b | Ruby | marcos-x86/AT04_API_test | /SergioNavarro/Session_02/Practice_05/Practice5_session3/practice.rb | UTF-8 | 1,244 | 3.984375 | 4 | [] | no_license | class Practice
#Some information about the program
puts "This program is for the conversion of seconds to minutes, hours and days"
#minute = 60
#hour = 3600
#day = 86400
def calculate
#The oerations to get the solution
print "Please insert the number of secods to conversion: "
seconds = gets.ch... | true |
8aeff27b7d24e2364fe3953f6e59bad18986674d | Ruby | IAlexKnight/Code | /Books/Understanding_Computation/FA/NFA_RE_v0.rb | UTF-8 | 4,825 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | require 'set'
class FARule < Struct.new(:state, :character, :next_state)
def applies_to?(state, character)
self.state == state && self.character == character
end
def follow
next_state
end
def inspect
"#<FARule #{state.inspect} --#{character}--> #{next_state.inspect}>"
end
end
class NFARul... | true |
1c79545e9f5485de9f33e4f820ea73847d1e275d | Ruby | mdaftab88/shortUrl | /app/models/short_url_g.rb | UTF-8 | 523 | 2.828125 | 3 | [] | no_license | class ShortUrlG < ApplicationRecord
after_create :generate_sort_url
private
def generate_sort_url
p self
short_url = get_short_url(self.id)
self.short_url = short_url
self.save
end
def get_short_url(id)
alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
temp = id
shor... | true |
ac001611517e9c23bf893f97f8a628c90829f6e8 | Ruby | runpaint/numb | /spec/numb/cubic_residue_spec.rb | UTF-8 | 939 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # coding: utf-8
describe Integer, "#cubic_residue?" do
# A096107
@seq = [
[1],
[1,2],
[1,3],
[1,2,3,4],
[1,5],
[1,6],
[1,3,5,7],
[1,8],
[1,3,7,9],
[1,2,3,4,5,6,7,8,9,10],
[1,5,7,11],
[1,5,8,12],
... | true |
b97f3f80188685582d096a93efa794ad120a31c3 | Ruby | maarf/advent-of-code-2019 | /3/1.rb | UTF-8 | 1,026 | 3.765625 | 4 | [] | no_license | require 'set'
lines = File.readlines('input.txt')
wires = lines.map { |l| l.split(',') }
def untangle(path)
points = Set.new
end_point = [0, 0]
path.each do |loc|
direction = loc[0]
distance = Integer(loc[1..-1])
case direction
when 'R'
(1..distance).each { |d| points.add([end_point[0] + d... | true |
045098e72c60045f31b426457b3d891f621d10b2 | Ruby | frogo123/tic-tac-toe-rb-bootcamp-prep-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,764 | 4.1875 | 4 | [] | no_license | # Helper Method
# Define display_board that accepts a board and prints
# out the current state.
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end... | true |
acb287748e3d5ecf2ae2b7867fc85eeaabe6f94c | Ruby | Shayane08/THP_EXO_JEUDI | /exo_09.rb | UTF-8 | 159 | 3.53125 | 4 | [] | no_license | puts("c'est quoi ton prenom stp?")
first_name = gets.chomp
puts("c'est quoi ton nom stp?")
last_name = gets.chomp
puts("Bonjour, #{first_name} #{last_name}") | true |
4a61b77dec3cb210fd815a1bf03f285a31550a94 | Ruby | ViolaCrellin/bank_tech_test | /lib/transaction.rb | UTF-8 | 421 | 3.171875 | 3 | [] | no_license | private
class Transaction
attr_reader :date, :type, :amount, :client_balance
def initialize(amount, type, client_balance)
@amount = amount
@type = type
@client_balance = client_balance
@date = Time.now
end
def make
credit? ? add : subtract
end
def credit?
type == :credit
end
... | true |
9ac2f7021860eca01fbe0914511a9b059e3e122d | Ruby | pbrudny/my_conference | /app/services/waiting_users/accept.rb | UTF-8 | 887 | 2.671875 | 3 | [] | no_license | module WaitingUsers
class Accept
def initialize(waiting_user)
self.waiting_user = waiting_user
end
def call
accept unless already_registered?
end
private
attr_accessor :waiting_user
def accept
WaitingUser.transaction do
user = create_user
waiting_user.... | true |
dae2f5d28c9a84532866f95e6b69b5d7b6e17ed2 | Ruby | csilva1/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 2,073 | 4.21875 | 4 | [] | no_license | #GPS 2.2 assignment pair with Jung
# Pseudocode:
# Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# store the grocery items into a data structure (Hash)
# set default quantity (do this when creating the hash)
# print the list to the console ... | true |
c57a64a71527ff329bea6f404566cfbf8516670c | Ruby | deeeki/bremen | /lib/bremen/mixcloud.rb | UTF-8 | 1,617 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'bremen/base'
module Bremen
class Mixcloud < Bremen::Base
BASE_URL = 'http://api.mixcloud.com/'
self.default_options = {
keyword: '',
limit: 20,
page: 1,
}
class << self
def find_url uid_or_url
if uid_or_url.to_s.include?('www.mixcloud.com')
... | true |
5faf53c75add5ad63fe66aa1834f2c81b64e66d9 | Ruby | wilson/nats | /bin/nats-sub | UTF-8 | 432 | 2.734375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'nats/client'
trap("TERM") { NATS.stop }
trap("INT") { NATS.stop }
def usage
puts "Usage: nats-sub <subject>"; exit
end
subject = ARGV.shift
usage unless subject
i = 0
NATS.on_error { |err| puts "Server Error: #{err}"; exit! }
NATS.start do
puts "Listening on ... | true |
53aeefdb9fe3648c91944ad80e37da5e24e8dfe4 | Ruby | Jayad25/CrackingCodeInterview | /subsets.rb | UTF-8 | 449 | 2.921875 | 3 | [] | no_license | def subsets(array)
return [[]] if array.empty?
subs = subsets(array.take(array.length - 1))
subs.concat(subs.map { |sub| sub + [array.last] })
end
def checksum(array,target)
p subset = subsets(array)
count = 0
subset.each do |sub|
count += 1 if sub.reduce(:*) == target
end
... | true |
8bc286dad4589ccc32ba9cefd5049914c593f1ec | Ruby | ENuge/strava_uploader | /strava.rb | UTF-8 | 6,316 | 3.171875 | 3 | [
"MIT"
] | permissive | #!/usr/local/bin/ruby
# ^ This assumes an installation of ruby 2.5.1
# at /usr/local/bin, which may not be true for you.
# But, you can always just run this manually via
# `ruby strava.rb`.
require 'json'
require 'ostruct'
require 'requests'
require 'tempfile'
require_relative './workout_templates'
require_relative '.s... | true |
7caf0e7643771d5b31e6cb48735aa718ddf0249f | Ruby | debugger1809/Classes_Objects_Variables | /Pascal.rb | UTF-8 | 654 | 4.09375 | 4 | [] | no_license | class Figures
def trianglePascal()
number = 0
while number < 1 or number > 11
puts "Insert a number..."
begin # try
number = Integer( ARGV[0])
rescue # catch
puts "It's not a number!"
end
end
for y in 0..number
for x in 0..y
val = factorial(... | true |
15a688ca94d84e72f5587d9c6f17e131f36a9a2e | Ruby | DougEisner/weather_underground | /api_calls/spotify_endpoints.rb | UTF-8 | 2,151 | 3.078125 | 3 | [] | no_license | require 'net/http'
require 'json'
require_relative 'in_memory_cache'
require_relative 'file_system_cache'
Spotify
https://api.spotify.com/v1
https://api.spotify.com/v1/artists/{id}/albums
https://api.spotify.com/v1/artists/{id}/top-tracks
/v1/artists/{id}/albums
/v1/artists/{id}/top-tracks
/v1/artists/{i... | true |
61314f4745fe4c7654a4b878c7d62abc4e4e5f23 | Ruby | abrahamsangha/to-do-app | /app/controllers/controller.rb | UTF-8 | 469 | 2.96875 | 3 | [] | no_license | require_relative '../../config/application'
class Controller
def run(option, entries = nil)
execute(option, entries)
end
def execute(option, entries)
case option
when "list"
Task.list
when "add"
Task.add(entries)
when "complete"
Task.complete(entries)
when "delete"
... | true |
d42b9eeb8c9c47ae1d2744ddd40aa213f17767f5 | Ruby | rina71/ruby-music-library-cli-v-000 | /lib/musicimporter.rb | UTF-8 | 328 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path, :files
path = './spec/fixtures/mp3s'
def initialize(path)
@path = path
@files
end
def files
@@all = Dir.glob(path + "/*.mp3").collect{|files| files.split(/\mp3s\//)[1] }
@@all
end
def import
files.each{|files| Song.create_from_filename(files)}
... | true |
310a0d1721ed875e65669d13eb13a2dda3d78c01 | Ruby | afide26/studio_game | /lib/loaded_die.rb | UTF-8 | 190 | 2.609375 | 3 | [] | no_license | require_relative 'auditable'
class LoadedDie
include Auditable
attr_reader :number
def roll
numbers = [1,1,2,2,5,6]
@number = numbers.sample
audit
@number
end
end | true |
1c33bcaa196eeca73e2dd20b2a9d12933343898e | Ruby | MarcoBgn/bolt-template | /app/models/utility/time_span.rb | UTF-8 | 654 | 3.078125 | 3 | [] | no_license | # frozen_string_literal: true
# Helper for time periods manipulation
class Utility::TimeSpan
attr_accessor :matches, :period
TIME_PERIOD_MAPPING = {
'd' => 'day',
'w' => 'week',
'm' => 'month',
'q' => 'quarter',
'y' => 'year'
}.freeze
def initialize(span)
self.matches = /(.+)(.)/.match... | true |
bb0c04d4456695ff72f2e30faefd4119d985d366 | Ruby | fatmaMY/my-each-re-coded-000 | /my_each.rb | UTF-8 | 155 | 3 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(collection) # put argument(s) here
# code here
n=0
while n < collection.length
yield(collection[n])
n=n+1
end
collection
end
| true |
4d4a62a507132eb811688ebbb07c36121d42a5b7 | Ruby | DaniyarKulmanov/Thinknetica2 | /Lesson_8/wagon.rb | UTF-8 | 637 | 2.96875 | 3 | [] | no_license | require_relative 'manufacturer'
require_relative 'accessors'
require_relative 'validation'
class Wagon
extend Accessors
include Manufacturer
include Validation
LENGTH_RULE = 'Длинна не должна превышать ='.freeze
HEIGHT_RULE = 'Высота не должна превышать ='.freeze
strong_accessor :wagon_length, class: 'In... | true |
6a76597b11ee4a9d746067c023d3114681e07d40 | Ruby | izaxveta/gilt_line | /app/models/venue.rb | UTF-8 | 1,465 | 3.15625 | 3 | [] | no_license | class Venue
attr_reader :name,
:categories,
:price,
:rating,
:review_count,
:phone,
:location,
:image_url
def initialize(data)
@name = data[:name]
@categories = get_categories(data[:categories])
... | true |
a0b17981a32cc3ea846c4b6abb6c84326f66a1ce | Ruby | mneumann/talks | /ruby_way_back_productivity/src/snippets/wikipedia_meta.rb | UTF-8 | 325 | 2.84375 | 3 | [] | no_license | require 'hpricot' # HTML parser
require 'open-uri' # treat any kind of URI like a file
NAME = readline.split.map{|i| i.capitalize}.join('_')
URL = "http://de.wikipedia.org/wiki/#{NAME}"
doc = Hpricot(open(URL).read)
(doc / "td.metadata-label").each {|e|
puts "#{e.inner_text.ljust(20)} #{e.next_sibling.inner_text... | true |
55a05b1627141205cb52e3074db7c222ef5ce533 | Ruby | rshiva/MyDocuments | /10-book-case/ruby1.9/samples/refcarray_37.rb | UTF-8 | 553 | 3.25 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
047100c81b44cf4a0b24706177c95c23698000ca | Ruby | BillMux/game-of-life-ruby | /lib/cell.rb | UTF-8 | 318 | 3.1875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'world'
# the cells within world, which can be dead or alive
class Cell
attr_accessor :alive
attr_reader :x_coord, :y_coord
def initialize(x_coord, y_coord)
@alive = false
@x_coord = x_coord
@y_coord = y_coord
end
def alive?
alive
end
end
| true |
14edb0a94edf963f9e55b5d9a3462a3fbbc73b7f | Ruby | JFVF/cucumber_022015 | /Vanessa/Session 8/singleton_two.rb | UTF-8 | 369 | 3.296875 | 3 | [] | no_license | =begin
Singleton second example
=end
class Base
def initialize
@value = 0
end
def any
@value = 10
end
def some
@value
end
end
def singleton_example
@singleton_example ||= Base.new
end
puts singleton_example.any
puts singleton_example.object_id
puts singleton_example.some
puts singleton_example.objec... | true |
29bdfe92865dd0aa6a5a882a6ab96be3f9f0ea99 | Ruby | AdamBaab/rubyday2 | /exo_12.rb | UTF-8 | 336 | 3.375 | 3 | [] | no_license |
today= 2021
puts "Quel age as-tu?"
userage = gets.to_i
userbirthdate = today - userage
f = -1
for i in userbirthdate..today
f += 1
if userage -f == f
puts " Il y a #{userage -f} ans , vous etiez à la moitié de votre age"
else
puts " Il y a #{userage -f} ans , tu avais #{f} ans"
... | true |
016346d519d0b585999d617ce04be389a815514a | Ruby | realtradam/ruby2d-camera | /lib/ruby2d/camera/text.rb | UTF-8 | 2,070 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Ruby2D
module Camera
# Wraps existing variables as well as adding new methods
# so that it can be handled by the Camera Module
# TODO: note that text could not be resized at the current iteration
# of Ruby2D so the math needs to be changed compensate for this.
... | true |
9b034224becfee2b633227958cf61e6b1894e8ad | Ruby | spencereldred/Adventure_mini_06 | /app/workers/get_adventures.rb | UTF-8 | 999 | 2.546875 | 3 | [] | no_license | require 'net/http'
class GetAdventures
include Sidekiq::Worker
sidekiq_options :retry => false
def perform (id)
begin
library = Library.find(id)
rescue
puts "oops Library not found"
puts "Library id : #{id}"
else
url = URI.parse(library.url "adventures.json")
... | true |
039389d922005455c0505b8047bcae348f7d4332 | Ruby | meyerhoferc/Sorting-Suite | /insertion_sort.rb | UTF-8 | 730 | 3.71875 | 4 | [] | no_license | class InsertionSort
def initialize
end
def sort(unsorted)
sorted = []
sorted << unsorted.shift
unsorted.length.times do
to_insert = unsorted.shift
sorted_index = 0
while sorted_index < sorted.length
if to_insert < sorted[sorted_index]
sorted.insert(s... | true |
82e737aae66c4f9cb6a35f02987a7d94c26e1826 | Ruby | makenai/Infosphere | /lib/infosphere/book.rb | UTF-8 | 2,251 | 2.84375 | 3 | [] | no_license | class Book
# Takes an Amazon::Response as an argument
def initialize( item )
data = {
:title => item.get_unescaped('ItemAttributes/Title'),
:author => item.get_unescaped('ItemAttributes/Author'),
:asin => item.get('ASIN'),
:isbn => item.get('ItemAttributes/ISBN'),... | true |
34d8dc41499fabe9b9f8789fad3a2ab4f0ee3a5d | Ruby | stp-che/timus | /lib/1027.rb | UTF-8 | 1,560 | 3.609375 | 4 | [] | no_license | class DPlusPlusProgram
ROOT_CTX = 1
OPENING_BRACE = 2
SENTENCE = 3
COMMENT = 4
COMMENT_STAR = 5
ERROR = 6
BRACE_OPEN = '('
BRACE_CLOSE = ')'
STAR = '*'
SENTENCE_ALPHA = /[=+\-*\/0-9]/
def initialize(source=nil)
@state = ROOT_CTX
@braces_depth = 0
validate(source) if source
end
... | true |
1558966852c8eaa575eaa625b0143e3d05c00408 | Ruby | benrugg/Tint-Website | /app/controllers/api_controller.rb | UTF-8 | 840 | 2.609375 | 3 | [] | no_license | class ApiController < ApplicationController
def create_random_gradient
# create a random gradient
api = Api.new
@gradient = api.create_random_gradient
# reverse the gradient (because the rgb wall is mounted facing away from the viewer)
@gradient.reverse!
# join the ... | true |
13b1dc8960e6c55ce61e4f097da21c304a5f0c4c | Ruby | tony-a/Blackjack | /Hand.rb | UTF-8 | 1,081 | 3.734375 | 4 | [] | no_license | require './Shoe'
class Hand
attr_reader :total_hand, :soft17
attr_accessor :cards, :stand, :bet, :bust
def initialize
@stand = false
@bust = false
@bet = nil
@cards = []
@stand = false
@soft17 = false #this is to be used by the dealer, so that he can hit on a soft 17
end
def display
result = '('
... | true |
35d375c0ebf6ba8bb8c799b3f63cb1245724aed3 | Ruby | hazenbrassy/ttt-7-valid-move-bootcamp-prep-000 | /lib/valid_move.rb | UTF-8 | 541 | 3.734375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # code your #valid_move? method here
def valid_move?(board, index)
if (index > 0 || index < 0)
puts "Invalid selection"
return false
elseif position_taken?(board,index)
puts "Position taken. Please select another"
return false
else
return true
end
end
# re-define your #position_taken? meth... | true |
df14ba2e40c4d8b9b3ab8fdd57935d62cb129b3a | Ruby | 4thAce/careercup | /memofactorial.rb | UTF-8 | 349 | 3.546875 | 4 | [] | no_license | # Factorial computation with memoization
class MemoFactorial
def initialize
@@memo = Hash.new
end
def fact(arg)
return 1 if arg == 1
raise ArgumentError if arg < 1
raise ArgumentError if !arg.is_a? Integer
return @@memo[arg] if @@memo.has_key?(arg)
@@memo[arg] = arg * fact(arg - 1)
... | true |
cfc70e27ba903b54b2890dd047beba0af7ce4414 | Ruby | JEG2/warehouse_keeper | /lib/warehouse_keeper/level.rb | UTF-8 | 2,302 | 3.296875 | 3 | [] | no_license | module WarehouseKeeper
class Level
LEVELS_FILE = File.join(__dir__, *%w[.. .. levels original_and_extra.txt])
module Empty
def contents; nil end
def has_player?; false end
def has_gem?; false end
end
class Void
include Empty
end
class Wall
include Empty
... | true |
161d6281d1038455a783a03e14e2f1abee9fcd0f | Ruby | ConcoMB/Multiparty | /silo_particle.rb | UTF-8 | 2,311 | 3.0625 | 3 | [] | no_license | class SiloParticle
attr_accessor :id, :r, :x, :y, :vx, :vy, :fx, :fy, :m
KN = 10 ** 5
KT = 0 # KN / 10
M = 0.01
G = - 10
def initialize(id, r, x, y, vx = 0, vy = 0, wall = false)
self.id = id
self.r = r
self.x = x
self.y = y
self.vx = vx
self.vy = vy
self.m = M
end
# Fn =... | true |
0eec1b53f6ad934e1cbae58c5b8fb6786c2f7359 | Ruby | kjkosmatka/makebelieve | /test/test_inference.rb | UTF-8 | 1,239 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'helper'
class TestInference < Test::Unit::TestCase
context "A Network" do
setup do
@n = Network.new do
attributes do
title "Wet Grass"
author "Kristopher J. Kosmatka"
date DateTime.now
end
variables do
boolean :cloudy
... | true |
2262dd6a994e86e2e12384cefd326fe7c38a7f9c | Ruby | darcy504/programming-univbasics-4-simple-looping-lab-den01-seng-ft-080320 | /lib/simple_loops.rb | UTF-8 | 526 | 3.6875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def loop_message_five_times(message)
count = 0
while count < 5 do
puts message
count += 1
end
end
def loop_message_n_times (message, limit)
count = 0
while count < limit do
puts message
count += 1
end
end
def output_array (array)
count = 0
while count < array.length do
puts a... | true |
dabb7fc486c829155997bdfbf7c4e7464e9b08f8 | Ruby | jtrim/mariner | /spec/navigation/helper_spec.rb | UTF-8 | 4,251 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Mariner
describe Helper, :type => :helper do
before do
Mariner.configure do
a_group do
root_path "A Thing!"
a_sub_group {}
end
end
end
after { Mariner.configuration = nil }
describe "#render_navigation" do
context... | true |
7b91abb1fbaaf520c3d877bf44b77f65ad2f9aa6 | Ruby | ossforumjp-app-IoT/rubyiot_mobile | /app/models/ServerLogin.rb | UTF-8 | 892 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | class ServerLogin
HTTP = 'http://'
LOGIN_URL = '/api/login'
def self.login(nextproc)
if $loginSession == nil
loginSession(nextproc)
else
nextproc.call(true)
end
end
def self.loginSession(nextproc)
if $loginSession != nil
nextproc.call(true)
end
if $settings.server... | true |
601981c074b1cb089209b7f56f2cc940425a3d78 | Ruby | dara-lillis/ada_selenium | /selenium_starter.rb | UTF-8 | 2,351 | 2.796875 | 3 | [] | no_license | # to get started: install selenium-webdriver gem
# gem install selenium-webdriver
# download geckodriver (geckodriver-v0.19.1-macos.tar.gz)
# from https://github.com/mozilla/geckodriver/releases
# and unzip it and place the binary file in /usr/local/bin
#
# This is the basic intro script from the official site.
# https... | true |
45d599e89817f0f00990374b4389e87149927c86 | Ruby | yasmineezequiel/Vanilla_Ruby | /Section_18_Classes_1/Accessor_Method.rb | UTF-8 | 1,151 | 3.90625 | 4 | [] | no_license | # Ruby has a built-in shortcut accessor method available for setter/writer and getter/reader.
# attr_accessor # method for setter/witer and getter/reader
# attr_reader # method for getter/reader
# attr_writer # method for setter/writer
# example:
class Cars
attr_accessor :model, :color
# The above attr_accessor... | true |
a4737fba0293ffc8a944368cc018b4bdbd92f90a | Ruby | amossefin/exercism | /ruby/hello-world/hello_world.rb | UTF-8 | 223 | 3.328125 | 3 | [] | no_license | class HelloWorld
BLANK_VALUE = HelloWorld.new
def HelloWorld.hello(name = BLANK_VALUE)
if BLANK_VALUE == name
"Hello, World!"
else
"Hello, #{name}!"
end
end
end | true |
d0c24eef66dcf7e08b97c4564e345b09906384d4 | Ruby | rafaelss/brdinheiro-lite | /lib/brdinheiro_lite/extenso_real.rb | UTF-8 | 1,849 | 2.953125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module ExtensoReal
include Extenso
# Escreve por extenso em reais.
#
# Exemplo:
# 1.por_extenso_em_reais ==> 'um real'
# (100.58).por_extenso_em_reais ==> 'cem reais e cinquenta e oito centavos'
def por_extenso_em_reais
ExtensoReal.por_extenso_em_reais(self)
end
# Alias ... | true |
03b5087bd2a9f171ad03590e490ba5236b0a624f | Ruby | eduardosasso/bullish | /Rakefile | UTF-8 | 3,235 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require './bullish.rb'
require './services/news/crawler'
require './services/twitter'
task default: %w[test]
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = 'test/**/*_test.rb'
t.warning = false
end
task :send_free_edition do
day = ARGV[1]
send_email(Bullish.fre... | true |
217bdc587940ae36758cce8b0c124e68a06798e1 | Ruby | nitindhar7/bucketread | /app/models/user.rb | UTF-8 | 1,716 | 2.546875 | 3 | [] | no_license | class User < ActiveRecord::Base
# ASSOCIATIONS
has_many :pages, :dependent => :delete_all
has_many :providers, :dependent => :delete_all
has_one :photo, :dependent => :delete
# FILTERS
before_save :encrypt_password
# ACCESS MODIFIERS
attr_readonly :password_salt, :password_hash
attr_accessor ... | true |
604b756405d232d9d00d4daaa15b7596cae68cdb | Ruby | shanebeehler/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 168 | 3.46875 | 3 | [] | no_license | def add(numb1, numb2)
numb1 + numb2
end
def subtract(numb1, numb2)
numb1 - numb2
end
def sum(array)
total = 0
array.each { |numb| total += numb }
total
end
| true |
6139ee3af91dbfd88c87b8cb20dcf6fdc259c1f5 | Ruby | sabinastoicescu/customer_relationship_application | /contacts.rb | UTF-8 | 541 | 3.0625 | 3 | [] | no_license | class Contact
attr_accessor: id,first_name, last_name,email,notes
def initialize(id, first_name, last_name, email, notes)
@id=id
@first_name=first_name
@last_name=last_name
@email=email
@notes=notes
end
def to_s
"#{@id}, #{@first_name}, #{@last_name}, #{@email}, #{@notes}"
end
def email
@email
end
de... | true |
8e0bfd8badba2fb7c595b5c9a1df29d34ade2bfa | Ruby | fhir-crucible/fhir_models | /spec/lib/fhir_models/fhir_spec.rb | UTF-8 | 21,302 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | RSpec.describe 'FHIR' do
describe '#primitive?(datatype: datatype, value: value)' do
subject { FHIR }
describe "datatype: 'boolean'" do
let(:datatype) { 'boolean' }
context 'return true when' do
let(:result) { true }
specify 'value = true' do
expect(subject.primitive?(da... | true |
309eda303d58d87ce99e181b9d7b88e71ab3c53c | Ruby | Format-X22/ai | /ai/Mind.rb | UTF-8 | 661 | 3.09375 | 3 | [] | no_license | require_relative 'Bond'
class Mind
attr_accessor :id, :word
def initialize
@id = nil
@word = nil
@bonds = {}
end
def update(mind, link_inc, group_inc, identity_inc)
link(mind, link_inc)
group(mind, group_inc)
identity(mind, identity_inc)
end
def link(mind, inc)
bond(mind).link(inc)
end
def gr... | true |
847257ec1f18c147185915d753a30162c587ea09 | Ruby | tylerc/to-the-exit-again | /game.rb | UTF-8 | 6,030 | 2.78125 | 3 | [
"Zlib"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
require 'dev/engine'
include Engine
class GameObject
def flicker
@@screen.draw_box_s([@x+rand(@width+8)-10, @y+rand(@height+8)-10], [@x+rand(@width+8), @y+rand(@height+8)], [0, 0, 0])
end
end
class Timer < Text
def initialize
super(:text => " ", :depth => ... | true |
f1a860e76507a60c3bb3f624ddb27929268ceabf | Ruby | subomionanuga/gilded-rose-noths | /ruby/spec/backstage_passes_spec.rb | UTF-8 | 1,121 | 3 | 3 | [
"MIT"
] | permissive | require "backstage_passes"
describe "Backstage passes" do
it "checks that quality increases by 1 if concert more than 10 days away" do
item = [BackstagePasses.new(15, 10)]
shop = GildedRose.new(item)
shop.update_quality
expect(item[0].quality).to eq(11)
end
it "checks that quality increases by ... | true |
70cb0acc93d0fc7b78d1e40da0eb02411c0f4e88 | Ruby | SolomonRFeldman/ck2-character-builder | /ck2-character-builder-server/app/models/culture.rb | UTF-8 | 3,482 | 2.609375 | 3 | [
"MIT"
] | permissive | class Culture
class << self
def all
{
"North Germanic": [
"Norse",
"Swedish",
"Norwegian",
"Danish"
],
"Central Germanic": [
"German",
"Lombard",
"Frankish",
"Suebi"
],
"West Germanic":... | true |
6b0bfb4e4617ccc2a9e7bcc7e31d4023013a384f | Ruby | tmaria17/sweater-weather | /spec/models/daily_weather_spec.rb | UTF-8 | 790 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
describe 'daily weather' do
before :each do
daily_data = {
"summary": "Mostly cloudy throughout the day.",
"icon": "partly-cloudy-night",
"time": 1547017200,
"temperatureHigh": 52.18,
"temperatureLow": 28.76,
"precipProbability": 0
}
@day_weather... | true |
57dc8dad19dd125ec49930d012d4e6ee7cc8f30b | Ruby | mansam/manageiq | /app/models/manageiq/providers/google/regions.rb | UTF-8 | 1,339 | 2.5625 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module ManageIQ
module Providers::Google
module Regions
# From https://cloud.google.com/compute/docs/zones
REGIONS = {
"us-east1" => {
:name => "us-east1",
:hostname => "us-east1",
:description => "Eastern US",
},
"us-central1" => {
... | true |
7ab3d3187acfc612b0b601c1f48fdba08da5e23d | Ruby | SasukeBo/wangbo-study | /ruby/programingRuby/Chapter3/eg_3_32.rb | UTF-8 | 751 | 3.609375 | 4 | [] | no_license | # Sometimes a class needs to provide methods that work without being tied to any particular object.
# We have already come across one such method.
# The new method creates a new Song object but is not itself associated with a particualr song.
# Class methods are distinguished from instance methods by their definition.
... | true |
4a188bd3c4243c4b37ea071d86457591886b6600 | Ruby | GeorgieGirl24/enigma | /lib/shift.rb | UTF-8 | 730 | 3.34375 | 3 | [] | no_license | class Shift
def self.squared_number(number)
(number.to_i * number.to_i)
end
def self.last_four_digits(number)
number.to_s[-4..-1].to_i
end
def self.find_offset(date)
last_four_digits(squared_number(date))
end
def self.key_values(key)
key.chars.each_cons(2).map do |numbers|
numbers... | true |
4abf9087cea7c4ff3c3fd8faf6f6ad4dd2bdcfb4 | Ruby | jonbrandenburg/BraveZealot | /test/build_gnu_map.rb | UTF-8 | 668 | 2.625 | 3 | [] | no_license | require(File.join(File.dirname(__FILE__), "..", "bzrequire"))
bzrequire('lib/map.rb')
bzrequire('lib/obstacle.rb')
module BraveZealot
f = Flag.new(Coord.new(100,100), 'green')
c1 = Obstacle.new([Coord.new(-150,-150), Coord.new(-100,-150), Coord.new(-100,-100), Coord.new(-150,-100)])
c2 = Obstacle.new([Coord.n... | true |
d8d72847e19aab0020520bb181257f71784c4779 | Ruby | ferocia/matchbot | /api/app/models/match.rb | UTF-8 | 3,631 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
class Match < ApplicationRecord
belongs_to :game
has_many :results
has_many :rating_events
has_many :teams, through: :results
has_many :players, through: :teams
def calculate_ratings_for_players!
# if this match has rating events, we don't want to re-calc
return if r... | true |
ae6edefd072356817521a62bf09462dd62c00a3d | Ruby | Uthaeus/exercises | /exercism/sieve.rb | UTF-8 | 149 | 3.328125 | 3 | [] | no_license |
def sieve num
arr = (2..num).to_a
x = 0
arr.each do |i|
if i % arr[x] == 0
i.delete
end
x += 1
end
arr
end
sieve(200) | true |
cf6990294aacc81ae82aa1ba84dcbce565a100fd | Ruby | bcjordan/ruby-bits | /ruby-bits-1/blocks.rb | UTF-8 | 194 | 3.21875 | 3 | [] | no_license | def call_this_block_twice
yield
yield
end
call_this_block_twice { puts "twice" }
def call_this_block
block_result = yield "foo"
puts block_result
end
call_this_block { |arg| arg.reverse } | true |
a6db85246d33594ebccca552c2633caeeba5feef | Ruby | rolme/molotov | /mission.rb | UTF-8 | 1,379 | 2.984375 | 3 | [] | no_license | class Mission
attr_reader :tasks, :require_to_fail, :number_of_operatives, :votes, :number_of_players
def initialize(number_of_operatives, number_of_players, require_to_fail=1)
@number_of_operatives = number_of_operatives
@number_of_players = number_of_players
@require_to_fail = require_to_fail
@vot... | true |
00e4b431a4e9c654b87a5a4feae6dd6f1e8c6485 | Ruby | ranjanin21/vow | /app/models/tax.rb | UTF-8 | 901 | 2.546875 | 3 | [] | no_license | class Tax < ActiveRecord::Base
#before_save :tax_type_with_rate
before_save :tax_name_upcase
before_save :generate_tax_type_of_tax
belongs_to :usercategory
belongs_to :user
belongs_to :authuser
# has_many :bills
#has_one :line_item
has_many :bill_taxes
has_many :line_items, through: :bill_taxes... | true |
44df857250a3cc9df84aa4550cdae25e3f2b0402 | Ruby | karabitski/dma-watcher | /watcher.rb | UTF-8 | 1,618 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require './config/environment.rb'
output = [
{id: 1, name: "CouchBase", country: "USA", website: "http://couchbase.com/"},
{id: 2, name: "Ffifty One", country: "USA", website: "http://fiftyone.com/"},
{id: 3, name: "Forsythe", country: "USA", website: "http://forsythe.com/"}
]
accounts = out... | true |
b5697b7e80626f9aa57181534e66f51d98e105ab | Ruby | fw42/projecteuler | /files/271.rb | UTF-8 | 443 | 3.171875 | 3 | [] | no_license | #!/usr/bin/ruby
def eea(a,b)
return a,1,0 if b == 0
d,s,t = eea(b, a % b)
return d, t, s - (a/b) * t
end
ps = [2,3,5,7,11,13,17,19,23,29,31,37,41,43]
n = ps.inject(1){ |a,b| a*b }
xs = ps.map{ |p| [*0..(p-1)].select{ |x| x**3 % p == 1 } }
s = ps.map{ |p| g, r, s = eea(p,n/p); s*(n/p) }
puts xs.first.product(*xs.d... | true |
7c3027f3f7744b5f395c4d92d8aed0ca6252637e | Ruby | gost-serb/lora_device_lib | /bindings/ruby/lib/ldl/radio.rb | UTF-8 | 3,930 | 2.59375 | 3 | [
"MIT"
] | permissive | module LDL
class Radio
include LoggerMethods
attr_accessor :broker, :mac, :active
attr_reader :buffer
def initialize(mac, broker)
raise "SystemTime must be defined" unless defined? SystemTime
@broker = broker
@mac... | true |
428fda685cfeb490197d5610764c87c7d9aecaf1 | Ruby | mameneses/bw_sos | /app/helpers/product_helper.rb | UTF-8 | 397 | 2.8125 | 3 | [
"MIT"
] | permissive | module ProductHelper
def format_price (number)
if number.to_s.size >= 2
number.to_s.insert(-3,".")
elsif number.to_s.size >= 5
number.to_s.insert(-3,".").insert(-5,",")
else
number
end
end
def format_discount (decimal)
if decimal == 0 || decimal == nil
"None"
else... | true |
b5a76a5e439006dbe96d27aff6d0113ccd1ea30c | Ruby | s4kr4/sns | /spec/models/user_spec.rb | UTF-8 | 2,170 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe "User model" do
before do
@user = User.new(name: "testuser",
email: "testuser@example.com",
password: "password",
password_confirmation: "password")
end
context "... | true |
6935bc9599d20068d3eb97a931e8de3c437a0aee | Ruby | Sweex99/Study_Ruby | /test_split.rb | UTF-8 | 113 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
str = 'block.bl'
puts str.split('.').first;
if str.split('.').last == 'bl'
puts 'Nice';
end | true |
53c449a1974d245870a89853a55c534dd9d50618 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/c7bc34249f924195823e46953d9b23b2.rb | UTF-8 | 450 | 3.34375 | 3 | [] | no_license | class Bob
def hey(input)
if input.gsub(" ", "") == (" ")
response_to_silence
elsif input == input.upcase
response_to_shouting
elsif input.end_with? ("?")
response_to_question
else
"whatever"
end
end
end
def response_to_silence
puts "Fine. Be that way!"
end
def response_to_shouti... | true |
8e027ddbfec2411f824c3184054a8d5e627d1487 | Ruby | famished-tiger/Macros4Cuke | /lib/macros4cuke/coll-walker-factory.rb | UTF-8 | 3,738 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
# File: coll-walker-factory.rb
# Purpose: Implementation of the CollWalkerFactory class.
require_relative 'macro-collection'
module Macros4Cuke # Module used as a namespace
# A Coll(ection)WalkerFactory object is a factory that creates
# an enumerator that itself walks in the passed ma... | true |
a8c8463cda7a5d85fb9a0e402cbc4b52464cf61f | Ruby | rdcsg/fizz_buzz | /spec/fizz_buzz_spec.rb | UTF-8 | 477 | 3.375 | 3 | [] | no_license | # spec/fizz_buzz_spec.rb
require './lib/fizz_buzz'
describe 'fizz_buzz' do
it 'returns "1" if number = 1' do
expect(fizz_buzz(1)).to eq 1
end
it 'returns "fizz" if number is dividable by 3' do
expect(fizz_buzz(3)).to eq "fizz!"
end
it 'returns "buzz" if number is dividable by 5' do
exp... | true |
41f354c904c9d0cbb5169ffd38803578e7d15d2d | Ruby | cjhdev/dlms_trouble | /lib/dlms_trouble/cosem_method_descriptor.rb | UTF-8 | 681 | 2.671875 | 3 | [
"MIT"
] | permissive | module DLMSTrouble
class CosemMethodDescriptor
attr_reader :classID, :instanceID, :methodID
def self.decode(input)
classID = input.read(2).unpack("S>")
instanceID = OBIS.decode(input)
methodID = input.read(1).unpack("c")
self.new(classID, instanceID, ... | true |
08d2534ed7184225219ce0ff194984cc8ff161dc | Ruby | ananace/serial_crack | /lib/serial_crack/backends/range.rb | UTF-8 | 939 | 2.703125 | 3 | [
"MIT"
] | permissive | module SerialCrack::Backends
class Range
def initialize(options = {})
ranges = options[:range]
@combined = ranges.map(&:to_a).join
@cur_index = 0
# TODO?
@min_length = 0
@max_length = 0
@current = [options[:start] || @combined[0]]
end
def current
@curren... | true |
50e3ff815bd9e9eef75e3ea7257c3f58f78615c3 | Ruby | giozerias/student_shuffle | /10.20_question1.rb | UTF-8 | 346 | 3.59375 | 4 | [] | no_license | puts "Your name please"
name = gets.chomp.downcase
arr_students = ["Giovanna", "Geraldine", "Eagle", "James", "Stefanie"]
arr_teachers = ["Aaron", "Richard", "Mandy", "Melissa"]
if arr_students.include?(name)
puts "Keep studing #{name}"
elsif arr_teachers.include?(name)
puts "Time to get goin' #{name}"
else
p... | true |
d72faa4a2362b88e4ce7433bd3041ebfea0f291f | Ruby | dougpotter/controlcenter | /branches/backend/app/models/job.rb | UTF-8 | 3,886 | 2.78125 | 3 | [] | no_license | # == Schema Information
# Schema version: 20101220202022
#
# Table name: jobs
#
# id :integer(4) not null, primary key
# type :string(255) not null
# name :string(255) not null
# parameters :text not null
# created_at :datetime not null
# status :... | true |
2b90113d8d797b21a173ea202d021f5772c5f704 | Ruby | Softmatech/sql-crowdfunding-lab-noukod-000 | /lib/sql_queries.rb | UTF-8 | 1,654 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
76049a85e3735d2dea74bdf6a02d2b05036d4df1 | Ruby | richardxia/rag | /lib/auto_grader.rb | UTF-8 | 2,490 | 2.9375 | 3 | [] | no_license | class AutoGrader
class AutoGrader::NoSuchGraderError < StandardError ; end
# ==== Attributes
# textual feedback from the autograder on the student's answer
attr_accessor :comments
# errors running the autograder, if any; else nil
attr_accessor :errors
# identifier of question being graded
attr_access... | true |
56cda59ace7227f66e086578ce68301f6f4e70c2 | Ruby | Emilie-D/Decouverte_Ruby | /exo_04.rb | UTF-8 | 111 | 2.796875 | 3 | [] | no_license | puts "Salut, ça farte ?"
#Le programme ne fonctionnait pas car il manquait un guillemet à la fin de la ligne | true |
717ab81004f5354e33ce90fc2500c4dc95c99753 | Ruby | bmarini/knife-inspect | /lib/health_inspector/checklists/base.rb | UTF-8 | 4,509 | 2.609375 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'pathname'
require 'ffi_yajl'
require 'parallel'
require 'inflecto'
module HealthInspector
module Checklists
class Base
include Color
class << self
def title
Inflecto.humanize(underscored_class).downcase
end
end
def self.run(knife)
... | true |
98dfcf77b51a22c3a90f740042823ee1bf38fe88 | Ruby | Themichaelreimer/dnd_app | /app/helpers/application_helper.rb | UTF-8 | 2,619 | 3.53125 | 4 | [] | no_license | module ApplicationHelper
# TODO: Make eval_expr helper methods private.
# Keep roll, valid_expr, and eval_expr public
def valid_expr?(str)
# TODO: Check that brackets match up
!(/[0-9\+\-d*x\(\)]/=~str).nil?
end
def is_number?(char)
!(/\d/=~char).nil?
end
def is_operator?(char)
!(/[\+\... | true |
7cb750854e963d7b10ad1901513d898444dcd6e5 | Ruby | vladigonzalez/PruebaRuby1 | /pruebaruby1.rb | UTF-8 | 5,063 | 3.25 | 3 | [] | no_license | # pruebaruby1.rb
NOTA_BASE = 5
# ejercicio
# Creo archivo con promedio
def creoarchivo(nom,promedio)
file = File.open("#{nom}", 'w')
file.puts promedio
file.close
end
def creoarchivonotas(hs)
file = File.open('notas.txt', 'w')
hs.each{ |key , val| file.puts "Alumno: #{key} Nota: #{val}"}
file.close
end
d... | true |
d315bb5c60b9db22e496c4447e61d8587e9dd507 | Ruby | kminevskiy/ruby-exercises | /reverse_vowels.rb | UTF-8 | 131 | 3.4375 | 3 | [] | no_license | # @param {String} s
# @return {String}
def reverse_vowels(s)
vowels = s.scan(/[aioue]/i)
s.gsub(/[aioue]/i) { vowels.pop }
end | true |
3656abce7f95457c2fc99dee1c71d811f74d6ff8 | Ruby | mrjris/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 814 | 3.75 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum(array)
array.inject(0, :+)
end
def max_2_sum(array)
sum(array.sort.last(2))
end
def sum_to_n?(array, n)
return false if array.empty? && n.zero?
array.combination(2).any? { |a, b| a + b == n }
end
# Part 2
def hello(name)
"Hello... | true |
5abb8d6b914222b36b54c04e26093ca1b450df16 | Ruby | harrika/learn_ruby | /06_timer/timer.rb | UTF-8 | 163 | 3 | 3 | [] | no_license |
class Timer
attr_accessor :seconds
def initialize
@seconds = 0
end
def time_string
Time.at(@seconds).utc.strftime("%X")
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.