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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1403cbb042125b1617cb7ee524499c0c83788148 | Ruby | malachispencer/bookmarks-manager | /lib/bookmark_tag.rb | UTF-8 | 528 | 2.765625 | 3 | [] | no_license | require_relative './database_connection.rb'
class BookmarkTag
attr_reader :tag_id, :bookmark_id
def initialize(tag_id:, bookmark_id:)
@tag_id = tag_id
@bookmark_id = bookmark_id
end
def self.create(tag_id:, bookmark_id:)
result = DatabaseConnection.query(
"INSERT INTO bookmarks_tags (tag_id... | true |
fb409515a7076e656e624f7285989c9db3765dda | Ruby | abdulrahman86/rubyproject | /lib/singleton.rb | UTF-8 | 134 | 2.9375 | 3 | [
"MIT"
] | permissive | class Test
def hello
puts 'hello'
end
end
class Test2 < Test
def hello1
hello
end
end
x = Test2.new()
x.hello1
| true |
0b053c49d82e970ecbbdd6bb95fa9275b6003ed0 | Ruby | tienle/cassandra-model | /lib/cassandra-model/types.rb | UTF-8 | 800 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module CassandraModel
class StringType
def self.load(v)
return '' unless v
s = v.to_s
s.clone.force_encoding('UTF-8') if (RUBY_VERSION > '1.9' && s.encoding.name.downcase != 'utf-8')
s
end
end
class IntegerType
def self.load(v)
v && v.to_i
end
end
class FloatTyp... | true |
b552b636359f602122c55896eb0ec5a5786f2acc | Ruby | adrienbourgeois/fredwina | /spec/model/dog_spec.rb | UTF-8 | 2,382 | 3.28125 | 3 | [] | no_license | require_relative '../../config'
RSpec.describe 'dog' do
describe 'move' do
subject { Dog.new([1,2,'N']) }
it { expect(subject).to respond_to(:move) }
it 'returns the coord the dog would have if it executes the motion' do
expect(subject.move).to eq(Position.new([1,3]))
end
end
describe '... | true |
7c41b3f0eb9fe7cce199f4837fb540490c57cd8e | Ruby | tracycaruso/MuralWorks | /app/services/instagram_service.rb | UTF-8 | 752 | 2.8125 | 3 | [] | no_license | class InstagramService
attr_reader :user
def initialize(user)
@user = user
end
def get_user_instagrams
client = Instagram.client(:access_token => user.token)
image_data = []
client.user_recent_media.each do |media|
if media.tags == ["harrisburgmuralproject"]
image_data << {
... | true |
bb06edc4fd761fbaec13e4248ab93b1e8338e07a | Ruby | akm/object_pascal_analyzer | /lib/object_pascal_analyzer/pascal_file.rb | UTF-8 | 657 | 2.96875 | 3 | [
"MIT"
] | permissive | require "object_pascal_analyzer"
require "object_pascal_analyzer/pascal_class"
module ObjectPascalAnalyzer
class PascalFile
attr_reader :klass, :name, :classes
def initialize(name)
@name = name
@classes = []
end
def add_class(name)
PascalClass.new(self, name).tap{|r| @classes << r... | true |
3c50d5eaa09c84502a94798f787cb4beacff56dd | Ruby | SalesFunnel/sinatra | /apps/store/data_store.rb | UTF-8 | 420 | 2.53125 | 3 | [] | no_license | require 'json'
require_relative '../helper/data_helper'
class DataStore
include DataHelper
def initialize(settings)
@settings = settings
end
def get_all_data
data_hash = parse_data
p @settings.name
p 'get all data'
data_hash
end
def update_item
p 'do something update'
end
... | true |
a09d1cf17e1993c0bbd93b22ce07ed6c6e88e80e | Ruby | Madhanag0pal/Problem_Solving | /Tarifa/tarifa.rb | UTF-8 | 91 | 2.65625 | 3 | [] | no_license | bl = x = gets.to_i
n = gets.to_i
for i in 1..n
bl += x - gets.to_i
end
puts bl
| true |
c53c51fcdeecc2ccf8158b310ae783b5fd8af93d | Ruby | jordandavidson1990/homework_3 | /exercise_c_uk.rb | UTF-8 | 1,394 | 3.6875 | 4 | [] | no_license | united_kingdom = [
{
name: "Scotland",
population: 5295000,
capital: "Edinburgh"
},
{
name: "Wales",
population: 3063000,
capital: "Swansea"
},
{
name: "England",
population: 53010000,
capital: "London"
}
]
# 1. Change the capital of Wales from `"Swansea"` to `"Cardiff"`... | true |
f6a2d6cc989fb73d3ccff774430dd91876d310de | Ruby | chameleon-bi/chambi_oa | /app/validators/url_validator.rb | UTF-8 | 549 | 2.578125 | 3 | [
"MIT"
] | permissive | # Custom validator to validate URLs
class UrlValidator < ActiveModel::EachValidator
# Validates URLs to include full protocol, subdomain, domain, TLD (or sTLD)
def validate_each(record, attribute, value)
unless value =~ URL_REGEX
record.errors[attribute] << (options[:message] || 'is not a valid web addres... | true |
54247f5bbc7c7a825c2b9e6d5bcc9fc957039dde | Ruby | ckhsponge/railsvendor | /vendor/plugins/active_merchant/lib/active_merchant/billing/credit_card.rb | UTF-8 | 5,298 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'time'
require 'date'
require 'active_merchant/billing/expiry_date'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
# == Description
# This credit card object can be used as a stand alone object. It acts just like an ActiveRecord object
# but doesn't support the .save method as its not bac... | true |
6d348d1858b412d796be066753650d425de8e1c3 | Ruby | spoonm/idarub | /demos/gameoflif.rb | UTF-8 | 1,106 | 3.890625 | 4 | [] | no_license | #!/usr/bin/env ruby
#
# Game of life yo
#
# circular board
# crappy and sloppy implementation, don't reuse for anything
#
class GameOfLif
attr_accessor :board
def self.new_random(height, width)
new((0..height).map { (0..width).map { rand(2) } })
end
def initialize(_board = [[]])
self.board = _board
end
d... | true |
f7c15de768549e2da6bdd29cad43f9bd0704b461 | Ruby | crabtw/home-config | /bin/seq-rename | UTF-8 | 1,159 | 3.015625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
def nat_ord s
s.split(/(\d+)|(\D+)/).select {|c| c != ''}.map do |c|
x = c.to_i
x > 0 || c[0] == '0' ? x : c
end
end
class Fixnum
alias :old_cmp :<=>
def <=> a
case a
when Fixnum then old_cmp a
when String then -1
end
end
end
class String
... | true |
1ffc704dbaeb7553d3e5c4e8b9a3af998b14ad70 | Ruby | benjamin-korobkin/Web_Design_Adaleg | /Ruby/fib.rb | UTF-8 | 326 | 3.53125 | 4 | [] | no_license | def fib(n)
num0 = 0
num1 = 1
if n == 1 then
return num0
elsif n == 2 then
return num1
else
for x in 1..(n-2) do
num2 = num0 + num1
num0 = num1
num1 = num2
end
end
return num2
end
puts fib(1)
puts fib(2)
puts fib(3)
puts fib(4)
puts fib(5)
puts fib(6)
puts fib(7)
puts f... | true |
802fba9256b8e112a43e7b7c2ca72eb5289f7467 | Ruby | EDalSanto/LaunchSchool | /exercises/120_OOP/med1/circular_queue.rb | UTF-8 | 1,490 | 3.921875 | 4 | [] | no_license | class CircularQueue
def initialize(size)
@queue = []
@max_size = size
end
def enqueue(element)
dequeue if @queue.size == @max_size
@queue.push(element)
end
def dequeue
@queue.shift
end
end
class CircularQueueLONG
def initialize(size)
@queue = Array.new(size)
@next_index ... | true |
a544db67090bf173598c4e93cd634ddc50831b49 | Ruby | hsheikhm/airport_challenge | /lib/plane.rb | UTF-8 | 274 | 3.015625 | 3 | [] | no_license | class Plane
attr_reader :status, :location
def initialize
@status = :flying
@location = :air
end
def flying
@status = :flying
@location = :air
self
end
def landed
@status = :landed
@location = :airport
self
end
def flying?
@status == :flying
end
end
| true |
53488fe8865df1c266cda7c97401e37c5a0746bd | Ruby | acantu101/triangle-classification-v-000 | /lib/triangle.rb | UTF-8 | 994 | 3.1875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
def initialize(a, b, c)
@triangle_sides = []
@triangle_sides << a
@triangle_sides << b
@triangle_sides << c
@a = a
@b = b
@c = c
end
def valid?
sum_one_two = @triangle_sides[0] + @triangle_sides[1]
sum_one_three = @triangle_sides[0] + @triangle_sides[2]
sum... | true |
76d2db878aeffd06342356e5bc714e2d8812d05a | Ruby | runeni/brew-temper | /app.rb | UTF-8 | 1,105 | 2.515625 | 3 | [] | no_license | require "sinatra"
require "sinatra/activerecord"
require "time"
require "pp"
set :database, "sqlite3:///temper.db"
class Measure < ActiveRecord::Base
def nice_time
self.created_at.strftime("%Y-%m-%d %H:%M")
end
end
get '/measures.json' do
content_type :json
Measure.all.to_json
end
get '/measure/:at' do
... | true |
5e0c9e2fb04bcee57bbfedf68c12d525dfbaa74b | Ruby | pmarreck/ruby-snippets | /null_object.rb | UTF-8 | 305 | 3.15625 | 3 | [] | no_license | class NullObject
def method_missing(*args)
self
end
def initialize
@origin = caller.first
end
def nil?; true; end
end
def Maybe(value)
value.nil? ? NullObject.new : value
end
foo = nil
p Maybe(foo).bar.baz + 5
p NullObject.new || 5
p Maybe('ABC').downcase.strip.tr_s('^a-z0-9', '-')
| true |
2fb1cd3783241ce808dc45b2faa0d8da050bf972 | Ruby | thesilentc/oo-barking-dog-v-000 | /lib/dog.rb | UTF-8 | 275 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
attr_accessor :name
def bark
puts "woof!"
end
end
# class Dog
# def name # setter (or writer method?)
# @name
# end
# def name=(dog_name) # getter (or reader method?)
# @name = dog_name
# end
# def bark
# puts "woof!"
# end
# end
| true |
90298f9d2f52720a796f050f556e7567d1e28554 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature686/method_source/13944.rb | UTF-8 | 196 | 3.28125 | 3 | [] | no_license | def combine_anagrams(words)
h = {}
words.each do |word|
word2 = word.downcase.chars.sort
h.has_key?(word2) ? (h[word2] = (h[word2] + [word])) : (h[word2] = [word])
end
h.values
end | true |
05a96354c20f2035f23d82785e012c7619fe3545 | Ruby | dugancathal/ladder-board | /app/models/leader_board.rb | UTF-8 | 488 | 3.140625 | 3 | [] | no_license | class LeaderBoard
attr_reader :points, :rank
def initialize(users)
@users = users
@lowest_rank = 1
@current_board = []
end
def rankings
current_rank = 1
current_score = @users.first.score
number_passed = 0
@users.map do |player|
if current_score > player.score
current_... | true |
dd974e752cc60dcc11bb7a406ed35b516fbad60d | Ruby | johnsafe/send_cloud | /lib/send_cloud.rb | UTF-8 | 3,066 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'send_cloud','version.rb')
module SendCloud
class EmailRecord
attr_accessor :api_user,:api_key,:format
require 'net/https'
require 'uri'
def initialize(args={})
args[:format]||='xml'
raise ArgumentError.new('user missing') if args[:api_user].nil?... | true |
48302760e1545fd826f522c02953b408c8a2d317 | Ruby | mcs526/RubyExploration | /DaffyDuckified.rb | UTF-8 | 430 | 4.1875 | 4 | [] | no_license | print "Your input please: "
#.chomp removes the newline that is created as a defult from gets
user_input = gets.chomp
#the use of the "!" is used so the user_input string is modified-in-place
user_input.downcase!
if user_input.include? "s"
user_input.gsub!(/s/, "th")
else
print "your phrase can't be Daffy Duckified... | true |
99aca3737d26e6049edd68e78353b75d6da5603e | Ruby | elizabethhyer/grid_monsters_web | /db/seeds.rb | UTF-8 | 3,100 | 2.921875 | 3 | [
"MIT"
] | permissive | ### SEED DATABASE ###
## Users ##
dracula = User.create(:name => "Dracula", :username => "vampman2000", :password => "hooray4blood")
the_mummy = User.create(:name => "The King", :username => "linenlover404", :password => "asleep4ages")
the_blob = User.create(:name => "The Blob", :username => "huskyguy", :password =>... | true |
1bd7aaf957e058b0777134aa10cf8efd9e3c9056 | Ruby | viditn91/vinsol-training | /Ruby_exercise/Sales_tax/lib/product.rb | UTF-8 | 370 | 2.78125 | 3 | [] | no_license | class Product
attr_reader :name, :price, :import_status, :exemption
attr_accessor :sales_tax, :price_incld_tax
def initialize(name, import_status, exemption, price)
@name, @import_status, @exemption, @price = name, import_status, exemption, price
end
def is_imported?
@import_status =~ /yes/i
end
d... | true |
f474583486844bcd0fc67b9b4bb42c15f2a21c8c | Ruby | jtlai0921/PG20249_example | /PG20249_sample/Ruby268-SampleProgram-UTF8/Ch2/sample038-02.rb | UTF-8 | 164 | 2.9375 | 3 | [] | no_license | p "1".to_f #=> 1.0
p "1.2".to_f #=> 1.2
p "a".to_f #=> 0.0
p Float("1") #=> 1.0
p Float("1.2") #=> 1.2
p Float("a") #=> ArgumentError: invalid value for Float: "a"
| true |
ae39918ab40947c414035c120f792f159dedb95f | Ruby | BettyHoPro/2AllPlayer | /helper.rb | UTF-8 | 1,239 | 3.5625 | 4 | [] | no_license | require './game'
require './player'
require './question'
##--- Game helpers ---## ---> these twos can just be a turn class itself
def check_current_player?(current_player, player1, player2, non_current_player)
question = Question.new
puts ""
puts "----- NEW TURN -----"
if current_player == 1
@non_curren... | true |
8bbf0c2c930439ef7af78e002a3c12babcf4c899 | Ruby | Shonda860/linked-lists | /lib/linked_list.rb | UTF-8 | 1,510 | 3.625 | 4 | [
"MIT"
] | permissive | require_relative "node"
class LinkedList
attr_reader :head
def initialize
@head = nil
end
# Time complexity - O(1)
# Space complexity - O(1)
def add_first(data)
#head starts as nil
first = Node.new(data, @head) #(3,nil)
@head = first # reassign first to be head
# head = 3
return f... | true |
985a6587d7281f0cd98ac4c4f9db33918c6cc57e | Ruby | OMGDuke/learn_to_program | /ch12-new-classes-of-objects/happy_birthday.rb | UTF-8 | 468 | 3.78125 | 4 | [] | no_license | def happy_birthday
puts "What year were you born in? (ie 1970)"
year = gets.chomp
puts "What month were you born in? (ie 11)"
month = gets.chomp
puts "what day were you born on? (ie 26)"
day = gets.chomp
birthday = Time.local(year,month,day)
puts "Your birthday is #{birthday.strftime("%d-%m-%Y")}"
ag... | true |
6839b81f7c4d48e32e6d38a8bf2e43f5d4f39112 | Ruby | veloso/aiqueburro | /aiqueburro.rb | UTF-8 | 2,691 | 2.703125 | 3 | [] | no_license | #!ruby19
# encoding: utf8
# author: tiago veloso
require 'rubygems'
require 'twitter'
@config = YAML::load(File.open('/opt/aiqueburro/config.yml')) #abre o config.yml somente-leitura na memória
@config2 = YAML::load(File.open('/opt/aiqueburro/config_1.yml', 'r+')) #r+ significa leitura e escrita
httpauth = Twitter:... | true |
ac6dbd5c75653b0d0d86188abae9eefd5d316838 | Ruby | ga-wolf/wdi-21 | /05-ruby/loops/loop.rb | UTF-8 | 1,233 | 4.125 | 4 | [] | no_license | # while some_condition
# # Some code to execute
# end
# while true
# puts "This isn't that bad of an idea"
# end
# Infinite loops aren't as bad as JS, CTRL + C is to quit
# Loops
# Starting Point
# Increment or a Step
# End Condition
# i = 0
# while i <= 5
# puts "I: #{i}"
# i += 1
# end
#
# x = 5
# wh... | true |
f0702ef74daa66eaba05b7fd490cc558aae60b3f | Ruby | rockshandy/raildoku | /app/controllers/sudoku_controller.rb | UTF-8 | 4,330 | 2.734375 | 3 | [] | no_license | require 'local_search'
class SudokuController < ApplicationController
include LocalSearch
def index
@board = Board.new
#example
end
# stat a new board, should be ajax, perhaps should start solving in background
def init
# the javascript puts an extra comma at end so get rid of it
#val = Board... | true |
4f75216f4f0012c99c5e5099b07e84b334180e81 | Ruby | NUBIC/katas | /anagrams/anagram_runner.rb | UTF-8 | 520 | 3 | 3 | [] | no_license | require File.expand_path("../anagram", __FILE__)
require 'benchmark'
require 'benchmark/ips'
word_list = File.readlines("wordlist.txt").collect(&:chomp)
Benchmark.ips do |suite|
[(1000..1010), (1000..1100), (1000..2000), (1000..11000), (0..-1)].each do |range|
suite.report("sets #{range.inspect} #{range.last -... | true |
902a2ac88a49c012f45c115db8830aadcda91e94 | Ruby | nateReiners/minesweeper | /minesweeper.rb | UTF-8 | 1,148 | 3.453125 | 3 | [] | no_license | require_relative 'board'
class Minesweeper
attr_reader :board
def initialize(board = Board.new)
@board = board
end
def valid_move?(pos)
pos.is_a?(Array) &&
pos.length == 2 &&
!board.grid[pos[0]][pos[1]].visible
end
def make_move(pos)
board.grid[pos[0]][pos[1]].make_visible
end
def... | true |
cf25fb5661d2709bfefa335c73992b0d6669444c | Ruby | mairon/pratic | /vendor/plugins/brazilian-rails/brnumeros/lib/brnumeros/number_portuguese.rb | UTF-8 | 4,526 | 2.8125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
module Extenso
@@unidade = {
0 => "CERO",
1 => "UN",
2 => 'DOS',
3 => "TRES",
4 => "CUATRO",
5 => "CINCO",
6 => "SEIS",
7 => "SIETE",
8 => "OCHO",
9 => "NUEVE",
}
@@dezena = {
10 => "DIEZ",
11 => "ONCE",
12 => "DOCE",
13 => "TRECE",
14... | true |
a33016a9dbe8bf4e6cd9626dc6bb1edb7bb67b32 | Ruby | m-mrcr/jungle_beats | /test/linked_list_test.rb | UTF-8 | 2,851 | 3.265625 | 3 | [] | no_license | require './test/test_helper'
class LinkedListTest < MiniTest::Test
def setup
@list = LinkedList.new
end
def test_it_exists
assert_instance_of LinkedList, @list
end
def test_it_has_attributes
assert_nil @list.head
end
def test_it_can_append_to_head
@list.append("doop")
assert_insta... | true |
6c91f0330f8d2af85249cfec084b3db6c0accfbf | Ruby | omikron15/Ruby_Poker_App | /models/specs/player_spec.rb | UTF-8 | 414 | 2.8125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative '../Player.rb'
class TestPlayer < Minitest::Test
def setup()
options1 = {
"name" => "Connor",
"colour" => "Blue"
}
@player1 = Player.new(options1)
end
def test_name()
assert_equal("Connor", @player1.name)
end
de... | true |
30eb7f9a11d1fa158955c57f19d90fa4bebc501e | Ruby | onkar-josh/GitTraining | /calculator.rb | UTF-8 | 599 | 3.953125 | 4 | [] | no_license | class Calculator
def substract(a,b)
puts a-b
end
def multiplication(a,b)
puts a*b
end
def squre(x)
puts x * x
end
def addition(a,b)
puts a + b
end
def powering(num)
puts num**num;
end
def divide(operand1, operand2)
begin
puts (operand1 / operand2)
rescue
... | true |
7b3e90fba609b00fc390ea36166ffb1e8fab0bc2 | Ruby | mac718/Launch_School | /small_problems/easy_6/find_the_duplicate.rb | UTF-8 | 225 | 3.46875 | 3 | [] | no_license | def find_dup(arr)
dup = arr.reject { |num| arr.count(num) < 2 }
dup[0]
end
# or
def find_dup(arr)
iterated_nums = []
arr.each do |num|
return num if iterated_nums.include?(num)
iterated_nums << num
end
end | true |
54bbb0ffe950c897bc4627f5b4a3efdca9345f80 | Ruby | kg-coderta/atcoder | /GIGAcode2019.rb | UTF-8 | 1,285 | 3.21875 | 3 | [] | no_license | A
a = gets.split.map(&:to_i)
p a[0]*a[1]**2
B
a = gets.split.map(&:to_i)
ans= 0
for num in 1..a[0] do
b= gets.split.map(&:to_i)
ans+=1 if b[0] >= a[1] && b[1] >= a[2] && b[0]+b[1] >= a[3]
end
p ans
C #(2)まで
a = gets.to_i
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
upper_sum = 0
can_buy = 1000000000
fo... | true |
b6c5686b4892473ad3b323713356bf6bcdd3bf20 | Ruby | harr1193/cartoon-collections-cb-gh-000 | /cartoon_collections.rb | UTF-8 | 702 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)# code an argument here
# Your code here
dwarves.each_with_index { |name, i| puts "#{i+1}. #{name}" }
end
def summon_captain_planet(planeteer)# code an argument here
# Your code here
planeteer_new = []
planeteer_new = planeteer.collect do |name|
name.capitalize + "!"
end
... | true |
7368848646b55def0e8abda769f3863c7e118d9e | Ruby | marzily/sales_engine | /lib/invoice.rb | UTF-8 | 1,386 | 2.734375 | 3 | [] | no_license | require_relative 'model_object'
require_relative 'transaction'
class Invoice < ModelObject
attr_reader :customer_id, :merchant_id, :status
def initialize(data, invoice_repo)
super
@customer_id = data[:customer_id].to_i
@merchant_id = data[:merchant_id].to_i
@status = data[:status]
end
de... | true |
bcbea74444ac8f684eb5c12b0ffd09f08a06960c | Ruby | gillsinaglass/hikr | /app/models/hike.rb | UTF-8 | 1,017 | 2.703125 | 3 | [] | no_license | class Hike < ApplicationRecord
belongs_to :trail
belongs_to :user
def self.completed_hikes
Hike.all.select do |hike|
hike.updated_at != hike.created_at
end
end
def start_time
d = DateTime.parse(self.created_at.to_s)
d.strftime('%I:%M %p')
end
def status
if self.updated_at == s... | true |
5d31a7af10d85c96a0887deab3e5ff311b12ce60 | Ruby | cielavenir/procon | /yukicoder/tyama_yukicoder216.rb | UTF-8 | 140 | 2.765625 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
h=Hash.new(0)
gets
$<.map{|e|e.split.map(&:to_i)}.transpose.each{|x,y|h[-y]+=x}
puts h.max_by{|k,v|[v,k]}[0]==0 ? :YES : :NO | true |
eff67e21cb9bd7604d3121df146bc53aee867a37 | Ruby | willmanduffy/Plex-Ruby | /lib/plex-ruby.rb | UTF-8 | 1,282 | 2.75 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
require 'cgi'
module Plex
# Converts camel case names that are commonly found in the Plex APIs into
# ruby friendly names. I.E. <tt>playMedia</tt> -> <tt>play_media</tt>
#
# @param [String] camel case name to be converted
# @return [String] snake case form
def self.u... | true |
94bb3a12380330537e40a20498773d91f56cc792 | Ruby | idanci/ofx | /lib/ofx/parser/ofx102.rb | UTF-8 | 667 | 2.671875 | 3 | [
"MIT"
] | permissive | module OFX
module Parser
class OFX102 < BaseParser
VERSION = "1.0.2"
def self.parse_headers(header_text)
# TODO: refactor
# Change single CR's to LF's to avoid issues with some banks
header_text.gsub!(/\r(?!\n)/, "\n")
# Parse headers. When value is NONE, convert it t... | true |
027948b51ffeb987444ef995da05c259bbd168f4 | Ruby | ccahill1117/definer | /app.rb | UTF-8 | 1,672 | 2.609375 | 3 | [
"MIT"
] | permissive | require('sinatra')
require('sinatra/reloader')
also_reload('lib/**/*.rb')
require('./lib/definer')
require('pry')
get ('/') do
@library = Word.all()
@library = Word.sort_alphabetical()
erb(:input)
end
post ('/') do
word = params["word"]
definition = params["def"]
image = ""
if (word == "") || (definiti... | true |
4c605226ce074f5dc63a16c563a76966422750f9 | Ruby | kswhyte/black_thursday | /lib/merchant.rb | UTF-8 | 659 | 2.5625 | 3 | [] | no_license | class Merchant
attr_reader :id,
:name,
:created_at,
:updated_at
def initialize(merchant, merchant_repository_parent = nil)
@merchant_repository_parent = merchant_repository_parent
@id = merchant[:id].to_i
@name = merchant[:name]
@created_at = Time.parse(mer... | true |
e1b80238b085b21fbf7ce9d82ad4140cf1ada2bf | Ruby | happyhappyhappyhappy/rubycode | /atcoderruby/begineersSelection/chap2/PASTFILES/ABC081A_1.rb | UTF-8 | 270 | 3.515625 | 4 | [] | no_license | # Problem https://atcoder.jp/contests/abc081/tasks/abc081_a
# Ruby 1st Try
one,two,three = gets.chomp('\n').split('')
answer = 0
if one == '1'
answer = answer + 1
end
if two == '1'
answer = answer + 1
end
if three == '1'
answer = answer + 1
end
puts(answer) | true |
63763c0730701694c3424374bebc5a10052b5ff5 | Ruby | dudekmch/Robo | /app/helpers/adresses_helper.rb | UTF-8 | 227 | 2.671875 | 3 | [] | no_license | module AdressesHelper
def full_name(address)
names = [address.last_name, address.first_name]
names.join(' ')
end
def city_zipcode(address)
data = [address.city, address.zip_code]
data.join(' ')
end
end
| true |
a1ce9732ab83930a214081c8628e1ba159512a39 | Ruby | akiradeveloper/haskeller | /lib/haskeller/lazy/enumerable.rb | UTF-8 | 730 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Enumerable
def mapL(&blk)
Enumerator.new do |y|
self.each do |x|
y << (blk.call x)
end
end
end
def filterL(&blk)
Enumerator.new do |y|
self.each do |x|
y << x if blk.call(x)
end
end
end
def zipL( *its )
es = []
es << self
its.each d... | true |
55ff1b7a755fe6b5440a9993878c7379c7719777 | Ruby | runewit/Lab3-Chat-Client | /Server.rb | UTF-8 | 3,245 | 3.359375 | 3 | [] | no_license | require 'socket'
class Server
def initialize()
@server = TCPServer.new 9001 #port 9001
@disconnect = false
@users = []
@usercode = []
run_server(@server)
end
def run_server(server)
loop do
Thread.start(server.accept) do |client|
client.puts "Hello there, what is your name?"
... | true |
0d34188a81a5ec8f066775faf3ba4bdddc97f8ed | Ruby | chrabyrd/project_euler | /problem_31.rb | UTF-8 | 1,008 | 4.0625 | 4 | [] | no_license | =begin
In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:
1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
It is possible to make £2 in the following way:
1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
How many different ways can £2 be made using any number ... | true |
4060a22e16e95b2e997a368fff7da72a91a01d2d | Ruby | missamii/GA-Mirror | /w11/Classwork/ruby_testing/stackqueue_rspec/spec/queue_spec.rb | UTF-8 | 1,309 | 3.203125 | 3 | [] | no_license | require_relative '../queue'
RSpec.describe do
before :each do
@queue = Queue.new
end
describe '#new' do
it "should take no arguments and return a stack object" do
expect(@queue).to be_an_instance_of Queue
end
end
describe '#add' do
it "should add an element to a queue and return the ... | true |
80d041e068157e433b2b448da2c11b3ea5b4c492 | Ruby | fregas/RubyRapper | /rapper.rb | UTF-8 | 1,728 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# vim: set ft=ruby
require 'bundler'
# require_relative '../lib/dpx_active_tags'
Bundler.require
# require 'pg'
# Output a table of current connections to the DB
#conn = PG.connect( dbname: 'postgres' )
#conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
# puts " PID | User ... | true |
1dd4d19a83e331f57437b6c320088677947c350e | Ruby | ForestJay/AllY0urBas1czRBel0ngT0Us | /test_missing_number.rb | UTF-8 | 346 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Written by Forest J. Handford (She/Her)
require_relative 'missing_number'
require 'minitest/autorun'
# Class for testing
class TestMissingNumber < Minitest::Test
def test_find_missing
missing_number = MissingNumber.new
assert_equal 7, missing_number.find_missing
assert_e... | true |
bc2a4e05f866f26c6331c88aeeb5ad1cfaf910b5 | Ruby | sullerandras/garfield-ocr-ruby | /app/entities/line.rb | UTF-8 | 276 | 2.984375 | 3 | [] | no_license | require 'entities/bw_image'
class Line < Bubble
def initialize(bubble)
super bubble.top, bubble.left, false
(bubble.top..bubble.bottom).each do |row|
(bubble.left..bubble.right).each do |col|
add row, col, bubble[row, col] == BWImage::WHITE
end
end
end
end
| true |
e26aeb027b470477ca347d1bb063c3633773f2d5 | Ruby | smoline/departures | /app/models/departure_matrix.rb | UTF-8 | 603 | 3.015625 | 3 | [] | no_license | require 'matrix'
module DepartureMatrix
def airports_matrix!(counts:, field1: "origin", field2: "dest")
h_matrix = counts.each_with_object({}) do |record, hash|
hash[record[field1]] ||= Hash.new(0)
hash[record[field1]][record[field2]] = Integer(record["count"])
end
airports = h_matrix.keys.so... | true |
002f8ff834c09a122a0d92fe2c82aacda007b920 | Ruby | rahuks123/saas201 | /saas201/day3/experiment3.rb | UTF-8 | 277 | 3.890625 | 4 | [] | no_license | class Sample
def initialize (na)
@name=na
puts "this is in the constructor #{@name}"
end
def display(tname)
vd=tname
puts"the name is #{vd}"
end
def tota x=(tn)
puts"the last name is#{x}"
end
end
obj=Sample.new("rahul")
obj.display "vineth"
obj.tota("harsha")
| true |
288cc6e4d5ce5e537f9ab88e8fbf5768e00546ff | Ruby | iliabylich/pattern_matching | /bin/ruby.pm | UTF-8 | 487 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
ROOT = File.expand_path('../..', __FILE__)
$: << File.join(ROOT, 'lib')
require 'pattern_matching'
def run_file(filepath)
if ENV['DEBUG']
puts
puts "[DEBUG] Running #{filepath}:"
puts PatternMatching
.process(File.read(filepath))
.split("\n")
.map
.with_inde... | true |
ede65c051d17746d4cdf3c517a5fac1dbd4115be | Ruby | misyo98/order_management | /app/services/update_delivery_date.rb | UTF-8 | 395 | 2.65625 | 3 | [] | no_license | class UpdateDeliveryDate
def self.call(customer, day = nil)
new(customer, day).call
end
def initialize(customer, day)
@customer = customer
@day = day&.to_date
end
def call
LineItem.for_customer(customer.id).with_state(:delivery_arranged).each do |item|
item.set_appointment_date(day) i... | true |
587669e79f43827b290b1c17c1c2de5ffb264e1d | Ruby | jurre/Enigma | /lib/rotor.rb | UTF-8 | 1,164 | 3.515625 | 4 | [
"MIT"
] | permissive | class Rotor
attr_accessor :rotor_values, :position, :notch # rotor values are accessible for testing purposes only
def initialize(values, start_position, notch)
left_row = ('A'..'Z').to_a * 2 # create an array with the alphabet twice, just like that
# create a twodimentional array where the first dimension... | true |
b830e4b91a303589cd057ff72da02720df14b21b | Ruby | beneggett/hw | /led-demo.rb | UTF-8 | 2,610 | 3.28125 | 3 | [] | no_license | require 'dino'
require 'httparty'
class HW
attr_accessor :board
def initialize
@board = Dino::Board.new(Dino::TxRx.new)
end
def leds
[blue, red, green, yellow ]
end
def blue
Dino::Components::Led.new(pin: 4, board: board)
end
def red
Dino::Components::Led.new(pin: 5, board: board)
... | true |
cb3eef2cd0a3d1bf06e6294b7a6b30dd822ffe26 | Ruby | wisetara/4.5.4_Game_of_Life | /lib/Board.rb | UTF-8 | 558 | 3.3125 | 3 | [] | no_license | class Board
attr_reader :width, :height, :spaces
def initialize(width, height)
@width = width
@height = height
@spaces = []
end
def Board.create(width, height)
new_board = Board.new(width, height)
end
def populate(width, height)
1.upto(width) do |width|
1.upto(height) do |heigh... | true |
0b87338085838002a1d91fe4fb1d714e019565eb | Ruby | thoughtbot/factory_bot | /spec/support/matchers/delegate.rb | UTF-8 | 1,099 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | RSpec::Matchers.define :delegate do |delegated_method|
chain :to do |target_method|
@target_method = target_method
end
chain :as do |method_on_target|
@method_on_target = method_on_target
end
chain :with_arguments do |args|
@args = args
end
match do |instance|
@instance = instance
@... | true |
70f92b48f47d2854bb8ff24f5e86213aa26c4c28 | Ruby | mwagner19446/wdi_work | /w01/d04/Jenn_Dodd/receipt_generator.rb | UTF-8 | 408 | 3.53125 | 4 | [] | no_license | #GATHER USER INFO
puts "Where did you shop?"
place = gets.chomp
puts "What good/service did you buy?"
bought = gets.chomp
puts "What was the cost of said item?"
print "$"
cost = gets.chomp.to_f
#MAKE THE NEW FILE
f = File.new("receipt.txt", "w")
f.puts "Company Name: #{place}"
f.puts "Good/Service Provided: #{bo... | true |
bbd946210c115239b708080f9029595bb583f039 | Ruby | tonyhammond/yads | /tools/clients/ruby/doi/yadt.rb | UTF-8 | 2,959 | 3.09375 | 3 | [] | no_license | #!/usr/local/bin/ruby
########################################################################
#
# yadt - Yet Another DOI Tool (this version for Ruby)
#
# Author - Tony Hammond <tony_hammond@harcourt.com>
#
########################################################################
require 'dataObject'
requir... | true |
b9b8343dd5b50550bcb69e08716871d0bc3d694c | Ruby | OlegSliusar/binary_tree | /test.rb | UTF-8 | 726 | 2.90625 | 3 | [] | no_license | require_relative 'tree'
require 'yaml'
new_tree = Tree.new
ary = [7, 8, 3, 13, 6, 4, 14, 1, 10]
new_tree.build_tree(ary)
puts YAML::dump(new_tree)
File.open('tree.yaml', 'w') do |file|
file.puts YAML::dump(new_tree)
end
puts "#" * 50
puts YAML::dump(new_tree.breadth_first_search(13))
File.open('found_node_bfs.yaml... | true |
a18567c0f6949628c4ff6a76a83645d6e6f02404 | Ruby | Gallup93/pantry_2003 | /lib/cook_book.rb | UTF-8 | 604 | 3.28125 | 3 | [] | no_license | class CookBook
attr_reader :recipes
def initialize
@recipes = []
end
def add_recipe(recipe)
@recipes << recipe
end
def ingredients
all_ingredients = []
@recipes.each do |recipe|
recipe.ingredients_required.each {|key, value| all_ingredients << key.name}
end
all_ingredients.un... | true |
1a024e72d180c9c92ebd93c7bda3287df664fbab | Ruby | VMJ-GG/Generic | /lib/euler/lib/euler/arguments.rb | UTF-8 | 673 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'ostruct'
module Euler
# Arguments Objects are an Hash like structure used to store data about algorithm
# functionalities like needed arguments.
#
# Required options fields are:
# - arguments -> Every arguments necessary to algorithm for working
# (WARNING: don't confuse it with body arguments)
... | true |
cc9c4c3ecc291ec0903ea65c551f1446e2992a73 | Ruby | amsmyth1/yardsourcing-engine | /spec/facades/yards_facade_spec.rb | UTF-8 | 3,098 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe YardsFacade do
describe "class methods" do
it ".find_yards" do
@yard1 = create(:yard, host_id: 1)
@yard2 = create(:yard, host_id: 2)
@yard3 = create(:yard, host_id: 1)
@yard4 = create(:yard, host_id: 2)
@yard5 = create(:yard, host_id: 1)
@... | true |
05c67cac8b3d75de7512be46839f12b07dbb5997 | Ruby | fig/scheduleless | /app/models/calculators/coworkability/rating.rb | UTF-8 | 449 | 2.953125 | 3 | [] | no_license | module Calculators
module Coworkability
class Rating
def self.for(score)
new(score: score).rating
end
def initialize(score:)
@score = score
end
def rating
if score >= 900
:red
elsif score >= 450
:orange
elsif score >= 250
... | true |
4d3d36d3e0040035d0b7d0f23287dbaaed5a777b | Ruby | SarahCyrDesign/ttt-with-ai-project-v-000 | /bin/tictactoe | UTF-8 | 1,063 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../config/environment'
def self.start # for bin Game.start
puts "Welcome to Tic Tac Toe!"
puts "How many players? 0, 1, 2?"
input = gets.strip.to_i
if input == 0
puts "Computer \"X\" Vs Computer \"O\" game start!"
game = Game.new(Players::Com... | true |
96eb3001674ab364e73589f909b190400d039d24 | Ruby | RSijelmass/url-shortener | /app/models/url_parser.rb | UTF-8 | 257 | 2.75 | 3 | [] | no_license | class UrlParser
SHORTHAND_LIMIT = 5
def self.is_valid_url?(potential_url)
valid = potential_url && potential_url.match(/\A#{URI::regexp}\z/)
!!valid
end
def self.create_shorthand
SecureRandom.alphanumeric[0...SHORTHAND_LIMIT]
end
end
| true |
1256257167bacce1900894392bb01c6a1085879a | Ruby | MrAaronOlsen/headcount | /test/statewide_test_repository_test.rb | UTF-8 | 4,307 | 2.625 | 3 | [] | no_license | require_relative 'test_helper'
class StatewideTestRepositoryTest < MiniTest::Test
def test_that_it_is_a_statewide_test_repository
assert_instance_of StatewideTestRepository, StatewideTestRepository.new
end
def test_that_it_collects_unique_names
str = StatewideTestRepository.new
str.load_data({:statew... | true |
3e7c2ee5df10eca3c6fcac1814a1395709b9a858 | Ruby | AakashOfficial/ThreatExchange | /ruby/example/lib/example.rb | UTF-8 | 621 | 3.3125 | 3 | [
"BSD-3-Clause"
] | permissive | def parse(dataset)
printf "\nResults: \n"
if dataset.kind_of?(String)
puts dataset
elsif dataset.kind_of?(Hash)
unless dataset.empty?
dataset.each { |data| p data }
else
puts 'No data found.'
end
else
puts dataset
end
end
def banner(header)
puts '-'*80
puts header
puts '... | true |
f663033cd68e3b84835c2dbbcf410a7551b65580 | Ruby | nineties/math | /numeric/ex4/diff.rb | UTF-8 | 93 | 2.53125 | 3 | [] | no_license | include Math
x = PI/3
h = 10.0**-10
puts (sin(x+h)-sin(x))/h
puts 2*cos(x+h/2)*sin(h/2)/h
| true |
b7e4a38ef4ac62fd1fbfa7940a577a298788f9c8 | Ruby | jtescher/descriptive-statistics | /lib/descriptive-statistics/shape.rb | UTF-8 | 816 | 3.046875 | 3 | [
"MIT"
] | permissive | module DescriptiveStatistics
module Shape
def skewness
return if length == 0
return 0 if length == 1
sum_cubed_deviation / ((length - 1) * cubed_standard_deviation.to_f)
end
def kurtosis
return if length == 0
return 0 if length == 1
sum_quarted_deviation / ((length - ... | true |
8884fda078e572b709af4bc57e925e371841962a | Ruby | CamleGem/GemRepo | /interrupt.rb | UTF-8 | 551 | 2.96875 | 3 | [] | no_license | ltotal = 0
ctotal = 0
wtotal = 0
ARGV.each do |file|
begin
file_obj = File.open(file)
l = 0
c = 0
w = 0
file_obj.each_line do |line|
l += 1
c += line.size
line.sub!(/^\s+/, "")
arg = line.split(/\s+/)
w += arg.size
end
ltotal += l
ctotal += c
wtotal ... | true |
274b437c7ca7e2fdebb1ca38946b152638c9b077 | Ruby | tamu222i/ruby01 | /tech-book/2/2-17.rb | UTF-8 | 61 | 2.8125 | 3 | [] | no_license | # 関数の定義
def add(a, b)
a + b
end
print add(1, 2)
| true |
09a2221df858863b2a987359ff9abcccee276bea | Ruby | nist/ACIM | /tools/extract_lessons/test/test_config_extract.rb | UTF-8 | 1,351 | 2.734375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'test/unit'
require_relative '../lib/config_extract'
class ConfigExtractTest < Test::Unit::TestCase
def test_valid_config_file
config = ConfigExtract.new
assert_equal ConfigExtract, config.class
assert_equal false, config.config.empty?
end
# def test_invalid_config_file
# config = Confi... | true |
f0c98582c9695008c6a38ae875b758d300e79755 | Ruby | peregrinebalas/enigma | /lib/interface.rb | UTF-8 | 230 | 2.890625 | 3 | [] | no_license | module Interface
def read_file
file = File.open(ARGV[0], 'r')
file.read
end
def new_file
File.open(ARGV[1], 'w')
end
def write_file(alteration)
new_file.write(alteration)
new_file.close
end
end
| true |
79bf2ecefbcff4f230dfeb3ff69e8d10756d4a34 | Ruby | rfc2822/meta-tags | /lib/meta_tags/controller_helper.rb | UTF-8 | 1,562 | 2.671875 | 3 | [
"MIT"
] | permissive | module MetaTags
# Contains methods to use in controllers.
#
# You can define several instance variables to set meta tags:
# @page_title = 'Member Login'
# @page_description = 'Member login page.'
# @page_keywords = 'Site, Login, Members'
#
# Also you can use {InstanceMethods#set_meta_tags} method,... | true |
e76941abc7cb7b379664c589ad8e2a5e2efd4bcc | Ruby | clock-rick/TestRedirects | /redirects.rb | UTF-8 | 3,071 | 3.53125 | 4 | [] | no_license | require 'selenium-webdriver'
require 'csv'
require 'chromedriver/helper'
require 'colorize'
require 'net/http'
=begin
This test will open two csv files, the first with original urls
and the second with the redirects. The test will compare take the
original url and record the redirect in browser. Then compare it to
... | true |
6bf926e50f0882fcb3992267517e469bdab04c75 | Ruby | jhardy3/IronhackCourse | /UnitTest/lexiconomitron_spec.rb | UTF-8 | 869 | 3.3125 | 3 | [] | no_license | require "rspec"
require "./Lexiconomitron"
describe "Lexiconomitron" do
let(:lexi) { Lexiconomitron.new }
describe '#eat_t' do
let(:input) {"great scott!"}
let(:output) {"grea sco!"}
it "removes every letter t from the input" do
lexi = Lexiconomitron.new
expect(lexi.eat_t(input)).to eq(... | true |
7e2ac0d10b4276f434c51594095c86ef4dffe936 | Ruby | nricheton/FaitesLesComptes | /lib/pdf_document/page.rb | UTF-8 | 2,980 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | # coding: utf-8
require 'pdf_document/table'
module PdfDocument
class Page
attr_reader :number, :table, :document
def initialize(number, doc)
@number = number
@document = doc
end
def stamp
document.stamp
end
def top_left
"#{document.organism_name}\n#{document... | true |
8d90aa9efcdf010be019f779175c45b1c2de5c91 | Ruby | DouglasAllen/ruby-kickstart-4-rdoc | /session2/notes/05-other-useful-array-methods.rb | UTF-8 | 668 | 3.59375 | 4 | [] | no_license | class Session02Notes
=begin
=== Useful methods
chars = ['a', 'b', 'c']
# Concatenate with +
chars + ['d', 'e'] # => ["a", "b", "c", "d", "e"]
# Append to an array
chars # => ["a", "b", "c"]
chars << 'd'
chars # => ["a", "b", "c", "d"]
# Replace
chars[1] = 'Bee'
chars # => ["a", "Bee", "c", "d... | true |
d4808fb78806c907bdb3d05bc563df79c334e6ea | Ruby | dmono/rock-paper-scissors | /lib/rock.rb | UTF-8 | 208 | 2.859375 | 3 | [] | no_license | require_relative 'move'
class Rock < Move
def initialize
@value = 'rock'
@initial = 'R'
end
def beats?(other_move)
other_move.value == 'scissors' || other_move.value == 'lizard'
end
end
| true |
2547091ec390e8589b45a2c68a0c121514e1c9b5 | Ruby | ivancarrascal/Generation-projects | /facetoface/semana_1/functions2.rb | UTF-8 | 400 | 3.953125 | 4 | [] | no_license | def power_formula(base_chemical)
sugar = base_chemical * 500
spice = sugar / 1000
everything_nice = sugar / 100
return sugar, spice, everything_nice
end
chemical_x = 10000
blossom, buttercup, bubbles = power_formula(chemical_x)
puts "Using the value #{chemical_x} as our base chemical"
puts "We get values of ... | true |
0cf607e2c67d7f0e4a74e12436e60b81c6c09ffc | Ruby | tompave/prime_numbers | /lib/prime_numbers/renderer.rb | UTF-8 | 1,133 | 3.21875 | 3 | [
"MIT"
] | permissive | module PrimeNumbers
class Renderer
def initialize(table)
@table = table
end
def render
buffer = []
buffer << render_header
buffer << render_separator
table.size.times do |row|
buffer << render_row(row)
end
buffer.join("\n")
end
private
... | true |
1603deeb048a0ff783d91604bd5649beaa84b3b3 | Ruby | mrdevin/scss-lint | /lib/scss_lint/linter/declaration_order.rb | UTF-8 | 918 | 2.71875 | 3 | [
"MIT"
] | permissive | module SCSSLint
# Checks the order of nested items within a rule set.
class Linter::DeclarationOrder < Linter
include LinterRegistry
DECLARATION_ORDER = [
Sass::Tree::ExtendNode,
Sass::Tree::PropNode,
Sass::Tree::RuleNode,
]
def visit_rule(node)
children = node.children.sel... | true |
6758d25e784dea0c3a926fd290db8442830fac56 | Ruby | MisterAreBe/rb-tic-tac-toe | /app_2.rb | UTF-8 | 4,868 | 2.734375 | 3 | [] | no_license | require 'sinatra'
require_relative 'ttt_require_me.rb'
enable :sessions
get '/' do
erb :index, :layout => :layout
end
post '/play' do
session[:size] = params[:size] || 3
session[:board] = Game_board.new(session[:size].to_i)
session[:playerx] = params[:playerx] || ''
session[:playero] = params[:playero] ||... | true |
6e9c723228321e31ed4cb5e3cd314d347eab4eb1 | Ruby | trueknightwhosayni/ni | /lib/ni/action_chain.rb | UTF-8 | 2,615 | 2.640625 | 3 | [
"MIT"
] | permissive | module Ni
class ActionChain
attr_accessor :name, :description, :received_values, :returned_values, :units, :failure_callback, :rescues
def initialize(klass, name, description, &block)
@interactor_klass = klass
@name = name, @description = description
@units = block_given? ? [block.to_proc] ... | true |
421f81536610f82a3580134ce52e2111c9530730 | Ruby | EricRicketts/LaunchSchool | /exercises/Ruby/object_oriented_programming/easy/one/exercise_eight_test.rb | UTF-8 | 512 | 3.34375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require 'pry-byebug'
class ExerciseEightTest < Minitest::Test
class Rectangle
def initialize(height, width)
@height = height
@width = width
end
def area
@height * @width
end
end
class Square < Rectangle
def initialize(sid... | true |
23643a61f0d8233f50e12aaa40f6459880cce08d | Ruby | katharinap/orange | /app/models/course.rb | UTF-8 | 1,534 | 2.5625 | 3 | [] | no_license | # == Schema Information
#
# Table name: courses
#
# id :integer not null, primary key
# name :string
# date :date
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Course < ApplicationRecord
belongs_to :user
validates :... | true |
c9dadf2cf09ca147c23739e78113c9b9515c110f | Ruby | roryg11/interview | /lib/address.rb | UTF-8 | 509 | 2.890625 | 3 | [] | no_license | require_relative 'geocoding'
class Address
attr_accessor :lat, :lng, :full_address
def reverse_geocoded_by
Geocoder.search([@lat, @lng]).first.address
end
def get_coordinates
Geocoder.search(@full_address)
end
def get_distance_from(addressTo, address)
addressToCoordinates = Geocoder.search(a... | true |
056586d9df36150d25d9ae8adeefbf7cf2e16c81 | Ruby | mislav/tolk | /lib/tolk/import.rb | UTF-8 | 1,244 | 2.65625 | 3 | [
"MIT"
] | permissive | module Tolk
module Import
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def import_secondary_locales
locales = I18n.available_locales - [self.primary_locale.name.to_sym]
phrases = Tolk::Phrase.all
locales.each {|name| import_locale(nam... | true |
f2dde4c332dcf157de5cd0eb11a6b2460285f8e5 | Ruby | Barteezy/rake-warmup | /Rakefile | UTF-8 | 1,011 | 3.578125 | 4 | [] | no_license | desc "Print a nice greeting"
task :greet do
puts "Hello there"
end
desc "Prints your favorite food is"
task :print_favorite_food do
ENV["FAVORITE_FOOD"] = "Pizza"
puts "Favorite Food is: #{ENV["FAVORITE_FOOD"]}"
end
task :first do
puts "First!"
end
task :second => :first do
puts "Second!"
end
task :wake_... | true |
6ab38a7aa329f2fd57a7bededea9ddce464fbdf2 | Ruby | marysadness/CS262 | /homework01/01-4-homework.rb | UTF-8 | 204 | 2.609375 | 3 | [] | no_license |
class CustomeTime < Time
def time_now()
return Time.now()
end
def time_day()
t = Time.local(time_now())
return t.friday?
end
def local_zone()
return Time.time_now().zone
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.