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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bf0bf09bfe14f069e8ce9ab53d5c0e22b2016292 | Ruby | shivapbhusal/vulnerability_analysis | /map/prettify/process_codes.rb | UTF-8 | 480 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env ruby
# country codes:
# http://en.wikipedia.org/wiki/ISO_3166-1
require 'rubygems'
require 'nokogiri'
require 'csv'
filename = ARGV[0]
header = ["name","2code","3code","numeric","iso"]
rows = []
f = File.open(filename)
doc = Nokogiri::HTML(f)
f.close
doc.css('tr').each do |tr|
row = []
tr.css('td'... | true |
fbf17a8c9233da6a28818cbc25f696054e0e553f | Ruby | travisariggs/RubyExercises | /Lesson2/super.rb | UTF-8 | 346 | 3.71875 | 4 | [] | no_license | class Parent
def something(a='Hello')
puts a
end
end
class Child < Parent
# alias_method :parent_method, :method
def something
super 'Goodbye'
end
# def other_method
# parent_method
# #OR
# Parent.instance_method(:method).bind(self).call
# end
end
p = Parent.new
p.something
puts
... | true |
0a588b922649265ed697f7eca0bd3100cf4bfaad | Ruby | inasacu/thepista | /httparty/ruby/1.9.1/gems/geokit-1.8.4/lib/geokit/bounds.rb | UTF-8 | 3,342 | 3.484375 | 3 | [
"MIT"
] | permissive | module Geokit
# Bounds represents a rectangular bounds, defined by the SW and NE corners
class Bounds
# sw and ne are LatLng objects
attr_accessor :sw, :ne
# provide sw and ne to instantiate a new Bounds instance
def initialize(sw,ne)
raise ArgumentError if !(sw.is_a?(Geokit::LatLng) && ne.is... | true |
7827baf84cd5001bec3e7ac6be78afe18c4dbb36 | Ruby | jdelmazo9/tadp_ruby_metaprogramming | /ruby/lib/pruebilla.rb | UTF-8 | 338 | 3.140625 | 3 | [] | no_license |
class Sarasa
def metodoCualquiera instancia
a = 0
eval( lambda {"a = 11"}.call )
puts a
bloque = proc { puts a + b }
instancia.instance_exec &bloque
end
end
class ClaseCualquieraQueNoConoceAA
attr_accessor :b
def initialize
@b = 1
end
end
Sarasa.new.metodoCualquiera ClaseCualquier... | true |
39c9b5483f1d9acbb719bf135cb06cff54ce2115 | Ruby | 19WH1A0578/BVRITHYDERABAD | /CSE/Scripting Languages Lab/18WH1A0580/program4.rb | UTF-8 | 375 | 2.921875 | 3 | [] | no_license | #comment
#file = "/Desktop/sl/prog3.rb"
puts "Enter file name"
file = gets.chomp
#file name
fbname = File.basename file
puts "file name: " +fbname
#base name
bname = File.basename file,".rb"
puts "Base name: " + bname
#file extention
fextn = File.extname file
puts "Extension:" +fextn
#path name
pa... | true |
09cfaa864d173a091ac1b3341dce0753c9810224 | Ruby | techtrailhead/metanorma-standoc | /lib/liquid/custom_blocks/key_iterator.rb | UTF-8 | 550 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | module Liquid
module CustomBlocks
class KeyIterator < Block
def initialize(tag_name, markup, tokens)
super
@context_name, @var_name = markup.split(',').map(&:strip)
end
def render(context)
res = ''
iterator = context[@context_name].is_a?(Hash) ? context[@context_... | true |
c0b6df567e9aa274248bd0255b918a4634ca4724 | Ruby | aequitas/puppet-profile-parser | /catalog-analyzer.rb | UTF-8 | 2,773 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'json'
require 'terminal-table'
require 'colored'
require 'set'
class Catalog
attr_reader :name, :environment, :version
def initialize(hash)
@data = hash['data']
@metadata = hash['metadata']
@name = @data['name']
@version = @data['version']
@environment = @data['... | true |
ae520b630fb4cfdd476100fa5a0836d3cab9688d | Ruby | RobPando/connect_four | /lib/connect_four.rb | UTF-8 | 2,425 | 3.890625 | 4 | [] | no_license | class ConnectFour
attr_accessor :playe1, :player2, :board
def initialize(player1, player2)
@players = [player1, player2]
@turn = 0
@board = [Array.new(7), Array.new(7), Array.new(7), Array.new(7), Array.new(7), Array.new(7)]
end
def show_board
@board.reverse.each { |row| print "#{row}" + "\n" }#Array is ... | true |
2c61b27ca33fb8af520627c60294aa48c87321e0 | Ruby | github2play/Acadgild | /Module4/ques2.rb | UTF-8 | 659 | 4.21875 | 4 | [] | no_license | # Write a program that takes a number from the user between 0 and 100 and reports back whether the number is between 0 and 50, 50 and 100, or above 100.
def check(num)
if(num<0)then
puts"You have entered an Invalid Number...\nPlease any positive Number between 0 to 100"
check(gets.to_i)
else
case
... | true |
1be5632abc0717e41b318d854d9a77264ab25113 | Ruby | Katy600/student-directory | /directory.rb | UTF-8 | 5,949 | 3.953125 | 4 | [] | no_license |
#We are de-facto using CSV format to store data.
#However, Ruby includes a library to work with the CSV files that we could use instead of working directly with the files.
#Refactor the code to use this library.
require 'csv'
@students = []
def print_menu
puts "1. Input the students"
puts "2. Show the studen... | true |
3e1ba105a20b5799a7dbae24df17b04c601ca0ab | Ruby | hspitzer2/badges-and-schedules-online-web-prework | /conference_badges.rb | UTF-8 | 532 | 3.515625 | 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(array)
badges = []
array.each do |name|
badges.push( "Hello, my name is #{name}." )
end
badges
end
def assign_rooms(array)
room_assignments = []
array.each_with_index do |name, index|
room_assignments.push("Hello, #{nam... | true |
690c39e31385e0de70c2a51eb6d7cd936534887a | Ruby | kjdchapman/advent-of-code-2019 | /lib/day-2/run_intcode.rb | UTF-8 | 818 | 3.375 | 3 | [] | no_license | class RunIntcode
def initialize(convert_intcode_string:, interpret_instruction:)
@convert_intcode_string = convert_intcode_string
@interpret_instruction = interpret_instruction
end
def execute(input)
instructions = @convert_intcode_string.execute(input)
instructions.each_slice(4) do |slice|
... | true |
41a3f43d345acc9a4cf3e8de43f91b7f5c911bb8 | Ruby | Sokre95/simple_server_log_analyzer | /server_log_analyzer/evaluator.rb | UTF-8 | 252 | 2.546875 | 3 | [] | no_license | module ServerLogAnalyzer
class Evaluator
def initialize(storage:)
@storage = storage
end
def evaluate(proc = nil, &block)
return proc.call(@storage) if proc
return block.call(@storage) if block
end
end
end
| true |
a83ed3d0e013d3abff66b13af1233abbfc400b2b | Ruby | buchheimt/marvel_101 | /lib/marvel_101/character.rb | UTF-8 | 942 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative 'topic'
class Marvel101::Character < Marvel101::Topic
attr_accessor :list, :team, :details
DETAIL_ORDER = [:real_name, :height, :weight, :abilities, :powers,
:group_affiliations, :first_appearance, :origin]
def display
display_description
display_details
display_... | true |
4bcda33d2efe5889e18118a40f891e295a772e60 | Ruby | edelhaye/Ruby_Training | /Session1/classes.rb | UTF-8 | 378 | 3.390625 | 3 | [] | no_license | class Car
def initialize
puts "creating a new car"
end
def set_make(make)
@make = make
end
def set_model(model)
@model = model
end
def description
@make + " " + @model
end
end
audi = Car.new
audi.set_make("Audi")
audi.set_model("A1")
puts audi.description
vw = Car.new
vw.set_mak... | true |
25f40cdef40b9401b34f98cf82fb498925e2d5c8 | Ruby | nealdeters/pre-coursework | /todo.rb | UTF-8 | 850 | 4.625 | 5 | [] | no_license | #Create a program that asks a user to enter
#four different words, one at a time. Then,
#the computer will ask the user to choose a
#number between 1 and 4. The computer will
#then display the word corresponding to the
#correct number. For example, assume the user
#typed in the words: ghost, umbrella, candy,
#and... | true |
12b455347975ebc02fba768056acb897c152f905 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/whelper_source/23165.rb | UTF-8 | 378 | 3.328125 | 3 | [] | no_license | def combine_anagrams(words)
temp = words
p = Array.new
h = Hash.new
temp.each { |word| h = makeHash(h, word) }
h.values.each { |ary| p.push(ary) }
return p
end
def makeHash(h, word)
seq = word.downcase.scan(/\w/).sort.join
if h.has_key?(seq) then
h[seq] = h[seq].push(word)
else
h[seq] = Array... | true |
93f75099ed461dd1dd645cfb23d7213321fd0bc9 | Ruby | DanielEFrampton/backend_module_0_capstone | /day_7/alt_caesar_cipher.rb | UTF-8 | 3,650 | 4.25 | 4 | [] | no_license | # An alternate version of CaesarCipher with an interactive console interface.
# Class to contain encoding method
class CaesarCipher
# Declare instance variables to contain non-encoded user input and shift value
attr_accessor :non_encoded_input, :shift_value
# Define intialization method, declare instance variab... | true |
76bf767c05fa751929ba4c760f720835a1e3d9b9 | Ruby | IFTTT/polo | /lib/polo/translator.rb | UTF-8 | 2,298 | 2.6875 | 3 | [
"MIT"
] | permissive | require "polo/sql_translator"
require "polo/configuration"
module Polo
class Translator
# Public: Creates a new Polo::Collector
#
# selects - An array of SELECT queries
#
def initialize(selects, configuration=Configuration.new)
@selects = selects
@configuration = configuration
en... | true |
beca59a288451f08237534a2935e8ba3a2327745 | Ruby | sbackus/calculating-pi | /leibniz.rb | UTF-8 | 386 | 3.34375 | 3 | [] | no_license | # Take the infinite series of all the odd fractions
# alternate adding and subtracting them
# the sum is equal to pi over 4
# 1/1 - 1/3 + 1/5 - 1/7 + 1/9... = pi/4
sum = 0
start = 1
finish = 1000000
by = 2
plus_or_minus = 1
for n in start.step(finish,by)
sum += 1.0/n * plus_or_minus
plus_or_minus *= -1
end
put... | true |
168c6c07467189ad52c0ef0abbc3068e4692d27d | Ruby | jaymccoy300/blocipedia | /db/seeds.rb | UTF-8 | 758 | 2.53125 | 3 | [] | no_license | require 'random_data'
5.times do
User.create!(
email: RandomData.random_email,
password: 'standardpassword',
standard: true,
premium: false,
admin: false
)
end
4.times do
User.create!(
email: RandomData.random_email,
password: 'premiumpassword',
standard: false,
premium: true... | true |
5e72339d5bd3c390d971f97719c4cf92ebfb6759 | Ruby | vcraescu/eyecare | /lib/eyecare/audio.rb | UTF-8 | 731 | 2.671875 | 3 | [
"MIT"
] | permissive | module Eyecare
# Audio
class Audio
attr_accessor :filename
attr_accessor :player
DEFAULT_PLAYER = 'aplay :file'
def initialize(filename, player = nil)
@filename = filename
@player = player ? player : DEFAULT_PLAYER
end
def play
return unless player
pid = spawn(play... | true |
814a641ffabcfb3d279b5cecb8eb325f2890ff71 | Ruby | pkayokay/ruby-notes | /challenges/random_color.rb | UTF-8 | 148 | 3.34375 | 3 | [] | no_license | class Ghost
attr_accessor :color
def initialize
@color = ["Yellow","Red","Blue","Green"].sample
end
end
ghost = Ghost.new
puts ghost.color | true |
ff7ac2cc9bc8896d479be866c29ab582aea1e21e | Ruby | lwoodson/ispeech | /lib/ispeech.rb | UTF-8 | 1,151 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'uri'
require 'net/http'
require 'ostruct'
module ISpeech
URL_ENCODED_ENDPOINT = 'http://api.ispeech.org/api/rest'
def self.parameterize(hash)
hash.inject(""){|str,tuple| str << "&#{tuple[0].to_s}=#{tuple[1].to_s.gsub(/\s/, '+')}"}[1..-1]
end
def self.decode_param_string(pstring)
map = {}
... | true |
ea8ce407b1e7481133157d98d23d6e034df9ffbc | Ruby | lifepillar/RubyBackupBouncer | /copiers/dd_rescue.rb | UTF-8 | 1,260 | 2.53125 | 3 | [
"MIT"
] | permissive | =begin
Clones a volume using dd_rescue.
dd_rescue (http://www.garloff.de/kurt/linux/ddrescue/) is modeled
after dd but optimized for copying data from possible damaged disks to
your system.
This task unmounts the source and target volumes, then runs
sudo dd_rescue <source device> <target device>
then remounts the v... | true |
835840d91de96b4f4fa2536edebd8839931e2b88 | Ruby | readyready15728/codewars-ruby-solutions | /7-kyu/square-every-digit.rb | UTF-8 | 97 | 3.125 | 3 | [] | no_license | def square_digits(num)
num.to_s.chars.map { |c| c.to_i ** 2 }.map { |n| n.to_s }.join.to_i
end
| true |
f5e388c0effcb8649afc6aeabce868e988af1e16 | Ruby | SPrio/competitive-coding-practice | /code4.rb | UTF-8 | 1,094 | 4.0625 | 4 | [] | no_license | # Task
#
# Your task is to print an array of the first N palindromic prime numbers.
# For example, the first 10 palindromic prime numbers are .
#
# Input Format
#
# A single line of input containing the integer N.
#
# Constraints
#
# You are not given how big N is.
#
# Output Format
#
# Print an array of... | true |
9030c4061cd1dca23b809907a611c0d0f0f5a3dc | Ruby | class-snct-rikitakelab/Understanding-Computation | /program/statement_script.rb | UTF-8 | 8,888 | 3.890625 | 4 | [] | no_license | #
# 前回の続き
#
require "./expression_script.rb"
#
# 文(statement)という違う種類のプログラムの構成を作る。
#
# 式は、ある式から新しい式を生成する。
# 一方、文は仮想計算機の状態を変える。
# この仮想計算機の持つ状態は環境だけだから、式で新しい環境を作って置き換える事ができるようにする。
#
# もっとも簡単な文は、なにもしないもので、簡約不能、そして環境にあらゆる影響を与えられないものである。
# これは簡単に作れる。
#
# 他のすべての構文クラスはstructクラスを継承しているが、DoNothingクラスは何も継承して... | true |
dea25245097d66294e27a337256baf832ca7db2d | Ruby | Freshly/law | /lib/law/judgement.rb | UTF-8 | 1,544 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# A **Judgement** determines if an **Actor** (represented by their **Roles**) are in violation of the given **Statute**.
module Law
class Judgement < Spicerack::RootObject
class << self
def judge!(petition)
new(petition).judge!
end
def judge(petition)
... | true |
eb49653560827e8a3794e2f03dad4fe4603798b5 | Ruby | wilson-penagos-admios/rubyTest | /reverser.rb | UTF-8 | 666 | 3.59375 | 4 | [] | no_license | class Reverser
def initialize(objectString)
raise unless objectString.is_a?(String)
@x = objectString
end
def original
@x
end
def reverse_odds
baseString = String.new(@x)
stringLength = baseString.length
# Avoiding one odd char strings
if stringLength < 4
return baseString... | true |
8084c12276e75a48c76e148f831556b893387d30 | Ruby | kentaroi/gmaps-rails | /lib/gmaps/js.rb | UTF-8 | 1,760 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'active_support/core_ext/string/output_safety'
class GMaps
class JS
class << self
def [](*args)
self.new(*args)
end
end
def initialize(str, *args)
@str = if args.empty?
str
elsif args.length == 1 && args.first.is_a?(Hash)
escap... | true |
82d61825f36674db1a007a14dff51c06b5231c25 | Ruby | catedm/launch-school-130-ruby-foundations-more-topics | /ls_challenges/easy_1/sum_of_multiples.rb | UTF-8 | 675 | 4.3125 | 4 | [] | no_license | # input: number
# output: number
# rules:
# => find sum of all multiples of particular numbers up to but not including the given num
# => write program that can find sum of multiples of a given set of numbers
# => if no set of numbers is given, default to 3 and 5
# => class method
# algorithm:
# => sum = []
# => 0.upt... | true |
4bbe080a30e80b09b332d107b94a70bcb531ceb7 | Ruby | prognostikos/cb2 | /spec/strategies/rolling_window_spec.rb | UTF-8 | 2,003 | 2.546875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe CB2::RollingWindow do
let(:breaker) do
CB2::Breaker.new(
strategy: :rolling_window,
duration: 60,
threshold: 5,
reenable_after: 600)
end
let(:strategy) { breaker.strategy }
describe "#open?" do
it "starts closed" do
refute strategy.open?
... | true |
94a9ebef4fbde9b7f8606f132eb44347147dd270 | Ruby | jmoglesby/uabootcamp-challenges | /linked_list/linked_list_2.rb | UTF-8 | 1,591 | 3.921875 | 4 | [] | no_license | class LinkedListNode
attr_accessor :value, :next_node
def initialize value, next_node=nil
@value = value
@next_node = next_node
end
end
def print_values list_node
if list_node
print "#{list_node.value} --> "
print_values list_node.next_node
else
print "nil\n"
return
end
end
def re... | true |
e57e983993b09eab9d717be97cdd62a8097bc7e3 | Ruby | sitepress/sitepress | /sitepress-rails/lib/sitepress/models/collection.rb | UTF-8 | 826 | 3.203125 | 3 | [
"MIT"
] | permissive | module Sitepress
module Models
# Everything needed to iterate over a set of resources from a glob and wrap
# them in a model so they are returned as a sensible enumerable.
class Collection
include Enumerable
# Page models will have `PageModel.all` method defined by default.
DEFAULT_NAME... | true |
c88f02fb7fb5f31cd2232ae3cefc9f71ba3f52a7 | Ruby | sicXnull/cryptoplace | /scripts/pixelize.rb | UTF-8 | 858 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'chunky_png'
require 'color'
colors = ['ffffff', 'e4e4e4', '888888', '222222', 'ffa7d1', 'e50000', 'e59500', 'a06a42', 'e5d900', '94e044', '02be01', '00d3dd', '0083c7', '0000ea', 'cf6ee4', '820080']
colors = colors.map { |color| "##{color}".match(/#(..)(..)(..)/) }.map { |a| Color::RGB.new... | true |
103c70f5bef8d6010eb45d2b2ea30fa9a77a10b4 | Ruby | krbrewer/advent-of-code-2020 | /day9/part1.rb | UTF-8 | 373 | 2.953125 | 3 | [] | no_license | file_data = File.read("day9.txt").split("\n")
n = 25
x = nil
for i in 0..file_data.length - n - 1
options = []
for j in i..i + n - 2
for k in i + 1..i + n - 1
options.push(file_data[j].to_i + file_data[k].to_i)
end
end
if !options.include?(file_data[i + n].to_i)
x... | true |
7f4dc0ad485e72beae68a944c2a21aaf3c1d0950 | Ruby | dorton/Samfundet | /app/models/standard_hour.rb | UTF-8 | 857 | 2.65625 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: standard_hours
#
# id :integer not null, primary key
# open_time :time
# close_time :time
# area_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# day :string(255)
#
class StandardHour < ActiveRecord:... | true |
03483659f5cc3d44c895880b435bf83edc77c35c | Ruby | tiffnuugen/sinatra-views-lab-dumbo-web-082718 | /app.rb | UTF-8 | 345 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class App < Sinatra::Base
get '/' do
erb :index
end
get '/hello' do
erb :hello
end
get '/goodbye' do
@name = "Joe"
erb :goodbye
end
get '/date' do
@weekday = Date.today.strftime("%A")
@month = Date.today.strftime("%B")
@day = Time.now.asctime.split(" ")[2]
@year = Time.now.asctime.split(" ")[... | true |
439d02f40a34d8887f363e0eba11c2b20ff8cde5 | Ruby | jeik0210/testing | /example.rb | UTF-8 | 447 | 2.953125 | 3 | [] | no_license | require 'minitest/spec'
require 'minitest/autorun'
describe 'MyTestSuit' do
before do
@array = []
end
it "adds 2 + 2 " do
(2 + 2).must_equal 4
end
it "includes a dog" do
%w(dog cat elephant).must_include 'dog'
end
it "is instance of fixnum" do
(2 + 2).must_be_instance_of Fixnum
end
it "must be ni... | true |
695d51051d54f513256ecb01b58df2d113c420f2 | Ruby | chweeks/takeaway-challenge | /spec/menu_spec.rb | UTF-8 | 546 | 2.703125 | 3 | [] | no_license | require 'menu'
describe Menu do
let(:dish) {double :dish, show_details: 'Coke: £1'}
it { is_expected.to respond_to :dishes }
describe '#add_dish' do
it { is_expected.to respond_to :add_dish }
it 'should add dish to menu' do
subject.add_dish(dish)
expect(subject.dishes.first).to eql dish
... | true |
ba2ad7d20a64d3d123892c0a355ff1e6e708a27a | Ruby | catherineemond/challenges | /leet-code/dynamic_programming/longest_subsequence.rb | UTF-8 | 841 | 4.0625 | 4 | [] | no_license | # Given an unsorted array of integers, find the length of longest increasing subsequence.
#
# Example:
#
# Input: [10,9,2,5,3,7,101,18]
# Output: 4
# Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.
#
# Note:
#
# There may be more than one LIS combination, it is only necessar... | true |
826b7033fee5d63af9c9ce1a0316aa7442359ae1 | Ruby | STRd6/strd6 | /hero_squad/app/models/game.rb | UTF-8 | 2,448 | 2.9375 | 3 | [] | no_license | class Game < ActiveRecord::Base
has_many :entries, :class_name => 'GameEntry'
has_many :players, :through => :entries, :order => 'position'
has_many :cards
has_many :character_instances
belongs_to :active_player, :class_name => 'Player'
belongs_to :active_character, :class_name => 'CharacterInstance'
... | true |
c86522846cf1f75852c4bdee97e5251ff9eea9a0 | Ruby | osgood1024/ruby-oo-object-relationships-has-many-lab-nyc-web-012720 | /lib/author.rb | UTF-8 | 406 | 3.171875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Author
attr_accessor :name
def initialize (name)
@name=name
@posts=[]
end
def posts
Post.all
end
def add_post (post)
@posts << self
post.author=self
end
def add_post_by_title (title)
post=Post.new(title)
add... | true |
46e8eb5b383a995c605847d5e053453ceb97faf4 | Ruby | softecspa/puppetlabs-mysql | /lib/puppet/parser/functions/mysql_hashruntime.rb | UTF-8 | 950 | 2.859375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | module Puppet::Parser::Functions
newfunction(:mysql_hashruntime, :type => :rvalue, :doc => <<-EOS
TEMPORARY FUNCTION: EXPIRES 2014-03-10
When given a hash this function strips out all blank entries.
EOS
) do |args|
input_hash = args[0]
allowed = args[1]
unless input_hash.is_a?(Hash)
raise(Puppet:... | true |
4229609206834e7a27c38d9d71234aaf18e56584 | Ruby | supersquashman/character-generator | /Resources/Lists/ClassList.rb | UTF-8 | 1,505 | 2.640625 | 3 | [] | no_license | # ClassList - Manager of D&D Classes[ClassModel]
# Copyright (C) 2011 Cody Garrett, Josh Murphy, and Matt Ingram
# This file is part of FishTornado D&D Character Generator.
# FishTornado D&D Character Generator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Publ... | true |
6687cb4ae05f12569eea764f123bb673720f4f5d | Ruby | capral/home | /home6/station2.rb | UTF-8 | 1,951 | 3.59375 | 4 | [] | no_license | class Station
attr_reader :name, :list
@@all_stations = []
def self.all_stations
@@all_stations
end
def initialize (name)
@name = name
@list = []
validate!
@@all_stations << self
end
def anything_station(&block)
@list.each{ |train| block.call(train) }
end
def add_list... | true |
fff8dfb8329cc43847aff1e717a5ad6f8495fefb | Ruby | CodeHaven9ja/binlist | /lib/binlist.rb | UTF-8 | 322 | 2.6875 | 3 | [
"MIT"
] | permissive | require "binlist/version"
require "httparty"
module Binlist
include HTTParty
base_uri "https://lookup.binlist.net"
# This is called to find a Bin
# @params bin [string]
# @return [Net::HTTPResponse] A subclass of Net::HTTPResponse, e.g. Net::HTTPOK
def self.find(bin)
get("/#{bin}", verify: false)
end
en... | true |
a89c06774c4d80020efd6545f0ae61207aa60d2d | Ruby | manuelbouvierpiz/ILoveBanana | /Defi.rb | UTF-8 | 2,681 | 2.984375 | 3 | [] | no_license | # Valentin CHAILLOU
# Defi.rb
# Implémentation de la classe Defi
# == Classe Defi :
# - connaît son envoyeur, son destinataire, sa Grille
# - sait relever un défi, supprimer un défi, donne le score de l'envoyeur
class Defi
# Variables d'instance
# * Variable d'instance (un <b>String</b>) qui représente le pseudo... | true |
1735ed59df55f31dd2f2a05b1d19ff4ab97fd465 | Ruby | danilobarion1986/desafio_vagas | /spec/talk_spec.rb | UTF-8 | 1,177 | 3.171875 | 3 | [] | no_license | require_relative './spec_helper.rb'
describe Talk do
before :all do
@title = "Title of talk lightning"
@long_title = "Long title 45min"
@talk = Talk.new @title
@long_talk = Talk.new @long_title
end
describe "#new" do
it "return a new Talk object" do
#@talk.should be_an_instance_of Talk # =>... | true |
26f550c6ddd0f5b43d81ebd164fbb055b53000a8 | Ruby | kitwalker12/ruby-interview | /min_stack.rb | UTF-8 | 530 | 4.15625 | 4 | [] | no_license | # Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
class MinStack
attr_accessor :vals, :min
def initialize
@vals = []
@min = []
end
def push(x)
if min.empty? || x <= self.get_min()
min.push(x)
end
vals.push(x)
end
def pop
if ... | true |
e0824fb79392783983f004816cd21b00a9ba19fb | Ruby | Agsiegert/Meeting_rooms | /spec/meeting_rooms_spec.rb | UTF-8 | 3,579 | 3.515625 | 4 | [] | no_license | require 'meeting_room'
RSpec.describe 'Meeting Rooms' do
context 'initialized with known constraints'do
room1 = MeetingRoom.new('Room 1')
room2 = MeetingRoom.new('Room 2')
it 'a room1 has a name Room 1:' do
expect(room1.name).to eq('Room 1')
end
it 'a room2 has a name Room 2:' do
expe... | true |
114b83bab2d553f8f5698c06b50f0c144b14fde4 | Ruby | developer88/Blitz-rake-task | /lib/tasks/blitz.rake | UTF-8 | 1,725 | 2.546875 | 3 | [] | no_license | require 'rubygems'
require 'blitz'
require 'pp'
URL_PRODUCTION = "http://production_somesite.com" # Default production URL
URL = "https://stage_or_development_url.com" # Default url
DLM0 = "====================================================="
DLM1 = "\n-----------------------------------------------------\n "
name... | true |
324f146c0c72999125a9b98b5ca38e50be53cc5d | Ruby | Rubeasts/gitget | /lib/gitget/github_repository.rb | UTF-8 | 1,698 | 2.859375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Github
# Main class to set up a Github User
class Repository
attr_reader :id, :name, :full_name, :is_private, :is_fork, :created_at,
:updated_at, :pushed_at, :size, :stargazers_count,
:watchers_count, :has_issues, :has_downloads, :forks_coun... | true |
22a6a0079b5edd7a61e2e22ba5bea25081d4bbf4 | Ruby | RomanADavis/challenges | /advent/2017/day8/solutions/part2.rb | UTF-8 | 510 | 3.4375 | 3 | [] | no_license | # --- Part Two ---
#
# To be safe, the CPU also needs to know the highest value held in any register
# during this process so that it can decide how much memory to allocate to these
# operations
require_relative "part1.rb"
class Computer
attr_accessor :max
def solve
self.max = 0
self.lines.each do |line|
... | true |
ee3b83686a8fadf0c3c3dd4cc6a24cbefbc514ef | Ruby | sumkincpp/CodeTest | /ruby/basics.rb | UTF-8 | 1,242 | 3.609375 | 4 | [] | no_license |
################################################
#
# Check if array includes Range
#
################################################
['w', '-', 12].grep('a'..'z') # => ["w"]
[ 4 , :a, '^'].grep('a'..'z') # => []
['w', '-', 'e'].grep('a'..'z') # => ["w", "e"]
# Here is a modified code of your using #grep :
ary = ['... | true |
bd2cfc8b3220abe7164cc12609db0969ef38689f | Ruby | rshiva/MyDocuments | /10-book-case/ruby1.9/samples/refcio_4.rb | UTF-8 | 647 | 2.53125 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
7a3506426d471a4f16163cde36c0a6544887fd91 | Ruby | ybasabe/rspec-fizzbuzz-ruby-intro-000 | /fizzbuzz.rb | UTF-8 | 171 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | Don't forget! This file needs to be 'required' in its spec file
# See README.md for instructions on how to do this
def fizzbuzz(int)
if int % 3 == log10
"Fizz"
end
end | true |
d98e85242c6ea3f3260c0f4e5bc538eca575dfcc | Ruby | PureMVC/puremvc-ruby-standard-framework | /src/org/puremvc/ruby/patterns/mediator/mediator.rb | UTF-8 | 1,001 | 2.59375 | 3 | [] | no_license | class Mediator < Notifier
# The name of the Mediator
# Typically, a Mediator will be written to serve one specific control or group
# controls and so,will not have a need to be dynamically named.
attr_reader :name
attr_accessor :view
def initialize(name="Mediator", view=nil )
@name = name
@vie... | true |
926d6e5c83de82568a01b6d6c12b38461fc58a3a | Ruby | spookyorange/top_projects | /binary_search_tree/bst.rb | UTF-8 | 4,752 | 3.34375 | 3 | [] | no_license | class Node
include Comparable
attr_accessor :right, :left, :root
def initialize(root = nil, left = nil, right = nil)
@root = root
@left = left
@right = right
end
def put
puts @root
end
end
class Tree
attr_reader :array
def initialize(array)
@array = array.uniq.sort
end
def r... | true |
72c5dfea2699ba99f7b565e056fe05eb6b28c72c | Ruby | knthompson2/backend_mod_1_prework | /section2/exercises/ex2.rb | UTF-8 | 1,471 | 4.3125 | 4 | [] | no_license | people = 30
cars = 40
trucks = 15
#analyzing if cars is greater than 30; follwoign that, commands for the computer to return.
#In this case, cars is greater than 30, so it will return : "we should take the cars."
if cars > 30
puts "We should take the cars."
elsif cars < people
puts "We should not take the cars."
... | true |
854353b6ca8716e1bef14dbc2224b1a9d3d62fa2 | Ruby | emrancub/Basic-Ruby-Programming-Practice | /chapter_3.1/comparitions_expressions.rb | UTF-8 | 555 | 4.0625 | 4 | [] | no_license | # age = 10
# puts "You are teenager" if age >=12 && age <=20
# puts "You're Not teenager" unless age >= 12 && age <= 20
# age = 23
# puts "You're 24!" if age == 24
# age = 2
# puts "You're either very young or very old" if age >= 80 || age <= 10
gender = "male"
age = 87
puts "A very young or old man" if gender == "m... | true |
2a723ff730528cbd80b3b66193d4780ad40fa454 | Ruby | srycyk/mine | /lib/mine/fetch/http/build_uri.rb | UTF-8 | 1,903 | 2.625 | 3 | [
"MIT"
] | permissive |
require "mine/fetch/http/url_to_uri"
module Mine
module Fetch
module Http
class BuildUri < Struct.new(:url)
include UrlToUri
TYPES = %i(params)
attr_accessor :address
def initialize(*)
super
self.address = uri
end
def call
... | true |
8095b2c4f3cd9bc8499b6823dab91e8576357199 | Ruby | jenko/query_engine | /test_datasetfunction.rb | UTF-8 | 2,989 | 2.53125 | 3 | [] | no_license | require 'test/unit'
require './dataset.rb'
require './datasetfunction.rb'
class TestDataset < Test::Unit::TestCase
def test_pct_move_2_insts
ds_sig = Datasetfunction.make_signature("PCT_MOVE", "F.SP.CLOSE", "F.SP.CLOSE", "-3", "1")
assert_equal([["F.SP.CLOSE","F.SP.CLOSE"], "{|d,v,i|100*(@ds1[i+1]-@ds0[i+-3])/@d... | true |
20f29321d538189aa3a904525774988ff93ade25 | Ruby | MondoGao/oo-student-scraper-cb-gh-000 | /lib/scraper.rb | UTF-8 | 987 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
require 'nokogiri'
class Scraper
def self.scrape_index_page(index_url)
students = []
index_folder = index_url.split(/index\.html/)[0]
doc = Nokogiri::HTML(open(index_url))
doc.css(".student-card").each do |card|
students << {
name: card.css(".student-na... | true |
85aabc936d8ead8104cd70db10ea01e4467dc056 | Ruby | ferocia/snek | /client/random_snake.rb | UTF-8 | 1,724 | 3.609375 | 4 | [] | no_license | class RandomSnake
def initialize(our_snake, game_state, map)
# Game state is an hash with the following structure
# {
# alive_snakes: [{snake}],
# leaderboard: []
# }
# Each snake is made up of the following:
# {
# id: id,
# name: name,
# head: {x: <int>, y: <int>,
... | true |
71b1a2b29ae230e31de38aed9dd4c3071794086d | Ruby | zhangruochi/Codewars | /Switch_it_Up.rb | UTF-8 | 841 | 4.21875 | 4 | [] | no_license | #!/usr/bin/env ruby
#info
#-name : zhangruochi
#-email : zrc720@gmail.com
=begin
When provided with a number between 0-9, return it in words.
Input :: 1
Output :: "One".
Try using "Switch" statements.
This kata is meant for beginners. Rank and upvote to bring it out of beta
=end
def switch_it_up(number)
... | true |
4d84dab90fc7704452575dba81cf26fcc68516ab | Ruby | vishalsanfran/ruby-algo | /graph/prim_maze_gen.rb | UTF-8 | 2,001 | 3.515625 | 4 | [] | no_license | class Maze
def initialize(rows, cols, wall="|", path="-")
@brd = Array.new(rows){Array.new(cols){wall}}
@path = path
end
def get_moves(row, col)
r_offs = [-1, 1, 0, 0]
c_offs = [0, 0, 1, -1]
moves = r_offs.each_with_index.map{|off, idx| [off + row, c_offs[idx] + col]}
moves.select{|move| ... | true |
044dafb2484f543c628765bff157c74862731133 | Ruby | SergioETrillo/code_wars | /Ruby/5kyu/firstnprimes.rb | UTF-8 | 198 | 3.640625 | 4 | [] | no_license | # TODO implement a Primes class with a class method first(n)
# that returns an array of the first n prime numbers.
require 'prime'
class Primes
def first(n)
Prime.first n
end
end | true |
4d43720972a564cf704df984a1126ab3d87deca9 | Ruby | Andreas-AS/W2D2 | /pieces/king.rb | UTF-8 | 192 | 2.578125 | 3 | [] | no_license | class King < Piece
include Steppable
KING_DIFS = [[0,1], [0,-1], [1, 1], [1,-1], [1,0], [-1, 0], [-1, 1], [-1,-1]]
def moves
unblocked_moves(pos, KING_DIFS)
end
end | true |
28b0f024d94a7c63808413ae2a861e1935365c98 | Ruby | arifikhsan/hello-ruby | /loop/range.rb | UTF-8 | 397 | 3.34375 | 3 | [] | no_license | (1..3).each do
puts 'range each 1 to 3'
end
(1..3).each do |i|
puts "range each, index: #{i}"
end
(1..3).map do
puts 'range map 1 to 3'
end
(1..3).map do |i|
puts "range map, index: #{i}"
end
(1..3).each { puts 'range each oneline' }
(1..3).each { |i| puts "range each oneline, i: #{i}" }
(1..3).map { puts... | true |
d6e200c46149d25347ae242e2f396416775450cc | Ruby | jessicajyeh/sp18-hw2 | /app/controllers/concerns/person.rb | UTF-8 | 353 | 3.734375 | 4 | [] | no_license | class Person
attr_accessor :name, :age, :nickname
def initialize(name, age)
@name = name
@age = age
@nickname = name[0,4]
end
def nickname
@nickname
end
def birth_year
year = (Time.now.year).to_i
@age = (age).to_i
year - @age - 1
end
def introduction
"I'm #{name} and ... | true |
b8656681ba25fecb3a6b5317597243ebfee13240 | Ruby | educabilia/ohm-identity_map | /test/identity_map_test.rb | UTF-8 | 2,048 | 2.75 | 3 | [
"Unlicense"
] | permissive | require_relative "prelude"
class Post < Ohm::Model
attribute :title
end
class Comment < Ohm::Model
attribute :body
reference :post, :Post
end
scope do
setup do
post = Post.create(title: "How to create an Identity Map in Ruby")
Comment.create(post_id: post.id, body: "Great article!")
Comment.cre... | true |
334ddb20966e353e99536cab4b5ceebca2a27477 | Ruby | dylankb/sprinter | /main.rb | UTF-8 | 5,081 | 2.625 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
require 'sinatra/reloader' if development?
require "tilt/erubis"
require 'date'
require 'csv'
use Rack::Session::Cookie, :key => 'rack.session',
:path => '/',
:secret => 'barmaged0n'
SPRINT_DAYS = 14.0
MINUTES_IN_HOUR = 60
hel... | true |
4292ecb94e50c4c92684249a9fdd7c179eac1e8f | Ruby | everypolitician-scrapers/mongolia-khurai-wp-multiple-terms | /lib/term_page.rb | UTF-8 | 737 | 2.625 | 3 | [] | no_license | require_relative 'constituency_member_table'
require_relative 'party_list_member_table'
require 'scraped'
class TermPage < Scraped::HTML
field :members do
constituency_members + party_list_members
end
field :constituency_members do
ConstituencyMemberTable.new(noko: constituency_member_table, response: r... | true |
ba361e071c5125fc94cdcdb95f0c559f3c3196a9 | Ruby | susiirwin/acquire_a_hire | /app/models/conversation.rb | UTF-8 | 370 | 2.71875 | 3 | [] | no_license | class Conversation
def initialize(raw_conversation, user_id)
@job_id = raw_conversation[0]
@sender_id = raw_conversation[1]
@recipient_id = raw_conversation[2]
@user_id = user_id
end
def job
Job.find(@job_id)
end
def with
if @user_id == @sender_id
User.find(@recipient_id)
e... | true |
1fb55d80b6f7cf0930b1578be1646817fc33dd82 | Ruby | elyrly/pickpocket | /config/config.rb | UTF-8 | 364 | 2.96875 | 3 | [] | no_license | class Config
def initialize(file_path)
@file_path = file_path
@config = JSON.parse(File.read(file_path))
end
def [](key)
@config[key.downcase]
end
def []=(key, value)
@config[key.downcase] = value
save
value
end
protected
def save
File.open(@file_path, 'w') do |f|
... | true |
f93678da28d67509dfb1494e53582c2071b618ff | Ruby | zeitschlag/adventofcode | /2019/01/first_day.rb | UTF-8 | 526 | 3.734375 | 4 | [] | no_license | def calculate_fuel(module_mass)
module_fuel = (module_mass.to_f/3).floor - 2
return module_fuel
end
def calculate_total_fuel(mass)
fuel = calculate_fuel(mass)
additional_fuel = calculate_fuel(fuel)
while additional_fuel >= 0 do
fuel += additional_fuel
additional_fuel = calculate_fuel(additional_fuel... | true |
2659c1787bd5c8a5b836d6124e92850fd1dd9a29 | Ruby | jnn-natsumi/Ruby | /problem/d11-30.rb | UTF-8 | 120 | 3.390625 | 3 | [] | no_license | # D013:割り算
x, y = gets.split(" ").map!{|i| i.to_i}
ans1 = x / y
ans2 = x % y
print ans1
print " "
print ans2
| true |
557e1e20a1349156d6113b3300db07e92ed652a7 | Ruby | sotayamashita/cal_exporter | /lib/cal_exporter/exporter.rb | UTF-8 | 1,104 | 2.640625 | 3 | [
"MIT"
] | permissive | require "yaml"
module CalExporter
class Exporter
def initialize(format, save_location)
@format = format
@save_location = save_location
end
def to_jekyll(event)
output_list = {
"title" => event.summary.gsub(/[|]|:/, '[' => '(', ']' => ')', ':' => ':'),
"loc... | true |
c1eee0367fa175b9e1d75c1d5b3d6d4b10e578c0 | Ruby | ro31337/math-apps | /app-addition.rb | UTF-8 | 3,103 | 3.75 | 4 | [] | no_license | class Addition
INFINITY = 1.to_f / 0
attr_reader :a, :b
def initialize
@a = @b = INFINITY
end
def regenerate
loop do
@a = rand(0..10)
@b = rand(0..10)
break if @a + @b <= 10
end
end
end
class Subtraction
attr_reader :a, :b
def regenerate
loop do
@a = rand(0..1... | true |
9adb5a6a6aa2b7b03e78ec30a4c9d7e9dc5b9afd | Ruby | gisikw/wemote | /lib/wemote/switch.rb | UTF-8 | 4,376 | 3.234375 | 3 | [
"MIT"
] | permissive | require 'socket'
require 'ipaddr'
require 'timeout'
require 'ssdp'
module Wemote
# This class encapsulates an individual Wemo Switch. It provides methods for
# getting and setting the switch's state, as well as a {#toggle!} method for
# convenience. Finally, it provides the {#poll} method, which accepts a block... | true |
8007342a4b8a9ad5a36e6b0c48dc955ff5fc5884 | Ruby | jplao/module_3_diagnostic | /app/models/station.rb | UTF-8 | 479 | 3 | 3 | [] | no_license | class Station
attr_reader :name,
:address,
:access_times,
:distance
def initialize(data)
@name = data['station_name']
@address = data['street_address']
@distance = data['distance']
@fuel_types = data['fuel_type_code']
@access_times = data['access_days_t... | true |
699e3a42f39dc000afc2d44ce6f81944e75a6bdb | Ruby | CristianCvc/arraysg49 | /filtro_procesos.rb | UTF-8 | 445 | 3.109375 | 3 | [] | no_license | num_mayor = ARGV[0].to_i
def read_file(filename)
original_data = open(filename).readlines
lines = original_data.count
array =[]
lines.times do |i|
array<<original_data[i].to_i
end
return array
end
datos = read_file("procesos.data")
filtrado = datos.select { |data| data > num_mayor}
outp... | true |
5b3d0f34927f4b0a37037b49703bdc319d7f8a91 | Ruby | JasonGL123/my-dcoder-solutions | /Easy/tracys_love.rb | UTF-8 | 97 | 3.03125 | 3 | [] | no_license | puts (n = gets.chomp.split().map(&:to_i)).inject(:+) == 6 || n.max - n.min == 6 ? "Love" : "Hate" | true |
908dbd7422dbb9df1fa20a9c10384cad6f780e0f | Ruby | krismacfarlane/godot | /w09/d05/instructor/pig_latin/lib/word.rb | UTF-8 | 88 | 2.6875 | 3 | [] | no_license | class Word
def initialize(original_word)
@original_word = original_word
end
end
| true |
55d5021c37ad95a75b7938f24e844fcb275cc446 | Ruby | Yates101/design_strategies_1 | /spec/remembering_names_spec.rb | UTF-8 | 172 | 2.734375 | 3 | [] | no_license | require "remembering_names.rb"
describe "the add_name method" do
it "appeases our terrible memory" do
expect(add_name("Alice")).to eq "Person remembered!"
end
end
| true |
6da7055504bb46bdb4c895a363f623301d575037 | Ruby | Josh-Gotro/ruby-enumerables-generalized-map-and-reduce-lab-austin-web-030920 | /lib/my_code.rb | UTF-8 | 1,367 | 3.359375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry' #binding.pry
def map(source_array)
i = 0
new = []
while i < source_array.length
new << yield(source_array[i])
i += 1
end
new
end
def reduce(array, sv=nil)
if sv
sum = sv
i = 0
else
sum = array[0]
i = 1
end
while i < array.length
sum = yi... | true |
b4790bc5388357c0a765ff67f549ee22ce471c79 | Ruby | markmcspadden/ruby-in-a-can | /compare.rb | UTF-8 | 3,455 | 3.140625 | 3 | [] | no_license | # We can now track the ruby as it gets fed into the compiler
SCRIPT_LINES__ = {}
# Setup file_path variable
file_path = nil
# Default to only one benchmark
n = 1
# Requried: a file path at the end of the ARGVs
# Optional: -n : number of benchmarks to us
ARGV.each_with_index do |a, idx|
if a.to_s == "-n"
n =... | true |
253fb22fdd00bdf0563e37aab72a332f17b9d539 | Ruby | Lorjuo/tgt | /lib/tasks/importer/messages_importer.rb | UTF-8 | 1,769 | 2.859375 | 3 | [] | no_license | # rails c
# Message.all.each{|message| message.destroy}
# TODO: import creation date
module MessagesImporter
# see for caching: http://stackoverflow.com/questions/6934415/prevent-rails-from-caching-results-of-activerecord-query
# import messages
def import_messages
puts "Importing messages..."
use_old_... | true |
30eed9000d209ea26e48097f576722953b764f82 | Ruby | JaniceYR/002_aA | /W2D3/poker/spec/hand_spec.rb | UTF-8 | 1,125 | 3.46875 | 3 | [] | no_license | require 'rspec'
require 'hand'
require 'deck'
describe Hand do
let(:four_of_a_kind) { [Card.new(1, "S"), Card.new(1, "C"), Card.new(1, "H"),
Card.new(1, "D"), Card.new(5, "S")]}
subject(:hand) { Hand.new(four_of_a_kind) }
describe "#initialize" do
it 'creates a card instance variab... | true |
a0725340dc3551410dbe07c1596844345dcdd2c8 | Ruby | adelapie/cryptopals | /05/36.rb | UTF-8 | 3,486 | 2.640625 | 3 | [
"Unlicense"
] | permissive | require_relative '../util'
ROLE = ENV['ROLE'] || 'C'
C = '/tmp/cryptopals-36-C'.freeze
S = '/tmp/cryptopals-36-S'.freeze
NIST_PRIME = 0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb... | true |
59bfdcad38434365442b741f4c29353c8b1fac96 | Ruby | liftiuminc/dashboard | /test/unit/event_recorder_test.rb | UTF-8 | 6,336 | 2.625 | 3 | [] | no_license | require 'test_helper'
class EventRecorderTest < ActiveSupport::TestCase
context "class methods" do
setup do
@event_array = ['Ad Delivered', 'AdBrite', 'US']
now = Time.parse("2009/12/01 20:30")
Time.stubs(:now).returns(now)
end
context "#serialize_key" do
should "build the key ba... | true |
6c72d2877e98509e235fc9d2ca84e7098d6a0aa4 | Ruby | kalebpomeroy/godtear | /dice.rb | UTF-8 | 157 | 3.265625 | 3 | [] | no_license | # This is the die roll thingy
DIE = [0, 0, 1, 1, 1, 2]
def roll dice
results = []
dice.times { results << DIE.sample }
results.inject(0, :+)
end
| true |
04d4d02b10ae81968165ebd0e961c4849ba47136 | Ruby | Overby/mastermind_redux | /guess.rb | UTF-8 | 1,205 | 3.53125 | 4 | [] | no_license | require './gameplay' #was './game'
#require './messages'
def start_guessing
puts Messages.call[:play]
loop do
input = gets.chomp.downcase
if input == 'q' || input =='quit'
puts "Thanks for playing!"
return
elsif input.chars.count < 4
puts "That is too short. Try again."
... | true |
46fdbc18c995a9c5f515a9496a32f4554498cc60 | Ruby | kcierzan/phase-0 | /week-6/bingo_solution.rb | UTF-8 | 6,077 | 4.40625 | 4 | [
"MIT"
] | permissive | # A Nested Array to Model a Bingo Board SOLO CHALLENGE
# I spent [2.5] hours on this challenge.
# Release 0: Pseudocode
# Outline: Create an instance of BingoBoard that
# Create a method to generate a letter ( b, i, n, g, o) and a number (1-100)
#Create a list with b, i, n, g, and o.
#Create a random number bet... | true |
146e1a0e9fd6682ce32bcf3972f7a93ceb9722e0 | Ruby | tapena/w02 | /diamond_refactoring/diamond_refactoring_exercise.rb | UTF-8 | 6,585 | 4.15625 | 4 | [
"MIT"
] | permissive | # Diamond Refactoring
# Initial Solution
def diamond_printer(word)
message = word.split("")
array = []
characters_list = {
"A" => 1,
"B" => 2,
"C" => 3,
"D" => 4,
"E" => 5,
"F" => ... | true |
e33c0ecaebda223e3629d28d0ae99c32040f80fe | Ruby | jmuldvp/ltc-ruby | /9/concat.rb | UTF-8 | 229 | 3.671875 | 4 | [] | no_license | p [1, 2, 3] + [4, 5]
p [1, 2, 3].concat([4, 5])
puts
nums = [1, 2, 3]
nums.concat([4, 5, 6])
p nums
puts
a = [1, 2, 3]
b = [4, 5, 6]
def custom_concat(arr1, arr2)
arr2.each { |e| arr1 << e }
arr1
end
p custom_concat(a, b)
| true |
b372fd58cbef4d4696c20f3680985464b66d5f5e | Ruby | habeshawit/ruby-collaborating-objects-lab-onl01-seng-pt-072720 | /lib/mp3_importer.rb | UTF-8 | 513 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MP3Importer
attr_accessor :artist, :song, :path
@@all = []
def initialize(path)
@path = path
end
def files
path_ = @path + "/**/*.mp3"
Dir[path_].map{ |f| File.basename(f)} #gets the file name without the file path
#Dir[path_].map{ |f| File.basename(f,".mp3... | true |
c2fb8f746930a3fc6a2c911d9e3fcf02c082fd00 | Ruby | A-Legg/class-inheritance-warmup | /spec/rectangle_spec.rb | UTF-8 | 291 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe Rectangle do
before do
@rectangle = Rectangle.new(50, 25)
end
it "should return it's area" do
@rectangle.area.should eq(1250)
end
it "should return it's perimeter" do
@rectangle.perimeter.should eq(150)
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.