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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
518b8cc8a454ccc011f64dc1435c6ceb1444a46b | Ruby | kimihito/e-share | /app/models/xvideo.rb | UTF-8 | 1,351 | 2.515625 | 3 | [] | no_license | require 'open-uri'
class Xvideo < ActiveRecord::Base
before_validation :set_title_and_thumb_url
has_many :watch_histories, dependent: :destroy
has_many :watched_users, through: :watch_histories, source: :user
has_many :favorite_videos, dependent: :destroy
has_many :favorited_users, through: :favorite_video... | true |
b92170d4a2a3665b051418b9135d8a3c63122cf1 | Ruby | katepdonahue/ruby_assessment | /katedonahue_assessment.rb | UTF-8 | 4,153 | 4.03125 | 4 | [] | no_license | # 1. Arrays
my_array = ["Blake", "Ashley", "Jeff"]
my_array.push "Kate"
puts my_array
my_array[1]
my_array.index "Jeff"
# 2. Hashes
instructor = { name: "Ashley", age: 27 }
instructor[:location] = "NYC"
instructor.each { |key, value| puts "#{key}: #{value}" }
instructor[:name]
instructor.key 27
# 3. Nested Structur... | true |
9bb87db9bb3352e889f0c4978dcb7aa0925c6ad3 | Ruby | strict-9/how-to-code | /samples/developer_home/controllers/api/baoming/baoming.rb | UTF-8 | 3,055 | 2.53125 | 3 | [] | no_license | require "sqlite3"
require "pp"
class BaomingAPI < Sinatra::Base
enable :sessions
get '/api/baoming/all' do
db_file = "db/baoming.db"
db = SQLite3::Database.new db_file
@projects=[]
db.execute( "select * from project" ) do |row|
@projects << {
... | true |
4d7888e22cfd4749ccef9492342bfb22747613b2 | Ruby | vickyjackson/wk1_d3 | /specs/homework_specs.rb | UTF-8 | 6,209 | 3.625 | 4 | [] | no_license | require('minitest/autorun')
require_relative('../homework.rb')
class FunctionsTest < MiniTest::Test
# Exercise A
# Given the following data structure:
# stops_array = [ "Croy", "Cumbernauld", "Falkirk High", "Linlithgow", "Livingston", "Haymarket" ]
# Complete these tasks:
# 1. Add "Edinburgh Waverley" to the end o... | true |
df446da60e0149e9e93bf0e7e47582424591599e | Ruby | in-formation/betsy | /test/models/user_test.rb | UTF-8 | 2,110 | 2.71875 | 3 | [] | no_license | require "test_helper"
describe User do
describe "validations" do
it "can be valid" do
is_valid = users(:valid_user).valid?
assert( is_valid )
end
it "is invalid if there is no name" do
invalid_user = users(:valid_user)
invalid_user.name = ""
is_valid = inv... | true |
e415418a8f701e7a7e96208b02dcd142f7d1ea01 | Ruby | Dagdagger/Bioinfo | /bioinfo36.rb | UTF-8 | 94 | 3.15625 | 3 | [] | no_license | file = File.open('newfile.txt')
contents = file.read()
hello = contents.chomp()
puts hello
| true |
e5b69cc7a8c6840691db1ea42dd30b482b3115d8 | Ruby | jesselsmith/reverse-each-word-online-web-ft-100719 | /reverse_each_word.rb | UTF-8 | 133 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
words = sentence.split
words = words.collect { |word|
word.reverse
}
words.join(" ")
end
| true |
9f3d45e934bd2aac6bfeb36fc1c62d54cff7f88d | Ruby | ghaxhaj/ruby-oo-relationships-practice-boating-school-exercise-nyc-clarke-web-010620 | /app/models/student.rb | UTF-8 | 748 | 3.15625 | 3 | [] | no_license | class Student
attr_accessor :first_name
@@all = []
def initialize(first_name)
@first_name = first_name
@@all << self
end
def self.all
@@all
end
def add_boating_test(test_name,instructor)
BoatingTest.new(self,test_name,instructor)
end
def self.find_... | true |
73c5942a1a70a029f735cfbdea9eada919a626de | Ruby | adammoelis/ParkShark | /app/models/spot.rb | UTF-8 | 2,962 | 2.625 | 3 | [] | no_license | class Spot < ActiveRecord::Base
belongs_to :owner, :class_name => 'User'
has_many :reviews, :dependent => :destroy
has_many :listings, :dependent => :destroy
has_many :pictures, :dependent => :destroy
has_many :purchases
has_many :reservations, :dependent => :destroy
validates_presence_of :title, :address... | true |
b200da340074f13e10936477401313b38006fbf0 | Ruby | ThoughtGang/BGO | /lib/bgo/image_changeset.rb | UTF-8 | 10,871 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
# :title: Bgo::ImageChangeset
=begin rdoc
BGO Image Changeset object
Copyright 2013 Thoughtgang <http://www.thoughtgang.org>
=end
require 'bgo/address'
require 'bgo/image_revision'
require 'bgo/patched_image'
# NOTE: document VMA as bei... | true |
fc69cdeb8994dacb7efece685ad211055b846602 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/04d1846d40694eb6bf523a2e3e8632f3.rb | UTF-8 | 258 | 3.40625 | 3 | [] | no_license | class Hamming
def self.compute(d1,d2)
n = 0
i = 0
d1 = d1.split("")
d2 = d2.split("")
while i < d1.length
n += match(d1[i],d2[i])
i += 1
end
return n
end
def self.match(a,b)
if a == b
return 0
else
return 1
end
end
end
| true |
2f73d18011c38bcb6406a7cee8e2a8be785ab5cb | Ruby | ecoologic/todomodo | /lib/ecoologic/class_extensions.rb | UTF-8 | 5,037 | 3.328125 | 3 | [] | no_license | # any class customisation here will be available in all the app
# ActiveRecord ----------------------------------------------------------------
class ActiveRecord::Base
# to access view helpers like pluralize
# eg: view_context.pluralize 1, 'cow'
def view_context
ActionController::Base.helpers
end
end
#... | true |
473e270d39611a30085a6993337135739330ed96 | Ruby | rdingwell/simplexml_parser | /lib/model/precondition.rb | UTF-8 | 3,932 | 2.5625 | 3 | [] | no_license | module SimpleXml
class Precondition
include SimpleXml::Utilities
FUNCTIONAL_OP = 'functionalOp'
LOGICAL_OP = 'logicalOp'
TEMPORAL_OP = 'relationalOp'
DATA_CRITERIA_OP = 'elementRef'
attr_reader :id, :preconditions, :reference, :conjunction_code, :negation
def initialize(entry, ... | true |
88161ec16f89fd9534094f92e82bea18ec9471fc | Ruby | niklas-ourmachinery/bitsquid-bsdoc | /Unit Tests/test_bsdoc.rb | UTF-8 | 805 | 3.1875 | 3 | [] | no_license | # Tests the bscod documentation system.
require '../init.rb'
# Unit tests for the Bitsquid documentation system.
class Test
def initialize
@doc = Bitsquid::Doc.new
@lines = IO.read("testdata.bsdoc").lines.to_a
end
def assert_equal(a, b)
if a != b
puts "Expected:"
puts(a)
puts "Result:"
puts(b)
... | true |
c0b2ff56f762c81de9abb2a078f00d3fd5342bfb | Ruby | NoSoft-SA/kromco_packhouse | /app/models/pdt_transactions/receive_intake_bin/delivery_bin_scanned_list.rb | UTF-8 | 1,487 | 2.859375 | 3 | [] | no_license | class DeliveryBinScannedList
attr_accessor :delivery_id,:mode
def initialize(delivery_id,mode)
@delivery_id = delivery_id
@mode = mode
end
def push(bin_number)
ActiveRecord::Base.transaction do
delivery_bin_scan=DeliveryBinScan.new
delivery_bin_scan.bin_number= bin_number.to_s
... | true |
69c5185d75b8351f338bddaad6b4855006d5282b | Ruby | ifpb/exercises | /src/pages/exercises/basic-hello/_codes/ruby/response/hello.rb | UTF-8 | 39 | 3.015625 | 3 | [] | no_license |
name = "Alice"
puts "Hello, #{name}!"
| true |
6666196a103d8c1c52f1a9dd72b090923bc9b2b8 | Ruby | Spencerx/data_store | /test/average_calculator_test.rb | UTF-8 | 6,390 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path '../test_helper', __FILE__
class AverageCalculatorTest < Test::Unit::TestCase
context 'AverageCalculator for a gauge type' do
setup do
DataStore::Base.db.tables.each do |table|
DataStore::Base.db.drop_table(table)
end
DataStore::Connector.new.reset!
@... | true |
f78676aa9703c189351ab934db16ee4ac42eb463 | Ruby | Rostammahabadi/credit_check | /lib/runner_file.rb | UTF-8 | 400 | 3 | 3 | [] | no_license | require './lib/credit_card'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
puts "Enter a credit card number for validation"
credit_card = gets.chomp
puts "Enter the credit cards limit"
limit = gets.chomp
new_credit_card = CreditCard.new(credit_card, limit)
puts "The last four of the card are #{new... | true |
4b379cf5d514b26364a5e4c55223073646f26832 | Ruby | ajkacca457/Ruby_Capstone_TelegramBot | /lib/bot.rb | UTF-8 | 3,915 | 3.265625 | 3 | [] | no_license | # rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/BlockLength
# rubocop:disable Metrics/MethodLength
# rubocop:disable Layout/IndentationConsistency
require 'telegram_bot'
require_relative '../lib/chucknorris.rb'
require_relative '../lib/bbcharachters.rb'
require... | true |
0b8edc99fc190bb1c9a0bc6a8be1b214232cf4b3 | Ruby | YizheWill/LeetCode | /ruby/search.rb | UTF-8 | 371 | 3.375 | 3 | [] | no_license | def search(nums, target)
idx = b_search(nums, target)
idx ? idx : -1
end
def b_search(nums, target)
return nil if nums.empty?
mid = nums.length / 2
return mid if nums[mid] == target
left = nums[0...mid]
right = nums[mid + 1..-1]
if nums[mid] < target
idx = b_search(right, target)
idx && mid + 1... | true |
21fb37f37830fa3474dd82907c6146e4bc037c7a | Ruby | OldShakespeareTHP/ruby-event-oop | /lib/event_creator.rb | UTF-8 | 889 | 3.625 | 4 | [] | no_license | #Classe permettant de creer un evenetement en interagissant avec l'utilisateur
class Event_creator
attr_accessor :event
def initialize
print " Salut, tu veux creer un evenement ? Cool !\nCommencons. Quel est le nom de l'evenement ?\n> "
@title = gets.chomp
print "Super, Quand aura-t-il lieu ? (ex : 2... | true |
12a917b45a49566b5af7a607f7c683e7af7598dc | Ruby | dry-rb/dry-core | /lib/dry/core/cache.rb | UTF-8 | 1,838 | 2.984375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require "concurrent/map"
module Dry
module Core
# Allows you to cache call results that are solely determined by arguments.
#
# @example
# require 'dry/core/cache'
#
# class Foo
# extend Dry::Core::Cache
#
# def heavy_computation(arg1, ar... | true |
4945c66d36e1e9d7cf39de874f1b72a96a2dd0df | Ruby | palewing/asterisk-challenge | /attackthemonsters/battle.rb | UTF-8 | 2,039 | 3.734375 | 4 | [] | no_license | class Battle
attr_accessor :player, :monster, :turn
def initialize
@player = spawn_player
@monster = spawn_monster
@turn = Turn.new([@player, @monster])
self
end
def perform
puts "#{@player.inspect}"
puts "#{@monster.inspect}"
puts '-------------------------------------------------... | true |
9082e6c84fe6a862dabec5893ac95050dc50af92 | Ruby | saumyamehta17/algorithm_and_system_design | /bits/pos_rightmost_diff_bit.rb | UTF-8 | 328 | 3.53125 | 4 | [] | no_license | def to_binary(num)
res = ""
while(num > 0)
res += (num % 2).to_s
num = num/2
end
res
end
def find_diff(num1, num2)
xor_val = num1 ^ num2
binary_val = to_binary(xor_val)
for x in 0...(binary_val.length)
if binary_val[x].to_i == 1
puts x+1
return
end
end
end
find_di... | true |
b086f3be40fefa6b7569c0c47da5f6f43e13491b | Ruby | aprofeit/advent-of-code-2017 | /lib/summing_spiral_cursor.rb | UTF-8 | 696 | 3.171875 | 3 | [] | no_license | require_relative 'spiral_cursor'
class SummingSpiralCursor < SpiralCursor
def update_matrix
matrix.set(position, neighbours_sum)
end
def found?
matrix.get(position) > target_value
end
private
def neighbours_sum
return 1 if iteration == 1
sum = 0
[
[position.x - 1, position.y],... | true |
0ad987453d17d36a975c362b557672cbf77d40a8 | Ruby | kjm0001/completerubyonrails | /ruby_projects/helloworldstring.rb | UTF-8 | 164 | 3.328125 | 3 | [] | no_license | ## use of variable
hello = "Hello World!"
puts hello
## reassign new value to same varaible
hello = "Welcome to the Complete Ruby on Rails Developer Course"
puts hello | true |
d20544ebbcb298aefed5d85945dee7a7e7fffeb0 | Ruby | alecbibat/tealeafexercises | /1_variables_as_pointers_2.rb | UTF-8 | 191 | 3.765625 | 4 | [] | no_license | a = 'hi there'
b = a
a = [1, 2, 3]
puts b
#the output should be [1, 2, 3] because a is defined after b
#in fact, the output is 'hi there'
#because b = a happens before a is defined? | true |
b737ccdc1e1478e6ae009c1a2c4d430e08015940 | Ruby | minhpascal/Clients | /v2/ruby/lib/vestorly/api/events_api.rb | UTF-8 | 4,656 | 2.515625 | 3 | [] | no_license | require "uri"
module Vestorly
class EventsApi
basePath = "https://staging.vestorly.com/api/v2"
# apiInvoker = APIInvoker
#
# Returns all events
# @param vestorly_auth Vestorly Auth Token
# @param [Hash] opts the optional parameters
# @return [Events]
def self.find_events(vestorly_au... | true |
e861a1f83dc2a3aea63558934fe7ed1bd6db8fdf | Ruby | manoj2411/sorting-by-dependency | /spec/jobs_list_spec.rb | UTF-8 | 1,424 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
require 'jobs_list'
RSpec.describe JobsList do
context 'invalid input file' do
["", "inputs/file1", "file1", nil].each do |file|
it "\"#{file}\" should return invalid file error" do
expect { JobsList.new(file) }.to raise_error(JobsList::INVALID_FILE_ERROR)
end
end
... | true |
4d6ef31ff985b2a0e5e2e20e379ba2db1cac1bdb | Ruby | bryanaka/interview-questions | /ruby/cash_register/cash_register.rb | UTF-8 | 1,124 | 3.703125 | 4 | [] | no_license | class CashRegister
@@cash_names = {
0.01 => 'PENNY',
0.05 => 'NICKEL',
0.10 => 'DIME',
0.25 => 'QUARTER',
0.50 => 'HALF DOLLAR',
1.00 => 'ONE',
2.00 => 'TWO',
5.00 => 'FIVE',
10.00 => 'TEN',
20.00 => 'TWENTY',
50.00 => 'FIFTY',
100.00 => 'ONE HUNDRED'
... | true |
6ec3f8f7ef55fedfa702c53704844cfe962adbc5 | Ruby | ozyborg/advent-of-code | /2020/day-21/part2.rb | UTF-8 | 928 | 3.171875 | 3 | [] | no_license | def process(data)
possible_ingredients = {}
all_ingredients = []
list = data.map { |d| d.scan(/(.*) \(contains (.*)\)/).first }
list.each do |l|
ingredients, allergens = l
ingredients = ingredients.split(' ')
allergens = allergens.split(', ')
all_ingredients += ingredients
allergens.each... | true |
16191e9f579ff794cd88da4a9dc9ab559c87b563 | Ruby | ScottDenton/square_array-prework | /square_array.rb | UTF-8 | 90 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
i = 0
array.each do |num|
array[i] = num ** 2
i+=1
end
end | true |
272e21dff596f76cf17e5f8e2aa5155d7dd2c7a1 | Ruby | GICodeWarrior/machine-head | /bin/scanner.rb | UTF-8 | 2,267 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/ruby
require 'timeout'
require 'rubygems'
require 'machine-head'
require 'gnuplot'
def avg(values)
values.inject(:+) / values.size.to_f
end
def stddev(values)
count = values.size
mean = avg(values)
Math.sqrt(values.inject(0){|sum, e| sum + (e - mean) ** 2} / count.to_f)
end
device = MachineHead:... | true |
249f82a601b567835e3cb1b1a79971e55c3dcc9f | Ruby | aliyamerali/ruby-exercises | /initialize/lib/ferret.rb | UTF-8 | 92 | 2.65625 | 3 | [] | no_license | class Ferret
attr_reader :name
def give_name(new_name)
@name = new_name
end
end
| true |
b2609388cef9a0f9f15b9d86c46930400301cc59 | Ruby | rubencp/enfoque_mental | /app/models/conversation.rb | UTF-8 | 974 | 2.90625 | 3 | [] | no_license | class Conversation
MESSAGES = [
'¿Quién eres?',
'¿Cuál es tu propósito en esta vida?',
'¿Cuál es tu vocación?',
'¿Cómo te sientes?',
'¿Qué decides plasmar como tu obra maestra?',
'¿Qué deseas?',
'¿Cuál es tu acción prioritaria?'
].freeze
def initialize(user)
@user = user
end
... | true |
88a395957598ef784c974c94fd153fe8119289b9 | Ruby | vibhorchhabra321/ecommerce-example | /scripts/generate_categories.rb | UTF-8 | 3,393 | 2.953125 | 3 | [] | no_license | require 'yaml'
# Set seed for randomness-based events
srand(1337)
# Transform the categories in nested hash structure (like a tree)
leaves = File.readlines('categories.txt').map do |line|
line.split(' >> ')[0..-2] if line.strip.end_with?('END')
end.compact
categories = {}
leaves.each do |leaf|
l1, l2, l3, l4 = l... | true |
b42af950464c0f41abaee454ca622e013f487ae4 | Ruby | kewaunited/reservation | /lib/reservation/hour_minute.rb | UTF-8 | 1,475 | 3.578125 | 4 | [
"MIT"
] | permissive | module Reservation
module Schedule
#
# a utility class to match the hour and minute elements of a Time instance, without considering any other values
#
class HourMinute
attr_accessor :hour, :minute
def initialize hour, minute
@hour, @minute = hour, minute
end
def matc... | true |
8b45596bed391b42948f2dd033ba8ce5b525ad9f | Ruby | cherimarie/mood-tracker | /test/models/event_test.rb | UTF-8 | 679 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class EventTest < ActiveSupport::TestCase
test "validations" do
no_name = Event.new(category: 'activity')
assert_not no_name.valid?, "Name is required for events"
Event.create(category: 'activity', name: 'ate cheese')
dupe_name = Event.new(category: 'activity', name: 'ate chees... | true |
ed821644187dd8cc62d830af42a61b2f6499ffa9 | Ruby | GertjanF/New-Women-Writers | /vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb | UTF-8 | 3,804 | 2.90625 | 3 | [
"MIT"
] | permissive | #
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... | true |
311fe657e00ca5b47b1703c8c33dceace449c3f4 | Ruby | cocolote/Ruby_Practice | /2nd_c/lib/02_letter_count.rb | UTF-8 | 140 | 3.4375 | 3 | [] | no_license | def letter_count(phrase)
result = {}
phrase.split.join.each_char do |letter|
result[letter] = result[letter] + 1
end
result
end
| true |
2c404132ff48401a2fad49afc0989bfe04f6cf2d | Ruby | agkramer/blocipedia | /spec/controllers/wikis_controller_spec.rb | UTF-8 | 12,594 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
include RandomData
RSpec.describe WikisController, type: :controller do
let(:user) { User.create!(email: "user@blocipedia.com", password: "helloworld", role: "standard") }
let(:my_wiki) { Wiki.create!(title: RandomData.random_sentence, body: RandomData.random_paragraph, user: user) }
#####... | true |
28224df9ed95921eb10f3c24213c6d04d61ff6be | Ruby | n3phos/guess | /lib/chat/ruby_chat/game.rb | UTF-8 | 6,890 | 2.65625 | 3 | [] | no_license |
require 'rest-client'
require 'time'
require 'users'
require 'quiz'
class Game
attr_accessor :cli, :ready, :looping_thread, :active, :started, :game_url, :resource, :quiz
attr_accessor :users, :events
attr_accessor :delayed_start, :delay_duration
attr_accessor :last_ready, :created_at, :last_play
def init... | true |
eca54fd991c6f41f667f592ea352dfb6c3c23182 | Ruby | walidwahed/ls | /exercises/101-109_small_problems/additional_practice/easy9/07.rb | UTF-8 | 593 | 4.5 | 4 | [] | no_license | # Name Swapping
# Write a method that takes a first name, a space, and a last name passed as a single String argument, and returns a string that contains the last name, a comma, a space, and the first name.
# Examples
# - input: string
# - firstname lastname
# - output: string
# - lastname, firstname
# - algo... | true |
8bbf6aa193ab2c05cd3ded96b2ea721b7d816820 | Ruby | kvakili813/my-collect-v-000 | /lib/my_collect.rb | UTF-8 | 145 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def my_collect(languages)
i = 0
lang = []
while i < languages.length
lang << yield(languages[i])
i += 1
end
lang
end
| true |
9e9ab449005e4802f7b7787683d7e0f51cb175b8 | Ruby | igorcb/transport | /app/helpers/barcode_generator_helper.rb | UTF-8 | 639 | 2.546875 | 3 | [] | no_license | module BarcodeGeneratorHelper
require 'barby'
require 'barby/barcode/code_128'
require 'barby/barcode/code_39'
require 'barby/outputter/png_outputter'
require 'barby/outputter/html_outputter'
def code128 number, variable=nil
barcode = Barby::Code128.new(number)
if (variable.nil?)
return barco... | true |
b9e47c09a0b52293b2e472573dde9520b9ce7a95 | Ruby | nathankleyn/advent-of-code-2015 | /ruby/lib/adventofcode/day_15/part_1.rb | UTF-8 | 1,358 | 3.546875 | 4 | [
"MIT"
] | permissive | module AdventOfCode
module Day15
# Solution to the exercise from Day 15 (http://adventofcode.com/day/15).
# This is part 1.
class Part1
def run(input)
# We don't want to take the calories, which is the final property,
# so we drop it here
props = parse_lines(input).transpose[... | true |
f8b1449dfda48baf8b422450c64639d9e8c0fd34 | Ruby | khampson/RubyBkt | /bkt.rb | UTF-8 | 10,511 | 2.6875 | 3 | [] | no_license | ### Bucket
#
# Main driver for the FileBucketSorter and Compresser code.
# The purpose of this driver is to approximate a best-fit given a set of files and the space constraints
# of a single-layer DVD. One or more filesets can be created and then optionally compressed in an (optionally)
# password-protected archi... | true |
0a4f726d119fe57d81fe2b21fbaa6809b9d5f1c7 | Ruby | fernandoepm1/literally-pokemon-ruby | /lib/pokeruby/storage.rb | UTF-8 | 409 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
class LPR::Storage
include HTTParty
base_uri 'https://pokeapi.co/api/v2'
class << self
def pokemons(offset = '0', limit = '151')
get("/pokemon?offset=#{offset}&limit=#{limit}")['results']
end
def pokemon_names
pokemons.collect { |poke| poke['name'] }
end
def... | true |
28148e618c5eb52d3f04560e5065bfd2897aeb81 | Ruby | Lodi2244/Mini_piscine_ruby_42 | /discovery_piscine/rb06/ex01/upcase_it.rb | UTF-8 | 82 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env ruby
def upcase_it(str)
puts str.upcase
end
upcase_it("hello")
| true |
01872bf5b5a6ae24300f631aaed5894070abd599 | Ruby | alexandremcosta/pucker | /lib/pucker/dealer.rb | UTF-8 | 396 | 2.859375 | 3 | [] | no_license | # Author: Alexandre Marangoni Costa
# Email: alexandremcost at gmail dot com
#
# Responsible for dealing and shuffling a deck of cards
require 'java'
java_import 'table.Deck'
module Pucker
class Dealer
def initialize
deck.shuffle
end
def deal
deck.deal
end
def reset
deck.res... | true |
4cc1d3c8b194eb540483cc4d5b408ea4a7c81d21 | Ruby | Masamune42/ruby_grafikart | /1-variables.rb | UTF-8 | 263 | 3.75 | 4 | [] | no_license | # chomp -> retire le saut de ligne
# nom = gets.chomp
# puts "Salut #{nom} comment allez vous?"
# Faire le to_i après car chomp converti en string
# true si un chiffre est pair, sinon false.
puts "Entrez un chiffre"
chiffre = gets.chomp.to_i
puts chiffre.even? | true |
ab2e870478799d6959cd0256e120ff05ed8aa8aa | Ruby | randz-argonillo/theodinproject | /flight-booker/db/seeds.rb | UTF-8 | 536 | 2.703125 | 3 | [] | no_license | Airport.delete_all
Flight.delete_all
airport_list = ["London Rain", "Chicago Wind",
"Barcelona Sun", "Guadalajara steal", "Alaska Cold"]
airport_list.each { |a| Airport.create(name: a) }
100.times do
departure = rand(5) + 6
arrival = rand(5) + 6
arrival = arrival % 5 + 6 if departure == arrival... | true |
fb8f1f377dc17c4725039e54a0fc37a3169f6284 | Ruby | dittmar/Tetris-AI | /tetris/src/lib/tetromino.rb | UTF-8 | 5,549 | 3.765625 | 4 | [] | no_license | # Kevin Dittmar
# 1 December 2015
# Artificial Intelligence Project: Tetris
# Used by Tetrominoes to save an "undo" copy of themselves.
require('deep_clone')
# Tetromino is the class that represents
# a generic tetromino, which is a shape made up
# of four squares called blocks. Each tetromino
# can be moved left, ... | true |
fb4f9fbf259a3de0f75438c8aa58acb8f75738e9 | Ruby | LindseyJ22/Blog-a-geddon | /app/controllers/users_controller.rb | UTF-8 | 1,576 | 2.5625 | 3 | [] | no_license | class UsersController < ApplicationController
# before_action :authenticate, only: [:edit, :update, :destroty]
#shows all users
# GET localhost:3000/users
def index
@users = User.all
end
# shows the form to make a new user
# GET localhost:3000/users/new
def new
@user = User.new
end
# handles f... | true |
abbf93967f7e13a97feea98b6700b22beb1c0bcc | Ruby | rudi-kit/WarOfHeroes | /src/main/resources/creatures/map_rus_to_eng.rb | UTF-8 | 374 | 2.578125 | 3 | [] | no_license |
def map_to_eng json
attr_map = {'атака'=>'attack',
'скорость'=>'speed',
'защита'=>'defence',
'инициатива'=>'initiative',
'урон'=>'damage',
'выстрелы'=>'shoots',
'здоровье'=>'health',
'мана'=>'mana',
'прирост'=>'increase'}
attr_map.each do |key, value|
json[value] = json[key.to_s]
end
json
end | true |
932991c014fd0a947a4242edc58ab28c3202eacb | Ruby | zsawala/code-wars | /multi.rb | UTF-8 | 162 | 3.34375 | 3 | [] | no_license | def solution(number)
sum=0
(1..number-1).to_a.each{|num| (num%3==0) ? sum=sum+num : (num%5==0 ? sum=sum+num : sum=sum)}
return sum
end
puts "#{solution(10)}"
| true |
9e4bb16ba23ffc302b9f889c2e94829c86b85f27 | Ruby | everypolitician/everypolitician-data | /bin/count_statements.rb | UTF-8 | 809 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
require 'json'
require 'pry'
require 'colorize'
total = 0
date = ARGV.pop if ARGV.last =~ /\d{4}-\d{2}-\d{2}/
ARGV.each do |file|
statements = 0
@json = JSON.load(File.read(file), lambda do |h|
statements += h.values.select { |v| v.class == String }.count if h.class == Hash
en... | true |
5145ae38e3ccfdf53d556af87e7f65be472c3b1c | Ruby | ShaunMackie/RB101 | /Lesson_6/21_Game/21_game.rb | UTF-8 | 5,624 | 3.671875 | 4 | [] | no_license | require 'yaml'
MESSAGES = YAML.load_file('21_Game.yml')
SUITS = %w(h d s c).freeze
VALUES = %w(2 3 4 5 6 7 8 9 10 J Q K A).freeze
DEALER_TARGET = 17
GAME_LIMIT = 21
def prompt(msg)
puts "=> #{msg}"
end
def messages(message)
prompt(MESSAGES[message])
end
def clear
system('clear')
end
def line_break
puts "\... | true |
4261e992fa00b647025409a54d897e1c2d140cf4 | Ruby | baintonw/prime-ruby-nyc-web-051319 | /prime.rb | UTF-8 | 129 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
if num <= 1
false
else
(2..num-1).to_a.all? do |divider|
num % divider != 0
end
end
end
| true |
16b8a540fcc2c25c959375e7362ac8a0bed4435b | Ruby | jodag/ScheRuby | /lib/scheruby/ScheRubyGrammarLexer.rb | UTF-8 | 22,841 | 2.765625 | 3 | [] | no_license | # ScheRubyGrammarLexer (ScheRubyGrammar.g)
# Generated by ANTLR 3.0.1 on 2008-01-13 22:11:14
class ScheRubyGrammarLexer
require 'stringio'
EOF=-1
WS=13
NUMBER=4
STRING=9
NIL=8
FALSE=7
SYMBOL=5
RPAREN=11
Tokens=15
LPAREN=10
COMMENT=14
SINGLE_QUOTE=12
TRUE=6
def initialize(input)
input = ... | true |
8ab31ebd9db0ea02aebf3c0be9baff8e52d702da | Ruby | ccankov/aa-w2d4-projects | /two_sum/two_sum.rb | UTF-8 | 2,759 | 3.8125 | 4 | [] | no_license | require 'io/console'
require 'benchmark'
def performance_test(size, count)
arrays_to_test = Array.new(count) { random_arr(size) }
Benchmark.benchmark(Benchmark::CAPTION, 9, Benchmark::FORMAT,
"Avg. Bad: ", "Avg. Okay: ", "Avg. Best") do |b|
bad_sum = b.report("Tot. Bad: ") { run_bad_su... | true |
b44d28cec2aedf0383e72fbae22a34fed2627039 | Ruby | hernanilr/learn | /closures.rb | UTF-8 | 167 | 3 | 3 | [] | no_license | # frozen_string_literal: true
def run_proc(pro)
pro.call
end
name = 'eu'
print_name = proc { puts name }
run_proc(print_name)
name = 'fruga'
run_proc(print_name)
| true |
c3f1790b35cfc9efba3a6bc97f532a718186bbbb | Ruby | furuya-tomoki/stdin_sample | /class1.rb | UTF-8 | 352 | 3.703125 | 4 | [] | no_license | # RPGの攻撃シーン
class Player
def initialize(name)
@name = name
end
def attack(enemy)
puts "#{@name}は#{enemy}を攻撃した"
end
end
team = []
team.push(Player.new("勇者"))
team.push(Player.new("戦士"))
team.push(Player.new("魔法使い"))
team.each do |person|
person.attack("スライム")
end
| true |
72dbcfc0c057120e8b46085bbd1cd1f0391af2aa | Ruby | jdconrad89/bottles | /lib/bottles.rb | UTF-8 | 832 | 4.4375 | 4 | [] | no_license | require 'pry'
class Bottles
attr_reader :number_of_bottles
def initialize(bottles)
@number_of_bottles = bottles
end
def sing_the_song(bottles)
until @number_of_bottles == 1
puts line
count
end
puts last_line_of_the_song
end
def line
"#{@number_of_bottles} bottles of beer... | true |
b905acc41c56dea96b61f50d5586c9336c34d37b | Ruby | dc3671/lkp-tests | /lib/statistics.rb | UTF-8 | 770 | 3.4375 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# https://www.bcg.wisc.edu/webteam/support/ruby/standard_deviation
# Add methods to Enumerable, which makes them available to Array
module Enumerable
def sum
begin
return self.inject(0) { |acc, i| acc + i }
rescue TypeError
$stderr.puts self
raise
end
end
def average
return ... | true |
4e21062743ac3ce7d26cb48e0e99f45c6cd997a9 | Ruby | viniciusjssouza/minesweeper | /lib/app.rb | UTF-8 | 1,217 | 3.171875 | 3 | [] | no_license | require_relative '../modules'
MODULES.each do |mod|
moduleFolder = File.expand_path("../../#{mod}/lib", __FILE__)
$LOAD_PATH.unshift(moduleFolder) unless $LOAD_PATH.include?(moduleFolder)
end
libFolder = File.expand_path("../../lib", __FILE__)
$LOAD_PATH.unshift(libFolder) unless $LOAD_PATH.include?(libFolder)
... | true |
0b480f710aed2fcface03bf583999fea792d0f14 | Ruby | shokai/gyaaazz-checker | /lib/gyaaazz.rb | UTF-8 | 1,391 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'rubygems'
require 'json'
require 'open-uri'
require 'kconv'
require 'uri'
require 'diff/lcs'
class Gyaaazz
def initialize(url)
url = url.scan(/(.+)\//).first.first if url =~ /\/$/
@url = url
end
def search(word=nil)
word = '.*' unless word
JSON.parse open(URI.... | true |
f17902898fb7698ca7ca82a8e0f770a164bd094e | Ruby | SiCuellar/Code_Wars | /Ruby/counting_chars_string/algo.rb | UTF-8 | 309 | 3.546875 | 4 | [] | no_license | require 'pry'
class Algo
def count_chars(s)
dict = Hash.new(0)
s.chars.each do |char|
if dict[char]
dict[char] += 1
end
end
dict
end
end
# Fancy short way of solving it
# def count_chars(s)
# s.chars.uniq.each_with_object({}) { |c, h| h[c] = s.count(c) }
# end
| true |
0b13e6d69b6d84e87c59d1a0d7b034104b75d8ba | Ruby | movilla1/elcan_weight | /lib/reports/driver_performance.rb | UTF-8 | 590 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
module Reports
# This class gets the performance data
class DriverPerformance
def initialize(start_date, end_date)
@start_date = start_date
@end_date = end_date
end
def report
[@start_date, @end_date, sum_rows]
end
private
def sum_rows
... | true |
db160dc9818f07105c10a6394d89e771f7101b07 | Ruby | cschell/adventofcode | /2019/03/puzzle_01.rb | UTF-8 | 1,196 | 3.328125 | 3 | [] | no_license | inputs = File.readlines("input.txt")
wire_1, wire_2 = inputs.map{ |wire| wire.split(",").map {|inst| [inst[0], inst[1..-1].to_i]} }
wired_coords = Hash.new([0, -1])
[wire_1, wire_2].each_with_index do |instructions, wire_idx|
current_coords = {x: 0, y: 0}
instructions.each do |direction, steps|
case directi... | true |
ae0a229ade06ba4dc66cbdda1df77b59ef71cc2c | Ruby | Bhavikpatel576/Launchschool | /IntroProg/hashes.rb | UTF-8 | 929 | 3.515625 | 4 | [] | no_license | #problem 1
# immediate_family = family.select {|family_member| family_member == :brothers || family_member == :sisters}
# #problem 2: Whats the difference between merge & merge!
# hash1 = {:height=>'6 ft', :weight=>'160 lbs', :hair=>'brown', :name=>'bob'}
# hash2 = {:sex=>"male", :race=>"Asian"}
# hash1.merge(hash2)
... | true |
550a2e74ac5c06f43a16e642dfa5a62946100386 | Ruby | skvisshal/W2D4 | /visshal_suresh_recap_exercise_3/problems.rb | UTF-8 | 2,736 | 3.6875 | 4 | [] | no_license | def no_dupes?(arr)
arr.select do |ele|
arr.count {|ele2| ele2 == ele} < 2
end
end
def no_consecutive_repeats?(arr)
arr.each.with_index do |ele, i|
return false if ele == arr[i + 1]
end
true
end
def char_indices(str)
result = {}
str.each_char.with_index do |char, i|
... | true |
212eb23e1a588aaa35c36a6ffd4a2fa28a98bb24 | Ruby | anette87/sql-library-lab-onl01-seng-ft-050420 | /lib/querying.rb | UTF-8 | 1,296 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"SELECT books.title, books.year
FROM books
INNER JOIN series
ON series_id = series.id
WHERE series.id = 1;"
end
def select_name_and_motto_of_char_with_longest_motto
"SELECT characters.name, characters.motto
FROM characters
ORDER BY ... | true |
7e9b04ae7fbfa269f8623043cd6477578857a7f8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/roman-numerals/b009eff0987d4caa9b99afd07f86eb02.rb | UTF-8 | 641 | 3.28125 | 3 | [] | no_license | # Monkey patching a core class shouldn't be necessary for this
class Fixnum
ROMAN_LITERALS = {
1000 => 'M',
900 => 'CM',
500 => 'D',
400 => 'CD',
100 => 'C',
90 => 'XC',
50 => 'L',
40 => 'XL',
10 => 'X',
9 => 'IX',
5 => 'V',
4 => 'IV',
1 => ... | true |
804e9327ebfd00cd17c1c0fb2cd8e26bc153333f | Ruby | ZEmilka/interpolation-super-power-online-web-sp-000 | /lib/display_rainbow.rb | UTF-8 | 755 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | colors=["red","orange","yellow","green","blue","indigo","violet"]
letter=["R","O","Y","G","B","I","V"]
#puts"R:#{display_rainbow[0]},O:#{display_rainbow[1]},Y:#{display_rainbow[2]},G:#{display_rainbow[3]},B:#{display_rainbow[4]},I:#{display_rainbow[5]},V:#{display_rainbow[6]}"
#puts"#{letter[0]}:#{display_rainbow[0]... | true |
bcee4e3c2ab128307119986b084870964eab555c | Ruby | oj5th/inventory_backend | /app/models/author.rb | UTF-8 | 557 | 2.890625 | 3 | [] | no_license | class Author < ApplicationRecord
belongs_to :book
validates :firstname, :middlename, :lastname, presence: true
def self.names
count > 2 ? etal_names : all_names
end
def self.etal_names
pluck(:firstname, :middlename, :lastname).first(2).map { |firstname, middlename, lastname| "#{firstname} #{midd... | true |
4c76e4ed47c1bace3e89f48f1d21b194f8df7b78 | Ruby | rtaycher/dotfiles | /.irbrc | UTF-8 | 679 | 2.65625 | 3 | [] | no_license | # Stolen from http://www.viget.com/extend/practical-sorcery-with-irb/
require 'rubygems'
p 1
require 'pp'
p 2
require 'wirble'
Wirble.init
Wirble.colorize
IRB.conf[:AUTO_INDENT] = true
p 3
class Object
def my_methods
(methods - Object.instance_methods).sort
end
end
def ls
%x{ls}.split("\n")
end
p 4
def cd... | true |
bbd989f9bdf825b818a13c7a782ca0b3d7afb19d | Ruby | vbrazo/algorithms-archives | /math/convert_to_base7.rb | UTF-8 | 367 | 4.34375 | 4 | [] | no_license | # Given an integer num, return a string of its base 7 representation.
#
# Example 1:
#
# Input: num = 100
# Output: "202"
#
# Example 2:
#
# Input: num = -7
# Output: "-10"
# @param {Integer} num
# @return {String}
def convert_to_base7(num)
num.to_s(7)
end
num = 100
puts convert_to_base7(num)
# Output: "202"
num =... | true |
00b4aa3bc8613977623316e1452c2c7e26c423ff | Ruby | beartums/dj-all | /lib/dj-all-cli.rb | UTF-8 | 5,168 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
require 'dj-all/controller'
require 'settings/dj-all'
require 'dj-all/version'
require 'optparse'
require 'ostruct'
def valid_application?(application)
!application.nil? && !application.empty?
end
def valid_environments?(environments)... | true |
66532e435cb0bee34dfb02fb8897588fdb8bee87 | Ruby | vofi/ese2012-web-ui | /trade/app/app.rb | UTF-8 | 1,274 | 2.546875 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
require 'haml'
require 'tilt/haml'
require 'app/models/store/user'
require 'app/models/store/market'
require 'app/models/store/item'
require 'app/controllers/authentication'
require 'app/controllers/main'
class App < Sinatra::Base
use Authentication
use Main
enable :sessi... | true |
5930c40bba33c43c6b715be1cbb9079f88a6ef50 | Ruby | evcodes/ruby_practice | /programs/deaf_grandma.rb | UTF-8 | 528 | 3.9375 | 4 | [] | no_license |
puts "What is your name?"
name = gets.chomp.capitalize
puts "Grandma: Hey, #{name}, how are you?"
counter = 0
input = gets.chomp
while (counter < 3)
if input == input.upcase && input != ""
if input == "BYE"
counter +=1
else
counter = 0
end
year = rand(21) + ... | true |
b270a79575d4d75bded62867652beb0708e575d5 | Ruby | AndrewDPalmer/LearningExercises | /InterviewQuestions/HighSpot_PlaylistEditor/services/mixtape_service.rb | UTF-8 | 2,682 | 3.15625 | 3 | [] | no_license | require "json"
require_relative "../managers/playlist_manager"
require_relative "../managers/song_manager"
require_relative "../managers/user_manager"
class MixtapeService
def initialize(source_file)
input_data = File.read(source_file)
json_data = JSON.parse(input_data)
@users = UserManager.new(json_d... | true |
653138a1aba6adc050c9f255d44be7f93788eb0a | Ruby | tall-dan/level_up_exercises | /dino_catalog/parser.rb | UTF-8 | 805 | 3.21875 | 3 | [] | no_license | require 'csv'
class Parser
def initialize
CSV::Converters[:blank_to_nil] = -> (field) {field && field.empty? ? nil : field}
CSV::HeaderConverters[:pick_header_title] = method(:pick_header_title)
end
def pick_header_title(header)
case header
when "genus" then "name"
when "weight_in_lbs"... | true |
1d3819e4380dce1d5a103ee2121928d2ad18462b | Ruby | ganmacs/ganmacs-sezemi-2015-readable-code | /lib/recipe_tool/csv_printer.rb | UTF-8 | 476 | 2.625 | 3 | [] | no_license | require 'recipe_tool/manager'
require 'csv'
module RecipeTool
class CSVPrinter
def call
manager.all_recipes_with_user.each do |recipe_with_user|
user = recipe_with_user[:user]
recipes = recipe_with_user[:recipes]
recipes.each do |recipe|
puts [user.id, user.name, recipe.i... | true |
4da4bdba56df1c05b4e84908b5ef73f0e45e795e | Ruby | nazwhale/boris-bikes | /lib/docking_station.rb | UTF-8 | 1,171 | 3.21875 | 3 | [] | no_license | require_relative 'bike'
require_relative 'van'
class DockingStation
attr_reader :capacity, :bikes
DEFAULT_CAPACITY = 20
def initialize(capacity = DEFAULT_CAPACITY)
@bikes = []
@capacity = capacity
end
def release_bike
#I'd like docking stations not to release broken bikes.
fail "No bikes availa... | true |
2d8bce2c142a32f8f2a9becbb67a4e7991f13e8e | Ruby | latin-language-toolkit/gregex | /lib/gregex/options.rb | UTF-8 | 437 | 2.8125 | 3 | [
"MIT"
] | permissive | class Gregex
class Options
def initialize(orig, opts)
@original = orig
@options = opts
options
end
def options
parse_options
if @options.empty? then 0 else @options end
end
def parse_options
int = @original
if int.odd? && !check_options("i")
@op... | true |
1468457c3fa9e3a60316d12bd3f908bed35ac7c8 | Ruby | kleopatra999/gcloud-ruby | /lib/gcloud/pubsub.rb | UTF-8 | 14,711 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2015 Google Inc. All rights reserved.
#
# 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 a... | true |
113191259baee60208e17e6738858cd7bdf8f03c | Ruby | NawarYossef/launch_school | /class_95/variables/exercise 4.rb | UTF-8 | 195 | 3.5625 | 4 | [] | no_license | #name.rb
puts "hello! What is your first name?"
first_name = gets.chomp
puts "And what is your last name?"
last_name = gets.chomp
puts "Nice to meet you " + first_name +" "+ last_name | true |
9cbb44058ae0cb9cbd2d111c50fb49c686e3ea7f | Ruby | sigma-ifsp/Sigma | /app/models/point_calculator.rb | UTF-8 | 694 | 3.609375 | 4 | [] | no_license | # Calculate points
# by given value end promotion
class PointCalculator
# Represents the monetary value of points
attr_reader :value
# The promotions associated with the point
attr_reader :promotion
# Receives:
# value: +Integer+
# promotion: +Promotion+
def initialize(value, promotion)
@value = v... | true |
64a48df46cd641809e4f16588bf7b996091008ae | Ruby | asilano/raspberry-calendar | /lib/webdriver.rb | UTF-8 | 1,701 | 2.671875 | 3 | [] | no_license | require 'watir-webdriver'
require 'rufus/scheduler'
class Webdriver
def initialize(config, cookie_file)
@base_url = config['base_url']
@refresh_interval = config['refresh_interval'] || '1m'
@reset_interval = config['reset_to_base_timeout'] || '10m'
@cookie_file = cookie_file
@current_url = @base_... | true |
d17e02810590f67a7f41278e263c5db7c6228b58 | Ruby | driftingruby/317-error-tracking-from-scratch | /tracker_example/lib/middlewares/capture_exceptions.rb | UTF-8 | 908 | 2.609375 | 3 | [] | no_license | require 'net/http'
class CaptureExceptions
def initialize(app)
@app = app
end
def call(env)
begin
@app.call(env)
rescue StandardError => e
@exception = e
capture_exceptions(env)
raise e
end
end
private
def capture_exceptions(env)
uri = URI('http://localhost:300... | true |
0710831f5c222fe2ba5a615eab8f7362ace30d0d | Ruby | suneetsasidharan/backchannelapp | /test/unit/user_test.rb | UTF-8 | 1,252 | 2.671875 | 3 | [] | no_license | require 'test_helper'
require 'test/unit'
require_relative '../../app/models/user'
class UserTest < Test::Unit::TestCase
#fixtures :users
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
# Do nothing
end
# Called after every test method runs. Can be used to... | true |
0a803424370258da24803ab4a8d07ca45bafbcf7 | Ruby | spike-imperial/FastLAS | /FastLAS1/data/CAVIAR/run_testing.rb | UTF-8 | 1,698 | 2.75 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'json'
require 'byebug'
require_relative 'enumerable.rb'
data = JSON.parse(File.read("results_" + ARGV[0] + ".json").split("\n").join(""))
ttp = 0
ttn = 0
tfp = 0
tfn = 0
recalls = []
precisions = []
f_1s = []
data["results"].each do |id, run_stats|
tp = 0
tn = 0
fp = 0
fn = 0
... | true |
73c80d842da1a9d0048503e18941a53d893b46c9 | Ruby | chrisjbenedict/blood-oath-relations | /app/models/cult.rb | UTF-8 | 2,012 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Cult
attr_reader :name, :founding_year, :minimum_age
attr_accessor :location, :slogan
@@all = []
def self.all
@@all
end
def initialize(name, location, founding_year, slogan, minimum_age = 18)
@name = name
@location = location
@founding_year = founding_year
@slogan... | true |
4cf2b5b822eb074d7b5ad98a58948e369d5d0c81 | Ruby | timurmaio/studykit-backend | /app/models/ability.rb | UTF-8 | 1,677 | 2.609375 | 3 | [
"MIT"
] | permissive | class Ability
include CanCan::Ability
def initialize(user)
# guest users - they are students by default
user ||= User.new
if user.admin?
can :manage, :all
elsif user.teacher?
can(:manage, Course) { |course| course.owner == user }
can(:manage, Lecture) { |lecture| lecture.course.o... | true |
1133e66c209789feb4894e259c7d07416b268042 | Ruby | davdkm/crud-with-validations-lab-v-000 | /app/models/song.rb | UTF-8 | 696 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
validates :title, presence: true, unless: :released_same_year?
validates :released, inclusion: { in: [true, false] }
validate :valid_released_year
def valid_released_year
if self.released && !self.release_year
errors.add(:released_year, 'Must have a valid release year ... | true |
be43fdd694480e5aa02d42d065d0fbdce1f07c29 | Ruby | thoran/trs | /lib/command_parser.rb | UTF-8 | 2,222 | 3.421875 | 3 | [] | no_license | # lib/command_parser.rb
class UnplacedToyRobotError < StandardError; end
class CommandParser
attr_accessor :command_list
attr_accessor :toy_robot
def initialize(program: nil, toy_robot: nil)
@command_list = load(program) if program
@toy_robot = toy_robot
end
def load(program)
@command_list = ... | true |
d73105d0eebf138c720223d55ae972b880f5e3bd | Ruby | MattManson/karaoke-homework | /specs/song_spec.rb | UTF-8 | 488 | 2.5625 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative("../room.rb")
require_relative("../guest.rb")
require_relative("../song.rb")
require_relative("../bar_tab.rb")
class TestSong < MiniTest::Test
def setup
@song1 = Song.new("My War", "Black Flag")
@song2 = Song.new("Straight Edge", "Minor Thr... | true |
88aeaefb19c2510c69049e304a9fe45028a2ef63 | Ruby | zamith/colossus_gui | /app/models/ticket_group.rb | UTF-8 | 297 | 2.734375 | 3 | [] | no_license | class TicketGroup
def initialize(ticket_group_attrs)
@ticket_group_attrs = ticket_group_attrs
end
def total
ticket_group_attrs["total_items"]
end
def items
ticket_group_attrs["items"].map{|ticket| Ticket.new(ticket)}
end
private
attr_reader :ticket_group_attrs
end
| true |
1bc69be30cf31c81c8eacf81ed96e260e9d2765a | Ruby | AkiraBrand/bailey_test | /githubplayground2.rb | UTF-8 | 129 | 2.75 | 3 | [] | no_license | puts "I am printing something to the screen"
puts "This is another printed message because this is all I can do"
puts "Whatever"
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.