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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
48ed67bf6f36a58c9327c29c53bfba7dfd411a46 | Ruby | Zeko369/algorithm-problems | /sort3.rb | UTF-8 | 454 | 3.625 | 4 | [] | no_license | def sort(arr)
items = {}
largest = nil
smallest = nil
arr.each do |item|
if items[item].nil?
items[item] = []
if largest.nil? || item > largest
largest = item
elsif smallest.nil? || item < smallest
smallest = item
end
end
items[item] << item;
end
other... | true |
c20e179121e65e2d039234afd909ae827803c303 | Ruby | demileee/farm | /farm.rb | UTF-8 | 2,925 | 3.875 | 4 | [] | no_license | class Farm
@@farm = []
@@hectares = 100
@@corn = 0
@@wheat = 0
def initialize
while true
puts <<~o
-----------------------------------
Options:
field -> adds a new field
harvest -> harvests crops and adds to total harvested
status -> displays some information about the... | true |
1bd2e88f0def4e990aa88c4139cefe98cad6fefd | Ruby | WalterJaramillo/ejerciciosRuby | /colecciones/iterador.rb | UTF-8 | 185 | 3.140625 | 3 | [] | no_license | =begin
arr =[2,4,6]
arr.each do |x|
puts x
end
arr = [2,4,6]
sum = 0
arr.each do |x|
sum +=x
end
puts sum
=end
arr = [8,11,4]
res = 1
arr.each do |z|
res*=z
end
puts res
| true |
686946d06afd7f582b55cdb207f2ec647175da9b | Ruby | kenkaigu/vaccinetime | /lib/sites/lowell_general.rb | UTF-8 | 3,753 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | require 'date'
require 'json'
require 'rest-client'
require 'nokogiri'
require_relative '../sentry_helper'
require_relative './base_clinic'
module LowellGeneral
SIGN_UP_URL = 'https://www.lowellgeneralvaccine.com/'.freeze
BASE_URL = 'https://lowellgeneralvaccine.myhealthdirect.com'.freeze
API_URL = "#{BASE_URL}... | true |
4b0915d9b9f1038d0291bf56cc35d5f1cf5da97d | Ruby | Ayakakaaa/AwsomeAnswer | /app/controllers/contacts_controller.rb | UTF-8 | 730 | 2.578125 | 3 | [] | no_license | class ContactsController < ApplicationController
def new
# render :new
end
def create
# render :create
# all parameters from HTTP or URL come in a hash called `params`
# params is a `hash with indifferent access` meaning that you can
# access values using string or ... | true |
931548365ccc6856553241a54cc2eb882d200deb | Ruby | piotrmurach/tty-progressbar | /examples/multi/resume.rb | UTF-8 | 331 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require_relative "../../lib/tty-progressbar"
bars = TTY::ProgressBar::Multi.new("main [:bar] (:current/:total)")
bar1 = bars.register "foo [:bar] :percent", total: 10
10.times { bar1.advance; sleep(0.1) }
bar2 = bars.register "bar [:bar] :percent", total: 15
15.times { bar2.advance; sl... | true |
8e5f78c1bcd2013227ae8f06253b654a62230d11 | Ruby | dmartinez09/Ruby1 | /Ejercicio_4/ej3.rb | UTF-8 | 271 | 4.09375 | 4 | [] | no_license | #Ejercicio 4: Arrays y strings.
#Crear un método que devuelva un arreglo con la cantidad de caracteres que tiene cada nombre.
a = ["Violeta", "Andino", "Clemente", "Javiera", "Paula", "Pia","Ray"]
a.each do |i|
i.length
puts "#{i} tiene #{i.length} caracteres"
end
| true |
b11e35e321145374c90c6e8708fbe47009134719 | Ruby | alexperez2160/reivew_101 | /odd.rb | UTF-8 | 147 | 3.578125 | 4 | [] | no_license | # arr = (1..99).to_a
# odd_arr = arr.select {|x| x.odd?}
# odd_arr.each {|x| puts x}
#or
0.upto(99) do |i|
if i.odd?
puts i
end
end
| true |
ab60e8f8043b9d45420b74434a52e158bf921f2e | Ruby | MrRob0t404/prime-ruby-001-prework-web | /prime.rb | UTF-8 | 188 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
x = 2
if num <= 1
return false
end
while x < num
if num % x == 0
return false
end
x += 1
end
return true
end
| true |
37977f1f4608ccaf86b2146a17829e68e4aa7b52 | Ruby | Jared-Prime/basic-dsa | /ruby/spec/queue_spec.rb | UTF-8 | 1,752 | 3.265625 | 3 | [] | no_license | require './lib/queue'
require './lib/node'
describe Queue do
subject { described_class.new }
describe '.initialize' do
it 'creates an empty queue' do
expect(subject.head).to be_nil
expect(subject.tail).to be_nil
end
end
describe '#push' do
context 'into an empty Queue' do
it 'se... | true |
288c053088b1729c58ed0119919e70a7f7ef5bec | Ruby | ga-wolf/wdi-21 | /06-sinatra/intro/main.rb | UTF-8 | 1,541 | 3.453125 | 3 | [] | no_license | require "pry"
require "sinatra"
require "sinatra/reloader"
# Create our first literal route
# Route is an HTTP Method (or verb) paired with a Path
# localhost:4567
# localhost:4567/
get "/" do
"Hello World"
end
# localhost:4567/about
get "/about" do
"I am Bill Murray"
end
# GET localhost:4567/hi
get "/hi" ... | true |
57bbab5def767cb7870f0556fbe696971f5a26d6 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex1432.rb | UTF-8 | 221 | 2.734375 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 648
require 'dl'
Message = DL.dlopen("code/dl/lib.so")
print_msg = Message[ "print_msg", "ISI" ]
msg_size, args = print_msg.call("Answer", 42)
puts "Just wrote #{msg_size} bytes"
| true |
d04fb2e4fde399f371d5acfa094e8db11295d6c9 | Ruby | PlumpMath/DesignPatterns-424 | /Day3/product_b.rb | UTF-8 | 426 | 3.171875 | 3 | [] | no_license | class ProductB
def do_my_job
puts "My subclass didn't override this method.It's a lazy product!!!"
end
end
class CoolProductB < ProductB
def do_my_job
puts "I'm a ProductB, doing it COOL!!!"
end
end
class UncoolProductB < ProductB
def do_my_job
puts "I'm a ProductB, doing it UNCOOL!!!"
end
end... | true |
3a66cb5f57ecc24e6089aaa1e4c7a16b7c1e7b0b | Ruby | Dgibbins/learn_ruby | /05_hello_friend/hello_friend.rb | UTF-8 | 186 | 3.515625 | 4 | [] | no_license | class Friend
attr_accessor :greet
def initialize
end
def greet(string="")
"Hello #{string}!"
end
end
@friend=Friend.new
puts @friend.greet("Bob")
puts @friend.greet
| true |
172e328916bbe0e62947d6d7d447114ed0f7ec7c | Ruby | Stmu/opendelivery_gem | /lib/opendelivery/domain.rb | UTF-8 | 4,702 | 2.53125 | 3 | [
"MIT"
] | permissive | #Copyright (c) 2014 Stelligent Systems LLC
#
#MIT LICENSE
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, me... | true |
8497a5129849beee768e168c1583e4cc0f20497f | Ruby | CJStadler/state_machine_checker | /lib/state_machine_checker/ctl/e_x.rb | UTF-8 | 1,189 | 3.03125 | 3 | [
"MIT"
] | permissive | require_relative "unary_operator"
require "state_machine_checker/check_result"
require "state_machine_checker/state_result"
module StateMachineChecker
module CTL
# The existential next operator.
class EX < UnaryOperator
# Check which states of the model have as a direct successor a state
# satisf... | true |
9cae7c6268ee6a8dfb604588aa954c8669499f45 | Ruby | bhbops/granpark.rb | /granpark.rb_23/puyopuyo.rb | UTF-8 | 3,031 | 3.40625 | 3 | [] | no_license | #!/usr/bin/ruby
# コマンドライン引数からデータファイル名を取得
$datafile = ARGV[0]
if $datafile == nil then # 無指定時のデータファイル名
$datafile = "puyo.data"
end
# グローバル変数
$stack = [] # 探索結果を一時的にためる
# 読み込んだデータを一問づつ解析
def analysis_data(row, col, data)
counter = 2
offset = 0
while (offset = search_origin(data)) != -1 do
if trace(offset, row, c... | true |
ee170b4cc289de185b1f9b19e54bc0ced295182e | Ruby | AnaisNWK/crazy_scrapping | /lib/mairiechristmas.rb | UTF-8 | 891 | 2.953125 | 3 | [] | no_license | require 'nokogiri'
require 'rubygems'
require 'open-uri'
# 1 : Récupérer les URLS de chaque ville
page = Nokogiri::HTML(open("https://www.annuaire-des-mairies.com/val-d-oise.html"))
page.xpath('//*[@id="voyance-par-telephone"]/table/tbody/tr[2]/td/table/tbody/tr/td/p/a').each do |el|
puts el.text
end
# 2 : Mettre... | true |
4fc1d267cc676bed2897826e20c855fa76517a3d | Ruby | kijimaD/well-grounded-rubyist | /CH6/11loop.rb | UTF-8 | 293 | 3.25 | 3 | [] | no_license | n = 1
loop do
puts n
n = n + 1
break if n > 9
end
n = 1
loop do
puts n
n = n + 1
next unless n == 10
break
end
n = 1
begin
puts n
n = n + 1
end while n < 10
puts "Done!"
# the body is executed once before the test is preformed.
n = 1
until n > 10
puts n
n = n + 1
end
| true |
7ef14f288f5cd5163eed79b95a0509c1201b2b36 | Ruby | HenryYHHsu/ruby_code_train | /config.ru | UTF-8 | 860 | 3.1875 | 3 | [] | no_license | # app=run Proc.new { |env|
# [
# '200', # http status
# {'Content-Type' => 'text/html'}, # Header
# ['Heloo Rack 1104'] # Body
# ]
# }
# run app
# app.call(env)
# class Cat
# def call(env)
# [
# '200', # http status
# {'Content-Type' => 'text/html'}, # Header
# # ['Heloo ... | true |
0a8780479e0b52be7f56fa40aebf74f4ba90d5d9 | Ruby | mariasoria/ruby_education | /Scripts to learn/even.rb | UTF-8 | 160 | 2.9375 | 3 | [] | no_license | numero = gets.chomp
numero = numero.to_i
residuo = numero % 2
if residuo == 0
puts "#{numero} es par"
end
=begin
1. **
2. * / %
3. + -
=end
| true |
9d92c289ae6b7c562eb2becf6635bbac592864cf | Ruby | anon0mys/scrabble | /test/game_reader_test.rb | UTF-8 | 987 | 3.03125 | 3 | [] | no_license | gem 'minitest'
require_relative '../lib/game_reader'
require_relative '../lib/player'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
class GameReaderTest < Minitest::Test
def game
@game
end
def setup
@game = GameReader.new
end
def test_game_generates_players
assert_instance_... | true |
e071f516b1f93c195e6e8625a951dd7b50f37f18 | Ruby | BillyDa/oop_inheritance | /MathGenius.rb | UTF-8 | 526 | 3.46875 | 3 | [] | no_license | require_relative 'multilinguist'
class MathGenius < Multilinguist
def report_total(array)
@total = 0
array.each do |sum|
@total += sum
end
@genius = "The total is #{@total}."
self.say_in_local_language(@msg)
end
end
me = MathGenius.new
puts me.report_total([23,45,676,34,5778,4,23,5465])
... | true |
2b445a53a0924ef8730e1f08e8ff4c60b4a5b75a | Ruby | Bderv/Ruby-on-Rails | /fundamentals/bank_tdd/bank_account.rb | UTF-8 | 1,503 | 3.484375 | 3 | [] | no_license | class BankAccount
@@accounts = 0
def initialize bank_num = 0, checkings = 0, savings = 0, interest = 0.01
@bank_num = bank_num
@checkings = checkings
@savings = savings
@@accounts += 1
bank_num_generator
end
def display_bank_num
return @bank_num
... | true |
4bdb96685657eacb5f158e7ac54043dd59afb54c | Ruby | acmassey3698/bitter-frost-9212 | /app/models/chef.rb | UTF-8 | 339 | 2.71875 | 3 | [] | no_license | class Chef < ApplicationRecord
has_many :dishes
def all_ingredients
ingredients =
dishes.map do |dish|
dish.ingredients
end
ingredients.flatten.uniq
end
def most_popular_ingredients
result =
all_ingredients.sort_by do |ingredient|
ingredient.dishes.length
end
result... | true |
ae7181486c2504e5aa55d00a1d31298dcf740057 | Ruby | qzio/neo4j-challange | /app.rb | UTF-8 | 1,815 | 2.53125 | 3 | [] | no_license | require "rubygems"
require "sinatra/base"
require "neography"
require "flattr"
require './lib/graph'
require './lib/scrape'
require './lib/user_node'
require './lib/thing_node'
class App < Sinatra::Base
if development?
Flattr.configure do |config|
config.endpoint = "https://api.flattr.dev/"
end
e... | true |
13a2d4ff12d24413c1bc2bb2974f43f804ada406 | Ruby | alistairkung/money_tracker_tech_test | /lib/earning.rb | UTF-8 | 187 | 2.921875 | 3 | [] | no_license | require 'date'
class Earning
attr_reader :date, :debit, :credit
def initialize(amount, datestring)
@date = Date.parse(datestring)
@debit = 0
@credit = amount
end
end
| true |
683b2a64a2999f284eb85314a7c8063897ebb9b4 | Ruby | Pancia/dotfiles | /lib/ruby/music/import.cmd.rb | UTF-8 | 1,719 | 2.65625 | 3 | [] | no_license | require 'music/music_db.rb'
module MusicCMD
def import(opts)
opts.banner = "Usage: import FILES"
opts.info = "Imports files into $MUSIC_DB & $MUSIC_DIR"
opts.on("-p", "--playlist PLAYLIST_NAME", "String to use as FILES's PLAYLIST metadata") { |pl|
$options[:playlist] = pl
}
opts.on("-a", "... | true |
f55364c38b6981bf8736e021cb0544a1fadcc093 | Ruby | Payal13/training_assignments | /Pragati/Day1/Question5.rb | UTF-8 | 314 | 3.484375 | 3 | [] | no_license | def get_ip_class
puts "Please enter IP address"
ip = gets
first = ip.split(".")[0].to_i
case first
when 0..127
puts "A"
when 128..191
puts "B"
when 192..223
puts "C"
when 224..239
puts "D"
when 240..255
puts "E"
else
puts "Please enter valid IP"
end
end
get_ip_class
| true |
564c71fc6fa838ae98c0866342f0f6127f6e96db | Ruby | lishulongVI/leetcode | /ruby/600.Non-negative Integers without Consecutive Ones(不含连续1的非负整数).rb | UTF-8 | 1,727 | 3.59375 | 4 | [
"MIT"
] | permissive | =begin
<p>Given a positive integer n, find the number of <b>non-negative</b> integers less than or equal to n, whose binary representations do NOT contain <b>consecutive ones</b>.</p>
<p><b>Example 1:</b><br />
<pre>
<b>Input:</b> 5
<b>Output:</b> 5
<b>Explanation:</b>
Here are the non-negative integers <= 5 with the... | true |
1dea34897348bd66562b1b4b66ebbaa2f4a13b50 | Ruby | JuanFdS/scriptBolaMagica | /bolaMagica/ruby/bolaMagicaRuby | UTF-8 | 603 | 3.5625 | 4 | [] | no_license | #!/usr/bin/env ruby
ruta_a_respuestas = ARGV[0] # leemos los argumentos que le pasan al programa
respuestas = File.readlines ruta_a_respuestas
# el while True es para que el programa nos vuelva a preguntar en vez de terminar
while true
# usamos stdout para mostrar cosas por la consola
puts "Preguntá algo:"
pr... | true |
79b37071bef0bc8d1245753ac126493e6c57f1aa | Ruby | RajeshPaul38/enterprise-chef-common | /libraries/dsl.rb | UTF-8 | 957 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | require_relative 'helpers'
module EnterpriseChef
# Allows us to use various helper methods directly in recipes,
# resources, and providers without a lot of ceremony.
#
# Thus, instead of something like
#
# if Foo::Bar.is_awesome?(node)
# include_recipe "awesome::default"
# end
#
# we can do... | true |
c3263a4360b2dc6490851d8f903a412b887c5117 | Ruby | epitron/epitools | /lib/epitools/typed_struct.rb | UTF-8 | 4,394 | 3.40625 | 3 | [
"WTFPL",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# Like a Stuct, but automatically casts assignments to specific types.
#
# Example:
#
# class SomeRecord < TypedStruct["some_id:int amount:float name:string a,b,c:bool untyped_var"]
# end
#
# record = SomeRecord.new(69, 12348.871, "stringy", true, 1, "no", Object.new)
#
# another_record = SomeRecord.new :amou... | true |
cec27a9d7f6bde023e8c64c54eb3912c862b53e9 | Ruby | niw/type_pad_template | /lib/type_pad_template/request.rb | UTF-8 | 1,249 | 2.53125 | 3 | [] | no_license | module TypePadTemplate
class Request
DEFAULT_HOST_NAME = "www.typepad.com"
MAX_CONCURRENCY = 10
def self.dispatch
hydra.run
end
def self.hydra
@@hydra ||= Typhoeus::Hydra.new(:max_concurrency => MAX_CONCURRENCY)
end
def initialize(url_or_path, options = {})
@url_or_pat... | true |
54f61de3161e7ab8be644cc0528ab400435f30c0 | Ruby | liweinan/recipies | /algorithm/diagraph/directed_depth_first_search.rb | UTF-8 | 342 | 2.890625 | 3 | [] | no_license | class DirectedDepthFirstSearch
attr_accessor :marked
def initialize
@marked = []
end
def search(diagraph, vertex)
@marked << vertex
diagraph.vertexesFrom[vertex.key] ||= []
diagraph.vertexesFrom[vertex.key].each do |vertexFrom|
search(diagraph, vertexFrom) unless @marked.include?(vertexF... | true |
06cac0175b47d9883233b1b3e6b3a679782ace5c | Ruby | JoyceKell/why_is_ruby | /regular_expressions/exclude_characters.rb | UTF-8 | 98 | 2.875 | 3 | [] | no_license | sales = "I bought 9 apples, 25 bananas an 4 oranges at the store"
p sales.scan(/[^aeiou,\s\d\.]/) | true |
bb4826e0480f503dede1423db7d6247a0c62b572 | Ruby | itiut/sutra-copying | /tanoshi-ruby/s08/point.rb | UTF-8 | 338 | 3.671875 | 4 | [] | no_license | class Point
attr_accessor :x, :y
protected :x=, :y=
def initialize(x=0.0, y=0.0)
@x, @y = x, y
end
def swap(other)
@x, other.x = other.x, @x
@y, other.y = other.y, @y
self
end
end
p0 = Point.new
p1= Point.new(1.0, 2.0)
p [p0.x, p0.y]
p [p1.x, p1.y]
p0.swap p1
p [p0.x, p0.y]
p [p1.x, p... | true |
31ec2e55d4bd72c41a7e041abbf9378df6c6c45e | Ruby | abeland/rubylab | /lib/sorting/selection_sort.rb | UTF-8 | 968 | 3.53125 | 4 | [] | no_license | require 'sorting'
module SelectionSort
include Sorting
def selection_sort(arr)
# In selection sort, for each outer loop iteration i, we are
# *selecting* the ith *statistic* of the array and placing
# it into index i. Therefore, after i=n iterations, each
# index i in the array has the ith stastic... | true |
74084109f25b0a017b223778c2eb898a95d45346 | Ruby | andradite/melanite | /data/samples/test.rb | UTF-8 | 2,213 | 4.15625 | 4 | [] | no_license | def genKey(start)
#~ Create array to store sets
a = Array.new
#~ Generate first set
b = craft(start[0])
a.push(b[0]+b[1]+b[2]+b[3])
#~ Generate second set
b = craft(start[1])
a.push(b[1]+b[2]+b[3]+b[0])
#~ Generate third set
b = craft(start[2])
a.push(b[2]+b[3]+b[0]+b[1])
#~ Generate fourth set
... | true |
b4ca8f9fa5c65f591ef6302fc88ea61e232f0778 | Ruby | Niyy/ludum-dare-depths-of-corruption | /app/tile.rb | UTF-8 | 2,134 | 3.3125 | 3 | [] | no_license | require 'app/Grid_Object.rb'
require 'app/Sprite_Grid_Object.rb'
class Tile < Sprite_Grid_Object
attr_accessor :binary, :marked, :is_grounded_level, :paths, :cost
def initialize(init_args)
super(init_args)
@marked = 0
@is_grounded_level = init_args[:is_grounded_level] != nil ?
... | true |
816c62934b9369c7d5b530841d276f846a69d64d | Ruby | TryCitra/tryPhoto | /return_url_to_the_user.rb | UTF-8 | 1,140 | 2.65625 | 3 | [] | no_license | require 'fileutils'
address_is = String.new
puts "\e[H\e[2J"
puts "=============================================="
puts " Parsing URL to your gallery... "
puts "=============================================="
if File.file?(".git/config") then
config_git_file = File.open('.git/config').read
config_git_file.gsub!(... | true |
d0ea84cf1a3b393f96658740badcf109cfa0d467 | Ruby | chanakyav/aAClasswork | /W4D4/poker/lib/deck.rb | UTF-8 | 399 | 3.171875 | 3 | [] | no_license | require_relative 'card'
class Deck
attr_reader :cards
SUITS = %w( Spades Clubs Hearts Diamonds ).freeze
NUMBERS = %w( Ace King Queen Jack 10 9 8 7 6 5 4 3 2 1 ).freeze
def initialize
@cards = []
generate_cards
@cards.shuffle!
end
def generate_cards
SUITS.each do |suit|
NUMBERS.eac... | true |
6e1e26fe50fa9063932ae57d5337e5a2ad86bea8 | Ruby | Alastair2D/boris_bikes | /lib/garage.rb | UTF-8 | 314 | 3.03125 | 3 | [] | no_license | class Garage
attr_reader :bikes_awaiting_repair, :repaired_bikes
def initialize
@bikes_awaiting_repair = []
@repaired_bikes = []
end
def fix(bike)
bike = bikes_awaiting_repair.sample
bikes_awaiting_repair.delete(bike)
repaired_bikes << bike
end
end
| true |
f9ac1caa90a437454f3e7fe98473b5b19276500c | Ruby | erithmetic/leap | /lib/leap/deliberation.rb | UTF-8 | 453 | 2.84375 | 3 | [
"MIT"
] | permissive | module Leap
class Deliberation
attr_accessor :characteristics
attr_accessor :reports
def initialize(characteristics)
self.characteristics = characteristics
self.reports = []
end
def [](characteristic)
characteristics[characteristic]
end
def compliance
... | true |
a1ee3adb228ebeda1a0fd5b2c5a40d5539731be9 | Ruby | kouheiszk/moneyforward-crawler | /moneyforward-crawler.rb | UTF-8 | 1,489 | 2.640625 | 3 | [] | no_license | require 'pry-byebug'
require 'nokogiri'
require 'mechanize'
require 'yaml'
class MoneyforwardCrawler
def initialize
@config = YAML.load_file('config.yml')
end
def retrieve
agent = Mechanize.new do |agent|
agent.log = Logger.new($stdout)
agent.user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac O... | true |
f72d8a04d26f43a3c9f184027d99489de6dc2934 | Ruby | JanMeckelholt/doko | /app/models/hand.rb | UTF-8 | 1,138 | 2.578125 | 3 | [] | no_license | class Hand < ActiveRecord::Base
#include ActiveModel::Model
#
has_many :cards #, -> { order(order_value) }
belongs_to :player
validates :cards, length:{maximum: 10}
#attr_accessor :hand_cards
#def initialize(player)
# @hand_cards = []
#end
#def add_card(card)
# @hand_cards << card
... | true |
7d991cbe6a418b55b06a68fa5cd192224c1018a5 | Ruby | salamidrus/ruby_101 | /classes_and_objects/initialize_method.rb | UTF-8 | 266 | 3.796875 | 4 | [
"MIT"
] | permissive | class Book
attr_accessor :title, :author, :pages
def initialize(title, author, pages)
@title = title
@author = author
@pages = pages
end
end
book3 = Book.new("Math", "Putri", 300) # Create object using intialize
puts book3.title | true |
73a242ae11ff84b8a9a2bcf58f9b2115f7d59f78 | Ruby | vinaysolanki/coin_market_cap | /lib/coin_market_cap/coin.rb | UTF-8 | 655 | 3.09375 | 3 | [
"MIT"
] | permissive | module CoinMarketCap
COIN_MARKET_CAP_URL = "https://coinmarketcap.com/"
# Coin class
class Coin
attr_accessor :coin
def initialize(coin)
@coin = coin.downcase
@currencies = fetch_coin_prices
end
def price
@currencies[@coin]
end
private
def fetch_coin_prices
doc = Nokogiri:... | true |
94884a70825c277acf56b54b4d9a5b33c8f791be | Ruby | tric/trick2013 | /nari/entry.rb | UTF-8 | 2,134 | 3.046875 | 3 | [
"MIT"
] | permissive | GC.disable
Tape = ObjectSpace
class Cell
attr_accessor :symbol
def initialize(s)
@symbol = s
end
end
class BF
def initialize
@max_id = 0
end
def run(src)
state = {pc: 0, head: 0, op: src[0]}
inc = last = 0
clocked = false
_, jump = src.chars.each_with_object([[], {}]).with_index d... | true |
872d71756633d63bbd66ae9e95b3c5b1a39c9d7f | Ruby | rmd6502/Commute_Info | /app/models/stop.rb | UTF-8 | 5,515 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'number_formatter'
require 'rbtree'
require 'stops_helper'
# A Stop is a station where one or more Routes intersect
class Stop < ActiveRecord::Base
set_primary_key "stop_id"
has_many :stop_times , :include => :trip, :order => :departure_time
has_many :trips, :through => :stop_times, :order => :departure_... | true |
0cf7215c5231498d5b522aa78a8d6f7a219c8bee | Ruby | rcclemente/trbcc | /spec/audio_format_spec.rb | UTF-8 | 639 | 2.546875 | 3 | [] | no_license | require_relative "../lib/audio_format.rb"
describe AudioFormat do
subject{ AudioFormat.new 15 }
before do
subject.check_brand_orders
end
describe '.orders' do
it "is not empty" do
orders = [
{:set_key=>6, :count=>1, :price=>810, :amount=>810},
{:set_key=>9, :count=>1, :price=>11... | true |
4bf752daaa02fcc230f4df7c96358e64a9fc5d43 | Ruby | rchen93/Quotopia | /test/models/author_test.rb | UTF-8 | 1,117 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class AuthorTest < ActiveSupport::TestCase
fixtures :authors
test "author name must not be empty" do
author = Author.new
assert author.invalid?
assert author.errors[:name].any?
end
test "should not save author without a name" do
author = Author.new
assert_not author.... | true |
4894363253dd66c4a9da99885a2624634ae6cd89 | Ruby | rparkerson/launch-school | /RB101/lesson_4_ruby_collections/practice_problems_additional_practice/7.rb | UTF-8 | 1,731 | 4.40625 | 4 | [] | no_license | =begin
Create a hash that expresses the frequency with which each letter occurs
in this string:
statement = "The Flintstones Rock"
ex:
{ "F"=>1, "R"=>1, "T"=>1, "c"=>1, "e"=>2, ... }
P
input: string
output: hash
rules
explicit:
create a hash with keys as letters and values as corresponding frequence
of letter
implic... | true |
b1c3bfdab739fa7a044a4d7bd99bb7ab8f58f5b9 | Ruby | wolverineks/oop | /models/question.rb | UTF-8 | 898 | 2.984375 | 3 | [] | no_license | class Question
attr_accessor :count
attr_reader :id, :difficulty, :category_id, :category_name, :sub_category_id, :sub_category_name
@@questions = []
def initialize(args)
@id = args[:question_id].to_i
@category_id = args[:category_id].to_i
@category_name = args[:category_name]
... | true |
0485f3bfc7f179099bdbc68f99bbd406d38e0779 | Ruby | bonjourannie/learn-co-sandbox | /weather_by_zip_code/lib/weather_by_zip_code/scraper.rb | UTF-8 | 360 | 3.1875 | 3 | [
"MIT"
] | permissive | #https://www.wunderground.com/cgi-bin/findweather/getForecast?query=pz:981&zip=1
require'nokogiri'
require 'open-uri'
require 'pry'
class Scraper
def self.city_by_zip(num)
url = "https://www.wunderground.com/cgi-bin/findweather/getForecast?query=pz:#{num}1&zip=1"
doc = Nokogiri::HTML(open(url))
bind... | true |
f480040cc3f8fcac26cad5fd7c00242120b09aaf | Ruby | smthom05/cronut | /models/batter.rb | UTF-8 | 154 | 2.515625 | 3 | [] | no_license | class Batter
attr_reader :id,
:type
def initialize(batter_data)
@id = batter_data["id"]
@type = batter_data["type"]
end
end
| true |
11faf3eac58e973bb6b46b902263174a1b919a44 | Ruby | nadiabarache/sample_app | /app/controllers/users_controller.rb | UTF-8 | 652 | 2.5625 | 3 | [] | no_license |
# ------ Note ------------#
# params : Contient des infos sur chaque requete
class UsersController < ApplicationController
def new
#le titre personnalisé
# pour la page de nouvel utilisateur
@user =User.new
@titre ="Inscription"
end
def show
# trouver les utilisateurs avec leur id
... | true |
db49eafd2b556af9aecc66aaa683edb352933770 | Ruby | NILID/kinship | /app/helpers/people_helper.rb | UTF-8 | 1,686 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | module PeopleHelper
def setup_person(person)
person.birth ||= LifeEvent::Birth.new
person.death ||= LifeEvent::Death.new
person
end
def get_json_pedigree_tree(person)
if person.birth.date
birthday = person.birth.date.strftime("%-Y")
else
birthday = "?"
end
if person.death.... | true |
44484a93a10f3823d2d812c0bee11f27ce4a2116 | Ruby | rbotafogo/RubyRich | /lib/sol/base_chart.rb | UTF-8 | 6,316 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*-
##########################################################################################
# @author Rodrigo Botafogo
#
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
# and distribute this software and its documentation, without fee and without a sig... | true |
dbfbfc79751fd949aa0df4f1e37629f5e4c18e57 | Ruby | igauravsehrawat/Algorithms | /fbhc_square_detector2.rb | UTF-8 | 1,129 | 3.046875 | 3 | [] | no_license | #separate function for problem logic
#don't debug in irb unless you know what's there for you. #dumb
def yesorno(some_string)
count=0
counter_count=0
f=File.open(some_string,"r")
sizer=f.size
f.each_line do|line|
for i in 1..line.size do
if(line[i]=="#")
count=count+1#counting first occurence of # in any... | true |
b977eaeddb2f504727fb96de37d919db4963005e | Ruby | baileytalks/boris_bikes | /lib/van.rb | UTF-8 | 481 | 2.96875 | 3 | [] | no_license | class Van
attr_reader :bikes
def initialize
@bikes = [ ]
end
def deliver(garage)
if @bikes.count == 0
raise "No bikes to deliver"
else
@bikes.each { |bike| garage.bikes.push bike }
@bikes = []
# garage.bikes.push(@bikes[0])
# @bikes.delete_at(0)
# garage.bikes.p... | true |
b4bd0f1e2409fab010f8c33b4497fb9b4f2b9d40 | Ruby | kclancy/bowling | /spec/bowling_spec.rb | UTF-8 | 1,027 | 3.078125 | 3 | [] | no_license | require 'bowling'
module Bowling
describe Bowling do
describe Game do
before(:each) do
@game = Game.new
end
it 'can create the Game class' do
@game.should be_instance_of Game
end
it 'can have a score set' do
@game.score = "XXXXXXXXXX"
end
it 'c... | true |
c484182bc8c3635da5205238dbf94acf02b6b989 | Ruby | mariow/elo | /app/models/player.rb | UTF-8 | 2,853 | 2.515625 | 3 | [] | no_license | class Player < ActiveRecord::Base
has_many :participations, :class_name => "Participant", :inverse_of => :player
has_and_belongs_to_many :leagues
has_many :games, :through => :participations, :limit => 20, :order => "created_at DESC"
belongs_to :last_game, :class_name => "Game"
acts_as_audited :except ... | true |
a356dba2022efb17694ddb290fcd603d2c947a6c | Ruby | DeveloperAlan/WDI_SYD_7_Work | /w01/d02/eugenius/prompt.rb | UTF-8 | 2,737 | 3.6875 | 4 | [] | no_license | require 'rainbow'
# A user should be given a menu of operations
# A user should be able to choose from the menu
def menu
print "Welcome to the calculator\n\n"
print "Please select an option below."
print Rainbow("\n(B)").yellow + "asic Caculator"
print Rainbow("\n(A)").yellow + "dvanced Calculator"
print Rai... | true |
5e638a57a2f944cddbb90f0eddfce07cf1d5ba75 | Ruby | rarch/codeeval | /easy/sumprimes.rb | UTF-8 | 278 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
def isprime(n)
return false if n<2 or n%2==0
3.step(Math.sqrt(n).ceil,2) do |i|
return false if n%i==0
end
true
end
count=1
sum=2
n=3
while count<1000 do
if isprime(n)
count+=1
sum+=n
end
n+=2
end
puts sum | true |
4f9dea677969d0878672f306125df89d0a00bf50 | Ruby | alexrothenberg/motion-addressbook | /motion/address_book/ios/multi_valued.rb | UTF-8 | 5,378 | 2.703125 | 3 | [
"MIT"
] | permissive | module AddressBook
class MultiValued
include Enumerable
attr_reader :mv_type
def initialize(opts)
unless opts.one?
raise ArgumentError, "MultiValued requires :attributes *or* :ab_multi_value argument"
end
if opts[:ab_multi_value]
@ab_multi_value = ABMultiValueCreateMut... | true |
1f3351d8af3e65d9d517b82951d31a84ac6785b1 | Ruby | skellock/rmq | /spec/utils.rb | UTF-8 | 5,291 | 2.90625 | 3 | [
"MIT"
] | permissive | module TestIsClassModule
class TestIsClassClass
end
class TestIsClassSubClass < TestIsClassClass
end
end
describe 'utils' do
before do
@rmq = RubyMotionQuery::RMQ
end
it 'should return true if class is passed to is_class?' do
@rmq.is_class?(String).should == true
@rmq.is_class?(UIView).shou... | true |
3030fd15b8aceed743a3c93b6aedd91f1ca184e6 | Ruby | data-driven/tealeaf-ruby-precourse | /oop_04_inheritence/exercise6.rb | UTF-8 | 1,134 | 4.21875 | 4 | [] | no_license | =begin
Exercise 5
Write a method called age that calls a private method to calculate
the age of the vehicle. Make sure the private method is not available
from outside of the class. You'll need to use Ruby's built-in Time class to help.
=end
module Haulable
def haul_cargo
puts "I'm a truck so I can haul ca... | true |
e66e0d8934f062b567e9ca294a399a1aaf4b9d89 | Ruby | dohliam/corpus-tools | /scripts/corpus_freq.rb | UTF-8 | 2,233 | 3.015625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby -KuU
# encoding: utf-8
# Print frequency list for all texts in a given folder, all
# words in a file, or all text in a pipe.
# Tailored for use with the texts from the ASP corpus:
# https://github.com/global-asp/asp-source
#
# Usage:
# ruby corpus_freq.rb [path/to/directory]
# =or=
# ruby corpus_freq.r... | true |
68838ba8d69f8882e7e53422526bf3be12389df1 | Ruby | chrischau/ProjectEuler | /010/ProjectEulerProblem010.rb | UTF-8 | 217 | 3.25 | 3 | [] | no_license | require 'mathn'
startTime = Time.now
sum = 0
for p in Prime.each(2000000)
sum += p
end
puts "Sum of all prime numbers below 2 million is " + sum.to_s
puts "Time took: " + (Time.now - startTime).to_s + " seconds" | true |
90a0fdf67c918469ee50ff362642df881576f4f5 | Ruby | mikz/Thesis | /examples/tests/spec.rb | UTF-8 | 430 | 2.5625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'example'
describe Example, "example with value" do
let(:value) { "value" }
subject { Example.new(value) }
describe "when asked about the value" do
it "should be the value" do
subject.value.must_equal value
end
end
it "should be truthy" do
subje... | true |
6f47c7d91bbdf21366b8bcf72135c80a1982e46f | Ruby | BagelEnthusiast/school-domain-houston-web-career-040119 | /lib/school.rb | UTF-8 | 691 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
require 'pry'
class School
attr_accessor :roster
def initialize(name)
@school = name
@roster = {}
end
def add_student(name, grade)
@roster[grade] ||= []
@roster[grade] << name
#binding.pry
end
def grade(student_grade)
... | true |
5020ccb0dfdd37a13200e225f380013ac2864aa4 | Ruby | otukutun/himekaminize | /lib/himekaminize/nodes/header.rb | UTF-8 | 569 | 2.921875 | 3 | [
"MIT"
] | permissive | module Himekaminize
module Nodes
class Header < BaseNode
PATTERN = /\#{1,6}/
attr_accessor :space, :name, :level, :size
def initialize(line)
@space, @level, @name = split_name_and_level(line)
@size = count_size
end
def to_s
sprintf("%s%s%s\n", @space, @leve... | true |
0ea9b4b6a463c108d1cfb0424c77d415b2e445fe | Ruby | TonyNarisi/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 1,809 | 4.28125 | 4 | [] | no_license | # Pseudocode
# Split the full name string into an array to separate first and last names
# Reverse the position of the names
# Join the names back together
# Make all letters in the full name lowercase so that they are easier to smoothly manipulate
# Define string of all vowels and string of all consonants
# Loop throu... | true |
d19cc48d58c05bc7800a02ba533197ac9572eeb7 | Ruby | Koupah/Ruby-Web-Editor | /classes/features/css/CssUtil.rb | UTF-8 | 412 | 2.875 | 3 | [] | no_license | # Best name I could come up with LMAO
class CssUtil
# Function to ensure root variable name begins with --
def CssUtil.rootVariableName(name)
if !name.start_with?("--")
name = "--" + name
end
return name
end
# Function to ensure class name begins with .
def CssUtil.classVariableName(name)
... | true |
d92973135b375edc08ea22dc50f23a95e250fd57 | Ruby | nerab/taskwarrior | /lib/taskwarrior/repository.rb | UTF-8 | 1,680 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module TaskWarrior
class Repository
def initialize(input)
@tasks = {}
@projects = Hash.new { |hash, key| hash[key] = Project.new(key) }
@tags = Hash.new { |hash, key| hash[key] = Tag.new(key) }
JSON.parse(input).each do |json|
task = TaskWarrior::Tas... | true |
b59089b6c3242772b7c502638d86841aac141d1d | Ruby | flowlikewater/rock-paper-scissors | /lib/rock.rb | UTF-8 | 634 | 2.96875 | 3 | [] | no_license | require ('pry')
class String
define_method(:rock) do |other_player_play|
self.downcase!()
if self.eql?(other_player_play)
return "draw"
elsif self == "scizzor"&& other_player_play == "rock"
return "lose"
elsif self == "paper"&& other_player_play == "rock"
return "win"
elsif self... | true |
77583accdff1ee69c6aaee016b9f79b1cca59282 | Ruby | phallguy/shamu | /lib/shamu/entities/list_scope.rb | UTF-8 | 3,472 | 2.765625 | 3 | [
"MIT"
] | permissive | module Shamu
module Entities
# The desired scope of entities offered {Services::Service} to prepare a
# list of {Entity entities}.
#
# ### Standard scopes
#
# - {Paging}
# - {ScopedPaging}
# - {Dates}
# - {Sorting}
#
# @example
# class UsersListScope < Shamu::Entitie... | true |
3f2dd185716761db88cea4cfed8da6d6facc4e22 | Ruby | cxn03651/writeexcel | /examples/formula_result.rb | UTF-8 | 940 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/ruby -w
# -*- coding: utf-8 -*-
#######################################################################
#
# Example of how to write Spreadsheet::WriteExcel formulas with a user
# specified result.
#
# This is generally only required when writing a spreadsheet for an
# application other than Excel where the ... | true |
2e2ba2c001f82d64d43188a1648dd2761f218ee4 | Ruby | seifertd/tournament | /scoring_bm.rb | UTF-8 | 1,083 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'benchmark'
require 'tournament'
pool = Tournament::Pool.ncaa_2008
pool.entry_fee = 10
pool.set_payout(1, 70)
pool.set_payout(2, 20)
pool.set_payout(3, 10)
pool.set_payout(:last, -10)
pool.scoring_strategy = Tournament::ScoringStrategy::Basic.new
b = pool.tournament_entry.picks
... | true |
37c0073aef8bfbc9185a256c5030cf21b904f2e7 | Ruby | gperl27/ironhack-web-development | /Week1/module_exercise/lib/programmer.rb | UTF-8 | 191 | 2.828125 | 3 | [] | no_license | class Programmer
include CaffeineConsumer
def program
consume_caffeine
do_wonderful_things_with_computers
end
def do_wonderful_things_with_computers
puts "I'm programming"
end
end | true |
ab8e12f6327da604adb61b86239d9731efb75bbd | Ruby | clivecrous/temporal | /test/hours.rb | UTF-8 | 335 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'temporal'
describe 'One hour in other units' do
it 'is 3600 seconds' do
1.hour.should == 3600.seconds
end
it 'is 60 minutes' do
1.hour.should == 60.minutes
end
it 'is 1/24th of a day' do
1.hour.should == (1.0/24).days
end
it 'is 1/168th of a week' do
1.hour.should == (1.0/168).we... | true |
300fb20d764653b12b4c6c2409fa68b66f3bf5d7 | Ruby | Mattlk13/maglev | /src/test/PutsTest.rb | UTF-8 | 1,193 | 4.25 | 4 | [] | no_license | #
# Tests the following:
# simple puts
# compound puts
# puts with variable
# Class definition
class PutsTest
# Expected value: nil
def simplePuts
puts "Hello World!"
end
# Expected value: nil
def compoundPuts
puts "Hello" + " World" + "!"
end
# Expected value: nil
... | true |
39f5099e9098811d9310106f6294349836529756 | Ruby | zorino/bioruby-scripts | /cd-hit-parser.rb | UTF-8 | 4,881 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# author: maxime déraspe
# email: maximilien1er@gmail.com
# review:
# date: 14-02-23
# version: 0.01
# licence:
require 'bio'
class CdhitParser
def initialize cdHitFile, fastaFile
@fastaFile = fastaFile
@cdHitFile = cdHitFile
end
def build_genome_in... | true |
7bd8f54f43ecaa1eedd510be134e02f338fd5fa8 | Ruby | ginason/ruby_fundamentals2 | /exercise7.rb | UTF-8 | 147 | 2.96875 | 3 | [] | no_license | def wrap_text(message, line = "---===###")
line_reverse = line.reverse
return "#{line}#{message}#{line_reverse}"
end
puts wrap_text("hello")
| true |
0f24eea6c958c65d9da404826401356152e47881 | Ruby | BillGatesNephew/blog_site | /app/controllers/tags_controller.rb | UTF-8 | 1,893 | 2.546875 | 3 | [] | no_license | class TagsController < ApplicationController
before_action :authenticate_author!, only: [:new, :update, :delete]
# POST /tag/new
def new
@errors = validate_params(tag_params)
if @errors.count == 0
@tag = Tag.new(tag_params)
@tag.save
end
respond_t... | true |
afdd2ed16f82ec1ee8214a6e012078f8f5298cb5 | Ruby | tarynsauer/ruby_ttt | /lib/ui.rb | UTF-8 | 437 | 2.859375 | 3 | [] | no_license | module RubyTictactoe
class UI
attr_accessor :io
def initialize
@io = Kernel
end
def first_move_message(marker)
"Player '#{marker}' goes first."
end
def next_move_message(marker)
"Player '#{marker}': Make your move."
end
def winning_game_message(marker)
"GAME... | true |
6d4866008a3464f400833d16f4adecad31950b00 | Ruby | ltfschoen/friendfactory | /db/seeds.rb | UTF-8 | 7,357 | 2.53125 | 3 | [] | no_license | # =============
# Template Site
# def site
# @site ||= Site.template
# rescue
# Site.create!(
# :name => Site::TemplateSiteName,
# :display_name => 'FriskyFactory',
# :analytics_account_number => '',
# :analytics_domain_name => '')
# end
# =======
# CSS
# file = File.join(Rails.root, 'db', 'seed... | true |
3ac5e02ff386d5fec86a84129f206d8e39c4a461 | Ruby | DerekKaknes/ruby-collaborating-objects-lab-cb-000 | /lib/mp3_importer.rb | UTF-8 | 356 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_reader :path
def initialize(path)
@path = path
end
def files
filenames = Dir["#{path}/*.mp3"]
filenames.collect {|fn| normalize_filename(fn)}
end
def normalize_filename(filename)
filename.split('/').last
end
def import
files.each do |fn|
Artist.create_... | true |
8f1b44743b6e55bcb3b0ace54dca8a36e0e21f9a | Ruby | fsp21/testesRuby | /Collections/testeHashes.rb | UTF-8 | 288 | 2.65625 | 3 | [] | no_license | jogos = {:dark_souls => 'multiplataforma', :demons_souls => 'ps4/ps5', :gears_of_war => 'xbox one/360'}
puts jogos
puts jogos[:dark_souls]
puts jogos[2] == nil
jogos[5] = 'número'
puts jogos[5]
puts jogos[:dark_souls]
puts jogos.keys
jogos.delete(:dark_souls)
puts jogos.size
| true |
b75db55da6f5733af1e188b924106fed69b9ac2e | Ruby | rafaeliga/dino_rails_example | /Game.rb | UTF-8 | 1,156 | 3.25 | 3 | [] | no_license | class Game
def show_green_led green_leds, id = 0
green_led = green_leds[id]
green_led.send(:on)
sleep(1)
green_led.send(:off) unless green_led == green_leds.last
end
def show_red_led red_leds, id = 0
red_led = red_leds[id]
red_led.send(:on)
sleep(1)
red_led... | true |
6e37326bfa8ab2e1f55cbb65c96e77c26b789b86 | Ruby | hsadoqi/reverse-each-word-dumbo-web-091718 | /reverse_each_word.rb | UTF-8 | 113 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
x = string.split
x.collect do |word|
word.reverse!
end
x.join(" ")
end
| true |
b4780564d8c101aa37affb1e3c90181b8f837db9 | Ruby | edward/hmm-notes | /viterbi_demo.rb | UTF-8 | 5,658 | 3.859375 | 4 | [] | no_license | # I don’t remember if I (Edward Ocampo-Gooding) wrote this or not. If I didn’t,
# please give me a shoutout.
# This code is massaged out of Sean R. Eddy’s “What is a hidden Markov model?”, which I’ll throw in this repo.
# When you run this thing, the key idea is that we’re taking a genomic sequence
# (the top sequenc... | true |
5f36ba43d1eb5aafd7235ef58ea4a92960ef1e6b | Ruby | iachettifederico/ruby_cordoba | /01/enumerable_spec.rb | UTF-8 | 5,670 | 3.390625 | 3 | [] | no_license | require 'turn'
# Test formatting config
Turn.config do |c|
#c.format = :outline # outline, progress, dotted, pretty, marshall, cue
#c.trace = true
#c.natural = true
end
# En of test formatting config
require "minitest/autorun"
require_relative "./fake_enumerable"
class EnumerateMe
include FakeEnumerable
#inc... | true |
1ffc13d86be6c7765b429b7368ee9721ce916f4e | Ruby | ndo7/online-shop-app | /app/models/inventory.rb | UTF-8 | 1,579 | 2.859375 | 3 | [] | no_license | class Inventory < ApplicationRecord
belongs_to :seller, foreign_key: "seller_id", class_name: :User
has_many :products
accepts_nested_attributes_for :products
def store_name
"#{seller.username}'s store"
end
def seller_username
self.seller.username
end
def product_available(product_name)
p... | true |
ca058ea328db2546994771f1e782eb37d0bb5d7d | Ruby | jamaspy/kahootz_server | /db/seeds.rb | UTF-8 | 1,359 | 2.78125 | 3 | [] | no_license | User.destroy_all
Question.destroy_all
Answer.destroy_all
Quiz.destroy_all
User.create :username => 'ben', :password_digest => 'chicken'
require 'httparty'
difficulties = %w( easy medium hard )
categories_index = (9..40)
categories_index.each do |category|
difficulties.each do |difficulty|
url = "https://ope... | true |
f45d3aea98bc6dc0c98fbca6df6a8e934b256232 | Ruby | Kingkunta1/oo-basics-dumbo-web-career-042219 | /lib/shoe.rb | UTF-8 | 373 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Shoe
attr_reader :brand,:color,:size,:material,:condition
attr_writer :color,:size,:material,:condition
def initialize(brand)
@brand = brand
end
def color
@color
end
def size
@size
end
def material
@material
end
def cobble
puts "Your shoe is as good as new!"... | true |
fc0d09ed92ea1af11b401153d4911a0ee07bd908 | Ruby | flawrencis/CodeLessons | /RubyBuildingBlocks/stock_picker.rb | UTF-8 | 796 | 3.921875 | 4 | [] | no_license | def stock_picker(prices)
buy_day = 0
sell_day = 0
profit = []
days = []
while buy_day < prices.size do
sell_day = buy_day #No backwards time travel allowed!
while sell_day < prices.size do
revenue = prices[sell_day].to_i - prices[buy_day].to_i
profit << revenue #Store all possible profit va... | true |
14012572ce6cc30e6c0cb5d81a29872a8475f64a | Ruby | swipely/hasta | /lib/hasta/combined_data_source.rb | UTF-8 | 666 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Copyright Swipely, Inc. All rights reserved.
module Hasta
# Combines multiple data sources so they can be iterated over continuously
class CombinedDataSource
attr_reader :name
def initialize(sources, name = nil)
@sources = sources
@name = name || sources.map(&:name).compact.join(', ')
e... | true |
ea668ecf409a9522f9420e8205d2acf224c7c6df | Ruby | atownley/tecode-ruby | /lib/tecode/ui/notification.rb | UTF-8 | 4,858 | 2.578125 | 3 | [] | no_license | #--
######################################################################
#
# Copyright 2008, Andrew S. Townley
#
# Permission to use, copy, modify, and disribute this software for
# any purpose with or without fee is hereby granted, provided that
# the above copyright notices and this permission notice appear in
# al... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.