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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5ef2fe5d0cd761075ac7a1f8cfffab70c488e46f | Ruby | vidriloco/MosaicsBackend | /app/models/exports/meta_questions.rb | UTF-8 | 948 | 2.578125 | 3 | [] | no_license | module Exports::MetaQuestions
# Recovers the data of this meta question for postprocessing to plist
def preprocess_to_plist
plist_hash = %w(title instruction type_of).each.inject({}) do |last, attr|
last[attr.to_sym] = self.send(attr)
last
end
%w(meta_answer_items meta_answer_options... | true |
6a9373b53386c304e01f954698257a2a5b8a3b21 | Ruby | forest-zjx/simplehotel | /HotalTest1/app/models/hotal.rb | UTF-8 | 912 | 2.65625 | 3 | [] | no_license | class Hotal < ActiveRecord::Base
attr_accessible :address, :is_admin, :lat, :lon, :name, :password, :status, :tel, :username
validates_presence_of :address, :message => '请输入地址。'
validates_presence_of :is_admin, :message => '请输入0或1。'
validates_presence_of :lon, :message => '请输入0~180数字。'
validates_presence_... | true |
6c5affac46ba61b003c17318ebff28a036c00f58 | Ruby | Omosofe/Play | /implement-map-in-lisp-in-ruby/implement-map-in-lisp-in-ruby.rb | UTF-8 | 2,643 | 3.71875 | 4 | [
"MIT"
] | permissive | # === booleans ===
t = ->(first, second) { first } # true
f = ->(first, second) { second } # false
n = ->() { n } # nil
_if = ->(bool, consequent, alternative) { bool[consequent, alternative][] }
do_if = ->(bool, consequent) { _if[bool, consequent, n] }
do_unless ... | true |
b5c68e33d05b1b6fc7104c8019e7557bedf91f80 | Ruby | kewpiedoll/RubyWinter2014 | /week4/exercises/code_timer_spec.rb | UTF-8 | 637 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | require './code_time'
describe CodeTimer do
it "should run our code" do
flag = false
CodeTimer.time_code do
flag = true
end
flag.should be_true
end
it "should time our code" do
Time.stub(:now).and_return(0,3)
time = CodeTimer.time_code do
end
time.should be_within(0.1).of(3.0)
end
... | true |
12cb53822dcb3e3f36b30999ec80c344819f85e3 | Ruby | gooch/RDialogy | /lib/rdialogy/checklist.rb | UTF-8 | 1,412 | 3.234375 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/base'
require File.dirname(__FILE__) + '/menu_item'
module RDialogy
# From dialog(1)
# A checklist box is similar to a menu box; there are multiple entries presented in the form of a menu.
# Instead of choosing one entry among the entries, each entry can be turned on or ... | true |
b518b102302762f274fd65aaf3af457923b7c44e | Ruby | dreadheaddreamz/hash-iteration-onl01-seng-pt-012120 | /lib/birthday.rb | UTF-8 | 830 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # birthday_kids = {
# "Timmy" => 9,
# "Sarah" => 6,
# "Amanda" => 27
# }
def happy_birthday(birthday_kids)
birthday_kids.each do |kids_name, age|
puts "Happy Birthday #{kids_name}! You are now #{age} years old!"
end
end
#def age_appropriate_birthday
# birthday_kids.each do |kids_name, age|
# if age... | true |
0a9d4230ae025b0ede7508c40ae09847ff251bcc | Ruby | Shopify/vcr | /lib/vcr/cassette/serializers.rb | UTF-8 | 2,006 | 2.5625 | 3 | [
"MIT"
] | permissive | module VCR
class Cassette
# Keeps track of the cassette serializers in a hash-like object.
class Serializers
autoload :YAML, 'vcr/cassette/serializers/yaml'
autoload :Syck, 'vcr/cassette/serializers/syck'
autoload :Psych, 'vcr/cassette/serializers/psych'
autoload :JSON... | true |
4de780bbbdfdc9df166375f3c2d3eabc66c4a0b2 | Ruby | MilesHeise/WikiSmarts | /db/seeds.rb | UTF-8 | 915 | 2.78125 | 3 | [] | no_license | require 'faker'
# Create Users
5.times do
User.create!(
email: Faker::Internet.email,
password: Faker::Internet.password,
confirmed_at: DateTime.now
)
end
users = User.all
# Create Wikis
15.times do
Wiki.create!(
title: Faker::Book.title,
body: Faker::Lovecraft.paragraphs(rand(2..8)).j... | true |
15f43b822af83528cf79077e509c4f379df3f2d2 | Ruby | prg-titech/ikra-ruby | /lib/types/inference/command_inference.rb | UTF-8 | 4,296 | 2.515625 | 3 | [
"MIT"
] | permissive | module Ikra
module TypeInference
class CommandInference < Symbolic::Visitor
def self.process_command(command)
return command.accept(CommandInference.new)
end
# Processes a parallel section, i.e., a [BlockDefNode]. Performs the following steps:
... | true |
fe54e1efbfc3b8a52ecccb47ad645fdc60641f0c | Ruby | jessesbyers/programming-univbasics-4-intro-to-hashes-lab-online-web-prework | /intro_to_ruby_hashes_lab.rb | UTF-8 | 539 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def new_hash
new_hash = {}
end
def my_hash
my_hash = {name: "Jesse", age:40}
end
def pioneer
pioneer = {name: "Grace Hopper"}
end
def id_generator
id_generator = {id: 7}
end
def my_hash_creator(key, value)
hash = {key => value}
end
def read_from_hash(hash, key)
read_from_hash = {key => a_value}
... | true |
83ae0cdbbea641c539f4e3d6458a74fb9db368ce | Ruby | Hawatel/hawatel_tlb | /lib/hawatel_tlb/mode/ratio.rb | UTF-8 | 2,406 | 2.875 | 3 | [
"MIT"
] | permissive | module HawatelTlb::Mode
##
# = Ratio algorithm
#
# Thease are static load balancing algorithm based on ratio weights.
# Algorithm explanation:
# 1. divide the amount of traffic (requests) sent to each server by weight (configured in the Client)
# 2. Sort by ratio (result from 1. point) from smallest to la... | true |
68b51b057a94c2ffe99069a71e75ee28372262c9 | Ruby | PickleBanquet/collatz | /collatz.rb | UTF-8 | 419 | 3.6875 | 4 | [] | no_license | def collatz_value(n)
n = n.to_i
if n <= 0
puts "Undefined value"
else
i = 1
while (n != 1)
i = i + 1
if (n % 2 == 0)
n = n /2
else
n = 3 * n + 1
end
end
return i
end
end
high_value = 0
high_collatz = 0
for i in (1..1000000)
current_value = collatz_value(i)
if (current_value > high... | true |
bc277282f1e402a7721aa03b64bbf9b6f406d528 | Ruby | davidsiaw/minazuki | /main.rb | UTF-8 | 8,708 | 2.65625 | 3 | [] | no_license | # frozen_string_literal: true
require 'active_support/inflector'
require 'date'
require 'fileutils'
require 'erubis'
require 'bunny/tsort'
# Global generator
class GlobalGenerator
attr_reader :resources
def initialize(file, resources)
@resources = resources
@file = file
end
def filename
@file
... | true |
c65066b4aff4e3b5ab22c6432f610f71941c2787 | Ruby | tkbrigham/pronto | /lib/pronto_summarizer.rb | UTF-8 | 601 | 2.5625 | 3 | [] | no_license | class ProntoSummarizer
def initialize(timestamp)
@timestamp = timestamp
end
def stats
StationStat.where(timestamp: @timestamp)
end
def summarize
stats.each do |stat|
StatSummarizer.new(stat).summarize
end
end
def clean
StationStat.where('created_at <= ?', Time.now - 1.hour).de... | true |
f8886b97c6a5fbbee257c5b1350d7511ed6ed5e1 | Ruby | suzuki211/ruby | /numeric.rb | UTF-8 | 64 | 2.796875 | 3 | [] | no_license | puts 1100
puts 100+3
puts 100-3
puts 100*3
puts 100/3
puts 100%3 | true |
f3c69c2a139c5a5b233d9f498de61f780acfb845 | Ruby | bnix/pdf417-rb | /lib/pdf417/text_compactor.rb | UTF-8 | 3,561 | 3.078125 | 3 | [] | no_license | module PDF417
class TextCompactor
PAD_CODEPOINT = 29
SUBMODE_UPPER = 'UPP'
SUBMODE_LOWER = 'LOW'
SUBMODE_MIXED = 'MIX'
SUBMODE_PUNCT = 'PUN'
# Generate mappings of PDF417 submode codepoints to ASCII characters
CODEPOINTS = {
SUBMODE_UPPER => "ABCDEFGHIJKLMNOPQRSTUVWXYZ\s",
SUB... | true |
4b19ec08c8f2ee48ae7019a6b5c1334865a34c04 | Ruby | ilyakogan/tahanot | /ruby-website/app/models/stop.rb | UTF-8 | 794 | 2.546875 | 3 | [] | no_license | class Stop < ActiveRecord::Base
include HasAddress
self.primary_key = "stop_code"
has_many :stop_times, primary_key: "stop_id"
has_many :trips, through: :stop_times
after_find { |stop| stop.fill_address }
def self.find_last_in_trip(trip_id)
joins(:trips).where(stop_times: {trip_id: trip_id}).order("stop... | true |
619049d20e7af343479cf95ebf3e6f514d6c7521 | Ruby | ajengs/kolla-go-food | /spec/models/voucher_spec.rb | UTF-8 | 4,268 | 2.65625 | 3 | [] | no_license | require 'rails_helper'
describe Voucher do
it 'has a valid factory' do
expect(build(:voucher)).to be_valid
end
it 'is valid with code, amount, unit, valid_from, valid_through, max_amount' do
expect(build(:voucher)).to be_valid
end
it 'is invalid without a code' do
voucher = build(:voucher, code... | true |
95c80c5499522ff162434136f69d1925169c4cd2 | Ruby | Phabibi/Agile | /app/models/player.rb | UTF-8 | 1,200 | 2.703125 | 3 | [] | no_license | require 'bcrypt'
class Player < ApplicationRecord
attr_accessor :remember_token
# Territory records will be cleared with the respective player.
has_many :territory, dependent: :destroy
# Attribute restrictions before saving to database.
validates :first_name, presence: true
validates :last_name, presence... | true |
f73cc6c56d782bdd80d3aa059d57ee3c5e1a81ed | Ruby | el-mark/ruby_course | /oop/authenticator.rb | UTF-8 | 859 | 3.546875 | 4 | [] | no_license | require 'bcrypt'
class User
attr_accessor :name, :email, :password
def initialize(name, email, password)
@name = name
@email = email
@password = set_password(password)
end
def set_password(password)
BCrypt::Password.create(password)
end
def get_password
... | true |
32ac778735a752cabeaefd602ff2a66db9c8863d | Ruby | debzow/ruby_exercices_week_0 | /exo_17.rb | UTF-8 | 405 | 3.390625 | 3 | [] | no_license | currentYear = Time.now.strftime("%Y").to_i
puts "Donnes moi ton année de naissance !!!!"
print ">"
userBirthYear = gets.chomp.to_i
y = userBirthYear
while (y <= currentYear) do
puts "Il y a #{currentYear-y} ans, tu avais #{y-userBirthYear} ans .."
puts "Et! Il y a #{currentYear-y} tu avais la moitié de l'age ... | true |
c22bf2ffafb1df8f946dd82e022d28596f723601 | Ruby | iwaseasahi/design_pattern_with_ruby | /Proxy/printer_proxy.rb | UTF-8 | 432 | 2.9375 | 3 | [] | no_license | require_relative 'printable'
require_relative 'printer'
class PrinterProxy < Printable
def initialize(name)
@name = name
@real = nil
end
def set_printer_name(name)
@real.set_print_name(name) unless @real.nil?
@name = name
end
def get_printer_name
@name
end
def print_out(string)
... | true |
edecf4b06d3b2bf49d4ddb8a757bac5fa7439378 | Ruby | anfurion/tn-ruby | /oop/validation.rb | UTF-8 | 1,438 | 2.765625 | 3 | [] | no_license | # frozen_string_literal: true
module Validation
def self.included(base)
base.extend ClassMethods
base.include InstanceMethods
end
module ClassMethods
attr_reader :validations
def validate(attr_name, check, options = nil)
@validations ||= []
@validations << { attr_name: attr_name, ch... | true |
0ff4fd090535e10664d264124a9efb866a45ffae | Ruby | weyewe/parking | /app/models/price_rule.rb | UTF-8 | 3,365 | 2.53125 | 3 | [] | no_license | class PriceRule < ActiveRecord::Base
validates_presence_of :price , :vehicle_case # , :is_base_price
validate :valid_vehicle_case
validate :no_overlap_for_non_base_rule
validate :hour_must_present_if_non_base_case
validate :valid_price
def valid_vehicle_case
return if not vehicle_ca... | true |
384dab749a2ef37215eb11459bc98cf8b2f197ac | Ruby | endoflife-date/endoflife.date | /_plugins/end-of-life-filters.rb | UTF-8 | 4,401 | 2.921875 | 3 | [
"MIT",
"CC-BY-SA-3.0",
"CC-BY-SA-4.0"
] | permissive | require 'nokogiri'
# Various custom filters used by endoflife.date.
#
# All the filters has been gathered in the same module to avoid module name clashing
# (see https://github.com/endoflife-date/endoflife.date/issues/2074).
module EndOfLifeFilter
# Enables Liquid templating in front-matter.
# See https://fettblo... | true |
9e8ed6d71f8ac73d9d4870ece6f5a930a6bfc635 | Ruby | davidrf/curriculum | /lessons/sum-of-integers/examples/002/sum_of_integers.rb | UTF-8 | 109 | 3.15625 | 3 | [] | no_license | def sum(file_path)
numbers = File.read(file_path).split
numbers.inject(0) { |sum, n| sum += n.to_i }
end
| true |
672d8382742c404f72867298f3c98fac555136a4 | Ruby | FelipeUrtubia/desafio_objeto_3 | /ejer-5.rb | UTF-8 | 1,404 | 4.4375 | 4 | [] | no_license | # Agregar un método de instancia llámado lados en ambas clases. El método debe imprimir un string con las medidas de los lados.
# Crear un método llamado perimetro que reciba dos argumentos (lados) y devuelva el perímetro.
# Crear un método llamado area que reciba dos argumentos (lados) y devuelva el área.Instanciar un... | true |
8bdd13c9094afdcea25ba221e4f69a8ff3c79ab7 | Ruby | jmc27/TeachBack | /app/models/sentiment_manager.rb | UTF-8 | 700 | 2.65625 | 3 | [] | no_license | class sentiment_manager
def self.getAvailableSentiments(lecture)
[:engaged, :confused]
end
def SM.recordSentiment(u_id, timestamp, lecture_sentiment_id)
SentimentRecord.create(u, t, lecture_sentiment_id)
end
def SM.getSentHist(lecture, from_t, to_t, int)
# database work to look records in sentiment_history... | true |
9ab5974db94c9c52a325dfe4f4608e5666908e4c | Ruby | seblindberg/texico | /lib/texico/cli/command/init.rb | UTF-8 | 3,757 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'tty-tree'
module Texico
module CLI
module Command
class Init < Base
def run
# Show welcome text
welcome
# As for configuration options for this session
config = ask_config
# Indicate that the config was accepted
prompt.say "#{ICON... | true |
c572e512c0451e8c690a6bff482efe8d29df685a | Ruby | parisestmagique/Exercices_du_vendredi | /exo_20.rb | UTF-8 | 113 | 3.046875 | 3 | [] | no_license | print "Combien d'étage voulez-vous ?"
n = gets.chomp.to_i
a = 0
b = ' '
n.times do puts b = b + "#"
a +=1
end
| true |
53e3fb1c69a47e566224c352119e941af3c65a01 | Ruby | yiweihuang/Keyword-Cloud | /services/kmap_to_discussion.rb | UTF-8 | 765 | 2.640625 | 3 | [] | no_license | require 'csv'
# require 'json'
class KmapToDiscussion
def self.call(course_id:, chapter_id:, tfidf:)
kmap_info = Hash.new
kmap_point = JSON.parse(tfidf).keys
db = Mysql2::Client.new(host: ENV['HOSTNAME'], username: ENV['USERNAME'],
password: ENV['PASSWORD'], database: ENV['DAT... | true |
0a9c18836490ab63fa10c3335200a04fac21bdc1 | Ruby | geoiq/geojoin-ruby | /fuzzy/example/spell.rb | UTF-8 | 672 | 3.015625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/ruby
$LOAD_PATH.push '..'
require 'fuzzymatch'
if ARGV.empty?
puts "Usage: spell.rb [<dictionary>] <word>"
exit
elsif ARGV.length == 1
dictionary = "/usr/share/dict/words"
lookup = ARGV[0]
lookup = 'café'
else
dictionary, lookup = ARGV[0..1]
end
idx = Fuzzymatch::Index.new()
line = 0
File.ne... | true |
9303b7cb4b65eb36f0e2db3c3158d4e34aead9d6 | Ruby | GAierken/programming-univbasics-4-crud-lab-dumbo-web-102819 | /lib/array_crud.rb | UTF-8 | 1,226 | 3.609375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def create_an_empty_array
[]
end
def create_an_array
toddler_toys=["crayons","playdoh","train","bear"]
end
def add_element_to_end_of_array(array, element)
toddler_toys=["crayons","playdoh","train","bear"]
toddler_toys<<"arrays!"
p toddler_toys
end
def add_element_to_start_of_array(array, element)
toddler_toys=... | true |
54af0564bca950e26eaa64b277bc1ea3e918de5d | Ruby | plutokid/if | /lib/if/repl.rb | UTF-8 | 1,687 | 3.09375 | 3 | [] | no_license | require "if"
module IF
class REPL
attr_reader :story
def initialize(config={}, &block)
@input = config[:input] || STDIN
@output = config[:output] || STDOUT
if config[:file]
@story = IF::Story.load config[:file], config
elsif block
@story = IF::St... | true |
afad0ddb7b1a1eab3a1f44fcb047822faee05fab | Ruby | rajat-11223/aprroveforme | /app/services/payment_gateway/set_default_card.rb | UTF-8 | 389 | 2.546875 | 3 | [] | no_license | module PaymentGateway
class SetDefaultCard
def initialize(user)
@user = user
end
def call(token:)
customer = user.payment_customer
raise "Don't have a customer" unless customer.present?
raise "Didn't provide token" unless token.present?
customer.default_source = token
... | true |
9c1564d34eac39a092d5dc5c4a45a97449ad9117 | Ruby | maksar/equation_builder | /lib/equation_builder.rb | UTF-8 | 1,753 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class EquationBuilder
def initialize _numbers, _result, _operators
@numbers = _numbers
@result = _result
@operators = Array(_operators)
@matcher = proc { |numbers, operators, result| numbers.zip(operators).flatten.join if eval(make_float(numbers).zip(operators).flatten.join) == result }
end
de... | true |
39d4d1aecb86a00e4824262eadb83763560e2bd0 | Ruby | bguest/blinky | /spec/models/sign_spec.rb | UTF-8 | 4,593 | 2.8125 | 3 | [] | no_license | # == Schema Information
#
# Table name: signs
#
# id :integer not null, primary key
# phrase :text
# letter_order :text
# created_at :datetime
# updated_at :datetime
# effects :integer
# color :string(255)
# background_color :string(255)
# fa... | true |
650602cc4147a187592591bcc66be4f219fdb74d | Ruby | arosswilson/auction | /app/models/item.rb | UTF-8 | 423 | 2.703125 | 3 | [
"MIT"
] | permissive | class Item < ActiveRecord::Base
# Remember to create a migration!
belongs_to :user
has_many :bids
def list_of_winning_items(array_of_items, user)
items_won = []
array_of_items.each do |item|
if item.stop < Time.now
item.winning_bidder_id = item.bids.order(:amount).last.user_id
if ... | true |
e12068e3266fc972fc7953204bb895eecc0b1f55 | Ruby | RSchaubeck/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 1,479 | 3.109375 | 3 | [] | no_license | module Players
class Computer < Player
def move(board)
if start(board)
start(board)
elsif block_or_win(board)
block_or_win(board)
else
corners_and_sides(board)
end
end
def start(board)
board.taken?(5) ? false : "5"
end
def block_or_win(board)... | true |
0983168ceb1c56c68f1e61e23523dc7915fc14dc | Ruby | dvberkel/letter-soup | /adjacency.rb | UTF-8 | 896 | 3.03125 | 3 | [] | no_license | #! /usr/bin/env ruby
def in_agreement(word, candidate)
word_letters = word.split("")
for first_index in (0..(word_letters.length-2)) do
first = word_letters[first_index]
for second_index in (first_index .. (word_letters.length-1)) do
second = word_letters[second_index]
if (first != second) then... | true |
367c0c12f88402ca08c3277c67ab95d0757e3efd | Ruby | kthatoto/automanation | /resources/object_list.rb | UTF-8 | 487 | 3.21875 | 3 | [] | no_license | class ObjectList
def initialize
@objects = {}
end
def [](key)
@objects[key]
end
def all_objects
@objects.map{|_, objects| objects}.flatten
end
def push(key, object)
raise unless Object === object
@objects[key] = @objects[key].to_a << object
end
def clear(key)
@objects[key] = []... | true |
e4da4a4524e4e1c550456b8c94be1134dca886f3 | Ruby | dipto0321/datastructures-and-algorithm | /ruby/learneroo/Sorting_Challeneges/find_duplicates.rb | UTF-8 | 297 | 3.25 | 3 | [] | no_license | def do_stuff(ar1, ar2)
ar1.each do |el|
ar2.delete_at(ar2.index(el))
end
puts ar2.sort.join(" ")
end
t = gets.to_i
inputs = []
(1..t).each do |_i|
n1 = gets
ar1 = gets.strip.split.map(&:to_i)
n2 = gets
ar2 = gets.strip.split.map(&:to_i)
do_stuff(ar1, ar2)
end
| true |
901a79cd3ae652b30b955a70f9ef3ae7d8e3f81f | Ruby | wangjoc/betsy | /app/helpers/application_helper.rb | UTF-8 | 773 | 2.90625 | 3 | [] | no_license | module ApplicationHelper
def render_rating(rating)
rating = rating.to_i
filled_star = '<i class="fas fa-star"></i>'
empty_star = '<i class="far fa-star"></i>'
# make a list of all the filled stars
star_list = []
until rating == 0
star_list << filled_star
rating -= 1
... | true |
1e9a241be7383f95b0d71dbe3280950a8cd8ba50 | Ruby | warcraft23/RubyExp | /exp6/until.rb | UTF-8 | 247 | 2.96875 | 3 | [] | no_license | #!/usr/bin/ruby
$i=0
$num=3
puts "begin until"
until $i==$num do
puts ("inside loop(until) i = #$i")
$i +=1
end
puts "end until"
$i=0
puts "begin do until"
begin
puts ("inside loop(until) i = #$i")
$i +=1
end until $i==$num
puts "end do until" | true |
c7c2061d8ab4a56b13386e422d808113a250098a | Ruby | Soleone/chat-server | /lib/chat-server/room.rb | UTF-8 | 197 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Chat
class Room < EM::Channel
attr_accessor :log
def initialize
@log = []
super
end
def say(msg)
@log << msg
push(msg)
end
end
end | true |
9bbb0aa5c485728feb95a5ee1f8398bcec2bdb30 | Ruby | peter-miklos/mercury-5 | /api/lib/omniauth/facebook.rb | UTF-8 | 1,642 | 2.515625 | 3 | [] | no_license | require 'httparty'
require_relative './response_error'
module Omniauth
class Facebook
include HTTParty
base_uri "https://graph.facebook.com/v2.9"
def self.authenticate(access_token)
provider = self.new
user_info = provider.get_user_profile(access_token)
return user_info
end
d... | true |
22800e14e602345589303ca87b967eba59c5ff21 | Ruby | southbambird/sandbox | /ruby/minitsuku/clever_print.rb | UTF-8 | 716 | 3.5 | 4 | [] | no_license | # coding: utf-8
def clever_print(*args)
args.each do |item|
case item
when Array
item.each do |value|
print value, " "
end
when Hash
item.each do |key, value|
print key, " ", value, " "
end
when String
print item, " "
end
end
print "\n"
end
=begi... | true |
be26c210df5fac508f463e926c744024808dce72 | Ruby | guiman/adventofcode | /mining_elf/lib/checker.rb | UTF-8 | 289 | 2.984375 | 3 | [] | no_license | require 'digest'
class Checker
TEMPLATE = "%{key}%{number}"
def initialize(key)
@key = key
end
def match?(number)
test = TEMPLATE % { number: number, key: @key }
if Digest::MD5.hexdigest(test).to_s[0..5] == "000000"
number
else
nil
end
end
end
| true |
6f9cb5b1b282d0e962e08f60ac0326330315f3d4 | Ruby | Phitherek/repoto | /memo.rb | UTF-8 | 902 | 2.578125 | 3 | [] | no_license | require 'yaml'
require 'singleton'
module Repoto
class Memo
include Singleton
def initialize
reload
end
def reload
if File.exists?("memodata.yml")
@memodata = YAML.load_file("memodata.yml")
else
@memodata = {}
... | true |
412839765d172248fe4ff4c32b4c4bb500e0a886 | Ruby | marat00/Ruby-Code | /threads.cgi | UTF-8 | 1,114 | 3.34375 | 3 | [] | no_license | #!/usr/local/bin/ruby
# Name: Marat Pernabekov
# CRN: 73157
# Assignment: Lab 5
# File: threads.cgi
# encoding: utf-8
$:.unshift(File.dirname(__FILE__))
# Boilerplate
require 'cgi_helper.rb'
include CGI_Helper
require 'cgi'
cgi = CGI.new('html4')
http_header
# End of boilerplate
# Create an array of alphabetical cha... | true |
8661330f2eacea1c1d3ca655c1da9cab1367b5db | Ruby | logoso321/ruby-testing | /02_calculator/calculator.rb | UTF-8 | 131 | 3.578125 | 4 | [] | no_license | def add(x,y)
x + y
end
def subtract(x,y)
x - y
end
def sum(num)
total = 0
num.each do |x|
total += x
end
return total
end | true |
2dacbe0c73e747e5342569f39bab3862322b5dc3 | Ruby | dommichalec/launch_school | /testing/car.rb | UTF-8 | 159 | 3.109375 | 3 | [] | no_license | # Car class
class Car
attr_accessor :model
attr_reader :wheels
def initialize
@wheels = 4
end
def ==(other)
model == other.model
end
end
| true |
1faf497efb5ee63450a8351d3131e5244453ac65 | Ruby | matthewbussa/netrepobuilder | /appveyor.rb | UTF-8 | 2,138 | 2.640625 | 3 | [] | no_license | require 'json'
require 'net/http'
require 'net/https'
require 'json'
require 'uri'
class AppVeyor
def initialize(project_url, build_path, email)
@project_url = project_url
@build_path = build_path.to_s.empty? ? '.' : build_path
@email = email
@api_token = ENV['APPVEYOR_API_KEY']
@base_url = 'ht... | true |
98e7d60b829e173330c4b1d747e739309c81ae1b | Ruby | TahirKalim/Learn_Ruby_with_Boris | /string/bangmethod.rb | UTF-8 | 127 | 2.796875 | 3 | [] | no_license | word = "hello"
word.capitalize!
p word
word.upcase!
p word
word.downcase!
p word
word.reserve!
p word
word.swapcase!
p word
| true |
49b42e08a3ed9d2feaa619e757cba6a5f1f1e1fb | Ruby | coopdevs/katuma_reports | /app/models/measurement_unit.rb | UTF-8 | 1,147 | 3.140625 | 3 | [] | no_license | # This class replicates the logic contained in OFN's
# app/assets/javascripts/admin/products/services/variant_unit_manager.js.coffee
#
# It goes one step further and by decoupling from variant and product it builds
# and abstraction of a measurement unit. For weight and volume only.
class MeasurementUnit
class Error ... | true |
557c69395e484f1f04d334acfe13f5d32c3c8399 | Ruby | onlyskin/ruby-ttt | /lib/board.rb | UTF-8 | 1,503 | 3.390625 | 3 | [] | no_license | class Board
MARKERS = %w[O X]
attr_reader :cells
def initialize(cells: :no_cells_passed, size: 3)
if cells == :no_cells_passed
@cells = ['-'] * size * size
else
@cells = cells
end
@paths = paths(size)
end
def available_moves
@cells.map
.with_index(1) { |cell, i| ce... | true |
a1e7080830bb92c971c4bf99535fd3bca6d667ed | Ruby | BBerastegui/foo | /wdg.rb | UTF-8 | 1,366 | 3.046875 | 3 | [] | no_license | require 'socket'
require 'digest/sha1'
def init()
receivefile()
end
def receivefile()
# Server starts
server = TCPServer.new("localhost", 2000)
puts "Server running..."
# Run 4ever
loop do
Thread.start(server.accept) do |client|
# Notify the client that party is going to start
client.puts "[/!\\] Hi. Reading..."
... | true |
05346943b924df140ecc669f40bef99796a0227a | Ruby | henryCraig/the-pokemans-clone | /pokemonClone/lib/pokeapi.rb | UTF-8 | 164 | 2.59375 | 3 | [] | no_license | require 'poke-api-v2'
(1..151).each do |n|
poke = PokeApi.get(pokemon: n)
puts poke.name
puts poke.id
puts poke.types[0].type.name
puts n
end | true |
8db2016f0699478e815b1bf53c58e39c007747e2 | Ruby | cristianames92/Portal | /script/lib/build_time_profiler.rb | UTF-8 | 2,815 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'ostruct'
require_relative 'build_time_log_parser'
class BuildTimeProfiler
attr_reader :outliers_deviation
attr_reader :warn_threshold
attr_reader :fail_threshold
attr_reader :build_log_file
attr_reader :filter_block
def initialize(outliers_deviation:, warn_threshold:, fail_threshold:, build_log_... | true |
19b9ba2cd369fa590e8465ba47a6d13b8db246c2 | Ruby | AllySco/Wk_4_Dy_1 | /specs/game_specs.rb | UTF-8 | 474 | 2.703125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative '../models/game.rb'
class TestGame < Minitest::Test
def setup
@game1 = Game.new('rock', 'scissors')
@game2 = Game.new('rock', 'paper')
@game3 = Game.new('scissors', 'paper')
@game4 = Game.new('scissors', 'scissors')
@game5 = Game... | true |
1196e94a2fc0ccdab92f61aee438b0d127f28dd9 | Ruby | avv8401/wordpress | /modules/oski/lib/puppet/parser/functions/delete_key_with_value.rb | UTF-8 | 1,301 | 3.203125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# delete_key_with_value.rb
#
module Puppet::Parser::Functions
newfunction(:delete_key_with_value, :type => :rvalue, :doc => <<-EOS
When passed a hash table, and a match string/regex/boolean (or an array of),
this function will delete any key-value pairs it matches against.
EOS
) do |arguments|
if argumen... | true |
cca786bce38fb7080d9fd5f356c0ed362ec2a4f5 | Ruby | dotslash/dotslash.github.io | /_plugins/converters.rb | UTF-8 | 1,228 | 2.515625 | 3 | [
"MIT"
] | permissive | # https://github.com/txt2tags/plugins
# by Aurelio Jargas, MIT Licensed
# Instructions:
# Save this file inside the _plugins folder for your Jekyll site
module Jekyll
class Txt2tagsConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /^\.t2t$/i
end
def output_ext(ext)
".html"
end... | true |
3005b408ac8a53911419d915e27c2ee03cc6e878 | Ruby | lukehorak/coolMathGamesRuby | /Match.rb | UTF-8 | 1,260 | 4.28125 | 4 | [] | no_license | require './Player'
require './Problem'
require './Round'
class Match
def initialize
p1 = new_player 1
p2 = new_player 2
@players = [p1, p2]
@problems = [
Problem.new("1 + 2", 3),
Problem.new("3 * 4", 12),
Problem.new("12 - 7", 5),
Problem.new("47 + 3", 50),
Problem... | true |
283a7a78aad59f090942787c84b7a13e61c2797a | Ruby | INOS-soft/knuckles | /lib/knuckles/active/hydrator.rb | UTF-8 | 2,068 | 2.96875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Knuckles
module Active
# The active hydrator converts minimal objects in a prepared collection
# into fully "hydrated" versions of the same record. For example, the
# initial `model` may only have the `id` and `updated_at` timestamp
# selected, which is ideal for ... | true |
12ea23bfe6e191efe6e25b134ece5ace4cb895bf | Ruby | waleritf/riq | /app/services/meta_extractor.rb | UTF-8 | 520 | 2.65625 | 3 | [] | no_license | require 'taglib'
class MetaExtractor
attr_reader :track_file
def initialize(track_file)
@track_file = track_file
end
def perform
TagLib::FileRef.open(track_file) do |fileref|
unless fileref.null?
tag = fileref.tag
properties = fileref.audio_properties
{
title:... | true |
16c86f4a071ecbb4ab6c09224cae2301a3471925 | Ruby | artekdrzyzga/BBD | /vendor/bundle/gems/scrypt-3.0.7/lib/scrypt/engine.rb | UTF-8 | 5,745 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require 'ffi'
require 'openssl'
module SCrypt
module Ext
# rubocop:disable Style/SymbolArray
# Bind the external functions
attach_function :sc_calibrate,
[:size_t, :double, :double, :pointer],
:int,
blocking: true
... | true |
74167a39e78ec36f9a8611d746c327cc65ef447f | Ruby | terminalnode/codewars | /ruby/6k-are-they-the-same/comp.rb | UTF-8 | 1,008 | 4.0625 | 4 | [] | no_license | # Are they the "same"?
# https://www.codewars.com/kata/550498447451fbbd7600041c
# Given two arrays of whole numbers, return true if the
# second array is the same as the first array squared
# regardless of order. Otherwise return false.
#
# If either of the arrays are nil, return false.
def comp(a1, a2)
return false... | true |
fdfc29ab7df3cd6522e7586e6f32dfe3d446fe40 | Ruby | Kartstig/nfl_draft | /app/models/player.rb | UTF-8 | 315 | 2.546875 | 3 | [] | no_license | class Player < ActiveRecord::Base
# Relations
has_one :draft
has_one :team, through: :draft
# Validations
validates_presence_of :name
#validates_uniqueness_of :name
def self.available
players = Player.all.delete_if { |p| p if p.team }
if players
return players
else
return false
end
end
end
| true |
cdb54993b8f2be38e54680d7671c50f64c80b31e | Ruby | Universe-Man/cartoon-collections-prework | /cartoon_collections.rb | UTF-8 | 636 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)
numberedDwarves = []
i = 0
until i == dwarves.length
numberedDwarves.push("#{i + 1}. #{dwarves[i]}")
i += 1
end
puts numberedDwarves
end
def summon_captain_planet(planeteer_calls)
planeteer_calls.collect do |call|
call.capitalize + "!"
end
end
def long_planetee... | true |
a64264864478913399a57e5b103ee35961db8133 | Ruby | webdestroya/uci-scheduler | /lib/modules/possible_schedule.rb | UTF-8 | 3,919 | 3.046875 | 3 | [] | no_license | class PossibleSchedule
def initialize(search, classes)
@classes = classes
@search = search
end
def ccodes
@ccodes ||= @classes.map(&:ccode)
end
def pretty_ccodes
@pretty_ccodes ||= self.classes.map(&:pretty_ccode)
end
def classes
@classes
end
def teachers
@teachers ||= @cl... | true |
4499ab4a108f2b3d5dbcdc08777e9c8ab68e5c30 | Ruby | albertbahia/wdi_june_2014 | /w02/d05/ASSIGNMENT_FILES/morning_ex/lib/rejector.rb | UTF-8 | 364 | 3.375 | 3 | [] | no_license | def rejector(array_of_values)
array_of_values.reject{ |string| string.to_i % 2 == 1 }
.map { |string| string.to_i}
.reduce(:+)
end
def rejector(array_of_values)
array_of_values.reject { |string| string.to_i.odd? }
.reduce(0) { |sum, n| sum + n.to_i }
end
# def rejector(array)
# array.map {|num| num.to_i.e... | true |
bc83668f8a270ea3f1e8658d27b43cf1dd75207e | Ruby | NaokiOouchi/ruby-cherry | /section4/until.rb | UTF-8 | 85 | 2.921875 | 3 | [] | no_license | a = [10, 20, 30, 40, 50]
until a.size <= 3
a.delete_at(-1)
end
a # => [10, 20, 30]
| true |
f32ab417c8edf46ae2947d0235e560c6bcc6aa5a | Ruby | JeffreyCheng92/appacademy_prep | /prep work/week 2/day 5/bubble_sort.rb | UTF-8 | 382 | 3.390625 | 3 | [] | no_license | def bubble_sort(array = [])
sorted = false
until sorted
sorted = true
array.each_index do |idx|
next if idx == array.length - 1
if array[idx] > array[idx + 1]
array[idx], array[idx + 1] = array[idx + 1], array[idx]
sorted = false
end
end
end
array
end
if __FILE__ == $PROGRAM_NAME
... | true |
413603ef215420e0b28bf19589760d958bdc8598 | Ruby | JeremyOttley/ruby-learn | /calculate | UTF-8 | 612 | 4.1875 | 4 | [] | no_license | #!/usr/bin/env ruby
def calculate
prompt = <<EOF
Please type in the math operation you would like to complete:
+ for addition
- for subtraction
* for multiplication
/ for division
EOF
puts prompt
operation = gets.chomp
puts "Enter your first number: "
number_1 = gets.chomp.to_i
puts "Enter your second number "
numb... | true |
1e67080a6003b229ab8a264bb917f8e7b258c573 | Ruby | Joseph-Burke/Icebreaker | /lib/program.rb | UTF-8 | 2,316 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
require_relative '../lib/string'
require_relative '../lib/webpage'
require_relative '../lib/printable'
class Program
include Printable
attr_accessor :current_page, :active
def initialize
@current_page = nil
@active = true
end
def display_content
page = curre... | true |
1cd0a7915db067255019cc759190886fad95e30b | Ruby | damianp63/kolejka_ruby | /queue.rb | UTF-8 | 1,135 | 3.28125 | 3 | [] | no_license | #require 'rspec/autorun'
class Queue
def initialize(tab=[])
@table=tab
end
def push(object)
@table.push(object)
end
def pop
@table.pop(@table.size-1)
end
def size
@table.size
end
def to_s
@table
end
def process(activity)
@table.each do |i|
i.activity
end
end... | true |
7abccb61b432783119e908a88a54f5d032861ab6 | Ruby | Mancini1/coursework | /w01d02/classes/bananashop.rb | UTF-8 | 586 | 2.9375 | 3 | [] | no_license | class BananaShop
attr_accessor :name, :opened_in, :staff
attr_reader :current_balance
def initialize name, opened_in
@name = name
@opened_in = opened_in
@staff = []
@current_balance = 0.0
end
def buy_banana
@current_balance = @current_balance + 0.10
end
# set name
# def set_name new_name
# @na... | true |
3dc010c29b71e1c399dd85be7879a83eb844f511 | Ruby | taggartj1985/Cinema | /models/screening.rb | UTF-8 | 1,726 | 3.25 | 3 | [] | no_license | #new class will need CRUD will need time and film_id also may need tickets! starting tickets
# with zero tickets sold and maybe a capcity limit.
# don't forget to add it into sql as a table will need to drop before films
# if its using its ID. IF you get screening done can add snacks as new table/class
require_relative... | true |
3d41af76ba01716641bfdcbe175abe0812b71317 | Ruby | codewithirene567/debugging-with-pry-onl01-seng-ft-050420 | /lib/pry_debugging.rb | UTF-8 | 53 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
num + 2
num
return (num + 2)
end | true |
53303e9e8d2b29ebe10b3ea366d6c618d7996d89 | Ruby | AlejandroFrndz/PDOO | /Civitas_Ruby/lib/casilla_calle.rb | UTF-8 | 981 | 2.65625 | 3 | [] | no_license | require_relative "titulo_propiedad.rb"
require_relative "sorpresa.rb"
require_relative "mazo_sorpresas"
module Civitas
class Casilla_Calle < Casilla
attr_reader :tituloPropiedad
def initialize (titulo)
super(titulo.nombre)
@tituloPropiedad = titulo
@importe = titulo.precioCompra
en... | true |
d051e49903e63b9a5aa23d32985dd385e97979e4 | Ruby | UltimateCoder00/Codility-Challenges | /spec/Lesson 4 Counting Elements/MissingInteger/missing_integer_spec.rb | UTF-8 | 2,908 | 3.40625 | 3 | [
"MIT"
] | permissive | require "./lib/Lesson 4 Counting Elements/MissingInteger/missing_integer"
describe 'MissingInteger' do
describe 'Example Tests' do
it 'example (without minus) - [1, 3, 6, 4, 1, 2] to 5' do
expect(missing_integer([1, 3, 6, 4, 1, 2])).to eq 5
end
end
describe 'Correctness Tests' do
context 'extr... | true |
bdffae801672d0e3bc6299ae38ee5dd50c8cddbc | Ruby | BenRKarl/WDI_work | /w03/d03/Rebecca_Strong/morning/caws/app.rb | UTF-8 | 1,076 | 2.59375 | 3 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'models/user'
require_relative 'models/caw'
require_relative 'config.rb'
#index
get '/' do
@users = User.all
erb :index
end
# new
get '/users' do
@users = User.all
erb :index
end
get '/users/new' do
erb :'users/new'
end
#create
post'/users' do
usernam... | true |
26e88cab0106aed7b7119d1eef3af74d4102e61d | Ruby | jordanpoulton/ruby_kickstart | /session2/1-notes/18-class-instance-variables.rb | UTF-8 | 1,264 | 4.1875 | 4 | [
"MIT"
] | permissive | # Lets say we wanted to know what planet people are from.
# Well, that information is the same across every person
# so we can keep it in an instance variable on the class.
class Person
# When we define methods here, they get defined for
# instances of Person, so we need to either store
# them in Person's class ... | true |
e3edded5ee94d9f3ae1554e1f614d40f36e98565 | Ruby | itggot-ida-franzen-karlsson/standard-biblioteket | /lib/is_negative.rb | UTF-8 | 164 | 3.15625 | 3 | [] | no_license | # tar ett heltal som input och avgör om talet är negativt
def is_negative(n)
is_neg = false
if n < 0
is_neg = true
end
return is_neg
end
| true |
2b26a369952f0bef22762f56964d3d57fb3d6d7b | Ruby | kkuivenhoven/kjvVerseCount | /lib/verse_count.rb | UTF-8 | 1,396 | 3.453125 | 3 | [] | no_license | require 'csv'
require 'open-uri'
class KjvVerseCount
@wholeBible = Hash.new
def initialize(name, chapter, verseTotal)
@name = name
@chapter = chapter
@verseTotal = verseTotal
end
def self.init
puts "inside init"
@wholeBible = Hash.new
CSV.new(open("https://raw.githubusercontent.com/kkuivenhoven/kjvVe... | true |
d8bafef7ce90652974b766a72627de298f571054 | Ruby | Apollo50/testGuru | /app/services/badge_service.rb | UTF-8 | 1,415 | 2.53125 | 3 | [] | no_license | class BadgeService
def initialize(test_passage)
@test_passage = test_passage
end
def check_rule
return unless Badge.exists?
Badge.all.each do |badge|
add_badge_to_user(badge) if self.send("#{badge.rule_name}_rule", badge)
end
end
private
def add_badge_to_user(badge)
@test_pass... | true |
f0f6be7e4ad631c80624fb39afdac4bac86ac813 | Ruby | dunphyben/to-do-list-refactored | /lib/to_do_lists.rb | UTF-8 | 3,169 | 3.734375 | 4 | [] | no_license | require './lib/to_do'
require './lib/list_class'
def main_menu
puts "\nPress 'n' to create a new list"
puts "Press 'v' to view all of your to-do lists"
puts "Press 'ex' to exit"
main_choice = gets.chomp
if main_choice == 'n'
new_list
elsif main_choice == 'v'
view_lists
elsif main_choice == 'ex... | true |
19be116c5e46162e1cedba50a0a4cec35a348798 | Ruby | frsyuki/fluentd11-old-very-old | /lib/fluentd/config/element.rb | UTF-8 | 3,245 | 2.53125 | 3 | [] | no_license | #
# Fluentd
#
# Copyright (C) 2011-2013 FURUHASHI Sadayuki
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | true |
fce85a6241761327cdfca74435015b90f14cac06 | Ruby | shamsbhuiyan/topfind4 | /topfind4.1/app/models/graph/mapMouseHuman.rb | UTF-8 | 603 | 3.375 | 3 | [] | no_license | #
class MapMouseHuman
def initialize()
@map = []
File.open("databases/paranoid8_many2many.txt").readlines.each do |line|
l = line.split("\t")
@map << {:h => l[0].strip(), :m => l[1].strip()}
end
end
def mouse4human(proteins)
return proteins.collect{|p| m4h(p)}.flatten
end
... | true |
91eecce3d7ddd6013f7cdd773389b61a2a15799c | Ruby | plkujaw/makers-bnb | /lib/booking_received.rb | UTF-8 | 1,814 | 2.78125 | 3 | [] | no_license | class BookingReceived
def self.all(owner_id)
@bookings_received = ActiveRecord::Base.connection.execute("SELECT s.name, s.price, s.description, s.street_address, s.city, s.country, s.postcode, b.id booking_id, b.confirmation, b.booking_start, b.booking_end FROM spaces s INNER JOIN bookings b ON s.id = b.space_id... | true |
d8d790815bf9cfec1c4422001cae1a8ed5545cc9 | Ruby | nBobrov/education_ror | /Lesson_3/accessors.rb | UTF-8 | 1,315 | 3.09375 | 3 | [] | no_license | module Accessors
def attr_accessor_with_history(*attr_names)
attr_names.each do |attr_name|
add_attr_getter(attr_name)
add_attr_setter(attr_name)
end
end
def strong_attr_accessor(attr_name, attr_class)
add_attr_getter(attr_name)
add_attr_setter_strong(attr_name, attr_class)
end
p... | true |
975f8f64df90b1be2d2edfd55ec6384861fbc743 | Ruby | hector2-cloud/my-collect-onl01-seng-pt-012220 | /lib/my_collect.rb | UTF-8 | 119 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(array)
new_array=[]
i=0
while i<array.length
new_array.push(yield array[i])
i += 1
end
new_array
end
| true |
bacf00abe5f4ef24d483f3120df175493d6ea082 | Ruby | koziscool/Ruby-E83 | /e83.rb | UTF-8 | 1,882 | 3.359375 | 3 | [] | no_license |
require './e83_data.rb'
require './graph.rb'
VertexInfo = Struct.new( :key, :min_path_weight, :min_path, :weight ) do
def to_s
"key: #{key} weight: #{weight} min path weight: #{min_path_weight}"
end
def min_path_string
ret_string = "[ "
min_path.each do | point |
ret_string = ret_string + "... | true |
6d99fc92595d92db5c736aa2f9cdbca27f5c484f | Ruby | Atar97/aA-Alpha-Course-completed | /Austin_Cotant_rspec/lib/02_calculator.rb | UTF-8 | 337 | 3.734375 | 4 | [] | no_license | def add(num1, num2)
num1 + num2
end
def subtract(num1, num2)
num1-num2
end
def sum(arr)
ans = 0
arr.each {|el| ans += el}
ans
end
def multiply(num1, num2)
num1*num2
end
def power(num1, num2)
num1**num2
end
def factorial(num)
if num < 1
return 0
end
answer = 1
(1..num).each {|el| answer*=e... | true |
af70f25f28c98f6f583b4a6673d466002846fd74 | Ruby | matpa/ttt-6-position-taken-rb-q-000 | /lib/position_taken.rb | UTF-8 | 306 | 3.65625 | 4 | [] | no_license | # code your #position_taken? method here!
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
def position_taken?(board, int)
if (board[int]==" ") || (board[int]=="")
return false
elsif (board[int]=="X") || (board[int]=="O")
return true
elsif (board[int]==nil)
return false
end
end
| true |
44dfcc408b8f8e43d04ee9b8b1718a81fb2a7000 | Ruby | jcald/dojo | /string_calculator/ruby/lib/string_calculator.rb | UTF-8 | 589 | 3.34375 | 3 | [] | no_license | class StringCalculator
def self.add(str)
params = StringParams.new(str)
params.scan_delimiter!
params.sum_delimited
end
private
class StringParams
def initialize(params)
@params = params
@delimiters = ",\n"
end
def scan_delimiter!
if delimiter = @params[/\[(.*?)... | true |
731cdf4e172de5585ed4468c4db39f6d26348926 | Ruby | AndriyK/timer | /app/helpers/works_helper.rb | UTF-8 | 2,000 | 3.25 | 3 | [] | no_license | module WorksHelper
include RoutinesHelper
# Function return the amount of days in defined month
#
# * *Args* :
# - +date+ date object-> date for which month amount of days is required
# * *Returns* :
# integer amount of days in month
def get_days_in_month date
months = { 1=>31, 2=>(Date.lea... | true |
2052bc302dfc65ea824d67f1d04ead50d64b86cb | Ruby | telegramstudio/mvc-parser | /app.rb | UTF-8 | 450 | 2.546875 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'net/https'
res = ''
# Fetch and parse HTML document
doc = Nokogiri::HTML(open('https://www.avito.ru/ussuriysk/bytovaya_elektronika?p=1', :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE))
doc.css('h3.item-description-title a').each do |link|
link = 'https://ww... | true |
e0dde698d20d76e04f4dbb040c3120d8ecd2e42c | Ruby | datu925/rulecoder | /rulecoder.rb | UTF-8 | 1,940 | 3.28125 | 3 | [] | no_license | #rulecoder
#rule file looks like this:
#target fields, target phrase, outcome label, outcome column, active status
#financial data looks like this:
#some number of data columns with descriptions of the transaction, a transaction amount in final column
#for each line in data,
#for each rule in file,
#ski... | true |
2e205b30d532f87cfebf9a9193f1e552fe362911 | Ruby | jlblcc/mdTranslator | /lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb | UTF-8 | 4,516 | 2.515625 | 3 | [
"Unlicense"
] | permissive | # ISO <<Class>> Polygon
# writer output in XML
# History:
# Stan Smith 2013-11-18 original script.
# Stan Smith 2014-05-30 modified for version 0.5.0
# Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
# Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
# ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.