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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e2a8a097619c6e0ea804eda4b8bc0f145ad07b04 | Ruby | Tracyaa/module-one-final-project-guidelines-dumbo-web-career-012819 | /app/interface.rb | UTF-8 | 1,177 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment'
def project_title
system "clear"
system "figlet -w 118 -c Find ArtWorks | lolcat -a -d 1"
end
def exit_programm
project_title
abort("Thanks for your visit, we'll see you soon! \n ")
end
def find_artworks
current_user = nil
project_title
prompt = TTY::Prompt.new
... | true |
5bd94918e1429719682c31bb8585312035377685 | Ruby | ellevargas/FarMar | /sharedmethods.rb | UTF-8 | 457 | 2.8125 | 3 | [] | no_license | # good place for wrapping a module around repeated methods between classes
# require_relative '../farmar'
# require 'csv'
module SharedMethods
# attr_reader :all_accounts
def self.all(file)
all_accounts = {}
CSV.open(file, 'r').each do |line|
id_key = line[0]
all_accounts[id_key] = line
... | true |
fe21ca740cc21220adad82bbb3a1990f15067082 | Ruby | hmorri32/black_thursday | /test/invoice_item_repository_test.rb | UTF-8 | 1,530 | 2.59375 | 3 | [] | no_license | require './test/test_helper'
require './lib/invoice_item_repository'
class InvoiceItemRepositoryTest < Minitest::Test
attr_reader :invoice_item_repository
def setup
@invoice_item_repository = InvoiceItemRepository.new("./data/invoice_items.csv")
end
def test_that_it_exists
assert_instance_of InvoiceI... | true |
96bc212d45ed609bb09f976c29b09bd9ee283c8d | Ruby | spaghetticode/mover | /spec/validator_spec.rb | UTF-8 | 759 | 2.640625 | 3 | [] | no_license | describe Validator do
let(:validator) { Validator.new(['D-01-A-1', 'D-01-A-8-11', 'D-01-A-8-15']) }
describe '#validate' do
it 'should return an array of invalid codes' do
validator.validate.should be_an(Array)
end
it 'should return expected invalid codes quantity' do
validator.validate.si... | true |
7c6696054277370397c302ab840129fe13b1d052 | Ruby | gerard76/arbitrage | /app/models/fxbtc.rb | UTF-8 | 329 | 2.71875 | 3 | [] | no_license | class Fxbtc < Exchange
API = "https://data.fxbtc.com/api?op=query_ticker&symbol=ltc_btc"
attr_accessor :buy, :sell
def initialize
result = JSON.parse(open(API).read)
# We request LTC_BTC but need BTC_LTC
self.sell = result["ticker"]["bid"].to_f
self.buy = result["ticker"]["ask"].to_f
... | true |
ce17f2761065be0f5d0bceff4e091d1a0354dc8b | Ruby | alexbraatz/launch_school_work | /lesson_4/additional_practice/pp8.rb | UTF-8 | 185 | 3.578125 | 4 | [] | no_license | # numbers = [1, 2, 3, 4]
# numbers.each do |number|
# p number
# numbers.shift
# end
numbers = [1, 2, 3, 4]
numbers.each do |number|
p number
numbers.pop(1)
end
| true |
ea9afe68d473956523dea16f7d2b042251e9ebb0 | Ruby | christiegoldstein/Ironhack_Bootcamp | /Week_2/Day_1/todo/spec/todolist_spec.rb | UTF-8 | 2,448 | 3.046875 | 3 | [] | no_license | require_relative("../lib/task.rb")
require_relative("../lib/todolist.rb")
require("yaml")
RSpec.describe TodoList do
before :each do @todo = TodoList.new("Jack") end
describe "#add_task" do
it "add task to list of tasks" do
task = @todo.add_task(Task.new("Walk the dog"))
task2 = @todo.add_task(Task.new("F... | true |
16c4209ec00027a073da725f7c6bef793e8940b5 | Ruby | ousiax/hangman | /Hangman/player.rb | UTF-8 | 3,390 | 3.203125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
# The MIT License (MIT)
#
# Copyright (c) 2016 Roy Xu
require_relative 'hangman'
require_relative 'letters_generator'
module Hangman
class Player
def initialize(player_id, request_url)
raise "'player_id' Required." unless player_id
raise "'request_url' Required." unless requ... | true |
a4b4913a07246138f977f7d9c051a708b3a5be91 | Ruby | kdingle88/enigma | /lib/crack.rb | UTF-8 | 338 | 2.890625 | 3 | [] | no_license | require './lib/enigma.rb'
enigma = Enigma.new
message_file = File.open(ARGV[0],"r")
encrypt_message = enigma.crack(message_file.read,ARGV[2])
crack_file = File.open(ARGV[1], "w")
crack_file.write(encrypt_message[:decryption])
puts "Created #{ARGV[1]} with the cracked key #{encrypt_message[:key]} and date #{encryp... | true |
48060399992fbc0802ad49a9e09253052ff52316 | Ruby | gnomus/aoc2020 | /7/puzzle2.rb | UTF-8 | 603 | 3.21875 | 3 | [] | no_license | INPUTS = File.readlines('input')
RULES = Hash.new
def gen_hash(variant, color)
"#{variant}_#{color}".to_sym
end
def count_contents(hash)
contents = RULES[hash].map do |c|
c[0] * count_contents(c[1])
end
contents.sum + 1
end
INPUTS.each do |rule|
parts = rule.split(' ', 5)
hash = gen_hash(parts[0], p... | true |
14fa2f07e58e82810ec06304214a8095478020aa | Ruby | isaac-20/array-methods-lab-onl01-seng-pt-030220 | /lib/array_methods.rb | UTF-8 | 347 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_include(array, element)
array.include?(element)
end
def using_sort(array)
a = array.sort
return a
end
def using_reverse(array)
a = array.reverse
return a
end
def using_first(array)
a = array.first
return a
end
def using_last(array)
a = array.last
return a
end
def using_size(array)
a =... | true |
7cf4787afa23a19719549c2b13152b7dc6ae99c4 | Ruby | eripheebs/airport_challenge | /lib/weather.rb | UTF-8 | 111 | 2.75 | 3 | [] | no_license | class Weather
def stormy?
random_number > 8
end
private
def random_number
rand(10)
end
end
| true |
9a9f2ae45b602ea21161a46ff6d4568c5eb5c295 | Ruby | TopSpectrum/rails_multisite | /lib/rails_multisite/specs_store/mixed.rb | UTF-8 | 974 | 2.515625 | 3 | [
"MIT"
] | permissive | module RailsMultisite
module SpecsStore
class Mixed < Base
def initialize ( strategies )
@strategies = strategies
end
def find_by_host ( host )
@strategies.each do | strategy |
spec = strategy.find_by_host host
return spec if spec
end
... | true |
fb561ff33aec21ebc1697436299a6b48e1c702bb | Ruby | arnaskro/tripbook-api | /spec/requests/v1/areas_spec.rb | UTF-8 | 3,060 | 2.625 | 3 | [] | no_license | require 'rails_helper'
describe "Areas Module" do
describe "> Autocomplete Funcionality" do
before(:each) do
create(:country, id: 59)
create(:city)
end
it 'successfully autocompletes a query for city' do
get "/v1/areas/Horsens"
expect(json.length > 0).to be true
end
it ... | true |
3dcb16b4d4fb4daa6267026cf96cd673efe0dca7 | Ruby | wesavetheworld/adwords-keyword-tool | /app/models/targeting_idea_service.rb | UTF-8 | 4,878 | 2.59375 | 3 | [] | no_license | class TargetingIdeaService
attr_accessor :limit
## Exception Handling
class NoCredentialsError < StandardError
end
def initialize(attributes = nil)
if attributes
attributes.each do |key,value|
send(key.to_s + '=', value)
end
end
@results_limit = limit
@client = Savon::Cl... | true |
bc2d0130b4edb61ed1dba9b0ca45c00a6ef10848 | Ruby | pocke/aoj_codes | /0018/729328AC.rb | UTF-8 | 78 | 3.078125 | 3 | [] | no_license | arr = gets.split.map {|x| x.to_i }
arr.sort! {|a,b| b<=>a }
puts arr.join ' '
| true |
44add3bebf5729f8e4593a8c6684590eb520058a | Ruby | LeDeep/go_fish | /lib/deck.rb | UTF-8 | 450 | 3.359375 | 3 | [] | no_license | class Deck
attr_reader :build, :cards
def initialize
@cards = []
@suits = %w{spades hearts diamonds clubs}
@values = %w{ ace two three four five six seven eight nine ten jack queen king }
end
def build
@cards = []
52.times do |i|
card = Card.new(@suits[i/13],@values[i%13])
@cards << card
end
... | true |
4e6da5ae99546ed91d8c96e5086cba894659ca0a | Ruby | dieulinh/Mortgage-Club | /app/services/completed_loan_services/tab_declarations.rb | UTF-8 | 1,049 | 2.75 | 3 | [] | no_license | module CompletedLoanServices
class TabDeclarations
attr_accessor :borrower, :secondary_borrower
def initialize(borrower, secondary_borrower)
@borrower = borrower
@secondary_borrower = secondary_borrower
end
def call
return false unless borrower
return declaration_completed?(b... | true |
5282693bfb3392f6d4e458dd54f58187e455238f | Ruby | tanyafn/flight_finder | /client/app/helpers/formatting_helper.rb | UTF-8 | 1,065 | 2.671875 | 3 | [] | no_license | module FormattingHelper
def timespan_in_words timespan
%w(day hour minute).inject("") do |str, interval|
num = timespan/1.send(interval)
timespan -= num.send(interval)
str += "#{num}#{interval[0]}" + " " if num > 0
str
end
end
def flight_caption from, to
(city_by_iata(from) + ... | true |
37cf3991988549bf88fed257f6f5272c514c337c | Ruby | elieteyssedou/interstar | /src/asteroid.rb | UTF-8 | 2,386 | 2.859375 | 3 | [
"MIT"
] | permissive | class Asteroid
attr_reader :x, :y, :force, :angle, :width, :height, :who
attr_accessor :life, :die
def initialize
@i = rand(1..4)
if @i == 1
@animation = Gosu::Image::load_tiles("media/images/rocks.png", 256, 256, :tileable => false)
else
@animation = Gosu::Image::load_tiles("media/images/asteroid.png",... | true |
867e7e7a9209c35a411b8afe1e849c84de325256 | Ruby | lennythomas-dev/launch_school_core | /lesson_4/practice_looping/print_until.rb | UTF-8 | 235 | 3.59375 | 4 | [] | no_license | # Courses > RB101 Programming Foundations > Lesson 4: Ruby Collections > Practice Looping > Ruby Basics > Loops 1 > Print Until
count = 0
numbers = [7, 9, 13, 25, 18]
until count == numbers.size
puts numbers[count]
count += 1
end
| true |
9e8a0deb6b73e964cca0a62d347c7ac1d51ca2f7 | Ruby | ethanrosenberg/signal-flux | /app/controllers/phone_controller.rb | UTF-8 | 830 | 2.671875 | 3 | [] | no_license | require 'json'
require 'open-uri'
require 'net/http'
require 'nokogiri'
require 'uri'
class PhoneController < ApplicationController
def search
results = [
{
provider: "whocalld",
:type=>"Land or VoIP",
:location=>"Pennsylvania US"
},
{
provider: "whit... | true |
41f715429a17c62a619a46d260b65849fe423738 | Ruby | jamesponeal/phase-0 | /week-8/ruby-review/pez/pez_spec.rb | UTF-8 | 894 | 2.78125 | 3 | [
"MIT"
] | permissive | require_relative "pez"
flavors = %w(cherry chocolate cola grape lemon orange peppermint raspberry strawberry).shuffle
describe "PezDispenser" do
it 'Expects a single argument for pez dispenser' do
expect(PezDispenser.instance_method(:initialize).arity).to eq 1
end
it 'returns true when pez count is 12 aft... | true |
d69f56b4100791cbcdc026affa82b050e888cd47 | Ruby | dsl-src/codebreaker | /lib/codebreaker/results.rb | UTF-8 | 835 | 3.109375 | 3 | [
"MIT"
] | permissive | module Codebreaker
class Results
FILE_RESULTS = 'file_results.txt'
class << self
def get_info player = {}
"Player: #{player[:name]} , attempts: #{player[:user_attempts]}, all_attempts: #{player[:all_attempts]}"
end
def load
data_file = String.new
File.readlines(FI... | true |
c73b442841634b7f2f73323902b5f17f9a412c11 | Ruby | Cartermatic/square_array-onl01-seng-ft-070620 | /square_array.rb | UTF-8 | 153 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
number_array = []
array.each do |number|
number_array << number**2
end
number_array
end
print square_array ([1,2,3]) | true |
315a09b538f7fa8be8ddcef89cf7fe38d4b02722 | Ruby | PopularDemand/assignment_rails_connect4 | /app/models/board.rb | UTF-8 | 3,117 | 3.40625 | 3 | [] | no_license | class Grid
attr_reader :column_count, :row_count
attr_reader :grid
def initialize(args = {})
@row_count = args[:rows]
@column_count = args[:columns]
@grid = args[:preset] || Array.new(row_count) { Array.new(column_count) }
end
def set_cell(row, col, value)
grid[row][col] = valu... | true |
19302fc1e2df296a5706614711266a9a4224a53c | Ruby | Warshavski/elplano-api | /app/services/tasks/update.rb | UTF-8 | 1,544 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
module Tasks
# Tasks::Update
#
# Used to perform task update
#
class Update
include Loggable
# @see #execute
def self.call(task, author, params)
new.execute(task, author, params)
end
# Perform task update
#
# @param task [Task]
# Updat... | true |
fd0db399cdf8e41f612262c20e6594c400b83a1c | Ruby | Jschloss309/Github_Portfolio2 | /showtime.rb | UTF-8 | 4,868 | 3.65625 | 4 | [] | no_license | Fighters = []
#Intro
puts "\nSubmit your ticket 🎫 to Enter into the Arena! 🕋"
print "\nPress Enter to Submit your 🎫"
enter = gets.chomp
system("clear")
puts "\n🗣 WELCOME TO THE FIRST OFFICIAL MMA vs BOXING MATCH IN HISTORY!!! 📚" #Title
puts "~" * 60
print "\n ***FLOYD 🇺🇸 MAYWEATHER*** \n ... | true |
7272ca1dcb8ca988070e93f8ba5211def6b39551 | Ruby | hacaravan/fizzbuzz | /spec/fizzbuzz_spec.rb | UTF-8 | 1,305 | 3.78125 | 4 | [] | no_license | require 'fizzbuzz'
describe 'fizzbuzz' do
it 'returns "fizz" when passed a multiple of 3 that isn\'t a multple of 5' do
# Generate a random multiple of 3
test_input_3 = (rand(6) + 1) * 3
# For this multiple of 3, run the test
while true do
break if test_input_3 % 15 != 0
test_input_3 = (r... | true |
7b6373f53e36d382ac60a574718157f85f4fd2ce | Ruby | moserrya/ShoutTrout | /app/jobs/daily_message_worker.rb | UTF-8 | 869 | 2.578125 | 3 | [] | no_license | class DailyMessageWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
# Plivo also has a User class; mixing it in here causes a namespace collision
recurrence {hourly}
def perform
PlivoClient.send_messages(hourly_users.pluck(:phone_number), message_body)
hourly_users.update_all(last_outbound... | true |
4c2a60d9d30f447f99b64f1e265a7152cc1c7d2a | Ruby | crishanks/practice-work | /bouncing-ball.rb | UTF-8 | 271 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def bouncing_ball(h, bounce, window)
if h <=0 || bounce <= 0 || bounce >=1 || window >= h
return -1
end
ball_seen = -1
while(h >= window)
ball_seen += 2
h = bounce * h
end
ball_seen
end
bouncing_ball(30, 0.66, 1.5) # 15 | true |
8c2f83240157ce1026d1a2e2422e65d4ecd8a314 | Ruby | rshiva/MyDocuments | /10-book-case/ruby1.9/samples/web_11.rb | UTF-8 | 773 | 2.765625 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
0ad55d07fc7245a3381e0a60cef0cf318256765c | Ruby | ferhatelmas/algo | /spoj/hangover.rb | UTF-8 | 123 | 3.109375 | 3 | [
"WTFPL"
] | permissive | while (k = gets.to_f) != 0
s, i = 0, 1
while s <= k
s += 1.0 / (i+1)
i += 1
end
puts("#{i-1} card(s)")
end
| true |
61bf9c66e6332c57aa5759c409a137dceee17380 | Ruby | George-Hudson/CloneWarz | /lib/clone_warz/carousels.rb | UTF-8 | 771 | 2.78125 | 3 | [
"MIT"
] | permissive | require './lib/clone_warz/carousel'
require './lib/db'
class Carousels < DB
def self.create
database.create_table(:carousels) do
primary_key :id
String :name
String :imgs
end unless database.table_exists?(:carousels)
end
def self.all
table.select.to_a.map do |data|
data[:img... | true |
42f94c6697a764deb2e40b213bea06371b0d286e | Ruby | sadrac131/sadrac131 | /task1.rb | UTF-8 | 185 | 2.765625 | 3 | [] | no_license |
h= ARGV[0]
l=h.to_s
m=h.encode(Encoding::UTF_8)
z1= m.gsub(/Р/, '')
z2=z1.gsub(/р/, '')
z3=z2.gsub(/К/, '')
z4=z3.gsub(/к/, '')
z5=z4.gsub(/Н/, '')
z6=z5.gsub(/н/, '')
puts z6 | true |
38c5b9d88c5c05e1c96a6b4d3ac8ee33d9874c05 | Ruby | deCadeh/wallarm-source-leak | /pkgs/api/common/export_spots_queue.rb | UTF-8 | 1,278 | 2.84375 | 3 | [] | no_license | require 'wallarm/common/processor'
class ExportSpotsQueue
attr_reader :last_processed_id
def initialize
@mutex = Mutex.new
@requests_queue = []
@requests_count = 0
@spots_queue = []
end
def set_range( firstid, lastid)
if firstid.nil? or lastid.nil?
@mutex.synchronize do
@req... | true |
4793136f983d0fad2bd312dd9dd298db57e51d6b | Ruby | gabichuelas/adopt_dont_shop_paired | /app/models/shelter.rb | UTF-8 | 656 | 2.8125 | 3 | [] | no_license | class Shelter < ApplicationRecord
validates_presence_of :name
validates_presence_of :address
validates_presence_of :city
validates_presence_of :state
validates_presence_of :zip
has_many :pets
has_many :reviews
def self.sort_alphabetically
all.sort_by { |shelter| shelter.name }
end
def self.so... | true |
1ff3c1533d725a24676e2cd8015f428a8e044ca3 | Ruby | richgeog/A_Well_Grounded_Rubyist | /Part_1_Examples/Chapter_3_Classes_organizing_classes/3.2/instance_variables.rb | UTF-8 | 1,173 | 4.3125 | 4 | [] | no_license | ############ INSTANCE VARIABLES ###############
# class Person
# def set_name(string)
# puts "Setting person's name...."
# @name = string
# end
# def get_name
# puts "Returning the person's name ...."
# @name
# end
# end
# joe = Person.new
# joe.set_name("Joe")
# puts joe.get_name
# #{multi... | true |
1e6e91c5e093f12232a977acd2d212fb7c0b7358 | Ruby | whoward/cadenza | /lib/cadenza/filesystem_loader.rb | UTF-8 | 1,848 | 3.09375 | 3 | [
"MIT"
] | permissive |
# frozen_string_literal: true
module Cadenza
# The {FilesystemLoader} is a very simple loader object which takes a given
# "root" directory and loads templates using the filesystem. Relative file
# paths from this directory should be used for template names.
#
# This implemenation makes no attempt to be se... | true |
893b22c338793bcaf2b5eb05ab2ce35148e58103 | Ruby | StoneFrog/exercism | /ruby/alphametics/alphametics.rb | UTF-8 | 2,076 | 3.5 | 4 | [] | no_license | class Alphametics
attr_reader :splitted_phrase, :original_phrase
def solve(phrase)
@original_phrase = phrase.gsub("^", "**")
@splitted_phrase = phrase.scan(/[a-zA-Z]+/).map(&:chars)
solve_with_brute_force
end
private
def solve_with_brute_force
unique_letters = splitted_phrase.flatten.uniq
... | true |
0aa7ddf3c4cafa0a068c891c3032f077d7b65251 | Ruby | cadetsnead/hangman | /hangman.rb | UTF-8 | 1,124 | 3.453125 | 3 | [] | no_license | class Hangman
attr_accessor :name,:guessed,:correct_blank,:counter
def initialize(password_name)
@name = password_name.upcase
@guessed = []
@correct_blank = blank()
@counter = 7
end
def correct_letter?(letter)
name.include?(letter)
end
def make_move(letter)
if correct_letter?(letter)
... | true |
1012df992d60ef276861e609a5c397a083946e95 | Ruby | fabriciosoares/Stricto_Ruby_on_Rails | /ufpe/lista_0/fabriciosoares_hw0_parte3.rb | UTF-8 | 720 | 3.625 | 4 | [] | no_license | # Author: Fabricio Soares da Silva
# email: fss7@cin.ufpe.br
# date: 04-jun-2015
class BookInStock
@isbn
@preco
# construtor
def initialize(isbn, preco)
@isbn = isbn
@preco = preco
raise ArgumentError, "ISBN vazio" unless @isbn != ""
raise ArgunentError, "Preço inválido" unless @preco > 0
end
# Get... | true |
a01266efeb5daaff25259d8ec1b4d8a8ff21e35d | Ruby | ab17ruby/ornekler | /adresdefteri/program | UTF-8 | 1,171 | 3.421875 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "kisi"
require_relative "adresdefteri"
print "Defter adınız ne olsun:"
defter_adi = gets.chomp
puts "Defter adı olarak #{defter_adi} seçildi"
defter = AdresDefteri.new(defter_adi)
loop do
puts "Ne yapmak istersiniz:"
puts "\t1) Listele"
puts "\t2) Ekle"
puts "\t3) Çıkış"... | true |
81770b881d69b1980e03a743e6f69bfd4918ba14 | Ruby | drodriguez92/W2D2 | /chess_game/pieces/null_piece.rb | UTF-8 | 198 | 2.765625 | 3 | [] | no_license | require 'singleton'
class NullPiece
attr_reader :name
include Singleton
def name
name = "n"
name
end
def color
return color
end
def symbol
return symbol
end
end
| true |
beb2122cc99b71f7a50af7d98a1d2a6125d3065a | Ruby | ironjan/klausurtool-ror | /spec/helpers/ausleihe_helper_spec.rb | UTF-8 | 1,484 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | require 'rails_helper'
describe AusleiheHelper do
describe "#color_class_for_lent_since" do
it "returns `` if the folder is lent for less than 2 days" do
old_lend_out = FactoryGirl.build(:old_lend_out, lendingTime: Time.new)
expect(color_class_for_lent_since(old_lend_out)).to eq('')
end
it ... | true |
28c609a644e89e9b616826a3105d676a74bc6087 | Ruby | ConwayWest/precourse_book | /methods/e_1.rb | UTF-8 | 111 | 3.796875 | 4 | [] | no_license | def greeting(name)
puts "Howdy #{name}!"
end
puts "What is your name?"
answer = gets.chomp
greeting(answer) | true |
9bde1213c2de9a149c52865356a70f774f8f6fa6 | Ruby | dmityreus/ruby_practice | /environment/2D_Arrays/combinations.rb | UTF-8 | 289 | 3.609375 | 4 | [] | no_license | def combinations(arr)
array = []
arr.each_with_index do |num1, idx1|
arr.each_with_index do |num2, idx2|
if idx2 > idx1
array << [num1, num2]
end
end
end
return array
end
print combinations([1, 2, 3]) | true |
fa059689b6c9c048390fc6e6a211773775a58127 | Ruby | alexey-lysiuk/macos-sdk | /MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/protocol/driver.rb | UTF-8 | 8,786 | 2.59375 | 3 | [] | no_license | #--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
# All rights reserved.
#
# This source file is distributed as part of the Net::SFTP Secure FTP Client
# library for Ruby. This file (and the library as a whole) may be used only as
... | true |
395adecf97c3cc9662885b1231e621cef6e0eb85 | Ruby | jpodeszwik/barkeep | /lib/string_filter.rb | UTF-8 | 2,494 | 3.28125 | 3 | [
"MIT"
] | permissive | # StringFilter is used to attach filters to methods that return strings.
# Filters are defined using `StringFilter.define_filter`.
# It can then be mixed in to classes with `include StringFilter`.
#
# The including class gains the `add_filter` method, which accepts
# a name of one of its instance methods to filter and ... | true |
3e8d36b7049143740f924595db545c3422a9d6ae | Ruby | elcuervo/airplay | /lib/airplay/player/media.rb | UTF-8 | 1,099 | 2.578125 | 3 | [
"MIT"
] | permissive | require "mime/types"
require "airplay/server"
module Airplay
class Player
class Media
attr_reader :file_or_url, :url
COMPATIBLE_TYPES = %w(
application/mp4
video/mp4
video/vnd.objectvideo
video/MP2T
video/quicktime
video/mpeg4
)
def initi... | true |
23f6590e523fd9c2c67959682af047ca63801736 | Ruby | azhar-uddin/testapp | /test.rb | UTF-8 | 537 | 3.1875 | 3 | [] | no_license | =begin
class Ha
attr_accessor :value, :next_node
x= Hash.new
x.value = "Azhar"
x.next_node = 2
puts x
end
asfasgas
aasgasgas
agagasf
# String is already the parent class
class Post
attr_accessor :title
def replace_title(new_title)
self.title = new_title
end
def print_title
puts ... | true |
5aae65be16694a21650058254356f21fe6ac4102 | Ruby | concord-consortium/rigse | /rails/spec/libs/archiveable_spec.rb | UTF-8 | 2,735 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | require 'spec_helper'
class WithoutArchiveFields
include Archiveable
end
class WithArchiveFields
include Archiveable
attr_accessor :is_archived
attr_accessor :archive_date
def update(hash_data)
hash_data.each do |k,v|
self.send("#{k}=".to_sym,v)
end
end
end
describe Archiveable do
let(:un... | true |
f23c4e22ba04278fb72d75e7ff47f01b6bb26898 | Ruby | angelabier1/DMS | /app/models/mbr.rb | UTF-8 | 9,224 | 2.703125 | 3 | [] | no_license | #encoding: utf-8
class Mbr
def self.analyze(num)
if car = Car.where(:order => num).first
print 'exist in cars'
print 'and published' if car.published
end
if car = MCar.find_by_ordernum(num)
print 'exist in mbclub'
prind ' and published' if car.sold == 0
end
end
def self... | true |
1e179672e1b0de1b8e399d118a7a6d4b1fb24a6d | Ruby | International/em-fork_reactor-example | /simple_fork.rb | UTF-8 | 494 | 2.625 | 3 | [] | no_license | elements = (1..2).to_a
processes = 2
proc_queue = []
pids = {}
elements.each do |elem|
puts "Using element #{elem}"
rd, wr = IO.pipe
if pid = fork
wr.close
pids[pid] = rd
else
# child
sleeping_for = (Random.rand * 100 % 20).to_i
puts "Sleeping for #{sleeping_for}"
rd.close
... | true |
2a2a4d249317fb15f91622cc03f881944811305c | Ruby | Carolyn63/IntrApp | /lib/tools/normal_crypt.rb | UTF-8 | 607 | 3.3125 | 3 | [] | no_license | module Tools
class NormalCrypt
attr_reader :encrypted, :decrypted
def initialize
@encrypted = nil
@decrypted = nil
end
def encrypt(str)
@encrypted = ''
i=7
str = str.reverse
str.each_byte do |b|
@encrypted << (~b+i).to_s + "*"
i = (i*i) % 423
... | true |
e1176aee01f79bf76c01deb3104d16527593b05e | Ruby | laganows/MOwNiT2-metryki-odleglosci | /plot.rb | UTF-8 | 1,018 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
#Three csv files need to exist to use this method
=begin
def plotData(nameOfPngOutput)
gnuplot_commands = <<"End"
set terminal png
set output "plot.png"
plot "test1.csv" using 0:1 with lines, "test2.csv" using 0:1 with lines, "test3.csv" using 0:1 with lines
End
image, s = Open3.cap... | true |
cfd9912eea56407ef5ac5bb40e3a7ae78390a824 | Ruby | ksimon93/Competitive_Programming | /Codeforces/609/A.rb | UTF-8 | 190 | 3.109375 | 3 | [] | no_license | n = gets.to_i
m = gets.to_i
arr = []
for i in 0..n-1
arr[i] = gets.to_i
end
arr = arr.sort
count = 0
idx = n-1
while m > 0
m -= arr[idx]
idx -= 1
count += 1
end
puts count
| true |
a12eca96ad3acf329ad7b69eea172f19346b838b | Ruby | Filmscore88/sinatra-nested-forms-lab-superheros-online-web-ft-031119 | /app/models/super_hero.rb | UTF-8 | 370 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Superhero
attr_accessor :name, :power, :bio
@@all=[]
def initialize(options={})
@name = options[:name]
@power = options[:power]
@bio = options[:bio]
@@all << self
end
# def intialize(params = {})
# @name=params[:name]
# @power=params[:power]
# @bio=params[:bio]
# @@all<<... | true |
6a06694f48dfc4fc6072d1d9ee8eda1b24c45f93 | Ruby | tbrack93/textalignjustify | /justify_spec.rb | UTF-8 | 2,656 | 3.0625 | 3 | [] | no_license | require 'rspec'
require_relative 'text_align_justify'
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
RSpec.describe "passed... | true |
940a150665987e1f0277d0e891e875cb940dc084 | Ruby | ssaunier/got_fixed | /lib/got_fixed/adapters/github.rb | UTF-8 | 2,249 | 2.71875 | 3 | [
"MIT"
] | permissive | require "httparty"
module GotFixed
module Adapters
class Github
include HTTParty
base_uri "https://api.github.com"
attr_accessor :access_token, :owner, :repo
def initialize(options = {})
ensure_mandatory_parameters options, true
end
# Retrieve all issues of a given ... | true |
072836f7e179f6814e6438133d15c039de8e0aed | Ruby | ctwoodnyc/playlister-rb | /lib/artist.rb | UTF-8 | 1,121 | 4.03125 | 4 | [] | no_license | #build method reset_artists that should return 0
#all class method
#count class method
class Artist
attr_accessor :name, :songs, :genre
@@artists = []
#initialize artist instance variable
def initialize(str=nil)
@name = str
@songs = []
@genre = []
@@artists.push(self)
end
# create the reset_... | true |
6cf712564fc06d029ecc39cd7fc3dbef46c7343f | Ruby | t-recx/turbomode | /test/turbomode/systems/animation_system_test.rb | UTF-8 | 3,185 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'turbomode'
include Turbomode
include Turbomode::Systems
include Turbomode::Components
describe AnimationSystem do
before do
@frame_duration = 100
@sprite1 = Object.new
@sprite2 = Object.new
@sprite3 = Object.new
@wrapper = Minitest::Mock.new
@frames = {
... | true |
2cdb20bfa5164234e794c77c20b9485dff635702 | Ruby | Lebeil/scrappeur | /lib/dark_trader.rb | UTF-8 | 1,994 | 3.65625 | 4 | [] | no_license | require 'nokogiri'
require 'open-uri'
#page = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
#puts page.css('title').text
#Scrapping name
def coins
page = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
name_array = Array.new
(0..200).each do |x|
name_array ... | true |
24713febcc00bd476c27cb8fc41fdcb76ecb22e8 | Ruby | Chaneze/Exo_Ruby | /exo_20.rb | UTF-8 | 322 | 3.5 | 4 | [] | no_license | puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?"
print "> "
user_number = gets.chomp.to_i
if user_number >= 1 && user_number <= 25
puts "Voici la pyramide :"
(user_number).times do |i|
i.times do
print "#"
end
puts "#"
end
else
puts "Il fallait saisir un nombre entre 1 et 25"
end... | true |
4c0a2c3eebdf676a1be0b34ae16ad04d042baa05 | Ruby | FredJCV/ls_prep_exercises | /intro_to_programming/arrays/7.rb | UTF-8 | 131 | 3.28125 | 3 | [] | no_license | orig_arr = [1, 2, 3]
def make_new_arr(array)
array.map { |i| i + 2 }
end
new_arr = make_new_arr(orig_arr)
p orig_arr
p new_arr | true |
2c3906f678dca23fa394565c70745648d1da4529 | Ruby | CodeCoreYVR/june_fundamentals | /rectangle.rb | UTF-8 | 443 | 3.5 | 4 | [] | no_license | ## VERSION 2
class Rectangle
attr_reader :area
def initialize(width, height)
@width, @height = width, height
# Precalculates the area and sets it to instance variable
@area = width * height
end
end
## VERSION 1
# class Rectangle
# attr_accessor :width
# attr_accessor :height
# de... | true |
7b50e0ebb7722df0bdf48f974eece18c1bb0d56c | Ruby | RonaldoFaustino/curso_qafull_stack_qaninja | /ruby/enjoeat_2/features/test.rb | UTF-8 | 79 | 2.84375 | 3 | [] | no_license |
quantidade = 2
quantidade.times do
puts "adiciona no carrinho"
end | true |
611260111676fb47a533289fa70afde293c9c378 | Ruby | mdesjardins/words_test | /lib/processor.rb | UTF-8 | 955 | 3.5 | 4 | [] | no_license | require_relative './sequences'
require 'set'
class Processor
include Sequences
# Initialize with something Enumerable (specifically
# something that responds to 'each', e.g., a file or an
# array).
def initialize(enumerable)
@enumerable = enumerable
end
# This function can work w/ a block into whic... | true |
6517acca97278ddaa6dcb74cc80378fce9cb1906 | Ruby | mikhliuk-k/cryptographic_algorithms | /substitution_cipher/encoder.rb | UTF-8 | 630 | 2.84375 | 3 | [] | no_license | path_to_file = ARGV[0]
secret_key = ARGV[1]
secret_hash = secret_key.split('').map.with_index {|a, index| [index, a]}.sort_by {|b| b[1]}
file_text = File.read(path_to_file).to_s
text_map = file_text.split('').each_slice((file_text.length / secret_key.length).ceil).to_a
(file_text.length / secret_key.length).ceil.times... | true |
60e7a4bc9157e27933ef23599d7d9964444cc835 | Ruby | YoungLad/Ironhack | /Week2/Day3/passwordchecker/spec/check_spec.rb.rb | UTF-8 | 583 | 2.765625 | 3 | [] | no_license | require_relative("../lib/check.rb")
RSpec.describe Check do
let :passcheck do
Check.new("rainbow@gmail.com", "R1ainbow@")
end
it "checks that there are more than 7 characters" do
expect(passcheck.pass_length?).to eq(true)
end
it "chack that the password has variety" do
expect(passcheck.alpha_numeral_ch... | true |
2bbe0262f8e8649d23ee486b3f1315f684e79fc1 | Ruby | dmsalomon/euler | /euler3.rb | UTF-8 | 284 | 3.03125 | 3 | [] | no_license | class Fixnum
def prime?
return false if self <= 1
primeness = true
2.upto self-1 do |i|
if self%i == 0
primeness = false
break
end
end
primeness
end
end
NUM = 600851475143
a = []
NUM.times do |x|
x << a if x.prime?
end
| true |
c21f5a7b03219c77bdb72671335bc1fc252f099b | Ruby | stinder/yamba | /database.rb | UTF-8 | 1,860 | 2.609375 | 3 | [] | no_license | require 'active_record'
require 'sinatra'
require 'sinatra/activerecord'
require 'date'
require_relative 'csv_data'
#TODO: turn db methods into instance methods
TIME_PATTERN = '%T'
class BusStop < ActiveRecord::Base
attr_accessible :stop_id, :stop_code, :stop_name, :stop_lat, :stop_lon
has_many :stop_times, :pri... | true |
c5bd05441e12801363d0a14674753c2d7cde4bcb | Ruby | Joe11000/FlashCards | /view.rb | UTF-8 | 1,194 | 3.65625 | 4 | [] | no_license | require_relative 'model'
require_relative 'controller'
EXIT_SENTINAL = "-1"
EXIT_MESSAGE = "Thanks for playing!"
SHOW_ANSWER = "show"
DEFINITION = 0
ANSWER = 1
our_model = Model.new
our_model.create_cards("flashcard_samples.txt")
our_deck = Deck.new(our_model.flashcards)
puts "Welcome to Ruby Flash Cards. To play,... | true |
0986ede5e91ec1c3d709860c984c15392c0209ce | Ruby | datarator/datarator-attic | /lib/datarator/out_context.rb | UTF-8 | 2,832 | 2.578125 | 3 | [
"MIT"
] | permissive | require_relative 'columns'
require_relative 'options'
require_relative 'out_templates'
module Datarator
class OutContext
attr_accessor :document, :row_index, :empty_value, :locale
attr_reader :template, :count, :columns, :options, :cache
class << self
def from_json(json)
raise ArgumentErro... | true |
44432f40fbb94b52f78f91220a8bafc44748dad5 | Ruby | ericfransen/event_reporter | /test/queue_test.rb | UTF-8 | 1,315 | 2.609375 | 3 | [] | no_license | require_relative './test_helper'
require_relative '../lib/queue'
class QueueTest < Minitest::Test
def test_can_load_file?
skip
queue = Queue.new upload?
assert_equal :true
end
def test_can_load_general_help_instructions
skip
queue = Queue.new
Queue.general_help
assert_equal "Help in... | true |
48ac9452d4a135d7d5fe50b59c2f1c9195bf31a7 | Ruby | jerryluk/has_zone | /spec/has_zone_spec.rb | UTF-8 | 1,640 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe HasZone do
class Resource
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
include HasZone
attr_accessor :time_zone
has_zone with: :time_zone
def write_attribute(attribute, value)
instance_variable_set("@#{attribute}".to_sym, v... | true |
cc73f1586e7667c0cf398a866fc5567826490a52 | Ruby | yuki3738/AtCoder | /abc/abc072/tasks/abc072_a.rb | UTF-8 | 101 | 2.859375 | 3 | [] | no_license | x, t = gets.split.map(&:to_i)
if (x - t).zero? || (x - t).negative?
puts 0
else
puts (x - t)
end | true |
68dc52511c808b3eae4afe0d05e449ebb9fdc481 | Ruby | StephenWetzel/pi-controller | /app/controllers/helper.rb | UTF-8 | 924 | 3.609375 | 4 | [
"MIT"
] | permissive | module Helper
SECONDS_IN_MINUTE = 60
SECONDS_IN_HOUR = 60 * 60
SECONDS_IN_DAY = 60 * 60 * 24
SECONDS_IN_YEAR = 60 * 60 * 24 * 365
# Returns negative seconds for future dates
def age(from_dt)
to_dt = Time.current
total_seconds = (to_dt - from_dt).to_i
seconds = total_seconds
if total_second... | true |
26b0925206ef62393037fb6035b1a1e2edbf8706 | Ruby | Moohy/FoodCourt | /app/models/order_line.rb | UTF-8 | 446 | 2.5625 | 3 | [] | no_license | class OrderLine < ApplicationRecord
belongs_to :order
belongs_to :menu_item
after_create :update_order
before_destroy :decrease_price
private
def update_order
price = self.price + order.total_price
order.update(total_price: price)
end
def de... | true |
6a5a75b9ae6a75e664b6ece2147270b1f4860afe | Ruby | sharat94/family_tree_sharat | /spec/kingdom_spec.rb | UTF-8 | 286 | 2.8125 | 3 | [] | no_license | require 'kingdom'
describe Kingdom do
describe ".initialize" do
it "check if the family members have been loaded to class instance variable" do
family_names = Kingdom.family.map{ |member| member.name }
expect(family_names.include?("vyan")).to eq true
end
end
end | true |
653cdaad053178cf34b030a9582ef382f357757a | Ruby | igorkaz001/phase-0 | /week-4/calculate-grade/my_solution.rb | UTF-8 | 338 | 3.640625 | 4 | [
"MIT"
] | permissive | # Calulate a Grade
# I worked on this challenge [by myself, with: ].
#myself
# Your Solution Below
def get_grade(avg)
if avg <= 100 and avg > 89
return "A"
elsif avg < 90 and avg > 79
return "B"
elsif avg < 80 and avg > 69
return "C"
elsif avg < 70 and avg > 59
return "D"
else avg < 60 and avg > 0
ret... | true |
1c7d0e8e53b9bed968436fe33b12475c5e01bdbe | Ruby | care0717/pro_con | /atcoder/abc/101/D.rb | UTF-8 | 465 | 2.9375 | 3 | [] | no_license |
K = gets.to_i
#res = []
#100000.times{|i|
## res << (i+1)/digit_sum(i+1).to_f
#}
#puts res
res = [*1..9]
res = res.concat([*1..9].map{|i| i*10+9})
res = res.concat([*1..9].map{|i| i*100+99})
((K-27)/90+1).times{|n|
base = 10**(n+2)
[*1..9].each{|i|
[*0..9].each{|j|
res << j*base+i*base*10+base-1
}
... | true |
3e3cc0bf1305dec3d9ef84831432c24799b4e545 | Ruby | chiodo/health-check | /app/models/master.rb | UTF-8 | 591 | 2.59375 | 3 | [] | no_license | #Simple representation of the master database status of the node in question
class Master
include ActiveModel::Model
attr_accessor :connect, :free_space, :archive_replication_status, :ok
#do we have a connection to the main node and archive node
def connect_ok?
connect['main'] == 'ok' && connect['archive'... | true |
bca9bf7c00111e58dde0565a0e3a2b2de6dc89ca | Ruby | bethsebian/exercism | /ruby/food-chain/food_chain.rb | UTF-8 | 1,407 | 3.765625 | 4 | [] | no_license | class FoodChain
VERSION = 2
FOOD = ["fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse"]
DESCRIPTIONS = { "spider" => "It wriggled and jiggled and tickled inside her.",
"bird" => "How absurd to swallow a bird!",
"cat" => "Imagine that, to swallow a cat!",... | true |
a9c40029e80b0f6f1daf43c00698a7ce94e46347 | Ruby | StephenDeVaux/Sei39 | /code-alongs/05_database/6.movies3/main.rb | UTF-8 | 1,246 | 2.703125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'httparty'
require 'pry'
require_relative 'db/db_access'
def info_page imdbID
cached_movielist = run_sql("SELECT * FROM cachedmovies1 WHERE imdbid = '#{imdbID}';")
if cached_movielist.count == 0
url = "http://omdbapi.com/?i=#{imdbID}&apikey=2f6435d9"
m... | true |
1da540bb2c634cdfdc8507e4022686953fb3fbb2 | Ruby | MCSimoes18/sinatra-mvc-lab-nyc-web-career-010719 | /models/piglatinizer.rb | UTF-8 | 1,525 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(word)
# new_word = word
word = word.split(' ')
vowels = ['a','e','i','o','u','A','E','I','O','U']
# if !word.strip.include?(" ")
# word.each do |word|
# if vowels.include?(word[0])
# new_word = word + "way"
# elsif !vowels.include?(word[0])... | true |
98ea1d69853aae7498d0ecd0f386bb289562fb33 | Ruby | jadencarver/coded_attribute | /lib/coded_attribute.rb | UTF-8 | 1,075 | 2.84375 | 3 | [
"MIT"
] | permissive | # CodedAttributes
module CodedAttribute
def coded_attributes
@@coded_attributes ||= {}
end
def coded_attributes=(value)
@@coded_attributes = value
end
def coded_attribute(*attributes_and_codes)
if attributes_and_codes.last.is_a?(Hash)
codes = attributes_and_codes.pop
elsif attributes... | true |
e8c8104b00db37ec1606eb1e4befc748a62674cf | Ruby | richardsbrandao/ruby | /gems/concurrency/threadsafevars/atom.rb | UTF-8 | 392 | 3.484375 | 3 | [] | no_license | require 'concurrent'
def next_fibonacci(set = nil)
return [0, 1] if set.nil?
set + [set[-2..-1].reduce{|sum,x| sum + x }]
end
def championship(set = nil)
return [0] if set.nil?
set + [[0,1,3].sample]
end
atom = Concurrent::Atom.new(championship)
38.times do
atom.swap{|set| championship(set) }
end
puts "Pont... | true |
ae8116b03bd212148e3f90d36b5739298576f932 | Ruby | rudecs/ePortal | /pay/config/initializers/_yml2os.rb | UTF-8 | 751 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | require 'yaml'
require 'ostruct'
class YML2OS
attr_reader :os
def initialize(file = nil)
convert(file) if file
end
def convert(file)
yaml = YAML.load(File.open(file))
@os = hash2os(yaml)
end
private
# Check for hashes and arrays inside 'hash'. Convert any hashes.
def hash2os(hash)
h... | true |
aed0203316418cf1dc3955887ade93366215d426 | Ruby | isabella232/metasploit-cache | /lib/metasploit/cache/ancestor_cell.rb | UTF-8 | 1,170 | 2.828125 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | # Helpers for `Metasploit::Cache::*::AncestorCell`s
module Metasploit::Cache::AncestorCell
# Enumerates `enumerable` giving `separator` for each element except the last so that comma separated lists can be
# rendered more easily
#
# @example separate actions to form a ruby array
# [
# <%- separate(a... | true |
28437863eceb812599d60d05d7ead17f07b4ad9f | Ruby | Fully34/daily-programming | /name-game/script.rb | UTF-8 | 2,934 | 4.34375 | 4 | [] | no_license | # [2015-04-20] Challenge #211 [Easy] The Name Game
# submitted 29 days ago * by XenophonOfAthens2 1
# Description
# If computer programmers had a "patron musician" (if such a thing even exists), it would surely be the great Shirley Ellis. It is my opinion that in the history of music, not song has ever come closer to ... | true |
40fd31e9fc709eda63de95b8c86d0893933b389d | Ruby | rubyunworks/corpus-ruby | /lib/corpus/analysis/bigrams.rb | UTF-8 | 4,106 | 3.3125 | 3 | [] | no_license | module Corpus
module Analysis
##
# Bigram analysis.
#
class Bigrams
include Utils
include Enumerable
REJECT_BIGRAMS = %w{ye yo n't d'n sh th ha ah la sa}
# Initialize Bigram analysis instance.
#
# analysis - The main Analysis instance.
#
def initiali... | true |
851e84b53a9c379a14439b15db13928e27808775 | Ruby | jklmaynard/assessment_week_3 | /spec/client_spec.rb | UTF-8 | 1,541 | 2.828125 | 3 | [] | no_license | require('spec_buddy')
describe(Client) do
describe("#name") do
it("returns the name of a stylist") do
client1 = Client.new({ :name => "Martha Jones", :stylist_id => 1 })
expect(client1.name()).to eq("Martha Jones")
end
end
describe("#save") do
it("saves a client into an array") do
... | true |
420bf54a6fb56a773ce81a9666014b689c773ab1 | Ruby | Ch00k/kubr | /lib/core_ext/hash.rb | UTF-8 | 298 | 2.578125 | 3 | [] | no_license | require 'active_support/core_ext'
class Hash
def recursively_symbolize_keys!
symbolize_keys!
values.each { |h| h.recursively_symbolize_keys! if h.is_a?(Hash) }
values.select { |v| v.is_a?(Array) }.flatten.each{|h| h.recursively_symbolize_keys! if h.is_a?(Hash) }
self
end
end
| true |
32d9a9f879b74cb2addc118d4ad025a44f4a2b3b | Ruby | theodi/dashboards | /lib/lecture_list.rb | UTF-8 | 1,010 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'json'
require 'net/http'
require 'active_support/all'
class LectureList
def self.update(status)
json = Net::HTTP.get URI.parse("http://theodi.org/lectures.json")
lectures = JSON.parse(json)
lecture_list = lectures.map do |url, data|
if data['status'] == status
tickets = get_tic... | true |
2cb1ab76e43dcb8ddf11300a65098315feebc882 | Ruby | johan--/Project-Euler | /ruby/9.rb | UTF-8 | 1,703 | 3.515625 | 4 | [] | no_license | #!/usr/bin/env ruby
require 'timing_method'
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
#
# a^2 + b^2 = c^2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
#
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
#
# a = 1000 - b - c
# b = 10... | true |
10c6e977df9ddfc5e22df611e7c0a7b2a25fec6f | Ruby | svenka3/simple_reg_model | /srm/unit_tests/test_reg_block.rb | UTF-8 | 886 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'ostruct'
require_relative "../lib/srm/reg_block"
require_relative "../lib/srm/register"
class TestRegBlock < MiniTest::Test
include SRM
def setup
@reg_block = RegBlock.new(name: 'cpu_registers') do |block|
block << Register.new(name: "r1").offset("cpu_map" => [0x100, 0... | true |
a7158494c2c8e583cd192d70e019aed93c0754ac | Ruby | rachellogie/api_spike | /tracker_stories.rb | UTF-8 | 419 | 2.625 | 3 | [] | no_license | require 'json'
require 'faraday'
require 'dotenv'
Dotenv.load
conn = Faraday.new 'https://www.pivotaltracker.com/services/v5/projects/1067890/stories'
response = conn.get do |req|
req.url 'https://www.pivotaltracker.com/services/v5/projects/1067890/stories'
req.headers['X-TrackerToken'] = ENV['TOKEN']
end
json_d... | true |
64761c00583ac2397e6ea0107178d69ff881f329 | Ruby | DeerAntlers/Lib | /03_stairway.rb | UTF-8 | 1,153 | 3.171875 | 3 | [] | no_license | #annonce de début de partie
def start_game
puts "Que la partie commence !"
end
def game
# On part de la marche 0
step = 0
# tant qu'on ne va pas plus loin que la 10e marche
until step == 10
puts "Lance le dé"
# lancé de dé random de 1 à 6
dice_throw = rand(1..6)
# dé = 5 ou 6 : monte d'une marche
puts ... | true |
1a927a0726b549d2c558e1991b9ff8cc1c3ab30f | Ruby | codeguru85/ios-png-check | /bin/ios-png-check | UTF-8 | 2,986 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'escape'
require 'fileutils'
# Main block
def main
files_wo_1x_version = []
files_wo_2x_version = []
size_errors = []
empty_files = []
png_files = Dir.glob('*.png')
png_files.each { |png_file|
name_parts = png_file.split(/[@\.]/)
# next if nam... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.