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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a88d10cf62d7418f6be836738a32c654eb645564 | Ruby | sdav9375/code_wars | /coffee_7kyu.rb | UTF-8 | 365 | 3.234375 | 3 | [] | no_license | def how_much_coffee(events)
activities = ['cw','CW','dog','DOG','cat','CAT','movie','MOVIE']
filtered = events & activities
number_of_cups = filtered.length
filtered.each do |event|
if event == event.upcase
number_of_cups += 1;
end
end
if number_of_cups > 3
return "You need extra sleep"
... | true |
eb59c7da5429e2347ac9dc9a990794fa247ca190 | Ruby | lrotschy/Ruby-Exercises | /OOP-Exercises/OO_Basics_3_10.rb | UTF-8 | 324 | 2.59375 | 3 | [] | no_license | # OO_Basics_3_10.rb
module Transportation
class Vehicle
end
class Truck < Vehicle
end
class Car < Vehicle
end
end
big_yellow = Transportation::Truck.new
herbie = Transportation::Car.new
# Namespacing: modules can group similar classes to make purpose clear and help avoid problems of same name in clas... | true |
365406ae6053066170f9d3645992e68521641563 | Ruby | avneetsng/advanced-ruby | /shopping_list.rb | UTF-8 | 742 | 4.03125 | 4 | [] | no_license | =begin
Write a simple DSL for creating a shopping list. We should be able to specify the item name and quantity..
Something like.
sl = ShoppingList.new
sl.items do
add("Toothpaste",2)
add("Computer",1)
=end
class Item
attr_reader :name, :quantity
def initialize(name, quantity)
@name = name
@quantit... | true |
19096f2333ecc6336793b71e5bc0cbbb2f3385ce | Ruby | mmaya/books_api | /app/controllers/book_copies_controller.rb | UTF-8 | 1,529 | 2.625 | 3 | [] | no_license | class BookCopiesController < ApplicationController
before_action :set_isbn, only: [:create, :update]
# GET /book_copies
def index
@book_copy = BookCopy.all
render json: @book_copy
end
# POST /book_copies
def create
# The book must exists to persist a copy of it.
# It's not a transaction... | true |
f91287af01ae3a69e716be8221f697b25a9300b6 | Ruby | pbldmngz/codewars | /kyu3/prime_streaming_PG-13.rb | UTF-8 | 343 | 3.3125 | 3 | [] | no_license | class Primes
@PRIME = [2]
MAX = 16000000
arr = [false] + [true] * (MAX-2)
arr[0] = nil
arr.each.with_index do |b, n|
next unless b
x = 2*n + 1
@PRIME << x
(x*x..MAX).step(x*2) { |i| arr[i/2] = nil }
end
arr = nil
def self.stream
@PRI... | true |
b26435af27463264534ddc5fc5f25274c0c522c0 | Ruby | OSC/ondemand | /apps/dashboard/app/apps/manifest.rb | UTF-8 | 5,423 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'yaml'
# Manifests provide metadata for applications (OodApps).
class Manifest
attr_reader :exception
# InvalidContentError is an error helper class to give users a nice
# error message when there are validation errors.
class InvalidContentError < StandardError
def initialize
super %q(Manif... | true |
683b35b40d86afe268c122ec510f23e50a03f110 | Ruby | carpcocolizo/caesar_cipher | /cesar.rb | UTF-8 | 1,012 | 4.09375 | 4 | [] | no_license | def caesar_cipher(string, shift)
string_nowarray = string.chars
finalword = []
string_nowarray.map do |char|
if char.ord > 96 && char.ord < 123
newchar = char.ord + (shift % 26)
if newchar.ord > 122
correctchar = newchar.ord - 122 + 96
finalword.push(correctchar.chr)
elsi... | true |
ce0cc19b5a26a3467c6d7f8329e01e3d4270ba08 | Ruby | ArmandoAmador/codewars | /ruby/8_kyu/subtract_the_sum/subtract_the_sum.rb | UTF-8 | 2,166 | 3.796875 | 4 | [] | no_license | # I took the long approach instead of just returning "apple" for this Kata as a good exercise on recursion
class SubtractTheSum
def self.subtract_sum(number)
if number >= 10 && number < 10000
number = number - self.sum_of_digits(number)
self.list.each do |item|
item = item.split("-")
i... | true |
a2b104a2656608d8bc46e8a377b1698376510b07 | Ruby | drapergeek/elbow | /spec/units/update_load_balancer_spec.rb | UTF-8 | 1,515 | 2.890625 | 3 | [] | no_license | require_relative '../../main'
describe UpdateLoadBalancer do
describe '#run!' do
context 'when given a load balancer that is in the system' do
it 'returns an string of yay' do
elb_double = load_balancer_collection(
['balancer1', 'balancer2']
)
output = UpdateLoadBalancer.... | true |
a99ea84c2d6f66d9d5da8fd86a563bcbae3875b7 | Ruby | tanoshiiruby/tanoshiiruby.github.io | /5/list/ch06/stripped_hello.rb | UTF-8 | 75 | 2.828125 | 3 | [] | no_license | puts("hello, world")
puts("こんにちは世界")
puts("你好,世界")
| true |
451fe212ed90a0e68a4efd527f9a59a306bc6d5d | Ruby | Alasdair321/CodeClan_work | /Classwork/week_03/day_04/IMDB Lab/models/casting.rb | UTF-8 | 951 | 2.828125 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class Casting
attr_accessor :fee
attr_reader :id, :movie_id, :performer_id
def initialize(options)
@id = options['id'].to_i if options['id']
@movie_id = options['movie_id'].to_i
@performer_id = options['performer_id'].to_i
@fee = options['fee'].to_i
end
... | true |
d3fe8d0a63a439466395ad41f22a954026436413 | Ruby | zhtlab/McuDevelop | /examples/IMU4P/tools/hamming.rb | UTF-8 | 1,828 | 3.046875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
G = [[1, 0, 0, 0, 0, 1, 1],
[0, 1, 0, 0, 1, 0, 1],
[0, 0, 1, 0, 1, 1, 0],
[0, 0, 0, 1, 1, 1, 1]]
H = [[1, 0, 1, 0, 1, 0, 1],
[0, 1, 1, 0, 0, 1, 1],
[0, 0, 0, 1, 1, 1, 1]]
$outCode = [-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1]
P = [0... | true |
87155c3104cee24cc00ea603016359f4f348ce60 | Ruby | jcfischer/referenz2 | /lib/permalink.rb | UTF-8 | 715 | 2.78125 | 3 | [] | no_license | class String
# From Typo:
# Converts a post title to its-title-using-dashes
# All special chars are stripped in the process
def to_url
result = self.downcase
# replace quotes by nothing
result.gsub!(/['"]/, '')
# strip all non word chars
result.gsub!(/\W/, ' ')
# replace all white s... | true |
011b491f280f2b6b3cc9c20cd3b1de751f8ab50d | Ruby | maxjacobzander/prime-ruby-onl01-seng-ft-081720 | /prime.rb | UTF-8 | 153 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(n)
if n < 2
false
elsif (2..n-1).none? do |numbers_checked|
n % numbers_checked == 0
end
true
else
false
end
end | true |
ef0f647776d5fdf69b9017d63030cd075b9ea778 | Ruby | Elis0317/Ruby | /BioRuby/-8/sample-hensu-5-4.rb | SHIFT_JIS | 730 | 3.5625 | 4 | [] | no_license | ### File-name: sample-hensu-5-4.rb
# True -> number (0, 17 ---) False -> nil
text_seq = "ATGCGTTGATGAGAAGGATGCATGCATGC"
print('Pattern_1 =', "\n")
p text_seq =~ /ATGC+ATGC/ # [+]͑O̕1ȏJԂƂɎgK\
# [=~i`_j]́AK\ɓĂ͂܂p^[݂邩m߂L
# }b`p^[݂Ȁ߂̕nڂ̎An-1ԂB
# ȂƂ nil ԂB
print('Pattern_2 =', "\n")
p text_seq =~ /(ATGC){2}/ #[ATGC]2JԂ... | true |
fa24ab009a225d402201c1ca276ae90bd8c8cd95 | Ruby | tyetrask/pin-retriever | /lib/pin_retriever.rb | UTF-8 | 1,698 | 3.0625 | 3 | [] | no_license | require 'cgi'
require 'fileutils'
require 'open-uri'
require 'lib/pinterest/pinterest_api_client'
class PinRetriever
def initialize(access_token, output_path, pinterest_api=PinterestAPIClient::V1)
@access_token = access_token
@pinterest_api = pinterest_api.new(@access_token)
@output_path = output_path
... | true |
620bffd8987b67fbce80eee0c280a5d95ccc71c2 | Ruby | Chitroopa/Train-system | /lib/train.rb | UTF-8 | 3,857 | 3.015625 | 3 | [] | no_license | class Train
attr_reader(:name, :id, :departure_time, :departure_location, :arrival_time, :arrival_location, :ticket_price)
def initialize(attributes)
@name = attributes.fetch(:name)
@id = attributes.fetch(:id)
@departure_time = attributes.fetch(:departure_time)
@departure_location = attributes.fetc... | true |
bb06b54273eabec08478ea957cf6e9119c414658 | Ruby | emilcecarlisa/Solar-System | /solar.rb | UTF-8 | 5,082 | 4.15625 | 4 | [] | no_license | # our customer will be able to interact with the program and
# choose which pieces of information they can see at a time,
# specifically by choosing which planet.
# sudo gem install samsouder-titlecase --source=http://gems.github.com
require 'rubygems'
require 'titlecase'
class SolarSystem
attr_accessor :planet_de... | true |
5ad4abb672008dcd0222abb9198498d5d57ec56b | Ruby | stanloo/launch-school | /intro_to_ruby/e10_final.rb | UTF-8 | 3,194 | 3.875 | 4 | [] | no_license | # Exercise 1
puts "1)"
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
arr.each { |x| p x }
puts ""
# Exercise 2
puts "2)"
arr.each { |x| p x if x > 5 }
puts ""
# Exercise 3
puts "3)"
odd = arr.select { |x| x.odd? }
p odd
puts ""
# Exercise 4
puts "4)"
arr << 11
arr.unshift(0)
p arr
puts ""
# Exercise 5
puts "5)"
arr.pop
arr... | true |
c7b5252b25fc27ec88e4b36a8240dc419bf99b31 | Ruby | sriramgunaseelan/Ruby | /Class.rb | UTF-8 | 292 | 3.890625 | 4 | [] | no_license | #class and objects
class College
attr_accessor :Name, :RollNo
def initialize
yield(self)
end
end
con = College.new do |obj|
puts("Enter your Name : ")
obj.Name = gets.chomp
puts("Enter your Roll Number : ")
obj.RollNo = gets.chomp
end
puts "The rollno of #{con.Name} is #{con.RollNo}"
| true |
ee6e69ba8e9a20f8946714a9ec278dbb96a8c59d | Ruby | theckman/rmuh | /lib/rmuh/rpt/log/parsers/unitedoperationsrpt.rb | UTF-8 | 3,021 | 2.625 | 3 | [
"MIT"
] | permissive | # -*- coding: UTF-8 -*-
require 'English'
require 'tzinfo'
require 'rmuh/rpt/log/parsers/base'
require 'rmuh/rpt/log/util/unitedoperations'
require 'rmuh/rpt/log/util/unitedoperationsrpt'
module RMuh
module RPT
module Log
module Parsers
# This is the UnitedOperations parser class. This separates t... | true |
fd30703e961e9753b839de0c58a0d56a85e1b97e | Ruby | seann1/cd_organizer_assesment | /lib/cd_organizer.rb | UTF-8 | 826 | 3.078125 | 3 | [] | no_license | class Cd_organizer
@@all_artists = []
def initialize
end
def Cd_organizer.clear
@@all_artists =[]
end
def Cd_organizer.add_cd(artist, album_name)
artist = Artist.new(artist)
album = Album.new(album_name)
artist.albums << album
@@all_artists << artist
end
def Cd_organizer.display... | true |
109fe25334c490e4dc327f0d1f651386cb2c0b98 | Ruby | hannahmalm/chicago | /lib/chicago/cli.rb | UTF-8 | 3,440 | 4.28125 | 4 | [
"MIT"
] | permissive | require 'pry'
class Chicago::CLI
#call the cli file from bin/chicago using Chicago::CLI.new.call
#Use namespacing on this Module because the CLI might be named chicago elsewhere
#.new is used to trigger the initialize method
#if you call self in a class method it will return the class - self in th... | true |
54100ae7ac9f7ef654d797bd0f2448edc6041de7 | Ruby | PersonofNote/programming-exercises | /ruby-exercises/Eulerproblems.rb | UTF-8 | 125 | 3.15625 | 3 | [] | no_license | i = 0
sums = 0
range = gets.chomp.to_i
while i < range
i+=1
if i % 3 == 0 || i % 5 == 0 then sums += i
end
end
puts sums
| true |
6c33e9435ff79c907196cbc33a13a324d2666a77 | Ruby | lycho29/cartoon-collections-ruby-cartoon-collections-000 | /cartoon_collections.rb | UTF-8 | 928 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | dwarves = ["Doc", "Dopey", "Bashful", "Grumpy"]
#this is correct
def roll_call_dwarves(dwarves)
dwarves.each_with_index do |item, index|
index += 1
puts "#{index}: #{item}"
end
end
#this is correct
planteer_calls = ["earth", "wind", "fire", "water", "heart"]
veggies = ["carrot", "cucumber", "pepper"]
frui... | true |
14ea544d3d6517d9c2daf0c9fd1919bace97637c | Ruby | HilmiAH/project_euler | /problem2.rb | UTF-8 | 363 | 4.15625 | 4 | [] | no_license | # For Fibonacci numbers less than or equal to 4 million, find the sum of the even numbers.
fibonacci_numbers = [1,2]
sum_of_even = 0
while fibonacci_numbers[-1] <= 4000000
if fibonacci_numbers[-1] % 2 == 0
sum_of_even += fibonacci_numbers[-1]
end
fibonacci_numbers << fibonacci_numbers[-1] + ... | true |
da591fe6669ba87f87198d446adb2b034404e249 | Ruby | roomorama/barefoot_api | /lib/barefoot/core_extensions.rb | UTF-8 | 519 | 2.96875 | 3 | [
"MIT"
] | permissive | module Barefoot
module CoreExtensions
def symbolize_keys(hash)
new_hash = {}
hash.each{ |key,value| new_hash[key.to_symbol] = value }
hash
end
def symbolize_keys!(hash)
hash.keys.each do |key|
hash[(key.to_sym rescue key) || key] = hash.delete(key)
end
hash
... | true |
ad93bf33886b208e22fb607d5cc6d2dd6783beb3 | Ruby | yonen/mephisto | /vendor/plugins/liquid/lib/liquid/variable.rb | UTF-8 | 1,399 | 2.578125 | 3 | [
"MIT",
"Ruby",
"BSD-2-Clause"
] | permissive | module Liquid
# Hols variables. Variables are only loaded "just in time"
# they are not evaluated as part of the render stage
class Variable
attr_accessor :filters, :name
def initialize(markup)
@markup = markup
@name = nil
@filters = []
i... | true |
785fea125b614a5feea9f25a0fc403e70c60a36b | Ruby | TU-Berlin-SNET/sdl-ng | /lib/sdl/util/documentation.rb | UTF-8 | 3,145 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | require 'active_support/inflector'
I18n.config.enforce_available_locales = true
module I18n
class MissingTranslation
module Base
alias :old_message :message unless method_defined?(:old_message)
def message
puts old_message
I18n.backend.store_translations I18n.locale, to_deep_hash({... | true |
10e3b5e298e0d5b7f34bfd7e456067cfd6e76636 | Ruby | AlyssaLemon/Ruby | /ruby_notes_arrays.rb | UTF-8 | 2,811 | 3.640625 | 4 | [] | no_license | empty_array = []
new_array = Array.new
my_array = [1, 2, 3, 4]
my_other_array = ["uno", "dos", "tres"]
yet_another_array = [1.0, "deuce", 3, true]
and_another_array = [[1.0, "deuce", 3, true], [2.0, "fast", 8, false]]
my_array = ["mary", "sybil", "edith"]
puts my_array[1]
Hash
my_hash = {"key" => "value", "another_... | true |
fbc295b5a3cc1898f5a11f9b90ccda66720d0605 | Ruby | sammy/LearnToProgram | /chapter5/exercise5.2.rb | UTF-8 | 206 | 3.640625 | 4 | [] | no_license | puts "Hey! What is your favorite number?"
fav_num = gets.chomp
better_num = fav_num.to_i + 1
puts "Have you ever considered " + better_num.to_s + " as a favorite number? Some people claim bigger is better!" | true |
d94541db5de77e3c5ca874d0be346b10e478214e | Ruby | abowler2/small_problems | /easy6/delete_vowels.rb | UTF-8 | 838 | 4.0625 | 4 | [] | no_license | =begin
Notes:
- input: array of strings
- output: array of same strings with vowels (a, e, i, o, u) removed
Example:
remove_vowels(%w(abcdefghijklmnopqrstuvwxyz)) == %w(bcdfghjklmnpqrstvwxyz)
remove_vowels(%w(green YELLOW black white)) == %w(grn YLLW blck wht)
remove_vowels(%w(ABC AEIOU XYZ)) == [... | true |
6947c29183817ed7d048ae5d660349f74660113d | Ruby | astanley74/ttt-with-ai-project-onl01-seng-pt-070620 | /lib/board.rb | UTF-8 | 1,190 | 3.90625 | 4 | [] | no_license | class Board
attr_accessor :cells
@cells = []
def reset!
self.cells = Array.new(9, " ")
end
def initialize
self.cells = Array.new(9, " ")
end
def display
puts " #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} "
puts "-----------"
puts " #{self... | true |
c4066e6c6e4f004b8fef5d0a5c9289b0e500f1f7 | Ruby | zamananjum0/spcore | /spec/transforms/dft_spec.rb | UTF-8 | 2,193 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'pry'
require 'gnuplot'
describe SPCore::DFT do
context '.forward' do
it 'should produce a freq magnitude response peak that is within 10 percent of the test freq' do
dft_size = 64
sample_rate = 400
test_freq... | true |
fd77114f9f082cbde6e29cb5968b03f50cae3a6b | Ruby | cordtsck/apcsp-lq | /quiz.rb | UTF-8 | 1,541 | 3.96875 | 4 | [] | no_license | def three_even(list)
puts "running"
(list.size - 2).times do |i|
#%2 even
if list[i]%2 == 0 && list[i +1]%2 == 0 && list[i + 2]%2 == 0
return true
end
end
return false
end
# puts three_even([2,1,3,5])#f
# puts three_even ([2,4,12,5]) #t
# puts thre... | true |
01e61901d43f0833905f8286456bfce7f7c3d61a | Ruby | sergio-bobillier/g | /spec/character_spec.rb | UTF-8 | 17,269 | 3.078125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../character'
require_relative '../party'
require_relative 'support/races'
require_relative 'support/jobs'
require_relative 'support/crystals'
RSpec.shared_context 'Default character' do
subject { described_class.new(blank_race) }
end
RSpec.shared_context 'Character ... | true |
cde6f07dc9e3cf645b583a51c9bfd737cab1f383 | Ruby | arineng/nicinfo | /lib/nicinfo/traceroute.rb | UTF-8 | 4,429 | 2.5625 | 3 | [
"ISC",
"BSD-3-Clause"
] | permissive | # Copyright (C) 2009 Original Author Unknown
# Copyright (C) 2016 American Registry for Internet Numbers
# Adopted from https://code.google.com/archive/p/rubyroute/
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# 1.... | true |
dfaabf2f0362bd28fdfed9bbb9757e5708376ff4 | Ruby | nathanluo915/phase-0 | /week-5/calculate-mode/my_solution.rb | UTF-8 | 2,828 | 4.03125 | 4 | [
"MIT"
] | permissive | # Calculate the mode Pairing Challenge
# I worked on this challenge [by myself, with: ]
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.
# 0. Pseudocode
# What is the inp... | true |
179e2db6535e75eab257fcd9fbc5452620aee010 | Ruby | grant-madden/LearningRuby | /CarDealer/ClassyCarDealer.rb | UTF-8 | 1,636 | 3.3125 | 3 | [] | no_license | require_relative 'car_model'
require_relative 'menu_helpers'
# Class Initialization
# Adds all options to option class
[['Leather Seats', 5000],
['DVD System', 1000],
['10 Speakers', 800],
['Navigation System',1400],
['CarPlay', 500],
['Android Auto', 500],
['Lane Monitoring', 2000]
].each do |... | true |
7f9ae06bdb91d1d93490cb85ba18aa0212296667 | Ruby | okl/myreplicator | /lib/service.rb | UTF-8 | 1,441 | 2.75 | 3 | [
"MIT"
] | permissive | require 'log4r'
require 'log4r/configurator'
include Log4r
class Service
# create logger named 'service.logger'
Configurator.custom_levels('DETAIL', 'DEBUG', 'INFO',
'WARN', 'ERROR', 'FATAL')
attr_reader :logger
def initialize
name = "#{self.class.name}"
@logger = Log4r:... | true |
9b1ece84685a5b19494f317ecddee318af0d8ee6 | Ruby | frogstarr78/sandbox | /ruby/spoj/fctrl2.rb | UTF-8 | 229 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
@cache = [1]
def factoral n
@cache << n * factoral(n - 1) if @cache[n].nil?
@cache[n]
end
@logic = proc do
puts factoral( gets.strip.to_i )
end
test_count = gets.strip.to_i
test_count.times &@logic
| true |
8c9f427ee693615f7c2000b67503d8e4173cd0f3 | Ruby | NikitaNaumenko/exercism | /ruby/flatten-array/flatten_array.rb | UTF-8 | 309 | 3 | 3 | [] | no_license | # frozen_string_literal: true
class FlattenArray
class << self
def flatten(array)
array.each_with_object([]) do |value, acc|
next if value.nil?
if value.is_a?(Array)
acc.concat(flatten(value))
else
acc << value
end
end
end
end
end
| true |
fbce519c9436b7fb4aefae30fcfa7be0a3058a2d | Ruby | Farhad33/Rspec_Practice | /TDD_Project/spec/array_methods_spec.rb | UTF-8 | 2,392 | 3.75 | 4 | [] | no_license | require 'rspec'
require 'array_methods.rb'
describe Array do
describe "#my_uniq" do
it "removes duplicates elements" do
expect([1,1,2,2,3,3].my_uniq).to eq([1,2,3])
end
it "does not change the order of elements" do
expect([3,3,4,1,5,5].my_uniq).to eq([3,4,1,5])
end
it "returns one ... | true |
fb00d46a1018b66b4564dca1c1a438f798109606 | Ruby | yiyi1026/projecteuler_ruby | /leetcode/78.subsets.rb | UTF-8 | 425 | 3.46875 | 3 | [] | no_license | '''
Given a set of distinct integers, nums, return all possible subsets (the power set).
Note: The solution set must not contain duplicate subsets.
For example,
If nums = [1,2,3], a solution is:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]'''
def subsets(nums)
return [[]] if nums.empty?
p... | true |
f20388fe3ab09ac77426d3bf81a9124d97ec85eb | Ruby | raphaelakpan/quotes-app | /app/models/quote.rb | UTF-8 | 454 | 2.546875 | 3 | [] | no_license | class Quote < ApplicationRecord
belongs_to :author
validates :content, presence: true, length: { minimum: 3, maximum: 1000 }
validates :author, presence: true
before_save :check_if_content_exists
private
def check_if_content_exists
quote = Quote.where("content ~* :content", content: content.strip)
... | true |
1512af275aad9cf6d662aceaf8b1f10f14d5af4a | Ruby | Kole565/RubyRush | /lesson_heritage/notepad/scripts/new_post.rb | UTF-8 | 785 | 2.828125 | 3 | [] | no_license | require_relative "../../../utils/methods.rb"
require_relative "../../../utils/winEncodeFix.rb"
lib_relative_folder = "../lib"
require_relative "#{lib_relative_folder}/postClass.rb"
require_relative "#{lib_relative_folder}/memoClass.rb"
require_relative "#{lib_relative_folder}/taskClass.rb"
require_relative "#{lib_rela... | true |
d3d521ef78ef63f6d493935a5541e5d1813e038e | Ruby | justindelatorre/rb_101 | /small_problems/easy_6/easy_6_10.rb | UTF-8 | 1,102 | 4.5625 | 5 | [] | no_license | =begin
Write a method that takes a positive integer, n, as an argument, and displays a
right triangle whose sides each have n stars. The hypotenuse of the triangle
(the diagonal side in the images below) should have one end at the lower-left of
the triangle, and the other end at the upper-right.
Inputs:
- integer, pos... | true |
74fedba5723a11ce30260b1fae85d6ff6baaca02 | Ruby | magdabm/ruby-exercises | /03_homework/01_Eratostenes_from_1.rb | UTF-8 | 720 | 4.15625 | 4 | [] | no_license | # Napisz program wyszukujący wszystkie liczby pierwsze z zadanego przedziału jako argumenty wywołania metodą Sita Eratostenesa
# $ ruby sieve_of_eratosthenes.rb 1 10
# Prime numbers: 2, 3, 5, 7
def prime_numbers(range)
ar = range.to_a
ar2 = [nil, nil] + [true] * ar.size
i = 2
while i <= Math.sqrt(ar.max)... | true |
5240f8873032cf25483e0e96d1ae71712cb14e7d | Ruby | srt32/airplane | /lib/seat.rb | UTF-8 | 318 | 2.90625 | 3 | [] | no_license | class Seat
attr_accessor :row, :letter
def position
(letter.to_s + row.to_s).to_sym
end
def type
letter_type[letter]
end
private
def letter_type
{
:A => :window,
:B => :middle,
:C => :aisle,
:D => :aisle,
:E => :middle,
:F => :window
}
end
end
| true |
56ed401fd49cd7372177a9eef4769690a8d43982 | Ruby | hemge/pit_stop_indicator_lamp | /lib/tasks/analyze.rake | UTF-8 | 1,034 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'time'
require 'zlib'
desc "show analyze result [dir=\"log/\", w=80, h=20]"
task :analyze do
w = (ENV["w"] || 80).to_i
h = (ENV["h"] || 20).to_i
dir = ENV["dir"] || "log/"
ary = []
first = last = nil
Dir.glob("log/*.log*").sort_by{|file| File.mtime(file)}.each do |file|
if file =~ /\.gz$/
... | true |
987e96c80ed90768cb6ba254e8631bd843a3eece | Ruby | koss-lebedev/advent-of-code | /2017/06/part2.rb | UTF-8 | 378 | 2.90625 | 3 | [] | no_license | memory = [2, 8, 8, 5, 4, 2, 3, 1, 5, 5, 1, 2, 15, 13, 5, 14]
cycle = 0
seen = {}
def redistribute(mem)
max = mem.max
idx = mem.index(max)
mem[idx] = 0
max.times do
idx = (idx + 1) % mem.size
mem[idx] += 1
end
end
loop do
if seen[memory]
puts cycle - seen[memory]
break
else
seen[memo... | true |
4351bc35f2523297660fdd182b641f4b8684bd84 | Ruby | Kazaera/otwarchive | /app/models/search_result.rb | UTF-8 | 1,988 | 2.640625 | 3 | [] | no_license | class SearchResult
include Enumerable
attr_reader :klass, :tire_response
def initialize(model_name, response)
@klass = model_name.classify.constantize
@tire_response = response
end
# Find results with where rather than find in order to avoid ActiveRecord::RecordNotFound
def items
if @i... | true |
441a125744e94b9f06c31815b6cab596f648097b | Ruby | mneedham/neo4j-football-stadiums | /app.rb | UTF-8 | 724 | 2.65625 | 3 | [] | no_license | require 'sinatra'
require 'neography'
require File.join(File.dirname(__FILE__), 'haversine.rb')
def neo_client
@neo ||= Neography::Rest.new
end
get '/' do
haml :index, :format => :html5
end
get '/stadiums/:lat/:long/:distance' do
lat, long, distance = params[:lat].to_f, params[:long].to_f, params[:distance].to_... | true |
ac1511001a74deb17c9c56c5a42e818372467ee0 | Ruby | markus851/eddy | /lib/definitions/elements/manual/480.version_release_industry_identifier_code.rb | UTF-8 | 12,762 | 2.5625 | 3 | [
"MIT"
] | permissive | module Eddy
module Elements
# ### Element Summary:
#
# - Id: 480
# - Name: (X12 Version) Version / Release / Industry Identifier Code
# - Type: AN (Not sure if this is AN or ID)
# - Min/Max: 1/12
# - Description: (X12 Version) Code indicating the version, release, subrelease, and industry ... | true |
88d3c913b0d220f1478b743158f5e708d4151836 | Ruby | husseinmaad/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 1,168 | 3.5625 | 4 | [] | no_license | def soccer_team
team_1 = "madrid"
team_2 = "ireland"
puts "i love soccer"
yield(team_1,team_2)
puts "i love soccer"
end
soccer_team { |team_1, team_2| puts "great to see #{team_1} vs #{team_2}" }
basketball_teams = ['lakers', 'rockets', 'jazz', 'bulls', 'cavs']
baseball_teams {
dodgers: 'los angeles',
padres... | true |
0faa13fd52827b0aeec4b11553ee1a7ae2e81932 | Ruby | zw963/rbkeymacs | /input.rb | UTF-8 | 714 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'revdev'
require 'ruinput'
include Revdev
include Ruinput
# 这是我的键盘输入设备 /dev/input/event1
input_device = EventDevice.new('/dev/input/event1')
uinput = UinputDevice.new
begin
input_device.grab
rescue IOError
puts("IOError when grabbing device.")
exit 1
else
l... | true |
73baafecfe6c351fbfea6fef2bcb8a2d6392ebd4 | Ruby | Rishat80/selenium-training-po | /ruby-example/app/application.rb | UTF-8 | 1,492 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'selenium-webdriver'
require '../pages/admin_panel_login_page'
require '../pages/customer_list_page'
require '../pages/registration_page'
class Application
def initialize
@driver = Selenium::WebDriver.for :chrome
@registration_page = RegistrationPage.new @driver
@admin_panel_login_page = AdminPan... | true |
56975f403e6780febc96816335d27127e9c6af76 | Ruby | taratatach/netexport-parser | /models/web_archive.rb | UTF-8 | 2,650 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'csv'
class WebArchive
def initialize( filename )
@filename = filename
end
def to_kb
result = data.dup
result[:jsSize] /= 1024.0
result[:cssSize] /= 1024.0
result[:imagesSize] /= 1024.0
result[:vendorSize] /= 1024.0
result[:parts].each do |p|
p[:contentSize] /= 1024.0
... | true |
da6a432bfe587aad4c63f1f694010f0ee9b899b8 | Ruby | GrayMyers/backend_mod_1_prework | /day_6/exercises/person.rb | UTF-8 | 906 | 4.21875 | 4 | [] | no_license | # Create a person class with at least 2 attributes and 2 behaviors.
# Call all person methods below the class and print results
# to the terminal that show the methods in action.
# YOUR CODE HERE
class Person
attr_reader :name, :age, :height, :status
def initialize(name,age,height,status)
@name = name
@age... | true |
b7fad03e718fad97da090f005d63cdf26a346f00 | Ruby | HolmstN/ls-ruby-more | /reduce_method.rb | UTF-8 | 200 | 3.40625 | 3 | [] | no_license | array = [1, 2, 3, 4, 5]
def reduce(array, num = 0)
counter = 0
value = num
while counter < array.size
value = yield(value, array[counter])
counter += 1
end
value
end
| true |
0ab6fb651e08a6557c8ca5195d3fecd4dcb409dc | Ruby | seung-lee-medamerica/selenium-cucumber-ruby-kickstarter | /lib/google_results_page.rb | UTF-8 | 810 | 2.609375 | 3 | [
"MIT"
] | permissive | # @author Jonathan Chrisp
class GoogleResultsPage
include DateHelper
include DirectoryHelper
attr_reader :name, :driver, :log
# Initialises GoogleSearchPage Class
#
# @param [String] name defines the name of the instance
# @param [Object] driver defines the driver instance
# @param [Object] log define... | true |
7580d392aa49feab5a270a5100340b5049c788d7 | Ruby | gangelo/string_cheese | /lib/string_cheese/raw_token.rb | UTF-8 | 303 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'token'
require_relative 'token_type'
module StringCheese
class RawToken < Token
def initialize(value, options = [])
super(:raw, value, TokenType::RAW, options)
end
def value(options = { space: :none })
super
end
end
end
| true |
0ccee258945fbccdbb3517c9b34d08028ce4bb93 | Ruby | spemmons/zhivago_mr | /frequency_counter.rb | UTF-8 | 1,456 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'wukong/script'
module FrequencyCounter
class Mapper < Wukong::Streamer::RecordStreamer
def process(*args)
location,off_count,stopped_count,moving_count,speed_min,speed_max,speed_ave,error_count,remainder = *args
yield [off_count,'off'] if off_count.to... | true |
75cbefbd1c37d88023a7af8cc8d76dbb4a5d3678 | Ruby | pre/koala-client | /lib/koala_client/external_authentication.rb | UTF-8 | 1,664 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'hpricot'
class KoalaClient::ExternalAuthentication
attr_accessor :login_type, :login_id, :name, :email, :expires_at, :auth_for
attr_accessor :login_token
def initialize(login_token)
self.login_token = login_token
authorize!
end
########################################################... | true |
8b73abddb586ae6ac482172d46db7bacef555e02 | Ruby | husteadrobert/Launch-School-Files | /Exercises/101 to 109 Exercises/Easy7.rb | UTF-8 | 3,120 | 4.1875 | 4 | [] | no_license | # Combine Two Lists
def interleave(array1, array2)
newarray = []
array1.size.times do |index|
newarray << array1[index] << array2[index]
end
newarray
end
# LS Solution
def interleave(array1, array2)
result = []
array1.each_with_index do |element, index|
result << element << array2[index]
end
r... | true |
3bd1b767a0e0b0154547542703fa4905d92fe693 | Ruby | ritmatter/Project-Euler | /euler_14.rb | UTF-8 | 1,089 | 3.828125 | 4 | [] | no_license | #!/usr/bin/ruby
=begin
Longest Collatz Sequence
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen ... | true |
656ffeea4bdcb80e8c4339d3becc8e3d6037e167 | Ruby | adam-phillipps/crawlBot | /spot_maker.rb | UTF-8 | 4,729 | 2.53125 | 3 | [] | no_license | require 'dotenv'
Dotenv.load
require 'aws-sdk'
require 'date'
require 'byebug'
require 'securerandom'
class SpotMaker
begin
def initialize
# this decides how many instances need to run and/or start. this is the denominator
# of the ratio -> backlog / wip
JOBS_RATIO_DENOMINATOR = 10
... | true |
92f1c6584986992261fde893671dc17d9013764c | Ruby | acgillette/Random-Menu | /random_menu.rb | UTF-8 | 1,710 | 3.890625 | 4 | [] | no_license | #random_menu is a program that generates random menu items
#from 1-10 items depending on the User input
adjectives = ["Paltry", "Ill", "Marvelously", "Trashy", "Habitually", "Special", "Righteous", "Impossibly", "Devilish", "Nervous"]
cooking_style = ["Seared", "Pickled", "Cured", "Boiled", "Stewed", "Fried", "Salted"... | true |
961e4d3190be4d0c16d4be3541e31f6db85f3e3b | Ruby | exlee/sbql4ruby | /lib/Common/Stack.rb | UTF-8 | 2,209 | 3.328125 | 3 | [] | no_license | module Common
class Stack
# Implements stack structure using internal array
def initialize()
@VAR_STACK = []
end
# Puts given object into the stack
#
# Params:
#
# var_Object:AbstractQueryResult - QRES model object
#
# Returns:
#
# Throws:
def push(var_... | true |
f52c7a46b954273e2a22d3e85f3d71e5bd5c3b46 | Ruby | Mattackai/RB_101 | /Exercises/small_problems_RB101-RB109/easy6_9.rb | UTF-8 | 582 | 4.21875 | 4 | [] | no_license | #Write a method named include? that takes an array and a search value as arguments.
#This method should return true if the search value is in the array, false if it is not.
#You may not use Array.include? in your solution.
#Examples:
#include?([1,2,3,4,5], 3) == true
#include?([1,2,3,4,5], 6) == false
#include?... | true |
63587875075fef6b9bbcf029a56754873e123c00 | Ruby | kmiscia/misc | /ruby/optparse_template | UTF-8 | 2,279 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse' ... | true |
5fa06ef23acaaba5855afee1d9e06e239d978f7c | Ruby | VincentSim/promo-2-challenges | /01-Ruby/02-Arrays-Enumerable/Optional-01-Roman-numerals/lib/roman_numerals.rb | UTF-8 | 1,737 | 3.5625 | 4 | [] | no_license | def old_roman_numeral(an_integer)
mille = "M"
cinq_cent = "D"
cent = "C"
cinquante = "L"
dix = "X"
cinq = "V"
un = "I"
a = an_integer / 1000
b = (an_integer % 1000) / 500
c = ((an_integer % 1000) % 500) / 100
d = (((an_integer % 1000) % 500) % 100) / 50
e = ((((an_integer % 1000) % 500) % 100) % 50... | true |
c6a7bfe96fa4919097ea89112a0aa0670991170a | Ruby | RomanSerikov/thinknetica | /lesson-09/acessors.rb | UTF-8 | 897 | 2.78125 | 3 | [] | no_license | module Acessors
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def attr_accessor_with_history(*args)
args.each do |arg|
var_name = "@#{arg}".to_sym
define_method(arg) { instance_variable_get(var_name) }
define_method("#{arg}=".to_sym) do |value|
... | true |
cb3121531ba07d7781b55e615c35f80c115101d4 | Ruby | couchrest/couchrest_extended_document | /lib/couchrest/validation/validators/method_validator.rb | UTF-8 | 3,024 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # Extracted from dm-validations 0.9.10
#
# Copyright (c) 2007 Guy van den Berg
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the right... | true |
f5f412be7a76bbdfb0ea07f3d2219c674593ac7e | Ruby | lchristopherson/mtg | /app/models/card.rb | UTF-8 | 1,276 | 2.65625 | 3 | [] | no_license | class Card < ApplicationRecord
include Comparable
RARITY_ORDER = {
CardConstants::MYTHIC => 0,
CardConstants::SPECIAL => 1,
CardConstants::BONUS => 2,
CardConstants::RARE => 3,
CardConstants::UNCOMMON => 4,
CardConstants::COMMON => 5
}
CATEGORY_ORDER = {
CardConstants... | true |
3e16ec5ac7233c8c43ea23cd1a14e07d8e84f03e | Ruby | Naoya-Ito/orehata_wiki | /app/helpers/culdcepts_helper.rb | UTF-8 | 1,288 | 2.5625 | 3 | [] | no_license | module CuldceptsHelper
def forbidden_field_text(card)
text = ""
text += "水" if card.forbidden_water?
text += "火" if card.forbidden_fire?
text += "地" if card.forbidden_forrest?
text += "風" if card.forbidden_wind?
text
end
def forbidden_item_text(card)
text = ""
text += " [[武器]] " i... | true |
b2d806aaa91d5cf68b089856a5501547dc8c1ced | Ruby | benfox1216/flash_cards | /lib/deck.rb | UTF-8 | 439 | 3.640625 | 4 | [] | no_license | class Deck
attr_reader :cards
def initialize(cards)
@cards = cards
end
def count
number_in_deck = 0
cards.each do |card|
number_in_deck += 1
end
return number_in_deck
end
def cards_in_category(given_category)
cards_in_category = []
cards.each do |card|
if given... | true |
bd3e9f679f77b6908b73d9ab9fa5aec27be2d9f4 | Ruby | artemave/conways-game-of-life | /lib/cell_generator.rb | UTF-8 | 461 | 3.21875 | 3 | [] | no_license | class CellGenerator
def self.generate cell_with_neighbours_matrix
target_cell = cell_with_neighbours_matrix[1,1]
live_neighbours_count = cell_with_neighbours_matrix.each.inject(0) do |cnt, cell|
cnt += cell.alive? ? 1 : 0
end
live_neighbours_count -= 1 if target_cell.alive?
if (target_cel... | true |
8f430882764539e4898502f524796778811ead98 | Ruby | carlsoncs/CS5950-Machine_Learning | /A2/Ruby/data_wrangler.rb | UTF-8 | 2,017 | 3.359375 | 3 | [] | no_license | require 'rubygems'
require 'csv'
class DataWrangler
@virginica=[]
@setosa=[]
@versicolor=[]
@iris_test=[]
@iris_train=[]
@iris_categories=[]
@training_iterator=["Iris-virginica", "Iris-versicolor", "Iris-setosa"]
# First Read the CSV into memory. Create three arrays.
CSV.foreach('iris_data.csv'... | true |
f734c47642e8dfda6594f53c1c688e4883f2b14d | Ruby | rubydoobydoo/meetings | /homeworks/ben/sinatra-shop-1/models/product.rb | UTF-8 | 1,322 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | class Product
#@@product_list = []
@@db_table = DB[:products]
#belongs_to :cart
attr_accessor :name, :price, :id
def initialize(name, price, discount = 0)
@id = Product.number_of_products
@name = name
@price = price *(1 - discount)
@buy_link = 'products/buy/#{self.name}'
#@@prod... | true |
ba05bb96e01f9abbc816c95dffc2f5fa72b1c592 | Ruby | Infinite-Loops-Firehose/chess | /spec/models/pawn_spec.rb | UTF-8 | 5,893 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Pawn, type: :model do
describe 'valid_move?' do
it 'should return true when moving one space forward' do
pawn = FactoryGirl.create(:pawn, x_position: 4, y_position: 2, is_white: true)
expect(pawn.valid_move?(4, 3)).to eq true
end
it 'should return true w... | true |
276c4e5e519897f482c6d138b32c6c71a3293223 | Ruby | cowannoel/all_day_pub_lab | /customer.rb | UTF-8 | 818 | 3.390625 | 3 | [] | no_license | class Customer
attr_reader(:name, :age)
def initialize(name, funds, age)
@name = name
@wallet = funds
@age = age
@drinks_bought = []
end
def get_age
return @age
end
def get_money_total
return @wallet
end
def reduce_customer_money(amount)
@wallet -= amount
end
def ge... | true |
1b42d49f795d4aab94d504aee6521826ed674e70 | Ruby | mindaslab/solid_ruby_code | /circle_better.rb | UTF-8 | 252 | 3.796875 | 4 | [] | no_license | # circle_better.rb
class Circle
attr_accessor :radius
PI = 3.14
def initialize radius
@radius = radius
end
def area
Circle::PI * radius ** 2
end
def circumference
2 * Circle::PI * radius
end
end
puts Circle.new(5).area
| true |
b3bca1df961c55b0c99f71239a0942d9b349bb83 | Ruby | TomNash/hw-acceptance-unit-test-cycle | /rottenpotatoes/features/step_definitions/movie_steps.rb | UTF-8 | 501 | 2.59375 | 3 | [] | no_license | Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
# each returned element will be a hash whose key is the table header.
# you should arrange to add that movie to the database here.
# hint: look at movies_controller#create for a hint toward the one-line solution.
... | true |
8ff89ee8d8b3bb1f927539b86f73155bb8bb9a86 | Ruby | paweljw/thirsty | /lib/thirsty/today/add.rb | UTF-8 | 901 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'date'
module Thirsty
module Today
class Add < Callable
def initialize(amount)
@amount = amount
end
def call
validate_amount
update_amount
end
private
attr_reader :amount
def validate_amount
if am... | true |
b0df8fae13a9d2450a3e167276426dc3689265ac | Ruby | batterypop/batterypop | /lib/dashboard_utility.rb | UTF-8 | 2,914 | 2.78125 | 3 | [] | no_license | module DashboardUtility
def self.users_to_census_age_array(arr, deductYears=false)
ret = Hash.new
arr.each do |user|
# ret << user.id
# targetDate = user.birthday.nil? ? 'unknown' : user.birthday.to_s
targetDate = user.birthday.nil? ? 'unknown' : (deductYears==true ? (Time.now.year - user.b... | true |
9da6a44e6857cf3582cdf486594f707e593dfdda | Ruby | franksnbeeeeans/brawndopoly | /scratch.rb | UTF-8 | 3,415 | 2.765625 | 3 | [] | no_license | require_relative 'classes/space'
require_relative 'classes/card'
require_relative 'classes/deck'
require 'json'
=begin
$spaces = []
[
{name: 'Go', number: 0, is_property: false},
{name: 'Mediterranean Avenue', number: 1, is_property: true},
{name: 'Community Chest', number: 2, is_property: false},
{name: 'Baltic Avenu... | true |
034336a7e6a8af3e9098816fa4852aca63120da0 | Ruby | marceltoben/evandrix.github.com | /defcon/drivesploit/modules/auxiliary/scanner/mysql/mysql_login.rb | UTF-8 | 3,627 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | ##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Au... | true |
e16b085a86ce7bccda0d7f0ca51565806126fe4e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/grains/ffcc99b6d113422b860a7f46249918c4.rb | UTF-8 | 203 | 3.390625 | 3 | [] | no_license | class Grains
SQUARES = (1..64)
def square(square_id)
2**(square_id - 1)
end
def total(squares = SQUARES)
squares.reduce { |subtotal, square_id| subtotal + square(square_id) }
end
end
| true |
6831e4aa814f4417141d185c24b21b885f510af8 | Ruby | mfyu/AaHw | /urlshortener/bin/cli | UTF-8 | 882 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
class CLI
def prompt_email
puts 'Enter email: '
email = gets.chomp
@current_user = User.find_by(email: email)
if @current_user.nil?
raise 'That user doesn\'t exist'
end
end
def create_url
puts 'Type long URL: '
long_u... | true |
05647adec2a0f45d619b254b8c1c036a29245804 | Ruby | oddbyte3d/RCMS | /lib/rcms/server/user/RCMSGroup.rb | UTF-8 | 502 | 3.078125 | 3 | [] | no_license |
class CuppaGroup
attr_reader :IS_ADMIN, :GROUP_NAME
def initialize(groupName, isAdmin)
@GROUP_NAME = groupName
@IS_ADMIN = isAdmin
end
def match(searchText)
if(getGroupName().downcase.index(searchText.downcase) > -1)
return true
else
return fal... | true |
f0a388ce77ec1dbfd6205bdce39eb6783fccb79e | Ruby | erezfree29/scrapper | /lib/methods.rb | UTF-8 | 3,715 | 3.21875 | 3 | [
"MIT"
] | permissive | require 'colorize'
require 'open-uri'
require 'net/http'
require 'set'
require 'csv'
require 'nokogiri'
# introduction of the Github tool
def introduction
puts 'hello welcome to the github scrapper'.light_blue
puts 'this tool is desgined for fetching data from github quickly and saving it to a csv file'.light_blue
... | true |
8e5d49ba1d97b596c5aab5b5a1adbea5986da730 | Ruby | r569594043/ProgramingRubyReadingNotes | /programing_ruby.rb | UTF-8 | 11,447 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | #! /usr/local/bin/ruby -w
#!/usr/bin/env ruby
3.times { puts "Hello!" }
"gin joint".length
"Rick".index("c")
-1942.abs
def say_goodnight(name)
result = "Good night, " + name
return result
end
puts say_goodnight("John-Boy")
puts say_goodnight("Mary-Ellen")
puts(say_goodnight("John-Boy"))
puts "Hell... | true |
b29cff55818e44926a29d22f9b3d635d1529d44a | Ruby | uharston/bf-coding-test | /app/controllers/medical_insurance_plan_controller.rb | UTF-8 | 7,808 | 2.515625 | 3 | [] | no_license | class MedicalInsurancePlanController < ApplicationController
require 'pdf/reader/html'
def home
@insurance_plan = MedicalInsurancePlan.new
end
def create
plans = params[:medical_insurance_plan]
plans.each do |k, v|
pdf = PDF::Reader.new(v.tempfile)
Me... | true |
60dbd1ac396ac8537f2814cd838987e6ce1d9eab | Ruby | charlesukpai/lamadaapp | /app/models/vendor.rb | UTF-8 | 413 | 2.5625 | 3 | [] | no_license | class Vendor < ApplicationRecord
def self.import(file)
CSV.foreach(file.path, headers: true) do |row|
Vendor.create! row.to_hash
end
end
#Adding method to our model to enable us downlaod data as csv files
def self.to_csv
CSV.generate do |csv|
csv << column_names
all.each do |ve... | true |
caba541725bdc0603eb95c66e2673b38080f815c | Ruby | colstrom/stamina | /lib/stamina-core/stamina/adl.rb | UTF-8 | 9,967 | 2.921875 | 3 | [
"MIT"
] | permissive | module Stamina
#
# Automaton Description Language module. This module provides parsing and
# printing methods for automata and samples. Documentation of the file format
# used for an automaton is given in parse_automaton; file format for samples is
# documented in parse_sample.
#
# Methods of this module ... | true |
64857217fef9cdc2c111e10e59940f368b32f5e8 | Ruby | eduardodeoh/RubyLearning | /Week5/Exercises/progExercise1.rb | UTF-8 | 578 | 3.984375 | 4 | [] | no_license | #
#Exercise1. Write a class UnpredictableString which is a sub-class of String. This sub-class should have a method called scramble() which randomly rearranges any string as follows:
#
#>ruby unpredictablestring.rb
#daano.r n sdt a htIsw taikmgy r
#>Exit code: 0
## the original string was: "It was a dark and stormy nig... | true |
5fa8c708286daa761ae4bc7d61ce07ad7eb853e6 | Ruby | chet-k/AppAcademy-Open-Work | /0-Foundations/03-RSPEC/rspec-exercise-1/chet_rspec_exercise_1/lib/part_2.rb | UTF-8 | 1,213 | 3.953125 | 4 | [] | no_license | def hipsterfy(word)
vowels = "aeiou"
i = word.length-1
while i >= 0
if vowels.include?(word[i])
break
end
i -= 1
end
return word if i == -1
word[0...i] + word[i+1..-1]
end
def vowel_counts(str)
vowels = "aeiou"
hash = Hash.new(0)
str.ea... | true |
a01d0f85cafde12ebabef2d42d88f88eb8f290ad | Ruby | kranthigit/ruby-school | /Blocks.rb | UTF-8 | 536 | 4.0625 | 4 | [] | no_license | # Iterator & Array
# each is a iterator. Iteratos are nothing but methods suppored to collections. each iterator stores the values in blocks.
# variable name between || is block. each stores the array in those blocks and puts them.
# In Rubys Arrays and Hashes are termed as Collections.
# Method1.
Books = ["Shell", "... | true |
cc148be212fe2448deb72e8d6a4042551c6298e0 | Ruby | lair001/a-most-byzantine-forum | /spec/01_models/02_forum_user_spec.rb | UTF-8 | 6,910 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'sinatra_helper'
# require 'helpers_spec_helper'
describe 'ForumUser' do
before do
@user1 = ForumUser.create(username: "test 123", email: "test123@aol.com", password: "test", moderator: false, administrator: false)
@user2 = ForumUser.create(username: "Top Gun", email: "tops@aol.com", password: "the... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.