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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
036fdea67f5022a5535fd5e690838b1eb5fbe9fd | Ruby | ext/hink | /spec/lib/plugins/feed_spec.rb | UTF-8 | 2,516 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
require 'liquid'
require "formatters/feed"
require 'plugins/feed'
describe Feed do
let(:feed_url) { "http://news.example.com" }
let(:feed_template) {
%(
<rss version="2.0">
<channel>
<title>News feed</title>
<link>http://news.example.com</link>
... | true |
ad4e3a926d497a71083f299d30a52a54fd8b45f4 | Ruby | chethan/ProjectEuler | /Ruby/ProblemSixteen.rb | UTF-8 | 288 | 3.6875 | 4 | [] | no_license | #2^(15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
#What is the sum of the digits of the number 2^(1000)?
require "Utils"
class Problem_Sixteen
def self.mine
p (2 ** 1000).to_digits.inject{|sum,i| sum +=i}
end
end
Problem_Sixteen.mine
| true |
3528d6d45c02561ec9c5142bfdb52bb052dcb393 | Ruby | danwhitston/2017-learn-to-program | /chap07/ex2.rb | UTF-8 | 282 | 3.375 | 3 | [
"MIT"
] | permissive | # Deaf grandma
your_sentence = ""
puts "AFTERNOON SONNY!"
until your_sentence == "BYE"
your_sentence = gets.chomp
if your_sentence == your_sentence.upcase
puts "NO, NOT SINCE " + (rand(99) + 1910).to_s + "!"
else
puts "HUH?! SPEAK UP, SONNY!"
end
end
| true |
aab77d8ac7f0b305a7983965faa4caa65bf4b5f1 | Ruby | bstiber/launch_school_exercises | /loops2/five.rb | UTF-8 | 921 | 4.71875 | 5 | [] | no_license | # The following code increments number_a and number_b by either 0 or 1. loop is used
# so that the variables can be incremented more than once, however, break stops the
# loop after the first iteration. Use next to modify the code so that the loop
# iterates until either number_a or number_b equals 5. Print "5 was... | true |
3c7ea1bc491d213a918b94a93ee55e91260e8ce8 | Ruby | HCoban/Training | /algorithms/random_subarray.rb | UTF-8 | 726 | 3.65625 | 4 | [] | no_license | def random_subarray(arr, n)
dup = arr.dup
r = rand(dup.length)
dup[0], dup[r] = dup[r], dup[0]
i = 1
while i < n
r = rand(dup.length-i) + i
dup[i], dup[r] = dup[r], dup[i]
i += 1
end
dup[0...n]
end
arr = [3, 7, 5, 11, 12]
freq = { 3 => 0, 7 => 0, 5 => 0, 11 => 0, 12 => 0 }
10000000.times d... | true |
c26dafd0184f0b8acd9a40b3cef3673835237352 | Ruby | tjarratt/transmogrifier | /lib/transmogrifier/nodes/value_node.rb | UTF-8 | 603 | 2.984375 | 3 | [
"MIT"
] | permissive | require_relative "node"
module Transmogrifier
class ValueNode < Node
attr_reader :parent_node
def initialize(value, parent_node=nil)
@value = value
@parent_node = parent_node
end
def find_all(keys)
return [self] if keys.empty?
raise "cannot find children of ValueNode satisfy... | true |
73356a6669812040deb8e8d3a7d3f5ac14af58b5 | Ruby | billuyadavg/ruby_code | /check_number_occurrence.rb | UTF-8 | 2,012 | 3.53125 | 4 | [] | no_license | #------------------------------------------------------------
# Checking occurrence of give number in give range of numbers
#------------------------------------------------------------
def is_validated
if $start_num > $end_num
re_enter_number
else
return false
end
end
def re_enter_number
puts " Please Ent... | true |
16bd380c61381e2be1911d1ed2eeae5ac112d992 | Ruby | yonjinkoh/assignment5 | /Parser.rb | UTF-8 | 234 | 3.34375 | 3 | [] | no_license | #Parses tweet lines
class Parser
def initialize(text)
@line = text
end
def receiver
receivers = @line.scan(/\@\w+/)
return receivers.map!{ |element| element.gsub(/@/, '') }
end
def sender
return @line[/\w+/]
end
end | true |
05a12a91ead76258fbbf8d21860e037eae341fac | Ruby | Saicheg/bsuir-courses | /2016/InnaKorotkova/hw-0/reverse.rb | UTF-8 | 1,035 | 3.546875 | 4 | [] | no_license | # 1/usr/bin/env ruby
operators = ["*", "/", "+", "-", "!"]
flag = true
count = 0
values = []
stack = []
def bitoperation(value, count)
code = value.to_s(2).reverse
if code.length > count && count.positive?
code.each_char do |i|
if count.nonzero? && code[i] == "1"
code[i] = "0"
count -= 1
... | true |
9039155b1c0309a73dacbea1d50145bb9ba8331b | Ruby | SettRaziel/wrf_forecast | /lib/wrf_forecast/forecast/wind_text.rb | UTF-8 | 3,068 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'wrf_forecast/data/directions'
module WrfForecast
module Text
# This class generates the forecast text for the wind speed
# and direction of the forecast
# warnings: all lesser warnings are a subset of the highest warning, that means
# only the worst warning needs to be shown, that can be d... | true |
0f00bc74b1070b0158fc79287b40fb4c882bb964 | Ruby | tamarlehmann/lrthw | /ex38.rb | UTF-8 | 1,176 | 3.921875 | 4 | [] | no_license | ten_things = "Apples Oranges Crows Telephone Light Sugar"
puts "Wait there are not 10 things in that list. Lets fix that"
stuff = ten_things.split(' ')
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy"]
# using math make sure there's 10 times
while stuff.length != 10
next_one = more_... | true |
2f202037a04e3525bac1abc1e0836e67df7b52a4 | Ruby | MattTennison/advent-of-code-2020 | /lib/day_sixteen.rb | UTF-8 | 3,293 | 3.28125 | 3 | [] | no_license | class TicketRule
attr_reader :name
def initialize(valid_ranges, name)
@ranges = valid_ranges
@name = name
end
def valid?(number)
@ranges.any? { |range| range.include?(number) }
end
end
class Ticket
def initialize(values)
@values = values
end
def invalid_values(rules)
@values.sele... | true |
298222c73f46a7b7a5501a79c0e4098de1326c62 | Ruby | keigori/marubatugame | /Output.rb | UTF-8 | 382 | 3.734375 | 4 | [] | no_license | #盤面を出力するクラス
class Output
def ban (*banmen)
3.times do |i|
3.times do |n|
print banmen[i][n]
print " "
end
puts ''
end
end
def win(k)
case
when k == 1
puts "先攻の勝利です"
when k == 2
puts "後攻の勝利です"
else k == 0
puts "引き分けです"
end
end
e... | true |
3c7957690f708a5b084d2028a054ea2a385fff02 | Ruby | diegofontecilla/BookMarkManager | /app.rb | UTF-8 | 639 | 2.578125 | 3 | [] | no_license | require 'sinatra/base'
require './lib/bookmark'
require 'uri'
require 'sinatra'
require 'sinatra/flash'
class BookmarkManager < Sinatra::Base
enable :sessions
register Sinatra::Flash
get '/' do
'Hello world'
end
get '/bookmark' do
@bookmarks = Bookmark.all
erb :index
end
post '/bookmark' do
puts para... | true |
fd88691ca995dcbced9947a203b0830cd1849d9e | Ruby | estein1988/backend_module_0_capstone | /day_6/ex_3_exercise.rb | UTF-8 | 1,068 | 4.03125 | 4 | [] | no_license | class MyCar
attr_accessor :color, :model
attr_reader :year
def initialize(year, color, model)
@year = year
@color = color
@model = model
@current_speed = 0
end
def info
puts "The #{year} #{color} #{model} is the car you will be driving today."
end
def speed_up(number)
@current_s... | true |
e91850a3bcbee3ec2cbf79005f8a00953089a0c3 | Ruby | ManuelAgustinLucero/ruby | /eje4.rb | UTF-8 | 280 | 3.40625 | 3 | [] | no_license | print "Porfavor ingrese un numero: "
numero= gets
numero=numero.to_i
resultado=0
i=0
while resultado <= numero
i+=1
resultado =resultado+i
end
# for i in(0..numero.to_i)
# puts i
# # result+=i
# end
puts "El resultado es #{resultado}"
# puts "El resultado es #{result}"
| true |
68cccb10ab58c8133ea35e7d5e2733632fca3ea9 | Ruby | arkency/zombiaki | /lib/zombie.rb | UTF-8 | 508 | 3.421875 | 3 | [] | no_license | class Zombie
def initialize(lives=1, name="zombie", moves_back_after_shoot=true)
@original_lives = lives
@lives = lives
@name = name
@moves_back_after_shoot = moves_back_after_shoot
end
def name
@name
end
def one_life_left?
@lives == 1
end
def hit
@lives -= 1
end
def d... | true |
85375be699a6193f8fd64a28142b8b34a6754733 | Ruby | bezrukavyi/design_patterns | /behavioral/interpreter/parser.rb | UTF-8 | 889 | 3.4375 | 3 | [] | no_license | class Parser
attr_accessor :token
OPERATIONS = %w(plus equal).freeze
def initialize(text)
@text = text
@tokens = text.scan(/\(|\)|[\w\.\*]+/)
end
def next_token
token = ParseSymbol.new(@tokens.shift).execute
parsed_tokens << token
token
end
def last_token
token = parsed_tokens[... | true |
0285f7fbc39be098e23e1673fa81d52ef2dde8b7 | Ruby | rodrigocezzar/programacaoorientadaaobjetos | /computer.rb | UTF-8 | 169 | 2.953125 | 3 | [] | no_license | class Computer
def turn_on
"turn on the computer kkkkk"
end
def shut_down
"shutdown the computer"
end
end
computer = Computer.new
puts computer.turn_on | true |
c6cfc4a77302d30641199464b681a7cfaf6efb62 | Ruby | Koda-thp/Morpion | /lib/app/board_case.rb | UTF-8 | 334 | 3.03125 | 3 | [] | no_license | # frozen_string_literal: true
class BoardCase
attr_accessor :case_id, :sign
# TO DO : la classe a 2 attr_accessor, sa valeur en string (X, O, ou vide), ainsi que son identifiant de case
def initialize(case_id, sign = " ")
# règle sa valeur, ainsi que son numéro de case
@case_id = case_id
@sign = sig... | true |
b3975e3638895b3dfc3000c5a71f25bb6ff543d8 | Ruby | arches/favorites | /lib/favorites.rb | UTF-8 | 339 | 2.703125 | 3 | [
"MIT"
] | permissive | module Favorites
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def favorite(finder, shortcuts)
singleton = (class << self; self; end)
shortcuts.each do |name, value|
singleton.send(:define_method, name, lambda{ send("find_by_#{finder}", value) })
end... | true |
d466cd26895f5f157d7d635d9090f04785ff6be1 | Ruby | jfield44/TropoSparkIntegration | /app/controllers/tropo_actions_controller.rb | UTF-8 | 2,140 | 2.515625 | 3 | [
"MIT"
] | permissive | require "net/http"
require "uri"
require 'open-uri'
class TropoActionsController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:create]
def create
message_id = params[:data][:id]
sender = params[:data][:personEmail]
room_id = params[:data][:roomId]
recieved_mess... | true |
304eb5d6e90252904f5bf48d4dd053a185bb63fe | Ruby | dsteed112/programming-univbasics-4-square-array-denver-web-033020 | /lib/square_array.rb | UTF-8 | 184 | 3.734375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(numbers)
counter = 0
sqr_numbers=[]
while numbers[counter] do
sqr_numbers<<numbers[counter]*numbers[counter]
counter += 1
end
sqr_numbers
end | true |
2160db391c74e6db1ce4d6a1e87a37d8f8609de3 | Ruby | parryjos1/sei35-homework | /warmups/week4/day_05_nucleotide_count/nucleotide_count.rb | UTF-8 | 499 | 3.390625 | 3 | [] | no_license |
def count_nucleotides dna
bases_count = {
'A' => 0,
'C' => 0,
'T' => 0,
'G' => 0
}
dna.each_char do |base|
if bases_count.key? base
bases_count[ base ] += 1
else
puts " #{base} is not a valid nucleotide "
end
end
... | true |
252282bd16ff3ce91d4560a15bc4f38e9e22c6d2 | Ruby | StarPerfect/flash_cards | /test/round_test.rb | UTF-8 | 2,125 | 3.640625 | 4 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/deck'
require './lib/turn'
require './lib/round'
class RoundTest < Minitest::Test
def setup
@card_1 = Card.new("What is the capital of Italy?", "Rome", :Geography)
@card_2 = Card.new("What is the capital of England?", "Lo... | true |
9f8fcc196aa2524d45d59aaedeeac83a7c1ae3ce | Ruby | djllap/crackin-the-code-interview | /Ch 1 - Strings/1.5.rb | UTF-8 | 721 | 4.03125 | 4 | [] | no_license | # Implement a method to perform basic string compression
# using the counts of repeated characters. For instance,
# the string 'aabcccccaaa' would become 'a2b1c5a3'. If the
# compressed string would not become smaller than the original
# string, return the original string. You can assume the string
# only has upper a... | true |
b9193011571c0db298dc6c9be005dba16cf6b22f | Ruby | efueger/donation-system | /lib/payment.rb | UTF-8 | 1,095 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'net/http'
require 'net/https'
require 'thank_you_mailer'
class Payment
attr_accessor :request
def initialize(request)
@request = request
end
def attempt
response = post('https://api.stripe.com/v1/charges')
if response.code == '200'
ThankYouMailer.send... | true |
99d740bf87b2bbd47068ab0d9a0ec07be2497a89 | Ruby | nkoehring/towerdefence | /classes/global_event_handler.rb | UTF-8 | 862 | 2.765625 | 3 | [
"ISC"
] | permissive | module TowerDefence
class GlobalEventHandler
include EventHandler::HasEventHandler
def initialize clock, handle_sdl_events=true
@clock = clock
@clock.enable_tick_events
@handle_sdl = handle_sdl_events
# Create an EventQueue to take events from the keyboard, etc.
# The events ar... | true |
6dd1b7172a39bdc4a1000a81781e48e12ed93542 | Ruby | kmhaines/renewable_energy_forecasting | /lib/repf/generic_data.rb | UTF-8 | 2,572 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'repf'
require 'repf/predictor/solar'
require 'csv'
require 'date'
module REPF
class GenericData
attr_accessor :data
def initialize( csv )
@data = to_array_of_hashes( clean( csv ) )
@data_by_date = {}
end
def dates
@data.collect {|dx| dx[:date]}.sort.uniq
end
def... | true |
c64817b97d52d41043dc15db9c452d3a64898785 | Ruby | uk-gov-mirror/ministryofjustice.specialist-publisher | /app/importers/cma_import/missing_body_generator.rb | UTF-8 | 1,117 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | class CmaImportMissingBodyGenerator
def initialize(create_document_service:, document_repository:)
@create_document_service = create_document_service
@document_repository = document_repository
end
def call(data)
document = create_document_service.call(data)
if needs_body_generating?(document)
... | true |
80443348240d9192f38d7738b9c632459ae5664a | Ruby | epang1/my-select-001 | /lib/my_select.rb | UTF-8 | 267 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
# your code here!
newlist = []
counter = 0
while counter < collection.count
if yield(collection[counter]) == true
newlist << collection[counter]
counter += 1
else
counter += 1
end
end
return newlist
end
| true |
e5de4c3047148227682afe0180ddc0a9a11d7a64 | Ruby | virajs/aws-sdk-core-ruby | /lib/aws/api/doc_example.rb | UTF-8 | 2,932 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | module Aws
module Api
class DocExample
include Seahorse::Model::Shapes
def initialize(obj_name, method_name, operation)
@obj_name = obj_name
@method_name = method_name
@operation = operation
end
def to_str
"resp = #{@obj_name}.#{@method_name}(#{params[1..... | true |
9d8dcbc31c3fa4c2cc9fc1f831c8691e07c2776d | Ruby | clburns107/web-app__todo-list | /app/models/assignee.rb | UTF-8 | 736 | 2.828125 | 3 | [] | no_license | class Assignee < ActiveRecord::Base
#Class Method for collection of an assignee's assignments
#
#takes an argument of a collection of assignments
#
#Returns all todo items assigned to an assignee
def self.todo_items(assignments)
all_tasks = []
assignments.each do |assignment|
all_ta... | true |
49ae37506816424795aa0ef831e648cd913e3cca | Ruby | postmodern/raingrams | /spec/probability_table_spec.rb | UTF-8 | 2,155 | 3 | 3 | [
"MIT"
] | permissive | require 'raingrams/probability_table'
require 'spec_helper'
describe ProbabilityTable do
before(:all) do
@grams = [:a, :b, :a, :a, :b, :c, :d, 2, 3, :a]
@table = ProbabilityTable.new
@grams.each { |g| @table.count(g) }
end
describe "empty table" do
before(:all) do
@empty_table = Probabil... | true |
8cb8331a64185e591103617a6499d068e00d3077 | Ruby | dhalai/hashids.rb | /lib/hashids.rb | UTF-8 | 6,081 | 3.046875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
class Hashids
VERSION = "0.0.5"
DEFAULT_ALPHABET = "xcS4F6h89aUbideAI7tkynuopqrXCgTE5GBKHLMjfRsz"
PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]
SaltError = Class.new(ArgumentError)
MinLengthError = Class.new(ArgumentError)
AlphabetError = Cl... | true |
2e6587c03cb1b72360c053bc843fc1a7acad0ad1 | Ruby | Terryben/LoLStatsApp | /test/concTest.rb | UTF-8 | 340 | 3.421875 | 3 | [] | no_license | def get_running_thread_count #borrowed from used Kashyap on Stack Overflow
Thread.list.select {|thread| thread.status == "run"}.count
end
x = Thread.new {
sleep 1
puts "Hello"
sleep 1
puts "Father"
}
y = Thread.new {
puts "My"
sleep 1
puts "good"
sleep 1
}
puts "Thread count is #{get_running_thread_count... | true |
1dac94de2b64436c0dd88e74c14002883515ea69 | Ruby | Sahej-Sandhu/W1D5 | /skeleton/lib/00_tree_node.rb | UTF-8 | 1,233 | 3.46875 | 3 | [] | no_license | require "byebug"
class PolyTreeNode
attr_reader :children
def initialize(value)
@value = value
@children = []
end
def parent
@parent
end
def children
@children
end
def value
@value
end
def inspect
if @children.empty?
@value.inspect
else
@children.inspect
... | true |
edbf53f2134631152456ecc4c872dc594f49e3d8 | Ruby | cin9247/MealMonster | /spec/models/order_spec.rb | UTF-8 | 1,638 | 2.84375 | 3 | [] | no_license | require_relative "../../app/models/order"
describe Order do
describe "#valid?" do
context "given no offerings" do
it "is not valid" do
subject.offerings = []
expect(subject.valid?).to eq false
end
end
context "given one offering" do
it "is valid" do
subject.offe... | true |
4a5c6a459ec34d62cac055788e7d0a34969af07f | Ruby | JoseVteVento/koan | /about_modules.rb | UTF-8 | 3,512 | 3.609375 | 4 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutModules < Neo::Koan
module Nameable
def set_name(new_name)
@name = new_name
end
def here
:in_module
end
end
def test_cant_instantiate_modules
assert_raise(___(NoMethodError)) do
Nameable.new
end
end... | true |
11e00b65a40963538fbe4a9747df48b50a85538f | Ruby | hannakalinowska/project-euler | /spec/problem037_spec.rb | UTF-8 | 632 | 3.15625 | 3 | [] | no_license | require 'spec_helper'
require 'problem037'
RSpec.describe "Truncatable primes" do
describe '#left_to_right_primes' do
it 'returns true' do
number = 3797
expect(left_to_right_primes(number.to_s)).to eq(true)
end
it 'returns false' do
number = 333
expect(left_to_right_primes(number... | true |
e5683367d1030b6596017e3c83f62c601707b04d | Ruby | trizen/sidef | /scripts/Tests/bitonic_sorter.sf | UTF-8 | 804 | 3.703125 | 4 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
# Bitonic sorter
# https://en.wikipedia.org/wiki/Bitonic_sorter
func bitonic_compare(x, bool) {
var dist = (x.len/2 -> int)
for i in ^dist {
if ((x[i] > x[i + dist]) == bool) {
x.swap(i, i+dist)
}
}
}
func bitonic_merge(x, bool) {
return(x) if (x.len == 1)... | true |
f1113716f9814d664cf4f472fd2af13138649c29 | Ruby | purchease/goose_project | /app/mutations/space/rule.rb | UTF-8 | 560 | 2.515625 | 3 | [] | no_license | class Space::Rule < Mutations::Command
optional do
integer :space_id
end
def validate
@space = Space.find space_id
end
def execute
if @space.space_skill = two_times
two_times
elsif [5,9,14,18,23,27,32,36,41,45,50,54,59].include?(space_id)
rip
elsif [5,9,14,18,23,27,32,36,41... | true |
a8aa403b7a3bca27a8ce37e145e5f6ffc9459f3f | Ruby | karlstav/fusuma | /lib/fusuma/device.rb | UTF-8 | 3,155 | 2.71875 | 3 | [
"MIT"
] | permissive | module Fusuma
# detect input device
class Device
attr_accessor :id
attr_accessor :name
attr_accessor :available
def initialize(id: nil, name: nil, available: nil)
@id = id
@name = name
@available = available
end
# @param [Hash]
def assign_attributes(attributes)
... | true |
8d4dab39f24f9b37e756dc0cfdae32bca1276bcf | Ruby | hashimoton/spelling_alphabet | /spec/converter_spec.rb | UTF-8 | 1,059 | 2.71875 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require 'spec_helper'
describe SpellingAlphabet do
describe 'Converter' do
context 'when generated without arguments' do
before do
@c = SpellingAlphabet::Converter.new
end
it 'converts letters to the corresponding words with the default word set' do
... | true |
d4b7a3f7bc304cfeca63a45d6da14156fe6feb0b | Ruby | trizen/sidef | /scripts/Tests/hash_concat.sf | UTF-8 | 338 | 3.171875 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## Hash.concat on various things, including non-hashes
#
var hash = Hash()
hash += 1
assert_eq(hash{"1"}, nil)
hash += Hash(:a => :b)
assert_eq(hash{:a}, :b)
hash += %w(c d) # 2-item array
assert_eq(hash{:c}, :d)
hash += "2":3 # an actual Pair
assert_eq(hash{"2"}, 3)
say "*... | true |
9f159738dd98fee239d1f2001051f50c2590a7bb | Ruby | nhutwkm/bai_tap_ruby | /Baitap/diadiem.rb | UTF-8 | 361 | 3.46875 | 3 | [] | no_license | class Database
def initialize
end
end
x=[2,4,5,6,8,12,7,12,15]
y=[4,5,2,9,6,14,78,9,2]
puts "Nhap toa do diem o:"
puts "nhap x:"
$xx= gets.chomp.to_i
puts "nhap y:"
$yy= gets.chomp.to_i
i=x.length-1
for i in (0..i)
r=Math.sqrt(($xx-x[i])*($xx-x[i])+($yy-y[i])*($yy-y[i]))
if r<=5
puts "[#{x[i]},#{y[i]}]"
end
p... | true |
bfc42531a96af33bce0607d51843da32bf797ddc | Ruby | jmmastey/theatre-calendars | /lib/parsers/auditorium.rb | UTF-8 | 993 | 2.59375 | 3 | [] | no_license | require_relative 'generic_parser'
class Auditorium < GenericParser
title 'Auditorium Theater'
location '50 East Congress Parkway, Chicago, IL'
uri 'http://auditoriumtheatre.org/wb/pages/home/performances-events/calendar.php?date=%Y-%m-01'
date_xpath "//table[@class='calendar']//td[@class='linkedweekendday' or... | true |
11c5b1895a3f5b449b09e2facfd6798ea85e7f29 | Ruby | saga1/double_write_cache_stores | /lib/double_write_cache_stores/client.rb | UTF-8 | 7,306 | 2.546875 | 3 | [
"MIT"
] | permissive | module DoubleWriteCacheStores
class Client # rubocop:disable Metrics/ClassLength
attr_accessor :read_and_write_store, :write_only_store
def initialize(read_and_write_store_servers, write_only_store_servers = nil)
@read_and_write_store = read_and_write_store_servers
if write_only_store_servers
... | true |
2bf9be674159d35442b45c9802b1d583cbad8e63 | Ruby | pantry/pantry | /lib/pantry/communication/reading_socket.rb | UTF-8 | 1,963 | 2.765625 | 3 | [
"MIT"
] | permissive | module Pantry
module Communication
# Base class of all sockets that read messages from ZMQ.
# Not meant for direct use, please use one of the subclasses for specific
# functionality.
class ReadingSocket
include Celluloid::ZMQ
finalizer :shutdown
attr_reader :host, :port
def ... | true |
aff593572efe0d37940793228e45e1a276662b4d | Ruby | voxpupuli/modulesync | /lib/modulesync/cli/thor.rb | UTF-8 | 1,048 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require 'thor'
require 'modulesync/cli'
module ModuleSync
module CLI
# Workaround some, still unfixed, Thor behaviors
#
# This class extends ::Thor class to
# - exit with status code sets to `1` on Thor failure (e.g. missing required option)
# - exit with status code sets to `1` when user calls `... | true |
206ccf675a22e1144564f8b139c7793980127a4a | Ruby | mthorry/programming_languages-web-071717 | /programming_languages.rb | UTF-8 | 1,005 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def reformat_languages(languages)
new_hash = {}
languages.each do |language_class, values|
# language_class = :oo; values = {:ruby=>{...}}
values.each do |language, info|
# language = :ruby; info = {:type=>"interpreted"}
info.each do |type, spec|
# type = :type; spec = "interprete... | true |
6f510473668148ab61bb82b1df27a50cda6da563 | Ruby | pithyless/lego | /lib/lego/model.rb | UTF-8 | 3,258 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'active_support/core_ext/hash/deep_merge'
module Lego
class Model
class ParseError < StandardError
def initialize(errors={})
@errors = errors
super(errors.inspect)
end
attr_reader :errors
end
private_class_method :new
class << self
def attribute(att... | true |
efb9b4bac3638d00b9b45cf7554d5c23da43a3f3 | Ruby | janvmusic/RubyRubyRubyRuby | /HardWay/ex20.rb | UTF-8 | 673 | 3.84375 | 4 | [] | no_license | input_file = ARGV[0]
def print_all(f)
puts f.read()
end
def rewind(f)
f.seek(0,IO::SEEK_SET)
end
def print_line(line_count,f)
puts "#{line_count} #{f.readline()}"
end
current_file = File.open(input_file)
puts "First let's print the whole file"
puts #a blank space
print_all(current_file)
puts "Now let's rewind,... | true |
04d1ec325f5b57fdf716b3915ea3136c9cad0caa | Ruby | MerStara/poseidon | /test/connection_test.rb | UTF-8 | 1,286 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class ConnectionTest < MiniTest::Test
def setup
@client = StringIO.new
@connection = ::Poseidon::Connection.new(@client)
end
def ready_to_read_test
# 默认可读
@connection.reset
assert(@connection.ready_to_read?)
@connection.send(:instance_variable_set, "@remain_body_si... | true |
771f58422f512353401b19cbf0d0f5a0d3cf8657 | Ruby | cbituin/oo-student-scraper-v-000 | /lib/scraper.rb | UTF-8 | 1,676 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
require 'nokogiri'
class Scraper
def self.scrape_index_page(index_url)
html = File.read(index_url)
roster = Nokogiri::HTML(html)
students = []
roster.css(".student-card").each do |student_card|
students << {
:name => student_card.css(".student-name").tex... | true |
41511afbe2cd594211e3636fd1b54f8b2744307e | Ruby | kenichi/h2 | /lib/h2/server/stream/request.rb | UTF-8 | 2,085 | 2.859375 | 3 | [
"MIT"
] | permissive | module H2
class Server
class Stream
class Request
# a case-insensitive hash that also handles symbol translation i.e. s/_/-/
#
HEADER_HASH = Hash.new do |hash, key|
k = key.to_s.upcase
k.gsub! '_', '-' if Symbol === key
_, value = hash.find {|header_key... | true |
5ad1a8ba833d97715ead84f383f0f8d76e2ecf84 | Ruby | moacirguedes/ZSSN-api | /app/controllers/concerns/reportable.rb | UTF-8 | 1,575 | 2.515625 | 3 | [] | no_license | module Reportable
extend ActiveSupport::Concern
def infection_status
if @survivor.infected
render json: {
error: 'This survivor is flagged as infected'
}, status: :forbiden
end
end
def percentage_infected
((Survivor.total_infected / Survivor.total_survivors) * 100).round(2)
e... | true |
73dc3644a7eadd1071240b3182d5e523cf9a326a | Ruby | CodeZeus-dev/leap-years | /lib/leap_years.rb | UTF-8 | 171 | 3.203125 | 3 | [] | no_license | def leap_year?(year)
return true if (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)
return false if (year % 100 == 0 && year % 400 != 0) || (year % 4 != 0)
end | true |
22f41d3c54701960786dd5104e1d345b39821b19 | Ruby | arslanyousaf77/coeus-ruby-basic-practice | /arrays.rb | UTF-8 | 659 | 3.6875 | 4 | [] | no_license | arr = Array.new
arr1 = Array.new(10) #specifiying size
names = Array.new(3, "coeus")
puts "#{names}"
nums = Array.new(10) { |e| e = e +1 }
puts "#{nums}"
nums1 = Array.[](1,2,3,4)
puts "#{nums1}"
nums2 = Array[10,20,30,"Arslan"]
puts "#{nums2}"
nums3 = Array(0..10)
puts "#{nums3}"
puts "#{nums3[2]}"
puts "#{num... | true |
ebad1da65c8691bd409dd824b11634145ce28200 | Ruby | foaf/foaftown | /2008/foafnews/news.bbc-linker.rb | UTF-8 | 4,329 | 2.765625 | 3 | [] | no_license | #!/usr/bin/ruby
#
# This is a quick hack utility to summarise the link structure of
# news.bbc.co.uk, and operates over a local crawled copy of the site
# (I used curlmirror), by default in the dest/ subdirectory.
#
# See below for a 'find' script that evokes this program on each file.
# Ultimately the ruby script sh... | true |
5802de54f6554e900d62bd5716892be308a01822 | Ruby | Salsa-Dude/review-flatiron | /Mod-1/Object-Oriented/mass-assignment.rb | UTF-8 | 847 | 3.71875 | 4 | [] | no_license |
# Create a Person class that accepts a hash upon initialization. The keys of the hash should conform to the attributes below:
# allowable properties:
class Person
attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed, :complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :... | true |
fc2b5db75715b29f1851532ef1199b31bd5e3fbe | Ruby | jfhinchcliffe/advent_of_code_2020 | /day_1/day_1.rb | UTF-8 | 803 | 3.359375 | 3 | [] | no_license | require_relative "../file_loader.rb"
lines = FileLoader.new("./day_1/input.txt").lines(->(x) { x.to_i })
# test_lines = [
# 1721,
# 979,
# 366,
# 299,
# 675,
# 1456,
# ]
TARGET_NUMBER = 2020
part_one_result = lines.reduce({}) do |acc, num|
complement = TARGET_NUMBER - num
break num * complement if a... | true |
caf67b5d41681be15ea577acf03a4c28e1b116e7 | Ruby | rodrigets/logica-de-programacao | /5 - Funções/funcoes04.rb | UTF-8 | 315 | 4.09375 | 4 | [
"MIT"
] | permissive | #Escreva uma função chamada fat que retorna o fatorial de um número. A função
#deve verificar se o parâmetro passado é inteiro e maior do que zero, caso contrário
#deve retornar -1.
def fat(x)
if x >= 0
fatorial = 1
for i in 1..x do
fatorial *= i
end
return fatorial
else
return -1
end
end
| true |
f12ac90176f5fc0631b6643cef20aed9eb94fb84 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/3143.rb | UTF-8 | 192 | 3.484375 | 3 | [] | no_license | def compute(a, b)
hamming = 0
if (a == b) then
return hamming # Optimisation
end
a.each_char.zip(b.each_char) do |l, r|
(l.nil? || r.nil?) || (l == r) || hamming += 1
end
hamming
end | true |
072973b2095f43e4a90523d0b8990614180f7cc1 | Ruby | olci34/MoDay | /lib/api.rb | UTF-8 | 1,151 | 2.859375 | 3 | [
"MIT"
] | permissive | class Api
@@api_key = "8f1dd76b"
def self.get_movie_by_id(id)
movie = Movie.find_by_imdbID(id)
if !movie #Avoids requesting API on already existed movies.
url = "https://www.omdbapi.com/?i=#{id}&apikey=#{@@api_key}"
response = HTTParty.get(url)
if response["... | true |
91d96849903eb6a83b3c3c06b3addc03e351f9dc | Ruby | cmb84scd/oo_relationships1 | /polymorphism.rb | UTF-8 | 914 | 3.453125 | 3 | [] | no_license | class ScrambledDiary
def initialize(contents)
@contents = contents
end
def read
@contents
end
def scramble(scrambler)
@contents = scrambler.scramble(@contents)
end
end
class ScrambleAdvanceChars
def initialize(steps)
@steps = steps
end
def scramble(contents)
plain_chars = conte... | true |
8899c5c2e44662b88bfeb4982d7d87c137697282 | Ruby | blacktm/tello | /bin/telloedu | UTF-8 | 751 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'tello/colorize'
require 'tello/version'
# Check Command-line Arguments #################################################
$edu = 'EDU'
usage = "Fly the Tello#{$edu} drone with Ruby!".bold + "\n
Usage: tello#{$edu.to_s.downcase} <command> <options>
[-v|--version]
Summary of com... | true |
17adb4511d60042e1b2b491b27e9b695b72f7d3a | Ruby | olook/chaordic-packr | /lib/chaordic-packr/buy_order.rb | UTF-8 | 1,181 | 2.875 | 3 | [] | no_license | require "chaordic-packr/packable_with_info"
require "chaordic-packr/cart"
module Chaordic
module Packr
class BuyOrder < PackableWithInfo
# @param [Cart] cart Shopping cart.
# @return [BuyOrder]
def initialize(cart)
@cart = cart if cart.instance_of? Cart
@tags = []
super(... | true |
c44f3fcbbf3a59ee0fe05fd19bb5c1ab8e821c1c | Ruby | jaredianmills/sql-crowdfunding-lab-nyc-web-062518 | /lib/sql_queries.rb | UTF-8 | 1,628 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
11e44b257ebd42c73f2f88d90b749bc6b8f5cdbd | Ruby | Junaidshah/ruby_programming | /objects_variables_classes.rb | UTF-8 | 630 | 3.6875 | 4 | [] | no_license | #!/usr/bin/ruby -w
class Customer
@@no_of_customers=0
def initialize(id, name, addr)
@cust_id =id
@cust_name =name
@cust_addr =addr
end
def display_details()
puts "Customer Id :#@cust_id"
puts "Customer Name:#@cust_name"
puts "Customer addr:#@cust_addr"
end
def total_no_of_customers... | true |
59142cc098ac20a16fbb219363a3bb30b9e761a5 | Ruby | code-builders/curriculum | /playground/chair.rb | UTF-8 | 424 | 2.734375 | 3 | [] | no_license | class Chair
attr_accessor :name, :weight, :color, :height, :rolls, :created_at
def initialize(attrs={})
# attrs is a hash
# {height: 30, name: "Vilgot", rolls: true}
@name = attrs[:name]
@weight = attrs[:weight]
@color = attrs[:color]
@height = attrs[:height]
@rolls ... | true |
111cf6b054d7d57a76a964a907d52b4831831b1b | Ruby | KoreanFoodComics/glimmer | /lib/command_handlers/models/widget_observer.rb | UTF-8 | 664 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class WidgetObserver
attr_reader :widget, :property
@@property_type_converters = {
:text => Proc.new { |value| value.to_s },
:items => Proc.new { |value| value.to_java :string}
}
def initialize model, property
@widget = model
@property = property
end
def update(value)
converte... | true |
03a8b88c6aeb54cc3ec577157a6aa3dd3b46de29 | Ruby | chrisotto/phase-0-tracks | /ruby/santa.rb | UTF-8 | 1,602 | 3.625 | 4 | [] | no_license | class Santa
attr_reader :age, :ethnicity
attr_accessor :gender
def initialize(gender, ethnicity)
puts "Initializing Santa instance ..."
@gender = gender
puts "Gender: #{@gender}"
@ethnicity = ethnicity
puts "Ethnicity: #{@ethnicity}"
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "... | true |
0f7af4e8ff392c25df20d84898f1dac183bc230a | Ruby | Alohata/Alohata.github.io | /ruby/hash_to_yaml.rb | UTF-8 | 3,981 | 2.75 | 3 | [] | no_license | # encoding: utf-8
require 'yaml'
languages = {
:bg => {
name: '',
image_title: 'Щастливи моменти',
title_1:'Безценни дни. Те всичките ухаят на море',
subtitle_1: 'Прозрачна вода. Лъскави вълни',
subtitle_2: 'Северния бряг на Оаху, Хавай',
block_1: '<p>Прозрачна вода, лъскави вълни, тръбни или бавни езди, риф или пяс... | true |
6727db76e391c2f114e434202a7520e17ebd2dd5 | Ruby | translunar/boolean | /lib/boolean/plot.rb | UTF-8 | 2,943 | 3.046875 | 3 | [] | no_license | require 'pry'
require 'rubyvis'
class Float
def exponent
return nil if self == Float::INFINITY || self == -Float::INFINITY
return 0 if self == 0
Math.log10(self).floor
end
end
module Boolean
module Plot
class << self
# Bin by order of magnitude.
# Pairs should consist of a p-value ... | true |
51a1ed9312eabd9bb819fa996dfc928a623a3eb6 | Ruby | skipsuva/advanced-hashes-hashketball-001-prework-web | /hashketball.rb | UTF-8 | 8,880 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def game_hash
{
:home => {
:team_name => "Brooklyn Nets",
:colors => ["Black","White"],
:players => [
{:player_name => "Alan Anderson",
:number => 0,
:shoe => 1... | true |
e6a6ab712e75a9270009987d8abe5a42a8c096bb | Ruby | benhutchinson/FAAST-Tube | /lib/train.rb | UTF-8 | 925 | 3.171875 | 3 | [] | no_license | class Train
MINIMUM_COACHES = 1
attr_reader :capacity, :passengers_in_train
def initialize(define_coaches = {})
@coach_count = define_coaches.fetch(:coaches, MINIMUM_COACHES)
@capacity = @coach_count * 40
@passengers_in_train = []
@at_a_station = false
end
def full?
@passengers_in_trai... | true |
b42de41db4deac230fbe268d359eb8c9c70de9ea | Ruby | VAGAScom/protoboard | /lib/protoboard/circuit_proxy_factory.rb | UTF-8 | 1,836 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Protoboard
##
# This module is responsible to manage a proxy module that executes the circuit.
module CircuitProxyFactory
class << self
using Protoboard::Refinements::StringExtensions
##
# Creates the module that executes the circuit
def create_mod... | true |
d351c428fafd506b157b98f11883b1e0a5ee07cb | Ruby | luther07/aws-sdk-for-ruby | /lib/aws/record/attribute_macros.rb | UTF-8 | 10,029 | 3 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" fil... | true |
8863f2964658dd0f6ce779af465c51e9ec95b115 | Ruby | dsulfaro/Algorithms-Projects | /heaps_and_heapsort/lib/heap_sort.rb | UTF-8 | 290 | 3.34375 | 3 | [] | no_license | require_relative "heap"
class Array
def heap_sort!
heap = BinaryMinHeap.new
# heapify array
while self.length > 0
heap.push(self.shift)
end
sorted = []
# pop off heap elements into array
while heap.count > 0
self << heap.extract
end
end
end
| true |
36c68c0939d442927fa4715959bc519ea4100f8e | Ruby | zfbtianya/code | /ruby/decate.rb | UTF-8 | 263 | 3.203125 | 3 | [] | no_license | #!/usr/bin/ruby
require "./Week.rb"
class Decade
include Week
no_of_yrs = 10
def no_of_months
puts Week::FIRST_DAY
number = 10*12
puts number
end
end
d1 = Decade.new
puts Week::FIRST_DAY
Week.weeks_in_month
Week.weeks_in_year
d1.no_of_months
| true |
787ad4ef0c2f91c0a024a456a92c30df91266c6e | Ruby | yR-DEV/MOD-1-PROJ-SW | /bin/run.rb | UTF-8 | 1,716 | 3.515625 | 4 | [
"Unlicense"
] | permissive | require_relative '../config/environment'
require 'pry'
require 'colored'
#binding.pry
class CLI
def self.return_or_quit
puts "\nType 'return' to return to the main menu. Type 'quit' to exit.\n\n".green.bold
response = gets.chomp
if response == "return"
self.main_menu
elsif response == "quit"
... | true |
6cb9d9eedc77b46cfc40037b4930dc94487ca978 | Ruby | Becojo/adventofcode | /2022/6.rb | UTF-8 | 193 | 3.203125 | 3 | [] | no_license | input = ARGF.read.strip
def find(input, n)
input.size.times do |i|
if input[i...i+n].chars.uniq.size == n
return i + n
end
end
end
puts find(input, 4)
puts find(input, 14)
| true |
d7123ce921258361feefe89dea3d444d4d4d6d80 | Ruby | shinwang1/phase-0 | /week-5/calculate-mode/my_solution.rb | UTF-8 | 3,093 | 3.734375 | 4 | [
"MIT"
] | permissive | # Calculate the mode Pairing Challenge
# I worked on this challenge [by with: Scoot Southard]
# I spent [1.5] 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
#... | true |
4a5858f72b186e6e2b37d0000fa5bec426c9375a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/bf779a88fd014ea697d84450aa72e7f3.rb | UTF-8 | 1,636 | 4.21875 | 4 | [] | no_license | # Pseudocode
# Need to make a program that can calculate the difference between two DNA strand
# Only going to worry about sequences of equal length
# If a user inputs 2 strings of letters - a sequence
# Return an integer that is the amount of differences between the two strings
# New algorithm idea: Compare at each ... | true |
6620e07fe50c21752cc4e2f91c318065af3e562b | Ruby | Lantoniaina/mercredi | /pyramide.rb | UTF-8 | 209 | 3.375 | 3 | [] | no_license | def num
puts "Combien d'étages voulez-vous pour votre pyramide,qui varie de 5 à 25: "
num =gets.chomp.to_i
diez = 1
while num > 0
puts " "*num << "#" *diez
num -= 1
diez += 2
end
end
puts num | true |
91d61cf28fbba1bd53d665f2abb668e54b67b066 | Ruby | danielkza/bolsa-capital | /lib/tasks/simulate.rake | UTF-8 | 1,057 | 2.578125 | 3 | [] | no_license | require 'simplify'
namespace :simulate do
desc 'TODO'
task :payment do
Simplify::public_key = "sbpb_N2YyMWMwNmMtNGRiOS00MjBhLTk1NzAtNTQ4NGEzZGUwNDUy"
Simplify::private_key = "ERInD4vAyClXX8LVfMVRBqAKpj5teXHGsfWzcNRT0b15YFFQL0ODSXAOkNtXTToq"
new_payment("5105105105105100", 2756)
end
task :populate do
... | true |
6f949e257f09331ba9a1d9a05ce77970b3c753fd | Ruby | szagar/pyzts | /daemons/ibgw2filed/lib/setup_queue/message.rb | UTF-8 | 750 | 2.8125 | 3 | [] | no_license | require "json"
require_relative "../log_helper"
module SetupQueue
class Message
include LogHelper
def initialize(params)
@command = params[:command]
@data = params[:data]
end
def to_json
{command: @command, data: @data}.to_json
end
def self.decode(json_msg)
warn ... | true |
7b43c707e18a7fbe13869ac852555190f8cf23dd | Ruby | kurt-friedrich/Blackjack- | /card.rb | UTF-8 | 551 | 3.328125 | 3 | [] | no_license | class Card
attr_accessor :face, :suit, :value
def initialize(face, suit)
self.face = face
self.suit = suit
self.value = infer_value
end
def self.suits
%w(Clubs Spades Hearts Diamonds)
end
def self.faces
%w(2 3 4 5 6 7 8 9 10 J Q K A)
end
def infer_value
if face.to_i > 0
... | true |
8f1d0258b903eb4e349e56ee2b22d81ceff081c2 | Ruby | miochung7/Ruby_Challenges | /6kyu Array-Diff.rb | UTF-8 | 954 | 4 | 4 | [] | no_license | =begin
Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.
It should remove all values from list a, which are present in list b.
array_diff([1,2],[1]) == [2]
If a value is present in b, all of its occurrences must be removed from the other:
arra... | true |
e8cf2d36380cfa00bff0533f4345a2bdf8373cf0 | Ruby | Schofield88/Smart_Pension_test | /spec/printer_spec.rb | UTF-8 | 697 | 2.65625 | 3 | [] | no_license | require './lib/printer'
describe Printer do
let (:printer) { Printer.new }
let (:total) { [
{:url=>"/about", :visits=>1},
{:url=>"/help", :visits=>6},
{:url=>"/about/2", :visits=>3}
]
}
let (:unique) { [
{:url=>"/about", :ips=>["451.106.204.921"]},
{:url=>"/about/2", :ips=>["382.335.... | true |
bb4c079903c9283bddbd5d9a573465a48588f5c6 | Ruby | self20/broad | /spec/support/fake_servers/fake_omdb.rb | UTF-8 | 543 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'sinatra/base'
class FakeOmdb < Sinatra::Base
get '/' do
imdb_id = params["i"]
data = omdb_data(imdb_id)
content_type :json
[200, data]
end
get '/*' do
raise NotImplementedError, "'#{self.url}' is not implemented in this fake"
end
private
def omdb_data(imdb_id)
file_path ... | true |
07d87faebbf10c4af5a3287789f0faec089cfc17 | Ruby | e-g-r-ellis/ruby-native-pallendrome | /lib/mygem/pallendromelib.rb | UTF-8 | 165 | 2.90625 | 3 | [] | no_license | require 'mygem/pallendrome'
def first_ruby_call
puts "Calling ruby pallendrome with 'hello'"
result = pallendrome "hello"
puts "Ruby result: "+result.to_s
end
| true |
f80494a767796f29a36f5db4d66ffaf7fd15b156 | Ruby | arturocedilloh/LS_101 | /lesson_4/selection_transformation.rb | UTF-8 | 3,231 | 4.09375 | 4 | [] | no_license | =begin
produce = {
'apple' => 'Fruit',
'carrot' => 'Vegetable',
'pear' => 'Fruit',
'broccoli' => 'Vegetable'
}
def select_fruit(fruit_list)
hsh = {}
fruit_list.each do |k,v|
if v == 'Fruit'
hsh[k] = v
end
end
hsh
end
puts select_fruit(produce) # => {"apple"=>"Fruit", "pear"=>"Fruit"}
p... | true |
e84ad79e2a30867db2449c4cddd43c1bf7898394 | Ruby | MDes41/class_exercises | /refactoring/pattern_refactor/pattern_refactor.rb | UTF-8 | 399 | 3.234375 | 3 | [] | no_license | class Engine
def core_weight
250
end
def propeller_weight
50
end
def weight
core_weight + propeller_weight
end
end
class Plane
attr_reader :engine
def initialize
@engine = Engine.new
end
def body_weight
1000
end
def engine_count
2
end
def weight
body_weigh... | true |
2040b612d7cf00e1e83ef2033866a413b1833469 | Ruby | nbriar/snapapp_api | /test/models/hyperlink_test.rb | UTF-8 | 999 | 2.578125 | 3 | [] | no_license | # == Schema Information
#
# Table name: hyperlinks
#
# id :bigint(8) not null, primary key
# url :string
# text :string
# target :string
# action :string
# created_at :datetime not null
# updated_at :datetime not null
#
require 'test_helper'
class HyperlinkTe... | true |
5b8804ab00bd883e3b51bef5db6d444015901a3a | Ruby | thinkerbot/tap | /tap-server/lib/tap/controller/extname.rb | UTF-8 | 790 | 2.53125 | 3 | [
"MIT"
] | permissive | module Tap
class Controller
# Add handling of extnames to controller paths. The extname of a request
# is chomped and stored in the extname attribute for use wherever.
module Extname
# Returns the extname for the current request, or nil if no extname
# was specified in the paths_i... | true |
6de86c689354c1ae41d634f151660901a7751e7c | Ruby | snakeyworm/mulparse | /test/ruby_comments_test.rb | UTF-8 | 170 | 2.578125 | 3 | [
"MIT"
] | permissive |
=begin
=end
# Hi
# Hello world!
# foo
# oof
# Hi =end
#
# quark
# Not a
# Block comment
# Hello world!
# foo
# blather
# bar =begin
#
| true |
f918ee485472ae93d16817c773d0e506c94cbc76 | Ruby | avdgaag/laze | /lib/laze/plugins.rb | UTF-8 | 1,524 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | module Laze
# Plugins provides access to all Laze plugins.
#
# A plugin is a simple decorator that can wrap an Item object. Every plugin
# itself can tell you to what objects it applies, and an Item includes
# all available plugins by using the +include_plugins+ macro:
#
# class MyItem < Item
# in... | true |
8655e2847ba4ca97a4598e29e3e293e90e9d4d46 | Ruby | williamkennedy/Euler-Solutions | /EulerProblem3.rb | UTF-8 | 315 | 3.71875 | 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 prime_factors(n)
return [n] if Prime.prime?(n)
Prime.prime_division(n)
end
puts prime_factors(600851475143).inspect
#refactor to only return the largest Prime factor | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.