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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6f24202ed740840afa9a105ad930d24e440620c1 | Ruby | deniciocode/practiceTDD | /spec/data_accessor_container_spec.rb | UTF-8 | 446 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'data_accessor_container'
describe DataAccessorContainer do
let(:data_container) { DataAccessorContainer.new }
it 'defines a method' do
expect(data_container.respond_to? :foo).to be true
expect(data_container.respond_to? :foo=).to be true
expect(data_container.respond_to? :bullshit).to be fals... | true |
8e7a6462845ceabd6951b06f4d027102ff59eee5 | Ruby | lame-impala/secret_parameter | /test/packer_test.rb | UTF-8 | 5,367 | 2.640625 | 3 | [
"MIT"
] | permissive | require_relative 'test_helper'
require_relative '../lib/secret_parameter/packer.rb'
require_relative './test_helper.rb'
class Uint8Test < Minitest::Test
def test_uint8_accessors_work
uint8 = SecretParameter::Uint8Packer.new('8_bit_unsigned_integer')
assert_equal(1, uint8.min_bytes)
assert_equal(1, uint8.... | true |
8ce3342f9aaa9b80b2099e9d5e12e0020187466c | Ruby | OlhaParkhomenko/RubyCode | /006_hello_world6.rb | UTF-8 | 314 | 3.640625 | 4 | [] | no_license | class Greeter
def hello(name = nil, familiy_name=nil)
if (name==nil || familiy_name ==nil)
puts "Hello world"
else
puts "Hello, #{name} #{familiy_name}"
end
end
end
greeting1 = Greeter.new
greeting1.hello('James','Bond')
greeting1.hello('Olga')
greeting1.hello(ARGV[1]='Bond')
greeting1.hello | true |
cff45a9ec17946b91fe9ad25efbdd0972c856d0e | Ruby | monicamendesmontanha/exercises_ruby | /Exercicio_de_repeticao/exercicio_de_repeticao_20.rb | UTF-8 | 553 | 4 | 4 | [] | no_license | #Altere o programa de cálculo do fatorial, permitindo ao usuário calcular o fatorial
#várias vezes e limitando o fatorial a números inteiros positivos e menores que 16.
def contador_valido()
contador = 0
while contador <= 0 or contador > 16 do
print "Digite um numero que você queria saber o fatorial: "
... | true |
f24655fdef280bbbe1387abf730114ec074265d5 | Ruby | GolovkoStepan/thinknetica_base_course | /lesson_1/task_2.rb | UTF-8 | 768 | 3.40625 | 3 | [] | no_license | # frozen_string_literal: true
# rubocop:disable Style/AsciiComments
# Площадь треугольника.
# Площадь треугольника можно вычислить, зная его
# основание (a) и высоту (h) по формуле: 1/2*a*h.
# Программа должна запрашивать основание и высоту
# треугольника и возвращать его площадь
# rubocop:enable Style/AsciiComments... | true |
22204e954a2d2994bf26587ec999fa2b5158cae6 | Ruby | furyfire/codingtests | /ProjectEuler/004/solve.rb | UTF-8 | 182 | 3.140625 | 3 | [] | no_license | max = 0;
(100..1000).each do |num1|
(100..1000).each do |num2|
sum = num1 * num2
if( sum > max and sum.to_s.reverse == sum.to_s)
max = sum
end
end
end
print max | true |
9e17722adec3b605fe0eb91450a2fff4c617aa92 | Ruby | Deepakdanger/TIC_TAC_TOE | /spec/spec_player.rb | UTF-8 | 474 | 2.671875 | 3 | [
"MIT"
] | permissive | require_relative '../lib/player'
require 'rspec'
# To Run "rspec spec/spec_player.rb"
describe Player do
player = Player.new
describe 'name_check method ' do
let(:per) { '' }
it 'should return false is person1 length = 0' do
expect(player.name_check(per)).not_to be true
end
end
describe 'name... | true |
3d0e701c37d6f9f0e39889c0f5fb320ab01486ca | Ruby | seanmr7/mastermind-exercise | /mastermind.rb | UTF-8 | 3,887 | 4.15625 | 4 | [] | no_license | # Defines solution creation and guess methods for human player.
module Human_Player
def guess
@colors = []
4.times do
puts 'What\'s your guess: '
@colors << gets.chomp
end
end
def define_solution
4.times do
puts 'Create a solution using colors: (r)ed, (g)reen, (y)ellow, (b)lue'
... | true |
5757e42badf997495493bd7ccaba4b7bcea7ddce | Ruby | Case104/phase-0 | /week-4/factorial/my_solution.rb | UTF-8 | 296 | 3.453125 | 3 | [
"MIT"
] | permissive | # Factorial
# I worked on this challenge with Kyle Zelman.
# Your Solution Below
def factorial(number)
total = 1
if number == 0
return 1
else
while number > 1
total *= number
number -= 1
end
return total
end
end
=begin
def factorial(number)
number.downto(1).reduce(:*)
end
=end | true |
19225e84e195c57c25f4e6bf2654fd7d5b563970 | Ruby | nuclearsandwich/fancy | /boot/rbx-compiler/parser/parser.rb | UTF-8 | 11,736 | 2.828125 | 3 | [
"BSD-3-Clause"
] | permissive |
class Fancy
# This module has methods that can be used as callbacks from
# the parser, so that we can have a relatively simple fancy.y
# For example, when the parser sees a literal (or any other node)
# it just calls methods defined here. that create actual
# AST nodes, returning them to the parser to be st... | true |
e6bf59e9e877a2e62a22b70edbb87506e95159e0 | Ruby | amanmibra/colab-webpacker-class | /app/controllers/api/posts_controller.rb | UTF-8 | 1,937 | 2.53125 | 3 | [] | no_license | class Api::PostsController < ApplicationController
# GET /api/posts
def index
render json: {
data: Post.all
}, status: :ok
end
# GET /api/posts/:id
def show
if Post.exists? params[:id]
render json: {
data: Post.find(params[:id]),
message: 'Post found.'
}, status... | true |
0a15aab29d7feb4302d3e7fd7b174b1f13f00171 | Ruby | alexfcdp/library | /utils/testData.rb | UTF-8 | 4,056 | 2.765625 | 3 | [] | no_license | require_relative '../model/book'
require_relative '../model/author'
require_relative '../model/reader'
require_relative '../model/order'
class TestData
def initialize(library)
loading_data(library)
end
def loading_data(library)
author1 = Author.new("Gregory Brown", "Has run the independently published ... | true |
352bc2da80f0cfe91e5bb600e7eeb506cec930cf | Ruby | mlnewman-ge/NetApp.rb | /lib/nmsdk/NaElement.rb | UTF-8 | 9,858 | 3.171875 | 3 | [
"MIT"
] | permissive | #============================================================#
# #
# $ID$ #
# #
# NaElement.rb #
# ... | true |
dca631dc0f9f48e286535dc7ca4b4f484e6f0a8b | Ruby | SlipperyJ/run_time_encoder_api | /spec/unit/lib/encoder_spec.rb | UTF-8 | 1,120 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../../lib/encoder'
# rubocop:disable Metrics/BlockLength
RSpec.describe Encoder do
describe '#encode' do
context 'when the text to encode is valid' do
let(:text_to_encode) { 'OOOOFFFFFFKBGGGEEEEEEE' }
it 'encodes the text' do
expect(describ... | true |
6761cc8e971338c6a9e103db429a1866a2fc83f7 | Ruby | vaevictis/evaluation | /html_indenter.rb | UTF-8 | 410 | 3.09375 | 3 | [] | no_license | module HtmlIndenter
def build_node(array, space_size=0, blank_line=false)
current_element = array.shift
space_size.times { putc "\s" }
puts "<" + current_element.to_s + ">"
puts if blank_line
unless array.empty?
build_node(array, space_size + 2, blank_line)
puts if blank_line
end... | true |
495f5d879a8fa72a269b275237909a82c89ebf87 | Ruby | damianFC/blockchain.lite.rb | /test/test_block.rb | UTF-8 | 640 | 2.78125 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | # encoding: utf-8
###
# to run use
# ruby -I ./lib -I ./test test/test_block.rb
require 'helper'
class TestBlock < MiniTest::Test
def test_version
pp BlockchainLite.version
pp BlockchainLite.banner
pp BlockchainLite.root
assert true ## (for now) everything ok if we get here
end
def test_exampl... | true |
63902abcba01b5d3e8ae7180be53e2adeb7b1460 | Ruby | samrjenkins/smartpension | /ruby_app/parser/models/log.rb | UTF-8 | 373 | 2.78125 | 3 | [] | no_license | # frozen_string_literal: true
module Parser
class Log
def initialize(file_path)
@file_path = file_path
end
def each_line(&block)
within_open_file do |file_lines|
file_lines.each(&block)
end
end
private
attr_reader :file_path
def within_open_file(&block)
... | true |
12c52d033be490ae417d7f27bc6f3c88fd5772c7 | Ruby | basileuskorax/prpwrk | /Done/appacademy-online-students-courses-103ccbf70eb0/lib/student.rb | UTF-8 | 1,156 | 3.21875 | 3 | [] | no_license | class Student
attr_reader :courses, :first_name, :last_name
def initialize(first_name, last_name)
@first_name, @last_name = first_name, last_name
@courses = []
end
def name
"#{first_name} #{last_name}"
end
def enroll(course)
return if courses.include?(course)
raise "course would cause... | true |
1d4b865911f5eb9bc60ce517ef62af0a29593d42 | Ruby | Yuki-Ichigo/Ruby-practice | /2-8/lesson7.rb | UTF-8 | 167 | 3.40625 | 3 | [] | no_license | puts "計算をはじめます"
puts "2つの値を入力してください"
a=gets.to_i
b=gets.to_i
puts "a+b=#{a+b}"
puts "計算を終了します" | true |
e980f226d0db826ec2b94c7768f1d462b57306a3 | Ruby | tasharnvb/basic-ruby | /classes.rb | UTF-8 | 1,908 | 4.6875 | 5 | [] | no_license | class Person
# This method creates the getters automatically
# attr_reader :height, :hair_colour, :top_colour, :name
# This method creates the setters automatically
# attr_writer :height, :hair_colour, :top_colour, :name
# This method combines the above two (creates setters and getters)
attr_accessor :nam... | true |
98d0860c7f34f236c2eec6be92efa249f66a84b1 | Ruby | maximiliano1985/tutorial_ruby_italiano | /6_classi/6.2_ereditarieta.rb | UTF-8 | 2,784 | 3.46875 | 3 | [] | no_license | #!/usr/bin/env ruby
#-------------------------------------------------------------------------#
# Esercitazioni in Laboratorio per il Corso di #
# Fondamenti di Informatica e Calcolo Numerico, AA 2013/2014 #
# ... | true |
7287dcb0f19111b3d3f7a111dfc10f41c72a0635 | Ruby | GBouffard/Airport-challenge | /spec/feature/grand_finale_spec.rb | UTF-8 | 822 | 3.0625 | 3 | [] | no_license | require 'capybara/rspec'
require 'airport'
require 'plane'
# Makers Academy Grand finale:
# Given 6 planes, each plane must land.
# Check when all the planes have landed that they have status "landed"
# Once all planes are in the air again, check that they have status "flying!"
feature 'Grand Finale' do
airport = A... | true |
87a2f15f2a231df1b0ea78b8e1017f8160e777d4 | Ruby | ktlustos/LearnRubyTheHardWay | /ex5.rb | UTF-8 | 535 | 3.640625 | 4 | [] | no_license | my_name = "Kent Tlustos"
my_age = 27
my_height = 72 * 2.54 # inches # now cms
my_weight = 135 / 2.2 # lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Blonde'
puts "Let's talk about #{my_name}."
puts "He's #{my_height} cms tall."
puts "He's #{my_weight} kilos heavy."
puts "Actually that's really light."
puts "He's g... | true |
7320fdef0e1d0791245adba8e0c7803afbd32e60 | Ruby | mcdonaldcarolyn/activerecord-validations-lab-online-web-pt-092418 | /app/models/post.rb | UTF-8 | 792 | 2.96875 | 3 | [] | no_license | class MyValidator < ActiveModel::Validator
def validate(post)
puts "got here with #{post.title}"
if !post.title
return false
elsif post.title.downcase.include? "won't believe"
return true
elsif post.title.downcase.include? "secret"
return true
elsif post.title.downcase.include? "... | true |
bd19dfc7bb1c0d8eaa0af34ea90343b4617bd081 | Ruby | Kyle-Law/hackerrank-solutions | /Hackerrank/encryption.rb | UTF-8 | 579 | 3.421875 | 3 | [
"MIT"
] | permissive | def encryption(s)
clean_s = s.strip
s_length = clean_s.size
ceil = (s_length**0.5).ceil
floor = (s_length**0.5).floor
grid = clean_s.split('').each_slice(ceil).to_a
while grid[-1].size < ceil
grid[-1]<<' '
end
tranpose_grid = grid.transpose
result = ''
tranpose_grid.each... | true |
0e6825127fcb955faf7f150e0f0608cbdfaccf58 | Ruby | FergusLemon/chitter-challenge | /app/models/user.rb | UTF-8 | 1,476 | 2.5625 | 3 | [] | no_license | require 'bcrypt'
class User
include DataMapper::Resource
attr_reader :password
has n, :peeps
property :id, Serial
property :name, String, :required => true, :messages => {
:presence => 'Please enter your name' }
property :username, ... | true |
0443b469858fd7f007da2aa3ef9f0837752464d1 | Ruby | colmarius/poodr | /chapter_5.rb | UTF-8 | 1,230 | 3.578125 | 4 | [] | no_license | class Vehicle
end
class Trip
attr_reader :name, :bicycles, :customers, :vehicle
def initialize(opts = {})
@name = opts.fetch(:name, 'Demo Trip')
@bicycles = opts.fetch(:bicycles, [])
@customers = opts.fetch(:customers, [])
@vehicle = opts.fetch(:vehicle, Vehicle.new)
end
def prepare(preparers... | true |
312263c3ea3c6e8d9ae9f5afc0a166b26cbee101 | Ruby | demonnic/rmuddy | /enabled-plugins/walker.rb | UTF-8 | 7,694 | 3.015625 | 3 | [] | no_license | #The Walker is a taaaaad bit more complex than the other plugins.
#The main reason being that we need to use multi-threading to make timers work.
#Essentially, we set our character down on a mono-rail of directions they should go through,
#and from there let the room ratter do it's work. Every time we hit, see, or do a... | true |
ad1c964236b1514b710f596b655a050901c3936e | Ruby | shlomif/kakuro-cross-sums | /solver/ruby/bin/dump-board-menneske.no-359426.rb | UTF-8 | 1,237 | 2.75 | 3 | [
"MIT"
] | permissive | require "kakuro-board.rb"
puts "Before new"
$BOARD = Kakuro::Board.new
puts "After new"
$BOARD.parse(<<'EOF')
[\] [17\] [16\] [7\] [\] [\] [\] [\]
[\19] [] [] [] [\] [\] [16\] [3\]
[\17] [] [] [] [29\] [4\11] [] ... | true |
ac109cbac4894286bbdef35821c8d968ca894477 | Ruby | GAP-RobertoSequeira/catching-up-with-ruby-basics | /session_5/07_reduce_array_and_hash.rb | UTF-8 | 1,408 | 3.9375 | 4 | [] | no_license | ##########################################################################
# In reduce the accumulator is passed by value
# and the result from the block execution is passed to the next iteration
##########################################################################
p [1, 2, 3].reduce(:+)
# in (m << v * 2) the << ... | true |
738e41b46736eec7930455d677ec4436e7352484 | Ruby | daniel-huertas/rails-superbarman | /db/seeds.rb | UTF-8 | 2,169 | 2.59375 | 3 | [] | no_license | require 'open-uri'
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of t... | true |
fdeaf71757ca4de4e8711dc43a1b316588cbea2d | Ruby | mdm106/vet-practice-rails | /app/models/treatment.rb | UTF-8 | 358 | 2.734375 | 3 | [] | no_license | class Treatment < ApplicationRecord
has_and_belongs_to_many :animals
def self.fromString(string)
treatment = Treatment.where(name: string.strip).first
return treatment ||= Treatment.create(["name" => string]);
end
def self.fromStrings(array_of_strings)
array_of_strings.map{|string|... | true |
2e2f0bfe8ebbe58c643b4cc1624350bdab9342e7 | Ruby | macGH/rpn_calculator | /rpn_calculator.rb | UTF-8 | 829 | 3.328125 | 3 | [] | no_license | require './rpn_error'
class RPNCalculator
OPERATORS = /^[\+\-\*\/]$/
NUMBERS = /^[-+]?[0-9]*\.?[0-9]+$/
def self.do_magic(input)
raise RPNError if !self.valid?(input)
stack = []
input.each do |i|
if !i.match(OPERATORS)
stack.push(i)
else
number_2 = stack.pop.to_f
... | true |
5768fc205a3b1075d31bb0c0bcce07ca43c3fe8a | Ruby | jubaan/m__capstone__linter | /lib/checks.rb | UTF-8 | 1,234 | 2.5625 | 3 | [
"MIT"
] | permissive | require_relative './errors.rb'
module Checks
include SyntaxErrors
def white_trailing_space?(str, idx)
raise TrailingSpaceError.new(str, idx) unless str.match?(/([^\s]\n)$/) || str.match?(/^\n$/)
rescue TrailingSpaceError => e
e.message
end
def space_after_colon?(str, idx)
raise NoSpaceAfterCErr... | true |
f652137ff0ac30978d705aab9e4cd07c7a7ef41b | Ruby | apetrov/apetrov-bundles | /Support/model_autocomplete.rb | UTF-8 | 1,352 | 2.671875 | 3 | [] | no_license | class ModelAutocomplete
def parse(line)
line = line.strip
tokens = line.split(".")
subject = tokens.first
if tokens.size == 1
if(complete_last_token?(line))
model_method_autocompete(tokens.first)
else
model_name_autocomplete(tokens.first)
end
else
... | true |
c07027ba17ea80d9116129ed56082bcfca09a44a | Ruby | patmccartney2/sorting_cards | /lib/guess.rb | UTF-8 | 619 | 3.46875 | 3 | [] | no_license | require './lib/card'
class Guess
attr_reader :response,
:card,
:response_boolean
def initialize(response, card)
@response = response
@card = card
@response_boolean
end
def correct?
response = []
@response.split.each_with_index do |string, index|
if index... | true |
dc91c8708aefc68f0a5078cd97d298d0f2652b8e | Ruby | javiertoledo/ruby2js | /bin/ruby2js | UTF-8 | 570 | 2.78125 | 3 | [] | no_license | #!/usr/bin/ruby -s
require 'rubygems'
require 'ruby2js'
# TODO: Create a File compiler using ruby2js library that compiles ARGV[0] .rb to .js
# Check the file exists and has rb extension
if ARGV[0] =~ /(.+)\.rb$/ && File.exists?(ARGV[0])
puts "Compiling Ruby file #{ARGV[0]} into JavaScript file #... | true |
4a6f4815d5c3cb3e2e96d9bbac81bd3dd78035f5 | Ruby | tohyongcheng/waffles | /app/models/book.rb | UTF-8 | 3,945 | 2.578125 | 3 | [] | no_license | class Book < ActiveRecord::Base
has_and_belongs_to_many :authors
belongs_to :publisher
has_many :opinions
has_and_belongs_to_many :subjects
attr_accessor :count
validates_presence_of :authors
validates_presence_of :subjects
def self.raw_to_books(results)
books = []
results.each do |r|
boo... | true |
3d298fb4d12f10be43dc977a4c1ef9449207b4ef | Ruby | AshleyRapone/programming_foundations | /small_problems_exercises/Easy5Q1.rb | UTF-8 | 897 | 5 | 5 | [] | no_license | # Write a method that determines and returns the ASCII string value of a string that is passed in as an argument.
# The ASCII string value is the sum of the ASCII values of every character in the string.
# (You may use String#ord to determine the ASCII value of a character.)
def ascii_value(string)
sum = 0
string.... | true |
2073d07e299664becee31609cc4e97e48a1047bf | Ruby | freiland/music-festival | /spec/artist_spec.rb | UTF-8 | 2,270 | 3.0625 | 3 | [] | no_license | require ('rspec')
require ('artist')
require('stage')
require('pry')
describe '#Artist' do
before (:each) do
Stage.clear()
Artist.clear()
@stage = Stage.new("SRV Stage", nil)
@stage.save()
end
describe ('#==') do
it ('is the same artist if it has the same attributes as another artist') ... | true |
4e8c221a7604436bf46494d9a3deac6143b88a1e | Ruby | nickcen/leetcode | /p637.rb | UTF-8 | 753 | 3.921875 | 4 | [] | no_license | # Definition for a binary tree node.
class TreeNode
attr_accessor :val, :left, :right
def initialize(val)
@val = val
@left, @right = nil, nil
end
end
# @param {TreeNode} root
# @return {Float[]}
def average_of_levels(root)
return [] unless root
queues = [root]
ret = []
while !queues.empty?
... | true |
9dd2b0724bbb0e67d7e63c384d77345de0fdc306 | Ruby | TribunaDoNorte/dojo | /17-nov-2012/session_1/spec/lib/relatorio_spec.rb | UTF-8 | 583 | 2.78125 | 3 | [] | no_license | # encoding: utf-8
require 'spec_helper'
describe Relatorio do
subject(:report) { Relatorio.new(input) }
let(:input) { 100 }
it "recebendo um número retorna uma instância válida" do
report.should be_kind_of(Relatorio)
end
describe '#imprimir' do
let(:fizzbuzz) { FizzBuzz.new }
it "deve ... | true |
d842bf543d3c44c8b6a27349cb2ea473a99d0503 | Ruby | jaysonvirissimo/scripture_group | /app/methods/verse_parser.rb | UTF-8 | 952 | 3.234375 | 3 | [] | no_license | # frozen_string_literal: true
class VerseParser
REPLACEMENT_CHARACTER = '�'
def initialize(line)
@line = line
end
def call
create_book
create_chapter
create_verse
end
private
attr_reader :book, :chapter, :line
def chapter_number
chapter_and_verse_numbers.first
end
def crea... | true |
fd17dc6e2ecb8d242fb722d8a397235e167c5c2b | Ruby | enowmbi/algorithms | /first_bad_version.rb | UTF-8 | 498 | 3.515625 | 4 | [] | no_license | # The is_bad_version API is already defined for you.
# @param {Integer} version
# @return {boolean} whether the version is bad
# def is_bad_version(version):
# @param {Integer} n
# @return {Integer}
def first_bad_version(n)
left = 1
right = n
while(right > left )
middle = ((right - left) / 2) + left
if ... | true |
f7338f907a606e72b07c10c2ef68b18999513298 | Ruby | vbyno/listvytsia | /components/app_component/app/values/app_component/phone.rb | UTF-8 | 520 | 2.953125 | 3 | [] | no_license | module AppComponent
class Phone
attr_reader :human_number
# PhoneValue.new("0673540404"), PhoneValue.new("+3803243-55-31")
def initialize(human_number)
@human_number = human_number
end
def to_s
number
end
def number
@number ||= to_number(human_number)
end
def ... | true |
73b93a608480ea9c5c29620a3a5ea2f58d3fc7aa | Ruby | zkevinbai/market-base-assessment | /intermediateProgramming/regex.rb | UTF-8 | 304 | 2.703125 | 3 | [] | no_license | def my_expression()
# Write your code here.Return a string version of a regular expression.
"/.+/+"
end
# Input https://www.talentmatch.ai/welcome
# Output //www.talentmatch.ai/
# def my_expression()
# # Write your code here.Return a string version of a regular expression.
# "^.+w+"
# end | true |
47e01bdfa3f7dab92e05da55c30c90623d4c7a77 | Ruby | tshoulders/the_swot_bot | /app/models/grade_calculator.rb | UTF-8 | 1,111 | 2.90625 | 3 | [] | no_license | class GradeCalculator
attr_reader :student, :course
def initialize(options = {})
@student = options[:student]
@course = options[:course]
@term = options[:term_id]
end
def grade
(total_points / total_weight) * 100
rescue ZeroDivisionError
100
end
def total_points
cumulative_score... | true |
da7e18d894ffd3af9eb367c210b38e639ba2c188 | Ruby | chitasan/enums_exercises_ruby | /lib/generator/none_problem.rb | UTF-8 | 1,229 | 2.984375 | 3 | [
"MIT"
] | permissive | class NoneProblem
def self.test_suites
exercise = Exercise.new(:none)
exercise << Problem.new(
"none_are_broken",
{"things" => %w(functional working works fixed good)},
{"none_broken" => "assert"},
'thing == "broken"'
).example!
exercise << Problem.new(
"double_negative... | true |
10c80d4230fb500d0d0ab23a9fd2de012f97c209 | Ruby | brentguf/stock-picker | /script.rb | UTF-8 | 986 | 3.59375 | 4 | [] | no_license | def stock_picker(stocks)
best_buying_day = 0
best_selling_day = 1
profit = stocks[best_selling_day] - stocks[best_buying_day]
possible_buying_days = stocks
possible_buying_days.each_with_index do |buying_day_price, buying_day|
first_possible_selling_day = buying_day + 1
possible_selling_days = stocks... | true |
54e91c0d68287cec6691e64762364d9254b821a8 | Ruby | gitmamhub/programming-fundamental | /exercise3.rb | UTF-8 | 148 | 3.515625 | 4 | [] | no_license | puts "whats your name ? "
user_name = gets.chomp
puts "Hello, #{user_name}"
x = 13
while (x > 4)
puts "I got printed !!! "
x -= 1 ;
end
| true |
550df83407811d83a978092645dd764ea6c3553b | Ruby | MadBomber/scripts | /docx_translate.rb | UTF-8 | 4,067 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
##########################################################
###
## File: docx_translate.rb
## Desc: Machine translation of *.docx files
## By: Dewayne VanHoozer (dvanhoozer@gmail.com)
#
require 'debug_me' # A tool to print the labeled value of variables.
require 'pathname' # STDLIB
require '... | true |
53e03117c91f57dd75388875301d60aa209bf74f | Ruby | Jiwoopark0508/coder_byte | /SecondGreatLow.rb | UTF-8 | 236 | 3.375 | 3 | [] | no_license | def SecondGreatLow(arr)
result = []
min = arr.sort.first
arr = arr.sort
arr.each do |x|
arr.delete(min)
end
min = arr.first
arr.each do |x|
if(x <= min)
result.push(x)
end
end
return result
end
| true |
e3ff47c84c881a3e2abb8911bb9b3cd286c91860 | Ruby | cbeer/mfcc | /lib/mfcc/dft.rb | UTF-8 | 1,069 | 2.890625 | 3 | [] | no_license | require 'complex'
module Mfcc
module Dft
def dft(data)
Mfcc.dft(data)
end
end
def self.dft(data)
return to_enum(:dft, data) { data.size } unless block_given?
n = data.size
data = plus_imaginary(data)
data.each_with_index do |_, k|
sumreal = 0
sumimag = 0
data.... | true |
b455be9934c51eadf9ef405d4aa9ab86a62b8064 | Ruby | CarlaHerran/Pre-work | /jueves1.rb | UTF-8 | 1,886 | 3.796875 | 4 | [] | no_license | #NUESTRO ABC
=begin
def caesar_cipher(original_text, rotate_number)
original_alphabet = "qwertyuiopasdfghjklzxcvbnm"
cipher_text = ""
original_text.split("").each do |letter|
if "?.,! '".include?(letter)
cipher_text << letter
else
cipher_alphabet = original_alphabet[(original_alphabet.index(le... | true |
7c2580668de801c43e94bf5388fdad5ba76d09dd | Ruby | rshiva/MyDocuments | /01-notes-programming /04-ruby+rails/ruby1.9/samples/refcio_45.rb | UTF-8 | 1,474 | 3.0625 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
de2acb8745fbd16880767bda471391d435665756 | Ruby | mikechau/gladius | /db/seeds.rb | UTF-8 | 1,938 | 2.578125 | 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 |
a737a79f7cbb38045c418b42305d0b3aa80142ac | Ruby | jsc215/Launch-Academy-Challenges | /isla-grill/code.rb | UTF-8 | 197 | 2.890625 | 3 | [] | no_license | dinner_total = 178
tip = 20
tip_amount = (dinner_total.to_f * tip.to_f) / 100
grand_total = dinner_total + tip_amount
puts "We should tip $#{tip_amount}"
puts "Our total bill is $#{grand_total}"
| true |
e3e4e62875570588274c0ae601af977f5ee6c332 | Ruby | jimmy2/launchschool_120_object_oriented_programming | /lesson_4_oo_practice_problems/easy_2/question_06.rb | UTF-8 | 422 | 3.671875 | 4 | [] | no_license | # Lesson 4: OO Practice Problems > Practice Problems: Easy 2
# If I have the following class:
class Television
def self.manufacturer
# method logic
end
def model
# method logic
end
end
# Which one of these is a class method (if any) and how do you know?
# The self.manufacturer is a class method. ... | true |
cae4e09c0dd94631e0f627247c27c25706685d77 | Ruby | brady-robinson/ls-rb101 | /lesson_6/twentyone.rb | UTF-8 | 2,826 | 3.328125 | 3 | [] | no_license | cards = [2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,
8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,11,11,11,11]
player_cards = []
dealer_cards = []
def eleven_to_one(player_cards)
player_cards.delete(11)
player_cards << 1
end
loop do
player_cards = []
dealer_cards = ... | true |
d02def20a092302b269765ca6ba37cc88f404374 | Ruby | hernanm92/rna_test_vocacional | /red_neuronal.rb | UTF-8 | 1,975 | 3.5625 | 4 | [] | no_license | require "rubygems"
require "ai4r"
CAREER = ['Ingeniero:', 'Abogado: ', 'Medico: ', 'Diseñador:', 'Contador: ']
skills = ARGV[0][1..-2].split(',').collect! {|n| n.to_i}
def result_label(result) #Match te optimal result
if result[0] > result[1] && result[0] > result[2] && result[0] > result[3] && result[0] > resul... | true |
2a0c2917d1ba90ba85f90bbbf193a3560f44ac38 | Ruby | Samdev145/checkout_system | /lib/total_discount_rule.rb | UTF-8 | 616 | 3.4375 | 3 | [] | no_license | class TotalDiscountRule
attr_reader :discount_percentage, :qualify_amount, :basket
def initialize(discount_percentage, qualify_amount)
@discount_percentage = discount_percentage
@qualify_amount = qualify_amount
end
def execute_rule(basket)
@basket = basket
if total_price > qualify_amount
return m... | true |
aafbee0f6035a837bc53341cd39ce5ebce7330d9 | Ruby | Lingy94/oo-relationships-practice-london-web-111918 | /app/models/airbnb/trip.rb | UTF-8 | 238 | 2.8125 | 3 | [] | no_license | class Trip
attr_accessor :guest, :listing
TRIPS = []
def initialize( guest, listing)
@guest = guest
@listing = listing
TRIPS << self
end
def self.all
TRIPS
end
def listings
end
def guests
end
end
| true |
16db156f39033803d64fb49a211b5ce7e5520523 | Ruby | Aiannn/ruby-enumerables-reverse-each-word-lab-nyc01-seng-ft-062220 | /reverse_each_word.rb | UTF-8 | 223 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #string = "Hello how are you?"
def reverse_each_word(string)
string.split
newArr = []
string.split.collect do |element|
newArr.push(element.reverse)
end
newArr.join(' ')
end
#reverse_each_word(string) | true |
8c478747ef2a9a685adfe59966f5d9212d28a6c4 | Ruby | vidhichander/ActionMap | /features/step_definitions/all_steps.rb | UTF-8 | 3,869 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require 'uri'
require 'cgi'
Given(/^(?:|I )am on (.+)$/) do |page_name|
visit path_to(page_name)
end
When(/^(?:|I )fill in "([^"]*)" with "([^"]*)"$/) do |field, value|
fill_in(field, with: value)
end
#
# When(/^(?:|I )fill in Idaho and press search$/) do
# visit search_repr... | true |
c5dc3f429207da6c16b4339fc775abc7bda5ab3a | Ruby | joao-parana/redis_sinatra | /webapp/lib/app.rb | UTF-8 | 780 | 2.65625 | 3 | [] | no_license | require "rubygems"
require "sinatra"
require "redis"
require "uri"
class App < Sinatra::Application
configure do
REDISTOGO_URL = "redis://localhost:6379/"
uri = URI.parse(REDISTOGO_URL)
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end
set :bind, '0.0.0.0'
ge... | true |
6a65c8867ec912b06abfc724950c3074acd8377e | Ruby | saifulAbu/leetcode | /1365_smaller_num_than_current.rb | UTF-8 | 340 | 3.578125 | 4 | [] | no_license | # @param {Integer[]} nums
# @return {Integer[]}
def smaller_numbers_than_current(nums)
result = []
nums.each do
|num|
count = 0
nums.each do
|num_compare|
count += 1 if num > num_compare
end
result << count
end
result
end
nums = [8,1,2,2,3]
p smaller_number... | true |
ad74813c3b96a4c62a3586897632444478ed1226 | Ruby | NateGiesing/Jungle_beat | /nodes/lib/linked_list.rb | UTF-8 | 764 | 3.453125 | 3 | [] | no_license | require "./lib/node.rb"
require "pry"
class LinkedList
attr_reader :head
:count
def initialize
@head = nil
@bag_of_strings = []
#@newest_node = newest_node
end
def append(data)
@bag_of_strings << data
if head.nil?
@head = Node.new(data)
else... | true |
4c8cd7c05ef50836cc6111fb96bdb28153bd3ed4 | Ruby | juanmoliva/POO | /TPs/TP1/Points/Figuras.rb | UTF-8 | 261 | 3 | 3 | [] | no_license | class Figuras
def initialize
not_overriden
end
def area
not_overriden
end
def perimeter
not_overriden
end
protected def not_overriden
raise 'This method should be overriden.'
end
def point_in_perimeter(p)
self.point_belongs_per(p)
end
end | true |
e45d79b9d16926f8b0e67b0edb237b39d6052d4e | Ruby | timctao/phase-0-tracks | /ruby/calorie_counter/calorie_counter.rb | UTF-8 | 8,726 | 3.5 | 4 | [] | no_license | # I know that this code is definitely NOT DRY, but I worked a long time and I think it works (I tested most everything)
# I would like to come back to this to modify the code but I'm a bit tired and I ran out of time. Hope it works for you!
require 'sqlite3'
# Create database for calorie counting
db = SQLite3::... | true |
202d1cf7103c6f3d799092228388a902a795ebb7 | Ruby | dladowitz/whiteboarding | /standard_solutions/fibonacci.rb | UTF-8 | 591 | 4.375 | 4 | [] | no_license | #1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89
def fibinacci_recursive(n)
if n < 2
return n
else
return fibinacci_recursive(n-2) + fibinacci_recursive(n-1)
end
end
def fibinacci_iterative(n)
sequence = [0, 1]
(n-1).times do |index|
sequence << sequence[-2] + sequence[-1]
end
sequence.last... | true |
90c94c9f6f036991e2ee5f39b57c0a11b10c1b3b | Ruby | sainipardeep87/vegan_snack | /app/models/spree/address_decorator.rb | UTF-8 | 3,146 | 2.609375 | 3 | [] | no_license | Spree::Address.class_eval do
before_validation :clear_validations_on_country
#before_validation :clear_validations_on_phone
belongs_to :user
#phone_no_regex = /\A[0-9]{3}-[0-9]{3}-[0-9]{4}|[0-9]{10}|[(][0-9]{3}[)][0-9]{3}-[0-9]{4}\Z/
phone_no_regex = /\A^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})\Z/
... | true |
650bca0a3f912dc7c1106ac1ff68a77504035021 | Ruby | stridera/wellington | /app/commands/import/dublin_members.rb | UTF-8 | 2,700 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Copyright 2019 Matthew B. Gray
#
# 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 applica... | true |
559e63e91b8b2c0b265dfab08bb888caf11021b7 | Ruby | ProgrammingPractice/YahtzeeGame | /console/lib/game_wrapper.rb | UTF-8 | 2,149 | 3.21875 | 3 | [
"MIT"
] | permissive | class GameWrapper
class RoundStep < Struct.new(:action, :callback); end
class AskForHoldPositionsAction < Struct.new(:roll, :player, :rolls_count); end
class AskForCategoryAction < Struct.new(:roll, :player); end
def initialize(game)
@game = game
advance_to_next_player
end
def score(player_na... | true |
c2ba1532fa2c999934e13065fde1edbbbad8f218 | Ruby | blnkt/cyoa-activerecord | /cyoa.rb | UTF-8 | 5,201 | 2.890625 | 3 | [] | no_license | require 'bundler/setup'
Bundler.require(:default)
Dir[File.dirname(__FILE__) + '/lib/*.rb'].each { |file| require file }
database_configurations = YAML::load(File.open('./db/config.yml'))
development_configuration = database_configurations['development']
ActiveRecord::Base.establish_connection(development_configuration... | true |
100129f48e0e11b7638f16a8fafe49480bd1e553 | Ruby | petertseng/adventofcode-rb-2018 | /01_frequency_deltas.rb | UTF-8 | 970 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | input = ARGF.each_line.map(&:to_i).freeze
puts sum = input.sum
if sum == 0
puts 0
exit 0
end
# https://www.reddit.com/r/adventofcode/comments/a20646/2018_day_1_solutions/eaukxu5/
# Summary: Track cumulative sum for one cycle through the input.
# Note that all future iterations are offset by the total delta for o... | true |
c7176d1c2c9bbd90e1b6ef3bcad2a75a78fb2d6b | Ruby | tekacs/simple-rsa-solver | /rsaenc.rb | UTF-8 | 255 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'ntheory'
def rsaenc(n, e, m, conv)
result = []
if conv
m = m.split('').map {|i| i[0]}
else
m = m.split(' ').map {|i| i.to_i}
end
m.each do |w|
result << NTheory.modexp(w, e, n)
end
return result
end
| true |
38976f47f987ab04ae0d0415ebf2a67abd83c8d0 | Ruby | readeldj/cheers_take2 | /test/test_cheers_integration.rb | UTF-8 | 4,665 | 3.1875 | 3 | [
"MIT"
] | permissive | # require 'rubygems'
# require 'bundler/setup'
require "minitest/autorun"
class TestCheersIntegration < Minitest::Test
def test_help_message
output = `./cheers`
expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with './cheers.rb' [Name] [MM/DD Birthday]
EOS
assert_equal expected... | true |
ae70051584906f222f796859a2beca77b7b49b7d | Ruby | corvec/NERO-Character-Creator | /src/nero_skills.rb | UTF-8 | 8,967 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
=begin
This file is part of the NERO Character Creator.
NERO Character Creator is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any la... | true |
4b31b92fb6fed60539503b0b48c7c891dafb7447 | Ruby | m4i/chef-cookbooks | /latest_version/libraries/latest_version/base.rb | UTF-8 | 915 | 2.609375 | 3 | [] | no_license | module LatestVersion
class Base
class << self
def latest_version(versions)
raise 'versions is empty' if versions.empty?
versions.map do |version|
[
::Gem::Version.new(version.gsub(/[^\.\dA-Za-z]+/, '.')),
version,
]
end.sort.last.last
... | true |
afebbd598c6ed492a32f93c9d130d923e81d0ad3 | Ruby | thirunjuguna/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 344 | 3.78125 | 4 | [] | no_license | def echo(msj)
msj
end
def shout(msj)
msj.upcase
end
def repeat(msj, n=2)
("#{msj} "*n).chop
end
def start_of_word(msj, n)
msj[0..n-1]
end
def first_word(msj)
msj[/\w+/]
end
def titleize(msj)
little_words = ['and', 'the', 'of', 'over']
msj.capitalize.split.map{ |str| little_words.include?(str) ? str : str.ca... | true |
4c81e99e2ffa4e190918b43f0f810322690f92bb | Ruby | mralexgray/ascii.io | /app/streamers/json_streamer.rb | UTF-8 | 430 | 2.875 | 3 | [
"MIT"
] | permissive | class JsonStreamer
def initialize(object)
@object = object
end
def each(&blk)
yield '{'
@object.each_with_index do |key_value, i|
key, value = key_value
yield %("#{key}":)
if value.respond_to?(:call)
value.call do |v|
yield v.to_s
end
else
... | true |
c4eb621da21cb5e422691185e671819d6d40efb8 | Ruby | pawan9489/TeachingRuby | /DemoCode/Session3/4.Functions/4.Yield.rb | UTF-8 | 2,081 | 4.46875 | 4 | [
"Unlicense"
] | permissive | =begin
Yield
- Used inside a Method body
- A keyword that transfer the control from method to the block that is
attached to the method call.
- When ever ruby sees the Yield Keyword it stops and executes the block
=end
def pass_control
puts "I'm inside of pass_control metho... | true |
caa29eb16601f20e8c43dab9315d94439df38e5c | Ruby | tjinjin/sekisho | /lib/sekisho/create.rb | UTF-8 | 1,626 | 2.78125 | 3 | [
"MIT"
] | permissive | module Sekisho
class Create < Base
attr_reader :github
def initialize(options)
super(options)
end
def get_next_week(day, base_wday)
if day.wday < base_wday
day.next_day(base_wday - day.wday)
elsif day.wday == base_wday
day
else
day.next_day(7 - (day.wd... | true |
21b531aa3508b4776087c3253a6bbb71c822a3b8 | Ruby | jfdoyle3/HackerRank | /ruby/30-days/Day05_Loops.rb | UTF-8 | 171 | 2.796875 | 3 | [] | no_license | #!/bin/ruby
require 'json'
require 'stringio'
n = gets.strip.to_i
for number in 1..10 do
product=n*number
puts n.to_s+" x "+number.to_s+" = "+product.to_s
end | true |
0985589b9cd115f248fbecb5eed67e484eaf1338 | Ruby | flannerychristopher/petercooper_beginningruby | /ch03/stringinterpolation.rb | UTF-8 | 355 | 4.28125 | 4 | [] | no_license | x = 10
y = 20
puts "#{x} + #{y} = #{x + y}"
#10 + 20 = 30
puts "100 * 5 = #{100 * 5}"
#100 * 5 = 500
puts "#{x} + #{y} = #{x + y}"
x = "cat"
puts "The #{x} in the hat"
#The cat in the hat
puts "It's a #{"bad " * 5}world"
#It's a bad bad bad bad bad world
x = 10
y = 20
puts x.to_s + " + " + y.to_s + " = " + (x + y).... | true |
afba1c0621207a225c9da34e82b4488718dd8a91 | Ruby | dhalverson/futbol | /test/game_stats_test.rb | UTF-8 | 1,740 | 2.984375 | 3 | [] | no_license | require './test/helper_test'
require './lib/game'
require './lib/game_collection'
require './lib/game_stats'
class GameStatsTest < Minitest::Test
def setup
@games_collection = GameCollection.new("./test/fixtures/games_truncated.csv")
@game_stats = GameStats.new(@games_collection)
end
def test_it_exists... | true |
857465a2cdfd29383e4c3aa6985980319e51f486 | Ruby | bjepson42/todo-ruby-basics-dc-web-091718 | /lib/ruby_basics.rb | UTF-8 | 332 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
num3 = num1/num2
num3
end
def assign_variable(value)
value
end
def argue(foo)
foo
end
def greeting(greeting,name)
end
def return_a_value
foo = "Nice"
foo
end
def last_evaluated_value
foo = "expert"
foo
end
def pizza_party(topping = "cheese")
foo = toppin... | true |
60e95dd12684b093d117dcef0b395f17ac26a834 | Ruby | omikron15/Day_10_Homework | /specs/bar_spec.rb | UTF-8 | 2,688 | 3.390625 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../bar.rb")
require_relative("../guest.rb")
require_relative("../drink.rb")
require_relative("../food.rb")
require_relative("../song.rb")
class BarTest < MiniTest::Test
def setup
@bar = Bar.new("The White Horse", 100)
@song1 = Song.new("N... | true |
621e127a95a053829555179217b5c35620c6af68 | Ruby | smeyyeac/Ruby-basic-examples | /usalma.rb | UTF-8 | 1,337 | 3.75 | 4 | [] | no_license | def tekrar
puts "devam etmek icin e ye cıkmak icin h ye basiniz"
devamdurum=gets.chomp
if devamdurum=="e"
islem
elsif devamdurum=="h"
exit 1
else
puts "hatali giris yaptiniz"
tekrar
end
end
def kareAlma(istek)
sonuc=istek*istek
puts sonuc
tekrar
end
def kupAlma(ist... | true |
5617f52a07ea191c105b74c95cb8e9e598c1c4b0 | Ruby | lyntco/wdi_melb_homework | /gumballs/regina_rauch/w2d2/stock_app/app.rb | UTF-8 | 759 | 2.640625 | 3 | [] | no_license |
require 'pry'
require 'sinatra'
require 'sinatra/reloader'
require 'yahoofinance'
get '/' do
stock_ticker = params[:stock_ticker]
if @stock_ticker && !@stock_ticker.empty?
@stock_ticker = @stock_ticker.upcase
@results = YahooFinance::get_quotes(YahooFinance::StandardQuote, @stock_ticker)
@last_trade = ... | true |
5abbbef299d1394f9ca597aa4a31b143943b1043 | Ruby | kojima-r/WebAnnotationToolForBirds | /work/clustering_mel10/bic_sort.rb | UTF-8 | 113 | 2.734375 | 3 | [] | no_license | arr=[]
while line=gets
str=line.strip.split(",")[0]
arr<<[str.to_i,line]
end
arr.sort.each{|el|
puts el[1]
}
| true |
a8b8f88cbc906205250e0aedce9398b93ea4d12b | Ruby | Merna-Khalid/ruby-lecture-reading-error-messages-bootcamp-prep-000 | /lib/a_type_error.rb | UTF-8 | 45 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | 1 + 1
String(1) + "is the loneliest number"
| true |
0c7e0d42093ab30fe73695f46f3cab291bedaaa0 | Ruby | thoni56/cyber-dojo | /app/docker/cyber-dojo.rb | UTF-8 | 6,463 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
def me; 'cyber-dojo'; end
def my_dir; File.expand_path(File.dirname(__FILE__)); end
def docker_hub_username; 'cyberdojofoundation'; end
def docker_version; ENV['DOCKER_VERSION']; end
def home; '/usr/src/cyber-dojo'; end # home folder *inside* the server image
# - - - - - - - - - - - - - - - -... | true |
214ab8bcdb03a2f5aafcad69fc48a6abc8fdd763 | Ruby | barttenbrinke/browser-prof | /lib/ruby-prof/graph_html_printer_enhanced.rb | UTF-8 | 3,740 | 3.046875 | 3 | [
"MIT"
] | permissive | # This is a modified version from the rubyprof project rubyprof.rubyforge.org
require 'ruby-prof/abstract_printer'
require "erb"
module RubyProf
# Generates graph[link:files/examples/graph_html.html] profile reports as html.
# To use the grap html printer:
#
# result = RubyProf.profile do
# [code... | true |
1f977dd7abc7c374a44b1a368d1adb23c1dd238f | Ruby | rubycoder/vt100 | /lib/vt100/erase.rb | UTF-8 | 558 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Vt100
module Erase
def erase_line_esc(attr)
"\x1B[#{attr}K"
end
def erase_screen_esc(attr)
"\x1B[#{attr}J"
end
def erase_end_of_line
print erase_line_esc ""
end
def erase_start_of_line
print erase_line_esc 1
end
d... | true |
fcb114fa78c761f45c995a57b4d3461e0b0101ef | Ruby | theHmpf/caesar-cipher | /ceasar_cipher.rb | UTF-8 | 1,375 | 3.9375 | 4 | [] | no_license | def caesar_cipher uncoded_string, shift_right
# Check if the string is valid
if uncoded_string.length <= 0
puts "Please enter a string"
return nil
else
# Variable to push the encoded string in
encoded_string = ""
# Array with all chars
alphabet_chars = ("a".."z").to_a
# Begin encoding... | true |
97ad63311e76503fe9f278768c27b990947a971f | Ruby | gomezhyuuga/RUPI | /models/models.rb | UTF-8 | 4,146 | 2.53125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
class Registro
include DataMapper::Resource
# set all String properties to have a default length of 255
DataMapper::Property::String.length(255)
# set the storage name for the :legacy repository
storage_names[:default] = "Registro"
# properties from teacher's ER-diagram
property :id, S... | true |
d2bfccb273b17e21ffdb37735faa7a0555a5ba07 | Ruby | JAdshead/checkout_promotions | /spec/utils_spec.rb | UTF-8 | 576 | 3.046875 | 3 | [] | no_license | require 'spec_helper'
require 'utils'
describe 'utils' do
describe ".price_to_pence" do
it { expect( Utils.price_to_pence "£10.00" ).to eq(1000) }
it { expect( Utils.price_to_pence "£11" ).to eq(1100) }
it { expect( Utils.price_to_pence "42" ).to eq(42) }
it { expect( Utils.price_to_pence 14 ).to ... | true |
112373eb1db1707623d0f6136ac1e8f08a73725e | Ruby | 1self/1self-rescueTime | /lib/util.rb | UTF-8 | 175 | 2.90625 | 3 | [] | no_license | module Util
extend self
def hours_to_milli_seconds(hours)
hours * 60 * 60 * 1000 rescue 0
end
def hours_to_seconds(hours)
hours * 60 * 60 rescue 0
end
end
| true |
f4e9db56c7bbc3bea69aed91012552becd467b49 | Ruby | josegonzalez/ruby-cimino | /_plugins/filters/extended_filters.rb | UTF-8 | 4,220 | 2.796875 | 3 | [
"MIT"
] | permissive | # Title: ExtendedFilters
# Description: Some extra filters for liquid
require 'hpricot'
require 'nokogiri'
require 'multi_json'
module Liquid
module ExtendedFilters
def tokenize(input, second)
stop_words = [
"a", "about", "above", "after", "again", "against", "all", "am", "an",
"and", "any... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.