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
30f722995586b23c59601226561a0acf9cc723e2
Ruby
louman/sales_taxes
/lib/sales_taxes/model/taxable_item.rb
UTF-8
193
2.671875
3
[]
no_license
require_relative 'tax' class TaxableItem attr_reader :item def initialize(item) @item = item @item.taxes << Tax.new(self.class.name, @item.price * rate) if applicable? end end
true
06a296219796897891f85f80ce91a0b98228efe2
Ruby
AndrewLosseff/codewars
/8-kyu/004-string-repeat/index.rb
UTF-8
771
3.875
4
[]
no_license
# Solution def repeat_str (n, s) newString = '' n.times do |i| newString += s end newString end # Solution def repeat_str (n, s) newString = '' for i in 1..n newString += s end newString end # Solution def repeat_str (n, s) s * n end # Solution def repeat_str (n, s)...
true
6a0ca06d7d68467c210bd3cb3e4febc08d196521
Ruby
bobgreenshields/start-spideroak
/spec/tmux/session_spec.rb
UTF-8
1,228
2.796875
3
[]
no_license
require "tmux/session" describe Tmux::Session do describe "#initialize" do subject(:session) { Tmux::Session.new(session_string) } context "with a good session string" do let(:session_string) { "spideroak: 1 windows" } it "returns a Session object" do expect(session).to be_an_instance_of Tmux::Sessio...
true
3548bba3322eee0e82965f4a006708cbc3d73d43
Ruby
jwharrow/backpack
/dumb_picker.rb
UTF-8
764
3.234375
3
[]
no_license
require_relative 'backpack' class DumbPicker def self.run(items, capacity) self.new.run(items, capacity) end def run(items, capacity) backpacks = all_backpacks(items) backpacks.reject{ |backpack| backpack.cost > capacity } .sort(&:value) .first end def all_backpacks(items) ## gathering ...
true
7942b54e8f7213a3df808a610d9e3417ac5094ec
Ruby
moh-alsheikh/rubypractice
/rubyp2.rb
UTF-8
65
2.9375
3
[]
no_license
vage = gets.chomp unless vage.to_i == 50 print "ok \n" end
true
4cd9ed789a0439ecb7bd9f6e4058d4debb91d9ae
Ruby
johnfelipe/mapa76
/aphrodite/app/services/link_service.rb
UTF-8
708
2.8125
3
[]
no_license
require 'tempfile' require 'open-uri' class LinkService attr_reader :file_url, :user def initialize(file_url, user=nil) @file_url = file_url @user = user end def call begin Tempfile.open(filename, encoding: 'ascii-8bit') do |file| open(file_url, 'rb') do |read_file| file.w...
true
d536fdaa3550bf0c7968f623275bb67e82c56a0c
Ruby
karlwitek/launch_school_rb101
/lesson1/small_problems/Easy_4/convert_to_signed.rb
UTF-8
1,850
4.4375
4
[]
no_license
# Add to this method so the return value is a positive # or negative number, depending on the string passed in, # (if there is a '+' or '-' sign before the number) HASH = { '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9 } def string_to_integer2(string) sign = '' ...
true
5e7e6b3a106a0d24fe9410d7006aa39453edd868
Ruby
Thatguy560/Banktechtest
/lib/bankstatement.rb
UTF-8
578
3.234375
3
[]
no_license
class Bankstatement def print(transaction_history) @transaction_history = transaction_history puts "date || credit || debit || balance\n" print_transactions end def convert_to_2dp(number) number == 0 ? "" : "%.2f" % number end def print_transactions transaction_array = @transaction_hist...
true
c249a6e9a26389c267a5cf382faca41a2520f51a
Ruby
octonion/hockey
/uscho/scrapers/uscho_games.rb
UTF-8
2,179
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'csv' require 'mechanize' agent = Mechanize.new{ |agent| agent.history.max_size=0 } agent.user_agent = 'Mozilla/5.0' d1_base = 'https://www.uscho.com/scoreboard/division-i-men' d3_base = 'https://www.uscho.com/scoreboard/division-iii-men' first_year = ARGV[0].to_i last_year = ARGV[1].to_...
true
d8e8c5f8f88b1de5db19e58466cf138d21a0016e
Ruby
katylee228/phase-0-tracks
/ruby/secret_agents.rb
UTF-8
600
3.515625
4
[]
no_license
def encrypt(str) i=0 while i<str.length if str[i]=="z" print str[i]="a" i+=1 end print str[i].next i+=1 end end def decrypt(str) i=0 while i<str.length if str[i]=="a" print str[i]="z" i+=1 end print (str[i].ord-1).chr i+=1 end end puts "would you like to decrypt or encrypt...
true
090f8153bbf6ebed2545c56bf984142e9df4b34e
Ruby
shawn42/chessbox
/src/actors/bishop.rb
UTF-8
271
2.796875
3
[]
no_license
class Bishop < ChessPiece def move_valid?(to_file, to_row, ignore_check_rules = false) if valid_diagonal_move? to_file, to_row if ignore_check_rules return true else return !move_puts_self_in_check?(to_file, to_row) end end return false end end
true
2be9357329ab2302988674e01079c38c288b40d6
Ruby
poolug/rubi-1
/escape.rb
UTF-8
84
2.734375
3
[]
no_license
g = ARGV[0].to_i r = ARGV[1].to_i velocidad = Math.sqrt(2*g*r) puts velocidad
true
bb3e1df26f12080f55d279e971fdccbe8a24af88
Ruby
jaym/braindump
/lib/braindump/status.rb
UTF-8
2,443
3.03125
3
[]
no_license
module Braindump module Status class Queued attr_reader :status_info def initialize(status_info) @status_info = status_info end def to_s 'queued' end end class Running attr_reader :status_info def initialize(status_info="") @status_info =...
true
51f93b5a1c16ca15e47811ec36c37b9baa9f007f
Ruby
yulu9206/ruby_fundamentals
/mammal.rb
UTF-8
144
3.28125
3
[]
no_license
class Mammal def initialize @health = 150 end def display_health puts @health end end # mammal1 = Mammal.new # mammal1.display_health
true
796a84e9caf586754636ca843be1bf66e52601e9
Ruby
rah00l/distance-calculator
/app/helpers/distances_helper.rb
UTF-8
292
2.515625
3
[]
no_license
module DistancesHelper def formatted_distance(dist) if dist['distance'].present? dist['distance'] elsif dist['error_code'].present? "You got error code of '#{dist['error_code']}' because of '#{dist['error_msg']}'" else "Somthing went wrong" end end end
true
51be0a1d871edde1f65bb2cf7d7ecc25973de084
Ruby
bashwork/project-euler
/029/029.rb
UTF-8
113
2.953125
3
[]
no_license
#!/usr/bin/env ruby require 'set' set = Set.new 2.upto(100) {|a| 2.upto(100) {|b| set.add(a**b) }} puts set.size
true
5ad5b8df1f2d1e32e8acab2ba39af25c0fa75afa
Ruby
mmarcolina/Ruby-Exercises
/Fundamentals/Hashes/bob.rb
UTF-8
377
4.3125
4
[]
no_license
# Given the following expression, how would you access the name of the person? person = {name: 'Bob', occupation: 'web developer', hobbies: 'painting'} p person.fetch(:name) # the fetch method returns a value for a specified key. In this case, the key we want to refer to is :name to obtain the value of Bob. # alter...
true
7a673818d523082180b295f2cbb0a7ffdbe45652
Ruby
JustinLove/gsl
/lib/gsl/historian.rb
UTF-8
822
2.875
3
[]
no_license
module GSL class Historian class Event def initialize(_historian, starting = {}) @historian = _historian @data = starting super() end def to_s "Event: " + @data.to_s end def record(what) case (what) when Resource; record_r...
true
78ec2525c60ee4ddbc7d019a07b326289ef1f354
Ruby
techno-tanoC/rubi_live
/lib/rubi_live/idol.rb
UTF-8
1,157
2.5625
3
[ "MIT" ]
permissive
module RubiLive class Idol < Hash include Hashie::Extensions::MethodAccess def ==(other) other.is_a?(self.class) && self.name == other.name end def birthday?(date = Date.today) month, day = birthday.split("/") birthday_date = Date.new(date.year, month.to_i, day.to_i) birthday...
true
b704ddc1fd4c0fcfa6de5327d3fd67883f3fbe23
Ruby
catman/ipreader
/test/test_database_utils2.rb
UTF-8
3,101
2.765625
3
[ "MIT" ]
permissive
require_relative "test_helper" require_relative "../ipreader/database_utils" require "sqlite3" class TestDatabaseUtils < Test::Unit::TestCase SMS_TABLE_CREATE = "CREATE TABLE message (rowid INTEGER, date TEXT, address TEXT, text TEXT, flags INTEGER)" class IpDbUtils include Ipreader::Database::Utils en...
true
f2f1cbf2dcfe7f506f8c5672cbbf775a97aadd84
Ruby
angelicawink/Rails-Practice-Code-Challenge-Travelatr-dc-web-082718
/app/models/blogger.rb
UTF-8
413
2.640625
3
[]
no_license
class Blogger < ApplicationRecord has_many :posts has_many :destinations, through: :posts validates :name, uniqueness: true validates :age, numericality: {greater_than: 0} validates :bio, length: {minimum: 30} def total_likes total = 0 self.posts.each do |post| total += post.likes end ...
true
77120548d202c709ff559daf480212374fee1fd3
Ruby
marcinbunsch/isaac
/test/test_commands.rb
UTF-8
1,824
2.5625
3
[ "MIT" ]
permissive
require 'helper' class TestCommands < Test::Unit::TestCase test "raw messages can be send" do bot = mock_bot {} bot_is_connected bot.raw "PRIVMSG foo :bar baz" assert_equal "PRIVMSG foo :bar baz\r\n", @server.gets end test "messages are sent to recipient" do bot = mock_bot {} bot_is_con...
true
5cbe9a19dcfc1a57e9abacd6fc6849ae74d130d7
Ruby
andrerferrer/tibia-travel-planner
/test_codes/graph.rb
UTF-8
635
3.359375
3
[]
no_license
# I took this solution from this tutorial # https://www.rubyguides.com/2017/05/graph-theory-in-ruby/ require 'rgl/adjacency' require 'rgl/dijkstra' graph = RGL::DirectedAdjacencyGraph.new graph.add_vertices "Los Angeles", "New York", "Chicago", "Houston", "Seattle" edge_weights = { ["New York", "Los A...
true
eebdecad116e1940157c1e518d2f3fd293bf45ae
Ruby
ahead123/ruby_Stuff
/join.rb
UTF-8
95
2.828125
3
[]
no_license
hip_hop = ["cool c", "cool b", "cool a", "cool j"] puts hip_hop puts puts hip_hop.join(', ')
true
6433b204fd521e97fe900e9d04d6a4b7e6c92342
Ruby
ess/absolution
/spec/absolution_spec.rb
UTF-8
2,281
2.890625
3
[ "MIT" ]
permissive
require 'spec_helper' require 'absolution' class Dummy include Absolution end describe Absolution do let(:klass) {Absolution} context 'when included' do let(:dummy) {Dummy.new} it 'knows about absolute URLs' do klass.instance_methods.each do |method| expect(dummy).to respond_to(method) ...
true
27745829351a248a613e767d46bcbadcb9197d13
Ruby
Haanyaj/music_in_the_way
/level5/main.rb
UTF-8
4,878
3.390625
3
[]
no_license
require 'json' require'date' class Rentals attr_accessor :id , :car_id, :start_date, :end_date, :distance def initialize(id, car_id, start_date, end_date, distance) @id = id @car_id = car_id @start_date = start_date @end_date = end_date @distance = distance end end...
true
d1d48992ee2892d33cdff066385d66a939ce1dea
Ruby
kmkr/moviemanage
/app/common/seconds_to_time_parser.rb
UTF-8
577
3.078125
3
[]
no_license
class SecondsToTimeParser def initialize(include_ms) @include_ms = include_ms end def parse (seconds) ss, ms = (1000*seconds).divmod(1000) mm, ss = ss.divmod(60) #=> [4515, 21] hh, mm = mm.divmod(60) #=> [75, 15] dd, hh = hh.divmod(24) #=> [3, 3] ms = ms.to_i hh = hh >...
true
0ba3e7733d1c9d1ba2fda6a7bc4220eb483e80f0
Ruby
beaucouplus/hospitalshifts
/level4/shift.rb
UTF-8
623
2.953125
3
[]
no_license
class Shift attr_reader :id, :planning_id, :worker_id attr_accessor :start_date def initialize(id,planning_id,worker_id,start_date) message = "Wrong type, parameter classes should be Int, Int, Int, Date" raise ArgumentError.new(message) unless id.is_a?(Integer) && planning_id.is_a?(Integer) && worker_id.i...
true
da072cca1d661b494a6820238e0773376e97fe8a
Ruby
leandro-ikehara/nivelamento-aluno
/exercicios/08-exercicio-parte1.rb
UTF-8
556
4.3125
4
[]
no_license
# EXERCICIO 08 - parte 1 =begin 1) Faça um programa para calcular a boa e velha tabuada. Pergunte ao usuário qual o número que ele quer o cálculo da taboada e imprima na tela os resultados. Por exemplo: Se o usuário digitar 7, deve imprimir dessa forma: 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 ... até 7 x 10 = 70 =end put...
true
eebba3d2fdd21b9ffa1b76d05445b02531391125
Ruby
noma4i/telegrammer
/lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_sticker.rb
UTF-8
992
2.578125
3
[ "MIT" ]
permissive
module Telegrammer module DataTypes # Telegram InlineQueryResultCachedSticker data type # # @attr [String] type Type of the result, must be sticker # @attr [String] id Unique identifier for this result, 1-64 Bytes # @attr [String] sticker_file_id A valid file identifier of the sticker # @attr ...
true
f6c4c1f866dadf9a80f9c32ff016daaf3a09f42a
Ruby
hoesler/link_dupes
/link_dupes
UTF-8
2,394
2.96875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'pathname' require 'tempfile' require 'optparse' require 'logger' module Logging def initialize(logging_level) @logger = Logger.new(STDOUT) @logger.level = logging_level end # This is the magical bit that gets mixed into your classes def logger @logger end end clas...
true
694e64d8da59a94a25695605ae1f522a821a9356
Ruby
bterkuile/couch_blog
/spec/support/end_with_matcher.rb
UTF-8
877
3.3125
3
[ "MIT" ]
permissive
module EndWithMatcher class EndWith def initialize(expected) @expected = expected end def matches?(target) @target = target @target =~ /#{@expected}$/ end def failure_message "expected <#{to_string(@target)}> to " + "end with <#{to_string(@expected)}>" end ...
true
1574976613070c8a5f7f991212f9b62d22ebd9c9
Ruby
etdev/algorithms
/0_code_wars/enumerable_magic_true_fo.rb
UTF-8
203
3.09375
3
[ "MIT" ]
permissive
# http://www.codewars.com/kata/54598e89cbae2ac001001135 # --- iteration 1 --- def any?(list, &block) list.any?(&block) end # --- iteration 2 --- def any?(list, &block) list.send(:any?, &block) end
true
a9b749af642def8eeaf75afd2d2731b9f13583fd
Ruby
TrevorSeitz/prime-ruby-v-000
/prime.rb
UTF-8
156
3.328125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime?(integer) return false if integer <= 1 for n in 2..(integer - 1) if (integer % n) == 0 return false end end return true end
true
123bc5a0af50abc1c4020e19de10f7721b663e6f
Ruby
guy-murphy/jAcumen
/Acumen.CMS2/vendor/plugins/acumen/lib/wiki_behaviour.rb
UTF-8
4,286
2.6875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby #-- # # Author: Guy J. Murphy # Date: 20/01/2010 # Version: 0.1 #++ # # = WikiBehaviour - A behaviour for resolving wiki text. # require 'naiad' import 'acumen.map.model.IOccurence' import 'acumen.resource.store.MySqlFileStore' import 'acumen.resource.model.ResourceException' import 'acumen...
true
27de2fac364547c6747d1fdf25456fbb3dac21c9
Ruby
Rexman17/OO-FlatironMifflin-nyc-web-071519
/lib/Employee_Manager.rb
UTF-8
234
2.671875
3
[]
no_license
# JOIN TABLE class Employee_Manager attr_accessor :employee, :manager @@all = [] def initialize(employee, manager) @employee = employee @manager = manager @@all << self end def self.all @@all end end
true
0a1ecbb84718016517ff20d69e1ad68f495ded76
Ruby
neomort/lunch_lady
/menu.rb
UTF-8
2,006
3.890625
4
[]
no_license
#{name: 'string' price:float, ingredients:['rice', 'beans']} #dish would be an instance of class # Dish - handles both main and side dishes #sideDish class and mainDish class #app.rb to hanfle logic #resturaunt class? # peudo code: class Dish attr_accessor :food, :price #type = main/side #food = type of food...
true
8d46af4d15ccc0a1cfcb68dd945c0393e57b03a2
Ruby
NicoRB28/Ruby
/interpolation.rb
UTF-8
326
3.453125
3
[]
no_license
def interpolation(string) #esto se puede hacer si la frase esta entre "" "hola #{string}" #el valor retornado por un metodo en ruby es el valor de la última expresion, por eso #no es necesario el return (aunque puede ir) end puts interpolation "nico" puts 'hola #{si esta entre single cuotes no interpo...
true
42a66931e315947789ce271c3c65c99f5aa6fbfb
Ruby
ardelapaz/algorithms
/introduction/fibonacci_iterative.rb
UTF-8
420
4.25
4
[]
no_license
def fib(n) puts "this is input: #{n}" return 0 if n == 0 return 1 if n == 1 fib_0 = 0 fib_1 = 1 for i in 2..n temp = fib_0 fib_0 = fib_1 fib_1 = temp + fib_1 end return fib_1 end puts fib(0) puts fib(1) put...
true
eb8b166223a3e46e4607abaf987062ff16f1ba05
Ruby
korney4eg/flats-crawler
/lib/flat-crawlers/tvoya-stolica.rb
UTF-8
1,866
2.828125
3
[]
no_license
require './lib/flat-crawlers/base.rb' # tvoya stalica crawler class TSCrawler < FlatCrawler def generate_urls(areas, price, step) page_urls = [] areas.each do |area| (price[0]..price[0]).step(step) do |pr| page_url = 'https://www.t-s.by/buy/flats/filter/' page_url += "district-is-#{are...
true
11129a40f9e6914a770044f14d6e98df2ca7a3f5
Ruby
kilimchoi/teamleada.com
/db/seeds/projects/018_sql_finance.rb
UTF-8
8,777
3
3
[]
no_license
main_page_content = [ ['text', "In this challenge you are tasked with quickly scraping a set of Yahoo data, and then storing the scraped data into a SQL database."], ['text', "The following are the steps you'll take to accomplish the task."], ['text', "1. Scrape Yahoo Finance data."], ['text', "2. Store the scr...
true
a4628681f79a6234c07f65c4c69471f42a521169
Ruby
paploo/sliderule_tester
/lib/generator/trig/polar.rb
UTF-8
1,480
3.328125
3
[ "BSD-3-Clause" ]
permissive
module Generator module Trig class Polar < Base def self.title return "Polar Coordinate Conversions" end def self.description return "Conversion to/from polar coordinates." end def self.instructions return <<-INST A. Convert into rectangul...
true
769cca1bb306a41f19c811136e41271d250711ea
Ruby
Coderdotnew/intro_web_apps_bs
/05_class/01_intro_to_arrays/code/01_array_methods/spec/array_methods_spec.rb
UTF-8
2,274
3.984375
4
[]
no_license
require_relative './spec_helper' require_relative '../array_methods.rb' describe "#sort_words" do it "sorts an array of words alphabetically and returns the sorted array" do words = ["watermelon", "strawberry", "apple", "banana", "peach"] expect(sort_words(words).first).to eq("apple") expect(sort_words(...
true
b3427d5abcc1dffded0fe8276f3652edf820abb3
Ruby
bmoises/saynews
/lib/downloader.rb
UTF-8
1,638
2.921875
3
[]
no_license
class Downloader attr_accessor :mech, :opts, :uri, :cached_file, :resume WORD_WRAP = 60 def initialize(opts = {}) @uri = opts[:uri] @mech = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } end def download if !file_exists? puts "File does not exist: #{cache...
true
d34ce1ee528bb008ff7c7c8bc196ee975ff7f343
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/cs169/combine_anagrams_latest/12110.rb
UTF-8
222
3.421875
3
[]
no_license
def combine_anagrams(words) anagrams = {} words.each do |w| s = w.downcase.chars.sort.join if (anagrams[s]) anagrams[s] = (anagrams[s] << w) else anagrams[s] = [w] end end anagrams.values end
true
59e903738f13806a763d51d6691cce61cc6d0123
Ruby
Jeff-Adler/key-for-min-value-nyc01-seng-ft-071320
/key_for_min.rb
UTF-8
384
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# prereqs: iterators, hashes, conditional logic # Given a hash with numeric values, return the key for the smallest value def key_for_min_value(name_hash) temp_min_price = nil temp_min_key = nil name_hash.each do |item,price| if temp_min_price == nil || price < temp_min_price temp_min_price = price...
true
cbc9ed11ba3aa65fbf611b0c464139c52de656da
Ruby
kennychong89/launch_school
/back_end/weekly_challenges/oop/medium_one/poker_incomplete.rb
UTF-8
3,859
3.953125
4
[]
no_license
=begin OO Exercises Launch School Kenny Chong 10/12/2016 12:34 pm https://launchschool.com/exercises/a1938086 =end class Card include Comparable attr_reader :rank, :suit def initialize(rank, suit) @rank = rank @suit = suit end def to_s "#{@rank} of #{@suit}" end def <=>(other_car...
true
9b0eb511e15bb9d95ed208e9977866f93c5f0a13
Ruby
Tcom242242/t_learn
/examples/k_means.rb
UTF-8
282
2.5625
3
[ "MIT" ]
permissive
require "t_learn" k_means = TLearn::K_Means.new() data_list = JSON.load(open("./sample_1dim.json")) history = k_means.fit(data_list, c=3) # => {result:=> Array, history => Array} # history[:result][0] => {id=>cluster's number, :vec=>cluster's point, :v_list=> clustered data list}
true
d32afd2b0fc7de2debafdff244e9885a781480a8
Ruby
mindaslab/ilrx
/class_eval.rb
UTF-8
165
3.65625
4
[]
no_license
# class_eval.rb class Animal end dog = Animal.new dog.class.class_eval do def say_something "I am a dog" end end pig = Animal.new puts pig.say_something
true
8da297b09996149d56d84d711fe6796770ddc076
Ruby
abdibogor/Ruby
/1.Jake Day Williams/Ruby/11.1.counter index each do.rb
UTF-8
196
2.6875
3
[]
no_license
array_test = ["first_line", " second line", " third line"] for object in array_test print " Item one #{object}" end puts for surf in array_test.reverse print "#{surf} " end $end
true
f3feadf9359b9361f6435ef3f4045b72c73f21dd
Ruby
mliew21396/Project-Euler
/2_even_fibonacci_numbers.rb
UTF-8
822
4.5
4
[ "MIT" ]
permissive
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ...
true
1f63227e382951bff7aa378a75fc11d7896925cb
Ruby
relevance/Facebook-Registration
/lib/rails/signed_request.rb
UTF-8
1,184
2.6875
3
[ "MIT" ]
permissive
require 'rubygems' require 'openssl' require 'base64' module FacebookRegistration class SignedRequest def self.parse(params) if params.is_a?(Hash) signed_request = params.delete('signed_request') else signed_request = params end unless signed_request rais...
true
dc2f954e02401cc74aac3bbe694bde1bc821ed82
Ruby
camsys/transam_core
/app/models/equipment.rb
UTF-8
2,968
2.609375
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
class Equipment < Asset # Callbacks after_initialize :set_defaults #------------------------------------------------------------------------------ # Associations common to all equipment assets #------------------------------------------------------------------------------ validates :quantity, :pre...
true
1fe1600b8d6b46ab7da54590a4577eac9878cc6b
Ruby
sharkham/oo-tic-tac-toe-online-web-pt-061019
/lib/tic_tac_toe.rb
UTF-8
2,718
4.375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class TicTacToe WIN_COMBINATIONS = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [2, 4, 6] ] def initialize @board = Array.new(9, " ") end def display_board puts " #{@board[0]} | #{@board[1]} | #{@board[2]} " puts "--...
true
c8743880ccd51ac4fb495a7cd16af960efc8b4f6
Ruby
krpiatkowski/tidsreg-miner
/run.rb
UTF-8
1,935
2.703125
3
[]
no_license
require 'rubygems' require 'bundler/setup' require 'dotenv' require './tidsreg_service.rb' Dotenv.load service = TidsregService.new(ENV['TIDSREG_USERNAME'], ENV['TIDSREG_PASSWORD']) # d = Date.today - (ENV['TIDSREG_WEEKS'].to_i * 7) # now = Date.today d = Date.strptime('01-05-2015', '%d-%m-%Y') now = Date.strptime...
true
529eaff4f2d35eacd7e3089f4b8805671396fd6a
Ruby
njbbaer/exercism
/ruby/sieve/sieve.rb
UTF-8
253
2.8125
3
[]
no_license
class Sieve def initialize(max) @max = max end def primes primes = [] (2..@max).each do |i| primes.push i if primes.none? do |p| (i % p).zero? end end primes end end module BookKeeping VERSION = 1 end
true
cb19b0d0c94979eb5f3d86c89aa593ea44b64e66
Ruby
Coderman112/game-app
/lib/game.rb
UTF-8
474
3.328125
3
[]
no_license
require 'pry' class Game @@all = [] def initialize(hash) hash.each do |key, value| self.class.attr_accessor(key) self.send("#{key}=", value) if self.respond_to?("#{key}=") end @@all << self end def self.all @@all end def se...
true
ef5117521eafbc6be12b09ad88fdaa3554e0a56b
Ruby
RitamDey/Algorithms-and-Data-Structres
/Ruby/Bubble_Sort_Recursive.rb
UTF-8
642
3.84375
4
[ "MIT" ]
permissive
def is_sorted?(arr) len = arr.length 0.upto(len-2) do |x| if arr[x] > arr[x+1] return false end end return true end def bubble_sort(arr, len) if len <= 1 return arr end 0.upto(len -2 ) do |x| if arr[x] > arr[x+1] arr[x], arr[x+1] =...
true
a74f22fc222bfff5fe6201957686f7d865b8c6fa
Ruby
dalssoft/rsearch
/document.rb
UTF-8
1,973
3.265625
3
[]
no_license
#encoding: UTF-8 # rsearch: a vector model information retrieval implemented in Ruby # Author: David Lojudice Sobrinho # 22/11/2008 # <dalssoft@gmail.com>. # # info: # http://www.ruby-doc.org/docs/ProgrammingRuby/ # http://en.wikipedia.org/wiki/Vector_space_model # http://www.hray.com/5264/math.htm class D...
true
9ba4425468815c5f2fccf3447a7b39b3f0274301
Ruby
apunko/TasksBoard
/app/models/draw_icon_module.rb
UTF-8
1,974
2.78125
3
[]
no_license
module DrawIconModule def draw_stat(image, user) image.combine_options do |c| c.pointsize '18' c.draw "text 20,20 TasksBoard#"+"#{user.name}" c.fill 'white' end image end def draw_achievement(background, achievement, user_id, x, y) image = Achievement.make_image(achievement, us...
true
721cac2de0617209f1ad07c3ce4d819d796ebfab
Ruby
github-luciano/tic_tac_toe
/tic_tac_toe.rb
UTF-8
3,007
3.28125
3
[]
no_license
$var1 = ' ' $var2 = ' ' $var3 = ' ' $var4 = ' ' $var5 = ' ' $var6 = ' ' $var7 = ' ' $var8 = ' ' $var9 = ' ' class X include Check @@class_name = 'X' def self.top_left $var1 = @@class_name puts X.new.check_table end def self.top $var2 = @@class_name puts X.new.check_table end def self.top_...
true
3f8af28781628828ead86389cadb51a7e1d321b9
Ruby
calvinsettachatgul/freecodecamp
/basic_algorithm_scripting/largest_numbers_in_array.rb
UTF-8
1,304
4.3125
4
[]
no_license
# https://www.freecodecamp.org/challenges/return-largest-numbers-in-arrays # # Return Largest Numbers in Arrays # Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays. # # Remember, you can iterate through an array with a s...
true
858071a79a5c960c276486224c7c809146d4deda
Ruby
DStorck/get-out
/lib/eventful_api_wrapper.rb
UTF-8
774
2.75
3
[]
no_license
require "httparty" module EventfulAPIWrapper BASE_URL = "http://api.eventful.com/json/events/search?&app_key=PNh8dcmkrJKGX8tx&keywords=" def self.search(term, current_user) city = current_user ? current_user.city : "seattle" initial_response = HTTParty.get(BASE_URL + term + "&location=#{city}", format: :json...
true
6dc23cfda29fbf5c6169af1c5801f89668cebcbd
Ruby
kdors007/gitprobz
/my_methods.rb
UTF-8
226
3.09375
3
[]
no_license
def add_nums(a, b) = return a + b end def fizzbuzz(num) if num % 3 == 0 && num % 5 == 0 "fizzbuzz" elsif num % 3 == 0 "fizz" elsif num % 5 == 0 "buzz" else num end end def suctract(b,a) a-b end
true
53849d5fa6ff9f5819ab044b33180963a278f9e5
Ruby
elikantor/sinatra-nested-forms-lab-superheros-nyc-clarke-web-100719
/app/controllers/application_controller.rb
UTF-8
1,209
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'sinatra/base' class App < Sinatra::Base set :views, Proc.new { File.join(root, "../views/") } get '/' do erb :new_team end # eate a Team and Heroes! </title> # <form method="POST" action="/team"> # <p>Team Name: <input type="text" name="name"></p> # <p>Motto: <input type="text...
true
61a79448eb08d9f744bfb1913330afa0cfbaea2c
Ruby
radkin/findme_demo
/lib/parse/startpage.rb
UTF-8
838
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative '../parser' # startpage specific search engine parsing attributes and methods class Startpage def initialize(query_result) @parser = Parser.new(query_result) @query_result = query_result end def gather_all_links @links = @parser.ga...
true
46d622b8ec14dd7f7111817bbcf6e583f3c5c2d4
Ruby
CodingMBA/lesson_5
/pp5.rb
UTF-8
572
3.5625
4
[]
no_license
munsters = { "Herman" => { "age" => 32, "gender" => "male" }, "Lily" => { "age" => 30, "gender" => "female" }, "Grandpa" => { "age" => 402, "gender" => "male" }, "Eddie" => { "age" => 10, "gender" => "male" }, "Marilyn" => { "age" => 23, "gender" => "female"} } male_hash = munsters.select { |_, v| v["gender"...
true
260b39089242fa8e5222f79dd432113dd46f1d0c
Ruby
codehabit/stat_patient
/lib/live_state.rb
UTF-8
768
2.609375
3
[]
no_license
class LiveState class << self @@state = {} def latest(practitioner_id) @@state[practitioner_id] end def register_latest(practitioner_id, cases) @@state[practitioner_id] = cases end def diff(practitioner_id, cases) current = @@state[practitioner_id] current_hash = {}.t...
true
d038f9085c12fcdc4c7d352839de7802d482338a
Ruby
src256/imagetools
/lib/imagetools/imageblog.rb
UTF-8
4,813
2.84375
3
[ "MIT" ]
permissive
# coding: utf-8 # imagehugo: hugo用の画像処理。リネームとサムネイル&アイキャッチ画像の生成。 require 'imagetools/version' require 'imagetools/imagefilter' require 'rmagick' require 'optparse' require 'fileutils' module Imagetools class ImageItem attr_accessor :srcfile, :dstfile, :outfile def to_s "#{srcfile}=>#{dstfile}=>#{outfil...
true
91a0ecc2549c4cae8d4b0153210ab19b7cfd9cbe
Ruby
gibbarko/Intro_to_ruby
/methods/method_chain.rb
UTF-8
408
3.9375
4
[]
no_license
=begin - this is method chaining def add_three(n) new_value = n + 3 puts new_value new_value end add_three(5).times { puts "this should print 8 times"} =end #Method calls as arguments def add(a, b) a + b end def subtract(a, b) a - b end def multiply(num1, num2) num1 * num2 end puts multiply(add(20, 45...
true
d5bff7b1d608f192be80505e2bcfdd7d13f05284
Ruby
chad-tung/week2_day3_snakes_ladders
/game.rb
UTF-8
1,435
3.78125
4
[]
no_license
class Game def initialize(name, players, board, dice) @name = name @players = players @board = board @dice = dice end def check_ladder(player) for number in @board.get_ladder_hash() if player.get_position == number[:start_point] player.set...
true
f545f65d5fdf3239387ee275919648a381ee4b41
Ruby
paul-christmann/project-euler
/ruby/spec/unit/util/fibonacci_spec.rb
UTF-8
2,089
3.234375
3
[]
no_license
require 'project_euler/util/fibonacci' include ProjectEuler::Util describe Fibonacci do describe 'calculate fibonacci recursive' do it 'should calculate last' do f = Fibonacci.new(:count => 7) f.fibonacci.should == 13 end it 'should calculate last' do f = Fibonacci.new(:count => 7, ...
true
c1c21a58f3e2ffee5bb587c1d45ffef631c8af42
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/hamming/88f94ccd33d44844af0a5a4f7837c459.rb
UTF-8
272
3.171875
3
[]
no_license
class Hamming def self.compute(seg1, seg2) return 0 unless seg1.length == seg2.length seg1_array = seg1.split('') seg2_array = seg2.split('') strands = seg1_array.zip(seg2_array) strands.collect{ |e,f| 1 if e != f }.compact.inject(:+) || 0 end end
true
4a8b5c21bf845c79db15675267434b002afa5666
Ruby
fiddler-crabs-2014/ESA
/view.rb
UTF-8
3,266
3.453125
3
[]
no_license
#require_relative 'controller.rb' class Interface ###Display attr_reader :username, :password def initialize end def self.who_are_you#(name) puts "Welcome to NYCSuggester!" puts "Create a new user with: new" #<username>" puts "Log in as a user with: login" # <username>" sign_...
true
8bf6a9de1b4d525bdb1758b0e63b612952d38faa
Ruby
zacharytwhite/project-euler-solutions
/project_euler_rb/problem_033.rb
UTF-8
559
3.5
4
[]
no_license
# The fraction 49/98 is a curious fraction, as an inexperienced mathematician, in attempting to # simplify it, may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. # We shall consider fractions like, 30/50 = 3/5, to be trivial examples. # There are exactly four non-trivial ex...
true
10bc81c8b6d0cd48ce0a18f142bfd1a20f3f9e9f
Ruby
miroosama/ruby-collaborating-objects-lab-web-010818
/lib/mp3_importer.rb
UTF-8
265
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class MP3Importer attr_accessor :path def initialize(path) @path = path end def files @files = Dir["#{path}/*.mp3"] @files.map{|file| file.split("/mp3s/")[1]} end def import files.each{|file| Song.new_by_filename(file)} end end
true
a0be27a5eeadf84d7b21eef48ac1426362c43c9a
Ruby
kamilsdz/radio
/api/server.rb
UTF-8
1,180
2.8125
3
[]
no_license
require "socket" require_relative "request" module Api class Server def initialize(port:, routing:) @port = port @routing = routing end def run server = TCPServer.new(port) while session = server.accept begin if process_request(session.recv(5000)) r...
true
d6a060f4cbc0752178e879adeb6d57efb5aea0b2
Ruby
laurentqro/command_line_games_inc
/lib/tic_tac_toe/computer.rb
UTF-8
1,285
3.3125
3
[]
no_license
require 'tic_tac_toe/game_state' class Computer attr_reader :mark def initialize(mark: nil) @mark = mark end def pick_move(board) minimax(game_state: GameState.new(board: board, current_player_mark: mark, max_player_mark: mark)) end private def minimax(game_state:, depth: 0, spot_scores: {}) ...
true
a79e7356b34952c7fafa77ca6be332a666d25825
Ruby
sandagolcea/Ruby
/katas/anagrams.rb
UTF-8
687
3.90625
4
[]
no_license
def anagram(string1, string2) return false if string1.size != string2.size hash = {} string1.split(//).each do |letter| if !hash[letter] hash[letter] = 1 else hash[letter] += 1 end end string2.split(//).each do |letter| if !hash[letter] # not anagram puts('not an anagr...
true
6e9ae4c1159fecc6c825e70e810c19e033d173f2
Ruby
mkrisher/katas
/ruby/balancer/1/balancer_spec.rb
UTF-8
1,188
3.234375
3
[]
no_license
require 'rspec' require 'pry' require_relative 'balancer' describe Balancer do let(:word) { "stead" } subject { Balancer.new(word) } describe "#run" do it "returns the word with the balance point delimited by spaces" do expect(subject.run).to eq("s t ead") end end context "private api" ...
true
d8de606abba35e4e014bd77de769fcd81791e493
Ruby
anthonyb/scramble
/scramble_pair.rb
UTF-8
3,565
3.765625
4
[]
no_license
class ScramblePair EXCEPTIONS = [ "AI","AY","EA","EE","EO","IO","OA","OO","OY","YA", "YO","YU","BL","BR","CH","CK","CL","CR","DR","FL", "FR","GH","GL","GR","KL","KR","KW","PF","PL","PR", "SC","SCH","SCR","SH","SHR","SK","SL","SM","SN","SP", "SQ","ST","SW","TH","THR","TR","TW","WH","WR" ] #--...
true
ed56f2ce2f35a1f655ec906b00dc9c2f31dfaef3
Ruby
IIIIIIIIll/RubyQuizess
/Quiz4/question20.rb
UTF-8
152
2.53125
3
[]
no_license
snowy_owl={ 'type'=>'bird', 'diet'=>'Carnivore', 'life_span'=>'10 years' } snowy_owl.select do |key,value| p value if key=='type' end
true
cf934e890c01b24550fd75dad3d9cc34cfca5129
Ruby
takagotch/o2
/thread/thread_safe.rb
UTF-8
2,467
2.921875
3
[]
no_license
class MyCommandHandler def initialize make_threadsafe_by_stateless end def call(cmd) local_var = cmd.something output(local_var) end private def make_threadsafe_by_stateless freeze end def output(local_var) puts(local_var) end end CMD_HANDLER = MyCommandHandler.new class My...
true
beb7131b84b698107e4ab636b07ab570d55cb21a
Ruby
johnjvaughn/ls_ruby_intro
/exercises/ex04.rb
UTF-8
97
3.09375
3
[]
no_license
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] puts arr.inspect arr << 11 arr.unshift(0) puts arr.inspect
true
ee2c5bd631c606455f499d171508293e08e2da36
Ruby
prrn-pg/Shojin
/Practice/AOJ/ALDS1/ALDS1_03/ALDS1_03B/alds1_03b.rb
UTF-8
636
3.375
3
[]
no_license
# 余った分は考えないらしい n, q = gets.chomp.split.map(&:to_i) queue = [] n.times do queue.push(gets.chomp.split.map{|x| x.match?(/^\d+$/) ? x.to_i : x}) end # 入力された順に処理する # FIFOは頭からいれてケツから出すという意識があるので queue.reverse! count = 0 # 経過時間 loop do break if queue.size.zero? # rubyではケツから取り出すのはpop t = queue.pop ...
true
d75aa54761338920fe99eeab11db77d7a7f5cf88
Ruby
novakun/CFstuff
/Ruby/program.rb
UTF-8
104
3.765625
4
[]
no_license
def greeting puts "Hey, man, what's your name?" name = gets.chomp puts "Hey " + name end greeting
true
cf0ff82fa63c019c307a9f9446a4f79c5903207c
Ruby
atownley/tecode-ruby
/lib/tecode/time.rb
UTF-8
4,702
3.15625
3
[]
no_license
#-- ###################################################################### # # Copyright (c) 2005-2016, Andrew S. Townley # All rights reserved. # # Permission to use, copy, modify, and disribute this software for # any purpose with or without fee is hereby granted, provided that # the above copyright notices and this...
true
0693bfd43c5de9a934682fe8550f1a6b8aa87e21
Ruby
pomidorus/bazis
/app/models/vipiska_file.rb
UTF-8
1,686
2.59375
3
[]
no_license
# encoding: utf-8 class VipiskaFile < ActiveRecord::Base attr_accessible :download_count, :file_name, :upload_at, :file_size, :file_for_data, :files_count_in M_RUS_SHORT = ['','янв','фев','мар','апр','май','июн','июл','авг','сен','окт','ноя','дек'] def month_short M_RUS_SHORT[file_for_data.month] end ...
true
9c4beaf7e24e9775ed5aded01c49e04e2b0128ef
Ruby
comsi02/json-rpc-1-1
/lib/json_rpc_client.rb
UTF-8
8,147
2.78125
3
[]
no_license
# # This is the JSON-RPC Client, the handler for the client side of a JSON-RPC # connection. # class JsonRpcClient require 'json' require 'net/http' require 'uri' # # Our runtime error class. # class Error < RuntimeError; end class ServiceError < Error; end class ServiceDown < Error; end ...
true
467d7e74b85e3744dd2ca724aa23ffafaf1f4c4d
Ruby
IanVaughan/twitter-scratch
/friends.rb
UTF-8
2,184
3.09375
3
[]
no_license
require 'rubygems' require 'twitter' require 'pp' def followers_of name print "Getting the followers..." r = Twitter::follower_ids(name) puts "...Done" r end def friends_of name print "Getting your friends..." r = Twitter::friend_ids(name) puts "...Done" r end def twitter copy_to httpauth = Twitter...
true
3de3700d27c6b28e52f2fc50c397fa4eda950908
Ruby
sds/scss-lint
/lib/scss_lint/linter/space_between_parens.rb
UTF-8
3,846
2.859375
3
[ "MIT" ]
permissive
module SCSSLint # Checks for the presence of spaces between parentheses. class Linter::SpaceBetweenParens < Linter include LinterRegistry def check_node(node) check(node, source_from_range(node.source_range)) yield end alias visit_atroot check_node alias visit_cssimport check_node ...
true
ed5e23b3ccf74f84056599f12b6d3a2f60e0d9e6
Ruby
Bonemind/Queryfy
/lib/queryfy/filter_lexer/formatter.rb
UTF-8
1,312
2.796875
3
[ "MIT" ]
permissive
require 'queryfy/queryfy_errors' module FilterLexer class Filter # Converts a FilterLexer::Filter to an arel node def to_arel(arel_table) # Get the elements we want to operate on field = elements[0].text_value operator_method = elements[1].to_arel val = elements[2].text_value field = Queryfy.get_ar...
true
b68f4833f3a8ef082c630100a0cbdc9523ee9df0
Ruby
sagarrat7/Scribe
/html/project/emigrant/bot-example.rb
UTF-8
4,126
2.9375
3
[ "MIT" ]
permissive
require 'open-uri' require 'json' require 'cgi' # Useful extension to Hash to create query strings: class Hash def to_params params = '' stack = [] each do |k, v| if v.is_a?(Hash) stack << [k,v] elsif v.is_a?(Array) stack << [k,Hash.from_array(v)] else params <...
true
97f1b2ecf9807007de8254ca4f338dfce6e8b84f
Ruby
gweng1t/exo_ruby
/exo_07.rb
UTF-8
413
3.46875
3
[]
no_license
user_name = gets.chomp puts user_name # gets demande à l'utilisateur d'entrer quelque chose #chomp retire le \n #Le premier programme demande d'entrer son nom puis affiche ce qu'a rentrer l'utilisateur #le 2eme programme demande d'entrer son nom puis affiche un > pour que l'utilisateur voit où il va ecrire #le 3eme n'...
true
8192c0f16f16087a9631a411efdc9fb4fc0da122
Ruby
OpenGotham/tickler
/lib/groper.rb
UTF-8
824
2.625
3
[]
no_license
require 'nokogiri' class Groper attr_reader :urls def initialize @urls = ["Estimizer_Daily_A.xml","Estimizer_Intraday_A.xml"] end def perform # file 1 filename = File.expand_path(File.join('..','..','tmp',Time.now.strftime("%Y%d%m%H%M%L.xml")), __FILE__) `wget -O #{filename} #{self.urls[0]}` ...
true
0ff61b6156bb431962cddf2f53eaccb298b132ab
Ruby
randyjap/project-euler
/09.rb
UTF-8
469
3.28125
3
[]
no_license
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. # Answer: 31875000 (1..1000).each do |a| (a..1000).each do |b| c = (1000...
true
e7b8189784dc457e7eb48fe57dcd0c71f6a96b50
Ruby
suturner/ruby-challenges
/test_example.rb
UTF-8
171
3.171875
3
[]
no_license
my_name = 'skillcrush' if my_name == 'skillcrush' puts "helloooooo, skillcrush!" else puts "Ooops, I thought your name was Skillcrush. Sorry about that, #{my_name}!" end
true
29a55baf0b80e9d83addbb7d2b8e39060be47b8f
Ruby
0xack13/panoptimon
/spec/util_spec.rb
UTF-8
1,033
2.546875
3
[ "BSD-3-Clause" ]
permissive
#!/usr/bin/env ruby require 'panoptimon/util' require 'ostruct' describe('os lookup string') { before(:each) { Panoptimon::Util.stub(:_os) { :plan9 } } it('returns correct string') { Panoptimon::Util.os.should == :plan9 } it('returns correct hash value') { Panoptimon::Util.os(plan9: 10, default:...
true
d8f8761bf63dd84ea8cfe44f7204b1e5444abc9a
Ruby
ninjudd/priority_queue
/test/priority_queue_test.rb
UTF-8
1,319
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require File.dirname(__FILE__) + '/test_helper' class PriorityQueueTest < Test::Unit::TestCase should "shift values in priority order" do pq = PriorityQueue.new pq[1] << :important_foo pq[1] << :important_bar pq[0] << :very_important_foo pq[4] << :foo pq[4] << :bar assert_equal :ver...
true
3245a7394c73625446617b2688ab882a6b74a657
Ruby
IanPFoertsch/Proposition
/lib/proposition/sentence/binary/and.rb
UTF-8
1,588
2.8125
3
[]
no_license
module Proposition class And < BinarySentence def self.compliment Or end def operator_symbol "AND" end def contains_and? true end def to_conjunction_of_disjunctions @left.to_conjunction_of_disjunctions.conjoin(@right.to_conjunction_of_disjunctions) end #...
true