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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c17bb962f8ede0ac3fa716b49f504485013ae2d5 | Ruby | andrewhbc/git-api | /lib/get-repos.rb | UTF-8 | 620 | 3.34375 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'json'
# The goal of this exercise is to have a working piece of code that queries the API and returns a list of repository names. You can simply print the names to screen.
# You can write this code in any language of choice.
# Upload your code to a public github repo and paste... | true |
7678961c7cf47756c9f83aaaebae1a3f04239143 | Ruby | priit/adva_cms | /engines/adva_spam/vendor/plugins/viking/lib/viking/akismet.rb | UTF-8 | 6,906 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'uri'
require 'set'
# Akismet
#
# Author:: David Czarnecki
# Copyright:: Copyright (c) 2005 - David Czarnecki
# License:: BSD
#
# Rewritten to be more agnostic
module Viking
class Akismet < Base
class << self
attr_accessor :valid_responses, :normal_responses, :standard_heade... | true |
4cad88bfa81d34fb0d610a053e687a57af643b4d | Ruby | Leozartino/PadroesDeProjeto | /Memento/memento.rb | UTF-8 | 1,534 | 3.78125 | 4 | [] | no_license | #
class Post
attr_accessor :title, :body
def initialize(title, body)
@title, @body = title, body
end
def save
PostVersion.new self
end
def rollback(version)
@title = version.title
@body = version.body
end
end
class PostVersion
attr_reader :title, :body
def initialize(post)
@t... | true |
071aeb86cc6fcbf4304cae799ba5646200e2a43c | Ruby | daichi-fumoto/dryflower | /app/models/question.rb | UTF-8 | 5,442 | 2.703125 | 3 | [] | no_license | class Question < ActiveHash::Base
self.data = [
{id: 1, text: "自分のいいところを3つ挙げてください"},
{id: 2, text: "次の文章に当てはまる言葉を考えてみて。\n「全ての人々が・・・だったらいいのになぁ」"},
{id: 3, text: "子供の頃にもらったプレゼントの中で\n特別なものは、なに?詳しく聞かせて。"},
{id: 4, text: "あなたにとって音楽とは?"},
{id: 5, text: "あなたの思う最高に贅沢なデザートとは?"},
{id: 6,... | true |
e44c2a53e7e5b969426bfaafd27daa1e392b77df | Ruby | kellyeryan/marvel | /bin/run.rb | UTF-8 | 895 | 2.765625 | 3 | [] | no_license | require "pry"
require_relative "../lib/avenger"
require_relative "../lib/movie"
require_relative "../lib/appearance"
thor = Avenger.new("Thor", "strength")
hulk = Avenger.new("Hulk", "strength")
iron_man = Avenger.new("Tony Stark", "super smart")
black_panther = Avenger.new("Black Panther", "panther powers")
ragnarok... | true |
5a5a3a00418e17cc580732384f4b15fc32397eb9 | Ruby | taillet/my-collect-prework | /lib/my_collect.rb | UTF-8 | 191 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def my_collect(array)
i = 0
narray = []
if array.size == 0
return nil
else
while i < array.size
narray << yield(array[i])
i += 1
end
narray
end
end
| true |
0627fa8e07abf4186c5e07c89b6f3dc75bd779ce | Ruby | ziptofaf/duality | /app/helpers/vpn_helper.rb | UTF-8 | 3,486 | 2.8125 | 3 | [] | no_license | require 'securerandom'
module VpnHelper
def pay(amount)
error_message and raise 'THIS MUST BE POSITIVE' unless amount>=0
flash[:error]="Insufficient funds" and raise 'Insufficient funds' if balance-amount<0
user = User.find(session[:user_id])
funds = user.balance - amount
user.update_attribute :balanc... | true |
32fcea577e8ed780700a587da27a633594a97531 | Ruby | olistik/custom_range | /lib/custom_range.rb | UTF-8 | 855 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
class CustomRange
attr_accessor :range_set
def initialize(range_set)
@range_set = range_set
end
def [](value)
EndPoint.new value, @range_set
end
end
class EndPoint
attr_accessor :index
def initialize(value, range_set)
@range_set = range_set
@index = self.send("in... | true |
27e34db50db60091fc7517686571ae27c1e93830 | Ruby | multi-io/xml-mapping | /lib/xml/xxpath.rb | UTF-8 | 3,603 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | # xxpath -- XPath implementation for Ruby, including write access
# Copyright (C) 2004-2006 Olaf Klischat
require 'rexml/document'
require 'xml/rexml_ext'
require 'xml/xxpath/steps'
module XML
class XXPathError < RuntimeError
end
# Instances of this class hold (in a pre-compiled form) an XPath
# pattern. Y... | true |
424cbcc61acf418c54c783274edabd5557081441 | Ruby | metdinov/Project-Euler | /problem3.rb | UTF-8 | 325 | 4.125 | 4 | [] | no_license | # The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
require 'prime'
def largest_factor(number)
upper_bound = number / 2
upper_bound.downto(2) do |n|
if number % n == 0 && n.prime?
return n
end
end
1
end
puts largest_factor(600851475... | true |
42b25263ea20b12fe8bfa26906a8e997fad7d788 | Ruby | XenoQueen/programming-univbasics-4-square-array-online-web-prework | /lib/square_array.rb | UTF-8 | 143 | 2.6875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
numbers = [4,16,28]
square_array(numbers)
end
new_numbers = [54,68,80,102]
square_array(new_numbers)
end | true |
8aabb6b7e9576e4df0ca58ea78b1c83d6497bbc4 | Ruby | richardrguez/exercises | /coderbyte/medium/StringScramble.rb | UTF-8 | 861 | 4.21875 | 4 | [] | no_license | # Using the Ruby language, have the function StringScramble(str1,str2) take both parameters being
# passed and return the string true if a portion ofstr1 characters can be rearranged to match str2,
# otherwise return the string false. For example: if str1 is "rkqodlw" and str2 is "world" the output
# should return t... | true |
40f22f19202298b1907fe7c89efd3968d7a47e5d | Ruby | pushplataranjan/shoes4 | /shoes-core/lib/shoes/list_box.rb | UTF-8 | 1,392 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class Shoes
class ProxyArray < SimpleDelegator
attr_accessor :gui
def initialize(array, gui)
@gui = gui
super(array)
end
def method_missing(method, *args, &block)
res = super(method, *args, &block)
gui.update_items
case res
when Pro... | true |
a33e4476be3cf3fd536f2ee5dc2d9b4f4db632c9 | Ruby | altbizney/commando | /commando-lightbox | UTF-8 | 1,953 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'commando-helpers.rb'
require 'yaml'
program :description, 'Renders LightBox projects to a frame sequence.'
program :version, '1.0.0'
def filename(id, prefix='', suffix='')
"#{prefix}#{sprintf "%05d", id}#{suffix}"
end
command :loop do |c|
c.description = 'Sorts bitmaps in <... | true |
63ba756ac23b97d4c4b88ffb3cd4a3631df67ab5 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/923e2242a3a64550a64b5c40cf73476c.rb | UTF-8 | 434 | 3.4375 | 3 | [] | no_license | class Bob
def hey some_words
@some_words = some_words
making_a_big_deal ? 'Woah, chill out!'
: dumb_question ? 'Sure.'
: cold_shoulder ? 'Fine. Be that way!'
: 'Whatever.'
end
private
def making_a_big_deal
@some_words.upcase == @some_words && @some_words.match(/[A-Z]/)
end
... | true |
82d789424d7d3fa66e6d48f020d175cb47e7de48 | Ruby | victorehrich/Desafio-Trainee-2020.2-Ruby | /calculator/menu.rb | UTF-8 | 1,235 | 3.609375 | 4 | [] | no_license | require_relative 'operations'
module Calculator
class Menu
def initialize
puts "-------------------------\n| Bem vindo a calculadora |\n-------------------------"
puts "1. Média preconceituosa"
puts "2. Calculadora sem números"
puts "3. Filtrar filmes"
puts "4. Sair"
puts "Sua opção: "
... | true |
ce9883d191757b5c5ac22d1377db63a8f34e7ef4 | Ruby | bernicetann/Two-Player-Math-Game | /main.rb | UTF-8 | 394 | 2.859375 | 3 | [] | no_license | require './player.rb'
require './math-game.rb'
require './question.rb'
game = Game.new
game.start(Player.new, Player.new)
# GAME FLOW
# put a blurb to welcome the game
# game loop(ask question, gets answer, evaluate T/F, if answer is wrong decrement
# currnt player, display blurb to current player, if curr... | true |
56e29201ba9881115b213fa5c257e9b08a632e66 | Ruby | juanjegt/flowerplants | /lib/creates_variety.rb | UTF-8 | 405 | 2.75 | 3 | [] | no_license | class CreatesVariety
def self.create(variety)
variety.save && create_product(variety)
end
private
def self.create_product(variety)
product = Product.new
product.family = variety.family
product.color = variety.color
product.variety = variety
product.name = variety.family.... | true |
ec3931a63d6637d1a8cdaeafe9cb50f964e4f3f5 | Ruby | rikkimalh/phase-0-tracks | /ruby/puppy_methods.rb | UTF-8 | 1,256 | 4.03125 | 4 | [] | no_license | class Puppy
def fetch(toy)
puts "I brought back the #{toy}!"
toy
end
def speak(integer)
i = integer.to_i
i.times do |x|
puts "Woof!"
end
end
def roll_over
puts " *rolls over*"
end
def dog_years(human_years)
n = human_years.to_i
puts dog_age = n*7
end
def jump... | true |
b97359a40a9307b19d82383fecf02d934dd2bc6e | Ruby | bhardin/bgg-tools | /app/models/game.rb | UTF-8 | 3,361 | 2.84375 | 3 | [] | no_license | require 'array'
class Game < ActiveRecord::Base
serialize :poll, Hash
has_many :users_games
has_many :users, through: :users_games
has_many :historical_prices
attr_accessor :marketplace_history
UPDATE_TIMEFRAME = 1.month
def self.primary_name(name_array)
name_array.each do |name|
return name... | true |
a6da2e0855faad4e91576862d7429815a2ef2aaa | Ruby | gentooboontoo/gentooboontoo-gphys | /lib/numru/gphys/varray.rb | UTF-8 | 29,709 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | require "numru/gphys/subsetmapping"
require "numru/gphys/attribute"
require "narray_miss"
require "numru/units"
require "numru/gphys/unumeric"
require "rational" # for VArray#sqrt
require "numru/misc"
module NumRu
=begin
=class NumRu::VArray
VArray is a Virtual Array class, in which a multi-dimensional array data... | true |
074d15ff2f86af6a2af75ecb91da3aea9855f29a | Ruby | MarhicJeromeGIT/exact_cover | /spec/exact_cover/cover_solver_spec.rb | UTF-8 | 3,175 | 2.890625 | 3 | [
"MIT"
] | permissive | require "byebug"
RSpec.describe ExactCover::CoverSolver do
subject { described_class.new(matrix) }
describe "#call" do
context "empty matrix" do
let(:matrix) do
[]
end
it "raises an error" do
expect { subject.call }.to raise_error(ExactCover::CoverSolver::InvalidMatrixSize)
... | true |
000a79e875cd67a36f89232b6c48cf4f3d0ec037 | Ruby | extended-debug/briar | /bin/briar | UTF-8 | 2,294 | 2.5625 | 3 | [
"MIT",
"Beerware"
] | permissive | #!/usr/bin/env ruby
#http://tech.natemurray.com/2007/03/ruby-shell-commands.html
require 'find'
require 'rainbow'
require 'require_relative'
require 'ansi/logger'
@log = ANSI::Logger.new(STDOUT)
require 'dotenv'
Dotenv.load
require_relative './briar_help'
require_relative './briar_resign'
require_relative './briar_i... | true |
9c7ddc3563e9e794518acd9ed6d696c45ad392fd | Ruby | wrumble/checkout-tech-test | /lib/Promotion_Rules.rb | UTF-8 | 448 | 2.859375 | 3 | [] | no_license | class Promotion_Rules
attr_accessor :list
def initialize
@list = {}
end
def add new_rule
count = list.count + 1
list[count] = new_rule
end
def delete rule_code
list.delete_if { |key| key == rule_code }
end
def update rule_code, updated_rule
list.select{ |key| list[key] = updated... | true |
fba94e38dad3c9a35dace08d705331dbd68d6a8d | Ruby | jalena-penaligon/backend_prework | /day_5/hash.rb | UTF-8 | 2,770 | 4 | 4 | [] | no_license | # create a mapping of state to abbreciation
states = {
'Oregon' => 'OR',
'Florida' => 'FL',
'California' => 'CA',
'New York' => 'NY',
'Michigan' => 'MI',
'Colorado' => 'CO',
'Arizona' => 'AZ'
}
# Create a basic set of states and some cities in them
cities = {
'CA' => 'San Francisco',
'MI' => 'Detroi... | true |
fdbdf0af8d6fe4328ad2c15ca8ab7d6bf24f0853 | Ruby | jennyjean8675309/alphabetize-in-esperanto-dc-web-100818 | /lib/alphabetize.rb | UTF-8 | 193 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
ESPERANTO_ALPHABET = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz".chars
def alphabetize(arr)
arr.sort_by do |phrase|
phrase.chars.map { |c| ESPERANTO_ALPHABET.index(c) }
end
end | true |
9bcb880d35cd3cdd3ad3f9aaf312b2af10481e67 | Ruby | asadexpert/teamflow | /src/tests/unit/MessageManager_test.rb | UTF-8 | 566 | 2.734375 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../../web/model/MessageManager.rb'
class TestMessageManager < MiniTest::Test
def setup
@mgr = MessageManager.new
end
def test_that_message_manager_returns_a_global_hash
# setup initializes $messages in global scope, so just check it exists and is empty
a... | true |
e7c460a5b9b8b9a13538b4c7329cf8f212a3d29d | Ruby | ryotarai/isucon5 | /access-log.rb | UTF-8 | 1,849 | 2.515625 | 3 | [] | no_license | #!/home/isucon/.local/ruby/bin/ruby
class Log
def initialize(h)
@h = h
end
def response_time
# unit: ms
@h['reqtime'].to_f * 1000
end
def endpoint
case [@h['method'], @h['uri']]
when ['GET', '/initialize']
'GET /initialize'
when ['GET', '/']
'GET /'
when ['GET', '/lo... | true |
4fbf0c73e938c1a91028cf182cd048e38a0d70d9 | Ruby | RyanMora/TDD-Poker | /tdd_project/lib/test_driven_development.rb | UTF-8 | 914 | 3.421875 | 3 | [] | no_license | class Array
def my_uniq
uniq = []
self.each do |el|
uniq << el unless uniq.include?(el)
end
uniq
end
def two_sum
pairs = []
(0...length).each do |i|
((i + 1)...length).each do |j|
sum = self[i] + self[j]
pairs << [ i,j] if sum == 0
end
end
pairs
... | true |
d3e4a9d2017a60a044b71ca2eadff11e4a317c9c | Ruby | sepandb/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 1,291 | 4.15625 | 4 | [] | no_license |
def starts_with_vowel(string)
string + "ay"
end
def starts_with_consonant(string)
first_letter = string[0]
beginning = string.delete(first_letter)
beginning + first_letter + "ay"
end
def starts_with_two_consonants(string)
first_letters = string[0] + string[1]
beginning = string.delete(first_letters)
beginnin... | true |
4badfcf5ca84b020f4aec5fc0440ecea8b4f3758 | Ruby | SwatiJadhav46/max-sum-and-sub-array | /specs/max_sum_and_sub_array_spec.rb | UTF-8 | 1,573 | 2.828125 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../max_sum_and_sub_array.rb'
describe "Test max suma and sub array opration class" do
describe "Check result of opration, Should return set expected sum and array of elements" do
it "Test Case 1" do
arr = [3, -5, 2, 0, 1, -3, 2, -4, 2]
sum_of_sub_array_obj... | true |
096d321041233278fb5ae9ebdb650a2fcd8c7961 | Ruby | gjanee/advent-of-code-2019 | /13.rb | UTF-8 | 6,787 | 3.8125 | 4 | [] | no_license | # --- Day 13: Care Package ---
#
# As you ponder the solitude of space and the ever-increasing
# three-hour roundtrip for messages between you and Earth, you notice
# that the Space Mail Indicator Light is blinking. To help keep you
# sane, the Elves have sent you a care package.
#
# It's a new game for the ship's arc... | true |
fa15e26d74c299986d926c742e0d09ac4bdb1087 | Ruby | rcluca/developer-exercise | /ruby/blackjack/tests/persontest.rb | UTF-8 | 4,857 | 3.296875 | 3 | [] | no_license | require 'test/unit'
require_relative 'stub_classes.rb'
require_relative '../blackjack'
require_relative '../person'
class PersonTest < Test::Unit::TestCase
def setup
@deck_stub = DeckStub.new
end
def test_given_a_player_hits_then_their_hand_size_increases_by_one
player = Blackjack.start_pl... | true |
7f5c04c90eaca7e7ee00aba3967faa290d097857 | Ruby | dmartinez09/PruebaRuby | /PruebaDiego.rb | UTF-8 | 2,414 | 3.765625 | 4 | [] | no_license | #Prueba 1 Ruby
#Menu de 4 opciones
def option
print "__________________________________"
puts "****MENU****"
puts "1) Generar archivo con promedios"
puts "2) Inasistencias totales"
puts "3) Alumnos que aprobaron"
puts "4) Salir"
print "___________________________________\n\n"
puts "Debe i... | true |
a343b3eb190afa898509a1d64385dbbf027a445e | Ruby | TonyNarisi/battleship-challenge | /view/game_messages.rb | UTF-8 | 1,409 | 3.734375 | 4 | [] | no_license | module GameMessages
def self.welcome_message
puts "Welcome to Battleship!"
puts "Here is your board:"
end
def self.illegal_placement
puts "That is an illegal placement."
end
def self.computer_chosen_coordinates
puts "The computer has chosen their ship placement. Begin game!"
end
def se... | true |
1ad845210eae339508ebc06296743e5c9f934376 | Ruby | InfernoPC/exercism-code | /ruby/high-scores/high_scores.rb | UTF-8 | 473 | 3.375 | 3 | [] | no_license | class HighScores
attr_reader :scores
def initialize(scores)
@scores = scores
end
def latest
@scores.last
end
def personal_best
@scores.max
end
def personal_top
@scores.sort.reverse[0..2]
end
def report
if self.latest == self.personal_best
"Your latest score was #{self.latest}. That's your ... | true |
5aa26697d1beb6ac7e1c4fc7e89a30f99aa7c1bb | Ruby | learn-co-students/austin-web-120919 | /mod_1/hashes-and-the-internet/app.rb | UTF-8 | 1,535 | 3.671875 | 4 | [] | no_license | require 'pry'
require 'rest-client'
require 'json'
def welcome
puts "Welcome the Book Searcher"
puts "Please enter a search term:"
end
def get_user_input
gets.chomp
end
def fetch_books(search_term)
response = RestClient.get("https://www.googleapis.com/books/v1/volumes?q=#{search_term}")
#binding.pry
JSON... | true |
af73424e9414071f0f246e0258c4fc80ca8888e5 | Ruby | apelerin/THP-S3-Jeudi-MassSendMails | /lib/app/townhalls_follower.rb | UTF-8 | 3,481 | 2.953125 | 3 | [] | no_license | require 'twitter'
require 'dotenv'
require 'pry'
require 'csv'
require 'nokogiri'
require 'open-uri'
Dotenv.load('../../.env')
class TwitterBot
attr_accessor :session_twitter, :city_names_array, :townhall_twitter_handle, :townhall_twitter_handle_via_csv
def initialize
#On initialise directement la session avec l... | true |
115eb19f12d9cfe29f78ea25e953e4c43a7158ba | Ruby | paulopatto/foot_stats | /lib/foot_stats/team.rb | UTF-8 | 1,206 | 2.578125 | 3 | [
"MIT"
] | permissive | module FootStats
class Team < Resource
attribute_accessor :source_id, :full_name, :city, :country
# Return all possible team players
#
# @return [Array]
#
def players(options = {})
Player.all(options.merge(team: source_id))
end
def self.all(options={})
championship_id = o... | true |
423f781959ecae137b656df34497860cd1e5d4e1 | Ruby | afunai/bike | /t/test_parser.rb | UTF-8 | 41,265 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: UTF-8
# Author:: Akira FUNAI
# Copyright:: Copyright (c) 2009 Akira FUNAI
require "#{::File.dirname __FILE__}/t"
class TC_Parser < Test::Unit::TestCase
def setup
end
def teardown
end
def test_scan_tokens
assert_equal(
{:tokens => ['foo', 'bar', 'baz']},
Bike::Parser.scan_t... | true |
f8eb78d4de2de8eb705fd5e4f1b5264efcf2c695 | Ruby | AaronRohrbacher/favorite_things_ruby | /lib/favorite_things_ruby.rb | UTF-8 | 973 | 3.1875 | 3 | [] | no_license | class Item
@@list = []
attr_reader :id, :rank
attr_accessor :name
def initialize(attributes)
@name = attributes.fetch(:name)
@rank = attributes.fetch(:rank)
@id = @@list.length + 1
end
def self.all()
@@list
end
def save()
@@list.push(self)
end
def self.clear()
@@list = ... | true |
e814bb96f83d5116d8ea1a933240895e4f0c28f0 | Ruby | jagregory/pact | /lib/pact/consumer/consumer_contract_builder.rb | UTF-8 | 4,248 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'uri'
require 'json/add/regexp'
require 'pact/logging'
require 'pact/consumer/mock_service_client'
require_relative 'interactions_filter'
module Pact
module Consumer
class ConsumerContractBuilder
include Pact::Logging
attr_reader :consumer_contract
def initialize(attributes)
... | true |
395dd8a3d6e461804ed1b7cd0c388d9de602e94f | Ruby | pemacy/Launch_School | /Coursework/100/109/Exercises/Easy6/cute_angles.rb | UTF-8 | 238 | 3.265625 | 3 | [] | no_license | DEGREE = "\xC2\xB0"
def dms(num)
decimal = num - num.truncate
minutes = (decimal * 60).abs
seconds = ((minutes - minutes.truncate) * 60).round
"%(#{num.truncate}#{DEGREE}#{minutes.truncate}'#{seconds}\")"
end
puts dms(-123.234)
| true |
ccea591045c4d2cb1193223dcd74a87cced60392 | Ruby | saravanan121533/cc-web-boot | /day_1/assign/10_does_it_include_c.rb | UTF-8 | 364 | 4.5625 | 5 | [] | no_license | # Write a code that takes user's input and then prints out "Yes it has C"
# if entered input contains the letter "C" (upper or lower case).
# And it prints "There is no C" if it doesn't
puts "Enter value to check for letter C: "
input = gets.chomp.strip.downcase
c_count = input.count("c")
if c_count > 0
puts "Yes ... | true |
7f23e84299ad9b1f75c944bc69d6940e1850a72c | Ruby | Wyattwicks/home | /lib/building.rb | UTF-8 | 1,137 | 3.328125 | 3 | [] | no_license | require './lib/building'
require './lib/apartment'
require './lib/renter'
class Building
attr_reader :units, :renters, :bedrooms, :number
def initialize
@units = []
end
def add_unit(unit)
@units << unit
end
def renters
@renters = []
@units.find_all do |unit|
@renters << unit.ren... | true |
1c0817b6c6aced952764c6694632b31972f05f9a | Ruby | lymanwong/Ruby-Stuff | /learn_ruby/00_hello/adder.rb | UTF-8 | 109 | 3.296875 | 3 | [
"MIT"
] | permissive | total = 0
loop do
p "Enter a number"
num = gets.strip
total += num.to_i
p "Total: " + total.to_s
end
| true |
a2293e477e452092d3658a705f926d4be583f97f | Ruby | ethunk/phase10 | /meetups-in-space/app/models/meetup.rb | UTF-8 | 917 | 2.5625 | 3 | [] | no_license | class Meetup < ActiveRecord::Base
has_many :attendees
has_many :users, through: :attendees
validates :name, :location, :description, presence: true
def creator
meetup_id = self.id
user_id = Attendee.where('meetup_id = ? AND creator = true ', meetup_id)[0].user_id
return User.where('users.id = ?', u... | true |
b30abff409f940ed71e9e5d580f64844b8ac987d | Ruby | abstraktor/racket-port_scanner | /syn_scan.rb | UTF-8 | 2,291 | 2.953125 | 3 | [] | no_license | require 'monitor'
require 'pcaprub'
require 'racket'
ERR_NEED_ROOT = "Execute me as root! I need to bypass your operating systems network stack!\nYou might want to do: \n\trvmsudo %s %s" %[$0, $*.join(" ")]
#this is a threadsafe, stealth syn-scan
class SynScan < Monitor
# lets bypass the os network stack and build... | true |
eb77cd5260916931135c1ad3ce763d890ba5b89c | Ruby | orenyomtov/ironbee | /fast/suggest.rb | UTF-8 | 3,921 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# Suggest fast modifiers for rules.
#
# This script should be given an IronBee rules file on standard in. It will
# search for @rx or @dfa operators in those rules and analyize the regular
# expressions for appropriate fast patterns. The rule file, plus annotation
# comments, will be emitted to s... | true |
571fc05c419de0cf0e8a4d79b65d1f73818c8ca4 | Ruby | petertseng/exercism-problem-specifications | /exercises/palindrome-products/verify.rb | UTF-8 | 1,856 | 3.34375 | 3 | [
"MIT"
] | permissive | require 'json'
require_relative '../../verify'
json = JSON.parse(File.read(File.join(__dir__, 'canonical-data.json')))
cases = by_property(json['cases'], %w(smallest largest))
# We can't actually get fancy here; searching by diagonal doesn't work.
# https://codereview.stackexchange.com/questions/63304/finding-palind... | true |
d3ac3c61a40b2582000510045deb9168cc4e8221 | Ruby | ThomasMcP/week_02_day_2_lab | /bus.rb | UTF-8 | 441 | 3.9375 | 4 | [] | no_license | class Bus
attr_reader :route_number, :destination, :passengers
def initialize(route_number, destination)
@route_number = route_number
@destination = destination
@passengers = []
end
def drive()
return "Brum brum"
end
def pick_up(passenger)
@passengers << passenger
end
def drop_o... | true |
c3e27790df63c82e8437455413112048cb81c19e | Ruby | kirweekend/I704_Ruby | /project/game.rb | UTF-8 | 3,214 | 2.984375 | 3 | [] | no_license | require 'gosu'
require_relative 'player'
require_relative 'bomb'
require_relative 'bullet'
require_relative 'explosion'
module Game
class Space < Gosu::Window
attr_reader :score
WIDTH = 960
HEIGHT = 720
PLAYER_WIDTH = 480
PLAYER_HEIGHT = 360
BOMB_FREQUENCY = 0.03
def initialize
supe... | true |
d5c8008ce9dde164a256a45c3029642a5632c0ee | Ruby | yuihyama/funcrock | /examples/primefactors_example.rb | UTF-8 | 718 | 3.75 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require './lib/primefactors'
p primefactors(20) # => [2, 5]
puts primefactors(20)
# =>
# 2
# 5
print primefactors(20), "\n" # => [2, 5]
p primefactors(1) # => []
p primefactors(-20) # => [2, 5]
# p primefactors(0) # => ZeroDivisionError
puts primefactors(1) # => (nil)
puts
(1..45).each { |n... | true |
3470ba9e50bb7d7572a179078dc85a1e47a5fcef | Ruby | JoelQ/game-of-life | /spec/terminal_spec.rb | UTF-8 | 598 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
describe "Terminal" do
before(:each) do
@terminal = Terminal.new
end
# it "should convert the world.cells 2d array into an array of lines" do
# @terminal.world = World.new(4,3)
# @terminal.output_world
# @terminal.two_d_to_string.should == [" "*4, " "*4, " "*4]
# end
#
... | true |
21534ee68a81972e6c9b038859f872857eda9c95 | Ruby | mmcnickle-float/aoc2020 | /day4/test_passport_file.rb | UTF-8 | 2,294 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require 'minitest/spec'
require_relative 'passport_file'
require_relative 'fields'
describe PassportFile do
describe '#passports' do
it 'returns a list of passports' do
passport_filedata = <<~PASSPORT_FILEDATA
ecl:gry pid:860033327 eyr:2020... | true |
e4ea6d5b6f86568831df55a27f522c7e2b22e9c6 | Ruby | CardozoIgnacio/Ruby_Tp | /Tp8/ej_04.rb | UTF-8 | 782 | 3.375 | 3 | [] | no_license | puts "Para cada registro del archivo creado en el punto1, solicite
el ingreso del suelod de cada persona y guarde esa dupla (nombre+sueldo)
eb yb byevi archivo.(El dato sueldo debe estar formateado a un tamaño gual para todos los registros)"
def formatera_sueldo(sueldo,cant)
while (cant!=sueldo.size())
... | true |
c42e3c5ed2078ec42345e545e4cc531a9c720477 | Ruby | Aviory/Dark_Library | /src/entities/book.rb | UTF-8 | 411 | 3.265625 | 3 | [
"MIT"
] | permissive | require_relative "../entities/author"
class Book
attr_reader :author, :title
def initialize(title, author)
if !title.is_a?(String) or title.size == nil or author.is_a?(Author)
begin
raise CustomError.new("Invalid argument")
rescue => e
puts e.msg
end
else
@title = t... | true |
db3202f8a1f85743fdb6b8a6d6322d030d705292 | Ruby | atsumori/sp_authentication | /lib/sp_authentication/generator.rb | UTF-8 | 1,391 | 2.828125 | 3 | [
"MIT"
] | permissive |
module SpAuthentication
class Generator
class << self
# signatureを生成する
# 処理概要
# 1. httpリクエストメソッド、url、キーでアルファベット順にソートしたリクエストパラメータの順番で&で連結し、rfc3986形式でurlエンコーディングを行います
# 2. 1で生成した文字列をシークレットキーを使ってhmacsha1 アルゴリズムでhash値を生成します
# 3. 2で生成したhash値をbase64エンコードします
def create_signature(meth... | true |
22f53efa7cf542ac90073421d3b37af1fbe9fe4b | Ruby | danicortesloba/E6CP1A1 | /3 ciclos anidados/ejercicio3.rb | UTF-8 | 437 | 3.90625 | 4 | [] | no_license | # Construir un programa que permita ingresar un número por teclado e imprimir
# la tabla de multiplicar del número ingresado. Debe repetir la operación hasta
# que se ingrese un 0 (cero).
# Ingrese un número (0 para salir): _
puts "Ingrese un número (0 para salir)"
num = gets.chomp.to_i
while num != 0
for i in 1..10... | true |
3a9d8eb4d47c733cbbc5c850b3dba3370677d446 | Ruby | BrennanFulmer/ttt-game-status-bootcamp-prep-000 | /lib/game_status.rb | UTF-8 | 856 | 3.78125 | 4 | [] | no_license | # Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,4,8],
[2,4,6],
[0,3,6],
[1,4,7],
[2,5,8]
]
def won?(board)
result = false
WIN_COMBINATIONS.each do |set|
if board[set[0]] == "X" &... | true |
e3b0f5f3150d0470f8458e584920af3c8def6f17 | Ruby | thekatainthehat/thekatainthehat-sessions | /110401_miniXPDayBenelux/acceptance_tests.rb | UTF-8 | 306 | 2.71875 | 3 | [] | no_license | require "test/unit"
class AcceptanceTests < Test::Unit::TestCase;def test_making_money; beret = Beret.new 4; rabbit = SomethingThatMoves.new; beret.please_be_at 3, 15; rabbit.please_be_at 4, 14; assert_equal 0.€, beret.money; rabbit.would_you_please_fall_down; assert_equal 1.€, beret.money; end ;end; | true |
a9eb58e194c72d67ff0c497a9cb61380aab97bbe | Ruby | carpetofgreenness/food4u | /lib/stilltasty.rb | UTF-8 | 872 | 3.125 | 3 | [] | no_license | class StillTasty
require "net/http"
require "json"
def self.search(food)
food = food.tr(" ", "&").tr("—", "-")
p food
uri = URI("https://shelf-life-api.herokuapp.com/search?q=#{food}")
response = Net::HTTP.get(uri)
json = JSON.parse(response)
result = json[0]["id"]
uri2 = URI("https://shelf-li... | true |
39f7cd607860f154dd723f11086763cb4f28167c | Ruby | luis-novoa/desafio-back-end | /app/services/input_formatter.rb | UTF-8 | 1,341 | 3.21875 | 3 | [] | no_license | class InputFormatter
def initialize(string)
@string = string
end
def extract_infos
@string = @string.split('')
transaction_type = @string.shift.to_i
date = @string.slice!(0, 8).join('')
value = @string.slice!(0, 10)
cpf = @string.slice!(0, 11)
credit_card = @string.slice!(0, 12).join(... | true |
06cadb1661f1bc8c6238dd8a47fe823b81f1756e | Ruby | ben7x7/bebessiere | /db/seeds.rb | UTF-8 | 1,875 | 2.703125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
1e0e8e4d168061218134f4ce623c700ebfdf47fd | Ruby | sigvei/pgn2tex | /lib/pgn2tex/texable.rb | UTF-8 | 1,103 | 2.9375 | 3 | [
"MIT"
] | permissive | require "erb"
module Pgn2tex
module Texable
# Converts the object to LaTeX, by running an ERB template. Templates
# need to be put in lib/pgn2tex/templates/, and be named <Class>.tex.erb, where
# Class is the name of the class the Texable module is included in.
#
# Note that this method will lik... | true |
5f4d5621f80033b90311d2380f97e834db0d8572 | Ruby | Jeremy-Barrass/learn_to_program | /ch13-creating-new-classes/extend_built_in_classes.rb | UTF-8 | 826 | 4.28125 | 4 | [] | no_license | class Integer
# your code here
def factorial
if self < 0
return 'You can\'t take the factorial of a negative number!'
end
if self <= 1
1
else
self * (self-1).factorial
end
end
def to_roman
# your code here
numerals = Hash.new
numerals[1] = "I"
numerals[5] = "V"
numerals[10] = "X... | true |
14e416495aa29f34d19137cf20ccd9337d0ee5fc | Ruby | iangreenleaf/rrrex | /lib/rrrex/match.rb | UTF-8 | 826 | 2.765625 | 3 | [
"MIT"
] | permissive | module Rrrex
class Match
end
end
require 'rrrex/regexp'
require 'rrrex/string_match'
require 'rrrex/range_match'
require 'rrrex/or_match'
require 'rrrex/concat_match'
require 'rrrex/not_match'
module Rrrex
class Match
def self.convert( atom )
if atom.kind_of? Match
atom
elsif atom.kind_of?... | true |
77fc1271c9e5a5480fa330f482811ba1d137a18c | Ruby | atd/google_scholar | /lib/google_scholar/article.rb | UTF-8 | 754 | 2.671875 | 3 | [] | no_license | module GoogleScholar
class Article
class << self
include ActiveSupport::Memoizable
end
attr_reader :doc
def initialize(doc)
@doc = doc
end
def title
doc.css("h3").text
end
def link
doc.css('h3 a').first['href']
end
def details
doc.css('.gs... | true |
bd668df65ba98b5b647de48c832c775e18290e0e | Ruby | MattSHeil/Iron_Hack | /week_3/exercise/ratings_imdb/app.rb | UTF-8 | 97 | 2.625 | 3 | [] | no_license | require('imdb')
trek_search = Imdb::Search.new('Star Trek')
movies = trek_search.new
p movies
| true |
10876f0bd8295b13ec015a3a2ffe7619eb7aa8f6 | Ruby | leduc81/hipme | /app/models/outfit.rb | UTF-8 | 1,471 | 2.625 | 3 | [] | no_license | class Outfit < ActiveRecord::Base
attr_accessor :address
belongs_to :user
has_many :bookings
has_attached_file :picture,
styles: { large: "800x800>", medium: "300x300>", thumb: "100x100>" }
validates_attachment_content_type :picture,
content_type: /\Aimage\/.*\z/
ALL_STYLES = [ "Urban", "Hipster", "... | true |
a47e90eed797ed808468757199fef4f506483b3c | Ruby | ballman/hoops | /lib/fox_game_fetcher.rb | UTF-8 | 978 | 2.5625 | 3 | [] | no_license | require 'net/http'
class FoxGameFetcher < GameFetcher
URL = 'msn.foxsports.com'
def get_game_list_html(game_date, url, conference_id='all')
conference_id ||= 'all'
path = '/collegebasketball/scores?scheduleDayCode=' + game_date.strftime("%Y-%m-%d") +
'&conference=' + conference_id.to_s
Net::HTTP.s... | true |
66a906af05637d59e283f8f7af8bd6a7f0f23b73 | Ruby | Finble/learn_to_program | /ch09-writing-your-own-methods/roman_numerals.rb | UTF-8 | 909 | 3.40625 | 3 | [] | no_license |
def roman_numeral (num)
thous = (num/1000)
hunds = (num % 1000/100)
tens = (num % 100/10)
ones = (num % 10)
roman = 'M' * thous
if hunds == 9
roman = roman + 'CM'
elsif hunds == 4
roman = roman + 'CD'
else
roman = roman + 'D' * (num % 1000/500)
roman = roman + 'C' * (num % 500/100)
end
if tens ... | true |
c14d91daf79c5441a52d1328ad6b3eaee1d39cfa | Ruby | lucasjct/Ruby-Brief-Introdution | /basico/estruturaCondicional.rb | UTF-8 | 480 | 4.0625 | 4 | [] | no_license | puts "Digite o numero 1 ou 2"
value = gets.to_i
=begin
if value == 1
puts "valor é igual a 1"
elsif value == 2
puts "valor é igual a 2"
else
puts "valor não é igual a 1"
end
=end
#Estrututa unless - executa o código se a condicional for falsa
#unless value == 2
# puts "condição falsa"
#else
# ... | true |
0b294b0522b794e5a315d3c77dc2b0ce375a86a5 | Ruby | rwatari/minesweeper | /game.rb | UTF-8 | 1,182 | 3.578125 | 4 | [] | no_license | require_relative "board"
require_relative "tile"
require 'byebug'
require 'yaml'
class Game
def self.load(filename)
saved_state = File.read(filename)
Game.new(YAML::load(saved_state))
end
def initialize(board)
@board = board
@game_over = false
end
def parse_pos(string)
string.scan(/\d/... | true |
d906bc6d32ca199245664e4d0b991ab5bd656559 | Ruby | foodini/bash_environment | /projecteuler/0057.rb | UTF-8 | 275 | 3.453125 | 3 | [] | no_license | def digits(i)
count=0
while i>0
count+=1
i/=10
end
count
end
num = 1
den = 1
count = 0
1000.times do
num += den
tmp = num
num = den
den = tmp
num += den
if digits(num) > digits(den) then count += 1 end
end
puts count
| true |
ceb80dcb7144313bdac9af046836328644df895d | Ruby | dkitchenerable/code-teasers | /tests/arrays/max_profit_test.rb | UTF-8 | 636 | 3.109375 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../../arrays/max_profit.rb'
class TestMaxProfit < MiniTest::Unit::TestCase
def setup
@result = [1,6,5]
end
def test_minimum
assert_equal(@result, max_profit([1,6]))
end
def test_left_end
assert_equal(@result, max_profit([1,6,1,4,3,5]))
end
def t... | true |
c04af354b3905ce760ba3957470d32e115dc0bbc | Ruby | Kento75/ruby-example | /sec3-2/next_loop.rb | UTF-8 | 253 | 2.796875 | 3 | [
"MIT"
] | permissive | languages = %w(Perl Python Ruby Smalltalk JavaScript)
languages.each do |language|
puts language
next unless language == 'Ruby' # next は多言語の continue
puts 'I found Ruby!!!!' # nextの条件にマッチしなかった場合出力
end | true |
589629f47eeabfc5272489d8908621a7500514b7 | Ruby | Sun5hine/reverse-each-word-ruby-cartoon-collections-000 | /reverse_each_word.rb | UTF-8 | 91 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
string.split(" ").collect {|x| x.reverse}.join(" ")
end
| true |
bebdfb8fe3aa59447f0a67b58921c31a6e02d2cd | Ruby | HirenBhalani/My-Pro | /27.rb | UTF-8 | 445 | 3.5625 | 4 | [] | no_license | people = 20
cats =30
dogs = 15
if people < cats
puts "Too many cats! The world is doomed"
end
if people>cats
puts "Not many cats! The world is saved"
end
if people<dogs
puts "THe world is drooled on!"
end
if people>dogs
puts "The world is dry!"
end
dogs+=5
if people>=dogs
puts "People are greter then or equa... | true |
011247bdac8f29625c856c56d9a2a49c8394601c | Ruby | curufinwe/open_bridge | /client/lib/gui/beam.rb | UTF-8 | 412 | 2.859375 | 3 | [] | no_license | class Beam
def initialize(game, from_pos, to_pos, color)
@from = from_pos
@to = to_pos
@color = color
@game = game
@graphics = game.add.graphics(0,0)
draw!
after 0.2.seconds do
@graphics.destroy
end
end
def draw!
@graphics.clear
@graphics.lineStyle(1, @color , 2)
... | true |
2c3716f0f292936347c81c6e97ed35776c0fc82c | Ruby | amsmyth1/yardsourcing-engine | /spec/requests/api/v1/yard_search_spec.rb | UTF-8 | 6,016 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe "Yard Search" do
describe "Happy Path" do
it "returns yard records that match the zipcode criteria" do
yard_1 = create(:yard, zipcode: '19125')
yard_2 = create(:yard, zipcode: '19125')
yard_3 = create(:yard, zipcode: '19125')
yard_4 = create(:yard, zi... | true |
583727f3065f6167f35af0112162b787601bc408 | Ruby | JoshCheek/project-euler | /079.rb | UTF-8 | 275 | 3.484375 | 3 | [] | no_license | # https://projecteuler.net/problem=65
E = [2]
1.upto(100) { |k| E << 1 << 2*k << 1 }
def e(n)
return E[0].to_r if n < 1
E[0] + 1r/e2(1, n)
end
def e2(crnt, stop)
return E[crnt] if crnt == stop
E[crnt] + 1r/e2(crnt+1, stop)
end
e(99).numerator.digits.sum # => 272
| true |
ad1087b98568d525f075ce32c20d3402c9aa7a3c | Ruby | Stearnzy/final_ic_2008 | /lib/pantry.rb | UTF-8 | 575 | 3.53125 | 4 | [] | no_license | class Pantry
attr_reader :stock
def initialize
@stock = Hash.new(0)
end
def stock_check(ingredient)
@stock[ingredient]
end
def restock(ingredient, quantity)
@stock[ingredient] += quantity
end
def enough_ingredients_for?(recipe)
ing_list_complete =recipe.ingredients.map do |ing|
... | true |
0d1199619dbbf4e3b5fcc4622cd295d2323c13c9 | Ruby | Chanson9892/oo-tic-tac-toe-ruby-intro-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,673 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class TicTacToe
def initialize(board = nil)
@board = board || Array.new(9, " ")
end
def display_board
puts " #{@board[0]} | #{@board[1]} | #{@board[2]} "
puts "-----------"
puts " #{@board[3]} | #{@board[4]} | #{@board[5]} "
puts "-----------"
puts " #{@board[6]} | #{@board[7]} | #{@board[8]} "
end
... | true |
17b20701d5097c0298d22c6c331778173af4490d | Ruby | 5t111111/racc-example-hs | /hs.rb | UTF-8 | 356 | 3.015625 | 3 | [] | no_license | class HS
def initialize(receiver:, method:, args:)
@receiver = receiver
@method = method
@args = args
def @receiver.method_missing(method, args)
case method
when :elem
p args.include?(self.to_i)
else
raise NoMethodError
end
end
end
def call
@receiv... | true |
f97a49cdc1ce53178c20e5d8e730cc6ce3cedef9 | Ruby | francoisdevlin/config-expressions | /config-expression | UTF-8 | 3,471 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'json'
require 'optparse'
require_relative 'ruby/lib/matchers'
require_relative 'ruby/lib/functions'
command = ARGV[0]
available_commands = ["lookup","explain"].sort
unless available_commands.include? command
print "'#{command}' is not a valid command, it must be one of:\n"
available_com... | true |
c94fe3166a1b54a081684902c4e60d859632e410 | Ruby | PhilippePerret/WriterToolbox2 | /__SITE__/unanunscript/page_cours/main.rb | UTF-8 | 3,560 | 2.59375 | 3 | [] | no_license | # encoding: utf-8
# Seul un auteur du programme ou un administrateur peut passer par ici
#
user.unanunscript? || user.admin? || raise('Section interdite.')
#
# Pour l'affichage d'une page de cours du programme UN AN UN SCRIPT.
# Noter que c'est presque le même module que pour la collection Narration
#
class Unan
cl... | true |
26d9523aeb9412205ed293b473b15ab1289deba0 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/a0e681f94b4d4f879ef99f52da9816e2.rb | UTF-8 | 1,787 | 3.421875 | 3 | [] | no_license | class Bob
# Public API, method under test.
def hey( input )
interaction = interaction_for( clean( input ) )
interaction.response
end
# Internal - return the interaction class for the given input
def interaction_for( input )
interactions.find{ |k| k.handles?( input ) }
end
# Internal - The ... | true |
cfebe37feec11111686d04ba572d38a4fbe09a6c | Ruby | sharath666/wd-june | /ruby/array_search.rb | UTF-8 | 464 | 4.03125 | 4 | [] | no_license | numbers = []
puts "enter 5 numbers"
5.times do
n = gets.to_i
numbers.push(n)
#numbers.push(gets.to_i)
end
puts "Input : #{numbers}"
puts "Enter the number to be searched"
search_number=gets.to_i
count=0
#1st approach
numbers.each do |num|
if num == search_number
count +=1
end
end
#2nd approach
count = numb... | true |
f6f2ce076023ef6f5b8a87605f3a2db066c30e37 | Ruby | bethsecor/ruby-exercisms | /pangram/pangram.rb | UTF-8 | 296 | 3.28125 | 3 | [] | no_license | class Pangram
VERSION = 1
def self.is_pangram?(string)
alphabet = "abcdefghijklmnopqrstuvwxyz".chars
string_lower = string.downcase
letter_count = 0
alphabet.each do |letter|
letter_count += 1 if string_lower.include?(letter)
end
letter_count == 26
end
end
| true |
43965b05ca4ab8ff4d472e01e0d90b0cb180b1e2 | Ruby | adarsh-rai/rails-adv-training | /app/helpers/format_helper.rb | UTF-8 | 352 | 2.53125 | 3 | [] | no_license | module FormatHelper
def custom_format name='Guest'
"Hello #{name}"
end
def custom_class alert_type = 'success'
return "alert alert-success" if alert_type == 'success'
return "alert alert-danger" if alert_type == 'alert'
return "alert alert-warning" if alert_type == 'warning'
return "alert alert-info" if... | true |
b82f06b2a2ad2bcd37ce1218d74481d47455489a | Ruby | kkornafel82/blocipedia | /db/seeds.rb | UTF-8 | 1,595 | 2.78125 | 3 | [] | no_license | require 'faker'
1.times do
user = User.new(
name: "member1",
email: "member1@example.com",
password: "helloworld",
role: "standard"
)
user.skip_confirmation!
user.save!
end
1.times do
user = User.new(
name: "member2",
email: "member2@example.com",
password: "helloworl... | true |
4abcf3bc80a140a2ce36757ac596d87e34cea74d | Ruby | LilianaEverett/w04_Ruby_Project_Vet_Management | /models/vet.rb | UTF-8 | 1,609 | 3.234375 | 3 | [] | no_license | require_relative( '../db/sql_runner' )
require_relative('./patient')
class Vet
attr_reader :id
attr_accessor :first_name, :last_name
def initialize( options )
@id = options['id'].to_i if options['id']
@first_name = options['first_name']
@last_name = options['last_name']
end
def save()
sql ... | true |
f04f3f018579b02d21ab51e14f31bb0095a2d221 | Ruby | samuelwford/adventofcode | /2020/12/p2.rb | UTF-8 | 1,415 | 3.453125 | 3 | [] | no_license | #!/usr/bin/ruby -w
file = "input.txt"
input = File.readlines(ARGV[0] || File.join(File.dirname(__FILE__), file), chomp: true)
x, y, wx, wy = 0, 0, 10, 1
ds = ['east', 'south', 'west', 'north']
input.each do |i|
puts "ship at (#{x}, #{y}), waypoint at (#{wx}, #{wy}), instruction #{i}"
c, v = i[0], i[1..].to_i
... | true |
ef5ea6bccb6a79116a1b5451f5e41e92c2323454 | Ruby | nwtgck/ruby_js_obj | /lib/js_obj.rb | UTF-8 | 249 | 2.53125 | 3 | [
"MIT"
] | permissive | require "js_obj/version"
class Hash
def method_missing name, value=nil
if name.match(/=$/)
self[name[0..-2].intern] = value
elsif !name.nil?
key?(name) ? self[name] : key?(name.to_s) ? self[name.to_s] : nil
else
super
end
end
end | true |
444c008eee51ce2d27c9088010ba7fb9a034574b | Ruby | xxheronxx/conference-root | /app/models/admin.rb | UTF-8 | 1,375 | 2.546875 | 3 | [] | no_license | require 'digest/sha2'
class Admin < ActiveRecord::Base
attr_reader :password
ENCRYPT = Digest::SHA256
has_many :sessions, :dependent => :destroy
validates_uniqueness_of :name, :message => "is already in use by another admin"
validates_format_of :name, :with => /^([a-z0-9_]{2,16})$/i,
... | true |
065123272d85b8f5f0a726b8424305555bdddbb7 | Ruby | SamanAtashi/Enumerables_Ruby_Project | /enumerables.rb | UTF-8 | 4,569 | 2.953125 | 3 | [] | no_license | # rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/ModuleLength
# rubocop:disable Metrics/BlockNesting
# rubocop:disable Lint/DuplicateBranch
# rubocop:disable Lint/ToEnumArguments
module Enumerable
def my_each
... | true |
910f222a9523db993242c85a741a723048b94f0f | Ruby | shageman/component-based-rails-applications-book | /docker/geminabox/gems/trueskill-e404f45af5b3/spec/saulabs/gauss/distribution_spec.rb | UTF-8 | 5,717 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- encoding : utf-8 -*-
require File.expand_path('spec/spec_helper.rb')
describe Gauss::Distribution, "#initialize" do
it "should set the mean to 10.1" do
Gauss::Distribution.new(10.1, 0.4).mean.should == 10.1
end
it "should set the deviation to 0.4" do
Gauss::Distribution.new(10.1, 0.4).deviation... | true |
6e68d405fc596e3dcc448ab626500c9cd108dd32 | Ruby | haider-sheikh/assignment | /calender.rb | UTF-8 | 6,793 | 3.828125 | 4 | [] | no_license | require_relative 'event'
class Calender
attr_reader :hash
def initialize
@hash = {}
end
def display_portal
loop do
puts "\n\t\t****Welcome to Calendar****"
puts "\t\t 1. Add New Event"
puts "\t\t 2. Remove Event"
puts "\t\t 3. Edit Event"
puts "\t\t 4. Print Month View"
... | true |
9b966ae936c7be9e98f3e1afbeb6861d2319cc0d | Ruby | rcuhljr/rosalind | /rosalind_distance_matrix.rb | UTF-8 | 656 | 3.109375 | 3 | [
"MIT"
] | permissive | load 'fasta.rb'
load 'dna.rb'
fasta = FASTA.new()
fasrecs = fasta.load_file "dist_matrix.fas"
def p_distance(start, target)
DNA.new(start).hamming_distance(target).to_f/target.size
end
File.open('results.txt', "w") do |output|
samples = fasrecs.values
sample_size = samples.size
half_matrix = {}
samples... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.