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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9a7e85d1906343a475c485f72813018669ca84e9 | Ruby | mcharnay/ruby_consume_api_rest | /platanus.rb | UTF-8 | 10,567 | 2.6875 | 3 | [] | no_license | #Autor: Michel Charnay Escobar.
#Correo: michelantoine.charnay@gmail.com
#github: https://github.com/mcharnay
#imports de las gemas usadas.
require 'rest-client'
require 'json'
#Obtención de transacciones de las últimas 24 horas dadas en segudos (24 hrs) por timespan por mercado.
response1 = RestClient.get("https://... | true |
ec3e3b658beba3dd137a115412b8a8a60154f536 | Ruby | ronaldabreu-dev/Rails-Practice-Code-Challenge-Travelatr-nyc01-seng-ft-051120 | /app/models/blogger.rb | UTF-8 | 450 | 2.71875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Blogger < ApplicationRecord
has_many :posts
has_many :destinations, through: :posts
validates :name, uniqueness: true
validates :age, numericality: { greater_than: 0 }
validates :bio, length: { minimum: 30}
def likes
self.posts.map { |p| p.likes }.sum
end
def featured_post
self.posts.max_by { |po... | true |
3b44f8d3e02fc2dc075960f7a34da71c5d9b4c19 | Ruby | gregolsky/suburb | /lib/suburb/time.rb | UTF-8 | 286 | 2.671875 | 3 | [] | no_license |
require 'time'
module Suburb
class TimeConverter
def self.convert_to_milliseconds(seconds, minutes = 0, hours = 0)
seconds_in_minutes = 60 * minutes
seconds_in_hours = 3600 * hours
(seconds + seconds_in_minutes + seconds_in_hours) * 1000
end
end
end
| true |
64e15ce4b73ca638944e46d5d8d310af787b0631 | Ruby | eiji-a/epconv | /bin/image2mag.rb | UTF-8 | 1,984 | 2.65625 | 3 | [] | no_license | #!/usr/bin/ruby
#
# image2mag: apply images to virtual magazine with status
#
# usage: image2mag.rb <tank_dir>
# <tank_dir> : directory of image tank
#
require 'fileutils'
require_relative 'epconvlib'
USAGE = <<-EOS
usage: idx2magtab.rb <tank_dir>
<tank_dir> : dire... | true |
aa4475ea9787da84f69242a0aaeec0c2c1e750c2 | Ruby | bretfunk/homework | /pseudocode.rb | UTF-8 | 972 | 4.25 | 4 | [] | no_license | =begin
If you don’t input anything (just hit enter) they respond with HELLO?!
If you ask a question with any lower-case letters, they respond with I AM HAVING A HARD TIME HEARING YOU.
If you ask a question in all upper-case letters, they respond with NO, THIS IS NOT A PET STORE
The first time you say GOODBYE! they say ... | true |
02a44b1081169667b0227820831945fafd0243a3 | Ruby | oscos/launch_school | /rb101/lesson4/additional_practice/x05.rb | UTF-8 | 497 | 3.15625 | 3 | [] | no_license | =begin
Launch School: RB101 Programming Foundations - Lesson 4 - Additional Practice
ExerciseName: [Lesson 4 - Additional Practice](https://launchschool.com/lessons/85376b6d/assignments/a76c28ac)
FileName: x05.rb
Answered On: 10/12/2020
=end
# require "pry"
# require "pp"
# Find the index of the first name that start... | true |
f656f5b35556c09395e98ba07d9ed680145108ca | Ruby | GJRamos87/GA | /homework/test.rb | UTF-8 | 59 | 3.09375 | 3 | [] | no_license | ['Hi', 'Hello', 'Bienvenidos'].each do |xyz|
puts xyz
end | true |
cd455c53a0f8f1ebddff5450a941acf510e5094e | Ruby | michelson/postablr | /app/helpers/postablr/blog_helper.rb | UTF-8 | 742 | 2.515625 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
module Postablr
module BlogHelper
def sanitize_clean(html, truncate = false, link=nil)
unless truncate
Sanitize.clean(html, Sanitize::Config::RESTRICTED)
else
truncate_html(clean_html( html ), truncate , link )
end
end
def sanitize_strict(html... | true |
7528f1f4b83bcbdad275de045541eeee90940eeb | Ruby | balajimpk/aggregates | /extracted_state/project_management/issue.rb | UTF-8 | 1,707 | 2.703125 | 3 | [] | no_license | module ProjectManagement
class Issue
InvalidTransition = Class.new(StandardError)
attr_reader :changes
def initialize(state)
@changes = []
@state = state
end
def create
invalid_transition unless can_create?
apply(IssueOpened.new(data: {issue_id: state.id}))
end
... | true |
1330ff1e597ecf48a22faae57e2eb6250093eab7 | Ruby | GunioRobot/extreme-solitaire | /lib/solver.rb | UTF-8 | 4,140 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'solitaire_board'
require 'sorted_queue'
require 'hash_helper'
require 'eql_helper'
# Solitaire solver
class Solver
# True once the solver has run
attr_reader :solved
# The number of nodes that were ever queued
attr_reader :queued
# The number of nodes that were skipped because the board had alread... | true |
3b75d38b92b60124d6b92a6813aca1e3ff4d8388 | Ruby | ashamani9/Ruby | /26-08-2016/pattern2.rb | UTF-8 | 211 | 2.78125 | 3 | [] | no_license | #Display the pattern
i = 1
j = 2
while i >= 1
a = " "*j+"*"*i+" "*j
puts a
i += 2
j -= 1
if i > 5
break
end
end
i = 3
j = 1
while i >= 1
a = " "*j+"*"*i+" "*j
puts a
i -= 2
j += 1
end
| true |
7e807a4210d0840594bd583c70229548cc7563f8 | Ruby | jmoypace/ruby-objects-has-many-lab-cb-000 | /lib/author.rb | UTF-8 | 346 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Author
attr_accessor :name
@@all=[]
def initialize(name)
@name=name
@@all<<self
end
def self.all
@@all
end
def add_post(post)
post.author=self
end
def add_post_by_title(title)
post=Post.new(title)
post.author=self
end
def posts
Post.all.select {|post| post.author == self}
end
def self.post_count
... | true |
88960ff0617b1b29db976bfa63d658cd144acca2 | Ruby | george-carlin/abroaders | /app/concepts/travel_plan/edit.rb | UTF-8 | 1,669 | 2.59375 | 3 | [] | no_license | class TravelPlan < TravelPlan.superclass
# Find a Card by its ID, and prepare to edit it
class Edit < Trailblazer::Operation
extend Contract::DSL
contract TravelPlan::Form
step :setup_model!
step :assert_plan_is_new_style!
step Contract::Build()
private
def setup_model!(options, param... | true |
f7c8501ca3edcadc2a6bc77fc455c9b621cce274 | Ruby | i2e-haw-hamburg/protobuf-guy | /src/guy.rb | UTF-8 | 4,759 | 2.875 | 3 | [] | no_license | require_relative 'helper'
require_relative 'parser'
class Guy
def initialize(args={})
options = {
:verbose => false,
:input => '.',
:output => '.',
:map_name => 'MessageTypes.txt',
:not_installed => false
}.merge(args)
@verbose = options[:verbose]
@input_f... | true |
8bb2adf5fd9a89ec5b7f6a79a261c8afceb513d9 | Ruby | ksavransky/chess | /human_player.rb | UTF-8 | 328 | 2.96875 | 3 | [] | no_license |
require_relative 'display'
class HumanPlayer
attr_accessor :name, :display, :color
def initialize(name = 'John')
@name = name
@display = nil
@color = nil
end
def play_turn
result = nil
until result
@display.render
result = @display.get_input
end
pos = result
en... | true |
5394c36fed3a8da29a12ea045f81c0c1ef35c2f0 | Ruby | snayak-rails/ruby_programs | /double_elements.rb | UTF-8 | 100 | 3.046875 | 3 | [] | no_license | input = Array[1,2,3,4,5]
input_doubled = input.map {|element| element * 2}
puts "#{input_doubled}" | true |
84107043a4d40ef792c3739bb484f85a25568374 | Ruby | alexkv/appscrolls | /lib/appscrolls/config.rb | UTF-8 | 2,072 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'active_support/ordered_hash'
module AppScrollsScrolls
class Config
attr_reader :questions
def initialize(schema)
@questions = ActiveSupport::OrderedHash.new
schema.each do |hash|
key = hash.keys.first
details = hash.values.first
kind = details['type']
r... | true |
f2efb236cca449719fcf8bc5c64d53fa976d85f6 | Ruby | cantremember/madderlib | /spec/benchmark_spec.rb | UTF-8 | 1,151 | 2.59375 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'spec_helper')
require 'benchmark'
include Benchmark
=begin
class Bencher
attr_accessor :debug
def call(name='(none)', &block)
x = nil
unless @debug
x = block.call
else
bm(6) do |reporter|
reporter.report(name) { x = block.call }
end
end
x
end
end... | true |
cb3427cae010cdacd72b1e09b25fc237454bf886 | Ruby | amsidebottom/oo-banking-v-000 | /lib/transfer.rb | UTF-8 | 1,253 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Transfer
def initialize(sender, receiver, amount)
@sender = sender
@receiver = receiver
@status = "pending"
@amount = amount
end
def sender=(sender)
@sender = sender
end
def sender
@sender
end
def receiver=(receiver)
@receiver = receiver
end
def receiver
@rec... | true |
ff71b111ce72b481e68267acd7b4534b18790031 | Ruby | jmz456/phase_0_unit_2 | /week_4/2_creative/make_a_homework_cheater/my_solution.rb | UTF-8 | 3,366 | 4.0625 | 4 | [] | no_license | # U2.W4: Homework Cheater!
# I worked on this challenge [by myself, with: ].
# 2. Pseudocode
# Input:
# Output:
# Steps:
# 3. Initial Solution
def essay_writer(title, topic, date, thesis_statement, pronoun)
puts "#{title}"
puts ""
if "#{pronoun}" == "male"
puts "#{topic} was an important per... | true |
b94357d423ceb3f85efb35f1b82eed8cb7bb76bc | Ruby | reednj/redditgold | /sh/gold.rb | UTF-8 | 5,683 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
ENV['GEM_PATH'] = File.expand_path('~/.gems') + ':/usr/lib/ruby/gems/1.8'
require 'rubygems'
require 'sequel'
require 'yaml'
require 'json'
require 'rest-client'
require 'cgi'
require './config/db.rb'
require './lib/simpledb'
class App
def initialize
@db = SimpleDb.new
end
def main
# get th... | true |
fbeeff75c877a3fa1fefc253801783f8e82d90d3 | Ruby | rainflush7707/Mashiro-exploration-translation | /output/Mashiro-exploration/DataExtracted/scripts/Script106.rb | UTF-8 | 40,277 | 2.703125 | 3 | [] | no_license | #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 装備品オプション追加 - KGC_AddEquipmentOptions ◆ VX ◆
#_/ ◇ Last update : 2008/04/01 ◇
#_/----------------------------------------------------------------------------
#_/ 装備品のオプションを追加します。
#_/==============================================... | true |
1781a77cc4f9d006af12f6a6d22063809c9e0848 | Ruby | A-Jhee/AlgoExpert | /valid_subseq.rb | UTF-8 | 4,093 | 3.71875 | 4 | [] | no_license |
# non-empty arr of integer and non-empty arr of integer => boolean
# the 2nd arr is compared to 1st
# A and B => boolean
# B is compared to A.
# for? if B is a subsequence of A
# what is a subsequence? array containing set of numbers that are
# not necessarily adj in the comparison... | true |
b72c78028c2e632cbdd58e3059ccc505c2664076 | Ruby | bret/watircraft | /vendor/gems/gems/taglob-1.0.0/lib/taglob/extensions/dir.rb | UTF-8 | 778 | 2.921875 | 3 | [
"MIT"
] | permissive | class Dir
def self.tags(pattern)
files = {}
Dir.glob(pattern).each do |file|
tags = File.tags(file)
files.merge!({file => tags}) unless tags.empty?
end
files
end
def self.taglob(pattern,tags)
if(tags.include?('|'))
Dir.tag_or(pattern,*tags.split('|'))
else
D... | true |
626d671ef1db2030e8601fdf73c5123e3ebde9de | Ruby | cyross/gbconverter | /gbc_converter.rb | UTF-8 | 2,232 | 2.953125 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
require './gbc_logger'
require './gbc_paragraph'
class GBConverter
# コンバータに必要なもの
# knife: パラグラフを切り分け、Paragraphオブジェクトを作成
# analizer: パラグラフの内容を解析
# preprocessor: メイン処理前に必要な処理を施す
# formatter: パラグラフ番号の割り振りなど、メイン処理
# postprocessor: メイン処理が終わった後に必要な処理を施す
# printer: パラグラフを出... | true |
5b1b0326ad9618b26a50873aaed20d3a9c03b7fc | Ruby | jjhay-bot/batch8-activities | /rubyActivities/codingExercise/3.2_unique_in_order.rb | UTF-8 | 201 | 3.375 | 3 | [] | no_license | def unique_in_order(x)
a = (x.class == String ? x.chars : x ).chunk { |i| i }
a.map{|a| a.first}
end
unique_in_order('AAAABBBCCDAABBB')
unique_in_order('ABBCcAD')
unique_in_order([1,2,2,3,3]) | true |
a293e2e0a782a58e041f9e8a067712ff587adcd2 | Ruby | acarvajal09/eva | /lib/eva/table.rb | UTF-8 | 336 | 2.71875 | 3 | [
"MIT"
] | permissive | module Eva
class Table
attr_reader :width, :height
attr_accessor :x, :y
# This method initialize the table
#
# @param width [Integer] table width
# @param height [Integer] table height
def initialize(width, height)
@width = width
@height = height
@x = 0
@y = 0
... | true |
7edc48e93282aa05d1aca66924796e55c40053a0 | Ruby | isabanin/pretty_diff | /lib/pretty_diff/diff.rb | UTF-8 | 2,581 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #
# Main class to interact with. In fact this is the only class you should interact with
# when using the library.
#
# === Usage example
# pretty = PrettyDiff::Diff.new(udiff)
# pretty.to_html
#
# Keep in mind that Diff will automatically escape all HTML tags from the intput string
# so that it doesn't interfere with... | true |
b70ee9be683d7c25195149217c72e46cc19e3ef2 | Ruby | melalat910/looping-while-until-onl01-seng-pt-090820 | /lib/until.rb | UTF-8 | 226 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_until#your code here
levitation_force = 6
# 1. Condition to be met
until levitation_force == 10
# 2. Stuff to do while true
puts "Wingardium Leviosa"
# 3. How do we meet the condition
levitation_force +=1
end
end
| true |
12b671e9cb0ac9539475c89619b38c3e1afca85e | Ruby | hegemonia/dibstarter | /app/services/scalable_press.rb | UTF-8 | 2,510 | 2.5625 | 3 | [] | no_license | require 'httmultiparty'
require 'json'
require 'yaml'
class ScalablePress
include HTTMultiParty
debug_output $stderr
base_uri "https://api.scalablepress.com/v2"
basic_auth '', SCALABLE_PRESS_APIKEY
def create_orders
Product.all.each do |product|
dibs = Dib.initial.where(product_id:product.id)
... | true |
fb1287cc585d3e56ad9b9847d922fa54a7e2dbf4 | Ruby | alexander-lazarov/advent-of-code | /2022/18/solution.rb | UTF-8 | 1,379 | 3.625 | 4 | [] | no_license | require 'set'
input_file = 'input.txt'
# input_file = 'input-sample.txt'
points = Set.new(File.read(input_file).split("\n").map { _1.split(',').map(&:to_i) })
def neighbours_of(x, y, z)
[
[x + 1, y, z],
[x - 1, y, z],
[x, y + 1, z],
[x, y - 1, z],
[x, y, z + 1],
[x, y, z - 1],
]
end
clas... | true |
8635d53e125c537e5028c01d802d8e490ad317ad | Ruby | jbaiza/find-your-doctor | /doctor_app/app/models/speciality.rb | UTF-8 | 538 | 2.859375 | 3 | [] | no_license | class Speciality < ApplicationRecord
def self.load_data(*file_names)
file_names.each do |file_name|
load_file_data(file_name)
end
end
def self.load_file_data(file_name)
specialities = {}
CSV.foreach(file_name, col_sep: ",", headers: :first_row) do |row|
code = row[7].strip.upcase
... | true |
a7e5fffd8c2fdbd3866024f50ec5bd56e8e45ae4 | Ruby | balalnaeem/launch-school-101-lessons | /exercises/easy_6/2.rb | UTF-8 | 692 | 4.46875 | 4 | [] | no_license | =begin
Write a method that takes an array of strings, and returns an array of the same string values, except with the vowels (a, e, i, o, u) removed.
In: array (of strings)
Out: array (of same strings)
Al:
-def a method that takes an array of strings
-Iterate over the array - e = string
-delete the vowel... | true |
d2bd65ccce5cabda07f0f94b3804b23a11289391 | Ruby | jaysubia/Vagrant | /ruby/arrays.rb | UTF-8 | 315 | 3.625 | 4 | [] | no_license | a = ["jermaine","subia","dojo","josh"]
b = [1,2,8,6,9,8,10,11]
c= ["Dojo",9]
# shuffle and join
puts a.shuffle.join(',')
# delete
a.delete("jermaine")
puts a
# at
puts b.at(0)
# reverse
puts a.at(1).reverse
puts c.at(0).length
puts a.sort
puts b.slice(1)
puts b.shuffle
puts a.join("-")
puts c.insert(2,3) | true |
d88ae5e937aa98502e797e1d8d2c5c5de96363ce | Ruby | xdite/twitter-message-wall | /lib/twitter_search.rb | UTF-8 | 2,127 | 2.71875 | 3 | [
"WTFPL"
] | permissive | require 'rubygems'
require 'net/http'
require 'json'
require 'cgi'
require 'actionpack'
module TwitterSearch
class Tweet
VARS = [:text, :from_user, :to_user, :to_user_id, :id, :iso_language_code, :from_user_id, :created_at, :profile_image_url ]
attr_reader *VARS
attr_reader :language
def initial... | true |
5f3c52620e10f1e9a8cec1fd81b175e6029e684d | Ruby | GregoryArmstrong/headcount-1 | /lib/enrollment_repository.rb | UTF-8 | 1,190 | 3.25 | 3 | [] | no_license | require 'pry'
require_relative 'enrollment'
require_relative 'csv_parser'
class EnrollmentRepository
attr_accessor :enrollment, :districts
attr_reader :parser
def initialize
@parser = BasicParser.new
end
def load_data(given_data)
given_data[:enrollment].each do |grade, percentages_data|
parse... | true |
4623c0aca0fa679ddee1323579da17b0757ab3c7 | Ruby | AubreyNeimeier/anagram-detector-v-000 | /lib/anagram.rb | UTF-8 | 1,346 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
require 'pry'
=begin
First solution attempt.
we need to build a regexp(a string) that consists of an word repeated word.length times. [word][word][word][word]
save that string into a variable
use grep to return an array of matches to the regexp(string)
#word_length = @name.length... | true |
4370ce9c53f9b75019d8b7d4473a4c8dda0c79f2 | Ruby | TupoBanKai/lessons | /Black jack/main.rb | UTF-8 | 1,736 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'card'
require_relative 'deck'
require_relative 'counter'
require_relative 'player'
require_relative 'diler'
require_relative 'bank'
require_relative 'simulation'
# class main for create anth
class Main
@@bank = Bank.new
def initialize
@deck = Deck.new
@deck... | true |
4505db864c0d25fcdba5bb7d194dfbfbab1ad82b | Ruby | RuanShan/jpos_rapi | /spree/core/app/models/spree/stock/splitter/shipping_category.rb | UTF-8 | 1,031 | 2.640625 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | module Spree
module Stock
module Splitter
class ShippingCategory < Spree::Stock::Splitter::Base
def split(packages)
split_packages = packages.flat_map(&method(:split_by_category))
return_next(split_packages)
end
private
def split_by_category(package)
... | true |
79ebaa6491033277be857af9f748f1352d66a102 | Ruby | xennygrimmato/extractab | /app/models/handle_mapper.rb | UTF-8 | 934 | 3.5625 | 4 | [] | no_license | module HandleMapper
BASE_CHARS = '0SKVnQFHhGs9qo7p8cWR54duMYNXTCErx2tDmwO3kabfUB1elLvjiIgyJAZ6Pz'.split('')
BASE = BASE_CHARS.length
MAKE_IT_LOOK_BIG = 500000
def self.decode(string)
chars = string.split('')
decoded = chars.each_with_index.inject(0) do |sum, (char, index)|
sum + (BASE_CHARS.inde... | true |
dec52c787e1dd94fd43a29140e2ea22c4b121861 | Ruby | fionajessica23/WDI_13_HOMEWORK | /Fiona Jessica/wk04/3-wed/happi_tails/client.rb | UTF-8 | 518 | 3.921875 | 4 | [] | no_license | class Client
def initialize(name, num_child, age)
@name = name
@num_child = num_child
@age = age
@pets = []
end
# not being used,
# assume client can only have pets through adoption
# def add_pet_array(pet)
# @pets += pet
# end
def name
@name
end
def pets
@pets
end
... | true |
fce47ba7dffe8a419911a7b167a3ebf02cbafc28 | Ruby | angelolloqui/CocoaPods | /lib/cocoapods/command/spec.rb | UTF-8 | 20,883 | 2.71875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Pod
class Command
class Spec < Command
def self.banner
%{Managing PodSpec files:
$ pod spec create [ NAME | https://github.com/USER/REPO ]
Creates a PodSpec, in the current working dir, called `NAME.podspec'.
If a GitHub url is passed the spec is prepopula... | true |
00cd7c70e7c7c8de6d33f96fb8702309dbf34f5b | Ruby | virgi1974/lextrend_challenge | /order_list_module.rb | UTF-8 | 701 | 3.25 | 3 | [] | no_license | module Order_list
def order_data
sort_by_heigth()
@data_a = sort_by_same_height()
end
private
def sort_by_heigth
@data_a.sort! do |x,y|
x[0] <=> y[0]
end
end
def sort_by_same_height
array_sort = []
temp = ""
@data_a.each do |key_val|
if temp != key_val[0]
... | true |
477d6b5a06186b666a4102fb3a6e48a85b2fd8f1 | Ruby | arsen-bakhtishaiev/messages_sinatra | /encryption.rb | UTF-8 | 553 | 2.90625 | 3 | [] | no_license | require "openssl"
require "digest/sha1"
require "base64"
IV = "1234567890ABCDFEFGHIJ"
ALGO = "aes-128-cbc"
KEY = "dfgertbg;fhjfdvbfg"
class AES
def encrypt(text)
aes = OpenSSL::Cipher::Cipher.new(ALGO)
aes.encrypt
aes.key = KEY
aes.iv = IV
data = aes.update(text)
data << aes.final
return Base64.encod... | true |
f8862c03e52c680388e5f434370c20b4a43ddda1 | Ruby | Quang7hong81/ruby-xdr | /spec/lib/xdr/var_array_spec.rb | UTF-8 | 2,126 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | require "spec_helper"
describe XDR::VarArray, "#read" do
let(:empty_array) { "\x00\x00\x00\x00" }
let(:one_array) { "\x00\x00\x00\x01\x00\x00\x00\x00" }
let(:many_array) { "\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x00" }
let(:too_large_array) { "\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\... | true |
757d7135e74cade547a1a9be1b56c8d0d4fa0cd9 | Ruby | pawelduda/codeeval-ruby-solutions | /easy/147.rb | UTF-8 | 731 | 3.515625 | 4 | [] | no_license | # https://www.codeeval.com/browse/147/
def get_case_stats(str)
upcase = 0
downcase = 0
str.split('').each do |c|
c == c.upcase ? upcase += 1 : downcase += 1
end
upcase_percent = '%.2f' % (upcase.to_f * 100 / str.length)
downcase_percent = '%.2f' % (downcase.to_f * 100 / str.length)
"lowercase: #{d... | true |
451157095a390cf1ac201dd84d54e826c4cb90bb | Ruby | 1p2m3m/rubytest | /code1/helloworld.rb | UTF-8 | 235 | 3.71875 | 4 | [] | no_license |
puts "Pleaae enter your name"
name = gets.chomp
puts "Please enter your fav color"
color = gets.chomp
puts "Please enter you age"
age = gets.chomp
puts "Hello my name is #{name}. \nMy fav color is #{color} and I am #{age} years old"
| true |
35cfda891953e39fffa052f1340a79ea5d630594 | Ruby | hjensen1/euler-project | /66.rb | UTF-8 | 887 | 3.296875 | 3 | [] | no_license | require './pell.rb'
max = 0
best = 0
(6..1000).each do |d|
x, y = solve_pell(d)
puts "#{x} ^ 2 - #{d} * #{y} ^ 2 = 1"
if x > max
max = x
best = d
end
end
# (6..1000).each do |d|
# start = Time.now
# next if Math.sqrt(d).round ** 2 == d
# m = 1
# factors = (d * 2).all_factors
# loop do
# ... | true |
bed9e064c6d1acae98d9dc4c538bbd3ff4bddbd1 | Ruby | archit1jain/RubyPractice | /Enumerable/out.rb | UTF-8 | 352 | 3.28125 | 3 | [] | no_license | require_relative 'player'
require_relative 'team'
player1 = Player.new("Bob",13,5)
player2 = Player.new("Mike",19,3)
player3 = Player.new("Wick",21,2)
red_team = Team.new("Red")
red_team.add_players(player1,player2,player3)
elig_players = red_team.select { |player| (14..20)===player.age }.reject{|player| player.skill... | true |
284c76cc897c70eaf1898ec69696e369984e1d4b | Ruby | arirusso/micromidi | /lib/micromidi/instructions/output.rb | UTF-8 | 1,013 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | module MicroMIDI
module Instructions
# Commands that deal with MIDI output
class Output
extend Forwardable
def_delegators :@state, :toggle_auto_output
alias_method :auto_output, :toggle_auto_output
# @param [State] state
def initialize(state)
@state = state
end... | true |
010488b832adb91d7542605ad9e8d34325ea7cdc | Ruby | charlie320/programming_labs_projects | /ruby_vagrant_box/ruby_on_rails/project/project.rb | UTF-8 | 551 | 3.359375 | 3 | [] | no_license | class Project
@@no_of_projects = 0
attr_accessor :project_name, :project_description, :project_owner
attr_reader :tasks
def initialize(name, description, owner)
@project_name = name
@project_description = description
@project_owner = owner
@tasks = []
@@no_of_projects += 1
puts "Number... | true |
59ba833e16bac0b1176a7e321e48d04808820860 | Ruby | ia7ck/monkey-interpreter | /lib/parser.rb | UTF-8 | 10,299 | 3.328125 | 3 | [] | no_license | require_relative "token"
require_relative "lexer"
require_relative "ast"
class MonkeyLanguageParseError < StandardError; end
module Precedence
LOWEST,
EQUALS,
LESSGREATER,
SUM,
PRODUCT,
PREFIX,
ACCESS,
INITIALIZE,
CALL,
INDEX = [1, 2, 3, 4, 5, 6, 7, 7, 7, 7]
end
class Parser
def initialize(inpu... | true |
768fad0409efed10d713543669541580602ebff0 | Ruby | Erol/jisho | /lib/jisho.rb | UTF-8 | 973 | 3.359375 | 3 | [
"MIT"
] | permissive | require 'jisho/version'
require 'jisho/misspellings'
module Jisho
# Check text for misspelled words.
#
# misspellings = Jisho.check 'Thiis sentence has a misspelled word.'
# misspellings.words # => ["Thiis"]
# misspellings.first[:word] # => "Thiis"
# misspellings.first[:row] ... | true |
635a02c6dbd4c99095ac52feda87b0c6efd9a469 | Ruby | rspeicher/video_dimensions | /lib/video_dimensions/backends/media_info.rb | UTF-8 | 1,727 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-mediainfo-lib",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module VideoDimensions
module Backends
class MediaInfo < Base
def self.available?
`which #{binary} 2>&1 > /dev/null`
$?.exitstatus == 0
end
def self.binary
'mediainfo'
end
def initialize(input)
@input = input
end
def dimensions
[... | true |
f4dd6722ed495f0b455567597d31e0935e6adc8a | Ruby | timgentry/ndr_import | /lib/ndr_import/non_tabular/table.rb | UTF-8 | 7,355 | 2.625 | 3 | [
"MIT"
] | permissive | require 'ndr_import/table'
module NdrImport
module NonTabular
# This class maintains the state of a non tabular table mapping and encapsulates
# the logic required to transform a table of data into "records". Particular
# attention has been made to use enumerables throughout to help with the
# transf... | true |
e48195d9ba2cce8000b1250923c834266cd3d261 | Ruby | mikegehard/rttt | /lib/rttt.rb | UTF-8 | 1,079 | 3.578125 | 4 | [] | no_license | class TicTacToe
attr_reader :board
def initialize
@board = Array.new(9,nil)
@turn = true
@size = 9
end
def set_board(new_board)
(0...board.length).each do |index|
@board[index] = new_board[index]
end
end
def move(index, turn)
@board[index - 1] = (turn ? "X" : "O")
end
def winner?
combinat... | true |
c48dd608979cefc9f4ddd227037f6a0e904557dd | Ruby | kfultz/prag_studio_game | /spec/studio_game/berserk_player_spec.rb | UTF-8 | 833 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'studio_game/berserk_player'
module StudioGame
describe BerserkPlayer do
before do
@initial_health = 50
@player = BerserkPlayer.new("berserker", @initial_health)
end
it "does not go berserk when w00ted up to 5 times" do
1.upto(5) { @player.w00t }
@player.berserk?.sh... | true |
ee0fc5a5beb28abbaa30e41e08499858081ec207 | Ruby | Rolikhattri/Flipkart_crawl | /app/models/product.rb | UTF-8 | 2,372 | 2.625 | 3 | [] | no_license | require 'rubygems'
require 'csv'
require 'open-uri'
require 'nokogiri'
class Product < ActiveRecord::Base
belongs_to :user
def self.crawl_data(url)
params = {}
link = url
file = Nokogiri::HTML(open("#{link}"))
title=''
title = file.css('._3eAQiD').text if !file.css('._3eAQiD').nil?
params[:... | true |
2599866db8920e8d3ae29705e043c1fbb6499698 | Ruby | jinyingwu/Alpha-works | /Students & Courses/appacademy-online-students-courses-103ccbf70eb0/lib/student.rb | UTF-8 | 684 | 3.296875 | 3 | [] | no_license | class Student
attr_accessor :courses, :first_name, :last_name
def initialize(fName, lName)
@first_name = fName
@last_name = lName
@courses = []
end
def name
"#{@first_name} #{@last_name}"
end
def enroll(course)
if self.courses.include?(course)
return
end
raise "course wo... | true |
90f94d169602319576894517279d0b5d312713aa | Ruby | xavierloos/codewars | /Ruby/lib/reversing_array.rb | UTF-8 | 285 | 3.734375 | 4 | [] | no_license | =begin
Change the order of the array
[1,2,3,4,5] => [5,4,3,2,1]
=end
def reverse(arr)
raise "Wrong type of argument" if !arr.is_a? Array
reversed = []
position = arr.length-1
while position >= 0
reversed << arr[position]
position = position - 1
end
reversed
end | true |
4850e021307b2c78872b142c70a5f0d427f1e6c8 | Ruby | phluid61/ruby-experiments | /thread-test/thread-test.rb | UTF-8 | 484 | 3.046875 | 3 | [
"ISC"
] | permissive | require 'threadpuddle'
puddle = ThreadPuddle.new 10
@array = (1..100).to_a
while @array.size > 0
# this shift is not synced because '@array'
# is only accessed from the one thread
item = @array.shift
#print "popped item #{item.inspect} at time #{Time.now.strftime '%H:%M:%S.%6N'} Puddle size is #{puddle.size}... | true |
5a260cdf4185cdf968bc22fdbea2d558ce226562 | Ruby | nuclearsandwich/fancy | /boot/rbx-compiler/compiler/ast/super.rb | UTF-8 | 445 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | class Fancy
class AST
class Super < Node
def initialize(line)
super(line)
end
end
class SuperSend < Node
def initialize(line, method_name, args)
super(line)
@method_name = method_name.name.to_sym
@args = args
end
def bytecode(g)
pos(... | true |
82ba11cf099aa70b803d669514a3b998d2728436 | Ruby | LincolnFleet/ruby-object-attributes-lab-atlanta-web-career-031119 | /lib/person.rb | UTF-8 | 256 | 2.984375 | 3 | [] | no_license | class Person
def initialize(name=nil, job=nil)
@name=name
@job=job
end
def name=(arg)
@name=arg
end
def name
@name
end
def job=(arg)
@job=arg
end
def job
@job
end
end | true |
fdfcb75d2ae1d4113e8ad277a5307706deb7b051 | Ruby | manny361/coding | /phase-0-unit-1/week-3/6-fix-the-errors/my_solution.rb | UTF-8 | 4,630 | 3.828125 | 4 | [] | no_license | # --- error -------------------------------------------------------
# "Screw you guys" + "I'm going home" = cartmans_phrase
# (1) what is the name of the file with the error?
# my_solution.rb
# (2) what is the line number where the error occurs?
# 3
# (3) what is the error message?
# unexpected '='
# (4) what is ruby... | true |
358aa049e2c15c7029ce42a8b35462102073dd6c | Ruby | k00ka/asteroids | /lib/asteroid/base.rb | UTF-8 | 2,449 | 2.625 | 3 | [
"MIT"
] | permissive | # Encoding: UTF-8
# Ruby Hack Night Asteroids by David Andrews and Jason Schweier, 2016
require_relative '../body'
#require_relative '../circle'
module Asteroid
class Base < Body
attr_reader :image, :shape
attr_writer :shape if defined? RSpec
@@asteroids = []
@@white = 0xff_ffffff
# accept po... | true |
f2fe175e9c43423306eb00244be158113aeeb712 | Ruby | robpe/multi_dispatch | /examples/pattern_matching.rb | UTF-8 | 3,002 | 3.109375 | 3 | [
"MIT"
] | permissive | require_relative '../lib/multi_dispatch.rb'
class ListPatternMatching
include MultiDispatch
# (match '(1 2 3)
# [(list a b c) (list c b a)]) => '(3 2 1)
#
def_multi :ex1, lambda { |l| l.size == 3 } do |list|
a,b,c = list
[c, b, a]
end
# (match '(1 2 3)
# [(list 1 a ...) a]) => '(2 3)
... | true |
adbcccdc0d13565a8c7d3b393957ba211a85f462 | Ruby | lukeivers/deckbuilder | /cards/eaglehorn_bow.rb | UTF-8 | 419 | 2.546875 | 3 | [] | no_license | require './weapon'
class EaglehornBow < Weapon
def initialize
super
self.cost = 3
self.name = 'Eaglehorn Bow'
self.attack = 3
self.durability = 2
self.deck_class = 'Hunter'
end
def battlecry
super
$game.add_hook(:secret_reveal, self)
end
def on_secret(opts = {})
self.dur... | true |
265aa192a0b4637bbd81b40187154e18e46d8f68 | Ruby | elsurudo/classy_enum | /spec/classy_enum/active_record_spec.rb | UTF-8 | 4,802 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
class Breed < ClassyEnum::Base; end
class Breed::GoldenRetriever < Breed; end
class Breed::Snoop < Breed; end
class Breed::Husky < Breed; end
class Color < ClassyEnum::Base; end
class Color::White < Color; end;
class Color::Black < Color; end;
clas... | true |
929f5b4cc3508b6c0ef4d6f949d167dd153d2590 | Ruby | ConorFl/Project-Euler | /prob048.rb | UTF-8 | 128 | 3.53125 | 4 | [] | no_license | def self_power(n)
sum = 0
1.upto(n) do |i|
puts i
sum+= (i**i) % 10000000000
end
puts sum
end
self_power(1000) | true |
82f46b233e5ba7ade6a4154f2a85774125f35991 | Ruby | arnaldoaparicio/black_thursday | /spec/item_spec.rb | UTF-8 | 1,833 | 2.828125 | 3 | [] | no_license | require './lib/item'
require 'bigdecimal'
RSpec.describe do
it 'exists' do
i = Item.new({
:id => 1,
:name => "Pencil",
:description => "You can use it to write things",
:unit_price => BigDecimal(10.99,4),
:created_at => Time.now,
:updated_at => Time.now,
... | true |
cb07b29cb8a818683e6e6eb69d7f5a12d0e194a6 | Ruby | Brendaneus/the_odin_project | /ruby_programming/knights_travails.rb | UTF-8 | 1,823 | 4.03125 | 4 | [] | no_license | #TODO:
# Clean this thing up
# Make recursive method containing all functionality?
class KnightBoard
def initialize
@directions = [[1, 2], [2, 1], [2, -1], [1, -2], [-1, -2], [-2, -1], [-2, 1], [-1, 2]]
end
class Space
attr_reader :location, :last_space
def initialize location
@location = location
end... | true |
272ccda3fad9a2bda214313f2358b3065c08d891 | Ruby | mopuriiswaryalakshmi/Ruby_Programs | /using_ternary_operator_find_largest_no.rb | UTF-8 | 301 | 3.515625 | 4 | [] | no_license | puts "Enter three numbers"
numbers=[]
count=0
while count < 3
number=Random.rand(1000).to_i
puts number
numbers.push(number)
count +=1
end
largest_number = ( (numbers[0]>numbers[1] ? a = numbers[0] : a=numbers[1] )>numbers[2] )? a : numbers[2]
puts " largest number is #{largest_number}" | true |
f13b3a64326aa72a6666fde06a2713a7a10b8e8a | Ruby | nicklombardi/wdi | /exampleCode/ruby/pry_example.rb | UTF-8 | 209 | 2.9375 | 3 | [] | no_license | require 'pry'
require 'pry-debugger'
puts "enter first name"
first = gets.chomp
puts "enter last name"
last = gets.chomp
binding.pry
# launches pry
last = last.upcase
puts "your full name is #{first} #{last}" | true |
e869014c1fc5f4f6adcd2b7f6ab31ff18591f2ec | Ruby | wleborgne/lrthw_exercises | /chapter_7/ex7.rb | UTF-8 | 1,368 | 4.28125 | 4 | [] | no_license | # Print a string literal
puts 'Mary had a little lamb.'
# Assign a string literal to a variable
snow = 'snow'
# Print a string containing the value of a variable
puts "Its fleece was white as #{snow}."
# Print a string literal
puts 'And everywhere that Mary went.'
# Print a string literal 10 times
puts '.' * 10 # what'... | true |
9a15c68cc8b823eb8557eb78a21a9ac19f933c18 | Ruby | saulocamposi/labrubyandmongo | /variables_scopes.rb | UTF-8 | 483 | 3.546875 | 4 | [] | no_license | class VariablesScopes
@@_variable_of_class = 0
def initialize
@first_variable = 'First variable'
@second_variable = 'Second variable'
@third_variable = 'Third variable'
@@_variable_of_class += 1
end
def display_details
puts "first_variable #{@first_variable}"
... | true |
74a75f769d2b6ba3634b06c3da8c6ba94a6afc44 | Ruby | prasadanvekar/lono | /lib/lono/cfn/util.rb | UTF-8 | 563 | 2.609375 | 3 | [
"MIT"
] | permissive | module Lono::Cfn::Util
def are_you_sure?(stack_name, action)
if @options[:sure]
sure = 'y'
else
message = case action
when :update
"Are you sure you want to want to update the #{stack_name.colorize(:green)} stack with the changes? (y/N)"
when :delete
"Are you sure you w... | true |
00c04f3b31c9bb0bcead66e9ac18863e4c3698d0 | Ruby | prayjourney/RubyStudy | /Ruby base/base source/6.4.3-1.rb | UTF-8 | 145 | 3.484375 | 3 | [] | no_license | Person = Struct.new(:name, :gender, :age)
fred = Person.new("Fred", "male", 50)
chris = Person.new("Chris", "male", 25)
puts fred.age + chris.age | true |
e8598650b49875e1b0a5c6461373dcbd5f673a99 | Ruby | veryhappythings/shooter | /shooter.rb | UTF-8 | 2,249 | 2.765625 | 3 | [] | no_license | BULLET_MOVEMENT_SPEED = 5
PLAYER_MOVEMENT_SPEED = 10
MOVEMENT_SPEED = 1
Shoes.app :height => 300, :width => 600, :resizable => false do
def new_wave
wave = []
(0..5).each do |i|
if rand(2) > 0
wave << image('enemy.jpg', :top => i*50, :left => 600, :height => 30)
end
end
return wav... | true |
e15352253861fa5478514f740476522eb30ad917 | Ruby | axiomcoding/hashketball | /spec/hashketball_spec.rb | UTF-8 | 5,057 | 3.046875 | 3 | [] | no_license | require_relative './spec_helper'
require_relative '../hashketball.rb'
describe '#game_hash' do
it 'should return a hash' do
expect(game_hash).to be_a(Hash)
end
end
describe '#num_points_scored' do
it 'knows the number of points scored by each player' do
expect(num_points_scored("Stephen Curry")).to eq(3... | true |
1e0846a774971ceb92d2f5e4a9a028a4850dd573 | Ruby | stiehlrod/backend_prework | /day_7/checkerboard.rb | UTF-8 | 1,056 | 4.09375 | 4 | [] | no_license | #Create a file called checker_board.rb and within that file,
#write a program that will print a checkerboard based on the size
#*indicated by the user*. On this board, the black spaces will be
#represented with 'X' and the white spaces will be represented with ' '.
#And example of the output for a size 6 board would l... | true |
b7385b3d27e08b0c7a04c8d68ad24cef1ce82159 | Ruby | Yancey2126/the_odin_project | /Web Development 101/Learn Ruby/03_simon_says/simon_says.rb | UTF-8 | 828 | 4.21875 | 4 | [] | no_license | #Lesson 3 - Simon Says TestFirst.org learn ruby
#Echos back the word
def echo(word)
return word
end
#Returns the word in in upper case
def shout(word)
return word.upcase
end
#Repeats the word 1-n times
def repeat(word, n = 2)
return ((word + " ")* n)[0...-1]
end
#Returns the first n letters
def start_of_word(wor... | true |
c41bbf0d5a036f15b25773973601f1b7c60d02f2 | Ruby | pczupil/ttt-7-valid-move-cb-gh-000 | /lib/valid_move.rb | UTF-8 | 445 | 3.59375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # code your #valid_move? method here
def valid_move?(board, ind)
if ind > 8 or ind < 0
return false
end
return !position_taken?(board, ind)
end
# re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.
def position_taken?(board, ind)
if board[ind] == " " or boa... | true |
0a039771c97b7aaa634b3aee1cc989cfb6f9f2e3 | Ruby | kalifs/project_euler | /lib/039.rb | UTF-8 | 655 | 3.03125 | 3 | [] | no_license |
pyt=lambda{|n|
result=[]
(n/2).downto(3) do |c|
b_start=n-c-1
lim=(c-n/2).abs
lim=lim==0 ? 2 : lim
(b_start).downto(lim) do |b|
a=n-c-b
nr=[a,b,c].sort
if nr[0]**2+nr[1]**2==nr[2]**2 && a+b>c
result<< nr
end
end
end
return result.uniq
}
max_result=[]
best_n=... | true |
0d7efe1c4de52e804201a77a9780a564d84436bd | Ruby | PacktPublishing/Practical-OneOps | /Chapter 09/circuit-oneops-1-master/components/cookbooks/spark-cluster-v1/recipes/add.rb | UTF-8 | 7,474 | 2.546875 | 3 | [
"MIT"
] | permissive | # Spark - Spark cluster level code.
#
# This recipe contains the code that is run at the cluster level
# in a Spark deployment.
Chef::Log.info("Running spark-cluster::add")
# Parse the ciName to extract the cloud ID from it
#
# INPUT:
# ciName: The CI name to parse
#
# RETURNS:
# A string containing the numeric cloud... | true |
e9a28d179d62e822afb5c5851d253f07d900dd5b | Ruby | ryush00/MCVotifier | /lib/mcvotifier/client.rb | UTF-8 | 1,865 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'socket' # Sockets are in standard library
module MCVotifier
class Client
attr_reader :socket_object, :service_name
attr_accessor :minecraft_server
def initialize(service_name, minecraft_server, opts = {})
@service_name = service_name
@minecraft_server = minecraft_server
... | true |
8e9ba89bf72cdb8dbed1a231286b9e595d5f59ee | Ruby | mcooledge/RubyPractice | /friends.rb | UTF-8 | 364 | 3.703125 | 4 | [] | no_license | class Person
attr_accessor :name, :birthday
def about_person
return "#{@name} was born on #{@birthday}."
end
end
class Friend < Person
def hug
puts "I love you!"
end
end
class Enemy < Person
def attack
puts "I punch you!"
end
end
my_friend = Friend.new
my_friend.name = "Emily"
my_friend.birthday = "Nov... | true |
b0ccedfc3bf4e46b75f375d43faad7cc762661d2 | Ruby | RomaneGreen/learn_ruby-master | /04_pig_latin/pig_latin.rb | UTF-8 | 453 | 3.375 | 3 | [] | no_license |
def translate(word)
vowels = ["a","e","i","o","u"]
csblend = ["ch","thr","sch","qu","squ","br",]
x = word.split(" ")
x.map do |word|
if vowels.include?(word.chr)
word+"ay"
elsif csblend.include?(word[0..1])
word[2..word.length] + word[0..1] + "ay"
elsif csblend.include?(word[0..2])
word[3..word.leng... | true |
0d1984fff821694822b56e66f9d8ff0df94c21d1 | Ruby | garagisti/oo_challenge | /container.rb | UTF-8 | 1,695 | 3.5625 | 4 | [] | no_license | class Container
attr_accessor :volume, :parcels
def initialize(volume)
@volume = volume
@parcels = []
end
# Adds Parcel
def add_parcel(parcel)
@parcels << parcel if
any_space?(parcel.volume) && !parcel_in_container?(parcel.id)
end
# Removes Parcel
def remove_parcel(id)
if parcel_i... | true |
0b0e2226bfb4c032187eaa7966613818aab344c4 | Ruby | rodrigodsp/LiberCapitalTest | /code/eratosthenes_rabbitmq/worker.rb | UTF-8 | 1,016 | 3.015625 | 3 | [] | no_license | require_relative 'rabbitmq_base'
require 'redis'
require 'prime'
require 'logger'
require 'time'
class Worker < RabbitMQBase
def start
logger = Logger.new(STDOUT)
logger.info("[#{Time.now}] RabbitMQ aguardando por mensagens.")
@queue.subscribe(block: true) do |_delivery_info, _properties, body|
... | true |
99231b910ab67a17cd4a8ffa7405a70d215d8f71 | Ruby | lukemorton/marionetta | /lib/marionetta/manipulators.rb | UTF-8 | 851 | 2.625 | 3 | [
"MIT"
] | permissive | # `Manipulators` is a container for registering manipulators.
#
# The interface of a manipulator is:
#
# self.tasks() an array of methods to expose via
# RakeHelpers *optional*
#
# initialize(server) *required*
# can?() *required*
#
module Marionetta
mo... | true |
6943f2a5db180c96643788387286d628b62f7601 | Ruby | Abhinaya-P/todo_list | /rails_projects/todo_list/app/models/todo.rb | UTF-8 | 508 | 2.625 | 3 | [] | no_license | class Todo < ActiveRecord::Base
attr_accessible :description, :status, :alert, :due_date,:priority
belongs_to :tasklist
validates :description,presence: true
validates :status, presence: true
validates :priority, presence:true
def self.search_result(search_text,user)
res = []
if !search_text.empty?
... | true |
015a123128596eaf2f341460fb53650c8617b8eb | Ruby | danieleandreatta/wiki_page_stats | /wiki_split.rb | UTF-8 | 420 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
$t1 = Time.new()
$pages = []
File.open(ARGV[0], "r") do |fin|
fin.binmode
while (line = fin.gets)
ws = line.split(" ")
if ws[0] == "en" && ws[2].to_i > 500
$pages << [ws[1], ws[2].to_i]
end
end
end
$pages.sort! {|a, b| b[1] <=> a[1]}
$t2 = Time.new()
$... | true |
8013554aa6e918d62455fcb184bd9fa85da425de | Ruby | bikefighter/roomie | /lib/roomie/solve.rb | UTF-8 | 6,017 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'roomie/not_solvable'
module Roomie
class Solve
attr_reader :matches, :matched_pairs
def initialize *people_prefs
@people_prefs = *people_prefs
@group_size = @people_prefs.size
@best_proposals = Array.new(@group_size)
if phase_one
@matches = @people_prefs.flatten
... | true |
0b0fc99bc5101a8de94a776947c34b16473fb692 | Ruby | jenf/18xx | /spec/lib/engine/games/g_1889_spec.rb | UTF-8 | 1,269 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require './spec/spec_helper'
require 'engine/game/g_1889'
require 'engine/part/city'
require 'json'
module Engine
describe Game::G1889 do
let(:players) { [Player.new('a'), Player.new('b')] }
subject { Game::G1889.new(players) }
context 'on init' do
it 'starts with c... | true |
683dd29c5177b8792ef12b97625ef986b978baf8 | Ruby | orunior19/capy | /spec/elements_js_spec.rb | UTF-8 | 1,459 | 2.84375 | 3 | [] | no_license | describe 'Alertas de JS', :js do
before(:each) do
visit '/javascript_alerts'
end
it 'deve validar alert()' do
click_button 'Alerta'
mensagem = page.driver.browser.switch_to.alert.text
puts mensagem
expect(mensagem).to eql 'Isto é uma mensagem de alerta'
end
... | true |
208a5aaecad12ada036610bb183a4f450be8f442 | Ruby | albertbahia/wdi_june_2014 | /w02/d02/najee_gardner/GoT_inheritance/lib/knight.rb | UTF-8 | 461 | 3.5 | 4 | [] | no_license | require_relative 'human.rb'
class Knight < Human
attr_reader :king_name, :sword_name
def initialize(name, house, sword_name)
super(name, house, 50)
@sword_name = sword_name
@hp = 500
end
def pledge_loyalty(king)
@king_name = king.name if king.is_a?(King)
king.is_a?(King)
end
def intr... | true |
fdacc912101d3d1a089b293855729f1748c9d942 | Ruby | KKennedyCodes/ride-share-rails | /app/models/driver.rb | UTF-8 | 601 | 2.953125 | 3 | [] | no_license | class Driver < ApplicationRecord
has_many :trips
##Validation Code
validates :name, presence: true;
validates :vin, presence: true, uniqueness: true
#logic for drivers total earnings here.
#logic for drivers average rating here.
def average_rating
average = 0
count = 0
self.trips.each... | true |
1459d9e63584dccf3569315c4f018fad2d156518 | Ruby | Ashkanthegreat/futbol | /test/game_test.rb | UTF-8 | 1,545 | 2.90625 | 3 | [] | no_license | require './test/test_helper'
require './lib/game'
require 'pry'
class GameTest < Minitest::Test
def setup
@game = Game.new({
game_id: 2017030161,
season: "20172018",
type: 'Postseason',
date_time: '4/11/18',
away_team_id: "30",
home_team_id: "52",
away_goals: 2,
home_goals: 3,
v... | true |
a1a00ec39db6af87b172896e3edc13c9c6639da5 | Ruby | jeffwklein/youtoobbot | /scraper.rb | UTF-8 | 1,422 | 2.65625 | 3 | [
"MIT"
] | permissive | # scraper.rb
# Authors: Jeffrey Klein and James Smith
require 'redditkit'
require './video_data'
if ARGV.size != 1
puts "Must provide exactly one filename argument"
exit
end
csv = File.new("#{ARGV[0]}.csv","w")
# Constants
HundredsOfPosts = 100
BotUsername = "vid-info"
BotPassword = "csci4330"
###
RedditKit.si... | true |
ac530120de7f79f2da26973145766467d4c9ffc3 | Ruby | fpscube/tradingRobot | /histdata/concat.rb | UTF-8 | 358 | 2.625 | 3 | [] | no_license | output = ""
Dir.glob("*.csv") {|file_name|
data = File.read(file_name)
puts file_name
output = output + data.gsub(/;[^;]$/,",").gsub(/^.*;/,"")
}
output = "double gPriceTab[]={\n" + output + "\n};\n\nint gPriceTabSize = sizeof(gPriceTab)/sizeof(double);";
file = File.open("priceTab.cpp","w")
file.write(... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.