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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c3809ed8cebfb0e7722dda132d3532e1eaf6a496 | Ruby | nygardryan/neuralNetworkSimpleFollow | /outputNeurons.rb | UTF-8 | 1,975 | 3.234375 | 3 | [] | no_license | require_relative 'neuron'
require 'ruby2d'
require_relative 'thing'
class IncreaseXNeuron < Neuron
def fire
@chargeBias = @charge - @bias
if sigmoid(@chargeBias) > 0.5
@parentThing.changeX(1)
@didFire = true
else
@didFire = false
end
@charge = 0
end
def checkIfFiredCorrectl... | true |
1ca302b65551a3afee437cbf0dfb5e9d874e5f66 | Ruby | VinsonWang92/T1A3---Vinson | /add_income.rb | UTF-8 | 568 | 3.21875 | 3 | [] | no_license | module Income
def add_income
puts 'What is your net monthly income?'
income = gets.chomp
begin
income = Integer(income)
rescue ArgumentError, TypeError
puts "Invalid input, please retry adding income and input integers only"
return income = nil ... | true |
9ef346aad1f2f8b0dd612ab277516570dd82e518 | Ruby | juanmanuelramallo/sistemas-distribuidos-paralelos | /Entregable 2/cuatro.rb | UTF-8 | 1,645 | 3.390625 | 3 | [] | no_license | if ARGV.count < 5
puts "Missing arguments"
puts "\t * N cantidad de elementos del vector"
puts "\t * MAX_NUM numero maximo de cada elemento del vector"
puts "\t * X elemento a buscar ocurrencias"
puts "\t * T cantidad de threads"
puts "\t * I imprime?"
return
end
N = ARGV[0].to_i
MAX_NUM = ARGV[1].to_i
X... | true |
d60a2bf8708c4f5277b60069c73fc552803bd94b | Ruby | completelynovel/pdfcheck | /lib/pdfcheck/reader.rb | UTF-8 | 2,854 | 2.703125 | 3 | [] | no_license | module PDFcheck
class Reader
attr_accessor :details, :xml
attr_accessor :fonts, :colors, :metadata, :security, :pages, :pages_info
# PDFCheck.new(file_path, option)
# options
# - :pdfcheck_path #=> path to pdfcheck bin
# - :tmp_dir #=> path to a tmp directory to store xml output
# - :ke... | true |
2a241b7dc5db2e183f895f7d31a1a2a86ccdeefd | Ruby | studentinsights/studentinsights | /app/lib/flat_exporter.rb | UTF-8 | 754 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'csv'
# For exporting nested json as a flat CSV
class FlatExporter
def csv_string(json_rows)
return '' if json_rows.size == 0
row_hashes = json_rows.map {|row| flatten(row) }
header_row = row_hashes.first.keys # all rows should have the same shape
body_rows = row_hashes.map {|row_hash| row_h... | true |
f9cc72654f71c68729a737405c6bc60f461c5670 | Ruby | defunkt/choice | /examples/ftpd.rb | UTF-8 | 1,536 | 2.5625 | 3 | [
"MIT"
] | permissive | $:.unshift "../lib"
$:.unshift "lib"
require 'choice'
port = 21
PROGRAM_VERSION = 4
Choice.options do
#banner "Usage: ftpd.rb [options]"
header ""
header "Specific options:"
option :host do
short '-h'
long '--host=HOST'
desc "The hostname or ip of the host to bind to"
desc "(default 127... | true |
a5bfa6bb5734470431b1d03bcee57adb0ac0825c | Ruby | awong-dev/cantonese-tools | /romanization_util.rb | UTF-8 | 3,879 | 3.109375 | 3 | [] | no_license | #!/usr/bin/ruby -w
require 'romanization_util_data'
SPLIT_NUM = /([a-zA-Z]+)(\d.*)/
SPLIT_CANTODICT_TONE = /(\d)(\*\d)?/
def split_tone(phonetic)
phonetic =~ SPLIT_NUM
phoneme = $1
tone = $2
return phoneme, tone
end
def yale_tone_mark_to_jyutping(yale_tone_mark)
jyutping = YaleMark2Jyutping[yale_tone_mark... | true |
5214c3f3af4afb9c872ddaef4880668dc23ec57d | Ruby | jmrada14/projectEuler | /ruby/even_fibonacci_numbers.rb | UTF-8 | 550 | 3.546875 | 4 | [] | no_license | # frozen_string_literal: true
# Project Euler exercises - Problem 2
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the
# first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose value... | true |
2deec2551f097035baafb5d7ee58e96e073b4373 | Ruby | zach/letsjam | /lib/letsjam/runner.rb | UTF-8 | 1,966 | 2.90625 | 3 | [
"MIT"
] | permissive | # Based on https://github.com/endel/googlecodejam
module LetsJam
class Runner
def initialize(options={})
instance = self.initialize_from_path(options[:source])
test_cases = read(instance, IO.read(options[:input]).split($/))
options[:output] ||= options[:input].gsub('.in', ".out")
if test... | true |
1a0aae991b02a47413b5d4a5df9470699cee3832 | Ruby | Pragmaticpraxis37/Battleship | /test/board_test.rb | UTF-8 | 4,539 | 3.21875 | 3 | [] | no_license | require "minitest/autorun"
require "minitest/pride"
require "./lib/cell"
require "./lib/ship"
require "./lib/board"
class BoardTest < Minitest::Test
def setup
@board = Board.new
@cruiser = Ship.new("Cruiser", 3)
@submarine = Ship.new("Submarine", 2)
end
def test_test_it_exists
assert_instance_of... | true |
7348a0affb1fb42ebc04415e4075a8ded071d01d | Ruby | hhoopes/black_thursday | /lib/item.rb | UTF-8 | 391 | 2.640625 | 3 | [] | no_license | class Item
attr_reader :id, :name, :description, :unit_price, :merchant_id, :created_at, :updated_at
def initialize(data)
@id = data[:id]
@name = data[:name]
@description = data[:description]
@unit_price = data[:unit_price]
@merchant_id = data[:merchant_id]
@created_at... | true |
db0c03c5061d0364022212fd02b119e9d3b2f7e8 | Ruby | blythos/budget_tracker | /models/specs/tag_spec.rb | UTF-8 | 381 | 2.703125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative("../Tag.rb")
class TestTag < MiniTest::Test
def setup()
@tag1 = Tag.new({
'id' => 1,
'name' => 'groceries'
})
end
def test_get_name()
result = @tag1.name
assert_equal('groceries', result)
end
def test_get_id()
... | true |
c2cbe67ad6baa5aa5300928402f4d0a3014d1e87 | Ruby | sul-dlss-deprecated/cocina-food-inspector | /app/services/cocina_druid_retriever.rb | UTF-8 | 3,385 | 2.640625 | 3 | [] | no_license | require 'fileutils'
class CocinaDruidRetriever
attr_reader :druid
def initialize(druid)
@druid = druid
end
def self.try_retrieving_unseen_druids(max_to_retrieve: Settings.max_unseen_druids_to_retrieve)
Druid.unretrieved.limit(max_to_retrieve).find_each { |druid| try_retrieval_and_log_result(druid.dru... | true |
920b45fd3f3f84e5851dd84af3c618453fd188c7 | Ruby | tanyafn/search | /ui.rb | UTF-8 | 1,541 | 3.234375 | 3 | [] | no_license | # frozen_string_literal: true
require 'readline'
class UI
WELCOME_MESSAGE = %(
********************************************************************
Welcome to Snoopy App: almost-elasticsearch app! 🐶
********************************************************************
Snoopy is good at find... | true |
a4159f4f454ce726c2ac97ceecb7add9428cf327 | Ruby | Lavinia/Nemah | /lib/nemah/specific_need/abstract_need.rb | UTF-8 | 974 | 3.125 | 3 | [
"MIT"
] | permissive | module Nemah
module SpecificNeed
class AbstractNeed
attr_reader :need
def initialize(need)
@need = need
end
def ideal(decimals: 2)
_ideal.round(decimals)
end
def min(decimals: 2)
_min.round(decimals)
end
def max(decimals: 2)
_max.... | true |
3d3112e05fc1f81141370800ec49d543f4a1a9da | Ruby | jack604/rc1 | /book/ch9/yamlexperimentwrite.rb | UTF-8 | 681 | 3.46875 | 3 | [] | no_license | require 'yaml'
myarray=["hello", "some", "more", "words"]
myhash=[key1: "value1", key2: "value2", key3: myarray]
puts myhash
out=File.open("out2.yaml", "w")
yamldata=YAML::dump(myarray)
puts yamldata
yamldata2=YAML::dump(myhash)
puts yamldata2
out.write(yamldata2)
#Ok, men sedan när man ska läsa tillbak... | true |
c617a2e9790993b18a3c81535912476521f031ef | Ruby | Reivnaj/TicTacToe_ruby | /app.rb | UTF-8 | 712 | 3.046875 | 3 | [] | no_license | require 'bundler'
Bundler.require
$:.unshift File.expand_path('./../lib', __FILE__)
require 'app/player.rb'
require 'app/game.rb'
require 'app/board.rb'
require 'app/board_case.rb'
def start_game
puts 'Bienvenue dans le meilleur jeu de Morpion du MONDE !'
puts 'Joueur 1, quel est ton prénom ?'
print '> '
player_1... | true |
70ecb10bde6b6146fbb0d07ec4731c2d4b513284 | Ruby | Cdunagan05/night_writer | /test/translate_test.rb | UTF-8 | 769 | 2.734375 | 3 | [] | no_license | gem 'minitest', '~> 5.0'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
require './lib/night_write'
require './lib/translate'
class TranslateTest < Minitest::Test
def test_it_exists
assert Translate
end
def test_it_translates_a_lcase_letter
writer = NightWrite.new
translate =... | true |
edd9f075b1919d48eeea2741a0d528db57b4e8ce | Ruby | MunkiPhD/kata-five | /bloom_filter_spec.rb | UTF-8 | 827 | 3.109375 | 3 | [] | no_license | require_relative 'bloom_filter.rb'
describe BloomFilter do
context 'is in set' do
let(:set) { ["one", "two", "three", "four", "five"] }
it 'returns true' do
bloom = BloomFilter.new(set, 100, 2)
expect(bloom.is_in_set?("one")).to be_true
end
it 'returns a false positive' do
bloom = BloomFilter.new(s... | true |
414067eb6419e459ab2a559b25b899467afff631 | Ruby | TonyNarisi/phase-0-tracks | /ruby/list/todo_list.rb | UTF-8 | 287 | 3.3125 | 3 | [] | no_license | class TodoList
def initialize(items)
@items = items
end
def get_items
@items
end
def add_item(new_item)
@items << new_item
end
def delete_item(another_item)
@items.delete(another_item)
@items
end
def get_item(index)
@items[index]
end
end | true |
ac10535a8b6510478982cd02daed44c1da029600 | Ruby | GeopJr/Granz_bot | /lib/modules/commands/rate.rb | UTF-8 | 593 | 2.59375 | 3 | [
"MIT"
] | permissive | module Granz::DiscordCommands
module Rate
extend Discordrb::Commands::CommandContainer
command :rate, min_args: 1 do |event, *rating|
begin
arr = %w[0 1 2 3 4 5 6 7 8 9 10]
message = rating.join(" ")
event.channel.send_embed do |embed|
embed.colour = 0xffff00
... | true |
81c84d129c23fb27408a0b9586ba4650cb7ff2d2 | Ruby | hotsdm/Python_ruby | /Function/5.rb | UTF-8 | 481 | 3.546875 | 4 | [] | no_license | # ids = ['har', 'space', 'SDM']
# for id in ids do
# if id == input_id
# puts('Hello!, ' +id)
# exit
# end
# end
# puts('who are you?')
puts("아이디를 입력해주세요.")
input_id = gets.chomp()
def login(id)
members = ['har', 'space', 'SDM']
for member in members do
if member == id
... | true |
51503b22bd0a9cf8e6c6ca21128ce7d75ed7f2f2 | Ruby | TempYoshiji/koolicar_test | /lib/rental_tracked_position_csv_importer.rb | UTF-8 | 2,355 | 3.0625 | 3 | [] | no_license | # This class could be located at lib/importers/rental_tracked_position_importer.rb
# This folder lib/importers/* would contain Importer classes
require 'csv'
class RentalTrackedPositionCsvImporter
attr_accessor :rental, :csv_uploaded_file, :csv_parsed, :errors
def initialize(rental, csv_uploaded_file)
@rental... | true |
521ed8568c012254320c626e918ab210f85b893a | Ruby | lokibyte/myRubycode | /Ruby codes/Ruby Examples/sequl_relationships_examples/Dbdictionary.rb | UTF-8 | 2,839 | 3.40625 | 3 | [] | no_license | %w(rubygems sequel yaml).each {|a| require a }
# Database
DB = Sequel.sqlite ('G:\Ruby\MyWork\sequel\Database\dictionary.sqlite')
DB.create_table?:words do
primary_key :id
string :word,
:unique => true,
:null => false
string :meaning,
:null => false
end
class Words < Sequel::Model(:words)
end
... | true |
2e2a70bc46f1d9113ec724140068168d7ca1508c | Ruby | Albin-Willman/advent | /2017/2/task.rb | UTF-8 | 713 | 3.5 | 4 | [] | no_license |
class ChecksumCalculator
attr_accessor :row_evaluator
def initialize(row_evaluator)
@row_evaluator = row_evaluator
end
def run(input)
input.map { |e| row_evaluator.run(e) }.inject(0, :+)
end
end
class DifferenceRowEvaluator
def run(row)
row_data = row.gsub(/\s+/m, ' '... | true |
c3b5f7db08de616e14562e406e92c1967f391bf2 | Ruby | poojitha2512/sample | /t1.rb | UTF-8 | 168 | 3.421875 | 3 | [] | no_license | class Book
def initialize(name,p)
@author=name
@price=p
end
def display
puts @author
puts @price
end
end
bb=Book.new("poo",22)
bb.display
| true |
5ee18e6eec3ccbce9e17b8c748256e543daf99d6 | Ruby | wichru/pairguru | /app/validators/title_brackets_validator.rb | UTF-8 | 883 | 3.296875 | 3 | [] | no_license | class TitleBracketsValidator < ActiveModel::Validator
BRACKET_PAIRS = { '[' => ']', '{' => '}', '(' => ')' }
def validate(record)
string = record.title
if !empty_brackets?(string)
record.errors.add(string, "brackets cannot be empty")
elsif !closed_brackets?(string)
record.errors.add(string... | true |
a98efe70eab23cd73fb3c7698b4f4c9aabf7e77d | Ruby | sugahara/traffic_utility | /example/3sigma_anomaly_detection.rb | UTF-8 | 965 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'traffic_utility'
include AnomalyDetection
include Timeseries
timestamp_array=[]
no_anomaly_timewindow = Timewindow.new(100,1)
sigma_detector = Detector::Sigma.new(3.0)
result_array = []
data = File.open(ARGV[0],'r')
data_lines = data.readlines.delete_if{|v| v.include?("#")}
# Without timestamp
# data_line... | true |
fa3e62063325dd4ebba09d0efab0d5bc0456ff19 | Ruby | mikez321/enigma | /test/compiler_test.rb | UTF-8 | 2,993 | 3.15625 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require 'minitest/autorun'
require 'minitest/pride'
require './lib/compiler'
class CompilerTest < Minitest::Test
def setup
@compiler_shift = {
"a" => 3,
"b" => 27,
"c" => 73,
"d" => 20
}
end
def test_it_exists
compiler = Compiler.new("hell... | true |
b20e5a6d902f497d4fa44600c8a25a182eaf80e0 | Ruby | jasondecastro/werewolves | /app/models/round.rb | UTF-8 | 2,656 | 2.765625 | 3 | [] | no_license | class Round < ApplicationRecord
belongs_to :game
def play
# binding.pry
#refactor into case statement
if self.number == 1
round_1
elsif self.number == 2
round_2
end
end
def display_page(user)
if self.number == 1 && user.player.card.role == "Werewolf"
"'werewolf'"
... | true |
6f1b56d5bc8a9485dba697bb87cf87981b559039 | Ruby | ButeraMV/black_thursday | /test/invoice_item_test.rb | UTF-8 | 1,651 | 2.8125 | 3 | [] | no_license | require './lib/invoice_item'
require './test/test_helper'
class InvoiceItemTest < Minitest::Test
def test_it_exists
invoice_item = InvoiceItem.new(1, 54321, 4, 2, "2196",
"2016-01-11 09:34:06 UTC",
"2016-01-11 09:34:06 UTC",
... | true |
22a2e56a58d143525f765ced714aa5fcb5a6b451 | Ruby | lloeki/nanoserve | /lib/nanoserve.rb | UTF-8 | 5,599 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require 'socket'
require 'logger'
require 'time'
module NanoServe
class TCPResponder
def initialize(host, port, &block)
@host = host
@port = port
@block = block
@thr = nil
@srv = nil
end
def start(y)
@srv = TCPServer.new(@port)
... | true |
202fab2fd9d30587f8d59caba74c780c092ff435 | Ruby | keomony/learn-to-program | /chap07/ex3_table_of_content.rb | UTF-8 | 504 | 3.78125 | 4 | [] | no_license | #Start the program with an array holding all of the information for
#your table of contents (chapter names, page numbers, etc.). Then print out
#the information from the array in a beautifully formatted table of
#contents.
table_of_content = [["Numbers", 1], ["Letters", 72], ["Variables", 118]]
line_width = 50
puts("... | true |
55fd7f95745ce28f20f934c763c6e21a379c9227 | Ruby | MadBomber/bible_reference_parser | /lib/bible_reference_parser/metadata/bible_metadata.rb | UTF-8 | 1,546 | 3.578125 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'yaml'
module BibleReferenceParser
# This class encapsulates the metadata about a book's name and short name.
# It also holds info on the number of verses in each chapter. See metadata.yml for more details.
class BibleMetadata
class << self
# The metadata contents loaded from the yaml file.... | true |
12b023055b56872e048d232e423733286fc1774b | Ruby | anthrolisp/roam-tools | /roam_date.rb | UTF-8 | 1,056 | 3.390625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | require 'date'
module RoamDate
extend self
def roam_date_link(date, label_text=nil)
return "" if date.nil?
date_text = "[[#{roam_date(date)}]]"
return date_text if label_text.nil?
"[#{label_text}](#{date_text})"
end
def roam_date(date)
return "" if date.nil?
"#{Date::MONTHNAMES[dat... | true |
4a13e24539f159fcdafd09c4ace3a7055759cee8 | Ruby | Awlter/leetcode_algo | /basic_alro.rb | UTF-8 | 1,749 | 3.3125 | 3 | [] | no_license | # @param {String} s
# @return {Integer}
def calculate(s)
tokens = []
ops = []
number = ""
s << ' '
need_fit_zero = true
s.each_char do |c|
if c <= '9' && '0' <= c
number << c
need_fit_zero = false
elsif !number.empty?
tokens << number
number = ''
end
if c == "("
... | true |
4161bcdee3fac322bf2ffac7d62a5835dece986a | Ruby | kochoa76/ruby-object-attributes-lab-bootcamp-prep-000 | /lib/person.rb | UTF-8 | 136 | 2.703125 | 3 | [] | no_license | class Person
def name
@name
end
def name=(new_name)
@name= new_name
end
def job
@job
end
def job=(singer)
@job=singer
end
end | true |
664524e61dc8bd22368469f0ae26c1dfea0d5ca0 | Ruby | learn-co-students/nyc-clarke-web-100719 | /10-intro-to-mod2/runner.rb | UTF-8 | 223 | 2.515625 | 3 | [] | no_license | require 'sinatra'
get '/' do
'<h1>YOU MADE IT HOME</h1>'
end
get '/profile' do
'<h4>It is all about you it is your profile</h4>'
end
get '/profile/:variable' do
'<h4>It is all about you it is your profile</h4>'
end | true |
97f342a6adc71cd43dc0e131e6eb1bf9c8e2689f | Ruby | EzraMoore65/raylib-ruby | /lib/raylib/helpers/ffi_struct.rb | UTF-8 | 785 | 2.703125 | 3 | [
"MIT"
] | permissive | module FFI
class Struct
def self.ray_struct_accessor(*attrs)
attrs.each do |attr|
define_method attr do
self[attr]
end
define_method "#{attr}=" do |val|
self[attr] = val
end
end
end
def self.ray_struct_init_accessor(*attrs)
ray_struct_... | true |
1eba684eb2be827c72e7b91fc214fc46df4cd718 | Ruby | luna3p/Ruby | /05配列ハッシュ正規表現/arraysize.rb | UTF-8 | 90 | 2.84375 | 3 | [] | no_license | class Arraysize
a=[1,2,3,4,5]
#配列名.size で配列の大きさ
print a.size
end | true |
507506bb235bddd308fb280b1352c654602ccecd | Ruby | cristobalparedesn/Desafios-Ruby | /Desafio-Ciclos/lorem_generator.rb | UTF-8 | 515 | 3.40625 | 3 | [] | no_license | =begin
Crear un programa llamado lorem_generator.rb en ruby que sea capaz de mostrarn en pantalla
varios parrafos de Lorem ipsum, donde el número de párrafos se especifica al cargar el script. (El
texto puede ser extraído del primer párrafo de https://www.lipsum.com/feed/html)
Uso:
ruby lorem_generator.rb
Lorem ipsu... | true |
4ac88d4dbc9128852cbd37b801c62a169b85951a | Ruby | rverdin/Gosu-Project | /main.rb | UTF-8 | 2,238 | 2.828125 | 3 | [] | no_license | require 'Gosu'
require 'Sprite'
require 'Background'
include Gosu
class Game < Gosu::Window
def initialize
super(800, 600, false)
@cursor = Gosu::Image.new(self, 'media/cursor.png')
@menu = Background.new(self, 'media\\menu.png')
@title = Sprite.new(self, 'media\\title.png')
#charact... | true |
b85b68789df3e2eb2b3310701dbcdf96913aade9 | Ruby | eric-reale/mealscope | /app/models/cuisine_tag.rb | UTF-8 | 694 | 2.546875 | 3 | [] | no_license | class CuisineTag < ApplicationRecord
CUISINE_TAG = ['Algerian', 'American', 'Belgian', 'Brazilian', 'British', 'Cajun', 'Canadian', 'Caribbean', 'Chinese', 'Cuban', 'Egyptian', 'French', 'German', 'Greek', 'Hawaiian', 'Haitian', 'Indian', 'Irish', 'Italian', 'Japanese', 'Jewish', 'Kenyan', 'Korean', 'Latvian', 'Leba... | true |
517862fbb969fe71aab821c3500e6c5939a225ba | Ruby | MarciClark/yield-and-blocks-online-web-pt-011419 | /lib/hello.rb | UTF-8 | 181 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def hello_t(array)
i = 0
end
while i < array.length
yeild (array[i])
i = i + 1
end
array
end
hello_t(["Tim", "Tom", "Jim"]) do |name|
if name.start_with?("T")
puts "Hi, #{name}"
| true |
0d35604cc3445f5cbcfbd34972a457f85c7875e9 | Ruby | salo18/rb100_exercises | /9_Conditionals/e9.rb | UTF-8 | 327 | 4.40625 | 4 | [] | no_license | # Currently, "5 is a cool number!" is being printed every time the program is run.
# Fix the code so that "Other numbers are cool too!" gets a chance to be executed.
number = rand(10)
puts number
if number == 5
puts '5 is a cool number!'
else
puts 'Other numbers are cool too!'
end
# line 8 was missing == instea... | true |
f3426b39a24f8bbe1f52fbbe6ca8fe2222d48065 | Ruby | Tetsuya-Nagsako/ruby-sample1 | /hello.rb | UTF-8 | 2,417 | 3.953125 | 4 | [] | no_license | puts "hello ruby !!!!!"
puts "Branding Engineer"
puts "Hello"
puts "HR Tech"
puts "1"
puts "2"
puts "3"
puts "1"+"2"+"3"
puts 2 + 2
date = 20201221
p date
fruits = ["apple", "mellon", "banana", "srawaberry"]
p fruits
p fruits[0]
p fruits[1]
p fruits[2]
p fruits[3]
applle = { name: "りんご", price: 100 }
p applle[:name]
p ... | true |
07a9b1dfd5cc585d988f815447d8eb19400c63dc | Ruby | 500friends/name_drop | /lib/name_drop/error.rb | UTF-8 | 757 | 2.78125 | 3 | [
"MIT"
] | permissive | # Namespace for classes and modules that handle interaction with Mention API
#
# @since 0.1.0
module NameDrop
# Custom Error for NameDrop
#
# @since 0.1.0
class Error < StandardError
# Stores additional details of Error typically reflecting errors returned in Mention API response
#
# @!attribute [r]... | true |
18c6395dedf6865d8770cac53e185aeb779321e7 | Ruby | adamcooke/authie | /lib/authie/session_model.rb | UTF-8 | 4,148 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'active_record'
require 'securerandom'
require 'authie/config'
module Authie
class SessionModel < ActiveRecord::Base
attr_accessor :temporary_token
self.table_name = 'authie_sessions'
belongs_to :parent, class_name: 'Authie::SessionModel', optional: true
scop... | true |
53feea6e4125af2b001b850fde613a5ffdd6d324 | Ruby | glenpike/microbit-midi | /ruby/src/midi-input-test.rb | UTF-8 | 473 | 2.9375 | 3 | [] | no_license | require 'unimidi'
@input = UniMIDI::Input.gets
def print_exception(exception, explicit)
puts "[#{explicit ? 'EXPLICIT' : 'INEXPLICIT'}] #{exception.class}: #{exception.message}"
puts exception.backtrace.join("\n")
end
begin
loop do
midi = @input.gets
puts "midi: #{midi}"
sleep(0.1)
end
rescue Int... | true |
c3d8f4a08fc361812b5a57a6eedc2fb355b79aca | Ruby | bilalbash/expenser | /app/models/line_item.rb | UTF-8 | 619 | 2.890625 | 3 | [] | no_license | class LineItem < ApplicationRecord
belongs_to :category
belongs_to :item
validates :purchase_date, :price, presence: true
before_create :save_purchase_info
def save_purchase_info
self.purchase_month = self.purchase_date.month
self.purchase_week = self.week_number
end
def week_number
day = ... | true |
dd86850bf23bbaa42a83c442271152711246acf8 | Ruby | Jarrod-Alford/Small_Problems | /Easy_8/double_char_part_1.rb | UTF-8 | 206 | 3.484375 | 3 | [] | no_license | def repeater(str)
output = ''
str.each_char { |char| output << char * 2 }
output
end
puts repeater('Hello') == "HHeelllloo"
puts repeater("Good job!") == "GGoooodd jjoobb!!"
puts repeater('') == ''
| true |
680693ad7d38eedbf486d2aefa3e07578bae0ef2 | Ruby | johnwilde/polaris | /lib/polaris.rb | UTF-8 | 3,797 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'polaris/version'
require 'algorithms'
require 'pry'
include Containers
# Polaris is a star that guides, aka "The North Star". It implements the A* algorithm.
class Polaris
attr_reader :nodes_considered
def initialize(map)
@map = map
@nodes_considered = 0
end
# Returns the path without the ... | true |
1ebf23f88042473d27553b23fa78009c6c6602e8 | Ruby | ugifractal/ptool | /profligacy/swing.rb | UTF-8 | 8,489 | 3.015625 | 3 | [] | no_license | require 'java'
import 'javax.swing.SwingUtilities'
# Profligacy is a library that helps to build Swing GUIs without getting the
# way of the huge number of components and options available. The approach
# taken by Profligacy is to be a purposefully leaky abstraction. Rather than
# try to cover all the possible con... | true |
c1f9cb29a0f612508d149fe394accbcac84d184b | Ruby | albertbahia/wdi_june_2014 | /w03/d03/james_liu/hw_w03_d03/hamnet.rb | UTF-8 | 641 | 2.671875 | 3 | [] | no_license | require 'sinatra'
require'sinatra/reloader'
get '/welcome' do
erb(:welcome)
end
get '/calc' do
erb(:calc)
end
post '/calculate' do
first_number = params[:first_number].to_i
math_operation = params[:math_operation]
second_number = params[:second_number].to_i
case math_operation
when '+... | true |
7e436ae50e0f604a298ea1bf89066c62be1b705e | Ruby | moisesnarvaez/epayco | /lib/epayco/client/plans.rb | UTF-8 | 4,366 | 2.75 | 3 | [
"MIT"
] | permissive | module EPayCo
class Client
# Defines methods related to Plans
module Plans
# Returns all the Plans registered
#
# @format :json
# @return [Array]
# @example All the Plans
# [
# {
# "id_plan": "cursocarpinteria",
# "object": "plan",
... | true |
90087fc375433ad194e496c5868eacc71f5eb98a | Ruby | Zouz84/Nokogiri | /mairies.rb | UTF-8 | 2,877 | 3.171875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
#<====== Recupere L'adresse mail sur la page annuaire-des-mairies.com/95/vaureal.html ===>
#======== Va chercher les liens dans la balise ========
def get_all_the_urls_of_val_doise_townhalls
page1 = Nokogiri::HTML(open("http://annuaire-des-mairies.co... | true |
46e9066a6f39b91d6233fe09ab890e3b2ae0e3ef | Ruby | smurfik/dress_up | /app/models/product_option.rb | UTF-8 | 327 | 2.5625 | 3 | [] | no_license | class ProductOption < ActiveRecord::Base
belongs_to :product
validates :name, presence: true
validates :price_in_cents, presence: true, numericality: { only_integer: true }
def dropdown_view
"#{name} #{formatted_price}"
end
def formatted_price
price = price_in_cents/100.to_f
"$#{price}"
en... | true |
8de267f75029a2e29411d56b6a73b47d0faec366 | Ruby | josh-lauer/bork | /lib/bork/status.rb | UTF-8 | 1,411 | 2.6875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | module Bork
class Status
attr_accessor :raw_result, :finished, :attempted, :completed
def unattempted?
!attempted?
end
# whether running the test file has been attempted, regardless of outcome
def attempted?
!!attempted
end
# whether the test has run to completion and gotten... | true |
a38013f3fcaeede6aaa996943246183b3670d623 | Ruby | GEROMAX/ruby_learning_sample | /lib/data_cache.rb | UTF-8 | 382 | 2.671875 | 3 | [] | no_license | module DataCache
FILE_ENCODE = "ASCII-8BIT"
def dump(data, file_name)
dmp = Marshal.dump(data)
offset = 0
while offset < dmp.size
offset += IO.write(file_name, dmp[offset..(offset + 999_999)], offset, encoding: FILE_ENCODE)
end
end
def load(file_name)
dmp = File.read(file_name, encod... | true |
5dc7d74f7c42705c200ff401ea1843fcaa6ae907 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/5e03fb479ffb4c7eac654867f49050b5.rb | UTF-8 | 110 | 2.921875 | 3 | [] | no_license | require 'time'
require 'date'
class Gigasecond
def self.from(birthday)
return birthday + (10**9)
end
end
| true |
2d70bf4910fd4c79e422d3a7081060293881b676 | Ruby | alex-solo/ruby-problems | /Medium 1/stack_machine_interpretation.rb | UTF-8 | 1,566 | 3.875 | 4 | [] | no_license | =begin
- input: string of commands(numbers, and words)
- output: numbers
- depending on command, print values of operations or value of register
Algorithm:
- main method (interpreter)
- take string and split into elements.
ex. commands = '5 PUSH 3 MULT PRINT'.split
- iterate through array - each ... | true |
497a49ce4d7cd34384d136dce9700f61e4df0548 | Ruby | shadow3x3x3/tfaim-manger | /tfaim_web.rb | UTF-8 | 5,910 | 2.578125 | 3 | [] | no_license | # coding: utf-8
require 'sinatra'
require 'sinatra/reloader'
require 'tilt/erb'
require 'pry'
require_relative 'src/reader'
### Configure && Initialize ###
configure do
set :concentrations, {}
set :additives, nil
end
before do
@base_intake = Reader::intake
@food_list = Reader::food_list
end
### Routing &... | true |
e5c1028eb9de04d38b82b9c90e8c10576a419842 | Ruby | rvna/tumbldr | /app/models/tumblr_user.rb | UTF-8 | 224 | 2.875 | 3 | [] | no_license | class TumblrUser
attr_reader :name
def initialize(raw_user)
@name = raw_user['name']
@raw_blogs = raw_user['blogs']
end
def blogs
@raw_blogs.map do |raw_blog|
Blog.new(raw_blog)
end
end
end
| true |
a6bac93e36dfc13567de120793c479189db024e8 | Ruby | duckinator/inq | /lib/inq/text.rb | UTF-8 | 582 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Inq
##
# Helper class for printing text, but hiding it when e.g. running in CI.
class Text
def self.show_default_output
@show_default_output = true unless
instance_variable_defined?(:"@show_default_output")
@show_default_output
end
def self.s... | true |
166e7c9aed8e31f8e89b6c32a786241eb35f63e6 | Ruby | sukki07/serenity_now | /dsalgo/list/reverse_list.rb | UTF-8 | 601 | 3.4375 | 3 | [] | no_license | require './list.rb'
def func_r(node,prev)
if node.next == nil
$head = node
node.next = prev
else
func_r(node.next,node)
node.next = prev
end
end
def func_i(head)
current = head
prev = nil
while(current.next!=nil)
ahead = current.next
current.next = prev
prev = current
current = ahead
end
cur... | true |
7a1f5b2bfff995c9765150158bb04adb2df8f08f | Ruby | HewlettPackard/oneview-sdk-ruby | /examples/shared_samples/id_pool.rb | UTF-8 | 3,977 | 2.75 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # (C) Copyright 2017 Hewlett Packard Enterprise Development LP
#
# 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 applicable law... | true |
0394e27cb49ca01ce79ec3a3b43e89debb235aac | Ruby | Hasimov/kindle-notes-exporter | /lib/book.rb | UTF-8 | 382 | 2.671875 | 3 | [] | no_license | class Book
attr_reader :attributes
def initialize(attributes)
@attributes = attributes
end # initialize(attributes)
def author
@author ||= attributes[:author]
end # author
def authors
author
end # authors
def title
@title ||= attributes[:title].strip
end # title
def clippings
... | true |
9b949e20baaa72fb388581d3d21ecc62c1db1a52 | Ruby | bcaller/uap-ruby | /spec/version_spec.rb | UTF-8 | 2,518 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe UserAgentParser::Version do
it "parses '1'" do
version = UserAgentParser::Version.new('1')
_(version.major).must_equal '1'
end
it "parses '1.2'" do
version = UserAgentParser::Version.new('1.2')
... | true |
170bb65286d6a74795b5de2e149007a2a61d4371 | Ruby | Pil3q/introductions-2 | /say_hello.rb | UTF-8 | 79 | 2.578125 | 3 | [] | no_license | puts "Hello Patryk!"
puts "Hello Gabriel!"
puts "Hello me!"
puts "hello again"
| true |
3b68160b0a665be800134cc2c0d5525d5359ba03 | Ruby | blazeinfosec/ActiveEvent | /ActiveEvent.rb | UTF-8 | 3,713 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | # ActiveEvent v1.0 - Burp Suite Etension
# Created by Tiago Ferreira - Security Engineering (tiago at blazeinfosec dot com)
# Blaze Information Security - http://www.blazeinfosec.com/
#
# Description: ActiveEvent is a plugin that will continuously monitor the Burp vulnerability scanner
# looking for new security issues... | true |
e855786a214672188f1db78ab5abb6928a9d8b48 | Ruby | wacekg/Cwiczenia | /cwiczenia.rb | UTF-8 | 8,120 | 3.546875 | 4 | [] | no_license | # ------------------------------------Choinka
# def choinka(margin, start, stop) #definicja metody 3 zmienne
# start.step(stop, 2) do |i| #pętla krok o 2 do stop
# print " " * margin #wydruj spacji margines podstawy piętra 1 zmienna
# print " " * ((stop - i)/2) #wydruk spacji od marginesu do g... | true |
0509acc02efa7cdb5c29d1419b136043a720f7b4 | Ruby | paradigmshift/weekly-challenges | /octal.rb | UTF-8 | 501 | 3.578125 | 4 | [] | no_license | class Octal
attr_accessor :oct_ary
def initialize(octal_str)
oct = octal_str.to_i.abs
begin
self.oct_ary = split_to_ary(oct)
# make sure no elements over the value of 7
self.oct_ary.all? { |e| e < 8 } ? true : raise
rescue
self.oct_ary = [0]
end
end
def split_to_ary(x)
... | true |
a8a30d0fa0e06ce610667c5980d2e09f20c6b938 | Ruby | sosuke119/TThouse | /app/bot/custom/controllers/bot_session_slot_controller.rb | UTF-8 | 8,276 | 2.609375 | 3 | [] | no_license | class BotSessionSlotController
attr_accessor :session_slots_objects, :session_slot_updated
def initialize(bot_message:nil,
session: nil,
session_slot: nil,
session_slots: nil,
processor: nil
)
@bot_message = bot_message
@session = session
@session_slot = session... | true |
4f56fdfac51868b668b5432050deb8d222441f1c | Ruby | turn2/apocryphal_antelope | /app/models/part.rb | UTF-8 | 1,066 | 2.8125 | 3 | [] | no_license | require 'fastercsv'
class Part < ActiveRecord::Base
validates_presence_of :part_name, :quantity, :total_sale_price, :part_number, :date_of_sale
validates_numericality_of :quantity, :only_integer => true, :greater_than => 0, :message => "must be a whole number greater than 0"
validates_numericality_of :total_sa... | true |
90eb34295c67e3553f9a8b61ef4d083b2424576a | Ruby | jfhinchcliffe/CoderFactoryAcademy2016Notes | /Coderfactory_Notes/Week2/customer1111.rb | UTF-8 | 1,281 | 3.796875 | 4 | [] | no_license | class Customer
def initialize(customer, hair_colour)
@customer = customer
@hair_colour = hair_colour
end
def print_customer_details
puts "Customer details:"
puts "Name: #{@customer['name']}"
puts "Starsign: #{@customer['starsign']}"
puts "Age: #{@customer['age']}"
puts "Hair colour: ... | true |
524fd8cd3c8489bc7ea073f273b557e7914fd270 | Ruby | rav-pradhan/compilations.ravii.dev | /app.rb | UTF-8 | 1,735 | 2.671875 | 3 | [] | no_license | require 'sinatra/base'
require 'sequel'
require 'pg'
require 'dotenv/load'
require_relative 'lib/gateway/books_gateway_sequel'
require_relative 'lib/use_cases/fetch_books'
require_relative 'lib/use_cases/fetch_book'
class App < Sinatra::Base
before do
cache_control :public, :max_age => 31536000
@database = ... | true |
775dd81a2580e804d7557d7ad83341af0de949ca | Ruby | AkashRana1/MyChat | /app/models/user.rb | UTF-8 | 352 | 2.546875 | 3 | [] | no_license | class User < ApplicationRecord
validates_uniqueness_of :username
def self.generate
adjectives = ['Ancient','Creative','Dengerous','Effective','Flying','Gilded']
nouns= ['Highway','Intern','Jackhammer','Lion','Master']
number= rand.to_s[2..4]
username = "#{adjectives.sample}-#{nouns.sample}-#{number}"
crea... | true |
7812ea5cb89742aeb4a463d04dd7254b6b4e864f | Ruby | rahulraj/virtual_keywords | /lib/spec/virtualizees/not_user.rb | UTF-8 | 101 | 2.703125 | 3 | [
"MIT"
] | permissive | class NotUser
def initialize value
@value = value
end
def negate
not @value
end
end
| true |
b010ad9d02fc320ae655c433406deedc6ffe0426 | Ruby | NickyEXE/die-roll-probabilities | /spec/die_roll_probabilities_spec.rb | UTF-8 | 603 | 3.09375 | 3 | [] | no_license | require_relative '../die_roll_probabilities.rb'
RSpec.describe "Die Rolls" do
it "can roll a die" do
result = roll_a_die(2)
expect(result).to be <=2
end
it "can roll multiple dice" do
result = roll_multiple_dice(2, 666)
expect(result[1] + result[2]).to eq 666
end
i... | true |
ccb2a4c38882fa15ef8d876524d238963c764bff | Ruby | paddyjoneill/wk2_weekend_homework | /specs/bar_spec.rb | UTF-8 | 1,192 | 3.046875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/reporters')
require_relative('../drink')
require_relative('../bar')
require('pry')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
class TestBar < MiniTest::Test
def setup
@beer = Drink.new("Beer", 4)
@redwine = Drink.new("Red Wine", 6)
@whi... | true |
8feebe12fb1c2800b5f3955413042861df3a0fb5 | Ruby | Mloweedgar/eloquent_ruby_code | /26/ex_7_private_with_class_meth_spec.rb | UTF-8 | 1,162 | 2.5625 | 3 | [] | no_license | require '../utils/rspec_utils'
require 'structured_document'
require 'structured_doc_def_method'
class StructuredDocument ##(main
# Rest of the class omitted...
def self.disclaimer
"This document is here for all to see"
end
def self.privatize
private :content
def self.disclaimer
... | true |
832f930144f225295799219c933a31058012e646 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/a942eec772e1418584102a19671df050.rb | UTF-8 | 299 | 3.4375 | 3 | [] | no_license | class Phrase
def initialize(value)
@string_value = value.to_s
end
def word_count
words = Hash.new(0)
normalized_words = @string_value.downcase.scan(/[\w']+/)
normalized_words.each_with_object(words) do |word, word_hash|
word_hash[word] += 1
end
words
end
end
| true |
0b0b64a68b2cc53b1430ce8ad1ec7a3b082ef1d1 | Ruby | hooptie45/xiki | /lib/xiki/core/notes.rb | UTF-8 | 39,294 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'xiki/core/styles'
require 'xiki/core/line'
require 'xiki/core/effects'
require 'xiki/core/view'
require 'xiki/core/keys'
require 'xiki/core/clipboard'
module Xiki
class Notes
LABEL_REGEX = /(?:[a-zA-Z0-9 _-]+\) )?/
def self.menu_before *args
# If @notes is nested under a menu, use that menu... | true |
502a6bf4700aaeff0d15b5df59823be895ffc22f | Ruby | uchiyu/NLP100 | /07/68.rb | UTF-8 | 466 | 2.71875 | 3 | [] | no_license | =begin
68. ソート
"dance"というタグを付与されたアーティストの中でレーティングの投票数が多いアーティスト・トップ10を求めよ.
=end
require 'json'
require 'mongo'
client = Mongo::Client.new(['127.0.0.1:27017'], :database => 'NLP100_Chapter07')
coll = client[:artist_data]
i = 1
coll.find({ 'tags.value':'dance' }).sort({'rating.count':-1}).limit(10).each do |row|
print... | true |
a0ee2f834a19cd8f75acc0c74c5dec3f5f78508f | Ruby | thebravoman/software_engineering_2014 | /class018_homework/Dimitar_Andreev_B_14/csv_writer.rb | UTF-8 | 207 | 2.703125 | 3 | [] | no_license | require 'csv'
def csv_write (res, head)
CSV.open("results_Dimitar_Andreev_B_14.csv", "w") do |csv|
csv << head
res.each do |row|
names = row[0].split(' ', 2)
csv << names + row[1]
end
end
end
| true |
592ee75a301fa49adf56fac98a04181f09a19392 | Ruby | OSSystems/validates_as_inscricao_estadual | /lib/estados/MS.rb | UTF-8 | 414 | 2.546875 | 3 | [] | no_license | ValidacaoInscricaoEstadual.registrar_estado("MS")
class Validacao
def setup
@pesos = ["9", "8", "7", "6", "5", "4", "3", "2"]
@cadastro_tamanho = 9
@digitos_tamanho = 1
end
def calcular
resto = multiplicar_pesos_com_numeros_cadastro % 11
@digito1 = 0 if resto.to_s.to_i == 0
if resto > 1... | true |
b76b6a0956643dc8609826d2e863c27f3f300b00 | Ruby | reid-andrew/enigma | /lib/alphabet.rb | UTF-8 | 507 | 3.265625 | 3 | [] | no_license | class Alphabet
def self.alphabet
@@alphabet ||= ("a".."z").to_a << " "
end
def self.alpha_by_letter
counter = 1
@@alpha_by_letter ||= Alphabet.alphabet.reduce ({}) do |alpha_hash, letter|
alpha_hash[letter] = counter
counter += 1
alpha_hash
end
end
def self.alpha_by_number... | true |
deb097238d2a8e4c700e014616a0c86d9422bcd1 | Ruby | HectorMF/subdivision_select | /app/helpers/subdivision_select/subdivisions_helper.rb | UTF-8 | 720 | 2.796875 | 3 | [
"MIT"
] | permissive | module SubdivisionSelect
module SubdivisionsHelper
def self.get_subdivisions(alpha2)
# The countries gem returns a hash, where:
# the keys are the ISO 3166-2 subdivision two letter codes
# and the value is a hash with two key/values:
# - "name" is the most popular/most correct name
#... | true |
deed20803dd755282338f538e63d3eb9ed0b09b5 | Ruby | jkranking/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 1,912 | 4.4375 | 4 | [] | no_license | # Method to create a list
def newlist(items)
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# go from string to hash
#set up a new hash
# grocery_list= {}
#Convert our string to array
items = items.split(' ')
#iterate through the array
# items.each ... | true |
dd39d80f8ca050341bec36bf0a9d17014bbba2fc | Ruby | avanegasp/MakeitClass | /segundaSemana/sinatra_día1/rutas1.rb | UTF-8 | 1,225 | 3.34375 | 3 | [] | no_license | require 'sinatra' #este archivo ya contiene todo lo de sinatra
get '/' do # verbo # ruta
'Hello world!' #lo que quiero que sinatra le diga a la aplicación que pase dentro de esa ruta
end
#Correr la aplicación ruby rutas.rb
#Sinatra utiliza el puerto 4567
#SE A SERVIDO LA PRIMERA PÁGINA A TRAVEZ DE... | true |
34fd0e9b511f2262acdadf1656c3165d30181aba | Ruby | gforces/smart_sanitize | /lib/smart_sanitize/css.rb | UTF-8 | 2,069 | 2.734375 | 3 | [
"MIT"
] | permissive | module SmartSanitize
class Css
def clean(text)
dupe = text.dup
clean!(text) || dupe
end
def clean!(text)
text.scan(/(.*?)\{(.*?)\}/m).map {|selector, style| "#{SmartSanitize::Selector.clean(selector)} {#{clean_style(style)}}" if SmartSanitize::Selector.allowed?(selector)}.join("\n")
... | true |
8d920acfc71ff3543473eb696b6820513f131fae | Ruby | aaronwtan/RB101 | /small_problems/easy6/q10.rb | UTF-8 | 1,209 | 4.25 | 4 | [] | no_license | # What will the following code print, and why? Don't run the code until you have tried to answer.
array1 = %w(Moe Larry Curly Shemp Harpo Chico Groucho Zeppo)
array2 = []
array1.each { |value| array2 << value }
array1.each { |value| value.upcase! if value.start_with?('C', 'S') }
puts array2
# Moe
# Larry
# CURLY
# SH... | true |
dd384210fa3f6cf642217a10b8c0abaa66d60027 | Ruby | poushitaguha/ar-exercises | /lib/store.rb | UTF-8 | 536 | 2.546875 | 3 | [] | no_license | class Store < ActiveRecord::Base
has_many :employees
# Validations
validate :mens_or_womens_apparel_present
validates :name, length: { minimum: 3 }
validates :annual_revenue, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
def mens_or_womens_apparel_present
if mens_a... | true |
b91c95214d25b8de2e8b0ec3b7cb6f60b4bfffa8 | Ruby | austinandrade/snowy-pine-8251 | /spec/models/airline_spec.rb | UTF-8 | 1,877 | 2.75 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Airline, type: :model do
describe 'relationships' do
it {should have_many :flights}
it { should have_many(:flights_passengers).through(:flights) }
it { should have_many(:passengers).through(:flights_passengers) }
end
before(:each) do
@airline_1 = Airline.cre... | true |
f6f1cc48379655e089f8e7455a7aeb982d1312ea | Ruby | avdgaag/gista | /lib/gista.rb | UTF-8 | 1,582 | 3 | 3 | [
"MIT"
] | permissive | require 'gista/version'
require 'gista/api_request'
require 'gista/token_request'
require 'gista/gist_request'
require 'gista/login_prompt'
require 'gista/user_token'
require 'gista/options'
# Gista allows for easily creating Gists from the command line or a Ruby
# program. For full instructions on how to use it from ... | true |
b9b58c3a31078fe0f3f4357ac6ea112dd861eb62 | Ruby | megazear7/susicivus-opus | /ruby-interpreter-part3/comp.rb | UTF-8 | 868 | 3.40625 | 3 | [] | no_license | require "./op.rb"
require "./comp_op.rb"
class Comp
attr_accessor :op1
attr_accessor :op2
attr_accessor :comp_op
def initialize tokens
tokens.skip "("
@op1 = Op.new(tokens)
@comp_op = CompOp.new(tokens)
@op2 = Op.new(tokens)
tokens.skip ")"
end
def value variables
case @comp_op.t... | true |
1593d4e8d38ee3ae398b2847933f0e3231552b40 | Ruby | graywolf1138/sp-parser | /lib/parser/line.rb | UTF-8 | 131 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
class Line
attr_reader :uri, :ip
def initialize(uri, ip)
@uri = uri
@ip = ip
end
end
| true |
a0814baf3c2f85e504f9aef67a62594a6530c968 | Ruby | smartscheduling/chatto-hub | /lib/slack_adapter.rb | UTF-8 | 2,025 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'rest-client'
# Configuration in config/initializers/slack
class SlackAdapter
class SlackTeamInviteError < StandardError; end
DEFAULT_CHANNEL_ID = ENV['SLACK_DEFAULT_CHANNEL']
cattr_accessor :team_id, :token, :team_name
def slack
Slack
end
def channels_create(opts={})
slack.channels_creat... | true |
7fc353ce54bab0ba337ff42f0371b260dace3ebe | Ruby | asolace/Project-Euler | /27_Quadratic_Primes.rb | UTF-8 | 1,390 | 3.90625 | 4 | [] | no_license | # Quadratic primes
# Problem 27
#
# Euler discovered the remarkable quadratic formula:
#
# n^2+n+41
#
# It turns out that the formula will produce 40 primes for the consecutive integer
# values 0≤n≤39.
#
# However, when n=40,40^2+40+41=40(40+1)+41 is divisible by 41,
# and certainly when n=41,41^2+41+41 is clearly divi... | true |
0613e24d39ec25e321d7503454bdd07529465ca3 | Ruby | matee911/wsc | /chat.rb | UTF-8 | 1,768 | 2.859375 | 3 | [] | no_license | require 'rubygems'
require 'em-websocket'
require 'json'
class Action
@@users = {}
class << self
def users
return @@users
end
def parse_message message, socket
user, data = JSON.parse! message
return Action.send(data['cmd'], user, data, socket)
end
def connect(use... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.