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
5f4aab5464314b08bb8226ea3d81dfa49bcf0b43
Ruby
baxtjm/my-first-repo
/Day 3/tip_calculator_hackathon.rb
UTF-8
363
3.546875
4
[]
no_license
puts "What's your subtotal" subtotal = gets.to_f puts "What would you like to tip" gratuity_percentage = gets.to_f puts "How many people did you eat with?" num_people = gets.to_f gratuity = subtotal * gratuity_percentage total_bill = subtotal + gratuity my_share = total_bill / num_people puts "The total bill is #{tot...
true
b74cda036bcdc2439b26a330cd61f17c9a9a5804
Ruby
pfranciskoe/pk_aa_cw
/w4d1/tic_tac_toe_supercomp/lib/tic_tac_toe_node.rb
UTF-8
1,897
3.578125
4
[]
no_license
require_relative 'tic_tac_toe' class TicTacToeNode attr_reader :board, :next_mover_mark, :prev_move_pos def initialize(board, next_mover_mark, prev_move_pos = nil) @board = board # instance of Board, has 2D array as board inside @next_mover_mark = next_mover_mark @prev_move_pos = prev_move_pos end ...
true
ad95c3b37a0333ccb82a5f9de6c14e9c5cbd6626
Ruby
mijkami/ruby_newb
/exo_13.rb
UTF-8
132
3.171875
3
[]
no_license
puts "Bonjour, quelle est ton annรฉe de naissance ?" i= gets.chomp.to_i loop do i += 1 puts i if i == 2018 break end end
true
2c201b4308903d0711b44cf68610aba2d6b619da
Ruby
jebitok-dev/dsa
/find-the-duplicates-jebitok-dev/challenge.rb
UTF-8
384
3.34375
3
[]
no_license
def duplicates(arr1, arr2) new_arr1 = *arr1 new_arr2 = *arr2 new_arr1.each do |i| if new_arr2.include?(i) new_arr2.delete_at(new_arr2.find_index(i)) end end new_arr2.sort! end p duplicates([203, 204, 205, 206, 207, 208, 203, 204, 205, 206], [203, 204, 204, 205, 206, 20...
true
7115bd9fb6c3e877b13bc1c81170829ce0c3b281
Ruby
dbilek/gig
/lib/gig/greper.rb
UTF-8
3,335
3.03125
3
[]
no_license
require "net/http" require "open-uri" require 'json' ITEMS_PER_PAGE = 50 API_URL = "https://api.github.com" module Gig class Greper attr_reader :options attr_accessor :uri def initialize(options = []) @options = options url = API_URL + "/search/repositories" @uri = gen...
true
74e90bb722c317e5b67adcedf1d3428fc1b244dc
Ruby
ju-to-sh/rsv_app
/reservation.rb
UTF-8
2,099
3.296875
3
[]
no_license
class Reservation attr_accessor :id, :user_name, :datetime, :contents, :created_at def initialize(id, user_name, datetime, contents, created_at) @id = id @user_name = user_name @datetime = datetime @contents = contents @created_at = created_at end def self.valid_name name = gets.chomp....
true
b2b68b70dc3f43a26a4c226c9c3f5201a04908f9
Ruby
amiel/quantum-delta
/lib/quantum-delta/invalid_delta_combinations.rb
UTF-8
521
2.953125
3
[ "MIT" ]
permissive
module QuantumDelta class InvalidDeltaCombinations attr_reader :period def initialize(period) @period = period end def invalid_combinations (0..(period - 1)).map { |n| combinations_for(n) }.flatten end private def combinations_for(n) incrementer = BaseIncrementer.new(p...
true
c9b5961ed34dcc8085213317113e9c5a01de8e1e
Ruby
tarujkhan/tic-tac-toe-rb-online-web-sp-000
/lib/tic_tac_toe.rb
UTF-8
4,245
3.71875
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def display_board(board) divider = "|" lines = "-----------" puts " #{board[0]} #{divider} #{board[1]} #{divider} #{board[2]} " puts "#{lines}" puts " #{board[3]} #{divider} #{board[4]} #{divider} #{board[5]} " puts "#{lines}" puts " #{board[6]} #{divider} #{board[7]} #{divider} #{board[8]} " end def posit...
true
96b3ca7656965ef0ff004f56a9971fb6d5ebad83
Ruby
Itsindigo/boris
/spec/bike_spec.rb
UTF-8
520
2.5625
3
[]
no_license
require 'bike' RSpec.describe Bike do bike = described_class.new it {is_expected.to respond_to(:working?)} it "should report the bike's working status" do expect(bike.working?).to eq("Working") end it "should change the working status of a bike to false" do expect{bike.report_broken}.to change{bi...
true
0c20aa735314ff661f00ed37fb9957bde0b1b87f
Ruby
citelao/3am-Jazz-Band
/scratch/PlayerTest.rb
UTF-8
1,888
3.21875
3
[]
no_license
require 'unimidi' require_relative '../Factories/ChordFactory' require_relative '../Cues/Rest' require_relative '../Player' require_relative '../Instrument' require_relative '../Cue' tempo = 120 #bpm $quarter = 60.0 / tempo $eighth = $quarter / 2 $triplet = $quarter / 3 puts $quarter, $eighth, $triplet # Prompt the...
true
8ab21e44b3376f88149906a3d625999729274ce1
Ruby
andistuder/ruby-hack
/task.rb
UTF-8
218
2.859375
3
[]
no_license
# a simple ruby task, run like this: # API_KEY=<MYKEY> bundle exec ruby task.rb Hello World require_relative 'lib/translator' input = ARGV.join(" ") translator = Translator.new puts translator.translate(input)
true
977c6b677871192f122b8d53716fe06ea18a99e1
Ruby
mrnugget/ttf2eot
/lib/ttf2eot.rb
UTF-8
1,403
3.140625
3
[]
no_license
module TTF2EOT # Public: Converts a TTF font file to an EOT font. # # input - the input TTF font as a String (representing a path) or IO object # (responding to #read). # output - the output destination as a String (representing a path) or IO # object where the EOT font will be written. ...
true
623d2230c5e0ce13dcf1d17fc0a6d8214a1af939
Ruby
blambeau/yargi
/examples/random.rb
UTF-8
594
2.71875
3
[ "MIT" ]
permissive
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'yargi' COLORS = ["blue", "red", "yellow", "green"] # We build a random graph with approximately 20 vertices # and 60 edges (will be stripped by default). Each vertex # will have a color picked at random. graph = Yargi::Digraph.random(20,60) d...
true
43d605335382f454af2f977715df56af8ccfe542
Ruby
jordanmaguire/frontier_generators
/lib/frontier/attribute/validation/uniqueness.rb
UTF-8
1,475
2.703125
3
[]
no_license
class Frontier::Attribute::Validation::Uniqueness < Frontier::Attribute::Validation # attribute: name # key: "uniqueness" # args: true OR {scope: :user_id} def initialize(attribute, key, args) super # For a scope: argument, ensure the value is :value if args.is_a?(Hash) && args["scope"] && args["s...
true
fe44cb1c34ff51f259699455192a8375f744bc1b
Ruby
cigraphics/ArchiveBot
/cogs/log_db.rb
UTF-8
1,249
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'analysand' class LogDb def initialize(uri, credentials) @db = Analysand::Database.new(uri) @credentials = credentials end ## # Given an array of the form # # [JSON string, numeric, ..., JSON string, numeric] # # and an amplified job, this method JSON-parses all strings, generates ...
true
6c5831105c4211f35a93f1f58a15b628bfced392
Ruby
kjferris/intro_to_programming
/exercises/chap4_ex3.rb
UTF-8
259
3.921875
4
[]
no_license
puts "please enter a number between 0 and 100" num = gets.chomp.to_i if num > 100 || num < 0 puts "Your number is not between 0 and 100" elsif num >= 51 puts "Your number is between 50 and 100" else num <= 0 puts "Your number is between 0 and 50" end
true
449603e8ef628d97be036eb7f6e1108071f8fbab
Ruby
bikeonastick/snapdragon
/spec/lib/snapdragon/path_spec.rb
UTF-8
2,918
2.6875
3
[ "MIT" ]
permissive
require_relative '../../../lib/snapdragon/path' describe Snapdragon::Path do describe "#initialize" do it "stores the raw path in an instance variable" do path = Snapdragon::Path.new('some/path:423') path.instance_variable_get(:@raw_path).should eq('some/path:423') end context "when given a ...
true
debb7c608957429d26ff9eec33e023aa7a861bc1
Ruby
CinnaBomb/knight-traversal
/knight.rb
UTF-8
2,059
3.78125
4
[]
no_license
class Knight attr_accessor :position, :parent, :children def initialize(position=[0,0], parent = nil) @position = position @parent = parent @children = possible_moves_for(position) end #returns array of possible moves for position #only used to create children of nodes def possible_moves_for(position) p...
true
7625d5a8eabfc6b5baeec20c6426312a14c9054c
Ruby
chrisortman/configurious
/lib/configurious/transformer.rb
UTF-8
1,112
2.703125
3
[ "MIT" ]
permissive
require 'configurious/operations' module Configurious class Transformer def initialize @steps = [] end def add(path, value) op = Configurious::Operations::Add.new op.path = path op.content = value @steps << op end def replace(path, with:, part: nil) r = Con...
true
f557652094cbd6b4855e06bbcd6b3355ccb1a811
Ruby
hiltonatgithub/looping-while-until-001-prework-web
/lib/until.rb
UTF-8
219
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def using_until levitation_force = 6 # Continued own until zero reached. until levitation_force == 10 print "Wingardium Leviosa\n" levitation_force += 1 end end
true
bc32b98026cd206fa78fad13ce6af857b62acaf1
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/strain/616befc0e49441158f3ff829a86f0f95.rb
UTF-8
321
3.265625
3
[]
no_license
class Array def method_missing(method_name, &block) result = [] i = 0 while i < self.length case method_name when :keep result << self[i] if block.call(self[i]) when :discard result << self[i] if not(block.call(self[i])) end i += 1 end result end end...
true
1ce926b9d3eca2b73fd28df6eedd91d17c6196f9
Ruby
overtakermtg/Experiencia14
/Ejercicio2.rb
UTF-8
792
4.09375
4
[]
no_license
# Dado el arreglo nombres = ["Violeta", "Andino", "Clemente", "Javiera", "Paula", "Pia", "Ray"] # Se pide: # 1. Extraer todos los elementos que excedan mas de 5 caracteres utilizando el mรฉtodo # .select. # 2. Utilizando .map crear una arreglo con los nombres en minรบscula. # 3. Utilizando .select para crear un arreglo c...
true
14d656cb77a76ac7953b583904986e49b7dbbde2
Ruby
reproio/remote_syslog_sender
/lib/remote_syslog_sender/sender.rb
UTF-8
2,125
2.5625
3
[ "MIT" ]
permissive
require 'socket' require 'syslog_protocol' module RemoteSyslogSender class Sender # To suppress initialize warning class Packet < SyslogProtocol::Packet def initialize(*) super @time = nil end end attr_reader :socket attr_accessor :packet def initialize(remote_ho...
true
24a263d9662a1c9bce6c8bbb1d562a51a53bbc0f
Ruby
learn-co-students/nyc-chi-042621
/0629-1-crud/db/seeds.rb
UTF-8
955
3.15625
3
[]
no_license
# #CREATE# # # Model.create(hash_of_attributes) # inst = Model.new(hash_of_attributes) # inst.save unf = Book.create( name: "Series of Unfortunate Events", author: "Lemony Snicket", page_count: rand(100)) fortunate = Book.create( name: "Series of Fortunate Events", author: "Lime Snicket", ...
true
486e0620add5e32a4c0ace08295c6e7149d69568
Ruby
dotnotation/hairless_furever
/lib/hairless_furever/cli.rb
UTF-8
2,535
3.5625
4
[ "MIT" ]
permissive
class HairlessFurever::CLI def call #start scraping method HairlessFurever::DogCatcher.catch_dog_breeds #welcome user and set flow of program puts "\nWelcome to Hairless Furever!\n" puts "\nHere you can learn all about hairless dog breeds.\n" puts "UใƒปแดฅใƒปU" ...
true
80bb32c8eb3184ddfbf7a0317964fda5f931a836
Ruby
MislavGunawardena/Back-End-Lesson01
/excercises/small_problems_repeat/set1.7/7.rb
UTF-8
299
3.53125
4
[]
no_license
def show_multiplicative_average(numbers) multiplicative_average = numbers.inject(&:*) / numbers.size.to_f puts format("The result is %.3f", multiplicative_average) end show_multiplicative_average([1, 10, 1]) show_multiplicative_average([3, 5]) show_multiplicative_average([2, 5, 7, 11, 13, 17])
true
61be6c15948083148e77b259200d784ac0de5135
Ruby
markkauffman22/ttt-8-turn-bootcamp-prep-000
/lib/turn.rb
UTF-8
1,463
4.25
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end def valid_move?(board, i) # check if position is taken or if it is 'out-of-bounds' ....
true
b0ae7c8204ea5be31bb8bddb6c033f1586e5df89
Ruby
gammons/todolist-ruby
/lib/todo-cli/filter.rb
UTF-8
2,901
3.015625
3
[ "MIT" ]
permissive
module Todo class Filter def initialize(todos = [], input = nil) @todos = todos.clone @input = input end def filter return todos if @input.nil? filter_archived filter_projects filter_contexts filter_date group end def group g = nil @inp...
true
e4e3cb8c311dad4bef8f42f161558307ab7e96ec
Ruby
FlisAnn/ruby_excercises
/number3.rb
UTF-8
756
4.8125
5
[]
no_license
# '4' == 4 ? puts("TRUE") : puts("FALSE") # if the statement is true show TRUE, otherwise FALSE # It's false since we are comparing a String to Int =begin rescue => exception end x = 2 if ((x * 3) / 2) == (4 +4 -x -3) puts "Did you get it right?" else puts "Did you?" end =end # 2 * 3 / 2 = 3 ...
true
33ae1e1a56e6296da3ef012362af10a8cc18aa98
Ruby
01022012/medical-appointments
/vendor/rails/activesupport/test/core_ext/module_test.rb
UTF-8
4,371
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
require File.dirname(__FILE__) + '/../abstract_unit' module One end class Ab include One end module Xy class Bc include One end end module Yz module Zy class Cd include One end end end class De end Somewhere = Struct.new(:street, :city) Someone = Struct.new(:name, :place) do deleg...
true
abd88e2ccb677154e109e0e6b97f5847365c55ab
Ruby
flaviuvr/wolfpack-ror-internship
/Assignment2/carCleaningService.rb
UTF-8
3,209
3.34375
3
[]
no_license
require 'time' # Describes the schedule by which the service operates module Schedule START_TIME_HOUR = 8 END_TIME_HOUR = 17 def self.open?(time) open_time?(time) && open_day?(time) end def self.open_time?(current_time) current_time.hour > START_TIME_HOUR && current_time.hour < END_TIME_HOUR end ...
true
5d73c5bc2f5f16fb9f983894719c41f867b6d993
Ruby
wley3337/Flatiron-Students-Connect-Backend
/app/models/user.rb
UTF-8
712
2.546875
3
[]
no_license
class User < ApplicationRecord has_many :notes accepts_nested_attributes_for :notes has_many :user_references has_many :references, through: :user_references validates :username, uniqueness: true, presence: true validates :first_name, presence: true validates :last_name, presence: true ...
true
91e534b1ab17bb972caaa77162a4b46d35fc16d3
Ruby
miguelvieira123/BetESSEntrega
/MVC/Gambler.rb
UTF-8
290
2.921875
3
[]
no_license
class Gambler < Object attr_reader :username , :password, :coins def initialize @username = "John Doe" @password @coins = 0.0 end def setUsername(usr) @username = usr end def setPassword(passwd) @password = passwd end def setCoins(coins) @coins = coins end end
true
7b51bb6528713072ea8aa136122b3b47ff9a3d26
Ruby
inhortte/rt_rails3.2
/app/models/user.rb
UTF-8
1,040
2.6875
3
[]
no_license
require 'digest' class User < ActiveRecord::Base attr_accessor :password attr_accessible :username, :password, :password_confirmation # validates :password, :presence => true, # :confirmation => true, # :length => { :within => 6..40 } before_save :encrypt_password def has_password?(submitte...
true
47ec5bceda2dfac6885b094c4b453bd0734a10fe
Ruby
nerdyamigo/learnruby
/exercs/mystuff.rb
UTF-8
185
3.4375
3
[]
no_license
# this goes in mystuff.rb class MyStuff def initialize() @tangerine = "And now a thousand years between" end attr_reader :tangerine def apple() puts "I AM APPLES!" end end
true
983a56014f7ae57d94c14ea1ec070eacf31fc2e0
Ruby
loyaldev03/cultivation-app
/app/commands/cultivation/append_material_use.rb
UTF-8
1,074
2.59375
3
[]
no_license
# Call this method instead of SaveMaterialUse if want to: # 1. append new product to use module Cultivation class AppendMaterialUse prepend SimpleCommand attr_reader :current_user, :id, :items def initialize(current_user, id, items) @current_user = current_user @id = id.to_bson_id @it...
true
437244853491f96823866b83dbd9f28773eebde0
Ruby
cato-hga/TimeTracker
/db/seeds.rb
UTF-8
1,646
2.65625
3
[]
no_license
@employee = Employee.create(email: "jchristopher.cato@gmail.com", password: "asdfasdf", password_confirmation: "asdfasdf", first_name: "John", last_name: "Snow", phone: "8138422213") puts "1 employee createed" AdminUser.create(email: "hga813@gmail.com", password: "asdfasdf", pa...
true
48936c2ac3cf9f8c78be6f010fe62719cc04136e
Ruby
ayumin/apex
/lib/apex/converter.rb
UTF-8
5,106
2.921875
3
[ "MIT" ]
permissive
#!/usr/bin/ruby # -*- coding: utf-8 -*- module Apex module Converter # # Apexใ‚ณใƒผใƒ‰ใ‚’JavaDocใŒ่งฃ้‡ˆใงใใ‚‹Javaใ‚ณใƒผใƒ‰ใซๅค‰ๆ›ใ—ใพใ™ใ€‚ # # ApexใจJavaใฎใ‚ณใƒผใƒ‰ไป•ๆง˜ใฎ้•ใ„ใ‚’ใชใ‚‹ในใๅธๅŽใ—ใ€JavaDocใง่งฃ้‡ˆๅฏ่ƒฝใชใ‚นใ‚ฑใƒซใƒˆใƒณ # ใ‚ณใƒผใƒ‰ใจใ—ใฆๅ‡บๅŠ›ใ—ใพใ™ใ€‚ไธปใช็›ธ้•็‚นใฏไธ‹่จ˜ใฎใจใŠใ‚Šใงใ™ใ€‚ # # - ๆ–‡ๅญ—ๅˆ—ใƒชใƒ†ใƒฉใƒซ # Javaใงใฏใ‚ทใƒณใ‚ฐใƒซใ‚ฏใ‚ชใƒผใƒ†ใƒผใ‚ทใƒงใƒณใงๅ›ฒใพใ‚ŒใŸๆ–‡ๅญ—ๅˆ—ใฏ1ใคใฎๆ–‡ๅญ—ใฎใฟใ‚’ใ‚ใ‚‰ใ‚ใ— # ใพใ™ใŒApexใงใฏใ‚ทใƒณใ‚ฐใƒซใ‚ฏใ‚ชใƒผใƒˆใงๆ–‡ๅญ—ๅˆ—ใ‚’่กจ็พใ—ใพใ™ใ€‚ใใฎใŸใ‚Ape...
true
571eab8475a3d72b6f750df6196993c1b40e484f
Ruby
matheusjohannaraujo/exemplos_ruby
/estrutura_de_repeticao/teste_2.rb
UTF-8
313
3.796875
4
[ "MIT" ]
permissive
def separador puts "-" * 30 end separador vet = [7, 895, 9, 6, 36, 81, 55454, 3563] for i in 0...vet.size puts "Pelo for: #{vet[i]}" end separador vet.each do |i| puts "Pelo each: #{i}" end separador obj_hash = { a: 1, b: 2, c: 3 } obj_hash.each do |k, v| puts "Chave: #{k} | Valor: #{v}" end
true
de720232e2977acd7f5a7f159cbe37dd0f3811f3
Ruby
maetl/mementus
/spec/structure/indexed_graph_example.rb
UTF-8
2,657
2.546875
3
[ "MIT" ]
permissive
require 'spec_helper' shared_examples_for "an indexed graph data structure" do |supports_edge_ids: false| describe '#new' do it 'starts with empty node list' do expect(structure.nodes_count).to eq(0) end it 'starts with empty edge list' do expect(structure.edges_count).to eq(0) end end...
true
4a93af09a6e3333dab0b1871fbb86ff8a14d2e5f
Ruby
sebas095/Ruby
/class/proc.rb
UTF-8
147
3.125
3
[]
no_license
def hi proc1, proc2 proc1.call proc2.call end proc1 = Proc.new { puts "Hola proc1" } proc2 = Proc.new { puts "Hola proc2" } hi(proc1, proc2)
true
dd092676e1de8253c1151b297c5ee7ed11aca20c
Ruby
ginter/hackerrank
/sherlock_and_squares.rb
UTF-8
120
2.828125
3
[]
no_license
t = gets.to_i t.times.map do a, b = gets.split(' ').map(&:to_i) p (Math.sqrt(a).ceil..Math.sqrt(b).floor).count end
true
0410df4c830c8c39a35c4bbb10f05d519599f68b
Ruby
moinvirani/learn_ruby
/03_simon_says/simon_says.rb
UTF-8
543
4
4
[]
no_license
def echo(word) return word end def shout(word) return word.upcase end def repeat(word, num=2) return ("#{word} " * num).strip #strip removes all the whitespace in a string end def start_of_word(word, num=0) return ("#{word.slice(0,num)}") end def first_word(word) return ("#{word.split[0]}") end def title...
true
5f8c121a5ab0594d81cbf0758dd26684c85f975f
Ruby
dunkkle/whois-bot
/bot.rb
UTF-8
4,293
3.234375
3
[]
no_license
# DNS Bot # This script is the skeleton for a bot that will automatically check DNS and Whois records for a given domain. # # Uses net/dns gem: https://github.com/bluemonk/net-dns # Uses whois gem: https://whoisrb.org/ # # require 'sinatra' require 'slack-ruby-client' require 'net/dns' require 'whois' require 'net/ht...
true
302e1b8bb4f9dde5c54deb7f1c5bc871d93b80d7
Ruby
anchietajunior/improving-jaya-test
/app/services/events/event_creator_service.rb
UTF-8
714
2.578125
3
[]
no_license
module Events class EventCreatorService < ApplicationService def initialize(request) @request = JSON.parse(request) end def call Result.new(true, nil, create_event!) rescue StandardError => e Result.new(false, e.message, nil) end private attr_accessor :request def...
true
7df547ab5f621ca62cd814a898efb3b737311db8
Ruby
casualjim/ironrubyinaction
/Chapter 2/Listing2.10.rb
UTF-8
1,488
3.84375
4
[]
no_license
class MusicLibrary < Array def add_album(artist, title) # The << operator pushes an item onto the end of the array. self << [artist, title] self end def search_by_artist(key) reject { |b| !match_item(b, 0, key) } end def search_by_artist_or_title(key) # reject returns a new array contai...
true
3f26f5e06d647fa716e0b2cec620dd05938ccd8b
Ruby
ekrako/CtCI-6th-Edition-Ruby
/Chap_1_Arrays_and_Strings/Q1_08_Zero_Matrix.rb
UTF-8
399
2.625
3
[ "MIT" ]
permissive
require 'pp' def zero_column(matrix, col_index) matrix.each_with_index do |item, row_index| item[col_index] = 0 end end def zero_matrix(matrix) zMatrix = Marshal.load(Marshal.dump(matrix)) matrix.each_with_index{|row,i| row.each_with_index{|value,j| if value==0 zMatrix[i].map!{|output| out...
true
b864c2b994fae43a3262f89535f32685201b22f8
Ruby
obliviusm/my_enumerable
/my_enumerable.rb
UTF-8
160
3.1875
3
[]
no_license
module MyEnumerable def map new_list = self.class.new self.each { |x| new_list << (yield x) } if block_given? new_list end end
true
af28862f8e289de706d22c90e77e565dcb55ea8c
Ruby
tagirahmad/Ruby
/lesson9/accessors.rb
UTF-8
1,106
2.8125
3
[]
no_license
module Accessors def self.included(base) base.extend ClassMethods end # rubocop: disable Metrics/MethodLength module ClassMethods def attr_accessor_with_history(*names) history_arr = [] names.each do |name| var_name = "@#{name}".to_sym history_var_name = "@#{name}_history".t...
true
f70e590f78ccf3274692ddc18b4907e8932a685b
Ruby
cielavenir/procon
/hackerrank/bon-appetit.rb
UTF-8
106
2.5625
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby n,k,*c=`dd`.split.map(&:to_i) r=c.pop-(c.reduce(:+)-c[k])/2 puts r==0 ? 'Bon Appetit' : r
true
f6040b856b1045d5a23f81461c41e2af1a00f0bb
Ruby
sugaryourcoffee/syc-svpro
/lib/sycsvpro/transposer.rb
UTF-8
2,246
3.25
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Operating csv files module Sycsvpro # Tranposes rows to columns and vice versa # # Example # # infile.csv # | Year | SP | RP | Total | SP-O | RP-O | O | # | ---- | -- | -- | ----- | ---- | ---- | --- | # | | 10 | 20 | 30 | 100 | 40 | 140 | # | 2008 | 5 | 10 | 15 | ...
true
493399e4e66e7815067ba444043ada0b6debe03c
Ruby
bkerley/rong
/rong-server/spec/rong/server/game_spec.rb
UTF-8
2,801
2.828125
3
[]
no_license
require 'spec_helper' describe Rong::Server::Game do let(:game) { Rong::Server::Game.new(800, 600) } context "initialization" do it "expects an x and y dimension" do expect { Rong::Server::Game.new }.to raise_error(ArgumentError) expect { Rong::Server::Game.new(50) }.to raise_error(ArgumentErr...
true
814e6e9b3ac80b8da225d79c337195c058a4754f
Ruby
livash/AppAcademy_work
/w1d7/exam_1/lib/03_fibonacci.rb
UTF-8
315
3.265625
3
[]
no_license
def fibs(fibs_to_ret) return [0] if fibs_to_ret == 1 return [0,1] if fibs_to_ret == 2 return [] if fibs_to_ret == 0 #else build fibs sequence last_number = fibs(fibs_to_ret - 1)[-1] second_to_last_number = fibs(fibs_to_ret - 1)[-2] fibs(fibs_to_ret - 1) + [last_number + second_to_last_number] end
true
a2a397ec4f357cf2785f7599b577e93e393307d5
Ruby
yauhenininjia/computational_methods
/lib/custom_matrix.rb
UTF-8
2,184
3.015625
3
[]
no_license
module CustomMatrix def custom_pretty_print string = '' maxes = array_maxes row_vectors.each do |row| row.each_with_index do |value, index| string.concat " #{value.to_s.rjust(maxes[index])}" end string.concat("\n") end string end def custom_inverse begin ...
true
6e3e8eacf2cab97ab84d6ee73920d74177a2b8f1
Ruby
flyingbird1221/diffj
/src/main/ruby/diffj/ast/imports.rb
UTF-8
2,472
3
3
[]
no_license
#!/usr/bin/jruby -w # -*- ruby -*- require 'diffj/ast/element' module DiffJ class ImportsComparator < ElementComparator IMPORT_REMOVED = "import removed: {0}" IMPORT_ADDED = "import added: {0}" IMPORT_SECTION_REMOVED = "import section removed" IMPORT_SECTION_ADDED = "import section added" def ...
true
c7aca53da14fe6641bb76801572207af09a35cb4
Ruby
pupca/lovecode_shop
/vendor/core_extensions/time.rb
UTF-8
3,874
3.265625
3
[]
no_license
class Time # Create Time object from given object # # Time.from(Time.now) # => 2014-07-03 11:52:29 +0200 # Time.from(Date.today) # => 2014-07-03 00:00:00 +0200 # Time.from(DateTime.now) # => 2014-07-03 11:53:50 +0200 # Time.from('1404381277'...
true
9ea27c9d08835e8d3827f9aa609fbef990997c5e
Ruby
Codaisseur/day4-oop-exercises
/4-1/main.rb
UTF-8
154
2.578125
3
[]
no_license
# ./main.rb require_relative 'space_ship' ship = SpaceShip.new('Millenium Falcon', 'gray') ship.print_details ship.paint('rainbow') ship.print_details
true
db3ece50bad822dd7a75334154f86e068b8b5a8b
Ruby
ellesuzuki/Episode9
/pandas.rb
UTF-8
335
2.984375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'rubygems' require 'bundler/setup' #Bundler.require require 'about-suzuki' puts 'Hello! Thanks for using this gem.' puts suzuki = Suzuki.new puts "The author's name is #{suzuki.name}." puts puts "Her favorite color is #{suzuki.fave_color}, while her favorite food is #{suzuki.fave_food}." puts puts "That's...
true
494657ecb909b834825bc06f5fe1dd5d83463942
Ruby
adriandelarco/week2_ironhack
/Day4/age.rb
UTF-8
106
2.75
3
[]
no_license
class Age def self.calculate(year) year == "" ? 0 : (Time.now.strftime "%Y").to_i - year.to_i; end end
true
e9d424c8d9e56767b337cd47195250c92df64aaa
Ruby
joelbyler/rspec-junklet
/spec/spec_helper.rb
UTF-8
2,240
2.671875
3
[ "MIT" ]
permissive
# spec_helper.rb PROJECT_ROOT=Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), '..'))) require_relative PROJECT_ROOT + "lib" + "rspec" + "junklet" require "pry" require "byebug" # Since we've kept rigidly to 80-columns, we can easily # Do a pretty side-by-side diff here. This won't handle # Line del...
true
bd775fa15d48082fdb2b2a944b8e41deb2c03d9b
Ruby
puneet18190/desy
/spec/lib/autoload/thread_proc_spec.rb
UTF-8
2,204
2.8125
3
[]
no_license
require 'spec_helper' describe ThreadProc do describe '.new' do context 'when initialized with a block' do subject { described_class.new {} } let(:raw_sources) do { close_connection_before_execution_true: "proc do\n CLOSE_CONNECTION_PROC.call\n block.call\n e...
true
fb0c6bd7ba24d2f8b171c02da15f2e4361669d17
Ruby
Jackmt9/programming-univbasics-nds-nds-to-insight-raw-brackets-lab-nyc-web-012720
/lib/nds_extract.rb
UTF-8
1,070
3.234375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'directors_database' require "pry" def directors_totals(nds) # Remember, it's always OK to pretty print what you get *in* to make sure # that you know what you're starting with! # # # The Hash result be full of things like "Jean-Pierre Jeunet" => "22231212312...
true
e6649e29e04ae7c9f7b6928ea21a982b24c1b829
Ruby
i2w/token_generator
/lib/token_generator.rb
UTF-8
714
3.171875
3
[ "MIT" ]
permissive
require "securerandom" require "token_generator/version" module TokenGenerator extend self def token(length = self.length, group_size = self.group_size) token = (1..length).map{ random_char }.join hyphenize(token, group_size) end def hyphenize(input, group_size = self.group_size) return input if ...
true
125515f580733f63b69cba52d899839343b964ee
Ruby
jmanero/net-block
/lib/net/block/address.rb
UTF-8
3,785
2.859375
3
[]
no_license
# frozen_string_literal: true require_relative 'bitset' module Net module Block # An IPv4 network address # class Address ZERO = 0 THIRTY_ONE = 31 THIRTY_TWO = 32 attr_reader :address attr_reader :mask attr_reader :metadata # Construct an Address from a CIDR s...
true
b6350e748d92caea845715d838bc4d6729abe08b
Ruby
rsupak/appacademy2020
/SoftwareEngineeringFundamentals/rspec_exercise_4/lib/part_2.rb
UTF-8
327
3.625
4
[]
no_license
def proper_factors(num) (1...num).select { |n| (num % n).zero? } end def aliquot_sum(num) proper_factors(num).sum end def perfect_number?(num) num == aliquot_sum(num) end def ideal_numbers(n) arr = [] current = 1 while arr.size < n arr << current if perfect_number?(current) current += 1 end a...
true
20a5c7e8fcee1e815fae831bab60768bc587998c
Ruby
katemorris/backend_mod_1_prework
/day_1/exercises/ex3.rb
UTF-8
809
4.4375
4
[]
no_license
puts "I will now count my chickens:" # outputs a line of text puts "Hens #{25.0 + 30.0 / 6.0}" # does some simple math to count hens puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}" # same for roosters puts "Now I will count the eggs:" # text output puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 # maths! puts ...
true
185681bf1176d242023d17e4d706f1dc482c9b26
Ruby
alfonsojimenez/amazon-instance
/lib/amazon-instance/amazon-ec2.rb
UTF-8
2,282
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
require 'AWS' require 'socket' require 'timeout' class AmazonEC2 def initialize(access_key, secret_key, ec2_server, elb_server) @ec2 = AWS::EC2::Base.new(:access_key_id => access_key, :secret_access_key => secret_key, :server => ec2_serve...
true
f932614e518fe82512d7be7218ed5157a3b276e0
Ruby
thanq/Thanq-s-Note
/ruby/ruby.rb
GB18030
1,663
3.625
4
[]
no_license
class MegaGreeter attr_accessor :names def initialize(names = "world") @names = names end def say_hi if @names.nil? puts "..." elsif @names.respond_to?("each") @names.each do |name| puts "HEllo #{name}" end else puts "Hello #{@names} !" end end def say_bye if @names.nil? puts "....
true
066741feed08f9a68e60b9cce68add8f42ed2c47
Ruby
mikel-codes/rubymine
/sortHash.rb
UTF-8
2,979
3.640625
4
[]
no_license
require_relative 'word_char.rb' #require_relative 'sortHash.rb' require 'test/unit' raw_text = %{The problem breaks down into two parts. First, given some text as a string, return a list of words. That sounds like an array. Then, build a count for each distinct word. That sounds like a use for a h...
true
7ead5fb9eba6040d6b44f0226b0a473d91058aa9
Ruby
jcovell/my-first-repository
/workit2/fe10.rb
UTF-8
340
4.125
4
[]
no_license
# 10.C an hash values be arrays? Can you have an array of hashes? (give examples) # Ans1: Yes, hash values can be arrays. # Example: hash = { county1: [Berwick, Eliot, Portsmouth], county2: [York, Wells, others] } # Ans2: Yes, you can have an array of hashes. # Example: array = [ {town: Berwick}, {town: Bridgton}, {:...
true
0650dca6277f0d4ac67b32218f5eee513ac77b3a
Ruby
Hermanverschooten/duration
/lib/duration/time/holidays.rb
UTF-8
345
3.03125
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- class Time module Holidays # Time object for this Christmas. def christmas local(Time.now.year, 12, 25) end # Time object to new years day. def new_years local(Time.now.year + 1, 1) end alias_method :xmas, :christmas alias_method :newyea...
true
503862dd7856896c0d831e5330dc8ef09a2a3d00
Ruby
yggie/minesweeper-ruby
/app/risk_manifold.rb
UTF-8
586
2.9375
3
[ "MIT" ]
permissive
class RiskManifold def initialize end def take_turn(state) cells = state.unexplored_cells.map do |cell| risk_factor = state.cells_around(cell.x, cell.y).inject(1) do |total, neighbouring_cell| if inner_cell.explored? n = state.cells_around(neighbouring_cell.x, neighbouring_cell.y) ...
true
35a75ae67882b999328bc3c433b650d91428050e
Ruby
onigra/gotenyama_trust_bus_api
/app/models/busall.rb
UTF-8
475
2.71875
3
[]
no_license
class Busall include ActiveModel::Model include DateType PLACE_LIST = ["shinagawa", "gotenyama"] validates :from_place, inclusion: { in: PLACE_LIST, message: "Invalid place. Valid place is gorenyama or shinagawa." } attr_accessor :from_place def initialize(from_place) @current_datetime = DateTime.no...
true
53c2669985a6e6a9b4e8e8c4b6e7891c724976d0
Ruby
widygui93/ruby-tutorial
/p062instVarInherit.rb
UTF-8
216
3.59375
4
[]
no_license
class C def initialize @n = 100 end def increase_n @n *= 20 end end class D < C def show_n puts "n is #{@n}" end end d = D.new d.show_n d.increase_n d.show_n d2 = D.new d2.show_n
true
da80a7e2b647f8f5a9c129e605f245f4e7b39a78
Ruby
arekf/repofeed
/app/services/github_api/repo.rb
UTF-8
560
2.671875
3
[]
no_license
# frozen_string_literal: true module GithubAPI class Repo < Base API_URL = 'https://api.github.com' attr_reader :owner, :name def initialize(owner, name) @owner = owner @name = name end def info api_response(api_endpoint) end def commits api_response(api_endpoi...
true
db1b40ec5be0d072de7a26d884798a7493eb15d3
Ruby
hvgaming/collections_practice-v-000
/collections_practice.rb
UTF-8
272
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(num) num.sort do|a,b| a <=> b end end def sort_array_desc(num) num.sort {|a,b| -(a <=> b)} end def sort_array_char_count(string) string.sort do |a,b| a.length <=> b.length end end def swap_elements(array) end end
true
a534ed1a8596dd5c25f3017fdb44979c7aeadb8b
Ruby
sorah/emony
/lib/emony/output_router.rb
UTF-8
1,113
2.765625
3
[ "MIT" ]
permissive
require 'thread' require 'emony/utils/operation_threadable' require 'emony/outputs' require 'emony/tag_matching/matcher' module Emony class OutputRouter include Emony::Utils::OperationThreadable def initialize(outputs) @outputs = initialize_outputs(outputs) @matcher = TagMatching::Matcher.new(ou...
true
16965bd3204c92706cb4544072dbfd86e0f6cd5c
Ruby
karino-minako/paiza-d-quick-solution-set
/shoe-size.rb
UTF-8
526
3.71875
4
[]
no_license
# ้ดใฎใ‚ตใ‚คใ‚บ่กจ่จ˜ใซใฏใ€ไธ€่ˆฌ็š„ใช cm(ใ‚ปใƒณใƒใƒกใƒผใƒˆใƒซ)ใฎ่กจ่จ˜ไปฅๅค–ใซใ€USใ‚ตใ‚คใ‚บใจUKใ‚ตใ‚คใ‚บใŒใ‚ใ‚Šใพใ™ใ€‚ # ใƒกใƒณใ‚บใฎ้ดใฎๅ ดๅˆใ€ # ใƒปUSใ‚ตใ‚คใ‚บใฏใ€cmใฎ่กจ่จ˜ใ‹ใ‚‰18ใ‚’ๅผ•ใ„ใŸใ‚‚ใฎ # ใƒปUKใ‚ตใ‚คใ‚บใฏใ€cmใฎ่กจ่จ˜ใ‹ใ‚‰18.5ใ‚’ๅผ•ใ„ใŸใ‚‚ใฎ # ใจใ—ใฆๆฑ‚ใ‚ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚ # cmใง่กจใ•ใ‚ŒใŸใƒกใƒณใ‚บ้ดใฎใ‚ตใ‚คใ‚บใ‚’ใ€USใ‚ตใ‚คใ‚บใจUKใ‚ตใ‚คใ‚บใซๅค‰ๆ›ใ—ใฆๅ‡บๅŠ›ใ—ใฆใใ ใ•ใ„ใ€‚ line = gets.to_f us = line - 18 uk = line - 18.5 puts "#{us} " + "#{uk}"
true
05bdd34ca954a098cf85eb891ace6d3947fb0420
Ruby
smeds1/Ruby_Practice
/Unit5/stat.rb
UTF-8
732
3.890625
4
[]
no_license
#Sam Smedinghoff #3/13/18 #stat.rb #find mode of a list of numbers def mode(nums) most = 0 mostN = 0 last = 0 count = 0 nums.each do |n| if n == last count += 1 else if most < count most = count mostN = last end count = 1 last = n end end return m...
true
bb79a62e12491b2161c2b7fb75ac1f3ee0089d46
Ruby
si405/BART_upstream
/bart_upstream/app/controllers/bartjourneys_controller.rb
UTF-8
5,233
2.671875
3
[]
no_license
class BartjourneysController < ApplicationController include BartjourneysHelper def new @bartstations = get_station_names_DB @bartjourney = Bartjourney.new end # Create a new journey using the params provided from # the view and redirect back to the main index page def create @bartjourney = Bartjourney.n...
true
63ce7f75f3a00acefd42fe6bd28001e1cbf483b6
Ruby
aturkewi/object-relations-assessment-assessment-test
/app/models/customer.rb
UTF-8
663
3.203125
3
[]
no_license
class Customer attr_accessor :first_name, :last_name @@all = [] def initialize(name) @first_name = name.split(" ")[0] @last_name = name.split(" ")[1] @@all << self end def self.all @@all end def self.find_by_name(full_name) all.find{|customer| customer.full_name == full_name} ...
true
eeacc356a2b8c8b3278431c0518cc288148e90af
Ruby
brettapeters/exercism-ruby
/rna-transcription/rna_transcription.rb
UTF-8
446
3.546875
4
[]
no_license
# RNA Transcription. A program that takes a DNA nucleotide sequence and # returns its RNA complement. class Complement VERSION = 2 def self.of_dna(dna) fail ArgumentError unless dna.match('^[GCTA]+$') dna.gsub(/[GCTA]/, 'G' => 'C', 'C' => 'G', 'T' => 'A', 'A' => 'U') end def self.of_rna(rna) fail...
true
19ff3fcf1a1296cb6ec7f036a968f026da5d0995
Ruby
mark-bah/sailfishScripts
/Romo/Scraper.rb
UTF-8
803
2.953125
3
[]
no_license
require 'ckan' #Dir["/Users/markpileggi/Documents/workspace/ckan/lib/ckan/*.rb"].each {|file| require file } class Scraper attr_accessor :line attr_accessor :hash attr_accessor :hashList def initialize @hash = Hash.new @hashList = [] puts "initializing app: #{@line}" end def cre...
true
deda381b71a40f80e6e43b5972ea76fd4caecff7
Ruby
colinxfleming/github_clawgrabber_ruby
/lib/github_clawgrabber/fetcher.rb
UTF-8
1,402
2.71875
3
[ "MIT" ]
permissive
require 'httparty' module GithubClawgrabber # Handle Github GraphQL interactions class Fetcher GITHUB_GRAPHQL_ENDPOINT = 'https://api.github.com/graphql'.freeze class << self def fetch(auth_token, repo, filepath, branch) response = make_api_call auth_token, repo, filepath, branch con...
true
ee721b6bd6bff5b864f23446abd75119a9e01fc9
Ruby
mrjabba/gitlish
/delish_reformat.rb
UTF-8
428
2.78125
3
[]
no_license
require 'nokogiri' class Delishreformat def initialize(*args) puts "start" @file_path = "delicious-20101217.htm" f = File.open(@file_path) doc = Nokogiri::XML(f) nodes = doc.xpath("//DT/A") nodes.each { |element| puts "<bookmark><title>#{element.text}</title><url>#{element['HREF']}</url...
true
23f01f673899456e946f7c6c94ae32fca9262bb2
Ruby
ahmadr9279/05-jukebox-cli-lab
/lib/jukebox.rb
UTF-8
911
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
songs = [ "Phoenix - 1901", "Tokyo Police Club - Wait Up", "Sufjan Stevens - Too Much", "The Naked and the Famous - Young Blood", "(Far From) Home - Tiga", "The Cults - Abducted", "Phoenix - Consolation Prizes", "Harry Chapin - Cats in the Cradle", "Amos Lee - Keep It Loose, Keep It Tight" ] def list...
true
7b00709465cfa85a80f7d1eceeedaa891301ec67
Ruby
JE27/contacts-client
/contacts_controller/contacts_controller.rb
UTF-8
2,645
2.59375
3
[]
no_license
module ContactsController def contacts_index_action response = Unirest.get("http://localhost:3000/contacts") contacts = response.body puts JSON.pretty_generate(contacts) end def contacts_create_action print "Enter contact ID" input_id = gets.chomp response = Unirest.get("http://lo...
true
a705f1c5f921b30b0155be8ca6df55b43b3b4026
Ruby
justinlecc/playogo-ice-booking
/lib/date_time_formatter.rb
UTF-8
1,426
3.625
4
[]
no_license
class DateTimeFormatter def initialize() @short_months = ['Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec'] end def shortToMidDateStr(date) date_a = date.split('-') if date_a.length != 3 raise "ERROR: date string did not contain 3 components in DateTimeFormatter::sho...
true
b61b055d77955410d3c36b600cae64c65f273a0f
Ruby
macsrok/CloudApp---Code-sample
/app/services/asset_scrape_service.rb
UTF-8
2,205
2.96875
3
[]
no_license
## This Service is takes a url an array of media types on initialization # It then parses the html page at the provided URL and scrapes out the URLS for each of the assets. class AssetScrapeService require 'open-uri' require 'uri' require 'mimemagic' ASSET_TAGS = %w( img video svg script link ).join(', ') d...
true
d2129db622ca4716507bb29490fbf6a0b9bdff1d
Ruby
00mjk/interview-cake
/CompressURLList/compress_url_list.rb
UTF-8
182
2.71875
3
[ "MIT" ]
permissive
class CompressURLList def initialize @visited = {} end def visit_url(url) host = URI::parse(url).host return if @visited[host] @visited[host] = true end end
true
020b3e6b608a5afbbfd9c4b6b003914f322df86f
Ruby
extremeboredom/pubtrip
/test/unit/member_test.rb
UTF-8
1,881
2.84375
3
[]
no_license
require 'test_helper' class MemberTest < ActiveSupport::TestCase test "group is required" do member = Member.new assert member.invalid? assert_equal ["can't be blank"], member.errors[:group] end test "user is required" do member = Member.new assert member.invalid? assert_equal ["can't be...
true
7f400d13dd4cd0004bc844bc0e5f531c1909769c
Ruby
krsnachandra/learning-light
/server/app/models/course.rb
UTF-8
945
2.546875
3
[]
no_license
class Course < ApplicationRecord belongs_to :instructor has_many :chapters has_many :sections, through: :chapters has_many :all_reviews, class_name: 'Review' def reviews all_reviews.where({show_flag: true}) end def for_user(user_id) sections = sections_for_user(user_id) section_count = sec...
true
27c7315ee2a016587ff9df052cdf12726df1ed70
Ruby
sleepingkingstudios-archive/examples-records
/lib/person.rb
UTF-8
537
3.171875
3
[]
no_license
# lib/person.rb require 'record' # Data class for storing information about a person. class Person < Record attributes *%w(last_name first_name middle_initial gender date_of_birth favorite_color).map(&:intern) # @return [String] The person's gender in full string format. Can return # "Female", "Male", ...
true
851c601e55de775261a2cf6a7a68aaa401731e58
Ruby
GyozaGuy/GyozaGuyAPI
/spec/models/post_spec.rb
UTF-8
4,448
2.609375
3
[]
no_license
require 'spec_helper' describe Post do let(:post) { FactoryGirl.build :post } subject { post } it { should respond_to(:title) } it { should respond_to(:time) } it { should respond_to(:content) } it { should respond_to(:published) } it { should respond_to(:user_id) } # it { should not_be_published } #...
true
c30ea2ca2e7bd8b2d6001e3671260525e0401bc4
Ruby
sharanchavadi/Ruby-Exersises
/api_requests.rb
UTF-8
1,971
2.96875
3
[]
no_license
require 'httparty' require 'JSON' require 'pry' url = "http://localhost:3000/api/v1/states" response = HTTParty.get("#{url}") states = JSON.parse(response.body) puts "The states and codes are :" states.each do |state| puts "#{state["code"]} - #{state["name"]}" end puts "Enter the code to find the state" state_c...
true
ce5ed6f1231e3e475ffb555df4522bb54d395b3a
Ruby
kariya/TVS2-hikaritv
/TVS/Plug-In/hikaritv/record.rb
UTF-8
191
2.703125
3
[]
no_license
f = open(ARGV[0], "r") while (line = f.gets) if (line =~ /.*\[.*\]$/) crid = line.sub(/^.*\[/, "").sub(/\]$/, "") print "SET CRID=" + crid break end end
true
dfdce1c6fb6a8577c0e2598496c9ebb919a4bfbc
Ruby
rvt-tex/programming-univbasics-4-array-simple-array-manipulations-online-web-prework
/lib/intro_to_simple_array_manipulations.rb
UTF-8
814
3.28125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def artist = [" nickleback", "ariana", "usher", "dmx"] next_artist = "jay-z" artist.push(next_artist) end def artist = [" nickleback", "ariana", "usher", "dmx"] next_artist = "max" artist.unshift end def artist = [" nickleback", "ariana", "usher", "dmx"] usher_artist = artist.pop end #pop_with_arg def ...
true
75e8005bbb83ea0030d2af1a3a9adfd37c4aa9d8
Ruby
dzackgarza/coursera_saas
/hw_one/hw_one_part_2.rb
UTF-8
1,362
4.0625
4
[]
no_license
# Part 2 class WrongNumberOfPlayersError < StandardError ; end # Raised when strategy is not 'R', 'P', or 'S' class NoSuchStrategyError < StandardError ; end # Given a two element list, return the name and strategy of the winning player. def rps_game_winner(game) raise WrongNumberOfPlayersError unless game.length ==...
true
f7dd8588526d5b5dde9dad3c970fd2b160671a85
Ruby
transitland/transitland-datastore
/app/controllers/concerns/jwt_auth_token.rb
UTF-8
805
2.515625
3
[ "MIT" ]
permissive
# https://github.com/jimjeffers/rails-devise-cors-jwt-example/blob/master/lib/auth_token.rb module JwtAuthToken extend ActiveSupport::Concern SIGNING_ALGORITHM = 'HS256' def self.issue_token(payload) payload['exp'] = 24.hours.from_now.to_i # Set expiration to 24 hours. JWT.encode(payload, Rails.applica...
true
6912d6ce7589d860eabb89cb6f62b2466eb0a566
Ruby
byverdu/boris_bikes
/lib/bike.rb
UTF-8
866
3.265625
3
[]
no_license
class Bike attr_reader :serial_number attr_accessor :rent_time, :return_time $bikes = [] def serial_number_generator sn = ("A".."Z").to_a.sample(3).join indicative1 =(0..9).to_a.sample(3).join indicative2 =(0..9).to_a.sample(2).join indicative3 =(0..9).to_a.sample(5).join "#{sn} #{indicative1}-#{ind...
true