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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f0dddbf80e4fc731627c14d6828406059713a567 | Ruby | beaucouplus/programming_foundations | /exercises/delete_vowels.rb | UTF-8 | 630 | 4.46875 | 4 | [] | no_license | # Write a method that takes an array of strings, and returns an array of the
# same string values, except with the vowels (a, e, i, o, u) removed.
# define an array of vowels to handle comparison
# select every char from string which isn't a vowel
# return the new string
VOWELS = /[aeiouAEIOU]/
def remove_vowels(arr... | true |
4b81eba5b006c01a114fa81cbcf8e614dd9983b2 | Ruby | barkinet/wistia-doc | /_plugins/indexer.rb | UTF-8 | 2,588 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'nokogiri'
require 'tire'
# Adapted from https://raw.github.com/PascalW/jekyll_indextank/master/indexer.rb &&
# https://github.com/jaysoo/jaysoo.ca/blob/master/_plugins/indexer.rb
module Jekyll
class Indexer < Generator
attr_accessor :site
def initialize(config = {... | true |
0cf21ef4d50c41b5ee84a8643ea7a596f4026c6b | Ruby | saraemanuelsson/properties_lab | /models/property.rb | UTF-8 | 2,128 | 3.09375 | 3 | [] | no_license | require('pg')
class Property
attr_accessor :address, :value, :square_footage, :build
attr_reader :id
def initialize(options)
@id = options['id'].to_i if options['id']
@address = options['address']
@value = options['value']
@square_footage = options['square_footage']
... | true |
7aa295c0f9314572308bac79b1732578b43fe974 | Ruby | Mat24/Curso-Programacion-USC-2014 | /Auditoria-USC/app/controllers/reportes_controller.rb | UTF-8 | 4,525 | 2.578125 | 3 | [] | no_license | require 'prawn/table'
class ReportesController < ApplicationController
before_action :set_reporte, only: [:show, :edit, :update, :destroy]
# GET /reportes
# GET /reportes.json
def index
@reportes = Reporte.all
respond_to do |format|
format.html
format.json
format.csv {send_data @repor... | true |
b8edcc15ed391345172fc5114903f4c54e864764 | Ruby | jwass91/flatiron_labs | /hs-oo-stretch-challenges-lab-precollege-se1-nyda-061515-1-master/lib/path.rb | UTF-8 | 581 | 3.28125 | 3 | [] | no_license | class Path
attr_accessor :path
def initialize(path) # Notice the power of an objects
@path = path # properties. Because the object stores
# the path variable, we no longer need to
# pass it around to all the other methods
# that rely on it.... | true |
9f905a90030416600300228cffa5d868b3d8f3eb | Ruby | DanielOrtegaCar/ManejodeMemoriaVirtual | /ruby/hlTablaPagina.rb | UTF-8 | 851 | 3.203125 | 3 | [] | no_license | #!usr/bin/ruby
load 'EntradaTP.rb'
class TablaPagina
def initialize(cantidad, cantidad_marcos_de_pagina)
@marco_actual = 0
@puntero_LRU = 0
@contador_de_fallos = 0
@cantidad_marcos_disponibles = cantidad_marcos_de_pagina
@tamano = cantidad
@tamano_mp = cantidad_marcos_de_pagina
@entrada = Array.new(can... | true |
8dfcfca96c507380e5519f365b46a04b2de78081 | Ruby | matin/pdf-reader | /lib/pdf/reader/explore.rb | UTF-8 | 3,861 | 2.5625 | 3 | [
"MIT"
] | permissive | ################################################################################
#
# Copyright (C) 2006 Peter J Jones (pjones@pmade.com)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software with... | true |
220ca1d387e453faf0f1ded913d7d38c341dbc07 | Ruby | benjamintillett/airports | /spec/airport_spec.rb | UTF-8 | 3,531 | 3.40625 | 3 | [] | no_license | require 'airport'
require 'plane'
require 'weather_spec'
# A plane currently in the airport can be requested to take off.
#
# No more planes can be added to the airport, if it's full.
# It is up to you how many planes can land in the airport and how that is impermented.
#
# If the airport is full then no planes can l... | true |
1c5e4e84cc36c5fd19806d0fe92f6517f06e0880 | Ruby | sankage/eve.doctrinator | /app/models/doctrine_diff.rb | UTF-8 | 1,171 | 2.53125 | 3 | [] | no_license | class DoctrineDiff
attr_reader :doctrine, :pilots, :fittings
def initialize(doctrine, pilots)
@doctrine = doctrine
@fittings = doctrine.fittings.sort_by { |fit| fit.full_name }
@pilots = pilots
end
def doctrine_name
doctrine.name
end
def fitting_names
fittings.map(&:full_name)
end
... | true |
23a0dcdd3db4bbd9ca3bca7ef50d7643cc245a2e | Ruby | iolloyd/ProjectManager | /projectmanager.rb | UTF-8 | 8,655 | 2.75 | 3 | [] | no_license | #!/usr/bin/ruby
require 'cgi'
require 'cgi/session'
cgi = CGI.new
print cgi.header("type" => "text/html")
def compose(f,g)
lambda{ |x| f(g(x)) }
end
def xtag (kind,title)
"<#{kind}>text</#{kind}>"
end
def htmltag
tags = ['div','p','h1','h2','h3','script']
tags.each do |t|
#{t = lambda { | atts | "<#{t} #... | true |
dcb8d4014d2f962985c40483b594ba1831f5e9a6 | Ruby | manuca/job_board | /models/plan.rb | UTF-8 | 441 | 2.859375 | 3 | [] | no_license | class Plan
POSTS = {
"free" => 5,
"small" => 1,
"medium" => 5,
"large" => 10,
"punchgirls" => 1000
}
PRICING = {
"free" => 0,
"small" => 50,
"medium" => 100,
"large" => 150,
"punchgirls" => 0
}
attr :id
def self.[](id)
new(id)
end
def initialize(id... | true |
a320d13d0d1dad6729adbe4ee6661364d3ec074b | Ruby | alim16/refresher | /selenium/webdriverEx2.rb | UTF-8 | 2,132 | 3.046875 | 3 | [] | no_license | require 'selenium-webdriver'
#tested with firefox v47.0.1
searchText = ARGV[0] #type in something to look for as the first param
requiredLang = ARGV[1] #type in a language e.g svenska as the second param
#incase no args given
if ARGV.empty?
searchText = "FiReFOX"
requiredLang = "Deutsch"
end
#Naviga... | true |
565d34e0ab37541abbe887a153d5f8aedb924b26 | Ruby | lbvf50mobile/til | /20230313_Monday/20230313.rb | UTF-8 | 1,172 | 3.640625 | 4 | [] | no_license | # Leetcode: 101. Symmetric Tree.
# https://leetcode.com/problems/symmetric-tree/
# = = = = = = = = = = = = = =
# Accepted.
# Thanks God, Jesus Christ!
# = = = = = = = = = = = = = =
# Runtime: 83 ms, faster than 76.47% of Ruby online submissions for Symmetric Tree.
# Memory Usage: 211 MB, less than 43.53% of Ruby online... | true |
de7683a7ba501c23af50b2159e3215cabaa34207 | Ruby | Sruthisarav/My-computer-science-journey | /Open App Academy/Software Engineering Foundations/Rspec/rspec_exercise_1/lib/part_1.rb | UTF-8 | 583 | 3.984375 | 4 | [] | no_license | def average(n1, n2)
return (n1 + n2)/2.to_f
end
def average_array(array)
average = array.inject {|acc, ele| acc += ele}
return average/array.length.to_f
end
def repeat(str, n)
new_str = ''
n.times {new_str += str}
return new_str
end
def yell(str)
return str.upcase + '!'
end
def alternati... | true |
abb70e2873b1e85898192c999f249f5dade0dbb8 | Ruby | AnRenYiL/class_notes_and_labs | /day_35_rails_object/animals.rb | UTF-8 | 398 | 3.859375 | 4 | [] | no_license | class Animals
attr_accessor :name, :color
def initialize(name,color)
@name = name
@color = color
end
def eat
puts "I'm eating"
end
def walk
puts "I'm walking"
end
end
class Dog < Animals
def eat
super
puts "Bones are yummy!"
end
... | true |
7a3fc8c17daa0bf02d03deb8fdc2a97000b747ee | Ruby | gitter-badger/vedeu | /test/lib/vedeu/models/buffer_test.rb | UTF-8 | 4,634 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
module Vedeu
describe Buffer do
let(:attributes) {
{
name: '',
back: back,
front: front,
previous: previous,
}
}
let(:back) { {} }
let(:front) { {} }
let(:previous) { {} }
describe '#initialize' do
it... | true |
cd7dc1411a817a2c8276741cc138dbf2a3af72cc | Ruby | dgonca/artistg | /app/helpers/session_helpers.rb | UTF-8 | 353 | 2.625 | 3 | [] | no_license | #sets current user to session[:user_id] from login
def current_user
current_user ||= User.find_by(id: session_user)
end
def session_user
session[:user_id]
end
#checks if session[:user_id] is not nil, which will only happen if someone is logged in
def logged_in?
session_user != nil
end
def authenticate!
redir... | true |
227041423fd90e1555a68dc38e79c7df0e6e67e3 | Ruby | marcelopedras-ufvjm/gestaopatrimonial | /app/models/loan.rb | UTF-8 | 1,575 | 2.625 | 3 | [] | no_license | class Loan < ActiveRecord::Base
belongs_to :user
belongs_to :resource
has_many :resource_histories
validates_presence_of :user, :resource
validate :devolution_forecast_greater_than_start_date,
:end_date_greater_than_start_date,
:start_and_devolution_forecast_must_be_exist_to_loan,
... | true |
b09e02b2b7dade057656af6931f11ff2468b9cb9 | Ruby | smartlyio/logger-metadata | /lib/logger/metadata/formatter.rb | UTF-8 | 1,239 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'thread'
class Logger
module Metadata
module Formatter
def call(severity, timestamp, program_name, message)
timestamp_string = '[' + timestamp.to_s + ']'
formatted_message = "#{faint(timestamp_string)} #{message}#{faint(metadata_text)}"
super(severity, timestamp, program_nam... | true |
9850f9c09fc7b70041364ab8674479b572bbde08 | Ruby | bettymakes/playing_with_lcbo_api | /html_generator.rb | UTF-8 | 2,546 | 3.359375 | 3 | [] | no_license | require 'open-uri'
require 'json'
class HtmlGenerator
# cost to help get clean water to those in need in Africa http://waterwellsforafrica.org/whats-the-cost/
WATER = 3.5
def print_header
puts "<!DOCTYPE html>"
puts "<html>"
puts " <head></head>"
puts " <body>"
end
def print_end
puts " </body>"
... | true |
b8a0b522c7bf1fee0c53b8cef5518371766e1f37 | Ruby | ungsophy/little-mrt | /lib/little-mrt/path.rb | UTF-8 | 926 | 3.046875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module LittleMRT
class Path
attr_reader :adjacencies
def initialize(adjacencies = [])
@adjacencies = adjacencies
end
def add_adjacency(adjacency)
if adjacencies.empty? || last_adjacency.to == adjacency.from
adjacencies << adjacency
else
raise ArgumentError, "Last a... | true |
452e0b86fd39297acba30392c945d5ab8ed22d37 | Ruby | uehara55/fleamarket_sample_37d | /app/models/address.rb | UTF-8 | 1,207 | 2.5625 | 3 | [] | no_license | class Address < ApplicationRecord
belongs_to :user
validates :first_name, presence: true
validates :last_name, presence: true
validates :first_name_kana, presence: true, format: { with: /\A[\p{katakana}\p{blank}ー-]+\z/, message: 'はカタカナで入力してください'}
validates :last_name_kana, presence: true, format: { w... | true |
1b90a028ace5d0c2fb938f5577e1431dce0659d5 | Ruby | eloisecoveny/codeclan_cinema | /console.rb | UTF-8 | 1,473 | 2.734375 | 3 | [] | no_license | require_relative("models/customer")
require_relative("models/film")
require_relative("models/ticket")
require_relative("models/screening")
require("pry")
Ticket.delete_all()
Screening.delete_all()
Customer.delete_all()
Film.delete_all()
film1 = Film.new("title" => "Stalker", "price" => "8")
film1.save()
film2 = Fil... | true |
5117832a52c893854f347614ae735e6a6a400934 | Ruby | gruis/advent2018 | /10_the_stars_align.rb | UTF-8 | 17,705 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
VERBOSE = ARGV.delete('-v')
SKIP = ARGV.delete('-s')
def plot(data)
minx,maxx = data.map(&:first).minmax
miny,maxy = data.map(&:last).minmax
height, width = dimensions(data)
puts "#{width}:#{height} - #{maxx}:#{minx}; "\
"#{maxy}:#{miny}; #{maxx - minx}:#{maxy - miny}"
grid = Ar... | true |
39fd9b1cd0f6ccdf1b21c17b1bfbe982eda2d334 | Ruby | bdb2381/advanced-hashes-hashketball-sea01-seng-ft-071320 | /hashketball.rb | UTF-8 | 8,639 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def game_hash
{
home: {
team_name: "Brooklyn Nets",
colors: ["Black", "White"],
players: [
{
player_name: "Alan Anderson",
number: 0,
shoe: 16,
points: 22,
rebounds: 12,
assists: 12,
steals: 3,
... | true |
9ea7c8566892db4d9fd37a35a7b72e680a71dd80 | Ruby | fifiteen82726/computer-security | /question_abc.rb | UTF-8 | 2,048 | 2.953125 | 3 | [] | no_license | # 128 AES CBC
require 'openssl'
class MyEncryption
def initialize(mode, size)
@run_time_histroy = {}
@mode = mode
@size = size
end
def encryption_then_decrypt(data, file_name)
size = data.size
# Generate key
start_time = Time.now
cipher = OpenSSL::Cipher::AES.new(@size, @mode)
ci... | true |
b084324d83e94f93302e387fb293b7a78d1cb5a0 | Ruby | danielnaranjo/Ruby-Udemy | /guess.rb | UTF-8 | 570 | 3.71875 | 4 | [] | no_license | answer = "Watson\n"
puts("Let's play a guessing game. You get three tries.")
print("What is the name of the computer that played on Jeopardy? ")
response = gets
if response == answer
puts("That's right!")
else
print("Sorry. Guess again (Two tries left): ")
response = gets
if response == answer
puts("That's righ... | true |
b074a61de8245a5a6ff15f4f93f03524f0d91217 | Ruby | sneharpatel/ruby-leetcode-problem-solving | /time_conversion.rb | UTF-8 | 544 | 3.796875 | 4 | [] | no_license | # https://github.com/PaulNoth/hackerrank/tree/master/practice/algorithms/warmup/time_conversion
#
#
def timeConversion(s)
timeArr = s.split(":")
hour = timeArr[0]
min = timeArr[1]
seconds = timeArr[2][0..1]
am_pm = timeArr[2][2..3]
if am_pm == "AM"
if hour == "12"
hour = "00"
end
else
... | true |
7ba84c904bf40cf80f1782fb9ee159405756cfd6 | Ruby | MiraMarshall/TaskList | /test/controllers/tasks_controller_test.rb | UTF-8 | 4,618 | 2.546875 | 3 | [] | no_license | require "test_helper"
require "test_helper"
describe TasksController do
# Note to students: Your Task model **may** be different and
# you may need to modify this.
let (:task) {
Task.create name: "sample task", description: "this is an example for a test",
completion_date: "date"
}
#... | true |
93c37c08956a293ff223019ac8d552efc1a89e6a | Ruby | donbader/DollayTon | /lib/triangle_arbitrage/strategy/base.rb | UTF-8 | 999 | 2.6875 | 3 | [] | no_license | module TriangleArbitrage
module Strategy
class Base
def initialize(base, coin1, coin2)
@base = base
@coin1 = coin1
@coin2 = coin2
@clients = [
Client::Cobinhood.corey,
Client::Max.baimao,
# Client::Binance.instance,
]
end
# ... | true |
8c206761981744e1dd0ca0e8fb4af70a1edd8a69 | Ruby | eventide-project/virtual | /lib/virtual/protocol_method.rb | UTF-8 | 518 | 2.640625 | 3 | [
"MIT"
] | permissive | module Virtual
module ProtocolMethod
Error = Class.new(RuntimeError)
def self.define(target_class, method_name)
method_defined = target_class.method_defined?(method_name, true) ||
target_class.private_method_defined?(method_name, true)
if not method_defined
target_class.send(:def... | true |
a23282e2d5c6a17b55bdbfc11d784241d558c727 | Ruby | edborden/MathFlowsAPI | /app/lib/processed_content.rb | UTF-8 | 975 | 2.65625 | 3 | [] | no_license | module ProcessedContent
def processed_content
if content.blank?
[Snippet.new]
else
EquationExtractor.new(content,try(:styles)).array
end
end
def processed_content_lines element_width
content_lines = []
unused_content = processed_content
until unused_content.empty?
conte... | true |
110f27383f5ab90f432356f92fdabaa506b61de6 | Ruby | jpavioli/ruby-objects-has-many-through-lab-houston-web-career-040119 | /lib/doctor.rb | UTF-8 | 653 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Doctor
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def new_appointment(patient,date)
#given a date and a patient, creates a new appointment
Appointment.new(date,patient,self)
end
def appointments
#returns an array of all apointments sch... | true |
b793edcc5a64eb81a3e0f6c65f029aeaf5e9f6ab | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/rubocop-0.93.1/lib/rubocop/cop/style/class_methods.rb | UTF-8 | 1,439 | 2.625 | 3 | [
"CC-BY-NC-4.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# This cop checks for uses of the class/module name instead of
# self, when defining class/module methods.
#
# @example
# # bad
# class SomeClass
# def SomeClass.class_method
# # ...... | true |
1747bb78ebabe8ac82d1d6b34b00641f40b3515a | Ruby | pathawks/kibana-demo | /random.rb | UTF-8 | 648 | 2.984375 | 3 | [] | no_license | def randomDay
r = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 6, 6].sample
return r * 24 * 60 * 60
end
def randomHour
r = [0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20,... | true |
e13ff717cd6077d41675dad6c3cec97633287c53 | Ruby | brgeen/App-Academy-Ruby-Practice | /advanced_problems/most_vowels.rb | UTF-8 | 481 | 3.796875 | 4 | [] | no_license | def most_vowels(sentence)
vowels = "aeiou"
count = Hash.new(0)
sentence.split.each do |ele|
count[ele] = 0
end
count.each_key do |key|
key.each_char do |char|
if vowels.include?(char)
count[key] += 1
end
end
end
sorted = count.sort_by { |k, v| v }
return sorted[-1][0]
end
... | true |
63c4af7c99e0db2d369f068654c0b72ac6ac0045 | Ruby | MisterDeejay/Poker | /lib/deck.rb | UTF-8 | 837 | 3.921875 | 4 | [] | no_license | require_relative 'card'
class Deck
attr_accessor :ary_of_cards
def initialize
@ary_of_cards = Deck.create_deck
end
def count
ary_of_cards.count
end
def shuffle
ary_of_cards.shuffle!
end
def deal_hand(number = 5)
new_cards = ary_of_cards.take(number)
self.ary_of_cards = ary_of_... | true |
172b86bcbdca4b48dd63c2b0065eb6af3d668bcc | Ruby | ptolemybarnes/baby-steps | /katas/lib/instant_runoff_voting.rb | UTF-8 | 2,078 | 3.65625 | 4 | [] | no_license | # CodeWars Kata: http://www.codewars.com/kata/52996b5c99fdcb5f20000004/train/ruby
# Solution by Ptolemy Barnes.
=begin
Your task is to implement a function that calculates an election winner from a list of
voter selections using an Instant Runoff Voting algorithm:
1) Each voter selects several candidates in order o... | true |
08246b4a3a70bb64a618335729101ee2358b7bb8 | Ruby | bird1204/maoyuan_farm | /app/helpers/carts_helper.rb | UTF-8 | 670 | 2.765625 | 3 | [
"MIT"
] | permissive | module CartsHelper
def hello_message
if current_user
"會員:#{current_user.email.split('@').first} 您好!"
else
"非會員:您是會員嗎?請先登入"
end
end
def cart_message(cart)
"共購買 #{cart.total_unique_items} 項商品 運費共:$#{cart.shipping_cost} 消費總金額:$#{cart.total}"
end
def success_message(cart)
"共購買&... | true |
96e98dbf111054872ea94c1277e3ae0f15ccc97c | Ruby | joshlacey/programming_languages-prework | /programming_languages.rb | UTF-8 | 416 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def reformat_languages(languages)
new_hash = {}
languages.each do |style, list|
list.each do |language, attribute|
new_hash[language]= attribute
new_hash[language][:style] = []
end
end
languages.each do |style, list|
list.each do |language, ... | true |
26c3ace8845c1b34d30394a6996eead7f61f0c70 | Ruby | andrew-black512/tools | /file_with_head.rb | UTF-8 | 873 | 2.984375 | 3 | [] | no_license | #!/usr/bin/ruby
require 'colorize'
require 'open3'
#https://www.honeybadger.io/blog/capturing-stdout-stderr-from-shell-commands-via-ruby/
#---------------------------------------------------------------------
# Semi config
#---------------------------------------------------------------------
def print_indented_text t... | true |
055f1ec14debe1770c2c6488c14546d8aab15a26 | Ruby | Scooterlicious/twendy | /db/seeds.rb | UTF-8 | 1,183 | 2.78125 | 3 | [] | no_license | # ================================
# CREATES COUNTRIES AND ADDS WOEID
# ================================
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_AC... | true |
1aff40b183a65eecaf6a7f2086b219994f3efe16 | Ruby | dmolesUC/xml-mapping_extensions | /example.rb | UTF-8 | 1,159 | 2.828125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'xml/mapping_extensions'
require 'rexml/document'
class MyElem
include ::XML::Mapping
root_element_name 'my_elem'
date_node :plain_date, 'plain_date'
date_node :zulu_date, 'zulu_date', zulu: true
time_node :time, 'time'
uri_node :uri, 'uri'
mime_type_node :mime_type, 'mime_... | true |
202f9304320d5a8239e74e505282eb73c66de74c | Ruby | noda50/practis-dev | /lib/practis/executable.rb | UTF-8 | 697 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'practis'
module Practis
#=== Store current executable.
class ExecutableGroup
include Practis
def initialize
@threads = ThreadGroup.new
end
def exec(*args)
th = Thread.start do
fork_exec(*args)
end
@threads.add... | true |
ce57eef29c01ca4cf427018db22e56ffad51f50a | Ruby | T-Dnzt/Moltin-Ruby-SDK | /lib/moltin/resource.rb | UTF-8 | 1,184 | 2.703125 | 3 | [
"MIT"
] | permissive | module Moltin
class Resource
attr_accessor :config, :storage
def initialize(config, storage)
@config = config
@storage = storage
end
# Public: Retrieve the access_token from storage or from the API
#
# Returns a valid access_token if the credentials were valid
def get_access_... | true |
c7cce8a9e9a500db6fdd76cfa62cd5825bb50e6f | Ruby | katcarr/recipe_box | /spec/recipe_spec.rb | UTF-8 | 1,627 | 2.59375 | 3 | [
"MIT"
] | permissive | require("rspec")
describe(Recipe) do
it { should have_and_belong_to_many(:ingredients) }
it { should have_and_belong_to_many(:categories) }
describe('#update_ingredients') do
it 'adds new, leaves same and deletes old ingredients from a recipe' do
test_recipe = Recipe.new({:title => "Pea Soup", :instru... | true |
f55e0e3012aa22d213bfca232e82f7fc64711902 | Ruby | mohammad523/backend-capstone | /db/seeds.rb | UTF-8 | 1,470 | 2.59375 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
06f52549388c69a061768aaf8684dc40887e3cee | Ruby | timgaleckas/oauth2_provider_engine | /app/models/oauth2_provider/access.rb | UTF-8 | 2,813 | 2.609375 | 3 | [
"MIT"
] | permissive | # Access info related to a resource owner using a specific
# client (block and statistics)
if defined?(Mongoid::Document)
module Oauth2Provider
class Access
include Mongoid::Document
include Mongoid::Timestamps
field :client_uri # client identifier (internal)
fi... | true |
0ff0ac7c41b8776007ae1855e23e538b83dae897 | Ruby | willfowls/prepcourse | /ruby_books/intro_to_ruby/3rd_attempt_at_exercises/61.rb | UTF-8 | 278 | 3.34375 | 3 | [] | no_license | # take array and turn it to new array that consists of strings containing one word
a = ['white snow', 'winter wonderland', 'melting ice',
'slippery sidewalk', 'salted roads', 'white trees']
a = a.map { |pairs| pairs.split }
a = a.flatten
p a
# no check | true |
08a36314daae58059f3606eb3d88b4ad169a93b6 | Ruby | WilfredTA/algorithmic_acrobatics | /Dynamic Programming/min_path_sum.rb | UTF-8 | 2,457 | 4.28125 | 4 | [] | no_license | #Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
#Note: You can only move either down or right at any point in time.
#Example 1:
#[[1,3,1],
# [1,5,1],
# [4,2,1]]
#Given the above grid map, return 7. Because the path ... | true |
574968c9edffc6d47c59535ef8ac7aa208d2b755 | Ruby | prashanthrajagopal/SalesTax | /lib/order.rb | UTF-8 | 1,118 | 3.421875 | 3 | [] | no_license | require_relative './tax_calculator'
require_relative './math'
require 'bigdecimal'
class Order
def initialize(args, quant)
@products = args
@quantities = quant
end
def calculate_tax
product_tax = []
@products.each do |product|
tc = TaxCalculator.new(product)
tax_rate = tc.calculate_t... | true |
bcca4623611af2f0259525204212f16204b70aa9 | Ruby | lorca/flat_file_benchmark | /gen_data.rb | UTF-8 | 494 | 2.859375 | 3 | [] | no_license | #
# generate a data file
#
# do ruby gen_data.rb > input/mydata.csv
#
user_id=1
for user_id in (1..10000)
payments = (rand * 1000).to_i
for user_payment_id in (1..payments)
payment_id = user_id.to_s + user_payment_id.to_s
payment_amount = "%.2f" % (rand * 30);
is_card_present = "N"
created_at = (rand * 1... | true |
920300350837676071082ee1254560e08cf5ff9f | Ruby | elbagre/Chess-Project | /pieces/pawn.rb | UTF-8 | 933 | 3.625 | 4 | [] | no_license | require 'byebug'
require_relative "piece"
class Pawn < Piece
WHITE_MOVES = [
[-1, 0],
[-1, -1],
[-1, 1],
[-2, 0]
]
BLACK_MOVES = [
[1, 0],
[1, -1],
[1, 1],
[2, 0]
]
def initialize(position, color, board)
super(position, color, board)
@color == :white ? @symbol = " ♟... | true |
8bd36c60b9974443c57b4613573be4315fdb3fa4 | Ruby | rsoemardja/Codecademy | /Ruby/Learn Ruby/Looping/Loops & Iterators/The 'Until' Loop.rb | UTF-8 | 218 | 2.828125 | 3 | [] | no_license | # Problem
counter = 1
until counter __ 10
puts counter
# Add code to update 'counter' here!
end
# Solution
counter = 1
until counter > 10
puts counter
# Add code to update 'counter' here!
counter += 1
end | true |
e9fc62cb0d6312660a3efdf08152f3344bf76988 | Ruby | Filipe-p/OTB-test | /lib/OTB/queue.rb | UTF-8 | 1,945 | 3.125 | 3 | [
"MIT"
] | permissive | module OTB
class Queue
attr_accessor :jobs, :jobs_parsed
#usign job:nil for stability & latter flexibity
# Idea being you could also have string:nil
# then you could initialized with Job objects in the jobs:
# or you could initialized with String objects in the string:
def initial... | true |
f276b5ee641ea98d28f2779eed2bc8c19efd1b5e | Ruby | Furaha/ugandasms | /app/models/participant.rb | UTF-8 | 1,289 | 2.546875 | 3 | [] | no_license | class Participant < ActiveRecord::Base
require 'csv'
validates :number, presence: true
has_many :answers
def self.import(file)
CSV.foreach(file.path, headers: true) do |row|
participant_hash = row.to_hash
participant = Participant.where(number: participant_hash["number"])
if participant... | true |
7c4b6cf33dbe2d1742d0b57aaefddd55d5ac7429 | Ruby | kazunetakahashi/atcoder-ruby | /0208_ARC033/C.rb | UTF-8 | 99 | 2.90625 | 3 | [
"MIT"
] | permissive | s = gets.chomp.split("+")
x = 0
s.each{|y|
if y.include?("0")
x += 1
end
}
puts s.size - x
| true |
b198358579add741338b7587395490d0af49cdc0 | Ruby | RJ-Ponder/RB101 | /lesson_6/scratch.rb | UTF-8 | 76 | 2.546875 | 3 | [] | no_license | def clear(state = 'clear')
system state
puts "this is a test"
end
clear | true |
0e44f68b9b96b9ac38c8616a65c77996605a1e7b | Ruby | quetzaluz/codesnippets | /ruby/codeeval/007_prefix_expressions.rb | UTF-8 | 596 | 3.578125 | 4 | [] | no_license | OPS = ['+', '/', '*']
def pref(line)
s = line.split(' ')
r = []
s.reverse.each do |i|
if OPS.include?(i)
r1 = r.pop()
r2 = r.pop()
if i == '+'
r.push(r1 + r2)
elsif i == '*'
r.push(r1 * r2)
elsi... | true |
1e9a56bf038a227c7fd3beaa3f187ae7f82e5351 | Ruby | tmaria17/pantry | /test/pantry_test.rb | UTF-8 | 2,054 | 3.234375 | 3 | [] | no_license | require './lib/pantry'
require './lib/recipe'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
class PantryTest < Minitest::Test
def test_it_exists
pantry = Pantry.new
assert_instance_of Pantry , pantry
end
def test_stock_hash
pantry = Pantry.new
assert_equal({ }, pantry.stock)
... | true |
1908d0b26fb9e41c96ba0359a4b8307df52cbf08 | Ruby | himaratsu/nokogiri_moviecom | /sample.rb | UTF-8 | 304 | 2.703125 | 3 | [] | no_license | # -- coding: utf-8
require "open-uri"
require "rubygems"
require "nokogiri"
# スクレイピングするURL
url = "http://www.walmart.com.br/"
charset = nil
html = open(url) do |f|
charset = f.charset
f.read
end
doc = Nokogiri::HTML.parse(html, nil, charset)
# タイトルを表示
p doc.title
| true |
bd05a2f29d35447253b0a73270cf0e31421d5321 | Ruby | LinuxGit/Code | /ruby/ProgrammingRuby/block_object.rb | UTF-8 | 87 | 2.8125 | 3 | [] | no_license | bo = lambda { |param| puts "You called me with #{param}" }
bo.call "ruby"
bo.call "51"
| true |
e52259cf57573ea9d21faecad651fbcb69a1e557 | Ruby | n-studio/arena-test | /app/services/fight_service.rb | UTF-8 | 2,635 | 3.140625 | 3 | [
"Beerware"
] | permissive | class FightService
POINTS_LIMIT = ENV.fetch('POINTS_LIMIT', 10)
LIFE_POINTS_FACTOR = ENV.fetch('LIFE_POINTS_FACTOR', 5)
MAX_STEPS_COUNT = ENV.fetch('MAX_STEPS_COUNT', 20)
FIGHTERS_COUNT_MAX = ENV.fetch('FIGHTERS_COUNT_MAX', 2)
attr_reader :fight, :fighters
def initialize(fight:)
@fight = fight
@fi... | true |
6f94dd08422cb1e09ac9de2c3f56895ab0fad6d7 | Ruby | mihirkelkar/languageprojects | /ruby/code_eval_stack.rb | UTF-8 | 287 | 3.234375 | 3 | [] | no_license | #!/usr/bin/ruby
fileContent = open(ARGV[0], 'r').readlines
fileContent.each do |line|
reverse_temp = line.split().reverse
join_list = []
for ii in (0..reverse_temp.length - 1)
if ii % 2 == 0
join_list << reverse_temp[ii].to_s
end
end
puts join_list.join(" ")
end
| true |
083e838e7fb489567d0aa6c79885e3229eb849c4 | Ruby | jrambold/scrabble | /test/player_test.rb | UTF-8 | 833 | 2.9375 | 3 | [] | no_license | gem 'minitest'
require_relative '../lib/player'
require_relative '../lib/scrabble'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
class PlayerTest < Minitest::Test
def setup
@player_1 = Player.new(Scrabble.new)
end
def test_total_score_starts_at_0
assert_equal 0, @player_1.total_score... | true |
7dfdc841d1045afa1b33a81c0b459798cb7d88c3 | Ruby | getflywheel/uptimerobot | /lib/uptimerobot/client.rb | UTF-8 | 2,825 | 2.5625 | 3 | [
"MIT"
] | permissive | class UptimeRobot::Client
ENDPOINT = "https://api.uptimerobot.com/"
USER_AGENT = "Ruby UptimeRobot Client #{UptimeRobot::GEM_VERSION}"
METHODS = [
:getAccountDetails,
:getMonitors,
:newMonitor,
:editMonitor,
:deleteMonitor,
:getAlertContacts,
:newAlertContact,
:deleteAlertContact
... | true |
d0fe3014200a17a011d978ad143cf31755b53498 | Ruby | donfanning/kodi-dedup | /lib/kodi_dedup/classes/show.rb | UTF-8 | 362 | 2.625 | 3 | [
"MIT"
] | permissive | module KodiDedup
class Show
def initialize(data)
@data = data
end
def episodes
@episodes ||= KodiDedup.episodes(tvshowid)
end
def method_missing(method, *args)
@data[method.to_s].presence || super(method, args)
end
def respond_to_missing?(method, *)
@data[method.... | true |
fc9c13911ba95327b55a67eafc1fb47c3c4df3f9 | Ruby | drosenfeld87/reinforcing_exercise_tdd | /calculator.rb | UTF-8 | 561 | 3.359375 | 3 | [] | no_license |
def add (number1, number2)
number1 + number2
end
# def adds_2_and_2
# assert_equal 4, add(2, 2)
# end
#
# def adds_positive_numbers
# assert_equal 8, add(2, 6)
# end
# subtract takes two parameters and subtracts the second from the first
def subtract (number1, number2)
number1 - number... | true |
1dd6943c3cb1e67bd5ff9dac8fd78885aa69c176 | Ruby | vsvld/rmagick | /test/Image_attributes.rb | UTF-8 | 24,020 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'fileutils'
require 'rmagick'
require 'minitest/autorun'
# TODO
# test frozen attributes!
# improve test_directory
# improve test_montage
class Image_Attributes_UT < Minitest::Test
def setup
@img = Magick::Image.new(100, 100)
gc = Magick::Draw.new
gc.stroke_width(5)
gc.circle(50, 50, ... | true |
5271481f57736f880964578b09212163551dea67 | Ruby | jpedrosa/luhnybin | /luhn.rb | UTF-8 | 1,814 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive |
DOUBLE_DIGITS = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
class Luhn
def test_it a, start_at, max_len
total = 0
double_digit = false
i = start_at + max_len - 1
while i >= start_at
total += double_digit ? DOUBLE_DIGITS[a[i]] : a[i]
double_digit = !double_digit
i -= 1
end
total % 10 ... | true |
70fdb3c42de60c3be22cdef99d04e98f5f1f1ce9 | Ruby | CosmicSpagetti/enigma | /lib/enigma.rb | UTF-8 | 838 | 2.6875 | 3 | [] | no_license | class Enigma
def encrypt(message, key = Key.new, date = Offset.new)
shifts = Shifts.new(key, date)
{ encryption:shifts.shifter(message) ,
key: shifts.key_instance.key ,
date: shifts.date_instance.date }
end
def decrypt(message, key = Key.new, date = Offset.new)
shifts = Shifts.new(key, d... | true |
f10a761971474e707e59cec621bd5f7b90aaf92b | Ruby | hybitz/tax_jp | /lib/tax_jp/depreciation_rate.rb | UTF-8 | 1,622 | 2.796875 | 3 | [
"MIT"
] | permissive | module TaxJp
module DepreciationRates
end
# 減価償却率
class DepreciationRate
DB_PATH = File.join(TaxJp::Utils.data_dir, '減価償却率.db')
attr_reader :valid_from, :valid_until
attr_reader :durable_years
attr_reader :fixed_amount_rate
attr_reader :rate, :revised_rate, :guaranteed_rate
def initia... | true |
d54abdfd364146693a8ffa7a7510ffb1fb3fe6b0 | Ruby | bin3/learnrb | /rpl/tcp_client.rb | UTF-8 | 184 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby -w
# coding: utf-8
require 'socket'
puts "[TCP Client]"
host, port = ARGV
TCPSocket.open(host, port) do |s|
while line = s.gets
puts line.chop
end
end
| true |
024aaa3edb6b7bb1c46211cca032bfa1a18cf03b | Ruby | yasmineezequiel/Vanilla_Ruby | /Section_19_Modules_and_Mixins/Mixins_Part_1.rb | UTF-8 | 1,153 | 4.40625 | 4 | [] | no_license | # Why mix in modules to classes?
# Different classes need similar functionalities.
# For example, String and Numeric both need <, <=, >, >=, and ==
# However, neither class can be represented as subclass of the other.
# Duplication of methods across classes violates the DRY principle.
# The solution is to use mixi... | true |
cc35a7ec890a9aee669bfdf60ef7fc5794eda268 | Ruby | kmac02/phase-0-tracks | /ruby/santa.rb | UTF-8 | 1,591 | 4.0625 | 4 | [] | no_license | # santa class
class Santa
attr_accessor :gender
attr_reader :age, :ethnicity
def initialize (gender, ethnicity, age)
puts "Initializing Santa instance..."
@gender = gender
@ethnicity = ethnicity
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer", "Vixen", "Comet", "Cupid", "Donner", "B... | true |
863a2a56dc62982f09221542c2e75ff2e11df663 | Ruby | soufiane121/ruby-enumerables-cartoon-collections-lab-nyc-web-100719 | /cartoon_collections.rb | UTF-8 | 475 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(arg)
answer=[]
arg.each_with_index do |ele, idx|
answer << "#{idx+1} #{ele}"
end
print answer
end
def summon_captain_planet(arr)
answer=arr.collect { |ele| "#{ele.capitalize}!"}
answer
end
def long_planeteer_calls(arr)
arr.any? {|ele| ele.length > 4 }
end
def find_the_cheese(... | true |
3c5dae75479fd955c7fca26a588dcf04a0115bae | Ruby | DustinFehlman/CST438 | /HangmanTwo/app/controllers/games_controller.rb | UTF-8 | 3,176 | 2.921875 | 3 | [] | no_license | class GamesController < ActionController::Base
def play
if cookies[:sessionID] && !params[:newGame]
sessionID = cookies[:sessionID]
currentGame = continueGame(sessionID)
else
currentGame = createGame()
end
@game = currentGame
... | true |
3e8f67812710abac24a35cd0041d93459ab0aeb5 | Ruby | Mohammad-Daylaki/prime-ruby-re-coded-000 | /prime.rb | UTF-8 | 132 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(number)
if number <=1
return false
end
numbers=(2..Math.sqrt(number)).to_a
numbers.all?{|n| number%n!=0}
end
| true |
6abc4b707afa6968fa8a12bcd2a9341ec9a82163 | Ruby | olwend/tic_tac_toe | /spec/player_spec.rb | UTF-8 | 213 | 2.6875 | 3 | [] | no_license | require_relative '../lib/player'
describe Player do
subject { described_class.new}
it "has a name" do
tom = Player.new("Tom")
expect(tom.name).to eq("Tom")
end
it "takes a turn" do
end
end
| true |
f7f9b9d6364e572fa5a406ac4593dd4648f5dd6b | Ruby | kostanzhoglo/rspec-fizzbuzz-v-000 | /fizzbuzz.rb | UTF-8 | 145 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(i)
if i % 3 == 0 && i % 5 == 0
"FizzBuzz"
elsif i % 3 == 0
"Fizz"
elsif i % 5 == 0
"Buzz"
end
end
# fizzbuzz(i)
| true |
3847247d3fc049b16fdb99d424c8ea40718685df | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/9e69741c3c9e488fb8818726c1724047.rb | UTF-8 | 147 | 3.234375 | 3 | [] | no_license | class Gigasecond
def initialize(birthday)
@birthday = birthday.to_time
end
def date
(@birthday + 1_000_000_000).to_date
end
end
| true |
e4c540ce3b134d97c090f04c0343d029f9aadd8a | Ruby | jacegu/nervion | /lib/nervion/stream.rb | UTF-8 | 1,360 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'eventmachine'
require 'nervion/stream_parser'
require 'nervion/reconnection_scheduler'
module Nervion
class Stream < EM::Connection
attr_reader :http_error
def initialize(*args)
@request = args[0]
@handler = args[1]
end
def post_init
@scheduler = ReconnectionScheduler.ne... | true |
1d98892a93e8992bc496309004fcb3b0879cff7c | Ruby | fredericcormier/fingers | /lib/instrument.rb | UTF-8 | 4,020 | 3.609375 | 4 | [
"MIT"
] | permissive | require "tones"
require "tuning"
include Tones
include Tuning
module Instrument
#===Note about tuning
# The tuning used here is from the first (highest) string to lowest string
# ex for standard guitar (first to last):
# Guitar: E, B, G, D, A, E
#for touch instruments, with inverted tunings,... | true |
93be1c3d0e0a176eb848004acba88dba77de292a | Ruby | JoyFoodly/joyful_12 | /db/seeds.rb | UTF-8 | 4,096 | 2.65625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
ffbc7e214284def5b03f6be40553c6e2f619254b | Ruby | codedymes/ruby-challenges | /numerology.rb | UTF-8 | 955 | 3.359375 | 3 | [] | no_license | puts "please enter your birthdate in the following format: MMDDYYYY"
birthday = gets
results = birthday[0].to_i + birthday[1].to_i + birthday[2].to_i + birthday[3].to_i + birthday[4].to_i + birthday[5].to_i + birthday[6].to_i + birthday[7].to_i
results.to_s
results = results[0].to_i + results[1].to_i
if (results > 9)
... | true |
8a7d7f8b2d59fb35e12b427372acf5647ab7a078 | Ruby | TheLucasMoore/oo-meowing-cat-v-000 | /lib/meowing_cat.rb | UTF-8 | 66 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cat
attr_accessor :name
def meow
puts "meow!"
end
end | true |
a6b4fed270c77a410ae83d94f5a30721e3b82b72 | Ruby | rhivent/ruby_awal | /array.rb | UTF-8 | 764 | 4 | 4 | [] | no_license | #array
bahasa = ["array",2,"js","css","python"]
puts "pertama : " + bahasa.first
puts "terakhir : " + bahasa.last
#ambil 2 bagian pertama
puts "2 bgian pertama : #{bahasa.take(2)}"
puts "count array : #{bahasa.count}"
puts "length array : #{bahasa.length}"
bahasa.push("ruby") #memasukkan data ke dlm array di akhir a... | true |
9c7252a52d76b9c8c74aba4353ee188819c21d78 | Ruby | phallguy/shamu | /lib/shamu/events/channel_stats.rb | UTF-8 | 654 | 2.625 | 3 | [
"MIT"
] | permissive | module Shamu
module Events
# Indicates that an {EventsService} supports reporting channel activity states.
module ChannelStats
# Gets stats for the given `channel`.
#
# #### Stats Included in the results.
#
# - **name** name of the channel.
# - **subscribers_count** the n... | true |
7a105eed66b60e90c105d391d8ea0cf7e19d553f | Ruby | takaya-47/take_out_app | /app/models/order_order_detail.rb | UTF-8 | 1,895 | 2.5625 | 3 | [] | no_license | class OrderOrderDetail
# フォームオブジェクトクラスであるのでライブラリを読み込む
include ActiveModel::Model
# このクラスで扱う属性を全て定義
attr_accessor :quantity, :total_price, :last_name, :first_name, :last_name_kana, :first_name_kana, :prefecture_id, :address,
:phone_number, :visit_day_id, :visit_time_id, :menu_id, :token
# バリデ... | true |
1b12157e1e7b1733542485894b3f9b14d0b13bfd | Ruby | gersonnoboa/TaxiAppAPI | /app/controllers/api/bookings_helper.rb | UTF-8 | 2,222 | 2.640625 | 3 | [] | no_license | module Api::BookingsHelper
require 'compute_distance_between.rb'
def create_booking(user, location)
Booking.create(location_id: location.id, status: Booking::AVAILABLE, user_id: user.id)
end
def push_to_next_driver(driver, booking)
driver_list = []
drivers = Driver.where("status = ? ", Driver::ACT... | true |
46ee130cbfd5a2830a73de1575f7e230596da23e | Ruby | JOCOghub/ruby-getting-remote-data-lab-onl01-seng-ft-070620 | /lib/get_requester.rb | UTF-8 | 371 | 2.6875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'open-uri'
require 'net/http'
require 'json'
class GetRequester
URL = "http://data.cityofnewyork.us/resource/uvks-tn5n.json"
def initialize(url)
@url = url
end
def get_response_body
uri = URI.parse(@url)
variable = Net::HTTP.get_response(uri)
variable.body
end
def parse_json
... | true |
4526361dd94884300cbcbbe669e64aea156d0c7b | Ruby | bhb/tack | /lib/tack/middleware/parallel.rb | UTF-8 | 2,295 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'forkoff'
require 'facter'
module Tack
module Middleware
class Parallel
include Middleware::Base
def initialize(app, options = {})
super
@processes = options.fetch(:processes) { processors }
@processes = processors if @processes == 0
@output.puts "Runn... | true |
688e9211f39aca5543016fddbebfea96115bb550 | Ruby | khamilowicz/Jumpstart_store | /app/models/address.rb | UTF-8 | 473 | 2.703125 | 3 | [] | no_license | class Address < ActiveRecord::Base
attr_accessible :country, :city, :zip_code, :street, :house_nr, :door_nr
validates_numericality_of :zip_code, :house_nr, :door_nr, greater_than: 0, only_integer: true, allow_nil: true
belongs_to :user
def to_s
"#{self.country} #{self.zip_code_formed} #{self.city} #{self... | true |
84a929384b3cc260f652c9f675ec73c2fa28cb9a | Ruby | wusuopu/youdao-dict-rb | /db.rb | UTF-8 | 3,605 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
#-*- coding:utf-8 -*-
# Copyright (C) 2012 ~ 2013 Deepin, Inc.
# 2012 ~ 2013 Long Changjin
#
# Author: Long Changjin <admin@longchangjin.cn>
# Maintainer: Long Changjin <admin@longchangjin.cn>
#
# This program is free software: you can redistribute it and/or modify
# it under th... | true |
80adf16887814e1559dc96b6cddb014e2a166d63 | Ruby | npogodina/linked-lists | /lib/linked_list.rb | UTF-8 | 1,298 | 3.734375 | 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)
first = Node.new(data, head)
@head = first
end
# Time complexity - O(1)
# Space complexity - O(1)
def get_first
return ... | true |
25182b8f7240c6a4daac68f2104cfb9e1b166978 | Ruby | Himuravidal/E8CP1A1 | /ejer04.rb | UTF-8 | 439 | 3.109375 | 3 | [] | no_license | def show_stock_by_product
lines = File.open('archivo.txt', 'r').readlines.each(&:chomp)
new_lines = []
lines.each { |line| new_lines.push(line.split(', ').map(&:chomp)) }
new_lines.each do |details|
name = details.shift
sum = get_sum(details)
end
end
def get_sum(details)
suma = 0
detail... | true |
b9008b9e2161c71f8841d4d76ad5c4382737d6f0 | Ruby | RTurney/Birthday-app | /app.rb | UTF-8 | 534 | 2.953125 | 3 | [] | no_license | # frozen_string_literal: true
require 'sinatra'
require_relative './lib/birthday_calculator'
# Main app class. Inherits from Sinatra base.
class Birthday < Sinatra::Base
get '/' do
erb(:index)
end
post '/birthday' do
@bday_calculator = BirthdayCalculator.new
@name = params[:name]
@day = params... | true |
133399338118b6d3a3907ef3d03368fcacf095af | Ruby | cielavenir/procon | /yukicoder/3xxx/tyama_yukicoder3100.rb | UTF-8 | 85 | 2.9375 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
gets.to_i.times{
n=gets.to_i
p (n+~gets.split.map(&:to_i).sum)%-~n
}
| true |
ee095668338af80b696ec60587ca5782897e2bb6 | Ruby | ifcwebserver/IFCWebServer-Extensions | /extensions/byclass/IFC.rb | UTF-8 | 2,109 | 2.671875 | 3 | [] | no_license | xx = <<-eos
class API
def getObjectByLineID(id)
#doc:<div class='documentaion' >Return an IFC object by its STEP ID </div>
end
def IFC_CLASS_NAME.nonInverseAttributes
#doc:<div class='documentaion' >Return a list of IFC class basic attributes<br>
#doc:<b> IFCCOLUMN.nonInverseAttributes</b>: -->>><br>"|globalId... | true |
ce22665fc23fe3acc939441cd8b3df8f91d86071 | Ruby | eggyy1224/101-programming-foundation | /small_problems/medium2/balance.rb | UTF-8 | 616 | 3.828125 | 4 | [] | no_license | require 'pry'
def balanced?(str)
left = 0
right = 0
str.chars.each do |char|
if char == '('
left += 1
elsif char == ')'
right += 1
return false if left - right == -1
end
end
right - left == 0 ? true : false
end
puts balanced?(')Hey!(')
puts balanced?('What (is) this?')... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.