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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4f7f46f7903b6968bdcd0a2c92d2770ad28dc603 | Ruby | draalin/dockerRailsProd | /app/workers/hard_worker.rb | UTF-8 | 1,219 | 3.46875 | 3 | [] | no_license | # class HardWorker
# include Sidekiq::Worker
# def perform(*args)
# # Do something
# end
# end
class HardWorker
include Sidekiq::Worker
# To use OurWorker manually, just call the instance method:
#
# OurWorker.new.perform("super_hard")
#
# The argument can be one of "super_hard", "hard", or... | true |
cfd1b3926d692f3a97b7755466b0dd1c2c44668a | Ruby | SneyderHOL/ruby_intro | /platzi/procs.rb | UTF-8 | 487 | 3.5625 | 4 | [] | no_license | saludar = Proc.new {|nombre| puts "Hola #{nombre}" }
puts saludar.class
puts saludar.call("simon")
puts '-' * 20
class Transaction
def exec
puts "ejecutando transaccion"
if block_given?
yield
end
puts "despues del yield"
end
end
tx = Transaction.new
puts tx.exec
puts '-' * 20
puts tx.exec {
... | true |
708b52c203df96f2a49afcd443b8ac84087d6392 | Ruby | flyingbest/python-ruby | /function/4.rb | UTF-8 | 78 | 3.015625 | 3 | [] | no_license | def make_string(str, num)
return str * num
end
puts(make_string('ans', 10))
| true |
6e781804c37e954bcd2b3dd05cb69251bc313d9a | Ruby | irastypain/blackjack | /spec/engine/round_spec.rb | UTF-8 | 12,566 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
describe Blackjack::Round do
let(:player) { Blackjack::Player.new('John') }
let(:dealer) { Blackjack::Dealer.new('Smith') }
def prepare_round(cards)
deck = instance_double(Blackjack::Deck, cards: cards)
shoe = Blackjack::Shoe.new(deck, 1)
round = Blackjack::Round.new(de... | true |
ce3fb0d4c125dcd6be24dd04212f4edf05786202 | Ruby | rjungemann/simple-queue | /lib/simple/queue.rb | UTF-8 | 665 | 2.953125 | 3 | [] | no_license | require "simple/queue/version"
module Simple
class Queue
def initialize
@array = []
@mutex = Mutex.new
end
def clear
@mutex.synchronize { @array = [] }
end
def empty?
@mutex.synchronize { @array.empty? }
end
def length
@mutex.synchronize { @array.length }
... | true |
3660e8a09e9b1237f9b4f8cd94df6f1338c8b1d1 | Ruby | negi141/pittura | /app/models/work.rb | UTF-8 | 831 | 2.578125 | 3 | [] | no_license | class Work < ActiveRecord::Base
S3_URL = 'https://s3.ap-northeast-1.amazonaws.com/twi-kaki/'
def getImageUrlJpg
# img_nameに".jpg"がある場合は、そのまま返す
if self.img_name.include?('.jpg')
return S3_URL + self.img_name
else
return S3_URL + self.img_name + '.jpg'
end... | true |
ffda632f7d080af7c381da8c508593bfc5f502dd | Ruby | SimonDein/launch | /course_120_oop/lesson_4/practice_problems_easy_2/question_6.rb | UTF-8 | 582 | 3.96875 | 4 | [] | no_license | # If I have the following class:
class Television
def self.manufacturer
# method logic
end
def model
# method logic
end
end
# Which one of these is a class method (if any) and how do you know? How would you call a class method?
=begin
Answer:
Class methods are prepended by self in the method name an... | true |
5995eb2d8581d28118bc351a88342088479a7d5c | Ruby | neeraj7078/RubyService | /DB/media_queries.rb | UTF-8 | 1,945 | 2.625 | 3 | [] | no_license | require 'mysql2'
require 'json'
require_relative 'common.rb'
require 'securerandom'
def media_table_insert (inputData)
puts "table_insert::start"
puts "inputData " + inputData
inputJson = JSON.parse(inputData)
client = get_mysql_client();
puts "parsed input : " + inputJson.to_s
mediaID = SecureRandom.uuid
inser... | true |
68c904fd2f655637e7f06bf4a7b569463094126a | Ruby | sspiderd/peuler | /src/problem48.rb | UTF-8 | 78 | 2.984375 | 3 | [] | no_license | total = 0
for i in 1..1000
total += i ** i
end
p total
p total % 10000000000 | true |
8d0217cc87db69e931d30f83fb03d3e8291a09a1 | Ruby | acronism12/Country_Project | /specs/countries_spec.rb | UTF-8 | 1,250 | 3.3125 | 3 | [] | no_license | require_relative('../country_functions')
require_relative('../countries_data')
require('minitest/autorun')
class CountriesTest < MiniTest::Test
def setup
@countries = COUNTRIES
end
def test_gives_an_array_of_all_country_names
names = country_names(@countries)
assert_equal(247, names.length)
end
... | true |
cb9ed8b676444bb0c36eabe7cf712826536441f7 | Ruby | akexinad/topics | /15-yegge_questions/01-string_reverse/reverse.rb | UTF-8 | 110 | 2.765625 | 3 | [] | no_license | def reverse_string string
reversed = string.reverse()
puts reversed
end
reverse_string "desrever gnirts"
| true |
473fb34e8f6bdcfe038f946c9905ed72696c22d9 | Ruby | kealanmcd/Ruby | /Week 8/Accessorize/children.rb | UTF-8 | 1,688 | 3.359375 | 3 | [] | no_license | require './parents'
require './mixins'
class Ball < Toy
def initialize(minimum_age_group, material, size) # 4, 5 leather
super minimum_age_group, material
@size = size
end
def to_s
puts "A size #{@size} #{@class_type} suitable for age groups #{minimum_age_group}+"
end
end
class PotatoHead < Toy
... | true |
f41d9b2f5125aa2b9c35ac939874bf70e5dbb332 | Ruby | anniezh12/oo-cash-register-v-000 | /lib/cash_register.rb | UTF-8 | 909 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class CashRegister
attr_accessor :discount, :total, :last_item_price, :transactions,:item
@last_item_price
def initialize(discount=0)
@total = 0
@discount = discount
@@transactions = []
end #end of initialize
def add_item(item,price,quantity= 1)
@total += price * quantity
... | true |
d13b1f9e63bccd301b33fe9e18176d828a3716e8 | Ruby | reedlaw/ruby-mmo | /players/teeler.rb | UTF-8 | 1,423 | 3.21875 | 3 | [] | no_license | module Teeler
def self.extended(base)
base.instance_variable_set :@round, 0
end
def to_s
"Teeler"
end
def move
@round += 1
cataclysm
end
def cataclysm
if should_battle?
fight
else
monk
end
end
def should_battle?
if health >= 100 && @round < 10
... | true |
43fc50d059986ac93a93a84399204210afb91028 | Ruby | mxrch/thp_emails-bomber | /lib/app/townhalls_scrapper.rb | UTF-8 | 2,269 | 3.359375 | 3 | [] | no_license | require "nokogiri"
require "open-uri"
require "awesome_print"
require "json"
class Scrapp_All
PAGE_URL1 = "http://annuaire-des-mairies.com/loire-atlantique.html"
PAGE_URL2 = "http://annuaire-des-mairies.com/haute-corse.html"
PAGE_URL3 = "http://annuaire-des-mairies.com/seine-saint-denis.html"
def initialize
... | true |
3021c9ee41071f37126e9476315f75d89482282a | Ruby | b0bhamilton/CS169.1x-Fall2012-Berkeley | /hw1/part7.rb | UTF-8 | 216 | 3.140625 | 3 | [] | no_license | class CartesianProduct
include Enumerable
def initialize(seq1, seq2)
@seq1 = seq1
@seq2 = seq2
end
def each
return to_enum unless block_given?
@seq1.each do |a|
@seq2.each {|b| yield [a,b]}
end
end
end
| true |
702fb1fd33d4f9a4b43af3db5ff79ca6e0b6ec7c | Ruby | dvopalecky/launchschool-101 | /small_problems/seeing_stars.rb | UTF-8 | 623 | 4.3125 | 4 | [
"MIT"
] | permissive | # Write a method that displays an 8-pointed star in an nxn grid, where n is an
# odd integer that is supplied as an argument to the method. The smallest such
# star you need to handle is a 7x7 grid.
def star(n)
# create n x n nested array with ' ' as default value
matrix = Array.new(n) { Array.new(n) { ' ' } }
m... | true |
0910123cd1a50ae03d68d3135d34ea4c60be6d4d | Ruby | mhnguyen289/programming_languages-001-prework-web | /programming_languages.rb | UTF-8 | 330 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry' # binding.pry
def reformat_languages(languages)
hash = {}
languages.each do |style, type|
type.each do |name, description|
if name == :javascript
description[:style] = [:oo, style]
else
description[:style] = [style]
end
hash[name]= description
end
end
... | true |
cb1671d7f1718cf60a8cac55b99a55136bc0ee19 | Ruby | nmg9964/Common-Sense-CS | /chapter_11/riffle_shuffle.rb | UTF-8 | 1,543 | 4.90625 | 5 | [] | no_license | # Write a method that takes two linked lists and puts them together with a riffle shuffle.
# That is, if you riffle shuffle the following lists: [1, 3, 5, 7] and [2, 4, 6, 8], the resulting list should be [1, 2, 3, 4, 5, 6, 7, 8].
class Node
attr_accessor :data, :next_node
def initialize(data)
@data = data
... | true |
6afb272432fb04ec7dd64d49496cb1f774d801b0 | Ruby | marcin-jedynski/UAM-algorytmy-rozproszone | /TEMAT-C/46/client.rb | UTF-8 | 2,225 | 2.59375 | 3 | [] | no_license | require 'ffi-rzmq'
# This example shows the basics of a CURVE-secured REP/REQ setup between
# a Server and Client. This is the minimal required setup for authenticating
# a connection between a Client and a Server. For validating the Client's authentication
# once the initial connection has succeeded, you'll need a ZA... | true |
d71f8d394b1c1a0a6516fe0968b482160f6fdaa7 | Ruby | cha63506/buzz2 | /app/models/review_from.rb | UTF-8 | 1,341 | 2.578125 | 3 | [] | no_license | class ReviewFrom < ActiveRecord::Base
has_many :reviews
belongs_to :product
belongs_to :link_url
attr_accessible :phrase
attr_accessible :product_id
def self.clean(str)
# str.sub!(/Review from/,'')
str.sub!(/This review is from:/i,'')
str.gsub!(/<[^>]+>/,'') # take out tags and links
str.... | true |
298e1984217f7b644bb0ca6bb9b9c3f2429932fc | Ruby | Dale-R-Harrison/RB101 | /lesson_six/twenty_one.rb | UTF-8 | 6,613 | 3.875 | 4 | [] | no_license |
FACES = { 2 => 'Two',
3 => 'Three',
4 => 'Four',
5 => 'Five',
6 => 'Six',
7 => 'Seven',
8 => 'Eight',
9 => 'Nine',
10 => 'Ten',
'J' => 'Jack',
'Q' => 'Queen',
'K' => 'King',
'A' => 'Ace' }
ROUND_LIM... | true |
f25c25c5a8e2abc19f1436f972177244395b5918 | Ruby | Fukayanegi/CodeIQ | /question_of_this_week/integral_multiple_votes.rb | UTF-8 | 639 | 3.078125 | 3 | [
"MIT"
] | permissive | m, n = STDIN.gets.chomp.split(" ").map{|v| v.to_i}
min_votes_limit = n / m
def patterns sum, num, min
return 1 if sum >= min && num == 1
return 0 if sum < min
limit = sum / num
answer = 0
(min..limit).each do |votes|
tmp = patterns sum - votes, num - 1, votes
answer += tmp
end
answer
end
answer... | true |
125ad734dd00c678456b2cc892c5cc7144fc3f5d | Ruby | LetsUnlockiPhone/conduit-sprint | /lib/conduit/sprint/decorators/base.rb | UTF-8 | 1,231 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'conduit/sprint/meid_type_detector'
require 'street_address'
require 'delegate'
require 'forwardable'
module Conduit::Sprint::Decorators
class Base < SimpleDelegator
extend Forwardable
def street_direction
parsed_address1.prefix if !parsed_address1.blank?
end
def street_number
p... | true |
f13a02e0186d71d3605ee2cccf87bb9a29aa0d30 | Ruby | ludwiggj/ruby-pickaxe | /ch04-containers-blocks-iterators/misc/blocks_procs_and_lambdas.rb | UTF-8 | 8,479 | 4.4375 | 4 | [] | no_license | # http://www.eriktrautman.com/posts/ruby-explained-blocks-procs-and-lambdas-aka-closures
# Ruby Explained: Blocks, Procs, and Lambdas, aka "Closures"
# This post will explain blocks and Procs, with which you're probably at least somewhat
# familiar, but also some lesser known Ruby closures like Lambdas and Methods
#... | true |
219e6d50aa142dd9d0f421d7dc15954724e10244 | Ruby | sjhedges/ruby-Magic-Number | /MagicNumber.rb | UTF-8 | 502 | 3.953125 | 4 | [] | no_license | require 'numbers_in_words'
require 'numbers_in_words/duck_punch'
def start
puts "Input any positive number"
number_input = gets.to_i
if number_input > -1
main(number_input)
else
puts "That is invalid. Please type a positive number."
end
end
def main(number_input)
string_number = number_input.in_wo... | true |
ba540db04b8ce75eb9c68b3c9562069e6fe5e50b | Ruby | tiagobabo/advent-of-code-2018 | /lib/9/part_1.rb | UTF-8 | 632 | 2.953125 | 3 | [] | no_license | n_players, max_score = File.read('input.txt').scan(/(\d+)\D+(\d+)/).flatten.map(&:to_i)
players_score = Hash.new(0)
played_marbles = [0]
current_position = 0
next_marble = 1
(1..n_players).cycle do |player|
if next_marble % 23 == 0
current_position = (current_position - 7) % played_marbles.size
players_scor... | true |
cbaac40c39cdf28b883ff571452e1d2d839cd859 | Ruby | SpartaSixZero/store-calc | /county.rb | UTF-8 | 211 | 3.25 | 3 | [] | no_license | class County
attr_reader :id, :taxrate, :name
def initialize(id, name, taxrate)
@id = id
@name = name
@taxrate = taxrate
end
def tax_collected(base_price)
base_price * taxrate
end
end | true |
2658121df7dbf1ffb9d6544e052fb7376aac2e2d | Ruby | cesareferrari/intro-to-programming | /the_basics/ex4.rb | UTF-8 | 101 | 3.078125 | 3 | [] | no_license | a = [ 1975, 2004, 2013, 2001 ]
puts a[0]
puts a[1]
puts a[2]
puts a[3]
# this does the same
puts a
| true |
17ea80bb82654bb4f126ce0b0e331db0925c295f | Ruby | marisadanae/silicon-valley-code-challenge-seattle-web-071519 | /tools/console.rb | UTF-8 | 1,556 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
#the paramete... | true |
ef7916dab9069ae46f1798b2dcb025ee44f9919c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/3748.rb | UTF-8 | 154 | 3.328125 | 3 | [] | no_license | def compute(seq1, seq2)
distance = 0
seq1.chars.zip(seq2.chars) do |a, b|
distance += 1 unless a == b
end
distance
end | true |
2f03ca9253ba5b55fc379db41f1013f198e7e87c | Ruby | aerickson/implicitcad_watcher | /lib/openscad_watcher.rb | UTF-8 | 2,124 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "listen"
class OpenscadWatcher
DEBUG_MODE = true
# TODO: refactor names of these vars
# work on .scad and .escad
ESCAD_FILE_GLOB = [("*.scad"),
"*.escad"].freeze
ESCAD_REGEX = /\.[e]*scad$/
# TODO: allow cnofiguration or better detection for non OS X
IMPL... | true |
c914610afd960b0cfab2bd365ca15c0778c76a73 | Ruby | meryldakin/tweet-shortener-web-031317 | /tweet_shortener.rb | UTF-8 | 991 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def dictionary
dictionary = {
hello: "hi",
to: "2",
two: "2",
too: "2",
for: "4",
four: "4",
be: "b",
you: "u",
at: "@",
and: "&",
a: "a"
}
end
def word_substituter(tweet)
tweet_arr = tweet.split(" ")
original_words_arr = dictionary.keys.to_s
shortened_tweet ... | true |
a69bc616ffd759947ed956e427d1db7da809c5b0 | Ruby | psparrow/attr-gather | /lib/attr/gather/workflow/task_execution_result.rb | UTF-8 | 1,604 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Attr
module Gather
module Workflow
# A wrapper containing information and results of a task execution
#
# @!attribute [r] started_at
# @return [Time] time which the execution occured
#
# @!attribute [r] task
# @return [Attr::Gathe... | true |
d2b86aebea1c968be69487e7f4ff3f3637dc9542 | Ruby | kengonakajima/snippets | /ruby/rubyinclude/aho.rb | UTF-8 | 194 | 3.453125 | 3 | [] | no_license |
module Fuck1
def fuck
print "1\n"
end
end
module Fuck2
def fuck
print "2\n"
end
end
class Aho
include Fuck2
include Fuck1
def initialize( a )
fuck
end
end
a = Aho.new(2)
| true |
9aa6334c242c23af5cc7e9b52e7aabc2e58fe3ea | Ruby | SinkLineP/RubyOnRails-18.08.2021 | /Ruby on rails/coalla-cosmetology-ddcbe64f3200/app/models/concerns/group_places_extensions.rb | UTF-8 | 552 | 2.53125 | 3 | [] | no_license | module GroupPlacesExtensions
extend ActiveSupport::Concern
included do
%i(academics distances).each do |name|
define_method("#{name}_free_place") do
[send("#{name}_place") - send("#{name}_count"), 0].max
end
end
def free_places_for(education_form)
return unless education_form... | true |
ea208080330486669ce2c42e6e2c2339055e85ec | Ruby | catcstevens/javascript-intro | /simon_says.rb | UTF-8 | 1,082 | 3.765625 | 4 | [] | no_license | ##Only perform commands if it starts with "Simon says"
# if add +
# if subtract -
# if multiply *
# if no Simon says return 0
def simon_says(arr)
sum = 0
arr.each do |str|
if str.start_with?("Simon says")
n = str.split(' ')[-1].to_i
sum += n if str.include?("add")
sum -= n if st... | true |
5c5b04ac22cebee68c4f9744a64eab7d936ba937 | Ruby | TylerRick/tyler-git | /lib/handle_backup_and_add_for_user_manually_resolving_conflict.rb | UTF-8 | 1,455 | 2.6875 | 3 | [] | no_license | require 'colored'
# also handles checking for conflict markers
def handle_backup_and_add_for_user_manually_resolving_conflict(path, backup_path)
begin
path.cp backup_path
yield
add_file = true
system "git-file-has-no-conflict-markers #{path}"
if add_file && !$?.success?
STDERR.puts "Warn... | true |
3d4fad0c9a29b3e2eccd20747c5ffe8841ef8886 | Ruby | leedu708/cooking-project | /db/seeds.rb | UTF-8 | 2,129 | 2.84375 | 3 | [] | no_license | User.delete_all
Recipe.delete_all
Item.delete_all
Image.delete_all
Ingredient.delete_all
MULTIPLIER = 5
puts 'Old records destroyed'
User.create(:email => "admin@test.com",
:username => "adminTester",
:first_name => "John",
:last_name ... | true |
a78bd743d8f90069d35b86acf671d7ded8b3af65 | Ruby | kate102/oo_relationships_1 | /lib/expect.rb | UTF-8 | 746 | 3.765625 | 4 | [] | no_license | class Expect
def initialize(value)
@value = value
end
def to(comparison)
if comparison.compare(@value)
puts "Test passed"
else
puts "Test failed"
end
end
end
class Equal
def initialize(value)
@value = value
end
def compare(other)
other == @value
end
end
class Incl... | true |
fac3b5ea93775df8a4a81235c033521d93c3ea4d | Ruby | nav2cool/Project-Euler | /problem5/main.rb | UTF-8 | 105 | 3.015625 | 3 | [] | no_license |
a = (2..20).to_a.inject(1) { |a, i| a.lcm(i) }
puts a
puts ("\n")
b = (1..20).to_a.inject(:lcm)
puts b | true |
a1f609384213d04f50c7894248a3d69b9991ffcf | Ruby | kudohamu/slatan | /lib/slatan/mouth/mpim.rb | UTF-8 | 994 | 2.671875 | 3 | [
"MIT"
] | permissive | module Slatan
module Mouth
module Mpim
@category = 'mpim'
class << self
## @see https://api.slack.com/methods/mpim.close
def close(channel, options={})
send('close', {
channel: channel
}.merge(options))
end
## @see https://api.slack.com... | true |
7cc18d66e22a981bb4bc31460d7525bd276f54cb | Ruby | pdg137/speedily-dictionary | /lib/dictionary_reader.rb | UTF-8 | 177 | 3.03125 | 3 | [] | no_license | class DictionaryReader
attr_reader :words
def initialize(filename)
@words = {}
File.open(filename).each do |word|
@words[word.strip] = true
end
end
end
| true |
ba6bf319280b7c4e686de4bf8d05fc6ebb3f1d3b | Ruby | Erick-EEV/ruby-enumerables-hash-practice-emoticon-translator-lab-wdc01-seng-ft-100520 | /lib/translator.rb | UTF-8 | 762 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require "yaml"
require 'pry'
def load_library(file_path)
new_library = {}
library = YAML.load_file(file_path).each do |emoji_name, emoji|
new_library[emoji_name] = {}
new_library[emoji_name][:english] = emoji[0]
new_library[emoji_name][:japanese] = emoji[1]
end
new_library
en... | true |
3b843f51c13e87fc1c8156bf4a977f358c604410 | Ruby | kremso/metall | /app/models/corpus_extractors/wikipedia/extractor_en.rb | UTF-8 | 2,305 | 2.546875 | 3 | [] | no_license | DUMP_PATH = 'dumps/enwiki-20121201-pages-articles-multistream.xml'
LANG = 'en'
MAX_WORD_LENGTH = 30
module CorpusExtractors
module Wikipedia
class ExtractorEn
def self.clean_word(word)
word = word.downcase.gsub(/\A[\d_\W]+|[\d_\W]+\Z/, '').gsub(/\A&[a-z0-9]+;|&[a-z0-9]+\Z/, '').gsub(/\A[\d_\W]+|[\d... | true |
f60599c61bf8848371e115650a798b31fca7250a | Ruby | danlucraft/jruby-prof | /test/basic_test.rb | UTF-8 | 7,593 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'test/unit'
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'jruby-prof'
class C1
def C1.hello
sleep(0.1)
end
def hello
sleep(0.2)
end
end
module M1
def hello
sleep(0.3)
end
end
class C2
include M1
extend M1
end
class C3
def hello
sleep(0.4)
end
end... | true |
51a626aa5869c9aca140d4a8fb07f097e1163b0f | Ruby | nachoal/task-manager-622 | /task.rb | UTF-8 | 272 | 2.703125 | 3 | [] | no_license | # MODEL
class Task
attr_reader :name
def initialize(name, completed = false, description)
@name = name
@completed = completed
@description = description
end
def completed?
@completed
end
def complete!
@completed = true
end
end | true |
949098e48cacce430f2ca2d5675e64d8b2732128 | Ruby | sam-david/algorithms | /challenges/project-euler/special_pythagorean_triplet.rb | UTF-8 | 488 | 3.421875 | 3 | [] | no_license | # https://projecteuler.net/problem=9
# Solved
(0..500).each do |a_value|
(a_value + 1..1000).each do |b_value|
c_value = Math.sqrt((a_value ** 2 + b_value ** 2))
triplet_total_sum = a_value + b_value + c_value
# c_value even int and is it bigger than b, then pytha triplet
if c_value % 1 == 0 && c_val... | true |
f08801defb912c9a10f868e382c6e0035a061699 | Ruby | urbanvas/square_array-cb-000 | /square_array.rb | UTF-8 | 96 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
# your code here
sq = []
array.each{|num| sq << num*num}
sq
end
| true |
5ec84fb4393f02ff7253c121fd7596891ab2e3ad | Ruby | MikhailSorokin/CMSC417-Project-3 | /public_tests/part3/node.rb | UTF-8 | 5,219 | 2.734375 | 3 | [] | no_license | require_relative 'node_helpers'
$port = nil
$hostname = nil
$server = nil
# --------------------- Table Classes ------------ #
class RoutingInfo
attr_accessor :src, :dst, :nextHop, :distance
def initialize(src, dst, nextHop, distance)
@src = src
@dst = dst
@nextHop = nextHop
@distance = distance
end
def ... | true |
0bbb8e2cc0c71d410ccc8a5e3c30152b0a6553e9 | Ruby | jamievullo/Tag-Sale | /app/controllers/categories_controller.rb | UTF-8 | 870 | 2.734375 | 3 | [
"MIT"
] | permissive | class CategoriesController < ApplicationController
helper_method :sort_column, :sort_direction
def index
@categories = Category.order(sort_column + " " + sort_direction)
end
def new
end
def create
@category = Category.create(category_params)
end
def show
... | true |
2dda6272392626752c3b1bd836941fc73b940677 | Ruby | jay2452/FMS | /app/models/student_subject.rb | UTF-8 | 1,180 | 2.71875 | 3 | [] | no_license | class StudentSubject < ApplicationRecord
belongs_to :subject
belongs_to :user
belongs_to :semester
belongs_to :section
def self.import(file)
spreadsheet = open_spreadsheet(file) # => defined in ApplicationRecord.rb file
header = spreadsheet.row 1
(2..spreadsheet.last_row).each do |i|
row ... | true |
17a9e9b0f323e802e3c66947af125eac372ffe94 | Ruby | stamaniorec/place-finder | /scrapers/tripadvisor_scraper.rb | UTF-8 | 2,126 | 2.765625 | 3 | [] | no_license | require 'mechanize'
require 'sanitize'
require_relative 'base_scraper'
class TripAdvisorScraping < BaseScraper
def endpoint
'http://www.tripadvisor.com/'
end
def get_search_url(place_name)
"#{endpoint}Search?q=#{place_name}"
end
def navigate_from_suggestions_page_to_hotel_page(suggestions_page, qu... | true |
0d0a25ee8ff7c1ea5accc0487c17134fffefef5f | Ruby | segunadeleye/ruby_track | /Ex23/lib/employee.rb | UTF-8 | 950 | 3.21875 | 3 | [] | no_license | require "csv"
class Employee
def read_csv_data(file)
CSV.read(file, headers: true)
end
def extract_details(data)
body = data.to_a[1..-1]
end
def sort_details(body)
body.sort_by! { |row| row[2] }
end
def group_details(body)
grouped_details = body.group_by { |row| row[2] }
grouped... | true |
09555030a42d64efd9d8f521b3b3d7a798e938ce | Ruby | roseulldemolins/understanding_programming | /hashes.rb | UTF-8 | 687 | 3.203125 | 3 | [] | no_license | # # meals = {
# # "breakfast" => "cereal",
# # "lunch" => "roll",
# # "dinner" => "pizza"
# # }
# # meals["supper"] = "marmite"
# # puts meals["supper"]
#
# name = {
# "Abby" => "£10",
# "Ben" => "£5",
# "Carl" => "£7"
# }
# puts name ["Ben"]
# countries = {
# uk: {
# capital: "London",
# populat... | true |
5b851d7dbfe37f46570476b3358a75a4c553894c | Ruby | teliosdev/settingable | /lib/settingable/deep_merge.rb | UTF-8 | 2,050 | 3.265625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Settingable
# A module to handle the merging of a hash.
module DeepMerge
module_function
# Merges the source into the destination. This is non-destructive
# to the destination. If a block is given, it's called if both
# the source and destination have a non-mergable valu... | true |
fe3a7aba8c3688aab25e168eae4c35be9519e3bf | Ruby | rmatambo8/Ruby-Small-Problems | /medium_2/longest_sentence.rb | UTF-8 | 1,961 | 4.375 | 4 | [] | no_license | =begin
prompt - Write a program that reads the content of a text file
and then prints the longest sentence in the file based on number of words.
Sentences may end with periods (.), exclamation points (!), or question marks (?).
Any sequence of characters that are not spaces or sentence-ending characters
should be tre... | true |
5014b72f6a94eaeec5d49a4ec0293993c2d488de | Ruby | AntonBarkan/tgt | /lib/StepsHolder/steps_holder.rb | UTF-8 | 1,233 | 3.0625 | 3 | [] | no_license | require 'StepsHolder/step_holder'
class StepsHolder
attr_accessor :steps
def initialize (cucumber_output)
lines = cucumber_output.split("\n")
@steps = Array.new
firstIndex = 0
lastIndex = -1
lines.each_with_index do |line, index|
if line == 'You can implement step definitions for undefin... | true |
7114ba97d9d74ba1b0c54d6b550558d8bbc7f99a | Ruby | 1lyan/bakery | /lib/bakery/order_processor.rb | UTF-8 | 2,763 | 3.21875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Bakery
class OrderProcessor
class InvalidOrder < StandardError; end
class InvalidProduct < StandardError; end
attr_accessor :products
attr_reader :order
def initialize(products: [], order:)
check_order!(order)
raise InvalidProduct unless product... | true |
37efaf7f6f7acb6a1448df3123524f32be9ebb46 | Ruby | sandonovsuse/sct | /modules/SCTCrowbar.rb | UTF-8 | 10,258 | 2.5625 | 3 | [] | no_license | # encoding: utf-8
# ------------------------------------------------------------------------------
# Copyright (c) 2006 Novell, Inc. All Rights Reserved.
#
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 2 of the GNU General Public License as published by the
# ... | true |
cb2115cd6412bd282b30dfcdde355c4a3504bb4a | Ruby | rentalname/AOJ | /ITP1/ITP1_3_C.rb | UTF-8 | 187 | 2.796875 | 3 | [] | no_license | require 'stringio'
$stdin = StringIO.new(<<-RRR)
3 2
2 2
5 3
0 0
RRR
ARGF.each_line do |line|
arr = line.split.map(&:to_i).sort
break if arr.all?(&:zero?)
puts arr.join("\s")
end
| true |
f9345b6c33d40a61bb2ebc82d50e3da7ee571d0a | Ruby | VincenzoAltieri/LS_101 | /lesson_4/exercises_methods/ex4.rb | UTF-8 | 379 | 3.453125 | 3 | [] | no_license | # ex4.rb
['ant', 'bear', 'cat'].each_with_object({}) do |value, hash|
hash[value[0]] = value
end
# In this example we are passing a collection argument which is a hash.
# once it's done iterating each_with_object will return the collection object
# with the block code executed. In this case after the modication it ... | true |
89760f12787dab2ee6026e2e37fd31c1b74c740e | Ruby | benjaminkent/number-guesser | /guesser.rb | UTF-8 | 629 | 4.28125 | 4 | [] | no_license | min = 0
max = 1000
tries = 0
guess = 501
puts "Think of a number between 1 and 1000. I will be able to guess in 10 tries of less."
puts "Is your number 501? (y)es, (h)igher, or (l)ower."
while true
answer = gets.chomp
if answer == "h"
min = guess + 1
guess = ((max - min) / 2) + min
puts "Is your numb... | true |
99af813bac21a8ba158bbd9a04c49d1ab19af058 | Ruby | alinadin09/phase-0-tracks | /ruby/problem_solving_methods.rb | UTF-8 | 1,247 | 4.34375 | 4 | [] | no_license | # Release 0
def search_array(array, x)
placeholder = 0
while placeholder < array.length
if array[placeholder] != x
placeholder += 1
elsif array[placeholder] == x
return array[placeholder]
else
return nil
end
end
end
trial = [1, 2, 3, 4,... | true |
981769cdd9563146328078390774260fb659bb57 | Ruby | joan2kus/ChartDirector | /railsdemo/app/controllers/icondonut_controller.rb | UTF-8 | 2,424 | 2.53125 | 3 | [
"IJG"
] | permissive | require("chartdirector")
class IcondonutController < ApplicationController
def index()
@title = "Icon Donut Chart"
@ctrl_file = File.expand_path(__FILE__)
@noOfCharts = 1
render :template => "templates/chartview"
end
#
# Render and deliver the chart
#
def getch... | true |
889d6b3572b7bba0bb8d9fee41afcb0c1fdd5d56 | Ruby | kittysquee/oystercard | /lib/journey.rb | UTF-8 | 868 | 3.375 | 3 | [] | no_license | class Journey
#responsible for calculating the fare based on journey
attr_reader :entry_station, :exit_station, :fare
PENALTY_CHARGE = 6
MINIMUM_CHARGE = 1
def initialize(entry_station = nil)
@entry_station = entry_station
@exit_station = nil
end
def start(station)
self.entry_station = sta... | true |
209a8065bc572abb2df75ab1afda1bf02467753f | Ruby | ch2isk4kos/operators-dumbo-web-career-010719 | /lib/operations.rb | UTF-8 | 348 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def unsafe?(speed)
if speed > 60
return true
elsif speed < 40
return true
end
# return true if speed is less than 40
# and greater than 60; false if it's not
speed < 40 && speed > 60 ? true : false
end
def not_safe?(speed)
if speed > 60
return true
elsif speed < 40
return true
end
speed < 40 && sp... | true |
16fac32ba0e0c1f289320fac5451a7f77eb68615 | Ruby | dianacamacho/weekend_work | /weekend_4/oop/calc_3.rb | UTF-8 | 4,052 | 4.5 | 4 | [] | no_license | # In this example, we have THREE calculators, the two included in the previous
# exercises as well as Whiz Bang Calculator that can even calculate the hypotenuse
# of a triangle if given the length of the other two sides. Figure out how to
# DRY up all the code below - there shouldn't be a single method duplicated bet... | true |
7cf8606a2dec204eae4423e4ef3989e5cf46fc95 | Ruby | willfowls/prepcourse | /ruby_books/intro_to_ruby/2nd_attempt_at_exercises/93.rb | UTF-8 | 688 | 4.25 | 4 | [] | no_license | # in 92.rb, you wrote code asking if they want code to print something. this code excepted any input as valid.
# if you answered anything but y, it treated it as an n response and quit without printing anything
# modify so it prints an error message for any inputs that aren't y or n, and asks to try again.
# keep askin... | true |
56015a59fa319721e51f1a18d87f59c9cbec70d4 | Ruby | wenbo/rubyg | /sample/CHAPTER03/025/ivar.rb | EUC-JP | 828 | 3.875 | 4 | [] | no_license | self # => main
@main = "main" # ȥåץ٥ʤɤǤɤ߽Ǥ롣main°Ƥ롣
class Hoge
@class_ivar = "instance variable of Hoge" # 饹Υѿ
def self.cmeth # 饹åɤʤΤ@class_ivarϸ롣
@class_ivar # => "instance variable of Hoge"
end
# 饹ʸ̮ʤΤ@class_ivarϸ롣
@class_ivar # => "instance variable of Hoge"
def initializ... | true |
a7d29958cf4872a981fde6d5af3e4cf482837f0d | Ruby | 47colborne/dojo | /ruby/observable_20171027/lib/observable_from_array.rb | UTF-8 | 237 | 2.953125 | 3 | [] | no_license | require_relative 'observable'
class ObservableFromArray < Observable
def initialize(items)
@items = items
end
def subscribe(observer)
@items.each { |item| observer.do_on_next(item) }
observer.do_on_complete
end
end
| true |
ab79ae6c0eb20ae23b3ee18d1c19b15eaf79679c | Ruby | PeterCamilleri/mini_term | /test/mini_term_test.rb | UTF-8 | 3,194 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative '../lib/mini_term'
gem 'minitest'
require 'minitest/autorun'
class MiniTermTest < Minitest::Test
MiniTerm.open(quiet: true, strict: true) unless MiniTerm.term_open?
def test_that_it_has_a_version_number
refute_nil ::MiniTerm::VERSION
assert(::MiniTerm::VERSION.froze... | true |
6080df276087a974680d9732c6bf1b8115abd946 | Ruby | bentrevor/football-pool | /app/models/pick.rb | UTF-8 | 1,238 | 3.09375 | 3 | [] | no_license | class Pick < ActiveRecord::Base
belongs_to :game
belongs_to :user
def team
if is_home_team
home_team
else
away_team
end
end
def other_team
if is_home_team
away_team
else
home_team
end
end
def to_s
"#{user.name} picks #{team.name} over #{other_team.nam... | true |
1dfa0a4d711c51d812b5edfae302a13cde22827f | Ruby | BerilBBJ/scraperwiki-scraper-vault | /Users/P/pezholio/crawley_planning_applications.rb | UTF-8 | 9,670 | 2.671875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'date'
#ScraperWiki.sqliteexecute('CREATE TABLE `swdata` (`url` text, `uid` text, `address` text, `postcode` text, `applicant` text, `agent_name` text, `application_type` text, `description` text, `agent_address` text, `case_officer` text, `comment_url` ... | true |
45d39608eb26bb35f78c441376ecb9e3888352e4 | Ruby | ryuichi7/sinatra-nested-forms-v-000 | /models/pirate.rb | UTF-8 | 211 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pirate
attr_accessor :name, :weight, :height, :ships
PIRATES = []
def initialize(params)
params.each do |k,v|
self.send("#{k}=",v)
end
PIRATES << self
end
def self.all
PIRATES
end
end | true |
5eb2d92b130c7228a95f3276e988166c99bf730b | Ruby | janessatran/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 465 | 3.6875 | 4 | [] | no_license | #write your code here
def add(a, b)
return a.to_f + b.to_f
end
def subtract(a, b)
return a.to_f - b.to_f
end
def sum(numArray)
sum = 0
numArray.each do |num|
sum += num.to_f
end
return sum
end
def multiply(a, b)
return a.to_f * b.to_f
end
def power(a, b)
return a.to_f**b.to... | true |
167f33311d93fa10b65cf6bc755f3f4f9a1c77d8 | Ruby | tiemiarashiro/friendcup | /app/models/ranking.rb | UTF-8 | 539 | 2.53125 | 3 | [] | no_license | class Ranking < ApplicationRecord
belongs_to :user
def update_by_match(match)
self.played_games +=1
if(match.player1.user.id == self.user.id)
my_score = match.score_player1
other_score = match.score_player2
else
my_score = match.score_player2
other_score = match.score_player1... | true |
f13e27f1b8f29937d7b602bca550b25491c537a9 | Ruby | richwynmorris/ruby_small_problems | /challenges/max_subarray_sum.rb | UTF-8 | 1,991 | 4.46875 | 4 | [] | no_license | # Problem
# The maximum sum subarray problem consists in finding the maximum sum of a contiguous subsequence in an array or list of integers:
# maxSequence [-2, 1, -3, 4, -1, 2, 1, -5, 4] -- should be 6: [4, -1, 2, 1]
# Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of ... | true |
fd79535ae1036d66557c64bb8e94534b0b34f9fe | Ruby | caelum/restful-explorer | /vendor/gems/restfulie-0.7.2/lib/restfulie/client/http/link.rb | UTF-8 | 1,068 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | module Restfulie::Client
# Offer easy access to link relationships, such as <tt>post.next</tt> for
# <tt><link rel="next" href="http://resource.entrypoint.com/post/12" type="application/atom+xml" /></tt> relationships.
module LinkShortcut
def method_missing(method_sym,*args)#:nodoc:
selected_lin... | true |
2a57f0ef550f8676edb836d01775534bdc14a47e | Ruby | phillbaker/rubystats | /lib/rubystats/binomial_distribution.rb | UTF-8 | 2,829 | 3.265625 | 3 | [
"MIT"
] | permissive | require 'rubystats/probability_distribution'
# This class provides an object for encapsulating binomial distributions
# Ported to Ruby from PHPMath class by Bryan Donovan
# Author:: Mark Hale
# Author:: Paul Meagher
# Author:: Bryan Donovan (http://www.bryandonovan.com)
module Rubystats
class BinomialDistribution < R... | true |
c29bd67b53772150384cc9ca31afc52f0eded250 | Ruby | mttwright/ruby-music-library-cli-online-web-pt-090919 | /lib/artist.rb | UTF-8 | 752 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../lib/concerns/findable.rb"
class Artist
extend Concerns::Findable
@@all = []
attr_accessor :name
def initialize(name)
@name = name
@songs = []
self.save
end
def songs
@songs
end
def self.all
@@all
end
def self.destroy_all
@@all = []
end... | true |
a638abafc7d48bc586f15b67203b5a879ff84ce4 | Ruby | jessmitch42/ruby-objects-has-many-through-lab-v-000 | /lib/artist.rb | UTF-8 | 756 | 4.0625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
# An artist is initialized with a name and an empty @songs array.
# The Artist class needs an instance method, #add_song, that takes in an argument of a song and adds that song to the artist's collection of songs. The #add_song method should also tell the song that it belongs to that artist.
# The Ar... | true |
7d967f59021204750d74806f5c188115c6e96a16 | Ruby | LrdVnz/Chess | /lib/pieces/helpers/castling_helper.rb | UTF-8 | 2,290 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
# helper to store castling code
module CastlingHelper
def check_castling(piece, goal)
@piece = piece
@goal = goal
@rook = nil
return false unless @piece.instance_of?(King) && @piece.moves_made.zero?
castling_side
end
def castling_side
if @goal[1] == (@piece... | true |
a7b66964ff112428736c624f80bd533be18a3ade | Ruby | ChristopherDurand/Exercises | /ruby/small-problems/easy3/e01.rb | UTF-8 | 371 | 3.6875 | 4 | [
"MIT"
] | permissive | numbers = []
places = %w(1st 2nd 3rd 4th 5th)
(0..4).each do |n|
puts "Enter the #{places[n]} number:"
numbers[n] = gets.chomp.to_i
end
puts "Enter the last number:"
last_number = gets.chomp.to_i
if numbers.include?(last_number)
puts "The number #{last_number} appears in #{numbers}."
else
puts "The number ... | true |
37a3c253d04fbed0ef4eb3266be6049a91a38e2a | Ruby | cassidywalsh/kwk-l1-reading-arrays-lab-kwk-students-l1-min-072318 | /reading_arrays.rb | UTF-8 | 612 | 3.203125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | STUDENT_NAMES = [
"Adele",
"Beyoncé",
"Cardi B",
"Lady Gaga",
"Nicki Minaj",
"Rihanna"
]
def first_student_by_index
return STUDENT_NAMES[0]
end
first_student_by_index
def fourth_student_by_index
return STUDENT_NAMES[3]
end
fourth_student_by_index
def last_student_by_index
return STUDENT_NAMES[5]
... | true |
190daee580271acecb92190c8bb223743cdf97ed | Ruby | JohnForster/oystercard_JF | /spec/station_spec.rb | UTF-8 | 359 | 2.671875 | 3 | [] | no_license | require 'station'
describe Station do
let(:station) { Station.new('Aldgate East', 1) }
describe '#zone' do
it 'should return the zone that the station is in.' do
expect(station.zone).to eq 1
end
end
describe '#name' do
it 'should return the name of the station' do
expect(station.name).... | true |
1d7ec21fac972fbd001f8bf0f0f2caf7d5be64d8 | Ruby | Reprazent/rackit_scrobbler | /lib/rackit_scrobbler/last_fm/client.rb | UTF-8 | 1,126 | 2.5625 | 3 | [
"MIT"
] | permissive | require "lastfm"
module RackitScrobbler
module LastFm
class Client
attr_accessor :lastfm_instance
def initialize
@lastfm_instance = Lastfm.new(LastFm.config.api_key, LastFm.config.api_secret)
end
def authenticated?
lastfm_instance.session
end
def authentica... | true |
e443009cfad9f0dbaa8ed21e66c1a9174b169c93 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hexadecimal/77054b25aab0485b98c8f5d05141484e.rb | UTF-8 | 456 | 3.59375 | 4 | [] | no_license | class Hexadecimal
def initialize(hex)
@hex = hex
end
def to_decimal
digits = @hex.reverse.chars.map { |c| from_digit(c) || from_letter(c) }
return 0 if digits.any? { |d| d.nil? }
digits.each_with_index.reduce(0) do |sum, (digit, index)|
sum + digit.to_i * 16 ** index
end
end
private
... | true |
6966d7f63054956dc62d7dcaad67c5db10ff0a2d | Ruby | jpmckinney/tf-idf-similarity | /lib/tf-idf-similarity/tokenizer.rb | UTF-8 | 449 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'unicode_utils/each_word'
require 'tf-idf-similarity/token'
# A tokenizer using UnicodeUtils to tokenize a text.
#
# @see https://github.com/lang/unicode_utils
module TfIdfSimilarity
class Tokenizer
# Tokenizes a text.
#
# @param [String] text
# @return [Enumerator] an enumerator of Token obj... | true |
30d9d184c09b1ab9890b7643b152ce1c1e79c19d | Ruby | gitalek/rubythink | /module_03/alphabet.rb | UTF-8 | 191 | 3.25 | 3 | [] | no_license | vowels = %w[a e i o u y]
alphabet = ('a'..'z').to_a
result = {}
alphabet.each_with_index do |letter, index|
result[letter] = index + 1 if vowels.include?(letter)
end
puts result.inspect
| true |
5df6ba251ebd5f97cf979333fcac6172b0ac8670 | Ruby | arirusso/spall | /lib/spall/thread.rb | UTF-8 | 545 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | module Spall
module Thread
extend self
def new(options = {}, &block)
thread = ::Thread.new do
begin
if options[:timeout] === false
yield
else
duration = options[:timeout] || 1
Timeout::timeout(duration) { yield }
end
re... | true |
560012b6a358fecd64cffe839720bdd7a6d8fe66 | Ruby | chris-skud/api-tequila | /lib/tasks/nom.rake | UTF-8 | 466 | 2.640625 | 3 | [] | no_license | namespace :nom do
desc "import-convert-seed tequila nom data"
task :seed => :environment do
puts 'seeding nom'
binding.pry
puts 'fetching Nom file'
spreadsheet = NomFetch.new.xlsx_file
puts 'fetch complete'
puts 'transforming to array'
nom_2d_array = NomSpreadsheet.new(spreadsheet).to_... | true |
a6d08f634f4a0a9aa93f12083df5bbe57185d506 | Ruby | adicu/house | /dashboard/jobs/foursquare.rb | UTF-8 | 1,709 | 2.609375 | 3 | [] | no_license | require 'httparty'
require 'json'
herenow = 0
users = ''
total_users = 0
user_index = 0
checkins = 0
index = 0
VENUE_ID = '521ed95711d227dca81a6504'
BASE_URL = "https://api.foursquare.com/v2/venues/#{VENUE_ID}/"
cnf = YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), '../config.yml'))
CLIENT_ID = ... | true |
91459bfbed21192258e001a3de0070994945cc64 | Ruby | dan-marino/ruby-practice-problems | /ruby_challenges/easy2/scrabble_score.rb | UTF-8 | 548 | 3.40625 | 3 | [] | no_license | class Scrabble
SCORER = [[], ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'],
['D', 'G'], ['B', 'C', 'M,', 'P'],
['F', 'H', 'V', 'W', 'Y'], ['K'], [],[],['J', 'X'], [], ['Q', 'Z']]
attr_reader :str
def initialize(str)
str.nil? ? @str = '' : @str = str
end
def score
counte... | true |
ac994eedd9a899bea98292c491a1516234d4b50b | Ruby | carolinesoleelee/collections_practice_vol_2-dc-web-100818 | /collections_practice.rb | UTF-8 | 956 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def begins_with_r(array)
array.all? do |x|
x[0] == ("r")
end
end
def contain_a(array)
array.select do |x|
x.include?("a")
end
end
def first_wa(array)
array.find do |x|
x.to_s.start_with?("wa")
end
end
def remove_non_strings(array)
array.delete_if do |x|
x != x.to_s
end
end
def co... | true |
01201199c202958fcb195d12bd9b755f1127a084 | Ruby | haresh14/csv-utility | /csv_processor.rb | UTF-8 | 5,720 | 2.625 | 3 | [] | no_license | =begin
cat scoping.csv | ruby csv_processor.rb --row-template 'row-template.erb'
cat scoping.csv | ruby csv_processor.rb --row-template 'row-template.erb' --csv-header 'contact_id,opportunity_id,contact_created,opportunity_created,project_start,farming,first_name,last_name,company,opportunity,scope,project'
cat s... | true |
68fa16f53547f61a671c9b6610c54f9403f092a9 | Ruby | mbronek7/University | /SemestrVI/SI/P1/zad2/words.rb | UTF-8 | 1,665 | 3.15625 | 3 | [] | no_license | # frozen_string_literal: true
require 'set'
require 'pry'
require 'byebug'
MAX_LENGTH = 34
def max(a, b)
a > b ? a : b
end
def min(a, b)
a < b ? a : b
end
# bool, text[array], size
def find_words(text, dictionary)
return [true, [], 0] if text == ''
if text.size == 1
if dictionary.include?(text)
re... | true |
f7b5645cab1ea0ac7d7a4a809d69cb2bf28be80c | Ruby | jan-czekawski/introduction-to-programming-exercises | /more/book_of_ruby/20_dynamic_programming/4eval.rb | UTF-8 | 84 | 2.59375 | 3 | [] | no_license | input = ""
until input == "q"
input = gets.chomp
eval(input) if input != "q"
end | true |
92b3c8e0d500677a3fcf682663f41d8c7c48b1d8 | Ruby | dmzza/citibike-2 | /lib/citibike/client.rb | UTF-8 | 3,205 | 2.546875 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'citibike/api'
require 'citibike/response'
module Citibike
# Client for interacting with the Citibike NYC
# unofficial API
class Client
attr_reader :options, :connection, :altconnection
VALID_KEYS = [:unwrapped]
def initialize(opts = {})
@options = {}
# Pars... | true |
4bc3cce30fd5ad0d9142d7b7a6df2d5c21c21ac3 | Ruby | cice/wsdl-mapper | /lib/wsdl_mapper/dom_generation/schema_generator.rb | UTF-8 | 4,487 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'wsdl_mapper/naming/default_namer'
require 'wsdl_mapper/generation/result'
require 'wsdl_mapper/generation/default_formatter'
require 'wsdl_mapper/generation/default_module_generator'
require 'wsdl_mapper/dom_generation/default_class_generator'
require 'wsdl_mapper/dom_generation/null_ctr_generator'
require 'w... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.