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
226c9cd5a2fe3ceaa3166e06f45481708982bf51
Ruby
margaritawang/ar-exercises
/exercises/exercise_7.rb
UTF-8
497
3.09375
3
[]
no_license
require_relative '../setup' require_relative './exercise_1' require_relative './exercise_2' require_relative './exercise_3' require_relative './exercise_4' require_relative './exercise_5' require_relative './exercise_6' puts "Exercise 7" puts "----------" # Your code goes here ... # puts "Gimme a name" # user_input =...
true
c674ae987dcd2189c9f46f12c91e856d1c1a5d30
Ruby
sensu-plugins/sensu-plugins-opsgenie
/bin/check-opsgenie-heartbeat.rb
UTF-8
2,193
2.71875
3
[ "MIT" ]
permissive
#! /usr/bin/env ruby # # check-opsgenie-heartbeat # # DESCRIPTION: # Sends heartbeat signal to Opsgenie. If Opsgenie does not receive one at least every 10 minutes # it will alert. Fails with a warning if heartbeat is not configured in the Opsgenie admin # interface. # # OUTPUT: # plain text # # PLATFORMS: # ...
true
fa7a7cf34f2048a5c87080503421a21382f9d151
Ruby
famished-tiger/Rley
/lib/rley/parse_rep/parse_rep_creator.rb
UTF-8
2,036
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true require_relative '../parser/parse_walker_factory' module Rley # This module is used as a namespace module ParseRep # This module is used as a namespace # Utility class that helps to create a representation of a parse from # a given Parsing object. class ParseRepCreator ...
true
d4dfaa9f50974d6e718fdc9af6b57ef5edc2e771
Ruby
kenchan/competitive_programming
/atcoder/abc155/d.rb
UTF-8
203
2.546875
3
[]
no_license
N, K = gets.split.map(&:to_i) A = gets.split.map(&:to_i) minus, plus = A.partition {|i| i < 0 } minus.sort! plus.sort! index = 1 if 0 < minus.size && 0 < plus.size minus.each do |i| end end
true
83bc883ee00b3ff08e722542a7a430ba94380f98
Ruby
rogerleite/minion_server
/lib/minion_server.rb
UTF-8
1,431
2.640625
3
[ "MIT" ]
permissive
require "socket" require "rack" class MinionServer VERSION = "0.0.2" def initialize(app) @app = app end def start(host = "localhost", port = 4000, options = {}) #puts "== Starting #{@app.inspect}" @pid_server = fork do server_options = { :app => @app, :server => 'webrick', ...
true
ac8058c76d89d0e6bb7009df78b784f087cab875
Ruby
alu0100700459/prct09
/lib/prct09/matriz.rb
UTF-8
3,738
3.71875
4
[ "MIT" ]
permissive
module Prct09 class Matriz include Enumerable attr_reader :filas, :columnas # Constructor. No crea ningún contenedor def initialize(filas, columnas) validate_sizes(filas, columnas) @filas = filas @columnas = columnas end # Método para poder utilizar Enumerable def each for i in 0...self...
true
7db0270f114c1b1350737ab400a02f3106dd2c52
Ruby
vroy/songster
/lib/songster/mouth.rb
UTF-8
2,086
3.0625
3
[ "MIT" ]
permissive
module Songster # Holds extra information about the mouth found in Face. class Mouth attr_reader :left_x, :left_y, :center_x, :center_y, :right_x, :right_y attr_reader :left, :center, :right attr_reader :x, :y, :width, :height, :top, :middle, :bottom attr_reader :opening_size, :chin_height # ...
true
25c967e65a1ed2e3e8326ebc7cf82c1a56e5e4f4
Ruby
GarlandLai/sphinx-heroku
/app.rb
UTF-8
961
2.59375
3
[]
no_license
require('sinatra') require('sinatra/reloader') also_reload('lib/**/*.rb') require('./lib/sphinx.rb') get('/') do "Home" erb(:sphinx) end get('/sphinx') do "sphinx intro page" erb(:sphinx) end get ('/sphinx/question1') do "question for first riddle here" erb(:question1) end get ('/sphinx/question2') do ...
true
bc61321032d4440d83c1cdf09443d520669a8be4
Ruby
meganmersch/kwk-l1-mothers-day-methods-kwk-students-l1-raleigh-072318
/mothers_day.rb
UTF-8
248
3.953125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
## Define your method, mothers_day, below. Go through the README and update your method as needed! def mothers_day puts "Happy Mother's Day, Mom!" end mom = gets def mothers_day(mom) puts "Happy Mother's Day, #{mom}!" end mothers_day(mom)
true
a0f8923d6ecfdba3163714a180a4e0dddc2d46e7
Ruby
badCompany110/LearningProjectcs
/Projects/Ruby/Loops/until_loop.rb
UTF-8
514
4.125
4
[]
no_license
answer="" # if you don't define answer before commencing the loop, ruby will return an error of undefined variable of answer until answer=="no" print "Do you want this loop to continue? (yes/no) " answer=gets.chomp end def print_hello(number_of_times) i = 0 until i >= number_of_times print "hello " ...
true
05c3fa3f129686c568f80557282b722896db1af1
Ruby
camyhsu/TO-Chinese-School
/chineseschool/app/helpers/instruction/school_classes_helper.rb
UTF-8
1,687
2.78125
3
[]
no_license
module Instruction::SchoolClassesHelper def format_family_fields(student) families_as_child = student.find_families_as_child return format_family_fields_without_parent(student) if families_as_child.empty? family_fields = {} extract_parent family_fields, families_as_child extract_email_phone fami...
true
c504d395847f344bd8a005c53c9a363f50bfe1a4
Ruby
stubblyhead/advent2015
/day13/kingarthur.rb
UTF-8
1,472
2.9375
3
[]
no_license
lines = File.readlines('./input', :chomp=>true) guests = [] happiness_rules = {} lines.each do |i| i.sub!('gain', '') #do some minor line edits for easier regex i.sub!('lose ', '-') match = i.match(/^(\w+).* (-?\d+).* (\w+).$/) #grab the names on either end and the happiness modifier in the middle current,ha...
true
ddbf9b37abeef35c848a7f96c0e88bcea942eb20
Ruby
kjjwhitlock/boris-bikes
/spec/dockingstation_spec.rb
UTF-8
784
2.8125
3
[]
no_license
require 'docking_station' describe 'DockingStationTest' do it 'responds to release_bike' do expect(DockingStation.new).to respond_to(:release_bike) end it 'get the bike and check if bike is working' do station = DockingStation.new station.dock_bike expect(station.release_bike).to respond_to(:work...
true
c2cc0374afcae7e091df4886705c29dc0a5000d1
Ruby
elebecca/Battle
/spec/oystercard_spec.rb
UTF-8
3,432
3.171875
3
[]
no_license
describe Oystercard do let(:entry_station) { double :station } let(:exit_station) { double :station } let(:journey){ {a: entry_station, b: exit_station} } describe '#initialize' do it 'defaults balance to 0' do expect(subject.balance).to eq 0 end it '#journeys to nil' do expect(subject....
true
c9d62a6d13dfa1b04634964be8f77b9d18ad99a2
Ruby
aadlani/nanoc-toolbox
/lib/nanoc/toolbox/helpers/html_tag.rb
UTF-8
1,635
2.90625
3
[ "MIT" ]
permissive
module Nanoc::Toolbox::Helpers # NANOC Helper for HTML Tags # # This module contains functions for generating simple tags with attribute # # @author Anouar ADLANI <anouar@adlani.com> module HtmlTag # Simple tag # # @param [String] name the tag name # @param [Hash] options options to set to ...
true
2ec690b424f753b903628036811c1755580a7a73
Ruby
jeremiahlukus/ruby-stuff
/ruby_algorithms/prime_factorization.rb
UTF-8
149
3.09375
3
[]
no_license
require 'prime' def prime_factorization(n) Prime.prime_division(n).flat_map { |factor, power| [factor] * power } end p prime_factorization(12)
true
f47591d8df87a5fa7eb278dd3275c7ee8742ae26
Ruby
Serabe/bank_scrap
/lib/bank_scrap/banks/ing.rb
UTF-8
6,444
2.578125
3
[ "MIT" ]
permissive
require 'json' require 'base64' require 'RMagick' require 'tempfile' module BankScrap class Ing < Bank BASE_ENDPOINT = 'https://ing.ingdirect.es/' LOGIN_ENDPOINT = BASE_ENDPOINT + 'genoma_login/rest/session' POST_AUTH_ENDPOINT = BASE_ENDPOINT + 'genoma_api/login/auth/response' CLIENT_ENDPOINT ...
true
d052844ced288618a617f3e2fefb275c15656f9e
Ruby
Keisuke-Awa/algorithm
/atcoder/abc311/c.rb
UTF-8
391
2.890625
3
[]
no_license
n = gets.to_i graph = gets.split.map(&:to_i) result = [] counter = Array.new(n, 0) next_point = graph[0] while true do result << next_point candidate = graph[next_point - 1] if counter[candidate - 1] == 1 result = result[result.index(candidate)..-1] break else next_point = candidate counter[c...
true
f9d313c6fe24405e94280a8414bcc6c02645bee5
Ruby
stanvandepoll/RB101
/small_problems/easy_5/8.rb
UTF-8
315
3.171875
3
[]
no_license
NUMBER_WORDS = %w(zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen) def alphabetic_number_sort(numbers) numbers.sort do |a, b| NUMBER_WORDS[a] <=> NUMBER_WORDS[b] end end
true
45413858fc9295f1eb0d507f46a058c063aa61b9
Ruby
irmiller22/Exercises
/factorial/factorial.rb
UTF-8
77
3.078125
3
[]
no_license
def factorial(num) if num <= 1 1 else num * factorial(num-1) end end
true
c47c2e4c894d94ab0d5ec7d0a6702a02fef19066
Ruby
sasalatart/acid-auth-ws2
/app/models/user.rb
UTF-8
690
2.609375
3
[]
no_license
# == Schema Information # # Table name: users # # id :integer not null, primary key # email :string # image :text # created_at :datetime not null # updated_at :datetime not null # class User < ApplicationRecord before_validation :downcase_email VALID_EMAIL_REGEX = /...
true
7a317a7379c0e314060626252dca62c84a1c0195
Ruby
jhogrefe/2015-02-10-erb-intro
/main.rb
UTF-8
334
2.625
3
[]
no_license
require 'sinatra' get "/greeting" do @name = "Jason" #find the ERB file in views/welcome.erb and return it. erb :welcome, :layout => :boilerplate end # get "/greeting" do # @name = "Jason" # "Welcome to my website #{@name}, you are great!" # end # # get "/goodbye" do # "Thank you for visiting my w...
true
d1f4e34c198b343c48a2e8c78a46fd9e97b10bb6
Ruby
Ororophoenix/phase-0
/week-9/ruby/ruby-review.rb
UTF-8
590
4.15625
4
[ "MIT" ]
permissive
# I worked on this challenge by myself # This challenge took me 3 hours. # Pseudocode =begin create method that only takes a string IF there is no string return a empty string ELSE reverse each word in the sentence =end # Initial Solution def reverse_words(string) string_parts = string.split if string_p...
true
9db2a636ec0d209250da107dcfc891e437eed5e5
Ruby
jtp184/inkblot
/lib/inkblot/components/qr_code.rb
UTF-8
1,186
2.6875
3
[]
no_license
require 'rqrcode' require 'barby/barcode/qr_code' require 'barby/outputter/png_outputter' module Inkblot module Components # Render and display QR Codes class QrCode < Component # Sugar method for the encoded message def message options[:message] end private # Sets the...
true
da791e5bcf88dad2bfb117ddf1661b4ce256c864
Ruby
leviwilson/mohawk
/features/step_definitions/table_steps.rb
UTF-8
3,214
2.84375
3
[ "MIT" ]
permissive
When /^we are observing the people table$/ do on(MainScreen).data_entry_form_button on(DataEntryForm).should be_active end Then /^the table row information should look like the following:$/ do |row_items| row_items = row_items.map_column("row") { |r| r.to_i } row_items = row_items.map_headers("text" => ...
true
c6f5125b9fa7bc5ba07b5588a145d7e558954f1b
Ruby
GoodGuyGregory/Ruby
/ruby_loops/for_loop.rb
UTF-8
1,117
4.875
5
[]
no_license
# for loops are iterators in Ruby lang #they have a fairly humours range specification with a starting point # it creates an array style structure and iterates them for item in 1..10 do puts "The current item is #{item}." end puts "=====================" # using a for loop with an array structure for item in ["Pro...
true
6731b0ba4af06146c7e46a6dfd84668307c5bc80
Ruby
JEG2/advent_of_code_2015
/day_11/password.rb
UTF-8
711
3.40625
3
[]
no_license
#!/usr/bin/env ruby -w class Password def initialize(current) @current = current end attr_reader :current private :current def valid? has_straight? && not_confusing? && has_pairs? end def next loop do @current = @current.succ break if valid? end self end def to...
true
262dd87c815dc2ea13fbc9862f9700f76f5e0b2a
Ruby
ambtus/bipolar_type_old
/config/initializers/symbol.rb
UTF-8
996
3.75
4
[ "MIT" ]
permissive
# Restart required even in development mode when you modify this file. class Symbol # create a new class instance from a symbol # e.g. symbol.to_klass_name => KlassName.new(sym) def method_missing(method, *args, &block) if %w{to_str to_ary to_int}.include?(method.to_s) # don't override super ...
true
9316bd091791867bffa1df34f6620ffd38ab0de8
Ruby
ngeballe/ls-130-lesson2
/names.rb
UTF-8
214
2.578125
3
[]
no_license
names = ["John Wayne", "Wayne Wayne", "Wayne John", "John John", "Roland Wilson", "John"] p names.select { |name| name =~ /(John|Wayne) [^\1]/ } #== ["John Wayne", "Wayne John"] perms = %w(John Wayne).permutation(2).to_a p perms regex = Rege
true
5894142f1b20939a0b41b1a5d748641c339fc547
Ruby
nayaya/Quest01
/ex02/my_add.rb
UTF-8
174
3.75
4
[]
no_license
# A function that accepts two int params and retuirn their sum def my_add(nbr1, nbr2) return nbr1 + nbr2 end # Display of the Sum by callig the function puts my_add(2, 3)
true
e21292020a582a481c47b23113ddfa4318cef6df
Ruby
JumpStartGeorgia/Land-Registry
/scripts/scraper.rb
UTF-8
2,145
2.859375
3
[]
no_license
#!/usr/bin/env ruby APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require APP_PATH # set Rails.env here if desired Rails.application.require_environment! require 'typhoeus' require 'nokogiri' require 'fileutils' @data_path = "../data/" @lo...
true
cbaf8c2dad87466360bdf75b6c609711a7474fc9
Ruby
Atul9/rubylearning56
/4_week/5e_dir_inventory.rb
UTF-8
1,444
3.9375
4
[]
no_license
=begin Exercise5. Difficulty level: MEDIUM Write a one-line Ruby script that displays on the screen all the files in the current folder as well as everything in all its sub folders, in sorted order. Make use of Dir.glob method as follows: Dir.glob('**/*') Name this program inventory.rb. Create an inventory file by typ...
true
b53f6495a244c1d067edb550033375c2ad9da704
Ruby
kkcook/ls_ruby_old
/lesson_4/fruit_selector.rb
UTF-8
588
3.3125
3
[]
no_license
produce = { 'apple' => 'Fruit', 'carrot' => 'Vegetable', 'pear' => 'Fruit', 'broccoli' => 'Vegetable' } def select_fruit(produce) fruit_hsh = {} key_array = produce.keys counter = 0 loop do break if counter == key_array.size current_key = key_array[counter] ...
true
46a8a963185774c68cf6d34b0f497a12205e4465
Ruby
mhenrixon/dialers
/lib/dialers/short_circuit.rb
UTF-8
319
2.828125
3
[ "MIT" ]
permissive
module Dialers class ShortCircuit def initialize(condition, action) self.condition = condition self.action = action end def can_stop?(response) condition.call(response) end def stop(response) action.call(response) end attr_accessor :condition, :action end end
true
a3aefc0a6278dba3b44e2196357a9d52e5db3f2e
Ruby
anthonycarlos/jarvis
/jarvis/services/base_service.rb
UTF-8
815
3.109375
3
[]
no_license
module Jarvis module Services class BaseService require 'httparty' include HTTParty attr_accessor :text def initialize(text="") # Should give the service the params["text"] sent with the request to Jarvis, so the service can # implement more specific behaviors based on wha...
true
38a464ee4b4e5a24ad3702718e1e62c1c03e0b03
Ruby
tpickett66/Project-Euler-Solutions
/bin/301-350/p341
UTF-8
569
3.140625
3
[]
no_license
#!/usr/bin/env ruby # encoding: UTF-8 $:.unshift(File.dirname(__FILE__) + '/../../lib') unless $:.include?(File.dirname(__FILE__) + '/../../lib') # The Golomb's self-describing sequence {G(n)} is the only nondecreasing sequence of natural numbers such that n appears exactly G(n) times in the sequence. The values of G(...
true
fb2f0f29091b578bc512b7e44daf47219d3ef9b6
Ruby
waldowred5/Sith-Lord-Jedi-Ewok
/src/sith_jedi_ewok/lib/models/game.rb
UTF-8
718
3.296875
3
[ "MIT" ]
permissive
require 'yaml' class Game @games = YAML.load(File.read("lib/games.yml")) rescue [] class << self def map @games.map { |game_ary| yield game_ary } end def next_id @games.length + 1 end def save(game) game.id = next_id ...
true
5b6bcdc767297178cc41b2654884ab8ef0ccf30a
Ruby
arthurjacobklein/git_ruby
/autres exos/exo_08.rb
UTF-8
102
2.640625
3
[]
no_license
puts "Bonjour, comment tu t'appeles ?" user_name = gets.chomp + ", merci à toi" + "!" puts user_name
true
6998c985a377ec8f8888ee6fa4fcb0f5b7367ab5
Ruby
afurmanov/tagged_logger
/examples/simplest_usage.rb
UTF-8
439
2.640625
3
[ "MIT" ]
permissive
require File.join(File.dirname(__FILE__), '/examples_helper') puts "\n<<<#{File.basename(__FILE__, ".rb")}>>> \n".upcase TaggedLogger.rules do info /.*/, :to => Logger.new(STDOUT) end class A def foo logger.warn "WARNING message" #will be printed since treshold is set to 'info' end logger.debug "DEBUG me...
true
f64450a191715e0cd49ca00e14c714417d1ca312
Ruby
ryosuke/DSA.rb
/dsa_example.rb
UTF-8
330
2.671875
3
[]
no_license
#!/usr/bin/env ruby # # dsa_example.rb # require "./dsa" dsa = DSA.new(ARGV[0]) cve = dsa.getReferences().scan(/CVE-[0-9]+-[0-9]+/) print "Announce: #{dsa.getDate()}\n" print "URL: #{dsa.getURL()}\n" print "Reference:\n" cve.each do |c| print " * #{c}\n" end print "Details: \n \{\{\{\n #{dsa.getInformation()}\n ...
true
06671a19ac0973d16b4436104a25d17ab234a571
Ruby
MITLibraries/archivesspace_export_service
/exporter_app/tasks/repository_merge_task.rb
UTF-8
2,443
2.59375
3
[]
no_license
require 'fileutils' require 'tmpdir' require 'erb' require_relative 'task_interface' class RepositoryMergeTask < TaskInterface def initialize(task_params, job_identifier, workspace_base) @job_identifier = job_identifier @workspace_directory = workspace_base @jobs_to_merge = task_params.fetch(:jobs_to_me...
true
8e4e19c286e32fc05cb9930c55f47690e674a2b3
Ruby
runeb/adventofcode2017
/2.rb
UTF-8
1,040
3.828125
4
[]
no_license
# https://adventofcode.com/2017/day/2 require "minitest/autorun" def checksum(rows) rows.each_line.inject(0) do |mem, row| numbers = row.split.map(&:to_i) mem += numbers.max - numbers.min mem end end def evensums(rows) rows.each_line.inject(0) do |mem, row| numbers = row.s...
true
58d5c390adf7e8a886f1f4c9c38f1300c5f1fafd
Ruby
rico2114/Ruby-Online-Game
/Server/src/world/region/Region.rb
UTF-8
265
3.078125
3
[]
no_license
require_relative "../../player/Player" class Region def initialize(regionId) @id = regionId @players = [] end def addPlayer(player) @players.push(player) end def removePlayer(player) @players.delete(player) end def players() @players end end
true
a232147fc0b5dc83ce6b187a38c31fa71245712e
Ruby
bharatagarwal/launch-school
/100_back-end_prep/intro-to-programming/1_basics/2.rb
UTF-8
230
3.71875
4
[]
no_license
# take a 4 digit number and find the digit in the 1000s, 100s, 10s and 1s. digit = 2399 thousands = digit/1000 hundreds = (digit%1000)/100 tens = (digit%100)/10 ones = digit%10 puts thousands puts hundreds puts tens puts ones
true
cee6bbf872293e540e07ae5f151937edaa65c26b
Ruby
c17ep/final_project
/models/moods.rb
UTF-8
401
2.90625
3
[]
no_license
class Moods attr_accessor :moods def initialize @moods = ["angry", "heartbreak-depressing", "heartbreak-feel good", "happy", "frustrated/agitated", "hyper/pumped", "inspired/motivated", "abandoned", "aggressive", "anxious", "ashamed", "conflicted", "sentimental", "jealous", "impulsive", "sassy", "victorious", "...
true
15b346a1a5e09238c97ac1972c713ab5a2a72645
Ruby
Rebeliosman/RubyProjectRep
/Expens_tracker/expenses_writer.rb
UTF-8
1,642
3.359375
3
[]
no_license
require "rexml/document" # парсер xml require "date" # даты puts "What did you spend money on?" expense_text = STDIN.gets.chomp puts "How much did you spend?" expense_amount = STDIN.gets.chomp.to_i puts "The date of spending in the DD.MM.YYYY format (empty field - today)?" date_input = STDIN.gets.chomp # If про пус...
true
23b93a561f078cb683468d16ee653837107e37c6
Ruby
kctrlv/black_thursday
/test/customer_repository_test.rb
UTF-8
2,732
2.75
3
[]
no_license
require './test/test_helper' require './lib/customer_repository' require 'csv' class CustomerRepositoryTest < Minitest::Test attr_reader :cr def setup fixture = CSV.open('./test/fixtures/customers_fixture.csv', headers: true, header_converters: :symbol) ...
true
5109dcec02f91a979d582949bb9e2261da53bbe1
Ruby
SkifUA/categories
/db/seeds.rb
UTF-8
955
3
3
[]
no_license
def run_seed(categories, parent_name) brands = ['Reebok', 'Adidas', 'Nike'] parent = Category.create(name: parent_name) categories.each do |key, value| category = Category.create(name: key, parent_id: parent.id) puts category value.each do |name| cat = Category.create(name: "#{category.name} #{...
true
f1358b708f6e83635474d8f2f592803674a11a25
Ruby
samvera-labs/hydra-grouper
/lib/hydra/grouper/institution_function_set.rb
UTF-8
653
2.828125
3
[ "Apache-2.0" ]
permissive
module Hydra module Grouper # A container object that exposes convenience methods related to the underlying institution_functions set. # # For a given InstitutionFunctionSet we can ask "are you an admin?" class InstitutionFunctionSet def initialize(institution_functions: []) @institution...
true
d6402bce7efcaa83c3bd1b3d3d2874a35555e546
Ruby
LogicalBricks/prev
/app/support/date_range.rb
UTF-8
2,836
4.0625
4
[]
no_license
# Public: Utility class to generate and validate a range of dates. It receives # an initial and final date or just a year. If two values are provided, they # will be used as initial and final date. If just one value is provided, it # will be used as year. The initial and final dates should be kind of `Date` or # respon...
true
984afc05296d3d895e03f2bc14ab5f0fa1269cbd
Ruby
anddon/mpd_client
/examples/stickers.rb
UTF-8
1,425
2.703125
3
[ "MIT" ]
permissive
require 'bundler' Bundler.setup :default require 'logger' require 'mpd_client' MPDClient.log = Logger.new($stderr) # Stickers # http://www.musicpd.org/doc/protocol/ch03s07.html client = MPDClient.new # Connecting to the server client.connect('/run/mpd/socket') puts "MPD version: #{client.mpd_version}" puts "mpd_c...
true
2d9e36723b24a99fffef03d4894c8a7ea1f4e1b4
Ruby
Antaresgames/gamemachine
/server/spec/java_grid_spec.rb
UTF-8
2,356
2.84375
3
[ "Apache-2.0" ]
permissive
require 'spec_helper' module GameMachine describe JavaLib::Grid do subject do JavaLib::Grid.new(100,25) end describe "#set" do it "returns true when value is set" do expect(subject.set('blah',0,0,0,'player')).to be_truthy end it "creates a grid point in correct cell...
true
dbbd8093178cf7b59b0766cc15b2ae5e1436909c
Ruby
5v3n/rock_paper_scissors
/app/tournament.rb
UTF-8
968
3.484375
3
[]
no_license
require_relative '../lib/rock_paper_scissors' require_relative '../lib/player' require_relative '../lib/logic' require_relative '../lib/strategy/constant' class RockPaperScissors::Tournament def self.play # Spieler A) wählt immer Papier # Spieler B) trifft zufällige Wahl player_a = RockPaperScissors::Player....
true
78659173435ea046937bfbadbe28ad0f34e430aa
Ruby
duckinator/name_generator
/exe/name_generator
UTF-8
1,011
3.328125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require "name_generator" DEFAULTS = { "min_length" => 5, "max_length" => 10, "debug" => false, "num_words" => 1, } def parse_args(args) arguments = DEFAULTS.clone args.each do |arg| key, value = arg.split('=', 2) # You can technically do `name_generator min-length=5` and it'l...
true
e0f64c5b7cabab429ee5bc8da249d6015a30c134
Ruby
BlueMorning/MusicStore_app_with_Ruby_Sinatra_plsql
/application/controllers/artists_controller.rb
UTF-8
1,800
2.5625
3
[]
no_license
require( 'sinatra' ) require( 'sinatra/contrib/all' ) require( 'pry-byebug' ) require_relative('./../models/artist') require_relative('./../helper/navigation') # Display the list of artist get NavArtists::GET_INDEX do @filters = {} @filters["art_name"] = "" @artists = Artist.find_all() ...
true
d432e8107bf66331e1fe66b541cfb8529762a626
Ruby
francescobbo/jwk
/lib/jwk/ec_key.rb
UTF-8
2,963
2.90625
3
[ "MIT" ]
permissive
require 'jwk/key' module JWK class ECKey < Key CURVE_NAMES = { 'prime256v1' => 'P-256', 'secp384r1' => 'P-384', 'secp521r1' => 'P-521' }.freeze COORD_SIZE = { 'P-256' => 32, 'P-384' => 48, 'P-521' => 64 }.freeze def initialize(key) @key = key vali...
true
659ec901591e855dd0b6539b2ebdd7b935691354
Ruby
restc/BlackJackDoubles
/lib/blackjack_doubles/Notifier.rb
UTF-8
232
3.1875
3
[]
no_license
module BlackjackDoubles class Notifier def update(hand, points) case when points > 21 puts "Your hand busted with a score of #{hand.points}!" else puts "Good job" end end end end
true
25441a4694456dfb142cf12375394e8d9d33c21f
Ruby
stevenspasbo/dotfiles
/Rakefile
UTF-8
2,295
2.640625
3
[]
no_license
#------------------------------------------------------------- # Author: Steven Spasbo #------------------------------------------------------------- #------------------------------------------------------------- # Constants #------------------------------------------------------------- HOME = ENV['HOME'] REPO = File....
true
cc0b94bce49f3741d2f05bdc7b46474c687687ba
Ruby
sungchoi/topics-in-cs
/functions/ruby/triangle.rb
UTF-8
339
3.359375
3
[]
no_license
module Triangle def triangle?(side_a, side_b, side_c) # The sum of the lengths of any two sides of a triangle always exceeds the length of the third side, a principle known as the triangle inequality sides = [side_a, side_b, side_c].sort! if sides[0] + sides[1] > sides[2] true else false ...
true
b3355e825d4f6f513b1d1916a540d1dbb1b75050
Ruby
paulodfreitas/ruby86
/sequential/Instructions/jmp.rb
UTF-8
639
2.671875
3
[]
no_license
class Jmp < Instruction def self.has_val true end def execute r r[:cc] = op return r end def pc_update r processor.pc = r[:cc] ? r[:vc] : r[:vp] end def op true end end class Jle < Jmp def op (processor.sf ^ processor.of) or processor.zf end end class Jne < Jmp def op ...
true
fd46118b75e974f720f0e5bc85adadf9970e32cb
Ruby
AlexBaranosky/EmailOMatic
/src/reminder/emailable_reminders.rb
UTF-8
1,124
3.203125
3
[]
no_license
require File.dirname(__FILE__) + '/../../src/reminder/email_history' require File.dirname(__FILE__) + '/../../src/email/reminder_email_creator' require File.dirname(__FILE__) + '/../../src/email/email_sender' #TODO: figure out how to unit test each feature of this object, and do it class EmailableReminders def initi...
true
1837abe857715bcd9ffffd0aa814f0d5f85982e2
Ruby
karlverdiere/semaine2mardi
/multilple.rb
UTF-8
188
3.421875
3
[]
no_license
def villani i = 0 sum = 0 while i < 1000 if (i % 3 == 0) || (i % 5 == 0) sum = sum + i end i += 1 end return sum end puts villani
true
b97328ee18e2be5152a1758bb80b1e38eefec8f9
Ruby
jhbadger/scripts
/gosTaxPies
UTF-8
2,249
2.65625
3
[]
no_license
#!/usr/bin/env ruby require 'optparse' require 'ostruct' require 'sqlite3' require 'GOS' require 'csv' opt = OpenStruct.new o = OptionParser.new opt.filters = 3 opt.rank = "kingdom" #ARGV.push("/Users/jbadger/clusters/sanger_io.db") o.banner << " sqlite.db" begin o.on("-f ", "--filters ", Integer, "minimum filter...
true
981379aee7f476c6c51ef8a1da699fcb3782bff0
Ruby
trexnix/receipt-calculator
/lib/receipt-calculator/product.rb
UTF-8
135
3.203125
3
[ "MIT" ]
permissive
class Product attr_accessor :name, :price def initialize(name: nil, price: nil) @name = name @price = price.to_f end end
true
19215b988086f371495cd73b170b828208071c4f
Ruby
gatherdigital/endpoint
/lib/endpoint/soap/fault.rb
UTF-8
1,835
2.640625
3
[ "MIT" ]
permissive
module Endpoint module Soap class Fault < StandardError class AbstractBuilder def build(response) fault_node = response.at_css('Fault') if fault_node code = extract_code fault_node rescue nil reason = extract_reason fault_node rescue nil end ...
true
5d7f77e36d5b1595735e53f55d1f492db4e2ecd8
Ruby
AdrianadelV/lab-webdesktop-portalejecutivo
/WebDesktopV1/app/models/ensambladora_vehiculos.rb
UTF-8
4,147
2.515625
3
[]
no_license
class Ensambladora_vehiculos < ActiveRecord::Base #Adriana Santana -->Sino quieren ver una trigra con tigritos recien nacidos por favor no borren esto def grabar_ensambladora(rif,nombre,correo,telefono,ciudad,direccion,marca,nombre_usuario) @usuario = Usuario.find(:first, :conditions => "nombre='#{nombre_usuari...
true
03bae5c10f7c7fe69fe88f576f9fc818f74aaae3
Ruby
amyjording/rest-client-session
/rest_client.rb
UTF-8
661
3.140625
3
[]
no_license
require 'rest-client' puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~".center(70) puts " Rest Client Search Service ".center(70) puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~".center(70) puts printf "What would you like to search? : " input = gets.chomp # formating the search query so it matches the parameters for google i...
true
7373d82a4d89426953bef4dbfc6850c41b531db1
Ruby
mishitoshi/at-coder
/ABC170/B-CraneAndTurtle.rb
UTF-8
114
3.15625
3
[]
no_license
X, Y = gets.split(' ').map(&:to_i) ans = 'No' (0..X).each { |x| 2*x + 4*(X-x) == Y ? ans = 'Yes' : next } puts ans
true
1d09e7190c95be2fa235535d25b08df1a32fee5e
Ruby
johncruickshank/cc_cinema
/db/seeds.rb
UTF-8
4,006
2.734375
3
[]
no_license
require_relative("../models/customers") require_relative("../models/films") require_relative("../models/tickets") require_relative("../models/screenings") require("pry-byebug") Ticket.delete_all() Screening.delete_all() Film.delete_all() Customer.delete_all() customer1 = Customer.new({'name' => 'John', 'funds' => 150...
true
e16611cd391db3ed34eba3df34c2699359b83846
Ruby
nasa-itc/gsw-cosmos
/config/targets/SIM_42_TRUTH/lib/nadir_in_body.rb
UTF-8
670
2.546875
3
[]
no_license
require 'openc3/conversions/conversion' module OpenC3 class NadirInBody < Conversion def initialize(*args) super() @items = args @converted_type = :FLOAT @converted_bit_size = 64 @converted_array_size = 3 end def call(value, packet, buffer) p = [packet.read(@items[0...
true
3835f09e6699275b33a42442efb808ce3b59724f
Ruby
abadi230/cli-applications-guessing-game-london-web-080519
/guessing_game_cli.rb
UTF-8
391
3.75
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" def run_guessing_game roll = 1+rand(6) guess = "Guess a number betwen 1 and 6." right = "You guessed the correct number!" wrong = "Sorry! The computer guessed #{roll}." puts guess input = gets.chomp if input == "exit" puts "Goodbye!" elsif input.to_i == roll ...
true
0d6f943c34b3c1678ae11404b7866f125f0806a9
Ruby
Ripster47/params_game_app
/app/controllers/api/games_controller.rb
UTF-8
1,037
2.578125
3
[]
no_license
class Api::GamesController < ApplicationController def name_game @entry = params[:name] if @entry.upcase[0] == "A" @message = "Hey, your name starts with the first letter of the alphabet!" end render 'name_game.json.jbuilder' end def guess_the_number @guess = params[:guess].to_i ...
true
9a493a56318043957abe220bac967fe3989cb130
Ruby
alpardal/factory_lite
/lib/factory_lite/container.rb
UTF-8
917
2.5625
3
[ "MIT" ]
permissive
module FactoryLite class Container attr_reader :config def initialize(config) @config = config @factories = {} end def register_factory(factory_name, attrs_key: factory_name, &block) @factories[factory_name] = Instance.new(attrs_key, config: config) instance_exec(@factories[f...
true
04c6cc44fbfd1910a7f37beb815c82c75ee248fb
Ruby
xLeachimx/GCBRR
/lib/generic_case.rb
UTF-8
1,634
3.3125
3
[ "MIT" ]
permissive
class GenCase attr_reader :designation attr_reader :attributes # Precond: # None # Postcond: # creates a new GenCase with the specfied designation def initialize designation @designation = designation end # Precond: # attrName is the name of the attribute(either string or symbol) # attrValues is an array...
true
498f00a3860b3d5b6532163b991bebdd24f75cc8
Ruby
fanomallot/dadax
/exo11.rb
UTF-8
114
3.265625
3
[]
no_license
puts "entrer le nombre de votre choix" print">" nombre = gets.to_i for i in 1..nombre puts"Salut,ça farte?" end
true
3ec7623637f94ed189019187455055b54a8d16b4
Ruby
f3mshep/ruby-objects-has-many-lab-v-000
/lib/post.rb
UTF-8
322
3.609375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Post attr_accessor :title, :has_parent def initialize(title) @title = title self.has_parent = false end def author=(name) self.has_parent = true @author = name end def author @author end def author_name if has_parent == true return self.author.name else return nil end end en...
true
db1570fb94bc48464712cf1eb269e10a48ae9c34
Ruby
Yash-YC/Source-Code-Plagiarism-Detection
/gcj/gcj/188266/rafaelkin/168107/0/extracted/base.rb
UTF-8
769
2.875
3
[]
no_license
file = File.open("A-small-attempt0.in") t = file.readline.to_i @cycle = [] def calculate(number, base) base_number = number.to_s(base).split(//).map(&:to_i) sum = 0 base_number.each do |value| sum += value*value end #puts "number: #{number}, base_number: #{base_number}, sum: #{sum}" #sleep 1 return...
true
da4323d2035f534d93d5973712eb57e10bd704f6
Ruby
sonu2016-stack/Ruby_On_Rails_Practice_Question
/hashes.rb
UTF-8
161
2.796875
3
[]
no_license
data = {"Akash" => "Physics", "Ankit" => "Chemistry", "Aman" => "Maths","Akash" => "Physi"} puts data["Akash"] puts data["Ankit"] puts data["Aman"]
true
1e837b8962c6f7511e8ce30fc6cdef777bcf5864
Ruby
jduan/json_parser
/spec/json_parser/parser_spec.rb
UTF-8
2,134
2.953125
3
[ "MIT" ]
permissive
require "spec_helper" module JsonParser describe Parser do #it "#parse_string should return a quoted string" do # str = %Q{{"name": [1, "hello"]}} # Parser.new.parse(str).should == {"name" => [1, "hello"]} #end it "should be able to parse a single true value" do Parser.new.parse("true")....
true
fb56227905fa1f0019a6bafd659b547a8f3eca81
Ruby
bePericon/eis
/batalla_naval/spec/tablero_spec.rb
UTF-8
371
2.5625
3
[]
no_license
require 'rspec' require_relative '../model/tablero' require_relative '../model/barco' describe 'Tablero' do let(:tablero) { Tablero.new(10,10)} it 'Creacion del tablero de 10x10' do expect(tablero.medidas).to eq [10,10] end it 'devolucion de indice de letra, empezando la numeracion de 1..n' do expe...
true
1027ba412f8325bc5348a73ea1a1939d24d948aa
Ruby
nemuzuka/yoita
/app/models/resource.rb
UTF-8
3,557
2.515625
3
[]
no_license
# encoding: utf-8 require "model" # # resourcesテーブルのmodel # class Resource < ActiveRecord::Base attr_accessible :entry_resource_id, :lock_version, :memo, :name, :resource_type, :sort_num, :update_resource_id # validates validates :resource_type, :length => { :is => 3 } validates :name, :length => { :maximum ...
true
4495cf373ec1f44236faa7fe7da958bf73ff1cbb
Ruby
addriv/aa-homeworks
/W1D5/w1d5_hw.rb
UTF-8
810
3.21875
3
[]
no_license
class Stack attr_accessor :ivar def initialize @ivar = [] end def add(el) ivar.push(el) end def remove ivar.pop end def show ivar.dup end end class Queue attr_accessor :ivar def initialize @ivar = [] end def enqueue(el) ivar.unshift(el) end def dequeue i...
true
77172b62258faad602c7784da117e49cd4295e70
Ruby
kenliu/mojipoints
/app/controllers/auth_controller.rb
UTF-8
2,509
2.671875
3
[ "MIT", "CC-BY-3.0" ]
permissive
# code is heavily borrowed from https://github.com/slackapi/Slack-Ruby-Onboarding-Tutorial/blob/master/auth.rb class AuthController < ApplicationController BOT_SCOPE = 'bot' SLACK_CONFIG = { slack_client_id: ENV['SLACK_CLIENT_ID'], slack_api_secret: ENV['SLACK_API_SECRET'], slack_redirect_uri: ENV['SL...
true
814b63afef421ec4a9ad3e656bc23d3671cbd5a4
Ruby
gunterja/jg-ttsdal-ecommerce
/test/integration/user_stories_test.rb
UTF-8
3,584
2.640625
3
[]
no_license
require 'test_helper' class UserStoriesTest < ActionDispatch::IntegrationTest fixtures :products # User goes to index page. Selects a product, additing to their cart. # They then check out, filling in details on the checkout form. An order # is created with that info, plus a single line item with their #...
true
f42eace42b0ca4b1e92ad750903265076fdc96e3
Ruby
PeterWong327/aA-homeworks
/W2D4/big_octopus.rb
UTF-8
1,658
3.765625
4
[]
no_license
#Sluggish Octopus: O(n^2) time def longest_fish(fishes) fishes.each_with_index do |fish1, i1| longest = true fishes.each_with_index do |fish2, i2| next if i1 == i2 longest = false if fish2.length > fish1.length end return fish1 if longest end end #Dominant Octopus: O(n log n) time c...
true
cc25cd5a5cda814513cec7bc7d3a288a545f5384
Ruby
tjinjin/til
/programing/poodr/ch3/gear7.rb
UTF-8
757
3.609375
4
[]
no_license
class Gear attr_reader :chainring, :cog, :wheel # デフォルト値を決めとく def initialize(args) # false, nilが来たときにデフォルト値を設定する @chainring = args[:chainring] || 40 @cog = args[:cog] || 18 @wheel = args[:wheel] end def gear_inches # 恐ろしい計算 ratio * diameter # 恐ろしい計算 end def diameter...
true
c2267dcd17936fbd5bc8dfd50ae3663c4064e0cb
Ruby
darkn3rd/oop-tut
/ruby/f01.immutable/demo.rb
UTF-8
228
2.515625
3
[]
no_license
#!/usr/bin/ruby require 'Person' # include Person.rb # instantiate three Person objects on the heap captain = Person.new "Jean-Luc", 48382 officer = Person.new "Data", 38923 ensign = Person.new "Wesley", 48234
true
0fadcf93732642b382c47f60731090099affe232
Ruby
philanderson888/ruby
/ruby_13_function.rb
UTF-8
285
3.53125
4
[]
no_license
# declare the function def do_this puts "doing something from inside a function" end # call the function do_this def return_something return 1 end def return_nothing end puts "\n\nThis should return 1" puts return_something puts "\n\nThis should return nil" puts return_nothing
true
f6e48f0beeeccdadd66b74b8bcde35a31328dbc2
Ruby
lukeredpath/marley
/app/marley/archive.rb
UTF-8
270
2.859375
3
[ "MIT" ]
permissive
module Marley class Archive def initialize(posts) @posts = posts end def posts_indexed_by_month_and_year @posts.inject({}) do |index, post| (index[post.month_and_year] ||= []) << post index end end end end
true
849995854c5a94e12c63bae40ba2abe8ab621403
Ruby
wideopenspaces/madhattr
/lib/madhattr/hattr_accessor.rb
UTF-8
1,197
2.828125
3
[ "MIT" ]
permissive
module HattrAccessor def hattr_reader(source, *keys) ensure_readable source define_readers(source, keys) end alias_method :hattr_readers, :hattr_reader def hattr_reader_with_default(source, *keys_with_defaults) ensure_readable source define_readers_with_defaults(source, keys_with_defaults) en...
true
a63d00835c2ce4507996befad19a1b4b184f400c
Ruby
squeemishly/battleship
/lib/create_computer_ship.rb
UTF-8
1,504
3.609375
4
[]
no_license
require './lib/ocean' require 'pry' class CreateComputerShip def initialize(ship_size) @ship_size = ship_size @ocean = Ocean.new @ocean.startup @ship_range = [] @ship = nil end def random_start @num = (1..@ocean.size).to_a.sample @char = (65..(64 + @ocean.size)).to_a.sample resul...
true
7001a83027b25c7f6a6613ae86617566380efba7
Ruby
theaboutbox/migrant
/lib/migrant/clouds/base.rb
UTF-8
3,451
2.703125
3
[]
no_license
require 'fog' module Migrant module Clouds # Base class for cloud service providers. # All service providers use Fog to handle bootstrapping servers and running stuff # Cloud service providers are responsible for starting up the server, setting up ssh # access with the provided keypair, and (even...
true
50638ce5a92cab08bb785914b96caa0759e61ac1
Ruby
co2co2/solar_system
/solar_system.rb
UTF-8
937
3.578125
4
[]
no_license
class System def initialize @bodies = [] end def add(body) @bodies << body end def total_mass total = 0 @bodies.each {|b| total += b.mass} return total end end class Body < System def initialize (name, mass) @name = name @mass = mass end def name @name end def ...
true
dc0973ff45cd967a5bfdb8fa61c8e3f7b42fe765
Ruby
leannemcabey/cartoon-collections-prework
/cartoon_collections.rb
UTF-8
646
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def roll_call_dwarves(dwarves) dwarves.each_with_index do |dwarf, index| puts "#{index + 1}. #{dwarf}" end end def summon_captain_planet(planateer_calls) planateer_calls.collect do |call| call.capitalize! << "!" end planateer_calls end def long_planeteer_calls(calls) calls.any? do |call| call....
true
844f675a5b96f057a448d588aaf06fc5f71dbeca
Ruby
eirinikos/ruby-bites
/_reddit_dailyprogrammer.rb
UTF-8
3,830
3.84375
4
[]
no_license
# challenge #228 # https://www.reddit.com/r/dailyprogrammer/comments/3h9pde/20150817_challenge_228_easy_letters_in/ # write a program that determines if the letters in a word are in alphabetical order. # bonus: see if you can check words spelled in reverse alphabetical order. # `list`, a single string, is a list of w...
true
0fcfde5d12194a3bdff51423c30ffc6984ba87ac
Ruby
Machi427/ruby_scripting
/sample_scripts/lecture02/count-flock2.rb
UTF-8
749
2.984375
3
[]
no_license
#!/usr/bin/env ruby # -*- coding: utf-8 -*- # ロック処理を追加 (ロック時間短縮版) dbfile = "counter" lockfile = dbfile + ".lck" # ロックに使うダミーファイル require 'dbm' STDERR.print "いくつ足しますか: " x = STDIN.gets.to_i # 加算値を先に読み込んでおく open(lockfile, "w") do |lf| lf.flock(File::LOCK_EX) # ロック設定 STDERR.puts "#{dbfile} に対する...
true
39fe76b80a40f9387e060f4e3dab9312da5aefed
Ruby
nicoleticknor/math_game
/game.rb
UTF-8
838
3.890625
4
[]
no_license
require './questions.rb' class Game def ask_question(qs, num, player) puts "---------- NEW TURN ----------" if player == 1 print "Player 1: " else print "Player 2: " end qs.each do |q| if q[:id] == num puts q[:q] answer = q[:a] return answer end ...
true
fee528a65d3eb3c5e823ca5743c5ddaa1429f85b
Ruby
codeship/bitbucket
/lib/bitbucket_rest_api/api_factory.rb
UTF-8
746
2.59375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
# encoding: utf-8 require 'bitbucket_rest_api/core_ext/hash' module BitBucket class ApiFactory # Instantiates a new bitbucket api object def self.new(klass, options={}) return create_instance(klass, options) if klass raise ArgumentError, 'must provide klass to be instantiated' end # Pa...
true
a6ecb5256db4f9d9b0b166c8fe7aab324b44b8f2
Ruby
JoshCheek/connect4
/lib/connect4/ansi.rb
UTF-8
831
2.671875
3
[]
no_license
require 'connect4' module Connect4 module Ansi class Board < Connect4::Board def to_s off = "\e[0m" yellow = "\e[48;5;#{16+6*6*5}m" red = "\e[48;5;#{16+6*6*5+6*5}m" blue = "\e[48;5;#{16+5}m" black = "\e[48;5;16m" vsep = "#{blue} #{off}" hse...
true
a309cc030b89a8c1754b6b4135a44920196fddfb
Ruby
TuanNguyen1010/chitter-challenge
/app.rb
UTF-8
561
2.546875
3
[]
no_license
require 'sinatra' require './lib/peep_class' require './lib/user_class' class Chitter < Sinatra::Base get '/' do erb(:login) end post '/User/new' do current_user = User.create(email: params[:email], password: params[:password]) session[:email] = current_user.email[0] redirect '/homepage' end ...
true