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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e4c3914641754d4defc5d30199d639027fdd50d1 | Ruby | azhi/BSUIR_labs | /7sem/SAMM/lab3/task_source.rb | UTF-8 | 294 | 3.109375 | 3 | [] | no_license | class TaskSource
attr_reader :tasks_count, :time_to_task
def initialize(time_to_task = 2)
@time_to_task = time_to_task
@tasks_count = 0
end
def step
@time_to_task -= 1
if @time_to_task.zero?
@time_to_task = 2
@tasks_count += 1
true
end
end
end
| true |
7ab973156382d19a47d780f89beb7bba5acbcb37 | Ruby | endeepak/neo4j | /lib/neo4j/rels/traverser.rb | UTF-8 | 2,292 | 2.9375 | 3 | [
"MIT"
] | permissive | # external neo4j dependencies
require 'neo4j/to_java'
module Neo4j
module Rels
# Traverse relationships of depth one from one node.
# This object is returned when using the Neo4j::Rels which is included in the Neo4j::Node class.
#
class Traverser
include Enumerable
include ToJava
... | true |
eebfea02745689f49848540ebeaac65a0426041d | Ruby | kenkeiter/SMPTE360 | /smpte360.rb | UTF-8 | 692 | 2.578125 | 3 | [] | no_license | require 'packets'
require 'stringio'
require 'pp'
module SMPTE360
class Stream
attr_accessor :packets
def initialize(path)
@fp_path = path
@fp = File.open(path, 'r')
@packets = []
map_stream!
end
def map_stream!
while @fp.pos != File.size(@fp_path)
... | true |
b5990197d762fe2be61560eb5103d55e128b9a96 | Ruby | neddy/Introduction-To-Programing | /7. Hashes/5_ex.rb | UTF-8 | 112 | 3.15625 | 3 | [] | no_license | # 5_ex.rb
opposites = {positive: "negative", up: "down", right: "left"}
puts opposites.has_value?("negative")
| true |
b1c159746407cdbeb50eee9ef46646dd7f30551f | Ruby | kkchu791/CodingProblems | /pramp/pancake_sort.rb | UTF-8 | 390 | 3.421875 | 3 | [] | no_license | def pancake_sort(arr)
(arr.length).downto(1).each do |i|
maxIndex = find_max_index(arr, i) + 1
flip(arr, maxIndex)
flip(arr, i)
end
arr
end
def flip(arr, k)
i = 0
j = k - 1
while i < j
arr[i], arr[j] = arr[j], arr[i]
i += 1
j -= 1
end
arr
end
def find_max_index(arr, i)
ma... | true |
f93b2cdce4be52c383b85b9439e90a2e2022214c | Ruby | tk0358/design_patterns_in_ruby | /chapter14_builder/computer.rb | UTF-8 | 954 | 3.171875 | 3 | [] | no_license | class Computer
attr_accessor :display
attr_accessor :motherboard
attr_reader :drives
def initialize(display=:crt, motherboard=Motherboard.new, drives=[])
@display = display
@motherboard = motherboard
@drives = drives
end
end
class CPU
# CPU共通のコード...
end
class BasicCPU < CPU
... | true |
7bd3f0eb6530420e3497d14a28ff9b0999dd135c | Ruby | gabriel-dehan/doggui | /lib/parser.rb | UTF-8 | 528 | 3.015625 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
require 'byebug'
class Parser
def initialize
@url = 'https://www.chiens-de-france.com/etalons/'
end
def save_dogs
html_file = open(@url).read
html_doc = Nokogiri::HTML(html_file)
index = html_doc.search("form .acc-1 .acc-select option").map { |n| n.text }.i... | true |
2c82eefdbb69fa0aee5156a51695f11e9ca80736 | Ruby | kevintom/rspec_primer | /interest_calculator.rb | UTF-8 | 416 | 3.1875 | 3 | [] | no_license | require 'date'
class InterestCalculator
def initialize(term:, principal:, rate:)
@term = term
@principal = principal
@rate = rate
end
def num_days
today = Date.today
return 0 if today.day == 1
next_month = Date.new(today.next_month.year, today.next_month.month, 1)
(next_month - to... | true |
19d35eb5c08580b19001efeb083f2f3d23bfe72e | Ruby | benchristel/waterslide | /test.rb | UTF-8 | 3,276 | 3.140625 | 3 | [
"MIT"
] | permissive | gem 'minitest'
require 'minitest/autorun'
require_relative 'lib/waterslide'
include Waterslide
class AddOne
include Filter
def pipe_one(thing)
yield thing + 1
end
end
class Add
include Filter
def initialize(n)
@increment = n
end
def pipe_one(thing)
yield thing + @increment
end
end
def... | true |
40ad6fec2706bd4d0437443329db9765bbd7040f | Ruby | jerorhn/dataStructures | /01-data-structures/05-hashes-part-2/separate_chaining/separate_chaining.rb | UTF-8 | 1,521 | 3.484375 | 3 | [] | no_license | require_relative 'linked_list'
require 'prime'
class SeparateChaining
attr_reader :max_load_factor
def initialize(size)
@items = Array.new(size)
@size = size
@max_load_factor = 0.7
end
def []=(key, value)
idx = index(key, @size)
if @items[idx].nil?
@items[idx] = LinkedList.new
... | true |
c44db8c89815c9c10328dce793dd63d699425e26 | Ruby | ehefferon/courseproject | /fullname.rb | UTF-8 | 196 | 3.046875 | 3 | [] | no_license | fname = "Ed"
lname = "Hefferon"
puts fname + " " + lname
puts "#{fname} #{lname}"
puts 4936 / 1000
puts 4936 % 1000
puts 4936 % 1000 / 100
puts 4936 % 1000 % 100 /10
puts 4936 % 1000 % 100 % 10 | true |
154dd65cf8dbca29de7fcdbe6c31ad99977700ad | Ruby | Virksaabnavjot/HealthCare-Heroku-CloudApplication | /lib/tran_decorator.rb | UTF-8 | 1,851 | 3.8125 | 4 | [] | no_license | # the concrete component we would like to decorate, a car in our example
class BasicTran
def initialize(c, m, age)
@cost = c
@firm = m
@age = age
@description = "basic transfer"
end
# getter method
def cost
return @cost
end
# a method which retu... | true |
36b9f5725ec6ed1fe693964b11c9c8b1967fc5dd | Ruby | moriie/OO-FlatironMifflin-dumbo-web-career-031119 | /run.rb | UTF-8 | 430 | 2.78125 | 3 | [] | no_license | require_relative "lib/Manager"
require_relative "lib/Employee"
require 'pry'
Art_Vandalay = Manager.new("Art", "Sales", 38)
Blake = Employee.new("Blake", 32000, "Art")
Anders = Employee.new("Anders", 33000, "Art")
Art_Vandalay.hire_employee("Adam", 31000)
Rilakkuma = Manager.new("Kuma", "Food", 7)
Korilakkuma = Empl... | true |
ba07f34df21dba4cb49816137b5421bdc5c5f136 | Ruby | famished-tiger/SRL-Ruby | /lib/regex/char_class.rb | UTF-8 | 1,155 | 3.15625 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
# File: char_class.rb
require_relative 'polyadic_expression' # Access the superclass
module Regex # This module is used as a namespace
# Abstract class. A n-ary matching operator.
# It succeeds when one child expression succeeds to match the subject text.
class CharClass < Polyadi... | true |
6fd005bb350039aa3b5145c89a94147aba5e9085 | Ruby | guacamobley/data-structures-and-algorithms | /binary-search-tree.rb | UTF-8 | 6,105 | 3.296875 | 3 | [] | no_license |
class Node
include Comparable
attr_accessor :data, :left, :right
def initialize data=nil, left=nil, right=nil
@data = data
@left = left
@right = right
end
def <=> other
return self.data <=> other.data
end
def to_s
"data: #{data}"
end
def left?
left.nil? ? false : true
... | true |
49a0a09f8607bab1624d000080477fae04c09432 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/leap/949957731d164b39a8c9a5a42ccd9727.rb | UTF-8 | 507 | 3.5 | 4 | [] | no_license | # year.rb
# jennyb exercism.io github.com/jbasalone
class Year
def self.leap?(year)
@theyear = year
divbyfour? && !acentury? || bcentury?
end
def self.theyear
@theyear
end
#private
def self.acentury?
theyear.modulo(100).zero?
end
def self.divbyfour?
... | true |
33a0874724237debf18171d8d91195b34f4de67f | Ruby | tpickett66/Project-Euler-Solutions | /bin/151-200/p185 | UTF-8 | 1,593 | 3.421875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: UTF-8
$:.unshift(File.dirname(__FILE__) + '/../../lib') unless $:.include?(File.dirname(__FILE__) + '/../../lib')
# The game Number Mind is a variant of the well known game Master Mind.
# Instead of coloured pegs, you have to guess a secret sequence of digits. After each guess you're o... | true |
3f99d19f2bbbd5a73a002031cf8c2f8c1c8c8186 | Ruby | fadiTill/ruby-objects-has-many-through-lab-onl01-seng-pt-012120 | /lib/artist.rb | UTF-8 | 326 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name
@@all =[]
def initialize (name)
@name = name
@@all << self
end
def self.all
@@all
end
def songs
Song.all.select {|song| song.artist == self}
end
def new_song(song_name, genre)
Song.new(song_name, self, genre)
end
def genres
self.songs.map{ |song| song.genre }
en... | true |
46f0aa6f707f36736bfb239a4bf159f473f4474e | Ruby | nateleroux/princessfrenzy | /websocketserver/server.rb | UTF-8 | 12,015 | 3.15625 | 3 | [] | no_license | require 'eventmachine'
require 'em-websocket'
require_relative 'game.rb'
require_relative 'arrow.rb'
require_relative 'user.rb'
require_relative 'helpers.rb'
def send_move_message(game,ws,user)
message = Game::MOVE + Game::DELIMITER + user.id + Game::DELIMITER + user.dir.to_s + Game::DELIMITER + user.x.to_s ... | true |
bac9a3b30bf5571c75dd73634ce8999541059a6d | Ruby | Cynth42/weather-app | /todays_weather.rb | UTF-8 | 418 | 3.671875 | 4 | [] | no_license | require 'yahoo_weatherman'
def todays_weather(location)
client = Weatherman::Client.new
weather = client.lookup_by_location(location)
city = weather.location['city']
region = weather.location['region']
condition = weather.condition['text']
puts "Today's weather in #{city}, #{region} is #{condi... | true |
85b7ca70df554c4653058dfd647ea8aa0965d0cf | Ruby | fredemmott/rxhp | /spec/element_spec.rb | UTF-8 | 3,367 | 2.59375 | 3 | [
"ISC"
] | permissive | require 'spec_helper'
describe Rxhp::Element do
describe '#initialize' do
it 'should default to having no children' do
e = Rxhp::Element.new
e.children.should be_empty
e.children?.should be_false
end
it 'should default to having no attributes' do
e = Rxhp::Element.new
e.att... | true |
efb67ac38ad5e78872486f24e7e1e7d3439a8b18 | Ruby | h4hany/leetcode | /solutions/39_combination_sum.rb | UTF-8 | 1,367 | 3.734375 | 4 | [] | no_license | # Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidateswhere the candidate numbers sums to target.
# The same repeated number may be chosen from candidates unlimited number of times.
# Note:
# All numbers (including target) will be ... | true |
728a505c284ec7bab1a765199da19f36d00651cf | Ruby | kwx4github/facebook-hackercup-problem-sets | /2015/qualifying_round/1.Cooking_the_Books/solutions/sources/x.5471.Spencer | UTF-8 | 1,130 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env ruby
def improve_number!(num)
candidate = num
0.upto(num.length-2) do |start|
(start+1).upto(num.length-1) do |finish|
if yield(num, start, finish, candidate)
candidate = swap(num, start, finish)
end
end
return candidate if candidate != num
end
num
end
def sma... | true |
0ddfd84090a27db6212bdbc23bf84c0145aa61db | Ruby | isabella232/totango | /lib/totango/event.rb | UTF-8 | 1,376 | 2.6875 | 3 | [
"MIT"
] | permissive | module Totango
class Event
# http://help.totango.com/installing-totango/quick-start-http-api-server-side-integration/
#
# Sending an event to Totango
#
# The HTTP API can be used to track user-activity from anywhere in your web-app.
# Simply send the following parametrized HTTP request every... | true |
4ff0c0527c4b0720c3c3535aed1487aad6ca67ac | Ruby | iZsh/ragweed | /lib/ragweed/utils.rb | UTF-8 | 2,276 | 3.046875 | 3 | [] | no_license | # These should probably be extensions to Module since that's the location of instance_eval and friends.
class Object
module ObjectExtensions
# Every object has a "singleton" class, which you can think
# of as the class (ie, 1.metaclass =~ Fixnum) --- but that you
# can modify and extend without fu... | true |
3d68a85a6d679934a47776c3cddea1b39b4e3d24 | Ruby | QWYNG/Review_Gacha | /gacha_bot.rb | UTF-8 | 1,775 | 2.515625 | 3 | [] | no_license | require 'sinatra'
require 'json'
require './reviewer'
require 'dotenv/load'
require './array_extension.rb'
using SlackFormat
reviewer_box = ReviewerBox.new(essential_reviewers: [], other_reviewrs: [])
post '/' do
check_token!
user_id = request['user_id']
essntial_reviewer = reviewer_box.essential_reviewers.sam... | true |
dc11d95b0f045966e59d6413298778458c78d534 | Ruby | kjnsn/mug_credit_server | /helpers.rb | UTF-8 | 575 | 2.828125 | 3 | [] | no_license | require 'json'
require 'digest'
def to_json(hash)
JSON.generate(hash)
end
def json_error(msg)
halt [500, to_json({error: msg})]
end
class String
def numeric?
return true if self =~ /^\d+$/
true if Float(self) rescue false
end
end
class TransactionKlass
def initialize(amount, username, time = Tim... | true |
1b40a1ac8664c84749970094063742407ca05113 | Ruby | cbh808/RB130 | /rb130_exercises/easy1/10_count_items_further.rb | UTF-8 | 521 | 3.96875 | 4 | [] | no_license | =begin
Further Exploration
Write a version of the count method that meets the conditions
of this exercise, but also does not use each, loop, while, or until.
=end
def count(array)
array.select { |n| yield(n) }.length
end
p count([1,2,3,4,5]) { |value| value.odd? } == 3
p count([1,2,3,4,5]) { |value| value % 3 == 1... | true |
075b7905283ad101b8b72d44d7a7339ed0bbd72c | Ruby | ryanwaudby/project-euler-in-ruby | /problem_019.rb | UTF-8 | 636 | 3.671875 | 4 | [] | no_license | #You are given the following information, but you may prefer to do some research for yourself.
#1 Jan 1900 was a Monday.
#Thirty days has September,
#April, June and November.
#All the rest have thirty-one,
#Saving February alone,
#Which has twenty-eight, rain or shine.
#And on leap years, twenty-nine.
#A leap year occ... | true |
6590349da0945d0ed97a1a5d0453c92cb255e877 | Ruby | kimpossible1/grocery-store | /lib/order.rb | UTF-8 | 1,429 | 3.265625 | 3 | [] | no_license |
require 'csv'
require 'pry'
module Grocery
class Order
attr_reader :id
attr_accessor :products
def initialize(id, products = 0)
@id = id
@products = products
end
def add_product(product_name, product_price)
if @products.include?(product_name)
return false
else... | true |
7ed367ae1c62b514e16c0bc7e901154367c00461 | Ruby | mmagn/motion-demos | /app/models/go/game.rb | UTF-8 | 2,909 | 3.140625 | 3 | [] | no_license | # frozen_string_literal: true
module Go
# this class represents everything needed to build a square Go board,
# track the state of the game, and possibly produce a game record based
# on the stones placed on the board.
class Game
# TODO: replace with DB storage of games
@active_games = {}
def self... | true |
fcb817324dd40bf2045c36e3f5a77cbc843f2a17 | Ruby | pragdave/dion | /bo/RoleHelper.rb | UTF-8 | 3,453 | 2.828125 | 3 | [] | no_license | # ----
# Copyright (c) 2003, 2003 David Thomas (dba Thomas Consulting)
# All Rights Reserved.
# The right to use this software is granted by separate license
# between Destination Imagination, Inc and David Thomas.
#
# No part of this program may be reproduced, stored in a retrieval
# system, or transmitted, in any for... | true |
b1fe68fc7645fb473a1f18dd33495a6cfd574e2e | Ruby | PetarSimonovic/battle_monsters | /spec/player_spec.rb | UTF-8 | 431 | 2.859375 | 3 | [] | no_license | require 'player.rb'
describe "Player" do
subject(:claude) { Player.new('Claude') }
subject(:pete) { Player.new('Pete') }
it "stores the player name" do
expect(claude.name).to eq("Claude")
end
it "has hit points" do
expect(claude.hit_points).to eq(Player::HIT_POINTS_START)
end
it "receives da... | true |
a7eea304ef518d4efbf2c74b8fe7cb7b7b1b2833 | Ruby | SaimonL/CyberPowerAVR | /lib/CyberPowerAVR.rb | UTF-8 | 842 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'CyberPowerAVR/version'
module CyberPowerAVR
class << self
def to_hash
output = Hash.new
data = system_call.strip
data.each_line do |line|
if line[0...2] == "\t\t"
hash = line_to_hash(line)
output[hash[:key]] = hash[:value]
end
end
output
... | true |
471640eae242bd6bf23fe8be570557272def5554 | Ruby | mattmeng/jadis | /lib/jadis/config.rb | UTF-8 | 846 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'jadis/exceptions'
module Jadis
class Config
attr_accessor :base_dir
BaseDirNotValid = Class.new( Exceptions::JadisArgumentError )
# Loads the settings from `.jadis` and creates a new configuration object.
# Will yield to a given block to modify settings further, which will o... | true |
c05598e8f45bec5f1acaa8da19f7eaf1ad60bde5 | Ruby | theKeithD/lightrail-dash | /app/models/jira_countdown.rb | UTF-8 | 1,002 | 2.765625 | 3 | [] | no_license | # Model for tracking the number of days left until the release of the next JIRA project version.
#
# Based on Extensions::WidgetBase, which gives it a +name+ property, as well as the +html_id+ and +html_class+ virtual properties. This is a kind of Widget.
# Based on Extensions::JiraBase, which gives it the +jira_server... | true |
0a134dfbe8d7ff86eccba5f1fc73b2edc36348aa | Ruby | Zarecki/wk03_day3_music_collection_lab | /models/artists.rb | UTF-8 | 851 | 3.015625 | 3 | [] | no_license | require ('pry')
require_relative('./albums.rb')
require_relative('../db/sqlrunner.rb')
class Artist
attr_reader :id
attr_accessor :name
def initialize(options)
@name = options['name']
@id = options['id'].to_i if options['id']
end
def save
sql = "INSERT INTO artists (name) VALUES ($1) RETURNING id... | true |
1a8b59997a818d22210ca0e1b79ad950b10ebdae | Ruby | sim-mokomo/Youtube | /src/video.rb | UTF-8 | 587 | 2.890625 | 3 | [] | no_license | require './src/youtube_service'
class Video
attr_reader :video_id, :title
def initialize(video_id, title)
@video_id = video_id
@title = title
@youtube_service = YoutubeService.new
end
def url
"https://www.youtube.com/watch?v=#{@video_id}"
end
# @param [Array<String>]
def contain_langua... | true |
b6a71048ee2ef8b64c22529f4a5ae018e4eb3a07 | Ruby | orhanna14/task-it-to-me | /spec/task_printer_spec.rb | UTF-8 | 2,895 | 2.859375 | 3 | [] | no_license | require "spec_helper"
require "task_printer"
RSpec.describe TaskPrinter do
it "#finished prints out that a specific task is finished" do
stdout = StringIO.new("")
task_name = "First task"
task_printer = TaskPrinter.new(stdout)
task_printer.finished(task_name)
expect(normalized_output(stdout)).t... | true |
280dfe284ff11fafa6ecca61fe6cc77e0b569ffe | Ruby | tadasmajeris/GAME | /spec/lib/action_spec.rb | UTF-8 | 1,066 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
require_relative '../../lib/action'
class TestAction < Action
def action_attributes
@attribute = :strength
@difficulty = :toughness
end
end
describe Action do
let(:hero) { double("hero", strength: 3, gain_exp: nil, gain_gold: nil, damage: nil) }
let(:monster) { double("monster", ... | true |
bfc90346dc1765cbfab8aadf2739ebc921586bc4 | Ruby | paosch/bookmark_manager | /lib/database_connection.rb | UTF-8 | 957 | 3.046875 | 3 | [] | no_license | require 'pg'
# extracting the database connection logic to a class called class DatabaseConnection
# the class sets up a persistent connection to the correct database with the method setup
class DatabaseConnection # a wrapper for PG
def self.setup(dbname) # there's a test for this method in the spec file
@connec... | true |
2bb84341cb197b2ccb50531cd248c68040754745 | Ruby | ldonnet/atlas | /lib/atlas/location_index.rb | UTF-8 | 1,407 | 2.609375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
module Atlas
class LocationIndex
attr_reader :exact_index, :phonetic_index
def initialize
@exact_index = WordIndex.new
@phonetic_index = WordIndex.new
end
def push(location, attributes = {})
location = Location.from(location, attributes)
@exact_index... | true |
9fc94af8eafef8600c4adb0380ebad751b229972 | Ruby | dpaola2/mail_hatch | /lib/mail_hatch.rb | UTF-8 | 1,990 | 2.53125 | 3 | [] | no_license | class MailHatch
attr_reader :api_key,
:brand_color,
:debug,
:dry_run,
:sendgrid_api_key,
:title,
:address,
:ios_store_url,
:google_play_store_url
def initialize(api_key:,brand_color:,debug: false, dry_run: false, sendgrid_api_key:, title:, address:, ios_store_url:, google_play_sto... | true |
878b57861902410f2094985da86e1af51a07e069 | Ruby | Laurane01/tests-ruby | /lib/01_temperature.rb | UTF-8 | 143 | 3.265625 | 3 | [] | no_license | def ftoc(temp)
result = (temp - 32)/1.8
return result.round(1)
end
def ctof(temp)
result = temp * 1.8 + 32
return result.round(1)
end
| true |
10c66df336bcbe210a8e639d541ad91705a2b5e3 | Ruby | thatRailsGuy/euler | /Problems 041-050/euler44.rb | UTF-8 | 604 | 3.625 | 4 | [] | no_license | def pent(x)
x*(x*3-1)/2
end
def isPent?(x)
if x <= 0
return false
end
temp = x * 24 + 1
sqrt = Math.sqrt(temp).floor
return sqrt**2 == temp && sqrt % 6 == 5
end
def prob44
minD = -1
i = 1
j = i
bool = false
until bool
i += 1
j = i-1
until (pent(i) - pent(j) > minD && minD != - ... | true |
48c9ea170bcb999d7e4ccd3541b0f964dddf64af | Ruby | bosh/Heuristics | /Ambulance/Person.rb | UTF-8 | 1,424 | 3.1875 | 3 | [] | no_license | class Person
attr_accessor :number, :x, :y, :death, :in_ambulance, :saved
def initialize(str)
data = str.split ","
coords = (@x,@y = data[0].to_i, data[1].to_i)
@death = data[2].to_i
$bounds[:x][:min] = @x if @x < $bounds[:x][:min]
$bounds[:x][:max] = @x if @x > $bounds[:x][:max]
$bounds[:y][:min] = @x i... | true |
b9c79bc147cef0ca450674b7faed97c137041321 | Ruby | caike/dojorio | /20090701/jogador.rb | UTF-8 | 882 | 3.078125 | 3 | [] | no_license | class JogadorExpulsoException < StandardError; end
class Jogador
attr_accessor :cartoes
def initialize
@cartoes = Array.new
end
def cometer_falta(jogador, options = { :tipo => :leve })
raise JogadorExpulsoException if expulso?
cartao = cartao_cor(options[:tipo])
@cartoes.concat(car... | true |
4f8461a1a7df16112f0a1fd726d0beb02d00d3c1 | Ruby | dscataglini/paypal-ipn-forwarder | /spec/server_spec.rb | UTF-8 | 2,285 | 2.515625 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../lib/server'
require_relative '../lib/sandbox'
require_relative '../lib/cms'
require_relative '../lib/computer'
describe Server do
it 'forwards an ipn from a paypal sandbox to its corresponding computer' do
sb = Sandbox.new
ipn = sb.send
server = Serve... | true |
a70319c82cd46d80423bbf9555d77fe0a2fbe57e | Ruby | rubyunworks/baker | /work/old/baker-2004.09/lib/baker/download.rb | UTF-8 | 5,304 | 2.53125 | 3 | [] | no_license | # Baker - The Delicious Program Maker
# (c)2003 PsiT Corporation, LGPL
# LICENSE HERE
# external libs
require 'digest/md5'
require 'open-uri'
require 'progressbar/progressbar' # this is not part of standard ruby install (see raa)
# actually I made a small modifcation to it so i
... | true |
86e60198df0f41233777be10e272b630e6252172 | Ruby | fatnic/dotfiles | /.scripts/movies | UTF-8 | 1,706 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
# Requires sshpass to be installed
require 'rainbow'
require 'launchy'
require_relative 'kickparse'
REMOTE_USERNAME = "mediabox"
REMOTE_HOST = "192.168.0.44"
REMOTE_PASSWORD = 'tobie2003'
REMOTE_FILEPATH = "/home/mediabox/kickapoo/magnets.txt"
PROMPT = "d/l/v/h/q >> "
movies = kickparse()
put... | true |
a4948badbdb34d97910bfbec5a71c5785dc1488d | Ruby | jason0415/ctci | /sorting_searching/test/group_anagram_test.rb | UTF-8 | 146 | 2.59375 | 3 | [] | no_license | require '../group_anagram'
array = ['interview', 'hello', 'abb', 'ordlw', 'cba', 'lloeh', 'world', 'abc']
puts GroupAnagram.group!(array).inspect | true |
03e467f7ae49b3dbb78b036356dadab5cfbd226f | Ruby | SoumyadipC/ShopKart | /app/models/checkout.rb | UTF-8 | 943 | 2.875 | 3 | [] | no_license | class Checkout < ApplicationRecord
belongs_to :basket
def total
price_arr = cart_items.pluck(:product_total)
return price_arr.sum
end
def total_discounts
discount_per_product = []
cart_items.each do |item|
case item.product.name
when 'Product A'
flag = item.count/3
... | true |
25d53f942417118d2655f1c5cc4296db0fd4a354 | Ruby | takatoshiH/AtCoder | /ABC/ABC201A.rb | UTF-8 | 83 | 3.28125 | 3 | [] | no_license | a,b,c = gets.chomp.split(" ").map(&:to_i).sort
puts b - a === c - b ? 'Yes': 'No'
| true |
4270e8a24d865b8a3377d405bc6d535d0a6e9d83 | Ruby | hanqingchen15/Algorithms | /Misc/intersectionOf2Arrays.rb | UTF-8 | 259 | 3.578125 | 4 | [] | no_license | def intersection(nums1, nums2)
hash = Hash.new()
res = []
nums1.each do |num|
hash[num] = true
end
nums2.each do |num|
if hash[num]
res << num
hash[num] = false
end
end
return res
end | true |
1e0cc33575afc6b158682c3f65b086a8d99e57b1 | Ruby | krlsdu/rosalinda_challenges | /count_dna_nucleotides/lib/dna.rb | UTF-8 | 173 | 3.375 | 3 | [
"MIT"
] | permissive | module DNA
SYMBOLS = %w('A', 'C', 'G', 'T')
def self.count_nucleotides(dataset)
sum = []
SYMBOLS.each { |x| sum.push(dataset.count(x)) }
sum * ' '
end
end | true |
d7bb0a47ff8d24aaceebf2da8ac5e41b70b52653 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/sum-of-multiples/a0171110cd0e42949f861b40a6cc854f.rb | UTF-8 | 559 | 3.734375 | 4 | [] | no_license | class SumOfMultiples
class Summatory
def initialize(*selectors)
@selectors = *selectors
end
def to(limit)
(1...limit).to_a.select { |n| selected?(n) }.reduce(:+) || 0
end
private
def selected?(num)
@selectors.inject(false) do |selected, selector|
selected || (num.modulo(selector) == 0)
... | true |
52fc52a3ad685693cfb26e7cef705a677dfa5418 | Ruby | DahliaBloomstone/ruby-advanced-class-methods-lab-online-web-sp-000 | /lib/song.rb | UTF-8 | 2,378 | 4.1875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #Given:
class Song
attr_accessor :name, :artist_name #basic properties
@@all = [] #class variable to store all instances for Song created through the instance method Song#save
def self.all
@@all #build class methods that interact on the class data of @@all
end
def save
self.class.all << self
end
... | true |
d8b58bc404757ec75e2f9ed40acde1dcd3d7af50 | Ruby | KodaiISHIJIMA/assignment | /0032070-160511/sigmoid_inverse.rb | UTF-8 | 515 | 3.34375 | 3 | [] | no_license | # coding: utf-8
Epsilon = 0.0001
# シグモイド関数
# シグモイド関数は単調増加
def sigmoid(x)
return 1/(1 + Math.exp(-x))
end
# シグモイド関数の逆関数
def sigmoid_inverse(y,a,b)
m = (a+b)/2.0
# xがmのときのyの値が許容範囲であればmを返す
if (y - sigmoid(m)).abs < Epsilon
return m
# xがmより大きいとき
elsif y - sigmoid(m) > 0
return sigmoid_inverse(y,m,b)
... | true |
857ca6388928f27fdbdd7d7fa65667badeae8e7e | Ruby | janymai/ruby-utility | /basic/hash.rb | UTF-8 | 352 | 4.15625 | 4 | [] | no_license | # Write a program that uses a hash to store a list of movie titles with the year they came out
# Print the year
films = {xitrum: '1995', boyOverFlowers: '2012', love: '2014'}
puts films[:xitrum]
puts films[:boyOverFlowers]
puts films[:love]
years = []
years[0] = films[:xitrum]
years[1] = films[:boyOverFlowers]
yea... | true |
e512c6cf2ae29d9663edcf92234fa25bca499dcb | Ruby | lymanwong/Ruby-Stuff | /algorithms/my_parseInt/my_parseInt.rb | UTF-8 | 1,441 | 4.3125 | 4 | [
"MIT"
] | permissive | =begin
JavaScript provides a built-in parseInt method.
It can be used like this:
parseInt("10") returns 10
parseInt("10 apples") also returns 10
We would like it to return "NaN" (as a string) for the second case because the input string is not a valid number.
You are asked to write a myParseInt method with the follo... | true |
c71c828fae8689309c74cfadc9b415a3713b6089 | Ruby | sydra08/beer-me | /spec/features/add_beer_to_collection_spec.rb | UTF-8 | 2,289 | 2.515625 | 3 | [
"MIT"
] | permissive | describe "Feature Test: User's Beer Collection", :type => :feature do
describe "Adding Beer" do
context "beer already exists in database" do
# log in as user
# nav to new beer page
# fill_in("beer[name]", :with => "Fat Tire")
# fill_in("beer[abv]", :with => "5.20%")
# fill_in("beer[d... | true |
a1a843f6fbf66f7815bdfcf3beef7bb5ccf424ae | Ruby | eliastre100/Advent-of-Code-2020 | /specs/day 14/day_14_spec.rb | UTF-8 | 3,183 | 3.3125 | 3 | [
"MIT"
] | permissive | require 'rspec'
require_relative '../../day 14/mask'
require_relative '../../day 14/address_mask'
require_relative '../../day 14/memory'
RSpec.describe Mask do
let(:subject) { described_class.new }
describe '#initialize' do
it 'has an all X mask' do
expect(subject.mask).to eql 'XXXXXXXXXXXXXXXXXXXXXXXXX... | true |
b2c2675a2557337ea7213e8abe7e51f861810d18 | Ruby | tokhi/log_fetcher | /log_fetcher_tool.rb | UTF-8 | 4,196 | 2.515625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'open-uri'
require 'yaml'
require 'net/http'
require 'uri'
require 'iconv'
require 'data_mapper'
CONFIG_FILE = "file.yml"
@config = YAML.load_file(CONFIG_FILE)
LOAD_AVG = 'loadavg'
DISC_SPACE = 'discspace'
RESPONSE_TIME = 'responsetime'
ADAPTER = @config.fetch('dbconnection')['adapter']
HOST... | true |
4c6a158a32a79bde3700c5cf6479f028501fbebd | Ruby | Drus566/Exercices | /Arrays/task2.rb | UTF-8 | 3,110 | 3.8125 | 4 | [] | no_license | # двумерные массивы
array = Array.new(4){ Array.new(rand(2..4)){rand(-6..6)}}
array_a = [
[1,3,2],
[4,1,2],
[12,20,1]
]
array_b = [
[12, 43, 75],
[10, 1, 68],
[65, 14, 74]
]
# Поменять первый и последний столбец массива мест... | true |
07b2e4388c170f00e8abdab93dbd07023ab0371b | Ruby | kyatul/ExercismRuby | /robot-name/robot_name.rb | UTF-8 | 210 | 3.03125 | 3 | [] | no_license | class Robot
def initialize
@name = "RX"+(100+rand(99)).to_s
end
def name
@name
end
def reset
temp = @name
while temp.eql? @name
@name = "RX"+(100+rand(99)).to_s
end
@name
end
end | true |
da071050aa5a0f56224bfdf4700b1f1ba54d6561 | Ruby | dongmy54/learn-note | /ruby/元编程/method_missing.rb | UTF-8 | 1,354 | 3.40625 | 3 | [] | no_license | # 来源: method_missing 是 BasicObject 私有实例方法
# 原理: 在找遍所有祖先链未果,会执行 method_missing
# 本质: method_missing 只是截获作用,方法仍不存在
# PS:
# 1、method_missing 明确 截获的方法类型(避免不必要的截获)
# 2、方法已存在,使用白板类(class A < BasicObject)
class A
def method_missing(name,*params)
case name.to_s
when /^cheng_du.*/ # 以cheng_du 开头的方法
puts '成... | true |
5c7ed759e301595262d441fb74d6e371ca219810 | Ruby | souri-nina/Letters | /Letters.rb | UTF-8 | 285 | 3.296875 | 3 | [] | no_license |
def menu
print `clear`
puts 'Letters Menu'
puts '---------------'
puts '1) Your Input'
puts '2) Exit Letters'
user_input = gets.strip
exit(2) if user_input == '2'
input
end
def input
puts 'What is your input?'
@letters = gets.strip
if @letters
end
menu | true |
a336659e83959bd5c75e6a895067322f754ac679 | Ruby | tohyongcheng/ga-examples | /day1/friends.rb | UTF-8 | 159 | 2.828125 | 3 | [] | no_license | friends = ["Chip Potts", "Cogsworth", "Lumière", "Mrs. Potts"]
# You can use anything here. lol
friends.each do |friend|
puts "Belle is friends with #{friend}"
end | true |
7063746414fb886bd7275028e885e0f0672e0a29 | Ruby | lfmars/uzduotys | /second.rb | UTF-8 | 391 | 3.734375 | 4 | [] | no_license | class Multimulti
attr_accessor :numbers_array
def initialize( numbers)
@numbers_array = numbers
end
def calculator
answer = 1
numbers_array.each do |x|
answer *= x
end
answer
end
end
#puts "kiek kartu dauginsim?"
#amount = gets.chomp.to_i
#array = []
#amount... | true |
a02a964602672efb4836bc30cd21f8bd637f4220 | Ruby | wilsonokibe/BasicRuby | /replace_regex/bin/main.rb | UTF-8 | 206 | 3.828125 | 4 | [] | no_license | require_relative '../lib/string.rb'
puts "Enter input. I will replace all vowels with '*': "
string = gets.chomp
new_string = string.replace_vowel
puts "I have changed '#{string}' to \n '#{new_string}'"
| true |
34eab05ac8b8d334c21983a8e680a1febdbb74db | Ruby | Saiyan/euler | /ruby/0005.rb | UTF-8 | 189 | 3.3125 | 3 | [] | no_license |
c=0
i=0
while c != 20 do
c=0
i+=20
if i % 1000000 == 0
puts i
end
for j in 1..20
if i % j == 0
c+=1
else
break
end
end
end
puts i | true |
a826153202a13f921ba6ba724b9aa50978da84c1 | Ruby | vmasko/algs4-pu | /Week 1: Analysis of Algorithms/three_sum.rb | UTF-8 | 322 | 3.796875 | 4 | [] | no_license | class ThreeSum
def count(a)
n = a.length
count = 0
i = 0
while i < n
j = i + 1
while j < n
k = j + 1
while k < n
count += 1 if a[i] + a[j] + a[k] == 0
k += 1
end
j += 1
end
i += 1
end
puts "Result: #{count}."
end
en... | true |
45a3405294020f4a22f1e4c43b77c5c87158d835 | Ruby | jakedjohnson/DBC-highlights | /week-1/binary_search/spec/binary_search_spec.rb | UTF-8 | 718 | 2.9375 | 3 | [
"MIT"
] | permissive | require_relative '../binary_search'
describe 'binary_search_include?' do
let (:symbols) { [:A, :B, :C, :D] }
let (:one) { ["butt"] }
let (:empty) { [] }
context 'searches an array' do
it 'finds the element in the array' do
expect(binary_search_include?(:B, symbols)).to eq true
end
it 'doesn\'t fi... | true |
d3714dbb6eb3a97c0fd083504dee40abba5c7716 | Ruby | orimolad/aa_classwork | /w4d4/poker/spec/poker_spec.rb | UTF-8 | 460 | 2.859375 | 3 | [] | no_license | require 'poker'
require 'rspec'
describe Card do
let(:card) { Card.new("spades", 3) }
describe "#initialize" do
it "initializes with a suit and a value" do
expect(card.suit).to eq("spades")
expect(card.value).to eq(3)
end
end
end
describe Deck do
let(:deck) {Dec... | true |
1594608085bb87546bfeca067e6a800ad81f3586 | Ruby | dsaenztagarro/interpreter | /lib/reader.rb | UTF-8 | 373 | 3.28125 | 3 | [] | no_license | ##
# This class translates a block message into a system "control information"
class Reader
class << self
def read(&message)
self.new.instance_eval(&message)
end
end
def initialize
@@sentence = Hash.new
end
def method_missing(method_id, *args, &block)
@@sentence[method_id] = args
... | true |
b7d31ca6ba0145f9a33963ebdf6f8383f87ee452 | Ruby | garethrees/feed-the-zettelkasten | /lib/feed_the_zettelkasten/notes.rb | UTF-8 | 324 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module FeedTheZettelkasten
class Notes
include Enumerable
def initialize(notes)
@notes = notes
end
def hit_target?(target)
to_a.size >= target
end
def each
notes.each { |note| yield note }
end
protected
attr_reader :notes
end
... | true |
4cb913badb8c1787e2bda0fb7b59fa86a157b1d2 | Ruby | Dahie/metro | /lib/metro/events/hit_list.rb | UTF-8 | 1,639 | 3.03125 | 3 | [
"MIT"
] | permissive | module Metro
#
# The HitList is an object that maintains when an object is touched/clicked
# and then moved and finally released. The object attempts to work through
# the process:
#
# hit_list.hit(first_event)
# hit_list.update(next_event)
# hit_list.update(next_event)
# hit_list.rel... | true |
af3ed3a60392efba428967908df17262b98df7b4 | Ruby | matteosister/twig | /spec/twig/commit_time_spec.rb | UTF-8 | 2,063 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Twig::CommitTime do
before :each do
@time = Time.utc(2000, 12, 1, 12, 00, 00)
end
describe '#initialize' do
it 'stores a Time object' do
commit_time = Twig::CommitTime.new(@time, '99 days ago')
expect(commit_time.instance_variable_get(:@time)).to eq(@time)
... | true |
fa12bbef11fd9283e2aff226e673bcce2bd5b555 | Ruby | greggroth/game_of_life | /gol_spec.rb | UTF-8 | 2,386 | 2.84375 | 3 | [] | no_license | require "gol"
describe 'Game of Life' do
let(:world) { World.new }
context "cell utility methods" do
subject { Cell.new(world) }
it "spawn relative to" do
cell = subject.spawn_at(3,5)
cell.is_a?(Cell).should be_true
cell.x.should == 3
cell.y.should == 5
cell.world.should ... | true |
db22f3706cfa58edf525171b53c84b5a8460fb25 | Ruby | romainbazeler/rails-yelp-mvp | /app/controllers/restaurants_controller.rb | UTF-8 | 944 | 2.546875 | 3 | [] | no_license | class RestaurantsController < ApplicationController
# GET /restaurants
def index
@restaurants = Restaurant.all
end
# GET /restaurants/1
def show
@restaurant = Restaurant.find(params[:id])
end
# GET /restaurants/new
def new
@restaurant = Restaurant.new
end
# POST /restaurants
... | true |
b40eaf32b2ce495210cf720d3de087bacc7d4141 | Ruby | jmeirow/grpbldr | /app/models/member_history.rb | UTF-8 | 1,195 | 2.796875 | 3 | [] | no_license | class MembershipHistory
@segments = Array.new
def initialize
@segments = reload
end
def reload
MemberHistorySegment.where("member_history_id = ? ", self[:id])
end
def current_member?
current_segment.nil? ? false : true
end
def current_segement
@segments.select { x | Date.to... | true |
af3ca507cdde90852806f6780c458333abd6cd18 | Ruby | LouAlicegary/true_skill | /lib/true_skill/variable.rb | UTF-8 | 1,131 | 3.078125 | 3 | [
"MIT"
] | permissive | module TrueSkill
class Variable < Gaussian
@delta=nil
def initialize()
super()
@messages={}
end
def set(val)
@delta=delta(val)
@pi=val.pi
@tau=val.tau
end
def delta(other)
return [(@tau-other.tau).abs,Math.sqrt((@pi-o... | true |
7f1160a1e436b0efff31aab2cb10f96b6e913b44 | Ruby | iconara/snogmetrics | /lib/snogmetrics/kissmetrics_api.rb | UTF-8 | 3,784 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Snogmetrics
class KissmetricsApi
# Do not instantiate KissmetricsApi yourself, instead mix in Snogmetrics
# and use it's #km method to get an instance of KissmetricsApi.
def initialize(api_key, session, output_strategy)
@session = session
@api_key = api_key
@output... | true |
054af1d875f54ba3fa2f150b9f2a3add7d51d04f | Ruby | edxco/tic-tac-toe | /lib/player.rb | UTF-8 | 397 | 3.28125 | 3 | [
"MIT"
] | permissive | # rubocop:disable Style/MultipleComparison
class Player
attr_reader :name, :sign
def initialize(name, sign = 'x')
@name = name
@sign = sign
end
end
def check_player(player1, player2)
player1.include?(player2) ? true : false
end
def check_sign(first_player_sign)
first_player_sign == 'x' || first_play... | true |
04663f1870cedad23bfbf1f8f8fb82d568c929ef | Ruby | ffgi-es/slowSilver | /lib/data_label.rb | UTF-8 | 243 | 2.9375 | 3 | [] | no_license | # a helper class to enumerate data section labels
class DataLabel
@indices = Hash.new(-1)
class << self
def indexed(label)
"#{label}#{@indices[label] += 1}"
end
def reset
@indices = Hash.new(-1)
end
end
end
| true |
9026655acbcf1d988f25bda3ed0ea922dab6744a | Ruby | bysxiang/ruby-learn | /module/test6.rb | UTF-8 | 287 | 2.84375 | 3 | [] | no_license | # 测试模块方法
# 证明在模块中执行module_eval, class_eval
# 生成的是实例方法
module Abc
module_eval <<-ruby, __FILE__, __LINE__ + 1
def aa
puts 3333
end
ruby
def aa2
end
end
p Abc.instance_methods | true |
e881dd8b893e2c672175371a754da56b5c2a3888 | Ruby | codeclimate/codeclimate-duplication | /lib/cc/engine/analyzers/sexp_lines.rb | UTF-8 | 802 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module CC
module Engine
module Analyzers
class SexpLines
attr_reader :begin_line, :end_line
def initialize(root_sexp)
@root_sexp = root_sexp
calculate
end
private
attr_reader :root_sexp
def calculate
... | true |
18b98742707ba254f44aeb0aba68a4012a3359de | Ruby | ngohoaiphuong/ruby-pratices | /examing/18.rb | UTF-8 | 900 | 4.0625 | 4 | [] | no_license | Doubleton Number
Mubashir was reading about Doubleton Numbers on Wikipedia.
A natural number is a "Doubleton Number", if it contains exactly two distinct digits. For example, 23, 35, 100, 12121 are doubleton numbers, and 123 and 114455 are not.
Create a function which takes a number n and finds the next doubleton num... | true |
9cc0d8e87f2ce007d8589fa85fb4a136164af02e | Ruby | c-quezada/E6CP1A1 | /3 ciclos anidados/ejercicio3.rb | UTF-8 | 399 | 3.953125 | 4 | [] | no_license | # Construir un programa que permita ingresar un número por teclado e imprimir
# la tabla de multiplicar del número ingresado. Debe repetir la operación hasta
# que se ingrese un 0 (cero).
# Ingrese un número (0 para salir): _
num = 1
until num == 0
puts 'Ingrese un número o cero para salir'
num = gets.chomp.to_i
... | true |
83cb28434f68d4b25662131ebc7855177ab79c81 | Ruby | aziks/Sinatra_Blog | /spec/blog_spec.rb | UTF-8 | 796 | 2.75 | 3 | [] | no_license | require 'rspec'
require 'rack/test'
require_relative '../lib/blog.rb'
require_relative '../lib/post.rb'
RSpec.describe "Blog" do
let (:bloglist) { Blog.new }
describe "#add_post" do
it "should add a post to the blog array" do
new_post = Post.new("post1", "ijdsaffhju")
expect(bloglist.add_post(n... | true |
30ce1c188ad0c061ea172c9648f3e85fb3638757 | Ruby | sinisterchipmunk/vulkan-ruby | /lib/vulkan/dispatch_table.rb | UTF-8 | 3,248 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'vulkan/platform'
module Vulkan
class DispatchTable
include Vulkan::Platform
attr_reader :instance, :device
def initialize(instance, device)
# NOTE it's important we keep handles to both instance and device to
# avoid garbage collection of those objects if they should go out of
... | true |
e1207aa7b411f9a285da5e8bd7156a831db10579 | Ruby | rsbarbo/temp-mid-mod | /spec/features/user_signup_spec.rb | UTF-8 | 1,839 | 2.609375 | 3 | [] | no_license | require "rails_helper"
RSpec.describe "User Sign Up" do
describe "when user visit the root page" do
it "expects to see the option to sign up" do
# As an unauthenticated user
# When I visit the root of the application "/"
visit '/'
# I should be redirected to a page which prompts me to "Lo... | true |
9686d890300e91c3ec800bf2dab2e586fd70112a | Ruby | DaihanaMora/bootcampTalleres | /06Ruby/case.rb | UTF-8 | 1,245 | 4.03125 | 4 | [] | no_license | #print "enter your note"
#grade= gets.chomp
#case grade
#when "a","b"
# puts "you pretty smart"
#when "c","d"
# puts "malo"
#end
include Math
print "introduzca"
print "\n1 para triangulo rectangunlo"
print "\n2 para cuadrado"
print "\n3 para circulo"
print "\n4 para rectangunlo"
print "\n5 para salir"
print "\n... | true |
e968da08b3fef44442e4d03f57512a545c228454 | Ruby | majia2968/euler | /p1-p25/p7.rb | UTF-8 | 104 | 2.578125 | 3 | [] | no_license | Ruby
require 'prime'
i = 1
j = 1
loop do
i += 1
j += 1 if i.prime?
break unless j<10002
end
p i | true |
3f2a9269346684f11814317ddcb3ef206067d468 | Ruby | strasa/behebuilder | /db/seeds.rb | UTF-8 | 1,846 | 3.09375 | 3 | [] | no_license | # Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Behemoth Instincts
Instinct.create([
{name: "Nightmarish", description: "This behemoth is unpredictable and dangerous. It draws two additional cards in its initial hand.... | true |
0e7b050cc247cace010f2f52e150c8ec252021e2 | Ruby | USSBA/certify_activity_log | /spec/support/activity_spec_helper.rb | UTF-8 | 2,789 | 2.6875 | 3 | [] | no_license | # Creates mock hashes to be used in simulating activities
module ActivitySpecHelper
def self.json
JSON.parse(response.body)
end
# helper to replace the rails symbolize_keys method
def self.symbolize(hash)
hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
end
def self.mock_activities_sym
... | true |
2ce6c4af3f081afae7630606cee1c3271476b64e | Ruby | micahshute/ece_code | /applied_crypto/playground/lesson1/lesson1_ex3.rb | UTF-8 | 4,649 | 3.28125 | 3 | [] | no_license | require 'digiproc'
require 'sqlite3'
require 'pry'
class RubySQL
DB = {}
def self.setup_database(name)
system("touch #{name}.db")
DB[:conn] = SQLite3::Database.open("#{name}.db")
DB[:conn].results_as_hash = true
end
def self.run_migrations(*migrations)
migrations.each ... | true |
5a1e93c8f251877cbea86d6f32410eaa0a308615 | Ruby | camorford/githubportfolio | /trythis_solution.rb | UTF-8 | 1,092 | 3.9375 | 4 | [] | no_license | class Animal
attr_accessor :fur, :eyes, :teeth, :name
@@farm = []
def initialize(fur,eyes,teeth,name)
@fur = fur
@eyes = eyes
@teeth = teeth
@name = name
@@farm << self
end
def self.all
@@farm
end
def position
self.class.all.index(self) + 1
end
def self.list
all.each do |animal|
puts "#{anim... | true |
03679854a624d7f998dacc50e60ed2046c8466c5 | Ruby | fidgeters/fidgetfun | /app/services/badge_creator.rb | UTF-8 | 1,674 | 2.890625 | 3 | [] | no_license | class BadgeCreator
attr_reader :device_id
def initialize(device_id)
@device_id = device_id
end
AVAILABLE_BUDGES = [
{
value: -> (device_id) { Event.where(event_type: :button, device_id: device_id).count },
badges: [
{
condition: -> (value) { value > 0 },
name: :... | true |
226c8212ce0c7dc6c6dd3b6525ce6878b32fea46 | Ruby | irahrosete/snake-game | /src/game/game.rb | UTF-8 | 592 | 3.0625 | 3 | [] | no_license | require_relative "board"
require_relative "snake"
require_relative "prey"
require "io/console"
board = Board.new(18)
board.create_board_array
prey = Prey.new(board)
prey.draw_prey
snake = Snake.new(board, prey)
snake.draw_snake
# refreshes screen when control is input
thread = Thread.new do
while !snake.game_ov... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.