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
79452d5cca308deebf790c16813be8dae0ea8efc
Ruby
hmuronaka/git-ext
/git_ext.rb
UTF-8
1,076
2.78125
3
[]
no_license
#!/usr/bin/env ruby # ex: git_ext # # get issue-id from branchname by regexp. # issue_pattern /issue_([\d]+)$/ do # $1 # end # # # get a url of an issue page. # issue_url do |issue| # "http://issue.com/view/#{issue}" # end module GitExt module Lib def error(message) puts message exit! end ...
true
29edb299aea5f6ca6c8451e7a700896247baf1e9
Ruby
snoozer05/daimon_skycrawlers
/lib/daimon_skycrawlers/storage/file.rb
UTF-8
1,047
2.625
3
[ "MIT" ]
permissive
require "daimon_skycrawlers/storage/base" module DaimonSkycrawlers module Storage # # Storage for files # class File < Base def initialize(base_dir) super() @base_dir = Pathname(base_dir) end def save(url, headers, body) @base_dir.mkpath body_path(ur...
true
f0b40b1f9080da6d6c0b8ada542d5a2f910ddd85
Ruby
nathanl/.dotfiles
/bin/moredates
UTF-8
210
2.71875
3
[]
no_license
#!/usr/bin/env ruby # Output datestamps for recording activity on workdays require "date" today = Date.today (today..today + 30).to_a.reverse.each do |date| puts "#{date.strftime("%Y-%m-%d (%a)")} - " end
true
8ad1aca1c396039dcec492b21926027658d8a221
Ruby
zishe/problems
/stack/node_linked_list.rb
UTF-8
1,747
4.0625
4
[]
no_license
class Node attr_accessor :value, :next_node def initialize(val, next_in_line) @value = val @next_node = next_in_line puts "Initialized a Node with value: #{value}" end end class LinkedList def initialize(val) @head = Node.new(val, nil) end def add(value) current = @head while cur...
true
9daec9fbcf1ffb36dc07d5c32e82ded1da1571b9
Ruby
zwaarty/project_euler
/ruby/problem_046.rb
UTF-8
322
3.09375
3
[]
no_license
require 'prime' class Integer def goldbach_conjecture? Prime.each(self).detect do |pr| a = ((self - pr) / 2.0 ) ** 0.5 (a - a.to_i) < 1.0e-12 end end end ODD_COMPOSITE = (3..Float::INFINITY).lazy.select { |n| n.odd? and not n.prime? } p ODD_COMPOSITE.detect { |oc| not oc.goldbach_conjecture? ...
true
8fc21a5c306ba53cc67f37bdb8280625c54dae9a
Ruby
hoangtommy/rubyExercises
/lib/substrings.rb
UTF-8
827
3.890625
4
[]
no_license
# example dictionary = ["below", "below", "down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit", "below"] # > substrings("below", dictionary) # RETURNS => { "below" => 1, "low" => 1 } # search the list, item by item, for the given word (and its substring) # when a match is found, add ...
true
d7d9afc6c8371a55fa017415c9ce28ebc5b23490
Ruby
jcpny1/oo-student-scraper-v-000
/lib/scraper.rb
UTF-8
1,164
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'nokogiri' require 'open-uri' class Scraper def self.scrape_index_page(index_url) base_path = File.dirname(index_url) + '/' doc = Nokogiri::HTML(open(index_url)) doc.css(".student-card").collect { |student| { :name => student.css("div.card-text-container h4.student-name").text, :lo...
true
d339113ffc6344d1ef0bfa5db4476fd4c060b641
Ruby
danimaleski/Ruby
/classesb.rb
UTF-8
560
4.03125
4
[]
no_license
#Ruby é uma linguagem considerara puramente orientada a objetos #Porque no Ruby tudo são objetos #Classe é uma forma de organizar ações para um determinado objeto. #Classe possui atributos e métodos #Características e ações #Ex: carro (nome, marca, modelo, cor, quantidade de portas, etc) #Ações: ligar, busina...
true
d63dc4da4cf7fdf0da57126ac0f448d6f599e310
Ruby
laboon/fuzzy-wuzzy
/ruby-utils/unicode-helpers.rb
UTF-8
5,073
2.859375
3
[ "MIT" ]
permissive
class UnicodeHelpers def ascii_character_categories { letter_uppercase: ranges_to_array([[0x0041, 0x005A]]), # A-Z letter_lowercase: ranges_to_array([[0x0061, 0x007A]]), # a-z decimal_number: ranges_to_array([[0x0030, 0x0039]]), # 0-9 connector_punctuations: [0x005F], #...
true
31c0cc2685a4b31d516bd6b3114c48f18ef03118
Ruby
bc-luke/panier
/lib/panier/application/cli.rb
UTF-8
1,547
2.921875
3
[ "MIT" ]
permissive
include Panier::Domain module Panier module Application ## # A class responsible for handling the command line interface input. # class CLI EXIT_SUCCESS = 0 EXIT_FAILURE = -1 def initialize I18n.enforce_available_locales = false @service = SalesTaxService.new ...
true
e5468e8ef284bd08ab7d5786e26cc7ffa83791fc
Ruby
garrick/rayd8or
/test/shared/test_web_cc_sample.rb
UTF-8
887
2.53125
3
[ "MIT" ]
permissive
require 'shared/web_cc_sample.rb' require 'test/unit' class TestWebCCSample< Test::Unit::TestCase def setup @unit = WebCCSample.new end def test_data_map @unit = WebCCSample.new expected_map = {:name=>nil, :status => nil, :last_failed => nil, :last_passed => nil, :build_number => nil} assert_eq...
true
12a33d4e2e30473bc4bbd1029dcbb501c31898d2
Ruby
JustinData/GA-WDI-Work
/w01/d04/David/apartment.rb
UTF-8
1,005
3.375
3
[]
no_license
# class Apartment # attr_accessor :apt_name, :price, :is_occupied, :sqft, :num_beds, :num_baths, :renters # def initialize(apt_name, price, is_occupied, sqft, num_beds, num_baths) # @apt_name = apt_name # @price = price # @is_occupied = is_occupied # @sqft = sqft # @num_beds = num_beds # ...
true
8551b518e84d0ae2de4e5e424f7bf0287a2fed1f
Ruby
shirshendu/hackerrank-ai
/lib/botclean/fully_observable/bot.rb
UTF-8
7,460
2.890625
3
[]
no_license
#!/usr/bin/ruby # Head ends here def next_move posx, posy, sizx, sizy, board if File.exists? "solution" steps = read_solution action = steps.shift persist_solution steps return action else best_path = Botclean::FullyObservable::Bot.find_path posx, posy, sizx, sizy, board steps = best_path.s...
true
c313dd66c4a41397ad8f3aa863f513b70f5377e0
Ruby
AbigailMcP/gilded-rose-tech-test
/spec/gilded_rose_spec.rb
UTF-8
4,609
2.984375
3
[ "MIT" ]
permissive
require 'gilded_rose' describe GildedRose do describe "#update" do it "does not change the name" do items = [Item.new("foo", 0, 0)] GildedRose.new(items).update expect(items[0].name).to eq "foo" end it "reduces sell_in by one at the end of the day" do items = [Item.new("foo", 1,...
true
126be62072f4e630977739dd15d179677a044e0c
Ruby
elenastagg/manchester_transport_card
/spec/transport_card_spec.rb
UTF-8
2,540
2.953125
3
[]
no_license
# frozen_string_literal: true require 'transport_card' describe TransportCard do describe '#initilize' do it 'has a default balance' do expect(subject.balance).to equal TransportCard::DEFAULT_BALANCE end end describe '#top_up' do it { is_expected.to respond_to(:top_up).with(1).argument } ...
true
35d7745b1deb2b32ed5fcd4f66740cc6a3338330
Ruby
skalee/safer_tokens
/spec/features/generator_spec.rb
UTF-8
1,103
2.578125
3
[ "ISC", "Ruby", "BSD-2-Clause" ]
permissive
# coding: utf-8 require "spec_helper" describe "Custom generators" do let(:token){ model.set_token! } let(:options){ {} } let(:model) do options_ = options # local variable is accessible in class_eval block ExampleModel.class_eval do token_in :token, options_ private def custom_gener...
true
db777397174eddface6d1e3d1ab695230ef2a6b1
Ruby
naeglinghaff/Battle
/lib/game.rb
UTF-8
1,252
3.71875
4
[]
no_license
# frozen_string_literal: true class Game attr_reader :player_1, :player_2, :current_player, :current_opponent, :game_over def initialize(player_1, player_2) @player_1 = player_1 @player_2 = player_2 @turn = true @current_player = @player_1 @current_opponent = @player_2 @game_over = false ...
true
c0f8e4162f648b6813880592fc385ece266502ed
Ruby
Tkam13/atcoder-problems
/abc023/a.rb
UTF-8
73
3.203125
3
[]
no_license
x = gets.chomp ans = 0 x.size.times do |i| ans += x[i].to_i end puts ans
true
b3c93a2b9342d70cc78d600b9d374e8656ef6a7d
Ruby
upfluence/rbutils
/lib/upfluence/utils/semaphore.rb
UTF-8
690
2.90625
3
[ "MIT" ]
permissive
module Upfluence module Utils class Semaphore def initialize(size) @size = size @used = 0 @mutex = Mutex.new @cond = ConditionVariable.new end def acquire(count = 1) @mutex.synchronize do loop do break if @used + count <= @size ...
true
fa90718172594fe0100ad56cabec5af47535bc84
Ruby
lrs8810/brownfield-of-dreams
/app/facades/invite_facade.rb
UTF-8
397
2.5625
3
[]
no_license
class InviteFacade attr_reader :current_user, :invitee_email, :invitee_name def initialize(user, path) @current_user = user @service = InviteService.new(user.token, path) @invitee_email = nil @invitee_name = nil invitee_json end def invitee_json invitee = @service.retrieve_invitee @...
true
ca962fb53a0d2a51bc95a39eacb3a9c493921ed8
Ruby
h3rald/glyph
/spec/lib/macro_spec.rb
UTF-8
7,762
2.59375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby describe Glyph::Macro do before do Glyph.macro :test do "Test: #{value}" end create_tree = lambda {|text| } create_doc = lambda {|tree| } @text = "test[section[header[Test!|test]]]" @tree = create_tree @text @doc = create_doc @tree @node = Glyph::MacroNode.new.from({:name => :...
true
385148e888f7c07182c0affeb7f5e072bf7c2134
Ruby
jaewooklim1/W4D5
/two_sum.rb
UTF-8
2,078
3.828125
4
[]
no_license
def brute_force_two_sum?(arr, target_sum) (0...arr.length).each do |idx1| (idx1+1...arr.length).each do |idx2| return true if arr[idx1] + arr[idx2] == target_sum end end false end arr = [0, 1, 5, -1, 3, 4] # p brute_force_two_sum?(arr, 6) ...
true
bb70699b809bfd2314749ccacd4179c656a43ddd
Ruby
kmitko19/transport_motion
/monitor.rb
UTF-8
2,573
3.28125
3
[]
no_license
# 4. Метод: Общее состояние дорожного движения на заданный # момент времени от начала движения def monitor @route_m = [] @veh_m = [] @ligth_m = [] # проверка наличия транспортных средств на дороге if @flag_game == false puts "!" puts "The game is not activated" return else end if @veh...
true
0d74853d33f263014f692ff601577242eb08c78f
Ruby
t-awana/RGSS3-Plugins
/menu/title_copyright.rb
UTF-8
1,386
2.671875
3
[ "MIT" ]
permissive
#============================================================================== # ■ タイトル画面に著作権表示 RGSS3 v1.0 MIT License; see git.io/tic #------------------------------------------------------------------------------ #  タイトル画面に任意の著作権表示を描画します。 #====================================================================...
true
1874ceb875e0db1b63f291386f5d7d7a8401be2b
Ruby
rbobbins/secret-santa
/main.rb
UTF-8
1,723
2.90625
3
[]
no_license
require 'optparse' require './lib/santa_shuffler' require './lib/santa_mailer' require './lib/person_list_parser' require 'io/console' options = {} OptionParser.new do |opts| opts.banner = "Usage: main.rb [options]" opts.on("-d", "--dry-run", "Prints Santa output w/o actually sending emails") do |dry_run| ...
true
2245081986902c4a76d82d5aa066f146e61bae2d
Ruby
UiP9AV6Y/docker-container-discovery
/lib/docker/container_discovery/array_tree.rb
UTF-8
4,596
2.84375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Docker module ContainerDiscovery class ArrayTree DEFAULT_WILDCARD = '*' class Node attr_reader :key, :value, :children, :wildcard def initialize(wildcard = DEFAULT_WILDCARD, key = nil, value = [], children = []) @key = key @va...
true
fc430bb039041153f0701c0b8778a5971e9eac08
Ruby
eating247/assignment_knights_travails
/benchmark.rb
UTF-8
514
2.875
3
[]
no_license
require_relative 'knight_searcher.rb' bfs_time = [] dfs_time = [] 1000.times do root_coordinates = [rand(7), rand(7)] b = MoveTree.new([rand(7), rand(7)], rand(5)) a = KnightSearcher.new(b) target_coordinates = [rand(7), rand(7)] bfs_start = Time.now a.bfs_for(target_coordinates) bfs_end = Time.now ...
true
547e3b59f5e64789938e884b71896e3157536777
Ruby
infyloop/ruby_euler
/002.rb
UTF-8
173
3.109375
3
[]
no_license
high = 4000000 arr = [0, 1] while arr.last < high arr << arr[-2] + arr[-1] end arr = arr.select { |n| n%2 == 0 } puts arr.inject(:+) #puts arr.inject(0) {|sum, n| sum+n}
true
9d215a6a2d9678eca7382f75c75562ddc8b65084
Ruby
joeainsworth/launch-school
/102-object-orientated-programming/4-oo-exercises/exercises_hard_1_q1.rb
UTF-8
1,202
3.546875
4
[]
no_license
# Alyssa has been assigned a task of modifying a class that was initially created to keep track of secret information. The new requirement calls for adding logging, when clients of the class attempt to access the secret data. class SecretFile def initialize(secret_data, security_logger) @logger = security_logger...
true
8f790df6e2087203599c1baf992d2111ea7463d4
Ruby
rslim87/my-collect-v-000
/lib/my_collect.rb
UTF-8
149
3.25
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_collect(list) new_array = [] counter = 0 while counter < list.length new_array << yield(list[counter]) counter += 1 end new_array end
true
ad633287a133491819bd13170f2a6906de37660e
Ruby
cesarecamurani/Bank-Tech-Test-Ruby
/spec/feature_tests/print_statement_feature_spec.rb
UTF-8
527
2.890625
3
[]
no_license
require 'bank_account' describe 'feature test display statement' do let(:my_account) { BankAccount.new } it 'displays a statement' do my_account.deposit(2000) my_account.withdraw(500) printed_balance = " date || credit || debit || balance\n"\ " #{Time.now.strftime('%d/%m/%Y')} |...
true
224f79eb3a09de3012f01e474ed7b9d3fd5e32ca
Ruby
khwon/loco
/termapp/processors/select_board_menu.rb
UTF-8
4,316
2.9375
3
[]
no_license
module TermApp # Corresponding Processor of LocoMenu::Item.new('Select', :select_board_menu). # User can navigate Boards and select a Board. class SelectBoardMenu < Processor def process process_init loop do # TODO: Consider setting start point as locoterm.current_board. if @str ==...
true
3f5229561a96ffcce049e10ab6222d69e3f19db1
Ruby
mattkuras/ruby-enumerables-hash-practice-emoticon-translator-lab-online-web-prework
/lib/translator.rb
UTF-8
730
3.203125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'yaml' require 'pry' def load_library(file_path) emoticons = YAML.load_file(file_path) hash = {get_meaning: {}, get_emoticon: {}} emoticons.each do |key, array| hash[:get_meaning][array[1]] = key hash[:get_emoticon][array[0]] = array[1] end hash end def get_japanese_emoticon(file_path, emoticon) i...
true
d168ba3641d90b5135f903d48621a868f474407e
Ruby
sttagami2/Rails-Tutorial4
/Tutorial4.3/4.3.3/3.rb
UTF-8
390
2.921875
3
[]
no_license
# userというハッシュを定義してみてください。このハッシュは3つのキー:name、:email、:password_digestを持っていて、それぞれの値にあなたの名前、あなたのメールアドレス、そして16文字からなるランダムな文字列が代入されています。 user = { name: "Shoto", email: "shoto@gmail.com", password_digest: "abshejdkgndmrjdk" }
true
2bec0a73543a3fa479b0d2a257d48452b5177665
Ruby
RubyOnRails-JHU-605-484/Module5
/3_reporting_system1.rb
UTF-8
367
3.328125
3
[]
no_license
require_relative 'store' class ReportingSystem1 def initialize @store = Store.new end def get_piano_desc @store.get_piano_desc end def get_piano_price @store.get_piano_price end # ...many more simimlar methods... end rs = ReportingSystem1.new puts "#{rs.get_piano_desc} costs #{rs.get_...
true
3fffecbedf5791dd6f5095709ff1d0b6c264672a
Ruby
nantrinh/launch_school
/ruby_small_problems/easy_9/10.rb
UTF-8
250
3.46875
3
[]
no_license
def buy_fruit(arr) arr.each_with_object([]) do |subarr, newarr| subarr[1].times{ newarr << subarr[0] } end end p buy_fruit([["apples", 3], ["orange", 1], ["bananas", 2]]) #== # ["apples", "apples", "apples", "orange", "bananas","bananas"]
true
30841049cbb5ddc793deab163c97239719cde373
Ruby
hc5duke/wordo
/lib/train.rb
UTF-8
1,575
3.0625
3
[]
no_license
require 'rmagick' require 'ai4r' # Train the network puts "Training the network, please wait." # types = [ '_blank', '_dl', '_dw', '_tl', '_tw' ] + ('a'..'z').to_a types = ('a'..'z').to_a @image_size = 12 # Create a network with 256 inputs, and 31 outputs # blank, tw, tl, dw, dl, a-z = 31 net = Ai4r::NeuralNetwork::Ba...
true
d5766152bc3bc629e9eed7e5cf06ce8cd0bbf99d
Ruby
cielavenir/procon
/yukicoder/tyama_yukicoder295_WA.rb
UTF-8
260
2.9375
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby S=gets.split.map(&:to_i) h=[0]*26 gets.chomp.bytes{|b| h[b-97]+=1 } res=1 S.size.times{|i| next if h[i]==0 d,r=S[i].divmod(h[i]) #p [S[i],h[i],d,r] h[i].times{|j| res*=d+(j<r ? 1 : 0) if res>=2**62 puts :hel exit end } } p res
true
0680ee63b8270df60935cab0eacc8de78bbf871c
Ruby
BJSummerfield/PrePrework
/Season3/Episode10/Exercise1.rb
UTF-8
64
3.703125
4
[]
no_license
puts "What's your name?" first = gets.chomp puts "Hey #{first}!"
true
0301758efdce91bd077df4e424c0ebf2ec04702d
Ruby
dvillarama/ladder
/app/models/team.rb
UTF-8
1,833
2.59375
3
[ "MIT" ]
permissive
class Team < ActiveRecord::Base has_one :rating, autosave: true, dependent: :destroy has_many :rosters has_many :players, through: :rosters validate :team_must_be_unique before_create :build_rating def build_rating if self.rating.nil? self.rating = Rating.new end end def team_must_be_u...
true
a7d1b52c8b213f3e665c0e21bdc3069dcf5f560f
Ruby
alexkoltun/logmind
/grocker/grocker.rb
UTF-8
1,502
3.03125
3
[ "Apache-2.0" ]
permissive
require "rubygems" require "pp" items = [] File.open('sample.txt').each do |line| print line items << line end # Determine encoding format, (1) csv (2) name-value (3) json (4) yaml (5) xml (6) text # If text determined then do the following # Try to extract parameters from the current line # In the f...
true
1fc673223b86a6fc0d91abc792382fdb8b10eb9d
Ruby
NARKOZ/imgur
/lib/imgurapi/api/account.rb
UTF-8
597
2.609375
3
[ "MIT" ]
permissive
module Imgurapi module Api class Account < Base # https://api.imgur.com/endpoints/account#account def account Imgurapi::Account.new communication.call(:get, 'account/me') end # https://api.imgur.com/endpoints/account#images def images(page = 0) communication.call(:g...
true
17f59b860c36f2074a9ed5dd8b129b5daf8e0662
Ruby
dallasread/remetrically
/app/services/importer.rb
UTF-8
1,288
2.640625
3
[]
no_license
class Importer def initialize(user_id) @user_id = user_id end def user @user ||= User.find @user_id end def spreadsheet @spreadsheet ||= open_spreadsheet end def import row_count = spreadsheet.count (2..spreadsheet.last_row).each do |i| data = Hash[[headers, spreadsh...
true
57ec8bb33b36c8b234a99e32f527d955d58faa96
Ruby
elmendalerenda/are_we_rich_yet
/lib/options_agreement.rb
UTF-8
462
2.703125
3
[]
no_license
module AWRY class OptionsAgreement < Struct.new(:stock, :strike_price, :grant_date, :cliff_pct, :cliff_n_months, :vesting_period) def initialize(hash) hash.each do |key, value| send("#{key}=", value) end end def cliff_release_portion cliff_pct / 100.0 end def vested_mon...
true
84ea27978455586d30383a939804e7492546ac56
Ruby
dowpm/ttt-4-display-board-rb-noukod-000
/lib/display_board.rb
UTF-8
364
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Define display_board that accepts a board and prints # out the current state. def display_board(state_array) puts " #{state_array[0]} | #{state_array[1]} | #{state_array[2]} " puts "-----------" puts " #{state_array[3]} | #{state_array[4]} | #{state_array[5]} " puts "-----------" puts " #{state_array[6]} | ...
true
ea6b003b394bf60930cbd5e2aef7526736d5958a
Ruby
absessive/locale-to-redis
/scripts/locale_to_redis.rb
UTF-8
1,974
2.875
3
[]
no_license
#! /usr/bin/env ruby require 'optparse' require 'yaml' require 'redis' require 'redis-namespace' require 'colorize' # require 'google-api-client' # Define all the helper methods here def create_redis_connection(namespace) $redis = Redis::Namespace.new(namespace, redis: Redis.new) end def recurse(obj, current_path =...
true
e07246eec8c5f35e00ad430e5ce0247f5cee3e11
Ruby
abhishekkr/wwwtf
/lib/wwwtf/http/url.rb
UTF-8
448
2.546875
3
[ "MIT" ]
permissive
# Wwwtf::HTTP::URL module Wwwtf module HTTP module URL def self.unroot(url) File.join File.dirname(url), File.basename(url) end def self.same(url1, url2) url1 = url1.gsub(/^https*\:\/\//, '') url2 = url2.gsub(/^https*\:\/\//, '') File.expand_path(url) === File....
true
43d00de6f06cbaa54fe7bbae22065051478b79e1
Ruby
radubogdan/rspark-spark
/spec/rspark/spark_spec.rb
UTF-8
682
2.75
3
[ "MIT" ]
permissive
require 'spec_helper' describe Rspark::Spark do let(:s) { Rspark::Spark.new( values: [10, 15, 25, 50, 40, 20] ) } describe "#pretty_print" do it "should return the graph when direction is horizontal" do expect(s.pretty_print).to eq("▂▃▄█▆▃") end it "should return the graph when ...
true
259ffb264628c5c5fa9c67d6accf9759ba123372
Ruby
zackseuberling/danger
/lib/danger/helpers/comments_parsing_helper.rb
UTF-8
1,954
2.671875
3
[ "MIT" ]
permissive
module Danger module Helpers module CommentsParsingHelper # !@group Extension points # Produces a message-like from a row in a comment table # # @param [String] row # The content of the row in the table # # @return [Violation or Markdown] the extracted message ...
true
e0d9e23480ff4b1ccb173e254e55c08341426443
Ruby
lacofabrique/lacofabrique.fr
/_plugins/string.rb
UTF-8
149
3.125
3
[]
no_license
class String def capitalize_first_char self[0].capitalize + self[1..-1] end def uncapitalize self[0].downcase + self[1..-1] end end
true
d64a79205a93e87039b1eea5813ca09a145953b3
Ruby
vivencio2/gsruby-scraper
/src/api/frank.rb
UTF-8
1,517
2.515625
3
[]
no_license
require 'sinatra' require 'sinatra/namespace' require 'redis' require 'json' get '/' do redirect '/api/v1/' end namespace '/api/v1' do before do content_type 'application/json' end get '/' do 'Hi, I''m Frank Sinatra API - API Details: + "/api/v1/partners" - Get all partners from all countries and location ...
true
4654e74240146ed1ae9bcb92e766edd50b159e89
Ruby
duquesnay/BankOCR
/ocr_test.rb
UTF-8
2,945
2.921875
3
[]
no_license
require "test/unit" require 'minitest/reporters' require './ocr.rb' require './ocr_utils.rb' # MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new class OcrTest < Test::Unit::TestCase include OcrUtils @ocr def setup @ocr=Ocr.new end # Called after every test method runs. Can b...
true
50b584575f92057a5544fc559f66e965a4c3af1f
Ruby
OlegPritula/first_ror_lessons
/Chapter01.rb
UTF-8
379
4.21875
4
[]
no_license
puts (24*365).to_s + ' hours in a year.' #how many hours are in a year? puts puts (60*24*365*10).to_s + ' minutes in a decade.' #how many minutes are in a decade? puts puts 'I am ' + (41*365*24*60*60).to_s + ' seconds old.' #how many seconds old are you? puts puts 'You are ' + (1298000000/60/60/24/365).to_s + ' y...
true
fd09698330b36f553de3cd01b61f80066d0ffb9a
Ruby
kiran-gurujada/pickaxe
/chapter12/count_words2.rb
UTF-8
438
3.765625
4
[]
no_license
# analyse a text file, counting occurences of each word # split into two parts, a method that reads the file and yields # successive words, and a block that does the counting def yield_words(file_name) File.foreach(file_name) do |line| line.scan(/\w+/) do |word| yield(word) end end end counts = Hash...
true
72c1f076b82366eb6121d8ad1ba7fff6a581341d
Ruby
simha-r/spoonly_backend_and_api
/lib/sms_provider.rb
UTF-8
1,347
2.5625
3
[]
no_license
require 'nexmo' require 'telerivet' module SmsProvider def send_message_with_nexmo phone_number,message nexmo = Nexmo::Client.new(key: ENV['NEXMO_API_KEY'], secret: ENV['NEXMO_API_SECRET']) nexmo.send_message(from: 'SPOONL', to: "91#{phone_number}", text: message) end def self.send_message_with_infini...
true
1cee2783721a4c4b9090d66a195d5903545376ad
Ruby
IsaiahJean/LS_Courses_1
/LS_101/small_problems/easy_4.rb
UTF-8
7,163
4.5625
5
[]
no_license
1. Short Long Short =begin Write a method that takes two strings as arguments, determines the longest of the two strings, and then returns the result of concatenating the shorter string, the longer string, and the shorter string once again. You may assume that the strings are of different lengths. =end Answer: def ...
true
fb1aab7f8b1199af15a636922e65ce0ec07a5ced
Ruby
DanielGlezExp/LPP10
/lib/huella_ambiental/PlatoExtendido.rb
UTF-8
1,051
3.234375
3
[]
no_license
#Clase platExtendido que hereda de la clase Plato #Respoecto a la clase Plato, PlatoExtendido además tiene co2 y terreno class PlatoExtendido < Plato attr_reader :co2, :terreno #Inicializar un objeto de la clase PlatoExtendido def initialize(lista_alimentos, nombre) super(lista_alimentos,nombre) inicial...
true
0f673ebe0f2bcd854a8afe859fa7fc9c3b1b1d8f
Ruby
RodrigoACortes/Basic_Ruby
/BRuby.rb
UTF-8
3,559
4.59375
5
[]
no_license
# Create a function that takes a string as an argument and adds the phrase "Only in America!" to the end of it # def america(string) # puts string + ', Only in America!' # end # # america('hi') # Create a function that takes two arguments, adds them together and returns their value split in 3 # def math(number1, n...
true
fa674e4ae8db538851e654defc654cbcc867490b
Ruby
aaronjensen/git-lead-time
/lib/git_lead_time/first_commit_finder.rb
UTF-8
605
2.53125
3
[ "MIT" ]
permissive
require 'set' module GitLeadTime class FirstCommitFinder attr_reader :target_refs def initialize(merge_target) @target_refs = Set.new(first_parents(merge_target)) end def first_commit(ref) first_commit = ref first_parents(ref) do |parent| break if target_refs.include? paren...
true
67fa77f07ba586dace482a289a3e3110808b8dca
Ruby
eaquimbayo/EAQC_Rails
/clases.rb
UTF-8
133
3.078125
3
[]
no_license
class MiClase def initialize puts 'instancia de clase' end end instancia = MiClase.new puts instancia.class
true
d54f8df91dc7dd6923b1096e11db462a7c596da9
Ruby
ukoloff/em-wssh
/lib/em/wssh/help.rb
UTF-8
660
2.578125
3
[ "MIT" ]
permissive
require_relative 'exe' module EventMachine::Wssh module Help Title='Show this help' def self.go! if mod = Exe.command?(ARGV.shift) command mod else top end end def self.top require_relative 'all' puts <<-EOT WSSH suite v#{VERSION} Usage: wssh command [parameters...] Availa...
true
0f17e40e2cef491be56bea0bc78b9300b74cdcae
Ruby
DIzosimov/ruby_exercises
/hello_world.rb
UTF-8
109
3.0625
3
[]
no_license
=begin #hello_world.rb names = ['David', 'Daniel', 'Axel'] names.each do |name| puts "Hello #{name}" end
true
c8a0824e056d93409478d33b0dbc7757502d0c29
Ruby
jamessct/hangman
/word.rb
UTF-8
653
3.90625
4
[]
no_license
class Word # This class holds the word (provided by the dictionary) and provides the game with the abilty to: # 1. Obfuscate the word # 2. Guess letters and # 3. Check if all letters have been guessed attr_reader :guess def initialize(word) @word = word @guess = "_"*word.length end def correct_guess?...
true
d1239169832b06f2e9f117e61a4406022f39148f
Ruby
lwoggardner/rfusefs
/lib/fusefs/pathmapper.rb
UTF-8
13,518
2.71875
3
[ "MIT" ]
permissive
module FuseFS begin require 'ffi-xattr' HAS_FFI_XATTR = true rescue LoadError warn "ffi-xattr not available, extended attributes will not be mapped" HAS_FFI_XATTR = false end # A FuseFS that maps files from their original location into a new path # eg tagged audio files can be mapped by ...
true
82a3d47f74ede801fff5edba1c7a006decfdce0d
Ruby
gglin/project-euler
/ruby_all/244.rb
UTF-8
1,289
3.578125
4
[]
no_license
# Problem 244: Sliders # http://projecteuler.net/problem=244 # You probably know the game Fifteen Puzzle. Here, instead of numbered tiles, we have seven red tiles and eight blue tiles. # A move is denoted by the uppercase initial of the direction (Left, Right, Up, Down) in which the tile is slid, e.g. starting from co...
true
f896cc237a6e6326cbd71943a996020a60671193
Ruby
ludat/ApprenticeshipTemplate
/TusLibros/app/models/cashier.rb
UTF-8
916
3.0625
3
[]
no_license
class Cashier def initialize(merchant_processor) @merchant_processor = merchant_processor end def charge(cart, to:) assert_cart_is_not_empty(cart) to.save! @merchant_processor.charge_to(to, price_of(cart)) record_sales_from_cart(cart) cart.destroy! end def assert_cart_is_not_empty...
true
4531fc7c2ae4128d3c044d022463711f29aee690
Ruby
somayajs/paly-around
/ruby/string-shifted.rb
UTF-8
187
3.234375
3
[]
no_license
#!usr/bin/env ruby # shift the sting nultiple numbers colors = "RRGGBBYYKK".split("") lines = 25 1.upto(lines) do |char| first = colors.shift colors << first puts colors.join end
true
245fc3c378df10d830888966cf1d127cb564b001
Ruby
ankurmans/dev-in-the-making
/ruby-practice-problems/CB Larger_num.rb
UTF-8
160
3.125
3
[]
no_license
def CheckNums(num1,num2) if num2 - num1 == 0 return -1.to_s elsif num2 - num1 > 0 return true else return false end end
true
3da24de61b0104ffd0826dbd6d93cb9982922680
Ruby
isikyus/inevitable-cacophony
/lib/inevitable_cacophony/octave_structure.rb
UTF-8
6,234
3.359375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'inevitable_cacophony/parser/scale_description' module InevitableCacophony # Represents Dwarf Fortress scales, and the chords and understanding # of octaves used to build them. class OctaveStructure # Frequency scaling for a difference of one whole octave OCTAVE_RAT...
true
0f9cc63c0fbefde3e4e170d9bf86376885fb688b
Ruby
asomers/zfs-ffi
/lib/zfs/nvpair.rb
UTF-8
1,007
2.765625
3
[]
no_license
require "zfs/libnvpair" require "zfs/nvvalue" class NVPair # Generate an NVPair from a native object. def self.from_native(nvp) nvp_type = LibNVPair.nvpair_type(nvp) name = LibNVPair.nvpair_name(nvp).force_encoding("UTF-8") nvv = NVValue.get_class(nvp_type).from_native(nvp) new(name, nvv, nvp_type)...
true
83abe4bccacda74e3e2fb6312b2c2a231699ab05
Ruby
moskyt/imf
/2015_2016/06/package/doc/generate.rb
UTF-8
613
2.84375
3
[]
no_license
require 'fileutils' def gnuplot(cycle, variable, y_title, column) template = IO.read("template.gp") template.gsub!("{cycle}", cycle.to_s) template.gsub!("{variable}", variable.to_s) template.gsub!("{y_title}", y_title.to_s) template.gsub!("{column}", column.to_s) FileUtils.mkdir_p("gp") File.write("gp/...
true
55443cf32b5e6144361d49c7c8dff7d7f1f54ef6
Ruby
realb0t/tinkoff-spy
/lib/parser/tinkoff.rb
UTF-8
1,083
2.734375
3
[]
no_license
require 'json' class Parser class Tinkoff < self def data response = HTTParty.get('https://www.tinkoff.ru/api/v1/currency_rates/') data = response.present? ? response.with_indifferent_access : {} if response.code == 200 && data[:resultCode] == "OK" dataTransforme(data) ...
true
fb880c9f1d030c9030d099cc5253daabb6c8bcdd
Ruby
latpaw/node
/okcoin.rb
UTF-8
530
2.796875
3
[]
no_license
require "nokogiri" require "open-uri" require "json" price = 0 while true do doc = Nokogiri::HTML(open("https://www.okcoin.com/api/ticker.do?symbol=ltc_cny")) result = JSON.parse doc.content newprice = result["ticker"]["sell"] if newprice.to_f > price system "growlnotify -m \"Rising,#{newprice}\"" pric...
true
a5363f66a74bce7e221746e0cb8beea4daf7d474
Ruby
dkintop/badges-and-schedules-online-web-ft-090919
/conference_badges.rb
UTF-8
589
3.71875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def badge_maker(name) "Hello, my name is #{name}." end def batch_badge_creator(names) batch = [] names.each do |name| a = badge_maker(name) batch << a end batch end def assign_rooms(speakers) list = [] speakers.each_with_index do |speaker, room_number| room_number +=1 a = "Hello, #{...
true
95fbb8258c096aef010b77a6d2c229c635f534a9
Ruby
gjmcgough/phase-0-tracks
/ruby/secret_agents.rb
UTF-8
1,652
4.15625
4
[]
no_license
# create interface, ask whether encrypt or decrypt password and loops until valid data loop = false until loop puts "Would you like to encrypt or decrypt a password?" choice = gets.chomp if choice == "encrypt" || choice == "decrypt" loop = true else puts "I don't understand" end end # asks for pas...
true
2a6dcc511e2bc40113794f1cfa7775987e071e4b
Ruby
jaygoyal/firehose_app
/app/controllers/pics_controller.rb
UTF-8
498
2.53125
3
[]
no_license
# We used this to create ways for information to get put into the DB # This also allows us to display the information in the DB #Controller #@pics communicates with "model" that communicates with "DB" class PicsController < ApplicationController def index @pics = Pic.all end def new @pic = Pic.new end ...
true
72404444feb64b7fe25d19cbeb4e4fdb105a1735
Ruby
FarazPatankar/ProjectEuler
/multiples-of-3-and-5/app.rb
UTF-8
409
4.34375
4
[]
no_license
# *****PROBLEM***** # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. # *****PROBLEM***** def sum_of_multiples(max_range) sum = 0 (1..(max_range - 1)).each do |num| if num...
true
11e63669df6cd2ef8af08968baec4bc0b0c45ef1
Ruby
pixapi/sorting_suite
/lib/insertion_sort.rb
UTF-8
526
3.84375
4
[]
no_license
class InsertionSort def sort(letters) unsorted = letters sorted = [] (letters.length).times do i = 0 temp = unsorted.shift.to_s until sorted.include?(temp) if sorted[i] != nil && sorted[i].to_s < temp i += 1 else sorted.insert(i, temp) ...
true
5b971d3e5fd743d7dcf413a7c099c1e513df5a4f
Ruby
beaucouplus/drivy
/backend/level6/main_test.rb
UTF-8
10,303
3.015625
3
[]
no_license
require 'minitest/autorun' require_relative 'main' require 'fileutils' class DrivyTest < Minitest::Test def setup @example_json = import_json("output.json") @generated = "generated.json" end def test_output_json_and_data_json_should_be_equivalent File.delete(@generated) if File.exist?(@generated) ...
true
d9f4b39c21a2c9159cc53196300794be2f38eacb
Ruby
castor4bit/atcoder
/AtCoder_Beginner_Contest/149/C_-_Next_Prime/C.rb
UTF-8
236
3.515625
4
[]
no_license
x = gets.to_i def is_prime(n) return false if n < 2 return true if n == 2 return false if n % 2 == 0 3.step(Math.sqrt(n), 2) do |i| return false if n % i == 0 end true end while !is_prime(x) do x += 1 end puts x
true
51c3f76f815c36ecac3cd55c1e635a9c868f27a4
Ruby
johnvoon/launch_school
/130/exercises/medium1/passing_parameters3.rb
UTF-8
531
4.3125
4
[ "MIT" ]
permissive
items = ['apples', 'corn', 'cabbage', 'wheat'] def gather(items) puts "Let's start gathering food." yield(items) puts "We've finished gathering!" end gather(items) do |*vegetables, produce| puts vegetables.join(', ') puts produce end gather(items) do |item, *vegetables, item2| puts item puts vegetables...
true
17afec77a2d6747c7d40e875433f08b79eba5845
Ruby
Dean-Delagrange/RB101
/lesson_4/practice_problems/methods/9.rb
UTF-8
138
3.1875
3
[]
no_license
# Capitalize the first character in each word words = "the flintstones rock" p words.split.map { |word| word.capitalize! }.join(' ')
true
1139d76711659f3913a7d2eb07d169e7070be585
Ruby
grumpyjames/Compass
/ruby/test/tc_robber_action.rb
UTF-8
999
2.578125
3
[ "MIT" ]
permissive
require 'test/unit' require '../test/fake_player.rb' require '../test/fake_board.rb' require '../test/fake_game.rb' require '../impl/robber_action.rb' require '../impl/resource.rb' class TC_RobberAction < Test::Unit::TestCase def test_action_forces_discard robber_action = RobberAction.new fake_board = Fak...
true
edd0aff8a38e47e3e893b740bcc9b7b5c2914fcc
Ruby
Jenniferzhan/ruby_codes
/idxiangtong.rb
UTF-8
87
2.640625
3
[]
no_license
str1 = "foo" str2 = str1 str3 = "f" + "o" +"o" p str1.equal?(str2) p str1.equal?(str3)
true
1cd071dbcef113ccb6354ca396379dcaea9833c2
Ruby
Sahhm/07-09-API
/models/articlesorvideo.rb
UTF-8
700
2.8125
3
[]
no_license
require_relative "ClassMethods.rb" class Articlesorvideo extend DatabaseClassMethods attr_reader :id attr_accessor :medialink, :assignment_id #initializes a new course object #sets object attributes to whatever was entered def initialize(work_options={}) @id = work_options["id"] @med...
true
5366d64e823261abfcf1e597f6779caea370a015
Ruby
rhivent/ruby_code_N_book
/book-of-ruby/ch3/string_concat.rb
UTF-8
920
4.375
4
[]
no_license
# The Book of Ruby - http://www.sapphiresteel.com # String concatenation # << string concatenation method << converts FixNum integers (but not floats) to string # Valid Fixnums are in the range 0 to 255 s1 = "This " << "is" << " a string " << 10 # try a float such as 10.5 or an int such as 256 # + method concatenate...
true
212b5bf39f29c3265c93c37ba9f2145676786bd9
Ruby
vsp2old/bspline
/ext/bspline/example/exdspline.rb
UTF-8
1,988
3.1875
3
[]
no_license
#! /usr/local/bin/ruby require 'bspline' include BSPLINE =begin # Interpolation with boundary condition by differential value 【Module】 BSPLINE 【Class】 Bspline 【Method】 (1)new Initialize obj = Bspline.new([[x1,y1],...,[xn,yn]],j,[[xn+1,yn+1],...,[xn+d,yn+d],[b1,...,bd]) :1 list of data points. :2 dimension :3...
true
620459f7b63359af947b0bfe1402cd9521741fd9
Ruby
spotch/project-euler
/ruby/spec/problem2_spec.rb
UTF-8
549
3.078125
3
[]
no_license
require 'problem2' describe Problem2, "#GetSumOfEvenValuedTermsOfFibonacciSequence" do it "sums even valued terms from fibonacci sequence" do limit = 346 fibonacciSequence = [1,2,3,4,5,6,7,8] sumOfEvens = 2 + 4 + 6 + 8 fibonacciSequenceGenerator = double("Fibonacci Sequence Generator") fibonacciSequenceG...
true
3f3eca0b679cea6ddeaf5df176f09a51756dfc75
Ruby
sccp2017/defective-project
/src/03_function/map_hard.rb
UTF-8
152
2.828125
3
[]
no_license
require_relative "./inject_normal.rb" # You can not use loop and recursion def map(arr) inject(arr, []){|acc, x| acc + [yield(x)] } end
true
6f4055c88572d58624f0b57a336da6573c104c24
Ruby
guidance-guarantee-programme/pension_guidance
/app/lib/entity.rb
UTF-8
405
2.71875
3
[ "MIT" ]
permissive
require 'active_model' class Entity include ActiveModel::Validations attr_accessor :id private :id= validates :id, presence: true def initialize(id, attributes = {}) self.id = id Array(attributes).each do |name, value| send("#{name}=", value) if respond_to?("#{name}=") end end def ...
true
de0d3c373317697fa08705f9f8630a7d002b2c92
Ruby
H-L/ruby-lab
/exo1.rb
UTF-8
132
3.78125
4
[]
no_license
puts "Enter your name: " name = gets.chomp.capitalize puts "Hello #{name} ! How old are you ?" age = gets.chomp.to_i puts age.even?
true
fb376a012bd623ea7945b4a35a9b0ef0cfb52df7
Ruby
adamof/smart_energy
/app/models/carbon_record.rb
UTF-8
334
2.578125
3
[]
no_license
class CarbonRecord < Record def self.for(date) if record = self.find_by_period_end(date.beginning_of_hour) return record.amount else return self.where("period_end >= ? AND period_end < ?", date, date + 1.month).group("date_trunc('month', period_end)").average(:amount).values.last.to_f.round(2) ...
true
9566fc8a0ae7856b811a2feb45f1a170b0b77e71
Ruby
xswordsx/Ruby-RPG
/lib/chest.rb
UTF-8
186
2.875
3
[]
no_license
require_relative 'item.rb' class Chest < Tile attr_reader :items def initialize(items, mob) super(true, mob) @items = items end def empty? @item.empty? end end
true
5103212840b4535e2b71786e10b043d07f937565
Ruby
kostya/myhtml
/bench/xtime.rb
UTF-8
310
2.515625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby def mem(pid); `ps p #{pid} -o rss`.split.last.to_i; end t = Time.now pid = Process.spawn(*ARGV.to_a) mm = 0 Thread.new do mm = mem(pid) while true sleep 0.1 m = mem(pid) mm = m if m > mm end end Process.waitall STDERR.puts "%.2fs, %.1fMb" % [Time.now - t, mm / 1024.0]
true
019e020112b3d0df56b9cded045de007908dfe54
Ruby
djc00p/Enigma-Project
/lib/decrypt.rb
UTF-8
341
2.828125
3
[]
no_license
require './lib/enigma' handle = File.open(ARGV[0], "r") incoming_text = handle.read handle.close enigma = Enigma.new decrypted_text = enigma.decrypt(incoming_text, "91645") writer = File.open(ARGV[1], "w") writer.write(decrypted_text[:decryption]) writer.close puts "Created #{ARGV[1]} with a key #{enigma.key} and ...
true
18083406663900e74476ed245865bb1f2c845a12
Ruby
eriksk/shirokuro
/lib/shirokuro/ecs/id_generator.rb
UTF-8
90
2.734375
3
[ "MIT" ]
permissive
class IdGenerator def initialize @current = 0 end def next @current += 1 end end
true
874c2e8dd4bee80260cda9f7a71a51db02baaf9f
Ruby
mojolingo/talking_stick
/spec/models/talking_stick/room_spec.rb
UTF-8
1,012
2.515625
3
[ "MIT", "BSD-3-Clause", "Apache-2.0" ]
permissive
require 'spec_helper' module TalkingStick RSpec.describe Room, type: :model do describe "#validation" do subject { described_class.new(name: "Test") } it "automatically sluggifys the room name" do expect { subject.valid? }.to change{ subject.slug }.from(nil).to("test") ...
true
a534b453cc349681cec10a1cadf766c08da4eff4
Ruby
jruby/rubysl-socket
/spec/ipsocket/getaddress_spec.rb
UTF-8
679
2.65625
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
require 'socket' describe 'IPSocket#getaddress' do describe 'when given a hostname' do it 'returns the IP address of the hostname' do addr = IPSocket.getaddress('localhost') %w{127.0.0.1 ::1}.include?(addr).should == true end end describe 'when given an IP address' do it 'returns the IP...
true
94bae147cf8c1b434f17f1f7e7503f4d3cb8eb46
Ruby
jbmyid/gorss
/app/models/tab.rb
UTF-8
430
2.78125
3
[]
no_license
require 'uri' class Tab < ActiveRecord::Base attr_accessible :name, :url, :category_id validates :name, :url, presence: true validates :name, length:{maximum: 50} validate :valid_url? belongs_to :category belongs_to :user def valid_url? uri = URI.parse(url) self.errors[:url] << "is invalid url" ...
true
0e904c0bc69cce92c6d35207691e1f148af15e71
Ruby
SrinivasPithani/devops
/ruby/arguments.rb
UTF-8
275
3.3125
3
[]
no_license
#!/usr/bin/ruby main, *args = ARGV puts "do you want to continue: " resp = "Y" if args.length <= 2 puts "insufficent arguments" else puts "good" end count = args.length case count when 2 .. 5 puts "5 args" when 5 .. 10 puts "more args" else puts "hefty args" end
true