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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
652256d25960740bcaa47ba4063e4f1774b3d80f | Ruby | theo-browne/W4D4 | /poker/spec/deck_spec.rb | UTF-8 | 393 | 2.671875 | 3 | [] | no_license | require "rspec"
require "deck"
RSpec.describe Deck do
describe "Deck::all_cards"
it "should generate a deck of 52 cards" do
expect(Deck.all_cards.uniq.length).to eq(52)
end
describe "Deck#initialize" do
let(:deck) { Deck.new }
it "should set instance variable, @cards, to represent the deck ... | true |
b781d5f60ccbadb97dc0b8c75463464769e2995b | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/1343.number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold.rb | UTF-8 | 1,570 | 3.59375 | 4 | [] | no_license | #
# @lc app=leetcode id=1343 lang=ruby
#
# [1343] Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold
#
# https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/description/
#
# algorithms
# Medium (64.20%)
# Total Accepted: 11.6K
# Total... | true |
9a03e760620182dd8e5380299f184deb701ead26 | Ruby | ensons/beacon | /lib/beacon/states/three.rb | UTF-8 | 405 | 2.71875 | 3 | [
"MIT"
] | permissive | module Beacon
module States
# Wait 3 intervals.
class Three
def call
blink
wait
next_state
end
private
def blink
Leds.blink! 3
end
def wait
Log.debug { "Waiting because I'll retry in 30 seconds" }
Sleep.call Beacon.config.d... | true |
1ed0aff6da2eed117190a1bf5f08f1390723ad99 | Ruby | roomorama/concierge | /apps/web/middlewares/health_check.rb | UTF-8 | 1,447 | 2.5625 | 3 | [] | no_license | require_relative "../../../lib/concierge/json"
require_relative "../../../lib/concierge/version"
module Web
module Middlewares
# +Web::Middlewares::HealthCheck+
#
# Implements a simple endpoint for health checking, necessary for the load
# balancer to determine if the server is healthy.
#
# ... | true |
24609ee94099296c60ce744fb99c1f8f9b7ad468 | Ruby | jslabovitz/photo-utils | /lib/photo-utils/values/aperture.rb | UTF-8 | 766 | 3.015625 | 3 | [] | no_license | module PhotoUtils
class ApertureValue < Value
APEX_LABEL = 'Av'
def self.parse(s)
case s.strip
when %r{^(f/?)?([\d\.]+)$}i
new($2.to_f)
when %r{^US\s+([\d\.]+)$}i
new_from_us_stop($1.to_f)
else
raise ValueParseError, "Can't parse #{s.inspect} as aperture valu... | true |
5bbbc602cdbe5f9e08712ba4c7e461ea4133a5c9 | Ruby | nemilya/ruby-todo-demo | /app.rb | UTF-8 | 5,781 | 2.59375 | 3 | [
"MIT"
] | permissive | # Простое ToDo приложение на базе Ruby/Sinatra/DataMapper
#
# [github][src], [демо][demo]
#
# [src]: https://github.com/nemilya/ruby-todo-demo
# [demo]: http://ruby-todo-demo.cloudfoundry.com
# подключение Sinatra и DataMapper библиотек
require "rubygems"
require "sinatra"
require 'dm-core'
require 'dm-migrations'
... | true |
c371dcb4256185dabc6484a731f297d2ed98d16d | Ruby | lambsubstitute/new-test-webdriver | /Features/support/page_objects/login_po.rb | UTF-8 | 760 | 2.5625 | 3 | [] | no_license | # encoding: utf-8
# class documentation
class LoginPo
include PageInitializer
# Container identifier
LOGIN_DIV_ID = 'login-panel'
# Element identifiers
USERNAME_INPUT_ID = 'username'
PASSWORD_INPUT_ID = 'password'
SUBMIT_INPUT_ID = 'login'
def get_login_div
@browser.div(:id, LOGIN_DIV_ID).wait_u... | true |
764c2ed7d73fbbe5fd825acfdf0f16aa3049963f | Ruby | m-chrzan/aoc2020 | /08/a.rb | UTF-8 | 439 | 3.203125 | 3 | [] | no_license | code = []
File.readlines('input.txt').each do |line|
instruction, number = line.split
code.push [instruction, number.to_i]
end
visited = {}
current_line = 0
acc = 0
while !visited[current_line]
visited[current_line] = true
case code[current_line][0]
when 'nop'
current_line += 1
when 'acc'
acc += ... | true |
1faf19b2285ea89bfbb58c958fb0fd61eb2153ac | Ruby | justindelatorre/itpwr | /flow_control/flow_control-3.rb | UTF-8 | 581 | 4.09375 | 4 | [] | no_license | =begin
Write a program that takes a number from
the user between 0 and 100 and reports
back whether the number is between 0 and
50, 51 and 100, or above 100.
=end
puts "Please select a number between 0 and 100."
# Convert input String into an Integer
num = gets.chomp.to_i
case
when num < 0
puts "You can't submit a n... | true |
07f3c5a37c7653a3eeb4c35efc094ad12728fc80 | Ruby | TiffanyChio/betsy | /test/models/orderitem_test.rb | UTF-8 | 4,842 | 2.65625 | 3 | [] | no_license | require "test_helper"
describe Orderitem do
let(:new_orderitem) {
Orderitem.new(
quantity: 1,
product: products(:stella),
order: orders(:order1),
shipped: false
)
}
describe "validation" do
it "can instantiate a valid orderitem" do
expect(new_orderitem.save).must_equa... | true |
b449e7d188b06aa67391bfa39d7d79c239adfd4a | Ruby | tatianabespalko/tatianabespalko.github.io | /tasks/mkdev/lesson_05/movies.rb | UTF-8 | 1,266 | 3.125 | 3 | [] | no_license | require 'csv'
require 'ostruct'
require 'date'
require_relative './movies_col.rb'
class Movie
attr_accessor :link, :name, :year, :country, :release_date, :genre, :length, :rating, :director, :actors, :collection, :month, :release_year
def initialize (film_collection, film)
film.each { |k,v| instance_variable... | true |
7ec03b688992703b4fa6525b170017fa8e751a6d | Ruby | igrigorik/em-proxy | /examples/balancing.rb | UTF-8 | 5,188 | 3.0625 | 3 | [
"MIT"
] | permissive | $:<< '../lib' << 'lib'
require 'em-proxy'
require 'ansi/code'
require 'uri'
# = Balancing Proxy
#
# A simple example of a balancing, reverse/forward proxy such as Nginx or HAProxy.
#
# Given a list of backends, it's able to distribute requests to backends
# via different strategies (_random_, _roundrobin_, _balanced_... | true |
12fd14b3492b4212065a7ca11fbdad695743afa9 | Ruby | fhmurakami/cookbook-campuscode | /db/seeds.rb | UTF-8 | 1,127 | 2.546875 | 3 | [] | no_license | user = User.create(name: 'Teste', email: 'teste@email.com', password: '123456', city: 'São Paulo', admin: false)
admin = User.create(name: 'Admin', email: 'admin@email.com', password: '123456', city: 'São Paulo', admin: true)
RecipeType.create(name: 'Sobremesa')
RecipeType.create(name: 'Entrada')
Cuisine.create(name: '... | true |
36314042e8dbbffb100e4f878a0def2e244ae1d2 | Ruby | mick-thumvilai/Lovemac_IntroToIce_Final | /lib/lovemac.rb | UTF-8 | 256 | 3.515625 | 4 | [] | no_license | #Siwat Thumvilai 5631378321
def lovemac(number)
if number%3 == 0 and number%5 ==0
return "HateWindows"
elsif number%3 == 0
return "Love"
elsif number%5 == 0
return "Mac"
else
return number
end
end
(1..50).each do |number|
puts lovemac(number)
end | true |
c6eb6dc8a45b94f180895f6001eb8fcc858dacd1 | Ruby | GratefulGarmentProject/StockAid | /spec/models/item_spec.rb | UTF-8 | 2,533 | 2.578125 | 3 | [
"MIT"
] | permissive | require "rails_helper"
describe Item do
describe ".for_category" do
it "returns items for_category" do
category = categories(:flip_flops)
expect(Item.unscoped.where(category_id: category.id).count).to eq(4)
flip_flop_items = Item.for_category(category.id)
expect(flip_flop_items.count).to ... | true |
75f30c6b05563a9e7825d8cb06ae9a3af9d6bc6c | Ruby | mateforlife/cryptodo | /lib/requester/coinmarketcap.rb | UTF-8 | 342 | 2.5625 | 3 | [] | no_license | module Requester
class Coinmarketcap
include HTTParty
base_uri 'https://api.coinmarketcap.com/v1/ticker'
def initialize(coin_name, convert)
@response = self.class.get("/#{coin_name}/?convert=#{convert}", format: :plain)
end
def parsed_response
JSON.parse(@response, symbolize_names: t... | true |
1cd8294de9f8fe45e5b1d38399269155cdbfc531 | Ruby | D0947506/opencspm | /docker/app/jobs/lib/fetcher/types/local_fetcher.rb | UTF-8 | 968 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
class LocalFetcher
def initialize(local_dirs, load_dir)
@local_dirs = local_dirs
@load_dir = load_dir
end
def fetch
puts @local_dirs
# Enumerate **/*manifest.txt and /*manifest.txt
@local_dirs.each do |local_dir|
dirs = Dir["#{local_dir}/*/*manifest.txt"]... | true |
d148108bf137852c9f5d45be13e1a077f696df30 | Ruby | ryanmillergm/code_challenge | /app/models/street_cafe.rb | UTF-8 | 763 | 2.78125 | 3 | [] | no_license | class StreetCafe < ApplicationRecord
validates_presence_of :restaurant_name,
:street_address,
:post_code,
:number_of_chairs
def self.cafes_by_size(*size)
if size.count == 1
where("category LIKE ?", "%#{size[0]}")
elsif size.count... | true |
1028214ef782ddcf5e554a3a62488c5bdac1faca | Ruby | cloudwow/rdesk | /lib/rdesk/project/auto_build.rb | UTF-8 | 1,761 | 2.546875 | 3 | [] | no_license |
class Project
def initialize(name,root_dir,source_dirs,build_command,error_regexes)
@name=name
@root_dir=root_dir
@source_dirs=source_dirs
@build_command=build_command
@error_regexes=error_regexes
@last_build_time=Time.now
end
def is_modified?
@sou... | true |
268a37fa72858dee28ab29704f10c44bf70cba71 | Ruby | ejdelsztejn/order_up | /app/models/chef.rb | UTF-8 | 394 | 2.78125 | 3 | [] | no_license | class Chef <ApplicationRecord
validates_presence_of :name
has_many :dishes
def most_popular_ingredients
ingredient_count = Hash.new(0)
self.dishes.each do |dish|
dish.ingredients.each do |ingredient|
ingredient_count[ingredient.name] += 1
end
end
ingredient_count.sort_by{ |ing... | true |
fccadaaf47c8465be1ec4f9fcad2e06d1e9e99c0 | Ruby | mcousin/tippspiel | /spec/models/matchday_spec.rb | UTF-8 | 5,124 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
describe Matchday do
context "associations" do
it { should belong_to(:league) }
it { should have_many(:matches).dependent(:destroy) }
end
context "method start" do
subject { FactoryGirl.build(:matchday) }
context "should have a default start if it has no matches" do
... | true |
e4001b6a436c849651f63a4ff910ac3ef7042394 | Ruby | ryanatwork/google-civic | /lib/google-civic.rb | UTF-8 | 555 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'google-civic/client'
module GoogleCivic
class << self
# Alias for GoogleCivic::Client.new
#
# @return [GoogleCivic::Client]
def new(options={})
GoogleCivic::Client.new(options)
end
# Delegate to GoogleCivic::Client.new
def method_missing(method, *args, &block)
return... | true |
aafe92292ae5155a4edb2801b322acf01d3e5611 | Ruby | fuchsto/aurita | /lib/aurita/modules/gui/lang.rb | UTF-8 | 2,865 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
require('yaml')
class Language_Pack
def initialize(pack, params={})
@lang = params[:lang].to_sym
@plugin = params[:plugin].to_sym
@pack = pack
end
def [](symbol)
s = @pack[@plugin][@lang][symbol] if @pack[@plugin] && @pack[@plugin][@lang]
return s if s
s = @pack[:main][@lang][symbo... | true |
8680c7f6a028aebe20adaba49ce431925ca66acd | Ruby | Elian1978/ruby_training | /1_strings.rb | UTF-8 | 284 | 3.71875 | 4 | [] | no_license | a= "Esto es un lindo string"
b = "Otro string"
#En ruby casi todo es un objeto
puts a.length
puts b.length
#string de multiples lineas
c ='Esto es\nun string\nde multiples lineas'
puts c
age = 42
#Interpolacion de variables solo funciona con comillas dobles
puts "Mi edad es, #{age} " | true |
df9e89c18e1421b53a5de670612b7e49e21bb752 | Ruby | gustavokath/advent-of-code-2020 | /18B/main.rb | UTF-8 | 361 | 3.09375 | 3 | [] | no_license | sum = 0
$stdin.each_line do |line|
expression = line.strip.split(' ')
sum_idx = []
expression.each_with_index do |v, idx|
sum_idx.push idx if v == '+'
end
sum_idx.each do |idx|
expression[idx-1] = "(#{expression[idx-1]}"
expression[idx+1] = "#{expression[idx+1]})"
end
value = eval(expression... | true |
a24b5de450f43db99565f78931395e86359356c5 | Ruby | vannak1/ttt-with-ai-project-v-000 | /lib/game.rb | UTF-8 | 895 | 3.4375 | 3 | [] | no_license | class Game
include GameStatus::InstanceMethods
attr_accessor :board, :player_1, :player_2
def initialize(player_1 = Player::Human.new("X"), player_2 = Player::Human.new("O"), board = Board.new)
@player_1 = player_1
@player_2 = player_2
@board = board
end
def turn
player = current_player
... | true |
6327b6eb968c3ee939da90c3341baeddc5a23114 | Ruby | fukuiretu/ruboty-todoist | /example/example.rb | UTF-8 | 799 | 2.546875 | 3 | [
"MIT"
] | permissive | require "open-uri"
require "pp"
require "json"
require 'time'
require 'dotenv'
Dotenv.load
API_URL = "https://todoist.com/API/v6"
# params = { token: TOKEN }
# request_url = "#{API_URL}/get_all_completed_items?#{URI.encode_www_form(params)}"
params = { token: ENV["TODOIST_TOKEN"], seq_no: 0, resource_types: '["all"]'... | true |
e1131524b60d4b8153093ca80bdca41da7277d4c | Ruby | taratip/chillow | /lib/occupant.rb | UTF-8 | 156 | 3.140625 | 3 | [] | no_license | class Occupant
attr_reader :first_name, :last_name
def initialize(firstname, lastname)
@first_name = firstname
@last_name = lastname
end
end
| true |
e32e5b0b9c3b4e87e702810acdbec0bcb38634f5 | Ruby | Elenkanee/ita | /hw_23/lib/script_23_01.rb | UTF-8 | 654 | 2.875 | 3 | [] | no_license | # ========================================================================
# Script = __FILE__
# ========================================================================
# Description = "This is a description of the script"
# Name = "Your Name"
# Email = "your@email.com"
# ======================================... | true |
6a5002112a8a8a9995ce44437a80bd1182478e1d | Ruby | monorkin/FER-RASUS | /first_assignment/Klijent/client.rb | UTF-8 | 7,964 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require 'socket'
require 'securerandom'
require 'net/http'
require 'singleton'
require 'csv'
require 'json'
require 'logger'
LOGGER = Logger.new(STDOUT)
$stdout.sync = true
class Reading
ATTRIBUTES = %i[temperature pressure humidity co no2 so2].freeze
attr_reader :data
attr_reade... | true |
804db4c2c8dc560a12df4dcdf4b68e28346e9adb | Ruby | chrishunt/exercises | /2020-02-19-max-in-subarray/solution.rb | UTF-8 | 202 | 3.03125 | 3 | [] | no_license | class Solution
def self.max_values(array:, k:)
max_values = []
i = 0
while (i + k) <= array.size
max_values.push(array[i..i+k-1].max)
i += 1
end
max_values
end
end
| true |
5aeea403361095297625cf82442fc40f8d0891d6 | Ruby | ankane/lockbox | /lib/lockbox/padding.rb | UTF-8 | 1,254 | 3.234375 | 3 | [
"MIT"
] | permissive | module Lockbox
module Padding
PAD_FIRST_BYTE = "\x80".b
PAD_ZERO_BYTE = "\x00".b
def pad(str, **options)
pad!(str.dup, **options)
end
def unpad(str, **options)
unpad!(str.dup, **options)
end
# ISO/IEC 7816-4
# same as Libsodium
# https://libsodium.gitbook.io/doc/padd... | true |
b6609393a501c095da3dbf4afa0e88d95ab37751 | Ruby | orbanbotond/ruby_exercise | /spec/algorythms/alg_future_training_01_tree_depth_spec.rb | UTF-8 | 903 | 3.25 | 3 | [] | no_license | require 'spec_helper'
describe 'Tree depth' do
# you can use puts for debugging purposes, e.g.
# puts "this is a debug message"
def solution(a)
if a.l.nil? && a.r.nil?
0
else
d1 = d2 = 0
d1 = 1 + solution(a.l) if a.l
d2 = 1 + solution(a.r) if a.r
d1 > d2 ? d1 : d2
end
... | true |
ef460c40e323b2e518b664948ff1b6aef8b8a4ad | Ruby | chn-challenger/test_rspec | /ch9_e1_spec.rb | UTF-8 | 906 | 3.59375 | 4 | [] | no_license | def old_roman_numeral num
num_of_m = (num/1000).to_i
num_of_d = ((num%1000)/500).to_i
num_of_c = ((num%500)/100).to_i
num_of_l = ((num%100)/50).to_i
num_of_x = ((num%50)/10).to_i
num_of_v = ((num%10)/5).to_i
num_of_i = (num%5).to_i
roman = "#{'M'*num_of_m}#{'D'*num_of_d}#{'C'*num_of_c}#{'L'*num_of_l}... | true |
2c58408d7622a06c4bb6cfae77583e3f25406d2b | Ruby | enricogenauck/labhound | /spec/models/payment_gateway_subscription_spec.rb | UTF-8 | 2,439 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
describe PaymentGatewaySubscription do
context '.subscribe' do
context 'existing subscription' do
it 'appends id to repo_ids metadata' do
stripe_subscription = MockStripeSubscription.new(repo_ids: [1])
subscription = PaymentGatewaySubscription.new(stripe_subscription)... | true |
8ba4f56dc290a144ef1c7ff89d17276d767a4632 | Ruby | jkeen/comma_splice | /lib/comma_splice/helpers/option_scorer.rb | UTF-8 | 3,059 | 3.078125 | 3 | [
"MIT"
] | permissive | module CommaSplice
# scores options based on how likely they are to be correct
class OptionScorer
attr_reader :option
def initialize(option, separator: ',')
@option = option
@start_score = 100
@separator = separator
end
def breakdown
score = @start_score
breakdown... | true |
33cf48fca6d657553c622b485f1c484ae1c1e0a6 | Ruby | vaxinate/stupid-board-game | /lib/creature.rb | UTF-8 | 1,085 | 2.8125 | 3 | [] | no_license | class Creature < Chingu::GameObject
attr_accessor :name, :speed, :position, :enchantments
attr_writer :selected
def self.selected
all.select { |cr| cr.selected? }
end
def initialize(options)
super
@name = options[:name] if options[:name]
@board = options[:board] if options[:board]
end
d... | true |
330d8f45459de5a57a0c59cfd8ac2b8bf85f3021 | Ruby | omareltahasantos/ruby | /expresion_regular.rb | UTF-8 | 1,639 | 3.90625 | 4 | [] | no_license | m1 = /Ruby/.match("El futuro de Ruby")
puts m1 #Devuelve la palabra en caso de encontrarla
puts m1.class #Devuelve MatchData en caso de haberlo en contrado o nil en caso contrario.
#Para buscar caracteres especiales se usa el escape \
m2 = /\?/.match("Estais bien?")
puts m2
puts m2.class
#Si queremos buscar una p... | true |
f1bc59ec7cca18abba5a8f5247b7ba8c47bb96ef | Ruby | llpereiras/tictactoe | /support/colorize.rb | UTF-8 | 688 | 3.5625 | 4 | [] | no_license | class Colorize
def self.colorize(text, color = "default", bgColor = "default")
colors = {"default" => "38","black" => "30","red" => "31","green" => "32","brown" => "33", "blue" => "34", "purple" => "35",
"cyan" => "36", "gray" => "37", "dark gray" => "1;30", "light red" => "1;31", "light green" => "1;32", "... | true |
e877c7c13a808247c78b28450b12857f58e9fc43 | Ruby | atecdeveloper/ruby_lessons | /plus_exercises/exercise9.rb | UTF-8 | 59 | 2.5625 | 3 | [] | no_license | #Hash with nested array
hash = {key: [1 , 2], key2: [3, 4]} | true |
d0697d5196063d3cd1486400836aa131066a85c9 | Ruby | matthewford/merb-meet-aop | /gems/gems/aquarium-0.4.0/lib/aquarium/aspects/dsl/aspect_dsl.rb | UTF-8 | 2,079 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'aquarium/aspects/aspect'
require 'aquarium/utils/type_utils'
# Convenience methods added to Object to promote an AOP DSL. If you don't want these methods added to Object,
# then only require aspect.rb and create instances of Aspect.
module Aquarium
module Aspects
module DSL
module AspectDSL
... | true |
9d9b4343ed4edb5aa1a7282ea65220e6215d18ef | Ruby | AnguillaJaponica/Ruby_Library_For_Contests | /ABC/ABC129/C.rb | UTF-8 | 340 | 2.609375 | 3 | [] | no_license | n, m = gets.split.map(&:to_i)
mod = 1_000_000_007
dp = Array.new(n + 2, 0)
a = []
dp[0] = 1
m.times do |i|
a[i] = gets.to_i
dp[a[i]] = -1
end
n.times do |i|
next if dp[i] == -1
if dp[i + 1] != -1
dp[i + 1] += dp[i]
dp[i + 1] %= mod
end
if dp[i + 2] != -1
dp[i + 2] += dp[i]
dp[i + 2] %= mod
... | true |
6e7ed4c5d068f69efbb3cb353db1136547949cec | Ruby | JorgeDDW/pokedex | /pokedex.rb | UTF-8 | 1,082 | 2.953125 | 3 | [] | no_license |
require 'telegram/bot'
require 'net/http'
require 'rest-client'
require 'json'
require 'open-uri'
token = 'Toke goes here'
puts "Ready to Go!"
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
pokemon_search = message.text
case message.text
when '/start'
p "starting"
b... | true |
11ea9ab29e89e8932daf78c9cd629e9886a4047e | Ruby | s-rayed/W2D3 | /lighthouse-test-oop-RETEST_rev1/spec/04_giant_salmon_and_tuna.rb | UTF-8 | 625 | 2.859375 | 3 | [] | no_license | require_relative 'spec_helper'
describe GiantSalmon do
before :each do
@salmon = GiantSalmon.new
end
it "should be a Fish" do
expect(@salmon).to be_a(Fish)
end
it "should weigh 4 kgs" do
expect(@salmon.weight).to eq(4)
end
it "should be worth 30 dollars" do
expect(@salmon.value).to eq(... | true |
83983fa67d1fb3516623f15392dcc36c5e8589e7 | Ruby | mliu-dark-knight/CS242 | /MP2/src/cs_air.rb | UTF-8 | 6,979 | 3.203125 | 3 | [] | no_license | require_relative 'graph'
require 'pp'
require 'json'
class CSAir < Graph
# get name of all cities
def allCity()
return allVerticesInfo('name')
end
# get longest single flight
def longestSingleFlight()
return reduceVariable('edges', 'distance', '>')
end
# get shortest single flight
def shortes... | true |
83427a2ddacaba6ae5d8c442044257179db0550f | Ruby | mstanislav/basecampnext | /lib/basecampnext.rb | UTF-8 | 1,356 | 2.625 | 3 | [] | no_license | require 'yaml'
require 'httparty'
require 'json'
class BasecampNext
def initialize(username = nil, password = nil, account = nil, api = nil)
@username = username || BASECAMPNEXT_CONFIG['username']
@password = password || BASECAMPNEXT_CONFIG['password']
@account = account || BASECAMPNEXT_CONFIG['account'... | true |
2b881a360931c1274c08765d3d46d42db1b0be2f | Ruby | ximengch/ruby_sample | /chapter7_8/hello_class.rb | UTF-8 | 763 | 3.875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
class HelloWorld
@@count=0 #类方法
attr_accessor:name
def initialize(myname="Ruby")
@name=myname
end
def hello
@@count+=1
puts "Hello,world.I am #{@name}"
end
def HelloWorld.hello(name) #类方法
puts "#{name} said Hello.这是类方法"
end
class<<self ... | true |
83f2a0fa22508087d937046cf9560fdd2a3904a6 | Ruby | realalien/rubyplayground | /ktools/test.rb | UTF-8 | 956 | 2.734375 | 3 | [] | no_license | #encoding:UTF-8
# --------------------------------
# self explanable where the knowledge(assumption) is got or can be confirmed.
# following the example function to demonstrate funcitionalities similar to the ones appear in Python's method comments, DSL, and
def administrative_divisions_of_china
meta = { }... | true |
8e39348d401bd010c34c929d677b89f8f0adb626 | Ruby | timcmartin/pdfmetadata | /app/models/chart.rb | UTF-8 | 839 | 2.546875 | 3 | [] | no_license | # chart.rb
class Chart
include Filemover
include ActiveModel::Model
attr_accessor(:title, :path, :composer, :genre, :keywords, :format, :filename)
validates_with ChartValidator
def initialize(attributes = {})
super
end
def pdf_hash
{ Title: title, Author: composer, Keywords: keywords, Subject:... | true |
1c0c9d499eb16d6f87342d3ce654dfddd0e282c6 | Ruby | tomyancey/coderbyte_solutions | /letter_changes.rb | UTF-8 | 807 | 4.3125 | 4 | [] | no_license | =begin
Have the function LetterChanges(str) take the str parameter being passed and modify it using the following algorithm. Replace every letter in the string with the letter following it in the alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally return t... | true |
8b1f1e2d3506ba2d4d1c639775971f27e77537fd | Ruby | cody-castro/say-hello-ruby-nyc-fasttrack-062020 | /say_hello.rb | UTF-8 | 164 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Build your say_hello method here
# say_hello = "Hello Ruby Programmer"
name = "Gabriela"
def say_hello(name = "Ruby Programmer")
puts "Hello #{name}!"
end
| true |
ddd3bcfd198eeb315e63205ba75b1becb0d14c4b | Ruby | erhsparks/Poker_FiveCardDraw | /spec/hand_spec.rb | UTF-8 | 3,276 | 3.640625 | 4 | [] | no_license | require 'rspec'
require 'hand'
describe Hand do
subject(:hand) { Hand.new }
let(:card1) { double("card1", :suit => :♠, :value => :"10") }
let(:card2) { double("card2", :suit => :♠, :value => :J) }
let(:card3) { double("card3", :suit => :♠, :value => :Q) }
let(:card4) { double("card4", :suit => :♠, :value => ... | true |
598d6881a76443c3e33721226e46b0120babb813 | Ruby | Val-Lee/epam | /1.rb | UTF-8 | 1,118 | 3.203125 | 3 | [] | no_license | class University
end
class Faculty < University
end
class Group < Faculty
attr_accessor :supahash
def initialize(name)
@name = name
@supahash = Hash.new(@name)
end
def add_student(student)
@supahash[@name] = [student]
end
def show_group
return @supahash
end
end
class Student < Group
a... | true |
7a8ec6bec6259ab0c454c210f6c03fe7a2bbbd15 | Ruby | CodeandoMexico/retos-civicos | /spec/models/location_spec.rb | UTF-8 | 2,255 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
describe Location do
describe 'search' do
fixtures :locations
describe 'given a valid query' do
describe 'given the search result has a locality' do
it 'should return a hash with state, city, and locality' do
expect(Location.search('64000').first.locality).to eq ... | true |
c6efea32d7cf5147d3a0baa77ceeceb0c91cd9ea | Ruby | bomattsson/battleship | /spec/player_spec.rb | UTF-8 | 735 | 2.984375 | 3 | [] | no_license | require 'grid'
require 'player'
describe 'Player' do
subject { Player.new }
it 'it creates a my_board' do
expect(subject.my_board).to be_kind_of Grid
end
it 'can place ship' do
subject.place_ship(:A1)
expect(subject.my_board.grid[:A1]).to eq "s"
end
it 'can receive a hit' do
subject.pla... | true |
5aac3de6d99ea6c13540f42e80cdad61e04e4ab9 | Ruby | AdamGoodApp/zero-robot | /lib/queue/ScheduledQueue.rb | UTF-8 | 3,177 | 2.546875 | 3 | [] | no_license | require 'concurrent/scheduled_task'
require 'concurrent/executor/thread_pool_executor'
require 'concurrent/utility/processor_counter'
module ActiveJob
module QueueAdapters
class ScheduledQueue
def initialize(**executor_options, &block)
@config = Configuration.new(&block)
@scheduler = Schedu... | true |
845c30563203b8d4f9d3d3927e4ebb4e5620fda6 | Ruby | JulieLev/bank-tech-test | /lib/bank_account.rb | UTF-8 | 854 | 3.40625 | 3 | [] | no_license | require 'date'
require_relative 'transaction'
class BankAccount
attr_reader :show_balance, :date, :read_transactions
def initialize
@balance = 0
@date = Date.today
@transactions = []
end
def withdraw(amount, date=Date.today)
withdrawal_update_balance(amount)
add_transaction('debit', amou... | true |
9e8c603182c025d65f3d406a0c37fb000fd569fe | Ruby | nicolasm/jekyll-metaweblog | /post.rb | UTF-8 | 4,474 | 3.1875 | 3 | [] | no_license | require 'yaml'
class Post
attr_accessor :base, :filename, :date, :body, :data, :type, :slug
def initialize(base, filename)
self.base = base
self.filename = filename
self.slug = filename
self.date = Date.today
self.type = :page
# the page itself
... | true |
1e1532f41e5bec77bce66ab7a49f6fd68b3911ce | Ruby | iangraham20/cs214 | /labs/01/Bird.rb | UTF-8 | 430 | 3.609375 | 4 | [] | no_license | #!/usr/bin/ruby
# Bird.rb Defines a Bird superclass to be extended by specific bird sub-classes
# Begun by: Dr. Adams, for CS 214 at Calvin College
# Completed by: Ian Christensen, for CS 214 at Calvin College
# Date: Spring, 2018
class Bird
attr_reader :name
def initialize(name)
@name = name
end
def call
'... | true |
b66c957cd6101cdcd804f942aa5da8309b5b06aa | Ruby | ioquatix/geospatial | /lib/geospatial/circle.rb | UTF-8 | 3,053 | 3.1875 | 3 | [
"MIT"
] | permissive | # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use... | true |
b59d42fdbc82ff6666271596068a55e2de142bd9 | Ruby | jinstrider2000/dynamic-orm-lab-v-000 | /lib/student.rb | UTF-8 | 346 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../config/environment.rb"
require 'active_support/inflector'
require 'interactive_record.rb'
class Student < InteractiveRecord
self.column_names.each do |col_name|
attr_accessor col_name.to_sym
end
def self.find_by_name(name)
DB[:conn].execute("SELECT * FROM #{self.table_name} WHERE n... | true |
f9e215f324f1c7a8d63719e556c21e73ed65b257 | Ruby | ECHOInternational/your_membership | /lib/your_membership/base.rb | UTF-8 | 7,626 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'httparty/ym_xml_parser'
module YourMembership
# Base Class inherited by all Your Membership SDK Classes.
class Base
include HTTParty
base_uri YourMembership.config[:baseUri]
# rubocop:disable Style/ClassVars
# Call IDs are usually tied to sessions, this is a unique call id for use whene... | true |
01674503f6dfb104ba865a1297650354af631fdc | Ruby | aaduru/technical_interview_problems | /remove_nth_node.rb | UTF-8 | 480 | 3.6875 | 4 | [] | no_license | class ListNode
attr_accessor :val, :next
def initialize(val)
@val = val
@next = nil
end
end
def remove_nth_from_end(head, n)
temp_node = ListNode.new(0)
temp_node.next = head
len = 0
first = head
while first != nil
len += len
first = first.next
end
len = ... | true |
ecc1b33a06dd319956a8b39710aa17d4b01594bf | Ruby | sizucca/meeting-schedule | /app/helpers/schedule_helper.rb | UTF-8 | 2,778 | 2.90625 | 3 | [] | no_license | # coding: utf-8
module ScheduleHelper
#
# selectのoptions:年
#
def select_year_options(options = {})
select_year_options = []
time_now = Time.zone.now
start_year = time_now.year.to_i
end_year = start_year + (options[:over_year] ||= 10).to_i
(start_year).upto(end_year) do |year|
sele... | true |
ffab0ede5c5e7d87cba8852e39a890bf3b7db3a6 | Ruby | arimay/time_scheduler | /sample/base_8.rb | UTF-8 | 391 | 2.953125 | 3 | [
"MIT"
] | permissive | require "time_scheduler"
Scheduler = TimeScheduler.new
cyclic1 = {
msec: "*/100"
}
cyclic2 = {
sec: "*/2"
}
Scheduler.wait( **cyclic1 ) do |time|
p [time.iso8601(3), :cyclic1]
end
goal = Time.now + 5
Scheduler.wait( **cyclic2 ) do |time|
p [time.iso8601(3), :cyclic2]
if time > goal
p [time.iso8601... | true |
5556c29c4c3fa92cdd05f31364271dc5b1cd9b56 | Ruby | cgaraudy/ruby_practice | /bartender.rb | UTF-8 | 287 | 4.15625 | 4 | [] | no_license | puts "Hey, what ya drinkin'?"
answer = gets.chomp
puts "Okay, cool, one #{answer} coming right up. Wait, how old are you?"
age = gets.to_i
x = 21 - age
if age >= 21
puts "Right on."
else
puts "I can't serve you. You have to wait #{x} years 'til you're old enough to drink."
end
| true |
c7862e7a9ed49e00739a2a2d8e6ec15bfc2f0c86 | Ruby | stuarthalloway/relevance-ruby-samples | /rails_samples/vendor/plugins/relevance_tools/test/relevance/object_additions_test.rb | UTF-8 | 838 | 2.671875 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), "/../test_helper")
require 'relevance/object_additions'
class ObjectAdditionsTest < Test::Unit::TestCase
def test_should_get_metaclass
obj = Object.new
metaklass = (class << obj; self; end;)
assert_equal metaklass, obj.metaclass
end
def test_should_be_able... | true |
e7e1dfd144d8caaf344960dbb94494d719de28b3 | Ruby | JNaftali/phase-0-tracks | /ruby/secret_agents.rb | UTF-8 | 1,303 | 4.75 | 5 | [] | no_license | #loop through each letter of the string.
#increase each letter, using a counter
#to keep track of where it is in the word
#
def encrypt (greeting)
letter = 0
result = ""
# use the index to print
while letter < greeting.length
if greeting[letter] == "z"
result += "a"
elsif greeting[letter] == " ... | true |
7244ab0b33133a8104faba7b1c4b137e8c8dbb40 | Ruby | ggwc82/takeaway-challenge | /lib/menu.rb | UTF-8 | 119 | 2.5625 | 3 | [] | no_license | class Menu
def initialize
@show = {ribs: 3, beef: 4, rolls: 3, chips: 2, pies: 5}
end
attr_reader :show
end | true |
3f69ec5440e07bb09a795804678c55847d27925b | Ruby | perplexes/porcupine | /lib/porcupine/dataflow/map_reduce.rb | UTF-8 | 1,290 | 2.921875 | 3 | [
"MIT"
] | permissive | class Porcupine
# In MapReduce terms, this is Input/Map together.
# Map and Reduce, at least in framework code, are the same.
class MapFunction < Porcupine
def getFallback
[]
end
end
# TODO: This doesn't take into account other threads working currently,
# we need some thread sharing instead ... | true |
b3a8bd65eb926725f41900268098b821c6a9d946 | Ruby | busyra/proga | /output.rb | UTF-8 | 2,893 | 3.640625 | 4 | [] | no_license | class Output
require 'pry'
def initialize
@dependent_hash = {}
@installed_components = []
read_text
end
def process(command, components)
if command == 'DEPEND' then depends(components)
elsif command == 'INSTALL' then installs(components)
elsif command == 'REMOVE' then removes(component... | true |
0443abfc59322836d617394bfa5629c5b08e0188 | Ruby | pry/pry-exception_explorer | /lib/pry-exception_explorer/commands.rb | UTF-8 | 3,511 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'pry-stack_explorer'
module PryExceptionExplorer
module ExceptionHelpers
include PryStackExplorer::FrameHelpers
private
def exception
frame_manager.user[:exception]
end
def in_exception?
frame_manager && exception
end
def last_exception
_pry_.last_exception
... | true |
0edf80aa5425768e820c112ddf8da2f06d0399a6 | Ruby | rmeritz/coursera | /algorithms-divide-conquer/sort.rb | UTF-8 | 3,831 | 3.171875 | 3 | [] | no_license | #!/usr/bin/env ruby
gem 'minitest'
require "minitest/autorun"
class Array
def swap!(a, b)
self[a], self[b] = self[b], self[a]
self
end
end
class Sort
def brute_force_sort l
naive_sort([], l)
end
def merge_sort l
len = l.length
if len <= 1
l
else
merge(merge_sort(l.take... | true |
6ba31cb491a17254f4d81ec6452921c80f78065c | Ruby | michaelsmith19951/isbn_number_web_app | /app.rb | UTF-8 | 1,179 | 2.984375 | 3 | [] | no_license | require "sinatra"
require_relative "isbn_functions.rb"
enable :sessions
get '/' do
isbn_output = params[:isbn_output]
validity_final = params[:validity_final]
isbn_orig = params[:isbn_orig]
isbn2 = params[:isbn2]
erb :isbn_number_main_page, locals:{isbn2: isbn2, isbn_output: isbn_output, isbn_orig: isbn_orig, va... | true |
8b61e7e09b1c2a74a666cda09c4e1a02477f6dca | Ruby | wildDAlex/rus_bank | /test/test_rus_bank.rb | UTF-8 | 4,099 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
require "test_helper"
class TestRusBank < Test::Unit::TestCase
VALID_BIC = "044585216"
INVALID_BIC = "0445852169999"
VALID_INT_CODE = "450000650"
INVALID_INT_CODE = "450000650999999"
VALID_REG_NUMBER = "316"
INVALID_REG_NUMBER = "289375237580009"
VALID_REGION = "16"
INVALID_REGION = ... | true |
886ccfe75aa83d20be58b7868c6bd245149e7968 | Ruby | ZinChen/bakery-ruby | /bin/bakery_start.rb | UTF-8 | 1,002 | 3.015625 | 3 | [] | no_license | require_relative '../lib/bakery'
require_relative '../lib/order'
require_relative '../lib/order_breakdown'
require_relative '../lib/order_parser'
require_relative '../lib/product'
vegemite_scroll = Product.new('Vegemite Scroll', 'VS5')
blueberry_muffin = Product.new('Blueberry Muffin', 'MB11')
croissant = Product.new(... | true |
d829c1606083c158c0f856d4030dcf0d54a3584e | Ruby | justindelatorre/rb_101 | /small_problems/easy_9/easy_9_4.rb | UTF-8 | 1,045 | 4.46875 | 4 | [] | no_license | =begin
Write a method that takes an integer argument, and returns an Array of all
integers, in sequence, between 1 and the argument.
You may assume that the argument will always be a valid integer that is greater
than 0.
Inputs:
- integer
Outputs:
- array (of integers)
Requirements:
- output array should include in... | true |
13ff474119e1b3e86d72d124391597b3c7651daa | Ruby | grh/scavenger-hunt | /lib/tasks/our_doc.rb | UTF-8 | 3,818 | 2.9375 | 3 | [] | no_license | module OurDoc
class Comment
attr_accessor :type, :content
def initialize (type)
@type = type
@content = []
end
end
def self.get_comments(t)
# initialize empty comments array and grab all .rb files
comments = []
rbfiles = File.join('**', '*.rb')
# iterate o... | true |
4645ada299b984215373b59e75e12bcb8743d646 | Ruby | mystioreo/array_intersection | /lib/array_intersection.rb | UTF-8 | 440 | 3.5625 | 4 | [] | no_license | #space complexity O[n], time complexity O[n*m]
# Creates a new array to return the intersection of the two input arrays
def intersection(array1, array2)
i = 0
intersect = []
unless array1 == nil || array2 == nil
until array1[i] == nil
j = 0
until array2[j] == nil
if array1[i] == array2[j]
... | true |
f11afe7239a581f457f62a648e93ca15327d65ac | Ruby | jeffreyzhen/chillow | /lib/dwelling.rb | UTF-8 | 236 | 3.0625 | 3 | [] | no_license | class Dwelling
attr_reader :address, :city_or_town, :state, :zipcode
def initialize(address, city_or_town, state, zipcode)
@address = address
@city_or_town = city_or_town
@state = state
@zipcode = zipcode
end
end
| true |
06fa42a2c8bf5d95fd28d60213781822df61f827 | Ruby | EJLarcs/playlister-cli-web-0715-public | /app/models/artist.rb | UTF-8 | 1,060 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
require_relative 'song'
require_relative 'genre'
class Artist
# code here
#attr_reader as genres
attr_accessor :name, :song, :genres
@@artists = []
def initialize(name=nil)
@name = name
@@artists << self
@songs = []
@genres = []
end
def self.all
@@artists
end
... | true |
3370bb8a536d80c6d9021a773da97af9e2200c4a | Ruby | lrnzgll/newgps | /app/services/weather.rb | UTF-8 | 258 | 2.6875 | 3 | [] | no_license | module Weather
attr_reader :lat, :lng, :location
def initialize(lat,lng, location = nil)
@lat = lat
@lng = lng
@forecast ||= ForecastIO.forecast(@lat,@lng, params:{ exclude: 'flags,minutely,hourly,alert'})
@location = location
end
end
| true |
ef0ea433239728fa28b9e13cf06903a2d4cd5f4a | Ruby | kathleen-carroll/backend_module_0_capstone | /day_7/ceaser_cipher.rb | UTF-8 | 731 | 3.296875 | 3 | [] | no_license | cipher = {
'A' => 'X',
'B' => 'Y',
'C' => 'Z',
'D' => 'A',
'E' => 'B',
'F' => 'C',
'G' => 'D',
'H' => 'E',
'I' => 'F',
'J' => 'G',
'K' => 'H',
'L' => 'I',
'M' => 'J',
'N' => 'K',
'O' => 'L',
'P' => 'M',
'Q' => 'N',
'R' => 'O',
'S' => 'P',
'T' => 'Q',
'U' => 'R',
'V' => 'S',
... | true |
60b3bec6bd3fb78ba35057c04a4f9526887f052e | Ruby | garedean/tamagotchi_sinatra | /spec/tamagotchi_spec.rb | UTF-8 | 1,271 | 3.265625 | 3 | [] | no_license | require('rspec')
require('tamagotchi')
require('pry')
describe('Tamagotchi') do
describe('#name') do
# get name
it('returns the name string') do
expect(Tamagotchi.new('Bob').name).to(eq('Bob'))
end
# set name
it('sets a name for the tamagotchi') do
expect(Tamagotchi.new('Bob').name =... | true |
a88aedbf52aa9c6e8b1784ea82587f5523f2b1fc | Ruby | jasonporritt/Hextown | /src/hexagon.rb | UTF-8 | 1,410 | 3 | 3 | [] | no_license | #class HexagonView < ActorView
# def draw(target, x_off, y_off, z)
# radius = 25
# x = @actor.x + x_off - radius
# y = @actor.y + y_off - radius
#
# rotation = @actor.rotation
# draw_ngon target, x,y, rotation, radius, 6, [200,200,255,140], z
# target.draw_line x,y, x+offset_x(rotation,radius), y+off... | true |
ff0cda846f1c0edc9e3d58c519f2bc9fa33e9604 | Ruby | daniero/code-challenges | /aoc2018/ruby/15/io.rb | UTF-8 | 1,167 | 3.921875 | 4 | [] | no_license | require 'set'
ATTACK = 3
HEALTH = 200
Unit = Struct.new(:x, :y, :team, :hp, :attack)
def read_input(filename)
units = Set[]
walls = Set[]
height = 0
width = 0
File.open(filename).each_line.with_index do |row, y|
row.chomp.each_char.with_index do |cell, x|
if cell == 'E'
units << Unit.new... | true |
7378ce11626b08872768204001fa5a650bc05a29 | Ruby | CartoDB/cartodb | /spec/helpers/unique_names_helper.rb | UTF-8 | 819 | 2.625 | 3 | [
"LicenseRef-scancode-generic-cla",
"BSD-3-Clause"
] | permissive | # These helpers are meant to be used in tests to generate random data which may collide, e.g: usernames
# The methods are parameter-less in purpose, so it is easier to modify the name generation if needed
module UniqueNamesHelper
@@item_count = 0
def unique_string
sprintf '%08d', unique_integer
end
def un... | true |
f78a7b66d03115402d41eadde82f7dfb6a3b2e20 | Ruby | hectorip/Ruby-Exercises | /Easy/SelfDescribingNumbers.rb | UTF-8 | 588 | 3.375 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
line.strip!
if line != ''
digits = []
success = true
line.each_char.with_index do | digit, index |
n = digit.to_i
if(digits[index] == nil)
digits[index] = [n,0]
else
digits[index][0] = n
end
if digits[n] != nil
... | true |
8136a69c322fd4c862d57abb67b83fbc2d982ad5 | Ruby | leav/S.TEST | /Scripts/Game_ActionResult.rb | UTF-8 | 6,745 | 3.046875 | 3 | [] | no_license | #encoding:utf-8
#==============================================================================
# ■ Game_ActionResult
#------------------------------------------------------------------------------
# 战斗行动结果的管理类。本类在 Game_Battler 类的内部使用。
#==============================================================================
cl... | true |
565852f10e984a52d9b32c02e88734c85616fc7b | Ruby | eac/predictomatic | /lib/predictomatic/input/feature.rb | UTF-8 | 374 | 2.765625 | 3 | [] | no_license | module Predictomatic::Input
class Feature
attr_reader :name, :value
def initialize(name, value = nil)
@name = name
@value = value
end
def to_s
pair = [ escaped_name, value ]
pair.compact!
pair.join(':')
end
def escaped_name
escaped = name.to_s
esc... | true |
dd72b9b3f06f79807ffba4d99a33bbb58f140911 | Ruby | eelsivart/nessus-report-downloader | /nessus6-report-downloader.rb | UTF-8 | 8,422 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
#################################################################################################
# Name: Nessus 6 Report Downloader
# Author: Travis Lee
#
# Version: 1.0
# Last Updated: 2/28/2016
#
# Description: Interactive script that connects to a specified Nessus 6 server using the
# Nessus R... | true |
665cb3e7d4e4a3d0e1085dee3bcd18f9f33f1da8 | Ruby | janpieper/Onions-Rails-API | /app/models/onion.rb | UTF-8 | 3,215 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'base64'
require 'openssl'
class Onion < ActiveRecord::Base
attr_accessible :HashedInfo, :HashedTitle, :HashedUser, :Title_Iv, :Info_Iv, :Title_AuthTag, :Info_AuthTag
# Take Onions from DB and decrypt them all after a User logs in
def self.decrypted_onions_with_key(onions,key)
if onions && key
... | true |
1c481e2783d42be650a1d483f61095dd6b9f9dfb | Ruby | rsoemardja/Codecademy | /Ruby/Learn Ruby/Object-Oriented Programming, Part II/Object-Oriented Programming, Part II in Ruby/The Marriage of Module and Classes.rb | UTF-8 | 768 | 4.03125 | 4 | [] | no_license | # In this exercise we will mixed together the behaviors of a class and a module
#When a module is used to mix additional behavior and information into a class
# It is called a mixin
# Mixins allows us to customize a class without having to rewrite code
# in this code they are define the jump method in the Action modu... | true |
5147cdd5c7cf7dd0442c8f1586f8dd6a8aa89f5a | Ruby | greghxc/advent-of-code | /main/day_06/lib.rb | UTF-8 | 600 | 3.375 | 3 | [] | no_license | class CodeFinder
def count_chars(data)
count = []
data.each do |d|
d.chars.each_with_index do |c, i|
count[i] = {} unless count[i]
count[i][c] ? count[i][c] += 1 : count[i][c] = 1
end
end
count
end
def get_char(count, day)
grab = [
->(c) { c.sort_by { |_, v| ... | true |
e5d0f084d2873f3a69c314357fae4dccec416ecd | Ruby | glassbead0/homework_assignments | /methods_and_flow_control/fizz_buzz.rb | UTF-8 | 363 | 4.0625 | 4 | [] | no_license | #!/usr/bin/env ruby
# print the numbers 1 - 100
# if the number is divisible by 3, print Fizz
# if the number is divisible by 5, print Buzz
# if the number is divisible by 3 and 5, print FizzBuzz
(1..100).each do |x|
if (x % 15).zero?
puts 'FizzBuzz'
elsif (x % 3).zero?
puts 'Fizz'
elsif (x % 5).zero?
... | true |
df1981c27e6c2700b173042fed91dfd48931dede | Ruby | evantravers/euler | /ruby/31.rb | UTF-8 | 476 | 3.359375 | 3 | [] | no_license | require 'pry'
require 'set'
Options = [200, 100, 50, 20, 10, 5, 2, 1]
@total_ways = Set.new
class Array
def sum
self.inject(:+)
end
end
# list is the current position
# start is the point after which it has to search
def evaluate list, start
in_hand = list
in_hand << Options[start]
if in_hand.sum == 20... | true |
9c2c0bb350b0c4aa486d4ee4d62cbbef83890460 | Ruby | zachlatta/shirts | /lib/shirts.rb | UTF-8 | 327 | 2.671875 | 3 | [
"MIT"
] | permissive | # Require all of the ruby files in the given directory. Taken from Jekyll.
#
# @param [String] Relative path from here to the directory.
def require_dir(path)
glob = File.join(File.dirname(__FILE__), path, '*.rb')
Dir[glob].each do |f|
require f
end
end
require_dir 'shirts'
module Shirts
class << self
e... | true |
aada40e1b3706ef39309e4eb014101f9c054c170 | Ruby | ilabsea/verboice-external-step | /app/models/period_rating.rb | UTF-8 | 2,394 | 2.625 | 3 | [] | no_license | class PeriodRating < ActiveRecord::Base
validates :code, :step_id, :from_date, :to_date, presence: true
serialize :numbers, Array
belongs_to :step
validates :code, uniqueness: true
validates :code, numericality: { greater_than: 0, less_than: 100 }
validate :from_date_must_be_less_than_to_date
validate ... | true |
03ea6e397e29fc928e20ee7cf6703a3c2fa7c862 | Ruby | ImperialOctopus/avalon-app | /speech/google-cloud.rb | UTF-8 | 971 | 3 | 3 | [
"Apache-2.0"
] | permissive | require "google/cloud/text_to_speech"
client = Google::Cloud::TextToSpeech.new
input_file = "input_lines.txt"
voice = {
:language_code => "en-GB",
:name => "en-GB-Wavenet-D",
:ssml_gender => "MALE"
}
audio_config = { :audio_encoding => "MP3" }
output_directory = "en-GB-D";
unless output_directory == "" then
... | true |
dde0e0f540a671f966b3495889af99993cefaaf0 | Ruby | leequarella/dr-scripts | /lee/disarm.rb | UTF-8 | 5,919 | 2.671875 | 3 | [] | no_license | class Disarm
attr_reader :sprung, :disarmed, :more_traps
DISARMING = Regexp.union([
/not yet fully disarmed/,
/proves too difficult to manipulate/,
/something to shift/,
/lock springs out and stabs you painfully in the finger/,
/An acrid stream of sulfurous air hisses quietly/,
/A stream of ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.