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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32a1eb3666cd3f94b59f099be9c58a101f9f5dd4 | Ruby | TravisGM92/enigma_api | /app/models/enigma.rb | UTF-8 | 787 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
class Enigma < ApplicationRecord
def self.transform(data)
indecies = TransformChars.transform_message(data)
if data['status'] == 'decrypt'
format_decryption({ indecies: indecies, date: data['date'], key: data['key'] })
else
format_encryption({ indecies: indecies,... | true |
19c05df27cc3dafb33c01676f3aefbe95630bbf8 | Ruby | clarchiu/math-game | /questions.rb | UTF-8 | 1,098 | 3.0625 | 3 | [] | no_license | @questions = [
{
str: "What is 10 + (-7)?",
answer: 3
},
{
str: "What is -4 + 7?",
answer: 3
},
{
str: "What is 8 + (-12)?",
answer: -4
},
{
str: "What is 10 + 9?",
answer: 19
},
{
str: "What is 3 + (-4)?",
answer: -1
},
{
str: "Double 7178",
answer:... | true |
c7eda3764a072ecb3e9911b05b6fa2b3f010e1ad | Ruby | sptsn/bakery | /bin/bakery_runner.rb | UTF-8 | 586 | 3.1875 | 3 | [] | no_license | require 'optparse'
require_relative '../lib/bakery'
require_relative '../lib/parser'
bakery = Bakery.new
def print(packs_ary)
packs_ary.each do |packs_hash|
total_price = packs_hash.inject(0) { |sum, (k, v)| sum + k['price'] * v }
str = packs_hash.map do |pack, number|
"#{pack['count']}-pack ($#{pack[... | true |
409a73dcfac16989fb8d429c75d8b5b65287f585 | Ruby | olegchursin/tweet-shortener-web-121117 | /tweet_shortener.rb | UTF-8 | 1,152 | 4.0625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def dictionary
dictionary = {
"hello" => "hi",
"to" => "2",
"two" => "2",
"too" => "2",
"for" => "4",
"four" => "4",
"be" => "b",
"you" => "u",
"at" => "@",
"and" => "&"
}
end
def word_substituter(tweet)
tweet_ary = tweet.split # create an array from the string
new_a... | true |
91557c8cf768b83fd3014d86674a8aab30ca04d7 | Ruby | kseebaldt/pivot-pong | /app/models/inactive.rb | UTF-8 | 331 | 2.609375 | 3 | [] | no_license | class Inactive < Achievement
class << self
def title
"Where'd You Go?"
end
def description
"Gone inactive after 30 days of not playing"
end
def badge
"fa fa-minus-circle"
end
def eligible?(player)
false # will be awarded when players are marked as inactive
en... | true |
ac2b9d6ea408a39a7795371ad3789b7b5824da06 | Ruby | balmoral/cx-util | /lib/cx/util/item.rb | UTF-8 | 1,023 | 3.59375 | 4 | [] | no_license | # A simple wrapper to pair an indexed collection with an index
# and provide functionality around the an item's knowledge of where
# it is located in the collection.
#
# Implemented as both an Itemize module and Item class
# to allow flexibility in implementation.
#
# TODO: consider issue of two-way reference between c... | true |
901daa3b570c7fe06b1e82525d489c521fe54555 | Ruby | szTheory/anki-rb | /test/deck_test.rb | UTF-8 | 859 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class DeckTest < Minitest::Test
def test_construct_deck
deck = Anki::Deck.new 'TestDeck'
assert(deck, 'deck should exist')
assert_equal('TestDeck', deck.name, 'name should match')
assert_kind_of(Numeric, deck.id, 'id should be a fixnum (int)')
end
def test_add_card
dec... | true |
ebc51e73cea727c103ee12458511e7311d3edb17 | Ruby | D-coder22/Ruby-Udemy | /Classes II - Section 20/bicycle.rb | UTF-8 | 249 | 2.90625 | 3 | [
"MIT"
] | permissive | class Bicycle
@@maker = "BikeTech"
@@count = 0
def self.description
"Hi there, I'm the blueprint for Bicycles! Use me to create a bicycle object."
end
def self.count
@@count
end
end
puts Bicycle.description
puts Bicycle.count
| true |
614b8377778d0f4e5e40e560294fd416be121e70 | Ruby | Faiza1987/VideoStoreAPI | /test/models/movie_test.rb | UTF-8 | 1,577 | 2.53125 | 3 | [] | no_license | require "test_helper"
describe Movie do
describe 'relations' do
it 'has a customer' do
movie = movies(:pride)
expect(movie).must_respond_to :customers
end
it "has a rental" do
movie = movies(:pride)
rental = Rental.new(movie_id: Movie.first.id, customer_id: Customer.first.id)
... | true |
ca511a6ddc2d5804441bf4f94dfe3b7c26fcef87 | Ruby | Academia-Hack-Promo2/w7_d31_ch7_mromero942 | /primos.rb | UTF-8 | 1,206 | 4.125 | 4 | [] | no_license | # numeros primos /numero natural mayor que 1 que solo tiene dos divisores el mismo y 1
#sin ciclos
#Verificar cuales números entre el 1 y el 6 son primos.
def arreglo
numeros = [1,2,3,4,5,6]
end
def primo ()
if arreglo[0] == 1
puts "#{arreglo[0]} = NO PRIMO"
end
if arreglo[1] % arreglo[1] == 0 && arre... | true |
a88e12279c3dab4de462dfb8b853dcd2e6d19d1d | Ruby | worace/flatten | /oorion.rb | UTF-8 | 482 | 3.546875 | 4 | [] | no_license | class CustomArray
attr_reader :array
def initialize(array)
@array = array
end
def my_flatten
array.my_flatten
end
end
class Array
def flatten_proc
Proc.new do |array, e|
if e.class != Array
array.push(e)
else
array += e.my_flatten
end
end
end
def my... | true |
cc67056df6a834122b3ad3740719902f311ee96a | Ruby | cindyMendes/first_programs | /divisible.rb | UTF-8 | 657 | 4.15625 | 4 | [] | no_license | def divisible_by_2()
array = []
1.upto(100) do |n|
if n % 2 == 0
array.push(n)
end
end
return array.to_s
end
puts "The numbers divisible by 2 are #{divisible_by_2()}"
puts
def divisible_by_3()
array = []
1.upto(100) do |n|
if n % 3 == 0
array.... | true |
aa3706aab9e4cc916a67136110f018f6f0b2a6a0 | Ruby | JiriChara/rgc | /lib/rgc/keygen.rb | UTF-8 | 457 | 2.53125 | 3 | [
"MIT"
] | permissive | module Rgc
class Keygen
def initialize(global_options, options, args)
if File.exists?(path = args.first)
abort "Key file already exists."
end
begin
File.open(path, 'w') do |f|
f.write(generate_secure_key)
end
rescue
abort "Cannot open #{path} for ... | true |
c8f1022f0626e31697e71c5221849cc017c7278b | Ruby | calderete/mini_test_work_out | /arry_splitting.rb | UTF-8 | 907 | 3.71875 | 4 | [] | no_license | require 'pry'
class ArrySplitting
def self.array_divider(*array)
#normally I would not save the array.count into a variable and just use array.slice!(array.count / 2)
#but the directions said to only iterate once and I was trying to keep in the spirit of that
length = array.count
unless length == 0
... | true |
08c6e6e3775829e6db3709016ef13e2eb14acf02 | Ruby | dawity/pickaxe | /fib_up_to.rb | UTF-8 | 220 | 3.453125 | 3 | [] | no_license | class Dawit
def fib_up_to(max)
i1, i2 = 1, 1
# parallel assignment (i1 = 1 and i2 = 1)
while i1 <= max
yield i1
i1, i2 = i2, i1+i2
end
end
end
dawit=Dawit.new
puts dawit.fib_up_to(10) {|f| print f, " " } | true |
d0cc77f01e96d1b350bd2500757b840f4915fd43 | Ruby | seanredmond/marcman | /exe/marcman | UTF-8 | 1,658 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "launchy"
require "marcman"
options = {:browser => false,
:indicators => false,
:repeat=>false,
:subfields => false}
# show help if there is no field argument
ARGV << '-h' if ARGV.empty?
OptionParser.new do |opts|
opts.banner = "Usage: marcman [CODE] [... | true |
61395e2f16fdb558109be5af47738cdc371cfba8 | Ruby | michaeljb/wonders | /db/migrate/20150307035250_create_games.rb | UTF-8 | 1,022 | 2.546875 | 3 | [
"MIT"
] | permissive | class CreateGames < ActiveRecord::Migration
def self.up
create_table :games do |t|
t.date :date
t.integer :player_count
# using expansions?
t.boolean :cities
t.boolean :leaders
(1..8).to_a.each do |n|
# foreign key - Players
t.integer :"player#{n}"
#... | true |
61432c929890410e1717f47a6a7fefcd50d31ba5 | Ruby | patvice/dnsaur | /lib/dnsaur/email_manipulation.rb | UTF-8 | 3,086 | 2.875 | 3 | [
"MIT"
] | permissive | require 'pry'
module EmailManipulation
include Sift3Distance
DOMAIN_THRESHOLD = 4
TOP_LEVEL_THRESHOLD = 3
DEFAULT_ERROR = "default domains list can't be nil or empty"
TOP_LEVEL_ERROR = "default top level domains can't be nil or empty"
@@default_domains = ["yahoo.com", "google.com", "hotmail.com", "gmail... | true |
164e3b4c86ead3f404b564e835ae51913bd4595d | Ruby | tarekzemmouri/Hach | /lib/01_mairie.rb | UTF-8 | 1,443 | 3.40625 | 3 | [] | no_license | require 'pry'
require 'nokogiri'
require 'open-uri'
def get_one_town_mail(url)
#Url verification test
if is_valid_url?(url) == false
puts "Sorry, this isn't a valid url : #{url}"
return false
end
page = Nokogiri::HTML(URI.open(url))
email = page.xpath('//section[2]//tr[4]/td[2]').... | true |
3db4fd63785416d4ed2932b870a0818544d1eec7 | Ruby | NicGiles/SP | /spec/web_logs_spec.rb | UTF-8 | 2,355 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'web_logs'
require 'spec_helper'
describe WebLogs do
subject(:logs) { described_class.new(printer) }
let(:printer) { double :printer }
context 'Empty file uploaded.' do
before do
subject.create_sites_hash('./spec/empty_log.log')
end
describe '#order_sites' do
it 'Warns user if t... | true |
1ea9240f3888acfa5bc53b82024e8058e69ba0e2 | Ruby | NiushaH/school-domain-v-000 | /lib/school.rb | UTF-8 | 502 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_accessor :name, :grade_levels, :student_names
attr_reader :roster
def initialize(name)
@name = name
@roster = Hash.new { |g, n| g[n] = [] }
end
def add_student(student_names, grade_levels)
@roster[grade_levels] << student_names
end
def grade(grade_levels)
grade_levels = @... | true |
1519beb619af23a1d34decf55784597ca3e2be56 | Ruby | travishaby/javascript_idea_box | /app/models/idea.rb | UTF-8 | 401 | 2.578125 | 3 | [] | no_license | class Idea < ActiveRecord::Base
validates :title, :body, presence: true
enum quality: [:swill, :plausible, :genius]
def update_quality(quality_params)
new_quality = Idea.qualities[self.quality] + quality_params[:quality].to_i
if new_quality.between?(0, 2)
quality_params[:quality] = new_quality
... | true |
de4542e83c10afb8de56205ad3937fbe73dfe752 | Ruby | puradawid/people | /app/repositories/user_project_repository.rb | UTF-8 | 1,442 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class UserProjectRepository
attr_accessor :user, :user_membership_repository, :projects_repository
def initialize(user, user_membership_repository, projects_repository)
self.user = user
self.user_membership_repository = user_membership_repository
self.projects_repository = projects_repository
end
... | true |
80cf7a3905d628e4e82d161e8b39506fc4a70b0c | Ruby | tcast10/challenges | /blur_3.rb | UTF-8 | 1,232 | 3.859375 | 4 | [] | no_license | class Image
def initialize (pic)
@pic = pic
end
def get_ones
ones = []
@pic.each_with_index do |row, row_num|
row.each_with_index do |item, col_num|
if item == 1
ones << [row_num, col_num]
end
end
end
ones
end
def blur!(blur_dist)
... | true |
5bcf11671fce104fc74b166e39a72c45f884f9eb | Ruby | AndrewKhoo1/chitter-challenge | /lib/peep.rb | UTF-8 | 742 | 3.015625 | 3 | [] | no_license | require 'pg'
class Peep
attr_reader :id, :message
def initialize(id:, message:)
@id = id
@message = message
end
def self.all
connection = PG.connect(dbname: 'chitter')
result = connection.exec("SELECT * FROM peeps ORDER BY ID DESC")
result.map do |peep|
Peep.new(id: peep['id'], mess... | true |
03d641e4195c8a37540598b0baa83ae4082d8e50 | Ruby | ralphcnunez/OO-Get-Swole-nyc-web-071618 | /app/models/gym.rb | UTF-8 | 577 | 3.34375 | 3 | [] | no_license | class Gym
ALL = []
attr_reader :name
def initialize(name)
@name = name
ALL << self
end
def self.all
ALL
end
def memberships
Membership.all.select do |membership|
#calling Class Membership, method (all)
membership.gym == self
end
end
def lifters
memberships.collect do... | true |
accbc2aa4fea1bbf82e1787ea4c439d83b08616a | Ruby | peterhuene/puppet-ruby-host | /lib/puppet/type.rb | UTF-8 | 6,600 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | require 'puppet-ruby-host/loader'
require 'puppet-ruby-host/protocols/type'
require 'puppet/parameter'
require 'puppet/property'
require 'puppet/parameter/boolean'
# Minimum implementation of the Puppet 4 resource type API
module Puppet
# Represents a Puppet resource type.
module Type
attr_reader :name, :file,... | true |
c579e5d4fd7d37aef9daa859f37d79b02a9fb089 | Ruby | kazu-horie/ruby-blog-app | /spec/unit/lib/router_spec.rb | UTF-8 | 2,880 | 2.578125 | 3 | [] | no_license | RSpec.describe Router do
let(:routes_file_string) do
<<-ROUTES
config do
get '/', to: 'hello#index'
end
ROUTES
end
let(:router) { Router.new(routes_file_string) }
describe '#routes' do
context '@routes が未定義の場合' do
it 'instance_eval を実行していること' do
allow(router).to r... | true |
14723248b3b1505c18cadc05896a399be8f4ada4 | Ruby | apoc64/black_thursday | /lib/sales_analyst.rb | UTF-8 | 11,341 | 3.03125 | 3 | [] | no_license | require 'bigdecimal'
# Class that analyzes sales data
class SalesAnalyst
attr_reader :engine
def initialize(sales_engine)
@engine = sales_engine
end
def average_items_per_merchant
items = @engine.items.elements.count.to_f
merchants = @engine.merchants.elements.count.to_f
(items / merchants).ro... | true |
473a758167e7a26a015514a3f821233edd244cfb | Ruby | Alex223124/Object-Oriented-Programming-Exercises | /classes_and_objectsI_exercise_one.rb | UTF-8 | 748 | 3.96875 | 4 | [] | no_license | class MyCar
def initialize(y,c,m)
@year = y
@color = c
@model = m
@current_speed = 0
end
def speed_up(number)
@current_speed += number
puts "You hit the gas and acelerate by #{number} mph"
end
def brake(number)
@current_speed -= number
puts "You push the break and decelerate... | true |
367d121bc91c55406c267d48e57c07c9d165c4b8 | Ruby | hotsonlu/introduction_to_programming_launchschool | /more_stuff/ex3.rb | UTF-8 | 180 | 2.78125 | 3 | [] | no_license | # What is exception handling and what problem does it solve?
# Exception handling is a process that deals with errors, handling the errors in advance to avoid exiting the program. | true |
e64608c3b45f8fe7ebc45dc19a79ad75f0e0a6a7 | Ruby | dimitras/phospho_spectral_counts_among_conditions | /scripts/spectra_counts_summary_table.rb | UTF-8 | 3,500 | 2.609375 | 3 | [] | no_license | # ruby spectra_counts_summary_table.rb ../results/spectra_counts_for_phospho_soft_stiff_b1_b2.csv
# formula to sort commons in excel: =IF(AND(D2>=1,E2>=1),1, 0)
require 'csv_parser_for_protein_hits'
#
csvp_condition1 = CSVParserForProteinHits.open("../csvs/F003933_soft1-2_piped.csv", 100)
csvp_condition2 = CSVParser... | true |
1b5b49c1e89d8a4da6889d1d9772d646782685d9 | Ruby | PianoFF/oo-relationships-practice-london-web-102819 | /tools/console.rb | UTF-8 | 680 | 2.875 | 3 | [] | no_license | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
guest1=Guest.new ("Monica")
guest2=Guest.new ("Ross")
guest3=Guest.new ("Chandler")
guest4=Guest.new ("Cade")
listing1 = Listing.new("Philadelphia")
most_popular_listing = Listing.new("London")
listing3 = Listing.new("Chicago")... | true |
c4e5a7e7a4baabb3af8112a7cff0d0b73e2d835e | Ruby | jtescher/descriptive-statistics | /spec/lib/descriptive-statistics/central_tendency_spec.rb | UTF-8 | 1,715 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe DescriptiveStatistics::CentralTendency do
describe '#sum' do
it 'returns the amount attained by adding all numbers in the array' do
DescriptiveStatistics::Stats.new([1,2,6]).sum.should == 9
end
it 'allows a block to be passed' do
DescriptiveStatistics::Stats.ne... | true |
97c0c3c84178dab1f171f47fe94549d198685b54 | Ruby | yuriineb/smsworldhub | /lib/smsworldhub/sms.rb | UTF-8 | 1,616 | 2.546875 | 3 | [
"MIT"
] | permissive | module Smsworldhub
class Sms
require 'httparty'
def initialize token
@api_url = 'https://api.smsworldhub.com/v1/'
@token = token
end
def send phone, message, params={}
@params = { token: @token, phone: phone, mes: message }
@params.merge! params if params.any?
@response... | true |
d2e1eaf524d7546584377609a901dc71f667afc4 | Ruby | stormbrew/channel9 | /environments/ruby/simple_tests/005.while.rb | UTF-8 | 168 | 3.359375 | 3 | [
"MIT"
] | permissive | i = 0
while i < 5
puts(i)
i += 1
end
i = 0
until i == 5
puts(i)
i += 1
end
i = 0
while (i += 1) < 5
;
end
puts(i)
i = 0
until (i += 1) > 5
;
end
puts(i)
| true |
584beaeb7aaf2f97bbd3ebdf1eb70765dca9ee91 | Ruby | Bluette1/RubySpace | /recursion_practice/balanced_tree.rb | UTF-8 | 5,357 | 3.78125 | 4 | [
"MIT"
] | permissive | class ListNode
attr_accessor :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
end
end
module LinkedList
# setup head and tail
@head = nil
@tail = nil
def add(number)
new_node = ListNode.new(number)
if @head.nil?
@head = new_node
e... | true |
21366fe341a2e5833d135c8cafc898969b02219f | Ruby | VenkiPhy6/Ruby-basics | /09_arrays.rb | UTF-8 | 1,286 | 4.09375 | 4 | [] | no_license | lucky_stuff = [4,8,"fifteeen", 16,23, 42.0]
lucky_stuff[0] = 90 #Mutable
puts lucky_stuff[0]
puts lucky_stuff[-1]
#Indexing
print lucky_stuff[2,3] # Returns a list of selected stuff
puts
puts lucky_stuff[2,3] # Puts out selected stuff in newlines
print lucky_stuff[2..3]; puts
print "Check the code out for these! "
pri... | true |
f470b62ec38732724a8f497d8304410a4f2e924a | Ruby | sybitetechnologies/inline_encryption | /lib/inline_encryption/config.rb | UTF-8 | 1,163 | 2.875 | 3 | [
"MIT"
] | permissive | require 'hashie/extensions/indifferent_access'
require 'hashie/extensions/method_access'
require 'hashie/extensions/dash/indifferent_access'
require 'hashie/dash'
require 'openssl'
module InlineEncryption
# known configuration variables
# key - a String containing the private key, a filename pointing to the priva... | true |
8b31406de5c18af26dc4e1734485ce4aaa9e3614 | Ruby | S-ANANDS/Photos_Database | /Main_final.rb | UTF-8 | 573 | 2.765625 | 3 | [] | no_license | require 'pry'
require 'sqlite3'
photos=Dir.entries("pics")
db = SQLite3::Database.open('Photo.db')
db.execute 'CREATE TABLE IF NOT EXISTS Tasks(Id INTEGER PRIMARY KEY,Name VARCHAR)'
# db.execute " INSERT INTO Tasks(Id,Name) VALUES (NULL,'f') "
# db.execute " INSERT INTO Tasks(Id,Name) VALUES (NULL,'g') "
a=db.execute "... | true |
d0e927c83c25ae41ffb644df0685a498317c13bb | Ruby | ashleighchun/my-collect-v-000 | /lib/my_collect.rb | UTF-8 | 328 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
require "pry"
def my_collect(array)
modified_collection = []
i = 0
while i < array.length
modified_collection << yield(array[i])
i += 1
end
modified_collection
end
#my_collect does not modify the original collection
#yields correct element from collection
#returns new collection of modified elem... | true |
467793af7ec728a6cb1237970c71da3f270a1c03 | Ruby | jef4490/binary-search-tree-web-0217 | /binary_search_tree.rb | UTF-8 | 505 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class BST
attr_accessor :data, :left, :right
def initialize(data)
@data = data
end
def insert(value)
if value <= data
if !self.left
self.left = BST.new(value)
else
self.left.insert(value)
end
else
if !self.right
self.right = BST.new(valu... | true |
5ca9c29a9d6120e8b5078323b194ba03474b1a4b | Ruby | yumojin/Example-Sketches | /samples/processing_app/basics/shape/load_display_shape.rb | UTF-8 | 537 | 2.796875 | 3 | [
"MIT"
] | permissive | # Load and Display a Shape.
# Illustration by George Brower.
#
# The loadShape() command is used to read simple SVG (Scalable Vector Graphics)
# files into a Processing sketch. This library was specifically tested under
# SVG files created from Adobe Illustrator. For now, we can't guarantee that
# it'll work for SV... | true |
3f5652605c0d88e013f7f07585ecb0f9200bd13f | Ruby | malinatran/tic-tac-toe-ruby | /spec/game_spec.rb | UTF-8 | 1,856 | 2.9375 | 3 | [] | no_license | require_relative "spec_helper"
require_relative "../lib/game"
module TicTacToe
describe TicTacToe::Game do
let(:board) { Board.new }
let(:computer_player) { ComputerPlayer.new }
let(:human_player) { HumanPlayer.new }
let(:user_interface) { UserInterface.new(ui_helper, validator) }
... | true |
756ba6763fe145770263ed004cebd0d21b84ab8c | Ruby | BuildEmpire/query_empire | /lib/query_empire/filter.rb | UTF-8 | 1,084 | 3.015625 | 3 | [
"MIT"
] | permissive | class QueryEmpire::Filter
attr_accessor :field, :operator, :value
def initialize(field, operator, value)
@field = field
@operator = operator
@value = value
end
def query
field = field_reference
case operator
when :lt
return "#{field} < ?", value
when :lte
return... | true |
8b0a8f0970cf9a7b81e532cc2432a851a27d3af0 | Ruby | theroncross/phase-0-tracks | /ruby/hamsters.rb | UTF-8 | 519 | 3.78125 | 4 | [] | no_license | puts "Hamster's name?"
name = gets.chomp
puts 'How loud is your hamster from 1-10?'
volume = gets.chomp.to_i
puts 'What is their fur color?'
fur_color = gets.chomp
puts 'Is the hamster a good candidate for adoption? (y/n)'
adoptable = gets.chomp == 'y' ? true : false
puts 'What is their estimated age?'
age = gets.c... | true |
6b8b3a3a9e270428c891caabedb5da0df4c98aac | Ruby | Calvinoea/webscraper-capstone-project | /lib/books_scraper.rb | UTF-8 | 943 | 3.09375 | 3 | [
"MIT"
] | permissive | # lib/books_scraper.rb
require 'nokogiri'
require 'open-uri'
require 'json'
class Books # :nodoc:
URL = 'https://www.waterstones.com/campaign/books-of-the-month'.freeze
def initialize
@list_of_books = []
@json_array = []
end
def top_books
hash = extract_books
return unless hash
hash.each... | true |
8d6084214d12d76486b02dc090db04b748683e6d | Ruby | h4hany/yeet-the-leet | /algorithms/Hard/1274.number-of-ships-in-a-rectangle.rb | UTF-8 | 2,009 | 3.671875 | 4 | [] | no_license | #
# @lc app=leetcode id=1274 lang=ruby
#
# [1274] Number of Ships in a Rectangle
#
# https://leetcode.com/problems/number-of-ships-in-a-rectangle/description/
#
# algorithms
# Hard (65.73%)
# Total Accepted: 4.6K
# Total Submissions: 7K
# Testcase Example: '[[1,1],[2,2],[3,3],[5,5]]\n[4,4]\n[0,0]'
#
# (This problem... | true |
28d12059c6b08e317c3ad335c62a138e6baa0a84 | Ruby | GHogChi/FloorSweepingsCraftsmanSpike | /pipeline/w1913_entry_extractor_spec.rb | UTF-8 | 882 | 2.921875 | 3 | [] | no_license | require 'pipeline/w1913_entry_extractor'
describe W1913EntryExtractor do
EOS = '===EOS==='
before(:each) do
@inqueue = Queue.new
@outqueue = Queue.new
end
it "should put EOS on queue when no entries in input" do
extractor = W1913EntryExtractor.new('xyz','def', EOS)
@inqueue << EOS
run... | true |
aa0e577dc871b30ff6ae5ffd321498610eb060b6 | Ruby | tos-miyake/rufo | /spec/lib/rufo/formatter_source_specs/case.rb.spec | UTF-8 | 2,397 | 3.15625 | 3 | [
"MIT"
] | permissive | #~# ORIGINAL
case
when 1 then 2
end
#~# EXPECTED
case
when 1 then 2
end
#~# ORIGINAL
case
when 1 then 2
when 3 then 4
end
#~# EXPECTED
case
when 1 then 2
when 3 then 4
end
#~# ORIGINAL
case
when 1 then 2 else 3
end
#~# EXPECTED
case
when 1 then 2
else 3
end
#~# ORIGINAL
case
when 1 ; 2 ... | true |
93d04de74b2f693cdfbd9abc54fcab46013d34ba | Ruby | JanLenaerts/Ruby | /Tutsplus - Ruby For Newbies/lesson5.rb | UTF-8 | 449 | 3.203125 | 3 | [] | no_license | name = "Joe"
name.reverse # => "eoJ"
name.concat(" the Plumber") # => "Joe the Plumber"
sites = ["net", "psd", "mobile"]
sites.map! do |site|
site += ".tutsplus.com"
end
puts sites[1]
sites = ["net", "psd", "mobile"]
sites.each { |site|
puts "#{site}.tutsplus.com"
}
sites = sites.map do |s|
"#{s}.tutsplus.... | true |
d16f39170382749ea95f4d5be7f48358bc258445 | Ruby | hellgirl/coffee_back | /app/services/drink_total_calculator.rb | UTF-8 | 358 | 2.71875 | 3 | [] | no_license | class DrinkTotalCalculator
def initialize(params)
@params = params
end
def total
drink_price + additions_price
end
private
def drink_price
::DrinksVolume.find(@params.fetch(:drinks_volume_id)).price
end
def additions_price
::DrinkAddition.where(id: @params.fetch(:drink_addition_ids, ... | true |
08b35bcf5454df0cfb6547a41c158f1e59032bb4 | Ruby | EgorBelyaev/test23.03 | /hello.rb | UTF-8 | 168 | 3.25 | 3 | [] | no_license | def hello number
i=0
while i<number
puts 'Hello World!'
i=i+1
end
end
def bye
puts 'Bye...'
end
if __FILE__ == $0
hello 2
bye
end | true |
a0bb4021d22295f121bd5bef81d37921f56ee685 | Ruby | puppetlabs/facter-test | /lib/facter/framework/core/fact_filter.rb | UTF-8 | 1,299 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Facter
# Filter inside value of a fact.
# e.g. os.release.major is the user query, os.release is the fact
# and major is the filter criteria inside tha fact
class FactFilter
def filter_facts!(searched_facts)
filter_legacy_facts!(searched_facts)
filter_blocke... | true |
023df69dd1f8ddad2f8bae0efde5bebafc620bfe | Ruby | fhayes301/Tech_Interview_Prep | /Cracking the Coding Interview/Ch-1: Arrays and Strings/C1.5.rb | UTF-8 | 1,124 | 4.0625 | 4 | [] | no_license | # There are three types of edits that can be performed on strings: insert a character,
# remove a character, or replace a character. Given two strings, write a function to check if they are
# fone edit (or zero edits) away.There are three types of edits that can be performed on strings: insert a character,
# remove a c... | true |
b9958b30d123c6bcc2de23e5464c504992dcabf1 | Ruby | tomoya55/gracenote-rb | /lib/gracenote/response/base.rb | UTF-8 | 647 | 2.625 | 3 | [
"MIT"
] | permissive | module Gracenote
class Response
class Base
include Helper
def self.attributes=(attrs)
attrs.each do |attr|
define_method(attr) do
self[attr]
end
end
end
def initialize(response)
@response = response
end
def [](attr)
... | true |
f90d0ee9a5cdc9a13a589a9d5e0ccfa906481ca9 | Ruby | fela/rlid | /lib/rlid/subtitles/create_corpora.rb | UTF-8 | 2,459 | 2.765625 | 3 | [
"MIT-0"
] | permissive | #!/usr/bin/env ruby1.9.1
require 'rlid/common'
class String
def cleanup!
# strip spaces at start and end of lines
gsub!(/^\s*/, '')
gsub!(/\s*$/, '')
# strip quotes when a line is 'text', or "text"
gsub!(/^(['"])(.*)\1$/, '\2')
# remove songs and descriptions for the deaf, etc. and similar b... | true |
b5661d72baa8ffdacfd7592f6f09ca4baac90648 | Ruby | jaedashson/appacademy_homework | /W3D5/map.rb | UTF-8 | 741 | 3.53125 | 4 | [] | no_license | class Map
def initialize
@map = []
end
def set(key, value)
@map.each_with_index do |pair, i|
if pair[0] == key
@map[i] = [key, value]
return
end
end
@map << [key, value]
end
def get(key)
@map.each do |... | true |
2839eaf15d2b5e3c8411e8cc4c42893cef3b6fbe | Ruby | AlexeyNechitailo/stomp | /examples/client_conndisc.rb | UTF-8 | 1,745 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | # -*- encoding: utf-8 -*-
#
# The current require dance for different Ruby versions.
# Change this to suit your requirements.
#
if Kernel.respond_to?(:require_relative)
require_relative("./stomp_common")
else
$LOAD_PATH << File.dirname(__FILE__)
require "stomp_common"
end
include Stomp1xCommon
#
# == Stomp Clie... | true |
655ddd4b00965b5ed525c3d8a33d84d586414e2b | Ruby | sordiz/LearnToProgram | /electoral_college.rb | UTF-8 | 1,220 | 3.203125 | 3 | [] | no_license | class ElectoralCollege
public
def calculate_winning_temperature(electorate)
return winning_temperature(collect_temperatures(electorate))
end
private
def collect_temperatures(electorate)
temperatures = Array.new
electorate.each do |voter|
case voter.category
when "SM... | true |
969936a15a897a2c0ce1ce30b6d8858a7413f540 | Ruby | Iknewthisguy/yield_star_client | /lib/yield_star_client/property_methods.rb | UTF-8 | 6,164 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'yield_star_client/validations'
require 'modelish'
module YieldStarClient
# Represents a property in the YieldStar system.
#
# A property is guaranteed to have an +external_property_id+ and +name+; all other attributes are optional.
#
# @attr [String] external_property_id the property ID
# @attr [S... | true |
1c0d82f8d3f56bf015adac19dc211dfd5f4a3227 | Ruby | courtland/tacacs_plus | /lib/tacacs_fields.rb | UTF-8 | 55,329 | 3.09375 | 3 | [
"Ruby"
] | permissive | module TacacsPlus
# the 'action' field
module Action #:nodoc: all
# CONSTANTS
# action
TAC_PLUS_AUTHEN_LOGIN = 0x01
TAC_PLUS_AUTHEN_CHPASS = 0x02
TAC_PLUS_AUTHEN_SENDPASS = 0x03 #(deprecated)
TAC_PLUS_AUTHEN_SENDAUTH = 0x04
ACTION_XLATES = {TAC_PLUS_AUTHEN_LOGIN => "Login",
... | true |
8ba13d1f0e9c8f2858c88b1bdb8d8d3e81472213 | Ruby | thestrauss3/CodeWars | /ruby/square_digits.rb | UTF-8 | 757 | 4.25 | 4 | [] | no_license | # Description:
#
# Welcome. In this kata, you are asked to square every digit of a number.
#
# For example, if we run 9119 through the function, 811181 will come out.
#
# Note: The function accepts an integer and returns an integer
def square_digits(num)
arr = num.to_s.chars.map(&:to_i)
arr.map! {|x| x*x }
arr.j... | true |
9d690aa7bab82ad4759e58e318bad698e440cb9a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/e0fc752feac041fbb8057774e62453d5.rb | UTF-8 | 224 | 3.25 | 3 | [] | no_license | class Hamming
def self.compute(str1,str2)
diff = 0
shorter_length = [str1.length, str2.length].min
for i in 0...shorter_length
if str1[i] != str2[i]
diff += 1
end
end
return diff
end
end
| true |
12f7a824e7d71848e5cd286a30200aa65719eb44 | Ruby | AndrewKairys/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 531 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
attendees.map do |i|
"Hello, my name is #{i}."
end
end
def assign_rooms(name)
name.map.with_index do |name, index|
"Hello, #{name}! You'll be assigned to room #{index + 1}!"
end
end
d... | true |
008ed5ae9781503f9ca4c2ad9e12362f2f93865a | Ruby | saturnflyer/strftime | /lib/strftime/directive.rb | UTF-8 | 11,124 | 2.6875 | 3 | [
"MIT"
] | permissive | module Strftime
class Directive
attr_accessor :key
attr_accessor :description
attr_accessor :example
attr_accessor :matcher
attr_accessor :related
@all = []
def initialize(key, description:, example:, matcher:, related: [])
self.key = key
self.description = description
... | true |
8a039d678f77ad3cbe91e9bb4b6b90f50bdbc978 | Ruby | stuartweir/Exercism | /ruby/hexadecimal/hexadecimal.rb | UTF-8 | 765 | 3.640625 | 4 | [] | no_license | # frozen_string_literal: true
class Hexadecimal
HEX_CHAR_MAPPING = {
'A' => 10,
'B' => 11,
'C' => 12,
'D' => 13,
'E' => 14,
'F' => 15
}.freeze
private
attr_reader :hex_string, :hex_chars
public
def initialize(hex_str)
@hex_string = hex_str.upcase
@hex_chars = format_hex_... | true |
30e7957c90adfb87e664f75405136046af1edc80 | Ruby | spejamchr/code | /other_ruby/virus.rb | UTF-8 | 350 | 3.34375 | 3 | [] | no_license | class Grid
COLUMNS = 160
ROWS = 24
def initialize
@grid = Array.new(ROWS){Array.new(COLUMNS, '.')}
end
def display
@grid.each { |row| puts row.join }
end
def infect
@grid[rand(ROWS)][rand(COLUMNS)] = 'O'
end
def spread
end
end
a = Grid.new
a.display
5.times do
sleep(0.2)
a.spre... | true |
09e902d6b42b1695b1a097aac3d136da20f5e642 | Ruby | acanshul/ruby_programs | /009.perfect_number_range.rb | UTF-8 | 487 | 4 | 4 | [] | no_license | # Print the list of perfect numbers within given range
print "Enter minimum range: "
min = gets.chomp.to_i
print "Enter maximum range: "
max = gets.chomp.to_i
if min > max
puts "Wrong Range! Please, Try Again."
exit
end
print "Perfect numbers in the given range are: "
#(min..max).each do |x|
for x ... | true |
0312147f9aff60aac5c2b346dee41f18c2a106e1 | Ruby | bschmeck/dotfiles | /symlinks/vpn.link | UTF-8 | 775 | 2.8125 | 3 | [] | no_license | #! /usr/bin/env ruby
CONNECTION_NAMES = {
"amex" => "Kenna Amex",
"boa" => "Kenna BoA",
"ds" => "Kenna Data Services",
"gcp" => "Kenna GCP",
"internal" => "Kenna Internal",
"nyc3" => "Kenna NYC3",
"us" => "Kenna US"
}
def names_for(conns)
conns = %w[internal] if conns.empty?
conns.map{|c| CONNECTIO... | true |
2de291b59e2b0db344835ed6d9e1b8d17f53ddc4 | Ruby | mithunder916/ruby | /class7/movieinputalt.rb | UTF-8 | 521 | 3.875 | 4 | [] | no_license | class Movie
attr_reader :name, :year, :director
attr_accessor :rating
def initialize(name, year, director, rating)
@name=name
@year=year
@director=director
@rating=rating
end
end
puts "Name your favorite movie?"
w=gets.chomp
puts "What year was that in?"
x= gets.chomp
puts "Who is the director... | true |
b84676a67d0cc07047503d0eae396b2f49962c3e | Ruby | gladys496/countdown-to-midnight-onl01-seng-pt-012120 | /countdown.rb | UTF-8 | 135 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def count_down(seconds)
while seconds > 0
puts "#{seconds} Second(s)"
second -=
end
"Happy New Year!"
end
| true |
ed5e7c73c1f709a73742023e1bea3fd90e9c01d1 | Ruby | gattik/exercises | /09 spaceage.rb | UTF-8 | 1,217 | 4.0625 | 4 | [] | no_license | require 'date'
class Seconds
def initialize
@s_rep = ["Earth", "Mercury", "Venus","Mars", "Jupiter", "Saturn",
"Uranus", "Neptune"]
@planets = [31557600, 760064796, 1941423552, 5935416523, 37435581691,
92929242600,265137014600, 520041856000]
end
def print_q
puts "Please select an option below."
puts "... | true |
5b1bb64a2f848c988fd29c39d0d6b944dbc76c79 | Ruby | companionstudio/islay | /app/asset_management/asset_worker.rb | UTF-8 | 1,459 | 2.640625 | 3 | [
"MIT"
] | permissive | class AssetWorker
def self.enqueue!(asset, mode, opts = {})
ASSET_QUEUE << self.new(asset, mode, opts)
end
# Stores the options to be used later when perform is run.
#
# @param Asset asset
# @param Symbol mode
# @param Hash opts
def initialize(asset, mode, opts = {})
@asset = asset
@mode = ... | true |
4517127f7c2fe629db7560142014e39dfcfc6ea7 | Ruby | venuu/jsonapi-authorization | /lib/jsonapi/authorization/default_pundit_authorizer.rb | UTF-8 | 12,248 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module JSONAPI
module Authorization
# An authorizer is a class responsible for linking JSONAPI operations to
# your choice of authorization mechanism.
#
# This class uses Pundit for authorization. You can use your own authorizer
# class instead if you have different ... | true |
010bbb4abc91c268bcba991f3c56617a00c4c519 | Ruby | KnVerey/test_first_ruby | /change.rb | UTF-8 | 237 | 3.640625 | 4 | [] | no_license | class Changer
def self.make_change(num)
hand_back = []
(num/25).times { hand_back << 25 }
(num%25/10).times { hand_back << 10 }
(num%25%10/5).times { hand_back << 5 }
(num%25%20%5).times { hand_back << 1 }
hand_back
end
end | true |
db4326bf4b723b079be64e35b8f4aeb2aeb88a0e | Ruby | wing-x/ABC | /012B.rb | UTF-8 | 1,452 | 3.375 | 3 | [] | no_license | n = gets.to_i
t = Time.at(n).utc.strftime("%H:%M:%S")
puts t
=begin
n(秒数)→hh:mm:ssに変換する問題
strftimeを使えば簡単っぽいな、便利そうだし使い方を覚えておこう
結構補則しておかないと駄目だな
・使う時はTimeメソッドを使う必要がある。
・Time.at(time)で時間を決めるが、
a = Time.at(0)
#=>1970-01-01 09:00:00 +0900 であることに注意
a =Time.at(n).utc
#=>1970-01-01 00:00:00 UTC
.utcをつけることで午前0時にする事が... | true |
859572803247810ebb3cbfc0f377a3523d2c4feb | Ruby | RANA-AKBAR/SPENDING_TRACKER_PROJECT | /models/transaction.rb | UTF-8 | 2,702 | 2.765625 | 3 | [] | no_license | class Transaction
attr_reader :id
attr_accessor :amount, :date, :merchant_id, :spendingtag_id
def initialize(options)
@id = options['id'].to_i if options['id']
@amount = options['amount'].to_f
@date = options['date']
@spendingtag_id = options['spendingtag_id']
@merchant_id = options['merchant... | true |
b6e2aaa1ac768631b6663bad069ae2b2663737a9 | Ruby | Sambi85/ruby-oo-relationships-practice-boating-school-exercise-nyc01-seng-ft-071320 | /app/models/instructor.rb | UTF-8 | 1,519 | 3.34375 | 3 | [] | no_license | class Instructor
attr_accessor :name
@@all = []
def initialize(name)
@name = name
Instructor.all << self
end
def self.all
@@all
end
def tests
BoatingTest.all.select do |bt|
bt.instructor == self
end
end
def pass_student(studen... | true |
e7d3fdc93ff5010213a68fad9f655d0aff13135e | Ruby | christopherdanella/phase-0-tracks | /ruby/shout-2.rb | UTF-8 | 704 | 4.125 | 4 | [] | no_license | # module Shout
#
# def self.yell_angrily(words)
# words + "!!!" + " :("
# end
#
#
# def self.yelling_happily(happy_words)
# happy_words + "!" + " :D"
# end
# end
#
# p Shout.yell_angrily("WHAT ARE YOU DOING?")
# p Shout.yelling_happily("Great job")
module Shout
def surprise_shout(words)
wor... | true |
758ccbc6bfc7c4cf7a493a811150f49c518d8b39 | Ruby | clay-f/algorithms-practice | /combination_sumIII216.rb | UTF-8 | 476 | 3.46875 | 3 | [] | no_license | # Find all possible combinations of k numbers that add up to a number n
# given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.
def combination_sum3(k, n)
arr = (1..('9'*k).to_i).map { |i| i }
result =
arr.each_with_object([]) do |i, arr|
arr.push(i.to... | true |
1c25d7386378ead844d5295d67bcf0464ed55e79 | Ruby | forestgood/pingpong | /app/models/user.rb | UTF-8 | 841 | 2.515625 | 3 | [] | no_license | # == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# fname :string(255)
# lname :string(255)
# email :string(255)
# company :string(255)
# location :string(255)
# pong :boolean
# created_at :datetime not null
# updated_at :date... | true |
da2e0618d55ec0003c8c6c17b9d81b0c0294f472 | Ruby | ajpagente/Stark | /stark/parser/notesparser.rb | UTF-8 | 217 | 2.6875 | 3 | [
"MIT"
] | permissive | module Stark
class NotesParser
attr_reader :notes
def initialize()
@notes = ""
end
def parse(filename)
@filename = filename
@notes = File.read(@filename)
end
end
end
| true |
fb674cf4e78f4c12e3cef14f2e67d08d334768f8 | Ruby | redding/scmd | /lib/scmd/stored_commands.rb | UTF-8 | 1,313 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "scmd/command_spy"
module Scmd
class StoredCommands
attr_reader :hash
def initialize
@hash = Hash.new{ |h, k| h[k] = Stub.new(k) }
end
def add(cmd_str, &block)
@hash[cmd_str].tap{ |s| s.set_default_proc(&block) }
end
def get(cmd_str, opts ... | true |
245a9eafbf19421fd5758bd36ca536b8d97de11b | Ruby | joegiralt/digitalocean_intro | /app.rb | UTF-8 | 1,190 | 2.703125 | 3 | [] | no_license | require 'sinatra/base'
require './persistable.rb'
require './student.rb'
require 'sqlite3'
# Why is it a good idea to wrap our App class in a module?
module StudentSite
class App < Sinatra::Base
get '/' do
"hello world!"
end
get '/hello-world' do
@random_numbers = (1..20).to_a
er... | true |
7c0eecd0e41a2adb8f3534ab31f7f06669796754 | Ruby | yogo/yogo | /spec/models/model_definitions/matchers.rb | UTF-8 | 2,272 | 2.546875 | 3 | [
"MIT"
] | permissive | Spec::Matchers.define :be_json do
match do |text|
lambda { JSON.parse(text) }.should_not raise_exception
end
end
Spec::Matchers.define :have_valid_model_id do |id_key|
id_key ||= 'guid'
match do |model_def|
model_def.should have_key(id_key)
id = model_def[id_key]
id.should_not be_nil
id.... | true |
c6e0cb4817329c27b6002fd63d7b8b777be6f219 | Ruby | NEsfandiari/Ruby_Personal_Projects | /http_server.rb | UTF-8 | 1,549 | 2.890625 | 3 | [] | no_license | require 'socket'
def main
socket = Socket.new(:INET, :STREAM)
socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
socket.bind(Addrinfo.tcp('127.0.0.1', 9000))
socket.listen(0)
conn_sock, addr_info = socket.accept
conn = Connection.new(conn_sock)
request = read_request(conn)
respond_to_req... | true |
46fcf728b46a575bfb31b65ba69fc61f0c15647a | Ruby | brianjbeach/aws-database-migration-samples | /mongodb/sampledb/v1/schema/load_sport.rb | UTF-8 | 2,625 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
#
# Copyright 2017 Amazon.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | true |
e0183fd414424743e9bf4b47a6268cc0a6f6cc0d | Ruby | dmbf29/cookbook-394 | /lib/controller.rb | UTF-8 | 1,703 | 3.359375 | 3 | [] | no_license | require_relative 'view'
require_relative 'scrape_bbc_service'
class Controller
def initialize(cookbook)
@cookbook = cookbook
@view = View.new
end
# inside instance methods, always have access to instance variables
def list
display_recipes
end
def create
name = @view.ask_user_for_recipe_na... | true |
712deaee92cdbbdbc429532742397c04ed65e44d | Ruby | harakonan/misc-codes | /Ruby/rubytest/test2/time3.rb | UTF-8 | 169 | 2.953125 | 3 | [] | no_license | t = Time.now
strTime = t.strftime("現在時刻 %H時 %M分 %S秒")
print(strTime, "\n")
strDay = t.strftime("現在日時 %B,%d(%A) %Y %Z")
print(strDay, "\n") | true |
e58bd9f0c6765f8bce8b48e265877d345394cdcd | Ruby | yasufumic/ruby | /happy_birth.rb | UTF-8 | 93 | 3.359375 | 3 | [
"MIT"
] | permissive | name = ARGV[0]
print "Happy birthday, ", name, "!\n"
puts
print "Happy birthday, #{name}!\n"
| true |
c3ac149ceb75fd171d45528d60356fd7f8cdbe9c | Ruby | eeshan9815/mongo-abac | /lib/mongo-abac/proxy.rb | UTF-8 | 17,380 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'em-proxy'
require 'logger'
require 'json'
require 'pp'
require 'socket'
require 'timeout'
require 'tod'
require 'openssl'
require 'base64'
class PeriodicEvents
def initialize(validity, time_of_day_range, days_of_week_range, dates_of_month_range, months_of_year_range, special_keywords)
@validity = validi... | true |
cf625768c4fc18401830e293e9a23d44dd42ab37 | Ruby | Florenceheng23/exos0607 | /exo_13.rb | UTF-8 | 62 | 2.578125 | 3 | [] | no_license |
50.times do |i|
puts i + 1
puts "jean.dupont.0#{i}@email.fr"
end
| true |
5d799d3e5ef31c92902df753d0f98f47f7f0294a | Ruby | matblair/SWEN30006-2015-SEM1 | /workshops/1 - ruby/Solution/e2.rb | UTF-8 | 296 | 3.125 | 3 | [] | no_license | ## Exampl solns
def odd_even_array a
(a.inject(0){|s,x| (x.odd?) ? s-=1 : s+= 1 })>=0 ? :odd : :even
end
def sum_binary a
a.reduce(:+).to_s(2)
end
def average a
a.reduce(:+)/a.count.to_f
end
def flatten_array a
a.inject([]){|f,e| e.instance_of? Array ? (f+flatten_array(e)) : f<<e }
end3. | true |
ee9ec8aec97450e324d286029bd2440954162605 | Ruby | StevenXL/testfirst | /04_pig_latin/pig_latin.rb | UTF-8 | 1,664 | 4.65625 | 5 | [] | no_license | # i have a hard time coding with the splat operator (used in the translate
# method below). Let's review how the splat operator works:
#
# The splat operator is used to create methods that have a variable parameter
# list - i.e., they can take any number of parameters. This parameter list is,
# in fact, a list, and wh... | true |
c802901c2bfcc306ba23e765a6148f26d560cae8 | Ruby | Anne-So/WernickeZone | /app/controllers/tat_controller.rb | UTF-8 | 3,444 | 2.59375 | 3 | [] | no_license | # coding: utf-8
class TatController < ApplicationController
def index
#Initialise les données liées à la session de l'utilisateur
session[:splitter] = '|-@-|'
if !session[:key].nil?
@tat = Tat.find(session[:key])
end
if @tat.nil?
@tat = Tat.new
@tat.step = "init"
@tat.save!... | true |
79e69516389e76196e779e22fcd339b428a7f8a8 | Ruby | PradeepLogu/testdev | /lib/tasks/__Scrape_TireMonkey.rake | UTF-8 | 5,967 | 2.59375 | 3 | [] | no_license | require 'nokogiri'
require 'rest_client'
namespace :ScrapeTireMonkey do
desc "Get tire information from TireMonkey.com"
task populate: :environment do
brands = ["Mastercraft", "Goodyear", "Uniroyal", "Cooper",
"Firestone", "Continental", "Kumho", "Yokohama",
"Mic... | true |
42e050799d3f4d67fb85c0b1f6e4854a7890da4d | Ruby | CSavi/operators-v-000 | /lib/operations.rb | UTF-8 | 185 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def unsafe?(speed)
return true if speed < 40 || speed > 60
return false else
end
def not_safe?(speed)
speed < 40 || speed > 60 ? true : false
binding.pry
end
| true |
c7c16f1573adf7dde79efa1c32018a581f23980e | Ruby | joan2kus/ChartDirector | /railsdemo/app/controllers/threedbubble2_controller.rb | UTF-8 | 2,460 | 2.59375 | 3 | [
"IJG"
] | permissive | require("chartdirector")
class Threedbubble2Controller < ApplicationController
def index()
@title = "3D Bubble Chart (2)"
@ctrl_file = File.expand_path(__FILE__)
@noOfCharts = 1
render :template => "templates/chartview"
end
#
# Render and deliver the chart
#
de... | true |
170fa74bbaf3e50f70fc0a9820fc9c1425f47c30 | Ruby | tehAnswer/space_invaders | /lib/space_invaders.rb | UTF-8 | 570 | 2.6875 | 3 | [
"MIT"
] | permissive | require_relative 'space_invaders/refinements/pattern_matching'
Dir[File.expand_path('../space_invaders/*.rb', __FILE__)].reverse.each { |f| require f }
require 'colorize'
module SpaceInvaders
def self.scan(file_path)
# TODO: Validate whether the file is valid or not. The instructions didn't specify any formal do... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.