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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
84a8826918ea21f3849d0010de9cb75b38adecf3 | Ruby | AJAYJAITWAL/Ruby_programs | /All_small_pro/vowel_orNot.rb | UTF-8 | 247 | 4.1875 | 4 | [] | no_license | puts "Enter character "
c = gets.chomp()
if(c=='a' or c=='i' or c=='o' or c=='u' or c=='e')
puts "This is a vowel"
elsif(c=='A' or c=='I' or c=='O' or c=='U' or c=='E')
puts "This is a vowel"
else
puts "This is a consonet"
end | true |
be246cdfa1c7640e4129a72b8418015d003dc9fa | Ruby | a2ikm/authenticate_from_scratch | /app/models/session_storage.rb | UTF-8 | 205 | 2.53125 | 3 | [] | no_license | module SessionStorage
class <<self
def set(key, value, expires_in)
Rails.cache.write(key, value, expires_in: expires_in)
end
def get(key)
Rails.cache.read(key)
end
end
end
| true |
a1d8101a59f42110f999dba1e00e3191c96996e2 | Ruby | ndomar/megasoft-13 | /Rails/WebsitesPrototypeBuilder/spec/models/comment_spec.rb | UTF-8 | 795 | 2.578125 | 3 | [] | no_license | require 'spec_helper.rb'
describe Comment do
before(:each) do
@attr = {:body =>"My Comment",:assigned_part => "1"}
end
it "should create a new Comment" do
Comment.create!(@attr)
end
it "should require a Comment" do
no_body = Comment.new(@attr.merge(:body => ""))
no_body.shoul... | true |
1a38254c1d75ac0408f438b5f436bd01a670a854 | Ruby | cola119/CompetitiveProgramming | /AtCoder/BeginnerSelection/ABC086C.rb | UTF-8 | 240 | 3.359375 | 3 | [] | no_license | def test
n = gets.chomp.to_i
t1, x1, y1 = 0, 0, 0
n.times do
t2, x2, y2 = gets.chomp.split(" ").map(&:to_i)
return "No" if ((x2-x1).abs+(y2-y1).abs-t2-t1) % 2 != 0 || (x2-x1).abs+(y2-y1).abs > t2-t1
end
return "Yes"
end
puts test
| true |
c36654b3b7b0a178795c022e2c695cef96ffe3bf | Ruby | turuthivic/EBWiki | /app/services/determine_visits_to_cases.rb | UTF-8 | 790 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# This service object, given a list of URLs and the views for each one, will
# return a list of cases the URLs lead to the corresponding views.
class DetermineVisitsToCases
include Service
# The begin..rescue..end block is used to determine if the URL leads to an
# article without ... | true |
9f8346f2d3522b98fae9d7cb4700dad4668c2840 | Ruby | sakura2uuu/algorithm | /ruby/acm_icpc_team.rb | UTF-8 | 1,271 | 3.296875 | 3 | [] | no_license | # Problem: https://www.hackerrank.com/challenges/acm-icpc-team/problem
# Original solution taking too long to run
def acmTeam(topic)
num_of_attendees = topic.count
permutations = (0..(num_of_attendees - 1)).to_a.permutation(2).to_a
unique_permutations = permutations.map do |array|
array.sort
end.uniq
r... | true |
c0264ada243be4f2a2430040d6fe01bd25669d7a | Ruby | briandunn/flatware | /lib/flatware/serialized_exception.rb | UTF-8 | 672 | 2.859375 | 3 | [
"MIT"
] | permissive | module Flatware
class SerializedException
attr_reader :class, :message, :cause
attr_accessor :backtrace
def initialize(klass, message, backtrace, cause = '')
@class = serialized(klass)
@message = message
@backtrace = backtrace
@cause = cause
end
def self.from(exception)
... | true |
a691cbe2cde2b7b7a69843b37b7489f6afe9352d | Ruby | nlangford/Odin | /LearnRuby/02_calculator/calculator.rb | UTF-8 | 164 | 3.59375 | 4 | [] | no_license | def add(num1, num2)
num1 + num2
end
def subtract(num1, num2)
num1 - num2
end
def sum(arr)
total = 0
arr.each {|i| total+=i}
return total
end | true |
92fa3b5d71533495a452649f4f3f2978a1ada7e0 | Ruby | kawatoshi/toukei | /kokyaku_jyouhou_touroku.rb | UTF-8 | 948 | 2.796875 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
require './inputkey'
include Inputkey
open(ARGV[0].chomp, 'r') do |io|
kokyaku = Inputkey::Inputkey.new("")
kokyaku_kana = Inputkey::Inputkey.new("")
kokyaku_ryaku = Inputkey::Inputkey.new("")
while line = io.gets
ary = line.split(/\t/)
k_id = ary[0]
kokyaku.set_source... | true |
ce36f28828c340ea268b243d12727474478e773b | Ruby | craigh44/Ruby_FizzBuzz | /lib/fizzbuzz.rb | UTF-8 | 371 | 4.03125 | 4 | [] | no_license | class FizzBuzz
def isDivisibleByThree(number)
number % 3 == 0
end
def isDivisibleByFive(number)
number % 5 == 0
end
def isDivisibleByFifteen(number)
number % 15 == 0
end
def say(number)
return "FizzBuzz" if isDivisibleByFifteen(number)
return "Fizz" if isDivisibleByThree(number)
return "Buzz" if ... | true |
b77fb2e684d2bf016e3ded88ecd3ac0d83b6c814 | Ruby | Kimbeaux/Learn-Ruby-Ex-5 | /ex5.rb | UTF-8 | 1,415 | 4.25 | 4 | [] | no_license | name = 'Zed A. Shaw'
age = 35 # not a lie
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
puts "Let's talk about %s." % name
puts "He's %d inches tall." % height
puts "He's %d pounds heavy." % weight
puts "Actually that's not too heavy."
puts "He's got %s eyes and %s hair." % [eyes... | true |
d39c4a76a5effa5c7926a8ead9fc24a1f8571613 | Ruby | leoelios/uniara_virtual_parser | /lib/uniara_virtual_parser/services/files.rb | UTF-8 | 1,575 | 2.609375 | 3 | [
"MIT"
] | permissive | module UniaraVirtualParser
module Services
module Files
def files(token)
response = Client.get_with_token('/alunos/consultas/arquivos/', token)
parse_files response.body
end
private
def parse_files(html)
doc = Nokogiri::HTML(html)
files = []
... | true |
378ff44458b8bdc6b837013b04e7f519e85a1a5d | Ruby | phinze/puppet-postgresql | /spec/puppet_spec/files.rb | UTF-8 | 1,327 | 2.625 | 3 | [
"ISC"
] | permissive | require 'fileutils'
require 'tempfile'
# A support module for testing files.
module PuppetSpec::Files
# This code exists only to support tests that run as root, pretty much.
# Once they have finally been eliminated this can all go... --daniel 2011-04-08
#if Puppet.features.posix? then
# def self.in_tmp(path)
... | true |
cf87b74cb75d2dafe202c23118064e4d7a6e0376 | Ruby | Matlawton/coder-academy-t1a3 | /src/extras_archive/name_controller.rb | UTF-8 | 970 | 3.65625 | 4 | [] | no_license | # require "./test2"
# THIS FILE IS NOT CURRENTLY BEING USED.
class NameController
def self.user_name
user_name_attempt = 0
while user_name_attempt < 3
puts "Hey, whats your name?"
user_name = gets.chomp.capitalize
# If the user types in a name then th... | true |
c5f048f88c084223e12b667b25a10216ad87b7b2 | Ruby | brainomite/ruby-minesweeper | /board.rb | UTF-8 | 1,821 | 3.671875 | 4 | [
"MIT"
] | permissive | require_relative "tile.rb"
class Board
def initialize()
@grid = Array.new(9) { Array.new }
@grid.each_with_index do |col, row_idx|
9.times { |col_idx| col << Tile.new([row_idx, col_idx], self)}
end
bombs = Board.get_ten_random_pos
bombs.each do |bomb|
x,y = bomb
@grid[x][y].make... | true |
cbf0b6170154c9c9cedff10dc8951d3f02557025 | Ruby | FusionBolt/PLP-Experiment | /DataTypes/TypeSystemDemo/type.rb | UTF-8 | 6,287 | 2.9375 | 3 | [
"MIT"
] | permissive | require './helper'
class Fun
attr_accessor :name, :params, :body, :param_type_constrains
def initialize(name, params, body, type_constrains = {})
@name, @params, @body, @param_type_constrains = name, params, body, type_constrains
end
def type_valid?(env = {})
@body.type_valid? full_env env
end
d... | true |
e7343c278380af226d922b43296cdaafe641fb71 | Ruby | krestenkrab/hotruby | /modules/vm-test/ruby_test/test/core/FileStat/instance/tc_size.rb | UTF-8 | 919 | 2.765625 | 3 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | #########################################################################
# tc_size.rb
#
# Test case for the FileStat#size and File::Stat#size? instance methods.
#########################################################################
require 'test/unit'
class TC_FileStat_File_Instance < Test::Unit::TestCase
def s... | true |
c37c606d2d4d9b3ebb982815885ff08b60b68c58 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/space-age/7d96ec4b063546b3b59ec9975fb2a364.rb | UTF-8 | 584 | 3.53125 | 4 | [] | no_license | class SpaceAge
attr_reader :seconds
def initialize(seconds)
@seconds = seconds
end
private
EARTH_YEARS = {
earth: 1.0,
mercury: 0.2408467,
venus: 0.61519726,
mars: 1.8808158,
jupiter: 11.862615,
saturn: 29.447498,
uranus: 84.016846,
neptune: 164... | true |
9acdf0a41542c227a8d5487d118b64fec6a19c40 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/method_source/14953.rb | UTF-8 | 340 | 3.1875 | 3 | [] | no_license | def combine_anagrams(words)
letter_counts = Hash.new
words.each do |word|
value = count_letters(word)
if letter_counts.has_key?(value) then
letter_counts[value].push(word)
else
letter_counts[value] = [word]
end
end
result = []
letter_counts.each_value { |value| result.push(value) }... | true |
3c57f87671f9a5ab6ce657637f441c793d112b2f | Ruby | edeutschie/Calculator | /ed.calculator.rb | UTF-8 | 1,958 | 5.125 | 5 | [] | no_license | # opening statment
print "\nAre you ready to do some math?"
# establish array of operators
operators = [ "add", "+", "subtract", "-", "multiply", "*", "divide", "/" ]
# get user input for operation
print "\n\nWhat do you want to do? You can enter add, + , subtract, - , multiply, * , divide, or /.\n\n"
operation = get... | true |
deb385bb297e95da98a011eded2b9ea012462411 | Ruby | trailblazer/representable | /test/skip_test.rb | UTF-8 | 2,994 | 2.53125 | 3 | [
"MIT"
] | permissive | require "test_helper"
class SkipParseTest < MiniTest::Spec
representer! do
property :title, skip_parse: ->(options) { options[:user_options][:skip?] and options[:fragment] == "skip me" }
property :band,
skip_parse: ->(options) { options[:user_options][:skip?] and options[:fragment]["name"].nil? ... | true |
a2099dcbcde25ee83b2975f35c946326ad2e7f55 | Ruby | emalfano/intro-to-programming | /loops_and_iterators/ex1.rb | UTF-8 | 115 | 3.375 | 3 | [] | no_license | x = [1, 2, 3, 4, 5]
x.each do |a|
a + 1
end
# the each expression returns the original array, a + 1 does nothing | true |
8fcfa306b093035cdfa18b388740538b2be1d5e4 | Ruby | charlesbjohnson/super_happy_interview_time | /rb/lib/leetcode/lc_108.rb | UTF-8 | 1,037 | 3.5 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
module LeetCode
# 108. Convert Sorted Array to Binary Search Tree
module LC108
TreeNode = Helpers::LeetCode::BinaryTree::TreeNode
# Description:
# Given an integer array nums where the elements are sorted in ascending order,
# convert it to a height-balanced binary se... | true |
6e5aecec64c7b69ace8392a5f0d79f20497f2158 | Ruby | bernerdschaefer/svg | /lib/svg/canvas.rb | UTF-8 | 899 | 2.84375 | 3 | [] | no_license | module SVG
class Canvas < XML::Document
include NodeHelpers
# @param width the canvas width
# @param height the canvas height
def initialize(width, height)
super()
self.root = SVG::Node.new "svg",
version: "1.1",
xmlns: "http://www.w3.org/2000/svg",
width: width,
... | true |
ec92574fed802fa38df98d8a8f283345570f7d01 | Ruby | taw/project-euler | /euler_38.rb | UTF-8 | 284 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env ruby1.9
rv = []
(1...100_000).each{|k|
v = ""
(1..9).each{|i|
v += (k*i).to_s
next if v.size < 9
break if v.size > 9
break if v =~ /0/
if v.split(//).uniq.size == 9
p [v.to_i, k, i]
rv << [v.to_i, k, i]
end
}
}
p rv
p rv.max
| true |
527a30f805becfb41da55671fc6a300b9e53d01b | Ruby | davidlesches/infuser | /lib/infuser/helpers/hashie.rb | UTF-8 | 317 | 2.609375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | module Infuser
module Helpers
module Hashie
def camelize_hash hash
hash.each_with_object({}) do |(key, value), h|
h[key.to_s.split('_').map { |w| safe_classify(w) }.join] = value
end
end
def safe_classify w
w[0] = w[0].upcase; w
end
end
end
end | true |
27ef7b369edb8535213816a6664227dc3161ca33 | Ruby | konomi1/ruby | /compare.rb | UTF-8 | 130 | 3.125 | 3 | [] | no_license | total=100
if total<200
puts "合計は200未満です。"
end
if total>=150
puts"合計は150以上です。"
end
| true |
6d43769f811c3868b5a193fa1abce236d1a2dea1 | Ruby | camisoul/atcoder | /ABC/056/A/ruby/test.rb | UTF-8 | 93 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
a, b = gets.split
puts a == b ? 'H' : 'D'
| true |
25a3aac7a4f9f1ba78b6ca188a08fc7283f2a259 | Ruby | Ninigi/upsalla | /lib/helpers/string_helper.rb | UTF-8 | 392 | 2.875 | 3 | [
"MIT"
] | permissive | module Upsalla
module StringHelper
def snake_case(string)
return string.downcase if string.match(/\A[A-Z]+\z/)
string.
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
gsub(/([a-z])([A-Z])/, '\1_\2').
downcase
end
def demodulize(string)
if i = string.rindex("::")
... | true |
9c115b4ab3511022f75330b4f96cf98a081879cd | Ruby | MDes41/exercism | /ruby/prime-factors/prime_factors.rb | UTF-8 | 537 | 3.703125 | 4 | [] | no_license | #all working but needs to be cleaned up
class PrimeFactors
def self.for(number)
final = [number]
result = []
divisor = 2
loop do
break if number == 1
break if result.reduce(:*) == final.first
while divisor <= final.first
if number % divisor != 0
divisor += 1
... | true |
019914c16ed65fecfec77105d91bdf0b9e08b084 | Ruby | adynata/EmotionalWeatherReport | /app/models/feel.rb | UTF-8 | 3,030 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: feels
#
# id :integer not null, primary key
# feel :string not null
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Feel < ActiveRecord::Base
attr_accessor :ra... | true |
9aeba903b93f735230fccfc18f6342d161b10c58 | Ruby | YOUSUKE0601/ruby-practice | /ruby_practice1/reizoko.rb | UTF-8 | 1,217 | 3.59375 | 4 | [] | no_license | require "./power.rb"
# 冷蔵庫モデルA クラス
class ReizoukoA
# 設定温度を受け取ってインスタンス変数を保持する
def initialize(num)
@set_temperature = num.to_i
@temperature = 25
@foodstuff = []
power(:on)
puts "設定温度を #{@set_temperature}に設定しました"
puts "現在の温度は #{@temperature}です"
puts "#{@foodstuff.size}個の食材があります"
end
... | true |
244deda55a0548ee4fb958004122442d2b3fd989 | Ruby | luismulinari/timestamp-estrito | /timestamp.rb | UTF-8 | 4,271 | 2.734375 | 3 | [] | no_license | class Transacao
attr_accessor :dados_bloqueados
attr_reader :id, :ts, :historia
def initialize(historia, ts, id)
@historia = historia.chomp("\n")
@operations = Array.new
@historia.split(' ').each { |a| @operations.push Operacao.new(a[0,1], a[2,1]) }
@ts = ts
@id = id
p "Transacao criada ... | true |
604b220504226303759d5be5df3047c01ce4cb28 | Ruby | kdow/slack-cli | /lib/channel.rb | UTF-8 | 1,002 | 2.90625 | 3 | [] | no_license | require_relative "recipient"
require 'dotenv'
Dotenv.load
module SlackCLI
class Channel < Recipient
attr_reader :topic, :member_count
def initialize(slack_id:, name:, topic:, member_count:)
super(slack_id: slack_id, name: name)
@topic = topic
@member_count = member_count
end
def ... | true |
b5a0ac38867f7fddd29cfb45211bfbfb77d4774b | Ruby | lsowen/pentestpackage | /gppdecrypt.rb | UTF-8 | 525 | 3.125 | 3 | [] | no_license | require 'rubygems'
require 'openssl'
require 'base64'
encrypted_data = ARGV
def decrypt(encrypted_data)
padding = "=" * (4 - (encrypted_data.length % 4))
epassword = "#{encrypted_data}#{padding}"
decoded = Base64.decode64(epassword)
key = "\x4e\x99\x06\xe8\xfc\xb6\x6c\xc9\xfa\xf4\x93\x10\x62\x0f\xfe\xe8... | true |
02d4a0dbb53f2b8ef2a2dbe0541e2be22b4be5f7 | Ruby | tongxm520/ruby-code | /ClassicalProgram/lib/enumerable.rb | UTF-8 | 3,285 | 3.6875 | 4 | [] | no_license | #encoding:utf-8
class Undergraduate
attr_accessor :student_no, :name, :gender, :birthday, :credit
def age
Time.now.year-self.birthday.year
end
def display_full_info
puts "#{self.name},#{self.student_no},#{self.gender},#{self.age},#{self.credit}"
end
def self.max_age(first,*rest)
# Assume t... | true |
30a1d00b8c46d080d1b62943caa629378a5a3967 | Ruby | carolyny/launchschool | /Backend/101/Exercises/halvsies.rb | UTF-8 | 409 | 3.59375 | 4 | [] | no_license | def halvsies(array)
array1=[]
array2=[]
index = 0
loop do
array1 << array[index]
index+=1
break if index >= array.size/2.0
end
loop do
break if index >= array.size
array2 << array[index]
index+=1
end
result = [array1,array2]
end
puts halvsies([1, 2, 3, 4]) == [[1, 2], [3, 4]]
puts halvsies([1, 5, 2, 4,... | true |
c8574d33a70eb895a1801301c3996de1a3dcb63f | Ruby | r-osoriobarra/desafios_array_archivos_27-05-21 | /calculo_notas2.rb | UTF-8 | 351 | 3.296875 | 3 | [] | no_license | #Desafío 3 - calculo_notas 2
#leer el archivo y transformarlo a array
data = (File.open('notas.data').read).split("\n")
marks = data.map {|e| e.split(',')}
#lógica de nota mayor
def nota_mas_alta(array)
high_marks = array.map do |i|
i.map {|e| e.to_i}.max
end
return high_ma... | true |
ea2e1df9093b6b4ba79aecc51673e5c397b400fd | Ruby | CspenceGroup/LouisianaCalling-api | /app/helpers/program_helper.rb | UTF-8 | 1,846 | 2.578125 | 3 | [] | no_license | module ProgramHelper
include ApplicationHelper
# Get regions query string
def regions_query_str(region_ids)
region_ids = region_ids.split(',')
list_of_regions = convert_regions_to_hash
regions = region_ids.map { |region| "'#{list_of_regions[region.to_i]}'" }
"region IN (#{regions.join(',')})"
... | true |
9f9715e8678fac69922dc3514150d1cba7623f5f | Ruby | EduardoLecaros/EconomicSim | /Data/PriceBelief.rb | UTF-8 | 911 | 3.5625 | 4 | [] | no_license | #PriceBelief.rb
require_relative '../Utilities/Extensions'
class PriceBelief
MIN_SPAN = 2.0
MIN_PRICE = 0.01
attr_reader :min, :max
def initialize(min, max)
@min = min
@max = max
end
def choose_price
@min + rand(@max - @min)
end
def narrow(narrow_amount)
new_min = @min + narrow_amou... | true |
d84ce6f6c71d93210d03fa93e47dc2534bbdebbe | Ruby | Liam-Williams/lighthouse | /week1/day3/pop_bottles.rb/pop_bottles.rb | UTF-8 | 557 | 3.8125 | 4 | [] | no_license | def total_bottles(money)
@bottles = money.to_i / 2
@empty_bottles_to_bottles = @bottles / 2
@caps_to_bottles = (@empty_bottles_to_bottles / 4) + @bottles
@empty_bottles_leftover = @bottles % 2
@caps_leftover = @bottles % 4
@total_bottles = @empty_bottl... | true |
3629366ea6b999167916ac7b09b86b0838f4cc6e | Ruby | 495-Labs-Projects/ChoreTrackerAPI | /app/controllers/tasks_controller.rb | UTF-8 | 3,164 | 2.609375 | 3 | [] | no_license | class TasksController < ApplicationController
# This is to tell the gem that this controller is an API
swagger_controller :tasks, "Tasks Management"
# Each API endpoint index, show, create, etc. has to have one of these descriptions
# This one is for the index action. The notes param is optional but helps des... | true |
a5be0f2d6c9c3b4099fc0598c2f5f7161b95a62d | Ruby | tylerball/raw2jpg | /raw2jpg | UTF-8 | 3,702 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'open3'
require 'optparse'
require 'tmpdir'
require 'fileutils'
require 'shellwords'
require 'byebug' if ENV['DEBUG']
options = {
formats: ['raf', 'nef', 'cr2'],
}
opts = OptionParser.new do |opts|
opts.banner = "Usage: raw2jpg [options] [directories]"
opts.on("-e", "--extensions [F... | true |
417b4bc2c36e3157ec0d43342d08f20c0acc9002 | Ruby | joyhuangg/my-select-dumbo-web-080618 | /lib/my_select.rb | UTF-8 | 167 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
i = 0
result = []
while i < collection.length
if yield collection[i]
result.push(collection[i])
end
i += 1
end
result
end
| true |
1ecb363f1abab5b2090ec1d0325350fcca792515 | Ruby | elizabethengelman/lil-blue-feeder | /logger.rb | UTF-8 | 620 | 3.015625 | 3 | [] | no_license | require 'serialport'
class Logger
PORT = '/dev/tty.usbmodem1411'
BAUD_RATE = 9600
DATA_BITS = 8
STOP_BITS = 1
PARITY = SerialPort::NONE
def start
puts "Startinglogger"
log_loop
end
def serial_port
SerialPort.new(PORT, BAUD_RATE, DATA_BITS, STOP_BITS, PARITY)
end
def log_loop
whil... | true |
ffaa55f8bf2fb2a42f22b32f5414bd237bd96dc6 | Ruby | siwka/target_sum | /lib/quest.rb | UTF-8 | 3,122 | 3.078125 | 3 | [] | no_license | require 'calculator'
require 'array'
class Quest
attr_accessor :cli, :calculator, :full_menu, :target, :prices, :values
def initialize(cli)
@full_menu = {}
@prices, @values, @results = Array.new
@calculator = Calculator.new
@cli = cli
end
def start
cli.exit_with_error_message unless @cli.ar... | true |
73fff125ce6779eda183d5c2b62d7a3982c03c07 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/2106.rb | UTF-8 | 307 | 3.234375 | 3 | [] | no_license | def combine_anagrams(words)
hash = Hash.new
words.each do |word|
normalized = word.downcase.chars.sort.join
if (hash[normalized] == nil)
hash[normalized] = Array.new
end
hash[normalized]<<word
end
array = Array.new
hash.each_value { |value| array<<value }
return array
end
| true |
28a2bdd831f6db6444b9fa9fe033043dd33431fb | Ruby | GianlucaAnsaldi/chitter-challenge | /lib/peep.rb | UTF-8 | 508 | 2.984375 | 3 | [] | no_license | require 'pg'
require_relative './database_connection'
class Peep
attr_reader :user_id, :create_time, :body
def initialize(user_id:, create_time:, body:)
@user_id = user_id
@create_time = create_time
@body = body
end
def self.all
peeps = DatabaseConnection.query('SELECT * FROM peeps ORDER BY ... | true |
3f17abb3e62ecae234ba3cb59c76aea0573ad472 | Ruby | rickcid/Ruby-Exercises | /RubyExercise10.rb | UTF-8 | 278 | 3.625 | 4 | [] | no_license | puts 'RUBY EXERCISES ASSIGNMENT'
puts ''
puts 'EXERCISE 10'
puts ''
#Ruby 1.9 method
h = {a: 1, b: 2, c: 3, d: 4}
puts h
h[:e] = 5
puts h
puts ''
#Ruby 1.8 method
new_hash = {:a => '500', :b => '600', :c => '700', :d => '800'}
puts new_hash
new_hash[:e] = "5"
puts new_hash
| true |
f8fbec4e7dd62d1c89b72871ccd7b7ffa3c7e8ba | Ruby | urbanczykd/rev0 | /Bowling/app/models/games/bowling/game.rb | UTF-8 | 2,126 | 3.515625 | 4 | [] | no_license | module Games
module Bowling
class Game < Array
class FramsNumberExceeded < StandardError; end
class UnknownStructure < StandardError; end
class PinNumberExceeded < StandardError; end
MAX_FRAMES = 10
MAX_PINS = 10
def initialize
push(::Games::Bowling::Frame.new)... | true |
f803eec9e15aa0c9f9bc47e15d0e36401af9588d | Ruby | zgfif/rock_scissors_paper | /lib/message.rb | UTF-8 | 495 | 3.59375 | 4 | [] | no_license | class Message
class << self
def win(winner)
"The winning move is #{winner.move}"
end
def tie
'Tie'
end
def invalid_move
'Error: One of the users wrote invalid move'
end
def please_wait
'Please wait...'
end
def name_question(n)
"Hey Player #{n}. Wha... | true |
1bbd5b5ca4ef47a6dbef3fa834e598449dd6e54c | Ruby | thai321/Notes | /Interview/HR/Implementation/Divisible_Sum_Pairs.rb | UTF-8 | 537 | 3.875 | 4 | [] | no_license | # You are given an array of n integers, a0, a1, ... a_n-1
# , and a positive integer, k .
# Find and print the number of (i,j) pairs where i < j and a_i + a_j is divisible by k.
#!/bin/ruby
def divisibleSumPairs(n, k, ar)
# Complete this function
count = 0;
(0...n-1).each do |i|
(i+1...n).each do |j|
... | true |
c387035cc740fdd05ae3131a183a6d49d2892123 | Ruby | obi-a/ragios | /lib/ragios/recurring_jobs/scheduler.rb | UTF-8 | 2,698 | 2.53125 | 3 | [
"MIT"
] | permissive | module Ragios
module RecurringJobs
class Scheduler
attr_reader :internal_scheduler, :work_pusher, :events_pusher
ACTIONS = %w(run_now_and_schedule schedule_and_run_later trigger_work reschedule unschedule).freeze
# interval jobs - trigger immediately and then triggers every time the set inter... | true |
1dcfc3ee939fefca6b92b4748679af811278ea36 | Ruby | sekiya93/ProgramTracing | /exam/ruby_code/tt004_comment.rb | UTF-8 | 338 | 3.5 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# 二進数の加算
# - 配列の添字0から値が入る
def tt004(c)
i = 0
q = 0
while q != 1 do
if c[i] == 1 then
c[i] = 0
i = i + 1
else
c[i] = 1
q = 1
end
printf("%s %d, %s\n", q, i, c.to_s)
end
p c
end
tape = [1, 0, 1]
tt004(tape)
tt004(tape)
tt004(tape)
| true |
6afc208477c7e952b867ac9c3a6385fec1f3cfe9 | Ruby | kyleblee/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 1,538 | 3.515625 | 4 | [] | no_license | module Players
class Computer < Player
WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
CORNERS = [0,2,6,8]
def move(board=nil)
if winning_combo = self.check_mate?(board) # for the winning opp when a ... | true |
0e73f634b2eef51aeb725406d4e21e64c6231028 | Ruby | MyriaBailey/personal-apps | /task_externalizer.rb | UTF-8 | 535 | 4.34375 | 4 | [] | no_license | # Task Externalizer
# Sometimes, you need a bit of extra help externalizing what all needs to be done and in what order.
# This very short program was written to help sort that in a simple interactive app.
def new_task(task)
loop do
puts "What do you need to do in order to #{task}?"
input = gets.chomp
if... | true |
bd02af7159c303f9d064ca3de20d06831c3ab9af | Ruby | Mattens15/Inline-LASESI | /vendor/bundle/gems/faker-1.8.7/lib/extensions/symbol.rb | UTF-8 | 139 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | # For Ruby 1.8
unless :symbol.respond_to?(:downcase)
Symbol.class_eval do
def downcase
to_s.downcase.intern
end
end
end
| true |
2b6ec75c005cad58674b244b29ce5d32af855379 | Ruby | rbembleton/Full-Stack-Blackjack | /app/models/game.rb | UTF-8 | 2,884 | 2.921875 | 3 | [] | no_license | # == Schema Information
#
# Table name: games
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
# turn_id :integer default(0)
# turn_type :string
# status :string default("new")
# next_order_num :integer ... | true |
e13c4701277f430a2fc641e524e4ba0c4353e0f5 | Ruby | mpaulweeks/commander-league | /rb/oracle.rb | UTF-8 | 1,170 | 2.84375 | 3 | [] | no_license |
require_relative 'store'
require_relative 'card_ref'
class Oracle
attr_reader :card_ref, :multiverse
def initialize(card_ref=nil)
@card_ref = card_ref || CardRef.new
@multiverse = Store.load_multiverse
@categories = [
'Land',
'Creature',
'Enchantment - Aura',
'Enchantment',
... | true |
05a8f9edb6f034d92985ab6a8eddb898c7b8af54 | Ruby | iamadawra/menuize | /features/step_definitions/restaurant_steps.rb | UTF-8 | 2,243 | 2.609375 | 3 | [] | no_license | Then /^the restaurant "(.*)" should be editable/ do |restaurant|
r = Restaurant.find_by_name(restaurant)
r.status.should eq("Collaborative")
end
Then /^the restaurant "(.*)" should be awaiting approval/ do |restaurant|
r = Restaurant.find_by_name(restaurant)
r.status.should eq("Pending Approval")
end
Then /^I... | true |
a90d3e18c815337a2e424b086fdde3019208bc57 | Ruby | mikexstudios/noceracode | /automate_chi/tafel_ait.expt | UTF-8 | 3,771 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'logger' #Must be required before automate_chi.rb!
#$log_file = File.new('Z:\Labs\noceracode\automate_chi\test.log', 'w')
$log_file = File.new('C:\Users\Nocera Group\Dropbox\Electrochemistry\Mike\04-08-2013\02tafel\tafel.log', 'w')
$log_file.sync = true #do not buffer
$log = Logger.new($log... | true |
2d446461bcff9bca5feda17f24e0ac41dd4520ac | Ruby | muniere/tailor | /Rakefile | UTF-8 | 5,284 | 2.6875 | 3 | [] | no_license | require 'open3'
#
# Constants
#
VERBOSE = true
NOOP = false
MAPPINGS = {
:bin => {
:src => File.join(Dir.pwd, 'bin'),
:dst => File.expand_path('~/.bin')
},
:bash => {
:src => File.join(Dir.pwd, 'completion/tailor.bash'),
:dst => File.expand_path('~/.bash_completion.d/tailor')
},
:zsh => {
... | true |
f2839bc7a034e3a301135a939f824079c074f1ac | Ruby | ismael-i/Mini_jeu | /app_2.rb | UTF-8 | 2,737 | 3.609375 | 4 | [] | no_license | require "bundler"
Bundler.require
require_relative "lib/game"
require_relative "lib/player"
puts "-" * 49
puts "|Bienvenue sur 'ILS VEULENT TOUS MA POO' ! |"
puts "|Le but du jeu est d'être le dernier survivant !|"
puts "-" * 49
# Demander à l'utilisateur, son prenom
print "Quel est votre prénom?\n"
first_name_... | true |
a6654e6515189e7f4ac5fb8636af400efd13791e | Ruby | epson121/adventofcode | /2016/01.rb | UTF-8 | 1,072 | 3.265625 | 3 | [] | no_license | file = File.new("01.txt", "r")
while (line = file.gets)
moves = line.split(",").map{|e| e.strip}
end
pos = [0, 0]
visited = []
map2 = {
"N" => {
"L" => [-1, 'W'],
"R" => [1, 'E']
},
"S" => {
"L" => [1, 'E'],
"R" => [-1, 'W']
},
"E" => {
"L" => [1... | true |
aa9f01929f9ccc7c69af2d9370168884339462a6 | Ruby | tjpkrp1/tts-class-9-17 | /methods/remainder_challenge.rb | UTF-8 | 662 | 4.4375 | 4 | [] | no_license | # Welcome to the Remainder Challenge
# Divide 2 numbers and return the number and remainder
# If either number is NOT an integer, don't aept the number and ask again.
# The number 0 is UNACCEPTABLE
def get_numbers
# ask the user for a number
puts "enter a number:"
# get that number and save it
number = gets.chomp... | true |
71b9d5659cb0d41a10ded05a4fd33e5125d8826a | Ruby | JulieBerry/Learn_Ruby | /ex14.rb | UTF-8 | 2,578 | 3.796875 | 4 | [] | no_license | # (variable-definition)user_name (equals) (argument-variable).first
# defines a variable as user input
user_name = ARGV.first
user_lastname = ARGV.last
# (variable-definition)prompt (equals) (single-quote)>(single-quote)
# defines a variable to a symbol
prompt = '(+)(+)'
# (put-string) (open-string)Hi (octothorpe)(get... | true |
1e838cf3d83e8a5beb660719b8e1851f07c5fe56 | Ruby | GabyML/battleships-2 | /spec/ship_locator_spec.rb | UTF-8 | 1,351 | 2.921875 | 3 | [] | no_license | require 'ship_locator'
describe ShipLocator do
let(:ship) { double :ship, length: 3 }
let(:board) {double :board, place: nil}
subject {ShipLocator.new(board: board)}
let(:vertical_ship_hash) do
{ship: ship, orientation: :vertical, seed: [0,0]}
end
let(:horizontal_ship_hash) do
{ship: ship, orient... | true |
83ee4cfa21c6dcbab5edf6e1857ca92d2979d094 | Ruby | pmoore/bcw_rails | /config/initializers/constants.rb | UTF-8 | 409 | 2.84375 | 3 | [] | no_license | module BcwConstants
class Cities
WASHINGTON_DC = { :name => 'Washington, DC', :name_short => "DC", :url_slug => 'dc' }
ATLANTA = { :name => 'Atlanta', :name_short => "Atlanta", :url_slug => 'atlanta' }
ALL_CITIES = [ WASHINGTON_DC, ATLANTA ]
def self.find_city_by_url_slug(slug)
ALL_CITIES.ea... | true |
eeab1a4c2007d3bd06967c0942f0a866565a30f4 | Ruby | rks/application_support | /test/array_test.rb | UTF-8 | 2,282 | 3.140625 | 3 | [] | no_license | require File.dirname(__FILE__) + "/test_helper"
require File.dirname(__FILE__) + "/../lib/array.rb"
class ArrayTest < Test::Unit::TestCase
def test_should_receive_instance_level_monkey_patches
injected_methods = %(divided_by)
injected_methods.each do |method|
assert Array.new.respond_to?(method.to_sym... | true |
03dc06aa810abe9540ae5cf8ed51dd3956ed6ce1 | Ruby | qbektrix/pixmatch | /lib/pixmatch/client/delete.rb | UTF-8 | 498 | 2.5625 | 3 | [
"MIT"
] | permissive | module Pixmatch
class Client
module Delete
# Given a list of image filenames, delete the images from the collection.
# @param files [Array] Array of file names.
def delete(filenames)
filenames = [ filenames ] if filenames.is_a?(String)
filenames_hash = { }
filenames.each... | true |
1bdb330348a015167fc03c97c5d0fd7269ec50f3 | Ruby | ysei/project_euler_solutions | /e010.rb | UTF-8 | 147 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'primes'
# N = 10
N = 2_000_000
p = Primes.new(N + 100)
sum = 0
while p.next_prime < N
sum += p.current
end
p sum
| true |
97f7b484ba70d3634c4463d61033b2d863253305 | Ruby | javonesm89/Sencbl | /lib/cli.rb | UTF-8 | 1,466 | 3.265625 | 3 | [] | no_license | require "../Sencbl/environment.rb"
require "./lib/scraper"
require "./lib/word"
class CLI
attr_accessor :word_hash, :has_name
@@prompt = TTY::Prompt.new
def run
if !@has_name
greet
Scraper.collect_dates
@has_name = true
end
@date_option... | true |
7e003c9898d5a591007d6d25750abdf78b75495c | Ruby | getty104/Ruby_Design_Pattern | /Producer-Consumer.rb | UTF-8 | 872 | 3.5 | 4 | [] | no_license |
class Bank
def initialize
@money = 0
@m = Mutex.new
@cv = ConditionVariable.new
end
def add
@m.synchronize{
while @money >5000
puts "add wait"
@cv.wait(@m)
end
n = (rand*2000).to_i
@money += n
puts "add:#{n} :#{@money}"
@cv.broadcast
}
end
def use
@m.synchronize{
whil... | true |
6af0584a9104c64237fddeab711c92ab0831f6b7 | Ruby | lis2/presentations | /objects-extended/test.rb | UTF-8 | 70 | 2.90625 | 3 | [] | no_license | a = 10
Klass = Class.new do |b|
a = 20
b = 30
end
puts a
puts b
| true |
a39da673e5fe1d3f181e082e776ca1cc809a8d58 | Ruby | DartmouthDSC/LinkedNameAuthority | /app/models/concerns/lna/date_helper.rb | UTF-8 | 1,604 | 2.90625 | 3 | [] | no_license | module Lna
module DateHelper
extend ActiveSupport::Concern
# Helper to set date values. Converts dates, in Date or String format, to a RDF::Literal.
#
# @param [String] name of field to be set
# @param [String|Date|DateTime|Time|nil] d value of field
def date_setter(name, d)
case d.cla... | true |
0b87a4654850c9259358d6a5e9ef6f637589c8d3 | Ruby | pronix/studyfiles | /vendor/plugins/hierarchy/lib/hierarchy.rb | UTF-8 | 4,946 | 2.78125 | 3 | [
"MIT"
] | permissive | # @private
module Arel
# @private
module Attributes
# @private
def self.for_with_psql(column)
case column.sql_type
when 'ltree' then String
else for_without_psql(column)
end
end
unless singleton_class.method_defined?(:for_without_psql)
singleton_class.send :alias_me... | true |
56dc25638cff8fa8ba58f4f1d67184f3e1c481a7 | Ruby | LoCodes/my-first-hash-onl01-seng-pt-032320 | /my_first_hash.rb | UTF-8 | 1,590 | 4.125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Challenge I: Instantiating Hashes
# #my_hash
# uses the literal constructor to create a hash that contains key/value pairs
# use the literal constructor to set the variable, my_hash, equal to a hash with key/value pairs of your choice.
def my_hash
my_name = {"name" => "Loren"}
end
# Challenge II: Hash with... | true |
875421a2db97dc9827ee452d91506fca1faa7de0 | Ruby | Daiki-Ishida/Pon | /test/helpers/application_helper_test.rb | UTF-8 | 1,140 | 2.84375 | 3 | [] | no_license | require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
def setup
@user = users(:one)
@ferret = ferrets(:one)
@contract = contracts(:one)
end
test "display_name returns name with proper suffix" do
assert display_name(@user) == "#{@user.name} さん"
assert display_name(@ferret)... | true |
25efa7819a88f66ca78fe17f28f0edfa4c9e8b2c | Ruby | gerard76/magic_engine | /app/models/player.rb | UTF-8 | 5,124 | 2.78125 | 3 | [] | no_license | class Player
DEFAULT_HAND_SIZE = 7
STARTING_LIFE = 20
ZONES = %i(graveyard exiled hand library)
attr_accessor :name, :game
attr_accessor :triggers
#zones
attr_accessor :deck, *ZONES
attr_accessor :life, :overdraw
attr_accessor :mulligan_count
attr_accessor :poison_counter, :mana_pool
a... | true |
467ef4646150eace114569fe1d91ee415cf56660 | Ruby | yoshi0202/uci | /src/app/app/services/ElectricityServices.rb | UTF-8 | 445 | 2.578125 | 3 | [] | no_license | require "ElectricityDTO"
class ElectricityServices
def create_dto(id)
dto = ElectricityDTO.new
dto.cost = find(id).cost
return dto
end
def find(id)
return ElectricitySupply.find(id)
end
def create_supply(charge_id, cost)
return 0 if charge_id.nil? or UtilityCharge.find_by_id(charge_id)... | true |
b214ef7e8dd8bc346d2f27d4399b07d0e885c607 | Ruby | yhupaul/TwO-O-Player-Math-Game- | /game.rb | UTF-8 | 728 | 3.734375 | 4 | [] | no_license | class Game
def initialize(name)
@name = name
@player1 = Player.new('Player1')
@player2 = Player.new('Player2')
end
def start
puts "NEW GAME!! Welcome #{@player1.name} and #{player2.name}"
turn
end
def game_status
puts "P1: #{@player1.lives}/3 vs P2: #{@player2.lives}/3"
end
de... | true |
1c0877b11bda5d9024ef32c63deab0401523f124 | Ruby | tobico/missingno | /spec/missingno_spec.rb | UTF-8 | 2,731 | 3.15625 | 3 | [
"MIT"
] | permissive | require 'missingno'
require 'spec'
#Single class using missingno
class SingleClass
def_when /^(foo|bar)$/, :test
def_when ['one', 'two', 'three'] do
@ok = true
end
attr_accessor :ok
end
#Subclass of class using missingno
class SubClass < SingleClass
def_when /^zap$/, :sub_test
end
#Class with method_mi... | true |
b7a536d4716ae5436690e3db4e8549aa9203abb3 | Ruby | jrobertson/sps_chat | /lib/sps_chat.rb | UTF-8 | 999 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
# file: sps_chat.rb
require 'sps_duplex'
class SPSChat < SPSDuplex
def initialize(host: 'localhost', port: '8080', \
userid: 'user' + (0..1000).to_a.sample.to_s, room: '', \
interactive: true)
@userid = userid
super(host: host, port: port, topic... | true |
c7fc0f52b2dd54a4a0d1330fb33a1a8a43effbf2 | Ruby | jmeirow/command_post | /lib/command_post/util/string_util.rb | UTF-8 | 521 | 2.765625 | 3 | [] | no_license | #require File.expand_path(File.dirname(__FILE__) + '/../../command_post')
module CommandPost
class StringUtil
def self.to_camel_case(field, upcase)
string = field.to_s
upcase == true ? string.upcase : string.split('_').collect{|x| x.slice(0,1).capitalize + x.slice(1..-1) }.join()
end
def ... | true |
d9f39d692e5b031a47dbd52faa2b7abc789648d7 | Ruby | mattTea/Notes_and_Playground | /ch10_airport.rb | UTF-8 | 1,005 | 3.84375 | 4 | [] | no_license | class Airport
def initialize
@hangar = []
end
def land(plane)
@hangar.push(plane)
puts "plane.index: #{@hangar.index(plane)}"
end
def take_off(plane)
if @hangar.length > 0
if @hangar.include? plane
plane_index = @hangar.index(plane)
@hangar.delete_at(plane_index)
... | true |
53a9e0f7674e09b29fd8d26dcd141d5447078ab7 | Ruby | craigjbass/naughts-and-crosses | /spec/unit/board_repository_spec.rb | UTF-8 | 1,230 | 2.546875 | 3 | [] | no_license | shared_examples 'a board repository' do
context 'given no board has been initialised' do
it 'should contain no board' do
expect(subject.fetch).to eq(nil)
end
end
context 'given a board has been saved' do
before { subject.update(this: 'is a fake board') }
it 'should contain a board' do
... | true |
e10124cc7faaf7ffdd4aa4901da7cf8c2f5b39d7 | Ruby | jan-czekawski/code_wars | /6kyu/calculate_string_notation.rb | UTF-8 | 1,187 | 4.375 | 4 | [] | no_license | # Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second.
# For instance, take the strings "fatigue" and "tiguefa". In this case, the first string has been rotated 5 characters forward to produce the second str... | true |
d8b6cbd4a72731baf25fc5b771db5c024a07b6e2 | Ruby | LouisSavoie/create-project | /create-project.rb | UTF-8 | 589 | 2.53125 | 3 | [] | no_license | require 'octokit'
require 'dotenv'
# Set up env vars
Dotenv.load
github_name = ENV['GITHUB_NAME']
github_token = ENV['GITHUB_TOKEN']
# Get project name from the user
print "Project Name: "
project_name = gets.chomp
# Setup Octokit and create GitHub Repo
client = Octokit::Client.new(:access_token => "#{github_token}"... | true |
74518fa6512571a23f76581b2e2496a557d91679 | Ruby | fracus/ruby.exercises | /lib/matem.rb | UTF-8 | 61 | 2.734375 | 3 | [] | no_license | class Matem
def self.suma(a,b)
n=a+b
return n
end
end
| true |
7c55d2c928c28b99034dc67decd73892a007160e | Ruby | jnmandal/chicago-trains | /app/models/train.rb | UTF-8 | 1,534 | 2.875 | 3 | [] | no_license | class Train < ActiveRecord::Base
before_validation :strip_whitespace
validates :run, uniqueness: true
before_save :set_flags
def self.import(file)
CSV.foreach(file.path, headers: true) do |row|
Train.create(
line: row.field(0),
route: row.field(1),
run: row.field(2... | true |
e5e8c3f13c1d0195ac0bff9a2c129c02112e7d30 | Ruby | rocky/rb-trepanning | /processor/command/next.rb | UTF-8 | 3,122 | 2.9375 | 3 | [
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*-
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
require_relative '../command'
class Trepan::Command::NextCommand < Trepan::Command
unless defined?(HELP)
NAME = File.basename(__FILE__, '.rb')
HELP = <<-HELP
**#{NAME}**[+|=|-|<|>|!|<>] [*event-name*...] [*count*]
Ste... | true |
e6162ce43b9d20c01b8ebac75d0af372432868a1 | Ruby | bosoxbill/advent-of-code-2020 | /day4/day4.rb | UTF-8 | 1,348 | 3.09375 | 3 | [] | no_license | class Identification
SHORTHAND_TO_ATTRS = {
pid: :passport_id,
cid: :country_id,
byr: :birth_year,
iyr: :issue_year,
eyr: :expiration_year,
hgt: :height,
hcl: :hair_color,
ecl: :eye_color
}
VALID_ATTRS = SHORTHAND_TO_ATTRS.values
REQUIRED_ATTRS = VALID_ATTRS - [:country_id]
att... | true |
e14bf35767f09e96fa2315a93e4c4928e2010fb9 | Ruby | ezkl/dimapa | /lib/diff_methods.rb | UTF-8 | 4,091 | 3.09375 | 3 | [
"MIT"
] | permissive | module DiffMethods
FIXNUM_MAX = 2**(0.size * 8 - 2) - 1
attr_accessor :diff_timeout
def initialize
# Number of seconds to map a diff before giving up (0 for infinity).
@diff_timeout = 1
end
# Find the differences between two texts. Simplifies the problem by
# stripping any common prefix or suffi... | true |
1d1658c7b999d202683e69222b196dbe9aff6541 | Ruby | nikolic/itekako-darts | /spec/models/game_spec.rb | UTF-8 | 1,399 | 2.5625 | 3 | [] | no_license | # == Schema Information
#
# Table name: games
#
# id :integer not null, primary key
# coeficient_id :integer
# number_of_players :integer
# doubles :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
require 'spec_helper'
... | true |
26ba156b79f4192de15cad3ecb2c5496bb64ba0e | Ruby | mcdees2010/Movie-Bites | /app/controllers/movielists_controller.rb | UTF-8 | 501 | 2.75 | 3 | [] | no_license | class MovielistsController < ApplicationController
def index
if params[:search] #if a user has searched for a movie
sanitized = params[:search].split.map { |i| i.capitalize }.join(' ') #turn what the user searched in capitalized words by each element in an array
@movies = Movie.wher... | true |
e174236c7808c43a9eef49ccdfaebb7d8a02996a | Ruby | rouge-ruby/rouge | /spec/support/similarity.rb | UTF-8 | 851 | 2.515625 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | module Similarity
def self.test(lexer_class)
# state_defintions is an InheritableHash, so we use `own_keys` to
# exclude states inherited from superclasses
state_names = Set.new(lexer_class.state_definitions.own_keys)
candidates = Rouge::Lexer.all.select do |x|
# we can only compare to RegexLex... | true |
b112a8d216b32521ae5532b2a0116a1eb333e0a7 | Ruby | ryanmeinzer/ruby-project-alt-guidelines-nyc01-seng-ft-042020 | /bin/run-legacy.rb | UTF-8 | 195 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require_relative '../config/environment'
# puts "Yo, what's your name? Let's shred."
# puts ""
# puts ""
# greeting
# starter
# play
# puts ""
# puts ""
# puts "Peace!"
# puts ""
# puts "" | true |
20357b10d84ace27f658543bae4a67be1364196d | Ruby | braintree/braintree_ruby | /lib/braintree/resource_collection.rb | UTF-8 | 1,314 | 2.9375 | 3 | [
"MIT"
] | permissive | module Braintree
class ResourceCollection # :nodoc:
include Enumerable
attr_reader :ids
def initialize(response, &block) # :nodoc:
@ids = Util.extract_attribute_as_array(response[:search_results], :ids)
@page_size = response[:search_results][:page_size]
@paging_block = block
end
... | true |
e137bd088c4277117ad73d1e1828e27efad4af87 | Ruby | kristjan/fastmuffin | /app/models/singly.rb | UTF-8 | 739 | 2.84375 | 3 | [] | no_license | require 'httparty'
class Singly
SINGLY_API_BASE = "https://api.singly.com"
def initialize(token)
@token = token
end
def checkins(opts)
start = Time.now
data = HTTParty.get(SINGLY_API_BASE + '/types/checkins', {
:query => opts.merge(:access_token => @token)
}).parsed_response
opts[:f... | true |
6d5b73af323b7e085c45bc86c285f655cf329ffc | Ruby | maksimoreo/chess_ruby | /lib/chesspieces/king.rb | UTF-8 | 3,881 | 3.21875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'chesspiece'
require_relative '../directional_moves'
require_relative '../chess_position'
# King chess piece
class King < ChessPiece
def allowed_cells(from, chessboard)
# Not using available_cells(from, cb) here, because it also returns unchecked castlings
move... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.