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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
351f17941cb9d20dd9d424d2254f09cd514ad504 | Ruby | JunZhuSecurity/d3-charts | /s.autoscout/prepare.rb | UTF-8 | 1,327 | 2.734375 | 3 | [] | no_license | require 'csv'
require 'json'
require 'FileUtils'
require 'Time'
TIME = 0
CPU = 26 # data[0].find_index('CPU') #note that the TCP header was forgotten
RAM = 27
FileUtils.chdir(__dir__)
start = Time.now - 20 * 24 * 60 * 60
result = []
(1..6).each do |i|
data = CSV.read("monitoring/lcdnscv00#{i}.csv").drop(1)
dat... | true |
0872134d89ae49b58d4b6804c6293c2902b48906 | Ruby | pelf/euler | /p18.rb | UTF-8 | 2,194 | 3.1875 | 3 | [] | no_license | triangle_s = <<-triangle
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 3... | true |
c2523e001f9f20c140a9df7d0855903760d4e5ae | Ruby | drumnation/badges-and-schedules-web-0217 | /conference_badges.rb | UTF-8 | 1,092 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # should return a formatted badge
def badge_maker(name)
"Hello, my name is #{name}."
end
# should return a list of badge messages
def batch_badge_creator(attendees)
badge_messages = Array.new
# creates a badge message for each attendee and shovels to the badge_messages array
attendees.each do |attendee|
b... | true |
6673a043c9eb8330e9e30f2ffb096fe4ef5213b9 | Ruby | IslamAzab/online_challenges | /strings_basic.rb | UTF-8 | 717 | 3.6875 | 4 | [] | no_license | =begin
Given an ASCII string, find the sum of all the numeric characters in the string.
For example, for 'abc1234z' the sum of all numeric characters is .
What is the sum of all the numeric characters in the string below?
'96h11k4959q615948s50922o38h1453ij38w73413d5577lzrqw3780b389750vf100zd29z73j5wh73l6965n85vm77cw10... | true |
c08860371fdd628f281ecc1190e6b9e3b79334e9 | Ruby | Walle06/firstRubyHW | /myprogram.rb | UTF-8 | 1,782 | 4.09375 | 4 | [] | no_license | def america(x)
x= x+ "...ONLY IN AMERICA!"
puts x
end
america("The terminator was Governor")
math = [5,10,20,100]
puts math[3]
def func(v)
[10,20,30,50]
if v > 40
puts v
end
end
func(60)
A = ['corvette: ','mustang: ','porsche: ']
B = ['fast','strong','flashy']
def func()
puts A[0] + B[0]
puts A[1] + B[... | true |
867aa0d2ce801bcaf0cc18b68d4cdf516a1964a8 | Ruby | anthonynavarre/Katas | /ruby/2010.08.05-bowling/frame.rb | UTF-8 | 1,245 | 3.234375 | 3 | [] | no_license | class Frame
# Add a roll to this frame instance.
# Return self since this is the primary means
# of interacting with a Frame instance.
def roll(i)
rolls.push i
self
end
# Frame#score calculates the score of this frame.
# Intentionally returns nil for strikes and spares
# unless the needed ... | true |
1b116ec679d9db46ce0e22ff605107faea386d62 | Ruby | kai5016/ccc | /ccc/InvestigateCrawledData/NormalizedChecker.rb | UTF-8 | 2,750 | 2.796875 | 3 | [] | no_license | # -*- encoding: utf-8 -*-
require 'nokogiri'
require '..\Dao\ScrapeResultDao'
require '..\Dao\CharCountDao'
require '..\eprun\lib\string_normalize'
class NormalizedChecker
def initialize(log = nil)
@log = log || Logger.new("crawlData.log")
end
attr_reader :log
# ベトナム語の1文字辺りの出現数をカウントする
def count_charact... | true |
22a591dcb0c6cd5da5bd8d04582850561efb6f82 | Ruby | randywallace/CalMon | /lib/CalMon/Client/Client.rb | UTF-8 | 848 | 2.921875 | 3 | [
"MIT"
] | permissive | #
# Author:: Randy D. Wallace Jr. (mailto:randy@randywallace.com)
# Copyright:: Copyright (c) 2012 Randy D. Wallace Jr.
# License:: MIT
#
require 'jimson'
module CalMon
# This class handles attaching the observer to the JsonRPC server and
# starting the server.
class Client
attr_reader :host, :port
... | true |
02ab6e67a1ae6481b7175d618b2846c4b7531b6d | Ruby | erodxd/square_array-dumbo-web-career-021819 | /square_array.rb | UTF-8 | 108 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each{|ele| new_array.push(ele*ele)}
return new_array
end
| true |
0cc583309d56d0a7a0da7108328b4ec1e403365d | Ruby | Avoarisera/exo_ruby_vendredi | /exo_11.rb | UTF-8 | 89 | 3.171875 | 3 | [] | no_license | puts "Donnez moi un nombre"
nbr=gets.to_i
nbr.times do |n|
puts"Salut, ça farte ?"
end | true |
f6525f6939e7f5a54bbab577097e708cdcff9852 | Ruby | azendoo/bmo | /lib/bmo/apns/notification.rb | UTF-8 | 2,956 | 2.671875 | 3 | [
"MIT"
] | permissive | module BMO
module APNS
# The Notification Class handles all the packaging logic
class Notification
# Define ==
include Equalizer.new(:device_token, :payload)
attr_reader :device_token, :payload
def initialize(device_token, payload, options = {})
@device_token = DeviceToken.ne... | true |
85f5dd3d4a77585edb308488248fc3aa99045c56 | Ruby | pwnall/rtunnel | /lib/rtunnel/command_protocol.rb | UTF-8 | 1,438 | 2.640625 | 3 | [
"MIT"
] | permissive | module RTunnel::CommandProtocol
include RTunnel::FrameProtocol
# Sends an encoded RTunnel command as a frame.
def send_command(command)
command_str = command.to_encoded_str
if @out_command_hasher
send_frame command_str + @out_command_hasher.hash(command_str)
else
send_frame comman... | true |
4cfa70e1516623976daa8168f80843d282f7dfc1 | Ruby | curoles/verp | /lib/verp/VerpOptions.rb | UTF-8 | 2,372 | 2.515625 | 3 | [] | no_license | =begin rdoc
Description:: Verp command line options
Copyright:: Igor Lesik 2014
Author:: Igor Lesik
License:: Distributed under the Boost Software License, Version 1.0.
(See http://www.boost.org/LICENSE_1_0.txt)
=end
require 'optparse'
require 'optparse/time'
require 'ostruct'
# VERP... | true |
04ded6f50d928fa7e723fad8a4dba9b81f60d496 | Ruby | zvrba/rubyrpn | /rpl/syswords.rb | UTF-8 | 1,918 | 3.28125 | 3 | [
"MIT"
] | permissive | #
# Implementation of system words -- stack manipulation, etc.
#
module RPL
class Words
def Words.register_stack_dict rpl
rpl.instance_exec do
defop("drop", [Object]*1) { |x| nil }
defop("dup", [Object]*1) { |x| [x,x] }
defop("over", [Object]*2) { |x,y| [x,y,x] }
... | true |
dd882a14ac830a9154f4f1fba97302c56ad560a5 | Ruby | youssefbenlemlih/ruby-practice | /ptp3/interface.rb | UTF-8 | 2,321 | 3.5625 | 4 | [] | no_license | # Author:: Youssef Benlemlih
# Author:: Jonas Krukenberg
# This class manages frontend interaction with the user,
# validates inputs, outputs results
require_relative 'converter'
class Interface
attr_reader :converter
# Set up some essential attributes
def initialize
@converter = Converter.new
@all_units... | true |
d2f105e326fd779bccdf3a250cc952c2859072a5 | Ruby | rwash/contribute | /app/models/project_actions/activate.rb | UTF-8 | 804 | 2.71875 | 3 | [] | no_license | require 'routing'
module ProjectActions
class Activate
include Routing
def initialize project
@project = project
end
def text
'Activate your project to receive contributions'
end
# TODO formatting
def description
"Take some time to look over your project and make sure... | true |
aff5dcb3dffdc72c1de4a8098b4926a775639ed0 | Ruby | kleberkunha/-TheHackingProject_Full_content | /TheHackingProject_FUll_content/Ruby_Exercises_Tuesday/exo_04.rb | UTF-8 | 164 | 3.828125 | 4 | [] | no_license | puts "Type the year that you were born:"
year = gets.chomp()
puts "In the year of #{100 + year.to_i} you will have 100 years, or maybe you will not even get there!" | true |
c80073043505d811adcf62c38d356d6521cc408e | Ruby | hariniaina/exercice-ruby | /exo_7_c.rb | UTF-8 | 127 | 2.859375 | 3 | [] | no_license | user_name = gets.chomp
puts user_name
# affiche just un chomp pour l'utilisateur ,et affiche la chaine écrit par l'utilisateur | true |
4800806c93f73f4c559b9d2e2cba23727963443c | Ruby | picodegallo/student-rails | /lib/scraper.rb | UTF-8 | 1,761 | 2.84375 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
class StudentScrape
attr_reader :doc
def initialize(profile)
@profile = profile
end
def doc
@doc ||= Nokogiri::HTML((open(@profile)))
end
def name
self.doc.search('div.page-title h4.ib_main_header').text.strip
end
def image
self.doc.search("img.... | true |
549bbca75ebfd3c3424ca17d99e3e5aa9bad7f4d | Ruby | chet-k/DSA-Problems | /bst_to_greater_search_tree.rb | UTF-8 | 1,502 | 3.5 | 4 | [] | no_license | =begin
submitted as part of mock assessment
https://leetcode.com/submissions/detail/551804341/
https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/
Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such
that every key of the original BST is changed to the original key plus sum... | true |
2628fbca7c8c9ed99fe48657beccc70629de9c69 | Ruby | ToniRib/headcount | /test/highschool_graduation_test.rb | UTF-8 | 3,871 | 3.375 | 3 | [] | no_license | require 'minitest'
require 'highschool_graduation'
class HighschoolGraduationTest < Minitest::Test
def test_class_exists
assert HighschoolGraduation
end
def test_can_be_initialized_with_data
data = { 2007 => 0.513, 2008 => 0.475 }
h = HighschoolGraduation.new(name: 'ACADEMY 20', data: data )
as... | true |
d792e5ea9b5858973a2398ee7dfe7c0664b224f5 | Ruby | abhayachauhan/pact-mock-service-standlone | /pact-mock-service-0.5.1-1-linux-x86_64/lib/vendor/ruby/2.1.0/gems/pact-support-0.4.0/spec/lib/pact/matching_rules/extract_spec.rb | UTF-8 | 2,562 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'pact/matching_rules/extract'
require 'pact/something_like'
require 'pact/term'
module Pact
module MatchingRules
describe Extract do
describe ".call" do
subject { Extract.call(matchable) }
context "with a Pact::SomethingLike" do
let(:matchable) do
{
... | true |
db1e2b112a9488464851980aa00f397e3bdd3f8a | Ruby | jtlai0921/PG20249_example | /PG20249_sample/Ruby268-SampleProgram-BIG5/Ch11/sample262-02.rb | BIG5 | 133 | 3.09375 | 3 | [] | no_license | def counts
if block_given? # ϶
yield 1
yield 2
yield 3
else # L϶
[1, 2, 3]
end
end
| true |
05d6c290054f01e21eb21aa499cc58001bca0c43 | Ruby | GRoguelon/ogc | /test/ogc/core_ext/string_test.rb | UTF-8 | 819 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'active_support/core_ext/string/strip'
module Ogc
class StringTest < TestCase
setup do
@xml = <<-XML.strip_heredoc
<class name="FakeClass"
extends="Object">
<methods>
<class-method name="clean" arity="1">
<arguements>... | true |
6f173bf66d969f4f1b600b9a9bbdf238f14674b6 | Ruby | markfranciose/drops_of_knowledge | /ruby/procs.rb | UTF-8 | 1,609 | 4.1875 | 4 | [
"MIT"
] | permissive | p = Proc.new { puts "Hello World"}
p.call
puts p.class
a = p
puts p
def multiple_procs(proc1, proc2)
proc1.call
proc2.call
end
a = Proc.new { puts "First proc" }
b = Proc.new { puts "Second proc" }
multiple_procs(a,b)
proc = Proc.new {puts "What's up dirty dogs?"}
lam = lambda { puts "What IS up dirty dogs??"... | true |
0d0ad2e8697fa871b807c2e1ef38afbdb282147f | Ruby | mixandgo/singleton_pattern | /lib/custom_singleton.rb | UTF-8 | 269 | 3.421875 | 3 | [] | no_license | class CustomSingleton
attr_reader :name
private_class_method :new
def initialize(name)
@name = name
end
def self.instance(name)
@instance ||= new(name)
end
end
puts CustomSingleton.instance("John").name
puts CustomSingleton.instance("Mary").name
| true |
01579e443e4a4a4e726a1b02582e64be06dc3c5b | Ruby | jmetev1/ttt-6-position-taken-rb-q-000 | /lib/position_taken.rb | UTF-8 | 314 | 3.46875 | 3 | [] | no_license | # code your #position_taken? method here!
#board=Array.new(9," ")
def position_taken?(board, index)
if board[index]==" "
false
elsif board[index]==""
false
elsif board[index]==nil
false
else
true
end
end
board=[" ", " ", " ", " ", " ", " ", " ", " ", " "]
output=position_taken?(board,0)
| true |
ea82bfbf4710dc05b9263bd79c868e4185ef286f | Ruby | cbeer/marc-msgpack | /lib/marc/msgpack.rb | UTF-8 | 1,782 | 2.53125 | 3 | [
"MIT"
] | permissive | require "marc/msgpack/version"
require 'msgpack'
require 'zlib'
require 'stringio'
require 'marc'
require 'marc/msgpack/reader'
require 'marc/msgpack/writer'
module MARC
module Msgpack
class Error < StandardError; end
class TruncatedLeader
def initialize(leader)
@leader = leader
end
... | true |
4132424c9c3dcbff5a844d08e2c19b11d6fb5324 | Ruby | evandrix/Splat | /doc/existing-work/revolve-ruby-GA-testing/spec/program/crossover_spec.rb | UTF-8 | 633 | 2.796875 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), "..", "spec_helper")
module Revolve
describe Program, "#crossover" do
before do
@parent = Program.new(1, 2, 3, 4, 5)
@mate = Program.new("one", "two", "three", "four", "five")
@child = @parent.crossover(@mate)
end
it "should produce a new Program" do
... | true |
ff74a8243d8b083732702cbe428dfaf4508c2e2a | Ruby | 23years/tensorflow | /lib/tensorflow/keras/models/sequential.rb | UTF-8 | 571 | 2.546875 | 3 | [
"MIT"
] | permissive | module TensorFlow
module Keras
module Models
class Sequential
def initialize(layers = [])
@layers = []
layers.each do |layer|
add(layer)
end
end
def add(layer)
@layers << layer
end
def compile(optimizer: nil, loss... | true |
1af759517125168fa994dcc2e418bec6fd3f7e8f | Ruby | vjoel/redshift | /doc/algorithms.txt | UTF-8 | 8,315 | 2.75 | 3 | [
"Ruby"
] | permissive | #!ruby docs
=begin
run n:
if not started
do_setup
started = true
step_discrete
for n steps
step_continuous
step_discrete
step_continuous:
for rk_level from 0 to 4
for each component
for each continuous var
if rk_level == 0
... | true |
d699d82a732d6a31bbd8cbfacb7cdc0401646192 | Ruby | txus/mayl | /lib/mayl/commands.rb | UTF-8 | 614 | 2.578125 | 3 | [
"MIT"
] | permissive | module Mayl
# Public: The Commands module is a namespace for all the commands that Mayl
# uses.
module Commands
def self.autocomplete(line, env)
key = line.split.first || ''
# Try to get namespaces or keys
keys = env.autocomplete(key)
return keys if keys.any?
# If not, autocomp... | true |
c1d4422953dfd5a96647bf389e7eb6deda5b049f | Ruby | lure/ProLang | /hw7/hw7testsprovided.rb | UTF-8 | 16,472 | 3.578125 | 4 | [] | no_license | # University of Washington, Programming Languages, Homework 7,
# hw7testsprovided.rb
require "./hw7.rb"
# Will not work completely until you implement all the classes and their methods
# Will print only if code has errors; prints nothing if all tests pass
# These tests do NOT cover all the various cases, especial... | true |
d1ab67817a52d029c835961b9f8d5556309ac027 | Ruby | berto168/crud-with-validations-lab-web-0916 | /app/models/song.rb | UTF-8 | 785 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
validates :title, length: {minimum: 1}
# validates :released, inclusion: {in: %w(true false)}
validate :must_have_valid_release_year
validates :artist_name, length: {minimum: 1}
validate :cannot_repeat_song_by_same_artist
def must_have_valid_release_year
if released && ... | true |
d79f23d933e493875489730e41f44ac042e9b73b | Ruby | debona/Releaser | /release.rb | UTF-8 | 3,737 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'pp'
require 'erb'
def main()
# Global settings
# working_dir = File.join(File.dirname(__FILE__), 'tmp')
conf_dir = File.join(File.dirname(__FILE__), 'conf')
options = {
root_build_dir: "#{ENV['HOME']}/Workspace/Builds/",
environments: ['development',... | true |
f16269e060d29e35d4cf3f74b88bf28126f41454 | Ruby | adamkittelson/websocket-rails | /lib/websocket_rails/data_store.rb | UTF-8 | 2,459 | 3.140625 | 3 | [
"MIT"
] | permissive | module WebsocketRails
# Provides a convenient way to persist data between events on a per client basis. Since every
# events from every client is executed on the same instance of the controller object, instance
# variables defined in actions will be shared between clients. The {DataStore} provides a Hash
# that... | true |
97e2aa859bcf77461497dd2a17347e7d41641792 | Ruby | jweir/laminate | /test/laminate/state_test.rb | UTF-8 | 3,356 | 2.625 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../helper')
require 'logger'
require 'laminate'
require 'laminate/timeouts'
class Laminate::StateTest < Test::Unit::TestCase
include Laminate
module TestHelpers
def helper_method(str)
["head", str].join(" ")
end
end
context "options" do
se... | true |
4bb470818f90acb6ab5b32c1341a2b4e53a57602 | Ruby | lukemico/03-DOM-Model | /master/Week_04/day_02/Warmup/raindrops.rb | UTF-8 | 1,117 | 4.40625 | 4 | [] | no_license | # Warmup - Raindrops
#
# Write a program that will take a number (eg 28 or 1755 or 9, etc) and output the following:
#
# If the number contains 3 as a factor, output 'Pling'.
# If the number contains 5 as a factor, output 'Plang'.
# If the number contains 7 as a factor, output 'Plong'.
# If the number does not contain ... | true |
5d57630057196ebea7937b0559583c64a1cf24d2 | Ruby | abreaux26/war_or_peace | /test/turn_test.rb | UTF-8 | 10,319 | 3.296875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/deck'
require './lib/player'
require './lib/turn'
class TurnTest < Minitest::Test
def test_it_exists
card1 = Card.new(:heart, 'Jack', 11)
card2 = Card.new(:heart, '10', 10)
card3 = Card.new(:heart, '9', 9)
card4 =... | true |
90d4ffa090938a999ffde4f9a818d879daf43541 | Ruby | creyes-dev/fs_timestamper | /lib/fs_timestamper/filesystem/entry_composite.rb | UTF-8 | 1,149 | 2.9375 | 3 | [
"MIT"
] | permissive | module FsTimestamper
module FileSystem
# EntryComposite class
# Stores the filesystem path and the actual timestamps of a
# filesystem entry. It also stores a unique id, the modified
# timestamps that can be used to replace the actual filesystem
# entry filestamps. If something wrong happens ret... | true |
7cbb2bdaf30dc8ed2cf0c0e1b4299688198268ba | Ruby | aplarson/app_academy_coursework | /w1/w1d5/00_tree_node.rb | UTF-8 | 944 | 3.59375 | 4 | [] | no_license | class PolyTreeNode
attr_accessor :children, :value, :parent
def initialize(value)
@parent = nil
@children = []
@value = value
end
def parent=(parent_val)
@parent.children.delete(self) unless @parent.nil?
@parent = parent_val
(@parent.children << self).uniq! unless @parent.nil?
e... | true |
bbc9a768b69292c978663c0a589006ad4c9ed44e | Ruby | isabella232/hobo_fields | /lib/hobo_fields/command.rb | UTF-8 | 1,928 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'fileutils'
require 'tmpdir'
require 'rubygems'
module HoboFields
module Command
BANNER = <<~EOS
Usage:
hobofields new <app_name> [rails_opt] Creates a new HoboFields Application
hobofields generate|g <generator> [ARGS] [options] Fires... | true |
564eec5eb1b72d7a007ed4421a05a1fd839c775e | Ruby | apache/arrow | /ruby/red-arrow/test/test-sort-indices.rb | UTF-8 | 1,494 | 2.5625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause",
"ZPL-2.1",
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"NTP",
"OpenSSL",
"CC-BY-4.0",
"LLVM-exception",
"Python-2.0",
"CC0-1.0",
"LicenseRef-scancode-protobuf",
"JSON",
"Zlib",
"CC-BY-3.0",
"LicenseRef-scancode-unknown-licens... | permissive | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | true |
3ddc11e5e2fb72d77e8862035963aff56475135b | Ruby | rudyNK/key-for-min-value-noukod-000 | /key_for_min.rb | UTF-8 | 298 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
name_hash = {:chair => 25, :table => 85, :mattress => 450}
name_hash.min do { |key_for_min_value| }
puts "#{key_for_min_value}:"
end
end
| true |
3281142fba42aae110f6d6832fc48188cae62359 | Ruby | edmundo096/triangle-classification-cb-gh-000 | /lib/triangle.rb | UTF-8 | 574 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Triangle
# write code here
def initialize(a, b, c)
@a = a
@b = b
@c = c
end
def kind
sides = [@a, @b, @c]
invalid = sides.any? { |side| !side.is_a?(Numeric) || side <= 0 }
raise TriangleError if invalid
sides.sort! # Now, first is smallest, last is biggest.
invalid = (s... | true |
334ffda907ab9ab657283300e6576610f9af08d4 | Ruby | Taregnaeem/datastructures-and-algorithm | /ruby/learneroo/Shorting_Algorithms/array_sum.rb | UTF-8 | 117 | 3.046875 | 3 | [] | no_license | def do_stuff(ar)
puts ar.inject(0,:+)
end
inputs = [[1,3],[2,7,13],[5,8,22,11]]
inputs.each { |ar| do_stuff(ar) } | true |
7722016cf7ca8425a3ba7edb8382fbf10aa4dedd | Ruby | kgoettling/small_problems | /easy_1/easy_1_06_reverse2.rb | UTF-8 | 516 | 3.609375 | 4 | [] | no_license | def reverse_words(str)
new_str = []
str.split.each do |word|
if word.size >= 5
new_str << word.reverse
else
new_str << word
end
end
new_str.join(' ')
end
def reverse_words2(str)
sub_words = str.split.select { |word| word.size >= 5 }
sub_words.each { |word| str.gsub!(word, word.reverse) }
str
end
pu... | true |
e8b7db3e8ba60159aba5b68b5d66bf9a33c9030b | Ruby | Race4Hospiz/teamcontrol | /spec/models/stats_spec.rb | UTF-8 | 11,052 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'yaml'
RSpec.describe Stats do
it 'gets initialized w/ optional param' do
s = Stats.new [], [], [] # default param
expect(s.mode).to eq :both
s = Stats.new [], [], [], :leaving
expect(s.mode).to eq :leaving
end
it 'sorts events into order given by timestamp' do
... | true |
df94038fc382ea0cfebdbd39e79b79df03d8322d | Ruby | DuckOfDoom/hearthstoneRNN | /encode_decode.rb | UTF-8 | 1,603 | 3.328125 | 3 | [] | no_license | # encoding: UTF-8
require 'json'
if ARGV.size < 3
puts "Usage: \"encode_decode.rb -[e,d] input_file output file\""
exit
end
@encoded_fields = ["id", "name", "type", "text", "attack", "health", "cost", "durability", "playerClass", "mechanics", "race", "rarity", "faction", "flavor"]
# We can conve... | true |
d9feadc91ed616e448728483ea5ce51e7c384858 | Ruby | DoggettCK/exercism | /ruby/strain/strain.rb | UTF-8 | 369 | 3.15625 | 3 | [] | no_license | # Array strainer
class Array
def keep
return to_enum(:each) unless block_given?
inject([]) do |acc, x|
if yield x
acc << x
else
acc
end
end
end
def discard
return to_enum(:each) unless block_given?
inject([]) do |acc, x|
if yield x
acc
e... | true |
9903455f076475ecd808842aa1bd119ac2f6d526 | Ruby | IndicoDataSolutions/LaunchAcademy | /respond_to_tweets.rb | UTF-8 | 2,005 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'oauth'
require 'json'
$baseurl = "https://api.twitter.com"
$consumer_key = OAuth::Consumer.new(
"",
""
)
$access_token = OAuth::Token.new(
"",
""
)
def post_tweet(body)
path = "/1.1/statuses/update.json"
address = URI("#{$baseurl}#{path}")
request = Net::HTTP::Post.n... | true |
1126a2963c73c4c7f5c2c263509c24422a4d253f | Ruby | smart-rb/smart_operation | /lib/smart_core/operation/result/error/context.rb | UTF-8 | 569 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# @api public
# @since 0.1.0
class SmartCore::Operation::Result::Error::Context
# @return [Hash]
#
# @api private
# @since 0.1.0
EMPTY_CONTEXT = {}.freeze
# @return [Hash, Any]
#
# @api private
# @since 0.1.0
attr_reader :context
# @param context [Hash, Any]
# @r... | true |
f4f97ba113de7b89832b149d532378f363047843 | Ruby | kofronpi/google_distance_matrix | /lib/google_distance_matrix/url_builder.rb | UTF-8 | 1,567 | 2.5625 | 3 | [
"MIT"
] | permissive | module GoogleDistanceMatrix
class UrlBuilder
BASE_URL = "maps.googleapis.com/maps/api/distancematrix/json"
DELIMITER = CGI.escape("|")
MAX_URL_SIZE = 2048
attr_reader :matrix
delegate :configuration, to: :matrix
def initialize(matrix)
@matrix = matrix
fail InvalidMatrix.new matr... | true |
c77cc1a8234dbc5e6c545c2168257b81cda80e3f | Ruby | friendtu/ruby_hard_way | /projects/ex47/tests/test_ex47.rb | UTF-8 | 1,202 | 3.1875 | 3 | [] | no_license | require 'ex47/game.rb'
#require "test/unit"
require 'minitest/autorun'
#class TestGame<Test::Unit::TestCase
class TestGame<Minitest::Test
def test_room
gold=Room.new("GoldRoom","""This room has gold in it you can grab. There's a dor the north.""")
assert_equal(gold.name,"GoldRoom")
assert_e... | true |
6cf4ea3f147721aa563b73bfa23cfaa7c973182f | Ruby | jsh/beginningruby | /analyzer.rb | UTF-8 | 1,279 | 3.25 | 3 | [] | no_license | filename = (ARGV.first == nil) ? "oliver.txt" : ARGV.first
lines = File.readlines(filename)
# basic statistics
puts "#{l=lines.size} lines"
text = lines.join
puts "#{p=text.split(/\n\n/).length} paragraphs"
puts "#{s=text.split(/\.|\?|!/).length} sentences"
puts "#{w=text.split.length} words"
stop_words = %w{the a by ... | true |
69fbfb19386c0cbb6eb61765f4d5deadc27d660f | Ruby | b-enji-cmd/black_thursday | /lib/items.rb | UTF-8 | 1,080 | 2.953125 | 3 | [] | no_license | require 'time'
require 'bigdecimal/util'
require 'bigdecimal'
class Item
attr_accessor :name,
:description,
:unit_price,
:updated_at
attr_reader :id,
:merchant_id,
:created_at
def initialize (data, repository)
@id = ... | true |
b091a3bb2dd378d30190af3b79a3981800e90b36 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/beer-song/5ebcca58a98e4a1fa176f35e7e3a8458.rb | UTF-8 | 1,047 | 3.578125 | 4 | [] | no_license | class Beer
def verse number
case number
when 0 then last_verse
when 1 then verse1
when 2 then verse2
else verses(number)
end
end
def sing(start, finish = 0)
start.downto(finish).inject("") { |song, v| song << "#{verse(v)}\n" }
end
private
def verse1
"1 bottle of be... | true |
b863668c8a2dfb4a8841fe6146637ba3537ebc7e | Ruby | JelF/flame | /spec/unit/application/config_spec.rb | UTF-8 | 1,662 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
describe Flame::Application::Config do
before do
@app_class = Class.new(Flame::Application)
@hash = {
foo: 1,
bar: 2,
baz: proc { 3 },
another_baz: proc { |a| a * 2 }
}
@init = proc do |app: @app_class, hash: @hash|
Flame::Application::Config.new(app, hash)
end
... | true |
c881e1d001bff1d00aac7a4e6a3adcb1ad261b8d | Ruby | trinhducduy/blog-system | /app/models/user.rb | UTF-8 | 1,886 | 2.515625 | 3 | [] | no_license | class User < ActiveRecord::Base
has_secure_password
attr_accessor :remember_token
validates :name, presence: true, length: {minimum: 6}
validates :email, presence:true, length: {maximum: 255},
format: {with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i}
has_many :active_relationships, class_name: 'Relationsh... | true |
3ad0c3c7ac907d96317b6f3fb826207b868157ea | Ruby | ashleydavies/Graphick | /lib/column_selector.rb | UTF-8 | 260 | 3.15625 | 3 | [
"MIT"
] | permissive | class ColumnSelector
def initialize(column, separator)
@column = column
@separator = separator
end
def select(input)
input.split(@separator)[@column - 1].strip
end
def to_s
"ColumnSelector<#{@column} by '#{@separator}'>"
end
end | true |
01e4bf78f8334ae6de399a3774b9d4824b8e10b8 | Ruby | kprudnikov/RubyGarage | /OOP_Library/book.rb | UTF-8 | 543 | 2.984375 | 3 | [] | no_license | require_relative "modules"
module Lib
class Book
include Jsonable
attr_reader :title, :author, :times_taken, :id
def initialize(title, author, id)
raise TypeError, 'Title must be a strings' unless title.is_a?(String)
raise TypeError, 'Author must be an author' unless author.is_a?(Author)
... | true |
7c73653728d33a28736669e069f6c9d5a60c1a6d | Ruby | iamdeveloper-me/new_doxly | /app/models/file_convert.rb | UTF-8 | 6,682 | 2.546875 | 3 | [] | no_license | include Asposewordsjavaforruby
# This class takes care of processing all the coversions using the tools as needed
class FileConvert
SUPPORTED_FILE_FORMATS = [".doc", ".docx", ".htm", ".html", ".ods", ".odt", ".rtf", ".txt", ".xls",
".xlsm", ".xlsx", ".xml", ".xsd", ".odp", ... | true |
8121438921ea9a3af14549b430542a277007375a | Ruby | tomsitter/realtime-hsr-map | /Rakefile | UTF-8 | 1,326 | 2.859375 | 3 | [] | no_license | # Rakefile
require "./app"
require "csv"
require "json"
require "sinatra/activerecord/rake"
class CSVImporter
def import_all!
self.import 'routes.txt', 'Route'
end
def import(file_name, class_name)
puts "Importing #{class_name}s..."
klass = Object::const_get( class_name )
k... | true |
49fd23d9e7645d7547499a15a932480d9beafac3 | Ruby | fcruzat/desafio_estructuras_de_control | /desafio_estruct_ejercicio_1.1.rb | UTF-8 | 177 | 3.4375 | 3 | [] | no_license | #1.1 Modifica la condición para que se cumpla.
# a = 2
# if a == 'saludo'
# puts 'La condición es verdadera.'
# end
a = 2
if a == 2
puts 'La condición es verdadera.'
end | true |
961335189ffc867c176fcfaa625f637e82977148 | Ruby | matsueJ1451/git-tutorial | /bin/fizzbuzz.rb | UTF-8 | 243 | 2.6875 | 3 | [] | no_license | in 1..100
if i%15 == 0 then
printf("FizzBuzz\n")
elsif i%3 == 0 then
printf( "Fizz\n")
elsif i%5 == 0 then
printf( "Buzz\n")
//7の倍数のときgitと言う
elsif i%7 == 0 then
printf("git")
else
printf("%d\n", i)
end
end
| true |
be00607b086c8da8ac839bb7872a925f9fd197c1 | Ruby | dandrust/vm_translator | /lib/instruction/arithmetic.rb | UTF-8 | 2,347 | 3.375 | 3 | [] | no_license | class Instruction
# Translates arithmetic instructions
class Arithmetic < Instruction
class << self
attr_accessor :jump_counter
end
OPERATION_SYMBOLS = {
add: '+',
sub: '-',
neg: '-',
and: '&',
or: '|',
not: '!'
}.freeze
JUMP_CONDITIONS = {
eq: ... | true |
14a72b1b31550be155771a2bf65a7aea854c6397 | Ruby | MikesUptown/bewd_10_nyc_homework | /_Mike_Lewis/Homework/ex_apartment_objects/lib/\.rb | UTF-8 | 382 | 3.328125 | 3 | [] | no_license | #Building Class
class Building
#attr_accessor :building_name, :building_address
attr_accessor :apartments
def initialize
@apartments = ["building_name", "building_address"]
end
def initialize(building_name, building_address)
@building_name = building_name
@building_address = building_address
end
def to... | true |
60f790ba22c1e66d5ec0493d95372e19bee340cb | Ruby | illiteratelinds/CrackingCode | /ArraysAndStrings/1.6.rb | UTF-8 | 588 | 4.21875 | 4 | [] | no_license | # Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?
matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
def rotate_clockwise(matrix)
rotated = []
matrix.transpose.each do |array|
... | true |
d699a721ff3612e092daeffb2279d49ade1bd9fa | Ruby | wonderfulkasey/rubycliproject | /lib/fortune/company.rb | UTF-8 | 556 | 3.078125 | 3 | [] | no_license | class Fortune::Company
attr_accessor :number, :name, :website_url
@@all = []
def initialize(hash)
hash.each {|k, v| self.send("#{k}=", v)}
@@all << self
end
def self.display_details(index)
c = self.all[index]
puts "---------------"
puts "That company is #{c.name}."
puts "Here... | true |
1816ffe5f76c9fd6deedcb12e4d476e8d0644060 | Ruby | grooves/engineer_training | /KIRAryo1/ruby_training/ruby_book/lib/class_foo.rb | UTF-8 | 284 | 3.4375 | 3 | [] | no_license | class Foo
# this puts is called when class definition is loaded
p "self under_direct class statement: #{self}"
def self.bar
p "self in class method: #{self}"
end
def baz
puts "self in instance method: #{self}"
end
end
puts Foo.bar
puts foo = Foo.new
puts foo.baz
| true |
f232bdb63f0425ef6edec810772f6bdd33bc17a9 | Ruby | Nizamovpl/money-bomb | /moneybomb.rb | UTF-8 | 7,045 | 2.96875 | 3 | [] | no_license | require 'gosu'
# I forgot to commit the file ; I finished it last night
#sorry I coulodn't commit it until 6 PM I had a job interview
#anyways this isn't done, but I haven't finished all the buggs though I was so close
#click/press keys to start/reset
#check spelling errors
# https://www.rubydoc.info/github/gosu/gosu/... | true |
a5f4c5101feca3ac6fc83de7b2e3b9a1c3f9c647 | Ruby | CDLUC3/stash | /stash-harvester/lib/stash/indexer/metadata_mapper.rb | UTF-8 | 1,797 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'config/factory'
require 'stash/wrapper'
module Stash
module Indexer
# Superclass of installation-specific mappers converting wrapped metadata to
# indexable documents.
class MetadataMapper
include ::Config::Factory
key :metadata_mapping
attr_reader :opts
def initializ... | true |
853de62bd9b4b996c0eb1d3d2cdb76f7f8790722 | Ruby | JeffWHenderson/top-documentary-cli-app | /lib/scraper.rb | UTF-8 | 853 | 2.734375 | 3 | [
"MIT"
] | permissive | class Scraper
attr_accessor
def self.current_movies
@@current_movies
end
def self.scrape_home_page(url = "https://topdocumentaryfilms.com/")
doc = Nokogiri::HTML(open(url))
category = doc.search("ul.cat-list a")
category.each_with_index do |x, i|
Category.new("#{x.text}", "#{x.attr('href')... | true |
e07bd2edf5e1af8597ad622059bb6243f9c5c717 | Ruby | kodywilson/RubyWinter2014 | /week3/exercises/vampire.rb | UTF-8 | 266 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | require './monster.rb'
class Vampire < Monster
def initialize(noc=true, legs=2, name ="Vampire", vul=[:garlic, :sunlight], dangers=[:bites])
super(noc,legs,name,vul,dangers)
end
def bite! human
end
def attack! human
puts "hi from Vampire"
end
end
| true |
35b522cb22a0fe77ac53a43eafada32cfdff23f0 | Ruby | kinsbrunner/challenges | /luhn/lib/luhn.rb | UTF-8 | 278 | 3.4375 | 3 | [] | no_license | module Luhn
def self.is_valid?(number)
digits = number.to_s.split("")
digits.reverse!.map!.with_index {|digit, i| i.odd? ? digit.to_i * 2 : digit.to_i }
digits.map! {|digit| digit > 9 ? digit - 9 : digit}
digits.reduce(0, :+) % 10 == 0 ? true : false
end
end | true |
e9dfd2d26eb7d49f017a0ff2ac687505e781f743 | Ruby | reidjs/rubybattleship | /spec/board_spec.rb | UTF-8 | 5,711 | 3.28125 | 3 | [] | no_license | require "rspec"
require "board"
require "byebug"
describe Board do
subject(:board) { Board.new }
let(:empty_grid) { Array.new(3) { Array.new(3) } }
let(:empty_board) { Board.new(empty_grid) }
let(:two_ship_grid) { [
[:s, :s, nil],
[nil, nil, nil],
[nil, nil, nil],
[nil, nil, nil]] }
let(:tw... | true |
4c7925f53c11718b828808ac7932687940a138ad | Ruby | tstromberg/dump | /domainfinder/make-wordfile.rb | UTF-8 | 853 | 3.46875 | 3 | [] | no_license | #!/usr/bin/env ruby
# pass me some input and I will attempt to extract normal looking words out of it.
min_occurances = (ARGV[0] || 1).to_i
min_word = 3
max_word = 24
used={}
$stdin.each do |line|
# clean out any HTML on the line.. kind of wasteful.
line.gsub!(/\<.*?\>/, '')
# split the line into words seper... | true |
6b692d237515baf3d1a08871f7bd1eac8f77603f | Ruby | Kashiwara0205/Pokotarou | /lib/pokotarou/registration_config_maker/template_option_setter.rb | UTF-8 | 2,102 | 2.546875 | 3 | [
"MIT"
] | permissive | require "pokotarou/registration_config_maker/config_domain.rb"
module Pokotarou
module RegistrationConfigMaker
class TemplateOptionSetter
class << self
def set all_content
templates = fetch_template_option(all_content)
all_content.each do |key, block_content|
next ... | true |
362ffc2f60ae20174215a1acbe6de515c66e6ede | Ruby | jim/bitbar-scripts | /ruby/calendar_menu.rb | UTF-8 | 1,659 | 2.515625 | 3 | [] | no_license | require_relative "lib"
require "json"
require "time"
require "active_support/core_ext/numeric/time"
require "action_view"
require "action_view/helpers"
include ActionView::Helpers::DateHelper
ten_min_ago = Time.now - min(10)
ten_min_since = Time.now + min(10)
ten_hours_since = Time.now + min(10 * 60)
events_json = ... | true |
28e66ff98493d2c95f5cacaf0d7cdb6b2dc81d98 | Ruby | gmacdougall/advent-of-code | /2020/19/part1.rb | UTF-8 | 525 | 2.84375 | 3 | [] | no_license | #! /usr/bin/env ruby
# frozen_string_literal: true
input = ARGF.lines.map(&:strip)
RULES = input[0...input.index('')].map { |s| s.split(': ') }.to_h
values = input[(input.index('') + 1)..]
def resolve(rule)
if rule.start_with?('"')
rule.gsub('"', '')
elsif rule.include?(' | ')
"(#{rule.split(' | ').map { ... | true |
43caa7ee061cf046bc7ff04a4608c9431e547bc4 | Ruby | nptravis/ruby-objects-belong-to-lab-v-000 | /lib/artist.rb | UTF-8 | 138 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name, :genre
# def initialize
# @name=name
# @genre=genre
# end
# def name
# @name
# end
end
| true |
e0005254fa1aa77eaba0fec81955e25f993d8385 | Ruby | brandfolder-archive/jsonapionify | /lib/jsonapionify/structure/objects/attributes.rb | UTF-8 | 1,453 | 2.515625 | 3 | [
"MIT"
] | permissive | module JSONAPIonify::Structure
module Objects
class Attributes < Base
# Attributes may contain any valid JSON value.
# Complex data structures involving JSON objects and arrays are allowed as
# attribute values. However, any object that constitutes or is contained in an
# attribute **MUST... | true |
b221897421f10858bcaed26e34ba3880713499b9 | Ruby | JaimeLynSchatz/rthw.exercises | /ex20extra.rb | UTF-8 | 2,094 | 4.03125 | 4 | [
"MIT"
] | permissive | puts Dir.pwd
# takes the command line argument and assigns it to input_file
input_file = ARGV[0]
# defines the print_all function which will work on a file paramenter
def print_all(f)
# print what is read from the file
puts f.read()
# ends the print_all function definition
end
# defines the rewind function, which t... | true |
d350cb918871cd03a695271deb1613d1b897fb50 | Ruby | innervisions/RB101 | /03_practice_problems/02_medium_1/05.rb | UTF-8 | 809 | 4.40625 | 4 | [] | no_license | # Ben's Code ##############
# limit = 15
# def fib(first_num, second_num)
# while first_num + second_num < limit
# sum = first_num + second_num
# first_num = second_num
# second_num = sum
# end
# sum
# end
# result = fib(0, 1)
# puts "result is #{result}"
# ########
# The issue with Ben's code is ... | true |
71bf0f9946e5bd6b0a15d3108131347e9b845978 | Ruby | bsgreenb/hackerrank | /coin.rb | UTF-8 | 824 | 3.6875 | 4 | [] | no_license | def getWays(n, c)
if n == 0
return 1
elsif n < 0
return 0
elsif c.count == 0
return 0
else
return getWays(n - c[0], c) + getWays(n, c[1..-1])
end
end
def getWaysMemoized(n, c)
answers = Array.new(n + 1) { Array.new(c.length) }
answers[0].each_with_index do |answer, i|
answers[0][i] = ... | true |
737e9438d0b09099d5f0982d28641ea3fda0a24e | Ruby | d0minikk/checkout | /app/logics/promotions/eligibility/validator.rb | UTF-8 | 706 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
module Promotions
module Eligibility
class Validator
def initialize(available_promotions)
@available_promotions = available_promotions
end
def eligible?(promotion, promotable, total: nil)
validator(promotable).eligible?(promotion, promotable, total... | true |
869555c069815afd8b7175a96778c531c4fc941d | Ruby | NewCircleMovement/ncm | /app/models/fruittype.rb | UTF-8 | 901 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: fruittypes
#
# id :integer not null, primary key
# name :string
# monthly_decay :float
# created_at :datetime not null
# updated_at :datetime not null
# epicenter_id :integer
#
"""
Every epicenter has it's own unique frui... | true |
c7e93bab4ad8daf11d03a5280c4a640ba9de985e | Ruby | railsdev/reminder_poc | /app/models/reminder.rb | UTF-8 | 3,555 | 2.515625 | 3 | [] | no_license | # == Schema Information
#
# Table name: reminders
#
# id :integer not null, primary key
# user_id :integer
# name :string(255)
# fq_type :string(255)
# interval :integer
# fq_month :integer
# fq_time :datetime
# created_at :date... | true |
03f0220011b298ff5b004c4fd85c6850a6d7f2d5 | Ruby | uybinh/hangman_game | /game.rb | UTF-8 | 2,107 | 3.828125 | 4 | [] | no_license | require "./lib/keyword.rb"
require "./lib/hangman.rb"
require "./lib/player.rb"
require "yaml"
def update_game_state(hangman, player, guess)
hangman.update_incomplete_word(guess)
update_player_state(hangman, player, guess)
end
def update_player_state(hangman, player, guess)
player.lives -= 1 if !hangman.guess_r... | true |
476040595c37547e8cac2a004af06c99c7ff89c9 | Ruby | jemise111/rubylearning | /3wk/9e_reverse_string.rb | UTF-8 | 586 | 3.984375 | 4 | [] | no_license | # 9e_reverse_string.rb
# Reverse the word order of a given string
=begin
doctest: reverse word order of a string
>> s = "This is test line one."
>> reverse_word_order(s)
=> "one. line test is This"
doctest: Lines are handled this way
>> s = "This is test line one.\nThis is test line two."
>... | true |
0d1d41a50d7573f84eabc1e673ca7548e769e1eb | Ruby | Swarzkopf314/maybe_loaded_relation | /lib/maybe_loaded_relation.rb | UTF-8 | 2,971 | 3.21875 | 3 | [
"MIT"
] | permissive | require "maybe_loaded_relation/version"
class MaybeLoadedRelation < SimpleDelegator
# Sometimes the association can be preloaded or not
# This allows you to avoid hitting the database when it's already preloaded
# while keeping the usual query syntax, example:
# pw = MaybeLoadedRelation.abstract_database!(sel... | true |
2351c123c74f25e5261cd4f0656a90aa54ca6458 | Ruby | bbg-deploy/madbooker-testing | /config/initializers/monkey_patches/object.rb | UTF-8 | 252 | 3.03125 | 3 | [] | no_license | class Object
def log color = :red
Rails.logger.debug inspect.send(color)
self
end
def to_bool
return false unless self
return false if self.to_s =~ /0|no|false/
true
end
def not_in?(*args)
!in?( *args)
end
end
| true |
3a66fc293adcc14a152be22a91bbf51dafa49bcd | Ruby | rahulpattanshetty/ruby-programs | /sq_dig.rb | UTF-8 | 158 | 3.03125 | 3 | [] | no_license | require 'pry'
number = 9119
output = []
number.to_s.split("").each do |num|
#binding.pry
output.push(num.to_i * num.to_i)
end
puts output.join("") | true |
65a3b0ebb9a922e8592a3998fb292268bb39e654 | Ruby | kelseybjames/learn_ruby | /15_in_words/in_words.rb | UTF-8 | 2,973 | 3.75 | 4 | [] | no_license | class Fixnum
def in_words
word = ""
number = self.to_s
word_hash = {"0" => "zero", "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five", "6" => "six", "7" => "seven", "8" => "eight", "9" => "nine", "10" => "ten", "11" => "eleven", "12" => "twelve", "13" => "thirteen", "14" => "fourtee... | true |
e87c4fe24d732766b1bb6c8a6c441ac398522ff9 | Ruby | technohippy/red-grape | /lib/ext/array_ext.rb | UTF-8 | 1,078 | 2.78125 | 3 | [
"MIT"
] | permissive | class Array
attr_accessor :should_pass_through_whole #TODO
def pass_through(pipe, context)
if @should_pass_through_whole
super
else
loops = context.loops
map! do |e|
context.loops = loops
pipe.pass e, context
end
context.loops = loops
normalize_for_graph... | true |
f8571823fe2ae7a707ba37f1759be025ac5fa1f9 | Ruby | jhoneto/ponto | /spec/controllers/office_hours_controller_spec.rb | UTF-8 | 6,470 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... | true |
ce9e87e4285574158321a95af736a7a86d14a24b | Ruby | rdbyrd/aresmush | /battle/commands/general/battle_action_command.rb | UTF-8 | 2,155 | 2.609375 | 3 | [] | no_license | module AresMUSH
module Battle
class BattleActionCommand
attr_accessor :names, :action_args, :combat_command
# parser function for handlilng user input for target names
def parse_args
if(cmd.args =~ /\=/)
self.names = InputFormatter.titlecase_arg(cmd.args.before("="))... | true |
9e9ecf1a641d083d0471a32e935b340beb75d608 | Ruby | nkrot/rufsl | /lesson.11.tasks/02.cstfilter/syn_mtag2mtag_cstfilter_stub.rb | UTF-8 | 423 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env ruby
# # #
#
#
def parse_mtag(line)
fields = line.split
wts = [] # word+tags
0.step(fields.length-1, 2) do |i|
wts << [fields[i], split_tags(fields[i+1])]
end
wts
end
def split_tags mtag
mtag.split('_') #.map {|tf| tf.split('/')}
end
while line = gets
line.chomp!
# TODO: write y... | true |
4dd108f8773ef75b98a07b0674c2bcca20b4a9a7 | Ruby | Meenakshi-Anand/Leetcode | /to_lower_case.rb | UTF-8 | 531 | 3.875 | 4 | [] | no_license | # question : 709
# Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
#
# Example 1:
#
# Input: "Hello"
# Output: "hello"
# Example 2:
#
# Input: "here"
# Output: "here"
# Example 3:
#
# Input: "LOVELY"
# Output: "lovely"
# @param {String} str
# @return {Strin... | true |
55d09afb898d510210101311ccae407b9daf523e | Ruby | shachsan/count-elements-dumbo-web-102918 | /count_elements.rb | UTF-8 | 105 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def count_elements(array)
animals = Hash.new 0
array.each {|animal|animals[animal]+=1}
animals
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.