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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
50054acfa0e97016212ea7e10f497b4db55ca3ff | Ruby | kenkuts/sublime_notes | /database_notes.rb | UTF-8 | 796 | 2.65625 | 3 | [] | no_license | NoSQL - Not Only SQL
Key-value pairs
Column Family
graph
Document
SQL
Relational(tables)
Analytical(OLAP) - 3D arrays
-Structured - organized easy to join
-Error checkin - enforces relationships
-Fast Joins:
-Cross Indexes
-Query Optimizer
-Support lots of documentation
-Stability features arent changing as much
-... | true |
9775ba9323030fe1a0f6d560003b970df2f95e62 | Ruby | bsouza/YReader | /tests/test_reader.rb | UTF-8 | 661 | 2.546875 | 3 | [] | no_license | require 'test/unit'
require_relative '../yreader'
class YReaderTest < Test::Unit::TestCase
def test_yreader_without_parameters
assert_raise RuntimeError do
get_reader.get
end
end
def test_yreader_with_one_parameter
assert_equal({"name" => "testing"}, get_reader.test.get)
end
def test_yreader_with_two_... | true |
da99d6128d9413ad87203908f5af3633d2149382 | Ruby | vagmi/heathen | /executioner.rb | UTF-8 | 2,556 | 3.03125 | 3 | [
"MIT"
] | permissive | module Heathen
class Executioner
attr_reader :logger, :last_exit_status
def initialize(log)
@logger = log
end
# Executes the given argument vector with fork/exec.
# Returns the command standard output as a String.
#
# ----------------------------------------------------------
... | true |
228e6a2bd78aaecbdea0893cf25808ac788f92b7 | Ruby | degica/voynich | /lib/voynich/encrypter.rb | UTF-8 | 1,601 | 2.75 | 3 | [
"MIT"
] | permissive | module Voynich
class Encrypter
class V1
attr_accessor :encrypter
def initialize(encrypter)
@encrypter = encrypter
end
def encrypt(plaintext)
enc = AES.new(secret[0..31], encrypter.auth_data, serializer: encrypter.serializer).
encrypt(plaintext)
{
... | true |
5abced349c5247b0f41b6398a8da06ffb10aa4bc | Ruby | Lisztomaniaa/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 368 | 3.765625 | 4 | [] | no_license | def echo(something)
something
end
def shout(something)
something.upcase
end
def repeat(something, r=2)
([something] * r).join ' '
end
def start_of_word(something,n)
something[0..(n-1)]
end
def first_word(something)
something.split(" ")[0]
end
def titleize(something)
something.split.map(&:capitalize).joi... | true |
f4b825b0a805cf406216c0fd947fbeb0a8103113 | Ruby | jamarin6/IronEvents | /app/models/event.rb | UTF-8 | 969 | 2.671875 | 3 | [] | no_license | class Event < ActiveRecord::Base
belongs_to :user
validates :name, presence: true, length: { maximum: 60 }
# validates_presence_of :name
# validates_length_of :name, maximum: 60
validates :description, length: {minimum: 100}, allow_blank: true
validate :start_at_is_present #aqui al ser validacion nuestra propia ... | true |
c7691c916312d0b56dad3e60436ffd6245f4384f | Ruby | Inglorion-G/AppAcademy | /Week1/W1D4/word_chainz.rb | UTF-8 | 1,796 | 3.390625 | 3 | [] | no_license | require 'set'
def adjacent_words(word, dictionary)
words_array = []
dictionary.each do |dict_word|
word.split('').each_with_index do |char, idx|
next if dict_word == word
if idx == 0
if word[1...word.length] == dict_word[1...dict_word.length]
words_array << dict_word
end
... | true |
c42cebccfe8f116c6eb6579ed65bbbcab4b67471 | Ruby | abimaelmartell/ruby-test-exercises | /ex_1/test.rb | UTF-8 | 472 | 2.59375 | 3 | [] | no_license | require "test/unit"
require_relative "./version_1"
require_relative "./version_2"
class CountTest < Test::Unit::TestCase
def test_count_numbers_v1
assert_equal(count_numbers_v1(1, 9), 8)
assert_equal(count_numbers_v1(4, 17), 12)
assert_equal(count_numbers_v1(0, 100), 82)
end
def test_count_numbers_... | true |
411e7b58d8752b01d28e9fb137728983dd049b3a | Ruby | farnswj1/ProjectSCHEMA | /src/app/models/user.rb | UTF-8 | 2,584 | 2.71875 | 3 | [] | no_license | # Project name: Project SCHEMA
# Description: This project aims to simplify the enrollment and management processes by
# reducing the clutter and only showing the essentials of a successful
# enrollment program.
# Filename: user.rb
# Description: Model class for the users
# Last modified on: 1... | true |
0ab4cda2cbf46f94aba25cb325c98395f1b40e31 | Ruby | eam/cfg | /cfg.rb | UTF-8 | 2,567 | 2.90625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'bundler/setup'
require 'sinatra/base'
require 'mysql2'
require 'sequel'
class CFG < Sinatra::Base
use Rack::Logger
configure do
# way too lazy to make 50000 erb files
enable :inline_templates
# turn on logging. FIXME: why does DEBUG not take?
set :logging, Logger::DEBUG
... | true |
7d1ac183f7517df2175654311cc614b5c69fa6dc | Ruby | rdsoze/ignitte | /app/models/user.rb | UTF-8 | 537 | 2.734375 | 3 | [] | no_license | class User < ActiveRecord::Base
has_many :tweets, :dependent => :destroy
attr_accessible :id
class << self
def populate(count)
@tweets = Tweet.get_tweets count
@tweets.each do |tweet|
user = User.get_user tweet
Tweet.add_tweet(user,tweet)
end
end
def get_user twee... | true |
fa7294c0f562fd9cba700a845fadb083048b0086 | Ruby | bakkdoor/stickup | /lib/primitives/functions.rb | UTF-8 | 1,116 | 3.234375 | 3 | [] | no_license | module Primitives
module Functions
def init_primitive_functions
define('ruby-require') { |name| require(name) }
define('+') { |arg1, arg2| arg1 + arg2 }
define('-') { |arg1, arg2| arg1 - arg2 }
define('*') { |arg1, arg2| arg1 * arg2 }
define('/') { |arg1, arg2| arg1 / arg2 }
d... | true |
88f6543f0cda91e37222a168d182fc942c283c76 | Ruby | Shy07/leetcode_by_ruby | /valid_number.rb | UTF-8 | 1,288 | 3.5625 | 4 | [] | no_license | # simple
def is_number(s)
/^(\+|-)?(\d+(\.\d+)?|\d+\.|\.\d+)(e(\+|-)?\d+)?$/ =~ s.strip ? true : false
end
# complex
def is_number(s)
s = s.strip.chars.inject([]) do |mem, var|
var = var.ord
var.between?(48, 57) || [43,45,46,101].include?(var) ? (mem << var) : (return false)
mem
end
return false if... | true |
c1667abc95f564fd5a6b8e383d069185c4fbd467 | Ruby | sakovski/Studies-PL- | /[SEM5] Krypografia/Xor/xor.rb | UTF-8 | 5,714 | 3.171875 | 3 | [] | no_license | #Kryptografia
#Zadanie 2: Błędne powtórzenie klucza jednorazowego
#Seweryn Rutkowski, 240865
#Wywołanie programu : ruby xor.rb arg1
#gdzie:
#arg1 = {-p = przygotowanie tekstu do przykładu działania, -e = szyfrowanie, -k = kryptoanaliza wyłącznie w oparciu o kryptogram}
class Xor
@@ascii_placeholder = 32
@@ascii_... | true |
482f3dcbf28e5fce7c35f117f75b2a57b776f2ab | Ruby | tblazz/freshstart-kapp10 | /app/services/url_shorteners/create_url_shortener_service.rb | UTF-8 | 504 | 2.515625 | 3 | [] | no_license | module UrlShorteners
class CreateUrlShortenerService
def initialize(destination)
@destination = destination
@rebrandly_api = Rebrandly::Api.new
end
def call
return unless !@destination.empty? && domain
rebrandly_link = @rebrandly_api.shorten(@destination, domain: domain.to_h)
... | true |
e09985dd47430763c716de726e79d405d9eb7bd0 | Ruby | ModestasSinkevicius1/Ruby_projects | /ruby_uzduotis_version_1.1/salyga_nr1.rb | UTF-8 | 911 | 3.5625 | 4 | [] | no_license | def trikampis_egzistuoja(a, b, c)
if type_a_float(a, b, c)
return false unless a + b > c && b + c > a && c + a > b
true
else
false
end
end
def type_a_float(a, b, c)
(a.is_a? Float) && (b.is_a? Float) && (c.is_a? Float)
end
def trikampio_tipas(a, b, c)
if a == b && a == c
'Tai lygiakrastis tr... | true |
c58535d642e9d43d5c68231bb9df57aeb5b9fe40 | Ruby | joel1di1/shell_test | /test/shell_test/string_methods_test.rb | UTF-8 | 3,870 | 2.671875 | 3 | [
"MIT"
] | permissive | require File.expand_path('../../test_helper', __FILE__)
require 'shell_test/string_methods'
class StringMethodsTest < Test::Unit::TestCase
include ShellTest::StringMethods
#
# assert_str_equal test
#
def test_assert_str_equal
assert_str_equal %{
line one
line two
}, "line one\n line two\... | true |
5204536212df643bad92787e8004d67894779598 | Ruby | digitalnatives/fron | /spec/dom/modules/classlist_spec.rb | UTF-8 | 1,734 | 2.59375 | 3 | [] | no_license | require 'spec_helper'
describe DOM::ClassList do
let(:element) { DOM::Element.new 'div' }
describe '#add_class' do
it 'should add a class' do
element.add_class 'test'
element['class'].should eq 'test'
end
it 'should add multiple classes' do
element.add_class 'test', 'help'
ele... | true |
19a2d522660ed6dc6a7ef68aeb6cf67d6c52b62b | Ruby | willbarrett/rubydatastructures | /spec/lists/singly_linked_list_spec.rb | UTF-8 | 2,664 | 3.203125 | 3 | [] | no_license | require 'spec_helper'
require_relative '../../lists/singly_linked_list'
describe SinglyLinkedList do
subject { SinglyLinkedList.new }
describe "new" do
it "has a size of 0" do
expect(subject.size).to eql(0)
end
it { is_expected.to be_empty }
end
describe "#push" do
before :each d... | true |
8b86b7c95e6db57b4c263131be8973d4d9499cdb | Ruby | lorenzVillain/fullstack-challenges | /03-AR-Database/02-SQL-CRUD/03-Create-Update/app/models/mealview.rb | UTF-8 | 1,406 | 3.234375 | 3 | [] | no_license | class MealView
def ask_for_info
print"meal name:"
name = gets.chomp
print "Meal price (in euros):"
price = gets.chomp.to_i
{name: name, price: price}
end
def list (meals)
meals.each do |meal|
puts "#{meal.id} - #{meal.name} -#{meal.price} euros"
end
end
end
class CustomerVie... | true |
a5f065635c38a5f024e0f06df2336d3ec7a669e8 | Ruby | launchpadtt/intent_pizza | /features/step_definitions/order_steps.rb | UTF-8 | 4,047 | 2.875 | 3 | [] | no_license | Given /^I order a pizza with the following information$/ do |fields|
step %{I select "Order a pizza"}
step %{I complete the pizza order}, fields
end
Given /^I place another order for a pizza with the following information$/ do |fields|
step %{I select "Place another order"}
step %{I complete the pizza order}, ... | true |
41707924feb15d02c1649035adbc3b5096a92621 | Ruby | somethinrother/bitmaker_lessons | /programming_fundamentals6/exercise.rb | UTF-8 | 890 | 4.125 | 4 | [] | no_license | # # Part 1
emotions = {
:anger => 1,
:hunger => 1,
:sadness => 1,
:happiness => 3,
:confusion => 2,
:contentment => 3,
:comfort => 2
}
# # Part 2
class Person
def initialize(name, emotions_hash)
@name = name
@emo... | true |
c587e25aacd41725f420e67c62fe9c6254f3e6b6 | Ruby | jinktiger/ninety-nine-bottles | /beer.rb | UTF-8 | 758 | 4.125 | 4 | [] | no_license | # YOUR CODE HERE
bottles = 99
while bottles >= 0 # While loop keeps running until bottles is greater than or equal to 0
if bottles > 1
puts "#{bottles} bottles of beer on the wall"
puts "#{bottles} bottles of beer"
bottles = bottles - 1
puts "Take one down and pass it around, #{bottles} bottles of beer ... | true |
93f701392a2047b4f4654bb31be3361252ce28c7 | Ruby | Pocket/fake_sqs | /spec/unit/message_spec.rb | UTF-8 | 1,428 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'fake_sqs/message'
RSpec.describe FakeSQS::Message do
describe "#body" do
it "is extracted from the MessageBody" do
message = create_message("MessageBody" => "abc")
expect(message.body).to eq "abc"
end
end
describe "#md5" do
it "is calculated from body" do
message = cre... | true |
5f8139c6aa2ba6c9283ceef26c3ea002e95e6d18 | Ruby | puppy36/script1 | /Ruby/me1.rb | UTF-8 | 394 | 3.671875 | 4 | [] | no_license |
print "enter the first number: "
num1 = gets.chomp.to_f
print "enter the second number: "
num2 = gets.chomp.to_f
print "enter your operator: "
oper = gets.chomp
case oper
when "-"
puts " #{op1}\n- #{op2}\n-----------\n #{(op1 - op2)}"
when "*"
puts " #{op1}\nX #{op2}\n-----------\n #{(op1 * op2)}"
when... | true |
dcdcc0c3a89f96b92e6c7d65f7aeaa2a09823abc | Ruby | kenko-org/kenko-ruby | /lib/kenko/middleware.rb | UTF-8 | 1,106 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'kenko/middleware/response_builder'
module Kenko
class Middleware
attr_reader :container, :checks, :options, :health_check_path_regexp, :checker
def initialize(app, path: '/health', checks: :all, container: Kenko::Container, checker: Kenko::Checker.new, **options)
@container = c... | true |
260a1b2fbe4d5fe53228a432151204b08097cf2f | Ruby | lighthousemo/oop_design_tic_tac_toe | /lib/board.rb | UTF-8 | 384 | 3.5 | 4 | [] | no_license | class Board
attr_reader :rows
def initialize()
@rows = [
[Tile.new(), Tile.new(), Tile.new()],
[Tile.new(), Tile.new(), Tile.new()],
[Tile.new(), Tile.new(), Tile.new()]
]
end
# Change the value of the tile at row, col
# Return the tile.
def record_move(row, col, value)
tile... | true |
5b7aeb6b12e4d4d6ddc68084c3d29ac31e5d6f0c | Ruby | stiegerj/417 | /hw7.rb | UTF-8 | 159 | 2.828125 | 3 | [] | no_license | require_relative "scan.rb"
s = Scanner.new()
t = s.next_token()
while(t.kind != 'exit' && t.kind != 'quit' && t.kind != 'eof')
t = s.next_token()
end | true |
b3092278e844542a42d5f5d67919cd784c929f6d | Ruby | nielschristiank/ruby-zombies | /hospital_level_1.rb | UTF-8 | 5,645 | 3.75 | 4 | [] | no_license | require './items'
require './player'
require './monsters'
class Room
attr_accessor :name, :items, :enemies
def initialize(name = "room", items = [], enemies = [])
@name = name
@items = items
@enemies = enemies
end
end
#hospital_room = Room.new("HOSPITAL ROOM", [Axe.new("Fire Axe")], [])
#------HOS... | true |
79be49b0e5b2a8431cf941378dd6bdd71a28c78f | Ruby | parm530/advanced-hashes-hashketball-001-prework-web | /hashketball.rb | UTF-8 | 4,558 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
# Write your code here!
def game_hash
{
:home => {
:team_name => "Brooklyn Nets",
:colors => ["Black", "White"],
:players => {
"Alan Anderson" => {:number => 0, :shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1},
... | true |
51b78c87dbf83147fe210769989b1a81cfeb47cb | Ruby | cristinaradu3/wgc_groundwork | /primes.rb | UTF-8 | 185 | 3.46875 | 3 | [] | no_license | require 'prime'
class Primes
def self.sum_to(limit = 100)
sum = 0
Prime.each(100) do |prime|
sum = sum + prime
end
puts sum
end
puts sum_to
end | true |
562d61d392675e0311f6f9a51c9fc2387d71dc8b | Ruby | IvikGH/solidgem | /z2.rb | UTF-8 | 1,286 | 3.609375 | 4 | [] | no_license | def brakets(str)
return " строка НЕвалидна так как начинается с закрывающейся скобки" if str[0] == ")"
temp = 0
str.chars.each do |char| # прохождение по строке
temp += ( char == "(" ? 1 : -1 ) # анализ "равновесия" скобок
return " строка невалидна " if temp < 0 # выход, если закрывающих больше, даже в се... | true |
565f8b1c2f3a9e3ca7f78624ffadf59c788b7591 | Ruby | JaroslavRamba/goodkit | /testing/15-check-not-used-objects.rb | UTF-8 | 2,931 | 2.6875 | 3 | [] | no_license | require 'date'
require 'gooddata'
require 'csv'
require 'optparse'
require 'yaml'
# initiate parameters for user input
options = {}
OptionParser.new do |opts|
opts.on('-u', '--username USER', 'Username') { |v| options[:username] = v }
opts.on('-p', '--password PASS', 'Password') { |v| options[:password] =... | true |
9f337c475759a06809a6ae529e29e84ac64aa4c4 | Ruby | Heath101/google_static_map | /lib/google_static_map/middleware.rb | UTF-8 | 855 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative './signed_url'
module GoogleStaticMap
class Middleware
def initialize(app)
@app = app
end
def call(env)
@env = env
if google_static_map_request?
signed_url = SignedURL.new(url_with_client_param, api_key)
[301, {'Location' => signed_url.to_s, 'Content-Ty... | true |
2782afe2b3deda57395c3139907f850d09b033eb | Ruby | richrosenthal/RubyHW | /method.rb | UTF-8 | 70 | 2.921875 | 3 | [] | no_license | def user(name)
puts "Hello #{name}"
end
user("Ricky")
user("Emma")
| true |
0dcf0811a05684a632a21196b7449cef143b630b | Ruby | seann1/train_system | /spec/line_spec.rb | UTF-8 | 1,587 | 2.859375 | 3 | [] | no_license | require 'spec_helper'
describe Line do
it 'is initialized with a name and id' do
new_line = Line.new({:name => 'yellow'})
expect(new_line).to be_a Line
expect(new_line.name).to eq "yellow"
end
describe 'save' do
it 'saves a line to the database' do
new_line = Line.new({:name => 'yellow'})
... | true |
d20770476302f05109cb12f007395205624ab627 | Ruby | Wil-McC/SweaterWhether | /app/poros/forecast_full.rb | UTF-8 | 1,618 | 3.1875 | 3 | [] | no_license | class ForecastFull
attr_reader :id,
:current_weather,
:daily_weather,
:hourly_weather
def initialize(data)
@id = nil
@current_weather = current_cleaner(data)
@daily_weather = daily_cleaner(data)
@hourly_weather = hourly_cleaner(data)
end
... | true |
7092c47a4771b6691e777a51502419951b6175be | Ruby | Wynnah/Ruby | /DNS Spoofing/arpSpoof.rb | UTF-8 | 1,859 | 2.5625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'rubygems'
require 'packetfu'
include PacketFu
class ArpSpoof
# Enable IP forwarding
`echo 1 > /proc/sys/net/ipv4/ip_forward`
def initialize(config, targetsAddr, targetsMac, iface)
@config = config
@targetsAddr = targetsAddr
@targetsMac = targetsMac
@iface = if... | true |
092f5cf8d069bbede69c0059c2d84d05152d4d71 | Ruby | Killsoft1692/First_ror_lessons | /numbers/numbers.rb | UTF-8 | 547 | 4.15625 | 4 | [] | no_license | def calculate_year
year = 365
hours = 365*24
return "We calculate that we have #{hours} hours"
end
def calculate_decade
decade = 10
minutes_in_decade = decade*24*60
return "A: #{minutes_in_decade} minutes"
end
def my_lifetime(time, revert)
if revert == 0
secons_old = time*365*24*3600
answ = "I'... | true |
93a8b0adb3fbcba34b6b2cc57cfe769c67f87137 | Ruby | kristianmandrup/directory_handler | /experiments.rb | UTF-8 | 804 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'active_support'
require 'test/unit'
module Blip
class Klass
end
end
module AppHandler
class Basic
def initialize
end
def matches(dir)
FileList["#{dir}/**/*"]
end
def handle(dir)
handle_app(dir) if matches(dir) # to location
end... | true |
651615258352ec3682dbd47fc95e8b0d34880e26 | Ruby | jeka2/Algorithms | /sorting/bucket_sort.rb | UTF-8 | 1,295 | 3.546875 | 4 | [] | no_license | class BucketSort
##Since bucket sort efficiency is entirely dependent on the allocation of
##the elements in the buckets(in other words, I'm assuming whoever is using it is
##overall aware of the distribution of the data), I'm going to assume a relatively
##even distribution and sort each individual bucket with... | true |
855c4a0f8c2c7834d566b00f726dab4b6d4ad75a | Ruby | swipely/pipely | /spec/lib/pipely/pipeline_date_time/pipeline_date_pattern_spec.rb | UTF-8 | 4,877 | 2.671875 | 3 | [] | no_license | # encoding: utf-8
require 'pipely/pipeline_date_time/pipeline_date_pattern'
TestSelection = Struct.new(:num_days_back, :target_date, :target_all_time)
class TestDatePatternMatcher
attr_accessor :day_offsets, :month_offsets, :year_offsets
PipelineDate = Pipely::PipelineDateTime::PipelineDate
def initialize(dat... | true |
62986dd2561bddc87844c786e047d3424a79dbd0 | Ruby | Hyunkim95/CFA-airbnb | /Ruby/code_wars/convertFracts.rb | UTF-8 | 229 | 2.84375 | 3 | [] | no_license | def convertFracts(lst)
multi = []
lst.each{|num| multi << num[1]}
ans = (multi[0].lcm(multi[1])).lcm(multi[2])
lst.each do |array|
array[0] = ans/array[1] * array[0]
array[1] = ans
end
end
| true |
f17fff62c0ff3490a7057d459edb9a659519223a | Ruby | mertoz41/sinatra-mvc-lab-wdc01-seng-ft-042020 | /models/piglatinizer.rb | UTF-8 | 1,316 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(input_str)
input_str.split(" ").map{ |word| piglatinize_word(word)}.join(" ")
end
# privatee
def vowel?(char)
char.match(/[aAeEiIoOuU]/)
end
def piglatinize_word(word)
# word starts with vowel
if vowel?(... | true |
283fbd12b2b281abc57fe0b773707aca0ed76140 | Ruby | parryd4/deli-counter-web-040317 | /deli_counter.rb | UTF-8 | 618 | 4.125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def line(queue)
if queue.size == 0
puts "The line is currently empty."
else
say_say_say = "The line is currently:"
length = queue.size
count = 0
while count < length do
say_say_say += " #{count+1}. #{queue[count]}"
count +=1
end
puts say_say_say
end
... | true |
fd912043436e1c9cbd304e237ba296625a07301c | Ruby | LeonB/callbacks | /lib/classmethods.rb | UTF-8 | 3,830 | 2.75 | 3 | [
"MIT"
] | permissive | module Callbacks
module ClassMethods
def callback_methods
#Use one @, else it gets stored in the module and then it will be avaiable in every class that uses callback
@callback_methods ||= []
end
def callback_actions
#Use one @, else it gets stored in the module and then it w... | true |
be565833ea5bdfa734dc9a58ce0842ad87efa32f | Ruby | altun/Learn | /metin_islemleri/metin_islemleri_3.rb | UTF-8 | 1,181 | 3.859375 | 4 | [] | no_license | puts "-----------------"
# Metin parçalama
metin = "Karşıki dağlar Jandarma!"
# 0 dan başla 3. karaktere gel ve bu karakterden itibaren 10 karakter ekrana bas
puts metin[3,10]
# üstteki örnekten farklı olarak 3. karakter ile 10. karakter arasını bastır demektir. (10 dahil)
puts metin[3..10]
# üstteki örneğin aynısı ... | true |
534f960f8df6288de372df2548e1949d1f00cc83 | Ruby | doolin/rpo | /openstruct/ips.rb | UTF-8 | 495 | 2.953125 | 3 | [] | no_license | require "benchmark/ips"
require "ostruct"
class Foo
attr_reader :a, :b, :c
def initialize(a:, b:, c:)
@a = a
@b = b
@c = c
end
end
Bar = Struct.new(:a, :b, :c)
params_as_hash = {a: "a", b: "b", c: "c"}
params_as_array = params_as_hash.values
Benchmark.ips do |bm|
bm.report(:class) do
Foo.n... | true |
85ddb4dd46915d3da0fe31c1bffd3df1420526c2 | Ruby | llollox/db_passi | /app/models/db_comuni/fraction.rb | UTF-8 | 2,606 | 2.765625 | 3 | [] | no_license | class Fraction < ActiveRecord::Base
include ConnectToDbComuni
include Searchable
belongs_to :municipality
belongs_to :region
geocoded_by :address
def address
address = self.name
address += ", " + self.municipality.name
address += ", " + self.municipality.province.name
address += ", " + se... | true |
e1981ca91724823c11df1608eed9f5c9e0fe8787 | Ruby | julalam/betsy | /app/models/product.rb | UTF-8 | 869 | 2.671875 | 3 | [] | no_license | class Product < ApplicationRecord
has_and_belongs_to_many :categories
belongs_to :merchant
has_many :reviews
has_many :order_items
has_many :orders, through: :order_items
validates :name, presence: true, uniqueness: true
validates :price, presence: true
validates :price, numericality: { greater_than: ... | true |
b6dabe8006bbb03c16bec843ed368b1c8e50594c | Ruby | srm985/StatisticalModeling | /PI Alarm Set Points_Maximums.rb | UTF-8 | 7,168 | 3.375 | 3 | [] | no_license | #This program works to establish High, HiHi, Low, and LoLo alarm set points. This is achieved
#by first flagging flat-lined or stale data points and then computing a Z-score table. Based
#on a Z-score acceptance factor, individual data points are included/excluded. Maximum and
#minimum values are then extracted fro... | true |
8cbef37d1151e260cc39d07b5b27bc73ca1dedd6 | Ruby | parroty/ruboto_spinner | /src/ruboto_spinner_activity.rb | UTF-8 | 1,009 | 2.59375 | 3 | [] | no_license | require 'ruboto/widget'
import 'android.widget.ArrayAdapter'
import 'java.util.Locale'
class RubotoSpinnerActivity
def on_create(bundle)
super
set_title 'Ruboto Spinner Sample'
self.setContentView(Ruboto::R::layout::activity_main)
adapter = ArrayAdapter.new(self, Ruboto::R::layout::simplerow)
a... | true |
12fddf956b54b816a3af49d840a3c23718755461 | Ruby | vinithanatarajan/Group_project---ChallengeTimer | /app/models/challenge.rb | UTF-8 | 467 | 2.96875 | 3 | [] | no_license |
require 'time'
class Challenge < ActiveRecord::Base
def to_s
<<-STRING
#{id}: #{name}
#{description}
Time taken: #{formatted_time}
STRING
end
def formatted_time
"#{time_completed}s" if time_completed
end
def start_timer
update(start_time: Time.now)
end
def end_timer
update(end_time: T... | true |
e1da8d50c70a5aa4776c8b58b844dbef7ce104a5 | Ruby | Bhuser/exercism | /ruby/matrix/matrix.rb | UTF-8 | 177 | 3.296875 | 3 | [] | no_license | class Matrix
attr_reader :rows
def initialize (input)
@rows = input.each_line.map { |i| i.chomp.split.map(&:to_i) }
end
def columns
@rows.transpose
end
end | true |
e8373b562652fa7ac1e017be28d76bc283eb6327 | Ruby | kouki9115/study_ruby- | /rand2.rb | UTF-8 | 154 | 3.359375 | 3 | [] | no_license | def aaa(h)
i = 1
while i <= 10 do
random = rand(5)
if random == 3
puts h
else
puts "def#{h}"
break
end
i = i + 1
end
end
puts aaa("hello") | true |
93d0dfd644837205666409c06c6cbaa3acaa12d4 | Ruby | johnsonch/RubyQuizes | /chop.rb | UTF-8 | 1,014 | 3.109375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | class Karate
def self.chop(target, array)
array.find_index(target) ? array.find_index(target) : -1
end
end
describe "chop" do
it 'runs the examples' do
Karate.chop(3,[]).should eql -1
Karate.chop(3,[1]).should eql -1
Karate.chop(1,[1]).should eql 0
Karate.chop(1, [1, 3, 5]).should eql ... | true |
efa972bfa369260599af876f5b4229fc2342fc28 | Ruby | scaryguy/rubylife | /spec/rubylife_spec.rb | UTF-8 | 5,110 | 3.125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require_relative './../lib/rubylife.rb'
require_relative './../lib/rubylife/board.rb'
require_relative './../lib/rubylife/cell.rb'
# General Structure
# -----------------
# _0,0_|_0,1_|_0,2_
# _1,0_|_1,1_|_1,2_
# _2,0_|_2,1_|_2,2_
#------------------
describe Rubylife do
context 'Game', game:... | true |
00947d8e64ed72dca6a788d04d861a9d5762e47d | Ruby | svasan/praxis | /ds/stack.rb | UTF-8 | 356 | 3.109375 | 3 | [] | no_license | require_relative 'linked_list'
class Stack < LinkedList
def each
p = @last
until p == nil
yield p.val
p = p.prev
end
end
def pop
return nil if @last.nil?
out = @last
@last = @last.prev
@last.next = nil if not @last.nil?
@size -= 1
out.prev = nil
out.val
end
... | true |
a3e1e4ef1fc2affa6bae66475ca19286e62fed3f | Ruby | graemenelson/aqua | /spec/object/pack_spec.rb | UTF-8 | 16,801 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require_fixtures
Aqua.set_storage_engine('CouchDB') # to initialize CouchDB
CouchDB = Aqua::Store::CouchDB unless defined?( CouchDB )
describe Aqua::Pack do
before(:each) do
@time = Time.now
@date = Date.parse('12/23/1969')
@log = Log.... | true |
7080ee45c25241c864e15b2bb258e2fbdf64c244 | Ruby | MichaelZLai/pokenatra | /app.rb | UTF-8 | 1,698 | 2.703125 | 3 | [] | no_license | require "sinatra"
require "sinatra/reloader"
require "active_record"
require 'pry'
require_relative "db/connection"
require_relative "models/pokemon"
require_relative "models/trainer"
# Pokemon Information ++++++++++++++++++++++++++
get "/" do
@pokemon = Pokemon.all
erb :"pokemon/index"
end
# create pokemon ++++... | true |
b4c48b301ae41d53ea889e7d913fb06bb17d32e1 | Ruby | bnzene/learn-to-program | /chap11/ex02.rb | UTF-8 | 285 | 3.59375 | 4 | [] | no_license | def spank
puts 'What year were you born in?'
year = gets.chomp.to_i
puts 'What month?'
month = gets.chomp.to_i
puts 'What day?'
day = gets.chomp.to_i
seconds = Time.new - Time.local(year, month, day)
years = seconds/(60*60*24*365)
puts 'SPANK!' * age
end
puts spank
| true |
f0627acfcac745853c86fc70f361b41511149fba | Ruby | Roobios/ex_Ruby | /exo_12.rb | UTF-8 | 321 | 3.671875 | 4 | [] | no_license | print "Quelle est ton année de naissance?"
nb = gets.chomp.to_i
année = nb
while nb <= 2021
if (2021-année)/2 != 2021-nb
puts "Il y a #{2021-nb} ans, tu avais #{nb-année} ans."
else
puts "Il y a #{2021-nb} ans, tu avais la moitié de l'âge que tu as aujourd'hui."
end
nb = nb +1
end | true |
4f8c4020593bcfc2f44a9cb203d7f9341046b36c | Ruby | yumayo14/character_game | /spec/equipments/stick_spec.rb | UTF-8 | 621 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../equipments/stick.rb'
describe 'Stick' do
let(:stick) { Stick.new }
it '攻撃力が30上昇する' do
expect(stick.attack).to eq 30
end
it '防御力が10上昇する' do
expect(stick.defence).to eq 10
end
it '戦士が装備した場合、補正値は0' do
expect(stick.warrior_correction).to eq 0
... | true |
ce55a2dfe4693c0dee6319ce78639891809afe59 | Ruby | chris-bon/jam | /db/initialseed.rb | UTF-8 | 3,491 | 2.578125 | 3 | [] | no_license | Faker::Config.locale = 'en-US'
User.create profile_id: 1,
username: 'admin',
email: 'chrisbon315@gmail.com',
password: 'Qwert1',
password_confirmation: 'Qwert1'
Profile.create user_id: 1,
name: 'Chris Bon',
age: 27,
... | true |
79fdb74e22e59eb12c76d649e81bc3d6187e0aea | Ruby | IIC2513-2017-1/grupo-12 | /config/initializers/requests.rb | UTF-8 | 1,077 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
# Main class to handle connections to telegram bot
class Telegram
def initialize
@path = "https://api.telegram.org/bot#{ENV['BOT_TOKEN']}"
@client = HTTPClient.new
@url = 'https://dreamfunder-uc.herokuapp.com/api/v1/'
@hook = 'telegram'
set_webhook
end
def send_... | true |
7f4edc6495a0721713e1b8471d63b680c8f8057e | Ruby | marythought/exercism_ruby | /series/series.rb | UTF-8 | 250 | 3.390625 | 3 | [] | no_license | class Series
def initialize(string)
@string = string.chars
end
def slices(num)
raise ArgumentError, "slice size must be smaller than series length" if num > @string.length
@string.each_cons(num).map { |a| a.map(&:to_i) }
end
end
| true |
2df18477bdd3516661dbdbd192e910943b75d50d | Ruby | janessatran/substrings | /spec/substrings_spec.rb | UTF-8 | 516 | 3.109375 | 3 | [] | no_license | require './substrings'
describe '#substrings' do
it 'takes a string and finds all the words + its substrings and returns how many times it appears' do
dict = ["below",
"down",
"go",
"going",
"horn",
"how",
"howdy",
"it",
... | true |
983e3568dac6b7111ffc282bca7e457db6012fbd | Ruby | thuongdv/ruby_selenium | /spec/tc01_user_can_create_account_with_valid_data_spec.rb | UTF-8 | 1,207 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'pages/home_page'
# TEST CASE: user can create an account with valid data
# STEPS:
# 1. Navigate to http://automationpractice.com\
# 2. Create an account with valid email address
# 3. Register personal information
# Verify successful message displays: Welcome to your account. Here you can manage all of your pe... | true |
3a08969c344e51baacad92d04e7f3d82cabcb0ff | Ruby | RichardRoepke/CampgroundCompare | /app/models/validators/rvparky_location_validator.rb | UTF-8 | 6,730 | 2.875 | 3 | [] | no_license | class RvparkyLocationValidator
include ActiveModel::Validations
# The names of the various attributes match the names of the attributes in
# RVParky, so that they don't have to be converted to and back whenever
# retreiving or updating info.
attr_accessor :website
attr_accessor :formerlyKnownAs
attr_acc... | true |
2a4ed30939437e3921cc414d942eefadb3057005 | Ruby | ltarnowski1/Ruby_Projekt3 | /bin/rent.rb | UTF-8 | 225 | 2.96875 | 3 | [] | no_license | class Rent
attr_accessor :id, :id_book, :rent_date, :return_date
def initialize(id, id_book, rent_date, return_date)
@id = id
@id_book = id_book
@rent_date = rent_date
@return_date = return_date
end
end | true |
1660dd1f287d457b83d554891172cda29261d468 | Ruby | cxn03651/write_xlsx | /examples/hide_sheet.rb | UTF-8 | 785 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#######################################################################
#
# Example of how to hide a worksheet with Excel::Writer::XLSX.
#
# reverse('c'), April 2005, John McNamara, jmcnamara@cpan.org
# convert to ruby by Hideo, Nakamura, nakamura.hideo@gmail.com
#
require '... | true |
14d9c3bfd90354172104d1ec0a548adef87d39e4 | Ruby | jwchau/AAHomework | /W4D5/octopus/octopus.rb | UTF-8 | 2,754 | 3.75 | 4 | [] | no_license | require 'io/console'
require 'benchmark'
class Array
def sluggish_octopus
longer = ""
(0...length).each do |i|
(i...length).each do |j|
longer = self[j] if self[j].length > longer.length
end
longer = self[i] if self[i].length > longer.... | true |
de8e63a292dff7affca018ff6e48ca645a86561a | Ruby | mycodelabs/Employee-Test | /notifications.rb | UTF-8 | 862 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
require "rb-fchange"
require "./folders.rb"
notifier = FChange::Notifier.new
notifier.watch(Folders[:root], :all_events, :recursive) do |event|
monitor = Monitor.new
monitor.monitor_changes
end
Signal.trap('INT') do
p "Bye bye...",
notifier.stop
abort("\n")
end
notifie... | true |
3b6bce671ba04c8c2e4c74463a76096e8467bc58 | Ruby | dkosowski87/rbnd-toycity-part3 | /lib/customer.rb | UTF-8 | 1,382 | 3.140625 | 3 | [
"MIT"
] | permissive | class Customer
attr_reader :name
@@customers = []
def initialize(options={})
@name = options[:name]
add_to_customers
end
def self.all
@@customers
end
def self.find_by_name(name)
@@customers.find { |customer| customer.name == name}
end
#Allows for purchasing a product. Creates a new transaction wit... | true |
21ac44bcef0f6d46d846c93c562f6fd2ab9ac3a4 | Ruby | showma0734/atcoder_beginner157 | /B.rb | UTF-8 | 1,467 | 3.546875 | 4 | [] | no_license | def valid?(a_arr, b_arr, c_arr, n, d_arr)
return false unless a_arr.is_a?(Array)
return false unless b_arr.is_a?(Array)
return false unless c_arr.is_a?(Array)
return false unless n.is_a?(Integer)
return false unless d_arr.is_a?(Array)
return false unless a_arr.all?{|obj| is_a?(Integer)}
return fals... | true |
0dd7544e7e9044131be7eda3595d9d32ddaf4d1c | Ruby | april/menagerie | /app/models/wordbank_term.rb | UTF-8 | 1,065 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
module WordbankTerm
# Dictionary
def self.dictionary
@dictionary ||= YAML.load_file(Rails.root.join("db/dictionary.yml")).to_set.freeze
end
def self.dictionary_word?(word)
return dictionary.include?(word)
end
# Blacklist
def self.blacklist
@blacklist ||= beg... | true |
ee89bd73fd037eec121bc5a2ed41c5750815a4b1 | Ruby | Veyb/Thinknetica | /lesson_2/vowels.rb | UTF-8 | 155 | 3.546875 | 4 | [] | no_license | alphabet = ('a'..'z').to_a
vowels = "aeiou"
vowels_hash = {}
vowels.each_char { |vowel| vowels_hash[vowel] = alphabet.index(vowel) + 1 }
puts vowels_hash
| true |
e2994d5ee364feb64a1efe850041a9906c1e75fc | Ruby | cosine/record_parser | /lib/record_parser/api.rb | UTF-8 | 1,561 | 2.84375 | 3 | [] | no_license | require "sinatra/base"
class RecordParser
class API < Sinatra::Base
class << self
attr_reader :records_option1, :records_option2, :records_option3
def reset_records!
@records_option1 = RecordParser::RecordSet.new(sort_by: RecordParser::RecordSet::SORT_ORDERS["option1"])
@records_opti... | true |
571241250bec2be06cc0cbe9d2b0530e9f9bf04e | Ruby | pablohenriq/lottery-play | /ruby/lib/run.rb | UTF-8 | 550 | 3.6875 | 4 | [] | no_license | def menu
puts "Select a game option \n
[1] Mega-sena [2] Quina [3] Lotomania [0] Exit \n\n"
print 'Enter your choice here: '
end
menu
game_chosen = gets.chomp
while game_chosen != '0'
system('clear')
case game_chosen
when '1'
puts "\nMEGA-SENA"
load 'ruby/lib/run_megasena.rb'
when '2'
... | true |
6031d59953a7f184d8be9657dbed8d7edcc154d3 | Ruby | caxlsx/caxlsx | /lib/axlsx/drawing/view_3D.rb | UTF-8 | 3,302 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Axlsx
# 3D attributes for a chart.
class View3D
include Axlsx::OptionsParser
# Creates a new View3D for charts
# @option options [Integer] rot_x
# @option options [String] h_percent
# @option options [Integer] rot_y
# @option options [String] depth_perc... | true |
77304f14d7006826ff28b3409c089cc80e1478be | Ruby | KFKilgore/programs | /homework/user_input_madlib.rb | UTF-8 | 1,159 | 3.75 | 4 | [] | no_license | puts "Please name a day of the week."
day_of_week=gets
puts "a verb ending in -ing"
verbing=gets
puts "a classmate"
classmate=gets
puts "a local restaurant"
local_restaurant=gets
puts "your favorite food"
food=gets
puts "a beverage"
beverage=gets
puts "a music act"
music_act=gets
puts "a city"
city=gets
... | true |
8d805e6241248f922880bd90159add86828afc2d | Ruby | krtb/ruby-objects-has-many-lab-nyc-web-051418 | /lib/song.rb | UTF-8 | 247 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :song, :artist, :name
def initialize(song)
@song = song
end
def name
self.song
end
def artist_name
if self.artist
self.artist.name
else
return nil
end
end
end
| true |
b21e1c40fadeb37d078073d904bafc1895124ed0 | Ruby | bschnitz/odin-chess | /lib/chess_pieces/knight.rb | UTF-8 | 271 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../chess_piece'
# depicts a knight on a chess board
class Knight < ChessPiece
def reachable_positions
deltas = [-1, 1, 2, -2].permutation(2).filter { |(a, b)| a != -b }
[positions_from_deltas(deltas)]
end
end
| true |
07a774e86aca1123aa70b802a2e0b001c5aab706 | Ruby | dpholbrook/ruby_small_problems | /basics/arrays/6.rb | UTF-8 | 241 | 3.515625 | 4 | [] | no_license | names = ['bob', 'joe', 'susan', 'margaret']
names[3] = 'jody'
# the problem was that we were improperly using element reference
# we need to reference elements using integers that represent the index, not strings that represent the element
| true |
09aa3b51ddebbba389806d9d9b906641333b8feb | Ruby | Sh1mensoka/ruby_kubsu | /Lab1/lab1.2.rb | UTF-8 | 408 | 3.078125 | 3 | [] | no_license | name = ARGV[0]
puts "Hello #{name}"
ARGV.clear
print 'Какой язык у Вас самый любимый? '
lang = gets.chomp
unless lang == 'ruby'
puts 'Скоро будет ruby.'
else
puts 'Подлиза.'
end
print "Введите команду Ruby: "
com_ruby = gets.chomp
print "Введите команду ОС: "
com_os = gets.chomp
system("ruby -e \"#{com_ruby}\"")
sys... | true |
1a541bfa5ea5721d60f56b8333a9933a8be4755a | Ruby | StephanieCunnane/Launch_School_Challenges | /robot_simulator/robot_simulator.rb | UTF-8 | 2,370 | 3.765625 | 4 | [] | no_license | #class Robot
# attr_writer :orientation
#
# ORIENTATIONS = [:north, :east, :south, :west].freeze
#
# def orient(direction)
# raise ArgumentError unless ORIENTATIONS.include?(direction)
# @orientation = direction
# end
#
# def bearing
# @orientation
# end
#
# def turn_right
# idx = ORIENTATIONS.index(... | true |
225b29df281c26c47e120b8cfa3c54e9c5f0407c | Ruby | kenjo0827/fizzbuzz-ruby | /lib/fizzbuzz.rb | UTF-8 | 161 | 3.28125 | 3 | [] | no_license | # coding: utf-8
def fizzbuzz( num )
return 'FizzBuzz' if num % 15 == 0
return 'Fizz' if num % 3 == 0
return 'Buzz' if num % 5 == 0
return ''
end | true |
4935d2992c848cd60394f8c6f438d4cadb59d5ae | Ruby | syclee/MyProjectEuler | /ruby/PE2/v2.rb | UTF-8 | 692 | 4.03125 | 4 | [] | no_license | # from forum there is a pattern for fibonacci numbers being even
#
# This may be a small improvement. The Fibonacci series is:
#
# 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610...
#
# Now, replacing an odd number with O and an even with E, we get:
#
# O, O, E, O, O, E, O, O, E, O, O, E, O, O, E...
#
# And s... | true |
adb17ebca30b63b52fac04e008ef28c5a9d8cb5c | Ruby | katie-bailey/RB101 | /Ruby_Small_Problems/Easy_2/e05.rb | UTF-8 | 166 | 3.6875 | 4 | [] | no_license | puts "Whats your name?"
name1 = gets.chomp
name2 = name1.upcase
if name1.include? "!"
puts "HELLO #{name2}. WHY ARE WE SCREAMING?"
else
puts "Hello #{name1}."
end | true |
bd6eef3aacf2d2e5d73edebe1477334452eec8d8 | Ruby | kamilkowalski/scraper | /lib/preprocessor.rb | UTF-8 | 426 | 2.671875 | 3 | [] | no_license | module Scraper
module Preprocessor
def clear_text(nodes)
nodes.map do |n|
n.content.gsub(/[\n\r]/, "").gsub(/\s+/, " ")
end.reject do |c|
c.nil? || c == " " || c == "" || c.length < 5
end.join("\n")
end
def extract_links(nodes)
nodes.map do |n|
n.attribute(... | true |
f9249d1c66932f84696742fcdb0ca63ce5f804da | Ruby | TylerSell/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 821 | 3.859375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(ascending)
ascending.sort do |a, b|
a <=> b
end
end
def sort_array_desc(decending)
decending.sort.reverse do |a, b|
a <=> b
end
end
def sort_array_char_count(chars)
chars.sort_by {|x| x.length}
end
def swap_elements(swap)
swap[1], swap[2] = swap[2], swap[1]
swap
end
def re... | true |
f8c92cf0e85e4137e1b26e7d97c3fb49ca2d0209 | Ruby | 5-stones/huginn_record_link_agent | /app/utils/record_link_builder.rb | UTF-8 | 2,884 | 2.546875 | 3 | [
"MIT"
] | permissive | class HuginnRecordLinkAgent::RecordLinkBuilder
# This is a utility class for managing the creation of RecordLink instances.
# As there are cases in which these links may need to be created in batch, the
# process has been isolated from the Agent to make things easier to maintain
def self.create_links(user, so... | true |
b8699868791560c284108b5b2336e7797174af4d | Ruby | dannygriffin000/rails | /activerecord/lib/active_record/database_configurations.rb | UTF-8 | 2,207 | 2.828125 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
module ActiveRecord
module DatabaseConfigurations # :nodoc:
class DatabaseConfig
attr_reader :env_name, :spec_name, :config
def initialize(env_name, spec_name, config)
@env_name = env_name
@spec_name = spec_name
@config = config
end
end... | true |
c20f0a3ddb44917024db6875941978466e9ef1eb | Ruby | amandagibson/library-challenge | /spec/library_spec.rb | UTF-8 | 1,420 | 2.890625 | 3 | [] | no_license | require './lib/library.rb'
require 'yaml'
describe Library do
let(:person) {instance_double('Person', name: 'Amanda', checked_out_book: 'Clean Code', message: @collection[index][:available])}
it 'have books in library' do
expect(subject.collection).not_to eq nil
end
it 'can search a book... | true |
821992d0703c24db3c42ce701547c1b75fe6cdda | Ruby | joegnelson/swagger-codegen | /samples/client/petstore/ruby/models/user.rb | UTF-8 | 1,509 | 3 | 3 | [
"Apache-2.0"
] | permissive |
class User
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
# :internal => :external
def self.attribute_map
{
:id => :'id',
:username => :'username',
:first_name => :'firstName',
:last_name => :'lastName',
:email => :'email',
:... | true |
0ae9ad5a1c9c323ee98faa01ad8643e73c016679 | Ruby | danielgroves/Optimus | /app/optimus.rb | UTF-8 | 1,632 | 2.953125 | 3 | [
"MIT"
] | permissive | require_relative 'resource_request'
require_relative 'image'
require_relative 'config'
# Rack application for on-the-fly image optimisation.
class Optimus
def initialize
@config = Config.new
end
def call(env)
request = Rack::Request.new env
if request.path_info == '/'
response = Rack::Respons... | true |
08ec3914a2335e249ad9f9f5c7d762525664446a | Ruby | Kelauni22/MoviesLibrary | /MoviesProgram.rb | UTF-8 | 1,219 | 3.140625 | 3 | [] | no_license | require './lib/MoviesClass.rb'
MoviesProgram = Movies.new
loop = true
while loop == true
MoviesProgram.questions()
#Display your movies
if MoviesProgram.choice == "d"
puts ("Here is your movie library: \n\n")
puts MoviesProgram.display()
puts ("\n")
elsif MoviesProgram.choice == "... | true |
33923eed8063357959e3cae77343e4b307248df3 | Ruby | kopylovvlad/hamdown | /lib/hamdown/md_regs/code.rb | UTF-8 | 670 | 2.671875 | 3 | [
"MIT"
] | permissive | module Hamdown
module MdRegs
# class with logic of markdown's code block
class Code < AbstractReg
REGS = {
'code' => /```[^`]*```/
}.freeze
private
def text_handler(text, scan_res, reg_name)
html_scan = scan_res.map do |i|
# delete spaces before last '```'
... | true |
e83ed81a296496f578765eabeb0f35bd1cda64c1 | Ruby | NandiniNayak/middleware-lesson | /Day3/timer_challenge.rb | UTF-8 | 266 | 3.203125 | 3 | [] | no_license | max_timer = 10.00
current_timer = 0.00
start_time = Time.now
while current_timer <= max_timer
print "\rTimer is ticking. #{current_timer}"
current_time_diff = Time.now - start_time
current_timer = current_time_diff.round(2)
end
puts "Timer is finished!"
| true |
a213e6447fa0bc276af4dddef338f7a114f63fb8 | Ruby | xiaoxinghu/noteman | /lib/noteman/md_processor.rb | UTF-8 | 843 | 2.640625 | 3 | [] | no_license | require 'redcarpet'
module Noteman
module MDProcessor
class StackRenderer < Redcarpet::Render::Base
attr_reader :items
def initialize
super
@items = []
end
def header(title, level)
items << { :text => title, :level => level, :type => :header }
"#{'#' * lev... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.