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
dd2a254a968f7812aa187899a1b944f49102e972
Ruby
balalnaeem/launch-school-101-lessons
/exercises/medium_2_again/2.rb
UTF-8
1,079
4.1875
4
[]
no_license
=begin We are given a collection of spelling blocks. Each block has two letters. Limits: -Both letters in the block cannot be used. -A block cannot be used twice either. -So only one of the letters of the block can be used. And once only. In: string Out: true Al: -create a hash with block letters as key value pairs....
true
fd336332923f8c3afb3762dfb8dbac20aa328d75
Ruby
jennceng/customize_dining_experience
/app/models/ingredient.rb
UTF-8
483
2.796875
3
[]
no_license
class Ingredient < ActiveRecord::Base attr_accessor :liked, :disliked has_many :preferences validates :name, presence: true def times_recorded total = preferences.size end def statistics @liked = 0 @disliked = 0 preferences.each do |preference| if preference.likes? @liked ...
true
083d0d25ad938301c5c92fe4ba3cbcfa43241f2c
Ruby
jeffWelling/tcd
/lib/tcd/CLI.rb
UTF-8
2,125
2.640625
3
[]
no_license
=begin Copyright 2009, Jeff Welling This file is part of Traffic Control Daemon (aka, tcd). Traffic Control Daemon is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the Licens...
true
473f4b2b3cba92ccb92b59e03fa5add11ef6cff9
Ruby
DouglasAllen/code-Metaprogramming_Ruby
/raw-code/PART_II_Metaprogramming_in_Rails/gems/rspec-1.2.6/lib/spec/mocks.rb
UTF-8
9,482
2.890625
3
[ "MIT" ]
permissive
#--- # Excerpted from "Metaprogramming Ruby: Program Like the Ruby Pros", # 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 ...
true
87e34e2f166fb8b5ef6599bb9482af4f45d62126
Ruby
tylermarshal/event_reporter
/test/cleaner_test.rb
UTF-8
4,543
2.921875
3
[]
no_license
require_relative 'test_helper' require 'csv' class CleanerTest < Minitest::Test include Cleaner def test_clean_whole_row full_list = load_command('./full_event_attendees.csv') clean_file_row_3 = {:regdate => "11/12/08 13:23", :first_name => "Sarah", :last_n...
true
60d85056400563e2e8d35f822f6c3de3a377ebc0
Ruby
thisisDom/phase-0-tracks
/databases/thesocialnetwork/users.rb
UTF-8
823
2.984375
3
[]
no_license
#file used to create and populate the users table for a social networking platform #load Faker and SQLite gems require 'sqlite3' require 'faker' #create new instance of database database = SQLite3::Database.new("thesocialnetwork.db") database.results_as_hash = true # create method for creating a new user accou...
true
e8558a3889aa627817002860761579ee9365674f
Ruby
dbateman3/bubble_sort
/bubble_sort.rb
UTF-8
830
4
4
[]
no_license
def bubble_sort(array) length = array.length i = 1 temp = 0 x = 0 for x in x..length - 1 do while i < length if array[i - 1] > array[i] temp = array[i - 1] array[i - 1] = array[i] array[i] = temp end i += 1 end i = 1 end return array end def bubble_sort_by(array) length = array.l...
true
61fcf2ddbadb929e9aa96b31154611dace715017
Ruby
akampjes/nonogram
/app/models/puzzle.rb
UTF-8
605
2.53125
3
[ "MIT" ]
permissive
class Puzzle < ActiveRecord::Base DEFAULT_BOARD_SIZE = 5 DEFAULT_MAX_COLORS = 1 MAXIMUM_COLORS = 5 MINIMUM_BOARD_SIZE = 5 attr_accessor :number_of_colors has_many :legends, dependent: :destroy after_initialize :default_values validates :board_size, numericality: { greater_than_or_equal_to: MINIMUM_B...
true
798be2b13087b0b0da52a9c677890d23a9b70aa1
Ruby
klaszcze/codility_lessons
/2_perm_check.rb
UTF-8
210
3.03125
3
[]
no_license
def solution(a) unless a.max == a.length return 0 end tab = [0]*a.length for i in 0..a.length-1 do if tab[a[i]-1] == 0 tab[a[i]-1] = 1 else return 0 end end return 1 end
true
ef1e2b165a231705e7b704dfe9df9261f5a2dcab
Ruby
troygnichols/exercism
/ruby/gigasecond/gigasecond.rb
UTF-8
99
2.796875
3
[]
no_license
class Gigasecond GIGA = 1_000_000_000 def self.from(t) Time.at(t.to_i + GIGA) end end
true
4f7a1c1e50fb185919b3dc12e95edd56201f412b
Ruby
manasg/yahsort
/lib/yahsort.rb
UTF-8
954
3.015625
3
[ "MIT" ]
permissive
require "yahsort/version" require "yahsort/helper" module Yahsort # dig should indicate the 'digits' # sec is secondary idx, number based match is done on same secondaries # db1 api2 ==> api2, db1 # prod0api1 ---> secondary = prod0api, dig = 1 PATTERN = '^(?<sec>\w*\D)(?<dig>\d+)' REGEX = Regexp.new(PATTER...
true
8bd15e3266333d2365ee9b1d21fd5d929af7c6fc
Ruby
gjtorikian/branta
/vendor/gems/ruby/2.1.0/gems/minitest-focus-1.1.0/lib/minitest/focus4.rb
UTF-8
638
2.6875
3
[ "MIT" ]
permissive
class MiniTest::Unit::TestCase # :nodoc: ## # Focus on the next test defined. Cumulative. Equivalent to # running with command line arg: -n /test_name|.../ # # class MyTest < MiniTest::Unit::TestCase # ... # focus # def test_pass; ... end # this one will run # ... # end def se...
true
1eb4874579863065cca56fa84e37c54aa88b2251
Ruby
miry/samples
/algorithms/problems/interviewcake/reverse_words_test.rb
UTF-8
1,095
2.9375
3
[ "MIT" ]
permissive
# frozen_string_literal: false require 'minitest/autorun' require_relative 'reverse_words.rb' class ReverseWordsTest < Minitest::Test def test_with_nil assert_nil reverse_words(nil) end def test_with_empty assert_equal '', reverse_words('') end def test_with_one_word assert_equal 'one', rever...
true
74ebfcbd7e3ac077cf74fae2ae923149c19b5fb9
Ruby
sccp2017/defective-project
/src/04_array_hash/check_renban_normal.rb
UTF-8
441
3.78125
4
[]
no_license
# Check if num is renban. # input : Integer # output : TrueClass/FalseClass # e.g. : # check_renban(123) # => true # check_renban(-123) # => true # check_renban(345) # => true # check_renban(987) # => true # check_renban(124) # => false def check_renban num arr = num.abs .to_s ...
true
e56fea56e2f90a10e9cc33edcab6a054f8269793
Ruby
philihp/rubykon
/lib/mcts/root.rb
UTF-8
932
2.734375
3
[ "MIT" ]
permissive
module MCTS class Root < Node def initialize(game_state) super game_state, nil, nil end def root? true end def best_child children.max_by &:win_percentage end def best_move best_child.move end def explore_tree selected_node = select playout_n...
true
5614d990501b70c38b6201bc50428b3ec730e639
Ruby
SoniaQ/bookmark_manager-1
/lib/link.rb
UTF-8
1,598
3.125
3
[]
no_license
require_relative './database_connection' require 'uri' class Link attr_reader :id, :url, :title def initialize(id, url, title) @id = id @url = url @title = title end def self.all result = DatabaseConnection.query("SELECT * FROM links") result.map { |link| Link.new(link['id'], link['url'],...
true
9369dea1ae51c34854c81ff990f299b592a8b6da
Ruby
al2o3cr/two_tents
/app/models/participant.rb
UTF-8
6,883
2.625
3
[]
no_license
class Participant < ActiveRecord::Base belongs_to :family belongs_to :user # has_many :registrations before_destroy :validate_no_dependents validates_presence_of :birthdate def participant_address1 address1.present? ? address1 : family.family_address1 end def participant_address2 address2.pre...
true
a8429c8219c3e28153eaa44abbdc7213165295f7
Ruby
AgataMatoga/ror-tasks
/task-4/test/user.rb
UTF-8
3,615
2.71875
3
[]
no_license
require_relative 'test_helper' require_relative '../lib/user' require_relative '../lib/todo_list' require_relative '../lib/todo_item' describe User do include TestHelper before(:each) do @valid_attributes = { :id => 3, :name => 'Joanna', :surname => 'Kowalska', :password => 'joasia19l...
true
7db3c9425939b65807d1b1eac40515e8e808eebe
Ruby
Augustine-/advent-code
/day-4/day-4-part-1.rb
UTF-8
1,350
3.78125
4
[]
no_license
=begin --- Day 4: The Ideal Stocking Stuffer --- Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the economically forward-thinking little girls and boys. To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes. Th...
true
f642b6327d82d9e5f03902c52b75a9466a90eaf2
Ruby
tariqhamid/crown-marketplace
/lib/tasks/management_consultancy/scripts/add_suppliers.rb
UTF-8
1,007
2.546875
3
[ "MIT" ]
permissive
require 'roo' require 'json' require 'capybara' require 'aws-sdk-s3' def add_suppliers suppliers_workbook = Roo::Spreadsheet.open(suppliers_workbook_filepath, extension: :xlsx) headers = { name: 'Supplier name', contact_email: 'Email address', telephone_number: 'Phone number', website: 'Website UR...
true
c18d0558018acc3a332baca2620024dcc04ae412
Ruby
austenjohnson/ruby-warmups
/element_picker.rb
UTF-8
914
4.59375
5
[]
no_license
# Write a program that allows a user to enter input and then choose even or odd to print all of the words at that index puts 'Enter some input: ' @input = gets.chomp.downcase def convert_to_arr arr = @input.gsub(/\W+/, ',') @arr2 = arr.split(",") odd_or_even end def odd_or_even puts 'Now choose odd or even to...
true
6b0a69cc383dc80fad2e14659838c80f7f8c8741
Ruby
pratikkamthe98/RubyProgramms
/leapyear.rb
UTF-8
595
3.75
4
[]
no_license
puts "Enter Year: " year=gets.chomp.to_i if year % 400 == 0 puts "#{year} is a leap year" elsif year % 4 == 0 && year % 100 !=0 puts "#{year} is a leap year" else puts "#{year} is not a leap year" end =begin Finding All Leap years in given range =end puts "Enter the starting year of range:" startpoint = gets.cho...
true
df0f387162d3ba750fe4ae029e4d237380825cf6
Ruby
Vicky099/sample-program
/proc_lam.rb
UTF-8
970
3.453125
3
[]
no_license
class Test #Return behavior using proc and lambda def lambda_test puts "Before lambda return" lam = lambda { return } lam.call puts "After lambda return" end def proc_test puts "Before proc return" p = proc { return } p.call puts "After proc return" end def block_test p "after block call" ...
true
f80877fce7d040706b24a6a6d027dab7de3be620
Ruby
decentralvision/ruby-collaborating-objects-lab-online-web-ft-011419
/lib/song.rb
UTF-8
401
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :name, :artist, :genre @@all = [] def initialize(name) @name = name end def self.new_by_filename(file_name) song_array = file_name[0..-5].split(' - ') new_song = self.new(song_array[1]) new_song.genre = song_array[2] artist = Artist.find_or_create_by_name(song_arra...
true
0adcc91fb023704eb750a7c76ff5ba0498e78094
Ruby
Rsaphra/blood-oath-relations-nyc-web-051319
/tools/console.rb
UTF-8
1,763
2.96875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative '../config/environment.rb' def reload load 'config/environment.rb' end # Insert code here to run before hitting the binding.pry # This is a convenient place to define variables and/or set up new object instances, # so they will be available to test and play around with in your console necronomicult...
true
a5b6e0de0b6c6fb61dd148b82c864dbb2b0fb24d
Ruby
gglin/project-euler
/ruby_all/275.rb
UTF-8
940
3.28125
3
[]
no_license
# Problem 275: Balanced Sculptures # http://projecteuler.net/problem=275 # Let us define a balanced sculpture of order n as follows: # A polyomino made up of n+1 tiles known as the blocks (n tiles) and the plinth (remaining tile); # the plinth has its centre at position (x = 0, y = 0); # the blocks have y-coordinates ...
true
9264227c6c6179f63a340461a6deabef098b04e5
Ruby
ilya0/WDI_Labs
/labs/SQLlab/app.rb
UTF-8
955
2.921875
3
[]
no_license
require 'pg' conn = PG.connect( dbname: 'world' ) # conn.exec( "SELECT * FROM country" ) do |result| # result.each do |row| # puts row["code"] conn.exec("INSERT INTO country VALUES ('XXX','Sexhualshokolate','Asia','Asia',652090,1969,22720000,69,5976.00,69,'Afqanestan','Asia','Mike Hunt',1,'XX')") do |resu...
true
c0a974f58b78040ea58c7eb1e6918113a10dc8a8
Ruby
dylanratcliffe/puppetlabs-cd4pe_deployments
/lib/puppet_x/puppetlabs/gzip_helper.rb
UTF-8
1,844
2.734375
3
[]
no_license
require 'zlib' module PuppetX::Puppetlabs # A static class to unzip .tar.gz files class GZipHelper TAR_LONGLINK = '././@LongLink'.freeze SYMLINK_SYMBOL = '2'.freeze def self.unzip(zipped_file_path, destination_path) # helper functions def self.make_dir(entry, dest) FileUtils.rm_r...
true
3a97079544fdc810e4a4faebb0668b9a0b005280
Ruby
unscaled/unscaled
/bin/runner
UTF-8
1,129
2.578125
3
[]
no_license
#!/usr/bin/env ruby require 'bundler/setup' require_relative "../lib/unscaled" require 'active_support/all' CONFIGS = { "foo" => { processes: { 1 => {id: 1, command: 'ls /'}, 2 => {id: 2, command: 'python -m SimpleHTTPServer 8000'} } } } raise "Must give name" unless ARGV[0].present? process_l...
true
42bae14ca3fda2ff6e8b834eca82a89f12904bf9
Ruby
staticimport/cranberry
/archive/ruby/lib/common/grammar/expression/binary_expression.rb
UTF-8
1,761
3.34375
3
[]
no_license
require 'lib/common/grammar/expression.rb' module Cranberry class BinaryExpression < Expression attr_accessor :left, :right, :operator def initialize(expr_type, left, right, operator) super(expr_type) raise "Left and Right types should match" unless @left.type == @right.type @left = left ...
true
145fff27693756b88b2ce514fdf01f34b1a4a3d7
Ruby
enowmbi/Ruby-Exercises
/mymath.rb
UTF-8
249
3.109375
3
[]
no_license
module MyMath class Math2 def initialize puts "initializing math class" end def factorial(number) if number <= 1 return 1 end if number > 1 return number * factorial(number -1) end end end end #p "displaying factorial of #{factorial(10)}"
true
89498e0dfe3972cd73e88f280a52c89ab7f08469
Ruby
HACKeverything/Sieve-of-Eratosthenes
/sieve.rb
UTF-8
821
3.796875
4
[]
no_license
class Sieve attr_reader :limit, :tag def initialize(n) limit_error(n) @limit = n @tag = {} for i in 2..n @tag[i] = :true end end def primes arr = [] test_if_key_is_prime for i in 2..limit if tag[i] == :true arr << i end end arr end pri...
true
33baeb12e8db623267c255c5a359f7f86a28bf6a
Ruby
LiubovKleimenova/jungle_on_rails
/spec/models/product_spec.rb
UTF-8
1,776
2.546875
3
[]
no_license
require 'rails_helper' RSpec.describe Product, type: :model do describe 'Validations' do it 'checks if there is no name for new records' do @category = Category.new @product = Product.new expect(@product.name).to be_nil end it 'ensures that a product with all four fields set will ind...
true
742e947b4fa446284495d37c43108d3a49919520
Ruby
iagosant/cost_calculator
/opportunity_cost.rb
UTF-8
3,461
3.84375
4
[]
no_license
class Activity attr_accessor :activity_name, :time_investment, :direct_cost, :satisfaction_index, :activity_cost def initialize(activity_name, time_investment, direct_cost, satisfaction_index, activity_cost) @activity_name = activity_name @time_investment = time_investment @direct_cost = direct_cost...
true
3bd156bb8ffe0b2bb999315f6af2c9fffbf51450
Ruby
ajcf/catpictures
/application.rb
UTF-8
2,193
2.78125
3
[]
no_license
require 'sinatra' require 'securerandom' require_relative 'cat_api' ##################### Configuration ##################### # load secret key from application.yml unless deploying to heroku if ENV['SECRET'] SECRET = ENV['SECRET'] else SECRET = YAML.load_file("config/application.yml")['secret'] end # enable...
true
bebac1099178cba3151d14c05a60e2c9e75d337b
Ruby
PrateekAlakh/Ruby-Programmes
/proc6_lambda.rb
UTF-8
97
3.078125
3
[]
no_license
def test ob=Proc.new{return "123"} a=ob.call puts "a is = #{a}" "789" end b=test p b
true
17f61a662593b0d0a06dfdf04f8d992cd13f2a33
Ruby
dohoonk/cafe
/app/controllers/users_controller.rb
UTF-8
4,861
2.65625
3
[]
no_license
class UsersController < ApplicationController def new @user = User.new end def edit @user = current_user end def update @user = current_user if @user.update user_params redirect_to user_path(@user), alert: "Updated" else render :edit end end def create @user = Us...
true
9eb76a26ea8415f2e76d35f86dff8b6e78f281dc
Ruby
robacarp/cryptopals
/shared/hamming.rb
UTF-8
417
3.484375
3
[]
no_license
class Shared class Hamming def self.distance str1, str2 # check to make sure that str1 is always the shorter string if str1.length > str2.length str1, str2 = str2, str1 end tuples = binary_str1.split('').zip binary_str2.split('') distance = 0.0 tuples.each do |a,b| ...
true
b68f9c5019608dca80d7150b7dffcf4306dc1081
Ruby
kyaroch/Miscellaneous-simple-scripts
/habsscrape.rb
UTF-8
3,220
2.75
3
[]
no_license
require 'nokogiri' require 'open-uri' require 'tumblr_client' load 'habs_config.rb' class UnsuitableURLError < StandardError; end Tumblr.configure do |config| config.consumer_key = CONSUMER_KEY config.consumer_secret = CONSUMER_SECRET config.oauth_token = OAUTH_TOKEN config.oauth_token_secret = OAUTH_TOKEN_S...
true
cf29c049978034351f345e4b694025244cb529d1
Ruby
Nasty8k/Ruby
/lab1/lib/main.rb
UTF-8
911
3.65625
4
[]
no_license
# frozen_string_literal: true require_relative 'converter_ckf' class Main def self.number_reader numbers = gets.chomp if numbers.to_f.to_i.to_s == numbers numbers.to_i else 'error' end end def self.start puts 'Enter value for degrees' value = number_reader if value == 'e...
true
d896bb305d3c6a76f965ae041c999aa9397ba955
Ruby
arafat8seed/TTS_Code_practice
/string reverse.rb
UTF-8
149
3.265625
3
[]
no_license
def string_reverse(word) letter = word.chars backwords=[] until letter.empty? backwords.push(letters.pop) end backwords.join end
true
c83dfe60e99073e722ddfa846af08e29fd8d6b2e
Ruby
h4hany/yeet-the-leet
/algorithms/Easy/1413.minimum-value-to-get-positive-step-by-step-sum.rb
UTF-8
1,426
3.609375
4
[]
no_license
# # @lc app=leetcode id=1413 lang=ruby # # [1413] Minimum Value to Get Positive Step by Step Sum # # https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/description/ # # algorithms # Easy (65.12%) # Total Accepted: 17.1K # Total Submissions: 26.3K # Testcase Example: '[-3,2,-3,4,2]\r' # # G...
true
39f2fc70520c2e8e2fd9d023033c2dbfb41e76fa
Ruby
mundocalderon/rails
/capsf-web-old/app/models/old_user.rb
UTF-8
1,419
2.53125
3
[]
no_license
class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation, :username, :first_name, :last_name, :role attr_accessor :password before_save :encrypt_password after_save :clear_password EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i validates :username, :presence => t...
true
e6cf843e5c4bfb5d0d8e59d67c867317b46b46f1
Ruby
MariiaAlehina/trip
/app/models/route.rb
UTF-8
910
2.796875
3
[]
no_license
class Route < ActiveRecord::Base validates :title, presence: true validate :stations_count has_many :railway_stations_routes has_many :railway_stations, through: :railway_stations_routes has_many :trains before_validation :set_name scope :with_station, -> (station) { Route.joins(:railway_stations).wher...
true
760bf09e11da63984c3530820fff2a0375fabc6a
Ruby
louie728/mldat
/script/create_import_file.rb
UTF-8
4,194
2.71875
3
[]
no_license
# little script to format sebco data into import data require './config/environment' puts "Deleting all from import file table" ImpFrmt.delete_all # go through website book table and insert data first from there Book.all.each do |b| #puts "Creating an import record for #{b.title} : #{b.ISBN13}" ebook_isbn = (b....
true
fc72d587d3d7f727ae6a96002781a7c21025bc68
Ruby
giginet/danger-xcprofiler
/lib/xcprofiler/danger_reporter.rb
UTF-8
2,368
2.734375
3
[ "MIT" ]
permissive
require 'xcprofiler' require 'pathname' module Danger class DangerReporter < Xcprofiler::AbstractReporter def initialize(dangerfile, thresholds, inline_mode, working_dir, ignored_files) super({}) @dangerfile = dangerfile @thresholds = thresholds @inline_mode = inline_mode @working_d...
true
b157f788bd76a469f6f68a9a5c5eebd73527fd49
Ruby
Rpascar1/sql-library-lab-online-web-ft-090919
/lib/querying.rb
UTF-8
1,248
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def select_books_titles_and_years_in_first_series_order_by_year "SELECT books.title, books.year FROM books where books.series_id =1" end def select_name_and_motto_of_char_with_longest_motto "SELECT characters.name, characters.motto from characters ORDER BY LENGTH(motto) DESC limit 1" end def select_value_and_cou...
true
6238b188df48597642a3c84d8301013d8888b3f5
Ruby
anuja-joshi/currency-convertor
/lib/user_input.rb
UTF-8
147
2.75
3
[]
no_license
# This handles user input class UserInput # TODO: Add validation based on input type def accept(msg) p msg gets.chomp.upcase end end
true
0471fbf729e8ad46806e62db68539cb977398d8b
Ruby
jeremira/TOP
/Ruby/Chess-game/spec/chess_spec.rb
UTF-8
7,529
3.125
3
[]
no_license
require 'spec_helper' describe Chess do describe "#new" do before :all do @chess = Chess.new end it "create a new board" do expect(@chess).to be_an_instance_of(Chess) end it "grid has 8x8 case" do expect(@chess.board.length).to be_eql (64) end it "random case in the middle have nil value" do ...
true
42d5a84cf88933d44d84d74333b123765665a7d8
Ruby
SarahBunker/rb101_programming_foundations
/lesson_5/sorting.rb
UTF-8
487
2.671875
3
[]
no_license
=begin sorting normally done on arrays since order matters strings don't have sorting, but can be converted to array and then sorted hash can be sorted, but since accessed with keys normally don't do this Sorting done by comparison doesn't know it is a list of numbers or letters uses <=> spaceship operator ...
true
296e6609e1f0fc8ba41a865fb89b197bc463702a
Ruby
shunal/sql-crowdfunding-lab-online-web-ft-071519
/lib/sql_queries.rb
UTF-8
1,798
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
84cac96615d4c41fe92fbdde87210aea00d3adc2
Ruby
Yobisense/rtesseract
/spec/rtesseract_spec.rb
UTF-8
12,865
2.625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') # encoding: UTF-8 require 'pathname' # Class to rise error class MakeStringError def to_s fail 'error' end end describe 'Rtesseract' do before do @path = Pathname.new(__FILE__.gsub('rtesseract_spec.rb', '')).expand_path @image_tif = @...
true
c15bee2cc4361e99575dae5d0594c80193a3e45c
Ruby
JortzFromSchool/W2D2
/jonathan_ortiz_hotel_project/lib/hotel.rb
UTF-8
1,257
3.828125
4
[]
no_license
require_relative "room" class Hotel def initialize(name, rooms) @name = name @rooms = {} rooms.each_key do |room| @rooms[room] = Room.new(rooms[room]) end end attr_reader :rooms def name result = [] @name.split(" ").each do |word| ...
true
ee5102dc93c5fb138955d93d836581ade4aa4cee
Ruby
tenaciousdee/weather
/weather.rb
UTF-8
126
2.765625
3
[]
no_license
a = [] File.open('weather.dat') do |f| f.each_line.each do |line| a << line.split.map(&:to_i) end end puts a.inspect
true
c2c491374a564baa20739370b1e3ed163f3c2248
Ruby
Sam-Fraser/Chess
/spec/linear_moves_spec.rb
UTF-8
2,502
3.4375
3
[]
no_license
#spec/queen_spec.rb require "./lib/queen.rb" require "./lib/board.rb" describe LinearMoves do before(:each) do @board = Board.new @queen = Queen.new([3,3], "w_queen", @board) end describe "#straight_moves" do it "will return all possible moves a linear piece can do to the right" do expect(@que...
true
74a204c3029096f130b6a3ab5da119692a4b6dcf
Ruby
chloeverity/noteapp
/spec/notepad_spec.rb
UTF-8
687
2.890625
3
[]
no_license
require 'notepad' describe Notepad do it 'adds a note and lists it out' do notepad = Notepad.new notepad.add("Horse notes", "I love horses") expect(notepad.list).to eq "Horse notes" end it 'adds two notes and lists them out' do notepad = Notepad.new notepad.add("Cat notes", "I love cats") notepa...
true
750245f436b8cb832bf869699b31705c1821813e
Ruby
rlogwood/game-of-life
/gol_cell.rb
UTF-8
1,580
3.59375
4
[]
no_license
# representation of a cell in the game of life board class GolCell attr_reader :row, :col, :alive, :visual def initialize(row, col) @row = row @col = col @alive = false @visual = nil @next_state = nil end # Any live cell with two or three live neighbours survives. # Any dead cell wit...
true
f1f80586e6618f2f486f74b99eaa374205986725
Ruby
niam0r/exercism
/ruby/pig-latin/pig_latin.rb
UTF-8
721
3.375
3
[]
no_license
class PigLatin def self.translate(input) input.split(' ').map { |word| process_word(word) }.join(' ') end def self.process_word(word) vowels = ['a','e','i','o','u'] consonants = [*'a'..'z'] - vowels if word.start_with?(*vowels, 'xr','yt') "#{word}ay" elsif word.=~(/\A[^aeiouy]qu/) ...
true
ad7b8287f856a1589cb4b928a15d351535aaa557
Ruby
someotherkyle/daily-programmer
/ruby/perfectlyBalanced/solution.rb
UTF-8
932
3.71875
4
[]
no_license
require 'pry' def generate_hash(input) count = Hash.new(0) i = 0 while i < input.length() count[input[i]] += 1 i += 1 end count end def balanced(input) count = generate_hash(input) if count["x"] != count["y"] return false end true end def balanced_bonus(input) count = generate_hash(in...
true
02ee0311d53c36c494220c796682a774591bbf78
Ruby
doublewordscore/W2D4
/anagrams.rb
UTF-8
1,460
3.984375
4
[]
no_license
def anagrams1(string) # O(n!) result = [] string = string.split"" if string.length == 1 return [string[0]] end string.length.times do string.rotate! letter = string.take(1) substring = string.drop(1) substrings = anagrams1(substring.join) # debugger substrings.each do |word| ...
true
7411701b499350baacbc5843537abca7564b8f2b
Ruby
KSriki/resume_game
/app/models/industry.rb
UTF-8
585
2.796875
3
[]
no_license
class Industry < ApplicationRecord has_many :companies # before_validation :remove_whitespace validates :field, format: { with: /\A[\w\s]+\z/, message: "only allows letters" } # def remove_whitespace # self.field.chomp! # end def self.count_companies industries = {} Company.all....
true
addb898c23a712d659634f68093211c1f943f5df
Ruby
Spelmo/email-scrapping-and-google-drive-API
/spreadsheet_scrapper/spreadsheet_scrapper.rb
UTF-8
739
3.140625
3
[]
no_license
require "google_drive" class Spreadsheet def initialize end def write(hash) session = GoogleDrive::Session.from_config("config.json") ws = session.spreadsheet_by_key("1MSf9hQ9RgzZ-6_ioP0w45BH0wdM1exx1TKg8XJcoRAs").worksheets[0] # Changes content of cells. # Changes are not sent to the server until you ca...
true
0bd25143e1e16dec1296167c85e843388bafe719
Ruby
AndrewRLloyd88/pokemon-site-rails
/app/controllers/pokemon_controller.rb
UTF-8
526
2.6875
3
[]
no_license
class PokemonController < ApplicationController def index end def search pokemon = find_pokemon(params[:number]) unless pokemon flash[:alert] = 'Pokemon not found' return render action: :index end @pokemon_name = pokemon["name"].capitalize() end private def request_api(url) ...
true
a363bd4742073e97c902ba147e349d41905f3a72
Ruby
woodpeckershop/mathGame
/player.rb
UTF-8
154
3.5625
4
[]
no_license
class Player attr_reader :name attr_accessor :life def initialize(name) @name = name @life = 3 end def loser? @life == 0 end end
true
833ee650fd197d620397276599855eb636ae81fe
Ruby
bvanderlaan/testtrack-cli
/lib/testtrack/hash.rb
UTF-8
437
3.40625
3
[ "MIT" ]
permissive
# I got the method_missing hit from http://www.goodercode.com/wp/convert-your-hash-keys-to-object-properties-in-ruby class Hash def method_missing(name) return self[name] if key? name self.each do |key, value| return value if key.to_s.to_sym == name super.method_mimssing name end end def respond_to?(s...
true
c0737017474d6b02daaf75e68ef87b3f8288a35d
Ruby
zackmdavis/App_Academy_Exercises
/Week_4/TwitterClient/lib/twitter_session.rb
UTF-8
1,291
2.890625
3
[]
no_license
require 'singleton' require 'oauth' require 'launchy' require 'yaml' require './consumer_constants' class TwitterSession attr_reader :access_token include Singleton include ConsumerConstants CONSUMER = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => "https://twitter.com") TOKEN_SAVE_FILE = "sav...
true
ea2988be072debaaa83800daee70be1a143e3648
Ruby
vespa-engine/system-test
/lib/nodetypes/qrs.rb
UTF-8
875
2.53125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. class Qrs attr_accessor :qrserver def initialize(testcase, vespa) @testcase = testcase @vespa = vespa @qrserver = {} end def empty? @qrserver.empty? end def wait_until_ready(t...
true
e6b0177b3dea41e6537257f96303d98e527b521c
Ruby
sharatsridhar/Movie-Sort
/moviesort.rb
UTF-8
4,347
3
3
[]
no_license
#Author: Sharat Sridhar class Movies attr_accessor :rating, :movie_id @@movies_db = Hash.new @@count = 0 def self.movies_db @@movies_db end def self.movies_db=(hash=Hash.new) @@movies_db = hash end def self.create_with_attributes(movie_id, rating) movie = self.new #movie.movie_id = movie_id movi...
true
45dc776913690b415a4ad9eb1e7af82f41e5630c
Ruby
edward/yard
/lib/yard/core_ext/symbol_hash.rb
UTF-8
658
3.109375
3
[ "MIT" ]
permissive
class SymbolHash < Hash def initialize(symbolize_value = true) @symbolize_value = symbolize_value end def self.[](*hsh) obj = new; if hsh.size == 1 && hsh.first.is_a?(Hash) hsh.first.each {|k,v| obj[k] = v } else 0.step(hsh.size, 2) {|n| obj[hsh[n]] = hsh[n+1] } end obj en...
true
d705d7d3f448cf38cac80d4c59a193bcc0e61b85
Ruby
Lokideos/ruby-think-project
/lesson-8/hw-les-8/car.rb
UTF-8
371
2.546875
3
[]
no_license
class Car include Manufacturable attr_reader :car_id alias id car_id def initialize(_attrib) validate! @car_id = object_id.to_s @manufacture = 'Toshiba' end def valid? validate! true rescue RuntimeError false end private def validate! raise 'Unexisting car type' unles...
true
ec30dd977ddd8558230de1fd29feb446eb4c1624
Ruby
ben7th/pin-discuss
/app/helpers/application_helper.rb
UTF-8
3,974
2.703125
3
[]
no_license
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def is_ie? /MSIE 6/.match(request.user_agent) end def is_ff? /Firefox/.match(request.user_agent) end # 清除一段文本中的html标签 def clear_html(text,replacement='') (text||'').gsub(/<[^>]*>/){|...
true
af2d12bb5fa809e6c4fea18972ab929e9113b331
Ruby
andreicap/Battle-City---Ruby-Gosu
/player.rb
UTF-8
680
3.34375
3
[ "MIT" ]
permissive
require_relative 'projectile.rb' class Player attr_accessor :x, :y, :phi def initialize @image = Gosu::Image.new 'resources/images/tank_player1_up_c0_t1.png' @x = @y = @phi = 0.0 @vel = 2 @score = 0 @state = 1 end def spawn(x, y, phi) @x, @y, @phi = x, y, phi end def left @ph...
true
7e67ee0b3ad79d1d7a872d472f46ddcb4d97de8d
Ruby
keibou7/repository
/chouhuku.rb
UTF-8
268
3.203125
3
[]
no_license
puts "プログラミングの勉強がしたい" puts "英語の勉強がしたい" puts "会計の勉強がしたい" def want_study(subject) puts "#{subject}の勉強がしたい" end want_study("プログラミング") want_study("英語") want_study("会計")
true
3f189ae1175b72dc18ebf56f2dce8914cd1a7c1e
Ruby
OpenGems/rails_email_checker
/lib/rails_email_checker/configuration.rb
UTF-8
1,862
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module RailsEmailChecker class Configuration attr_accessor :regex_email, :blacklist_domains, :whitelist_domains, :timeouts def initialize @regex_email = REGEX_EMAIL @blacklist_domains = default_blacklist_domains ...
true
5339904d2f5cf875a668d4eed50e3df454fc3bff
Ruby
normanrs/ex_ruby
/accumulate/accumulate.rb
UTF-8
162
2.796875
3
[]
no_license
# frozen_string_literal: true class Array def accumulate if empty? self else map do |elem| yield(elem) end end end end
true
8ca4ecccc16eb19c2f3576e3bb6c5339f768296c
Ruby
manchester-tech-events/techevents-nw
/gems/ruby/2.2.0/gems/therubyracer-0.12.2/benchmarks.rb
UTF-8
4,704
3.015625
3
[ "MIT" ]
permissive
require 'rubygems' require 'bundler/setup' require 'v8' require 'benchmark' require 'optparse' OPTIONS = { :times => 5, :mode => :object, :objects => 500 } parser = OptionParser.new do |opts| opts.on("-t", "--times [T]", Integer, "run benchmark N times") do |t| OPTIONS[:times] = t end opts.on("-m", "...
true
e1271e838c2be6100176b993a91d317828db4d7c
Ruby
AngelusProductions/launch-academy-coursework
/Ruby/the-right-clubs/code.rb
UTF-8
1,016
3.484375
3
[]
no_license
REQUIRED_BAG_SIZE = 10 available_clubs = [ :two_iron, :three_iron, :four_iron, :five_iron, :six_iron, :seven_iron, :eight_iron, :nine_iron, :pitching_wedge, :sand_wedge, :driver, :three_wood, :five_wood, :seven_wood, :putter ] index = 0 golf_bag = Array.new puts "\n" while index < REQU...
true
fc471abed4c8cc1bfa1d2c5106b56ab7f740d4c1
Ruby
KitaitiMakoto/epub-parser
/lib/epub/searcher/publication.rb
UTF-8
5,014
2.65625
3
[ "MIT" ]
permissive
require 'epub/publication' module EPUB module Searcher class Publication class << self def search_text(package, word, **options) new(package).search_text(word, options) end def search_element(package, css: nil, xpath: nil, namespaces: {}) new(package).search_ele...
true
079268bb5347f352984d505d1094f524da486620
Ruby
kaiomagalhaes/ruby-exercism
/ruby/robot-name/robot_name.rb
UTF-8
584
3.171875
3
[]
no_license
# frozen_string_literal: true # Can be found at: http://exercism.io/submissions/5befa43a2e4844b4a9036323ca58b312 class Robot @@used_names = [] def name @name ||= mount_name end def reset @@used_names.delete @name @name = nil end private def mount_name name = rand_char(2).join + rand_n...
true
dedbc1ca6b451c4e0989c9ccfa03dc1779e98017
Ruby
psagan/referrals
/app/services/referrals/capture_referral_action_service.rb
UTF-8
911
2.578125
3
[ "MIT" ]
permissive
module Referrals class CaptureReferralActionService private attr_reader :referral, :amount, :info public def initialize(referral:, amount:, info:) @referral = referral @amount = amount # instance of Money @info = info end def call return unless partner partner...
true
ef7e0b53b7da30bdff4f7c3dada0d8f75391b8d3
Ruby
LouiseReid/multiple-classes-ecosystem
/river.rb
UTF-8
355
3.59375
4
[]
no_license
class River def initialize(name, fish, fish_population) @name = name @fish = [] @population = fish_population end def fish_count() @fish.count end def add_fish(fish) @fish << fish end def remove_fish() @fish.pop() end def hold_many_fish(fish1, fish2, fish3) @fish << fish1 << fish2 << fish3 end def...
true
32a06a827218edc6760b89aaf0bc828e4526a0b5
Ruby
rcchen/latex-editor
/server.rb
UTF-8
1,041
2.609375
3
[]
no_license
require 'json' require 'sinatra' require 'tempfile' get '/' do send_file File.expand_path('index.html', settings.public_folder) end get '/file/:uuid' do send_file File.expand_path('tmp/' + params[:uuid] + '.pdf', settings.public_folder) end post '/render' do # Representations of the file filename = ...
true
60e364ff899a9c0e27c8c97ca4f0e0bb37ff6b80
Ruby
mikejmoore/system_track_shared
/lib/utils/ip_utils.rb
UTF-8
219
3.03125
3
[ "MIT" ]
permissive
def padded_ip(ip_address) parts = ip_address.split(".") new_parts = [] parts.each do |part| while(part.length < 3) part = "0" + part end new_parts << part end return new_parts.join(".") end
true
b9ddfd6fc8598bd845af0b3c3977448fe68a0c9a
Ruby
powersjcb/notes
/w1d2/file_shuffler.rb
UTF-8
259
2.71875
3
[]
no_license
def file_shuffler(file_name) file_text = File.readlines(file_name) file_text = file_text.shuffle new_file_name = "#{file_name.split('.')[0]}_shuffle.txt" File.open(new_file_name, 'w') do |f| f.puts (file_text) end end file_shuffler("rps.rb")
true
9918e3db855487ed61121206f0db87448fd70fa0
Ruby
dutrapedro/yaml_searcher
/lib/yaml_searcher.rb
UTF-8
556
2.53125
3
[ "MIT" ]
permissive
require_relative 'yaml_searcher/version' require_relative 'searcher' require_relative 'report' require 'logger' module YamlSearcher class << self attr_accessor :logger def start(path:, search_pattern:) start = Time.now results = Searcher.new(path: path, pattern: search_pattern).search Re...
true
07a4f0f3c7311ea0a92c28c016421dfd2a8d2377
Ruby
alexgarbarev/gena-plugins
/openapi/generators/objc/models/objc_type.rb
UTF-8
2,882
2.90625
3
[]
no_license
require_relative 'types/objc_types' class ObjcType attr_accessor :info # [ObjcTypeInfo] attr_accessor :descr attr_accessor :example attr_accessor :is_required attr_accessor :is_array def initialize(spec_property) if spec_property self.is_required = spec_property.is_required self.is_arra...
true
63cc4acca5eca3d6af7a06734745b7ab16fe0778
Ruby
djpinchevski/course_120
/Exercises/01_Medium/04_circular_queue.rb
UTF-8
1,137
4.03125
4
[]
no_license
require 'pry' class CircularQueue attr_reader :array def initialize(max_length) @array = Array.new(max_length) end def dequeue index = array.index { |item| !item.nil? } return index if index.nil? item = array[index] array[index] = nil item end def enqueue(item) move_queue_ove...
true
3efd0e59c92ca1ae931bfb52f99ae4233a1dd219
Ruby
dosterius/RubyCodeWars
/The_push_Method_the_Shovel_Operator_and_the_insert_Method.rb
UTF-8
491
3.546875
4
[]
no_license
locations = ["House", "Airport", "Bar"] p locations locations.push("Restaurant", "Saloon") p locations #the shovel operator is exacly the same as push method locations << "Restaurant" locations << "Saloon" p locations locations << "Restaurant" << "Saloon" p locations # insert method adds a bit of flexibility. Sta...
true
45d7691db60298ce5b921cda1844d3a0df6db70a
Ruby
shashankshetty/TimeTien
/app/models/authentication.rb
UTF-8
1,782
2.515625
3
[ "MIT" ]
permissive
class Authentication < ActiveRecord::Base belongs_to :user attr_accessible :provider, :uid attr_accessor :email def get_auth_details_for_github(omniauth) auth_details = { 'uid' => omniauth['extra']['raw_info']['id'].to_s || '', 'provider' => omniauth['provider'] || '', 'name' => omn...
true
873b7309e860e948db99882dd91addc6ed02a942
Ruby
connicov1/visable_bank
/app/services/accounts/funds_service.rb
UTF-8
1,054
2.984375
3
[]
no_license
# frozen_string_literal: true # Opens Accounts namespace module Accounts # Creates FundsService class that uses PFAAO pattern class FundsService # Defines #call! method # # @raise [ActiveRecord::RecordInvalid] # @return [Boolean] def self.call!(account_from:, account_to:, amount:) new(acc...
true
e872351cd8ce12b6e683c95f7eb78cca8cb954df
Ruby
rodrigoulisses/rocket_pays_rails_api
/lib/rocket_pays_rails_api/product.rb
UTF-8
978
2.796875
3
[ "MIT" ]
permissive
module RocketPaysRailsApi class Product < Base # Set description attr_accessor :description # Set name attr_accessor :name # Set unit price # Should be greater than zero attr_accessor :unity_price # Set quantity # Should be greater than zero attr_accessor :quantity val...
true
b45cec944140f046a7be0e35fcdc5b41bfec0c88
Ruby
prasetiady/practice
/hackerrank/algorithms/warmup/circular_array_rotation.rb
UTF-8
321
3.265625
3
[]
no_license
#!/bin/ruby def rotate_right(a,k) if k > a.length k = k % a.length end i = a.size - k a[i..-1].concat(a[0..i-1]) end n,k,q = gets.strip.split(' ') n = n.to_i k = k.to_i q = q.to_i a = gets.strip a = a.split(' ').map(&:to_i) a = rotate_right(a,k) for a0 in (0..q-1) m = gets.strip.to_i puts a[m] end...
true
0780b405a5e784b15b8b68115f45df6964b73742
Ruby
ChuckBriggs/mastermind
/lib/board.rb
UTF-8
654
2.9375
3
[]
no_license
# frozen_string_literal: true #require 'pry'; binding.pry #rubocop:disable all # asdf class init comment module Mastermind class Board def initialize @turn_results = [] end def add_guess(arr) @turn_results[@turn_results.length] = { guess: arr, result: [] } end def add_result(hash) ...
true
1ec96667e08fbc56f965996de4dcc9745eda0cf4
Ruby
austinandrade/snowy-pine-8251
/spec/models/flight_spec.rb
UTF-8
1,476
2.59375
3
[]
no_license
require 'rails_helper' RSpec.describe Flight, type: :model do describe 'relationships' do it {should belong_to :airline} it { should have_many(:flights_passengers) } it { should have_many(:passengers).through(:flights_passengers) } end before(:each) do @airline_1 = Airline.create!(name: 'United'...
true
f165a2cea80a8db06ab1348684f5abc7a5a50a3f
Ruby
FGalvao77/myCodesInRuby
/Aula_extra_02_funcaoSaudacao.rb
UTF-8
169
3.640625
4
[]
no_license
# criando uma função de saudação def hello name puts "Olá, #{name}!" end # chamando a função com o parâmetro puts '' hello "Fernando" hello "Kátia" puts ''
true
21dad9bb57e452d778fe7fe8c69e6a97a7452746
Ruby
sportngin/octopolo
/lib/octopolo/scripts/pivotal_auth.rb
UTF-8
1,096
2.53125
3
[ "MIT" ]
permissive
require_relative "../scripts" require_relative "../pivotal" module Octopolo module Scripts class PivotalAuth include UserConfigWrapper include CLIWrapper attr_accessor :email attr_accessor :password attr_accessor :token def execute ask_credentials request_tok...
true
cd1d31bdcaa82158f8cd99cc41d038e0993ee5ba
Ruby
Jhua96/Launchschool_exercises
/lesson_2/calculator.rb
UTF-8
1,613
3.921875
4
[]
no_license
require 'yaml' MESSAGES = YAML.load_file('calculator_messages.yml') def prompt(message) puts("=> #{message}") end def valid_number?(num) return true if num == '0' num.to_i != 0 end def number?(num) num.respond_to?(:to_f) end def operation_to_message(op) case op when '1' 'Adding' when '2' 'Sub...
true
f260e580230698f6fed0f5848c9efbde3396c740
Ruby
DmitryHetman/ruby-wayland
/wl/connection.rb
UTF-8
1,147
2.78125
3
[]
no_license
require 'socket' module WL class Connection def initialize(address) @address = address @socket = UNIXSocket.new(@address) @objects = [] end def start_event_loop while header = @socket.read(8) header_content = Message.unpack_header(header) body = @socket.read(header_content[:size]-8) if...
true
6c449ad299af03e00c0f9582f8628fe1e151f208
Ruby
sethdn/bay-projection
/lib/scrape/base/topic_persister.rb
UTF-8
2,434
2.640625
3
[]
no_license
module Scrape class TopicPersister include Scrape::Saving extend Forwardable def initialize(topic_scraper) @scraper = topic_scraper @logger = @scraper.logger ? @scraper.logger : Scrape::Logger.new end attr_accessor :logger def_delegators :@scraper, :record, :record= def save...
true
12c47aea017891c1cd3aeadd687e605f8eff6a73
Ruby
Su7ech/Pre_Course
/Flow Control/exercise2.rb
UTF-8
117
3.890625
4
[]
no_license
def uppercase(string) if string.length >= 10 string.upcase end end puts uppercase("This is 10 characters long!")
true