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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b2756a204e7c15264fe996f727abf25d13371e4a | Ruby | gmacdougall/advent-of-code | /2018/14/part2.rb | UTF-8 | 1,055 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
input = 793031
input_array = input.to_s.split('').map(&:to_i)
recipes = [3, 7]
elf1_index = 0
elf2_index = 1
while
new = (recipes[elf1_index] + recipes[elf2_index]).to_s.split('').map(&:to_i)
recipes.push(*new)
elf1_index = (elf1_index + (recipes[elf1_index] + 1)) % recipes.length
elf2_... | true |
7770069eff8a9b15d090661ddad36d754177dd83 | Ruby | wied03/ansible-ruby | /lib/ansible/ruby/modules/generated/monitoring/datadog_monitor.rb | UTF-8 | 5,309 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
# See LICENSE.txt at root of repository
# GENERATED FILE - DO NOT EDIT!!
require 'ansible/ruby/modules/base'
module Ansible
module Ruby
module Modules
# Manages monitors within Datadog
# Options like described on http://docs.datadoghq.com/api/
class Datadog_monitor... | true |
b1aee489a69161eab992189156c8fdbc6dd66d34 | Ruby | szagar/pyzts | /daemons/ibgw2filed/lib/ib_gw_2file.rb | UTF-8 | 62,755 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
$: << "#{ENV['ZTS_HOME']}/etc"
$: << "#{ENV['ZTS_HOME']}/lib"
$: << "#{ENV['ZTS_HOME']}/ib"
require 'store_mixin'
require 'order_struct'
require "s_m"
require "e_wrapper_2file"
require "ib-ruby"
require "json"
require "my_config"
require 'configuration'
require 'mkt_subscriptions... | true |
6b2cac89d175abab858914261dcc2ab5c60f6fa6 | Ruby | mstave/tdg | /td.rb | UTF-8 | 616 | 3.125 | 3 | [] | no_license | class CLI
def load_todos
@todo_arr = IO.readlines("todo.txt")
end
def print_todos
@todo_arr.each { |e| print e }
end
def get_pri(pri)
ret=[]
@todo_arr.each do |td|
ret << td if td.start_with?("(#{pri.upcase})")
end
return ret
end
def parse_todos
case ARGV[0]
whe... | true |
05a2d40fa458355340946041e70068296a0cec2f | Ruby | badBlackShark/meme-translator | /lib/meme-translator/api/api.rb | UTF-8 | 972 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'httparty'
require 'securerandom'
class Api
BASE_URL = 'https://api.cognitive.microsofttranslator.com/'
TYPE = 'application/json'
def initialize(secret, location)
@secret = secret
@location = location
end
def translate(text, to, from: nil)
if text.length > 10000
raise 'Translation... | true |
eb44d9b5ff01c2bad46c0a445965e8b1d7c17482 | Ruby | mvlofthus/tdd-exercise | /test/blackjack_score_test.rb | UTF-8 | 1,919 | 3.15625 | 3 | [] | no_license | require 'minitest'
require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/pride'
require_relative '../lib/blackjack_score'
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
describe 'Blackjack Score' do
it 'can calculate the score for a pair of number cards' ... | true |
2f4f20a9b9bdc13d6eb04cf56a9ecc6477f12348 | Ruby | amandeep1420/RB101 | /RB101/Small Problems/E9r2/6_long.rb | UTF-8 | 1,101 | 4.21875 | 4 | [] | no_license | =begin
P
- write a method that takes a string as an arg, and returns an array that
contains every word from the string - to which you have appended a space
and word length. you may assume that words in the string are separated by
exactly one space, and that any substring of non-space chars is a word
... | true |
1d75b1c3b7edd041c4b7c8884af1adcdfce3ff5e | Ruby | nickKolya/ruby_oop_samples | /prepend_module_simple.rb | UTF-8 | 403 | 3.09375 | 3 | [] | no_license | module TimeManager
def do_homework
p 'Doing homework...'
sleep 10
p 'Process finished!!!'
end
end
class Student
prepend TimeManager
def do_homework
p 'Will not be executed'
end
end
Student.new.do_homework
# "Doing homework..."
# NOTE: process will be paused on 10 seconds
# "Process finish... | true |
60ca0c1f5f1a8147a2a8bd502df5cf097ba02560 | Ruby | fjordllc/bootcamp | /app/decorators/regular_event_decorator.rb | UTF-8 | 666 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module RegularEventDecorator
def holding_cycles
regular_event_repeat_rules.map do |repeat_rule|
holding_frequency = RegularEvent::FREQUENCY_LIST.find { |frequency| frequency[1] == repeat_rule.frequency }[0]
holding_day_of_the_week = RegularEvent::DAY_OF_THE_WEEK_LIST.fin... | true |
69ee9b0fac4215ad6984483cfd4897121fa0c352 | Ruby | tamura2004/discordrb | /src/main.rb | UTF-8 | 990 | 3.078125 | 3 | [
"MIT"
] | permissive | require "natto"
require "yaml"
require "pathname"
require "set"
m = Natto::MeCab.new
a = Set.new
b = Set.new
Pathname.new("src").find do |path|
next unless path.file?
next unless path.extname == ".txt"
m.enum_parse(path.read).each do |n|
if n.feature =~ /^名詞/
next if n.surface.size <= 2
next if ... | true |
c3f9193fcbcf8f197e06ae726afaaa322d18219d | Ruby | xing/typhoeus | /lib/typhoeus/hydra_mock.rb | UTF-8 | 3,036 | 2.8125 | 3 | [
"MIT"
] | permissive | module Typhoeus
class HydraMock
attr_reader :url, :method, :requests, :uri
def initialize(url, method, options = {})
@url = url
@uri = URI.parse(url) if url.kind_of?(String)
@method = method
@requests = []
@options = options
if @options[:headers]
@optio... | true |
342524e077e5a229f9addd523a23f91a14c67559 | Ruby | christhoval06/YouShallNotPassword | /app/controllers/you_shall_not_passwords_controller.rb | UTF-8 | 1,011 | 2.546875 | 3 | [] | no_license | require 'json'
require_relative '../../lib/twitter_sec/dictionary_en'
require_relative '../../lib/twitter_sec/password_evaluator'
class YouShallNotPasswordsController < BaseApiController
attr_accessor :password_evaluator
def initialize
@dictionary = TweetSec::DictionaryEnglish.new
@dictionary.lookup
... | true |
224458a6034bd2eef74ff656ca2f735f2839a447 | Ruby | opheliasdaisies/spider-solitaire | /lib/card.rb | UTF-8 | 187 | 2.578125 | 3 | [
"MIT"
] | permissive | class Card
def initialize(data)
data.keys.each do |key|
self.instance_variable_set(:"@#{key}", data[key])
self.class.send(:attr_reader, :"#{key}")
end
end
end | true |
1cb158830316eb99ee204ebc4a28a510a5a6c88f | Ruby | mrkchoi/aa_prep | /03_SQL/01_ORM/aa_questions/model_base.rb | UTF-8 | 2,166 | 2.765625 | 3 | [] | no_license | require 'active_support/inflector'
require_relative './questions.rb'
require 'byebug'
class ModelBase
CLASS_TO_DB = {
'Question' => 'questions',
'User' => 'users',
'QuestionFollow' => 'question_follows',
'Reply' => 'replies',
'QuestionLike' => 'question_likes'
}
def self.find_by_id(id)
... | true |
f2bb0fff30d21d83c76446b2cafcb9986a3e3663 | Ruby | Mariana-21/launchschool_v2 | /101_Programming_Foundations/lesson_3/easy_1/question_04.rb | UTF-8 | 415 | 4.4375 | 4 | [] | no_license | # question_04.rb
# The Ruby Array class has several methods for removing items from the array.
# Two of them have very similar names. Let's see how they differ:
numbers = [1, 2, 3, 4, 5]
# What do the following method calls do (assume we reset numbers to
# the original array between method calls)?
p numbers.delete_a... | true |
aa21c1599108ae2996eb558b643fb5aa0d6be881 | Ruby | Paahn/jungle-on-rails | /app/models/sale.rb | UTF-8 | 357 | 2.65625 | 3 | [] | no_license | class Sale < ActiveRecord::Base
# define a class method, Active Record scope
def self.active
where("sales.starts_on <= ? AND sales.ends_on >= ?",
Date.current, Date.current).any?
end
def finished?
ends_on < Date.current
end
def upcoming?
starts_on > Date.current
end
def active?
starts_on < Date.curren... | true |
eff40916de904b012a18f15dba3f73bd914a7d30 | Ruby | Precnet/black_jack | /tests/table_spec.rb | UTF-8 | 823 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
require 'rspec'
require_relative '../table.rb'
describe 'Table' do
before(:all) do
@table = Table.new
end
context 'player operation' do
it 'should create an empty table' do
expect(@table.player).to be_nil
expect(@table.dealer).to be_nil
end
it 'should ad... | true |
c6bd8d7876caa3f3b1cae0bb70a6968b899f43b6 | Ruby | cielavenir/codeiq_solutions | /nabetani_takenori/tyama_codeiq3357.rb | UTF-8 | 485 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env ruby
D=[[0,0],[1,0],[2,0],[2,1],[2,2],[1,2],[0,2],[0,1]]
def num2place(n)
n-=1
x=y=0
z=1
while n>0
x+=D[n%8][0]*z
y+=D[n%8][1]*z
n/=8
z*=3
end
[x,y]
end
def place2num(x,y)
n=0
z=1
return nil if x<0||y<0
while x>0||y>0
idx=D.index([x%3,y%3])
return nil if !idx
n+=idx*z
x/=3
y/=... | true |
d906672da74d716665c74c1085094453866ee8d8 | Ruby | rsmease/homework-app-academy | /W1D5/notes.rb | UTF-8 | 4,515 | 3.765625 | 4 | [] | no_license | #DATA STRUCTURES
#CS Concepts that are agnostic to a specific language
#Arrays/Hashes etc. are data structs
#Abstract data types are a level above data structs (ADTs)
#E.g. a Set is an ADT
#Note that both an array and a hash map could be a set (it's more abstract)
#Another abstract data type is a map (dictionary)
... | true |
df4cf4b51dc5a4b0582d0336f61f9f89437457ae | Ruby | mkevins/Ninyni-Cats | /app/models/cat_rental_request.rb | UTF-8 | 1,576 | 2.515625 | 3 | [] | no_license | class CatRentalRequest < ActiveRecord::Base
validates(
:cat_id,
:start_date,
:end_date,
:status,
:user_id,
presence: true
)
validate :no_overlapping_approved_requests_unless_denied
belongs_to :cat
belongs_to :owner, class_name: "User", foreign_key: :user_id
def owner_name
self.... | true |
eeae969eaa76676fa58540f27909f6964b71293f | Ruby | uskey512/AtCoder | /ABC/170/d.rb | UTF-8 | 786 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
N = gets.to_i
P = gets.chomp.split.map(&:to_i)
del = []
P.sort!
(0...N).each do |i|
if P[i] == 0
next
end
tmp = P[i]
if i != (N-1) && tmp == P[i+1]
j = i + 1
while tmp == P[j]
P[j] = 0
j += 1
end
P[i] = 0
del.push(tmp)
end
end
P.sort!
idx = P.find_ind... | true |
7f8c8f8989f97a953d61d87ef13e24b82468777e | Ruby | MauroQuaglia/kata | /spec/underground/time_support.rb | UTF-8 | 228 | 2.5625 | 3 | [] | no_license | module TimeSupport
def minutes(value)
Rational(value * 60, 86400)
end
def hours(value)
minutes(value * 60)
end
def days(value)
hours(value * 24)
end
def years(value)
days(value * 365)
end
end | true |
5b964e6f4ddeeffd5f2fd12c99a4b423a5caaa40 | Ruby | Ayukito/Ruby-File-Loader | /Ruby File Loader/Project/pokemonsdk/scripts/01200 PFM/00100 Global Systems/02000 Hall_of_Fame.rb | UTF-8 | 1,139 | 2.796875 | 3 | [] | no_license | module PFM
# Class describing the Hall_of_Fame logic
class Hall_of_Fame
# Array containing every victory of the player
# @return [Array]
attr_accessor :player_victory
def initialize
@player_victory = []
end
# Register a win in the Pokemon League for the player
# @param mode [Symbo... | true |
7f0163059d14d88a9ac3381fdae823925c8828c9 | Ruby | jetpackpony/coursera-algorithms | /week1/count_inversions.rb | UTF-8 | 1,012 | 3.875 | 4 | [] | no_license | require 'byebug'
class Inversions
def initialize arr
@counter = 0
@arr = arr
end
def count_inversions
puts @arr.length
arr = count @arr
puts arr.length
return @counter
end
private
def count arr
return arr if arr.length == 1
split = arr.each_slice((arr.length / 2.0).ceil).... | true |
b76ebf32aceca9dd12b4cf2e461de3ef556476e4 | Ruby | bl0rch1d/library | /entities/book.rb | UTF-8 | 392 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../utils/validate'
class Book
include Validate
attr_reader :title, :author
def initialize(title:, author:)
validate title, author
@title = title
@author = author
end
def to_s
"#{title}, #{author}"
end
private
def validate(title, aut... | true |
ae2875f25072568b9775ea47bc0b5fcc75760400 | Ruby | shreyansdjp/ttt-game-status-cb-gh-000 | /lib/game_status.rb | UTF-8 | 2,853 | 3.953125 | 4 | [] | no_license | # Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
def won?( board )
WIN_COMBINATIONS.each do |comb... | true |
6e9105caad3a5b612a71ad460fc4211052b9a635 | Ruby | sngeth/project_euler | /1.rb | UTF-8 | 285 | 3.9375 | 4 | [] | no_license | #If we list all natural numbers below 10 that are multiples of 3 or 5, we get 3,
#5 ,6, and 9. The sum of these multiples is 23.
#Find the sum of all the multiples of 3 or 5 below 1000
sum = 0
(1..999).each do |num|
sum += num if num % 3 == 0 || num % 5 == 0
end
puts sum #233168
| true |
46a753bb5becacd49536992c1f76908587460c05 | Ruby | slewis96/PokemonClassExerciseRuby | /Characters/PokemonTypes/flying_normal.rb | UTF-8 | 245 | 2.6875 | 3 | [] | no_license | require_relative "../pokemon.rb"
module FlyingNormalType
class Weaknesses
def self.weakto
puts " x2 from: Electric, Rock"
end
def self.resists
puts " x0.5 from: Grass, Bug / x0 from: Ground, Ghost"
end
end
end
| true |
518df8662a0fcfaecc639f2cd94c29dca4b031ab | Ruby | CITguy/ratatouille | /lib/ratatouille/array.rb | UTF-8 | 3,485 | 3.03125 | 3 | [
"MIT"
] | permissive | module Ratatouille
# Module used to provide Array-specific validation methods
module ArrayMethods
# Iterator method to encapsulate validation
#
# @note Method will NOT work without a block
# @param [Hash] options
# Accepts global options in addition to the following:
# @option optio... | true |
1977e2e176fd842503a0431aae0a84c365737c84 | Ruby | 29medium/Exercism | /ruby/grade-school/grade_school.rb | UTF-8 | 484 | 3.421875 | 3 | [] | no_license | =begin
Write your code for the 'Grade School' exercise in this file. Make the tests in
`grade_school_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/grade-school` directory.
=end
class School
def initialize
@students = Hash.new(Array.new)
end
def add(stu, grade)... | true |
9295f0ac721e8a3849747a2a3750b3d0f521a534 | Ruby | hskrasek/faraday-sunset | /lib/faraday/sunset.rb | UTF-8 | 1,944 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'faraday'
module Faraday
class Sunset < Faraday::Middleware
class NoOutputForWarning < StandardError; end
# Initialize the middleware
#
# @param [Type] app describe app
# @param [Hash] options = {}
# @return void
def initialize(app, active_support: nil, logger: nil)
super(a... | true |
7aaedfa4db9cb4897ee7a6e25a362f553373e345 | Ruby | shawn42/netz | /script/run_client.rb | UTF-8 | 97 | 2.53125 | 3 | [] | no_license | require 'netz'
client = Netz::Client.new
client.join ARGV.pop
puts "client is waiting..."
gets
| true |
23aa2ee284f4a9d05ba3063d3ca77cff532541fd | Ruby | Kevinhcross96/phase-0-tracks | /ruby/santa.rb | UTF-8 | 1,946 | 3.453125 | 3 | [] | no_license | class Santa
attr_accessor :gender
attr_reader :age, :ethnicity, :reindeer_ranking
#def age
#@age
#end
#def ethnicity
#@ethnicity
#end
#def reindeer_ranking
#@reindeer_ranking
#end
#def gender=(new_gender)
#@gender = new_gender
#end
def celebra... | true |
7689d014dbf6ab4469684bd4a01f97f58c3bc912 | Ruby | voodoo15/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 1,158 | 4.125 | 4 | [] | no_license | require "pry"
#Exercise Debugging and Testing
#Example 4
#Name: Arnold Redoblado
#Date: 2016-03-30
#Purpose: Create a class(es) that'll pass a test script
# This example requires methods that will take string
# values and manipulate and return string.
def echo( word )
word
end
def shout( word ... | true |
be439e61551ebcf2a4cc4e9c2364984f50b8d396 | Ruby | BlueMorning/w2_d1_OOP | /specs/test_sports_team.rb | UTF-8 | 1,098 | 3.15625 | 3 | [] | no_license | require ('minitest/autorun')
require_relative('../sports_team.rb')
class TestSportsTeam < MiniTest::Test
def setup
@team = SportsTeam.new("Real Madrid", ["Ronaldo", "Benzema", "Bale"], "Zidane")
end
def test_team_name
assert_equal("Real Madrid", @team.team_name)
end
def test_players
assert_eq... | true |
7e77092b934e30d8f96ef97c76f33ef5cb8dbe7d | Ruby | mac718/project_cli_connect_four | /connect_four/lib/computer_player.rb | UTF-8 | 2,107 | 3.53125 | 4 | [] | no_license | require 'pry'
class ComputerPlayer
#private
def almost_win_horizontal?(current_player_piece, board)
board.each_with_index do |row, row_index|
position_index = 0
while position_index <= 4
if row[position_index..(position_index + 3)].count('B') == 3
return (position_index + row[po... | true |
3d447de2d537b375b24a6d419d688b099f3c2cfd | Ruby | Xrazik1/thinknetica_ror | /lesson_2/task_2.rb | UTF-8 | 29 | 3.015625 | 3 | [] | no_license |
puts (5..100).step(5).to_a
| true |
84ae690bf39b57496d7cdbf6900e54153b8f06b3 | Ruby | Besseeboy0947/oo-kickstarter-v-000 | /lib/project.rb | UTF-8 | 251 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Project
attr_accessor :backers
attr_reader :title
def initialize(project_name)
@backers = []
@title = project_name
end
def add_backer(backer)
backer.backed_projects << self
backers << backer
end
end
| true |
86373af27f9fb9c844972a623ceee856b62de950 | Ruby | Bello-Bello/bbs-v2 | /chapter-6/section-6.5/05-file_handling.rb | UTF-8 | 656 | 3.484375 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env ruby
# Read the whole contents of a file into a string
file = File.open("BRCA1.fasta","r").read
# Read the whole contents of a file into an array
# (this would also be the approach to use if you wanted to
# read a file line by line)
file = []
File.open("BRCA1.fasta","r").each_line do |line|
file.pus... | true |
a8b69e97421809e096b3fa26d8c122a00d2e7ec1 | Ruby | baezanat/Launch_School_bootcamp | /RB_100/Introduction_to_Programming/hashes/exercise_2.rb | UTF-8 | 259 | 2.65625 | 3 | [] | no_license | phil_books = {Phenomenology: "Hegel",
Modern: "Kant"}
fiction = {Mystery: "Kristeva",
Psychology: "Dostoyevski"}
all = phil_books.merge(fiction)
p all
p phil_books
p fiction
phil_books.merge!(fiction)
p "original array:"
p phil_books | true |
6f9971f52c3b5d6606cdd4773e2294ee8f8d7fcf | Ruby | hdhmail2000/nextcoin | /dep/load_accounts.rb | UTF-8 | 2,276 | 2.5625 | 3 | [] | no_license | #
# build in
require 'logger'
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '.'))
require 'config'
require 'lib/bitcoin_rpc'
require 'db/token_dao'
require 'db/account_dao'
require 'db/baseinfo_dao'
#使用教程
# 0. 前提:配置好baseinfo表格
# 1. 配置数据库
# 2. 运行程序
if $0 == __FILE__
#输出到文件,统一填写绝对路径,文件名log.... | true |
964ab85e2139faf5deb83650721936cd608e8beb | Ruby | shvets/etv | /lib/etv/engine/cookie.rb | UTF-8 | 605 | 3.15625 | 3 | [] | no_license | require 'cgi'
require 'time'
class Cookie
attr_reader :value
def initialize value
@value = value
@expires ||= calculate_expires
end
def expired?
@expires.nil? ? false : (Time.parse(@expires) < Time.now)
end
private
def calculate_expires
items = @value.split(";").collect do |item|
... | true |
2d369fbd4a8c11636a5ac6f24fdeb408539149e9 | Ruby | rrrene/inch | /lib/inch/utils/weighted_list.rb | UTF-8 | 2,481 | 3.4375 | 3 | [
"MIT"
] | permissive | module Inch
module Utils
class WeightedList
# Trims down a list of object lists to given sizes.
# If there are not enough objects in any particular tier,
# they are filled up from the tier below/above.
#
# @example
#
# list = [
# [:B1, :B2],
# [:C1, ... | true |
328b0b8ade6fab4eef948c58154dba8c52b11e5b | Ruby | ali-inc/Training-Material-Copy | /Week9/friday/postcode_som/lib/postcode.rb | UTF-8 | 387 | 2.546875 | 3 | [] | no_license | require_relative 'services/single_postcode_service'
require_relative 'services/multiple_postcode_service'
class Postcodesio
def single_postcode_service
SinglePostcodeService.new
end
def multiple_postcode_service
MultiplePostcodeService.new
end
end
# postcode_services = Postcodesio.new
# puts postco... | true |
066f683024b3109bf03b1a661c492becbcf4ee15 | Ruby | dahngeek/ruby-example-cartrips | /app/models/vehicle.rb | UTF-8 | 722 | 2.8125 | 3 | [] | no_license | class Vehicle < ApplicationRecord
belongs_to :vehicle_type
has_many :trips
validates :brand, :model, :plate, :year, :vehicle_type_id, :presence => true
validate :according_to_type
def according_to_type
@type = VehicleType.find(vehicle_type_id);
errors.add(:max_weight, 'cant be nil') if (@type.name ... | true |
77d9b166979db3ddf0571c88f5f06588d77c3a47 | Ruby | deivid-rodriguez/parallel_tests | /spec/integration_spec.rb | UTF-8 | 26,129 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
describe 'CLI' do
before do
FileUtils.remove_dir(folder, true)
end
after do
FileUtils.remove_dir(folder, true)
end
def folder
"/tmp/parallel_tests_tests"
end
def write(file, content)
path = "#{folder}/#{file}"
ensure_folder File.d... | true |
5cb96eab5c8482d373cb52bfbbfe4c24f345e602 | Ruby | simonmcc/buildwifi | /clients.rb | UTF-8 | 905 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'nokogiri'
require 'openssl'
def count_users(devices)
devices.each do |name,device|
uri = "wget --timeout=2 https://#{device} --user=admin --password=s2iabos --no-check-certificate -qO-"
uri = "curl -k --user admin:s2iabos https://#{device}"
... | true |
a7ffede2131a8fdbb5876ac5dc433952734015b0 | Ruby | jasonlhoward/ls-basics | /loops1/e5.rb | UTF-8 | 106 | 3.3125 | 3 | [] | no_license | say_hello = true
counter = 0
while say_hello
puts 'Hello!'
counter += 1
say_hello = counter < 5
end
| true |
d01aad6e56c34e8810374447bd116330988a9a9c | Ruby | drjolo/RubyLearning | /week_3/exercise7-Text_analyzer.rb | UTF-8 | 2,277 | 3.953125 | 4 | [] | no_license | =begin
Your text analyzer will provide the following basic statistics:
Character count
Character count (excluding spaces)
Line count
Word count
Sentence count
Paragraph count
Average number of words per sentence
Average number of sentences per paragraph
=end
=begin
doctest: Text Analyzer works!
>> puts 'hello wor... | true |
30236a033212b1fb6ef13c6cf14989198c08cddc | Ruby | hilarysk/Dinner-club-project | /person_test.rb | UTF-8 | 768 | 3.015625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'person_class.rb'
require "pry"
class PersonTest < Minitest::Test
#tests go here
#Each test method should start with test_, ala:
def test_simple_input_with_expected_integer_output
cs = Person.new("Batman")
assert_equal(0, cs.spend)
end
def test_add... | true |
c5de20b3fc4cf644aff3692457d4754a9b3f2909 | Ruby | knewter/bolts | /hamlr.thor | UTF-8 | 1,594 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'find'
require 'rubygems'
begin
require 'haml'
require 'haml/exec'
rescue LoadError => e
dep = e.message[/^no such file to load -- (.*)/, 1]
$stderr.puts <<MESSAGE
Required dependency #{dep} not found!
Run "gem install #{dep}" to get it.
MESSAGE
exit 1
end
class Hamlr < Thor
desc "hamltime", "convert all... | true |
432685d6c694b9d4d4b68fe4c0608676c45d2321 | Ruby | gmenz1/programming-univbasics-2-statement-repetition-with-while-nyc01-seng-ft-082420 | /lib/count_down.rb | UTF-8 | 98 | 3.390625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your code here
x = 10
while x > 0 do
puts "#{x}"
x -= 1
end
puts "Happy New Year!" | true |
7dd1b06100f8896d86d539461477eb0fded80949 | Ruby | firmoholanda/studying | /leetcode/312_burst_balloons.rb | UTF-8 | 910 | 3.421875 | 3 | [] | no_license | # https://leetcode.com/problems/burst-balloons/
# dynamic programming
# https://www.youtube.com/watch?v=vYquumk4nWw
# @param {Integer[]} nums
# @return {Integer}
def max_coins(nums)
# add 1 to start and end
nums.insert(0, 1)
nums.insert(nums.size, 1)
# initialize dp array. dp[l][r] is the max result of num... | true |
e0630d63a172b4076fdad048aa0a3749ecb10b4d | Ruby | martasmartinho/TP1_EW_G3 | /Server/Logic/client.rb | UTF-8 | 2,541 | 2.984375 | 3 | [] | no_license | load '../Server/DataAccess/data_client.rb'
load '../Server/DataAccess/data_reading.rb'
class Client
#fields
attr_accessor :client_id, :is_connected, :location, :readings, :temperature_counter, :acoustic_counter
#Constructor
def initialize(client_id = 0, is_connected = false, location = 000000)
@client_... | true |
e1a448913d7b3e5a9b633e49346449d2e9204d80 | Ruby | ochibi1/furima_app | /spec/models/product_spec.rb | UTF-8 | 6,909 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
describe Product do
describe "#create" do
let(:category) { create(:category) }
before do
category
end
it "is valid with a name, introduction,size_id, condition_id, postage_payer_id, prefecture_code, prep_date_id, price, trading_status, seller_id " do
product = buil... | true |
48fd8e7afb0fa3bd5a7b36303da1aeaf0ea8b3a0 | Ruby | tanuka16/key-for-min-value-dumbo-web-051319 | /key_for_min.rb | UTF-8 | 503 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
return nil if name_hash.empty?
#get the first key:value pair by using .first method
min_key, min_value = name_hash.first
name_hash.collect do |k, v|
# i... | true |
3fb4e8424f0517ac4963acd7094622ac76e0be9e | Ruby | rentalname/tddbc4th | /lib/person.rb | UTF-8 | 650 | 3.65625 | 4 | [
"Apache-2.0"
] | permissive | class Person
attr_reader :family_name
attr_reader :first_name
attr_reader :birthday
def initialize(family_name:, first_name:, gender:, birthday:)
raise ArgumentError unless [:male, :female].include? gender
raise ArgumentError if family_name.to_s =~ /\A\s*\z/
raise ArgumentError if first_name.to_s =... | true |
5e44b647d6df014cc4f3b26fddc780f0a8eaada6 | Ruby | Lindsay-c-Dennis/max-fun-CLI-gem | /lib/maximumfun/CLI.rb | UTF-8 | 4,333 | 3.09375 | 3 | [
"MIT"
] | permissive |
class CLI
#welcomes user, calls methods to scrape website, calls method to start program
def call
puts " ________________________________________________________________________"
puts " / \\ "
puts "| __ __ _ ... | true |
115a7eec1f7f6ada39ef9790419164348525c806 | Ruby | TheLastSultan/DevelopmentPorfolioDevelopment | /db/seeds.rb | UTF-8 | 2,508 | 2.515625 | 3 | [] | no_license | User.create!(
email: "mozeiny@gmail.com",
password: "allah199",
password_confirmation: "allah199",
name: "Admin User",
roles: "site_admin"
)
puts "1 Admin user created"
User.create!(
email: "test2@test.com",
password: "asdfasdf",
password_confirmation: "asdfasdf",
name: "Regular User",
)
puts "1 re... | true |
7c7c0caad69d48ca1e8472d8250c8d2d011813a6 | Ruby | Phoenix-GH/filmfans-cms | /app/serializers/collections_container_serializer.rb | UTF-8 | 688 | 2.625 | 3 | [] | no_license | class CollectionsContainerSerializer
def initialize(collections_container)
@collections_container = collections_container
end
def results
return '' unless @collections_container
generate_collections_container_json
end
private
def generate_collections_container_json
{
type: 'collecti... | true |
c8185805e8b7cdbf2f4ecbe98ecb3d6a3460360f | Ruby | bennorris/domestic_goods-cli-gem | /lib/domestic_goods/american_list.rb | UTF-8 | 1,783 | 2.8125 | 3 | [
"MIT"
] | permissive | class DomesticGoods::AmericanList
@@lists = []
def self.lists
@@lists
end
def self.assorted_scraper
@@lists = []
doc = Nokogiri::HTML(open("http://www.acontinuouslean.com/the-american-list/"))
doc.css("div.brands p").each do |company|
@@lists << h = DomesticGoods::Company.new({
:name => company.se... | true |
0658f37f08e4702cf1f8c5dfc618c7269f0907ec | Ruby | ljnissen/rubycode | /009/file_04.rb | UTF-8 | 282 | 3.734375 | 4 | [] | no_license | print "Please enter the identifier: "
identifier = gets
def words(identifier)
return identifier.each_char.to_a {|word| words.downcase }
if word[0] == "A"
print "The identifier is valid."
else
print "The identifier is not valid"
end
end
#print "As array: ", words(gets)
| true |
2a6bfc05b849d81fa1b8cfeba542da1b198f45d7 | Ruby | Steinunn89/object_oriented_programming | /rough work/example.rb | UTF-8 | 2,290 | 3.9375 | 4 | [] | no_license | #my_variable = "some value" #local variable - can't access inside initialize
#$my_variable = "some value" #global
class Point
#@@my_class_variable = "You can access me from the Class level"
#attr_reader :x, :y
#attr_writer :x, :y
attr_accessor :x, :y
def initialize (x,y)
#never have to call, .new utilizes, but ... | true |
805c3eed2896274f37ca7850824c76158ea8c6c0 | Ruby | ArmardB/Learn-Ruby-The-Hard-Way | /Exercise 45/ex45.rb | UTF-8 | 972 | 4.15625 | 4 | [] | no_license | ## Animal is-a object (yes, sort of confusing) look at the extra credit
class Animal
end
## ??
class Dog < Animal
def intialize(name)
## ??
@name = name
end
end
## ??
class Cat < Animal
def intialize(name)
## ??
@name = name
end
end
## ??
class Person
attr_accessor :pet
def initialize(name)
##??... | true |
80bdd4711cef23fc845f8ffa9c37a033f0aad5f6 | Ruby | BloomAndWild/email_address | /lib/email_addr.rb | UTF-8 | 3,396 | 2.671875 | 3 | [
"MIT"
] | permissive |
module EmailAddr
require "email_addr/config"
require "email_addr/exchanger"
require "email_addr/host"
require "email_addr/local"
require "email_addr/address"
require "email_addr/version"
require "email_addr/active_record_validator" if defined?(ActiveModel)
if defined?(ActiveRecord) && ::ActiveRecord::... | true |
a6ae316693261ae8b5946f01dbcf57f43c6ec22c | Ruby | railsc0d0r/global8ball_game | /spec/models/global8ball_game/configuration/ball_position_spec.rb | UTF-8 | 3,991 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
module Global8ballGame
module Configuration
RSpec.describe BallPosition, type: :model do
before do
@ball_position_config = BallPosition
@known_stages = ["PlayForBegin", "PlayForVictory", "ShowResult"]
end
it "raises an error if no stage is given as argume... | true |
5fb6de2a3d3805a96febc9399c177882df0d9e0e | Ruby | RocketRobC/property_finder | /lib/property_logger/entities/financial_data.rb | UTF-8 | 566 | 2.796875 | 3 | [] | no_license | class FinancialData < Hanami::Entity
DUTY_ESTIMATE = 0.043
def duty_and_max
amount = total_funds_in_dollars - (total_funds_in_dollars * DUTY_ESTIMATE)
duty_for(amount)
end
def max_spend
duty_and_max[1]
end
private
def duty_for(amount)
duty = StampDutyService.new(amount.round(0)).amount... | true |
375763516617bb866f343f131fa75eec50f4c210 | Ruby | addisoncole/hotel | /lib/block_room.rb | UTF-8 | 481 | 2.65625 | 3 | [] | no_license | require_relative 'reservation'
module Hotel
class Block_Room < Reservation
attr_reader :room_number, :check_in_date, :check_out_date, :nights_of_stay, :block_name, :block_discount
attr_accessor :block_reservation_status, :name
BLOCK_RESERVATION_STATUS = [:AVAILABLE, :BOOKED]
def initialize(input)
... | true |
fcf09c2d6b59ed7206035cdff170dba92546e672 | Ruby | MantasN/ruby-autoservice | /app/models/detail.rb | UTF-8 | 310 | 2.609375 | 3 | [] | no_license | # This is the repair details class which contains the
# information about car and owner of the repair order
class Detail < ApplicationRecord
belongs_to :order, inverse_of: :detail
validates :reason, :car, :owner, presence: true
def to_s
"[Reason: #{reason}; Car: #{car}; Owner: #{owner}]"
end
end
| true |
b3ee2cf98603c48adb84e4b4820ff1dcc4267fe6 | Ruby | BatesJernigan/finviz-crawler | /lib/low_pe_analyzer.rb | UTF-8 | 2,506 | 2.84375 | 3 | [] | no_license | require_relative "base.rb"
class LowPeAnalyzer < Base
FOLDER_PATH = "#{Dir.pwd}/csv_files/low_pe"
HEADERS = ["Ticker", "Company", "Sector", "Industry", "Country", "Market Cap", "P/E", "Price"].freeze
def screener_content(record_offset = 1)
# TODO: add other filter options
resp = self.class.get("/screene... | true |
71f4edaa11a67147636aed6f0806604fec6eed47 | Ruby | PayTrace/paytrace_ruby | /test/paytrace/api/request_spec.rb | UTF-8 | 4,010 | 2.609375 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '../../../test_helper.rb')
require 'paytrace/api/request'
describe PayTrace::API::Request do
before do
PayTrace.configure do |config|
config.user_name = "test"
config.password = "test"
end
end
it "sets the user name, password, and terms param... | true |
ec9d3cb113a20a03c4b17ab2ce9dbbd8d95db2f8 | Ruby | CounterSeal/ruby-newbie | /advent-of-code/day-02.rb | UTF-8 | 1,112 | 3.78125 | 4 | [] | no_license | # Advent of Code
# http://adventofcode.com/
# Day 2
# Part One
def total_paper(dimensions)
sides = dimensions.split("x").map { |n| n.to_i }
length, width, height = sides[0], sides[1], sides[2]
a, b, c = (length * width), (width * height), (height * length)
min_area = [a, b, c].min
result = (2 * a) + (2 * b) + (2 ... | true |
9d4d24781bdf99bfb4fe65bd8d5dec4bfec2bca5 | Ruby | DawidGaleziewski/LocalUdemyRuby | /23_upto_downto_methods.rb | UTF-8 | 632 | 3.9375 | 4 | [] | no_license | #Method on int class
#accept argument
#accept blocks
5.downto(1) {|i| puts "Countdown: #{i}" }
5.downto(0) do |current_number|
puts "We are currently on #{current_number}"
puts "Hooray!"
end
puts "Liftoff!"
10.upto(100){|i| puts "Number is #{i + 1}"}
5.upto(100) do |num|
puts "We're moving on up!"
puts "We ... | true |
17d2d88b77ee1de77f2e50ca29743b29404b9f36 | Ruby | sgonzalez/crosswalk-simulation | /Crosswalk/simulation.rb | UTF-8 | 9,064 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
#######################
## Santiago Gonzalez ##
#######################
require_relative "eventlist"
require_relative "welford"
require_relative "lehmers"
require_relative "person"
require_relative "events"
require_relative "rvgs"
require_relative "car"
DISTANCE_EDGE_MIDDLE = 1155 # distance from... | true |
77920df8f12c3cef243c509f40ffc9f2a26100e1 | Ruby | askl56/income-tax | /spec/income_tax/countries/albania_spec.rb | UTF-8 | 4,867 | 2.78125 | 3 | [
"MIT"
] | permissive | describe IncomeTax::Countries::Albania do
subject(:result) { described_class.new(income: income, income_type: type, tax_year: tax_year) }
let(:type) { :gross }
describe 'from gross income of 0' do
let(:tax_year) { 2015 }
let(:income) { 0 ... | true |
b26bead3ac6cb2fbe7675382f7563ef53a201027 | Ruby | serdg0/My_enumerables | /main.rb | UTF-8 | 1,659 | 3.796875 | 4 | [] | no_license | arr = [5,6,4,1,3,2,7,9,8]
strings = ["hi", "hello", "hey"]
hash = { "cinco": 5, "three": 3, "four": 4}
module Enumerable
def my_each
i = 0
while i < self.size
yield(self[i])
i += 1
end
self
end
def my_each_index
i = 0
while i < self.... | true |
1138fa1e945888ee0c059e7a6fcf4c102a9b1570 | Ruby | xm/anygram | /app/models/profile.rb | UTF-8 | 473 | 2.75 | 3 | [] | no_license | class Profile < ActiveRecord::Base
SEX_OPTIONS = { unknown: 0, male: 1, female: 2 }
validates_presence_of :name, :display_name, :sex
validates_uniqueness_of :name, case_sensitive: false
validates_inclusion_of :sex, in: SEX_OPTIONS.values
validate :name, :valid_name_format
belongs_to :user
def valid_nam... | true |
c9261f7d0da2aa42a6f4baf090935d039b7e4cd9 | Ruby | Angelorup/Kattis | /Problems/difficulty_1/r2.rb | UTF-8 | 156 | 3.375 | 3 | [] | no_license |
def r2
input = gets.to_s.split(" ")
number1 = input[0].to_i
number2 = input[1].to_i
sum = number2 * 2
total = sum - number1
puts total
end
r2
| true |
440d72204478731dc3e124e3a3288f41876bd350 | Ruby | ledewitt/Training | /Well_Grounded_Rubyist/chp5/p_130_Global_Variables.rb | UTF-8 | 228 | 3.28125 | 3 | [] | no_license | $gvar = "I'm a global!"
class C
def examine_global
puts $gvar
end
end
c = C.new
c.examine_global
local_var = "I'm not a global!"
class D
def examine_global
puts local_var
end
end
d = D.new
d.examine_global
| true |
107d5f5ccc6c5d07f8fc42903858fe6fa265c251 | Ruby | threedaymonk/net-rtmp | /bin/analyze-capture | UTF-8 | 1,225 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'net/rtmp'
require 'pp'
DATATYPE_NAMES = Net::RTMP::DATATYPES.invert
def inspect_packet(packet)
puts(
"Content type: 0x%x (%s)" % [packet.content_type,
DATATYPE_NAMES[packet.content_type] || '?'],
"Stream ID: 0x%x" % packet.stream_id,
"Timest... | true |
e5df8700767ad2fc8ba44a6ad428e2acc299d4db | Ruby | NotBadCode/SPOJandTimus | /SPOJ/Ruby/COMPSEM2.rb | UTF-8 | 187 | 2.859375 | 3 | [] | no_license | z=gets.to_i
z.times do
x=gets
if x =~/^1{1,}$/
puts 'TARANI'
elsif x =~/^5{1,}$/
puts 'AMIT'
elsif x =~/^1*6{1,}$/
puts 'KAUSHIK'
else
puts 'NONE'
end
end | true |
18528e4648eef725c2fa0d099e7db11d86a9963d | Ruby | FredrikSigvartsen/project-uno | /app/models/lobby.rb | UTF-8 | 335 | 2.78125 | 3 | [] | no_license | class Lobby < ActiveRecord::Base
has_many :games
def initilialize
super
end
def add(game)
if validate(game)
games << game
else
return false
end
save
reload
game
end
def remove(game)
games.delete(game)
game
end
def validated? game
#Check if game is active or not
# game.active?
... | true |
f02765cfc329daff4bbe478903a55c85dfb71101 | Ruby | ealdent/neweden-km-parser | /lib/neweden-km-parser.rb | UTF-8 | 4,554 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class KillmailParser
REGEXP_PRIMITIVES = {
:victim_name => "Victim: (.*)",
:corp => "Corp: (.*)",
:alliance => "Alliance: (.*)",
:faction => "Faction: (.*)",
:destroyed => "Destroyed: (.*)",
:system => "System: (.*)",
:se... | true |
ba62e49c560a3035970a0f5a25c70c7b5a17e3b3 | Ruby | lloydpick/lolbase | /lib/lolbase/exceptions.rb | UTF-8 | 1,402 | 2.65625 | 3 | [] | no_license | module Lolbase
module Exceptions
def self.raise_me(code, options = {})
case code
when "noCharacter"
raise CharacterNotFound.new(options[:character_name])
else
raise StandardError.new("The site returned an error: #{code.to_s}")
end
end
class InvalidXML < Sta... | true |
18b75a753e76fde2e0166b5ee8317b1b7bf72e6b | Ruby | ripta/drydock | /lib/drydock/plugins/npm.rb | UTF-8 | 694 | 2.53125 | 3 | [
"MIT"
] | permissive |
require_relative 'base'
module Drydock
module Plugins
# Drydock plugin to interface with `npm` inside a container. This plugin
# assumes that the `npm` command already exists beforehand.
class NPM < Base
# Install one or more packages, each provided as a string.
#
# Flags may be provi... | true |
35fd685cab87c429ca8bb82e899c38c704136c64 | Ruby | karthik51199/saas-201 | /day3/2accessSpecifiers.rb | UTF-8 | 99 | 3.203125 | 3 | [] | no_license | class Book
def m1
puts "m1"
end
def m2
puts "m2"
end
private :m2
end
b = Book.new
b.m1
| true |
c3e1064e809490931082a2a5aeb4002818419a70 | Ruby | ervinismu/ruang-datar | /lingkaran.rb | UTF-8 | 93 | 2.671875 | 3 | [
"MIT"
] | permissive | print "Masukkan Jari-Jari Lingkaran : "
r=gets.to_f
ll=3.14*r*r
print "Luas Lingkaran = ",ll
| true |
58f8ea1e61f2c5e0ae2c875471aff4a3e57b9a35 | Ruby | yodev21/vending_machine_app | /lib/message.rb | UTF-8 | 6,516 | 3.109375 | 3 | [] | no_license | module Message
private
def self.insert_message(money)
print "--------------------------------------------------------------------------------------------------------------------\n"
print "#{money}円投入されました!\n"
end
def self.current_total_message(total: 0)
print "-------------------------------------... | true |
3704edba57897a7269c88ed2fe2ac088b3b9a904 | Ruby | ayacai115/LeetCode | /solutions/929_unique_email_addresses/hash_map.rb | UTF-8 | 501 | 3.171875 | 3 | [] | no_license | # Title: Unique Email Addresses
# Problem URL: https://leetcode.com/problems/unique-email-addresses/
# Solution URL: https://leetcode.com/problems/unique-email-addresses/solution/
# Approach: HashMap
###############
# my solution
###############
# @param {String[]} emails
# @return {Integer}
def num_unique_emails(em... | true |
7dae2ca5ecb80752612dda5488fa32c0d7f896f5 | Ruby | alirezaandersen/rain_or_shine | /app/services/underground_weather_service.rb | UTF-8 | 1,085 | 2.5625 | 3 | [] | no_license | class UndergroundWeatherService
def initialize
@connection = Faraday.new(url: "http://api.wunderground.com/api/#{ENV["UNDERGROUND_APP_KEY"]}/")
@connection.headers["Authorization"] = ENV["UNDERGROUND_APP_KEY"]
end
def test_api
#http://api.wunderground.com/api/f9bc7bc5873d396b/conditions/q/CA/San_Fra... | true |
751a0df278c5c3ab40ff969a131332a9712623b6 | Ruby | bliuredhat/second_pdc | /errata-rails/lib/optional.rb | UTF-8 | 493 | 3.125 | 3 | [] | no_license | module Optional
# Call a given block, catching and logging any exception thrown.
# Intended for executing tasks that should work, but if they do not,
# sould not cause the more important containing task to fail.
#
# Syntactic sugar to avoid tons of begin..rescue statements
def optionally(name = '', logger =... | true |
cab1718619e02c7d17b9f7ac7ffbd431d55babe3 | Ruby | exagil/SampleApp | /test/models/micropost_test.rb | UTF-8 | 1,583 | 2.59375 | 3 | [] | no_license | # == Schema Information
#
# Table name: microposts
#
# id :integer not null, primary key
# content :text
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# picture :string
#
require 'test_helper'
class MicropostTest < ActiveSupport::Tes... | true |
4e4e4222dc7dbd58d5233c9ac41c5745873db1ea | Ruby | NUSGreyhats/write-ups | /resources/files/hitcon/simple/simple-01018f60e497b8180d6c92237e2b3a67.rb | UTF-8 | 1,462 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'sinatra/base'
require 'sinatra/cookies'
require 'openssl'
require 'json'
KEY = IO.binread('super-secret-key')
FLAG = IO.read('/home/simple/flag').strip
class SimpleApp < Sinatra::Base
helpers Sinatra::Cookies
get '/' do
auth = cookies[:auth]
if auth
begin
auth ... | true |
02acd295d6129e2c8c59f5777d8284df95e2dd71 | Ruby | GetsuKami-Hao/my_ruby | /program/100_module.rb | UTF-8 | 215 | 3.015625 | 3 | [] | no_license | module M
def yourname
p 'kakarot'
end
end
module Kernel #add method in Kernel
def whatsyourname
p 'my name is kakarot'
end
end
include M
whatsyourname
yourname
p Kernel.private_instance_methods
| true |
978d44f11beea6d9fdb7f50b0c2139635178d14e | Ruby | sumedhan/math-game | /question.rb | UTF-8 | 592 | 4.3125 | 4 | [] | no_license | # class that creates a basic math question using numbers 1 to 20
class Question
def initialize
@number1 = rand(1..20);
@number2 = rand(1..20);
@operator = ['+','-','*','/'].sample
@answer = eval(@number1.to_s + @operator + @number2.to_s)
end
def statement
operator_text =
case @operato... | true |
5f5c9dbbb595e24a128ad34bf3e1bd0df21038c4 | Ruby | melborne/yampla | /bin/yampla | UTF-8 | 1,730 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "yampla"
require "trollop"
class OptionParser
def self.parse!
Trollop::options do
version "yampla #{Yampla::VERSION} (c) 2013 kyoendo"
banner ~<<-EOS
Yampla is a builder to build index and each item pages from YAML data with a template engine. Liquid is used for th... | true |
5465b43577dd49ba6a6aa7e37e327ec7a3848469 | Ruby | PatriciaArnedo/programming-univbasics-4-finding-the-maximum-value-in-an-array-lab-nyc01-seng-ft-100520 | /lib/finding_the_max_value.rb | UTF-8 | 168 | 3.15625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_max_value(array)
# Add your solution here
x = 0
for i in 0...array.length()
if array[i] > x
x = array[i]
end
end
return x
end
| true |
e00ed48512b9785e988f9ab3e458c1ba58c4fd6a | Ruby | aarondevon/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 1,380 | 4.1875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Question 1
def sort_array_asc(array)
array.sort
end
# Question 2
def sort_array_desc(array)
array.sort {|least, greatest| greatest <=> least}
end
# Question 3
def sort_array_char_count(array)
array.sort do |first, second|
first.length <=> second.length
end
end
# Question 4
def swap_elements(array)
spot... | true |
bad1cc3181431a883fb48a99cfeaaad8f893eec9 | Ruby | MAPC/know-place-api | /app/queries/area_query.rb | UTF-8 | 489 | 2.671875 | 3 | [
"MIT"
] | permissive | class AreaQuery
def initialize(geojson)
@geojson = geojson
end
def execute
begin
GeographicDatabase.connection.execute to_sql
rescue
# NO OP
# TODO: We should at least be logging.
ensure
# NO OP
# Do we need an ensure clause when there's nothing happening in it?
... | true |
3cb11ae78202a6812f0c0bd933dee5b2a618874e | Ruby | calvinmcc/awesome-answers | /app/models/question.rb | UTF-8 | 1,959 | 2.828125 | 3 | [] | no_license | class Question < ApplicationRecord
# this sets up the one to many association from the question model. You
# always provide plural form of the model, in this case answers
# this will give us handy methods to easily work with the association
# You must provide a 'dependent' option to your 'has_many'
has_many ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.