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
33a5002cfdf3ba05766e89390d7991133a276325
Ruby
richardTowers/fixingVerify
/lib/pki.rb
UTF-8
752
2.53125
3
[]
no_license
require 'base64' def create_private_key(key) puts key.filename pem_path = key.path.sub(/\.pk8$/, '.pem') Dir.chdir("#{__dir__}/..") do `openssl genrsa -out '#{pem_path}' 2048` `openssl pkcs8 -topk8 -inform PEM -outform DER -in '#{pem_path}' -out '#{key.path}' -nocrypt` end end def create_certificate(...
true
1bbdeeeb577c914a73062f718af8dae9501cf2b7
Ruby
akax/akax.github.com
/newpost.rb
UTF-8
2,015
3.09375
3
[]
no_license
#!/usr/bin/env ruby # ********************************************* # Jekyll Post Generator Awesomeness # by Cody Krieger (http://codykrieger.com) # edited by Akax (http://blog.uytor.info) # ********************************************* # Usage: # % ./newpost.rb POST NAME if ARGV.empty? or ARGV[0].downcase == "--hel...
true
71b5837189c32b65ada4e539357f66faf260c72e
Ruby
marcelodanieldm/projectsAndPracticeRB
/helloname.rb
UTF-8
69
3.40625
3
[]
no_license
print "Write your name: " name = gets.chomp puts puts "Hi #{name}!"
true
fe0ef2cb0e695a6dcb99d7bdcd0756bcc06bf9ef
Ruby
fuzzySi/sonicPi
/shepardTone.rb
UTF-8
936
2.640625
3
[]
no_license
# Shephard tone tempo = 120 maxAmp = 0.5 layers = 5 use_synth :sine notes = chord:c3, :m, num_octaves: 4 len = notes.length vols = [] fade = len / 4 # proportion of loop affected by fade incr = maxAmp.to_f / fade # or # maxAmp.fdiv(fade) threads = [] for i in 0...layers threads[i] = len / layers * i # sorts ou...
true
4ced585a5f2d44783810ec3b7e858d2ae7f6a2ac
Ruby
ho-tonym/my-select-nyc-web-051418
/lib/my_select.rb
UTF-8
417
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_select(collection) if collection.length <= 0 "This block should not run!" else counter = 0 new_array = Array.new while counter < collection.length if yield(collection[counter]) == true new_array << (collection[counter]) end counter +=1 end en...
true
7e1579694792f130103b7b35d0e43373c5d8666e
Ruby
jlee-r7/raptor-io
/lib/raptor-io/support/struct2/c_struct_template.rb
UTF-8
900
2.5625
3
[ "BSD-3-Clause" ]
permissive
# -*- coding: binary -*- # RaptorIO::Support::Struct2 module RaptorIO::Support module Struct2 class CStructTemplate require 'raptor-io/support/struct2/c_struct' attr_reader :template, :template_create_restraints, :template_apply_restraint attr_writer :template, :template_create_restraints, :template_apply_r...
true
4b54cb14cb24034a814d3d85c3b9f9c5adffb6e1
Ruby
mcleary03/homework
/W3D1/plays_demo/playwright.rb
UTF-8
1,294
2.890625
3
[]
no_license
require 'sqlite3' require 'singleton' class PlaywrightDBConnection < SQLite3::Database include Singleton def initailize super('playwright.db') self.type_translation = true self.results_as_hash = true end end class Playwright attr_accessor :name, :plays def self.all data = PlaywrightDBConne...
true
d9c75ae5873669974dcaa3e3744fb468905b1b93
Ruby
KateWilkinson/takeaway-challenge
/spec/takeaway_spec.rb
UTF-8
2,169
3
3
[]
no_license
require 'takeaway' describe Takeaway do it { is_expected.to respond_to :check_menu } it { is_expected.to respond_to(:add_to_order).with(2).arguments } it 'should be initialised with a default menu' do expect(subject.menu).to eq Takeaway::MENU end describe 'check' do it 'should print out the list...
true
6c8357e9b3d261807441a58cf910816bb9f6e262
Ruby
Lean-GNU/EjerciciosRuby
/Metodos/ejercicio-metodos-retorno4.rb
UTF-8
430
4.03125
4
[]
no_license
=begin Elaborar un método que reciba tres enteros y nos retorne el valor promedio de los mismos. =end def promedio(v1, v2, v3) sum = v1 + v2 + v3 prom = sum/3 end #bloque principal print "Ingrese valor 1: " value1 = (gets.chomp).to_i print "Ingrese valor 2: " value2 = (gets.chomp).to_i print "Ingrese valor 3...
true
9adc85360d416646e5628565b5e8ed37f9eee5d4
Ruby
Ramez-/Gamification-Achievement-Platform
/Game_Tracking_System/lib/rule.rb
UTF-8
141
2.546875
3
[]
no_license
class Rule attr_accessor :metric_id,:value,:operation def initialize @metric_id = 1 @value = '32' @operation='>' end end
true
6d1ef44cec1cb0cae78729d103a6e4aeb8c5e866
Ruby
Zkalish/alchemy_cms
/lib/alchemy/mount_point.rb
UTF-8
572
2.5625
3
[ "BSD-3-Clause" ]
permissive
module Alchemy # Returns alchemys mount point in current rails app. # Pass false to not return a leading slash on empty mount point. def self.mount_point(remove_leading_slash_if_blank = true) alchemy_routes = Rails.application.routes.named_routes[:alchemy] raise "Alchemy not mounted! Please mount Alchemy...
true
70923b684e897cc835d3c64d66a9f670e38f96f5
Ruby
emomax/AdventOfCode2015
/dec12/task1/main.rb
UTF-8
1,019
3.5
4
[]
no_license
################# # Pieslicer # # 2015 # ################# ## --- Day 12: JSAbacusFramework.io --- # Santa's Accounting-Elves need help balancing # the books after a recent order. Unfortunately, # their accounting software uses a peculiar # storage format. That's where you come in. # They have a JSON...
true
0a4cece042baa98dea9adf9036d769e03a3a15cb
Ruby
Matts966/ruby_files
/1bitDemultiplexer.rb
UTF-8
457
3.28125
3
[]
no_license
def demultiplexer(i) r = {"o0" => false, "o1" => false} r["o0"] = (!i["x"] & i["s"]) |\ (i["y"] & !i["s"]) r["o1"] = (i["x"] & i["s"]) |\ (!i["y"] & !i["s"]) return r end begin print ("=====Testing demultiplexer===== \n") input = {"x" => true, "s" => false} output = {"o0" => false, "o1...
true
17c9cea35d285de5e4d51a48ed8359b2efb65bb7
Ruby
fuji-nakahara/nlp100
/src/04.rb
UTF-8
788
3.9375
4
[ "MIT" ]
permissive
# "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can." # という文を単語に分解し,1, 5, 6, 7, 8, 9, 15, 16, 19番目の単語は先頭の1文字,それ以外の単語は先頭に2文字を取り出し, # 取り出した文字列から単語の位置(先頭から何番目の単語か)への連想配列(辞書型もしくはマップ型)を作成せよ. sentence = 'Hi He Lied Because Boron Could Not Oxidize Fluorin...
true
4235af2ba7a46d24a449178979aef1f752d19f6d
Ruby
Rinbo/fizzbuzz
/lib/fizz_buzz.rb
UTF-8
419
4.40625
4
[]
no_license
def fizz_buzz(number) if number % 5 == 0 if number % 3 == 0 return "fizzbuzz" else return "buzz" end elsif number % 3 == 0 return "fizz" else return number end end while true print "Write a number: " n...
true
86752431dd7a3831851e20f0bd0c70f1233ae4a2
Ruby
Chucheen/Leaderboard
/lib/db_seed_populator.rb
UTF-8
280
2.5625
3
[]
no_license
class DbSeedPopulator def initialize(populator_class, rows) @populator = populator_class.new(rows) end def record_block @populator.record_block end def prepare @populator.try(:prepare) end end Dir["db_seed_populators/*.rb"].each {|file| require file }
true
a4d68b12fb5c855ea2fc543d67217abf41996262
Ruby
aditilonhari/wwcsf-backend-study-group
/designpatterns/src/main/ruby/designpatterns/behavioral/observer/ObserverB.rb
UTF-8
384
3.046875
3
[]
no_license
require_relative 'ObserverInterface' # Concrete Observers react to the updates issued by the Publisher they had been attached to. class ObserverB include ObserverInterface # @param [Publisher] publisher def update(publisher) return unless publisher.state.zero? || publisher.state >= 2 puts 'ObserverB: R...
true
9c34f4abc74e361f20157b13fe83a33d9fdab9b3
Ruby
Maxih/classwork
/W2D3/poker/lib/player.rb
UTF-8
1,109
3.609375
4
[]
no_license
require_relative 'hand' class Player attr_accessor :name, :pot, :hand, :fold def initialize(name, pot) @name = name @pot = pot @hand = Hand.new @fold = false end def discard_card(card) @hand.discard_card(card) end def recieve_card(card) @hand.add_card(card) end def render_ha...
true
b58ad57c195e435ef9583a887acfc2a4d8f683f5
Ruby
avrilanne/ruby
/synaps-weighin-challenge/db/seeds.rb
UTF-8
2,405
2.84375
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 rake db:seed (or created alongside the db with db:setup). # require 'csv' # participants_csv_text = File.read(Rails.root.join('lib', 'seeds', 'participants.csv')) # csv = ...
true
292ec2076ffe948803a2e73991fcf5ae534a80da
Ruby
muffatruffa/RB101-RB109-Small-Problems
/easy_8/middle_character.rb
UTF-8
727
4.21875
4
[]
no_license
# returns the middle character or characters of the argument. If the argument has an odd length, # you should return exactly one character. If the argument has an even length, # you should return exactly two characters. def center_of_bk(str) size = str.size size.even? ? str[size / 2 - 1] + str[size / 2] : str[...
true
d4ca9dbcc5377d31586d73c39a12cfb7b32a9750
Ruby
Giagnus64/OO-Art-Gallery-dumbo-web-071519
/tools/console.rb
UTF-8
616
2.875
3
[]
no_license
require_relative '../config/environment.rb' a1 = Artist.new("foo", 8) a2 = Artist.new("bar", 2) a3 = Artist.new("baz", 1) g1 = Gallery.new("alpha", "Vegas") g2 = Gallery.new("beta", "Ohio") g3 = Gallery.new("gamma", "Chicago") g4 = Gallery.new("psi", "Brklyn") g5 = Gallery.new("omega", "Nyc") p1 = Painting.new("but...
true
33ed19603d2b7ac8a1cf013c7d0ccb214834cf05
Ruby
GermanFilipp/Codebreaker
/lib/code_breaker/gamer.rb
UTF-8
806
3.078125
3
[ "MIT" ]
permissive
require 'yaml' module CodeBreaker class Gamer FILE = "./code_breaker/users_data.yaml" attr_accessor :gamers def initialize @gamers = [] end def add obj @gamers.push obj end def create_table_score @gamers.each do |f| puts "Name: #{f.name} Turns: #{f.turns}" ...
true
d79175b8b8a1b3d89d451267e10648f6f072007b
Ruby
xritqa/tst
/power.rb
UTF-8
303
3.53125
4
[]
no_license
#! /usr/bin/env ruby def power(x,y) if (y == 0) return 1 elsif (y == 1) return x else res = x end for i in 1..y-1 do res = res * x end return res end print 'power(10,0) ' puts power(10,0) print 'power(10,1) ' puts power(10,1) print 'power(10,2) ' puts power(10,2)
true
2fb9413df30c023816a500403110b5d193b35061
Ruby
maltize/nkbook
/app/models/spot.rb
UTF-8
989
2.515625
3
[]
no_license
# == Schema Information # # Table name: spots # # id :integer not null, primary key # profile_id :integer # duration :integer # position :integer # valid_from :datetime # valid_to :datetime # status :integer # created_at :datetime # updated_at :datetime # class Spot < ActiveRecord::B...
true
6c86eb1644a6a0f4c1061198120bc310f48ec2d5
Ruby
Corn-cloud/programming-univbasics-nds-nds-to-insight-understand-lab-houston-web-012720
/lib/nds_explore.rb
UTF-8
487
2.890625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'directors_database' # Call the method directors_database to retrieve the NDS def pretty_print_nds(nds) require 'pp' pp nds # Change the code below to pretty print the nds with pp nil end def print_first_directors_movie_titles index = 0 spilberg_movie...
true
8154c1c804d0535d2e59b0309d6744df5fb0755c
Ruby
rocky/rb-trepanning
/test/unit/test-proc-frame.rb
UTF-8
2,155
2.546875
3
[ "BSD-2-Clause" ]
permissive
#!/usr/bin/env ruby require 'test/unit' require_relative '../../processor' require_relative '../../processor/frame' require_relative '../../app/mock' $errors = [] $msgs = [] # Test Trepan::CmdProcessor Frame portion class TestCmdProcessorFrame < Test::Unit::TestCase def setup $errors = [] $msgs = [] ...
true
97f357737f27fa707ff25df439dddc93b3c2eab7
Ruby
givmo/couch_record
/lib/couch_record/trackable_container.rb
UTF-8
6,393
2.640625
3
[]
no_license
module CouchRecord module TrackableContainer attr_accessor :parent_record attr_accessor :parent_attr def _track_change(key = nil, value = nil) if self.is_a?(CouchRecord::Base) self.attribute_will_change_to!(key, value) else # passing nil here works because the current value mu...
true
1da338c37e673a15aa2ed526d977f6aa58f48a23
Ruby
mrphishxxx/api-snippets
/tools/snippet-testing/error_logger.rb
UTF-8
478
3.046875
3
[ "MIT" ]
permissive
require 'singleton' require 'colorize' class ErrorLogger include Singleton def initialize @errors = [] end def add_error(error) errors.push(error) end def build_failed? !errors.empty? end def print_errors puts "\n\n\n###############################################################\n"...
true
8df66fb3cadad1d8f90c11ff053e8019178cfb66
Ruby
pajkicdj/princess-krofne
/prep.rb
UTF-8
1,873
4.03125
4
[]
no_license
# FizzBuzz Assignment def fizzbuzz ii = "" for x in 1..100 if (x%3 == 0) && (x%5 == 0) ii += "FizzBuzz " elsif (x%5 == 0) ii += "Buzz " elsif (x%3 == 0) ii += "Fizz " else ii += "" end end print ii end fizzbuzz # Build A Calculator class Calculator def add(a, b) a + b end...
true
bdbd062381c8b2ca53682e616096f4a6453a11e9
Ruby
ne-ha/wage_slave
/lib/wage_slave/aba.rb
UTF-8
1,749
2.765625
3
[ "MIT" ]
permissive
module WageSlave class ABA attr_reader :descriptive_record, :details def initialize(transactions = []) @descriptive_record = WageSlave::ABA::DescriptiveRecord.new @details = WageSlave::ABA::DetailCollection.new(transactions) end ## # This method was adapted from https://github.com/...
true
a24dfd1c8b9769fa3197225913bb7ee24640b00a
Ruby
Andreautama/ElectivesLite
/Final-Project/models/category.rb
UTF-8
2,707
3.0625
3
[]
no_license
require './db/mysql_client.rb' require './models/item.rb' class Categories attr_accessor :category_name, :category_id, :item def initialize(param) @category_name = param[:category_name] @category_id = param[:category_id] @item = [] end def self.get_categories client = c...
true
da464beb3660ad9bbafb55c95a8cf5c117b7396c
Ruby
DrDhoom/RMVXA-Script-Repository
/Himeworks/Enemy Reinforcements.rb
UTF-8
7,602
3.40625
3
[ "MIT" ]
permissive
=begin #=============================================================================== Title: Enemy Reinforcements Author: Hime Date: Sep 23, 2016 -------------------------------------------------------------------------------- ** Change log Aug 31, 2016 - add_member should return the actual enemy added Sep 2...
true
2d9a8b280465ce4c657a867938658458cd8bba6e
Ruby
pureawesome/advent2016
/fourteen.rb
UTF-8
1,606
3.046875
3
[]
no_license
require 'digest' input = 'ngcjuoqr' test_input = 'abc' @sets = Hash.new(Float::INFINITY) @stretches = Hash.new(Float::INFINITY) @md5 = Digest::MD5.new def get_hexdigest(input) @sets[input] = @md5.hexdigest(input) if @sets[input] == Float::INFINITY @sets[input] end def key?(character, count, raw_input) status ...
true
1285c9ed1345e65e03478fc3c07f02cac28f848c
Ruby
n00dl3nate/Homework_week02_day_01
/Homework_exercise_1/student.rb
UTF-8
313
3.1875
3
[]
no_license
class Student attr_accessor :name, :cohort def initialize(name, cohort) @name = name @cohort = cohort end def get_name return @name end def get_cohort return @cohort end def talk() return "I can talk" end def say_favourite_language(language) return "I love #{language}" end end
true
419cddec46445fb93d3053c650ba521c575b9871
Ruby
uoysip/reglex
/lib/conversion_tests.rb
UTF-8
492
3.046875
3
[ "MIT" ]
permissive
require_relative "helper" require_relative "../src/main" @total = 0 @pass = 0 def assert(message, test) @total = @total + 1 if test then @pass = @pass + 1 puts "success: " + message else puts "failed: " + message end end @total = 0 @pass = 0 test_case = "(.(|LD)D(|LD(.DQ)))" assert("can...
true
f297660902a8173a62ddf9b4129f554b39b55b83
Ruby
pilarcormo/SNP_distribution_method
/Cluster/SDM/model_genome.rb
UTF-8
1,786
3.03125
3
[]
no_license
#encoding: utf-8 require_relative 'lib/model_genome' require_relative 'lib/write_it' require_relative 'lib/reform_ratio' name = ARGV[0] contig_size = ARGV[1].to_i fasta_file = "TAIR10_chr1.fasta" genome_length = ReformRatio::genome_length(fasta_file) genome_length.to_i snp = genome_length/3000 snp_2 = snp*2 size_2...
true
dc8f46e5e1f1bda4b5ebdaa9c1b44fa6858747a8
Ruby
etdev/algorithms
/0_code_wars/trimming_a_string.rb
UTF-8
299
3.546875
4
[ "MIT" ]
permissive
# http://www.codewars.com/kata/563fb342f47611dae800003c # --- iteration 1 --- def trim(str, size) if str.size < 3 return "#{str.slice(0...size)}..." elsif str.size <= size return str else new_sz = (size > 3 ? (size-3).abs : size) return "#{str.slice(0...new_sz)}..." end end
true
ac00963d15323e65252b21f74afbb30d4e40a757
Ruby
ryuichi7/cancan_lab-v-000
/app/models/note.rb
UTF-8
662
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Note < ActiveRecord::Base belongs_to :user has_many :viewers has_many :readers, through: :viewers, source: :user before_save :add_user_to_readers def visible_to=(users) self.reader_ids = users.split(",").map { |name| User.find_or_create_by(name: name.strip).id } # user_ids = [] # users.split(",").eac...
true
b6a6d950e21601c77d723801d157a2750add3839
Ruby
rondall/ruby_book
/exercises/5.rb
UTF-8
121
3.265625
3
[]
no_license
array = [1,2,3,4,5,6,7,8,9,10] array.push(11) array.unshift(0) p array array.pop #answer array << 3 #answer p array
true
4cca698e02438c216dba843067e3e37f42550d56
Ruby
nickhillwd/Ruby-CodeClan-week2-day2-homework-classes
/library.rb
UTF-8
1,266
3.5625
4
[]
no_license
class Library attr_reader :name, :books, :people def initialize(name) @name = name @books = {} @people = {} end def add_book(book) @books[book.title] = book end def list_all_books if @books.empty? "There are currently no books in the library" else book_strings = @bo...
true
b58a35539265b967b1b7df54e72b2a08328177e8
Ruby
amandaungco/api-muncher
/test/lib/recipe_test.rb
UTF-8
750
2.703125
3
[]
no_license
require "test_helper" describe Recipe do it "Cannot be initialized with less than 6 parameters" do expect { Recipe.new }.must_raise ArgumentError expect { Recipe.new "Name" }.must_raise ArgumentError end it "Must initialize parameters properly" do recipe = Recipe.new("chicken", ...
true
f8393b866dbc21689a75f7471c17308e999cc6ea
Ruby
rhq-project/samples
/rest-api/ruby/get_status.rb
UTF-8
399
2.71875
3
[]
no_license
# # Sample script to read the status from the server and print on stdout # Heiko W. Rupp # require 'rest_client' require 'JSON' load 'RHQ_config.rb' config = RHQ_config.new('rhqadmin', 'rhqadmin') base_url = config.base_url response = RestClient.get base_url + 'status.json' data = JSON.parse(response) values = d...
true
cfd74660f8163499b48ac1f60c8a8fa488e5dc09
Ruby
woodie/coding_challenges
/dump_neighbors.rb
UTF-8
1,565
4.03125
4
[]
no_license
#!/usr/bin/env ruby class NeighborNode attr_accessor :label, :neighbors def initialize(label, neighbors=[]) self.label = label self.neighbors = neighbors end # 1-2-3 (1,0)→ [] • return any suitable datatype # \| | (1,1)→ [2,4] • order doesn't matter # 4-5-6 (1,2)→ [1,2...
true
d4612cb79dbd689c255a9047a3364fd3c9319915
Ruby
stanvandepoll/exercises-launch-ruby-intro
/loops/ex2.rb
UTF-8
97
3.21875
3
[]
no_license
input = 'start' while input != 'STOP' puts 'What do you want to do?' input = gets.chomp end
true
eb7bb0aab40f50e109d67e517f664ee9ecffddc1
Ruby
walidwahed/ls
/100-program-prep/rubyintro/5-arrays/timestwo.rb
UTF-8
143
3.546875
4
[]
no_license
def timestwo(array) arrtwo = [] array.each do |element| arrtwo << element * 2 end p array p arrtwo end timestwo([5,10,12,13,14])
true
ddd62800524c3940bb2fe7f8843389c13a6e5728
Ruby
shanebdavis/Babel-Bridge
/lib/babel_bridge/nodes/non_terminal_node.rb
UTF-8
761
2.71875
3
[ "BSD-3-Clause" ]
permissive
=begin Copyright 2011 Shane Brinkman-Davis See README for licence information. http://babel-bridge.rubyforge.org/ =end module BabelBridge # rule node # subclassed automatically by parser.rule for each unique non-terminal class NonTerminalNode < Node def update_match_length @match_length = last_match ? last_matc...
true
b2d0f8a0adfeee08385c7dc34376fe6793efe988
Ruby
cclausen/petri_net
/test/reachability_graph/tc_graph.rb
UTF-8
10,765
2.65625
3
[ "MIT" ]
permissive
require 'rubygems' require 'logger' require 'test/unit' class TestPetriNetReachabilityGraph < Test::Unit::TestCase def setup @net = PetriNet::Net.new(:name => 'Water', :description => 'Creation of water from base elements.') @net.logger = Logger.new(STDOUT) end def fill_net @net <...
true
78e9862f5733a24115578e7c2c57ec46d1c552a6
Ruby
jessicamurphyma/tts_notes
/Week 6 SQL and Active Record /middle.rb
UTF-8
54
3.125
3
[]
no_license
def middle(array) puts array[1] end middle([1,2,3])
true
39a3ef00b878b8c6d14d3a03a23d80e1dfe37a65
Ruby
LeandrOS1/ruby-samples
/primer-hangout/Perro.rb
UTF-8
269
3
3
[]
no_license
require "./Mascota" class Perro < Mascota attr_accessor :talla def initialize(nombre, talla, peso) super(nombre, peso) @talla = talla end def costo_servicio case talla when "G" super + 150.0 when "P" super + 80.0 else 0 end end end
true
67a08e3db86c4f5e65ca97b4f701d0ad2ff945c4
Ruby
stripe/stripe-ruby
/lib/stripe/instrumentation.rb
UTF-8
3,671
2.59375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Stripe class Instrumentation # Event emitted on `request_begin` callback. class RequestBeginEvent attr_reader :method attr_reader :path # Arbitrary user-provided data in the form of a Ruby hash that's passed # from subscribers on `request_begin` t...
true
4c89b2290747ebb9be079a045f097514c21ae9a1
Ruby
DouglasAllen/facebook_group_files
/ruby-coding-exercises/january/12.rb
UTF-8
784
2.734375
3
[]
no_license
# https://www.crondose.com/2017/01/build-pseudo-random-number-generator-follows-specific-sequence/ require 'rspec' def pseudo_random(num) srand 1 Fiber.new do num.times do Fiber.yield rand 100 end end end describe 'Psudeo random number generator' do it 'creates the same sequence of random numbe...
true
0bacdb07c6b7af8a935d19edc6bde23430e7a5c7
Ruby
thinkerbot/clipr
/test/clipr/rule/actions_test.rb
UTF-8
1,181
2.609375
3
[ "X11-distribute-modifications-variant", "MIT" ]
permissive
require "#{File.dirname(__FILE__)}/../../test_helper.rb" require 'clipr' class ActionsTest < Test::Unit::TestCase Actions = Clipr::Rule::Actions def test_add_adds_string_action actions = Actions.intern do add "(> 1 2)" end assert_equal "(> 1 2)", actions.to_s end def test_register_...
true
43f8b06c1790f070689f9245da30b23cd6303b41
Ruby
hyprul/school-domain-houston-web-071618
/lib/school.rb
UTF-8
356
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code here! class School attr_reader :roster def initialize(name) @name = name @roster = {} end def add_student(name, grade) @roster[grade] ||= [] @roster[grade] << name end def grade(grade) @roster[grade] end def sort sorted = {} @roster.each do |grade, students| sorted[grade] = stude...
true
98601773a3f0aa8e29f7ca05744e8138daf6437c
Ruby
saintlove/cookbook-app
/runner.rb
UTF-8
1,234
2.609375
3
[]
no_license
require 'unirest' #INDEX ACTION # response =Unirest.get("http://localhost:3000/api/recipes") # puts JSON.pretty_generate(response.body) #SHOW ACTION # response = Unirest.get("http://localhost:3000/api/recipes/1") # puts JSON.pretty_generate(response.body) #CREATE ACTION # response = Unirest.post("http://localhost:...
true
f94af57b1e7cbf45b0bab7c9ae9fd107493a5040
Ruby
KqSMea8/HelloProjects
/HelloXcodeproj/02 - Ruby Helper/01_test_dump_object.rb
UTF-8
400
2.640625
3
[]
no_license
require_relative './rubyscript_helper' string = 'hello, world' dict = {"key" => "value"} array = [] number = 3 nilValue = nil def test(param) return param end dump_object(string) dump_object(dict) dump_object(array) dump_object(number) dump_object("string") dump_object({"key" => "value"}) dump_object([1, 2, 3]) d...
true
eaf6a885f6327f441c2c6ae331a3f5f2ff5a0b1a
Ruby
patrickdavey/AoC
/2015/day7/rshift_logic.rb
UTF-8
647
3.234375
3
[]
no_license
class RShiftLogic def initialize(first_input, shift_by, wire) @first_input = first_input @shift_by = shift_by.to_i @wire = wire end def has_value? first_input.is_a?(Integer) end def value first_input >> shift_by end def try_resolve(all_logics) # if we're in here, then we know we...
true
1cf423a22585a5d8628a84c9434d7d2aaeeeb388
Ruby
kohbis/leetcode
/algorithms/0941.valid-mountain-array/solution.rb
UTF-8
654
3.40625
3
[]
no_license
# @param {Integer[]} a # @return {Boolean} def valid_mountain_array(a) return false if a.size < 3 i = 1 while i < a.size break if a[i] <= a[i - 1] i += 1 end return false if i == a.size || i == 1 while i < a.size return false if a[i] >= a[i - 1] i += 1 end true end # # @param {Integ...
true
3856bc5f9fcc63f47661596b94c7c930c7302020
Ruby
rickbmitchell/memr-app
/app/models/post.rb
UTF-8
2,176
2.59375
3
[]
no_license
include Magick class Post < ActiveRecord::Base belongs_to :user has_many :votes has_one :meme has_one :archive has_attached_file :avatar, :styles => { :medium => "400x400>", :thumb => "100x100>" }, :default_url => "missing.png", id: "avatar" validates_attachment_content_type :avatar, content_type: ...
true
b8915c76bffb7fdd003310cdb6fc9762ffedca75
Ruby
njbryan/ls-rb100-book
/exercises/05-attayItemReplacement.rb
UTF-8
137
3.0625
3
[ "MIT" ]
permissive
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] array.push(11) p array array.unshift(0) p array array.delete(11) p array array.push(3) p array
true
813c51bc2cb64662859d2d96b412176e215d587b
Ruby
mpedersen2054/tealeaf
/course1/week4/exceptions.rb
UTF-8
227
2.8125
3
[]
no_license
i = 0 while i <= 10 begin if i == 0 1/0 end raise "random runtime exception" p "I should never get executed!" rescue ZeroDivisionError p 'I am rescuing only ZeroDivisionError' i += 1 end end
true
0665e925718a845bea64b88a47eecc91e952e107
Ruby
billstoneberg/say-hello-ruby-ruby-intro-000
/say_hello.rb
UTF-8
94
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def say_hello(name) name "Gabriela" name("Ruby Programmer") puts "Hello #{name}!" end
true
ccfccf9b20ddef70ec5e05e41c3bca299bfb0b3e
Ruby
volodymyr-mykhailyk/advent-of-code-2019
/lib/tasks/day11/runner.rb
UTF-8
1,016
3.03125
3
[]
no_license
require_relative '../utils/printer' require_relative '../utils/input_reader' require_relative '../../universe/ship/hull_painting_robot' require_relative '../../universe/communication/space_image' include Utils::Printer input_reader = Utils::InputReader.new(File.expand_path('input.txt')) PANEL_DIMENSION = 100 program...
true
c838ddb8dc1ee08cb867dee544f159a486da2ae8
Ruby
akcrono/blackjack
/blackjack.rb
UTF-8
1,594
4.21875
4
[]
no_license
require_relative 'card' require_relative 'deck' require_relative 'hand' def play_again? game_result puts game_result puts "Do you want to play again?(y/n)" if gets.chomp == 'y' return true end false end def play_game deck = Deck.new dealer_hand = Hand.new player_hand = Hand.new 2.times do |i|...
true
5c2a7a7730bdee246be31d76ab8516d08f56fceb
Ruby
dkentuk/ruby
/Desktop/RubyWork/30192014/personclean.rb
UTF-8
717
4.1875
4
[]
no_license
require 'pry' class Person #creates setter and getters methods attr_accessor :hair_color, :top_color #only getter attr_reader :height def initialize(height = 0.0) @hair_color = nil @height = height @top_color = nil end #methods def dance put...
true
73939bca98074ebdf57adb02e58d89301922af6b
Ruby
paeeon/tealeaf-intro
/intro_to_programming/variables/name.rb
UTF-8
272
3.9375
4
[]
no_license
puts "What's your first name?" first_name = gets.chomp puts "Okay, what's your last name?" last_name = gets.chomp name = first_name + " " + last_name puts "Hi, " + name + "!" 10.times do puts "I really, really, really, really, really, really like you, " + name + "!" end
true
1cb821aca1df91003fdf6ec03c8b070451c50931
Ruby
nkeller1/futbol
/lib/calculator.rb
UTF-8
96
2.78125
3
[]
no_license
module Calculator def find_pct(a, b) (a.length.to_f / b.length.to_f).round(2) end end
true
13ebab49f87396cc2f847dc7ba9739494f5f8ac8
Ruby
kanndide/william-kann-cli-app
/lib/william_kann_cli_app.rb
UTF-8
2,566
3.53125
4
[ "MIT" ]
permissive
require "william_kann_cli_app/version" module WilliamKannCliApp class CLI def call puts "Welcome to the Warren Buffet (Berkshire Hathaway) holdings thingy!" main_menu end def main_menu puts "What would you like to see?" puts "Current...
true
ad588399f582f93986220a80e6c12529b7a53f7b
Ruby
yuriskorobogatov/RoR
/Lesson_6/route.rb
UTF-8
794
3.46875
3
[]
no_license
require_relative 'instance_counter' class Route attr_reader :stations, :name include InstanceCounter def initialize(name, first_station, last_station) @name = name @stations = [first_station, last_station] register_instance validate! end def add_station(station) @stations.insert(-2, sta...
true
80bf60b011dfe781331fc801e149818c81d3ac90
Ruby
PunitDh/Dystoland
/methods.rb
UTF-8
12,891
3.1875
3
[]
no_license
# $wall_buff = 3 ############################################################################# def count_em(string, substring) string.scan(/(?=#{substring})/).count end ############################################################################# def clamp(val, min, max) return min if val <= min return max if val ...
true
2f73fbe71865e8a1d7ce455ae942a54a2d85863c
Ruby
abhinavgunwant/hackerrank-solutions
/Domains/Ruby/06 - Strings/05 - Ruby - Strings - Methods II/solution.rb
UTF-8
259
3.28125
3
[ "MIT" ]
permissive
def strike(s) "<strike>#{s}</strike>" end def mask_article(s, arr) arr.each do | word | # create a RegEx pattern based on the word in array! pattern = Regexp.new word s = s.gsub(pattern, strike(word)) end return s end
true
40cc38bece81ec84166f061cd0eaf695ba1929b7
Ruby
acmassey3698/backend_mod_1_prework
/section1/exercises/ex6.rb
UTF-8
1,273
4.5
4
[]
no_license
#establishes the number for types of people types_of_people = 10 #creates a variable 'x' that is a string interpolating variable "types_of_people" x = "There are #{types_of_people} types of people." #creates variable 'binary' and sets its value to a string binary = "binary" #creates variable 'do_not' and sets it equal ...
true
8f72e997f4ceb47a2bed1b4e4f1e7354971700e1
Ruby
vma13/University
/Archive/5sem/BD/aero_tickets/aero/lib/controllers/helper.rb
UTF-8
1,433
2.546875
3
[]
no_license
module Helper def companies_select(name, selected) "<select name = '#{name}'>" + Company.find_all(@db).map do |c| if c[:id].to_i == selected.to_i "<option value = '#{c[:id]}' selected>#{c[:name]}</option>" else "<option value = '#{c[:id]}'>#{c[:name]}</option>" en...
true
161dc343dbde550bd06ff3f896ca212086ab1238
Ruby
aasmith/struggle
/lib/struggle/arbitrators/card_play.rb
UTF-8
4,337
3
3
[ "MIT" ]
permissive
module Arbitrators class CardPlay < MoveArbitrator fancy_accessor :player, :optional needs :deck, :china_card, :hands, :cards, :guard_resolver # used for tracking state over two-instruction plays attr_accessor :previous_card, :previous_action def initialize(player:, optional: false) sup...
true
41b674befa06627ef9251c66d54e84c362dbe293
Ruby
festinalent3/ruby-kickstart
/session2/3-challenge/4_array.rb
UTF-8
1,637
4.4375
4
[ "MIT" ]
permissive
# Write a method named get_squares that takes an array of numbers # and returns a sorted array containing only the numbers whose square is also in the array # # get_squares [9] # => [] # get_squares [9,3] # => [3] # get_squares [9,3,81] # => [3, 9] # get_squares [...
true
8889954716be285311e09e5fc47295d11945ec0d
Ruby
NoahZinter/weather_getter_api
/spec/services/forecast_service_spec.rb
UTF-8
2,622
2.609375
3
[]
no_license
require 'rails_helper' RSpec.describe ForecastService do before :all do @lat = 39.738453 @lon = -104.984853 @data = ForecastService.get_forecast(@lat, @lon) end describe '.get_forecast' do it 'retrieves forecast with lat and lng' do expect(@data[:lat].round(2)).to eq @lat.round(2) exp...
true
da2504e91c9e783b3262aa91a139fee9f6f488cf
Ruby
gitvar/Assessment-149-Revision
/4. Blocks/e1_blocks.rb
UTF-8
422
3.9375
4
[]
no_license
def echo_with_yield(str) yield if block_given? str end puts echo_with_yield("Hello!") # No error if using 'if block_given?' # puts echo_with_yield { puts "world" } # => ArgumentError: wrong number of arguments (0 for 1) # puts echo_with_yield("hello!") { puts "world" } # world and return "hello!" # puts echo_w...
true
9c0bd57b151c93d6f61bca7cede6ab279be24c7d
Ruby
learn-co-students/nyc-web-010620
/07-oo-review-part-2/ride.rb
UTF-8
288
2.9375
3
[]
no_license
class Ride attr_accessor :duration, :price, :passenger, :driver @@all = [] def initialize(duration, price, passenger, driver) @duration = duration @price = price @passenger = passenger @driver = driver @@all << self end def self.all @@all end end
true
ec4a255b3147b63560ebd879b4b3ff99966834d1
Ruby
srashidi/RSpec_Project
/connect_four/spec/cage_spec.rb
UTF-8
5,535
3.21875
3
[]
no_license
require 'spec_helper' describe Cage do before :each do @cage = Cage.new end describe "#new" do it "creates a new Cage object with no pieces" do expect(@cage.row1).to eql "| | | | | | | |" expect(@cage.row2).to eql "| | | | | | | |" expect(@cage.row3).to eql "...
true
3fbf6f5f12e8a3909c2d9dc1d8eb8cca9a947176
Ruby
tosiaki/imaginationspace
/lib/import_association_map.rb
UTF-8
545
2.984375
3
[ "MIT", "Beerware", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class ImportAssociationMap def initialize @import_association_map = [] end def add_association(old_record, new_record, type) @import_association_map << {old_record: old_record, new_record: new_record, type: type} end def get_by_old_id(id, type) result = @import_association_map.select { |entry| e...
true
4f225d5d9f5439c4ffd5c7a7537904ac287a7a9a
Ruby
jeremiahogutu/ttt-10-current-player-cb-gh-000
/lib/current_player.rb
UTF-8
298
3.59375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn_count(board) playCount = 0 board.each do |playSpace| if playSpace == "X" || playSpace == "O" playCount+=1 end end return playCount end def current_player(board) playerTurn = turn_count(board) if playerTurn % 2 == 0 return "X" else return "O" end end
true
906264aeb89002cb47491191758147b099b3497c
Ruby
dirtyRuby/Practice
/EachMapVowel/map_vowel.rb
UTF-8
182
3.15625
3
[]
no_license
module MapVowel def map_vowel(&proc) vowels = ['a','o','u','i','e'].to_enum vowels.map{proc.call(vowels.next)} end end #Test include MapVowel map_vowel{ |x| puts x+'1'}
true
033661abba70a2348eab335cafa5706cfb4e851a
Ruby
innlouvate/bank_tech_test
/spec/account_spec.rb
UTF-8
1,238
2.953125
3
[]
no_license
require "./lib/account.rb" describe Account do subject(:account) {described_class.new(statement)} let(:statement) { double :statement } let(:date) { Time.new(2012, 01, 10) } before do allow(statement).to receive(:new_transaction) end describe "#initialize" do it "customer has a balance of £0" do ...
true
9a5c28da46b192cf34129066a0dda45bd49a434a
Ruby
hxcan/sbrowser_ruby_prototype
/SWebPageWidget.rb
UTF-8
6,609
2.515625
3
[]
no_license
require 'Qt4' require 'StbWebView.rb' require 'qtwebkit' class SWebPageWidget < Qt::Widget signals 'shouldOpenNewTab()','titleChanged(QString)','iconChanged(QIcon)' slots 'gotoUrlBarUrl()','refreshUrl(QUrl)','indicateLoadStart()','indicateLoadProgress(int)','indicateLoadFinished(bool)','indiateIconChanged()','f...
true
f51e2df31a123e04665b2a35dbbbb8ec7d26c1c9
Ruby
ianderse/gosu_dodger
/init.rb
UTF-8
5,857
2.859375
3
[]
no_license
#TODO: #Add shields (3 per game, icons at the bottom) (done) #Ability to shoot (done) #remove explosion gfx after a set amount of time (done) #scrolling for background #Powerups #Extra point drops from enemies require 'gosu' require './player' require './enemy' require './explosion' require './bullet' require './shie...
true
b2d34aed4f4ed3f3d4d91487f894fd9e867ff11e
Ruby
gregors/boilerpipe-ruby
/lib/boilerpipe/filters/density_rules_classifier.rb
UTF-8
1,135
2.78125
3
[ "Apache-2.0" ]
permissive
# Classifies TextBlocks as content/not-content through rules that have been determined # using the C4.8 machine learning algorithm, as described in the paper # "Boilerplate Detection using Shallow Text Features", particularly using text densities and link # densities. module Boilerpipe::Filters class DensityRulesCla...
true
6cfc82850d8c68770f8bed3fbe69a0115818ea63
Ruby
chameleon-bi/chambi_oa
/spec/support/login_macros.rb
UTF-8
635
2.640625
3
[ "MIT" ]
permissive
# Login methods for administrator module LoginMacros def login(administrator, initial_path) visit initial_path fill_in_details(administrator) check_path(initial_path) end def submit_login click_button 'Log In' expect(page).to have_text('Logged in!') end private def fill_in_details(adm...
true
a33812be8b3d227a6adffd825e6f885b29d8f783
Ruby
erose357/project_manager
/app/services/forecast.rb
UTF-8
646
2.921875
3
[]
no_license
class Forecast attr_reader :high, :low, :conditions, :icon_url, :weekday def initialize(attrs) @location = attrs[:date][:tz_long] @weekday = attrs[:date][:weekday] @day = attrs[:date][:day] @month = attrs[:date][:month] @year = attrs[:date][:year] @high = attrs[:...
true
911a1bc3fd4f821d2b2a6bd6cb29a7f526d04b7e
Ruby
cuzik/report-generator
/preprocessor.rb
UTF-8
1,660
3.046875
3
[]
no_license
require 'simple_xlsx_reader' require 'time' require 'csv' def open_xlsx(file_name) workbook = SimpleXlsxReader.open file_name report = workbook.sheets.find(name: 'report').first matrix = [] max_length = 0 report.rows.each { |x| x.length > max_length ? max_length = x.length : nil} rows = report.rows.m...
true
388630759ea2c43d093bd903cbb9c033fc74e0c3
Ruby
vma13/University
/Archive/9sem/rtos/rt/chma.rb
UTF-8
714
3.1875
3
[]
no_license
def main() arr = [] deadline = [] n = gets.to_i n.times do arr << gets.split.map{|x| x.to_i} end max = arr[n-1][1] for i in 0...n task = arr[i][1] while task < max deadline << task task += arr[i][1] end end deadline << max deadline = deadline.sort.uniq for i in 0...deadline.siz...
true
39931ab789de8f2e91395c27386e1f3cd4101283
Ruby
beegibson/fp-for-rubyists
/mutable_total.rb
UTF-8
424
3.546875
4
[]
no_license
def mutable_total_cart(items) total = 0 items.each do |item| total += item.cost end total end def recursive_total_cart(items) head, *tail = items if tail.empty? head.cost else head.cost + recursive_total_cart(tail) end end def immutable_total_cart(items) items.inject(0) { |total, item| t...
true
0fe89081d17107d50fd57f541873ce7feba3eb28
Ruby
stAndrei/the_task
/app/models/statistics.rb
UTF-8
2,438
2.671875
3
[ "MIT" ]
permissive
class Statistics def revenue gross_sales - payouts end def rejection_rate count_jobs('rejected') / count_jobs(%w(accepted done)) * 100 end def predicted_revenue(future_date) forecast, sigma = get_forecast(future_date) { forecast: forecast, sigma: sigma, best: forecast + si...
true
258f0bacdafd2185e7b171dfbb811ab71a1cf2ac
Ruby
jeanbahnik/exercism
/ruby/leap/leap.rb
UTF-8
194
3.46875
3
[]
no_license
class Year def self.leap?(year) answer = false answer = true if year % 4 == 0 answer = false if (year % 100 == 0 && year % 400 != 0) return answer end end
true
f193cb62110b3bd07c9cba7725cdc7f1e3cbe023
Ruby
jef-abraham/arabic2english
/spec/arabic2english_spec.rb
UTF-8
2,671
3.140625
3
[]
no_license
require 'spec_helper' require_relative '../arabic2english' describe "arabic2english" do it "should reply 'one'" do expect(get_full_word(1)).to eq('one') end it "should reply 'two'" do expect(get_full_word(2)).to eq('two') end it "should reply 'five'" do expect(get_full_word(5)).to eq('five') ...
true
c2efd0d4c426f44175df77d61a4a440a90a4b2c3
Ruby
sarceneaux/study-hall-classwork
/pal.rb
UTF-8
243
4.09375
4
[]
no_license
#this is my comment for you to find later puts "Enter a word. We'll see if it's a palindrome" word = gets.chomp reverseWord = word.reverse if reverseWord == word puts "#{word} is a palindrome" else puts "#{word} is NOT a palindrome" end
true
71aa6c3b4c947c5e9d44090fed2ddcd7756dbff9
Ruby
b-studios/doc.js
/lib/generator/generator.rb
UTF-8
8,412
3.109375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require_relative '../renderer' require_relative '../dom/dom' require_relative '../helper/helper' module Generator # If you already familiar with Ruby on Rails: Generators are pretty much like Controllers in Rails. # That's like in Rails: # # - They use the existing data-model (The {Dom} in our case) # - The...
true
f921fc7c3e3488f6f4639aa4231661015e7169bd
Ruby
jamesxuhaozhe/learn-ruby
/ex12.rb
UTF-8
160
2.75
3
[]
no_license
first, second, third = ARGV puts "This is the first argument #{first}" puts "This is the second argument #{second}" puts "This is the thrid argument #{third}"
true
231bc5a020b592b3c6b87ba89e3eaae79392d49f
Ruby
ivar/magic-search-engine
/lib/indexer.rb
UTF-8
12,763
2.578125
3
[]
no_license
require "date" require "ostruct" require "json" require "set" require "pathname" require "pry" require_relative "ban_list" require_relative "format/format" require_relative "indexer/card_set" require_relative "indexer/oracle_verifier" require_relative "indexer/foreign_names_verifier" # ActiveRecord FTW class Hash de...
true
fc067b6a9e05b8229ec0ef08757be2f59fea3a41
Ruby
Wertster/fsm
/helpers/fsm_event_source.rb
UTF-8
1,224
2.9375
3
[ "CC0-1.0" ]
permissive
require 'yaml' require 'socket' require_relative 'fsm_const' require_relative 'fsm_event' #Utility mixin, with event handling methods module FsmEventSource #Include constants into this module namespace include FsmConst #Establshes binding to a datagram socket on localhost def fsm_listen @socket ||= UDPSocket...
true
97efd03b606342835fd074ae3c1d7e5cbcf90c7b
Ruby
ravihebbar6/problem-solving
/ruby/problems/stack_test.rb
UTF-8
173
2.890625
3
[]
no_license
require '../data_structures/stack.rb' x = Stack.new([]) p x.list x.push(1) p x.list x.push(2) p x.list x.push(3) p x.list x.pop p x.list x.pop p x.list x.pop p x.list
true
4c0136cc95b94ea23600c053f50e6d8ee71c46e4
Ruby
corntrace/sleeve
/lib/Sleeve.rb
UTF-8
913
3.265625
3
[]
no_license
module Sleeve def push_into_sleeve_pocket(obj, label='') @sleeve_pocket = @sp ||= SleevePocket.new @sp.push(obj, label) end def fetch_from_sleeve_pocket(label, obj=nil) @sleeve_pocket.fetch(label) end end class SleevePocket # attributes that we would try one by one on a model @@t...
true