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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bfa714f1961b17f96194fd2a96e97434c0c854d7 | Ruby | eric-dowty/mythical_creatures | /medusa.rb | UTF-8 | 402 | 3.421875 | 3 | [] | no_license | class Medusa
attr_reader :name, :statues
def initialize(name)
@name = name
@statues = []
end
def empty?
if @statues.length = 0
true
else
false
end
end
def stare(victim)
@statues << victim
victim.stone = true
end
end
class Person
attr_reader :name
attr_accessor :stone
def initialize... | true |
92780987922ff8d8b4d2d013a3f186dcf8f3f1e0 | Ruby | car2323/w2 | /day5/lib/post.rb | UTF-8 | 445 | 3.15625 | 3 | [] | no_license | #Post class
class Post
attr_reader :created_at, :title
attr_accessor :text, :updated_at
def initialize(titlep, textp)
@title = titlep
@created_at = Time.now
@text = textp
@updated_at = nil
end
def test_atribute?
value_return = false
if ((@title != "" ) && (@cre... | true |
1c481f90ccde2633e240abfda70f392a781737d4 | Ruby | nathanmeira/aws-autoscale-workers | /app/services/interval_service.rb | UTF-8 | 2,561 | 2.71875 | 3 | [] | no_license | class IntervalService
attr_reader :cycle, :work_manager
def initialize(cycle)
@cycle = cycle.is_a?(Cycle) ? cycle : Cycle.find(cycle)
@work_manager = cycle.work_manager
end
def calculate
intervals = build_array_from_array(last_cycle_intervals)
total_intervals = intervals.size
processed_j... | true |
97f3d35f2733f93a2ab2a74f426b5530dc357e34 | Ruby | Unayung/better_round | /lib/better_round/rounding_helper.rb | UTF-8 | 398 | 2.546875 | 3 | [
"MIT"
] | permissive | # :nodoc:
# require 'active_support/number_helper/rounding_helper'
module BetterRound
module RoundingHelper
def better_round(number, symbol = nil, appendix = nil)
s = ''
s += "#{symbol} " if symbol
s += round(number).to_s
s += " #{appendix}" if appendix
s
end
end
end
Integer.i... | true |
dce8ad89184b14143f39af2e77e38e56a771fdae | Ruby | janmilosh/advent_of_code | /spec/day_5/intcode2_spec.rb | UTF-8 | 714 | 2.9375 | 3 | [] | no_license | require_relative '../../day_5/intcode2.rb'
RSpec.describe Intcode2 do
let(:file) { './day_5/data/test_data' }
let(:intcode) { Intcode2.new(file) }
describe '#initialize' do
it 'initializes the data to an array of integers' do
expect(intcode.data_array).to eq [1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, ... | true |
64747fb53e06d34fbb9065dd8c08e8802291ffda | Ruby | guicharn/Quotes-CMS | /lib/directory.rb | UTF-8 | 316 | 3.15625 | 3 | [] | no_license | require "proverb"
require "quote"
class Directory
attr_reader :entries
def initialize
@entries = []
end
def add_entry(entry)
@entries.push(entry)
end
def get_entry_at(index)
@entries[index]
end
def length
@entries.length
end
def to_s
@entries.join("\n")
end
end
| true |
812b598c17b98bf8daad25075171644699638f39 | Ruby | jajapop-m/AtCoder | /過去問/ABC/ABC_161/D_5_calc_next.rb | UTF-8 | 781 | 3.75 | 4 | [] | no_license | # 再帰関数を使わずに全列挙(BFS)
K = gets.to_i
# d桁のルンルン数が全列挙された配列を受け取り、
# d+1桁のルンルン数が全列挙された配列をreturnする関数(calc_next)
def calc_next(ary)
res=[]
ary.each do |val| # 配列の要素全てに対して、
(-1..1).each do |i| # 次の桁を計算し、
add = (val % 10) + i # それが0..9の間なら、1桁目に挿入してresに入れる
res << val*10 + add if add >= 0 && add ... | true |
efe82aea114688854187413f6107c43a729f63e2 | Ruby | brillantewang/Homework | /W2D5/lru_cache.rb | UTF-8 | 337 | 3.09375 | 3 | [] | no_license | class LRUCache
def initialize(max_num)
@max_num = max_num
@cache = []
end
def count
@cache.count
end
def add(el)
delete(el)
shift if count == @max_num
@cache.push(el)
end
def show
p @cache
end
private
def shift
@cache.shift
end
def delete(el)
@cache.dele... | true |
4ba29cc5f1b4fa2275177fb6a2154580eedd44ce | Ruby | PacktPublishing/RabbitMQ-Essentials-Second-Edition | /Chapter02/example_consumer.rb | UTF-8 | 896 | 3.125 | 3 | [
"MIT"
] | permissive | # 1. Require client library
require "bunny"
# 2. Read RABBITMQ_URI from ENV
connection = Bunny.new ENV["RABBITMQ_URI"]
# 3. Start a communication session with RabbitMQ
connection.start
channel = connection.create_channel
# Method for the processing
def process_order(info)
puts "Handling taxi order"
puts info
s... | true |
844d01a3756b3a5066f8b33983ab99cbd267c8bb | Ruby | lazyatom/media_organiser | /lib/downloaded_show.rb | UTF-8 | 1,643 | 3.078125 | 3 | [] | no_license | require 'fileutils'
require 'itunes_wrapper'
class DownloadedShow
attr_reader :filename, :show, :episode, :season, :name
def initialize(filename)
@filename = filename
extract_details
end
def output_path(root="")
File.join(root, show, "Season #{season}", output_filename)
end
def output_filenam... | true |
4529a190756aa161225e7466e876dff34252bb3c | Ruby | chubbymaggie/chromium-history | /lib/scripts/OWNERSoutputParse (2).rb | UTF-8 | 3,423 | 3.203125 | 3 | [] | no_license | def countCommits
count = 0
counts = Array.new
File.open("practiceOutput.txt").each do |line|
if (line.include? "::::")
puts "Over the course of one year, this file has had " + count.to_s + " commits"
puts ""
counts.push(count)
count = 0
puts line.slice(5, line.length - 12)
newFile = true
elsif... | true |
400489ce76d5bf3ef139c9daa07ad671ba6e902e | Ruby | omer-algreeb/Phoenix | /app/lib/voucher_consolidate_line_items.rb | UTF-8 | 1,319 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | class VoucherConsolidateLineItems
def initialize(attributes={})
# voucher, associated_collection = children that needs to be consolidated, attrib = column on which consolidation will be done eg. product_id, payment_mode_id, consolidate = field to be summed up (let me know if you can think of better term)
vouc... | true |
651d23959e07d5a94f590dac795582911799eb99 | Ruby | Tim-Feng/learn-ruby-the-hard-way | /ex14.rb | UTF-8 | 1,639 | 4 | 4 | [] | no_license | # Argument variable with the 1st input parameter
user = ARGV.first
# this variable is not in the exercise, it's for reminding that ARGV calls from 0
reminder = ARGV[1]
# this is just to unite the symbol so that you can change one code for all script
prompt = '>'
puts "Hi #{user}, I'm the #{$0} script."
puts "I'd like... | true |
cc440267665391b47757c9e66261acf80cec24c9 | Ruby | ndlib/curate_nd | /app/models/copyright.rb | UTF-8 | 1,042 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # Responsible for exposing means of looking up a list of copyrights from Locabulary
module Copyright
PREDICATE_NAME = 'copyright'.freeze
# @api public
#
# Get a list of active copyright terms available for selection
#
# @return [Array<#term_label, #term_uri, #description>]
def self.active
ControlledVo... | true |
d39eacf4733f2f1516ab4f97c88d43c4191dde40 | Ruby | 3014zhangshuo/refactoring-ruby | /inline_method.rb | UTF-8 | 193 | 2.9375 | 3 | [] | no_license | def get_rating
more_than_five_late_deliveries? 2 : 1
end
def more_than_five_late_deliveries
@number_of_late_deliveries > 5
end
def get_rating
@number_of_late_deliveries > 5 ? 2 : 1
end
| true |
7b18800c569c0530609191da53f76442863af6ae | Ruby | sergio-bobillier/g | /library/races.rb | UTF-8 | 776 | 3.1875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../race'
# This module contains a constant for each of the five races. Normally these
# would be loaded from a database but since this is conceptual game I want to
# keep it as simple as posible.
#
# @author Sergio Bobillier <sergio.bobillier@gmail.com>
module Races
H... | true |
0bdbc65ddae3275cdfca6d7b7eed8122323a4387 | Ruby | thomas-boyer/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 466 | 2.90625 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
puts "Please type the name of the s... | true |
e8ad3b4648a65be9217ca369cd49ffff45683839 | Ruby | DnailZ/ruby_make_script | /lib/ruby_make_script.rb | UTF-8 | 5,785 | 2.921875 | 3 | [
"MIT"
] | permissive | #
# Usage:
# ```
# require "ruby_make_script"
# make do
# :run .from "a.out" do
# ~ "./a.out"
# end
# "a.out" .from "test.c" do
# ~ "gcc test.c"
# end
# end
# ````
#
#
#
if !system('gem list | grep pastel > /dev/null')
puts "pastel not install automaticly, please 'gem install paste... | true |
c7cd7ba1cb0927720eb8b2dd0c394f5b9a8625f7 | Ruby | jalada/AutoQwert | /auto-qwert.rb | UTF-8 | 1,389 | 2.8125 | 3 | [] | no_license | require 'bundler'
Bundler.require
require 'open-uri'
# Fix for bug in AppConfig
require 'erb'
AppConfig.configure do |config|
config.config_file = "config.yml"
end
class AutoQwert
def state_file
"current.txt"
end
def send_mail
Pony.mail(subject: 'New Qwertee Tee!',
html_body: "<h1>Hi... | true |
84804d4ecc13128a4287dd617fa2b67b54ac7e77 | Ruby | errne/ruby_basics_functions | /part_a/part_a_spec/part_a_spec.rb | UTF-8 | 1,130 | 3.234375 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../part_a")
class TestPart_A < MiniTest::Test
def test_student_name
student1 = Student.new("Jake", "E26")
assert_equal("Jake", student1.name)
end
def test_student_cohort
student1 = Student.new("Jake", "E26")
assert_equal("E26"... | true |
a493e1a988a1ede7c71fb13e41cbe5b1a0ce2885 | Ruby | amy-l-hedges/parrot-ruby-dc-web-042318 | /parrot.rb | UTF-8 | 62 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def parrot(hello = "Squawk!")
puts hello
return hello
end
| true |
e3305c4f76507f9e222e75872aaae90e848d1669 | Ruby | liamzebedee/learning-style-manager | /rails/app/models/ausidentities_test_result.rb | UTF-8 | 8,093 | 3.125 | 3 | [] | no_license | class AusidentitiesTestResult < ActiveRecord::Base
AUS_IDENTITIES = ['Eagle', 'Kangaroo', 'Dolphin', 'Wombat']
QUESTIONS =
[["Do you enjoy having lots of friends, or just a few special friends?",
["Lots of friends.", "A few special friends."]],
["Do you prefer to talk about facts or possibilities?",
["Fa... | true |
21e3de1bf1f69adee0e4c4619a736dcbbe63baed | Ruby | TheKaterTot/Battleship | /test/messages_test.rb | UTF-8 | 2,755 | 3.125 | 3 | [] | no_license | require "./test/test_helper"
require "./lib/messages"
require "./lib/human_player"
require "./lib/computer_player"
require "stringio"
class MessageTest < Minitest::Test
def setup
@player = HumanPlayer.new
@computer = ComputerPlayer.new
end
def test_options
with_stdio do |input, output|
Messag... | true |
58abfe90093802a3a94e55fc32a28d7d057c4db2 | Ruby | cooo/Emular | /instructions/ret.rb | UTF-8 | 425 | 3.265625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | # 00ee - RET
# -------------------------
# Return from a subroutine.The interpreter sets the program counter to the
# address at the top of the stack, then subtracts 1 from the stack pointer.
class Ret
def match?(opcode)
@opcode = opcode
opcode.eql?("00ee")
end
def execute(cpu)
address = cpu.emular... | true |
4d4e5bdf6ab788243803225e5d0f8f217e3aeaeb | Ruby | QWYNG/Echoes | /lib/spotify_track.rb | UTF-8 | 537 | 2.90625 | 3 | [] | no_license | class SpotifyTrack
attr_accessor :name, :popularity, :image_url
def initialize(name, popularity, image_url)
@name = name
@popularity = popularity
@image_url = image_url
end
def deconstruct_keys(keys)
{ name: name, popularity: popularity }
end
def popularity_comment
case self
in na... | true |
04d131fa6b44796061b4376cedd85c0f02d9cb69 | Ruby | javrodri42/discovery_piscine_ruby | /ruby05/ex06/upcase_it.rb | UTF-8 | 79 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
if ARGV[0]
puts ARGV[0].upcase
else
puts "none"
end | true |
98fd954668355d9a62cefc47a874f6303b5148eb | Ruby | theinbetweens/cauldron | /lib/cauldron/operator/concat_operator.rb | UTF-8 | 1,507 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class ConcatOperator
include Cauldron::Operator
def initialize(indexes)
@indexes = indexes
@constant = 'bar'
end
def self.viable?(arguments, response)
return false unless arguments.all? { |x| x.is_a?(String) }
return false unless response.is_a?(String)
# TOD... | true |
253acaec1a6e107ac08cc5fc9c2d5313eea043d8 | Ruby | efueger/salama | /test/melon/fragments/test_itos.rb | UTF-8 | 437 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require_relative 'helper'
class TestRubyItos < MiniTest::Test
include MelonTests
def test_ruby_itos
@string_input = <<HERE
100000.to_s
HERE
@stdout = "Hello there"
check
end
def pest_ruby_itos_looping
@string_input = <<HERE
counter = 100000
while(counter > 0) do
str = counter.to_s
... | true |
cf2576e3d85e1f0e158888378ec93b19f0483569 | Ruby | yoshikig/ruby-cconv | /sjis2euc.rb | UTF-8 | 224 | 2.890625 | 3 | [] | no_license | require 'jis2euc'
require 'sjis2jis'
class Sjis2euc
def initialize
@jis2euc = Jis2euc.new
@sjis2jis = Sjis2jis.new
end
def conv(instr)
jis = @sjis2jis.conv(instr)
euc = @jis2euc.conv(jis)
return euc
end
end
| true |
6471175216508f68ef9b12cdd2a09d7db45b3fb5 | Ruby | WilliamAvHolmberg/AFS-Moped | /models/part_article.rb | UTF-8 | 1,209 | 2.59375 | 3 | [] | no_license | class PartArticle
include DataMapper::Resource
property :id, Serial
property :amount, Integer, :default => 1
property :status, Integer, :default => 0 #0 stands for "Not in stock", 1 stands for ordered but not recieved, 2 stands for "in stock" 3 stands for "dedicated to a specific constru... | true |
86f272a8c73a452fb5a0a98f3ebacc94f13bc6b0 | Ruby | howardbdev/flatiron-bnb-methods-v-000 | /app/models/reservation.rb | UTF-8 | 987 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Reservation < ActiveRecord::Base
belongs_to :listing
belongs_to :guest, :class_name => "User"
has_one :review
validates :checkin, presence: true
validates :checkout, presence: true
validate :guest_and_host_not_the_same, :is_available, :chronological
def duration
(checkout - checkin).to_i
end... | true |
b453dc77ac8fc30376c0b50f45d771d0204a217b | Ruby | danrodz/cartoon-collections-houston-web-071618 | /cartoon_collections.rb | UTF-8 | 457 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(array)
array.each.with_index(1) do |name, index|
puts "#{index}. #{name}"
end
end
def summon_captain_planet(array)
array.map do |word|
word.capitalize << "!"
end
end
def long_planeteer_calls(array)
array.any? do |word|
word.length > 4
end
end
def find_the_cheese(array)
... | true |
a2ba034fae3e9032eebfc1ad1380e85020da42b8 | Ruby | bdimcheff/rag | /lib/rag/aggregator.rb | UTF-8 | 453 | 2.765625 | 3 | [
"MIT"
] | permissive | module Rag
class Aggregator
attr_accessor :column, :start, :block
def initialize(column)
self.column = column
end
def inject(start, &block)
self.start = start
self.block = block
end
# TODO: make this work with streaming somehow
# def all(&block)
# ... | true |
8c7e323019a8080a984778875137f821809fd2c7 | Ruby | yanap/learning | /ruby/meta/sorcery/open_class.rb | UTF-8 | 203 | 3.4375 | 3 | [] | no_license | #encoding: utf-8
# 既存のクラスを拡張する
class String
def my_string_method
"私のメソッド"
end
end
"abc".my_string_method # => '私のメソッド'
p "abc".my_string_method | true |
5ae3fcbcc766e4454bb724a18e5eea9db282543e | Ruby | mengchenwang/Oystercard | /lib/station.rb | UTF-8 | 177 | 3.234375 | 3 | [] | no_license | class Station
def initialize(name, zone)
@station = { :name => name, :zone => zone }
end
def name
@station[:name]
end
def zone
@station[:zone]
end
end
| true |
d773e82c810aef268aa1d30ff1f8ec4ef7465a08 | Ruby | RomaneGreen/web_guesser | /web_guesser.rb | UTF-8 | 824 | 3.171875 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
#rand number before get request established
NUMBER = rand(100)
get '/' do
#erb :index, :locals => {:number => number,:message => 'Guess the number'}
def check_guess(number)
guess = params["guess"].to_i
if guess - 5 > number
erb :index, :locals => {:number => '_',:m... | true |
87dce2981fc85c54555e1e2e499260e571d26659 | Ruby | openstax/active_force | /lib/active_force/attribute.rb | UTF-8 | 664 | 2.5625 | 3 | [
"MIT"
] | permissive | module ActiveForce
class Attribute
attr_accessor :local_name, :sfdc_name, :as
def initialize name, options = {}
self.local_name = name
self.sfdc_name = options[:sfdc_name] || options[:from] || default_api_name
self.as = options[:as] || :string
end
def value_for_has... | true |
fe6be5d12756c0a37dbd8db8829a5de8f4f0abc3 | Ruby | puyo/exercises | /ruby/heartattack/Random.rb | UTF-8 | 228 | 3.453125 | 3 | [] | no_license |
def random(min, max)
return rand(max - min + 1) + min
end
def rollDice(string)
string =~ /([0-9]+)[dD]([0-9]+)/
num = $1.to_i
sides = $2.to_i
result = 0
(1..num).each {
result += random(1, sides)
}
return result
end
| true |
cc8688bcfa81ddb4b89a5c70243f8634a5722c24 | Ruby | Guillaume954/lib | /00_hello.rb | UTF-8 | 171 | 3.21875 | 3 | [] | no_license | def say_hello
return "Hello"
end
def user_name
puts " Quel est ton prénom ?"
print "> "
user_name = gets.chomp
return user_name
end
puts say_hello
puts user_name | true |
60c8b836831566e861f09cbb863849310b12b327 | Ruby | raegertay/exercises-ruby | /ttt_shirlaine.rb | UTF-8 | 1,612 | 4.09375 | 4 | [] | no_license | def start
welcome_message #welcomes player and shows empty board
show_board(board) #gets input from player and reflects X on board
end
#Welcome Message
def welcome_message
puts "Welcome to Tic-Tac-Toe"
new_board = ["0","1","2","3","4","5","6","7","8"]
show_board(new_board)
end
def show_board(board)
puts... | true |
32a293e59624440a30daff25d00735e18fd3d731 | Ruby | stjordanis/ownership | /lib/ownership/global_methods.rb | UTF-8 | 842 | 2.6875 | 3 | [
"MIT"
] | permissive | module Ownership
module GlobalMethods
private
def owner(*args, &block)
return super if is_a?(Method) # hack for pry
owner = args[0]
# same error message as Ruby
raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1)" if args.size != 1
raise ArgumentErr... | true |
437a61f6349866b55d01d3c3d80fb4e35f76c159 | Ruby | anhvu15/pruby | /ruby_month1.rb | UTF-8 | 589 | 3.421875 | 3 | [] | no_license | # l = lambda {"do nothing"}
# puts l.call
# t = lambda do |string|
# if string == "try"
# return "There is no such thing"
# else
# return "Do or do not"
# end
# end
# puts t.call("try")
# addition = lambda { |a,b| a + b}
# subtraction = lambda {|a,b| a - b}
# multiplicaiton = lambda {|a,b| a*b}
# division = l... | true |
612777e7d34c655c4a5718bd6f438da7daf2814d | Ruby | PiotrAleksander/Ruby | /WickedCoolRubyScripts/fileSecurity.rb | UTF-8 | 2,114 | 3.328125 | 3 | [] | no_license | # == Opis programu
#
# fileSecurity.rb: szyfruje i odszyfrowuje pliki; ilustruje działanie Blowfish: bardzo szybkiego symetrycznego szyfru blokowego
#
#
# == Sposób użycia
#
# szyfrowanie [OPCJE] ... PLIK
#
# -h, --help:
# Wyświetla pomoc
#
# --encrypt klucz, -d klucz
# Szyfruje plik przy użyciu hasła
#
# --decrypt... | true |
6b2502cb6cd4ff9d697ca9c8ee422467d5bc0756 | Ruby | eregon/image-demo.rb | /lib/noborder.rb | UTF-8 | 2,622 | 3.453125 | 3 | [
"MIT"
] | permissive | # An image class for people who dont care about border effects
class NoBorderImage
attr_reader :width, :height, :data
def initialize(w, h)
@width = w
@height = h
@data = Array.new(w*h, 0)
end
def from_io(io)
@data = io.read(@width*@height).bytes
self
end
def initialize_copy(from)
... | true |
7e66ef9eb1068303162cdba63852398578e07fa9 | Ruby | marltu/basketball | /spec/objects/throw_spec.rb | UTF-8 | 4,503 | 2.859375 | 3 | [] | no_license | require "./objects/throw"
describe Throw do
before(:each) do
@match = get_empty_match()
@home_member = @match.members_home.first
@away_member = @match.members_away.first
end
it "should increase count of throws after creating throw" do
expect { Throw.new(@home_member, 3) }.t... | true |
f37b11e4a1fbd0f55b537754d25ec4c96ebaf715 | Ruby | ca33dang/close-but-no-cigar | /close_ntdd.rb | UTF-8 | 909 | 2.625 | 3 | [] | no_license | require "minitest/autorun"
require_relative "close_no.rb"
class Test_close_no < Minitest::Test
def test_1_equals_1
assert_equal(1, 1)
end
def test_for_empty_array
my_n = "1234"
bash_n = []
assert_equal([], grand_bash(my_n, bash_n))
end
def test_1234
my_n = "1234"
bash_n = ["1234"]
assert_equal(["1234"... | true |
6ead42cf29c3b8dfac35810d4a722edf1a8c3322 | Ruby | virajs/aws-sdk-core-ruby | /vendor/seahorse/spec/seahorse/model/shapes/shape_spec.rb | UTF-8 | 3,209 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
module Seahorse
module Model
module Shapes
describe Shape do
describe 'from_hash_class' do
it 'fails if shape is not registered' do
expect do
Shape.from_hash_class('type' => 'invalid')
end.to raise_error(/Unregistered shape ty... | true |
71dc4a9dae87f5e1378ed0d1ac18a5b0add693fb | Ruby | sjezewski/dotfiles | /scripts/travis_build.rb | UTF-8 | 1,247 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
require "http"
require "json"
$latest = false
raw = %x`pwd`
$org_and_project = raw.strip.split("/")[-2..-1].join("/")
if ARGV.size == 1 && ARGV.last == "latest"
$latest = true
end
def repos_url(org_and_project)
org_and_project.gsub("/", "%2F")
"https://api.travis-ci.org/repos?slug=#{org_a... | true |
71953302b97fcbe21cc529f725a8a1b6e51ced26 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/kindergarten-garden/9070b234c44e41cc9245cb472e5f6ab8.rb | UTF-8 | 885 | 3.65625 | 4 | [] | no_license | class Garden
def initialize(diagram, students = DEFAULT_STUDENTS)
@diagram, @students = diagram, students.sort
define_student_accessors
end
private
DEFAULT_STUDENTS = ["Alice", "Bob", "Charlie", "David", "Eve", "Fred",
"Ginny", "Harriet", "Ileana", "Joseph", "Kincaid", "Larry"]
... | true |
927de8d496c1486a16398d931899a206dcf58b37 | Ruby | Lawrenccee/w1d5 | /skeleton/lib/00_tree_node.rb | UTF-8 | 1,069 | 3.703125 | 4 | [] | no_license | class PolyTreeNode
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent
@parent
end
def children
@children
end
def value
@value
end
def parent=(node)
if node != parent
parent.children.delete(self) if parent
@parent = node
no... | true |
b95000f7d58d4e01a13fa092119bf9cc6f525664 | Ruby | isabellassobral/nivelamento-aluno | /avaliacao/03-avaliacao.rb | UTF-8 | 1,034 | 4.40625 | 4 | [] | no_license | # 3) Defina uma função “altura_escada” que deve receber um número inteiro para representar a altura da escada e deve retornar um array de strings para representar graficamente a escada.
# Valide o parâmetro da altura da escada, que deve ser um número maior ou igual a 1. Caso contrário, a função deve retornar um array v... | true |
7c5fe396d6c4b3e93c6be0a02ddd16645dc732ef | Ruby | enogrob/ebook-effective-testing-with-rspec-3 | /src/code/09-configuring-rspec/04/configuring_rspec/mocha_spec.rb | UTF-8 | 837 | 2.703125 | 3 | [] | no_license | #---
# Excerpted from "Effective Testing with RSpec 3",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visi... | true |
76f72dc7f8f678dcbd2a96484bbc52e269d40795 | Ruby | zocoi/codefights | /challenges/antWalking.rb | UTF-8 | 1,047 | 3.78125 | 4 | [
"MIT"
] | permissive | # An ant starts at (0, 0) on an xy-coordinate plane and makes a sequence of n steps. Each step is of 1 unit length, and is directed left, right, up, or down. The direction is chosen randomly from these four options.
#
# Find the probability that after n steps the ant ends up back at (0, 0). Return this probability as a... | true |
dab416d479318a098f74cdea3818f07422997316 | Ruby | GovWizely/endpointme | /app/models/ingest_pipeline.rb | UTF-8 | 3,782 | 2.5625 | 3 | [] | no_license | class IngestPipeline
def initialize(name, metadata)
@name = name
@metadata = metadata
@array_context = false
end
def pipeline
Jbuilder.new do |json|
generate_description(json)
generate_pipeline(json)
end.attributes!.with_indifferent_access
end
private
def generate_descript... | true |
069a159cc1bedf550abe8ac5aa4622a4e683302b | Ruby | krismac/course_notes | /week_02/day_4/pry/pry_end_point/specs/cake_shop_specs.rb | UTF-8 | 759 | 2.671875 | 3 | [] | no_license | require( 'minitest/autorun' )
require( 'minitest/rg' )
require_relative( '../cake_shop' )
require_relative( '../cake' )
class TestCakeShop < MiniTest::Test
def setup
ingredients1 = ["chocolate", "cocoa powder", "flour", "eggs", "sugar", "butter"]
cake1 = Cake.new("brownie", ingredients1, 5)
ingredients... | true |
976f4c93155aac6069124d878a0e36e6190b90ff | Ruby | thoughtbot/factory_bot | /spec/acceptance/initialize_with_spec.rb | UTF-8 | 6,037 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | describe "initialize_with with non-FG attributes" do
include FactoryBot::Syntax::Methods
before do
define_model("User", name: :string, age: :integer) do
def self.construct(name, age)
new(name: name, age: age)
end
end
FactoryBot.define do
factory :user do
initialize_wi... | true |
7f7d157f4c8ca34e6829a8420fabe0ddd01ffab6 | Ruby | dcere/LearnRubyTheHardWay | /ex17-3.rb | UTF-8 | 111 | 2.640625 | 3 | [] | no_license | #from_file, to_file = ARGV
File.open(ARGV[1], 'w').write(File.open(ARGV[0]).read())
puts "Alright, all done."
| true |
97e3fa96afb438f8793d0f3898943afd65e4274a | Ruby | austinfromboston/projectmonitor | /app/models/dashboard_grid.rb | UTF-8 | 2,019 | 2.5625 | 3 | [
"MIT"
] | permissive | class DashboardGrid
DEFAULT_LOCATION_GRID_SIZE = 63
class << self
def generate(request_params={})
new(request_params).generate
end
end
def initialize(request_params)
@request_params = request_params
@tags = request_params[:tags]
@locations = request_params[:view]
@projects = find... | true |
3e3996efd654c2eb3d227a9db341f437488a053c | Ruby | leemachine/ruby-installer | /Hash.rb | UTF-8 | 552 | 2.828125 | 3 | [] | no_license |
#This is not used!
module Hash
def hash_check
require 'digest/md5'
require 'yaml'
config = YAML.load_file('config/hash.yaml') #Loads the config.yaml file
$hash = config['PyHash'] #read the config file and turn the PyHash fact into a variable
puts "Checking MD5 checksums "
#puts @hash
$md... | true |
555e4bfcdf3a1c7d7567b48efdb084f995b7b2bc | Ruby | crondaemon/sciformbot | /lib/xinfei_bot.rb | UTF-8 | 2,919 | 2.75 | 3 | [] | no_license | require 'telegram/bot'
$commands = Telegram::Bot::Types::ReplyKeyboardMarkup.new(one_time_keyboard: true, resize_keyboard: true,
keyboard: [
['cos\'è la XinFei?', 'dove sono i corsi'],
%w(orari costi promo),
%w(sito contatti)
])
def sanitize(text)
text.gsub!('\'', '')
text.gsub!('è', 'e')
text.gsub!('... | true |
5c417c9e74991d5c7d6f2b3aa5d6e8d97fa9f62f | Ruby | jcoglan/oyster | /lib/oyster/options/glob.rb | UTF-8 | 244 | 2.515625 | 3 | [
"MIT"
] | permissive | module Oyster
class GlobOption < Option
def consume(list)
Dir.glob(list.shift)
end
def default_value
super([])
end
def help_names
super.map { |name| name + ' ARG' }
end
end
end
| true |
6dee94aba6f1d93fa5463c5ddfc230fcbe5cda07 | Ruby | Kisamict/ruby | /homework8/2.rb | UTF-8 | 100 | 3.09375 | 3 | [] | no_license | def average(array)
return puts 0 unless array.all?(Integer)
p array.inject(:+) / array.size
end
| true |
8b1c7aca32146c4d387ad664c10242cf9ce1e918 | Ruby | robertoplancarte/rapier | /rapier_lang/compilador/CUA.rb | UTF-8 | 741 | 2.984375 | 3 | [] | no_license | #clase cuadruplo que junta strings. los operandos son arreglos de strings donde [0]:nombre, [1]:tipo y [2]:dir_mem
class Cuadruplo
attr_accessor :operador, :operando1, :operando2, :respuesta
def initialize(operador, operando2, operando1, respuesta='resp')
@operador = operador
@operando1 = operando1
@ope... | true |
8ab0d838427b7247f1e6dfa9ffd8cd1af2d36bd6 | Ruby | gudata/manga-downloadr-test-performance-mode | /simple-chapters-processor.rb | UTF-8 | 279 | 2.546875 | 3 | [] | no_license | require 'nokogiri'
require 'singleton'
class SimpleChaptersProcessor
include Singleton
def get_page_paths(chapter_page)
Nokogiri::HTML(chapter_page).
xpath("//div[@id='selectpage']//select[@id='pageMenu']//option").
map{|option| option['value'] }
end
end
| true |
87547c1cd07ab7b5de4186c82f1aa3c2f62f6ea2 | Ruby | beastie87/everypolitician-data | /rakefile_common.rb | UTF-8 | 3,765 | 2.9375 | 3 | [] | no_license |
# We take various steps to convert all the incoming data into the output
# formats. Each of these steps uses a different rake_helper:
#
# Step 1: combine_sources
# This takes all the incoming data (mostly as CSVs) and joins them
# together into 'sources/merged.csv'
# Step 2: verify_source_data
# Make sure that the m... | true |
0d6b412773362c09e3efe1dda10af1acbc463ca7 | Ruby | MarilenaRoque/CodeChallenges | /jewels_and_stones.rb | UTF-8 | 424 | 3.25 | 3 | [] | no_license | # @param {String} j
# @param {String} s
# @return {Integer}
def num_jewels_in_stones(j, s)
s = s.split('')
hash = {};
counter = 0
s.each do |el|
if hash[el]
hash[el] = hash[el] + 1
else
hash[el] = 1
end
end
j = j.split('')
j.each do |el|
... | true |
5ec6bfc69916d089e91a4a3d0e0d0a1aaf681cf8 | Ruby | codemargaret/contact | /lib/contact.rb | UTF-8 | 892 | 3.0625 | 3 | [
"MIT"
] | permissive | class Contact
@@list = []
attr_accessor :first_name, :last_name, :address, :phone_number
attr_reader :id
def initialize(attributes)
@first_name = attributes.fetch("first_name")
@last_name = attributes.fetch("last_name")
@address = attributes.fetch("address")
@phone_number = attributes.fetch("ph... | true |
c973bb313b06cd5842ff65bfc6c16fcd8614da60 | Ruby | MarcoBgn/bolt-template | /app/models/kpis/base.rb | UTF-8 | 3,272 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
# Abstract base class inherited by all the widgets
class Kpis::Base < ApplicationModel
attr_accessor :title, :settings, :hist_parameters, :currency, :watchables, :alerts
# Constants to be defined in child class
# BASE_ENTITIES = [String] - List of entities on which the KPI calculati... | true |
edf3366b0dc4a60b810f3305f36dc6467eaceb03 | Ruby | samtalks/sam-personal | /1011-dogstr/dogstr-original/generator.rb | UTF-8 | 583 | 2.921875 | 3 | [] | no_license | require_relative './environment'
# 100.times do
# Dog.new.tap do |d|
# d.name = Faker::Name.name
# d.color = Faker::Lorem.word
# d.bio = Faker::Lorem.paragraph
# d.save
# end
# end
index = ERB.new(File.open('lib/templates/index.erb').read)
dogs = Dog.all
File.open('_site/index.html', 'w+') do |f... | true |
32b577601657532f3116e2cba9736e6c058b45d3 | Ruby | pincsolutions/rosruby | /test/test_msg.rb | UTF-8 | 1,127 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
require 'ros'
require 'rosgraph_msgs/Log'
require 'std_msgs/UInt8MultiArray'
require 'test/unit'
class TestMessageInitialization < Test::Unit::TestCase
def test_message
now = ROS::Time.now
log = Rosgraph_msgs::Log.new(:header => Std_msgs::Header.new(:seq => 1,
... | true |
7434a3d5943be5c89de2b06319258b9d6607eb68 | Ruby | johslarsen/dotfiles | /test/bin/nrandfile_test.rb | UTF-8 | 789 | 2.640625 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/env ruby
require 'minitest/autorun'
require 'set'
require_relative '../test_helper'
class NrandfileTest < Minitest::Test
def test_that_2_runs_gives_different_result
files = Set.new(1.upto(100).map{|n| n.to_s})
tmpdir_with(*files) do |root|
a = nrandfile(4, root)
assert_equal 4, a.leng... | true |
e4b233a56bae9fd96ba4462aef1111c5a8ea72b2 | Ruby | ffloyd/flows | /lib/flows/shared_context_pipeline/track_list.rb | UTF-8 | 1,125 | 2.703125 | 3 | [
"MIT"
] | permissive | module Flows
class SharedContextPipeline
# @api private
class TrackList
attr_reader :current_track
def initialize
@tracks = { main: Track.new(:main) }
@current_track = :main
end
def initialize_dup(_other)
@tracks = @tracks.transform_values(&:dup)
end
... | true |
deb62e8e3b0176283418584cfe3526761dab0da7 | Ruby | maRce10/marce10.github.com | /vendor/bundle/ruby/2.5.0/gems/jekyll-github-metadata-2.2.0/lib/jekyll-github-metadata/value.rb | UTF-8 | 1,538 | 2.75 | 3 | [
"MIT"
] | permissive | require "json"
module Jekyll
module GitHubMetadata
class Value
attr_reader :key, :value
def initialize(*args)
case args.size
when 1
@key = "{anonymous}"
@value = args.first
when 2
@key = args.first.to_s
@value = args.last
else
... | true |
008e2c6ce64b29a6272cf0dba976a6221a695e86 | Ruby | tynmarket/coffeehub | /app/models/coffee.rb | UTF-8 | 522 | 2.53125 | 3 | [
"MIT"
] | permissive | class Coffee < ApplicationRecord
PER_PAGE = 10
belongs_to :site
enum roast: {
unknown: 0, light: 1, cinnamon: 2, medium: 3, high: 4,
city: 5, fullcity: 6, french: 7, italian: 8
}
enum_text :roast
class << self
def for_api(page)
eager_load(:site).order(created_at: :desc, id: :desc).page(... | true |
4b37ab167d5bfa4495387ea8c14501b1ba23c5d7 | Ruby | csilva1/phase-0-tracks | /ruby/list/list.rb | UTF-8 | 235 | 3.203125 | 3 | [] | no_license | class TodoList
def initialize(list_array)
@list = list_array
end
def get_items
@list
end
def add_item(item)
@list << item
end
def delete_item(item)
@list.delete(item)
end
def get_item(index)
@list[index]
end
end
| true |
fc5ed3d2295b3b7122e07559e5c75af05959d366 | Ruby | Eractus/CWRK-W3D2 | /aa_questions/reply.rb | UTF-8 | 2,274 | 2.71875 | 3 | [] | no_license | require 'sqlite3'
require 'singleton'
require 'byebug'
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super('questions.db')
self.type_translation = true
self.results_as_hash = true
end
end
class Reply
def self.find_by_id(id)
reply = QuestionsDatabase.instance.exe... | true |
d2b86c79cfd0a8043f0745d167ebbd9cd1cc52ba | Ruby | thedoritos/resheet | /src/resheet/sheet.rb | UTF-8 | 1,283 | 2.78125 | 3 | [] | no_license | module Resheet
class Sheet
attr_reader :error
attr_reader :header, :rows, :records
def initialize(sheets_service, spreadsheet_id, resource)
@sheets_service = sheets_service
@spreadsheet_id = spreadsheet_id
@resource = resource
end
def fetch
begin
values = @sheets_... | true |
b709594518600f1f5c823ce9a6bc862edbc2f02a | Ruby | leahhuyghe/codecore-fundamentals | /week_2/hash_looping.rb | UTF-8 | 314 | 4.25 | 4 | [] | no_license | # Write a hash that three contains Canadian provinces
# as keys and their capital as values then loop
# through it and print each province and its capital
canadian_cities = {"BC" => "Victoria", "ON" => "Ottawa", "Nova Scotia" => "Halifax"}
canadian_cities.each do |k, v|
puts "The Capital of #{k} is #{v}"
end | true |
7c434f170a012f38ce6597fbe25857e77d5bd8f9 | Ruby | marcinszydelko/week2_day4_lab | /star_system.rb | UTF-8 | 1,593 | 3.421875 | 3 | [] | no_license | class StarSystem
attr_reader :name, :planets
def initialize(name, planets)
@name = name
@planets = planets
end
def planet_names
@planets.map { |planet| planet.name }
end
def get_planet_by_name(name)
@planets.find { |planet| planet.name == name }
end
def get_largest_planet
result ... | true |
0a81ef89fe671220d82b45691c9b246d4c7e2257 | Ruby | calacademy-research/antcat | /app/services/markdowns/bolton_keys_to_ref_tags.rb | UTF-8 | 914 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
module Markdowns
class BoltonKeysToRefTags
include Service
attr_private_initialize :bolton_content
def call
replace_with_ref_tags
end
private
def replace_with_ref_tags
split_by_semicolon.map do |part|
part.gsub(/(?<bolton_key>.*?):/)... | true |
99e882dc794a0b438718c5e262880f5bba3f060e | Ruby | rubysoftwaredev/EmailAlerter | /email_sender.rb | UTF-8 | 791 | 2.765625 | 3 | [] | no_license | # This program reads email addresses from a table
# constructs personalized emails and sends the email
require 'rubygems'
require 'gmail_sender'
class EmailSender
attr_accessor :senderEmailer
def initialize(sender_addr,ppw)
@senderEmailer = GmailSender.new(sender_addr,ppw)
end
public
def send_e... | true |
c8f0c39ce71a5e5798c10b323e7d08d845e027f8 | Ruby | d3r3k6/Ruby_Praxy | /localvar.rb | UTF-8 | 293 | 3.765625 | 4 | [] | no_license | #Simple program to illustrate local variable in programs
def doubleThis num
numTimes2 = num * 2
puts num.to_s + ' doubled is ' + numTimes2.to_s
end
doubleThis 44
#The below will throw an error because numTimes2 is a local variable and doesnt exist outside of the method
puts numTimes2.to_s | true |
352f81819f7156eabe2ceb95627b37ad09450502 | Ruby | BilboAtBagEnd/pocket-battlelizer | /calculate-army-points.rb | UTF-8 | 1,186 | 3.65625 | 4 | [] | no_license | #!/usr/bin/ruby
require 'yaml'
require 'optparse'
require 'pocket-battles-1.0.rb'
OptionParser.new do |opts|
opts.banner = <<-END
Given input army units, calculates how much your army is worth.
Available armies:
- #{PocketBattles.armies.join("\n - ")}
Input your units with separate lines per army as:
ARMY1 ... | true |
6637d7f2f96f3a676cbda029510fc52b0ba9d321 | Ruby | kftwotwo/update_contacts | /spec/user_spec.rb | UTF-8 | 1,577 | 3 | 3 | [] | no_license | require('rspec')
require('user')
describe(User) do
before :each do
User.clear
end
describe('#initialize') do
it "will fetch the name" do
test_user = User.new(:name => 'Kevin')
expect(test_user.name()).to(eq('Kevin'))
end
end
describe('#save') do
it "will save the user into an ar... | true |
d8cdd2c5907b07704ade22d8d3d7ad88d89b4b00 | Ruby | smarbaf/2airport-challenge | /spec/airport_spec.rb | UTF-8 | 893 | 3.078125 | 3 | [] | no_license | require 'airport'
## Note these are just some guidelines!
## Feel free to write more tests!!
# A plane currently in the airport can be requested to take off.
#
# No more planes can be added to the airport, if it's full.
# It is up to you how many planes can land in the airport
# and how that is implemented.
#
# If th... | true |
ee9d14c96953dc0f2e24b021702413df7a3d8f93 | Ruby | leoprananta/ruby-basic-syntax | /logic.rb | UTF-8 | 218 | 3.265625 | 3 | [] | no_license | #logic || boolean
== "saya" == "anda" -> false
!= "saya" != "anda" -> true
> , >= 3 >= 2 -> false
< , <= 3 <= 2 -> false
&& 1==1 && 2==3 true && false -> false
|| 1==1 || 2==3 true || false -> true
| true |
8195c0f5430dea553920342c912235df5e9f33be | Ruby | gwright/acts_as_bitemporal | /test/acts_as_bitemporal/range_test.rb | UTF-8 | 5,636 | 2.75 | 3 | [
"MIT"
] | permissive | # encodsng: utf-8
require 'test_helper'
class ActsAsBitemporal::RangeTest < ActiveSupport::TestCase
ARange = ActsAsBitemporal::Range
RangeCases = [
# expected, start, end, visual
[false, 6, 7], # ---o -o
[false, 5, 6], # ---o-o
[false, 4, 5], # ---*o
[true, 3, ... | true |
d9b8f7e2eece0f4ae9ccf564a644729d45a6de9e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/method_source/24054.rb | UTF-8 | 325 | 3.265625 | 3 | [] | no_license | def combine_anagrams(words = [])
uniq_alphabetized_words = alphabetize(words)
grouped_anagrams = []
uniq_alphabetized_words.each do |uaw|
group = []
words.each do |w|
(group << w) if (w.downcase.split("").sort.join == uaw)
(grouped_anagrams << group)
end
end
return grouped_anagrams.uni... | true |
b03a2bb94deb540a825e09c784f97b1ee4c9fe59 | Ruby | coreymartella/project_euler | /p030.rb | UTF-8 | 537 | 3.765625 | 4 | [] | no_license | load 'common.rb'
def p30(n=5)
(2..10**(n+1)-1).reduce(0) do |r,i|
r + (i.to_s.chars.reduce(0){|s,d| s + d.to_i**5} == i ? i : 0)
end
end
# Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
# 1634 = 14 + 64 + 34 + 44
# 8208 = 84 + 24 + 04 + 84
# 9474 = 94... | true |
3077819478068a2f5cb8ed2fd0d8529662ac7c30 | Ruby | ganmacs/playground | /ruby/sinatra_test/utils/loader.rb | UTF-8 | 386 | 2.640625 | 3 | [] | no_license | module Utils
class Loader
def initialize(klass, file_path = '')
@klass = Models.const_get(klass)
@file_path = file_path
end
def all
@all ||= load_file.map do |o|
@klass.new(o)
end
end
def find(&block)
all.find(&block)
end
private
def load_file
... | true |
3f1e0f85db928741cbae4ae3f4821d895dfc5ba0 | Ruby | bfagundez/rubygoalcoach | /martiancoach.rb | UTF-8 | 8,325 | 3.015625 | 3 | [] | no_license | # RubyGoal - Fútbol para Rubistas
#
# Este documento contiene varias implementaciones mínimas de un entrenador de RubyGoal.#
#
# Esta clase debe implementar, como mínimo, los métodos `name` y `formation(match)`
# Esta clase debe ser implementada dentro del módulo Rubygoal
module Rubygoal
class Martiancoach < Coach
... | true |
256b4343d09c5aeeea217a93404a9bd9739196f1 | Ruby | m-lowen/-matthew-lowen-m-lowen- | /exercises/d3/exercises/fizzbuzz.rb | UTF-8 | 157 | 3.046875 | 3 | [] | no_license | i = 1
while i <=100
if (i%3==0 && i%5==0)
puts "fizzbuzz"
elsif i%3==0
puts "fizz"
elsif i%5==0
puts "buzz"
else puts i
end
i +=1
end
| true |
0626b0bfd39edf9b180e2befdf034a6ca7f9bca3 | Ruby | eddie/benji | /server.rb | UTF-8 | 1,579 | 2.859375 | 3 | [] | no_license | require 'em-websocket'
require 'json'
client_count = 0
browsers = []
def handle_command(data,command,&block)
begin
parsed_data = JSON.parse(data)
if parsed_data["command"] == command
yield parsed_data if block.arity > 0
end
puts parsed_data
rescue
puts 'JSON malformed:',$1
end
end... | true |
8fb2d426bca94196e866675bae83fd04ec8faeae | Ruby | jockofcode/NetworkService | /bin/network_server.rb | UTF-8 | 3,517 | 2.59375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'time'
require 'digest/md5'
require 'base64'
require 'eventmachine'
require 'network_message'
require 'http_message'
require 'gzip'
if ARGV.length == 0 then
port = 8888
else
port = ARGV[0].to_i
if port == 0 then port = 8888 end #should probably test for < 1024
end
STD... | true |
5971e6d200fdd3ade9337b3601b3445ae959203b | Ruby | l-jdavies/ruby_small_problems | /ruby_foundations_problems/medium_2/test_prompt_for_payment_method_transaction.rb | UTF-8 | 524 | 3 | 3 | [] | no_license | # Write a test that verifies that Transaction#prompt_for_payment sets the amount_paid correctly.
require 'stringio'
require 'minitest/autorun'
require_relative 'cash_register'
require_relative 'transaction'
class TestCashRegister < MiniTest::Test
def setup
@register = CashRegister.new(100)
@transaction = ... | true |
66a08fe27661144c92f5d7542c1adb7d250d3d85 | Ruby | satoshi-takano/hataraki | /app/models/guest.rb | UTF-8 | 770 | 2.609375 | 3 | [] | no_license | # coding: utf-8
class Guest < ActiveRecord::Base
belongs_to :user
attr_accessible :login_id, :login_password, :user_id, :memo
validates_presence_of :login_id, :login_password, :user_id, :message=>"は入力が必須です"
validates_format_of :login_id, :with=> /^[0-9A-Za-z]/, :message=>"は半角英数字で入力してください"
validates_format_... | true |
4e67a6804c33e04f635c780adce66d1ab571513e | Ruby | aerodame/sampler | /Algorithms/PairsSearch/Ruby/main.rb | UTF-8 | 590 | 3.546875 | 4 | [] | no_license | # https://github.com/aerodame/sampler
require './pairs_search'
puts "ENTER number of integers to pair[3-100]:"
n=gets.chomp.to_i
if (n < 3) || (n > 100)
puts "Illegal number of values"
abort
end
puts "ENTER sum value to search[4-200]:"
k=gets.chomp.to_i
if (k < 4) || (k > 200)
puts "Illegal... | true |
858b7d29650e4ebcc651397928f106448ad5b191 | Ruby | lastobelus/rudelo | /lib/rudelo/parsers/set_value_parser.rb | UTF-8 | 1,798 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'parslet'
module Rudelo
module Parsers
module Space
include Parslet
rule(:space) { match["\t "].repeat(1) }
rule(:space?) { space.maybe }
def spaced_op(s)
space >> str(s).as(:op) >> space
end
def spaced_op?(s, protect=nil)
... | true |
eca746efe9b3247822273864296bbb07038e2556 | Ruby | rinapratama335/belajar-ruby | /1.Dasar Banget/11.upto_dan_downto.rb | UTF-8 | 140 | 3.046875 | 3 | [] | no_license | 5.upto(10).each do |no|
puts "Perulangan naik ke-#{no}"
end
puts puts
10.downto(3).each do |x|
puts "Perulangan turun ke-#{x}"
end | true |
f962f2b39e062ccd66ced0966eb3e1d1d7ac236f | Ruby | tcopeland/occams-record | /lib/occams-record/query.rb | UTF-8 | 3,840 | 2.84375 | 3 | [] | no_license | require 'occams-record/batches'
module OccamsRecord
#
# Starts building a OccamsRecord::Query. Pass it a scope from any of ActiveRecord's query builder
# methods or associations. If you want to eager loaded associations, do NOT us ActiveRecord for it.
# Instead, use OccamsRecord::Query#eager_load. Finally, cal... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.