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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3fc1a3b619b2a85140beae05038fc1e6b4b4bb7e | Ruby | Thomascountz/battle_boats | /lib/battle_boats/null_ship.rb | UTF-8 | 249 | 2.90625 | 3 | [
"MIT"
] | permissive | module BattleBoats
class NullShip
attr_reader :name, :length, :symbol
def initialize
@name = "nothing"
@length = 1
@symbol = "X"
end
def empty?
true
end
def hit; end
def sunk?; end
end
end
| true |
14970f5e4bca03fe322e7dfcc330a3036c69e2b0 | Ruby | ChristopherJamesN/mmcli | /lib/mmcli/cli/application.rb | UTF-8 | 3,259 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'thor'
require 'fileutils'
require 'tempfile'
require 'find'
module Mmcli
module Cli
class Application < Thor
include Thor::Actions
class_option :h
class_option :l, :type => :array, :lazy_default => []
class_option :d, :type => :array, :lazy_default => []
class_option :a, :type =>... | true |
3c879b1dccba0a39f606bcaf84ddec4a486fc851 | Ruby | amypetrie/module_3_diagnostic | /app/models/station.rb | UTF-8 | 147 | 2.796875 | 3 | [] | no_license | class Station
attr_reader :name, :distance
def initialize(data)
@name = data["station_name"]
@distance = data["distance"]
end
end
| true |
ee54d9fd5f0056ee8539c88b6dcead51421545de | Ruby | Srossmanreich/phase-0 | /week-6/pad-array-refactor/my_solution.rb | UTF-8 | 635 | 4.15625 | 4 | [
"MIT"
] | permissive | # Review and Refactor: Pad an Array
# I worked on this challenge [by myself, with: ].
# My original solution:
def pad!(array, min_size, value = nil) #destructive
if array.size >= min_size
return array
else
i = min_size - array.size
i.times { array << value }
array
end
end
def pad(array, min_siz... | true |
136771188cd08fccc83f2f2516a936900232eba0 | Ruby | crbecker1/mymntr | /app/views/shared/profiles/om_baby.html.rb | UTF-8 | 1,122 | 2.703125 | 3 | [
"MIT"
] | permissive | class Views::Shared::Profiles::OmBaby < Views::Base
def content
strong "OM-Baby!", class: 'orange-title'
hr
p "Who knew a person who could control their mind could literally move
mountains?! When did you first know you could do that? Like, when you were a baby and
you could just go to your 'quiet place' a... | true |
b7e47f31a7c064a284a7be8f5c3123ac571f4534 | Ruby | txus/invaders | /classes/bullet/bullet.rb | UTF-8 | 1,121 | 3.21875 | 3 | [
"MIT"
] | permissive | class Bullet
attr_reader :x, :y, :power
@@bullets = Array.new
def initialize(window,x,y,direction = :none)
@x, @y = x, y
@width, @height = 3, 6
@direction = direction
@window = window
@power = 1
@@bullets << self
@img = nil
end
def move
@y -= speed
case @direction
when... | true |
f2b86ed095057207c31a93bcd1085692cbed4d1c | Ruby | YuukiMAEDA/AtCoder | /Ruby/ABC/B/Two_Anagrams.rb | UTF-8 | 104 | 3 | 3 | [] | no_license | s=gets.chomp.split("").sort.join("")
t=gets.chomp.split("").sort.reverse.join("")
puts s<t ? "Yes":"No"
| true |
1056f76bfa736408c7b13db2c79e74c4147a172e | Ruby | ethransom/tic-tac-toe | /lib/grid.rb | UTF-8 | 3,352 | 3.90625 | 4 | [
"MIT"
] | permissive | module TicTacToe
# TODO: Refactor. Subclass array somehow?
class Grid
def initialize
@table = []
3.times do |i|
@table[i] = Array.new 3, :blank
end
end
# http://lukaszwrobel.pl/blog/copy-object-in-ruby
def clone
grid = Grid.new
grid.each! do |v... | true |
8aabd3658f4953174c3597ea085a2731132aab39 | Ruby | philly-mac/deploy | /vendor/ruby/1.8/gems/rr-1.0.2/spec/api/stub/stub_spec.rb | UTF-8 | 4,171 | 2.796875 | 3 | [
"MIT"
] | permissive | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
class StubSpecFixture
attr_reader :initialize_arguments
def initialize(*args)
@initialize_arguments = args
yield if block_given?
method_run_in_initialize
end
def method_run_in_initialize
end
end
describe "stub" do
attr_... | true |
16f1b80a757af40c050fa13c40bd265f8b1b08cb | Ruby | jairodiaz/code-kata-2013j | /lib/editor.rb | UTF-8 | 1,077 | 2.984375 | 3 | [] | no_license | require "simple_image_editor/image_floodfill"
require "simple_image_editor/image"
require "simple_image_editor/command_validatable"
require "simple_image_editor/command"
require "simple_image_editor/null_command"
require "simple_image_editor/command_set"
require "simple_image_editor/image_commands"
module SimpleImageE... | true |
fcc2b898c03a49ca3afb4a40922333b065001c48 | Ruby | rdhkim/TheOdinProject | /basic_ruby/stock_picker.rb | UTF-8 | 1,083 | 3.765625 | 4 | [] | no_license | #> stock_picker([17,3,6,9,15,8,6,1,10])
#=> [1,4] # for a profit of $15 - $3 == $12
# The code looks to find the biggest difference from d2 and d1 selling in chronological order of days
def stock_picker(stock_array)
buy_sell_output = []
real_output = []
largest_difference = 0
for i in 0...stock_... | true |
2248f5712729a424abfac70f83295e15298a61d8 | Ruby | tk0358/design_patterns_in_ruby | /chapter13_factory/13_01.rb | UTF-8 | 681 | 4.25 | 4 | [] | no_license | class Duck
def initialize(name)
@name = name
end
def eat
puts("アヒル #{@name} は食事中です。")
end
def speak
puts("アヒル #{@name} はガーガー鳴いています。")
end
def sleep
puts("アヒル #{@name} は静かに眠っています。")
end
end
class Pond
def initialize(number_ducks)
@ducks = []
number_ducks... | true |
bc5ca07e1fe5455a4bbcdda7fc3e8e6178080b35 | Ruby | evheny0/bsuir-labs | /model/lab4/model.rb | UTF-8 | 1,213 | 3.1875 | 3 | [] | no_license | require './source.rb'
require './channel.rb'
require './end_channel.rb'
class Model
def initialize(prob = 0.5, end_channel_intensity = 5)
initialize_blocks prob, end_channel_intensity
link_blocks
@states_log = []
end
def start(count)
count.times do |_|
increase_counter
save_state
... | true |
c00cfbc4afc44af10b22dc2f177f44abbfabf6e9 | Ruby | oleg/incubator | /understanding-computation/ruby/transition_semantics/boolean_test.rb | UTF-8 | 632 | 2.9375 | 3 | [] | no_license | require './boolean'
require './test_setup'
class BooleanTest < Test::Unit::TestCase
def test_new_true
assert_equal true, Boolean.new(true).value
end
def test_new_false
assert_equal false, Boolean.new(false).value
end
def test_to_s
assert_equal "true", Boolean.new(true).to_s
assert_eq... | true |
9845185334a6613c2f85d83acff183e34da44cce | Ruby | exoprise/parsley_simple_form | /lib/parsley_simple_form/form_builder.rb | UTF-8 | 1,437 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'simple_form'
module ParsleySimpleForm
class FormBuilder < SimpleForm::FormBuilder
attr_reader :attribute_name
# this thing insists on using i18n server-side for validation error messages, we want client like parsley is used to
attr_accessor :use_client_translations
def input(attribute_n... | true |
686f5bb2016cb419273249210ca322b795b724e3 | Ruby | okjill/phase-0-tracks | /ruby/nested_data_structures.rb | UTF-8 | 1,736 | 3.15625 | 3 | [] | no_license | # Design and build a nested data structure that represents a real-world construct
my_playlists = {
okokok: {
season: "Winter 2015",
best_tracks: [
"Vince Staples: Blue Suede",
"Viet Cong: Continental Shelf",
"Perfume Genius: Fool",
"Kendrick Lamar: Ki... | true |
7c6533d455e0fde7d61cff0a11af9c33272c855c | Ruby | compostbrain/data-structures | /02-Algorithms-and-Complexity/07-Complex-Problems/tour.rb | UTF-8 | 232 | 3.640625 | 4 | [] | no_license | class Tour
attr_reader :cities, :distance
def initialize(cities)
@cities = cities
end
def distance
(0..cities.length - 1).reduce(0) do |sum, i|
sum + City.distance(cities[i], cities[i - 1])
end
end
end
| true |
2370bcbaaf94bc8a1d989d620c28999e1b0d395a | Ruby | btmccollum/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 767 | 4.15625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(array) #takes in an array of names, iterates over each and creates a new array with their badges
array.map{|attendee_name| badge_maker(attendee_name)}
end
def assign_rooms(array) #take an array of guests and creates a new array ... | true |
30d63700b69845f58636cbcec8ebec2aef9a0573 | Ruby | jtp184/inkblot | /bin/pi/install_deps | UTF-8 | 3,441 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/inline'
require 'optparse'
gemfile do
source 'https://rubygems.org/'
gem 'colorize'
gem 'tty-prompt'
gem 'net-ssh'
end
# Set up the prompt for user input
prompt = TTY::Prompt.new(
interrupt: -> { puts 'x'.light_black; puts 'Goodbye'.red; a... | true |
566aa02658dd027fdc1ed15b0f0fd970a49a643c | Ruby | jlong/acoustic | /lib/acoustic/configuration.rb | UTF-8 | 2,365 | 3.15625 | 3 | [
"MIT"
] | permissive | module Acoustic #:nodoc:
#
# The Acoustic::Configuration class provides a base class for the many different
# kinds of configuration used by Acoustic, including Acoustic::Settings and
# Acoustic::Router::Configuration.
#
# The main idea behind this object is to provide a way to capture the values
# store... | true |
cf74770917c3744501fa5925e8904c27dec56cef | Ruby | gengogo5/atcoder | /typical90/t029_2.rb | UTF-8 | 835 | 3.359375 | 3 | [] | no_license | # 小課題2
# 座標圧縮
# 問われているのは最も高い位置だけなので、座標間の距離情報は不要
W,N = gets.split.map(&:to_i)
L,R = N.times.map { gets.split.map(&:to_i) }.transpose
comp = []
# レンガの始点終点座標を記録
N.times do |i|
comp << L[i]
comp << R[i]
end
comp.sort! # 小さい順に並べる
comp.uniq! # 重複除外
# LとRの値を圧縮したlとrを求める
# l[i] = L[i]が何番目に小さい値か
l = []
r = []
N.times do |... | true |
b9b484543f1e74b190ffad7f07cea12f608eaa14 | Ruby | NicoBuch/social-fridge-api | /app/utils/push_notification.rb | UTF-8 | 1,156 | 2.5625 | 3 | [] | no_license | class PushNotification
attr_reader :user, :message, :data, :n_type
def initialize(options = {})
@user = options[:user]
@message = options[:message]
@data = options[:data]
@n_type = options[:n_type]
end
def simple_notification
return unless can_send?
user.device_tokens.each do |device_t... | true |
19cc3ddd837ea563d69d9cf1dbd24cd26e3212dd | Ruby | MarkRFerguson/ruby_steps | /votes.rb | UTF-8 | 243 | 2.96875 | 3 | [
"MIT"
] | permissive | lines = []
File.open("votes.txt") do |file|
lines=file.readlines
end
votes = Hash.new(0)
lines.each do |line|
name = line.chomp
name.upcase!
votes[name] += 1
end
votes.each do |name, count|
puts "#{name}: #{count}"
end
| true |
3af1407daef3a8cc2d3d5046027f9c5d5a2bcb18 | Ruby | raysuke/til | /ruby/if.rb | UTF-8 | 118 | 3.3125 | 3 | [] | no_license | num = ARGV[0].to_i
if num < 5
puts 'too small!'
elsif num === 5
puts 'equal!'
elsif num > 5
puts 'too big!'
end
| true |
ba162a0353c29793f6c806fc1022d92438177ee9 | Ruby | Sruthisarav/My-computer-science-journey | /Open App Academy/Ruby/Enumerables and Debugging/Enumerables E1/enumerables.rb | UTF-8 | 3,360 | 3.9375 | 4 | [] | no_license | class Array
def my_each(&prc)
len = self.length
count = 0
while(count != len)
prc.call(self[count])
count += 1
end
return self
end
def my_select(&prc)
newArr = []
self.my_each {|ele| newArr << ele if prc.call(ele)}
retur... | true |
d35eab739689e7e20332c1354ea49ff417309111 | Ruby | Ronan-deGuernisac/RachelMinto-intro_programming | /methods/ex_4.rb | UTF-8 | 78 | 2.859375 | 3 | [] | no_license | puts "I expect the code will print 'Yippeee!!!!'"
puts "... but I was wrong." | true |
63583feb39fb1874bdb28a3494a088d440cfae9b | Ruby | ethunk/Launch-Academy | /learn-oop/lib/cat.rb | UTF-8 | 158 | 2.890625 | 3 | [] | no_license | #cat
class Cat
attr_reader :name, :lives
def initialize(name)
@name = name
@lives = 9
end
end
garfield = Cat.new("Garfield")
| true |
c3da1322349f301633439ad968b28c0e113e46cd | Ruby | juzen2003/Algorithm-Project | /yujen_chang_3/lib/heap.rb | UTF-8 | 2,487 | 3.6875 | 4 | [] | no_license | class BinaryMinHeap
attr_reader :store, :prc
def initialize(&prc)
@store = []
@prc = prc
end
def count
@store.length
end
def extract
# swap root and last node
@store[0], @store[-1] = @store[-1], @store[0]
# pop out last value
pop_val = @store.pop
# heapify down
BinaryM... | true |
ae2d196de1c64cb1b42622b43c9641259c262037 | Ruby | ncuesta/vh | /lib/vh/apache_installer.rb | UTF-8 | 1,849 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | require "vh/base_config"
require "vh/apache_config"
module Vh
# Apache installation manager
class ApacheInstaller < BaseConfig
DEFAULT_CONFIG_PATH = "/etc/apache2/httpd.conf"
# Initializes a new instance of this class.
#
# @param [String] target_path The path to the vh configuration file that will... | true |
a7075b8abe09491fc6548906ef3fb0420d4f6239 | Ruby | yutakakinjyo/attend | /db/seeds.rb | UTF-8 | 1,233 | 2.515625 | 3 | [] | no_license | student_role = Role.create(name: 'student')
('A'..'Z').each do |item|
user = User.new
user.name = "student#{item}"
user.role_id = student_role.id
user.email = "student#{item}@example.com"
user.password = 'valid_password'
user.password_confirmation = 'valid_password'
user.save!
end
teacher_role = Role.... | true |
5d1bbfe0dc9e2cba2ac139edfbb316c7b663382f | Ruby | ChamGeeks/ChamonixHackathon2015 | /models/offer.rb | UTF-8 | 633 | 2.65625 | 3 | [] | no_license | class Offer
include DataMapper::Resource
property :id, Serial
property :starts_at, Integer
property :ends_at, Integer
property :tags, String
property :type, String
property :extra_info, String
belongs_to :day_of_week
belongs_to :bar
def day
day_of_week.name
end
def ends
"#{ends_at/60... | true |
d546786d207cd9f2961fbe21dea56b9683328c34 | Ruby | rterrabh/rdf | /dataset/vagrant/lib/vagrant/registry.rb | UTF-8 | 1,246 | 2.90625 | 3 | [
"MIT"
] | permissive | module Vagrant
class Registry
def initialize
@items = {}
@results_cache = {}
end
def register(key, &block)
raise ArgumentError, "block required" if !block_given?
@items[key] = block
end
def get(key)
return nil if !@items.key?(key)
return @results_cache[key] if... | true |
ced9936b33a95f9e737d3af8c8e5089f81873667 | Ruby | yshen901/AAClasswork | /W4D1/knights_travails/lib/knight_path_finder.rb | UTF-8 | 1,567 | 3.609375 | 4 | [] | no_license | require_relative "../../Yuci_Shen_polytree/lib/00_tree_node.rb"
class KnightPathFinder
attr_reader :start_pos
def self.valid_moves(pos) #returns array of possible positions to move to
x, y = pos
moves = [
[x-1, y-2], [x-1, y+2],
[x+1, y-2], [x+1, y+2],
[x-2, y-1], [x-2, y+1],
... | true |
4dd0d6a1cd2bd0647cc7859a06adb4f1b8dbb533 | Ruby | spiralofhope/compiled-website | /rb/tests/tc_common.rb | UTF-8 | 1,643 | 2.6875 | 3 | [] | no_license | # Used in class Test_Common < MiniTest::Unit::TestCase
# http://bfts.rubyforge.org/minitest/
require 'minitest/autorun'
class Test_Common < MiniTest::Unit::TestCase
def setup()
#
end
def test_unindent_1()
string = <<-heredoc
one
two
heredoc
expected = "one\ntwo\n"
result = stri... | true |
2034acd46b18265c2986253b1dd7d26de94099b4 | Ruby | carwbrown/99bottles-oop | /lib/bottles.rb | UTF-8 | 1,283 | 3.875 | 4 | [] | no_license | class Bottles
def verse(num)
bottle_number = BottleNumber.for(num)
"#{bottle_number} of beer on the wall, ".capitalize +
"#{bottle_number} of beer.\n" +
"#{bottle_number.action}, " +
"#{bottle_number.successor} of beer on the wall.\n"
end
def verses(n1, n2)
(n1).downto(n2).map{ |n| verse(n)}.join("\... | true |
c89dfe4e9f09e986315c9eaf0c6e998476babd71 | Ruby | rimever/CodeIQ | /Ruby/q07.rb | UTF-8 | 374 | 3.390625 | 3 | [] | no_license | require "date"
def isReversible(dateTime)
strDate = dateTime.strftime("%Y%m%d")
num = strDate.to_i()
num2 = num.to_s(2)
num_reverse = num2.reverse()
return num2 == num_reverse
end
date = Date.new(1964,10,10)
while (date <= Date.new(2020,7,24)) do
if isReversible(date) then
text = date.strftime("%Y... | true |
1fcd453a17b4b2748d6df0af153521414f330ce8 | Ruby | guilhermedacsilva/mines-ruby | /lib/util/attr_boolean.rb | UTF-8 | 561 | 2.953125 | 3 | [
"MIT"
] | permissive | # It includes the class method "attr_boolean :name"
module GameMines
module AttrBoolean
def self.included(base)
base.extend ClassMethods
end
# Class methods
module ClassMethods
def attr_boolean(*names)
names.each do |name|
class_eval "
def #{name}?
... | true |
8bc016fcbfcdfe60cb8bfe43c0ca9b1c8081bf73 | Ruby | ssteeg-mdsol/openapi3-generator | /gems/gems/pdf-core-0.7.0/lib/pdf/core/outline_item.rb | UTF-8 | 732 | 2.6875 | 3 | [
"Apache-2.0",
"GPL-3.0-only",
"GPL-2.0-only",
"Ruby",
"LicenseRef-scancode-public-domain"
] | permissive | module PDF
module Core
class OutlineItem #:nodoc:
attr_accessor :count, :first, :last, :next, :prev, :parent, :title, :dest,
:closed
def initialize(title, parent, options)
@closed = options[:closed]
@title = title
@parent = parent
@count = 0
end
de... | true |
9eec44df04065171caae78c35819193d94c60880 | Ruby | infectedfate/thinknetica | /lesson_5/station.rb | UTF-8 | 496 | 3.125 | 3 | [] | no_license | require_relative 'instance_counter'
class Station
include InstanceCounter
attr_reader :trains, :name
@@instances = 0
def self.all
@@instances
end
def initialize(name)
@@instances += 1
@name = name
@trains = []
@@instances << self
register_instance
end
def take_the_train(tra... | true |
5991cffaaed836c525c2a31e94d5da32b89e1908 | Ruby | learningearnings/Mayhem | /test/unit/credit_manager_test.rb | UTF-8 | 5,989 | 2.75 | 3 | [] | no_license | require 'test_helper'
require_relative '../../app/models/credit_manager'
describe CreditManager do
before do
@transaction_class = mock "Plutus::Transaction"
@account_class = mock "Plutus::Account"
@main_account = mock "main account"
@game_account = mock "game account"
@account_class.stubs(:find_b... | true |
e078bbb70d9029b8f692ff764b6ba9dc422605b4 | Ruby | nbondarenko/teapot | /app/controllers/calculations_controller.rb | UTF-8 | 2,958 | 2.96875 | 3 | [] | no_license | ##
#This class gathered operations for providing calculations
class CalculationsController < ApplicationController
before_action :check_null
def analyse
unless(cookies[:token])
return render json: { error: "Authorization error" }, status: 401
end
respond = Hash.new
valid_array = check_array(d... | true |
e23b0bcaa312725b46feb159eeecec25f13f9357 | Ruby | joshcass/sales_engine | /lib/invoice_item.rb | UTF-8 | 715 | 2.703125 | 3 | [] | no_license | class InvoiceItem
attr_reader :invoice_item, :parent
def initialize(invoice_item, parent)
@invoice_item = invoice_item
@parent = parent
end
def id
invoice_item[:id]
end
def item_id
invoice_item[:item_id]
end
def invoice_id
invoice_item[:invoice_id]
end
def quantity
invoi... | true |
153cdcee7e243c670da0eea0fa08132849f74607 | Ruby | vladlem/train_app | /gifts.rb | UTF-8 | 1,157 | 3.078125 | 3 | [] | no_license | require 'date'
require 'time'
class Gifts
attr_accessor :last_gift_day
FILE_NAME = 'notes.txt'
FILE_PATH = "#{Dir.getwd}/#{FILE_NAME}".freeze
def process_gift
'Gift is needed for Ann!' if is_gift_date?
end
private
def initialize
if FileTest.exists?(FILE_PATH)
@last_gift_day = File.open... | true |
52fe65f58ee70fe39888c7d042ac9e19a0de54cc | Ruby | jamis/castaway | /test/delta_test.rb | UTF-8 | 1,456 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'test_setup'
class DeltaTest < Minitest::Test
Reifiable = Struct.new(:reify)
def test_delta_should_interpolate_values
delta = Castaway::Delta.new(0 => 1, 1 => 5)
assert_equal 1, delta[0]
assert_equal 3, delta[0.5]
assert_equal 5, delta[1]
end
def test_delta_should_interpolate_multiple... | true |
44ed71474c99fc62d525262a446ecfa88c59d64d | Ruby | Jexeones24/hopperfit | /app/models/hopper.rb | UTF-8 | 1,484 | 2.875 | 3 | [] | no_license | require 'pry'
require 'sinatra/activerecord'
require './config/environment.rb'
require 'json'
movements = File.read('./tools/movement_library.json')
MOVEMENT_LIB = JSON.parse(movements)
class Hopper < ActiveRecord::Base
belongs_to :movement
belongs_to :workout
def self.generate_workout(time_domain)
#gener... | true |
25344bde6f624293aeb3ebe77d47f1e6f6c0fee5 | Ruby | maxschram/sheen | /lib/style.rb | UTF-8 | 1,324 | 2.953125 | 3 | [] | no_license | module Style
def self.matches?(elem, selector)
matches_simple_selector?(elem, selector)
end
def self.matches_simple_selector?(elem, selector)
selector.tag_name == elem.name &&
selector.id == elem.id &&
selector.classes.all? do |class_name|
elem.classes.includes?(class_name)
end
... | true |
ac6898143768584d1ef31e2fb8ff860dd757ecfa | Ruby | adamwight/WikiEduDashboard | /lib/importers/rating_importer.rb | UTF-8 | 1,203 | 2.546875 | 3 | [
"MIT"
] | permissive | #= Imports and updates ratings for articles
class RatingImporter
################
# Entry points #
################
def self.update_all_ratings
articles = Article.current.live
.namespace(0)
.find_in_batches(batch_size: 30)
update_ratings(articles)
end
def self.update_n... | true |
5601d128c0f3b7833fb039d76f755d1f01fae7a8 | Ruby | omunozg/simple-math-online-web-prework | /lib/math.rb | UTF-8 | 345 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def addition(num1, num2)
1 + 1
end
def subtraction(num1, num2)
30 - 10
end
def division(num1, num2)
40 / 2
end
def multiplication(num1, num2)
6*5
end
def modulo(num1, num2)
8%3
end
def square_root(num)
math.sqrt(25)
end
def order_of_operation(num1, num2, num3, num4)
3+4((5*6)/7)
#Hint: __ +... | true |
3a6317ff7518aa08d4ac1cc20822a7b25d51776d | Ruby | bridgway/ruby_view_server | /erb_example.rb | UTF-8 | 861 | 3.765625 | 4 | [] | no_license | require 'erb'
x = 42
template = ERB.new "The value of x is: <%= x %>"
puts template.result(binding)
a = 2 + 3
template = ERB.new "2 + 2 is: <%= a %>"
puts template.result(binding)
array = ["lucy", "ben", "marj", "ian"]
template = ERB.new "my family is: <%= array.each {|x| print #{x}} %>"
puts template.result(bindi... | true |
426e54b37f4bd2ea2cbdd6ef34a3c48f5801ef0f | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz131_sols/solutions/Jesse Brown/dynamic.rb | UTF-8 | 1,176 | 3.90625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# Jesse Brown
#
# By using a dynamic programming approach the previous
# geometric series can be reduced to an arithmetic series
# O(n^2)
#
# Limitations:
# Since there is no look-ahead feature here, zero-padded
# arrays will leave off the left zeros.
# ie. [0,0,4,0,0] produces [4,0,0]
# It is the... | true |
a6201d2384ed0e240befe46ade482af76434132f | Ruby | domw30/Learn-To-Program-Chris-Pine | /Ch6-BranchingName.rb | UTF-8 | 1,129 | 4.25 | 4 | [] | no_license | puts "Hello, and welcome to Brixton Library."
# Print string.
puts "My name is Dominic. What is your name?"
# Print string.
name = gets.chomp
# Retrieve string from user and chomp enter.
if name == name.capitalize
# If name starts with a capital letter and returns true..
puts "What a lovely name you have " +... | true |
2c9a02128851dff8848e1c1d3b1b0ff41f4fb715 | Ruby | wvdschel/ProxyBash | /proxybash.rb | UTF-8 | 4,772 | 3.296875 | 3 | [] | no_license | # ProxyBash, Bringing The World Through A Tight Hole
require 'gserver'
require 'timeout'
require 'thread'
require 'yaml'
# base64 used for proxy authentication, super secure
require 'base64'
module ProxyBash
# ForwardThread, forwards data from one socket to another.
# Used by both client and server.
class ForwardT... | true |
cd28290762cfa23aaf171f3c8494737680f9d585 | Ruby | sodatsu01/atcoder-problems | /abc/140/b.rb | UTF-8 | 312 | 3.34375 | 3 | [] | no_license | class Array
def sum
result = 0
self.each {|x| result += x}
result
end
end
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
bonus = []
a.each_with_index { |v, i| bonus << v - 1 if a[i + 1] == v + 1}
ans = b.sum
bonus.each {|i| ans += c[i]}
puts ans
| true |
96de196a9edce93cd2061eb628df25d1754b09bb | Ruby | nearspeak/Backend | /app/controllers/api/v1/tags_controller.rb | UTF-8 | 11,220 | 2.5625 | 3 | [] | no_license | ##
# The API tag controller.
class API::V1::TagsController < API::V1::ApiApplicationController
##
# Get infos about a specific tag via the nearspeak ID.
#
# @return [String] The requested tag as JSON object.
def show
tag_identifier = params[:id]
lang_code = params[:lang]
tag = Tag.with_tag_ide... | true |
c5c523b9ea04eaaabeb8933179d12c271b1ca529 | Ruby | mhammiche/drivy-challenge | /backend/level6/action.rb | UTF-8 | 451 | 2.890625 | 3 | [] | no_license | class Action < Struct.new(:who, :type, :amount)
def delta(updated)
if who != updated.who || type != updated.type
raise ArgumentError, "actions must be of the same owner and type"
end
amount_delta = updated.amount - amount
if amount_delta < 0
amount_delta = -amount_delta
new_type = ... | true |
6068d496ee94b665ef1b832a7682e205ad6581d7 | Ruby | MargotSylvain/rails-longest-word-game | /app/controllers/pages_controller.rb | UTF-8 | 1,801 | 2.78125 | 3 | [] | no_license | require 'open-uri'
require 'json'
class PagesController < ApplicationController
def game
@grid = generate_grid(@size)
@size = params[:number].to_i
end
def score
@grid = params[:grid].downcase
@trial = params[:shot]
@start_time = Time.parse(params[:start_time])
@time_taken = Time.now - @start_time... | true |
f903abb67f9b9379696193ae925842cbee47a5ca | Ruby | mnubiumm/SolutionsForCourseTasks | /factorial.rb | UTF-8 | 230 | 3.3125 | 3 | [] | no_license | module Factorial
def self.kth_factorial(k, n)
raise Exception, 'Invalid args' unless k > 0 && n >= 0
result = 1
(1..n).each do |m|
result *= m
end
return result**k
end
end
| true |
57d426cefb176f22c0b7dcb6f54ddb2e79798b21 | Ruby | deepfryed/ots | /test/test_ots.rb | UTF-8 | 600 | 2.625 | 3 | [
"MIT"
] | permissive | require 'helper'
describe 'OTS' do
it 'parse() should return an article instance' do
OTS.parse("hello world").must_be_kind_of OTS::Article
end
it 'parse() should raise ArgumentError on invalid text' do
assert_raises(ArgumentError) do
OTS.parse(1)
end
end
it 'should return a list of dicton... | true |
4e7f3de54193109af68173b7eb687d2980e0a9da | Ruby | FernandaFranco/assessment-ruby-and-general-programming | /live_video_4.rb | UTF-8 | 1,025 | 3.984375 | 4 | [] | no_license | # def string_reverser(string)
# reversed_array = []
# string.split("").each do |letter|
# reversed_array.unshift(letter)
# end
# reversed_array.join("")
# end
# puts string_reverser("hello world")
# def fizzbuzz(first, last)
# range = (first..last)
# array = []
# range.each do |number|
# array <... | true |
c60ba8eb6ce9a11b6332866e0b7cfb34381943f1 | Ruby | FernandoBasso/programming-how-to | /ruby/other/codecademy/basic/next1.rb | UTF-8 | 332 | 3.5 | 4 | [] | no_license | #!/usr/bin/env ruby -w
for i in 1..5
#
# Go to the `next` iteration of the
# loop in case i # is even.
#
#next if i % 2 == 0
next if i.even?
puts i
end
#
# When a `next` statement runs, remaining statements inside
# a block are skipped, and the code goes immediately to the
# beginning of t... | true |
535c1513451c0ce4145e09fb7991cd57b4e814d6 | Ruby | abarnes1/ruby-exercises | /knights-travails/lib/knights_travails.rb | UTF-8 | 1,065 | 3.1875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'chess/pieces/knight'
require_relative 'chess/position_helpers'
require_relative 'travail_node'
class KnightsTravails
include PositionHelpers
def initialize; end
def knights_moves(starting_position, ending_position)
@root = TravailNode.new(starting_position)
... | true |
ce240880ce03eea478952e6e629b6e08eff0c9b1 | Ruby | bartoszmaka/poker | /hand.rb | UTF-8 | 756 | 3.21875 | 3 | [] | no_license | require_relative 'combination'
require_relative 'card'
class Hand
include Comparable
attr_accessor :cards, :combination
def initialize(cards)
@cards = cards
validate_cards_count
@combination = Combination.new(@cards)
end
def <=>(other)
[combination.score,
combination.first_combination... | true |
11d427599e2adec6b0729ef7f60cd41b8f7be16c | Ruby | FloDenize/jenkins-selenium-tests | /test/selenium/basic_test.rb | UTF-8 | 1,895 | 2.546875 | 3 | [] | no_license | require File.dirname(__FILE__) + "/lib/base"
require File.dirname(__FILE__) + "/pageobjects/newjob"
require File.dirname(__FILE__) + "/pageobjects/pluginmanager"
class BasicSanityTests < JenkinsSeleniumTest
def test_proper_title
go_home
assert_not_nil @driver.title.match("\[Jenkins\]")
end
def test_cre... | true |
0de3c9306866e0b1efab2df25f1a630a90dcb21c | Ruby | VesnaVucinic/countdown-to-midnight-online-web-sp-000 | /countdown.rb | UTF-8 | 414 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | num_of_sec = 10
def countdown (num_of_sec)
while num_of_sec > 0
puts "#{num_of_sec} SECOND(S)!"
num_of_sec -= 1
end
return "HAPPY NEW YEAR!"
end
countdown (num_of_sec)
sleep 5
num_of_sec = 10
def countdown_with_sleep (num_of_sec)
while num_of_sec > 0
puts "#{num_of_sec} SECOND(S)!"
slee... | true |
52f22701778a6af104571376f1ff754b4218ec12 | Ruby | pyro2927/sandman | /lib/sandman.rb | UTF-8 | 4,487 | 2.609375 | 3 | [
"MIT"
] | permissive | require "sandman/version"
require "github_api"
require "bitbucket_rest_api"
module Sandman
@config = {:accounts => []}
@providers = Array.new
def self.filter_args(args)
Sandman.init
if args.count > 1
# try to automatically detect if we're being handed a file or key string
key = args[1]
... | true |
cf8f472935a182a05dc91e3e9553e6cc7daeff0f | Ruby | andysalvadors/gameday_api | /test/test_all_closing_pitchers_for_detroit.rb | UTF-8 | 408 | 2.8125 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | # This test will print a list of the starting pitchers for each of the Detroit
# Tigers games from the 2009 season.
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
require 'team'
team = Team.new('det')
pitchers = team.get_close_pitcher_appearances_by_year('2009')
count = 1
pitchers.each do |ap... | true |
6e146e1c3291de1a52b9991ab948a56b72ffb435 | Ruby | KaoruDev/ruby-mud | /lib/utils/ask_questions.rb | UTF-8 | 524 | 2.765625 | 3 | [] | no_license | module Utils
class AskQuestions
def self.yes_no(question, actions={})
response = Prompter.run(custom_text: "#{question} (y/n) ")
if response.match("y")
return actions[:yes].call if actions[:yes]
elsif response.match("n")
return actions[:no].call if actions[:no]
end
P... | true |
5fc57387894364165e0a3b6d887d55d049081a67 | Ruby | willnotwish/courses | /spec/models/courses/update_spec.rb | UTF-8 | 3,782 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
module Courses
RSpec.describe Update, type: :model do
subject { described_class.new( course ) }
context 'when updating a random course' do
let( :course ) { FactoryBot.create :courses_course, owner: FactoryBot.create( :user ) }
it { is_expected.to be }
it { is_expected.... | true |
ae49e109866d8f14852e84a6aa14db4acbffa565 | Ruby | jessehoareevans/places_ruby | /app.rb | UTF-8 | 539 | 2.796875 | 3 | [] | no_license | require('sinatra')
require('sinatra/reloader')
also_reload('lib/**/*.rb')
require('./lib/places')
get('/') do # '/' root page (index /placesform)
@places = Location.all() #creates an instance variable for where its going to go on the index page
erb(:index)
end
post('/places_form') do
place = params.fetch('place... | true |
925b4ca74563e99aee943207295268252ea972e0 | Ruby | jzeimen/csci568 | /project09/helpers_functions.rb | UTF-8 | 2,670 | 2.96875 | 3 | [] | no_license |
require './active_record_classes.rb'
def user_distance(user1, user2)
genre_ratings_1 = user1.genreratings
genre_ratings_2 = user2.genreratings
gr1 = genre_ratings_1.map{|g| g.genre_id}
gr2 = genre_ratings_2.map{|g| g.genre_id}
possible = gr1 | gr2
ratings_vector_1 = possible.map do |c|
r = Genrerating.f... | true |
c5a86aa28bbbd466f3a77399a52339bbf40a1ea5 | Ruby | levthedev/self_referential_hash | /hash.rb | UTF-8 | 1,359 | 3.25 | 3 | [] | no_license | class SelfHash < Hash
def refer(tracker, tracked)
self[tracker] = lambda { self[tracked] } # => #<Proc:0x007facfb833970@/Users/levkravinsky/man.rb:3 (lambda)>
instance_variable_set("@#{tracker}", :referential) # => :referential
end
def [](key)
clone = Hash[self.keys.zip(self.values)] ... | true |
2916730d8db5d38d5693cc61b660cdcacab1f3a1 | Ruby | jamisonordway/ruby_exercisms | /run-length-encoding/run_length_encoding.rb | UTF-8 | 1,092 | 3.765625 | 4 | [] | no_license | class RunLengthEncoding
def self.encode(input)
char_counts = {} # the value defaults to 0 for any key
result = ""
characters = input.split("")
characters.each_with_index do |char, index|
char_counts[char] = 1 unless char_counts[char] # set to 1 unless it exists
next_char = characters[ind... | true |
0eb8ebcf064237207ced8bd41c3a3d11c2eea244 | Ruby | trans/rubyintherough | /aop/work/scrap2/cut-b.rb | UTF-8 | 873 | 3.4375 | 3 | [] | no_license | # Cuts, Transparent Subclasses
# Copyright (c) 2004 Thomas Sawyer
# cut.rb
class Class
def cut; @cut; end
def cut=(c); @cut=c; end
alias_method :cnew, :new
def new(*args, &blk)
if @cut
@cut.new(*args, &blk)
else
self.cnew(*args, &blk)
end
end
end
class Cut < Module
attr :supercla... | true |
42594191afa1a2ec996d58582bef24926b4a89f7 | Ruby | chad-devos/hello-ruby | /learn/2.rb | UTF-8 | 322 | 4.375 | 4 | [] | no_license | # Run the code in this file by typing:
# ruby 2.rb
# into your command-line interface.
# value1 = 2
# value2 = 3
# if value1 == value2
# puts "yay"
# else puts "phew, math works"
# end
dinner = "tacos"
if dinner == "tacos"
puts "delish"
elsif dinner == "ice cream"
puts "even better"
else puts "booo"
en... | true |
9c12821ab6f4f292017bdc8e108bbfb468267b10 | Ruby | threez/simple_vm | /lib/simplevm/compiler.rb | UTF-8 | 2,547 | 3.265625 | 3 | [] | no_license | module SimpleLanguage
class SyntaxError < Exception
end
class VariableError < Exception
end
end
class InstructionsBuilder
def initialize
@instructions = []
@variable_register = {}
end
def declare_variable(type, name)
# assign a address to the variable
@variable_register[name] = @var... | true |
b404e6ea8735c5b64d3b7b732b0026849a1178a5 | Ruby | AndyLampert/warmups | /cards_in_ruby/in_class_deck.rb | UTF-8 | 805 | 4.0625 | 4 | [] | no_license | class Deck
def initialize # passing in means that you have to pass it in to create the Class!!
@cards = [] # a deck needs to remember what its cards are.
# shorthand for each element of this range, call to_s
ranks = (2..10).map(&:to_s) + ['J', 'Q', 'K', 'A']
ranks.each do |rank|
end
['hearts'... | true |
3f43fb41c2e33b32ff57906dd08b2aebc3dd677e | Ruby | Jgan91/project3 | /app/services/cards_service.rb | UTF-8 | 373 | 2.609375 | 3 | [] | no_license | class CardsService
attr_reader :connection
def initialize
@connection = Faraday.new( url: "http://deckofcardsapi.com/api/" )
end
def deck_of_cards_hash
parse( get_cards )
end
private
def get_cards
connection.get "deck/new/draw/?count=52"
end
def parse( response )
JSON.parse( respon... | true |
fcc5b51c4193b04fa984db76e4e4dc907c739d8b | Ruby | marina101/tic_tac_toe | /game.rb | UTF-8 | 1,138 | 3.875 | 4 | [] | no_license | class Game
require_relative 'board'
require_relative 'player'
finished = false
board = Board.new
player1 = Player.new(1)
player2 = Player.new(2)
puts "Welcome to tic-tac-toe!"
while (!finished) do
board.clearBoard
board.showBoard
even = true #to alternate between player one and play... | true |
099ac97bf33d9783c4a0c740a66f8c2656cd0580 | Ruby | zspector/algorithms | /sorting/sorting.rb | UTF-8 | 1,243 | 3.59375 | 4 | [] | no_license | require 'pry-debugger'
module Sort
# O(n^2)
def self.selection_sort(array)
min_loc = 0
i = 0
j = i + 1
for i in i...array.length
for j in i...array.length
if array[i] > array[j]
min_loc = j
array[i], array[j] = array[j], array[i]
end
end
end
a... | true |
4e0740f9384ccb4dcbcaf7d0eedbb33d604babc3 | Ruby | godefroy29/Glowing-Big-Octo-Bear | /src/Gtk/Menu.rb | UTF-8 | 1,757 | 2.828125 | 3 | [] | no_license | #Classe permettant d'afficher un menu laissant le choix au joueur de faire ce qu'il veut
class Menu
##
#Méthode permettant au joueur de choisir ce qu'il veut faire
def Menu.afficher(fenetre, langue)
padding = 20
boutonJouer = Gtk::Button.new("Test dev")
boutonModeDeJeu = Gtk::Button.new(langue.jouer)
bout... | true |
647ddc5b7863737a52294746e17775920279a45c | Ruby | rawls/cricket-scoreboard | /lib/cricinfo/structs/base.rb | UTF-8 | 1,828 | 2.625 | 3 | [] | no_license | module Cricinfo
module Structs
# Shared helper methods for the Cricinfo structs
class Base
def self.string(json, field_name, required = false)
enforce_required(required, field_name) do
str = json&.fetch(field_name)
str.empty? ? nil : str
end
end
def strin... | true |
6cc678ba46e1e0e8fa600a91cb284c806e68a029 | Ruby | da99/mu_mongo | /helpers/app/Color_Puts.rb | UTF-8 | 591 | 3.15625 | 3 | [
"MIT"
] | permissive |
require 'term/ansicolor'
module Color_Puts
%w{ white red green yellow }.each { |color|
eval( %~
def puts_#{color} msg = nil, &blok
colorize_and_print :#{color}, msg, &blok
end
def colorize_#{color} msg = nil, &blok
colorize :#{color}, msg, &blok
end
~)
}
def c... | true |
d4339d812ebe66439719ce8edda57fbc59b808ac | Ruby | delaneybarrow/kwk-l1-classes-and-instances-lab-ruby-students-l1 | /lib/person.rb | UTF-8 | 225 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # person.rb
class Person
def name=(person_name)
@this_persons_name = person_name
end
def name
@this_persons_name
end
end
adele_goldberg = Person.new
alan_kay = Person.new
adele_goldberg.name
alan_kay.name | true |
8c6022db79a88ee298ebce3f496a5e5a17b37307 | Ruby | jack-nie/ruby-concurrent | /philosopher/actor/philosopher.rb | UTF-8 | 1,119 | 3.40625 | 3 | [] | no_license | require_relative "actor"
require_relative "../lib/chopstick"
require_relative "../lib/table"
require_relative "waiter"
class Philosopher
include Actor
def initialize name
@name = name
end
def dine table, position, waiter
@waiter = waiter
@left_chopstick = table.left_chopstick_at position
@rig... | true |
b55b768d95ce2dea94d177aa69a9d6fd206a02cf | Ruby | vickyjackson/wk3_d4 | /imdb_lab/start_code/console.rb | UTF-8 | 927 | 2.953125 | 3 | [] | no_license | # require('pg')
require_relative('./models/movie')
require_relative('./models/star')
require_relative('./models/casting')
require('pry')
movie1 = Movie.new({ 'title' => 'The Breakfast Club', 'genre' => 'Comedy' })
movie1.save()
movie2 = Movie.new({ 'title' => 'Train of Life', 'genre' => 'Comedy' })
movie2.save()
movie... | true |
42ccc82a7507d2c5ab8d7bfe5893d928cd088a08 | Ruby | dj-sf/ruby-collaborating-objects-lab-v-000 | /lib/song.rb | UTF-8 | 1,164 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :filename, :artist_name, :genre, :artist
@@all = []
def initialize(name)
@name = name
end
def self.all
@@all
end
def save
self.class.all << self
end
def artist=(name) #takes in artist name string and sets @artist to artist object
@art... | true |
fc34774ca6905d15ae84c4a3f0adfac2b9660668 | Ruby | kojix2/ruby-dnn | /lib/dnn/core/link.rb | UTF-8 | 1,546 | 2.6875 | 3 | [
"MIT"
] | permissive | module DNN
class Link
attr_reader :prevs
attr_reader :node
attr_reader :num_outputs
def initialize(prevs: nil, node: nil, num_outputs: 1)
@prevs = prevs
@node = node
@num_outputs = num_outputs
@hold_datas = []
@held_flags = []
@requires_grad = nil
end
def ... | true |
af4bebe415d715700e07a81eeefdb0cf141ef67d | Ruby | eastmad/project-x-classic | /test_input_state.rb | UTF-8 | 2,860 | 2.59375 | 3 | [] | no_license | require_relative "input_state"
require_relative "control_systems/system_test_helper"
include TestHelper
describe InputState do
context "from a :start state" do
before (:each) do
@is = InputState.new(:start)
@is.state.should == :start
end
it "Should accept letters in the start state" do
... | true |
ab606bece7eb72d7b4a2d104694f33be3542c639 | Ruby | ylebedeva/ruby-labs | /course03/module04/assignment-Web-Services/triresults/app/models/address.rb | UTF-8 | 701 | 2.9375 | 3 | [] | no_license | class Address
include Mongoid::Document
field :city, type: String
field :state, type: String
field :loc, as: :location, type: Point
attr_accessor :city, :state, :location
def initialize(city = nil, state = nil, loc = nil)
@city = city;
@state = state;
@location = loc;
end
def mongoize
... | true |
e4b35c432aea46a4b482ea6a7263d09a7c656e01 | Ruby | cpoirier/rcc | /release_1/system/model/elements/slot.rb | UTF-8 | 6,979 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
#================================================================================================================================
# RCC
# Copyright 2007-2008 Chris Poirier (cpoirier@gmail.com)
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in co... | true |
9d7d7c9bceb0695bf4a85426395c69e0e5f0fd1d | Ruby | boacausa/webplatform | /app/lib/phone_format.rb | UTF-8 | 286 | 2.796875 | 3 | [] | no_license | # frozen_string_literal: true
module PhoneFormat
def only_numbers(phone)
phone.gsub(/[^\d]/, "")
end
def mask(phone)
return nil unless phone.present?
phone.gsub!(/\D/, "")
phone.gsub!(/^(\d{2})(\d)/, '(\1) \2')
phone.gsub!(/(\d)(\d{4})$/, '\1-\2')
end
end
| true |
541f0361ab92dc8eb59f1608bd04287d59a0f007 | Ruby | jaimeiniesta/json_contenders | /benchmark.rb | UTF-8 | 4,247 | 2.859375 | 3 | [] | no_license | require "benchmark"
require "avro_turf"
require "avro_turf/messaging"
require "msgpack"
require "google/protobuf"
require "./proto/order_pb.rb"
require "./thrift/order.rb"
require "./sparsam/gen-ruby/order_constants.rb"
class RandomOrder
def attributes
{
"a" => rand(10_000),
"b" => rand(10_000),
"... | true |
9dcc62969ced5dba614247b2cc85b822bb15e921 | Ruby | rackspaceautomationco/playtypus | /lib/playtypus/call_container.rb | UTF-8 | 419 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'json'
module Playtypus
class CallContainer
attr_accessor :calls
def self.from_log(log_content)
calls = []
json = JSON.parse(log_content.force_encoding("utf-8"))
json.each do |log_entry|
calls << Playtypus::Call.from_hash(log_entry)
end
return self.new(calls.so... | true |
0d69bf7b79add87ba0b04bf3e1728d4d22989bc8 | Ruby | RatheN/reverse-each-word-online-web-prework | /reverse_each_word.rb | UTF-8 | 152 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
string = string.split
new_string = string.collect do |r|
new_string = r.reverse
end
new_string.join(" ")
end
| true |
367cb0453114d34907e3ba30124bb30aee4da64b | Ruby | javijuol/nickel | /lib/holidays_wrapper.rb | UTF-8 | 422 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'holidays'
require 'holidays/us'
module Holidays
# sm - reads every holiday in region, including informal, and returns a date or nil
# the date range is for the 12 month period following now
def self.find_name(region, name)
Holidays.between(Date.today,Date.today>>12, region, :informal).each do |htest... | true |
50e30feea7d67e0d7c03ecc312f6bca554485786 | Ruby | thomaspouncy/algorithm_scripts | /tree.rb | UTF-8 | 1,368 | 3.34375 | 3 | [] | no_license | #! /usr/bin/env ruby
class Node
attr_accessor :parent_node, :children, :value
def initialize(node_value)
self.value = node_value
self.parent_node = nil
self.children = [$nil_node]
end
def childless?
self.children[0] == $nil_node
end
def add_child_node(node)
if childless?
self.c... | true |
4bddbd6157ff9118590fe5fb332df63d15209493 | Ruby | hemanth/octopress-socialink | /socialink.rb | UTF-8 | 937 | 2.578125 | 3 | [
"MIT"
] | permissive | # Title: Socialink plugin for ocotpress.
# Author: Hemanth.HM [h3manth.com]
module Jekyll
class SociaLink < Liquid::Tag
def initialize(tag_name, markup, tokens)
if /(?<social>\S+\/?\d?)(?:\s+(?<handle>[\w,]+))?/ =~ markup
@social = social
@handle = handle
end
end
def render(co... | true |
c679816f9e669a927ad97a9d6882d2f47d4e183c | Ruby | monde-sistemas/brcobranca | /lib/brcobranca/boleto/banrisul.rb | UTF-8 | 2,815 | 2.90625 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
module Brcobranca
module Boleto
class Banrisul < Base # Banco BANRISUL
validates_length_of :agencia, maximum: 4
validates_length_of :numero, maximum: 8
validates_length_of :convenio, maximum: 13
validates_length_of :carteira, is: 1
# Nova instancia do Banri... | true |
1ceac8d4054b539566281f470f2a09d9013e0d86 | Ruby | diannegabriel/two-o-player | /main.rb | UTF-8 | 323 | 3.0625 | 3 | [] | no_license | # Define a main.rb file that will require all the other files
require './game'
require './player'
require './question'
# player_one = Player.new('Chubby')
# player_two = Player.new('Tobi')
# player_one = Player.new(gets.chomp)
# player_two = Player.new(gets.chomp)
# new_game(player_one, player_two)
new_game = Game.... | true |
922eb39fbfcbbcea2d2286a3465f661634d4dcba | Ruby | vonasken/ironhack | /week3/Day13/javascript/app.rb | UTF-8 | 1,163 | 3.390625 | 3 | [] | no_license | require_relative("lib/country_counter.rb")
countries = [
"Puerto Rico", "Puerto Rico", "USA", "USA", "USA", "USA", "USA",
"Nigeria", "Nicaragua", "Cuba", "Cuba", "Cuba", "Cuba", "France",
"Zimbabwe", "Haiti", "Mongolia", "Argentina"
]
country_thing = CountryCounter.new
p count_countries("USA", countries) == 5
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.