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
32876cfe966ed7eacf1e921f20edc47a5617c5f5
Ruby
vigetlabs/colonel_kurtz_ruby
/lib/colonel_kurtz/block/type.rb
UTF-8
297
2.859375
3
[ "MIT" ]
permissive
module ColonelKurtz class Block private class Type attr_reader :type def initialize(type) @type = type end def formatted_type type.gsub("-", "_").downcase end def to_sym formatted_type.to_sym end end end end
true
6585e8ed1737783843d5a9746c0b7697769c167b
Ruby
indepthae/indepth-core
/app/models/assessments/assessment_schedule.rb
UTF-8
4,365
2.53125
3
[ "Apache-2.0" ]
permissive
class AssessmentSchedule < ActiveRecord::Base attr_accessor :first_start_time, :first_end_time, :second_start_time, :second_end_time, :third_start_time, :third_end_time serialize :exam_timings serialize :mark_entry_last_date, Hash belongs_to :assessment_group belongs_to :course has_and_belongs_to_many :b...
true
65bbc18172eeb23f43eb1c1b750eecc238ec328b
Ruby
fnando/sublime-text-screencasts
/lib/track.rb
UTF-8
390
2.640625
3
[ "MIT" ]
permissive
class Track def initialize(file, default) @file = file @default = default end def src @file end def default? @default end def label case File.basename(@file) when 'mac.vtt' 'Mac' when 'linux.vtt' 'Linux' when 'win.vtt' 'Windows' when 'other.vtt' ...
true
d9b69f946224278b12d35f2f65512f856b2afa45
Ruby
UNC-Libraries/ROWR
/lib/rowr/command_line.rb
UTF-8
1,258
2.515625
3
[ "Apache-2.0" ]
permissive
require 'rowr' require 'tty-prompt' module Rowr class CommandLine < Thor desc 'start', 'resurrect a really old website' def start rowr = Rowr::Resurrector.new rowr.start end desc 'continue', 'continue resurrecting' def continue rowr = Rowr::Resurrector.new...
true
c806f60426788898a6f3381972ece86cc3844264
Ruby
seenevz/the-bachelor-todo-london-web-121018
/lib/bachelor.rb
UTF-8
1,255
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" def get_first_name_of_season_winner(data, season) winner = [] data[season].each do |contestant| contestant.each do |key, value| if contestant["status"] == "Winner" winner = contestant["name"].split return winner[0] end end end end def get_contestant_name(data,...
true
2d5aa2bcdc44718843b7535b60169a0978e0a631
Ruby
syhsyh9696/Ruby
/Leetcode/maximum_subarray.rb
UTF-8
299
3.140625
3
[]
no_license
# encoding:utf-8 # @param {Integer[]} nums # @return {Integer} def max_sub_array(nums) max = nums[0]; submax = nums[0] 1.upto(nums.size - 1).each do |e| submax = 0 if submax < 0 submax += nums[e] max = submax if max < submax end max end
true
0d5e4f12a07eae4828841f8e057a0e399cc0d710
Ruby
parkermatheson/ruby_coding_exercises
/14feb18.rb
UTF-8
110
2.828125
3
[]
no_license
# interval 2 do # puts "hey there" # end 10.times do |i|(sec) p "#{i+1} mississippi..." sleep(sec) end
true
08dc7097a7920900025bcd1778351ba438a9e8bb
Ruby
ParkerJYoung/introtoruby_exercises
/methods/exercise1.rb
UTF-8
88
3.375
3
[]
no_license
def greeting(name) return "Good Afternoon" + " " + (name) end puts greeting("parker")
true
37712ab1ec743a0f658565692444f593b77a1ed3
Ruby
larb/email_address_validator
/lib/email_address_validator/rfc2822-parser.rb
UTF-8
57,924
2.78125
3
[ "MIT" ]
permissive
class EmailAddressValidator::RFC2822Parser # :stopdoc: # This is distinct from setup_parser so that a standalone parser # can redefine #initialize and still have access to the proper # parser setup code. def initialize(str, debug=false) setup_parser(str, debug) end # Prepares for par...
true
e1375ca4f78ffe60fdada282b3c58950f5cd2e76
Ruby
cyberplanner/equilibrium_index_exercise
/spec/equilibrium_spec.rb
UTF-8
896
3.15625
3
[]
no_license
require 'equilibrium' describe Equilibrium do let(:equilibrium) { described_class.new } it "has a solution method" do expect(equilibrium).to respond_to(:find_first_equilibrium).with(1).argument end describe "#solution" do context "if equilibrium index exists" do it "returns one of the equilibriu...
true
270eec8376dfe6070dbe0b8bb0b185181c009e9e
Ruby
aworldx/thinknetica
/lesson3/test.rb
UTF-8
3,096
3.34375
3
[]
no_license
require 'byebug' require './station' require './route' require './train' # station Имеет название, которое указывается при ее создании st1 = Station.new('Station 1') st2 = Station.new('Station 2') st3 = Station.new('Station 3') st4 = Station.new('Station 4') st5 = Station.new('Station 5') # Имеет номер (произвольная ...
true
12a261a26144074b7c4138dcd7af98162e0e784f
Ruby
bryanhou1/oo-student-scraper-v-000
/lib/scraper.rb
UTF-8
1,382
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'open-uri' require 'pry' class Scraper def self.scrape_index_page(index_url) doc = Nokogiri::HTML(open(index_url)) persons = doc.css("div.student-card") persons.collect {|person| hash = {name: person.css(".student-name").text, location: person.css(".student-location").text} hash[:prof...
true
46a20004f9176624d7dbefce6272f954b37300bb
Ruby
snayak-rails/ruby_programs
/star_pyramid.rb
UTF-8
133
2.734375
3
[]
no_license
for i in 1..5 for j in i.upto(5) print " " end for x in 1..((i*2)-1) print "*" end print "\n" end
true
f2fb6c60834d8f387cb3eeef159c1b2a4b98dfb6
Ruby
fs-labs/my-select-nyc-web-060418
/lib/my_select.rb
UTF-8
193
3.0625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_select(collection) i = 0 new_collection = [] while collection.length != i if yield(collection[i]) new_collection << collection[i] end i += 1 end new_collection end
true
3107e3a22de7230bceaa0dfc7e23f9f064846206
Ruby
MauricioGarc1a/beer
/un-split-bar.rb
UTF-8
1,980
3.953125
4
[]
no_license
class Beer # We ONLY want to be able to read @amount, not # change it without calling "sip!" attr_reader :amount def initialize @amount = 250 end def sip! if @amount > 0 puts "Slorp!" @amount -= 25 end end end class Person def initialize(name) @name = name end def gre...
true
435633c7a210e58aabd05ce9727ad37f7b56494a
Ruby
frank-mck/boris_bikes
/spec/docking_station_spec.rb
UTF-8
1,856
3.0625
3
[]
no_license
require 'docking_station' describe DockingStation do let(:bike) { double(:bike) } #it { is_expected.to respond_to(:bikes) } describe '#initialize' do it 'creates an instance of object with a specified capacity' do docking_station = DockingStation.new(40) 40.times { docking_station.dock(bik...
true
71f8ef12133453fb601115609d4343ac42cf88f1
Ruby
jmuldvp/ltc-ruby
/4/length_size.rb
UTF-8
226
3.578125
4
[]
no_license
a = "Hello world" b = "Hi, my name is Ruby!" c = " " d = "" p a.length p b.length p c.length p d.length puts p a.size p b.size p c.size p d.size puts p a.length.class p a.length.next p a.length.odd? p a.length.odd?.class
true
b90dd52c7c05b0ecc25860674a7291effa34c2f8
Ruby
alacaba/xbox-storeparser
/lib/xbox/storeparser/item.rb
UTF-8
1,558
2.640625
3
[ "MIT" ]
permissive
module Xbox module Storeparser class Item attr_accessor :item, :price, :box_art, :title, :discount, :boxart_section, :price_section, :amount, :currency, :store_link def initialize(item) @item = item end def price_section section = item.css('.sp_offer') ...
true
23794cc57de478923a1f7d155e1892f810e8f573
Ruby
epwortham/rails-longest-word-game
/app/controllers/games_controller.rb
UTF-8
1,636
3.328125
3
[]
no_license
require "open-uri" class GamesController < ApplicationController VOWELS = %w(A E I O U Y) def new @letters = Array.new(4) { VOWELS.sample } @letters += Array.new(6) { (('A'..'Z').to_a - VOWELS).sample } @letters.shuffle! end def score @letters = params[:letters].split @word = (params[:wor...
true
079d349a7231dc5365b0461342293606c25ede11
Ruby
jeremitu/RubyCLR
/Src/Ruby/help.rb
UTF-8
8,670
3
3
[ "MIT" ]
permissive
# This file adds help functionality to RubyCLR. This is an example of a # plug-in, which will be dropped into a plug-in API later on. Code in this file # can safely use any feature of RubyCLR. include System TYPE_COLOR = ConsoleColor::White EXCEPTION_COLOR = ConsoleColor::Yellow PARAMETER_COLOR = Console...
true
b00b6294640a3b58747271cb4dbe9cd7e37ae60c
Ruby
CharlesHarley/SquareBasher
/square_basher.rb
UTF-8
2,270
4.09375
4
[]
no_license
#!/usr/bin/env ruby -w class SquareBasher FIRST_SET_COUNT = 2500 SECOND_SET_COUNT = 2499 def solve min_start = 0 max_start = 100000000 smallest_number = find_matching_totals(min_start, max_start) if smallest_number != -1 puts "Found matching totals!" puts "Smallest number is #{sma...
true
5c93973f3ba344e608c22fd2bdaf48762e045f74
Ruby
bjjb/itunes
/lib/itunes/application.rb
UTF-8
1,099
2.625
3
[ "MIT" ]
permissive
require 'itunes/commands' require 'itunes/parser' require 'itunes/track' module ITunes class Application include Commands # Make a new Application def initialize(config = {}) @config = @@defaults.merge(config) end # See ITunes::Commands#osascript attr_accessor :callback # Asks iT...
true
e2c091a44c1ee86c7c3b5389371fe7de0fca653a
Ruby
howmuchcomputer/satestate
/lib/satellite/lib/satellite/configuration.rb
UTF-8
730
2.5625
3
[]
no_license
module Satellite class Configuration attr_accessor :url, :data_key, :health_sample_size, :stats_sample_size, :seconds_for_recovery, :altitude_stability, :health_status def initialize @url = 'http...
true
8e6abba457d05725d92450b5dcec6c8a86fd691e
Ruby
yokoyan/atcoder_problems
/abc111/a.rb
UTF-8
57
2.984375
3
[]
no_license
n = gets.chomp.to_s puts n.gsub(/[19]/,"1"=>"9","9"=>"1")
true
d280446548f7ba5a8b5f39d3b74ab49772a9f2ce
Ruby
Dm1trySt/viselitsa
/spec/game_spec.rb
UTF-8
1,152
2.984375
3
[]
no_license
require 'rspec' require './game.rb' describe 'Game' do # Победа без ошибок it 'should win' do # Загадываем слово game = Game.new('слово') # Убедимся, что статус игры - игра в процессе expect(game.status).to eq 0 # Внесем правильные буквы для проверки при 100% правильном ответе game.nex...
true
89a6a3e5078cc32cb12bd68dce2b969ebaaec541
Ruby
snepote/ruby
/playground/decorator.rb
UTF-8
345
3.296875
3
[]
no_license
require 'delegate' require 'date' class Person def born_on Date.new(1977, 12, 18) end end class PersonDecorator < SimpleDelegator def birth_year born_on.year end end decorated_person = PersonDecorator.new(Person.new) puts decorated_person.birth_year #=> 1989 puts decorated_person.__g...
true
5e81581deae53e65f0f5f70880f3eb3493c31408
Ruby
aonashi/jpstation
/lib/jpstation/import.rb
UTF-8
1,439
2.625
3
[ "MIT" ]
permissive
module Jpstation class Import def execute if ENV["FILE_DIR"].blank? puts "Specify FILE_DIR arguments." puts "rake jpstation:import FILE_DIR=/path/to/jpstation_dir" else file_dir = ENV["FILE_DIR"] company_files = Dir.glob(File.join(file_dir, 'company*.csv')) lin...
true
d04141d0aa6693877e0462b87bd5b0120a6fd5cf
Ruby
huydx/lfruit
/lib/lfruit/crawler.rb
UTF-8
1,738
2.515625
3
[ "MIT" ]
permissive
require "pry" module Lfruit class Crawler include DefaultValue include LDebugger attr_accessor :crawl_queue, :location_controller, :base_url, :limit, :queue, :filter, :finished_queue, :pattern def initialize(option) queue_size = option.parallel_num ||...
true
b3810796d5df6c3337a3c2b53eac241be1c3ba99
Ruby
bjtj/tjsamples
/ruby/rakefile/Rakefile
UTF-8
1,067
2.5625
3
[]
no_license
# coding: utf-8 desc "Print reminder about eating more fruit." task :apple do puts "Eat more apples!" end task :clean_cache do # Careful with rm_r (remove with recursion) as it will delete files without confirmation rm_r FileList["tmp/cache/*"] end task :import do puts "Importing data..." Dir.chdir(Rails...
true
0564b41152ffcd83d40232003d210dde9e150885
Ruby
mbeaudin/puppet
/lib/puppet/pops/types/p_error_type.rb
UTF-8
4,259
2.59375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Puppet::Pops module Types class PErrorType < PAnyType DEFAULT_ISSUE_CODE = 'ERROR'.freeze class Error include PuppetObject attr_reader :message, :kind, :issue_code, :partial_result, :details def self._pcore_type return PErrorType::DEFAULT end def self.from_hash(hash) self....
true
7ad79f70d3b73066b7f41214ec3baae91bde82d0
Ruby
ytaras/fool-game
/.watchr
UTF-8
3,099
2.59375
3
[]
no_license
require 'rubygems' # TODO Use libnotify require 'gir_ffi' # If your spec runner is at a different location: customize it here.. RSPEC_RUNNER = "bundle exec rspec" unless defined?(RSPEC_RUNNER) JASMINE_RUNNER = "bundle exec jasmine-headless-webkit --color" unless defined?(JASMINE_RUNNER) GirFFI.setup :Notify Notify.in...
true
169987ec44913edcc60ac73dd038574c0411bb97
Ruby
smartcamp/tdd-workshop200205
/sc_yhaguri_tkgwy/spec/lib/company_spec.rb
UTF-8
1,031
2.6875
3
[ "Apache-2.0" ]
permissive
require "date" describe Company do let(:today) { Date.today } let(:word_product) { Product.new(name: 'MS Word', type: 'W', price: 18_800) } let(:word_contract) { Contract.new(product: word_product, signed_on: today) } let(:excel_product) { Product.new(name: 'MS Excel', type: 'S', price: 27_800) } let(:excel_c...
true
8d3f14bcaaf33e7f4e19d241a05694c4c5aa0e04
Ruby
saheb222/ruby_practice
/basics/class_inheritance.rb
UTF-8
463
3.921875
4
[]
no_license
class Car attr_accessor :name, :price def initialize(name,price) @name = name @price = price end def parent "car name: #{@name} and price: #{@price}" end def speed "max speed is 160KMPH" end end class MyCar < Car def speed "MyCar max speed is 200KMPH" end end car_obj = Car.new("jaguar"...
true
d5584599efbb0236f807d5b6ca1b7a37d3624ac6
Ruby
nolan-m/ruby-projects
/to-do-list/spec/to_do_spec.rb
UTF-8
2,040
3.15625
3
[]
no_license
require 'rspec' require 'task' require 'list' describe Task do it 'should initialize the Task with a description' do new_task = Task.new('wash the car', '02/23/12', '1') new_task.should be_an_instance_of Task end it 'lets you read the description' do new_task = Task.new('wash the car','02/23/12', '1...
true
2ef039b43186ae0d76e4ec59e9e0c556a71131af
Ruby
tansaku/tictactoe
/lib/board.rb
UTF-8
1,571
3.265625
3
[]
no_license
class Board attr_reader :winner attr_accessor :game_state def initialize @board_template = File.read('./lib/board_template.txt') @game_state = {} end def current_state @board_template.gsub(/A1/,game_state.fetch(:A1,' ')) .gsub(/B1/,game_state.fetch(:B1,' ')) ...
true
0b7ade8b00f0ec5f95617d7e365c8388f7e56597
Ruby
TeWu/TWG4
/lib/twg4/authentication/auth_proxy.rb
UTF-8
1,124
2.59375
3
[ "MIT" ]
permissive
module TWG4 module Authentication class AuthProxy COOKIE_NAME = 'armt3' COOKIE_VALIDITY_PERIOD_COOKIE = 2663810.seconds # Random number COOKIE_VALIDITY_PERIOD_AUTH = 3004475.seconds # _DIFFERENT_ random number, but close to the first one (within few days) CURRENT_USER_ID_KEY = 'user_id' ...
true
7af2165e2fbc2f530f178846085659dd56646109
Ruby
awesome-academy/ruby-oe-34-library-management
/app/helpers/book_helper.rb
UTF-8
1,347
2.53125
3
[]
no_license
module BookHelper def show_category_name book cate_name = book.categories.name # Check category have parent category or not value_parent_id = book.categories.parent_id while value_parent_id.present? cate_parent = Categories.find_by id: value_parent_id cate_name += " - #{cate_parent.name}" ...
true
df3ef7541f14b5a21dade1b9da7360868e62c597
Ruby
EdHolanda/Desafio21Dias_Ruby
/multipla_escolha2.rb
UTF-8
390
3.453125
3
[]
no_license
puts "Digite uma opção (1..3)" opcao = gets.to_i case opcao when 1 fruta = "Banana" valor = 3.5 when 2 fruta = "Maca" valor = 4.5 when 3 fruta = "Pera" valor = 6 else fruta = "Opção inválida" end if fruta == "Opção inválida" puts fruta else puts "A fruta escolhid...
true
ba3625500f28cef87187442c0db8ad4e9f372523
Ruby
opencampground/OpenCampground
/test/unit/payment_test.rb
UTF-8
501
2.578125
3
[]
no_license
require 'test_helper' class PaymentTest < ActiveSupport::TestCase def test_taxes r = Reservation.create! :total => 105.0, :tax_amount => 5.0, :startdate => Date.today, :enddate => Date.today + 1 p = Payment.new :reservation_id => r.id, :amount => 105.0 net, tax = p.taxes assert net.round == 100.0 ...
true
c01c712795ffcb295ae675baa63b28cd76f8b4a8
Ruby
Fustrate/baseballbot_discord
/game_chat_bot/game_channel.rb
UTF-8
3,876
2.671875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'concerns/alerts' require_relative 'concerns/color_feed' require_relative 'concerns/game_feed' require_relative 'concerns/line_score' require_relative 'concerns/plays' require_relative '../shared/output_helpers' module GameChatBot # Handles everything related to havin...
true
78232d61a5b1218f20407a16ee120b324bb63df8
Ruby
shadefinale/assignment_mastermind
/renderer.rb
UTF-8
351
3.78125
4
[]
no_license
# Renderer draws the board state to the player. class Renderer def initialize(board) @guesses = board.guesses @hints = board.hints end def draw puts (" " * 16) + "The Board" puts (" " * 7) + ("Choice") + (" " * 17) + ("Hint") @guesses.length.times do |val| puts "#{@guesses[val]} #{@h...
true
6691a5af517176e09b598471eb6328cf4c6a84c0
Ruby
Byron-Mo/appacademy-ruby
/w2d3/exercises/lib/my_transpose.rb
UTF-8
254
3.34375
3
[]
no_license
class Array def my_transpose transposed = Array.new(self.first.size) { Array.new(self.size)} self.each_with_index do |row, idx| row.each_with_index do |el, jdx| transposed[jdx][idx] = el end end transposed end end
true
1ad2776890488b8f39b0af51dce1ccad52d52b88
Ruby
watsy0007/kindleSplit
/yinxiang.rb
UTF-8
3,873
2.828125
3
[ "MIT" ]
permissive
require 'digest/md5' require 'evernote-thrift' authToken = "S=s1:U=8f7d9:E=14fe066853b:C=14888b557f8:P=1cd:A=en-devtoken:V=2:H=c2c5102ba7ea19f3f764c0adbe04ed25" evernoteHost = "sandbox.evernote.com" userStoreUrl = "https://#{evernoteHost}/edam/user" userStoreTransport = Thrift::HTTPClientTransport.new(userStoreUrl) ...
true
1d85819a8d5edff15494852d632c981cc22d0dfe
Ruby
jrobertson/hidg0
/lib/hidg0.rb
UTF-8
12,932
2.796875
3
[]
no_license
#!/usr/bin/env ruby # file: hidg0.rb # description: Used with a Raspberry PI Zero plugged into a computer to act as USB Keyboard (HID) # This gem was made possible thanks to the code from [Turn Your Raspberry Pi Zero into a USB Keyboard (HID)](https://randomnerdtutorials.com/raspberry-pi-zero-usb-keyboard-hid/) # T...
true
20006b7ea6d8a3277327de70842ae758a1715767
Ruby
joshspicer/aug-31-rails-training
/test/models/movie_test.rb
UTF-8
2,351
2.703125
3
[]
no_license
require 'test_helper' class MovieTest < ActiveSupport::TestCase test "movie has a color format" do movie = create(:movie) assert movie.color?, "should be color" refute movie.black_and_white?, "should not be black and white" assert_equal "color", movie.color_format movie.black_and_white! as...
true
1a930b5dfb151592328ce5a93c37bcce7db7b1a1
Ruby
uni51/dic-ruby-basic
/algorithm_exercise3.rb
UTF-8
718
4.09375
4
[]
no_license
def sort_algo(sample_list) if sample_list.instance_of?(Array) # 引数が配列かどうかチェックする first_element = sample_list.first # 配列の先頭の要素を抽出 last_element = sample_list.last # 配列の末尾の要素を抽出 sample_list.delete_at(0) # 配列の先頭の要素を削除 sample_list.delete_at(-1) # 配列の末尾の要素を削除 sample_list.unshift(last_element) # 配列の先頭に末...
true
632641f00ed9a715a00b899a34dd3230fbd786ad
Ruby
alexiatanguy/PriceScrapper
/bot_debenhams.rb
UTF-8
1,749
2.796875
3
[]
no_license
require 'selenium-webdriver' require 'nokogiri' require 'capybara' require_relative 'colors' class Debenhams Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new(app, browser: :chrome) end Capybara.javascript_driver = :chrome Capybara.configure do |config| config.default_max_wait...
true
5cea7e33f5e8da6155273014ebc2299382561c45
Ruby
msynko/ruby_fundamentals1
/Desktop/Projects/Dec19-RE/exercise.rb
UTF-8
1,607
4.25
4
[]
no_license
def check_syntax(str) openables = { "(" => ")", "[" => "]", "{" => "}" } open = [] opening_chars = openables.keys closing_chars = openables.values str.each_char do |char| if opening_chars.include?(char) # opening bracket open << char elsif closing_chars.include?(char) # closing...
true
f7012f308e5cd6a4e27196d4a7f8d247a3ea83ad
Ruby
sobinsunny/puzzles
/Problem 1/are_anagram.rb
UTF-8
220
3.125
3
[]
no_license
module AreAnagrams def self.are_anagrams?(string_a, string_b) raise NotImplementedError, 'Not implemented' if string_b.strip.empty? || string_b.strip.empty? string_a.chars.sort == string_b.chars.sort end end
true
dff5f5e219195f86379259ecf8fbbe1d6c1517d5
Ruby
uk-gov-mirror/hmcts.et1
/app/types/gds_date_type.rb
UTF-8
916
2.6875
3
[ "MIT" ]
permissive
class GdsDateType < ActiveRecord::Type::Date def cast(value) super(pre_process(value)) end def deserialize(value) cast(value) end private def pre_process(value) value = from_params(value) value = pre_process_date_hash(value) if value.is_a?(Hash) value end def from_params(value) ...
true
69bb7dfca569e5e1d06055d41d81987cacada56a
Ruby
Jswish02/looping-while-until-online-web-ft-090919
/lib/until.rb
UTF-8
114
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def using_until levitation_force = 6 levitation_force+= 1 until levitation_force == 10 puts "Wingardium Leviosa" end
true
e3c1597ea7c391169cae815bd41d2695c422dfc8
Ruby
benszucs/project-euler
/pe3.rb
UTF-8
142
3.03125
3
[]
no_license
# Largest prime factor n = 600851475143 counter = 2 while counter < n if n % counter == 0 n /= counter end counter += 1 end puts n
true
4427112b4b015c77f222b4eccbedffeb8bca4ef5
Ruby
kp1/exifparser
/lib/exifparser/makernote/sony.rb
UTF-8
17,931
2.515625
3
[ "Ruby", "BSD-2-Clause" ]
permissive
# # exifparser/makernote/sony.rb # require 'exifparser/tag' require 'exifparser/utils' module Exif module Tag module MakerNote # # 0x0102 - Image Quality # class SonyQuality < Base Quality = { 0 => "Raw", 1 => "Super Fine", 2 => "Fine", ...
true
22f655ed6400d1ce028407e67b9efc13b79bc85b
Ruby
alvarezp/curso-ruby-on-rails-1
/app/helpers/invoice_headers_helper.rb
UTF-8
253
2.53125
3
[]
no_license
module InvoiceHeadersHelper def humanize_bool(value) return "No" unless value "Yes" end def humanize_payment_mode(value) if value == 1 return "Cash" elsif value == 2 return "Check" end "Credit Card" end end
true
b5946eb48b6f37d3015e0c8053befe8d74be3b1c
Ruby
infuerno/one-name-study
/lib/gro_births_extractor.rb
UTF-8
690
2.96875
3
[]
no_license
class GroBirthsExtractor < GroExtractor Entry = Struct.new(:entry_id, :forenames, :surname, :mothers_maiden_name, :year, :quarter, :location, :volume, :page) do def to_s "#{entry_id},#{forenames},#{surname},#{mothers_maiden_name},#{year},#{quarter},#{location},#{volume},#{page}" end end def initial...
true
128d5599e809add9610683c38f679a7ba769315e
Ruby
audiodude/song-a-week
/app/models/website.rb
UTF-8
347
2.5625
3
[]
no_license
class Website < ActiveRecord::Base before_validation :prepend_http validates :url, presence: true, url: true def prepend_http # If the URL doesn't start with http://, and there's not some kind of # malformed http in there, then prepend it. if !(self.url =~ /^http:\/\//) self.url = 'http://' + s...
true
39ad7b11adde084375b8249148d78eea0424842d
Ruby
CoralineAda/sophia
/lib/gramercy/constructors/subject.rb
UTF-8
1,020
2.65625
3
[ "MIT" ]
permissive
module Gramercy module Constructors class Subject include PoroPlus attr_accessor :subject, :adjective def in_form self.send(subject_structure) end private def article Article.matching_plurality(self.subject).indefinite.sample.base_form end def ...
true
46013b739bcad5c16fb8aed1efdb382e94fefb3d
Ruby
lucianoq/adventofcode
/2017/4/main2.rb
UTF-8
187
2.953125
3
[]
no_license
puts $stdin.readlines.map { |line| line.split.map do |word| word.chars.sort.join end }.count { |word_list| word_list.uniq.size == word_list.size }
true
b5693ab23e13e117d86a5e95335a1dcc5c24a6a8
Ruby
david115896/essai_ruby
/exo_12.rb
UTF-8
108
3.09375
3
[]
no_license
puts "Bonjour, donnes moi un numero stp" print ">" num=gets.chomp.to_i i=1 num.times do puts i i=i+1 end
true
2956e42518eee161ccf252e06871b9898895086b
Ruby
melari/wstrip
/wstrip
UTF-8
1,899
3.03125
3
[]
no_license
#!/usr/bin/env ruby require 'terrun' class WStrip < TerminalRunner name "WStrip" param "input", "The file or directory of files to strip whitespace from." option "--help", 0, "", "Shows this help file." option "--recursive", 0, "", "Recursively get files from directories." option "--extension", 1, "<extens...
true
38ae39aad50c0da85c2c97709ad336cc231b5156
Ruby
hackur/github-repo-lister
/lib/tasks/scheduler.rake
UTF-8
1,516
2.546875
3
[]
no_license
desc "This task checks for changes to repositories and emails them to subscribed users." task :check_subscriptions => :environment do puts "Checking Subscriptions..." def perform(subscr_id, email, repos, github_user) # puts "\n\n\n------------------------------------------------------------\n" # puts...
true
610c2403364bcf0009ba3eba4aea5723671d3d5a
Ruby
jdashton/glowing-succotash
/daniel/AoC/spec/advent06_spec.rb
UTF-8
1,047
2.984375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'spec_helper' require_relative '../advent06' describe Advent06 do let(:input) do <<~DOC_END COM)B B)C C)D D)E E)F B)G G)H D)I E)J J)K K)L DOC_END .lines .map(&:chomp) end let(:input2) do ...
true
8f68935f4e5a3bab09d3be83428d69f18afdabf3
Ruby
alanvardy/exercism
/ruby/beer-song/beer_song.rb
UTF-8
805
3.640625
4
[]
no_license
module BeerSong class << self def recite(bottles, verses) @bottles = bottles result = '' loop do result << "#{pluralize.capitalize} on the wall, #{pluralize}.\n" result << "#{deal_with_beer} #{pluralize} on the wall.\n" verses -= 1 break if verses < 1 res...
true
e95b3e708c100290ce7ba40f9191e8cac98e7a91
Ruby
DannySantos/blockchain
/1blockchain.rb
UTF-8
2,914
3.671875
4
[]
no_license
require 'digest' require 'yaml' class Transaction attr_accessor :from_address attr_accessor :to_address attr_accessor :amount def initialize(from_address, to_address, amount) @from_address = from_address @to_address = to_address @amount = amount end end class Block attr_reader :timestamp ...
true
5264b8c08501430e2763ee791f4b52ba18b12525
Ruby
clarkgrubb/oksql
/sql_parse_test.rb
UTF-8
5,132
3.21875
3
[]
no_license
# coding: utf-8 require 'test/unit' require File.dirname(__FILE__) + '/sql_parse.rb' require 'pp' class SqlParseTest < Test::Unit::TestCase def setup @sql = SqlParse.new() end # simple test def test_01 stmts = @sql.parse(" select 'foo'; ") assert_equal(1, stmts.size) stmt = stmts[0] asser...
true
77338cdb711eecb4f75eab9d560edcf16a421ba1
Ruby
StanfordBioinformatics/gbsc_utils
/dnanexus_handoff/QC/publish_runs.rb
UTF-8
2,096
2.78125
3
[]
no_license
#!/usr/bin/env ruby class PublishRuns @@Program = "publish_runs.rb" @@Archive = "/srv/gs1/projects/scg/Archive/IlluminaRuns" def parse_args if ARGV.size < 1 puts "Usage: #{@@Program} run_dir [run_dir...]" exit 1 end end def parse_run_dir_w_lanes(run_dir_w_lanes) # Parse the run di...
true
30e6c9d562a86b8abca6651d9208050ca73457d1
Ruby
meh/failirc
/lib/failirc/common/events.rb
UTF-8
3,174
2.625
3
[]
no_license
#-- # copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org] # # this file is part of failirc. # # failirc is free software: you can redistribute it and/or modify # it under the terms of the gnu affero general public license as published # by the free software foundation, either version 3 of the license, or # (at y...
true
733a4893ccd55b7168042429ee17c015547d7af6
Ruby
mattted/dynamic-orm-lab-onl01-seng-ft-021020
/lib/interactive_record.rb
UTF-8
1,381
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative "../config/environment.rb" require 'active_support/inflector' class InteractiveRecord def self.table_name self.to_s.downcase.pluralize end def self.column_names DB[:conn].execute("PRAGMA table_info(#{self.table_name})").map { |column| column["name"] } end def initialize(attributes...
true
4a69c0ad2102dcecf39570dd202b512f4fb2edf2
Ruby
Naoki1126/Ruby_practice2
/Ruby_2.1.1/meta_pro_ruby/object_model/self.rb
UTF-8
307
3.859375
4
[]
no_license
class MyClass def testing_self @var = 10 # selfのインスタンス変数 my_method # self.my_methodと同じ self end def my_method @var = @var + 1 puts @var end end obj = MyClass.new puts obj.testing_self #=> #<MyClass:0x007fb2789330a0 @var = 11>
true
70ad2861f34e4530e7a5a0cb23cdfe772524ecd8
Ruby
UntouchableHarlan/-SalOfaSutton
/app/models/twitter_feeds.rb
UTF-8
597
2.59375
3
[]
no_license
class TwitterFeeds def initialize @client = Twitter::REST::Client.new do |config| config.consumer_key = "" config.consumer_secret = "" config.access_token = "" config.access_token_secret = "" end end def tweet @client.search("to:justinbieber...
true
256705ec45f6a6f4c0813f8f05b14d0d83ed4e86
Ruby
sammo1235/programming
/tortoise race.rb
UTF-8
2,164
3.890625
4
[]
no_license
=begin Two tortoises named A and B must run a race. A starts with an average speed of 720 feet per hour. Young B knows she runs faster than A, and furthermore has not finished her cabbage. When she starts, at last, she can see that A has a 70 feet lead but B's speed is 850 feet per hour. How long will it take B to cat...
true
45702cbdc65ebe061c7856dd1b89ca56891f8d0e
Ruby
Trevoke/pipboy
/features/step_definitions/filesystem_steps.rb
UTF-8
1,283
2.53125
3
[ "MIT" ]
permissive
require 'fileutils' require 'tempfile' require 'tmpdir' Given /^an empty home directory$/ do @homedir = Dir.mktmpdir end And /^an empty config directory$/ do @configdir = Dir.mktmpdir Pipboy.config do |c| c.config_dir = @configdir end end Given /^a file named "(.*?)" in the home directory$/ do |file| f...
true
08cd0b6fced66527a487b03ad1ed30f11e571f33
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/robot-name/4f90985e3c9a4f6bb94791da6247283a.rb
UTF-8
478
3.296875
3
[]
no_license
class NameEnumerator def initialize @enum = Enumerator.new do |enum| [*'A'..'Z'].each do |n1| [*'A'..'Z'].each do |n2| 1000.times { |n3| enum.yield "#{n1}#{n2}%03d"%n3 } end end raise "No more Names" end end def next @enum.next end end class Robot @...
true
a8cd4239979666e8b74ec9a2271fa02169c91eb7
Ruby
homeshift/OpenlyLocal
/app/models/boundary.rb
UTF-8
808
2.703125
3
[]
no_license
class Boundary < ActiveRecord::Base belongs_to :area, :polymorphic => true validates_presence_of :area_id, :area_type, :boundary_line # NB coords are assumed to be lat_longs. GeoRuby stores them as coords (x,y) -- where x = long, y = lat. We make up polygon (actually a square) going clockwise def bounding_bo...
true
8c80d96210b85d0aea539fea3e86c337aedf9ea3
Ruby
bradenmugg/brewery_app
/brewery_db_old.rb
UTF-8
4,862
2.75
3
[]
no_license
def search_abv puts "ABV" brewery_db = BreweryDB::Client.new do |config| config.api_key = "4f7bf24d4106c5da74ca6a05b276a883" end self.abvs = [] count = 0 abv = self.user_beer.abv.to_f abv_low = abv - 0.3 abv_high = abv + 0.3 beers_abv = brewery_db.beers.all(abv: "#{abv_low},#{a...
true
28424c7aaded4f4d8c3cb55832cf5b1e524cb79a
Ruby
LexieLoo82/Homework_week2_Karaoke
/room.rb
UTF-8
797
3.25
3
[]
no_license
class Room attr_accessor :room_name, :entry_fee, :songs def initialize(room_name, entry_fee, occupancy, songs) @room_name = room_name @entry_fee = entry_fee @occupancy = occupancy @songs = songs end def occupancy_count return @occupancy.count end def guest_checks_out() return @...
true
9c86dd96f898121e10ec44d765f25850b62b2a2b
Ruby
siteriaitaliana/SalaryCalc
/main.rb
UTF-8
3,981
3.28125
3
[]
no_license
### usage instructions: ## => From the CLI just digit: ruby main.rb #!/usr/bin/env ruby require "csv" require "date" class ProcessCSV attr_reader :csv_filename def checkProcessed? csv_file = CSV.read(csv_filename) csv_file.shift months_processed = [] salary...
true
4de93007e87563ac32dd629d54857654833f9d04
Ruby
mhamdani/movie-list-service
/app/services/movie_service.rb
UTF-8
1,231
2.703125
3
[]
no_license
# encoding: UTF-8 require 'faraday' class MovieService def fetch_movies(user_id) movies = [] url = 'http://localhost:7001/' response = Faraday.get(url, users: user_id) list = JSON.parse(response.body) conn = Faraday::Connection.new("http://localhost:7003") do |faraday| faraday.adapt...
true
c708d9d99b3cc452022859e3b62549a8c444c141
Ruby
thetpaingunicorn/binance_bot
/examples/check_future_endpoints.rb
UTF-8
1,027
2.59375
3
[]
no_license
require 'colorize' require 'binance' require 'eventmachine' require 'pry' require 'json' require 'net/ntp' require 'bigdecimal' require_relative '../source/secret_keys' # spot_rest = Binance::Client::REST.new api_key: api_key, secret_key: secret_key # spot_ws = Binance::Client::WebSocket.new future_rest...
true
c46dfb6cfd554e146fadbdde64cf8a932b4ea20c
Ruby
znz/benchmark_driver
/lib/benchmark/driver/yaml_parser.rb
UTF-8
1,839
2.671875
3
[ "MIT" ]
permissive
module Benchmark::Driver::YamlParser class << self # @param [String] prelude # @param [Integer,nil] loop_count # @param [String,Array<String,Hash{ Symbol => String }>,Hash{ Symbol => String }] benchmark # @return [Array<Benchmark::Driver::Configuration::Job>] def parse(prelude: '', loop_count: nil...
true
af52d818d6dceb8017984f4dfd123c111e97b177
Ruby
zofuthan/vertx-mail-client
/src/main/resources/vertx-mail/mail_service.rb
UTF-8
3,926
2.59375
3
[]
no_license
require 'vertx/util/utils.rb' # Generated from io.vertx.ext.mail.MailService module VertxMail # smtp mail service for vert.x # # this Interface provides the methods to be used by the application program and is used to # generate the service in other languages class MailService # @private # @param...
true
a06ae6875956912c5c543b6416b5fb0b1efbb0c1
Ruby
dannyrooks/ruby-enumerables-generalized-map-and-reduce-lab-atlanta-web-071519
/lib/my_code.rb
UTF-8
364
3.375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def map(source_array) new_array = [] i = 0 while i < source_array.length new_array[i] = yield source_array[i] i += 1 end return new_array end def reduce(source_array, starting_point = 0) new_array = [] i = 0 yield source_array.map while i < source_array.length do new_array[i] = yield source_...
true
4ba99f1015af36c3f99d84abbaf80e46d0e7d80b
Ruby
cshtdd/truecrypt
/rakefile.rb
UTF-8
3,907
2.75
3
[]
no_license
task :default => [:help] def settings_file_path current_dir = File.expand_path(File.dirname(__FILE__)) settings_path = File.join(current_dir, './.settings') File.expand_path(settings_path) end def encrypted_file unless File.exists? settings_file_path raise "Settings file not found at '#{settin...
true
bacae96acc32b2164cab37615799ffc3f86e3f62
Ruby
mattbehan/exercises
/egg_drop.rb
UTF-8
4,303
4.03125
4
[]
no_license
# ---- PROMPT ----- # A building has 100 floors. One of the floors is the highest floor an egg can be dropped from without breaking. # If an egg is dropped from above that floor, it will break. If it is dropped from that floor or below, it will be completely undamaged and you can drop the egg again. # Given two eggs,...
true
ba4f9516dc1ab40d811a4476468c392e79d8aa89
Ruby
harshpoddar21/sar
/app/models/session.rb
UTF-8
497
2.84375
3
[]
no_license
class Session MORNING_SESSION=1 EVENING_SESSION=2 THRESHOLD_FOR_MORNING_SESSION=7*Constants::SECONDS_IN_HOUR def self.getCurrentSessionType if Time.now.to_i%Constants::SECONDS_IN_DAY > THRESHOLD_FOR_MORNING_SESSION return EVENING_SESSION else return MORNING_SESSION end end def self...
true
2cae4de9766fef58fe8f76f623371f846a76571b
Ruby
rbur004/rftp
/rftp.rb
UTF-8
8,122
3.046875
3
[]
no_license
#!/usr/bin/ruby require 'net/ftp' class NilClass def join(s) nil end end class FtpClient def initialize(host = nil) @binary = true @passive = false @ftp = nil open_remote_connection(host) shell end #Open a remote connection. #Ignore the port for now. def open_remote_connect...
true
3072f304e7eb37f165241ebc12e15cb75b90237f
Ruby
hanshasselberg/ec2-cmd
/ec2-cmd
UTF-8
1,626
2.875
3
[]
no_license
#!/usr/bin/env ruby require 'net/ssh' require 'open3' require 'rubygems' require 'thor' require 'term/ansicolor' C = Term::ANSIColor class Host attr_reader :name, :ip def self.all @hosts ||= `ec2-host`.lines.map{ |l| Host.new(l) } end def initialize(line) @name, @ip = line.split("\t").map(&:strip) ...
true
027f31df67d0746b4a62ad9ddc0f012674e66f48
Ruby
edhowland/viper
/minitest/lib/ext_assertions.rb
UTF-8
678
3.09375
3
[ "MIT" ]
permissive
# ext_assertions.rb: Extended assertions over MiniTest assert methods def assert_false obj assert obj == false end # TODO Remove me and replace with assert_equal def assert_eq val1, val2 assert_equal val1, val2 end # ditto. Replace with assert_equal def assert_equals val1, val2 assert_equal val1, val2 end # Poss...
true
4771971089123565ecf06c76a270c34f24f3eda1
Ruby
mostlyfine/webiblio
/lib/rakuten.rb
UTF-8
887
2.625
3
[]
no_license
require "open-uri" require "json" require "uri" class Rakuten attr_accessor :application_id def initialize(application_id) @application_id = application_id end def request(url) JSON.parse(open(url).read, symbolize_names: true) end def default_parameter {applicationId: application_id, formatV...
true
16bacadef859bd4df3f64ea326981bd124e1531d
Ruby
pombredanne/heuristics
/vendor/utils/timer.rb
UTF-8
711
2.578125
3
[]
no_license
module Utils module Timer def self.diff(t_1, t_2) ("%.3f" % (t_2 - t_1)).to_f end def time(msg = '', &block) t1 = Time.now puts msg yield t2 = Time.now diff = Timer.diff(t1, t2) puts " time #{diff}" puts "" diff end begin require ...
true
04a8c8abfb6152007af0f0bea1b4e40b3dcac0bb
Ruby
curriculet/onix
/lib/onix/list_writer.rb
UTF-8
1,335
2.703125
3
[ "MIT" ]
permissive
# coding: utf-8 module ONIX module ListWriter def list_writer(name, options = {}) options.symbolize_keys! unless options.is_a?(Hash) && options[:list].is_a?(Integer) raise ArgumentError, "Must specify code list number as ':list => Integer'" end define_method("#{name}=") do |value...
true
a15bb8fbb5e8de58f2abab8439ad48620652d7cd
Ruby
bcasadei/launch_school_exercises
/120_oop_easy_1/whats_the_output.rb
UTF-8
623
4.15625
4
[]
no_license
class Pet attr_reader :name def initialize(name) @name = name.to_s end def to_s "My name is #{@name.upcase}." end end # name = 'Fluffy' # Fluffy = Pet.new(name) # puts Fluffy.name # puts Fluffy # puts Fluffy.name # puts name name = 42 fluffy = Pet.new(name) # passes 42 into the class when instant...
true
6e32218015bc5a85b8a678fbe431922d394c99c7
Ruby
MattMatero/ToyLang
/lang/runtime/class.rb
UTF-8
665
2.78125
3
[]
no_license
class ClassTemplate < ObjectTemplate attr_reader :runtime_methods def initialize(superclass = nil) @runtime_methods = {} @runtime_class = Constants['Class'] @runtime_superclass = superclass end def lookup(method_name) method = @runtime_methods[method_name] unless method if @runtime_superc...
true
c2c23541c88567baa9cb7c54815124b856864f8a
Ruby
darkcode357/thg-framework
/lib/thg/util/thgcoreutils/script.rb
UTF-8
678
2.53125
3
[ "MIT" ]
permissive
# -*- coding: binary -*- module Rex ### # # This class provides an easy interface for loading and executing ruby # scripts. # ### module Script class Completed < ::RuntimeError end # # Reads the contents of the supplied file and exeutes them. # def self.execute_file(file, in_binding = nil) str = '' ...
true
f26aad3a5ab1f2be99351b615cce66354adbd562
Ruby
evakat/RoR
/dz3/kalkulyator.rb
UTF-8
564
3.4375
3
[]
no_license
puts "Введи число а" a = gets.to_f puts "теперь b" b = gets.to_f puts "Что с ними делать? Введи знак" vibor = gets.chomp # if vibor == "*" # s = a * b # elsif vibor == "+" # s = a + b # elsif vibor == "/" # s = a / b # elsif vibor == "-" # s = a - b # else # puts "Неверная операция" # end ...
true
27e6f2b3c0547306f2fa618723fe02de9f20a137
Ruby
jhspark17/W2D3
/spec_testing/spec/first_tdd_spec.rb
UTF-8
923
3.265625
3
[]
no_license
require 'first_tdd' require 'rspec' describe "#remove_dups" do it "should remove duplicate elements" do expect(remove_dups([1, 2, 1, 3, 3])).to eq([1,2,3]) end end RSpec.describe Array do describe "#two_sum" do it "returns all index pair that equal 0 in a n...
true
f987477d132d58ce832e56be08610e42f19805a0
Ruby
XavierDefontaine/Bank-Tech-Test
/lib/account.rb
UTF-8
713
3.40625
3
[]
no_license
# frozen_string_literal: true require_relative 'printer' require_relative 'transaction' class Account attr_reader :balance, :statement # Printer is the extracted module to call print_statement include Printer def initialize(balance = 0, transaction = Transaction) @transaction = transaction @balance ...
true
7ed7ae31cb1aa0016c2fcc4d36a380ab86c7253f
Ruby
jimlindstrom/multi_markov_composer
/tools/print_vector.rb
UTF-8
909
2.625
3
[]
no_license
#!/usr/bin/env ruby $LOAD_PATH << '.' require 'rubymusic_improv' vector_idx = ARGV[0].to_i puts "name: " + $fake_sensor_vectors.keys[vector_idx] vector = $fake_sensor_vectors.values[vector_idx] event_queue = MusicIR::EventQueue.new vector[:events].each { |e| event_queue.enqueue e } stimulus_notes = MusicIR::NoteQueu...
true
425e8fbb1095ffbce8c0dfb3340a534aaf7805ae
Ruby
AlbertGazizov/attr_validator
/lib/attr_validator/args_validator.rb
UTF-8
3,784
3.1875
3
[ "MIT" ]
permissive
# Helper class for arguments validation module AttrValidator::ArgsValidator class ArgError < StandardError; end class << self # Checks that specifid +obj+ is a symbol # @param obj some object # @param obj_name object's name, used to clarify error causer in exception def is_symbol!(obj, obj_name) ...
true
23e88aa340c39c90d35b9eb1436d1d166d7fc9ea
Ruby
laisee/nis-ruby
/lib/nis/struct/key_pair_view_model.rb
UTF-8
550
2.53125
3
[ "MIT" ]
permissive
class Nis::Struct # @attr [String] privateKey # @attr [String] publicKey # @attr [Nis::Unit::Address] address # @see https://nemproject.github.io/#keyPairViewModel class KeyPairViewModel include Nis::Util::Assignable attr_accessor :privateKey, :publicKey, :address alias :private_key :privateKey ...
true