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
a4589a39f702b138193ec39daab9137c20bce096
Ruby
sharat94/dictor
/lib/run_me.rb
UTF-8
977
2.78125
3
[]
no_license
#!/usr/bin/env ruby require 'optparse' require_relative 'dictor' @options= {} OptionParser.new do |opts| opts.on("-v", "--verbose", "Show logs") do @options[:verbose] = true end opts.on('--dictionary DICTFILE', '-d', 'Specify dictionary file') { |file| File.open(file) { |f| @options[:dict] = f....
true
90512c21f53afb22f5f930de9e84837cadb9ac76
Ruby
thomas-holmes/rspec-spy_on
/lib/rspec/spy_on/example_methods.rb
UTF-8
1,607
2.6875
3
[ "MIT" ]
permissive
module RSpec::SpyOn module ExampleMethods # Enables an RSpec::Mocks::TestDouble or any other object to act as # a test spy. Delegates to RSpec::Mocks to configure the allowing of # the messages # # In particular, `spy_on` makes this act of configuring real objects # as spies easier by providin...
true
5ff9f0bc1477baa5c6ddec134b7b095215c08319
Ruby
ihassin/alexa_verifier
/lib/alexa_verifier.rb
UTF-8
3,421
2.828125
3
[ "MIT" ]
permissive
require 'net/http' require 'openssl' require 'base64' require 'time' require 'json' class AlexaVerifier VERSION = '0.1.0' class VerificationError < StandardError; end DEFAULT_TIMESTAMP_TOLERANCE = 150 VALID_CERT_HOSTNAME = 's3.amazonaws.com' VALID_CERT_PATH_START = '/echo.api/' VALID_CERT_PORT = 443 ...
true
9e21cde41bafe1cf01b74dee245429557ebae4eb
Ruby
thefulltimereader/reblog
/app/example_user.rb
UTF-8
322
3.03125
3
[]
no_license
class Example_user attr_accessor :name, :email # gives us getter/setter def initialize(attributes = {}) @name = attributes[:name] @email = attributes[:email] end def formatted_email "#{@name} <#{@email}>" end #exercises ch 4 def shuffle_str(str) str.split('').to_a.shuffle.join end en...
true
257a677f3ab9b4d37a1f4aaeba37344f759e0ebb
Ruby
learn-co-students/seattle-web-071519
/04-one-to-many/apollo/lib/mission.rb
UTF-8
193
3.078125
3
[]
no_license
class Mission attr_reader :name attr_accessor :crew @@all = [] def initialize(name, crew) @name = name @crew = crew @@all << self end def self.all @@all end end
true
63bd4490db687ad9eef600f093bddd6d819c673c
Ruby
GreenRabite/Algorithms
/Practice Problems/mock_interview_02.rb
UTF-8
1,351
3.484375
3
[]
no_license
# How to build a LRU Cache # LRU cache is a combination of Hashed Maps and LinkedLists using the # best of both worlds. You will have an array of linked lists that # will periodically kick out from memory the oldest saved value from # the cache # To do this you must first understand what a Linkedlist and #hashed map i...
true
cea9c2c2ffe8fb7505c7bebdc490ffca21479d4a
Ruby
fgrehm/clipper
/lib/clipper/query/query.rb
UTF-8
1,035
2.5625
3
[]
no_license
module Clipper class Query def initialize(mapping, options, conditions) @mapping = mapping @conditions = conditions if options @limit = options.fetch(:limit, nil) @offset = options.fetch(:offset, nil) @order = options.fetch(:order, nil) end end def m...
true
a0ac157bc8c11282a6c011f3e3168f1ec5d2e04d
Ruby
flywheelnetworks/rails-google-visualization-plugin
/lib/google_visualization.rb
UTF-8
5,214
2.671875
3
[ "MIT" ]
permissive
# GoogleVisualization module GoogleVisualization class GoogleVis attr_reader :collection, :collection_methods, :options, :size, :helpers, :procedure_hash, :name @@vis_types = { 'motionchart' => 'MotionChart', 'linechart' => 'LineChart', 'annotatedtimeline' => 'AnnotatedTimeLine', 'tab...
true
e3e17f0e5fe66fed7f521eeae61bcadb359c19d3
Ruby
ErikNPeterson/Erik-s-Ruby-Math-Game-
/playerManager.rb
UTF-8
685
3.375
3
[]
no_license
require_relative './question' class PlayerManager # determining which players turn it is attr_reader :current_player, :enemy_player def initialize(players) @players = players.shuffle @current_player = nil @round = 1 end def get_current_player @players.first end def next_turn @curren...
true
d5634f4d1f5e74a9c4693ef7acdb5659ded93006
Ruby
alve-svaren-nti-johanneberg/school
/programmering1/overleaf_uppgifter/average.rb
UTF-8
346
3.453125
3
[]
no_license
require_relative "./average_number.rb" def average(numbers) if numbers.class != Array raise TypeError, "'numbers' must be an array" end for number in numbers if !number.is_a? Numeric raise TypeError, "'numbers' must only contain numeric values" end end return a...
true
f30e483cb41f99733c5547863bd17e888b745542
Ruby
briiking/AdTopics
/Ruby-labs/Greetings-lab.rb
UTF-8
132
3.8125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
puts "How many years old are you?" years = gets.chomp.to_i def age(years) puts "You are #{years * 365} days old." end age(years)
true
64788f0902089eb50bfe41ec9f27848fbbae68ea
Ruby
kuboj/bitstat-test
/spec/unit/ticker_spec.rb
UTF-8
1,345
2.734375
3
[ "Apache-2.0" ]
permissive
require 'spec_helper' describe Bitstat::Ticker do describe '#new' do it 'takes only one argument - interval' do expect { Bitstat::Ticker.new() }.to raise_error(ArgumentError) expect { Bitstat::Ticker.new(10) }.not_to raise_error end end let(:interval) { 0.1 } let(:ticker) { Bitstat::Ticker...
true
14bdc48b7ce64bdd95a0251c3912981cfa593d2d
Ruby
furafura/intro-to-simple-array-manipulations-001-prework-web
/lib/intro_to_simple_array_manipulations.rb
UTF-8
660
3.234375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def using_push(array, char) array.push(add) end def using_unshift(array, char) array.unshift(char) end def using_push(array, char) array.push(char) end def using_pop(array) array.pop end def pop_with_args(array) array.pop(2) end def using_shift(array) array.shift end def shift_with_args(array) array.shift(...
true
5799bc26b2b22679bf9ef6969fbfbd1a298098be
Ruby
nippysaurus/credit-card-validation
/classes/credit_card_number.rb
UTF-8
1,247
3.578125
4
[]
no_license
require_relative '../helpers/string' class CreditCardNumber attr_accessor :number def initialize(number) @number = number.strip_whitespace end # Attempts to classify the card type. def card_type return 'AMEX' if is_amex_card? return 'Discover' if is_discover_card? return 'MasterCard' if is...
true
b25d5c3bc89e2c0b08b647c9188c1ec132c56eff
Ruby
alansparrow/learningruby
/http_checking_error_and_redirect.rb
UTF-8
673
2.953125
3
[]
no_license
#!/usr/bin/env ruby require 'net/http' def get_web_document(url) uri = URI.parse(url) response = Net::HTTP.get_response(uri) case response when Net::HTTPSuccess return response.body when Net::HTTPRedirection puts "This is redirect link: " + response['Location'].to_s return get_web_document(res...
true
a33a2eea987541050e2b4d7a57e1895b60189470
Ruby
monora/stream
/test/teststream.rb
UTF-8
5,717
3.171875
3
[ "Ruby", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'test/unit' require 'stream' module StreamExamples def new_collection_stream (1..5).create_stream; end # a stream which is aquivalent to new_collection_stream def new_implicit_stream Stream::ImplicitStream.new { |s| x = 0 s.at_beginning_proc = proc { x < 1 } s.at_end_proc = p...
true
3b9e5aa735035e49ff15474aee2144da57b6ab95
Ruby
zosiu/nand2tetris
/hack_assembler/lib/nodes.rb
UTF-8
1,410
2.625
3
[]
no_license
# frozen_string_literal: true module Hack class Vars attr_accessor :variables, :next_var def initialize @variables = { 'R0' => 0, 'R1' => 1, 'R2' => 2, 'R3' => 3, 'R4' => 4, 'R5' => 5, 'R6' => 6, 'R7' => 7, 'R8' => 8, 'R9' => 9, 'R10' => 10, 'R11' => 11, 'R12' => 12, 'R...
true
54405de0bb949e902e30649d3f6837a9a70ed5db
Ruby
martinkilmartin/Web-Framework
/framework.rb
UTF-8
1,200
2.90625
3
[ "MIT" ]
permissive
class App def initialize(&block) @routes = RouteTable.new(block) end def call(env) request = Rack::Request.new(env) @routes.each do |route| content = route.match(request) return [200, {'Content-Type' => 'text/html'}, [content.to_s]] if content end [404, {}, ["Not found"]] end ...
true
e8996daa394b527e857131ba2220aaab2ce11aaa
Ruby
DagmaraSz/learn_to_program
/ch10-nothing-new/shuffle.rb
UTF-8
685
3.875
4
[]
no_license
=begin Defining perfect shuffle as one where no card happens after the same card it did before. Implementation here inspired by the "faro in-shuffle" =end def shuffle arr #split the array in two left, right = arr.each_slice((arr.size/2.0).round).to_a #generate new array where the two arrays intertwine i = 0...
true
28a341ae2dc2ee5cde8b4985a65d830850283cf7
Ruby
lsethi-xoriant/angular_rails_material_example
/lib/param_filters/posts_param_filter.rb
UTF-8
2,385
2.71875
3
[ "MIT" ]
permissive
class PostsParamFilter < ParamFilter LEAGUE_JOIN_KEY = :leaguejoin class << self def custom_params super + %w(q league_type) end def exclusions %w(id league_id post_id league_type user_id deleted_at) end def possible_hockey_league_params possible_params_for_class HockeyLeag...
true
1ffcab8af17eee2fe9632120017d8912cf4ba48d
Ruby
robinrob/ruby
/practice/read_file.rb
UTF-8
621
3.328125
3
[]
no_license
#!/usr/bin/env ruby $LOAD_PATH << '.' require 'lib/log.rb' # Example 1 - Read File and close counter = 1 file = File.new("read_file.rb", "r") while (line = file.gets) printf "%02d: %s".green, counter, line counter = counter + 1 end file.close puts # Example 2 - Pass file to block counter = 1 File.open("read_f...
true
d67e110038eb68a2c7f09ac784ac9a725b0eda0b
Ruby
joshy91/test-guide
/kilosSon.rb
UTF-8
201
3.796875
4
[]
no_license
def yoSon puts "Yo Son" end yoSon yoSon yoSon def pound_kilo num = gets.chomp kilo = num.to_f * 0.45359 return kilo end puts "Enter a number of pounds to convert to kilos son! " puts pound_kilo
true
78356fbd20585d6b5ed09bae67c6da6a30ffcacd
Ruby
Freygarr/disgaea-2-save-editor
/app/models/character/images.rb
UTF-8
831
3.03125
3
[ "MIT" ]
permissive
class Character module Images def self.included(base) base.send(:extend, ClassMethods) base.send(:include,InstanceMethods) end module ClassMethods def image_path(image_type,class_name,rank_id = 0) path = ['images','characters'] class_name = CLASS_IDS[class_name] if c...
true
e58ac44d08da017f6520af582788ce5a3a1ee849
Ruby
maggieholbling/2-player-game
/game.rb
UTF-8
1,343
3.75
4
[]
no_license
class Game attr_reader :player1, :player2 attr_accessor :current_player, :number1, :number2, :random def initialize @player1 = @current_player = Player.new(1) @player2 = Player.new(2) random_question end def random_question @number1 = rand(1..20) @number2 = rand(1..20) ...
true
31320d53028d58f3b5696e17a1f0c0696af82cc4
Ruby
lyntco/wdi_melb_homework
/gumballs/tim_grut/wk1d5 - dogs_n_stuff/pet.rb
UTF-8
504
3.1875
3
[]
no_license
class Pet attr_accessor :name, :age, :gender, :species, :multiple_toys def initialize(pet_details) @name = pet_details[:name] @age = pet_details[:age] @gender = pet_details[:gender] @species = pet_details[:species] @multiple_toys = pet_details[:multiple_toys] end end # jenny_details= { # :na...
true
387e8c2c088f782dcfd8b0f66c11865cddc57a2a
Ruby
conimorales/ProyectosEnRuby
/ruby.ciclosanidados/ruby/listas.rb
UTF-8
251
3.109375
3
[]
no_license
n_externo = ARGV[0].to_i n_interno = ARGV[1].to_i puts "<ul>" n_externo.times do |j| puts "<li> \n" puts "\t <ul>" n_interno.times do |i| puts "\t\t<li> #{j}.#{i} </li>" end puts "\t </ul>" puts "</li>" end puts "</ul>"
true
0d93006a4d99849509b87746c02f18e0a5709dac
Ruby
sambshapiro/slack-fooda-bot
/lib/fooda-bot/storage.rb
UTF-8
696
2.859375
3
[ "MIT" ]
permissive
require 'json' class Storage LATEST_KEY = 'latest' attr_reader :redis def initialize(redis) @redis = redis end def get_latest parse_latest(redis.get(encode(LATEST_KEY))) end def set_latest(name) redis.set(encode(LATEST_KEY), { time: Time.new, name: name }.to_json) end def push(name, ...
true
58b4c5a6f7e43a9f308b1bf1267d4b90b5f81c1d
Ruby
idej/ai
/app/ai.rb
UTF-8
4,944
2.765625
3
[]
no_license
require 'sinatra/base' require 'haml' require 'pry' require 'json' require_relative 'question.rb' class Ai < Sinatra::Base @@rules_array = [] @@conditions_list = {} @@context_stack = {} @@main_aim @@aims_stack = [] @@questions = [] helpers do def aims_options aims = [""] aims += @@rules_...
true
74dd915f1a3f3111b7c9786b3fc6f4fa8e80b236
Ruby
kuna/swpprefactoringpractice
/PrimeGetter.rb
UTF-8
1,578
3.96875
4
[]
no_license
class PrimeGetter attr_accessor :upperlimit, :prime_array, :prime_candidate, :errormessage def initialize(upperlimit) @upperlimit = upperlimit end def geterrormessage unless @upperlimit.is_a? Integer return "n must be an integer." end if @upperlimit < 0 return "n must be greater tha...
true
314739e17dc9cca3cf94f0a956b0c4dc0e02695c
Ruby
siso25/ruby-practices
/02.calendar/calendar.rb
UTF-8
1,302
3.703125
4
[]
no_license
#!/usr/bin/env ruby require 'date' require 'optparse' def positive_integer?(string) return !string.nil? && string.match?(/\d+/) && string.to_i > 0 end def within_range_of_month?(str_month) month = str_month.to_i january = 1 december = 12 return january <= month && month <= december end def calculate_start_...
true
af7010d5d98de20b0658095b0f7e7c47ee2b6f49
Ruby
mauricioedu/cursorubySenac
/Exercicio01/Questao8.rb
UTF-8
186
3.234375
3
[]
no_license
puts "Quanto voce ganha por hora" hora = gets.chomp.to_i puts "Quantos hora voce trabalho nesse mes" mes = gets.chomp.to_i salario = hora*mes puts "Nesse mes voce recebera :#{salario}"
true
5d28b8c722c95b2ae1ce1d9a0c5f4d530aa2b46f
Ruby
zihanoo/copycats
/script/fancies.rb
UTF-8
4,347
2.625
3
[ "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
# encoding: utf-8 #### # use: # $ ruby -I ./lib script/fancies.rb require 'copycats' pp FANCIES buf = "" buf += <<TXT # Updates - Fancy / Exclusive / Special Edition Cats - Timeline see <https://updates.cryptokitties.co> TXT def kitties_kitty_url( id ) "https://www.cryptokitties...
true
aad502a63b5031f4723d705834bef2505ca888df
Ruby
adamsanderson/metric_adapter
/test/reek_adapter_test.rb
UTF-8
1,303
2.703125
3
[]
no_license
require "minitest/autorun" require "metric_adapter" require "reek" class ReekAdapterTest < MiniTest::Unit::TestCase SAMPLE_PATH = 'dirty.rb' include MetricAdapter def test_empty_examiner examiner = Reek::Examiner.new([]) adapter = ReekAdapter.new(examiner) assert_equal [], adapter.metric...
true
315b4becaab63a2d6af2ff363124892bf8a17adf
Ruby
tk0358/meta_programming_ruby2
/chapter5/10paragraph.rb
UTF-8
265
2.921875
3
[]
no_license
class Paragraph def initiazlize(text) @text = text end def title?; @text.upcase == @text; end def reverse; @text.reverse; end def upcase; @text.upcase; end #... end def index(paragraph) add_to_index(paragraph) if paragraph.title end
true
20109b25d8e726038d705bab81fa56c1a004e76f
Ruby
hasinaniaina/DecouverteDeRuby
/exo_15.rb
UTF-8
155
3.359375
3
[]
no_license
puts "entrer votre année de naissance" i = gets.chomp nombre = i.to_i y = 0 for x in nombre..2017 puts " en #{x} vous aviez: #{y} an(s) " y +=1 end
true
d31cbb71ea52cdca807b13ce1b4ce7627dfa9421
Ruby
bburnett86/league
/parser.rb
UTF-8
266
2.75
3
[]
no_license
class Parser def input_teams(file_location) games = File.open(file_location).read.split("\n") end def create_file(output) File.open("final.txt", "w+") do |f| output.each { |element| f.puts(element) } end end end
true
6cb12035cc42344aeb3b4d55487cf87a35b20c71
Ruby
ajnassar/Chess
/pieces/pawn.rb
UTF-8
425
3.15625
3
[]
no_license
class Pawn < Piece #if starting position def deltas delts = [] if color == :black delts += [[0, 1],[0, 2]] elsif color == :white delts += [[0, -1],[0, -2]] end delts end def moves self.deltas.map do |delt| [position.first + delt.first, position.last + delt.last] e...
true
358976ada5e73db22dd36ea35d2644c18c8060d1
Ruby
ukcrpb6/skyrim-alchemy
/bin/ingredient-minima
UTF-8
2,640
2.875
3
[]
no_license
#!/usr/bin/env ruby # require 'csv' require 'json' require 'pp' require 'set' @ingredients = Hash.new json = JSON.parse(File.read(File.expand_path("../../json/ingredients.json", __FILE__))) json.each do |ingredient| ingredient = ingredient.map { |k, v| [k.to_sym, v]}.to_h @ingredients[ingredient[:ingredient]] = i...
true
1850e780d0905b6b55f4b689c058173c93843760
Ruby
axelletrt/movie_searcher
/app/services/search_movie.rb
UTF-8
753
2.734375
3
[]
no_license
class SearchMovie def initialize(request) # Tmdb::Api.key(Rails.application.credentials.dig[:access_key_id]) Tmdb::Api.key(Rails.application.credentials.access_key_id) @request= request end def search(request) array = [] @search = Tmdb::Search.new @search.resource('movie') # de...
true
5e1304baf8bb77c4628244e15736f942c7b91311
Ruby
Jounikononen/Koulu-ja-muita-koodeja
/Ruby/Jakso7.rb
UTF-8
1,164
3.4375
3
[]
no_license
#Jakso 7 tehtävät #Tehtävä 1 #Tarkastetaan onko luku alkuluku print ("Monenteenko lukuun asti etsitään?: ") luku = gets.to_i lista = Array.new lista.push(2) puts("2 on alkuluku!") jako = 3 while jako < luku for luvut in lista if (jako % luvut == 0) puts "#{jako} ei ole alkuluku." break ...
true
d14955e9368f8159542ed7657ce792fd97bf6610
Ruby
nikkamille/badges-and-schedules-onl01-seng-pt-021020
/conference_badges.rb
UTF-8
507
3.6875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def badge_maker(name) "Hello, my name is #{name}." end def batch_badge_creator(names) badges = [] names.each {|name| badges << "Hello, my name is #{name}."} badges end def assign_rooms(attendees) room_assignments = [] attendees.each_with_index {|name, index| room_assignments << "Hello, #{name}! You'll be ...
true
a1008c047ca05edfaa9db8618c3b33e8a1b9eb9e
Ruby
upstart/Kraken
/generator/bin/kraken
UTF-8
2,482
2.5625
3
[]
no_license
#!/usr/bin/env ruby # 1.9 adds realpath to resolve symlinks; 1.8 doesn't # have this method, so we add it so we get resolved symlinks # and compatibility unless File.respond_to? :realpath class File #:nodoc: def self.realpath path return realpath(File.readlink(path)) if symlink?(path) path end e...
true
4a408d5fb45e5c40747502fa889aca3ef35f2b0a
Ruby
austinthelolzcat/lesson1
/app/models/formatter.rb
UTF-8
1,303
3.5
4
[]
no_license
class Formatter def int(value) realreal(value) end def real(value) first = value / 2**3 value = value % 2**3 second = value / 2**2 value = value % 2**2 third = value / 2 value = value % 2 fourth = value / 2**0 result = first.to_s+second.to_s+third.to_s+fourth.to_s puts f...
true
faaf43e047d7aef2ee1a7fbf3c4791fb9484b655
Ruby
nickrim/qa_repo
/BTA/HW_16/script_16_09.rb
UTF-8
159
3.5625
4
[]
no_license
# script_16_09.rb # Display result of the comparison using .eql? operator of following: (1, 1 1, 1.0 qa, qa) puts 1.eql?1 puts 1.eql?(1.0) puts "qa".eql?"qa"
true
0f344f260419d7b7b01281d99683e59452ceda3f
Ruby
mlomnicki/automatic_foreign_key
/spec/support/matchers/have_index.rb
UTF-8
1,307
2.640625
3
[ "MIT" ]
permissive
module AutomaticForeignKeyMatchers class HaveIndex def initialize(expectation, options = {}) set_required_columns(expectation, options) end def matches?(model) @model = model @model.indexes.any? do |index| index.columns.to_set == @required_columns && (@unique ? inde...
true
76f4b1b85dc14e25b2969a1bbc4cd2bd611028e9
Ruby
MikeBlyth/ptbase
/app/helpers/selectable_items_helper.rb
UTF-8
2,804
2.8125
3
[]
no_license
require 'pry' module SelectableItemsHelper # Set up HTML table containing checkboxes supplied by SectionName.visit_fields, and pre-checked # according to their status in record. def check_boxes(record, section_name, columns=4) # section is attribute name for table to use e.g., symptoms section= section_name...
true
105826f88c83aca91c64c8daecaa90a7aefd6f9d
Ruby
cmu-is-projects/quizzing
/app/models/year_team.rb
UTF-8
2,594
3.28125
3
[]
no_license
#written based on YearQuizzer #TODO: test this whole thing; do not use until tested class YearTeam def initialize(team, quiz_year=QuizYear.new) @year = quiz_year @team = team @name = team.name @results = get_results_for_each_quiz_this_year # i.e., event_teams for this year @division = team...
true
b9c6e363cb66a74b1105c5e59068a9b04b285939
Ruby
timurb/sidekiq-failover-test
/lib/validate.rb
UTF-8
217
3.25
3
[ "MIT" ]
permissive
checkins = Hash.new(0) File.readlines('checkins.txt').each do |line| checkins[line.to_i] += 1 end (1..10000).each do |n| val = checkins[n] puts "#{n}: #{val}" if val != 1 end puts "Total: #{checkins.count}"
true
cf4196bf8b88369a96dd0164902a43a9b00b567c
Ruby
255BITS/wtf-is
/1-gitflow/example.rb
UTF-8
182
2.8125
3
[ "Apache-2.0" ]
permissive
require 'sinatra' get '/:year' do answer = "NO" year = params[:year] answer = "YES" if year.to_i <= Time.now.year """<h1>Is It #{year} yet?</h1> <h2>#{answer}</h2>""" end
true
7a6372a6ef0abcf24c44c9799cff68fd70dc506f
Ruby
itsolutionscorp/AutoStyle-Clustering
/assignments/ruby/combine_anagrams/src/19426.rb
UTF-8
306
3.203125
3
[]
no_license
def combine_anagrams(words) g = {} words.each do |w| sample = w.downcase.chars.sort { |a, b| a.casecmp(b) }.join g.has_key?(sample) ? ((g[sample] << w)) : (g[sample] = [w]) end gr = [] g.each do |k, v| subgr = [] v.each { |w| (subgr << w) } (gr << subgr) end return gr end
true
d8a3bc47d306275842f90f791117fb2056c47891
Ruby
tiimgreen/tabbit
/lib/tabbit.rb
UTF-8
2,295
3.609375
4
[ "MIT" ]
permissive
require 'toc' class Tabbit attr_reader :table # When Tabbit.new is called, takes a undefined amount of headers to add # to the table. # Table initialized as an Array def initialize(*headers) @table = [[]] headers.each { |h| @table[0].push h } end # Adds line to @table in form of Array def ad...
true
3794802c4781d46a41059bf50bd802e047418eb5
Ruby
chexton/aws
/awis-query-ruby/urlinfo.rb
UTF-8
1,165
2.6875
3
[]
no_license
#/usr/bin/ruby require "cgi" require "base64" require "openssl" require "digest/sha1" require "uri" require "net/https" require "rexml/document" require "time" ACCESS_KEY_ID = "AKIAJHGZRLLGTY3RSO6A" SECRET_ACCESS_KEY = "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" action = "UrlInfo" responseGroup = "TrafficData" url = ...
true
d09606b050695a9adcc21283fe503ca01c5eb2c6
Ruby
mezohe/cll
/scripts/xml_preprocess.rb
UTF-8
19,161
2.890625
3
[]
no_license
require 'nokogiri' require 'yaml' require 'byebug' mydir=File.expand_path(File.dirname(__FILE__)) require "#{mydir}/util.rb" #************************************************** # FUNCTIONS #************************************************** # Splits a node's text up by words into table columns # # The reason this ge...
true
8e6cd8433fb2daa76e1c860181783b42eb676560
Ruby
dosmode/Sinatra-Website-Practice
/app.rb
UTF-8
3,147
2.65625
3
[]
no_license
require "sinatra" require_relative "authentication.rb" require "stripe" set :publishable_key, "pk_test_xDS9v0c1IEmvkHsdji07ge8M" set :secret_key, "sk_test_c1cGu9GOwWXSqlKrxtNYTNWv" Stripe.api_key = settings.secret_key # need install dm-sqlite-adapter # if on heroku, use Postgres database # if not use sqli...
true
e7c911773b6062ccdac94d13e7ce9d72edb1b695
Ruby
ClaudeJardin/Pre-course-Exercises
/Chapter07/exercise07_1.rb
UTF-8
696
3.921875
4
[]
no_license
#“99 Bottles of Beer on the Wall....” #Write a program that prints out the lyrics to that beloved classic, #that field-trip favorite: “99 Bottles of Beer on the Wall.” i = 99 while i >= 2 puts i.to_s + ' bottles of beer on the wall, ' + i.to_s + ' bottles of beer.' puts 'Take one down and pass it around, ...
true
4be27f13960d859b3d1600f6ed0da9d8612ff45c
Ruby
kevalwell/seussscore
/parse.rb
UTF-8
403
2.953125
3
[]
no_license
require 'csv' # require 'pry' module Parse def self.dictionary(file) dictionary_hash = {} CSV.foreach(file, headers: true, header_converters: :symbol, col_sep: " ") do |row| dictionary_hash[row[:word]] = row[:pronunciation] end dictionary_hash end end # f = File.open('abridged_dictionary.tx...
true
fbbc92ef60043fbffdec0940fde9bc0edced156c
Ruby
julienemo/thp-w6-eventbrite
/app/models/event.rb
UTF-8
987
2.53125
3
[]
no_license
class Event < ApplicationRecord validates :location, presence: true validates :title, presence: true, length: {in: 5..140} validates :description, presence: true, length:{in:20..1000} validates :price, inclusion:{in:0..1000} validate :duration_be_positive_and_multiple_of_5 validate :cant_start_in_the_past ...
true
317cfb6b16fd0af9ad1c894c645a548f2aa85f2c
Ruby
seanmsmith23/sonder
/spec/helper_methods.rb
UTF-8
1,402
2.78125
3
[]
no_license
require_relative "object_creation_methods" def sign_in(user) visit '/sessions/new' fill_in "user[email]", with: user.email fill_in "user[password]", with: "1" click_button "Sign In" end def create_user_and_memorial user = create_user memorial = create_memorial create_membership(user, memorial) sign_...
true
8b17a1b86c612a6c6a11345b367484a85e94debf
Ruby
jamiepg1/alephant-publisher
/lib/alephant/publisher/views.rb
UTF-8
477
2.71875
3
[ "MIT" ]
permissive
module Alephant module Publisher module Views @@views = {} def self.register(klass) @@views[underscorify(klass.name.split('::').last)] = klass end def self.get_registered_class(id) @@views[id] end def self.underscorify(str) str.gsub(/::/, '/'). ...
true
6c797e71e76461694607089792d470bc6ff69ff3
Ruby
LubyRuffy/utility-belt
/lib/cipher_suites.rb
UTF-8
456
3.015625
3
[]
no_license
require_relative 'cipher_constants' class CipherSuites def initialize(data) @data = data end def supported_ciphers list = [] @data.scan(/..../).each do |cipher_id| name = CIPHER_MAP[cipher_id.hex] name = "UNKNOWN (0x" + cipher_id + ")" if name.nil? list << name end return l...
true
a5859c68420aebd598dcf65023053419186f7c0d
Ruby
kelleysislander/victoria_test_deploy
/app/models/map.rb
UTF-8
14,409
2.625
3
[]
no_license
class Map # a virtual model used as a container for the SQL and search logic include ActionView::Helpers::TextHelper # for "pluralize" include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :retailer_name, :retailer_addr, :retailer_category_id, :adverti...
true
5c32f63aca8360975495048a1bba9e34b7935b4e
Ruby
lucanioi/exercism-ruby
/binary-search-tree/binary_search_tree.rb
UTF-8
583
3.5625
4
[]
no_license
class Bst def initialize(data) @data = data end attr_reader :left, :right, :data def insert(new_data) new_data <= data ? insert_left(new_data) : insert_right(new_data) end def each(&blk) return to_enum unless block_given? tap do left.each(&blk) if left blk.call(data) ri...
true
936ea17abab80a74e28c7843148850adbf7c32cb
Ruby
masahino/mruby-lsp-client
/examples/example.rb
UTF-8
149
3.109375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Hoge def aaaa(n) if n == 1 puts "hoge" else puts "huga" end end end h = Hoge.new puts("test") clas
true
46288cc63daac1d55b9b04dd3717a4246bab940d
Ruby
johnmiller/CommandPattern
/ruby/lib/robot.rb
UTF-8
341
3.046875
3
[]
no_license
class Robot attr_accessor :position, :direction def initialize(position, direction) @position = position @direction = direction @commands_executed = [] end def execute_instruction(command) command.execute @commands_executed << command end def reset @commands_executed.reverse_each{|x| x.und...
true
2d6a5db1484b297c90fe00782d38b73d86ce1fd5
Ruby
werebus/moretticamp
/config/initializers/date_time_formats.rb
UTF-8
479
2.53125
3
[ "MIT" ]
permissive
# frozen_string_literal: true Time::DATE_FORMATS[:ics] = ->(time) { time.utc.strftime '%Y%m%dT%H%M%SZ' } Date::DATE_FORMATS[:unix] = ->(date) { date.to_time(:local).to_i } Date::DATE_FORMATS[:short_ordinal] = lambda { |date| day_format = ActiveSupport::Inflector.ordinalize(date.day) date.strftime "%b #{day_format...
true
54e534452e97c2dfd34c2dbe3545f49956faa621
Ruby
paulstefanort/play_analyzer
/spec/lib/analyzer_spec.rb
UTF-8
2,432
2.84375
3
[]
no_license
require 'rails_helper' require 'analyzer' describe Analyzer do it 'should load an XML file' do file_name = 'all_well.xml' file_path = File.expand_path('../../../data', __FILE__) analyzer = Analyzer.new(file: open("#{file_path}/#{file_name}")) expect(analyzer.file).to be_a(Nokogiri::XML::Document) e...
true
9621aff2dab2604de2b33b97914e7c3ace7ceb5c
Ruby
nachi412/mjai-silica
/silica.rb
UTF-8
8,762
2.546875
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- require 'pai.rb' require 'protocol.rb' require 'util.rb' require 'use_mjai_component.rb' require 'tehai.rb' require 'score.rb' require 'yama.rb' require 'furiten_checker.rb' require 'dojun_checker.rb' require 'pai_count.rb' require 'yakuhai.rb' require 'dora.rb' require 'silica_stats.rb' requir...
true
cf9940f4ebec40a0e0cfadb54cb01a37c992e188
Ruby
ratzan/post-bootcamp-challenges
/01-Ruby/03-Iterators-Blocks/03-Burger-restaurant/spec/interface_spec.rb
UTF-8
2,155
2.90625
3
[]
no_license
require 'open3' require 'interface_helper' require 'interface' locals = @variables describe "interface.rb" do before(:all) do Open3.popen2('ruby ./lib/interface.rb') do |i, o, th| @result = o.read end end describe "bigger_burger" do before(:all) do @burger = ["bread", "FISH", "mayo", "s...
true
4a6b2f071b86aa45e5891c34cf34e11803882acd
Ruby
barbs89/Hola-Aloha-app
/db/seeds.rb
UTF-8
561
2.546875
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
21c75c7f66078a7be3f13e72ce5fa51671dc8aa5
Ruby
bjjb/loveos-chunky_bacon
/lib/loveos/chunky_bacon/client.rb
UTF-8
644
2.609375
3
[ "MIT" ]
permissive
require 'open-uri' module LoveOS module ChunkyBacon # A silly client. A real client would do more interesting things (and also # handle errors, and whatnot). class Client attr_accessor :host, :port, :last_response def initialize(options = {}) @host = options[:host] || "localhost" # wo...
true
c21b3631a9b6cedf4d8655605cb4366887c79714
Ruby
marcolivier0930/dji
/lib/dji/scraper.rb
UTF-8
574
2.921875
3
[ "MIT" ]
permissive
# did not need to require any gem since it's all called in the environment.rb require_relative 'devices.rb' class Scraper def self.scrape doc = Nokogiri::HTML(open("https://store.dji.com/")) doc.css('.index__section-item___1aGxi').each do |info| hash = { # the co...
true
063ab8c20e8cb22d06be8aaec2e1a7ac2301816d
Ruby
GilbertMiao/cc169
/chap2_linked_lists/list_sum.rb
UTF-8
671
3.640625
4
[]
no_license
require_relative 'linked_list' require 'pry' def list_sum(l1, l2) max_length = l1.length > l2.length ? l1.length : l2.length sum = 0 l1_head = l1.head l2_head = l2.head (1..max_length).each do |i| # binding.pry if l1_head&.val.nil? sum += l2_head.val * (10 ** i) elsif l2_head&.val.nil? ...
true
3d9a545d9565fc88c32b0d798917fb304b72dbeb
Ruby
trizen/sidef
/scripts/RosettaCode/reverse_a_string.sf
UTF-8
153
3.265625
3
[ "Artistic-2.0" ]
permissive
#!/usr/bin/ruby # ## http://rosettacode.org/wiki/Reverse_a_string # say "asdf".reverse; # fdsa say "résumé niño".reverse; # oñin émusér
true
b11377e9ce83d7b93e0016276bf491bc561976c3
Ruby
bbryant7/ruby-exercises
/count_in_list.rb
UTF-8
948
4.3125
4
[]
no_license
# Method name: count_in_list(list, item_to_count) # Inputs: 1. a list of anything, 2. an item for us to count in the list # Returns: The number of times our item is contained in the input list # Prints: Nothing # # For example, # count_in_list([1,2,3], 1) == 1 # count_in_list([1,2,3], -1) == 0 # co...
true
c1d9932cd01f121d799a3f3cbba55c6a4111d724
Ruby
stellard/unite
/spec/lookup/simple_unit_spec.rb
UTF-8
1,311
2.546875
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- require 'spec_helper' require 'unite/lookup/simple_unit.rb' module Unite describe SimpleUnit do it { should ensure_inclusion_of(:dimension).in_array(Dimension::LIST) } it { should validate_presence_of(:si_factor)} it { should validate_presence_of(:dimension)} %w{ $ £ € m }...
true
fbe2f3cfcb22ae612a038abab3596e4986999516
Ruby
ketwalters/unbeatable_tic_tac_toe
/ruby/human.rb
UTF-8
379
3.25
3
[]
no_license
require_relative 'ui' class Human def get_human_spot(board, mark) spot = User_Interface.new.pick_spot if spot.between?(0,8) && board[spot] != "X" && board[spot] != "O" board[spot] = mark else if spot < 0 || spot > 8 puts "Invalid number. Please choose a number from 0 - 8" g...
true
67d3ab22602a85b10a8d60ccf98889f827bf9b64
Ruby
Okeibunor/ruby-coderbyte-solutions
/challenge5.rb
UTF-8
194
3.28125
3
[]
no_license
def Division(num1,num2) factors1 = [] factors2 = [] (1..num1).each { |x| factors1 << x if num1 % x == 0 } (1..num2).each { |x| factors2 << x if num2 % x == 0 } (factors1 & factors2).max end
true
f159ec2217d82a9132dcb2ae3316fdbad0e36b23
Ruby
saurookadook/sinatra-nested-forms-lab-superheros-v-000
/app/models/team.rb
UTF-8
140
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Team attr_accessor :name, :motto def initialize(info_hash) @name = info_hash[:name] @motto = info_hash[:motto] end end
true
d1a668800fd369b0c99c423ad8a9e8290bb06c32
Ruby
katymccloskey/phase-0-tracks
/ruby/gps2_2.rb
UTF-8
1,963
4.25
4
[]
no_license
# Method to create a list # input: string of items separated by spaces (example: "carrots apples cereal pizza") # steps: # [fill in any steps here] # set default quantity # print the list to the console [can you use one of your other methods here?] # output: [what data type goes here, array or hash?] def create_...
true
c758e4a12154912f2c512589263fa4a902a96ece
Ruby
jeffdeville/sherlock_homes
/lib/sherlock_homes/mapper/zillow.rb
UTF-8
1,084
2.5625
3
[]
no_license
module SherlockHomes class Mapper::Zillow < Mapper def self.map(raw_property) mapper = new(raw_property) mapper.map_basic_info mapper.map_estimate # TODO invoke methods to map other groups of data mapper.property end def map_basic_info property.property_type = raw_pro...
true
1259a1da56144aee0514861f2d74ad2c40a3117f
Ruby
rok/IKS
/create.rb
UTF-8
505
2.546875
3
[]
no_license
print "Title: " title = gets.chomp print "Tag: " tag = gets.chomp print "Location: " location = gets.chomp time = Time.now.strftime("%d %B %Y") post = "#{Time.now.strftime("%Y-%m-%d")} #{title.downcase}".gsub(/ /,'-') file = "_posts/#{post}.textile" File.open(file,"w") do |f| f.write <<EOF --- layout: post title: #{tit...
true
af1c2795be4f1160f9a8b0326dea296663a21902
Ruby
b0gok/thinknetica-ruby-basics
/lesson6/route.rb
UTF-8
1,629
3.296875
3
[]
no_license
# frozen_string_literal: true require_relative 'instance_counter.rb' require_relative 'validation.rb' # Маршрут # Имеет начальную и конечную станцию, а также список промежуточных станций. Начальная и конечная станции указываютсся при создании маршрута, а промежуточные могут добавляться между ними. # Может добавлять п...
true
4bf4080d54dd5acbcab9c5da3cfa9d053c085650
Ruby
wasamasa/aoc
/2015/21.rb
UTF-8
6,710
3.75
4
[ "Unlicense" ]
permissive
require_relative 'util' # --- Day 21: RPG Simulator 20XX --- # Little Henry Case got a new video game for Christmas. It's an RPG, # and he's stuck on a boss. He needs to know what equipment to buy at # the shop. He hands you the controller. # In this game, the player (you) and the enemy (the boss) take turns # attac...
true
272400116d22f0f7c282ab1c9f7bfd46a2b5c2c7
Ruby
pachacamac/kasten
/examples/desktop_annotations.rb
UTF-8
1,826
2.828125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # This example uses the Kasten Gem and several Unix tools to allow you to # interactively draw colored, annotated areas on (a copy of) your XFCE desktop wallpaper. # It utilizes: # - zenity for interactive dialog boxes and the color picker # - xfconf to get and set your XFCE desktop wallpaper # - x...
true
a137a66810d720913d28b809ee00f1006b8f05d9
Ruby
emanon001/atcoder-ruby
/abc007/c/main.rb
UTF-8
635
2.625
3
[]
no_license
R, C = gets.split.map(&:to_i) sy, sx = gets.split.map { |n| n.to_i - 1 } gy, gx = gets.split.map { |n| n.to_i - 1 } board = R.times.map { gets.chomp.chars } dy = [-1, 0, 1, 0] dx = [0, 1, 0, -1] visited = Array.new(R) { Array.new(C, false) } visited[sy][sx] = true queue = [[sy, sx, 0]] while !queue.empty? i, j, c = ...
true
6f2bf6e987b60083930a0701a0d0bfc923719904
Ruby
JoeStanton/baseline-agent
/lib/string_helpers.rb
UTF-8
106
2.640625
3
[]
no_license
class StringHelpers def self.slugify(str) str.downcase.gsub(/[^a-z1-9]+/, '-').chomp('-') end end
true
a85928fdb784681094f4e084ee7b3de600006bb6
Ruby
KeithHanson/opal-screeps
/ruby/threat_assessor.rb
UTF-8
243
2.78125
3
[]
no_license
class ThreatAssessor def self.assess(room) Debug.debug "ThreatAssessor assessing threat level for #{room.name}..." level = 0 Debug.debug "ThreatAssessment: #{level}" return level # dumb 100 point scale right now end end
true
648a7edb121c063fa1025a8f3dab69978e475765
Ruby
ianchesal/babbler
/lib/babbler.rb
UTF-8
1,036
3.09375
3
[ "MIT" ]
permissive
require "babbler/version" require "babbler/words" module Babbler class << self def babble(seed = nil) prng = Random.new(seed || Random.new_seed) adjectives = [] Babbler.config.num_adjectives.times do adjectives.push(ADJECTIVES[prng.rand(ADJECTIVES.length)]) end noun = N...
true
a619b639a0365aba2cf4491b829856cbfaf2dc73
Ruby
ivanbrennan/vim-splice
/spec/support/tmux.rb
UTF-8
950
2.625
3
[]
no_license
module Tmux def spawn_new_session(session_name) sidestep_nested_restriction do run_silent_command("new-session -d -s #{session_name}") end end def spawn_new_session!(session_name) ensure_tmux_present spawned = spawn_new_session(session_name) raise SpawnSessionError unless spawned end ...
true
99dae796c6c8d704ffb7bb466c1cb31f262e0ed4
Ruby
switch-ch/well_rested
/lib/well_rested/utils.rb
UTF-8
674
2.8125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'generic_utils' module WellRested module Utils extend GenericUtils extend self # Turn any nested resources back into hashes before sending them def objects_to_attributes(obj) if obj.respond_to?(:attributes_for_api) obj.attributes_for_api elsif obj.kind_of?(Hash) n...
true
8994e4fd9b27e00d01eb8ca25076cf44cf057770
Ruby
alaibe/bank_holidays
/app/helpers/bank_holidays_helper.rb
UTF-8
267
2.796875
3
[]
no_license
module BankHolidaysHelper def parenthesis(name_in_country) return if name_in_country.empty? " (#{name_in_country})" end def to_sentence(countries) countries.map do |country| "#{country.name} (#{country.iso})" end.to_sentence end end
true
459b6883f4d6c6f86e271cfb783bf6cf46df0c71
Ruby
BillMux/codewars
/rb/sudoku/lib/sudoku_done_or_not.rb
UTF-8
631
3.453125
3
[]
no_license
def sudoku_is_valid(grid) valid?(grid) && valid?(grid.transpose) && valid?(squares(grid)) end def valid?(grid) grid.each do |arr| return false if arr.uniq != arr || arr.sum != 45 || arr.any? { |x| x > 9 } end true end def squares(grid) squares, i, j = [], 0, 0 while i < grid.length while j < grid[...
true
09a685b8f441296ced42e853eb43209e9a307151
Ruby
WhitehawkVentures/split
/lib/split/alternative.rb
UTF-8
15,489
2.6875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'split/zscore' require 'active_support/all' require 'simple-random' # TODO - take out require and implement using file paths? module Split class Alternative attr_accessor :name attr_accessor :experiment_name attr_accessor :weight include Zscore def initialize(name, experiment_name) ...
true
ba6dbeb9338f4ccaba13879cf7b4b7ce11d0cbab
Ruby
dvimont/ruby-objects-has-many-through-lab-cb-000
/lib/patient.rb
UTF-8
316
3.1875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Patient attr_reader :name, :appointments def initialize(name) @name = name @appointments = Array.new end def add_appointment(appointment) appointment.patient = self @appointments << appointment end def doctors() return self.appointments.collect{|appt| appt.doctor} end end
true
e15e15a9fe8c21f2278587890c446c403c6343a6
Ruby
grassynull0/Introduction_to_Programming
/flow_control/exercise_1.rb
UTF-8
422
3.640625
4
[]
no_license
## Write down whether the following expressions return true or false. # Then type the expressions into irb to see the results. # 1. (32 * 4) >= 129 # 2. false != !true # 3. true == 4 # 4. false == (847 == '847') # 5. (!true || (!(100 / 5) == 20) || ((328 / 4) == 82)) || false ## # 1. is false LS had false # 2. is fal...
true
b7f543f9c60df303a03225779554819a550caa5f
Ruby
Emmanuelcole2017/ruby-collaborating-objects-lab-online-web-ft-112618
/lib/artist.rb
UTF-8
784
3.484375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist attr_accessor :name, :songs @@all = [] def initialize(name = "") @name = name @songs = [] instance = self @@all << instance end def add_song(song) @songs << song end def songs @songs end def save instance = self @@all << instance end def self.all ...
true
4e231d5e35c0e5d08e608a233c7b8755391cb9e7
Ruby
NJCA88/W1D5
/skeleton/lib/KnightPathFinder.rb
UTF-8
1,014
3.390625
3
[]
no_license
require_relative "00_tree_node" class KnightPathFinder attr_accessor :added_moves, :move_tree def initialize(pos) @added_moves = [pos] @move_tree = PolyTreeNode.new(pos) build_move_tree(@move_tree) end def build_move_tree(node) return nil if node.nil? self.find_moves(node.value).each do |...
true
d3242265da882efdadc139e63b81a21663851272
Ruby
antonr/calculator
/spec/lib/calculator_spec.rb
UTF-8
277
2.6875
3
[]
no_license
require 'calculator' describe Calculator do it "adds numbers" do expect(subject.add(2, 3)).to eq(5) end it "subtracts numbers" do expect(subject.subtract(2, 3)).to eq(-1) end it "multiplies numbers" do expect(subject.multiply(2, 3)).to eq(6) end end
true
86873272e589231015306749c5b04d0556ff5090
Ruby
yuqiqian/ruby-leetcode
/62_uniq_path.rb
UTF-8
170
2.765625
3
[]
no_license
def unique_paths(m, n) result = 1 total = m+n-2 chosen = ([m,n].min)-1 total.downto(total-chosen+1){|i| result *= i} 0.upto(chosen-1){|i| result /= i+1} result end
true
0a32c5c1d1e691b1440d4b6d3ae8686577a91a2c
Ruby
masterzora/tawny-cdk
/examples/entry_ex.rb
UTF-8
2,185
3.28125
3
[ "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
#!/usr/bin/env ruby require_relative 'example' class EntryExample < Example def EntryExample.parse_opts(opts, param) opts.banner = 'Usage: dialog_ex.rb [options]' param.x_value = CDK::CENTER param.y_value = CDK::CENTER param.box = true param.shadow = false super(opts, param) end # This ...
true