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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5e0d4b55bbea416cf13311ef552d63331b2f87f8 | Ruby | membrain/T003_easter-egg | /vendor/plugins/jesture/lib/jesture.rb | UTF-8 | 3,961 | 2.65625 | 3 | [
"MIT"
] | permissive | require "keymap"
module Jesture
class Config
attr_reader :jestures, :combos
def initialize(file = File.join(RAILS_ROOT, "config", "jestures.rb"))
@jestures = {}
@combos = {}
self.instance_eval(File.read(file))
end
def combo(name, *sequence)
@combos[name] = sequence.m... | true |
e3120183a082ae565b88e0c2bcb9e36149a06c1e | Ruby | ehundt/phaeno | /spec/models/station_spec.rb | UTF-8 | 887 | 2.625 | 3 | [] | no_license | require "spec_helper"
describe Station do
context "precise geolocation of a station is given" do
let!(:geolocation) { { latitude: 53.65,
longitude: 10.1833 } }
let!(:station) { Station.create( { dwd_station_id: 1,
name: "Hamburg-Volk... | true |
8813c3e33ac8fa5fe39d989273007915cf115be4 | Ruby | ascarter/config_vault | /lib/config_vault/homebrew.rb | UTF-8 | 1,686 | 2.515625 | 3 | [
"MIT"
] | permissive | module ConfigVault
module Homebrew
module_function
def collection(taps: [], pkgs: [], casks: [])
taps.each { |t| tap t }
pkgs.each { |p| install p }
casks.each { |c| Cask.install c }
end
def prefix(pre)
@prefix = pre
end
def command
@cmd ||= File.join(@prefix ... | true |
e3b207b37a1a444005b1655d66069b7e4f1f8ec6 | Ruby | charleslim88/phase-0-tracks | /ruby/shout.rb | UTF-8 | 229 | 3.578125 | 4 | [] | no_license | module Shout
def yell_angrily(words)
puts "#{words}!"
end
end
class Babies
include Shout
end
class Dogs
include Shout
end
babies = Babies.new
babies.yell_angrily("WAHHHH")
humans = Dogs.new
humans.yell_angrily("RUFF") | true |
b4316a1fe5d0b90bcb2f9724465b63ba0f180451 | Ruby | wissiyou/ruby | /exo_10.rb | UTF-8 | 135 | 3.421875 | 3 | [] | no_license | puts "En quelle année es-tu né ?"
birth_date = gets.chomp.to_i
age = 2017 - birth_date
puts "En 2017 tu avais " + age.to_s + " ans"
| true |
50970c8b3243f291d0352c668a7593479ab5a44f | Ruby | shortthirdman/code-eval-challenges | /moderate/sum4.rb | UTF-8 | 289 | 2.828125 | 3 | [
"MIT"
] | permissive | def numzero(s, c, z)
return z == 0 ? 1 : 0 if c == 0
return 0 if s.length < c || z + c * s[0] > 0 || z + c * s[-1] < 0
numzero(s[1..-1], c - 1, z + s[0]) + numzero(s[1..-1], c, z)
end
File.open(ARGV[0]).each_line do |line|
puts numzero(line.split(',').map(&:to_i).sort, 4, 0)
end
| true |
3a440d3d5f2c242bb942170a8b5f2777fdc8ea14 | Ruby | sukendhar/mine_app | /app/models/employee.rb | UTF-8 | 383 | 2.6875 | 3 | [] | no_license | class Employee < ActiveRecord::Base
attr_accessible :first_name, :last_name
def self.build_from_csv(row)
@error = nil
cust = Employee.find_or_initialize_by_first_name(row[0])
cust.attributes ={:first_name => row[0],
:last_name => row[1]}
return cust,@error
end
def self.E... | true |
dcc98f96f6062f8299354fc1c1d18b005bb9e755 | Ruby | ruby-concurrency/concurrent-ruby | /spec/concurrent/monotonic_time_spec.rb | UTF-8 | 865 | 2.65625 | 3 | [
"MIT",
"Ruby"
] | permissive | require 'concurrent/utility/monotonic_time'
module Concurrent
RSpec.describe :monotonic_time do
context 'behavior' do
it 'returns seconds as float' do
expect(Concurrent.monotonic_time).to be_a(Float)
end
[:float_second, :float_millisecond, :float_microsecond].each do |unit|
i... | true |
2df1711c2d5cd8215d88d8c75c05da762f0a9d34 | Ruby | acltc/ruby_practice | /filter_a_names.rb | UTF-8 | 301 | 3.296875 | 3 | [] | no_license | # Filter an array of names to only contain names that start with the letter "A".
# Driver code
p filter_a_names(["Bob", "Charlie", "Angel"]) # should be ["Angel"]
p filter_a_names(["Bob", "Charlie", "Bangel"]) # should be []
p filter_a_names(["Adam", "Charlie", "Adam"]) # should be ["Adam", "Adam"] | true |
5298f8c702fa77215c2d093489a49783699725eb | Ruby | RemyRamirez/Jour_6_ruby_gem | /lib/Untitled-1.rb | UTF-8 | 702 | 4.3125 | 4 | [] | no_license | def is_multiple_of_3_or_5?(current_number)
if current_number.class != Integer
puts "Yo ! Je ne prends que les entiers naturels. TG"
elsif (current_number %3) == 0 || (current_number %5) == 0
puts "true"
return true
else
return false
end
end
def sum_of_3_or_5_multiples... | true |
9c6e8a424e3f9feed68e5fe99f5706db9133e1c2 | Ruby | elliottevers/algorithmic_problems | /spec/intersection_spec.rb | UTF-8 | 215 | 2.71875 | 3 | [] | no_license | require 'rspec'
require_relative '../lib/intersection.rb'
describe '#intersection' do
it 'works' do
arr1 = [1,3,5,7,6,4]
arr2 = [1,-4,-7,3,10,12]
expect(intersection(arr1,arr2)).to eq [1,3]
end
end
| true |
90d5f998f2ed5321e2d1afcbb2fbb5b4423b77f6 | Ruby | dzhaparoff/zumbaster | /lib/shows/kinopoisk.rb | UTF-8 | 1,153 | 2.546875 | 3 | [] | no_license | class Kinopoisk
def initialize
@http = new_http_request_builder APP_CONFIG['kinopoisk_api_url']
end
def rating(kinopoisk_id)
rating = Nokogiri::Slop @http.get("https://rating.kinopoisk.ru/#{kinopoisk_id}.xml").body
kp = rating.rating.kp_rating.content if defined? rating.rating.kp_rating
kp_num_... | true |
451b65d9821781f9b86aeedb88be609b002cedd3 | Ruby | lugray/advent_of_code | /2022/day09.rb | UTF-8 | 786 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'day'
require 'matrix'
require 'set'
class Day09 < Day
DIRECTIONS = { 'U' => Vector[0, -1], 'D' => Vector[0, 1], 'L' => Vector[-1, 0], 'R' => Vector[1, 0] }
def initialize
@motions = input_grid
end
def simulate(knots)
@motions.each_with_object(Set.new) do |(dir, ... | true |
f7ce7f5618e71277470b0cc9a64e1fce32848496 | Ruby | shatalov-boris/slack_backup | /app/services/history_restorer.rb | UTF-8 | 790 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class HistoryRestorer
def self.restore(folder)
channels_json = File.read(folder + "channels.json")
channels = Oj.load(channels_json)
channels.each do |json_channel|
puts "Restoring #{json_channel['name']}"
channel = ChannelBuilder.build_from_json(json_channel)
... | true |
97559925eecfbaa3e137cb8cc4054510cf838748 | Ruby | Ivor/null_object_loader | /spec/support/school.rb | UTF-8 | 143 | 2.859375 | 3 | [
"MIT"
] | permissive | class School
attr_accessor :name, :principal
def initialize(name, principal = nil)
@name = name
@principal = principal
end
end | true |
8caecf239bb18209686906c2c121547eb6f6cce2 | Ruby | pasierb/time-shit | /test/time_shit/test_storage_csv.rb | UTF-8 | 2,719 | 2.71875 | 3 | [] | no_license | require 'test_helper'
class TestStorageCSVFileSystem < Test::Unit::TestCase
def setup
@folder = File.expand_path( File.join( __FILE__, "../../../tmp/time-shit" ) )
TimeShit::Config.stubs( :container ).returns( @folder )
end
def teardown
if Dir.exists?( @folder )
FileUtils.rm_rf("#{@folder}/.... | true |
d058ce864b76b30630124111a459f2ffa3233d0e | Ruby | Aramuad/casino | /player.rb | UTF-8 | 1,720 | 3.453125 | 3 | [] | no_license | require_relative 'cardsdeck'
require_relative 'generic'
require_relative 'dealer'
require 'colorize'
#require 'pry'
class Player < Dealer
attr_accessor :p_finish, :player_cards
def initialize(person)
@generic = Generic.new
@deck = Deck.new
@cards_deck = @deck.cards
@player_cards = []
@player_ca... | true |
e75ef5f5a178b42976afa8dc6efaad19dff96825 | Ruby | jas0nmjames/jas0nmjames.github.io | /vendor/bundle/ruby/3.2.0/gems/hashery-2.1.2/test/case_casting_hash.rb | UTF-8 | 1,289 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | require 'helper'
test_case CastingHash do
class_method :[] do
test do
h = CastingHash[:a=>1, :b=>2]
end
end
class_method :new do
test do
h = CastingHash.new
end
test 'with default' do
h = CastingHash.new(0)
h['a'].assert == 0
end
test 'with casting procedur... | true |
2bbded95bedef198063273ba6bcfdfa0fb727934 | Ruby | pdw207/TDD-Practice---Fractions-Object | /lib/fraction.rb | UTF-8 | 2,460 | 3.6875 | 4 | [] | no_license | class Fraction
# We need these to be attr_reader so that we can access the values from other fractions that we may use
attr_reader :numerator, :denominator
def initialize(numerator, denominator)
@numerator = numerator
@denominator = denominator
end
# We implement our own custom inspect method so that... | true |
b236dbc8afda1a4bf6a9b3959e4830f55af91a48 | Ruby | kengonakajima/snippets | /ruby/rubyinit2/aho.rb | UTF-8 | 81 | 2.90625 | 3 | [] | no_license | class Aho
def initialize(a)
return nil
end
end
a = Aho.new(1)
print a
| true |
237ba665c39f3499caf835054433a73241f2284e | Ruby | amsmyth1/rails-engine | /spec/models/item_spec.rb | UTF-8 | 4,093 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
describe "validations" do
it { should belong_to :merchant }
end
describe ".paginate" do
it "takes arguments for page and per_page to display results" do
answer = Item.paginate(page: 3, per_page: 2)
item_1 = create(:item)
item_... | true |
b16728f1fe65c3543003a4a92616a45712d14aa2 | Ruby | brad72287/project-euler-multiples-3-5-q-000 | /lib/multiples.rb | UTF-8 | 205 | 3.390625 | 3 | [] | no_license | # Enter your procedural solution here!
def collect_multiples(limit)
(1...limit).select {|x| x%3==0 || x%5==0}
end
def sum_multiples(limit)
sum=0
collect_multiples(limit).each {|x| sum+=x}
sum
end
| true |
ca0d4ba8f5c93b4c661e5cb25bfb7f9ff4ea93f1 | Ruby | OlukaDenis/Ruby-Data-Structures | /back-tracking-recursion.rb | UTF-8 | 453 | 3.53125 | 4 | [] | no_license | # frozen_string_literal: true
def exact_sum?(k, coins)
# write your code here
check_sum(k, coins, 0)
end
def check_sum(k, coins, i)
return true if k.zero?
return false if i >= coins.size && !k.zero?
p "Increment: #{i}"
p "Sum: #{k}"
p "============================"
check_sum(k - coins[i], coins, i +... | true |
f098814b90d530b64730e498e26cb52f5c89e520 | Ruby | f3mshep/oo-meowing-cat-v-000 | /lib/meowing_cat.rb | UTF-8 | 95 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ## code your solution here.
class Cat
def meow
puts "meow!"
end
attr_accessor :name
end | true |
887ab3127a98e668ab0bc763aa4220894ead3bbc | Ruby | ainevethe/collections_practice-cb-000 | /collections_practice.rb | UTF-8 | 794 | 3.78125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort! {|a, b| b <=> a}
end
def sort_array_char_count(array)
array.sort! {|a, b| a.length <=> b.length}
end
def swap_elements(array)
array[1], array[2] = array[2], array[1]
array
end
def reverse_array(array)
array.reverse... | true |
9e1d99d3446ccc890a09d376518b6b1c2490f543 | Ruby | cupakromer/fetchers | /lib/geocoder/ext/result_google.rb | UTF-8 | 1,105 | 2.953125 | 3 | [] | no_license | require 'geocoder/results/google'
class Geocoder::Result::Google
BOUNDING_BOX_KEYS = [:north_lat, :east_lng, :south_lat, :west_lng].freeze
def bounding_box( order = BOUNDING_BOX_KEYS )
coordinates = map_box_keys_to_values
order.map{ |key| coordinates[key] }
end
def extract_zip
zip_component = add... | true |
17cbecc1da98eb7cb09e0cf28eb9359fa9672bb8 | Ruby | trustedchild/create-gem-project | /spec/hola_spec.rb | UTF-8 | 319 | 2.84375 | 3 | [] | no_license | require 'hola'
RSpec.describe Hola do
describe '#hi' do
it ' returns hello world' do
lang = Hola.hi
expect(lang).to be_a_kind_of(String)
end
it "returns holo mundo" do
lang = Hola.hi('spanish')
end
it "returns hola monde" do
lang = Hola.hi('french')
end
end
end
| true |
6d215e5d18c6508b3f7e67fca08c6ce2bbdaa08b | Ruby | DaniilYusha/codebreaker | /spec/codebreaker/game_init_spec.rb | UTF-8 | 1,092 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe Codebreaker::Game do
let(:user) { Codebreaker::User.new 'Daniil' }
let(:difficulty) { Codebreaker::Difficulty.new 'hell' }
let(:game) { described_class.new user, difficulty }
describe '.init' do
it 'secret code is an Array' do
expect(game.secret_code.class... | true |
25c3ee94c6709a2574bb1a783460afcdc182e1a4 | Ruby | dbsk11/ruby-enumerables-reverse-each-word-lab-nyc01-seng-ft-042020 | /reverse_each_word.rb | UTF-8 | 394 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def reverse_each_word(string)
array = string.split(" ")
new_array = []
array.each do |word|
new_array << word.reverse
end
new_array.join(" ")
end
def reverse_each_word(string)
array = string.split(" ")
new_array = []
array.collect do |word|
new_array << word.reverse
end
new_a... | true |
789744b4b43aecea8e295622b35723db93b5bd6c | Ruby | likwokbiu/collections_iteration | /exercise11.rb | UTF-8 | 998 | 4.375 | 4 | [] | no_license | puts "How many pizzas do you want to order?"
number_of_pizza = gets.chomp.to_i
pizza_array = []
for i in (1..number_of_pizza)
puts "How many toppings for pizza #{i}?"
number_of_topping = gets.chomp.to_i
if number_of_topping == 1
puts "You have ordered a pizza with #{number_of_topping} topping."
else
pu... | true |
5eae557a9220264498a63e29ea95abd30e11d008 | Ruby | rajsolanki/davinci_motors | /spec/features/creating_cars_spec.rb | UTF-8 | 2,266 | 2.53125 | 3 | [] | no_license | require "rails_helper"
feature "Creating Cars" do
scenario "can create a car" do
visit '/'
click_link 'New Car'
fill_in 'Make', with: 'Ford'
fill_in 'Model', with: 'Mustang'
fill_in 'Year', with: '1967'
fill_in 'Price', with: '2300'
click_button 'Create Car'
expect(page).to have_c... | true |
1ef2229430303eb24200d7bafbe70b0493f903ed | Ruby | blazingcloud/my_cafe | /lib/menu_data.rb | UTF-8 | 220 | 2.734375 | 3 | [] | no_license | class MenuData
def self.make(data)
Item.delete_all
data.each do |item_data|
name, desc = item_data
puts " #{name} #{desc}"
Item.create!(:name => name, :description => desc)
end
end
end
| true |
273cbe1e1251eab5ed373fcc0ee438824c74dcc2 | Ruby | plicjo/codility_exercises | /spec/tape_equilibrium_spec.rb | UTF-8 | 543 | 2.90625 | 3 | [] | no_license | require 'spec_helper'
require_relative'../tape_equilibrium'
describe '#tape_equilibrium' do
it 'returns the smallest absolute difference' do
array = [3, 1, 2, 4, 3]
expect(tape_equilibrium(array)).to eq(1)
end
it 'works for a small array' do
array = [6, 2]
expect(tape_equilibrium(array)).to eq(4... | true |
1c3c464981f6aca1fca859d1eb619e6607fd2101 | Ruby | wchu248/67-272-Phase-2 | /app/models/item_price.rb | UTF-8 | 2,126 | 2.734375 | 3 | [] | no_license | class ItemPrice < ActiveRecord::Base
# Relationships
# -----------------------------
belongs_to :item
# Scopes
# -----------------------------
# gets only current prices
scope :current, -> { where(end_date: nil) }
# returns the prices for a specified date
scope :for_date, ->(date) ... | true |
13a1b4bd852695a52fb273bef00a6217ecb6e467 | Ruby | gabrielalmeidaa/PokeTraderCalculator | /app/models/trade_offer.rb | UTF-8 | 1,164 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
class TradeOffer
include Mongoid::Document
POKEMON_PER_TRADE_LIMIT = 6
embeds_many :pokemons
validate :pokemon_offer_list_not_empty
validate :pokemon_offer_list_does_not_surpass_pokemon_limit
validate :only_pokemon_instances_on_pokemon_array
def self.build_from_pokemon_ids... | true |
b04e3012f57d062e72a9b0d09a440f64222d1b68 | Ruby | savelbl4/ruby_lessons | /lesson05/cursor.rb | UTF-8 | 118 | 2.734375 | 3 | [] | no_license | # encoding: utf-8
sym = ['|','/','-','\\']
i = 0
while true
print sym[i % sym.size], "\r"
i += 1
sleep 0.1
end
| true |
46985bb8a13c245b95cd626fb7860368e4790219 | Ruby | kirs/rom | /lib/rom/mapper/builder/definition.rb | UTF-8 | 2,741 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
module ROM
class Mapper
class Builder
# Mapping definition DSL
#
# @private
class Definition
include Equalizer.new(:attributes, :model, :loader)
attr_reader :attributes, :mapper
LOADERS = [:instance_variables, :attribute_hash, :attribute_access... | true |
4b6819384ff3a6ef9420a90ab48c36c8514e3dad | Ruby | portatlas/tictactoe-ruby | /lib/console.rb | UTF-8 | 148 | 3 | 3 | [
"MIT"
] | permissive | $: << File.dirname(__FILE__)
class Console
def get_user_input
gets.chomp
end
def display_msg(message)
puts "#{message}"
end
end
| true |
1df2fac0f6ace362e9c41a785f67cffae4d2f124 | Ruby | ldgeanixr/rails-repo-test | /app/controllers/articles_controller.rb | UTF-8 | 1,729 | 2.6875 | 3 | [] | no_license | class ArticlesController < ApplicationController
before_action :set_article, only: [:edit, :update, :show, :destroy] #only this 4 methods will call set_article
def index
@articles = Article.all #grab all the articles(plural for convenience)
end
def new
@article = Article.new
end
def create
#debugger
... | true |
70eb509dc1066a431c36b2336c6e970036b7f760 | Ruby | ghostreef/bills-reminder | /app/models/purpose.rb | UTF-8 | 1,026 | 2.515625 | 3 | [] | no_license | # rails g model Purpose name:string
class Purpose < ActiveRecord::Base
validates :name, uniqueness: true, length: { minimum: 1 }
SUGGESTED_DEFAULTS = ['external transfer', 'internal transfer', 'income', 'services rendered', 'goods rendered',
'credit card payment', 'loan payment', 'anonymous... | true |
74482980455b71a17a1d0b028480316a8861d608 | Ruby | zacharydenton/soywiki | /lib/soywiki.rb | UTF-8 | 1,520 | 2.625 | 3 | [
"MIT"
] | permissive | require 'string_ext'
module Soywiki
VERSION = '0.9.1'
WIKI_WORD = /\b([a-z0-9][\w_]+\.)?[A-Z][a-z]+[A-Z0-9]\w*\b/
HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
def self.run
if %W( -v --version -h --help).include?(ARGV.first)
puts "soywiki #{Soywiki::VERSION}"
puts "by Daniel Choi dhchoi@gmail.com"
... | true |
965a195484b1688c520cfe53677d3a493593b13e | Ruby | ashumkin/torrents.watcher | /test/test-tracker.rb | UTF-8 | 1,878 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
# vim: set shiftwidth=2 tabstop=2 expandtab:
require 'test/unit'
require File.expand_path('../../lib/tracker.rb', __FILE__)
require File.expand_path('../helpers/mocks/tracker-owner.rb', __FILE__)
module TorrentsWatcher
class TestTracker < Test::Unit::TestCase
TESTED_FOLDER = File.expand_path('.... | true |
1f614e00e4a51bb606fd1a4c85fdf5bb8e15c7fd | Ruby | SiriusLL/Math_Game | /math_game/math_game_pair.rb | UTF-8 | 1,283 | 4.6875 | 5 | [] | no_license | # CLASS
# 1. create players, give a name, 3 lives, and score of 3/3
#create player class, will initialze instance variable for name, lives, Score
class Player
def initialize(name)
@name = name
@lives = 3
@score = score
end
end
player_1 = Player.new("Player_1")
player_2 = Player.new("Player_2")
#C... | true |
0d4f40a5c2ec8b95245a5e22a0b2fcb0dd1c189d | Ruby | eraytufan/CS342-Design-Patterns | /project3/Deck.rb | UTF-8 | 598 | 3.765625 | 4 | [] | no_license | require './Card.rb'
require "enumerator"
class Deck
include Enumerable
def initialize
@ranks = %w(2 3 4 5 6 7 8 9 T J Q K A)
@suits = %w(c d h s)
@cards = []
@ranks.each do |rank|
@suits.each do |suit|
@cards << Card.new(rank, suit)
end
end
shuffle()
end
#deals ... | true |
e776490c71f56491c9f6867216d60df8914b46c4 | Ruby | rdavid1099/black_thursday | /test/item_test.rb | UTF-8 | 3,570 | 2.625 | 3 | [] | no_license | require './test/test_helper'
require './lib/item'
class TestItems < Minitest::Test
def test_items_have_id
item = Item.new({:id => "263399749", :name => "Grande toile", :description => "Acrylique sur toile, mesurant environs 80/50cm.", :unit_price => "5000", :merchant_id => "12334395", :created_at => "2016-01-11... | true |
964f9de5d654a4cbbe67dd67f460b29f93aff8b3 | Ruby | Virakal/2015-Advent-of-Code | /9.2.rb | UTF-8 | 2,015 | 3.234375 | 3 | [] | no_license | def parse instructions
dists = parse_distances instructions
longest_path = {path: nil, dist: nil}
dists.keys.each do |place1|
dists.keys.each do |place2|
dists.keys.each do |place3|
dists.keys.each do |place4|
dists.keys.each do |place5|
dists.keys.each do |place6|
dists.keys.each do |place7|
dists... | true |
11d3483111ed6bb9effd2ea2560aedacdadf1eff | Ruby | Morozov-IvanM/task | /hello.rb | UTF-8 | 119 | 3.21875 | 3 | [] | no_license | puts 'How match second do y live?'
time=gets.chomp
ear=time.to_i/60/60/24/365
ear1=ear.to_s
puts 'Y live '+ear1+' ear'
| true |
d584ba84b8f6cad8eb17d7e1691b96cf3488d9dd | Ruby | aleksanderbrymora/sei-36 | /karthikeyan_sekar/week4/day2/homework/MTAruby.rb | UTF-8 | 3,267 | 3.359375 | 3 | [] | no_license |
$subwayLines = [{ :line => 'N' , :stops => ["Time Square","34th","28th", "23rd","Union Square","8th"]},
{:line => 'L', :stops => ["8th","6th", "Union Square","3rd","1st"]},
{:line => 'P', :stops => ["Grand Central","33rd", "28th","23rd","Union Square","Astor Place"]}]
$interSect... | true |
38d1f5b5676c5e7f40a2ac9bea111db2b0eb77af | Ruby | kmkr/moviemanage | /app/mover/movie_mover.rb | UTF-8 | 2,767 | 2.890625 | 3 | [] | no_license | require_relative '../common/file_finder'
require_relative '../common/file_writer'
require_relative 'audio_file_finder'
require_relative 'tease_file_finder'
require 'fileutils'
class MovieMover
def initialize
@tease_file_finder = TeaseFileFinder.new
@movie_file_finder = FileFinder.new
@audio_file_finder = Audio... | true |
23928eecdb1f2086f4f76dbda18bab124bca9a03 | Ruby | d-otis/cli-applications-guessing-game-online-web-prework | /guessing_game_cli.rb | UTF-8 | 814 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
# Code your solution here!
# def run_guessing_game
# secret_num = rand(1..6).to_s
# puts "Pick a number between 1 and 6"
# user_input = gets.chomp
# if user_input == "exit"
# puts "Goodbye!"
# elsif user_input != secret_num
# puts "Sorry! The computer guessed #{secret_num}."
# elsif u... | true |
ae6c42ec30fc694e6a1a67068632edb8aa2fd3aa | Ruby | MarieHughes93/p5c | /lib/p5c/cli.rb | UTF-8 | 4,512 | 3.484375 | 3 | [
"MIT"
] | permissive | # My CLI controller - responsible for business logic or user interactions
require 'colorize'
class CLI
def self.exit
input = "exit"
end
def self.option_1
print Compendium.all_persona_by_name
puts "Ruji: Come on man, select a number 1 to 225. We have treasures to unlock!\n".yellow
answer = gets.st... | true |
6f450505171c01ee5fa855f29cd30624d49f28c5 | Ruby | FabioAlvarado/Exercises-Ruby | /p010_backslash.rb | UTF-8 | 813 | 4.09375 | 4 | [] | no_license | puts "I am 6' 2\" tall."
puts 'I am 6\' 2" tall.'
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."
fat_cat = <<MY_HEREDOC
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
MY_HEREDOC
puts tabby_cat
puts persian_cat
puts backslash_cat
puts fat_cat
#... | true |
2b6d35213a707e1cd8e4e909f215939c46bf17c9 | Ruby | simonanger/snakes_ladders_lab | /spec/dice_spec.rb | UTF-8 | 517 | 3.09375 | 3 | [] | no_license | require( "minitest/autorun" )
require_relative( "../dice.rb" )
class TestDice < MiniTest::Test
def setup()
@dice = Dice.new( "Dice 1", 6 )
end
def test_dice_name
assert_equal( "Dice 1" , @dice.name )
end
def test_dice_sides
assert_equal( 6, @dice.sides)
end
# We tested the random number ge... | true |
366f5e2d43a34a6100eb953833797f720885d7b7 | Ruby | rubizza-camp/AppTracker | /lib/tasks/target_counry.rake | UTF-8 | 655 | 2.5625 | 3 | [] | no_license | namespace :country_manager do
desc 'Add new country to database'
task add: :environment do
ARGV.each { |arg| task arg.to_sym }
ARGV.drop(1).each do |arg|
TargetCountry.create(country_name: arg)
end
end
desc 'List all target countries'
task list: :environment do
TargetCountry.all.each_wi... | true |
d4a402280693f621021d344abbc864809acb88d0 | Ruby | julioprotzek/iddd_ruby | /lib/domain/identity/user_registered.rb | UTF-8 | 275 | 2.59375 | 3 | [] | no_license | class UserRegistered
attr_reader :version, :occurred_at, :username, :name, :email_address
def initialize(username:, name:, email_address:)
@version = 1
@occurred_at = Time.now
@username = username
@name = name
@email_address = email_address
end
end | true |
3e9c63aafc92ff6858af6872e2b5de7fb28e97e8 | Ruby | jmrcounseling/tealeaf-preparation | /tealeaf_preparation/return2.rb | UTF-8 | 381 | 3.203125 | 3 | [] | no_license | def add_three(number)
number + 3
end
returned_value = add_three(4)
puts returned_value
def add_three(number)
return number + 3
end
returned_value = add_three(4)
puts returned_value
def add_three(number)
return number + 3
number + 4
end
returned_value = add_three(4)
puts returned_value
def just_assignment(num... | true |
3c502d61fddb9ecb6456b20400f35684fddc602c | Ruby | patcarrasco/artist-song-modules-dumbo-web-111918 | /lib/concerns/paramable.rb | UTF-8 | 133 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Paramable
def to_param
name.downcase.gsub(' ', '-') # makes a string into parameter by replacing space with -
end
end
| true |
be47b5e3cb5bd024cc57b6f2992fe933f4c0d632 | Ruby | johnandjoss/word-checker | /spec/checker_spec.rb | UTF-8 | 617 | 3.4375 | 3 | [
"MIT"
] | permissive | require('rspec')
require('checker')
#It checks how frequently a given word appears in a given string.
#The user is able to input both the given word and the string to check for repeats.
describe('String#checked') do
it("returns the repeated words taken from a given sentence in an array") do
expect(("this cat i... | true |
5a8598cb01044ecfb235887ee0d7bc10628276d6 | Ruby | chrodriguez/ttps-presentacion-cli | /ttps_subject_presentation.rb | UTF-8 | 2,910 | 2.9375 | 3 | [] | no_license | require_relative "subject_presentation"
require_relative "teacher"
require_relative "schedule"
class TTPSSubjectPresentation < SubjectPresentation
def initialize(*,**)
super(title: "Tecnologias de\nProduccion de Software")
self.subtitle = "Ruby"
add_teacher Teacher.new(
kind: "Profesor",
f... | true |
1165deebd9a3ef93f6bbe62cf346aa3fa40b152c | Ruby | evelynnkaplan/MediaRanker | /app/models/work.rb | UTF-8 | 680 | 2.5625 | 3 | [] | no_license | class Work < ApplicationRecord
has_many :votes
has_many :users, through: :votes
def self.categories
return ["movie", "book", "album"]
end
def self.highlight
works = Work.all
works.max_by { |work| work.votes.count }
end
def self.top_works(category)
all_works = Work.where(category: catego... | true |
6743f64c0bc789a2a595caae1bcef92740edfee9 | Ruby | rubyworks/erbside | /lib/erbside/inline/sgml.rb | UTF-8 | 3,202 | 2.703125 | 3 | [
"BSD-2-Clause-Views",
"BSD-2-Clause"
] | permissive | module Erbside
require 'erbside/inline'
# XML and HTML
class SGML < Inline
EXTENSIONS = %w{ .html .xml }
#
def self.extensions
EXTENSIONS
end
#
def remarker
'<!--'
end
#
def remarker_block_begin
'<!--'
end
#
def remarker_block_end
'-->... | true |
eb523351cfb45da206fdead00dd5a450c37f45e7 | Ruby | JaganNarayanan/ar-sunlight-legislators | /lib/sunlight_legislators_importer.rb | UTF-8 | 1,273 | 3.015625 | 3 | [] | no_license | require 'csv'
require_relative '../db/config'
class SunlightLegislatorsImporter
def self.import(filename)
csv = CSV.new(File.open(filename), :headers => true)
csv.each do |row|
Legislator.create(title: row[0], first_name: row[1], middle_name: row[2], last_name: row[3], party: row[6], state: row[7], in_o... | true |
524d021fae76364beddae62f23c2069c26e517d8 | Ruby | paulfitz/rb_coopy | /lib/coopy.rb | UTF-8 | 4,056 | 2.625 | 3 | [] | no_license | require 'optparse'
class Coopy
class Flavor
attr_accessor :key
attr_accessor :banner
attr_accessor :min_length
def sql_subject?
[:diff,:patch].include? key
end
def sql_object?
key == :diff
end
def can_choose_format?
key != :patch
end
def can_set_output?
... | true |
fc8f014f57383437e7b93871a2bf191cf2fc89b4 | Ruby | arishermawan/go-scholar | /ex_cdwr/in_array.rb | UTF-8 | 370 | 3.59375 | 4 | [] | no_license | def in_array(array1, array2)
arr=[]
for i in 0...array2.length
array1.each do |x|
if array2[i].include?x
arr << x if !arr.include?x
end
end
end
arr
end
a1 = ["arp", "live", "strong"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
print in_array(a1, a2)
a1 ... | true |
a5b7bf7d8da17acd21d82e3537bed220493a6922 | Ruby | DanFCo/badges-and-schedules-dumbo-web-career-031119 | /conference_badges.rb | UTF-8 | 963 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
badges = []
attendees.each do|attendee|
greeting = "Hello, my name is " + attendee + "."
badges.push(greeting)
end
return badges
end
#def assign_rooms(attendees)
... | true |
335de0f62f130534877ceb9e638c6ad32f6735e8 | Ruby | nyc-cicadas-2015/Jooooooke | /model.rb | UTF-8 | 388 | 2.8125 | 3 | [
"MIT"
] | permissive | class JokeGenerator
attr_accessor :all_jokes, :all_dummy
attr_writer :used_joke
def initialize(args={})
@all_jokes = args[:all_jokes]
@all_dummy = args[:all_dummy]
end
def joke_getter
@all_jokes.shift
end
def dummy_getter
@all_dummy.sample
end
def dummy_sample
dummy_getter.dum... | true |
a99a162fba41a2f2560f197b083c445f31b0f8f4 | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/332.reconstruct-itinerary.rb | UTF-8 | 1,512 | 3.4375 | 3 | [] | no_license | #
# @lc app=leetcode id=332 lang=ruby
#
# [332] Reconstruct Itinerary
#
# https://leetcode.com/problems/reconstruct-itinerary/description/
#
# algorithms
# Medium (36.84%)
# Total Accepted: 169.1K
# Total Submissions: 459K
# Testcase Example: '[["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]'
#
# Given a l... | true |
168055f6798eeb444ec58642870c35cf4e41befe | Ruby | ryangadams/visual-component-library-parser | /lib/explorer.rb | UTF-8 | 1,112 | 2.609375 | 3 | [] | no_license | module LibraryExplorer
def render_html(components)
json = '{"components" : ['
components.each do |comp|
json = json + comp.to_json + ","
end
json.chomp!
json = json + "]}"
File.open("index.html","w") { |f|
f.write('<!DOCTYPE html><html><head><meta charset="UTF-8">')
... | true |
601077cf8a6be7c938b760a5873874940e5f4760 | Ruby | briecoyle/learn_ruby_the_hard_way | /ex9.rb | UTF-8 | 740 | 3.875 | 4 | [] | no_license | # Here's some new strange stuff, remember type it exactly
# sets a variable days equal to the string Mon Tue Wed Thu Fri Sat Sun
days = "Mon Tue Wed Thu Fri Sat Sun"
# sets a variable months equal to the string Jan
# Feb
# Mar
# Apr
# May
# Jun
# Jul
# Aug
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
# prints He... | true |
9c4c89f73908cc1be0ff3f78e8e7d54420d8df38 | Ruby | naoyanman-hashimoto/furima-35965 | /spec/models/product_spec.rb | UTF-8 | 4,066 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Product, type: :model do
describe '#create' do
before do
@product = FactoryBot.build(:product)
end
describe '商品出品機能' do
context '商品出品できる場合' do
it '必要な情報を適切に入力すると、商品情報がデータベースに保存されること' do
expect(@product).to be_valid
end
end
... | true |
b75ecb85827f9fbdb004df7efd46992d3a8ee15c | Ruby | riazmohamed/101_109_small_problems | /medium_1/rotate_rightmost_digits.rb | UTF-8 | 488 | 3.953125 | 4 | [] | no_license | # rotate_rightmost_digits.rb
def rotate_rightmost_digits(num, rotate_index)
arr = num.to_s.chars
rotate_element = arr.delete_at(-rotate_index)
result = arr + [rotate_element]
result.join.to_i
end
p rotate_rightmost_digits(735291, 1) == 735291
p rotate_rightmost_digits(735291, 2) == 735219
p rotate_rightmost_d... | true |
32b6067d0c510c431cff19e9bcf9c28549ac0270 | Ruby | hectorhuertas/business_placer | /app/services/finder_service.rb | UTF-8 | 1,464 | 2.671875 | 3 | [] | no_license | require 'yelp'
class FinderService
attr_reader :client
def initialize
@client = Yelp::Client.new({ consumer_key: ENV['YELP_CONSUMER_KEY'],
consumer_secret: ENV['YELP_CONSUMER_SECRET'],
token: ENV['YELP_TOKEN'],
... | true |
c3a7c87639721de799d5c2a154b9b9d73f9f21cb | Ruby | k-yasuda/mini_test_practice | /test/test_mini_test_practice.rb | UTF-8 | 1,014 | 2.875 | 3 | [
"MIT"
] | permissive | require 'minitest_helper'
class TestMiniTestPractice < MiniTest::Unit::TestCase
def setup
@my_class = ::MiniTestPractice::MyClass.new
end
def test_that_it_has_a_version_number
refute_nil ::MiniTestPractice::VERSION
end
def test_odd?
assert_equal true, @my_class.odd?(1)
# assert_equal false, @my... | true |
fe7e5b6a30af874b72502987c5e12ea5610a3e16 | Ruby | achen118/Homeworks | /w2d4/big_octopus/big_octopus.rb | UTF-8 | 2,558 | 4.125 | 4 | [] | no_license | # Big O-ctopus and Biggest Fish
# A Very Hungry Octopus wants to eat the longest fish in an array of fish.
fish = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
# => "fiiiissshhhhhh"
# Sluggish Octopus
# Find the longest fish in O(n^2) time. Do this by comparing all fish ... | true |
8ac330d16107f2fcca8bfc3f9043f542d957f175 | Ruby | ebmdatalab/nhstrusts | /_plugins/yesno.rb | UTF-8 | 753 | 2.59375 | 3 | [] | no_license | # coding: utf-8
module Jekyll
module YesNoFilter
def yesno(input)
if input and input.length == 1
if input.downcase.strip == 'y' or input.to_i > 0
"<span class='ballotbox tick'>yes</span>"
else
"<span class='ballotbox cross'>no</span>"
end
else
input
... | true |
fd8bdf1abed12cccc6d0bf14f09289c1bae6a9f6 | Ruby | ali1195shah/course | /sequential_array.rb | UTF-8 | 55 | 3.265625 | 3 | [] | no_license | numbers = [1,3,5,7,9,11,13,15,21]
puts numbers [3]
| true |
d89d22837242205e962387f3f7d06545b209c43f | Ruby | PositiveControl/OBGYN-Pt-Intake-Generator | /lib/patient.rb | UTF-8 | 967 | 2.578125 | 3 | [] | no_license | require 'patient_repository'
class Patient
ATTRIBUTES = [
:age, :g, :p, :at_weeks, :at_days, :by_weeks, :by_days, :ultrasound, :prenatal_care,
:placenta, :group_b_strep, :one_hr_diabetes, :three_hr_diabetes, :history, :times_delivery_type,
:largest_baby_birthed, :estimated_fetal_weight_lbs, :estim... | true |
8273f0ad57cd2cf7d1b4ba6093f21d9b7faac179 | Ruby | micfok/open-data | /db/seeds.rb | UTF-8 | 1,327 | 2.515625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
85822b8224c65e5c7b8759fd2608922d8e821135 | Ruby | PSalant726/AppAcademy | /Course Work/w2d4/max_windowed_range.rb | UTF-8 | 708 | 3.40625 | 3 | [] | no_license | def naive_window(array, window_size)
windows = []
start_of_window = 0
end_of_window = start_of_window + window_size
while end_of_window < array.size
end_of_window = start_of_window + window_size
windows << array[start_of_window...end_of_window]
start_of_window += 1
end
max_range = 0
windows.e... | true |
8daa38e9ffa023401acc66b22671db2f04115637 | Ruby | SNLSF/all-the-movies | /app/models/movie.rb | UTF-8 | 456 | 2.78125 | 3 | [
"MIT"
] | permissive | class Movie < ActiveRecord::Base
validates :title, :score, :genre, :thumbnail, :url, :release_date, presence: true
validates :url, uniqueness: true
end
# Psuedocode for movie trailer api call
# get movie title and substitute the spaces for hyphens
# Ex. "Inside Out"
# Movie.find(1).title.gsub(" ", "-")
# => "Insid... | true |
abd77c3505ca25a47b0cf485c22752e5d257f735 | Ruby | bakhsi22/Ruby_Learning_The_Hard_Way | /ex11.rb | UTF-8 | 272 | 3.828125 | 4 | [] | no_license | puts "what is your name ? "
name = gets.chomp()
# taj=king input from the user uisng gets.chomp()
print 'what\'s your age ? '
age = gets.chomp ()
end1 = "so your name is #{name} and age is #{age}. \n"
print end1
puts "so your name is #{name} and #{age} years old ." | true |
4aecf34c6523dc9330280981e2d48ad213147d2d | Ruby | pavanprakash21/turbo-adventure | /pkg/transactor-0.0.1/lib/commands/compute.rb | UTF-8 | 788 | 3 | 3 | [] | no_license | module Commands
# Compute class
class Compute
def self.calculate_interest(args)
return empty_args if args.empty?
require 'utils/compute.rb'
account = args[0].upcase
statement = 'account_number IS :val OR username IS :val'
user = Models::User.find_by(statement, val: account)
r... | true |
edf53d2aff8227023b939b53777264861d5c306d | Ruby | duett/community-detection | /Network.rb | UTF-8 | 990 | 3 | 3 | [] | no_license | class Node
attr_accessor :id, :spin
def initialize(id,spin)
@id = id
@spin = spin
end
end
class Link
attr_accessor :node1, :node2
def initialize(node1,node2)
@node1 = node1
@node2 = node2
end
end
class Network
attr_accessor :nodes, :edges, :neighbors, :groups, :q, :adjacency
def initialize(file_nam... | true |
46368ee945cb97bd6ab38c76f9f3c801e2e7f9b1 | Ruby | byellindc/anagram-detector-dc-web-career-010719 | /lib/anagram.rb | UTF-8 | 215 | 3.53125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Anagram
attr_accessor :text
def initialize(text)
self.text = text
@chars = text.split('').sort
end
def match(words)
words.select do |w|
w.split('').sort == @chars
end
end
end | true |
9a2e32c3d6737f219c4593705371263441d57c5f | Ruby | MarcelSF/batch-358 | /lectures/food-delivery-day-one/team.rb | UTF-8 | 368 | 2.78125 | 3 | [] | no_license | class Team
attr_reader :name, :location
attr_accessor :id, :ranking
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@location = attributes[:location]
@ranking = attributes[:ranking] || 20
@players = attributes[:players] || []
end
def hire(player)
@play... | true |
ea17a6735b03233c5912a4880aece955b72a1ae1 | Ruby | Arcovion/opal-jquery | /spec/element/after_spec.rb | UTF-8 | 734 | 2.578125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe "Element#after" do
html <<-HTML
<div id="some-header" class="kapow"></div>
<div id="foo" class="after-spec-first"></div>
<div id="bar" class="after-spec-first"></div>
<div id="baz"></div>
HTML
it "should insert the given html string after each element" do
el = ... | true |
8ad65b725de591aa7f2daf4323d7e2a378252420 | Ruby | jkvyff/OO-FlatironMifflin-seattle-web-career-042219 | /lib/Manager.rb | UTF-8 | 625 | 3.65625 | 4 | [] | no_license | class Manager
attr_accessor :name, :department, :age
@@all = []
def initialize(name, department, age)
@name = name
@department = department
@age = age
@@all << self
end
def employees
Employee.all.select do |employee|
employee.manager_name == self.name
end
end
def hire_employee(name, salary)
... | true |
34c163eec4e8c4abc29e5ea6b6f681f34445469a | Ruby | elisabjorg/Week_2_weekend_hw_Karaokee_bar | /specs/guests_spec.rb | UTF-8 | 454 | 2.921875 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../guests.rb")
class GuestsTest < MiniTest::Test
def setup
@guest_1 = Guests.new("Ruth", 5)
@guest_2 = Guests.new("Anna", 6)
@guest_3 = Guests.new("Hekla", 1)
guests = [@guest_1, @guest_2, @guest_3]
end
def test_guest_name
... | true |
ae046032b286bbed1902bf9ed96ee58cd7e0d9b3 | Ruby | jedipunkz/awscale | /lib/ssh.rb | UTF-8 | 1,831 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'fog'
require 'net/ssh'
require 'yaml'
module AWSCompute
def self.connect()
config = YAML.load_file("/Users/thirai/aws/awscale.yaml")
conn = Fog::Compute.new({
:provider => 'AWS',
:aws_access_key_id => config['aws_access_key_id'],
:aws_secret_access_key => confi... | true |
281d5ad5c72d304e7e5e414b6e5f5c8dca0eb81d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/crypto-square/5c17ea200fc644b5ae472dc41828a3ee.rb | UTF-8 | 803 | 3.4375 | 3 | [] | no_license | class Crypto
attr_reader :text
private :text
def initialize(text)
@text = text
end
def normalize_plaintext
text.downcase.scan(/\w/).join
end
def size
Math.sqrt(normalize_plaintext.size).ceil
end
def plaintext_segments
split_segments.map { |subletters| subletters.join }
end
... | true |
804fa401ce8af9360f808a1f3e98bc151b8f128b | Ruby | SeaRbSg/rosalind | /thagomizer/problems/bins.rb | UTF-8 | 1,064 | 3.609375 | 4 | [
"MIT"
] | permissive | # Problem
# The problem is to find a given set of keys in a given array.
# Given: Two positive integers n <= 10^5 and m <= 10^5, a sorted array
# A[1..n] of integers from -10^5 to 10^5 and a list of m integers
# -10^5 <= k1,k2,...,km <= 10^5.
# Return: For each ki, output an index 1<=j<=n s.t. A[j]=ki or "-1" if
# t... | true |
f42ebe37045d2de8ff7d1c9c1f562c79104458a1 | Ruby | parkeristyping/HotSpot | /lib/google_places.rb | UTF-8 | 1,225 | 2.9375 | 3 | [] | no_license | require_relative '../config/environment'
class GooglePlacesAPI
attr_reader :api_key
include ::HTTParty
NEARBY_URL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?"
DETAILS_URL = "https://maps.googleapis.com/maps/api/place/details/json?"
ENCODER = HTMLEntities.new
def initialize
@api_k... | true |
f4d8bdc96cae2dc3ba0bf6f9df4269af145426b4 | Ruby | ismasan/parametric | /lib/parametric/default_types.rb | UTF-8 | 1,526 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "date"
module Parametric
# type coercions
Parametric.policy :integer do
coerce do |v, k, c|
v.to_i
end
meta_data do
{type: :integer}
end
end
Parametric.policy :number do
coerce do |v, k, c|
v.to_f
end
meta_data do
{ty... | true |
f5c49710daa3569c34e0c4ef21fd8f797e6b1d92 | Ruby | nitingupta81/rubycode | /dice.rb | UTF-8 | 224 | 3.390625 | 3 | [] | no_license | def roll(dice)
result=[]
rolled_dice=dice.shuffle
result=rolled_dice.first(1)
end
dice = [1,2,3,4,5,6]
integer1=roll(dice)
integer2=roll(dice)
puts "your result is " + integer1.inspect + ", and " + integer2.inspect
| true |
bdf47688a5fc7a18782af93507cdc60c92206b71 | Ruby | Primix/Primix | /lib/primix/transformer.rb | UTF-8 | 2,746 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | module Primix
class Transformer
attr_reader :data
attr_accessor :all_swift_strings
class << self
def transform!(data)
Transformer.new(data).transform!
end
end
def initialize(data)
@data = data
end
SWIFT_STRING_REGEX = /("([^"\\]|\\.)*")/
PLACEHOLDER_STRING ... | true |
c28923be71dc25f606cd72e1ba8b8493dbb0efcb | Ruby | rshiva/MyDocuments | /01-notes-programming /04-ruby+rails/ruby1.9/samples/slgenerator_3.rb | UTF-8 | 502 | 2.9375 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
b1ca5285bc1e9d52d2ef9c3b5f8990c62854ef64 | Ruby | penkar/hellishrebuke | /spec/race_spec.rb | UTF-8 | 5,016 | 2.90625 | 3 | [
"MIT"
] | permissive | require_relative '../spec_helper.rb'
describe Dragonborn do
it 'It Should be able to create a Dragonborn of various colors.' do
a = Dragonborn.new('black')
expect(a.strength).to eq(2)
expect(a.charisma).to eq(1)
expect(a.movement).to eq(30)
expect(a.damage).to eq('acid')
end
it 'It Should be able to cr... | true |
be7f6589df60ad9dc5dae9aefd4dab203c52a90e | Ruby | matt31415/rook_v_bishop | /lib/chess_board.rb | UTF-8 | 814 | 3.9375 | 4 | [] | no_license | class ChessBoard
BOARD_WIDTH = 8
EMPTY_CELL = ' '.freeze
def initialize(*pieces)
@board = {}
%w[a b c d e f g h].each do |col|
(1..8).each do |row|
@board["#{col}#{row}"] = nil
end
end
pieces.each { |p| place_piece(p) }
end
def to_s
board_str = horizontal_edge + "\n"
... | true |
d7b42f1eb317a5ffa72625f95606b3516e26c3e9 | Ruby | jenbeckham/employee_review | /employee.rb | UTF-8 | 287 | 2.5625 | 3 | [] | no_license | require './setup.rb'
class Employee < ActiveRecord::Base
belongs_to :departments
def give_raise(dollar_amount)
self.salary += dollar_amount
end
def work_performance(review)
if review == true
"Satisfactorily"
else
"Unsatisfactorily"
end
end
end
| true |
4da1d0b3c5e15bd38662727b7d11787244d14ac0 | Ruby | rockdragon/rubyOnGuys | /statistics/libs/research/confidence_interval.rb | UTF-8 | 1,103 | 2.84375 | 3 | [] | no_license | module StatLib
require_relative '../exts/lib'
# 置信区间
class ConfidenceInterval
def self.level_to_c(level)
case level
when 0.9 then 1.64
when 0.95 then 1.96
when 0.99 then 2.58
else 1.96
end
end
# 正态(非正态)的置信区间
# n 非正态需 > 30
# o 也可表示样本方差s (Za/2)
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.