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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cb0decd3d863dcaac407e263a748fb6fd48e9d27 | Ruby | verdammelt/Greyhawk-Weather | /spec/precipitation_occurance_spec.rb | UTF-8 | 4,070 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'precipitationoccurance'
describe PrecipitationOccurance do
it "returns array of precipitation" do
roller = make_roller(13)
precip_occur = PrecipitationOccurance.new({(0..20) => mock(:PrecipitationInfo).as_null_object,
(21..100) =>... | true |
3e455f10bbbe95e97751bf21fc0b2339c305f91b | Ruby | adjeielias90/ruby-crypto | /caesar.rb | UTF-8 | 898 | 3.28125 | 3 | [] | no_license | require_relative 'formatting.rb'
class Array
def caesar_shift n
map do |letter|
if letter =~ /[^A-Za-z]/ then letter
else ((letter.downcase.to_alphabet_order + n) % 26).to_ascii_char.in_same_case_as(letter)
end
end.join
end
def in_cipher_alphabet char
caesar_shift(char.downcase.ord... | true |
30ce4465f8e395536336060903065d231ad2538f | Ruby | myoan/bowling | /score.rb | UTF-8 | 1,098 | 3.390625 | 3 | [] | no_license | class Score
class UndefinedTerm < RuntimeError; end
def initialize(data = "")
@row = data.gsub('-', '0').split('')
@stack = [] # data stack
@pc = @row.size-1 # program counter
@score = 0 # result
end
def score
while @pc >= 0 do
ch = @row[@pc]
case ch
when '0'..'9'
@stack.push(c... | true |
7cecbaf0d02a84709232202916625c7060c2d154 | Ruby | IanPFoertsch/Proposition | /lib/proposition/sentence/n_ary/n_ary_sentence.rb | UTF-8 | 737 | 3.15625 | 3 | [] | no_license | require_relative "../sentence"
require_relative "../logic"
module Proposition
class NArySentence < Sentence
def initialize(sentences)
sorted = sentences.sort_by { |s| s.in_text }
@sentences = sorted
end
def conjoin(other)
raise "other sentence is not an NArySentence" unless other.is_a?... | true |
87d07593d2da7a95e88d41d4dc637911c22aff1d | Ruby | stevieing/courtbooking | /lib/setup/permitted_attributes.rb | UTF-8 | 993 | 2.65625 | 3 | [] | no_license | class PermittedAttributes
##
# = Permitted Attributes
#
# These should be loaded from a yaml file in the following format:
# model_a:
# whitelist:
# - :attr_a
# - :attr_b
# - :model_ids: []
# nested:
# :model_b:
# - :attr_c
# - :attr_d
# virtual:
# - ... | true |
8d73326adcd89058b69062ef30ee097ac6f0d229 | Ruby | podral3/rubyProjects | /stockPicker.rb | UTF-8 | 192 | 3.453125 | 3 | [] | no_license |
def stock_picker(arr)
while arr[0] == arr.max &&
arr.shift
end
while arr[arr.length-1] == arr.min
arr.pop
end
end
stock_picker([17,16,3,6,9,15,8,6,2,10,1,1]) | true |
02ddbef801266afa9812afc1885b15375d6479b3 | Ruby | hankeliu2015/the-bachelor-todo-nyc-web-102918 | /lib/bachelor.rb | UTF-8 | 1,952 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def get_first_name_of_season_winner(data, season) # review the index i.
winner_first_name = ""
data.each do |seasons, season_data|
if seasons == season
season_data.each do |contestants_data|
i = 0
contestants_data.each do |key, value|
if value == "Winner"
... | true |
4ca747e272400a5640699b845cca1ce3cd485b3d | Ruby | social-snippet/social-snippet | /lib/social_snippet/repository/drivers/driver_base.rb | UTF-8 | 1,915 | 2.734375 | 3 | [
"MIT"
] | permissive | module SocialSnippet::Repository
# Repository base class
# usage: class GitDriver < DriverBase
class Drivers::DriverBase
attr_reader :url
# @example
# driver = Driver.new(url, ref)
# driver.fetch
# driver.cache # => save data into storage
def initialize(new_url)
@url = new_url
... | true |
dc054348253684027fef69c78322d5148103ef71 | Ruby | abineko2/app | /app/helpers/users_helper.rb | UTF-8 | 208 | 2.515625 | 3 | [] | no_license | module UsersHelper
#基本時間などの値を、指定書式にフォーマットしてかえす
def format_basic_time(datetime)
format("%.2f",((datetime.hour*60)+datetime.min)/60.0)
end
end
| true |
f282d3d51fc1f754abbe009da68eceb83195b5c9 | Ruby | litencatt/ruby-design-patterns | /www.techscore.com/iterator.rb | UTF-8 | 1,353 | 4.125 | 4 | [] | no_license | # 集約オブジェクトの要素
class Student
attr_reader :name, :sex
def initialize(name, sex)
@name = name
@sex = sex
end
end
# 集約オブジェクト
class StudentList
attr_reader :students, :last
def initialize
@students = []
end
def gt_student_at(index)
@students[index]
end
def add(student)
@students <<... | true |
6e2ec650aa149277ec88735fac778172e0afc4b7 | Ruby | nick-and-raquel-do-internet-things/date-night | /app/models/relationship.rb | UTF-8 | 232 | 2.53125 | 3 | [] | no_license | class Relationship < ApplicationRecord
belongs_to :person_a, class_name: 'User'
belongs_to :person_b, class_name: 'User'
def other_person(user)
if user == person_a
person_b
else
person_a
end
end
end
| true |
7f40e64c1e8b516f52d8302bec803c222f585630 | Ruby | eddiepr/MySecondRepository | /engine_exercise_car_class.rb | UTF-8 | 353 | 3.0625 | 3 | [] | no_license | require_relative("engine_exercise_engine1_class")
require_relative("engine_exercise_engine2_class")
require_relative("engine_exercise_engine3_class")
class Car
def initialize(car_sound, engine)
@car_sound = car_sound
@engine = engine
end
def start
@engine.sound
puts @car_sound#other sound that a car makes a... | true |
fb38ef748b3ee7ce3ad3001f468419cddec6e782 | Ruby | ducc/dablang | /src/compiler/nodes/node_symbol.rb | UTF-8 | 648 | 2.6875 | 3 | [
"MIT"
] | permissive | require_relative 'node_literal.rb'
class DabNodeSymbol < DabNodeLiteral
attr_reader :symbol
def initialize(symbol)
raise "empty symbol (#{symbol})" if symbol.to_s.empty?
super()
@symbol = symbol
add_source_parts(symbol)
end
def extra_dump
":#{symbol}"
end
def extra_value
symbol
... | true |
4b0b4a5da5ec2a41aeddd01e0fc36b4dc81a394d | Ruby | mindreframer/ruby-stuff | /github.com/russolsen/design_patterns_in_ruby_code/05/ex10_consistent_demo.rb | UTF-8 | 446 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
require '../example'
require 'ex10_consistent'
example %q{
fred = Employee.new("Fred", "Crane Operator", 30000)
fred.salary = 1000000
# Warning! Inconsistent state here!
fred.title = 'Vice President of Sales'
}
example %q{
fred = Employee.new("Fred", "Crane Operator", 30000)
# Don't inform... | true |
127758f25b303ef17ae0863903ffa131b356c11c | Ruby | JoevinCanet/JoevinCanet | /reboot/calculator/interface.rb | UTF-8 | 560 | 3.578125 | 4 | [] | no_license | require_relative "calculator"
choise = "y"
while choise == "y"
p "Entrez le premier chiffre de votre opération"
first_number = gets.chomp.to_f
p "Entrez le second chiffre de votre opération"
second_number = gets.chomp.to_f
p "Entrez le type d'opération souhaité (+, -, /, *)"
operation = ge... | true |
3fab56442798ea8d0f630cc95ebecb1fde34da22 | Ruby | Suylo/Discord-Bot | /src/modules/commands/helpCmd.rb | UTF-8 | 1,569 | 2.78125 | 3 | [] | no_license | # frozen_string_literal: true
# HelpCmd display all commands available on this bot
module HelpCmd
extend Discordrb::EventContainer
extend Discordrb::Commands::CommandContainer
command :help do |channel|
user_name = channel.user.username
user_distinct = channel.user.distinct
user_avatar_url = channel... | true |
c2e0ee059c3381ac85c978c79e5a32c78bb8319d | Ruby | aakrutishitut/online_cab_booking | /Location.rb | UTF-8 | 239 | 3.203125 | 3 | [] | no_license | class Location
Location_d=Struct.new(:x,:y)
attr_accessor :x
attr_accessor :y
def initialize(x,y)
@x=x
@y=y
end
def distance(l1) # location of the cab is passed in argument
return ((x-l1.x)*(x-l1.x)+(y-l1.y)*(y-l1.y))
end
end
| true |
082c233d6fb2de8fdfe6c588ca4c8efac8534099 | Ruby | DingChiLin/RubyExercise | /Algorithms/ClosestPair/FindClosestPairTest.rb | UTF-8 | 645 | 2.90625 | 3 | [] | no_license | require 'test/unit'
require './ClosestPairFinder'
class TestSimpleSorts < Test::Unit::TestCase
def setup
@pairs = []
File.open("pairs.txt","r") do |file|
file.each_line do |line|
@pairs.push(line.split(" ").map(&:to_i))
end
end
@expect = [[5, 5],[6, 6]]
end
def teardown
... | true |
b4757af69674da435abef4b3c73adbefece19916 | Ruby | gzim921/Car | /spec/my_car_spec.rb | UTF-8 | 1,235 | 2.734375 | 3 | [] | no_license | RSpec.describe Car::MyCar do
let(:bmw) { Car::MyCar.new('BMW', 2015, 'Blue') }
let(:defects) { 'Water pump, Oil leak' }
it 'creates new instance' do
expect(bmw).to be_instance_of(Car::MyCar)
end
it 'has current speed defined 0' do
expect(bmw.current_speed).to eq(0)
end
it 'speeding up' do
b... | true |
35a3c0c470eda46d8fc0307eef719aff1755dff1 | Ruby | pemacy/Launch_School | /Coursework/100/120/TwentyOne/twenty_one_game.rb | UTF-8 | 3,632 | 3.8125 | 4 | [] | no_license | module Hand
def display_cards(game_over = false)
if type == :player
puts cards
else
hidden = [cards.first]
(cards.size - 1).times { hidden << "Hidden Card" }
puts hidden unless game_over
puts cards if game_over
end
end
def hand_amount
num_aces = 0
sum = 0
car... | true |
982494442b365955d7a705780fb0f77912e505ef | Ruby | DinoSaulo/Learning-Ruby | /Estrutura de controle/if.rb | UTF-8 | 133 | 3.203125 | 3 | [] | no_license |
dia = "Domingo"
#dia = "Segunda"
almoco = 'Frango'
if dia == 'Domingo'
almoco = 'Bife'
end
puts "O almoço hoje é #{almoco}" | true |
08200e5b80431f419d4160eac3348860f6c7508c | Ruby | rschultheis/rosalind | /ruby/grph/grph.rb | UTF-8 | 355 | 2.546875 | 3 | [] | no_license | require_relative '../lib/rosalind.rb'
include Rosalind
dnas = parse_fasta_file ARGV[0]
ids = dnas.keys
adjacents = []
ids.each_index do |i|
ids.each_index do |j|
next if i==j
if is_adjacent?(dnas[ids[i]], dnas[ids[j]], 3)
adjacents << ids[i] + ' ' + ids[j]
end
end
end
output = adjacents.join("... | true |
b8d8cf8d4c87bfa405cc1fdfcae01bf462bc9082 | Ruby | mizukmb/animeStaffCompare | /test/controllers/anime_controller_test.rb | UTF-8 | 411 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
describe AnimeController do
it "should get scrape" do
hash = AnimeController.new
data= hash.scrape(5292) # SHIROBAKO
expect(data['タイトル']).to eq 'SHIROBAKO'
end
it "404ページは abort する" do
hash = AnimeController.new
begin
data = hash.scrape(9999) # 404 Not Found
... | true |
bf99f93c1b1dd8d7fa790b3d8e7406e980adb2c6 | Ruby | jonkchan/Product-Type-CLI | /spec/product_spec.rb | UTF-8 | 1,300 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative './spec_helper.rb'
require_relative '../lib/product.rb'
require_relative '../lib/json_parser.rb'
describe Product do
describe 'class properties' do
before(:example) do
json = JSONParser.parse_json('./spec/json/test_data.json')
@test_product = Product.new(json[0])
end
it 'exp... | true |
5a039a0285df9c4458bba8970d9613f20d069557 | Ruby | dmbf29/word-frequencies | /interface.rb | UTF-8 | 166 | 2.640625 | 3 | [] | no_license | require_relative 'frequencies'
text = File.open('speech.txt').read
histogram = word_counter(text)
histogram.each do |word, count|
puts "#{word}: #{count}"
end
| true |
b5a59b2a23660121d8b7ae9030d61411674346f1 | Ruby | dhanyanarendra/rubyexercise | /2.rb | UTF-8 | 74 | 3.46875 | 3 | [] | no_license |
puts "what is your name"
name=gets.chomp
puts name
puts "hello #{name}!" | true |
512a19ef11b6cc1a2e95efa778155d0dfe75f17f | Ruby | AlexNisnevich/splooshed | /lib/splooshed/water_data.rb | UTF-8 | 1,010 | 3.03125 | 3 | [] | no_license | class WaterData
include Singleton
def initialize
@data = load_water_data
end
def search(term)
# list all food names that don't have illegal characters ("?") and have gallons_per_kg defined
# and that match search term, if any
@data.select {|k, v| (!term || k.include?(term)) && !k.include?("?")... | true |
45135c2b6a876514d87238ac0e26ef9d64508ee7 | Ruby | glenn0/in_the_wild | /app/services/github/repo_fetcher.rb | UTF-8 | 2,004 | 2.546875 | 3 | [] | no_license | module Github
class RepoFetcher
def initialize(project, submitter)
@project = project
@submitter = submitter
end
def retrieve
if github_up?
fetch_repo_owner_and_name
if valid_repo?
get_additional_repo_attributes
generate_rspec_tags
if @pro... | true |
21809f437890b4a8eeb967ef66578440714fc626 | Ruby | khrystynaklochko/cli-superheroes | /main.rb | UTF-8 | 826 | 2.859375 | 3 | [] | no_license | require_relative "http_connector"
require_relative "json_parser"
@parser = JsonParser.new()
def card_commands(option)
case option
when "-h"
puts "Available commands"
puts " -cards-set List of cards grouped by set."
puts " -cards-set-rarity List of cards grouped by set and within each set grouped by r... | true |
c6368e70cf4268934e23b32e0be20f41768c210b | Ruby | louisbooth/introduction-to-programming | /flow-control/flow_control_1.rb | UTF-8 | 347 | 3.234375 | 3 | [] | no_license | =begin
1. (32 * 4) >= 129
2. false != !true
3. true == 4
4. false == (847 == '874')
5. (!true || (!(100 / 5) == 20) || ((328 / 4) == 82)) || false
1. false
2. false
3. ?
4. true
5. true
3 is false
integer 4 is a truthy value which means when used in a conditional value
it will evaluate to true, but it is not equal ... | true |
fececd1ff11201b477a111295ec63a76b9ea853e | Ruby | buithehoa/rspec-3-book | /book-code/15-using-test-doubles-effectively/24/sales_tax/lib/invoice.rb | UTF-8 | 388 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'my_app'
require 'sales_tax'
class Invoice
def initialize(address, items, sales_tax: SalesTax.new)
@address = address
@items = items
@sales_tax = sales_tax
end
def calculate_total
subtotal = @items.map(&:cost).inject(0, :+)
taxes = subtotal * tax_rate
subtotal + taxes
end
priv... | true |
3a4761ebd218d1b235d0f42f06a9ad4627bc1063 | Ruby | JoshCheek/binary_example | /spec/bin_spec.rb | UTF-8 | 1,381 | 2.875 | 3 | [] | no_license | require 'open3'
describe 'the binary' do
def execute_binary(filename)
binary_path = File.expand_path '../../bin/sort_words', __FILE__
Open3.capture3(binary_path, filename)
end
context 'when given a valid filename' do
let(:filename) { File.expand_path '../input_file', __FILE__ }
before { File.wr... | true |
87fadfbacf700f4d7eb4c5e7815f5ca87503eadf | Ruby | nbhandari/depot | /test/unit/cart_item_test.rb | UTF-8 | 961 | 2.640625 | 3 | [] | no_license | require 'test_helper'
class CartItemTest < ActiveSupport::TestCase
test "initialize" do
product = products(:one)
cart_item = CartItem.new product
assert_equal products(:one), cart_item.product
assert_equal 1, cart_item.quantity
end
test "increment_quantity" do
product = products(:one... | true |
0d9d55be543f9fbeea6f4efad6c9a48dec2ce489 | Ruby | blax/hackkrk-tanks | /client.rb | UTF-8 | 3,036 | 3.015625 | 3 | [] | no_license | # requires rest-client installed: gem install rest-client
require 'rest-client'
require 'yaml'
require 'time'
require 'json'
SERVER = "http://10.12.202.141:9999"
TIMEOUT = 300000
TOURNAMENT_ID = "master"
AUTHORIZATION_TOKEN = "ResponsibleBrownMallardAlligator"
STD_ANGLE = 5.0
STD_MOVE = 30.0
POWER = 80
USERNAME = "... | true |
15fae454697ef48022ee17ef774613e73d932c53 | Ruby | kipcole9/calendrical-ruby | /lib/calendrical/calendars/egyptian.rb | UTF-8 | 1,190 | 2.84375 | 3 | [
"MIT"
] | permissive | module Calendar
module Egyptian
def self.Date(*args)
Egyptian::Date[*args]
end
class Date < Calendrical::Calendar
extend Calendrical::Mpf
extend Calendrical::Days
# see lines 520-525 in calendrica-3.0.cl
def self.epoch
fixed_from_jd(1448638)
end
... | true |
92c8e2e13afc2d33ad0c3bdb5c38e1b02a5418ad | Ruby | esoto/blog_without_gems | /lib/csv_manager.rb | UTF-8 | 839 | 3.25 | 3 | [] | no_license | require 'csv'
class CSVManager
attr_accessor :id
def self.all
posts = read_post_file
posts.map{|post_attr| set_up_posts(post_attr) }
end
def self.create post
post.assign_id
CSV.open("lib/posts.csv", "ab") do |csv|
csv << [post.id, post.title, post.post_body]
end
end
def self.fi... | true |
2a44d47948db6eb37f3cffe3cd196c74d5ed6e79 | Ruby | samara-islam/intro-ruby | /flow_control/all_caps.rb | UTF-8 | 711 | 4.59375 | 5 | [] | no_license | # flow control
# exercise question 2
#
# write method that takes a string as argument.
# Method should return a new, all-caps version of the string,
# but only if the string is longer than 10 characters
# cute try but not quite:
#
#print "Enter a string: "
#user_input = gets.chomp
# test 1: is string longer than 10... | true |
53161729c66501809fa40d2daca206e21d471eb8 | Ruby | kakuda/myfiles | /tdiary/misc/plugin/a.rb | UTF-8 | 3,112 | 2.703125 | 3 | [] | no_license | # a.rb $Revision: 1.7 $
#
# Create anchor easily.
#
# 1. Usage
# a(url, name)
#
# a "http://www.hoge.com/diary/", "Hoge Diary"
#
# a(key, option_or_name = "", name = nil)
# Use dictionary file. You need to create the dictionary
# file with a CGI.
# a "home"
# a "home", "20020329.html", "Here"
#
# a("name|key... | true |
5f8ef53ed93c2a7dadfb73708316c290a0558df5 | Ruby | DavidEGrayson/redstone-bot2 | /spec/item_spec.rb | UTF-8 | 2,252 | 2.828125 | 3 | [] | no_license | # coding: ASCII-8BIT
require 'redstone_bot/models/item'
# TODO: remove this after we figure out the gzip problem
describe "basic problem with Ruby's GZipWriter" do
it "does not let you set mtime to 0" do
sio = StringIO.new
writer = Zlib::GzipWriter.new(sio)
writer.mtime = 0
writer.write "hello world... | true |
2d19eab98dc1ab3985861e8cf96f1d0664f5f69b | Ruby | bger/csv_cat | /lib/csv_cat/printer.rb | UTF-8 | 909 | 3.046875 | 3 | [] | no_license | module CsvCat
# Responsible for rendering data into given stream
#
class Printer
attr_reader :stdout, :data_stream, :stdin, :widths, :show_by
def initialize(parser:, stdout: $stdout, stdin: $stdin, show_by: 3)
@data_stream = parser.content
@widths = parser.widths
@stdout = std... | true |
1609c7d9f915ce246d287dc40558194d4349bdeb | Ruby | renanorodrigues/lessons-ruby | /algorithms/dijkstra_1_exec.rb | UTF-8 | 1,003 | 2.5625 | 3 | [] | no_license | grafo = {}
grafo = {
inicio: {a: 5, b: 2},
a: {d: 4, c: 2},
b: {a: 8, c: 7},
c: {fim: 1},
d: {c: 6, fim: 3},
fim: {}}
custs = {}
custs = {a: 6, b: 2, c: Float::INFINITY, d: Float::INFINITY, fim: Float::INFINITY}
fathers = {}
fathers = {a: :inicio, b: :inicio, c: nil, d: nil, fim: nil}
processeds_node... | true |
5c94d72f9d87a5e8af18024dd2832a7760a87ab7 | Ruby | Tuland/Rescribo | /.metadata/.plugins/org.rubypeople.rdt.launching/1290503595867/lib/namedescriptor.rb | UTF-8 | 872 | 3.296875 | 3 | [] | no_license | =begin
-------------------------------------------------- Class: NameDescriptor
Break argument into its constituent class or module names, an
optional method type, and a method name
------------------------------------------------------------------------
Class methods:
--------------
new
Instance me... | true |
690187505e34bb528b8f2915a3b5c8209ffa1349 | Ruby | castor4bit/leetcode | /0000/001.Two_Sum/001.rb | UTF-8 | 282 | 3.25 | 3 | [] | no_license | # @param {Integer[]} nums
# @param {Integer} target
# @return {Integer[]}
def two_sum(nums, target)
i = 0
nums.each do |n|
j = i + 1
nums2 = nums.slice(j..-1)
nums2.each do |m|
return [i, j] if n + m == target
j = j.succ
end
i = i.succ
end
end
| true |
1c01f39e94a6188f679860d3dae317e8b9284970 | Ruby | Sahhm/07-09-API | /models/groupmember.rb | UTF-8 | 580 | 3.03125 | 3 | [] | no_license | require_relative "ClassMethods.rb"
class Groupmember
extend DatabaseClassMethods
attr_reader :id
attr_accessor :name
#initializes a new course object
#sets object attributes to whatever was entered
def initialize(work_options={})
@id = work_options["id"]
@name = work_options["name"]
... | true |
66e932b715f6f716dc2fc78caaec3fa7d61eb0eb | Ruby | foreverLoveWisdom/computer_science_knowledge_practice_in_ruby | /hash_table.rb | UTF-8 | 1,316 | 3.890625 | 4 | [] | no_license | class HashTable
attr_accessor :data
def initialize(size)
@data = Array.new(size)
end
def set(key, value)
address = get_hash(key)
unless data[address]
data[address] = []
end
data[address].push([key, value])
end
def get(key)
address = get_hash(key)
data[address]&.each do ... | true |
ccf8b1cf58fb6076676051d968a2eb4f4e910e53 | Ruby | jasonayre/saruman | /lib/saruman/cli.rb | UTF-8 | 5,900 | 2.546875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require 'thor'
require 'saruman'
require "highline/import"
require 'saruman/generators/saruman'
module Saruman
class CLI < Thor
desc "extension", "Creates a new magento extension"
def extension
options = Hash.new
options[:command] = __method__
options[:namespace] = ask("Enter extension ... | true |
4de276d84278e8f6814d58836aac193ad6e4c632 | Ruby | davetron5000/weird-ruby | /weird/spec/person_spec.rb | UTF-8 | 2,004 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'weird/basic_object'
require 'weird/nil_like_sentinel'
require 'weird/person'
describe Person do
before(:each) do
class << Person
if methods.include?(:greet)
undef_method :greet
end
end
end
describe "naive" do
before do
load "weird/person_greet_... | true |
3b3cfe3a05b058cb91358788d670c1146adb23a2 | Ruby | daveheitzman/raylib-ruby | /lib/raylib/custom/vector4.rb | UTF-8 | 1,722 | 2.703125 | 3 | [
"MIT"
] | permissive | module Raylib
class Vector4
ray_alias_static :QuaternionIdentity, :identity # Returns identity quaternion
ray_alias_object :QuaternionLength, :length # Computes the length of a quaternion
ray_alias_object :QuaternionNormalize, :normalize # Normalize provid... | true |
0271f6058b0f9f124d23d845031364459879cb01 | Ruby | danimetz/Solar-System | /main.rb | UTF-8 | 3,860 | 3.859375 | 4 | [] | no_license | require_relative 'planet'
require_relative 'solar_system'
def main
#... Do stuff with planets ..
solar_system = SolarSystem.new("Sol")
earth = Planet.new('Earth', 'blue-green', 5.972e24, 1.496e8, 'Only planet known to support life')
saturn = Planet.new('Saturn','rust',5.683e26,1.433e9,"Saturn has at least 53 m... | true |
8355168b1575ccc0b863fe4eea309f5f628eddd3 | Ruby | intokozo/Thinknetica | /Lession_9/accessors.rb | UTF-8 | 884 | 3.0625 | 3 | [] | no_license | module Acсessors
def attr_accessor_with_history(*names)
names.each do |name|
accessor(name)
end
end
def accessor(name)
var_name = "@#{name}".to_sym
arr_name = "@#{name}_history".to_sym
define_method(name) { instance_variable_get(var_name) }
define_method("#{name}_history") { instanc... | true |
5c3b07a5f4cb036648292accfe248a1dbfbb9a08 | Ruby | Bratela/snitko_lessons | /lesson9.rb | UTF-8 | 185 | 3.6875 | 4 | [] | no_license | #Methods
puts "Yours name is:"
name = gets.chomp
def hello_world(name)
puts "Hello world!"
puts "My name is #{name}"
end
hello_world(name)
hello_world("Denis")
hello_world("Roman")
| true |
864825310673e34680f13bb251b7ce9a08598546 | Ruby | ching-wang/oo-email-parser-london-web-100719 | /lib/email_parser.rb | UTF-8 | 362 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
# or whitespace (' ')
class EmailAddressParser
def initialize(csv)
@csv = csv
end
def parse
split_ema... | true |
92d0d28dbf7aeafe8a17e1b29363ebbbbb039584 | Ruby | 7digital/7Fi | /src/seven_digital/artwork/artist_photograph.rb | UTF-8 | 236 | 2.5625 | 3 | [] | no_license | class ArtistPhotograph
attr_reader :url, :size
def initialize(url, size)
@url = url
@size = size
end
end
class Size
attr_reader :width, :height
def initialize(width=0, height=0)
@width = width
@height = height
end
end | true |
059b447f18c3df44625630379f33a88d5e760ac7 | Ruby | brett11/music | /spec/models/album_spec.rb | UTF-8 | 1,127 | 2.6875 | 3 | [] | no_license | require 'rails_helper'
require 'pry'
RSpec.describe Album, type: :model do
let(:album) { build(:album) }
it "is valid with valid attributes" do
expect(album).to be_valid
end
it "is not valid with no album name" do
album.name = ""
expect(album).to_not be_valid
end
it "is not valid with album... | true |
42eec194c248ea3c2e9059960c27e9ae30e3bc94 | Ruby | marcbobson2/my_programs | /exercises/roman.rb | UTF-8 | 718 | 3.859375 | 4 | [] | no_license | POS_HASH = { 1 => ["I", "V", "X"], 10 => ["X", "L", "C"], 100 => ["C", "D", "M"], 1000 => ["M", "M", "M"] }
class Fixnum
def to_roman
number = self
positions = number.to_s.split("").map(&:to_i).reverse
final_roman = []
positions.each_with_index do |num, index|
final_roman << determ... | true |
a15ab89d13c5fbaadb39bdb3c1bb0a5a1d6ebb8c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/4533.rb | UTF-8 | 335 | 3.375 | 3 | [] | no_license | def combine_anagrams(words)
groups = Hash.new()
words.each do |w|
key = w.downcase.chars.sort.join
if !groups.has_key?(key)
groups[key] = []
end
groups[key] += [w]
end
return groups.values
end
#puts combine_anagrams(['cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams', ... | true |
9835542409bbbbc59cc8626ebf21810c6b09abf5 | Ruby | kykalelker/phase-0-tracks | /ruby/santa.rb | UTF-8 | 1,960 | 3.828125 | 4 | [] | no_license | class Santa
attr_reader :reindeer_ranking
attr_accessor :gender, :age, :ethnicity
def initialize (gender, ethnicity)
puts "Initializing Santa instance ..."
@gender = gender
@ethnicity = ethnicity
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer", "Vixen", "Comet", "Cupid", "Donner", "... | true |
476fa5ae648bbd6b3434deaf09378fbbfc76644a | Ruby | bridgegade/PigLatinTranslator | /pig_latin_translator.rb | UTF-8 | 2,755 | 4.0625 | 4 | [
"MIT"
] | permissive | ##
# This class holds methods for translating text to Pig Latin
module PigLatinTranslator
##
# Translates a single line of text with words separated by spaces
def self.translate_line(line)
line = line.strip
words_array = line.split(" ")
translated_words = words_array.map{|word| translate_word(word)}
return ... | true |
5c0fc422bd65c2f6f2acbeb81ef39bb2b22aa3df | Ruby | mbwcogic/programming-univbasics-4-array-simple-array-manipulations-online-web-prework | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 929 | 3.546875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "pry"
def using_push(rainbow_array, next_color)
#binding.pry
rainbow_array.push(next_color)
end
def using_unshift(boros, new_boro)
boros.unshift(new_boro)
end
def using_pop(rainbow_array)
rainbow_array.pop
end
def using_shift(favorite_ice_creams)
favorite_ice_creams.shift
end
def pop_with... | true |
47db6c2f94dd76b5da54f009722f033ff850d5af | Ruby | reneecruz/learn-co-sandbox | /case.rb | UTF-8 | 573 | 3.953125 | 4 | [] | no_license | # Conclusion: Now you have one more way of communicating selection to Ruby, the case statement. For simple values, use ternary. For an if with an else and maybe an elsif use an if. For multiple cases, use a case statement.
greeting = "friendly_greeting"
case greeting
when "unfriendly greeting"
puts "What do yo... | true |
a10af15b9e994b8cb6acbb47d541bcfa50979f1a | Ruby | Grekz/coding-problems-ruby | /lib/mx/grekz/leetcode/easy/E111_MinimumDepthofBinaryTree.rb | UTF-8 | 647 | 3.671875 | 4 | [
"MIT"
] | permissive | class E111_MinimumDepthofBinaryTree
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @return {Integer}
... | true |
e6c0e03b376f2763537ab7b6f0f40ecb3a6c3806 | Ruby | Yeison2020/Backend-sinatra-spendy-app | /app/controllers/application_controller.rb | UTF-8 | 3,562 | 2.53125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class ApplicationController < Sinatra::Base
set :default_content_type, 'application/json'
# Bill Routers---------------------------------------------
get "/" do
{ message: "Howdy I'm working! 🚀🚀🚀 Please don't break me " }.to_json
end
#gets all bills
get "/bill" do
bills = Bill.all
bill... | true |
7977d31b5838745ab475ccaa7fff819000bff33c | Ruby | assemblyline/sidekicks | /lib/sidekicks/elb.rb | UTF-8 | 1,480 | 2.515625 | 3 | [] | no_license | require 'fog'
require 'open-uri'
require 'sidekicks/logger'
module Sidekicks
class ELB
def initialize
self.name = ENV['AWS_ELB_NAME']
self.tag = ENV['AWS_ELB_TAG']
self.region = ENV.fetch 'AWS_REGION'
self.key = ENV.fetch 'AWS_ACCESS_KEY'
self.secret = ENV.fetch 'AWS_SECRET... | true |
fcccfeeff46d6caec9edfe5255d65c9bdfeb7f16 | Ruby | Wayzyk/csv_parser | /csv_builder.rb | UTF-8 | 1,541 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
require './teams'
require 'csv'
TEAMS_FILE = 'data/Teams.csv'.freeze
PLAYERS_FILE = 'data/Batting.csv'.freeze
class CsvBuilder
def initialize
@team = Teams.new(TEAMS_FILE)
end
def call(options = {})
@options = options
results = []
data = []
last_row = {}
... | true |
5a25975cd5613c996511689c161daccaecc5f74e | Ruby | francois/linked_list | /lib/linked_list/node.rb | UTF-8 | 539 | 3.8125 | 4 | [
"MIT"
] | permissive | class LinkedList
# Implements a single node of the linked list.
class Node
attr_accessor :cdr, :value
def initialize(value, cdr)
@cdr, @value = cdr, value
end
# Two nodes are equal if their values are equal and their cdr's are equal too.
def ==(other)
cdr == other.cdr && value == o... | true |
209b21a5937f3d6be308408aecf126c1606576db | Ruby | pathsny/algo-class | /p4/scc.rb | UTF-8 | 2,642 | 3.21875 | 3 | [] | no_license | class DFS
def initialize(vertices)
@vertices = vertices
end
def search(options)
visited = {}
stack = []
visited_callback =
completed_callback = options[:completed_callback]
order = options[:order]
if (!order)
order = (@vertices.size-1).downto(1)
get_vertex = lambda {|i... | true |
137302296c718466c1f64b954d2e7d0f3b9efa09 | Ruby | CodeJusto/hacker-news-scraper | /lib/comment.rb | UTF-8 | 138 | 2.84375 | 3 | [] | no_license | class Comment
attr_reader :user, :text, :time
def initialize(user, text, time)
@user, @text, @time = user, text, time
end
end | true |
2414d2539b3fe85520c9b1a34e7cb7899208c60d | Ruby | GeorgeYan/op_rb | /block1.rb | UTF-8 | 155 | 3.5 | 4 | [] | no_license | def my_block
yield 1,100
end
my_block { |a,b| p "This number is #{1} + #{100}"}
def call_block(&block)
block.call
end
call_block { p "hello world"}
| true |
5efb2a95d2f5112258505fa304a181aaef477162 | Ruby | zklamm/ruby-small-problems | /exercises/second_pass/easy_07/04.rb | UTF-8 | 739 | 4.59375 | 5 | [] | no_license | # Write a method that takes a string as an argument and returns a new string in
# which every uppercase letter is replaced by its lowercase version, and every
# lowercase letter by its uppercase version. All other characters should be unchanged.
# input: str
# output: new str with char case swapped
# You may not use S... | true |
ffab264891792ae393108a41670f9f6ff797bc63 | Ruby | spenguinlui/react-native-foods | /csv_to_json.rb | UTF-8 | 6,508 | 2.890625 | 3 | [] | no_license | require 'csv'
require 'json'
data = File.open('./20_2.csv').read
csv_data = CSV.parse(data, :headers => true)
csv_data = csv_data.map{|row| row.to_a.to_h}
json_data = {}
nutrient_content_list = ['分析項分類', '分析項', '含量單位', '每單位含量', '每100克含量', '每單位重', '每單位重含量', '樣本數', '標準差']
# count = 0
# 不用這種方式會讀不到食品分類
csv_data.each do ... | true |
9ccefec4fb7a0c3fa65085d4cb262889e9eae250 | Ruby | AndyWendt/exercism | /ruby/matrix/matrix.rb | UTF-8 | 200 | 3.21875 | 3 | [] | no_license | class Matrix
def initialize(grid)
@grid = grid
end
def rows
rows = @grid.split("\n")
rows.map { |row| row.split(" ").map(&:to_i) }
end
def columns
rows.transpose
end
end
| true |
fd6eec89fc3f29a9166f1cd2a3169141abb05156 | Ruby | sgpl/sinatra | /ch1/main_v00_from_ch2.rb | UTF-8 | 1,269 | 2.796875 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader' if development?
get '/' do
erb :home # this is known as a view.
# just like route handlers, except that instead of finishing with a string that's
# sent back to the browser, we finish with erb :home
# it's a reference to what is known as a view (which is... | true |
761f5459dcc0c538c5cef7ab3d9c73ffa0f97f7d | Ruby | tlowande/TwO-O-Player-Math-Game- | /game.rb | UTF-8 | 1,058 | 3.546875 | 4 | [] | no_license | require './player'
class Game
# FOR REFERENCE
# def initialize player1, player2
# @player1 = player1
# @player2 = player2
# @curr = @player1
# end
@@player = 0;
# def game (player)
def start(players)
puts "----- NEW TURN -----"
question = Question.new
puts "#{players[0].lon... | true |
e73e50a9a6af8669a132e8120802196be051c5fd | Ruby | davejpatel/configparser | /config_parser_spec.rb | UTF-8 | 2,064 | 3 | 3 | [] | no_license | require_relative 'config_parser'
describe "ConfigParser" do
let(:config_file) { "#{File.expand_path(File.dirname(__FILE__))}/config_file.txt" }
let(:config_parser) { ConfigParser.new }
describe "#boolean_like" do
it "should return true if string contains boolean type" do
value = config_parser.send(:... | true |
e789f5094ddfae8367fe36d84d17006f20775e57 | Ruby | tkosuga/tiikitter.jp | /app/lib/cache_server.rb | UTF-8 | 675 | 2.65625 | 3 | [] | no_license | require 'memcache'
require 'singleton'
class CacheServer
include Singleton
def initialize
memcache_options = {
:c_threshold => 10_000,
:compression => true,
:debug => false,
:namespace => 'tiikitter',
:readonly => false,
:urlencode => false
}
... | true |
35e59ca14e96f22bf9c0776927511de60721b0cf | Ruby | melari/entity | /lib/evaluators/variable_assignment_statement.rb | UTF-8 | 1,022 | 2.9375 | 3 | [] | no_license | class VariableAssignmentStatementEval < StatementEval
def initialize(variable_path_eval, expression_eval, type)
@variable_path_eval = variable_path_eval
@expression_eval = case type
when '='
expression_eval
when '+='
DoubleOperandExpressionEval.new('+', @variable_path_eval, expression_eval... | true |
2b9a1084054c54b6fe33a2307dc8c0e1a38bbf89 | Ruby | kwikiel/lsruby | /basic/f55289ff.rb | UTF-8 | 136 | 3.546875 | 4 | [] | no_license | say_hello = true
count = 1
while say_hello
count+=1
puts 'Hello!'
say_hello = false
if count<=5
say_hello = true
end
end
| true |
97a739a00819e2358a443c69b2faee7bac600de0 | Ruby | sean1rose/blackjack | /procedural_blackjack.rb | UTF-8 | 3,505 | 4.0625 | 4 | [] | no_license | # test comment
def begin_game
puts "Welcome to the Blackjack Table. What's your name???"
user_name = gets.chomp
suits = ['of Clubs', 'of Diamonds', 'of Hearts', 'of Spades']
cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']
# Implemented concept of using product of 2 separate arrays (1... | true |
4065eec2bbc4e85c30c40aa1211e56fa51dcb9d0 | Ruby | abillig/rails-activerecord-model-rails-lab-web-0616 | /app/controllers/movies_list.rb | UTF-8 | 849 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'byebug'
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require_relative '../../config/environment.rb'
require_relative 'movie_stats'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
page = Nokogiri::HTML(open("https://en.wikipedia.org/wiki/Academy_Award_for_Best_Pict... | true |
30586a29f04c4a8b7f231bec1d76e8088c77d022 | Ruby | cdangg/learn_ruby | /05_silly_blocks/silly_blocks.rb | UTF-8 | 164 | 3.25 | 3 | [] | no_license | def reverser
yield.split.map { |word| word.reverse}.join(' ')
end
def adder(x=1)
num = yield
num + x
end
def repeater(x=1)
x.times do
yield
end
end | true |
0f6961c3f9836078b9f4f8885bba36f32c8ea7ba | Ruby | danielriley06/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 606 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
name_tags = []
attendees.each {|name| name_tags << "Hello, my name is #{name}."}
return name_tags
end
def assign_rooms(attendees)
rooms = 1
assignments = []
while rooms <= 7
attendees.each do |name|
... | true |
fe31393e979d175868404691235d085375e8da1b | Ruby | rcgutierrez/ruby-exercises | /16-ruby-excercise-while-loops.rb | UTF-8 | 127 | 3.078125 | 3 | [] | no_license | # While loops
index = 1
while index <= 5
puts index
index += 1
end
# Make sure you don't make an infinite loop !!!!!
| true |
710c483a60d9b9dfadceddc16b2839aaffe4a039 | Ruby | esteban-herrera/interview_practice_max_profit | /all_test.rb | UTF-8 | 405 | 3.125 | 3 | [] | no_license | require "./MaxProfit.rb"
[1,2,3,4,5,6,7,8].permutation.to_a.each do |p|
answer_brute = MaxProfit.find_max_profit(p)
answer_efficient = MaxProfit.find_max_profit_efficient(p)
if answer_efficient != answer_brute
puts "Failed with array #{p.to_s}, expected:#{answer_brute} - actual:#{answer_efficient}"
end
end
... | true |
1e63a81427b066deb4e875eee24ca45876c03055 | Ruby | smartiqaorg/weather | /lib/http.rb | UTF-8 | 1,148 | 2.75 | 3 | [] | no_license | require 'net/http'
class Http
def initialize(host, protocol, headers = {}, auth_cred = nil)
@base_url ="#{protocol}://#{host}"
@headers = headers
@auth_cred = auth_cred
end
def send_request(method, url, params = nil, data = nil)
uri = URI.parse("#{@base_url}#{url}")
Net::HTTP.start(uri.host... | true |
4947da0bfa97bd856fb56004ae840af26ef266bf | Ruby | famished-tiger/Rley | /lib/rley/formatter/asciitree.rb | UTF-8 | 3,937 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require_relative 'base_formatter'
module Rley # This module is used as a namespace
# Namespace dedicated to parse tree formatters.
module Formatter
# A formatter class that draws parse trees by using characters
class Asciitree < BaseFormatter
# TODO
attr_reader(:... | true |
6b199c1b0becbc8c9a0bca2557efc8e22e19d717 | Ruby | j-sto/Sneaker_Colors | /spec/color_spec.rb | UTF-8 | 1,347 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Color do
describe "initalized" do
it "should initalize the color class with a name of a color" do
test_color = Color.new({:name => 'Solar Red'})
expect(test_color).to be_an_instance_of Color
end
it 'should display attributes when they are called on the class' do
test_c... | true |
24423df04ae30926a9506dc78a18857ef4716987 | Ruby | erikbelusic/prime-multiplication-table | /lib/multiplication_table.rb | UTF-8 | 275 | 3.28125 | 3 | [] | no_license | class MultiplicationTable
attr_reader :x_axis, :y_axis
def initialize(x_axis, y_axis = nil)
@x_axis = x_axis
@y_axis = y_axis.nil? ? x_axis : y_axis
end
def get_product_at(x_axis_index, y_axis_index)
x_axis[x_axis_index] * y_axis[y_axis_index]
end
end | true |
caf2209fe58e51d91370813ddd6d5c41fd4d4531 | Ruby | andrestorresw/ruby | /6_io.rb | UTF-8 | 383 | 3.890625 | 4 | [] | no_license | puts "Bienvenido, dame tu nombre por favor"
print "==>"
#Chomp elimina el ultimo caracter de una cadena de texto
nombre = gets.chomp
puts "Hola, #{nombre} Un placer que éstes por aquí"
puts "Calculadora "
puts "Al numero que ingreses se le sumarán 10 puntos"
puts "==>"
numero = gets.chomp.to_i + 10
puts " El result... | true |
35d8c969816c054c8c23c9fc33d6b47e42663314 | Ruby | satyajyoti/Ruby_Euler | /17.rb | UTF-8 | 770 | 3.4375 | 3 | [] | no_license | def letter_count
num = Hash[(1..20).zip %w(one two three four five six seven eight nine ten eleven twelve
thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty)].merge({
30 =>"thirty",
40 => 'forty',
50 => 'fifty',
60 => 'sixty',
70 => 'seventy',
80 => 'eighty',
90 => 'n... | true |
44c1576855de1d4090947b832ab1841b68d5396f | Ruby | saraid/saraid_utils | /lib/units/of/length.rb | UTF-8 | 917 | 2.609375 | 3 | [] | no_license | module Units
class Meter < Unit.of(:length)
def to_s; 'm'; end
end
SI.expand_prefixes(Meter)
class Foot < Unit.of(:length)
def to_s; 'ft'; end
def conversions
{ Yard => { method_names: %i( to_yards ),
conversion: proc { |number| number.fdiv 3 } },
Mile => { method_n... | true |
4029c15ddff629be8ce310edc833e31c8adb6b20 | Ruby | ripienaar/mc-plugins | /discovery/puppetdb/discovery/puppetdb.rb | UTF-8 | 3,528 | 2.515625 | 3 | [] | no_license | require 'net/http'
require 'net/https'
# Proof of Concept PuppetDB integration for mcollective discovery
# capable of supporting class, fact and identity filters.
#
# Final incorporation into mcollective would depend on the
# http://projects.puppetlabs.com/issues/14763 being closed
#
# There are some hard coded hostna... | true |
0f9285d48de060d0092313ab3b53d3d5a6c4b32e | Ruby | emfigo/cluda | /spec/distances/chebyshev_spec.rb | UTF-8 | 688 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Cluda::Chebyshev do
let(:valid_point) { { x: 1, y: -3 } }
let(:valid_point2) { { x: -1, y: 3 } }
let(:not_valid_point) { {} }
describe '.distance' do
it 'doest not calculate any distance for a none valid point' do
expect {... | true |
69a1c9fbf0d4814845a0518716cdbf3e831cc9b2 | Ruby | astro/harvester | /chart.rb | UTF-8 | 1,304 | 2.890625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'dbi'
require 'yaml'
require 'gruff'
config = YAML::load File.new('config.yaml')
timeout = config['settings']['timeout'].to_i
sizelimit = config['settings']['size limit'].to_i
dbi = DBI::connect(config['db']['driver'], config['db']['user'], config['db']['password'])
class StatsPerCollection
... | true |
cd0f854467e64d6058de2a3be269eee9f0a539bb | Ruby | huangkc/phase-0 | /week-4/errors.rb | UTF-8 | 6,244 | 4.34375 | 4 | [
"MIT"
] | permissive | # Analyze the Errors
# I worked on this challenge [by myself ].
# I spent [1.5] hours on this challenge.
# --- error -------------------------------------------------------
# cartmans_phrase = "Screw you guys " + "I'm going home."
# This error was analyzed in the README file.
# --- error -------------------------... | true |
9665d38f2fe0d26b1b7e94bd6e812436567d7a1a | Ruby | kloomes/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 970 | 2.875 | 3 | [] | no_license | require 'json'
require 'open-uri'
class GamesController < ApplicationController
def new
@selection = []
letters = ("a".."z").to_a
10.times { @selection << letters.sample }
end
def score
@letter_count = {}
params[:letters].split('').each do |letter|
if @letter_count[letter.to_sym].nil?... | true |
646d7432db746f7e7064a147a39db2eba1bfd752 | Ruby | rothberry/leet | /amzn/search_in_rotate_sorted_array.rb | UTF-8 | 1,937 | 4.03125 | 4 | [] | no_license | # @param {Integer[]} nums
# @param {Integer} target
# @return {Integer}
# There is an integer array nums sorted in ascending order (with distinct values).
# Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k], num... | true |
0e2a27e577ad2de42f01b1149f1b4c1642fdd495 | Ruby | tom-warthog/ultimate_townhall | /lib/app/townhalls_follower.rb | UTF-8 | 1,561 | 3 | 3 | [] | no_license | require 'twitter'
require 'dotenv'
require 'pry'
Dotenv.load('.env')
# @info = [{"ville" => "Grenoble", "email" => "nicolas.bertin0@gmail.com", "departement" => "Isère"},
# {"ville" => "Meylan", "email" => "ludovic.bourgoin@gmail.com", "departement" => "Isère"},
# {"ville" => "Echirolles", "email" => "ludovic.bourgoi... | true |
1fc44d572dad7cae432fff98d34ea598999ea26b | Ruby | Seven-dev7/mini_jeu_poo | /app2.rb | UTF-8 | 2,966 | 3.359375 | 3 | [] | no_license | require 'bundler'
Bundler.require
$:.unshift File.expand_path("./../lib", __FILE__)
require 'game'
require 'player'
p "------------------------------------------------"
p "|Bienvenue sur 'ILS VEULENT TOUS MA POO' ! |"
p "|Le but du jeu est d'être le dernier survivant !|"
p "--------------------------------------... | true |
f95c96b24f86834d21b26f21af9c27328fd3fc73 | Ruby | chhavikirtani2000/rubyx | /test/slot_machine/instruction/test_resolve_method.rb | UTF-8 | 1,951 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative "helper"
module SlotMachine
class TestResolveMethod < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction
method = make_method
cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
ResolveMethod.new( "method" , :name , cache_entry )
end
... | true |
fe976753f8fa5f2f1409ef1769e12876d2eb4746 | Ruby | newfront/dailyhacking | /html5/eventsource/libs/formatter.rb | UTF-8 | 1,466 | 3.3125 | 3 | [] | no_license | require "hashie"
require "json"
require "pp"
# abstract base class Formatter
class Formatter
def format
raise "Abstract method. need to override in child class"
end
end
# Create a Formatter for EventSource
class EventSourceFormatter < Formatter
def format(notification)
# notification is an object of H... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.