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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26a87ccaef2dca6057e30ee5bb2f0e5d8a3bd8ea | Ruby | thrasher-redhat/shiftzilla | /lib/shiftzilla/release.rb | UTF-8 | 808 | 2.59375 | 3 | [] | no_license | require 'shiftzilla/milestones'
module Shiftzilla
class Release
attr_reader :name, :targets, :milestones, :default, :token
def initialize(release,builtin=false)
@name = release['name'].to_s
@token = @name.tr(' .', '_')
@targets = release['targets']
@default = release... | true |
6217361e38817a758da4ab6ed9fe850aaca8b549 | Ruby | dgriego/bgc_admin | /app/models/trip.rb | UTF-8 | 1,061 | 2.671875 | 3 | [] | no_license | # == Schema Information
#
# Table name: trips
#
# id :integer not null, primary key
# title :string
# location :string
# seats :integer
# alt_seats :integer
# start_date :date
# start_time :time
# end_time :time
# published :boolean default("false")
#
class Trip < Act... | true |
26639b9cefc838730594db39edfee8ddf650bf90 | Ruby | ga-wolf/WDI10-Homework | /robinson-lam/week_04/exercise_01/array.rb | UTF-8 | 446 | 3.53125 | 4 | [] | no_license | days_of_the_week = %w/ Monday Tuesday Wednesday Thursday Friday Saturday Sunday /
days_of_the_week.unshift(days_of_the_week.pop)
weekends = []
weekdays = []
days_of_the_week.each do |day|
if day == "Saturday" || day == "Sunday"
weekends.push(day)
else
weekdays.push(day)
end
end
print weekends
print wee... | true |
4c9b0f3d544ee41961c648d98ff5a0119171415e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/ed195c6874e84025a588bfaf661c7450.rb | UTF-8 | 341 | 3.515625 | 4 | [] | no_license | class Hamming
def self.compute(nucleotide_a, nucleotide_b)
#return nucleotide_a == nucleotide_b ? 0 : 1
b_arr = nucleotide_b.split('')
counter = 0
nucleotide_a.split('').each_with_index do |item, index|
break if index > b_arr.length - 1
counter = counter + 1 if item != b_arr[index]
end
... | true |
31ff3ec0629724dba52f054504ff78129e9ce7da | Ruby | f-meloni/vulcano | /lib/vulcano/parsed_class.rb | UTF-8 | 929 | 2.6875 | 3 | [
"MIT"
] | permissive | require "vulcano/codable_key"
module Vulcano
class ParsedClass
attr_reader :name
attr_reader :variables
attr_reader :codable_keys
attr_reader :is_public
attr_reader :is_struct
def initialize(name, variables, is_public, is_struct)
@is_public = is_public
@name = name
@variabl... | true |
78676dac76c6d71c36b8aa9af4dd7168a1349abe | Ruby | foxed/Learn-To-Program | /7-deafgram.rb | UTF-8 | 593 | 3.8125 | 4 | [] | no_license | #First Deaf Grandma Exercise
puts ''
while true
input = gets.chomp
if input != input.upcase
puts 'SPEAK UP!!'
else input == input.upcase
year = 1920 + rand(18)
puts 'OH NO, NOT SINCE, ' + year.to_s + '!'
if input == 'BYE'
break
end
end
end
#Second Deaf Grandma Exerc... | true |
1ccae9c8974bee15b9480a34c3076c6d4efcc7f0 | Ruby | rubyworks/shomen-model | /work/deprecated/core_ext/times.rb | UTF-8 | 2,976 | 3.890625 | 4 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Extend Numeric with time constants
class Numeric # :nodoc:
# Time constants
#
# TODO: Use RichUnits instead (?)
#
module Times # :nodoc:
MINUTES = 60
HOURS = 60 * MINUTES
DAYS = 24 * HOURS
WEEKS = 7 * DAYS
MONTHS = 30 * DAYS
YEARS = 365.25 * DAYS
# Number of se... | true |
f2685a8663d700159eac2357e5b877d1bc78a8f1 | Ruby | dlbirch/rubyPOS | /spec/right_t_padder_spec.rb | UTF-8 | 657 | 2.703125 | 3 | [] | no_license | require 'rspec'
require 'right_t_padder'
describe RightTPadder do
before(:each) do
@rtp = RightTPadder.new()
end
it 'should return an instance' do
expect(@rtp).to be_truthy
end
it 'should handle data longer than max length without throwing an exception' do
expect(@rtp.pad("1234567890123456789"... | true |
d5e68b52cbccdc46c64e86b23335652caceddd04 | Ruby | mlyubarskyy/leetcode | /362_design_hit_counter.rb | UTF-8 | 984 | 3.875 | 4 | [] | no_license | class HitCounter
=begin
Initialize your data structure here.
=end
def initialize()
@q = [[0, 0]] * 300
end
=begin
Record a hit.
@param timestamp - The current timestamp (in seconds granularity).
:type timestamp: Integer
:rtype: Void
=end
def hit(timestamp)
idx = timesta... | true |
9c39bfa9b8d125738c859c1a01629d49a305d4c6 | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/62.unique-paths.rb | UTF-8 | 1,177 | 3.515625 | 4 | [] | no_license | #
# @lc app=leetcode id=62 lang=ruby
#
# [62] Unique Paths
#
# https://leetcode.com/problems/unique-paths/description/
#
# algorithms
# Medium (54.32%)
# Total Accepted: 514.5K
# Total Submissions: 947.2K
# Testcase Example: '3\n2'
#
# A robot is located at the top-left corner of a m x n grid (marked 'Start' in
# t... | true |
22efedbebd5394d900d6aba08047d758718c7a2a | Ruby | oshou/procon | /AC/ARC/arc014a.rb | UTF-8 | 64 | 3.28125 | 3 | [] | no_license | n = gets.to_i
if n % 2 == 0
puts "Blue"
else
puts "Red"
end
| true |
49fbe07d8e92b01d61a2ef1e517eae2735cfde2f | Ruby | martom87/workshops_tennis | /spec/tennis/player_spec.rb | UTF-8 | 390 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../lib/tennis/player.rb'
RSpec.describe Player do
subject { described_class.new(points_amount, name)}
let(:points_amount) {15}
let(:name){'Edek'}
it 'returns players points amount' do
expect(subject.points_amount).to eq(points_amount)
end
it 'retur... | true |
dfbf6fa4bd7c1bd441808f8a60ee29f5e6ecb7d5 | Ruby | jvanderhoof/you_got_listed | /lib/you_got_listed/response.rb | UTF-8 | 679 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module YouGotListed
class Response
attr_accessor :ygl_response
def initialize(response, raise_error = true)
rash = Hashie::Rash.new(response)
self.ygl_response = rash.ygl_response
raise Error.new(self.ygl_response.response_code, self.ygl_response.error) if !success? && raise_error
... | true |
5a0d571f30ce7de852d7ba05e260256f15d46eb7 | Ruby | SocialCentivPublic/cheftacular | /lib/cheftacular/stateless_actions/cloud.rb | UTF-8 | 7,804 | 2.640625 | 3 | [
"MIT"
] | permissive |
class Cheftacular
class StatelessActionDocumentation
def cloud
@config['documentation']['stateless_action'][__method__] ||= {}
@config['documentation']['stateless_action'][__method__]['long_description'] = [
"`cft cloud <FIRST_LEVEL_ARG> [<SECOND_LEVEL_ARG>[:<SECOND_LEVEL_ARG_QUERY>]*] ` this... | true |
99146c4bc4b64653b3822888c77848f5046503ee | Ruby | golovanov1512/golovanov1512.github.io | /ruby_practice/ruby.rb | UTF-8 | 684 | 3.671875 | 4 | [] | no_license | class PasswordGen
def initialize(count_symbol)
@count_symbol = count_symbol
@vowel = %w(a e i y o u)
@consonant = %w(q w r t p s d f g h j k l m n b v c x z)
end
def vowel_or_consonant(index)
if index.even?
to_large_letter(@vowel[rand(@vowel.size)], index)
else
@consonant[rand(@co... | true |
fc99120ceae42dad870f23ab836aea3c7515e294 | Ruby | KarlaRobinson/Learning_Ruby_basics | /TablasDeMultiplicar.rb | UTF-8 | 273 | 3.34375 | 3 | [] | no_license | def multiplication_tables(num)
arr = Array(1..num)
range = Array(1..10)
arr.each do |arrElem|
range.each do |rangeElem|
value = arrElem * rangeElem
print "#{value}\t"
end
print "\n"
end
end
multiplication_tables(5)
multiplication_tables(7) | true |
6f737db76ae1aa152f008f92748f78227cf709c4 | Ruby | thelazyfox/euler | /p023/solution.rb | UTF-8 | 1,337 | 3.875 | 4 | [] | no_license | class Array
def sum
self.inject {|a,b| a+b}
end
end
def factor(n)
if n == 0
[0]
elsif n == 1
[1]
else
i = 2
while n % i > 0
i += 1
end
if i == n
[n]
else
factor(i) + factor(n/i)
end
end
end
def divisors(n)
primes = Hash.new(0)
factor(n).each do |va... | true |
ea0265e2cdc8c93a05feb1a30614b6d39f6a5d95 | Ruby | ahawkins/chassis-example | /app/utils.rb | UTF-8 | 523 | 2.625 | 3 | [] | no_license | class PhoneNumbersValidator
include ActiveModel::Validations
include Enumerable
validate do |phone_numbers|
phone_numbers.each do |number|
begin
UserRepo.find_by_phone_number! number
rescue UserRepo::UnknownPhoneNumber => ex
phone_numbers.errors.add :phone_numbers, ex.message
... | true |
13ea2ff883d92ce54ddf96396ae60a71b35ba372 | Ruby | AnyPresence/do_sqlserver-tinytds | /lib/do_sqlserver_tinytds/tiny_tds_extension.rb | UTF-8 | 3,168 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'tiny_tds'
module TinyTds
class Client
#raw_execute - freetds does not support dynamic sql so
#we're going to translate dynamic sql statements into a plain
#sql statement
def raw_execute(text , *var_list)
dynamic_sql = text.clone
flat_sql = var_list.empty? ? dynamic_sql : process... | true |
653a4efe08d00b0cb3279b4d784e4416a4871e55 | Ruby | czuger/nyog-sothep | /app/models/game_core/dices.rb | UTF-8 | 405 | 3.0625 | 3 | [
"MIT"
] | permissive | class GameCore::Dices
def self.method_missing( method_name, amount = 1 )
# puts method_name.inspect
dice_amount_match = method_name.to_s.match( /d(\d+)/ )
raise "Method mising : #{method_name}" unless dice_amount_match
# puts dice_amount_match.inspect
dice_amount = dice_amount_match[1].to_i
... | true |
d8af0ce17477b182e399e903d19e4a611299e0c6 | Ruby | RobinBailey84/PDA | /Static_and_Dynamic_Task_A/specs/card_game_spec.rb | UTF-8 | 745 | 3.21875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../card_game.rb')
require_relative('../card.rb')
class CardGameTest < MiniTest::Test
def setup()
@card1 = Card.new("spade", 5)
@card2 = Card.new("spade", 3)
@card3 = Card.new("diamonds", 9)
@card4 = Card.new("clubs", 1)
@card5 ... | true |
3f9efc9319d9fb4d95b15f3027f199a7f8177880 | Ruby | mochizuki-pg/ruby_types | /app.rb | UTF-8 | 1,193 | 3.296875 | 3 | [] | no_license | require_relative 'lib/recipe'
require_relative 'lib/ingredient'
require_relative 'lib/instruction'
title = 'いちごで作る サンタクロース'
ingredients = [
Ingredient.new(name: 'いちご', quantity: 2, unit: '個'),
Ingredient.new(name: 'ホイップクリーム', quantity: 10, unit: 'g'),
Ingredient.new(name: 'チョコレートペン (黒)', quantity: 1, unit: '本'... | true |
fd8cbf2f5a10aa0dabad352a69923e26de61c4be | Ruby | foood/codebreaker | /lib/codebreaker/game.rb | UTF-8 | 1,691 | 3.65625 | 4 | [
"MIT"
] | permissive |
module Codebreaker
class Game
attr_reader :secret, :player, :attempts, :hints
SECRET_SIZE = 4
MAX_ATTEMPTS = 4
def initialize(player)
@player = player
@secret = ""
@attempts = 0
@hints = 0
generate_secret
end
def generate_secret
SECRET_SIZE.times do
@secret << (Random... | true |
fd1975c2fb770019f2d71886f8cc9bc1def2eac8 | Ruby | Scott2bReal/intro-to-programming-with-ruby | /the-basics/4.rb | UTF-8 | 272 | 3.875 | 4 | [] | no_license | =begin
Use the dates from the previous example and store them in an array. Then
make your program output the same thing as exercise 3.
=end
movies = {"Jurassic Park" => 1995, "Forrest Gump" => 1992}
dates = []
movies.each { |k, v| dates.push(v) }
dates.each { |date| puts date }
| true |
975641d1484ae3d61f9dd23d0d7762fe21c65011 | Ruby | jaswanthJeenu/Ruby-to-MIPS-Compiler | /project/test/pointer2.rb | UTF-8 | 32 | 2.703125 | 3 | [] | no_license | a = []
a[1]=2
b = a+4
puts b[0]
| true |
e983ea42be36d6713b012ab81411405881ae3fc6 | Ruby | goldstar/blackbeard | /lib/blackbeard/metric_date.rb | UTF-8 | 376 | 2.625 | 3 | [
"MIT"
] | permissive | module Blackbeard
class MetricDate
#TODO refactor with MetricHour to be compaosed
attr_reader :date, :result
def initialize(date, result)
@date = date
@result = result
end
def results_for(segments)
segments.map{|s| result[s].to_f }
end
def result_rows(segments)
[... | true |
9333388773173d9b3d6f89fc31ec9f9a63e30672 | Ruby | SiCuellar/Code_Wars | /Ruby/decode_morse/algo.rb | UTF-8 | 240 | 3.0625 | 3 | [] | no_license | require 'pry'
#test/Hash Provided
class Algo
morse_letters = morseCode.split
morse_letters.map do |let|
MORSE_CODE[let]
end
end
# morseCode.strip.split(" ").map { |w| w.split(" ").map { |c| MORSE_CODE[c] }.join }.join(" ")
| true |
7805b4ac1ac858a049a9a170c059cb545f4e640a | Ruby | MadayAlcala/Ruby-Training | /Slide4/flight/boarding.rb | UTF-8 | 1,719 | 3.953125 | 4 | [] | no_license | require './flight'
require './passenger'
class Boarding
def passenger_data
puts "What is your name:"
name = gets.chomp
puts "What is your lastname:"
lastname = gets.chomp
puts "What is your address:"
address = gets.chomp
puts "What is your phone:"
phone = gets.chomp
puts "What is y... | true |
5309a40f02e9830afe718a639562a2a57784b914 | Ruby | olistik/website-template | /app/models/cell_registry.rb | UTF-8 | 1,504 | 2.625 | 3 | [
"MIT"
] | permissive | # cell_class = Cell::Base::class_from_cell_name(cell)
# use cell_class.instance_methods(false)
# to obtain the cell's list of available actions
class CellRegistry
@@registry = []
def self.registry
register_all if @@registry.empty?
@@registry
end
def self.registry=(r)
@@registr... | true |
dafe6a7c4c703637a3bd095c9ffff4e52d26edf3 | Ruby | nax2uk/decorating-command-line | /lib/example_lolize.rb | UTF-8 | 1,889 | 3.484375 | 3 | [] | no_license | # shows how to use lolize to selectively display rainbow coloured fonts.
require 'lolize'
colorizer = Lolize::Colorizer.new
puts "
████████╗██╗░█████╗░ ████████╗░█████╗░░█████╗░ ████████╗░█████╗░███████╗
╚══██╔══╝██║██╔══██╗ ╚══██╔══╝██╔══██╗██╔══██╗ ╚══██╔══╝██╔══██╗██╔════╝
░░░██║░░░██║██║░░╚═╝ ░░░██║░░░███████║... | true |
b8f01eaca138d1b613db2351f0e4aef00243f977 | Ruby | steinuil/yubiyubi | /vtuber_handler.rb | UTF-8 | 679 | 2.609375 | 3 | [
"Unlicense"
] | permissive | require 'yaml'
require_relative 'lib/irc'
class VtuberHandler
def initialize file
@file = file
reload_list
end
def reload_list
@list = YAML.safe_load(File.read @file)
@last_mtime = File.mtime(@file)
end
def handle msg
return unless msg.command == "PRIVMSG" && msg.params[1].strip == "'ch... | true |
f9a7fa2d333e6d807009212ea8a0eae32c8adf10 | Ruby | radu-constantin/small-problems | /easy7/swap_case.rb | UTF-8 | 426 | 3.59375 | 4 | [] | no_license | UPPERCASE = ('A'..'Z').to_a
LOWERCASE = ('a'..'z').to_a
def swapcase (string)
new_string = ''
string.each_char do |char|
if UPPERCASE.include?(char)
new_string << char.downcase
elsif LOWERCASE.include?(char)
new_string << char.upcase
else
new_string << char
end
end
new_string
... | true |
ef569a58b15051a3db6ec336cbf887c4405f66a2 | Ruby | tilmitt11191/mtg | /lib/decklists/read-operate-write-deckfiles.rb | UTF-8 | 1,139 | 2.53125 | 3 | [] | no_license |
#ruby
require "logger"
require '../../lib/util/deck.rb'
require '../../lib/util/store.rb'
log = Logger.new("../../log", 5, 10 * 1024 * 1024)
log.info ""
log.info "read-operate-write-deckfiles start."
log.info ""
deckname = "BG_Con_JF"
hareruya = Hareruya.new
#### read deck
#from file
deck = hareruya.read_deckfile(... | true |
15110b65550bf6d741f3dcae793b7792c141f4d8 | Ruby | enonnai/lrthw | /ex04/drill_02.rb | UTF-8 | 168 | 3.4375 | 3 | [] | no_license | x = 5
i = 3
sum = x + i
subtraction = x - i
multiplication = x * i
division = (x.to_f / i.to_f).round(2)
puts sum
puts subtraction
puts multiplication
puts division | true |
f9ebbc7600073dd48d1d489d148b9006bfe6f9f7 | Ruby | naathyn/workspace_management | /app/models/folder.rb | UTF-8 | 584 | 2.515625 | 3 | [] | no_license | class Folder < ActiveRecord::Base
attr_accessible :name, :directory_id, :subfolder_id
belongs_to :directory
belongs_to :subfolder, foreign_key: "subfolder_id", class_name: "Folder"
has_many :documents, dependent: :destroy
has_many :subfolders, foreign_key: "subfolder_id", class_name: "Folder", dependent: :d... | true |
6169acb5a550f238064b3d508c1c0416de6b770e | Ruby | liyijie/huanct | /app/models/comment.rb | UTF-8 | 1,917 | 2.703125 | 3 | [] | no_license | class Comment < ActiveRecord::Base
attr_accessible :dianping, :gongxian, :last_time, :member, :name, :qiandao, :reg_time
# 分页显示的默认值
self.per_page = 10
def self.create_by_member member
comment = Comment.new
comment.member = member
url = "http://www.dianping.com/member/#{member}"
params = {
... | true |
ec51717a567eaa7196298caa45045348010e5eb6 | Ruby | emarcha/scuba_shop_app | /app/models/tour.rb | UTF-8 | 1,078 | 2.84375 | 3 | [] | no_license | class Tour < ActiveRecord::Base
has_many :bookings,
before_add: :check_available_seats,
dependent: :destroy
before_create :populate_available_seats
before_create :parse_time_input
validates :title,
presence: true,
length: { maximum: 100 }
validates :tour_date... | true |
61e75895925e9a0e0101fd060a8a77520017221d | Ruby | shiratsu/shoppingrails | /lib/tasks/amazon_crawl.rb | UTF-8 | 2,162 | 2.53125 | 3 | [] | no_license | # coding: utf-8
require 'open-uri'
require 'json'
require "date"
require 'amazon/ecs'
class Tasks::AmazonCrawl
#変数初期化
@@api_url = 'http://ecs.amazonaws.com/onca/xml'
# メイン処理
def self.execute(category_id)
Amazon::Ecs.options = {
:associate_tag => 'shiratsu2014-22',
:AWS_access_key_id => '14G... | true |
0d528387539bb61d3ebe386340304d8130f40caa | Ruby | arthurgeek/nyane | /lib/nyane.rb | UTF-8 | 1,065 | 2.6875 | 3 | [
"MIT"
] | permissive | require "rack"
class Nyane
attr_reader :request, :response
def initialize(&block)
@actions = []
@root = File.dirname(eval("__FILE__", block.binding))
@app = self
instance_eval(&block)
end
def get(route, &block)
@actions << [route, :get, block]
end
def post(route, &block)
@action... | true |
1b0d83e49b368417aa9311a3271b2fee8c29037f | Ruby | mariecain27/key-for-min-value-v-000 | /key_for_min.rb | UTF-8 | 387 | 3.359375 | 3 | [
"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)
min_key = nil
start_zero_compare_value = 0
name_hash.each do |key, value|
if start_zero_compare_value == 0 || value < start_zero_compare_value
start_zero... | true |
ff53c895da85ee18364cff388c06413a3533f5bd | Ruby | kkchu791/coding-challenge-kkchu791 | /pop_growth/app/services/csv_parser.rb | UTF-8 | 1,866 | 2.984375 | 3 | [] | no_license | require 'csv'
class CSVParser
attr_reader :file, :type
def initialize(file, type)
@file = file
@type = type
end
def process_file
if type == "zip_codes"
process_zip_codes
else
process_core_based_stat_areas_file
end
end
def process_zip_codes
CSV.foreach(file, headers: tr... | true |
0b0f08bc99f2f12867e208c569f46e0aeefb598b | Ruby | ricardo39985/square_array-online-web-ft-120919 | /square_array.rb | UTF-8 | 115 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
# your code here
new_array = []
array.each { |n| new_array.push(n * n )}
new_array
end
| true |
79a95adc93347a5505ec2ae33a6ab1a87c9b1ae3 | Ruby | rabbitz/TryRuby | /test/unit/output_test.rb | UTF-8 | 1,497 | 2.734375 | 3 | [] | no_license | require 'test_helper'
# tests if the TryRubyOutput translation, for use with mouseapp_2.js and similar
# is working correctly
class OutputTest < Test::Unit::TestCase
def test_simple_result
t = TryRuby::Output.standard(result: [12,24])
assert_equal("=> \033[1;20m[12, 24]", t.format)
end
def test_re... | true |
5ad69a1732ec39a48e25e1609b0c19ad86054171 | Ruby | ghostlambdax/recognizeapp | /app/queries/streamable_recognitions.rb | UTF-8 | 3,418 | 2.640625 | 3 | [] | no_license | class StreamableRecognitions
# Order of badge is important because it is referenced in some places.
BADGE_FILTERS = %w[anniversary recognition]
attr_reader :current_user, :network, :company, :team_id, :filter_by
def self.call(args)
new(args).query
end
def initialize(args)
extract_args args
end
... | true |
44312f2669ca82b411ebd4affc6923254d100f01 | Ruby | petejkim/skeleton | /spec/support/fixture_saver.rb | UTF-8 | 1,996 | 2.515625 | 3 | [] | no_license | module FixtureSaver
# Saves the markup to a fixture file using the given name
def save_fixture(markup, name)
fixture_path = File.join(Rails.root, '/tmp/js_dom_fixtures')
Dir.mkdir(fixture_path) unless File.exists?(fixture_path)
fixture_file = File.join(fixture_path, "#{name}.fixture.html")
File.open... | true |
01435bb4522fd104e51e381dbcb4a08d56a75688 | Ruby | appwrite/sdk-for-ruby | /lib/appwrite/models/database_list.rb | UTF-8 | 766 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | #frozen_string_literal: true
module Appwrite
module Models
class DatabaseList
attr_reader :total
attr_reader :databases
def initialize(
total:,
databases:
)
@total = total
@databases = databases... | true |
c1aea7d6320a4ceb29aac46cf41026bb7e0fe64d | Ruby | thomgray/trot | /lib/trot/builder.rb | UTF-8 | 2,399 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'fileutils'
module Trot
class Builder
def initialize(target)
@target = target
end
def build
puts 'target', @target
object_files = []
source_files_to_compile = []
puts '.>>>>> sources', source_files
source_files.each { |source_file|
file_name = File.bas... | true |
4cc3f8f36afeaa02b71ab20b85ef9751768d79b1 | Ruby | codyruby/cursus_thp | /week2/scrapping/lib/dark_trader.rb | UTF-8 | 2,602 | 3.71875 | 4 | [] | no_license | # Il est possible de faire le programme en n'allant que sur une seule URL. C'est un bon moyen pour faire un programme rapide car ne chargeant pas 2000 pages HTML.
# Tout se jouera sur la rédaction d'un XPath pertinent et précis qui extrait juste ce qu'il faut d'éléments HTML. Puis un bon traitement de ces éléments pour... | true |
739e5d9b68e24eb2e8342b07e288ce2e1bc7d52b | Ruby | lipanski/hexagonly | /lib/hexagonly/polygon.rb | UTF-8 | 3,210 | 3.1875 | 3 | [
"MIT"
] | permissive | module Hexagonly
class Polygon
# Adds Polygon methods to an object. The Polygon corners are read via
# the #poly_points method. You can override this method or use the
# #poly_points_method class method to set a method name for reading
# polygon corners.
#
# @example
# class MyPolygon
... | true |
f57c32cc91e84ca130fe042ad0295673acc1b6da | Ruby | neilkelty/programming-ruby | /chapter_2/arrays_and_hashes.rb | UTF-8 | 515 | 3.21875 | 3 | [] | no_license | a = [1, 'cat', 3.14] # array with three elements
puts "The first element is #{a[0]}"
# set the third element
a[2] = nil
puts "The array is now #{a.inspect}"
inst_section = {
'cello' => 'string',
'clarinet' => 'woodwind',
'drum' => 'percussion',
'oboe' => 'woodwind',
'trumpet' => 'brass',
'violin' => 'strin... | true |
d40ce89baeb2022053f6b186aa9d474f8e9073a2 | Ruby | sedx876/badges-and-schedules-online-web-pt-090919 | /conference_badges.rb | UTF-8 | 461 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
attendees = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def badge_maker(name) do
puts "Hello, my name is #{name}"
end
def batch_badge_maker
#attendees = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
attendees.each do |name|
puts "Hello, my name is #{na... | true |
7eb689f0b6dc4e819e985b029674a4338cbe0a33 | Ruby | emielhagen/convoyer | /app/services/location_service.rb | UTF-8 | 1,582 | 2.828125 | 3 | [] | no_license | class LocationService
attr_reader :from_location, :to_location, :base_url, :api_key
attr_accessor :params
def initialize(params)
@from_location = params.dig('convoy', 'from_location')
@to_location = params.dig('convoy', 'to_location')
@base_url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/'
... | true |
ecaff361c4d36023aa63db8598b973fadab76d7a | Ruby | justinsteele/coveragetrends | /lib/coveragetrends.rb | UTF-8 | 385 | 2.578125 | 3 | [] | no_license | require './lib/circleci'
require 'csv'
class CoverageTrends
def initialize(username, project)
@username = username
@project = project
end
def run
ci = CircleCI.new(@username, @project)
stats = ci.get_stats
save_stats(stats)
return 1
end
def save_stats(array)
open('output/data.... | true |
ad303f4648f2f1a6777612cb890b5cad578c9364 | Ruby | masayasviel/algorithmAndDataStructure | /OtherContests/zone2021/mainA.rb | UTF-8 | 124 | 2.984375 | 3 | [] | no_license | s = gets.chomp
ans = 0
9.times do |i|
tmp = s[i..(i+3)]
if tmp == "ZONe" then
ans += 1
end
end
puts ans | true |
8be9ef85d7c0a93338c4b0d7c307096cbf57091f | Ruby | lvzhongwen/pms | /pms-server/app/models/enum/base_type.rb | UTF-8 | 913 | 2.9375 | 3 | [] | no_license | class BaseType<BaseClass
def self.method_missing(method_name, *args, &block)
mn=method_name.to_s.sub(/\?/, '')
if /\w+\?/.match(method_name.to_s)
begin
self.const_get(mn.upcase)==args[0].to_i
rescue
super
end
else
super
end
end
class<<self
define_metho... | true |
8d31576108cf12c70df5f17b43b77ba4654f8212 | Ruby | broad-well/aoc2016 | /day5.rb | UTF-8 | 815 | 3.0625 | 3 | [
"Unlicense"
] | permissive | # Day 5 of Advent Of Code, 2016
INPUT = 'ojvtpuvg'
require 'digest'
require 'set'
part2 = ARGV.include? 'part2'
fast = ARGV.include? 'fast'
i = 0
$c = Set.new if part2
pwd = part2 ? '00000000' : ''
loop do
md5 = Digest::MD5.hexdigest INPUT + i.to_s
if !fast && i % 50 == 0 then print "Fresh MD5: #{md5}\r" end
#... | true |
67bca19a9af6b558856e1e41533d40e7ebb62ef7 | Ruby | kaiks/unobot | /lib/misc.rb | UTF-8 | 1,188 | 2.5625 | 3 | [] | no_license | # TODO: separate logger from the rest
# require 'extend_logger.rb'
require 'logger'
$logger = Logger.new('logs/unobot.log', 'daily', 10)
$logger_queue = Queue.new
$logger.datetime_format = '%H:%M:%S'
$logger_thread = Thread.new do
loop do
while $DEBUG == true && $bot && $bot.config.engine.busy == false
$l... | true |
f058f9161f4811e53e651d66fdcc132612299588 | Ruby | pelensky/lrthw | /ex34.rb | UTF-8 | 471 | 4.03125 | 4 | [] | no_license | animals = ["bear", "ruby", "peacock", "kangaroo", "whale", "platypus"]
puts "The animal at 1 is ruby"
puts animals[1]
puts "The third animal is peacock"
puts animals[3-1]
puts "The first animal is bear"
puts animals[0]
puts "The animal at 3 is kangaroo"
puts animals[3]
puts "The fifth animal whale"
puts animals[5-1]
p... | true |
80878e5d6076dca59107ace39240663a11ee1ac8 | Ruby | shumShum/libgdx-tanks | /bin/src/config/sound_storage.rb | UTF-8 | 451 | 2.5625 | 3 | [] | no_license | class SoundStorage
SOUND_PATH_BASE = {
fire: 'res/sounds/fire.wav',
damage: 'res/sounds/damage.wav',
explosion: 'res/sounds/explosion1.wav',
}
attr_reader :sound_base
def initialize
@sound_base = {}
SOUND_PATH_BASE.each_pair do |name, path|
@sound_base[name] = Gdx.audio.newSound(G... | true |
e0876c35e82f5f6cb841924662bc35f3a818849d | Ruby | alexgh123/ruby_projects | /sorting.rb | UTF-8 | 395 | 3.9375 | 4 | [] | no_license | def bubble_sort(array)
n = array.length
p "hey n = #{n}"
loop do
swapped = false
(n-1).times do |i|
p "hey i is changing... it is: #{i}"
p "swapped is: #{swapped}"
if array[i] > array[i+1]
array[i], array[i+1] = array[i+1], array[i]
swapped = true
end
end
b... | true |
5bd2846dce2e47b7098eccbc9c4d7f3ed5dcfef3 | Ruby | eltonsantos/ruby-simple-files | /rot13.rb | UTF-8 | 1,046 | 3.15625 | 3 | [] | no_license | secret = {" "=>" ", "A"=>"N", "B"=>"O", "C"=>"P", "D"=>"Q", "E"=>"R", "F"=>"S", "G"=>"T", "H"=>"U", "I"=>"V", "J"=>"W", "K"=>"X", "L"=>"Y", "M"=>"Z", "N"=>"A", "O"=>"B", "P"=>"C", "Q"=>"D", "R"=>"E", "S"=>"F", "T"=>"G", "U"=>"H", "V"=>"I", "W"=>"J", "X"=>"K", "Y"=>"L", "Z"=>"M", "a"=>"n", "b"=>"o", "c"=>"p", "d"=>"q", ... | true |
108757892c14d44adcf7648aa8117ef40bbfa3b4 | Ruby | youssefbenlemlih/ruby-practice | /ptp1/classes/text_editor.rb | UTF-8 | 1,586 | 3.90625 | 4 | [] | no_license | # A class used to read text files
# Author:: Youssef Benlemlih
# Author:: Jonas Krukenberg
class TextEditor
attr_reader :content
# Initialize a new instance of *TextEditor*
# with String @content
# @param path: The path to the text file
def initialize(path)
File.open(path) { |f| @content = f.read }
end
... | true |
6ff71a3aadac96fef685e6c47fb1597b57bd7ab1 | Ruby | ranjanisrini/guvi | /compare.rb | UTF-8 | 79 | 3.28125 | 3 | [] | no_license | def helo
n = gets.chomp
y = gets.chomp
if (n==y)
true
else
false
end
end
| true |
45fd67c15721c85ba3d778629a49bfc48f927462 | Ruby | jolohaga/imap_model | /app/models/mail_server.rb | UTF-8 | 3,918 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'core_extensions'
module MailServer
class IMAP
# Mail::IMAP
#
# Description:
# Wrapper around Net::IMAP
#
require 'net/imap'
attr_accessor :settings, :connection, :query, :authenticated, :messages
attr_reader :access, :folder, :before, :body, :cc, :from, :on, :since, :subject... | true |
7ba612ede0baf65d596ecbaa27293ddb047251d9 | Ruby | arvidnilber/standard-biblioteket | /lib/power.rb | UTF-8 | 134 | 3.1875 | 3 | [] | no_license | def power(num1,up)
i = 0
output = 1
while i < up
output *= num1
i += 1
end
return output
end
| true |
a1cbb184cdf6a1b80139e28fb575699de359feb1 | Ruby | anners/ruby | /reverse-string | UTF-8 | 360 | 3.59375 | 4 | [] | no_license | #!/usr/bin/env ruby
string = "beer"
puts string
puts string.reverse
array = ["b", "e", "e", "r"]
array.reverse.each do |a|
print a
end
yarra = Array.new
yarra << array.pop until array.empty?
print yarra
array = ["b", "e", "e", "r"]
def rev(array)
x = array.pop
rev(array) if array.length > 0
array.unsh... | true |
9b053de63a29dde735ff362986c2605dc97703aa | Ruby | alexharv074/puppet-strings | /lib/puppet-strings/yard/util.rb | UTF-8 | 1,265 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'puppet/util'
# The module for various puppet-strings utility helpers.
module PuppetStrings::Yard::Util
# Trims indentation from trailing whitespace and removes ruby literal quotation
# syntax `%Q{}` and `%{q}` from parsed strings.
# @param [String] str The string to scrub.
# @return [String] A scrubbe... | true |
f4b9571473abeb92a0888911b7929c6e44c8f417 | Ruby | asiandcs/baseballbot_discord | /baseball_discord/commands/links.rb | UTF-8 | 847 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module BaseballDiscord
module Commands
# Basic debug commands that should log to the output file
module Links
extend Discordrb::Commands::CommandContainer
command(:bbref, help_available: false) do |event, *args|
LinksCommand.new(event, *args).bbref
end... | true |
a1a97dff36f7bc6a6f21e474242bbc46da973d40 | Ruby | kmbhuvanprasad/ruby_set4 | /modules/1.rb | UTF-8 | 211 | 3.390625 | 3 | [] | no_license | module W4
def z1
puts "I am number 1"
end
def z3
puts "I am number 3"
end
def nUMBER_4
puts "I am number 4"
end
end
class Q4
include W4
end
number = Q4.new
number.z1
number.z3
number.nUMBER_4 | true |
f7f5a843c92857a0a41cdbf62c91496cfb9c7c10 | Ruby | anukin/game_of_life-9_07 | /spec/gameoflife/board_spec.rb | UTF-8 | 686 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
module Gameoflife
describe "Cell" do
it "should generate the next generation" do
board = Board.new(3, 4)
curr_gen = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
nex_gen = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
board.set_current_generation(curr_gen)
expect(boa... | true |
033355d4596a85c44409c9b1a2c837dda5c3c0b3 | Ruby | JRSoftware92/Android-Class-Generator | /AXMLGenerator/src/main/android_sqlite_reader.rb | UTF-8 | 4,269 | 3.015625 | 3 | [] | no_license | require_relative 'sqlite_reader.rb'
require_relative 'sqlite_model.rb'
#Class for reading DDL and DML SQLite files
#TODO Rewrite to export generic xml data for template generation and utilize generic regex parser
#CAN BE DONE FOR BOTH DDL AND DML
class ASqliteReader# < SqliteParser
include Sqlite
#DDL_REGEX = /[a-... | true |
a59f73504c05ebe1bf845f2206ff7dab503c3876 | Ruby | steve-alex/anagram-detector-london-web-082619 | /lib/anagram.rb | UTF-8 | 361 | 3.6875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Your code goes here!
class Anagram
@@all=[]
attr_accessor
def initialize(word)
@word = word
@@all << self
end
def self.all
@@all
end
def sort_word(word)
word.chars.sort!.to_s
end
def match(anagram)
anagram.each.select{ |word| sort_word(... | true |
326e7c03b5c2b4c9ecdd6aacc7bf20329cc18896 | Ruby | xababafr/RubyPFE | /implementation/resl_compiler.rb | UTF-8 | 2,976 | 3.015625 | 3 | [
"MIT"
] | permissive | # the compiler takes ruby code as an input, and can :
# - add probes
# - generate the ast
# - simulate the code to infer types
# - do all those 3 and create a systemC code
require "./resl_data"
require "./resl_objects"
require "./resl_objectifier"
require "./resl_dsl"
require "./resl_simulator"
require "./visitors/sys... | true |
f8f56633de925adf7bf5615ee7191495e5b55e43 | Ruby | viing937/codeforces | /src/400B.rb | UTF-8 | 223 | 2.953125 | 3 | [
"MIT"
] | permissive | n, m = gets.split.collect{|i| i.to_i}
ans = Array.new(n)
n.times do |i|
s = gets.chomp
d = s.index("G")
c = s.index("S")
if d > c
puts -1
exit
end
ans[i] = c-d
end
puts ans.uniq.size
| true |
f6531a107f9053c1e75a359c8917322bf5c90a82 | Ruby | somalipirat3/GameTracker | /lib/modules/consume_api/tracker_data_only.rb | UTF-8 | 1,615 | 2.640625 | 3 | [] | no_license | # Tracker.gg api
# Full profile requests
class ConsumeApi::TrackerDataOnly
include HTTParty
def initialize(options = {})
@data = options
@api_key = Rails.application.credentials.api_keys[:tracker_gg][:key]
endpoint = Rails.application.credentials.api_keys[:tracker_gg][:endpoint]
... | true |
738af5499acde1463b603abd941ef9d77787dd23 | Ruby | omajul85/oystercard | /spec/journey_spec.rb | UTF-8 | 991 | 2.65625 | 3 | [] | no_license | require "journey"
describe Journey do
subject(:journey) { described_class.new }
let(:station) { double :station, zone: 1 }
it "journey should not be completed" do
expect(journey).not_to be_completed
end
it 'has a penalty fare by default' do
expect(subject.fare).to eq described_class::PENALTY_FEE
end
c... | true |
f6622987eefcd67dfc0fb13290b667f403aa48ab | Ruby | tetetratra/contest | /leetcode/6_16/3.rb | UTF-8 | 237 | 3.328125 | 3 | [] | no_license | # https://leetcode.com/problems/rotate-function/
def max_rotate_function(nums)
nums.size.times.map { |n| nums.rotate(n) }.map { |arr|
arr.map.with_index { |a, i| a * i }.sum
}.max
end
nums = [4,3,2,6]
max_rotate_function(nums)
| true |
2e23550093914cb6290721de13f2f996a0c514cd | Ruby | milesstanfield/whats-for-lunch | /spec/services/time_formatter_spec.rb | UTF-8 | 646 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
describe TimeFormatter do
describe '.visit_time(time)' do
it 'formats time' do
expect(TimeFormatter.visit_time(now_time)).to eq '02/09/2016'
end
end
describe '.days_ago(formatted_time)' do
it 'returns days since time argument' do
control_time = Time.parse('2016-02-1... | true |
713714e42caa50fe0c0d22b1e6661582214e88a1 | Ruby | Bielfla27/gerenciamento-servicos | /test/models/usuario_test.rb | UTF-8 | 1,502 | 2.625 | 3 | [] | no_license | require "test_helper"
class UsuarioTest < ActiveSupport::TestCase
test "deve salvar Usuario criado corretamente" do
usuario = Usuario.new nome: 'Usuario Teste',
cpf: '39775387485',
funcao: 'Confeiteiro',
password: 'password1'
assert usuario.save
end
test "nao deve salvar Usuario ... | true |
70fdac1013f6b45b05ed53415f50f4c25c9f56b5 | Ruby | schazbot/oo-relationships-practice-london-web-career-021819 | /app/models/user.rb | UTF-8 | 1,420 | 3 | 3 | [] | no_license | class User
attr_reader :name
@@all = []
def self.all
@@all
end
def initialize(name)
@name = name
@@all << self
end
def make_pledge(project, amount)
Pledge.new(self, project, amount)
end
def make_project(project_name, goal_amount)
Project.new(project_name, s... | true |
0173a501f107144afd808149940aa2f7d2d113f8 | Ruby | bethanyr/RubyFall2013 | /week4/exercises/timer_spec.rb | UTF-8 | 663 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | require './code_timer.rb'
describe CodeTimer do
it "should run our code" do
flag = false
CodeTimer.time_code do
flag = true
end
flag.should eq true
end
it "should time our code" do
Time.stub(:now).and_return(0,3)
run_time = CodeTimer.time_code do
end
run_time.should... | true |
2854882d1c23783acb0566f985cf0822107445ae | Ruby | marshallshen/bootcamp | /ruby/closest_palindrome.rb | UTF-8 | 2,453 | 3.6875 | 4 | [] | no_license | # @param {String} n
# @return {String}
# https://leetcode.com/problems/find-the-closest-palindrome/description/
def nearest_palindromic(n)
nums = n.split("")
if nums.size == 1
return (n.to_i - 1).to_s
end
cand1 = palindrom_by_mirror(nums)
cand2 = palindrom_by_increment(nums)
cand3 = pali... | true |
3fa56c9a5165d35b68462214dab0800008978225 | Ruby | moqingxinai/pujara-emnlp17 | /scripts/data-processing/psl/prep.rb | UTF-8 | 12,278 | 2.75 | 3 | [] | no_license | # Create the files that PSL will use.
# Processing:
# - Copy over the id mapping files (not necessary, but convenient).
# - Convert all ids in triple files from string identifiers to int identifiers.
# - List out all the possible targets (test triples and their corruptions).
# - Compute and output all the energy of... | true |
1b8ef115b9d9f9894628ddf6d8c4866acfaf962c | Ruby | mcruger/HW2office_directory | /s3uploadfile.rb | UTF-8 | 823 | 2.703125 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/proj_config')
(bucket_name, file_name) = ARGV
unless bucket_name
puts "Usage: s3uploadfile.rb <BUCKET_NAME> <FILE_NAME>"
exit 1
end
# get an instance of the S3 interface using the default configuration
s3 = AWS::S3.new
#init bucket object
bucket = s3.buckets[bu... | true |
72866b79a4b4a3748c2eacc5960250b17af636e7 | Ruby | matt5342/Leetcode | /find-all-numbers-disappeared-in-an-array/find-all-numbers-disappeared-in-an-array.rb | UTF-8 | 242 | 3.171875 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer[]}
def find_disappeared_numbers(nums)
obj = nums.to_h{|c| [c,0]}
result = []
i = 1
nums.length.times do
result.push(i) if !obj[i]
i += 1
end
result
end | true |
8eab21a69b5bba49a4119a1f166d04ee77a40ef8 | Ruby | mesh1nek0x0/resolve-yukicoder | /no296/snooze.rb | UTF-8 | 210 | 3.046875 | 3 | [] | no_license | #!/bin/ruby
input = gets.chomp.split(' ')
N = input[0].to_i
H = input[1].to_i
M = input[2].to_i
T = input[3].to_i
add_minutes = T * (N - 1)
tmp = M + add_minutes + (H * 60)
puts tmp / 60 % 24
puts tmp % 60 | true |
27b96c25fe9cc8806ed47ae8464bc1e60effa58d | Ruby | hanami/view | /spec/integration/helpers_spec.rb | UTF-8 | 1,543 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe "helpers" do
let(:dir) { make_tmp_directory }
describe "in templates" do
before do
with_directory(dir) do
write "template.html.erb", <<~ERB
<%= format_number(number) %>
ERB
end
end
let(:view) {
dir = self.dir
... | true |
237d01e22dc69e0e5524e10205aaeefd341595fc | Ruby | MrRogerino/dbc-whiteboarding | /August_9/example_solutions/two_sum.rb | UTF-8 | 602 | 3.421875 | 3 | [
"MIT"
] | permissive | def two_sum(array, target) #returns true or false
map = {}
i = 0
while i < array.length
difference = target - array[i]
if map[difference]
return true
end
map[array[i]] = 1
i += 1
end
return false
end
def two_sum_positions(array, target) #returns the position of the two numbers
map... | true |
2cf0ee197dbe7397b073e444bab51ca96641a5cd | Ruby | svallero/vaf-storage | /bin/af-create-deps.rb | UTF-8 | 3,669 | 2.9375 | 3 | [] | no_license | #!/usr/bin/ruby
#
# af-create-deps.rb -- by Dario Berzano <dario.berzano@cern.ch>
#
# Creates the dependency file for AliRoot versions. The following environment
# variables are needed:
#
# AF_DEP_URL => HTTP URL containing the list of AliEn packages for ALICE
# AF_DEP_FILE => destination file on the local filesystem... | true |
73fec8add9f7fc3b3f90d635deeab38f8f8ce2fb | Ruby | plapicola/enigma | /test/key_test.rb | UTF-8 | 954 | 2.859375 | 3 | [] | no_license | require_relative 'test_helper'
class KeyTest < Minitest::Test
def setup
@key = Key.new("02715")
end
def test_it_exists
# skip
assert_instance_of Key, @key
end
def test_it_can_return_the_key_as_a_string
# skip
assert_equal "02715", @key.key
end
def test_it_can_generate_a_random_key... | true |
c84950ef5553d61ae6abaac695b46429810d6e38 | Ruby | pshussain/Backup | /unlock.rb | UTF-8 | 541 | 2.640625 | 3 | [] | no_license | require 'time'
for i in 0..100 do
puts i.to_s
start_time=Time.now
(file = File.new('shared_file','r')).flock(File::LOCK_EX)
end_time=Time.now
diff=end_time-start_time
puts diff
lines = file.readlines
#if(lines[0]!="line1\\n")
puts lines
if lines != nil and lines != "" and !lines.empty?
put... | true |
236c175cc2d7245974204337cb1a9c0ae341dd2f | Ruby | amosjyng/UAS-Website | /app/models/event.rb | UTF-8 | 1,944 | 2.890625 | 3 | [] | no_license | class Event < ActiveRecord::Base
attr_accessible :content, :time, :title, :date, :day_time
validates :title, :date, :day_time, :content, :presence => true
validates :content, :length => {:minimum => 5}
validate :date_valid
validate :time_valid
def date
if time.nil?
return Time.now.strftime('%m/%... | true |
3b15db27fd5fd3aca4620217f2e5c04372312895 | Ruby | alejandro-medici/retrospectiva | /extensions/retro_wiki/ext/project.rb | UTF-8 | 1,241 | 2.53125 | 3 | [
"MIT"
] | permissive | Project.class_eval do
has_many :wiki_pages, :dependent => :destroy do
def find_or_build(title)
record = find_by_title(title)
unless record
record = build
record.title = title
end
record
end
end
has_many :wiki_files, :dependent => :destroy do
d... | true |
f5347127a5641b42dc75136a45e2bb514ab9fbb0 | Ruby | siwS/theysaidsocli | /lib/quote_terminal_printer.rb | UTF-8 | 542 | 3.203125 | 3 | [
"MIT"
] | permissive | require 'hirb'
class QuoteTerminalPrinter
def initialize(quote)
@quote = quote
@print_text = "#{@quote.author} said: \"#{@quote.quote}\""
@width = @print_text.size
end
def print
puts
print_separator
print_quote
print_separator
puts
end
private
def print_quote
puts "~... | true |
9cc6e2334547b5b9d1323c688d7b94efc9045855 | Ruby | seanwbrooks/blackjack | /spec/lib/hand_spec.rb | UTF-8 | 1,204 | 3.15625 | 3 | [] | no_license | require "spec_helper"
RSpec.describe Hand do
let(:hand) { Hand.new }
let(:card) { Card.new("♦", "2") }
let(:ace) { Card.new("A", "♦") }
let(:four_ace) { [Card.new("A", "♦"), Card.new("A", "♥"), Card.new("A","♦"), Card.new("A","♥")] }
describe '#initialize' do
it 'should take no arguments and create an ... | true |
5f8dee8f9cc482fd533ba7dbf88ab20648f2b355 | Ruby | popkorn96/ruby-music-library-cli-onl01-seng-ft-072720 | /lib/artist.rb | UTF-8 | 588 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
extend Concerns::Findable
attr_accessor :name, :songs
@@all = []
def initialize(name)
@name = name
@songs = []
@@all << self
end
def name
@name
end
def self.all
@@all
end
def self.destroy_all
@@all.clear
end
def save
@@all << self
end
def self.create(name)
new_artist =... | true |
af9a8a9417a8cbff7f48db3a093a3827283d16a7 | Ruby | achiurizo/boson | /lib/boson/inspector.rb | UTF-8 | 3,687 | 2.703125 | 3 | [
"MIT"
] | permissive | module Boson
# Scrapes and processes method attributes with the inspectors (MethodInspector, CommentInspector
# and ArgumentInspector) and hands off the data to FileLibrary objects.
#
# === Method Attributes
# Method attributes refer to (commented) Module methods placed before a command's method
# in a File... | true |
571521803896c418306191cafeeeb3f89307ace3 | Ruby | MuhammadTamzid/framgia_crb_v2 | /app/validators/name_validator.rb | UTF-8 | 608 | 2.953125 | 3 | [] | no_license | class NameValidator < ActiveModel::Validator
def validate record
# name may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen
if !(record.name =~ /^(?!-)(?!.*--)[A-Za-z0-9-]+(?<!-)$/i)
record.errors[:name] << "may only contain alphanumeric characters or single... | true |
ca567f6ac7bc9ac5ce370db9c43c015bd867c5d5 | Ruby | mdixon47/Codewars-Ruby | /8-kyu/Basic Fizz Buzz.rb | UTF-8 | 649 | 4.6875 | 5 | [] | no_license | #Description:
#FizzBuzz is probably the second most popular way to introduce beginners to the art of coding
#(the first probably being the ancient Fibonacci sequence, the grandfather of all the algorithm theory).
#In this very basic kata you will have to create a function that
#returns the same numbers that is given ... | true |
49bfaf32b0b1dbf85829fa22fbe3a7ca4eff7b00 | Ruby | sebatapiaoviedo/dibujandoasteriscosypuntos | /asteriscos_y_puntos.rb | UTF-8 | 145 | 3.015625 | 3 | [] | no_license | aux = ""
numero = ARGV[0].to_i
for i in (1..numero)
#i%2 == 0
if i.even?
aux += "."
else
aux += "*"
end
end
puts aux | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.