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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0e0714431e814457732b3f554ae6c632b6013c70 | Ruby | timgentry/ndr_support | /lib/ndr_support/safe_file.rb | UTF-8 | 4,014 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'ndr_support/safe_path'
class SafeFile
def initialize(*args)
a = self.class.get_fname_mode_prms(*args)
fname = a[0]
mode = a[1]
prms = a[2]
if prms
@file = File.new(fname, mode, prms)
else
@file = File.new(fname, mode)
end
# Just in case better clone the object
... | true |
1c98da37e723e38baec898dc11f7649c5c8a02f5 | Ruby | bingxie/code-questions | /lib/leetcode/739_daily-temperatures.rb | UTF-8 | 967 | 3.6875 | 4 | [
"MIT"
] | permissive | # 从前往后的方法
def daily_temperatures(t)
result = Array.new(t.size, 0)
previous_index = [0]
t.each_with_index do |temp, idx|
next if idx == 0
while !previous_index.empty? && temp > t[previous_index[-1]]
result[previous_index[-1]] = idx - previous_index[-1]
previous_index.pop
end
previous... | true |
66b7932eb5c53687012e44d9ca804bf3c3201fe8 | Ruby | shaggyone/ems_russia | /lib/ems_russia/cacher.rb | UTF-8 | 2,175 | 2.828125 | 3 | [] | no_license | require File.expand_path('../cacher_module.rb', __FILE__)
require 'yaml'
module EmsRussia
class Cacher
include ::EmsRussia::CacherInstanceModule
extend ::EmsRussia::CacherClassModule
attr_accessor :value
attr_accessor :expire_at
def initialize(attributes = {:value => nil, :expire_at => DateTim... | true |
c2ff38a3b52ffe51521c467f9e1cf90316afd443 | Ruby | jfarrell/sumo-ruby-client | /lib/sumologic/core_ext/numeric.rb | UTF-8 | 1,006 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | #
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under ... | true |
d1da6ae6ffdb59fb0a4c5c65d5e528cde9dff247 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w01/d04/Thomas/wines.rb | UTF-8 | 1,355 | 3.203125 | 3 | [] | no_license | require "pry"
wine_cellar = [
{:label => "Rutherford Hill", :type => "Chardonnay", :color => "white"},
{:label => "Nina Veneto", :type => "Pinot Grigio", :color => "white"},
{:label => "Wairau River", :type => "Sauvignon Blanc", :color => "white"},
{:label => "Tangley Oaks", :type => "Merlot", :color => "red"}... | true |
7800e54ce6ae1c3e60e2f358112251f5b507f9e7 | Ruby | JulianArnold/LRTHW | /pine.rb | UTF-8 | 201 | 3.859375 | 4 | [] | no_license | puts 'Hello, what\'s your name?'
name = gets.chomp
puts 'Hello ' + name + '.'
if name == 'Julian'
puts 'What an unusual name.'
else
if name == 'Geraldine'
puts 'What a lovely name.'
end
end
| true |
05555609ee0312da9d51ed12e2a3c32410782d50 | Ruby | scoin/phase_0_unit_2 | /week_6/8_BONUS_CarClass/my_solution.rb | UTF-8 | 2,946 | 4.125 | 4 | [] | no_license | # U2.W6: Create a Car Class from User Stories
# I worked on this challenge by myself
# 2. Pseudocode
# 3. Initial Solution
class Car
def initialize(model, color, year = 2014)
@my_car = "#{color.capitalize} #{year.capitalize} #{model.capitalize}"
@speed = 0
@mileage = 0.0
@pizza_stack = []
@last_acti... | true |
9c8ed557fbcc55fb7e484919339dbdaf22bd695b | Ruby | nahi/openpgp4u | /lib/pgp/packet/literaldata.rb | UTF-8 | 2,041 | 2.71875 | 3 | [] | no_license | # Copyright 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | true |
efb821d104dd16ddb48b1f4c131c55957335cec8 | Ruby | CharlaCeansky/tic-tac-toe-rb-v-000 | /lib/tic_tac_toe.rb | UTF-8 | 1,854 | 3.953125 | 4 | [] | no_license | WIN_COMBINATIONS= [
top_row_win=[0,1,2],
middle_row_win=[3,4,5],
bottom_row_win=[6,7,8],
left_column_win=[0,3,6],
middle_column_win=[1,4,7],
right_column_win=[2,5,8],
left_diagonal_win=[0,4,8],
right_diagonal_win=[2,4,6],
]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]}... | true |
e5ee0d5deae55706943488513fdc0086f852e1fd | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/2339ac8cda464cae9c1feda49f11ca7e.rb | UTF-8 | 235 | 3.4375 | 3 | [] | no_license | class Bob
def hey (str)
/\S/.match(str) or
return 'Fine. Be that way!'
/\p{Upper}/.match(str) and !/\p{Lower}/.match(str) and
return 'Woah, chill out!'
/\?\z/.match(str) and
return 'Sure.'
return 'Whatever.'
end
end
| true |
e618494922d4842b85bc1bf09de520c8c7c9edd1 | Ruby | chadbrewbaker/PowerComputing | /rec.rb | UTF-8 | 162 | 3.453125 | 3 | [] | no_license |
def faaa(n)
if( n==0)
return 2
end
if( n == 1)
return 6
end
return (3*faaa(n-1) + 5*faaa(n-2))
end
0.upto(10) do |n|
puts faaa(n)
end
| true |
75ecfc90d00ed49ed1408a8cc4f1b577a3ca6476 | Ruby | wabilin/Simple-SIC-XE-Assembler-in-Ruby | /main.rb | UTF-8 | 222 | 2.640625 | 3 | [] | no_license | #!usr/bin/ruby
$LOAD_PATH << "."
require 'assembler'
input_file = ARGV[0]
output_file = ARGV[1]
asm = Assembler.new
asm.read_sourse(File.read(input_file))
asm.pass_one
asm.pass_two
asm.print File.open(output_file, "w")
| true |
bf021bcc95f83752ba077294827a331187799683 | Ruby | ayucv/smsRuby | /lib/smsruby.rb | UTF-8 | 6,971 | 3.40625 | 3 | [] | no_license | require 'smsruby/send'
require 'smsruby/receive'
#
# The Smsruby class represent the connection between the client and the SMS middleware.
# Defines the API functions of the SMS middleware
#
class Smsruby
# Reference an instance of the Sender class
attr_reader :sender
# Reference an instance of the Receive clas... | true |
d53a2e07e91343e151e72e5bbacc3ab31b920c4d | Ruby | pyelton/Synteny-based-annotator | /fasta_parser.rb | UTF-8 | 772 | 2.96875 | 3 | [] | no_license | require 'ostruct'
class Fasta_file
attr_reader :file, :sequence, :header
def initialize(fasta_file)
@sequence = Array.new
@file = File.open(fasta_file)
end
def each_object #goes through file fasta objects
fasta = OpenStruct.new
sequence = Array.new
index = 0
buffer = Array.new
@file... | true |
8d9d2a0cc7be6304a60e676fdb8765a6d0659cde | Ruby | nmking22/war_or_peace | /test/deck_test.rb | UTF-8 | 1,803 | 3.328125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/deck'
class DeckTest < Minitest::Test
def setup
@card1 = Card.new(:diamond, 'Queen', 12)
@card2 = Card.new(:spade, '3', 3)
@card3 = Card.new(:heart, 'Ace', 14)
@cards = [@card1, @card2, @card3]
@deck = Deck.ne... | true |
4ef1494fb8f0ee4685dc413f81c51970b67ed301 | Ruby | ed-mare/jsonapiserver-example | /app/forms/v1/add_book.rb | UTF-8 | 807 | 2.625 | 3 | [] | no_license | module V1
class AddBook
attr_reader :book
def initialize(book_params, author_params, publisher_params)
@book = Book.new(book_params)
@author = Author.new(author_params) if author_params.present?
@publisher = Publisher.new(publisher_params) if publisher_params.present?
end
def save... | true |
f2eeb1684ea1d664b43fff55b4c51df86f228b37 | Ruby | UANDES-4103-201910/lab-assignment-2-juanesgh | /problems/frequency_finder.rb | UTF-8 | 112 | 3.046875 | 3 | [] | no_license | def find_frequency(sentence, word)
a = sentence.downcase.split()
b = word.downcase()
return a.count(b)
end | true |
58c3579612234c9ce5e25ec077668ab894cf73f6 | Ruby | hussyvel/ruby | /udemy_ruby_curso_jackson_pires/atributos_virtuais.rb | UTF-8 | 349 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
class Carro
attr_accessor :marca, :modelo
def velocidade_maxima
300
end
def descricao
"Marca: #{@marca} e Modelo: #{modelo}"
end
end
carro = Carro.new
carro.marca = 'Voyagem'
carro.modelo = 'Focus'
puts "Marca: #{carro.marca}"
puts "Modelo: #{carro.modelo}"
puts "Desc... | true |
e0a5fb8bcf3a5f9e699800733c754efcfaebf5bc | Ruby | kulisfunk/week_2_day_4 | /employee_system/specs/agent_spec.rb | UTF-8 | 454 | 2.703125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative '../agent.rb'
class TestAgent < MiniTest::Test
def setup()
@agent = Agent.new("James", "Bond")
end
def test_name()
actual = "The names " + @agent.surname + ", " + @agent.name + " " + @agent.surname
assert_equal("The names Bond, Jame... | true |
cdc3208bc04d759f327a96d54812479c2f3982d4 | Ruby | redazures/ruby-object-initialize-lab-ruby-intro-000 | /lib/dog.rb | UTF-8 | 238 | 3.640625 | 4 | [] | no_license | class Dog
def initialize(name, breed="Mutt")
@name=name
@breed=breed
end
def name
@name
end
def name=(name)
@name=name
end
def breed
@breed
end
def breed=(newbreed)
@breed=newbreed
end
end
| true |
8d1deb664a143e1f61ed29e2eac9447300cbbef8 | Ruby | IvanKhoteev/part1 | /prog2.rb | UTF-8 | 207 | 3.171875 | 3 | [] | no_license | def coincidence(array = false,range = false)
out = []
if array && range
array.each do |el|
if range.include?(el)
out.push(el)
end
end
end
return out
end
puts coincidence( )
| true |
aee146fda7a35927fb43bc3bfb49d283a5a12d70 | Ruby | pohor/algorithms_exercises | /first steps in ruby/20.rb | UTF-8 | 189 | 3.46875 | 3 | [] | no_license | puts "Podaj mi liczbę:"
usr_num = gets.to_i
sum = 0
div = 1
while div < usr_num
sum += (usr_num / div) % 10
div *= 10
end
puts "Suma cyfr w podanej przez Ciebie liczbie to #{sum}."
| true |
2c1f48e17f143cdf1bd46e5ee5b180e2e70ed3ea | Ruby | tcd/gql | /lib/gql/parse/union.rb | UTF-8 | 348 | 2.53125 | 3 | [
"MIT"
] | permissive | module Gql
module Parse
# @param data [Hash<Symbol>]
# @return [Gql::Models::Union]
def self.union(data)
union = Gql::Models::Union.new()
union.name = data[:name]
union.description = data[:description]
union.types = data[:possibleTypes].map { |pt| pt[:name] }
ret... | true |
aab2622239099b18759f422082f7304d6671ff4d | Ruby | FiskSMK/aggregations-2 | /scripts/dbrzezinski/s_to_a.rb | UTF-8 | 591 | 2.65625 | 3 | [] | no_license | require 'mongo'
include Mongo
coll = MongoClient.new("localhost", 27017).db("train").collection("questions")
coll.find.each do |record|
tags = record['tags']
tags = tags.to_s unless tags.is_a? String or tags.is_a? Array
coll.update({ "_id" => record['_id'] }, { "$set" => { "tags" => tags.split(" ") } }) if tags... | true |
1ba7872d3bdeed9a85792a7ec9c0b4deba2c9a62 | Ruby | jasooonko/library_import | /import_user.rb | UTF-8 | 2,572 | 3.078125 | 3 | [] | no_license | require "csv"
require "mysql"
$data_file = '/Users/jasonko/Dropbox/church/library/library_excel/person_information.csv'
$addr_file = '/Users/jasonko/Dropbox/church/library/library_excel/address.csv'
$addr_csv = CSV.open( $addr_file, "r", headers: true, :header_converters => :symbol )
def getuser(row)
lname = row[1]
... | true |
3eb99de6f391e96f41642aba1bc2591fad7bc177 | Ruby | juliansibaja84/fluffy-bassoon | /other/random_scripts/ruby/decoder.rb | UTF-8 | 1,150 | 3.734375 | 4 | [] | no_license |
a=[ '000000',
'000001',
'000010',
'000011',
'000100',
'000101',
'000111',
'001000',
'001001',
'001010',
'001011',
'001100',
'001101',
'001110',
'001111',
'010000',
'010001',
'010010',
'010011',
'010100',
'010101',
'010110',
'010111',
'011000',
'011001',
'011010',
'011011',
'011100',
... | true |
86aa48dac7e1aebb6b7053a32a4f088a42b8b7b3 | Ruby | hasumikin/mrubyc | /test/models/my_block.rb | UTF-8 | 252 | 3.296875 | 3 | [
"BSD-3-Clause"
] | permissive | class MyBlock
def initialize
@result = Array.new
end
def func1
yield
end
def each_double(array)
array.each do |v|
double(v)
end
end
def double(val)
@result << val * 2
end
def result
@result
end
end
| true |
15f45ef199f38dbb37a7ecca83ee30f9940b7981 | Ruby | oclaussen/chef-cookie-cutter | /lib/chef/cookie_cutter/autodocs/resource_dsl.rb | UTF-8 | 3,392 | 2.59375 | 3 | [
"Unlicense"
] | permissive | # frozen_string_literal: true
class Chef
module CookieCutter
module Autodocs
##
# Extensions to the Chef resource DSL
#
module ResourceDSL
##
# Describes an action on the resource
#
class Action
attr_reader :name
attr_accessor :descripti... | true |
cc97beea126b9cbcb5f7530bbe87a5ac8d2ca8b6 | Ruby | bleything/kuler | /test/test_kuler_theme.rb | UTF-8 | 1,065 | 2.5625 | 3 | [
"MIT"
] | permissive | require "test/unit"
require 'pathname'
require "kuler"
class TestKulerTheme < Test::Unit::TestCase
FIXTURES = Pathname.new( File.dirname(__FILE__) ).expand_path + "fixtures"
def setup
xml = FIXTURES + "single_random_result.xml"
nodes = Nokogiri::XML( xml.read ).at( "//kuler:themeItem" )
@theme = Kule... | true |
413729117c6037c01b7de5f5595a76f7a6cae985 | Ruby | mengyushi/LeetCode | /Ruby/983.rb | UTF-8 | 621 | 3.03125 | 3 | [] | no_license | # @param {Integer[]} days
# @param {Integer[]} costs
# @return {Integer}
def mincost_tickets(days, costs)
return 0 if days.empty?
first = days.min
last = days.max
results = [0]
1.upto(last-first+1) do |day|
if days.include?(day+first-1)
cands = []
cands << (day-1>=0 ?... | true |
1590ae75bbd76ea322ff798b38c4603a166cd67c | Ruby | terrybu/AlgorithmsCodingPractice | /Ruby/findLargestSubsequence.rb | UTF-8 | 916 | 4.0625 | 4 | [] | no_license | def findLargestIncreasingSubsequence(array)
arrayOfSubarrays = findIncreasingSubsequences(array)
arrayTotals = []
for subarray in arrayOfSubarrays
arrayTotals << determineIncrease(subarray)
end
answerIndex = arrayTotals.index(arrayTotals.max)
return arrayOfSubarrays[answerIndex]
end
def det... | true |
554c163e236620666bc7e5388169a0131fc46425 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/49de948322534d78bd466f06aaa07f39.rb | UTF-8 | 558 | 3.828125 | 4 | [] | no_license | class MessageProcessor
def initialize message
@message = message.strip
end
def find_response
if @message.empty?
'Fine. Be that way!'
elsif contains_no_lowercase_letters?
'Woah, chill out!'
elsif ends_with_a_question_mark?
'Sure.'
else
'Whatever.'
end
end
priva... | true |
23da332438f4a65af10e1ad3df03526059d4fe0b | Ruby | DashaDasha88/jungle | /spec/user_spec.rb | UTF-8 | 4,355 | 2.796875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
it 'password is required' do
expect(@user).to_not be_valid
expect(@user.errors.messages[:password]).to include('can\'t be blank')
end
it 'password and password confirmation need to match' do
user1 =... | true |
0fbfb0aa82a42306ea2cc003b9a366e487881004 | Ruby | MaeelAli/learn_ruby | /08_book_titles/book.rb | UTF-8 | 328 | 3.5625 | 4 | [] | no_license | class Book
attr_reader :title
def title=(new_title)
except = ["and", "or", "the", "of", "in", "a", "an"]
words = new_title.split
words[0].capitalize!
words[1..-1].map do |x|
if !except.include?(x)
x.capitalize!
end
end
@title = words.join(" ")#new_title.capitalize
... | true |
822122c32fdd43b09731be7ca357897f7506c97e | Ruby | Piotr0007/zjazd3PD | /sito2.rb | UTF-8 | 211 | 3.3125 | 3 | [] | no_license | def sito(x=2,y)
n = x..y
o = []
p = []
for i in n
next if o.include? i
ii = i *2
while ii <= n.last do
o << ii
ii = ii +i
end
p << i unless o.include?(i)
puts i
end
end
sito(50)
| true |
521406d1bc8db99b8a1cc13f8697df9d57d8b777 | Ruby | bhenderson/indifferent_hash | /test/ar_hash.rb | UTF-8 | 1,194 | 3.25 | 3 | [
"MIT"
] | permissive | # Basic implementation of HashWithIndifferentAccess for benchmark comparison.
class ARHash < Hash
def self.[](other) self.convert(other) end
def self.convert(other)
case other
when self
other
when Hash
new.update other
when Array
other.map{|o| convert(o)}
else
other
e... | true |
7e9f16438da222af4a1eada98df3002379060129 | Ruby | MaleehaBhuiyan/ruby-oo-practice-has-many-through-template-nyc01-seng-ft-060120 | /lib/membership.rb | UTF-8 | 274 | 2.859375 | 3 | [] | no_license | class Membership
attr_accessor :student, :club, :date
@@all = []
def initialize(student, club, id)
@student = student
@club = club
@date = date
@@all << self
end
def self.all
@@all
end
end
| true |
d07b4cbdf753e677cc48ee618992995dd9d036cb | Ruby | prwelber/practice | /read_in.rb | UTF-8 | 123 | 2.6875 | 3 | [] | no_license | File.open('./9235', "r") do |file_handle|
file_handle.each_line do |server|
server.split(" ")
puts server.max
end
end | true |
522f4188406873a9fbfb8114d55afc6c7868f24d | Ruby | amit-personal/sample-rails-app | /app/models/link.rb | UTF-8 | 1,498 | 2.65625 | 3 | [] | no_license | class Link < ApplicationRecord
belongs_to :user
has_many :comments
has_many :votes
# where(created_at: (Time.now - 24.hours)..Time.now).order(hot_score: :desc)
scope :hottest, -> { where(created_at: (Time.now - 24.hours)..Time.now).order(points: :desc) }
scope :newest, -> { order(created_at: :desc) }
v... | true |
46243f0398e6470f4330b199c8304f97a7136158 | Ruby | MengruHan/ruby-learning | /faraday.rb | UTF-8 | 1,748 | 2.96875 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: UTF-8 -*-
require 'JSON'
require 'FARADAY'
require 'CSV'
require 'dotenv'
Dotenv.load ('.env')
TOKEN = ENV['TOKEN']
response = Faraday.get("https://faria.openapply.cn/api/v1/students?auth_token=#{TOKEN}&per_page=10")
puts response #将返回一个 “#<Faraday::Response:0x00007fdea703df58>”带有响应状态,标... | true |
e4304462c225acf7f9cb979e1556a9643a2549f8 | Ruby | rachaelsh/ruby-object-attributes-lab-v-000 | /lib/person.rb | UTF-8 | 183 | 2.578125 | 3 | [] | no_license | class Person
def name=(name_set)
@name = name_set
end
def name
@name
end
def job=(job_set)
@job = job_set
end
def job
@job
end
end
| true |
8f414a217adff2d3b37c2862a5e7c71a8ca21066 | Ruby | blambeau/viiite | /benchmarks/miscellaneous/sloppy_and_tidy.rb | UTF-8 | 489 | 2.8125 | 3 | [
"MIT"
] | permissive | # A benchmark pioneered by @tenderlove
# @see https://gist.github.com/1170106
class Sloppy
def sloppy; @sloppy; end
end
class Tidy
def initialize; @tidy = nil; end
def tidy; @tidy; end
end
Viiite.bench do |b|
tidy = Tidy.new
sloppy = Sloppy.new
b.variation_point :ruby, Viiite.which_ruby
b.range... | true |
86bb4825cc6b6fcec656268578322a0c07a0447d | Ruby | mneumann/rubyjs | /test/test_exception.rb | UTF-8 | 826 | 3.21875 | 3 | [] | no_license | class TestException
def self.main
p "before block"
begin
p "in block"
end
p "after block"
###
begin
p "block"
rescue
p "rescue"
rescue Exception => a
p "another rescue"
p a
else
p "else"
end
p RuntimeError.new("test")
puts "before... | true |
48aa7f3e91c8a828309c6bea960e90c98e9fb515 | Ruby | mozg1984/eva-lang | /spec/block_spec.rb | UTF-8 | 645 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'eva'
require 'parser/EvaParser'
RSpec.describe Eva do
subject(:eva_machine) { Eva.new }
describe '#eval block expression' do
let(:expr) do
'(begin
(var x 10)
(var y 20)
(+ (* x y) 30)
)'
end
let(:result) { 230 }
it ... | true |
f31783cb55ab7fc6653feed7d3850a0602decf89 | Ruby | nllevin/W6D1 | /word_chainer.rb | UTF-8 | 1,612 | 3.609375 | 4 | [] | no_license | class WordChainer
attr_reader :dictionary, :all_seen_words
attr_accessor :current_words
def initialize(dictionary_file_name)
@dictionary = File.readlines(dictionary_file_name, chomp: true).to_set
end
def adjacent_words(word)
alphabet = ("a".."z").to_a
new_words = []
... | true |
8701bb092c424bfe3c06680505e593f760e5ef5e | Ruby | alakim/grains | /NHtml/BuildTagDefinitions.rb | WINDOWS-1251 | 3,422 | 2.921875 | 3 | [] | no_license | $stdout = File.open("TagDefinitions.cs", "w+")
tags = ['DIV', 'P', 'SPAN', 'A', 'PRE', 'UL', 'OL', 'LI', 'INPUT', 'TEXTAREA', 'TABLE', 'TR', 'TH', 'TD', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6']
attributes = ['class', 'width', 'height', 'border', 'cellpadding', 'cellspacing', 'align', 'valign', 'style', 'src', 'href', 'i... | true |
a5f4e9e106520c2c53dc183ee66d500b9ee0ef30 | Ruby | cfoust/leetcode-problems | /problems/insert-delete-getrandom-o1-duplicates-allowed/solution.rb | UTF-8 | 894 | 3.96875 | 4 | [] | no_license | class RandomizedCollection
=begin
Initialize your data structure here.
=end
def initialize()
end
=begin
Inserts a value to the collection. Returns true if the collection did not already contain the specified element.
:type val: Integer
:rtype: Boolean
=end
def inse... | true |
b121c0d4a1a4a74f35abb8a9929404f2c9e726e1 | Ruby | sho12chk/ruby_lesson | /heredoc.rb | UTF-8 | 788 | 3.390625 | 3 | [] | no_license | puts <<~TEXT
私の
名前は
神里です
TEXT
# putsを使用した場合
puts "おはよう"
puts "こんにちは"
puts "こんばんは"
# ヒアドキュメントを使用した場合
puts <<~TEXT
おはよう
こんにちは
こんばんは
TEXT
puts <<~亜亜亜
おはよう
こんにちは
こんばんは
亜亜亜
puts <<~あああ
おはよう
こんにちは
こんばんは
あああ
puts <<~aaa
おはよう
こんにちは
こんばんは
aaa
puts <<~111
おはよう
こんにちは
こんばんは
111
# putsを使用した場合(空文字で改行)
puts "おはよう"
puts ""
put... | true |
a739b4daa3a4343bc3ab02404ca93e1439bf63b3 | Ruby | janebranden/launch-school-intro-to-programming | /01_basics/basics2.rb | UTF-8 | 450 | 4.65625 | 5 | [] | no_license | # basics2.rb
# Use the modulo operator, division, or a combination of both to take a 4 digit number and find the digit in the:
# 1) thousands place
# 2) hundreds place
# 3) tens place
# 4) ones place
number = 2017
thousands = number / 1000
hundreds = number % 1000 / 100
tens = number % 100 / 10
ones = number % 10
p... | true |
bce06254cf2c33c09d3ddc14cbeb516921e80806 | Ruby | ess/wrapomatic | /spec/wrapomatic/wrapper_spec.rb | UTF-8 | 1,702 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Wrapomatic
describe Wrapper do
let(:dummy) {Object.new}
let(:text) {"This is some text to wrap. It is intentionally long and contains a few newlines\nto ensure that all of the features of the wrapper\nwork\nas\nexpected."}
describe '.new' do
it 'has a default indentati... | true |
3f592aaa55605c16d1a2f2919504094380f4ef6e | Ruby | FDA/precisionFDA | /app/helpers/space_reports_helper.rb | UTF-8 | 1,315 | 2.578125 | 3 | [
"CC0-1.0"
] | permissive | module SpaceReportsHelper
def generate_report(user, data, filters)
"""
<h3>Interaction Report</h3>
<div>Report date: #{Date.today.strftime("%m/%d/%Y")}</div>
<div>Report by: #{user.full_name}</div>
<br>
<div>Filters</div>
<div>Start date: #{filters[:dates][:start_date]}</div>
... | true |
b9b7beae87e90212f15ef3606612233c7e402a96 | Ruby | svenfuchs/gem-release | /lib/gem/release/context.rb | UTF-8 | 1,092 | 2.515625 | 3 | [
"MIT",
"MPL-2.0"
] | permissive | require 'gem/release/context/gem'
require 'gem/release/context/git'
require 'gem/release/context/paths'
require 'gem/release/context/ui'
module Gem
module Release
class Context
attr_accessor :config, :gem, :git, :ui
def initialize(*args)
opts = args.last.is_a?(Hash) ? args.pop : {}
n... | true |
7fb526b4e6e0ac270ae15bfc8e9744ce2d3fe14b | Ruby | jasmarc/kmeans | /lib/tfidf.rb | UTF-8 | 3,705 | 3.453125 | 3 | [] | no_license | require "array_hacks.rb"
require "string_hacks.rb"
class TFIDF
attr_reader :word_list, :term_document_matrix
def initialize(dir_glob, stoplist)
@word_list = Hash.new # This is our main wordlist
@documents = Hash.new # Let's keep track of each docs' sizes
@stop_list = File.read(stoplist).split # Words ... | true |
00bd28a3fdf53399b7dada1f8497f4999827cd2f | Ruby | anime-memes/json-csv-parser-task | /checker.rb | UTF-8 | 1,204 | 3.5625 | 4 | [] | no_license | # class that checks data for errors and deletes hashes with errors
class Checker
class << self
def check_data(file_data)
errors = []
file_data.each do |data_hash|
errors << check_name(data_hash)
errors << check_cost(data_hash)
end
# delete hashes that contain errors
checked_data = file_data.de... | true |
213140d0adb0e6c871a819fd15ce3912325122aa | Ruby | mcousin/tippspiel | /app/models/open_liga_db_league.rb | UTF-8 | 4,044 | 2.578125 | 3 | [] | no_license | require "savon"
require "fuzzystringmatch"
class OpenLigaDbLeague < ActiveRecord::Base
attr_accessible :league_id, :league, :oldb_league, :oldb_season
belongs_to :league
SERVICE_URL = "http://www.openligadb.de/Webservices/Sportsdata.asmx?WSDL"
def import_matches
unless (matchdays_aligned? and teams_alig... | true |
b5e458100083da16cc000ce4db7d5f8767c24e9b | Ruby | drewundone/development | /cable.rb | UTF-8 | 206 | 3.046875 | 3 | [] | no_license | COMPOUND = 4332
COMPOUND2 = 565
puts 'What is the diameter of the first cable?'
diameter = gets.chomp
puts 'What is the compound?'
answer = gets.chomp
puts 'Please enter COMPOUND1 or COMPOUND2'
end
| true |
5433b3c805c076a8f3c653afcceb30890d2e81f3 | Ruby | slc21/ICS-Course | /ch13/orangeTree.rb | UTF-8 | 1,580 | 4.4375 | 4 | [] | no_license | class Tree
def initialize name
@name = name
@height = 0
@yearPass = 0
@oranges = 0
puts "#{@name} has sprouted"
puts "Type 'help' to begin"
end
def oneYearPass
@height = @height + rand(4) + rand(2)
puts "One year passes..."
@yearPass = @yearPass + 1
if @height >= rand(21)... | true |
54db203d9c9c5f5319ad7f3345b5270f541b8436 | Ruby | sangster/mocapi | /lib/mocapi/models/amortization_period.rb | UTF-8 | 505 | 3.046875 | 3 | [] | no_license | module Mocapi
module Models
class AmortizationPeriod
VALID_RANGE = (5..25).freeze
# @param years [Integer] The length of the amortization period, in years
def initialize(years)
unless VALID_RANGE.include?(years)
raise ArgumentError,
format('Amortization of %d y... | true |
8e9e0fd004b97b739d06999f6f5c9a0cca41ae60 | Ruby | gardnerl-bit/intro_Ruby_bookLS | /ch10_exercises/exercise4.rb | UTF-8 | 92 | 3.203125 | 3 | [] | no_license | arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
#append
arr.push(11)
#prepend
arr.unshift(0)
p arr
| true |
4f44709327ffe10e88851d2dd534069917ca7d02 | Ruby | BurdetteLamar/rdoc_toc | /bin/rdoc_toc | UTF-8 | 1,049 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rdoc_toc'
# Confirm that we're in a git project.
git_dir = `git rev-parse --show-toplevel`.chomp
unless $?.success?
message = <<EOT
rdoc_toc must run inside a .git project.
That is, the working directory one of its parents must be a .git directory.
EOT
raise RuntimeError.new(message)... | true |
2b171bbc8c828d1031bc97aaeb9dde39d06e83f2 | Ruby | donghL-dev/Study-RubyOnRails | /Ruby/test.rb | UTF-8 | 266 | 3.796875 | 4 | [] | no_license | list = []
a = gets.chomp
b = a.to_i #정수로 형변환 시켜줌.
for i in 1..b
print "#{i}번째 숫자를 입력하세요 :"
number = gets.chomp
list.push(number)
end
list.each do |i|
puts "당신이 입력한 숫자는 #{i}입니다."
end
| true |
8309bafc66b651cd9541f00dc747d166bf91dcaa | Ruby | LeonardoRO/chemistrykit-examples | /google/formulas/lib/formula.rb | UTF-8 | 986 | 2.953125 | 3 | [] | no_license | # Encoding: utf-8
# This is where you can define generic helper functions
# that are inhereted by your formulas.
# The ones below are borrowed from:
# http://elemental-selenium.com/tips/9-use-a-base-page-object
class Formula < ChemistryKit::Formula::Base
attr_reader :driver
def initialize(driver)
@driver = ... | true |
8e3ae21d3453699201f1a9784e34b81bb41b064f | Ruby | JeanTimothee/TCC | /app/controllers/students_controller.rb | UTF-8 | 1,072 | 2.515625 | 3 | [] | no_license | class StudentsController < ApplicationController
def index
@lessons = Lesson.all
@students = Student.all
# search params
@students = Student.search_by_first_last_name(params[:query]) if params[:query].present?
if params[:level].present?
level_query = params[:level].map do |level|
L... | true |
c343a33f41182c29431191cf3e6294325d5ffef2 | Ruby | mikeblatter/automation_object | /lib/automation_object/blue_print/composite/hook_action.rb | UTF-8 | 2,011 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Require parent class
require_relative 'base'
require_relative 'hook_element_requirements'
module AutomationObject
module BluePrint
module Composite
# HookAction composite class
class HookAction < Base
# Get the order to run the hook in
# @return [Arra... | true |
705432f547d8f3d4ec20eb4a9d6120e9aa2a396d | Ruby | BinetLoisir/FlipperMap | /app/controllers/map_controller.rb | UTF-8 | 3,597 | 2.640625 | 3 | [] | no_license | class MapController < ApplicationController
def map
@latitude = Bar.first[:latitude]
@longitude = Bar.first[:longitude]
google_bar_list = Google.all.map do |bar|
stars = [[(bar[:rating].to_f - 0.01) * 2 - 5, 3].min, 0].max.to_i
pbs = 0
description = "<b>#{bar[:name]}"
descriptio... | true |
e4641d68d8f5376cc0e9ca99d40160e2cc84cb4d | Ruby | sampreet-chawla/GA-unit4-ruby-intro-to-ruby | /instrructor_examples/fizz_buzz.rb | UTF-8 | 744 | 3.984375 | 4 | [] | no_license | # https://repl.it/@jkeohan/Ruby-FizzBuzz-Solutions
# WHILE LOOP
# i = 0
# while i < 35 do
# if i % 3 == 0 && i % 5 == 0
# puts "fizz buzz #{i}"
# elsif i % 3 == 0
# puts "fizz " + i.to_s
# elsif i % 5 == 0
# puts "buzz"
# else
# puts i
# end
# i += 1
# end
# FOR IN LOOP
# for i in 0..35
#... | true |
92727ca11acb03e7a69b57acdfd71b459714aea2 | Ruby | jemyers/classroom | /vendor/bundle/ruby/2.6.0/gems/dependency_checker-0.2.0/bin/dependency-checker | UTF-8 | 1,854 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'dependency_checker'
require 'json'
options = {}
OptionParser.new { |opts|
opts.on('-o module,version', '--override module,version', Array, 'Forge name of module and semantic version to override') do |override|
options[:override] = override
end
opts.on('-c', '... | true |
386edeb80a1f0309ce43537a9832b15756a45100 | Ruby | jeffkreeftmeijer/guidedown | /bin/guidedown | UTF-8 | 691 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../lib/guidedown'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: guidedown [options]"
opts.on("-h", "--help", "Show this message") do
puts opts
exit
end
opts.on("--html-code-blocks", "Wrap code blocks in `<code>` and `<pre>` ta... | true |
ce7975863a8b5361a22c0a09ac743fc6d32c20f8 | Ruby | tajimata/freemarket_sample_57a | /db/fixtures/01_Category.rb | UTF-8 | 12,184 | 2.609375 | 3 | [] | no_license | # 00 親カテゴリー作成
# 01 レディースの子カテゴリー作成
# 02 メンズの子カテゴリー作成
# 03 ベビー・キッズの子カテゴリー作成
# 04 インテリア・住まい・小物の子カテゴリー作成
# 05 本・音楽・ゲームの子カテゴリー作成
# 06 おもちゃ・ホビー・グッズの子カテゴリー作成
# 07 コスメ・香水・美容の子カテゴリー作成
# 08 家電・スマホ・カメラの子カテゴリー作成
# 09 スポーツ・レジャーの子カテゴリー作成
# 10 ハンドメイドの子カテゴリー作成
# 11 チケットの子カテゴリー作成
# 12 自動車・オートバイの子カテゴリー作成
# 13 その他の子カテゴリー作成
# 00 親カテゴリー作成... | true |
ee1fad8deaf47631fbcdc276cb8ee026f954486a | Ruby | keixcruick90/programming-univbasics-4-array-methods-lab-dumbo-web-102819 | /lib/array_methods.rb | UTF-8 | 513 | 3.703125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def using_include(array, element)
array.include?(element)
end
def using_sort(array)
anime = ["Rurouni Kenshin", "Yu Yu Hakusho", "I", "Inuyasha", "wow"]
anime.sort
end
def using_reverse(array)
fun = ["wow", "blue", "tandem", "arrays!"]
fun.reverse
end
def using_first(array)
words = ["wow", "damn", "boy",... | true |
bb65b059e41312b92072ffb4a0dfd310a03ef44f | Ruby | DianeEugenie/cinema_sql_and_ruby | /console.rb | UTF-8 | 3,237 | 2.765625 | 3 | [] | no_license | require_relative("./models/customer.rb")
require_relative("./models/film.rb")
require_relative("./models/ticket.rb")
require_relative("./models/screening.rb")
require("pry-byebug")
Ticket.delete_all()
Screening.delete_all()
Customer.delete_all()
Film.delete_all()
customer1 = Customer.new(
{
"name" => "Phoebe... | true |
bb04075fc597e5788159af03b9a216f6ccc6b7ac | Ruby | jinshen-cn/meetapp | /app/helpers/sessions_helper.rb | UTF-8 | 551 | 2.546875 | 3 | [] | no_license | module SessionsHelper
def current_user=(user)
@current_user = user
session[:session_token] = user.session_token
end
def current_user
return nil if session[:session_token].nil?
@current_user ||= User.find_by_session_token(session[:session_token])
end
def logged_in?
!current_user.nil?
end
def logout_c... | true |
35a6c0acff1d9eb418d7f6b9cc2059db79486523 | Ruby | tjisher/quiz14 | /lcd_tests.rb | UTF-8 | 8,282 | 3.5 | 4 | [] | no_license | ##ToC
# Basic Assignments
# Output
# Time object as input
# Logger
# Character and encoding changes
require './lcd.rb'
require 'minitest/autorun'
class LCDTest < MiniTest::Test
#Basic Assignments
def test_assignment_string
lcd = LCD.new
lcd.values = "01234"
assert_equal "01234", lcd.values,
"Values to... | true |
1573cca45f155cb8a3fb283378a2e9f846472446 | Ruby | rf-/keynote | /lib/keynote/presenter.rb | UTF-8 | 3,976 | 2.90625 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
module Keynote
# Keynote::Presenter is a base class for presenters, objects that encapsulate
# view logic.
#
# @see file:README.md
class Presenter
include Keynote::Rumble
class << self
attr_writer :object_names
# Define the names and number of the objects presented by ... | true |
1fb249ef24d8973ec595ded6a5f05011da9368f4 | Ruby | goldhoorn/utilrb | /test/test_array.rb | UTF-8 | 248 | 2.6875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'utilrb/test'
require 'utilrb/array'
class TC_Array < Minitest::Test
def test_to_s
assert_equal("[1, 2]", [1, 2].to_s)
end
def test_to_s_recursive
obj = [1, 2]
obj << obj
assert_equal("[1, 2, ...]", obj.to_s)
end
end
| true |
2141a4353ecd36c3540a4a41eec8191bf645c988 | Ruby | unabatede/shagit | /lib/enhancing_grit.rb | UTF-8 | 799 | 3.078125 | 3 | [
"MIT"
] | permissive | # this adds a method called 'repo_name' that returns only the filename without path or file extension
require 'pathname'
require 'find'
module Grit
# return foldername including extension
def shagit_foldername
foldername = Pathname.new(self.path).basename.to_s
end
# return foldername from path without ext... | true |
71fb2d91edb43474990ca7cb67e1ac35cd41e041 | Ruby | bethsecor/ruby-exercisms | /sum-of-multiples/sum_of_multiples.rb | UTF-8 | 458 | 3.5625 | 4 | [] | no_license | class SumOfMultiples
def initialize(*multiples)
@multiples = multiples
end
def to(ceiling_number)
if ceiling_number < @multiples.min
0
else
sum_multiples(ceiling_number)
end
end
def sum_multiples(ceiling_number)
numbers = (1...ceiling_number).to_a
result = []
@multip... | true |
b5c3fdfcd91f2b464bddd418b8b6f37f4a0cf569 | Ruby | cynthiacd/betsy | /app/models/product_order.rb | UTF-8 | 908 | 2.703125 | 3 | [] | no_license | class ProductOrder < ApplicationRecord
belongs_to :order, optional: false
belongs_to :product, optional: false
validates_uniqueness_of :order_id,
scope: [:product_id],
message: "This item is already in the cart"
validate :quantity, :check_quantity
# you sho... | true |
8b55840c05725f78a5659e2d543991371c897d27 | Ruby | acidhelm/kq_olympic_scoring_test | /test.rb | UTF-8 | 2,264 | 2.84375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "dotenv/load"
require "json"
require "optparse"
require "rest-client"
require_relative "bracket"
require_relative "config"
require_relative "match"
require_relative "player"
require_relative "scene"
require_relative "team"
require_relative "tournament"
Options = Struct.new(:tourn... | true |
cb7d7f042e39e0b839485b889db4ddb82e323e4b | Ruby | jsb/attic | /mirror/jsb/irc.rb | UTF-8 | 2,480 | 3.296875 | 3 | [] | no_license | require 'socket'
require 'iconv'
def try_to_convert(string, from, to)
begin
string = Iconv.iconv(to, from, string).to_s
return string
rescue Iconv::IllegalSequence, Iconv::InvalidCharacter
return string
end
end
class IRCLineFormatError < StandardError; end
class Client
ServerUsesUT... | true |
5569e8d88912d3b364aeb601b780dc6c51958fb7 | Ruby | livash/Poker | /lib/hand.rb | UTF-8 | 2,606 | 3.5625 | 4 | [] | no_license | require_relative 'deck'
require_relative 'card_suits_faces'
class Hand
include CardSuitsFaces
attr_accessor :cards
def initialize(cards)
@cards = cards
end
#private
def suits_hash
return_hash = {}
cards.each do |card|
if return_hash[card.suit].nil?
return_hash[card.suit] ... | true |
b2d17f278091729d05f17a19409ef756f0cff5b2 | Ruby | JoseGomez247/codeacamp | /prework/Jueves/hashkeys.rb | UTF-8 | 259 | 3.546875 | 4 | [] | no_license | def hash_keys(hash)
arr= []
hash.each_key do |key|#separo el hash en "keys"
arr << key#imprimo el key dentro de un array
end
arr
end
p hash_keys({"Vegetal" => ['zanahoria', 'elote' ], "Fruta" => ['manzana', 'arandano']}) == ["Vegetal", "Fruta"] | true |
9da9633b26c97eb4818bbcb57262a99fd861b070 | Ruby | AshleyRapone/Intro_to_Programming_Ruby | /Exercises/Example3.rb | UTF-8 | 214 | 4.34375 | 4 | [] | no_license | #Now, using the same array from #2, use the select method to extract all odd numbers into a new array.
numbers = [1,2,3,4,5,6,7,8,9,10]
new_array = numbers.select do |number|
number % 2 != 0
end
puts new_array
| true |
48c721091601086feb57fcee9ba2efac672d4456 | Ruby | taw/z3 | /spec/integration/algebra_problems_spec.rb | UTF-8 | 427 | 2.515625 | 3 | [
"MIT"
] | permissive | describe "Algebra Problems" do
it do
expect("algebra_problems").to have_output <<EOF
Solution to problem 01:
Solution to problem 03:
* x = -22
* |-6| = 6
* |x-2| = 24
Solution to problem 04:
* ax = -4
* ay = -5
* bx = -1
* by = -1
* |a-b| = 5
Solution to problem 05:
* x = 9/2
* y = 0
Solution to problem 06:
* ans... | true |
80e0a284db11e783995da20c8d66572dc7a2a949 | Ruby | murashit/murashitbot | /lib/murashitbot/command.rb | UTF-8 | 946 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'thor'
module Murashitbot
class Command < Thor
desc 'init USERNAME', 'Authorize and generate config file.'
def init(name)
Murashitbot::Generator.start
end
desc 'parse USERNAME', 'Parse source.txt and cache results.'
def parse(name)
db = Murashitbot::Parser.start(na... | true |
8cada18e8374cb91b285a05ff37f750699664f72 | Ruby | jph98/ant-colony-optimisation | /ant.rb | UTF-8 | 2,891 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
class Ant
attr_accessor :x, :y, :mode, :state, :direction
RANDOM_MOVEMENT = :random
PHEROMONE_MODE = :pher
LOOK_AROUND = :look
DEBUG = false
STATE = "A"
DIRECTIONS = [:N, :NE, :E, :SE, :S, :SW, :W, :NW]
def initialize(x, y, random_direction_change)
@x = x
@y = y
@food_collected... | true |
00bb7f2da2f5c986aade6a31b86bb2c9157c8631 | Ruby | jgorset/kingpin | /lib/kingpin/frameworks/django.rb | UTF-8 | 764 | 2.6875 | 3 | [] | no_license | require "pathname"
module Kingpin
module Frameworks
class Django < Framework
class << self
# Determine whether the web application at the given path
# is developed with Django.
#
# path - A string describing the path to the root of a web application.
#
# R... | true |
dfb3b04711166dffffa263f172a787020c5d0f69 | Ruby | mr-bat/cs291a_project1 | /function.rb | UTF-8 | 3,210 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
require 'json'
require 'jwt'
require 'pp'
def lowercaseKeys(hash)
result = {}
hash.to_hash.each_pair do |k, v|
result.merge!(k.downcase => v)
end
result
end
def main(event:, context:)
# You shouldn't need to use context, but its fields are explained here:
# https://docs... | true |
1313a61a6a1bdb7ee9a6dabc247724ee87a70e2c | Ruby | MrCesar107/Sample-Catalogue-App | /app/utils/catalogues.rb | UTF-8 | 229 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
class Catalogues # :nodoc:
attr_reader :status
def initialize(status)
@status = status
end
def catalogues
status.eql?('active') && Catalogue.active || Catalogue.inactive
end
end
| true |
7d5bdc81663e1c45a0eb669a024a406c4ba38f15 | Ruby | MaciejLorens/codility | /6.rb | UTF-8 | 425 | 3.234375 | 3 | [] | no_license | def solution(a)
n = a.length
l = Array.new(n + 1)
l[0] = -1
for i in 0 .. (n - 1)
l[i + 1] = a[i]
end
count = 0
pos = (n + 1) / 2
candidate = l[pos]
for i in 1 .. n
if (l[i] == candidate) then
count = count + 1
end
end
if (count > n / 2) then
return candidate;
end
retu... | true |
80482bc3c02bb5210eca7d83319e92dfe6da95b3 | Ruby | stefanlenoach/Reddit-Bot-Maker | /upvoter.rb | UTF-8 | 973 | 2.59375 | 3 | [] | no_license | require 'rubygems'
require 'watir'
require 'selenium-webdriver'
require 'watir-webdriver'
require 'bench'
class Upvote
def initialize
@bots = File.open("reddit_bots.txt").readlines.map {|line| line}
@i = 0
end
def upvote
@browser = Watir::Browser.new :chrome
@browser.goto('https://www.reddit.co... | true |
37f81007701d89a1feb5e964c971377643078606 | Ruby | miyohide/just_kidding_ken_all_parser | /db_to_yaml.rb | UTF-8 | 1,160 | 2.671875 | 3 | [] | no_license | require 'yaml'
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
host: 'localhost',
username: 'user1',
password: 'user1',
database: 'ken_all'
)
class Todofuken < ActiveRecord::Base
end
class City < ActiveRecord::Base
end
class Town < ActiveRecord::Base
end
to... | true |
74ef404a3113e3453d2160e8e2dc0c55e2433fb3 | Ruby | Almnir/rubies | /searchXML1.rb | UTF-8 | 1,603 | 2.671875 | 3 | [] | no_license | require 'nokogiri'
fileSchools = File.open('d:\SCREEEENSHOOOTS\тест\rbd_Schools.xml')
fileSchoolsClasses = File.open('d:\SCREEEENSHOOOTS\тест\rbd_SchoolClasses.xml')
docSchools = Nokogiri::XML(fileSchools)
docSchoolsClasses = Nokogiri::XML(fileSchoolsClasses)
idsSchools = []
idsSchoolsClasses = []
idsSch... | true |
0252c4a1793a14a34411b6c69dd83cfe57ff11e1 | Ruby | fatih/shoulda-matchers | /spec/warnings_spy/reader.rb | UTF-8 | 950 | 3 | 3 | [
"MIT"
] | permissive | class WarningsSpy
class Reader
attr_reader :warning_groups
def initialize(filesystem)
@warnings_file = filesystem.warnings_file
@current_group = []
@warning_groups = []
end
def read
warnings_file.rewind
warnings_file.each_line do |line|
process_line(line)
... | true |
f1d2d312e6abef67a5051b3d598b68400fa72e73 | Ruby | rvachon1/rb130 | /exercises/challenges/easy1/series.rb | UTF-8 | 1,000 | 4.53125 | 5 | [] | no_license | =begin
Write a program that will take a string of digits and give you all the possible
consecutive number series of length n in that string.
Rules:
-Input: String of digits
-Ouput: Array of digit arrays
-Sliced arrays must consist of consecutive numbers
-Every sliced array must be unique
-Raises ArgumentError if size... | true |
38ba5ae326f3ff4b9cd5e050276be8129acb72c0 | Ruby | RodolfoPena/E7CP2A1 | /ejercicio1.rb | UTF-8 | 1,747 | 4.1875 | 4 | [] | no_license | # 1. Utilizando *map* generar un nuevo arreglo con cada valor aumentado en 1.
# 2. Utilizando *map* generar un nuevo arreglo que contenga todos los valores convertidos a *float*.
# 3. Utilizando *map* generar un nuevo arreglo que contenga todos los valores convertidos a *string*.
# 4. Utilizando *reject* descartar todo... | true |
49aa6fb6f5502a548d90d469e7bea5a3acadaae4 | Ruby | hobodave/nagios-probe | /lib/nagios-probe.rb | UTF-8 | 1,163 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Nagios
OK = 0
WARNING = 1
CRITICAL = 2
UNKNOWN = 3
class Probe
attr_reader :retval, :message
def initialize(opts = {})
@opts = opts
@retval = Nagios::OK
@message = "OK: #{ok_message}"
end
def crit?
return false unless check_crit
@retval = Nagios::CRITICA... | true |
134b5899ed620614650ae396fe9e43a40dbd9779 | Ruby | artisanengine/artisanengine | /spec/acceptance/visitors/goods/options/select_good_options_spec.rb | UTF-8 | 3,481 | 2.703125 | 3 | [] | no_license | require 'acceptance/acceptance_helper'
feature 'Select a Variant Using Option Drop-Downs', %q{
In order to select a variation of a good
As a visitor
I want to use option drop-downs to choose the variant.
} do
background do
# Given a good exists with three options and three variants,
@good = Factory(... | true |
d2541b16d60bf703f0ec76ffb2505f1ff77d4a4a | Ruby | xanzor/Qwant | /FullStack/Bootcamp Ruby/Ruby Quest01/ex02/my_first_variable_string.rb | UTF-8 | 49 | 2.5625 | 3 | [] | no_license | my_string = "Learning is growing"
puts(my_string) | true |
978aaa1ea9bc68470e3cf81dd73db42e7ed6748a | Ruby | bkozhaev/test | /lib/test_body.rb | UTF-8 | 1,620 | 3.609375 | 4 | [] | no_license | class TestBody
#1. Сократил написание сеттеров
attr_reader :user_name, :points
def initialize(user_name, file_path)
@user_name = user_name
@points = 0
@count = 0
#2. Вывел ссылку на файл в main.rb а сам метод привязал к (file_path)
#3. Изменил чтение строки с файла одной строкой
begin
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.