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
bf3d1ffc226043b8621b0f9f871ebc78fb9ae04e
Ruby
mjonx/Ironhack
/Week-1/Day-4/day4_shopping_cart.rb
UTF-8
1,244
3.859375
4
[]
no_license
class ShoppingCart def initialize @items = [] end def add_item(item) @items.push(item) end def show_items @items.each do |single_item| puts "#{single_item.name}: #{single_item.price}" end end def cost total = 0 @items.each do |item| total += item.price end retur...
true
01b2563c9794162afbaf387b4388afe09c900d75
Ruby
EthanZeng1992/FizzBuzzWhizz
/nums.rb
UTF-8
311
3.1875
3
[]
no_license
class Nums class << self def is_times(i, n, s) return (i % n == 0) ? s : '' end def is_valid?(nums) str = nums.split(',').join match1 = nums.match(/^[1-9]\,[1-9]\,[1-9]$/) match2 = str.match(/^(?!0)(?:([1-9])(?!.*\1))+$/) return match1 && match2 end end end
true
128118d1a6feb2d618ca532ce0eacbc75808cc72
Ruby
TristanBomb/shadow-state
/src/country_defaults.rb
UTF-8
2,509
2.71875
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
include Math module CountryDefaults module_function def stats # Note: Less efficient than using constants, but also less likely to lead to hard-to-track bugs if the constant is accidentally mutated stats = { pol_power_gen: 10, pol_power_factor: 0, diplo_cap_gen: 10, diplo_cap_facto...
true
1596e2f9bb3ab20e6d019e50e5a94f61298065ff
Ruby
enrahyla/dand
/game_spec.rb
UTF-8
549
2.9375
3
[]
no_license
require_relative 'class' describe 'Player' do it "has a capitalized name" do player = Player.new("aaron", 100) player.name.should == "Aaron" end it "has an initial health" do player = Player.new("aaron") player.health.should == 150 end it "has a string representation" do player = Pla...
true
a2c6ee9b5d695100b21dcd3c47097d0c9be764c0
Ruby
bhollan/activerecord-validations-lab-v-000
/app/models/post.rb
UTF-8
677
2.65625
3
[]
no_license
# class ValidClickBait < ActiveModel::Validator # def validate(record) # !record.title.nil? && record.title.scan(/(Won't Believe|Guess|Secret|Top \d+)/).empty? # end # end class Post < ActiveRecord::Base include ActiveModel::Validations validates :title, presence: true validates :content, length: {minimu...
true
a47830d2146a683632e1fd97ce31368d93b256c6
Ruby
anfb/learningRspec
/unitTest/spec/firstexample_spec.rb
UTF-8
216
2.65625
3
[]
no_license
describe 'suit rspec' do it 'sum of values' do sum = 10 + 5 expect(sum).to eql 15 end it 'soma de valores string' do soma = 10 + 5 expect(soma.to_s).to eql '15' end end
true
290fe8e219501f09db825607b4ea80d21275f312
Ruby
ggarnier/chip8.rb
/lib/emulator.rb
UTF-8
643
3.171875
3
[]
no_license
require_relative "operation" class Emulator attr_reader :registers, :pc def initialize @registers = [0] * 16 end def exec(instructions) @pc = 0 loop do operation = Operation.for(instructions[pc]) case operation.name when 'set' registers[operation.register] = operation.v...
true
5b68f55157f6526f3bba8fe2af11741ccf703e93
Ruby
Kingkunta1/my-each-dumbo-web-career-042219
/my_each.rb
UTF-8
207
3.046875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require'pry' def my_each(array) i = 0 while i < array.length yield array[i] #binding.pry i = i + 1 end array end # put argument(s) here # code here # i = 0 set the variable as the counter
true
e688286d2fca4dff25f66b806f01f50d8a4f2aa8
Ruby
skyzh/lisp-interpreter
/ruby/step4_if_fn_do.rb
UTF-8
1,868
2.90625
3
[ "MIT" ]
permissive
require 'readline' require_relative 'reader' require_relative 'printer' require_relative 'env' require_relative 'core' def READ(x) read_str(x) end # @param [Env] env def EVAL(x, env) case x when List then if x.empty? x else case x[0] when :def! then env.set(x[1], EVAL(x[2], env...
true
ce68c72867b13d95bb4e83d12b9b50b5c813ead2
Ruby
gimite/hrwt
/lib/hrwt/rpc_base.rb
UTF-8
1,606
2.546875
3
[]
no_license
if RUBY_PLATFORM == "javascript-hotruby" old_debug = JS.debug JS.debug = false end require "rubygems" require "webrick" require "json" require "set" class RemoteObject def initialize(client, id, class_name) @client = client @id = id @class_name = class_name end def method_...
true
287bdaaaf9986d6f5014996ad87b20d782bdc242
Ruby
alexmchale/attribute_boolean
/test/global_false_values_test.rb
UTF-8
818
2.59375
3
[ "MIT" ]
permissive
require "test_helper" class GlobalFalseValuesTest < Minitest::Test def setup @class = Class.new do include AttributeBoolean attr_boolean :finished end @obj = @class.new end def test_custom_false AttributeBoolean.false_values = [ "no way" ] assert_equal [ "no way" ]...
true
451186dab51df7f731f7225481dc5b48fe0cdcf8
Ruby
chck/facebook-tester
/selenium_test_image.rb
UTF-8
1,551
2.6875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby #-*- coding:utf-8 -*- require 'selenium-webdriver' require 'rainbow' require 'yaml' class SeleniumTest def initialize @url = "https://m.facebook.com/home.php" conf = YAML::load(open("../API.yaml")) @email = conf["fb_email"] @pass = conf["fb_pass"] #@bsr = Selenium::WebDriver.f...
true
84f1f78db3894e124bae9df087716e744d7da388
Ruby
fabiopichler/Projects-RGSS
/FP-Keyboard-System/FP-Keyboard-System.rb
UTF-8
12,041
2.65625
3
[ "MIT" ]
permissive
#=============================================================================== # * * FP Keyboard System * * #=============================================================================== # * Criado por: Fábio Pichler - http://fabiopichler.net # * Licença: MIT License - http://fabiopichler.net/mit-license/ # * Versã...
true
aaba83d75b7a1586839505b326462c643266de09
Ruby
yagihiro/hockey
/lib/hockeyhelper/version.rb
UTF-8
1,290
2.515625
3
[ "MIT" ]
permissive
module Hockey VERSION = '0.0.7' # Version on HockeyApp class Version attr_reader :id attr_reader :version attr_reader :mandatory attr_reader :config_url attr_reader :download_url attr_reader :timestamp attr_reader :appsize attr_reader :device_family attr_reader :notes at...
true
ee9aad7e3996ca1690240b5b9773292cb24f8260
Ruby
harrisonmalone/todo_app_mvc_ft
/lib/todo.rb
UTF-8
790
3.421875
3
[]
no_license
class Todo attr_reader :id, :name, :done def initialize(id: nil, name: 'no name', done: false) @id = id @name = name @done = done end def self.all [ { id: 1, name: "Walk the dog", done: false }, { id: 2, name: "Do homework", do...
true
5be7289f1882d25029a4f92583f2c40ef6bc8340
Ruby
kenchose/Ruby-on-Rails
/rails/controllers_views/survey_form/app/controllers/users_controller.rb
UTF-8
676
2.515625
3
[]
no_license
class UsersController < ApplicationController def index @user = User.new end def results session[:counter] ||= 0 @user = User.create( user_params ) if @user.save flash[:notice]=session[:counter] += 1 end end private def user_params params.require(:user).permit(:name, :lan...
true
65826ad215693ff99c56ea50b86b1553a3647fb8
Ruby
abishekaditya/RubyProjects
/find
UTF-8
218
3.5
4
[ "MIT" ]
permissive
#!/usr/bin/env ruby puts ["cat","b","catcher"].inject {|temp,word| temp.length > word.length ? temp : word} def longest ar puts ar.inject {|t,w| t.length > w.length ? t: w} end longest ARGV[0].split(',')
true
1fb197b46494905d13979be1fed733b3c16581ad
Ruby
aduane/geckoboard-weather-widget-data-feeder
/app/controllers/weather_controller.rb
UTF-8
1,124
2.75
3
[]
no_license
class WeatherController < ApplicationController require 'open-uri' def index weather_data = JSON.load(open(weather_url)) @weather = {'item' => [{'text' => weather_html(weather_data)}]} render json: @weather end private def weather_url "http://api.openweathermap.org/data/2.5/weather?q=#{Rails...
true
87b65dd2229fdd805abba8d34c0a592bdcf505a0
Ruby
caltonhill/ruby_learning
/ruby by example/chap4_sortChildrensNames.rb
UTF-8
383
3.953125
4
[]
no_license
# accept user input of a series of names. user enters 0 # to signal end of input # store names in an array # display the stored names in alpha order names_array = [] while true do print "Enter childrens names (enter STOP to finish):" input = gets.chomp if input != 'STOP' names_array << input else break end ...
true
936d30912618c3cf2c97043e3339771888509895
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/gigasecond/b6492e8a385e4927ba3ba4129de9f5a2.rb
UTF-8
220
2.671875
3
[]
no_license
class Gigasecond def self.from(dt) epoc = if dt.instance_of? Date dt.strftime('%s').to_i + 1000000000 + 24*60*60 else dt.strftime('%s').to_i + 1000000000 end Time.at(epoc).to_date end end
true
d4d204352722bbaac5d773b7e9f83e6678f1ecc5
Ruby
krames/trinity-ruby
/L4-conditionals-loops.rb
UTF-8
1,450
4.09375
4
[]
no_license
# Conditionals is_this_thing_on = true if is_this_thing_on puts "Yep! It's on!" end # the shorter version puts "Yep! It's on!" if is_this_thing_on #what about the opposite? puts "turn it on" unless is_this_thing_on #what else can we do? if is_this_thing_on puts "It's on!" else puts "Turn it on" end def grad...
true
28de23b4fb87a339999d49d2e4438497207477e6
Ruby
kaigitt/ruby-book
/each.practice.rb
UTF-8
437
3.734375
4
[]
no_license
numbers =[1,2,3,4] sum = 0 numbers.each do |n| sum_value = n.even? ? n * 10 : n sum += sum_value end puts sum numbers = [1, 2, 3, 4, 5] even_numbers = numbers.select { |n| n.even? } puts even_numbers non_multiple_of_three = numbers.reject { |n| n % 3 == 0 } puts non_multiple_of_three def liquid?(temperatur...
true
6bfe97eb54e1d9511be70c51b426b578a728689c
Ruby
alliesground/ruby-exercises
/chapter7_3.rb
UTF-8
214
3.015625
3
[]
no_license
movies = { jaws: 1984, rocky: 1990, commando: 1998 } movies.each_key {|title| puts title} movies.each_value {|year| puts year} movies.each {|title, year| puts "#{title} => #{year}"}
true
2be361eccaf305a60628558e39e10b10ee0550c7
Ruby
valdemaximus/XX
/lib/extensions/nil.rb
UTF-8
240
2.640625
3
[]
no_license
class NilClass def not_nil? false end def include?(o) false end def empty? true end def not_empty? false end def length 0 end alias :blank? :empty? alias :not_blank? :not_empty? end
true
751771603770ff6f447e81426f8b49490102b5a2
Ruby
izbiz/Flatiron
/development/hash_practice.rb
UTF-8
921
3.875
4
[]
no_license
#Has is an unordered list of key-value pairs. starts/ends w/ curly braces #defining hash using symbols bucket_list_hash = {:paige=>"sky diving", :trish=>"hang glide", :louisa=>"bungee jump", :everybody=>"learn Ruby", :emily=>"go to Russia", :brian=>"fly a helicopter" } #acces value w/key = everybody # puts...
true
7b6e1c0c1f6cace328a84dd0ca4dce44e00606ef
Ruby
prkhrv/Ruby-Starter-pack
/sum.rb
UTF-8
78
2.890625
3
[]
no_license
# a = 10; # b = 20; b = 20; puts "Enter the numbers"; a = gets.to_i puts a+b;
true
0f935ba7d3f536f3a3a2b3fc899c34b3c106fb12
Ruby
gemathon-warriors/gemathon
/app/controllers/tareek_controller.rb
UTF-8
1,345
2.625
3
[]
no_license
class TareekController < ApplicationController def calc method = params[:commit].split(' ').join('_') self.send(method.downcase.to_sym) render json: { date: @result } end def calc_day @result = Tareek::Dates.date_of_next(params[:day]) render json: { date: @result } end def humanized_d...
true
f5e543d9c20d3449ef3958ebbd8c43bc65d3f7eb
Ruby
joemecha/war_or_peace
/test/turn_test.rb
UTF-8
8,248
3.15625
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/card' require './lib/deck' require './lib/player' require './lib/turn' class TurnTest < Minitest::Test def setup @card1 = Card.new(:heart, 'Jack', 11) @card2 = Card.new(:heart, '10', 10) @card3 = Card.new(:heart, '9', 9) @card4 = Car...
true
81fff916faf2ec836b9500c155815b4b565af9c1
Ruby
stac47/ruby-sandbox
/03-curses/curses-tuto5.rb
UTF-8
459
3.015625
3
[ "MIT" ]
permissive
#!/usr/bin/ruby -w # vi:set fileencoding=utf-8 : # # Created on 2014-01-29 # # @author : Laurent Stacul require 'curses' Curses.init_screen begin win = Curses.stdscr x = win.maxx / 2 # We will center our text y = win.maxy / 2 win.setpos(y, x) # Move the cursor to the center of the screen win.addstr("Hello...
true
d06be0a7d1a95dc10bdb6cbe7aaacfad21a4a138
Ruby
willyjie/book_store_task
/app/api/v1/book_api.rb
UTF-8
960
2.71875
3
[]
no_license
module V1 class BookAPI < Base helpers do def not_found_method(result) return error!('Record Not Found', 404) unless result.present? end end desc 'Serach books price' params do requires :price, type: Float end get '/book_price' do result = [] Store.all.e...
true
1951adc3e150f546ba6b91fd4167e39dc27d2b1e
Ruby
tiffany-simionescu/udemy-ruby-notes
/3_strings.rb
UTF-8
403
4.125
4
[]
no_license
puts "Enter your first name?" first_name = gets.chomp puts "Enter your last name" last_name = gets.chomp full_name = "#{first_name} #{last_name}" puts "Your full name is #{full_name}" puts "Your full name reservsed is #{full_name.reverse}" puts "Your name has #{full_name.length - 1} characters in it" puts "Enter a ...
true
0f20817f93865a4ecda5a4eb86f8f09590221785
Ruby
ayanit1/ruby_practice
/lib/to_square_or_not_to_square.rb
UTF-8
157
3.296875
3
[]
no_license
class SquareOrSquareRoot def square_or_square_root(arr) arr.map {|int| Math.sqrt(int) % 1 == 0 ? Math.sqrt(int).to_i : int * int } end end
true
918898c3096426188564974c5b179c42bf725c83
Ruby
StevenGerdes/ECE421-project-2
/shell_contract.rb
UTF-8
1,914
3.046875
3
[]
no_license
require 'test/unit' class ShellContract < Test::Unit::TestCase def test_execute shell = Shell.new test_string = 'the quick brown fox jumps over the lazy brown dog' execution_text = "echo #{test_string}" std_out_message = StringIO.new $stdout = std_out_message #invariant old_shell = sh...
true
914c679f684cae22058682003cd6856399908f82
Ruby
JoelLindow/mod_1_homework
/calculator_exercise/lib/calculator.rb
UTF-8
230
3.34375
3
[]
no_license
class Calculator attr_reader :number def initialize @number = clear end def clear 0 end def add(num) @number += num end def subtract(num) @number -= num end def total @number end end
true
70f0ccc526d334b7da5dfc3d1a5b1d99229ded35
Ruby
maler306/ProjectTN_1
/lesson_02/year_day.rb
UTF-8
428
3.234375
3
[]
no_license
puts "Введите последовательно число, месяц и год" d = gets.chomp.to_i m = gets.chomp.to_i y = gets.chomp.to_i ar_year= (1..12).to_a day_month=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] if m>1 qty = (day_month[0..(m-1)].reduce :+) + d #not january qty +=1 if ((y % 4==0 && y%100!=0 ) || y%400==0 ) && m>2 el...
true
619a4c8dfd8fbbd0d5e863ff12326f4afe8fe38f
Ruby
kage1029/atcoder
/atcoder056C.rb
UTF-8
74
3.15625
3
[]
no_license
x = gets.chomp.to_i n = 1 while n * (n + 1) < 2 * x n += 1 end puts n
true
dec057c3b73663d94d5439d99da8f73b6c2c5b5c
Ruby
blacktm/apps_for_blue_button
/server/actions/blue_button_to_labs.rb
UTF-8
711
3.015625
3
[]
no_license
# Blue Button to Labs (blue_button_to_labs.rb) # Description: # Converts parsed Blue Button data to a neutral lab format. module Actions class BLUE_BUTTON_TO_LABS def self.run(app) app['data'] = JSON.parse(app['data']) labs = {} app['data'] = app['data']['VITALS AND READI...
true
b71c933598f3ca60df6f5f2aba7e1b22bb1f8105
Ruby
Koshoo/learn_ruby
/02_calculator/calculator.rb
UTF-8
503
4.21875
4
[]
no_license
#write your code here def add(a, b) a + b end def subtract(a, b) a - b end def sum(arr) sum = 0 i = 0 while i < arr.length sum += arr[i] i += 1 end sum end def multiply(*numbers) sum = numbers[0] puts numbers.length for i in 1..(numbers.length - 1) sum *= numbers[i] end sum end d...
true
27d673c2a8f46fe6605490fd1b003bd0b6a535e3
Ruby
Mudasirrr/Courses-
/Johns Hopkins University - Ruby on Rails Web Development Specialization/JHU - Ruby on Rails Web Services and Integration with MongoDB/module1/asgn01-MongoDB-Connection/spec/assignment_spec.rb
UTF-8
3,691
2.984375
3
[ "Apache-2.0" ]
permissive
require_relative "../assignment" require 'rspec' require 'mongo' Mongo::Logger.logger.level = ::Logger::INFO describe Solution do subject(:solution) { Solution.new } let!(:db_url) { Mongo::Client.new('mongodb://localhost:27017') } let!(:connection) { db_url.use('test') } before :all do $continue = true ...
true
f13346879c8ccf59b072d9dfc3a8fa2b3979aaf7
Ruby
gcontrerash/ruby-learning
/ciclos.rb
UTF-8
617
4.28125
4
[]
no_license
x = 1 while x <= 5 do puts "el numero es: #{x}" x += 1 end x = 1 loop do puts "hola #{x}" x += 1 break if x >= 5 end for x in 1..4 do puts "hola #{x}" end [1,2,3,4].each { |x| puts "hola #{x}"} 4.times do |x| puts "hola" end def counter_letters(word) puts "la palabra es: #{wo...
true
a26cead1be15ecb325eeba6e9219d19a39f416f1
Ruby
utahkay/combiner
/grouper.rb
UTF-8
8,360
2.984375
3
[]
no_license
# take a look at Steiner # Steiner system S(t, k, v) group_size = 2 people_count = 9 people_count = ARGV[0].to_i if ARGV[0] people = (1..people_count).to_a class Grouper def initialize(group_size, sub_group_size) @n = group_size @k = sub_group_size @or_rules = [ method(:only...
true
5a445e3162342f4e7ab5cb033248362906fb6582
Ruby
KalMegati/scraping-kickstarter-online-web-pt-090919
/kickstarter_scraper.rb
UTF-8
1,269
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "nokogiri" require "pry" # require libraries/modules here def create_project_hash projects = {} html = File.read('fixtures/kickstarter.html') kickstarter = Nokogiri::HTML(html).css("li.project.grid_4") title = kickstarter.css("h2.bbcard_name strong a") image = kickstarter.css("div.project-thum...
true
c8b6d803cdfc29a56c7b6431e282e2fcf58242e6
Ruby
ananogal/Takeaway
/spec/order_spec.rb
UTF-8
2,034
2.96875
3
[]
no_license
require './lib/order.rb' describe Order do let(:client) {double :client} let(:dish){double :dish, :name => :burger, :cost =>2.9} let(:dish2){double :dish2, :name => :coke, :cost =>2.5} let(:menu){double :menu, :name => :all, :cost =>5.4} let(:item) {double :item, :meal =>menu, :quantity =>1, :cost =>5.4} let(:i...
true
937cf637f35a05fb6ed4732d33b0859a38182ed6
Ruby
anam-mansoor7/LondonDisruptionsMap
/tests/app_test.rb
UTF-8
933
2.546875
3
[]
no_license
require 'minitest/autorun' require 'rack/test' require_relative '../app' class DisruptionsMapAppTest < Minitest::Spec include Rack::Test::Methods def app DisruptionsMap end def test_displays_main_page get '/' assert last_response.ok? assert last_response.body.include?('London Traffic Disr...
true
a1b6355ba76de3381b665fd53dbfa4bbafcbe1d4
Ruby
rakshit6432/archivesspace
/backend/spec/lib_accession_converter_spec.rb
UTF-8
1,400
2.5625
3
[ "ECL-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
require 'spec_helper' require 'converter_spec_helper' require 'csv' require_relative '../app/converters/accession_converter' describe 'Accession converter' do def my_converter AccessionConverter end before(:all) do test_file = File.expand_path("../app/exporters/examples/accession/aspace_accession_impo...
true
62326985650dc5db9d0669053e6ccacdff0ca592
Ruby
javierav/changefu
/lib/changefu/changes_group.rb
UTF-8
369
2.640625
3
[ "MIT" ]
permissive
module Changefu class ChangesGroup attr_reader :type, :changes def initialize(type, changes=[]) @type = type @changes = changes end def humanized_name if Changefu::Configuration.respond_to?(:types) Changefu::Configuration.types[type.to_sym] || type.capitalize else ...
true
e6204749d25d6d0a330c15393f39741fe921b423
Ruby
ShaunMackie/Ruby_Small_Problems
/Easy_3/Easy3_1_again.rb
UTF-8
2,800
4.90625
5
[]
no_license
=begin #Problem - write a program that solicits 6 numbers from the user - then prints a message that describes whether or not the 6th number appears among the first 5 numbers #Input - 6 integers #Output - a string saying whether the 6th integer appears among the first 5 integers #Examples ==> En...
true
4822432f067fb8e89d5a20689266e6603aa93aa3
Ruby
dojorio/dojo_niteroi
/2010/20101028_ruby_vitos_family/vito.rb
UTF-8
787
3.34375
3
[]
no_license
class CampoMinado def initialize(campo) @campo = campo end def resultado tamanho = @campo.size @retorno = [] for i in 0..tamanho-1 do @retorno << [0]*tamanho end @campo.each_index do |linha| @campo[linha].each_index do |coluna| ...
true
e9b3d214d9f30249ac7edf98b39b1e902058e520
Ruby
Mattlk13/maglev
/src/test/Trac504.rb
UTF-8
486
2.546875
3
[]
no_license
h = { } # Used to raise ERROR 2010, Undefined method `to_hash' for nil raise 'fail 1' unless (h == nil) == false raise 'fail 2' unless h != nil #################### Trac Info # ID: 504 # Summary: Hash#== not correct # Changetime: 2009-04-26 20:32:39+00:00 ### # The implementation of == for RubyHash (ali...
true
374a22dd72363cb1cbedec3f5d3774e65e6b375d
Ruby
saranderson13/ruby-objects-has-many-lab-online-web-pt-041519
/lib/artist.rb
UTF-8
527
3.515625
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'pry' class Artist attr_accessor :name attr_reader :songs @@artists = [] def initialize(name) @name = name @songs = [] @@artists << self end def add_song(song) song.artist = self # Lets song know that the artist is it's artist (Belongs to) @songs << song # Lets artist know tha...
true
59e3b36d26c3086fb5b579e6131f2a8e3fe1d755
Ruby
yohannteston/Parallel-course-Lab3
/labOpenMP/bench_lu.rb
UTF-8
448
2.78125
3
[]
no_license
#!/usr/local/bin/ruby # Benchmark for gram2 # For each size and each number of thread launch 20 times # the program and keep the least time. [1,4,8,12,16,24,32,48,64].each do |n| min_time = 10000000000 ; ENV['OMP_NUM_THREADS'] = "#{n}" ; 20.times { system "export OMP_NUM_THREAD=#{n}" out = `./lu` out_split ...
true
e51e1f99a4af83e24bd4628be8c54e20491f42ea
Ruby
Fem-Fem/ruby-collaborating-objects-lab-v-000
/lib/song.rb
UTF-8
614
3.0625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :name, :artist def initialize(name) @name = name end def artist_name=(artist_name) artist = Artist.find_or_create_by_name(artist_name) artist.add_song(song) end def self.new_by_filename(filename) song_name = filename.scan(/-(.+)-/) song_name = song_name[0][0...
true
dc9b8e5cbdf0fd9376c12f7c6a6a5b368b00898d
Ruby
spearwolf/burnify
/server/lib/chartify.rb
UTF-8
746
2.75
3
[]
no_license
module Chartify def init_chart_data returning Hash.new do |h| h[:type] = self.class.name h[:title] = name #h[:estimated_hours] = estimated_hours h[:start_at] = start_at h[:deadline] = deadline h[:color] = color h[:id] ...
true
ea05d38e077deadab0c4fde5e081c3f28f80c058
Ruby
alexandredct/studying-ruby
/level-3/example-7.rb
UTF-8
448
3.84375
4
[]
no_license
greetings = lambda { |name| puts "Greeting #{name}" } message = lambda { puts "If you need and help you can email to contact@abc.com" } # ======================= class Member def initialize(name) @name = name end attr_reader :name # using Proc as a method parameter def first_steps message mess...
true
d10c0c321fa14f37ac4e54ce7bee5c7f91c1cce5
Ruby
idrysdale/walks
/app/activity_data.rb
UTF-8
224
2.609375
3
[]
no_license
class ActivityData attr_reader :id, :name, :started_at, :course_data def initialize(id, name, started_at, course_data) @id = id @name = name @started_at = started_at @course_data = course_data end end
true
fc85b95896ceadae987b5e8f15c121fa480d3a47
Ruby
sergiocortessat/Ruby-Milestone1-BubleSort
/bubble_sort_by.rb
UTF-8
425
3.59375
4
[ "MIT" ]
permissive
def bubble_sort_by(array) i = 0 while i < array.length - 1 result = yield(array[i], array[i + 1]) if result.positive? array[i], array[i + 1] = array[i + 1], array[i] i = 0 else i += 1 end end array end print bubble_sort_by([14, 8, 3, 100, 3, 9, 2, 1, 0, 12, 20]) { |left, right|...
true
c6c894951f6eda2e7207b83f652bdfed8ab84f74
Ruby
09a-Abukar/Ruby
/rubyPlayGround/ascii2.rb
UTF-8
57
2.734375
3
[]
no_license
nam= ['72','69','76','76','79'] nam.each {|n| puts n.chr}
true
ad4f8278e48409852ed50a5eef5706d2cf5ba0a6
Ruby
graydon/stellar_core_commander
/bin/scc
UTF-8
1,340
2.546875
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby require 'stellar_core_commander' require 'slop' def run $opts = Slop.parse do banner 'Usage: scc -r RECIPE' on 'stellar-core-bin', 'a path to a stellar-core executable (defaults to `which stellar-core`)', argument: true on 'docker-mode', 'mode to run the docker containers in', ...
true
bf95d2e6fd8dc01f82b573e7e8982e195e5ffe79
Ruby
danstutzman/segment-by-syllable
/open.rb
UTF-8
2,939
2.921875
3
[]
no_license
require 'wavefile' require 'chunky_png' path = ARGV[0] or raise "Specify stereo .wav as first param" info = WaveFile::Reader.info(path) puts "Duration: #{info.sample_frame_count / info.sample_rate}" samples = [] num_buffers = 0 WaveFile::Reader.new(path).each_buffer(4096) do |buffer| if info.channels == 1 sampl...
true
5c567ab855d59d1436d92aeae0aab352ff3b6653
Ruby
sawaezamin/backend_mod_1_prework
/section1/ruby_basics_lessons/ex11.rb
UTF-8
443
4.25
4
[]
no_license
print "How old are you? " age = gets.chomp print "How tall are you? " height = gets.chomp print "How much do you weigh? " weight = gets.chomp print "What is your favorite food? " food = gets.chomp print "What is your favorite sport? " sport = gets.chomp puts "So, you're #{age} years old, #{height} tall and #{weight} ...
true
9b15b634d2fd3213dbc3da7912b9557d6b84b2d1
Ruby
conniechu929/Ruby_algos
/permutation_string.rb
UTF-8
1,484
3.53125
4
[]
no_license
# Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. # In other words, one of the first string's permutations is the substring of the second string. # Example 1: # Input: s1 = "ab" s2 = "eidbaooo" # Output: True # Explanation: s2 contains one permutation of s1 ("ba"). #...
true
388e1453f122c33ad2c9dae603ccced38f9f5253
Ruby
cowang01/cc_karaokeClass
/specs/songs_spec.rb
UTF-8
914
3.125
3
[]
no_license
## require('minitest/autorun') require('minitest/rg') require_relative('../songs.rb') class TestSongs < MiniTest::Test def setup @song_1 = Song.new("Don't Stop Believin'", "Journey", 4.18, "Pop") @song_2 = Song.new("Bohemian Rhapsody", "Queen", 5.92, "Rock") @song_3 = Song.new("Bat Out of Hell", "MeatLoa...
true
5f02e3e9ef8d0e614c375048e575ff5ac52d8c88
Ruby
meanpenguin/DNE
/atari_wrapper.rb
UTF-8
2,199
2.625
3
[ "MIT" ]
permissive
require 'numo/narray' module DNE # Convenience wrapper for the Atari OpenAI Gym environments class AtariWrapper attr_reader :gym_env, :reset_obs, :reset_obs_py, :act_type, :act_size, :obs_size, :skip_type, :downsample, :preproc, :row_div, :col_div extend Forwardable def_delegator :@gym_env, :re...
true
1228cef08c2653af0ef3a729b0df7dde73653b84
Ruby
levimllr/the-bachelor-todo-teacher-onboarding
/lib/bachelor.rb
UTF-8
1,431
3.65625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" def get_first_name_of_season_winner(data, season) data.each do |key, value| if key == season value.each do |contestant| if contestant["status"] == "Winner" full_name = contestant["name"] name_array = full_name.split(" ") first_name = name_array[0] ...
true
5e66c28b65a8014088c415cb38199aafe6259a99
Ruby
yogmk/prog
/rb/getJIRAs.rb
UTF-8
3,308
2.59375
3
[]
no_license
#!/usr/bin/env ruby require "rubygems" require "win32ole" require "Nokogiri" # download the data # parse xml and extract data of interest # create/populate the Excel. $twoD_arr= Array.new def parse_data(dd) doc = Nokogiri::HTML(dd) x = Array.new # we need a more robust 'xpath' here. This ...
true
92ef3d870bb73fc191ad35a894e0e0107d65ceb9
Ruby
josornoc/josornoc.github.io
/course/SRCProcessing/example1.rb
UTF-8
40
2.65625
3
[]
no_license
(1..10000).each do |item| puts item end
true
a677e112854774edee9897b69cf41e73973c6f72
Ruby
johanek/puppet-parse
/lib/vendor/puppet/provider/confine/feature.rb
UTF-8
412
2.5625
3
[ "MIT" ]
permissive
require 'puppet/provider/confine' class Puppet::Provider::Confine::Feature < Puppet::Provider::Confine def self.summarize(confines) confines.collect { |c| c.values }.flatten.uniq.find_all { |value| ! confines[0].pass?(value) } end # Is the named feature available? def pass?(value) Puppet.features.send...
true
406c944e7863c80f8f467c5c09cd35e7a0c8a846
Ruby
PaulStevenson/lab_hogwarts_ruby_sql_html
/db/seeds.rb
UTF-8
643
2.84375
3
[]
no_license
require_relative('../models/student') require('pry-byebug') student1 = Student.new({ 'first_name' => 'Iain', 'last_name' => 'Rogerson', 'house' => 'Gryffindor', 'age' => 12 }) student1.save() student2 = Student.new({ 'first_name' => 'Paul', 'last_name' => 'Stevenson', 'house' => 'Slytherin', 'age' =>...
true
ab6b62e02f589f8b5df88ef6a4adb70499cb1275
Ruby
pwyszynski/neville-coeffs
/spec/integration/VectorOperations_spec.rb
UTF-8
1,207
2.75
3
[]
no_license
require_relative '../spec_helper.rb' require_relative '../../lib/VectorOperations.rb' describe "#Coefficients" do it "calculates current vector values for example from documentations" do pyramid = NArray.object(3,3) x = Array[1,2,4] y = Array[0,2,12] pyramid[0,0] = Wektor.new(3) pyramid[0,0].setVecto...
true
02d9df3c1fdfa1897f9956cb00a736058f0ad07b
Ruby
taw/mtg
/bin/cod2txt
UTF-8
549
2.578125
3
[]
no_license
#!/usr/bin/env ruby require "optimist" require_relative "../lib/mtg" opts = Optimist::options do opt :input, "input (default STDIN)", type: :string opt :output, "output (default STDOUT)", type: :string opt :autofilename, "select file name based on deck name", type: :boolean, default: false end parser = Cockatr...
true
d090490a4b828115be0f71a7a06bb0054bdd4fe2
Ruby
lypnol/adventofcode-2019
/day-05/part-1/tpxp.rb
UTF-8
998
2.796875
3
[ "MIT" ]
permissive
def run(s) input = s[0].split(',').map &:to_i inputvals = [1] i = 0 outputs = [] loop do a0, a1, a2, a3 = input[i..i+3] code = a0 % 100 v1 = a0 / 100 % 10 == 1 ? a1 : input[a1] v2 = a0 / 1000 % 10 == 1 ? a2 : input[a2] v3 = a0 / 10000 == 1 ? a3 : input[a3] ...
true
9876de7eb8a90bebd8e0411fd09b0d690e1b4b95
Ruby
olareskii/exercitii
/ex31.rb
UTF-8
942
2.734375
3
[]
no_license
# encoding: utf-8 def prompt print ">" end puts "M-am pornit la moară, ajung la o rascruce cu doua drumuri. drum #1 și drum #2." prompt; drum = gets.chomp if drum == "1" puts "acolo sunt gradini frumoase,multe fructe" puts "1. intru in gradini" puts "2. merg mai departe" puts "3. ma intorc inapoi" pro...
true
50a4630b07c4774cd48bfae35a294a7e72c634ef
Ruby
SankakuAJB/flight_booker
/app/models/flight.rb
UTF-8
604
2.71875
3
[]
no_license
class Flight < ActiveRecord::Base belongs_to :from_airport, class_name: "Airport" belongs_to :to_airport, class_name: "Airport" def self.flight_dates all.collect { |f| [f.formatted_date, f.start_time.to_date] }.uniq end def self.search(params) if params[:search] Flight.on_date(params[:date].to_date) ...
true
a5b0fc05f5398b33b0649f49763dff99505d76fb
Ruby
lynchd2/assignment_ruby_api_calls
/private_github.rb
UTF-8
820
2.8125
3
[]
no_license
require 'github_api' require 'pp' require 'pry' class GithubAPI GITHUB_API_KEY = ENV["GITHUB_API_KEY"] def initialize @github = Github.new(oauth_token: GITHUB_API_KEY) end def user_repos(name) @github.repos.list user: name end def commits(name, repo) array = [] response = @github.repos...
true
bbd5f87513ba3a9147fce172bd45cac91d370ad4
Ruby
fabiodocarmo/redmine_vale
/plugins/redmine_business_rules_management/app/models/business_rule.rb
UTF-8
3,043
2.640625
3
[]
no_license
class BusinessRule < ActiveRecord::Base unloadable serialize :parameters PARAMETER_TYPES = { string: lambda { |parameter| parameter.to_s }, int: lambda { |parameter| parameter.to_s.to_i }, float: lambda { |parameter| parameter.to_s.to_f } } PARAMETER_KEYS = Set.new [:type, :value] CUST...
true
cbfe7b696ce901f2a0a6542c4a72b32c5403192e
Ruby
BlookHo/talented_alex_rb
/spec/rule_spec.rb
UTF-8
1,237
2.71875
3
[]
no_license
require './source/rule' require './source/parser' require './source/constants' RSpec.describe Parser do context 'check conditions of rule apply - method #satisfies_conditions?' do let(:first_rule) { Parser.load_rules(RULES_FILE)[0] } let(:rule) { Rule.new(first_rule) } let(:cart_content) { { AP1: 3, FR1:...
true
5c269e06ea858e4ed5a8dea10ff966ce1c6cb140
Ruby
nextekcarl/traveller-spec-trader
/lib/GalacticTrader/defined_trade_good.rb
UTF-8
37,396
2.6875
3
[ "MIT" ]
permissive
class DefinedTradeGood #This is the specific type of BasicTradeGood to be found #Has a name, ton increment, and Base Price attr_accessor :tonnage def self.specific(basic_trade_good, remaining_tonnage) case when basic_trade_good == "Basic Electronics" case roll('2d6') when 2 ...
true
5ce0fa565adc660f79e459b5245bf72db64199d8
Ruby
eltercero/scraperd
/test/activity_test.rb
UTF-8
1,324
2.5625
3
[ "MIT" ]
permissive
require 'test_helper' class ActivityTest < MiniTest::Test def test_activity_conversion item = { :title => "Nausica\xC3\xA4 of the Valley of the Wind, 1984 - \xE2\x98\x85\xE2\x98\x85\xE2\x98\x85\xC2\xBD", :link => "http://letterboxd.com/eltercero/film/nausicaa-of-the-valley-of-the-wind/", ...
true
b14abf554250fa1792d7ede714193648718da4c1
Ruby
aladac/iml
/lib/iml/base.rb
UTF-8
2,951
2.84375
3
[ "MIT" ]
permissive
# frozen_string_literal: true # Base media file class class IML::Base < OpenStruct # @return <String> Allows retrieving and setting of the format string for the output name attr_accessor :format_string # @return <String> Allows for setting and getting the output path sans the output base filename attr_accessor...
true
643bd1268b237de8c7647fc2b4e96eee1838e3b8
Ruby
danoguera/ruby_pro
/reto5.rb
UTF-8
920
3.828125
4
[]
no_license
class Guess attr_accessor :question, :answer def initialize question, answer @question = question @answer = answer end end class Play def game puts "Bienvenido a reto 5. Para jugar solo ingresa el termino correcto para cada una de las definiciones. Listo? Vamos!" puts "Definición" questions_answers=...
true
cb566e13e1e8d5a17103071430d008650b0a9829
Ruby
McKid/hwwyncodeproj
/homework2/quickfox.rb
UTF-8
153
2.875
3
[]
no_license
class QuickFox def jumped_over(arg1, arg2) end end lazy_dog = 1 daisy_log = " " quick_fox = QuickFox.new quick_fox.jumped_over(lazy_dog, daisy_log)
true
ff3c83fc13cf6c583c0087c7e1f8cdb018932aca
Ruby
kaiheiongaku/mtv_cribs
/lib/building.rb
UTF-8
1,126
3.375
3
[]
no_license
require './lib/apartment' class Building attr_reader :units def initialize @units = [] end def add_unit(unit) @units << unit end def renters name_array = [] @units.each do |unit| if unit.renter != nil name_array << unit.renter.name end end name_array end ...
true
3bb922f5a8576ec7e62bd0297def9d92e49d5b61
Ruby
tts-ws-2017/10-4-ruby
/team.rb
UTF-8
707
3.6875
4
[]
no_license
class Team attr_accessor :name, :ranking def initialize(name, ranking) @name = name @ranking = ranking end end @teams = [] def menu puts "Welcome" puts "1. Enter a team" puts "2. List teams" puts "0. Exit program" choice = gets.chomp.to_i case choice whe...
true
745e1db8fe3170c927a6ab67f651701403117d3f
Ruby
alismxwll/hero_tracker
/heros.rb
UTF-8
4,130
3.390625
3
[]
no_license
require 'active_record' require './lib/hero.rb' require './lib/colors.rb' require './lib/leagues.rb' require 'pry' database_configurations = YAML::load(File.open('./db/config.yml')) development_configuration = database_configurations['development'] ActiveRecord::Base.establish_connection(development_configuration) de...
true
32b48adeb95236215dabc8e4fedb46098a65ab5e
Ruby
Nirbhay1997/rspec
/spec/start_with_end_with_matchers_spec.rb
UTF-8
413
2.71875
3
[]
no_license
require 'rspec' RSpec.describe 'start with end with' do describe 'animal' do it 'we will check the woking' do expect(subject).to start_with('ani') end it 'one liner' do is_expected.to start_with('ani') end end describe [:a ,:b ,:c, :d] do it 'should check for elements at the...
true
e21d3ffca1dd3888d753933d289f4c3d83c533bb
Ruby
denolfe/spotify-album-art
/main.rb
UTF-8
1,552
2.71875
3
[]
no_license
# encoding: utf-8 require 'rautomation' require 'rspotify' require 'open-uri' require 'certified' # Resolves ssl issues when downloading image. http://stackoverflow.com/questions/10728436/opensslsslsslerror-ssl-connect-returned-1-errno-0-state-sslv3-read-server-c class Monitor attr_accessor :window, :title, :l...
true
9d8a49368244f38c789307136c30a3bcd2c5b4b9
Ruby
marten/swapr
/lib/agent.rb
UTF-8
2,732
2.65625
3
[]
no_license
require 'mongoid' Inital_pl = 0.5 Inital_pd = 0.5 class Agent include Mongoid::Document # field :id , type: Moped::BSON::ObjectId field :user_id, type: String, default: nil field :pl, type: Float, default: Inital_pl field :pd, type: Float, default: Inital_pd field :contribution...
true
3a91bccef1fa5688234cb05e3882a476dda220c7
Ruby
misterpk/Introduction-to-Programming-with-Ruby
/07_hashes/exercise_3.rb
UTF-8
166
3.3125
3
[]
no_license
person = { name: 'Bob', occupation: 'web developer', hobbies: 'painting' } puts person.keys puts person.values person.each { |k, v| puts "Key: #{k}, Value: #{v}" }
true
fae54dc77ea84bd2299c1cf311b8e1e13b41840e
Ruby
talum/espresso-shot
/hashes.rb
UTF-8
124
2.828125
3
[]
no_license
hash = { name: "Tracy", age: 25, dob: "August 15, 1989", favorite_boy_band: "BSB", } puts "#{hash[:name]} is so cool."
true
cdfbc3efda29380897b04471cb5c22cf02f36858
Ruby
rvictory/RaptorSecurityAnalytics
/consumers/dns_history_by_host.rb
UTF-8
2,762
2.578125
3
[]
no_license
# DNS History By Host: Reads Bro DNS events from the MapR Stream and updates aggregate information in MapR-DB # TODO: Change to MapR-DB Mutations instead of updating the whole document (concurrency issues) # TODO: Write Stats to a statistics stream # TODO: general cleanup include Java require_relative '../lib/streams_...
true
36244a8b58e0b92aa9ba9c4f50bc40ee37dffcfb
Ruby
jayqui/developer-exercise
/ruby/blackjack/spec/model_specs/round_spec.rb
UTF-8
334
2.671875
3
[]
no_license
require_relative "../../models/round" describe "Round" do let(:alice) { Player.new("Alice")} let(:ben) { Player.new("Ben")} let(:round) { Round.new([alice, ben]) } describe "the round" do it "each player should start with two cards" do round.hands.each do |hand| expect(hand.cards.count).to eq(2) end ...
true
7d1789f994a2f3ca3ab1ecdf277568230bcd3940
Ruby
SFEley/etapper
/spec/duplicate_account_search_spec.rb
UTF-8
2,091
2.5625
3
[ "MIT" ]
permissive
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Duplicate Account Search" do it "allows a name" do d = Etapper::DuplicateAccountSearch.new(:name => "John Smith") d.name.should == "John Smith" end it "allows a phone number" do d = Etapper::DuplicateAccountSearch.new(:pho...
true
3fb58b1fdaaa7c15cf895168eaf95e1ef129e5e5
Ruby
iddumied/MIMA
/lib/MIMA/Register.rb
UTF-8
2,746
3.515625
4
[]
no_license
module MIMA ## # A Register is a MIMA bus component. # A Register can read and save the current state of # the bus pipes and also write its current state to the bus. # class Register ## # initialize this with a given name and number of pipes # it can read or write (default 24). # If the ...
true
ee4ee9f764b1cabf3941359e2b57cd75ebd814f0
Ruby
verdammelt/rangehash
/spec/rangehash_spec.rb
UTF-8
3,151
3.03125
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/spec_helper.rb' describe RangeHash do let(:rh) { RangeHash.new } let(:rh_with_default) { RangeHash.new(:default_value) } let(:rh_with_other) describe "[]" do it "allows bare fixnum keys" do rh[1] = :foo rh[1].should == :foo end it "allows ranges as...
true
e7d1e6e8f3b83fc26acf1932725dce038dc3b4c6
Ruby
thekindofme/price_grabber
/data_structures/category.rb
UTF-8
167
2.5625
3
[ "MIT" ]
permissive
module LPriceGrabber class Category attr_accessor :name, :url def to_s puts '' puts "name: #{@name}" puts "url: #{@url}" end end end
true
212c6ff482e93f2fb3de558ba03083076a7ec34e
Ruby
fahryfauzan/final_project_GG
/main.rb
UTF-8
1,617
2.609375
3
[]
no_license
require 'sinatra' require './controllers/user_controller.rb' require './controllers/post_controller.rb' get '/' do usercontrollers = UserController.new usercontrollers.show_all_users end get '/users/addUser' do usercontrollers = UserController.new usercontrollers.show_add_user end post '/users/creat...
true
b0aa4395884f8e1e538e55422ca389b5ab86c389
Ruby
mrlhumphreys/twisty_guide
/lib/cubic/facing_grid.rb
UTF-8
1,871
3.375
3
[]
no_license
require 'lib/face_parser' require 'lib/cubic/facing_square' module Cubic class FacingGrid def initialize(x:, y:, units:, squares: ) @x, @y = x, y @units = units @squares = case squares when String FaceParser.new(squares).to_a when Array squares else rai...
true
2878c6454a012cff95cd50194aa39a0d0e98722d
Ruby
patgraczyk/Ruby_project_plastic_tracker
/db/seeds.rb
UTF-8
2,093
2.890625
3
[]
no_license
require_relative("../models/tag.rb") require_relative("../models/plastic.rb") require_relative("../models/product.rb") require("pry-byebug") Product.delete_all() Tag.delete_all() Plastic.delete_all() tag1 = Tag.new({ "category" => "cosmetics" }) tag1.save tag2 = Tag.new({ "category" => "hot_drink" }) tag2.s...
true
48605b16da9466b2a60dc19404c0b523aec33399
Ruby
joramjacobi/euler
/prob40.rb
UTF-8
1,392
3.65625
4
[]
no_license
# Project Euler Problem 40: Champernowne's Constant # User: jmjacobi # # An irrational decimal fraction is created by concatenating the positive # integers: # 0.123456789101112131415161718192021... # # It can be seen that the 12th digit of the fractional part is 1. # # If dn represents the nth digit of the fractional...
true
84988b52ca0b5493aa1c2bd2dacd639e0d32b43d
Ruby
jcincotta22/odd_numbers
/code.rb
UTF-8
102
3.078125
3
[]
no_license
num = 0 while num <= 100 do if num % 2 != 0 puts num num += 1 else num += 1 end end
true