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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a9f9325fcd6eef0155e365b47da906d8692e1c28 | Ruby | ug-training/learning | /rubylrn/subcl.rb | UTF-8 | 374 | 3.5625 | 4 | [] | no_license | class Contant
@@value=5
def initialize(len,width)
@len = len
@width = width
end
def area
puts @@value=@len*@width*@@value
end
def printv
puts "#{@len}\n#{@width}"
end
end
class Thin < Contant
def initialize(val)
@val = val
super(val,val)
end
def printval
puts @val
end
end
s=Thin.ne... | true |
4f8eb4c862e88edbdbc8313360e35234a2729533 | Ruby | inohiro/atcoder | /beginner_023/ex2.rb | UTF-8 | 953 | 3.734375 | 4 | [] | no_license |
def main
n = gets.strip!.to_i
s = gets.strip!.to_s
if n < 1 or n > 100
puts '-1'
return
end
unless valid_s?(s, n)
puts '-1'
return
end
accessory = ['b']
return if same_name?(accessory, 0, s)
(1..n).each do |i|
case i % 3
when 1 # 3n + 1
accessory.unshift 'a'
ac... | true |
efebc90ec79fb9ec596e95b05ac4bfaaa756fd35 | Ruby | uddin0786/rubyPrograme | /unique.rb | UTF-8 | 186 | 3.1875 | 3 | [] | no_license | class Unique
def uniqk
numbers = [1, 4, 2, 4, 3, 1, 5]
target = []
numbers.each {
|x| target << x unless target.include?(x)
}
puts target
end
end
Unique.new.uniqk | true |
02a19086a15ceb7dc15f6908db9c1a3637ea753b | Ruby | imightbeinatree/comic_reads | /app/helpers/roles_helper.rb | UTF-8 | 3,141 | 2.875 | 3 | [] | no_license | module RolesHelper
# Creates checkboxes for a has and belongs to many relationship between ?
#
# @param obj An instance of a model with the specified field
# @param column The attribute of the obj parameter used to determine if the assignment_object is assigned to the obj parameter
# @param assignment_objects A list of... | true |
9e4e199dab0ff4264a6bc36084fb65838f110084 | Ruby | ingdavidjauregui/ruby | /david.rb | UTF-8 | 1,120 | 2.578125 | 3 | [] | no_license | {\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf760
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partighte... | true |
b954d9ba023fbbf695fa1a1d01f976eb99de633d | Ruby | Karthick-sketch/Solitare-Game | /solitare/Solitaire.rb | UTF-8 | 9,715 | 2.734375 | 3 | [] | no_license | require 'fox16'
include Fox
require 'colorize'
require 'win32/sound'
include Win32
$cardvalue = ["A",2,3,4,5,6,7,8,9,10,"J","Q","K"]
$app = FXApp.new
$app.create
def mbox(picName,caption,message)
pic=File.open("C:/Users/ajith/OneDrive/Desktop/card/#{picName}.png","rb")
pic2=FXPNGIcon.new($app, pic.... | true |
aa01709493acc2b0dcac245d17b76f60255bc9b7 | Ruby | AdrianPardo99/metaheuristics | /actividadP1/tspRMHC.rb | UTF-8 | 1,250 | 2.6875 | 3 | [] | no_license | cities={(i,[j,c])_0,(i,[j,c])_1,...,(i,[j,c])_n}
# Conjunto de ciudades donde
# => i es el indice del grafo (ciudad)
# donde entre parentesis son
# => => j es el indice del siguiente grafo (ciudad)
# => => c es el costo de trasladarse de i a j
i_city=cities[random%cities.lenght]
path=[i_city]
lim_iterator=M
iterato... | true |
ce68a11705f6a4ea1e75f1b7879669e1dceb8680 | Ruby | JingfZhang/math-game | /game.rb | UTF-8 | 1,175 | 3.8125 | 4 | [] | no_license | require "./player"
require "./question"
class Game
def initialize
p1 = Player.new("player1")
p2 = Player.new("player2")
@players = [p1, p2]
end
def play
round_count = 0
while (!game_over?)
round_count += 1
turn = Turn.new(@players[0], round_count, Question.new)
puts "=====... | true |
0871dea5adf9bbd3e29b11b105584b0da461abf5 | Ruby | tonnybrito/ruby | /carro/pessoa/cadastro.rb | UTF-8 | 583 | 2.515625 | 3 | [] | no_license |
require 'net/http'
require 'date'
require 'time'
require './pessoa'
# Cadastro
class Cadastro
attr_accessor :autocode, :dado_pessoal, :especialidade,
:plantao, :horarios
def initialize(cadastro = {})
@autocode = cadastro [:autocode]
@dado_pessoal = cadastro [:dado_pessoal]
... | true |
6f201f16be7530a932bea0f15439f1156a8b68e9 | Ruby | thorrsson/Monitoring | /write_to_graphite.rb | UTF-8 | 1,620 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Writes a passed value to the graphite server of your choosing.
# * *Arguments:
# host <h>
# port<p>
# tree(Structure to create in Graphite) <t>
# value (to be written to graphite <v>
#
# Examples:
# +require './write_to_graphite'+
# +graphite = Write_To_Graphite::Graph.new('graphite.yourdom... | true |
b2ba3c7d649ad371f74b168380dd9da06436d9d8 | Ruby | julesnuggy/oystercard_challenge_2 | /spec/oystercard_spec.rb | UTF-8 | 3,412 | 2.921875 | 3 | [] | no_license | require 'oystercard'
describe Oystercard do
#oystercard = Oystercard.new
subject(:oystercard) {described_class.new}
subject(:oystercard_min) {described_class.new}
subject(:oystercard_empty) {described_class.new}
let(:station_dbl) { double(:station_dbl, name: "Paddington") }
let(:station_dbl_2)... | true |
008b26756f79523c27e5dfad80c7cdbdfb0f8687 | Ruby | cheokman/code_lab_2016 | /entity_relational_mapping/lib/erm/attribute/accessor.rb | UTF-8 | 785 | 2.671875 | 3 | [
"MIT"
] | permissive | module ERM
class Attribute
module Accessor
attr_reader :name
attr_reader :instance_variable_name
def self.extended(base)
super
name = base.options.fetch(:name).to_sym
base.instance_variable_set('@name', name)
base.instance_variable_set('@instance_variable_name',... | true |
9d5474c4c5e62a316a81f610e9280984a725d92f | Ruby | ianwhite/dummy_player | /players/player.rb | UTF-8 | 207 | 3.203125 | 3 | [] | no_license | require 'ian_hangman'
class Player
def name
"Ian White"
end
def take_turn(state, guesses)
@hangman = IanHangman.new(state.length) if guesses.empty?
@hangman.answer(state, guesses)
end
end
| true |
be5e5d3c93c50b091e413ad2e1fba0522c591f92 | Ruby | Artoria/CocoDK | /coco.rb | UTF-8 | 4,153 | 2.546875 | 3 | [] | no_license | ENV['path'] = "#{ENV['path']};C:\\railsinstaller\\DevKit\\mingw\\bin"
class Expr
attr_accessor :obj, :scope
def initialize(obj, scope = nil)
@obj = obj
@scope = scope
end
alias to_s obj
[:+, :-, :*, :/, :==, :!=, :%, :^, :&, :|].each{|x|
define_method(x){|obj|
a = obj.... | true |
fd57df291d9c0022dd294583d457ba2f758a8992 | Ruby | ddmaness/app-academy-exercises | /ruby-exercises/data-structures/skeleton/lib/00_tree_node.rb | UTF-8 | 1,412 | 3.765625 | 4 | [] | no_license | class PolyTreeNode
def initialize(value)
@value = value
@parent = nil
@children = Array.new()
end
def parent
return @parent
end
def children
return @children
end
def value
return @value
end
def parent=(node)
unless @parent =... | true |
f2879a7cf8f521050396b96db0980566465c9eb4 | Ruby | LisaLouAEH/mercredi_s1 | /full_pyramide.rb | UTF-8 | 750 | 3.875 | 4 | [] | no_license | =begin
Faire une pyramide complete.
=end
def pyramide
puts "HI ! how many floor do you want (only between 1 to 25) ?"
print "-->"
number = gets.to_i
hash = 1
spaces = number
floor = 0
if number < 1
puts "We said more than 1 floor min..."
elsif n... | true |
8284a786b381cc133a31fba15c19d177e43c58fa | Ruby | trevorsmith1667/aa-classwork | /W4D4/TDD/spec/array_spec.rb | UTF-8 | 2,072 | 3.765625 | 4 | [] | no_license | require "rspec"
require "array"
describe Array do
let(:my_arr) {[1, 2, 1, 3, 3]}
let(:my_neggy) {[-1, 1, 2, -2, 3,-3]}
let(:my_bupkis) {[-1, 0, 80, -75, 4, 10]}
let(:my_grill) {[
[0, 1, 2],
[0, 1, 2],
[0, 1, 2]
]}
let(:my_enron_stock) {[2, 1, 100, 4... | true |
a491414702d3781018ed1cfe73a7d5c1c385c979 | Ruby | alf-tool/alf-core | /lib/alf/aggregator/sum.rb | UTF-8 | 674 | 3.078125 | 3 | [
"MIT"
] | permissive | module Alf
class Aggregator
#
# Defines a `sum()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.sum{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :total => sum{ qty })
#
class Sum < Aggregator
# Returns ... | true |
0bdc98ad1b1fc51a5c118ff9fcc34929b6cebf8f | Ruby | VladDaImpaler18/anagram-detector-onl01-seng-pt-032320 | /lib/anagram.rb | UTF-8 | 295 | 3.546875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(list_of_words)
output = []
list_of_words.each do |word|
output << word if word.split("").sort == @word.split("").sort
#binding.pry
end
output
end
end | true |
9c47f36e75975fd034d2be046ac9e9453a75a18d | Ruby | bebbs/takeaway-challenge | /lib/menu.rb | UTF-8 | 582 | 3.640625 | 4 | [] | no_license | class Menu
require 'csv'
def initialize(restaurant)
@dishes = []
@name = restaurant
load_menu(restaurant)
end
attr_reader :name, :dishes
def load_menu(restaurant)
CSV.foreach("#{restaurant}.csv", {col_sep: ','}) do |line|
populate_dish(line)
end
end
def populate_dish(item)
... | true |
6670864b1c77b4af5beeb05528dd1249ae371f1a | Ruby | MarshaAnnon/the-best-botanical-gardens-USA | /lib/scraper.rb | UTF-8 | 516 | 2.6875 | 3 | [
"MIT"
] | permissive | class Scraper
TheActiveTimes_URL = "https://www.theactivetimes.com/travel/best-botanical-gardens-us-gallery"
def self.scrape_TheActiveTimes
html = open(TheActiveTimes_URL)
doc = Nokogiri::HTML(html)
doc.css(".slide-main").each do |garden_info|
title = garden_info.css(... | true |
89dc7b739b8a041aa6cba9144278907f0100d155 | Ruby | producthunt/ShareMeow | /app/image.rb | UTF-8 | 747 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'securerandom'
module ShareMeow
class Image
# Zooming in makes text more crisp
DEFAULT_OPTIONS = { zoom: 2 }
attr_reader :template
def initialize(params)
@template = template_class(params['template']).send(:new, params)
end
def to_jpg
options = DEFAULT_OPTIONS.merge(wid... | true |
67ffd806b822c6b7737c8c66f4c16a7eed394496 | Ruby | jsiny/101_programming_foundations | /exercises/03_easy_2/ex_9.rb | UTF-8 | 416 | 3.9375 | 4 | [] | no_license | name = "Bob"
save_name = name
name.upcase!
puts name, save_name
# This program prints out:
# BOB
# BOB
# The reason behind this is that String#upcase! is a destructive method.
# As such, it mutated the caller (name), which means that the space in
# memory was changed.
# As save_name points to the same space in memor... | true |
3afb06af87b403741cb9b27a456524af49ab9aed | Ruby | saranderson13/keys-of-hash-online-web-prework | /lib/keys_of_hash.rb | UTF-8 | 275 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Hash
def keys_of(*arguments)
# returns an array of every key with a value that matches an argument
array_of_keys = []
arguments.each do |arg|
keys.each { |key| array_of_keys << key if arg == self[key] }
end
array_of_keys
end
end
| true |
019bbb60506552863344e0af6181c694c7b3d87c | Ruby | taylorfinnell/kayvee | /lib/kayvee/store.rb | UTF-8 | 2,329 | 2.96875 | 3 | [
"MIT"
] | permissive | module Kayvee
# Represents a simple key value store. Provides multiple backing stores.
#
# @example Basic Useage
# store = Kayvee::Store.new(:s3, aws_access_key: '', ... )
# key = store.set('hello', 'world')
# key.read
# => 'world'
#
# store = Kayvee::Store.new(:redis, host: 'redis://locah... | true |
5216e0770f085f1183c018340a73371dc9c505c7 | Ruby | RudiBoshoff/ruby-exercises | /procExample.rb | UTF-8 | 537 | 4.53125 | 5 | [] | no_license | # Passing a Proc in a method
def action someProc
someProc.call
end
hello = Proc.new do
puts "Hello World!"
end
# Passing a Proc that has a parameter in a method
def action2 (someProc, name)
someProc.call(name) # have to pass the name to the call function
end
bye = Proc.new do |name|
puts "Ewwww that is a te... | true |
e2c71a8e8d7276fa316b306675e0bb7706c62adf | Ruby | darkelv/lessons | /Lesson_1/area_of_a_triangle.rb | UTF-8 | 256 | 3.328125 | 3 | [] | no_license | puts "Введите основание треугольника"
base = gets.to_f
puts "Введите высоту треугольника"
height = gets.to_f
area = 0.5 * base * height
puts "Площадь треугольника #{area.round(2)}"
| true |
ef53e81275f66fffa9b9037561411fcb014eaaf7 | Ruby | Eractus/data_structures | /QuickSort/lib/quick_select.rb | UTF-8 | 1,086 | 3.765625 | 4 | [] | no_license | #Write an in-place instance method on the Array class that will find the 'kth' smallest element in 'O(n)' time. You will likely want to use a partition method similar to that of QuickSort! For a bous, how can we eliminate any extra space cost.
class Array
def quick_select(array, k)
left = 0
right = self.lengt... | true |
be4d8568ae81f17ff211ffc65a7de995a3660d8d | Ruby | jaredm-ibm/ibm-cloud-sdk-ruby | /lib/ibm/cloud/sdk_http/base_collection.rb | UTF-8 | 4,437 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | # typed: true
# frozen_string_literal: true
require_relative 'base_http_mixin'
require_relative 'has_child'
module IBM
module Cloud
module SDKHTTP
# Container that encapsulates the VPC API.
# This class is used as a base for collection APIs.
# @param parent [Object] The parent instance in the ... | true |
f76abf9f52625a89bc3c0d844a099e94d5b000cd | Ruby | sobopla/placeholder | /app/helpers/spotify_helper.rb | UTF-8 | 2,660 | 2.890625 | 3 | [] | no_license | require 'net/http'
require 'json'
module SpotifyHelper
def self.get_token
encode = (Base64.encode64(ENV["SPOTIFY_ID"] + ':' + ENV["SPOTIFY_SECRET"])).gsub("\n",'')
uri = URI.parse("https://accounts.spotify.com/api/token")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Basic #{encode}... | true |
88e76664c454d2bfc06257660b910a358c4c316e | Ruby | hackershare/hackershare | /db/migrate/20200928161133_add_fuzzywuzy.rb | UTF-8 | 1,667 | 2.6875 | 3 | [
"MIT"
] | permissive | class AddFuzzywuzy < ActiveRecord::Migration[6.0]
def change
enable_extension :fuzzystrmatch
execute(<<~SQL)
CREATE OR REPLACE FUNCTION ratio(l text, r text) RETURNS int
LANGUAGE plpgsql IMMUTABLE
AS $$
DECLARE
diff int; -- levenshtein编辑距离
... | true |
680bed2fdb13a0871c494104b1cb8d751b65709a | Ruby | neilmarion/qtest | /lib/word_helper.rb | UTF-8 | 543 | 2.75 | 3 | [] | no_license | module WordHelper
def self.tally(some_string)
words = some_string.split(' ')
frequency = Hash.new(0)
words.each { |word| frequency[word.downcase.to_sym] += 1 }
return frequency
end
def self.filter(phrase, black_list)
black_list.split.each {|replacement|
phrase.gsub!(/(#{replacement})/i,... | true |
156257ac7e990119defe67b930c1b2b1ebc1b582 | Ruby | alexandru-calinoiu/simple_delegator_example | /burger_decorator.rb | UTF-8 | 252 | 2.8125 | 3 | [] | no_license | require_relative 'burger'
require 'delegate'
class BurgerDecorator < SimpleDelegator
def initialize(burger)
@burger = burger
super
end
end
burgerDecorator = BurgerDecorator.new(Burger.new)
puts burgerDecorator.cost
puts burgerDecorator.calories | true |
39d65b3fcbb73822f43cfa820e26e643a909357f | Ruby | Balaraju/Task | /task66.rb | UTF-8 | 351 | 4.03125 | 4 | [] | no_license |
#Below method is Block method
name1=lambda do
|name|
puts "Hello #{name} Welcome to Ruby on Rails"
end
puts "HELLO PLZ ENTER YOUR NAME :"
#using Below Method we can read entered name
enter_name=gets.chomp
#uisng Below Method we can pass the enterd variable into Block Me... | true |
fee9b85291b1102e2a3b2916c6bfc60b498574c5 | Ruby | quartzmo/butterfly_net | /test/test_case_test.rb | UTF-8 | 6,539 | 2.546875 | 3 | [
"MIT"
] | permissive | require "test/unit"
$: << File.expand_path(File.dirname(__FILE__))
$: << File.join(File.expand_path(File.dirname(__FILE__)), File.join("..", "lib"))
require "butterfly_net/file_writer"
require "butterfly_net/definitions"
require "butterfly_net/test_unit_method"
require "butterfly_net/test_unit_adapter"
require "butterf... | true |
98efe6f780f5b3e48d90251b950d34e595671b64 | Ruby | lilliealbert/pine_ruby_exercises | /pine_ch05s6b--better_fav_number.rb | UTF-8 | 545 | 4.34375 | 4 | [] | no_license | #and here's my one-upping favorite number machine
puts "Hey, so what's your favorite number?"
fav_number = gets.chomp.to_i + 1
puts "Really? Because you might get a lot further in life with a favorite number like " + fav_number.to_s + " . But that's just my opinion. What do I know? I'm just a passive-aggressive comput... | true |
8c59a507a1dfe66294c2dc927863b81c13520a1b | Ruby | Nicholas-Maxwell/array-CRUD-lab-v-000 | /lib/array_crud.rb | UTF-8 | 989 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def create_an_empty_array
[]
end
def create_an_array
fruits = [ "orange" , "apples" , "coconut" , "mangos"]
end
def add_element_to_end_of_array(array, element)
fruits = [ "orange" , "apples" , "coconut" , "mangos"]
fruits.push("arrays!")
end
def add_element_to_start_of_array(array, element)
fruits = [ "orange"... | true |
37a73397f844df61a1ff4df5e27894fdffaad7f5 | Ruby | rerack-me/rerack.me | /test/models/group_test.rb | UTF-8 | 1,727 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class GroupTest < ActiveSupport::TestCase
def setup
setup_players_and_global
end
test "add player to group by username" do
gr = FactoryGirl.create(:group)
gr.add_player_by_username(@a.username)
assert gr.players.include? @a
assert !gr.add_player_by_username(@a.userna... | true |
0f14991520be826dcb582c1ac6fce74de8154a86 | Ruby | bglusman/s10-mod | /lib/poker_help/card.rb | UTF-8 | 4,583 | 3.4375 | 3 | [] | no_license | module PokerHelp
# FORKED FROM RUBY-POKER GEM by Rob Olson
# Copyright (c) 2008, Robert Olson
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain t... | true |
f0edae555639dc2e041bb19f055b2afdef4aef79 | Ruby | nickklesaris/propertymgt | /spec/features/add_a_building_spec.rb | UTF-8 | 1,677 | 2.6875 | 3 | [] | no_license | require 'spec_helper'
feature 'add a building', %Q{
As a real estate associate
I want to record a building
So that I can refer back to pertinent information
} do
#Acceptance Criteria:
# I must specify a street address, city, state, and postal code
# Only US states can be specified
# I can opt... | true |
fb19c830baf8997737b556189b6ed77651e81f4d | Ruby | Cleyrauz/Functions_Lab-1 | /ruby_functions_practice.rb | UTF-8 | 877 | 3.59375 | 4 | [] | no_license | require ( 'Date' )
def return_10
return 10
end
def add(num1,num2)
return num1+num2
end
def subtract(num1, num2)
return num1 - num2
end
def multiply(num1, num2)
return num1*num2
end
def divide(num1, num2)
return num1/num2
end
def length_of_string(string)
return string.length
end
def join_string(string... | true |
085bc9ce3ff8e1feeb2ae8b5e3c9905ff5b56ae2 | Ruby | guacamobley/caesar-cipher-webapp | /caesar-cipher.rb | UTF-8 | 882 | 3.5625 | 4 | [] | no_license | CAPITAL_A = 65
CAPITAL_Z = 90
LOWERCASE_A = 97
LOWERCASE_Z = 122
def normalize_shift shift
if shift > 0
shift %= 26
else
shift *= -1
shift %= 26
shift *= -1
end
return shift
end
def shift_letter (code,shift)
if code >= CAPITAL_A && code <= CAPITAL_Z
new_code = code + shift
if new_c... | true |
34f2a22b0ca08ddf2cfe39267bb7abab46b79ca6 | Ruby | ITGGOT-Eric-Bratt/standard-biblioteket | /lib/max_of_two.rb | UTF-8 | 335 | 4 | 4 | [] | no_license | # Public: Decide the biggest of two numbers
#
# siffra1, siffra 2 - The integers being compared
#
# Examples
#
# max_of_two(1, 2)
# # => 2
#
# Returns the biggest of the two integers.
def max_of_two(siffra1, siffra2)
if siffra1 > siffra2
output = siffra1
else
output = siffra2
end
re... | true |
0a475998f834b9f7a07e57a6771bc501d95844f3 | Ruby | larsonkonr/sales_engine | /lib/sales_engine.rb | UTF-8 | 1,080 | 2.546875 | 3 | [] | no_license | require_relative 'repositories/merchant_repository'
require_relative 'repositories/item_repository'
require_relative 'repositories/invoice_repository'
require_relative 'repositories/invoice_item_repository'
require_relative 'repositories/customer_repository'
require_relative 'repositories/transaction_repository'
class... | true |
f1eee18bd7619e2b3f3a412874d3eec72893015a | Ruby | prusswan/euler-rails | /code/euler068.rb | UTF-8 | 634 | 3.09375 | 3 | [] | no_license | (1..10).to_a.permutation.each do |p|
# next unless p[0] == 9
next unless [p[2],p[4],p[6],p[8]].include? 10
# numerically lowest external node
next if p[0] > p[2]
next if p[0] > p[4]
next if p[0] > p[6]
next if p[0] > p[8]
s1 = p[0] + p[1] + p[3]
s2 = p[2] + p[3] + p[5]
next if s2 != s1
s3 = p[4... | true |
d678b0611ae180f19dbcc2469a8a9b07ca7083f2 | Ruby | james-cape/sweater_weather | /spec/models/forecast_spec.rb | UTF-8 | 980 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
describe Forecast do
it 'has attributes' do
dark_sky_forecast = File.read('./spec/fixtures/dark_sky_response.rb')
response = Forecast.new(dark_sky_forecast, 'denver,co', 'United States')
expect(response.citystate).to eq('denver,co')
expect(response.country).to eq('United State... | true |
76ea148b2cad760ae9290761f75825281b96bbf5 | Ruby | shoyan/git_find_committer | /lib/git_find_committer/filter.rb | UTF-8 | 328 | 2.625 | 3 | [
"MIT"
] | permissive | module GitFindCommitter
class Filter
def initialize(config)
@config = config
end
def select_committer(committer)
unless @config.available_committer_names.nil?
committer.select {|c| @config.available_committer_names.include?(c[:name]) }
else
committer
end
end
... | true |
0f07b218357f1764a62caf5a13a0540ac0ba71a0 | Ruby | ankane/barkick | /test/barkick_test.rb | UTF-8 | 1,261 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative "test_helper"
class BarkickTest < Minitest::Test
def test_gtin
gtin = Barkick::GTIN.new("016000275263")
assert gtin.valid?
assert_equal "00016000275263", gtin.gtin14
assert_equal "0016000275263", gtin.gtin13
assert_equal "016000275263", gtin.gtin12
assert_equal "0016000275263... | true |
5a3f053e02ba41bf8ff10b1c905a380ff018ca80 | Ruby | 00mjk/dnsdiff | /lib/dnsdiff/query.rb | UTF-8 | 1,371 | 2.875 | 3 | [] | no_license | require 'dnsruby'
require 'colorize'
require_relative './logging'
module DNSDiff
class Query
include Logging
attr_accessor :record, :type
def initialize(opts)
@record = opts[:record]
@type = opts[:type]
end
def colors
{ :Pass => :green, :Fail => :red }
end
def res... | true |
6893f6300624b02b3a7e0ec60ba4a0a7771be138 | Ruby | eoogbe/todo-sinatra | /spec/support/object_mother.rb | UTF-8 | 686 | 2.859375 | 3 | [] | no_license | module ObjectMother
def new_item attrs = {}
text = attrs[:text] || 'The text'
user = attrs[:user] || create_user
Item.new text: text, user: user
end
def create_item attrs = {}
create_model new_item(attrs), ItemMapper
end
def new_user attrs = {}
email = attrs[:email] || "user#{ne... | true |
a9a4158134ba0dc910b6096e92e5d8c03c5bc616 | Ruby | moosan63/my-scheme-in-ruby | /lib/my-scheme-in-ruby/expression.rb | UTF-8 | 1,056 | 2.96875 | 3 | [] | no_license | module MySchemeInRuby
class Expression
attr_reader :value
def initialize(expression)
@value = expression
end
def cons(a, b)
end
def car
if self.is_list?
Expression.new(@value[0])
else
self
end
end
def cdr
if self.is_list?
Expr... | true |
0af64cfa6cfbb4d591af894dd255479b92f65e64 | Ruby | goeunpark/string_reverse | /lib/string_reverse.rb | UTF-8 | 400 | 3.96875 | 4 | [] | no_license | # A method to reverse a string in place.
def string_reverse(my_string)
if my_string == [] || my_string == nil
return my_string
end
my_string.chars
length = my_string.length
low = 0
high = length-1
while low < high
x = my_string[low]
my_string[low] = my_string[high]
my_s... | true |
7868209d9f8d499fd3637469336fbebf2bed5150 | Ruby | topickering/chitter-challenge | /spec/peep_spec.rb | UTF-8 | 532 | 2.515625 | 3 | [] | no_license | require 'peep'
describe Peep do
describe '#all' do
it 'returns all bookmarks' do
connection = PG.connect(dbname: 'chitter_test')
connection.exec("INSERT INTO peeps (text) VALUES('this is a test') RETURNING id, text;")
connection.exec("INSERT INTO peeps (text) VALUES('this is also a test') RETUR... | true |
c4f1e7e8c7a118f51abfa9c075c98feb5391febe | Ruby | toshimaru/ProjectEuler | /002/problem2.rb | UTF-8 | 366 | 3.75 | 4 | [] | no_license | def fibo(n)
a, b = 1, 2
while a < n do
yield a
a, b = b, a + b
end
end
sum = 0
fibo(4000000) {|f|
if f % 2 == 0
sum += f
end
}
puts "answer: " + sum.to_s
=begin
sum = 2
a = 1
b = 2
c = 0
while c < 4000000
c = a + b
a = b
b = c
if c % 2 == 0
sum +=... | true |
ea984c0e1dbb02ae6f88cc15a5b2505c253074a5 | Ruby | apetlock/parchment | /lib/parchment/formats/txt/document.rb | UTF-8 | 753 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'parchment/document'
require_relative 'paragraph'
require_relative 'style'
module Parchment
module TXT
class Document < Parchment::Document
def initialize(file)
@text = file
@styles = []
set_paragraphs
end
private
# These methods parse ... | true |
c8c9fd1fdb8928e6e3b04fd28d61ad737a7b393d | Ruby | mainglis/haley_house | /ruby_scripts/data_clean_up_script.rb | UTF-8 | 9,217 | 3.171875 | 3 | [] | no_license | #in Terminal: cd Dropbox/Database\ Files/Shared\ Database\ Files/Overall\ Files/
#in Terminal: irb
#must require csv
require 'csv'
#must define people variable, even though empty
people = []
#Creates a ruby file out of the existing csv file, right?
CSV.open('mailingList.csv', 'r', ?,, ?\r) { |row| people << row }
#... | true |
e598d3618ad614f5ce44d8f127fcd779f11f4278 | Ruby | drewbee736/PA2 | /MovieTest.rb | UTF-8 | 2,261 | 3.5 | 4 | [] | no_license | class MovieTest
def initialize()
require_relative 'MovieData'
@m = MovieData.new("ml-100k", "u1");
stddev = stddev()
rmse = rms()
puts "Average Prediction Error: #{@mean}. Standard Deviation: #{stddev}. Root Mean Square Error: #{rmse}."
return to_a()
end
def mean()
@datalist = []
i = 0
... | true |
99c9f6c8dfe1044bc899dbf128ce4f45737fb94f | Ruby | NekoQ/social | /app/models/list.rb | UTF-8 | 257 | 2.609375 | 3 | [] | no_license | class List < ApplicationRecord
def add_people(array)
array.each do |name|
p = Person.find_by(name: name)
p.lists.append(self.name)
p.save
end
people.concat array
self.save
end
end
| true |
0349f8215a44f3dd9eddaa3b8caca87bfb2d2064 | Ruby | AlfredBryan/smartupapi | /app/models/assessment_result.rb | UTF-8 | 1,405 | 2.53125 | 3 | [] | no_license | class AssessmentResult < ApplicationRecord
belongs_to :assessment
belongs_to :user
STATUSES = %w(started completed)
STATUSES.each do |state|
define_method "#{state}?" do
self.status == state
end
end
GRADES = {
(0..49).to_a => "F",
(50..59).to_a => "E",
(60..69).to_a => "D"... | true |
52daaf64881b5ad227c0173d84af1e7d31a00781 | Ruby | neonmind/skillcrush | /rubylove.rb | UTF-8 | 116 | 3.609375 | 4 | [] | no_license | puts "Do I love you? What day is it?"
day = gets
while (day[0] != "S")
puts "Why yes, I do love you!"
break
end | true |
245b8a458c9f5e1034247f093a805bba8ec28c10 | Ruby | donatasm/saas-class | /hw1/part1/part1.rb | UTF-8 | 482 | 3.4375 | 3 | [] | no_license |
def palindrome?(string)
if string
downcaseWord = string.gsub(/\W/, "").downcase
if downcaseWord.length > 0
return downcaseWord.eql? downcaseWord.reverse
end
return false
end
end
def count_words(string)
count = {}
if string
words = string.downcase.split(/\b/)
words.each do |w|
... | true |
92c3b4d13f00e07e478399e9206091feb285ac7d | Ruby | mstanielewicz/reminders | /app/use_cases/check_assignments/create.rb | UTF-8 | 898 | 2.546875 | 3 | [
"MIT"
] | permissive | module CheckAssignments
class Create
attr_reader :checker, :assignments_repository, :project_check,
:contact_person
private :checker, :assignments_repository, :project_check,
:contact_person
def initialize(checker:, project_check:, assignments_repository: nil,
... | true |
db4eb32b115abaf507f8c1aaa38d9ce3cbeb3817 | Ruby | furuya-tomoki/stdin_sample | /gets_practice.rb | UTF-8 | 188 | 2.921875 | 3 | [] | no_license | line = gets.split(' ')
# splitメソッド = 文字列を分割して配列として格納するメソッド
# 分割するための区切り文字は第一引数に指定します
p line
| true |
a72945262e018b329729f314789c2184ebe36028 | Ruby | devlab-oy/sepa | /lib/sepa/error_messages.rb | UTF-8 | 3,390 | 2.53125 | 3 | [
"MIT"
] | permissive | module Sepa
# Contains error messages used in this gem
module ErrorMessages
# Error message which is shown when {Client#customer_id} validation fails
CUSTOMER_ID_ERROR_MESSAGE =
'Customer Id needs to be present and needs to have a length of less than 17 characters'.freeze
# Error message which is... | true |
b8ae7bde499f6fa38f223a1bfb8791aec987e9ed | Ruby | VictorArd/Calendar_Ruby | /lib/user.rb | UTF-8 | 253 | 2.703125 | 3 | [] | no_license | require "pry"
require "rb-readline"
class User
attr_accessor :email, :name
@@all_users = []
def initialize(email_to_save)
@email = email_to_save
@@all_users << self
end
def self.all
return @@all_users
end
end
#binding.pry
| true |
9b0152312e628646b38483cb79609de3a1e6a485 | Ruby | DaveWexler/todo-ruby-basics-001-prework-web | /lib/ruby_basics.rb | UTF-8 | 312 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
total = num1 / num2
total
end
def assign_variable(value)
name = value
end
def argue(argument)
argument
end
def greeting(one, two)
end
def return_a_value
return "Nice"
end
def last_evaluated_value
return "expert"
end
def pizza_party(topping = "cheese")
topping
end
| true |
f420ff4a58078bd8014f7c2dcdf6e5d4f7872e24 | Ruby | bilfar/oyster_card | /lib/station.rb | UTF-8 | 214 | 3.078125 | 3 | [] | no_license | class Station
attr_reader :name, :zone
def initialize(station)
@name = station[:station_name]
@zone = station[:zone]
end
def station_zone
@zone
end
def station_name
@name
end
end
| true |
cfd0b7e0633f3dad16d1cbc48b4862b1f8b532bf | Ruby | wwchen/FootTraffic | /app/jobs/yelp_search_job.rb | UTF-8 | 897 | 2.625 | 3 | [] | no_license | require 'yelp_request'
class YelpSearchJob < Struct.new(:location_id)
def perform
puts "[ YelpSearchJob ] (#{location_id}) Starting..."
loc = Location.find_by_id(location_id)
# Normally I'd split the search and the details requests
# into two separate jobs, but in this case we don't have to.
# ... | true |
40571be2a61f14ba9ac1a9d1d57d9edfbc83a590 | Ruby | enspirit/bmg | /lib/bmg/summarizer/percentile.rb | UTF-8 | 1,940 | 3.15625 | 3 | [
"MIT"
] | permissive | module Bmg
class Summarizer
#
# Percentile summarizer.
#
# Example:
#
# # direct ruby usage
# Bmg::Summarizer.percentile(:qty, 50).summarize(...)
#
class Percentile < Summarizer
DEFAULT_OPTIONS = {
:variant => :continuous
}
def initialize(*args, &bl)... | true |
949a012b81f63edd25fa6b51c467a1d72d51dc1a | Ruby | supremebeing7/ruby_dictionary | /spec/word_spec.rb | UTF-8 | 2,691 | 3.171875 | 3 | [] | no_license | require 'rspec'
require 'word'
describe Word do
before do
Word.clear
end
it 'initializes an instance of the word class' do
test_word = Word.new('boat',"English")
test_word.should be_an_instance_of Word
end
it 'initializes with a language' do
test_word = Word.new("boat", "English")
test_w... | true |
1611bbf541d250a12434ece80e992ea71cf68e60 | Ruby | kdonovan/bizsearch | /lib/repayment_projection.rb | UTF-8 | 2,933 | 2.953125 | 3 | [] | no_license | class RepaymentProjection
attr_reader :listing, :kali, :ruth, :sba, :sources
def initialize(listing)
@listing = listing
@sources = [
@kali = MoneySource.new(max: 20_000, rate: 0.01, years: 5, price: listing.price),
@ruth = MoneySource.new(max: 300_000, rate: 0.03, years: 5, price: listing.p... | true |
9eb22bc3a3a1b271223692754850b5471a960b94 | Ruby | bfontaine/BUP7_API | /search.rb | UTF-8 | 3,199 | 2.546875 | 3 | [] | no_license | #! /usr/bin/ruby1.9.1
# -*- coding: UTF-8 -*-
require 'uri'
require 'yaml'
require 'net/http'
require 'nokogiri'
CONFIG = begin
YAML.load(File.read('config.yaml'))
rescue Errno::ENOENT
{}
end
require_relative './query'
class BUP7
class Book
def initialize(d)
... | true |
edb5b98d0610b3063affa94b99a65da3afc5070f | Ruby | cernanb/blog_cli | /lib/blog_cli/cli.rb | UTF-8 | 723 | 3.46875 | 3 | [
"MIT"
] | permissive | class BlogCLI::CLI
attr_reader :last_input
def call
puts "Welcome to your CLI Blog!"
menu
end
def menu
puts "What would you like to do?"
puts "1. Write a post"
main_menu_loop
end
def main_menu_loop
while user_input != "exit"
case last_input.to_i
when 1
post_new... | true |
51e434b3f4976f5ee7e6d4dc41edb3e5a9bfa483 | Ruby | haracane/kajax | /lib/hash_extensions.rb | UTF-8 | 795 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module HashExtensions
module Hash
module MultiDimensionAccess
def fetch_with_keys(key_list)
ret = self
key_list.each do |key|
ret = ret[key]
return nil if ret == nil
end
return ret
end
def store_with_keys(key_list, val)
last_inde... | true |
7a3eb42ac6e9fda857f6bd91c2d7caabc312aa24 | Ruby | borovsky/project-euler | /p34.rb | UTF-8 | 210 | 3 | 3 | [] | no_license | require 'lib'
MAX = 7 * factorial(9)
r = []
FAC = (0..9).map{|i| factorial(i)}
(10..MAX).each do |i|
if i.digits.map{|d| FAC[d]}.sum == i
p i
r << i
end
puts " #{i}" if i % 100000 == 0
end
| true |
1bf8daebc4bf13be3f8b22a8a1ab6092ff049479 | Ruby | wesabe/bouncer | /tasks/deploy.rb | UTF-8 | 2,210 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | require "robot-army"
require "highline/import"
class Deploy < RobotArmy::TaskMaster
def app
return "bouncer"
end
def root
return "/opt/#{app}"
end
def deploy_path(jar_location)
return File.join(root, File.basename(jar_location))
end
def current_link
return File.join(root, "curren... | true |
b96168b7028cbc965e1ff446c5c0f1a78f646e2d | Ruby | lukehaines2/HW_wk5d3_PROTEIN | /app.rb | UTF-8 | 1,203 | 2.671875 | 3 | [] | no_license | class Powder < Sinatra::Base
# General route actions
get '/' do
erb :home
end
get '/about' do
erb :about
end
# RESTful Protein Controller Actions
# index
get '/proteins' do
@proteins = Protein.all
erb(:"proteins/index")
end
# new
get '/proteins/new' do
@proteins = Protein.n... | true |
7f2f73d20bc49f37f5c05d2bb4386fbdbf869647 | Ruby | rcallen89/battleship | /lib/print.rb | UTF-8 | 1,655 | 3.328125 | 3 | [] | no_license | # A module that can be used in other classes as a way to clean up some other methods.
# :nocov:
#No coverage because console printout
module Print
def player_ship_print(ship, ship_length)
print "The #{ship} is #{ship_length} units long.\n\n"
puts "Please enter the coordinates placement (ex. A1 A2 A3): "
en... | true |
cf9ada5ab4237004b5ec4482c46c3fdbc241c6f4 | Ruby | KakinumaMiki/ruby | /Comprehension_Test/04_Hash.rb | UTF-8 | 967 | 4.15625 | 4 | [] | no_license | # 4. 配列内のハッシュ情報を表示してみよう
fruits = [
{name: "バナナ", price: 200},
{name: "リンゴ", price: 200},
{name: "イチゴ", price: 500},
{name: "オレンジ", price: 250},
{name: "モモ", price: 350}
]
# - 4-1. priceが300以上のものだけ、nameの情報を出力(puts)してみよう。
puts '4-1 300以上のnameの出力'
fruits.each do |fruit|
if fruit[:price] >= 300
puts frui... | true |
ec52deba1e3ea638490da38d2fd5e088ea167942 | Ruby | joelbarton-io/rb130_139 | /exercises/regex/regex_book.rb | UTF-8 | 1,731 | 3.671875 | 4 | [] | no_license | def url?(str)
str.match(/\Ahttps?:\/\/\S+\z/) ? true : false
end
def fields(str)
str.split(/[ \t,]+/)
end
def mystery_math(str)
str.sub(/[+\-*\/]/, '?')
end
def danish(str)
str.sub(/\b(apple|cherry|blueberry)\b/, 'danish')
end
def format_date(str)
if str.match(/\A\d{4}-\d{2}-\d{2}/)
str.gsub(/(\d{4})-... | true |
38dd42da8bc78c0c82700698092dcd2f8ad743eb | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/saddle-points/855fd39423cf4147bf3e5c995b6a7e7f.rb | UTF-8 | 1,324 | 3.28125 | 3 | [] | no_license | class Matrix
attr_accessor :rows , :columns
def initialize(args)
self.rows = []
self.columns = []
args.split("\n").each_with_index do |row, row_i|
self.rows[row_i] = []
row.split(" ").each_with_index do |col,col_i|
self.rows[row_i] << col.to_i
if self.columns[col_i] the... | true |
1d7862546669995864544382bc139b09a18951c2 | Ruby | adamwong246/x_and_o | /spec/models/game_spec.rb | UTF-8 | 753 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe Game do
describe "win_cat_or_else" do
it "should know a win" do
game = Game.new(board: 'xxxoxoxox')
game.win_cat_or_else.should eq({win: :x})
end
it "should know a win" do
game = Game.new(board: 'xx oooxx ')
game.win_cat_or_else.should eq({win: :o}... | true |
201e4dc320b3a9e5c17c27251a8269891e0c7192 | Ruby | Docworld/social-notifier | /lib/messenger/tcp.rb | UTF-8 | 3,212 | 3.03125 | 3 | [] | no_license | require 'socket'
require_relative 'base'
module SocialNotifier
module Messenger
class Tcp < SocialNotifier::Messenger::Base
#
# Initialize the Class
#
# @param notifier_engine [SocialNotifier::Engine]
# @param is_listener [Boolean]
# @raise [ArgumentError]
# @return [V... | true |
425d9c5efda14c8ae3a0a438dc7d2228a725ebd4 | Ruby | justonemorecommit/puppet | /lib/puppet/pops/parser/code_merger.rb | UTF-8 | 1,356 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive |
class Puppet::Pops::Parser::CodeMerger
# Concatenates the logic in the array of parse results into one parse result.
# @return Puppet::Parser::AST::BlockExpression
#
def concatenate(parse_results)
# this is a bit brute force as the result is already 3x ast with wrapped 4x content
# this could be combi... | true |
7f8ed05114f627818752de9bc33af5041b91d1c4 | Ruby | RDeckard/color-blocks | /main.rb | UTF-8 | 1,534 | 3.09375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# SETTINGS
X = 100
Y = 100
COLORS = %w[R G B].freeze
# DATA STRUCTURES
TILES =
X.times.map do
Y.times.map do
{ color: COLORS.sample, group_id: nil }
end.freeze
end.freeze
COUNTS_BY_GROUP_ID = Hash.new(1)
# EXPLORATION ALGORITHM
explore =
lambda do |x, y, origin_poi... | true |
700cfc78ab5d5b96827141f698efd52602aa86a9 | Ruby | samsarge/recognition-cam | /recognition/object_detector.rb | UTF-8 | 1,110 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
module Recognition
class ObjectDetector
def initialize(dataset = 'datasets/haarcascade_frontalface_alt.xml.gz')
@classifier = OpenCV::CvHaarClassifierCascade.load(dataset)
@objects_detected = 0
@frames_objects_detected_for = 0
end
attr_reader :frames_objec... | true |
a3a2911e95b4a70b81de006d14ee6bc9a31432be | Ruby | cronkllr/health_cards | /lib/health_cards/key_set.rb | UTF-8 | 2,186 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'forwardable'
module HealthCards
# A set of keys used for signing or verifying HealthCards
class KeySet
extend Forwardable
def_delegator :keys, :empty?
# Create a KeySet from a JWKS
#
# @param jwks [String] the JWKS as a string
# @return [HealthCards... | true |
781aa46d91c9aebec293b596499beead4764590b | Ruby | hbarradah/sample_app | /spec/models/user_spec.rb | UTF-8 | 3,774 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
describe User do
before(:each) do
@attr = {
:name => "Example User",
:email => "user@example.com",
:password => "foobar",
:password_confirmation => "foobar"
}
end
it "should create a new instance given valid attributes" do
User.create! (@attr)
... | true |
85da3efbd9d99f8980a443545d2e62150e9f5bfb | Ruby | corrirc/pub_lab | /customer.rb | UTF-8 | 402 | 3.453125 | 3 | [] | no_license | class Customer
attr_reader :name, :wallet, :age, :drunkness_level
def initialize(name, wallet, age)
@name = name
@wallet = wallet
@age = age
@drunkness_level = 0
end
def buy_drink(drink)
@wallet -= drink.price
@drunkness_level += drink.alchol_level
end
def buy_food(food)
... | true |
0b955d0a642b42996346898db58ae6e724cc53b0 | Ruby | Xiawpohr/ac-exercise-tictactoe | /tic_tag_toe.rb | UTF-8 | 2,533 | 4.1875 | 4 | [] | no_license | class TicTagToe
attr_reader :board, :win_condition, :turn
attr_accessor :player
def initialize
@board = [1,2,3,4,5,6,7,8,9]
@win_condition = [
[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]
]
@turn = 0
@player = {'O' => [], 'X' => []}
end
def launch!
introduction
#action loop
... | true |
545171cd82e30f8366d0c6607561fb5d0c743744 | Ruby | baezanat/Launch_School_bootcamp | /RB_109/prep_videos/substrings.rb | UTF-8 | 2,524 | 4.53125 | 5 | [] | no_license | =begin
Write a method that will return a substring based on specified indices.
substring('honey', 0, 2) == 'hon'
substring('honey', 1, 2) == 'on'
substring('honey', 3, 9) == 'ey'
substring('honey', 2) == 'n'
INPUT: string, num1(index1), num2(index2)
OUTPUT: string
RULES:
- return a string slice from index1 to index... | true |
1051b401c35c16790a7ac18d9779b07216f273c1 | Ruby | ViralSeq/viral_seq | /lib/viral_seq/pid.rb | UTF-8 | 719 | 3.203125 | 3 | [
"MIT"
] | permissive |
module ViralSeq
module PID
# generate all Primer ID combinations given the length of Primer ID
# @param l [Integer] the length of the Primer ID.
# @example generate a pool of Primer IDs with length of 10
# primer_id_pool = ViralSeq::PID.generate_pool(10) # 10 is the length of Primer ID
# pu... | true |
b6710f1fdf547426c1e59063e377456fd0da4d64 | Ruby | ytjmt/at_coder | /abc/abc142/a/logic.rb | UTF-8 | 49 | 3.125 | 3 | [] | no_license | n = gets.chomp.to_i
puts ((n + 1) / 2) / n.to_f
| true |
e2301ec1caddff0490984b804c9cba9dc761c7c5 | Ruby | arjamizo/tieto_decode_2012-solved | /src/q21.rb | UTF-8 | 263 | 3.03125 | 3 | [] | no_license | def nFirstFibbNrs n
fibb=[1,1]
p1,p2=fibb[1],fibb[0]
(n-2).times{
newfib=p1+p2
p2=p1
p1=newfib
fibb<<newfib
}
fibb
end
fibs=nFirstFibbNrs(1000)
fexpects=fibs.keep_if{|n|
[2,3,5,7].count{|i| n%i==0}==4
}
puts fibs.to_s
puts fexpects.to_s
puts fexpects.length | true |
3b121e0201854f69104200854974dd82356f9acd | Ruby | kfili/codewars | /8kyu-difficulty-level/rock-paper-scissors/problem.rb | UTF-8 | 240 | 3.546875 | 4 | [] | no_license | # Rock Paper Scissors
#
# Let's play! You have to return which player won! In case of a draw return Draw!.
#
# Examples:
#
# rps('scissors','paper') // Player 1 won!
# rps('scissors','rock') // Player 2 won!
# rps('paper','paper') // Draw!
| true |
ee2a9b35110eaf81c30edae0ad1d8de77cdc771b | Ruby | amancevice/pooler | /lib/pooler/user.rb | UTF-8 | 1,286 | 2.625 | 3 | [
"MIT"
] | permissive | require 'bcrypt'
module Pooler
class User < ActiveRecord::Base
include BCrypt
validates :username, presence:true, uniqueness:true, :length => { :in => 2..20 }
validates :email, presence:true, uniqueness:true, format: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
has_many :picks
has_many :payments
... | true |
b75044b5a073161f73bd61bcda6163f8a996802d | Ruby | wendelscardua/dotini | /spec/dotini/key_value_pair_spec.rb | UTF-8 | 2,760 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Dotini
RSpec.describe KeyValuePair do
describe 'to_s' do
context 'when there is no key' do
context 'when there is no comment' do
subject(:pair) do
described_class.new
end
it 'returns an empty string' do
expe... | true |
1c96bdedc891a6013637b131a97eb7d4956b78e3 | Ruby | gabdelaun/dotfiles | /wishlist.rb | UTF-8 | 2,057 | 3.9375 | 4 | [] | no_license | # TODO:
# Build a gift wishlist, where you can:
# List products in your wishlist
# Add a new product to your list (e.g. "Jeans", "Socks", etc..)
# Delete an item you don't want in your list anymore
# Mark any item as "checked" when you've bought it
# It's like a basic todolist with products instead of tasks.
def list_... | true |
05484e3beee7e7b4935e6fc83da74da6c03e2c08 | Ruby | jammb/sockoramma | /db/seeds.rb | UTF-8 | 1,356 | 2.640625 | 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 |
d2330f1930a4dee907617945a585e126490833d1 | Ruby | the-night-shift/testing | /change_machine.rb | UTF-8 | 1,864 | 3.640625 | 4 | [] | no_license | require 'rspec'
# 1 [1]
# 2 [1,1]
# 3 [1,1,1]
# 4 [1,1,1,1]
# 5 [5]
# 6 [5,1]
# 7 [5,1,1]
# 8 [5,1,1,1]
# 9
# 10 [10]
# 11
# 12
# 13
# 14
# 15
class ChangeMachine
def change(money)
coins = []
denominations = [25,10,5,1]
denominations.each do |denomination|
while money >= denomination
coins... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.