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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17563ca8f603e00798a9dfe762e1955266ac41fb | Ruby | aleksandraszwaczka/code_sensei_course | /zjazd_1/10_power.rb | UTF-8 | 62 | 3.171875 | 3 | [] | no_license | def power(number, exp = 2)
number ** exp
end
puts power(3)
| true |
3ebe36e027309826a047d70c73841ce142cb3fd0 | Ruby | morganric/halloween | /halloween.rb | UTF-8 | 1,204 | 3.375 | 3 | [] | no_license | # Project demonstrates
# - local and instance variables - DONE
# - arrays, hashes, and custom object type(s) - DONE apart from Custom???
# - logical conditions - DONE
# - branching via both if/elsif/else and case/when
# - classes and object instantiation
# - attr_accessor - DONE
# - instance methods - DONE
# - module m... | true |
9f1218d2ca16b09e00f70bdc8efaad0cb09d5458 | Ruby | russolsen/md_inc | /lib/md_inc/md_inc_commands.rb | UTF-8 | 3,532 | 2.65625 | 3 | [
"MIT"
] | permissive | module MdInc
module Commands
def full_path(path)
if options[:base_dir]
File.join(options[:base_dir], path)
else
path
end
end
def content
@content
end
def process_file(file_name)
process(File.read(file_name))
end
d... | true |
4a6dbee6f1c2cff0fac7314ba34535c5213d70bd | Ruby | jtannas/rspeccery-101 | /spec/three_spec.rb | UTF-8 | 975 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
require 'spec_helper'
require 'three'
RSpec.describe Three do
describe '.russian_roulette' do
before do
allow(described_class).to receive(:kill_the_kitten)
end
(1..5).each do |number|
context "when rand returns #{number}" do
before do
allow(de... | true |
f25511f93ecc6a670bf55ad9026f95e30628f5fa | Ruby | nataliakikuchi/Ruby_first_steps | /Arrays/exercises.rb | UTF-8 | 18,635 | 4.75 | 5 | [] | no_license | # 1. Write a Ruby program to check whether a value exists in an array.
colors = ['red', 'green', 'blue']
colors.include? 'red' #=> true
colors.include? 'yellow' #=> false
# 2. Write a Ruby program to check whether 7 appears as either the first or last element in a given array. The array length must be 1 or more.
def... | true |
0702cfafadfc3ad4e9fb7146f7f71db4555cf405 | Ruby | hbu50/sse-server | /lib/sse/server/redis_channel.rb | UTF-8 | 2,787 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'redis'
require 'json'
module Sse
module Server
class << self
def ignore_exception
begin
yield
rescue => e
Sse::Server.configuration.logger.error "Ignored Exception: #{e.message}"
end
end
def pack_as_sse(id, event, data)
output=""
... | true |
fffaa1c71edd6c620bd3ec5c06dfda9a3c9823a9 | Ruby | wenbo/rubyg | /sample/CHAPTER04/051/compare-obj.rb | EUC-JP | 734 | 3.609375 | 4 | [] | no_license | 1 <=> 2 # => -1
1 <=> 1 # => 0
2 <=> 1 # => 1
3.between?(1,3) # => true
# ͤȤ
2 < 10 # => true
# ʸȤ
"2" < "10" # => false
"abc" < "def" # => true
"def".between?("abc","ghi") # => true
# 饹⥸塼... | true |
acfcca5ec7460581b44135e3c85a7bd8876df41c | Ruby | mariela-hdz/cs61aPrepCourse | /chpt2/assignment2.rb | UTF-8 | 202 | 3.515625 | 4 | [] | no_license | #hours in a year
#if leap year
puts 24*366
#if not
puts 24*365
#minutes in a decade
puts 60*24*(365*10)
#age in seconds
puts (60*60)*(24*365)*18
#author's age
puts 1160000000/(60*60*24*365) | true |
5d15960b18d9db90921e196023367d8f3c5591ce | Ruby | JustinData/GA-WDI-Work | /w02/d05/Paris/cookies_sessions/server.rb | UTF-8 | 927 | 2.546875 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'sinatra/cookies'
require 'pry'
enable :sessions
set :sessions, true
get "/" do
erb :login_form
end
# COOKIES AND COOKIES_READER:
get "/cookies" do
response.set_cookie(:c_is_for, :value => "COOKIES")
# response.set_cookie(:c_is_for, :expires => Time.new(... | true |
f620f422822304c2459017e38a8ca2ad7d3d9943 | Ruby | THISS/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 549 | 3.015625 | 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 ...
print "Please enter a store name > "... | true |
23d0d9e8b4e2f6e72a899a8c79c009f47bb7f35f | Ruby | rparkerson/launch-school | /RB100/intro_to_ruby/9_exercises/14.rb | UTF-8 | 409 | 3.5625 | 4 | [] | no_license | a = ['white snow', 'winter wonderland', 'melting ice',
'slippery sidewalk', 'salted roads', 'white trees']
# one word arrays as a new array. can use .map .flatten .split
# split strings with a space(all of them) then flatten to single dimensional
# array
new_arr = []
a.each { |words| new_arr << words.split(" ") ... | true |
dfdc528c65a23f93b7bae7596b6a712d86d4a779 | Ruby | wley3337/oo-my-pets-dc-web-060418 | /lib/dog.rb | UTF-8 | 336 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
require_relative "./fish"
require_relative "./cat"
require_relative "./owner"
class Dog
attr_accessor :owner, :mood
attr_reader :name, :species
@@all = []
def self.all
@@all
end
def initialize(name)
@name = name
@species = "dog"
@mood = "nervous"
self.class.all << se... | true |
33c180c2d663695ad544234fd96752024364cf3f | Ruby | davidenglishmusic/matisse | /app.rb | UTF-8 | 679 | 3.21875 | 3 | [] | no_license | require_relative 'colour'
require_relative 'painter'
require_relative 'canvas'
source_image = ImageList.new('beach.jpg')
quantize_image = source_image.quantize(16, RGBColorspace)
colours_from_histogram = quantize_image.color_histogram
unsorted_colours = []
colours_from_histogram.each do |key, _count|
colour = Colou... | true |
ed7dadd8e4bafeb8a8f26d210f02f54b0a6cfd98 | Ruby | andyprickett/launch-school | /101-programming-foundations/lesson-4/exercises-methods-and-more-methods/exercise_10.rb | UTF-8 | 323 | 3.875 | 4 | [] | no_license | result = [1, 2, 3].map do |num|
if num > 1
puts num
else
num
end
end
p result
# the block will return either nil or num. if the condition evaluates to
# true, then it will puts the number to output, and return nil from the
# block to the method because puts returns nil.
# map should return [1, nil, ni... | true |
7d5d071049319b4c46633d3f98f9ccbe94f0f9c8 | Ruby | jlx012/ruby_august_2017 | /tyler_thomson/fundamentals/arrays.rb | UTF-8 | 276 | 3.234375 | 3 | [] | no_license | a = ["Matz", "Diesel", "Maximus", "Diocletian"]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9]
puts a.at(0)
puts b.delete(1)
puts a.reverse
puts b.length
puts a.sort
puts b[2..3]
puts a.shuffle
puts a.join("-")
puts b.insert(1, "3.14159")
puts a.values_at(2,3).join(' and the co-emperor ')
| true |
af0e072d7acdc75d3a51043d82e21faf7667f84c | Ruby | zhydanovajulia/log_parser | /log_file.rb | UTF-8 | 654 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
require './sorters/no_sort'
require './formatters/no_format'
class LogFile
def initialize(filename:, parser:, statistic:)
@statistics_collector = statistic
parser.collect_ips_per_page(filename, statistics_collector)
end
def all_visits(sorter: NoSort, formatter: NoFormat)
... | true |
59990966dead2232ef3611bde8b6808273b82cf4 | Ruby | JAYKRISHNAN/toy-on-table-simulator | /spec/toy_on_table/models/command_spec.rb | UTF-8 | 3,714 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../../lib/toy_on_table/models/command'
describe ToyOnTable::Models::Command do
describe '.initialize' do
it 'sets the index, name and the arguments of the command given raw input line - case without arguments' do
command = ToyOnTable::Models::Command.new(... | true |
856e84fd902a99ce6a657d3573bcbfef9dde7bc1 | Ruby | qapulse/demo | /features/step_definitions/pressButtonsHelper.rb | UTF-8 | 3,379 | 2.59375 | 3 | [] | no_license | #I press new message button
Then /^I press new message button$/ do
performAction('click_on_screen',90, 10)
performAction('wait_for_text', 'New Message')
end
#I press new contact button
Then /^I press new contact button$/ do
#Tab on the icon
performAction('click_on_screen',90, 10)
#wait until the in... | true |
2eeba67343deeccbf11d53537d47c39e12d51e7a | Ruby | Hectorjmz/ruby-objects-has-many-through-lab-onl01-seng-pt-081720 | /lib/artist.rb | UTF-8 | 631 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name, :song
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def songs
song_arr = []
Song.all.each do |x|
if x.artist == self
song_arr << x
en... | true |
bfe1ba2780916214143e4f2ea5245fc88c7446e0 | Ruby | GreenPeepCoder/poker | /lib/hand.rb | UTF-8 | 922 | 3.765625 | 4 | [] | no_license | require_relative 'poker_hands'
class Hand
include PokerHands
attr_reader :cards
def initialize(cards)
if cards.length < 5
raise "must have five cards"
end
@cards = cards.sort
end
def self.winner(hands)
hands.sort.last
end
def trade_cards(old_c... | true |
4fd6b74e04e455361a0b254a42f6b1533dfdbeca | Ruby | annieaitken/shirtapp | /spec/models/product_spec.rb | UTF-8 | 687 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
describe Product do
context "when a product has comments" do
before do
@product = Product.create!(name: "Cut-Out Sweater")
@user = User.create!(email: "annie@annit.com", password: "password")
@product.comments.create!(rating: 1, user: @user, body: "Awful shirt!")
@product.comment... | true |
7030734aebae048700f4a9ca4ba82b2932f0bead | Ruby | EDIrb/EDI | /lib/edi/slack/websocket_incoming_message.rb | UTF-8 | 620 | 2.765625 | 3 | [
"MIT"
] | permissive | module Slack
class WebsocketIncomingMessage
attr_accessor :channel, :user, :text, :type
def initialize(params)
params = JSON.parse(params)
@channel = params["channel"]
@user = params["user"]
@text = params["text"]
@type = params["type"]
end
def to_s
"Slack::Websock... | true |
048c42ca51b827827e1bf04596db7212e2911f60 | Ruby | fetsroman/readability_text | /app/models/text.rb | UTF-8 | 941 | 2.703125 | 3 | [] | no_license | class Text < ApplicationRecord
has_and_belongs_to_many :users
before_save do
readability = 0
sentences_count = self.text.scan(/[^?!.][?!.]/).count
words_count = self.text.split.count
asl = words_count/sentences_count
lang = DetectLanguage.simple_detect(self.text)
case lang
when "en"
... | true |
9c855b5045fdc1ecd234966561c396a95d5169c2 | Ruby | thiyagarajan/pry | /lib/pry/default_commands/documentation.rb | UTF-8 | 7,539 | 2.703125 | 3 | [
"MIT"
] | permissive | class Pry
module DefaultCommands
Documentation = Pry::CommandSet.new do
command_class "ri", "View ri documentation. e.g `ri Array#each`" do
banner <<-BANNER
Usage: ri [spec]
e.g. ri Array#each
Relies on the ri executable being available. See also: show-doc.
B... | true |
853c05c76c6ac3b7b58e8e8e28ceeb19f6d6768e | Ruby | chriskite/robotex | /lib/robotex.rb | UTF-8 | 3,583 | 2.71875 | 3 | [
"MIT"
] | permissive | # Author (2012): Chris Kite
# Original Author (2008-2011): Kyle Maxwell
require 'rubygems'
require 'open-uri'
require 'uri'
require 'timeout'
class Robotex
VERSION = '1.0.0'
DEFAULT_TIMEOUT = 3
attr_reader :user_agent
class ParsedRobots
def initialize(uri, user_agent)
io = Robotex.get_ro... | true |
4856e344a7979f5e8be7413a25b4660d39b457f1 | Ruby | jakelovitz/square_array-nyc-web-career-042219 | /square_array.rb | UTF-8 | 99 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each do { |number| new_array.push(number**2) }
end | true |
055c081663ab09b3aed795a43a840136b718179b | Ruby | AAM77/hearth_and_home_inventory | /app/models/concerns/item_folder_category_helpers.rb | UTF-8 | 2,236 | 3.1875 | 3 | [
"MIT"
] | permissive | module ItemFolderCategoryHelpers
############################################
# CLASS METHODS
############################################
module ClassMethods
###############################################################
# Finds the item by the slug, item id, the user id. #
# This is ... | true |
451d83e3b4e567d21ec87e5c6c142fbdc78f7567 | Ruby | rsa2135/GetSwift | /requests.rb | UTF-8 | 326 | 2.515625 | 3 | [] | no_license | require 'net/http'
require 'json'
# Downloading the data through API requests
class Request
attr_reader :uri
def initialize(uri = 'codetest.kube.getswift.co')
@uri = uri
end
def drones
JSON.parse(Net::HTTP.get(uri, '/drones'))
end
def packages
JSON.parse(Net::HTTP.get(uri, '/packages'))
en... | true |
3218e89ab42884bdd0c43931ed418a7fa86544a9 | Ruby | RLOG89/cc_w1_d2 | /ruby_functions_practice.rb | UTF-8 | 1,417 | 3.890625 | 4 | [] | no_license | def return_10()
return 10
end
def add( num_1, num_2 )
return ( num_1 + num_2 )
end
def subtract( num_1, num_2 )
return ( num_1 - num_2 )
end
def multiply( num_1, num_2 )
return ( num_1 * num_2 )
end
def divide( num_1, num_2 )
return ( num_1 / num_2 )
end
def length_of_string( str )
return str.length
en... | true |
73ae99546dfeb1d1068aac137abfbac912ce2bb7 | Ruby | shirleytang0121/AAClasswork | /W3D3/recursion_exercise/solution.rb | UTF-8 | 1,433 | 3.84375 | 4 | [] | no_license | def b_search(arr,target)
return nil if arr.length<1
middle=arr.length/2
return middle if arr[middle]==target
lower_half=arr[0...middle]
higher_half=arr[middle+1..-1]
if target<arr[middle]
b_search(lower_half,target)
else
result=b_search(higher_half,target)
... | true |
9b25c971513792f7b906bc9ddf04852f9226b0ea | Ruby | jquigley1003/jeff_test | /app/lib/talkative_robot.rb | UTF-8 | 2,288 | 3.640625 | 4 | [] | no_license | require 'pry'
require 'csv'
require './person'
require './user'
require './author'
require './grocery_list'
# def write_to_csv(grocery_list, any_csv_file)
# CSV.open(any_csv_file, "w") do |csv|
# csv << ["Item Number", "Item Name"]
# grocery_list.each_index do |item|
# csv << ["#{item+1}", grocery_list[it... | true |
d6227cc0ce95b0788349ef79d67817cc25606eda | Ruby | ca33dang/mathcal | /subtracttest.rb | UTF-8 | 674 | 3.125 | 3 | [] | no_license | require "minitest/autorun"
require_relative "subtract.rb"
class Subtract_test < Minitest::Test
def test_one
assert_equal(20, subtract(30, 10))
end
def test_two
assert_equal(10, subtract(-5, -15))
end
def test_three
assert_equal(100, subtract(500, 400))
end
def test_four
assert_equal(-80, subtract(-280, -200))
end... | true |
a8b8279e613398355485cb9c1d9597d87a11c9f3 | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/1477.find-two-non-overlapping-sub-arrays-each-with-target-sum.rb | UTF-8 | 1,840 | 3.625 | 4 | [] | no_license | #
# @lc app=leetcode id=1477 lang=ruby
#
# [1477] Find Two Non-overlapping Sub-arrays Each With Target Sum
#
# https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/description/
#
# algorithms
# Medium (30.71%)
# Total Accepted: 10.7K
# Total Submissions: 34.8K
# Testcase Example: '... | true |
aa23d2cba6049ab80ccb68ac53e3a926c78a0ec2 | Ruby | IvanRud95/blackjack.ruby | /jol/game_play.rb | UTF-8 | 1,743 | 3.109375 | 3 | [] | no_license | require_relative 'hand'
class GamePlay
attr_accessor :bank
attr_reader :menu, :logic, :user, :dealer, :deck
def initialize(menu, logic, user, dealer)
@user = user
@dealer = dealer
@menu = menu
@hand = Hand.new
@bank = Bank.new(0)
@deck = Deck.new
user.points = 0
user.remove_card... | true |
daaf0d860870de8d358eaacbaaeaf61d061610cb | Ruby | meltzerj/PhotoMosaic | /blog/vendor/plugins/simple_search/lib/simple_search.rb | UTF-8 | 511 | 2.5625 | 3 | [
"MIT"
] | permissive | # SimpleSearch
module BeginningRails
module SimpleSearch
def simple_search(*fields)
class_inheritable_accessor :searchable_fields
raise "Please specify the fields to search on" if fields.empty?
self.searchable_fields = fields
end
def search(value)
conditions = []
... | true |
b3d912fd22b7f3597e3566db54de84d75936878e | Ruby | tpitale/staccato | /lib/staccato/measurable.rb | UTF-8 | 2,143 | 2.609375 | 3 | [
"MIT"
] | permissive | module Staccato
# Measurable adds field mapping and param collection
# for Measurement classes to be add to Hit
module Measurable
def self.included(model)
model.extend Forwardable
model.class_eval do
attr_accessor :options
def_delegators :@options, *model::FIELDS.keys
end... | true |
f7bf389191a78aeb27e844ffc1f64741a44ae396 | Ruby | ozzman84/independent_challenges | /assessments/craft_time/lib/person.rb | UTF-8 | 348 | 3.171875 | 3 | [] | no_license | class Person
attr_reader :name,
:interests,
:supplies
def initialize(hash)
@name = hash[:name]
@interests = hash[:interests]
@supplies = Hash.new(0)
end
def add_supply(supply, amount)
@supplies[supply] += amount
end
def can_build?(craft)
@supplies >= craft.... | true |
329ee57ca72f3eb64046cdbbb134116b1bc555a9 | Ruby | kage1029/atcoder | /atcoder40A.rb | UTF-8 | 269 | 3.203125 | 3 | [] | no_license | s = gets.chomp.to_s.split(//)
n = s.size
ary = Array.new(n + 1, 0)
i = 0
while i < n
if s[i] == "<"
ary[i+1] = ary[i] + 1
end
i += 1
end
i = n - 1
while i >= 0
if s[i] == ">"
ary[i] = [ary[i+1] + 1, ary[i]].max
end
i -= 1
end
puts ary.inject(:+) | true |
0dc14eb1264c2d3e37153aacf2cfba5075de96df | Ruby | alex6851/ruby-music-library-cli-online-web-sp-000 | /lib/Artist.rb | UTF-8 | 685 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
require_relative '../lib/concerns/Findable'
class Artist
extend Concerns::Findable
attr_accessor :name, :songs
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def self.destroy_all
@@all = []
end
def save
@@all << self
end
def self.create(... | true |
93b0929a2b7af9b13effe736feb2ef7c105efe50 | Ruby | sperBruno/ruby-course | /Bruno/tasks/filepractice.rb | UTF-8 | 1,337 | 4.0625 | 4 | [] | no_license | =begin
1. ask for a filename and extension .E.g test.txt
2. Then you will delete all the content of the file (in case that already
exist)
3. Then ask for the user for the amount of lines to be added
4. According the amount of lines, ask for each line.
5. Close the file
6. Finally print the values of the file (also be s... | true |
85042d271a65be6ad8181af7a5f93c834353f5b9 | Ruby | cloudfoundry/buildpacks-ci | /scripts/php-modules/update-hashes.rb | UTF-8 | 1,052 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | require 'digest/md5'
require 'open-uri'
require_relative('update.rb')
require_relative('../../../binary-builder/recipe/php_common_recipes.rb')
require_relative('../../../binary-builder/recipe/php_recipe.rb')
def cache_key(name, version, klass)
[name, version, klass]
end
def get_hash(name, version, klass, cache)
... | true |
84c767ea6839c5c06f71b4766520700f0cb50d2e | Ruby | dma315/phase-0 | /week-6/bingo_solution.rb | UTF-8 | 6,570 | 4.65625 | 5 | [
"MIT"
] | permissive | # A Nested Array to Model a Bingo Board SOLO CHALLENGE
# I spent [#] hours on this challenge.
# Release 0: Pseudocode
# Outline:
# => 1) Define an initialization that starts a game using an input of 'board' and rejects inputs where the array is an invalid size
# => 2) Define a method that 'call' randomly generates a... | true |
72be9311c82f3e4ef4ebfc3a236984206572fa11 | Ruby | mekhanique/serverspec-extended-types | /lib/serverspec_extended_types/http_get.rb | UTF-8 | 6,973 | 2.6875 | 3 | [
"MIT"
] | permissive | ##############################################################################
# serverspec-extended-types - http_get
#
# <https://github.com/jantman/serverspec-extended-types>
#
# Copyright (C) 2015 Jason Antman <jason@jasonantman.com>
#
# Licensed under the MIT License - see LICENSE.txt
#
############################... | true |
8b5ec02981b4c8f19e878a18c4d80468ba81209e | Ruby | davetron5000/optparse-plus | /test/unit/test_cli_logging.rb | UTF-8 | 5,068 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"GPL-3.0-only"
] | permissive | require 'base_test'
require 'optparse_plus'
require 'stringio'
class TestCLILogging < BaseTest
SLEEP_TIME = 0.1
test_that "another class using CLILogging gets the same logger instance" do
Given {
@first = MyClassThatLogsToStdout.new
@second = MyOtherClassThatLogsToStdout.new
}
Then {
... | true |
ba3f30c4ea24d4b30d7ec017f12b42d582b4821a | Ruby | bobdorff/phase-0 | /week-4/variables-methods.rb | UTF-8 | 1,753 | 4.1875 | 4 | [
"MIT"
] | permissive | puts "What is your first name?"
first_name = gets.chomp
puts "What is your middle name?"
middle_name = gets.chomp
puts "What is your last name?"
last_name = gets.chomp
puts "Nice to formally meet you, " + first_name + " " + middle_name + " " + last_name + "!"
puts "Say, " + first_name + ", what's your favorite numbe... | true |
21993605b237f085f587f1d9bf8f881f06e01b89 | Ruby | donaldpiret/asset_hash | /lib/asset_hash.rb | UTF-8 | 2,676 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'digest/md5'
require 'time'
require 'mime/types'
require 'asset_hash/railtie' if defined?(Rails::Railtie)
module AssetHash
def self.process!
AssetHash::Base.process!
end
def self.fingerprint(path)
AssetHash::Base.fingerprint(path)
end
class Base
DEFAULT_ASSET_PATHS = ['favicon.ico', 'im... | true |
1af45ea0b715032657b2b46aabf8d15ca2e87ba3 | Ruby | NielsTalens/3llo | /lib/3llo/presenter/board/list.rb | UTF-8 | 525 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Tr3llo
module Presenter
module Board
class ListPresenter
def initialize(interface)
@interface = interface
end
def print!(boards)
interface.print_frame do
boards.each { |board| present_board(board) }
end
... | true |
1fb1942f32c5425c2f861d889bc81504339e1e31 | Ruby | jasonthompson/binary_exercise | /spec/hex_to_decimal_converter_spec.rb | UTF-8 | 504 | 2.578125 | 3 | [
"MIT"
] | permissive | require_relative '../lib/base_converter/hex_to_decimal_converter'
require 'minitest/spec'
require 'minitest/autorun'
module BaseConverter
describe HexToDecimalConverter do
subject{HexToDecimalConverter.new("4E")}
describe "#value" do
it "returns the value of given binary" do
subject.value.must... | true |
0a3eedfb04fee7617946aa1f333565dedbadbe6b | Ruby | tauebel/connect_four | /lib/twitter_slot.rb | UTF-8 | 387 | 3.4375 | 3 | [] | no_license | class TwitterSlot
attr_reader :color, :value
def initialize
@color = nil
@empty = true
@value = 0
end
def empty?
@empty
end
def fill(color)
return "already filled" if empty? == false
@empty = false
@color = color
color == "X" ? @value = 1 : @value = 5
end
def to_s
... | true |
ff0de8602817d061b4182b2be09125147b749912 | Ruby | Peretus/cookbook | /test.rb | UTF-8 | 852 | 3.421875 | 3 | [] | no_license | load "cookbook.rb"
mex_cuisine = Cookbook.new("Mexican Cooking")
burrito = Recipe.new("Bean and Cheese Burrito", ["tortilla", "bean", "cheese"], ["heat beans", "heat tortilla", "place beans in tortilla", "sprinkle cheese on top", "roll up"])
chips_n_salsa = Recipe.new("Chips and Salsa", ["tortilla chips", "salsa"], ... | true |
9dc5d5f6d261adaef771d229ffec9382640ca58d | Ruby | nathanshort/adventofcode2020 | /07/run.rb | UTF-8 | 1,029 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby
def part1( all_rules, target, seen )
count = 0
all_rules.each do |color,children|
if children.any?{|child| ! seen.key?(color) && child[:color] == target }
seen[color] = true
count = count + 1 + part1( all_rules, color, seen )
end
end
count
end
def part2( al... | true |
b01bdc6e30a49079efa19d26d8678d0c52f39985 | Ruby | collinsmith1990/recursive_parking | /recursive_parking.rb | UTF-8 | 1,471 | 4.15625 | 4 | [] | no_license | # precondition: n >= 1
# postcondition: Return the number of ways to park 3 vehicles,
# designated 1, 2 and 3 in n parking spaces, without leaving
# any spaces empty. 1 takes one parking space, 2 takes two spaces,
# 3 takes three spaces. Each vehicle type cannot be distinguished
# from others of the same ... | true |
d56fe9f143fb7918767e81fda52270d974c451e2 | Ruby | hanfak/battle | /app.rb | UTF-8 | 917 | 2.65625 | 3 | [] | no_license | require 'sinatra/base'
require './lib/player'
require './lib/game'
class Battle < Sinatra::Base
enable :sessions
get '/' do
erb(:index)
end
post '/names' do
@player1 = Player.new(params[:player1])
@player2 = Player.new(params[:player2])
Game.save(Game.new(@player1, @player2))
redirect('/pl... | true |
966de7f2bb91e9b88d33c43edf96743e002cc177 | Ruby | ruggz13/debugging-with-pry-dc-web-062419 | /lib/pry_debugging.rb | UTF-8 | 48 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
sumNum = num + 2
sumNum
end
| true |
f1674ea45ed05df92caeb649f2186093a93a3348 | Ruby | amulyamari/kwk-l1-ruby-strings-kwk-students-l1-min-072318 | /invitation.rb | UTF-8 | 298 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | puts "What is your name?"
name= gets.chomp
puts "What type of party is this?"
party= gets.chomp
puts "When is it?"
date=gets.chomp
puts "Who is the host?"
host=gets.chomp
puts "Dear #{name}, You are cordially invited to #{party} on #{date}. Please RSVP no later than October 30. Sincerely, #{host}" | true |
1e92c97a1b22efb739c33fd3815f4d7772677fae | Ruby | hmishinev/dcell | /lib/dcell/mailbox_manager.rb | UTF-8 | 558 | 2.71875 | 3 | [
"MIT"
] | permissive | module DCell
# Manage mailbox addresses of local actors
class MailboxManager
@mailboxes = ResourceManager.new
class << self
# Enter a mailbox into the registry
def register(mailbox)
address = mailbox.address
@mailboxes.register(address) { mailbox }
end
# Find a mail... | true |
7b93622fda505c36006fb2b6d5d4dc8ddb25a98e | Ruby | superchen14/leetcode | /ruby/031.rb | UTF-8 | 676 | 3.25 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Void} Do not return anything, modify nums in-place instead.
def next_permutation(nums)
last_asc_index = -1
0.upto(nums.length - 2) do |i|
last_asc_index = i if nums[i] < nums[i + 1]
end
if last_asc_index == -1
nums.reverse!
else
sub_array = nums[last_asc_index... | true |
95b27125a2082f21153cb5d86e05a50eb4346f5c | Ruby | Perevedko/tarot-bot | /lib/message_sender.rb | UTF-8 | 1,380 | 2.625 | 3 | [] | no_license | require './lib/reply_markup_formatter'
require './lib/app_configurator'
require './models/tarot_cache'
class MessageSender
attr_reader :bot
attr_reader :text
attr_reader :chat
attr_reader :answers
attr_reader :logger
attr_reader :tarot
def initialize(options)
@bot = options[:bot]
@text = options... | true |
964e8d99163157bba4ea4f551dccd02dc3e9cdc8 | Ruby | PSalant726/AppAcademy | /Course Work/w2d3/poker/lib/deck.rb | UTF-8 | 519 | 3.40625 | 3 | [] | no_license | require 'card'
class Deck
attr_reader :cards
def initialize
@cards = []
end
def self.create_deck(suits = Card::SUITS, values = Card::VALUES)
deck = Deck.new
suits.each do |suit|
values.each do |value|
deck.cards << Card.new(value, suit)
end
end
deck
end
#
# def ... | true |
f798a35ed49845ad83f4523c42444747da916c72 | Ruby | heyjulieh/ruby-methods | /ruby_methods.rb | UTF-8 | 2,993 | 4.40625 | 4 | [] | no_license | # LOOPING
# 1.Write a method called p_times that takes a statement and a num
# puts the statement some num of times to the console.
# 1-define method name and its (parameters)
def p_times (statement,num)
puts statement * num # 3-insert logic which is asking to put statement num of times (2 ways to do it based on vag... | true |
bdbe0c54dba6a22be33adf1581a763d537b09f2d | Ruby | davidgarber/concerts_epicodus_week4_v2 | /lib/band.rb | UTF-8 | 433 | 2.71875 | 3 | [] | no_license | class Band < ActiveRecord::Base
has_and_belongs_to_many(:venues)
validates(:name, :presence => true)
before_save(:capitalize_name)
define_singleton_method(:find_band) do |name|
found_band = nil
Band.all().each() do |band|
if band.name().==(name)
found_band = band
end
end
f... | true |
9a2c179ed7163c980117aee6d66d3a1ee59b6b01 | Ruby | barebrock/XppEmu | /Cpu.rb | UTF-8 | 8,448 | 2.8125 | 3 | [] | no_license | require 'pp'
require 'Opcodes'
class Fixnum
def to_sint8
if self & 0x80 != 0
self - 0x100
else
self
end
end
def to_sint16
if self & 0x8000 != 0
self - 0x10000
else
self
end
end
def to_sint4
if self & 0x8 != 0
self - 0x10
else
self
end
end
end
... | true |
210f1d615ced486f4ad330f05903519020f4bea0 | Ruby | ayanit1/lrthw | /chap01/ex30.rb | UTF-8 | 1,061 | 4.1875 | 4 | [] | no_license | # assigns the variables with the values...
people = 30
cars = 40
trucks = 15
# if cars is more than people, print statement
if cars > people
puts "We should take the cars."
# or if cars is less than people, print statement
elsif cars < people
puts "We should not take the cars."
# if it's equal then print this ... | true |
4e19c67dbec2ec57b5de1aba0c0688f634f75cd9 | Ruby | alvarezmelissa87/rails-tweetlibs | /db/seeds.rb | UTF-8 | 818 | 2.6875 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
100d2011225a315d27110c461b485114f9a4d46a | Ruby | btowle/dieroll-sinatra | /dieroll_restful.rb | UTF-8 | 1,587 | 2.515625 | 3 | [] | no_license | require 'dieroll'
require 'json'
include Dieroll
get '/dieroll/:dicenotation.json' do |notation|
content_type :json
notation.sub!("D","/")
{ :result => Roller.new(notation).roll! }.to_json
end
get '/dieroll/:dicenotation/report.json' do |notation|
content_type :json
notation.sub!("D","/")
roller = Roller.... | true |
b14ffe1dbd297bd5abeae11bceee2b666fbc354c | Ruby | PraneethChandraThota/socketlabs-ruby | /lib/socketlabs/injectionapi/message/merge_data.rb | UTF-8 | 1,175 | 3.109375 | 3 | [
"MIT"
] | permissive | require_relative '../core/string_extension.rb'
module SocketLabs
module InjectionApi
module Message
# Represents MergeData as a key and value pair.
# Example:
# data1 = MergeData.new("key1", "value1")
class MergeData
# the MergeData key
attr_accessor :key
# th... | true |
76a7813299dacdc647d7889b4b779360204c72e5 | Ruby | akchalasani1/myruby | /examples/Last/14ex4_hash_literal_notation.rb | UTF-8 | 484 | 3.75 | 4 | [] | no_license | # Hash creation with literal notation => :
# In the third script, we create a hash with the "hash literal notation".
# The "values" are bound by the "curly brackets".
# And the "key-value" pairs are associated with the "=>" characters.
domains = {"de" => "Germany",
"us" => "United States",
"ca" => "Canada",
... | true |
b88eb58a14f68426ae921f7914a0d242031351bd | Ruby | arturocedilloh/LS_100 | /rubybasics/something2.rb | UTF-8 | 242 | 3.78125 | 4 | [] | no_license |
loop do
puts '>> Do you want me to print something? (y/n)'
response = gets.chomp.upcase
if response== "Y"
puts 'something'
break
elsif response.upcase == "N"
break
end
puts '>> invalid input! Please enter y or n'
end
| true |
627b10b51c3348fafa792f2e75172dc2b27c9144 | Ruby | evanlivingston/evanlivingston.github.com | /_site/Rakefile | UTF-8 | 3,062 | 2.609375 | 3 | [] | no_license | # Standard library
require 'rake'
require 'yaml'
require 'fileutils'
# Load the configuration file
config = YAML.load_file("_config.yml")
# Set "rake watch" as default task
task :default => :watch
# rake post["Post title"]
desc "Create a post in _posts"
task :post, :title do |t, args|
title = args[:title]
te... | true |
38f4b93e8426c64e0ecbabceca732c45d0e4f14e | Ruby | easyeah/githubtutorial | /Loop/1.rb | UTF-8 | 117 | 3.15625 | 3 | [] | no_license | while false do
puts('Hello World')
end
puts('After While')
i=0
while i<3 do
puts('Hello world')
i = i + 1
end
| true |
7393e68762d775f10a71b43cf79b3c5364bc5acc | Ruby | GKhalsa/the_scout | /app/services/walmart_service.rb | UTF-8 | 548 | 2.609375 | 3 | [] | no_license | class WalmartService
def initialize
@_conn = Faraday.new(url: "http://api.walmartlabs.com")
@_conn.params["apiKey"] = ENV['WALMART_API']
end
def get_categories
parse(connection.get("/v1/taxonomy"))[:categories]
end
def get_items(category)
parse(connection.get("/v1/paginated/items", category... | true |
7cddb7d085c00075105b68fc1f8b4e2157d7c9d6 | Ruby | margaretleedees2/school-model | /school.rb | UTF-8 | 483 | 3.796875 | 4 | [] | no_license | class School
attr_accessor :name, :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(student,grade)
self.roster[grade] ||= [] #substituted self for @roster; add if it doesn't already exist
self.roster[grade] << student
end
def grade(grade)
self.roster[grade]
... | true |
4001d767345dcf082e66554182efe0baf1fc22d5 | Ruby | jtb1137/trending-stocks-gem | /lib/trending-stocks-gem/stock.rb | UTF-8 | 757 | 2.71875 | 3 | [] | no_license | class TrendingStocksGem::Stock
attr_accessor :name, :last, :high, :low, :change, :change_percent, :volume, :market_cap, :roi, :beta, :hourly, :daily, :monthly
@@all = []
def initialize(name=nil, last=nil, high=nil, low=nil, change=nil, change_percent=nil)
@name = name
@last = last
@high = high
@low =... | true |
9d7cc486ab1e937c1218884cde0e89075f0798a8 | Ruby | Zvrbsky/ror_project | /app/providers/events_provider.rb | UTF-8 | 677 | 2.75 | 3 | [] | no_license | class EventsProvider
attr_reader :results
def initialize(search, cat)
@results = Event.all
@results = filter_events(cat)
@results = search_events(search)
# binding.pry
end
def search_events(search)
@results = if search.nil?
@results
elsif search == ''
... | true |
c70c75298c33b06d28f8123d7d148b70340a7129 | Ruby | mortonfox/wordsearch | /wordsearch.rb | UTF-8 | 2,887 | 3.546875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'set'
class WordPuz
def initialize
@puzzle = []
@words = []
end
def process_puz_row line
@puzzle << line.gsub(/\s/, '').downcase.chars
end
def process_words line
@words += line
.gsub(/\s/, '')
.downcase.split(',')
.reject { |word| word.size < 1... | true |
8dd667addad308b22ce5bb84af4370bf88d47b58 | Ruby | NateJBeck/donations | /app/models/availability_writer.rb | UTF-8 | 383 | 2.828125 | 3 | [] | no_license | require "csv"
class AvailabilityWriter
def initialize(availabilities)
@availabilities = availabilities
end
def to_csv
CSV.generate do |csv|
csv << ["Date", "Address"]
@availabilities.each do |availability|
availability.confirmed_pickups.each do |pickup|
csv << [availability... | true |
ff92ed54f6b6d7c92dbb1f4cf0194d1ce1a3133c | Ruby | akronim/rails_sample_app | /app/controllers/users_controller.rb | UTF-8 | 823 | 2.59375 | 3 | [] | no_license | class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
def create
puts ">>>>>>>>>>>>>>>>>>>>>>>"
puts params[:user] # hash of user attributes
@user = User.new(user_params)
if @user.save
log_in @user
flash[:s... | true |
22804695d6df9876ae993c197b1debe5e047f4ac | Ruby | cyclingzealot/letter_gen | /spec/text_field_spec.rb | UTF-8 | 1,211 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'letter_gen/form_field'
require_relative 'spec_helper'
require 'Qt'
describe 'TextField' do
before(:each) do
app = Qt::Application.new ARGV
@test_field_name = 'Test Field'
@test_field = TextField.new(@test_field_name)
@test_field.text_field.text = 'test text'
end
... | true |
fc325c6363e2ca99beffc45b6a1fdb102efca1c3 | Ruby | takaaki-kit/design_pattern | /ruby/facade.rb | UTF-8 | 284 | 3.171875 | 3 | [] | no_license | class Hello
def say
print 'hello'
end
end
class World
def say
print 'world'
end
end
class Exclamation
def say
print '!'
end
end
class HelloWorldfacade
def say
Hello.new.say
World.new.say
Exclamation.new.say
end
end
HelloWorldfacade.new.say
| true |
f911a06309c3a3e37c9f88bf002fe60e81383ded | Ruby | romulo059/Uri_Levels_1_to_7 | /exercise_1113.rb | UTF-8 | 815 | 4.625 | 5 | [] | no_license | # Ascending and Descending
# Read an undetermined number of pairs of integer values.
# Write a message for each pair indicating if this two numbers
# are in ascending or descending order.
# IMPUT
# The input file contains several test cases.
# Each test case contains two integer numbers X and Y.
# The input will ... | true |
7929c32b5623b597be5fc1c58f55bd48e0670fc6 | Ruby | kopylovvlad/hamdown | /spec/hamdown/md_handler_spec.rb | UTF-8 | 14,039 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe Hamdown::MdHandler do
describe 'h1' do
it 'can replace it' do
text = <<~EOL
# Hello it is title
# It is second title
EOL
right_result = <<~EOL
<h1>Hello it is title</h1>
<h1>It is second title</h1>
EOL
result... | true |
8abc051bf15b386acf2372ebbd85e36dcefd42b2 | Ruby | ashtn/api-muncher | /lib/edamam_api_wrapper.rb | UTF-8 | 1,618 | 2.921875 | 3 | [] | no_license | require 'httparty'
class EdamamApiWrapper
BASE_URL = "https://api.edamam.com/search?"
APP_ID = ENV["APP_ID"]
APP_KEY = ENV["APP_KEY"]
def self.findRecipes(query)
url = BASE_URL + "q=#{query.gsub(" ", "+")}" + "&to=100" + "&app_id=#{APP_ID}" + "&app_key=#{APP_KEY}"
response = HTTParty.get(url)
... | true |
a690ef7e6ac168a3eb67993292413d3845b0910d | Ruby | jhass/configurate | /spec/configurate/lookup_chain_spec.rb | UTF-8 | 3,480 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require "spec_helper"
class InvalidConfigurationProvider; end
class ValidConfigurationProvider
def lookup(_setting, *_args); end
end
describe Configurate::LookupChain do
subject { described_class.new }
describe "#add_provider" do
it "adds a valid provider" do
expect {
... | true |
0fbfe5bdb2d0d22a922d8fc228690c28d0710f41 | Ruby | acltc/random-puzzle-app | /app/models/puzzle.rb | UTF-8 | 561 | 2.6875 | 3 | [] | no_license | class Puzzle
attr_accessor :id, :name, :instructions, :solution
def initialize(attributes_hash)
@id = attributes_hash["id"]
@name = attributes_hash["name"]
@instructions = attributes_hash["instructions"]
@solution = attributes_hash["solution"]
end
def self.random_daily
todays_puzzle = Puzzl... | true |
df18a8fa000a2c2d73b0d791b4e9e44a5c6ecb59 | Ruby | snyderbc/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 1,788 | 4.34375 | 4 | [] | no_license | def adder
number1 = 5
number2 = 2
puts "Forget how to add?"
yield(number1, number2)
end
adder {|number1, number2| puts "Here's a little help: #{number1} + #{number2}"}
############
dogs = ["dalmation", "lab", "pit bull"]
musicians = {
"Led Zeppelin" => "Robert Plant",
"Pink Floyd" =>"David Gilmour",
"... | true |
ea99ba630b45eef7b9f3c21519b849c1ed4a766b | Ruby | Kndekaru/phase-0-tracks | /ruby/list/todo_list.rb | UTF-8 | 274 | 3.15625 | 3 | [] | no_license | class TodoList
attr_accessor :get_items
def initialize(get_items)
@get_items = get_items
end
def add_item(item)
@get_items.push(item)
end
def delete_item(item)
@get_items.delete(item)
end
def get_item(i)
@get_items[i]
end
end | true |
8e8b918e25d861eab52b1de1396b4d444d0036f3 | Ruby | shibayu36/algorithms | /ruby/lib/hackerrank/coin-change.rb | UTF-8 | 1,227 | 3.640625 | 4 | [] | no_license | require 'json'
require 'stringio'
#
# Complete the 'getWays' function below.
#
# The function is expected to return a LONG_INTEGER.
# The function accepts following parameters:
# 1. INTEGER n
# 2. LONG_INTEGER_ARRAY c
#
def getWays(n, c)
getWaysHelper(n, c, 0, {})
end
def getWaysHelper(n, c, index, memo)
retur... | true |
1ab4dbaaf59b904356466597efa9d6bb8b130087 | Ruby | kendallrowe/two-o-player-math-game | /player.rb | UTF-8 | 285 | 3.140625 | 3 | [] | no_license | class Player
attr_reader :id
attr_accessor :current_lives
@@number_of_players = 0
def initialize
@current_lives = MAX_LIVES
@@number_of_players += 1
@id = @@number_of_players
end
def lose_life
self.current_lives -= 1
end
private
MAX_LIVES = 3
end | true |
32010bfd4f5ae4cd18a3a111b4dd8ae2f3ec44eb | Ruby | Draganovic/mythical-creatures | /medusa.rb | UTF-8 | 390 | 3.21875 | 3 | [] | no_license | class Medusa
attr_reader :name, :statues
def initialize(name)
@name = name
@statues = []
end
def respond_to?(action)
true
end
def stare(victim)
@statues << victim
victim.stone = true
end
end
class Person
attr_reader :name
attr_accessor :stone
def initialize(name)
@nam... | true |
7745e4e5a281fc04597892d29e059bf7414ecf57 | Ruby | nnutter/rosalind | /dna/dna.rb | UTF-8 | 206 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
index = {'A' => 0, 'C' => 1, 'G' => 2, 'T' => 3}
count = [0, 0, 0, 0]
ARGF.each do |line|
line.chomp!
line.each_char do|c|
count[index[c]] += 1
end
end
puts count.join(' ')
| true |
2e95940b9623e97ec65046f98c5b6bd338ee3c46 | Ruby | thehicksivist/ruby-challenges | /notes/classrevision.rb | UTF-8 | 330 | 3.84375 | 4 | [] | no_license | class Hello
@@count = 0
attr_accessor :name
def self.count
@@count
end
def initialize(name)
@name = name
@@count += 1
end
def speak
puts @name
end
end
# Main entry point
Hello.new("John")
Hello.new("Mary")
Hello.new("Bill")
puts Hel... | true |
9b3208a690f30d8d6a6a32e662d7434d782548b4 | Ruby | jamesquietly/RubyProgramming | /EventManager/lib/event_manager.rb | UTF-8 | 1,686 | 3.3125 | 3 | [] | no_license | require 'csv'
require 'sunlight/congress'
require 'erb'
Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5"
def clean_zipcode(zipcode)
zipcode.to_s.rjust(5, "0")[0..4]
end
def legislators_by_zipcode(zipcode)
Sunlight::Congress::Legislator.by_zipcode(zipcode)
end
def save_thank_you_letters(id, fo... | true |
b6497c25c8af0e0f93ac8158fd05300199d777ac | Ruby | khipu/khipu-chaski-api-ruby-client | /lib/khipu-chaski-api-client/models/device.rb | UTF-8 | 1,468 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | module KhipuChaski
#
class Device < BaseObject
attr_accessor :token_id, :recipients, :extra_data
# attribute mapping from ruby-style variable name to JSON key
def self.attribute_map
{
# token para notificaciones asociado al dispositivo. Tiene la forma <platform>:<registr... | true |
ca87a3e7d797b98da782eb2e3791fa33ff2f0161 | Ruby | jbryanmiller/grpc-rest-example | /ruby/bin/rest_client.rb | UTF-8 | 743 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(File.dirname(this_dir), 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'releases_client'
require 'pp'
if ARGV.length != 1
puts "Need to specify HTTP server host on command line"
exit 1
... | true |
682c7f781ed4aaab0ed0538c8a39e5ffa4726ad5 | Ruby | yudedako/codility | /4_counting_elements/perm_check.rb | UTF-8 | 751 | 3.0625 | 3 | [] | no_license | require 'pry'
require 'byebug'
require 'pry-byebug'
require 'minitest/autorun'
# Test score 100%
# - Correctness 100%
# - Performance 100%
def solution(a)
before_num = 1
a.sort.each do |num|
return 0 if before_num != num
before_num = num + 1
end
return 1
end
class Tests < MiniTest::Unit::TestCase
d... | true |
145bf53061580b50e87182d142df158abdae03e3 | Ruby | octagonal/SPBS | /spbs/parse.rb | UTF-8 | 786 | 2.5625 | 3 | [] | no_license | string = ARGV[0]
puts string
arr = string.scan(/(%(\d+),(\d+)%)/).reverse
p arr
def form_query(iteration,match,string)
(match[iteration][1]..match[iteration][2]).each do |n|
parsed = ''
parsed = string.sub(match[iteration][0], n.rjust(2,"0"))
if iteration != 0
form_query(iteration-1,match,parsed)
... | true |
04bfeecbf1791610b5ff4207bf299dbef3fc6338 | Ruby | jkingsbery/ruby-euler | /006.rb | UTF-8 | 143 | 2.828125 | 3 | [] | no_license | max=100
squares = (1..max).collect{ |x| x*x }.inject(:+)
sum_of_n=max*(max+1)/2
difference = sum_of_n * sum_of_n - squares
puts difference
| true |
c9a19bdb8fa332d1a6b96c34a680a190730ab5b7 | Ruby | kairos0ne/story-capture-api | /app/controllers/api/v1/trips_controller.rb | UTF-8 | 5,755 | 2.578125 | 3 | [] | no_license | module Api
module V1
class TripsController < ApiController
before_action :require_login
before_action :set_trip, only: [:show, :update, :destroy]
swagger_controller :trips, "Trip Management"
swagger_api :index do
summary "Fetches all the trips for a given user"
notes "This lists... | true |
2e821b2dce00a77d3d51d55f7b0af6b3a97567b9 | Ruby | rleber/bun | /lib/bun/bots/sandbox/hyphen_task.rb | UTF-8 | 1,330 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# -*- encoding: us-ascii -*-
require 'lib/hyphenator'
WORDS_FILE = "/usr/share/dict/words"
LINE_SIZE = 50
METHODS = %w{moby knuth}
desc "hyphen", "Test loading hyphenation library"
option "method", :aliases=>'-m', :type=>'string', :desc=>"Use this method (#{METHODS.join(',')})"
def hyphen
wo... | true |
3b24b24dc3b7da7bd06d56cce44ee0501dad72da | Ruby | sabat/Counter | /lib/counter.rb | UTF-8 | 611 | 3.3125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'counter/version'
class Counter
def initialize(v = 0)
@value = v
end
def increment
@value = @value.succ
end
def decrement
@value = @value.pred
end
def inspect
@value.to_s
end
def ==(v)
@value == v
end
def >(v)
@value > v
end
def <(v)
@value < v
end
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.