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
a7bad44da4950c15b29d933635761c230e25f43f
Ruby
stevecreedon/retify-admin
/app/helpers/html_helper.rb
UTF-8
2,083
2.53125
3
[]
no_license
module HtmlHelper def love_form_helper(form, opts={}) HtmlHelper::LoveFormHelper.new(self, form, opts) end class LoveFormHelper def initialize(controller, form, opts={}) @form = form @model = form.object @controller = controller @opts = {class: 'input-xlarge'}.merge(opts) e...
true
723a2e6a200806f6a3acec389c3885a6efaee1fd
Ruby
stevefaeembra/week_02_day_5
/spec/venue_spec.rb
UTF-8
2,493
3.359375
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require_relative("../venue") require_relative("../room") require_relative("../group") class TestVenue < MiniTest::Test def setup @venue = Venue.new("The Hairbrush and Mirror", 1000.0) end def test_venue__exists assert_equal(Venue,@venue.class) end ...
true
fc0fcd8b763b89b98f9504b0e40ae875853c351a
Ruby
stogashi146/dmm-2
/lesson7-1.rb
UTF-8
208
3.65625
4
[]
no_license
puts "計算を始めます" puts "2つの値を入力してください" a = gets b = gets answer = a.to_i * b.to_i puts "計算結果を出力します" puts "a*b=#{answer}" puts "計算を終了します"
true
a099a7af6a799ed09386b104b177e6bbabdeebc5
Ruby
Seva-Sh/RB130
/exercises/easy_1/3_missing_array.rb
UTF-8
788
3.96875
4
[]
no_license
# - Iterate over numbers # - start num first element in the array # - end num last element in the array # - iterate over each number adding 1 every iteration # - check if current number is included in the given array? # - if it it, go to the next, # - if it is not, add current number to a new array def missin...
true
c3239314ee04e59eefa506e61ccd3b4632eee8ca
Ruby
enowmbi/algorithms
/array_partition_1.rb
UTF-8
253
3.515625
4
[]
no_license
def array_partition(arr) arr = arr.sort! sum = 0 arr.each_with_index do |item,index| if index % 2 == 0 #getting the elements at the indices which are even, will be the minimum since array is 2n sum += item end end return sum end
true
7abb06fd65a664a140284a79d323f05137ff9cf7
Ruby
andygeek/my-blog-rails
/app/controllers/posts_controller.rb
UTF-8
3,692
2.703125
3
[]
no_license
class PostsController < ApplicationController # Sirve para ejecutar una accion antes de entrar al controlador # Cuando creamos una accion que puede modificar el comportamiento de un request usamos el ! # Aqui lo usamos en el authenticate_user. # y luego usamos el only para decir que solo debe ser ejecutado ant...
true
a3ea27e8729671452956100e8ea0c5fdc0d3a1dc
Ruby
sofiamay/test-first-ruby
/lib/01_temperature.rb
UTF-8
130
3.84375
4
[]
no_license
#Fahrenheit to Celsius def ftoc(temp) (temp - 32) * (5.0/9) end #Celsius to Fahrenheit def ctof(temp) temp * (9.0/5) + 32 end
true
dfda377005f79b3c1278505fb0deaf1dab8e6288
Ruby
jaw09/algorithm_for_practice
/ruby/move_zeros.rb
UTF-8
224
3.453125
3
[]
no_license
def move_zeroes(nums) num_of_zeroes = 0 new_array = [] nums.each do |n| if n == 0 num_of_zeroes += 1 else new_array.push n end end for i in 0..num_of_zeroes new_array.push 0 end end
true
556cfc1ed155eb1c0007b8580a3215f70a0652aa
Ruby
yangxin1994/yangxin
/app/models/issue_related/text_blank_issue.rb
UTF-8
1,286
3.21875
3
[]
no_license
require 'error_enum' require 'securerandom' #Besides the fields that all types questions have, text blank questions also have: # { # "min_length" : minimal length of the input text(Integer) # "max_length" : maximal length of the input text(Integer) # "has_multiple_line" : whether has multiple lines to input(Bo...
true
456acd6a78bbb7a32a1ddd1babe4bb6ff7f1e1d9
Ruby
quangdung92/rails2
/app/models/book.rb
UTF-8
1,656
2.6875
3
[]
no_license
class Book < ActiveRecord::Base belongs_to :location belongs_to :genre belongs_to :shop belongs_to :publisher attr_accessible :author, :book_name, :final_purchase, :final_sale, :inventory_number, :jan, :nation_sale, :price, :sale_number, :publisher_id, :shop_id, :genre_id, ...
true
25f110b8f125f365c77a206a7c68986c9c12243c
Ruby
benjimon24/stockportfolio
/app/models/portfolio.rb
UTF-8
589
2.984375
3
[]
no_license
class Portfolio < ApplicationRecord belongs_to :user has_many :stocks, dependent: :destroy validates :name, presence: true #validates :name, uniqueness: {scope: :user_id, message: "Portfolio with the name already exists!"} def current_value self.stocks.inject(0) {|total, stock| total += stock.current_v...
true
3450025a254d3cd6fd0648098f6b4604fc7dbefc
Ruby
jackmcc08/makershnd
/lib/user.rb
UTF-8
1,175
3.171875
3
[]
no_license
require_relative 'database_connection' require 'bcrypt' class User attr_reader :id, :email, :password, :name, :username def initialize(id, email, password, name, username) @id = id @email = email @password = password @name = name @username = username end def self.create(email, password, n...
true
69ab6780b24eae1d9cf28384840201b6d7ebf114
Ruby
mgborgman/intro_to_programming
/ch3_methods/exercise1.rb
UTF-8
85
3.453125
3
[]
no_license
def greeting(name) "Hey #{name}! Glad you could be here." end puts greeting("Matt")
true
5529f6a64fe1a7994162ddff2d2048d8ba92d6c9
Ruby
andrustory/cartoon-collections-online-web-pt-061019
/cartoon_collections.rb
UTF-8
442
3.40625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def roll_call_dwarves (array) array.each_with_index do |item, index| puts "#{index + 1}. #{item}" end end def summon_captain_planet (array) array.map do |item| "#{item.capitalize}!" end end def long_planeteer_calls (array) array.any? do |call| call.length > 4 end end def find_the_cheese (ar...
true
886aa2c2a20e8d2dd75175185217489ce71fac6a
Ruby
freddyfallon/lrthw
/chap37/ex37_break.rb
UTF-8
117
3.640625
4
[]
no_license
[1,2,3].each do |i| puts i # will break out of a loop if a condition is given or immediately break if i == 2 end
true
0ce0ecf9ec2ad521e53e63d3ce2810fc153106b6
Ruby
Ashley-Wright/unit2_apt_hunt
/apt_hunter
UTF-8
2,999
3.125
3
[]
no_license
#!/usr/bin/env ruby require_relative 'lib/environment' require_relative 'models/apartment_complex' require_relative 'models/apartment' require_relative 'lib/argument_parser' class ApartmentHunter attr_reader :options def initialize @options = Parser.parse @options[:command] = ARGV[0] @options[:table] ...
true
3fbf1ba02cf6aa4514e005b074dacda7f66f9af2
Ruby
Maxscores/enigma
/test/decryptor_test.rb
UTF-8
1,639
3
3
[]
no_license
require_relative 'test_helper' class DecryptorTest < Minitest::Test def test_class_initializes decryptor = Decryptor.new() assert_instance_of Decryptor, decryptor end def test_initializes_with_characters decryptor = Decryptor.new() assert_instance_of Hash, decryptor.characters end def tes...
true
d1c89c10cb090194eba9e8f1be18adc6ff1cbfcc
Ruby
josfervi/ruby_playground
/00-Before_first_coding_interview/00-practice_problems--prompts_and_solutions/solutions-MINE/04-time-conversion.rb
UTF-8
1,002
4.25
4
[]
no_license
# Write a method that will take in a number of minutes, and returns a # string that formats the number into `hours:minutes`. # # Difficulty: easy. # FUTURE FEATURE: could add a.m. , p.m. for good measure def time_conversion(minutes) # --minute string- right justify to a mini...
true
02a9dbaa949ac322ea4e1cc9d74e9792bc7e7e24
Ruby
victorskurihin/ruby
/stepic.org/Discrete_Math/Dainiak/1.8/Step_12/Step_12.rb
UTF-8
2,450
2.984375
3
[]
no_license
#!/usr/bin/env ruby # -*- coding: utf-8 -*- ################################################################################ # $Date$ # $Id$ # $Version: 0.1$ # $Revision: 8$ # $Author: Victor |Stalker| Skurikhin <stalker@quake.ru>$ ################################################################################ # Сколь...
true
b89b56a4a7d837c231c3186f043ce710c027d881
Ruby
jollopre/bambooing
/spec/bambooing/timesheet/clock/entry_spec.rb
UTF-8
2,591
2.53125
3
[ "MIT" ]
permissive
require 'spec_helper' require 'support/configuration_shared_context' RSpec.describe Bambooing::Timesheet::Clock::Entry do include_context 'configuration' let(:date) { Date.new(2019,05,25) } let(:start) { Time.new(date.year, date.month, date.day, 8, 30) } let(:_end) { Time.new(date.year, date.month, date.day, ...
true
cc27f57a5f75cb377839cc95efccda25bbfc2a97
Ruby
kgoettling/intro_to_programming
/ch9_more_Stuff/ex5_error_message.rb
UTF-8
380
3.921875
4
[]
no_license
# Why does the following code give us an error message when we run it? #def execute(block) # block.call #end #execute { puts "Hello from inside the execute method!" } #A: The variable parameter 'block' does not have an '&' in # front of it, so it is not a block object. It is just # a regular variable, so when y...
true
be6d3b692f98e9c2e3f1bfe9a336092254ea4d7b
Ruby
aubreymasten/trace_italian
/app/models/scene.rb
UTF-8
608
2.640625
3
[ "MIT" ]
permissive
class Scene < ApplicationRecord belongs_to :story, foreign_key: :story_id, optional: true has_many :choices, dependent: :destroy validates :title, :text, presence: true def get_desc (length) if self.text.length <= length self.text else self.text.slice(0,length-1).chomp(".").concat('...') ...
true
47a271614bb5d9c0238091062f6038776b83385b
Ruby
umd-lib/annual-staffing-request
/test/models/fiscal_year_test.rb
UTF-8
630
2.625
3
[]
no_license
# frozen_string_literal: true require 'test_helper' # Tests for the "User" model class FiscalYearTest < ActiveSupport::TestCase def format_fy(year) "FY#{year.to_s.match(/\d\d$/)}" end def setup @year = Time.zone.today.financial_year end test 'should return the correct values' do assert_equal F...
true
578a558b951d1002122d490f1919e47910b9de33
Ruby
QNester/hey-you
/lib/hey_you/builder/email.rb
UTF-8
1,212
2.578125
3
[]
no_license
require_relative '_base' module HeyYou class Builder class Email < Base attr_reader :subject, :body, :layout, :mailer_class, :mailer_method, :delivery_method, :body_parts def build @mailer_class = ch_data.fetch('mailer_class', nil) @mailer_method = ch_data.fetch('mailer_method', nil)...
true
a12e7cb858cb6ef55b55347a4199ad1792a79edd
Ruby
doudou/flexmock
/lib/flexmock/deprecated_methods.rb
UTF-8
1,849
2.53125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby #--- # Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com). # All rights reserved. # # Permission is granted for use, copying, modification, distribution, # and distribution of modified versions of this work as long as the # above copyright notice is included. #+++ class Module def flexm...
true
0e9cacf41ec442c166c41dc37d25f1050456ee93
Ruby
cielavenir/procon
/yukicoder/tyama_yukicoder1335.rb
UTF-8
45
2.796875
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby s=gets;puts gets.tr('0-9',s)
true
1e09cde8b0c1fe0efae3193b117fad7f0c47cc84
Ruby
sakane133/activerecord-tvland-dc-web-062419
/app/models/actor.rb
UTF-8
419
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Actor < ActiveRecord::Base has_many :characters has_many :shows, through: :characters def full_name "#{self.first_name} #{self.last_name}" end # Write a method in the `Actor` class, `#list_roles`, # that lists all of the characters that actor has. def list_roles self...
true
fea20899e4d3601044371991e02fe774bb7f8bb7
Ruby
sinefunc/proton
/lib/proton/cacheable.rb
UTF-8
895
2.640625
3
[ "MIT" ]
permissive
class Proton # Module: Cache module Cacheable def self.enable! @enabled = true end def self.disable! @enabled = false end def self.enabled?() !! @enabled end # Enable by default enable! def self.cache(*args) if enabled? @cache ||= Hash.new ...
true
93ed022ce2881934163a5c14230f721f9da7f931
Ruby
holywyvern/carbuncle
/gems/carbuncle-doc-ext/mrblib/array.rb
UTF-8
269
3.96875
4
[ "Apache-2.0" ]
permissive
# An Array represents a list of items in sequence. # To create new arrays usually you use it from literals. # @example # my_list = [1, 2, 3] # my_list is an Array of 3 elements # my_list[0] # => 1 Arrays start from 0. # my_list.first # => also 1. class Array end
true
77e362458aa378973b0d005a5f020ff47d9e3635
Ruby
kyungbaek/euler_solutions
/1-20/problem2.rb
UTF-8
192
3.71875
4
[]
no_license
sum = 0 def fib(n, mem = {}) if n == 0 || n == 1 return n end mem[n] = fib(n-1, mem) + fib(n-2, mem) end 34.times do |x| if fib(x) % 2 == 0 sum += fib(x) end end print sum
true
46f64a2a13459f480136db5d14c79a3881cebdb4
Ruby
dcantoran/ruby-advanced-class-methods-lab-online-web-sp-000
/lib/song.rb
UTF-8
1,361
3.359375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'pry' class Song attr_accessor :name, :artist_name @@all = [] def self.create song = self.new song.save song end def self.new_by_name(song_name) song = self.new song.name = song_name song end def self.create_by_name(song_name) song = self.create song.n...
true
b78bc110095c0626325217fdf12a915716d7c56b
Ruby
Hidayat-rivai/ruby_read
/getchar.rb
UTF-8
75
2.640625
3
[]
no_license
s = $stdin.getc(); puts s puts "jumlah #{s.length}" puts "kelas #{s.class}"
true
1a8115a26c5f482b59676f071800efa703c53dca
Ruby
onja302/email.JSON
/email.rb
UTF-8
921
2.515625
3
[]
no_license
require 'rubygems' require 'json' require 'nokogiri' require 'open-uri' #require "google_drive" #array = [] #mairie = Hash.new page = Nokogiri::HTML(open("http://annuaire-des-mairies.com/val-d-oise.html")) get_townhall_email = page.css('a[class = "lientxt"]').map{|a| "http://annuaire-des-mairies.com/"+ a["hr...
true
11e83ecb2c052ed49717db282b606f7aa8400977
Ruby
thib123/TPJ
/Notes/Ruby/sample_code/ex0505.rb
UTF-8
2,966
2.96875
3
[ "MIT" ]
permissive
# Sample code from Programing Ruby, page 276 #include "ruby.h" #include "cdjukebox.h" static VALUE cCDPlayer; // Helper function to free a vendor CDJukebox static void cd_free(void *p) { free_jukebox(p); } // Allocate a new CDPlayer object, wrapping // the vendor's CDJukebox structure static VALUE cd_alloc(VALUE...
true
2ea1b31a8a5c9b9a5c4ee67ace971224799a30bb
Ruby
lroal/Roald
/tortage/lib/change_list_cleaner.rb
UTF-8
449
2.828125
3
[]
no_license
class ChangeListCleaner def initialize(branches) @branches = branches end def clear_changelist @branches.each do |branch_name| puts "=== clearing changelist in #{branch_name} ===" cmd = "git checkout #{branch_name}_current" puts cmd `#{cmd}` cmd = "git tag -afm\"clear_...
true
1e4b47a94653fd0dffb7c6d33bbbfe47f4722ee8
Ruby
RussellHaley/CalendariumAnglicum
/spec/readme_spec.rb
UTF-8
1,217
2.765625
3
[]
no_license
require 'spec_helper' # erm... yes, copy-pasted from calendarium-romanum's spec suite class MarkdownDocument def initialize(str) @str = str end def each_ruby_example example = nil line = nil @str.each_line.with_index(1) do |l, i| if example.nil? if example_beginning?(l) e...
true
c7b8dd9c991a3980ecd28ecaec0fc7305bde8a26
Ruby
sanjuro/twitter_ruby
/spec/runner_spec.rb
UTF-8
736
2.59375
3
[]
no_license
require 'spec_helper' require 'runner' describe Runner do describe "public instance methods" do describe "#initialize" do it 'defaults to Printer if no interace is given' do expect(subject.printer).to be_a(Printer) end end describe "#run" do it 'checks the User file is not to...
true
7f7d982583efb198eb17fc094b5a747e15cd07fb
Ruby
lilaboc/hackerrank
/ruby/ruby-tutorials-object-method-parameters.rb
UTF-8
166
2.5625
3
[]
no_license
# https://www.hackerrank.com/challenges/ruby-tutorials-object-method-parameters # Enter your code here. Read input from STDIN. Print output to STDOUT a.range?(b, c)
true
daac779d146f14bf106407567b02eb3866bffe8d
Ruby
j-luong/oystercard
/lib/oystercard.rb
UTF-8
945
3.34375
3
[]
no_license
require_relative 'journey_log' class Oystercard MAX_BALANCE = 90 MIN_FARE = 1 MIN_AMOUNT = 1 attr_reader :balance attr_reader :journey attr_reader :journeys def initialize @balance = 0 @journeys = JourneyLog.new end def top_up(amount) raise "Maximum balance of £#{MAX_BALANCE} exceeded"...
true
b6e01ab2ca7e2cf598eb3eb46d951702b36595fe
Ruby
honnza/drops
/DTDBuilder.rb
UTF-8
3,492
2.859375
3
[]
no_license
require 'nokogiri' NX = Nokogiri::XML # Class definitions ############################################################ class Tag attr_accessor :name, :tag_rules, :attr_rules, :cdata_always, :cdata_sometimes def initialize name @name = name @tag_rules = {} @attr_rules = {} @cdata_always = true ...
true
fa593ba885b435b74424ad562d4527c3ba21f26b
Ruby
Keishiro308/sample-kakeibo
/app/models/item.rb
UTF-8
1,196
2.84375
3
[]
no_license
class Item < ApplicationRecord belongs_to :room belongs_to :user with_options presence: true do validates :value validates :category validates :date validates :room_id end validates :value, numericality: { only_integer: true } def start_time self.date end def self.caliculate_month_c...
true
1ea191332674006a39f0dc35c7d6af11cdf6c68e
Ruby
wasabibr/IFRN_RUBY
/questao_02.rb
UTF-8
274
4.0625
4
[]
no_license
=begin Crie um script em Ruby que lê um valor real em dólar, e converte o valor para reais. Considere que a cotação é US$ 1 = R$ 1,82. =end print "Digite o valor em dólar, para converter: " num_dolar = Float(gets.chomp) print "Valor em reais: " puts num_dolar * 1.82
true
12374be3f6d00e431f5f5b823183100470684a13
Ruby
harroyo0610/ejerciciosFase01
/nested_arrays2.rb
UTF-8
621
3.453125
3
[]
no_license
def table tabla = [["Nombre", "Edad", "Genero", "Grupo", "Calificaciones"], ["Rodrigo Garcia", 13, "Masculino", "Primero", [9,9,7,6,8]], ["Fernanda Gonzalez", 12, "Femenino", "Tercero", [6,9,8,6,8]], ["Luis Perez", 13, "Masculino", "Primero", [8,7,7,9,8]], ["Ana Espinosa",...
true
4294b710c4d61c0ffa6a465e7d929156830cec20
Ruby
tadasshi/green_monkey
/lib/green_monkey/ext/view_helper.rb
UTF-8
3,902
2.53125
3
[]
no_license
# coding: utf-8 require "chronic_duration" # Provides view helpers # time_tag with "datetime" support # time_tag_interval for time intervals # time_to_iso8601 time-period converter # mida_scope shortcut to build "itemscope" and "itemtype" attributes # breadcrumb_link_to makes a link with itemtype="http://data-vocabul...
true
67d074c1dabcaa2dfe40c0c74ccb334f1124fb6b
Ruby
sdimkov/OCR
/test/test.rb
UTF-8
3,283
3.21875
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'ffi' require 'yaml' LANG_PATH = ENV['OCR_TEST_LANG'] LIB_PATH = ENV['OCR_TEST_LIB'] # Add text effects String class class String def apply_code(code) "\e[#{code}m#{self}\e[0m" end def red() apply_code(31) end def green() apply_code(32) end def yel...
true
4e273e123fc3e0752a2b3d8dbe3b9edd0710c019
Ruby
ekylibre/active_list
/lib/active_list/helpers.rb
UTF-8
778
2.53125
3
[ "MIT" ]
permissive
module ActiveList module Helpers def recordify!(value, record_name) if value.is_a?(Symbol) record_name + '.' + value.to_s elsif value.is_a?(CodeString) '(' + value.gsub(/RECORD/, record_name) + ')' else raise ArgumentError, 'CodeString or Symbol must be given to be record...
true
2b250481fd1f3bb968ebace94e0ca344aa9e34db
Ruby
kanpou0108/launchschool
/Exercises/100_ruby_basics(Programming_Back-end_Prep)/06_UserInput/user_input_8_ans.rb
UTF-8
1,212
4.53125
5
[]
no_license
def valid_number?(number_string) number_string.to_i.to_s == number_string end numerator = nil loop do puts '>> Please enter the numerator:' numerator = gets.chomp break if valid_number?(numerator) puts '>> Invalid input. Only integers are allowed.' end denominator = nil loop do puts '>> Please enter the ...
true
c702ef5b180e58b15e3d97cc82e74025dcce40f5
Ruby
lambda/buildscript
/build_utils.rb
UTF-8
2,869
2.578125
3
[]
no_license
# @BEGIN_LICENSE # # Halyard - Multimedia authoring and playback system # Copyright 1993-2009 Trustees of Dartmouth College # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either versi...
true
9f63885e54b58fd1c18f5b077f1a54c6ca50cbe4
Ruby
chitoto/Ruby-blog
/test.rb
UTF-8
179
3.078125
3
[]
no_license
while true puts "タイトルを入力" blog_title = gets puts "本文を入力" blog_content = gets puts "Title : #{blog_title}" puts "Content: #{blog_content}" end
true
a0b1ab1eb575be1b64bae0b78db94638b0820495
Ruby
Jun-lo/tokinagara
/ex.0621.rb
UTF-8
937
3.5
4
[]
no_license
#-*- coding: utf-8 -*- #クラス数・各クラスの人数・全員の点数を読み込んで、点数の合計点と平均点を求めるプログラムを作成せよ。 point = [] a = [] print "クラス数:" input = gets classnum = input.to_i ninzu = 0 for i in 0..classnum - 1 print sprintf("\n%d組の人数:", i + 1) input = gets num = input.to_i a.push(num) point[i] = Array.new(a[i],0) ninzu += num for ...
true
b26cd80d6764f1d4c82dcbe60f932b5567ca662d
Ruby
rooreynolds/BlinkyTape_Ruby
/test_BlinkyTape.rb
UTF-8
276
2.671875
3
[]
no_license
require './BlinkyTape.rb' bt = BlinkyTape.new 60.times do |i| bt.sendPixel(i,i,i) end bt.show # sleep 2 # 20.times do |i| # bt.sendPixel(255,0,0) # bt.sendPixel(0,255,0) # bt.sendPixel(0,0,255) # end # bt.show # sleep 2 # bt.displayColor(255,255,255) bt.close
true
f00f330f844b1c634c8b85133f6546854a299fc9
Ruby
mame/world-flag-search
/scripts/fetcher.rb
UTF-8
2,716
2.671875
3
[]
no_license
require "open-uri" require "json" require "cgi" require "digest/md5" Dir.mkdir("cache") unless File.directory?("cache") Dir.mkdir("svg") unless File.directory?("svg") class Fetcher def fetch_json(url) cache = File.join("cache", Digest::MD5.hexdigest(url)) if File.readable?(cache) json = File.read(cach...
true
185ce936f43a936dcd4836ab5856413a4f2a8f80
Ruby
ess/brine
/lib/brine/commands/pull.rb
UTF-8
445
2.703125
3
[]
no_license
desc 'Pull features from Github' long_desc <<PULLDESC Pull features from Github If given an issue number, that issue will be written to a feature. If given a feature file, that feature will be updated from Github. If given no arguments, all issues are pulled as features. PULLDESC arg_name 'issue or feature', :option...
true
eda49a2d386f427aa6ab70fc9cee19995fd00385
Ruby
dwiesenberg/project_cli_blackjack
/lib/blackjack.rb
UTF-8
305
2.609375
3
[]
no_license
# Blackjack # program collector require './game' require './board' require './participant' require './dealer' require './player' require './deck' # Includes the Blackjack # module into the global # namespace include Blackjack # Play! puts "\nReady to play ... please wait" sleep(1) Game.new.play
true
368423750810a5f2178532401185f851961d7a08
Ruby
madking55/Turing_Back_End
/2module/intro_to_apis/film.rb
UTF-8
259
2.671875
3
[]
no_license
class Film attr_reader :title, :director, :producer, :rotten_tomatoes def initialize(film_data) @title = film_data[:title] @director = film_data[:director] @producer = film_data[:producer] @rotten_tomatoes = film_data[:rt_score] end end
true
ab133798213c6e8a6ff21502a521597208c2fe69
Ruby
adub65/js-rails-as-api-pokemon-teams-project-pca-001
/pokemon-teams-backend/app/models/pokemon.rb
UTF-8
248
2.65625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Pokemon < ApplicationRecord belongs_to :trainer validate :no_more_than_six_on_trainer private def no_more_than_six_on_trainer if trainer.pokemons.length >= 6 self.errors.add(:length, "Whoops!") false end end end
true
9042adf3bf9f8dc2a150c0f57a18b3080aab7e6a
Ruby
shelbipinkney/method-scope-lab-v-000
/lib/catch_phrase.rb
UTF-8
71
2.609375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def catch_phrase(phrase) puts phrase end #catch_phrase #puts phrase
true
66ce5b7a1be46436a6289815c158c315de2d108d
Ruby
ErikaJZhou/ICanHazBacon
/bacon.rb
UTF-8
104
3.453125
3
[ "MIT" ]
permissive
puts 'Haz bacon?' STDOUT.flush item = gets.chomp if item == 'bacon' puts 'Yup' else puts 'Nope' end
true
dad7d9e442bbdf520f64b58b7f370e8125414c70
Ruby
brady-robinson/Object-Oriented-Programming
/lesson_4/practice_easy_2/3.rb
UTF-8
437
3.546875
4
[]
no_license
module Taste def flavor(flavor) puts "#{flavor}" end end class Orange include Taste end class HotSauce include Taste end print Orange.ancestors print HotSauce.ancestors # The list of ancestor clases is also called a lookup chain, # because ruby will look for a method starting in the first class # in the...
true
1ce6feb0ae9459d338b1f3628663c104dddd6f60
Ruby
lexxeice/Task
/TaskProfitero.rb
UTF-8
1,499
2.875
3
[]
no_license
require 'curb' require 'nokogiri' require 'csv' # try to connect progressbar - optional start_time = Time.now url = ARGV[0] + "?p=#{(page_number = 1)}" || abort('Wrong URL') file = if ARGV[1].nil? then 'Petsonic.csv' elsif ARGV[1].end_with?('.csv') then ARGV[1] else ARGV[1] + '.csv' end puts 'Category page processing...
true
1a260ae77486e7a5b6df4d51a17aae9a39cb036c
Ruby
myokoym/runch
/lib/runch/command.rb
UTF-8
272
2.5625
3
[ "MIT" ]
permissive
require "runch/language" module Runch class Command class << self def run(*arguments) new.run(arguments) end end def initialize end def run(arguments) Language.create(arguments[0], arguments[1..-1]).run end end end
true
e6439e9680952560e33960767693441fbbfb33a1
Ruby
ipastushenko/TextFormatting
/ruby/reader.rb
UTF-8
360
3.265625
3
[ "MIT" ]
permissive
# Module formatting text module TextFormatting # The reader # @abstract class Reader # Calls the given block once for each character, # passing the character as an argument. # The stream must be opened for reading or an IOError will be raised. # If no block is given, an enumerator is returned inst...
true
6f3c7bae865387dae57933587b1700efd61e45a7
Ruby
juliancheal/AlexaOnRails
/lib/travis_api.rb
UTF-8
642
3.234375
3
[]
no_license
require 'travis' # They call him Travis, he has an API. class TravisAPI attr_reader :travis def initialize @travis = Travis::Client.new end def build_status(repo) repo = @travis.repo(repo) colour = repo.color response_string = "" case colour when "green" response_string = "Buil...
true
1e579528e0224eb52f3ee3dec03a04a42d417e9d
Ruby
sandagolcea/battle-ships-web
/spec/game_spec.rb
UTF-8
643
2.84375
3
[]
no_license
require 'game' describe Game do let(:player1){double :player} let(:player2){double :player} it 'can initialize a new game with two players' do end it 'should allow a player to place ships on his board' do end it 'should allow a player to look on his opponents board to see where he shot at wit...
true
f9e90ec4a8e86f95d3c5aebf4ce2a5e959175882
Ruby
samvera/hyrax
/app/services/hyrax/workflow/workflow_importer.rb
UTF-8
7,866
2.59375
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true module Hyrax module Workflow # Responsible for loading workflows from a data source. # # @see .load_workflows # @see .generate_from_json_file class WorkflowImporter class_attribute :default_logger self.default_logger = Hyrax.logger class_attribute :p...
true
8b0ba9a53a455f948143197612461abe89bd6664
Ruby
linrock/the-traveler
/app/models/scout.rb
UTF-8
3,027
2.859375
3
[]
no_license
# The scout explores unvisited domains and finds prospective # domains to visit in the future # class Scout LOG_FILE = "log/scout.log" BEANSTALK_HOST = "localhost:11300" MAX_QUEUE_SIZE = 20000 OUTPUT_TUBE = "domains_to_visit" def initialize(url = nil) @logger = ColorizedLogger.new(LOG_FILE)...
true
541fdca44fb738a2abd49d71c2119887f5846ec5
Ruby
LYoungJoo/CVE-in-Ruby
/CVE-2016-6210/cve-2016-6210_exploit.rb
UTF-8
964
2.8125
3
[]
no_license
#!/usr/bin/env ruby # # CVE-2016-6210 | OpenSSHd user enumeration # KING SABRI | @KINGSABRI # begin require 'net/ssh' rescue puts "[!] Install net-ssh gem\ngem install net-ssh" end if ARGV.size >= 1 host, port = ARGV[0].split(':') user_list = File.readlines ARGV[1] password = 'A' * 25000 else puts "...
true
5c1ac4ea4a87f7f05692fdf3aabb96b55272a548
Ruby
denio-rus/thinknetica-ruby
/lesson2/fibonacci.rb
UTF-8
134
2.921875
3
[]
no_license
fibonacci = [0] next_number = 1 until next_number > 100 fibonacci << next_number next_number = fibonacci[-1] + fibonacci[-2] end
true
abef4f6de0d9a24a4b3b63cb3f5aad36f751ab86
Ruby
andoshin11/twterm
/lib/twterm/tab/base.rb
UTF-8
1,676
2.71875
3
[ "MIT" ]
permissive
require 'twterm/event/screen/resize' require 'twterm/subscriber' module Twterm module Tab class Base include Curses include Subscriber attr_reader :window attr_accessor :title def ==(other) self.equal?(other) end def close unsubscribe window.cl...
true
ca77266109a96215ffcb2a804e16a73136718390
Ruby
kelseywaldo/cs-fundamentals
/concepts/recursion/iterative-exercises.rb
UTF-8
1,331
4.4375
4
[]
no_license
# reverse the elements in an integer array in place # time: O(n) / Linear - dependent on size of array # space: O(1) / Constant - variables independent of size of array def reverse(array) i = 0 j = array.length - 1 while i < j array[i], array[j] = array[j], array[i] i += 1 j -= 1 end return arra...
true
e1d974b078103fed734535da547b46828386273e
Ruby
SpaceOtterInSpace/RubyWarrior
/levelcode.rb
UTF-8
954
3.625
4
[]
no_license
#level 2 class Player def play_turn(warrior) if warrior.feel.empty? warrior.walk! else warrior.attack! end end end #level 3 class Player def play_turn(warrior) if warrior.feel.empty? if warrior.health < 20 warrior.rest! else warrior.walk! end el...
true
d7b87dbcb12fce2ab61c043d0e2d8792c2ff10c0
Ruby
JordanStafford/Ruby
/Ruby Practice Continued/Arrays/finding_the_index_element.rb
UTF-8
237
4.0625
4
[]
no_license
#finding the index of an element days_of_week.index("Wed") #starting at element 0 and working through days_of_week[1, 3] #specifying a range to index through days_of_week[1..3] #using the slice method instead days_of_week.slice(1..3)
true
e0a0fdd628c0ede73e1059e7b0f340b3cd77c784
Ruby
masao/p-album
/yaml-test.rb
UTF-8
580
2.90625
3
[]
no_license
#! /usr/local/bin/ruby # $Id$ require 'time' require 'exif' require 'yaml' def exif2hash (exif) hash = Hash.new exif.each_entry() {|tag, value| hash[tag] = value } return hash end metadata = YAML::load(File.open "metadata.yaml") exif = Exif.new(ARGV[0]) hash = exif2hash(exif) puts( { File::basename(ARGV...
true
cc558522f6d5952f4f0dbf20cb20ce1536d26100
Ruby
kuizor/server-todo
/0propedeutico/retos/resultados/04suma_50num_enteros.rb
UTF-8
221
3.328125
3
[]
no_license
#Escriba el código Ruby que calcule la suma de los 50 primeros números #enteros. puts "Partiendo los Enteros de 0" num = 0 i = 0 sum = 0 while (i <= 50) do num = num + 1 sum = sum + num i +=1 #puts ant end puts sum
true
e9ae269c95d38a9304cfd925a984bae4f376bd9a
Ruby
naiginod/Launch_School_Examples
/exercises1.rb
UTF-8
40
2.765625
3
[]
no_license
arr = Array(1..10) arr.each {|x| puts x}
true
5bd42ef0104785d3fd1b48cd39b349faa03ac0d6
Ruby
Lydias303/event_reporter-1
/lib/messages.rb
UTF-8
259
2.609375
3
[]
no_license
class Messages def help "Hey Im a help method!" end def intro_message "Welcome to Entry Repository. Please enter your first commmand." end def exit "exit" end def invalid_message "Invalid entry, please try again. " end end
true
6de8a52b7371441349eab42cf5c31e0ff2a47b0a
Ruby
n-gb/advent-of-code-2020
/dec14_1.rb
UTF-8
479
3.265625
3
[]
no_license
require_relative 'advent_data' data = AdventData.new(day: 14, session: ARGV[0]).get def masked(number, mask) and_mask = mask.gsub('X', '1').to_i(2) or_mask = mask.gsub('X', '0').to_i(2) ((number & and_mask) | or_mask) end mask = '' mem = [] data.each do |instruction| what, value = instruction.split(' = ') ...
true
2bf368c3e96acf43ad0cd4e70d947f55754f3e6c
Ruby
tvweinstock/ruby_fundamentals1
/exercise3.rb
UTF-8
155
4
4
[]
no_license
puts "What's your name?" name = gets.chomp puts "Hi #{name}!" puts "How old are you?" age = gets.chomp puts "Oh, so you were born in #{2014 - age.to_i}"
true
9f7ff3de074b243d3d351ab6924fcba043930df2
Ruby
brandonlilly/lantern
/lib/switch.rb
UTF-8
2,395
2.828125
3
[ "MIT" ]
permissive
require_relative 'store' require_relative 'actions' require_relative 'conditions' require_relative 'expressions/term' require_relative 'assignment' require_relative 'wrapper' class Switch include AndOr include StoreId include Term @@store = Store.new attr_accessor :inverted, :name, :switch_id def initial...
true
6e4677be8ab86e95e39d0096afbfea8cbc041495
Ruby
JohnsCurry/pre-course
/introduction_to_programming/loops_and_iterators/3ex.rb
UTF-8
128
3.453125
3
[]
no_license
arr = ['zero', 'one', 'two', 'three'] arr.each_with_index do |arr, index| puts "#{arr} has the numeric form of #{index}" end
true
079491bc345287db59181c35dc8ac3137ca557af
Ruby
bblimke/webmock
/lib/webmock/request_registry.rb
UTF-8
853
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module WebMock class RequestRegistry include Singleton attr_accessor :requested_signatures def initialize reset! end def reset! self.requested_signatures = Util::HashCounter.new end def times_executed(request_pattern) self.requested_sig...
true
f6ff02cf69bd9b2a50318b6c4ff9805950c8d883
Ruby
jbyrnesshay/launchschool_enrolled
/this_other_thing/review_more.rb
UTF-8
33,643
3.078125
3
[]
no_license
# my solution def triple_double(num1,num2) nums_1, nums_2 = num1.to_s.chars, num2.to_s.chars straight_triple = nums_1.select.with_index {|num, i| [nums_1[i+1], nums_1[i+2]].all? {|test| num == test} } matched_double = nums_2.select.with_index {|num, i| straight_triple.any? {|test| num == test} && num == nums_2[...
true
3804d8ab95edd5e4341e75b74884254966738d66
Ruby
relaxdiego/mign
/app/models/ability.rb
UTF-8
1,755
2.671875
3
[ "MIT" ]
permissive
class Ability include CanCan::Ability def initialize(user) # Define abilities for the passed in user here. For example: # # user ||= User.new # guest user (not logged in) # if user.admin? # can :manage, :all # else # can :read, :all # end # # The first argume...
true
ddfea7bb9fa25e445f6409389ad098dab5ff3d5c
Ruby
josegonzalez/ruby-cimino
/_plugins/tags/strip.rb
UTF-8
462
2.515625
3
[ "MIT" ]
permissive
# Title: StripTag # Source: https://github.com/aucor/jekyll-plugins/blob/master/strip.rb # Description: Replaces multiple newlines and whitespace between them with one newline # Usage: {% strip %}Content{% endstrip %} module Jekyll class StripTag < Liquid::Block def render(context) return super if Liquid::...
true
f58fdaef234da26cfa4b13819eeadd72eb6dd1b3
Ruby
yxlau/project_sinatra_dashboard
/models/company_profiler.rb
UTF-8
1,524
2.625
3
[]
no_license
class CompanyProfiler attr_reader :ratings def initialize(listings, ip) @listings = listings @ip = ip @ratings = [] end def get_company_ratings get_companies get_ratings end def get_companies @companies = [] @listings.each do |listing| unless @companies.include?(listing.c...
true
48be8e6787224f116bd3869a2fe37331951b4171
Ruby
Joecleverman/event-organizer-app
/app/models/event.rb
UTF-8
645
2.578125
3
[ "MIT" ]
permissive
class Event < ActiveRecord::Base belongs_to :user has_many :attenders, dependent: :destroy has_many :contractors, dependent: :destroy validates_presence_of :name def formatted_date self.date.strftime("%A %B %e, %Y") end def confirmed_attenders self.attenders....
true
2dc9206c7495299c955aa67e7d3d7057117e17b8
Ruby
jtanadi/LS-IntroRuby
/2-Variables/age.rb
UTF-8
159
3.78125
4
[]
no_license
puts "How old are you?" input_age = gets.chomp.to_i offset = 10 4.times do puts "In #{offset} years you will be:\n#{input_age + offset}" offset += 10 end
true
a37e4eb92a060cf1f8c8362abd21e631175b5549
Ruby
hpnguyen/demo_social
/app/workers/resque_log.rb
UTF-8
435
2.8125
3
[]
no_license
class ResqueLog @queue = :log_queue def self.perform(id, message) my_time = Time.now begin if message.kind_of?(Array) message.each do |item| puts "[#{my_time.to_datetime}] #{id} : #{item}" end else puts "[#{my_time.to_datetime}] #{id} : #{message}" end rescue Except...
true
cc4e028efd79f6b090c64a4e49c8b9274964a8af
Ruby
olsi2984/Ruby_Practice
/string_methods.rb
UTF-8
295
3.640625
4
[]
no_license
var1 = 'stop' var2 = 'STRESSED' var3 = 'Can you pronounce this sentence backwards?' puts var1.reverse puts var2.reverse puts var3.reverse puts var1.upcase puts var2.downcase puts var3.swapcase lineWidth = 50 puts var1.center(lineWidth) puts var2.center(lineWidth) puts var3.center(lineWidth)
true
ba270fe60da095bff052219041db7f15e93ca756
Ruby
kelvin8773/data-algorithm
/8-leetcode/078-sub_sets.rb
UTF-8
471
3.515625
4
[ "MIT" ]
permissive
# @param {Integer[]} nums # @return {Integer[][]} # Ruby build-in method for this challenge! def subsets_r(nums) result = [] for i in 0..nums.size result += nums.combination(i).to_a end result end def subsets(nums) return [[]] if nums.empty? curr_num = nums.shift results = subsets(nums) ...
true
9026ce1db64c5448a2f30acdd9c53f4b3c529aba
Ruby
littlegustv/redemption
/player.rb
UTF-8
9,855
2.90625
3
[]
no_license
class Player < Mobile # @return [TCPSocket, nil] The Client Connection. attr_reader :client # @return [Integer] The account ID associated with this player. attr_reader :account_id # # Player Initializer. # # @param [PlayerModel] player_model The model used to generate this player ...
true
564644b05517012871ef088416a0a42fc7231ec8
Ruby
Halvard75/thp-1
/WEEK_2/week2_day2/test/hash_spec.rb
UTF-8
4,084
3.203125
3
[]
no_license
=begin describe Hash do it "should return a blank instance" do Hash.new.should == {} end end describe Hash do before do @hash = Hash.new({:hello => 'world'}) end it "should return a blank instance" do Hash.new.should == {} end it "hash the correct information in a key" do @hash[:hello...
true
7f79e2e139929bd0d0955a8467c73e49b8f5261c
Ruby
shanecolby/conditionals_1.rb
/HashToArray6.rb
UTF-8
487
2.9375
3
[]
no_license
words = ["do", "or", "do", "not"] word_frequency = {} index = 0 while index < words.length word = words[index] if word_frequency[word] == nil word_frequency[word] = 0 end word_frequency[word] += 1 index += 1 end p word_frequency words = ["do", "or", "do", "not"] word_frequency = {} index = 0 while index...
true
9315204004e50557ba6ec10e1113230a8659eaab
Ruby
pabloroz/linked_lists
/problem_3/solution.rb
UTF-8
693
3.421875
3
[]
no_license
require './linked_list_node' require './list_infinite_detector' def print_values(list_node) print "#{list_node.value} --> " if list_node.next_node.nil? print "nil\n" return else print_values(list_node.next_node) end end node1 = LinkedListNode.new(37) node2 = LinkedListNode.new(99, node1) node3 = L...
true
257dce9476e90f8b8bcd55196435bdfbf6b3bcac
Ruby
bobzoller/muniup
/models.rb
UTF-8
3,936
2.65625
3
[]
no_license
require 'ostruct' require 'open-uri' require 'cgi' module Muniup class Config < OpenStruct def routes @routes ||= begin routes = [] super.each_with_index{|r, idx| routes[idx] = Route.new(idx, r)} routes end end end class Route < OpenStruct attr_accessor :id d...
true
96c5a1f086639dc5f95893c9a9bac0b927c3a9e2
Ruby
manish4uanand/toy_robot_simulator
/toy_robo.rb
UTF-8
406
3.171875
3
[]
no_license
require_relative 'simulator' simulator = Simulator.new puts "Please enter valid commands, which are as follows:" puts "# \'PLACE X,Y,NORTH|SOUTH|EAST|WEST\', MOVE, LEFT, RIGHT, REPORT" command = STDIN.gets while command command.strip! if command.downcase == "exit" puts "# Bye" exit else output = s...
true
b662788fc49f7832b8b0cca6cced3e424e59813e
Ruby
dl184/globalGymRubyProject
/models/signed_up.rb
UTF-8
1,749
2.96875
3
[]
no_license
require_relative('../db/sql_runner') require_relative("./gymclass.rb") require_relative("./member.rb") class Signed_up attr_accessor :id, :member_id, :gymclass_id def initialize(options) @id = options['id'].to_i if options['id'] @member_id = options['member_id'] @gymclass_id = options['gymclass_id'] ...
true
15804723991e903bbde8eba65bd75bdf692e1552
Ruby
jameshamann/student-directory
/ex8.rb
UTF-8
116
3.265625
3
[]
no_license
puts __FILE__ puts "Hello what\'s your name?" name = gets.chomp puts "Well, hello there #{name}, nice to meet you!"
true
7e15024b3a8de21fd16089436f3f6a9bad33c7ec
Ruby
miriam-cortes/door
/door.rb
UTF-8
1,903
3.75
4
[]
no_license
# Door Exercise class Door def initialize(unlocked="unlocked",open="open",inscription=nil) @door = { is_unlocked: unlocked, is_open: open, has_inscription: inscription } end def is_door_open? if @door[:is_open] == "open" return true elsif @door[:is_open] == "closed" ...
true
709868ac3d6d60a4279cbded4b4d6377091897ef
Ruby
sugaryourcoffee/syc-task
/lib/syctask/task_service.rb
UTF-8
6,605
3.015625
3
[ "MIT" ]
permissive
require 'csv' require 'yaml' require_relative 'environment.rb' # Syctask provides functions for managing tasks in a task list module Syctask # Provides services to operate tasks as create, read, find, update and save # Task objects class TaskService # Default directory where the tasks are saved to if no dir...
true