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
b1d13ff0cda372e0a0eb3f52cc7aecf7f3ec5678
Ruby
chriseppstein/archetype
/lib/archetype/actions/theme.rb
UTF-8
2,384
2.546875
3
[ "Apache-2.0" ]
permissive
description = "Generate a new Archetype theme" if @description.nil? options = { :extends => Archetype.name } OptionParser.new do |opts| opts.banner = description opts.define_head "Usage: #{Archetype.name} theme [path] [options]" opts.separator "" opts.separator "Example usage:" opts.separ...
true
13cbc06e27f14ae7b62a592f038764d41a71e184
Ruby
mlipper/runt
/test/scheduletest.rb
UTF-8
4,624
2.53125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#!/usr/bin/env ruby require 'minitest_helper' # Unit tests for Schedule classes # Author:: Matthew Lipper class ScheduleTest < MiniTest::Unit::TestCase include Runt def setup # Jane is very busy these days. @sched=Schedule.new # Elmo's World is on TV: Mon-Fri 8am-8:30am @elmo=Event.new("Elmo's W...
true
dcf965a8d11a1af91ec328bdf4da4b8c649d8207
Ruby
simple/My-QRoo
/myqroo.rb
UTF-8
1,490
2.65625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
require 'rubygems' require 'sinatra' require 'qroo' include Qroo before do headers "Content-Type" => "text/html; charset=utf-8" end get '/' do @title = "My-QRoo, Login Information" erb :form end post '/' do @title = "Your QRooQRoo barcode scan history" client = QrooClient.new(params[:loginid], @params[:p...
true
a745d834f5919d78a970d410d8ce4c13d1e7f883
Ruby
thesteady/traffic_spy
/spec/traffic_spy/model/event_spec.rb
UTF-8
2,534
2.796875
3
[ "MIT" ]
permissive
require 'spec_helper' require 'rspec' require 'rack/test' describe TrafficSpy::Event do include Rack::Test::Methods def app TrafficSpy::Event end describe "Class method" do let(:e1) do {:name => "sociallogin", :site_id => 1} end let(:e2) do {:name => "log_in", :site_id => 2} ...
true
b905112bb85e22414e98cb75f3fff76df87711f8
Ruby
danielbispos/dbsqafullstack
/basico/hashes.rb
UTF-8
434
3.4375
3
[]
no_license
# HASH é uma coleção de dados que se parece com ARRAYS, porém indexada por chave-valor ao invés de inteiros carro = Hash[nome: 'Civic', marca: 'Honda', cor: 'Vermelho'] #puts carro # É possível acessar as informações através das chaves puts carro[:marca] # Pode-se criar uma nova chave em outro setor do código - ate...
true
dc10b0e4c15bff05b67c0e15a773877d2545369b
Ruby
Ronaq13/scraping
/app/models/url.rb
UTF-8
795
2.75
3
[]
no_license
class Url < ApplicationRecord include Parser has_many :h_one, dependent: :destroy has_many :h_two, dependent: :destroy has_many :h_three, dependent: :destroy validates :link, presence: true, uniqueness: true, format: { with: URI::regexp(%w[http https]), message: 'URL provided was in-valid' } va...
true
7d10470ada703045c6abff13244b7553e4818c56
Ruby
itggot-Emanuel-Strom/standard-biblioteket
/lib/max_of_two.rb
UTF-8
124
2.890625
3
[]
no_license
def max_of_two(num1, num2) if num1 > num2 max = num1 else max = num2 end return max end
true
6a8b69dcee7e0acef09833523b52dcadb0b52b0c
Ruby
Racibor72/cacl_lab
/Pytha_Theo_Calc.rb
UTF-8
749
3.296875
3
[]
no_license
#input puts "Enter in the Data for each Variable, if unknown leave blank" puts "What is the value of A?" a = gets.chomp puts "What is the value of B?" b = gets.chomp puts "what is the value of C?" c = gets.chomp #operation if a == "" && b != "" && c != "" b_squared = b.to_f**2 c_squared = c.to_f**2 a_squared = ...
true
d9d462e726287550323469985dfc1fad5c767201
Ruby
SanaJoshi/Exercises
/sites1/classesobject.rb
UTF-8
315
2.859375
3
[]
no_license
#create a person app. class Personfactory #how do we describe it def initialize(name, personaity, age, haircolor) @name = name @personality = personality @age = age @haircolor = haircolor end #what can it do def name (name) @name = name end def talk(sentence) sentence end end
true
70eec4cc8287771904a43ef85e315e18e0987735
Ruby
at-point/porro
/spec/porro/types/collection_spec.rb
UTF-8
2,678
2.59375
3
[ "MIT" ]
permissive
require 'spec_helper' require 'support/shared_type' require 'support/type_matchers' require 'support/models' require 'porro/types' require 'porro/types/collection' RSpec.describe Porro::Types::Collection do subject { Porro.collection(Email) } it_behaves_like 'a Type', supports: false let(:personal) { Email.new...
true
bf57498c7b41c4ae7f9467c37ef9075320f4289f
Ruby
larshollingsed/07-16-activerecord_atomics
/models/photo.rb
UTF-8
554
2.671875
3
[]
no_license
class Photo < ActiveRecord::Base belongs_to :photographer has_and_belongs_to_many :albums validates :name, presence: true def top_photo? self.albums.length >= 3 end def self.top_photos top_photos = [] self.all.each do |photo| if photo.top_photo? top_photos << photo e...
true
017e8abc6ce0e69d65c3df887346c276bb27c34b
Ruby
JLeech/exon_grouper
/exon_grouper.rb
UTF-8
9,681
2.53125
3
[]
no_license
require "csv" require "json" require "set" require_relative "exon.rb" require_relative "organism.rb" require_relative "data_processor" require_relative "cat_cat_matcher.rb" require_relative "common.rb" class ExonGrouper attr_accessor :path_to_file attr_accessor :path_to_alignment attr_accessor :percent att...
true
b1bf16bbe5dd4254a79102f23d0b153adca2f18f
Ruby
dekom/random-scripts
/ruby/rename.rb
UTF-8
2,606
3.015625
3
[]
no_license
#!/usr/bin/env ruby # encoding: utf-8 require 'optparse' require 'optparse/time' require 'ostruct' require 'pp' class Optparse CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary] CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" } # # Return a structure describing the options. # def self.p...
true
342529ef27bbfe542aa958b7f344a204f3c9de8d
Ruby
milevy1/ruby-exercises
/initialize/test/quail_test.rb
UTF-8
434
2.84375
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/quail' class QuailTest < Minitest::Test def test_it_exists quinn = Quail.new("Quinn") assert_instance_of Quail, quinn end def test_it_has_a_name quinn = Quail.new("Quinn") assert_equal "Quinn", quinn.name end def test_it_wil...
true
e6f4807d26d2a6595de925c0a6ba6a3575b51dba
Ruby
mstashev/Testing-1
/tea.rb
UTF-8
409
3.46875
3
[]
no_license
class Tea attr_accessor :tea, :full, :empty, :drinks def initialize(tea, drinks = 4, full = true, empty = false) @tea = tea @full = full @empty = empty @drinks = drinks end def full? if @drinks == 4 true else false end ...
true
fc3824a10a8170d3210ce7906c5a1db2e43ae745
Ruby
bmader6406/bozzuto-old
/test/unit/bozzuto/neighborhoods/filterer_test.rb
UTF-8
4,518
2.546875
3
[]
no_license
require 'test_helper' class Bozzuto::Neighborhoods::FiltererTest < ActiveSupport::TestCase context 'A neighborhoods filterer' do described_class = Bozzuto::Neighborhoods::Filterer before do # neighborhood # - community_1 # - rapid_transit # - community_2 # - non_smo...
true
14825914e4960812521a2049fdf76573388b46a0
Ruby
socialchorus/intramural
/lib/intramural/decoder.rb
UTF-8
299
2.640625
3
[ "MIT" ]
permissive
module Intramural class Decoder attr_reader :message def initialize(message, logger) @message = message end def perform JSON.parse(message) rescue JSON::ParserError logger.error "ERROR: Unable to process as json: #{message}" message end end end
true
bc0c31f13937845cc60c414e68501967b6d76f42
Ruby
Snowballx/Test
/math.rb
UTF-8
615
4.28125
4
[]
no_license
# Maths puts sum = 13 + 379 puts product = 923 * 15 puts quotient = 13209 / 17 #Quotient means 'divide' my_name = "Doug".downcase.reverse.upcase #CHAIN CALLS puts my_name print "Integer please: " user_num = Integer(gets.chomp) if user_num < 0 puts "You picked a negative integer!" elsif user_num > 0 puts "You pic...
true
352b04cb6dcf219d168367870f4e0cf1cf0a2095
Ruby
Zibby/datadog_database_statsd
/main.rb
UTF-8
3,897
2.671875
3
[]
no_license
#!/usr/bin/env ruby # frozen_string_literal: true require "datadog/statsd" require "pg" require "yaml" require "logger" require "socket" require "timeout" require 'pry' LOGGER = Logger.new(STDOUT).freeze TIMEOUT = 500 # Time SQL queries can run for before timeing out in seconds LOGGER.info "Logger initiated" # Create...
true
dfbac003bfe185704df087b5af368893adc0394c
Ruby
wolox-training/mr-automation-rails
/features/step_definitions/invalid_form.rb
UTF-8
719
2.6875
3
[]
no_license
# Leave form fields empty When('I leave the {string} field empty') do |field| wait_for_element_to_be_ready(:id, field) enter_text(:id, '', field) end And('I click some other field') do wait_for_element_to_be_ready(:id, 'unauth_container') click(:id, 'unauth_container') end # Fill form fields with invalid inf...
true
59833e8a7572bf73ca02648f917a4def8068a5aa
Ruby
RaYu147/gozilla
/spec/models/account_spec.rb
UTF-8
580
2.625
3
[]
no_license
require 'rails_helper' describe Account do describe '#pass=' do example 'p.145<パスワード暗号化>文字列を与えると、passwordは長さ60の文字列になる' do account = Account.new account.pass = 'ga' expect(account.password).to be_kind_of(String) expect(account.password.size).to eq(60) end example '<パス...
true
0ed05381a39b13fa428cbed89ca28981447bae6b
Ruby
bookinstock/bookinstock
/play/foo.rb
UTF-8
631
3.265625
3
[]
no_license
require 'ostruct' $a = 0 def start $a += 1 OpenStruct.new(key: "start", value: $a) end def stop $a += 1 OpenStruct.new(key: "stop", value: $a) end a = [stop, start, stop, start, start, stop, stop, start, start, start, stop, start] # 2, 3, 4, 6, 8, 11 tmp = "stop" b = [] a.each do |e| if e.key != tmp ...
true
196258b95ae550599ade59cc4a5f13401220fda1
Ruby
yogeshmuthuraj/karmayogi
/app/controllers/concerns/home_concern.rb
UTF-8
3,932
2.796875
3
[]
no_license
# frozen_string_literal: true module HomeConcern include ApplicationHelper def leaderboard(team_id, current_user) leaderboard_message = "\n\n<h1>Leaderboard</h1>\n\n" not_in_board = 'you are not on the board yet, he he.' current_user_in_board = User.exists?(team_id: team_id, user_id: current_user[:id]...
true
3fd853879a4eecfb206680f0b1755e6d99d6309d
Ruby
ccroal/weekend_homework_week_2
/specs/room_spec.rb
UTF-8
2,693
3.296875
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../room.rb') require_relative('../guest.rb') require_relative('../song.rb') class RoomTest < MiniTest::Test def setup() song1 = Song.new("Common Peopl", "Pulp") song2 = Song.new("Material Girl", "Madonna") song3 = Song.new("Wait and Bl...
true
f9c06c98713511b864859845168cefaafb9f5312
Ruby
quintproquo/ruby-music-library-cli-cb-000
/lib/mp3_importer.rb
UTF-8
345
3
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class MusicImporter attr_accessor :path, :filenames def initialize(path) @path = path @filenames = [] end def files dir = Dir.new(self.path) dir.each {|e| self.filenames << e if e[".mp3"] == ".mp3"} self.filenames end def import self.files.each {|e| Song.create_from...
true
8c162112ed805a9abbd3337ad4e09256f0b372e9
Ruby
Xitog/tallentaa
/ruby/thread/testThread.rb
UTF-8
871
3.234375
3
[]
no_license
# type nomVar; # int a; # int * b = NULL; # int * * c; # *(&a) = a # float d = (float) 5; # int * a = (int *) malloc(sizeof(int)); # *a = 5 # Thread::new x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" } a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" } x.join # Let the ...
true
9e6f96c28da0ab1bf113a9dc3cff1922e883f9a2
Ruby
Fingertips/attribute-decorator
/test/test_helper.rb
UTF-8
3,230
2.78125
3
[ "MIT" ]
permissive
module AttributeDecorator module Initializer VENDOR_RAILS = File.expand_path('../../../../rails', __FILE__) OTHER_RAILS = File.expand_path('../../../rails', __FILE__) PLUGIN_ROOT = File.expand_path('../../', __FILE__) def self.rails_directory if File.basename(File.dirname(PLUGIN_ROOT)) == '...
true
aad289ba2d226849d5cf61c15060fd5c8a720dfc
Ruby
mmcnickle-float/aoc2020
/day6/declarations.rb
UTF-8
378
2.8125
3
[]
no_license
# frozen_string_literal: true require 'set' module Declarations def self.num_questions_answered(group_declaration) Set[*group_declaration.join.chars].count end def self.num_questions_everyone_answered(group_declaration) questions_sets = group_declaration.map do |declaration| Set[*declaration.char...
true
b9bbc63c755d71bf47dfb3c57dc1e5a8de0c4977
Ruby
npatel007/Computer-Science-Notes
/Ruby/RubyLect3.progs/-_RubyLect3.progs/people.rb
UTF-8
339
3.5
4
[]
no_license
########### # PEOPLE ## Copyright Mark Keane, All Rights Reserved, 2013 class Person def fname @fname end def give_fname(name) @fname = name end def lname @lname end def give_lname(name) @lname = name end end inst1 = Person.new inst1.give_fname("mark") inst1.give_lname("keane") #pu...
true
53b327679f35c7b13a6e6ff729ce50d2c7fcd899
Ruby
bwreid/rails-practice
/planets-2013-02-12/app/models/planet.rb
UTF-8
513
2.546875
3
[]
no_license
# == Schema Information # # Table name: planets # # id :integer not null, primary key # image :text # name :string(255) # orbit :float # diameter :float # mass :float # moons :integer # class Planet < ActiveRecord::Base # THIS ACCESSES A CLASS THAT HAS TONS OF FUNCTIONALITY THAT ...
true
c8398c027df32532eeaba5c5bd136c17b599017f
Ruby
CjMoore/headcount
/test/statewide_test_repository_test.rb
UTF-8
2,076
2.609375
3
[]
no_license
# require 'simplecov' # SimpleCov.start require 'minitest/autorun' require 'minitest/pride' require_relative '../../headcount/lib/statewide_test_repository' class StatewideTestRepositoryTest < MiniTest::Test def test_statewide_repository_can_gather_data_by_district str = StatewideTestRepository.new input_d...
true
ad21001ca0c51be9649f8c21a2f99d78adc20589
Ruby
cloudfoundry/uaa-release
/docs/mock_property.rb
UTF-8
1,027
2.90625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class MockProperty attr_reader :name def initialize(name) @name = name.kind_of?(Array) ? name[0] : name end def [](key) MockProperty.new("#{name}.#{key}") end class FindElem def [](key) @key = key @capt = FindCapt.new @capt end attr_reader :key, :capt end class...
true
4aa1de73848cc29bfb59eac53183c4e5d5c85f71
Ruby
tommetge/neverpix
/test/test_event.rb
UTF-8
1,824
2.65625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'test/unit' require 'bundler/setup' require 'leveldb' require 'securerandom' require_relative '../lib/photo' require_relative '../lib/event' class TestEvent < Test::Unit::TestCase def setup @db_path = Dir.mktmpdir @db = LevelDB::DB.new(@db_path) end def teardown @db.cl...
true
39dd0ca646d2efdd0d19bcaf6b85a07cbe8a2871
Ruby
achmorgill/week2day3lab
/specs/game_lab_spec.rb
UTF-8
1,500
3.34375
3
[]
no_license
require ('minitest/autorun') require ('minitest/rg') require_relative('../game_lab.rb') require_relative('../dice.rb') require_relative('../player.rb') class TestGame < MiniTest::Test def setup @player1 = Player.new("Fred") @player2 = Player.new("Jane") @player3 = Player.new("Dave") @game = Game.n...
true
19a857bc32567c4ee701dfdb9f5b9b278c1e5c19
Ruby
jimweirich/presentation_ynot
/src/y32.rb
UTF-8
564
2.734375
3
[]
no_license
puts ->() { # Fixpoint # Higher Order Functions # Functional refactorings # (1) Tennent Coorespondence Principle # (2) Introduce Binding # (3) Rebind # (4) Wrap function # (5) Inline Definition # Recursive Functions error = ->(n) { fail "SHOULD NOT BE CALLED" } fact_improver = ->(partial) { ...
true
e2ece2abae08eecf702152cfb444dc1d3e5be863
Ruby
dleidert/sololearn
/Popsicles.rb
UTF-8
212
2.90625
3
[ "Unlicense", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#!/usr/bin/ruby siblings = STDIN.gets.chomp.to_i popsicles = STDIN.gets.chomp.to_i i = popsicles % siblings if i == 0 then puts "give away" else puts "eat them yourself" end # vim: set ts=2 sw=2 ai si et:
true
062a8990951859a87ac25450383492adc29ef139
Ruby
th0r0nd0r/Homeworks
/w2d5/LRU_cache.rb
UTF-8
402
2.984375
3
[]
no_license
class LRUCache def initialize(max_length = 5) @cache = [] @max_length = max_length end def count @cache.count end def add(el) if cache.include?(el) cache.delete(el) elsif count == @max_length @cache.pop end @cache.unshift(el) end ...
true
b7d51d0998679ed23c2d43d8182e30dbfd2cae12
Ruby
Sufl0wer/summer-2019
/3711/1/top_gems.rb
UTF-8
734
2.90625
3
[]
no_license
require_relative 'scanner/shell' require_relative 'scanner/yaml' require_relative 'parser/repo' require_relative 'rating' require_relative 'printer' args = Scanner::Shell.new.scan gem_names = Scanner::Yaml.new(args[:file]).scan return puts "Can't find any gems" if gem_names.empty? names_to_parse = args[:name] ? gem_...
true
c57d5ff328449a5bfd1cc57d464c4f06de34b6cb
Ruby
allmende/pluginGeek
/app/controllers/submissions_controller.rb
UTF-8
1,535
2.828125
3
[ "MIT" ]
permissive
class SubmissionsController < ApplicationController # Handle submission of links and repos # GET /submit?url=...&title=... def submit # Redirect if :url is missing url_provided? or return redirect_to_root_path # Is a github repo being submitted? if github_repo? # Is the repo already listed?...
true
ea60883eeb86305b13bcfb115e6cfefeb9ea3d55
Ruby
evilosa/thinknetica
/lesson03/models/railway_carriage/railway_carriage.rb
UTF-8
399
3.03125
3
[]
no_license
require_relative '../../modules/manufacturer' require_relative '../../modules/number_searchable' class RailwayCarriage include Manufacturer include NumberSearchable def initialize(number = 0) @number = number.to_s end def check_carriage puts 'Default check completed successfuly!' end def type ...
true
6e149434f6df9f7b48765124f273a735f725a5f9
Ruby
sschuberth/dev-scripts
/bundle/ruby/gems/gerry-0.1.2/lib/gerry/client/request.rb
UTF-8
2,885
2.53125
3
[ "MIT" ]
permissive
module Gerry class Client module Request # Get the mapped options. # # @param [Array] or [Hash] options the query parameters. # @return [String] the mapped options. def map_options(options) if options.is_a?(Array) options.map { |v| "#{v}" }.join('&') elsif o...
true
d8ae419f2baba2899adcc3da9a969311496cbc0a
Ruby
IgoVeyner/regex-lab-onl01-seng-pt-061520
/lib/regex_lab.rb
UTF-8
552
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' # updated with ternary statements def starts_with_a_vowel?(word) word.match(/^[aeiouAEIOU]/) ? true : false end def words_starting_with_un_and_ending_with_ing(text) text.scan(/un\w+ing/) end def words_five_letters_long(text) text.scan(/\b[a-zA-Z]{5}\b/) end def first_word_capitalized_and_...
true
8c727424a702158163f8b964afa990a711e1a796
Ruby
VadikVadik/black_jack
/game.rb
UTF-8
3,645
3.171875
3
[]
no_license
# frozen_string_literal: true class Game attr_accessor :bank, :players, :card_deck attr_reader :player, :dealer def initialize(player, dealer) @player = player @dealer = dealer @bank = 0 @players = [player, dealer] @card_deck = [ { nominal: 2, title: "2+" }, { nominal: 2, title: "2<3" ...
true
95f0bd0f0b81ad2b6fe5e4f8a22fbbdaeec39362
Ruby
ChuckBTaylor/oo-tic-tac-toe-bootcamp-prep-000
/lib/tic_tac_toe.rb
UTF-8
1,963
4.0625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe def initialize(board = nil) @board = board || Array.new(9," ") end def display_board puts " #{@board[0]} | #{@board[1]} | #{@board[2]} " puts "-----------" puts " #{@board[3]} | #{@board[4]} | #{@board[5]} " puts "-----------" puts " #{@board[6]} | #{@board[7]} | #{@board[...
true
59ef0d238f9729cfd7e2ad0456db8a2eeefe4b11
Ruby
Fdoperezg/rentabilidad
/emprendedor2.rb
UTF-8
274
2.6875
3
[]
no_license
p = ARGV[0].to_i nu = ARGV[1].to_i up = ARGV[2].to_i ug = ARGV[3].to_i g = ARGV[4].to_i utilidades = (p*(nu+(up*2)+(ug*0))-g) if utilidades > 0 puts "Las utilidades, luego de aplicado el 35% de impuesto, son #{utilidades * 65/100}" else puts "Tiene pérdidas" end
true
6b4f72fd6c4d6a5cde44b082ab17cb37ce9bed93
Ruby
brokerad/payps14
/lib/paypersocial/url_validator.rb
UTF-8
764
2.703125
3
[]
no_license
module Paypersocial class UrlValidator class << self def is_valid?(url) is_well_formatted?(url) && is_alive?(url) end def is_well_formatted?(url) url =~ Paypersocial::Constants::URL_PATTERN end def is_alive?(url) begin parsed_url = URI.parse(url) ...
true
cb9f93b5090f7467796f907cb7c719cf178713f6
Ruby
desertwinds/code_advent_2020
/day 2/code.rb
UTF-8
1,324
3.28125
3
[]
no_license
valid_passwords = [] invalid_passwords = [] puts "Enter option 1 or 2 for the puzzle solution" type = gets.chomp.to_i if type < 1 || type > 2 puts "Sorry, can't handle that type, only allowed value is 1 or 2" return end File.foreach("input.txt") do |password_line| /(?<lower>\d+)-(?<highest>\d+) (?<constraint>.)...
true
c21a98b05001b9d81746ff6bc808b319172db4b9
Ruby
roseak/sales_engine
/lib/invoice.rb
UTF-8
1,199
2.921875
3
[]
no_license
class Invoice attr_reader :id, :customer_id, :merchant_id, :status, :created_at, :updated_at, :repository def initialize(row, repository) @id = row[:id].to_i @customer_id = row[:customer_id].to_i @merchant_id =...
true
2ca3a3aa1cdaf0b33e0c5a0aec2428bbcc40588f
Ruby
jsymons/the-odin-project
/02_web_development_101/test-first-ruby/02_calculator/calculator.rb
UTF-8
408
3.859375
4
[]
no_license
def add(x,y) x+y end def subtract(x,y) x-y end def sum(array_to_sum) sum = 0 array_to_sum.each { |x| sum += x } sum end def multiply(*multipliers) product = 1 multipliers.each { |x| product *= x} product end def power(number,exponent) number**exponent end def factorial(number) if number == 0 1 else ...
true
c806b4670d4b9c441c327e47f81415a2c11a9502
Ruby
VarvaraBabkova/activerecord-validations-lab-houston-web-062419
/app/models/validator.rb
UTF-8
295
2.78125
3
[]
no_license
class MyValidator < ActiveModel::Validator def validate(record) clickbaity = ["Won't Believe", "Secret", "Guess"] clickbaity.each do |c| return if record.title.include? c end return if record.title[/Top \d+/] record.errors[:title] << 'Should be a clickbait-y title!' end end
true
b6af1c4265d208933f0d3ede6f6e14cde98fb758
Ruby
aiit2016/chou-cloud-api
/data_center.rb
UTF-8
3,082
2.796875
3
[ "MIT" ]
permissive
require 'net/https' class DataCenter def initialize(user_id) @user_id = user_id end def get_all() response = request_get('instances/') return response end def get_one(id) response = request_get("instances/#{id}") return response end # request creation # @param memory [Integer] ...
true
36b332f60fd76aab48024e656578e614ef286264
Ruby
chino/pxr
/scenes/wave_x.rb
UTF-8
1,627
2.578125
3
[]
no_license
$game = Game.new("Model Viewer", $options[:width], $options[:height], $options[:fullscreen]) $quad = Quad.new $time = Time.now.to_f $wave = Proc.new{ $time = Time.now.to_f $quad.verts.each do |vert| vert[:vector][2] = Math.sin vert[:vector][0]+$time end } $objects = [$quad,Lines.new] $camera = View.new $c...
true
0eac5483df78cdd580eeb6909359e53f701fa3a2
Ruby
rochefort/misc
/book_tutorials/ruby_crawler/5-10_seo/google_rank.rb
UTF-8
593
2.703125
3
[]
no_license
#!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'google-search' def find_item(uri, query) search = Google::Search::Web.new do |s| s.query = query s.size = :large s.each_response { print '.'; $stdout.flush } end puts uri search.find { |item| item.uri =~ uri } end def rank_for(domain, query) p...
true
ae06a5a75da88631de146e10d1d366bfc94f5189
Ruby
ZulqarnainNazir/impact-sample
/app/models/connect_token.rb
UTF-8
678
2.671875
3
[]
no_license
module ConnectToken def self.encode(payload) JSON::JWT.new(payload.merge(exp: exp.to_i)).sign(ENV['CONNECT_KEY']).encrypt(private_key.public_key).to_s end def self.decode(token) verify JSON::JWT.decode(token, private_key).with_indifferent_access end private def self.exp Time.now + 10.seconds ...
true
556ce83a85c4400da358849083dd520e4657f3c1
Ruby
jeremiahishere/parser_tutorial
/heuristics/assignment_count.rb
UTF-8
503
2.796875
3
[]
no_license
class AssignmentCount < NodeCount def generate "Assignments: #{assignment_count(@node)}" end def assignment_types [:lvasgn, :ivasgn, :cvasgn, :gvasgn, :casgn, :'op-asgn', :'or-asgn', :'and-asgn'] end def assignment_count(node) count = 0 if(assignment_types.include? node.type) count +=...
true
6157f145fbbcab0fb5e825be1c768fdf6f3ebe0b
Ruby
IvaDobreva/CodeHulk
/level2/whiteRabbit.rb
UTF-8
351
3.453125
3
[]
no_license
def fibonacci_num(limit) current = 0 prev1, prev2 = 1, 1 counter = 1 sum = 0 while counter<=limit do #sum += current prev1 =prev2 prev2 = current sum += prev1 + prev2 current = prev1 + prev2 counter +=1 end puts "fibonacci #{current}" puts "sum #{su...
true
aff0822dabb3a965ac2d665664048bc4afa2bb67
Ruby
nans64/kerala-test
/spec/models/person_spec.rb
UTF-8
3,814
2.59375
3
[]
no_license
require 'rails_helper' RSpec.describe Person, type: :model do before do Person.importation('public/people.csv') end describe 'Parse the database to check if CSV datas are into the Person table' do context "when the CSV has been imported successfully" do it 'successfully imp...
true
ef031521602b28b888bbcfa189d2097f01cd6793
Ruby
cristian-castrillon/makeitreal
/sinatra_app/store/main.rb
UTF-8
1,919
2.765625
3
[]
no_license
require "sinatra" enable :sessions products = [ {name: "audifonos", price: 150, currency: "usd"}, {name: "book", price: 30, currency: "usd"}, {name: "mouse", price: 20, currency: "usd"}, {name:"mac", price: 2300, currency: "usd"} ] get "/" do @products = products @visited = request.cookies.fetch("visited", 0)...
true
4080545f8639e0f2a7e7574ee293976696cd5094
Ruby
Sid-ah/hk-bc
/ruby-drill-control-flow-in-loops-challenge/in_loops.rb
UTF-8
766
4.21875
4
[]
no_license
# Generic looping method: no break, next, or return def loop_no_extras numbers = [] counter = 0 while counter < 20 counter += 1 numbers << counter end numbers end # Loops with a break condition def loop_with_break numbers = [] counter = 0 while counter < 20 counter += 1 break if cou...
true
2f28968f909ebce390149339f959dbdf95ad1e62
Ruby
StephenWattam/VPeqNP
/lib/token.rb
UTF-8
893
3.1875
3
[]
no_license
module VPNP class Token # Read-write type attr_accessor :type, :source, :prev # Read string attr_reader :string, :word attr_writer :next def initialize(string, word, type=nil) @word = word @string = string @type = type end # Retrieve the next token in the...
true
456114ac3fe2aefa3fd6f1909d2ba79ea6b1e911
Ruby
puppetlabs/r10k
/lib/r10k/tarball.rb
UTF-8
5,876
2.625
3
[ "Apache-2.0" ]
permissive
require 'fileutils' require 'find' require 'minitar' require 'tempfile' require 'uri' require 'zlib' require 'r10k/settings' require 'r10k/settings/mixin' require 'r10k/util/platform' require 'r10k/util/cacheable' require 'r10k/util/downloader' module R10K class Tarball include R10K::Settings::Mixin include...
true
094ab372109bfd85817a0799f62c7327ad9c632e
Ruby
seaswalker/ruby-machine
/nfa/nfa.rb
UTF-8
861
3.375
3
[]
no_license
NFA = Struct.new(:current_states, :accept_states, :rulebook) do def accepting? # 取交集 (current_states & accept_states).any? end def read_character(character) self.current_states = rulebook.next_states(current_states, character) end def read_string(string) string.chars.each do |character| ...
true
00ca622a9f1e072b4c5309bd6c9ce521ef3c940a
Ruby
apuffy/Final-Project
/spec/models/contact_spec.rb
UTF-8
1,560
2.546875
3
[]
no_license
require 'spec_helper' describe Contact do before (:each) do @attr = {:name => "John Doe", :email => "jdoe@example.com"} end it "should create a new instance given valid attributes" do Contact.create!(@attr) end it "should require a name" do no_name_Contact = Contact.new(@attr.merge(:name =>...
true
a827338f355f45e8cce14668f464e1fe36cd22f4
Ruby
fnando/troy
/lib/troy/meta.rb
UTF-8
618
2.5625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Troy class Meta extend Forwardable def_delegators :data, :[], :fetch, :key? REGEX = /^---\n(.*?)\n---\n+/m.freeze attr_reader :file def initialize(file) @file = file end def content @content ||= raw.gsub(REGEX, "") end def data...
true
f24d7930b8db66c2a8ed1e211dee99db1f367b27
Ruby
piktur/pg_multisearch
/lib/pg_multisearch/constants.rb
UTF-8
1,153
3.015625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module PgMultisearch # @return [Array] EMPTY_ARRAY = [].freeze # @return [String] EMPTY_STRING = ''.freeze # @return [Hash] EMPTY_HASH = {}.freeze # @return [Set] EMPTY_SET = ::Set[].freeze # @return [Proc] NOOP = ->(*) {}.freeze # @return [Object] Undefined =...
true
aa00a121efd39725861e1d2479b08cf87808b56b
Ruby
harrybournis/capstoneED-api
/app/models/game_setting.rb
UTF-8
2,778
2.515625
3
[]
no_license
# Holds the Gamification Settings for an Assignment. Specified by the Lecturer class GameSetting < ApplicationRecord # Attributes # # id :integer # assignment_id :integer # points_log :integer # points_log_first_of_day :integer # points_peer_assessment :integer # points_peer_assessment_first_of_team :in...
true
bfe87438a286561ca91e0d536c929559336dca91
Ruby
kenchan/competitive_programming
/atcoder/arc080/d.rb
UTF-8
330
2.875
3
[]
no_license
H, W = gets.split.map(&:to_i) N = gets.to_i A = gets.split.map(&:to_i) aa = A.each_with_index.inject([]) {|acc, (a, i)| acc + [(i + 1)] * a } H.times do |h| W.times do |w| if h.even? w2 = w else w2 = W - w - 1 end print aa[h * W + w2] if w != W print ' ' end end print...
true
3b5fc40f957cc272dd8c78c259a909c1bd509a79
Ruby
anku19/BasicRuby
/hashLooping.rb
UTF-8
273
3.28125
3
[]
no_license
mark = Hash.new mark['English'] = 50 mark['Math'] = 70 mark['Science'] = 75 total = 0 mark.each { |key,value| total = total + value } puts "Total Marks="+total.to_s # .to_s returns string =begin Output: C:\Users\USER\Desktop>ruby loopHash.rb Total Marks=195 =end
true
573d333ec037b86bf5a66559a7e83a0a961401ae
Ruby
anjackson/hansard
/spec/models/division_placeholder_spec.rb
UTF-8
6,476
2.609375
3
[]
no_license
require File.dirname(__FILE__) + '/../spec_helper' def mock_divisions_placeholder_builder mock_builder = mock("xml builder") mock_builder end describe DivisionPlaceholder, "when asked for its xml id" do it 'should not throw an error if it does not have a preceding contribution' do placeholder = DivisionP...
true
b7162c56cd39ad938f6c50a9c685b27f508eb34e
Ruby
quintel/etengine
/app/models/qernel/node_api/conversion.rb
UTF-8
5,652
3.140625
3
[ "MIT", "LicenseRef-scancode-free-unknown" ]
permissive
# frozen_string_literal: true module Qernel module NodeApi # Enables converting some calculated values from one unit of measure to another. # # Each method takes a single parameter, which allows you to convert the original value to one # in another unit. For example: # # total_costs_per(:no...
true
63b72c084a57cf6a983209f0e71cd300ad19fdb6
Ruby
bitsofcotton/eqnarray
/scripts/relinit-eqn.rb
UTF-8
4,312
2.984375
3
[ "Unlicense" ]
permissive
#! /usr/local/bin/ruby require 'wrapper.rb' wrap = CWrapper.new field = wrap.addField( "初等的な関係と言い換え" ) # 四則演算冪乗様々な律 wrap.addDedDBSeed( "a + 0", "a", 3, field, "加法単位元" ) wrap.addDedDBSeed( "a - a", "0", 3, field, "加法逆元" ) wrap.addDedDBSeed( "a\\cdot 0", "0", 3, field, "乗法と加法" ) wrap.addDedDBSeed( "a\\cdot 1", "a", 3...
true
e88f8532d149a32bbc5c8d049220c38aec9dacca
Ruby
djpinchevski/small_problems
/03_easy/05_squaring.rb
UTF-8
446
4.375
4
[]
no_license
=begin Using the multiply method from the "Multiplying Two Numbers" problem, write a method that computes the square of its argument (the square is the result of multiplying a number by itself). Example: square(5) == 25 square(-8) == 64 =end def multiply(a, b) a * b end def square(num) multiply(num, num) end de...
true
90eb60d42c9991e609ce768d609ce4914601a082
Ruby
mytestbed/labwiki_r_plugin
/lib/labwiki/plugin/r/rserve_session.rb
UTF-8
13,710
2.640625
3
[]
no_license
require 'omf_base/lobject' require 'stringio' require 'rserve' require 'labwiki/plugin/r/protocol' require 'labwiki/plugin/r/rserve_connection' module LabWiki::Plugin::R RSERVE_INTERNALS_DEBUG = false # create debug messages related to RServe internals # Thrown by eval handler if the just processed line # sh...
true
f8bbb4215ca9349c3f6bdf0390df794f20a2756f
Ruby
charliejp0311/my-each-onl01-seng-pt-012220
/my_each.rb
UTF-8
157
2.984375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def my_each(a) # put argument(s) here # code here i = 0 while i < a.length a.collect do |in_a| yield a[i] i += 1 end end a end
true
8aa2af0b74c9775dbc904a0c015c573b30ef8cc4
Ruby
mcaers/FizzBuzz
/fizzbuzz_test.rb
UTF-8
558
2.875
3
[]
no_license
require "test/unit" require_relative 'fizzbuzz' class FizzBuzzTest < Test::Unit::TestCase def test_divisible_by_3 assert_equal "Fizz", FizzBuzz.identify(3) end def test_divisible_by_5 assert_equal "Buzz", FizzBuzz.identify(10) end def test_divisible_by_5_and_3 assert_equal "FizzBuzz", FizzBuzz.identify(1...
true
4717e9d9c593bf6bee5f2cda5272bb3c23ca631a
Ruby
tnodland/LaughTracks
/app/models/comedian.rb
UTF-8
306
2.65625
3
[]
no_license
class Comedian < ActiveRecord::Base validates :name, presence: true validates :age, presence: true has_many :specials def self.average_age average(:age) end def self.unique_cities cities = Comedian.select(:city).distinct.map {|comedian| comedian.city} cities.join", " end end
true
a22f9788f68cb5265921da01a6ba9b4c1b5a2ce1
Ruby
zaki/backlogjp
/lib/backlogjp/activity_type.rb
UTF-8
670
2.734375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Backlogjp # Represents a backlog.jp activity type class ActivityType < Container # @!attribute [r] id # @return [Integer] Activity type ID # @!attribute [r] name # @return [String] Activity type name attributes :id, :name # Returns an array of all activity types # @return [Ar...
true
981c6f0e2ea85f81a15029312c79b9e622b1b761
Ruby
bellps/Ruby-TDD
/exemplo_rspec_tdd/spec/mocks/mocks_spec.rb
UTF-8
944
3.3125
3
[]
no_license
require 'student' require 'course' describe 'Mock' do #no mock, as fases de exercise e verify se invertem it '#bar' do #setup student = Student.new #verify expect(student).to receive(:bar) #ele fica esperando o comportamento acontecer, por ...
true
13f4fe20bc8d7201eacc300817e64cfc867ed928
Ruby
jcoglan/advent-of-code
/2018/10/solution.rb
UTF-8
1,297
3.484375
3
[]
no_license
class Points P = Struct.new(:px, :py, :vx, :vy) def initialize(points) @points = points end def at(t) @points.map { |p| [p.px + t * p.vx, p.py + t * p.vy] } end end class Optimiser def initialize(points) @points = points end def run t, v = 0, nil loop do new_v = variance(t...
true
8d24f7ae2088122c8de8e84eb3b40571530ed4a0
Ruby
puffsun/ctci_ruby
/lib/queue.rb
UTF-8
1,558
3.65625
4
[]
no_license
module Ch3 class Queue def initialize @q = [] end def enq(e) @q << e self end def deq raise StandardError if empty? @q.shift end def empty? @q.empty? end end # Queue implemented with two stacks class MyQueue def initialize @stac...
true
3b047f61d61b7f4fb094dc60b7d32834e5f73900
Ruby
kasawyer/practice
/ruby_challenges/disemvowel_trolls.rb
UTF-8
671
4.15625
4
[]
no_license
# Trolls are attacking your comment section! # # A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. # # Your task is to write a function that takes a string and return a new string with all vowels removed. # # For example, the string "This website...
true
ba93565cf3ed14eabf1630148f832ff38fc6b3b9
Ruby
v9n/cracking_the_coding_interview
/lib/algorithms/sorting/top_down_merge_sort.rb
UTF-8
1,103
3.34375
3
[ "MIT" ]
permissive
module Algorithms module Sorting module TopDownMergeSort def sort(a) sort!(a.clone) end def sort!(a) # could be more efficient, but chose to take Enumerable'ish approach r_merge_sort(a).each_with_index { |e, i| a[i] = e } unless a.size <= 1 a end pr...
true
666011e8b99dcb580ae7ad592b6b5bb4ed05d312
Ruby
afrase/advent-of-code_2020
/ruby/advent2.rb
UTF-8
1,480
3.328125
3
[ "MIT" ]
permissive
# frozen_string_literal: true class Row def self.parse(file_path, rule_class: Rule) File.readlines(file_path).map { |l| new(l, rule_class) } end attr_reader :raw attr_reader :rule attr_reader :password # @param [String] row # @param [Class] rule_class def initialize(row, rule_class) raise(Arg...
true
a393cc422b0fe87989164c890327d2027c1c9221
Ruby
timpalpant/Ruby-Genomics
/nucleosome/findNuke.rb
UTF-8
3,359
3.0625
3
[]
no_license
#!/usr/bin/env ruby1.9 # == Synopsis # Finds the first nucleosome from either the 5' or 3' end of a window (such as an ORF) # # == Usage # Finds the first nucleosome for the spots in orfs.bed for the nukes in nukes.txt # # findNuke.rb -i nukes.txt -l orfs.bed -o orfs.nukes.bed # # For help use: fin...
true
570f5b152721ddcd297fee2571106180c37c692a
Ruby
jordansissel/jruby-elasticsearch
/lib/jruby-elasticsearch/bulkstream.rb
UTF-8
2,087
3.078125
3
[]
no_license
require "jruby-elasticsearch/namespace" require "thread" class ElasticSearch::BulkStream # Create a new bulk stream. This allows you to send # index and other bulk events asynchronously and use # the bulk api in ElasticSearch in a streaming way. # # The 'queue_size' is the maximum size of unflushed # reque...
true
2ae0ebafa89091012543dc09887070b4b383587c
Ruby
CoderAcademyEdu/mel-morning-challenges19
/term_one/ruby/week_1/03_banking_app_canvas.rb
UTF-8
1,154
3.765625
4
[]
no_license
# The initial balance should be 0. Show this on screen when the app runs. # The initial balance should be 0. Show this on screen when the app runs. # Let the user determine the output. Ask them what they would like to do. If they type balance and hit return, show them their balance! Currently the only option is balance...
true
2a6f19974059c1553e04956123ea2cbd6ba2a6ec
Ruby
cedretaber/codes_for_atcoder
/abc/107/b.rb
UTF-8
234
2.71875
3
[]
no_license
$stdin.read.split(?\n).tap do |_, *map| map .map { |line| line.split // } .select { |line| line.include? "#" } .transpose .select { |line| line.include? "#" } .transpose .each do |line| puts line * "" end end
true
485f1e6b9f4f2fa68e4232e11c5483f0c63df1bc
Ruby
emaust/hotel
/lib/hotel_controller.rb
UTF-8
2,578
3.28125
3
[]
no_license
require_relative 'date_range' require_relative 'reservation' require 'pry' module Hotel class HotelController # does this need to be accessor? idk, look it up attr_accessor :reservation_list, :rooms, :reservation # Wave 1 def initialize @rooms = (1..20).to_a @reservation_l...
true
9e5687fd11ccdbec2e6dc5c7299a6547146b2acb
Ruby
voidsatisfaction/Project-Euler-in-Ruby
/53.rb
UTF-8
292
3.515625
4
[]
no_license
# variables count = 0 # functions def factorial(n) fac = 1 for k in 1..n fac *= k end return fac end # main for n in 1..100 for r in 0..n value = factorial(n)/(factorial(r) * factorial(n-r)) if value > 1000000 p value count += 1 end end end p count
true
14ada33c962a268a6b87f1adee803dbd780ee521
Ruby
melkotoury/rubyCourse
/control flow.rb
UTF-8
262
3.65625
4
[]
no_license
a = 5 if a == 1 puts "a is 1" elsif a == 2 puts "a is 2" else puts "I don't know the value of 'a' " end x=6 case x when 1 puts "x is 1" when 2 puts "x is 2" when 3 puts "x is 3" else puts "I don't know the value of 'x' " end
true
087735a003f81428378e505ed7bc987279f5ab74
Ruby
andrepiske/kvstore-rb
/test/database_test.rb
UTF-8
3,839
2.96875
3
[ "MIT" ]
permissive
# This file is part of Kvstore # (2016) André Diego Piske # https://github.com/andrepiske/kvstore-rb # See LICENSE file for the license # require 'minitest/autorun' require 'kvstore' require 'tempfile' require 'set' describe Kvstore::Database do let :pre_filled_db_path do file_name = temp_file_path db = Kvst...
true
1715f6c2e0c2d3a3415638151e376731ca875a31
Ruby
mitio/programming-at-athlon
/2012-05-31/cup.rb
UTF-8
642
3.9375
4
[]
no_license
class Cup def initialize(capacity, used) @capacity = capacity @used = used end def gulp amount = [@used, 30].min() @used -= amount puts "Gulped #{amount} ml!" end def plug(how_much) plugged = [how_much, @capacity - @used].min() extra = how_much - plugged @used += plugged ...
true
b9a54c20f91647a21f1e15199762d2b32c7e6790
Ruby
damusix/kudos-code-challenge
/app/models/user.rb
UTF-8
415
2.546875
3
[]
no_license
class User < ApplicationRecord has_many :kudos_received, class_name: :Kudo, foreign_key: :to_id has_many :kudos_sent, class_name: :Kudo, foreign_key: :from_id def kudos_totals @received = self.kudos_received.inject(0) { |sum, kudo| sum + kudo.amount } @sent = self.kudos_sent.inject(0) { |...
true
12949f27305f1aec5a234be859b62dbdd12aa00c
Ruby
ChristopherDurand/Exercises
/ruby/small-problems/easy8/e01.rb
UTF-8
318
3.84375
4
[ "MIT" ]
permissive
def sum_of_sums(arr) arr.map.with_index { |_, idx| arr[0,idx+1] }.flatten.inject(:+) end puts sum_of_sums([3, 5, 2]) == (3) + (3 + 5) + (3 + 5 + 2) # -> (21) puts sum_of_sums([1, 5, 7, 3]) == (1) + (1 + 5) + (1 + 5 + 7) + (1 + 5 + 7 + 3) # -> (36) puts sum_of_sums([4]) == 4 puts sum_of_sums([1, 2, 3, 4, 5]) == 35
true
d919bb305883d4fff141b40cf82e6884c3e45bcd
Ruby
noplanb/tbm_ios
/doc/namer.rb
UTF-8
402
3.140625
3
[]
no_license
vowels = %w{a e i o u} consonants = ('a'..'z').to_a - vowels - ["q"] first_vowels = %w{a e o u} second_vowels = %w{a o u} consonants.each do |c1| consonants.each do |c2| first_vowels.each_with_index do |v1, i| second_vowels.each_with_index do |v2, j| print "\n" if i==0 && ...
true
1261d446c59f8ff670d7c3ad86f2a6a2eb37d1e7
Ruby
thomasfl/vrtx
/bin/vrtx
UTF-8
1,550
2.53125
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'davclient' require 'vrtx' def print_usage puts "usage: vrtx COMMAND [ARGS]" puts "" puts "Available vrtx commands:" puts " ls List files on webdav server" puts " pwd Print current working url" puts " cd Change current working url" put...
true
554ef0556357194fdc57706c2995c3b3f79eae04
Ruby
dlcmh/simple-interpreter-in-ruby
/src/calc5.rb
UTF-8
2,645
4.28125
4
[]
no_license
INTEGER, PLUS, MINUS, MUL, DIV, EOF = %w[INTEGER PLUS MINUS MUL DIV EOF] class Token attr_reader :type, :value def initialize(type, value) @type = type @value = value end def to_s "Token(#{type}, #{value.inspect})" end def inspect to_s end end class Lexer attr_reader :text, :pos, :c...
true
eb456d8e87388b7cc64d95ce71fdd1c2537f4581
Ruby
tomwwright/delayed-jobs-aws-batch
/app/jobs/dummy_error_job.rb
UTF-8
143
2.546875
3
[]
no_license
DummyErrorJob = Struct.new(:text) do def perform puts "Finna blow up: " + text raise end def max_attempts return 2 end end
true
85e137c85ff41eda10fd257a6715585dd8363252
Ruby
nyoke/VLS
/SIFTExtractor.rb
UTF-8
1,129
2.796875
3
[]
no_license
#!/opt/local/bin/ruby -w # -*- coding: utf-8 -*- #require 'rubygems' require 'yaml' #################################################################################### # 引数として渡された画像ファイルのSIFT特徴量を算出する # 設定ファイルから #  画像ファイル保存先ディレクトリ:image_path #  SIFT特徴量保存先ディレクトリ:sift_path # ---------------------------------------- # <改訂履...
true
6d2b287b00ec2d464da6167e397adcc9be852248
Ruby
Pavanswamy/rubymonk
/26_5 /array_copy_each.rb
UTF-8
110
2.75
3
[]
no_license
def array_copy(source) destination=[] source.each do |i| destination << i if i<4 end return destination end
true