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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36d2eff9b37ab9141e276a4fc40bba22bd0152e9 | Ruby | nvien/net-iot | /lib/external_api_request.rb | UTF-8 | 2,698 | 2.53125 | 3 | [] | no_license | require 'active_support/core_ext/hash/compact'
require 'active_support/core_ext/module'
class ExternalApiRequest
include HTTMultiParty
format :json
# Constants
RESPONSE_BODY_LOG_MAX_CHARACTER_COUNT = 200
BLACKLISTED_LOG_KEYS = %w(
access_token
APPLICATION_TOKEN
Authorization
authToken
c... | true |
427520a7b0b176f395cb35d04826d8a1df22ecb6 | Ruby | fog/fog-aws | /lib/fog/aws/requests/storage/copy_object.rb | UTF-8 | 3,681 | 2.53125 | 3 | [
"MIT"
] | permissive | module Fog
module AWS
class Storage
class Real
require 'fog/aws/parsers/storage/copy_object'
# Copy an object from one S3 bucket to another
#
# @param source_bucket_name [String] Name of source bucket
# @param source_object_name [String] Name of source object
... | true |
bf3f7c351011761114b71a34664d9746594afc12 | Ruby | drKreso/emenu | /lib/emenu/menu.rb | UTF-8 | 2,290 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class Menu
IDENTATION = 2
SPACE = " "
DEFAULT_SPACE = SPACE*IDENTATION
attr_reader :title, :items, :type, :path
def initialize(title, parent, config, path="#")
@title = title
@parent = parent
@config = config
@path = path
@items = []
@type = @parent.nil? ? :title : :menu
end
de... | true |
93fd3b1f1513aebb03f91ebc092a9bbc7dca010d | Ruby | grosser/gettext_i18n_rails_example | /vendor/plugins/valid_attributes/lib/valid_attributes.rb | UTF-8 | 1,981 | 2.796875 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | module ValidAttributes
# create a valid new record
# attributes are set separetly(no mass-assignment)
# valid User or valid 'user' or valid User, :name=>'Peter'
def valid(type,attributes={})
klas = type.to_s.camelcase.constantize
record = klas.new
valid_attributes(klas.to_s.underscore).merge(attribu... | true |
fe68f010e0ef13434e6273bb2b31f2baa363c95b | Ruby | DrummerKH/mysql2pg-replicator | /bin/processes/signals.rb | UTF-8 | 405 | 2.953125 | 3 | [] | no_license | module Replicator
class Signals
def self.term
$term.each(&:call)
end
def self.hup
$hup.each(&:call)
end
def self.subscribe(signal, &method)
if signal == 'term'
$term << method
elsif signal == 'hup'
$hup << method
end
end
end
$term = []
... | true |
63568ec3ac5f4898fbe731b77127309026bc72bb | Ruby | nikolaip33/ttt-with-ai-project-v-000 | /lib/genesis.rb | UTF-8 | 4,001 | 3.703125 | 4 | [] | no_license | class Genesis
def main_start
input = nil
puts "Welcome to TicTacToe."
puts "Please Choose a game mode:"
puts "(1). Human vs. Human"
puts "(2). Human vs. Computer"
puts "(3). Computer vs. Computer"
until input.to_i.between?(1,3)
input = gets.chomp
end
case input
when "1"
... | true |
7d0dfff34ae4785645bc12ab3e3180e5f8f7b6e1 | Ruby | dbacall/battleships_tech_test | /lib/board.rb | UTF-8 | 915 | 3.234375 | 3 | [] | no_license | class Board
def initialize
@layout = [["x", "x", "x", "x", "x", "x", "x", "x", "x"],
["x", "x", "x", "x", "x", "x", "x", "x", "x"],
["x", "x", "x", "x", "x", "x", "x", "x", "x"],
["x", "x", "x", "x", "x", "x", "x", "x", "x"],
["x", "x", "x", "x", "x", "x", "x", "x", "x"],
["x", "x", ... | true |
b3c91ddda721e78622af201395be512dfb37fa71 | Ruby | d-lange/phase-0 | /week-4/leap-years/my_solution.rb | UTF-8 | 267 | 3.0625 | 3 | [
"MIT"
] | permissive |
# Leap Years
# I worked on this challenge [with: Michael Wang].
# Your Solution Below
def leap_year?(year)
if year % 4 == 0
if year % 100 ==0
if year % 400 ==0
return true
end
return false
end
return true
end
return false
end | true |
0323dfaf980de627178aa68e552441ddaeefb5dd | Ruby | alexhanh/motivate | /lib/fineli.rb | UTF-8 | 2,974 | 2.703125 | 3 | [
"MIT"
] | permissive | # include Rails environment
# require File.expand_path("../../config/environment", __FILE__)
#doc = Nokogiri::HTML(open('mitat.html'))
class Fineli
def assign_food_units(product, unit_page)
s = unit_page.css("th:contains('Ruokamitta')").first.parent.next_sibling
volume_added = false
while !s.nil?
... | true |
06dee7c1e3a6b1a7d26006827144fd5924632a46 | Ruby | YourSouLi5Mine/trainee | /jorgePrecich/spotify/test.rb | UTF-8 | 622 | 2.515625 | 3 | [] | no_license | require 'active_support'
require_relative 'hash'
path = File.expand_path File.dirname(__FILE__)
autoload :Token, "#{path}/token"
autoload :Client, "#{path}/client"
puts 'Welcome to the Spotify Api Client'
puts '1.- Create a token -> token = Token.new.token'
puts '2.- Create a client -> client = Client.new(t... | true |
17937924e9c66cbff4f0e15caceea3b9ba74ad24 | Ruby | softcover/polytexnic | /lib/polytexnic/code_inclusion.rb | UTF-8 | 11,156 | 3 | 3 | [
"MIT"
] | permissive | module CodeInclusion
class CodeInclusionException < Exception; end;
class RetrievalException < CodeInclusionException; end;
class SubsetException < CodeInclusionException; end;
# Converts the CodeInclusion line to a set of arguments, i.e.:
# '%= <<(file.rb[6-14,37], git: {repo: repo_path/.git, ta... | true |
c1c409448238407d97513fd183d301ddb7572350 | Ruby | Pauwil5/Ejerc_entret | /bisiesto.rb | UTF-8 | 244 | 3.734375 | 4 | [] | no_license | puts "Ingrese el año"
a = gets.chomp.to_i
if a%400 == 0
puts "El año #{a} es bisiesto"
elsif (a%4 == 0 && a%100 < 0) #divisible por 4 pero no por 100
puts "El año #{a} es bisiesto"
else
puts "El año #{a} no es bisiesto"
end | true |
c8d36cc6928eb4791e5054898574ad4780c03c40 | Ruby | PhilippeVienne/OnlineClassroom | /app/models/ability.rb | UTF-8 | 1,295 | 2.578125 | 3 | [] | no_license | class Ability
include CanCan::Ability
def initialize(user)
# See the wiki for help on this file:
# https://github.com/ryanb/cancan/wiki/Defining-Abilities
guest=user.nil?
# If user does not logged, create an guest user
user||=User.new
subject_group=[Subject, Answer, PossibleAnswer, Ques... | true |
32785230909d4211337aa82ff699b50925ec7692 | Ruby | RJTaylor8286/reverse-each-word-online-web-pt-110419 | /spec/reverse_each_word_spec.rb | UTF-8 | 183 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | favorites = ("Zelda", "God of War", "NBA2K")
video_games(favorites)
favorites.collect do |favorites|
puts "The best video games are #{favorites}"
end
reverse_each_word(favorites) | true |
6ef196bccc66a14555e5c010491408ecde7bbd63 | Ruby | ikroni/ruby------------- | /C/main.rb | UTF-8 | 241 | 2.65625 | 3 | [] | no_license | radius = File.open('radius.in','r'){|file| file.read}
rad = radius.to_f
diam = rad*2
lenght = rad * Math::PI * 2
area = Math::PI * rad**2
File.open('radius.out','w'){|file| file.puts "#{ '%.3f' % diam} #{ '%.3f' % lenght} #{ '%.3f' % area}"} | true |
924fa219a0cac7dda65334b4083545adfd250792 | Ruby | mhepfer/recursionPractice | /rubyRecursion/blocks.rb | UTF-8 | 1,083 | 3.328125 | 3 | [] | no_license | class Array
def my_each
for i in (0...self.length)
yield self[i]
end
end
def my_map
[].tap do |result|
self.my_each do |element|
result << yield(element)
end
end
end
def my_select
[].tap do |result|
self.my_each do |element|
result << element ... | true |
2be46995b041c412a5537025a402f2fc15126c43 | Ruby | KerryAlsace/ruby-challenges | /my_first_object.rb | UTF-8 | 411 | 3.78125 | 4 | [] | no_license | class Pets
def set_name=(pet_name)
@name=pet_name
end
def get_name
return @name
end
def set_type=(pet_type)
@type=pet_type
end
def get_type
return@type
end
def pet_sound
return "woof"
end
end
my_pet = Pets.new
my_pet.set_name = "Nikki"
pet_name = my_pet.get_name
my_p... | true |
411249fd168202ef2e2ce0fbbdc25a3cab155d75 | Ruby | Fiaxhs/advent-of-code-2019 | /11/main.rb | UTF-8 | 3,922 | 3.40625 | 3 | [] | no_license | #!/bin/ruby
file = File.new("input.txt", "r")
line = file.gets
file.close
class Amp
def initialize(memory)
@memory = memory
@pointer = 0
@first = true
@ret = nil
@relative = 0
100000.times do
@memory.push 0
end
end
def read (n, mode)
case mode
when 0
@memory[n].to_i
when 1
... | true |
f54419103180207dfdf777a1a56ba524af43bece | Ruby | zmess24/Algorithmic-Toolbox | /1-1_max_pairwise_product/submission.rb | UTF-8 | 231 | 3.234375 | 3 | [] | no_license | #!/usr/bin/env ruby
def max_pairwise_product(a)
a.sort!
return a[a.length-1] * a[a.length-2]
end
if __FILE__ == $0
data = STDIN.read.split().map(&:to_i)
n = data[0]
a = data[1..n]
puts "#{max_pairwise_product(a)}"
end | true |
6dcee2cf442e63812bb85c37e27cc40643b8b47f | Ruby | cloneforyou/findcareers | /lib/code_for_cash/client.rb | UTF-8 | 2,598 | 2.796875 | 3 | [] | no_license | # frozen_string_literal: true
require "json"
require "net/http"
module CodeForCash
##
# Code for Cash API client
#
class Client
DEFAULT_ENDPOINT = "https://i.codefor.cash/api/metum"
Error = Class.new(StandardError)
# Server responses that indicate failure or a failure processing its response
... | true |
9c915589d4d7b3bf779b1e6da2f4dd8103c74987 | Ruby | redscode/mapbox-sdk-rb | /lib/mapbox/geocoder.rb | UTF-8 | 1,630 | 2.59375 | 3 | [
"ISC",
"MIT"
] | permissive | require 'rest-client'
require 'json'
require 'uri'
module Mapbox
class Geocoder
include Mapbox::APIOperations::Request
extend Mapbox::HashUtils
def self.assemble_params(options={})
proximity = options[:proximity]
bbox = options[:bbox]
types = options[:types]
params = ''
opt... | true |
e01dbc516da6ed321d616d1c46b7fa1705f2d239 | Ruby | Louu123/Ruby | /exo_18.rb | UTF-8 | 431 | 3.5 | 4 | [] | no_license | #Écris un programme exo_18.rb qui va créer une liste de 50 faux emails et les stocker dans une array. Voici le format que devront avoir les faux emails"jean.dupont.01@email.fr" "jean.dupont.02@email.fr" etc.
tableau = [ ]
i = 0
while i < 50 do
i = i + 1
if i < 10
1.times do
tableau<<... | true |
5a6040a38910a4f70ed1e586ea38b1e36990e83e | Ruby | rcarver/orel | /features/steps/sql_steps.rb | UTF-8 | 792 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | Given /^I have these class definitions:$/ do |string|
step %{a file named "classes.rb" with:}, string
end
When /^I use Orel to fill my database with tables$/ do
step %{a file named "create.rb" with:}, <<-EOF
require 'orel/test'
require 'classes'
Orel.recreate_database!
Orel.create_tables!
puts ... | true |
d8e74c303daa1e9697ce902ba721fe79115da043 | Ruby | omgitsgod/programming_languages-dumbo-web-100818 | /programming_languages.rb | UTF-8 | 269 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reformat_languages(languages)
# your code here
hashy = {}
languages.each do |k, v|
v.each do |x, y|
if hashy.has_key?(x)
hashy[x][:style] << k
else
hashy[x] = y
hashy[x][:style] = [k]
end
end
end
hashy
end
| true |
bb04c4e66013192207bf00cc4e695f7672443943 | Ruby | tsvet-elina/first_Ruby | /thirdsample.rb | UTF-8 | 512 | 2.640625 | 3 | [] | no_license |
# 3.Напишете програма, която приема име на текстов файл от конзолата, отваря файла и създава нов
# файл, в който обръща наобратно редовете от оригиналния файл. Името на новия файл трябва да
# е също наобратно.
file_text = File.new("txet.txt", "w+")
File.new("text.txt").each_line.reverse_each { |line| file_text.... | true |
515cfd2a6972a49faf22b9202cc6ff2c55b1c25e | Ruby | jamesapowers/Ruby_projects | /W1D2/player.rb | UTF-8 | 330 | 3.8125 | 4 | [] | no_license | class Player
attr_reader :name
def initialize(name)
@name = name
end
def pick_a_spot
puts "Please pick the coordinate: (i.e.(0,1))"
input = gets.chomp.split(",")
input.map! { |el| Integer(el) } #return [0,1]
end
def pick_number
puts "What value do you wanna put here? "
gets.chomp
... | true |
b333b04f69d789de1b681caf6475c342652feb56 | Ruby | wfischer42/market | /lib/market.rb | UTF-8 | 1,057 | 3.40625 | 3 | [] | no_license | require_relative './vendor'
class Market
attr_reader :name,
:vendors
def initialize(name)
@name = name
@vendors = []
end
def add_vendor(vendor)
@vendors << vendor
end
def vendor_names
@vendors.map do |vendor|
vendor.name
end
end
def vendors_that_sell(item)
... | true |
e7d5a96516f64d6b978f725ebe58c7a1d9724057 | Ruby | lucoby/mafia_sim | /Mafia_Sim.rb | UTF-8 | 1,501 | 3.03125 | 3 | [] | no_license | require_relative 'Village'
#Mafia monte carlo sim
$TRIALS = 10000
$START_DAY = true
$TOWN_SETUP = {:Townie => 7, :Doctor => 1, :Cop => 1}
#$TOWN_SETUP = {:Townie => 13}
$MAFIA_SETUP = {:Goon => 2, :RoleBlocker => 1}
#$MAFIA_SETUP = {:Goon => 2}
$VILLAGE_SETUP = {:Town => $TOWN_SETUP, :Mafia => $MAFIA_SETUP}
$NIGHTLESS... | true |
8ac0c69fc493c2319f3cc0f3531c9c614f2ed8a9 | Ruby | kylecoberly/oo-cash-register-teacher-onboarding | /lib/cash_register.rb | UTF-8 | 713 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :discount, :total
attr_reader :items, :prices
def initialize(discount = 0)
@total = 0
@discount = discount
@items = []
@prices = []
end
def add_item(title, price, quantity=1)
(1..quantity).each {
@items << title
}
@prices << price * quantity
... | true |
a68780eb8084e2251c4d65f1e0fd695fc570009b | Ruby | TruongMTu/WikiParser | /Ruby WikiParser/wiki_parser_full.rb | UTF-8 | 1,755 | 3.703125 | 4 | [] | no_license | #coded by Tu Truong
#encoding: utf-8
# Function creates a paragraph from string p
# and writes them out to file f
def paragraph(p,f)
# Replaces everything that has <b>, </b>, etc.
value = p.gsub(/<b>|<\/b>|<a>|<\/a>/, "")
arr = value.split(/</)
# Gets rid of anything else from .* to >
# and fixes spaces be... | true |
84f14d487a750bd6978a6e57eb4ffe64c5e7bbb3 | Ruby | mrjslau/Prism2.0 | /ruby/spec/map_spec.rb | UTF-8 | 3,415 | 3.015625 | 3 | [] | no_license | # spec/map_spec.rb
require 'spec_helper.rb'
describe Map do
described_class.instance.residents.clear
described_class.instance.notifications.clear
let(:map) { described_class.instance }
let(:location) { Location.new(5, 4) }
let(:person) do
Person.new('Jane', 'Doe', 'female', '1990-06-03', location)
en... | true |
d82a0ffb28c61816586f670c97ceae1675c0899c | Ruby | RichardBlankenhorn/learning_by_doing | /arrays/fizz_buzz_array.rb | UTF-8 | 372 | 3.703125 | 4 | [] | no_license | #!/usr/bin/env ruby
numbers = (1..100).to_a
fizz_buzz_array = []
count = 1
numbers.each do |value|
if value % 3 == 0 && count % 5 == 0
fizz_buzz_array.push('FizzBuzz')
elsif value % 3 == 0
fizz_buzz_array.push('Fizz')
elsif value % 5 == 0
fizz_buzz_array.push('Buzz')
else
fizz_buzz_array.push(... | true |
8ed44ed23e524ca861694b45c129afda98e37294 | Ruby | cha63506/jquery-governance | /app/models/conflict_list.rb | UTF-8 | 2,891 | 3.25 | 3 | [] | no_license | class ConflictList < Array
cattr_accessor :delimiter
self.delimiter = ','
attr_accessor :owner
def initialize(*args)
add(*args)
end
##
# Add conflicts to the ConflictList. Duplicate or blank conflicts will be ignored.
# Use the <tt>:parse</tt> option to add an unparsed conflict string.
#
# Ex... | true |
503be30e717e979ed807aaa0ce75574d74eb0038 | Ruby | jfeng702/Projects | /W2D5/myhashmap/lib/p02_hashing.rb | UTF-8 | 633 | 3.40625 | 3 | [] | no_license | class Fixnum
# Fixnum#hash already implemented for you
end
class Array
def hash
self.join('').to_i.hash
end
end
class String
def hash
sum = 0
self.each_char { |ch| sum += ch.ord }
sum = sum / self[0].ord
sum.hash
end
end
class Hash
# This returns 0 because rspec will break if it retur... | true |
0b9096df4e3013d1737950ba85a9f18133e69f6c | Ruby | txusyk/rubyIdeas | /IMDB-Manager/test/tc_actor.rb | UTF-8 | 389 | 2.828125 | 3 | [] | no_license | require_relative '../actor'
require 'test/unit'
class Tc_actor < Test::Unit::TestCase
def test_initialize
actorsArray = [Actor.new('Josu','Alvarez'), Actor.new('David','Max'), Actor.new('Koldo','Gojenola')]
actorsArray.each_index do |index|
assert_not_nil actorsArray[index].name
p "Actor: #{acto... | true |
716016e8413e9d3f3de3f251a280c534112b8e5a | Ruby | lalithalisha/workspace | /cls_method.rb | UTF-8 | 241 | 3.96875 | 4 | [] | no_license | # Program for Person details using class method
class Person
def self.sample(name,address)
@n=name
@a=address
puts"The Person name is : #@n"
puts"The Person address is: #@a"
end
end
Person.sample("Hrushi","Hyd")
| true |
ab5e48796fabdb219072be0c570118769f0ec1b2 | Ruby | six7zero9/Learning_ruby | /01_no_repeats.rb | UTF-8 | 646 | 4.46875 | 4 | [] | no_license | # Write a function, `no_repeats(year_start, year_end)`, which takes a
# range of years and outputs those years which do not have any
# repeated digits.
#
# You should probably write a helper function, `no_repeat?(year)` which
# returns true/false if a single year doesn't have a repeat.
#
# Difficulty: 1/5
def no_repea... | true |
e80a021f3c06718c8959f0de742c6511cb5e94ab | Ruby | lstrzalk/Rozprochy | /lab1/task 1/client.rb | UTF-8 | 1,296 | 3 | 3 | [] | no_license | require 'socket'
require_relative 'messenge'
class Client
def initialize(server, nickname)
@server = server
@nickname = nickname
@id = -1
@request = nil
@response = nil
@messenge = Messenge.new(@id,@nickname)
connect
listen
send
@request.join
@response.join
end
def connect
tryTimes = 0
maxT... | true |
cd29f12d5cc793281933f79a398c4f28f61a521c | Ruby | gregfelice/hr-system | /flow/app/services/people_tree.rb | UTF-8 | 2,706 | 3.21875 | 3 | [] | no_license | require 'singleton'
class PeopleTree
include Singleton
attr_accessor :top_node_id
@top_node_id = nil
def get_people_tree(person)
Rails.logger.info "using person #{person.inspect} to get tree"
get_tree(person)
end
def set_top_node_id(id)
@top_node_id = id
end
def initialize
begin
... | true |
234c3133bf5ab0a2ad4e1d8b740e91aa70c1087c | Ruby | iiom/codewars | /most_frequently_used_words.rb | UTF-8 | 1,655 | 3.40625 | 3 | [] | no_license | def top_3_words(text)
return [] unless text =~ /[a-zA-Z]/
str = text.downcase.gsub(/[.,:\/]/, '')
hash = {}
str.split(' ').each do |elem|
if hash.keys.include?(elem)
hash[elem] += 1
else
hash[elem] = 1
end
end
hash.sort_by {|_, v| v}.reverse.map! {|i| i.first}.first(3)
end
p top_3_w... | true |
d17d3cb876b8bec0eeafc3c1c189fec9b6120b83 | Ruby | katiekeel/date-night | /lib/node.rb | UTF-8 | 351 | 3.65625 | 4 | [] | no_license | # Creating a Node class that allows us to create nodes for insertion into tree
class Node
# Each node has a rating (value), and a pointer to left and/or right
attr_accessor :rating, :title, :left, :right
def initialize(rating, title, left=nil, right=nil)
@rating = rating
@title = title
@left = left... | true |
a985784c4e15c19444f110c04795ced3a39f2e86 | Ruby | lanlhtomosia97/Itmtu_download | /seifuku_crawl.rb | UTF-8 | 2,744 | 2.953125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'csv'
require 'thread'
require 'pry'
class Notice
def insert_number
"= = = = = = = = = = INSERT NUMBER = = = = = = = = = = = = = = = ="
end
def insert_last_page
"= = = = = = = INSERT LAST PAGE = = = MAX IS 21 PAGE = = = = = = = "
end
def nil_link
"... | true |
a45cf07d3c99ef08e3636fc16a6fa97c7fbc4f79 | Ruby | zhimin/rwebspec | /spec/utils_spec.rb | UTF-8 | 2,495 | 2.765625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + "/stack"
# $:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebspec")
# gem "rspec"
# require File.join(File.dirname(__FILE__), "..", "lib/extensions/rspec_extensions.rb")
# require File.join(File.dirname(__FILE__), "..", "lib/rwebspec/core.rb")
# require File.join(File.dirname(... | true |
7c9edbb7f0a7b47a522861366003fc2a4bde8be8 | Ruby | charman/surveyor_tweaks | /lib/surveyor_tweaks/models/response_set_methods.rb | UTF-8 | 3,892 | 2.640625 | 3 | [] | no_license | module SurveyorTweaks
module Models
module ResponseSetMethods
def self.included(base)
base.send :scope, :with_responses, :include => { :responses => [:question, :answer] }
end
def most_recent_response_created_at
if responses_sorted_by_created_at.last
responses_sorted... | true |
b1a88fd6ddf4d2e245710fb8e4eb27eb2af4dc2b | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/crypto-square/4088c90c756c4f96bbbb9d17d10360a0.rb | UTF-8 | 565 | 3.1875 | 3 | [] | no_license | class Crypto
attr_reader :text
def initialize(text)
@text = text
end
def normalize_plaintext
text.gsub(/\W+/, "").downcase
end
def size
Math.sqrt(normalize_plaintext.length).ceil
end
def plaintext_segments
normalize_plaintext.scan(/.{1,#{size}}/)
end
def ciphertext
"".tap d... | true |
c144ef010724ca0b87d8967d1be4d90b24f3d9a8 | Ruby | adfret/cartoon-collections-dumbo-web-career-040119 | /cartoon_collections.rb | UTF-8 | 529 | 3.515625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves (arr)
arr.each_with_index do |dwarf, i|
puts "#{i+1}: #{arr[i]}"
end
end
def summon_captain_planet (arr)
array = []
arr.map do |i|
array << "#{i.capitalize}!"
end
array
end
def long_planeteer_calls(arr)
arr.any? do |i|
i.length>4
end
end
def find_the_cheese(arr)
# t... | true |
f6d2809619c8752df362a61e688e99e46861d70c | Ruby | wasilak/detox | /test/unit/budget_test.rb | UTF-8 | 643 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class BudgetTest < ActiveSupport::TestCase
test "get all budgets" do
budgets = Budget.get_all_budgets
assert_kind_of Array, budgets, "No budgets queried."
end
test "amount should be greater then zero" do
budget = Budget.new
budget[:amount] = -8
... | true |
c0d4c8b8ceabdee07ec1d7f9628396ee010a12fe | Ruby | victorsc175/fintrack | /app/jobs/update_price_job.rb | UTF-8 | 862 | 2.546875 | 3 | [] | no_license | class UpdatePriceJob < ApplicationJob
queue_as :default
BASE_FOR_CHANGE = 10
BASE_FOR_DELAY = 15
attr_reader :stocks_total, :stock, :change
def perform(*_args)
loop do
stocks_total = Stock.count
@stock = Stock.offset(rand(stocks_total)).limit(1).first
@change = (-BASE_FOR_CHANGE..BASE_F... | true |
531f0e71fe9cf489f445f9828ad73a5fdfd2d3e8 | Ruby | perjerz/unpoly-site | /lib/unpoly/guide/referencer.rb | UTF-8 | 799 | 2.546875 | 3 | [] | no_license | module Unpoly
module Guide
module Referencer
def reference_names
@reference_names ||= []
end
def reference_names=(names)
@reference_names = names
end
def references
reference_names.map do |name|
Guide.current.find_by_name!(name)
end
... | true |
3ff2bfbb07eaec60881c3cad537908da370e2a46 | Ruby | RedTeamSeed/Studios | /challs/codeabbey/007/SYLAR.rb | UTF-8 | 367 | 3.609375 | 4 | [] | no_license | #!/usr/bin/ruby
def read_file(filename)
respuesta=" "
File.foreach(filename).with_index do |line|
line=line.split(" ")
line.each { |x|
celsius = x.to_i
fahrenheit = (celsius.to_i - 32) /1.8
respuesta = respuesta + " " +fahrenheit.round.to_s
}
end
return respuesta
end
puts "Start"
puts re... | true |
bcac3ea607387f5acf1d671ccd3923c39a858182 | Ruby | Alonsorozco/desafioarrelosarchivos | /grafico.rb | UTF-8 | 261 | 3.25 | 3 | [] | no_license | data = [5, 3, 2, 5, 10]
def chart (array)
maximo = array.max
array.each do |i|
puts "|" + "**" *i
end
print ">" + "--" * maximo
print "\n"
(1..maximo).each do |n|
print "#{n} "
end
print "\n"
end
##chart (data) | true |
3ef8d507fcaa86d533566fdc352b78dfeceac72b | Ruby | jasonrhalpern/deals | /app/models/concerns/date_former.rb | UTF-8 | 306 | 2.546875 | 3 | [] | no_license | require 'chronic'
module DateFormer
extend ActiveSupport::Concern
def get_date_from_day(day)
today = Date::DAYNAMES[Date.today.wday]
if day.blank? || (today == day)
Date.today
else
Chronic.parse("#{day}").to_date
end
end
def upcoming_deal_period
1.week
end
end | true |
ad4f708b37ba17ec19629126e214a9da302f7eab | Ruby | duplys/noisr | /examples/rubyvis.rb | UTF-8 | 692 | 2.546875 | 3 | [] | no_license | require 'rubyvis'
signal = open('examples/signal.dat','r').readlines
data = pv.range(0, signal.size, 1).map {|x|
OpenStruct.new({:x=> x, :y=> signal[x].to_f}) #Math.sin(x) + 2+rand()})
}
#p data
w = 1300
h = 600
x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
y = pv.Scale.linear(data, lambda {|d| d.y... | true |
8c6c88ca0594a7097ffdae18aa16aee8e9fa2558 | Ruby | stuffyUdaya/Ruby | /ruby_basics/add.rb | UTF-8 | 188 | 3.46875 | 3 | [] | no_license | x =60; y= 45; z = x+y;
puts "sum is #{z} "
puts "sum is ", +z
puts "sum is %d" %z
name = "udaya"
puts "This is %s"%name
puts "\t\tThis\n is \t%s"%name
a ="this"
b = " is"
puts a+b
| true |
9f35609a344cb886c5b6629ab2638ba454c01df7 | Ruby | SireeR13/ImageBlur1Challenge | /imageblur11.rb | UTF-8 | 579 | 4.34375 | 4 | [] | no_license | class Image
def initialize(arrays)
# arrays is an multidimensional array with 4 rows and undefined columns
# as provided in the code in the assignment
@image = [arrays[0], arrays[1], arrays[2], arrays[3]]
end
def output_image
# loops through each array row
@image.each do |row|
... | true |
987edc77917ab91e1a5099e948ec5d411c592eb5 | Ruby | yoshis777/design_pattern | /factory_method_pre.rb | UTF-8 | 380 | 3.921875 | 4 | [] | no_license | class Duck
def initialize(name)
@name = name
end
def eat
puts "アヒルの#{@name}は食事中です"
end
def sleep
puts "アヒルの#{@name}は寝ました"
end
end
class Pond
def initialize(duck)
@duck = duck
end
def simulate_one_day
@duck.eat
@duck.sleep
end
end
pond = Pond.new(Duck.new("アヒル1"))
pond.si... | true |
5cac97f7a7a6c2d952ddfe2c5cd6c819b9bc82fa | Ruby | lukewhchen/babybook | /app/models/user.rb | UTF-8 | 2,047 | 2.515625 | 3 | [] | no_license | # == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# first_name :string not null
# last_name :string not null
# email :string not null
# password_digest :string not null
# session_token :string ... | true |
08f8fb562e94844da9fab748c61a4320c71a0036 | Ruby | NMLangridge/BearRiverFish | /Bear.rb | UTF-8 | 273 | 3.609375 | 4 | [] | no_license | class Bear
attr_reader :name, :type, :stomach, :fish
def initialize(name, type)
@name = name
@type = type
@stomach = []
@fish = []
end
def bear_take_fish(fish)
@stomach.push(fish)
end
def roar()
return "Roar! I'm a bear!"
end
end
| true |
1e31c7d7f13aa9b7eb027a2efe0dba604afe6559 | Ruby | andrewtrent/square_array-v-000 | /square_array.rb | UTF-8 | 115 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
# your code here
array_two = []
array.each {|x| array_two.push(x*x)}
array_two
end
| true |
3fb3ebc5324eb9d433cbadba5d1b9c97355526fa | Ruby | cheezenaan/procon | /atcoder/abc002/c.rb | UTF-8 | 143 | 3.046875 | 3 | [] | no_license | # frozen_string_literal: true
xa, ya, xb, yb, xc, yc = gets.split.map(&:to_i)
puts(((xa - xc) * (yb - yc) - (xb - xc) * (ya - yc)).abs / 2.0)
| true |
f8fdb70333b26e5c79b0f8081771036ff854eeb5 | Ruby | csquared/Chaos-Composer | /Generators.rb | UTF-8 | 5,381 | 3.359375 | 3 | [] | no_license | #module Generators by Chris Continanza
#
# Generators are the chaotic equations I am using to generate the sequences of numbers
# that are sent to the EventTree to analyze.
# The ChaosGenerator class provides a 'step' method, which is used to create the run.
#
# The Henon generator overrides the 'step' method becaus... | true |
782c541af1eb3c513a2bdad150ee3e0fc0e7b3fb | Ruby | angiemalaika/ruby-collaborating-objects-lab-online-web-ft-051319 | /lib/artist.rb | UTF-8 | 1,448 | 3.890625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
@@all = []
attr_accessor :name, :songs
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def add_song(song)
@songs << song
end
def self.find_or_create_by_name(name)
self.find(name) ? self.find(name) : self.create(name)
end
def self.f... | true |
a0bf547f723958af8c8e20a684c006a54af9d0e6 | Ruby | jlusenhop-mchs/medibot-amisys | /conversions/it_extract_preprocess.rb | UTF-8 | 982 | 2.71875 | 3 | [] | no_license | def initialize_variables
@it_extract = ARGV[0]
@template = ARGV[1]
end
def open_files
@it_extract_file = File.open("#{@it_extract}.txt", "r")
@old_template_file = File.open("#{@template}.feature", "r")
end
def process_template_file (new_feature_file_essette)
line_count = 0
@old_template_file.each_line do ... | true |
28194f6386ca66636eae731e814cad07c684a458 | Ruby | nelsnelson/can-u-code | /problem2.rb | UTF-8 | 670 | 4 | 4 | [] | no_license | #! /usr/bin/env jruby
# Write a function that combines two lists by alternatingly
# taking elements. For example: given the two lists [a, b, c]
# and [1, 2, 3], the function should return [a, 1, b, 2, c, 3].
def combine(list1, list2)
combined = []
list1_length = list1.length
list2_length = list2.length
unti... | true |
df988433f56cced372a886cd27dcebe9f5a01d5a | Ruby | lennythomas-dev/launch_school_core | /lesson_4/practice_problems_additional_practice/problem_1.rb | UTF-8 | 623 | 4.15625 | 4 | [] | no_license | # Courses > RB101 Programming Foundations > Lesson 4: Ruby Collections > Practice Problems: Additional Practice
# Problem 1
# Understand the problem : turn the given array into a hash where the names are key's and array position is the value
# data structure : input = array , output = hash
# algorithm
# instantiate an ... | true |
4d79eed511f8939045bc95e6e0f4a40c25d7b48e | Ruby | achr3f/rufus-lua | /spec/functions_spec.rb | UTF-8 | 1,828 | 2.75 | 3 | [
"MIT"
] | permissive |
#
# Specifying rufus-lua
#
# Wed Mar 11 17:09:17 JST 2009
#
require File.dirname(__FILE__) + '/spec_base'
describe 'Rufus::Lua::State (functions)' do
before do
@s = Rufus::Lua::State.new
end
after do
@s.close
end
it 'should return Lua functions' do
@s.eval('return function () end').class.sho... | true |
509798e3d67cbaf2e1994a1e3f476eec0182b61b | Ruby | ajtran303/market_2005 | /lib/market.rb | UTF-8 | 1,947 | 3.484375 | 3 | [] | no_license | require 'date'
class Market
attr_reader :name, :vendors, :date
def self.get_date
Date.today.strftime("%d/%m/%Y")
end
def initialize(name)
@name = name
@vendors = []
@date = Market.get_date
end
def add_vendor(vendor)
@vendors << vendor
end
def vendor_names
@vendors.map do |ve... | true |
d897d0668ce07ea12f71288c08b95bf912c33980 | Ruby | jorgechavezrnd/IngeDeSoftware | /spec/game_spec.rb | UTF-8 | 9,696 | 3.09375 | 3 | [] | no_license | require './lib/game'
describe Game do
before(:each) do
@game=Game.new
end
it "deberia devolver la cantidad de cuartos de 16 en un nuevo mapa pequeño por defecto" do
@game.newDefaultGame(false, 'small')
expect(@game.getQuantityOfRooms).to eq(16)
end
it "deberia devolver 1 si el jugador esta en la habitacion ... | true |
db08a4b03622b7bc7b6bbc2f3202c07b96a46d6f | Ruby | thinkybeast/ruby-exercises | /basics/user_input/4.rb | UTF-8 | 1,263 | 4.4375 | 4 | [] | no_license | =begin
In the previous exercise, you wrote a program that asks the user if they want the program to print "something".
However, this program recognized any input as valid: if you answered anything but y,
it treated it as an n response, and quit without printing anything.
Modify your program so it prints an error mes... | true |
ece891e750cacd2df934d5b10aba9c21787ad467 | Ruby | TertiumQuid/Palimpsest | /app/helpers/news_articles_helper.rb | UTF-8 | 4,590 | 2.53125 | 3 | [] | no_license | module NewsArticlesHelper
def previous_month_link(date=Time.now)
link_to "<< " << date.advance(:months => -1).strftime("%b"),
news_archives_path(date.advance(:months=>-1).year,date.advance(:months=>-1).month),
:class => "left"
end
def next_month_link(date... | true |
cd22b66ade484a04e1e6231b5be773bedb03805c | Ruby | hengtangan2025/base_questions | /160706/number/ruby/9.rb | UTF-8 | 353 | 3.71875 | 4 | [] | no_license | def number9 n
max_length = n*2 - 1
(1..max_length).each do |i|
if i <= n
x_length = i*2 - 1
blank_length = (max_length - x_length)/2
else
x_length = (max_length - i)*2 + 1
blank_length = (max_length - x_length)/2
end
puts " "*blank_length + "x"*x_length + " "*blan... | true |
9e85cedfb636b1f039222ca3f31f16f1805bca56 | Ruby | thatkaiguy/AppAcademy | /Week3/w3d2/aa-questions/question_follow.rb | UTF-8 | 2,544 | 2.90625 | 3 | [] | no_license | require_relative 'questions_database'
require_relative 'user'
require_relative 'question'
class QuestionFollow
TABLE_NAME = 'question_follows'
attr_accessor :user_id, :question_id
def self.find_by_id(id)
follows_rows = QuestionsDatabase.instance.execute(<<-SQL, id: id)
SELECT
... | true |
f39bb364b444a3390618a9447634fc0d8c664c61 | Ruby | ngocluong/bookstore | /app/service/pagination_info_builder.rb | UTF-8 | 409 | 2.5625 | 3 | [] | no_license | class PaginationInfoBuilder
attr_accessor :paginated_data
def self.build_pagination_info(*args)
new(*args).generate_pagination_info
end
def initialize(options = {})
self.paginated_data = options[:data]
end
def generate_pagination_info
OpenStruct.new(current_page: paginated_data.current_page, ... | true |
f201eec6d3993f9e996021ab49e9422aaa192ea3 | Ruby | eric1234/admin_controller | /lib/admin_controller/crud.rb | UTF-8 | 2,385 | 2.546875 | 3 | [] | no_license | # Common pattern for the admin of data.
module AdminController::Crud
extend ActiveSupport::Concern
included do
self.responder = AdminController::Responder
respond_to :html
end
def index
load_objects
respond_with controller_namespace + [@objects]
end
def new
new_object
respond_with... | true |
d8b32754140c9a1bb81f5d8120dc4abeb14bd132 | Ruby | thebravoman/software_engineering_2015 | /c24/A_21_Nikolay_Danailov.rb | UTF-8 | 192 | 3.390625 | 3 | [] | no_license | num = ARGV[0].to_i
divisers_count = 0
(2...num).each do |i|
if num % i == 0
print "#{i} "
divisers_count += 1
end
end
puts
puts "The number #{num} has #{divisers_count} devisers" | true |
ec3e228f1c60e88c684dc8a90ff525f800af1b44 | Ruby | shantanutrip/RubyMethod | /MethodCall.rb | UTF-8 | 2,242 | 2.96875 | 3 | [] | no_license | class MethodCall
attr_reader :node
def initialize(node)
@node = node
end
def implicit_receiver?
case node.type
when :call, :aref, :unary, :binary, :super, :zsuper then false
when :fcall, :command, :command_call, :var_ref, :vcall then true
when :met... | true |
3c07052012df16cecfc90a585eae03d6f0ce1c75 | Ruby | lafesh/programming_languages-online-web-prework | /programming_languages.rb | UTF-8 | 273 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reformat_languages(languages)
# your code here
new_hash = {}
languages.each do |style, lang|
lang.each do |type, string|
new_hash[type] ||= string
new_hash[type][:style] ||= []
new_hash[type][:style] << style
end
end
new_hash
end
| true |
2f003d534df073fc119b48b9ebb51ec5e2651e7a | Ruby | pikonori/auto_sftp | /lib/autosftp/connection.rb | UTF-8 | 1,829 | 2.765625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require 'net/ssh'
require 'net/sftp'
module Autosftp
class Connection
# username@host:port形式かどうかチェックする。
def self.check? sftp
if /.*\@.*|.*\@.*\:.*/ =~ sftp
true
else
false
end
end
# username@host:port形式を分解する。
def self.explode sftp
... | true |
fe1185989ef870ddc41633294f33d4d6f1d72cf2 | Ruby | kenzie/Kudos | /lib/kudos/filter.rb | UTF-8 | 232 | 2.6875 | 3 | [] | no_license | module Kudos
class Filter
attr_reader :tweet
def initialize(tweet)
@tweet = tweet
end
def match?
return false unless tweet
!!(tweet.text =~ /congrats|congratulations|kudos/i)
end
end
end | true |
1f9d64a45bc2534540d56615bc5d17e87424bdb5 | Ruby | wencakisa/keeper | /lib/keeper/models/user.rb | UTF-8 | 305 | 2.734375 | 3 | [
"MIT"
] | permissive | class User
include DatabaseSerializable
attr_accessor :username, :age
def initialize(id = nil, username, age)
@id = id
@username = username
@age = age
end
def self.database_fields
[
StringField.new(:username, false, 16),
IntegerField.new(:age)
]
end
end
| true |
dc6dbc130eec956132b4504e10b190b3aa2d33ae | Ruby | bogdanovich/cadence-ruby | /lib/cadence/workflow/dispatcher.rb | UTF-8 | 691 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | module Cadence
class Workflow
class Dispatcher
WILDCARD = '*'.freeze
def initialize
@handlers = Hash.new { |hash, key| hash[key] = [] }
end
def register_handler(target, event_name, &handler)
handlers[target] << [event_name, handler]
end
def dispatch(target, e... | true |
a8c4fa35e0ca5cfb8fafae7a68ae49f696fb3c06 | Ruby | prihandi/Quiz-Master | /test/models/question_test.rb | UTF-8 | 2,478 | 3.0625 | 3 | [] | no_license | require 'test_helper'
class QuestionTest < ActiveSupport::TestCase
def setup
@question = Question.new(question: "Example User", answer: "1", submitted_answer: "")
end
test "should be valid" do
assert @question.valid?
end
test "question should be present" do
@question.question = " "
assert_no... | true |
2978bce5bec823a9b28d7b67521ce584f973a74d | Ruby | lewisisom/ls_rb101 | /lesson_4/additional_practice.rb | UTF-8 | 5,072 | 4.65625 | 5 | [] | no_license | ##### Question 1
# Turn this array into a hash where names are keys
# and values are positions in the array:
flintstones = ["Fred", "Barney", "Wilma", "Betty", "Pebbles", "BamBam"]
# Initialize an empty hash.
# Initialize a second array.
# Fill the second array with the numbers one through the input array size.
# Pair... | true |
0b8c2acbce293ebeba96c5b5999d221fd20e5f80 | Ruby | amitbiswas1992/Learn-Fun-Ruby- | /array.rb | UTF-8 | 408 | 2.671875 | 3 | [] | no_license | ary =["Amit",001,"Mazegeek",3030]
ary.each do |i|
puts i
end
simple = [ "ID","NAME","ADRESS","NUMBER"]
simple.each do |i|
puts i
end
display= ["001","AmitBiswas","3605 29th St","3476217821"]
display.each do |j|
puts j
end
(15..30).each do |n|
puts n
end
(2..10).each do |i|
puts i
end
puts "test... | true |
9cf92da2500911bf2c6b3b546b8cb499f1a2e66c | Ruby | jmejia/sales_engine | /test/base_repository_test.rb | UTF-8 | 719 | 2.609375 | 3 | [] | no_license | require 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/base_repository'
require_relative '../lib/customer'
class BaseRepositoryTest < MiniTest::Unit::TestCase
attr_reader :br
=begin
def setup
@br = BaseRepository.new(Customer)
end
def test_it_exists
asse... | true |
3664320a11efca0239e0c2cf8cd074abeff3847c | Ruby | felhix/ruby-roman-numerals | /roman_numerals.rb | UTF-8 | 550 | 3.671875 | 4 | [
"MIT"
] | permissive | class Fixnum
def to_roman
number_in_string = self.to_s
return to_tenths(number_in_string[-2]) + to_units(number_in_string[-1])
end
private
def to_tenths(tenths)
tenths_romans = ["X", "XX", "XXX", 'XL', 'L', 'LX', 'LXX', "LXXX", "XC"]
return "" if tenths == "0" || tenths == nil
return tent... | true |
1165a3b7df667699afde31b27ff50d20a88ac3e7 | Ruby | miletbaker/decimalizer | /spec/decimalizer_spec.rb | UTF-8 | 1,113 | 3.046875 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/spec_helper'
class TestClass
include Decimalizer
decimalize :number
end
describe TestClass do
before do
@test = TestClass.new
@test.stub!(:write_attribute)
@test.stub!(:read_attribute).and_return(45)
end
it "should have been generated number_as_decimal" do
@test.sh... | true |
f84b6f9d0d44b792abc33c8710a4fe2ab338b863 | Ruby | nashsibanda/app_academy_open | /Ruby/Object-Oriented Programming/Error Handling Funtime/super_useful.rb | UTF-8 | 2,146 | 4.1875 | 4 | [] | no_license | # PHASE 2
def convert_to_int(str)
Integer(str)
rescue ArgumentError => err
puts "This ain't an integer, buddy."
return nil
end
# PHASE 3
FRUITS = ["apple", "banana", "orange"]
class CoffeeError < StandardError
def message
"Jeez Louise, that's some excellent Nicaraguan blended bean juice! What a pal. Got a... | true |
0e285093179694c2b6ed68fe41c4d5d599598570 | Ruby | copiousfreetime/flat_kit | /lib/flat_kit/field_type.rb | UTF-8 | 2,334 | 2.59375 | 3 | [
"MIT"
] | permissive | module FlatKit
class FieldType
extend FlatKit::DescendantTracker
CoerceFailure = Class.new(::Object).freeze
def self.candidate_types(data)
find_children(:matches?, data)
end
def self.best_guess(data)
candidate_types(data).sort_by { |t| t.weight }.last
end
def self.type_nam... | true |
9318c8fb307c59184c9162b2406462d4d6351140 | Ruby | sergiobanegas/DocumentAnalizer-ruby | /Article.rb | UTF-8 | 588 | 3.015625 | 3 | [] | no_license | require 'Document.rb'
class Article < Document
def initialize (magazine, id, year, title, sections)
super(id, year, title, sections)
@magazine=magazine
end
def publishedInMagazineAndContainsAcronym(magazine, acronym)
if (containsAcronym?(acronym) && (@magazine.upcase.include? magazine))
retur... | true |
8ea82e1163e4994bad11d6e1b01c99956300bcb5 | Ruby | Wolf-Fivousix/AAClasswork | /W4D4/TDD/lib/tdd.rb | UTF-8 | 602 | 3.59375 | 4 | [] | no_license | require "byebug"
class Array
def my_uniq
inject([]) { |new_array, element| new_array += (new_array.include?(element) ? [] : [element]) }
end
def two_sum
sums = []
length.times do |index_1|
(index_1 + 1...length).each do |index_2|
sums << [index_1, index_2] if self[index_1] + self[index... | true |
664b36f08c7cfb1e08bd58722ad47df2f2679dcb | Ruby | ministryofjustice/check-financial-eligibility | /app/services/collators/gross_income_collator.rb | UTF-8 | 2,968 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module Collators
class GrossIncomeCollator < BaseWorkflowService
include Transactions
def call
if assessment.employments.any?
assessment.employments.each { |employment| Utilities::EmploymentIncomeMonthlyEquivalentCalculator.call(employment) }
Calculators::EmploymentIncomeCalculator.call... | true |
7e1264f244c6e005ba524b5ef25ca9bbda4d4b31 | Ruby | AquaCheckPool/demoapiaquacheckpool | /apisimulator.rb | UTF-8 | 855 | 3.140625 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'json'
#constantes
MINUTES = 1
POOLS = [1,2,3]
APIURL = "http://aquacheckpool.herokuapp.com/api/add_pool_values"
def send_values(pool_id,ph,cl2,temp)
uri = URI.parse(APIURL)
header = {'Content-Type': 'application/json'}
user = {
pool_id: pool_id,
... | true |
edbe8781e2c2d4c616381ee618921a83051bd9eb | Ruby | nubs/euler | /015-grid-routes.rb | UTF-8 | 446 | 3.375 | 3 | [] | no_license | #def numroutes(rows, cols)
# return (cols == 2 ? rows + 1 : numroutes(rows, cols-1)) + (rows == 2 ? cols + 1 : numroutes(rows-1, cols))
#end
#puts numroutes(ARGV[0].to_i, ARGV[0].to_i)
#def pascal(row, col)
# (1..col).inject(1) {|v, c| v * (row + 1 - c) / c }
#end
#puts pascal(2*ARGV[0].to_i, ARGV[0].to_i)
class Inte... | true |
4fcad31ea1baf270eb0521e8597a24273c781e71 | Ruby | hugotannus/social-recipes | /spec/features/users_update_their_profile_spec.rb | UTF-8 | 2,490 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
feature 'User updates his profile' do
scenario 'successfully' do
user = create(:user)
authenticate(user)
within 'header' do
click_on user.name
click_on 'Editar perfil'
end
fill_in 'Nome', with: 'John Doe Jr.'
fill_in 'Senha', with: 'novasenha'
fill_in ... | true |
b9b3b6573a4a011bd8156759be81a9bf10d6d8b8 | Ruby | holmesm8/rev_it_up | /app/facade/restaurant_facade.rb | UTF-8 | 283 | 2.984375 | 3 | [] | no_license | class RestaurantFacade
attr_reader :data
def initialize(data)
@data = data
end
def name
@data[:name]
end
def avg_rating
@data[:avg_rating]
end
def address
@data[:location][:display_address].join(" ")
end
def price
@data[:price]
end
end
| true |
53c8e6438bb0c8677bb12ec90b13c61d8b96a16d | Ruby | borivo/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 492 | 3.859375 | 4 | [] | no_license |
def echo(ech)
return ech.to_s
end
def shout(sh)
return sh.to_s.upcase
end
def repeat(word, amount=2)
new_word = ((word+" ") * amount).strip
return new_word
end
def start_of_word(word,letter)
letter -= 1
word[0..letter]
end
def first_word(word)
word.partition(" ").first
end
def titleize(word)
stop... | true |
852320ce46c2e287e4766eae830e821c57edb7b9 | Ruby | darkfeatherstsai/codewartrain | /train_code/create_phone_number.rb | UTF-8 | 451 | 3.984375 | 4 | [] | no_license | =begin
題目:給一個長度為 10 的實數陣列(數字介於 0 - 9)
將其轉換成 "(123) 456-7890" 的形式
想法:
=end
def create_phone_number(arr)
return "(" + arr[0..2].join + ") " + arr[3..5].join + "-" + arr[6..9].join
end
create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
=begin
後記:修正成下面這樣比較簡潔
def create_phone_number(arr)
return "(#{arr[0..2].joi... | true |
192cd648c2ffad2ab5673677ba99dd06c7d1b61d | Ruby | BrianButterly/mod-1-mini-challenge-intro-to-oo | /run.rb | UTF-8 | 806 | 3.296875 | 3 | [] | no_license | require 'pry'
require_relative "./models/clown"
# test your code here!
# create a few new clown instances, for example:
#krusty = Clown.new("Krusty", 55, "Juggling Chainsaws", "Failure")
# then run "ruby run.rb" and call your methods to make sure your code works
# for example:
# krusty.name
# => "Krusty"
# krusty.na... | true |
2ec6fb22aaa581387e828392e943cac7878accd9 | Ruby | christinacarlson/MadLib | /lol.rb | UTF-8 | 1,468 | 3.8125 | 4 | [] | no_license | #ask user if they want a knock knock joke, a mad lib or a riddle
puts "Welcome to the Laughter Lab!"
puts "Choose a category and type your choice."
puts "knock knock joke, mad lib, riddle"
games = {}
kkjoke = {0=>"a", 1=>"b", 2=>"c"}
mlib = {0=>"d", 1=>"e", 2=>"f"}
riddle = {0=>"g", 1=>"h", 2=>"i"}
games["kn... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.