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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
51f9db0cdf66febfc92a929500b374380d238612 | Ruby | samuelwford/adventofcode | /2020/01/p1.rb | UTF-8 | 343 | 3.046875 | 3 | [] | no_license | #!/usr/bin/ruby -w
numbers = File.readlines(ARGV[0] || File.join(File.dirname(__FILE__), "input.txt"))
i = 0
while i < numbers.length - 1
n = numbers[i].to_i
j = i + 1
while j < numbers.length
m = numbers[j].to_i
if n + m == 2020
puts "#{n} + #{m} = #{n + m}, #{n} * #{m} = #{n * m}"
end
j ... | true |
77f27844f855ff404bdc2cb5586fbab8975bc5c7 | Ruby | raycast/script-commands | /commands/dashboard/youtube-statistics.template.rb | UTF-8 | 1,485 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title YouTube Statistics
# @raycast.mode inline
# @raycast.refreshTime 1h
# Optional parameters:
# @raycast.packageName YouTube Statistics
# @raycast.icon images/youtube.png
# Documentation:
# @raycast.description Shows YouTube Subscrib... | true |
647d8a026213b576a10e3ae28fafdfbb70edff24 | Ruby | MitulMistry/sinatra-nested-forms-lab-superheros-v-000 | /app/controllers/application_controller.rb | UTF-8 | 529 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'sinatra/base'
require_relative '../models/hero.rb'
require_relative '../models/team.rb'
class App < Sinatra::Base
set :views, Proc.new { File.join(root, "../views/") }
get '/' do
erb :super_hero
end
post '/teams' do
@team = Team.new(name: params[:team][:name], motto: params[:team][:motto])
... | true |
a6655ec984a0e241c5479672cc310cba64b1bdf5 | Ruby | mort666/otx_ruby | /lib/otx_ruby/hostname.rb | UTF-8 | 2,676 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module OTX
class Hostname < OTX::Base
def get_general(hostname)
uri = "/api/v1/indicators/hostname/#{hostname}/general"
json_data = get(uri)
general = OTX::Indicator::IP::General.new(json_data)
return general
end
def get_geo(hostname)
uri = "/api/v1/indicators/hostname/#{... | true |
9d599bb314b5b319de5f23d9a7384f2f38f4ca8f | Ruby | codecop/javaclass-rb | /examples/count_classes_in_modules.rb | UTF-8 | 1,706 | 2.953125 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Example usage of classpath (JavaClass::Classpath): Scan all classpaths (e.g. modules)
# of an an Eclipse "workspace". A workspace is a folder containing several Eclipse
# projects, e.g. JavaClass::Classpath::EclipseClasspath. Report the number of found
# classes per module.
# Author:: Peter Kofler
# Cop... | true |
6c1e70c4cadf7171f01480b33d4d39ccdd9bb0ec | Ruby | CrankyJones/leetspeak | /lib/leet.rb | UTF-8 | 144 | 2.8125 | 3 | [] | no_license | #!/usr/bin/ruby
class String
def leet_speak
self.gsub(/a/i, "4").gsub(/e/i, "3").gsub(/I/, "1").gsub(/o/i, "0").gsub(/\Bs/, "5")
end
end | true |
aff474c64326c5f5034b9859cc8c5fd0e3619849 | Ruby | nishimat/Euler | /p071.rb | UTF-8 | 411 | 3.359375 | 3 | [] | no_license |
# shoudl be a >=b
#
def furui( a, b )
loop do
return a if b == 0
m = a % b
t = b
b = m
a = t
end
end
min = 1000
maxval= 1000000
ans = []
2.upto( maxval ){ |n|
m = 3 * n
if m % 7 == 0
f = 3 * n / 7 - 1
else
f = 3 * n / 7
end
diff = (3 * n - 7 * f).to_f / (7 * n ) .to_f
if diff < min
min ... | true |
0cb482863097d232b9a7633e3382c8ef569dbf76 | Ruby | dinershtein/setmore_api | /lib/setmore_api/appointment.rb | UTF-8 | 2,960 | 2.515625 | 3 | [] | no_license | module SetmoreApi
class Appointment
REQUEST_PATH = '/bookingapi/appointment'
def initialize
fail 'SetmoreApi not configured yet!' unless SetmoreApi.configuration && SetmoreApi.configuration.refresh_token
end
def create appointment_attributes = {}
fail 'Acess Token expired' if SetmoreApi... | true |
3a87070202bd4662e2b613adff0f5bbeea507ff0 | Ruby | Code-Pendency/Mined_Minds_Kata2 | /Commit_Ex1.RB | UTF-8 | 94 | 2.6875 | 3 | [] | no_license | "Commit_Ex1.RB"
def x
0
end
100.times do |x|
if x == 3
print "mined"
else
puts x
end
end | true |
6be5b75958fa2cec0faf68ce3068d9b900c83ec0 | Ruby | callumnec/hangman | /dictionary.rb | UTF-8 | 122 | 3.015625 | 3 | [] | no_license | class Dictionary
def initialize
@words = IO.read("words.txt").split
end
def sample
@words.sample
end
end
| true |
339b909e03a46ec0441d2e6614ec0fe951a31f55 | Ruby | whiskyjs/codeeval | /src/2-hard/minesweeper/main.rb | UTF-8 | 1,086 | 3.140625 | 3 | [] | no_license | # encoding: utf-8
contents = File.read ARGV.first
[TrueClass, FalseClass].each do |klass|
klass.class_eval do
def to_i
self ? 1 : 0
end
end
end
contents.split($/).each do |line|
size, matrix_str = line.split(";")
y, x = size.split(',').map &:to_i
matrix = []
y.times do |n|... | true |
0efe7374d09068bdb6cc745660bc107a1415ffa5 | Ruby | bfl3tch/young-thunder-2893 | /spec/features/movies/show_spec.rb | UTF-8 | 1,991 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'The Movie Show Page' do
before(:each) do
@studio_1 = Studio.create!(name: 'Universal Studios', location: 'Orlando')
@movie_1 = @studio_1.movies.create!(title: 'Blow', creation_year: 2003, genre: 'Drama')
@movie_2 = @studio_1.movies.create!(title: 'Shrek', creation_y... | true |
87839ce211f87c0e163ae7c6696c14b9eb273384 | Ruby | antimon2/julializer | /spec/core/float/constants_spec.rb | UTF-8 | 1,540 | 2.796875 | 3 | [
"MIT"
] | permissive | require File.expand_path('../../../spec_helper', __FILE__)
describe "Float constant" do
xit "DIG is 15" do
"Float::DIG".should be_equivalent_to "15"
end
it "EPSILON is 2.220446049250313e-16" do
"Float::EPSILON".should be_equivalent_to "2.0 ** -52"
"Float::EPSILON".should be_equivalent_to "2.22044604... | true |
22b1d7dacf171c41e489bd5847075d0ba4842f62 | Ruby | aljarrell/app-for-pizza | /app.rb | UTF-8 | 3,716 | 2.90625 | 3 | [] | no_license | require 'sinatra'
require_relative 'price.rb'
get '/' do
pizza_list = params[:pizza_list] if params[:pizza_list]
pizza_list = "" if !params[:pizza_list]
erb :home, locals: {pizza_list: pizza_list}
end
post '/home' do
pizza_list = params[:pizza_list]
number_of_pizzas = params[:number_of_pizzas]
size ... | true |
b72acc434fc0a7cab9781ddb6ad60fd4af8903dd | Ruby | slaterio/tasklist | /spec/features/tasklists/create_spec.rb | UTF-8 | 1,784 | 2.515625 | 3 | [] | no_license | require 'spec_helper'
describe "creating tasklists" do
def create_tasklist(options={})
options[:title] ||= "My Tasklist"
options[:description] ||= "this is my tasklist"
visit "/tasklists"
click_link "New Tasklist"
expect(page).to have_content("New Tasklist")
fill_in "Title", with: options[:title]
fi... | true |
fb074d9bf8f3afd052d2fdeec3a5738d7da1c963 | Ruby | BerniceChua/phase-0 | /week-7/gps6/my_solution.rb | UTF-8 | 7,975 | 3.984375 | 4 | [
"MIT"
] | permissive | # Virus Predictor
# I worked on this challenge [by myself, with John Dees].
# We spent [1] hour on this challenge.
# Sun, 11/15 at 3:00 pm PST
# EXPLANATION OF require_relative
#
#
require_relative 'state_data'
class VirusPredictor
# attr_accessor :population, :population_density
def initialize(state_of_origin)... | true |
ffe7b50997205eb4903a9128bdb70aa5fc1021ea | Ruby | charlesbjohnson/super_happy_interview_time | /rb/test/ctci/test_ctci_c1_p4.rb | UTF-8 | 824 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require("config")
require("ctci/ctci_c1_p4")
module CTCI
module C1
class TestP4 < Minitest::Test
include(P4)
def test_encodes_spaces
s = "Mr John Smith"
actual = encode_spaces(s)
assert_equal("Mr%20John%20Smith", actual)
end
def te... | true |
0521267d36255401004767f94de74aa6fb3ca36d | Ruby | SJKenyon/Sparta-UI-Testing | /Cucumber/cucumber_expressions/features/step_definitions/expressions_step_defs.rb | UTF-8 | 786 | 3.109375 | 3 | [] | no_license | Given("I provide an integer of {int}") do |int|
@arg1 = int
end
Then("I will be able to test the integer") do
expect(@arg1).to eq 14
end
Given("I provide a float of {float}") do |float|
@float_var = float
end
Then("I will be able to test the float") do
expect(@float_var).to be_kind_of(Float)
expect(@float_... | true |
76f870a3a36995ef64f890037f6bf62732dedee0 | Ruby | Manali7494/LighthouseLabs | /Week6/Weekend/RubyPractice/LaunchSchoolExercises/04_part2_cont.rb | UTF-8 | 568 | 3.8125 | 4 | [] | no_license | # Important convention to add 'able' to the action the module perform
=begin
MODULES VS CLASSES
If it's an "is-a" relationship,
choose class inheritance.
If it's a "has-a" relationship,
choose modules
=end
module Swimmable
def swim
puts "I'm swimming!"
end
end
# Note empty classes can use this synta... | true |
ea50fc55e420943d1eaf3e63fc8024574d3dae51 | Ruby | bglusman/DiffApp | /db/seeds.rb | UTF-8 | 4,200 | 2.578125 | 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 rake db:seed (or create!d alongside the db with db:setup).
#
# Examples:
#
# cities = City.create!([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create!(name: 'Eman... | true |
05174b5d5641f32e2a8fc96a582ec9985e3e05dd | Ruby | lfmalves/Exercism | /ruby/gigasecond/gigasecond.rb | UTF-8 | 75 | 2.5625 | 3 | [] | no_license | require 'time'
class Gigasecond
def self.from(date)
date + 1e9
end
end | true |
6e200305cdc4b91a2e129aaf32705612f8eb5dbc | Ruby | olegbilyk777/Ruby-lessons | /game.rb | UTF-8 | 485 | 4.1875 | 4 | [] | no_license | puts("Hello! What is your name?")
name = gets.chomp
puts("Welcome to the game #{name}!")
number = rand(1..10)
puts("Please, guess number between 1 and 10. You have 3 attempts!")
winner = false
while winner == false
guess = gets.to_i
if guess > number then
puts("Sorry, wrong. You have 2 more attempts!")
e... | true |
00528383cb46d6c8f0713009f7b3e26bf6e4208c | Ruby | doverh/TECH-HIRE-katas | /ISBN/OLD/test_isbn.rb | UTF-8 | 1,617 | 3.40625 | 3 | [] | no_license | # Requirements
# - Takes a string
# - Check for invalid chars
# - Accept X on last position
# - Return true or false
# - Check position of string
require "minitest/autorun"
require_relative "isbn.rb"
class TestIsbn < Minitest::Test
#ISBN10 TESTS
def test_isbn_lenght_10_chars
assert_equal(true,check_length(["978 ... | true |
a449d7b081bed796863bfabdff784e4873e16254 | Ruby | RobbieDumbrell/chris-pine-ruby-tutorials | /recursion.rb | UTF-8 | 671 | 4.4375 | 4 | [] | no_license | # Using recursion in place of while loops.
def ask_recursively question
puts question
reply = gets.chomp.downcase
if reply == "yes"
true
elsif reply == "no"
false
else
puts "Please answer \"yes\" or \"no\"."
ask_recursively question # this line is the method calling itself within itself (so act... | true |
d566c4c0b6b77b2339a37f23af2f76f856ac6caf | Ruby | svn2github/teraterm-trunk | /tests/clipboard-access.rb | UTF-8 | 3,508 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: ASCII-8BIT
Encoding.default_external = "ASCII-8BIT" if RUBY_VERSION >= "1.9.0"
require 'timeout'
require 'kconv'
def rawio(t=nil, &blk)
saved_mode = nil
open("|stty -g") do |stty|
saved_mode = stty.gets
end
begin
system("stty raw -echo")
if t
return Timeout.t... | true |
32145add917cf68b331a8b56143ab5185ea2732b | Ruby | ryaan-anthony/tempo-cli | /test/lib/tempo/models/composite_test.rb | UTF-8 | 2,929 | 2.546875 | 3 | [] | no_license | require "test_helper"
describe Tempo do
before do
# See Rakefile for directory prep and cleanup
@dir = File.join( Dir.home,"tempo" )
Dir.mkdir(@dir, 0700) unless File.exists?(@dir)
end
describe "Model::Composite" do
it "should inherit readable only id" do
tree_factory
inherits_attr... | true |
89ff0b63f990fdbf6d0ae822bc2e919f88aaf761 | Ruby | madglory/nowplayus | /app/presenters/ical.rb | UTF-8 | 1,128 | 2.546875 | 3 | [] | no_license | require 'icalendar'
class Ical
include Icalendar
include Rails.application.routes.url_helpers
def initialize(events = [], options = {})
@title = ' - ' + options[:title] if options[:title]
puts @title
@calendar = Calendar.new
add_events(events) if events
@calendar
end
def add_events(e... | true |
06ab10cc6cb4a2a0ab990dcccc35053b493c79df | Ruby | weyus/hcc_tropo_demos | /demo3/examples.rb | UTF-8 | 1,534 | 2.5625 | 3 | [] | no_license | VOICE = 'vanessa'
DEFAULT_OPTIONS = {:attempts => 2,
:timeout => 15,
:voice => VOICE,
:choices => '1, 2, 3',
:onBadChoice => lambda {|event|
case event.attempt
... | true |
96967da99a352a9951a6108b23aa972afe9e16fc | Ruby | emikojima/sinatra-basic-routes-lab-v-000 | /app.rb | UTF-8 | 297 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
"Hello, World!"
end
get '/name' do
"My name is Emi"
end
get '/hometown' do
"My hometown is Tokyo"
end
get '/favorite-song' do
"My favorite song is Juke Box"
end
end
| true |
2545a906f5ec282e411c82700dfdeb94fb53a2b3 | Ruby | kevin-marshall/wixgem | /lib/file.rb | UTF-8 | 334 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require 'win32ole'
class File
def self.read_only?(path)
raise "'#{path}' does not exist" unless(File.exist?(path))
fso = WIN32OLE.new('Scripting.FileSystemObject')
raise 'Failed to create Scripting.FileSystemObject' if(fso.nil?)
fo = fso.GetFile(path)
return ((fo.Attributes & 1) != 0) ? true : f... | true |
ec720c75778db2646083f11e00a2f07799f08df4 | Ruby | HIDERO-T/weatherapp | /spec/models/point_weather_spec.rb | UTF-8 | 1,589 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe PointWeather, type: :model do
context "when APIKey is invalid," do
before { PointWeather.api_key = "INVALIDAPIKEY" }
it "raises APIKeyError when API Key is invalid." do
expect { PointWeather.new(35, 135) }.to raise_error(PointWeather::APIKeyError)
end
end
... | true |
753a6c482c7e231e3886cf9381ea7439b346d9bb | Ruby | apo5698/helli-grading | /app/lib/helli/matcher.rb | UTF-8 | 653 | 2.875 | 3 | [
"MIT"
] | permissive | module Helli
class Matcher
def initialize(expected, actual, level = 0)
@expected = expected
@actual = actual
@level = level
@checker = DidYouMean::SpellChecker.new(dictionary: [])
end
def match; end
# Matches every single character.
def strict_match
@expected == @a... | true |
c60557aee80a165b3a310e45cb52eac707959ba6 | Ruby | AmelieSK/bookmark_manager | /spec/bookmark_spec.rb | UTF-8 | 2,443 | 2.640625 | 3 | [] | no_license | require './lib/bookmark'
require 'pry'
describe Bookmark do
it 'shows all the bookmarks' do
Bookmark.create(url: 'http://www.google.com', title: 'Google')
Bookmark.create(url: 'http://www.makersacademy.com', title: 'Makers')
expect(Bookmark.all).to include an_instance_of(Bookmark)
end
# describe 'cr... | true |
e59affffc214e1aa2cb8dc42cddd33790a24f9ef | Ruby | EugZol/btcruby | /lib/btcruby/script/signature_hashtype.rb | UTF-8 | 2,054 | 2.984375 | 3 | [
"MIT"
] | permissive | # Hash type determines how OP_CHECKSIG hashes the transaction to create or
# verify the signature in a transaction input.
# Depending on hash type, transaction is modified in some way before its hash is computed.
# Hash type is 1 byte appended to a signature in a transaction input.
module BTC
# First three types are ... | true |
d24e9ed7c431e9fa2f616dc39c9830318dcf12b3 | Ruby | jayeshsidhwani/tatkal_tinyowl | /app/services/recommender_service.rb | UTF-8 | 1,866 | 2.796875 | 3 | [] | no_license | module RecommenderService
class << self
def recommend(user)
recommendations = recommended_items(user)
items_in_rooster = rooster_items(user)
exact_matches = recommendations.where(:item_id => items_in_rooster).pluck(:item_id)
more_items_to_fetch = 10 - exact_matches.length
aux_match... | true |
5048b33cba83e19e0a0817bcff069daa1ff5a12d | Ruby | jgt17/project_euler | /problem_87.rb | UTF-8 | 404 | 3.078125 | 3 | [] | no_license | # frozen_string_literal: true
require 'set'
require 'prime'
target = 50_000_000
valid_nums = Set.new
Prime.each do |a|
Prime.each do |b|
Prime.each do |c|
candidate = a**2 + b**3 + c**4
candidate < target ? valid_nums.add(candidate) : break
end
break unless a**2 + b**3 + 16 < target
end
... | true |
e182c45d1f03c545da7aeeb3751f22ee062beb52 | Ruby | alan-brennan/git_practice | /practice/part3.rb | UTF-8 | 354 | 3.75 | 4 | [] | no_license | def line_to_print(line, name)
birthday = "Happy Birthday"
case line
when 1,2,4 then return "#{birthday} to you!"
when 3 then return "#{birthday} dear #{name}"
end
end
puts "Enter your name"
name = gets.chomp
#puts line_to_print(1,"alan")
line = 1
while line < 5 do
puts line_to_pr... | true |
90fb268edbb220b949521b81eacd3ab86012a997 | Ruby | kristinatong/badges-and-schedules-nyc-web-080618 | /conference_badges.rb | UTF-8 | 564 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def badge_maker(string)
"Hello, my name is #{string}."
end
def batch_badge_creator(array)
badge_array = []
for i in (0...array.length)
badge_array.push("Hello, my name is #{array[i]}.")
end
badge_array
end
def assign_rooms(array)
badge_array = []
for i in (0...array.length)
badge_array.push("Hel... | true |
cc137bdad2eb5bdd640839d45f9703e151c2e8f5 | Ruby | telgi/bank-app | /lib/printer.rb | UTF-8 | 339 | 3.34375 | 3 | [] | no_license | # Responsible for printing account information
class Printer
def statement(transactions)
statement_header
statement_body(transactions)
end
private
def statement_header
puts 'Date || Trans || Balance'
end
def statement_body(transactions)
transactions.reverse.each { |trans| puts tran... | true |
93e146011d0af0386e44e6f325f8ac8071ca9593 | Ruby | sheriefCloud/oo-tic-tac-toe-online-web-sp-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,496 | 4.28125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class TicTacToe
WIN_COMBINATIONS=[
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
# binding.pry
def initialize
@board = Array.new(9, " ")
end
def display_board
puts " #{@board[0]} | #{@board[1]} | #{@board[2]} "
puts "-----... | true |
8ce3751ff9049439e911eb271f70e3e307bcc3b6 | Ruby | remya17/hotel-booking-api-app | /lib/stripe_payment.rb | UTF-8 | 2,339 | 2.65625 | 3 | [] | no_license | class StripePayment
Stripe.api_key = "sk_test_32EQAi8W6LtXD6YEuzxe4ITk"
STRIPE_TIMEOUT = 10
attr_reader :options, :response
def initialize(options)
@options = options
@response = {status: :ok}
end
def charge_card
get_token
if response[:status] != :ok
log_error(response)
retur... | true |
57a834ed656c36aada720d6e729c9abe9f060ba2 | Ruby | cincospenguinos/AdventOfCode2020 | /lib/AdventOfCode2020/day_six/day_six.rb | UTF-8 | 290 | 3.1875 | 3 | [
"MIT"
] | permissive | require_relative 'group'
class DaySix
attr_reader :groups
def initialize(groups)
@groups = groups.map { |g| Group.new(g) }
end
def count
count_with(:unique)
end
def strict_count
count_with(:every)
end
private
def count_with(func)
groups.map(&func).inject(:+)
end
end | true |
a71ff215d88ebf1dff2c1769b79e2fde5d1268b1 | Ruby | mooremo/HW002 | /bin/record_sort | UTF-8 | 1,201 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'awesome_print'
require_relative '../lib/profile'
require_relative '../lib/profile_collection'
options = {}
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: 'record_sort FILE [OPTIONS]"
opts.separator ""
opts.separator "Options"
opts.on('-s', '-... | true |
d8e125061af6cc8538e2d7996aec58482d3989c1 | Ruby | mikefieldmay/oyster-card-challenge | /spec/station_spec.rb | UTF-8 | 565 | 2.8125 | 3 | [] | no_license | require 'station'
describe Station do
subject(:station) { described_class.new(:a_name, :a_zone)}
it{expect(station).to respond_to(:name)}
it{expect(station).to respond_to(:zone)}
context "when creating a station" do
it "takes name as an argument" do
expect{described_class.new("name", "zone")}.not_t... | true |
c644f0e1eb4f1adfe79063d00830391ef2af96e0 | Ruby | zufardhiyaulhaq/CodeChallenge | /other/competitive/battleship-tdd/lib/player.rb | UTF-8 | 1,079 | 3.546875 | 4 | [] | no_license | class Player
attr_reader :name
attr_reader :player_map
def initialize(name, map)
if name.class != String || map.class != Map
raise ArgumentError, 'Err: argument should be String & Map'
end
@name = name
@player_map = map
@missile = []
end
def add_ship(coordinate)
if coordinate.... | true |
1e5a4735697793873d2b90ff5ebfbe53c5efe168 | Ruby | smatalha/ruby-oo-object-relationships-kickstarter-lab-nyc01-seng-ft-042020 | /lib/backer.rb | UTF-8 | 478 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require 'pry'
class Backer
attr_accessor :name
def initialize(name)
@name = name
end
def back_project(project)
ProjectBacker.new(project, self)
end
def backed_projects_helper
ProjectBacker.all.select { |project| project.backer == self }
end
def backed... | true |
6557476231f27d5ed556928a4d810be9030494a8 | Ruby | thomasvanophem/Ruby | /fibonacci.rb | UTF-8 | 573 | 3.703125 | 4 | [] | no_license | def fibonacci(number1, number2, sequence)
next_number = number1 + number2
sequence << next_number if next_number < 4000000
fibonacci(number2, next_number, sequence) if next_number < 4000000
end
def fibonacci_sequence(f1, f2, sequence)
next_number = f1 + f2
if next_number < 400000
sequence << next_numb... | true |
7eba0953e239df79ac6c05352b836b692ca3aa4e | Ruby | mutsey/ruby-objects-belong-to-lab-online-web-pt-110419 | /lib/post.rb | UTF-8 | 230 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name, :genre
def initialize(name, genre)
@name = name
@genre = genre
end
end
drake = Artist.new("Lizzo", "rap")
Good_As_Hell = Song.new("Good As Hell")
Good_As_Hell.artist = Lizzo | true |
3f96c6439fa837db92a602d20f8d3619b22ac84d | Ruby | LaraLaPierre/prework | /2.24.1.rb | UTF-8 | 107 | 3.5625 | 4 | [] | no_license | #Print out all numbers from 200 to 300.
number = 200
101.times do
p number
number = number + 1
end | true |
fba09a8623a086c27daf44a85a723c564163a215 | Ruby | gilesbowkett/citrus | /lib/citrus.rb | UTF-8 | 1,673 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'strscan'
# Citrus is a compact and powerful parsing library for Ruby that combines the
# elegance and expressiveness of the language with the simplicity and power of
# parsing expressions.
#
# http://mjijackson.com/citrus
module Citrus
autoload :File, 'citrus/file'
VERSION = [2, 2, 2]
# Returns the cu... | true |
54a6815ad109f6ca4be9c8e70c5bdc5d36f70708 | Ruby | austinb847/anagram-checker | /lib/anagram.rb | UTF-8 | 1,385 | 4.0625 | 4 | [] | no_license | require 'pry'
class Word
def initialize(word1, word2)
@word1 = word1
@word2 = word2
end
def check_for_vowels?(word)
if word.count("aeiouy") > 0
true
else
false
end
end
def format_string(word)
word.downcase.gsub(/[^a-z]/,'')
end
def get_letter_matches(word1, word2)
... | true |
119e1b0c46a42afd3aa6d0596b3588eccc8623ee | Ruby | Magmahr/collections_practice-nyc-web-060418 | /collections_practice.rb | UTF-8 | 744 | 3.875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort.reverse
end
def sort_array_char_count(array)
array.sort { |x, y| y=x.length <=> y.length}
end
def swap_elements(array)
array2 = []
array2.push(array[0], array[2], array[1])
array2
end
def reverse_array(array)
array.reverse
... | true |
a5f1679ded146f8a39c1e25a9a060f86243461a6 | Ruby | fe80/troclapi | /app/helpers/reset.rb | UTF-8 | 880 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
#
# This module is a helper for trocla reset function
#
module ResetHelpers
#
# @api private
#
def trocla_reset(key, format, options)
raise 'Trocla key is an empty value' if key.empty?
raise 'Format is an empty value' if format.empty?
logger.info "#{session[:user]} R... | true |
493e6200604b72a47b2b12fa8ca8c7907aab56ef | Ruby | mirana2/expl | /spec/02_calculator_spec.rb | UTF-8 | 250 | 2.6875 | 3 | [] | no_license | require_relative '../lib/02_calculator'
describe "add" do
it "adds 0 and 0" do
expect(add(0,0)).to eq(0)
end
it "adds 2 and 2" do
expect(add(2,2)).to eq(4)
end
it "adds positive numbers" do
expect(add(2,6)).to eq(8)
end
end | true |
ff6c19419dfbf89f147b84c1486d77cd548f9086 | Ruby | Itshalffull/ruby-tests | /09_timer/timer.rb | UTF-8 | 525 | 3.3125 | 3 | [] | no_license | class Timer
attr_accessor :seconds
def initialize
@seconds = 0
time_string;
end
def padded(num)
if num < 9
num = "0" + num.to_s
else
num = num.to_s
end
num
end
def time_string
if @seconds < 10
@time_string = "00:00:#{padded @seconds}";
elsif @seconds < 3600
@time_string = "00:#{padded ... | true |
2b61f3219c9552340d23537647aeceb4c340c077 | Ruby | jmhill91/ruby-object-attributes-lab-dumbo-web-career-042219 | /lib/person.rb | UTF-8 | 206 | 2.71875 | 3 | [] | no_license | class Person
def initialize
@name=name
@job=job
end
def name
@name
end
def name=new_name
@name=new_name
end
def job
@job
end
def job=new_job
@job=new_job
end
end
| true |
994340a94729b2cb9278b238ac03e509288ad9ca | Ruby | htano/summary_dev | /lib/auto-summary/summarizer.rb | UTF-8 | 4,156 | 2.8125 | 3 | [] | no_license | # coding: utf-8
require 'open-uri'
require './lib/text-analyzer.rb'
require './lib/contents-extractor.rb'
class AutoSummary::Summarizer
include TextAnalyzer
include ContentsExtractor
include AutoSummary
SUMMARY_LENGTH = 150
def initialize
params_dir = PARAMS_DIR
df_dir = DF_DIR
@weight = read_ha... | true |
d24c63e957f45445da32ec11c80cca123e53e1ca | Ruby | MostlyFocusedMike/ttt-10-current-player-ruby-intro-000 | /lib/current_player.rb | UTF-8 | 193 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board) # empty spaces are set to " ", not "" anymore
return board.count {|piece| piece != " "}
end
def current_player(board)
return turn_count(board).even? ? "X" : "O"
end | true |
46dfe58d224074b7724ae6cbfdb3ba5d63ee2500 | Ruby | ZeroCry/db | /spec/movie_reviews_integration_spec.rb | UTF-8 | 2,320 | 3.125 | 3 | [] | no_license | require "movie_reviews_app"
require 'json'
describe "integration" do
let(:reviews_json) {
<<-JSON
[
{"title":"Star Wars","review":"Great, this film was","score":77},
{"title":"Star Wars The Force Awakens","review":"A long time ago in a galaxy far far away someone made the best sci-fi film o... | true |
4a573d3888281db7106bb508fbc981650e9c3b07 | Ruby | mroker242/LaunchSchool | /Orientation/Hashes/loop.rb | UTF-8 | 315 | 3.75 | 4 | [] | no_license | #loop
def print_keys(hash)
hash.each_key { |k| puts k }
end
def print_values(hash)
hash.each_value { |k| puts k }
end
def print_keys_values(hash)
hash.each { |k,v| puts "#{k} and #{v}" }
end
h = {'name' => 'michael', 'age'=> 33, 'lastname'=> 'roker'}
print_keys(h)
print_keys_values(h)
print_values(h); | true |
77589c81f41b98258a6a9b570e15f2fbda08c971 | Ruby | omarbranez/bar-captain | /app/models/drink.rb | UTF-8 | 373 | 2.625 | 3 | [
"MIT"
] | permissive | class Drink < ActiveRecord::Base
validates_uniqueness_of(:name)
has_many :user_drinks
has_many :users, through: :user_drinks
has_many :drink_products
has_many :products, through: :drink_products
def slug
name.downcase.gsub(" ", "-")
end
def self.find_by_slug(slug)
Drin... | true |
b66ee271e7462d93f8ef74d874b9529f2fe7f82e | Ruby | vermartian/chillow | /spec/lib/occupant_spec.rb | UTF-8 | 661 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe Occupant do
let(:occupant) { Occupant.new("John", "Denver") }
describe "#initialize" do
it "has a first name" do
expect(occupant).to be_an(Occupant)
expect(occupant.first_name).to eq("John")
end
it "does not have writeable first name" do
expect... | true |
d2eddf3deb76f5a60b9e16b5522a3d109f950b7a | Ruby | pitosalas/repsurv | /app/models/program.rb | UTF-8 | 2,318 | 2.609375 | 3 | [] | no_license | class Program < ActiveRecord::Base
attr_accessible :name, :description, :open,
:locked, :suppress_hidden_participants,
:moderator, :id, :opened, :closed, :moderator_id
attr_accessor :last_import_results
has_many :questions, dependent: :destroy
has_many :rounds, dependent: ... | true |
ef6c40f4d39d0d0ba71f5082b836aa12563dac7b | Ruby | MedetaiAkaru/optional_exercises | /enums_3.rb | UTF-8 | 434 | 4.5 | 4 | [] | no_license | # Module: Enumerable Methods
# Write a method abbreviate_sentence that takes in a sentence string
# This returns a new sentence where every word longer than 4 characters has all of it's vowels removed
def abbreviate_sentence(sent)
# Write your code here
end
puts abbreviate_sentence("follow the yellow brick road")... | true |
02f1c0f45b70247b6af73f9857d2e20c8893e468 | Ruby | christophszcz/ruby_fundamentals2 | /exercise7.rb | UTF-8 | 462 | 3.359375 | 3 | [] | no_license | students = {
:cohort1 => 34,
:cohort2 => 42,
:cohort3 => 22,
}
def student_list(hash)
hash.each do |key,value|
puts "#{key}: #{value}"
end
end
students[:cohort4] = 43
student_list(students)
students.delete(:cohort2)
student_list(students)
students.each { |key,value| students[key] = (value * 1.05).round}
s... | true |
24c4e8b23e2d6a62bf77ea476a68d7b97883f292 | Ruby | neshmi/website | /app/models/location.rb | UTF-8 | 499 | 3.125 | 3 | [] | no_license | class Location
attr_accessor :name, :address, :zip, :city, :state
def initialize( hash = {} )
hash.each do |key, value|
method = "#{key}="
send(method, value) if self.respond_to?(method)
end
end
def self.new_from_meetup( request )
if request.venue
new({
name: request.venu... | true |
5fc48c2c79dcb0cecf497a33e91444e56391ca4c | Ruby | KG700/algorithm-complexity | /lib/timer.rb | UTF-8 | 585 | 3.578125 | 4 | [] | no_license | def timer(method)
(5000..100000).step(5000).to_a.each do |number|
# run method 10 times to warm up the laptop:
10.times {
array = create_array(number)
array.send(method)
}
times = []
101.times {
array = create_array(number)
times << time(method, array)
}
# print ... | true |
f91a117488212faf422f7ec80426e490bc527a96 | Ruby | greenjoshua/RB101 | /lesson_6/twenty_one.rb | UTF-8 | 6,384 | 3.578125 | 4 | [] | no_license | WINNING_SCORE = 21
DEALER_MAX_HIT_VALUE = 17
GRAND_WINNER = 5
def prompt(message)
puts "=>#{message}"
end
def clear
system('cls') || system('clear')
end
deck = {}
hands = { player: [], dealer: [] }
def initialize_deck(dck)
dck["H"] = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
dck["D"... | true |
334e144064ca52edd5c6801f9b6aa4e3ae6b5286 | Ruby | descholar-ceo/telegram-bot | /spec/formatter_spec.rb | UTF-8 | 2,000 | 2.640625 | 3 | [] | no_license | require 'time'
require_relative '../lib/helpers/formatter'
require_relative '../lib/modules/constants'
describe Formatter do
let(:formatter) { Formatter.new }
let(:word_res) do
formatter.format_response('word', TestMockData::SAMPLE_WORD_FROM_INTERNET) ==
TestMockData::SAMPLE_WORD_TO_USER
end
let(:qu... | true |
07d0cdb06629016f8674f4eb12d95c2339c75fc0 | Ruby | jturgeon88/Josh_Turgeon_homework | /W5D1/music_app/music_app/app/controllers/users_controller.rb | UTF-8 | 1,009 | 2.609375 | 3 | [] | no_license | class UsersController < ApplicationController
def new #this presents a form to the user to create a new user (SIGNUP)
render :new
end
def create #this creates the user in the database given the user params if they are valid
@user = User.new(user_params)
if @user.save
... | true |
3eeb84228c9919fdeff17321f8cf45112fb8fe6f | Ruby | jr1412594/ruby-check | /Classes/protected_methods.rb | UTF-8 | 639 | 2.90625 | 3 | [] | no_license | =begin
Protected Methods
Review of Methods
public methods allow interaction with an object
public methods can be called by any other object
private methods can onlhy be called within the object
private methods cannot be invoked by another object.
private methods cannot be called with an explici... | true |
24bb6d3eef3c6953645a920e0da7ff604d8eba87 | Ruby | Quintasan/woodpecker | /lib/woodpecker/prospect.rb | UTF-8 | 1,555 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Woodpecker
class Prospect
VALID_STATUSES = %w(active replied bounced autoreplied invalid blacklist).freeze
ATTRS = %i[email status first_name last_name tags company
industry title phone address city state country website
snipet1 snipet2 snipe... | true |
cffc141a59afe3571ba9a963ec9e2dd1b17a673a | Ruby | torafugu/houdd_alpha | /app/models/mini_map_road.rb | UTF-8 | 2,460 | 2.53125 | 3 | [] | no_license | # This class describes a road of mini map.
class MiniMapRoad < ActiveRecord::Base
belongs_to :start_mini_map, :class_name => 'MiniMap', :foreign_key => 'start_mini_map_id'
belongs_to :end_mini_map, :class_name => 'MiniMap', :foreign_key => 'end_mini_map_id'
validates :start_mini_map_id, :presence => true
valid... | true |
1863f552dd980dbe86f2b681c501906301d4f0c1 | Ruby | daryllxd/hotels | /lib/importers/hotels/columns/images.rb | UTF-8 | 854 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require './lib/importers/hotels/columns/base'
module Importers
module Hotels
module Columns
class Images < Base
def transformed_value
raise HotelsError, 'Invalid images, must be a hash' unless value.is_a?(Hash)
value.keys.each_with_object({}) do |... | true |
de2fedc9ed4c37fb5323bb1880f28662e45f1058 | Ruby | russomp/learn-ruby-the-hard-way | /ex19.rb | UTF-8 | 717 | 4.34375 | 4 | [] | no_license | def cheese_and_crackers(cheese_count, boxes_of_crackers)
puts "You have #{cheese_count} cheeses!"
puts "You have #{boxes_of_crackers} boxes of crackers!"
puts "Man that's enough for a party!"
puts "Get a blanket.\n"
end
puts "We can just give the function numbers directly:"
cheese_and_crackers(20,30)
... | true |
5f8c4706c1d90586d793a53832bbd62142fe5c58 | Ruby | samvera-deprecated/hydradam | /script/import_metadata | UTF-8 | 494 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
filename = ARGV[0]
user_key = ARGV[1]
if user_key.nil?
puts "Usage: #{$PROGRAM_NAME} filename username"
puts "Please provide the a file path you want to import and a user key."
exit(1)
end
unless File.exists?(filename)
puts "Unable to read file #{filename}"
exit(1)
end
puts "Loading e... | true |
c6f0df93d9cef3546d4d34951d394eb1faae2460 | Ruby | serkansahin55/ruby-enumerables-reverse-each-word-lab-nyc01-seng-ft-091420 | /reverse_each_word.rb | UTF-8 | 373 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # # string = "Hello there, and how are you?"
# def reverse_each_word(string)
# words = string.split(" ")
# reversed = []
# words.each do |word|
# reversed << word.reverse
# end
# reversed.join(" ")
# end
def reverse_each_word(string)
words = string.split(" ")
new = []
words.collect do |word|
ne... | true |
e34f35378ee575205ddcde4cc91b40946b9e60aa | Ruby | pilarcormo/small_genomes_SNPs | /lib/metric_work.rb | UTF-8 | 4,234 | 2.9375 | 3 | [] | no_license | #encoding: utf-8
class MetricWork
require_relative 'reform_ratio'
require_relative 'GATOC'
require 'pmeth'
require 'pdist'
=begin Testing how well the fitness method of the genetic algorithm,
identifies permuations that are approaching the correct order.
1. Get an array of correctly ordered FASTA contigs
... | true |
075cc412b13f71fca7613860360f607cbbe2d43a | Ruby | korethisyo/ruby-hw | /lesson7-1.rb | UTF-8 | 210 | 3.59375 | 4 | [] | no_license | puts "計算をはじめます"
puts "2つの値を入力してください"
a = gets
b = gets
puts "計算結果を出力します"
result = a.to_i * b.to_i
puts "a*b=#{result}"
puts "計算を終了します" | true |
458e63b3debb8c8db0096ba65446c1227acef478 | Ruby | mariajennings/phase-0-tracks | /ruby/secret_agents.rb | UTF-8 | 1,943 | 4.4375 | 4 | [] | no_license | # Friday Afteroon Extra Fun Times
def encrypt(string1)
count = 0
alphabet = "abcdefghijklmnopqrstuvwxyz"
while count < string1.length
if string1[count] == " "
string1[count] = " "
count += 1
else
original = alphabet.index(string1[count])
converted = original + 1
encrypted_le... | true |
ac72ea83d9dbc83723beb8650087a4d70dfb9264 | Ruby | mxdavis/oo-student-scraper-v-000 | /lib/scraper.rb | UTF-8 | 1,618 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
student_index_array = []
html = File.read(index_url)
student_scraper = Nokogiri::HTML(html)
student_scraper.css("div.student-card").collect do |s|
each_student = {
:name => s.css("div.card-text-conta... | true |
e46eafdf91b8779da7304a2f72e6c0acb3e9135f | Ruby | NathanSadler/epicode_1 | /Thursday/Allergies/lib/allergies.rb | UTF-8 | 612 | 3.46875 | 3 | [] | no_license | #!/usr/bin/env ruby
# Create a hash where the keys are powers of 2 and the values are allergens
allergens = [:eggs, :peanuts, :shellfish, :strawberries, :tomatoes,
:chocolate, :pollen, :cats]
allergen_hash = Hash.new
(0...allergens.length).to_a.each do |number|
allergen_hash.store(2**number, allergens[number].to_s)
... | true |
1fc63fe277f291002a81b449763d760672b9d327 | Ruby | msavoury/ruby-playground | /scopes/scope-change.rb | UTF-8 | 277 | 3.40625 | 3 | [] | no_license | #!/usr/bin/ruby
var1 = "Marcos"
class Alpha
puts "Inside Alpha"
#puts "var1 is #{var1}" #This causes an error, it's undefined
end
puts "var1 is #{var1}" #This is fine
class Beta
puts "Inside Beta"
# puts "var1 is #{var1}" #Will also cause an error
end
| true |
e9fa549cebfa1e9c2a7b774b4e8ebcb3d96d18b8 | Ruby | lsauld/programming-univbasics-4-array-simple-array-manipulations-part-1-hou01-seng-ft-060120 | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 324 | 2.90625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def using_unshift(array,string)
array.unshift(string)
end
def using_pop(array)
array.pop
end
def pop_with_args(array)
array.pop(2)
end
def using_shift(array)
array.shift
end
def shift_with_args(array)
array.shift(2)
end
def using_push(array,string)
array.push(string)
... | true |
115d6eb215b318ea71937d44c51371d1d4b177ca | Ruby | MRossant/W7D1 | /ninetynine_cats/app/models/user.rb | UTF-8 | 1,283 | 2.625 | 3 | [] | no_license | class User < ApplicationRecord
after_initialize :ensure_session_token
validates :user_name, :session_token, :password_digest, presence: true
validates :password, length: { minimum: 6, allow_nil: true}
attr_reader :password
has_many :cats,
primary_key: :id,
foreign_key: :user_id,
... | true |
21f4871bea358a58fbbe350ee2669fab80c0b776 | Ruby | vinpac/import-js | /lib/import_js/js_module.rb | UTF-8 | 2,043 | 2.875 | 3 | [
"MIT"
] | permissive | module ImportJS
# Class that represents a js module found in the file system
class JSModule
attr_reader :import_path
attr_reader :lookup_path
attr_reader :file_path
attr_reader :main_file
attr_reader :skip
attr_accessor :is_destructured
# @param lookup_path [String] the lookup path in w... | true |
997907bc2c7b5362b544270f159339467282bcbe | Ruby | whites11/advent-of-code-2020 | /day4/2/run.rb | UTF-8 | 2,222 | 3.078125 | 3 | [] | no_license | #!/usr/bin/ruby
file="input"
file="simple" if ARGV[0] == "--simple"
passports = []
# number of columns in a row.
cols_in_row = 0
current_passport = {}
f = File.open(file, "r")
f.each_line do |line|
if line.strip == ""
passports << current_passport if current_passport.length > 0
current_passport = {}
n... | true |
70f0d826619d33b5e6659295c26d447a63ca6368 | Ruby | willcosgrove/advent_of_code | /2017/14b.rb | UTF-8 | 1,957 | 3.59375 | 4 | [] | no_license | require 'matrix'
require 'set'
require 'pry'
require './circular_buffer'
ROPE_HASH_SUFFIX = [17, 31, 73, 47, 23].freeze
def rope_hash(str)
lengths = str.bytes + ROPE_HASH_SUFFIX
rope = CircularBuffer[*(0..255)]
position = 0
skip_size = 0
64.times do
lengths.each do |length|
rope[position.... | true |
1f5d880ee6c089ca255f60c63c8ebb9a1d3c2abd | Ruby | Billiam/mastercook2jekyll | /master_cook_parser.rb | UTF-8 | 1,873 | 2.78125 | 3 | [] | no_license | require_relative './recipe'
module MasterCookParser
extend self
def parse(content)
recipes = content.split(/\* +Exported from *MasterCook +\*/)
recipes.map(&:strip).reject(&:empty?).map{|recipe| parse_recipe(recipe) }
end
def recipe_regex
%r{
\A(?<title>.+)\n+
(?:Recipe.+\n+)?
... | true |
9e75911bbda7f29450c8c7e366a22adc5906f019 | Ruby | gperl27/ironhack-web-development | /Week2/movie_game/models/game.rb | UTF-8 | 258 | 3.65625 | 4 | [] | no_license | class Game
attr_accessor :movies
def initialize
@movies = []
end
def add_movies(movie_array)
movie_array.each_with_index { |movie,index|
@movies << movie
if index >= 8
break
end
}
end
def get_random_movie
@movies.sample
end
end | true |
1457cd77ac4ff304ea89e57dc9f990ab514dac3f | Ruby | lenriquez/file-change-detector-websocket | /src/websocket_helper.rb | UTF-8 | 681 | 2.671875 | 3 | [] | no_license | require 'digest/sha1'
# WebSocket related methods that can be reused and do not hold state
module WebSocketHelper
class << self
# Extract key from header
def get_websocket_key(header)
header.match(/^Sec-WebSocket-Key: (\S+)/)[1]
end
# Tem=plate for header
def prepare_header(response_key)
... | true |
e765f5ca9cac844eb7eb47b7ecbd1c420caafceb | Ruby | jeffmiller00/miller_team_league | /_scripts/fetch_nfl_wins.rb | UTF-8 | 4,630 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'typhoeus'
require 'nokogiri'
require 'date'
require 'json'
require 'yaml'
require 'pry'
DATA_FILE = '../_data/nfl.json'
PICKS_FILE ='../_data/index/nfl_picks.yml'
def get_teams
all_teams = File.read(DATA_FILE)
JSON.parse(all_teams)
end
def parse_team_name(combined_name)
if combined_name.include?('Was... | true |
dba0abf77b3eefedda670408789f5d3e5459821e | Ruby | rtezera1/cash_register_3 | /cashier_iii.rb | UTF-8 | 2,726 | 3.390625 | 3 | [] | no_license | require 'csv'
require 'pry'
count={}
i=1
cost=nil
report={}
quantity={}
light={}
s_total=[]
selection=nil
change=0
amount={}
total={}
chosen_amount=nil
CSV.foreach('/Users/robeltezera/Dropbox/launchacademy/cashier_3/products.csv', headers: true) do |row|
puts "#{i}) Add Item - #{row[3].to_i} - #{row[1]}"
# { id... | true |
24c55fa1cecf32320c8fe8e04c988aba10f5c4bd | Ruby | radiospiel/etest | /test/etest_assertions.rb | UTF-8 | 948 | 2.703125 | 3 | [] | no_license | module Etest::ComparisonAssertions::Etest
# I don't know how to test asserts. This, at least, give (fake) C0 coverage
def test_comparision_assertions
assert_lt 1, 2
assert_le 1, 1
assert_ge 2, 2
assert_gt 2, 1
assert_eq 2, 2
assert_ne 1, 2
end
end
module Etest::Assertions::Etest
#
# t... | true |
5bf431f8849e7a2dcf7f404d99e201233cd12cb8 | Ruby | mikehale/akismet | /lib/akismet.rb | UTF-8 | 1,715 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'net/http'
require 'uri'
class Akismet
version = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'VERSION.yml'))
version = "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
USER_AGENT = "Akismet-rb/#{version} | Akismet/1.11"
def initialize(key, url)
@key = key
@url = url
end
... | true |
703fc941b9fc78f77bacab5a885f0285e5918c8f | Ruby | ahopkins94/boris-bikes | /lib/docking_station.rb | UTF-8 | 636 | 3.265625 | 3 | [] | no_license | require_relative 'bike'
require_relative 'van'
class DockingStation
DEFAULT_CAPACITY = 20
attr_reader :stored_bikes, :capacity
def initialize(capacity = DEFAULT_CAPACITY)
@stored_bikes = []
@capacity = capacity
end
def release_bike
raise "Docking station is empty" if empty?
raise "Bike not... | true |
e04f938b93d4e627c6c488d1c7d04f6ca9c83853 | Ruby | ip-ilamparithi/GUVI | /palindrome.rb | UTF-8 | 108 | 3.0625 | 3 | [] | no_license | number=gets.strip
if number == number.reverse
puts "PALINDROME"
else
puts "NOT A PALINDROME"
end
| true |
9415489f5c3850ca60ada342fffd8ab580d3ab67 | Ruby | robotarmy/botnick | /read | UTF-8 | 184 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'socket'
if ARGV.empty?
puts "#{__FILE__} host port"
exit(1)
end
host = Addrinfo.tcp(ARGV[0],ARGV[1])
host.connect do |socket|
puts socket.gets
end
| true |
b2f8fd12e1fe3bbcb7d6fa37d420cdc939ff38ac | Ruby | CenturyLinkLabs/panamax-fleet-adapter | /app/models/service_linker.rb | UTF-8 | 943 | 2.75 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | module FleetAdapter
module Models
class ServiceLinker
using FleetAdapter::StringExtensions
def self.link(services)
new(services).link
end
def initialize(services)
@services = services
end
def link
@services.each do |parent_service|
parent_se... | true |
8d6479282a452791d17cf4eb6cdfcffa1e9897c5 | Ruby | Tkam13/atcoder-problems | /msolutions2020/d.rb | UTF-8 | 329 | 3.25 | 3 | [] | no_license | n = gets.to_i
as = gets.chomp.split.map(&:to_i)
money = 1000
stock = 0
(n-1).times do |i|
if as[i] < as[i+1]
stock += money / as[i]
money -= as[i] * (money / as[i])
elsif as[i] > as[i+1]
money += stock * as[i]
stock = 0
end
if i == n - 2
money += stock * as[i+1]
stock = 0
end
end
pu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.