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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c305a979b572f811576120caee56a232751a9d3d | Ruby | snakerabbit/W2D1 | /skeleton/chess/display.rb | UTF-8 | 832 | 3.5 | 4 | [] | no_license | require 'colorize'
require_relative 'board'
require_relative 'cursor'
class Display
def initialize (board)
@board = board
@cursor = Cursor.new([0,0], board)
end
def build_grid
@board.grid.each.map.with_index do |row, i|
build_row(row, i)
end
end
def build_row(row, i)
row.map.wit... | true |
4809d1e399cc1871ef8d69219b180cf56091f458 | Ruby | odelevingne/booking | /spec/seat_spec.rb | UTF-8 | 339 | 2.75 | 3 | [] | no_license | require 'seat'
describe 'Seat' do
let(:seat) { Seat.new }
let(:booked_seat) { Seat.new.book! }
it 'is empty when created' do
expect(seat).not_to be_booked
end
it 'can be booked' do
expect(booked_seat).to be_booked
end
it 'can be unbooked' do
booked_seat.unbook!
expect(seat).not_to b... | true |
ea7ca98e0685197f3106ebe8fa9a32dd3b05e1a8 | Ruby | jj54321/playlister-sinatra-v-000 | /.bundle/gems/httpclient-2.5.3.3/bin/jsonclient | UTF-8 | 2,834 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain",
"Ruby"
] | permissive | #!/usr/bin/env ruby
# httpclient shell command.
#
# Usage: 1) % httpclient get https://www.google.co.jp/ q=ruby
# Usage: 2) % httpclient
#
# For 1) it issues a GET request to the given URI and shows the wiredump and
# the parsed result. For 2) it invokes irb shell with the binding that has a
# HTTPClient as 'self'. ... | true |
d6333686c7f62b2f26112843509ddf78020f52f6 | Ruby | suhlig/wordclock | /exe/wordclock | UTF-8 | 810 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'word_clock/clock_24'
require 'word_clock/xkcd_color_sampler'
require 'word_clock/color_picker'
require 'faderuby'
if ARGV.size.zero?
time = Time.now
elsif ARGV.size == 1
time = Time.parse(ARGV.first)... | true |
bb89b52f3a2aac110decb5eebb024e9a919be40c | Ruby | scel-hawaii/control-tower | /jobs/status_report/status_report.rb | UTF-8 | 2,239 | 2.859375 | 3 | [] | no_license | # Status report of the current REIS services
require 'pg'
require 'active_support/all'
require 'pp'
class SensorReport
def initialize()
end
def execute_database(command)
conn = PGconn.open(:host=> 'localhost', :dbname => 'control_tower', :user=>'control_tower', :password=>'password')
res = conn.exe... | true |
eabd0daa38c14eb8b273582a5b01d71215c731c3 | Ruby | patrickhidalgo/lrthw_exercises | /chapter_4/ex4.rb | UTF-8 | 1,182 | 3.75 | 4 | [] | no_license | #!/usr/bin/env ruby
# This defines the variable cars to equal 100.
cars = 100
# This defines the variable space_in_a_car to equal 4.0.
space_in_a_car = 4.0
# This defines the variable drivers to equal 30.
drivers = 30
# This defines the variable passengers to equal 90.
passengers = 90
# This defines the variable cars_... | true |
792ba0e7b917bbda6832583a77eba25bc4489d1c | Ruby | tatscru/ruby-puppy-online-web-pt-102218 | /lib/dog.rb | UTF-8 | 792 | 3.984375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
# attr_reader :name
@@all = []
# here we are gathering a list of dog names
def initialize(name)
@name= name
@@all << self
# self is referred to the name being passed through
end
# def bark
# puts "woof"
# # example that if you put dog.new the only method linked to the ne... | true |
8f83398d82787725e8ba35b8a48981526a24f5a4 | Ruby | Enoch2k2/120919-ft-object-initialize-and-properties | /lib/character.rb | UTF-8 | 2,324 | 4.1875 | 4 | [] | no_license | require 'pry'
# In Ruby, the `self` keyword is a reference to the current context object
# In Ruby, inside a method, the `self` keyword is a reference to the receiving object
# In Ruby, inside a method, the `self` keyword is a reference to the object the method was called on
# In Ruby, inside an INSTANCE method, the `s... | true |
58a22bcef17e36588f76edfbff844b1b7ceaf0a7 | Ruby | keithyow/code-katas | /day9.rb | UTF-8 | 217 | 3.40625 | 3 | [] | no_license | def TimeConvert(num)
# code goes here
hours = num.to_i/60
mins = num.to_i%60
return hours.to_s + ":" + mins.to_s
end
# keep this function call here
puts TimeConvert(STDIN.gets)
| true |
b7c51c9f9468562489c8dbaaef1c5d267fc205b2 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/74ffff50a7fe438580e92dbac67278b6.rb | UTF-8 | 546 | 3.4375 | 3 | [] | no_license | class Anagram
def initialize word
@word = word.to_s.downcase
end
def match word_list
filter_anagrams word_list
end
private
def is_anagram? anagram
@word != anagram && sorted_word == sort_string(anagram)
end
def sorted_word
@sorted_word ||= sort_string(@word)
end
def downc... | true |
d3e367583c791895a025c5205fe4e379c57cd67f | Ruby | roger-sge/ruby_exercises | /hours_in_a_year.rb | UTF-8 | 252 | 4.03125 | 4 | [] | no_license | # figuring out hours in a year
def hours_in_a_year(leap=false)
days_in_a_year = 365
if leap
days_in_a_year = 366
puts "it's a leap year!"
end
hours_in_a_day = 24
return days_in_a_year * hours_in_a_day
end
puts "#{hours_in_a_year()}" | true |
2ce5f2d1a592f96b48e16e09eac2bc0e5b986841 | Ruby | kasumi8pon/atcoder_practice | /abc/102/b.rb | UTF-8 | 111 | 2.890625 | 3 | [] | no_license | n = gets.to_i
a = gets.split(" ").map(&:to_i)
abs_a = a.map(&:abs)
answer = abs_a.max - abs_a.min
puts answer | true |
9ff3140b8ff3c17a2e6ebe671827c884403806d6 | Ruby | nctruong/ruby_advanced | /advanced/Logging.rb | UTF-8 | 1,241 | 3.234375 | 3 | [] | no_license | require 'logger'
class Logger
@@instance = Logger.new("mylog.txt")
def self.instance
@@instance
end
module Severity
# Redefine Constant by using self.class:: syntax
self.class::DEBUG = 0
self.class::INFO = 1
self.class::WARN = 2
self.class::ERROR = 3
self.class::FATAL = 4
WILL = ... | true |
438950cdd0bc2d99230c5e4e0d9b88e63a7a3865 | Ruby | Thiago-Cardoso/devportifolio | /app/validators/date_interval_validator.rb | UTF-8 | 605 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | class DateIntervalValidator < ActiveModel::Validator
def validate(record)
@record = record
if @record.start_date.present?
validate_future_start_date
validate_start_date_after_end_date if @record.end_date.present?
end
end
private
def validate_future_start_dat... | true |
7dfe543b22c1a46688083a05cf8d9da4e4d9ff97 | Ruby | agorf/adventofcode | /2015/02/2.rb | UTF-8 | 146 | 2.9375 | 3 | [] | no_license | sum = $stdin.reduce(0) do |sum, line|
l, w, h = line.chomp.split('x').map(&:to_i)
sum + [2*(l+w), 2*(w+h), 2*(h+l)].min + l*w*h
end
puts sum
| true |
70847a30b3af30d5cb4a2dd83c6f7b88ad1c5273 | Ruby | edev/cs510-analytics-in-data-science | /app/round_1.rb | UTF-8 | 10,617 | 2.953125 | 3 | [] | no_license | require 'sinatra/base'
class Round1 < Sinatra::Base
get '/round_1/index.html' do
erb :'round_1/index.html'
end
get '/round_1/all_meals.js' do
meals = CouchDB::get(CouchDB::uri("_design/round_1/_view/all_meals"))
meals = meals[:rows]&.map do |obj|
# obj is a Hash with the following keys:
... | true |
6bf48e0b3aa7035d2557b11b7352769277246e1b | Ruby | hsyubon/demo | /int.rb | UTF-8 | 220 | 3.796875 | 4 | [] | no_license | def call_block(&block)
block.call(1)
block.call(2)
block.call(3)
end
proc_1 = Proc.new { |i| puts "#{i}: Blocks are cool!"}
proc_2 = lambda { |i| puts "#{i}: lambda are cool!"}
call_block(&proc_1)
call_block(&proc_2) | true |
ed87e9650449b66d85c8690499103b16c464280b | Ruby | mfilej/rubytapas-dl | /lib/rubytapas-dl/download_progress_notifier.rb | UTF-8 | 484 | 2.9375 | 3 | [] | no_license | # encoding: utf-8
require "pathname"
class DownloadProgressNotifier
attr_reader :target, :output
def initialize(target, output = $stderr)
@target = Pathname(target)
@output = output
end
def download_started
output.puts
end
def progress(percent)
report_progress percent
end
def downl... | true |
22a6147a5143279dbac3d4556c9624b060010751 | Ruby | andrewtrent/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 370 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #def reverse_each_word(string)
# string_arr = string.split(" ")
# string_arr_two = []
# string_arr.each do |x|
# string_arr_two << x.reverse
# end
# string_arr_two.join(" ")
#end
def reverse_each_word(string)
string_arr = string.split(" ")
string_arr_two = []
string_arr.collect do |x|
string_arr_two ... | true |
7bb9197209c6d6fcb952e43f27a2fc9ece99c25c | Ruby | AaronC81/parlour | /lib/parlour/debugging.rb | UTF-8 | 4,641 | 3.140625 | 3 | [
"MIT"
] | permissive | # typed: true
require 'rainbow'
module Parlour
# Contains methods to enable debugging facilities for Parlour.
module Debugging
extend T::Sig
@debug_mode = !ENV["PARLOUR_DEBUG"].nil?
# Set whether debug messages should be printed.
# @param [Boolean] value True if debug messages will be printed, fa... | true |
635b301546fec46801ae14a65626c4481f809598 | Ruby | alextacho/foosball | /app/models/match.rb | UTF-8 | 950 | 2.703125 | 3 | [
"MIT"
] | permissive | class PlayerNotInBothTeams < ActiveModel::Validator
def validate(record)
player_in_both_teams = (record.try(:home_team).try(:player_ids) & record.try(:away_team).try(:player_ids))
if player_in_both_teams.any?
player_in_both_teams.each do |player_id|
player = Player.find player_id
record... | true |
35616e80915be630620cc2654c4390c6b4e542b6 | Ruby | kota-shidara/atcoder-problems | /ABC/123/123-C.rb | UTF-8 | 106 | 3.125 | 3 | [] | no_license | n = gets.to_i
min_times = 5.times.map { gets.chomp.to_i }.min
ans = 4 + (n / min_times.to_f).ceil
puts ans | true |
f07e254cf1026985826a4ee6f0011c720df08fcf | Ruby | paulfjacobs/knight-move-on-phone-keypad | /chess.rb | UTF-8 | 458 | 3.1875 | 3 | [] | no_license |
Move_map=[[4,6],[6,8],[7,9],[4,8],[3,9],[],[1,7],[2,6],[1,3],[2,4]]
def compute(v,n)
h = 1
prefix_queue = [ "#{v}" ]
cur_level = [ v ]
new_level = []
while h <= n
cur_level.each do |k|
prefix = prefix_queue.shift
Move_map[ k ].each do |x|
new_level.push x
prefix_queue.push "#{prefix},#{x}"
en... | true |
f0e6dd0410e36d209e7ef8d4a7a9d7284106f196 | Ruby | jeanfrancis/membr | /features/step_definitions/member_steps.rb | UTF-8 | 1,742 | 2.609375 | 3 | [] | no_license | Given /^I chose to add a new member$/ do
visit("/members/new")
end
Given /^I am on the members page$/ do
visit("/")
end
Given /^a member exists with ic_number (\d+)$/ do |ic_number|
@member = create(:member, ic_number: ic_number)
@member.should_not be_nil
end
When /^I add a new member with details:$/ do |tab... | true |
d750ac61ec4ee226fe562043e0ebd5ceea7fe06b | Ruby | peek/peek-mongo | /lib/peek/views/mongo.rb | UTF-8 | 2,739 | 2.75 | 3 | [
"MIT"
] | permissive | require 'mongo'
require 'concurrent'
module Peek
# Query times are logged by timing the Socket class of the Mongo Ruby Driver
module MongoSocketInstrumented
def read(*args, &block)
start = Time.now
super(*args, &block)
ensure
duration = (Time.now - start)
::Mongo::Socket.query_time.... | true |
07a68525f74fcb0083eb2bef96b07560b6472f9a | Ruby | dpmontooth/pre_ruby_exercises | /hashes/exercise_3c.rb | UTF-8 | 197 | 4.1875 | 4 | [] | no_license | # program to loop through hash and print keys and values
hash_1 = {fluffy_dog: "Juno", skinny_dog: "Bailey", brother: "Mark", sister: "Kristie"}
hash_1.each {|k,v| puts "My #{k} is named #{v}."}
| true |
ae8505afdc467be28a07901d4ef9554da5cbedf0 | Ruby | gera-gas/iparser | /lib/iparser/state.rb | UTF-8 | 2,267 | 3.265625 | 3 | [
"MIT"
] | permissive | module Iparser
# Used for describe single state
# of parser machine.
class State
attr_reader :statename
attr_accessor :branches, :entry, :leave, :ientry, :ileave, :ignore
# call-seq:
# State.new( String )
def initialize ( sname )
unless sname.instance_of? String
raise Type... | true |
cb18783d974c1d6f31955c999de742d79c9c719e | Ruby | ElaErl/Intro-to-programming | /intro_to_prog/arrays_6/6_1.rb | UTF-8 | 87 | 3.34375 | 3 | [] | no_license | arr = [1, 3, 5, 7, 9, 11]
number = 3
if arr.include?(num)
puts "num is in arr"
end
| true |
a8cc78ed528128dcf7a98463ec26f9687cd4168d | Ruby | jhererxp/HotelSW | /confirm1.rb | UTF-8 | 140 | 3.078125 | 3 | [] | no_license | class Confirm1
attr_reader :roomr
attr_writer :roomr
def initialize(room)
@roomr = room
end
def say_room
" #{roomr}"
end
end
| true |
7b73edd622223ebcfd4bb9fbd35557f1a2d53a9d | Ruby | galtet/posts_system | /lib/tyrion/models/post.rb | UTF-8 | 1,904 | 3.03125 | 3 | [] | no_license | require 'date'
module Tyrion
module Models
class Post < ActiveRecord::Base
belongs_to :user
has_many :votes
after_create :update_hot_posts
MAX_HOT_POSTS = 20
@@hot_posts = []
def self.hot_posts
@@hot_posts ||= []
end
def self.set_hot_posts(h_posts)
@@hot... | true |
5a8d649f9abe7ee61c362aab161d75f764d4ac3b | Ruby | dlhede1509/classes-and-instances-lab-ruby-bootcamp-prep-000 | /lib/dog.rb | UTF-8 | 155 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
attr_accessor :name
end
fido = Dog.new
fido.name = 'fido'
snoopy = Dog.new
snoopy.name = 'snoopy'
lassie = Dog.new
lassie.name = 'lassie' | true |
7deb1c6031ca9f69298c9fd4dae6e7135cb117cb | Ruby | PhilippePerret/Collecte | /lib/required_then/classe/Collecte/Collecte/instance/props.rb | UTF-8 | 570 | 2.546875 | 3 | [] | no_license | # encoding: UTF-8
class Collecte
# L'instance {Film} du film de la collecte
def film ; @film ||= Film.new(self) end
# {Array} Liste des erreurs rencontrées au cours de
# l'opération.
attr_reader :errors
# Instance Collecte::Metadata des métadonnées
def metadata ; @metadata ||= Metadata.new(self) end
... | true |
ae5382cf219db04e8c3c65691707edf6b2cbca4b | Ruby | vannida-lim/ruby-enumerables-hash-practice-emoticon-translator-lab-dumbo-web-100719 | /lib/translator.rb | UTF-8 | 1,055 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require "yaml"
def load_library(filepath)
# code goes here
emoticons = YAML.load_file(filepath)
result = {}
result[:get_meaning] = {}
result[:get_emoticon] = {}
emoticons.each do |meaning, array_emojis|
english_emojis = array_emojis[0]
japanese_emojis = array_emojis[1]
... | true |
8eb55c7f4d4d1c3c5a5cdce9fc33f2f8d5ec363e | Ruby | codeAligned/super_happy_interview_time | /rb/lib/leetcode/lc_49.rb | UTF-8 | 506 | 3.453125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module LeetCode
# 49. Group Anagrams
module LC49
# Description:
# Given an array of strings, group anagrams together.
#
# Examples:
# Input: ["eat", "tea", "tan", "ate", "nat", "bat"]
# Output: [
# ["ate", "eat", "tea"],
# ["nat", "tan"],
# ["... | true |
9b34bf955decf414a2d929ed62e99d13b30b19df | Ruby | PhilippePerret/Piano | /public/page/article/admin/scores/Scores.rb | UTF-8 | 3,216 | 2.515625 | 3 | [] | no_license | # encoding: UTF-8
=begin
Class Stores
------------
Gestion des images créées à l'aide des scripts xextra sur Icare
Extension administration seulement
=end
class Score
app.require_module 'Score'
class << self
attr_reader :logs
##
#
# Retourne pour affichage les messages de l'opération
# demand... | true |
ef557b89428bfd884027eec9d077a5304bba1fa3 | Ruby | kchien/KindleClippingExtractor | /lib/kindle_extractor/writes_anki_import_file.rb | UTF-8 | 700 | 2.953125 | 3 | [] | no_license | module KindleExtractor
class WritesAnkiImportFile
ANKI_FIELD_SEPARATOR = "\t"
def initialize(dir=ENV['PWD'])
@output_dir = File.expand_path "#{dir}"
end
def write_out(highlight)
FileUtils.mkdir_p(output_dir) unless Dir.exists?(output_dir)
anki_text_file = File.join(output_d... | true |
4aaf0c0b0ca8d5675338d370f82f7346e930f480 | Ruby | maayankaufman/todo-ruby-basics-001-prework-web | /lib/ruby_basics.rb | UTF-8 | 350 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
num1/num2
end
def assign_variable(name)
variable=name
end
def argue(phrase)
phrase = "I'm right and you are wrong!"
end
def greeting (greeting, name)
greeting = "Hi there, "
name = "Bobby!"
end
def return_a_value
"Nice"
end
def last_evaluated_value
"expert"
end
def pizza_party (t... | true |
e9858edec1e777931256bf197f1a8a947f99e052 | Ruby | BigTallJim/BorisBike | /spec/boris_bikes_spec.rb | UTF-8 | 1,802 | 2.921875 | 3 | [] | no_license | require "boris_bikes"
describe DockingStation do
let(:bike) { double :bike }
it "expect release of bike" do
is_expected.to respond_to(:release_bike)
end
it "test bike is returned from release bike if bikes exist" do
allow(bike).to receive(:is_working?).and_return(true)
dock = DockingStation.new
... | true |
e5f2a2241e320020f7457530146c6b4d5b057001 | Ruby | IIIIIIIIll/RubyQuizess | /Quiz5/question21.rb | UTF-8 | 92 | 3.28125 | 3 | [] | no_license | class Calculator
def self.add(x, y)
return(x + y)
end
end
puts Calculator.add(3, 4) | true |
43e2329d459edc2b1dade37ebedf9f58d06c8e74 | Ruby | kacperwalanuselpassion/pasher | /app/models/storage/mongo/dish.rb | UTF-8 | 1,209 | 2.625 | 3 | [] | no_license | module Storage::Mongo
class Dish
class << self
def mapper
Storage::Mongo::Dish::Mapper
end
def all
collection.find().sort(_id: -1).map { |response| mapper.to_object(response) }
end
def find(id)
response = collection.find_one(_id: BSON::ObjectId(id))
... | true |
d953332066f6a9af673a66ed6d67897d8167e219 | Ruby | prw001/mastermind | /GameTools.rb | UTF-8 | 237 | 3.015625 | 3 | [] | no_license | module GameTools
def numToColor(num)
case num
when 1
return 'r'
when 2
return 'y'
when 3
return 'b'
when 4
return 'g'
when 5
return 'c'
else
return 'p'
end
end
end | true |
2bd390c9f77cf8d2d1d619ff3d55392911a94279 | Ruby | johnhowardroberts/launch-school | /101_109_small_problems/odd_numbers.rb | UTF-8 | 286 | 4.65625 | 5 | [] | no_license | # Print all odd numbers from 1 to 99, inclusive. All numbers should be printed on separate lines.
(1..99).each { |num| puts num if num.odd? }
# Further Exploration
# Integer#upto
1.upto(99) { |num| puts num if num.odd? }
# Array#select
puts (1..99).to_a.select { |num| num.odd? }
| true |
5123ce700b20065f51b86af02f0d48562b77b250 | Ruby | bil-bas/bored_game_hotspot_editor | /test/TC_gridnode.rb | UTF-8 | 5,326 | 3.171875 | 3 | [] | no_license | ###############################################################################
#
#
require 'test/unit'
# require 'yaml' # For debugging only.
require '../lib/pathfinding'
include PathFinding
###############################################################################
#
class TC_GridNode < Test::Unit::TestCase
... | true |
6286dcc44a044fa3270313df47980af2dce95ddb | Ruby | gyg22/puzzle | /interview/elance/third/app.rb | UTF-8 | 1,087 | 2.609375 | 3 | [] | no_license | #encoding: utf-8
require 'sinatra'
require_relative 'config'
require_relative 'user'
class APP < Sinatra::Base
get '/users' do
users = User.all
[200, {'Content-Type' => 'application/json'}, users.to_json]
end
post '/users' do
user = User.new email: params[:email]
if user.save
[200, {'Co... | true |
5face4852a136f07ff6a3814de46d37a11a75470 | Ruby | nramadas/WebChess | /spec/libraries/bishop_spec.rb | UTF-8 | 1,391 | 2.984375 | 3 | [] | no_license | require 'colorize'
describe "Bishop".red do
let(:board) { Chess::Board.new }
subject(:piece) { Chess::Bishop.new(0, 4, :black, board) }
its(:row) { should eq(0) }
its(:col) { should eq(4) }
its(:player) { should eq(:black) }
describe "it has" do
it "a bishop token" do
piece.token == "\u265d"
end
end
... | true |
054c10cb724aecd8dbb7f36d3f7e7ab893e7c81b | Ruby | riverswb/gryff_outdoor | /app/models/item.rb | UTF-8 | 508 | 2.5625 | 3 | [] | no_license | class Item < ApplicationRecord
validates :title,:description, :price, :image, presence: :true
belongs_to :category
has_many :order_items
has_many :orders, through: :order_items
enum status: [:active, :retired]
def self.item_list(cart_items)
cart_items.map do |item, quantity|
[find(item), quant... | true |
4c5c872d74bec9a590d966d67638a2f51dd283bb | Ruby | noontage/scratches | /binary_gacp.rb | UTF-8 | 320 | 3.234375 | 3 | [] | no_license | def solution(n)
ary = []
t = 0
s = n.to_s(2)
s.each_char do |c|
if c == '1'
unless t.zero?
ary.push(t)
t = 0
end
else
t+=1
end
end
return 0 if ary.empty?
ary.max
end
p solution(0b11111111111111111) | true |
dc2bc0dcd58fc53c082430c8fda17382c0632833 | Ruby | docljn/advent2019 | /lib/instruction.rb | UTF-8 | 729 | 3.734375 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
class Instruction
attr_reader :direction, :distance
def initialize(data)
@direction = data[0].upcase
@distance = data.delete(direction).to_i
end
def ==(other)
direction.equal?(other.direction)
distance.equal?(other.distance)
end
def path_from(starting_point)... | true |
84a1b03eef85d19cbd6756254557a0b96ee3350b | Ruby | baldesco/Ruby | /ejercicios/hipo.rb | UTF-8 | 197 | 3.484375 | 3 | [] | no_license | puts "Digite el primer lado del triangulo"
a=gets.chomp.to_i
puts "Digite el segundo lado del triangulo"
b=gets.chomp.to_i
c=(a**2+b**2)**0.5
puts "La longitud de la hipotenusa es #{c}" | true |
4cdc4c058e2987a87dd0586b3b294ef2b2b28f90 | Ruby | mlongerich/plural_sight_exercises | /ruby_fundamentals/test/control_structs.rb | UTF-8 | 138 | 2.546875 | 3 | [] | no_license | lander_count = 10
message = if lander_count > 10
"Launching probe"
else
"Waiting for probes to return"
end
puts message
a = b = 10
| true |
c7e4141270d3f3fc33d350b38db03a4c9c21214a | Ruby | grzeswol/Euklides | /main.rb | UTF-8 | 169 | 2.5625 | 3 | [] | no_license | require 'sinatra'
def nwd(a,b)
a, b = a.abs, b.abs
while b > 0
a,b = b, a % b
end
a
end
get '/' do
erb :index, :layout => false do
erb :page_layout
end
end
| true |
15a4beb2dcc72a568b6b319304e780483d047c41 | Ruby | Lindy-admin/lindy-admin | /rails-app/lib/tasks/lindy.rake | UTF-8 | 650 | 2.5625 | 3 | [] | no_license | namespace :lindy do
desc "Adds members and registers them to courses"
task seed: :environment do
Course.all.each do |course|
print "seeding #{course.title}\n"
30.times do
name = Faker::Name.name
space = name.index(" ")
firstname = name[0..space-1]
lastname = name[spac... | true |
6de80f370e56959cde6d711db687d8932e5331e0 | Ruby | amandeep1420/RB101 | /RB101/Small Problems/E5/4_letter.rb | UTF-8 | 1,365 | 4.9375 | 5 | [] | no_license | # def swap(word)
# word_array = word.split(' ')
# word_array.each do |word|
# first_letter = word[0]
# last_letter = word[-1]
# word[0] = last_letter
# word[-1] = first_letter
# end.join(' ')
# end
# puts swap('Oh what a wonderful day it is') == 'hO thaw a londerfuw yad ti si'
# puts swap('Abcde... | true |
17ec98df81fdcd39e1e1444e859ee105c267cf23 | Ruby | hackerway/Crime-Prediction | /code/crime_proc.rb | UTF-8 | 13,270 | 3.03125 | 3 | [] | no_license | require 'sqlite3'
require './crime_proc_funcs'
require './offense_type'
$db = SQLite3::Database.open "./crime.db"
########################### Define areas.
# Probably better done with hardcoded boundaries.
def areaTab()
# Create area table. Tables with longitude/latitude information:
# codeViol, pr_inc, neighborho... | true |
8e9d562438a000d39b0e89ca3014c0ff1cfd64fc | Ruby | HewlettPackard/oneview-chef | /libraries/resource_provider.rb | UTF-8 | 14,974 | 2.5625 | 3 | [
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # (c) Copyright 2016 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | true |
878968860dbe199564b51e8f3ff9558802307301 | Ruby | maikeru/vending_machine | /lib/vending_machine.rb | UTF-8 | 668 | 3.703125 | 4 | [] | no_license | #require 'drink'
class VendingMachine
DENOMINATIONS = [10, 50, 100, 500, 1000]
def initialize
@total_inserted = 0
@drink = Drink.new "Coke", 120, 5
end
def insert_money value
if DENOMINATIONS.include? value
@total_inserted += value
else
refund value
end
end
def get_total_i... | true |
c790d562cff582083bbec5e290a4194f96c44153 | Ruby | jesse-zonneveld/App-Academy-Open | /13 Chess/board.rb | UTF-8 | 2,981 | 3.625 | 4 | [] | no_license | require_relative "pieces"
require "byebug"
class Board
attr_reader :null_piece, :grid
def initialize(dup_bool = false)
@null_piece = NullPiece.instance
setup_board(dup_bool)
end
def [](pos)
x, y = pos
@grid[x][y]
end
def []=(pos, piece)
x, y = pos
... | true |
2b04b504b73c15c4971528cfdb66cf69c44f65ae | Ruby | Inglorion-G/mythal | /lib/mythal/npc.rb | UTF-8 | 1,128 | 2.671875 | 3 | [
"MIT"
] | permissive | module Mythal
class Npc
include Procto.call
def initialize(challenge_rating: "1/4", user_overrides: {})
@challenge_rating = challenge_rating
@user_overrides = user_overrides
end
def call
self
end
def stats
@stats ||= Mythal::Stats.new(
challenge_rating: chall... | true |
6c8ea5b3b6b9f31e03efc2a441d04aa1c5f61a92 | Ruby | buithehoa/rspec-3-book | /book-code/06-integration-specs/09/expense_tracker/spec/integration/app/ledger_spec.rb | UTF-8 | 1,837 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative '../../../app/ledger'
module ExpenseTracker
RSpec.describe Ledger, :aggregate_failures, :db do
let(:ledger) { Ledger.new }
let(:expense) do
{
'payee' => 'Starbucks',
'amount' => 5.75,
'date' => '2017-06-10'
}
end
describe '#record' do
# .... | true |
0fdcb6ac201fbcf9bf33edc4db428d84d99bf83c | Ruby | marcosrafaellsousa/Curso-ruby-cucumber-capybara | /secao 5/xpath/mapeando_elementos.rb | UTF-8 | 1,621 | 3.921875 | 4 | [] | no_license | # Referências: https://www.w3schools.com/xml/xpath_intro.asp
#
# Elemento HTML são composto por:
#
# Exemplo: <p class="important"> This is a paragraph </p>
#
# Abertura da tag: <p
# Conjunto de atributos e valores:
# Nome do atributo: class=
# Valor do atributo: ... | true |
c1a5f9c460f16468c08bc2b3f208003d2aca1c46 | Ruby | mlresearch/papersite | /ruby/old-mlresearch.rb | UTF-8 | 14,172 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'bibtex'
require 'yaml'
require 'facets'
require 'latex/decode'
require 'latex/decode/version'
require 'latex/decode/compatibility'
require 'latex/decode/base'
require 'latex/decode/accents'
require 'latex/decode/diacritics'
require 'latex/decode/maths'
require 'latex/decode/punctuation'
req... | true |
9be87ca1fc9eda13b30bae903470d3e600bc145d | Ruby | b1nary/robobot | /lib/robobot/notification.rb | UTF-8 | 1,383 | 2.625 | 3 | [
"MIT"
] | permissive | # Notifications help to show results and information to the user
# It uses: libnotify
# Author:: Roman Pramberger (mailto:roman@pramberger.ch)
# License:: MIT
module Robobot
module Notification
# show a notification
# you must define a title
#
# Parameter
# title: required title
# options:... | true |
acde5ed70393a471f52f7a2fbf5ef502c29695c9 | Ruby | sheikhhamza012/ror_test | /config/schedule.rb | UTF-8 | 558 | 2.5625 | 3 | [] | no_license | # Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
#job_type :mail, '/home/mehroz/railsTest/instagramclone/app/jobs/mail_to.rb :user'
ever... | true |
1b0f62d9351cd115d6a6f13961be9567ec64b8bd | Ruby | srfraser/adventofcode | /2020/15/ruby/1.rb | UTF-8 | 1,908 | 3.5625 | 4 | [] | no_license | def play_memory_game_naively(sequence, desired_number = 2020)
(1..desired_number).each { |_|
last_spoken = sequence[-1]
if sequence[0..-2].include?(last_spoken)
# puts "#{last_spoken} was in #{sequence[..-2]}"
sequence.append(sequence.length - 1 - sequence[0..-2].rindex(last_spoken))
else
... | true |
1336eb81bc9427b8949fa1133ecddb017f38c1f2 | Ruby | spree/spree | /core/app/models/spree/stock/estimator.rb | UTF-8 | 2,251 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | module Spree
module Stock
class Estimator
include VatPriceCalculation
attr_reader :order, :currency
def initialize(order)
@order = order
@currency = order.currency
end
def shipping_rates(package, shipping_method_filter = ShippingMethod::DISPLAY_ON_FRONT_END)
... | true |
9f10d1bd00412484cd7c1130bdabb08d9645778d | Ruby | jordanbyron/advent-of-code | /2015/9-travel/part_one.rb | UTF-8 | 2,539 | 3.546875 | 4 | [
"MIT"
] | permissive | require_relative '../advent'
Visitor = ->(places, h = {}) {
if places.one?
return places.first
else
places.each do |place|
h[place] = Visitor[places - [place]]
end
h
end
}
module DistanceCalcualtor
extend self
def distance_for(origin, destination)
distances[origin][destination] |... | true |
2e33288d6d70c79c68fb9910ae7a86343721e4b8 | Ruby | rhys117/LaunchSchoolCurriculum | /Backend/101/exercises/easy4/short_long_short.rb | UTF-8 | 309 | 3.515625 | 4 | [] | no_license | def short_long_short(str_one, str_two)
if str_one.length > str_two.length
str_two + str_one + str_two
else
str_one + str_two + str_one
end
end
puts short_long_short('abc', 'defgh') == "abcdefghabc"
puts short_long_short('abcde', 'fgh') == "fghabcdefgh"
puts short_long_short('', 'xyz') == "xyz" | true |
b500ff684f4dacae65946da884e8672f9486eba6 | Ruby | ManageIQ/manageiq-performance | /lib/manageiq_performance/reporter.rb | UTF-8 | 5,292 | 2.671875 | 3 | [] | no_license | require "yaml"
require "bigdecimal"
module ManageIQPerformance
class Reporter
attr_reader :io
HEADERS = {
"ms" => %w[ms],
"queries" => %w[queries],
"query (ms)" => %w[activerecord elapsed_time],
"rows" => %w[rows]
}
def self.build(run_dir, io=STDOUT)
new(run_dir, io).b... | true |
f9f9da8954e986396948d5c89991970be187e9bc | Ruby | JayTeeSF/TimeTracker | /lib/time_tracker.rb | UTF-8 | 2,927 | 3.21875 | 3 | [] | no_license | class TimeTracker
INSTANCES = {}
def self.help
puts <<-EOM
irb -r ./app/lib/time_tracker.rb
> TimeTracker.clear
> t = TimeTracker.new("1")
> t.start :one
> TimeTracker.find("1") == t
=> true
> TimeTracker.clear
> TimeTracker.find("1") == t
=> false
> TimeTrack... | true |
f952ac4ce590d5ba01b82f71302658cb82629c0e | Ruby | deepigarg/rubyx | /test/mains/source/32_adds__10.rb | UTF-8 | 287 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Integer < Data4
def <(right)
X.comparison(:<)
end
def +(right)
X.int_operator(:+)
end
def -(right)
X.int_operator(:-)
end
end
class Space
def main(arg)
a = 0
b = 20
while( a < b )
a = a + 1
b = b - 1
end
return a
end
end
| true |
728072b2df612723d8645bc95c9d43f587a0806a | Ruby | jaleszek/reddit_wrapper | /1/lib/tdd.rb | UTF-8 | 2,208 | 3.109375 | 3 | [] | no_license | require "addressable/uri"
require 'curb'
require 'json'
module RedditAPI
class Pinger
attr_reader :resource, :action, :url, :http_method
BASE_URL = 'http://www.reddit.com'
FUNCTIONAL_ARGS = [:resource, :action]
FORMAT = '.json'
ROUTING = {
"article/popular" => {
url: "#{BASE_URL}/subre... | true |
0b18d0986687b8eeeee9e3ebbd0ff3e341e2a7d4 | Ruby | spookybit/daily_projects | /w1d2/Sudoku/tile.rb | UTF-8 | 127 | 2.796875 | 3 | [] | no_license | class Tile
attr_accessor :value
def initialize(value = 0, given = false)
@given = given
@value = value
end
end
| true |
c6421d4f180a15112c370e36e11d935db11205ae | Ruby | cielavenir/procon | /atcoder/abc/tyama_atcoderABC021C.rb | UTF-8 | 381 | 2.765625 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
n=gets.to_i
s,g=gets.split.map(&:to_i)
h=Hash.new{|h,k|h[k]=[]}
gets.to_i.times{|i|
a,b=gets.split.map(&:to_i)
h[a]<<b
h[b]<<a
}
q=[s]
depth={s=>1}
sum=Hash.new(0)
sum[s]=1
while !q.empty?
cur=q.shift
h[cur].each{|e|
if !depth.has_key?(e)
depth[e]=depth[cur]+1
q<<e
end
if depth[e]==dept... | true |
d1109fd460eee4dcf195b75ae7eb9be0fddc6dff | Ruby | sisyphe0713/furima-30355 | /app/models/order_address.rb | UTF-8 | 953 | 2.515625 | 3 | [] | no_license | class OrderAddress
include ActiveModel::Model
attr_accessor :post_code, :prefecture_id, :city, :address_number, :building, :telephone, :user_id, :item_id, :token
with_options presence: true do
validates :post_code, format: { with: /\A\d{3}[-]\d{4}\z/, message: "is invalid. Inclue hyphen(-)" }
validates... | true |
1697a5b954ccac7035aa46f9cb0cec93ee384d66 | Ruby | DanKnox/tmp_mail | /lib/tmp_mail/address.rb | UTF-8 | 480 | 2.609375 | 3 | [] | no_license | module TmpMail
class Address < ::Mail::Address
def self.demongoize(object)
Address.new(object)
end
def self.mongoize(object)
case object
when Address then object.mongoize
when String then Address.new(object).mongoize
else
object
end
end
def self.evolv... | true |
b5c8d14ff470479d4b6bfe6fb254d76c6d33a8e6 | Ruby | tylerpalef/Thursday_July_26 | /student.rb | UTF-8 | 778 | 3.328125 | 3 | [] | no_license | require_relative "person"
class Student < Person # This is how you make a class inherit another class
Level = 0 # Constants are not supposed to change. So you put it in a constant variable. That way you can change the number if you have a big class
# Value should always be there before initialize
def initialize... | true |
19b3c0edc25a00ad6757749faf8cfde85b9a8f17 | Ruby | siuying/gitdocs | /lib/gitdocs/markdown_converter.rb | UTF-8 | 1,250 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'redcarpet'
require 'pygments'
# Singleton markdown converter, configured with github favoured markdown
#
# adapted from (https://github.com/chitsaou/ruby-taiwan/blob/d342b58dcfff3089a9599714a6911ca9c1f1490f/config/initializers/markdown.rb)
class MarkdownConverter
include Singleton
class HTMLwithSyntaxH... | true |
5e9500788b451cf25803c4d407f6d99b11a13787 | Ruby | Muhidin123/programming-univbasics-4-simple-looping-lab-chi01-seng-ft-102620 | /lib/simple_loops.rb | UTF-8 | 297 | 3.875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your methods here
def loop_message_five_times(message)
5.times do
puts message
end
end
def loop_message_n_times(message, n)
n.times do
puts message
end
end
def output_array(message)
message.map {|x| puts x }
end
def return_string_array(arr)
arr.map(&:to_s)
end
| true |
600a57080374d49d7184fcc751b2e9c1aecbc4da | Ruby | shuangliu12/NFL_data | /server.rb | UTF-8 | 1,943 | 3.5 | 4 | [] | no_license | require 'sinatra'
require 'csv'
def import_csv(filename)
data = []
CSV.foreach(filename, headers:true) do |row|
data << row.to_hash
end
data
end
def count_results(league)
wins = {}
losses = {}
#set all losses and wins to 0, initialize values
league.each do |game|
wins[game["home_team"]]=0
... | true |
d35a4fed5075c1958f4d3241887764ec3fb5e996 | Ruby | alhd7892/git-push-origin-master | /db/seeds.rb | UTF-8 | 1,144 | 2.6875 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
6182f7d0f1ed7ad7f24d1fc745c1d16c48b4136b | Ruby | thenice/Poll-Everywhere-Ruby-API-Wrapper | /poll_everywhere.rb | UTF-8 | 5,956 | 2.671875 | 3 | [
"MIT"
] | permissive | # @author Daniel Cohen
# @release_date July, 23 2010
# @website http://thenice.tumblr.com
# @email daniel.michael.cohen@gmail.com
# @license MIT license: http://www.opensource.org/licenses/mit-license.php
require 'net/http'
module PollEverywhere
class Poll
# Add any key of a poll to not have instantiated as a fi... | true |
8852f5f2d0c8feb58fdef1ae63b80305334b9b79 | Ruby | Ermako27/compilers-course-work | /tests/sample3.rb | UTF-8 | 408 | 2.78125 | 3 | [] | no_license | def foo (arg1, arg2, arg3)
intVar = 42
dynVar = arg1 / 2
arrVar = []
fullArrVar = [9, 8]
fullArrVar[0] = 5
strVar = 'hello'
floatVar = 9.9
arrayOfVar = [intVar, floatVar]
def barr(arg2)
b = 99
dynVar = arg2 / 2
arrVar = []
return b
end
funcCa... | true |
787d93e171237249168aae6e5b771d53f4e00cbf | Ruby | dpsk/book-club | /app/models/book.rb | UTF-8 | 936 | 2.578125 | 3 | [] | no_license | class Book < ActiveRecord::Base
attr_accessible :cover_url, :author, :genre, :name, :notes, :user_id, :featured
belongs_to :user
has_many :votes
validates :name, presence: true, uniqueness: true
validates :cover_url, :format => URI::regexp(%w(http https))
validates :author, presence: true
validates :use... | true |
a1347e517bb64c92b2fd661cace64524c028b577 | Ruby | atiaxi/kuiper | /lib/options.rb | UTF-8 | 9,966 | 2.921875 | 3 | [] | no_license | require 'yaml'
require 'overrides'
# Holder class for every option in the game
class Options
attr_accessor :filename
attr_accessor :screen_size
attr_accessor :fullscreen
attr_reader :controls
def self.from_file(fullpath)
result = YAML::load_file(fullpath)
result.filename = fullpath
retur... | true |
12207a0d5d6a674b12157e3f8579aa2a2049b046 | Ruby | hallbergandrew/Ruby-Dictionary | /lib/word.rb | UTF-8 | 259 | 2.6875 | 3 | [] | no_license | require './lib/definition.rb'
class Word
attr_reader :word, :language
attr_accessor :definition
def initialize(word, language, definition)
@word = word
@language = language
@definition = Definition.new(definition, language)
end
end
| true |
f8b846da6861935ab69464f8668037eb664d4815 | Ruby | coryschires/katas | /bowling/spec/bowling_spec.rb | UTF-8 | 4,289 | 3.078125 | 3 | [] | no_license | require 'bowling'
describe Bowling do
before { @bowling = Bowling.new }
describe "#score" do
it "should mark a double gutter" do
@bowling.roll(0,0)
@bowling.score.should == 0
end
it "should mark seven pins" do
@bowling.roll(5,2)
@bowling.score.should == 7
end
it "shou... | true |
d5e5354a18a673529b6e7b8e748376c42ff46d08 | Ruby | samir-ayoub/aula_ruby | /orientacao_objeto/produtosEstoqueRefacao2/exec.rb | UTF-8 | 851 | 3.21875 | 3 | [] | no_license | require "byebug"
require "/Users/samir/projetos/aula_ruby/orientacao_objeto/produtosEstoqueRefacao2/cliente.rb"
require "/Users/samir/projetos/aula_ruby/orientacao_objeto/produtosEstoqueRefacao2/produto.rb"
def carga_de_produtos
20.times do |i|
produto= Produto.new
produto.codigo=i
produto.nome="Nome#{i}"
pro... | true |
24935c10186f0ff1e462e0956c7992a4b1f9e0dd | Ruby | johnfelixespinosa/top_vinyls | /lib/top_vinyls/cli.rb | UTF-8 | 2,075 | 3.375 | 3 | [
"MIT"
] | permissive | class TopVinyls::CLI
require 'pry'
def start
puts ""
puts "---------- Top 100 Must Own Vinyl Records ----------"
puts ""
puts "Which albums would you like to see?"
puts "
1. [01-25]
2. [26-50]
3. [51-75]
4. [76-100]"
puts ""
puts "Choose 1-4"
... | true |
b84bfd047a9aa9e5df5e53376141488c18995085 | Ruby | mikdiet/gretel | /lib/gretel/view_helpers.rb | UTF-8 | 4,195 | 2.609375 | 3 | [
"MIT"
] | permissive | module Gretel
module ViewHelpers
# Sets the current breadcrumb to be rendered elsewhere. Put it somewhere in the view, preferably in the top, before you render any breadcrumbs HTML:
# <%
# breadcrumb :category, @category
# %>
def breadcrumb(*args)
options = args.extract_options!
... | true |
87aecb1d9951716f2f20b41e12ec3efa8d94c905 | Ruby | Mustikrz/PR3 | /PR3 Git/PR3_Smits_Lösungen/05_textanalysis/solution/wortliste.rb | UTF-8 | 1,321 | 3.453125 | 3 | [] | no_license | class Wortliste
def initialize
@liste = {}
@liste.default = nil
end
def <<(wort)
key = wort.downcase
frequency = @liste[key] || 0
frequency += 1
@liste[key] = frequency
end
def length
@liste.length
end
def count_wo... | true |
e63668c0077484a468e6812245458b5ee1d37265 | Ruby | thiagomsilva/desafio-back-end | /app/models/store.rb | UTF-8 | 419 | 2.546875 | 3 | [] | no_license | class Store < ApplicationRecord
attribute :name, :valid_string
attribute :owner, :valid_string
validates_presence_of :name, :owner
validates_uniqueness_of :name, scope: :owner
has_many :financial_transactions, dependent: :destroy
def total_amount
Utils::NumberUtil.new(
... | true |
63310933ff870a7853e51c5c479aab92052e6588 | Ruby | ministryofjustice/laa-apply-for-legal-aid | /app/validators/date_validator.rb | UTF-8 | 1,718 | 2.71875 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | class DateValidator < ActiveModel::EachValidator
DEFAULT_FORMAT = "%Y-%m-%d".freeze
DEFAULT_EARLIEST_DATE = "1900-01-01".freeze
def validate_each(record, attribute, value)
value = parse_date(value, options[:format]) if value.is_a?(String)
return unless valid_date(record, attribute, value)
validate_n... | true |
9ce981ed1cf81f338d07e6c15f463328f5027d28 | Ruby | abinofbrooklyn/Metis | /week1/music_problem.rb | UTF-8 | 755 | 3.59375 | 4 | [] | no_license | require 'csv'
class Music
attr_accessor :db
def initialize
@db = {}
end
def sort
CSV.foreach("music.csv") do |row|
artist_name = row[3]
song_title = row[0]
if db.has_key?(artist_name)
db[artist_name] << song_title
else
db[artist_name] = [song_title]
end
... | true |
cb677f71ade081601250b2ca00960edb1ef602a8 | Ruby | BDCraven/learn-to-program | /chap02/ex1.rb | UTF-8 | 234 | 3.71875 | 4 | [] | no_license | puts "Number of hours in a year = #{24 * 365}"
puts "Number of minutes in a decade = #{60 * 24 * 365 * 10}"
puts "Number of seconds in 20 years = #{60 * 60 * 24 * 365 * 20}"
puts "Chris Pine's age = #{1160000000 / 60 / 60 / 24 / 365}"
| true |
e4e3111b09aaca43a5098be9e6f463c512ea675a | Ruby | Onionator/anagram_checker | /lib/anagram.rb | UTF-8 | 1,540 | 4.15625 | 4 | [
"MIT"
] | permissive | class Anagram
def initialize(input)
@first_word = input
end
def anagram?(second_word)
if self.is_word?
@first_word.delete!("!@#${%^&*()}_+=[]|:;\"'<,>.?/ ")
@first_word.downcase!()
word_holder = @first_word.chomp
second_word.delete!("!@#${%^&*()}_+=[]|:;\"'<,>.?/ ")
second_wo... | true |
f39c5aa5c3c02ea410205aacf4b55ea7960ffac6 | Ruby | gillisd/rebay | /lib/rebay/api.rb | UTF-8 | 1,852 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'json'
require 'uri'
module Rebay
class Api
# default site is EBAY_US, for other available sites see eBay documentation:
# http://developer.ebay.com/DevZone/merchandising/docs/Concepts/SiteIDToGlobalID.html
class << self
attr_accessor :app_id, :default_site_id, :sandbox
... | true |
4c83d1150b5fd9329a2d58d3e1ba801b50b60e93 | Ruby | luc34fenos/ruby | /exo_07_a.rb | UTF-8 | 122 | 3.0625 | 3 | [] | no_license | puts "Bonjour, c'est quoi ton blase ?"
user_name = gets.chomp #attend d'un donnees entrer par l'utilisateur
puts user_name | true |
57d7520a5541d2f10864b80fa232313f4a8d7957 | Ruby | AndryMac/first | /Lesson_1/part_2.rb | UTF-8 | 251 | 3.0625 | 3 | [] | no_license | puts "Укажите основание треугольника"
base = gets.chomp.to_i
puts "Укажите высоту треугольника"
height = gets.chomp.to_i
area = 0.5*base*height
puts "Площадь треугольника #{area}" | true |
daa7fdfe780f7cb046bc7c0dc6ccec96d4ea4456 | Ruby | rich-ma/aA-homeworks | /w2d5/LRU_cache.rb | UTF-8 | 882 | 3.3125 | 3 | [] | no_license | class LRUCache
attr_reader :arr, :max_size
def initialize(size)
@arr = Array.new(size)
@max_size = size
end
def count
arr.length# returns number of elements currently in cache
end
def add(el)
arr.delete(el) if arr.include?(el)
arr.shift if arr.length == @max_size
arr.push(el)
en... | true |
32b31c1b9d41c4a9b148a1008366432ff6a5b137 | Ruby | Dan2D/learn_ruby | /05_book_titles/book.rb | UTF-8 | 946 | 3.953125 | 4 | [] | no_license | #arg = gets.chomp
=begin
class Book
# write your code here
def title(arg)
no_cap = ["the","a","an","and","in","of"]
@books = arg.split(' ')
#puts @book.inspect
@books.map!{|x|
if @books.index(x)==0 or !no_cap.include?(x)
x=x.capitalize
else
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.