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
89166ef860b9a146b3efea5c35ba2b157a430446
Ruby
genail/githooks
/hooks/tests/space_test.rb
UTF-8
1,555
2.765625
3
[]
no_license
require 'lib/test.rb' require 'lib/commit_info.rb' require 'lib/file_utils.rb' require 'config/config.rb' class SpaceTest < Test def initialize() super() end def perform(commit_info) if Config::cnt_allow_tabs and Config::cnt_allow_trailing_spaces return end ...
true
ac739cc95197d27d7375a4e394015b599614d0e2
Ruby
din982/redit
/lib/redit/chunk.rb
UTF-8
724
3.546875
4
[ "MIT" ]
permissive
# What's a chunk? It's something you can work with. What's it made of? # Other chunks. # # This is a high-level structure that represents some semantic unit of # text. Maybe it's a paragraph; maybe a sentence; maybe an intonation # unit or a line of code or a variable or a word or syllable. # # The weird thing is that ...
true
e5c0d774c12a974238676f29f8e61c45a4aae376
Ruby
asridha/udemy_ruby
/Chap11_ex62.rb
UTF-8
440
4.03125
4
[]
no_license
alist = [6,8,10,1,3,5,7,9,4,2] passnum = alist.length - 1 puts(passnum) catch (:stop) do =begin alist.each do |i| puts i end =end while passnum >= 0 for i in 0..passnum print(alist[i]) #prints all the items in the array alist from 0..9 the first time, then from 0..8 and so on .. if i > 6 throw ...
true
f2843f3974c2d20be85f644e96ef136d8844c787
Ruby
bipul21/bs-ruby-koans
/bs-keyserver/key_server.rb
UTF-8
1,762
3.453125
3
[]
no_license
require 'securerandom' require 'set' EXPIRATION_TTL = 300 UNBLOCK_TTL = 60 ## Key object to hold key and metadata about keys # @key : Unique Id for the key # @timestamp : Timestamp of the creation time of the key class Keys attr_accessor :key attr_accessor :timestamp def initialize(key = SecureRandom.uuid, ts...
true
4784be7856e6b4f30993d8a421abb6e24fe5d052
Ruby
amarkules1/Graphs
/spec/graph_spec.rb
UTF-8
2,128
2.953125
3
[]
no_license
require_relative '../my_edge' require_relative '../my_vertex' require_relative '../my_graph' require 'yaml' require 'spec_helper' describe "graph object" do before :all do vertices = [ MyVertex.new, MyVertex.new, MyVertex.new, MyVertex.new, MyVertex.new ] File.open...
true
226628441a70c9fcb0cd4991d89d6fef77ed90f0
Ruby
RyanZolper/AssignmentsIronYard
/assignment13.rb
UTF-8
317
4.15625
4
[]
no_license
puts "Guess a number from 1 to 15" a = rand(1...15) r = gets.chomp.to_i count = 1 until r == a puts 'nope' if r < a puts 'too low bro' else puts 'too high, tough guy' end puts 'Guess again, chump.' r = gets.chomp.to_i count += 1 end puts "Congratulations! You guessed #{count} times! You suck!"
true
b5c6ab4e9be16f7a5003514419f1bbba1c221e2f
Ruby
freddyfallon/GildedRose-Refactoring-Kata
/ruby/spec/normal_item_handler_spec.rb
UTF-8
911
2.59375
3
[ "MIT" ]
permissive
require 'normal_item_handler' describe NormalItemHandler do describe "#update_quality" do it "should reduce quality by 1 if sell_in above 0" do item = Item.new("+5 Dexterity Vest", 10, 10) NormalItemHandler.new.update_quality(item) expect(item.quality).to eq 9 end it "should reduce qua...
true
a6f9b40fccae3702326b4694a21e3887bc81b59d
Ruby
johncarney/memonic
/spec/memonic_spec.rb
UTF-8
1,537
2.734375
3
[]
no_license
require "spec_helper" require "memonic" describe Memonic do shared_context "memoize the result" do before do allow(memoizer).to receive(:computation).and_call_original end it "returns the computation result on the first call" do expect(memoizer.value).to be result end it "returns th...
true
7200589a5b8834ff324f20b9d454159281a0f1d2
Ruby
heuristic-cons/farmbot-raspberry-pi-controller
/lib/controllers/read_status_controller.rb
UTF-8
884
2.703125
3
[ "MIT" ]
permissive
require_relative 'abstract_controller' module FBPi class ReadStatusController < AbstractController def call reply "read_status", info end def info info = {busy: bot.status[:busy], current_command: bot.status[:last]} info.merge(pin_info).merge(axis_info) end def pin_info ...
true
42646821b0974fb1e178e74570ad319ca56417a5
Ruby
klavinslab/protocols_aquarium_1_0
/recombineering/validation/005_pick_colonies.rb
UTF-8
4,188
2.625
3
[]
no_license
needs "aqualib/lib/standard" needs "aqualib/lib/cloning" class Protocol include Standard include Cloning def arguments { io_hash: {}, plate_ids: [13578,13579], num_colonies: [3,3], debug_mode: "No", group: "cloning" } end def main io_hash = input[:io_hash] io_hash = i...
true
d0bd5bd4433b69230abea1cd17c02167be10485c
Ruby
goncalog/oystercard
/spec/journey_log_spec.rb
UTF-8
1,354
2.671875
3
[]
no_license
require 'journey_log' describe JourneyLog do let(:journey_log) { JourneyLog.new } let(:entry_station) { double :station, zone: 2 } let(:exit_station) { double :station, zone: 2 } describe '#start' do it 'starts a new journey with an entry station' do journey_log.start(entry_station) ...
true
34c1f86afb4f028baa1e09f44fe3d7b49c899c49
Ruby
MasoodGit/coding_chanllenges
/image_blur/image_blur_1.rb
UTF-8
2,157
3.6875
4
[]
no_license
#class Image class Image @@rows = 0 def initialize(data) @data = data @rows = @data.length @cols = @data[0].length end def output_image_map puts @data.map{ |row| row.join("") }.join("\n") end def blur_image_helper(x, y) if x - 1 >= 0 @data[x-1][y] = 1 end if x + 1 < @row...
true
38616bf76e3a0794ecdd227a41a7b8c389ac46b3
Ruby
ShaDuv/Daily_Code_Challenge
/edit_distance_between_two_strings/front.rb
UTF-8
684
3.9375
4
[]
no_license
require './lib/edit_distance' p 'The edit distance between two strings refers to the minimum number of character insertions, deletions, and substitutions required to change one string to the other. For example, the edit distance between “kitten” and “sitting” is three: substitute the “k” for “s”, substitute the “e” fo...
true
ff14697d9c8a4ebba33df230c0514cef78f96374
Ruby
treble37/ruby_asteroids
/box.rb
UTF-8
517
3.40625
3
[]
no_license
class Box attr_accessor :x, :y, :width, :height, :color def initialize(x, y, width, height, color=Gosu::Color::RED) @x = x @y = y @width = width @height = height @color = color end def move(x, y, x_boundary, y_boundary) @x = (@x + x) % x_boundary @y = (@y + y) % y_boundary end ...
true
bab2b1c2f893fc9d2784dda3c025231bfaa86f11
Ruby
ktlacaelel/ix
/bin/ix-rot3
UTF-8
212
3.09375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby normal = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" rot13 = "cdefghijklmnopqrstuvwxyzabCDEFGHIJKLMNOPQRSTUVWXYZAB" STDIN.each_line do |line| puts line.tr!(normal, rot13) end
true
c8552dc8ccfeebfca5e4d46a6324e818deb6dcb7
Ruby
bstarr7070/finals
/battle.rb
UTF-8
376
3.328125
3
[]
no_license
class Battle attr_accessor :damage :hp def hp @maxhp - @damage end def select select = gets.to_i if select == 1 puts "you used #{skills[1]}" elsif select == 2 puts "you used #{skills[2]}" elsif select == 3 puts "you used #{skills[3]}" else puts "please select an...
true
b32e86ae217d252ee521375cd4b72e25401703e0
Ruby
Schlipak/launchlibplus
/lib/llibplus/opt_parser.rb
UTF-8
1,352
2.609375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- require 'optparse' require 'logger' module LLibPlus class Parser USAGE = "llib+ [options]" attr_reader :parser, :options def initialize @options = Hash.new @parser = nil end def parse! begin @parser = OptionParser.new(USAGE, 23, "\t") do |opts...
true
062cf78d2a6440b1f3e625dd7f473e27c29ada50
Ruby
Coolnesss/uinti
/app/models/user.rb
UTF-8
1,048
2.578125
3
[]
no_license
class User < ActiveRecord::Base has_secure_password validates :username, uniqueness: true has_many :event_users, dependent: :destroy has_many :events, through: :event_users has_many :user_achievements, dependent: :destroy has_many :achievements, through: :user_achievements def to_s username.capitali...
true
37859088f08f3fac89535711cd5e4897299efb9c
Ruby
monydara/EMS
/app/controllers/acd_degree_setup_controller.rb
UTF-8
5,976
2.53125
3
[]
no_license
class AcdDegreeSetupController < ApplicationController def getDegreeCourse data = [] d_id = params[:degree_id] if params[:degree_id] puts("******** #{d_id}") data = AcdDegreeCourse.joins(:acd_degree,:acd_course_faculty) .select("acd_course_faculties.id as id, acd_degree_courses.id AS degree_cour...
true
f05ffe890a60e2ea7a05373b450df8d1fdc5b5e5
Ruby
geeosh/nreduce-public
/lib/include/nreduce_util.rb
UTF-8
701
2.890625
3
[]
no_license
class NreduceUtil def self.cleanup_phone_number(number) number.to_s.strip.gsub(%r{\D}, "").gsub(%r{^\+1}, "").gsub(%r{^1}, "") end def self.friendly_token(length = 15) SecureRandom.base64(length).tr('+/=', 'xyz') end def self.parse_twitter_handles(twitter_text) items = [] twitter_text.to_s....
true
de5881cf57d88b0c2453fbe31d9be35ce27e44fc
Ruby
NicolasAllip/eis
/Calculadora/features/step_definitions/operaciones_basicas_steps.rb
UTF-8
802
2.53125
3
[]
no_license
#Suma Given(/^voy a la pagina de calculadora$/) do visit 'calculadora' end Given(/^eligo el operador suma$/) do select('Suma', from:'operador') end Given(/^un operando es (\d+)$/) do |operando1| fill_in 'operando1', with: operando1 end Given(/^otro operando es (\d+)$/) do |operando2| fill_in 'operando2', w...
true
d3c94576ff3326160f0a5a8d703623fe2774198a
Ruby
zverok/tty-progressbar
/lib/tty/progressbar/formatter/bar.rb
UTF-8
1,220
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module TTY class ProgressBar # Used by {Pipeline} to format bar # # @api private class BarFormatter MATCHER = /:bar/.freeze def initialize(progress) @progress = progress end # Determines whether this formatter is applied or not. # ...
true
d146addb03c26a1a8b55675b1b6fad937c323466
Ruby
chhatrolaa/euler
/31.rb
UTF-8
1,607
4.09375
4
[]
no_license
# -*- coding: utf-8 -*- # Problem 31 # 22 November 2002 # # In England the currency is made up of pound, £, and pence, p, and there are # eight coins in general circulation: # # 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). # It is possible to make £2 in the following way: # # 1*£1 + 1*50p + 2*20p + 1*5p + 1*2p +...
true
71ac4f40b8bd1a976121a01c617aafc138f5419f
Ruby
karlwitek/launch_school_rb101
/lesson1/small_problems/Debugging/tf_idf.rb
UTF-8
6,487
3.734375
4
[]
no_license
# Term frequency - inverse document frequency: # A measure of how important a term is to a document in a collection of documents # (the importance increases proportionally to the term frequency in the document, # but decreases with the frequency of the word across documents) def tfidf(term, document, documents) tf(t...
true
3239925b1db511be0c88460875ec4f759f08084d
Ruby
jan-czekawski/code_wars
/7kyu/categorize_new_member.rb
UTF-8
1,837
4.3125
4
[]
no_license
# The Western Suburbs Croquet Club has two categories of membership, # Senior and Open. They would like your help with an application form # that will tell prospective members which category they will be placed. # To be a senior, a member must be at least 55 years old and have a # handicap greater than 7. In this cro...
true
f8c7edb4c57c5ee4886576c6289c18a8f15ae9a9
Ruby
jodeci/fortuna
/app/services/statement_service/update.rb
UTF-8
524
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module StatementService class Update include Callable attr_reader :statement, :params def initialize(statement, params) @statement = statement @params = params end def call params["correction"] = correction statement.update(params) end ...
true
6e0454a903002ae9df5ddada35200559b8c3d75d
Ruby
karthickpdy/CP
/a20j/typos.rb
UTF-8
195
3.203125
3
[]
no_license
s = gets.chomp ans = "" s.each_char do |a| if ((a == ans[-1]) && ans[-2] && (a == ans[-2])) || ((a == ans[-1]) && (ans[-2] && ans[-3] && (ans[-2] == ans[-3]))) else ans << a end end puts ans
true
769c1f9e354db7d9a7a88793b5df4f0570e8c9b8
Ruby
nanma80/euler_project
/p101_125/p112/main.rb
UTF-8
600
3.46875
3
[]
no_license
class Integer def bouncy? str = self.to_s length = str.length return false if length < 3 up = false down = false (1..length - 1).each do |i| if str[i-1] > str[i] down = true elsif str[i-1] < str[i] up = true end if up && down return true en...
true
70ed3b7cbe2f32b27d3b581a2f70f2beb65d2c14
Ruby
bakutinamari/ruby2
/wagon.rb
UTF-8
287
3.09375
3
[]
no_license
require_relative 'manufacturer' class Wagon include Manufacturer attr_reader :type, :total_place, :used_plase def initialize(type, total_place) @type = type @total_place = total_place @used_place = 0 end def free_place total_place - used_plase end end
true
aa76f1b46974b81a15d98e4b9ea705ab521dbc2a
Ruby
lukes/herald
/test/herald_test.rb
UTF-8
5,869
2.75
3
[ "MIT" ]
permissive
# start tests by 'rake test' on root path describe Herald do before do @herald = Herald.watch_twitter { _for "test" } end after do Herald.clear end describe "initialisation with watchers" do it "must throw an acception if no 'check' param is given" do assert_raises(RuntimeError) do ...
true
e7772a4ca58039887fbcbc745a32490580c7a348
Ruby
dminchev/econt
/lib/econt/client.rb
UTF-8
865
2.53125
3
[ "MIT" ]
permissive
# demo user & pass 'iasp-dev' module Econt class Client SERVICE_URL_DEMO = 'http://demo.econt.com' SERVICE_URL = 'http://www.econt.com' attr_accessor :username, :password, :service_url, :builder_obj def initialize(username, password, demo = true) @username = username @password = passwor...
true
31c69372ebb9d0871fee16d74a557a76a42a9771
Ruby
zeteticl/udonarium
/src/src_bcdice/utils/ArithmeticEvaluator.rb
UTF-8
2,228
3.328125
3
[ "MIT" ]
permissive
# # 四則演算を評価するクラス # class ArithmeticEvaluator # 四則演算を評価する # @param [String] expr 評価する式 # @param [Symbol] round_type 端数処理の設定 :omit 切り捨て, :roundUp 切り上げ, :roundOff 四捨五入 # @return [Integer] def eval(expr, round_type = :omit) @tokens = tokenize(expr) @idx = 0 @error = false @round_type = round_type ...
true
c2beb3d191fed6f6463479161c99b8ec455ec0b6
Ruby
refs/7_languages_in_7_days
/exercises/ruby/solutions/pages_examples/random_guesser.rb
UTF-8
219
3.46875
3
[]
no_license
rng = Random.new puts "take a guess" number = rng.rand(10) while true do puts number guessed = gets.to_i if guessed == number then puts "nice!" break else puts "make another guess" end end
true
ccb378b7cf1541632bee063716807d26b879f747
Ruby
mzahrada/Buckets
/lib/buckets/csv_results_writer.rb
UTF-8
2,460
2.671875
3
[]
no_license
module Buckets # Class for recording results and writing them to CSV file. # --- # Output (2 instances, 2 solving methods): # # id;method;bucket-operation-count;closed-states-sum;expanded-states-sum;trace # 11;bfs;10;8921;10219;first >> 0,0,1,0,0 >> 14,0,1,0,0 >> 14,10,1,0,0 >> 12,10,1,2,0 >> 12,10...
true
13091983a04e1f818f588f18adff364da76ca96d
Ruby
puppetlabs/puppetlabs-cd4pe_deployments
/lib/puppet/functions/cd4pe_deployments/create_git_branch.rb
UTF-8
2,110
2.78125
3
[]
no_license
require 'puppet_x/puppetlabs/cd4pe_client' require 'puppet_x/puppetlabs/cd4pe_function_result' # @summary Creates a git branch with the given branch name and commit SHA Puppet::Functions.create_function(:'cd4pe_deployments::create_git_branch') do # @param repo_type # The type of repo to perform the operation on....
true
721c4290d53c8dd29421d0d9caf5b1a95553d097
Ruby
makevoid/hostgist
/hostgist.rb
UTF-8
1,109
2.59375
3
[]
no_license
require 'bundler' Bundler.require :default require 'open-uri' GISTS_HOST = "https://raw.github.com/gist" BaseClass = defined?(Goliath) ? Goliath::API : Sinatra::Base class HostGist < BaseClass CACHE = {} def download(gist_id, file) key = "#{gist_id}/#{file}" file = CACHE[key] unless file fi...
true
83876e5c6fdc4bbe111673246203939192199a22
Ruby
SleepyDragon/dreamforge
/test/models/rule_spec.rb
UTF-8
845
2.546875
3
[ "MIT" ]
permissive
describe Rule do it "should be valid" do rule = Fabricate.build(:rule) rule.must_be_valid end it "should have a name" do rule_without_a_name = Fabricate.build(:rule, name: nil) rule_without_a_name.wont_be_valid end it "should not have actions" do rule_with_actions = Fabricate.buil...
true
df004ae575774528e55cefce5ce2e7d5134e3279
Ruby
allencwwong/happy-orange
/app/controllers/foods_controller.rb
UTF-8
3,769
2.515625
3
[]
no_license
require 'json' class FoodsController < ApplicationController def index #hide all liked , passed , blocked food items @display = true @selected_restaurant = Store.find(99) @selected_food_item_id = 99 end def show @display = true if(params[:food_id]) @selected_food_item_id = params...
true
ae14bca1acfd6dac2ec25589702d1bb0dde9a535
Ruby
atseng3/w2d7
/player.rb
UTF-8
1,406
3.90625
4
[]
no_license
class Player attr_accessor :hand, :sum_result def initialize @hand = [] @sum_result = 0 end def pick(choice, card_played, suit_selected) choice = choice.to_i raise "Pick a card that's there, pick again" unless @hand.length >= choice if is_eight?(choice) new_card_played = @hand.de...
true
276dea9f5096578fb60f1bd9b631f8219087296d
Ruby
cozziekuns/Yotsuba
/game.rb
UTF-8
7,568
2.90625
3
[]
no_license
require_relative 'hand' #================================================================================================== # ** Game_Hand #================================================================================================== class Game_Hand #-----------------------------------------------------------...
true
0309c0930945a1c4c7378973e200748486474e72
Ruby
hellouniverse26/cm1
/rails/projects/goal_app/solution/app/models/user.rb
UTF-8
2,046
2.65625
3
[]
no_license
# == Schema Information # # Table name: users # # id :integer not null, primary key # username :string(255) # password_digest :string(255) # session_token :string(255) # created_at :datetime # updated_at :datetime # cheer_count :integer # require 'bcrypt' class User...
true
e8211e3ffde29bb9d1981a4c1fffc01cfa85e8c2
Ruby
AdamYLiang/W2D1
/chess/pieces/nullpiece.rb
UTF-8
268
3
3
[]
no_license
require_relative 'piece' require 'singleton' class NullPiece < Piece include Singleton def self.instance(board) @@instance ||= new(board, "white", :null) end def initialize(board, color = "white", symbol = :null) super end end
true
d838c4448ec635c2586e3ea906650c6530072010
Ruby
defoebrand/enumerable
/main.rb
UTF-8
1,070
3.796875
4
[]
no_license
require_relative './lib/enumerable.rb' puts 'my_each Array' [2, 5, 6, 7].my_each do |n| puts n end puts 'my_each Range' (1..5).my_each do |n| puts n end puts 'my_each_with_index Array' [2, 5, 6, 7].my_each_with_index do |n, i| puts i.to_s + ': ' + n.to_s end puts 'my_each_with_index Range' (1..5).my_each_with...
true
6f39a56d62bd02cf1dec1906ed4914f3dcb3f7c6
Ruby
easydatawarehousing/ferro
/app/assets/javascripts/application/components/aside/tic_tac_toe/tic_tac_toe.js.rb
UTF-8
2,682
3.078125
3
[ "MIT" ]
permissive
require_relative 'tic_tac_toe_game_engine' class TicTacToe < Ferro::Component::Base def after_create add_state :hidden, true end def cascade add_child :title, Ferro::Element::Text, size: 4, content: 'Tic Tac Toe' add_child :new_game, NewGameButton, content: 'New game', disabled: true add_chi...
true
fd53c272b53beea38c2fa7da53aa6ca2dedc5f75
Ruby
h4hany/leetcode
/python_solutions/224.basic-calculator.rb
UTF-8
1,381
3.953125
4
[]
no_license
# # @lc app=leetcode id=224 lang=ruby # # [224] Basic Calculator # # https://leetcode.com/problems/basic-calculator/description/ # # algorithms # Hard (32.49%) # Total Accepted: 105.1K # Total Submissions: 323K # Testcase Example: '"1 + 1"' # # Implement a basic calculator to evaluate a simple expression string. # ...
true
daa006a3ef040ba2e03d6b319fb19fc1b8092faf
Ruby
tiy-boomtown/class-notes
/4/fizzbuzz/fizzbuzzer.rb
UTF-8
765
3.578125
4
[]
no_license
class Fizzbuzzer def initialize @rules = {} end def register_rule(number, replacement) # @rules[2] = "A" @rules[number] = replacement end # @rules = { # 2 => "A", # 3 => "B" # } def rule_for(number) # @rules[2] => "A" @rules[number] end def apply_one(n) # matches = @...
true
3b7a705852a386ad6b60de4daa329f08060ce939
Ruby
anathomical/otwarchive
/lib/pseudable.rb
UTF-8
1,091
2.640625
3
[]
no_license
# For models which have pseuds (authors) module Pseudable def pseuds_to_add=(pseud_names) pseud_names.split(',').reject {|name| name.blank?}.map {|name| name.strip}.each do |name| possible_pseuds = Pseud.parse_byline(name) if possible_pseuds.size > 1 possible_pseuds = Pseud.parse_byline(name,...
true
4da76a8cdbfcc78a2be787501e70d3da4284f202
Ruby
StanTim/Shop2.0
/add_a_product.rb
UTF-8
1,424
3.265625
3
[]
no_license
# Добавление продуктов в *.xml файл require_relative 'lib/product.rb' require_relative 'lib/disk.rb' require_relative 'lib/movie.rb' require_relative 'lib/book.rb' require 'rexml/document' if (Gem.win_platform?) Encoding.default_external = Encoding.find(Encoding.locale_charmap) Encoding.default_internal = __ENCOD...
true
e0568f5746cdb59ca044ed5872bc5064fa70f166
Ruby
rossato/donations
/app/models/donor.rb
UTF-8
482
2.703125
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
class Donor < ActiveRecord::Base include Comparable has_many :donations belongs_to :user def <=> (other) ret = self.last_name <=> other.last_name return ret unless ret == 0 return self.full_name <=> other.full_name end def ytd_donations(year = Time.now.year) donations.where(date: (Time.n...
true
79b52d7869f766bbeee5d4c6f1ef14396c33e099
Ruby
narrator0/dataUri_parser
/lib/dataUri_parser.rb
UTF-8
346
2.59375
3
[ "MIT" ]
permissive
# # @creator arfullight # @date 2016/03/19 # @info parse dataURL into a file # require 'base64' require 'class/DataUri' class DataUriParser def self.toDataUri(targetFile, fileType) data = File.read(targetFile) dataURI = "data:#{fileType};base64," + Base64.encode64(data) obj = DataUri.new(dataUR...
true
49be7936a94041ae8494b80bbf59ba825366e247
Ruby
dummygithubaccount/own_bash_preferences2
/convert_txt_to_sql.rb
UTF-8
1,262
2.84375
3
[]
no_license
class ConvertToSql attr_accessor :file_lines, :table_name module TypeOfTable TEAMS = { :id => 'int', :name => 'str', :created_at => 'str', :updated_at => 'str', :external_id => 'str'} #fixtures #competitions end def initialize table_name self.table_name = table_name end def table_format ...
true
f39bce0559db3eff566d0c06b2f7fc3242b579ca
Ruby
FabioRC13/Ruby
/CodeAcademy/alphabetize.rb
UTF-8
188
3.53125
4
[]
no_license
#Metodo que organiza um array por ordem crescente ou decrescente def alphabetize(arr,rev=false) arr.sort! if rev return arr.reverse! else return arr end end
true
c67f5e6859affbcb34f22122358cf8c433df0bfc
Ruby
EliezerAmbion/Ruby-Activities
/activity1-control_flow/control_flow4.rb
UTF-8
292
4.25
4
[]
no_license
# Below we have given you an array and a number. # Write a program that checks to see if the number is divisible by 2 and store them into a new array. arr = [6, 3, 1, 8, 4, 2, 10, 65, 102] arr2 = [] arr.each do |each_num| if each_num % 2 == 0 arr2.push(each_num) end end puts arr2
true
209544d132103144a08a4b7a81d096868e87117f
Ruby
APWilson97/RB_120
/rb_120_object_oriented_programming/oo_basics_classes_and_object_1/exercise_1.rb
UTF-8
50
3.453125
3
[]
no_license
puts "Hello".class puts 5.class puts [1,2,3].class
true
b1917071aef04e5188416b47e2c186f1aff5f90d
Ruby
chullman/sandbox
/RandomRuby/arrays2.rb
UTF-8
429
4.09375
4
[]
no_license
students = Array.new #students = [] students.push("Chris") loop do # Ask user for new student puts "Enter the new student's name:" new_student = gets.chomp if new_student.to_s.downcase == "exit" break end # Push the student to the array students.push(new_student.capitalize) #...
true
d3e9eb63221afe4ac6199bf9dde3cfbfb7e42708
Ruby
boochtek/randomly_generated
/lib/randomly_generated.rb
UTF-8
655
2.796875
3
[ "MIT" ]
permissive
require "randomly_generated/version" require "randomly_generated/object" require "randomly_generated/integer" require "randomly_generated/string" module RandomlyGenerated def self.respond_to?(method_name) class_name = method_name.to_s.split("_").map(&:capitalize).join Object.const_defined?("::RandomlyGenera...
true
18aa25c9b18d2721d42ee409ed9d32f6ac40871b
Ruby
YehSal/tots
/tots/app/services/mask_service.rb
UTF-8
5,554
3.5
4
[]
no_license
class MaskService attr_accessor :day_string, :available, :day_size, :hour_size def initialize(day_string, available) #Expects inputs which are binary strings of the format "MTWThFSaSu" and "0:00 0:30 ........23:00 23:30" @day_string = day_string @available = available @day_size = 7 @hour_size = 48 ...
true
90c63ff3e180190e6b6191ca816bd98b11dc03de
Ruby
vcorvington/collections_practice-v-000
/collections_practice.rb
UTF-8
638
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(array) array.sort end def sort_array_desc(array) array.sort do |a, b| b <=> a end end def sort_array_char_count(array) array.sort do |a, b| a.length <=> b.length end end def swap_elements(array) array.sort do |a, b| a[1] <=> b[2] end end def reverse_array(array) ...
true
0a93896f3f20e4fec98c480c81d7e557e3f18742
Ruby
SriHarshaSabbineni/RubyHomework
/1+2.rb
UTF-8
83
3.15625
3
[]
no_license
age = 20 name = "Harsha" puts "I am" + name + "and I am" + age.to_s + "years old."
true
20581888925f06b0e8ba8ce50d0fb8d5fcc5180e
Ruby
young10270/basic_Ruby_Python
/class_member/3.rb
UTF-8
217
3.09375
3
[]
no_license
class Cs @@count = 0 def initialize #@@는 클레스에 속하는 값 @@count = @@count+1 end def Cs.getCount return @@count end end i1 = Cs.new i2 = Cs.new i3 = Cs.new i4 = Cs.new p Cs.getCount
true
e2015f0f93d43e6d5fab82a00c70f05662954a2d
Ruby
govfollower/repfinder
/app/services/propublica_api/get_all_senate_reps.rb
UTF-8
1,330
2.6875
3
[]
no_license
require 'net/http' require 'json' module PropublicaApi class GetAllSenateReps def initialize (as_models) @as_models = as_models == true end def perform url = URI.parse("https://api.propublica.org/congress/v1/115/senate/members.json") http = Net::HTTP.new(url.host, url.port) http...
true
be3be4b574a805f0abca1c33e4a00a072b9465a5
Ruby
krtierney/exercism
/ruby/strain/strain.rb
UTF-8
252
3.046875
3
[]
no_license
class Array def keep(result = [], &block) self.each do |i| result << i if block.call(i) end result end def discard(result = [], &block) self.each do |i| result << i unless block.call(i) end result end end
true
c003f3f6beb9859d293b8eea8628c87361270eb7
Ruby
oscarock/ruby-intro
/challenges/ruby/20-factorial/my_solution.rb
UTF-8
433
3.765625
4
[]
no_license
# Factorial # Tu solucion abajo: def factorial(number) cont = 1 while number>=1 cont = cont*number number = number-1 end return cont end puts factorial(5) # def factorial(number) # if number == 0 # 1 # else # number * factorial(number-1) # end # end # # puts factorial(5...
true
0fca38ba27dd7cc57e4f07828d51e7c88668fa57
Ruby
tolidevs/PokEvolve-app
/app/models/user.rb
UTF-8
6,171
3.25
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class User < ActiveRecord::Base has_many :pokemons has_many :pokemon_families, through: :pokemons def catch_pokemon(name) if PokemonFamily.find_pokemon_family_by_name(name) Pokemon.create(pokemon_name: name, pokemon_family_id: PokemonFamily.find_id_by_name(name), user_id: ...
true
6ccda9d675a1a81a302b1e1c3c69eceafbdc22c7
Ruby
ReggTheSecond/time-keeper
/src/reminder.rb
UTF-8
1,156
2.953125
3
[]
no_license
require 'date' require_relative 'time_constants.rb' require 'colorize' class Reminder < TimeConstants attr_accessor :reminder_name attr_accessor :finish_time REMINDER_COMPLETE = "Reminder: " def set_time_to_be_reminded_at(reminder_time) @finish_time = DateTime.parse(DateTime.now().strftime("%Y-%m-%dT#{remi...
true
93cb2fb5d402bd11f92184414bd9a7583ea977bb
Ruby
ozzman84/2107_enigma
/enigma/spec/encrypt_spec.rb
UTF-8
571
2.796875
3
[]
no_license
# require 'spec_helper' # # RSpec.describe Encrypt do # before :each do # @encrypt = Encrypt.new('Hello! WorLd!', '02715', '040895') # end # # it 'exists & has attributes' do # expect(@encrypt).to be_a(Encrypt) # expect(@encrypt.message).to eq('hello! world!') # end # # it 'returns the converted i...
true
c18b9fc924db1bf9bd08d8329f5ad37ae8acc1b3
Ruby
NexusClash/NexusClash
/behaviour/effect/skill_purchasable.rb
UTF-8
713
2.71875
3
[]
no_license
module Effect class SkillPurchasable attr_reader :parent attr_reader :cp_cost def initialize(parent, cost) @parent = parent @cp_cost = cost end def describe if @parent.respond_to? :name "Learning #{@parent.name} costs #{@cp_cost.to_s} CP." else "Learning this skill costs #{@cp_cost.to_...
true
45775d1c38b4f7a482bc9163d3d189d49fc2a6ca
Ruby
ericchapman/ruby_wamp_client
/lib/wamp/client/transport/base.rb
UTF-8
2,662
2.78125
3
[ "MIT" ]
permissive
require 'wamp/client/serializer' require 'wamp/client/event' module Wamp module Client module Transport class Base include Event attr_accessor :uri, :proxy, :headers, :protocol, :serializer, :connected create_event [:open, :close, :message, :error] # Constructor for the t...
true
96387ece7ebc4575af14fcda50877f93cd2a9f46
Ruby
wenbohan/glados
/test/models/concerns/taggable_test.rb
UTF-8
1,376
2.515625
3
[ "MIT" ]
permissive
require 'test_helper' describe Taggable do let(:article) { Article.create(title: 'Taggable Article Title', subtitle: 'Taggable article subtitle.', body: 'Taggable article body.', posted_on: 'Date.today.to_s(:db)') } it "adds a list of tags to an object" do article.tag_list = 'one, two, three' article.tag...
true
405fa0397dfa21247abbf03e9fdb011ad64860b2
Ruby
natalieytan/teamplayers
/db/seeds.rb
UTF-8
3,403
2.671875
3
[]
no_license
require 'csv' # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Ri...
true
f1a7b38fb0c3054098c268e9bd0217eaaea0e18e
Ruby
JasonRhoads/pathfinder
/undead.rb
UTF-8
309
2.515625
3
[]
no_license
require_relative 'monster' require_relative 'actions' require_relative 'magical_actions' class Undead < Monster attr_accessor :master def initialize (name, hp, move, master = "Necromancer") super(name, hp, move) @master = master @actions = MagicalActions.new(name) end end
true
39ef8120aef38eb51758175b6ce41ec8bc1d5fc3
Ruby
beck/www.ruby-lang.org
/lib/linter/release.rb
UTF-8
1,601
3.046875
3
[]
no_license
class Linter class Release # identifier displayed in error messages attr_reader :name attr_reader :version, :date, :post, :filename def initialize(data) @version = data["version"] @date = data["date"] @post = data["post"] @name = "Ruby #{version} release data (in `#{Linter:...
true
55b99d8a6a09141cf8149f7d796a03269ad814e4
Ruby
countxyz/exercism-atbash-cipher
/lib/atbash_cipher.rb
UTF-8
754
3.203125
3
[]
no_license
class AtbashCipher def initialize substitution @substitution = substitution.split(//) @alphabet_symbol = (:a..:z).to_a @alphabet_string = ('a'..'z').to_a @atbash_array = @alphabet_symbol.zip @alphabet_string.reverse @cipher = @atbash_array.to_h end def encode @substitution...
true
e41a97113bd352d3b47d08d6e654b0d8bd008504
Ruby
jamescanos/RubyExercises
/Level3/practice_exercises/evaluation2.rb
UTF-8
1,112
3.578125
4
[]
no_license
module Similarity def distance_to(other) if block_given? yield other else m = self.length n = other.length print "Other - #{other} - m: #{m} - n: #{n}\n" return m if n == 0 return n if m == 0 d = Array.new(m+1) {Array.new(n+1)} (0..m).each {|...
true
2545c9134f181f059eabe4571deb4b8ed8ee515f
Ruby
Barkha13/hash_methods_demo
/hash_demo.rb
UTF-8
238
3.28125
3
[]
no_license
new_hash = {first_name: "Bob", last_name: "Smith"} hash2 = {:first_name => "Mike", :last_name=> "Will"} puts new_hash.empty? new_hash.delete(:last_name) puts new_hash puts new_hash.has_key?(:first_name) puts new_hash.has_value?("Bob")
true
e955d7d15bdc0e03378a2217e05a760dbe0964ab
Ruby
kimono-k/ruby-training-field
/fundamentals/9math-and-numbers.rb
UTF-8
48
2.78125
3
[]
no_license
# Math and Numbers puts 10 / 7.0 # decimal back
true
ac1ac4b4082d3e4288befc7d197bd868f5e30078
Ruby
curpeng/search-app
/lib/search/message.rb
UTF-8
244
2.53125
3
[]
no_license
# frozen_string_literal: true class Search::Message attr_reader :body def initialize(body) @body = body end def to_json { body: body }.to_json end def ==(other_message) body == other_message.body end end
true
adb9b6af5605bf6fc138f7aa0a5c33e0ec0253f0
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/gigasecond/47e2df84031240b58917685c473bbf5c.rb
UTF-8
111
2.796875
3
[]
no_license
class Gigasecond def self.from(date) date + 10**9/86400; # billion divided by seconds in 1 day end end
true
e6b50e2d44bf38968816033511ae8780e551cfdd
Ruby
89himanshu-dwivedi/Other_Language_Program
/ruby/string.rb
UTF-8
175
2.953125
3
[]
no_license
msg="this tutorial is form javaTpoint" puts msg["javaTpoint"] puts msg["tutorial"] puts msg[0] puts msg[0,2] puts msg[0..20] puts msg[0,msg.length] puts msg[-3]
true
e87373770adc3f9d1a86ddb5d54a1093d7ae8e78
Ruby
ting682/collections_practice-online-web-sp-000
/collections_practice.rb
UTF-8
1,266
3.859375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(array) array.sort end def sort_array_desc(array) array.sort do |a,b| if a == b 0 elsif a > b -1 else 1 end end end def sort_array_char_count(array) array.sort do |a,b| if a.length == b.length 0 ...
true
ee9cbfd378549e08cd288941ea77316e32d25449
Ruby
noctrl-csc495-spring2016/Team-2
/odyssey/app/models/pickup.rb
UTF-8
3,380
2.796875
3
[]
no_license
class Pickup < ActiveRecord::Base belongs_to :day validates :donor_name, presence: true validates :donor_address_line1, presence: true validates :donor_city, presence: true validates :donor_email, presence: true validates :donor_zip, presence: true validates :donor_dwelling_type, presence: true #Func...
true
00bea2551c33689dec3f5acb9ceb00252a682ff5
Ruby
hesoyam-dev/race_threads
/main.rb
UTF-8
382
2.953125
3
[]
no_license
require './car' require './race' require 'colorize' threads = [] cars = [ Car.new('Audi'), Car.new('BMW '), Car.new('Volvo'), Car.new('Mercedes') ] cars.each do |car| threads << Thread.new(car) do |car| car.run end end threads << Thread.new do Thread.current['stop'] = false loop do Race.disp...
true
a0b5e8e0f0103a7be9a8320280f140d86456c7c9
Ruby
sghosh968/simple-server
/app/models/reports/result.rb
UTF-8
6,477
2.671875
3
[ "MIT" ]
permissive
module Reports class Result PERCENTAGE_PRECISION = 0 def initialize(region:, period_type:, data: nil) @region = region @period_type = period_type @quarterly_report = @period_type == :quarter @current_period = if quarterly_report? Period.quarter(Quarter.current) else ...
true
039ec246f395282e592046446283df0c11fc2af4
Ruby
ajwilder/EulerProject
/Ruby/eul9.rb
UTF-8
349
3.765625
4
[]
no_license
def pythagorean?(a,b,c) if a * a + b * b == c * c true else false end end def euler9(n) a = 1 while a < n b = a + 1 while b + a < n c = n - b - a if c > b && pythagorean?(a,b,c) return "#{a},#{b},#{c}" end b = b + 1 end a = a + 1 end end puts euler...
true
3618d30810a51fd740a49b49f703346ec7697374
Ruby
StevenGerdes/ECE421-project-2
/timer.rb
UTF-8
997
3.109375
3
[]
no_license
require 'deferFileNotify' class Timer @@nsec_per_msec = 1000000 def initialize(message, wait_time_ms) @message = message if !wait_time_ms.respond_to? :to_i puts 'invalid wait time: setting it to one second' wait_time_ms = 1000 end @wait_time = wait_time_ms.to_i * @@nsec_per_msec end #Start the time...
true
f1fad1ba38c7b70ba75d3cbe746a2178569fde31
Ruby
bsingr/file_tree_profiler
/lib/file_tree_profiler/file.rb
UTF-8
445
2.734375
3
[ "MIT" ]
permissive
module FileTreeProfiler class File attr_reader :parent, :name def initialize parent, name @parent = parent @name = name end def path ::File.join(parent.path, name) end def relative_path if parent.respond_to? :parent ::File.join(parent.relative_path, name) ...
true
93eec569edac1d1946773c5cdf9a854d8b148545
Ruby
IrynaStein/gallery_db_backend
/app/models/collector.rb
UTF-8
1,543
2.65625
3
[]
no_license
class Collector < ActiveRecord::Base has_many :collections has_many :artworks, through: :collections def self.render_collectors all.map do |collector| { id: collector.id, first_name: collector.first_name, last_name: collector.last_name, email: collector.email, ad...
true
8329429df8edeabf864bc42d910322d0836d8013
Ruby
rwalters/dry-effects
/lib/dry/effects/providers/timestamp.rb
UTF-8
1,774
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true require 'dry/effects/provider' require 'dry/effects/providers/current_time' module Dry module Effects module Providers class Timestamp < Provider[:timestamp] include Dry::Equalizer(:round) include CurrentTime::TimeGenetators Locate = Effect.new(type: ...
true
a9e2b289c8fea5b484169d8b03b87dbe5e1b3a65
Ruby
MicFin/ga-regex-lab
/main.rb
UTF-8
1,392
3.109375
3
[]
no_license
require_relative 'source' require 'pry' def valid_ip_addresses(check) check.scan(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/) end def valid_mit_ip_addresses(check) check.scan(/18\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/) end def non_mit_ip_addresses(check) (check.scan(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/)) - (check....
true
88ff0e0c4f6b0886c58714c9f6a40a6ff71ef750
Ruby
giorgiobornia/cuperativa
/src/base/gfx_general/modal_msg_box.rb
UTF-8
840
2.59375
3
[]
no_license
#file: modal_msg_box.rb module ModalMessageBox ## # Modal message box with question yes / no def modal_yesnoquestion_box(caption, text) if FXMessageBox.question(self, MBOX_YES_NO, caption, text) == MBOX_CLICKED_YES update_dsp return true end update_dsp return false e...
true
7ca5167c13c48e9cd73a70bd31a43795118ce5e9
Ruby
EdmundLeex/action_callback
/test/callback_test.rb
UTF-8
777
2.515625
3
[ "MIT" ]
permissive
require 'test_helper' class CallbackTest < Minitest::Unit::TestCase def setup @callback_chain = Callback::Chain.new end def test_it_initializes_with_before_and_after_callback assert_includes @callback_chain.instance_variables, :@_before_chain assert_includes @callback_chain.instance_variables, :@_af...
true
fd2781eeb55da8d00f0cb47517ff54e53779f31e
Ruby
tobywinter/boris-bikes-2
/spec/DockingStation_spec.rb
UTF-8
1,135
2.765625
3
[]
no_license
require 'DockingStation' describe DockingStation do it { is_expected.to respond_to :release_bike } describe '#release_bike' do it "releases a bike" do @bike = Bike.new subject.dock(@bike) expect(subject.release_bike).to eq @bike end end it "Docks a bike" do bike = Bike.new expect(subject.dock(bike)).to...
true
2079b35bd3c0c66aa6cb3726a68df03e9a59fbc7
Ruby
zamudio/ruby-enumerables-introduction-to-map-and-reduce-lab-seattle-web-102819
/lib/my_code.rb
UTF-8
1,260
3.703125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#maps to return new Array def map_to_negativize(source_array) fnl_array = [] i = 0 while i < source_array.length do fnl_array.push(source_array[i] * -1) i += 1 end fnl_array end def map_to_no_change(source_array) fnl_array = [] i = 0 while i < source_array.length do fnl_array.push(source_ar...
true
0b70c7d66e8042a62330dc62d36b27576bf09f96
Ruby
castrodd/pearls
/4_plus_5/column_four.rb
UTF-8
1,117
4.28125
4
[]
no_license
# Binary Search # Given a sorted array, find the index of target element if in array. If not, report that error. def binary_search(target, array) # Check for empty array and one-element array if array.length == 0 return "Error: element not in array." elsif array.length == 1 && array[0] != target return ...
true
73c88eed9ff28a16891d02b09cbc658fe11dafc0
Ruby
maxplomer/Developer-Applicant-Exercise
/simple_refactoring_exercise/template.rb
UTF-8
379
2.578125
3
[]
no_license
module Template def template(source_template, req_id) source_template .gsub('%CODE%', req_id) .gsub('%ALTCODE%', "#{req_id[0..4]}-#{req_id[5..7]}") end end # Refactor Comments: # repetition of manually written substitution method # not taking advantage of built in methods like gsub # create uncessa...
true
a47537cae757779151bd212593c63aeb0acf5458
Ruby
henare/linksys_am300_statistics
/check_stats.rb
UTF-8
516
2.765625
3
[]
no_license
require './dslmodem.rb' raise "Incorrect number of arguments supplied. Need URL, username and password" if ARGV.size != 3 modem = DSLModem.new(ARGV[0], ARGV[1], ARGV[2]) while true modem.get_stats_page statistics = modem.statistics status = if modem.offline? "Offline" else "Online. Bandwidth: #{stat...
true
7dc44a1293a71bd4308f73e033107b3a56badb04
Ruby
Romantiktak/lessons
/lesson4/rail_road.rb
UTF-8
9,072
3.296875
3
[]
no_license
class RailRoad include InstanceCounter attr_reader :trains, :wagons, :stantions, :routes def initialize @trains = [] @wagons = [] @stantions = [] @routes = [] end def start loop do puts 'Введите 0 чтобы выйти' puts 'Введите 1 чтобы создать станцию' puts 'Введите 2 чтобы...
true
a4b355c6a0c9f086c6483920dc39856cfb32cd4b
Ruby
StephaniePruna/mel-clg-morning-challenges
/term-1/week-3/gems.rb
UTF-8
139
2.6875
3
[]
no_license
require "colorize" puts "hello!".colorize(:blue) puts "hello again!".colorize(:red) require "programmer_joke" puts ProgrammerJoke.joke
true
437ceca53a4f15214e4ff3867b7096aaa96d1f6a
Ruby
tschannes/bm_exercises
/hangman/test/test.rb
UTF-8
1,639
3.421875
3
[]
no_license
require_relative '../hangman2.rb' require 'test/unit' class TestHangman < Test::Unit::TestCase def setup @hangman = Hangman.new @board = "canada" # @chances = 0 end def test_initialize_all_variables assert_equal "", @hangman.string assert_equal 8, @hangman.chances assert_equal "", @hangman.guesses ...
true
ee8d246d2cb72a1cca87ba1d57fcc0ce710eaebe
Ruby
JacobNinja/complexity_for_beginners
/lib/complexity_for_beginners/processors/core_monkeypatch.rb
UTF-8
359
2.609375
3
[]
no_license
class CoreMonkeypatch < Processor CORE = %w(Integer Fixnum String Object) # and so on... def initialize @monkey_patches = Hash.new {|h, k| h[k] = Array.new } end def result @monkey_patches end def process_class(exp) if CORE.include?(exp.value) @monkey_patches[exp.value] << {class: exp....
true