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
94f250bf9ffb19a424d051d4ac75f06753af81f1
Ruby
aldazj/Platform_am_v11
/app/controllers/video_clip_steps_controller.rb
UTF-8
2,878
2.515625
3
[]
no_license
##################################### # Aldaz Jayro HEPIA # ##################################### class VideoClipStepsController < ApplicationController #On inclut la librarie Wicked include Wicked::Wizard #On définit les différents états qu'on va faire passer notre element video clip #L'ordre ...
true
888d01d50b198d4420f2619c73adb8bbe6e45068
Ruby
rafaeljcadena/estudos_rspec
/spec/matchers/classes/classes_spec.rb
UTF-8
504
2.875
3
[]
no_license
require 'string_nao_vazia' describe 'Matchers de classes' do it 'be_instance_of' do expect(10).to be_instance_of(Integer) # Exatamente a classe end it 'be_kind_of' do expect(10).to be_kind_of(Integer) # Pode ser herança end it 'be_a / be_an ' do str = StringNaoVazia.new expect(str).to be_an(String) ex...
true
a340aa7ff97f60bebc4894a0e23af4903848d61e
Ruby
djekels-zz/infoblox
/lib/infoblox/connection.rb
UTF-8
1,368
2.625
3
[ "MIT" ]
permissive
module Infoblox class Connection attr_accessor :username, :password, :host, :connection, :logger, :ssl_opts def get(href, params={}) wrap do connection.get(href, params) end end def post(href, body) wrap do connection.post do |req| req.url href r...
true
be7056ca1ab91a467e1edec202457080808c06b7
Ruby
zeevex/evri_rpx
/lib/evri/rpx/credentials.rb
UTF-8
1,480
2.671875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Evri module RPX class Credentials def initialize(json) @json = json end # Returns the type of credentials: # (Facebook|OAuth|WindowsLive) # # Generally, you should use the helper methods such # as #facebook?, #oauth?, #windows_live? def type ...
true
6cd4ddc5a5147bc5c18ab8c98ecd0f860b89e831
Ruby
devlab-oy/pupenext
/app/models/concerns/searchable.rb
UTF-8
1,655
2.78125
3
[]
no_license
module Searchable extend ActiveSupport::Concern module ClassMethods def search_like(args = {}) raise ArgumentError, "should pass hash as argument #{args.class}" unless args.is_a? Hash result = self.all args.each do |key, value| if exact_search? value result = result.where ...
true
d2d85f3efdb31f1ccbf9b6dd2e793e816a3730b4
Ruby
mikennaji/ruby-music-library-cli-cb-000
/lib/ musicimporter.rb
UTF-8
315
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class MusicImporter attr_accessor :path def initialize(path) @path = path end def files directory = Dir["#{self.path}/*"] directory.map do |file| file.slice!(self.path + "/") end return directory end def import self.files.each do |file| Song.create_from_filename(file) end end end
true
f5de47d505fb965436c290cf0c81dada59259f94
Ruby
MrPowers/battleship
/spec/board_spec.rb
UTF-8
700
3.359375
3
[]
no_license
require_relative "../board.rb" describe Board do let(:board) { Board.new } context "#grid" do it "creates a grid with 11 rows" do board.grid.count.should eq 11 end it "creates a grid with 11 columns" do board.grid.transpose.count.should eq 11 end it 'the first row of the grid is [" ", "A", "B", "C...
true
7c4aee3ac8a7ffe07da6453c9bb76575c3a568b5
Ruby
mauricioszabo/gml2svg
/spec/svg_builder_spec.rb
UTF-8
1,008
2.59375
3
[]
no_license
require 'svg_builder' describe SVGBuilder do include SVGBuilder it 'deve ser possível criar um documento vazio' do svg = build_svg {} svg.should == "<?xml version='1.0' standalone='no'?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'> <svg xm...
true
d85978dff7e54519868cb45e24b7712a65d32e1c
Ruby
deleyla/kid2camp
/app/controllers/families_controller.rb
UTF-8
2,277
2.734375
3
[]
no_license
class FamiliesController < ApplicationController # get all families from my database def index families = Family.all p "Hello i'm about to print where the user is" p current_family # if current_family # families = current_user.families # render json: families.as_json # else # ...
true
62aeb242e67e797c131e668d7f7f14a3afbef51c
Ruby
jeffreyyyy/Ruby_Connect
/spec/models/admin_spec.rb
UTF-8
1,690
2.640625
3
[]
no_license
require 'spec_helper' describe Admin do before(:each) do @attr = { :name => "Jeffrey Jurgajtis", :email => "jeffrey@example.com" } end it "should create a new instance given a valid attribute" do Admin.create!(@attr) end it "should require a name" do no_name_admin = Admin.new(@attr.merge...
true
6a47c10c7c871b4c4463339f6f397ed52e4e2f6a
Ruby
radiodan-archive/frankenpins
/scratch/interrupt.rb
UTF-8
314
2.703125
3
[ "Apache-2.0", "BSD-2-Clause" ]
permissive
require 'bundler/setup' require 'wiringpi2' INPUT = 0 PUD_UP = 2 INT_EDGE_BOTH = 3 pin = 0 io = WiringPi::GPIO.new io.pin_mode(pin,INPUT) io.pullUpDnControl(pin, PUD_UP) io.wiringpi_isr(pin, INT_EDGE_BOTH) do puts "in block" end puts "before while" while (true) puts io.digital_read(pin) sleep(0.5) end
true
0bc62612f06a6e353bc30c61b696cb1202732de5
Ruby
ercekal/bank-account-tt
/lib/account.rb
UTF-8
544
3.453125
3
[]
no_license
require_relative './log.rb' require_relative './transaction.rb' class Account attr_reader :balance, :log def initialize(log = Log.new) @balance = 0 @log = log end def deposit(number) @balance += number @log.add_to_log(number, @balance) end def withdraw(number) if @balance >= number ...
true
fb375884998c6f83a63c80b30c52e3b644db2240
Ruby
clayton/ofcp_scoring
/lib/ofcp_scoring/organized_hand.rb
UTF-8
802
2.90625
3
[ "MIT" ]
permissive
class OfcpScoring::OrganizedHand include Enumerable def initialize(organized_hand) @hand = organized_hand end def ranks @hand[:ranks] end def sequences ranks = @hand[:ranks].reverse prev = ranks[0] ranks.slice_before { |cur| prev, prev2 = cur, prev prev2 - 1 != prev }....
true
b1d52b3829d536291a2fbb09d6453d96baddb990
Ruby
daveadams/sakai-info
/lib/sakai-info/hacks.rb
UTF-8
1,312
2.84375
3
[ "LicenseRef-scancode-public-domain", "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# hacks.rb # Hacks necessary to work around problems in external libraries # # Created 2012-05-20 daveadams@gmail.com # Last updated 2012-10-05 daveadams@gmail.com # # https://github.com/daveadams/sakai-info # # This software is public domain. # ###################################################################### ...
true
930ade4be4f6c0c7b4204654fd78ff66ab8068ed
Ruby
k16shikano/isbn.rb
/test-isbn.rb
UTF-8
354
2.78125
3
[]
no_license
require 'test/unit' require 'isbn' class TC_ISBN < Test::Unit::TestCase def setup @sicp = ISBN.new("0262011530") @sicp13 = 9780262011532.to_isbn @sicpj = 9784894711631.to_isbn end def test_sicp assert_equal(@sicp13, @sicp.isbn13) end def test_sicpj assert_equal("4 89471 163 X", @sicpj.i...
true
b984b31ca0d8c4ad7be44b0df742978974934152
Ruby
murayama/qiita_hackathon
/ruby/ranking_items.rb
UTF-8
604
2.65625
3
[]
no_license
require File.join(File.expand_path('../', __FILE__), 'qiita') class RankingItems < Base def execute followees = @client.list_user_followees(@current_user['id'], page: 1, per_page: 100).body followees << @current_user followees = followees.sort{|a,b| b['items_count'] <=> a['items_count']} msg = [] ...
true
6041ed04bc3fbace110e2c78ac93dd0c8701b252
Ruby
nkoehring/rails-batchquery
/batch_query.rb
UTF-8
1,416
2.703125
3
[]
no_license
# encoding: utf-8 class BatchQuery attr_reader :columns include Enumerable def initialize(table, fields, batch_size=10, conn=nil) @table = table # Is fields a string? I want an array! if fields.respond_to? "join" @fields = fields @fields_str = fields.join(",") else @fields = fie...
true
77bb45394e82ed638c352dba082a3ecea7237c95
Ruby
rotyflo/appacademy
/ruby/projects/recursion/deep_dup.rb
UTF-8
596
3.859375
4
[]
no_license
class Array def deep_dup dup_arr = [] self.each do |ele| ele.is_a?(Array) ? dup_arr << ele.deep_dup : dup_arr << ele end dup_arr end end arr = [1, [2], [3, [4]]] # Recursive 'deep_dup' duplicates any arrays within the top level array arr_deep_dup = arr.deep_dup arr_deep_dup[1] << "deep dup" p arr ...
true
968cc29d25a0196a551c4c95947194d92978d26f
Ruby
jaretogarato/portal-2018
/db/lecture_content.rb
UTF-8
35,159
2.65625
3
[]
no_license
def lecture_seed [ '<h1>Console / Input / Output Ruby</h1> <p> <img src="http://www.unixstickers.com/image/data/stickers/ruby/ruby_badge.sh.png" height="296" width="200"> </p> <p>Today is a very light day due to: getting to know you exercises, building tour, lunch, computer setup, canvas setup, canvas explori...
true
c3a60bd87e7110b05a5c3ce31f2ccc7fe16ffbe0
Ruby
pdynowski/phase-0
/week-4/define-method/my_solution.rb
UTF-8
138
2.640625
3
[ "MIT" ]
permissive
# Define an Empty Method # I worked on this challenge all on my lonesome. # Your Solution Below def do_something(par1, par2, par3) end
true
fba8b385a73d7a07b89c917ce53caa7b1c909ddd
Ruby
rasensio1/Enigma
/key.rb
UTF-8
359
3.203125
3
[]
no_license
class Key attr_accessor :value def initialize(number = '') @value = number end def generate keys = (10000..99999).to_a @value = keys.sample.to_s end def create_key_from_rotation(rotation) a = rotation.a.to_s b = rotation.b.to_s c = rotation.c.to_s d = rotation.d.to_s e = r...
true
8b77a88c55506390bd24f3a1f2e67d2b32007792
Ruby
GSpence/learn_ruby
/03_simon_says/simon_says.rb
UTF-8
400
3.859375
4
[]
no_license
def echo(x) x end def shout(x) x=x.upcase end def repeat(word, sum=2) ([word]*sum).join ' ' end def start_of_word(word, x) word [0,x] end def first_word(string) string.split[0] end def titleize(string) y=string.split(' ') y.each do |x| if x == 'and' || x == 'over'|| x == 'the' nex...
true
26a709459d77fbff84359dd5d4463688608dbfb4
Ruby
tbonza/CS_CS169.1x
/hw1/lib/fun_with_strings.rb
UTF-8
1,237
3.859375
4
[]
no_license
module FunWithStrings def initialize(check_string) @check_string = check_string end attr_accessor :check_string def palindrome? """ A palindrome is a word or phrase that reads the same forwards as backwards, ignoring case, punctuation, and nonword characters. (A 'nonword chara...
true
77744738d753c47077ad50f376b120747860e1ad
Ruby
siorekoskar/Ruby-tickets
/app/models/event.rb
UTF-8
765
2.671875
3
[]
no_license
class Event < ActiveRecord::Base validates :artist, :presence => true validates :description, :presence => true validates :price_low, :presence => true, :numericality =>true validates :price_high, :presence => true, :numericality =>true validates :event_date, :presence => true validate :event_d...
true
18ac3a2821224f444b2d77bafb7d0499efd630d1
Ruby
btdunn/codewars
/ruby/findMissingNumber.rb
UTF-8
47
2.59375
3
[]
no_license
def missing_no(nums) 5050 - nums.sum end
true
55a4f30b2c9c2447bcf782b8736109c8d93b9fdb
Ruby
bbatsov/volt
/spec/reactive/computation_spec.rb
UTF-8
2,538
2.53125
3
[ "MIT" ]
permissive
require 'spec_helper' describe Volt::Computation do it 'should trigger again when a dependent changes' do a = Volt::ReactiveHash.new values = [] -> { values << a[0] }.watch! expect(values).to eq([nil]) a[0] = 'one' Volt::Computation.flush! expect(values).to eq([nil, 'one']) a[0] ...
true
f526848019385617faff950a61572da51c49df06
Ruby
KazW/multi-buildpack
/bin/compile
UTF-8
2,704
2.53125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # Load libraries require 'uri' require 'tmpdir' require 'fileutils' require 'yaml' # Allow git commands to function locally. ENV['GIT_DIR'] = nil # Variables @last_framework = "None" @buildpacks = [] @frameworks = [] @release = {} @last_release = {} def parse_buildpack_file bu...
true
1ba333c200d9007b0ad0015a7b362e9577a55276
Ruby
dianeyasminec/phase-3-ruby-oo-basics-object-initialization-lab
/lib/person.rb
UTF-8
84
2.5625
3
[]
no_license
class Person attr_reader :name def initialize(name) @name = name end end
true
797cae4b260aa2a02f3de2d21cf30d2bc26f190a
Ruby
mitmedialab/MediaMeter-Coder
/utilities/blacklist_duplicate_entries.rb
UTF-8
846
2.78125
3
[]
no_license
require '../config/environment.rb' @duplicate_count = 0 @previous_duplicate_string = nil @previous_abstract = nil Article.all(:conditions=>['(blacklist_tag IS NULL or blacklist_tag="" or blacklist_tag ="duplicate")'], :order=>"source, pub_date asc, headline asc, abstract").each do |article| duplicate_string = "" + a...
true
162166a5c179090acffb4739db70e91564c6b276
Ruby
SotirisKavv/oo-email-parser-cb-gh-000
/lib/email_parser.rb
UTF-8
630
3.453125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Build a class EmailParser that accepts a string of unformatted # emails. The parse method on the class should separate them into # unique email addresses. The delimiters to support are commas (',') # or whitespace (' '). class EmailAddressParser attr_accessor :email_addresses_filetext, :email_addresses def init...
true
402e20283149d6fe376c00fff01294fafdb7e26c
Ruby
oscos/launch_school
/rb101/lesson3/easy1/x07.rb
UTF-8
381
3
3
[]
no_license
=begin Launch School: RB101 Programming Foundations - Lesson 3 - Practice Problems ExerciseName: [Easy 1(https://launchschool.com/lessons/263069da/assignments/e2593fe1) FileName: ex07.rb Answered On: 09/23/2020 =end # Make this into an un-nested array. flintstones = ["Fred", "Wilma", ["Barney", "Betty"], ["BamBam", ...
true
27f6446dc0094c283da7bda183a9b9df8282dbf9
Ruby
eggyy1224/introduction_to_programming
/array/exercise7.rb
UTF-8
84
3.328125
3
[]
no_license
def increment_by_two arr p arr.map {|x| x+2} p arr end increment_by_two [1,2,3]
true
5ce1f8d12ce2a0e9988094ab5c9747a32d5ce9a9
Ruby
samueladesoga/inec-poll
/csv_to_json.rb
UTF-8
460
2.640625
3
[]
no_license
require 'csv' require 'json' extracted_data = CSV.table('SenatorialDistrict_Massaged.csv', :headers => false , :encoding => 'ISO-8859-1') senatorial_districts = Hash.new { |hash, key| hash[key] = Hash.new(&hash.default_proc) } extracted_data.each {|line| senatorial_districts[line[0].strip][line[1].strip]= line[2].sp...
true
c04f735271a36da94ec34bd9f0bfe52e0e7c22d5
Ruby
joaocferreira/algorithms
/ruby/linked_list/linked_list.rb
UTF-8
1,283
3.84375
4
[]
no_license
class Element attr_accessor :value, :next def initialize(value) @value = value @next = nil end end class LinkedList attr_reader :head def initialize(head = nil) @head = head end def append(new_element) current = head if head while current.next do current = current.next...
true
83d8826e3bacd7f250cca9120c7f03258e2cc014
Ruby
nrazam95/AA-Online-Study
/muhd_nurul_azam_recap_exercise_3/recap_exercise_3.rb
UTF-8
5,727
3.765625
4
[]
no_license
#General Problems! def no_dupes?(array) hash = {} new_array = [] hash = Hash.new {|hash, key| hash[key] = 0} array.each do |num| hash[num] += 1 end hash.each do |k, v| new_array << k if v == hash.values.min end if new_array.include?(true) || new_array.include?(fa...
true
c68a0eae7db3196bc02edff04eb59a2022ed5afe
Ruby
agisga/mixed_models
/examples/LMM_from_formula.rb
UTF-8
1,547
2.984375
3
[ "BSD-3-Clause" ]
permissive
require 'mixed_models' ############################################################################## # Model with numerical and categorical variables as fixed and random effects # ############################################################################## df = Daru::DataFrame.from_csv './data/alien_species.csv' ...
true
a1365386d7c5f768a379a125ff17469cf4240bf2
Ruby
JFVF/cucumber_022015
/Ruben/Practice3.rb
UTF-8
1,652
3.78125
4
[]
no_license
puts "type your name please..." names = gets.chomp puts "hello #{names} how are yo today" =begin commented code "Some Test".chomp(' Test') "Some Test\r\n".chomp "\tRobert Martin\r\n".strip =end puts "give me a number" firstNumber = gets.chomp.to_f defaultValue = 20 puts result = "Result = #{firstNumber + defaultValue...
true
539708c204ed68027bb917ea128f91acfe654850
Ruby
JoshvaR88/mutant
/spec/support/mutation_verifier.rb
UTF-8
1,793
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
class MutationVerifier include Adamantium::Flat, Concord.new(:original_node, :expected, :generated) # Test if mutation was verified successfully # # @return [Boolean] # # @api private # def success? unparser.success? && missing.empty? && unexpected.empty? end # Return error report # # @ret...
true
d38036698233970cd957a2dd2c70e7e3fedaff82
Ruby
ShanaHunte/Homework
/Homework-1/problem-3.rb
UTF-8
68
2.671875
3
[]
no_license
def greeting join_strings('Hello', 'Dolly!') puts(greeting) end
true
e9e51eb316cc021470cd06c7baf7e5027d476e1b
Ruby
zwhite11/School-Work
/Ruby On Rails/Module 3/Assignment2Submission/assignment2.rb
UTF-8
535
2.984375
3
[]
no_license
#Agile Development with Ruby on Rails: assignment 2 #Zachary White words = IO.read("assignment_two_text.txt").split(/\s+/) domain_pattern = /\w+@\w+.com/ words_with_domains = words.select { |word| word =~ domain_pattern } just_domains = Array.new words_with_domains.each{ |domain| just_domains.push(domain[/\w+.com/])...
true
6202a74e5a92f6bc63eeb6d7f5a68f207b3d8ec8
Ruby
kakitaku00/RubyForProfessionl
/4/4_5/4_5_0.rb
UTF-8
365
4.25
4
[]
no_license
# 範囲(Range) # Rubyには「AからB』までといった範囲オブジェクトが存在する 1..5 # 最後の値を含む 1...5 # 最後の値を含まない (1..5).class #=> Range (1...5).class #=> Range # Rangeを変数に格納せず呼び出す際は()で囲まないとエラーとなる 1..5.include?(1) #=> NoMethodError (1..5).include?(1) #=> true
true
f5fc863331b873101d575164323dd3f53c2d5b8c
Ruby
d3vkit/battleship
/lib/game_manager.rb
UTF-8
1,266
3.140625
3
[]
no_license
require 'singleton' require_relative 'input_manager' require_relative 'text_manager' class GameManager include Singleton attr_accessor :turn, :players def initialize @turn = 0 @players = [] end def next_turn @turn = determine_next_turn end def start_turn # error if no players curr...
true
ec895ae2dd9b76dac4e970bb6a09710165b3037d
Ruby
idaolson/relational-rails
/spec/models/boba_shops/boba_shops_spec.rb
UTF-8
1,419
2.578125
3
[]
no_license
require 'rails_helper' describe BobaShop do describe 'associations' do it {should have_many :drinks} end describe 'methods' do before(:each) do @store_1 = BobaShop.create!( name: 'Sharetea', drive_thru: false, capacity: 25 ) @store_2 = BobaShop.create!( ...
true
807994c9d55de12d20d77dc42ae0d8955f176603
Ruby
kpalania/planit_app-api-scaffold
/lib/database/mongodb.rb
UTF-8
721
2.59375
3
[]
no_license
module Database module MongoDB # Save the object to MongoDB def persist object if object.save $logger.debug "..persisted to MongoDB: \n....#{object.inspect}\n" else raise Mongoid::Errors::MongoidError, "#{object.class} could not be saved" end end # TODO(krish): Not ...
true
7b39a69a46aff2257d118c0a7f458fffe534b5a3
Ruby
jmschles/codeeval
/moderate/stack_implementation.rb
UTF-8
417
3.515625
4
[]
no_license
class Stack attr_reader :stack def initialize @stack = [] end def push(el) @stack << el end def pop @stack.delete_at(-1) end end File.open(ARGV[0]).each_line do |line| next if line.chomp.empty? data = line.chomp.split(' ') s = Stack.new data.each { |el| s.push(el) } to_print ...
true
5edcd8e77eade72e6548b0ef5d590b75be86d96b
Ruby
whatalnk/codejam
/kickstart/2017/Practice-2/B.rb
UTF-8
834
2.765625
3
[ "MIT" ]
permissive
T = gets.chomp.to_i R_MAX = 3000 C_MAX = 3000 T.times do |cc| r, c, k = gets.chomp.split(' ').map(&:to_i) m = Array.new(r){Array.new(c, 0)} cumsum = Array.new(r+1){Array.new(c+1, 0)} k.times do ri, ci = gets.chomp.split(' ').map(&:to_i) m[ri][ci] = 1 end r.times do |i| c.times do |j| cums...
true
87063989b4b9463d8af4a55c2b540a4cf47fa80c
Ruby
ChewbaccaJerky/Code-Challenges
/practice-thy-algorithms/Leetcode/ruby/container_with_most_water.rb
UTF-8
859
3.65625
4
[]
no_license
# Leetcode Problem #11 # Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). # n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). # Find two lines, which together with x-axis forms a container, such that the container contains th...
true
44be487655e203982eb7b693a70238ae03bcc7f5
Ruby
Ben-Gelbard/trading--robot
/main.rb
UTF-8
1,882
3.328125
3
[]
no_license
# require gems require 'stock_quote' # require modules require_relative 'methods.rb' # create User class class User attr_accessor :account_name, :account_balance, :user_stocks, :cart def initialize name @account_name = name @account_balance = 0 @user_stocks = [] @cart = []...
true
9f4560144df86636472b1879a988acfc2cfd6cad
Ruby
hnamitha1/broadcaster_promotions
/run.rb
UTF-8
1,322
2.90625
3
[]
no_license
#!/usr/bin/env ruby require './lib/broadcaster' require './lib/delivery' require './lib/material' require './lib/order' require './lib/price_discount' require './lib/delivery_discount' standard_delivery = Delivery.new(:standard, 10.0) express_delivery = Delivery.new(:express, 20.0) broadcaster_1 = Broadcaster.new(1,...
true
c82c11f643ca19650b1118db4604f409ab832065
Ruby
Hack-Slash/sunday_afternoon
/factorial_recursive.rb
UTF-8
116
3.203125
3
[]
no_license
def factorial(number) if number == 1 return number end number * factorial(number - 1) end p factorial(5)
true
453c9ad81af5f0b9d26d621a12da14387a91f218
Ruby
Kenshincp/StringCalculator
/lib/string_calculator.rb
UTF-8
480
3.65625
4
[]
no_license
class StringCalculator def calcular valor = nil if valor != nil # Primer spilt con menos # numeros = valor.split('-').map{|str| str.to_i}.inject(0, :+) numeros = sumarValores valor numeros else "Este es el metódo" end end # definimos el méto...
true
0ac0fc66a95b45810760f383da39414286f0bdcb
Ruby
jeffrafter/marvin
/lib/marvin/irc/server/user/handle_mixin.rb
UTF-8
4,502
2.671875
3
[]
no_license
module Marvin::IRC::Server::User::HandleMixin def handle_incoming_pass(opts = {}) @password = opts[:password] end def handle_incoming_user(opts = {}) @user = opts[:user] @mode = opts[:mode] @real_name = opts[:real_name] welcome_if_complete! end def handle_incoming_nick(opt...
true
f8b102dff25f1ccfb78632778b4d6c0fbe39a351
Ruby
alexisspa9/connect_four
/spec/player_spec.rb
UTF-8
1,851
3.3125
3
[]
no_license
require "./lib/connect_four/player.rb" require "./lib/connect_four/board.rb" RSpec.describe Player do context "#initialize" do it "requires input" do expect { Player.new }.to raise_error(ArgumentError) end it "initializes with a valid hash" do expect{ Player.new({name: "Bob", marker: "H"})...
true
9074f23a45d5753c0007d1546a2e8f59d6b1669f
Ruby
micahlagrange/adventurer-factory
/lib/adventurer_factory/dice.rb
UTF-8
1,481
3.484375
3
[]
no_license
module AdventurerFactory class ArgumentError < StandardError; end class Die attr_reader :value, :sides def initialize(sides) @sides = sides @value = roll end def > val @value > val end def < val @value < val end def to_h {sides: @sides, value: @value}...
true
3ee2151cb3b8b1af7ccfe7c9e8e942d0dcaecf09
Ruby
alexandralaudon/hash-array-pair-one
/spec/bluegrass_parser_spec.rb
UTF-8
1,372
2.75
3
[]
no_license
require "spec_helper" require "bluegrass_parser" describe BluegrassParser do let(:bluegrass_parser) { BluegrassParser.new} describe "#get_artists" do it "returns an array of all artists from the data" do expect(bluegrass_parser.get_artists).to eq ["Foggy Mountain Boys", "Doc Watson"] end end de...
true
d68ef0a84aa687cf0e1f39301b67fae36bbe91d7
Ruby
yuki3738/AtCoder
/abc/abc094/a/main.rb
UTF-8
74
3
3
[]
no_license
a, b, x = gets.split.map(&:to_i) puts x.between?(a, a + b) ? "YES" : "NO"
true
050c01c593a5649f9f8e69c187cad9286f6bc5ea
Ruby
SoniaSS05/basketball_teams-backend
/app/application.rb
UTF-8
5,021
2.59375
3
[]
no_license
class Application def call(env) res = Rack::Response.new req = Rack::Request.new(env) #APPLICATION ROUTES #team Index if req.path == ('/teams') && req.get? return [200, { 'Content-Type' => 'application/json' }, [Team.all.to_json ]] end #player Index if req.path == ('/player')...
true
925a02493113297789f323954e0243fef92611fc
Ruby
Sajonara/Ruby
/datei/file1.rb
UTF-8
1,090
3.59375
4
[]
no_license
# Dieses Script präsentiert den Umgang mit Dateien # Datei öffnen File.open("./argv.rb", "r") do |datei| # Datei zum Lesen öffnen mit Option "r" n = 1 while zeile = datei.gets print "#{n}:" puts zeile # Inhalt Zeile für Zeile ausgeben n += 1 end end File.open("./testfile.rb", "w") ...
true
e01376e80443eea7f892f7f2585b817281e16025
Ruby
alanzoppa/proforma
/lib/forms.rb
UTF-8
2,259
2.5625
3
[]
no_license
require 'validation' require 'exceptions' require 'getters' require 'formhash' class Form include TestModule if $test_env include Validation include Getters attr_accessor :fields, :errors, :valid def initialize(data=nil) _define_defaults _initialize_fields _prepare_getters _raise_usage_valid...
true
c61d497acc9b2f50319d9aaf5a3e6e6d1101aa2a
Ruby
nervosnetwork/ckb-explorer
/app/utils/query_key_utils.rb
UTF-8
705
2.53125
3
[ "MIT" ]
permissive
module QueryKeyUtils class << self def integer_string?(query_key) /\A\d+\z/.match?(query_key) end def valid_hex?(query_key) start_with_default_hash_prefix?(query_key) && length_is_valid?(query_key) && hex_string?(query_key) end def start_with_default_hash_prefix?(query_key) que...
true
51659a6d17438181678b218ec0a5b3378914f03e
Ruby
flori/tins
/lib/tins/attempt.rb
UTF-8
3,728
3.015625
3
[ "MIT" ]
permissive
module Tins module Attempt # Attempts code in block *attempts* times, sleeping according to *sleep* # between attempts and catching the exception(s) in *exception_class*. # # *sleep* is either a Proc returning a floating point number for duration # as seconds or a Numeric >= 0 or < 0. In the forme...
true
dc1997247b81cd95fabb053fd7ca16279da64cd9
Ruby
metaquark/eden
/test/single_character_tokenization_test.rb
UTF-8
1,946
2.65625
3
[ "MIT" ]
permissive
$: << File.dirname(__FILE__) + "/../test" require 'test_helper' class SingleCharacterTokenizationTest < Test::Unit::TestCase def setup @sf = Eden::SourceFile.new( "dummy.rb" ) end def test_single_character_tokenisation @sf.stubs(:source).returns("<>~!@% ^&*()[]{}|.: ;=? +-") @sf.tokenize! tokens...
true
88e784c9d0fbb60304a38aaeed0370280d96251f
Ruby
as6730/Data-Structures-and-Algorithms
/LRU_Cache/LRU_cache_review.rb
UTF-8
769
3.4375
3
[]
no_license
# Given a doubly linked list, like the one you built, reverse it. # You can assume that this method is monkey patching the LinkedList class # that you built, so any methods and instance variables in that class are available to you. # always think of pointers class LinkedList # ..... def reverse org_first = f...
true
cf93c197a2eb999f3cf3228fdc82b0bd12ff5a63
Ruby
GeneFunctionTeam/pooled-transposon
/scripts/inv-hiseq.rb
UTF-8
1,885
2.8125
3
[]
no_license
#!/usr/bin/ruby require 'fastqgz.rb' # Script to process and map inverse PCR products # Regexps: http://rubular.com site = "GATC" transposon = /\A\w{20,30}TCTAGGG/ sims = "TGAATTC([ATGC]{8,30}?)(TACATC|#{site})" west = "TTCGACC([ATGC]{8,30}?)(CAGTCTG|#{site})" bwa = "/apps/bwa/0.7.5a/bwa" genome = "/scratch/readonly...
true
bd8bcd491c39fe7c10d1288084a6fb96d6607b03
Ruby
faketrees/alpaca
/w3/w3d1/solutions/Jannis Harder/wordmorph.rb
UTF-8
3,891
3.078125
3
[]
no_license
#!/usr/bin/env ruby class Array def concat!(other) self.push(*other) end end module WordMorph module Helper def variation_regexp(word) out_res=[] (0...word.size).each do |index| out_res << /#{Regexp.escape(word[0,index])}.#{Regexp.escape(word[index+1..-1])}/ end Regexp.un...
true
38bd37cced585d52656d6f2efa9f8a90515c2991
Ruby
devkmsg/daemon_runner
/examples/example_semaphore.rb
UTF-8
614
2.734375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require_relative '../lib/daemon_runner' require 'dev/consul' @service = 'myservice' @lock_count = 3 @lock_time = 10 ::Dev::Consul.run ::Dev::Consul.wait # Get a new semaphore @semaphore = DaemonRunner::Semaphore.lock(@service, @lock_count) # Spawn a thread to handle renewing the lock @renew_thr...
true
fa22227033c17c9de6b0246d73968ca91dc0a045
Ruby
jakobbuis/updateinsight
/src/Analysers/Composer.rb
UTF-8
835
2.578125
3
[]
no_license
module Analysers class Composer def initialize logger @logger = logger end def analyse # Check for composer file existence if !File.exists?('composer.json') @logger.info "Project has no composer.json file, no composer analysis performed" ...
true
30bcc554ebce24ebaae9f4a0d1d5c9107cac9ce6
Ruby
devscola/RTanque
/lib/rtanque/gui/shell.rb
UTF-8
811
2.609375
3
[ "MIT" ]
permissive
require 'gosu' module RTanque module Gui class Shell attr_reader :shell DEBUG = ENV["DEBUG_SHELLS"] def initialize(window, shell) @window = window @shell = shell @x0 = shell.position.x @y0 = @window.height - shell.position.y @shell_image = Gosu::Image.n...
true
e9c68e84e9c842f22470481f090ce762bbc5b9d9
Ruby
hiby90hou/search-practice
/lib/search_cli.rb
UTF-8
7,566
3.0625
3
[ "MIT" ]
permissive
require 'json' require 'terminal-table' require 'date' require 'pry' class SearchInterface def initialize(organization_file_address, user_file_address, ticket_file_address) @organization_file_address = organization_file_address @user_file_address = user_file_address @ticket_file_address = ticket_file_add...
true
eb106b1e4a349bf46b3445ef59b3b21fcf642198
Ruby
aschak/99Cats
/app/models/cat.rb
UTF-8
406
2.59375
3
[]
no_license
class Cat < ActiveRecord::Base include CatHelper validates :birth_date, :name, presence: true validates :color, inclusion: { in: COLORS, message: "%{value} is not a valid color"}, presence: true validates :sex, inclusion: { in: %w(M F), message: "%{value} is not a valid sex"}, presenc...
true
11616c603f3dbbef3660774d715470e9f3d90dd5
Ruby
davispuh/Document-Registry
/app/helpers/documents_helper.rb
UTF-8
613
2.84375
3
[ "Unlicense" ]
permissive
module DocumentsHelper # Truncate a string so it doesn't exceed specified length and also append '...' # @param str [String] string to truncate # @param length [Fixnum] target length # @return [String] truncated string def truncate(str, length) return str if str.length <= length # Rails truncate meth...
true
2cd7502196ce291008011edaa3789c9220b0c0ca
Ruby
emiliocm9/Facebook-Bot
/bot.rb
UTF-8
1,382
2.71875
3
[]
no_license
require "selenium-webdriver" driver = Selenium::WebDriver.for :firefox url = 'https://www.facebook.com/' driver.get(url) email = 'yourname@email.com' password = 'yourpassword ' groups = ['https://www.facebook.com/groups/275366519230814', 'https://www.facebook.com/groups/rordevelopers', 'https://www.facebook.com/groups...
true
302508d0f6aa8de07b0a4959470f487ba8ba3a5f
Ruby
KitaitiMakoto/optparse-range
/lib/optparse/range.rb
UTF-8
1,468
2.6875
3
[ "BSD-2-Clause", "Ruby" ]
permissive
require 'optparse' class OptionParser class << self def accept_range(accepter, converter=nil, &block) accept accepter do |range,| return range unless range points = range.split('-') raise AmbiguousArgument if points.length > 2 points << points.first if points.length == 1 ...
true
2082945ff3db0eabce674e00fe1b408f428b249c
Ruby
thespecial/onliner
/features/pages/product_page.rb
UTF-8
1,659
2.609375
3
[]
no_license
# frozen_string_literal: true # Product view page object class ProductPage include PageObject h1(:title, Selectors::PRODUCT_PAGE[:title]) table(:specs, Selectors::PRODUCT_PAGE[:specs]) # There is suggestions section on product page - one top and others page_section( :suggestions, ProductSuggestions...
true
adf1166a29ee47275bc3feb44d9f107d2cca1de7
Ruby
papanosuke/sudoku
/sudoku3.rb
UTF-8
14,514
3.234375
3
[]
no_license
# -*- encoding: utf-8 -*- #************************************************************* #*数独問題作成 #************************************************************* require 'win32ole' #************************************************************* #*サブルーチン #************************************************************* #****...
true
b5676dbe425c286549fe047425e435bcc64fc700
Ruby
amitzman/phase-0
/week-4/errors.rb
UTF-8
7,303
4.3125
4
[ "MIT" ]
permissive
# Analyze the Errors # I worked on this challenge by myself. # I spent 1.5 hours on this challenge. # --- error ------------------------------------------------------- cartmans_phrase = "Screw you guys " + "I'm going home." # This error was analyzed in the README file. # --- error ---------------------------------...
true
91bc9a6a67f3d977195966637a967aea4afa6552
Ruby
Sid-ah/hk-bc
/roman-numerals-challenge/spec/roman_numerals_spec.rb
UTF-8
490
2.75
3
[]
no_license
require_relative '../roman_numerals' describe 'converting an Arabic number to a Roman numeral' do describe 'old Roman numerals' do it 'converts 1 to I' do expect(convert_to_roman(1)).to eq "I" end it 'converts 4 to IIII' do expect(convert_to_roman(4)).to eq "IIII" end # Release 1 .....
true
b1f98af7cc62b063e2b9f1b9741befdedb9f427d
Ruby
delta4d/youdao-dict-cli
/bin/ydict
UTF-8
792
3.28125
3
[]
no_license
#!/usr/bin/env ruby require 'dict' # Linux terminal color codes RESET = "\e[0m" BLACK = "\e[30m" RED = "\e[31m" GREEN = "\e[32m" YELLOW = "\e[33m" BLUE = "\e[34m" MAGENTA = "\e[35m" CYAN = "\e[36m" # Prompt PROMPT = ">> " # Exit codes defination EXIT = "bye" def usage puts <<-END.gsub(/^\s*\|/...
true
ef3436eb99391c6b83d93bfe54e10f6a9ca977d7
Ruby
CEsGutierrez/hotel
/lib/booker.rb
UTF-8
3,807
3.28125
3
[]
no_license
require 'date' require_relative 'room' require_relative 'reservation' require_relative 'date_mediator' require_relative 'block' require_relative 'reporter' class Booker attr_reader :HOTEL_CAPACITY attr_accessor :rooms, :reservations, :reserved_blocks HOTEL_CAPACITY = 20 def initialize @rooms = populate...
true
d2f8c3095d0ec98294f3ef07c8d3d4e42fb17b66
Ruby
seaweeddol/Ada-Jumpstart-Curriculum
/password_verification.rb
UTF-8
1,360
3.75
4
[]
no_license
password_valid = false password_error = [] # loop until password is valid until password_valid print "Enter a new password: " password = gets.chomp # check if password is valid if password.length >= 8 && password =~ /\d/ && password =~ /@|%|\*|!/ && password =~ /[a-z]/ && password =~ /[A-Z]/ print "Enter a...
true
1f72511276c251356fdcd43101b2133e3103fe20
Ruby
notmarkmiranda/robot_world
/test/models/robot_test.rb
UTF-8
953
2.96875
3
[]
no_license
require_relative '../test_helper' class RobotTest < Minitest::Test def test_assigns_attributes_correctly robot = Robot.new({ :name => "John", :city => "Denver", :state => "CO", :avatar => "http://www.robohash.org/John", ...
true
1674fec77d1cef26dddba23dacc32eecdeabdaf0
Ruby
wenbo/rubyg
/sample/CHAPTER06/120/nitems.19.rb
UTF-8
188
3.125
3
[]
no_license
RUBY_VERSION # => "1.9.1" ary = [1,2,false,nil,3] ary.length # => 5 ary.nitems # => # ~> -:4:in `<main>': undefined method `nitems' for [1, 2, false, nil, 3]:Array (NoMethodError)
true
cdc4c73f764ee93d097b81715f05614d5f1d0941
Ruby
richa-prof/sharetribe
/spec/models/numeric_field_value_spec.rb
UTF-8
3,616
2.515625
3
[]
no_license
# == Schema Information # # Table name: custom_field_values # # id :integer not null, primary key # custom_field_id :integer # listing_id :integer # text_value :text(65535) # numeric_value :float(24) # date_value :datetime # created_at :datetime # updated_at :dat...
true
49fd9350227dc355303697fc494bc989a3da31f7
Ruby
romaindeveaud/index-app
/indexing/Listener.rb
UTF-8
3,648
2.640625
3
[]
no_license
require 'rexml/document' require 'rexml/streamlistener' include REXML class Listener include StreamListener def initialize(dico, post_file, stoplist, listing) @current_file = nil @name = nil @isName = nil @dico_indice = 0 @offset = Array.new ...
true
80dff008aab5632cb8e37b2a9d21485a73c892f3
Ruby
chen-factual/scripts
/resolve/parameter-sweeps/parse-results.rb
UTF-8
1,722
3.203125
3
[]
no_license
require 'json' B0 = "b0" B1 = "b1" OVERALL = "overall" SUMMARY_SCORE = "summary_score" INPUT_OVERFOLD = "input-overfold-rate" INPUT_REPULSION = "input-repulsion-score" INPUT_COHESIVENESS = "input-cohesiveness-score" SUMMARY_DUPE = "summary-dupe-rate" SUMMARY_OVERFOLD = "summary-overfold-rate" def attach_score(score) ...
true
51813c0717dfe20848e8c39f14105e8afa73b305
Ruby
annakiuber/minedmindskata
/reverse_array_3and_5.rb
UTF-8
255
3.5
4
[]
no_license
def reverseminedmindskata() array = (1..100).to_a array.map! do |num| if num % 15 == 0 num ="mined minds" elsif num % 3 == 0 num = "mined" elsif num % 5 == 0 num = "minds" else num end end array end # puts reverseminedmindskata
true
e15d2ce1b46f7e04d77455a476b5c084766efceb
Ruby
okhlybov/iop
/lib/iop/string.rb
UTF-8
2,129
3.453125
3
[]
no_license
require 'iop' module IOP # # Feed class to send arbitrary string in blocks of specified size. # # ### Use case: split the string into 3-byte blocks and reconstruct it. # # require 'iop/string' # ( IOP::StringSplitter.new('Hello IOP', 3) | IOP::StringMerger.new ).process! # # ...
true
7d0071175dadbbc7558e5926d086ec7f06dad075
Ruby
CaileeHarrington/learn-co-sandbox
/challenge2.rb
UTF-8
325
3.953125
4
[]
no_license
# Monday Morning Challenge Question WARM UP:car::blue_car::racing_car: #Start Here class Vehicle def initialize(color, type) @color = color @type = type end def color @color end def color=(color) @color = color end end car1 = Vehicle.new ("blue","racing") puts "Hey, I'm a #{color} #{type} car. H...
true
b65060c95216263083dc52e637c512397dcbb97f
Ruby
benhamilton15/Karaoke_Classes_weekend_hw_w2
/guests.rb
UTF-8
515
3.125
3
[]
no_license
class Guests attr_reader :name, :wallet, :fav_song def initialize(name, wallet, fav_song) @name = name @wallet = wallet @fav_song = fav_song end def pay_fee(fee) if can_afford(fee) @wallet -= fee end end def can_afford(fee) return @wallet >= fee end def fav_song_playin...
true
3532f72e793dbdc5a433ca2ceb098414c17c7751
Ruby
misslesliehsu/week-1-group-review-web-112017
/review-question-3.rb
UTF-8
995
3.703125
4
[]
no_license
# begin to build a simple program that models Instagram # you should have a User class, a Photo class and a comment class # OUR RESPONSES class User attr_accessor :name, :photos def initialize(name) @name = name @photos = [] end end class Photo attr_reader :user, :comments def initialize @com...
true
e2b0c0acaeca851e228bb0c57d22bd45597395d7
Ruby
letheyue/IUI-project
/yulp_app/app/models/restaurant.rb
UTF-8
6,466
2.84375
3
[]
no_license
require 'yelp_client.rb' require 'crawler_client.rb' require 'category.rb' class Restaurant < ActiveRecord::Base has_many :reviews has_many :users, through: :reviews has_and_belongs_to_many :categories self.table_name = "restaurants" def trim_to_empty(str) if str.nil? return '' end str ...
true
21d8b1e2d03be1298f15bae20a91245d4dbf9772
Ruby
rgagnon/server_side_google_maps_api
/spec/lib/base_service_provider_spec.rb
UTF-8
1,138
2.515625
3
[ "MIT" ]
permissive
require "#{File.dirname(__FILE__)}/../spec_helper" require 'server_side_google_maps_api/apis/base' describe ServerSideGoogleMapsApi::Api::Base do let(:base) { ServerSideGoogleMapsApi::Api::Base.new } it "should be a base object" do base.should be_a ServerSideGoogleMapsApi::Api::Base end describe "Buildi...
true
0eff704e8cf9437854a4e029697c1efd8cce52fd
Ruby
kbaba1001/flying_money
/app/models/expense_item.rb
UTF-8
933
2.515625
3
[]
no_license
class ExpenseItem < ActiveRecord::Base belongs_to :user has_many :outlays, dependent: :destroy validates :name, presence: true, uniqueness: {scope: :user_id} validates :display_order, presence: true, numericality: {only_integer: true, greater_than: 0} validates :user_id, presence: true before_validation :...
true
e1f0bf3ae550532549a1a79fe52559383fb3038c
Ruby
cacdesign/thp_ruby
/pyramide.rb
UTF-8
129
3.203125
3
[]
no_license
puts "Donne moi un nombre :) hihi" nombre = gets.chomp.to_i nombre.times do |i| puts " " * (nombre - (i+1)) + "#" * (i+1) end
true
ec7c3eaa4b662bae96e10da854b74f22552367b8
Ruby
smdecker/ruby-collaborating-objects-lab-v-000
/lib/mp3_importer.rb
UTF-8
494
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class MP3Importer attr_accessor :path def initialize(path) @path = "./spec/fixtures/mp3s" end def files #loads all the mp3 files in the path directory Dir.glob("./spec/fixtures/mp3s/*.mp3") #normalizes the filename to just the mp3 filename with no path Dir.entries("./spec/fixtures/mp3s...
true
eac80ae99b5716ed06d3b5458e2e8bdb74543e14
Ruby
carolemny/TheHackingProject-the_gossip_project
/db/seeds.rb
UTF-8
1,698
2.515625
3
[]
no_license
require 'pry' #Variables pour les tests NB_CITIES = 20 NB_USERS = 100 NB_PRIVATE_MESSAGES = 500 NB_GOSSIPS = 200 NB_TAGS = 50 gossip_ary = Array.new tag_ary = Array.new cities = [] users = [] pms= [] #Cities NB_CITIES.times do cities << City.new(name: Faker::Address.city, zip_code: Faker::Number.leading_zero_number...
true
47b826742818ac982310fe6ab379a5ec5002a5a7
Ruby
CalumCannon/multiple-classes-ruby
/specs/bear_spec.rb
UTF-8
438
2.78125
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../bear.rb') require_relative('../river.rb') class TestBear < MiniTest::Test def setup @bear = Bear.new("James", "Brown") @river = River.new("Clyde") end def test_take_fish() @bear.take_fish(@river) assert_equal(1,@bear.stomach....
true
7b49868233d3b7eaea3ebff156200c73efdc796f
Ruby
alexglach/project_tdd_minesweeper
/spec/cell_spec.rb
UTF-8
480
2.6875
3
[]
no_license
require 'cell' describe Cell do describe "#initialize" do let(:c) { Cell.new(3, 2) } it "should initialize with a row_index" do expect(c.row_index).to eq(3) end it "should initialize with a column_index" do expect(c.column_index).to eq(2) end it "starts with no cont...
true
82426527fbb12c2697326687daf63ffbde900718
Ruby
halogenandtoast/reconstructing_ruby
/code/chapter_2-parsing/test.rb
UTF-8
154
3.578125
4
[]
no_license
class Greeter def initialize(name) @name = name end def greet puts "Hello #{@name}" end end greeter = Greeter.new("Ruby") greeter.greet
true
7a62784722783b76a8b66b100701c6d99242837a
Ruby
briceth/diamond
/db/seeds.rb
UTF-8
962
2.59375
3
[]
no_license
Proposal.delete_all User.delete_all Activity.delete_all password = "passwordpassword" 20.times do user = User.new user.email = Faker::Internet.email user.password = password user.first_name = Faker::Name.first_name user.last_name = Faker::Name.last_name user.avatar = Faker::Avatar.image("my-own-slug", "50...
true