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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dab8a8901b3dbb16f4100460357da47d5d0e49e5 | Ruby | TheEntropics/serben-cash | /app/helpers/application_helper.rb | UTF-8 | 381 | 2.546875 | 3 | [] | no_license | module ApplicationHelper
def true_mark
check_box_tag nil, 1, true, disabled: true
end
def false_mark
check_box_tag nil, 0, false, disabled: true
end
def boolean_mark(status)
status ? true_mark : false_mark
end
def format_date(date)
date.strftime("%d/%m/%Y")
end
def format_currency(a... | true |
a437a4205e37c25a08deb3c2e9f97dc7a5e356a0 | Ruby | ginasekhar/ruby-enumerables-hash-practice-green-grocer-lab-online-web-prework | /grocer.rb | UTF-8 | 2,010 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def consolidate_cart(cart)
consolidated_hash = {}
cart.each do |item_hash|
item_name = item_hash.keys[0]
item_details = item_hash.values[0]
if consolidated_hash.has_key?(item_name)
consolidated_hash[item_name][:count] += 1
else
consolidated_hash[item_name] = {count: 1,
... | true |
bd9f1e9970871af23a56fe93cc75ac8e69346055 | Ruby | jalena-penaligon/brownfield-of-dreams | /spec/models/user_spec.rb | UTF-8 | 3,278 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'validations' do
it {should validate_presence_of(:email)}
it {should validate_presence_of(:first_name)}
it {should validate_presence_of(:password)}
end
describe 'roles' do
it 'can be created as default user' do
user = Use... | true |
e7756d4f7e6d442b516737b82abbc67efcd0643d | Ruby | AlwaysBCoding/ruby_tictactoe | /lib/square.rb | UTF-8 | 585 | 3.40625 | 3 | [] | no_license | class Square
attr_accessor :x_value, :y_value, :diag_value, :number, :text_value
def initialize(x,y,diag=nil,text_value=nil,number=nil)
@x_value = x
@y_value = y
@diag_value = diag
@text_value = text_value.to_s
@number = number
end
def empty?
return true if text_value.to_s != "X" && text_... | true |
5ddc6c028a84303147ce349142e7644f8c087290 | Ruby | zebogen/climate_tweets | /app/controllers/twitterpull.rb | UTF-8 | 2,144 | 2.703125 | 3 | [] | no_license | require 'oauth'
require 'json'
module TwitterPull
def TwitterPull.pull(inp_query, inp_count)
consumer_key = OAuth::Consumer.new(
"wcs1zGACZ8pBMLGUWDJwLvVPt",
"q2OycC0G2cFNBZrkqP5Z2UXClDlcg63BqDEMP9OrRGeYZoCX5v")
access_token = OAuth::Token.new(
"1628440405-T5dufqnbYGMZ8kYOkHMvZaiE6b6lM4... | true |
82db1e8782d33e803f38ec26a7120f5a1e549d0c | Ruby | historyforge/historyforge | /app/models/role.rb | UTF-8 | 848 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# This used to be an ActiveRecord model from the MapWarper days. It is now a bitmask model to make storage and
# lookup more efficient.
class Role < BitmaskModel
self.data = [
'Administrator',
'Editor',
'Reviewer',
'Photographer',
'Census Taker',
'Builder',
'... | true |
3251825e48f62ecb263c853c3a3dc0105efbd88a | Ruby | mikylamoehlenbruck/rb101 | /lesson_2/rock_paper_scissors.rb | UTF-8 | 3,815 | 3.421875 | 3 | [] | no_license | require 'yaml'
MESSAGES = YAML.load_file('rps_messages.yml')
LANGUAGE = 'en'
VALID_CHOICES = %w(rock paper scissors lizard spock)
ABBREVIATIONS = %w(r p s l $)
WINNING_OPTIONS = {
'rock' => ['scissors', 'lizard'],
'paper' => ['rock', 'spock'],
'scissors' => ['paper' 'lizard'],
'lizard' => ['spock', 'paper'],... | true |
be967b155f4c1ba28a431ae64b9b3ade002f3152 | Ruby | BlueVajra/sinatra_test | /lib/item_repository.rb | UTF-8 | 378 | 3.4375 | 3 | [] | no_license | class ItemRepository
def initialize
@items = []
end
def add(item_to_add)
@items << item_to_add
end
def items
@items
end
def delete(item_to_delete)
@items.delete(item_to_delete)
end
def edit(old_name, new_name)
@items.each_with_index do |item, index|
if item == old_name
... | true |
6674217de47555dde77f337d9e94beef7195e18e | Ruby | larouxn/cli-library | /library.rb | UTF-8 | 5,074 | 3.703125 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
###############################
# Nicholas La Roux #
# April 2015 #
# Command line personal #
# library management utility #
###############################
require 'yaml'
require_relative 'book'
def load_library
storage = File.open('my_library.yaml', 'a+')
... | true |
3075c7062ea3df331d4292b526d17f03197d8cc2 | Ruby | the-color-bliu/war_or_peace | /test/turn_test.rb | UTF-8 | 6,701 | 3.21875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
require './lib/card'
require './lib/deck'
require './lib/player'
require './lib/turn'
class TurnTest < Minitest::Test
def test_it_exists_and_has_attributes
card1 = Card.new(:heart, 'Jack', 11)
card2 = Card.new(:heart, '10', 10)
card3 = Car... | true |
6809445b23ddcf2d2362c3aa8c58f7860c91b28a | Ruby | aspc/aspc-website | /app/services/engage_events_service.rb | UTF-8 | 3,257 | 2.6875 | 3 | [
"MIT"
] | permissive | # app/services/engage_events_service.rb
class EngageEventsService
def initialize()
end
def get_events()
headers = {
"Accept" => "application/json",
"X-Engage-Api-Key" => Rails.application.credentials.engage_api[:production]
}
start_time = Time.now.to_i * 10... | true |
1c200e1d5373f7a6817506b5890d0ed227ff7b18 | Ruby | MGellman88/Ruby-on-Rails | /arrays.rb | UTF-8 | 274 | 3.625 | 4 | [
"MIT"
] | permissive | array1 = ["Rocky", "Colt", "Tum-Tum"]
array2 = ["Larry", "Moe", "Curly"]
array3 = ["Paul", "John", "George", "Ringo"]
x = (array1+array2) - array3
puts x.to_s
puts array1.shuffle.join('-')
array3.delete("John")
puts array3
puts "Length of array3 is #{array3.length}"
| true |
9584495575a504c35ff06fba8e43d9a91899e081 | Ruby | ramblex/euler | /euler-2.rb | UTF-8 | 505 | 3.828125 | 4 | [] | no_license | #
# Each new term in the Fibonacci sequence is generated by adding the previous two
# terms. By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose values do not exceed
# four million, find the sum of the even-valued ter... | true |
a6de7e2c29dc33f52bf7f53a8352bd176a5cf27e | Ruby | VladislavKadyshev/Rubylabs | /lab2/lib/computing.rb | UTF-8 | 906 | 3.546875 | 4 | [] | no_license | require 'csv'
# Comp operations
class Computing
def initialize
name = "#{__dir__}/ruby.csv"
@arr = []
CSV.foreach(name, col_sep: ';') do |a|
@arr << a[1].to_f
end
@arr.shift
end
def comp_max
@arr.max
end
def comp_min
@arr.min.round(2)
end
def comp_average
(@arr.su... | true |
a94ff1d82dcd47ea04534c45f9bd567c087e79be | Ruby | joshmosh/learning-ruby | /classes/dog_test.rb | UTF-8 | 509 | 3.03125 | 3 | [] | no_license | require File.join(File.dirname(__FILE__), 'dog')
require 'test/unit'
class DogTest < Test::Unit::TestCase
def test_small_dog_size
small_dog = Dog.new(8)
noise = small_dog.make_noise
assert_equal "Horrific yapping", noise
end
def test_medium_dog_size
medium_dog = Dog.new(24)
noise = medium_d... | true |
b9040e91f57a65a45afdad29caa79664668ca195 | Ruby | anikeef/connect_four | /spec/game_spec.rb | UTF-8 | 2,192 | 3.140625 | 3 | [] | no_license | require "./lib/game.rb"
describe Game do
before :each do
$stdout = StringIO.new
end
describe "#initialize" do
it "stores the usernames" do
allow_any_instance_of(Game).to receive(:gets).and_return("Gena", "Tayga")
game = Game.new
players = game.instance_variable_get(:@players)
exp... | true |
091049dd2e217ecbc05852800f563835d278f77c | Ruby | volontariat/voluntary_music_metadata_enrichment | /dummy/spec/support/deferred_garbage_collector.rb | UTF-8 | 1,299 | 2.671875 | 3 | [
"MIT"
] | permissive | # https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f #used to be 10.0
@@last_gc_run = Time.now
def self.start
return if unsupported_enviroment
GC.disable if DEFERRED_GC_THRESHOLD > ... | true |
7ce219f8638696dcf4858a08f6fb1a489a2c3c3b | Ruby | lkilk/test_driven_development | /library_exercise/spec/library_spec.rb | UTF-8 | 1,001 | 3.109375 | 3 | [] | no_license | require 'library'
describe Library do
describe "#find_book" do
it 'can find a specific book' do
library = Library.new
expect(library.find_book("POODR")).to eq(:title=>"POODR", :author=>"Sandi Metz", :subject=>"OOP")
end
end
describe "#add_book" do
it 'can add a new book' do
library... | true |
e4d8d0dbf364286eef6c16001af1c65e2d165ebb | Ruby | andremleblanc/kairosdb-ruby | /lib/kairosdb/client/http.rb | UTF-8 | 2,644 | 2.640625 | 3 | [
"MIT"
] | permissive | module KairosDB
module HTTP
def post(url, data)
headers = { 'Content-Type' => 'application/json' }
connect_with_retry do |http|
response = do_request http, Net::HTTP::Post.new(url, headers), JSON.generate(data)
if response.is_a? Net::HTTPSuccess
handle_successful_response(res... | true |
d11abcf4d92ff3ff6fa2033e33a048e91386f7b7 | Ruby | ruliana/design-patterns-101 | /lib/mercearia/cesta.rb | UTF-8 | 301 | 3.0625 | 3 | [] | no_license | class Cesta
def initialize
@produtos = []
end
def adicionar(produto)
@produtos << produto
end
def preco
@produtos.reduce(0.reais) { |acumulado, produto| acumulado + produto.preco }
end
def accept(visitor)
@produtos.each { |produto| produto.accept(visitor) }
end
end
| true |
f48fd8c18e3b3625ba273e3048010a9691f58323 | Ruby | victorperezcotapos/desafios_Intro_Ruby | /mas_cerca_puntos.rb | UTF-8 | 701 | 3.34375 | 3 | [] | no_license | coordenada_x = [ARGV[0].to_f,ARGV[2].to_f,ARGV[4].to_f,ARGV[6].to_f,ARGV[8].to_f]
coordenada_y = [ARGV[1].to_f,ARGV[3].to_f,ARGV[5].to_f,ARGV[7].to_f,ARGV[9].to_f]
distancias = Array.new
distancias[0]= Math.sqrt((coordenada_x[0]-coordenada_x[1])**2+(coordenada_y[0]-coordenada_y[1])**2)
distancias[1]= Math.sqrt((coord... | true |
eff5170df1269db119b9abf775305a9b04d25128 | Ruby | MarcusRiemer/sport.db | /sportdb-formats/lib/sportdb/formats/season_utils.rb | UTF-8 | 3,972 | 3.203125 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | # encoding: utf-8
module SeasonHelper ## use Helpers why? why not?
def prev( season )
## todo: add 1964-1965 format too!!!
if season =~ /^(\d{4})-(\d{2})$/ ## season format is 1964-65
fst = $1.to_i - 1
snd = (100 + $2.to_i - 1) % 100 ## note: add 100 to turn 00 => 99
"%4d-%... | true |
150f575372186996aaa24b4210d57905f1bb7a0b | Ruby | ssowonny/c11n | /lib/c11n/importer/google_drive.rb | UTF-8 | 973 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'c11n/external/google_drive_driver'
require 'c11n/table'
module C11n
module Importer
class GoogleDrive
def initialize(options = {})
@driver = C11n::External::GoogleDriveDriver.new(options)
end
def table
@table ||= C11n::Table.new(@driver.table)
end
def impo... | true |
2b525a287d4d7a93103680c2a603c1981c77ac5e | Ruby | nmking22/monster_shop_2008_solo | /spec/features/merchant/discounts/edit_spec.rb | UTF-8 | 5,660 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe 'As a Merchant Employee, when I visit a discount edit page' do
before :each do
@batarang_emporium = Merchant.create(
name: "Batman's Batarang Emporium",
address: '123 Wayne Dr.',
city: 'Gotham',
state: 'IL',
zip: 80210
)
@batman = User.create!... | true |
fbb77f0d272833c9304c4c96d78f2e644e7ae301 | Ruby | jfredrickson/finerworks | /lib/finerworks/client.rb | UTF-8 | 4,803 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'finerworks/request'
require 'finerworks/response'
require 'finerworks/account'
require 'finerworks/print'
require 'finerworks/gallery'
require 'finerworks/image'
require 'finerworks/order'
require 'finerworks/order_details'
require 'finerworks/cart'
module FinerWorks
# The Client is the primary interface to... | true |
410f994d0d66c0b31d2c9e482a188dba041a1f8a | Ruby | ejstraband/Ruby | /learnToProgram/chapter8/favorites.rb | UTF-8 | 265 | 3.296875 | 3 | [] | no_license | favorites = []
puts '--------'
puts favorites
puts '--------'
favorites.push 'raindrops on roses'
favorites.push 'whiskey on kittens'
puts favorites[0]
puts favorites.last
puts favorites.length
puts '--------'
puts favorites.pop
puts favorites
puts favorites.length | true |
270fef38bd4698547c2307a17092ebe05ab7e379 | Ruby | tkusuki/tasklist-campuscode | /tarefa.rb | UTF-8 | 477 | 3.140625 | 3 | [] | no_license | class Tarefa
attr_reader :id, :feita
# attr_reader :descricao
attr_accessor :descricao
def initialize(id, descricao, feita = false)
@id = id
@descricao = descricao
@feita = feita
end
def marcar_feita()
@feita = true
end
def to_s()
string_feita = feita() ? "Sim" : "Não"
"- Tare... | true |
2d0e6ec32847716c1348d271aa81080719cb0b12 | Ruby | DianaLuciaRinconBl/Small_exercises | /easy4/ex_4.rb | UTF-8 | 1,368 | 4.65625 | 5 | [] | no_license | # input
# year (integer)
# output
# true or false
#
# before 1752 leap years were any year divisible by 4
# after 1752 leap years were any year divisible by 4 but
# if also divisible by a 100 then it also needs to be divisible by 400 to be a leap year.
#
# 1. check if the year argument is an integer greater than 1752
#... | true |
16e08f533b5b1e4225c9dc77fe2128aeb44ce426 | Ruby | bentrevor/ruby_ttt | /spec/console_input_spec.rb | UTF-8 | 434 | 2.734375 | 3 | [] | no_license | require 'spec_helper'
require 'console_input'
describe ConsoleInput do
let(:reader) { MockReader.new }
it "reads from stdin" do
reader.inputs = ["1\n", "2\n"]
input = ConsoleInput.new(reader)
input.get_int.should == 1
input.get_int.should == 2
end
it "prompts until it gets an int" do
re... | true |
1f1991dd041fd4505c7527ae396391fcf0c8f18c | Ruby | SesameSeeds/oo-ride-share | /lib/driver.rb | UTF-8 | 1,013 | 3.125 | 3 | [] | no_license | require 'csv'
require_relative 'trip'
module RideShare
class Driver
attr_reader :driver_id, :driver_name, :vin
def initialize driver_id, driver_name, vin
@driver_id = driver_id
@driver_name = driver_name
@vin = vin
raise ArgumentError.new("VIN is invalid.") if vin.length != 17
... | true |
3abd60f17a12a001bafa424c8a0b126aeaaa9a7a | Ruby | Tafby/oo-relationships-practice-seattle-web-career-012819 | /app/models/listings.rb | UTF-8 | 1,218 | 3.703125 | 4 | [] | no_license | class Listings
attr_accessor :city, :guests, :trips, :trip_count
@@all = []
def initialize(city)
@city = city
@guests = []
@trips = []
@trip_count = trip_count
@@all << self
end
def self.all
@@all
end
def self.find_all_by_city(city)
... | true |
08a601dea2b1fc78db649e99e0b2d19af6432012 | Ruby | RDJoseDeSouza/nivelamento-aluno | /10-exercicio-parte-2.rb | UTF-8 | 474 | 3.15625 | 3 | [] | no_license | # 2) Esse aqui é um desafio. Faça um código para obter esse resultado:
# *
# **
# ***
# ****
# *****
# ******
# *******
# ********
# *********
# **********
vezes = 1
numero = 1
while numero < 11
for espaco_em_branco in (1..9)
... | true |
949d28e43157ce6590630a9dd46c710488738f25 | Ruby | peterdk/adventOfCode2015 | /day21.rb | UTF-8 | 4,036 | 3.421875 | 3 | [] | no_license | class Item
attr_reader :type, :name, :cost, :damage, :armor
def initialize(type, name, cost, damage, armor)
@name = name
@cost = cost
@damage = damage
@armor = armor
@type = type
end
def to_s
"#{@type}: #{@name}\t#{@cost}\t#{@damage}\t#{@armor}"... | true |
c03ef22ee80a36b8285eac91a365235eba75d926 | Ruby | ajakate/buddy-guy | /run.rb | UTF-8 | 254 | 3.484375 | 3 | [] | no_license | module Buddy
CYCLE = ["friend","buddy","pal","guy"]
def self.print
puts "I'm not your #{CYCLE[rand(0..3)]}, #{CYCLE[rand(0..3)]}"
sleep 1
end
end
loop do
begin
Buddy.print
rescue Exception => e
puts "Hey! Stop it!"
end
end
| true |
769835fa2d5e6d3bd6bb158ec21488e54e2094ff | Ruby | pepabo-college/1st-pullrequest-question | /ryucheru/answer-00.rb | UTF-8 | 39 | 2.5625 | 3 | [] | no_license | str = "stressed"
str.reverse!
puts str
| true |
0cf228f63007b51f22854280f042d3ebe5a73398 | Ruby | eebbesen/minutes_maid | /vendor/cache/ruby/2.5.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp_connection.rb | UTF-8 | 2,045 | 3 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'mail/check_delivery_params'
module Mail
# == Sending Email with SMTP
#
# Mail allows you to send emails using an open SMTP connection. This is done by
# passing a created Net::SMTP object. This way we can get better performance to
# our local mail server by reducing ... | true |
4171fdaf948b037e697bb0fa9f260d1cdfcb28d1 | Ruby | instructure/inst-jobs | /spec/delayed/message_sending_spec.rb | UTF-8 | 3,332 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "spec_helper"
require "debug_inspector"
RSpec.describe Delayed::MessageSending do
before do
allow(Rails.env).to receive(:test?).and_return(true)
end
before(:all) do
# this has to be a "real" constant
class SpecClass # rubocop:disable RSpec/LeakyConstantDeclarat... | true |
5228dd20c846c2eeaa12f86bd3cb6d0b867d77c0 | Ruby | Geovo/codeeval | /moderate/array_absurdity/array_absurdity.rb | UTF-8 | 180 | 3.046875 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
line = line.split(/[\;\,]/).map {|n| n = n.to_i}
size = line.shift
x = 0
line.map {|el| x = el if line.count(el) > 1 }
puts x
end
| true |
160de41e5a5ca46f3ac91aa2e5d503f6dcc1bce9 | Ruby | aptible/aptible-cli | /lib/aptible/cli/formatter/keyed_list.rb | UTF-8 | 560 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Aptible
module CLI
module Formatter
class KeyedList < List
# KeyedList is a list of objects with one key that is more important
# than the others. Some renderers may opt to only display this key when
# rendering the list.
attr_reader :key
def initialize(key)
... | true |
ced689573f575201a04ce088ed6419f26a08fe09 | Ruby | srallen/ruby | /tic-tac-toe.rb | UTF-8 | 5,009 | 3.8125 | 4 | [] | no_license | class TicTacToe
def initialize
@cpu = "X"
@player = "O"
@board = { "c1" => " ", "e1" => " ", "c2" => " ",
"e2" => " ", "ct" => " ", "e3" => " ",
"c3" => " ", "e4" => " ", "c4" => " " }
@positions = @board.keys
@board_guide = " c1 | e1 | c2 \n-------------\n e2 | ct... | true |
391faaa9d5ba7a33090b7d1d287bbe30808469b4 | Ruby | montethinks/Concepts | /01_basics/exercise_5.rb | UTF-8 | 293 | 3.8125 | 4 | [] | no_license | #Outputs factorial of the numbers 5, 6, 7, 8.
five_factorial = 5 * 4 * 3 * 2 * 1
six_factorial = 6 * 5 * 4 * 3 * 2 * 1
seven_factorial = 7 * 6 * 5 * 4 * 3 * 2 * 1
eight_factorial = 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1
puts five_factorial
puts six_factorial
puts seven_factorial
puts eight_factorial | true |
cc45c4f37bcdeccf38c12d5d71d5bb1149ae1f48 | Ruby | blsalcido/phase_0_unit_3 | /week_7/7_gps3.1/our_solution.rb | UTF-8 | 1,259 | 4.28125 | 4 | [] | no_license | # U3.W7: Build an Electronic Grocery List!
# Your full names:
# 1. Bridgette Salcido
# 2. Jen Tutu
# User Stories (As many as you want. Delete the statements you don't need)
# As a user, I want to create a list of products to buy
# As a user, I want to be able to add items to the list
# As a user, I want to be abl... | true |
e01eb8ab5f77baf311fc7e5745b4fb7b3c504410 | Ruby | sethkrasnianski/shenanigans | /lib/shenanigans/object/display.rb | UTF-8 | 380 | 3.5 | 4 | [
"MIT"
] | permissive | class Object
# Outputs the object and also returns it.
# Will use <tt>puts</tt> if <tt>new_line</tt> is <tt>true</tt> and
# <tt>print</tt> otherwise.
# "foo".display
# foo
# #=> "foo"
#
# "foo".display(false)
# foo#=> "foo"
def display(new_line = true)
m = new_line ? :puts : :print
... | true |
f3fd94aacf83ca20c0c3afe8d8697e54e4673350 | Ruby | kjhenner/prosody | /lib/prosody/poem.rb | UTF-8 | 3,650 | 2.890625 | 3 | [] | no_license | class Poem
def initialize(graph, line_length, scheme)
@line_length = line_length
@scheme = scheme
@rhymes = {}
@line_count = 0
@graph = graph
@starts = get_starts
@path = [init_path]
@meter = '01'
end
def to_s
"#{@line_length}, #{@scheme}"
end
def init_path
{
... | true |
1f3d2b69592bdada4cd0ccc259d74a01b58af971 | Ruby | nanakenashi/moz_api_caller | /lib/api.rb | UTF-8 | 1,551 | 2.828125 | 3 | [] | no_license | require 'base64'
require 'bigdecimal'
require 'json'
require 'openssl'
require 'open-uri'
require 'uri'
class Api
ENDPOINT = 'https://lsapi.seomoz.com/linkscape/url-metrics/'
COLS = 32 + # External Equity Links
34359738368 + # Page Authority
68719476736 # Domain Authority
... | true |
049fa82997af7786c77fca2c626033367cb374bf | Ruby | jencoleman/my-first-repository | /array/mutate.rb | UTF-8 | 196 | 3.421875 | 3 | [] | no_license | #testing
def mutate(arr)
arr.pop
end
def not_mutate(arr)
puts arr.select { |i| i > 3 }
end
a = [1, 2, 3, 4, 5, 6]
not_mutate(a)
["b", 1], ["b", 2]
names[names.index('margaret')] = 'jody'
| true |
86de49fc0961202974ee2fb941cddc099dc6418b | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/3d712df1a56d4e5680c7d97fffef5355.rb | UTF-8 | 622 | 3.703125 | 4 | [] | no_license | class Bob
def hey(message)
if silence?(message)
answer(:silence)
elsif shouting?(message)
answer(:shouting)
elsif asking?(message)
answer(:asking)
else
answer(:talking)
end
end
private
def silence?(message)
message.to_s.strip.empty?
end
def shouting?(messa... | true |
f989666e775c3f10237ecf817904c65e0fb540b9 | Ruby | andre-schilipack/tostranslate | /app/models/translation_file.rb | UTF-8 | 649 | 2.703125 | 3 | [
"MIT"
] | permissive | class TranslationFile < ActiveRecord::Base
has_many :translation_lines
attr_accessor :file
after_create :create_translation_lines
def percentage
self.translation_lines.where(translated: true).count.to_f / self.translation_lines.count.to_f * 100
end
private
def create_translation_lines
require... | true |
808fe44baf4207ffd969a4615468596a09fb2d60 | Ruby | sdmalek44/algorithm_practice | /tests/two_d_array_test.rb | UTF-8 | 438 | 3 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/two_d_array.rb'
class TwoDArrayTest < Minitest::Test
def test_it_gets_highest_hourglass
arr = [[-9, -9, -9, 1, 1, 1],
[0, -9, 0, 4, 3, 2],
[-9, -9, -9, 1, 2, 3],
[0, 0, 8, 6, 6, 0],
[0, 0, 0, -... | true |
3468d6470a7339f5041a2933b4d6aa13bb83cc3e | Ruby | markdefg/maze-runner | /lib/features/steps/request_assertion_steps.rb | UTF-8 | 3,614 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'test/unit'
require 'minitest'
require 'open-uri'
require 'json'
require 'cgi'
require_relative '../../maze/wait'
include Test::Unit::Assertions
# @!group Request assertion steps
def assert_received_requests(request_count, list, list_name)
timeout = Maze.config.receive_reques... | true |
246e52e5c817c3cfcbf743cad9feed8925cef4f8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/2f4b2a9b58014e159fd73eb85b51b6a5.rb | UTF-8 | 1,013 | 3.484375 | 3 | [] | no_license | class Complement
def initialize(params)
@type = :dna if params[:dna]
@type = :rna if params[:rna]
@string = params[@type]
end
def dna?
@type == :dna
end
def rna?
@type == :rna
end
def dna_to_rna_map
{
'G' => 'C',
'C' => 'G',
'T' => 'A',
'A' => 'U'
}
... | true |
34ff9f57561fd2f95e79552afc49a586391382e1 | Ruby | cynthiak/wonton-analytics | /app/helpers/expenses_helper.rb | UTF-8 | 3,228 | 3.03125 | 3 | [] | no_license | module ExpensesHelper
# Expenses ##############
def get_expenses_array(expense_type=nil, start_date=nil, end_date=nil)
if start_date == nil
start_date = Expense.all.order("date").first.date
end
if end_date == nil
end_date = Expense.all.order("date").last.date
end
if expense_type
... | true |
4daa644718e8d74b004734b59436d7c808856561 | Ruby | njruby/practice | /problems/practice2.rb | UTF-8 | 301 | 3.53125 | 4 | [] | no_license | # Refactor the below methods into a single method
def print_string_class(string)
puts "#{string} is of class #{string.class}"
end
def print_array_class(array)
puts "#{array} is of class #{array.class}"
end
def print_integer_class(integer)
puts "#{integer} is of class #{integer.class}"
end
| true |
2b831d252ef686fb836eb169664923c3dec17bde | Ruby | sleepingkingstudios/bronze | /lib/bronze/transforms/entities/normalize_transform.rb | UTF-8 | 1,680 | 2.84375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'bronze/transform'
require 'bronze/transforms/entities'
module Bronze::Transforms::Entities
# Transform class that maps an entity to a normal representation.
class NormalizeTransform < Bronze::Transform
# @param [Class] entity_class The entity class to normalize.
# @p... | true |
1aebb143795a697014ebb306355637d78ae7dd24 | Ruby | malachispencer/dependency-injection | /spec/exercise_4_spec.rb | UTF-8 | 1,072 | 3.765625 | 4 | [] | no_license | =begin
Makers. 05/11/20. Here I wrote a test for the Greeter class, which doesn't use the actual Kernel module.
1) We first created a simple kernel double.
2) We then create an instance of Greeter, where we pass in the kernel double, this double will be @kernel in greeter.
3) Inside the it block, we stub the gets metho... | true |
62e239245d855151e90e5e7bd37b8932df432c6c | Ruby | dhamilt9/sinatra-integrating-models-walkthrough-nyc-web-111918 | /app.rb | UTF-8 | 1,004 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
require_relative 'models/text_analyzer.rb'
require 'pry'
class App < Sinatra::Base
get '/' do
erb :index
end
post '/' do
@text_from_user = params[:user_text]
@word_count=@text_from_user.split(" ").count
@vowel_count=0
@consenant_count=0
@letter_hash=... | true |
288edd9f2bb5e0ed0160976c00012cc49813d1b3 | Ruby | sinharahul/solr | /ferret/format.rb | UTF-8 | 128 | 2.625 | 3 | [] | no_license | File.open("index.rb").readlines.each do |line|
if line =~ /(\d)+/
line = line.sub(/(\d)+/,"")
puts line
end
end
| true |
f693490ce382e7f54330f761bc6159a3c4082c50 | Ruby | aphilippartd/zenps-ruby | /lib/zenps/client.rb | UTF-8 | 1,640 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'net/http'
require 'uri'
require 'json'
module Zenps
# Api client for Zenps
class Client
def initialize
check_configuration
end
def call(options = {})
@options = options
perform_request
expose_response
end
private
attr_reader :options, :response
def c... | true |
80962791b0f5450c0ad4078f477c421a3fdc365f | Ruby | FeminismIsAwesome/California-Scraper | /lib/models/voting_history_scraper.rb | UTF-8 | 2,568 | 2.578125 | 3 | [] | no_license | class VotingHistoryScraper
def self.get_voting_history_for(content)
content = content.force_encoding("ISO-8859-1")
ayes = getAyesFor(content)
noes = getNoesFor(content)
absents = getAbsentsFor(content)
author = getAuthorFor(content)
topic = getTopicFor(content)
date = getDateFor(content)
... | true |
94f1659eedf63915faeaa753618d1b9f7154f214 | Ruby | StlMaris123/active-jobs | /spec/models/article_spec.rb | UTF-8 | 2,891 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe Article do
let(:article) { Fabricate(:article) }
[:title, :body].each do |attribute|
it "is not valid without a #{attribute}" do
article.update_attributes(attribute => nil)
expect(subject).to_not be_valid
end
end
context "when it has invalid attributes" do
... | true |
232ecc52b4b87b077da8a5078eede155975bc169 | Ruby | SampsonCrowley/assignment_file_ops_sprint | /lib/dictionary.rb | UTF-8 | 1,061 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'dictionary_loader'
require_relative 'dictionary_searcher'
require_relative 'dictionary_ui'
require_relative 'results_saver'
class Dictionary
attr_reader :words, :searcher, :ui, :writer
def initialize(dict = "dictionary.txt")
@words = DictionaryLoader.load(dict)
@searc... | true |
8b8e23556d1d1af915b4aa60a4cf511c4d532b12 | Ruby | kenta-s/atcoder | /virtual_contest/20200628/caddi2018b_a.rb | UTF-8 | 37 | 2.78125 | 3 | [] | no_license | n = gets.to_i
puts n.to_s.count('2')
| true |
a35af0110f652f6bef0e8dc633c204f7b3ae68b9 | Ruby | khonowitz/rad_scheduler | /app/services/schedule/importer.rb | UTF-8 | 760 | 2.546875 | 3 | [] | no_license | class Schedule::Importer
def perform(spreadsheet_id = "1Ox-aFv-KTMFACh0WRhEnShlSlLL4rcoinN6GhAs_nDA")
@spreadsheet = fetch_spreadsheet(spreadsheet_id)
process_schedule
end
private
def fetch_spreadsheet(spreadsheet_id)
google_drive = GoogleDrive.saved_session(Rails.root.join('... | true |
119056e0fc0a0190ab3d8e3d26a626da195d056d | Ruby | Kahaan/Daily-Projects | /W2D1/chess/board.rb | UTF-8 | 2,000 | 3.5 | 4 | [] | no_license | require 'byebug'
require_relative 'errors'
require_relative 'piece'
require_relative 'display'
class Board
attr_reader :grid
PIECES = {
[0,0] => Rook
}
def initialize
# wboard = Array.new(2) {Array.new(8) {Piece.new(:w)}}
# nboard = Array.new(4) {Array.new(8) {NullPiece.instance}}
# bboard =... | true |
9c00701ce2af6305cafa162240dfac7347305b99 | Ruby | binarycleric/berlin_clock | /spec/clock_test_cases.rb | UTF-8 | 870 | 2.609375 | 3 | [] | no_license | require "clock"
describe Clock, "#display" do
it "tests display 00:00:00" do
clock = Clock.new
expected = "Y\n" +
"OOOO\n" +
"OOOO\n" +
"OOOOOOOOOOO\n" +
"OOOO"
clock.display('00:00:00').should == expected
end
it "tests display 13:17:01" do
clock = Clock.new
expected ... | true |
1b5bbca4e37087797b1b7f6be49f3e4e1b23e7f2 | Ruby | kenta-s/atcoder | /virtual_contest/20200628/arc080_b.rb | UTF-8 | 1,128 | 2.875 | 3 | [] | no_license | h, w = gets.split.map(&:to_i)
n = gets.to_i
as = gets.split.map(&:to_i)
table = Array.new(h, Array.new(w))
visited = Array.new(h, Array.new(w))
visited = {}
if w == 1
dir = 'down'
else
dir = 'right'
end
idx = 0
i = 0
j = 0
visited[0] = {}
visited[0][0] = 0
as[idx] -= 1
while (idx != n-1) || as[idx] != 0
visited... | true |
893584d19620e98b03bfc45a80e430aadfde002d | Ruby | yaauie/PFTT | /lib/util/column_manager.rb | UTF-8 | 869 | 2.71875 | 3 | [
"MIT",
"MS-PL"
] | permissive |
module Util
module ColumnManager
class Base
# current row number. see #add_row, option hash key :row_number
attr_reader :row_num
def initialize
@row_num = 0
end
def to_s
render
end
def add_row(*cells)
# adds a row of cells
#
# each cell ... | true |
07ff3a9bde9dceeadfa8db98e3949a35a894d38d | Ruby | YujohnNattrass/ruby_challenges | /advanced_1/saddle_points.rb | UTF-8 | 554 | 3.5 | 4 | [] | no_license | class Matrix
def initialize(string)
@matrix = string.split("\n").map { |row_string| row_string.split(" ").map(&:to_i) }
end
def rows
@matrix
end
def columns
@matrix.transpose
end
def saddle_points
saddle_points_coordinates = []
@matrix.each_with_index do |row, row_index|
row.... | true |
6904217275ae427229d5fb846839d35b889b2974 | Ruby | cseiter/Phase3SQLLibrary | /lib/querying.rb | UTF-8 | 2,213 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"select books.title,books.year from books where books.series_id='1' order by books.year";
end
def select_name_and_motto_of_char_with_longest_motto
"select characters.name,characters.motto from characters order by length(characters.motto) desc limit 1"... | true |
3bede1ea13f8c2b7b284ac86d9d616654f00d1ec | Ruby | dvsocean/rubyStuff | /fall_code/puts_count.rb | UTF-8 | 310 | 3.15625 | 3 | [] | no_license | name = 'Boris'
job = 'Engineer is the song that never ends'
life = 'great'
power = 'attorney'
p name, job, life.class, power
multi_line_string = <<DMLS
thjis is the sonf thay never ends, yes it gfors
on an d on my frind
some people started singing it not knowing what it was
DMLS
puts multi_line_string | true |
fc8712d68c000ffa92c3eb4b91a00c1f8780ff3d | Ruby | PierreNicoletti/shipup-challenge | /level2/repositories/package_repository.rb | UTF-8 | 453 | 3.046875 | 3 | [] | no_license | require 'json'
require_relative '../models/package'
class PackageRepository
def initialize(input_file_path)
@packages = []
serialized_data = File.read(input_file_path)
JSON.parse(serialized_data)["packages"].each do |package|
@packages << Package.new(id: package["id"], carrier: package["carrier"],... | true |
57137ff27bd15e868d814a428c65ff4f37074ad1 | Ruby | xuhui-github/rubydailyprogramming | /proc/instace_eval.rb | UTF-8 | 391 | 3.0625 | 3 | [] | no_license | class User
end
User.instance_eval do
@Female="Female of User"
def gender
:female
end
def self.Female
@Female
end
def self.setFemale(female)
@Female=female
end
end
puts User.gender
u=User.new
u.instance_eval do
def gender
"female just"
end
end
puts u.gender
puts User.Female
Us... | true |
f66cebe3bf3fc5b2c0abad9d8f63757dc116d2db | Ruby | flaviogf/courses | /geral/livro_entendendo_algoritmos/binary_search.rb | UTF-8 | 567 | 3.828125 | 4 | [
"MIT"
] | permissive | def main()
values = load()
result = binary_search(values, 9773)
puts result
end
def load()
values = []
IO.foreach("sorted.txt") do |line|
values.push line.to_i
end
return values
end
def binary_search(values, target)
left = 0
right = values.size - 1
while left ... | true |
7e711a52edc0d3ae150f3619e323e99dad617468 | Ruby | danielpselph/enigma | /test/shift_test.rb | UTF-8 | 1,961 | 3.09375 | 3 | [] | no_license | require_relative 'test_helper'
require 'date'
require './lib/shift'
class ShiftTest < Minitest::Test
def setup
@shift = Shift.new
end
def test_it_exists
assert_instance_of Shift, @shift
end
def test_it_has_attributes
assert_equal String, @shift.key.class
assert_equal 5, @shift.key.length
... | true |
1f22c0c75a7773bcad192c8e0b9344ffbc9d0e56 | Ruby | joshheath/day1challenges | /challenge2.rb | UTF-8 | 633 | 4.59375 | 5 | [] | no_license | hash = { a: 1, b: 2 }
# adding one to each hash value
newhash = {}
hash.each do |key, value|
newhash[key] = hash[key] + 1
end
puts newhash
#zipped values, sorted and turned into a hash
hash2 = { a: 2, b: 5, c: 1 }
hash2values = hash2.values.sort
hash2keys = hash2.keys
print Hash[hash2keys.zip(hash2values)]
#conver... | true |
28bd6d9d02a351cdfac1aa450ac1c6b85e8b86b4 | Ruby | 3lsilver/restful_clicktocall | /web/run_me.rb | UTF-8 | 2,283 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'sinatra' # Get with "gem install sinatra"
require 'restful_adhearsion'
require 'pp'
#Create our Adhearsion object connected to the RESTful API of Adhearsion
Adhearsion = RESTfulAdhearsion.new(:host => "localhost",
:port => 5000,
... | true |
bd3b0d88242d11bf808c418c01ba5e62c06fdb28 | Ruby | janpadrta/invoicing | /app/modules/utilities.rb | UTF-8 | 421 | 3 | 3 | [] | no_license | module Utilities
def self.months_range(klass, column)
date_from = klass.minimum(column).to_date
date_to = klass.maximum(column).to_date
date_range = date_from..date_to
date_range.map { |d| Date.new(d.year, d.month, 1) }.uniq
end
def self.virtual_sum(collection, v_attr) # Totals the virtual a... | true |
1e7f9bb910be8ef5c38b92f6614970fb8fb0d162 | Ruby | kagflores/oxford-comma-v-000 | /lib/oxford_comma.rb | UTF-8 | 373 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.size == 1
comma_free = array.join
return comma_free
elsif array.size == 2
and_join = array.join (" and ")
return and_join
else
last_element = array.pop
comma_join = array.join (", ")
last_element = ", and #{last_element}"
comma_and_join = comma_join... | true |
156c30cbb13114117e3c61c0b848d9af1a09bb74 | Ruby | Himuravidal/E6CP1A1 | /3 ciclos anidados/ejercicio1.rb | UTF-8 | 253 | 3.3125 | 3 | [] | no_license | =begin
Se pide imprimir la secuencia numérica, de la siguiente forma:
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16
=end
matrix = [1, 2, 3, 4]
(0..4).each do |i|
puts "#{matrix[i]} #{matrix[i] * 2} #{matrix[i] * 3} #{matrix[i] * 4}"
end
| true |
c9fa5d70537e86788ae0fa35fa66c7a63cf669cc | Ruby | chastell/talks | /src-2011/code/grid-faster.rb | UTF-8 | 701 | 3.5625 | 4 | [] | no_license | require 'inline'
class Integer
def popcount_to_s
to_s(2).count '1'
end
def popcount_bitshift
count = 0
number = self
while number > 0
number &= number - 1
count += 1
end
count
end
inline do |builder|
builder.c '
int popcount_builtin() {
return __builti... | true |
8c710da8025401459e4e080dd81b2937c33c8958 | Ruby | JanBussieck/simulation-game | /app/controllers/simulation_controller.rb | UTF-8 | 2,448 | 2.640625 | 3 | [] | no_license | class SimulationController < ApplicationController
def simulate
update_game_data
remove_sold_resources
update_credit
adjust_market_price
simulate_technical
simulate_disease
simulate_weather
redirect_to root_path
end
def update_game_data
game.period += 1
game.set_current_i... | true |
bae28dd0f6ba3b50d8bab52476404d73f3fa7e33 | Ruby | mguymon/obfuscate | /lib/obfuscate.rb | UTF-8 | 2,505 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with this
# work for additional information regarding copyright ownership. The ASF
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use t... | true |
91cf6e90f8ee7ff26e6b2815250b4e465bcb76f8 | Ruby | Ahmed13061988/my-each-online-web-pt-120919 | /my_each.rb | UTF-8 | 68 | 2.90625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(collection)
my_each(collection) do |i|
puts i
end | true |
502685af3a66c74cfcb82bf9ced38c6588ae1512 | Ruby | victoralvesf/ruby-study | /capybara/spec/key_spec.rb | UTF-8 | 555 | 2.59375 | 3 | [] | no_license | describe 'Keyboard', :keyboard do
before(:each) do
visit 'https://training-wheels-protocol.herokuapp.com/key_presses'
end
def check_letter(key)
find('#campo-id').send_keys key
expect(page).to have_content 'You entered: ' + key.to_s.upcase
end
it 'enviando teclas' do
keys = %i[tab escape s... | true |
8e9fe4cc2dc01b43486a50e572c5a4246bd145cd | Ruby | turingschool-projects/keevah | /db/seeds.rb | UTF-8 | 3,062 | 2.90625 | 3 | [] | no_license | class Seed
def call
generate_tenants(200000)
generate_users(30000)
generate_categories(15)
generate_loan_requests(500000)
generate_loans(50000)
end
def generate_users(quantity)
puts "Creating #{quantity} users"
quantity.times do |n|
first_name = Faker::Name.name
username ... | true |
e56eae0b05e5102f8bbcf6c8450278ffab15815d | Ruby | AcChrome/math_game | /question.rb | UTF-8 | 328 | 3.859375 | 4 | [] | no_license | class Question
attr_accessor :num1, :num2, :sum
def initialize()
self.num1 = rand(1..20)
self.num2 = rand(1..20)
self.sum = self.num1 + self.num2
end
def question()
puts "What does #{num1} plus #{num2} equal?\n"
end
def answer(ans)
if ans == sum
true
else false
end
e... | true |
3ceb733cd0fb5c89b2976e9f18e8408a44fb60b8 | Ruby | Angelorup/Kattis | /Problems/difficulty_1/symmetric_order.rb | UTF-8 | 180 | 3.484375 | 3 | [] | no_license | def symm
input = gets.to_i
asc_arr = []
desc_arr = []
names_arr = []
for i in (1..input)
names = gets.chomp.to_s
names_arr << names
end
puts names_arr.reverse
end
symm
| true |
a3d96275f0e2f82ba8940353efb7d98d7d65e7f8 | Ruby | aakim0907/AppAcademy | /w2d3/towers_of_hanoi/lib/tower_of_hanoi.rb | UTF-8 | 700 | 3.71875 | 4 | [] | no_license | class Tower
attr_reader :grid
def initialize(grid = [[3,2,1],[],[]])
@grid = grid
end
def move(move_pos)
raise 'invalid argument' unless move_pos.length == 2
start_disc = @grid[move_pos[0]]
end_disc = @grid[move_pos[1]]
if start_disc.last > end_disc.last && !end_disc.empty?
raise 'No... | true |
8de2584449ff88b361a106553de329a5dde3eb67 | Ruby | r-gamedev/lita-gamedev-spam | /lib/common/messaging/reddit/modmail.rb | UTF-8 | 1,747 | 2.84375 | 3 | [] | no_license | require 'common/messaging/message'
require 'htmlentities'
module Lemtzas
module Common
module Messaging
module Reddit
# Represents a modmail message
class Modmail < Message
attr_accessor :body,
:name,
:id,
:au... | true |
33c53c11eff143508adf13f11de84e3937d589fe | Ruby | zeroeth/net_rogo | /male_marten.rb | UTF-8 | 1,943 | 3.015625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/marten'
require 'logger'
$log = Logger.new("marten_events.log")
class MaleMarten < Marten
def tick
raise 'spawn me' if spawned?
go
end
def go
actual_distance = 0
forage
die_if_starved
metabolize
self.age += 1
if age > (18 * 365)
$log.in... | true |
8c086f7803345ce0bf5a0c505d258cc425a048f1 | Ruby | jb2718/ls-backend | /101/101_3/exercises_m1/q1.rb | UTF-8 | 61 | 2.859375 | 3 | [] | no_license | 10.times{ |num| puts "The Flintstones Rock!".rjust(21 + num)} | true |
f2e3b018bc6b9019f7d582ef4fec5b33bf4f70f2 | Ruby | 8bithero/predict-backend | /app/services/prediction_service.rb | UTF-8 | 1,624 | 3.09375 | 3 | [] | no_license | class PredictionService
attr_reader :prediction_term
def initialize(prediction_term=Rails.configuration.x.prediction_word)
@prediction_term = prediction_term
@errors = ErrorHash.new
@value = nil
end
def call(team_string:)
clear!
validate_team_string_format(team_string)
return result un... | true |
d9a5a92d3c9a27b7cfce9c3f50dfe13a72faa1ca | Ruby | nodog/povstick-bmp-generator | /movie-matrixle.rb | UTF-8 | 1,326 | 3.140625 | 3 | [
"MIT"
] | permissive | #
# programming
# nodog
# 2014-03-03
#
# movie-matrixle.rb
# is a generater of a 1D movie (a 2D bmp file) for a 120x1 RGB LED array.
# coding: binary
require "./bmp_writer.rb"
MOVIENAME = "matrixle"
NLEDS = 120
RAMPINLENGTH = 128
RAMPOUTLENGTH = 5048
MAXBRIGHT = 192
NT = 16000
bmp = BMP::Writer.new(NLEDS, NT)
# ... | true |
12b901a1cd7f2411e93877b3fdf9d7f7cbe6f4cd | Ruby | W-Mills/ruby-exercises | /Small Problems/Medium/matching_parenthesis.rb | UTF-8 | 2,789 | 4.34375 | 4 | [] | no_license | require 'pry'
# Matching Parentheses?
# Write a method that takes a string as argument, and returns true if all parentheses in the string are properly balanced, false otherwise. To be properly balanced, parentheses must occur in matching '(' and ')' pairs.
# Problem: Write a method that takes a string as an argument a... | true |
1c5b2ef570cb7ac74326a6461c50f3fcdcd6ff89 | Ruby | SebastianOsinski/AdventOfCode2016 | /Day 5/day5.rb | UTF-8 | 663 | 3.1875 | 3 | [] | no_license | require 'digest/md5'
door_id = 'ojvtpuvg'
md5 = Digest::MD5.new
index = 0
password = ''
while password.length < 8
digest = md5.hexdigest(door_id + index.to_s)
password += digest[5] if digest.start_with?('00000')
index += 1
end
puts password
# second part
password = Array.new(8)
known_chars_count = 0
inde... | true |
38e3ae4211750e4e84ddf69ddd93563dcc7b6d39 | Ruby | substars/trinidad | /lib/trinidad/helpers.rb | UTF-8 | 2,531 | 2.796875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Trinidad
module Helpers
# @private
@@silence = nil
# Should we be silent - no warnings will be printed.
def self.silence?; @@silence; end
# Silence ! (... or I kill you)
def self.silence!; @@silence = true; end
# Print a warning (using `Kernel.warn`).
def self.warn(msg)
... | true |
9ba04f853eb177ba016b8a04f99f5930f052e12c | Ruby | Altovate/OpenTiger | /app/services/custom_landing_page/markdown_helper.rb | UTF-8 | 2,253 | 2.625 | 3 | [
"MIT"
] | permissive | module CustomLandingPage
# Limited HTML Markdown Renderer extend the default
# Redcarpet HTML rendered, but it ignores certain Markdown block.
#
# See the list of IGNORED_BLOCKS to see which blocks are ignored.
# The commented blocks in the list are available.
#
class LimitedHTMLMarkdownRenderer < Redcar... | true |
a04aceb40c14af8c251b882ddebf8866df3725c0 | Ruby | p2rdw/viziwiki | /lib/viziwiki/mediawiki/parser.rb | UTF-8 | 7,586 | 2.84375 | 3 | [
"MIT"
] | permissive |
require 'viziwiki/context'
require 'cgi'
class Viziwiki::Mediawiki::Parser
def log
::Viziwiki::log
end
# normalize text (fact to parser)
@@section_elements = %w(h1 h2 h3 h4 h5 h6 h7 h8)
@@end_paragraph_elements = %w(div p li ol ul) + @@section_elements
@@end_sentence_elements = @@end_paragraph_el... | true |
16e9ef11ccc2ad885d13c062944f596062e71ac3 | Ruby | lrotschy/Ruby-Exercises | /Basics/easy_4_10.rb | UTF-8 | 1,170 | 4.28125 | 4 | [] | no_license | # easy_4_10.rb
=begin
input: a signed integer (-321, 567)
output: a string version of same with sign ('-321', '+567')
if int > 0 prepend '+'
else
int = int * -1
prepend '-'
=end
DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
def integer_to_string(int)
new_num = ''
loop do
remainder, str = int.... | true |
8dc847879cf12878ac662064a720041fe0045c6d | Ruby | undees/yesbut | /2008-11-29/quine.rb | UTF-8 | 129 | 2.65625 | 3 | [] | no_license | require 'base64'
class String
def unscramble
Base64.decode64 self
end
end
s = "cmVxdWlyZSAnYmFzZTY0JwoKY2xhc3MgU3RyaW5nCiAgZGVmIHVuc2NyYW1i
bGUKICAgIEJhc2U2NC5kZWNvZGU2NCBzZWxmCiAgZW5kCmVuZAoKcyA9ICIl
cyIKCnB1dHMgcy51bnNjcmFtYmxlLnN1YigiJXMiLCBzKQo=
"
puts s.unscramble.sub("%s", s)
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.