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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
04bd2b3977a5705c82fc7da774b3dbf75f7ed024 | Ruby | ramteen85/sei35-homework | /ramteen-taheri/week5/sequences/sequences.rb | UTF-8 | 609 | 3.859375 | 4 | [] | no_license | class SimpleSums
def initialize number
@number = number
end
def number
@number
end
def s1
@number % 2
end
def s2
sum_s2 = (@number * (@number + 1)) / 2
sum_s2
end
end
sum = SimpleSums.new(4)
p sum.number
p sum.s1
p sum.s2
# def sequence_one... | true |
394e23689e730d32e5b41248c028c70c43f1fcf8 | Ruby | osak/Contest | /Codeforces/108/C.rb | UTF-8 | 280 | 3.171875 | 3 | [] | no_license | #!/usr/bin/env ruby
MOD = 1000000007
n, m = gets.split.map(&:to_i)
transpose = Array.new(m) { {} }
n.times do
gets.chomp.each_char.to_a.each_with_index do |ch, idx|
transpose[idx][ch] = 1
end
end
cnt = 1
transpose.each do |set|
cnt *= set.size
cnt %= MOD
end
p cnt
| true |
dc03afff7d9b7acc2295b47dea4312250e4581f2 | Ruby | Juan1808/EjerciciosRails | /CursoRuby/src/_04_3_ordenador/Modelo_persona/Contacto.rb | UTF-8 | 767 | 2.796875 | 3 | [] | no_license | module ModuloAgenda
class Contacto
def initialize (dni, nombre, telefono, mail, direccion)
@dni = dni
@nombre = nombre
@telefono = telefono
@mail = mail
#quiero guardar un objeto (dirección) de la clase Dirección
@direccion = direccion
end
def setDir... | true |
9d83ba1c9b9c7e872cf2b0b885340d50dc976ddc | Ruby | tiy-austin-ror-may2015/notes | /week3/day3/irb-history.rb | UTF-8 | 855 | 3.359375 | 3 | [] | no_license | load 'modules_part_deux.rb'
my_ride = Helicopter.new
puts my_ride.refuel
my_heli = HeliCarrier.new
puts my_heli.refuel
puts "look at the ancestors of the HeliCarrier"
puts HeliCarrier.ancestors.inspect
puts "They contain both modules that were mixed in"
puts TonkaTruck.ancestors
class User
def unlock_doors
if... | true |
4f126b2682a09c1cecb02f0bf4723745fe339938 | Ruby | nembrotorg/nembrot | /app/models/diffed_note_version.rb | UTF-8 | 1,449 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
class DiffedNoteVersion
attr_accessor :sequence, :title, :body, :tag_list, :previous_body, :previous_title, :previous_tag_list,
:is_embeddable_source_url, :external_updated_at
def initialize(note, sequence)
versions = note.versions
if sequence == 1
version = versio... | true |
94f0a5cf32c8caa769a22e773df73bb1d0f70d75 | Ruby | wikiscript/wikiscript | /wikitree/test/test_nodes.rb | UTF-8 | 349 | 2.625 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | ###
# to run use
# ruby -I ./lib -I ./test test/test_nodes.rb
require 'helper'
class TestNodes < MiniTest::Test
def test_page
page = Wikitree::Page.new( 'La Florida, Chile', 'La Florida' )
assert_equal ' La Florida ', page.to_text
assert_equal '[[La Florida, Chile|La Florida]]', page.to_wiki
... | true |
c196889b19a333cabde466e09d2e97ba2612cdc4 | Ruby | AlphaHydroxy/Hogwarts_students_houses | /db/console.rb | UTF-8 | 868 | 2.90625 | 3 | [] | no_license | require_relative '../models/student'
require_relative '../models/house'
require 'pry-byebug'
# student1 = Student.new({
# 'first_name' => 'Harry',
# 'second_name' => 'Potter',
# 'house' => 'Gryffindor',
# 'age' => 12
# })
# student1.save()
# student2 = Student.new({
# 'first_name' => 'Jia',
# ... | true |
f4dc34d086cc89fd75c4281bb8f036b5931a756f | Ruby | viktorija8902/scheduling-app | /app/models/selected_babysitting_time.rb | UTF-8 | 1,543 | 2.609375 | 3 | [] | no_license | class SelectedBabysittingTime < ApplicationRecord
belongs_to :babysitter
belongs_to :babysitting_day
belongs_to :babysitting_time
def self.update_available_times(params, babysitter_id)
babysitting_day = params.dig('babysitting_day')
babysitting_times = params.dig('babysitting_time') || []
delete_previ... | true |
e5e996d948ca319fbfefbfb84240345ad1e7ece6 | Ruby | audefaucheux/ruby-enumerables-cartoon-collections-lab-london-web-080519 | /cartoon_collections.rb | UTF-8 | 891 | 3.640625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarf_name)# code an argument here
# Your code here
dwarf_name.each_with_index { |name, index| puts "#{index + 1}. #{name}"}
end
def summon_captain_planet(planeteer_calls)# code an argument here
# Your code here
new_array = []
planeteer_calls.map { |call| new_array.push("#{call.capitali... | true |
1d45ac33263905a26540491653fe09c2b9493a7e | Ruby | dwhenry/trader | /app/jobs/import_price_data.rb | UTF-8 | 1,140 | 2.703125 | 3 | [] | no_license | class ImportPriceData < ApplicationJob
def perform(ticker, period: 'yesterday')
price_data = YahooSearch.prices(
ticker,
from: from(period),
to: to(period),
)
price_data.each do |price_record|
find_and_update(ticker, price_record)
end
end
def find_and_update(ticker, price... | true |
1baada13a03b3342d165f25349b34731319aac1e | Ruby | brettsanders/grocery_list | /yaml/grocery_list_with_yaml_persistence.rb | UTF-8 | 2,310 | 4.03125 | 4 | [] | no_license | require 'yaml'
class Grocery_list
attr_accessor :username
def initialize
@list = {}
@bought = {}
end
def add(item)
if @list.has_key?(item)
@list[item] += 1
else
@list[item] = 1
end
@list.inspect
end
def buy(item)
if @list.has_key?(item) && @list[item] > 1
... | true |
8d185fac6aa1341145212b463957c3f57499e815 | Ruby | NullTerminator/Colony | /lib/system/animation.rb | UTF-8 | 635 | 3.25 | 3 | [] | no_license | module System
class Animation
attr_accessor :frame, :time
attr_reader :frames, :frame_length
def initialize(frames, frame_length)
@frames = frames
@frame_length = frame_length
@frame = 0
@time = 0.0
end
def update(delta)
self.time += delta
if time >= frame_len... | true |
19cdb8a5edd24e632231330d9d874effec49b068 | Ruby | rozannadickson1988/srename | /srename.rb | UTF-8 | 2,519 | 2.90625 | 3 | [] | no_license | #!/usr/bin/ruby
# srename.rb - Quickly rename tv series
#
# Copyright 2008 Sunny Ripert <sunny@sunfox.org>
# Original python version by Antoine 'NaPs' Millet <antoine@inaps.org>
# This is just a ripoff of that good idea of his.
#
# This program is free software; you can redistribute it and/or modify
# it under the te... | true |
ea8fd3634b4df8cd4076bbd5b6691a7e6df3cd4a | Ruby | holmesm8/ruby-exercises | /objects-and-methods/exercise-2/lib/bag.rb | UTF-8 | 353 | 3.5625 | 4 | [] | no_license | class Bag
attr_reader :candies
def initialize
@candies = []
end
def empty?
true if @candies.count == 0
end
def count
@candies.count
end
def <<(candy)
@candies << candy
end
def contains?(type)
@candies.any? {|candy| candy.type == type}
end
def grab(type)
Candy.new(ty... | true |
ce6e6da88961d1ffe5643815a81276e63004d255 | Ruby | spaghetticode/whowonit | /lib/presenter.rb | UTF-8 | 531 | 2.8125 | 3 | [] | no_license | class Presenter
def self.inherited(klass)
attribute = klass.name.chomp('Presenter').downcase
klass.instance_eval do
define_method attribute do
@object
end
define_method "#{attribute}=" do |object|
@object = object
end
end
end
def initialize(object, template)
... | true |
bb818dd1455e9c0b8d953c3725b3e38c0281904f | Ruby | mrphishxxx/growler_alerts_starter | /spec/clapton_craft_spec.rb | UTF-8 | 1,303 | 2.515625 | 3 | [] | no_license | require "./spec/spec_helper"
require "./lib/clapton_craft"
describe ClaptonCraft do
it "can be initialized with a uri" do
clapton_craft = ClaptonCraft.new("http://google.com")
clapton_craft.must_be_instance_of ClaptonCraft
end
it "can be initialized with a filepath" do
clapton_craft = ClaptonCraft.n... | true |
07806f7edd498371e8e49c646d1adac584cb258a | Ruby | eabousaif/collections_practice_vol_2-pca-000 | /collections_practice.rb | UTF-8 | 1,620 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
def begins_with_r(array)
array.all? {|word| word.start_with?("r")}
end
def contain_a(array)
array.select {|word| word.include?("a")}
end
def first_wa(array)
array.find do |key, value|
if key.to_s.start_with?('wa')
return key
elsif value.to_s.start_with?('wa')
return val... | true |
e7a144b1ddd80a9a57f93245ed9442531d54265d | Ruby | moinstla/cd-organizer | /lib/artist.rb | UTF-8 | 395 | 2.59375 | 3 | [] | no_license | class Artist
@@artists = []
define_method(:initialize) do |name|
@name = name
@album_list = []
end
define_method(:name) do
@name
end
define_singleton_method(:list_all) do
@@artists
end
define_method(:save) do
@@artists.push(self)
end
define_singleton_method(:clear) do
@@... | true |
471b27dcf3ce815c78f05ee96958f2473af7ff0f | Ruby | Arvinje/tipsy | /lib/tipsy/text_analyzer.rb | UTF-8 | 1,130 | 2.9375 | 3 | [
"MIT"
] | permissive | module Tipsy
class TextAnalyzer
attr_reader :text_ngrams, :polarity
STOPWORDS = File.readlines("mysql_stopwords.txt").map(&:chomp)
def initialize(text)
@text = text
@pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma)
@text_ngrams = []
end
def run
prepr... | true |
d786b4f8a66a0d79d71d937202da87d5e9c1b520 | Ruby | haifeng/freemium | /lib/freemium/duration_string.rb | UTF-8 | 2,112 | 3.078125 | 3 | [
"MIT"
] | permissive | module Freemium
module DurationString
DURATION_VALUES=[['5 Days','5D'], ['1 Week','1W'], ['1 Month','1M'],['3 Months', '3M'],['6 Months','6M'],['9 Months','9M'],['1 Year','1Y']]
# DURATION_TEXT=DURATION_VALUES.inject({}) { |a,v| a[v[1]]=v[0]; a}
YEARLY='1Y'
MONTHLY='1M'
DURATION_CONSTANTS={'D' => ... | true |
daea804411f97dd4e06790135108d80957a45e42 | Ruby | Brinews/jacky | /C/C-SYNC/cs3357a-src1/support/crc32.rb | UTF-8 | 317 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
# 6 lines of code to validate command line arguments, open and read a file,
# compute its CRC-32 checksum, and print it out.
#
# Not really fair, is it? ;)
require 'zlib'
if ARGV.size != 1 || ! File.file?(ARGV[0])
puts "USAGE: #{$0} FILE"
exit -1
end
puts Zlib::crc32(File.read(ARGV[0]))
| true |
de76e1584edf339ad6fdc9c2ab15849a565960ad | Ruby | Hinnds/TheHackingProject | /exo_13.rb | UTF-8 | 194 | 3.28125 | 3 | [] | no_license | puts "Quelle est ton année de naissance?"
print ">"
user_year = gets.chomp.to_i
i = 0
loop do
puts "#{user_year}"
user_year +=1
if user_year == 2020
puts "#{user_year}"
break
end
end
| true |
186dfee594bf653dcfea7fe098c3c4a6759ab299 | Ruby | Kole565/RubyRush | /lesson_json/seasons/seasonChoice.rb | UTF-8 | 655 | 3.5625 | 4 | [] | no_license | require "json"
require "date"
require_relative "../../utils/methods.rb"
data = File.read("data/seasons.json", encoding:"utf-8")
json_data = JSON.parse(data)
puts "What's your birthday?"
date_inp = get_console_inp()
birth_date = Date.parse(date_inp + ".2000")
user_season = nil
user_season_weather = nil
json_data.e... | true |
0040ff6f41c39a90fa974d1d8d1cbfdde9c9fd58 | Ruby | jonatack/bitcoin-stuff | /scripts/parse-debuglog.rb | UTF-8 | 2,341 | 3 | 3 | [
"MIT"
] | permissive | #!/bin/env ruby
require "date"
require "pp"
# Simple parser for bitcoind's debug.log file
#
# input looks like this:
# 2021-08-19T07:32:11Z UpdateTip: new best=0000000000000000000a3f7a1c99d3acedd84658886782c04750f59bac9e60b0 height=632169 version=0x27ffe000 log2_work=91.986597 tx=534065287 date='2020-05-29T10:50:23Z' ... | true |
26e0c77182205f0a337b92997c665e906763a89a | Ruby | vanny96/sinatra_projects | /web_platform.rb | UTF-8 | 1,216 | 2.53125 | 3 | [] | no_license | #ruby web_platform.rb
require "sinatra"
require "sinatra/reloader" if development?
require_relative "apps/caesar-cipher/caesar-cipher"
require_relative "apps/hangman/hangman"
get "/" do
erb :index
end
get "/caesar" do
unless params["line"].nil?
new_line = caesar_cipher params["line"], params["number"].to_i
... | true |
99e92fc2af2addb3d522a7758f3225b21d7426e7 | Ruby | coffeemancy/fortitudo | /lib/fortitudo/programs/gzcl_regular.rb | UTF-8 | 5,247 | 2.578125 | 3 | [
"Unlicense"
] | permissive | # encoding: utf-8
require_relative '../programs.rb'
module Fortitudo
module Programs
module GZCLRegular
include GZCLIntroPlus
module_function
def intensity(pr, exrx, nearest_val = 5)
srladder = [[[1, 1, 1, 2], 3], [[2, 2, 2, 3], 2], [[3, 3, 3, 5], 1]]
inp = intensityproc(... | true |
0cdcad311e68eb5b97a37c4463381d85e4d545dc | Ruby | financeit/ach | /examples/ach/records/shared/batch_summaries.rb | UTF-8 | 1,559 | 2.515625 | 3 | [
"MIT"
] | permissive | # Include with:
#
# self.instance_eval(&shared_examples_for_batch_summaries)
module SharedExamples
def self.batch_summaries
Proc.new do
describe '#service_class_code' do
it 'should accept an Integer' do
@record.service_class_code = 200
@record.service_class_code.should == 20... | true |
379ad9a952e61eefcf8ae8c2a7b6f03b802bc993 | Ruby | MrMarvin/simpleblockingwebsocketclient | /samples/stdio_client.rb | UTF-8 | 385 | 3 | 3 | [
"BSD-3-Clause"
] | permissive |
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
require "ws"
if ARGV.size != 1
$stderr.puts("Usage: ruby samples/stdio_client.rb ws://HOST:PORT/")
exit(1)
end
client = Net::WS.new(ARGV[0]) { |data| puts data }
puts("Connected")
$stdin.each_line() do |line|
data = line.chomp()
client.send(data)
printf("Se... | true |
748859e27b9e0db7370be78026529dbf746b2236 | Ruby | jeremyevans/roda | /lib/roda/plugins/optimized_string_matchers.rb | UTF-8 | 1,577 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
#
class Roda
module RodaPlugins
# The optimized_string_matchers plugin adds two optimized matcher methods,
# +r.on_branch+ and +r.is_exactly+. +r.on_branch+ is an optimized version of
# +r.on+ that only accepts a single string, and +r.is_exactly+ is an
# optimized versi... | true |
bb96176abf755c104181df181c5c7b48007132fb | Ruby | Keilyn92/badges-and-schedules-online-web-ft-110419 | /conference_badges.rb | UTF-8 | 731 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
attendees.map { |attendee| "Hello, my name is #{attendee}."}
end
def assign_rooms(attendees)
# assign rooms in here
attendees.map.with_index { |attendee, index| "Hello, #{attendee}! You'll be assigned to r... | true |
108b65df8d1ac0f45e6cdfc2e731c339287c5c4e | Ruby | rokibulhassan/DecisionTreeLearning | /app/models/svm.rb | UTF-8 | 2,369 | 2.859375 | 3 | [] | no_license | class Svm
require 'libsvm'
# Attributes
# 1. pregnant -> Number of times pregnant
# 2. oral_glucose_tolerance -> Plasma glucose concentration a 2 hours in an oral glucose tolerance test
# 3. blood_pressure -> Diastolic blood pressure (mm Hg)
# 4. skin_fold_thickness -> Triceps skin fold thickness (mm)
# 5... | true |
f53b81543a44a176018119e7698817e8b968b223 | Ruby | prograsdk/dynaccount | /lib/dynaccount/query_builder.rb | UTF-8 | 1,246 | 3.0625 | 3 | [
"MIT"
] | permissive | module Dynaccount
class QueryBuilder
attr_accessor :klass, :selects, :wheres, :limits, :offsets, :orders
def initialize(klass)
self.klass = klass
end
def order(o)
if o.is_a?(Hash)
unless [:DESC, :ASC].include?(o[o.keys.first].to_sym)
raise ArgumentError.new("Wrong argum... | true |
02d6ae1ca01ab550a9dbfdb4478ddc3e0d162f58 | Ruby | EricSchwartz7/project-euler-multiples-3-5-web-1116 | /lib/oo_multiples.rb | UTF-8 | 448 | 3.5 | 4 | [] | no_license | class Multiples
attr_accessor :limit
def initialize(limit)
@limit = limit
end
def collect_multiples
num = 1
array = []
while num < @limit
if num % 3 == 0 || num % 5 == 0
array << num
end
num += 1
end
array
end
# def sum_multiples
# total = 0
# co... | true |
0a2889e282e59592d2bdf62ba6234e32886e511f | Ruby | mayokake/practice_ruby | /ruby_for_pro/test/bowling_test7.rb | UTF-8 | 2,487 | 3.578125 | 4 | [] | no_license | # frozen_string_literal: true
class Bowling
def initialize(score)
@score = score
end
def scores
debug_with_sleep('scores')
@scores = @score[0].split(',').flat_map { |s| s == 'X' ? [10, 0] : s.to_i}
end
def basic_score
debug_with_sleep('basic_score')
@basic_score = scores.each_slice(2).t... | true |
c4e349312d97f3fabad1eb18faf9860d36b3bad9 | Ruby | rodrigues/hari | /lib/hari/relation.rb | UTF-8 | 2,240 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'hari/relation/sorted_set'
module Hari
#
# Has a relation from one {Hari::Node} to another
#
class Relation < Entity
DIRECTIONS = %w(in out)
attr_accessor :label, :start_node_id, :end_node_id, :default_weight
validates :label, :start_node_id, :end_node_id, presence: true
# @return [... | true |
276ff19614e365fd7dea44f57c1d6c65bfd195ea | Ruby | MatthewSerre/cartoon-collections-v-000 | /cartoon_collections.rb | UTF-8 | 560 | 3.53125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)
array.each_with_index{|dwarf,index| puts "#{index + 1}. #{dwarf}"}
end
def summon_captain_planet(array)
array.collect { |call| call.capitalize + "!" }
end
def long_planeteer_calls(array)
array.any?{|call| call.length > 4}
end
def find_the_cheese(array)
# the array below is here t... | true |
b3e7777b0f83c5a3e1a08a915c8cd5f36dc22a79 | Ruby | dalewb/anagram-detector-nyc-web-040218 | /lib/anagram.rb | UTF-8 | 264 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(words_to_match)
words_to_match.select {|new_word| sort_word(new_word) == sort_word(word)}
end
def sort_word(word)
word.split('').sort.join('')
end
end
| true |
5fcb468bfcaefa52067f70778c8823b70c9e782f | Ruby | ELOHIMSUPREMES/octokit.rb | /lib/spike.rb | UTF-8 | 9,848 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'forwardable'
require 'json'
require 'pathname'
require 'active_support/inflector'
module Spike
class Resource
attr_reader :path, :segments
def initialize(path)
@path = path.to_s
@segments = @path.split("/").reject(&:empty?)
end
def name
s = objects.first
if subresour... | true |
7c9bb85bf57f11b831e87bb3bbb957712859afaf | Ruby | hubertlepicki/scrumastic | /vendor/plugins/amberbit-config/lib/amber_bit_app_config.rb | UTF-8 | 2,101 | 3.015625 | 3 | [
"MIT"
] | permissive | # Defines class used for storing application-wide setting values.
# == Usage:
#
# Say, config/applications/default.yml looks like this:
#
# default:
# my_app_name: Super App
#
# Then in your ruby code:
#
# AppConfig['my_app_name'] #=> "Super App"
#
# or
#
# AppConfig.my_app_name #=> "Super App"
#
module Amb... | true |
2df40c6a8251fbd5d6d38f30e8779caad45f87fa | Ruby | DouglasAllen/code-Metaprogramming_Ruby | /raw-code/Part_I_Metaprogramming_Ruby/ch01_Monday_The_Object_Model/the-ruby-object-model-and-metaprogramming/v-dtrubyom-v-07-code/included/append_features.rb | UTF-8 | 145 | 2.59375 | 3 | [] | no_license | class Object
def self.append_features(*args)
p args
super
end
end
class Dave
include Enumerable
end
d = Dave.new
d.sort | true |
552212bd140e92469c3b20e2701fa3a59d6c3853 | Ruby | znake/rubylearning.org-exercises | /week2/week2_exercise2.rb | UTF-8 | 561 | 4.09375 | 4 | [] | no_license | #Exercise2. Run the following two programs and try and understand the difference in the outputs of the two programs. The program:
#def mtdarry
#10.times do |num|
#puts num
#end
#end
#mtdarry
#and the program:
#def mtdarry
#10.times do |num|
#puts num
#end
#end
#puts mtdarry
def mtdarry
10.times do |num|
... | true |
583ce94b7e7a37a07adb7925d54595aab8ceb8a4 | Ruby | kissthink/CPME48 | /DASM48/lib/dasm48.rb | UTF-8 | 4,782 | 2.703125 | 3 | [] | no_license | module CPME48
INS = {
"NOP" => 0b00000, "JMP" => 0b00001, "CALL" => 0b11000, "RET" => 0b11111,
"JZ" => 0b00010, "JE" => 0b11010, "JNE" => 0b11100, "JFR" => 0b10110, "JBR" => 0b11101,
"SUB" => 0b00100, "ADD" => 0b00110, "MVI" => 0b01000, "MOV" => 0b01010,
"STA" => 0b01100, "LDA" => 0b01110,... | true |
34d5d40e3c7396629335464b92908541302acf36 | Ruby | beseeley/RubyLearning | /chapter1/reverse_o_matic.rb | UTF-8 | 81 | 3.0625 | 3 | [] | no_license | #!/bin/ruby
puts "Enter a word or phrase:"
input = gets.chomp.reverse
puts input
| true |
844a20fa4605cf59f0a5bcb4544c07d29b09c589 | Ruby | windix/goldread | /lib/freekindlecn/tweet.rb | UTF-8 | 1,928 | 2.578125 | 3 | [
"MIT"
] | permissive | require "open-uri"
require 'twitter'
require FreeKindleCN::CONFIG_PATH + '/twitter'
require 'weibo_2'
require FreeKindleCN::CONFIG_PATH + '/weibo'
require 'fb_graph'
require FreeKindleCN::CONFIG_PATH + '/facebook'
module FreeKindleCN
class Tweet
def initialize(text, tag=nil, image_url=nil, asin=nil)
@te... | true |
7b66b1fb464394edae94d425378d0273d25802bd | Ruby | jessenovotny/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 78 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
string.split.map {|e| e.reverse}.join(" ")
end | true |
2c7120e9bcf53e5f1f67319c0275339b804ea66e | Ruby | eilw/mars_tech_test | /spec/unit/grid_spec.rb | UTF-8 | 384 | 2.65625 | 3 | [] | no_license | require 'grid'
describe Grid do
subject(:grid){described_class.new()}
describe '#has_scent?' do
it 'does not have a scent initially' do
expect(grid.has_scent?('N')).to be false
end
end
describe '#leave_scent' do
it 'matches the scent with the direction given' do
grid.leave_scent('N')
... | true |
beb0dbce57c99fa09cbdc5535a89c88256cdd18a | Ruby | wonda-tea-coffee/atcoder | /abc/045/a.rb | UTF-8 | 62 | 2.75 | 3 | [] | no_license | a = gets.to_i
b = gets.to_i
h = gets.to_i
puts h * (a + b) / 2 | true |
79d8af25011b24980d5b5a652768bed870714e51 | Ruby | patriciaschulz/projects | /railsgirls/ruby-for-beginners/excercises/methods_2-2.rb | UTF-8 | 123 | 3.25 | 3 | [] | no_license | def add_one(number)
number + 1
end
result = add_one(5)
result = add_one(result)
result = add_one(result)
puts result
| true |
9e1053c4eff0d73a8757e0f051d458b0d4428c19 | Ruby | OsQu/couchdb-test | /tests/conflicts.rb | UTF-8 | 821 | 2.546875 | 3 | [] | no_license | require 'couchrest'
lab1 = CouchRest.database("http://lab1:5984/test")
lab2 = CouchRest.database("http://lab2:5984/test")
conflict_view = <<-VIEW
function(doc) {
if(doc._conflicts) {
emit(doc._conflicts, null);
}
}
VIEW
lab2.save_doc(
"_id" => "_design/conflict",
views: {
detect: {
map: conflic... | true |
c5b2521cbc2636f3060b14bc81cbc2ac7ad3c434 | Ruby | maca/scruby | /lib/scruby/server/nodes.rb | UTF-8 | 1,173 | 2.625 | 3 | [
"MIT",
"GPL-3.0-or-later"
] | permissive | module Scruby
class Server
class Nodes
include Enumerable
attr_reader :server, :semaphore, :graph
private :server, :semaphore
def initialize(server)
@graph = Graph.new([])
@server = server
@semaphore = Mutex.new
end
def decode_and_update(msg)
... | true |
fc56cbb6364f7bc0d85aa086c810d2df11c6dc78 | Ruby | tamu222i/ruby01 | /tech-book/7/m-20.rb | UTF-8 | 214 | 3.234375 | 3 | [] | no_license | # 以下の実行結果になるようにxに記述する適切なコード
def sum(x)
total = 0
a.each{|i|total += i}
return total
end
print sum(1,2,3,4,5)
# 実行結果
# 15
# 1. a
# 2.*a
# 3.a[]
# 4.&a
| true |
6ef49a6dda98604615b4a0ed1a58f88cc4cb084c | Ruby | makersacademy/sum_squares_kata | /spec/sum_squares_spec.rb | UTF-8 | 654 | 2.71875 | 3 | [] | no_license | require "sum_squares"
describe SumSquares do
subject(:sum_squares) { SumSquares.new }
context "initially" do
it "has a total of 0" do
skip "delete this line and complete the test"
end
end
context "when #addSquares is called with 1" do
before do
sum_squares.addSquare(1)
end
it... | true |
4f98d8c66add416687a08105969a2f2fa30cc52b | Ruby | Flippylolz/Lab3 | /pet.rb | UTF-8 | 3,569 | 3.953125 | 4 | [] | no_license | class Pet
attr_reader :health, :time, :hunger, :rest, :age, :happiness
attr_accessor :name
def initialize
@health = 10
@time = 10
@hunger = 10
@rest = 10
@age = 0
@happiness = 5
@volosatost = 3
end
def help
puts "Allowed commands:\nfeed, rest, play, stab, kill(?), walk, stat"... | true |
cdad395da0fab3959b395a1faab612ccb7cda831 | Ruby | firefield/ff-tbl-macros | /lib/macros/base.rb | UTF-8 | 1,202 | 3 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Macros
# Base class for all the Trbr step macros
class Base
include Uber::Callable
# @param args Any arguments that our macro operation supports
# @return Single step object that can be used in operation step
def initialize(*args)
self.args = args
end... | true |
32e9817e86ed7be48fce0e0e06b16f8f05473268 | Ruby | ranganathk/data_structures | /double_linked_list.rb/double_linked_list.rb | UTF-8 | 533 | 3.15625 | 3 | [] | no_license | require_relative '../linked_list'
class DoubleLinkedListNode < LinkedListNode
attr_accessor :previous
end
class DoubleLinkedList < LinkedList
def initialize
@sentinel = DoubleLinkedListNode.new(nil)
end
def tail
@sentinel.previous
end
def insert(val)
node = DoubleLinkedListNode.new(val)
... | true |
61b96c8399f576becac9a534ea21af02f9c73e0c | Ruby | SidharthNambiar/Launch-School | /course_101_programming_foundations/101-109_small_problems/easy_1_ex_5.rb | UTF-8 | 476 | 4.375 | 4 | [] | no_license | # Course 101 Programming Foundations
# 101-109 Small Problems
# Easy 1: Reverse It (Part 1)
# Write a method that takes one argument, a string,
# and returns the same string with the words in reverse order.
def reverse_sentence(str)
str.split.reverse.join(" ")
end
# Examples:
puts reverse_sentence('') == ''
puts ... | true |
27b9c8fa328fa9e918553d2241659ba2053dae47 | Ruby | ismasan/parametric | /spec/dsl_spec.rb | UTF-8 | 4,491 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require "parametric/dsl"
describe "classes including DSL module" do
class Parent
include Parametric::DSL
schema :extras, search_type: :string do |opts|
field(:search).policy(opts[:search_type])
end
schema(age_type: :integer) do |opts|
field(:title).policy(:string)
... | true |
451c931c2ece662dc4121b9152d105b05bf05ebd | Ruby | openstax/swagger-rails | /lib/tasks/generate_model_bindings.rake | UTF-8 | 2,743 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'open-uri'
require 'fileutils'
require_relative '../openstax/swagger/swagger_codegen'
namespace :openstax_swagger do
desc <<-DESC.strip_heredoc
Generate the Ruby API model bindings in the app/bindings directory. swagger-codegen
must be installed. Run like `rake openstax_swagger:generate_model_bindi... | true |
d124293becd829d1bb1d88b8d3d809072290c2e6 | Ruby | sbower/rbnd-udacitask-part1 | /udacitask.rb | UTF-8 | 1,673 | 3.421875 | 3 | [] | no_license | #!/usr/bun/env ruby
require './todolist.rb'
require 'json'
# Creates a new todo list
list = TodoList.new("Shawn's List")
# Add four new items
list.add_item("item1")
list.add_item("item2")
list.add_item("item3")
list.add_item("item4")
# Print the list
list.print_list
# Delete the first item
list.remove_item(1)
# P... | true |
cb301b9733b19b6956fc49f447513302b17ac353 | Ruby | stringham/contests | /2011-mebipenny/finals/server/spec/coordinate_spec.rb | UTF-8 | 1,005 | 2.984375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative '../hexagons/coordinate'
describe Hexagons::Coordinate do
context "creation" do
it "should set row and col" do
row = 2
col = 5
coord = Hexagons::Coordinate.new(row, col)
expect(coord.row).to eq(row)
expect(coord.col).to eq(col)
end
end
context "sorting" do
... | true |
c20f5fea89c3e0af19b609a341f632a918d76478 | Ruby | jaredfrankel10/regex-lab-v-000 | /lib/regex_lab.rb | UTF-8 | 1,045 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def starts_with_a_vowel?(word)
if word[0].match(/[aeiouAEIOU]/) then
return true
else
return false
end
end
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/(un+\S+ing)/).flatten
# values = text.split(" ")
# my_array=[]
# values.each do |value|
# if val... | true |
9a6f0b4f362fcb2312276cb6f4397353e3375917 | Ruby | ludovicdeluna/drivy | /backend/level6/drivy.rb | UTF-8 | 7,485 | 2.875 | 3 | [] | no_license | require "date"
require "set"
module Drivy
class PricingViewer
attr_reader :cars, :rentals, :pricing, :rental_changes
def initialize(data = {})
@cars = Car.load(data["cars"])
@rentals = Rental.load(data["rentals"], cars)
@rental_changes = RentalChange.load(data["rental_modifications"], rent... | true |
475f70bd025afebf54ce65edb5ecdf4f6bacb4e2 | Ruby | Juststeens/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 2,372 | 4.3125 | 4 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# Create method that turns string into hash
# key is item, value is quantity
full_list = nil
def hash_maker(items)
grocery_list = Hash.new(0)
items.split(' ').each { |item| grocery_list[... | true |
01033abb88b939b577ff1b5f6ee924835a68858d | Ruby | Ivb1990/ruby-retrospective-1 | /solutions/02.rb | UTF-8 | 1,224 | 3.34375 | 3 | [] | no_license | class Song
attr_reader :name, :artist, :genre, :subgenre, :tags
def initialize(name, artist, genre, subgenre, tags)
@name, @artist, @genre = name, artist, genre
@subgenre, @tags = subgenre, tags
end
def matches?(criteria)
criteria.all? do |type,value|
case type
when :name t... | true |
ac8b4566cd0f57a309f4c352d209eab189d9c17d | Ruby | semyonovsergey/int-brosayZavod | /lesson 2/app4.rb | UTF-8 | 164 | 3.3125 | 3 | [] | no_license | print "Enter X: "
x = gets.chomp
print "Enter Y: "
y = gets.chomp
print "Enter Z: "
z = gets.chomp
puts "x = " + x + "; y = " + y + "; z = " + z + ";"
| true |
c483a575f98bb374ed3770f366b0850462f83487 | Ruby | leon-joel/sample_app | /app/helpers/sessions_helper.rb | UTF-8 | 1,365 | 2.875 | 3 | [] | no_license | module SessionsHelper
def sign_in(user)
# 記憶トークン(暗号化していない生文字列)を新規作成
remember_token = User.new_remember_token
# 記憶トークン(生文字列)をクッキーに保存
cookies.permanent[:remember_token] = remember_token
# ※permanent は下の「20年後に期限切れになるクッキー」と同じ意味
# cookies[:remember_token] = { value: remember_token,
# expires... | true |
b6e64dee8c1bca7b01e2bbd79bd11f1a0968267b | Ruby | jjuarez/pgpool-pcpwrapper | /lib/pgpool/response.rb | UTF-8 | 1,810 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'pgpool/node_info'
module PGPool
#
# = class: Response
class Response
OK = 0
UNKNOWN = 1 # Unknown Error (should not occur)
EOF = 2 # EOF Error
NOMEM = 3 # Memory shortage
READ = 4 # Error while reading from the server
WRITE = 5 # Error while writing to the se... | true |
3761c06d390359859b1a9fcbf2605e6da8d1a336 | Ruby | benhutchinson/FAAST-Tube | /lib/passenger.rb | UTF-8 | 937 | 3.0625 | 3 | [] | no_license | class Passenger
MINIMUM_CREDIT_REQUIRED = 2
DEFAULT_CREDIT = MINIMUM_CREDIT_REQUIRED
attr_accessor :entered_station
def initialize(creditparam = {})
@credit = creditparam.fetch(:credit, DEFAULT_CREDIT)
@entered_station = false
end
def has_credit?
@credit >= MINIMUM_CREDIT_REQUIRED
end
d... | true |
2a3943993c5543b0dfab9fe51172c70f785646a3 | Ruby | riannacastro/joke_cli | /lib/cli.rb | UTF-8 | 1,966 | 3.5 | 4 | [
"MIT"
] | permissive | class CLI
def start
puts "Hello! We are the Jokesters! What is your name?"
API.get_data
input = user_input
greeting(input)
end
def user_input
gets.strip
end
def greeting(name)
puts "Nice to meet you, #{name}! Would you like to hear a joke? Enter \... | true |
ac4a554609f2ff3a18e97b5edd650c3f60c440a5 | Ruby | robertmtpaul/sei37-homework | /karthikeyan-sekar/week4/mon/classexe/conditionals-exercises/aircon.rb | UTF-8 | 1,299 | 4.125 | 4 | [] | no_license | ### 1. Drinking age?
# - Ask the user for their age.
# - Remember that anytime you get input, it is a string, so you will need to change the age input to a number.
# - If age is less than 18, print an appropriate message.
# - If the age is equal to or over 18, print a different message.
#
#
# ### 2. Air Conditi... | true |
5e9b16fa75274fa39ac278d19f62f0499f223093 | Ruby | joacoache/ruby-music-library-cli-cb-000 | /lib/music_importer.rb | UTF-8 | 427 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path, :files
def initialize(path)
@path = path
@files = []
end
# def files
# Dir.new(self.path).each {|f| @files << f.gsub("./spec/fixtures/mp3s")}
# end
def files
files = []
Dir.new(self.path).each do |file|
files << file if file.include?(".mp3")... | true |
5dd57c743c592ab7ede9cd2c9d7ece7357b5de32 | Ruby | nettan20/concurrent-ruby | /lib/concurrent/lazy_reference.rb | UTF-8 | 2,041 | 3.421875 | 3 | [
"MIT",
"Ruby"
] | permissive | module Concurrent
# Lazy evaluation of a block yielding an immutable result. Useful for
# expensive operations that may never be needed. `LazyReference` is a simpler,
# blocking version of `Delay` and has an API similar to `AtomicReference`.
# The first time `#value` is called the caller will block until the
... | true |
af31797803b2661345c7899d441613c51747bfbf | Ruby | angusjfw/learn_to_program | /ch10-nothing-new/shuffle.rb | UTF-8 | 301 | 3.25 | 3 | [] | no_license | def shuffle arr
rec_shuffle(arr, [])
end
def rec_shuffle(arr, shuffled)
unshuffled = []
selected = rand(arr.length)
(0...arr.length).each { |i|
i == selected ? (shuffled << arr[i]) : (unshuffled << arr[i])
}
return shuffled if unshuffled == []
rec_shuffle(unshuffled, shuffled)
end
| true |
7507422d6022f88af812ab6f3a0c22988e4f1230 | Ruby | EliseJane/algorithm-exercises | /algorithm_exercises/backtracking/palindrome_partition.rb | UTF-8 | 502 | 3.671875 | 4 | [] | no_license | def partition(s, set=[], solutions=[])
if s.length == 0
solutions << set.clone
else
(0...s.length).each do |i|
if is_palindrome(s[0..i])
set << s[0..i]
partition(s[i+1..-1], set, solutions)
set.pop
end
end
end
solutions
end
def is_palindrome... | true |
ca04d637d1ecc1c00060e3e9a7175e0fd7f485b5 | Ruby | jckylalaina/Ruby | /exo_16.rb | UTF-8 | 104 | 3.375 | 3 | [] | no_license | puts "votre age"
age=gets.chomp.to_i
n=1;
while n<age
puts "il y a #{n} ans tu avais #{age-n}"
n+=1
end | true |
93a21aeebde3c085a2836bbee15ecb36eb88953d | Ruby | willjshark/boris-bikes-3 | /lib/docking_station.rb | UTF-8 | 339 | 3.1875 | 3 | [] | no_license | # require './lib/bike'
class DockingStation
def initialize
@bikes = []
end
def release_bike
fail 'No bikes available' unless @bikes.length > 0
@bikes.pop
end
def dock_bike(bike)
fail 'The docking station can only hold 20 bikes' if @bikes.length == 20
@bikes.push(bike)
end
#def bike
... | true |
a2aceb81eec39f3f7820c8cf3bfeb9d87c3949b7 | Ruby | ALucking1/oyster_card | /lib/journey_log.rb | UTF-8 | 578 | 2.96875 | 3 | [] | no_license | require_relative 'journey'
class JourneyLog
attr_reader :journey_class, :journey_history
def initialize(journey_class = Journey.new)
@journey_class = journey_class
@journey_history = []
end
def start(station)
journey_class.journey[:entry_station] = station.name
journey_class.journey[:entry_zone] = station.... | true |
6255bd7c7536da1b4f8287371988cbd450f237cf | Ruby | frequalize/numerics-ruby | /examples/load_data | UTF-8 | 911 | 2.71875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'date'
require 'time'
require 'yaml'
require 'numerics'
local = {:access_key => "EDYUCFLJHGODCBRFBHHWAGES", :secret_key => "CUFMZISBIKKTAMQSWLSEBLJSDRPKQKLVBOWG",:host => "127.0.0.1", :port => 9000}
remote = { :access_key => 'AMJHUBGGINARXIZBHMXCTNEK', :secret_key => 'PTHMBFEJUGFKTGGGJHQX... | true |
117ebe4e9cfabe99727c0517ee96565e5d5b629a | Ruby | Deceptio-Solutions/tapir | /lib/tapir/tasks/pipl_search.rb | UTF-8 | 2,533 | 2.578125 | 3 | [
"BSD-2-Clause"
] | permissive | #module Task
#module PiplApi
def name
"pipl_search"
end
def pretty_name
"Search the Pipl database"
end
def authors
['jcran']
end
def description
"Uses the Pipl API to search for information"
end
def allowed_types
[ Entities::Account,
Entities::Username,
Entities::FacebookAccount,
Entities::... | true |
76e871f46cbb4247dbcad6845cf97ab19ecf19f7 | Ruby | marcolivier0930/ruby-enumerables-cartoon-collections-lab-online-web-prework | /cartoon_collections.rb | UTF-8 | 503 | 3.015625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves # code an argument here
# Your code here
dwarves = ["Doc", "Dopey", "Bashful", "Grumpy"]
dwarves.each_with_index{|value, index| do
puts "#{index} : #{value}"
end
end
def summon_captain_planet(planeteer_calls) # code an argument here
# Your code here
end
def long_planeteer_calls... | true |
9cdd2efa926de222236669e2858dd3cedc6ebe9a | Ruby | eyyelikealion/QuizLikeLion | /euler3.rb | UTF-8 | 209 | 3.078125 | 3 | [] | no_license | def primefact(num)
a=2
b=num
while a <= b do
if b%a==0
x=a
b/=a
else
a+=1
end
end
puts x
puts b
end
primefact(600851475143)
| true |
db8cd3ea0d9699933fc63138d5fb5507532308fd | Ruby | longmartin/ruby-exercise | /exception/test4.rb | UTF-8 | 131 | 2.59375 | 3 | [
"MIT"
] | permissive | begin
raise 'A test exception.'
rescue Exception => e
puts e.message
puts e.backtrace.inspect
ensure
puts "Ensuring execution"
end
| true |
5a97e34fdb2e035fee371c0414ffcecd2e083d85 | Ruby | Rubenfppinto/Capybara_BBC_Testing_lab | /spec/bbc_login_error_spec.rb | UTF-8 | 3,857 | 2.75 | 3 | [] | no_license | require 'spec_helper'
describe 'Incorrect user details produces valid error' do
context 'it should respond with the correct error when incorrect details are input' do
it 'should produce an error clicking sign-in with blank fields' do
@bbc_site = BbcSite.new
@bbc_site.bbc_homep... | true |
3d52e43e162c64e4d8af4cf42c3cdebc7d7eb006 | Ruby | icrossm/confess_it | /spec/models/user_spec.rb | UTF-8 | 4,243 | 2.75 | 3 | [] | no_license | require 'spec_helper'
describe User do
before(:each)do
@attr= {
:name =>"Example User",
:email =>"user@ecample .com",
:password =>"foobar",
:password_confirmation => "foobar"}
end
it "should create a new instance given a valid attribute" do
User.crete!(@attr)
end
it "should require a n... | true |
5625e7d7bf262eb0a5c76b456324c4ecab5ab256 | Ruby | Lean-GNU/EjerciciosRuby | /Metodos/ejercicio-metodos-retorno3.rb | UTF-8 | 385 | 4.28125 | 4 | [] | no_license | =begin
Confeccionar un método que le enviemos como parámetros dos enteros y nos retorne el mayor.
=end
def return_greater(v1, v2)
if v1 > v2
return v1
else
return v2
end
end
# bloque principal
print "Ingrese el primer valor: "
value1 = gets.to_i
print "Ingrese el segundo valor: "
value2 = ... | true |
eea8d3c4c7f680e88365a3b986bb9b5647d04f69 | Ruby | KPobeeNorris/battle | /spec/player_spec.rb | UTF-8 | 250 | 2.6875 | 3 | [] | no_license | describe Player do
subject(:player) { described_class.new("Bob") }
it "returns the player's name" do
expect(player.name).to eq "Bob"
end
it "has has hit-points associated with each player" do
expect(player.hp).to eq 100
end
end
| true |
f15f564fa8e499313e01f265c47c685dac88d7f3 | Ruby | piercus/tweetECP | /app/models/user.rb | UTF-8 | 11,809 | 2.578125 | 3 | [] | no_license | class User < ActiveRecord::Base
validates_uniqueness_of :screen_name
has_many :tweets
has_many :relations
has_many :friends_to, :foreign_key => "user_to_id", :class_name => "Friendship"
has_many :friends_from, :foreign_key => "user_from_id", :class_name => "Friendship"
require 'twitter'
# We import the modu... | true |
1d445950d0309a7205bc2cb0caa2f23170c24292 | Ruby | Justafigurehead/CodeClanWork | /week_1/day_3/hashes/avengers_ex.rb | UTF-8 | 484 | 3.078125 | 3 | [] | no_license | avengers = {
ironman: {
attack: [75, 80, 100],
intelligence: 100,
weapon: "the suit",
unique_skills: "intelligence and money"
},
captain_america: {
attack: "Brute force",
intelligence: "Alright",
weapon: "shield",
unique_skills: "leadership"
},
hulk: {
attac... | true |
279c7ea367b93772693452f2e61a7d4cbcd2e6ae | Ruby | potsbo/alfred-omnifocus-workflow | /spec/app/task_spec.rb | UTF-8 | 3,207 | 3.03125 | 3 | [
"MIT"
] | permissive | require "task"
RSpec.describe Task do
describe "#project" do
it "detects ::shop" do
task = Task.new("Get milk ::shop")
expect(task.project).to eq("shop")
end
it "detects :shop" do
task = Task.new("Get milk :shop")
expect(task.project).to eq("shop")
end
it "detects :sho... | true |
93b24e96ee539e42271d2b8ac5625ba1e66ecf78 | Ruby | paulozag/hired-challenges | /challenge_2/braces.rb | UTF-8 | 955 | 3.484375 | 3 | [] | no_license | require 'pry'
def braces expressions
expressions.each do |expression|
p is_valid_expression? expression
end
end
def is_valid_expression? string
expression_queue = string.split('')
built_expression = []
while !expression_queue.empty?
new_brace = expression_queue.shift
if opening_brace... | true |
bce238f0cb59f34f5d99d9e087a0299b6b718e97 | Ruby | michael-sd/Ruby_Programs | /cats.rb | UTF-8 | 261 | 3.765625 | 4 | [] | no_license | def like_cats(answer)
if answer == "yes"
return "Mike does too"
elsif answer == "no"
return "Dogs are ok"
else
return "Make a decision fool!"
end
end
puts "Do you like cats?"
answer = gets.chomp.downcase
puts like_cats(answer) | true |
03d44d057058d8ee1e0fab142952af1a63668024 | Ruby | fatum/replicator | /lib/replicator/events.rb | UTF-8 | 880 | 2.671875 | 3 | [
"MIT"
] | permissive | module Replicator
class Events
attr_reader :publisher
class_attribute :events
self.events ||= {}
def initialize(publisher)
@publisher = publisher
end
def self.subscribe(event, &block)
self.events[event] ||= []
self.events[event] << block
end
def run_callbacks(event... | true |
0033deca21256bed49195295f5318925873da218 | Ruby | viing937/codeforces | /src/544A.rb | UTF-8 | 245 | 3.0625 | 3 | [
"MIT"
] | permissive | k = gets.to_i
q = gets.chomp
if q.split("").uniq.size < k
puts "NO"
else
puts "YES"
tmp = q.split("").uniq[0, k]
(k-1).times do |i|
puts q[q.index(tmp[i])...q.index(tmp[i+1])]
end
puts q[q.index(tmp[-1])..-1]
end
| true |
94a035cb01f37b47b98d680bffc8b86224b06403 | Ruby | bukowskis/seek | /spec/lib/seek_spec.rb | UTF-8 | 3,247 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Seek do
let(:params) { { page: 4, per_page: 20, 'sort_by' => :first_name, sort_direction: 'DESC' } }
let(:options) { { 'max_per_page' => 30, valid_sort_bys: %w{ age first_name last_name } } }
let(:seek) { Seek.new params, options }
context 'pagination' do
describe 'pag... | true |
e1ab2fa2ef752fec14a90383e69c20b00c52e62d | Ruby | harveyjohal/ruby-course | /lesson_4/csv.rb | UTF-8 | 1,586 | 3.84375 | 4 | [] | no_license | # Read file name as the first arguement
filename = ARGV.first
def get_file_lines(file_name)
file = open(file_name)
text = file.read
lines = text.split("\n")
return lines
end
# Parse lines from file
# Input: Line of text from the file
# Output: Array of columns / fields from the lines
# Example: "Mircea, Cimpo... | true |
52b6e9c47fdc498c59dfccf52d75be65883f3444 | Ruby | yoshikot/cartoon-collections-v-000 | /bin/cartoon_collections.rb | UTF-8 | 606 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../cartoon_collections.rb"
dwarves = ["Doc", "Dopey", "Bashful", "Grumpy"]
roll_call_dwarves(dwarves)
planeteer_calls = ["earth", "wind", "fire", "water", "heart"]
puts summon_captain_planet(planeteer_calls)
short_words = ["puff", "go", "two"]
puts long_planeteer_calls(short_words)
#=> false
assor... | true |
8860c596ab5a68029e8b456829ff66ca58fdcc8e | Ruby | gcongreve/BusLab__multiple_classes | /bus_stop.rb | UTF-8 | 275 | 3.28125 | 3 | [] | no_license | class BusStop
attr_reader :stop_name, :queue
def initialize(stop_name)
@stop_name = stop_name
@queue = []
end
def add_person(person)
@queue << person
end
def add_people(people)
for person in people
@queue << person
end
end
end
| true |
db7b0fb2dfc9f6e1d32867500700ee396ff9a60d | Ruby | guilleam/mystuff | /tweets.rb | UTF-8 | 302 | 3.34375 | 3 | [] | no_license | all_tweets = ["My first tweet", "My second tweet", "My third tweet", "I have the world’s most boring tweets"]
total_number_of_tweets = all_tweets.size
tweets_display = 0
while (tweets_display < total_number_of_tweets)
puts all_tweets[tweets_display]
tweets_display += 1
puts tweets_display
end | true |
4ae8f3c794408141762d99cdf4293f044081b7f1 | Ruby | ptshih/friendmashserver | /lib/mongo_functions.rb | UTF-8 | 1,065 | 2.765625 | 3 | [] | no_license | require 'mongo'
# only populating first degree
def populatemongonetwork
db = Mongo::Connection.new("localhost", 27017).db("networks")
#coll = db.collection("masterNetwork")
Network.where("degree=1").find_each(:batch_size => 5000) do |network|
coll = db.collection(network['facebook_id'])
#doc =... | true |
dbbb0c83417dccf5e063d67eb209d11eaf33a32c | Ruby | mtortonesi/sisfc | /lib/sisfc/statistics.rb | UTF-8 | 1,607 | 3 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative './request'
module SISFC
class Statistics
attr_reader :mean, :n, :received, :longer_than
alias_method :closed, :n
# see http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
# and https://www.johndcook.com/blog/standard_dev... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.