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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a7069650a00b5d9c8ae064be49be66b7fecff840 | Ruby | concord-consortium/rigse | /rails/lib/default_runnable.rb | UTF-8 | 3,153 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | class DefaultRunnable
class <<self
def create_default_runnable_for_user(user, name="simple default #{TOP_LEVEL_CONTAINER_NAME}", logging=false)
unless runnable = user.send(TOP_LEVEL_CONTAINER_NAME_PLURAL).find_by_name(name)
runnable = TOP_LEVEL_CONTAINER_NAME.camelize.constantize.create do |i|
... | true |
b52c97e77be056256dc4374ec5c2b9dca327397d | Ruby | zddhub/ruby_exercise | /test/soft_wrap_test.rb | UTF-8 | 869 | 3.140625 | 3 | [
"MIT"
] | permissive | require "minitest/autorun"
require_relative "../exercise/soft_wrap.rb"
class SoftWrapTest < Minitest::Test
include Wrap
def test_that_should_be_wrap_if_text_is_longer_than_max_length
text = "abc" + " abc" * 5
assert_equal "abc abc abc abc\nabc abc", wrap(text, 15)
end
def test_that_should_be_wrap_if_t... | true |
980e8ed9a8b6cec1b5fedb91f01253e42cd3ad3a | Ruby | shuuuuun/reiwa-puzzle | /data/csv2json.rb | UTF-8 | 1,435 | 3.25 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# $ ./data/csv2json.rb ./data/gengo_data.csv > ./gengo-puyo/gengo_data.json
require 'csv'
require 'json'
input_file = ARGV.first
# puts "input_file: #{input_file}"
# 時代,元号名,読み,始期,終期,年数,天皇名,改元理由
headers = %i(era yomi begin_date end_date year_count emperor_name reason)
results = {}
# input = CSV.r... | true |
b93c080b3295ccb43519ed97e10813342a0c8512 | Ruby | Ec-Ikonne/platform-code-test | /update_quality.rb | UTF-8 | 1,362 | 3.109375 | 3 | [] | no_license | require 'award'
def update_quality(awards)
awards.each do |award|
case award.name
when "Blue Star"
handle_blue_star(award)
when "Blue Distinction Plus"
#do nothing. We can put this as default or omit it entirely from the switch case.
when "Blue First"
handle_blue_first(award)
... | true |
e89ee872513841286d7b29d583c2a0794efb5cf8 | Ruby | akandeel/ruby_fundamentals2 | /exercise5.rb | UTF-8 | 127 | 2.6875 | 3 | [] | no_license | def temperature_convert (num)
celcius = (num.to_i - 32) * (5 / 9.0)
puts "celcius is #{celcius} yay!"
end # testng ssh
| true |
809508f692c7469f84fff448112f6e81975171ff | Ruby | jaredbeck/graph_matching | /benchmark/mcm_bipartite/complete_bigraphs/benchmark.rb | UTF-8 | 648 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# No shebang here. Usage:
# BM_DIR='benchmark/mcm_bipartite/complete_bigraphs'
# ruby -I lib "$BM_DIR/benchmark.rb" > "$BM_DIR/time.data"
require 'benchmark'
require 'graph_matching'
MIN_SIZE = 2
MAX_SIZE = 500
$stdout.sync = true
def complete_bigraph(n)
g = GraphMatching::Graph::B... | true |
f5a399b4f493a83acf488be394b914fb7c306ce6 | Ruby | dweinand/mesabi | /lib/mesabi/route_map.rb | UTF-8 | 2,045 | 2.65625 | 3 | [
"MIT"
] | permissive | module Mesabi
class RouteMap
attr_accessor :routes
def initialize
self.routes = []
yield self if block_given?
end
def match(path, options={})
self.routes << [nil, Route.new(path, options)]
end
def recognize(path, meth)
routes.each do |route|
... | true |
f964bd88212410d4d89d8840c34fc0d6765b0a35 | Ruby | ethunk/Launch-Academy | /chillow/spec/house_spec.rb | UTF-8 | 646 | 2.921875 | 3 | [] | no_license | require 'spec_helper'
describe House do
let(:home) {House.new("7109 Junction Village Avenue", "Las Vegas", "NV", "89119", 225000)}
context "prints address details" do
it "returns a street number and name" do
expect(home.address).to eq("7109 Junction Village Avenue")
end
it "returns a ci... | true |
2d3294839892db96b68b60aa51d06af74e0c0692 | Ruby | tamura2004/atcoder | /lib/ruby/しゃくとり法.rb | UTF-8 | 1,146 | 3.3125 | 3 | [] | no_license | # lo,hi,cnt,ans = 0,0,1,0
# while hi < n
# # 右を進める
# cnt *= a[hi]
# hi += 1
# # 条件を満たすまで左を追いつく
# while k < cnt
# cnt /= a[lo]
# lo += 1
# end
# # 条件を満たしている
# len = hi - lo
# ans = len if ans < len
# end
class Syakutori
attr_reader :a, :n, :k, :lo, :hi, :cnt, :ans
def initialize(n,k,a)
... | true |
8b06e2a965c43a3334d5b3370fd103b5aac8c4f0 | Ruby | bdwyertech/chef-rundeck2 | /lib/chef-rundeck/util.rb | UTF-8 | 1,648 | 2.625 | 3 | [
"MIT"
] | permissive | # Encoding: UTF-8
# rubocop: disable LineLength
#
# Gem Name:: chef-rundeck
# Module:: Util
#
# Copyright (C) 2016 Brian Dwyer - Intelligent Digital Services
#
# All rights reserved - Do Not Redistribute
#
require 'json'
module ChefRunDeck
# => Utility Methods
module Util
extend self
####################... | true |
844252d8c37a39bf5513585d8aa91394c693aa81 | Ruby | upstarter/ruby_algorithms | /lib/ruby_algorithms/algorithms/strings/string_similarity.rb | UTF-8 | 1,773 | 3.90625 | 4 | [
"MIT"
] | permissive | require 'set'
# string similarity
module StringSimilarityMeasures
def self.set_overlap(tokens1,tokens2)
tokens1_set,tokens2_set = [tokens1,tokens2].map { |tokens| tokens.to_set }
tokens1_or_2_set = tokens1_set | tokens2_set
tokens1_and_2_set = tokens1_set & tokens2_set
return tokens1_and_2_set.length.... | true |
2a7dbddea955ca514cf713d45c48688b95157e7a | Ruby | alphagov/local-links-manager | /app/lib/local_links_manager/import/summariser.rb | UTF-8 | 2,246 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module LocalLinksManager
module Import
class Summariser
def initialize(name, import_source_name)
@name = name
@import_source_name = import_source_name
@import_source_count = 0
@missing_record_count = 0
@missing_id_count = 0
@invalid_record_count = 0
@... | true |
d28cf8f27401daf979afe2c158caef80f48ba1b2 | Ruby | iwilliams83/my-select-prework | /lib/my_select.rb | UTF-8 | 231 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | nums = [1, 2, 3, 4, 5]
def my_select(collection)
i = 0
temp = []
while i < collection.length
if yield(collection[i]) == true
temp.push(collection[i])
end
i += 1
end
temp
end
my_select(nums) do |n|
n.even?
end
| true |
0babca5309eaae7cddf306e31edba566bd997b45 | Ruby | malachaifrazier/remotework | /app/services/link_shortening_service.rb | UTF-8 | 451 | 2.921875 | 3 | [] | no_license | class LinkShorteningService
CHARSET = ('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a
def initialize(persist = ShortenedLink)
@persist = persist
end
def short_url(long_url)
shortened_link = @persist.find_or_create_by!(long: long_url) do |s|
s.short = (0...6).map{ CHARSET[rand(CHARSET.size)] }.jo... | true |
795e0611024d9fc84ff75d9ced8d10fa9ade8abd | Ruby | timomitchel/inventory | /test/inventory_test.rb | UTF-8 | 2,269 | 3.15625 | 3 | [] | no_license | require "minitest/autorun"
require "minitest/pride"
require './lib/inventory'
require "./lib/date"
require "./lib/store"
class InventoryTest < Minitest::Test
def test_an_inventory_exists
inventory = Inventory.new('some data')
assert_instance_of Inventory, inventory
end
def test_inventory_can_hold_date
... | true |
ee603ddb2904b4a1dcbfae742466b9c7a6c38f93 | Ruby | jhartwell/ironruby | /Tests/Experiments/Methods/to_proc.rb | UTF-8 | 338 | 3.015625 | 3 | [] | no_license | class B
def foo
puts 'super'
end
end
class C < B
def foo x
super()
a = 1
puts 'foo'
end
end
x = C.new
m = x.method :foo
p m
1.times &m.to_proc
def foo m
Proc.new { |*args| m.call(*args) }
end
#q = foo(m)
z = m.to_proc
eval("p local_variables", z)
eval(... | true |
701611fde1227963a0d9fc265c7c4497609425ab | Ruby | ghuong/coding-problems | /rotate_matrix.rb | UTF-8 | 1,242 | 4.09375 | 4 | [] | no_license | # Rotate NxN matrix 90 degrees
# Assumption: matrix is an N-array of N-arrays
def rotate_matrix(matrix)
n = matrix.length
(n / 2).times do |j|
(j..n-2-j).each do |i|
top = matrix[j][i]
matrix[j][i] = matrix[n-1-i][j] # copy left half into top half
matrix[n-1-i][j] = matrix[n... | true |
dc62f67d49c52c2233d156b7b88c09b1169e78c3 | Ruby | miller-a61/Practice | /codeeval/easy/notSoClever/notSoClever.rb | UTF-8 | 358 | 2.90625 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
line = line.chomp.split('|')
iter = line[1].to_i
line[0] = line[0].chomp
sort = line[0].split.map(&:to_i)
a = 0
b = 1
while iter > 0
if sort[a] > sort[b]
temp = sort[b]
sort[b] = sort[a]
sort[a] = temp
iter -= 1
a = 0
b = 1
else
a += 1
b += 1
... | true |
aabfdda707afbb42978d59866e086bd2762daddd | Ruby | nanma80/euler_project | /p226_250/p235/v1.rb | UTF-8 | 279 | 3.515625 | 4 | [] | no_license | def sum_brute_force(n, r)
sum = 0.0
(1..n).each do |k|
sum += (900 - 3 * k) * (r ** (k - 1))
end
sum
end
def sum(n, r)
((900 - 3 * n) * (r ** n) - 897.0) / (r - 1.0) +
3.0 * r * (r ** (n - 1) - 1.0) / (r - 1.0) ** 2
end
p sum_brute_force(10, 2.0)
p sum(10, 2.0) | true |
5bf88e0fd0dd29583da983019cd587b24457e6c7 | Ruby | daltonamitchell/ruby-algorithms | /spec/caesar_cipher_spec.rb | UTF-8 | 1,174 | 4.15625 | 4 | [
"ISC"
] | permissive | # Write a method that takes in an integer `offset` and a string.
# Produce a new string, where each letter is shifted by `offset`. You
# may assume that the string contains only lowercase letters and
# spaces.
#
# When shifting "z" by three letters, wrap around to the front of the
# alphabet to produce the letter "c".
... | true |
832d2c9f36b143de21fee879327ece5691e7d55a | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w02/d03/Mary/vending_machine/spec/vendingmachine_spec.rb | UTF-8 | 3,893 | 3.21875 | 3 | [] | no_license | require_relative '../lib/sku'
require_relative '../lib/vendingmachine'
describe VendingMachine do
let(:vm) do
VendingMachine.new([
Sku.new('1', 'Coke', 1.50, 5),
Sku.new('2', 'Diet Coke', 1.50, 0),
Sku.new('3')
])
end
describe "#get_sku" do
it "should return a Sku object for a vali... | true |
1a94bd911a8677fcc3f06a7eefb041aa413ce784 | Ruby | funnythingz/sandbox-ruby | /times.rb | UTF-8 | 127 | 2.921875 | 3 | [] | no_license | 0..24.times do |hour|
0..60.times do |minute|
puts "#{sprintf("%0#{2}d", hour)}:#{sprintf("%0#{2}d", minute)}"
end
end
| true |
983c2d9d93f36f60d24a37bc30310ca7b63e5741 | Ruby | wouerner/algoritmos | /nivel01/respostas/ruby/exercicio07.rb | UTF-8 | 262 | 3.0625 | 3 | [] | no_license | print "O preço do carro na fabrica: "
carro_fabrica = gets.to_i
percentual = (carro_fabrica * 28)/100
imposto = (carro_fabrica * 45)/100
preco_consumidor = carro_fabrica + percentual + imposto
puts "O preço do carro ao consumidor é de #{preco_consumidor}"
| true |
8375dde3880eb20ba20e8a3f0c1a72683fa6ad14 | Ruby | steveeliopoulos/phase-0-tracks | /ruby/secret_agents.rb | UTF-8 | 1,687 | 4.34375 | 4 | [] | no_license |
def encrypt(string)
# Initizlize count to zero (outside of the while loop)
index = 0
# Loop through the items in the string using a while loop
while index < string.length
# Replace letter at index with letter following in the alphabet making an exception for z
if string[index] == "z"
string[index]= "... | true |
319b38274d4cb2dca1c14c5a4a18463002d7f9c7 | Ruby | cupofjoy/collections_practice-nyc-web-042318 | /collections_practice.rb | UTF-8 | 781 | 3.953125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort do |a, b|
a <=> b
end
end
def sort_array_desc(array)
array.sort do |a, b|
b <=> a
end
end
def sort_array_char_count(array)
array.sort do |a, b|
a.length <=> b.length
end
end
def swap_elements(array)
array[1], array [2] = array[2], array [1]
return arra... | true |
cc4df73e921f810ffb57d6fdc74311258ea1a4c4 | Ruby | timstott/fluent-plugin-claymore | /lib/fluent/plugin/parser_claymore.rb | UTF-8 | 2,403 | 2.671875 | 3 | [] | no_license | require 'fluent/plugin/parser'
require 'claymore/gpu_hash_rate'
require 'claymore/total_hash_rate'
module Fluent
module Plugin
class ClaymoreParser < Fluent::Plugin::Parser
Fluent::Plugin.register_parser('claymore', self)
# Extract gpu index, temperature, old and new fan speed
#
# Exampl... | true |
18cfab8a675442cf3bf6acd71eeb6c17e36d2db6 | Ruby | versionone/verver | /spec/verver/loader/asset_spec.rb | UTF-8 | 1,320 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'verver/loader/asset'
describe Verver::Loader::Asset do
subject do
attributes = {rank: 'General', full_name: 'Robert E. Lee', favorite_ice_cream: 'chocolate'}
Verver::Loader::Asset.new('Member:42:99', attributes)
end
describe '#oid' do
it "removes the moment from the oid" do
subject.o... | true |
8dea05f1891cf07fe776ba8174286d54ee9906b9 | Ruby | jwrathall/Rails-Music-Discovery | /app/models/user.rb | UTF-8 | 1,247 | 2.625 | 3 | [] | no_license | class User < ActiveRecord::Base
require 'bcrypt'
require 'securerandom'
EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
attr_accessible :username , :hash_password,:id
attr_protected :salt
attr_accessor :password
before_save :create_password
after_save :clear_fields
validates :username,:... | true |
b2cf6906c5be38450bb9deeadb1f8072c3505dda | Ruby | daimyo-college/ruby-super-intro-lesson | /yazawa8/chapter9/9-1.rb | UTF-8 | 588 | 3.9375 | 4 | [] | no_license | #モジュール内にメソッドを定義
module ChocolateChip
def chocolate_chip
@name += "チョコレートチップ"
end
end
#クラスにモジュールを入れる
#初期化メソッドとnameメソッドを実装
class Drink
include ChocolateChip
def initialize(name)
@name = name
end
def name
@name
end
end
#インスタンスを生成 インスタンス変数に引数を渡す
#インスタンスメソッドの実行
#インスタンス変数を表示... | true |
29d0b0c06373dbfd107409815392799b7e8c3849 | Ruby | nickyp/nanoc | /test/data_sources/test_filesystem_combined.rb | UTF-8 | 7,309 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'test/helper'
class Nanoc3::DataSources::FilesystemCombinedTest < MiniTest::Unit::TestCase
include Nanoc3::TestHelpers
# Test preparation
def test_setup
# Create data source
data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
# Remove files to ... | true |
af037b767ac18f3d696733671a8ca1d76bc59de7 | Ruby | tienduy-nguyen/exo-unkle | /backend/db/seeds.rb | UTF-8 | 2,436 | 2.59375 | 3 | [
"MIT"
] | permissive | #***********************************************************************************************************************************#
# Notice #
# Before run the rai... | true |
bc7d16774e3ae9427d2f03919ebe65d28f1432de | Ruby | yulia-2008/ruby-oo-practice-flatiron-zoo-exercise-nyc01-seng-ft-062220 | /lib/Zoo.rb | UTF-8 | 643 | 3.65625 | 4 | [] | no_license | class Zoo
@@all=[]
attr_accessor :name, :location
def initialize(name, location)
@name=name
@location=location
@@all << self
end
def animals
Animal.all.select {|animal| animal.zoo==self}
end
def self.all
@@all
end
def animal_species
all_species=[]
animals.map do |animal|... | true |
dde9320135add97d85f832836458ff04619cd6ed | Ruby | isLittleHusky/caesar-cipher | /caesar_cipher.rb | UTF-8 | 563 | 3.9375 | 4 | [] | no_license | require "pry"
def caesar_cipher(string, shift)
cipher = ""
for string.split("").each do |char|
p(char)
if char.between?("a","z")
if (char[0].ord + shift) > 90
cipher += (char[0].ord + shift - 90 + 65).chr
else
cipher += (char[0].ord + shift).chr
end
elsif char.between?("A","Z")
... | true |
ea82b38e5fd8060053137b74113c54eb751dd81c | Ruby | lffg-archive/rb--learning-ruby | /sections/005/app.rb | UTF-8 | 125 | 3.296875 | 3 | [] | no_license | 10.times do |i|
i += 1
if (i.to_s.length == 1)
i = "0" + i.to_s;
end
puts "Estou na vez de número: #{i}!"
end
| true |
989bf5c133b784ad0903296158166205f1aa63ea | Ruby | MarkCTest/cucumber | /webTest/spec/word_count_spec.rb | UTF-8 | 240 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative '../features/word_count.rb'
require 'rspec'
describe WordCount do
context "counting words" do
it "can count three words" do
wc = WordCount.new("there should be six words here")
wc.result.should == 6
end
end
end | true |
66637bb09f12622dc422cf9e069cef57b08c0070 | Ruby | tylergaugler16/the_odin_project_repo | /hangman/hangman.rb | UTF-8 | 2,076 | 3.921875 | 4 | [] | no_license | require 'yaml'
class Hangman
attr_reader :word
attr_accessor :guesses , :solution, :guesses_remaining
def initialize
@word= get_word_from_file()
@guesses_remaining=@word.length()+1
@solution=""
@guesses=[]
(@word.length-2).times{@solution.concat("-")}
puts "do you want to load a file?(y/n)"
reply... | true |
662cdfb47e5711e6f2e5595b5aa56e93d355594c | Ruby | sh19910711/github-issues-label-manager | /lib/server/models/repository.rb | UTF-8 | 1,737 | 2.5625 | 3 | [
"MIT"
] | permissive | require "server/models"
require "server/common"
module Server
module Models
class Repository
include Server::Common
include Server::Models
include Mongoid::Document
field :owner, type: String
field :name, type: String
field :reponame, type: String
has_many :labels
... | true |
4190b7bfc20753e4b3b18f12a3e770c3f509f480 | Ruby | Hansen-Nick/RB101 | /101-109_practice_problems/easy_3/searching_101.rb | UTF-8 | 548 | 4.1875 | 4 | [] | no_license | def prompt(string)
puts "==> #{string}"
end
prompt("Enter the 1st number:")
int_1 = gets.to_i
prompt("Enter the 2nd number:")
int_2 = gets.to_i
prompt("Enter the 3rd number:")
int_3 = gets.to_i
prompt("Enter the 4th number:")
int_4 = gets.to_i
prompt("Enter the 5th number:")
int_5 = gets.to_i
prompt("Enter the ... | true |
eb304adf7431e9f606a45620fa40a6df78eecee3 | Ruby | shervonc/programming-univbasics-nds-nds-to-insight-understand-lab-atlanta-web-021720 | /lib/nds_explore.rb | UTF-8 | 425 | 2.828125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'directors_database'
require 'pp'
# Call the method directors_database to retrieve the NDS
def pretty_print_nds(nds)
# Change the code below to pretty print the nds with pp
pp nds
end
def print_first_directors_movie_titles
movies = directors_database[0][:movies]
... | true |
bb1583b9eece148830c60fecebd03d6daadb37a8 | Ruby | metacorn/black_jack | /source/history.rb | UTF-8 | 219 | 3.0625 | 3 | [] | no_license | class History
attr_reader :list
def initialize
@list = []
end
def clear
@list = []
end
def write(action)
@list << action
end
def not_empty?
!@list.empty?
end
end
| true |
f28c12e45b1cdb2401bce86228c4122cdeb8d96b | Ruby | htachib/clerk | /lib/mappers/unfi_east_reclamation.rb | UTF-8 | 2,064 | 2.515625 | 3 | [] | no_license | module Mappers
class UnfiEastReclamation < Base
class << self
def prepare_rows(raw_rows)
raw_rows.map do |raw_row|
prepared_row = OutputHeaders::ROW_FIELDS.deep_dup
prepared_row['Customer'] = 'UNFI East'
prepared_row['Parser'] = 'UNFI East Reclamation'
prepar... | true |
27be9a34a02ed0f78f15430d83dd03818d6cd6c6 | Ruby | cmccandless/ExercismSolutions-ruby | /isogram/isogram.rb | UTF-8 | 186 | 2.5625 | 3 | [
"MIT"
] | permissive | class Isogram
def self.isogram?(word)
word = word.downcase.chars.select { |ch| ch =~ /[[:alpha:]]/ }
word.size == word.uniq.size
end
end
module BookKeeping
VERSION = 4
end
| true |
5b7224de70b292da76466f43f3316a1730f2b730 | Ruby | sigfrid/stati_stica | /lib/stati_stica/t_distribution.rb | UTF-8 | 266 | 2.546875 | 3 | [
"MIT"
] | permissive | module StatiStica
class TDistribution
require 'yaml'
def self.value_for(probability, degrees_of_freedom)
t_table = YAML::load_file "#{File.dirname __dir__}/tables/t#{probability.to_s[-2,2]}.yml"
t_table[degrees_of_freedom]
end
end
end
| true |
1cf6041c5aea3b1dfe35b90c59de674ee62a3422 | Ruby | wloonstra/circles | /circles/ruby/version2/src/ruby/circles.rb | UTF-8 | 518 | 3.390625 | 3 | [] | no_license | class Circle
attr_accessor :radius
def initialize(radius)
@radius = radius
end
end
class CircleCombination
attr_accessor :smallCircle, :bigCircle
def initialize(circleA, circleB)
if circleA.radius < circleB.radius
@smallCircle = circleA
@bigCircle =... | true |
319fe681ec4e84be682811d9f688ea94de8d3ac7 | Ruby | Alex-Joseph/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 480 | 2.984375 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
puts "Enter new store name"
@input =... | true |
83d9680053540f5d59c6493ed115f1b651aacfcd | Ruby | joe-re/todoist | /lib/todoist/base.rb | UTF-8 | 1,272 | 3.03125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'httparty'
require 'json'
module Todoist
##
# The Todoist::Base class is responsible for making all queries to the
# todoist web API.
class Base
class AuthenticationError < StandardError; end
include HTTParty
format :json
##
# Get authentication token using user email and password... | true |
4275bebe0735c14ce3991d6f9be15737cef381b3 | Ruby | learn-co-students/nyc-mhtn-040218 | /20-intro-tdd/program.rb | UTF-8 | 774 | 4.1875 | 4 | [] | no_license | require 'pry'
class Palindrome
def self.is_palindrome?(word)
if (word.class != String)
raise ArgumentError
end
test_word = word.gsub(' ', '').gsub(/[[:punct:]]/, '').downcase
test_word == test_word.reverse
end
end
# x! = x * (x-1) * (x-2) all the way to 1
# 4! = 4 * 3 * 2 * 1 = 24
# x! is ... | true |
3e2f4395fc763fff359081a2c1d5099e2b2b6309 | Ruby | russenoire/LS_core | /rb101/exercises/lesson_1/documentation/004_manda_blox.rb | UTF-8 | 67 | 3.59375 | 4 | [] | no_license | a = [1, 4, 8, 11, 15, 19]
puts a.bsearch {|elem| elem > 8 } #=> 11
| true |
57fa480fc160d7cdd48bfcc13820ed3c4947c92b | Ruby | annikulin/code-classifier | /naive_bayes/resources/ruby/cluster_spec.rb | UTF-8 | 3,388 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
describe Mongo::Cluster do
let(:client) do
double('client')
end
describe '#==' do
let(:addresses) do
['127.0.0.1:27017', '127.0.0.1:27019']
end
let(:cluster) do
described_class.new(client, addresses)
end
context 'when the other is not a cluster' do
... | true |
12145d40d57c1987d15a83ff489cea29946125d9 | Ruby | filipebarcos/metaprogramming-talk | /duplication/method_missing_restaurant.rb | UTF-8 | 486 | 2.828125 | 3 | [] | no_license | class Restaurant
def initialize(restaurant_id, data_source)
@id = restaurant_id
@ds = data_source
end
def method_missing(name, *args)
super if !@ds.respond_to?("get_#{name}_info")
info = @ds.send("get_#{name}_info", @id)
price = @ds.send("get_#{name}_price", @id)
result = "#{name.to_s.capitalize}: #{inf... | true |
cc5f2413f97b1f2f12baeef3089c580d6bbd5010 | Ruby | kaylawoodbury/library-challenge | /lib/library.rb | UTF-8 | 1,805 | 3.28125 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'date'
class Library
attr_accessor :catalog, :return_date, :books_checked_out
STANDARD_TIME_MONTH = 1
def initialize
@catalog = YAML.load_file('./lib/data.yml')
@return_date = set_return_date()
end
#User can search
def author_search(user_search)
@... | true |
cf96f5bdb27991e20ce3662172e6f45e34c9a3bf | Ruby | cokernel/embaggen | /lib/kdl/embaggen.rb | UTF-8 | 904 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'find'
module KDL
class Embaggen < BagIt::Bag
def add_directory(src_dir)
Find.find(src_dir) do |src_file|
if File.file? src_file
bag_file = relative_bag_path_from src_dir, src_file
dir = File.join data_dir,
File.dirname(bag_file)
FileU... | true |
9679ea211f8c53c8050f6fb82e1d630e0f839e85 | Ruby | tjcarney89/key-for-min-value-immersive-alum | /key_for_min.rb | UTF-8 | 614 | 3.890625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
require 'pry'
def key_for_min_value(name_hash)
if name_hash.empty?
return nil
else
lowest_num = 0
selected_name = ""
num_only = name_hash.collect do |name, num|
num
en... | true |
3e57a6729526f0d6ad6fc8f2d81657828a6b8b26 | Ruby | loveshell/asciinema.org | /app/models/cursor.rb | UTF-8 | 367 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class Cursor
attr_reader :x, :y, :visible
def initialize(x, y, visible)
@x, @y, @visible = x, y, visible
end
def diff(other)
diff = {}
diff[:x] = x if other && x != other.x || other.nil?
diff[:y] = y if other && y != other.y || other.nil?
diff[:visible] = visible if other && visible != ot... | true |
5fb4512b2397aa39e35da557d8c07e3447806f5e | Ruby | athlaliel/ruby-learning | /ruby/loop2.rb | UTF-8 | 682 | 3.625 | 4 | [] | no_license | jobs = ["戦士", "魔道士", "暗殺者", "盗賊"]
jobs.each do |job|
puts "名前: #{job}"
end
4.times do |i|
puts i + 1
end
member_count = 0
works = []
2.times do
work = {}
puts "職業は何ですか?"
work[:name] = gets.chomp
puts "実務経験は何年ですか?"
work[:year] = gets.to_i
works << work
if work[:year] >= 1
puts "#{work[:name]}さんは... | true |
fc69dd8ca22fa2059e103415362da5013feb41d6 | Ruby | agarun/homeworks | /alpha-course/week1/day2/problems/lib/00_silly_blocks.rb | UTF-8 | 195 | 3.40625 | 3 | [] | no_license | def reverser(&block)
string = yield
string.split.map(&:reverse).join(" ")
end
def adder(value = 1, &block)
yield + value
end
def repeater(number = 1, &block)
number.times { yield }
end
| true |
6317a26843ad41dc6e8d1f7cf8d7ea2bcd326d86 | Ruby | katemyer/recursion-writing | /lib/recursive-methods.rb | UTF-8 | 2,789 | 3.671875 | 4 | [] | no_license | # Authoring recursive algorithms. Add comments including time and space complexity for each method.
# Time complexity: O(n) because n number of multplications
# Space complexity: O(n) because n-1 in activation chain
def factorial(n)
# recursion here
if n == 0
return 1
elsif n == -1
raise Ar... | true |
0697f3fa1eeacbe86fd0bba393afad86c6df2873 | Ruby | JisuKim82/project_euler | /spec/12-highly_divisible_triangular_number_spec.rb | UTF-8 | 954 | 3.703125 | 4 | [] | no_license | require_relative 'spec_helper'
require_relative '../12-highly_divisible_triangular_number'
describe 'number_factors' do
context 'returns the total amount of factors' do
it 'returns a count of 4 when six is passed in' do
expect(number_factors(6)).to eq 4
end
it 'returns a count of 6 when twenty-e... | true |
803267fdf46144c6cbd9e0209df243832cbee095 | Ruby | adadani-r7/Ruby-Scripts | /bulk_exceptions/bulk_exceptions.rb | UTF-8 | 7,628 | 2.765625 | 3 | [] | no_license | ## Instructions:
## Step 1: Install Ruby 1.9.3 or higher (install method is dependant on platform)
## Step 2: Install the nexpose 0.5.4 gem from a command prompt(gem install -v 0.5.4 nexpose)
## Step 3: Edit the script and edit the line 'nsc = Nexpose::Connection.new('ConsoleIP', 'UserID', 'Password')' with your... | true |
007ee22efc35025919ec1df0034344cc1a6df78d | Ruby | danwhitston/learn-to-program | /Chapter6.rb | UTF-8 | 1,205 | 3.953125 | 4 | [] | no_license | puts 'IF ELSE END'
puts 'What\'s your name?'
name = gets.chomp
if name == 'Bob'
# This is how we do comments
puts 'BOB! WOOOO!'
else
# COMMENTS!
puts 'NOT BOB!'
end
puts 'WHILE END loop'
command = ''
while command != 'bye'
if command != ''
puts command
end
command = gets.chomp
end
puts 'Come again soon!... | true |
af841390185e38ff88087df2bffad790ec8aaca1 | Ruby | callanccook/callanccook.github.io | /project/rps.rb | UTF-8 | 1,239 | 4.25 | 4 | [] | no_license |
def choose
puts "Let's play rock, paper, scissors!".downcase
puts "Do you pick rock, paper, or scissors?".downcase
user_choice = STDIN.gets.chomp
comp = rand(3)
if comp == 1
comp_choice = "rock"
elsif comp == 2
comp_choice = "paper"
else comp == 3
comp_choice = "scissors"
end
puts "Computer pick... | true |
01ffb4cb61c2e5a7fed52f7694d27b31495dfc7a | Ruby | Nikita-Boyarskikh/Automorph | /backend/test/controllers/automorph_controller_test.rb | UTF-8 | 1,973 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class AutomorphControllerTest < ActionDispatch::IntegrationTest
ANSWERS = [1, 5, 6, 25, 76].freeze
setup do
signin_as_user1
end
test 'should get result for automorph numbers less or equal then 25' do
get automorph_result_url(number: 36)
assert_response :success
assert_te... | true |
51ea58eea05dae502e84542f577bdddd30d1a48f | Ruby | tribut/html2rss | /lib/html2rss/utils.rb | UTF-8 | 1,197 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'active_support/core_ext/hash'
require 'addressable/uri'
module Html2rss
##
# The collecting tank for utility methods.
module Utils
##
# @param url [String, URI]
# @param base_url [String]
# @return [Addressable::URI]
def self.build_absolute_url_from_rel... | true |
2340e1156ed98d70b16d826e9cdca4e4171b8a68 | Ruby | alopod/alopod | /lib/alopod/core/response.rb | UTF-8 | 546 | 2.546875 | 3 | [
"MIT"
] | permissive | module Alopod
class Response
extend Forwardable
def_delegators :@response, :headers, :status
attr_reader :request
def initialize(response, request)
@response = response
@request = request
end
def body
mash(raw_body.length > 0 ? JSON.parse(raw_body) : {})
end
de... | true |
01cd8d9cd4a709352d067e8882978bf57875efdf | Ruby | Jesusg1012/prime-ruby-dumbo-web-121018 | /prime.rb | UTF-8 | 183 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
if num < 2
return false
end
int = 2..num
for counter in int
if num != counter && num % counter == 0
return false
end
end
return true
end
| true |
39b686bf9916c1c8b6a0fb87773e68adfb6af54e | Ruby | JFVF/cucumber_022015 | /Pedro/practice_16.rb | UTF-8 | 45 | 2.5625 | 3 | [] | no_license | b = 7
a = 2
a = 'Hi' unless b == 7
puts a
| true |
660db8ee5ddf13f4e4778b80daaea096e4b8e380 | Ruby | gideonwhylr/photozone | /app/models/user.rb | UTF-8 | 1,185 | 2.5625 | 3 | [] | no_license | class User < ActiveRecord::Base
has_many :photos
has_many :comments
def password
@password
end
def password=(value)
@password = value
self.salt = Random.rand
self.password_digest = Digest::SHA1.hexdigest(value + self.salt.to_s)
end
def password_valid?(candidate)
return Digest::SHA1.hexdigest(candida... | true |
db4bd4efa77d800190142849a0ebbc568806a157 | Ruby | lsethi123/restaurant_puzzle | /test/unit_test/restaurant/input_test.rb | UTF-8 | 1,409 | 2.796875 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../../test_helper'
# This is the test Class for Restaurant::Input class
# containing unit test cases for the same.
class Restaurant::InputTest < Test::Unit::TestCase
def setup
@sample1 = File.dirname(__FILE__) + '/../../../sample_data.csv'
@sample2 = File.dirname(__FILE__)... | true |
1cc7ee388f9587d22288755fa697b6a787a323aa | Ruby | JProphet89/RubyRails | /Cityroots/app/models/payment.rb | UTF-8 | 1,439 | 2.78125 | 3 | [] | no_license | class Payment
attr_accessor :ip, :money, :credit_card
def initialize(remote_ip='',money='',payment_hash)
@ip = remote_ip
@money = money
@credit_card = create_credit_card(payment_hash)
end
def purchase
if @credit_card.valid?
# or gateway.purchase to do both authorize and capture
res... | true |
53af5c8e1ff5ce38fc5d5348d3ffffc5aa549bdc | Ruby | keikun17/bnet-mashery-rb | /lib/bnet/diablo3/hero.rb | UTF-8 | 6,287 | 2.515625 | 3 | [
"MIT"
] | permissive | class Bnet::Diablo3::Hero < Bnet::BnetResource
attr_accessor :paragon_level, :seasonal, :name, :hero_id,
:level, :hardcore, :gender, :dead, :hero_class, :last_update,
:active_skills, :passive_skills, :region, :battle_tag, :career,
:items, :followers, :raw_attributes,
# stats
:life, :damage, :att... | true |
f0854d8520caf3c93f217c22434e68bfb279305f | Ruby | harrysboileau/pupular | /app/models/profile.rb | UTF-8 | 792 | 2.578125 | 3 | [] | no_license | class Profile < ActiveRecord::Base
belongs_to :dog
attr_accessible :age, :breed, :gender, :location, :image, :spayed, :size
validates_presence_of :dog_id
validates :gender, inclusion: { in: ["", "Male","Female"], message: "%w{value} is not a valid gender"}
validates :size, inclusion: { in: ["", "Toy", "Smal... | true |
44ace5c293e51dfcc1e1817dd91c0da97ef0f315 | Ruby | giritheja/codetriage | /test/unit/email_decider_test.rb | UTF-8 | 561 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'test_helper'
class EmailDeciderTest < ActiveSupport::TestCase
test "decides email frequency" do
# daily
assert EmailDecider.new(rand(0..3)).now?(1)
# wait
assert EmailDecider.new(rand(4..6)).skip?(1)
# twice a week
assert EmailDecider.new(rand(7..13)).now?([3, 6, 9, 12].sample)
... | true |
0e134eed7258833837abec0bbf3b2040c944afc8 | Ruby | BearingMe/exercicios-CeV | /exs/mundo_1/ruby/019.rb | UTF-8 | 445 | 3.84375 | 4 | [
"MIT"
] | permissive | =begin
Desafio 019
Problema: Um professor quer sortear um dos seus quatro alunos para
apagar o quadro. Faça um programa que ajude ele, lendo o
nome dos alunos e escrevendo na tela o nome do escolhido.
Resolução do problema:
=end
alunos = []
4.times do
print"Digite o nome do aluno: "
a = gets.ch... | true |
d91301e7b9e32c28bcfae0b7ffbc7529488d05b4 | Ruby | labba/BISC | /Lab 8/BISC/2_CallAPI.rb | UTF-8 | 577 | 2.65625 | 3 | [] | no_license | #!/usr/bin/ruby -I/msf3/lib -Ilib/
require 'bisc'
#
# Create our BISC object, which will handle scanning for instruction
# sequences and managing scratch data space
#
bisc = BISC::Assembler.new(ARGV)
# EXERCISE:
#
# Create a return-oriented program to call a Win32 API function
# through the IAT with one or more cons... | true |
1ec89692f7a1bf2cc7650d27291d4163e6bace85 | Ruby | richardbrodie/fitreader | /lib/fitreader/sdk/sdk.rb | UTF-8 | 469 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'yaml'
class Sdk
@enums ||= YAML.load_file(File.join(File.dirname(__FILE__), 'enums.yml'))
@fields ||= YAML.load_file(File.join(File.dirname(__FILE__), 'fields.yml'))
@messages ||= YAML.load_file(File.join(File.dirname(__FILE__), 'messages.yml'))
def self.enum(name)
@enums[name]
end
def self.... | true |
0d05f13a3000f5cca2023e4ff616c7de182a8f3d | Ruby | kazzac/----Ruby | /helloruby.rb | UTF-8 | 294 | 3.234375 | 3 | [] | no_license | =begin
コメントを複数行に
わたって書く場合
=end
#←これ以降、行末までコメント
num0 = ARGV[0].to_i
num1 = ARGV[1].to_i
puts "#{num0}+#{num1}=#{num0+num1}"
puts "#{num0}-#{num1}=#{num0-num1}"
puts "#{num0}*#{num1}=#{num0*num1}"
puts "#{num0}/#{num1}=#{num0/num1}" | true |
7fb7e49f8d09c6014f3d79f2167d3a96218fd38e | Ruby | aimker/launch-school-120-oop | /02_OOP/02_Classes and Objects/exercises_rest.rb | UTF-8 | 1,071 | 3.96875 | 4 | [] | no_license | class Person
attr_accessor :name, :first_name, :last_name
def initialize(full_name)
full_name_processing(full_name)
end
def name
if @last_name == ""
@name = @first_name
else
@name = @first_name + " " + @last_name
end
end
def name=(full_name) # Exercise 3
full_name_processi... | true |
c1397101d3cf5d479b8eb125b91bb18fce2a259c | Ruby | theRingleman/flatiron-bnb-methods-v-000 | /app/models/neighborhood.rb | UTF-8 | 1,064 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Neighborhood < ActiveRecord::Base
belongs_to :city
has_many :listings
def neighborhood_openings(start_date, end_date)
listings.each do |listing|
listing.reservations.each do |reservation|
start_date <= reservation.checkout.to_s && end_date >= reservation.checkin.to_s
end
end
e... | true |
10c40ac77f383eea4e3139931c8f930b889bae7a | Ruby | beaucouplus/programming_foundations | /exercises/squaring.rb | UTF-8 | 343 | 3.6875 | 4 | [] | no_license |
def multiply(number1, number2)
number1 * number2
end
def square(number)
multiply(number, number)
end
p square(5) == 25
p square(-8) == 64
def power(number, power)
result = number
power = power - 1
power.times do
result = multiply(result, number)
end
result
end
p power(3,3) == 27
p power(2,4) == ... | true |
c678246d58966f53e39c39e6f29469f781cf39f6 | Ruby | virginiac32/W2D3 | /poker2/spec/deck_spec.rb | UTF-8 | 665 | 3.125 | 3 | [] | no_license | require 'deck'
require 'rspec'
require_relative './card'
describe Deck do
let(:deck) {Deck.new()}
describe "#initialize" do
subject(:deck) { Deck.new() }
it "initializes with a deck of 52 cards" do
expect(deck.cards.length).to eq(52)
end
end
describe "#draw" do
let(:cards) {[double... | true |
aaf85e12e2ad61de70de6838dd18e6ef113e81c9 | Ruby | justinkizer/a-A-Daily-Projects | /W3D2/reply.rb | UTF-8 | 2,510 | 2.9375 | 3 | [] | no_license | require 'singleton'
require 'sqlite3'
require_relative 'questions'
require_relative 'user'
class Reply
def self.all
reply = QuestionsDatabase.instance.execute("SELECT * FROM replies")
reply.map { |datum| Reply.new(datum) }
end
def initialize(options)
@id = options['id']
@subject_question_id = o... | true |
52e025d4c690be24d0a00de48861ce9bbe00c146 | Ruby | siakaramalegos/prep_ruby_challenges | /unique.rb | UTF-8 | 631 | 4.625 | 5 | [] | no_license | # Write a method uniques which takes an array of items and returns the array
# without any duplicates. Don’t use Ruby’s uniq method!
# uniques([1,5,”frog”, 2,1,3,”frog”])
# => [1,5,”frog”,2,3]
def uniques items
# don't want to compare the first item so start at 1
index = 1
# changed from .each and .each_with_in... | true |
18a6136e5b0e1c01ccf59831d7f762d1f436209f | Ruby | rudolph9/mail_monitor | /lib/mail_monitor/polling.rb | UTF-8 | 1,288 | 2.84375 | 3 | [
"MIT"
] | permissive | # @author Kurt Robert Rudolph (rudolph9)
#
module MailMonitor
class Polling
# @return [Int] the frequency in seconds the polling_address will be polled
attr_accessor :frequency
#
#
# @param [Int] frequency the frequency in seconds the polling_address will be polled
# @param [Mail] mailbox ... | true |
36357fc376fefe132353fdc704aab2ec8126faf4 | Ruby | sunildsr/Myproject-Sweet_docs | /app/controllers/reports_controller.rb | UTF-8 | 1,190 | 2.546875 | 3 | [] | no_license | class ReportsController < ApplicationController
def show_display_options
@dates_with_readings = Reading.available_dates
@months_with_readings = Reading.available_months
end
def results
@report_type = params[:report_type]
@date = Reading.format_date(params[:date])
@month = params[:month]
... | true |
f34c68491e3f55cd39ce5c1d5bda288f5d832d74 | Ruby | mklagassey/Launch-School | /RB101d/lesson_5/practice.rb | UTF-8 | 6,329 | 3.96875 | 4 | [] | no_license | # How would you order this array of number strings by descending numeric value?
# arr = ['10', '11', '9', '7', '8']
#
# p arr.sort_by { |elem| elem.to_i }.reverse
#
# p arr.sort { |elemA, elemB| elemB.to_i <=> elemA.to_i }
# How would you order this array of hashes based on the year of publication of
# each book, fro... | true |
a8f997bfb2077e7fd08c6a6b235198cf9f5eb23e | Ruby | Jeff-Adler/ruby-oo-relationships-practice-gym-membership-exercise-nyc01-seng-ft-062220 | /lib/lifter.rb | UTF-8 | 883 | 3.328125 | 3 | [] | no_license | class Lifter
attr_reader :name, :lift_total
@@all = []
def initialize(name, lift_total)
@name = name
@lift_total = lift_total
self.class.all << self
end
def self.all
@@all
end
def memberships
Membership.all.select do |element|
element.lifter == self
end
end
def gyms
... | true |
0b9908e087d4f11e7693a7efe44162ecba7e04fa | Ruby | amsibamsi/coding | /puzzles/ruby/lib/test/mapreduce.rb | UTF-8 | 268 | 2.609375 | 3 | [] | no_license | require 'test/unit'
require 'mapreduce'
class MapReduceTest < Test::Unit::TestCase
def test_mapreduce
m = MapReduce.new([['a','b'],['b','c']])
r = m.mapreduce(2,2)
assert_equal 1, r['a']
assert_equal 2, r['b']
assert_equal 1, r['c']
end
end
| true |
a0fc6063ece55a79ace6f5014c8fcf59ca2f38cf | Ruby | gmalicki/newstrex | /gems/gems/data_objects-0.9.6/lib/data_objects/uri.rb | UTF-8 | 892 | 2.625 | 3 | [
"MIT"
] | permissive | require 'addressable/uri'
module DataObjects
URI = Struct.new(:scheme, :user, :password, :host, :port, :specified_port, :path, :query, :fragment)
class URI
def self.parse(uri)
return uri if uri.kind_of?(self)
uri = Addressable::URI::parse(uri) unless uri.kind_of?(Addressable::URI)
self.new(... | true |
28b3574ad5ff3f442141f33fe75242c77ebc3cd8 | Ruby | aflock/emojitrans | /emojitrans.rb | UTF-8 | 1,135 | 2.9375 | 3 | [] | no_license | require 'sinatra'
require './translator'
require 'rubygems'
require 'twilio-ruby'
get '/emojitrans.rb' do
print params
initial_body = params[:Body]
from = params[:From]
unless initial_body
return "NO DATA"
end
text = initial_body.split("::")[0]
number = initial_body.split("::")[1]
unless number &&... | true |
809b8d84e7e968924170d6fe84a28abfaaf4e967 | Ruby | wachin/Windows-WachiManuales | /Sketchup/Extensiones/Window_Tools/WindowTools1.1/WindowTools1.1/frame_tool.rb | UTF-8 | 4,311 | 2.734375 | 3 | [] | no_license | =begin
# Author: tomot
# Name: FrameTool
# Description: Create a simple Window, with Frame, & Glazing
# Usage: click 3 points, on an EXISTING OPENING, creates a window frame with glazing
# Date: 2008
# Type: Tool
# Revised: 2008,09,13 Thanks to Jim Foltz... | true |
e19e02cf1a130218f3704af6178a5792a14e0889 | Ruby | reinierv4/prework | /RUBY_post_prework/week_1/housingagency.rb | UTF-8 | 1,336 | 3.859375 | 4 | [] | no_license | # Ruby exercise 1 Easier than it seems , still harder than Life
class Home
attr_reader(:name, :city, :capacity, :price)
def initialize(name, city, capacity, price)
@name = name
@city = city
@capacity = capacity
@price = price
end
end
houses = [
Home.new("Renier","No Existe",6,0),
Home.new... | true |
1ff7fca684379fcbbc4ba9ad002014550732874e | Ruby | ministryofjustice/offender-management-allocation-manager | /bin/copy-offender-from-dev.rb | UTF-8 | 1,622 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
raise 'Run it with "bin/rails runner", not on its own' unless Object.constants.include?(:Rails)
if ENV['KUBERNETES_SERVICE_HOST'].present? || ENV['DATABASE_URL'].present? || ! Rails.env.development?
raise 'Anomaly detected in your environment - you might not be on your local machine or your data... | true |
585461c92ceb008875a20061136447b7d46cdbbb | Ruby | Dujota/Ruby-comprehensive-examples-for-students | /SystemAdmini/copyingDirectoryTree.rb | UTF-8 | 1,438 | 3.3125 | 3 | [] | no_license | puts <<-EXP
lines = File.open(filename) {|f| f.readlines}
# Manipulate as needed
lines.each {|x| puts x}
# at a time
File.open(filename) do |file|
file.each_line do |line|
puts line
end
end
EXP
puts "=== copying a Directory Tree ==="
require 'fileutils'
def recurse(src,dst)
Dir.mkdir(dst)
Dir.foreach(src)... | true |
e36846b911765b2122d93e1358dfddff3442f887 | Ruby | Moesif/moesifapi-ruby | /lib/moesif_api/http/http_request.rb | UTF-8 | 907 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive |
module MoesifApi
class HttpRequest
attr_accessor :http_method, :query_url, :headers, :parameters, :username, :password
# The constructor.
# @param [HttpMethodEnum] The HTTP method.
# @param [String] The URL to send the request to.
# @param [Hash, Optional] The headers for the HTTP Request.
... | true |
1ea45814955197563a2f67e0f80606b877bc6ccf | Ruby | ashmckenzie/oggler | /lib/oggler/store/redis.rb | UTF-8 | 423 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'redis-namespace'
module Oggler
module Store
class Redis
def initialize redis
@redis = ::Redis::Namespace.new(:oggler, :redis => redis)
end
def set! feature, new_state
redis.set feature, new_state
end
def get feature
redis.get(fe... | true |
3d09395fce3a505b5fcb6aa9ead13bdf59f7722c | Ruby | KatherineGuenther/phase-0-tracks | /databases/awesome/table_utilities.rb | UTF-8 | 2,502 | 3.359375 | 3 | [] | no_license | # Display the matches for a given client id
def display_matches(db, client_id)
client = db.execute("SELECT * FROM clients WHERE id = #{client_id}")
matches = db.execute("SELECT * FROM houses WHERE price <= #{client[0][2]} AND area_id = #{client[0][3]}")
if matches.empty?
puts "Sorry. No listings m... | true |
4063df0c5bed6296e024e957d840343eb0d0a25d | Ruby | sul-dlss/SearchWorks | /spec/lib/search_works_marc/instrumentation_spec.rb | UTF-8 | 2,123 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
describe Instrumentation do
include MarcMetadataFixtures
let(:document) { SolrDocument.new(marcxml: marc_382_instrumentation) }
subject { described_class.new(document) }
describe 'values' do
it 'should return an Hash' do
expect(subject.values.class).to eq Hash
end
it ... | true |
d45442236bedd37b2637591d363c94f3a737c1e8 | Ruby | irekovic/bet_calculator | /lib/bet_calculator/units.rb | UTF-8 | 4,419 | 3.203125 | 3 | [] | no_license | module BetCalculator
class Unit
include Comparable
attr_reader :stake, :max_return
def initialize(stake, max_return)
@stake = stake.to_f
@max_return = max_return.to_f
end
def <=>(other)
if @max_return > other.max_return
+1
elseif @max_return < other.max_return
... | true |
98b70a6c28b0512b9a319d5a7a03faae617ebae3 | Ruby | renakuwa/ruby | /while2.rb | UTF-8 | 49 | 2.734375 | 3 | [] | no_license | a = 0
while(a < 10) do
p a
a sleep 1
end | true |
7d8515e705ed0b1570b12cfb15e4e63fcbadc005 | Ruby | kurtisnelson/senior-design | /app/models/game_state/lineup.rb | UTF-8 | 1,211 | 2.640625 | 3 | [] | no_license | module GameState
class Lineup < State
def initialize(id, type)
super(id)
@type = type
populate unless llength(my_name) > 0
end
def populate
r.del my_key
if @type == :home
parent_lineup = @game.home_lineup
else
parent_lineup = @game.away_lineup
end... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.