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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ea130d7c5b0336d197633c84ad164e8650332fe5 | Ruby | adachan/whatever_you_say | /vendor/gems/googletranslate-0.2/tests/ts_translate.rb | UTF-8 | 1,415 | 2.609375 | 3 | [
"MIT"
] | permissive | $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
require 'test/unit'
require 'rtranslate'
class TranslateTest < Test::Unit::TestCase
include Language
def test_english_translate
assert_equal("مرحبا العالم", Translate.t("Hello world", ENGLISH, ARABIC));
assert_equal("你好世界", Translate.t("Hello... | true |
4c3dc950b4fd2b4f4b35c296e44b0635875fe4dc | Ruby | taw/etwng | /anim_sound_event/ase_pack | UTF-8 | 534 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
class File
def self.write(file_name, data)
File.open(file_name, 'wb'){|fh|
fh.write data
}
end
end
def load_txt(file_name)
eval(File.open(file_name, 'rb', &:read))
end
def save_ase(data, file_name)
bindata = [data.size].pack("V") + data.map{|sample|
[sample.size].pack("V... | true |
c3687365055a5ce2b8de76627aaf18aa86f0c3a8 | Ruby | janevent/best_islands | /lib/best_islands/scraper.rb | UTF-8 | 1,666 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'pry'
module BestIslands
class Scraper
def self.scrape_page
# html = open("https://www.islands.com/top-20-best-islands-to-live-on/")
# @doc = Nokogiri::HTML(html)
@@browser = CapybaraScraper::Browser.new.visit("https://www.islands.com/top-20-best-islands-to-live-on/")
@@browser.pa... | true |
433d2f9791a8e2e9b9d015da6fe78a0a46a37830 | Ruby | huwgoma/knights_travails | /graph.rb | UTF-8 | 1,300 | 3.78125 | 4 | [] | no_license | # Logic for all possible moves of a chess piece;
# given its current Cell position and its Type
module LegalMoveable
X = {
"Knight" => [2, 2, -2, -2, 1, -1, 1, -1]
}
Y = {
"Knight" => [1, -1, 1, -1, 2, 2, -2, -2]
}
def legal_moves(cell, piece)
x = X[piece.to_s]
y = Y[piece.to_s]
legal_mo... | true |
be8703abe71a1850e71fbf19d4d0a32d0a4281e6 | Ruby | rayning0/ctci | /google/crossword.rb | UTF-8 | 1,992 | 3.96875 | 4 | [] | no_license | # Given a nxn crossword puzzle and a word, return earliest [row, col] where you can fit that word. Fill in word right or down. Part of word may be filled in already. Length of space must exactly equal length of word.
# word = "tent"
# A _ # T _ N S # _ #
_ # T _ _ T # _ _ _ # col = [1, 2]
_ # _ _ # # # _ # _
_ # _ _ ... | true |
150b746b41ee9926d4fd9425f1b416c79ecb2c29 | Ruby | XCO-team/finder | /lib/finder/gem.rb | UTF-8 | 4,112 | 2.625 | 3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Finder
module Find
# RubyGems finder methods.
#
module Gem
include Base
#
# Search gems.
#
# @param [String] match
# The file glob to match.
#
# @param [Hash] options
# Search options.
#
# @option options [String] :from
#... | true |
9a8bfdcf0aba94b0d1ea088d4993d148daf43f12 | Ruby | cbpolley/rubyTest | /stock_picker.rb | UTF-8 | 960 | 3.9375 | 4 | [] | no_license | def stock_picker(number_array)
#declare variables.
max_profit = 0
index_day = 0
first_number = 0
#loop through the number_array, comparing the difference between all numbers until we find the highest difference (a.k.a. profit).
number_array.each_with_index do |valuemin, indexmin|
min = valuemin
numb... | true |
461030688ed9eb253a9a6463bea5273536714b72 | Ruby | jjulian/pitboss | /lib/pitboss/deck.rb | UTF-8 | 771 | 3.34375 | 3 | [] | no_license | module Pitboss
class Deck
def burn!
card!
# YOU GET NASSING, LEBOWSKI! NASSING!
false
end
def card!
@dealt ||= []
card = @cards.pop
@dealt.push(card)
card
end
def cards
@cards
end
def initialize
@cards = %w(C D H S).map do |suit|
... | true |
68eb51fc83ed1f993e59c326468f0643ae10ea32 | Ruby | alu0100885941/final_version_menu_dietetico | /spec/menu_alimentos_spec.rb | UTF-8 | 1,276 | 2.59375 | 3 | [
"MIT"
] | permissive | require "./lib/dieta/menu_alimentos.rb"
require "spec_helper.rb"
context "Menu de alimentos." do
before:all do
@desayuno = Menu_alimentos.new("Panes y cereales","Desayuno", [15, 20], [["Tostadas con aceite", "2 porciones", 80],["Café con leche", "1 taza", 100]], "150,75 KCal", [20,30,60])
... | true |
467cebf71f6c49003d7da16003aef98bffceb06e | Ruby | sreeix/fake_dynamo | /lib/fake_dynamo/key_schema.rb | UTF-8 | 587 | 2.6875 | 3 | [
"MIT"
] | permissive | module FakeDynamo
class KeySchema
attr_accessor :hash_key, :range_key
def initialize(data)
extract_values(data)
end
def description
description = { 'HashKeyElement' => hash_key.description }
if range_key
description['RangeKeyElement'] = range_key.description
end
... | true |
9010fa48931cf318b39e833938ca372dea8ff186 | Ruby | waasifkhaan/key-for-min-value-v-000 | /key_for_min.rb | UTF-8 | 370 | 3.609375 | 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)
key_1 = nil
value_1 = nil
name_hash.each do |key,value|
if key_1.nil?
key_1 = key
value_1 = value
elsif value < value_1
key_1 = ke... | true |
79b463bb8a93bd9cbf2fd863d6eb67f0733d085d | Ruby | agarun/homeworks | /classwork/W11D2/lib/p04_linked_list.rb | UTF-8 | 2,009 | 3.578125 | 4 | [] | no_license | class Node
attr_accessor :key, :val, :next, :prev
def initialize(key = nil, val = nil)
@key = key
@val = val
@next = nil
@prev = nil
end
def to_s
"#{@key}: #{@val}"
end
def remove
# optional but useful, connects previous node to next node
# and removes self from list.
# c... | true |
df26eadf2475168e34ac0866b02d5fc0553ae420 | Ruby | PhantasticHenry/family_fun | /lib/family_fun/scraper.rb | UTF-8 | 1,091 | 2.6875 | 3 | [
"MIT"
] | permissive | class FamilyFun::Scraper
def self.scrape_events
doc = Nokogiri::HTML(open("https://www.parentmap.com/calendar"))
events = doc.search("div.col-content")
events.each do |e|
event = FamilyFun::Event.new
event.name = e.search("h3.event-title").text.strip
even... | true |
02ad5ae2ec964f0dfdebf8a0394d9ec242249eac | Ruby | amireh/pibid | /lib/tasks/pibi/recurrings.rake | UTF-8 | 2,589 | 2.53125 | 3 | [
"MIT"
] | permissive | namespace :pibi do
namespace :recurrings do
desc "commits all applicable recurring transactions"
task :commit => :outstanding do
puts "Committing..."
nr_committed = 0
nr_outstanding = 0
Recurring.all.select { |rtx| rtx.active? }.each { |rtx|
occurrences = rtx.all_occurrences
... | true |
30041fbb5d62056ba0286316d87930f4287046bd | Ruby | apml/apml-library | /RoR/bitnik_apm/lib/automata_parser/graph.rb | UTF-8 | 3,060 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | module AutomataParser
module Constants
ANYTHING = '_AutomataParser_*_'
end
class GraphVertexWrapper
include AutomataParser::Constants
attr_accessor :name
def initialize(name,arcs)
@arcs = arcs
end
def with(label)
@arcs.each do |arc|
if(arc[label]!=nil)
r... | true |
486314bbd4280db10872a402e386c3a109911a2f | Ruby | JeffreyXieCn/sample_app | /test/models/comment_test.rb | UTF-8 | 887 | 2.515625 | 3 | [
"MIT",
"Beerware",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'test_helper'
class CommentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
@user = users(:michael)
@micropost = @user.microposts.first
@comment = @micropost.comments.build(content: "A value comment")
@comment.user = @user
end
test "should be v... | true |
7c3d2629b45a9501943c16d57e08ff91065ff339 | Ruby | PhilippePerret/Icare_AD_2018 | /_lib/_required/User/instance/statut.rb | UTF-8 | 2,498 | 2.53125 | 3 | [] | no_license | # encoding: UTF-8
=begin
Méthodes de statut pour l'utilisateur (courant ou autre)
=end
class User
# Pour admin?, super? et manitou?,
# cf. le fichier inst_options.rb
# Rappel : Seuls les bits de 0 à 15 peuvent être utilisés par
# le rest-site (la base). Les bits de 16 à 31 sont réservés à
# l'application ell... | true |
15dbdd7b12e4fc8f410828ce11c5d86638002458 | Ruby | crankapps/bookafy-rails | /test/bookafy/appointment_test.rb | UTF-8 | 8,251 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
module Bookafy
class AppointmentTest < ActiveSupport::TestCase
setup do
Bookafy.access_token = '12345678'
Bookafy.client_token = '12345678'
end
test 'should return appointments model instance' do
appointment_service = Bookafy::Appointment.new
service = Booka... | true |
40a46dc3c3c5be18d6326fc7922c75725bb4a2a2 | Ruby | dubey98/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 937 | 4.03125 | 4 | [] | no_license | #write your code here
def echo(input_str)
return input_str
end
def shout(input_str)
return input_str.upcase
end
def repeat(input_str , times=2)
output_str = ""
index = 1
while index <= times-1
output_str += input_str
output_str += " "
index+=1
end
output_str +=input... | true |
bcb97adfcbe9d30516b3969b464f9b5910eff012 | Ruby | changemewtf/grimoire | /lib/grimoire/noop.rb | UTF-8 | 180 | 2.765625 | 3 | [] | no_license | # This represents a "no-op", short for "no operation".
# It allows for a functional programming style in situations
# that would otherwise require a conditional.
NOOP = -> x { x }
| true |
737501ca092b90e2a1190ab94ea25677ff788be5 | Ruby | veereshyh/mp1 | /merge_arrays/merge_array.rb | UTF-8 | 423 | 3.46875 | 3 | [] | no_license | a=[]
b=[]
c=[]
puts "Input number of elements in first array"
m=gets.chomp.to_i
puts "Input#{m} integers"
for c in 0...m
a[c]=gets.chomp.to_i
end
puts "Input number of elements in second array"
n=gets.chomp.to_i
puts "Input #{n} integers"
for c in 0...n
b[c]=gets.chomp.to_i
... | true |
094b5d36cb88931e255715b0b53da1456f254500 | Ruby | diegodurs/roadtrip-planner | /lib/travel.rb | UTF-8 | 194 | 2.625 | 3 | [] | no_license | require_relative 'abstract_step'
class Travel < AbstractStep
def to_s
"Will travel for #{pluralize(nb_days, 'day')} to <strong>#{name}</strong>"
end
def travel?
true
end
end | true |
d48d69d96a57b1849d09b18ee86498fd9cf5e342 | Ruby | YouSysAdmin/ruby_string_color | /lib/string_color.rb | UTF-8 | 1,203 | 3.140625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'string_color/version'
class String
# Return White
def white; colorize(self, "\e[1;37m"); end
# Return red
def red; colorize(self, "\e[31m"); end
# Return Light Red
def light_red; colorize(self, "\e[1;31m"); end
# Return Green
def green; colorize(self, "\e[32... | true |
035d686a60e141c7933bdbcb10a1490ea7c743fc | Ruby | turnerking/cards | /spec/unit/war_spec.rb | UTF-8 | 473 | 2.515625 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'war/war'
describe War do
it "creates two players" do
w = War.new
w.players.size.should == 2
w.players.each {|player| player.should be_a Player}
w.deck.size.should == 52
w.deck.each {|card| card.should be_a Card }
end... | true |
0e3efe48c3cdae12a4762612f191a79ee0190b67 | Ruby | tlgakn/rb_101 | /small_problems/09_easy/00_grocery_list.rb | UTF-8 | 457 | 3.96875 | 4 | [] | no_license | =begin
Grocery List
Write a method which takes a grocery list (array) of fruits with quantities
and converts it into an array of the correct number of each fruit.
=end
def buy_fruit(nested_array)
new_array = []
nested_array.to_h.each do |key, value|
value.times do
new_array << key
end
end
new_a... | true |
bff31ade05cc4fbf2c7d960b7de8388e78877fa9 | Ruby | Kah919/school-domain-dumbo-web-121018 | /lib/school.rb | UTF-8 | 659 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
require 'pry'
class School
def initialize(name)
@name = name
@roster = {}
end
def roster
@roster
end
def add_student(name, grade)
if @roster.keys.include?(grade)
@roster[grade] << name
else
@roster[grade] = [name]
end
end
def grade(grade)
@roster[gra... | true |
3860365af2f39a0e103077150889e9b5f276f983 | Ruby | ulyssesrex/timelogger | /app/controllers/application_controller.rb | UTF-8 | 3,616 | 2.671875 | 3 | [] | no_license | class ApplicationController < ActionController::Base
set_current_tenant_through_filter
before_action :set_organization
protect_from_forgery with: :exception
include ApplicationHelper
include SessionsHelper
# Allows use of 'help.pluralize' in controllers.
class Helper
include Singleton
include ... | true |
580c184f2f48969d0125f1c63134fc71c7953799 | Ruby | puffo/spiral-drawing | /canvas.rb | UTF-8 | 1,483 | 3.734375 | 4 | [] | no_license | class Canvas
attr_reader :grid, :cursor_x, :cursor_y
EMPTY_CHARACTER = ' '
WRITTEN_CHARACTER = '*'
def initialize(size: 5, cursor_x: 0, cursor_y: 0)
@grid = initialize_empty_grid(size)
@cursor_x = cursor_x
@cursor_y = cursor_y
end
def draw_right(distance)
write_at_current_location
... | true |
12d26baa3b8a65e6154eaa92d9301933f85664b1 | Ruby | wakumo/bitcoin-ruby | /lib/bitcoin/bloom_filter.rb | UTF-8 | 3,205 | 2.578125 | 3 | [
"MIT"
] | permissive | module Bitcoin
# https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki
class BloomFilter
SEED_SHIFT = 0xfba4c795
BIT_MASK = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80].freeze
MAX_FILTER_SIZE = 36_000
MAX_HASH_FUNCS = 50
# flags for filterload message
BLOOM_UPDATE_NONE = 0
... | true |
8d355cf87a37b4c3226ad41801d1dfb52ddf2939 | Ruby | stormbrew/user_input | /spec/user_input_spec.rb | UTF-8 | 10,537 | 3.25 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'lib/user_input'
require 'ipaddr'
require 'date'
require 'set'
describe "UserInput" do
describe String do
it "Should accept anything that can have to_s called on the class method" do
String.from_user_input("OMGWTFBBQ").should == "OMGWTFBBQ... | true |
c0c7d810580afa9036e1bced2a23668868721359 | Ruby | HudsonHumphries/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,403 | 4 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
# YOUR CODE HERE
sum = 0
for x in arr
sum = sum + x
end
return sum
end
def max_2_sum arr
# YOUR CODE HERE
sum = 0
arr = arr.sort
if arr.length == 1
sum = arr[0]
elsif arr.length > 1
length = arr.length
su... | true |
2c2510218ecc72e2e6666e7e57f0de26202e4d32 | Ruby | skuan/src | /mashable.rb | UTF-8 | 1,264 | 3.03125 | 3 | [] | no_license | require 'httparty'
require 'JSON'
response = HTTParty.get('https://gist.githubusercontent.com/thebucknerlife/ce3598eb76deaec8ae4c/raw/ba25f9a6ed6d1fa9bbc3a41b1e85e8900d6d3e39/mashable.json', verify: false)
hash = JSON.parse(response)
monkey = hash['new']
turtle = hash['rising']
rabbit = hash['hot']
new_articles_so... | true |
7520400c8693e9f7eb88a853c86bc12ab7d77783 | Ruby | afleisch/Labs | /gluten.rb | UTF-8 | 1,840 | 4.375 | 4 | [] | no_license | require './allergy_error' #in order to use AllergyError in this program,
#link the file where the AllergyError class was created
#the kinds of food to be eaten
pizza = ["cheese", "gluten", "tomatoes"]
pan_seared_scallops = ["scallops", "lemons", "pasta", "olive oil"]
water = ["h", "h", "o"]
class Person
attr_acce... | true |
10fd29b3bd4fbb2b6985737cef55fbe10d30c08f | Ruby | eshou1014/phase-0 | /week-5/gps2_2.rb | UTF-8 | 1,263 | 3.953125 | 4 | [] | no_license | # Create an empty hash
# Create an add method that updates quantity to the list
# Create a remove method that removes item from the list
#IF item exists, then remove
#ELSE it doesn't exist
#Set a quantity to an object or an item
#Print the list
#With Celeen
# def grocery_list
# Hash.new{}
# end
# def add(item, qu... | true |
1d8f864d69f5434829ad14ecf44a051a26f72ffb | Ruby | igorsimdyanov/ruby | /hashes/value.rb | UTF-8 | 143 | 2.921875 | 3 | [] | no_license | h = { fst: 1, snd: 2, thd: 3, fth: 4 }
p h.value? 3 # true
p h.value? 10 # false
p h.has_value? 3 # true
p h.has_value? 10 # false
| true |
47d0891e65bb8e2798483a63060650cc396da327 | Ruby | abdulg95/99_bottles_of_oop | /chapter_8/06_removing_concretion_from_verse.rb | UTF-8 | 1,852 | 3.5 | 4 | [] | no_license | =begin
The final issue yet to be addressed is the concretion BottleNumber inside lyrics.
lyrics depends on BottleNumber and for and there is a Blank Line code smell that
suggests it has more than one responsibility.
The number argument is used only once, where it's converted to something else.
So the converted vers... | true |
9405e4eff6342201a24b23737963ef9e0da2eec6 | Ruby | LucianoPC/mkalias | /lib/commands/remove_signal.rb | UTF-8 | 639 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'command'
require 'commands/mka'
require 'mkalias'
# Command 'mkalias add_signal' implementation
class RemoveSignal < Command
def self.options_messages
%( remove_signal $ mkalias remove_signal
\t\t - Remove signal to run 'source ~/.bashrc' when
\t\t - add or remove an alias
)
end
def self... | true |
6e17fb717621c9057de2b1d016cf811fadd4ac29 | Ruby | krewskatee/hangman-ruby | /hangman.rb | UTF-8 | 1,545 | 4.1875 | 4 | [] | no_license | # HANGMAN
def replace(array, letter, word_guessed)
count = 0
array.each do |element|
if element == letter
word_guessed[count] = letter.upcase
elsif word_guessed[count] == "X"
word_guessed[count] = "X"
end
count += 1
end
word_guessed
end
def populate(array)
word_guessed = []
arr... | true |
a2a9909df9c3a129efb7612a620ee9e7d77a1fe6 | Ruby | mitchelloliveira/ruby-pdti | /Aula02/exercicio04.rb | UTF-8 | 587 | 3.625 | 4 | [] | no_license | # Curso de Ruby - PDTI-SENAC/RN
# Profº Weskley Bezerra
# Mitchell Oliveira
# 02/10/2020
# --------------------------------------------------------------
#Faça um Programa que verifique se uma letra digitada é vogal ou consoante.
puts 'Informe uma letra do alfabeto:'
letra = gets.strip.downcase
eh_alfabeto = letra.o... | true |
1115df3420d954acdc86a0d731ebaecd291419fe | Ruby | jatinbaweja/hangman | /hangman_view.rb | UTF-8 | 2,755 | 3.59375 | 4 | [] | no_license | TITLE_TEXT = "Welcome to Hangman"
INPUT_TEXT = "Enter your next guess: "
OUTPUTS = {
0 => <<-HANG0,
____________
| |
|
|
|
|
|
|
--------------
HANG0
1 => <<-HANG1,
____________
| |
... | true |
65490c2d789a3f9d361152bece6b3724f0b90953 | Ruby | wehman/name_location_numbers | /app_numberb.rb | UTF-8 | 861 | 3.1875 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader' if development?
get "/" do
erb :get_name
end
post '/post_name' do
bname = params[:user_name]
erb :get_age, :locals => {:name => bname}
end
post '/post_age' do
bage = params[:user_age]
bname = params[:user_name]
erb :get_numbers, :l... | true |
fe248fabdb7d16481dabd01f90596c4340d81e7e | Ruby | itggot-mans-jakobi/standard-biblioteket | /lib/average.rb | UTF-8 | 369 | 4.03125 | 4 | [] | no_license | # Public: Calculates the average of the integr:s in the array.
#
# array - an array with integer:s.
#
# Examples
#
# average([1, 4])
# # => 2.5
#
# Returns the average of the integr:s in the array.
def average(array)
i = 0
sum = 0
while i < array.length
sum += array[i].to_int
i += 1
... | true |
c04b8eb88fb518e4239d709ca198a6a5b5f356c3 | Ruby | pboling/sanitize_email | /lib/sanitize_email/mail_header_tools.rb | UTF-8 | 2,584 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
# Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
# Released under the MIT license
module SanitizeEmail
# Tools for modifying the header of an email
module MailHeaderTools
def self.prepend_subject_array(message)
prepend = []
if SanitizeEmail.use_actual_email_p... | true |
2eb8fc6c78daf459fd37c86b03787828a40defec | Ruby | scotthillson/hoppler | /app/models/image.rb | UTF-8 | 1,443 | 2.8125 | 3 | [] | no_license | class Image < ActiveRecord::Base
MAX_DELTA = 600
def self.store(tower,image,time,page)
success = 0
if !tower || !image
return success
end
if where(image:image).count < 1
i = new
i.tower_id = tower.id
i.image = image
i.time = time
if upload_image page, image
... | true |
9f8ad3130fca93c98781e8b185ccfc42338671e5 | Ruby | stantoncbradley/postapp | /test/models/comment_test.rb | UTF-8 | 2,367 | 2.609375 | 3 | [] | no_license | require 'test_helper'
class CommentTest < ActiveSupport::TestCase
def setup
@comment = Comment.new({
post_id: 1,
user_id: 1,
content: "great article!"
})
end
# Test validation
test "shou... | true |
8c661a666f61a6d69241d6a758d0c973d60feacd | Ruby | jeffreycwitt/catlogic | /lib/catlogic/quality.rb | UTF-8 | 405 | 3.078125 | 3 | [
"MIT"
] | permissive | module Catlogic
class Quality
attr_reader :label
def initialize(quality)
@label = quality
end
def opposite
if self.label == 'negative'
qualityopposite = Quality.new('affirmative')
elsif self.label == 'affirmative'
qualityopposite = Quality.new('negative')
end
... | true |
f83eae00f9b4c25a65c0b17c0f9f16da3ecda6b7 | Ruby | kaljt/workbook_intermediate_quiz1 | /Ex2.rb | UTF-8 | 214 | 2.953125 | 3 | [] | no_license | statement = "The Flintstones Rock"
statement.gsub!(" ",'').downcase!
freq = {}
phrase = statement.chars
phrase.each do |letter|
if freq.key?(letter)
freq[letter] +=1
else
freq[letter] = 1
end
end
p freq
| true |
19bdea599085109589141f18a072de6d5f444653 | Ruby | vivangkumar/prodder | /lib/prodder/event.rb | UTF-8 | 999 | 2.734375 | 3 | [] | no_license | require 'securerandom'
class Event
EVENT_PREFIX = 'event:'
attr_accessor :app_name, :time_spent, :timestamp, :user_id, :id, :score
def initialize(app_name, time_spent, timestamp, user_id)
@app_name = app_name
@time_spent = time_spent
@timestamp = timestamp
@user_id = user_id
end
def save
... | true |
58ea58238be9efd91cd11bc68ac82a4a0029f58a | Ruby | awarewolf/ClassicalInheritence | /frog.rb | UTF-8 | 218 | 2.71875 | 3 | [] | no_license | require_relative 'amphibian'
class Frog < Amphibian
attr_accessor :jump_distance
def initialize(name,jump_distance)
super(name,4)
@jump_distance = jump_distance
end
def ribbit?
true
end
end
| true |
d96f8524c2ea7c9449474d7350d358bfcf239e18 | Ruby | govaniso/phidgets-ffi | /examples/bridge.rb | UTF-8 | 1,257 | 2.71875 | 3 | [] | no_license | require 'rubygems'
require 'phidgets-ffi'
puts "Library Version: #{Phidgets::FFI.library_version}"
br = Phidgets::Bridge.new
puts "Wait for PhidgetBridge to attached..."
#The following method runs when the PhidgetBridge is attached to the system
br.on_attach do |device, obj|
puts "Device attributes: #{device.att... | true |
59e957aa96a4f9b3592277a40e0c7ddc438aeb94 | Ruby | lfriedrichs/crud-with-validations-lab-seattle-web-012720 | /app/models/release.rb | UTF-8 | 315 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Release < ActiveModel::Validator
def validate(song)
if song.released == true
unless Integer === song.release_year && song.release_year <= Time.now.year
song.errors[:release_year] << "Needs to be an integer earlier than this year"
end
end
end
end | true |
37f483342ab6f98123b5bc4518ee73401e6ce9fa | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/5a201d406f784a89aec0dfcda96227a0.rb | UTF-8 | 179 | 2.859375 | 3 | [] | no_license | class Hamming
class << self
def compute(strand_a, strand_b)
strand_a.chars.select.with_index do |gene, i|
gene != strand_b[i]
end.size
end
end
end
| true |
f674f25326784b520bf700c039169c8ec3a6a99b | Ruby | prajjwaldimri/ITGWebsite | /test/models/user_test.rb | UTF-8 | 2,802 | 2.703125 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Prajjwal Dimri",
email: "prajjwaldimri@hotmail.com",
rollno: "141340101018",
user_type: "Student",
password: "anypass12", password_confirmation: "anypass12")
@user1 = User.new(name: "Ayush Pant"... | true |
376f05a453e320ec9e747471db0b9b0d48b1a2d0 | Ruby | DrugAddicts/Ruby-on-Rails | /Lr7/Lab7_2/task.rb | UTF-8 | 605 | 3.84375 | 4 | [] | no_license | #
class Word
attr_reader :word
def initialize(word)
@word = word
end
def print_w
puts "Значение поля: #{@word}"
end
def print_len
print 'Количество букв в слове: '
@word.size
end
end
#
class Intnum < Word
attr_reader :len_w
def initialize(word)
super(word)
... | true |
1aa9072f465c0106899031b7089470db2145d028 | Ruby | britishtea/touchwonders-api | /lib/resizer.rb | UTF-8 | 661 | 3.390625 | 3 | [] | no_license | require "mini_magick"
require "stringio"
class Resizer
def initialize(image)
@image = image
end
def thumb
crop_and_resize(@image, 50, 50)
end
def full
crop_and_resize(@image, 1000, 1000)
end
private
def crop_and_resize(file, width, height)
image = MiniMagick::Image.read(file)
ou... | true |
6aa104162bb038d532715611e5076be0544ad1c7 | Ruby | lexieernst/phase_0_unit_2 | /week_5/4_boggle_board/my_solution.rb | UTF-8 | 1,653 | 4.21875 | 4 | [] | no_license | # U2.W5: A Nested Array to Model a Boggle Board
# I worked on this challenge [by myself, with: ].
boggle_board = [["b", "r", "a", "e"],
["i", "o", "d", "t"],
["e", "c", "l", "r"],
["t", "a", "k", "e"]]
def create_word(board, *coords)
coords.map { |coord| board[coor... | true |
e1f4283a05f03c2b820a8fd9e4760766015b8812 | Ruby | yopage-generator/server | /app/services/per_landing_fee_strategy.rb | UTF-8 | 715 | 2.53125 | 3 | [] | no_license | # Стратегия списания абонплаты - за каждый лендинг в месяц
class PerLandingFeeStrategy
include Virtus.model(strict: true, nullify_blank: true)
attribute :account, Account
attribute :tariff, Tariff
attribute :month, Date
def call
total = Money.new(0)
descriptions = []
account.landings.find_each ... | true |
202c6a946690d43bc577c123f6d4ff67893c0ff4 | Ruby | opensourcery/laika | /lib/component_descriptors.rb | UTF-8 | 38,904 | 2.671875 | 3 | [] | no_license | require 'delegate'
# In order to be able to parse and validate a particular form of XML based
# medical document, we need to be able to describe the logical components of
# the document such that we can extract key fields for comparison with or
# export to some other model.
#
# components - a base component module of ... | true |
0c98282e8b4e7c544372b9a85583e96ad8632ab2 | Ruby | andreyvit/xdry | /lib/xdry/parsing/model.rb | UTF-8 | 5,129 | 2.6875 | 3 | [
"MIT"
] | permissive |
module XDry
class OGlobal
def initialize
@names_to_classes = {}
end
def classes
@names_to_classes.values
end
def new_file_scope
SFile.new.bind(self)
end
def << child
case child
when SInterface
lookup_class(child.class_name).add_interface child
... | true |
5788afd0aeaeb94f7880bd7e24b31ea979e3605f | Ruby | fauxparse/battlesnake | /lib/snake.rb | UTF-8 | 603 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'from_json'
require 'segment'
class Snake
extend FromJson
attr_reader :id, :name, :health, :body
def initialize(id:, name:, health:, body:)
@id = id
@name = name
@health = health
@body = body.map.with_index do |segment, i|
Segment.new(x: segment['x'], y: segment['y'], life: body.s... | true |
1b583996e31c1c127a53f50e9fad52cb92469302 | Ruby | extreem-engineer/extreme-engineer4 | /fare_table.rb | UTF-8 | 304 | 2.90625 | 3 | [] | no_license | require_relative 'fare'
class FareTable
def initialize()
@fareTable = []
end
def add(fare)
@fareTable << fare
end
def find_fare(dept,dest)
fareFind = @fareTable.find {|fare|
fare.dept == dept &&
fare.dest == dest}
return fareFind.fare
end
end | true |
0405252b5e85b872dc61cb43e8b2dc8072ce1d62 | Ruby | link108/ruby_server | /lib/server.rb | UTF-8 | 858 | 2.765625 | 3 | [] | no_license | require 'sinatra'
require './ip_manager'
manager = IpManager.new
puts ''
get '/' do
return ok("Hello #{params[:name]}\n")
end
post '/blah' do
this = request.body.read.to_s
return "#{this.to_s}\n" if this
return "NO THIS!!\n"
end
get '/blah/:name/hello' do
return "Hello #{params[:name]}"
end
p... | true |
48f8c7dec68d530ae2e614fcd4553162e94a6989 | Ruby | hkim0331/yatt | /src/yatt-text.rb | UTF-8 | 1,016 | 2.921875 | 3 | [] | no_license | # VERSION: 1.1.1
class MyText < TkText
@@sticky = false
@@loose = false
def initialize(parent, params)
@text=TkText.new(parent,params)
@text.tag_configure('good', background: GOOD)
@text.tag_configure('bad', background: BAD)
end
def insert(text)
@text.configure(state: 'normal')
@text.... | true |
82904fbdf5231fd6478e1a05db3499d1cdd06e1e | Ruby | Bram9205/WebInfo | /Code voor Pechineskey/News Classifier/index_Jasper.rb | UTF-8 | 165 | 2.5625 | 3 | [] | no_license | #!/usr/bin/ruby
i = 1
# Change the boundary to the number of entries in the database.
# 400
while(i < 376)
j = i
system("ruby ML_Jasper.rb " + j.to_s)
i += 1
end
| true |
635b1e7cc8e43a9b8fdec200efe5150283624a38 | Ruby | dwlknsn/WDI_Project1 | /db/seeds.rb | UTF-8 | 5,654 | 2.703125 | 3 | [] | no_license | Classroom.delete_all
Program.delete_all
Course.delete_all
# Classrooms
r1 = Classroom.create!(name: "London: Room 1", capacity: 20, city: "London", country: "England")
r2 = Classroom.create!(name: "Berlin: Room 2", capacity: 20, city: "Berlin", country: "Germany")
r3 = Classroom.create!(name: "New York: Room 1", capa... | true |
9b8721ea0c8020fd2897705af29b4c282bda3ecc | Ruby | juli0w/mgo | /app/models/_company_importer.rb | UTF-8 | 6,394 | 2.515625 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class CompanyImporter
CATEGORIES = [
{ root: 'produtos-farmaceuticos-e-cosmeticos',
name: 'Beleza', categories:
[ { category: 'Cosmésticos e perfumaria' } ] },
{ root: 'noite', name: 'Noturno',
categories:
[ { category: 'moteis',
n... | true |
c216f128fe585dde2364cc24ef1c28cde015219f | Ruby | cernandes/curso-ruby | /aula03/elsif.rb | UTF-8 | 356 | 3.5 | 4 | [] | no_license | # utilizado quando há a necessidade de verificar mais de uma condição em im (if)
# Sintaxe, abre com (if) depois (else) fecha o bloco com (end), atenção a sintaxe (elsif)
day = 'Saturday'
lunch = 'normal'
if day == 'Sunday'
lunch = 'Special'
elsif day == 'Holiday'
lunch = 'Later'
else
lunch = 'Normal'
end
... | true |
c99865843d8fdc83cf6cec15cfd63cb15caa16fb | Ruby | y-yagi/querly | /lib/querly/script.rb | UTF-8 | 221 | 2.5625 | 3 | [
"MIT"
] | permissive | module Querly
class Script
attr_reader :path
attr_reader :node
def initialize(path:, node:)
@path = path
@node = node
end
def root_pair
NodePair.new(node: node)
end
end
end
| true |
90f20bf54f89beadd96680989a75820df7499d90 | Ruby | eebbesen/minutes_maid | /vendor/cache/ruby/2.5.0/gems/mail-2.7.1/lib/mail/parser_tools.rb | UTF-8 | 446 | 2.640625 | 3 | [
"MIT"
] | permissive | module Mail
# Extends each field parser with utility methods.
module ParserTools #:nodoc:
# Slice bytes from ASCII-8BIT data and mark as UTF-8.
if 'string'.respond_to?(:force_encoding)
def chars(data, from_bytes, to_bytes)
data.slice(from_bytes..to_bytes).force_encoding(Encoding::UTF_8)
... | true |
531573b0103e1c7f91a3313b4de03b47e06c9e1d | Ruby | HoneyryderChuck/httpx | /lib/httpx/domain_name.rb | UTF-8 | 5,020 | 2.796875 | 3 | [
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
#
# domain_name.rb - Domain Name manipulation library for Ruby
#
# Copyright (C) 2011-2017 Akinori MUSHA, All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redist... | true |
631a67f01174fd20bc1fefc5ac4efb877fae7cb1 | Ruby | ckagana/LaunchAcademy-Challenges | /vending-machine/code.rb | UTF-8 | 251 | 3.375 | 3 | [] | no_license | items_we_have = "chips popcorn skittles clif-bar mentos gum cheetos m&ms"
puts "What item would you like?"
item = gets.chomp
index = items_we_have.index(item)
if index != nil
puts "Item index:\n#{index}"
else
puts "We don't have that item."
end
| true |
bbb6f3f7ec811f3d6559c7327b2c7c68fdaa7ac7 | Ruby | Fendev-repo/launch_school_101_ls6_slightly_larger_programs | /assignment_twenty_one_bonus_features/presentation_and_io_to_terminal.rb | UTF-8 | 4,458 | 3.3125 | 3 | [] | no_license | require_relative 'game_logic'
def prompt(msg)
puts msg
end
def welcome_user_to_the_game
clear_cli
prompt ""
prompt " Let's Play #{MAX_HAND_VALUE}!"
end
def show_card_images
card_image_a
card_image_b
end
def present_hands(player_hand, dealer_hand, game_status, game_count)
show_dealer_cards(dealer_han... | true |
e901a42a63bc5df77fa146592f391a0afd5383b5 | Ruby | nwmclaren/CC_HW_WK4_day2 | /pizza_controller.rb | UTF-8 | 774 | 2.625 | 3 | [] | no_license | require( 'sinatra' )
require( 'sinatra/contrib/all' )
require( 'pry' )
require_relative('./models/pizza_order')
also_reload('./models/*')
# INDEX - SHOW ALL PIZZAS
get '/pizza_orders' do
@orders = PizzaOrder.all()
erb(:index)
end
# NEW - DISPLAY A FORM TO MAKE A NEW PIZZA ORDER
get '/pizza_orders/new' do
er... | true |
81568440ffd876253472a18eb8410429c821f1c0 | Ruby | ged/ruby-framenet | /lib/frame_net/definition.rb | UTF-8 | 1,108 | 2.5625 | 3 | [
"CC-BY-4.0",
"MIT"
] | permissive | # -*- ruby -*-
#encoding: utf-8
require 'loggability'
require 'libxml'
require 'frame_net' unless defined?( FrameNet )
# A marked-up English language definition from various FrameNet elements
class FrameNet::Definition
### Construct a Definition from the given +node+ (a LibXML::XML::Node for a
### definition ele... | true |
edb6557433ed28c46d5c814b86046e52a1850947 | Ruby | keyclicker/labs | /Term5/Ruby/Test/main.rb | UTF-8 | 1,795 | 3.5 | 4 | [] | no_license | class Field
attr_accessor :value
def initialize(value)
@value = value
end
end
class Phone < Field
end
class Skype < Field
end
class Email < Field
end
class Social < Field
end
class Contact
attr_accessor :name, :phone, :skype, :email, :social
def initialize(name = nil, phone = nil, skype = nil, email ... | true |
8961fdd5a21b72680f0d52ddb677c6ece00c3fbb | Ruby | andersonvom/saas-class | /assignments/01.ruby.calisthenics/lib/05_advanced_oop.rb | UTF-8 | 652 | 3.421875 | 3 | [] | no_license | class Class
# provides the same functionality as attr_accessor but also
# tracks every value the attribute has ever had.
def attr_accessor_with_history(*attr_names)
attr_names.each do |attr|
attr_name = attr.to_s
attr_reader attr_name
attr_reader "#{attr_name}_history"
class_eval %Q{... | true |
9f5f3f7ebe33986cb4d221b507c3b1851f50102a | Ruby | jennyCorrea/interpolation-super-power-q-000 | /lib/display_rainbow.rb | UTF-8 | 266 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your #display_rainbow method here
def display_rainbow(colors)
i = 0
s = colors.map do |color|
# to pass spec only, doesnt do anything
colors[i]
i += 1
"#{color[0].upcase}: #{color}"
end.join(", ").inspect.gsub!(/"/, '')
puts s
end
| true |
34aba0ed13ebfb7e49d788d1d9335777ac635db2 | Ruby | ricardovaltierra/ruby-exercises | /Module1/testing-with-rspec/exercise_7/lib/deck.rb | UTF-8 | 940 | 3.484375 | 3 | [] | no_license | class Deck
attr_reader :cards
NUMBER_OF_CARDS = 52
FACES = [ "Ace", "Deuce", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" ]
SUITS = [ "Hearts", "Diamonds", "Clubs", "Spades" ]
def initialize
@current_card = 0
@cards = Array.new(NUMBER_OF_CARDS){PlayingCa... | true |
9806ce8fba03e769d211218bea2d0a5fbe2c2d8c | Ruby | celic/Beaconator | /ping_beacon.rb | UTF-8 | 384 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'nokogiri'
# Beacon url
url = 'http://beacon.nist.gov/rest/record/last'
# Get Beacon data
xml = Net::HTTP.get_response(URI.parse(url)).body
# Parse outputValue from xml
doc = Nokogiri::XML(xml)
# Clear previous output
file = File.open "beacon", "w"
file.truncate 0
# Output beacon to file... | true |
424232c902e756dc6027ed9295450aa1264922a3 | Ruby | rom-rb/rom-support | /lib/rom/support/class_macros.rb | UTF-8 | 1,219 | 2.890625 | 3 | [
"MIT"
] | permissive | module ROM
# Internal support module for class-level settings
#
# @private
module ClassMacros
UndefinedValue = Object.new
# Specify what macros a class will use
#
# @example
# class MyClass
# extend ROM::ClassMacros
#
# defines :one, :two
#
# one 1
# ... | true |
12de3cbc3b8055238594b85208832b62eb3c463c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/11757.rb | UTF-8 | 606 | 3.78125 | 4 | [] | no_license | def is_anagram?(word1, word2)
if word1.downcase.chars.sort.join == word2.downcase.chars.sort.join
return true
else
return false
end
end
def combine_anagrams(words)
list = Array.new
words.each do |word|
find_anagram = false
list.each do |item|
if is_anagram?(item[0], word)
item.p... | true |
5da862251305ce241ef8bf5d08f66df35f2703ff | Ruby | baumanj/ccsubs | /spec/helpers/holiday_spec.rb | UTF-8 | 1,162 | 2.84375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Holiday, type: :helper do
describe "name" do
it "returns the right name when the current day is a holiday" do
xmas_2018 = Date.new(2018, 12, 25)
allow(Date).to receive(:current).and_return(xmas_2018)
expect(Date.current).to eq(xmas_2018)
expect(Holid... | true |
549cb6e2189dac6fb07d073401496f39d3cfb17f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/filtered-submissions/d420649955484deaac62e6c05d4e9bce.rb | UTF-8 | 182 | 3.046875 | 3 | [] | no_license | def compute(shorter, longer)
if shorter.size > longer.size
self.compute(longer, shorter)
else
shorter.chars.zip(longer.chars).count { |a,b| a != b }
end
end | true |
7d2786668b1219aecce4447ab3f43719647143d0 | Ruby | socketry/falcon | /lib/falcon/services.rb | UTF-8 | 2,032 | 2.546875 | 3 | [
"LicenseRef-scancode-dco-1.1",
"MIT"
] | permissive | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.
require_relative 'service/generic'
module Falcon
# Represents one or more services associated with a host.
#
# The services model allows falcon to manage one more more service associated with a given host. ... | true |
b5a07e3dffaa3eafaa3a3d6bb00d672679cb2669 | Ruby | akanshmurthy/codelearnings | /odin/eventmanager/lib/event_manager.rb | UTF-8 | 2,181 | 3.28125 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'sunlight/congress'
require 'erb'
require 'date'
Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5"
def clean_zipcode(zipcode)
zipcode.to_s.rjust(5,"0")[0..4]
end
def legislators_by_zipcode(zipcode)
Sunlight::Congress::Legislator.by_zipcode(zipcode)
end
def save_thank_you_lett... | true |
13daf97f6c18e5685020b4ffd154085a230b9019 | Ruby | wolfgangw/digital_cinema_tools_distribution | /xsd-check.rb | UTF-8 | 1,799 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Wolfgang Woehl v0.2011.12.29
#
# Validate XML document against XSD.
# Quick and dirty. Thank you, libxml and nokogiri!
#
# xsd-check.rb <Schema file> <XML document>
# xsd-check.rb SMPTE-429-7-2006-CPL.xsd cpl.xml
#
# For XML Catalog operation see env XML_CATALOG_FILES and XML_DEBUG_CATALOG
#
re... | true |
db8c4be83946eccabd467acec9495cd6b19fa20b | Ruby | lascar/robots_fight_club | /app/models/fight.rb | UTF-8 | 1,602 | 2.65625 | 3 | [
"MIT"
] | permissive | class Fight < ActiveRecord::Base
belongs_to :robot1, :class_name => 'Robot', :foreign_key => 'robot1_id'
belongs_to :robot2, :class_name => 'Robot', :foreign_key => 'robot2_id'
validates_associated :robot1, :robot2
validates :robot1, :robot2, :win1, :fight_time, presence: true
before_save :verif_robots_users,... | true |
6e3f5fe5486887d6b3e0e1d5259a6430d5c45f82 | Ruby | ComaToastUK/apples | /lib/apple.rb | UTF-8 | 200 | 2.65625 | 3 | [] | no_license | require './lib/bowl'
class Apple
def initialize
@rotten = true
end
def rotten?
@rotten
end
attr_writer :rotten
# def rotten=(new_value)
# @rotten = (new_value)
# end
end
| true |
8ad5ecaafb504a03153d0e9d9c3df69e7799d76c | Ruby | chcyellow/src_ruby | /for_names.rb | UTF-8 | 71 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | names=["awk","Perl","Python","Ruby"]
for name in names
puts name
end
| true |
75b86de2155b398042e4444a91ab441aef2e7127 | Ruby | NebulaFintech/banxico | /lib/banxico/exchange_rate.rb | UTF-8 | 385 | 2.90625 | 3 | [
"MIT"
] | permissive | module Banxico
class ExchangeRate
attr_reader :currency, :date, :value
def initialize(currency, xml)
@currency = currency.to_sym
@date = Date.iso8601(xml[:TIME_PERIOD])
@value = xml[:OBS_VALUE].to_f
end
class << self
def get_date(array, date)
array.select{|exchange_rat... | true |
bacb2490271bdc7c690ebd901fbebfd633d28694 | Ruby | jhbadger/scripts | /parseGenBank2PhyloDB | UTF-8 | 10,013 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'optimist'
require 'bio'
require 'ZFile'
require 'digest/sha1'
ARGV.push("--help") if ARGV.empty?
opts = Optimist::options do
banner File.basename($0)
opt :definition, "use definition as organism name"
opt :input, "genbank file(s) to process", :type=>:strings, :req... | true |
c2c07bb89b4ff5019d322a6046140c26b9785441 | Ruby | SamGarner/ruby_tictactoe | /tictac_old.rb | UTF-8 | 1,441 | 3.84375 | 4 | [] | no_license | # frozen_string_literal: false
# represents a single TicTac game
class Game
attr_accessor :players_turn, :space1
def initialize
@space1 = 0
@space2 = 0
@space3 = 0
@space4 = 0
@space5 = 0
@space6 = 0
@space7 = 0
@space8 = 0
@space9 = 0
@players_turn = "X"
puts @playe... | true |
ce422091868336f252d09fcb208f275f65f2f528 | Ruby | chickenbear/codingeducation | /practice.rb | UTF-8 | 1,750 | 3.734375 | 4 | [] | no_license | a=[1,2,3,4,5,6,7,8,9,10]
def print_even(list)
list.each{|n| puts n if n%2==0}
end
def gugudan(n)
(1..9).each{|x| puts "#{n}*#{x}=#{n*x}" }
end
def sphere_volume(r)
pi=Math::PI
v=pi*4/3*r**3
puts "Volume of sphere with radius #{r} is #{v}"
return v
end
def sqrt_round2(value)
if(!value.is_a?Numeric or v... | true |
6cbc554e32505916d92e6ab1968f251d19a3ce50 | Ruby | bgreg/studyGuide | /spec/lib/algorithms/sort/insertion_sort_spec.rb | UTF-8 | 753 | 3.03125 | 3 | [] | no_license | require_relative "../../../../lib/algorithms/sort/insertion_sort"
require "spec_helper"
describe InsertionSort do
describe "#sort" do
context "Grabs items from the right of the array and finds where it belongs in the sorted, left side." do
context "given a random list of numbers" do
let(:randomized... | true |
6441d33c1fab697a9036de0b274d9bb837f93d17 | Ruby | ShobhitRatan/ruby-oo-relationships-practice-gym-membership-exercise-nyc-web-030920 | /tools/console.rb | UTF-8 | 570 | 2.953125 | 3 | [] | no_license | # You don't need to require any of the files in lib or pry.
# We've done it for you here.
require_relative '../config/environment.rb'
# test code goes here
l1 = Lifter.new("Oliver Queen", 300)
l2 = Lifter.new("Barry Allen", 150)
l3 = Lifter.new("Steve Rogers", 1000)
l4 = Lifter.new("Bruce Wayne", 500)
g1 = Gym.new("X... | true |
fecf0f96e81aad12f18ba515437db74797af52fa | Ruby | musajoemo/sinatra-webrtc | /server.ru | UTF-8 | 1,508 | 2.75 | 3 | [] | no_license | require 'rubygems'
require 'sinatra/base'
require 'rack/websocket'
require 'json'
USERS = {}
class App < Sinatra::Base
get '/' do
send_file File.expand_path('../webrtc_test.html', __FILE__);
end
end
class User
def initialize(name, ws)
@name = name
@ws = ws
end
def to_json(*a)
@name.inspe... | true |
21931576fa6ba5ce53aa05e4b8cd9c828c2dbbfd | Ruby | RanjitReddy/Hackerrank-Solutions | /jumping_on_the_clouds.rb | UTF-8 | 377 | 3.203125 | 3 | [] | no_license | #!/bin/ruby
n = gets.strip.to_i
c = gets.strip
c = c.split(' ').map(&:to_i)
flag = false
count = 0
count = count.to_i
1000.times do
if c[2] == 0
c.shift
c.shift
count = count + 1
elsif c[1] == 0
c.shift
count = count + 1
elsif c[1] == 1 or c[2] == 1
flag = true
bre... | true |
28da0b273c74bb6f3852b465125ac91014c92ddd | Ruby | karahiyo/totsuzennoshi | /spec/totsuzennoshi_spec.rb | UTF-8 | 2,078 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Totsuzennoshi" do
describe "は" do
it "突然の死を出す" do
Totsuzennoshi.totsuzennoshi("突然の死").should eq("_人人 人人_\n> 突然の死 <\n ̄Y^Y^Y^Y^Y ̄\n")
end
it "その結果がこれだよ" do
Totsuzennoshi.totsuzennoshi("その結果がこれだよ... | true |
fa87c3ac85d4905a736f0fa4b2abe006faf0ba7e | Ruby | thebravoman/software_engineering_2013 | /class17_homework/Kristian_Popov/csv2graph.rb | UTF-8 | 1,731 | 3.25 | 3 | [] | no_license | require_relative 'graph_drawer'
require 'csv'
class CsvToGraph
def initialize output="Kristian_Popov.svg",x=256,y=256
@text = []
@vertexes = []
@edges = []
@drawer = Drawer.new output,x,y
@graph_drawer = GraphDrawer.new @drawer
... | true |
4e9d8a5fd09a1d22ac1638f0b89af3c50532d1f7 | Ruby | jasmine1226/sinatra-basic-routes-lab-online-web-pt-051319 | /app.rb | UTF-8 | 285 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/name' do
"My name is Jasmine"
end
get '/hometown' do
"My hometown is Taipei, Taiwan"
end
get '/favorite-song' do
"My favorite song is Truth Hurts by Lizzo"
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.