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
baed6dd27a917749706687c2cc6bfe4d785e4ea8
Ruby
benmicol/trading-web
/trading-web/spec/lib/common_spec.rb
UTF-8
2,010
3.40625
3
[ "Apache-2.0" ]
permissive
require File.dirname(__FILE__) + '/../spec_helper' class Holder attr_accessor :nested def initialize nested=nil @nested = nested end end describe "Common Util extenssion for string, dates, money and similar" do it "should format Money into html representation with $ sign in front" do ...
true
75748a5c8520b63c8e9a716fb4faf5b5d51c03c2
Ruby
hofmannedv/training-ruby
/calculations/min-max.rb
UTF-8
651
4.03125
4
[]
no_license
# ----------------------------------------------------------- # calculate the minimum, and the maximum value for a list of integers #o # (C) 2015 Frank Hofmann, Berlin, Germany # Released under GNU Public License (GPL) # email frank.hofmann@efho.de # ----------------------------------------------------------- # define...
true
0530967f6a1bfc0e96b0a17395eb5949d41d2ab6
Ruby
jshorns/bank-tech-test
/lib/account.rb
UTF-8
1,687
3.21875
3
[]
no_license
# frozen_string_literal: true require_relative 'transaction' require_relative 'transaction_history' require_relative 'statement' require 'date' # Account class, for recording balance and making deposits and withdrawals. class Account OPENING_BALANCE = 0 def initialize(transaction_history = TransactionHistory.new...
true
d809678d7e8dc82b3fb227ede26ac6e7943c86bb
Ruby
tewarbit/smslacquey
/lib/smslacquey/movietimes/movietimesfilter.rb
UTF-8
1,864
2.828125
3
[]
no_license
require 'singleton' require 'rubygems' require 'orderedhash' require 'lib/config' module SmsLacquey class MovieTimesFilter include Singleton private def match_movie(title, msg_words) title_words = title.downcase.scan(/[\w']+/) (msg_words.select { |word| title_words.include?(word) })...
true
2503693f2393508105c93ed3fa47446710f19e1e
Ruby
SierraSchultz/advent-of-code
/2019/day1/day1Solver.rb
UTF-8
298
3.171875
3
[]
no_license
puzzleFile = File.open("./day1InputSierra.txt") puzzleData = puzzleFile.readlines.map(&:chomp) puzzleFile.close fuelCount = 0 def fuelDividedBy3(spaceModule) (spaceModule.to_i / 3).floor end puzzleData.each do |spaceModule| fuelCount += fuelDividedBy3(spaceModule) - 2 end puts fuelCount
true
d3e377484d10caa749dac8e0c80e97ed5479e1c3
Ruby
aparkening/orm-mapping-db-to-ruby-object-lab-online-web-pt-041519
/lib/student.rb
UTF-8
2,641
3.421875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Student attr_accessor :id, :name, :grade # Create student instance from database row def self.new_from_db(row) new_student = self.new new_student.id = row[0] new_student.name = row[1] new_student.grade = row[2] new_student end # Get all students from database and cre...
true
e8bc7ae534443350378cac0925c7aebc1e2b620a
Ruby
GlynnisOC/dpl_1901
/lib/library.rb
UTF-8
354
3.4375
3
[]
no_license
class Library attr_reader :books def initialize @books = [] #this doesn't seem like SRP (as books is included in the author class), please correct me if I'm wrong! end def add_to_collection(book_info) @books << book_info end def include?(book_title) @books.any? do |book_title| book.title...
true
f5bebe1eaf96be10493d51acca936a72372f45ce
Ruby
KarlGl/music_coder
/lib/wave.rb
UTF-8
2,260
2.8125
3
[]
no_license
#a waveform. this is looped to create a Tone. class Wave # stores the detail amount in a #Fader.start. nil means use sin wave during generation. # Fader.start is the main # Fader.final is at the end. nil means same as wave start attr_accessor :detail #saturation effect (a random fluctuation on each data point to the c...
true
78971437cb8348472eeda0d031e0a4644fc392e1
Ruby
wasamasa/aoc
/2015/03.rb
UTF-8
3,085
4.34375
4
[ "Unlicense" ]
permissive
require_relative 'util' # --- Day 3: Perfectly Spherical Houses in a Vacuum --- # Santa is delivering presents to an infinite two-dimensional grid of # houses. # He begins by delivering a present to the house at his starting # location, and then an elf at the North Pole calls him via radio and # tells him where to m...
true
62aff7b53d644540dfe4cad2f0b61822953042ce
Ruby
anle1337/RubyCodingProblemSolution
/RNAtoProteinSequence.rb
UTF-8
5,922
3.53125
4
[]
no_license
# Description: # The central dogma of molecular biology is that DNA is transcribed into RNA, which is then tranlsated into protein. RNA, like DNA, is a long strand of nucleic acids held together by a sugar backbone (ribose in this case). Each segment of three bases is called a codon. Molecular machines called ribosome...
true
db0c4630eab853741195d9336e8c6ab2ca070636
Ruby
DannyBen/webcache
/spec/webcache/web_cache_spec.rb
UTF-8
7,052
2.53125
3
[ "MIT" ]
permissive
describe WebCache do let(:url) { 'http://example.com' } before { subject.flush } describe '#new' do it 'sets default properties' do expect(subject.life).to eq 3600 expect(subject.dir).to eq 'cache' end context 'with arguments' do subject { described_class.new dir: 'store', life: 1...
true
e20bc512bfe891b3aaf9e3ec2948cc5636f7f4a4
Ruby
BrianMehrman/EatMe
/app/models/nut_data.rb
UTF-8
730
2.515625
3
[]
no_license
class NutData < ActiveRecord::Base #set_primary_key :NDB_No alias_attribute :n, :Nutr_Val belongs_to :definition, :class_name => "NutrDef", :foreign_key => "Nutr_No", :primary_key => "Nutr_No" belongs_to :source, :class_name => "SrcCd", :foreign_key => "Src_Cd", :primary_key => "Src_Cd" belongs_to :derivati...
true
caa3114683b9e2eb802282742d952b3afd6ea1eb
Ruby
kmanahan/programming-univbasics-3-build-a-calculator-lab-online-web-prework
/lib/math.rb
UTF-8
499
3.53125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def addition(num1, num2) puts num1 + num2 return num1 + num2 end addition(1,2) def subtraction(num1, num2) puts num1 - num2 return num1 - num2 end subtraction(2,1) def division(num1, num2) puts num1/num2 return num1/num2 end division(2,1) def multiplication(num1, num2) puts num1 * num2 return num1 * num2 end mu...
true
63a5bd0af90590398eb73f820502131b0b627ffb
Ruby
ushadow/tabletop_kinect
/ruby/eval_clicks.rb
UTF-8
3,154
3.328125
3
[]
no_license
#!/usr/bin/env ruby require 'optparse' def eval_segment(segment) avgx = segment.reduce(0) { |sum, e| sum + e[1] } / segment.size avgy = segment.reduce(0) { |sum, e| sum + e[2] } / segment.size {start_index: segment.first[0], end_index: segment.last[0], avgx: avgx, avgy: avgy} end def eval_gt_clicks(gro...
true
7e952afda68f3f47b2ba2ee6736da3bde3696084
Ruby
naranhoe/prime_number
/prime.rb
UTF-8
126
3
3
[]
no_license
class PrimeFactors def generate(number) factors = [] if number > 1 factors << 2 end factors end end
true
0fbb117ef79059081784876f9a02b035df211d27
Ruby
Burrick2003/ruby-objects-has-many-lab-v-000
/lib/song.rb
UTF-8
507
3.234375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song @@songs = 0 attr_accessor :name, :artist, :genre def initialize(name) @name = name @@songs += 1 end def artist_name #@artist #why doesn't this work? (artist in artist class not song) #if self.artist.name != nil #not does it have an artist name, but is it an existing artist (to be ...
true
35a7454cadc772c977f1bd9e00e170dce915c05a
Ruby
floum/zwischenzug_cli
/lib/zwischenzug_cli/puzzle.rb
UTF-8
1,285
3
3
[ "MIT" ]
permissive
class Puzzle attr_reader :pgn def initialize(attrs = {}) @initial_ply = attrs.fetch(:initial_ply) { 0 } @fen = attrs.fetch(:fen) @moves = attrs.fetch(:moves) end def pgn %Q([SetUp "1"]\n[FEN "#{@fen}"]\n#{line}\n) end def yaml %Q(- fen: #{@fen}\n moves: #{line}\n ply: 1\n) end ...
true
56c03504e6af5f35e04f3d7e78ebe034da71a4ce
Ruby
jclemans/Point-of-Sale-System
/pos_ui.rb
UTF-8
3,578
3.34375
3
[]
no_license
require 'active_record' require 'pry' require './lib/product' require './lib/cashier' require './lib/customer' require './lib/checkout' ActiveRecord::Base.establish_connection(YAML::load(File.open('./db/config.yml'))['development']) def welcome puts "Welcome to the POS system." cashier_login menu end def cash...
true
c11b694a3b04e8f1cf2059ed2f23b17ac2b7574e
Ruby
zeroboo/java-scripting-rhino-jdk8
/engines/jruby/test/src/main/ruby/flowers.rb
UTF-8
474
4.0625
4
[]
no_license
# # flowers.rb class Flowers @@hash = {'red' => 'ruby', 'white' => 'pearl'} def initialize(color, names) @color = color @names = names end def comment $, = ", " puts "#{@names}. Beautiful like a #{@@hash[@color]}!" end def others(index) @names.delete_at(index) puts "Others ar...
true
2ee5987dd16ca7130097546d41c4e3ba69215002
Ruby
ajtran303/codeacademy-ruby
/5/basic-methods.rb
UTF-8
110
2.9375
3
[]
no_license
# Review of writing methods # define method def welcome puts "Welcome to Ruby!" end # call method welcome
true
89cdb254e3b9f885ddedd51ac5e68f315231400d
Ruby
sa2taka/UnsecretPuzzle
/models/user.rb
UTF-8
926
2.796875
3
[]
no_license
require 'digest' require 'bcrypt' require_relative '../models.rb' class User < ActiveRecord::Base validates :id, presence: true, uniqueness: true validates :password, presence: true has_many :styles def self.create(name, new_password) user = User.new user.id = name user.password = ...
true
b00dc43862c56d87016b41a66ebebc18cdbfbd0b
Ruby
tgrosch91/kitten-scraper
/lib/ages.rb
UTF-8
462
2.984375
3
[]
no_license
require 'pry' require_relative '../lib/concerns/cattributes' class Ages include Cattribute::InstanceMethods extend Cattribute::ClassMethods attr_accessor :name, :cats def initialize(name) @name = name @cats = [] end def self.create(name) self.new(name).tap{|age| age.save} end def self.fi...
true
4940e249c589cf24874a43a6a54355f29934a35a
Ruby
lucashungaro/scoring_rules
/lib/scoring_rules/rule.rb
UTF-8
205
3.140625
3
[ "MIT" ]
permissive
class Rule attr_accessor :points def initialize(points, condition) @points = points @condition = condition end def evaluate(instance) @condition.evaluate(instance) * @points end end
true
581f7e022abd561eb15115c9e3c357bfb0679bd1
Ruby
akandeel/CHOCO
/app/models/user.rb
UTF-8
5,883
2.75
3
[]
no_license
class User < ApplicationRecord enum role: [:customer, :business] after_initialize :set_default_role, :if => :new_record? def set_default_role self.role ||= :customer end attr_accessor :remember_token, :activation_token # to create an accessible attribute to store cookies without saving to database ...
true
76b4b2eb029f9fb79785c90385a3336a62ad5758
Ruby
addislw/appA-Foundations
/blocks_project/lib/part_1.rb
UTF-8
555
3.703125
4
[]
no_license
def select_even_nums(array) array.select do |nums| nums % 2 == 0 end end def reject_puppies(hash_array) hash_array.reject do |hash| hash['age'] <= 2 end end def count_positive_subarrays(array) array.count do |sub_array| sub_array.sum > 0 end end def aba_translate(string) vowels = 'aeiou...
true
cdbd7109472855d34b7850f406c1d36c79494fe1
Ruby
mlowen/sequel_populator
/lib/sequel_populator/runner.rb
UTF-8
1,621
2.859375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Sequel # Module is responsible for housing the functionality to populate a database # with seed data, based on either a hash or file path provided. module Populator require 'sequel' # This class is responsible for populating the database. class Runner def i...
true
01669889027dfbe3827e3dbe6c490f2acd78244a
Ruby
DSIW/tictactie
/spec/tictactie/game_spec.rb
UTF-8
444
2.640625
3
[ "MIT" ]
permissive
require "spec_helper" RSpec.describe TicTacTie::Game do let(:game) { described_class.new } describe "status" do context "correct player has won with message" do before do game.board.place_symbol(0, 'X') game.board.place_symbol(4, 'X') game.board.place_symbol(8, 'X') end ...
true
63a3222abe875f383cbcad83d8adcc9ea4695a50
Ruby
megaya/tocaro_webhook
/lib/tocaro_webhook/sender.rb
UTF-8
1,000
2.78125
3
[ "MIT" ]
permissive
require 'uri' require 'net/http' require 'openssl' require 'tocaro_webhook/payload' module TocaroWebhook class Sender attr_accessor :url attr_writer :payload def initialize(web_hook_key) @url = web_hook_url(web_hook_key) end def set_text(text) payload.text = text end # c...
true
6908fcc1541debe8df4a9fdb0696540a689a2196
Ruby
peggycodus/poker_hand_ruby
/spec/poker_hand_spec.rb
UTF-8
216
2.71875
3
[]
no_license
require('rspec') require('poker_hand') describe("poker_hand") do it("returns the name of the poker hand, given a five card argument") do poker_hand(['2S', '3C', '4D', '5C', '6H']).should(eq('straight')) end end
true
6e7f3253bf281ee9fa6fcca8fba32071ca3d22d1
Ruby
tylerjharden/dbpedialite
/lib/freebase_api.rb
UTF-8
1,952
2.625
3
[ "MIT" ]
permissive
require 'net/https' require 'uri' require 'cgi' module FreebaseApi USER_AGENT = 'DbpediaLite/1' MQLREAD_URI = URI.parse('https://www.googleapis.com/freebase/v1/mqlread') RDF_BASE_URI = URI.parse('http://rdf.freebase.com/rdf/') GOOGLE_API_KEY = ENV['GOOGLE_API_KEY'] HTTP_TIMEOUT = 2 class Exception < Excep...
true
e0ddcbcdced06f1cf3400c4b4c3fb028b61aa910
Ruby
stereocat/training
/pbrlbswitch/pbrlb-table.rb
UTF-8
1,700
2.546875
3
[]
no_license
# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of...
true
a5c0980a2fff7ff233715d880b5c596c5c48cbf9
Ruby
JBlackN/budik
/lib/budik/devices.rb
UTF-8
4,427
2.765625
3
[ "MIT" ]
permissive
# = devices.rb # This file contains methods for managing devices (storage and TV). # # == Contact # # Author:: Petr Schmied (mailto:jblack@paworld.eu) # Website:: http://www.paworld.eu # Date:: September 20, 2015 module Budik # 'Devices' class manages display and storage devices. class Devices include Sing...
true
1b01a845689e7f63ca592096d10b17e8dae9df9c
Ruby
mlarcher531/ruby-oo-relationships-practice-gym-membership-exercise-hou01-seng-ft-082420
/tools/console.rb
UTF-8
374
3.140625
3
[]
no_license
# You don't need to require any of the files in lib or pry. # We've done it for you here. require_relative '../config/environment.rb' l1 = Lifter.new("Mike", 9000) l2 = Lifter.new("J", 7000) g1 = Gym.new("GloboGym") g2 = Gym.new("Average Joe's") m1 = Membership.new(20, g1, l1) m2 = Membership.new(10, g2, l1) m3 = Me...
true
74cad7b651c6c424c2fe878c38d40161f87763f8
Ruby
rendon/algorithms_weekly_rally
/week05/SCHEDULE/gen.rb
UTF-8
134
2.875
3
[]
no_license
#!/usr/bin/env ruby puts 11 * 2 ** 10 0.upto(10) do |k| 0.upto(2**10 - 1) do |n| puts "10 #{k}" puts "%010b" % n end end
true
1ce860dfb44b5bbf2716c679f3e99e28f5011a22
Ruby
orbanbotond/ruby_exercise
/spec/algorythms/alg_euclidean_02_common_prime_divisors_spec.rb
UTF-8
1,319
3.6875
4
[]
no_license
require 'spec_helper' describe 'Stone Wall' do # you can use puts for debugging purposes, e.g. # puts "this is a debug message" def are_other_prime_divisors(x, common_prime_divisor) while x > 1 gcd = x.gcd common_prime_divisor break if gcd == 1 x /= gcd end x != 1 end def has...
true
f9fb74befb81d0ce0aac92ba4c61a4960c357298
Ruby
m1kal/exercism_ruby
/allergies/allergies.rb
UTF-8
415
3.390625
3
[ "MIT" ]
permissive
class Allergies ALLERGENS = %w(eggs peanuts shellfish strawberries tomatoes chocolate pollen cats).freeze def initialize(number) @allergies = number.to_s(2).reverse end def allergic_to?(allergen) @allergies[ALLERGENS.index(allergen)] == '1' end def list @allergies.each_char.w...
true
779b563f9addc1fbc85dd35f12c19c2833c949c0
Ruby
sherpanat/encrypt-246
/encrypt.rb
UTF-8
593
3.46875
3
[]
no_license
def encrypt(sentence) alphabet = ("A".."Z").to_a sentence.split("").map do |caracter| caracter_upcased = caracter.upcase old_index = alphabet.index(caracter_upcased) old_index ? alphabet[old_index - 3] : caracter_upcased end.join end # false #on fait un tableau de lettres de l'alphabet #on découpe la...
true
17d00d79195a7dabb708e1a10475120f2c9b5a87
Ruby
fanjieqi/LeetCodeRuby
/101-200/130. Surrounded Regions.rb
UTF-8
1,311
3.828125
4
[ "MIT" ]
permissive
AROUND = [ [-1, 0], [+1, 0], [0, -1], [0, +1], ] def solve_margin(board, points, x, y) board[x][y] = "1" points << [x, y] AROUND.each do |i, j| xx, yy = x + i, y + j next if xx < 0 || yy < 0 || xx >= board.length || yy >= board[0].length solve_margin(board, points, xx, yy) if board[xx][yy] ==...
true
5def6a3e2f9c3bf96c475e2d51a79042ab6edb61
Ruby
MtnBiker/Croatian-Restaurants-Rails-2
/lib/tasks/import_addresses.rake
UTF-8
1,221
2.546875
3
[]
no_license
#lib/tasks/import.rake desc "Imports a CSV file into an ActiveRecord table" task :csv_model_import, [:filename, :model] => [:environment] do |task,args| lines = File.new(args[:filename]).readlines header = lines.shift.strip keys = header.split(',') lines.each do |line| values = line.strip.split(',') att...
true
c3c43f603a2e7a186480dfc3e200a88d3dfac59a
Ruby
dudemcbacon/poop_dominos
/controller.rb
UTF-8
1,985
2.84375
3
[]
no_license
require 'sinatra' require 'rmagick' require 'httparty' AGENT_URL = "https://agent.electricimp.com/IxdMGFT6Ie3p/image" WIDTH = 264 HEIGHT = 176 WHITE = 0 BLACK = 1 get '/start' do image = start_page prepare_image(image) end get '/pizza' do filepath = File.dirname(__FILE__) + '/static/pizza.png' logger.warn ...
true
77433289d835e5f89aafaf0d1e30d2033a937c41
Ruby
Pamela454/cartoon-collections-v-000
/cartoon_collections.rb
UTF-8
616
3.453125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def roll_call_dwarves(dwarves) # code an argument here # Your code here dwarves.each_with_index do |dwarf, index| puts "#{index + 1}, #{dwarf}." end end def summon_captain_planet(planeteer) planeteer.map do |planet| "#{planet.capitalize + "!"}" end end def long_planeteer_calls(calls)# code an argument...
true
8754a4c83100223176d8916484166d597e019825
Ruby
nklammer/zedg_multifamily
/analyses/osw_2_osa_multizedg.rb
UTF-8
27,544
2.546875
3
[ "MIT" ]
permissive
# this will convert an OSW file to an OSA file # additionally it can gather files for the analysis zip file # It works by populating the workflow of a template OSA file with measure steps from the OSW # ARGV[0] json file is generated unless false # ARGV[1] zip file is generated unless false # todo - add in arg for serv...
true
67c57b4e4dbdddb474882259c577e5fa1acdb5a9
Ruby
ryu2129/paiza
/Brank/3-3.rb
UTF-8
103
3.703125
4
[]
no_license
#文字列が入力されるので、その長さを出力してください。 n = gets puts n.length
true
d43034905fad1e438bb51c4b8d753ae02e063b10
Ruby
davidprea/freezing-shame
/monsters/orc.rb
UTF-8
4,813
2.796875
3
[]
no_license
require './monster' class Orc < Monster def initialize super end def self.armors result = super result[:orc_armor] = Armor.new("Orc armor", 3, 0) return result end def self.weapons result = super result[:bent_sword] = Weapon.new( "Bent Sword", 4, 10, 12, 0, :one_handed, :d...
true
3a440a040279199af4e362cefdbd25bd90396527
Ruby
pocke/self-hosting-whitespace
/test/basic_features_test.rb
UTF-8
2,082
2.578125
3
[]
no_license
require 'test_helper' class BasicFeaturesTest < Minitest::Test def test_calc_add io = WhitespaceIO.new io.push_num 3 io.push_num 8 io.add io.write_num io.exit io.eof assert_ws "11", io end def test_calc_sub io = WhitespaceIO.new io.push_num 3 io.push_num 8 io.s...
true
f54364b348236cc7ba8e6572b3c3147541e6a896
Ruby
ishmetjahan/prime-ruby-dumbo-web-062419
/prime.rb
UTF-8
207
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Add code here! def prime?(num) if num<=1 return false elsif num==1 || num==2 return true else i=2 while i< num if num% i ==0 return false end i+=1 end end return true end
true
07067df47ffa4c88ee4f2f22f62bc1a7b83946cd
Ruby
shelbycer/machine-translator-challenge
/lib/formatter.rb
UTF-8
166
2.90625
3
[]
no_license
class Formatter DELIMITER = "\n" def self.split_string(text) text.split(DELIMITER) end def self.join_pieces(text) text.join(DELIMITER) end end
true
c6d27ebf01ce02b53358680c5a63f0956f53cdfe
Ruby
marcos-x86/AT04_API_test
/YuriOrtuno/Session_01/Practice_09/Practice01.rb
UTF-8
1,060
3.859375
4
[]
no_license
class Father attr_accessor :money def initialize money @@money = money end def howMoneyExist @@money end end class SonOne < Father def initialize moneyTake @moneyTake = moneyTake @@money -= @moneyTake end def howtake @moneyTake end end class SonTwo < Father def initialize mo...
true
b05b98026d17478305c32efccf2013ac0be4c394
Ruby
herringtown/paper_trail
/lib/paper_trail/attribute_serializers/legacy_active_record_shim.rb
UTF-8
1,517
2.5625
3
[ "MIT" ]
permissive
module PaperTrail module AttributeSerializers # Included into model if AR version is < 4.2. Backport Rails 4.2 and later's # `type_for_attribute` so we can build on a common interface. module LegacyActiveRecordShim # An attribute which needs no processing. It is part of our backport (shim) # o...
true
33c418cf41a2d35e27c975a34eb32fba76c5d795
Ruby
MaksimPW/service_taxi
/app/models/inspection.rb
UTF-8
1,446
2.65625
3
[]
no_license
class Inspection # Принадлежит/лежит ли точка в/на окружности? # x1, y1 - координаты точки # x2, y2, r - координаты центра окружности и ее радиуса def self.inside_the_circle?(x1,y1,x2,y2,r) return true if (((x1 - x2)**2) + ((y1 - y2)**2)) <= r**2 false end def self.summary_build_route(locations) ...
true
6ee7529e4fd917136d7d5487ed3d9c156fe7190c
Ruby
sreevenkat/destroy-all-software
/data-compressor/zip.rb
UTF-8
2,066
3.625
4
[]
no_license
#!/usr/bin/env ruby def compress(original) tree = build_tree(original) table = build_table(tree) compressed = [] original.bytes.each do |byte| bits = look_up_byte(table, byte) compressed << bits end.flatten pack_table(table, compressed) compressed end def decompress(compressed, data_length) ...
true
d0f7d7bbc61cd0c8f94d00a1712da432edd72293
Ruby
mluts/mini-nrepl
/lib/mini_nrepl/nrepl/result_handler.rb
UTF-8
1,817
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'set' require 'mini_nrepl/logging' module MiniNrepl class Nrepl # Allows to setup flexible handling of nrepl output class ResultHandler include Logging # @param args [Object] Any args accepted def initialize(*args) logger.debug(self.class) { "...
true
18df2c55c817dc7818e3bf3a38040b5f3e9a7f93
Ruby
eashmore/app_academy
/w2d4-master/piece.rb
UTF-8
2,770
3.34375
3
[]
no_license
require 'colorize' class Piece MOVES_DIFFS = [[1,1], [1,-1], [-1,-1], [-1,1]] PAWN_SYMBOL = '0' KING_SYMBOL = 'K' # JUMP_DIFFS = [[2,2], [2,-2], [-2,-2], [-2,2]] attr_reader :color, :board attr_accessor :pos, :king, :moves, :jumps, :neighbors def initialize(pos, color, board) @pos = pos @color =...
true
243666ecf415d759e80d9835b368b868096f1c6b
Ruby
weyewe/zgazga
/app/models/roller_accessory_detail.rb
UTF-8
2,220
2.53125
3
[]
no_license
class RollerAccessoryDetail < ActiveRecord::Base belongs_to :roller_identification_form_detail belongs_to :item validates_presence_of :roller_identification_form_detail_id validates_presence_of :item_id validates_presence_of :amount validate :valid_roller_identification_form_detail_id validate :valid_item...
true
95ab4d4a62ef445d4649ed4c10159a8bbc50f172
Ruby
thernull/star-wars-simulator
/Mission/Mission.rb
UTF-8
2,450
3.09375
3
[]
no_license
class Mission def initialize(goodSide, badSide) @goodSide = goodSide @badSide = badSide @dead = [] @injured = [] @events = [] end def play (1..rand(10)+1).each do |idx| break if @goodSide.size == 0 break if @badSide.size == 0 goodGuy = @goodSide[rand(@goodSide...
true
1b06a129ee762cce08fd31537bdb40ccfce07418
Ruby
davelively14/sep-assignments
/01-data-structures/01-introduction-to-data-structures/screen/screen_spec.rb
UTF-8
1,702
3.296875
3
[]
no_license
require_relative 'screen' RSpec.describe Screen, type: Class do let(:screen) { Screen.new(10, 10) } describe "#insert" do it "inserts a pixel at the proper x, y coordinates" do pixel = Pixel.new(255, 200, 175, 1, 1) screen.insert(pixel) expect(screen.at(1, 1)).to eq pixel end it "r...
true
e6f38e7b97ad40f35626ff4c0ceb6b8653841219
Ruby
devnivek/Ruby
/Desafios Ruby/Word_Count.rb
UTF-8
524
3.21875
3
[]
no_license
#DESAFIO CONTAR VOGAIS E CONSOANTES class Word_Count def vowels_count(phrase) require "i18n" #aplicando internacionalização para remover acentos puts I18n.transliterate(phrase).upcase.count "AEIOUY" #transformando em maiusculas e contando vogais end def consonants_count(phrase) requi...
true
93dc8974491341abd7aacadb2ebdaa500e3bad7b
Ruby
Solertis/splam
/lib/splam/rules/user.rb
UTF-8
452
2.53125
3
[ "MIT" ]
permissive
class Splam::Rules::User < Splam::Rule def run bad_words = ["qq.com", "yahoo.cn", "126.com"] bad_words |= %w( mortgage ) bad_words.each do |word| add_score 50, "User's email address has suspicious parts: #{word}" if @user.email.include?(word) end add_score "20", "User has lots and l...
true
3e2a0a167ec0ef78f3d392fe423b42b3b699496c
Ruby
TheMaxta/JobFinder
/jobs_sctructured.rb
UTF-8
5,266
2.796875
3
[]
no_license
require 'HTTParty' #sends request to page require 'Nokogiri' #places xml info into ruby object require 'JSON' require 'Pry' #debugging gem require 'csv' #AS OF NOW, ONLY CRAIGSLIST WORKS!! class ProgramController def initialize @cities = %w[ denver sandiego sanantonio newyork seattle chicago orangecoun...
true
f8072b303120088b4ce30ffff18ccb223a49e201
Ruby
itsmumar/Hellobar
/app/services/calculate_bill.rb
UTF-8
2,202
2.890625
3
[]
no_license
class CalculateBill # @param [Bill::ActiveRecord_Relation] bills # @param [Subscription] subscription def initialize(subscription, bills:) @subscription = subscription @bills = bills end def call if active_paid_bills.empty? make_bill_to_full_amount elsif upgrading? make_bill_for_u...
true
27812fa92df9b8d1bcb2b0bfbdfc0f7c0cdaa7e5
Ruby
telsaiori/rbnd-toycity-part4
/lib/udacidata.rb
UTF-8
2,970
3.109375
3
[]
no_license
require_relative 'find_by' require_relative 'errors' require 'csv' class Udacidata create_finder_methods("brand", "name") @@data_path = File.dirname(__FILE__) + "/../data/data.csv" def self.create(attributes = {}) new_product = Product.new(attributes) CSV.open(@@data_path, "a+") d...
true
ade24971ccd552bc81e36ca1bc8a475346ea896c
Ruby
amt1/wkend-hmwrk
/wk2-wkend-hmwrk/specs/room_spec.rb
UTF-8
2,824
3.0625
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../karaoke_bar') require_relative('../guest') require_relative('../room') require_relative('../song') class TestRoom < Minitest::Test def setup @room1 = Room.new("The Colorado Lounge", 2) @guest1 = Guest.new("Delbert Grady", 100, "It's All Forgo...
true
2fa7cfa5027614cf051c28409cdb054664c4b3ea
Ruby
hnsaavedraa/Mock-Nequi
/Goal.rb
UTF-8
2,360
3.234375
3
[]
no_license
require_relative "DBconect.rb" class Goal def initialize(id,sql) @mysql_obj = sql @id = id @list_goals = Array.new() @max_goals = Array.new() @balance_goals = Array.new() end def createGoal(name_goal, value_goal, date_goal) @mysql_obj.query("INSERT INTO accounts (`type_account`, `name_a...
true
20086a5b81cd52e9f5dab6d0029c0ac1fd6e7b8b
Ruby
jfeng702/JS-Exercises
/cracking/linkedlist/kth_to_last.rb
UTF-8
874
4.03125
4
[]
no_license
# find kth to last element of singly linked list class Node attr_accessor :val, :next def initialize(val) @val = val @next = nil end end def kth_to_last(head, k) counter = 1 @head = head while head head = head.next counter += 1 end counter_2 = 1 head = @head while head if co...
true
57815c904e1b5cef1ff8a86639502e2a2467c826
Ruby
sf-squirrels-2017/hipsteroverflow
/app/helpers/session_helpers.rb
UTF-8
308
2.71875
3
[]
no_license
helpers do def login(user) session[:user_id] = user.id end def logout session.clear end def current_user if session[:user_id] User.find(session[:user_id]) else nil end end def user? if current_user != nil true else false end end end
true
5f681c5e5859f74d55d3becb9063fb8d5ba08e11
Ruby
coinbase/salus
/lib/salus/path_validator.rb
UTF-8
567
2.671875
3
[ "Apache-2.0" ]
permissive
module Salus class PathValidator def initialize(base_path) @base_path = base_path end def local_to_base?(path) return true if @base_path.nil? path = Pathname.new(File.expand_path(path)).cleanpath.to_s rpath = File.expand_path(@base_path) return true if path == rpath i...
true
b482fd185ee4ff8aaddefcd70e2d4c6a1c2c16db
Ruby
pabloleonalcaide/webChat
/webChat-back/lib/errors/roomsNotFound.rb
UTF-8
359
2.75
3
[ "MIT" ]
permissive
module Errors class RoomsNotFound < StandardError def initialize @message = 'No se han encontrado salas' @status = 400 end def to_h { status: status, message: message } end def serializable_hash to_h end def to_s to_h.to_s end ...
true
d3940116f085e6625fb0d886200c4ec277125231
Ruby
Jayin/practice-on-Ruby
/getting-start/iterators.rb
UTF-8
292
3.984375
4
[]
no_license
#iterators 迭代 # C style s = 'abc' i = 0 while i<s.length printf "<%c>", s[i] i+=1 end print "\n" #Ruby s.each_byte{ |item| printf "<%c>", item } print "\n" # yield def repeat(num) while num > 0 yield num -= 1 end end repeat(3) { puts "foo" }
true
61b37b8594bd35eb3017757e6d09bf1e80ffaa3d
Ruby
necrojan/exercises
/opposite.rb
UTF-8
305
3.640625
4
[]
no_license
def opposite_sum(nums) count = 0 nums.each_with_index do |ele1, idx1| nums.each_with_index do |ele2, idx2| if ele1 + ele2 == 0 && idx2 > idx1 count += 1 end end end return count end puts opposite_sum([2, 5, 11, -5, -2, 7]) puts opposite_sum([21, -23, 24, -12, 23])
true
5bd377cb550ab8423ba13219a1666cd917970a98
Ruby
glen/algorithms
/ruby/linear_search/app.rb
UTF-8
1,137
2.78125
3
[]
no_license
require File.expand_path('../boot', __FILE__) ["linear_search.rb"].each do |lib_file| require_relative(File.join(App.root, 'lib', lib_file)) end require_relative(File.join(App.root, 'helpers', 'formatted_output.rb')) include FormattedOutput print_value(value: "#{'#'*25} Linear Search Implementation #{'#'*25}", col...
true
a8ab63b89dbb9760595b1627e2fa4fd2fa228ff3
Ruby
lenn4rd/chores_kit
/lib/chores_kit/chore/notification.rb
UTF-8
223
2.59375
3
[ "MIT" ]
permissive
class Notification def initialize(condition) @condition = condition @commands = [] end # rubocop:disable Style/MethodMissing def method_missing(name, *args) end # rubocop:enable Style/MethodMissing end
true
63df779f5ac1c4d78434b075262430db87ca96bb
Ruby
dfucci/StarWars-Gosu
/bobba.rb
UTF-8
1,726
3.046875
3
[]
no_license
load 'bullet.rb' class Bobba attr_reader :x, :y, :direction, :shoots, :height, :bullet attr_accessor :shooting SPEED = 6 def initialize window, x, y @height, @x, @window, @direction, @shooting, @shoots = height, x, window, direction, false, 3 @width = 32 @height = 41 @frame = 0 @samp...
true
efd2b888bef49df538e42ee96ae5e3c7265a774b
Ruby
wengkhing/flashcards
/db/seeds.rb
UTF-8
618
2.640625
3
[]
no_license
require 'faker' if Card.all.count == 0 deck = Deck.create(name: "Geography", instruction: "Guess if place name is a country, a state or a city?") 50.times do randnum = rand(3) case randnum when 0 Card.create(question: Faker::Address.country, answer: "country", deck: deck) when 1 Card.cr...
true
148a45abac90b8c4dedf381a4333129ae481d5b3
Ruby
jede/crafty
/lib/crafty/toolset.rb
UTF-8
1,774
2.75
3
[ "MIT" ]
permissive
module Crafty module Toolset class << self # Define the given elements and self-closing elements in the given # module. The module will be modified to never overwrite existing # methods, even if they have been defined in superclasses or other # previously-included modules. def define...
true
708186024980a2b9f3f0a93a0135a2d8d59a71c8
Ruby
yuhangwu2009/eulerPrjs
/ruby/project_6.rb
UTF-8
223
3.765625
4
[]
no_license
print "Please input your number: " number = gets.chomp.to_i x = 1 y = 0 sum = 0 while x <= number y += x sum += x*x x += 1 end y = y*y z = y-sum puts "The difference is #{z} which is the difference of #{y} & #{sum}."
true
e56a4b1e3e09632fd3d0834c36d837d879c78235
Ruby
harrisj/nytimes-movies
/lib/nytimes/movies/link.rb
UTF-8
737
2.734375
3
[ "MIT" ]
permissive
module Nytimes module Movies ## # Represents a link returned from the Reviews API. Each link has a URL, suggested text, and a link_type which gives you some idea of what the remote # target of the link is. Possible link types include: # FIXME class Link attr_reader :link_type, :url, :suggested_text ...
true
a17c4d197f4afec58df82c64a427e7dcaf97e8d8
Ruby
Bhanditz/gem-aws-instmd
/lib/aws/instmd.rb
UTF-8
1,986
2.90625
3
[ "MIT" ]
permissive
require 'net/http' module AWS class InstMD def self.method_missing name, *args, &block @@root ||= InstMD.new @@root.method(name).call(*args, &block) end # Can't be the first one to make that pun. # Still proud. class Hashish < Hash def method_missing name self[name.to_s...
true
3536fb3ee4766cbc79fddcdf785e90d0698b7896
Ruby
WildCat27/Ruby
/Project/SingleControllers/DBController.rb
UTF-8
1,329
2.6875
3
[]
no_license
require "mysql2" require_relative "Singleton" class DBController private_class_method :new def self.controller @@controller ||= new end def try_connect begin @client = Mysql2::Client.new( :host => "localhost", :username => "test_user", ...
true
a4f358f33f90bf491a98841b272b2309eb0ac4da
Ruby
sdevine90/little_pets
/controllers/pets_controller.rb
UTF-8
941
2.578125
3
[]
no_license
require( 'sinatra' ) require( 'sinatra/contrib/all' ) require( 'pry-byebug' ) require_relative( '../models/pet.rb' ) require_relative( '../models/owner.rb' ) get '/pets' do @pets = Pet.all @owners = Owner.all erb(:"pets/index") end get '/pets/new' do erb :"pets/new" end post '/pets' do pet = Pet.new(param...
true
4555eff83b8cc80aa2ded35b434cbf93831e91ed
Ruby
dawa/codeprep
/interview_1_wk_2.rb
UTF-8
1,543
4.125
4
[]
no_license
class CustomHash def initialize() @length = 16 @hash_array = [] @size = 0 end def get(key) index = hash_func(key) @hash_array[index][1] unless @hash_array[index].nil? end def put(key, value) index = hash_func(key) @hash_array[index] = [key, value] @size += 1 @lengt...
true
2281982b6a9163fa1f5ef509a65cca87c8bce565
Ruby
shiveshdewangan/LaunchSchool
/smallproblems/Easy2/teddy.rb
UTF-8
63
3.09375
3
[]
no_license
def teddy() puts "Teddy is #{rand(20..200)} years old!" end
true
b53f4b385fd14169bb8667061134288845d91429
Ruby
dbesserman/LS_exercises
/small_problems/medium_2/6.rb
UTF-8
485
3.828125
4
[]
no_license
def triangle(angle_1, angle_2, angle_3) angles_array = [angle_1, angle_2, angle_3] if (angles_array.inject(:+) != 180) || angles_array.include?(0) :invalid elsif angles_array.include?(90) :right elsif angles_array.any? { |angle| angle > 90 } :obtuse else :acute end end puts triangle(60, 70...
true
1ee2883c5a8c84d679cee38f0558d106274c9fe2
Ruby
mikekauffman/reddit_warmup
/image_fetcher.rb
UTF-8
386
2.953125
3
[]
no_license
class ImageFetcher def initialize(data) @data = data end def count_children @data["data"]["children"].count end def first_child @data["data"]["children"].first["data"] end def all_images @data["data"]["children"].map { |child| child["data"]["url"]} end def only_imgur_images a...
true
aab9defd1e0ac35ae33cfb006cfb23042fe27961
Ruby
triplecanopy/alongslide
/lib/alongslide.rb
UTF-8
2,238
2.8125
3
[ "MIT" ]
permissive
# # alongslide-redcarpet.rb: top-level bindings and entrypoint for Redcarpet # and Treetop. # # Copyright 2013 Canopy Canopy Canopy, Inc. # Author Adam Florin # require 'yaml' require 'haml' require "alongslide/engine" require "alongslide/templates" require "alongslide/redcarpet/render" require "alongslide/treetop/p...
true
357b1055f9eebdd8fd1255440ac977ebc95df0b7
Ruby
amolborcar/Project-Euler
/problem_007.rb
UTF-8
212
3.484375
3
[ "MIT" ]
permissive
def nth_prime(n) primes = [] i = 2 while primes.length < n do primes << i if (2..i-1).all? { |num| i % num != 0 } i += 1 end return primes end p nth_prime(10001) # This is slow... # As hell...
true
a5556536ea25e6f4772281ffe6e2c43f060d6384
Ruby
MeowNya/Ruby_socket_based_simple_server_client
/common.rb
UTF-8
518
3.046875
3
[]
no_license
def recv_all(s) begin raw_msg_len = s.read(8).unpack('Q').first # Unpack is 8 byte to number return s.read(raw_msg_len) rescue return '' end end def send_all(s, msg) begin msg = msg.to_s s.write [msg.length].pack('Q') + msg # Q is 8 byte (long long int) rescue return end end def pa...
true
940d0e71278d42bcbac6edb9027b07ecddcf0a27
Ruby
Keerthu8999/WEB-TECH-LAB
/pg3.rb
UTF-8
338
3.609375
4
[]
no_license
puts "String Operations" string = "keerthana" p string.upcase p string.downcase p string.capitalize p string.swapcase p string.center(100) p string.ljust(20) p string.rjust(50) p string.chomp("na") p string.include?("t") p string.index("h") p string.start_with?("s") p string.end_with?("na") p string.sub(...
true
66b37a6a85b93f0c3d291e0bcf3deaf7761f0d3a
Ruby
matao0214/Demo
/1946.rb
UTF-8
40
2.703125
3
[]
no_license
m,n = gets.split.map(&:to_i) puts m - n
true
fb1b4d1056735bb7a31160fc401957e5e149f55d
Ruby
redding/whysoslow
/lib/whysoslow/measurement.rb
UTF-8
950
3.046875
3
[ "MIT" ]
permissive
require 'benchmark' module Whysoslow class Measurement MEASUREMENTS = [:user, :system, :total, :real] attr_reader :units, :multiplier attr_reader *MEASUREMENTS def initialize(units='ms') @user, @system, @total, @real = 0 @units, @multiplier = if units == 's' ['s', 1] else ...
true
583d5916ca6bab4c6f0c6b6bda4769df9fa682dd
Ruby
krile136/atcoder
/138/A-Red_or_Not.rb
UTF-8
99
2.765625
3
[]
no_license
a = gets.strip.to_i s = gets.strip.split('') if a >= 3200 puts s.join('') else puts 'red' end
true
d0a489568988b3fb6390a83c2b44fbfcd4fbd142
Ruby
jpabico/reference_stuff
/euler_project/ep_problem_20.rb
UTF-8
175
3.1875
3
[]
no_license
product = 1 for i in 1..100 product *= i end a = product.to_s.split("") b= a.map do |elem| elem.to_i end sum = 0 b.each do |element| sum += element end sum
true
3ef5c5fb75e5525a67880f3fd0d685fe6193b5f9
Ruby
enowmbi/algorithms
/add_to_array_form_of_integer.rb
UTF-8
262
3.15625
3
[]
no_license
# @param {Integer[]} a # @param {Integer} k # @return {Integer[]} def add_to_array_form(a, k) return a if k == 0 sum = (a.join.to_i) + k result = [] sum.to_s.each_char do |char| result << char.to_i end return result end
true
24abe69353bbe2b363f591cee0fe9f7b8e901827
Ruby
CynthiaBin/Programacion-Paralela
/proyecto/daemon.rb
UTF-8
1,737
2.765625
3
[]
no_license
require 'httparty' require_relative './models/server' require_relative './models/file' # Client class Daemon include HTTParty base_uri 'localhost:9292' def delete_(server_name, current_file) url = '/files/' + server_name + '/' + current_file self.class.delete(url) end def copy_(server_name, current_...
true
9e4a027cc91f93ad7a6c9fbb72dfdcb0476e1dd2
Ruby
mthorry/ruby-collaborating-objects-lab-web-071717
/lib/song.rb
UTF-8
525
4.03125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# The Song class will be responsible for creating songs given each filename and sending the artist's name (a string) to the Artist class class Song attr_accessor :name, :artist def initialize(name) @name = name end def self.new_by_filename(filename) song_name = filename.split(" - ")[1] song = sel...
true
9ace6b60423d7a3abdb81b985d5c0a35c2831546
Ruby
kaanbursa/kaan.bursa.kaanbursa
/exercises/hashonhash.rb
UTF-8
238
2.78125
3
[]
no_license
hash1 = { :description => "rice", :ingrendients => ["salt", "pepper", "water"], :steps => ["soak the rice in water", "boil and cook", "add salt"] } cookbook = { "Hash browns" => ["description", "ingrendients", "steps"] } puts hash1
true
118cf2a5aef62c4f06fe3ce166540b25c22e0ee9
Ruby
Asoyan/exo_rb
/pyramide.rb
UTF-8
636
3.265625
3
[]
no_license
i = 0 puts ("- Salut BG, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ? ") print "> " nombre = gets.chomp.to_i puts ("- On essaye!! : ") while (i < nombre) i += 1 htag = "#" * i puts htag end puts "- OHHH!! Bravooo BGGG!! t'es trop fort là !!! t'arrives bien à descendre toi hein!!??? et bah ...
true
7a65da9f2ed08560b1db6f90c1a0e550e4f89597
Ruby
TaylorHuston/Ruby_RestaurantFinder
/lib/restaurant.rb
UTF-8
1,649
3.296875
3
[]
no_license
class Restaurant @@filepath=nil def self.filepath=(path=nil) @@filepath = File.join(APP_ROOT, path) end attr_accessor :name, :cuisine, :price #Class should know if restaurant file exists def self.file_usable? if (@@filepath!=nil && File.exists?(@@filepath) && File.readable?(@@filepat...
true
eec31cc165165225ffb118e5be24f06d48cf0aa1
Ruby
idkjay/Launch
/week1-advoop/bounding-box/spec/02_bounding_area_spec.rb
UTF-8
1,717
3.0625
3
[]
no_license
require_relative '../lib/bounding_area' require_relative '../lib/bounding_box' RSpec.describe BoundingArea do describe '#boxes_contain_point?' do it 'is always false for an empty bounding area' do empty_area = BoundingArea.new([]) expect(empty_area.boxes_contain_point?(0.0, 0.0)).to eq(false) end...
true
d941b39da073b8eafae9342df8a4e189974c4f68
Ruby
oscos/launch_school
/rb101/lesson2/calculator_refactored.rb
UTF-8
2,171
4.15625
4
[]
no_license
=begin Launch School: RB101 - Lesson 2 - Refactoring Calculator ExerciseName: [Refactoring Calculator](https://launchschool.com/lessons/a0f3cd44/assignments/fcd8a299) FileName: calculator.rb Answered On: 09/18/2020 =end =begin - ask the user to input two numbers - ask user to input type of operation to use in calculat...
true
fea8ff8756691a3e4c2a56345bb5834f6068325c
Ruby
cherifb16/ruby_sample_codes
/code.rb
UTF-8
1,545
3.984375
4
[]
no_license
# concaténation # car = "Ferrari" # puts "my favorite car is" + car # puts "One of the luxury cars is the" + car # Expansion de l'expression # car = "Ferrari" # puts "my favorite car is #{car}" # puts "One of the luxury cars is the #{car}" # compter les caractères dans un mot d'un utilisa...
true