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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6e2b060a03871daaf03deb6cc9d4d959a72cbdc4 | Ruby | dyet92k/reel | /lib/reel/response/writer.rb | UTF-8 | 1,763 | 2.71875 | 3 | [
"MIT"
] | permissive | module Reel
class Response
class Writer
CRLF = "\r\n"
def initialize(socket)
@socket = socket
end
# Write body chunks directly to the connection
def write(chunk)
chunk_header = chunk.bytesize.to_s(16)
@socket << chunk_header + CRLF
@socket << chunk +... | true |
c80edc49c41341ff533ea61133fb75e67df2af29 | Ruby | kattak/phase-0-tracks | /ruby/list/list.rb | UTF-8 | 414 | 3.5625 | 4 | [] | no_license | class TodoList
def initialize(ary)
@items = ary
#@ means an instance variable, accessed by other methods within the class
#don't use @? it would have been a variable within this method
end
def get_items
return @items
end
def add_item(item1)
@items.push(item1)
end
def delete_i... | true |
88cc311e5e38e06f2f1785cd7433f7e52158d780 | Ruby | trose618/my-each-dumbo-web-102918 | /my_each.rb | UTF-8 | 126 | 3.203125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(array)
# code here
indx = 0
while indx < array.length
yield array[indx]
indx+=1
end
array
end | true |
c5808a0f1adbac44fbafeead71aeb3a471d07cbb | Ruby | charlesbjohnson/super_happy_interview_time | /rb/lib/leetcode/lc_19.rb | UTF-8 | 923 | 3.5625 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
module LeetCode
# 19. Remove Nth Node From End of List
module LC19
ListNode = Helpers::LeetCode::LinkedList::ListNode
# Description:
# Given a linked list, remove the nth node from the end of list and return its head.
# Examples:
# Input: head = [1, 2, 3, 4, 5], n... | true |
a75619dfe7c09c426671bbdbe5ff84e0b33a86b0 | Ruby | Galaxylaughing/ride-share-rails | /test/models/driver_test.rb | UTF-8 | 9,892 | 2.90625 | 3 | [] | no_license | require "test_helper"
describe Driver do
let (:new_driver) {Driver.new(name: "Kari", vin: "123", active: true, car_make: "Cherry", car_model: "DR5")}
it "can be instantiated" do
# Assert
expect(new_driver.valid?).must_equal true
end
it "will have the required fields" do
# Arrange
new_driv... | true |
3e6763d1918e3a4ffaad245ee88d02b4902f8bea | Ruby | makevoid/headshot | /models/hshot.rb | UTF-8 | 1,087 | 2.75 | 3 | [] | no_license | class SiteNotFound < Exception
def initialize(site)
@site = site
end
def message
"error in finding the site, got: #{@site} - review your list of sites, or the site you are calling"
end
end
class HShot
require 'url2png'
require 'net/http'
include Url2png::Helpers::Common
def initial... | true |
70cee05d03cd42aa31b4a86dea7d1843bd8716ca | Ruby | tomecho/PrimeSpeedTest | /prime.rb | UTF-8 | 376 | 3.78125 | 4 | [
"Apache-2.0"
] | permissive | #!/bin/ruby
def test(prime)
for i in 2...prime
if(prime % i == 0)
return false
end
end
return true
end
def main
if ARGV[0] == nil
puts 'please call me like "ruby prime.rb range"'
exit 1
else
@range = ARGV[0].to_i
end
primes = []
for i in 0...@range
if(test(i))
prim... | true |
55458a5656f0413415636a6b677f358b8c2a1675 | Ruby | marzily/sales_engine | /lib/repository.rb | UTF-8 | 1,235 | 3.078125 | 3 | [] | no_license | require 'date'
require_relative 'model_object'
class Repository
attr_reader :collection, :engine
def initialize(data, engine)
@collection = generate(data)
@engine = engine
end
def generate(data)
data.map { |object_data| model_class.new(object_data, self) }
end
def all
collection
en... | true |
bfc5d46f4ddd6ded8c7e2fcc8435b1134b293dc4 | Ruby | marlomajor/enigma | /lib/enigma_one.rb | UTF-8 | 484 | 2.703125 | 3 | [] | no_license | require_relative 'encrypt'
require_relative 'decrypt'
require_relative 'message_encrypter'
require 'pry'
# FILEIO for ENCRYPT
if __FILE__ == $0
decrypted_file = ARGV[1]
encrypted_file = ARGV[0]
encrypted_message = File.read(encrypted_file)
decrypted_message = MessageEncrypter.new(encrypted_message).encry... | true |
d92e46b4a8d27c7dfc8092dc1231bc7498d5d66d | Ruby | metacoder87/maze_solver | /lib/minotaur.rb | UTF-8 | 5,481 | 4.25 | 4 | [] | no_license | # meta_coder (Gary Miller) =)
# gmiller052611@gmail.com
# https://github.com/metacoder87/maze_solver
class Maze
attr_reader :grid
# reads the maze file and creates the grid array for easy solving
def initialize(*maze)
unless maze[0]
@maze = gets_maz... | true |
422703db29471357f3e6f7cd6884fe83e68a2a3b | Ruby | tommottom/ruby | /whats_empty?.rb | UTF-8 | 119 | 2.671875 | 3 | [] | no_license |
p "".empty?
p "ruby".empty?
#文字列の長さが0のときにtrue
#文字列の長さが0以上にときにfalse
| true |
11d9f54a81b2a26c4a28c5e1849b5337440ce824 | Ruby | alrawi90/anagram-detector-re-coded-000 | /lib/anagram.rb | UTF-8 | 421 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
class Anagram
attr_accessor :word
@matched=[]
def initialize(word)
@word=word
@matched=[]
end
def matched
@matched
end
def match(arr)
#arr=text.split(" ")
arr.each do |w|
if word.split("").sort==w.split("").sort
matched.push(w)
end
end
... | true |
ec5f001b8c8ea2d76653e14601d4b1b35afd66b4 | Ruby | danigunawan/Itinerant | /backend/app/models/itinerary.rb | UTF-8 | 2,495 | 2.671875 | 3 | [] | no_license | class Itinerary < ApplicationRecord
has_many :user_itineraries
has_many :users, through: :user_itineraries
has_many :cities
has_many :areas, through: :cities
has_many :attractions, through: :areas
has_many :plans, through: :cities
before_save :default_values
def default_values
self.vital_info ||= ... | true |
f920d9684c40e36f6f7fdcdf2c721dd7d97087fe | Ruby | sisinduku/finance | /spec/finance/income_spec.rb | UTF-8 | 1,764 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe Finance::Income do
subject { described_class.new }
let(:first_report) { Finance::Report.new(1000, 200, 'INDIVIDUAL', Date.parse('2021-01-01')) }
let(:second_report) { Finance::Report.new(2000, 100, 'INDIVIDUAL', Date.parse('2021-02-01')) }
let(:third_report) { Finance::Repo... | true |
1ab16dccd8437bd852a9736f3098d6bc38bbc8be | Ruby | JeremyDownes/LS-Ruby-Object-Oriented-Programming-Exercises | /OOP Easy 1.rb | UTF-8 | 2,985 | 3.703125 | 4 | [] | no_license | # Banner Class
class Banner
def initialize(message)
@werds = message
@leng = @werds.length
end
def to_s
[horizontal_rule, empty_line, message_line, empty_line, horizontal_rule].join("\n")
end
private
def horizontal_rule
hr = "+"
(@leng+2).times {hr += "-"}
hr += "+"
end
... | true |
05d0f6df707ad2e695f8a939635e5aa3d59e98f4 | Ruby | RodCardenas/AppAcademyProjects | /HIR/problems/spec/valid_walk_spec.rb | UTF-8 | 1,334 | 4.03125 | 4 | [] | no_license | # ### Valid Walk ####
# You have a walking robot. Given a string of compass directions (e.g., "nesw"
# or "nnssen"), it will travel one mile in each of those directions. Write a
# method to determine whether a set of directions will lead your robot back to
# its starting position.
# Example:
# valid_walk?("nnnn") # =>... | true |
702c2c6daed1e63f50861c34915cfa6c98549f3b | Ruby | hegwin/Design-Patterns-in-Ruby | /Meta-Programming/playground.rb | UTF-8 | 489 | 2.875 | 3 | [] | no_license | require_relative './composite_base'
class Tiger < CompositeBase
member_of :population
member_of :classification
end
class Jungle < CompositeBase
composite_of :population
end
class Species < CompositeBase
composite_of :classification
end
tiger = Tiger.new('Tony')
jungle = Jungle.new('Northeastern Jungle')
j... | true |
def1ce573623cee271041f6e6e1c3a3d6b87a304 | Ruby | kevinjcoleman/studentideals | /app/models/category_loader.rb | UTF-8 | 868 | 2.6875 | 3 | [] | no_license | class CategoryLoader
attr_accessor :file_name
def initialize(file_name)
@file_name = file_name
end
def import!
CSV.open("tmp/category_errors.csv", "wb") do |errors|
CSV.foreach(file_name, headers: true) do |row|
begin
row_hash = row_hash(row)
business = Business.find_b... | true |
9612f19e6efaf1ee6da84477dfe8f60b00577f24 | Ruby | inosyo/ABC | /def_rubiocci.rb | UTF-8 | 1,649 | 3.734375 | 4 | [] | no_license | #!/usr/koeki/bin/ruby
# -*- coding: utf-8 -*-
def cry(ct)
ct.times do
print("ぴよ\t")
end
print("\n")
sleep(0.5)
end
def message(usr, tame)
STDERR.printf("%sを世話しよう: \n", usr)
for line in 0 .. tame.length - 1
STDERR.printf("[%d]\t%s\n", line + 1, tame[line])
end
end
def fat(perday, exercise)
e... | true |
de8abbbef54c1467147be7eee4cb9210b2b7a330 | Ruby | jes5199/nodegel | /app/models/user.rb | UTF-8 | 319 | 2.515625 | 3 | [] | no_license | class User < ActiveRecord::Base
has_secure_password
validates_format_of :name, with: /\A[''a-zA-Z0-9!?. _-]+\z/
validate :no_weird_spacing
def to_s
return self.name
end
def no_weird_spacing
if name != name.strip.gsub(" ", " ")
errors.add(:name, "can't have weird spaces")
end
end
end
| true |
c6b5f33d0a9087ce549a91a6ac0819d3b996e06d | Ruby | nuclearsandwich/sbpprb | /08_query_method.rb | UTF-8 | 173 | 2.90625 | 3 | [] | no_license | # Query Method
# Ruby has a syntactical edge on this one: there is a clear and
# well-known idiom for naming predicate methods.
class Switch
def on?
# ...
end
end
| true |
a861cbdb830891eeb91d2f61eac7dcca93265e48 | Ruby | BenitolSantos/model-class-methods-reading-v-000 | /app/controllers/posts_controller.rb | UTF-8 | 2,010 | 2.765625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class PostsController < ApplicationController
#added to ensure access to params hash
helper_method :params
#Note: You can use helper_method in a controller to expose, or make available, a controller method in your view, but, as we'll talk about soon, this isn't always a great idea.
def index
@posts = Post.... | true |
bc413b275baf63246527ceaeabbef997d4657c47 | Ruby | svenfuchs/travis-activity | /lib/stats/table.rb | UTF-8 | 725 | 2.75 | 3 | [] | no_license | class Stats
class Table
ROW_COUNTS = {
month: 12,
week: 52,
day: 365
}
attr_reader :repos, :user, :interval
def initialize(options = {})
@repos = options[:repos] || REPOS
@user = options[:user]
@interval = options[:interval] || :week
end
def data
... | true |
4098c274ff25647ee0be5b5aed127fb1c1a3ab36 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/sum-of-multiples/d0f59e37780c46a89445c09ad010ec2c.rb | UTF-8 | 279 | 3.734375 | 4 | [] | no_license | class SumOfMultiples
def initialize(*multiples)
@multiples = multiples
end
def self.to(n)
SumOfMultiples.new(3, 5).to(n)
end
def to(n)
(1...n).select do |i|
@multiples.any? do |m|
i % m == 0
end
end.reduce(0, :+)
end
end
# puts SumOfMultiples.to(1)
| true |
e351fd040f4bf2e5119fca82d6c01a4e81363673 | Ruby | tfb34/chess | /player/chess_pieces/piece.rb | UTF-8 | 3,665 | 3.5625 | 4 | [] | no_license |
require_relative File.expand_path("../gameboard/board.rb",File.dirname(__FILE__))
class Piece
attr_reader :location, :coat, :color, :route
BLACK = "black"
WHITE = "white"
def get_x
@location[0]
end
def get_y
@location[1]
end
def add_to_route(value)
@route = [] if @... | true |
cd829322ceba87492cf0bcb31eb75cabd6c46001 | Ruby | lortza/project_tdd_minesweeper | /lib/row.rb | UTF-8 | 182 | 2.984375 | 3 | [] | no_license | require_relative 'cell'
class Row
def build(board_size)
cell_qty = board_size - 1
row = Array.new(cell_qty) { Cell.new }
row << Mine.new
row.shuffle!
end
end
| true |
7393b02aa8c7377d734b2b7965c0ca1912924b69 | Ruby | MoiRouhs/livecursor | /libs/livecurses.rb | UTF-8 | 10,597 | 2.6875 | 3 | [] | no_license | #!/usr/bin/ruby
require 'curses'
include Curses
class Ventana < Window
# Define la forma de usar los colores
def pintar arg = 'nil'
abreviacion = {
'nn' => 0, 'rn' => 1, 'vn' => 2, 'an' => 3, 'zn' => 4, 'mn' => 5, 'cn' => 6, 'bn' => 7,
'nr' => 8, 'rr' => 9, 'vr' => 10, 'ar' => 11, 'zr' => 12, 'mr' ... | true |
60b82a509f00da0235a63fc70fa171120e02bdbc | Ruby | jonstokes/irongrid | /spec/fixtures/stretched/registrations/ironsights/extensions/normalization.rb | UTF-8 | 7,491 | 2.640625 | 3 | [] | no_license | Stretched::Extension.define "ironsights/extensions/normalization" do
extension do
def normalize_punctuation(text)
return unless text.present?
str = " #{text} "
str.gsub!(/\d\,\d{3}(\D)/) do |match|
match.sub!(",", "")
end
str.gsub!(/\,|\!|\;/, " ")
str.strip.squeeze(" ... | true |
dd00d0b5e6ba630a5d5ca8051ab7a673e7cf7e1e | Ruby | email2jie/AppAcademyProjects | /Week1/W1D4/recursion_exercises2.rb | UTF-8 | 1,268 | 4.40625 | 4 | [] | no_license | def fibonacci_iterative(length)
fibonacci_nums = []
fibonacci_nums << 0
fibonacci_nums << 1 if length > 1
while fibonacci_nums.length < length
fibonacci_nums << fibonacci_nums[-1] + fibonacci_nums[-2]
end
fibonacci_nums
end
def fibonacci_recursive(length)
if length == 1
[0]
elsif length == 2
... | true |
7d0550e635b11d99d064d6b027b1027269066fc0 | Ruby | castor4bit/leetcode | /0300/349.Intersection_of_Two_Arrays/test_349.rb | UTF-8 | 417 | 2.75 | 3 | [] | no_license | require 'test/unit'
require './349'
class LeetCodeSolutionTest < Test::Unit::TestCase
def test_349
nums1 = [1, 2, 2, 1]
nums2 = [2, 2]
assert_equal [2].sort, intersection(nums1, nums2).sort
nums1 = [4, 9, 5]
nums2 = [9, 4, 9, 8, 4]
assert_equal [9, 4].sort, intersection(nums1, nums2).sort
... | true |
d638709b77a4bae4c8a532c25416c0b429ebd6fb | Ruby | seok0801/Kepre | /app/controllers/tool_factory.rb | UTF-8 | 328 | 2.671875 | 3 | [
"MIT"
] | permissive | class ToolFactory
def self.build (item, *args)
case item
when "MHC I"
MhciItem.new(*args)
when "MHC II"
MhciiItem.new(*args)
when "KBIO MHC I"
KbioMhciItem.new(*args)
when "KBIO MHC II"
KbioMhciiItem.new(*args)
end
... | true |
f9e5977d9d3ec4bc25e1901f51797e96abe5dfe3 | Ruby | sandipransing/number_to_indian_currency | /test/number_to_indian_currency_test.rb | UTF-8 | 1,105 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class NumberToIndianCurrencyTest < Minitest::Test
def subject
@subject ||= begin
object = Object.new
object.extend(::NumberToIndianCurrency::CurrencyHelper)
object
end
end
def test_that_it_has_a_version_number
refute_nil ::NumberToIndianCurrency::VERSION
en... | true |
230327e10fdce77036025d3c768b374217c29979 | Ruby | charrednewth/Succubus-Rhapsodia-ENG | /Scripts - manually insert these/153 - Window_Battle_Command.rb | SHIFT_JIS | 5,436 | 2.796875 | 3 | [] | no_license | #==============================================================================
# Window_BoxLeft
#------------------------------------------------------------------------------
# @{bNXʂŁAaĂ閲̖O\EBhEB
#==============================================================================
class Window_Battle_Command < Window_Ba... | true |
c12fa51f81138160f84dfa4bdf08ee1840be371f | Ruby | hackhands/Ruby-on-Rails-4-Course | /Ruby/metaprogramming-example/open-class.rb | UTF-8 | 112 | 3.125 | 3 | [] | no_license | class Fixnum
def hour
self * 3600
end
def hours
self * 3600
end
end
puts 1.hour
puts 3.hours | true |
f413d317a0d0bdec68c080b0266d2bdab8f313ff | Ruby | akira-kuriyama/sssummary | /lib/Sssummary.rb | UTF-8 | 3,584 | 2.8125 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
require 'sqlite3'
require 'csv'
class Sssummary
public
def execute(options, sql)
begin
set_up(options, sql)
@records = get_records
create_table
import
result_records = execute_sql
@messages << get_output(result_records)
@exit_status = 0
rescue FileEmptyError
@... | true |
ab074200109ce7228c09b7e670f5648f893a4fd3 | Ruby | jennifercford/homework | /lib/homework/github.rb | UTF-8 | 1,665 | 2.53125 | 3 | [
"MIT"
] | permissive | module Homework
class Github
include HTTParty
base_uri "https://api.github.com"
def initialize
@headers = {
"Authorization" => "token #{ENV["OAUTH_TOKEN"]}",
"User-Agent" => "HTTParty"
}
end
def get_user(username)
Github.get("/users/#{username}", headers: @he... | true |
554beb48f8ee15e12ae70aa971b23285704b1ef9 | Ruby | swaption2009/rbnd-survivr-part2 | /lib/tribe.rb | UTF-8 | 559 | 3.34375 | 3 | [] | no_license | class Tribe
attr_accessor :name, :members
def initialize(options={})
@name = options[:name]
@members = options[:members]
puts "#{@name.to_s.white} has been added with the following members: "
@members.each { |x| puts x.name.capitalize.pink }
end
def to_s
@name
end
def tribal_council... | true |
dc6e8050180568e3cb7b4f2093a12892d2c965d4 | Ruby | maconaco/ruby_mal | /main.rb | UTF-8 | 937 | 2.90625 | 3 | [] | no_license | require "./tokenizer"
require "./parser"
#tokenizer = Tokenizer.new("(+ 10 22 (+ 1 2) 3)", 0)
tokenizer = Tokenizer.new("(+ 1 2 (+ 3 4))", 0,)
puts tokenizer.call
p "tokenize --------------------------"
tokens = p tokenizer.tokenize
index = 0
# インスタンス化する時に空配列わたすの、だいたい頭の悪いパターンなのでやめとく
parser = Parser.new(0,tokens)
p ... | true |
2e05b75eaa5138f6ef71dd1ee4ba130054ffa628 | Ruby | 0cha/mrubyc_for_ESP32_Arduino | /examples/bmp085/code.rb | UTF-8 | 291 | 3.078125 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- coding: utf-8 -*-
bmp085 = BMP085.new
bmp085.begin()
while true
puts bmp085.readTemperature
puts bmp085.readPressure
puts bmp085.readAltitude
puts bmp085.readSealevelPressure
puts bmp085.readSealevelPressure(10500)
puts bmp085.readSealevelPressure(10500.0)
sleep(10)
end
| true |
39395b567584b0c5ddcf361c9d8dbb1a879b47b1 | Ruby | Azzerty23/THP | /THP-jour25/airbnb/db/seeds.rb | UTF-8 | 2,477 | 2.53125 | 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 |
889f382a7bb8d6b6f04d9d79489da8489ab68405 | Ruby | carolyny/launchschool | /Backend/101/Exercises/finddup.rb | UTF-8 | 134 | 3.3125 | 3 | [] | no_license | def find_dup(array)
array.each do |number|
if array.count(number)==2
return number
else
end
end
end
puts find_dup([4,5,3,3,1]) == 3 | true |
90debb622162706bbd82155ca28e0a67c732391d | Ruby | NazarOliynyk/test_api_mailjet | /lib/reporter/custom_logger.rb | UTF-8 | 649 | 2.84375 | 3 | [] | no_license | require 'log4r'
require 'fileutils'
module CustomLogger
class MyLogger
attr_accessor :logger
def initialize(file_path)
@logger = Log4r::Logger.new('my_logger')
format = Log4r::PatternFormatter.new(pattern: '[%d]: %l - %m')
create_path(file_path)
@logger.outputters << Log4r::FileOutpu... | true |
cf0628631c20a2b981e7c7b7ce9e87c75ad6cf94 | Ruby | NetsoftHoldings/growl | /scripts/nib-to-xib.rb | UTF-8 | 639 | 2.671875 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/ruby
require 'find'
require 'fileutils'
def xibify(path)
Find.find(path) do |subpath|
if File.extname(subpath) == '.nib'
newsubpath = File.dirname(subpath) + "/" + File.basename(subpath, '.nib') + '.xib'
command = "ibtool --upgrade \"#{subpath}\" --write \"#{newsubpath}\... | true |
9fb32a8ef8d4c8504eac93fcf267b182bc7150ce | Ruby | sPesce/advanced-hashes-building-hashketball-wdc01-seng-ft-060120 | /hashketball.rb | UTF-8 | 1,569 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def game_hash
nets_players =
[
player("Alan Anderson", 0, 16, 22, 12, 12, 3, 1, 1),
player("Reggie Evans" , 30, 14, 12, 12, 12, 12, 12, 7),
player("Brook Lopez" , 11, 17, 17, 19, 10, 3, 1, 15),
player("Mason Plumlee", 1, 19, 26, 11, 6, 3, 8, 5),
player("Jason Terry" ... | true |
b56460043b5743bfa12ed9717f5b9011748ddb9f | Ruby | jetthoughts/jetmeter | /test/jetmeter/csv_formatter_test.rb | UTF-8 | 1,861 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive | require 'minitest/autorun'
require 'csv'
require 'jetmeter/csv_formatter'
class Jetmeter::CsvFormatterTest < Minitest::Test
def test_builds_commulative_table
flows = {
'Backlog' => {
Date.new(2017, 4, 9) => [1, 2, 3],
Date.new(2017, 4, 10) => [4, 5, 6, 7],
Date.new(2017, 4, 12) => ... | true |
23d2e77e13019af89920b58b98161e5f58862b05 | Ruby | vannak1/algorithm | /sum_of_two.rb | UTF-8 | 395 | 4.25 | 4 | [] | no_license | # You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false.
#
# Example
#
# For a = [1, 2, 3], b = [10,... | true |
e4c98069fc5845250037474f72e78111fe50d14e | Ruby | hiendinhngoc/ruby | /modul/stack.rb | UTF-8 | 355 | 3.3125 | 3 | [] | no_license | require "./stacklike"
class Stack
include Stacklike
end
# Create and using an instance of class Stack
s = Stack.new
s.add_to_stack("item one")
s.add_to_stack("item two")
s.add_to_stack("item three")
puts "Objects currently on the stack: "
puts s.stack
taken = s.take_from_stack
#taken = s.take_from_stack
puts "... | true |
5663591dd0e45ebf4e1909bcc43cb1e7c7e40706 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/1023.rb | UTF-8 | 289 | 3.40625 | 3 | [] | no_license | def compute (x,y)
if x.length <= y.length
strand_size = x.length
else
strand_size = y.length
end
hamming_distance = 0
for i in (0..(strand_size-1))
if x[i] != y[i]
hamming_distance += 1
end
end
return hamming_distance
end | true |
dde4fa99ef69b081b97136a37544ce9371228c8c | Ruby | chrisswk/sinatra-best-practices | /app2.rb | UTF-8 | 1,425 | 2.578125 | 3 | [
"MIT"
] | permissive | #app2
require 'sinatra/base'
require_relative 'helpers'
require_relative 'routes/secrets'
require_relative 'routes/sessions'
class SimpleApp < Sinatra::Base
set :root, File.dirname(__FILE__)
enable :sessions
helpers Sinatra::SampleApp::Helpers
register Sinatra::SampleApp::Routing::Sessions
register Sin... | true |
04e6c6d21c32d54d28aa2e1c26eea3024f8fe3c5 | Ruby | AlexHorch/AoC_Python | /2018/day04/solution.rb | UTF-8 | 700 | 3.015625 | 3 | [] | no_license | require 'date'
#[1518-02-05 00:55] wakes up
#[1518-07-08 00:02] falls asleep
#[1518-05-22 23:50] Guard #797 begins shift
input = File.open("input.txt").read.split"\n"
f = File.open("output.txt", "w")
input.sort_by! {|line| DateTime.parse(line.split(/[\[\]]/)[1])}.each do |line| f.write line + "\n" end
class Entry
... | true |
80878ef875cc53c371d0549ae2c16716173938ae | Ruby | CaptainSpectacular/black_thursday | /test/item_repository_test.rb | UTF-8 | 1,255 | 2.734375 | 3 | [] | no_license | require './test/test_helper'
require './lib/item_repository'
class ItemRepositoryTest < MiniTest::Test
def setup
csv = './data/items.csv'
@ir = ItemRepository.new(csv, nil)
end
def test_existence
assert_instance_of ItemRepository, @ir
end
def test_all
assert_equal 99, @ir.all.size
end
d... | true |
fdafe6a826272d37fc711ed9a59f8c728ee8202f | Ruby | Sifuri/rubyAlgorithms | /CelsiusToFahrenheit.rb | UTF-8 | 690 | 3.765625 | 4 | [] | no_license | =begin
@author Lemuel M. Uhuru
@Date July 14, 2013
Book Title: From Control Structures through Objects by Tony Gaddis
Page: 268 Challenge 11: Celsius to Fahrenheit Table
@Description Write a program that displays a table of the Celsius temperatures
0 through 20 and their Fahrenheit equivalents. Your ... | true |
ef28cd11078da1bf51b7d4164213b8cbf516718e | Ruby | learn-co-students/london-web-030920 | /04-oo-otm/virus.rb | UTF-8 | 586 | 3.546875 | 4 | [] | no_license | class Virus
@@all = []
attr_accessor :name
def initialize(virus_name)
@name = virus_name
@@all << self
end
def self.number_of_cases
Person.all.select {|person| person.virus }.size
end
def number_of_cases
people_infected.length
end
def people_infected
# self used in a instance... | true |
140ce5f4c6703a166d5c7ca739a22856c27a2b96 | Ruby | eyi1/my-select-nyc-web-040218 | /lib/my_select.rb | UTF-8 | 164 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
arr = []
i = 0
while i<collection.length
if yield(collection[i])
arr.push(collection[i])
end
i+=1
end
arr
end
| true |
c6afbaf982752ad88260b9ee0548006efe3608ee | Ruby | pbusswood/fizzbuzz | /fizzbuzz.rb | UTF-8 | 868 | 4.03125 | 4 | [] | no_license | # Version 1
# puts (1..100).map { |num|
# output = num + " "
# if num % 3 == 0
# output = output + 'fizz'
# end
# if num % 5 == 0
# output = output + 'buzz'
# end
# puts output
# }
# Version 2
# puts (1..100).map { |num|
# f = b = output = '';
# if num % 3 == 0
# f = 'fizz'
# end
# i... | true |
e277262b3e5b392514b333de85703eaa48ddbeba | Ruby | omgannie/litmus | /app/models/song.rb | UTF-8 | 3,087 | 2.640625 | 3 | [
"MIT"
] | permissive | class Song < ActiveRecord::Base
scope :recent, -> { order("created_at DESC").limit(5) }
validates :artist_name, :song_title, presence: true
has_one :lyric
belongs_to :genre
def self.most_recent_with_lyrics
Song.recent.select do |song|
song.genre.has_lyrics
end
end
def self.song_ids
... | true |
dbd989df5a432f13580dbd12cb442cb2871c9c47 | Ruby | jrobertson/gtk2html | /lib/gtk2html.rb | UTF-8 | 12,711 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
# file: gtk2html.rb
require 'gtk2svg'
require 'htmle'
# module InspectArray is located in dom_render.rb
module Gtk2HTML
class Render < DomRender
def initialize(x, width, height)
@width, @height = width.to_i, height.to_i
super x
end
def body(e,... | true |
dafc4b9f19b1f030bc7e191f07dc5326b6865744 | Ruby | kwatch/rubinius | /spec/library/mailbox/receive_spec.rb | UTF-8 | 1,335 | 2.890625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../../spec_helper'
require 'mailbox'
describe "Mailbox#receive" do
before :each do
@mbox = Mailbox.new
end
it "returns objects" do
objects = ["hello there", 100, :asdf, Object.new]
objects.each {|o| @mbox.send(o) }
results = []
objects.size.times { result... | true |
ad99f25b40d15f6f7eaf7c22a2096c48ea6dafcf | Ruby | kojinhiga/ruby- | /01_5.rb | UTF-8 | 723 | 3.84375 | 4 | [] | no_license | puts <<~TEXT
旅行プランを選択してください
1. 沖縄旅行(¥10000)
2. 北海道旅行(¥20000)
3. 九州旅行(¥15000)
TEXT
print "プランを選択 > "
plan = gets.to_i
if plan == 1
puts "沖縄旅行ですね、何人で行きますか?"
print "人数を入力 > "
num = gets.to_i
total_price = 10000 * num
elsif plan == 2
puts "北海道旅行ですね、何人で行きますか?"
print "人数を入力 > "
... | true |
8824355be1c2e6e85860c461e01fa3e8a9a2722d | Ruby | danieljanowski/Snowman_game | /specs/hiddenword_specs.rb | UTF-8 | 673 | 2.8125 | 3 | [] | no_license | require ('minitest/autorun')
require ('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative('../hiddenword')
require_relative("../player")
class HiddenwordTest< Minitest::Test
def setup()
@hiddenword1 = Hiddenword.new("poland rules")
@player1= Player.new("Da... | true |
65cf16bbabfd2828633f2127d96591ec8c391b68 | Ruby | gglaine/todoux | /app/helpers/application_helper.rb | UTF-8 | 2,956 | 2.515625 | 3 | [] | no_license | module ApplicationHelper
require 'open_weather'
def time_greeting
gday = "Bonjour"
night = "Bonne nuit"
@time = DateTime.current
if @time.strftime("%H").to_i > 18
return night
else
return gday
end
end
CITY_IDS = {
:paris => "2988506",
:argenteuil => "6457376",
... | true |
669cbd3142f23567543e469bde50a920affaa29f | Ruby | jgraichen/acfs | /lib/acfs/service/middleware/stack.rb | UTF-8 | 1,401 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module Acfs
class Service
module Middleware
class Stack
include Enumerable
MUTEX = Mutex.new
IDENTITY = ->(i) { i }
attr_reader :middlewares
def initialize
@middlewares = []
end
def call(request)
b... | true |
09114b663734f8c44931649315ba8903c5159268 | Ruby | Areid0093/OO-mini-project-austin-web-091619 | /app/models/Ingredient.rb | UTF-8 | 338 | 3.09375 | 3 | [] | no_license | class Ingredient
attr_accessor :ingredient_name
@@all = []
def initialize(ingredient_name)
@ingredient_name = ingredient_name
@@all << self
end
def self.all
@@all
end
def self.most_common_allergen
Allergy.all.max_by {|a| a.ingredient.count(a)}... | true |
8c4aac074b948d37de4e152eae5f4e016a8f0dab | Ruby | teoucsb82/pokemongodb | /lib/pokemongodb/pokemon/exeggutor.rb | UTF-8 | 1,288 | 2.59375 | 3 | [] | no_license | class Pokemongodb
class Pokemon
class Exeggutor < Pokemon
def self.id
103
end
def self.base_attack
232
end
def self.base_defense
164
end
def self.base_stamina
190
end
def self.buddy_candy_distance
2
end
... | true |
574289d47d68f1ec34d0543850069cdce062cae3 | Ruby | louisraymond/looping-while-until-prework | /lib/until.rb | UTF-8 | 174 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_until
levitation_force = 6
#your code here
counter = 0
until levitation_force == 10
puts "Wingardium Leviosa"
levitation_force += 1
end
end
| true |
d7c2e3008deb42eabdfc8af2d9de6d20ee561e60 | Ruby | darkelv/qna | /db/seeds.rb | UTF-8 | 1,433 | 2.71875 | 3 | [] | no_license | Question.destroy_all
User.destroy_all
user1 = User.create(
email: 'user1@yandex.ru',
password: 'secret1',
password_confirmation: 'secret1',
)
user2 = User.create(
email: 'user2@yandex.ru',
password: 'secret2',
password_confirmation: 'secret2',
)
user3 = User.create(
email: 'user3@yandex.ru',
password... | true |
55218cd2a59f8096f1436422c1fd4bd462dc4151 | Ruby | gropmor/dragonquest_program | /monster.rb | UTF-8 | 270 | 3.453125 | 3 | [] | no_license | require "./character.rb"
class Monster < Character
def appear
puts "#{@name}があらわれた!"
end
def attack(brave)
puts "#{@name}の攻撃!"
calculate_damage(brave)
puts "#{brave.name}は#{@damage}のダメージを受けた!"
end
end | true |
fa86bd4c219c7c13445e90d190e746cd1f306b7c | Ruby | phongnh/threetaps_client | /lib/threetaps_client/core_ext/hash.rb | UTF-8 | 858 | 3.140625 | 3 | [
"MIT"
] | permissive | class Hash
# Returns a "flatten" hash representation of the receiver:
#
# { :source => 'CRAIG', :location => { :country => 'USA' } }.flatten
# # => { :source => 'CRAIG', :"location.country" => 'USA' }
#
# { :param => 1, :nested => { :param => 2, :nested => { :param => 2 } } }.flatten
# # => { :par... | true |
3276d200538084ce41d9d4d796961f3121a8def0 | Ruby | nicoledag/reverse-each-word-online-web-sp-000 | /reverse_each_word.rb | UTF-8 | 198 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def reverse_each_word(string)
string = string.split
reversed_string = []
string.collect do |word|
reversed_string << word.reverse
end
return reversed_string.join(' ')
end
| true |
dfb62222b0f9df392dd55859514ad8f7c453a6c5 | Ruby | jkopczyn/AdventOfCode | /2015/day18.rb | UTF-8 | 1,541 | 3.390625 | 3 | [] | no_license | require 'byebug'
def life_lights(filename, steps)
light_array = []
File.open(filename, 'r') do |file|
file.each do |line|
light_array.push(line.strip.split('').map {|c| c == '#'})
end
light_array[0][0] = true
light_array[0][-1] = true
light_array[-1][-1] = true
light_array[-1][0] = true
end... | true |
d4cf8475b8c0b0501495955088a3252933872fb8 | Ruby | yoshida-keita/aoj | /course/Introduction_to_Programming_I/10_2.rb | UTF-8 | 216 | 3.140625 | 3 | [] | no_license |
a,b,c=gets.split.map(&:to_f)
sin=Math.sin((c/180)*Math::PI)
cos=Math.cos((c/180)*Math::PI)
puts sprintf("%.8f",(a*b*sin/2.0))
puts sprintf("%.8f",a+b+((a**2)+((b**2)-2*a*b*cos))**(1/2.0))
puts sprintf("%.8f",sin*b)
| true |
e4fc15a0f2aa36aa3569c0a1ac773dc34b489057 | Ruby | prettymuchbryce/princessfrenzy | /websocketserver/messaging.rb | UTF-8 | 2,967 | 3.078125 | 3 | [] | no_license | # This module is used for nothing more than sending messages.
# It doesn't care about state. It just knows how to send particular messages.
# Do you get the message ?
module Messaging
DEBUG = true
DELIMITER = "%"
LOGIN = "L"
LEVEL = "E"
BANNED = "B"
CHAT = "C"
QUIT = "Q"
DIE = "D"
MOVE = "M"
BULLET... | true |
2e7b0d7bff2d840fa1f4faee0c13eb4a8d57814e | Ruby | randallr18/nyc-mhtn-web-060418 | /10-intro-tdd/program.rb | UTF-8 | 114 | 3.140625 | 3 | [] | no_license | def is_palindrome?(word)
# 'dad'
word = word.split(' ').join('')
word.downcase == word.downcase.reverse
end
| true |
3ea8d814e870693adf73793a281780932d702351 | Ruby | bitfluent/wheneva | /vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb | UTF-8 | 4,694 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'net/https'
require 'rubygems'
require 'active_support'
require 'hoptoad_notifier/configuration'
require 'hoptoad_notifier/notice'
require 'hoptoad_notifier/sender'
require 'hoptoad_notifier/catcher'
require 'hoptoad_notifier/backtrace'
# Plugin for applications to automatically post errors ... | true |
f9d83c916b5d26d72b80b69ae1ba4c4e7985296c | Ruby | malinovskymax/files-names-parser | /app/models/parser.rb | UTF-8 | 1,173 | 3.078125 | 3 | [] | no_license | class Parser
VALID_ID_PATTERN = /^u\d{1,15}/i
VALID_TYPE_PATTERN = /(account)|(activity)|(position)|(security)/i
SIMPLE_DATE_PATTERN = /\d{8}/
VALID_FILENAME_PATTERN = /#{VALID_ID_PATTERN}_#{VALID_TYPE_PATTERN}_#{SIMPLE_DATE_PATTERN}\.*/i
# VALID_FILENAME_PATTERN = /^u\d{1,15}_((account)|(activity)|(positio... | true |
ec7af2e7e1c3a45dc4406c7606b0a81186c764b8 | Ruby | cloudhead/prose | /lib/prose.rb | UTF-8 | 8,581 | 3.109375 | 3 | [] | no_license | require 'cgi'
require 'json'
require 'yaml'
##
# Copyright (c) 2009 Alexis Sellier
#
# Prose - A lightweight text to html parser inspired by Markdown & Textile
#
class Prose < String
#
# Usage:
#
# Prose.new(text).parse
# or
# Prose.parse text
#
# lite mode (no headers, escape html):
#
# text = Prose.new(text... | true |
739e5b8c7e1049195a1128863e108656b0611816 | Ruby | bernardoamc/labs | /ruby/cryptopals/03_set/18.rb | UTF-8 | 281 | 2.53125 | 3 | [] | no_license | require_relative '../helpers'
require 'openssl'
input = base64_decode(
'L77na/nrFsKvynd6HzOoG7GHTLXsTVu9qvY/2syLXzhPweyyMTJULu/6/kXX0KSvoOLSFQ=='
)
key = 'YELLOW SUBMARINE'.unpack('C*')
nonce = 0
puts(aes_ctr_decrypt(input, key, nonce).pack('C*'))
puts(
"Success: #{aes_ctr_encrypt(aes_ctr_decrypt(input, key, nonc... | true |
7e2d28debb79925fa7d0417c8e1f363e4d9c7627 | Ruby | kpapacostas/todo-ruby-basics-web-103017 | /lib/ruby_basics.rb | UTF-8 | 355 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
quotient = num1/num2
quotient
end
def assign_variable(value)
name = value
name
end
def argue(argument)
argument
end
def greeting(greeting, name)
end
def return_a_value
comment = "Nice"
comment
end
def last_evaluated_value
qualifier = "expert"
qualifier
end
def pizza_party... | true |
8b409f4c59e0f026e5c641859fb2854a25b8d320 | Ruby | tanvir002700/RubyDesignPattern | /Creational patterns/factory/src.rb | UTF-8 | 206 | 2.6875 | 3 | [] | no_license | require './factory.rb'
require './mega_factory.rb'
require './warrior_factory.rb'
m = Factory.new MegaFactory.new
m.create 10
puts m.members
w = Factory.new WarriorFactory.new
w.create 10
puts w.members
| true |
288fc08d52640e7b699a1f407532a002dc9704e8 | Ruby | susmitabhowmik/conference_app | /meeting_notes.rb | UTF-8 | 392 | 2.796875 | 3 | [] | no_license | require 'http'
p "If you would like the meeting notes from a particualar meeting, please enter the number of the meeting else enter 'all':"
meeting_id = gets.chomp.to_i
if meeting_id == 0
meeting_notes = HTTP.get('http://localhost:3000/api/meetings')
p meeting_notes.parse
else
meeting_notes = HTTP.get("http://... | true |
c919059ae0982a1c385d15aa0c829311eb156b56 | Ruby | potamus/fujirockive | /main.rb | UTF-8 | 6,627 | 2.65625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/cross_origin'
require 'sinatra/reloader'
require 'active_record'
require 'mysql2'
require 'youtube_search'
require 'json'
require 'rexml/document'
require 'cgi'
require 'kconv'
require 'yaml'
enable :cross_origin
set :bind, '0.0.0.0'
# DB設定の読み込み
ActiveRecord::Base.establish_connecti... | true |
4f05ea6c5d653596af999cc6905381bbfb344593 | Ruby | grantcottle/kovid | /lib/kovid/request.rb | UTF-8 | 2,570 | 2.9375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'json'
require_relative 'tablelize'
require_relative 'cache'
require_relative 'uri_builder'
module Kovid
class Request
COUNTRIES_PATH = UriBuilder.new('/countries').url
STATES_URL = UriBuilder.new('/states').url
class << self
def by_country(country_name)
... | true |
cda9e85391082aa996a0484ec66984495bd25901 | Ruby | atomic-changes/procedure | /lib/procedure/helpers/errors/default_errors.rb | UTF-8 | 1,172 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
module Procedure
module Helpers
module Errors
MESSAGES = {
new_records: "isn't a saved model",
nils: "can't be nil",
required: 'is required',
}.merge(
ARRAY_MESSAGES,
DATATYPE_MESSAGES,
DATE_MESSAGES,
NUMERIC_MESSAG... | true |
4e027de1ea0a8b306551914c14e0b03da3c89089 | Ruby | benrodenhaeuser/repetitions | /109_prep/more_exercises/quick_sort_rep.rb | UTF-8 | 1,857 | 4.40625 | 4 | [] | no_license | def swap(array, index1, index2)
temp = array[index1]
array[index1] = array[index2]
array[index2] = temp
array
end
def partition(array, left_pointer, right_pointer)
pivot_pointer = right_pointer
pivot = array[pivot_pointer]
right_pointer -= 1
loop do
while array[left_pointer] < pivot
left_poi... | true |
602506076a5d733dc451c06f9e21ce58188440d1 | Ruby | sanger/traction-service | /spec/support/request_helpers.rb | UTF-8 | 1,975 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
module RequestHelpers
def json_api_headers
{
'Content-Type' => 'application/vnd.api+json',
'Accept' => 'application/vnd.api+json'
}
end
#
# Returns a hash representing the decoded json response
#
# @return [Hash] The decoded json
#
def json
ActiveS... | true |
f5b2ea3cab4eb24e60cf261be7587d37e07dc3ab | Ruby | nielsabels/understanding-computation | /chapter3/005.nfa.rulebook.rb | UTF-8 | 2,528 | 4.0625 | 4 | [] | no_license | # Moving on to non-deterministic finite automata
# Relaxing the determinism constraints has produced an imaginary machine that is very different from the real, deterministic computers we’re familiar with. An NFA deals in possibilities rather than certainties; we talk about its behavior in terms of what can happen rath... | true |
9c622445dc0d92c508d60c8b44b7f6a27a4caec1 | Ruby | S-zebra/gaba-web-dev | /app/models/account.rb | UTF-8 | 508 | 2.640625 | 3 | [] | no_license | class Account < ApplicationRecord
has_many :posts, dependent: :destroy
validates :user_id, presence: true, uniqueness: true, length: {minimum: 5, maximum: 20}
validates :password, presence: true, length: {minimum: 5}
validate :encrypt_password
def encrypt_password
self.password = BCrypt::Password.create(... | true |
421ae63872379ac73acbcd8820d672c6c97f3bb2 | Ruby | cpcsacggc/RubySchool.US | /arc/18/net_demo8.rb | UTF-8 | 260 | 2.53125 | 3 | [] | no_license | require 'net/http'
require 'uri'
def is_wrong_password password
uri = URI.parse 'http://mynetwd/'
response = Net::HTTP.post_form(uri, :login => "admin", :password => password).body
response.include? "denied"
end
puts is_wrong_password "Number10"
| true |
30d1b8f86cf03a8a9f7d11e7cc57d350fbd08a99 | Ruby | jjc224/Matasano | /Ruby/matasano_lib/aes_128_common.rb | UTF-8 | 894 | 2.90625 | 3 | [] | no_license | module MatasanoLib
module AES_128_COMMON
BLOCKSIZE = 16
class << self
# Expects a hex-encoded ciphertext.
def detect_mode(ciphertext)
blocks = ciphertext.scan(/.{1,32}/) # Split into 16-byte blocks; working with hex, so 32 characters.
blocks_dups = {}
# Iterate thr... | true |
9331e13529337011fd86171f5753475f94b5be4d | Ruby | rnadler/fg-csv-processor | /lib/converters/heated_tube_type_converter.rb | UTF-8 | 319 | 2.890625 | 3 | [] | no_license | require_relative '../constants'
class HeatedTubeTypeConverter
def self.convert(value)
case value
when 'None'
0
when '15mm'
1
when '19mm'
2
when 'NULL'
NULL_VALUE
else
raise "HeatedTubeTypeConverter: Unknown value: #{value}"
end
end
end
| true |
8c20a1c824f9f3c3384d8447fc611b489ba6b63c | Ruby | Jagaa/site_scaffold | /generators/products_catalog/templates/models/product.rb | UTF-8 | 1,036 | 2.640625 | 3 | [
"MIT"
] | permissive | class Product < ActiveRecord::Base
belongs_to :product_category
has_many :product_images, :dependent=>:destroy
validates_presence_of :name, :product_category_id
validates_length_of :short_description, :maximum => 30, :message => "breve descrição deve ser menor que %d"
after_update :save_images ... | true |
11b8f1fa780cbcd45acc73efd1e476890e69ad3e | Ruby | daroleary/HeadFirstRuby | /animals/dog.rb | UTF-8 | 97 | 2.828125 | 3 | [] | no_license | require './animal'
class Dog < Animal
def to_s
"#{@name} the dog, aged #{@age}"
end
end | true |
7c771d6c9f050b7f4f0d51dbd6f1ec617da63645 | Ruby | janicky/fifteen-puzzle-solver | /spec/depth_first_search_spec.rb | UTF-8 | 856 | 2.875 | 3 | [] | no_license | require "fifteen_puzzle_solver"
require_relative "../lib/fifteen_puzzle_solver/depth_first_search"
RSpec.describe "DepthFirstSearch" do
before do
# 1 2 3
# 4 0 6
# 7 5 8
@board = FifteenPuzzleSolver::Board.new([1, 2, 3, 4, 0, 6, 7, 5, 8], 3, 3)
@dfs = FifteenPuzzleSolver::DepthFirstSearch.new(@bo... | true |
d4a4252b0cab9be17ccd2ec821edaa170c3f4480 | Ruby | bp50fathoms/alpha | /src/genetic_fitness.rb | UTF-8 | 882 | 3.15625 | 3 | [] | no_license | module GeneticFitness
MAXFIT = 1e6
FUNC = {
:< => { true => lambda { |a,b| a < b ? 0 : a - b + 1 },
false => lambda { |a,b| a < b ? b - a : 0 } },
:<= => { true => lambda { |a,b| a <= b ? 0 : a - b },
false => lambda { |a,b| a <= b ? b - a + 1 : 0 } },
:== => { true => lambda { |a,b| a ==... | true |
e27686f7fa22570d7e9a5d39e8ce5abfb7795e37 | Ruby | akshaya-9/III-year-Lab | /SL/Experiment 10/exp10(2).rb | UTF-8 | 176 | 3.09375 | 3 | [] | no_license | s = Hash.new 0
s['English'] = 80
s['telugu'] = 75
s['hindi'] = 91
total_marks = 0
s.each {|key,value|
total_marks +=value
}
puts "Total Marks: "+total_marks.to_s | true |
588bc233c07ebfbc11441ccd8c5b572b234e88e3 | Ruby | ympek/uw-team-faq-downloader | /uw-team-faq-grabber.rb | UTF-8 | 955 | 2.953125 | 3 | [] | no_license | require 'net/http'
puts 'UW-TEAM FAQ DOWNLOADER'
puts 'This script will download all the materials present on http://www.uw-team.org/faq.html'
$dir = "uwteam"
Dir.mkdir $dir if not Dir.exist? $dir
uri = URI('http://www.uw-team.org/faq.html')
site = Net::HTTP.get(uri)
$origin = "http://www.uw-team.org/data"
# fin... | true |
80b5256f01ee85319eb582f718d9c9086aa28cec | Ruby | tlopo-ruby/svcdeps_tasks | /lib/probe.rb | UTF-8 | 3,145 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'socket'
require 'timeout'
require 'etc'
require 'yaml'
require 'net/http'
require 'openssl'
class Probe
def initialize(opts)
@type = opts[:type].downcase
@timeout = opts[:timeout] || 5
@opts = opts
end
def tcp_probe
host = @opts[:host]
port = @opts[:port]
Timeout::timeout(@time... | true |
9603e428c1032692c7c24e01e50c96e5981bd807 | Ruby | kyle-cook/hash-search | /lib/util/names.rb | UTF-8 | 719 | 2.96875 | 3 | [
"MIT"
] | permissive | module HashSearch
class Names
@@Names = [
"Alice",
"Bob",
"Charles",
"Daniel",
"Eve",
"Felicia",
"George",
"Harriet",
"Igor",
"Jessica",
"Kevin",
"Laura",
... | true |
6eb6a13c62645e508df43548c9d71b9e30955e11 | Ruby | ocktagon/phase_0_unit_2 | /week_6/4_PezDispenser_solo_challenge/my_solution.rb | UTF-8 | 2,833 | 4.1875 | 4 | [] | no_license | # U2.W6: PezDispenser Class from User Stories
# I worked on this challenge [with: Adam Dziuk].
# 1. Review the following user stories:
# - As a pez user, I'd like to be able to "create" a new pez dispenser with a group of flavors that
# represent pez so it's easy to start with a full pez dispenser.
# - As a pe... | true |
af90f6decf1a9fb5aaa151ce36760e7f12160aea | Ruby | carlypecora/algorithm-practice | /are_there_duplicates.rb | UTF-8 | 1,124 | 4.625 | 5 | [] | no_license | # Implement a function called, areThereDuplicates which accepts a variable number of arguments, and checks whether there are any duplicates among the arguments passed in. You can solve this using the frequency counter pattern OR the multiple pointers pattern.
# // Examples:
# // areThereDuplicates(1, 2, 3) // false
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.