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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a168086d6368fd0b76f02e3f6f1bf705ab9cea40 | Ruby | ivncastillo/desafio_ruby_ciclos | /gen.rb | UTF-8 | 190 | 3.65625 | 4 | [] | no_license | def gen(x)
abcedario='abcdefghijklmnopqrstuvwxyz'
if x<= 27 && x>0
return abcedario[0,x]
else
puts 'introduzca un numero entero postivo menor a 27'
end
end | true |
eb4019fba10eb51fb0215018e8af87a850238c9e | Ruby | jugyo/logy | /lib/logy/command.rb | UTF-8 | 519 | 2.546875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
module Chlgr
class Command
@@commands = {}
class << self
def add(name, &block)
@@commands[name.to_sym] = block
end
def get(name)
@@commands[name.to_sym]
end
def search(text)
return [] if text.nil? || text.empty?
@@command... | true |
1f4719a46e8dd14ec1b3f1b042991cf7838f337b | Ruby | ThilakshanArulnesan/ar-exercises | /exercises/exercise_1.rb | UTF-8 | 500 | 3.25 | 3 | [] | no_license | require_relative '../setup'
require_relative '../lib/store'
puts "Exercise 1"
puts "----------"
# Your code goes below here ...
s1 = Store.create(name: "Burnaby", annual_revenue: 300_000, mens_apparel: true, womens_apparel: true)
s2 = Store.create(
name: "Richmond",
annual_revenue: 1_260_000,
mens_apparel:fals... | true |
a6a314f9d87493eaeabf5d13d3064de2d1ca3ec8 | Ruby | uejonuba/reverse-each-word-cb-000 | /reverse_each_word.rb | UTF-8 | 128 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(word)
array = word.split()
result = array.collect {|part| part.reverse}
return result.join(" ")
end
| true |
7eb84e717dbcb2243cda4bf655c8876d8a62e4cf | Ruby | bonniepan02/fizz_buzz | /lib/looper.rb | UTF-8 | 661 | 2.921875 | 3 | [] | no_license | require 'rule_factory_mapper'
require 'fizz_buzz'
require 'rule_config_parser'
require 'rule_repository'
# Loop through to concatenate fizzbuzz run rule results
class Looper
DELIMETER = ' '.freeze
def initialize
mapper = RuleFactoryMapper.new
parser = RuleConfigParser.new(mapper)
config_path = File.ex... | true |
ad2131311c8b03b894db7a7516b86b994f2e5888 | Ruby | samgd/dlx | /lib/dlx/node.rb | UTF-8 | 1,397 | 3.265625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Dlx
class Node
attr_reader :row, :col, :header
attr_accessor :up, :right, :down, :left
def initialize(row, col, header, up = self, right = self, down = self, left = self)
@row, @col = row, col
@header = header
@up, @right, @down, @left = up, right, down, left
end
def lin... | true |
bfad66899b87a15d079071f0d484fcdd60a38669 | Ruby | austinandrade/mastermind | /test/game_test.rb | UTF-8 | 1,000 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/mastermind'
require './lib/printer'
# require './lib/player_guess_matcher'
require 'pry'
class GameTest < Minitest::Test
def test_post_win
skip
game = Game.new
sandwich = mastermind.post_win("p")
assert_equal true, sandwich
end
de... | true |
8c23ec3b432da35833564d1140796caa8f6f91b4 | Ruby | harryFBloch/ruby-music-library-cli-online-web-ft-092418 | /lib/artist.rb | UTF-8 | 518 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name, :songs
extend EasyModule::ClassMethods
extend Concerns::Findable
include EasyModule::InstanceMethods
@@all = []
def initialize(name)
super
end
def self.all
@@all
end
def genres
return_array = self.songs.map {|song| song.genre}.uniq
end
... | true |
1c10e8a04da0a6a6a1deb7202268655e3295a701 | Ruby | paulief/interview-practice | /mth_to_last.rb | UTF-8 | 1,264 | 4.03125 | 4 | [] | no_license | # https://www.hackerrank.com/contests/programming-interview-questions/challenges/m-th-to-last-element
class Node
attr_accessor :val, :forward, :backward
def initialize(val)
@val = val
end
end
class LinkedList
attr_accessor :head, :tail
def initialize(head)
@head = head
... | true |
431c28f632d0823232d5ae8f3f8c866a1cbb9cb5 | Ruby | invisibill/invisibill-ruby-client | /lib/invisibill-ruby-client/api_client.rb | UTF-8 | 1,610 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'typhoeus'
API_SCHEME = ENV['API_SCHEME'] || 'https'
API_HOST = ENV['API_HOST'] || 'api.invisi-bill.com'
API_USER_AGENT = ENV['API_USER_AGENT'] || 'invisibill-ruby-client api'
API_MAX_ATTEMPTS = (ENV['API_MAX_ATTEMPTS'] || 5).to_i
module Invisibill
class ApiClient
class << self
def base_url
... | true |
f7fb77c2cd55ccd8a958ff74dc111bb54dbb7abc | Ruby | northerner/adventofcode2017 | /day5.rb | UTF-8 | 529 | 3.328125 | 3 | [] | no_license | def step_count(instructions_string)
instructions = instructions_string.split.map(&:to_i)
location = 0
steps = 0
in_bounds = true
while in_bounds
steps = steps + 1
next_location = instructions[location] + location
in_bounds = (0..instructions.size-1).include?(next_location)
if in_bounds
... | true |
91da610d80d5cfc0613bb24d9b95afe1f91313a2 | Ruby | ChristieRenaud/Course-120 | /twenty_one_final.rb | UTF-8 | 5,490 | 3.796875 | 4 | [] | no_license | module Hand
def hit
deck.deal(self)
end
def stay
puts "#{name} stayed. #{name}'s hand is #{hand}"
end
def busted?
total > 21
end
def total
total = 0
hand.each do |card|
total += card.value
end
hand.select { |card| card.face.first == "Ace" }.count.times do
break ... | true |
9ca4370d9f34dd9e63ad425673b8ab16dbaf42cb | Ruby | macosgrove/toy-robot | /spec/table_spec.rb | UTF-8 | 1,435 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative "../lib/table"
require_relative "../lib/robot"
describe Table do
subject(:table) { Table.new(3, 6) }
describe "#valid_location" do
context "When the coordinates are inside the table boundaries" do
[[0, 0], [0, 5], [2, 0], [2, 5]].each do |coords|
i... | true |
8501f78864922ef58eaf089c24aa14e17f813fc8 | Ruby | ishige-shogo/Atcoder | /atcoder192_contest.rb | UTF-8 | 1,693 | 3.203125 | 3 | [] | no_license | #提出の基本となる部分
# 整数の入力
a = gets.to_i
# スペース区切りの整数の入力
b,c=gets.chomp.split(" ").map(&:to_i);
# 文字列の入力
s = gets.chomp
# 出力
print("#{a+b+c} #{s}\n")
# a1,a2,a3...anの入力
a = gets.chomp.split(" ").map(&:to_i)
# 列の入力
arr=h.times.map{gets.chomp.split("")}
puts a.reject{|i| i == X}.join(" ")
#入力したものを加工
X,Y,R=get... | true |
edbd938e4f9f6c17a4c867103cdf68c0effac20d | Ruby | SwtCharlie/Quick-Testing | /number randomizer.rb | UTF-8 | 180 | 3.25 | 3 | [] | no_license | require "pp"
numbers = [1, 2, 3, 4, 5].sort_by { rand }
results = []
half = (numbers.size/2.0).ceil
half.times do |i|
results << [numbers[i], numbers[i+half]]
end
pp results | true |
f6991efa96527dabddaebf8fbf2f1a3ef756818f | Ruby | tanaken0515/try-red-chainer | /examples/seq2seq/data/prepare_dictionaries.rb | UTF-8 | 676 | 2.703125 | 3 | [] | no_license | require 'csv'
require 'natto'
require_relative '../utility/eng'
jpn_words = ''
eng_words = ' '
nm = Natto::MeCab.new('-Owakati')
CSV.foreach('examples/seq2seq/data/jpn_eng_sentences.csv', col_sep: "\t", liberal_parsing: true) do |row|
jpn_sentence, eng_sentence = row
jpn_words << nm.parse(jpn_sentence) + ' '
e... | true |
2910b82150d4a8a082f8ec0643b2c1aaa9262bbe | Ruby | Putterhead/ruby-kickstart | /session2/challenge/6_array.rb | UTF-8 | 2,110 | 4.90625 | 5 | [
"MIT"
] | permissive | # Write a method named prime_chars? which takes array of strings
# and returns true if the sum of the characters is prime.
#
# Remember that a number is prime if the only integers that can divide it with no remainder are 1 and itself.
#
# Examples of length three
# prime_chars? ['abc'] # => true
# prime_... | true |
e3c740f9b6bad66e6d58cf920abb4cf784554e89 | Ruby | raigons/parser | /spec/unit/parser/parser_spec.rb | UTF-8 | 3,074 | 2.96875 | 3 | [] | no_license | require 'spec_helper'
describe "Parser" do
let :raw_message do
"09/12/2014, 21:37 - Ramon Henrique: Hello world"
end
let :raw_message_2 do
"09/12/2014, 22:08 - Ramon Henrique: hello again!"
end
let :raw_message_3 do
"09/12/2014, 22:08 - Matheus Gonçalves: Hi!"
end
subject { WhatsAppParser... | true |
159c1f40ce5bd41afc1ef67f5a5e54109ed98a4c | Ruby | peteyluu/coderbyte | /Easy/ab_check.rb | UTF-8 | 865 | 4.21875 | 4 | [] | no_license | =begin
Have the function ABCheck(str) take the str parameter being passed and
return the string true if the characters a and b are separated by exactly
3 places anywhere in the string at least once (ie. "lane borrowed" would
result in "true" because there is exactly three characters between a and b).
Otherwise retu... | true |
713d0791dacc417d9aec4307fa92f018a75ece98 | Ruby | Jcornick21/factorial | /lib/factorial.rb | UTF-8 | 348 | 3.890625 | 4 | [] | no_license | # Computes factorial of the input number and returns it
def factorial(number)
if number == nil
raise ArgumentError.new("number cannot be nil")
elsif number == 0 || number == 1
return 1
end
count = 0
fac = 1
while count < number
fac *= (number - count)
count += 1
end
return fac
# ra... | true |
301dcfc68182ad6ed96252e9ad2857cedfad3783 | Ruby | masakisanto/ecuacovid | /lib/ecuacovid/data.rb | UTF-8 | 4,530 | 3.109375 | 3 | [
"WTFPL"
] | permissive | require 'date'
module Ecuacovid
class Data
FECHA = ->(valor) { valor.created_at.strftime("%d/%m/%Y") }
UNO = ->(valor) { 1 }
class << self
def calculador(multiplicador, &formula)
lambda do |acc, data|
result = (acc * multiplicador)
return result if data.nil?
r... | true |
75559dabc16f6fff8ac6ec954f0030358f653e44 | Ruby | tylerbrazier/archive | /id3ntify-ruby/tag.rb | UTF-8 | 6,915 | 2.828125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'taglib'
$args = Arg_Handler.new ARGV
# Called by set and edit methods. This does not check if img_path is good
# TODO mime type?
def set_pic(tag, img_path)
return unless tag.class == TagLib::ID3v2::Tag
# first remove existing (is this necessary?)
tag.remove_frames('APIC')
... | true |
edfa5ff69b959c4b0e2b5251cfdb170073a95b42 | Ruby | notarandomusername/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 365 | 3.34375 | 3 | [] | no_license | def translate(input)
array = input.split('')
result = []
array.each do |x|
consonant = 0
len = x.length
while((x[consonant] != 'a') && (x[consonant] != 'e') && (x[consonant] != 'i') && (x[consonant] != 'o'))
consonant += 1
end
result.push(x[consonant..(len - 1)] + x[-len..-(len - consona... | true |
f6f5e7e224d36047f505d1299c49e3e6276ac38d | Ruby | jackson-r/backend_prework | /day_6/exercises/person.rb | UTF-8 | 436 | 4.71875 | 5 | [] | no_license | # Create a person class with at least 2 attributes and 2 behaviors. Call all
# person methods below the class so that they print their result to the
# terminal.
class Person
attr_accessor :thing1, :thing2
def initialize(thing1, thing2)
@thing1 = thing1
@thing2 = thing2
end
def method_one
p self... | true |
b9987a3fd8bea9a25e80a2cdb23ac099c10017b8 | Ruby | roderickfung/quiz1 | /q8.rb | UTF-8 | 1,407 | 4.03125 | 4 | [] | no_license | # 8. Create a Ruby class called Article inside a module called Blog that has two attributes: title and body. Write another class called Snippet that inherits from the Article class. The Snippet method should return the same `title` but if you call `body` on a snippet object it should return the body truncated to a 100 ... | true |
df4c135b48a8e40899c4168d2e05df80e15aa249 | Ruby | imwithsam/sales_engine | /lib/merchant.rb | UTF-8 | 2,220 | 2.671875 | 3 | [] | no_license | require 'bigdecimal'
require 'date'
require_relative 'record'
class Merchant < Record
def name
attributes[:name]
end
def items
return @items if defined? @items
@items = repository.engine.item_repository.find_all_by_merchant_id(id)
end
def invoices
return @invoices if defined? @invoices
... | true |
0171493ff82db7a24c8eebf01160ad9f558a9421 | Ruby | iastewar/oct-2015 | /ruby/password_crack.rb | UTF-8 | 702 | 3.765625 | 4 | [] | no_license | require 'digest/sha1'
#finds original password given that it is n letters, lower case, and uses SHA1 hashing
def find_password(hashed_password, n)
password = ("a" * n).split("");
_find_password(hashed_password, password, 0)
return password.join
end
def _find_password(hashed_password, password, index)
if index... | true |
04ff3a14b460b80679079d6a8897af78a35dc619 | Ruby | spemmons/zhivago_mr | /hour_counts.rb | UTF-8 | 927 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'wukong/script'
module HourCounts
class Mapper < Wukong::Streamer::Base
def process(*args)
imei,date,remainder = args[0].split(',')
lat,lng,ign,spd,remainder = args[1].split(',')
time = Time.parse(date)
time_string = Time.gm(time.year,time... | true |
3120abfdac672f2992e6e433b8dc207afbe83928 | Ruby | amymcgowan/app_academy_open | /02_software_engineering_foundations/17_mastermind_project_2019/lib/code.rb | UTF-8 | 1,106 | 3.5 | 4 | [] | no_license | class Code
POSSIBLE_PEGS = {
"R" => :red,
"G" => :green,
"B" => :blue,
"Y" => :yellow
}
attr_reader :pegs
def self.valid_pegs?(chars)
chars.all? { |char| POSSIBLE_PEGS.has_key?(char.upcase) }
end
def self.random(length)
random_pegs = []
length.times { random_pegs << POSSIB... | true |
648e6e1fe355e14480b0508a3e655ef02e9b8a71 | Ruby | nataliarossini/DSA-challenges | /lec-84.rb | UTF-8 | 607 | 4.5625 | 5 | [] | no_license | # Google Question
# Given an array = [2,5,1,2,3,5,1,2,4]:
# it should return 2
# Given an array = [2,1,1,2,3,5,1,2,4]:
# ir should return 1
# Given an array = [2,3,4,5]
# it should return undefined
require 'set'
def first_recurring_char(array)
hash = Set.new
array.each do |e|
if hash.include?(e)
... | true |
be6e2b2ff45179b047ec2d953797cbb16a97cd49 | Ruby | fabianekc/HyvE4 | /lib/tasks/sample_data.rake | UTF-8 | 1,863 | 2.65625 | 3 | [] | no_license | namespace :db do
desc "Fill database with sample data"
task populate: :environment do
make_users
make_postings
make_relationships
make_projects
make_groups
make_structures
make_datavals
end
end
def make_users
admin = User.create!(name: "Example User",
emai... | true |
15e8b0bca63eb9902bfa11f76e5955d0911c1205 | Ruby | katsuyoshi/motion-support | /spec/motion-support/core_ext/time/conversion_spec.rb | UTF-8 | 1,535 | 2.71875 | 3 | [
"MIT"
] | permissive | describe "Time" do
describe "conversions" do
describe "to_formatted_s" do
before do
@time = Time.utc(2005, 2, 21, 17, 44, 30.12345678901)
end
it "should use default conversion if no parameter is given" do
@time.to_s.should == @time.to_default_s
end
it "should use de... | true |
74a4e4e4e7e66d3782319c579ee246a86e8aa5d5 | Ruby | ning/cosmic-standalone | /lib/jruby/1.9/gems/cinch-1.1.3/lib/cinch/logger/formatted_logger.rb | UTF-8 | 2,461 | 3 | 3 | [
"MIT"
] | permissive | require "cinch/logger/logger"
module Cinch
module Logger
# A formatted logger that will colorize individual parts of IRC
# messages.
class FormattedLogger < Cinch::Logger::Logger
COLORS = {
:reset => "\e[0m",
:bold => "\e[1m",
:red => "\e[31m",
:green => "\e[32m",
... | true |
c28c95458ad8d859d595ce5470deb20074f575cb | Ruby | Sameer164/Word-Ghost | /twoplayerversion/game.rb | UTF-8 | 2,718 | 3.640625 | 4 | [] | no_license | require 'set'
require_relative './player.rb'
require 'byebug'
FILE = File.open('text.txt')
FILEDATA= FILE.readlines.map(&:chomp)
SET = FILEDATA.to_set
class Game
attr_reader :dictionary, :current_player, :previous_player
def initialize(name_player1, name_player2)
@fragment = ""
player1 = Play... | true |
144f0a8d20e083831830c1c8abf6b8259d117003 | Ruby | BenRKarl/WDI_work | /w01/d03/Andrea_Trapp/person.rb | UTF-8 | 557 | 3.796875 | 4 | [] | no_license | require 'pry'
class Person
attr_reader :name
attr_reader :age
attr_accessor :fav_color
attr_reader :fav_foods
def initialize(name, age, fav_color, fav_foods)
@name = name
@age = age
@fav_color = fav_color
@fav_foods = fav_foods
end
def greeting
puts "Hello #{@name}"
end
# this method would overwr... | true |
d5c913d78ad19b6f2f48d10fc69e06d4f16e233e | Ruby | doctordeep/arachni | /lib/arachni/mixins/progress_bar.rb | UTF-8 | 2,308 | 2.90625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | =begin
Copyright 2010-2014 Tasos Laskos <tasos.laskos@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless requi... | true |
1831ab4a722772e7225f4d7fbfd930aed16e5ae2 | Ruby | james-poore/ruby_word_count | /wc.rb | UTF-8 | 5,705 | 3.125 | 3 | [] | no_license | require 'optparse'
require 'pp'
APP_NAME = "wc.rb"
APP_VERSION = "v1.0"
APP_AUTHOR = "James L Poore Jr."
DEBUG = false
options = {}
$text_from_stdin = false
$names_from_stdin = false
$error_message = ""
optparse = OptionParser.new do |opts|
opts.banner = "Usage: wc.rb [options] [file1 file2 ...]\n" +
... | true |
3a69fdd291b0a6eaacc8f717b43d75530160875d | Ruby | matthew-black/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 2,920 | 4.375 | 4 | [] | no_license | #RELEASE 0
def welcome_to_iteration
name1 = "Matthew"
name2 = "Bruno"
puts "Welcome to iteration! The block has not yet ran."
yield(name1, name2)
puts "The block has run, hooray!"
end
welcome_to_iteration { |name1, name2| puts "#{name1} and #{name2} are learning about iteration!" }
#RELEASE 1
pizza_topping... | true |
3cfcca810f73e87a034f5312323e317762211f73 | Ruby | ansdelft/qti | /lib/qti/v1/models/interactions/base_fill_blank_interaction.rb | UTF-8 | 1,428 | 2.59375 | 3 | [
"MIT"
] | permissive | module Qti
module V1
module Models
module Interactions
class BaseFillBlankInteraction < BaseInteraction
CANVAS_REGEX ||= /(\[.+?\])/.freeze
def canvas_stem_items(item_prompt)
item_prompt.split(CANVAS_REGEX).map.with_index do |stem_item, index|
if stem_i... | true |
b9a9244b44aec0a203b28e84e2dac95137bdc9e4 | Ruby | peterallin/palaver | /lib/palaver/gauge.rb | UTF-8 | 666 | 2.671875 | 3 | [
"BSD-2-Clause"
] | permissive | # Copyright (c) 2012, Peter Allin <peter@peca.dk> All rights reserved.
# See LICENSE file for licensing information.
module Palaver
class Gauge < Palaver::Base
def initialize(options)
@inital_percentage = 0
super(options)
end
def show
cmd = "dialog #@common_options --gauge '#@text' #@... | true |
7ee7cedd6baf9812d97f45f4fd76803b76a52531 | Ruby | gerndtr/ruby_practice | /Ruby_book/chapt7_1.rb | UTF-8 | 146 | 3.0625 | 3 | [] | no_license | puts 1 < 2
puts 1 > 2
puts 4 >= 5
puts 5 <= 5
puts "bug lady" < "Xander"
puts "bug lady".downcase < "Xander".downcase
puts 2 < 10
puts "2" < "10"
| true |
b62c379e5bbcde5bb83c9f86931aa136131c46e8 | Ruby | andresjordanze/ray_tracing | /vector3d.rb | UTF-8 | 916 | 3.484375 | 3 | [] | no_license | class Vector3d
attr_accessor :x, :y, :z
def initialize(x,y,z)
@x = x
@y = y
@z = z
end
def sum(v2)
x = (@x + v2.x)
y = (@y + v2.y)
z = (@z + v2.z)
r = Vector3d.new(x,y,z)
end
def res(v2)
x = (@x - v2.x)
y = (@y - v2.y)
z = (@z - v2.z)
r = Vector3d.new(x,y,z)
... | true |
d68d5ba515bc3272adbbabe04260637134eb5f34 | Ruby | Shehbaz/prima | /lib/prima.rb | UTF-8 | 270 | 2.75 | 3 | [] | no_license |
require 'prima/primegen'
require 'prima/table'
module Prima
class Prima
attr_accessor :length,:algorithm
def initialize(length,algo = Primegen.new)
@algorithm = algo
@length = length
end
def generate
algorithm.generate(length)
end
end
end
| true |
5bb352c51ca7ec33c3421986380c893880043b21 | Ruby | torihuang/phase-0 | /week-4/mini-challenge.rb | UTF-8 | 402 | 4.03125 | 4 | [
"MIT"
] | permissive | valueNotEntered = true;
while valueNotEntered do
puts "Is it a leap year? Y/N"
isLeapYear = gets.chomp
if isLeapYear == "N"
puts "There are #{365*24} hours in a year."
valueNotEntered = false;
elsif isLeapYear == "Y"
puts "There are #{366*24} hours in a leap year."
valueNotEntered = false;
e... | true |
e237c6f8a73f1b380a0f5703b88d2846dac2e173 | Ruby | lishulongVI/leetcode | /ruby/41.First Missing Positive(缺失的第一个正数).rb | UTF-8 | 1,506 | 3.796875 | 4 | [
"MIT"
] | permissive | =begin
<p>Given an unsorted integer array, find the smallest missing positive integer.</p>
<p><strong>Example 1:</strong></p>
<pre>
Input: [1,2,0]
Output: 3
</pre>
<p><strong>Example 2:</strong></p>
<pre>
Input: [3,4,-1,1]
Output: 2
</pre>
<p><strong>Example 3:</strong></p>
<pre>
Input: [7,8,9,11,12]
Output:... | true |
b3a3a6ba0258ff57255d942177c2c4fc16e95fe6 | Ruby | adrientoub/gdpr-explorer | /videos/types.rb | UTF-8 | 1,300 | 2.828125 | 3 | [] | no_license | require 'json'
require 'date'
class VideosIndex
attr_accessor :version, :channels
def self.from_json(json)
index = new
index.version = json['version']
index.channels = json['channels']&.map do |channel|
ChannelIndex.from_json(channel)
end
index
end
end
class ChannelIndex
attr_access... | true |
cfd504a7378bb1f6a6461c8c36b9a91b7a00c1aa | Ruby | colleenlavin/joerickettssucks | /scrapper.rb | UTF-8 | 373 | 2.890625 | 3 | [] | no_license | # TwitterTrends1.rb
require 'rubygems'
require 'rest_client'
require "uri"
def getPage(page)
offset = (50 * page).to_s
url = 'http://archive.is/offset=' + offset + '/http://laist.com/*'
RestClient.get(url)
end
page = getPage(0)
for url in URI.extract(page)
if url.include? 'laist'
puts url
end
end
# ... | true |
52d1b06a9f527fc32a43c638f7c264a9c994c3f6 | Ruby | DragonRuby/dragonruby-game-toolkit-contrib | /dragon/readme_docs.rb | UTF-8 | 60,526 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | # coding: utf-8
# Copyright 2019 DragonRuby LLC
# MIT License
# readme_docs.rb has been released under MIT (*only this file*).
module GTK
module ReadMeDocs
def docs_method_sort_order
%i[
docs_hello_world
docs_new_project
docs_deployment
docs_deployment_mobile
docs_de... | true |
2ca5b764134e35e14562d55ba81acbe5bf70893d | Ruby | jinascimento/task_manager | /app/services/tasks/task_creator.rb | UTF-8 | 418 | 2.59375 | 3 | [] | no_license | class Tasks::TaskCreator
COLOR_BY_PRIORITY = { low: '#6fd86f', medium: '#7471F9', high: '#FF2A2B' }.freeze
def initialize(params)
@params = params
end
def call
@task = Task.new(@params)
@task.pending!
set_color_by_priority
OpenStruct.new(success?: @task.save, task: @task, errors: nil)
end... | true |
deeeccd902643d7d9efdb353bd3573dc239d0f5f | Ruby | edwinlin/cartoon-collections-dumbo-web-career-010719 | /cartoon_collections.rb | UTF-8 | 436 | 3.140625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarves)
dwarves.each_with_index {|dwarf, idx| puts "#{idx+1} #{dwarf}"}
end
def summon_captain_planet(array)
return array.map {|ele| ele[0].upcase + ele[1...ele.length] + "!"}
end
def long_planeteer_calls(array)
return array.any? {|ele| ele.length > 4}
end
def find_the_cheese(snacks)
c... | true |
32390b645a48d0a44a11ae048eda87f7c5b44157 | Ruby | willpiers/tic-tac-toe | /lib/ttt_io.rb | UTF-8 | 2,046 | 3.828125 | 4 | [] | no_license | class TttIO
def self.determine_opponent_type
puts "would you like to play against a friend, or the computer?"
answer = nil
until ['1','2'].include? answer
puts "press 1 for computer, and 2 for human."
answer = accept_input
end
answer == '1' ? :computer : :human
end
def self.deter... | true |
b52ba0a4c834ccb72376108b7d8e4e0f5b7daffd | Ruby | substantial/sous-chef | /lib/sous-chef/node_manager.rb | UTF-8 | 372 | 2.53125 | 3 | [
"MIT"
] | permissive | class SousChef::NodeManager
attr_reader :parser, :nodes
def initialize(config_file)
@parser = SousChef::Parser.new(config_file)
@nodes = {}
initialize_node_collections
end
private
def initialize_node_collections
@parser.parse.each do |name, collection|
@nodes[name] = SousChef::NodeBui... | true |
d8bf236d675939fc2f1c2cb548beb83187d207c0 | Ruby | ID25/caesar | /test/services/cipher_test.rb | UTF-8 | 490 | 2.796875 | 3 | [] | no_license | require 'test_helper'
class CipherTest < ActiveSupport::TestCase
test 'correct decrypted text' do
shift = 3
text = 'hello world'
cipher = Cipher.new(text, shift)
encrypted_text = 'khoor zruog'
assert cipher.encrypt(text), encrypted_text
end
test 'correct encrypted text in other lang' do
... | true |
4c7203d9f3ee2d44072e808c2f335a9422b922de | Ruby | RossKinsella/CS4032-lab-1 | /lab-1.rb | UTF-8 | 496 | 3.390625 | 3 | [] | no_license | require 'socket'
class String
def string_between_markers marker1, marker2
self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
end
end
message = "hello"
socket = TCPSocket.new 'localhost', 8000
socket.puts "GET /distributed-sytems-lab-1.php?message=#{message} HTTP/1.0\r\n\r\n"
response = socke... | true |
2d150156a8ca07c424d5d61540a7ad8caf06a07e | Ruby | rcjara/git-writing-tool | /lib/git_writing_tool.rb | UTF-8 | 771 | 2.6875 | 3 | [] | no_license | require_relative 'file_reader.rb'
require_relative 'section.rb'
require_relative 'section_displayer.rb'
require_relative 'composer.rb'
module GWT
def self.run_file(filename)
full_filename = (filename =~ /\./) ? filename : filename + '.rb'
GWT::Runner.new(full_filename).instance_eval(File.read(full_filename)... | true |
49b2c65c7f06db80adfa9d64d035135ee769213d | Ruby | bsanyi/erlang-etf | /lib/erlang/etf/extensions/symbol.rb | UTF-8 | 844 | 2.671875 | 3 | [
"MIT"
] | permissive | module Erlang
module ETF
module Extensions
module Symbol
def __erlang_type__
if to_s.bytesize < 256
if to_s.ascii_only?
:small_atom
else
:small_atom_utf8
end
else
if to_s.ascii_only?
:atom... | true |
a70a240f982c903aeb605b140afca37289725652 | Ruby | marcripley/BioshockTA | /lib/rapturesubs.rb | UTF-8 | 1,633 | 3.6875 | 4 | [] | no_license | # Initializes the player and stores the name, current location, health and inventory
class Player
attr_accessor :name, :difficulty, :location, :health, :weapons, :inventory
def initialize(player_name, difficulty)
@name = player_name
@difficulty = difficulty
@health = 100
@weapons = ... | true |
1e9b48396e5c970f80eb39f91c5bedb9cca35e17 | Ruby | lmeriluoto/cs61aPrepCourse | /ch8/buildingAndSorting.rb | UTF-8 | 147 | 3.484375 | 3 | [] | no_license | puts 'Type as many words as you want!'
input = gets.chomp
words = []
while input != ''
words.push input
input = gets.chomp
end
puts words.sort
| true |
276f6250b6f431c4ec02d919e20c490cf9c03e26 | Ruby | dvdalilue/f_heap | /test/f_heap_test.rb | UTF-8 | 4,332 | 3.09375 | 3 | [
"MIT"
] | permissive | require "test_helper"
class FHeapTest < ActiveSupport::TestCase
def setup
@heap = FHeap.new
end
def setup_sample_heap
@node_1 = @heap.insert!(1)
@node_2 = @heap.insert!(2)
@node_6 = @heap.insert!(6)
@node_5 = @node_2.add_child!(5)
@node_3 = @node_1.add_child!(3)
@node_4 =... | true |
84b55cf28598ff79f6c7721e776f10dcedadb609 | Ruby | NicholasJYee/mediliza | /app/models/preference.rb | UTF-8 | 476 | 2.5625 | 3 | [] | no_license | # Preference record of all the patients
#
# @attribute patient_id
# @return [Integer] id of the patient being interacted with
# @attribute description
# @return [String] information about the preference
# @attribute likes
# @return [Boolean] true for likes and false for dislikes
class Preference < ActiveRecord::B... | true |
308aa64ba1748dfa85f0e144b88460b02522ebf7 | Ruby | jdbernardi/assignment_oop_warmups_1 | /fib.rb | UTF-8 | 558 | 4.15625 | 4 | [] | no_license | ## FIBONACCI SEQUENCE ##
def fibs( num )
# initial array for fibonacci
fib_start = [0,1]
index = 0
if num == 1
print [0]
return [0]
end
# until the count of result is the given num
until fib_start.count >= num
# if the array is 1 or 2 we return [0] or [0,1]
fib_start << fib_start[ index ] + fi... | true |
06851a7fea398c867cbb55e1ed7727a74e988d77 | Ruby | pgaret/ttt-with-ai-project-web-0916 | /lib/board.rb | UTF-8 | 888 | 3.84375 | 4 | [] | no_license | require 'pry'
class Board
attr_accessor :cells
def initialize
@cells = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
end
def reset!
@cells = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
end
def display
print "\n-----------\n"
for i in 0..8
if i % 3 == 0 || i % 3 == 2 then print "... | true |
10ca1be7c663c541418c960edc6d2366e203ce9c | Ruby | bchandramouli/ruby_test_progs | /cookbook.rb | UTF-8 | 993 | 3.828125 | 4 | [] | no_license | #!/usr/bin/env ruby
class Cookbook
attr_accessor :title
attr_reader :recipes
def initialize(title)
@title = title
@recipes = []
end
def add_recipes(recipe)
@recipes << recipe
p "Added a recipe #{recipe.title} to the collection #{@title}"
end
def recipe_titles()
@recipes.each { |r| p r.title }
end
... | true |
dbb86eb008b19a988c6fea5f0a1e47038b52ee9d | Ruby | mliq/ruby | /StoS.rb | UTF-8 | 211 | 3.015625 | 3 | [] | no_license | h = {"dog"=>"puppy", "cat"=>"kitty", "goat"=>"kitty"}
g = {}
h.each do |key,value|
# puts "#{key} #{value}"
# h.delete[key]
key=key.gsub(/\s+/,"_").downcase.to_sym
g[key] = value
end
puts h
puts g
| true |
d61fc243aa479642ba14dc98449199d76ce95b3d | Ruby | yamashita-tomonori/object_brain | /ob_4_6/bucho.rb | UTF-8 | 200 | 2.765625 | 3 | [] | no_license | # coding: utf-8
require './shain.rb'
class Bucho < Shain
def initialize(name, kihonkyu)
super(name, kihonkyu)
end
def yakushoku
'部長'
end
def kyuryo
@kihonkyu * 3
end
end | true |
30e68a4b89cb399c2d6d712e97900f732e7042b0 | Ruby | kanamikiii/final | /lib/tasks/sample_data.rake | UTF-8 | 2,427 | 2.625 | 3 | [] | no_license | namespace :db do
desc "Fill database with sample data"
task populate: :environment do
make_users
make_entries
make_comments
make_relationships
# admin = User.create!(name: "Example User",
# email: "admin@admin.com",
# password: "admin12345",
# p... | true |
5c92066b435ecf70e5469607a3cd5e13cd4707fc | Ruby | nkansal96/aurora-ruby | /bin/aurora-tts | UTF-8 | 760 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'aurora-sdk'
if ARGV.length == 4
text = ARGV[0]
filename = ARGV[1].dup
app_id = ARGV[2]
app_token = ARGV[3]
if !filename.downcase.end_with? '.wav'
filename << '.wav'
end
begin
Aurora.config = Aurora::Config.new(app_id, app_token)
... | true |
63b8048eb9a1e464bd8146076f3b1bb940032fcc | Ruby | kallus/TrafficSim | /model/tcross_e_tile.rb | UTF-8 | 2,309 | 2.78125 | 3 | [] | no_license | #done and tested
class TcrossETile < Tile
def initialize
@paths = []
#copy of SW turn
entrance_west = lambda do |s|
s = s.to_f
r = 5.0
if s < 20 then [s, 25]
elsif s < 20 + r/2*Math::PI then
[20+r*Math.sin((s-20)/r),20+r*Math.cos((s-20)/r)]
else [25, 40+r/2*Math:... | true |
747300b898c6e871dbd41a6541908b4811542bd0 | Ruby | jayjaybigdog/fakebigdata | /NumberFileOutput.rb | UTF-8 | 1,104 | 3.359375 | 3 | [] | no_license | class NumberFileOutput
@width = 70 # 70 actual characters per line
@leftPadding = 5 # 5 white spaces on left side of a line
@rightPadding = 5 # 5 white spaces on right side of a line
def initialize (width, leftPadding, rightPadding)
@width = width
@rightPadding = rightPadding
@leftPadding... | true |
845a84fedb5bfd32a9eb6b4e93d71e910ef37143 | Ruby | tamouse/elapsed_watch | /lib/elapsed_watch/version.rb | UTF-8 | 498 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module ElapsedWatch
VERSION = "1.1.0"
DESCRIPTION = "
Reading a file of events, containing an event name (a string) and a
date-time string (yyyy-mm-dd hh:mm(:ss)), print a nice duration since
the event (if the event occurs in the past) or until the event (if the
event occurs in the future).
The impetous for this ... | true |
019912d95bb504d11aa773c62c9adf4ec44a95fc | Ruby | mihaibuzgau/pdksync | /lib/pdksync/constants.rb | UTF-8 | 3,776 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require 'yaml'
# @summary
# A module used to contain a set of variables that are expected to remain constant across all iterations of the main pdksync module.
# @note
# Configuration is loaded from `$HOME/.pdksync.yml`. If $HOME is not set, the config_path will use the current directory.
# Set PDKSYNC_LABEL to '... | true |
a7295d73ed84ebeb7ee911256f224a60c02d36d8 | Ruby | gadgetguy82/gym_project | /db/seeds.rb | UTF-8 | 4,087 | 2.796875 | 3 | [] | no_license | # require("pry")
require_relative("../models/booking")
require_relative("../models/gym_class")
require_relative("../models/room")
require_relative("../models/member")
require_relative("../models/instructor")
require_relative("../models/gym")
Booking.delete_all
GymClass.delete_all
Room.delete_all
Member.delete_all
Inst... | true |
a2097e4733e440019cf93020c191fbeed9c0b1b4 | Ruby | wearit/dagnabit | /lib/dagnabit/vertex/settings.rb | UTF-8 | 1,508 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), %w(.. vertex))
module Dagnabit::Vertex
##
# Contains parameters that can be customized on a per-vertex-model basis.
module Settings
##
# The name of this vertex's edge model.
#
# @return [String]
attr_accessor :edge_model_name
##
# The edge m... | true |
7a0f3fa51736eb1fd0d5f2b1cee111158415e338 | Ruby | Peacepapi/Aggron | /test/models/tool_test.rb | UTF-8 | 949 | 2.609375 | 3 | [] | no_license | require "test_helper"
class ToolTest < ActiveSupport:: TestCase
def setup
@tool = Tool.new(name: "Drill", description: "Yo, this things really work.")
end
test "user_id should be present" do
@tool.user_id = nil
assert_not @tool.valid?
end
test "tooltype should be present" do
@tool.tooltype_id = nil
... | true |
2892e399bcdc9d63b90145e7cb2230a022844784 | Ruby | lukedemi/advent-of-code-2018 | /day-20/part-2.rb | UTF-8 | 1,659 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
file_path = File.expand_path("../input.txt", __FILE__)
INPUT = File.read(file_path).chomp
MAP = Hash.new
D = {
'E' => [1,0],
'W' => [-1,0],
'S' => [0,1],
'N' => [0,-1]
}
def p
max_y = MAP.keys.max_by { |c| c.last }.last + 1
min_y = MAP.keys.min_by { |c| c.last }.last - 1
max_x = MA... | true |
4083daf21e72d5f1cecdd7a5ab7685ee142d4f7e | Ruby | NickPapayiannakis/ruby_experiments | /stock_picker.rb | UTF-8 | 851 | 3.734375 | 4 | [] | no_license | def stock_picker(array_of_prices)
highest_profit, current_profit, buy_price, sell_price, buy_day, sell_day = 0
array_of_prices.each_index do |day|
current_sell_price = array_of_prices[day]
current_buy_price = array_of_prices.first(day).min
if current_sell_price != array_of_prices.first... | true |
c9bf3e6df570014f6ef8958d74626f951509b4d7 | Ruby | autopp/dominion-2nd-lap | /border_guard.rb | UTF-8 | 5,134 | 3.265625 | 3 | [] | no_license | require_relative 'tactic'
class BorderGuard < Tactic
BG = :bg
# partner returns partner of this tactic
#
# @return [Symbol]
#
def partner
raise NotImplementedError
end
def gen_decks
with_combination_of_estates(12) do |factory, other_indices|
other_indices.permutation(2).map do |others|
... | true |
a93bd17cd929c56e0694c25a00fe0b56a774d34a | Ruby | StephenVarela/collections_and_iterations | /exercise5.rb | UTF-8 | 1,942 | 3.640625 | 4 | [] | no_license | def separate()
puts "-------------------------------------------------"
end
fav_colors = ['red', 'blue', 'green', 'yellow']
ages = [22,24,32,19,7]
coin_flips = ['heads', 'tails', 'heads', 'heads', 'heads']
fav_artists = ['Dream Theater', 'Metallica', 'Motley Crue']
fav_colors_sym = [:red, :blue, :green, :yellow]
#... | true |
b816c9a8a89ca3830ed97b48908f4742aa062da0 | Ruby | Reti500/NewsT | /hola.rb | UTF-8 | 396 | 3.15625 | 3 | [] | no_license | @tag = []
@str = "#Esto es un #Hashtag de prueba #AprendoAProgramar#Ruby".split(" ")
# @str.each do |cad|
# if cad.include? "#"
# @tag << cad.split( /#(\S+)/ ).last
# end
# end
def getTags( palabras, tags )
palabras.each do |p|
if p.include? "#"
minitag = p.split( /#(\S+)/ ).last
unless minitag.includ... | true |
1ddfc9edceb33e343563469e2586823116de6427 | Ruby | gsamokovarov/carmine | /lib/carmine/version.rb | UTF-8 | 359 | 2.609375 | 3 | [
"MIT"
] | permissive | class Carmine
module Version
Major, Minor, Patch =
File.read(File.expand_path('../../../VERSION', __FILE__)).split('.')
end
class << self
# Public: The version of the client.
#
# Returns a String of the dot joined version parts.
def version
[Version::Major, Version::Minor, Versi... | true |
bc9ef1c65662b5bf89b9a8f3ee9fe346bcd19f26 | Ruby | wthompson92/cross_check | /lib/team_module.rb | UTF-8 | 7,867 | 3.015625 | 3 | [] | no_license | require 'pry'
module TeamModule
def team_info(id)
team = teams.find{|x| x.team_id == id}
{ "team_id" => team.team_id,
"franchise_id" => team.franchise_id,
"short_name" => team.short_name,
"team_name" => team.team_name,
"abbreviation" => team.abbreviation,
"link" => team.link}
end
de... | true |
ea045c7d87a0b10327a14aee6e6a43809bb7af15 | Ruby | dlaguerta/FarMar | /specs/product_spec.rb | UTF-8 | 1,956 | 3 | 3 | [] | no_license | require_relative 'spec_helper'
module FarMar
describe Product do
describe "#initialize" do
let(:product) { Product.new(23, "milk", 112) }
it "should create an instance of a product" do
product.must_be_instance_of(Product)
end #end initialize method
end
describe "self.all" do
... | true |
506cb224a577d554329bd8e2a33f168a502cafc0 | Ruby | renaudbedard/ludivine | /test/test_health.rb | UTF-8 | 1,331 | 2.96875 | 3 | [] | no_license | #!/bin/env ruby
# encoding: utf-8
require 'coveralls'
Coveralls.wear!
require 'minitest/autorun'
require 'memory'
require_relative '../answer'
class TestHealth < Minitest::Test
def setup
require_relative '../module.health'
@@memory = HealthMemoryTest.new()
end
def test_health_health
... | true |
0c57e4b97ba79e93fce8232e8c8772c7557192fa | Ruby | thestokkan/RB100 | /exercises_ruby_basics/methods/make_and_model.rb | UTF-8 | 663 | 4.75 | 5 | [] | no_license | =begin
Make and Model
Using the following code, write a method called car that takes two arguments and prints a string containing the values of both arguments.
car('Toyota', 'Corolla')
Expected output:
Toyota Corolla
=end
def car(make, model)
puts make + ' ' + model
end
car('Toyota', 'Corolla')
=begin
Furth... | true |
d1064aa7e2fc5eab79c2b0bb763bf3881f89ee64 | Ruby | cristylk/weather-app | /weather.rb | UTF-8 | 1,365 | 3.109375 | 3 | [] | no_license | require 'yahoo_weatherman'
require 'sinatra'
def weatherman(user_location)
client = Weatherman::Client.new
celsius_result = client.lookup_by_location(user_location).condition['temp']
fahrenheit_result = ((celsius_result * 9) / 5) + 32
end
def conditions(user_location)
client = Weatherman::Client.new
c... | true |
820e91eef9b53bd4c64aa046297b22766d3345b1 | Ruby | chmodawk/Study_Ruby | /代码块/代码块参数.rb | UTF-8 | 2,038 | 3.90625 | 4 | [] | no_license | def total(from, to)
result = 0
# upto 方法将整数值按照从小到大的方式取出
from.upto(to) do |num|
# 判断变量是否由块赋予
if block_given?
# result += 从外部传来的num
result += yield(num)
else
# result += 自身的num
result += num
end
end
result
end
p total 1, 10
p total(1, 10) {|x| x ** 2}
... | true |
c3059889a62fafdf74e6ce75b2cd6081bb3ac5d3 | Ruby | mostafa-zahran/customer-record-cli | /data_stores/in_memory/stores/user.rb | UTF-8 | 646 | 2.546875 | 3 | [] | no_license | require './data_stores/in_memory/in_memory_interface'
module DataStores
module InMemory
module Stores
# Implementation of user store for in memory data store
class User
include DataStores::InMemory::InMemoryInterface
def initialize(origin_point)
@origin_point = origin_point... | true |
ca7c4d4bc39b56203301bf712531a9ec45f79f95 | Ruby | PaulaPaul/xRails | /learn-rails/app/models/owner.rb | UTF-8 | 980 | 3.8125 | 4 | [] | no_license | # owner model file
class Owner
def name
name = "Paula"
end
def birthdate
#this is the big day, on the actual year of birth
birthdate = Date.new(1960,12,8)
#Date is a pre-made class in Rails but not Ruby
end
def birthday
#this is the big day, in the current year
today = Date.today
... | true |
f3571ef48240595a07a8bb9073e3316f510361ca | Ruby | nathanallen/peoplesorts | /models/DSV.rb | UTF-8 | 427 | 3.25 | 3 | [] | no_license | class DSV #delimiter seperated values
def self.open(filepath)
input = File.read(filepath)
rows = input.split(/^/)
rows.map do |row|
yield(parse(row))
end
end
def self.delimiter_regex
%r{
\,\s # comma
| # or
\s\|\s # pipe
| # or else
\s ... | true |
6da8ae3a04d7ffa1ef27e5971d900d93be9b1db3 | Ruby | TMRahim/Deploy | /lib/match_schedules.rb | UTF-8 | 3,144 | 2.984375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'pry'
class Weather
def initialize(weather_site)
site_html = open(weather_site)
@weather_team = Nokogiri::HTML(site_html)
end
def weather_info
@weather_team.css("p.wx-temp").children.first.text
end
def rain_change
@weather_team.css("div.wx-d... | true |
d40e783ddcd92f70c9eb04f9da129af8102ef6cf | Ruby | a-straube/address-book | /lib/contact.rb | UTF-8 | 1,402 | 3.1875 | 3 | [
"MIT"
] | permissive | class Person
@@people = []
attr_accessor :first_name, :last_name, :birthday,
:phone, :email, :mailing_address
define_method(:initialize) do |attributes|
@first_name = attributes.fetch(:first_name)
@last_name = attributes.fetch(:last_name)
if attributes.has_key?(:birthday)
@birth... | true |
cab09dd4efb240c437b2789b348b7cffa330f209 | Ruby | fnando/formatted_attributes | /test/formatted_attributes_test.rb | UTF-8 | 1,164 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
class FormattedAttributesTest < Minitest::Test
test "sets initial value" do
product = Product.new(price: 12_300)
assert_equal "123,00", product.formatted_price
end
test "updates formatted price" do
product = Product.new(price: 12_300)
assert_... | true |
f2bd8d9938799c0ab49bf7e6ac6477597f9dbefd | Ruby | srirambtechit/ruby-programming | /ri-immutable-obj.rb | UTF-8 | 819 | 4.09375 | 4 | [] | no_license | # Freezing objects : The freeze method in class
# prevents you from changing on object, effectively
# turning an object into a constant. After we freeze
# an object, an attempt to modify it results in
# RuntimeError.
str = "A simple string"
str.freeze # Making it as immutable
begin
str << "An attempt to modify"
res... | true |
40d0d14039652c28d01ec115667b0f9e7d6bc1f1 | Ruby | mashedkeyboard/zxcvbn-ruby | /lib/zxcvbn/tester.rb | UTF-8 | 885 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'zxcvbn/data'
require 'zxcvbn/password_strength'
module Zxcvbn
# Allows you to test the strength of multiple passwords without reading and
# parsing the dictionary data from disk each test. Dictionary data is read
# once from disk and stored in memory for the life of the Tester object.
#
# Example:
... | true |
3c2953f4033c6a99d928c022be96a604b8753713 | Ruby | dashotv/flame | /ruby/lib/flame/client.rb | UTF-8 | 1,363 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | require 'rest-client'
require 'uri'
require 'json'
module Flame
class EmptyResponseError < StandardError; end
class BadRequestError < StandardError; end
class Client
def initialize(url, options = {})
@base = url
@options = {}.merge(options)
@headers = {
content_type: 'applica... | true |
e34976aab792936c6b72a63c21829d1e5f8456b8 | Ruby | Unicity/Modules.rb | /unicity/bt/task_status.rb | UTF-8 | 1,159 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
##
# Copyright © 2015 Unicity International.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | true |
e9bf6148a8bf383d7583a04394952d887765fe61 | Ruby | Snakdoc/Ruby-J2 | /exo_17.rb | UTF-8 | 209 | 3.6875 | 4 | [] | no_license | puts "Hello visiteur, quel est ton âge?"
print ">"
age = gets.chomp.to_i
age.times do |i|
if (age - i == i)
puts "Moitié de l'âge";
else
puts "Il y a #{age - i} ans tu avais #{i} ans"
end
end
| true |
cb09a362bf277bba4bcdcce242aa69bd7087755d | Ruby | raychorn/analytics_logger | /app/controllers/files_controller.rb | UTF-8 | 1,487 | 2.65625 | 3 | [] | no_license | require "rubygems"
# Feature: Upload files to the server by using HTTP POST requests.
# Description: This feature initially is for the PCAP project
# Usages:
# $curl -F file=@C:\test.txt http://10.100.162.63:8082/files
# $curl -k -F file=@test.txt https://sprintcm.analytics.smithmicro.com/files
class FilesCo... | true |
1555ead666b336d31734bb48d7c4b4b32045d12d | Ruby | LBelin/Estimate | /lib/Order.rb | UTF-8 | 297 | 3.125 | 3 | [] | no_license | class Order
def self.worst(current)
current.each do |fbcase|
estimate = fbcase[0]
actual = fbcase[1]
score = estimate - actual
fbcase[2] = score
end
sorted_current = current.sort_by {|fbcase|fbcase[2]}
end
def self.best(current)
self.worst(current).reverse!
end
end
| true |
3ea9b05d9d76d8e8ded647df76688e0bb9b50792 | Ruby | brownjs03/key-for-min-value-online-web-pt-081219 | /key_for_min.rb | UTF-8 | 320 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
low_name = nil
low_num = nil
name_hash.collect do |name, num|
if low_num == nil or num < low_num
low_num = num
low_name = name
end
end
low_name
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.