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
a93830faf72fee9d3f536b75db6620c0dcea4a25
Ruby
JulianCedric/2020.05.11.OO.Ruby.2
/lib/role.rb
UTF-8
323
2.921875
3
[]
no_license
class Role attr_accessor :movie, :actor, :team @@all = [] def initialize(movie, actor, team=nil) @movie = movie @actor = actor @team = "avenger" Role.all << self end def self.all @@all end def change_team @team = "villain" end ...
true
77807f74998c83bc39a277fd308c3227815f19c2
Ruby
mmanousos/ruby-small-problems
/ruby_basics/loops1/two.rb
UTF-8
612
4.21875
4
[]
no_license
# 2. Loopception # The code below is an example of a nested loop. Both loops currently loop infinitely. Modify the code so each loop stops after the first iteration. loop do puts 'This is the outer loop.' loop do puts 'This is the inner loop.' break # 'break' after inner loop executes once returns to out...
true
9c5d944b1a8d69159a5398b2e9f8ec376488fc28
Ruby
amatriain/feedbunch
/FeedBunch-app/lib/entry_manager.rb
UTF-8
7,192
2.828125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true require 'encoding_manager' require 'sanitizer' require 'url_validator' ## # Class to save or update in the database a collection of entries fetched from a feed. class EntryManager ## # Save new feed entries in the database. # # For each entry passed, if an entry with the same g...
true
b6185069a87149022687da113bc866b601973848
Ruby
ababich/tubity-roda
/models/counter.rb
UTF-8
1,286
2.921875
3
[]
no_license
class Counter # originally aplhabet is 53 symbols: # "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ0123456789-_" # and is a bit shuffled to be more interesting ALPHABET = %W( sMXzj6TZLlvk4c1bqS0ghCBJ9Fx-t2PdG3_nQRVrHp8NKDfm7W5w 4sPhwXl-mfTJB8GMnqkQFbcjdpgt5W1rvS9HD32_NCZ7xL0zR6KV 6kp8v0CRnX2_K...
true
b06e86803e3f8862140be9e540b495adedb58f34
Ruby
uNmasK95/EstacaoAmbiental
/AppAmbiental/client/Client.rb
UTF-8
1,071
3
3
[]
no_license
require 'socket' require_relative "XdkSensor.rb" class Client include XdkSensor def initialize( hostname, port, id, latitude, longitude) @hostname = hostname @port = port @id = id @latitude = latitude @longitude = longitude #@latitude = rand(-90.0..90.0) #@longitude = rand(-180.0..180...
true
082cd97fc048c5f8e4533bb82d76664d0af959a1
Ruby
lis2/presentations
/0mq/examples/rr-client.rb
UTF-8
417
2.65625
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'ffi-rzmq' context = ZMQ::Context.new(1) puts "Connecting to hello world server..." requester = context.socket(ZMQ::REQ) requester.connect("tcp://localhost:5555") 0.upto(9) do |request_nbr| puts "Sending request #{request_nbr}..." requester.send_string "Hello" r...
true
355699f29cb75f581231a2d09aa77944124b9fae
Ruby
igorsch/studio_game
/gameturn.rb
UTF-8
517
3.078125
3
[]
no_license
require_relative 'player' require_relative 'die' require_relative 'treasures' module GameTurn def self.take_turn(player) die = Die.new case die.roll when 1..2 player.blam when 3..4 player.skipped else player.w00t end treasures = Treasure_Chest.random # puts "#{player...
true
2f26b0904b60d2527133d0e7698723571388442e
Ruby
lioforest/jour15-sinatra
/jour15-sinatra/the_gossip_project_sinatra/lib/gossip.rb
UTF-8
1,138
3.03125
3
[]
no_license
class Gossip attr_accessor :content attr_accessor :author def initialize(author, content) @content = content @author = author end def save CSV.open("./db/gossip.csv", "ab") do |csv| csv << [@author, @content] end end def self.all all_gossips = [] #on initialise un array vide # va cherche...
true
d3e13c9ef631c1b0617dadadc93eb697855fbf34
Ruby
nathanworden/A-Common-Sense-Guide-to-Data-Structures-and-Algorithms
/35.chap17_trie.rb
UTF-8
859
3.875
4
[]
no_license
class TrieNode def initialize(self) self.children = {} end end class Trie def initialize(self) self.root = TrieNode.new end end # Exercises #3) Write a function that traverses each node of a trie and prints out each key, including all "*" keys def traverse(self, node=nil) currentNode = node || se...
true
81721d3953c2699609d2cde6774851667e88db9a
Ruby
aaronpederson/dice-as-a-service
/roll-server.rb
UTF-8
746
2.8125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'highline/import' require 'commander' require 'ffi-rzmq' def roll(dice, sides) rolls = [] dice.times do roll = rand 1..sides puts roll rolls << roll end rolls.reduce(:+).to_s end def listen context = ZMQ::Context.new server = context.socket ZMQ::REP server.bind...
true
c339e22546bda8ed863d6d56b0ed66af08083f7b
Ruby
adharmad/jruby-examples
/testTreeSet.rb
UTF-8
163
2.890625
3
[]
no_license
require 'java' include_class 'java.util.TreeSet' set = TreeSet.new set.add "foo" set.add "Bar" set.add "baz" set.each do |v| puts "value: #{v}" end
true
d4d62ca4f9bc45d48993e9aac441500f020addc3
Ruby
oscarcuihang/leetcode
/ruby_solutions/038.CountAndSay.rb
UTF-8
717
4.34375
4
[]
no_license
# The count-and-say sequence is the sequence of integers beginning as follows: # 1, 11, 21, 1211, 111221, ... # 1 is read off as "one 1" or 11. # 11 is read off as "two 1s" or 21. # 21 is read off as "one 2, then one 1" or 1211. # Given an integer n, generate the nth sequence. # @param {Integer} n # @return {String}...
true
b3ab90776bcb1c372e577cb943898c3708d2280e
Ruby
arunshariharan/trello-cards-search
/Output/output.rb
UTF-8
934
3.25
3
[]
no_license
require 'ruby-progressbar' require 'colorize' class Output def self.display(result) if result.size > 0 puts "\n\n" puts "We found ".yellow + result.size.to_s.red + " cards that are similar \n\n".yellow result.each {|each_result| puts each_result.green + "\n"} else puts "\n\n" pu...
true
14bce18e54b5e79006965c7e052ce80ed44bc8c2
Ruby
reruns/hackerrank
/Mathematics/Fundamentals/even-odd-query.rb
UTF-8
299
3.21875
3
[]
no_license
n = $stdin.gets.to_i a = $stdin.gets.chomp.split(' ').map(&:to_i) q = $stdin.gets.to_i q.times do ns = $stdin.gets.chomp.split(' ').map(&:to_i) x = ns[0] y = ns[1] if x != y && a[x] == 0 then puts "Odd" elsif a[x-1].odd? then puts "Odd" else puts "Even" end end
true
2752bd244e95641538fd8ae1826ba4409a4e12b2
Ruby
inside-track/remi
/lib/remi/parser.rb
UTF-8
1,674
2.78125
3
[ "MIT" ]
permissive
module Remi # A parser is an object that converts data returned from an # Remi::Extractor into a dataframe. This is a parent class meant to be # inherited by child classes that define specific ways to parse # data. class Parser # @param context [Object] The context (e.g., DataSource) for the parser (def...
true
d53376b5ce5e91885a709108c665a0a0f5f5ad21
Ruby
saurabhgulati/gdal
/lib/gdal/info.rb
UTF-8
1,023
2.921875
3
[ "MIT" ]
permissive
module Gdal class Info attr_reader :path, :upper_left, :upper_right, :lower_left, :lower_right, :center, :data def initialize options={} @path = options[:path] @upper_left = options[:upper_left] @upper_right = options[:upper_right] @lower_left = options[:lower_left] @lower_right...
true
c2471c4ccad4dede97c9f1c8d5601c6db9bf38a4
Ruby
osbilln/chef
/replication_scripts/db_tables_from_file_dump.rb
UTF-8
1,053
2.65625
3
[]
no_license
#!/usr/bin/ruby if ARGV.count != 7 puts "db_tables_from_file_dump.rb usage: <db_name> <db_host> <db_user> <db_pw> <dump dir> <tables to dump> <max tables per dump>" exit end DB_NAME = ARGV[0] DB_HOST = ARGV[1] DB_USER = ARGV[2] DB_PW = ARGV[3] DUMP_DIR = ARGV[4] TABLES_TO_DUMP_FILE = ARGV[5] MAX_TABLES = ARGV[6] ...
true
c1865bc5c51a2e805169dbe69a93bb4b8f5ff40a
Ruby
sanjsanj/inject-challenge
/spec/array_spec.rb
UTF-8
3,017
3.21875
3
[]
no_license
require 'array' context 'Array' do context 'without arguments' do it 'can add' do expect([1, 2, 3].inject { |sum, n| sum + n }).to eq 6 expect([1, 2, 3].my_inject { |sum, n| sum + n }).to eq 6 end it 'can multiply' do expect([1, 2, 3].inject { |sum, n| sum * n }).to eq 6 expect([...
true
a6ddc5dc1fe552135e4ecfabca949a9127c58e60
Ruby
yuta830/kadai-ruby-1
/kadai-introduce.rb
UTF-8
102
2.9375
3
[]
no_license
myouji = '加藤' namae = '優太' nenrei =21 puts myouji+namae+"です。"+nenrei.to_s+"歳です。"
true
59bed737d153e74809e49a996bef79e745235dde
Ruby
matthewdu/project_euler
/3.rb
UTF-8
119
2.859375
3
[]
no_license
i = 2 n = 600851475143 factors = [] while n != 1 do if n%i == 0 factors << i n /= i end i += 1 end puts factors
true
9198a01437c0311c22d8ea402253c25629d621af
Ruby
tsangyeeyau/csci3180
/asgn2/connect_4.rb
UTF-8
5,354
3.15625
3
[]
no_license
# CSCI3180 Principles of Programming Languages # --- Declaration --- # I declare that the assignment here submitted is original except for source # material explicitly acknowledged. I also acknowledge that I am aware of # University policy and regulations on honesty in academic work, and of the # disciplinary guideli...
true
819729057c659cb8526af569906627fd97543508
Ruby
Tsutomu19/StudyingAlgorithms
/0610.rb
UTF-8
7,205
3.390625
3
[]
no_license
# 1回目の組み合わせの番号を決定 pair_a = gets.chomp.split(" ").map(&:to_i) pair_b = gets.chomp.split(" ").map(&:to_i) # 1回目の速度を設定 @first_time = gets.chomp.split(" ").map(&:to_i) # エントリーナンバーに応じた速度を設定 a = @first_time[pair_a[0]-1] b = @first_time[pair_a[1]-1] c = @first_time[pair_b[0]-1] d = @first_time[pair_b[1]-1] # 1回戦目の勝利判定 def ...
true
5c67d6e1e82c42a4ebb8e890283d199abf2decd4
Ruby
learn-co-curriculum/chicago-se-120720
/active-record-associations/db/seeds.rb
UTF-8
553
2.953125
3
[]
no_license
require "faker" Book.destroy_all Author.destroy_all AuthorBook.destroy_all 10.times do Book.create(title: Faker::Book.title, description: Faker::Lorem.sentence) Author.create(name: Faker::Book.author) end book_ids = Book.all.map{ |book| book.id } author_ids = Author.all.map{ |author| author.id } 30.times do a...
true
bef66fc24472b196e71e7f554efab46dfa650bd7
Ruby
vladimir-nm/pick_a_card
/main.rb
UTF-8
163
3.28125
3
[]
no_license
require_relative 'lib/deck' deck = Deck.new.shuffle puts 'How many cards do you pick?' number = STDIN.gets.to_i puts number.times do puts deck.pop_a_card end
true
a4081b4064acc97e9f945b5072ee71f1ab3eab69
Ruby
kputnam/stupidedi
/spec/lib/stupidedi/either_spec.rb
UTF-8
11,337
2.65625
3
[ "BSD-3-Clause" ]
permissive
describe "Stupidedi::Either" do def mksuccess(value) Stupidedi::Either.success(value) end def mkfailure(value) Stupidedi::Either.failure(value) end describe "#reason" do context "on failure" do it "returns the value given to the constructor" do expect(mkfailure("a").reason).to be =...
true
b49deb170f784a0b59921ed1d3705567b9ad6921
Ruby
zomux/utils
/oldkyusu/preprocess.rb
UTF-8
226
2.703125
3
[]
no_license
require 'moji' STDOUT.sync = true hyphentxt = "#{File.expand_path(File.dirname(__FILE__))}/hyphen.txt" hyphen=nil open(hyphentxt){|fp| hyphen = fp.gets.chomp} while gets puts Moji.han_to_zen($_.chomp.gsub(hyphen,"-")) end
true
0b33e6c4fd6393fe8632776723dbe18846055a94
Ruby
postazure/CS-Principals
/binary-tree/lib/tree.rb
UTF-8
246
3.359375
3
[]
no_license
class Tree attr_accessor :root def initialize(root) @root = Node.new(root) end def dfs(value, node = @root) return if node.nil? return node if node.value == value dfs(value, node.left) || dfs(value, node.right) end end
true
21d82a96b79c6ec0e4f8e1cdb3c856de0a5c3b5a
Ruby
dtrej9999/hw-ruby-intro
/lib/ruby_intro.rb
UTF-8
1,341
3.875
4
[]
no_license
# When done, submit this entire file to the autograder. # Part 1 def sum(arr) sum = 0 arr.each{|num| sum += num} sum end def max_2_sum(arr) sum = 0 if arr.length > 1 max1 = arr.at(0) max2 = arr.at(1) arr2 = arr.drop(2) arr2.each{|val| if (val > max1) && (max2 > max1) ...
true
fa69940fde66bd0531555812bc0eb42f92e18e52
Ruby
egaichet/ElementWar
/app/services/character_builder.rb
UTF-8
1,140
2.921875
3
[]
no_license
class CharacterBuilder class << self def build(args) Character.new( Attributes.new(args[:attributes][:hit_points], args[:attributes][:speed]), args[:strikes] ) end def hero Character.new( Attributes.new(100, 60), { fire_bolt: StrikeBuilder.fire_...
true
68b762789202486d5bbaca4c1f5e4a6b2e3089b1
Ruby
stevieing/courtbooking
/app/models/permissions/member_permission.rb
UTF-8
2,094
2.625
3
[]
no_license
module Permissions ## # permissions for a Member # basic permissions will be added as per guest user. # Any other permissions are done on a by user basis basis loaded from the database. class MemberPermission < BasePermission def initialize(user) super @user = user @permissions = @user....
true
b096105a3d9644201fafc0fa647c4eacbf893d0e
Ruby
karmiclychee/codechallenges
/mcarthy91[easy].rb
UTF-8
371
4.3125
4
[]
no_license
# m(n) # if n > 100 # return n - 10 # else # m(n + 11) # end def m(n) if n > 100 puts "M(#{n-10}) since 110 is greater than 100" n - 10 else puts "M(M(#{n+11})) since #{n} is equal to or less than 100" m(m(n + 11)) end end def mccarthy(n) puts "M(#{n})" puts "#{m(n)} since #{m...
true
2c43abdf96f10a7a3fd978a92e87ce4fc147f8fe
Ruby
bry/pingboard
/lib/pingboard/request.rb
UTF-8
839
2.84375
3
[ "MIT" ]
permissive
module Pingboard class Request attr_accessor :client, :path, :http_verb, :headers, :body, :params def initialize(client:, http_verb:, path:, headers:, body:, params: {}) @client = client @http_verb = http_verb @path = path @headers = headers @body = body @params = params ...
true
252ded65b2848753b2896c8a249cc4a3dffce290
Ruby
ylluminarious/hello_name_cmd_line
/rb/main.rb
UTF-8
318
2.796875
3
[]
no_license
require "opal" require "browser" prompt_for_name = Proc.new do name = $$.prompt("What's your name?") unless name == "" || name == nil $$.alert("Hi, #{name}!") else $$.alert("That's not a valid name.") end end logo = $$[:document].getElementById("logo") logo.onclick = prompt_for_name
true
a15f1978b62dcfc33045011555c313467adc1893
Ruby
osyoyu/saikoh.tk
/app.rb
UTF-8
3,301
2.578125
3
[]
no_license
require 'sinatra/base' require 'sinatra-websocket' require 'redis' require 'redis-objects' require 'connection_pool' require 'json' require 'logger' require_relative './counter.rb' class SaikohTk < Sinatra::Base configure do set :redis_url, ENV['REDIS_URL'] || 'redis://localhost:6379' Redis::Objects.red...
true
b24bde489c2a77ef1ff3f063a903c5f18076d0b9
Ruby
Abdel-Nasser/salut
/salut/lib/03_basics.rb
UTF-8
341
3.640625
4
[]
no_license
def who_is_bigger(a, b, c) if a == nil || b == nil || c == nil return "nil detected" end if a > b && a > c return "a is bigger" end if b > a && b > c return "b is bigger" end if c > b && c > a return "c is bigger" en...
true
f13767a2c98f02028042d815c816edf7211fc238
Ruby
ivanionut/old-study
/ruby/classes-objects-and-variables/my_class.rb
UTF-8
351
3.078125
3
[]
no_license
class MyClass # public... default def method1 end protected def method2 end private def method3 end public def method4 end end # un'alternativa class MyClass2 def method1 end def method2 end def method3 end def method4 end public :method1, :method4 protected :me...
true
fd5c9ff92f3994bd5bcb1170787ed9ef2cd082dd
Ruby
bryanalves/rrtorrent
/lib/rrtorrent/client.rb
UTF-8
631
2.609375
3
[]
no_license
module RRTorrent class Client def initialize(host, port) @backend = Backend.new_from_hash(host: host, port: port) end def list_torrents(view = :main) @backend.values_for_torrent_view(view).map do |torrent| Model::Torrent.new(torrent) end end def get_torrent(id) Mo...
true
0f6f3fa419cb5e71c3142b057a3052f27756838f
Ruby
optixx/quickdev16
/scripts/zip2raw.rb
UTF-8
3,545
2.5625
3
[]
no_license
use_file_names = true include_file_names = false loop do if ARGF.read(2) != "PK" if ARGF.eof? exit end warn "Input is not a zip file" exit 1 end if !(ARGF.read(2) == "\003\004") # file header exit end version = ARGF.read(2).unpack("v").first ...
true
e39a6cefb6c33b0ded90706f14c59b19041e888a
Ruby
hermesdt/insbef
/app/services/search_service.rb
UTF-8
733
2.671875
3
[]
no_license
class SearchService def initialize chuck_service: ChuckService.instance, query_saver_service: QuerySaverService.new @chuck_service = chuck_service @query_saver_service = query_saver_service end def query(query_param) if query = find_query(query_param) return q...
true
223d5d5f4a771c4e1c6aa9df04a371feb2e2ab8d
Ruby
appunite/liftoff
/lib/liftoff/file_manager.rb
UTF-8
3,020
2.703125
3
[ "MIT" ]
permissive
module Liftoff class FileManager def create_project_dir(name, &block) FileUtils.mkdir(name) Dir.chdir(name, &block) rescue Errno::EEXIST STDERR.puts "Directory '#{name}' already exists" exit 1 end def generate(template, destination = template, project_config = ProjectConfigura...
true
aa8485d07ac1de1298dc9ed516fdd5d3af005b39
Ruby
charlie320/programming_labs_projects
/ruby_vagrant_box/ruby_on_rails/run_queries.rb
UTF-8
3,660
2.84375
3
[]
no_license
Task 1: 2.3.1 :009 > players = Player.all Player Load (4.8ms) SELECT "players".* FROM "players" 2.3.1 :010 > players.each do |player| 2.3.1 :011 > team = player.team 2.3.1 :012?> puts "Player: #{player.name}, Team: #{team.name}, Mascot: #{team.mascot}, Stadium: #{team.stadium}" 2.3.1 :013?> end 1 query to r...
true
4771498bcd85d0f274012d303a1c77ebdb147c82
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/anagram/6a975dd4728d49bbb0e18688db9af0b7.rb
UTF-8
237
3.6875
4
[]
no_license
class Anagram def initialize(word) @word = word end def match(words) words.select { |word| anagram?(word) } end def anagram?(word) word != @word && word.chars.sort.join == @word.downcase.chars.sort.join end end
true
6e98f45cfb122ac9c55e7722952c20f66986bd53
Ruby
muupan/project_euler
/30/pe30.rb
UTF-8
158
3.046875
3
[]
no_license
numbers = [] for n in 2..999999 numbers << n if n == n.to_s.split("").inject(0){|sum, c| sum + c.to_i ** 5} end p numbers puts "sum:#{numbers.inject(:+)}"
true
bab7e635e384efd3e178f1b546294d32d8a69535
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/a356b9ec1e1c466581b4fc724feea69e.rb
UTF-8
520
4.09375
4
[]
no_license
class Bob def hey(string) utterance = Utterance.new(string) case when utterance.empty? then "Fine. Be that way." when utterance.question? then "Sure." when utterance.shouting? then "Woah, chill out!" else "Whatever." end end end class Utterance attr_reader :string def initia...
true
5c8c4bf2aa64fb481b6c02d99feef027eac42c4c
Ruby
SeanFmcdonnell/REPLgame
/REPL_game.rb
UTF-8
850
3.296875
3
[]
no_license
loop do puts "Welcome to the Flamingo in South Beach!" puts "What do you want to do?" puts "Options: go to the pool, play volleyball, go paddleboarding" option = gets.chomp.downcase case option when "go to the pool" puts "You're at the pool. Do you want to 'do a gainer'? or 'put on sunscreen'?" option_2 = gets...
true
709a75f73b0ec27dbf9ff61080e4f09d65a4396c
Ruby
mintona/enigma
/test/enigma_test.rb
UTF-8
6,327
3.4375
3
[]
no_license
require './test/test_helper' require_relative '../lib/enigma' require_relative '../lib/shift' require_relative '../lib/offset' require_relative '../lib/key' class EnigmaTest < Minitest::Test def setup Key.expects(:generate_number).returns("12345") Date.expects(:today).returns(Date.new(2019,11,2)) @enigm...
true
ac1daa0254f32ff60027af4fd1a56a748b85ebd2
Ruby
rudenko9/reverse-each-word-online-web-pt-021119
/reverse_each_word.rb
UTF-8
323
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(phrase1) array = phrase1.split(" ") returning = [] array.each do |word| returning << word.reverse end returning.join(" ") end def reverse_each_word(phrase2) array = phrase2.split(" ") returning = [] array.collect do |word| returning << word.reverse end returning.join(" ") e...
true
764f486c19320d7c8290bcd828ba85c3bb437cba
Ruby
turboladen/rosh
/lib/rosh/changeable.rb
UTF-8
619
2.640625
3
[ "MIT" ]
permissive
class Rosh module Changeable def change_if(criteria, &block) if execute_action?(criteria) return block.call end puts 'Check state first and criteria met. Returning.' false end private def execute_action?(criteria) return true unless current_shell.check_state_...
true
71a02d6b8f8c4070339dcc695d98b9a6a7b115a4
Ruby
xodus899/Ironhack
/week2/Todolist/spec/todolistclass_spec.rb
UTF-8
618
3.046875
3
[]
no_license
require_relative("../lib/todolistclass.rb") require_relative("../lib/task.rb") RSpec.describe TodoList do # task3= Task.new("mop") # task4= Task.new("clean") # task5=Task.new("blah") let(:task3) {Todolist.new("Mop the floor")} let(:task4) {TodoList.new("Wash the car")} let(:task5) {Todolist.new("Drink some ...
true
15fa583bfe64f75ffec58af7d8260296472d1520
Ruby
bkshogun/phase-0-tracks
/ruby/alias_manager.rb
UTF-8
884
4.40625
4
[]
no_license
# Establish a variable with the spy's name spy_name = "Felicia Torres" # Define array of vowels and constnants vowels = ["a", "e", "i", "o", "u"] constnants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"] # Define empty arrays for later use vowels_in_name =...
true
75c5e581391b93c985bd197edb9c7ca11ead5969
Ruby
dimidd/numbers_in_words
/lib/numbers_in_words/duck_punch.rb
UTF-8
517
2.90625
3
[ "MIT" ]
permissive
module NumbersInWords def in_words language=NumbersInWords.language NumbersInWords.in_words(self, language) end end module WordsInNumbers def in_numbers(only_compress = false, language=NumbersInWords.language) NumbersInWords::ToNumber.new(self, language).in_numbers(only_compress) end def num_compres...
true
7ad4a11b8493031a2cceaecfa607404bac9409be
Ruby
kanbkit/learning
/learnruby/user.rb
UTF-8
565
2.90625
3
[]
no_license
require 'json' class User attr_accessor :name, :email, :permissons def initialize(*args) @name = args[0] @email = args[1] @permissons = User.permissons_from_template end def self.permissons_from_template file = File.read 'user_permisson_temp.json' JSON.lo...
true
bb54e989be8cb1a7fb6ef320dafd4212e0d5f842
Ruby
Widdershin/train-empire
/app/concepts/state_modifiers/keep_route_cards.rb
UTF-8
848
2.75
3
[]
no_license
class StateModifiers::KeepRouteCards attr_reader :cards_to_keep, :errors, :player_id def self.from_action(action) new(action.player_id, action.route_cards_to_keep) end def initialize(player_id, cards_to_keep) @player_id = player_id @cards_to_keep = cards_to_keep.map(&:to_i) @errors = [] end ...
true
805af71a562b91b6dd88657967094ed00215861d
Ruby
bradrf/better_bytes
/lib/better_bytes.rb
UTF-8
1,138
3.265625
3
[]
no_license
class BetterBytes BINARY = [%w{B KiB MiB GiB TiB PiB EiB ZiB YiB}, 1024] DECIMAL = [%w{B KB MB GB TB PB EB ZB YB}, 1000] def self.humanize(val, precision: 0.1, units: :binary) val.is_a? String and val = dehumanize(val) if units.is_a? Symbol abbrev, mult = units == :binary ? BINARY : DECIMAL ...
true
6a69a1a25f33dac49052d2275cb2cce5772bc596
Ruby
mevdschee/AdventOfCode2018
/infi/part2.rb
UTF-8
2,921
3.109375
3
[]
no_license
lines = File.readlines('input') tiles = { ║: { up: true, down: true, left: false, right: false }, ╔: { up: false, down: true, left: false, right: true }, ╗: { up: false, down: true, left: true, right: false }, ╠: { up: true, down: true, left: false, right: true }, ╦: { up: false, down: true, left: true, right...
true
9fe35a3cf34a69fd95e9e853385cb617b20668e8
Ruby
ccelestial/flower_shop_console
/spec/lib/product_factory_spec.rb
UTF-8
872
2.578125
3
[]
no_license
require 'spec_helper' require 'product_factory' describe ProductFactory do describe '#get' do before { allow(ArrayProducts).to receive(:get).and_return([ { name: "Roses", code: "R12", bundles: [ { quantity: 5, price: 6.99 ...
true
c0a88f7eedb6897a5a5ca4db232ddca2b84f9191
Ruby
jamesonji/git-exercise-clean-merge
/cookie.rb
UTF-8
161
3.46875
3
[]
no_license
class Cookie attr_accessor :sugar attr_accessor :flour def initialize(sugar, flour) @sugar, @flour = sugar, flour puts(@sugar, @flour) end end
true
b262549560e127ddd77f1abf72e72f78e4a96d85
Ruby
estensland/project_euler
/32 Pandigital Products/31.rb
UTF-8
616
3.5625
4
[]
no_license
def coin_changer_combinations(coin, coins) table = Array.new(coin+1){|i| Array.new(coins.length, i.zero? ? 1 : nil)} 1.upto(coin) do |outer_num| coins.length.times do |inner_num| previous_number_combinations = table[outer_num - coins[inner_num]][inner_num] unless outer_num < coins[inner_num] previ...
true
77df8681a9c8b98e3c423655f8907a0e33f8ffe1
Ruby
vdaubry/twitwin
/app/classes/keyword.rb
UTF-8
305
2.53125
3
[]
no_license
class Keyword attr_reader :lang, :file def initialize(lang:) @lang = lang @file = YAML.load_file("config/keywords/keywords-#{lang}.yml") end def texts file["search_texts"] end def direct_message file["direct_message_text"] end def regex file["tweet_regex"] end end
true
cf807cf4735aad701a23254ba34c46c393ff8eac
Ruby
ritchey0713/rails_project
/app/models/game.rb
UTF-8
735
2.734375
3
[ "MIT" ]
permissive
class Game < ApplicationRecord has_many :rankings has_many :users, through: :rankings validates :name, presence: true validates :play_time, numericality: true accepts_nested_attributes_for :rankings scope :pro_level, ->(play_time) { where("play_time > 200", play_time ) } scope :score, -> { where("score ...
true
8381108360eead25df1121c713d0b3d8f16fdeb6
Ruby
evinracher/ST0251-PROYECTO_INTEGRADOR_UNO
/MOCA/db/seeds.rb
UTF-8
1,431
2.515625
3
[]
no_license
# coding: utf-8 # 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 R...
true
79615e0b3cabf0ca8b745e90b9b1daf503423489
Ruby
brandonwirz/array-CRUD-lab-v-000
/lib/array_crud.rb
UTF-8
614
3.984375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def create_an_empty_array [] end def create_an_array array = ["Music", "Hiking", "Biking", "Camping"] end def add_element_to_end_of_array(array, element) array.push(element) #array << element end def add_element_to_start_of_array(array, element) array.unshift(element) end def remove_element_from_end_of_arra...
true
e816055ae92b40b60c1454edb0349c476af7520e
Ruby
MrConstantine/znaigorod
/app/models/kind.rb
UTF-8
1,489
2.609375
3
[]
no_license
class Kind < ActiveRecord::Base belongs_to :institution_kind belongs_to :institution # All kind's of parameters has_many :parameter_strings, :dependent => :destroy has_many :parameter_booleans, :dependent => :destroy scope :published, includes(:institution).where(:institutions => {:published => true}) ...
true
ca47a7d2c76801390097d13a1a492f02df088402
Ruby
machinelearner/spree_recommendations
/app/models/recommendation/user_similarity_score.rb
UTF-8
2,620
2.53125
3
[ "BSD-3-Clause" ]
permissive
module Recommendation class UserSimilarityScore < ActiveRecord::Base self.table_name = "spree_user_similarity_scores" attr_accessible :user1_id, :user2_id, :score def self.create_scores all_users = Spree.user_class.find_all_with_atleast_one_purchase return if all_us...
true
8429767e1cd671aa2878c2c31b7cefa57ce36e55
Ruby
Jenkyrados/Euler
/Ruby/problems/prob70.rb
UTF-8
660
3.109375
3
[]
no_license
require 'prime' start = Time.now totient = Array.new(10000001){0} totient[1] = 1 min = [Float::INFINITY,0] (2..9999999).each do |n| if totient[n] == 0 then totient[n] = n-1 ((2*n)..9999999).step(n).each do |i| j = i/n if totient[i] != 0 || totient[j] == 0 then next end q = j; ...
true
0a4e0a14d9344a025cf50bef08abd6d44c2be6a5
Ruby
nickcluc/zelda_zombie_battle
/Zelda/game.rb
UTF-8
5,164
2.90625
3
[]
no_license
require 'rubygems' # only necessary in Ruby 1.8 require 'gosu' require 'pry' require_relative 'models/player' require_relative 'models/enemy' require_relative 'models/bounding_box' require_relative 'models/menu' require_relative 'models/background' class GameWindow < Gosu::Window attr_reader :music def initial...
true
a882f5492ebaeec813135f5cde038d67e9fdca6f
Ruby
richardsa/learn_ruby
/05_silly_blocks/silly_blocks.rb
UTF-8
141
3.1875
3
[]
no_license
def reverser yield.split(' ').map(&:reverse).join(' ') end def adder(a = 1) yield + a end def repeater(a = 1) a.times do yield end end
true
e344a980639034ddbd88e093f150e043980a5e7a
Ruby
amkhrjee/mb-geometry
/bin/triangulate.rb
UTF-8
2,814
2.75
3
[ "BSD-2-Clause" ]
permissive
#!/usr/bin/env ruby require 'bundler/setup' require 'pry' # Uncomment if debugging --- require 'pry-byebug' require 'json' require 'benchmark' $:.unshift(File.join(__dir__, '..', 'lib')) require 'mb/geometry' if ARGV.length < 1 || ARGV.include?('--help') puts "\nUsage: \e[1m#{$0}\e[0m file_with_points_array.json...
true
625efc0b11f0ff19118b83a361aa97c554936981
Ruby
wwwkang8/Ruby_study
/method/method1.rb
UTF-8
699
3.375
3
[]
no_license
module Api module V2 class Hello def initialize(name, age) @name = name @age = age end def Hello.call_age(age) "My age is #{age}" end def call_name(name) "My name is #{name}" end def varargs(a, *b) [a,b] end def mi...
true
307da1c18761fa37eabd12403bb1c1dcbdfc7739
Ruby
Maxwell-Baird/backend_module_0_capstone
/day_1/ex11.rb
UTF-8
464
4.34375
4
[]
no_license
print "How old are you? " age = gets.chomp print "How tall are you? " height = gets.chomp print "How much do you weight? " weight = gets.chomp puts "So, you're #{age} old, #{height} tall and #{weight} heavy." puts "What type of pet do you own? " pet = gets.chomp puts "What color is your pet? " color = gets.chomp puts ...
true
438a941c510db0b75923693d4f2f51e1066a071b
Ruby
SettRaziel/wrf_library
/lib/wrf_library/json_converter/hourly_sum_converter.rb
UTF-8
645
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "wrf_library/wrf" module WrfLibrary module JsonConverter # Child class to generate valid json output for the result data of a given wrf meteogram # result already stored in a data repository class HourlySumJsonConverter < HourlyJsonConverter private # implementation of the abstrac...
true
fae6fa0f15951884231800018bd3ae4db8c5ed1f
Ruby
friendtu/ruby_hard_way
/projects/Ex49/tests/test_parser_no_module.rb
UTF-8
314
2.703125
3
[]
no_license
require 'parse_no_module.rb' require "minitest/autorun" class TestParse_no_module<Minitest::Test def test_parse_sentence() sentence=Sentence.new("Go east") assert_equal("player",sentence.subject) assert_equal("Go",sentence.verb) assert_equal("east",sentence.object) end end
true
363b0c4b4c0dc9df48bdb8676fb31269492721b4
Ruby
eamouzou/backend_module_0_capstone
/day_6/class_obj.rb
UTF-8
3,635
4.5625
5
[]
no_license
# You create an object by defining a class and instantiating it by using # the '.new' method to create an instance, also known as an object. # Example below #class MyClass #end #my_obj = MyClass.new # Classes Define Objects # good_dog.rb class GoodDog end sparky = GoodDog.new # Initializing a New Object # good_d...
true
05c07134bc36931925de887e279bce0bb2242478
Ruby
shadre/challenges
/easy1/octal.rb
UTF-8
697
4.125
4
[]
no_license
# Implement octal to decimal conversion. Given an octal input string, your # program should produce a decimal output. # Note: # Implement the conversion yourself. Do not use something else to perform the # conversion for you. Treat invalid input as octal 0. class Octal def initialize(number_string) @number_strin...
true
384b88cce7dbb0ceb720f90085f2f52f6c5191ad
Ruby
collinksmith/algorithms-and-data-structures
/algorithms/coderbyte/medium/22_bracket_matcher.rb
UTF-8
973
4.34375
4
[]
no_license
=begin Using the Ruby language, have the function BracketMatcher(str) take the str parameter being passed and return 1 if the brackets are correctly matched and each one is accounted for. Otherwise return 0. For example: if str is "(hello (world))", then the output should be 1, but if str is "((hello (world))" the the ...
true
d331a11915303577188e288e481b75b92c3e5514
Ruby
dfujimoto/Julio-Prime-Factors
/dfujimoto/prime_factor_spec.rb
UTF-8
388
2.53125
3
[]
no_license
require "./prime_factors.rb" describe PrimeFactors do it "factores de 2" do factores = PrimeFactors.new factores.generate(2).should == [2] end it "factores de 3" do factores = PrimeFactors.new factores.generate(3).should == [3] end it "factores de 6" do factores = Prim...
true
1d95bf4cfceb4d8cbb77252985f15afc46fad9c1
Ruby
marclerodrigues/learnrubythehardway
/ex13-3.rb
UTF-8
123
3.3125
3
[]
no_license
name, age, height, weight = ARGV puts " #{name.capitalize}, you're #{age} years old, #{height} tall and #{weight} heavy."
true
a34885260296ba2901207503c15ec1e430d35869
Ruby
abonner1/ruby-collaborating-objects-lab-v-000
/lib/song.rb
UTF-8
421
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :name, :genre, :artist def initialize(name) @name = name end def self.new_by_filename(filename) artist, name, genre = filename.chomp(".mp3").split(" - ") song = self.new(name) song.genre = genre song.artist_name = artist song end def artist_name=(artist) ...
true
2240837db77260bdcb5beeed98cdf15fe558ce35
Ruby
erichwelz/rabbitmq-tutorials
/t4-routing/emit_log_direct.rb
UTF-8
344
2.609375
3
[]
no_license
#!/usr/bin/env ruby # encoding: utf-8 require "bunny" conn = Bunny.new conn.start channel = conn.create_channel exchange = channel.direct("direct_logs") severity = ARGV.shift || "info" message = ARGV.empty? ? "Hello World!" : ARGV.join(" ") exchange.publish(message, routing_key: severity) puts " [x] Sent ...
true
e9306a430c20f71e42db5d26dce49d4c8b389cc0
Ruby
kaynewbie1/phase-0-tracks
/ruby/puppy_methods.rb
UTF-8
816
4.09375
4
[]
no_license
class Puppy def fetch(toy) puts "I brought back the #{toy}!" toy end def speak(integer) integer.times do |i| puts "woof" end end def roll_over puts "*rolls over*" end def dog_years(integer) dog_years = integer * 10 dog_years end def initialize puts "Initializ...
true
518f8f759feb5fea81910063ccf70ca1f3d3024a
Ruby
angielg/interpolation-super-power-v-000
/lib/display_rainbow.rb
UTF-8
247
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def display_rainbow(any) print "R: #{any [0]},", " O: #{any [1]},", " Y: #{any [2]},", " G: #{any [3]},", " B: #{any [4]},", " I: #{any [5]},", " V: #{any [6]}\n" end colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
true
182a850ed1ff0c4b5fee77f5eb3fd9c6643350f4
Ruby
cp/cumulus
/lib/cumulus.rb
UTF-8
4,695
2.796875
3
[ "MIT" ]
permissive
require 'cumulus/version' require 'terminal-table' require 'cloudability' require 'netrc' require 'thor' module Cumulus class CLI < Thor include Cloudability method_options type: :string desc 'budgets', 'Displays a table of budgets' def budgets budgets = Client.new(auth_token: token).budgets ...
true
5b721419909986d3e61d9491dd833a7da4cd88e0
Ruby
dmbf29/letter-changer-429
/encrypt.rb
UTF-8
437
3.609375
4
[]
no_license
ALPHABET = ('A'..'Z').to_a def encrypt(text) text.split('').map do |character| index = ALPHABET.index(character) index ? ALPHABET[index - 3] : character end.join # range of ALPHABET # split the text to an array on each character # itterate over the letters # find the letter index in the range of A...
true
67bbfaeda3f02890cf14ace59307dc9e5597f9f7
Ruby
doahuang/misc
/hackerrank/hashmaps/twoStrings.rb
UTF-8
212
3.75
4
[]
no_license
def twoStrings(s1, s2) s1, s2 = s2, s1 if s1.length > s2.length chars = {} s1.chars.each do |el| chars[el] = true end s2.chars.each do |el| return 'YES' if chars[el] end 'NO' end
true
d9b2d69a9f1be1774c27bd53bbdc1e26ac7fa534
Ruby
tanoshiiruby/tanoshiiruby.github.io
/5/list/ch21/power_of.rb
UTF-8
104
3.421875
3
[]
no_license
def power_of(n) lambda do |x| return x ** n end end cube = power_of(3) p cube.call(5) #=> 125
true
c4dd7542216e8602fc300378bab98cfec3d2d30f
Ruby
Morendil/AdventOfCode2018
/day19_rb.rb
UTF-8
111
2.65625
3
[]
no_license
a = 1 b = (a == 1) ? 10551343 : 943 a = 0 f = 1 begin a = a + f if b % f == 0 f = f + 1 end while f <= b p a
true
4068bf5cb32082c074e4851fe0d2702111cd7381
Ruby
RandyG3/Udemy
/Ruby/Section 12 Hashes I/152-Intro to Hashes.rb
UTF-8
566
3.59375
4
[]
no_license
=begin What is a Hash? A hash or has map is a data structure that stores key-value pairs. Hashes are called dictionaries, maps, or associative arrays in other languages A hash object connects unique indentifiers (keys) to values. Rules of the Hash Hash keys and has values can be objects of any typ...
true
93cc364ff5816edcf508dc02591f70962e481115
Ruby
crrood/euler
/p12.rb
UTF-8
384
3.640625
4
[]
no_license
# problem 12 # What is the value of the first triangle number to have over five hundred divisors? sum = 1 i = 2 found = false while !found factors = 0 sqrt = Math.sqrt(sum) j = 1 while j < sqrt if sum % j == 0 factors += 2 end j += 1 end if sum % sqrt == 0 factors += 1 end if factor...
true
dce36cdc84083346389d5bdd1d8c7e4c81b7a231
Ruby
XiaoA/tealeaf-precourse
/11_exercises/exercise15.rb
UTF-8
433
3.8125
4
[]
no_license
# 11_exercises/exercise15.rb # Create the array arr = ['snow', 'winter', 'ice', 'slippery', 'salted roads', 'white trees'] # Delete words that start with an 's' arr.delete_if {|string| string.start_with?("s")} # Recreate the array arr = ['snow', 'winter', 'ice', 'slippery', 'salted roads', 'white trees'] # Delete w...
true
c92b7c1a45494606163ffe47b5108f35a5bfc449
Ruby
rodrigosites/conservatoriohvl
/app/models/professor.rb
UTF-8
1,112
2.515625
3
[]
no_license
class Professor < ActiveRecord::Base #associações no banco de dados has_many :horarios, :dependent => :destroy has_many :lecionam, :dependent => :destroy has_many :cursos, through: :lecionam, :dependent => :destroy #validações validates :cpf,:rg, uniqueness: true validates :nome, :endereco, :rg, :cpf, :t...
true
313254f58a6382414f0c9d76b7ba9ca859ac5d68
Ruby
Splodge77/hwk_5_12_17_bounty
/console.rb
UTF-8
346
2.578125
3
[]
no_license
require('./models/bounty.rb') bounty1 = Bounty.new( "name" => "Vicotira", "bounty_value" => "500", "danger_level" => "4/10", "last_known_location" => "Vegas Station" ) bounty1.save() bounty1.bounty_value = 700 Bounty.update(boun...
true
918d328db1ebdfe9b23716e24bef22bb98527e78
Ruby
JordonGoodsir/Connect-Four-Terminal-app
/src/Main_Menu/game.rb
UTF-8
11,170
3.28125
3
[]
no_license
class Game @@player1_icon = "x".red @@player2_icon = "o".yellow @@turn_counter = 1 @@called0 = 0 @@called1 = 0 @@called2 = 0 @@called3 = 0 @@called4 = 0 @@called5 = 0 @@called6 = 0 @@selector_array = [" "," "," "," #{@@player1_icon} "," ...
true
2f8dece8c6936949f0fb80e54718c348cf1e29b9
Ruby
GJRamos87/GA
/05/house_example.rb
UTF-8
362
3.875
4
[]
no_license
# class House # attr_accessor :paint_color # def turn_on_sprinklers # puts "Sprinklers on!" # end # end # new_house = House.new # new_house.turn_on_sprinklers class House attr_accessor :paint_color def print_color puts "The color is: #{self.paint_color}" end end new_house = House.new_house new_house....
true
debf450e18bb7d07d1be65da236509c43f82bee5
Ruby
fiosman/App-Academy
/rails_curriculum/18_rails_lite/bin/p07_flash_server.rb
UTF-8
1,549
2.6875
3
[]
no_license
require 'rack' require_relative '../lib/controller_base.rb' require_relative '../lib/router' # Create an erroneous new dog to test the functionality of your Flash class Dog attr_reader :name, :owner def self.all @dogs ||= [] end def initialize(params = {}) params ||= {} @name, @owner = params["n...
true
3e29475740636a6d3327574923acdfc1b8b094ff
Ruby
NawarYossef/launch_school
/class_100/sum or product game.rb
UTF-8
1,442
4.59375
5
[]
no_license
def validate(num) num > 1 end def sum(num) total = 0 (1..num).each { |value| total += value } total end def product(num) total = 1 (1..num).each { |n| total *= n } total end number = '' msg2 = <<-sms *************************************** Hello! This program calculates the sum or prod...
true
c6bcfda64fff14afec205ac2e67df44f6c4dac1c
Ruby
rpersun/Ruby_Book
/More Stuff/ex6.rb
UTF-8
37
2.640625
3
[]
no_license
arr = [1,2,2,3,4,5,5,6] puts arr.uniq
true
a7feedb4f048136fe7a2298c402226282533239e
Ruby
WillLiang918/poker_etc
/poker/lib/poker.rb
UTF-8
813
3.84375
4
[]
no_license
class Card attr_reader :suit, :value def initialize(suit, value) @suit = suit @value = value end end class Deck VALUES = [:A, 2, 3, 4, 5, 6, 7, 8, 9, 10, :J, :Q, :K] SUITS = { spade: VALUES, heart: VALUES, club: VALUES, diamond: VALUES } attr_reader :deck def initialize ...
true
eed84ec06adde71f8f5d6ab59a62248a4743613d
Ruby
aleksarad/ruby-oo-object-relationships-collaborating-objects-lab-nyc04-seng-ft-041920
/lib/artist.rb
UTF-8
1,149
3.78125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative 'song.rb' class Artist attr_accessor :name @@all = [] def initialize(name) @name = name @@all << self end def self.all @@all end def add_song(song) song.artist = self end #lists all songs that belong to this artist def song...
true
709d58d490ea300b4efa4aa884167ebde209d9ca
Ruby
JonathanSerafini/sfn_policy-helpers
/lib/sfn_policy/helpers/parameters.rb
UTF-8
697
2.5625
3
[]
no_license
require 'attribute_struct' module SfnPolicy class Parameters class << self # Initialize parameters # # @return [self] def init! @parameters = AttributeStruct.hashish.new self end # Register block # # @param name [String, Symbol] name of item ...
true
cf6b0805955541010af0efb22515f1ef84813649
Ruby
Jesrogers/odin-flight-booker
/app/services/flight_finder.rb
UTF-8
431
2.75
3
[]
no_license
class FlightFinder def initialize(params) @origin = Airport.find(params[:from_airport_id]) @destination = Airport.find(params[:to_airport_id]) @date = params[:start] end def find_flights flights = Flight.where(from_airport_id: @origin, to_airport_id: @destination, start: @da...
true