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
a385801d2f025fc33b23633b49f389b94d67c661
Ruby
VinutaChetan/VinolyaAccounts
/base.rb
UTF-8
176
3.171875
3
[]
no_license
# class Base # def self.find_by_name(name) # self.find_all{|obj| obj.name == name} # end # def self.less_than_50 # self.find_all{|obj| obj.price < 50 } # end # end
true
5b9a37176cb57f071b0fdb20afed8c4d718ea19e
Ruby
efueger/alonetone
/app/models/asset/uploading.rb
UTF-8
1,933
2.71875
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
require 'zip' class Asset include Paperclip # see config/initializers/paperclip for defaults attachment_options = { styles: { original: '' }, # just makes sure original runs through the processor processors: [:mp3_paperclip_processor] } if Alonetone.storage == 's3' attachment_options[:path] = "/m...
true
299dd5ce7d09d51febcc2a7ee7f9a6582da2f7a5
Ruby
mhmoudgmal/tic_tac_toe
/app/services/tic_tac_toe/tic_tac_toe_service.rb
UTF-8
283
2.6875
3
[]
no_license
require 'tic_tac_toe' module TicTacToe class TicTacToeService attr_reader :inviter def initialize player @inviter = player end def play TicTacToe::GameBoard.new do |game_board| game_board.players[0].name = inviter end end end end
true
2c8a709b72f9e544059cde8d7ea3fbe9cbfd69d3
Ruby
smartlyio/heaven
/spec/lib/heaven/comparison/linked_spec.rb
UTF-8
1,757
2.578125
3
[ "MIT" ]
permissive
require "spec_helper" require "heaven/comparison/linked" require "support/helpers/comparison_helper" describe "Heaven::Comparison::Linked" do include ComparisonHelper let(:comparison) do { :html_url => "https://github.com/org/repo/compare/sha...sha", :total_commits => 1, :commits => [ ...
true
5a9fdb43b6565604895c1fa07018a82414b0edc4
Ruby
wenlilearn/leetcode
/strStr/main.rb
UTF-8
754
3.890625
4
[]
no_license
=begin Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. =end module Main # @param {String} haystack # @param {String} needle # @return {Integer} def str_str(haystack, needle) if haystack.empty? && !(needle.empty?) return -1...
true
001a97baabf241666cb9b6428395d52b12b05b63
Ruby
mob1970/RailscastsDownloader
/RailscastsDownloader.rb
UTF-8
3,908
2.78125
3
[]
no_license
########################################################################### # # RailscastsDownloader 2.0 # # Copyright (C) 2009 Miquel Oliete <ktalanet@gmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free So...
true
c87dbb79a286224e60f925dba1d71c20dfe29955
Ruby
matt5342/Leetcode
/add-strings/add-strings.rb
UTF-8
593
3.5
4
[]
no_license
# @param {String} num1 # @param {String} num2 # @return {String} def add_strings(num1, num2) result = 0 num1.reverse.each_char.with_index do |c, i| if i > 0 j = 10 if i == 1 j = 10 ** i if i > 1 result += (c.ord - 48) * j else result += c.ord - 48...
true
e97cddac186b2636c9daf6d128a7eee1c690dece
Ruby
zeekerpro/programming-note
/ruby/meta_program/code_hub/act_as_field.rb
UTF-8
1,113
3.015625
3
[]
no_license
module ActAsField def self.included base base.extend ClassMethods base.include InstanceMethods base.class_eval do @fields = [] end end module ClassMethods def field method_name, path method_sym = method_name.to_sym @fields << method_sym define_method method_sym do ...
true
103c87108b91cd49053453cc04794e1e3282a25a
Ruby
aeroyu/simple_cacheable
/spec/cacheable/model_fetch_spec.rb
UTF-8
2,982
2.546875
3
[ "MIT" ]
permissive
require 'spec_helper' describe Cacheable do let(:cache) { Rails.cache } before :all do @user = User.create(:login => 'flyerhzm') @post1 = @user.posts.create(:title => 'post1') @post2 = @user.posts.create(:title => 'post2') end describe "singleton fetch" do it "should find an object by id...
true
3c23cc6681f2dd43092fb1a9f110acb6489708df
Ruby
chad/jazztoolbox
/app/models/scale_tone.rb
UTF-8
538
2.625
3
[]
no_license
# Represents one tone in a scale. # # == Attributes # # * +tone+ - A tone index from 0-11 representing the relative position of the # tone within the chromatic scale. # # * +letter_index+ - A 0-6 value representing the relative letter position, which # helps to disambiguate theoretic values such as Eb and ...
true
635f0f2fb3a9656135587e88001390dbbea8e7cb
Ruby
conao3/dev
/c/aizu/ruby/intro/itp1_3_d.rb
UTF-8
111
3.09375
3
[ "MIT" ]
permissive
a, b, c = gets.split.map(&:to_i) count = 0 for i in a .. b if c % i == 0 count += 1 end end puts count
true
9e847c6217ecf75a284e65a9d50ab1b6b729a740
Ruby
bobylegros/Day12EnvoieMailsRaf
/scrap_mairies.rb
UTF-8
1,431
3
3
[]
no_license
require_relative "log" require_relative "scrapper_for_dummies" def get_emails_from_all_towns_in_dpt(url_path) infos = Hash.new url = $base_url + url_path towns = scrapper_for_dummies(url, "a.lientxt") # towns.each do |town| towns[0..10].each do |town| #XXX: pour éviter d'être "noyer" par l'...
true
5b87a40cb76b50a00feaa4f0c3d94ae0ea452599
Ruby
itmightgetloud/learn_ruby
/05_silly_blocks/silly_blocks.rb
UTF-8
136
3.203125
3
[]
no_license
def reverser yield.split().map{ |i| i.reverse }.join(" ") end def adder(a=1) yield + a end def repeater(a=1) a.times {yield} end
true
b4a21df0482aec8331983bdf32c068aa65c6703d
Ruby
nhance/racecar-control
/lib/scoreboard_message.rb
UTF-8
2,224
3.109375
3
[ "MIT" ]
permissive
class ScoreboardMessage @@registry = {} MESSAGE_COMMANDS = { '$A' => "ScoreboardMessage::A", '$B' => "ScoreboardMessage::B", '$COMP' => "ScoreboardMessage::Comp", '$C' => "ScoreboardMessage::C", '$E' => "ScoreboardMessage::E", '$F' => "ScoreboardMessage::F", '$G' => "ScoreboardMessage::...
true
123b48c4bc2f893de585e36847f10286a3ff45d3
Ruby
johanlindblad/synacor-challenge
/tools/find_r7.rb
UTF-8
159
2.53125
3
[]
no_license
0.upto(32767).each do |n| val = `cd ..;echo "memory #{n}\nexit\n"|./debug`.split("\n").first.to_i puts "not #{n}" if n%1000 == 0 puts n if val == 32775 end
true
76e80f5d7a1e91b89f267e7965cc36fb5d4c61be
Ruby
mindaslab/ilrx
/date_time_server.rb
UTF-8
223
2.578125
3
[]
no_license
# date_time_server.rb require "socket" dts = TCPServer.new('localhost', 3000) loop do Thread.start(dts.accept) do |s| print(s, " is accepted\n") s.write(Time.now) print(s, " is gone\n") s.close end end
true
be22526213b614c8ab455f41bae7c1361edec770
Ruby
LouisaBarrett/runline-2
/app/models/formatter.rb
UTF-8
606
3.390625
3
[]
no_license
class Formatter def format_for_seconds(seconds) hours = (seconds/3600).to_i minutes = ((seconds/60) - (hours * 60)).to_i seconds_remaining = (seconds - (minutes * 60 + hours * 3600)) if hours >= 1 "%01d:%02d:%02d" % [hours, minutes, seconds_remaining] elsif minutes == 0 "%02d:%02d" % ...
true
d5a29d85b5ca8b912c29a7b6c6c3522cbdcec963
Ruby
danielnottingham/brasil_systems
/task1_characters.rb
UTF-8
263
4.34375
4
[]
no_license
# Tarefa - 1: Crie um algoritmo que receba o nome como entrada e nós dê como saída o nome # digitado e o comprimento do mesmo. puts 'Digite um nome: ' name = gets.chomp newName = name.strip result = "#{newName} #{newName.chars.count} caractares" puts result
true
8d5ef2d947e9797549b1c139b14a947e47be9aa1
Ruby
propublica/table-fu
/spec/table_fu_spec.rb
UTF-8
8,711
2.6875
3
[ "MIT" ]
permissive
require 'spec' require 'spec_helper' describe TableFu do before :all do csv = FasterCSV.parse(File.open('spec/assets/test.csv')) @spreadsheet = TableFu.new(csv, :style => {'URL' => 'text-align: left;'}) end it 'should give me back a Row object' do @spreadsheet.rows.each do |r| r.class.should...
true
30b2868ffe8de7365b1c02da16fa6661c8869da0
Ruby
innervisions/object-oriented-programming
/01_oo_basics_1/01.rb
UTF-8
75
3.0625
3
[]
no_license
# 01 - Find the Class puts "Hello".class puts 5.class puts [1, 2, 3].class
true
06e0ad374445ddd5ca33eaa7d8676005893f3bd7
Ruby
hungpk205/ruby_newbe
/define_method.rb
UTF-8
355
3.28125
3
[]
no_license
class A define_method(:wilma) {puts "Touch me!!!"} end class B < A define_method(:barey) {puts "Call me!!!"} end b = B.new b.barey b.wilma class Caller def method_missing(m, *args, &block) puts "Caller #{m} with #{args.inspect} and #{block}" end end # Caller.new.anything Caller.new.anything(3,4) str = "He...
true
8b9f88b499b66b708b81166ca017c031e48c609d
Ruby
adomokos/mocks_vs_stubs
/order/spec/order_rspec_stub_long_spec.rb
UTF-8
730
2.53125
3
[]
no_license
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'order' describe Order do before(:each) do @warehouse = stub('warehouse_stub') end it "fills the order with enough items in warehouse" do @warehouse.stub!(:quantity_at).and_return(50) @warehouse.stub!(:set_quantity_at).and_...
true
7e2e038faa4c9e00086fc1f98aedc84c009334df
Ruby
kashio-tech/kadai
/ruby/lesson7.rb
UTF-8
588
4
4
[]
no_license
### 確認問題1 # puts "計算をはじめます" # puts "2つの値を入力してください" # a = gets.to_i # b = gets.to_i # puts "計算結果を出力します" # puts "a*b=#{a*b}" # puts "計算を終了します" ### 確認問題2 puts "計算をはじめます" puts "何回繰り返しますか?" aa = gets.to_i for i in 1..aa do puts i.to_s + "回目の計算" puts "2つの値を入力してください" a = gets.to_i b = gets.to_i puts "a+b=#{...
true
e59ffb449502882de72f1c7750a86f88fc44d339
Ruby
gcongreve/CodeClanCinema
/console.rb
UTF-8
1,507
2.828125
3
[]
no_license
require_relative('models/customer') require_relative('models/film') require_relative('models/ticket') require_relative('models/screening') require('pry-byebug') Ticket.delete_all Customer.delete_all Film.delete_all customer1 = Customer.new({'name' => 'Customer One', 'funds' => 50}) customer1.save customer2 = Custom...
true
45a2a3ae840b34f893c7863f307a31b176df9624
Ruby
myokoym/rhythmmml
/lib/rhythmmml/object/rhythm.rb
UTF-8
586
2.828125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "rhythmmml/object/base" module Rhythmmml module Object class Rhythm include Base attr_reader :info def initialize(window, x, y, info, options={}) super(window, x, y, options) @info = info @width2 = @window.width * 0.1 / 2 @height2 = @window.height * 0.02...
true
cb87d8320793dd9edd963fb0eef1363b47bf5933
Ruby
codyss/emoticon-translator-001
/lib/prime_test.rb
UTF-8
224
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime(num) if num == 2 || num == 3 return true else t = 2 while t <= num / 2 if num % t == 0 return false break else t += 1 end end return true end end
true
57909b86b553a034502cf36dff5c71e2d0587a19
Ruby
edgarduran/snow-dashboard
/app/services/geocoding_service.rb
UTF-8
746
2.65625
3
[]
no_license
class GeocodingService attr_reader :connection def initialize @connection = Faraday.new(:url => 'https://maps.googleapis.com/maps/api/geocode/') do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :logger # log requests to STDOUT ...
true
f1732966070b11fb0394b09a13fdcaf7edf40c12
Ruby
fiteclub/2020_advent
/spec/day_05_spec.rb
UTF-8
1,970
3.1875
3
[]
no_license
require_relative '../day_05/boarding_00' require_relative '../helpers' testdata = BoardingPassList.new(get_data('day_05/test_input.txt', type = 'array')) testempty = BoardingPassList.new(int_to_boarding_code([101, 102, 104, 107, 108])) RSpec.describe 'BoardingPass class' do it 'converts to binary' do expect(tes...
true
255c3bdb433d19c7ca561e6f282bb31c2f11bc23
Ruby
boudejo/lookatrails
/vendor/plugins/thinkweb/lib/thinkweb/validations.rb
UTF-8
1,202
2.59375
3
[ "MIT" ]
permissive
module TW::Validations def validate_date_before(comp_date) puts 'validate before' # end def validate_date_after(comp_date) puts 'validate after' end def validate_period(start_date, end_date, *args) options = args.extract_options! allow_equal = options.delete(:allow_equal) || false...
true
24f0eeeebbd3ad0bd0e80a06b8d9f5e1fd65b034
Ruby
jnicklas/uploadcolumn
/spec/custom_matchers.rb
UTF-8
3,954
2.984375
3
[ "MIT" ]
permissive
class BeIdenticalWith def initialize(expected) @expected = expected end def matches?(actual) @actual = actual FileUtils.identical?(@actual, @expected) end def failure_message "expected #{@actual.inspect} to be identical with #{@expected.inspect}" end def negative_failure_message "expec...
true
83d43430c068be9d24b430442aadf3ddea56cb1c
Ruby
beachio/hammer-gem
/lib/hammer/parsers/sass.rb
UTF-8
5,945
2.578125
3
[ "MIT" ]
permissive
require 'hammer/parser' require 'hammer/parsers/css' require 'bourbon' require 'fileutils' module Hammer class SASSParser < CSSParser accepts :sass, :scss returns :css def format @path.split('.')[-1].to_sym end def to_format(new_format) if new_format == :css parse(@original...
true
f82cbeeb7805bead2416c48d7587bbe37e80fd12
Ruby
m-negishi/ruby_training
/TeachYourselfRuby/section4/4_check.1.rb
UTF-8
903
4.03125
4
[]
no_license
# 標準入力を行う場合は下記 # puts '1つ目の整数を入力' # a = gets # until a.integer? do # puts '整数を入力してください' # a = gets # end # # puts '演算子を入力' # operator = gets.to_s # # puts '2つ目の整数を入力' # b = gets # until b.integer? do # puts '整数を入力してください' # b = gets # end # # puts "入力した式:#{a} #{operator} #{b}" # str = '2 たす 2' # str = '2 ひく 2' ...
true
8044217844350e6193c65b9c57cecd30d3953034
Ruby
daimyo-college/ruby-super-intro-lesson
/aoronesy/chapter7/7-3.rb
UTF-8
55
2.796875
3
[]
no_license
def dice d = [1,2,3,4,5,6] d.sample end puts dice
true
0784c3bff63a3823ba9e7090c27d7b614f5b8163
Ruby
tasosh/pine
/chapter122.rb
UTF-8
61
2.5625
3
[]
no_license
time = Time.new time2 = Time.new + 60 puts time puts time2
true
e932b3146a0f59c33285897c8b081ccba017a463
Ruby
rafidude/RubyDesignPatterns
/proxy.rb
UTF-8
1,176
3.71875
4
[]
no_license
class BankAccount attr_reader :balance def initialize(starting_balance = 0) @balance = starting_balance end def deposit(amount) @balance += amount end def withdraw(amount) @balance -= amount end end class VirtualAccountProxy def initialize(starting_balance=0) @starting_balance = starting...
true
eb26b46ebad49c1976ad5a7e8947a3e700aca196
Ruby
yangzhsh1173/algorithm009-class02
/Week_06/count_substrings.rb
UTF-8
613
3.640625
4
[]
no_license
# 回文子串 https://leetcode-cn.com/problems/palindromic-substrings/ # @param {String} s # @return {Integer} def count_substrings(s) return 0 if s.size < 1 start_at = 0 end_at = 0 count = 0 for i in 0...s.size len1 = expand_from_middle(i, i, s) len2 = expand_from_middle(i, i+1, s) ...
true
f222f6770cc03ed1f23296904bb372e46ae96a5e
Ruby
yetka/scrabble_score
/spec/scrabble_score_spec.rb
UTF-8
463
2.765625
3
[]
no_license
require('rspec') require('scrabble_score') require('pry') describe('scrabble_score') do it("returns a scrabble score for a letter") do expect("a".scrabble_score()).to(eq(1)) end it("returns a scrabble score for a word with two letters") do expect("at".scrabble_score()).to(eq(2)) end it("returns a scr...
true
2ba51bf6b2e35bbc19da28382f5f9b4f22b9f66c
Ruby
rsgrafx/toy-gen-tcp
/base_game.rb
UTF-8
503
2.984375
3
[]
no_license
module Base; end class Base::Game attr_accessor :client, :data, :current_question, :data, :current_game, :inputs def initialize @data ||= {} @inputs ||= "" end def speak(text) @current_question = text system("say", @current_question) client.write("⭐ " << @current_question << "\n") end ...
true
42452382848cd1befe615916b85830b88a2d151d
Ruby
Eden-Eltume/101
/101_Exercises/Small_Problems3/5_Easy5/ex9.rb
UTF-8
1,079
3.953125
4
[]
no_license
=begin Problem - return a string that contains the value of the original string with all consecutive duplicate characters reduced into a single one Example -crunch('ddaaiillyy ddoouubbllee') == 'daily double' Data structure - take string as argument - return none redundant string Algo - - loop through ...
true
72b0ee5c508248747cabda23b179b4447c42b74d
Ruby
alexg622/phase-0-tracks
/ruby/practice.rb
UTF-8
950
4.125
4
[]
no_license
def crypto(nite) index = 0 until index == nite.length if nite[index] == "z" nite[index] = "a" elsif nite[index] == " " else nite[index] = nite[index].next! end index += 1 end puts "#{nite}" end def batman(robin) index = 0 abc = "abcdefghijklmnopqrstuvwxyz" until index == robin.length if robin[index] ==...
true
ef20c301258fdcb164239f2828ce26deab39c2ff
Ruby
joedaniels29/IntelliJIdea2016.2
/rubystubs/ruby18/debugger/1.6.6/debugger.rb
UTF-8
17,825
2.75
3
[]
no_license
=begin This is a machine generated stub using stdlib-doc for <b>module Debugger</b> Sources used: gem debugger, v. 1.6.6 Created on 2014-04-10 18:47:58 -0400 by IntelliJ Ruby Stubs Generator. =end # == Summary # # This is a singleton class allows controlling the debugger. Use it to start/stop debugger, # set/remo...
true
8087a445ee91589176c1835fb8d9a9351c47ea64
Ruby
danielyanez92/desafio-methods
/desafiomethods.rb
UTF-8
1,545
4.09375
4
[]
no_license
#ejercicio1 puts 'ejercicio 1' def par(x) x.even? end puts par(2) puts par(3) puts par(4) puts par(5) #ejercicio2 puts 'ejercicio 2' def random result = [true, false].sample end puts random ? 'si':'no' #ejercicio3 puts 'ejercicio 3' def check5(n) n > 5 ? 'true' : 'false' end puts check5(5) # Debería ser false put...
true
30223276ec73281477b733c082e11c59fe248e6f
Ruby
uche-inyama/leet-code
/reverse_vowel.rb
UTF-8
685
4.5
4
[]
no_license
# if s is empty return s # I will use a set define my vowel # declare an empty an array to hold the vowel in given string # declare an empty string # my first loop will extract the vowels in the given and pass it into an array # in my second loop, I will create a new string require 'set' def reverse_vowel(s) retur...
true
9c62ae88c4930891e845274486828ab83e6f9c75
Ruby
jedwin1891/TheClashApp
/lib/ClashApp/menu.rb
UTF-8
2,321
2.953125
3
[ "MIT" ]
permissive
class Menu system ("clear") def start Api.get_albums Api.get_bio Api.get_top Menu.main_menu end def self.main_menu system ("clear") space puts " ╔═╗┬ ┌─┐┌─┐┬ ┬...
true
460146fd8bcb9f9d416153bba24ce39faf5f9143
Ruby
ArmideonOkawa/programming-univbasics-nds-nds-to-insight-understand-lab-dumbo-web-111819
/lib/nds_explore.rb
UTF-8
389
2.796875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'directors_database' # Call the method directors_database to retrieve the NDS def pretty_print_nds(nds) pp nds end def print_first_directors_movie_titles dir_films = directors_database[0][:movies] index = 0 while index < dir_films.length do titles = ...
true
7f6040d4c4f6d68ab59c0e1e74b16f26e30067a0
Ruby
o3o3o/execise
/ruby/code/one.rb
UTF-8
188
3
3
[]
no_license
movie={ :a=>1975, :b=>2004, :c=>2013 } #puts(movie[:a], movie[:b], movie[:c]) dates=[1975, 2004, 2013] puts(dates[0], dates[1], dates[2]) 5.times do |i| print i, " " end
true
68e21460bddc11df072c7f9acb7568cccc8385c3
Ruby
reillywj/code_eval_challenges
/hard/robot_movements/robot_movements.rb
UTF-8
1,508
3.65625
4
[]
no_license
class RobotMovements def initialize(rows, columns) @pathways = [] end end class Path attr_reader :rows, :columns, :steps def initialize(rows, columns, steps = [0, 0]) @steps = [steps] @rows = rows @columns = columns end def next_paths paths = [] possible_moves.each do |move...
true
d1002ee63d5e2cb51c66374928a0edee70bf5e2d
Ruby
RudiBoshoff/ruby-exercises
/bubble_sort/bubble_sort.rb
UTF-8
1,826
4.375
4
[]
no_license
=begin The most straightforward logic would be this: for i in 0..size-2 for j in 1..size-1 if array[i] < array[j] swap values I have however done this a different way that is less optimized but gets The job done as more of a fun challenge rather than opti...
true
1f5520529b284bee39088a5105e5b08a009d17eb
Ruby
georgehwho/sweater_weather
/spec/facades/weather_facade_spec.rb
UTF-8
2,115
2.625
3
[]
no_license
require 'rails_helper' describe WeatherFacade, :vcr do describe 'class methods' do context '.get_forecast' do it 'happy path: returns current weather, daily weather, and hourly weather' do forecast = WeatherFacade.get_forecast('denver,co') expect(forecast.id).to eq(nil) expect(for...
true
71149a6d17d5504852d1f9188e5288b90e73e1ec
Ruby
BradleyJrichardson/codewars-solutions-ruby
/25_kata_6kyu.rb
UTF-8
887
4.28125
4
[]
no_license
# Write a function that when given a number >= 0, returns an Array of ascending length subarrays. # pyramid(0) => [ ] # pyramid(1) => [ [1] ] # pyramid(2) => [ [1], [1, 1] ] # pyramid(3) => [ [1], [1, 1], [1, 1, 1] ] # Note: the subarrays should be filled with 1s def pyramid(numbers) array_of_arrays = [] ...
true
e81141bd81c608d502be7e17f6090d3987409434
Ruby
NotJamesM/ruby_visual_sorter
/sorting.rb
UTF-8
680
3.59375
4
[]
no_license
class Sorter attr_accessor :data def initialize() @data = generateRandomData end def show_data @data.each_with_index do |val, index| puts "Index:#{index}\t\tValue: #{val}" end end #Implementation of a bubblesort algorithm def bubbleSort @data.each do |i| @data.each_with_ind...
true
7a2a9f8723d0f905c85317346a6a77bf2faa3c9e
Ruby
zeroeth/orbits
/angle.rb
UTF-8
342
2.6875
3
[]
no_license
require 'base_class' class Angle < BaseClass attribute :angle, 0 attribute :rpm, 10 attribute :steps, :smooth attribute :type, :absolute def initialize(options = {}) write_attribute :defaults, {:angle=>0, :rpm=>1, :steps=>:smooth, :type=>:absolute} super options end def update self.angle = ...
true
418faf2b33aefe58275e181482b0892aa799666c
Ruby
samanthagongora/homework
/pseudocode.rb
UTF-8
1,567
3.78125
4
[]
no_license
Samantha Gongora May 2, 2017 =begin tying your shoes 1. Place your shoe so that the toe faces away from you 2. Take the right shoelace in your right hand 3. Take your left shoelace in your left hand 4. Cross your right lace in front of your left to make an x 5. Wrap your right lace around your left once 6. Pull both l...
true
07f92d459e0bcd7ea5f8b93d19af9bfa4a0377dd
Ruby
StevenXL/learntoprogram
/chapter_10_recursion/shuffle.rb
UTF-8
1,099
4.59375
5
[]
no_license
# the point of this exercise is to create a method that takes an array and # returns the items in the array in in a completely random way # # for this program, I am going to be using the rand function, which returns an # integer greater than or equal to 0 but less than the number passed. # # I'm also going to use the...
true
b2a4a867ecf0c06e9b2da33be8d6c9da07034766
Ruby
arnaldoaparicio/black_thursday
/lib/transaction_repository.rb
UTF-8
1,516
2.859375
3
[]
no_license
class TransactionRepository attr_reader :all def initialize(transaction_path) @all = ( transaction_objects = [] CSV.foreach(transaction_path, headers: true, header_converters: :symbol) do |row| transaction_objects << Transaction.new(row) end transaction_objects) end def ins...
true
3dcaa5d8496e0c41297b2cc159ae711f3b008777
Ruby
jmschles/advent-of-code
/day6/fire_hazard.rb
UTF-8
1,254
3.296875
3
[]
no_license
class LightField attr_reader :grid def initialize @grid = Array.new(1000) { Array.new([0] * 1000) } end def turnon(start_pos, end_pos) (start_pos[0]..end_pos[0]).each do |row| (start_pos[1]..end_pos[1]).each do |col| @grid[row][col] += 1 end end end def turnoff(start_pos, ...
true
ed789f30d5b6d4c78b7311f5b4231682aeba0059
Ruby
gruis/starbot
/lib/starbot/contact.rb
UTF-8
690
2.875
3
[ "MIT" ]
permissive
class Starbot class Contact attr_accessor :id, :alias, :status, :online # [nil, String, Object] room - in some IM systems some contacts are not directly addressable # outside of a room. A bot that rides on a transport for such a system should set the room # attribute of any contact that cann...
true
373ec54767cabf126a8faa0eb3b985e3a206eedf
Ruby
csharpd/myinject
/spec/myinject_spec.rb
UTF-8
1,282
3.28125
3
[]
no_license
require 'myinject' describe 'Myinject' do let (:myarray) {[1,2,3,4]} let (:big_array) {[100,3,2]} it 'raises an error if no block given' do expect{myarray.myinject}.to raise_error(LocalJumpError) end it 'returns nil if an empty array is given' do empty = [] expect(empty.myinject {|acc,num| a...
true
3eafa4e80689a74d7941d10c28b5e6573af22e60
Ruby
kostya/pgq_web
/test/dummy/app/models/pgq/pgq_issues.rb
UTF-8
213
2.703125
3
[ "MIT" ]
permissive
class PgqIssues < Consumer2 # to insert event: PgqIssue.my_event(1, 2, 3) # async execute def my_event(a, b, c) sleep 0.2 logger.info "async call my_event with #{[a, b, c].inspect}" end end
true
fa4790d70550f4d7a0ffe63b95b9d0c0de8649d0
Ruby
nskillen/aoc2018
/d19.rb
UTF-8
1,666
3.40625
3
[]
no_license
require_relative 'day' require 'io/console' class D19 < Day OPCODES = { addr: -> regs, a, b, c { regs[c] = regs[a] + regs[b] }, addi: -> regs, a, b, c { regs[c] = regs[a] + b }, mulr: -> regs, a, b, c { regs[c] = regs[a] * regs[b]}, muli: -> regs, a, b, c { regs[c] = regs[a] * b }, banr: -> regs, a, b, c ...
true
349e4868f195bf46c445b689660cb8f1b0247ae6
Ruby
leekarho/borisbikes
/lib/docking_station.rb
UTF-8
454
2.96875
3
[]
no_license
class DockingStation attr_reader :bikes def initialize @bikes = [] @max = 20 end def release_bike fail 'No bikes available' if @bikes.empty? @bikes.last end def dock(my_bike) fail 'No space available' if @bikes.length == @max @bikes << my_bike @bikes.last end # def full ...
true
d26fb45a963e3f1c6a0db8147d240bfd778a362b
Ruby
ignaciorivas1401/desafio-HerenciayUML
/herencia.rb
UTF-8
2,024
3.5
4
[]
no_license
class Appointment attr_accessor :location, :purpose, :hour, :min def initialize(location,purpose,hour,min) @location = location @purpose = purpose @hour = hour @min = min end def location @location end def purpose @purpose end def...
true
f692be8de91914b21bae1c474d6571a9a078ad34
Ruby
moviepilot-de/omdb
/app/models/log/cast_log_entry.rb
UTF-8
207
2.515625
3
[ "MIT" ]
permissive
class CastLogEntry < LogEntry def value old_value.nil? ? new_value : old_value end def job Job.find value.split(',').last end def person Person.find value.split(',').first end end
true
81b6f50302027dd0d28e7e8502e1aca2a701f626
Ruby
MothOnMars/sitemaps
/lib/sitemaps/fetcher.rb
UTF-8
1,966
3.0625
3
[ "MIT", "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
module Sitemaps # Simple single purpose HTTP client. Uses `Net::HTTP` directly, so as to not incur dependencies. module Fetcher class FetchError < StandardError; end class MaxRedirectError < StandardError; end @max_attempts = 10 # Fetch the given URI. # # Handles redirects (up to 10 ...
true
3419005b462f07a3a751ac1f9bad1626ecaf873b
Ruby
brettCole/flatiron-bnb-methods-v-000
/app/models/city.rb
UTF-8
889
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class City < ActiveRecord::Base include InstanceMethods extend SharedMethods has_many :neighborhoods has_many :listings, :through => :neighborhoods def city_openings(start, finish) parse_overlap(start, finish) end def self.highest_ratio_res_to_listings city_res_count = 0 high_ratio = nil ...
true
de15398368b77a063eab59ab2e2084a43b9b94e9
Ruby
PopulateTools/gobierto-etl-utils
/operations/download/run.rb
UTF-8
849
2.53125
3
[]
no_license
#!/usr/bin/env ruby require "bundler/setup" Bundler.require require "fileutils" require "open-uri" require "net/http" require "net/https" # Usage: # # - Must be ran as an independent Ruby script # # Arguments: # # - 0: URL to download the content # - 1: Output file # - 2: --compatible # # Samples: # # /path/to/...
true
5f966a20859b24832b8bdcd465efa7ae7134b8a2
Ruby
appstr/ruby
/case_statement.rb
UTF-8
301
3.84375
4
[ "Apache-2.0" ]
permissive
def case_statement(class_obj) case when class_obj == String puts "FOUND STRING!!" when class_obj == Integer puts "FOUND INTEGER!!" else puts "FOUND NOTHING!!" end end class_obj = 10.class case_statement(class_obj) class_obj = "10".class case_statement(class_obj)
true
e990d27e2376adf80b65710fbcff4248b2873068
Ruby
jpkrohling/ruby-presentation
/classes.rb
UTF-8
1,493
3.59375
4
[]
no_license
class BaseEntity attr_accessor :id ## this generates a getter/setter end class Persona < BaseEntity ; end persona = Persona.new persona.id = 123 puts persona.id ## Of course, you can override the getter/setter, if you want: puts class Persona < BaseEntity attr_accessor :created_at @@factor = 2 ## this is a cl...
true
9d06675b54ee31d912890909f24ca092b16b51d3
Ruby
masahino/mruby-termbox
/test/termbox.rb
UTF-8
1,269
2.5625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
assert("constants") do assert_equal 0x00, Termbox::DEFAULT assert_equal 0x01, Termbox::BLACK assert_equal 0x02, Termbox::RED assert_equal 0x03, Termbox::GREEN assert_equal 0x04, Termbox::YELLOW assert_equal 0x05, Termbox::BLUE assert_equal 0x06, Termbox::MAGENTA assert_equal 0x07, Termbox::CYAN assert...
true
a7718abd6e90f94b949a7b2d6acf56bd8bc3adec
Ruby
mattbechtel1/november-25-app
/dealershipapp/app/models/salesperson.rb
UTF-8
395
2.6875
3
[]
no_license
class Salesperson < ApplicationRecord has_many :assignments has_many :cars , through: :assignments def car_ids=(ids) ids.each do |id| car = Car.find(id) unless self.cars.include?(car) self.cars << car end end end def total_...
true
8664c7e6db77d35cfa9b634c1a502751542052ff
Ruby
chriscpan/rails_lite
/lib/params.rb
UTF-8
1,350
3.21875
3
[]
no_license
class Params # uses initialize to merge params from # 1. query string # 2. post body # 3. route params def initialize(req, route_params = {}) @req = req @params = route_params parse_www_encoded_form(@req.body) parse_www_encoded_form(@req.query_string) end def [](key) @params[key] en...
true
2279d8c1974041e68a82fdb3cbe7405f75c10470
Ruby
kiytang/tic_tac_toe_ai
/lib/tic_tac_toe_ai/prompter.rb
UTF-8
354
3.703125
4
[ "MIT" ]
permissive
module TicTacToe class Prompter def self.get_move print "To select your move, please enter a number between 0 to 8: " gets.chomp.to_i end def self.play_again? print "To play again, please enter Y or N (Y or N): " if STDIN.gets.chomp =~ /Y|y/ yield return true ...
true
a9763b0eb426088dde093b595fe2872fb8dab3e2
Ruby
huyh/robot
/spec/command_factory_spec.rb
UTF-8
1,143
2.546875
3
[]
no_license
require 'spec_helper' require 'command_factory' require 'command_data' require 'command/place' require 'command/move' require 'command/turn_left' require 'command/turn_right' require 'command/report' describe CommandFactory do let(:factory) { CommandFactory.new } describe '#create_command' do context 'valid c...
true
954f89b6796856e19b0c311418c731bc9bc6ae09
Ruby
ikappas/php-composer
/lib/composer/repository/filesystem_repository.rb
UTF-8
2,354
2.578125
3
[ "MIT" ]
permissive
# # This file was ported to ruby from Composer php source code. # Original Source: Composer\Repository\FilesystemRepository.php # # (c) Nils Adermann <naderman@naderman.de> # Jordi Boggiano <j.boggiano@seld.be> # # For the full copyright and license information, please view the LICENSE # file that was distributed w...
true
308ae29c73d6795d73b5d326814a70366c896480
Ruby
taylormaed/ruby_challenges
/blog2.rb
UTF-8
1,568
3.4375
3
[]
no_license
class Blog @@all_blog_posts = [] #empty array which will eventually not be empty @@num_all_blog_posts = 0 #start at zero end def self.count_all_blog_posts(new_blog_post) @@all_blog_posts << new_blog_post #new posts into the empty array @@num_all_blog_posts += 1 #increment by one end ...
true
3f70c9da04acf12e731eb9150bbf0b9d65ad6d2e
Ruby
pepychicago07/week2
/friday_methods.rb
UTF-8
132
3.21875
3
[ "Apache-2.0" ]
permissive
# Change this method definition so that it emits # "Hello, my name is Jeff Coeh" def introduce end puts "Hello, my name is Jeff Cohen."
true
ab306f87fa900fa32a24d01a2f8bdc9416338cfb
Ruby
Holy87/Overdrive_Code
/skill_system/skill_windows.rb
UTF-8
28,504
2.5625
3
[]
no_license
class Window_ActorSmallInfo < Window_ActorInfo def fitting_height(line_number) super(line_number - 1) end def draw_actor_basic_info(x, y) draw_actor_face(actor, x, y) x += 100 draw_actor_name(actor, x, 0) draw_actor_level(actor, x, y + line_height) #draw_actor_class(actor, x, y + line_he...
true
3ad8dc303c141dffecbf5d77f75e2eebec1938ff
Ruby
orfah/shotchart
/model/shot.rb
UTF-8
1,903
2.59375
3
[]
no_license
module NBA class Shot < ActiveRecord::Base belongs_to :game belongs_to :player belongs_to :team_for, :class_name => "Team", :foreign_key => :team_for belongs_to :team_against, :class_name => "Team", :foreign_key => :team_against # designated initializer def self.initialize_with_hash(hash) ...
true
57c10f552247cb8bd1bf29ca6482f5de76b966ab
Ruby
Meenakshi-Anand/Aa-HomeWorks
/W1D5/map.rb
UTF-8
1,015
3.453125
3
[]
no_license
class Map def initialize @ivar = Array.new { Array.new } end def assign(key, value) unless @ivar.any?{|sub_arr| sub_arr.first == key} @ivar << [key,value] else @ivar.each_with_index do |sub_arr,idx| @ivar[idx] << value if sub_arr.first == key && sub_arr.last == nil en...
true
74dbc826059054519a5920752c0e29115d2216f5
Ruby
KatherinaFatiguso/rspec-exercises-week-6-4-3-Timecop
/kickstarter.rb
UTF-8
669
3.90625
4
[]
no_license
# EXERCISE 6.4.3 # Write a class and spec to represent a kickstarter campaign. # You should define a method called completed? # which is true if the current time is more than 10 days from commencement. class Kickstarter attr_accessor :title, :start DAY = 24 * 60 * 60 def initialize(title) @title = title e...
true
df933c72d618dddac2fc95de4c6f908d87e3d89b
Ruby
ndlib/curate_nd
/app/inputs/composite_input.rb
UTF-8
2,809
2.890625
3
[ "Apache-2.0" ]
permissive
require 'simple_form' # Render Something Like This # # <div class="control-group composite optional foo_bar"> # <span class="control-label"> # <label for="foo_bar_baz" class="string composite optional input-xlarge">Baz</label> # <label for="foo_bar_bong" class="string composite optional input-xlarge">Bong</l...
true
9393631205d1f610f69b63df4d170a54b809a624
Ruby
gree/observed
/spec/task_spec.rb
UTF-8
6,494
2.671875
3
[ "MIT" ]
permissive
require 'spec_helper' require 'observed/task' describe Observed::MutableTask do let(:factory) { Observed::TaskFactory.new(:executor => Observed::BlockingExecutor.new) } it 'yields the given block' do yielded = nil task = factory.mutable_task { |data| data } task.now({a:1}, {b:2}) do |d...
true
15d8cc9d673759c008abc6ef1b74979585dd5391
Ruby
dasch/omg
/pubsub.rb
UTF-8
713
2.65625
3
[]
no_license
require "faye/websocket" class PubSub KEEPALIVE_TIME = 15 # in seconds def initialize(app) @app = app @clients = [] @messages = [] end def call(env) if Faye::WebSocket.websocket?(env) handle(env) else @app.call(env) end end private def handle(env) ws = Faye::We...
true
3efe1ce5b1d199779411c5d58ebe2298d34189d8
Ruby
CalebKnox/regex-lab-v-000
/lib/regex_lab.rb
UTF-8
450
3.109375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def starts_with_a_vowel?(word) return !!(word =~ /\A[aeiouAEIOU]/) end def words_starting_with_un_and_ending_with_ing(text) text.scan(/un\w*ing/) end def words_five_letters_long(text) text.scan(/\b\w{5}\b/) end def first_word_capitalized_and_ends_with_punctuation?(text) return !!(text =~ /\A[A-Z].*\W\z/) end...
true
695970400c2224b9c549b85316289434f535cc88
Ruby
alaash3lan/problems-solving
/Mini-Max-Sum.rb
UTF-8
483
3.90625
4
[]
no_license
#Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. #Then print the respective minimum and maximum values as a single line of two space-separated long integers. def mini_max_sum (arr) sum = 0 max = arr[0] min = arr[0] f...
true
7cf10c2657bb7c6686477deaf8a7740cae9f2278
Ruby
thebravoman/software_engineering_2014
/class018_homework/Denis_Stoinev_B_13/csv_writer.rb
UTF-8
299
2.828125
3
[]
no_license
require 'csv' class CSVWriter def write(results, classes, time) CSV.open("results_Denis_Stoinev_B_13.csv", "w") do |csv| csv << ["", time, classes].flatten results.keys.sort.each do |key| student = key.split("_") csv << [student, results[key].values].flatten end end end end
true
c3d132d93de059688897fb3eaa74a41dd86226f9
Ruby
40grivenprog/homeworks
/HW_04/Andrei_Dubouski/andrei_dubouski_hw_04_t_01.rb
UTF-8
345
3.625
4
[]
no_license
def fib(number) # used dynamic programming res = Array.new(number) { 0 } return [0] if res.empty? return [1] if number == 1 res[0] = 1 res[1] = 1 (2...res.size).each { |ind| res[ind] = res [ind - 2] + res[ind - 1] } res end def task_4_1(number) if number.is_a?(Integer) && number >= 0 fib(number)...
true
0586b077dfff2e755fa3cd8c1cfeb96aabab53dd
Ruby
decklin/bin
/quarter
UTF-8
129
2.625
3
[]
no_license
#!/usr/bin/env ruby ARGV.each do |path| mtime = File.stat(path).mtime puts "#{mtime.year}q#{(mtime.month - 1) / 3 + 1}" end
true
00be7e64db36da085bf3f17f6461924fe1e68e87
Ruby
smthom05/cross_check
/lib/game.rb
UTF-8
1,094
2.578125
3
[]
no_license
class Game attr_reader :game_id, :season, :type, :date_time, :away_team_id, :home_team_id, :away_goals, :home_goals, :outcome, :home_rink_side_start, :venue, :venue...
true
d6e181d8dca25e0f2996194cc2d4e6a719d5b94e
Ruby
nanma80/euler_project
/p201_225/p218/main.rb
UTF-8
666
3.625
4
[]
no_license
def coprime(a, b) gcd(a, b) == 1 end def gcd(a, b) return gcd(b, a) if a < b return a if b == 0 gcd(b, a % b) end def main count = 0 limit = 10 ** 12 p_limit = Math.sqrt(Math.sqrt(limit)).to_i (1..p_limit).each do |p| puts p if p % 1000 == 0 (1..p-1).each do |q| next if (p - q) % 2 == 0 ...
true
e58ba1f82e5c3c3d7e3cb892229a1b8306cd79aa
Ruby
norkick13/week3day1
/y.rb
UTF-8
98
2.609375
3
[]
no_license
k = ['a', 'b', 'c'] v = ['aa', 'bb', ['aaa','bbb']] h = {} k.zip(v) { |a,b| h[a.to_sym] = b } p h
true
b12128166b0a9a2e2f44ffe7c97275efc972ea03
Ruby
SashaTlr/algos
/Chpt2_LinkedLists/2_1.rb
UTF-8
478
3.5625
4
[]
no_license
//remove dupes from unsorted linked list class Node attr_accessor :val, :next def initialize(val, next_node) @val = val @next = next_node end end //delete dupes def delete_dups(head) dataHash = Hash.new dataHash[head.val] = true; pointer = head; while (pointer.next != nil) do if dataHash...
true
995f309602da38f789d55001a806693c81822d08
Ruby
AkiraBrand/market
/lib/vendor.rb
UTF-8
487
3.34375
3
[]
no_license
class Vendor attr_reader :name, :inventory def initialize(vendor) @name = vendor @inventory = Hash.new(0) end def check_stock(item) @inventory[item] end def stock(item, amount) @inventory[item] += amount end end # def stock(item, amount) # # ##uuugghh how do i...
true
b3d60c5d2b1156ee92fd36baeaca5d19aa995833
Ruby
h4hany/yeet-the-leet
/algorithms/Medium/253.meeting-rooms-ii.rb
UTF-8
795
3.078125
3
[]
no_license
# # @lc app=leetcode id=253 lang=ruby # # [253] Meeting Rooms II # # https://leetcode.com/problems/meeting-rooms-ii/description/ # # algorithms # Medium (45.80%) # Total Accepted: 311.6K # Total Submissions: 680.4K # Testcase Example: '[[0,30],[5,10],[15,20]]' # # Given an array of meeting time intervals consisting...
true
2c9945620345e344ca0b1441d95c6832d10b3abc
Ruby
stender1995/FIT5H_EuP
/Ruby/Unterricht/05_classen.rb
UTF-8
438
3.921875
4
[]
no_license
class Player def initialize(name, health = 100) @name = name @health = health end def say_hello puts "Ich bin Ludwig mit einem Wert von #{@health}." end def w00t(value = 0) @health = @health + value end def blam(value = 0) @health = @health - value end end player1 = Player.new("...
true
2c66887b3eddcdf81faeceada6c4ca56971b53e4
Ruby
cjkelling/sweater_weather
/app/models/Weather.rb
UTF-8
201
2.9375
3
[]
no_license
class Weather def initialize(lat_long) @latitude = lat_long[:lat] @longitude = lat_long[:lng] end def current_weather DarkSkyService.new.get_weather(@latitude, @longitude) end end
true
0a1232f0484f979775cb7142d3d59c2587029c27
Ruby
fbohz/my-each-online-web-prework
/my_each.rb
UTF-8
162
3.09375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def my_each(arr) if block_given? i = 0 while i < arr.length yield(arr[i]) i += 1 end arr else "Please input an argument" end end
true
bd83f077bc26ec2398971012e94e164869db3595
Ruby
s5unty/dotfiles
/mutt/archives/ical-todo.rb
UTF-8
608
2.546875
3
[]
no_license
#!/usr/bin/env ruby # # Converts an iCalendar to a todotxt/remind entry # require "rubygems" require "icalendar" require "date" cals = Icalendar.parse($<) cals.each do |cal| cal.events.each do |event| puts event.summary + " rem:(" + "#{(event.dtstart.offset == 0 ? DateTime.parse(event.dts...
true
cfed440a4f6af693e2938577301c06383ac3a364
Ruby
chienyuan/guessword
/lib/guessword.rb
UTF-8
1,538
3.765625
4
[]
no_license
class Guessword # Guess words by using patter and letters. # # Example: # >> Guessword.guess("****o","hell") # or # Using excute command # >> guessword ****o hell # # output: hello # # Arguments: # pattern_str: (String) # letters_str: (String) # Return: # words: (Array) # def se...
true
6936971ee4ab05d60060b2bb7e751a7fa955e9f6
Ruby
mjgpy3/DataStructsAndAlgsPractice
/List/math_list.rb
UTF-8
798
3.53125
4
[]
no_license
class MathList def initialize @sum = 0 @prod = 1 @counts = {} @items = [] end def add item @sum += item @prod *= item if @counts.include? item @counts[item] += 1 else @counts[item] = 1 end @items << item end def remove item if not @items.find_ind...
true