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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
af7b38cc79187360fe177b2e18d2f8b9423e1d8f | Ruby | QPC-WORLDWIDE/tem_ruby | /lib/tem/sec_exec_error.rb | UTF-8 | 2,205 | 2.8125 | 3 | [
"MIT"
] | permissive | # Raised when executing a SEC.
class Tem::SecExecError < StandardError
attr_reader :line_info
attr_reader :buffer_state, :key_state
attr_reader :trace
def initialize(secpack, tem_trace, buffer_state, key_state)
super 'SEC execution failed on the TEM'
if tem_trace
if tem_trace[:ip]
... | true |
93e73c125b34272a08f92abd60386bab9e702ad6 | Ruby | bjacobson26/project3 | /app/models/user.rb | UTF-8 | 986 | 2.625 | 3 | [] | no_license | require 'bcrypt' #this must be at the top of the file
class User < ActiveRecord::Base
attr_accessor :reset_token
validates_presence_of :first_name
validates_presence_of :last_name
has_secure_password
validates_uniqueness_of :email
validates_presence_of :email
has_many :orders
# Sets the password reset a... | true |
34fbbfd7f9908581f00b8e921fc90501951827b3 | Ruby | mike590/Polly | /parses/combineparses.rb | UTF-8 | 980 | 3.109375 | 3 | [] | no_license | require 'json'
require 'pry'
f = File.read("parses/sixthparsecombined.json")
first_list = JSON.parse(f)["list"]
f = File.read("parses/seventhparseraw.json")
second_list = JSON.parse(f)["list"]
comb_list = []
dup_list = []
first_list.each do |k|
word = k["word"]
temp = k
second_list.each_with_index do |j, i|
... | true |
eb170225702f1bd2958eaadea36591eb3e81a7ff | Ruby | wbschlosser/learningRuby | /ex15thru20/e16ReadingWriting.rb | UTF-8 | 910 | 4.15625 | 4 | [] | no_license | # close - closes file (file -> save)
# read - reads contents of the file, can assign result to variable
# readline - reads one line of a file
# truncate - empties file
# write('stuff') - writes "stuff" to the file
# Write takes parameter of a string to write to the file
fn = ARGV.first
puts """
We're going to erase #{... | true |
579556de72ac0ba1122a1334d6b7ad38d4de4ac9 | Ruby | mgreg90/playwright-cli-old | /lib/playwright/cli/utils/display.rb | UTF-8 | 1,775 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'playwright/cli/utils/util'
module Playwright
class CLI < Hanami::CLI
module Utils
module Display
def display
@display ||= Display.new
end
class Display < Util
InvalidPrintMethod = Class.new StandardError
VALID_PRINT_METHODS = [:p, :puts, :pr... | true |
a3986345ebd54f5f0742290fa77a38afc7126f93 | Ruby | DYDamaschke/Launch_School | /exercises_ruby_basics/variable_scope/what_value5.rb | UTF-8 | 180 | 3.75 | 4 | [] | no_license | a = "Xyzzy"
def my_value(b)
b = 'yzzyX'
end
my_value(a)
puts a
# 'Xyzzy' because while b first references the 'a' string, assignment has changed
# it to point to a NEW string. | true |
f9d5ef0f0a9df402ba0d6ab3f868c23a53a60997 | Ruby | PeoneEr/nmax | /lib/nmax.rb | UTF-8 | 552 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'nmax/version'
module Nmax
class Generator
def self.sample_data
File.open('sample_data', 'w+') do |file|
1000.times do
arr = []
r = Random.new
1000.times do
arr << r.rand(100_000)
end
file.write(arr.join(' '))
end
... | true |
82de3f0ea898f710a7bb6cabb7d131c164e84dbc | Ruby | kjellm/shellout | /spec/shellout/table_spec.rb | UTF-8 | 3,027 | 2.953125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'stringio'
require 'shellout'
describe Shellout::Table do
include Shellout
before(:each) do
@out = StringIO.new
end
describe 'when no parameters' do
it 'should not print anything' do
Table().print(@out)
@out.string.should == ''
end
end
describe 'when... | true |
ac3cf7772d3685b2e62d329e92204af58ec56123 | Ruby | martinpoljak/bit-packer | /lib/bit-packer.rb | UTF-8 | 5,439 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
require "set"
class BitPacker
##
# Holds types index.
#
TYPES = Set::new [
:number,
:boolean
]
##
# Indicates size of one byte.
#
BYTESIZE = 8
##
# Holds resultant d... | true |
47aabfdb2ca6d520493bd787aafd86e756a69cfc | Ruby | densonclan/pinpoint | /app/models/postcode_sector.rb | UTF-8 | 701 | 2.640625 | 3 | [] | no_license | class PostcodeSector < ActiveRecord::Base
validates_presence_of :area, :district, :sector, :residential, :business
validates_length_of :area, maximum: 2
validates_length_of :zone, maximum: 2
before_validation :set_defaults
scope :ordered, order(:area, :district, :sector) # for now
scope :search, lambda ... | true |
21188c4ac53cbdc8f4ccc98e6408ecd925322754 | Ruby | Froz10/RubyRush | /Lesson6/app1.rb | UTF-8 | 135 | 3.40625 | 3 | [] | no_license |
arr1 = [1, 2, 3, 4, 5]
puts arr1.inspect
arr2 = arr1.reverse
puts arr2.inspect
puts arr1.inspect
arr1.reverse!
puts arr1.inspect | true |
9edbc103a596780dabf65ac3087de974b0ec09cb | Ruby | robsyme/bioruby-chado | /lib/bio/db/chado/general.rb | UTF-8 | 2,241 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Bio
module Chado
# Classes in this namespace correspond to tables and views in the
# Chado General module.
module General
# A database authority. Typical databases in bioinformatics are
# FlyBase, GO, UniProt, NCBI, MGI, etc. The authority is
# generally known by this short... | true |
7931b0eb512c2775fe05f93874f6eeba98679ba5 | Ruby | Rpascar1/coral_getter | /coral_getter/lib/coral_getter/end/end_class.rb | UTF-8 | 52,316 | 2.546875 | 3 | [
"MIT"
] | permissive | class Ending
def initialize
@@skull1
@@skull2
@@skull3
@@skull4
@@skull5
@@skull6
@@skull7
@@skull8
@@skull9
@@skull10
end
def ending_secret
heads = [@@skull1,@@skull2,@@skull3,@@skull4,@@skull5,@@skull6,@@skull7,@@skull8,@@skull9,@@skull10]
3.times do
i = 1
whil... | true |
6804dfbf161386e78f83fa9ae4a3755352a05890 | Ruby | puppetize/infrastructure | /modules/site/templates/bacula/app_backup/backup.rb.erb | UTF-8 | 2,645 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'yaml'
require 'bacula/console'
class BaculaAppBackup < OptionParser
DEFAULT_CONFIG_FILE = "/etc/bacula/<%= @app_name %>.yaml"
def initialize
super(nil, 16, '')
self.banner = "Usage: #{program_name} [options] [<client>]"
self.separator <<-EOS.gsub(/^ ... | true |
83517af0b71544c357d85d46522adf3bd4e85604 | Ruby | kaylawoodbury/code_wars | /ruby/7KYU/beginner_series_3_sum_of_numbers.rb | UTF-8 | 385 | 3.8125 | 4 | [] | no_license | # resource: http://flats.github.io/blog/2015/12/02/getting-to-know-rubys-map-and-reduce/
# Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b.
# Note: a and b are not ordered!
def get_su... | true |
16e992edb35308defa6559b5b30744fb8a64ede3 | Ruby | hectoregm/bayes | /lib/bayes/parser.rb | UTF-8 | 992 | 3.09375 | 3 | [
"MIT"
] | permissive | module Bayes
class Parser
def initialize(path)
@content = File.read(path)
end
def get_random_variables
return @variables if @variables
result = /Variables:\s*\[(.+?)\]/m.match(@content)[1]
@variables = []
result.scan(/{(.+?):([0-9,]+?)}/) do |name,values|
@variables... | true |
f6dd3eb794f54ae8ff600db978c079dc431b2562 | Ruby | cklim83/launch_school | /01_rb101_programming_foundations/lesson_03_practice_problems/medium_two.rb | UTF-8 | 31,188 | 3.78125 | 4 | [] | no_license | =begin
Question 1
Every named entity in Ruby has an object_id. This is a unique identifier for that object.
It is often the case that two different things "look the same", but they can be different objects. The "under the hood" object
referred to by a particular named-variable can change depending on what is done to... | true |
34b96042ba18f2153d48b7c496ded46733daa167 | Ruby | piotr-galas/play-with-ruby | /block_proc_lambda/block_invoke.rb | UTF-8 | 818 | 4.3125 | 4 | [] | no_license |
def multiple_by(number)
Proc.new { |n| n * number}
end
block_instnce = multiple_by(3)
# the n in block didn't change, it is fresh for all new invoke
puts block_instnce.call(10)
puts block_instnce.call(8)
# Proc can be used as argument in method
def multiply_proc(block_instance, number)
block_instance.cal... | true |
368121f521623e2c9f5657fb2c6989018c69717e | Ruby | anup-segu/ruby-projects | /Hashmaps_LRU_Caches_project/lib/p05_hash_map.rb | UTF-8 | 1,534 | 3.421875 | 3 | [] | no_license | require_relative 'p02_hashing'
require_relative 'p04_linked_list'
class HashMap
include Enumerable
attr_reader :count
def initialize(num_buckets = 8)
@store = Array.new(num_buckets) { LinkedList.new }
@count = 0
end
def include?(key)
bucket(key).include?(key)
end
def set(key, value)
li... | true |
cf5b961740ab8f068f2aba3c65a69ab5436adab8 | Ruby | gustavo-depaula/stalin-sort | /ruby/stalin_sort_recursive.rb | UTF-8 | 201 | 3.171875 | 3 | [
"MIT"
] | permissive | def stalin_sort(array, prev = nil)
first, *rest = *array
if first.nil?
[]
elsif prev.nil? || first >= prev
[first, *stalin_sort(rest, first)]
else
stalin_sort(rest, prev)
end
end
| true |
d7aa47dc32d9c530172ce4785886cfb006e60cd9 | Ruby | kw7oe/fyp-mock | /student_generator.rb | UTF-8 | 1,468 | 3.234375 | 3 | [] | no_license | require 'faker'
module StudentGenerator
extend self
HEADER = [
"name",
"email",
"studentId",
"icOrPassport",
"nationality",
"contactNumber",
"birthDate",
"programme",
"intake",
"semester"
]
PROGRAMME = [
"BCS",
"BIT",
"BCNS",
"BIS",
"BSE"
]
INT... | true |
323dc0c1a28678fdf25cfaca62cad7fd0f1b597f | Ruby | mdumke/tealeaf_exercises | /course 0 - prep course/intro_programming_1/02_variables/exercises/exercise_01_name.rb | UTF-8 | 180 | 3.84375 | 4 | [] | no_license | # exercise 1: get the name and greet the user
print "Hi, I'm Rachel, but my friends call me computer. What's your name? "
name = gets.chomp
puts "Hi, #{name}, nice to meet you!"
| true |
2589afa954d13917ee4386aba1e2e04c708d6a32 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/83d5cceebc4040ab9b95b06aa75cad9c.rb | UTF-8 | 156 | 2.9375 | 3 | [] | no_license | class Gigasecond
def self.from(start_Date)
@days_constant = ((10**9)/(24*60*60)).ceil
@init_year = start_Date + (@days_constant)
@init_year
end
end
| true |
5e6cc7ac7739e55e240830025aa45f77845d2be2 | Ruby | stanvandepoll/RB101 | /small_problems/easy_1/10.rb | UTF-8 | 682 | 4.4375 | 4 | [] | no_license | =begin
Write a method that takes two arguments, a positive integer and a boolean,
and calculates the bonus for a given salary. If the boolean is true, the
bonus should be half of the salary. If the boolean is false, the bonus should
be 0.
Problem:
input: positive integer and boolean
- salary, and if bonus should be... | true |
7bcc95baecdb33a3134c9aca626888d0405b0b23 | Ruby | 7cordovac/ttt-2-board-rb-q-000 | /lib/board.rb | UTF-8 | 109 | 2.5625 | 3 | [] | no_license | # Define the variable board below.
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
greeting = "Hello World"
| true |
351f27816c3b83247e84b14190b2ae28f5df29cd | Ruby | rei-ishinabe/climbing-log | /lib/hash_string.rb | UTF-8 | 275 | 2.5625 | 3 | [] | no_license | puts 'Started genarating hash_string for each user'
User.all.each do |user|
user.hash_string = Digest::SHA1.hexdigest(user.email)
user.save
end
puts 'Completed generating hash_string for all users'
User.all.each do |user|
puts user.email
puts user.hash_string
end
| true |
a4949204d777321e0308a585ea23ac08b6d9df3c | Ruby | ajhorus/admiosTraning | /ruby/7_lenguages_7_weeks/day1/bonus.rb | UTF-8 | 320 | 3.90625 | 4 | [] | no_license | puts "Try to guess the ramdon number between 0 and 10"
def getRamdonNumber
return rand 11
end
def evaluateNumber number
guess = getRamdonNumber
if number.to_i == guess
puts "Wiiii you Win a candy"
else
puts "You lose insert a coin"
puts "The correct number was #{guess}"
end
end
evaluateNumber gets.chomp
| true |
407ff5fa9133f5d6e2c342e88fa048699d622e6d | Ruby | shsachdev/ls101 | /lesson_3/hardq3.rb | UTF-8 | 535 | 3.265625 | 3 | [] | no_license | def dot_separated_ip_address?(input_string)
dot_separated_words = input_string.split(".")
while dot_separated_words.size > 0 do
word = dot_separated_words.pop
if is_an_ip_number?(word) != true
return false
else
nil
end
end
return true
end
# ruby method to determine if an input stri... | true |
b517e0088df33738f6ae7cea6366b6062b392911 | Ruby | Dice-K39/Flatiron_Ruby | /ruby-collaborating-objects-lab-onl01-seng-pt-041320/lib/song.rb | UTF-8 | 656 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist
@@all = []
def initialize(song_name)
@name = song_name
@@all << self
#binding.pry
end
def self.all
@@all
end
def self.new_by_filename(file_name)
file_name_array = file_name.chomp(".mp3").split(" ... | true |
cd5603affa591995bf323eb3d20ddf2d0d9f54cd | Ruby | grahambrooks/Preflight | /preflight.rb | UTF-8 | 5,016 | 2.6875 | 3 | [] | no_license | class String
def black;
"\e[30m#{self}\e[0m"
end
def red;
"\e[31m#{self}\e[0m"
end
def green;
"\e[32m#{self}\e[0m"
end
def brown;
"\e[33m#{self}\e[0m"
end
def blue;
"\e[34m#{self}\e[0m"
end
def magenta;
"\e[35m#{self}\e[0m"
end
def cyan;
"\e[36m#{self}\e[0m"
... | true |
025f4bb5277499f4945a1d4f7c9a77fb3db22543 | Ruby | eclubb/RCAP | /lib/rcap/cap_1_0/info.rb | UTF-8 | 25,286 | 2.703125 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | module RCAP
module CAP_1_0
# In Info object is valid if
# * it has an event
# * it has an urgency with a valid value
# * it has a severity with a valid value
# * it has a certainty with a valid value
# * all categories are valid and categories has at minimum 1 entry
# * all Resource object... | true |
85eca65e5d0fbcf989f7b4a1bb1eb78d4ed5a290 | Ruby | Xanthyr/AFA_Files | /ex40.rb | UTF-8 | 1,065 | 3.875 | 4 | [] | no_license | module Songlist
SANTERIA = ["I don't practice Santeria", "I ain't got no crystal ball",
"I had a million dollars, but I", "I spent it all"]
BDAY = ["Happy birthday to you",
"I don't want to get sued",
"So I'll stop right there"]
BULLS = ["They rally around tha family",
"With pockets full of shells"]
end... | true |
f71628c0a5f6a3d56dfc8d6be8a23c44750a2f7b | Ruby | QWYNG/taric | /lib/taric/operation/league.rb | UTF-8 | 3,224 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'base'
require_relative 'endpoint_template'
module Taric
module Operation
module League
include Taric::Operation::Base
LEAGUES_BY_SUMMONER_ID = EndpointTemplate.new(template_url: 'https://{host}/lol/league/v3/leagues/by-summoner/{summonerId}')
POSI... | true |
060b2777d905519f92d5b9e77c882cccf13c4f4e | Ruby | antonin-siguier/The-Hacking-Project | /j06/04_pig_latin/pig_latin.rb | UTF-8 | 1,450 | 3.921875 | 4 | [] | no_license | #write your code here
def translate(words)
vowels = "aeiouyAEIOUY"
single_words = words.split(" ") # transforme le string passé en paramètre 'words' en array
translated_words = single_words.map do |word|
if vowels.include?(word[0]) # Si la première lettre du mot a l'index auquel on est commence par une voyelle
... | true |
d42b9ad2b622b29fbc4903ca5e8418bfc4b0da1d | Ruby | jiselle03/codecore_bootcamp | /ruby/basics/fizzbuzz.rb | UTF-8 | 519 | 4 | 4 | [] | no_license | #FizzBuzz
num_1 = gets.to_i
num_2 = gets.to_i
# Solution 1
for number in 1..100
if number % num_1 == 0 && number % num_2 == 0
puts "FizzBuzz"
elsif number % num_1 == 0
puts "Fizz"
elsif number % num_2 == 0
puts "Buzz"
else
puts number
end
end
# Solution 2
for num... | true |
1591507f0ecbf8678c7a246ef6fbec4e10cb4dfa | Ruby | AkuaAA/Birthday-Web-App | /app.rb | UTF-8 | 383 | 2.546875 | 3 | [] | no_license | require 'sinatra/base'
require './lib/countdown'
class Birthday < Sinatra::Base
get '/' do
erb :index
end
post '/name_birthday'do
$name = params[:name]
$day = params[:day]
$month = params[:month]
redirect('/Birthday')
end
get '/Birthday' do
@countdown = Countdown.new($name, $day, ... | true |
5d0e17a194b0c983424585aaf600180580bdfe1e | Ruby | RyryTheGuy/odin-ruby | /basic-projects/caesar_cipher.rb | UTF-8 | 1,236 | 3.953125 | 4 | [] | no_license | # Caesar Cipher Mini-Project
# Caesar Cipher function will accept a string and shift amount each character will shift by
def caesar_cipher(string, shift)
# Break up the string into a character array
# Convert the characters into their char codes
char_array = string.split("").map do |char|
# Only convert alph... | true |
affb1a9e4e8ea8cc2c38655b2ad83b725dfbd948 | Ruby | jasonpilz/ctci-6th-edition-ruby | /lib/chapter_01/1.06.rb | UTF-8 | 294 | 2.65625 | 3 | [] | no_license | # frozen_string_literal: true
module One
module Six
module_function
def call(input)
comp = input
.chars
.slice_when(&:!=)
.reduce(String.new) { |s, a| s << a.instance_eval { "#{first}#{size}" } }
[comp, input].min_by(&:length)
end
end
end
| true |
9cc8d02df16870c1b86f8b328ad4c9543a675362 | Ruby | atsuya/microservices-as-controllers | /controller.rb | UTF-8 | 975 | 2.671875 | 3 | [] | no_license | require 'json'
require 'stringio'
require 'webrick'
require './producer'
require './consumer'
class Controller
def initialize(request_config, response_config)
@request_config = request_config.clone
@response_config = response_config.clone
end
def start
@producer = Producer.new(@response_config)
... | true |
93757620ff648b11d447ab9e3962a4041210da0a | Ruby | Jahmal23/Squeege | /Lib/ReferenceUSA/reference_usa_results.rb | UTF-8 | 2,628 | 3.046875 | 3 | [] | no_license | require_relative '../helpers/pauseable'
class ReferenceUSAResults
include Pausable
BASE_URL = "http://www.referenceusa.com/UsWhitePages/Result/".freeze
HOME_URL = "http://www.referenceusa.com/Home/Home".freeze
def scrape_results(capy_session)
unless capy_session.current_url.include? BASE_URL
puts ... | true |
f41048bc6caab9974f6cf84150aa07e3f1cc6e20 | Ruby | dhoangk07/movie-data | /app/models/movie.rb | UTF-8 | 1,079 | 2.53125 | 3 | [] | no_license | require 'uri'
require 'net/http'
class Movie < ApplicationRecord
validates :title, uniqueness: true
def self.fetch_themoviedb
url = URI("https://api.themoviedb.org/3/movie/now_playing?page=1&language=en-US&api_key=65863bf5229c0d57bcf2f3a29183ac0e")
http = Net::HTTP.new(url.host, url.port)
http.use_s... | true |
01bf290d66152bfed61fda62c9424ce269500133 | Ruby | paskuvan/challenge13 | /ex03.rb | UTF-8 | 70 | 2.875 | 3 | [] | no_license | h = {"x": 1, "y":2,}
h [:z] = 3
h [:x] = 5
h.delete(:y)
puts h.invert | true |
cac7c2470ff7778e639bceaa3fa5099a912495b2 | Ruby | dnourie/learning_ruby | /exercises/hash3.rb | UTF-8 | 317 | 2.921875 | 3 | [] | no_license | grocery_list = { "Onions" => 2, "Carrots" => 4, "Potatoes" => 6, "Lemons" => 2 }
grocery_list.each do |k, v|
puts k
end
grocery_list.each do |k, v|
puts v
end
planets = { mars: "red", earth: "blue", venus: "white", neptune: "blue" }
planets.each_key {|key| puts key }
planets.each_value {|value| puts value }
| true |
96f053aa22bf4a92a95de6c4eee35cec858fec8e | Ruby | FineTralfazz/NookBot | /semester_rollover.rb | UTF-8 | 1,308 | 3.1875 | 3 | [
"BSD-3-Clause"
] | permissive | require 'discordrb'
require 'json'
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
puts 'THIS SCRIPT IS VERY DANGEROUS'
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
puts 'Running it on the wrong server or at the wrong time of year will make '\
'a lot of people very angry!'
puts 'Are you sure you want to remove everyone from every clas... | true |
46f07203faf8033d9e9e713506017f9501ffe3d1 | Ruby | andydlindsay/may24-2021 | /w08d05/04_methods.rb | UTF-8 | 232 | 3.90625 | 4 | [] | no_license | # function == method
def say_hello name, age
# return_val = "hello there #{name} you are #{age}"
# puts return_val
# return return_val
"hello there #{name} you are #{age}"
end
greeting = say_hello 'Bob', 42
puts greeting
| true |
757e315cca4e1287ee817b944ae3e8ead769f33b | Ruby | huy/deployment_helper | /lib/core_ext.rb | UTF-8 | 4,561 | 2.53125 | 3 | [] | no_license | unless defined?(CoreExt)
CoreExt = true
class Hash
def assert_valid_keys(*valid_keys)
unknown_keys = keys - [valid_keys].flatten
raise(ArgumentError,
"<error>Unknown key(s): #{unknown_keys.join(", ")}\nValid key(s): #{valid_keys.join(',')}</error>") unless unknown_ke... | true |
059b445d39f26debb26c7128fb8b540cb3a7939d | Ruby | ryanwood/prayerthread.org | /app/models/membership.rb | UTF-8 | 1,270 | 2.515625 | 3 | [] | no_license | class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :group
before_save :set_notifications
attr_accessible :notification_level, :group, :user
validates_presence_of :group, :user
validates_uniqueness_of :user_id, :scope => :group_id, :on => :create
NOTIFICATION_LEVELS = [
[ "wh... | true |
2086703385e7f5b11dcdd3781981bbfd7d06eb61 | Ruby | ddx-510/todo-app | /app/models/todo_item.rb | UTF-8 | 580 | 2.640625 | 3 | [] | no_license | class TodoItem < ApplicationRecord
default_scope { order(created_at: :desc) } # default scope : newest appear first
belongs_to :user
validates :title, presence: true
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
def all_tags=(tags_string)
tag_names = tags_string.split(",").... | true |
987d09dc1500066b27da8c10a39f8526c8670608 | Ruby | LeonamAnjos/ruby-learning | /abstract_class.rb | UTF-8 | 208 | 3.453125 | 3 | [] | no_license | class AbstractKlass
def welcome
puts "#{hello} #{name}"
end
end
class ConcreteKlass < AbstractKlass
def hello
"Hello"
end
def name
"Ruby learners"
end
end
ConcreteKlass.new.welcome
| true |
d0ba401dafbc8b180bdb58e4e4c789d9a5ef6c06 | Ruby | Antondomashnev/nabokov | /lib/nabokov/commands/syncers/project_syncer.rb | UTF-8 | 3,886 | 2.859375 | 3 | [
"MIT"
] | permissive | require "nabokov/commands/syncers/syncer"
require "nabokov/core/file_manager"
require "nabokov/helpers/merger"
require "nabokov/models/strings_file"
module Nabokov
class ProjectSyncer < Syncer
self.abstract_command = false
self.command = "project"
self.summary = "Synchronize project localization strings ... | true |
2cdf8534213256dc6f70cf64d3c6bbb1f7d4d994 | Ruby | czuger/potamos | /lib/ground.rb | UTF-8 | 1,537 | 3 | 3 | [
"MIT"
] | permissive | require 'rhex'
require_relative 'ground_hex'
require_relative 'ground_events'
class Ground
include Magick
include GroundEvents
attr_reader :ground, :rows, :cols, :hex_ray
PIC_NAME = 'test2.png'
def initialize( rows, cols, debug: false )
@rows = rows
@cols = cols
@ground = SquareGrid.new( el... | true |
98040d65648a98c374864047947f7562897a4a07 | Ruby | PushkarDureja/FizzBuzz | /fizz-buzz/ruby.rb | UTF-8 | 270 | 3.453125 | 3 | [
"Unlicense"
] | permissive | #ruby 2.5.1
(1..100).each {
|n|
case
when (n % 3 == 0) && (n % 5 == 0)
puts "FizzBuzz"
when (n % 3 == 0)
puts "Fizz"
when (n % 5 == 0)
puts "Buzz"
else
puts n
end
}
| true |
f11079171da2d4f52cacc2b88b06b3fd978d8aaf | Ruby | cbascom/euler | /ruby/prob2.rb | UTF-8 | 162 | 3.421875 | 3 | [] | no_license | #!/usr/bin/env ruby
fib1 = 1
fib2 = 1
sum = 0
while fib2 < 4000000
sum += fib2 if fib2 % 2 == 0
fib = fib1 + fib2
fib1 = fib2
fib2 = fib
end
puts sum
| true |
769bb179da099fcd5cfd80c6fcc745936db06369 | Ruby | zhang4952/dspace2hydra | /mapping/community.rb | UTF-8 | 643 | 2.59375 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | # frozen_string_literal: true
module Mapping
class Community
require 'csv'
require 'yaml'
extend Extensions::BasicValueHandler
##
#
#
# @param[String] value - An array of collection handles passed from CustomNode
# @param[Array] *args -
# return -
def self.lookup_community_na... | true |
737aa6e4afc70ddd838298a05c0873f6f2d9b6ee | Ruby | uk-gov-mirror/alphagov.datainsight-format-success-recorder | /lib/model/format_success.rb | UTF-8 | 2,944 | 2.5625 | 3 | [] | no_license | module FormatSuccess
class Model
include DataMapper::Resource
include DataInsight::Recorder::BaseFields
include DataInsight::Recorder::TimeSeries
property :start_at, DateTime, :required => true, :unique_index => :format_date_range
property :end_at, DateTime, :required => true, :unique_index => :f... | true |
78ade720b755b62b868ace47731d770824402481 | Ruby | tkaszuba/consulting | /rubyfunc/ruby_ex2.rb | UTF-8 | 529 | 3.953125 | 4 | [] | no_license | def sumInts(a,b)
if a > b
0
else
a + sumInts(a+1,b)
end
end
def sumSquares(a,b)
def square(x)
x*x
end
if (a>b)
0
else
square(a) + sumSquares(a+1,b)
end
end
def sumPowersOfTwo(a,b)
def powerOfTwo(x)
if (x == 0)
1
else
2 * powerOfTwo(x-1)
end
end
if... | true |
00590d84f103236893bcfdc9d6cc0bc57e22663d | Ruby | girija/muvi | /app/models/user_follower.rb | UTF-8 | 1,262 | 2.609375 | 3 | [] | no_license | class UserFollower < ActiveRecord::Base
require 'open-uri'
belongs_to :user
def add_follower(current_user_id, follower_id,options = {})
@follower = []
@uf = UserFollower.find_by_user_id(current_user_id)
unless @uf.blank?
unless @uf.followers.blank?
@follower = ActiveSupport::JSON.decode(@uf.follo... | true |
62d7468b90e8930083e9fcef47d07fa4c4f6fcbf | Ruby | HoustonVS/Project | /app/models/extension_database.rb | UTF-8 | 1,851 | 2.734375 | 3 | [] | no_license |
class ExtensionDatabase
module ExtensionType
Knowledge = 1
Psycho = 2
Skill = 4
Other = 8
end
class ATExtension
attr_accessor :name, :controller_class, :ext_type, :description
attr_accessor :accepts_action, :accepts_task, :generate_state, :task_description, :task_exec_path
def get_task_descript... | true |
28d3ed11a0ba2ed808bfa040ee5b337fbfecef25 | Ruby | drunkwater/leetcode | /medium/ruby/c0023_47_permutations-ii/00_leetcode_0023.rb | UTF-8 | 467 | 3.21875 | 3 | [] | no_license | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#47. Permutations II
#Given a collection of numbers that might contain duplicates, return all possible unique permutations.
#Example:
#Input: [1,1,2]
#Out... | true |
6a513ecc264858a5f5fca294d548dc3f7dca2306 | Ruby | GustavoCaso/codewars_cli | /lib/codewars_cli/config.rb | UTF-8 | 1,275 | 2.5625 | 3 | [
"MIT"
] | permissive | module CodewarsCli
class Config < Thor
desc 'api_key KEY', 'Set the global configuration for api_key'
method_options update: :boolean
def api_key(api_key)
Configuration.write(api_key, :api_key, options)
end
desc 'language LANGUAGE', 'Set the global configuration for language'
long_desc ... | true |
b99db5c0038dac4df0eb13dd1f4d683fd77ea943 | Ruby | Lasiorhine/Random-Menu | /draft_assignment_1.rb | UTF-8 | 1,905 | 3.59375 | 4 | [] | no_license | =begin
This is assignment 1 for Ada cohort 9
Assigned: 18-2-05 pm
Due: 18-2-06 am (before class)
Specs:
OVERALL: Randomly access the contents of 3 10-item arrays to produce a
10-item menu.
SPECIFICS: * Each item should be in the format "Adj, cookingstyle, foodnoun"
* Should run in... | true |
cd5f26ebcdc474043aac2769e7aee552a9e0bd57 | Ruby | zonika/flatiron-bnb-methods-web-0715-public | /app/models/city.rb | UTF-8 | 828 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, :through => :neighborhoods
has_many :reservations, :through => :listings
def self.highest_ratio_res_to_listings
cities = {}
all.each do |city|
cities[city] = city.reservations.length.to_f/city.listings.length.to_f
end... | true |
8471df8aaf36f014917eae19a84d06b75343f644 | Ruby | nkthota/TCSDemo | /pageobjects/specialSavings.rb | UTF-8 | 1,298 | 2.75 | 3 | [] | no_license | require 'rspec'
require 'selenium-webdriver'
class SpecialSavings < AbstractPage
#define object name for all page objects
attr_accessor :select_items
#intialize the selector strings for all the objects defined
def initialize(driver)
super(driver)
@select_items = "[name='rpp']"
end
# verify all s... | true |
f53b88c70b0c43240957ce7079dddd4806588d7b | Ruby | Githerdone/ar-address-schema | /app/models/contact.rb | UTF-8 | 753 | 2.75 | 3 | [] | no_license | require_relative '../../db/config'
class Contact < ActiveRecord::Base
validates :company, :presence => true
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/
validates_format_of :phone, :with => /\(?\d{3}\)?-?\s?\d{3}\-\d{4}/
def initialize
@first_name = hash[:first_name]
... | true |
22b34cdbb6806ef66f96249bcb5682c1b85456c4 | Ruby | aaduru/course-work | /W1D2/match_game/card.rb | UTF-8 | 466 | 3.40625 | 3 | [] | no_license | require_relative "board"
class Card
attr_accessor :face_up, :face_value
def initialize(face_value, face_up=false)
@face_value = face_value
@face_up = face_up
end
def flip
self.face_up == true ? self.face_up = false : self.face_up = true
end
def display
if self.face_up == true
self.... | true |
28af72ed641b62ff4e36ea70d6d77d0149ee213e | Ruby | ac6087/algorithms | /ruby/graphs/graph.rb | UTF-8 | 1,369 | 3.296875 | 3 | [] | no_license | class Vertex
attr_accessor :color, :d, :pi, :adj_list, :attribute, :f
def initialize(color, d, pi, adj_list=[], attribute)
@color, @d, @pi, @adj_list, @attribute= color, d, pi, adj_list, attribute
end
end
class Edge
attr_accessor :v1, :v2
def initialize(v1, v2)
@v1, @v2 = v1, v2
end
end
class Un... | true |
8cf5cac572a52d56e595228d077ddbe72acd4896 | Ruby | DIGITALFRANK/RUBY_PLAYGROUND | /heroku_deployment.rb | UTF-8 | 2,389 | 2.9375 | 3 | [] | no_license |
# Heroku Deployment
# 1. Visit https://www.heroku.com/ and sign up for an account.
# 2. Create a new app in the Heroku Application Dashboard.
# Reference Image
# 3. Visit and download the Heroku Git CLI (Using Brew) https://devcenter.heroku.com/articles/heroku-cli
# 4. Go back to the dashboard and follow the ... | true |
f1b0a9819b82b7d46abef6155e452efdd4e42d43 | Ruby | dgoodlad/launchpad | /test/test_interaction.rb | UTF-8 | 9,852 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'helper'
class BreakError < StandardError; end
class TestInteraction < Test::Unit::TestCase
context 'initializer' do
should 'create device if not given' do
Launchpad::Device.expects(:new).with(:input => true, :output => true).returns('device')
assert_equal 'device', Launchpad::Intera... | true |
9123420d5dcb6555c30123e51a9dc9a0506aafc7 | Ruby | annayerofeyeva/architect-challenge | /lib/train.rb | UTF-8 | 208 | 3.015625 | 3 | [] | no_license | require_relative 'station'
class Train
attr_reader :coaches
def initialize(number=1)
@coaches = []
number.times{@coaches << Coach.new}
end
def coach_count
@coaches.count
end
end | true |
55375e62fab7e0bd707151dd50eeedd2f8b5ffca | Ruby | nithinsunny/Ruby | /Ruby/arrayelementssquare.rb | UTF-8 | 53 | 2.953125 | 3 | [] | no_license | a = [1,2,3,4]
b = a.map {|x| x*x}
print a
print b
| true |
645d7d7bd5cfacc49d79639a01f59b92464e805e | Ruby | cms718/battle | /app.rb | UTF-8 | 787 | 2.546875 | 3 | [] | no_license | require 'sinatra/base'
require 'sinatra/reloader'
require './lib/player.rb'
require './lib/game.rb'
class Battle < Sinatra::Base
enable :sessions
configure :development do
register Sinatra::Reloader
end
get '/' do
erb(:index)
end
get '/play' do
@game = $game
erb(:play)
end
post '/... | true |
7b629499e91c377fcde1371aaceb42073f6b1518 | Ruby | markcp/fsmc | /app/models/movie.rb | UTF-8 | 1,910 | 2.609375 | 3 | [] | no_license | class Movie < ApplicationRecord
require 'csv'
has_many :viewings, dependent: :destroy
accepts_nested_attributes_for :viewings,
reject_if: proc { |attributes| attributes['date'].blank? },
allow_destroy: true
before_validation :build_title_index
... | true |
318108948266d341b25159a7b9edb114f0d59b3f | Ruby | scottburton11/ProjectImporter | /lib/project_importer/mover.rb | UTF-8 | 2,921 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module ProjectImporter
class Mover
attr_reader :local_file, :logger
def initialize(path, account_prefix, home)
@local_file = ProjectImporter::LocalFile.new(path)
@account_prefix = account_prefix
@home = home
@logger = ProjectImporter::Logger
end
def self.move(dir, account_pre... | true |
5b7d5b5117581cc97ac048dedfb003b0601ef896 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/combine_anagrams_latest/6793.rb | UTF-8 | 440 | 3.28125 | 3 | [] | no_license | def combine_anagrams(words)
ordenados = Array.new
anagramas = Array.new
words.each do |word|
ordenados << word.downcase.chars.sort(&:casecmp).join
end
ordenados.uniq.each do |ordenado|
temporal = Array.new
words.each do |word|
if ((word.downcase.chars.sort(&:casecmp).join.casecmp ordenado) =... | true |
855681e8d7b702a3b6c7846471d3b02e429dff89 | Ruby | Tr1ckX/FAAST_Week-1 | /spec/passenger_spec.rb | UTF-8 | 870 | 2.6875 | 3 | [] | no_license | require './lib/passenger'
describe Passenger do
let(:passenger) { Passenger.new }
let(:card) { double :card }
before do
allow(Card).to receive(:new).and_return(card)
end
it 'should not to have a card when initialized' do
expect(@card).to be(nil)
end
it 'can buy a card' do
passenger.... | true |
5abda917f7484124732d620020479c4c8f547673 | Ruby | XANi/marionette-collective | /spec/matchers/exception_matchers.rb | UTF-8 | 2,104 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | module MCollective
module Matchers
def raise_code(*args)
CodedExceptionMatcher.new(args)
end
class CodedExceptionMatcher
def initialize(args)
@args = args
raise "Need at least an exception to match" if args.size == 0
@expected_code = @args.shift
@expected_dat... | true |
627d7e0f8a594e07f33811520c96c9d6daf4f584 | Ruby | EgorCrytski/pss | /lib/product.rb | UTF-8 | 323 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'page'
class Product
attr_reader :name
attr_reader :price
attr_reader :image
def initialize(name, price, image)
@name = name
@price = price
@image = image
end
def print
puts("name: #{@name};\nprice: #{@price};\nimage: #{@image}\n\n")
end
e... | true |
efc8fde1ab9e65a468d4b845d48ef209454d6a28 | Ruby | yebhub/sinatra_practice | /basics.rb | UTF-8 | 982 | 3.28125 | 3 | [] | no_license | #requiring gems
require 'rubygems'
require 'sinatra'
#landing page, just says hello world
get '/' do
"Hello, World!"
end
get '/about' do
"Hey there, this is about me. "
end
#:name is a key in the params array, which holds all GET and POST variables
get '/hello/:name' do
"hello there, #{params[:na... | true |
90251a47b8b9b3fba7cd47896c3790af35140ace | Ruby | lisafolliard/word_definition | /app.rb | UTF-8 | 742 | 2.5625 | 3 | [] | no_license | require('sinatra')
require('sinatra/reloader')
also_reload('lib/**/*.rb')
require('./lib/word')
require('./lib/definition')
require('pry')
get('/') do
@words = Word.all()
erb(:index)
end
get('/words/new') do
erb(:word_form)
end
get('/word_details/:id') do
@word = Word.find(params.fetch('id').to_i())
erb(:w... | true |
c6533900f9ca369cb420901ea5bda3c15b5ff5e7 | Ruby | yfzo/math_game | /turn.rb | UTF-8 | 351 | 3.03125 | 3 | [] | no_license | require('./question')
class Turn
attr_reader :asker, :responder, :question
def initialize asker, responder
@asker = asker
@responder = responder
@question = self.question_generator
end
def question_generator
num1 = rand(20) + 1
num2 = rand(20) + 1
Ques... | true |
7590509d323500bb3ab10fb03006644585685160 | Ruby | kel29/ruby-enumerables-generalized-map-and-reduce-lab-seattle-web-082619 | /lib/my_code.rb | UTF-8 | 224 | 3.40625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Your Code Here
def map(arr)
arr.map { |i| yield i }
end
def reduce(arr, v = nil)
if v
r = v
i = 0
else
r = arr[0]
i = 1
end
until i >= arr.length
r = yield(r, arr[i])
i += 1
end
r
end | true |
04a695cbb2d3f35af2cfc343f295a2d50c65b673 | Ruby | clarkee013/Snakes_and_Ladders | /snake.rb | UTF-8 | 353 | 3.09375 | 3 | [] | no_license | class Snake
def initialize(snake)
@snake = snake
end
def get_snake_head()
return @snake[:start]
end
def get_snake_tail()
return @snake[:end]
end
def for_landing_on_snake(token_position)
if token_position == @snake[:start]
token_position == @snake[:end]
return token_positio... | true |
ff0014c25c2110ee1fc0f3000c548ae499c755ba | Ruby | alliricker/ttt-10-current-player-online-web-sp-000 | /lib/current_player.rb | UTF-8 | 231 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
counter = 0
board.each do |players|
if players == "X" || players == "O"
counter += 1
end
end
counter
end
def current_player(board)
turn_count(board).even? ? "X" : "O"
end
| true |
cef535ac6ef3ac1dc285fb8442e246739a2d2599 | Ruby | asyrafsaupi/code-client | /clientt.rb | UTF-8 | 145 | 2.921875 | 3 | [] | no_license | require 'socket'
host = '192.168.74.134'
port = 1600
sock = TCPSocket.open(host, port)
while line = sock.gets
puts line.chop
end
sock.close
| true |
f845b3e7e866ee67136e53d9891e41d0feac3e4f | Ruby | YinnyF/codewars | /Ruby/8KYU/invert-values.rb | UTF-8 | 121 | 2.671875 | 3 | [] | no_license | =begin
https://www.codewars.com/kata/5899dc03bc95b1bf1b0000ad
=end
# my solution
def invert(list)
list.map{|x| -x}
end | true |
166d96930167c33f1737eb9df780011af59e210c | Ruby | mediagreenhouse/spontaneous | /lib/spontaneous/logger.rb | UTF-8 | 11,134 | 2.609375 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
## Adapted from Padrino::Logger
#
# Defines our SPOT_LOG_LEVEL
SPOT_LOG_LEVEL = ENV['SPOT_LOG_LEVEL'] unless defined?(SPOT_LOG_LEVEL)
module Spontaneous
##
# Returns the spontaneous logger
#
# ==== Examples
#
# logger.debug "foo"
# logger.warn "bar"
#
def self.logger
Threa... | true |
08eccd25b3f0f41acff37e78191f1953430c2b63 | Ruby | sr/atom-test | /tests/feed_logo.rb | UTF-8 | 228 | 2.625 | 3 | [
"MIT"
] | permissive | xml = <<XML
<!--
Description: feed logo
-->
<feed xmlns="http://www.w3.org/2005/Atom">
<logo>http://example.com/logo.jpg</logo>
</feed>
XML
test = lambda { |feed|
assert_equal 'http://example.com/logo.jpg', feed.logo.to_s
}
| true |
09e8b969486212280888f9f25803e092ca058971 | Ruby | russenoire/ls100 | /008_more/examples/boolean_matchdata.rb | UTF-8 | 173 | 2.9375 | 3 | [] | no_license | def has_a_b?(str)
/b/.match(str) ? (puts "We have a match!") : (puts "No match here.")
end
has_a_b?("basketball")
has_a_b?("football")
has_a_b?("hockey")
has_a_b?("golf") | true |
f2c8d41bba4002939eec181c6f45af453f4ce092 | Ruby | SeanLF/colonies-technical-test | /level3/main.rb | UTF-8 | 1,952 | 3.390625 | 3 | [] | no_license | require './json_file_manipulation.rb'
require 'date'
class GetAround
include JsonFileManipulation
DISCOUNTS = {
1 => 0.1,
4 => 0.3,
10 => 0.5
}.freeze
def initialize(input_file = './data/input.json')
input = get_json_from_file(input_file)
@cars = cars_hash(input['cars'])
@rentals = in... | true |
847cf54c13324f20dd1702bfc4c80d30b5a79152 | Ruby | weelliam/mpm-magic | /lib/cards/imported/serra_advocate.rb | UTF-8 | 356 | 2.609375 | 3 | [] | no_license |
class SerraAdvocate < Creature
def initialize(owner=nil)
super(owner)
@name = "Serra Advocate"
@strength = 2
@toughness = 2
@cost = 4 # 3W
@description = "Flying {Tap}: Target attacking or blocking creature gets +2/+2 until end of turn."
@img = "cards/13162.png"
@mtg_id = 13162
e... | true |
77a3a7dedd312935c2335ba87ce22af8a7e65c0e | Ruby | tirodactyl/coding_challenge0714 | /lib/prime.rb | UTF-8 | 638 | 3.84375 | 4 | [] | no_license | def is_prime?(n)
# this line prevents us from having to check ANY even numbers once we check for division by two
if n != 2
return false if n % 2 == 0
end
i = 3
until i >= n
return false if n % i == 0
i += 2
end
true
end
def n_primes(n)
results = []
i = 1
until results.length ==... | true |
8eb8b252e4b1da06bf697127dc94fcd601dc023e | Ruby | ibanez270dx/dotfiles-older | /scripts/quote.rb | UTF-8 | 419 | 2.8125 | 3 | [] | no_license | require 'httparty'
require 'htmlentities'
require 'colorize'
begin
response = HTTParty.get('http://www.iheartquotes.com/api/v1/random?show_permalink=false')
print "\n #{HTMLEntities.new.decode(response.to_s)} \n".bold
rescue Exception => e
print "\n No soup for you! -Soup Nazi".bold
print "\n Socket Error! Che... | true |
7e205928a13d82139271f875d37cf725cb148ca3 | Ruby | frandorr/isw2-tp1 | /item_plan.rb | UTF-8 | 133 | 2.625 | 3 | [] | no_license | class ItemPlan
attr_reader :fecha
attr_reader :tarea
def initialize fecha, tarea
@fecha = fecha
@tarea = tarea
end
end | true |
36f05df044f7c3a444b8b1947963cc5f4cf29c40 | Ruby | georgiybykov/simpler | /lib/simpler/controller.rb | UTF-8 | 1,570 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'view'
module Simpler
class Controller
HEADERS_TYPES = {
html: 'text/html',
plain: 'text/plain'
}.freeze
class ValidationError < StandardError; end
attr_reader :name, :request, :response
def initialize(env)
@name = extract_name
... | true |
d47f0756b4daee42bd351152aec6db897eac87ba | Ruby | parsongalicia/wcs | /ch08/tableOfContents.rb | UTF-8 | 367 | 3.296875 | 3 | [] | no_license | width = 50
pages = [' page 1', ' page 9', 'page 13']
title = ['Table of Contents']
lines =['Chapter 1: Getting Started',
'Chapter 2: Numbers ',
'Chapter 3: Letters ']
puts (title [0]).center(width)
puts " "
reps = 0
lines.each do |lines|
lines = lines + (pages[reps]).rjust(width/2)
p... | true |
9b1b0f2fc4a7e84ee9c83165d20102be272f95cd | Ruby | chef/chef_secrets | /lib/veil/hasher.rb | UTF-8 | 749 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | require "veil/utils"
require "veil/hasher/base"
require "veil/hasher/bcrypt"
require "veil/hasher/pbkdf2"
module Veil
class Hasher
DEFAULT_OPTIONS = {
type: "Veil::Hasher::PBKDF2",
iterations: 10_000,
hash_function: "SHA512"
}
class << self
#
# Create a new Hasher instance
... | true |
5caffb95e4051ee18e18cf45c5f28e281c2eed21 | Ruby | RickCarlino/xkcd-287 | /lib/support.rb | UTF-8 | 470 | 3.609375 | 4 | [] | no_license | # A module containing the less important helper methods, such as string format
# methods, etc.
module Support
# A support method that converts irregular prices to precise (Fixnum) amounts
# in cents. Returns Fixnum to avoid rounding errors.
# Params:
# (String) price - A string representation of money in USD.
... | true |
fe1e1e2f73c26ecc9ce031e5845d818a5410f850 | Ruby | GWitczak/ruby-book-exercises | /Loops_Iterators/3.rb | UTF-8 | 129 | 3.203125 | 3 | [] | no_license | animals = ["Dogs", "Cats", "Parrots", "Lions", "Zebras", "Monkeys"]
animals.each_with_index { |type, i| puts "#{i+1}. #{type}" } | true |
82e81bec23a3fef81b6392e4ed266c960ca39406 | Ruby | chironaga/pemu | /lib/example/packet.rb | UTF-8 | 1,043 | 2.546875 | 3 | [] | no_license | require_relative './protocol'
require 'yaml'
module Example
module Protocol
class Packet
attr_reader :name
def initialize(version, file)
@version = version
@file = file
@name = File.basename(file).sub(/\.yml/, '')
@commands = load
end
def dequeue
payload = @commands.shift
paylo... | true |
994acc61dea73bb11b82f31b5d3d9fde5a870639 | Ruby | vladmyshchuk/ruby_study | /fibonacci_numbers.rb | UTF-8 | 557 | 4.0625 | 4 | [] | no_license | # frozen_string_literal: true
# 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 ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.