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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
07bdee9426f686e91e73108a197192aa25ddd1fb | Ruby | danielnc/tidus | /lib/tidus/strategies/cond_anonymizer.rb | UTF-8 | 1,542 | 2.578125 | 3 | [
"MIT"
] | permissive | module Tidus
class CondAnonymizer
def self.anonymize(table_name, column_name, options = {})
adapter = ActiveRecord::Base.connection.instance_values["config"][:adapter]
case adapter
when "postgresql"
name = "#{table_name}.#{column_name}"
type = options[:result_type] || "text"
... | true |
692a9ae59577f71ee582076a381c3f22ae2b6e62 | Ruby | Invoca/large_text_field | /lib/large_text_field/owner.rb | UTF-8 | 4,059 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "invoca/utils"
module LargeTextField
module Owner
extend ActiveSupport::Concern
include ActiveSupport::Callbacks
included do
has_many(
:large_text_fields,
class_name: "LargeTextField::NamedTextValue",
as: :owner,
autosave: true... | true |
c73ad5aeb19f9fd0e9f04b81665d152a93f41512 | Ruby | taisrs/cefet-redes-pilha-protocolos | /Transporte/client.rb | UTF-8 | 3,274 | 3.265625 | 3 | [] | no_license | # formato de chamada pelo terminal:
# ruby client.rb <IP_ADDRESS> <FILE_NAME>
ip = ARGV[0]
file_name = ARGV[1]
file_content = File.read(file_name)
def build_header(seq:nil, ack:nil, ctl:[], win:nil)
header = "<SEQ="
if seq != nil
header << seq
end
header << "><ACK="
if ack != nil
header << ack
end
head... | true |
b179b785b91fa1c6dfb8b6d9b8f7be59b615cdc5 | Ruby | Dahie/caramelize | /lib/caramelize/health_check.rb | UTF-8 | 1,919 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Caramelize
class HealthCheck
attr_reader :wiki_path, :options
DEFAULT_GOLLUM_HOME_TITLE = 'Home'.freeze
def initialize(wiki_path, options={})
@wiki_path = wiki_path
@options = options
end
def execute
#puts page_paths.sort.inspect
check_pages
#puts intra_wi... | true |
b7c77bd023fd50859cf3a6eef96c7b9982d24b8b | Ruby | ChrisLundquist/project-euler | /7.rb | UTF-8 | 86 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'prime'
primes = Prime.each.take(10001)
puts primes.last
| true |
ce9c19a570d10a2d2e2c9d6113f052b50c9fb805 | Ruby | upenn-libraries/pop_pull | /bin/tagify.rb | UTF-8 | 887 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'csv'
require 'set'
require 'unicode'
flickr_tags = Set.new
tag_source = File.expand_path('../../data/tags_from_flickr.csv', __FILE__)
CSV.foreach(tag_source) do |row|
flickr_tags.add row[0]
end
source_file = File.expand_path('../../data/POPTagList_Mitch_and_Laura_Categories_Sheet1.csv'... | true |
60d582bdfe252ac8ad481945872a32f6e42f3baa | Ruby | pgadzinski/711Coffeescript | /time2.rb | UTF-8 | 903 | 2.9375 | 3 | [] | no_license | require 'time'
#Build the date/time array
@opHrsHash = Hash.new
@opHrsHash[1] = [1,'8:00', '10']
@opHrsHash[2] = [2,'6:00', '8']
@opHrsHash[3] = [3,'10:00', '12']
@opHrsHash[4] = [2,'6:00', '8']
@opHrsHash[5] = [3,'10:00', '12']
@dateTimeAry = "var date_array = ["
@numOfRows... | true |
1c22721bef1e2ce2b58dbdb7401abf9b3f298aed | Ruby | inanecuteposse2/credit_check_new_assignment | /credit_check_new.rb | UTF-8 | 764 | 2.796875 | 3 | [] | no_license | credit_card_num = "4929735477250543"
credit_card_num.reverse!
#set each digit to a variable
number_1 = credit_card_num[0].to_i
number_2 = credit_card_num[1].to_i
number_3 = credit_card_num[2].to_i
number_4 = credit_card_num[3].to_i
number_5 = credit_card_num[4].to_i
number_6 = credit_card_num[5].to_i
number_7 = credit... | true |
4fd8f912cc1772b09282f0fc9208f1538839a095 | Ruby | Friindel33/RubyLessons | /Myapp2/game.rb | UTF-8 | 1,570 | 3.796875 | 4 | [] | no_license | print "How ols are you? "
age = gets.to_i
print "Would you like to play? (Y/N)"
answer = gets.strip. capitalize
if answer == "Y" && age >= 18
puts " Ok, lets play "
money = 100
1000.times do
puts " Press enter to start"
gets
x = rand(0..9)
y = rand(0..9)
z = rand(0..9)
print " #{x} "
sleep ... | true |
b23c27d105f5cd4fe7549ae1c214514f5e9ee5ce | Ruby | yourilwill/web_tutorial | /ruby_projects/case.rb | UTF-8 | 382 | 2.953125 | 3 | [] | no_license | # stone = 'sapphire'
# if stone == 'ruby'
# puts '7月'
# elsif stone == 'peridot'
# puts '8月'
# elsif stone == 'sapphire'
# puts '9月'
# else
# puts 'データが登録されていません'
# end
stone = 'garnet'
case stone
when 'ruby'
puts '7月'
when 'peridot'
puts '8月'
when 'sapphire'
puts '9月'
else
puts 'データが登録されていません'
end
| true |
dd8dd56e86642a73b47c73eff6bb1e26c91666f6 | Ruby | wesleyit/ruby_engesoft_pmc | /arquivado/PMC_Funcionando_0.1/neuronio.rb | UTF-8 | 2,470 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Coding: utf-8
# ***********************************************************************
# Author: Wesley Rodrigues <wesley.it@gmail.com>
# Description: OOPMC - Perceptron Multicamadas Orientado a Objetos
# Version: 0.1
# ***********************************************************************
#
#... | true |
46f4dbd044179906fc5867e954e4941b7f5adab8 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w03/d05/Jacob/wdi_student/lib/wdi_student.rb | UTF-8 | 382 | 3.578125 | 4 | [] | no_license | class Student
attr_accessor :name, :knowledge, :energy
def initialize(name)
@name = name
@knowledge = 0
@energy = 100
end
def code
if energy > 25
@knowledge += 5
elsif @energy < 25
@energy = 0
end
@energy -= 25
end
def break
if @energy > 85
@energy = 100
... | true |
cb91799c64db4a080c261f0a8df87c10fb825499 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/9c258481d0844afe809a3e7b531c9e01.rb | UTF-8 | 200 | 3.546875 | 4 | [] | no_license | class Hamming
def self.compute(str_one, str_two)
len = [str_one.size, str_two.size].min
hamming = 0
(0...len).each { |i| hamming += 1 if str_one[i] != str_two[i] }
hamming
end
end
| true |
0fdce285770beb87e33d7e02cae08ab5c9a8b9be | Ruby | mwagner19446/wdi_work | /w07/d01/Michael/makechange/lib/makechange.rb | UTF-8 | 1,359 | 3.734375 | 4 | [] | no_license | require 'pry'
##Attempt 2
def make_change(cents)
@cents = cents
@change = []
coin_iterator
return @change.join.chomp(" ")
end
def coin_iterator
coins = [ {"value"=>25,"type"=>"Q"},{"value"=>10,"type"=>"D"},{"value"=>5,"type"=>"N"},{"value"=>1,"type"=>"P"} ]
coins.each do |coin|
if coin["value"] <=... | true |
93ecdf9ac0cdc4e42cb1614b6b950ef0fd6aaf22 | Ruby | ruby-i18n/ruby-cldr | /test/format/time_test.rb | UTF-8 | 8,127 | 2.546875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
# frozen_string_literal: true
require File.expand_path(File.join(File.dirname(__FILE__) + "/../test_helper"))
require "date"
class TestCldrTimeFormat < Test::Unit::TestCase
def setup
super
@locale = :de
@calendar = Cldr::Export::Data::Calendars.new(@locale)[:calendars][:gregorian]
en... | true |
0ceb25e620769b81f1274eb3bbbda1147809a7de | Ruby | Immers23/makersbnb | /public/models/conversation.rb | UTF-8 | 471 | 2.765625 | 3 | [
"MIT"
] | permissive | class Conversation
attr_reader :cid, :u1_id, :u2_id
def initialize(db_row)
@cid = db_row['cid']
@u1_id = db_row['u1_id']
@u2_id = db_row['u2_id']
end
def self.all(uid:)
DatabaseConnection.query("SELECT * FROM
conversations WHERE
u1... | true |
7cd03b2f1d1fc2f9494691b42ac73ff0c42a51ad | Ruby | charlesbjohnson/super_happy_interview_time | /rb/test/leetcode/test_lc_309.rb | UTF-8 | 455 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require("config")
require("leetcode/lc_309")
module LeetCode
class TestLC309 < Minitest::Test
include(LC309)
[
[[1], 0],
[[1, 2], 1],
[[2, 1], 0],
[[2, 4, 1, 3], 2],
[[1, 3, 2, 4], 3],
[[1, 2, 3, 0, 2], 3]
].each.with_index { |(prices, e... | true |
79002c55bc67ef2078bfc7f13ff4c3dcf810e84d | Ruby | tadeusrox/hackerrank | /30_days_of_code/day11.rb | UTF-8 | 577 | 3.5625 | 4 | [] | no_license | #!/bin/ruby
n = gets.strip.to_i
binary_chars = n.to_s(2).chars
binary_chars << 'x'
consecutive_counts = 0
response = 0
last_char = nil
all_ones = (binary_chars - ['x']).all? {|x| x == '1' }
if all_ones
puts binary_chars.length - 1
else
binary_chars.each_with_index do |c|
if (c == '1' && (last_char == '1' ||... | true |
cff47965844d174fb206c99e726dfcc6ab7f8ac1 | Ruby | vogon/searchase | /process-snp-dump.rb | UTF-8 | 5,014 | 2.8125 | 3 | [] | no_license | require 'set'
require './snpget'
require './snpcall'
require './snpcall-23andme'
require './alfred'
def base_set_from_seq(bases)
base_set = Set.new
base_set << :A if bases =~ /A/
base_set << :C if bases =~ /C/
base_set << :G if bases =~ /G/
base_set << :T if bases =~ /T/
base_set
end
def seq_from_base_set(ba... | true |
579bb02c466fe51780fd3cc7bf00272d28a4b81f | Ruby | WowzaMediaSystems/wsc-sdk-ruby | /lib/wsc_sdk/enums/idle_timeout.rb | UTF-8 | 1,389 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | ####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
####> This code is licensed pursuant to the BSD 3-Clause License.
module WscSdk
module Enums
# Enumerate valid idle timeouts for a Transcoder.
#
module IdleTimeout
extend WscSdk::Enums
# No idle ... | true |
ccfa4e57025630247660e02c523171ad8a958f54 | Ruby | johnjamesmartin/ruby-on-rails-recipes-app | /test/models/recipe_test.rb | UTF-8 | 1,450 | 2.875 | 3 | [] | no_license | require 'test_helper'
class RecipeTest < ActiveSupport::TestCase
def setup
@chef = Chef.create!(chefname: "mashrur", email: "mashrur@example.com", password: "password", password_confirmation: "password")
@recipe = @chef.recipes.build(name: "vegetable", description: "great vegetable recipe")
en... | true |
8c101f0e8b802d58bd6623087f50474ed055c1b9 | Ruby | nicolerego/seatyourself | /spec/models/restaurant_spec.rb | UTF-8 | 1,310 | 2.765625 | 3 | [] | no_license | # A restaurant must have a name
# A restaurant must have an address
# A restaurant must have a phone number
# A restaurant must have a picture
# A restaurant must have a description
# A restaurant must belong to a category
# A restaurant must not be able to accept more people than it's capacity
require 'rails_helper'... | true |
26d028d2bf37c08a2ad83cccdc722bb7ec52dbab | Ruby | olliebrownlow/Boris_Bikes | /lib/docking_station.rb | UTF-8 | 609 | 3.3125 | 3 | [] | no_license | require_relative 'bike'
class DockingStation
DEFAULT_CAPACITY = 20
attr_accessor :capacity, :bikes
def initialize(capacity = DEFAULT_CAPACITY)
@capacity = capacity
@bikes = []
end
def dock(bike)
fail "Docking station full!" if full?
@bikes << bike
end
def release_bike
fail "No bike avai... | true |
c4ef4e5a35de0d3aa2f07fbe0d62275f1e25b858 | Ruby | alexmpalermo/oo-counting-sentences-online-web-sp-000 | /lib/count_sentences.rb | UTF-8 | 330 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
if self.end_with?("!",".","?")
true
else
false
end
end
def question?
if self.end_with?("?")
true
else
false
end
end
def exclamation?
if self.end_with?("!")
true
else
false
end
end
def count_sentences
self.scan(/[\w][!.?]/).si... | true |
8a8f6a6abd5b09bb353e9a603d3afe80916d3a4a | Ruby | DouglasAllen/Ruby-midi-projects | /NSS-Skip-Theory-101/test/test_scales.rb | UTF-8 | 1,569 | 2.640625 | 3 | [] | no_license | require 'test/unit'
require 'scales'
class ScalesTest < Test::Unit::TestCase
def example_scale1
Scales.new("cmaj")
end
def example_scale2
Scales.new("dmaj")
end
def example_scale3
Scales.new("dbmaj")
end
def example_scale4
Scales.new("bbmaj")
end
def example_scale5
Scales.new... | true |
f56914437754bcfc301741a7717d86f63bd5ec52 | Ruby | this-is-simon/cc_w2d3_pub_homework | /bar.rb | UTF-8 | 411 | 3.4375 | 3 | [] | no_license | class Bar
attr_reader :name
attr_accessor :till, :drinks_stock
def initialize(input_name, input_till, input_drinks_stock)
@name = input_name
@till = input_till
@drinks_stock = input_drinks_stock
end
def bar_can_lose_drink(requested_drink)
@drinks_stock.delete(requested_drink)
return @dr... | true |
5ed6d88b1aa3127b41b82bab0850119fc8765471 | Ruby | arcwhite/integrit-remote | /integrit-remote.rb | UTF-8 | 6,483 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
# == Synopsis
# integrit-remote is a tool for using integrit on a remote filesystem.
# It uploads and runs integrit remotely.
# It then compares the remotely-generated databases against
# the local ones, and sends an email if changes are detected.
require 'net/smtp'
require 'optparse'
require 'rdoc... | true |
ddc0021f4cf0ef17829b459377ec2a0bf00a8b46 | Ruby | onebree/adventofcode | /2015/day02/day02a.rb | UTF-8 | 327 | 2.859375 | 3 | [] | no_license | surface_area = 0
input = File.read('input')
input.each_line do |line|
dimensions = line.split('x').map(&:to_i)
sides = dimensions.combination(2).map { |x| x.inject(:*) }
slack = sides.min
area = 2 * sides.inject(:+)
surface_area += area + slack
end
puts "Total square feet of wrapping paper needed: #{surface_... | true |
6cf3e7e8e3985eb387e35d8365a5c3a2a2d1007b | Ruby | Asahi20/git_practice | /sample.rb | UTF-8 | 34 | 2.515625 | 3 | [] | no_license | msg = "Hello World!"
puts "HELLO"
| true |
dd8c2707ff22fbe32739adf7244db304b93d575d | Ruby | joedean/coderdojo-mcplugins | /lib/bubblebabble.rb | UTF-8 | 1,416 | 3.28125 | 3 | [] | no_license | require "digest/md5"
module BubbleBabble
class << self
def md5(value)
encode Digest::MD5.digest(value)
end
# Direct port of the Ruby 2.1 implementation, since JRuby doesn't
# have it yet.
def encode(digest)
seed = 1
vowels = ["a", "e", "i", "o", "u", "y"]
consonants = ["b... | true |
25e013cad3b92a961249d4174c1c316020a61437 | Ruby | hotchpotch/chrome-extension-starter | /lib/chrome_extension_starter.rb | UTF-8 | 1,067 | 2.671875 | 3 | [
"MIT"
] | permissive |
require 'pathname'
require 'fileutils'
require 'erb'
require 'rubygems'
require 'uuidtools'
class ChromeExtensionStarter
def initialize(argv)
@target_name = argv.first
@uuid = UUIDTools::UUID.random_create.to_s.gsub('-', '')
if !@target_name
warn "usage: chrome-extension-starter myextension"
... | true |
8450e5fc14b2010d23f5ecc1cddfd9f2a3168c98 | Ruby | lanwentian/cocoapods-hmap | /lib/hmap/hmap_reader.rb | UTF-8 | 3,356 | 3.078125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module HMap
# hmap bucket
class HMapBucketStr
attr_reader :key, :perfix, :suffix
def initialize(key, perfix, suffix)
@key = key
@perfix = perfix
@suffix = suffix
end
def description
<<-DESC
Key #{@key} -> Prefix #{@perfix}, Suffix #{@s... | true |
7f47494629f42a88d5308e08a66a07673b6131a3 | Ruby | kenjdavidson/linkedin-ruby-essential-training-1 | /5-enumerables-and-code-blocks/ruby_blanks.rb | UTF-8 | 927 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env ruby
SENTENCES = [{
sentence: "I decided to _ a _ funny party for my _ _.",
options: ["verb", "adjective","adjective","noun"]
},{
sentence: "I was _ down the street one afternoon when _ came up to me and _ in my face.",
options: ["verb", "noun", "verb"]
}]
puts "----------------"
puts "... | true |
01a7dc1d9839a69dd69a018d0f02a338c0339f8f | Ruby | joannalew/aA-homeworks | /W2D1/lib/simon.rb | UTF-8 | 1,269 | 3.6875 | 4 | [] | no_license | class Simon
COLORS = %w(red blue green yellow)
attr_accessor :sequence_length, :game_over, :seq
def initialize(val=1)
@sequence_length = val
@game_over = false
@seq = []
end
def play
while !game_over
take_turn
end
game_over_message
reset_game
end
def take_turn
show_sequence... | true |
5861ba7d660277d42574bcecd4ae74328c6f0b65 | Ruby | mpelos/flush | /lib/flush/promise_attribute.rb | UTF-8 | 353 | 2.65625 | 3 | [
"MIT"
] | permissive | module Flush
class PromiseAttribute
attr_reader :attr_name
def initialize(attr_name)
@attr_name = attr_name
end
def method_missing(method_name)
fail AttributeNotResolved, "This attribute is just a reference and can't call this method; " +
"attribute: #{attr_name}, called_method: #... | true |
2addbce788d1e7e47233eca16b8236bc4755da58 | Ruby | SteveOscar/Complete-Me | /docs/complete_me_test.rb | UTF-8 | 1,667 | 3 | 3 | [] | no_license | require 'pry'
require 'minitest'
require 'minitest/autorun'
require './complete_me'
class CompleteMeTest < Minitest::Test
attr_reader :tree
def setup
@tree = CompleteMe.new
end
# def test_empty_tree
# assert tree.children = {}
# end
#
# def test_it_inserts_a_letter
# tree.insert("c")
# ... | true |
60bfe4bfde2ecac4ed895876fc32b48fbc42a6d0 | Ruby | russellkoons/learning-ruby | /module_2/comparison.rb | UTF-8 | 197 | 3.0625 | 3 | [] | no_license | # in ruby == is equality and != is inequality
# Less than <
p 1 < 8
p 12 < 5
#Less than or equal to <=
p 1 <= 1
p 1 <= 3
# greater than > or equal to >=
p 10 > 5
p 5 > 10
# Works on floats too | true |
bdf26052170553831c7117dfc32b208fcbfa2dcd | Ruby | Marvalero/LearningRuby | /codewars/check_types.rb | UTF-8 | 385 | 2.8125 | 3 | [] | no_license | #!/usr/bin/ruby
class Typer
{
number: Numeric,
string: String,
array: Array,
time: Time,
regexp: Regexp,
boolean: [TrueClass, FalseClass],
exception: Exception,
nil: NilClass
}.each do |(name, types)|
define_singleton_method("is_#{name}?") do |object|
... | true |
0ce88cb195c22b1b6732e989cbc4a3d8b59d43b1 | Ruby | jtp184/taptag | /lib/taptag/nfc.rb | UTF-8 | 5,081 | 2.765625 | 3 | [] | no_license | require 'taptag/pn532/structs'
require 'taptag/pn532/library_constants'
require 'taptag/pn532/pn532'
module Taptag
# The higher level interface to the hardware, implements reading and writing functions using ruby
# conventions.
module NFC
class << self
# Set the interface type, one of :spi, :i2c, or :u... | true |
569b3f59cb2b5c509af429a5726cd887b1ac5240 | Ruby | dant00ine/Ruby-TDD-Basic-Practice | /project.rb | UTF-8 | 233 | 3.109375 | 3 | [] | no_license | class Project
attr_accessor :name, :description
def initialize(name, description)
@name= name
@description = description
puts "\nCreated project #{@name}"
end
def elevator_pitch()
puts "#{@name} #{@description}"
end
end | true |
496bbf93d840d02e26128401565bb1847d096ce4 | Ruby | rovf/rkanren | /app/controllers/home_controller.rb | UTF-8 | 1,529 | 2.578125 | 3 | [] | no_license | # OBSOLETE????
class HomeController < ApplicationController
def init
logger.debug("HomeController.init")
reset_message
end
# params hash:
# username
# dictionaryname
# dictionarykind
# create / open
def login
logger.debug(params.inspect)
reset_message
username=params[:usern... | true |
99645c69706d335a47c0d24f3a886f7da8ce8e89 | Ruby | TylerWDickens/Ruby_Basics | /Loops2/insertnumbers.rb | UTF-8 | 214 | 3.5625 | 4 | [] | no_license | # insertnumbers.rb
numbers = []
loop do
puts 'Enter any number:'
input = gets.chomp.to_i
#numbers << input
numbers.push(input)
break if numbers.size == 5
end
puts "Here are your numbers:"
puts numbers
| true |
7c3a7a8486ee4f7c80bc3a5d9bf04451f7eb450f | Ruby | tiy-tpa-ruby/cohort-7 | /week-6/day-5/terminal-swapi/alderaan.rb | UTF-8 | 1,916 | 3.609375 | 4 | [] | no_license | require 'httparty'
require_relative 'ap'
require_relative 'swapi_attribute'
require_relative 'film'
require_relative 'character'
require 'terminal-table'
require 'tty-prompt'
# When you run the program from the command line (say, ruby alderaan.rb),
# you are presented with a list of Star Wars movie titles to choose be... | true |
f6cf6e71c0887f5278c49ccec7392445cc7e2f15 | Ruby | anaalta/lrthw | /lrthw/ex33/ex33_drill.rb | UTF-8 | 213 | 3.515625 | 4 | [] | no_license |
def counting(n,t)
i =0
numbers = []
while i<n
numbers.push(i)
i+=t
end
numbers.each {|num| puts num}
end
puts "The numbers:"
n=7
t=2
counting(n,t)
puts "and another test:"
n=4
t=1
counting(n,t)
| true |
e3e25a8979ae64345c0d3fdb4fd0c8bc5cbd9834 | Ruby | siman-man/astkit | /lib/astkit/node/unless.rb | UTF-8 | 278 | 2.78125 | 3 | [
"MIT"
] | permissive | class AbstractSyntaxTreeKit
class Node
attr_reader :condition, :body, :els
class UNLESS < Node
def initialize(node:, condition:, body:, els:)
super(node)
@condition = condition
@body = body
@els = els
end
end
end
end
| true |
a64ad0d7e2d577a4b2e328ac4690a12d35f9da2c | Ruby | mszekalski/UMA-Coding-Challenge | /app/models/appointment.rb | UTF-8 | 2,389 | 3.015625 | 3 | [] | no_license | class Appointment < ApplicationRecord
validates :appointment_time, :duration, presence: true
belongs_to :doctor
validate :between_nine_and_five, :in_the_future?, :not_overlapped?, :not_on_weekend?
validates_numericality_of :duration, :greater_than_or_equal_to => 1, :only_integer => true, :message => "Appointmen... | true |
1f5fb1a682bedf248abd08ebe9e05de43b04a5c2 | Ruby | VinceBarresi/common_cs_algorithms | /math/fibonacci.rb | UTF-8 | 235 | 3.34375 | 3 | [] | no_license | =begin
Fibonacci Number Sequence
=end
def fibonacci n
sequence = []
prepre, pre, i = 0, 1, 2
return 0 if n == 0
while i < n
sum = prepre + pre
puts sequence = sum
prepre = pre
pre = sum
i += 1
end
end
| true |
333929defe87b46056465fc8d5ba5a9f17cb1de5 | Ruby | zackforbing/idea_box_js | /db/seeds.rb | UTF-8 | 641 | 2.90625 | 3 | [] | no_license | idea1 = Idea.create(title: "do the thing", body: "you could probably try doing the thing.")
puts "'#{idea1.title}' created!"
idea2 = Idea.create(title: "don't do the thing", body: "you could probably try not doing the thing.", quality: 1)
puts "'#{idea2.title}' created!"
idea3 = Idea.create(title: "forget the thing you... | true |
562558497238536a0fd337e6d9a755aa57478a58 | Ruby | zamananjum0/WeatherForcastApp | /app/models/location.rb | UTF-8 | 400 | 2.90625 | 3 | [] | no_license | class Location
include Locator
attr_accessor :city, :lat, :lng, :country, :timezone
def initialize(city:, lat:, lng:, country:)
begin
@city = city
@lat = lat
@lng = lng
@country = country
@timezone = Timezone.lookup(lat, lng)
rescue ActiveRecord::RecordNotFound => e
p... | true |
220d9a626ecc802a19940dd1e54e8acbb18ae764 | Ruby | Ducz0r/kenlee | /lib/kenlee/wikilee.rb | UTF-8 | 2,856 | 2.578125 | 3 | [
"MIT"
] | permissive | module KenLee
class WikiLee < Base
require 'curb'
require 'json'
MAX_PAGE_LIMIT = 10
ENDPOINT_PREFIX = 'https://{{lang}}.wikipedia.org/w/api.php'
MAIN_TEMPLATE =
'{{ep}}?action=query&generator=random&{{rnc}}&grnlimit={{limit}}&' +
'grnnamespace=0&prop={{prop}}&{{prop_params}}&' +... | true |
6d9f3db485f36d68754032e6f922c478d8a172f9 | Ruby | aggarwaldeepanshu/lightening_poker | /spec/card_spec.rb | UTF-8 | 2,156 | 3.3125 | 3 | [] | no_license | require 'spec_helper'
require 'card.rb'
#require 'Set'
RSpec.describe "a playing card" do
def card(params={})
defaults={
suit: :spades,
rank: 7,
}
#Card.new(**defaults.merge(params))
Card.build(*defaults.merge(params).values_at(:suit, :rank))
end
it "has a suit" do
raise unless card(suit: :spades).suit... | true |
518650e1090a994981fd73b1a9d32acdf76cdb7a | Ruby | renanvy/mini_bank_ruby | /lib/transfer.rb | UTF-8 | 130 | 2.671875 | 3 | [] | no_license | module Transfer
def transfer(account_credited, amount)
@balance -= amount
account_credited.balance += amount
end
end | true |
121e43deddd6509889321aa311edc20ed29e00f6 | Ruby | Aram-Anderson/house-salad | /spec/services/member_spec.rb | UTF-8 | 533 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
describe Member do
it "is instantiated with valid attributes" do
attrs = {
id: "D000197",
first_name: "Diana",
last_name: "DeGette",
role: "Representative",
party: "D",
seniority: "22",
district: "1"
... | true |
8530e6307bd3a04e171e15d6f884a3bbcf1f9fb6 | Ruby | sosedoff/apple_push | /lib/apple_push.rb | UTF-8 | 1,702 | 2.625 | 3 | [
"MIT"
] | permissive | require 'connection_pool'
require 'em-apn'
require 'apple_push/configuration'
require 'apple_push/server'
module ApplePush
LIVE_URL = 'gateway.push.apple.com'
SANDBOX_URL = 'gateway.sandbox.push.apple.com'
@@options = {}
@@pools = {}
def self.configure(options={})
config = ApplePush::Configur... | true |
980625d6aeccdf77b109367885356f21f20a1531 | Ruby | allizad/powerrangers | /powerranger.rb | UTF-8 | 3,005 | 3.96875 | 4 | [] | no_license | #included punch module so every class can fight
module Punch
def punch(punch_strength=10, person_punched)
puts "#{self.name} has punched #{person_punched.name}."
#punch depletes energy by punch_strength
self.strength -= punch_strength
#punch depletes punchee's caffeine_level
person_punched.caffeine_level -= ... | true |
c619faabab999d191b9251eb50d8cdb489aa0b2f | Ruby | dark-panda/google-maps-tools | /lib/google_maps_tools/quad_tree.rb | UTF-8 | 3,838 | 3.078125 | 3 | [
"MIT"
] | permissive |
module GoogleMapsTools
# An implementation of a quad tree for clustering points on a Google Map.
# (Or for that matter, any sort of slippy map that uses Google's projection,
# a.k.a. EPSG:900913, a.k.a. EPSG:3857, a.k.a. EPSG:3785.)
#
# Microsoft's Bing maps documentation has some good information on how
#... | true |
52c9f6460827a67a515880a853ff268b4a1b596d | Ruby | bdezonia/ian | /reports/DBF.rb | UTF-8 | 5,229 | 2.8125 | 3 | [
"MIT"
] | permissive |
#output like this:
# class, metric a, metric b, metric c, etc.
# water,0,0,1
# scrub,1,1,1
require InstallPath + "BinaryWriter.rb"
class ReportWriter
def name
"dBASE format [class metrics only] (.DBF)"
end
def help(verbose)
if verbose
["RDBF - DBF format (dBASE)",
"... | true |
f8b6977e5f06368275c86afd7e6ef8997a9c0627 | Ruby | Louiefigz/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 1,137 | 3.421875 | 3 | [] | no_license |
class Player::Computer < Player
attr_accessor
def move(board)
return "5" if !board.taken?(5)
best_option(board)
end
def best_option(board)
win_move(board) || block_move(board) || strategic_move(board)
end
def opponent_token
self.token == "X" ? "O" : "X"
end
def close_win(board,... | true |
8809f29267cfa0241356eb95940dedd0d73d5540 | Ruby | guidance-guarantee-programme/reporting | /lib/importers/pwni_satisfaction/record.rb | UTF-8 | 1,409 | 2.71875 | 3 | [] | no_license | require 'csv'
module Importers
module PwniSatisfaction
class Record
VALID_SMS_VALUES = '1'..'3'
VALID_SATISFACTION_VALUES = '1'..'5'
SATISFACTION_MAP = {
'1' => 4,
'2' => 3,
'3' => 2,
'4' => 1,
'5' => 0
}.freeze
def initialize(cells)
... | true |
3b2d65edb1fe9aba36a2a4079c7a7141892b83c4 | Ruby | aditya-ramakrishnan/42-ruby-programs | /42-ruby-programs-master/DAY02/ex03/string_search.rb | UTF-8 | 142 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
string = ARGV[0]
query = "z"
if ARGV.length != 1
puts "none"
else
puts query * string.scan(query).length
end
| true |
f98efa2107a76ac4d3729913a383d35182008c89 | Ruby | doomspork/seancallan.com | /src/_plugins/generate.rb | UTF-8 | 1,022 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require "json"
require 'nokogiri'
class SeancallanDotCom < Jekyll::Generator
def generate(site)
writings = []
site.posts.docs.each do |page|
writings.push({
url: "#{site.config['url']}#{page.url}",
title: page.data['title'],
date: page.data['date'],
summary: page... | true |
e9b1064274aad7c6bda29209f2527424585a978b | Ruby | Ramaze/ramaze | /tasks/bacon.rake | UTF-8 | 2,428 | 2.53125 | 3 | [
"MIT"
] | permissive | desc 'Run all bacon specs with pretty output'
task :bacon do
require 'open3'
require 'scanf'
require 'matrix'
require 'pathname'
specs = PROJECT_SPECS
some_failed = false
root_path = Pathname.new(File.expand_path('../../', __FILE__))
# Generate a hash of relative and absolute paths for all the... | true |
0683a12add33ffee245472bb35b6fc52041e5534 | Ruby | subhashsaran/Vending-Machine | /lib/config_loader.rb | UTF-8 | 1,792 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
# This is used by the CLI for interacting with the vending machine config file.
#
# It provides an abstraction layer over the config file to return only Coin and Product objects
# and handles issues with validation and parsing.
class ConfigLoader
CONFIG_PATH = File.join(__dir__, '..', '... | true |
832bace606c3ace8fdd5be2e50d0d3898f6c360e | Ruby | grasp/TestCloudV01 | /bin/Cron/pm_counter/lib/generate_kpi_from_key_counter.rb | UTF-8 | 3,822 | 2.65625 | 3 | [] | no_license | #output kpi result hash string
#key=>fomula name
#value=>kpi value array for each cell
def generate_kpi_from_key_counter(all_fomula,s1_ip,time_counter_hash,source_file,logger)
cell_size=3
time_counter_hash.each do |start_time,one_time_counter|
counter_hash=one_time_counter
#logger.debug "kpi calculation for start... | true |
c58cd42cea707cefbbad50c728507f1023dfa484 | Ruby | socketry/async | /examples/capture/capture.rb | UTF-8 | 2,541 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2022, by Samuel Williams.
require 'irb'
require 'console'
pids = ARGV.collect(&:to_i)
TICKS = Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz).to_f
def getrusage(pid)
fields = File.read("/proc/... | true |
3e76f488a7ce8e3b312f8f2dfd0de0465bf25d8f | Ruby | SlevinKelevra/thinknetica | /Lesson2/task3.rb | UTF-8 | 128 | 3.09375 | 3 | [] | no_license | fibonacci = [0, 1]
while (new_element = fibonacci[-2] + fibonacci[-1]) < 100 do
fibonacci << new_element
end
puts fibonacci
| true |
ac997a8addd7588b22947f94ad33df002438e6ad | Ruby | durf666/thinknetica | /lesson4/main.rb | UTF-8 | 3,448 | 3.359375 | 3 | [] | no_license | require_relative 'cargo_train'
require_relative 'passenger_train'
require_relative 'passenger_car'
require_relative 'cargo_car'
require_relative 'route'
require_relative 'station'
@trains = []
@stations = []
private
def main_menu
puts '************************'
puts 'Программа управления железной дорогой. Выбери... | true |
d6a486b5ff553a3c84f3b1f39f41ff4e1c20b3b5 | Ruby | jewkesy/legendary-happiness | /scripts/niteworks/mvClick.rb | UTF-8 | 2,568 | 2.65625 | 3 | [] | no_license | require 'optparse'
require 'metabolizer'
include Plasma
class Clicky < Metabolizer
attr_accessor :verbose
attr_accessor :outpool
@@webURl = "http://localhost:7787/sluice/niteworks/"
def initialize(*hoses)
puts "starting Clicky daemon" if @verbose
super(*hoses)
@verbose = false
@outpool = ''
... | true |
35071d7aca8b1ef342234c66b9b2fbe7bbc47605 | Ruby | adavia/no_name | /app/models/product.rb | UTF-8 | 588 | 2.8125 | 3 | [] | no_license | class Product < ApplicationRecord
has_many :order_items, dependent: :destroy
validates :title, presence: true
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 1 }
validates :price, presence: true, numericality: { greater_than_or_equal_to: 1 }
def in_stock?
self.quantity > 0
... | true |
20109eb46bfb7fbe5cdbda890562df29417ecfdc | Ruby | bioruby/bioruby.github.io | /archive/doc/Japanese/BR040824-jst/example/example4.rb | UTF-8 | 388 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'bio'
serv = Bio::KEGG::API.new
# lists gene ids on pathway
genes = serv.get_genes_by_pathway("path:hsa00020")
puts "# genes on human's pathway 00020"
genes.each do |gene|
puts gene
end
# converts EC numbers to genes
list = ["ec:1.1.1.1", "ec:1.2.1.1"]
list.each do |ec|
puts "# E. co... | true |
3f3f12df59df5fa91d2c292d260794d9e9477c9f | Ruby | EricRicketts/LaunchSchool | /exercises/Ruby/object_oriented_programming/easy/one/exercise_seven_test.rb | UTF-8 | 865 | 3.34375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require 'pry-byebug'
class ExerciseSevenTest < Minitest::Test
class Car1
attr_accessor :mileage
def initialize
@mileage = 0
end
def increment_mileage(miles)
total = mileage + miles
mileage = total
end
def print_mileage
... | true |
e92d242d94aa0cda5220db98b2336261c237751a | Ruby | AlisherZakir/bringing-it-all-together-london-web-051319 | /lib/helper.rb | UTF-8 | 374 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Helper
# def self.included(klass)
# klass.instance_variable_set(:@all, [])
# klass.singleton_class.class_eval{attr_reader(:all)}
# end
def initialize(**hash)
hash[:id] ||= nil
hash.each do |var, value|
instance_variable_set("@#{var}", value)
self.class.class_eval{attr_accessor(... | true |
7f94e4afdcc8730b1339466fd96764df62603bb4 | Ruby | tamasjung/gp-web-app | /lib/dir_maker.rb | UTF-8 | 339 | 2.96875 | 3 | [
"MIT"
] | permissive | module DirMaker
def ensure_dir(path, mode)
unless isDir(path)
Dir.mkdir path, mode
else
unless File.stat(path).mode == mode
raise "could not change mode for #{path}" unless (1 == File.chmod(mode, path))
end
end
end
def isDir(path)
(File.exist? path) && (File.directory?... | true |
3c03add010b9060d11d77adda62f2512083855a0 | Ruby | halorgium/bt-integration-core | /lib/braintree/grouped_accessor.rb | UTF-8 | 1,294 | 3.03125 | 3 | [] | no_license | module GroupedAccessor
def grouped_accessor(group, *names)
names.each do |name|
if name.is_a?(Hash)
name.each{ |nom,aliased_by| make_grouped_accessor(group, nom, aliased_by) }
else
make_grouped_accessor(group, name)
end
end
end
def make_grouped_accessor(group, name, alia... | true |
c73fdbe4d25945ecff7a792f909fb3c1a66d56bf | Ruby | JBon19/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 144 | 3.265625 | 3 | [] | no_license | def ftoc number
number = (((number-32)*5) / 9)
return number
end
def ctof number
number = (number*9)/5.0 + 32
return number
end | true |
e51cfed2421dba358d4aa27d3f9cabde617c103d | Ruby | daxwann/App_Academy | /intro_programming/to_initials.rb | UTF-8 | 342 | 4.28125 | 4 | [] | no_license | # Write a method to_initials that takes in a person's name
# string and returns a string representing their initials.
def to_initials(name)
str = ""
name.split(" ").each { |ele| str += ele[0] }
return str
end
puts to_initials("Kelvin Bridges") # => "KB"
puts to_initials("Michaela Yamamoto") # => "MY"
pu... | true |
34713c4615c047dfe24632529fe6af66f5d78ad4 | Ruby | eddiepr/MySecondRepository | /profane_filter/spec/profanity_filter_spec.rb | UTF-8 | 803 | 3.0625 | 3 | [] | no_license | # Initial version of our spec, before stubs.
require_relative("../lib/profanity_filter.rb")
require_relative("../lib/imdb_movie_stub.rb")
RSpec.describe("Profanity filter") do
let(:profane_movie) { Imdb::Movie.new("tt0417148") }
# "All these mothafucking snakes on this mothafucking plane."
let(:clean_movie) {... | true |
411c10472cd181739a8fa77f223bbd04643dd468 | Ruby | briwoo/ICS-Course | /ch5/biggerBetterNumber.rb | UTF-8 | 155 | 3.796875 | 4 | [] | no_license | puts "What is your favorite number?"
favNum = gets.chomp
favNum = favNum.to_f
newNum = favNum + 1.0
puts "Here is a better, bigger number: " + newNum.to_s
| true |
d301ab0522ef348d9fa6017405b1abd8e3b23e93 | Ruby | HMoreira2020/recipe-book | /recipe-book-backend/db/seeds.rb | UTF-8 | 2,196 | 2.5625 | 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
0d9df0095352baaf00d39f3126cfa8f502eb2c51 | Ruby | mx98829/123 | /OOP/ttt_bonus_name.rb | UTF-8 | 7,538 | 3.96875 | 4 | [] | no_license | require "pry"
class Board
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] + # cols
[[1, 5, 9], [3, 5, 7]] # diagonals
def initialize
system 'cls'
display_welcome_message
@squares = {}
reset
end
def di... | true |
8b417996e8f535676b99224ccb7a730154b0623e | Ruby | t27duck/porygon | /app/models/nick_whitelist.rb | UTF-8 | 375 | 2.546875 | 3 | [] | no_license | class NickWhitelist < ApplicationRecord
validates :nick, presence: true, uniqueness: true
before_validation :downcase_nick
def self.includes?(nick)
pluck(:nick).include?(nick)
end
private ######################################################################
# before_validation
def downcase_nick
... | true |
ff3840e9cd50f62056e75c25e7d885d1b67bcb66 | Ruby | ZABarton/project_euler | /003/003.rb | UTF-8 | 824 | 4.3125 | 4 | [] | no_license | # The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
require 'prime'
factors = []
def prime_factor(number, factor)
return factor if number == 1
Prime.each(number) do |p|
puts p
if number % p == 0
number = number/p
puts number
if p >= factor
... | true |
6d2da63308c4461892aec266829f31edc2d93bfc | Ruby | xDAGRONx/maze_runner | /builder.rb | UTF-8 | 1,208 | 3.5625 | 4 | [
"MIT"
] | permissive | class Builder
attr_reader :maze, :path
def self.path(maze)
result = new(maze).run.path
result.each { |n| yield n } if block_given?
result
end
def initialize(maze)
@maze = maze
@path = []
end
def run
unless built?
path << maze.entrance.path
path << maze.exit.path
... | true |
9e7d0816e0b0ccd6c8ba69cfa69df4f7f1b5d3cc | Ruby | dcrosby42/libgdx-ecs-truck-physics | /lib/ruby/body_renderable_system.rb | UTF-8 | 1,370 | 2.671875 | 3 | [] | no_license |
class BodyRenderableSystem
include MathUtils
def tick(delta, entity_manager)
OLD_tick delta, entity_manager
entities = entity_manager.get_all_entities_with_component_of_type(BodyRenderable)
entities.each do |e|
brends = entity_manager.get_components_of_type(e,BodyRenderable)
brends.each do... | true |
3ef374fe6330d55e36a83a649e46865a866947e5 | Ruby | clairebvs/Jungle-beat- | /test/Linkedlist-test.rb | UTF-8 | 969 | 2.9375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/Linkedlist.rb'
class LinkedListTest < Minitest::Test
def test_it_exists
list = LinkedList.new
assert_instance_of LinkedList, list
end
def test_list_head_nil_first
list = LinkedList.new
assert_nil list.head
end
def test_appe... | true |
ae517c9ffd8742bbd08a4610e1515e407e11a694 | Ruby | csmb/sinatra-fun | /sinatra.rb | UTF-8 | 456 | 2.625 | 3 | [] | no_license | require 'sinatra'
get '/' do
"Hello world!"
end
get '/about' do
"About me goes here!"
end
get '/hello/:name/:city' do
"Hey there #{params[:name]} from #{params[:city]}"
end
get '/more/*' do
params[:splat]
end
get '/form' do
erb :form
end
post '/form' do
"You said '#{params[:message]}'"
end
get '/secr... | true |
5e720fe2ed2fa4543f9de04fcb5ebafbc11b5ea9 | Ruby | onalv/key-for-min-value-cb-gh-000 | /key_for_min.rb | UTF-8 | 432 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
values_array = name_hash.collect{|key, value| value}
min_value = values_array[0]
key_min = ""
name_hash.collect do |key, value|
if value <= min_value
... | true |
8245cb744fec1c92fca18e44c20bf5a6ef8ef3cb | Ruby | kupolak/codewars | /Ruby/8 KYU/Grasshopper - Summation.rb | UTF-8 | 44 | 2.875 | 3 | [] | no_license | def summation(num)
(num * (num+1)) / 2
end | true |
fbd5172a029ff386da2de507e418027e003e34dc | Ruby | AKarakehayova/ruby-retrospective-2015-1 | /solutions/01.rb | UTF-8 | 303 | 3.453125 | 3 | [] | no_license | EXCHANGE_RATE = {bgn: 1, usd: 1.7408, eur: 1.9557, gbp: 2.6415}
def convert_to_bgn(price, currency)
(price * EXCHANGE_RATE[currency]).round(2)
end
def compare_prices(price, currency, price_two, currency_two)
convert_to_bgn(price, currency) <=> convert_to_bgn(price_two, currency_two)
end
| true |
8ced2a4eb2187ccdf54cc1661c044c9b6d7537d6 | Ruby | aman199002/Data-Structures-and-Algorithms-in-Ruby | /array/largest_contiguous_binary_subarray/largest_subarray.rb | UTF-8 | 950 | 4.0625 | 4 | [] | no_license | # Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.
# Example:
# Input: [0,1]
# Output: 2
# Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.
# Input: [0,1,0]
# Output: 2
# Explanation: [0, 1] (or [1, 0]) is a longest contiguous su... | true |
4a404fd33ecfbd3a60d600c5a43024687f16e9be | Ruby | gchan/advent-of-code-ruby | /2019/day-08/day-08-part-2.rb | UTF-8 | 399 | 3.203125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
file_path = File.expand_path("../day-08-input.txt", __FILE__)
input = File.read(file_path).strip
height = 6
width = 25
area = height * width
layers = input.chars.map(&:to_i).each_slice(area)
area.times do |i|
layer = layers.find do |layer|
pixel = layer[i]
pixel == 0 || pixel == 1... | true |
064ca99d3629b1a2bf160fad2bbd327e561aeddc | Ruby | Mackdatascience007/Projet-validant-POO | /app.rb | UTF-8 | 639 | 3.203125 | 3 | [] | no_license | require 'bundler'
require 'pry'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
player1 = Player.new("Josiane")
player2 = Player.new("José")
while player1.life_points > 0 && player2.life_points >0
puts "--------------------------------------------------------------------"
puts " ... | true |
4a3f0a2315c011fa2872a82c61c1d9481dbdac75 | Ruby | rcackerman/notice-of-claim | /app/helpers/application_helper.rb | UTF-8 | 577 | 2.5625 | 3 | [] | no_license | module ApplicationHelper
def display_time time
return time.strftime("%I:%M %p")
end
def filter_trues object
booleans = get_booleans(object.class)
trues = booleans.select do |k,v|
object.send(k) == true
end
trues
end
def human_boolean label, boolean_value
render "shared/human_b... | true |
4e6fc04f591c0af9e99da77458e79a18d8cd4e00 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/4d808b3c6e38420cba24d763ea5addc5.rb | UTF-8 | 270 | 3.90625 | 4 | [] | no_license | class Anagram
def initialize(word)
@word = word
end
def match(words)
words.select{ |w| anagrams?(w,@word) }
end
private
def sort_chars(word)
word.downcase.chars.sort
end
def anagrams?(w1,w2)
sort_chars(w1) == sort_chars(w2)
end
end
| true |
395e3189956b9111a8362c00134adeaa2a20bcda | Ruby | philihp/tarot | /lib/tarot.rb | UTF-8 | 1,539 | 2.875 | 3 | [
"MIT"
] | permissive | # Turn on tail recursion optimization
# RubyVM::InstructionSequence.compile_option = {
# tailcall_optimization: true,
# trace_instruction: false
# }
module MCTS
require 'mcts/node.rb'
require 'mcts/root.rb'
require 'mcts/search.rb'
require 'mcts/state.rb'
end
module Tarot
MAX_SIZE = 5
CASTLE_TYPE = :x... | true |
53d71560b12b9351e0a93b9667fb8369f1767d34 | Ruby | ondrejbartas/simple_states | /test/class_macro_test.rb | UTF-8 | 793 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class ClassMacroTest < Test::Unit::TestCase
include ClassCreateHelper
test "assumes :created as default initial state" do
assert_equal :created, create_class.initial_state
end
test "states announces states the class supports" do
klass = create_class { states :created, :started, ... | true |
5654fa22a292057ce2f591c4eb589480c9cc1f92 | Ruby | 121watts/sales_engine | /test/transaction_repository_test.rb | UTF-8 | 1,402 | 2.828125 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/transaction'
require_relative '../lib/transaction_repository'
class TransactionRepositoryTest < Minitest::Test
def setup
@transactions = TransactionRepository.new('./test/fixtures/transactions.csv')
end
def test_it_returns_empty_array_if_nothing_is_fo... | true |
a15734e2d646d65260e183077e957bb8242c538e | Ruby | krosipko/cartoon-collections-online-web-prework | /cartoon_collections.rb | UTF-8 | 570 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(here)
here.each_with_index do |name, index|
puts "#{index + 1} #{name}"
end
end
def summon_captain_planet(present)
mod_array = present.map {|x| x.capitalize + "!"}
end
def long_planeteer_calls(names)
len = []
names.each do |x|
if x.length > 4
len << true
else
len ... | true |
92f83f797119e7aac0c0ed826cce8c1bddae9b7b | Ruby | edgar/NYCGeoClient | /lib/nyc_geo_client/client/bbl.rb | UTF-8 | 766 | 2.78125 | 3 | [
"MIT"
] | permissive | module NYCGeoClient
class Client
# Defines methods related to branches
module BBL
# Returns property level information about a tax lot.
#
# @param borough [String] The borough in which the address is located
# @param block [String] Tax block number
# @param lot [String] Tax lot ... | true |
153b4c1d7ae7601095b66766f9a7ae17d9158085 | Ruby | rshallit/tumblr-bot | /tumblr_bot.rb | UTF-8 | 3,891 | 2.671875 | 3 | [] | no_license | require 'watir'
require 'watir-webdriver'
require './account_info.rb'
#$tpass and $temail are defined in external 'account_info.rb' file.
$root = "http://www.tumblr.com"
#Start browser and sign-in
@browser = Watir::Browser.new
@browser.goto $root+'/login'
@browser.text_field(:name => "user[password]").set($tpass) #... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.