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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
24c30637d236953809a4f07fb873fc23d2473148 | Ruby | patrickdavey/vimwiki_markdown | /lib/vimwiki_markdown/wiki_body.rb | UTF-8 | 2,457 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'active_support/inflector'
require 'github/markup'
require 'html/pipeline'
require 'pathname'
require "vimwiki_markdown/vimwiki_link"
require "vimwiki_markdown/vimwiki_toc_filter"
class VimwikiMarkdown::WikiBody
def initialize(options)
@options = options
end
def to_s
hack_replace_commonmarker_p... | true |
7e403928be17337cadf959c0a3ffb2da93ae117c | Ruby | alberto/rublo | /test/post_factory.rb | UTF-8 | 346 | 2.640625 | 3 | [] | no_license | class PostFactory
@@posts = {}
def self.create post_symbol
initialize if @@posts.empty?
@@posts[post_symbol]
end
private
def self.initialize
@@posts[:default] = Post.new('title' => "The title", 'date' => '2011-05-20')
@@posts[:second] = Post.new('title' => "Second title", 'date' => '20... | true |
8826b4e0a187fca0183eb24a10bf47c631633665 | Ruby | sher-s7/chess | /square.rb | UTF-8 | 297 | 3 | 3 | [] | no_license | class Square
attr_reader :coordinate
attr_accessor :piece
@@instances = []
def initialize(coordinate)
@coordinate = coordinate
@piece = nil
@@instances << self
end
def self.all
return @@instances
end
def to_s
return piece.nil? ? ' ' : piece.unicode
end
end | true |
57f8bae75d37c6906daac1b9738c2772e84b4423 | Ruby | sanger/warehouse_two | /script/api_loader | UTF-8 | 2,761 | 2.796875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'thor'
require File.expand_path('../../config/environment', __FILE__)
class ::String
module Ranging
def to_range
case
when self =~ /^(\d+)..(\d+)$/ then ($1.to_i .. $2.to_i)
when self =~ /^(\d+)...(\d+)$/ then ($1.to_i ... $2.to_i)
when self.to_i > 0 ... | true |
9d632f473c176b6119b049647b2ca0377a5b334b | Ruby | marcroberts/adventofcode2017 | /day5.rb | UTF-8 | 632 | 3.40625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
input = ARGF.read
original_instructions = input.split("\n").map(&:to_i)
instructions = original_instructions.dup
size = instructions.size
pointer = 0
count = 0
loop do
jump = instructions[pointer]
count += 1
break if pointer+jump > size-1
instructions[pointer] += 1
pointer += jum... | true |
fb0dddc7577f03f12374eb00fad6649630d6b0b2 | Ruby | kai021998/cartoon-collections-prework | /cartoon_collections.rb | UTF-8 | 641 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(array)# code an argument here
# Your code here
array.sort!
array.each_with_index {|val, index| puts "#{index + 1} #{val}" }
end
def summon_captain_planet(array)# code an argument here
# Your code here
array.each do
|x| x.capitalize!
end
array.collect do
|x| x << "!"
end
en... | true |
baef00a7834dc253dcf370233d4cb57c78eda328 | Ruby | eprothro/cassie | /lib/cassie/statements/statement/relation.rb | UTF-8 | 1,685 | 2.609375 | 3 | [
"MIT"
] | permissive | module Cassie::Statements::Statement
#
#
# relation :username, :eq
# relation :username, :eq, value: :method
# relation :phone, :in
# relation :user_id, :gteq, term: "minTimeuuid('2013-02-02 10:00+0000')"
class Relation
# https://cassandra.apache.org/doc/cql3/CQL.html#selectStmt
OPERA... | true |
199aa61666001803094661143d60c5021545991a | Ruby | siebertm/redis-mmm | /bin/redis_mmm | UTF-8 | 9,080 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'redis'
require 'logger'
require 'thor'
require 'parseconfig'
$log = Logger.new(STDOUT)
class RedisMMM < Thor
class Error < ::RuntimeError
def initialize(subject = nil)
@subject = subject
end
attr_reader :subject
end
class NoMaster < Error; end... | true |
f768918d890683c229a722e7f45a182b3cc90f47 | Ruby | sungchoi/topics-in-cs | /data-structures/ruby/key_value.rb | UTF-8 | 718 | 3.15625 | 3 | [] | no_license | def KeyValue(key, value = nil)
# NOTE: ruby case statements use ===
# NOTE: when LinkedList::Node === case value
# NOTE: LinkedList::Node === value.class #=> LinkedList::Node === Class #=> false
# NOTE: http://stackoverflow.com/questions/3801469/how-to-catch-errnoeconnreset-class-in-case-when
case key
when ... | true |
405690186fda28c52246b67b2c3848172062e8fa | Ruby | quintel/fever | /lib/fever/deferrable_activity.rb | UTF-8 | 2,709 | 3.359375 | 3 | [
"MIT"
] | permissive | module Fever
# An activity where unfulfilled demand will be deferred, to be attempted again
# later.
#
# Notes:
#
# * **This class is not thread-safe.**
#
# * Presence of items in the deferments array is done with @deferments[0]
# rather than #any? or #none? since it's 3-4x faster.
#
class... | true |
de16253ff2aeee3cd1368ccdb5671a13400e7518 | Ruby | ianmurrays/connect-four | /app/controllers/users_controller.rb | UTF-8 | 1,393 | 2.515625 | 3 | [] | no_license | class UsersController < ApplicationController
before_filter :ensure_boards!
before_filter :load_boards
def show
@turn = @player_one.turn ? 1 : 2
end
def play
# Where was the disc dropped?
column = params[:column].to_i
# Drop into the correct column for our board
board = @player == 1 ... | true |
fd7ae0f89b237bfac5cde69511eedba1a4472ce0 | Ruby | unimatrixZxero/brains | /server/lib/robot.rb | UTF-8 | 2,523 | 3 | 3 | [
"MIT"
] | permissive | require 'rest_client'
class Robot < Actor
MAX_RESPONSE_LENGTH = 256
VALID_ACTIONS = %w(idle move attack turn)
attr_accessor :brain
def self.place(width, height)
x_variance = width * 0.1
x = rand(-x_variance, x_variance) + width / 2
y_variance = height * 0.1
y = rand(-y_variance, y_variance) ... | true |
e2040cfbd96728268a56c4883005dcc2ed52e763 | Ruby | lucanioi/exercism-ruby | /connect/board.rb | UTF-8 | 326 | 3.171875 | 3 | [] | no_license | class Board
def initialize(board)
@rows = board.map(&:split)
end
def winner
case
when connect?('O', rows) then 'O'
when connect?('X', rows.transpose) then 'X'
else ''
end
end
private
attr_reader :rows, :seen
def connect?(player, rows)
Connect.new(player, rows).connect?
en... | true |
4eb9fb936719ff8ffafa3288c92a9248302bff3a | Ruby | ChenWeiLee/CWSVM | /kernels.rb | UTF-8 | 1,402 | 3.671875 | 4 | [
"MIT"
] | permissive |
class KernelType
attr_reader :type
attr_accessor :sigma
def initialize(kernelType = :linear,sigmaValue = 1)
@type = kernelType
@sigma = sigmaValue
end
def linear
@type = :linear
end
def rbf(sigmaValue = 1)
@type = :rbf
@sigma = sigmaValue
end
end
class Kernels
attr_accesso... | true |
81be4b0ebae170a659141072425b79d9dfbd1200 | Ruby | dimitras/Zfish-Project | /lib/mrna_parser.rb | UTF-8 | 2,117 | 3 | 3 | [] | no_license | require 'mrna'
class MrnaParser
attr_accessor :filename, :count
def initialize(filename)
@filename = filename
@filehandle = File.new(filename) #if filename
@index = {}
@index_by_prot_accno = {}
create_indexes
@count = 0
end
def increment()
@count += 1
end
def self.open(filename)
mrnap = Mrna... | true |
45e0cfbf206b40fabaa86aa7485d7bae52c4d4ef | Ruby | QuasimodoPrograms/Ruby-dice | /dice.rb | UTF-8 | 84 | 3.15625 | 3 | [] | no_license | puts "How many dice?"
num = gets.to_i#to int
num.times do
puts rand(6) +1
end | true |
1c273dc17a3d44e7e6875910453fc52892864e35 | Ruby | MR-RenatoBlue/inventory-cable | /app/models/product.rb | UTF-8 | 149 | 2.640625 | 3 | [
"MIT"
] | permissive | class Product < ApplicationRecord
def price=(other)
self.price_in_cents = other * 100
end
def price
price_in_cents / 100.0
end
end
| true |
99675e8f8595f8e76bd1b45cd091ebea10ee9657 | Ruby | mattpritchard4/codeeval_solutions | /easy/sum_of_digits.rb | UTF-8 | 487 | 4.15625 | 4 | [] | no_license | # SUM OF DIGITS
# CHALLENGE DESCRIPTION:
# Given a positive integer, find the sum of its constituent digits.
# INPUT SAMPLE:
# The first argument will be a path to a filename containing positive integers, one per line. E.g.
# 23
# 496
# OUTPUT SAMPLE:
# Print to stdout, the sum of the numbers that make up the in... | true |
1d4ca7b68bcb4a3047272e88ec6e54a0412efde8 | Ruby | Shelf-Share-BEE-Mod3/book_buddy | /poros/book.rb | UTF-8 | 362 | 2.640625 | 3 | [] | no_license | class Book
attr_reader :id, :title, :author, :description, :thumbnail, :isbn, :category
def initialize(attributes)
@id = nil
@title = attributes[:title]
@author = attributes[:author]
@description = attributes[:description]
@thumbnail = attributes[:thumbnail]
@isbn = attributes[:isbn]
@c... | true |
e7f35409ce86ce1cae712293c176af05b5fc583b | Ruby | josedonizetti/sss_ruby | /lib/sss_ruby/nodes/literal.rb | UTF-8 | 265 | 2.71875 | 3 | [
"MIT"
] | permissive | module SSS
class Literal
def initialize(value)
@value = value
end
def to_css(context)
@value.to_s
end
def ==(o)
o.class == self.class && o.state == state
end
protected
def state
@values
end
end
end
| true |
ac0557fb43d7e5a86a263f1f42c64642e6a1e089 | Ruby | NNCT18J/ruby-cercil | /20-1.rb | UTF-8 | 361 | 4.03125 | 4 | [] | no_license | age=18
height=120
if age>=18
puts "Adult\n"
else
puts "Child\n"
end
if height>=120 and age>=6
puts "You can ride coaster\n"
else
puts "You cant ride coaster\n"
end #もしif文が一行で終わっても必ずendが必要
#if文は式として扱われる
message=if(age>=20)
"Adult2"
else
"Child2"
end
puts message
| true |
21dbf6423578ff75e9183f12d916767ba13f5188 | Ruby | diman0o1999/clinic | /spec/features/user_spec.rb | UTF-8 | 4,506 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
describe User do
before { @user = User.new(
user_name: "Тестовое имя",
surname: "Тестовая фамилия",
patronymic: "Тестовое отчество",
email: "user@example.com",
password: "qwerty",
password_confirmation: "qwerty"
)
}
subject { @user }
#общая валида... | true |
2e20119756e955781f9ff130786769a83bb68853 | Ruby | RSchaubeck/rails-portfolio-project | /app/helpers/users_helper.rb | UTF-8 | 221 | 2.625 | 3 | [] | no_license | module UsersHelper
def get_first_name(full_name)
name_arr = full_name.split(" ")
name_arr[0]
end
def get_last_name(full_name)
name_arr = full_name.split(" ")
name_arr[name_arr.length - 1]
end
end
| true |
3752e287bc46cfa9bcb118d6bd5a1d346451d931 | Ruby | corny/tlspolicy | /lib/icann.rb | UTF-8 | 820 | 2.90625 | 3 | [] | no_license | module ICANN
extend self
HOST_PATTERN = /\A(xn--+)?[a-z0-9]+(-+[a-z0-9]+)*\z/
def tlds
@tlds ||= read_tlds
end
def fqdn_validity(name)
errors = fqdn_errors(name)
if errors.empty?
:valid
else
["invalid", *errors].join("_").to_sym
end
end
def fqdn_errors(name)
parts ... | true |
da4b76262ae9adee98c30212835d93fca4d2ac7f | Ruby | L3-Informatique-Groupe-3/Hashi | /Game/Core/Party/Grid.rb | UTF-8 | 18,021 | 2.90625 | 3 | [] | no_license | # @Author: Despres Maxence <checkam>
# @Date: 18-Mar-2020
# @Email: maxence.despres.etu@univ-lemans.fr
# @Filename: Grid.rb
# @Last modified by: checkam
# @Last modified time: 05-Apr-2020
################################################################################
# File: Grid.rb ... | true |
55471d7aa412dcb4cc9ed7a025a8c0584685c601 | Ruby | valentinorusconi/ruby-exercises | /enumerables/exercises_1/objects/thing.rb | UTF-8 | 124 | 2.71875 | 3 | [
"MIT"
] | permissive | class Thing
def initialize(adjective)
@adjective = adjective
end
def weird?
@adjective == 'weird'
end
end
| true |
50187e53e23bf484a1d1d58a1428cdbcac236c89 | Ruby | cielavenir/procon | /rosalind/tyama_rosalindINDC.rb | UTF-8 | 160 | 2.8125 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
n=gets.to_i*2
a=[1]
n.times{a=[1]+a.each_cons(2).map{|x,y|x+y}+[1]}
n.downto(1){|i|a[i-1]+=a[i]}
puts (1..n).map{|i|Math.log10(a[i]*0.5**n)}*' ' | true |
98d725b9544beb8080b365f265b4b8be0f2513de | Ruby | mishal1/Rock-Paper-Scissors | /spec/computer_spec.rb | UTF-8 | 770 | 2.921875 | 3 | [] | no_license | require 'computer'
describe Computer do
let(:computer) {Computer.new}
possible_computer_choice = Proc.new {|choice| ["rock", "paper", "scissors"].include?(choice)}
it 'should have a default array of options' do
expect(computer.options).to eq ["rock" , "paper", "scissors"]
end
it 'should be able to c... | true |
a8be454ae4a92c02033b147bd5d574ced096c122 | Ruby | mikaelblomkvist50/snippets-ruby | /exercism/rna-transcription/rna_transcription.rb | UTF-8 | 262 | 3.203125 | 3 | [] | no_license | class Complement
def self.of_dna(dna_strand)
dna_rna = { 'A' => 'U', 'C' => 'G', 'G' => 'C', 'T' => 'A'}
rna = dna_strand.chars.map { |letter| dna_rna[letter] }
if rna.include?(nil)
return rna = ''
else
rna.join
end
end
end
| true |
c43898ff7109c8e2bf0133b430ebc87cb1ee574b | Ruby | lapluviosilla/rails_admin | /lib/rails_admin/abstract_model.rb | UTF-8 | 3,034 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'active_support/core_ext/string/inflections'
require 'rails_admin/generic_support'
module RailsAdmin
class AbstractModel
@models = []
# Returns all models for a given Rails app
def self.all
if @models.empty?
excluded_models = RailsAdmin::Config.excluded_models.map(&:to_s)
... | true |
e0d39100bb348f112d9941739bb2d29fb704f164 | Ruby | moofmayeda/tic_tac_toe_ruby | /spec/tic_tac_spec.rb | UTF-8 | 2,568 | 3.453125 | 3 | [] | no_license | require 'rspec'
require 'player'
require 'space'
require 'board'
describe "Player" do
describe "initialize" do
it "initializes a player with a name and symbol" do
player_new = Player.new("Joe", "X")
expect(player_new).to be_an_instance_of Player
end
end
end
describe "Space" do
before do
... | true |
2b45313be1d75fbab532e4d62962974b6c3a0420 | Ruby | luvtechno/red_blocks | /lib/red_blocks/paginator.rb | UTF-8 | 761 | 3.109375 | 3 | [
"MIT"
] | permissive | module RedBlocks
class Paginator
DEFAULT_PER = 10
DEFAULT_PAGE = 1
attr_reader :head, :tail, :per, :page
def initialize(per: DEFAULT_PER, page: DEFAULT_PAGE, head: nil, tail: nil)
if head && tail
unless head >= 0 && tail >= 0 && head <= tail
raise ArgumentError.new("he... | true |
4c5f0719ce65b446b7a8f13ace92ef1e5c5326cc | Ruby | DamellMorningstar/ActiveRecord-VHS-Store | /app/models/client.rb | UTF-8 | 844 | 3.015625 | 3 | [] | no_license | class Client < ActiveRecord::Base
has_many :rentals
has_many :vhs, through: :rentals
# `Client.first_rental` - accepts an instance of arguments needed to create a new `Client` instance
# a currently available `Vhs` instance (or, more difficult: a `Movie` instance or just a `Movie` title and on that ... | true |
d7e5ca0ad1ad8ff32abf484399903bbb75be0cde | Ruby | Invizory/sperm | /lib/sperm/groups/multiplicative.rb | UTF-8 | 745 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'sperm/groups/intmod'
module Sperm::Groups
# Represents (Z/pZ \ {0}, *) - a multiplicative cyclic group of integers
# modulo p.
#
class ZpMul
include Zn
attr_reader :prime, :generator
alias_method :modulo, :prime
def initialize(prime, generator)
@prime = prime
@generator =... | true |
060ec1a386ab6fc38419e714237f96d82827bc20 | Ruby | janikgar/TTS-coursework | /Week-1/skills-check/skills_check_1/10_fishes.rb | UTF-8 | 84 | 3.140625 | 3 | [] | no_license | fish = 1
while fish < 4 do
puts "#{fish} fish"
fish += 1
end
puts "blue fish" | true |
a2ac3d2681336d7345a5f5d252719f9db53c939f | Ruby | oleglr/grub-background-changer | /grub_bg.rb | UTF-8 | 672 | 2.65625 | 3 | [] | no_license | puts 'Enter source address of image'
puts '# for eg: Downloads/trees.jpg'
background =gets.chomp
if File.exist?(background)
file_name = '/etc/default/grub'
cmd = `cp #{background} /etc/default`
puts 'Successfully copied file'
f = File.open(file_name,'r')
file_content = ''
i = -1
f.each_line do |line|
file... | true |
48f5c8850179e7d9364ada55b1b71bf735302c27 | Ruby | JohnB/hairball | /destinations/jekyll_datestamped_blog_entries.rb | UTF-8 | 847 | 2.828125 | 3 | [] | no_license | class JekyllDatestampedBlogEntries
def initialize(dest_dir)
@dest_dir = dest_dir
end
def methods_expected_of_converter
%w[year month day title contents]
end
def add(converter)
dest_filename = [converter.year, converter.month, converter.day, converter.title+'.textile'].join('-')
dest_fullpath ... | true |
8a3765efd678f4a3c75091f569b822f105a2b284 | Ruby | vincentporquet/promo-2-challenges | /01-Ruby/04-Hash-Symbols/01-Modeling-with-Hash/lib/mc_donald.rb | UTF-8 | 616 | 3.375 | 3 | [] | no_license | mcDonald = {
"Cheese Burger" => 290,
"Big Mac" => 300,
"Mc Bacon" => 400,
"Royal Cheese" => 130,
"French fries" => 130,
"Potatoes" => 130,
"Coca" => 160,
"Sprite" => 170
}
menu = []
begin
puts menu.empty? ? "What do you want to eat ?" : "And with that ?"
answer = gets.chomp
menu << answ... | true |
0192b59ccc385c3d13cf6920bc594efa8a98a301 | Ruby | Kinselan/learn-to-program | /loops_and_iterations/ex4.rb | UTF-8 | 167 | 3.578125 | 4 | [] | no_license | # ex4.rb
def countdown(num)
if num <= 0
num
else
puts num
countdown(num - 1)
end
end
# puts countdown(10)
# puts countdown(20)
puts countdown(-3) | true |
111355affe286c99caa05ea31f3c2965395c734a | Ruby | pedz/Condor3 | /app/models/user.rb | UTF-8 | 1,478 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#
# Copyright 2012-2013 Ease Software, Inc.
# All Rights Reserved
#
# The User record for the application. The ldap_id is the email
# intranet address of the user.
class User < ActiveRecord::Base
##
# :attr: id
# The Integer primary key for the table.
##
# :attr: ldap_id
# The int... | true |
7c5abdcd5c78bd8dc8957de099d92405542824ef | Ruby | pethomestay/phs | /app/models/reference_data/size.rb | UTF-8 | 692 | 3.171875 | 3 | [] | no_license | class ReferenceData::Size
attr_accessor :id, :title
def initialize(id, title)
@id = id
@title = title
end
def self.all
[SMALL, MEDIUM, LARGE, GIANT]
end
def self.all_titles
[SMALL.title, MEDIUM.title, LARGE.title, GIANT.title]
end
def self.find(id)
raise ActiveRecord::RecordNotFo... | true |
150a483b59853d1bdf7c844a6676a3ce04f18df6 | Ruby | dwilkie/chibi | /spec/support/analyzable_examples.rb | UTF-8 | 4,716 | 2.6875 | 3 | [] | no_license | module AnalyzableExamples
# this must return a UTC time
def miliseconds_since_epoch(date)
(date.to_date.to_datetime.beginning_of_day.to_i * 1000)
end
def eight_days_ago
8.days.ago
end
def operator_name
resource.user.operator_name
end
def country_code
resource.user.country_code
end
... | true |
650911a29a4937ece437e2be4f7a68f3729e6543 | Ruby | annabellaroberts/assignment2 | /question2.rb | UTF-8 | 437 | 4.0625 | 4 | [] | no_license | class Book
attr_accessor :title, :chapters
def initialize(title)
@title, @chapters = title, []
end
def add_chapter(chapter)
@chapters << "#{@chapters.length + 1}. #{chapter}"
end
def stats
puts "Your book: #{@title} has #{@chapters.length} chapters:"
puts @chapters
end
end
book = Book... | true |
d7d6d1c3566b878cab0141e36fde9c73025e1088 | Ruby | pshowell23/project-euler-problems | /longest-collatz-sequence/longest-collatz-sequence.rb | UTF-8 | 1,087 | 4.28125 | 4 | [] | no_license | #Returns starting number of longest Collatz sequence where starting number is less than limit provided
def get_longest_collatz(limit)
starting_num = 2
longest_collatz = []
while starting_num < limit do
collatz = get_collatz(starting_num)
if collatz.length > longest_collatz.length
... | true |
3753ac005b66aa439685add1caef1794bb3e9c91 | Ruby | luluzheng1/LootTable | /loot_table.rb | UTF-8 | 3,875 | 3.59375 | 4 | [] | no_license | class LootTable
# Take in a table hash and initialize a LootTable object
def initialize(t)
@TableType = t["TableType"]
@TableName = t["TableName"]
@TableEntryCollection = initialize_entries(t["TableEntryCollection"])
end
# Initializes a set of TableEntrys for a LootTable... | true |
c5d5c230dbabcfd7c33a7eff4483df3fa0955aa1 | Ruby | leslie0726/ntub-ruby-course2017 | /10446007/order.rb | UTF-8 | 354 | 3.234375 | 3 | [] | no_license | class Order
attr_accessor :state
attr_reader :products
def initialize(products=[])
@state = "pending"
@products = products
end
def pay!
@state = "paid"
end
def items
@products
end
def total_price
amount = 0
@products.reduce(0) {|amount, products| amount + products[:price] *... | true |
82ffd7addf1e36f3c0599ff57ccae4dd158646e7 | Ruby | DouglasAllen/code-Metaprogramming_Ruby | /raw-code/PART_II_Metaprogramming_in_Rails/gems/rails-2.3.2/lib/rails_generator/secret_key_generator.rb | UTF-8 | 1,346 | 2.953125 | 3 | [
"MIT"
] | permissive | #---
# Excerpted from "Metaprogramming 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:/... | true |
c5c7ebd7630f760ec23c1d81d9a3ab5a6701f54f | Ruby | diplay/num_methods | /laba1/matrix_generator.rb | UTF-8 | 1,619 | 3.359375 | 3 | [] | no_license | #!/usr/bin/ruby
#coding: utf-8
require 'matrix'
class Matrix
def []=(i, j, x)
@rows[i][j] = x
end
end
def gen_matrix(n, symm, min, max)
a = Matrix.build(n) do |i, j|
rand(min .. max)
end
a.each_with_index(:strict_lower) { |el, i, j| a[i, j] = a[j, i] } if symm
return a.row_vectors
end
def print_... | true |
bfb7a8f32891c2f04364033e23271834fc1f7153 | Ruby | sascott624/school-domain-v-000 | /lib/school.rb | UTF-8 | 560 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
require 'pry'
class School
attr_reader :name, :roster
def initialize(name, roster = {})
@name = name
@roster = roster
end
def add_student(student_name, grade)
if @roster.keys.include? (grade)
@roster[grade] << student_name
else
@roster[grade] = []
@roster[grade... | true |
ad9b0c7ae2ab3644ae91c25a373ae0e736057818 | Ruby | spruceboy/Spruceboy-s-Data-Processing-Scripts | /copy_geo_info.rb | UTF-8 | 1,948 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
require "rubygems"
require "yaml"
require 'getoptlong'
require "pp"
def runner ( s )
puts("Runner running \"#{s}\"")
start_time = Time.now.to_f
system(s)
end_time = Time.now.to_f
run_time = (end_time-start_time)
if ( run_time > 60)
printf("This run took %d m\n", (end_time-start_ti... | true |
6562d229404501db91c3f8fcba6dd360f13930ea | Ruby | egrueter-dev/LTP-2nd-edition | /learnruby10.rb | UTF-8 | 495 | 4.21875 | 4 | [] | no_license | # #blocks, nested blocks to be exact.....
#
#
# array.each do |x|
# puts "first #{x}"
# array.each do |x| #executes the same blog again in between the first and second value..
# puts "second #{x}"
# end
# end
#
#
# array = [1,2]
#
# array.each do |x|
# puts "first #{x}"
# array.each do |x2| #in between th... | true |
238b056abf4226795499abc48d326a5031b2d439 | Ruby | mwickman/project-euler | /euler2.rb | UTF-8 | 172 | 3.453125 | 3 | [] | no_license | sum = 0
fib = [1,2,2]
while fib[2] <= 4000000
if fib[2] % 2 == 0
sum += fib[2]
end
fib[2] = fib[0] + fib[1]
fib[0] = fib[1]
fib[1] = fib[2]
end
puts sum | true |
8de0fa1d9e060940860651b8fdde692b86f921f5 | Ruby | think41c/sinatra_sitepoint | /main.rb | UTF-8 | 1,889 | 3.421875 | 3 | [] | no_license | # Uses 2 sub folders to keep data. '/public' for stylesheets & images, and '/views' for Slim templates.
require 'sinatra'
require 'sinatra/reloader'
require 'slim'
get '/' do
slim :index # Misspelling 'slim' will result in a 'No Method Error'. Misspelling 'index' results in Error - No such file
# Slim automat... | true |
3dc7bfa91eb20bbd32acc11795831df883316533 | Ruby | dcmorse/text-via-twillio-ruby | /main.rb | UTF-8 | 475 | 2.609375 | 3 | [] | no_license | require 'twilio-ruby'
account_sid = ENV['TWILLIO_ACCOUNT_SID'] # Your Account SID from www.twilio.com/console
auth_token = ENV['TWILLIO_AUTH_TOKEN'] # Your Auth Token from www.twilio.com/console
from_phone = ENV['TWILLIO_TRIAL_PHONE'] # Replace with your Twilio number
to_phone = ENV['MY_CELL_PHONE']
@client = Twil... | true |
7190160da826903957435a24747940305aef0ed8 | Ruby | spaghetticode/rubyacademy-2013 | /testing/examples/spec/xmas_countdown_spec.rb | UTF-8 | 1,862 | 2.9375 | 3 | [] | no_license | require_relative '../xmas_countdown'
describe Countdown do
it 'knows when is Christmas' do
subject.xmas_day.should == '12-25'
end
describe '#next_xmas' do
it { subject.next_xmas.should be_a Date }
it 'is the next Christmas date' do
subject.next_xmas.should == Date.parse("#{Date.today.year}-12... | true |
57bfc0ba1bf35b92f3d69bb26e830d09cfa06ea1 | Ruby | microspino/xkcdize | /xkcdize2.rb | UTF-8 | 1,590 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require 'bundler/setup'
require 'rmagick'
require_relative 'rmagick_patch'
include Magick
# Source of algo http://blog.wolfram.com/2012/10/05/automating-xkcd-diagrams-transforming-serious-to-funny/
def xkcdize(src, shift=20)
# Construct 2 "distorsion maps", separate for x and y... | true |
2b23b9d3705a48c7cfff6e65c731df72c973cd78 | Ruby | nick-aschenbach/accuweather | /lib/accuweather/location/city.rb | UTF-8 | 694 | 3.03125 | 3 | [] | no_license | module Accuweather
module Location
class City
attr_reader :id, :city, :state, :latitude, :longitude
def initialize(id:, city:, state:, latitude:, longitude:)
@id = id
@city = city
@state = state
@latitude = latitude
@longitude = longitude
end
def =... | true |
3edc98277683e9adf1f93a8f78195008fe25aad9 | Ruby | gdiasdasilva/prime_factors | /bin/prime_factorization.rb | UTF-8 | 856 | 3.65625 | 4 | [] | no_license | class PrimeFactorization
def initialize(number)
@calculated_primes = {}
@number_to_factorize = number
end
def prime_factors
factors = []
processing_number = @number_to_factorize
while true do
current_factor = minimal_divisible_factor(processing_number)
break if current_factor.nil... | true |
3aa98234612712360d61869afea81426f91ec17c | Ruby | satnegirji/language | /lib/language/word_class.rb | UTF-8 | 1,024 | 3.3125 | 3 | [
"MIT"
] | permissive | module Language
module WordClass
# A part of speech (abbreviated form: PoS or POS) is a category of words
# (or, more generally, of lexical items) which have similar grammatical
# properties.
#
# Words that are assigned to the same part of speech generally
# display similar behavior in terms o... | true |
72f7557a6e1b206314a92ff17746caddfd13bb0d | Ruby | aaduru/technical_interview_problems | /search_insert.rb | UTF-8 | 633 | 3.84375 | 4 | [] | no_license | def search_insert(nums, target)
i = 0
while i < nums.length
if nums[i] == target
return i
elsif i == 0 && target < nums[i]
return i
elsif (i+1 == nums.length) && target > nums[i]
return (i + 1 )
elsif (i - 1 ) >= 0
if target < nums... | true |
70b9bc7f9ceec05ed32dc3981e3152981f9d63af | Ruby | marisayou/programming-univbasics-nds-nested-arrays-iteration-lab-part-1-sea01-seng-ft-100520 | /lib/iteration_with_loops.rb | UTF-8 | 325 | 3.828125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_even_values(src)
# Given an Array of Arrays of Integers ( [ [10, 11], [99, 50, 3, 4], [23, 41] ] ):
#
# Output all even values in each nested array
n = src.length
for i in 0...n
m = src[i].length
for j in 0...m
num = src[i][j]
if num%2 == 0
puts num
end
end
en... | true |
d35a91b12aef85b7f214e17da7d2917df810bb9a | Ruby | phss/playground | /exercises/skiena/chapter_three/exercise_3_21/binary_tree_dictionary.rb | UTF-8 | 2,879 | 3.484375 | 3 | [] | no_license | # Most of the functions are O(h), where h is the height of the tree. Ideally h = log n, in a balanced tree.
class BinaryTreeDictionary
attr_reader :root
def initialize
@root = nil
end
# O(h)
def search(key)
key_node = find_node_for(key)
return key_node.nil? ? nil : key_node.item
end
#... | true |
97f47015b25387981f34b7c6cd873ffd9cd76499 | Ruby | deepakjois/gchartrb | /spec/gchartrb/markers_spec.rb | UTF-8 | 6,199 | 2.65625 | 3 | [
"MIT"
] | permissive | require File.expand_path("#{File.dirname(__FILE__)}/../helper")
describe GoogleChart::Markers do
before(:each) do
@chart = GoogleChart::LineChart.new
@chart.data "Series 1", [1,2,3,4,5], "ff00ff"
end
it "is supported by LineChart, LineXYChart, BarChart, ScatterPlot and SparklineChart" do
[GoogleChart... | true |
afb5455b0b10b090fc2984a200fb24244df78ad9 | Ruby | Ryanbarker0/key-for-min-value-london-web-091718 | /key_for_min.rb | UTF-8 | 285 | 3.4375 | 3 | [
"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)
k = nil
v = 0
name_hash.map do |key, value|
if v == 0 || value < v
v = value
k = key
end
end
k
end
| true |
5825b88b743dd14a03da0404ef6d3c78a8f4f66b | Ruby | abe-t/ruby_training | /ruby/kadai/practice_csv/read_csv.rb | UTF-8 | 1,469 | 3.75 | 4 | [] | no_license | class Week
require 'csv'
require 'date'
#最初に検索したいcsvファイルを入力させる
def initialize file
@csv_data = CSV.read(file, headers: true)
end
#曜日毎の月の作業時間を求めるめそっと
def week_sum
#各曜日の変数
mon = 0
tue = 0
wed = 0
thu = 0
fri = 0
sat = 0
sun = 0
#最初の勤務日と最後の勤務日を変数に代入
fi... | true |
9fbca8c3171628e51b7f9b7641926a0ce44342fb | Ruby | markjeee/activefacts | /lib/activefacts/api/constellation.rb | UTF-8 | 5,890 | 3.09375 | 3 | [
"Zlib"
] | permissive | #
# ActiveFacts Runtime API
# Constellation class
#
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
#
module ActiveFacts
module API #:nodoc:
# A Constellation is a population of instances of the Concept classes of a Vocabulary.
# Every concept class is either a Value type or an E... | true |
1db82bf48d5370cc1bd20184c0ad29fcedeb0677 | Ruby | shreya317/flashcards-wk1-phase2 | /db/seeds.rb | UTF-8 | 947 | 3 | 3 | [] | no_license | User.destroy_all
Deck.destroy_all
Card.destroy_all
Turn.destroy_all
taha = User.create!(email: "taha@foo.com", password: "password")
class Parser
attr_reader :lines, :hashes
def initialize(filename)
@lines = []
@hashes = []
File.open(filename, "r").each_line { |line| @lines << line.strip if line.strip... | true |
b08e1a07ebf846f8a625df854c67d3ab4b514cad | Ruby | kanzash/ruby | /ex7.rb | UTF-8 | 634 | 4.53125 | 5 | [] | no_license | #LESSON 7: MORE PRINTING
puts "Mary had a little lamb."
puts "It's fleece was white as #{'snow'}."
puts "And everywhere that Mary went."
puts "." * 10 #what'd that do
#doing . multiplied by 10 and puts that prints out the . 10 times
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 ... | true |
d1659e42740d7ec96117f235e4c99d7d86b61898 | Ruby | jenrzzz/HERP-urban-crossfitters | /app/models/exercise_category.rb | UTF-8 | 1,195 | 3.0625 | 3 | [
"MIT"
] | permissive | # Model for a category of exercises.
class ExerciseCategory < ActiveRecord::Base
# ----- ATTRIBUTES ACESSIBLE -----
attr_accessible :category
# ----- NAMED SCOPES -----
# order categories in ascending order
scope :ordered, :order => 'category ASC'
# ----- VALIDATION CALLS -----
validates_presence_of :c... | true |
84de50f8aa6debab8bf56292a982e98067dd3226 | Ruby | imFawkes/todo | /app/services/tasks/change_list.rb | UTF-8 | 524 | 2.515625 | 3 | [] | no_license | class Tasks::ChangeList
Result = Struct.new(:success?, :errors, :object)
def call(params, current_user)
task = current_user.tasks.find_by(id: params[:id])
if task == nil
return Result.new(false, ['Task not found'], nil)
end
list = current_user.lists.find_by(id: params[:list_id])
if li... | true |
57a2eaa6960aceea387585f44c03547ce9d1fbb3 | Ruby | Marco85180/promo-2-challenges | /01-Ruby/Exercices supplémentaires/Exo_lundi14a.rb | UTF-8 | 849 | 3.40625 | 3 | [] | no_license | todo = {}
while true
puts "Que devez-vous faire aujourd'hui?"
task = gets.chomp.to_s
break if task == ""
begin
puts "Quelle priorité?"
priority = gets.chomp.to_i
end while!(1..10)include?(priority)
todo[task] = priority
end
puts 'Here are your tasks :'
todo.each do|key, value|
puts "- #{key} à un... | true |
9426e90b30d95a7c622a79490f72d9c0afd5e70a | Ruby | maiha/typed | /lib/typed/hash.rb | UTF-8 | 3,798 | 2.578125 | 3 | [
"MIT"
] | permissive | module Typed
class Hash
include Enumerable
DEFAULT_OPTIONS = {
:schema => true,
}
delegate :keys, :size, :to=>"@hash"
attr_reader :changes
attr_reader :events
def initialize(options = {})
@hash = ActiveSupport::OrderedHash.new
@options = DEFAULT_OPTIONS.merge(option... | true |
66b34e2b38707c9f50264f53ea2ecb46dc9c0a3c | Ruby | Lwyrup/Questions-App | /questions | UTF-8 | 3,372 | 3.8125 | 4 | [] | no_license | #!/usr/bin/env ruby
#Class that deals with file and its modification
class Fileq
#Sets up variable for array of questions
def initFile
@questions = []
@listNum = 1
end
#Displays questions numbering by element number
def see
@questions.each do |question|
puts "#{@listNum}.#{question}"
@listNum += 1
... | true |
196e0c7d42fc7bf321fc23c5f7eeaef2f9677522 | Ruby | GenMaker/animal_rolodex | /bin/animal_rolodex | UTF-8 | 377 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#this is a shebang line that tells the program loader what command to use to execute the files
require_relative '../lib/animal_rolodex'
#this line tells the loader that we need this file in the lib folder
CLI.new.run
#this calls the Cli class and .new creates a new instance of that class. .... | true |
d5441d995aeb03d0d664f3d07c5ce05b65281286 | Ruby | jierasmus27/star_wars_battle | /app/models/person.rb | UTF-8 | 1,117 | 2.65625 | 3 | [] | no_license | class Person
include Comparitor::Person
attr_accessor :id, :name, :height, :mass, :hair_color, :skin_color, :birth_year, :gender, :homeworld,
:eye_color, :films, :species, :vehicles, :starships, :created, :edited, :url
def self.find_by_id(id)
api_val = Rails.cache.fetch("swapi_rb3/#{id}", ex... | true |
3916ff1072e0ecdaee122e7321d83ca9bdc7b0ae | Ruby | IanPFoertsch/Proposition | /lib/proposition/parser/token/token.rb | UTF-8 | 633 | 2.9375 | 3 | [] | no_license | module Proposition
module Parser
class Token
attr_reader :string
def initialize(string)
@string = string
end
def ==(other)
#TODO: this logic is shared amongst many classes, consolidate to module
return false unless other.is_a?(self.class)
other.string == se... | true |
2d073d7210c8f3441cf09441476c4ee641043d68 | Ruby | hjanuschka/fastlane | /spaceship/lib/spaceship/tunes/availability.rb | UTF-8 | 1,358 | 3.09375 | 3 | [
"MIT"
] | permissive | require_relative 'territory'
module Spaceship
module Tunes
class Availability < TunesBase
# @return (Bool) Are future territories included?
attr_accessor :include_future_territories
# @return (Array of Spaceship::Tunes::Territory objects) A list of the territories
attr_accessor :territor... | true |
24b33e9c0f7dd5aac44cdcc1c13d11fe4bca8f3d | Ruby | 0xR0/godofwar | /lib/godofwar/payloads.rb | UTF-8 | 2,988 | 2.75 | 3 | [
"MIT"
] | permissive | #
# KING SABRI | @KINGSABRI
#
module GodOfWar
#
# All war internal operations
#
class Payloads
Payload = Struct.new(:name, :desc, :os, :conf, :url, :ref, :path)
# @!attribute [r] [String] payloads_home
# full path of the payloads home
# @!attribute [r] [Hash] payloads_db
# parsed cont... | true |
c552b6851c8904729e73db90794ebaa6e82564ce | Ruby | agorf/adventofcode | /2018/05/2.rb | UTF-8 | 544 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby
REACTIVE_PAIRS = Regexp.union(
*('a'..'z').
zip('A'..'Z').
concat(('A'..'Z').zip('a'..'z')).
map(&:join).
freeze
)
def react_polymer(polymer)
polymer = polymer.dup
loop do
prev_polymer = polymer.dup
polymer.gsub!(REACTIVE_PAIRS, '')
return polymer if polymer == ... | true |
2c8094ba7dcee010fdb314c399fd8bd5a84fce46 | Ruby | MarcPer/cs-algorithms | /data-structures/week1_basic_data_structures/3_network_simulation/process_packages_test.rb | UTF-8 | 836 | 2.578125 | 3 | [] | no_license | require_relative './process_packages.rb'
require 'minitest/autorun'
class SolutionTest < Minitest::Test
def test_solution
specs = [
{buff_size: 1, input: [], want: []},
{buff_size: 1, input: ["0 0"], want: [0]},
{buff_size: 1, input: ["1 0"], want: [1]},
{buff_size: 1, input: ["0 1", "0 1... | true |
3856dbd9044a92151bd98f6df521d34669f3fd4a | Ruby | fkmuramoto/pixuleco | /game.rb | UTF-8 | 1,037 | 3.03125 | 3 | [] | no_license | require 'gosu'
require_relative 'player'
require_relative 'money'
require_relative 'moro'
class Pixuleco < Gosu::Window
def initialize
super(1000, 500)
self.caption = "Pixuleco"
@background_image = Gosu::Image.new("wallpaper.jpg", :tileable => true)
@player = Player.new(0, 0, 340)
@money_bag = [... | true |
d3dcac0588b137e89620b2c87dbcad475ab1a2cc | Ruby | corroded/covetous | /lib/covetous/shen.rb | UTF-8 | 407 | 2.703125 | 3 | [
"MIT"
] | permissive | module Covetous
class Shen
include HTTParty
attr_accessor :url, :response
def initialize(url_option, extra_options={})
@response = self.class.get @url
end
def method_missing(name, *args, &block)
camelcased_key = name.to_s.camelize(:lower)
if @response.has_key?(camelcased_key)
... | true |
c04baab52b2893a60dfab346aab74d933ea6b86f | Ruby | okapce/Ruby-studies | /projects/loadType.rb | UTF-8 | 470 | 2.890625 | 3 | [] | no_license | require "open-uri" # Allows us to send GET requests and receive the response
require "json" # Allows us to parse the reponse into a JSON object/hash
def load_types(type_get)
begin
URI.open("https://pokeapi.co/api/v2/type/"+type_get.to_s+"/").read
rescue OpenURI::HTTPError
puts "Error: No se pudo conect... | true |
9a1bf4c2aadb7b315ed7d29618b96fbab95265bf | Ruby | RedBeardTech/spellchecker | /lib/spellchecker.rb | UTF-8 | 1,324 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class Spellchecker
require 'net/https'
require 'uri'
require 'rexml/document'
ASPELL_WORD_DATA_REGEX = Regexp.new(/\&\s\w+\s\d+\s\d+(.*)$/)
@@aspell_path = "aspell"
def self.aspell_path=(path)
@@aspell_path = path
end
def self.aspell_path
@@aspell_path
end
def self.check(text,... | true |
f095236657bfc4732e5394a363988b69e97a8b22 | Ruby | zubairshams/foosball | /app/models/user.rb | UTF-8 | 1,103 | 2.546875 | 3 | [] | no_license | class User < ActiveRecord::Base
has_and_belongs_to_many :teams
validates :first_name, :last_name, presence: true
def full_name
"#{first_name} #{last_name}"
end
def self.stats
query = <<-SQL
SELECT u1.id,
concat(u1.first_name, ' ', u1.last_name) AS name,
coalesce(u2... | true |
723e1fe4bae3e11b0631e987da34ea4cc1aeb19c | Ruby | javatarz/the-eod-machine | /app/models/team_location.rb | UTF-8 | 960 | 2.765625 | 3 | [] | no_license | class TeamLocation < ApplicationRecord
belongs_to :team
validates :name, presence: true
validates :time_zone, presence: true
validate :eod_time_must_be_valid_time, :eod_time_must_be_at_valid_minute
def self.with_eod_time_near(team_locations, utc_time)
team_locations.select do |team_location|
team_... | true |
1568135021099ac469eeb2c1c82958b19cd9a641 | Ruby | payscale/logstash-codec-fieldselect | /lib/logstash/codecs/fieldselect.rb | UTF-8 | 1,592 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | # encoding: utf-8
require "logstash/codecs/base"
require "logstash/codecs/line"
class LogStash::Codecs::Fieldselect < LogStash::Codecs::Base
# This codec will select only the fields listed or default
# to only selecting message
#
# input {
# stdin { codec => fieldselect { fields => [] }
# }
#
# or
... | true |
6167fa7e308a523b11a1d336504433108223808b | Ruby | lyntco/wdi_melb_homework | /gumballs/joshua_richardson/wk1d5/happitails/main.rb | UTF-8 | 2,119 | 3.890625 | 4 | [] | no_license | require "pry"
require_relative 'client'
require_relative 'shelter'
require_relative 'animal'
def seperator
puts "------------------------------------------------------"
end
# empty array to store all the data
# shelter = []
# hashes to use as placeholders
a1_details = {
name: "Peeekaaaaa",
age: 123,
gender... | true |
1b226f7870a84a89de9d35d0fae3a3598abd602f | Ruby | davey-e/project1_week5_money_cashboard | /models/transaction.rb | UTF-8 | 3,090 | 3.15625 | 3 | [] | no_license | require('date')
require_relative('../db/sql_runner')
class Transaction
attr_reader :id
attr_accessor :transaction_date, :amount, :tag_id, :vendor_id
def initialize(options)
@id = options['id'].to_i if options['id']
@transaction_date = Date.parse(options['transaction_date'])
@amount = options['amoun... | true |
5d55f3299915d9400b6935564004d8bf695e1b8f | Ruby | hbellows/smooth_move | /app/services/data_usa_client_helper.rb | UTF-8 | 1,069 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
module DataUsaClientHelper
def city_overview
CityData.new(find_city_overview).data
end
def city_stats
CityData.new(find_city_stats).data
end
def transportation_stats
CityData.new(find_transportation_data).data
end
def ethnicity_stats
CityData.new(find_eth... | true |
7912aa88d8c2c7eb7d9a4e645665bab5ca3ad397 | Ruby | OutWooods/student_directory | /Pine_exercises.rb | UTF-8 | 882 | 3.546875 | 4 | [] | no_license | #Programme Logger
#Attempt at the programme logger form Chris Pine
#https://pine.fm/LearnToProgram/chap_10.html exercise 2
@padding = ""
def programme_logger (programme,proc)
padding_length = 2
puts "#{@padding}#{programme} has started at #{Time.now}"
@padding += " " * padding_length
proc.call
@paddin... | true |
ae693d83308c706a211fa541cbb1ef0af42db811 | Ruby | CharlesAMoss/ruby-tools | /card.rb | UTF-8 | 536 | 3.6875 | 4 | [] | no_license | puts
puts "lets make a card"
puts
print "How about a picture? (image url)"
image = gets.chomp
print "Who is in the picture? (alt and title info)"
who = gets.chomp
print "give them a rank ( B | A | S )"
rank = gets.chomp.upcase
puts
puts "<div class=\"wrapper\">"
puts
puts "<div class=\"card\">"
puts "<img s... | true |
e10a54848b07bec9c5fa1d604c4bd3a1a9fc939c | Ruby | dwyn/yield-and-blocks-001-prework-web | /lib/hello.rb | UTF-8 | 270 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # def hello_t(arg)
# homies = arg
# homies.each do |name|
# if name.start_with?("T")
# puts "Hi, #{name}"
# else
# puts
# end
# end
def hello_t(arg)
arg.each do |name|
if name.start_with?("T")
puts "Hi, #{name}"; end
end
end
# hello_t(array)
| true |
dc9f823a3c89fe007ebcf78e44316f39de024373 | Ruby | alpendergrass/montanacycling-racing_on_rails | /app/models/competitions/tabor_overall.rb | UTF-8 | 1,794 | 2.515625 | 3 | [
"Ruby",
"MIT"
] | permissive | class TaborOverall < Overall
def TaborOverall.parent_name
"Mt. Tabor Series"
end
def default_bar_points
1
end
def create_races
races.create!(:category => Category.find_or_create_by_name("Fixed Gear"))
races.create!(:category => Category.find_or_create_by_name("Category 4 Women"))
races.c... | true |
a12525af631fb45efb22d7205924dceaabc2a304 | Ruby | snowe2010/computer_simulation_projects | /lady_bug_game_no_gem/lady_bug_game/tiles/home_tile.rb | UTF-8 | 217 | 2.78125 | 3 | [] | no_license | class HomeTile < GameBoard
attr_reader :name, :text
def initialize gameboard
@name = "Home"
@text = "Home tile"
@gameboard = gameboard
end
def run
@gameboard.player.winner = true
end
end
| true |
5843ff89aa76e82c8852dfaa331c2ef051e381b3 | Ruby | ChapterHouse/rtanque_play | /bots/the_clan/advanced_tank.rb | UTF-8 | 2,410 | 2.71875 | 3 | [] | no_license | require_relative 'simple_tank'
require_relative 'hostiles'
module AdvancedTank
include SimpleTank
attr_writer :autoload_shells
def aquire_target
self.target = hostiles.closest(self)
if target.nil?
@target_aquired = false
else
@target_aquired = true
target_aquired
track_targ... | true |
7e616bd359f89e31c501abfa6007e43374624b52 | Ruby | Morozzzko/benchmarking-ruby | /benchmarks/do-vs-transaction/do.rb | UTF-8 | 470 | 2.515625 | 3 | [] | no_license | require 'dry-monads'
module DoVsTransaction
class Do
include Dry::Monads::Do.for(:call, :plus_two, :conditional_exit, :times_two)
include Dry::Monads
def call(value)
multiplied = yield times_two(value)
if multiplied > 100
yield Failure("it exceeded 100")
end
yield plus_... | true |
6aa643338b686081175c8bed57cb29db40b055d4 | Ruby | zeteticl/udonarium | /src/src_bcdice/diceBot/KillDeathBusiness.rb | UTF-8 | 107,493 | 2.53125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
# frozen_string_literal: true
class KillDeathBusiness < DiceBot
# ゲームシステムの識別子
ID = 'KillDeathBusiness'
# ゲームシステム名
NAME = 'キルデスビジネス'
# ゲームシステム名の読みがな
SORT_KEY = 'きるてすひしねす'
# ダイスボットの使い方
HELP_MESSAGE = <<INFO_MESSAGE_TEXT
・判定
JDx or JDx+y or JDx-y or JDx,z or JDx+y,z JDx-y,z
(x... | true |
8d303ea83a2fb3fee1879c69318a9f0838d722d3 | Ruby | MyNameIsSpencer/Friday_Nov16_exercises | /real_friday_exercises.rb | UTF-8 | 2,732 | 3.734375 | 4 | [] | no_license | require 'date'
require 'active_support'
require 'active_support/core_ext'
require 'holidays'
class Cohort
FIRST_COFFEE_CODE_WEEK = 3
LAST_COFFEE_CODE_WEEK = 10
WEEKS_IN_COHORT = 10
def initialize(first_day)
@first_day = first_day
end
def last_day
@first_day + (WEEKS_IN_COHORT - 1).weeks + 4.d... | true |
cd9c34c4ee502bea5bd83fc9a3913f7e718de69e | Ruby | caffo/boardgame-proto | /lib/challenge.rb | UTF-8 | 217 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | class Challenge < Hash
def initialize(initial_values)
self.merge!(initial_values)
end
def solve
result = instance_eval &self[:solve]
self[:card].to(self[:discard_to])
return result
end
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.