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
6da5203107d76f5d8f107113f6fe59b2632ea20e
Ruby
MilesBradt/library_db
/lib/author.rb
UTF-8
2,126
3.109375
3
[]
no_license
require 'pg' require 'pry' class Author attr_reader(:name, :id) def initialize(attributes) @name = attributes.fetch(:name) @id = attributes.fetch(:id) end def self.all author_list = DB.exec("SELECT * FROM authors;") authors = [] author_list.each() do |author| name = author.fetch("na...
true
f48a7c7e9e6a6c84d5067ae125f16d837e13bb57
Ruby
melissa160/ruby-intro
/challenges/ruby/10-leap-years/my_solution.rb
UTF-8
1,183
3.734375
4
[]
no_license
# Leap Years # # Tu solucion abajo: # condition = true # unless !condition # p "algo" # end # p 'blahah' if condition <<<<<<< HEAD # Tu solucion abajo: def leap_year?(año) # if año%4 == 0 && año%100 != 0 # true # elsif año%4 == 0 && año%400 == 0 # true # else # false # end # año%400==0 && !(año%100==0) &&...
true
3c38d5587e082ae96876033e24c03c939338227e
Ruby
fosdev/crichton
/lib/crichton/descriptor/semantic_decorator.rb
UTF-8
1,327
2.84375
3
[ "MIT" ]
permissive
require 'crichton/descriptor/detail_decorator' require 'crichton/descriptor/options_decorator' module Crichton module Descriptor ## # Manages retrieving the data values associated with semantic descriptors from a target object. class SemanticDecorator < DetailDecorator ## # Whether the...
true
5535961d11736c832ab0b61099d11ddccdd72318
Ruby
rjp-at-insight/Ruby-Full-Stack-Development
/Intro/procs.rb
UTF-8
475
3.6875
4
[ "MIT" ]
permissive
# AUTHOR : Robert James Patterson # DATE : 09/24/2020 # FILE : procs.rb # SYNOPSIS : Work-thru file for 'Ruby Full Stack Development: Introduction'. # # using Proc.new my_proc = Proc.new { |x| puts "The argument value sent to proc is #{x}\." } puts "\nA proc object returns: '#{my_proc.cla...
true
97139fce8fc8b49382834e3b8a4a941613e4ebf5
Ruby
bestjsabc/tizzet
/app/models/ticket.rb
UTF-8
544
2.546875
3
[ "MIT" ]
permissive
class Ticket < ActiveRecord::Base belongs_to :seller, :class_name => 'User' validates_numericality_of :quantity, :price_in_cents validates_presence_of :quantity, :price_in_cents has_many :orders def self.event_types [ 'Concert', 'Sport', 'Arts and Theatre' ] end def self.seating_types [ 'Gen...
true
ea6eabef3cfd2604fc363370b58bd46394db279e
Ruby
KotlinKen/giblish
/lib/giblish/pathtree.rb
UTF-8
2,775
3.546875
4
[ "MIT" ]
permissive
# frozen_string_literal: true # This class can convert the following paths: # basedir/file_1 # basedir/file_2 # basedir/dir1/file_3 # basedir/dir1/file_4 # basedir2/dir2/dir3/file_5 # # into the following tree: # basedir # file_1 # file_2 # dir1 # file_3 # file_4 # basedir2 # dir2 # dir3 # fi...
true
936b3d45dbc4aaa1ca6bd2262283ebf28d90d946
Ruby
k220j/cloud_chamber
/lib/aws_moudle.rb
UTF-8
563
2.515625
3
[]
no_license
require 'aws-sdk' class AWS def self.initialize(access_key_id, secret_access_key, aws_s3_region) Aws.config.update({ credentials: Aws::Credentials.new(:access_key_id, :secret_access_key) }) Aws.config.update({region: 'ap-northeast-2'}) end ec2 = Aws::EC...
true
2bd23167f560c9053cc512217de376a003d9d98a
Ruby
jwhiteman/cryptopals
/scratch-work/set3-ch19-scratch.rb
UTF-8
935
2.921875
3
[]
no_license
# ks[n] = c[suspiciously-popular-byte] XOR "e" # c[spb] = ks[n] XOR "e" suspiciously_popular_byte = e2.last.first %w(E T A O I N S H R L D U e t a o i n s h r l d u).map do |guess| fixed_xor(bytes_at(b1, 2).join, (suspiciously_popular_byte.ord ^ guess.ord)) end (0..256).map { |n| [n, fixed_xor(bytes_at(b1, 2).jo...
true
2cffb6f25eea29bf021cef539943ec6f15864bed
Ruby
CHeavyarms/coding_challenge
/test/unit/temperature_test.rb
UTF-8
1,948
2.875
3
[]
no_license
require 'test_helper' class TemperatureTest < ActiveSupport::TestCase #Check validations test "temperatures are valid" do assert Temperature.find(temperatures(:one)).valid? end test "value is present to save" do temp = Temperature.new(:scale_from => "Kelvin", :scale_to => "Kelvin") assert !temp....
true
94553acf5406a032971b4cf15fcf8e915dd171cf
Ruby
rwjblue/ember-dev
/lib/ember-dev/asset.rb
UTF-8
2,079
2.625
3
[ "MIT" ]
permissive
require 'pathname' require_relative 'publish' module EmberDev module Publish class Asset attr_accessor :file, :current_revision, :current_tag, :build_type def initialize(filename, options = nil) options ||= {} self.file = Pathname.new(filename) self....
true
1fe23937922b1f65caf015589a2b30a05d6154dd
Ruby
907to407/img1
/blur1.rb
UTF-8
286
3.328125
3
[]
no_license
class List def initialize (array) @array = array end def output_list @array.each do |array| puts array.join('') end end end list = List.new([ [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0] ]) list.output_list
true
6048cc5053e39717ee20737ac8bc085a4ddc313e
Ruby
shakir11/learn_ruby_thehardway
/ex19_func_var.rb
UTF-8
425
3.8125
4
[]
no_license
def cheese_and_crackers(cheese_count, boxes_of_crackers) puts "So, you have #{cheese_count} of cheese" puts "and you have #{boxes_of_crackers} boxes of crackers" end print "Please enter the number of cheese: \n> " amount_of_cheese = gets.chomp.to_i print "Please enter the number boxes with crackers: \n> " ...
true
bbb14cb8365d05059872a7733ec2a076d4944f19
Ruby
jayl109/fa16-hw1
/foobar.rb
UTF-8
331
3.0625
3
[]
no_license
class Foobar def self.baz(a) set=a.map{|a| Integer(a)+2}.delete_if{|a|a%2==1}.delete_if{|i|i>10}.uniq sum = 0 set.each { |a| sum+=a } return sum end def foo(b) # Instance method # Call with foobar_instance.foo end def bar(c) # Instance method # Call with foobar_instance.bar ...
true
ea2633960551655b32135e8dc1ed403129d496c1
Ruby
gordoneccles/RubyDB
/lib/associatable.rb
UTF-8
3,977
2.5625
3
[]
no_license
require 'active_support/inflector' class AssocOptions attr_accessor :primary_key, :foreign_key, :class_name def model_class @class_name.constantize end def table_name @class_name.underscore + "s" end end class BelongsToOptions < AssocOptions def initialize(owner, options = {}) @primary_key...
true
c383c5093e9e179963be1a1b0596a87772b789d8
Ruby
raquelnishimoto/launchschool_RB101_RB109
/small_problems/easy1/array_average.rb
UTF-8
495
4.78125
5
[]
no_license
# Write a method that takes one argument, an array containing integers, and returns the average of all numbers in the array. # The array will never be empty and the numbers will always be positive integers. # Change the return value of average from an Integer to a Float def average(array) total = 0 array.each do |...
true
2085a0324afa6324e0a88b243a40a323e03a00a2
Ruby
cassar/skrol_basic
/lib/onboard/sentence_pair_processor.rb
UTF-8
944
2.8125
3
[]
no_license
class SentencePairProcessor def initialize(standard_script1, standard_script2, source) @standard_script1 = standard_script1 @standard_script2 = standard_script2 @entry_processor1 = SentenceEntryProcessor.new(standard_script1, source) @entry_processor2 = SentenceEntryProcessor.new(standard_script2, sou...
true
bb791c2c167903a38d12e7ac0911cb99f7de9f02
Ruby
bupekunda/ttt-3-display_board-example-ruby-intro-000
/lib/display_board.rb
UTF-8
215
3.09375
3
[]
no_license
# Define a method display_board that prints a 3x3 Tic Tac Toe Board def display_board puts "A Tic Take Toe Board" end puts " | | " puts "-----------" puts " | | " puts "-----------" puts " | | "
true
21a6621f03b1f10b89cf07c8ff80f12a7523daff
Ruby
peterla/object_oriented_programming
/sales_taxes.rb
UTF-8
4,006
4.0625
4
[]
no_license
# To keep things elegant, I'm going to create a Product class that doesn't know anything about exemptions or whether it was imported # That logic will belong to the ShoppingCart class class Product attr_accessor :name, :price def initialize(name, price) @name = name @price = price end end class Shopp...
true
e239df549cbb317679e4b2e717c12ffec0515f33
Ruby
BettyMutai/word_count
/lib/word_count.rb
UTF-8
248
3.03125
3
[ "MIT" ]
permissive
class String define_method(:word_count) do |word| my_count = 0 self.split(" ").each do |item| if(word == item) my_count = my_count+1 else #word did match my search word end end my_count end end
true
f64facf72fb8a1b069b1876b01f6a2ef7b945b8e
Ruby
jamesfoster/jq-wysihat
/vendor/sprockets/lib/sprockets/source_line.rb
UTF-8
1,677
2.53125
3
[ "MIT" ]
permissive
module Sprockets class SourceLine attr_reader :source_file, :line, :number def initialize(source_file, line, number) @source_file = source_file @line = line @number = number end def comment @comment ||= line[/^\s*\/\/(.*)/, 1] end def comment? !!comment end...
true
8b9641b2f32f0a76cded95760906b07e6431f44a
Ruby
ignisf/hipchat-pidgin-theme
/lib/manifest.rb
UTF-8
756
2.6875
3
[ "MIT" ]
permissive
module HipChat class Manifest attr_accessor :name, :description, :icon, :author, :emoticons def initialize(emoticons) @name = 'HipChat' @description = 'A HipChat smiley theme' @author = 'Petko Bordjukov' @emoticons = emoticons end def to_s output = '' output << "N...
true
f693f857053e26c265e91ff39358fc02f59c4215
Ruby
alexisteh/ruby-oo-self-count-sentences-lab-yale-web-yss-052520
/lib/count_sentences.rb
UTF-8
549
3.9375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class String def sentence? if self.end_with?(".") return true end return false end def question? if self.end_with?("?") return true end false end def exclamation? if self.end_with?("!") return true end false end def count_se...
true
1ad60cc5d6df25dfff8319d99f729638c2c428ad
Ruby
bleavitt92/ObjectOrientedProgramming
/studying/test.rb
UTF-8
1,162
3.765625
4
[]
no_license
module Magic def cast_spell end end module Armor def attach_armor end def remove_armor end end class Player attr_reader :name, :strength, :intelligence, :health def initialize(name, health=100) @name = name @health = health @strength = roll_dice @intelligence = roll_dice end d...
true
c005bdda37d59a710e51f6b3e47f5cb164f9dae1
Ruby
Amorphizm/terminal-farkle
/program.rb
UTF-8
878
3.65625
4
[]
no_license
require_relative 'player.rb' require_relative 'bot.rb' require_relative 'brains.rb' require 'io/console' num_players_valid = false while num_players_valid == false print "Enter the amount of players: " number_of_players = gets.chomp.to_i if number_of_players <= 0 or number_of_players > 6 puts "In...
true
9e24778bdfdfe983fb4f76d1745252ed6e768b0c
Ruby
cyzanfar/Palindrome-solver
/spec/palindrome_reverse_spec.rb
UTF-8
550
3.1875
3
[]
no_license
describe "PalindromeReverse" do it 'returns true when civic is passed in' do expect(PalindromeReverse.new("civic").pop_shift).to eq(true) end it 'returns false when cololloc is passed in' do expect(PalindromeReverse.new("cololloc ").pop_shift).to eq(false) end it 'returns true when aibohphobia is pa...
true
b9c6b9294db08c0fdb623837c9580190dfda95df
Ruby
aaron-contreras/ruby_rspec_TOP
/spec/11_shared_example_spec.rb
UTF-8
1,091
2.671875
3
[]
no_license
# frozen_string_literal: true # rubocop:disable Layout/LineLength # Not only will the class being tested be located in a different file, # but there are multiple classes for this example. All files begin with '11_' # To learn more about the use of shared examples, check out the documentation: # https://relishapp.com...
true
b34816dcb3f0605a6b7f334c1dfedbcc1cc5e4e5
Ruby
Jarred-Sumner/commandant
/lib/commandant/command.rb
UTF-8
870
3.171875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Commandant class Command attr_reader :description # Create a new command by name and add it to the commands list. # # @param [Symbol] name the name of the command # @param [String, nil] description the command's description # @raise [ArgumentError] if a command block is not provided ...
true
83749c4991ce6e2aabf288801b4871bdbe9544b6
Ruby
martensonbj/api_curious
/app/models/github_service.rb
UTF-8
3,463
2.75
3
[]
no_license
require 'open-uri' class GithubService attr_reader :connection def initialize(current_user) @current_user = current_user @connection = Faraday.new("https://api.github.com") @connection.headers = {"User-Agent"=>"Faraday v0.9.2", "Authorization" => "token #{@current_user.token}"} end def starred_re...
true
0fc4363729b19a47879716f0a91c4d1cf4cec1bd
Ruby
gizmore/ricer4
/lib/ricer4/core/params/target.rb
UTF-8
3,832
2.640625
3
[ "MIT" ]
permissive
# # *user*#ch*an:serv # Peter # #foo # module ActiveRecord::Magic class Param::Target < Parameter def own_multi_handler?; true; end def default_options { online:nil, # online nil=both, true=only online, false=only offline wildcard:false, autocomplete:false, # wildcard handling curr...
true
71bc36337a57146856a9ede985cb7b97d014e978
Ruby
SangMeeSpecht/Whiteboarding-DBC-Chicago
/solutions/recursive_person_creator_solution_arnamak.rb
UTF-8
894
3.5
4
[]
no_license
require 'csv' class Person def initialize(args={}) @first_name = args[:first_name] @last_name = args[:last_name] @email = args[:email] end end ################################################################################################## module RecursivePersonCreator def self.import(raw_...
true
b725dd816f5f9cdde20eab90a5a509c3ac698b28
Ruby
mcmire/papyrus2
/lib/papyrus/block_command.rb
UTF-8
2,874
3.34375
3
[]
no_license
# A block command has a start tag, an end tag, and possibly modifier tags. The # content between tags may span multiple lines, and contain subs itself. For # instance, here is a hypothetical `[show-unless-locked]` block command: # # <p>Here is a sample sentence.</p> # [show-unless-locked] # <p>This text w...
true
eaf16a76b6625bf6adb65f3aae51ad2c5820473a
Ruby
S-Cardenas/MyOwnHashSetRuby
/p04_linked_list.rb
UTF-8
2,176
3.359375
3
[]
no_license
class Link attr_accessor :key, :val, :next, :prev def initialize(key = nil, val = nil) @key = key @val = val @next = nil @prev = nil end def to_s "#{@key}: #{@val}" end end class LinkedList include Enumerable def render node = @head puts node return nil if node.nil? ...
true
4383e15c06e24ab89e2320c8f13733c349fb6472
Ruby
michelleamazinglin/aA-classworks
/W11D1/jbuilder/app/views/api/parties/show.json.jbuilder
UTF-8
1,362
2.671875
3
[]
no_license
json.extract! @party, :name, :location # json.array!(@reservations) do |json, reservation| # json.restaurant reservation.restaurant.name # json.reservation_time reservation.time # json.details do # json.address reservation.restaurant.address # json.rating reservation.restaurant.rating ...
true
240d26dbe4ffea36ecaf9a419fbd9ff68f34cf3b
Ruby
katerniles/Redo-of-HTML-Course2
/Ruby/program.rb
UTF-8
206
3.671875
4
[]
no_license
def greeting #here we say def to define a method and put the name of our method puts "Please enter your name:" #here's the code inside our method name = gets.chomp puts "Hello" + " " + name end greeting
true
a28f6ca51cb29b9bc8b61342ce1d508ce90c2b89
Ruby
sebatapiaoviedo/rentabilidad
/emprendedor1.rb
UTF-8
212
2.734375
3
[]
no_license
precio = ARGV[0].to_f usuarios = ARGV[1].to_f gastos = ARGV[2].to_f utilidades = (precio*usuarios)-gastos puts utilidades if utilidades > 0 u = utilidades*35/100 puts utilidades-u end
true
c79cd1edf83ed9ce44ff08eddf82c42ee55aaed7
Ruby
schmudu/akumai
/app/helpers/application_helper.rb
UTF-8
366
2.546875
3
[]
no_license
module ApplicationHelper # Returns full title on a per-page basis def full_title(page_title) base_title = "TRIO" if page_title.empty? base_title else "#{base_title} | #{page_title}" end end def generate_hash o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten return (0....
true
ed93f6a4f468f009879b8394c631fe4105ab9751
Ruby
techery/chunk-uploader
/lib/chunk_uploader.rb
UTF-8
1,937
2.640625
3
[]
no_license
require 'exceptions/invalid_checksum_error' require 'exceptions/invalid_chunk_id_error' require 'active_support' module ChunkUploader extend ActiveSupport::Concern included do enum status: [:without_chunks, :uploading, :finalized] after_create do make_uploads_folder! self.without_chunks! if s...
true
8573c9849370eab1ff06363da6ffefbfa5b08693
Ruby
Forsooth-168/Ruby
/2nd.rb
UTF-8
7,572
3.859375
4
[]
no_license
answer = "1" while answer != "0" puts "\nМеню: 0. Выход 1. Приветствие 2. Вывод всех методов String 3. Выполнение методов класса String 4. Вывод переменных и констант класса String 5. Примеры форматированных строк" answer = STDIN.gets.chomp.downcase.strip case answer when "1" #Получе...
true
1571f6d23c3313e86455b4d59e3d6e5ce613e742
Ruby
SebastianDelima/artist-song-modules-dc-web-102819
/lib/song.rb
UTF-8
306
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' require_relative '../lib/concerns/memorable' class Song include Memorable::InstanceMethods extend Memorable::ClassMethods attr_accessor :name attr_reader :artist def initialize super end def self.all @@all end def artist=(artist) @artist = artist end end
true
f7829f2036531b99e584f2144de8db632d5106f5
Ruby
SergeyDz/chef-repo
/cookbooks/magic/libraries/reification.rb
UTF-8
1,226
2.546875
3
[ "Apache-2.0", "ISC" ]
permissive
module Reification def reify resource, spec, notifications=[], actions=[] spec = ::Mash.new(spec.to_hash) name = spec.delete 'name' send resource.to_sym, name do spec.each do |k, v| send k.to_sym, v end notifications.each do |notify_spec| raise 'Not a valid notification...
true
9f25579efbf957f0a453a1d31920df2580ca6884
Ruby
izumin5210-sandbox/coding-exercises
/abc134/c/main.rb
UTF-8
187
2.96875
3
[ "MIT" ]
permissive
N = gets.to_i arr = N.times.map { gets.to_i } sorted = arr.sort max_1 = sorted[-1] max_2 = sorted[-2] N.times do |i| if arr[i] == max_1 puts max_2 else puts max_1 end end
true
da4ddc94193619aecced274bff61eef55cf716ab
Ruby
santattech/dev
/file_read_1.rb
UTF-8
1,254
3.28125
3
[]
no_license
require 'rubygems' require 'open-uri' require 'nokogiri' class HtmlParse def title_tag(obj,tag_val) # self define title method title_text = obj.match(/<#{tag_val}>(.*)<\/#{tag_val}>/m)[1].strip end def download p "Enter a URL you want to parse : " url = gets url_obj = open("#{url}"...
true
b23a860f8fbc3824ddee6847d7f976f62e16fc03
Ruby
mkyaw/ruby-basics
/scope.rb
UTF-8
304
3.484375
3
[]
no_license
a=5 =begin 2.times { a+=2 } =end 2.times do |n| a+=n b=22 end puts "a = #{a}" c = 22 def some_method c = 3 end puts "c = #{c}" # " c = 22" because c = 3 is inside the method scope puts b #variable 'b' is not defined outside the scope hence there is error 'undefined local variable'
true
4a461d12a27c2d15bdd331e2bfe8a79b8e6d67b8
Ruby
lcrepet/CoopAssistantBot
/app/actions/action.rb
UTF-8
1,460
2.609375
3
[]
no_license
class Action attr_accessor :scenario def initialize(scenario = nil) @scenario = scenario end def execute raise StandardError.new('Override me.') end def text_message(text:) { type: 'text', content: text, } end def generic_buttons(message:, button_hash_array:) { ...
true
a5795e526a3ed553b144e9133381b4a46351cde4
Ruby
eleloya23/Fractal-Landscape
/landscape_generator.rb
UTF-8
3,781
2.90625
3
[ "MIT" ]
permissive
# Luis Loya # This script generates a pov-ray landscape using the Midpoint Displacement Algorithm require 'pry' require 'RMagick' include Magick $map = Hash.new(0) def prompt(*args) STDERR.puts(*args) gets end def squares(x1,y1,x2,y2, dh, roughness) random_z = lambda { rand() } dx = x2 - x1 dy = y2 - y...
true
4318cf31c5f8aa6de4f06a00a5dbb910cbe7fc63
Ruby
k2works/baukis-kai
/app/models/hash_lock.rb
UTF-8
759
2.625
3
[ "MIT" ]
permissive
# == Schema Information # # Table name: hash_locks # 排他制御 # # id :integer not null, primary key # table :string(255) not null # テーブル # column :string(255) not null # カラム # key :string(255) not null # キー # created_at :datetime ...
true
d72641362f6ea04110fa87d555e1aacd8f6b72ca
Ruby
nmartinovic/aA-Homeworks
/SQL.4_Active_record_under_the_hood/AR1/lib/02_searchable.rb
UTF-8
566
2.515625
3
[]
no_license
require_relative 'db_connection' require_relative '01_sql_object' require_relative 'relation' require_relative 'validatable' module Searchable def deprecated_where(params) lookup = params.keys.map { |key| "#{key} = ?" }.join(" AND ") query = DBConnection.execute(<<-SQL, *params.values) SELECT ...
true
15dd97a0ed4738549d5c4c35d784ea1f18bd3bc9
Ruby
tavon/bcms_content_rotator
/app/portlets/content_rotator_portlet.rb
UTF-8
596
2.546875
3
[ "MIT" ]
permissive
class ContentRotatorPortlet < Portlet # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI. enable_template_editor false def render # Collect the list of slide_ids @slide_ids = [] (1..5).each do |i| s_id = self.send("slide_#{i}_id") @slide_ids << s_i...
true
d8801e36f001dfb09ca7d6703cc7db3cc49a41e5
Ruby
peterc/bits
/cdown.rb
UTF-8
859
3.40625
3
[]
no_license
# Basic Countdown numbers solver # Principally ported from Jake Archibald's JS solution # at https://jsbin.com/yimejin/4/edit?js,console def solve(nums, target) bs = nil nums.sort.reverse.combination(2).each do |i, j| %I{+ - * /}.each do |op| next if op == :* && (i == 1 || j == 1) next if op == :/ ...
true
1ba48d5e26b38564b08843940bd81b8f81303b70
Ruby
BenB-C/Week8Monday
/QueenAttack/spec/queen_attack_spec.rb
UTF-8
1,147
3
3
[]
no_license
require('rspec') require('pry') require('queen_attack') describe('Array#queen_attack?') do it('is false if the coordinates are not horizontally, vertically, or diagonally in line with each other') do expect([1,1].queen_attack?([2, 3])).to(eq(false)) end it('is false if the coordinates are not horizontally, v...
true
683f9234c1802cc9e73b95358103f10b6749f15b
Ruby
fredmcgroarty/bw-be-tech-test
/app/services/uk_public_holiday_fetcher.rb
UTF-8
1,245
3.09375
3
[ "MIT" ]
permissive
# 'Subdivision' felt like the most politically neutral term and non # nation/constitution specific class UKPublicHolidayFetcher class InvalidSubdivisionError < RuntimeError; end FETCH_URL = 'https://www.gov.uk/bank-holidays.json'.freeze SUBDIVISIONS = %w(england-and-wales northern-ire...
true
624003011c417a40cb23b253c44d35fece0f5dca
Ruby
hicarrie/holberton-system_engineering-devops
/0x1B-regular_expressions/7-OMG_WHY_ARE_YOU_SHOUTING.rb
UTF-8
139
2.828125
3
[]
no_license
#!/usr/bin/env ruby # Accepts one argument and passes a regular expression matching # only capital letters puts ARGV[0].scan(/[A-Z]/).join
true
32e3c10de329dcadb404e01bd4a67e4c5acd6993
Ruby
chrisaugust/Small-Problems-Easy-2
/even_numbers.rb
UTF-8
249
3.796875
4
[]
no_license
# Even Numbers # # prints all even numbers from 1 to 99 # numbers are printed on a separate line puts "Even Numbers" puts "-----------" puts "hit any key to continue" gets.chomp (1..99).each do |number| if number.even? puts number end end
true
17ac1c857e6e10219ff4c8b91d08c091833251c8
Ruby
garritfra/r-dailyprogrammer
/easy/Ruby/challenge1/app.rb
UTF-8
681
4.125
4
[]
no_license
=begin Title: [easy] challenge #1 Text: create a program that will ask the users name, age, and reddit username. have it tell them the information back, in the format: your name is (blank), you are (blank) years old, and your username is (blank) for extra credit, have the program log this information in a file ...
true
e9b21c04ceaaa02673345e88559c2039db99e6c5
Ruby
hawx/guard-sass
/lib/guard/sass/runner.rb
UTF-8
3,836
2.59375
3
[ "MIT" ]
permissive
require 'sass' require 'benchmark' module Guard class Sass class Runner attr_reader :options # @param watchers [Array<Guard::Watcher>] # @param formatter [Guard::Sass::Formatter] # @param options [Hash] See Guard::Sass::DEFAULTS for available options def initialize(watchers, form...
true
4fa8ace77eafabb623a585c1c4b6351b285ad1fc
Ruby
gnklausner/dominion-scraper
/src/dominion_scraper.rb
UTF-8
2,900
3.171875
3
[]
no_license
require 'mechanize' require 'nokogiri' require_relative './scraper.rb' class DominionScraper < Scraper def self.Login(agent, domain, user_name, password) login_page = agent.get(domain) form = login_page.form_with :name => "Login" form['USER'] = user_name form['PASSWORD'] = password next_page =...
true
2d196b6543193ba98f0e4852bd83236283246c9e
Ruby
aerohit/learningtocode
/ruby/wellgrounded/ch02/references.rb
UTF-8
459
3.765625
4
[]
no_license
abc = "hello" pqr = abc abc.replace("world") puts pqr def change_string(str) str.replace("New string") end str = "Old string" change_string(str) puts str # Duplicating objects # Duplicating a frozen object produces a non-frozen object change_string(pqr.dup) puts pqr # Freezing objects abc.freeze # both would thro...
true
f9ec9aa883b002250fe7ec031cf079752c9c9d3e
Ruby
kknevitt/number_to_words
/numbers_to_words_spec.rb
UTF-8
2,101
3.34375
3
[]
no_license
require 'minitest/autorun' require './number_to_words' class NumberToWordsTest < MiniTest::Test describe "to_words" do it "should handle individual numbers" do 1.to_words.must_equal("one") 2.to_words.must_equal("two") 3.to_words.must_equal("three") end it "should handle the teens" do ...
true
fa4733122d782e4983fea41d09dc093516584f7f
Ruby
rafa-ce/ror-ws-mongodb
/Module 2/Lesson03-assignment-Advanced-MongoDB-Ruby-Driver/places/app/models/place.rb
UTF-8
3,350
2.609375
3
[]
no_license
class Place include Mongoid::Document attr_accessor :id, :formatted_address, :location, :address_components def initialize params @id = params[:_id].to_s @formatted_address = params[:formatted_address] @location = Point.new(params[:geometry][:geolocation]) @address_components = [] if !param...
true
0bd312fc78ea80cc129ff0af4fffe0030ba89d85
Ruby
adrianmendez03/algos
/ruby/encrypt.rb
UTF-8
912
3.578125
4
[]
no_license
def rot13(string) string = string.split("") # loop through string string.each_with_index do | char, index | # checking if char is a capital letter # if it isn't we don't do anything if char.ord >= 65 && char.ord <= 90 # checks for overflow new_char = (char.ord + 13) % 90 ...
true
27c51e546e49cc22307db9c2c21a1c6177800ec2
Ruby
GermainDuran/ruby-boating-school-nyc-web-102918
/app/models/instructor.rb
UTF-8
1,479
3.453125
3
[]
no_license
class Instructor attr_accessor :name @@all = [] #init with name def initialize(name) @name = name @@all << self end def self.all @@all end #should take in a student name and test name and return status passed def self.pass_student(student_name,test_name) student = Student.find_student ...
true
a1cb1f29e844e798bd493c7878bc771128e7f2a1
Ruby
castor4bit/leetcode
/0200/232.Implement_Queue_using_Stacks/test_232.rb
UTF-8
337
2.6875
3
[]
no_license
require 'test/unit' require './232' class LeetCodeSolutionTest < Test::Unit::TestCase def test_232 queue = MyQueue.new queue.push(1) queue.push(2) assert_equal 1, queue.peek assert_equal 1, queue.pop assert_equal false, queue.empty assert_equal 2, queue.pop assert_equal true, queue...
true
81c444f9434629b93caef9481ac47321e4976040
Ruby
jeffweiss/backbone-facter
/bb_facter.rb
UTF-8
1,100
2.65625
3
[]
no_license
require 'sinatra' require 'sinatra/static_assets' require 'haml' require 'json' require 'facter' require 'fact_getter' use Rack::Session::Pool, :expire_after => 2592000 get '/' do haml :index end post '/refresh' do puts "refreshing facts" session[:fact_names] = Facter.to_hash.keys {:fact_names => session[...
true
dbeff172f24848a8574539d771dfb9c1ab0fc5c6
Ruby
jtrtj/quantified_self
/app/models/food.rb
UTF-8
856
2.84375
3
[]
no_license
class Food < ApplicationRecord validates_presence_of :name, :calories has_many :meal_foods has_many :meals, through: :meal_foods def self.fetch_all Food.all end def self.find_a_food(id) Food.find_by_id(id) end def self.create_new_food(name, calories) new_food = Foo...
true
84dd88e5bd916715d594c29a35d0bb57fccebece
Ruby
wilsonsilva/xavier
/lib/xavier/mutator.rb
UTF-8
1,732
2.953125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'xavier/state' require 'xavier/mutation_strategies/class_copy' require 'xavier/mutation_strategies/instance_copy' module Xavier # Applies and unapplies state mutations to objects. # # @api private class Mutator # Returns a state representation from a given +observable...
true
f95aa6a79f2aae37ad3d34bf84d3a5fe21af517a
Ruby
sneharpatel/ruby-leetcode-problem-solving
/algorithm/day_of_the_programmer.rb
UTF-8
2,029
4.46875
4
[]
no_license
# Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer # (the day of the year) during a year in the inclusive range from to . # # From to , Russia's official calendar was the Julian calendar; since they used the Gregorian calendar system. # The transit...
true
70c873e398bda4f68e134034ab833de753d13a36
Ruby
Nicola-Carroll/boris-bikes_2
/spec/docking_station_spec.rb
UTF-8
1,215
3.03125
3
[]
no_license
require 'docking_station' require 'bike' describe DockingStation do describe '#release_bike' do it { is_expected.to respond_to :release_bike } it {expect {subject.release_bike}.to raise_error("There is no bike at this docking station")} end describe '#dock' do it 'docks a bike' do is_expe...
true
85a0c7f264efaa6068016260b3de3a4ea37093fb
Ruby
benash/crypto
/hash.rb
UTF-8
319
2.90625
3
[]
no_license
require 'digest' block_size = 1024 s = open('intro.mp4', 'rb') { |f| f.read }; blocks = [] until s.empty? blocks << s.slice!(0, block_size) end digest = '' until blocks.empty? sha256 = Digest::SHA256.new sha256.update blocks.pop sha256.update digest digest = sha256.digest end puts digest.unpack('H*')
true
f1f20612ceb11f600d4c9e865b2cc3735c30fe4e
Ruby
mindreframer/ruby-stuff
/github.com/russolsen/design_patterns_in_ruby_code/12/ex2_class_method_demo.rb
UTF-8
527
2.984375
3
[]
no_license
#!/usr/bin/env ruby require '../example' expect_error %q{ class SomeClass def a_method puts('hello from a method') end end SomeClass.a_method } example %q{ class SomeClass puts("Inside a class def, self is #{self}") end } example %q{ class SomeClass def self.class_level_method puts('hello from th...
true
abf31a582034834adc4d83f5dc28c5cf9ecc3a4c
Ruby
duckmole/aoc2020
/test/day8_test.rb
UTF-8
610
2.546875
3
[]
no_license
require 'minitest/autorun' require_relative '../src/day8.rb' class Day8Test < Minitest::Test def test_line assert_equal({cmd: 'nop', data: 0}, line('nop +0')) end def test_1 data = ['nop +0', 'acc +1', 'jmp +4', 'acc +3', 'jmp -3', 'acc -99', 'acc +1', 'jmp -4', 'acc +6'] assert_equal 5, puzzle1(da...
true
b78de02532e0d79ef7d44e22b041a3dba7eeb17d
Ruby
hophuongnam/Harry.Potter
/pr.xml2html.rb
UTF-8
2,085
2.671875
3
[]
no_license
require 'nokogiri' if ARGV[0].nil? puts "Usage: command Filename.xml" exit end file = File.open ARGV[0] doc = Nokogiri::XML file; nil doc.remove_namespaces!; nil doc.xpath("//bookmarkStart").remove; nil doc.xpath("//bookmarkEnd").remove; nil # We only care about 'commentRangeStart' element. # B...
true
acfc9ead9d031f7111cfbc45815cb1897d98cba0
Ruby
jamesedwardferguson/WDi18-Homework
/james_ferguson/week_10/regular_expressions/regex.rb
UTF-8
309
3.390625
3
[]
no_license
require 'pry' ARGF.each do |line| # Using the pattern test program, make a pattern to match the string match. Try the program with the input string beforematchafter. Does the output show the three parts of the match in the right order? if line =~ /(wilma.*fred)|(fred.*wilma)/ puts line end end
true
99f63bf59aee07e97a926439cbe1047ac6351ab5
Ruby
puppetlabs/puppetlabs-stdlib
/lib/puppet/parser/functions/time.rb
UTF-8
1,431
3.03125
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true # # time.rb # module Puppet::Parser::Functions newfunction(:time, type: :rvalue, doc: <<-DOC @summary This function will return the current time since epoch as an integer. @return the current time since epoch as an integer. @example **Usage** time() ...
true
50ad08651b49eefc551b9951111cc1f9051f9568
Ruby
ghudachek/WouldYouRather
/db/seeds.rb
UTF-8
1,511
2.515625
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 bin/rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # ...
true
4dbe49aabda55c605809ae8b35691819a572ad76
Ruby
mlan080/self-learning-ninja
/6. Objects and Methods /instance_variable_example.rb
UTF-8
397
3.390625
3
[]
no_license
#!/usr/bin/ruby class Customer def initialize(id, name, addr) @cust_id = id @cust_name = name @cust_addr = addr end def to_s "(#{@cust_id}, #{@cust_id}, #{@cust_id})" end end # Create Objects cust1 = Customer.new("1", "John", "Wisdom Apartments, Ludhiya") cust2 = Customer.new("2"...
true
ee3f4e5eab891a7be58ef6535048e9f13320b682
Ruby
nshoeheart/hawk-scheduler
/app/helpers/section_builder.rb
UTF-8
1,999
3.265625
3
[ "MIT" ]
permissive
# # Class SectionBuilder provides a utility to convert a set of courses obtained from MAUI and parse its data format into one that is convenient for this scheduling application. Takes care of fully building Section objects and assigning them to the correct SectionGroup within each Course. # # @author Nathan Schuchert <...
true
1624415b599620f15fe2453db4236d621d93fdbb
Ruby
clgroft/advent-of-code-2018
/day10/skywriting.rb
UTF-8
1,132
3.109375
3
[]
no_license
class Point attr_reader :x_pos, :y_pos def initialize(x_pos, y_pos, x_vel, y_vel) @x_pos = x_pos @y_pos = y_pos @x_vel = x_vel @y_vel = y_vel end def fast_forward(num_steps) @x_pos += @x_vel * num_steps @y_pos += @y_vel * num_steps end end points = ARGF.each_line.map do |l| /^posit...
true
0f1dc21d2f91b42b84529c09e5484132fcfa7b8a
Ruby
Brookeruu/parcels
/spec/parcels_spec.rb
UTF-8
809
3.046875
3
[]
no_license
require 'rspec' require 'pry' require 'parcels' describe('#parcels') do it("Determine the volume of the parcel.") do parcel1 = Parcel.new(3,3,3, nil, nil) expect(parcel1.get_volume()).to(eq(27)) end it("Determine the cost for weight.") do parcel2 = Parcel.new(nil, nil, nil, 8, nil) expect(parcel...
true
b8c7d7a8b0727743ca463a611391ac7620994335
Ruby
d-a-grv/rb101
/small_problems/easy9/anagrams.rb
UTF-8
433
3.25
3
[]
no_license
def get_anagrams(arr) anagrams = [[]] arr.length.times do |counter| anagrams << [] unless anagrams.include?([]) arr.each do |word| anagrams[counter] << word if word.delete(arr[counter]).empty? end end anagrams.uniq.each { |arr| p arr } end words = ['demo', 'none', 'tied', 'evil', 'dome',...
true
f5d46cc2a771e639deb5ec2a2f6f9ad2a00622a7
Ruby
andikan/pa-project
/db-parsing/inventorTable.rb
UTF-8
2,367
2.5625
3
[]
no_license
require_relative '../lib/connect_mysql' connect = Connect_mysql.new('chuya', '0514') origin_db = connect.db('mypaper') new_db = connect.db('patentproject2012') # temp = false for i in 2006..2006 puts i.to_s + " start" #for i in 1976..2009 tpapers = origin_db.query("select Patent_id, Inventors from `content_"+i.to...
true
9e53a877ec62e33cec6101a5a01338091c73a042
Ruby
hindenbug/game_of_life
/spec/board_spec.rb
UTF-8
1,606
2.984375
3
[]
no_license
require "spec_helper" require "debugger" require "./cell" require "./board" describe Board do let(:board) { Board.new(4,4) } let(:cells) { board.cells } it "should create board with defined dimensions" do board.rows.should eql 4 board.cols.should eql 4 end it "should have all the cells as dead" do...
true
f7115b3bf822bcb61668b40f2d413f650f63ac9f
Ruby
Guillaume49700/lrthw
/ex3b.rb
UTF-8
60
2.703125
3
[]
no_license
puts 3+4+5 puts 15.0/4.5 puts "Oh, that's why it's false."
true
1bc7d819f00ea210721a8f4211f4c065cddafb27
Ruby
patsilvia/base26
/driver.rb
UTF-8
215
3.0625
3
[ "Artistic-2.0" ]
permissive
#!/usr/bin/env ruby require_relative 'lib/base26' #Main n = Base26.new() input = 'lina+luna' puts "The result of #{input} is: #{n.run(input)}" input = 'xv + da' puts "The result of #{input} is: #{n.run(input)}"
true
657dfcba95e2304813927ea9bac68a8cd34d3a76
Ruby
andech/free-courses
/task3.rb
UTF-8
680
3.734375
4
[]
no_license
# Task 3 seconds = ARGV[0].to_i + ARGV[1].to_i hours = seconds / 3600 minutes = seconds % 3600 / 60 seconds = seconds % 3600 % 60 result = "" def func(number, a, b, c) last_digit = number % 10 if last_digit == 1 && number != 11 "#{number} #{a}" elsif last_digit > 1 && last_digit < 5 && number / 10 != 1 ...
true
66993c0f3baf1e820ff522fa86e95b9470c3b2cb
Ruby
ManageIQ/rubyrep
/lib/rubyrep/scan_progress_printers/progress_bar.rb
UTF-8
2,566
2.953125
3
[ "MIT" ]
permissive
module RR module ScanProgressPrinters # A helper class to print a text progress bar. class ProgressBar MAX_MARKERS = 25 #length of the progress bar (in characters) # Register ProgressBar with the given command line options. # (Command line format as specified by OptionParser#on.) ...
true
6bbff517e80abf33acaf88f961bd8dc4f23147e9
Ruby
adking241/evenodd
/evenodd.rb
UTF-8
186
3.46875
3
[]
no_license
def evenodd_function(number) if number.is_a? String "only numbers allowed" elsif number % 2 == 0 #this means divisible by 2 with a remainder of zero "even" else "odd" end end
true
0558b10787b5131f87d709f5c5727c2cf3d6f33c
Ruby
stephan-nordnes-eriksen/BOBrb
/lib/BOBrb.rb
UTF-8
442
2.53125
3
[ "MIT" ]
permissive
require "BOBrb/version" require "BOBrb/element" require "BOBrb/child_array" module BOBrb @@mode = :html def self.new(*args) BOBrb::Element.new(*args) end def self.data(*args) BOBrb::Element.method(:data) end def self.d(*args) BOBrb::Element.method(:d) end def self.set_mode(mode=:html) #supported: :htm...
true
94b50bbb60bdb373764a764a11f02bb88dfec45a
Ruby
kevinmoore9/ticker-back-end
/app/models/stock.rb
UTF-8
1,375
2.984375
3
[]
no_license
# == Schema Information # # Table name: stocks # # id :integer not null, primary key # symbol :string not null # price :float not null # created_at :datetime # updated_at :datetime # company_name :string # class Stock < ActiveRecord::Base validates :symb...
true
c9768348e1b4643a1d55719f90eb957fb764444f
Ruby
vikas-lamba/gen-tj
/lib/gen-tj/genresources.rb
UTF-8
2,019
2.734375
3
[]
no_license
#encoding: UTF-8 # # Generate TJ resources from YAML file + present.suse.de:9874 # require 'yaml' require 'net/telnet' module GenTJ Encoding.default_external = "UTF-8" class Genresources # # Create vacations entry for 'name', write to 'to' # # Use present.suse.de:9874 to extract dates # ...
true
884ef51ec05e425f3ce0c34f1a39faf9ea802b11
Ruby
BarbaraC12/TIC-TAC-TOE
/lib/game.rb
UTF-8
2,140
3.75
4
[]
no_license
class Game attr_accessor :current_player, :board, :player def initialize puts " *******************************" puts " * BIENVENUE DANS LE MORPION * " puts " * X O X * " puts " *******************************" puts puts "Les regles du j...
true
8f16de9f31f1d004cfbb6cad4597ca3350c685c6
Ruby
kpmoy88/BEWDiful_Students
/05_Classes_Objects/exercises/ex_secret_number_objects/secret_number/runner.rb
UTF-8
1,283
3.78125
4
[]
no_license
# Kenneth Moy # 7/1/2013 # Back-End Web Development - HW #2 Secret Number Game Updated require_relative '../secret_number/lib/player' require_relative '../secret_number/lib/game' # Checks for bad input (Only accepts 'y' or 'n') def check_yes_no_input(input) while input != 'y' && input != 'n' puts "Wrong Input! Ple...
true
dda790fcc91236623ab99e5dd05b7cc6e4d7c02f
Ruby
Johntremont/Curso_Fullstack
/RoR/myblog/db/seeds.rb
UTF-8
1,675
2.734375
3
[]
no_license
article_list = [ [ "¿Cómo hacer videojuegos?", "Seguramente ya has escuchado que la industria de los videojuegos tuvo el doble de ganancias que Hollywood en 2017. La industria de los videojuegos viene pisándole los talones a la gran pantalla desde desde el 2013, y podrías creer entonces que crear tu ...
true
d91bd36a420db6cbda2bedaf4e3e539ab2a865c3
Ruby
w0nche0l/cs198-api
/test/models/enrollment_test.rb
UTF-8
1,136
2.640625
3
[]
no_license
require "test_helper" describe Enrollment do let(:student_enrollment) do Enrollment.new( person: people(:student_1), course: courses(:cs106a_term_1), position: 'student' ) end let(:lecturer_enrollment) do Enrollment.new( person: people(:staff_1), course: courses(:cs106a...
true
3cbb4491a40e961564c24abbde29fc4e274edb13
Ruby
baron816/Krewe
/lib/groups/expansion_check.rb
UTF-8
571
2.59375
3
[]
no_license
module Groups class ExpansionCheck attr_reader :group def initialize(group) @group = group end def ripe_for_expansion? aged?(1.month) && group.attended_activities_count >= 4 && group.can_join == false && group.has_expanded == false && group.ready_to_expand == false end def ripe_and...
true
47c2049d1783afb9775a7aebd044556501213f84
Ruby
johnfig/stitch-fix-project
/spec/models/item_spec.rb
UTF-8
3,769
2.703125
3
[]
no_license
require 'rails_helper' describe Item do it { should belong_to(:style) } it { should belong_to(:clearance_batch) } describe '#sellable' do let!(:unsellable_item) { FactoryGirl.create :item, status: 'not sellable' } context 'item is has status of `sellable`' do it 'returns an array of all sellable...
true
86da3058f37966fe6e7b980eb81ff0bb5419d082
Ruby
joshuapaling/stockfighter
/lib/stockfighter/client.rb
UTF-8
1,587
2.625
3
[ "MIT" ]
permissive
require 'httparty' require 'json' module Stockfighter class Client BASE_URL = 'https://api.stockfighter.io/ob/api/' def initialize(api_key) @api_key = api_key end def heartbeat(venue = nil) return get("venues/#{venue}/heartbeat") if venue get('heartbeat') end def stocks(v...
true
db5cbd813233215786cd927bcb5772d9cb1de54c
Ruby
navkumar2245/database_consistency
/lib/database_consistency/configuration.rb
UTF-8
478
2.53125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'yaml' module DatabaseConsistency # The class to access configuration options class Configuration def initialize(filepath = nil) @configuration = if filepath YAML.load_file(filepath) else {} end en...
true
0be4f54762ac29b5298ac784f904effefb0e904f
Ruby
MaryBork/backend_prework
/day_6/good_dog.rb
UTF-8
1,056
4.28125
4
[]
no_license
#What are objects? p "hello".class p "world".class #Classes Define Objects #good_dog.rb --- snake case for file names #GoodDog --- CamelCase for class names class GoodDog attr_accessor :name, :height, :weight def initialize(n, h, w) @name = n @height = h @weight = w ...
true
a253e6452aea7271ec873fc2e5167cad410f1a44
Ruby
alice-ecila/RubyWork
/getsString.rb
UTF-8
100
3.25
3
[]
no_license
#! /usr/bin/env ruby print 'InputName>' name = $stdin.gets.chomp puts "Hi! I'm #{name}!" exit 0
true
4839c6d7f3ec344740c3149e65588f86983b92a2
Ruby
pelicularities/macrotery
/db/seeds.rb
UTF-8
13,817
2.703125
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