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
bc88914ca4acb2c2ddedeb32040b12759eb8de16
Ruby
Anuradha-yadav169/ruby-programs
/personclass.rb
UTF-8
293
3.296875
3
[]
no_license
# class program class Peron attr_reader :first_name, :last_name def initialize(first_name, last_name) @first_name = first_name @last_name = last_name end def full_name "#{first_name} #{last_name}" end end anu = Peron.new('anu', 'yadav') anu.full_name puts anu.inspect
true
b6e5d6be69f45bbb502369a56339bb9191c605b0
Ruby
drewswinburne/landlord
/db/seeds.rb
UTF-8
1,197
2.6875
3
[]
no_license
require_relative 'connection' require_relative '../models/apartment' require_relative '../models/tenant' Tenant.destroy_all Apartment.destroy_all this = Apartment.create(:address =>"1234 this lane", :monthly_rent => 700, :sqft => 1400, :num_beds => 2, :num_baths => 1) that = Apartment.create(:address =>"5678 that lan...
true
c886e2a5b565aba8ff95c0b88d1168227c8d924a
Ruby
mohammadaliawan/code-academy-practice
/collect.rb
UTF-8
304
3.5
4
[]
no_license
my_array = [2,3,4] # my_2_array= [] # my_array.each{|x| # my_2_array.push(x**2) # } # puts my_2_array # my_array.collect{|num| # num**2 # } # puts my_array # my_array.collect!{ |num| # num**2 # } # puts my_array my_2_array = my_array.collect{|num| num**2 } puts my_2_array print my_2_array
true
8f59bb3d16653da9201c80d73150935af4009eb9
Ruby
treble37/rebuilding_rails
/best_quotes/config.ru
UTF-8
477
2.78125
3
[]
no_license
# best_quotes/config.ru require './config/application' class BenchMarker def initialize(app, runs = 100) @app, @runs = app, runs end def call(env) t = Time.now result = nil @runs.times { result = @app.call(env) } t2 = Time.now - t STDERR.puts <<OUTPUT Benchmark: #{@runs} runs ...
true
0ea361aeffc0375dd29a98a6e172a751a044a789
Ruby
pauldix/code-katas
/kata_4/part_two.rb
UTF-8
626
3.40625
3
[]
no_license
class PartTwo class << self def calculate(file_name) team, spread = nil, 500 File.readlines("#{File.dirname(__FILE__)}/#{file_name}").each do |line| if line_has_score?(line) new_team, new_spread = team_and_spread(line) team, spread = new_team, new_spread if new_spread < spr...
true
a594838a718d223cb8564212b16f34fc6c9b0579
Ruby
kopo4eweb/ruby_beginer
/lesson_3/railway_station_management/station.rb
UTF-8
1,793
3.609375
4
[]
no_license
=begin Класс Station (Станция): + Имеет название, которое указывается при ее создании + Может принимать поезда (по одному за раз) + Может возвращать список всех поездов на станции, находящиеся в текущий момент + Может возвращать список поездов на станции по типу (см. ниже): кол-во грузовых, пассажирских + Может отпр...
true
b1d33fddc3c650d228bf1256a523f7210dae2929
Ruby
dmaster18/my-collect-online-web-sp-000
/lib/my_collect.rb
UTF-8
249
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_collect(array) i = 0 collection = [] while i < array.length collection << yield(array[i]) i+=1 end collection end array = ["Bob Jones", "Joe Jackson", "John Williams", "Homer Simpson"] my_collect(array) do |name| name.split(" ").first end
true
7a2d0ba44e2c007895184edbfb2c969d2c59c1bf
Ruby
kohski/perfect_ruby
/11/5_set/11_5_1_set.rb
UTF-8
1,105
3.84375
4
[]
no_license
require 'set' (1..5).to_set # => #<Set: {1, 2, 3, 4, 5}> Set.new(%w(tim timtim yoko)) # => #<Set: {"tim", "timtim", "yoko"}> sets = Set.new(%w(tim timtim yoko)){|name| name.upcase } sets # => #<Set: {"TIM", "TIMTIM", "YOKO"}> Set[1,2,3,4] # => #<Set: {1, 2, 3, 4}> sets = Set.new(1..5) # => #<Set: {1, 2, 3, 4, 5...
true
c772c7911b5d6ab34c9db4c2345e1ce2ed870c14
Ruby
nteixeira336/collections_practice-onl01-seng-pt-032320
/collections_practice.rb
UTF-8
733
3.875
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 |left,right| right <=> left end end def sort_array_char_count(array) array.sort do |left,right| left.length <=> right.length end end def swap_elements(array) array[1],array[2] = array[2],array[1] array en...
true
fa3a761dbb876fe9726d259e9b724521bbd68830
Ruby
nlicalzi/ruby_exercises
/advanced_topics/easy_2/sequence_generator.rb
UTF-8
278
3.5625
4
[]
no_license
# Source: https://launchschool.com/exercises/ec8dd514 def step(first, last, step_val) arr = (first..last).to_a counter = 0 while counter < arr.size yield(arr[counter]) counter += step_val end nil end puts step(1, 10, 3) { |value| puts "value = #{value}" }
true
22bc6c1c53676e8a92f607dfd5f3053f2df94b92
Ruby
AmritSidhu/learnRubyTheHardWay
/lrthw/ex15.rb
UTF-8
289
3.25
3
[]
no_license
filename = ARGV.first txt = open(filename) #Calls ex15.sample.txt (requires script) puts "Here's your file #{filename}:" print txt.read #Command that reads the script print "Type the filename again: " file_again = $stdin.gets.chomp txt_again = open(file_again) print txt_again.read
true
2c1a9a12cc0bbcd5314b5af2f97e545c46e26024
Ruby
dwoznicki/phase-0
/week-6/credit-card/my_solution.rb
UTF-8
3,427
4.3125
4
[ "MIT" ]
permissive
# Class Warfare, Validate a Credit Card Number # I worked on this challenge [with: Rebecca Nelson ]. # I spent [1] hours on this challenge. # Pseudocode # Input: A 16-digit integer # Output: a boolean, true or false # Steps: # UNLESS number is 16-digit integer # Argument error # Split the integer into an array ...
true
1d5f9c95dbc72aae5e95f0055c4d301c871f6b3b
Ruby
jeffchiucp/Ruby-and-Rail-Projects
/w2/w2d2-w2d3/chess/pieces/chess_pieces.rb
UTF-8
1,266
3.515625
4
[]
no_license
# encoding: UTF-8 require "./exceptions.rb" class Piece attr_accessor :color, :pos DIAGONALS = [ [1, 1], [1, -1], [-1, 1], [-1, -1] ] STRAIGHTS = [ [0, 1], [0, -1], [1, 0], [-1, 0] ] def initialize(color, board, pos) @color, @board, @pos = color, board, pos ...
true
3a80c638c6a0b6bb46e125bf618cc2f6d197542b
Ruby
sammieValsangkar/my-cart-cli-app
/user_interaction.rb
UTF-8
1,477
3.28125
3
[]
no_license
# cli's Interactions are handled here # it prints msgs and gets inputs class UserInteraction def self.get_product_details data = {} $ProductProperties.drop(1).each do | pr| print "Enter Product #{pr} :" data[pr] = gets.chomp end data end def self.get_category_details data = {} ...
true
fbb7b49b9e7157facd10f89f9ee11840f2e09463
Ruby
MasashiFukuzawa/design-patterns-learned-in-ruby
/chap15-facade/properties.rb
UTF-8
268
2.796875
3
[]
no_license
class Properties def initialize(filename) @filename = filename end def property(mailaddr) File.open(@filename, 'r') do |f| f.read.split("\n").each do |line| break line.split('=')[1] if line.match(/#{mailaddr}/) end end end end
true
3f156280071eaaa523d7b821e0a0e94be299acd4
Ruby
chubas/stretto
/spec/music_elements/voice_change_spec.rb
UTF-8
1,404
2.578125
3
[]
no_license
require File.dirname(__FILE__) + '/../spec_helper' context "when creating it from its string representation" do context "when using numeric notation" do it "should return its value correctly" do Stretto::MusicElements::VoiceChange.new("V5").index.should be == 5 end ALL_ELEMENTS.except(:voice_chan...
true
15bd25b9ccd5bea6181d3eb9c6569c26df77d098
Ruby
yasmineezequiel/Vanilla_Ruby
/Section_18_Classes_1/Getter_Methods.rb
UTF-8
695
4.125
4
[]
no_license
# Reader/Getter method # Method that can read instance variables values # example: class Gadget def initialize @username = "User #{rand(1..100)}" @password = "topsecret" @product_number = "#{("a".."z").to_a.sample}-#{rand(1..100)}" end def to_s "Gadget #{@product_number} has the username #{@us...
true
0c55eb73bf26f5a646aefc69ee65c8b604c9c8c0
Ruby
pulkit21/blog_post
/app/models/post.rb
UTF-8
2,102
2.625
3
[]
no_license
class Post < ActiveRecord::Base validates_presence_of :title, :body belongs_to :user scope :sorted, lambda {order('published_at')} scope :published, lambda {where('published_at IS NOT NULL')} # scope :published, lambda {where("published_at IS NOT NULL AND published_at <= ?", Time.now.strftime('%a, %d %b %Y ...
true
beaad01e78a8ceaccd9bd470339c22f0e540a4fc
Ruby
randy-darsh/flash_cards
/lib/round.rb
UTF-8
395
2.984375
3
[]
no_license
class Round attr_reader :deck, :guesses, :feedback, :number_correct def initialize(deck) @deck = deck @guesses = [] @number_correct = 1 end def current_card @current_card = deck.cards.first end def record_guess(answer) @attempt = Guess.new(an...
true
e3fb2ac391502abe23b2d78bbd7265065ef17bed
Ruby
flashlaser/Scripts
/wb_crawler/tweet_commenters.rb
UTF-8
1,037
2.515625
3
[]
no_license
#!/usr/bin/env ruby # encoding: utf-8 require "rubygems" require "yaml" env = 'development' CONFIG = YAML.load_file('config/weibo.yml')[env] require "./access_dispatcher" require "./weibo_ext" require "./crawler" require "./utils" def commenters(count) sids = $stdin.map {|l| l.to_i} crawler = WeiboCrawler.new ...
true
6af11a2b6200c91aa67e9312c62bf631e83659d3
Ruby
slonia/aoc2016
/day07/part2.rb
UTF-8
1,445
3.28125
3
[]
no_license
require 'pry' class IpValidator def initialize(ip) @ip = ip extract_nets end def suports_ssl? net_babs = @nets.map { |net| possible_babs(net) }.flatten hypernet_babs = @hypernets.map { |net| possible_babs(net, true) }.flatten (net_babs & hypernet_babs).any? end private def extract_n...
true
e4fe746e48c87a66b0f84a5aad1a4cba93170843
Ruby
jwoodmansee/man_cheatsheet
/man_cheatsheet.rb
UTF-8
995
3.828125
4
[]
no_license
# menu def main_menu puts "***Main Menu***" puts '1. Command Line' puts '2. Search' puts '3. Exit' puts '** Make A Selection **' get_input end def get_input @input = gets.chomp check_input end def check_input if @input == '1' command_menu elsif @input == '2' puts 'What woud you like to kn...
true
1e220e21b3ed4f89eda7ba511ba6e0281107f76c
Ruby
kevthunder/good-and-evil-kings
/app/models/missions/trade_mission.rb
UTF-8
1,744
2.578125
3
[]
no_license
class TradeMission < Mission validate :garrisons_must_carry, on: :create validate :must_have_some_goods, on: :create validate :must_own_goods, on: :create after_initialize :after_initialize def after_initialize() add_sequence(['going','returning']) end def start_going create_movement :going ...
true
ea00eef63ccca5fd79f21ec3572509da1225f9be
Ruby
diautzi/many-to-many-through-event-ticket-attendee
/app/models/event.rb
UTF-8
1,280
3.5
4
[]
no_license
class Event attr_reader :name, :ticket_price, :total_cost @@all = [] def initialize(name, total_cost, ticket_price) @name = name @total_cost = total_cost @ticket_price =ticket_price @@all << self end def self.all @@all end def my_tickets Ticket.all.select do |instances| ...
true
dab3fd18cfb5d07dc24a1d5feefca7150c10aee8
Ruby
jrcech/ruby-snippets
/16_while_loop.rb
UTF-8
106
3.515625
4
[]
no_license
i = 0 while i <= 10 # Counts 0, will do 11 puts "Hey there" i += 1 # While has to be incremented end
true
0b9e19bc40dc05e9837273426bd65aef8f8b75e4
Ruby
mdubost/THP-jeu_combat_ruby
/app_2.rb
UTF-8
1,866
3.5
4
[]
no_license
require 'bundler' Bundler.require require_relative 'lib/game' require_relative 'lib/player' @user @player1 @player2 @enemies def welcome_message puts "Bienvenue dans le jeu le plus golri de l'histoire" puts "_________________________________________________" end def fight(user, player1, player2, enemies) whi...
true
97d0228b9bd712228489cf68e050c053f2d73e38
Ruby
victorhebdo/victorhebdo.github.io
/ruby/S_0/Exo_20.rb
UTF-8
489
3.96875
4
[]
no_license
puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ? Choisis un nombre entre 1 et 25 !" print ">" x = gets.chomp puts "Voici la pyramide :" n = 1 while n <= x.to_i puts ("# " * n) n += 1 end =begin 1.upto(x.to_i).each{|n| puts ("#" * n).ljust(x.to_i)} Possibilité avec ce code de ...
true
79662fd98e1b6f1fe40034daadf37015792fe0b2
Ruby
JulienPelisson/S3Lun
/S3Lun/cours/user_2.rb
UTF-8
364
3.15625
3
[]
no_license
require 'pry' class User attr_accessor :email @@user_count = 0 def initialize(email_to_save) if check_email(email_to_save) @email = email_to_save else puts "TON EMAIL C'EST DE LA MERDE, RENTRE MOI CA MIEUX CONNARD." @@user_count = @@user_count + 1 puts "Email : Bienvenue !!" end def self.count r...
true
82e66dee020899c20e4835f223eb2135429fe218
Ruby
RCOliveira98/logical-challenges-with-ruby
/multiply-array.rb
UTF-8
615
4.1875
4
[]
no_license
# Origem: CodeSaga # Você deve implementar o método para substituir cada posição do array pela multiplicação # do elemento anterior com o seguinte. Exemplos: # [1, 2, 3, 4] deve retornar [2, 3, 8, 12] # [2, 6, 7, 1, 3] deve retornar [12, 14, 6, 21, 3] # [3, 1, 2, 8, 9, 5] deve retornar [3, 6, 8, 18, 40, 45] class Arr...
true
0db053822c2caaf12452f3bb6a8886ed79eea6af
Ruby
yasuhito/symbo
/lib/symbo/expressions/fraction.rb
UTF-8
3,469
3.234375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'symbo/expressions/concerns/constant' module Symbo # Symbo fraction computation class Fraction < Expression include Constant using Symbo # :section: Power Transformation Methods # べき乗の低 # # (1/3).base # => UNDEFINED def base UNDEFINED ...
true
19952a1db5c43967072fabfd541bb3ba39fca373
Ruby
jmoon90/tdd_word_analytics
/tdd_word_analytics_rspec.rb
UTF-8
1,221
3.140625
3
[]
no_license
require './tdd_word_analytics' describe TddWordAnalytics do describe '#word' do it 'counts the number for each word' do expect(TddWordAnalytics.new('Hello').word_count).to eql({"Hello"=>1}) end it 'counts parses words in a sentence and give it a counter' do expect(TddWordAnalytics.new('This ...
true
8499ac40451d29aada57a2fe2a6f579f7cc4e7a3
Ruby
lorenzosinisi/cv
/lib/lorenzosinisi/warmup.rb
UTF-8
231
2.890625
3
[ "MIT" ]
permissive
module Lorenzosinisi class Warmup def initialize self.hello end def self.hello "Hello, how is going? Try to ask me what about something in that way: Lorenzosinisi.what_about? :email" end end end
true
d9a50d9cfc3ea190795db98e94315820a28fb94c
Ruby
willherrick/learn_ruby
/01_temperature/temperature.rb
UTF-8
1,312
4.03125
4
[]
no_license
temperature = 37.0 resultTemp = 0.0 #ftoc # resultTemp = (temperature - 32) * 5/9 #ctof # resultTemp = temperature * 9/5 + 32 # T(°C) = (68°F - 32) × 5/9 = 20 °C def ftoc(temperature) resultTemp = (temperature - 32) * 5.0/9.0 end # T(°F) = 20°C × 9/5 + 32 = 68 °F def ctof(temperature) resultTemp = temperature * 9...
true
35f1776d1fa74ac6e688f521d68ba715054eeaa4
Ruby
CodeCoreYVR/oct-2015-fundsy
/app/models/campaign.rb
UTF-8
2,234
2.625
3
[]
no_license
class Campaign < ActiveRecord::Base belongs_to :user has_many :comments, as: :commentable has_many :pledges, dependent: :nullify has_many :pledged_users, through: :pledges, source: :user has_many :rewards, dependent: :destroy # this enables us to creates rewards at the time we create the campaign. # by...
true
6d05377a933ccbc4903cd39ef296707670448728
Ruby
ababup1192/db-entity-generator
/generator.rb
UTF-8
3,305
3.171875
3
[]
no_license
# -*- coding: utf-8 -*- require 'singleton' require 'fileutils' # File -> [Text] -> [DriverEntity], [MorphiaEntity], [IciqlEntity] class EntityReader include Singleton def read csv_files = Dir.glob('*.csv') # csv -> [{ファイル名: [行データ]}] -> {ファイル名: [行データ]} file_hash = csv_files.map{ |csv_file| File.o...
true
eb6e55aa0d0815400f755978b6b4857a6282165e
Ruby
BenRKarl/WDI_work
/w03/d03/Ben_Karl/phases/phase_2.rb
UTF-8
853
3.03125
3
[]
no_license
require "pg" require "active_record" database_name = "bus_app" ActiveRecord::Base.establish_connection("postgres://localhost/#{database_name}") class Bus < ActiveRecord::Base has_many :passengers end class Passenger < ActiveRecord::Base belongs_to :bus end the_l = Bus.create({route: ["8th", "6th", "Union Square...
true
9ce3e869b4c9a4186fed3c54cde57e57ce3153e4
Ruby
rafaeldoria/ruby_class
/new_person.rb
UTF-8
211
3.640625
4
[]
no_license
class Person def initialize end def say puts 'Hello' end def say(name) puts 'Hello ' + name end end person = Person.new # person.say error person.say('Rafael')
true
c93b12c6a2991ee1b345f47f71cbbfc2d09dcb8a
Ruby
raquelnishimoto/launchschool_RB101_RB109
/small_problems/easy6/triangle.rb
UTF-8
319
3.765625
4
[]
no_license
def triangle(num) star = '*' spaces = ' ' num.times do |iteration| num -= 1 puts "#{spaces * num}#{star * iteration}" end end def triangle_down(num) star = '*' spaces = ' ' num.times do |iteration| num -= 1 puts "#{star * num}#{spaces * iteration}" end end triangle(9) triangle_down(9)
true
c02837c8ec76ecfdc9b555f8c866ea3b5c51c0a3
Ruby
Corey-Miller85/Practice
/FreqLetters.rb
UTF-8
326
3.5625
4
[]
no_license
def frequent_letters(string) frq_arr = [] new_hash = Hash.new(0) string.each_char do |char| new_hash[char] += 1 end new_hash.each do |char, num| if num > 2 frq_arr << char end end return frq_arr end print frequent_letters('mississippi') #=> ["i", "s"] puts print frequent_letters('bootcamp') #=> [...
true
5b7f18cb64f67f7e47cb257b85f4ea01fa0f9ee7
Ruby
jubby2000/aA-homeworks
/W2D4/big_o.rb
UTF-8
1,523
3.6875
4
[]
no_license
FISHIES = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh'] TILES = ["up", "right-up", "right", "right-down", "down", "left-down", "left", "left-up"] def sluggish largest = FISHIES.first FISHIES.each do |fish| FISHIES.each do |fish2| if fish2.length > fish.lengt...
true
09d8446f1ceec43b788aca63c07a836f8bd57ce4
Ruby
alexlolas/Homework
/W3D4 HW/homework.rb
UTF-8
428
3.203125
3
[]
no_license
class Stack attr_reader :array def initialize @array = [] end def push(el) array.push(el) end def pop @array = @array[0...-1] end def peek @array end end class Queue def initialize @array = [] end def enqueue(ele) @array.unshift(ele) end def dequeue @array = @array[0...-1] e...
true
57aaa385c0fcc8d3e610d94bf754e3dbdec48588
Ruby
Vlad-Andres/ruby_scripts
/sign_in.rb
UTF-8
815
3
3
[]
no_license
require 'rubygems' require 'mechanize' require 'nokogiri' def signIn(login,pass) puts "Please insert String" unless login.is_a? String a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } a.get('https://github.com/login') do |page| puts "running..." puts page.inspect form = p...
true
0c9c9dd8a6503f688ecc8e66c3d6233ea29d1c92
Ruby
isalevine/oo-relationships-practice-seattle-web-career-021819
/app/models/imdb/console.rb
UTF-8
1,652
3.109375
3
[]
no_license
require_relative './actor.rb' require_relative './character.rb' require_relative './movie.rb' require_relative './moviechar.rb' require_relative './show.rb' require_relative './showchar.rb' require 'pry' kaitlin = Actor.new("Kaitlin") devito = Actor.new("Devito") rob = Actor.new("Rob") charlie = Actor.new("Charlie") ...
true
76b40771a8c3c484f2161abaf6811ebf885035a5
Ruby
bendee48/hangman-2.0
/spec/guess_logic_spec.rb
UTF-8
4,492
3.28125
3
[]
no_license
# frozen_string_literal: true require_relative '../lib/guess_logic' require_relative '../lib/word_to_guess' require_relative '../lib/guess' RSpec.describe GuessLogic do subject(:guess_logic) { described_class.new(word_to_guess) } let(:word_to_guess) { instance_double(WordToGuess, word: 'hello') } describe '#w...
true
f3944014d5206d8025022d81229145cf2ca57326
Ruby
SherwinTempRepoFolder/ruby-monster-oop
/starter-code/monster.rb
UTF-8
1,126
3.46875
3
[]
no_license
### monster.rb - run this file # Monster class class Monster include Comparable attr_accessor :habitate, :threat_level, :name @@monster_count = 0 THREAT_LEVEL = [:low, :medium, :high, :midnight].freeze def initialize(threat_level = :medium, name = "Noname") @habitate = "Cave of Caerbannog" if THREAT_LEV...
true
c02ed8a388d7e63a9644a7d986b3cdb607b59ab6
Ruby
cheshire137/graphql-ruby
/lib/graphql/analysis/field_usage.rb
UTF-8
1,491
2.53125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module GraphQL module Analysis # A query reducer for tracking both field usage and deprecated field usage. # # @example Logging field usage and deprecated field usage # Schema.query_analyzers << GraphQL::Analysis::FieldUsage.new { |query, used_fields, used_deprecated_fi...
true
1b7dcc14fb0eed2f0ece6436e0ee69ed340e08fd
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/prime-factors/dcd85945cb1f47dfa75cd134145ca0a3.rb
UTF-8
547
3.546875
4
[]
no_license
class PrimeFactors def self.for(number) factors = [] i = 1 while i <= (number) while number % i == 0 && prime?(i) factors << i number = number / i end i += 1 end factors end private def self.prime?(n) if n < 4 lookups[n] elsif n.even? ...
true
518ba08ffd3414f18655f08f96c1a3914a6aec1c
Ruby
marnen/quorum2
/spec/models/search_spec.rb
UTF-8
2,068
2.90625
3
[ "BSD-3-Clause" ]
permissive
# coding: UTF-8 require 'spec_helper' describe Search do before(:each) do @hash = {:a => 1, :b => 2} end it "should be usable on a Hash" do expect { @hash.extend(Search) }.to_not raise_error end it "should be able to extend nil" do pending "How do we test this without screwing up the environme...
true
4124a2e14c12ab4bcce31c143b73810e9df98bc5
Ruby
zelaznik/scratchpad
/App-Adademy/app_academy_prep/w2d3.rb
UTF-8
3,784
3.21875
3
[]
no_license
require 'sqlite3' class SQLite3::Database def next_id(tbl_name) qry = 'SELECT MAX(ID) FROM ' + tbl_name id = self.execute(qry)[0][0] (id==nil)? 1: id + 1 end end $db = SQLite3::Database.new(':memory:') $db.execute(''' CREATE TABLE Course ( ID INTEGER PRIMARY KEY AUTOINCREMENT ,Name TEXT NOT NULL ...
true
4ebc6eaef58d3d9c41de5cafcf5c6fa900848916
Ruby
97-Jeffrey/updates
/app/controllers/updates_controller.rb
UTF-8
1,742
3.0625
3
[]
no_license
require "httparty" class UpdatesController < ApplicationController # All logics of sorting, filtering, and counting are implemented by controllers' methods, then passed into index action as variables, so index.html.erb is just for render html and ruby variables. # So index action knows nothing about logics, it...
true
c0239ad6f5460fc964adc14329e1cae86816ea09
Ruby
hidez8891/joysound_ranking_tracker
/lib/batches/get_records.rb
UTF-8
2,073
2.78125
3
[]
no_license
# -*- encoding: utf-8 -*- class GetRecords require 'nokogiri' require 'open-uri' require 'date' require 'cgi' def self.execute() Artist.all.each do |artist| url = REQUEST_SEARCH_URL + CGI.escape(artist.name) logs = data_to_hash(get_data_all(url)) date = Date::today.to_s logs.ea...
true
c33fa88eb4cc396fd4824b78376a03efcf849f9b
Ruby
lisp-ceo/kata
/ruby/lib/fizz_buzz.rb
UTF-8
592
4.125
4
[]
no_license
# -*- coding: utf-8 -*- "Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”." (1..100).to_a.each{|i| print "Fizz" if i % 3 == 0 prin...
true
abdbc80fb4388058bf6bc368ac86a8b0531ac13b
Ruby
denisnurboja/Assignments
/Hiring and Firing Employees/company.rb
UTF-8
879
4.0625
4
[]
no_license
# Set's the class of 'Company' with name, city, and employees (which is an []) # attributes. class Company attr_accessor :name, :city, :employees # Initalizes employees attribute to be an array. def initialize @employees = [] end # Creates the fire method by using 'delete_if' and the variable 'fired'...
true
ea8456208b31902ccd8ebe2c543930c152fec1c9
Ruby
johnjenkins/SassyExport
/lib/SassyExport.rb
UTF-8
5,160
2.703125
3
[ "MIT" ]
permissive
require "compass" require "json" extension_path = File.expand_path(File.join(File.dirname(__FILE__), "..")) Compass::Frameworks.register('SassyExport', :path => extension_path) # Version is a number. If a version contains alphas, it will be created as a prerelease version # Date is in the form of YYYY-MM-DD module Sa...
true
3dac7b4541558b8f5b0d1bca97dedb49185067c8
Ruby
jessjchang/Ruby-Object-Oriented-Problems
/RB120_OOP_exercises/easy_1/fix_the_program_books_1.rb
UTF-8
1,208
4.125
4
[]
no_license
class Book attr_reader :author, :title def initialize(author, title) @author = author @title = title end def to_s %("#{title}", by #{author}) end end book = Book.new("Neil Stephenson", "Snow Crash") puts %(The author of "#{book.title}" is #{book.author}.) # => The author of "Snow Crash" is Neil...
true
147d169e77859561d1688efdcbc81100231d28b5
Ruby
tcrurup/oo-student-scraper-online-web-sp-000
/lib/scraper.rb
UTF-8
1,996
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'open-uri' require 'pry' class Scraper #name: student.css(".student-name").text #location: student.css("student-location").text #profile_url: student.css("a").attribute("href").value def self.scrape_index_page(index_url) index_page = Nokogiri::HTML(open index_url) all_profiles = [] ...
true
f6c8384ccdc3fb2fd4eed2ac8307b17f647fc10c
Ruby
m-yan/home-automation-webapp
/app/parameters/hgw_if_parameters.rb
UTF-8
1,650
2.5625
3
[]
no_license
class HgwIfParameters private_class_method :new def initialize(params) @params = params['Device']['Modules'] end def self.build_from_hash(params) return new(params) end def self.build_from_xml(xml) return new Hash.from_xml(xml) end def to_params params = {} params.store :mode, m...
true
77bcb6bf1df6c3ca67f84cf73fc4e14ab71713bc
Ruby
magdamurphy/magda-first-project
/magda.rb
UTF-8
147
3.6875
4
[]
no_license
def isThisMyFirstMethod(isTrue) if isTrue.to_i == 9 puts "Yes" else puts "No" end end input = gets.chomp isThisMyFirstMethod(input)
true
5b463657d457580b6755431dfacfcc74a5995993
Ruby
gameisch/plit
/app/models/search.rb
UTF-8
2,010
2.609375
3
[]
no_license
class Search < ActiveRecord::Base attr_accessible :keywords, :user_id, :user_name, :user_nick, :user_proff, :user_adress, :user_detail, :post_title, :post_content def users @users ||= find_users end def posts @posts ||= find_posts end private def find_posts Post.find(:all, :conditions => conditions) end ...
true
7922d3609ff12ce1f80abde4988ac30b926aa67a
Ruby
otherworldlyguardian/apples-and-holidays-prework
/lib/holiday.rb
UTF-8
1,095
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def second_supply_for_fourth_of_july(holiday_hash) holiday_hash[:summer][:fourth_of_july][1] end def add_supply_to_winter_holidays(holiday_hash, supply) holiday_hash[:winter].each do |key, value| value << supply end end def add_supply_to_memorial_day(holiday_hash, supply) holiday_hash[:spring][:memorial_d...
true
1524a4474e0d9f7a9b67880926918fda9d6725b7
Ruby
infinum/json_api_responders
/lib/json_api_responders/config.rb
UTF-8
1,228
2.546875
3
[]
no_license
module JsonApiResponders class Config attr_reader :required_options DEFAULT_RENDER_METHOD = :json RENDER_METHODS = [:jsonapi, :json] def required_options=(opts = {}) @required_options = opts end def check_required_options(options) return if @required_options.nil? || @required_opt...
true
e4665b03a1575e0c46ec02df1d74353a1c133777
Ruby
eewhy/ruby-playground
/calculation_generator_730.rb
UTF-8
395
3.296875
3
[]
no_license
# calculation password_generator # Print out a command followed by two numbers # the command will be either: ADD, SUB, DIV, or MUL # the numers will be two numbers btw 0 - 100 COMMANDS = ["SUB", "ADD", "DIV", "MUL"] output ="" 10.times do number_1 = rand(100) + 1 number_2 = rand(100) + 1 output << "#{COMMANDS....
true
ab8b98705cf616563ce2451c1580048301e1f967
Ruby
carlmunn/my_rails_helpers-params_helper
/spec/my_rails_helpers/defaults_spec.rb
UTF-8
2,309
2.734375
3
[]
no_license
require 'spec_helper' describe MyRailsHelpers::ParamsHelper do def new_toggle(*args) MyRailsHelpers::ParamsHelper::Toggler.new(*args) end def _debug(msg) puts "\e[32m #{msg.inspect} \e[0m" end context 'defaults' do let(:defaults) do {val: { opt1: false, opt2: false, ...
true
f2b68e1ee3a405a6a97ec2616442b030eda52246
Ruby
escoffon/fl-framework
/lib/fl/framework/access/access.rb
UTF-8
10,848
3.078125
3
[ "MIT" ]
permissive
module Fl::Framework::Access # Access control APIs. # This module adds support for access control to a class. # When it is included, it defines the macro {ClassMacros#has_access_control}, which turns on access # control support in the class. # When access control is enabled, a number of instance and class met...
true
762504c2051a2443f6a1ab5de850617cae034666
Ruby
xc145214/practise
/ruby/src/helloworl.rb
UTF-8
464
3.578125
4
[]
no_license
print("hello,ruby.\n") print("hello,\nRuby \n!\n") print("hello ,\"ruby\".\n") print ("hello \\ruby!\n") print('hello,\nruby\n!\n') print('hello, \'ruby\'.') print('hello \\ruby.') print("hello,","ruby",".","\n") puts('hello,Ruby.') puts("hello,","Ruby!") puts("100") puts(100) p "100" p 100 puts "hello ,\...
true
86cb6fbe4149bbd7e38a8b333a6ad5e6b35afdae
Ruby
ilydia/ilydia.github.io
/oop.rb
UTF-8
687
3.8125
4
[]
no_license
class Animals attr_accessor :name, :owner_name end class Dogs < Animals def bark return "ruh-roh" end end class Cats < Animals def meow return "purr purr" end end class Lambs < Animals def bleet return "baa baa" end end my_dog = Dogs.new m...
true
cef84027108e10d812616dde327ceced73a5e195
Ruby
ericwhited/MicroBlog
/app.rb
UTF-8
4,853
2.890625
3
[]
no_license
require 'sinatra' require 'sinatra/activerecord' require 'bundler/setup' require 'sinatra/flash' require 'bootstrap' require './models/user.rb' require './models/post.rb' require './models/profile.rb' enable :sessions configure(:development){set :database, "sqlite3:testapp_signin.sqlite3"} #route to the home page, i...
true
b0b952839c9edf017c3eabc2dc927d3d5525eb46
Ruby
Madh93/stallman_bot
/lib/stallman_bot/listener.rb
UTF-8
825
2.703125
3
[ "MIT" ]
permissive
require 'stallman_bot/commands' module StallmanBot class Listener def initialize @listening = false @cmd = Commands.all @replies = Locale.replies end def respond(message, bot = nil, id = nil) if command?(message) @listening = run_command(message, bot, id) elsif @lis...
true
bcc123497a33024c8c79b3d12389f40b3b68d330
Ruby
nomlab/camome
/app/models/google_calendar/event.rb
UTF-8
741
2.984375
3
[]
no_license
module GoogleCalendar class Event def initialize(event,color) @event = event @color = color end def to_fullcalendar full_event = {} full_event["id"] = @event["id"] full_event["title"] = @event["summary"] full_event["start"] = @event["start"]["dateTime"] || @event["star...
true
9b7644eabd58f9376c94e2dd307e035d3460c85f
Ruby
stmosher27/app-
/app_in-class/w1d2/ComputerPlayer.rb
UTF-8
2,094
3.09375
3
[]
no_license
class ComputerPlayer def initialize(name = "machine") @name = name @store = { 1 => [[],[]], 2 => [[],[]], 3 => [[],[]], 4 => [[],[]], 5 => [[],[]], 6 => [[],[]], 7 => [[],[]], 8 => [[],[]] } @possible_moves = fill_up_moves @result = [] # @prev_va...
true
169e802ebe707c362939bf8349cd26c35a67f7ba
Ruby
Jaquelinealvess/Ruby03
/operadores_distribuicao.rb
UTF-8
26
2.71875
3
[ "Apache-2.0" ]
permissive
a = 2 a = a + 1 puts a
true
eeed3468f6fdfa98bdee519ba3a101b4d5e9469e
Ruby
KellyIB/super_duper_sports_games
/lib/standard_dev.rb
UTF-8
508
3.140625
3
[]
no_license
class StandardDev def initialize(input) @input = [] end def standard_dev(input) average_input = (input.sum.to_f / input.length.to_f).round(2) ab_value_diff_from_ave = input.map do |input| (average_input - input).abs end squared_difference_from_average = ab_value_diff_from_ave.map do |num...
true
c328fd744a1dfa3a1e73165f86adca2b926a8355
Ruby
julio/puzzles
/strings/four_letter_words.rb
UTF-8
1,668
3.640625
4
[]
no_license
class SuffixFinder DICTIONARY = "/usr/share/dict/words" # --------------------------------------------------------------------------- def initialize(word_length) @word_length = word_length @suffixes = Hash.new(0) @words = {} end # --------------------------------------------------------...
true
45e65da72b6f9b447304249fb6f6eb26d17387fc
Ruby
danroche10/battle-game-2
/spec/player_spec.rb
UTF-8
541
2.890625
3
[]
no_license
require 'player' describe Player do let(:player1) { (described_class.new("Dan"))} let(:player2) { (described_class.new("Hotu"))} describe '#initialize' do it "initializes with name Dan" do expect(player1.name).to eq "Dan" end it 'initializes the hits as 100' do expect(player1.hit_points...
true
71c62c2da4163c3d994e9b31c486ff714d1a5465
Ruby
ayaniimi213/Rakuten-Recipe
/comvert2complete-matrix.rb
UTF-8
997
2.8125
3
[]
no_license
#!/usr/bin/ruby # -*- coding: utf-8 -*- require 'nkf' opt = "-w -h -Z1" if ARGV.size < 2 puts "USAGE: " + __FILE__ + " " + "foodCompositionTableFile queryResultFile" exit else foodCompositionTableFile = ARGV.shift queryResultFile = ARGV.shift end foodIDs = Array.new File::open(foodCompositionTableFile){|f| ...
true
e5ebeef0c83c6311a4ce9b8e0ed635398276a516
Ruby
CRSmith15/ttt-7-valid-move-online-web-sp-000
/lib/valid_move.rb
UTF-8
371
3.265625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
board = [" "," "," "," "," "," "," "," "," "] def valid_move?(board, index) spot = nil if index.between?(0, 8) && !(position_taken?(board, index)) spot = true else spot end spot end def position_taken?(board, x) taken = nil if (board[x] == " " || board[x] == "" || board[x] == nil) taken...
true
8b9c5687b20a9015d9488a700fe1140f468c59c9
Ruby
tashk85/codewars
/is_prime.rb
UTF-8
836
4.53125
5
[]
no_license
# Is Prime # Define a function isPrime/is_prime() that takes one integer argument and returns true/True or false/False depending on if the integer is a prime. # Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. # Example # bool isPrime...
true
767e9c358e63ccfa63e17305d38fc620bd06cfe5
Ruby
albertintech/ruby_basics
/user_input/ex9_launch_school_printer_pt2.rb
UTF-8
1,651
4.59375
5
[]
no_license
# In an earlier exercise, you wrote a program that prints 'Launch School is the best!' repeatedly until a certain number of lines have been printed. Our solution looked like this: # number_of_lines = nil # loop do # puts '>> How many output lines do you want? Enter a number >= 3:' # number_of_lines = gets.to_i # ...
true
05fc7a7f880fdebc288cde4bcb7df66d88c5d5e0
Ruby
nguyennam9696/NoteWebApp
/app/controllers/index.rb
UTF-8
1,456
2.53125
3
[ "MIT" ]
permissive
# HOME PAGE (LOG-IN / REGISTER) get '/' do if logged_in? redirect "/users/#{current_user.id}/notes" else erb :index end end #----------- LOGIN SUBMISSION ----------- post '/login' do user = User.where(email: params[:email]).first if user && user.password == params[:password] login(user) redi...
true
71aeca1bcd3e075d3829ffbade6b145eac62875f
Ruby
marioabreu/levelup-exercises
/basic-ruby/ruby-core/base_dinosaur.rb
UTF-8
352
3.5
4
[]
no_license
class BaseDinosaur attr_reader :name, :period, :weight, :walking def initialize(name: "", period: "", weight: 0, walking: "") @name = name @period = period @weight = weight @walking = walking end def to_s "Name: #{name}\n" + "Period: #{period}\n" + "Weight: #{weight}\n" + "W...
true
f34759ac27a5f4a827b100e5a96defa63d61bf30
Ruby
mikej/url_decrufter
/lib/url_decrufter.rb
UTF-8
1,271
2.90625
3
[ "MIT" ]
permissive
require "url_decrufter/version" require "uri" module UrlDecrufter class UrlFilter attr_accessor :uri def initialize(uri) @uri = uri.dup end def params return [] if @uri.query.nil? @uri.query.split("&").map { |p| p.split("=") } end def update_params(new_params) # ma...
true
d6d3885834e920937f70111c95aa02e75fc687e9
Ruby
joequincy/flash_cards
/test/deck_test.rb
UTF-8
1,413
3.40625
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/deck' require './lib/card' class DeckTest < Minitest::Test def setup @card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) @card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the sur...
true
3554456a87a47c43eabd00cf16acdc6c23bc6f62
Ruby
jsamos/scrape-engineer-blogs
/main.rb
UTF-8
1,687
2.859375
3
[]
no_license
require 'rubygems' require 'simple-rss' require 'open-uri' blacklist = ['https://rainsoft.io/rss/'] year = 2016 month = 8 day = 31 posts = {} def get_feed(url) begin timeout(10) do p "Trying #{url}" open(url) end rescue p "Failed to read: #{url}" nil end end def get_recent_posts(fe...
true
e65956f2c39aa8f6855405b43c531d74aa2a0c80
Ruby
jsdelivrbot/Semaine-0
/day5/exo_15.rb
UTF-8
252
3.6875
4
[]
no_license
puts "Donne moi ton année de naissance" user_number = gets.chomp u = user_number.to_i puts "Je vais compter à partir de #{user_number} jusqu'à 2017" while (u <= 2017) age = u-user_number.to_i puts "En #{u} vous aviez #{age} an(s)" u = u + 1 end
true
8d983ab53dea49f366691b15d45d6a4134286605
Ruby
vi7ali/connect-four
/lib/game.rb
UTF-8
901
3.890625
4
[]
no_license
require_relative 'board.rb' require_relative 'player.rb' class Game attr_accessor :board, :player_1, :player_2, :current_player, :other_player def initialize @board = Board.new @player_1 = Player.new @player_2 = Player.new @current_player = player_1 @other_player = player_2 end def play ...
true
8996cf54a559574f3354368059da21f9ba9e69e5
Ruby
lukpod1/n-random
/app/services/postgre_sql.rb
UTF-8
808
3.1875
3
[]
no_license
require 'pg' class PostgreSql def initialize @client = PG::Connection.new(host: ENV['POSTGRESQL_HOST'], dbname: 'rand_number', user: ENV['POSTGRESQL_USERNAME'], password: ENV['POSTGRESQL_PASSWORD']) @client.query('CREATE TABLE IF NOT EXISTS rand_numbers (id serial PRIMARY KEY, number INTEGER);') @numbers...
true
6a05712ee0575b5cdcaa2719fd8cc5eec7686b0f
Ruby
jKwibe/backend_module_0_capstone
/day_6/exercises/burrito.rb
UTF-8
1,339
4.1875
4
[]
no_license
# Add the following methods to this burrito class and # call the methods below the class: # 1. add_topping # 2. remove_topping # 3. change_protein class Burrito attr_reader :protein, :base, :toppings def initialize(protein, base, toppings) @protein = protein @base = base @toppings = toppings end...
true
bc5840798311606c5ce5334f7bcf8e572b6d0af7
Ruby
nishidy/ParseWikipediaXML
/share/build_on_spot_instance.rb
UTF-8
3,046
2.578125
3
[]
no_license
require 'aws-sdk-core' require 'active_support/all' # Show message def decop(text) deco="===" puts "#{deco} #{text} #{deco}" end # Wait on showing message with motion def waitp(text,sleept) cnt = 0 max_cnt=10 while cnt<max_cnt do $stdout.flush print "=== "+text print " [" ...
true
6bc053e0b88f6dcdbfd3d38cce1712701174dc9d
Ruby
sejinkim1904/little_shop
/spec/models/merchant_spec.rb
UTF-8
2,170
2.703125
3
[]
no_license
require 'rails_helper' RSpec.describe Merchant do describe 'Relationships' do it {should have_many :items} end before(:each) do @megan = Merchant.create!(name: 'Megans Marmalades', address: '123 Main St', city: 'Denver', state: 'CO', zip: 80218) @brian = Merchant.create!(name: 'Brians Bagels', addre...
true
d78307d69721f2f405d1890eac89d00305ec8f16
Ruby
geronimod/mormon
/lib/mormon/weight.rb
UTF-8
1,221
2.828125
3
[ "MIT" ]
permissive
module Mormon class Weight # Represents an hipotetical velocity of the transport in the way type @weightings = { motorway: { car: 10 }, trunk: { car: 10, cycle: 0.05 }, primary: { cycle: 0.3, car: 2, foot: 1, horse: 0.1 }, secondary: { cycle: 1, car: 1.5, foot: 1, ho...
true
669812af7a58b01d7a970cbf64c813ba603673b8
Ruby
tiy-boomtown/class-notes
/6/katas_spec.rb
UTF-8
816
3.703125
4
[]
no_license
require 'rspec' class Item attr_reader :name, :price def initialize(name, price) # @name, @price = name, price @name = name @price = price end end class Cart def initialize @list = [] end def add_item(item) # item.name # item.price @list.push item end def total_price ...
true
cc00cbc3992b62c7278093950c1c5697e660160d
Ruby
IkumaTadokoro/Exercism
/ruby/grains/grains.rb
UTF-8
636
3.625
4
[]
no_license
=begin Write your code for the 'Grains' exercise in this file. Make the tests in `grains_test.rb` pass. To get started with TDD, see the `README.md` file in your `ruby/grains` directory. =end class Grains FIRST_TERM = 1 COMMON_RATIO = 2 START_OF_SQUARE = 1 END_OF_SQUARE = 64 def self.square(length) rai...
true
4c2325be75818f8046ee605bb83d8b967b04e7f2
Ruby
marcel/scout
/app/controllers/matchups_controller.rb
UTF-8
3,469
2.546875
3
[]
no_license
class MatchupsController < ApplicationController def index @week = (params[:week] ||= GameWeek.current.week).to_i @defensive_matchups = Game.where(week: @week).includes(:home, :away, :stadium).load.map do |game| [game.home_team_defensive_matchup, game.away_team_defensive_matchup] end.flatten.sort_...
true
d6532b0ef1b67fd1865fc449a385fad644787dc8
Ruby
evansenter/dinosaur
/transformer_test.rb
UTF-8
1,083
2.828125
3
[]
no_license
require "./transformer.rb" DinoParser.debug = true DinoTransformer.debug = true puts "+--------------------------------------------------------+" puts "| TRANSFORMER TESTS |" puts "+--------------------------------------------------------+" solution = DinoTransformer.apply(...
true
6189a1fda92a47567da1ee90a150ad64b9d88ce1
Ruby
maddeno/programming-univbasics-4-square-array-chi01-seng-ft-010620
/lib/square_array.rb
UTF-8
159
3.421875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def square_array(array) counter = 0 new_array = [] while counter<array.length do new_array<< array[counter]**2 counter += 1 end new_array end
true
c496f874eade6aa6252c6b652732c7e0edd11f05
Ruby
ryenus/euler
/pe007.rb
UTF-8
348
3.9375
4
[]
no_license
#~ require 'prime' #~ m, n = 2, 1 #~ loop do #~ m += 1 #~ if m.prime? #~ n += 1 #~ break if n == 10_001 #~ end #~ end #~ puts m #~ require 'mathn' require 'prime' primes = Prime.new 10_000.times { primes.next } puts "Prime is #{ primes.next }." #~ Prime.each(100) do |prime| #~ p prime #=> 2, 3, ...
true
f794309901f8b253f8ac8195dc3ba1fd64d024b8
Ruby
hackphobic/Cryptography
/compute_average_ioc.rb
UTF-8
886
3.4375
3
[]
no_license
def compute_ioc(text, start, skip) frequencies = Hash.new{|h, k| h[k] = 0} (start..text.size-1).step(skip) do |i| frequencies[text[i]] += 1 end ioc = 0 frequencies.each_value do |frequency| ioc += frequency*(frequency-1) end ioc /= 1.0*(text.size/skip)*((text.size-1)/skip) return ioc ...
true
12ea431a52477872804abc89f10ccfcc336d5c92
Ruby
tleish/did_you_mean
/lib/did_you_mean/finders/name_error_finders/similar_name_finder.rb
UTF-8
1,004
2.828125
3
[ "MIT" ]
permissive
module DidYouMean class SimilarNameFinder include BaseFinder attr_reader :name, :_methods, :_local_variables, :_instance_variables def initialize(exception) @name = exception.name @_methods = exception.frame_binding.eval("methods") @_local_variables = except...
true
f0aace96e41c0bb5d36108bb857e052cfa2d44d9
Ruby
joshliu/misc
/scripts/crossword.rb
UTF-8
1,771
3.015625
3
[]
no_license
require 'pry' require 'tesseract' e = Tesseract::Engine.new {|e| e.language = :eng e.blacklist = '|' } text = e.text_for('help.JPG').strip text = text.gsub("0","O") text = text.gsub("1","I") lol = /[a-zA-Z]/.match(text) array = [] sample = "" $twod = [] text = text.split("") text.each do |lol| if /[a-zA-Z\n]/...
true
413429efb44cb2ed98a6de71c5bbb0ac1905bfd6
Ruby
show412/leetcode
/problems/amazon/medium/find_all_dupliates_in_array.rb
UTF-8
948
3.703125
4
[]
no_license
# Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. # Find all the elements that appear twice in this array. # Could you do it without extra space and in O(n) runtime? # Example: # Input: # [4,3,2,7,8,2,3,1] # Output: # [2,3] # https://leetcode.com/prob...
true