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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3c1974eb571d9f05208e5b893a0ba61d68a16ac8 | Ruby | right-solutions/rscmd | /template/rails/app/models/enquiry.rb | UTF-8 | 3,276 | 2.78125 | 3 | [
"MIT"
] | permissive | class Enquiry < ActiveRecord::Base
# Constants
UNREAD = "unread"
READ = "read"
ARCHIVED = "archived"
DELETED = "deleted"
STATUS_LIST = [UNREAD, READ, ARCHIVED, DELETED]
EXCLUDED_JSON_ATTRIBUTES = [:created_at, :updated_at]
# Validations
extend PoodleValidators
validate_string :name, mandatory: tr... | true |
ffe1e2f35a0e8a7ff4894dc4c2cd5c1bd71cf195 | Ruby | np711/ruby-objects-has-many-through-lab-online-web-sp-000 | /lib/genre.rb | UTF-8 | 261 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
attr_accessor :name, :genre
attr_accessor :song
def initialize(name)
@name = name
end
def songs
Song.all.select do |song|
song.genre == self
end
end
def artists
Song.all.map do |song|
song.artist
end
end
end
| true |
4916278096b574c089da25d357f64c6c9bde829c | Ruby | RJasonClarke/ttt-5-move-rb-online-web-sp-000 | /bin/move | UTF-8 | 692 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
puts "Welcome to Tic Tac Toe!"
puts "Where would you like to go?"
user_input = gets.strip
input_to_index(user_input)
index = user_input.to_i - 1
move(board, index, player = "X")
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{... | true |
7bf04fb7d57a314de7b5bde0d30a80c269010290 | Ruby | fossabot/gistrb | /bin/gistrb | UTF-8 | 1,904 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require File.expand_path('../../lib/gist', __FILE__) # Require the Gist library files
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = 'Usage: gist [options] files'
opts.on('-u', '--user', 'Post as user') do |u|
options[:user] = u
end
opts.on('-s', '--sign-in', ... | true |
76b8b917fe1ff39d4459ad2b8985386fd0007569 | Ruby | sharatsridhar/tdd | /triangle.rb | UTF-8 | 472 | 3.5 | 4 | [] | no_license | require 'minitest/autorun'
require_relative 'point'
class Triangle
attr_accessor :area
def initialize(p1, p2, p3)
@p1 = p1
@p2 = p2
@p3 = p3
calc_area
end
def calc_area
@area = (0.5*((@p1.x - @p2.x).abs) * ((@p1.y - @p3.y).abs))
end
end
describe Triangle do
before do
@p1 = Point.new(0, 0)
@p2 ... | true |
0cb668bcd8b2af03c36acbba1eec58570e1720fe | Ruby | SelamawitA/grocery-store | /lib/order.rb | UTF-8 | 2,297 | 3.28125 | 3 | [] | no_license | require 'csv'
require 'awesome_print'
@@all_orders
module Grocery
class Order
attr_reader :id, :products
def initialize(id, products)
@id = id
@products = products
end
def total
total = 0
@products.values.each do |grocery_product|
total += grocery_product
end
... | true |
9cc5908b7e803f49d86bb664e9deb1f1be2e9608 | Ruby | hannahherbig/sort_shoes | /algos/merge.rb | UTF-8 | 462 | 2.859375 | 3 | [] | no_license | def mergesort(left=0, right=nil)
right = array.length - 1 if right == nil
return if left >= right
middle = (left + right) / 2
mergesort(left, middle)
mergesort(middle + 1, right)
i, end_i, j = left, middle, middle + 1
while i <= end_i and j <= right
compare(i, j)
if array[i] <= array[j]
i +=... | true |
362915ff30d99a6b67a4941b1f5202a136753abb | Ruby | edgarjsr/Retina | /ultima_version/retina_symTable.rb | UTF-8 | 1,102 | 3.625 | 4 | [] | no_license | class SymbolTable
attr_accessor :father
def initialize(father = nil)
@symTable = Hash.new
@father = father
end
def insert(key, values)
return @symTable.store(key, values)
end
def delete(key)
return @symTable.delete(key)
end
def contains(key)
return @symTable.include?(key)
end
def update(key,... | true |
64ab66fccb3656eaa091c42630bdafaa9e31d262 | Ruby | sato-s/algorism | /hacker_rank/stack_queue/largest_rectangle4.rb | UTF-8 | 846 | 3.46875 | 3 | [] | no_license | require 'pry'
arr = %w[8979 4570 6436 5083 7780 3269 5400 7579 2324 2116].map(&:to_i)
def calc(arr)
stack = []
results = []
(0...(arr.size)).each do |i|
if stack.empty? || arr[stack.last] <= arr[i]
stack << i
else
while !stack.empty? && arr[stack.last] > arr[i]
stack_last_index = stac... | true |
d55675ddc7238391d665e4c1aabad3a55bb78f24 | Ruby | yokoto/extreame_hands_on | /torishimariyaku_spec.rb | UTF-8 | 458 | 2.8125 | 3 | [] | no_license | # -*- config: utf-8 -*-
require 'rspec'
require_relative 'torishimariyaku'
describe Torishimariyaku do
let(:torishimariyaku) { Torishimariyaku.new }
it '取締役の給料は基本給の4倍+2、基本給が100なら給料は402' do
expect(torishimariyaku.calculate_salary(100)).to eq 402
end
it '取締役はふんぞり返って立ち上がる' do
expect(torishimariyaku.standup).to e... | true |
bc017dcb4438ee5685f0f4c9dd8e62fe5d7b937e | Ruby | ripperhe/coo | /lib/coo/helper/cm.rb | UTF-8 | 1,998 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'open3'
module Coo
module Helper
module CM
# 利用 system 语句执行 shell 命令
def self.sys(command_str)
puts current_time_str(command_str)
system command_str
result = $?
flag = result.to_s.split(' ').last.to_i
if flag != 0
# 非0,执行失败
puts "er... | true |
30a72d64794ec3d3eff2bc9217d08a3ff58be51e | Ruby | sh6khan/ruby-algo | /Trie/trie/trie.rb | UTF-8 | 1,707 | 3.890625 | 4 | [] | no_license | # this is the larger trie structure composed of Nodes
require_relative 'node'
class Trie
def initialize
@root = Node.new
@char_map = ("a".."z").to_a
@all_words_that_start_with = []
end
def contains_word?(word)
final_node = search_node(word)
return false unless final_node
return final_nod... | true |
2a928897776d86f1310739f9baea3bf10ae11290 | Ruby | mikeseven/apollon | /lib/apollon/extensions/string.rb | UTF-8 | 1,012 | 3.328125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
# String class extensions
class String
# rubocop:disable all
def camelcase(*separators)
case separators.first
when Symbol, TrueClass, FalseClass, NilClass
first_letter = separators.shift
end
separators = ['_', '\s'] if separators.empty?
str = self.dup
separato... | true |
7e563b9025c49f46af14df0a6c3c1e5c6976a970 | Ruby | ragnarock91/thnad | /test/test_parser.rb | UTF-8 | 1,611 | 2.5625 | 3 | [] | no_license | $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'minitest/autorun'
require 'minitest/spec'
require 'thnad/parser'
include Thnad
describe Parser do
before do
@parser = Thnad::Parser.new
end
it 'reads a number' do
input = '42 '
expected = {:number => '42'}
@parser.number.p... | true |
73f07e768890a623ffefed1c467a06813a87bf63 | Ruby | vosyk/remote_repository | /ItPwRuby/4-flowcontrol/exer5.rb | UTF-8 | 797 | 4.375 | 4 | [] | no_license | def check_num(number)
if (number >= 0 && number < 50)
puts "Number is between 0 and 50"
elsif (number >= 51 && number < 100)
puts "Number is between 51 and 100"
else
puts "Number is greater than 100"
end
end
def check_num_case1(number)
case
when number <= 50
puts "Number is between 0 and 5... | true |
ccc9a0ef7e5b1c42f0758866bffb121b00f01fc2 | Ruby | nateg101/Oystercard | /spec/station_spec.rb | UTF-8 | 366 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require 'station'
describe Station do
subject { described_class.new("Aldgate", 2)}
describe '#name' do
it 'knows it has a name' do
expect(subject.name).to eq "Aldgate"
end
end
describe '#zone' do
it 'knows what zone it is in' do
expec... | true |
007397ae6f6ce8a72ae2b3ffbb6442e3377fbca9 | Ruby | aspett/wits | /lib/wits/final_interim_prices.rb | UTF-8 | 1,699 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'wits/nodes'
require 'wits/helpers'
require 'wits/client'
require 'wits/error'
require 'wits/final_interim_prices/convenience_methods'
module Wits
module FinalInterimPrices
extend self
extend Helpers
extend ConvenienceMethods
def self.extended(base)
base.extend Helpers
... | true |
a94177f318108b2d859fad485a817676504b3a57 | Ruby | akramhelil/rack-dynamic-routes-lab-nyc-web-career-021819 | /app/application.rb | UTF-8 | 662 | 3.09375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
class Application
@@items = []
def call(env)
resp = Rack::Response.new
req = Rack::Request.new(env)
if req.path.match(/items/)
item_name = req.path.split("/items/").last
#item_name is an array of names that after split from the /items/
if item = @@items.find {|t| t.name == item_name... | true |
53cf1f9f5d213d5599bddb27bab6e36158452a86 | Ruby | ajalvarez89/hotel | /app/serializers/booking_serializer.rb | UTF-8 | 1,167 | 2.65625 | 3 | [] | no_license | # == Schema Information
#
# Table name: bookings
#
# id :integer not null, primary key
# room_id :integer
# user_id :integer
# check_in :date
# check_out :date
# minibar :float
# final_price :float
# created_at :datetime not null
# updated_at :datetime not n... | true |
298e3769d1e21831c95f9064fdadf6f5716b454a | Ruby | wleung1291/Rails | /advanced_rails_forms/polymorphism_and_concerns/db/migrate/20190903233428_create_toys.rb | UTF-8 | 624 | 2.625 | 3 | [] | no_license | class CreateToys < ActiveRecord::Migration[5.2]
def change
create_table :toys do |t|
t.string :name, null: false
t.references :toyable, polymorphic: true, index: true
t.timestamps
end
# want to ensure that all toys are unique by their name, toyable_id, and
# toyable_type propertie... | true |
ac1ad46596db962d876d36953a46ddb24c23b2a3 | Ruby | MarieHeller/Family | /db/seeds.rb | UTF-8 | 2,663 | 2.546875 | 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
e1159d5612412d08075a2323ce4423484eb0fdf7 | Ruby | pablokbs/clasesruby | /hola.rb | UTF-8 | 30 | 2.6875 | 3 | [] | no_license | 5.times { puts "hola mundo" }
| true |
51e4ba7ad05b2e188a7036b2ade28867e39c865a | Ruby | iamvery/fp101x | /2-types-and-classes/twice-curried.rb | UTF-8 | 786 | 3.078125 | 3 | [] | no_license | require 'rspec'
twice = ->(function, arg) do
function.(function.(arg))
end.curry
dbl = ->(number) { number * 2 }
puts twice.(dbl, 2)
RSpec.describe 'twice' do
let(:function) { double :function }
let(:arg) { double :arg }
it 'calls the function twice with arguments' do
expect(function).to receive(:call).... | true |
d48043c851289c0dae34ab1f64fa5ddced46e2c8 | Ruby | Stoovles/LaughTracks | /spec/models/comedian_spec.rb | UTF-8 | 1,751 | 2.578125 | 3 | [] | no_license | RSpec.describe Comedian, type: :model do
describe 'Validations' do
describe 'Required Field(s)' do
it 'should be invalid if missing a name' do
comic = Comedian.create(age: 48, home_town: 'boston')
expect(comic).to_not be_valid
end
it 'should be invalid if missing an age' do
... | true |
97d0e0f32b7c5d3c2077d337b145f2049a704c30 | Ruby | discourse/onebox | /lib/onebox/file_type_finder.rb | UTF-8 | 2,272 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Onebox
module FileTypeFinder
# In general, most of file extension names would be recognized
# by Highlights.js. However, some need to be checked in other
# ways, either because they just aren't included, because they
# are extensionless, or because they contain d... | true |
aa206df790456d9cdb22a47785c207cd0649c65f | Ruby | jeffmbellucci/Assessments | /solutions/assessment02-retake/lib/foundation.rb | UTF-8 | 718 | 3.171875 | 3 | [] | no_license | require_relative 'move_error'
class Foundation
attr_reader :cards, :suit
def initialize(suit, cards = [])
@cards = cards
@suit = suit
end
def move(card)
raise MoveError.new("does not extend foundation") unless valid_move?(card)
@cards << card if valid_move?(card)
end
def remove
if self... | true |
d0f6409c92d199ed54c39ca8015b04baf9631fa5 | Ruby | Coolnesss/naive-bayes | /ruby_lib/ruby_test.rb | UTF-8 | 424 | 2.78125 | 3 | [] | no_license | require 'benchmark'
require './bayes_classifier'
d = IO.read("../test/data/20ng-train-all-terms.txt")
training = d.split("\n").map{|x| x.split("\t")}
d = IO.read("../test/data/20ng-test-all-terms.txt")
test = d.split("\n").map{|x| x.split("\t")}
puts Benchmark.measure {
b = BayesClassifier.new
training.each ... | true |
7da60d1b76e38b626c496b1c09f3c2c5ab9da779 | Ruby | TyrusB/Poker | /lib/player.rb | UTF-8 | 1,791 | 3.859375 | 4 | [] | no_license | require_relative 'hand'
class Player
attr_reader :hand, :pot, :name
def initialize(name, pot = 200)
@name = name
@hand = nil
@pot = pot
end
def to_s
self.name
end
def get_new_hand(deck)
@hand = Hand.deal_from(deck)
end
def bet(amount)
@pot -= amount
... | true |
b42fc218b915a6314951bf29702d79d96ff19f3d | Ruby | isabella232/rom-migrator | /lib/rom/migrator/class_dsl.rb | UTF-8 | 1,547 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
class ROM::Migrator
# Migrator class DSL
#
# @api private
#
module ClassDSL
# Returns a container of adapter-specific settings
#
# @return [ROM::Migrator::Settings]
#
def settings
@settings ||= Settings.new
end
# Returns the adapter-specific subclass of ... | true |
a72be7cafda40f8594e146772bef813e568c501c | Ruby | mikegw/lots_to_do | /lib/models/todo.rb | UTF-8 | 2,715 | 2.8125 | 3 | [] | no_license | # +---------+------------------+------+-----+---------+----------------+
# | Field | Type | Null | Key | Default | Extra |
# +---------+------------------+------+-----+---------+----------------+
# | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
# | title | varchar(31) ... | true |
34b17d53cef5d35b1675d43897f3d50a1565e791 | Ruby | nimbletechnique/cruisecontrolrb | /test/unit/application_helper_test.rb | UTF-8 | 2,705 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | require File.dirname(__FILE__) + '/../test_helper'
require 'builds_controller'
class ApplicationHelperTest < Test::Unit::TestCase
include ApplicationHelper
def test_format_time_humane
Time.stubs(:now).returns(Time.parse('2007-01-03 03:00:00'))
# before this year
assert_equal '31 Dec 06', format_tim... | true |
c09f064f39dbec4f83a272625c5a32997f651201 | Ruby | garcia50/jungle_beats | /test/jungle_beats_test.rb | UTF-8 | 2,794 | 3 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/jungle_beats'
class JungleBeatsTest < Minitest::Test
attr_reader :beats
def setup
@beats = JungleBeats.new
end
def test_instance_of_Linked_beats
assert_instance_of JungleBeats, beats
end
def test_head_returns_nil
assert_nil b... | true |
da98e9d42933cce550c1a959fe21129c2be2b9a2 | Ruby | michaelstucki/introduction_to_programming | /09_exercises/ex_12.rb | UTF-8 | 600 | 2.90625 | 3 | [] | no_license | contact_data = [["joe@email.com", "123 Main st.", "555-123-4567"],
["sally@email.com", "404 Not Found Dr.", "123-234-3454"]]
contacts = {"Joe Smith" => {}, "Sally Johnson" => {}}
def get_contact_data(contact, contact_data)
contact = contact[0, contact.index(' ')].downcase
contact_data.each do |dat... | true |
d3ca264380c04d8236f2de1dee807ed7ef297cc0 | Ruby | huydx/lfruit | /lib/lfruit/empty_class.rb | UTF-8 | 137 | 2.78125 | 3 | [
"MIT"
] | permissive | module Lfruit
class BlackHole
def method_missing(name, *args)
## just do nothing, because i'm blackhole!!!
end
end
end
| true |
fe3d7471adf5ddeb7399e715d9c158050c223710 | Ruby | WillSewell/country-suggestions | /model.rb | UTF-8 | 1,201 | 3.0625 | 3 | [] | no_license | require 'em-hiredis'
class Model
def initialize
@redis = EM::Hiredis.connect
end
def get_all_users
@redis.keys("*").callback { |keys| yield keys }
end
# Get all selected countries for a given user
def get_selected user
@redis.smembers(user).callback { |members| yield members }
end
# Add,... | true |
df1b0b8a7799aa87173d935dd1e0410c382ff5a9 | Ruby | notapatch/exercises_for_programmers | /ruby/44_product_search/test/product_search/test_product.rb | UTF-8 | 1,139 | 2.953125 | 3 | [] | no_license | require 'test_helper'
require_relative '../../lib/product_search/product'
describe Product do
describe '#key' do
it 'returns lowercase unchanged' do
Product.new(name: 'lower', price: 0, quantity: 0).key.must_equal 'lower'
end
it 'returns uppercase transformed to lower' do
Product.new(name: '... | true |
36cff1ed3c2d761a093cb0d38c386e78e587fbf1 | Ruby | jahseng-lee/hangman-rails | /app/services/make_game.rb | UTF-8 | 305 | 2.859375 | 3 | [
"MIT"
] | permissive | class MakeGame
attr_reader :game
INITIAL_LIVES = 11
def call
@game = HangmanGame.new(
mystery_word: random_word.downcase,
initial_lives: INITIAL_LIVES
)
game.save
end
private
def random_word
File.read('./app/assets/dictionary.txt').split("\n").sample
end
end
| true |
0e35f18104019973c70a22f138793c4916695996 | Ruby | Alnakhlani/rubyscript | /ex4.rb | UTF-8 | 155 | 2.9375 | 3 | [] | no_license | puts '"I want a dyke for president
...
I want a Black woman for president
I want someone with bad teeth..."'
puts "Zoe Leonard"
puts "1992"
puts ARGV[0]
| true |
b690b3757edf2b9bda6bab51d3344eb82ce817c4 | Ruby | uroshima/Graphs | /lib/install_order.rb | UTF-8 | 1,057 | 3.265625 | 3 | [] | no_license | # Given an Array of tuples, where tuple[0] represents a package id,
# and tuple[1] represents its dependency, determine the order in which
# the packages should be installed. Only packages that have dependencies
# will be listed, but all packages from 1..max_id exist.
# N.B. this is how `npm` works.
# Import any file... | true |
8e6cf128cebc47e7b9385f7cbb10e91960048ac6 | Ruby | mac718/advanced_building_blocks | /Enumberable_methods.rb | UTF-8 | 1,488 | 3.65625 | 4 | [] | no_license | module Enumerable
def my_each
for i in self
yield(i)
end
self
end
def my_each_with_index
i = 0
while i < self.length
yield(self[i], i)
i += 1
end
self
end
def my_select
selection_arr = []
self.my_each do |i|
if yield(i)
selection_arr.push(i)
end
end
selection_arr
end
d... | true |
50053224f31d2e3537f7933ef2f2dd5d739e8093 | Ruby | adamburmister/to_spreadsheet | /spec/xlsx_spec.rb | UTF-8 | 1,785 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe ToSpreadsheet::XLSX do
let(:spreadsheet) {
html = Haml::Engine.new(TEST_HAML).render
package = ToSpreadsheet::XLSX.generate(html)
}
it 'creates multiple worksheets' do
spreadsheet.workbook.should have(2).worksheets
end
it 'supports num format' do
spreadsheet.... | true |
d92d05b47b5916a2011c9272581049cc775ef2bf | Ruby | Godoy/videoflag | /app/models/flag.rb | UTF-8 | 301 | 2.65625 | 3 | [] | no_license | class Flag < ActiveRecord::Base
belongs_to :video
attr_accessible :description, :seconds, :title, :video_id
def seconds_formatted
seconds = self.seconds % 60
minutes = (self.seconds / 60) % 60
hours = self.seconds / (60 * 60)
format("%02d:%02d:%02d", hours, minutes, seconds)
end
end
| true |
eb7d12a4ba0dc9cc85607e3008bdf3b3cc178756 | Ruby | samlandfried/looping-while-until-ruby-intro-000 | /lib/until.rb | UTF-8 | 245 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_until
levitation_force = 6
spell = ""
#your code here
until levitation_force == 10
spell += "Wingardium Leviosa\n"
levitation_force += 1
end
puts spell
end
| true |
f970dd484ac69c1365c6ea6809d6f5ccd1d514ea | Ruby | gavinlaking/vedeu | /lib/vedeu/geometries/area/area.rb | UTF-8 | 7,529 | 3.09375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Vedeu
module Geometries
# Define an area from dimensions or points.
#
# @api private
#
class Area
extend Forwardable
def_delegators :border,
:bottom?,
:enabled?,
:left?,
... | true |
2f3ede59e792ec59ab14c3d0a1eb3249bb55bf6e | Ruby | KimberlyRosaly/activerecord-validations-lab-onl01-seng-pt-081720 | /app/models/post.rb | UTF-8 | 935 | 2.984375 | 3 | [] | no_license | require 'pry'
class Post < ActiveRecord::Base
validates :title, presence: true
validates :content, length: { minimum: 250 }
validates :summary, length: { maximum: 250 }
validates :category, inclusion: { in: %w(fiction nonfiction Fiction Nonfiction) }
validate :clickbait
def clickbait
# binding... | true |
acf4519bf27d56159df545b1146bd562406d7b8d | Ruby | preethi29/TechRound | /app/helpers/colleges_scraper.rb | UTF-8 | 1,560 | 3.015625 | 3 | [] | no_license | require 'net/http'
require 'json'
class CollegesScraper
def self.get_colleges
colleges = scrap_colleges_data
colleges = map_scraped_data(colleges)
write_to_file(colleges)
end
def self.write_to_file(colleges)
File.open('public/colleges.json', 'w') do |f|
f.write(... | true |
1e6f34552099ad721ea95b61388e2b9dcc553afb | Ruby | TravisL12/spending_app | /app/helpers/transactions_helper.rb | UTF-8 | 770 | 2.5625 | 3 | [] | no_license | module TransactionsHelper
def category_sum(transactions)
transactions.inject(Hash.new(0)) do |h, (category, transaction)|
transaction.each { |trans| h[category] += trans.amount }; h
end
end
def category_count(transactions)
transaction_cats = transactions.inject([]) do |cats, transaction|
... | true |
47ca6d878b58a795e3b11980ef443101ed51e4eb | Ruby | Patrick-Duvall/backend_prework | /day_6/exercises/person.rb | UTF-8 | 465 | 4.28125 | 4 | [] | no_license | # Create a person class with at least 2 attributes and 2 behaviors. Call all
# person methods below the class so that they print their result to the
# terminal.
#YOUR CODE HERE
class Person
attr_accessor :name, :age
def initialize(name, age)
@age = age
@name = name
end
def age
@age +=1
end
def... | true |
3f258b351257f549f5822ff30fec31e48a1c680b | Ruby | slimane/learning_ruby | /diet/Util.rb | UTF-8 | 257 | 3.03125 | 3 | [] | no_license | module ValueCheck
def numeric?(variable)
variable.kind_of?(Numeric)
end
end
module Translation
def mile_to_km(mile = 1)
mile * 1.60934
end
def calc_required_time(speed, distance)
60.0 * ((distance * 1.0) / speed)
end
end
| true |
38749a20576a4512fef8a75d57f38ed680bffea1 | Ruby | fwenzel/fredericiana | /site/_plugins/yearly_archive_generator.rb | UTF-8 | 1,280 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | require 'enumerator'
module Jekyll
class YearlyArchivePage < BaseArchivePage
attr_accessor :posts
def layout_err_msg
"
Hold your horses! yearly_archive_generator plugin, here.
You've enabled me but haven't added a yearly_archive layout.
At least put an empty file there or I'm not going to run.
Miss... | true |
42722cd8f9bf208da2c077b69707c151968780ba | Ruby | lwlsns/claim-additional-payments-for-teaching | /app/helpers/govuk_form_helper.rb | UTF-8 | 4,202 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module GovukFormHelper
# = GOVUK Form Tag Helpers
#
# For usage, components and patterns see:
# https://design-system.service.gov.uk/
# Can be used to wrap multiple or single components.
#
# Creates a div with the 'govuk-form-group' css class, if the provided object has errors, adds
# the 'govuk-form-g... | true |
596f0d85def2f3e8dcad684154632ac8604b1396 | Ruby | jjschnei/phase-0 | /week-9/ruby-excercises.rb | UTF-8 | 1,254 | 4.46875 | 4 | [
"MIT"
] | permissive | def angry_boss
p "WHAT DO YOU WANT?!"
input = gets.chomp
p "WHADA MEAN YOU \"#{input}\"?!? YOU'RE FIRED"
end
def deaf_grandma
p "Hi, Sonny"
input = gets.chomp
if input == "BYE"
p "BYE DEAR"
exit
elsif input == input.upcase
year = 1950 - rand(20)
p "NO, NOT SINCE " + year.to_s... | true |
efaa8f08471031f143a5ac780dce88c05958d05c | Ruby | thebravoman/software_engineering_2013 | /class6_belt_exam/test_yellow_task2.rb | UTF-8 | 477 | 2.578125 | 3 | [] | no_license | require 'csv'
CSV.open("results2.csv", "w") do |csv|
Dir.glob("*_2.rb") do |file|
begin
`mkdir test_execution`
`cp #{file} test_execution`
`cd test_execution && ruby #{file} ../bank.csv EUR`
result = `diff test_execution/bank_result.csv test_data2/bank_expected.csv`
result = result.gsub(/[\n\r]/,"")
... | true |
f5804310533ff8f9e4a82b0386a5ebf33e609b73 | Ruby | spartanPAGE/ruby-snake | /lib/ruby/snake/game/entity/angle_based_entity.rb | UTF-8 | 1,034 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'gosu'
require 'ruby/snake/game/entity/moving_entity'
module Ruby
module Snake
module Game
# AngleBasedEntity is a GameEntity designed
# for angle+length based movement
class AngleBasedEntity < Game::MovingEntity
attr_accessor :speed
attr_accessor :torsion_angle
... | true |
473a193760d5a3bded2444f6e7c55847273e7b2a | Ruby | cSquirrel/xcider | /lib/xcider/xcodeselect.rb | UTF-8 | 702 | 2.65625 | 3 | [] | no_license |
# xcode-select: Report or change the path to the active
# Xcode installation for this machine.
#
# Usage: xcode-select --print-path
# Prints the path of the active Xcode folder
# or: xcode-select --switch <xcode_path>
# Sets the path for the active Xcode folder
# or: xcode-sel... | true |
cc7edcc6e554483a2949b8702cbc3557b75e25d1 | Ruby | brazenbraden/random-challenges | /spec/temperature_converter/temperature_spec.rb | UTF-8 | 2,010 | 3.40625 | 3 | [] | no_license | require_relative '../../src/temperature_converter/temperature'
describe Temperature do
context "instantiating" do
it "it is instantiable" do
expect(Temperature.new 100, :c).to be_an_instance_of Temperature
end
it "it represents a temperature" do
temp = Temperature.new 100, :c
expect(te... | true |
f3386d300572f276eb4f77b542fdf9eecc9363f6 | Ruby | shibinp/RubyMonk_exercises | /modules4_s.rb | UTF-8 | 98 | 2.875 | 3 | [] | no_license | class Array
def initialize
@size = 400
end
end
our_array = Array.new
puts our_array.class
| true |
c8b1222b38156cebbf9ea8eb4affee37b4cfa30d | Ruby | travishaby/chisel | /emphasis_marker_test.rb | UTF-8 | 2,144 | 2.6875 | 3 | [] | no_license | gem 'simplecov', :require => false, :group => :test
require 'simplecov'
SimpleCov.start
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require './emphasis_marker'
require './list_marker_test'
class EmphasisMarkerTest < Minitest::Test
def test_blank_strand
sm = EmphasisMarker.new
assert_... | true |
fe0f0384ee1efed2305fe9066497bb15f93713ab | Ruby | jhaagmans/netzke-core | /lib/netzke/core/dsl_support.rb | UTF-8 | 2,125 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Netzke
module Core
module DslSupport
extend ActiveSupport::Concern
module ClassMethods
# It's the easiest to explain by example.
#
# declare_dsl_for :components
#
# creates:
#
# 1) DSL method `component` for declaration of child compo... | true |
c04304bf1024f2e9f8e2fe511d6897cbe8c58528 | Ruby | iwhiteday/ChipsManager | /app/controllers/chips_controller.rb | UTF-8 | 1,558 | 2.5625 | 3 | [] | no_license | class ChipsController < ApplicationController
def index
@chips = Chip.all
@currency = Balance.all
end
def edit
end
def new
@chips = Chip.all.pluck(:value)
end
def create
chips = params[:chips]
@result = Balance.exchange_chips(chips, 'usd')
if @result.nil?
@msg = 'Conversio... | true |
a16372a64a14d6ee592508be3844e3c6bf7ef41e | Ruby | kirillian/api_demo | /app/services/api/response.rb | UTF-8 | 922 | 2.890625 | 3 | [] | no_license | module API
class Response
attr_accessor :response, :request, :result, :block
def initialize(response, request, result, &block)
@response = response
@request = request
@result = result
@block = block
end
def debug?
ENV["DEBUG"] == "true"
end
def handle_response
... | true |
29b7d97e34258717c77f1ac4cf1145492a454c3d | Ruby | bvpb/mailbucket | /mailbucket.rb | UTF-8 | 1,357 | 2.65625 | 3 | [] | no_license | require 'sinatra'
require 'pony'
post '/' do
redirect_url = params.delete('redirect')
Mailer.mail :to => ENV['MAIL_RECIPIENT'],
:from_email => params.delete('email') || ENV['MAIL_RECIPIENT'],
:from_name => params.delete('name') || '',
:subject => params.delete('subject') ... | true |
ef9daaafdc31facb388b8bdac6d7b8e0211efec9 | Ruby | staqapp/roo-google | /test/test_roo_google.rb | UTF-8 | 12,016 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class TestRooGoogle < MiniTest::Test
def test_simple_google
go = Roo::Google.new('egal')
assert_equal '42', go.cell(1, 1)
end
def test_formula_google
with_each_spreadsheet('formula') do |oo|
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell('A', 1)
as... | true |
716b86f60299b20023b3e36c675fa22a6d511427 | Ruby | JasSidhu/hello-world | /ruby/ReverseArray.rb | UTF-8 | 262 | 3.859375 | 4 | [] | no_license |
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
puts "Array #{array}"
i = 0
j = (array.length)-1
while i<j do
puts "i=#{i} and j=#{j}"
first = array[i]
last = array[j]
array[i]=last
array[j]=first
i += 1
j -= 1
end
puts "Reversed array #{array}"
| true |
8222e58b48b029f1bd8994447e812edde1e7fc64 | Ruby | watermelonexpress/primer | /lib/primer/base_service.rb | UTF-8 | 1,183 | 2.59375 | 3 | [
"MIT"
] | permissive | module Primer
class BaseService
class << self
attr_reader :running_command, :port, :repo_name
def set_port(port)
@port = port
end
def set_repo_name(repo_name)
@repo_name = repo_name
end
def set_running_command(command)
@running_command = command
... | true |
bb9a4e6735a0ea9bde6542eae40956e5dac159ac | Ruby | sj26/dd-trace-rb | /integration/apps/sinatra2-modular/app/basic.rb | UTF-8 | 461 | 2.828125 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"BSD-3-Clause"
] | permissive | require 'sinatra/base'
require 'ddtrace'
require_relative 'parent'
# Inherit from another app to verify middleware/extension inheritance
class Basic < Parent
get '/basic/default' do
200
end
get '/basic/fibonacci' do
n = rand(25..35)
result = fib(n)
[
200,
{ 'content-type' => 'text/p... | true |
af9a9c8af61c00e5de20b468a2e60dafd9ee5826 | Ruby | virattt/testfirst_ruby | /learn_ruby/01_temperature/temperature.rb | UTF-8 | 225 | 3.984375 | 4 | [] | no_license | # This method converts Fahrenheit to Celsius
#
def ftoc(fahrenheit)
celsius = (fahrenheit - 32) * (5.0/9.0)
end
# This method converts Celsius to Fahrenheit
#
def ctof(celsius)
fahrenheit = (celsius * (9.0/5.0)) + 32
end | true |
77ad623187fb096d6804d6c5bf3dd57ccdf324cf | Ruby | slavam/hmc-rails52 | /app/models/playday.rb | UTF-8 | 223 | 2.703125 | 3 | [] | no_license | class Playday < ApplicationRecord
def self.get_playdays(year, month)
days = self.select(:pd_day).where(pd_year: year, pd_month: month).order(:pd_day)
ret = []
days.each {|d| ret << d.pd_day}
ret
end
end
| true |
3ee9c19a3fc5c54f13a551bc92ec524f702018db | Ruby | hen-chow/baking-app | /app/models/ingredient.rb | UTF-8 | 1,119 | 2.953125 | 3 | [] | no_license | class Ingredient < ApplicationRecord
belongs_to :recipe
belongs_to :food_item
# create table for metric <--> imperial conversions
@@conversion_table = {
'Imperial' => {
'L' => {
'fl oz' => 35,
},
'ml' => {
'fl oz' => 1/30.0,
},
'g' => {
'oz' => 0.035,
... | true |
4fcc7bbf53a748ab20375f8d82035afa40ddde9e | Ruby | Luchoperrotta/tpfinal | /app/helpers/products_helper.rb | UTF-8 | 1,344 | 2.640625 | 3 | [] | no_license | module ProductsHelper
def iconify_active(estado)
if estado == true
return '<span class="badge bg=success">EN STOCK</span>'
else
return '<span class="badge bg=danger">SIN STOCK</span>'
end
end
def icono_oferta(oferta)
if oferta == true
re... | true |
550487f13ecc178797107805f9a264fa2f48f21d | Ruby | skuhlmann/sales_engine | /test/item_repository_test.rb | UTF-8 | 2,416 | 2.734375 | 3 | [] | no_license | require_relative 'test_helper'
class ItemRepositoryTest < Minitest::Test
attr_reader :item_repository, :repository, :sales_engine
def setup
file_path = "./test/support/items.csv"
@sales_engine = Minitest::Mock.new
repository = Minitest::Mock.new
@item_repository = ItemRepository.new(file_path, sales_engine)... | true |
d868a10b09162b082c3e758356460e5a2c087d00 | Ruby | Kylemainstreetcodes/prework-week-1 | /hello_method.rb | UTF-8 | 94 | 3.1875 | 3 | [] | no_license | def hello_method(name)
puts "Hello " + name
end
hello_method("Kyle")
hello_method("Bob")
| true |
4cf34c5780eb75425010f197a5df2c45301bc27a | Ruby | Yuni-Q/blog | /TIL/algorithm/ruby/피보나치.rb | UTF-8 | 427 | 3.625 | 4 | [
"MIT"
] | permissive | # fibo = -> n do
# if (n<2)
# answer = n
# else
# answer=fibo.call(n-1).to_i+fibo.call(n-2).to_i
# end
# return answer
# end
# dab = fibo.call(6)
# puts dab
n = 4
a = 1
b = 1
c = 0
answer = 0
if n <= 2
c = 1
else
for i in (3..n)
c = a + b
a = b
b = c
end... | true |
86fab29e72cc44ff3e900e3bf4aa4edb45924e29 | Ruby | szorfein/learn-ruby | /x03/regex.rb | UTF-8 | 370 | 3.78125 | 4 | [
"MIT"
] | permissive | # / /i will match with caps and not
the_time = '10:24 AM'
puts "it's morning!" if /am/i =~ the_time
# Start with 'Once' with \A or ^
s = "Once upon a time"
puts "it begin with Once!" if /\AOnce upon a time/ =~ s
# End with 'after' with \z or $
s = "and they all lived happily ever after"
puts "it's ending with after" ... | true |
5780647596e4a024b7a04156a9e3e93ac6357105 | Ruby | marclerodrigues/ruby_exercises_refactored | /lib/exercises/min_of_three.rb | UTF-8 | 212 | 2.78125 | 3 | [] | no_license | require_relative '../modules/process_data'
module MinOfThree
include ProcessData
def self.verify data
sanitized = ProcessData::Sanitize(data)
sanitized.collect { |triplet| triplet.min }
end
end
| true |
1954b989cba9c5be4af839c665809048e710e7f8 | Ruby | swparkaust/rmxp-kwangtteng-online | /src/Viewport.rb | UTF-8 | 375 | 2.921875 | 3 | [] | no_license | class Viewport
def x
return rect.x
end
def y
return rect.y
end
def width
return rect.width
end
def height
return rect.height
end
def x=(x)
rect.x = x
end
def y=(y)
rect.y = y
end
def width=(width)
rect.width = width
end
def ... | true |
82683f218a26ea859ca01d09d00683f96a9b9256 | Ruby | actsasbuffoon/zippers | /lib/zippers/cons_cell.rb | UTF-8 | 729 | 3.875 | 4 | [
"MIT"
] | permissive | module Zippers
# An immutable cons cell. It holds a single value and a pointer to the next
# cell. If this is the end of the list then it should point at EmptyCell.
#
# It's usually an O(n) operation to find the length of a linked list, but we
# can store the value directly in the list since it's immutable (t... | true |
a562461a165f5fa45e55fae36d2797826e153631 | Ruby | ttakahashi/inspect | /util.rb | UTF-8 | 434 | 2.890625 | 3 | [] | no_license | require 'tempfile'
class Util
def linedelete(filename, num_of_lines)
temp = Tempfile.new(filename + "temp", File.dirname(filename))
file = File.open(filename)
linenum = 1
file.each{|line|
temp.write(line) unless file.lineno == num_of_lines
linenum += 1
}
temp.close
m... | true |
57b41c5cb3891d8d22d12c60a54f0f67c8ed4b2c | Ruby | ifyouseewendy/baton-web | /lib/models/product_code.rb | UTF-8 | 1,358 | 3.734375 | 4 | [] | no_license | # Public: Product code presentation by 6 length default, uniform upcase,
# 0-9A-Z charset successor, 0->1, 9->A, Z->0.
#
# Examples
#
# pc = ProductCode.new('k000AZ')
#
# pc.next # => 'K000B0'
# pc.to_s # => '07X1AZ'
#
# pc.next!
# pc.to_s # => '07X1B0'
class ProductCode
CHARSET = ('0'..'9').to_a + ('A'..'Z... | true |
963c3327508ab578429dfad7c785233f1812d965 | Ruby | shideneyu/lotus | /lib/lotus/activity.rb | UTF-8 | 7,280 | 2.765625 | 3 | [] | no_license | module Lotus
# This class represents an Activity object that represents an action taken
# by a Person.
class Activity
require 'time-lord/units'
require 'time-lord/scale'
require 'time-lord/period'
include Lotus::Object
STANDARD_TYPES = [:article, :audio, :bookmark, :comment, :file, :folder,
... | true |
c51a35ed0a22d66073814b02aba83049bbffa899 | Ruby | awanderson8/Poco-A-Poco | /99-bottles-of-beer.rb | UTF-8 | 210 | 3.625 | 4 | [] | no_license | num = 99
while num > 0
puts "#{num} bottles of beer on the wall"
puts "#{num} bottles of beer!"
puts "Take one down, pass it around"
num = num - 1
puts "#{num} bottles of beer on the wall!"
puts ""
end | true |
f2abbe6504b649cd3fd29ac63e3004412fa9d4c6 | Ruby | iskyok/btc_stat | /scripts/website/binance.rb | UTF-8 | 3,679 | 2.90625 | 3 | [] | no_license | require 'parallel'
@api_key="LP3hhXt1tdK2PoQF0jZmH7fYhcNarFdk4YUK8QQ1JW4Cp9oW2X1fzIYv2gnNJQh7"
@secret="pjkGnCqDRtwmJ9jDb1xPlokAKvYwZdpmCDH3bGvIOxpBq6YJA4foqAqvdxBvt2pT"
@client = Binance::Client::REST.new(api_key: @api_key,secret_key: @secret)
#通过周线获取统计信息
# data=@client.klines symbol: "BNBBTC",interval: '1w'
# data.... | true |
f56642d9fae7c6a49d9c729a18b1c7de5b2ca9bc | Ruby | hoshito/AtCoder | /AtCoder Beginner Contest 128/main_c.rb | UTF-8 | 588 | 2.953125 | 3 | [] | no_license | n,m = gets.chomp.split(" ").map(&:to_i)
ks = []
m.times do |i|
ks << gets.chomp.split(" ").map(&:to_i)
end
p_arr = gets.chomp.split(" ").map(&:to_i)
c = 0
# 1 <= n <= 10
(2 ** n).times do |i|
bi = (i.to_s(2)).reverse + "0" * 10
arr = []
n.times do |j|
arr[j] = bi[j] == "1" ? true : false
end
flag = ... | true |
ccc529534a34eb13ec2528313408485711e16172 | Ruby | InvalidCookie/OBS-text-changer | /changer.rb | UTF-8 | 482 | 3.0625 | 3 | [] | no_license |
def load_data
@array = []
File.open('options.txt', 'r').each_line { |x|
@array << x.chomp
}
@i = 0
puts "--Data reloaded!"
end
count = 1
load_data
loop {
arr_leng = @array.length
ran_num = rand(arr_leng)
array_split = @array[ran_num].split('#')
quote = array_split[0].strip
open('stream.tx... | true |
a81b57f0e920b78b4c56d1253ce14606350d7b4e | Ruby | glurp/ang | /main_screencast.rb | UTF-8 | 8,721 | 2.5625 | 3 | [] | no_license | # Creative Commons BY-SA : Regis d'Aubarede <regis.aubarede@gmail.com>
###########################################################################
# ANG.RB : planetoide game
#--------------------------------------------------------------------------
# install ruby
# install Gosu > gem install gosu
# download this > ... | true |
293e0ad212ed23978e3ef53a4c525f1511564000 | Ruby | u5surf/twitter_info | /search.rb | UTF-8 | 1,082 | 2.640625 | 3 | [] | no_license | require 'twitter'
require 'pp'
require 'yaml'
yaml = YAML.load_file("./config.yml")
client = Twitter::REST::Client.new(
consumer_key: yaml["YOUR_CONSUMER_KEY"],
consumer_secret: yaml["YOUR_CONSUMER_SECRET"],
access_token: yaml["YOUR_ACCESS_TOKEN"],
access_token_secret: yaml["YOUR_ACCESS_SECRE... | true |
a150361b1762dd6dde954b7d764b4198a228b4cd | Ruby | Ranats/Competitive | /ABC087/B.rb | UTF-8 | 3,269 | 3.59375 | 4 | [] | no_license | a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
coin500 = [*0..a]
coin100 = [*0..b]
coin50 = [*0..c]
puts coin500.product(coin100,coin50).collect{|arr| arr[0]*500 + arr[1]*100 + arr[2]*50}.select{|num| num == x}.size
exit
count = 0
if x == 50
if c == 0
puts 0
exit
end
... | true |
e7adba9474c3151c4f5ea2e2a038763091701ee6 | Ruby | mosson/nonomurish | /lib/nonomura.rb | UTF-8 | 2,157 | 3.1875 | 3 | [] | no_license | # encoding: utf-8
# require mecab on shell
require 'romaji'
module Nonomura
def self.translate(text, level=10)
parsed = parse(text)
dic = dictionary(level.to_i)
parsed.inject(""){|memo, arr|
if dic[arr[0]]
memo << arr[1] + dic[arr[0]].sample
else
memo << arr[1] + dic[nil].s... | true |
060188f93382f8a78fc334971261c5613f5de127 | Ruby | fuser002/playground | /app/store.rb | UTF-8 | 397 | 2.703125 | 3 | [] | no_license | class Store
include Inesita::Store
def initialize
@store = {
a: 0,
b: 0,
c: 0
}
every 1 do
@store[@store.keys.sample] += 1
update_dom
end
end
def get_value(name)
@store[name]
end
def set_value(name, value)
@store[name] = value
end
def inc(name)
... | true |
f66ab4fff7bd73c8da73b7189188be9c2c10a5cb | Ruby | doomspork/icepick | /lib/icepick.rb | UTF-8 | 1,561 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'icepick/version'
require 'icepick/config'
require 'icepick/prompt'
require 'pry'
require 'pry-doc'
require 'pry-stack_explorer'
require 'pry-byebug'
require 'awesome_print'
require 'readline'
module Icepick
# AwesomePrint configuration options
AWESOME_OPTS = {
indent: 2,
sort_keys: true
}... | true |
2fde2675d2f2a071232ffc453daa3aa73f71ac92 | Ruby | travisvalentine/testing-eventable-error | /app/models/_model.rb | UTF-8 | 2,751 | 2.625 | 3 | [] | no_license | class Model
class << self; include EM::Eventable; end;
@@datas = {}
@@fields = {}
def initialize(attributes = {})
# coverts string to symbol
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
attributes.each { |key, value|
self.send("#{key}=", value) if self.class.fie... | true |
13973b17d1e506318de8d0dde257ac97cb0e4b8f | Ruby | dorsath/spaceship | /lib/spaceship.rb | UTF-8 | 4,939 | 2.59375 | 3 | [] | no_license | require 'models/cylinder'
class Spaceship < Physics::Body
def start_engine
self.accelerations[:engine] = V[0,0,-2]
end
def stop_engine
self.accelerations.delete(:engine)
end
def accelerate
push(0, 0, 10.0)
end
def brake
push(0, 0, -10.0)
end
def draw
glMultMatrix(rotation)
... | true |
2fa20eca1888d8f60bc0a7ca658c49855670c537 | Ruby | trefong/phase-0 | /week-7/gps6/my_solution.rb | UTF-8 | 3,995 | 3.8125 | 4 | [
"MIT"
] | permissive | # Virus Predictor
# I worked on this challenge [with: David Tao ].
# We spent [1] hours on this challenge.
# EXPLANATION OF require_relative
# Require_relative links to the file stated based on the relative path
# It differs from require because it loads to the file relative to the file it is in.
require_relative '... | true |
d2a386e1684dc825c2d8b358462ba2ab46578ae3 | Ruby | haruru003/furima-33029 | /spec/models/user_spec.rb | UTF-8 | 4,810 | 2.65625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context "ユーザー新規登録ができるとき" do
it "usernamaとemailとpassword、firstname、lastname 、first_name_kana、last_name_kanaが存在すると登録できる" do
expect(@user).to be_valid
end
... | true |
3558a31a5adbdf70a3e795ca0e65c9a407e34ea9 | Ruby | abenari/scoped_search_demo_app | /app/models/author.rb | UTF-8 | 231 | 2.546875 | 3 | [] | no_license | class Author < ActiveRecord::Base
attr_accessible :first_name, :last_name
has_many :books
default_scope :order => 'LOWER(authors.last_name)'
def to_s
name
end
def name
"#{first_name} #{last_name}"
end
end
| true |
2ee827ff98d1f7e7f8624b7ec8928d4a83d85cfa | Ruby | yusuketsuiki/euler | /16.rb | UTF-8 | 90 | 2.96875 | 3 | [] | no_license | num = 2**1000
sum = 0
for i in 1..9
sum += num.to_s().scan(/#{i}/).size() * i
end
p sum
| true |
82079a02673f9e8378b07284acba6812cf80ab9c | Ruby | jblee123/RoboSim_jruby | /geom_utils.rb | UTF-8 | 4,334 | 3.234375 | 3 | [] | no_license | module GeomUtils
DEG_PER_CIRCLE = 360.0
def GeomUtils.deg_to_rad( deg )
deg * ( ( 2 * Math::PI ) / DEG_PER_CIRCLE )
end
def GeomUtils.rad_to_deg( rad )
rad * ( DEG_PER_CIRCLE / ( 2 * Math::PI ) )
end
def GeomUtils.normalize_angle( angle )
angle += DEG_PER_CIRCLE while angle < 0
angle -... | true |
b7f7166d75a29a668f2361dc8e4b9d3d90cf92b2 | Ruby | SpencerLindemuth/ArtsyFartsy-Backend | /db/seeds.rb | UTF-8 | 1,489 | 2.65625 | 3 | [] | no_license | require 'rest-client'
require 'json'
PUBLIC_DOMAIN_URL = 'https://collectionapi.metmuseum.org/public/collection/v1/objects?&departmentIds=13'
INDIVIDUAL_URL = 'https://collectionapi.metmuseum.org/public/collection/v1/objects/'
def get_public_ids()
response = RestClient.get(PUBLIC_DOMAIN_URL)
get_individual_o... | true |
242e4ad0060c24f178bec27b91265cf04b14c79a | Ruby | youcefressam/tests-ruby-rspec | /lib/02_calculator.rb | UTF-8 | 256 | 3.25 | 3 | [] | no_license | def add (a,b)
return a+b
end
def subtract (a,b)
return a-b
end
def multiply (a,b)
return a*b
end
def power (a,b)
return a**b
end
def factorial(num)
if num == 0
return 1
else
return num *factorial(num-1)
end
end
| true |
b1de35421bac82a591a3eee9de32c19aadbd8851 | Ruby | yakataN/ProgrammingCompetition | /Atcorder/abc/ABC106/question_a/main.rb | UTF-8 | 100 | 3.03125 | 3 | [] | no_license | # a = gets.chomp.to_i
# b = gets.chomp.to_i
a,b = gets.chomp.split.map(&:to_i)
puts a*b-(a+b-1)
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.