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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c94f883a2051ea050b2eda2bf8e462e7823f48f7 | Ruby | spruceboy/Spruceboy-s-Data-Processing-Scripts | /wms/add_overviews_threaded.rb | UTF-8 | 872 | 2.890625 | 3 | [] | no_license | require "rubygems"
require "yaml"
require "pp"
tasks = []
ARGV.each do |x|
task = []
task.push("gdaladdo -r average #{x} 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192")
tasks.push(task)
end
threads = []
1.upto(8) do
threads << Thread.new do
loop do
todo = tasks.... | true |
e7dfa8510640e28a5f080cdc56cc6730a382c5e5 | Ruby | MigueRobles/NAPAKALAKI-Practicas-PDOO | /Napakalaki Ruby/lib/death_bad_consequence.rb | UTF-8 | 650 | 3.015625 | 3 | [] | no_license | # To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
require_relative 'numeric_bad_consequence'
require_relative 'player'
module NapakalakiGame
class DeathBadConsequence < NumericBadConsequence
... | true |
e6097bd276d686b24da0cd38c2fab4ff359f404c | Ruby | josefzacek/lynda-rspec | /Chapter09/09_04/car_project/spec/car_spec.rb | UTF-8 | 1,126 | 3.09375 | 3 | [] | no_license | require 'car'
require 'shared_examples/a_standard_vehicle'
describe Car do
it_behaves_like('a standard vehicle')
it "allows reading and writing for :doors" do
subject.doors = 1
expect(subject.doors).to eq(1)
end
describe '#initialize' do
it "defaults to 4 doors" do
expect(subject.doors).... | true |
5ffb4192b2f60d950617dbd091ff28f32988d78e | Ruby | JEG2/icfp_2013 | /bin/guess_answer | UTF-8 | 344 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "../lib/sherlock"
require "json"
unless (id = ARGV.shift) &&
(program = ARGV.shift)
abort "Usage: #{$PROGRAM_NAME} ID PROGRAM"
end
result, response = Sherlock::API.new.guess(id, program)
if result == :success
puts JSON.pretty_generate(response)
else
puts resul... | true |
249c18330cd27d52f3e567d2df5d1143b5b6b526 | Ruby | matteomelani/school-circle | /lib/has_avatar.rb | UTF-8 | 1,956 | 2.546875 | 3 | [] | no_license | require 'active_record'
# For a class to have an avatar you need to:
# - include HasAvatar
# - call has_avatar
# - in the controller CREATE add after the save method is successful: Zfile.set_attachable(params[:avatar_id], @family) if params[:avatar_id]
# - in the controller UPDATE add after the update_attributes i... | true |
0f68712dbe291a3507a81924a794d46b5f6abcf9 | Ruby | David-Roark/code_practice | /exercism/pangram/pangram.rb | UTF-8 | 97 | 2.828125 | 3 | [] | no_license | class Pangram
def self.pangram?(str)
str.downcase.scan(/[a-z]/).uniq.size == 26
end
end
| true |
ef1049231dcb0fbc2f547967fe956029c00160f3 | Ruby | monkeygq/ruby_demo | /data_structures_and_algorithm_analysis/permutation2.rb | UTF-8 | 1,076 | 3.5625 | 4 | [] | no_license | def permutation(num)
str = init(num)
p str
arrow = Hash.new(0) # 0 is left, 1 is right
while(index_arr = find_and_change_arrow(str, num, arrow))
str = change(str, index_arr)
p str
end
end
def init(num)
(1..num).inject("") { |str, n| str << n.to_s }
end
def find_and_change_arrow(str, num, arrow)
... | true |
6004c648fc122d6e8c60c20ca2f570a9576165e5 | Ruby | yhshin0/python_ruby | /13. Module/ruby3.rb | UTF-8 | 1,535 | 3.828125 | 4 | [] | no_license | ### python์์์ ๋ชจ๋์ ํ์ผ๋ก ๋ถ๋ฆฌ๋์ด์ผ ํ์ง๋ง
### ruby์์์ module์ ํ์ผ๋ก ๋ถ๋ฆฌ๋ ์๋ ์๊ณ
### ๊ทธ๋ ์ง ์์ ์๋ ์์.
### ์ฐ์ ๋ชจ๋์ ๋ง๋ค๊ธฐ ์ํด์ module์ด๋ผ๋ ํค์๋๋ฅผ ์ฌ์ฉ.
module Egoing
### module_function() : ๋ชจ๋์์ ํจ์๋ค์ ์ฌ์ฉํ ์ ์๋๋ก ํ๋ ๋ช
๋ น์ด.
### ๊ถ์ฅํ์ง ์์ผ๋ ๋์ค์ ์๋ฆฌ๋ฅผ ์๊ธฐ ์ ๊น์ง๋ ์ฌ์ฉํ ๊ฒ.
module_function()
def a
return 'Egoing a'
end
end
puts(Egoing.a()) # Egoing a
mo... | true |
2402f48207f7146c078b4cab1502b00a8ccae597 | Ruby | mygulamali/secret_bambino | /lib/secret_bambino/renderer.rb | UTF-8 | 651 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'ostruct'
module SecretBambino
class Renderer
TEMPLATES_PATH = "../../../templates"
def render(var_hash, html=false)
template = html ? html_template : plain_template
variables = OpenStruct.new(var_hash)
ERB.new(template).result(variables.instance_eval { binding })
... | true |
c62a6338df07c0996921f2b880b8b648c53af3dc | Ruby | franccesco/dmp | /lib/dmp/cli.rb | UTF-8 | 3,089 | 3.265625 | 3 | [
"MIT"
] | permissive | require 'thor'
require 'dmp'
require 'colorize'
require 'clipboard'
module Dmp
# Command line interface for DMP
class CLI < Thor
default_task :gen_pass
# Define option 'gen' that accepts a flag to copy to clipboard ('-c')
# and another one to check the generated password agains HIBP ('-H')
# This ... | true |
90920158c666811c1bc91785c21d62cbf4cab42c | Ruby | zwarburg/exercism | /ruby/!DONE/leap/leap.rb | UTF-8 | 103 | 3.21875 | 3 | [] | no_license |
class Year
def self.leap?(year)
return year%4 == 0 && (year%100!=0 || year%400 == 0 )
end
end
| true |
eba50839f3d5492c46196efa74f04311db88a017 | Ruby | bergscott/learn_ruby | /08_book_titles/book.rb | UTF-8 | 454 | 3.328125 | 3 | [] | no_license | class Book
attr_reader :title
@@conj = ['and','or','but','nor','for','so','yet']
@@preps = ['of','to','in','as','at','by']
@@articles = ['a','an','the']
@@nocaps = @@conj + @@preps + @@articles
def title=(str)
words = str.downcase.split
title_words = [words[0].capitalize]
words[1..-1].each do... | true |
fd5db69664650798c2db224246aab46bcce9a6f3 | Ruby | malkaviano/Interpreter | /lib/expressions.rb | UTF-8 | 2,106 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'forwardable'
module Malk
class Operator
def initialize(args)
args.size.times {|i| instance_variable_set("@arg#{i + 1}", args[i])}
end
end
class UnaryOperator < Operator
def self.arguments
1
end
private
def evaluate(op)
instance_eval("#{op}@arg1.interpret")... | true |
81c972b8e572748fd43a404e1dcd439ef95af41d | Ruby | shelbyd/ruby-genes | /main.rb | UTF-8 | 1,256 | 3.421875 | 3 | [] | no_license | class Random
def next
rand
end
end
class GeneticAlgorithm
def initialize(&block)
instance_eval &block
end
def generate(&block)
if block_given?
@generate = block
else
@generate
end
end
def fitness(&block)
if block_given?
@fitness = block
else
@fitness
... | true |
42e775267a0b3731228d06aaa8908be0634008b1 | Ruby | ronaldtse/asciidoctor-bibliography | /lib/asciidoctor-bibliography/citation_item.rb | UTF-8 | 899 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'asciidoctor/attribute_list'
module AsciidoctorBibliography
class CitationItem
attr_accessor :key, :target, :positional_attributes, :named_attributes, :locators
def initialize
yield self if block_given?
end
def locators
Helpers
.slice(named_attributes || {}, *CiteProc::C... | true |
c3b801b59032158948df7096b6af2feb49cc2749 | Ruby | ipahenderson/solo_project_greazy | /models/deal.rb | UTF-8 | 2,442 | 3.234375 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Deal
attr_reader(:id, :name, :discount, :day, :eatery_id, :burger_id)
def initialize( options )
@id = options['id'].to_i if options['id']
@name = options['name']
@discount = options['discount'].to_f
@day = options['day']
@eatery_id = options['eatery_... | true |
d8c8cde9d8ec7e65c840c831dfb5a96d61f7f4f5 | Ruby | huangpuxiang/programming-exercise | /18-square.rb | UTF-8 | 243 | 3.4375 | 3 | [] | no_license | # ๅปบๆไธไธช้ตๅๆไธ็พไธช็ๅ
็ด ๏ผๅ
ๅฎนๆฏ 0, 1, 4, 9, 16, 25...... ๆฏไธชๅ
็ด ๆฏ่ฏฅ็ดขๅผ็ๅนณๆน
arr = []
print "่ฏท่พๅ
ฅๆฐๅญ N๏ผ็ถๅๆ Enter: "
n = gets
m = (n.to_i)-1
for i in 0..m
arr[i] = i*i
end
puts arr.to_s
| true |
19edc52103f91f261dd17343528484ef36d8f3da | Ruby | kocsenc/project-euler | /src/p9.rb | UTF-8 | 1,153 | 3.859375 | 4 | [] | no_license | #!/usr/bin/env ruby
# Kocsen Chung
# Project euler # 9
#A Pythagorean triplet is a set of three natural numbers, a b c, for which,
#a^2 + b^2 = c^2
#For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.
#There exists exactly one Pythagorean triplet for which a + b + c = 1000.
#Find the product abc.
#include 'Math'
def main(... | true |
dd834a837dbc9a706732f1a2eed7a4e9db06214b | Ruby | tanaken0515/ruby-examination | /gold/challenge01/ex25/sample04.rb | UTF-8 | 74 | 2.9375 | 3 | [] | no_license | v1 = 1 / 2 == 0
v2 = !!v1 or raise RuntimeError
v3 = v2 and false
puts v3
| true |
c4a62a63f577e602a6fb6dbc0529e3cbce9492d0 | Ruby | acslocum/pong | /gosu_helloworld.rb | UTF-8 | 1,118 | 2.9375 | 3 | [] | no_license | require 'rubygems' # only necessary in Ruby 1.8
require 'gosu'
require 'paddle'
require 'ball'
class MyWindow < Gosu::Window
def initialize
super(640, 480, false)
self.caption = 'PONG!'
@paddle1 = Paddle.new(20,50, Gosu::KbA, Gosu::KbZ, :left, self)
@paddle2 = Paddle.new(580,50, Gosu::KbK, Gosu::KbM, :ri... | true |
a27a0e75f07bc598f9553cac3d43a91287d0e746 | Ruby | halogenandtoast/tagged | /test/delimiter_test.rb | UTF-8 | 519 | 2.875 | 3 | [] | no_license | require 'test_helper'
class Bar
include Tagged::Base
end
class TaggingTest < Test::Unit::TestCase
context "A tagged instance with a custom delimiter" do
setup do
Bar.delimiter = '|'
@bar = Bar.new
@bar.tag('hoge|fuga|piyo')
end
should "respond with the correct tags" do
ass... | true |
15bd9ce0d5d245fb44aab58277cef34122ab7402 | Ruby | achl93/math-game | /app/main.rb | UTF-8 | 158 | 2.515625 | 3 | [] | no_license | require './player.rb'
require './question.rb'
require './turn.rb'
require './game.rb'
class Main
game = Game.new
game.startGame
puts 'Game over!'
end | true |
547395d2cdba2dbcfeb445139215ed8cdf769960 | Ruby | KasiaCat/Ruby | /ruby/tabs.rb | UTF-8 | 156 | 3.609375 | 4 | [] | no_license | array = [1,2,3,4,5]
array.each do |x| #each { |x| }
x += 10
print "#{x}"
end
------
odds = [1,3,5,7,9]
odds.each do |elem|
print elem * 2
end
| true |
aa2e71a14303038ee730ec03ed0b5d0383325563 | Ruby | OwenKLenz/ruby_challenges | /medium1/nth_prime.rb | UTF-8 | 2,489 | 4.3125 | 4 | [] | no_license | # Input: Integer (the nth prime we want)
# Output: Integer, the value of the prime
# Data Structure:
# Integers for input and Output
# An integer to track the current prime
# Considerations:
# Start at 2 (first prime)
# Primes can only be odd (after 2) so ignore evens
# Only checking divisibleness of numbe... | true |
22463e2eb89d04847457eacb6335fd2f5f98d198 | Ruby | Mozl/chitter-challenge | /spec/web_helpers.rb | UTF-8 | 690 | 2.53125 | 3 | [] | no_license | require 'pg'
def fill_data
connection = PG.connect(dbname: 'chitter_test')
# Add the test data
connection.exec("INSERT INTO peep (peep, name, handle) VALUES('what up', 'Zuckerberg' , '@zuckyboi');")
connection.exec("INSERT INTO peep (peep, name, handle) VALUES('Louis is so awesome', 'Daniel Tooke' , '@t00kie_... | true |
f0c354f0e96e610326202b76ea028f1affc160e7 | Ruby | jaffamonkey/Ruby_Automation | /helpers/helpers.rb | UTF-8 | 342 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | # Some information here
module EventuallyHelper
module_function
def eventually(timeout: 10, interval: 2, &block)
time_limit = Time.now + timeout
begin
yield
rescue Exception => error
raise error if Time.now >= time_limit
# waiting when object will appear
sleep interval
re... | true |
be374d6140fd7ca582556b41aa547c66cbe13e0f | Ruby | crest-cassia/oacis_nsga_module | /zdt4/target_zdt4.rb | UTF-8 | 294 | 2.671875 | 3 | [
"MIT"
] | permissive | require_relative '../target'
class ZDT4 < Target
# average
def fitness(ps)
tmp = {}
ps.runs.each{|r|
@objectives.each{|k|
tmp[k] ||= []
tmp[k] << r.result[k]
}
}
fitness = @objectives.map{|k| tmp[k].inject(:+)/tmp[k].size.to_f }
end
end
| true |
250a8e6d58b9cd96bd3628f3b288f696f1cd5ecd | Ruby | wongmichael/tic-tac-toe-rb-bootcamp-prep-000 | /lib/tic_tac_toe.rb | UTF-8 | 1,744 | 3.953125 | 4 | [] | no_license | WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[6,4,2]
]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{b... | true |
0789a7eb4f9c3119789ab690b6f1aea8517d2bf7 | Ruby | HowieDL/learn_to_program | /ch06-more-about-methods/angry_boss.rb | UTF-8 | 137 | 2.875 | 3 | [] | no_license | puts "WHADDAYA WANT! I'M A BUSY MAN SO MAKE IT QUICK!"
reply = gets.chomp.upcase
puts "WHADDAYA MEAN \"" + reply + "?!?\" YOU'RE FIRED!!" | true |
2503b6d436ed19c0ec1341ee460684bade2e4725 | Ruby | cadyherron/assignment_self_associations | /db/seeds.rb | UTF-8 | 1,195 | 2.71875 | 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 |
d2e57a7d5cef660b7949e4a047a2c44198aa50d4 | Ruby | spatchcock/vector_geometry | /spec/exercises_spec.rb | UTF-8 | 5,298 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
# require 'geometry'
include Geometry
describe Vector do
context "30 degrees and magnitude 2" do
before do
@angle = 30 # degrees
@magnitude = 2
@vector = Vector.from_polar(@magnitude, @angle, :unit => :deg)
end
it "should calculate the x component" do
@... | true |
89829f1e18a81b2e34278b1cc4ba1ad438412f3f | Ruby | scootcho/the_odin_project | /ruby/learn_ruby/06_performance_monitor/performance_monitor.rb | UTF-8 | 106 | 2.90625 | 3 | [] | no_license | def measure(n=1)
time_start = Time.now
n.times {yield}
stop = Time.now - time_start
stop / n
end
| true |
fd9aaee0a08becef4baefa2690629aa0f6d8b22f | Ruby | aksharma/imdb_reader | /app/models/fetch.rb | UTF-8 | 593 | 2.578125 | 3 | [] | no_license | module Fetch
def search(s,page)
url = url_for_search(s,page)
arr = JSON.parse(get_data(url).body)['Search']
merge_actors(arr)
end
private
def url_for_search(s,page)
"http://www.omdbapi.com/?y=&plot=short&r=json&s=#{s}&page=#{page}"
end
def url_for_id(id)
"http://www.omdbapi.com/?plot=... | true |
759f73e4c57d06fa922453da07ac46cf139c4f16 | Ruby | arashrestha/Codewars-Challenges | /rmduplicates.rb | UTF-8 | 155 | 3.515625 | 4 | [] | no_license | def unique(integers)
response = Array.new
integers.each do |number|
response << number unless response.include?(number)
end
return response
end | true |
843f9b7214de0a4c12bca7afd9450d7211d9ab93 | Ruby | nkalinos/gCamp-Nick-Kalinoski | /app/models/project.rb | UTF-8 | 409 | 2.53125 | 3 | [] | no_license | class Project < ActiveRecord::Base
validates :name, presence: true
has_many :tasks, dependent: :destroy
has_many :memberships, dependent: :destroy
has_many :users, through: :memberships
def owner_count
owners_found = 0
self.memberships.each do |membership|
p membership.role
if membershi... | true |
6e914c3cd0344a5a4ccfdb4e5aa938a17c68d218 | Ruby | huberb/eulerproblems | /euler50/euler50.rb | UTF-8 | 865 | 3.546875 | 4 | [] | no_license | require('prime')
class Euler50
attr_accessor :primes, :memory, :prime_count, :max_key
def initialize()
puts "generating.."
self.prime_count = 1_000_000
self.primes = prime_count.times.select { |p| Prime.prime?(p) }
puts "done.."
find_consecutive()
end
def find_consecutive()
rows = sel... | true |
bb5d30e57ba901b6028088cb4cab502b096d8052 | Ruby | matuba/tdd_example | /money.rb | UTF-8 | 787 | 3.640625 | 4 | [] | no_license | # coding: utf-8
require './expression'
class Money < Expression
attr_reader :amount
attr_reader :currency
def initialize(amount, currency)
@amount = amount
@currency = currency
end
def Money.dollar(amount)
return Money.new(amount, "USD")
end
def Money.franc(amount)
return Money.new(amo... | true |
b902943d22baf913ddd5e0f80b09f6a9ba05df19 | Ruby | cmaher92/launch_school | /coursework/books/intro_to_programming/basics/exercise_6.rb | UTF-8 | 531 | 4.3125 | 4 | [] | no_license | # Exercise 6
# Ruby Basics
# Write a program that calculates the squares of 3 float numbers of your choosing and outputs the result to the screen
numbers = []
puts "please choose a number"
number = gets.chomp
numbers << number.to_f
puts "please choose another number"
number = gets.chomp
numbers << number.to_f
puts "pl... | true |
9467dd7a32de648e808a9f9a15686f5f849a09a2 | Ruby | GKnirps/stublog | /app/models/quote_to_fortune.rb | UTF-8 | 1,576 | 2.6875 | 3 | [
"MIT"
] | permissive | #Class that makes a fortune databank out of the published quotes of the day
class QuoteToFortune
#make a fortune db file string out of the published quotes
def quotelist()
@quotelist ||=QuoteOfTheDay.published.map{|q| Sanitize.fragment(q.content).strip}.join "\n%\n"
end
#return file path to the .tar.gz fortune... | true |
3baecbd1e5cc69dea80f51d5e444816383f26b0d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/phone-number/1e1be33e544d4397b6c32fa08020a06a.rb | UTF-8 | 740 | 3.34375 | 3 | [] | no_license | class PhoneNumber
ERROR = "0000000000"
def initialize(string)
@string = string
@digits_only = string.gsub(/[^0-9a-z]/i, '')
end
attr_reader :string
def number
return ERROR if has_letters(string) == false
return ERROR if @digits_only.length < 10 || @digits_only.length > 11
if @digits_only.... | true |
339742d326a8e80cf094463f315b65e0d8bdcae0 | Ruby | rpeina01/despegar | /Trip.rb | UTF-8 | 3,241 | 3.25 | 3 | [] | no_license | require 'colorize'
require 'open-uri'
class ColoredNumber
def initialize(number, price_ranges)
@number = number
@price_ranges = price_ranges
end
def getLowestPriceWithColor
# return lowest_price.formatWithPoints if @price_ranges.nil?
# output = lowest_price.formatWithPoi... | true |
48c2dc7e90710f368cb3e5264ec9766eaa8d2f53 | Ruby | priteshrnandgaonkar/rubyBasics | /modules.rb | UTF-8 | 1,318 | 3.515625 | 4 | [] | no_license | # Modules
# => As namespaces
# => As mixins
# Using built in Ruby modules, especially Enumerable
# "require_relative"
# Modules are container for classes, methods and constants
# Or other modules
# Like a Class, but cannot be instantiated
# "Class" inherits from "Module" and adds "new"
module Sports
class Match
at... | true |
e62fe3f66d29fc58839e1804196076c346e81e32 | Ruby | passabilities/paperclip-watermark | /lib/paperclip-watermark/watermark.rb | UTF-8 | 1,661 | 2.5625 | 3 | [
"MIT"
] | permissive | # from http://github.com/ng/paperclip-watermarking-app
# with modifications from http://exviva.posterous.com/watermarking-images-with-rails-3-and-papercli
# and even more modifications to ensure works with paperclip >= 2.3.8 and rails >= 3
#
# Note: In rails 3 paperclip processors are not automatically loaded.
# You mu... | true |
0830ef871cd6940787cabcb337ff686ff27cf678 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/filtered-submissions/e8cd681920f34b419a2863f64f047b12.rb | UTF-8 | 278 | 3.109375 | 3 | [] | no_license | def compute(first, second)
String.try_convert(first)
String.try_convert(second)
count=0
first.each_char do |i|
if i!=second[0]
count=count+1
end
second = second[1..-1]
end
return count
end | true |
9fa7e78beb5184e26240eca5bd141b91a033ad27 | Ruby | mleue/project_euler | /problem_0045/ruby/0045.rb | UTF-8 | 768 | 3.453125 | 3 | [] | no_license | class Integer
def is_pentagonal_number?
base = (1+Math.sqrt(1+24*self))/6
return base.is_int?
end
def is_triangle_number?
base = (-1+Math.sqrt(1+8*self))/2
return base.is_int?
end
def is_hexagonal_number?
base = (1+Math.sqrt(1+8*self))/4
return base.is_int?
end
def triangle_number
return (self*(... | true |
0b8f84a5e53f601457fb602fa99bbda2fafe7e34 | Ruby | jazzlynpulley/csci305-ruby-lab | /ruby_lab.rb | UTF-8 | 3,284 | 3.84375 | 4 | [
"MIT"
] | permissive |
#!/usr/bin/ruby
###############################################################
#
# CSCI 305 - Ruby Programming Lab
#
# Jazzlyn Pulley
# jazzlyn406@gmail.com
#
###############################################################
$bigrams = Hash.new(0) # The Bigram data structure
$name = "Jazzlyn Pulley"
# function to pro... | true |
65fd11e2cb85cc8ae1fd75dc6657e85d85fcf5d5 | Ruby | adventcoder/adventofcode-2020 | /07_handy_haversacks.rb | UTF-8 | 695 | 3.46875 | 3 | [] | no_license | require_relative 'common.rb'
input = get_input(7)
$contents = Hash.new { |h, k| h[k] = [] }
input.each_line do |line|
words = line.delete('.,').split
words.delete_if { |word| word == 'contain' or word =~ /^bags?$/ }
next if words.last(2) == ['no', 'other']
bag = words.take(2).join(' ')
words.drop(2).each_sl... | true |
e6de7ca29fe8a5c771af9795b89e3c9d5b7e6f18 | Ruby | Honza0297/IFJ | /testy/testiky/funkcni/20.rb | UTF-8 | 173 | 3.046875 | 3 | [] | no_license | a = substr("ahoj", 0, 2)
print a
if 0 < 10 then
print("dobry den;;;")
else
print("jedem ti domu")
end
def funkce(m, n)
m = 2 * n
if m != n then
chr(m)
else
end
end | true |
eb7fd44480814d6e975fb082f9d39f96953ef579 | Ruby | dmitrym0/semi_heap_sort | /src/semi_heap_sort.rb | UTF-8 | 2,908 | 3.3125 | 3 | [
"MIT"
] | permissive | class SemiHeapSort
def self.check_tournament(t)
t.each_with_index(:upper) do |e, row, col|
raise "#{row}, #{col} must be 1, 0 or nil and is #{e}" unless [0, 1, nil].include? e
if row == col
raise "#{row}, #{col} ought to be nil" unless e.nil?
else
... | true |
10d7f2309fe9aa628b9af9a11dd17d7edc23ac10 | Ruby | duykhoa/tdd-pair | /lib/listing.rb | UTF-8 | 136 | 2.796875 | 3 | [] | no_license | class Listing
attr_reader :array
def initialize(array:)
@array = array
end
def build
array.permutation.to_a
end
end
| true |
dfdadd3783c90465761c46f9a6eadd3718c48bc6 | Ruby | andrewdmoore408/LS-RB130-More-Ruby-Topics | /lesson_2/todo_list.rb | UTF-8 | 2,735 | 3.859375 | 4 | [] | no_license | class Todo
DONE_MARKER = 'X'
UNDONE_MARKER = ' '
attr_accessor :title, :description, :done
def initialize(title, description='')
@title = title
@description = description
@done = false
end
def done!
self.done = true
end
def done?
done
end
def undone!
self.done = false
... | true |
59eeda6cb853d3c96ec99a36297672c5bd47a5d0 | Ruby | portugol/decode | /Algoritmos Traduzidos/Ruby/Algoritmos_Hugo/38.rb | UTF-8 | 147 | 3.59375 | 4 | [] | no_license | #Ler um nรบmero real e imprimir a terรงa parte deste nรบmero
puts "Introduza um numero real (X.X):"
num1 = gets
num1 = num1.to_f / 3
puts "#{num1}" | true |
ce88d1f90f7dce9c14f7c13e8c7803696aaeb160 | Ruby | UncleMussels/Launch-School | /Exercises/101-109 - Small Problems/Easy 7/swapcase.rb | UTF-8 | 654 | 4.3125 | 4 | [] | no_license | # Write a method that takes a string as an argument and returns a new string
# in which every uppercase letter is replaced by its lowercase version, and
# every lowercase letter by its uppercase version. All other characters should
# be unchanged.
# You may not use String#swapcase; write your own version of this me... | true |
eb91d828651e37beb713edd6654d4f38f66bc578 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/space-age/349b45e03ce241a3b54d03d881daea05.rb | UTF-8 | 656 | 3.640625 | 4 | [] | no_license | class SpaceAge
EARTH_YEAR = 31_557_600
PLANET_YEAR_FACTOR = {
earth: 1,
mercury: 0.2408467,
venus: 0.61519726,
mars: 1.8808158,
jupiter: 11.862615,
saturn: 29.447498,
uranus: 84.016846,
neptune: 164.79132
}
attr_reader :seconds
def initialize(seconds)
@seconds = seconds
... | true |
126a07c37a19169ddceff544f83e4f0ec2ae9985 | Ruby | fazaton/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 363 | 3.609375 | 4 | [] | no_license | #write your code here
def echo(a)
return a
end
def shout(a)
return a.upcase
end
def repeat(a, b=0)
k = []
if b == 0
return a + ' ' + a
else
return ((a + ' ') * b).chop
end
end
def start_of_word(a, b=1)
return a.slice(0, b)
end
def first_word(a)
return (a.split)[0]
end
def titleize(a)
#(a.slice(0, a.le... | true |
79f24b897bfb6692f327d205abec234cc28c9736 | Ruby | MarkBWilliams11/ruby_stuff | /files_serialization/file_properties.rb | UTF-8 | 1,961 | 3.125 | 3 | [] | no_license | #Fiiles existence and properties
require 'open-uri'
=begin
File ans Dir class methods that can determine various properties of
files, including size, its directory and wether or not a file with a given name
exists
=end
#Flie.exists? or directory
filename = "sample.txt"
if File.exists?(filename)
puts "#{filename} e... | true |
f7e8bb02558419411d20b60675d9b09d862a2912 | Ruby | maxjacobson/todo_lint | /lib/todo_lint/reporter.rb | UTF-8 | 2,063 | 3.421875 | 3 | [
"MIT"
] | permissive | module TodoLint
# We want to be able to report to users about the todos in their code, and
# the Reporter is responsible for passing judgment and generating output
class Reporter
# Accept a todo and a path to check for problems
# @example
# Reporter.new(todo,
# judge: Judge.new(todo))
# ... | true |
4609079468b67bdff8d75cc576fc02d74d94dd11 | Ruby | Justin-Mullins/launch_school | /101_Programming_Foundations/lesson_4/twenty_one.rb | UTF-8 | 4,429 | 4.1875 | 4 | [] | no_license | # twenty_one.rb
CARD_VALUES = { '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
'7' => 7, '8' => 8, '9' => 9, '10' => 10, 'jack' => 10,
'queen' => 10, 'king' => 10, 'ace' => 11 }
def prompt(msg)
puts "=> #{msg}"
end
def display_hands(dealer_hand, player_hand, hide_dealer_card)
s... | true |
142fd589c3673fa2e5c667ce9b6caf1270d2e972 | Ruby | rbergena/hotel | /lib/hotel.rb | UTF-8 | 2,631 | 3.765625 | 4 | [] | no_license | require_relative 'block'
require 'date'
module Hotel
class Hotel
attr_reader :rooms
def initialize
# array of rooms
@rooms = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
# array of reservations
@reservations = []
#array of blocks
@blocks = []
end
# reser... | true |
afe989184cd6497ab8aa5b143e2d593d2b3742ac | Ruby | kirstenwerner/ruby-collaborating-objects-lab-online-web-ft-021119 | /lib/mp3_importer.rb | UTF-8 | 387 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MP3Importer
attr_accessor :filename, :path
def initialize(file_path)
@path = file_path
end
def files
clean_filename = Dir["#{self.path}/**/*.mp3"]
clean_filename.map do |filename|
filename.slice!(self.path+'/')
end
clean_filename
end
def import
sel... | true |
a389e73de89ac6338df1e1b72458653ad00b6178 | Ruby | swistaczek/source2swagger | /lib/swagger_reader.rb | UTF-8 | 2,825 | 2.90625 | 3 | [
"MIT"
] | permissive |
class SwaggerReader
def analyze_file(file, comment_str)
code = {:code => [], :line_number => [], :file =>[]}
File.open(file,"r") do |f|
line_number = 1
while (line = f.gets)
v = line.strip.split(" ")
if !v.nil? && v.size > 0 && (v[0]==comment_str)
code[:code] << v[... | true |
d57a20e4ab7a8303830501208da1d27146571d68 | Ruby | lordDashh/AllSeeingEye | /modules/moderation.rb | UTF-8 | 4,025 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'securerandom'
module Modules
module Moderation
extend Discordrb::Commands::CommandContainer
# Returns a sassy message if the user doesn't have permissions to execute commands such as warn, kick, ban, etc otherwise nil.
def self.check_perms(victim, moderator, bot)
if victim.owner?
... | true |
bb36c49685d7385a536c0b12788e9fca527cee63 | Ruby | bmanandhar/App_acad_prep | /hash_tagify.rb | UTF-8 | 987 | 4.6875 | 5 | [] | no_license |
# Hashtagify
# Given a sentence string and an array of words, hashtag-ify the words (case-insensitive)
# in the original string and return the updated cool string with hashtags.
def hashtagify(sentence, tags)
#
# your code goes here
# empty array as accumulator
# split sentence into array and iterate looking... | true |
dc53a7f06e73b328e698bfe35dcb63a6c9649f3b | Ruby | Richard-Burd/front-end-portfolio-project | /back-end/app/models/storage_area.rb | UTF-8 | 3,407 | 2.96875 | 3 | [] | no_license | class StorageArea < ApplicationRecord
has_many :pallets
def total_pallet_weight
total_weight = []
self.pallets.each do |pallet|
total_weight << pallet.weight
end
total_weight.sum
end
def total_pallets
self.pallets.count
end
def total_pallet_order
self.pallets.sort_by(&:weigh... | true |
4ac7a4da875ae9cd90410c6995f8db8e5f953b87 | Ruby | spidey93/message_board | /lib/Board.rb | UTF-8 | 848 | 3.15625 | 3 | [
"MIT"
] | permissive | require ('pry')
class Board
attr_reader :id, :name
@@total_rows = 0
@@boards = {}
def initialize(attributes)
@name = attributes.fetch(:name)
@id = attributes.fetch(:id) || @@total_rows += 1
end
def self.all
@@boards.values()
end
def save
@@boards[self.id] = Board.new({:name => self.n... | true |
549361abdee8d7d896669fbd55036fe554cba088 | Ruby | SciRuby/mdarray | /test/mdarray/test_non_numeric.rb | UTF-8 | 3,766 | 2.859375 | 3 | [
"NetCDF",
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*-
##########################################################################################
# Copyright ยฉ 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
# and distribute this software and its documentation, without fee and without a signed
# licensing agreement, i... | true |
a43c746a111da538e765aa70c539e11fda94cff4 | Ruby | mizukiokumura/sql | /sql.rb | UTF-8 | 6,289 | 3.09375 | 3 | [] | no_license | # ใใผใฟใใผในใฎๆไฝ
# ใฟใผใใใซใงใฎไฝฟ็จๆนๆณใๅญฆใถ
# ใฟใผใใใซใงใฏใmysqlใจใใRDBMSใไฝฟ็จใใฆSQLใๅฎ่กใงใใใ
# MySQLใไฝฟ็จใใใซใฏใใฟใผใใใซใใใญใฐใคใณใใใ
# % cd
# % mysql -u root
# -u rootใจใใใชใใทใงใณใงใใฆใผใถใผใฏใใซใผใใใงใญใฐใคใณใใใจใใๆๅณใซใชใใ
# ใใใงใใใซใผใ(root)ใจใฏใMysqlใงๅ
ใใ็จๆใใฆใใใฆใใใฆใผใถใผใๆใใฆใใใ
# ใใฎใฆใผใถใผใฎใในใฏใผใใฏ็ฉบใง่จญๅฎใใใฆใใใฎใงใใญใฐใคใณใซใในใฏใผใใฏๅฟ
่ฆใชใใ
# sqlใฏmysql>ใฎ็ถใใใใๅ
ฅๅใใฆๅฎ่กใใงใใใ
# ใพใใSQLใฏGUIใใผใซใงใใsequel... | true |
1793ff07f585a51634380bbc673c2274be3189d5 | Ruby | jfinkhaeuser/collapsium | /lib/collapsium/prototype_match.rb | UTF-8 | 3,232 | 3.109375 | 3 | [
"MITNFA"
] | permissive | # coding: utf-8
#
# collapsium
# https://github.com/jfinkhaeuser/collapsium
#
# Copyright (c) 2016-2017 Jens Finkhaeuser and other collapsium contributors.
# All rights reserved.
#
module Collapsium
##
# Provides prototype matching for Hashes. See #prototype_match
module PrototypeMatch
# Large negative integ... | true |
08a86fe15de2146f6d9e09d0440e5933e14d0dea | Ruby | NUBIC/vivo-vl | /lib/tasks/cytoscape.rake | UTF-8 | 6,577 | 2.953125 | 3 | [] | no_license | require "#{Rails.root}/lib/tasks/vivo"
include Vivo
##
# Tasks to call the VIVO SPARQL API to get data
# which is then massaged into a format used by
# cytoscapeweb - http://cytoscapeweb.cytoscape.org/
# @see CytoscapeController
namespace :cytoscape do
desc 'Create files for for all vivo:FacultyMembers saving the ... | true |
9c5dd576f9b428e1927a4495d0e4f79d88f97b6d | Ruby | mristola/discobowling | /app/controllers/game_controller.rb | UTF-8 | 1,689 | 3.171875 | 3 | [] | no_license | class GameController < ApplicationController
def index
playerList = []
rolls = 21
currentRoll = 0
end
#Adds a player with the name given in the textbox in the view
#Also adds an array with the same name of the player plus the string "Score" to hold individual player score
def addPlayer(name)
nam... | true |
822a79ac6094a363b5206d7288b9f1d30ff0b4f7 | Ruby | lilaboc/euler_ruby | /92.rb | UTF-8 | 409 | 3.484375 | 3 | [] | no_license | require 'set'
eightynine = Set.new([89])
one = Set.new([1])
#1.upto 10000000 do |x|
10000000.downto 1 do |x|
num = x
chain = [num]
loop do
num = num.to_s.each_char.map(&:to_i).inject(0){|sum, x| sum += x ** 2}
chain << num
if one.include? num
one.merge(chain)
break
elsif eightynine.in... | true |
f84386aa2f38d36705444d089a3c8e43994a0938 | Ruby | kavunshiva/ruby-inheritance-lab-web-040317 | /bin/time_for_school | UTF-8 | 1,008 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
require_relative "../lib/user.rb"
require_relative "../lib/teacher.rb"
require_relative "../lib/student.rb"
steve = Student.new
steve.first_name = "Steve"
steve.last_name = "Jobs"
avi = Teacher.new
avi.first_name = "Avi"
avi.last_name = "Flombaum"
jim = User.new
jim.first_name = "Jimmy"
jim.last... | true |
c7efcce0dabb7d4522d3a4a2034758d1facadfa7 | Ruby | guildenstern70/rubyerails | /src/Montecarlo.rb | UTF-8 | 701 | 3.703125 | 4 | [
"MIT"
] | permissive | def montecarlo(maxloop)
pi = 0.0
i = 0
array_denominatori = Array.new
(1..maxloop).step(2) { |n|
array_denominatori.push(n)
}
onetime = true
array_denominatori.each { |denom|
addendum = 4.0 / denom
if onetime
pi += addendum
else
pi -= addendum... | true |
efcf9d3529ca03d49a6aac23e949178d9ce05302 | Ruby | randallmlough/ruby-starter-template | /spec/greeting_spec.rb | UTF-8 | 640 | 3.359375 | 3 | [] | no_license | require 'greeting'
describe 'say_hello' do
it 'say_hello should accept a string' do
expect { say_hello("james")
}.to_not raise_error
end
it 'return a sentence greeting the person' do
expect(say_hello("james")).to eq("hello, james")
end
end
describe 'say_hello_block' do
it 'say_hello_block s... | true |
6929cb38a50d078d0083c4a7a7fe032f2d870b71 | Ruby | desareca/curso67RoR_Ruby | /Ruby I/leon.rb | UTF-8 | 454 | 3.84375 | 4 | [] | no_license | require_relative 'mamifero'
class Leon < Mamifero
def volar(n=1)
@salud -= 10*n
self
end
def atacar_ciudad(n=1)
@salud -= 50*n
self
end
def comer_humanos(n=1)
@salud +=20*n
self
end
def mostrar_salud
print "Este es un leรณn: "
s... | true |
bdd99e503228755090b9938e0e45ccf9d98f1c55 | Ruby | AlexanderCode/Launch_School | /foundations/octal.rb | UTF-8 | 1,435 | 4.09375 | 4 | [] | no_license | # class Octal
# attr_reader :oct_num
# def initialize(num)
# @oct_num = num
# end
# def alpha_check
# array = []
# oct_num.chars do |num|
# if num.to_i.to_s == num
# array << false
# else
# array << true
# end
# end
# return true if array.include?(true)
# ... | true |
346b5fa19305209cdced95c8e4000d4a2f3950f1 | Ruby | tripeersyou/the_craft_central | /app/models/product.rb | UTF-8 | 3,780 | 2.796875 | 3 | [] | no_license | class Product < ApplicationRecord
require 'csv'
# Entity relationships
belongs_to :brand
has_many :delivery_products
has_many :pullout_products
has_many :ending_inventory_products
has_many :order_products
has_many :transfer_products
has_many :store_products
has_many :stores, thro... | true |
309ac8007114dbc3d0efd17fac981f1272f387fe | Ruby | season89757/cosi166-learncoding | /test/minitest/goodtest.rb | UTF-8 | 1,036 | 3 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../test_helper'
require_relative '../../lib/api/goodapi'
describe "GoodRead" do
before do
@search = GoodR.new(20,"computer science")
end
it "check if result is valid" do
check = true if @search
check.must_equal true
end
it "check the number of result... | true |
b27fe5d976fbe2e5777cd7170c9498e44eb09c7e | Ruby | shuhei555/my_help | /bin/my_help_thor | UTF-8 | 1,363 | 2.84375 | 3 | [
"GPL-1.0-or-later",
"GPL-3.0-only",
"LicenseRef-scancode-other-copyleft",
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'thor'
require 'my_help'
require 'colorize'
class MyCLI < Thor
desc('setup', 'set up the test database')
def setup(*args)
$control = MyHelp::Control.new()
end
desc "list", "list all helps, specific HELP, or item"
def list(*args)
invoke :setup
file = args[0]
item = ... | true |
362acb105b20e305106063c7c60c7a1a52b0e2f8 | Ruby | threeifbywhiskey/houston | /rb/112.rb | UTF-8 | 162 | 3.484375 | 3 | [] | no_license | def bouncy? n
c = n.to_s.chars.to_a
c != (s = c.sort) && c != s.reverse
end
b, n = 0, 0
until b / n.to_f == 0.99
n += 1
b += bouncy?(n) ? 1 : 0
end
p n
| true |
5e213ce1187a8984be02290e1253b7349483e7ff | Ruby | zouhairkhallaf/deli-counter-ruby-apply-000 | /deli_counter.rb | UTF-8 | 701 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def line (katz_deli_arr_line)
phrase = "The line is currently"
if katz_deli_arr_line == []
phrase += " empty."
else
c = 1;
phrase = phrase+ ":"
katz_deli_arr_line.each do |i|
phrase += " #{c}. #{i}"
c+=1
end
end
puts phrase
end
def take_a_number(katz_... | true |
2b5c883c2edf3e257df93ffdde40b6c63da455a1 | Ruby | im-me/CodeAdvent | /day_2/challenge_1.rb | UTF-8 | 419 | 3.875 | 4 | [] | no_license | input = File.readlines('input.txt')
two_times = 0
three_times = 0
input.each do |line|
chars = line.strip.split('')
occurs_two_times = false
occurs_three_times = false
chars.each do |c|
occurs_two_times = true if line.count(c) == 2
occurs_three_times = true if line.count(c) == 3
end
two_times +=... | true |
602c642bd299477f894f97a140112eaf3cc7212f | Ruby | Huanzo/aoc2020 | /day_02/second.rb | UTF-8 | 252 | 2.953125 | 3 | [] | no_license | input = File.readlines('./input')
a = input.map do |pwl|
matches = pwl.match /(?<start>\d+)-(?<end>\d+) (?<char>\w): (?<pw>\w+)/
matches[:pw].chars.values_at(matches[:start].to_i-1, matches[:end].to_i-1).count(matches[:char])
end
puts a.count(1)
| true |
2ff13b15bcc6e508d8141a86f267e42ca8add47f | Ruby | NotionLabs/embeds_many | /lib/embeds_many/child_collection.rb | UTF-8 | 1,271 | 2.53125 | 3 | [
"MIT"
] | permissive | module EmbedsMany
class ChildrenCollection
def new(attrs={})
record = @child_klass.new(attrs.merge(parent: @obj))
@created_instances << record
record
end
def create(attrs={})
record = @child_klass.new(attrs.merge(parent: @obj))
record.save
@created_instances << reco... | true |
ace88172f7a3498fd06e415d7ac68541af196fca | Ruby | forthowin/TealeafAcademy-Lessons | /lesson_2/OOP_book/classes_and_objects_p1/exercise_1.rb | UTF-8 | 676 | 3.703125 | 4 | [] | no_license | class MyCar
attr_accessor :color
attr_reader :year
def initialize(year, color, model)
@year = year
@color = color
@model = model
@current_speed = 0
end
def self.mileage_calc(gallons, miles)
miles/gallons
end
def speed_up(num)
@current_speed += num
end
def brake(num)
@cu... | true |
b1040c1caf7661d5597bdd4005f6db3d061bb883 | Ruby | emilyfreeman/lactation-station | /app/models/response_parser.rb | UTF-8 | 770 | 2.890625 | 3 | [] | no_license | class ResponseParser
attr_accessor :response
def initialize(response)
@response = response
end
def nursing_mothers
confirm_response(@response[:nursing_mothers]).first
end
def description
confirm_response(@response[:description]).first
end
def substance_name
confirm_response(@response... | true |
177840f57955b669657395a7bab08d6e82b2378f | Ruby | AntonFagerberg/BM-Elite-Force | /entities/enemies/end_boss.rb | UTF-8 | 2,278 | 2.734375 | 3 | [] | no_license | require 'entities/boss'
require 'entities/projectiles/enemy_fireball'
class EndBoss < Boss
def initialize(window)
@window = window
@height= 144
@width = 212
@scale = 1
@speed_x = 0
@speed_y = 1
@frames = 2
@switch_speed = 8
@angle = 0.0
@health = 99999
@score = 100
@ou... | true |
5d7a4b2e8baaff33747eb0df5e4f9caef2bea3d8 | Ruby | zluo16/school-domain-web-051517 | /lib/school.rb | UTF-8 | 473 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
def add_student(name, grade)
if @rost.keys.include?(grade)
@rost[grade] << name
else
@rost[grade] = Array.new.push(name)
end
end
def roster
@rost
end
def initialize(name)
@name = name
@rost = {}
roster
end
def name
@name
end
def grade(num)... | true |
9fd37ab6897bbc8201d1b4053bb5c8430c35c50a | Ruby | prkrsign/my_new_gear | /spec/models/user_spec.rb | UTF-8 | 5,055 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'ใฆใผใถใผๆฐ่ฆ็ป้ฒ' do
it "ๅ
จใฆใฎๅฟ
้ ้
็ฎใๅ
ฅใใๅ ดๅใใขใซใฆใณใ็ป้ฒใใงใใ" do
user = build(:user)
user.valid?
expect(user).to be_valid
end
describe 'ใฆใผใถใผๆฐ่ฆ็ป้ฒ(usernameใฎๅฆฅๅฝๆง็ขบ่ช)' do
it "usernameใ1ๆๅญใฎๅ ดๅใใขใซใฆใณใ็ป้ฒใใงใใ" do
user = build(:user,... | true |
fcefff63bb7b04427006f9b53f0a2686be14e942 | Ruby | charlotte-ruby/projecteuler | /spec/fibber_spec.rb | UTF-8 | 590 | 3.296875 | 3 | [] | no_license | require 'spec_helper'
describe Fibber do
it "generates fib numbers up to the provided number" do
fibs_up_to_10 = [1, 2, 3, 5, 8]
expect(Fibber.generate(10)).to eq(fibs_up_to_10)
fibs_up_to_100 = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
expect(Fibber.generate(100)).to eq(fibs_up_to_100)
end
it "knows... | true |
5f48ea6298dc2c478f3ecb46d93dbffe61af1e65 | Ruby | pdsanch1/homegrown | /router.rb | UTF-8 | 292 | 2.65625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'page_generator'
if ARGV.size == 0
puts "Usage: ruby router.rb [action]"
exit
end
action = ARGV[0]
if action == 'index' || action == 'random'
#
page_generator = WebPageGenerator.new
page_generator.generate_list(action)
puts "Unknown action! Try again."
end
| true |
90c6907253656e207710707fde8146f0c6d2b935 | Ruby | dr-walfeld/PBI | /Uebung02/error10-1.rb | UTF-8 | 181 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env ruby
dna = 'ACGAATT\tACTTTAGC"'
rna = dna.gsub(/T/, "U")
print "Here is the starting DNA:\t"
print "#{dna}\n"
print "Here is the result:\t"
puts "#{rna}\n"
exit 0
| true |
1b9aea46fd0b6a13efed83e2ba34e19497c57dd0 | Ruby | revis0r/time_of_day_attr | /lib/time_of_day_attr.rb | UTF-8 | 1,505 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'time_of_day_attr/active_record_ext'
require 'action_view'
require 'time_of_day_attr/form_builder_ext'
files = Dir[File.join(File.dirname(__FILE__), '../config/locales/*.yml')]
I18n.load_path.concat(files)
module TimeOfDayAttr
class << self
def delocalize(value, options = {})
format = options[:... | true |
8d373926729483388cb0f68e56722231d441c6a3 | Ruby | Tsubasaman0/ruby_practice | /lib/convert_hash_syntax.rb | UTF-8 | 170 | 2.875 | 3 | [] | no_license | def convert_hash_syntax(old_syntax)
old_syntax.gsub(/:(\w+) *=> */, '\1: ')
end
puts convert_hash_syntax(
":name => 'Alice', :age => 20, :gender => :female"
)
| true |
122657fdf7e16c7d967a5a0fd90f08c8d8563487 | Ruby | stewartjohnson/gaman | /lib/gaman/message.rb | UTF-8 | 1,020 | 3.375 | 3 | [
"MIT"
] | permissive | module Gaman
# Internal: Represents a message that has been sent to or from the user.
class Message
attr_reader :to, :from, :time, :type, :text
# Internal: Creates a new record of a message that has been sent/received
# through FIBS. Paramaters:
#
# to - The name of the person to whom the mes... | true |
9a99898bdc522fbf53aae68edf72f6ae09225030 | Ruby | redferret/colorado_lottery | /lib/contestant.rb | UTF-8 | 628 | 3.140625 | 3 | [] | no_license | class Contestant
attr_reader :first_name,
:last_name,
:age,
:state_of_residence,
:spending_money,
:game_interests
def initialize(attrs)
@first_name = attrs[:first_name]
@last_name = attrs[:last_name]
@age = attrs[:age]
@state_of_... | true |
32a4f6e53feb56fd7bcc72f027e3f06763facf64 | Ruby | switchboard/switchboard | /config/initializers/date_time_formats.rb | UTF-8 | 2,108 | 3 | 3 | [] | no_license | Time::DATE_FORMATS.merge!({
weekday_short: '%a, %b %-d',
weekday_long: '%A, %b %-d',
long_date_no_year: '%A, %B %d',
full_time: '%I:%M %p',
clean: "%l:%M %p",
rfc_2445: '%Y%m%dT%H%M%SZ',
rfc_822_no_zone: '%Y-%m-%d %H:%M:%S',
weekday_short_time: '%a, %b %-d at %l:%M %p', # Thu, Jul 12 at 11:15 pm
weekd... | true |
a0e11d7a567b69a42eea8f607e47fa6e82827bb8 | Ruby | yprokule/learn-ruby | /case_statement.rb | UTF-8 | 418 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | #!/bin/env ruby
vcs = 'a1'
def evaluate_it(vcs)
case vcs
when 'p4' ,'p3'
puts "#{vcs} is too old"
when 'o1' ,'o2'
puts "#{vcs} is mid term"
when 'a1' , 'a2'
puts "#{vcs} is Alpha !!!"
else
puts "Unsupported version #{vcs}"
end
end... | true |
1428f785d01cedcace4c68919a9232aeae1eeade | Ruby | nimam1992/programming-univbasics-4-array-concept-review-lab-nyc-web-030920 | /lib/array_methods.rb | UTF-8 | 517 | 3.421875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
x = value_to_find
list = nil
i=0
while i < array.length do
array[i]
if array[i]===x
list = i
end
i+=1
end
if list===nil
list = nil
end
return list
end
def find_max_value(array)
x = array[0]
array.length.times {|index|
if ar... | true |
48ad72ad8acdaf46e99199fb29bec2a2eff855f8 | Ruby | WreckitRuss/oxford-comma-onl01-seng-pt-061520 | /lib/oxford_comma.rb | UTF-8 | 470 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
#def oxford_comma array
if array.length==1
return array[0]
else
last=array[array.length-1]
array.pop
string=array.join(', ')
if array.length==1
string.concat(" and ")
else
string.concat(", and ")
end
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.