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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0ec24a771a482fbab573c0577b96daf41e60d7ac | Ruby | robbystk/sleep-tracker | /app/helpers/sleep_records_helper.rb | UTF-8 | 394 | 2.515625 | 3 | [] | no_license | module SleepRecordsHelper
class MyDuration < ActiveSupport::Duration
def hours
parts[:hours]
end
def minutes
parts[:minutes]
end
def to_s
"%d:%02d" % [hours, minutes]
end
end
def duration_between(start, stop)
start = start.in_time_zone
stop = stop.in_time_zone
... | true |
bfdc382f34f8d9aaff4e08ca33a3527ea57a5693 | Ruby | Saicheg/bsuir-courses | /2015/NemytovTimothy/2/gemfiler | UTF-8 | 515 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'chooser.rb'
require_relative 'parser.rb'
require_relative 'colorizer.rb'
require 'optparse'
parser = OptionParser.new do |opts|
opts.banner = "Usage: ./gemfiler [gem_name] [gem_versions]"
opts.on('-h') do
help_string = "I can't help you, sorry"
puts help_string
exi... | true |
4f4809e1011b8a1a07e210f231710b85980ba151 | Ruby | choznerol/ruby-on-rulers | /lib/rulers/util.rb | UTF-8 | 388 | 2.6875 | 3 | [] | no_license | require 'json'
module Rulers
def self.to_underscore(string)
string.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
gsub(/([a-z\d])([A-Z])/, '\1_\2').
tr("-", "_").
downcase
end
end
class String
def to_html
gsub('<', '<').gsub('>', '>')
end
end
class Objec... | true |
6af4aa1dce9eb7a13e3ff3f10391cfd5e272f32b | Ruby | goyalankit/analyze-valgrind | /scripts/pv | UTF-8 | 2,829 | 3.203125 | 3 | [] | no_license | #!/work/02681/ankitg/programs/bin/ruby
require 'csv'
require 'pry'
# create a method in string class to covert hex to integer
class String
def to_d
self.to_i(16) #convert hex(16) to decimal(10)
end
end
class VarInfo
attr_accessor :name, :base_address, :size
def initialize name, base_address,... | true |
f9d53eeaec0a7a8229790124bda2d32a0469003c | Ruby | samgorick/programming-univbasics-nds-nds-to-insight-understand-lab-chicago-web-033020 | /lib/nds_explore.rb | UTF-8 | 434 | 2.875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'directors_database'
require 'pp'
require 'pry'
# Call the method directors_database to retrieve the NDS
def pretty_print_nds(nds)
pp nds
nil
end
def print_first_directors_movie_titles
counter = 0
steven = directors_database[0][:movies]
while counter < stev... | true |
b4d45063229f896bb6bba070ee8d7f68542eeef9 | Ruby | chriswright47/ruby_pdx | /2015-07-09/basic_math.rb | UTF-8 | 818 | 4.90625 | 5 | [] | no_license | # Math in Ruby:
# Integers, Floats, & c.
# Examples of ruby math:
puts "3 + 5 = #{3 + 5}"
puts "3 * 5 = #{3 * 5}"
puts "9 / 4 = #{9 / 4} ... wait, what?"
puts "9.0 / 4 = #{9.0 / 4} ... oh, I see :)"
puts "9 / 4.0 = #{9 / 4.0} ... same thing :)"
puts "5 % 3 = #{5 % 3}"
# simple calculator class for example of a rub... | true |
1598ec6ead0ef925df1d7b1cf00b1063a324bc1a | Ruby | RainbowQuartz/mercredi_semaine_1 | /password.rb | UTF-8 | 752 | 3.328125 | 3 | [] | no_license | def define_password
puts "Entrez votre mot de passe :"
@user_password = gets.chomp
end
def password_verification(password)
puts "Confirmez le mot de passe :"
confirmation = gets.chomp
if confirmation == password
puts "Mot de passe correct."
return password
else
puts "Mots de passe non concordant... | true |
1efd8a4ef0ddf9f5418097aa2f8721f287e31d05 | Ruby | 4inarina/ruby_sept_20 | /ht2/03_exercise.rb | UTF-8 | 233 | 3.03125 | 3 | [] | no_license | puts "Введите ширину прямоугольника"
a = gets.chomp.to_i
puts "Введите длину прямоугольника"
b = gets.chomp.to_i
puts "Площадь прямоугольника #{ S = a * b }" | true |
fd0f981424d184d552673d835f6e9e769eb0a30f | Ruby | alexkravets/isstvo.com | /lib/venice/kit.rb | UTF-8 | 1,368 | 2.75 | 3 | [] | no_license | require "venice/version"
require "thor"
module Venice
class Kit < Thor
include Thor::Actions
desc "new", "runs the command to clone venice into new project"
def new(repo_name = "new-venice-project")
url = "https://github.com/alexkravets/venice.git"
system "git ls-remote #{url} > /dev/null 2... | true |
10f618ae00cac40399d2f34544da5d49d4213e6e | Ruby | PhilipDeFraties/Code_Challenges | /3sum/test.rb | UTF-8 | 337 | 2.546875 | 3 | [] | no_license | require 'minitest/autorun'
require './code'
require 'pry'
class ThreeSumTest < Minitest::Test
# def test_it_responds
# assert_equal true, three_sum([])
# end
def test_three_sum
assert_equal [[-1,-1,2],[-1,0,1]], three_sum([-1,0,1,2,-1,-4])
assert_equal [], three_sum([])
assert_equal [], three_su... | true |
c3d5e519dc780980d779d10eeb15095bc4f00d85 | Ruby | arjunmenon/Convection | /app/helpers/application_helper.rb | UTF-8 | 1,567 | 2.53125 | 3 | [
"MIT"
] | permissive | # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# same function as application_controller.rb's logged_in? method
def logged_in?
!current_user.nil?
end
def delete_widget(obj... | true |
55ba50510bbf0e1aa7627c30026a4f78c1d73dda | Ruby | nog/atcoder | /contests/abc178/e/main.rb | UTF-8 | 458 | 3.03125 | 3 | [] | no_license | N = gets.to_i
X = Array.new N
Y = Array.new N
dmax = 0
dmin = (10**9) * 2
N.times do |i|
X[i], Y[i] = gets.split.map(&:to_i)
d = X[i] + Y[i]
if d > dmax
dmax = d
end
if d < dmin
dmin = d
end
end
res = dmax - dmin
dmax = -(10**9) * 2
dmin = (10**9) * 2
N.times do |i|
d = X... | true |
a246fe1c401fc3a7355d57d9cb7d2cfa9f3ce555 | Ruby | charrednewth/Succubus-Rhapsodia-ENG | /Scripts - manually insert these/151 - Scene_Box(処理まとめ).rb | SHIFT_JIS | 9,967 | 2.703125 | 3 | [] | no_license | class Scene_Box
#--------------------------------------------------------------------------
# tF[h
#--------------------------------------------------------------------------
def fade
# tF[hCB10t[ōsB
n = 10
case @fade_flag
when 1 # So
# wi
if @center[0].opacity < 120
... | true |
9ca36e6ff65af52a4ef6c1fbe879051fda37daa4 | Ruby | nysol/mining | /bin/mnewman.rb | UTF-8 | 8,283 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require "rubygems"
require "nysol/mcmd"
$version="1.0"
$revision="###VERSION###"
CMD="mnewman.rb"
def help
STDERR.puts <<EOF
----------------------------
#{CMD} version #{$version}
----------------------------
概要) newman クラスタリング
特徴) 1) modularityの最適化を用いたクラスタリングが実施できる。
2) 辺... | true |
d2a29b58a78bbd782427e33cd92b29a88a6c81bf | Ruby | donnrri/MediaFactory | /Model/grid_object.rb | UTF-8 | 3,877 | 3.390625 | 3 | [] | no_license | require './Utils/utilities'
=begin
The purpose of this class is to contain methods to create, manipulate or display the grid of pixels.
=end
module GridModule
class GridObject
attr_accessor :grid_data
include Utilities
def initialize
@grid_data = []
@default_color = Utilities.default_c... | true |
62d4358d2de3df925b34458bdd1bba6d188d7b8d | Ruby | lara/llama-kisses | /app/models/redemption.rb | UTF-8 | 555 | 2.625 | 3 | [] | no_license | class Redemption < ApplicationRecord
belongs_to :user
validates :kisses_redeemed, presence: true
validate :kiss_count_cannot_exceed_available_kisses, on: :create
private
def kiss_count_cannot_exceed_available_kisses
return if kisses_redeemed.blank?
return unless kiss_count_exceeds_available_kisses?
... | true |
4c63236b4319bcfa64548959a32897666e0adfc7 | Ruby | cielavenir/procon | /hena/tyama_hena3.rb | UTF-8 | 489 | 2.765625 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/env ruby
#http://nabetani.sakura.ne.jp/hena/ord3ynode/
T={ #clockwise
'A'=>['D','C','B'],
'B'=>['E','A','C'],
'C'=>['F','B','A'],
'D'=>['A','E','F'],
'E'=>['B','F','D'],
'F'=>['C','D','E'],
}
STDOUT.sync=true
while gets
curr='A';prev='B'
print 'A'
$_.chomp.chars{|e|
if e=='b'
curr,prev=prev,cur... | true |
84ac71479d2a763c1970261257f82d64fe7bfdd9 | Ruby | Rynaro/video-app | /app/components/video_stats_button_component.rb | UTF-8 | 446 | 2.546875 | 3 | [] | no_license | class VideoStatsButtonComponent < ViewComponent::Base
ICONS = {
views: "fa-eye",
upvote: "fa-thumbs-up",
downvote: "fa-thumbs-down"
}.freeze
COLORS = {
views: "is-info",
upvote: "is-success",
downvote: "is-danger"
}.freeze
def initialize(type:, countage:)
@type = type
@counta... | true |
5f499a66f60342e898a7b7d8fae75b5125824790 | Ruby | cdisong/W2D3 | /w2d3-poker-master/lib/hand.rb | UTF-8 | 1,068 | 3.484375 | 3 | [] | no_license | class Hand
attr_reader :cards
SUITS = %w{club spade heart diamond}.freeze
RANKS = {
"A" => 1,
"2" => 2,
"3" => 3,
"4" => 4,
"5" => 5,
"6" => 6,
"7" => 7,
"8" => 8,
"9" => 9,
"10" => 10,
"J" => 11,
"Q" => 12,
"K" => 13
}.freeze
def initialize(cards)
@car... | true |
eeb8b57b078c4a134f60da2d3682d5fa826cd98d | Ruby | denio-rus/thinknetica-ruby | /lesson7/wagon.rb | UTF-8 | 475 | 2.796875 | 3 | [] | no_license | class Wagon
include Production
include ValidationMethods
attr_reader :id, :status
@@wagons = []
def initialize(id)
@id = id
validate!
@status = "free"
@@wagons << self
end
def self.find(id)
@@wagons.find { |wagon| wagon.id == id }
end
def set_free
@status = "free"
end
... | true |
76368c7d93ac5a25cb4272e6f3319b05cc4e9b35 | Ruby | GCHwee/The_Well_Grounded_Rubyist | /built-in/enumerable_and_enumerator/cycle_method.rb | UTF-8 | 420 | 3.390625 | 3 | [] | no_license | puts
class PlayingCard
SUITS = %w{ clubs diamonds hearts spades }
RANKS = %w{ 2 3 4 5 6 7 8 9 10 J Q K A }
class Deck
def initialize(n = 1)
@cards = []
SUITS.cycle(n) do |suit|
RANKS.cycle(1) do |rank|
@cards << "#{rank} of #{suit}"
end
end
end
def card... | true |
d4e0bd985f0b4593b5ee6364826b8e709f3beba7 | Ruby | tfar/blog | /lib/helpers/more_helper.rb | UTF-8 | 443 | 2.84375 | 3 | [] | no_license | module MoreHelper
def strip_more(content, params = {})
more_index = content.index("<!--more-->")
if more_index.nil?
more_index = content.index("<!-- more -->")
end
unless more_index.nil?
return content[0..more_index-1] + more_url(params[:more_url])
end
return content
end
def more_url(url)
if... | true |
a99855d710bb7d1ae8889859e8a5ad78ee55781f | Ruby | freddywong/WDI_SYD_7_Work | /w03/d01/frederick/blog/app.rb | UTF-8 | 1,596 | 2.90625 | 3 | [] | no_license | require "pry"
require "sinatra"
require "sinatra/reloader"
require "pg"
def run_sql(sql_string)
connection = PG.connect(dbname: "my_blog", host: "localhost")
result = connection.exec(sql_string)
connection.close
return result
end
get '/' do
@posts = run_sql("SELECT * FROM posts;")
#You will recieve an array... | true |
b76674ceb2f07195e1ab64021834fe5eaa2286fa | Ruby | imBAOSS/homeworks | /W2D1/chess/pieces/knight.rb | UTF-8 | 467 | 3.28125 | 3 | [] | no_license | require_relative "../modules/stepping_piece"
require_relative "../piece"
class Knight < Piece
include SteppingPiece
DELTAS = [
[-2, 1],
[-2, -1],
[-1, 2],
[-1, -2],
[1, 2],
[2, -1],
[2, 1],
[1, -2]
]
def initialize(pos, board, color)
@name = (color == :white) ? "\u2658" : ... | true |
7170b3d281a50cce79cb00fd89bf54bad19e0327 | Ruby | miguelmoreba/cashapp | /db/seeds.rb | UTF-8 | 571 | 2.640625 | 3 | [] | no_license | require_relative("../models/tags.rb")
require_relative("../models/transactions.rb")
require("pry-byebug")
Transaction.delete_all
Tag.delete_all
tag1 = Tag.new({
"name" => "Groceries"
})
tag1.save
tag2 = Tag.new({
"name" => "Clothes"
})
tag2.save
transaction1 = Transaction.new({
"dt" => "2-12-17",
"na... | true |
bd6c1bb26c885a638141a96f3f78b0d667d24b9c | Ruby | deanh/zombies | /test/test_zombies.rb | UTF-8 | 3,786 | 2.8125 | 3 | [
"MIT"
] | permissive | require "minitest/autorun"
require "minitest/benchmark" if ENV['BENCH']
require "zombies"
class TestZombies < MiniTest::Unit::TestCase
attr_accessor :p
def setup
@p = Person.new nil, 37, 42
end
def test_tl
assert_equal [32, 37], p.tl
end
def test_tr
assert_equal [42, 37], p.tr
end
def t... | true |
384d2417a469d6f26c8bb8687a8566971b1ed898 | Ruby | danabase/RubySandbox | /array_experiment.rb | UTF-8 | 186 | 2.984375 | 3 | [] | no_license |
arr = [['banana','carrot','strawberry'],
[1,50,150],['book','pencil','book bag']]
for (a,b) in arr do
puts "#{a}"
end
puts "**********************"
print (arr[1][1]) | true |
2ac9980e7c21bcaff6c45d10d777e4c7d2c6aeea | Ruby | sounz/SOUNZ-Online | /sounz-1.62.0/sounz/app/models/event_advanced_search_details.rb | UTF-8 | 1,935 | 2.515625 | 3 | [] | no_license | #This is used to store the details of an advanced contributor search in order to render the form.
#Note these details are NOT saved in the database, they are merely collected here for convenience.
#A serialised verison of the object could be saved, this would provide for a "saved search" option
class EventAdvancedSearc... | true |
afa044056f8a58d737b9cf99c145498025ffc69f | Ruby | k-ankobia/bank_tech_test | /lib/account.rb | UTF-8 | 368 | 3.09375 | 3 | [] | no_license | require_relative 'helper'
class Account
include Helper
attr_reader :balance, :transaction
def initialize
@balance = 0
@transaction = []
end
def deposit(amount)
@balance += amount
@transaction << [date, amount, '', @balance]
end
def withdrawl(amount)
@balance -= amount
@transa... | true |
4d5d02e5c8720bbaa33f6fbc0a9bd7c3ba330fd0 | Ruby | seikin123/Ruby_practice | /heiseinen.rb | UTF-8 | 359 | 3.734375 | 4 | [] | no_license | #西暦年か平成年を求める
seireki = Time.now.year
print "西暦#{seireki}年は、"
#西暦年から平成年とする
#平成1年とは、西暦1989年。その差は、1989
#西暦年 - 1989 = 平成*年
#例:西暦1989年 - 1989 = 平成1年
#例:西暦2015年 - 1988 = 平成27年
heisei = seireki - 1988
puts "平成#{heisei}年です"
| true |
1f5d5f135676d58d462ea2cc51632954e487c65d | Ruby | nicinabox/qmk_keymaps | /programmer.rb | UTF-8 | 1,142 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
KEYBOARD_PATH = ARGV[0]
FLASHERS = {
'dfu': ['lufa-dfu', 'qmk-dfu', 'atmel-dfu'],
'avrdude': ['caterina', 'usbasploader'],
'teensy': 'halfkay',
}
BOOTLOADERS = {
'halfkay': ['512', '1024'],
'atmel-dfu': '4096',
'usbasploader': '2048',
}
def bootloader_from_size(size)
size and BOOTL... | true |
30b50e7ea096ea40231663fbdd67d2004eda8fd3 | Ruby | theodi/spindle_gouge | /lib/spindle_gouge/helpers.rb | UTF-8 | 1,878 | 2.578125 | 3 | [
"MIT"
] | permissive | module SpindleGouge
module Helpers
PALETTE = YAML.load_file 'config/palette.yaml'
DEFAULTS = YAML.load_file 'config/defaults.yaml'
def fetch_colour name
PALETTE[name] || name
end
def wrangle_colours params
@colour = fetch_colour params.fetch('colour', DEFAULTS['colours']['primary'])
... | true |
06f9ad0e9eab0c7031d2875316e69fc2ec6a0d15 | Ruby | rahmaw00/bakery-site | /pastries.rb | UTF-8 | 2,350 | 2.921875 | 3 | [] | no_license | class Cookie
attr_reader :description, :price, :image
def initialize(description, price, image)
@description = description
@price = price
@image = image
#@image = image
end
end
class Cake
attr_reader :description, :price, :image
def initialize(description, price, image)
@description = des... | true |
520b80aa6ec755f9ad937e768800b9311524ccb3 | Ruby | imwithsam/sales_engine | /lib/invoice.rb | UTF-8 | 1,872 | 2.59375 | 3 | [] | no_license | require_relative 'record'
class Invoice < Record
def customer_id
return @customer_id if defined? @customer_id
@customer_id = attributes[:customer_id].to_i
end
def merchant_id
return @merchant_id if defined? @merchant_id
@merchant_id = attributes[:merchant_id].to_i
end
def status
attribu... | true |
3ce33af89426785a975fd094c505830fba5685d4 | Ruby | douglasdutt/Conversor-e-Calculadora-de-bases | /calculadora_de_bases.rb | UTF-8 | 4,532 | 4.1875 | 4 | [] | no_license | def decimal_para_binario(valor)
#code
valor_binario = ""
if valor == 0
return "0"
end
while valor > 0
resto = valor % 2
valor = valor / 2
valor_binario = valor_binario + resto.to_s
end
return valor_binario.reverse
end
def decimal_para_hexadecimal(valor)
#code
valor_hexadecimal = ""
... | true |
c1ac99937c872162d50da7c88beb0b3f37a013db | Ruby | DaveSeidel/ShlispTools | /bin/shtool | UTF-8 | 4,702 | 3 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#------------------------------------------------------------------------------
# ops
#------------------------------------------------------------------------------
class OpResult #:nodoc: all
attr_reader :args, :result
def initialize(args=nil, result=nil)
@args = args
@result = resu... | true |
524064dd17e9343d6df788d5f1df61c62f1fb61c | Ruby | barrettclark/DallasRubyPOR | /lib/geocode.rb | UTF-8 | 542 | 2.515625 | 3 | [] | no_license | # NOTE: this has been replaced by (moved to) the Stands4Geocoder gem
class Geocode
# include HTTParty
# base_uri 'www.stands4.com'
# # GET http://www.stands4.com/services/v1/zip.aspx?tokenid=tk1902&zip=90210
# def self.reverse_geocode(zipcode)
# options = {
# :query => { :zip => zipcode, :tokenid =>... | true |
2438807b2d0bb47089d2817996945ec1271557b6 | Ruby | kennyfrc/programming_pearls | /lib/16-random-samples/1-n-samples.rb | UTF-8 | 191 | 2.78125 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | n = 20
#----excerpt
list = (1..200).to_a
samples = []
while samples.length != n
samples << rand(list.length)
samples.uniq!
end
samples.map!{|i|list[i]}
#----excerpt
puts samples.inspect | true |
3fabb4e6af172b85bd5d3d73d5938d175903e68f | Ruby | kirualex/Flamingo | /vendor/bundle/ruby/2.6.0/gems/fastlane-2.167.0/deliver/lib/deliver/upload_price_tier.rb | UTF-8 | 1,380 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative 'module'
require 'spaceship'
module Deliver
# Set the app's pricing
class UploadPriceTier
def upload(options)
return unless options[:price_tier]
price_tier = options[:price_tier].to_s
app = options[:app]
attributes = {}
territory_ids = []
# As of 2020-09... | true |
2fc18b9b96bb58736e0e5b6a4619613284598eb1 | Ruby | gregors/boilerpipe-ruby | /lib/boilerpipe/filters/large_block_same_tag_level_to_content_filter.rb | UTF-8 | 720 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | # Marks all blocks as content that:
# are on the same tag-level as very likely main content
# (usually the level of the largest block)
# have a significant number of words, currently: at least 100
# Used downstream of KeepLargestBlockFilter
module Boilerpipe::Filters
class LargeBlockSameTagLevelToContentFilter... | true |
3e3397156739e3c72b9a06a50d3bbb9fb61ded1c | Ruby | abunashir/metanorma-ietf | /lib/asciidoctor/rfc/v2/blocks.rb | UTF-8 | 7,772 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | require "htmlentities"
module Asciidoctor
module Rfc::V2
module Blocks
# Syntax:
# [discrete]
# == Section
def floating_title(node)
noko do |xml|
xml.t do |xml_t|
xml_t.spanx node.title, style: "strong"
end
end
end
# Syntax:
... | true |
4b0f6584709bcd7a92ae6ee330cea9d64ef9362d | Ruby | Bumsuk/MyRubyBase | /08-010-wrong_addition.rb | UTF-8 | 213 | 3.15625 | 3 | [] | no_license | class Fixnum
alias original_addition + # 元の定義を別のメソッド名で退避する
def +(rhs) # 再定義
original_addition(rhs).succ
end
end
p 1+1 #=> 3
p 5+2 #=> 8
| true |
392998a8bfab7edd7a77dc7c9c0ee6180426a3e5 | Ruby | duskyshelf/battleships-beta | /lib/game.rb | UTF-8 | 168 | 2.734375 | 3 | [] | no_license | require_relative 'ship'
class Game
attr_reader :ship1
attr_reader :ship2
def initialize
@ship1 = Ship.new carrier 1
@ship2 = Ship.new boat 2
end
end | true |
fa32b3b7fe338382b5e9b6b8d08dec03258f269c | Ruby | dcsim0n/garden-roots | /garden-api/app/models/plant.rb | UTF-8 | 230 | 2.53125 | 3 | [] | no_license | class Plant < ApplicationRecord
has_many :bed_plants
has_many :garden_beds, through: :bed_plants
def soil_delta(soil_int)
#calculate difference as absolute value
(self.soil - soil_int).abs
end
end
| true |
f0e75e21bfc34bb41c89a846bde35fd074764aa3 | Ruby | jholton/govdelivery-tms-ruby | /lib/govdelivery/tms/resource/keyword.rb | UTF-8 | 1,315 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | module GovDelivery::TMS #:nodoc:
# A Keyword is a word that TMS will detect in an incoming SMS message. Keywords can have Commands, and
# when an incoming text message has a keyword, TMS will execute the keyword's Commands. Keywords may
# also have a response text field. If the response text is not blank, the ... | true |
d5e27aed5bfa40add307009ec73c275eb1e1b993 | Ruby | Avhana/allscripts_api | /lib/allscripts_api.rb | UTF-8 | 2,423 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "nokogiri"
require "allscripts_api/configuration"
require "allscripts_api/utilities/validator"
require "allscripts_api/magic_params"
require "allscripts_api/named_magic_methods"
require "allscripts_api/orders"
require "allscripts_api/patients"
require "allscripts_api/demographics"... | true |
9c2bbf754ead284b92e6691e5b100b593a6151d7 | Ruby | PowerToChange/pulse | /vendor/plugins/koala/spec/koala/graph_api/graph_api_tests.rb | UTF-8 | 2,495 | 2.546875 | 3 | [
"MIT"
] | permissive | shared_examples_for "Koala GraphAPI" do
# all Graph API instances should pass these tests, regardless of configuration
# API
it "should never use the rest api server" do
Koala.should_receive(:make_request).with(
anything,
anything,
anything,
hash_not_including(:rest_api => true)
)... | true |
2e26a4752122d41667e0ec61cafbeb8b82f1abd1 | Ruby | lfriedrichs/project-euler-factorial-digit-sum-seattle-web-030920 | /lib/project_euler_factorial_digit_sum.rb | UTF-8 | 229 | 3.53125 | 4 | [] | no_license | # code your solution here
def factorial(n)
output = n
until n == 1 do
n -= 1
output *= n
end
output
end
def sum_of_digits(n)
n.digits.sum
end
def factorial_digit_sum(n)
sum_of_digits(factorial(n))
end
| true |
885ff100a018e12ec032e5cf1603510cb03655cb | Ruby | tmikeschu/black_thursday | /lib/transaction_repository.rb | UTF-8 | 1,075 | 2.90625 | 3 | [] | no_license | require_relative 'find_functions'
require_relative 'transaction'
require 'csv'
class TransactionRepository
include FindFunctions
attr_reader :file_contents,
:all,
:parent
def initialize(file_name = nil, engine = nil)
return unless file_name
@parent = engine
@file... | true |
3d6aeaf6809f0341c79c1bde34ff29e9ef082359 | Ruby | wildjcrt/wargame-web | /generator.rb | UTF-8 | 698 | 3.15625 | 3 | [
"MIT"
] | permissive | # Here are shared variables/methods.
counter = "00"
def style(x,y)
style="background-position: #{x}px #{y}px;"
end
# End of shared.
def cards_generator
w = -242
h = -372
col = 6
row = 2
(0..row).each do |j|
(0..col).each do |i|
x = w * i
y = h * j
puts "#card#{counter.succ!} {#{style... | true |
cb21f36d25b0eeebc9de22055f3b62e17d879244 | Ruby | sudip32/sudip32 | /.rvm/gems/ruby-2.1.4/gems/honeybadger-1.16.6/lib/honeybadger/monitor/worker.rb | UTF-8 | 4,953 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | require "singleton"
module Honeybadger
module Monitor
class Worker
include Singleton
# Sub-class thread so we have a named thread (useful for debugging in Thread.list).
class MetricsThread < Thread
end
def initialize
init_metrics
init_traces
@delay = define... | true |
6ace1ef0ceb84da6d7aeca4c6b22650768beea34 | Ruby | Bryantellius/ruby_practice | /FizzBuzz.rb | UTF-8 | 899 | 4.09375 | 4 | [] | no_license | # Fizz Buzz Coding Challenge
puts "\nFizzBuzz Coding Challenge"
puts "\n The goal is to print out FIZZ if number is divisible by 3, BUZZ if the number is divisible by 5, and FIZZ BUZZ if divisible by both. Begin.\n"
num = 1
while num < 101 do
if num % 3 == 0 and num % 5 == 0 and num != 0
puts "#{num} FIZZ ... | true |
f2d58d9b78dd625bb1e8b6ba1047f8e7361465f5 | Ruby | kennydrobnack/simple_credit_kata | /lib/credit.rb | UTF-8 | 1,274 | 3.625 | 4 | [] | no_license | require 'bigdecimal'
class Credit
def initialize (credit_limit, start_amount, rate)
@credit_limit = BigDecimal(credit_limit, 2)
@updates = Array.new
@rate = BigDecimal(rate, 2)
@principal = start_amount
first_credit = {
'amount' => BigDecimal(start_amount, 2),
'start_date' => 0, #Start at day 0 to av... | true |
b34d4ff92e474425f2381842bccbca6297ddbb28 | Ruby | thantko20/Basic-Ruby-Projects-TOP | /substrings.rb | UTF-8 | 463 | 3.71875 | 4 | [] | no_license | dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"]
def substrings(string, dict)
hash = Hash.new
checker = string.split.map! { |item| item.downcase}
dict.each do |word|
checker.each do |item|
if item.include?(word)
hash[word] = 0 unless h... | true |
f29bb9965783f62cac0530f664cc03a0b943defd | Ruby | CloudMarc/cloud_cache | /test/cache_tests.rb | UTF-8 | 7,190 | 3.015625 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require File.join(File.dirname(__FILE__), '/../lib/cloud_cache')
require 'my_class.rb'
#
# You'll need make a ~/.test-configs/cloud_cache.yml file that contains:
# cloud_cache:
# access_key: ACCESS_KEY
# secret_key: SECRET
#
class CacheTests < Test::Unit::TestCase
def setup
puts("... | true |
8caf7de87f9bd9524468a6bcf6157ebedfd37899 | Ruby | crawfordmikyle/key-for-min-value-v-000 | /key_for_min.rb | UTF-8 | 213 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def key_for_min_value(name_hash)
key_s = nil
value_s = nil
name_hash.each do |key,value|
if value_s == nil || value_s > value
value_s = value
key_s = key
end
end
return key_s
end
| true |
940aa432c7565402ffa2f993e7a60b0bea58d9e0 | Ruby | mattyoho/rong | /rong-elements/lib/rong/elements/game.rb | UTF-8 | 3,487 | 3.125 | 3 | [] | no_license | require 'rong/elements/ball'
require 'rong/elements/paddle'
require 'rong/elements/window_constants'
module Rong
module Elements
class Game
include WindowConstants
WINNING_SCORE = 12
attr_accessor :paddles, :ball, :winner,
:left_score, :right_score,
:score_callbacks, :hit_call... | true |
828a9c998af401139a65a14e0bee790195e5493c | Ruby | ruebenramirez/ruby-code-test | /lib/cart.rb | UTF-8 | 338 | 3.21875 | 3 | [] | no_license | require 'product'
class Cart
attr_reader :total
attr_reader :items
def initialize
@items = []
@total = 0.00
end
def add(product_code)
product = Product.find(product_code)
@items.push(product_code => product)
@total += product["Price"]
end
def items
@items
end
def total
... | true |
835f09c38faaa667505ec8a9f80e46f286219c51 | Ruby | thomasdwood/chess | /lib/pieces/queen.rb | UTF-8 | 261 | 2.8125 | 3 | [] | no_license | class Queen < Piece
def sym
@team == :white ? "♕" : "♛"
end
def moves
moves = {
:direction => [],
:spaces => 7,
:special_moves => :none
}
@@directions.each { |key, val| moves[:direction] << val }
moves
end
end | true |
7a7f3d8de6e09ba19dbee9f91e20aff34aeedde5 | Ruby | Andry75/swgr2rb | /assets/endpoint_object_models/json_validator/json_validator.rb | UTF-8 | 1,026 | 2.703125 | 3 | [
"MIT"
] | permissive | class JsonValidator
class << self
def validate(expected_schema, actual_data, expected_data = nil)
preprocess_actual_data(actual_data).each do |data|
JsonSchemaValidator.validate(expected_schema, data)
end
if expected_data
expected = preprocess_expected_data(expected_schema, expec... | true |
3cda3f4f06e681197907f827d6918527864a043d | Ruby | pushpaagr/palindrome_check | /lib/palindrome_check.rb | UTF-8 | 537 | 4.0625 | 4 | [] | no_license | require 'pry'
# Returns true if the input positive integer word forms a palindrome. Returns false otherwise.
def palindrome_check(word)
i = 0
if word == nil
return false
end
length = (word.length) - 1
while length >= 0
if word[length] == " "
word[length] = ""
end
length = length - ... | true |
e24c02a236ef2319bd0d6ff21b4e434530f67038 | Ruby | agrzelewska/Practice_Ruby | /your_order.rb | UTF-8 | 527 | 3.921875 | 4 | [] | no_license | # Your task is to sort a given string. Each word in the string will contain a single number.
# This number is the position the word should have in the result.
# If the input string is empty, return an empty string.
# The words in the input String will only contain valid consecutive numbers.
# Examples:
# "is2 Thi1s T... | true |
17be706094210407f841166776940fba871464fc | Ruby | ashesh1105/ruby-on-rails-project | /03_strings/strings_1.rb | UTF-8 | 8,945 | 4.6875 | 5 | [] | no_license | name = "Ashesh"
revenue = "$23 dollars"
puts name, revenue # shortcut of printing multiple strings with line breaks
# length method
puts "name.length: #{name.length}"
# .class
puts "name.class: #{name.class}" # prints String, the class name
# .new method, alternate syntax to create Strings
name = String.new("David"... | true |
512d2b4ce0313711a8f54e8cb712a047d5c115c8 | Ruby | bjacobel/proglang | /lab6/twitter.rb | UTF-8 | 1,432 | 3.09375 | 3 | [] | no_license | require 'twitter'
Twitter.configure do |config|
config.consumer_key = "xaD9NI779fFhx5EpegCwbw"
config.consumer_secret = "QiRYthjNH0dEMP1kBDTlVfuUKjRrYi90ZwH1B9t9Q"
config.oauth_token = "15299776-qbzGy4hqag1xGVL4YEzaI0Pu27uqPvVEuDGslnN74"
config.oauth_token_secret = "Yt78nOxoOcqgqgvAWKJ1BTjkfkhkiCUQ5vXi... | true |
03ce63a5a027367f48d9cba44dec9c1bd5cdda6d | Ruby | unepwcmc/redlist-api | /extract.rb | UTF-8 | 989 | 2.640625 | 3 | [] | no_license | require "csv"
require "HTTParty"
require "JSON"
require "nokogiri"
require "open-uri"
csv_data = []
CSV.foreach("orig_data.csv", {:headers => true}) do |row|
# use row here...
response = HTTParty.get("http://api.iucnredlist.org/index/species/#{row['BINOMIAL'].sub(' ','-')}.json")
species_summary = JSON.parse re... | true |
8682d8d9dbd8f1d7584eb6561ef896906d16ae99 | Ruby | osdakira/ruby_test | /practice/haskell_sort.rb | UTF-8 | 200 | 3.21875 | 3 | [] | no_license | def qsort(_list)
return _list if _list.empty?
x = _list.shift
qsort(_list.select { |y| y > x }) + [x] + qsort(_list.select { |y| y <= x })
end
p qsort([3, 5, 1, 4, 2])
p qsort([2, 2, 3, 1, 1])
| true |
d8eadecd8af5b2e7af28027caf65dc4745a97235 | Ruby | karuna24s/codingChallenges | /glossier/exercise/ruby/lib/exercise/models/product.rb | UTF-8 | 385 | 2.984375 | 3 | [] | no_license | module Exercise
class Product
attr_reader :category, :id, :name
# category: String
# The category that the product belongs to, e.g.: skincare, makeup.
# id: Integer
# The unique id of the product.
# name: String
# The name of the product.
def initialize(category:, id:, name:)
... | true |
be5cd8f05d4232dbcab975de14bb28aa902a42ac | Ruby | doviende/adventofcode-rb | /2018/spec/p4_spec.rb | UTF-8 | 1,008 | 2.921875 | 3 | [] | no_license | require_relative "../p4.rb"
require 'easy_tests'
require 'pry'
date_examples = [
{ args: "1518-08-29 00:30", answer: ["1518-08-29", 30] },
]
describe "2018 problem 4" do
context "MyDate" do
it_behaves_like "easy test", :parse_date, date_examples do
let(:klass) { MyDate }
end
end
context "Slee... | true |
a8599fd0b0f573fb7c14e38feeec4b652cd189d5 | Ruby | tylermcgraw/launchcode_ruby_book | /the_basics/exercise_five.rb | UTF-8 | 159 | 3.515625 | 4 | [] | no_license | def factorial(num)
fac = 1
for i in 1..num do
fac *= i
end
return fac
end
puts factorial(5)
puts factorial(6)
puts factorial(7)
puts factorial(8)
| true |
de28567f762ee9a3bfcafc055c5a111ab93d41ae | Ruby | sonots/irc_parser | /lib/irc_parser/messages.rb | UTF-8 | 3,691 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'erb'
module IRCParser
module Messages
# Store all known message classes under convenient keys so they are easy to find.
ALL = Hash.new
# Create a Message class and save it on the IRCParser::Messages::ALL hash
# for easy retrieval with different names.
def self.define_message(name, *argu... | true |
66dbb7913eaaf70853ea6c79a4b868ae495682b5 | Ruby | rspine/mappings | /lib/spine/mappings/commands/fetch.rb | UTF-8 | 526 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | module Spine
module Mappings
module Commands
class Fetch
attr_reader :method_name
def initialize(method_name)
@method_name = method_name
end
def execute(source)
if source.respond_to?(method_name)
source.public_send(method_name)
elsi... | true |
16b1be3bd1b3821388c81562829a73792200d495 | Ruby | neuenm/notasRuby | /notas.rb | UTF-8 | 1,925 | 2.6875 | 3 | [] | no_license | # require 'nombre_de_la_gema'
# declaracion de las gemas que vamos a usar en nuestra app
# notese que 'Shotgun' se instala por Rubygems pero no se declara
# en la aplicacion.
require 'rubygems'
require 'sinatra'
require 'slim'
require 'data_mapper'
# Inicializacion, declarando tipo y path de la base de datos
DataMapper... | true |
38e5bd60cfc59e6c82f4b27000c610bfcf053bb2 | Ruby | edvio4/csv-to-db | /code.rb | UTF-8 | 569 | 3 | 3 | [] | no_license | require "csv"
require "pg"
require 'pry'
def db_connection
begin
connection = PG.connect(dbname: "ingredients")
yield(connection)
ensure
connection.close
end
end
# CSV.foreach("ingredients.csv", headers: false) do |ingredient|
# db_connection do |conn|
# conn.exec_params("INSERT INTO ingredien... | true |
aced5324d4a702fb96c66132f7ce6ef95a094a7b | Ruby | MattRooney/Web-Guesser | /web_guesser.rb | UTF-8 | 828 | 3.265625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
Secret_Number = rand(100)
@color = "background: #0016FF;"
get '/' do
guess = params["guess"].to_i
message = compare_guess(guess)
erb :index, :locals => { :number => Secret_Number, :message => message, :color => @color }
end
def compare_guess(guess)
if guess >= Sec... | true |
754779076d5619c3b3efc480f8f7f078e5ffd621 | Ruby | UgoMare/oop-06 | /patient.rb | UTF-8 | 411 | 3.234375 | 3 | [] | no_license | class Patient
#STATES?
attr_accessor :room, :id
def initialize(args = {})
@id = args[:id]
@name = args[:name] # String
@cured = args[:cured] || false # Boolean
@blood_type = args[:blood_type] || 'A'
@room = nil
end
end
# joe = Patient.new(name: 'Joe')
# p joe
# bob = Patient.new(cured: t... | true |
3e82687ea5706b4113a57739d8d71f40588eed1f | Ruby | gabrie30/Practice | /CoderByte/medium_Run_Length.rb | UTF-8 | 580 | 3.78125 | 4 | [] | no_license | def check_word(target,word)
word = word.split("")
count = 0
i = 0
while i < word.length
if target.include?(word[i])
count += 1
end
i += 1
end
if count == target.length-1
return true
end
false
end
def one_off_words(str, word_list)
target = str.split("")
answer = []
i = 0
... | true |
221cb4185252d1d4b80d5ac69d1bac0a970eea42 | Ruby | 0exp/smart_core | /lib/smart_core/validator/error_set.rb | UTF-8 | 1,858 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class SmartCore::Validator
# @api private
# @since 0.1.0
class ErrorSet
# @return [void]
#
# @api private
# @since 0.1.0
def initialize
@errors = Set.new
@access_lock = Mutex.new
end
# @param error_codes [Arrray<Symbol>]
# @return [void]
... | true |
8401242ce43718d507a62c35682a58a3b939b35c | Ruby | yalasti/Tealeaf | /Methods5.rb | UTF-8 | 205 | 3.53125 | 4 | [] | no_license |
#Methods5 1.
def scream(words)
words = words + "!!!!"
puts words
end
scream("Yippeee")
#Methods5 2. returns nil
#Methods 6. The error message says need two arguments, but you only put one argument.
| true |
bfde9b82da6d98d6ea56acec73d95755bcea19ef | Ruby | adam1/den | /seq/graph-density-friends.rb | UTF-8 | 541 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/ruby
def main
x_start = ARGV[0].to_i
graph_filename = "Density-friends-#{x_start}.png"
puts "writing #{graph_filename}"
plot_cmds = <<END
set terminal png
set output "#{graph_filename}"
set grid xtics lt 0
set grid ytics lt 0
set xrange [#{x_start}:]
f1(x) = 1/x
plot f1(x) with lines title "1/x", ... | true |
9bf6a3a2895455a958705324801af4fe7e00c9b5 | Ruby | kristo75/class_notes | /week_01/day_03/loops.rb | UTF-8 | 2,846 | 3.71875 | 4 | [] | no_license | # counter = 0
# my_number = 7
#
# while (counter < my_number)
# p "The counter is #{counter}"
# counter += 1
# end
# ###########################
# my_number = 9
#
# p "What nubmber am I thinking of?"
# input = gets.chomp().to_i()
#
# while (input != my_number)
# if (input < my_number)
# p "Too low..."
# els... | true |
10e85d6991092105a5f1dda2995f8446f029ba25 | Ruby | pandwoter/log-parser | /lib/adapters/file_adapter.rb | UTF-8 | 1,388 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
require 'entries/line'
require 'entries/statistic'
require 'pathname'
module LogsParser
module Adapters
class FileAdapter
ALLOWED_EXTENSIONS = ['.log', '.txt'].freeze
class ValidationError < StandardError; end
def initialize(
path,
line_entity =... | true |
daab3759d0f741b27601bd59d3f2c0917e153629 | Ruby | team-strasbourg/PointBudget | /app/models/gas_simulation.rb | UTF-8 | 4,730 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
class GasSimulation < ApplicationRecord
belongs_to :full_simulation
has_many :join_table_gas_simulation_contracts, dependent: :destroy
has_many :gas_contracts, through: :join_table_gas_simulation_contracts
validates :actual_price_paid,
presence: true,
nume... | true |
71837342e34b9b747e93c5c974b448c1844e9049 | Ruby | rtroncoso/spree_docker_boilerplate | /vendor/cache/ruby/2.2.0/gems/monetize-1.4.0/lib/monetize.rb | UTF-8 | 6,793 | 2.984375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'money'
require 'monetize/core_extensions'
require 'monetize/version'
require 'collection'
module Monetize
CURRENCY_SYMBOLS = {
'$' => 'USD',
'€' => 'EUR',
'£' => 'GBP',
'₤' => 'GBP',
'R$' => 'BRL',
'R' => 'ZAR',
'¥' => 'JPY',
'C$' => '... | true |
def6038295308c641f61f3a32ec3183bf1ffd15c | Ruby | kathinka/square_array-online-web-sp-000 | /square_array.rb | UTF-8 | 102 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each { |number| new_array << number ** 2 }
new_array
end
| true |
58ff0094b086e876a23d17695ceecec1ebb3a577 | Ruby | VikingPeter/assignment_mastermind | /lib/formats.rb | UTF-8 | 539 | 3.09375 | 3 | [] | no_license | # this module is for all of the CLI formatting and coloring mixins
module Formats
# create array of possible colors from which to choose
POSSIBLE_COLORS = %w(R G B Y C P)
def colorize(peg)
text = peg
color_code = case peg
when "R"
color_code = 31
when "B"
color_code = 34
when "G"
color_cod... | true |
c9f3c0c2f74f64f2c5f0d749f65308c106dd46c0 | Ruby | Paxa/server-compare | /lib/server_compare/server_state.rb | UTF-8 | 4,129 | 2.515625 | 3 | [] | no_license | require "FileUtils"
require "yaml"
class ServerCompare::ServerState
attr_accessor :host_name
attr_accessor :host_ip
attr_accessor :distro
attr_accessor :kernel
attr_accessor :packages
attr_accessor :auto_load_services
attr_accessor :users_groups
attr_accessor :users_info
attr_accessor :users_crontab... | true |
5e930c69918d4efdbbcfed3dadd80bf7885538ce | Ruby | ellesuzuki/Episode10 | /terminator_spec.rb | UTF-8 | 1,471 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'rspec'
require "./terminator"
describe GoodTerminator do
it 'should protect_john_connor' do
subject.protect_john_connor!
subject.current_mission.should == 'protect: john_connor'
end
it 'should protect_sarah_connor' do
subject.protect_sarah_connor!
subject.current_mission.should == 'prot... | true |
25b9e279f0e130922c726fdbcb5be81e1ef699fe | Ruby | Jeremy-Sabadie/Send_mails_mairies47 | /scrap_mairies47.rb | UTF-8 | 2,154 | 3.21875 | 3 | [] | no_license | require 'rubygems'
require 'open-uri'
require 'nokogiri'
require 'watir'
def get_the_email_of_a_townhal_from_its_webpage(url)
doc = Nokogiri::HTML(open(url))
email = doc.xpath('/html/body/table/tr[3]/td/table/tr[1]/td[1]/table[4]/tr[2]/td/table/tr[4]/td[2]/p/font')
email.text
end
#On créé une foction "get_the_em... | true |
e85f58197b4a4b0d6456018910ca2c8cfbf22ab7 | Ruby | meranly8/reverse-each-word-onl01-seng-pt-090820 | /reverse_each_word.rb | UTF-8 | 421 | 4 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
words_in_reverse = [] #empty array to hold reveresed words
sent_to_array = sentence.split(" ") #split string into array
sent_to_array.collect do |word| #reverse each element/word and add to
reversed_word = word.reverse #reverse word
words_in_reverse << reversed_word ... | true |
7c80e620f208f27117e0bd19d914e49b7f4723f3 | Ruby | robb1e/magic_rails | /app/models/comments.rb | UTF-8 | 255 | 2.609375 | 3 | [] | no_license | class Comments
include Enumerable
attr_reader :post_id
def initialize args
@post_id = args[:post_id]
end
def each(&block)
Db::Comment.where(post_id: post_id).each do |comment|
block.call(Comment.new(comment))
end
end
end
| true |
c7b58c5fc9d3b07cf4da749d64c580e6cd76b28a | Ruby | buddylove954/practice-problems | /no_repeats.rb | UTF-8 | 501 | 3.578125 | 4 | [] | no_license | def no_repeats(year_start, year_end)
answer = []
while year_start <= year_end
if year_start.to_s.split("").uniq! == nil
answer << year_start
end
year_start += 1
end
answer.inspect
end
# Write a function, `no_repeats(year_start, year_end)`, which takes a
# range of years and outputs those y... | true |
a9e1f9ddc43dd8f287a5ae300131ac1a032c4e41 | Ruby | smart-rb/smart_types | /lib/smart_core/types/primitive/checker.rb | UTF-8 | 609 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# @api private
# @since 0.1.0
# @version 0.3.0
class SmartCore::Types::Primitive::Checker
# @param expression [Proc]
# @return [void]
#
# @api private
# @since 0.1.0
def initialize(expression)
@expression = expression
end
# @param value [Any]
# @param runtime_attrib... | true |
3c812dcf4eef1d1606c1efc096edcc873e9b5d65 | Ruby | DMazzei/log-analyser | /bin/display_output.rb | UTF-8 | 1,360 | 3.171875 | 3 | [
"MIT"
] | permissive | class DisplayOutput
def print_table(description, list)
output = ''
output.concat(format_header(description), "\n") unless description.empty?
output.concat(format_list(list))
print_output(output)
end
def print_header(text)
print_output(format_header(text))
end
def print_list(list)
pri... | true |
3d99558a3ed3005d840b47dbf412f28ce1035110 | Ruby | Diazware12/GIGIH_BE_Bangsa | /module3/session1/db_connector.rb | UTF-8 | 3,300 | 2.84375 | 3 | [] | no_license | require 'mysql2'
require_relative 'items'
require_relative 'category'
def create_db_client
client = Mysql2::Client.new(
:host => "localhost",
:username => "root",
:password => "",
:database => "food_oms_db"
)
client
end
def get_all_item
client = create_db_client
raw... | true |
e0d70f7183ecbecf58c44cb22d6d1582e9b86d53 | Ruby | subbat9710/Favorite_number | /app.rb | UTF-8 | 1,453 | 2.8125 | 3 | [] | no_license | require 'sinatra'
get '/' do
erb :get_name
end
post '/name' do
name = params[:user_name]
erb :get_location, :locals => {:name => name}
end
post '/location' do
location = params[:user_location]
name = params[:user_name]
erb :get_age, :locals => {:name => name, :location => location}
end
post '/age... | true |
2124a58d29be55dce24e337601eb818533f07305 | Ruby | RanaSulaiman/stacks-queues | /lib/job-simulation.rb | UTF-8 | 2,505 | 3.640625 | 4 | [] | no_license | require './Stack.rb'
require './Queue.rb'
class JobSimulation
#attr_reader :workers, :waiting, :roll
def initialize (job_seekers)
jobs_available = 6
jobs_waiting = job_seekers - jobs_available
@workers = Stack.new
jobs_available.times do |i|
@workers.push("Worker ##{ i + 1 }")
end
... | true |
cb7fd3df4d662b1637220a6181e6a24aa30ff40b | Ruby | nakamurahitoshi/searchat-tokyo | /app/views/stations/search.json.jbuilder | UTF-8 | 471 | 2.890625 | 3 | [] | no_license | json.array! @nearby_station do |station|
if station != nil
# 駅が取得できたら、各情報を返す
json.id station[:stobj].id
json.name station[:stobj].name
json.lat station[:stobj].lat
json.lng station[:stobj].lng
json.dist station[:dist].round # 小数以下は四捨五入
else
# 取得できなかった駅の情報はnullにする
json.id nil
json... | true |
aa40f90cd17cc387bd067996f490bb093ae68858 | Ruby | erebor/switchvox | /lib/switchvox/array.rb | UTF-8 | 329 | 3.28125 | 3 | [
"MIT"
] | permissive | # A fancy way of iterating over an array and converting hashes to objects
class Array
def to_obj
# Make a deep copy of the array
a = Marshal.load(Marshal.dump(self))
a.each do |i|
case i.class.to_s
when "Hash" then i = i.to_obj
when "Array" then i = i.to_obj
end
end
a
... | true |
a66f51105a7cd90509575112dcc03dca5bc24219 | Ruby | zishe/problems | /euler_project/2 level/064.rb | UTF-8 | 798 | 2.75 | 3 | [] | no_license | # √2=[1;(2)], period=1
# √3=[1;(1,2)], period=2
# √5=[2;(4)], period=1
# √6=[2;(2,4)], period=2
# √7=[2;(1,1,1,4)], period=4
# √8=[2;(1,4)], period=2
# √10=[3;(6)], period=1
# √11=[3;(3,6)], period=2
# √12= [3;(2,6)], period=2
# √13=[3;(1,1,1,1,6)], period=5
# √14=[3;(1,2,1,6)], period=4
# √42 = [6;2,12]
res = 0
ps = (... | true |
9854a481d3309909f20e410898f0ec7b50b6d011 | Ruby | torresga/launch-school-code | /exercises/101-109_small_problems/easy_6/fibonacci_number_length.rb | UTF-8 | 2,538 | 5 | 5 | [] | no_license | # Fibonacci Number Location By Length
# The Fibonacci series is a series of numbers (1, 1, 2, 3, 5, 8, 13, 21, ...) such that the first 2 numbers are 1 by definition, and each subsequent number is the sum of the two previous numbers. This series appears throughout the natural world.
# Computationally, the Fibonacci se... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.