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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1b9cb7d7a23219fe6e61e41c8d086384e18f7516 | Ruby | jch/whatcodecraves.com | /app/models/post.rb | UTF-8 | 3,806 | 3 | 3 | [] | no_license | require 'date'
require 'pathname_extensions'
# A blog post is a directory with an index.text document found within `root_path`.
class Post
class Error < StandardError
attr_reader :post
def initialize(post, message)
@post = post
super("#{post.permalink}: #{message}")
end
end
class << self... | true |
18c0484f5e53c60364d1f7ec3dc1944db2534d3f | Ruby | josei/tron3000 | /code/entities/homing.rb | UTF-8 | 562 | 2.65625 | 3 | [
"MIT"
] | permissive | module Homing
def self.included klass
klass.class_eval do
follow nil
homing_strategy :best
homing_method do case @homing_strategy
when :best; method(:best_angle)
when :closest; method(:closest_angle)
end
... | true |
0d61a665de2df8336a8cb7f32509095b9bb51ebb | Ruby | tengyuma/cs229t-percy | /lectures/otl2tex | UTF-8 | 11,052 | 2.96875 | 3 | [] | no_license | #!/usr/bin/ruby
# Converts an outline file (otl) into a latex file.
# Input: <file.otl>
# Output: <file.tex>
# Format of an OTL file:
# !format TSI
# !documentclass[12pt]{article}
# !preamble \usepackage{mystyle}
# !include- macros.otl (- means don't include again if already included)
# !verbatim: include stuff direc... | true |
01cd58ca3d8d050a8ffc6ddd6b879cd37e1a3331 | Ruby | claeusdev/algorithms | /leetcode/Leetcode 26. Remove Duplicates from Sorted Array.rb | UTF-8 | 1,835 | 4.3125 | 4 | [
"MIT"
] | permissive | # Given a sorted array, remove the duplicates
# in place such that each element appear only once
# and return the new length.
#
# Do not allocate extra space for another array,
# you must do this in place with constant memory.
#
# For example,
# Given input array nums = [1,1,2],
#
# Your function should return length =... | true |
00f7d123d0b443a2ed8990d7b37e54df1dd0e026 | Ruby | mindfire-solutions/survey | /app/models/survey/survey_evaluation_item.rb | UTF-8 | 3,252 | 2.5625 | 3 | [
"MIT"
] | permissive | #app/models/survey/survey_evaluation_item.rb
module Survey
class SurveyEvaluationItem < ActiveRecord::Base
set_table_name "survey_evaluation_items"
attr_accessible :parent_id, :evaluation_id, :question_id, :answer_text, :level, :children_attributes
attr_accessible :question_set_item_id
belongs_to :evaluatio... | true |
890543a0ebffaba650d000d7c021270bbf95ee97 | Ruby | gregors/boilerpipe-ruby | /lib/boilerpipe/filters/terminating_blocks_finder.rb | UTF-8 | 1,509 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # Finds blocks which are potentially indicating the end of an article
# text and marks them with INDICATES_END_OF_TEXT. This can be used
# in conjunction with a downstream IgnoreBlocksAfterContentFilter.
module Boilerpipe::Filters
class TerminatingBlocksFinder
def self.process(doc)
doc.text_blocks.each do ... | true |
e80055239e8f2803fcdb280fcac647b66d9445f7 | Ruby | johnto20/tealeaf_course | /Intro_to_programming/loops_and_iterators/exercise_3.rb | UTF-8 | 150 | 3.34375 | 3 | [] | no_license | array1 = ["John", "Jim", "Andrew","Adelaide", "Sarah", "Johnny"]
array1.each_with_index do |name, index|
puts "#{index}" + ". " + "#{name}"
end | true |
c62ed7f72a2929106634e714bf02cf203598911e | Ruby | siakaramalegos/assignment_rspec_ruby_tdd | /spec/stock_spec.rb | UTF-8 | 887 | 3.5 | 4 | [] | no_license | require_relative '../lib/stock.rb'
describe '#stock' do
it 'should raise an error if an argument is not given' do
expect{stock}.to raise_error(ArgumentError)
end
# TODO: Better way to do this? arg.to be_Array?
it 'should only accept an array as an argument' do
expect{stock(1)}.to raise_error("Oops,... | true |
cc10e44ec9cd5f17d182b85092ea6c4e9b69c36f | Ruby | josephelias-techversant/Calender | /Ruby/sample.rb | UTF-8 | 622 | 4 | 4 | [] | no_license | #Sample code to prompt user to enter his name
puts "Enter your name: "
first_name = gets.chomp
puts "Hi #{first_name}, welcome to Ruby!"
#The below lines will create a file or over write the exisitng file
File.open('file2.txt', 'a+') do |f|
f.puts "This is JavaTpoint"
f.write "You are reading Ruby tu... | true |
83563d9f0d5257ed408cf6b12ce93731cef52ea8 | Ruby | levbrie/rails_tutorial_app | /app/controllers/users_controller.rb | UTF-8 | 3,345 | 2.6875 | 3 | [] | no_license | class UsersController < ApplicationController
# before filter arranges for a method to be called before the given actions
# following and followers actions in the signed_in_user filter enables us
# to set title, find user, and retrieve followed_users or followers using defs
before_filter :signed_in_user,
... | true |
82d3873b5f8df92276316d9492b202158455633d | Ruby | emanon001/atcoder-ruby | /joi2014yo/d/main.rb | UTF-8 | 831 | 2.984375 | 3 | [] | no_license | N = gets.to_i
R = gets.chomp.chars
MOD = 10 ** 4 + 7
def r_to_k(r)
case r
when 'J' then 0
when 'O' then 1
when 'I' then 2
end
end
dp = Array.new(N + 1) { Array.new(1 << 3, 0) }
dp[0][1] = 1
N.times do |i|
r = R[i]
(1..7).each do |bits|
next if dp[i][bits] == 0
next_value = Array.new(1 << 3, 0)
... | true |
5df0211c754c9be3349a98273be4c0f76f19c134 | Ruby | volunteermatch/vm-contrib | /archive/api-examples-v2/generate_credentials/generate_credentials.rb | UTF-8 | 789 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'base64'
require 'digest/sha2'
if ARGV.length == 2
account_name, api_key = ARGV
else
puts "Usage: #{$0} account_name api_key"
exit 1
end
class VolunteerMatchApi
attr_reader :nonce, :creation_time, :digest
def initialize (account_name, api_key)
@account_name = account_name
... | true |
1e3dba1b1f3eea147c678aa34e953d9870d134ac | Ruby | EzraMoore65/raylib-ruby | /examples/textures/textures_raw_data.rb | UTF-8 | 2,566 | 2.765625 | 3 | [
"MIT"
] | permissive | # /*******************************************************************************************
# *
# * raylib [textures] example - Load textures from raw data
# *
# * NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
# *
# * This example has been created using raylib 1.3 (www.r... | true |
93ddba4d2d4b454cc1a7fcb8d1e184e023ff2fe5 | Ruby | MatthewShepherd/phase-0-tracks | /ruby/vampires2.rb | UTF-8 | 343 | 3.546875 | 4 | [] | no_license | # Request user input
# name
# age and year
# garlic bread?
# health insurance?
p "what is your name?"
user_name = gets.chomp
p "how old are you?"
age = gets.chomp
p "what year were you born?"
year = gets.chomp
"would you liike garlic bread(y/n)?"
bread = gets.chomp
"health insurance?(y/n)... | true |
7c972a71394208fea7933aba2b55bf028cc29102 | Ruby | pedrogglima/scrap-cbf | /lib/scrap_cbf/errors.rb | UTF-8 | 1,551 | 3.015625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class ScrapCbf
# Base error for all ScrapCbf errors.
class BaseError < ::StandardError; end
# Raised when a required method is not implemented.
class MethodNotImplementedError < BaseError; end
# Raised when a argument is not included in a predefined range of values.
class Ou... | true |
fdcfc7374cadb4c0dce204c987b545af091b58bb | Ruby | Dyoon3102/phase-0-tracks | /ruby/hashes.rb | UTF-8 | 1,750 | 3.9375 | 4 | [] | no_license | # Initialize an empty hash to start collecting client information.
client = {}
puts "Please key in corresponding information."
puts ""
# Prompt user to input corresponding information.
puts "Client's name:"
name = gets.chomp
# Convert input to value of key
client[:name] = name
puts ""
# Prompt user to input correspo... | true |
5c4833030c09c5c5ac4d02baa6ab0bf684ce28f3 | Ruby | aagooden/Pizza | /pizza.rb | UTF-8 | 1,166 | 3.71875 | 4 | [] | no_license | def crust()
["Thick Crust", "Thin Crust", "Pan Crust", "Stuffed Crust"]
end
def meats()
["Pepperoni", "Sausage", "Ham", "Chicken"]
end
def veggies()
["Peppers", "Onions", "Mushrooms", "Peas"]
end
def special_sauce()
["Tomato Sauce", "Ranch Sauce", "Itallian Sauce", "Fruit Sauce"]
end
def special_tops()
["Extra... | true |
c386cac69dbaa2373698b64ddd393fd398175c20 | Ruby | jnunemaker/gemwhois | /lib/rubygems/commands/whois_command.rb | UTF-8 | 1,295 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'rubygems/gemcutter_utilities'
require 'crack'
require 'unindent'
class Gem::Commands::WhoisCommand < Gem::Command
include Gem::GemcutterUtilities
def description
'Perform a whois lookup based on a gem name so you can see if it is available or not'
end
def arguments
"GEM name of gem"
... | true |
4f16528c70399d5e4733acc079da200a2d824565 | Ruby | Porti2/Appium | /LoginStaff_Valido.rb | UTF-8 | 1,525 | 2.734375 | 3 | [] | no_license | # Importamos las librerias o scripts necesarias
require '../Login.rb'
puts "** Test 3: Login Satff Válido **\n--------------------------"
Login.login('Paco.cid','1234abcd')
# Realizamos un 'Click' en el boton para iniciar la sesión.
$driver.find_element(:id, "com.Intelinova.TgApp:id/btn_login_staff").click
# Indicam... | true |
ffde1c2368c5fa6d3e8e307360c630d40ff31e0d | Ruby | oshou/procon | /HackerRank/Algorithms/sock_merchant.rb | UTF-8 | 179 | 3.109375 | 3 | [] | no_license | n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
counts = {}
arr.uniq.each do |v|
counts[v] = arr.count(v)
end
pairs = 0
counts.map { |k, v| pairs += v / 2 }
puts pairs
| true |
85476bd160b947e21ebf45a48575fb1ded3ed0ae | Ruby | PrateekAlakh/Ruby-Programmes | /Proc_floor.rb | UTF-8 | 79 | 2.9375 | 3 | [] | no_license | a=[1.2,2.3,3.4,4.5,5.6,6.7]
fl=Proc.new do |n|
n.floor
end
p a.collect!(&fl)
| true |
3c318eb85764a75f610d44936b017e3de3f4e5c0 | Ruby | wendy0402/jsm | /spec/jsm/states_spec.rb | UTF-8 | 2,007 | 2.859375 | 3 | [
"MIT"
] | permissive | describe Jsm::States do
let(:states) { Jsm::States.new }
describe '.add_state' do
it 'register new state' do
states.add_state(:x)
expect(states.list[0].name).to eq(:x)
end
it 'can register more than one state' do
states.add_state(:x)
states.add_state(:y)
expect(states.lis... | true |
ae0eca544070ed1e741ab843dc5e7a237c73353c | Ruby | kaspernj/attr_args_shorthand | /lib/attr_args_shorthand.rb | UTF-8 | 920 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class AttrArgsShorthand
def self.set(object, arguments, args = {})
arguments.each do |key, value|
object.instance_variable_set("@#{key}", value)
unless object.respond_to?(key)
object.define_singleton_method(key) do
instance_variable_get("@#{key}")
end
end
unless... | true |
3a5344c73eda3b157bcfa9ac3c631658546fd25c | Ruby | marcandre/backports | /lib/backports/2.5.0/string/undump.rb | UTF-8 | 2,411 | 2.984375 | 3 | [
"MIT"
] | permissive | unless String.method_defined? :undump
class String
def undump
# Making sure to return a String and not a subclass
string = to_s
raise 'string contains null byte' if string["\0"]
raise 'non-ASCII character detected' unless string.ascii_only?
match = string.match(/\A(".*?"?)(?:\.force... | true |
9e22fb124a31cfc8e2f69335afc65f53b5cbfe44 | Ruby | callahanbrothers/larry | /spec/models/twitter_account_spec.rb | UTF-8 | 4,328 | 2.53125 | 3 | [] | no_license | require "rails_helper"
RSpec.describe TwitterAccount, type: :model do
let(:user) { User.create(uid: "123", token: "token", secret: "secret") }
let(:twitter_params) { {
uid: "123",
screen_name: "screen_name",
profile_image_url: "profile_image_url",
followers_count: "followers_count",
f... | true |
f1c2d7f1d9c5fe9f568b674a6d29931a2aebb863 | Ruby | mahichy/Ruby_Blockss | /05/bonus.rb | UTF-8 | 837 | 3.984375 | 4 | [] | no_license | # def n_times(number)
# 1.upto(number) do |c|
# yield(c)
# end
# end
# n_times(5) do |n|
# puts "#{n} situps"
# puts "#{n} pushups"
# puts "#{n} chinups"
# end
def deal(number_of_cards)
faces = ["Jack", "Queen", "King", "Ace"]
suits = ["Hearts", "Diamonds", "Spades", "Clubs"]
if block_given?
numbe... | true |
f0aa8bfd9ee84a60c424c465d58939b509d260ce | Ruby | analyticalCat/playground | /todolists/app/models/profile.rb | UTF-8 | 626 | 2.625 | 3 | [] | no_license | class Profile < ActiveRecord::Base
belongs_to :user
validate :first_last_name_not_null
def first_last_name_not_null
if first_name.nil? and last_name.nil?
errors.add(:first_name, "and last name cannot both be null")
end
end
validates :gender, inclusion: { in: ["male", "female"]}
validate ... | true |
baee2c8c4ac64ef5575c482ead0ca4ffbdaeec7f | Ruby | louiechristie/WDI_LDN_5_Assignments | /louiechristie/w9d3/code_test/Card.rb | UTF-8 | 2,094 | 3.65625 | 4 | [] | no_license | class Card
attr_accessor :card_number
attr_accessor :card_type
def initialize(card_number)
@card_number = card_number.gsub(/\s+/, "") #strip out white space
@card_type = "Unknown" if !valid_type_of_card?
end
def check()
valid? ? "valid" : "invalid"
end
def valid?
is_a_number? && ... | true |
1799d5227d656713c4a291aa0d89ce3c66135fe4 | Ruby | IlyaUmanets/improve_your_code | /lib/improve_your_code/code_comment.rb | UTF-8 | 1,626 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'yaml'
require_relative 'smell_detectors/base_detector'
module ImproveYourCode
class CodeComment
CONFIGURATION_REGEX = /
:improve_your_code: # prefix
(\w+) # smell detector e.g.: UncommunicativeVariableName
... | true |
1a7584f3a8a282305cfc40882338814a246a6895 | Ruby | majestrate/BitMessageForum | /lib/bmf.rb | UTF-8 | 1,996 | 2.609375 | 3 | [] | no_license | require 'thread'
module BMF
require_relative "bmf/lib/bmf.rb"
require_relative "bmf/lib/alert.rb"
def self.puts_and_alert msg
puts msg
Alert.instance << msg
end
def self.sync
new_messages = MessageStore.instance.update
Alert.instance.add_new_messages(new_messages)
AddressStore.instance... | true |
e1e2dbcb6a249d3704594c3248ccad35aa0bd65f | Ruby | vkothari-systango/mars_rover | /mars_rover_input.rb | UTF-8 | 737 | 3.234375 | 3 | [] | no_license | require_relative "./mars_rover"
puts "Enter Top(upper-right) coordinates of the plateau separated by spaces:"
upper_right_coordinate = gets
starting_position = []
instructions = []
inputs = []
for i in 0...2
puts "Enter Rover's starting position(two integers and a letter) separated by spaces:"
starting_position[... | true |
e8c00aab1507d50dcecbadc8f8452fd34da0fa02 | Ruby | alanryoung01/badges-and-schedules-onl01-seng-pt-090820 | /conference_badges.rb | UTF-8 | 557 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
people = []
attendees.each do |name|
people.push("Hello, my name is #{name}.")
end
return people
end
def assign_rooms(att)
people = []
counter = 1
att.each do |name|
people.pu... | true |
d4a56f009d5e16a97f68853d518d0831f30f0d4b | Ruby | DanS/design_patterns | /composite_pattern/spec/baker_spec.rb | UTF-8 | 1,242 | 2.703125 | 3 | [] | no_license | require "baker.rb"
describe "cake making tasks" do
it "should mix dry ingredients" do
adi = AddDryIngredientsTask.new
adi.name.should == "Add dry ingredients"
adi.get_time_required.should == 1.0
end
it "should add the wet ingredients" do
awi = AddLiquidsTask.new
awi.name.should == "Adding li... | true |
7388e63ae5b11e50f3498a4eff30d0533a39ac23 | Ruby | emrancub/Basic-Ruby-Programming-Practice | /chapter_3.1/arry_iteration.rb | UTF-8 | 328 | 4.0625 | 4 | [] | no_license | # iterating through arrays
[1, "test", 2, 3, 4].each{|element| puts element.to_s + "X"}
# each iterations through an array element
[1, 2, 3, 4].collect {|element| puts element*2}
# array acess using loop and add new letter with a array
a = [1, 'test', 2, 3, 4]
i = 0
while (i<a.length)
puts a[i].to_s + "X"
... | true |
b1aed24d9df6ce9e86b196b61348d2dfc9778213 | Ruby | brandontricci/debut | /inclass/arrayask.rb | UTF-8 | 210 | 3.875 | 4 | [] | no_license | puts "enter the array elements (type 'exit' to get out)"
input = gets.chomp
arr = []
while input != 'exit'
arr << input.to_i
input = gets.chomp
end
puts arr.count
puts "times u have entered array items!!" | true |
4921217f95f36d26a70285297f7700592dc480f1 | Ruby | kjchiu/cobra | /app/services/sos_calculator.rb | UTF-8 | 2,490 | 2.71875 | 3 | [] | no_license | class SosCalculator
def self.calculate!(stage)
players = Hash[stage.players.map{ |p| [p.id, p] }]
# calculate points and cache values for sos calculations
points = {}
games_played = {}
opponents = {}
points_for_sos = {}
corp_points = {}
runner_points = {}
stage.eligible_pairings.e... | true |
b3338fb2e1ae6bcdd7d2adb5eed4c7650b2fcc3b | Ruby | cblair/portal | /app/models/job.rb | UTF-8 | 2,972 | 2.59375 | 3 | [] | no_license | class Job < ActiveRecord::Base
require 'spawn'
require 'delayed_job_runner'
attr_accessible :description, :finished, :user_id
belongs_to :user
has_one :delayed_job
def submit_job(current_user, ar_module, options)
jobs = Job.where(:user_id => current_user.id)
if jobs.count > 1000
puts "WARN:... | true |
7f8513517965e7c8d93a4985b9809027e6cc0261 | Ruby | tmacram/Ruby- | /ex13ec3.rb | UTF-8 | 636 | 3.625 | 4 | [] | no_license | first, second, third = ARGV
puts "Maybe you can guess maybe you cannot, whaddya think the first one is?"
print "? "
response = STDIN.gets.chomp()
puts "You guessed #{response} and the correct answer was #{first}, sorry :("
puts "Alright another try, this variable is an animal but smells lika a...."
print "? "
respon... | true |
df7c6548dc457732a64667c9e8f9adf2cd97525c | Ruby | Polo94/testdrivendev | /00_hello/hello.rb | UTF-8 | 125 | 3.5625 | 4 | [] | no_license | #write your code here
def hello
"Hello!"
end
def greet(someone)
"Hello, #{someone}!"
end
puts greet("Alice"),greet("Bob") | true |
982e559fc0471eb0807abac65741ef5930e36cf6 | Ruby | ABBennett/chillow | /lib/truck.rb | UTF-8 | 191 | 2.515625 | 3 | [] | no_license | require_relative 'box'
require_relative "capacity_module"
class Truck
include Capacity
attr_reader :array
def initialize(capacity)
@capacity = capacity
@array = []
end
end
| true |
4621c87fac4d70494e4cedb3fdf8f2bd63d9d4d8 | Ruby | richardtemple/dice_game | /lib/draw/die.rb | UTF-8 | 542 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'gosu'
class Die
attr_accessor :value, :image, :selected, :locked
def initialize()
@selected = false
@locked = false
@new_lock = false
roll
end
def roll
@value = rand(6) + 1
@image = Gosu::Image.new("./media/#{@value}.png") # code smell
end
def clicked
@selected = !@selected unless @lock... | true |
1e4aa892e13dad89084303f0e44ab3fa9b0c970d | Ruby | adoan91/essential-ruby | /string-manip.rb | UTF-8 | 298 | 4.59375 | 5 | [] | no_license | # Method for getting user input
def get_input
print "Enter a string: "
return gets.chomp.to_s
end
str = get_input
print("String entered (str): #{str}\n")
print("Capitalizing of str: #{str.upcase}\n")
print("Length of string str: #{str.length}\n")
print("Reverse of string str: #{str.reverse}\n") | true |
3c93531a061337a6bd6442e45293eb9c646f0d7d | Ruby | phump81/bank_test | /spec/unit/account_spec.rb | UTF-8 | 730 | 2.921875 | 3 | [] | no_license | require 'account'
require 'timecop'
describe Account do
let(:account) { Account.new }
let(:deposit) { account.deposit(1000) }
let(:withdraw) { account.withdraw(500) }
it "adds deposit to balance" do
deposit
expect(account.instance_variable_get(:@balance)).to eq(1000)
end
it "deducts withdrawal f... | true |
462985f616cb2704c012a25568f1b3c66b2e76ca | Ruby | guillaumejounel/CodeWars | /Ruby/top_3_words.rb | UTF-8 | 776 | 4.125 | 4 | [] | no_license | #Returns the top 3 words from a string. Words should be lowercased and may contain a '
def top_3_words(text)
rank = {}
words = text.downcase.scan(/[a-z]+['[a-z]+]*/)
words.uniq.map{|w| rank[w] = words.count(w)}
rank.sort_by{|k,v| [-v, k]}[0..2].to_h.keys
end
#Really interesting challenge as I don't of... | true |
fde1005b994355fce659f937e39cccddc651663a | Ruby | bdurand/lumberjack | /lib/lumberjack/template.rb | UTF-8 | 5,354 | 3.15625 | 3 | [
"MIT"
] | permissive | # frozen_string_literals: true
module Lumberjack
# A template converts entries to strings. Templates can contain the following place holders to
# reference log entry values:
#
# * :time
# * :severity
# * :progname
# * :tags
# * :message
#
# Any other words prefixed with a colon will be substituted ... | true |
1491b6ac2dd125a251717295339798c24a8470d2 | Ruby | taijinlee/sift-ruby | /examples/client.rb | UTF-8 | 1,948 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# A simple example of how to use the API.
require 'rubygems'
require 'sift'
require 'multi_json'
TIMEOUT = 5
if ARGV.length.zero?
puts "Please specify an Plugin key"
puts "usage:"
puts " ruby client.rb <Plugin KEY>"
puts
exit
end
plugin_key = ARGV[0];
class MyLogger
def warn(e)
... | true |
6a046deb434b9c7b363f270b6a4c0aa3a3a05ca5 | Ruby | RobinBailey84/gym_project | /models/member.rb | UTF-8 | 1,325 | 2.90625 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Member
attr_accessor(:id, :name, :gold_membership)
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@gold_membership = options['gold_membership']
end
def save()
sql = "INSERT INTO members (name, gold_membersh... | true |
c7eb948b01fec05b11b5dbdadf94e556313fb387 | Ruby | djfletcher/AAScavengerHunt | /part1.rb | UTF-8 | 789 | 2.796875 | 3 | [] | no_license | require 'httparty'
require 'nokogiri'
page = HTTParty.get('https://scottduane.github.io/TopSecretClue/')
doc = Nokogiri::HTML(page)
links = doc.css('a')
valid_links = []
links.each do |a|
address = a['href']
response = HTTParty.get(address)
if response.code == 200
valid_links << address
end
end
def p... | true |
b65c98c4a149b80379a92c787d14a17687eefc28 | Ruby | pjsmueller/Ruckus | /db/seeds.rb | UTF-8 | 1,160 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'faker'
50.times do
User.create(username: Faker::Internet.user_name, f_name: Faker::Name.first_name, l_name: Faker::Name.last_name, password: "pass")
end
movies = Movie.now_playing
movies.each do |movie|
Movie.create(api_id: movie.id )
end
100.times do
Review.create(title: Faker::Hipster.word, body: Faker... | true |
50a9cf4f145c94b1699903de8cfbd8c0d21e34c8 | Ruby | imac18078/collections_practice_vol_2-001-prework-web | /collections_practice.rb | UTF-8 | 1,347 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
def begins_with_r(array)
array.all? do |x|
x.start_with?("r")
end
end
def contain_a(array)
array.select do |x|
x.match("a")
end
end
def first_wa(array)
array.find do |x|
x[0].match("w") && x[1].match("a")
end
end
def remove_non_strings(array)
array.select do |x|
x.... | true |
19d583dca59eed45513cb1b92fe0a12a0e3bc272 | Ruby | keblodev/sassificator | /lib/sassificator.rb | UTF-8 | 9,239 | 2.6875 | 3 | [
"MIT"
] | permissive | # Created by: Roman Fromrome
# https://github.com/rimaone
#TODO:
# - mediaquery inside of a mediaquery - done partically (only for one tree level deep)
# - images formating pattern setting
# - add convertor: all #_colors_ to rgb
# - MAJOR: formatting is done only for output sass_string, but not for sass_obj. Move for... | true |
001dde2a81e15576f02ef14377e7655ba022558f | Ruby | Russian-AI-Cup-2015/ruby-cgdk | /my_strategy.rb | UTF-8 | 425 | 2.78125 | 3 | [] | no_license | require './model/car'
require './model/game'
require './model/move'
require './model/world'
class MyStrategy
# @param [Car] me
# @param [World] world
# @param [Game] game
# @param [Move] move
def move(me, world, game, move)
move.engine_power = 1.0
move.throw_projectile = true
move.spill_oil = tru... | true |
42b907bbaf8f1b2e9ba5f759828386e9752a49fd | Ruby | David-Kirsch/ruby-oo-practice-relationships-domains-nyc01-seng-ft-071320 | /app/models/shows.rb | UTF-8 | 551 | 3.375 | 3 | [] | no_license | class Show
@@all = []
attr_reader :name
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def show_characters
ShowCharacter.all.select {|show_char| show_char.show == self}
end
def characters
self.show_characters.map... | true |
209e7492c833fb0e1a5fb643359f24696b645d53 | Ruby | jtruong2/battleship | /lib/battleship.rb | UTF-8 | 3,644 | 2.9375 | 3 | [] | no_license | require 'pry'
require_relative 'player'
require_relative 'computer'
require_relative 'grid'
class Battleship
attr_reader :player,
:computer,
:grid
def initialize
@player = Player.new
@computer = Computer.new
@grid = Grid.new
@player_ship1_count = 0
@player_ship2_co... | true |
3343e9b8cab4bc27730c4b43e169ababe77fceda | Ruby | cjlofts/testrepo1 | /lol.rb | UTF-8 | 238 | 4.0625 | 4 | [] | no_license | # write some code that asks for 2 inputs
# then returns the product
puts "Enter the first number:"
num_1 = gets.chomp.to_f
puts "Enter the second number:"
num_2 = gets.chomp.to_f
puts "the two numbers multiplied are #{num_1 * num_2}" | true |
eae282fcfc6be75d6201198377210a94f15ca391 | Ruby | nramadas/ChessOld | /lib/pieces.rb | UTF-8 | 2,626 | 3.75 | 4 | [] | no_license | class Piece
DIAGONAL = [[-1, -1], [-1, 1], [1, -1], [1, 1]]
STRAIGHT = [[-1, 0], [1, 0], [0, -1], [0, 1]]
KNIGHT = [[-1, -2], [-2, -1], [-2, 1], [-1, 2],
[1, 2], [2, 1], [2, -1], [1, -2]]
attr_reader :token
attr_accessor :coordinates, :player_type
def initialize(coordinates, player_type)
@... | true |
70c2fd9550c48e9db7b1575a96d3c7ed1bc5797b | Ruby | artzte/itcostus | /app/models/category_matcher.rb | UTF-8 | 349 | 2.671875 | 3 | [
"MIT"
] | permissive | class CategoryMatcher < ActiveRecord::Base
def regexp
@regexp ||= Regexp.new self.value, Regexp::IGNORECASE
@regexp
end
def keywords
@keywords ||= self.value.split.uniq
@keywords
end
def self.dump
dumped = all
puts "["
dumped.each{|cm| puts " [\"#{cm.category}\",\"#{cm.regex}\"... | true |
13a30d28d41c099b7a6c1515162a6bb88e638b05 | Ruby | fujin/foodcritic | /lib/foodcritic/helpers.rb | UTF-8 | 6,815 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'xmlsimple'
module FoodCritic
# Helper methods that form part of the Rules DSL.
module Helpers
# Create a match from the specified node.
#
# @param [Nokogiri::XML::Node] node The node to create a match for
# @return [Hash] Hash with the matched node name and position wi... | true |
c3c819989577c062bc204b64840064343cdabca3 | Ruby | pacuum/vtc_payment | /lib/vtc_payment/mobile_card/crypt.rb | UTF-8 | 1,067 | 2.734375 | 3 | [
"MIT"
] | permissive | require "openssl"
require "digest"
require "base64"
module VtcPayment
module MobileCard
class Crypt
class << self
def encrypt( input, seed )
input = input.to_s.strip;
# it seems openssl automatically pad the string in the same way as php sample code
# encrypt
... | true |
32da5df5c75213e7ebf7c904d8d86d64d16f75a3 | Ruby | gushul/parse_result_list | /parser_json.rb | UTF-8 | 7,015 | 2.78125 | 3 | [] | no_license | class ImportRaytingWorker
require 'rubyXL'
require 'json'
def self.perform
debug_file = open("output.txt", 'w')
result_file = open("result.json", 'w')
debug_file.write("Begin\n")
workbook = RubyXL::Parser.parse("rating_2016.xlsm")
worksheet = workbook.worksheets[0]
total = 0
worksh... | true |
e10cebbeeb5da74d2d30a6057675152833616ef9 | Ruby | sirisak-amivoice/aohs_old | /app/models/dsrresult_log.rb | UTF-8 | 730 | 2.53125 | 3 | [] | no_license | class DsrresultLog < ActiveRecord::Base
belongs_to :voice_log
def rec_text
extract_result
return @ret_txt
end
def rec_stime
extract_result
return @ret_stime.to_f.round(4)
end
def rec_etime
extract_result
return @ret_etime.to_f.round... | true |
975aeff134e2af095e0ea02de604551e57cf3e33 | Ruby | yous/Yous-Webtoon | /bin/getList.rb | UTF-8 | 879 | 2.6875 | 3 | [] | no_license | # encoding: utf-8
require 'logger'
require 'site'
logger = Logger.new(STDERR)
logger.level = Logger::INFO
trap("QUIT") {
logger.close
exit
}
sites = [SiteNaver.new, SiteDaum.new]
count = 0
while true
if count % (6 * 24) == 0
sites.each do |site|
begin
site.getList :all => true
logger.... | true |
6960f055e24a123dd581487ee5535f07cee48f15 | Ruby | andolu/final | /createdb.rb | UTF-8 | 1,436 | 2.5625 | 3 | [] | no_license | # Set up for the application and database. DO NOT CHANGE. #############################
require "sequel" #
connection_string = ENV['DATABASE_URL'] || "sqlite://#{Dir.pwd}/development.sqlite3" #
DB = Sequel.connect(connection_string) ... | true |
887db45dd111f5927dbafe62f2e0bf8411c2b79f | Ruby | AIexey-L/http_profiler | /profiler.rb | UTF-8 | 2,123 | 2.53125 | 3 | [] | no_license | require 'net/http'
require 'progress_bar'
require 'benchmark'
require 'bundler/setup'
Bundler.require(:default)
rows = []
main_samples = []
samples_different = %w[dme lon mos pari novos vosto kras shan ber amster]
samples_two_lwtters = %w[dm mo sa ne no sh am]
main_samples << samples_different
main_samples << samples_... | true |
d46a4dbfc7270f66667ca3b93ec06e7487afd758 | Ruby | bugoodby/bugoodbylib | /script/rb/01.command_line.rb | UTF-8 | 437 | 3.640625 | 4 | [
"Unlicense"
] | permissive | #!/bin/ruby
def main()
puts "count = #{ARGV.length}"
puts "--- method 1 ---\n"
for arg in ARGV
puts arg
end
puts "--- method 2 ---\n"
ARGV.each {|arg|
puts arg
}
puts "--- method 3 ---\n"
ARGV.each_with_index {|arg, i|
puts i.to_s << " : " << arg
}
puts "--- method 4 ---... | true |
a959ac50269f00897b29d3e4bbc879edbe5afec7 | Ruby | jcellomarcano/movies-backend-manager-ruby | /lambdabuster.rb | UTF-8 | 22,314 | 3.390625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'set'
require 'date'
require_relative 'classes'
def create_order(movies,type,user)
if type == :rent
my_name="rentar"
verb_in_past="rentado"
my_price="rent_price"
action="rent_order"
store="rented_movies"
else
my_name="comprar"
ver... | true |
22a26fd3295f7ca1189e44b0a9a35044dd4ee8c4 | Ruby | p3ban3/megacalcio | /mega.rb | UTF-8 | 1,638 | 2.59375 | 3 | [] | no_license | require "sinatra"
require './config'
# squadre = DB.carica "squadre"
enable :sessions
get "/migrate" do
DataMapper.auto_migrate!
"db pronto"
end
get "/" do
erb :index
end
get "/typography" do
erb :typography
end
get "/squadre" do
squadre.to_s
end
get "/users/new" do
erb :users_new
end
post "/user... | true |
a174d6a2a5f2d15724e7330f1e31c4bc2e75a2d5 | Ruby | invibelabs/iron-workers | /mandrill_mailer/mandrill_mailer.rb | UTF-8 | 563 | 2.625 | 3 | [
"MIT"
] | permissive | require "mandrill"
puts "Starting Mandrill Mailer"
mandrill_api_key = params["mandrill_api_key"]
from_email = params["from_email"]
from_name = params["from_name"]
subject = params["subject"]
content = params["content"]
to_email = params["to_email"]
mandrill = Mandrill::API.new mandrill_api_key
puts "Building email... | true |
50728d737e20e643bdd62060fcd91b43be8e1ac9 | Ruby | Vellimir/ParallelDots-Ruby-API | /lib/config.rb | UTF-8 | 406 | 2.75 | 3 | [] | no_license | require 'parseconfig'
def set_api_key( api_key )
file = File.open( 'paralleldots_key.conf', 'w' )
config = ParseConfig.new( file )
config.add( "PD", api_key )
config.write( file )
file.close
puts "API Key Set.\nKey Value: %s"%api_key
end
def get_api_key
begin
config = ParseConfig.new( "paralleldots_key.conf"... | true |
231e0d740504a0eb2ea4a1185bcf29121b1f4e9a | Ruby | markevan100/exercisms | /ruby/collatz-conjecture/collatz_conjecture.rb | UTF-8 | 277 | 3.09375 | 3 | [] | no_license | module CollatzConjecture
def self.steps(num)
raise ArgumentError if num < 1
counter = 0
loop do
break if num == 1
counter += 1
if num % 2 == 0
num = num / 2
else
num = (3 * num) + 1
end
end
counter
end
end
| true |
8582f2a0c5c0b4fdae431a9f2dd9a41c4638a7fe | Ruby | benizi/dotfiles | /bin/git.encryptedjs | UTF-8 | 2,998 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'base64'
def encrypting?
!!(__FILE__ =~ /encrypt$/)
end
def contents
@contents ||= $stdin.read
end
def lines
@lines ||= contents.lines.to_a
end
def password
`git config filter.encryptedjs.password || true`.chomp
end
def encrypted?
!!((lines[0] || '') =~ /^benizi/)
end
def do... | true |
4a99cbb7c32a08fa0d2bd070099d6c4f421cbfb5 | Ruby | renuo/hashcode2017-jamp | /app/file_reader.rb | UTF-8 | 3,698 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative './world.rb'
require_relative './video.rb'
require_relative './endpoint.rb'
require_relative './request.rb'
require_relative './connection.rb'
require_relative './cache_server.rb'
class FileReader
def initialize(file_path)
@file = File.read(file_path)
end
def p... | true |
2c2f1428d3ceb42375bf9a99671f0596f3de3096 | Ruby | JoeJones76/programming-univbasics-nds-green-grocer-part-2-chicago-web-021720 | /lib/grocer_part_2.rb | UTF-8 | 2,535 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative './part_1_solution.rb'
def consolidate_cart(cart)
hash = {}
cart.each do |item_hash|
item_hash.each do |name, price_hash|
if hash[name].nil?
hash[name] = price_hash.merge({:count => 1})
else
hash[name][:count] += 1
end
end
end
hash
end
def apply_coupo... | true |
b61b7b2e9724070289c6281a7cd2b825341b2035 | Ruby | stuartwakefield/testality | /lib/testality/request.rb | UTF-8 | 2,561 | 3.09375 | 3 | [
"MIT"
] | permissive | require "json"
module Testality
class Request
def initialize(socket)
puts "New request"
@socket = socket
puts "Parsing request"
@request = parse_request @socket
puts "Parsing headers"
# Parse headers
@headers = parse_headers @socket
puts "Parsing body"
# Parse body
... | true |
20fc03a16f282f3b23be8e774acf39d180f48b59 | Ruby | bishma-stornelli/ANN | /one-neuron/prueba.rb | UTF-8 | 214 | 2.6875 | 3 | [] | no_license | #!/usr/bin/ruby
require 'rubygems'
require 'gruff'
g = Gruff::Dot.new
g.title = "Mi gráfica de prueba"
g.data("Java", [24, 25, 18])
g.data("C", [17.5, 17, 16.5])
g.labels = {0 => '2003'}
g.write('prueba.png') | true |
aa08bb512b3adb75f900bd9de943c7bcded3cbbb | Ruby | asciidoctor/kramdown-asciidoc | /lib/kramdown-asciidoc/api.rb | UTF-8 | 6,750 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Kramdown
module AsciiDoc
DEFAULT_PARSER_OPTS = {
auto_ids: false,
hard_wrap: false,
html_to_native: true,
input: 'GFM',
}
DEFAULT_PREPROCESSORS = [
(Preprocessors.method :extract_front_matter),
(Preprocessors.method :replace_toc),
(Preprocessors.m... | true |
7f75860a8d54621e3943dc644deda712da426c43 | Ruby | CultureHQ/adequate_serialization | /lib/adequate_serialization/attribute.rb | UTF-8 | 3,131 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module AdequateSerialization
def self.dump(object)
if object.is_a?(Hash)
object
elsif object.respond_to?(:as_json)
object.as_json
else
object
end
end
module Attribute
class Simple
attr_reader :name
def initialize(name)
@nam... | true |
8faaaf41a81acaa54eef92f83e9db80b6d37f2d1 | Ruby | drewswinburne/landlord | /ar_exercise/exercise.rb | UTF-8 | 6,406 | 3.3125 | 3 | [] | no_license | ### NOTE: Make sure you've loaded the seeds.sql file into your DB before starting
### this exercise
require "pg" # postgres db library
require "active_record" # the ORM
require "pry" # for debugging
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:database => "landlord"
)
class Tenant < Active... | true |
72486b4c215735a375f041e2382022865aa1c283 | Ruby | arturcp/arenah-rails | /app/models/sheet/character_attribute.rb | UTF-8 | 1,758 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
module Sheet
class CharacterAttribute
include EmbeddedModel
attr_accessor :name, :order, :type, :master_only, :description,
:formula, :action, :base_attribute_group, :base_attribute_name,
:abbreviation, :table_name, :cost, :prefix, :content, :points,
:total, :... | true |
87f767f3ad26922725d31d37456cea42cc794ce4 | Ruby | kmicinski/micinski-dissertation | /location_privacy/data/scripts/main.rb | UTF-8 | 4,982 | 2.828125 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'rubygems'
require 'optparse'
require 'pathname'
require './dataset'
require './data'
require './applist'
require './plotter'
THIS_FILE = Pathname.new(__FILE__).realpath.to_s
HOME = File.dirname(__FILE__) + "/.."
class Array
# Process each element of an array using a separate process.... | true |
663fd8143c3b04d9ad0ddd7f632ef2baaa90b81c | Ruby | Steven-Galvin/Contacts | /spec/address_spec.rb | UTF-8 | 3,012 | 3.046875 | 3 | [] | no_license | require "address"
require "rspec"
require "pry"
describe Address do
describe('#street') do
it('returns the street of the address') do
test_address = Address.new({:street => '123 Test St.', :city => 'Portland', :state => "OR", :zipcode => "97236", :type => "Home"})
expect(test_address.street()).to(eq... | true |
947382ec7f9412c825314ba333bef177601ddb7d | Ruby | nkeszler/Boris-Bikes | /spec/garage_spec.rb | UTF-8 | 640 | 2.953125 | 3 | [] | no_license | require 'garage'
describe Garage do
let(:garage) {Garage.new}
it "Should initialize with a capacity of 200 bikes" do
expect(garage.capacity).to eq(200)
end
it "Should accept all bikes from a van" do
van = Van.new
5.times do
bike = Bike.new
bike.break
van.dock(bike)
end
garage.get_all_broken... | true |
7e4bf22805039bc5b15944154a516696eb99591e | Ruby | textmate/ruby.tmbundle | /Support/vendor/rcodetools/test/data/attic/unit_test_rbtest-output.rb | UTF-8 | 79 | 2.703125 | 3 | [
"LicenseRef-scancode-boost-original",
"Ruby",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | =begin test_bar
assert_equal("BAR", bar("bar"))
=end
def bar(s)
s.upcase
end
| true |
726eebc612147bf06c9df4411ae09b18393a603a | Ruby | ashirahattia/cs169-pgm | /app/models/match.rb | UTF-8 | 4,067 | 3.265625 | 3 | [
"MIT"
] | permissive | require 'munkres'
class Match < ActiveRecord::Base
belongs_to :group
belongs_to :project
@@big_number = 999999999999999
def self.generate_preference_list(group)
group_preferences = [group[:first_choice], group[:second_choice],
group[:third_choice], group[:f... | true |
da4ad99e70c6f3c0206b1aa9ebdb003c3e0eb68a | Ruby | snoble/relational_streams | /example.rb | UTF-8 | 728 | 2.75 | 3 | [] | no_license | require './relational_stream'
require './relational_event'
require 'redis'
redis = Redis.new
x = InputRStream.new("x", [:a])
x.each! {|n| puts "#{n[:a]} added to x"}
y = x.select {|n| n[:a].even?}
y.each! {|n| puts "#{n[:a]} filtered to y"}
another_x = InputRStream.new("another_x", [:a])
j = x.join(another_x, redi... | true |
0ada2e6b1f0023be134c031ff7e62e985bb7c590 | Ruby | StephenOey/LS_Ruby | /RB 100/Intro_to_Programming_with_Ruby/Flow_Control/true.rb | UTF-8 | 132 | 3.984375 | 4 | [] | no_license |
if a = 5 #this is assigning a value to a rather than checking with ==
puts "how can this be"
else
puts "it is not true"
end | true |
353f6f08c6da881a257358aea9a0ae4023531ad6 | Ruby | hazemosman/germanizer | /db_base.rb | UTF-8 | 2,988 | 2.9375 | 3 | [] | no_license | # TODO Change into active record
require 'sqlite3'
require_relative 'verb'
class DBBase
def initialize
@db = SQLite3::Database.new('dbfile')
@db.results_as_hash = true
end
def drop_tables
puts 'Dropping pronouns table...'
@db.execute 'Drop table if exists pronouns'
@db.execute 'Drop table if... | true |
267e8a023c78c65bd229f51f75bf7406f6cfb54c | Ruby | nbdavies/phase-0 | /week-4/errors.rb | UTF-8 | 8,558 | 4.4375 | 4 | [
"MIT"
] | permissive | # Analyze the Errors
# I worked on this challenge by myself.
# I spent [#] hours on this challenge.
# --- error -------------------------------------------------------
cartmans_phrase = "Screw you guys " + "I'm going home."
# This error was analyzed in the README file.
# --- error ----------------------------------... | true |
7d4d2e8b5fcf33af4fef68a742baff8de5f0a2cb | Ruby | atruby-team/internship-18-summer | /at-tanvo/Exercise1.rb | UTF-8 | 381 | 3.4375 | 3 | [] | no_license | add = ->(*arr) { arr.inject { |i, y| i + y } }
sub1 = ->(*arr) { arr.inject { |i, y| i - y } }
multi = ->(*arr) { arr.inject { |i, y| i * y } }
div = lambda { |*arr|
if arr.slice(1, arr.length).include? 0
'Khong chia duoc'
else
arr.inject { |i, y| i / y }
end
}
puts add.call(5, 4, 3, 4, 5, 6, 7)
puts sub1... | true |
54f277609de4428435a2819349f174fcec67219b | Ruby | stocker5076/capistrano | /Back/first/funcionPares.rb | UTF-8 | 126 | 3.5 | 4 | [] | no_license | def function3
even_numbers =[]
for x in 1..100
even_numbers << x if x.even?
end
puts even_numbers.inspect
end
function3 | true |
3d7749ef9e4d87bde55cbab7740b7bbdaf81ec01 | Ruby | christianotieno/codility | /cyclic_rotation.rb | UTF-8 | 213 | 3.21875 | 3 | [] | no_license | # https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/
def solution(a, k)
# a.rotate(k)
return [] if a.empty?
k.times do
removed_val = a.pop
a.insert(0, removed_val)
end
a
end
| true |
0bf1c64f257bfa1c216bd11278fd22884eba6454 | Ruby | betesh/hanoi | /spec/hanoi_spec.rb | UTF-8 | 792 | 3.15625 | 3 | [
"MIT"
] | permissive | require File.expand_path("../../hanoi", __FILE__)
def expect_invalid_input_error(input, message)
begin
hanoi = Hanoi.new(input)
rescue InvalidInputError => e
e.message.should eq(message)
end
end
describe "invalid inputs" do
it "should raise an error if input is not an Integer" do
expect_invalid_in... | true |
c16dbb94f7e8678c7590d42c8fd40cb7fdeb8f61 | Ruby | mahinourElsheikh/ice_cube | /spec/examples/yearly_rule_spec.rb | UTF-8 | 3,960 | 2.890625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
describe IceCube::YearlyRule, 'interval validation' do
it 'converts a string integer to an actual int when using the interval method' do
rule = IceCube::Rule.yearly.interval("2")
expect(rule.validations_for(:interval).first.interval).to eq(2)
end
it 'co... | true |
b2353a43c53cc74219db5e0bc372a0813dc65c5f | Ruby | theoandtheb/CRM | /CRM.rb | UTF-8 | 3,411 | 3.375 | 3 | [] | no_license | require_relative 'contact'
require_relative 'rolodex'
def sleepForSleepsSake
sleep 0.1
end
def intCheck(x,y)
$selectr = gets.chomp.to_i
unless $selectr.between?(x,y)
until $selectr.between?(x,y)
print "\nLet\'s try that again.\n\nEnter a number: "
$selectr = gets.chomp.to_i
end
end
end
class CRM
... | true |
2a39b60f1ade656d4b48e8e47be1b9369fe2654d | Ruby | tomofumi-run/cherry_book | /lib/4章/4.7.14.rb | UTF-8 | 257 | 3.578125 | 4 | [] | no_license | #ミュータブル(変更可),イミュータブル(変更不可)=integer,float,symbol,true,false,nilなど
#[]や<<を使った文字列の操作
a = 'abcde'
a[2] #c
a[1,3] #bcd
a[-1] #e
a[0] = 'x' #'xbcde'
a[1,3] = 'y' #'xye'
a << 'pqr' #'xyepqr' | true |
7b56f621d5f8753439e95bed231bd4f37c1c3cf2 | Ruby | nvdai2401/metaprogramming-ruby-2 | /class_definitions/singleton_class.rb | UTF-8 | 325 | 2.875 | 3 | [] | no_license | an_object = Object.new
singleton_class = class << an_object
self
end
def an_object.my_singleton_method; end
p singleton_class.class
p singleton_class.singleton_class
p singleton_class.singleton_class.superclass
p singleton_class.singleton_class.ancestors
p singleton_class.instance_methods.grep(/m... | true |
95d7fd5c99aa78c45943238f532b49636a187a1f | Ruby | dvc94ch/go2nix | /lib/go2nix.rb | UTF-8 | 3,355 | 2.53125 | 3 | [] | no_license | require 'go2nix/go'
require 'go2nix/revision'
require 'go2nix/vcs'
require 'erubis'
require 'go2nix/nix'
require 'set'
module Go2nix
TEMPLATE_PATH = File.expand_path("../nix.erb", __FILE__)
def self.snapshot(gopath, tags, til, imports, revs=[], processed_imports=Set.new)
imports.each do |import|
next if... | true |
58d29d9edccc299bfb97dff3606913852fda0cb5 | Ruby | vyklimavicius/cartoon-collections-dumbo-web-career-021819 | /cartoon_collections.rb | UTF-8 | 412 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)
array.each_with_index do |name,idx|
puts "#{idx+1} #{name}"
end
end
def summon_captain_planet(array)
array.collect do |ele|
ele.capitalize << "!"
end
end
def long_planeteer_calls(array)
array.any? do |word|
word.length > 4
end
end
def find_the_cheese(array)
arra... | true |
da96d4daf59b78594e9fb6a855f74ff0eb0c830f | Ruby | Account-onmi-2xplanet/rails-mister-cocktail | /app/controllers/cocktails_controller.rb | UTF-8 | 1,358 | 2.8125 | 3 | [] | no_license | class CocktailsController < ApplicationController
def index
@cocktails = Cocktail.all
@phrases = ["Frank Sinatra said, 'Alcohol may be man's worst enemy, but the Bible says love your enemy.'",
"Irish Quote:'When we drink, we get drunk. When we get drunk, we fall asleep. When we fall asleep,... | true |
b284b40defcbad3324a22c18543de2f4e432f699 | Ruby | walidwahed/ls | /120-oop/lesson_4-exercises/easy2/05.rb | UTF-8 | 392 | 3.984375 | 4 | [] | no_license | # Question 5
# There are a number of variables listed below. What are the different types and how do you know which is which?
excited_dog = "excited dog" # local variable
@excited_dog = "excited dog" # instance variable
@@excited_dog = "excited dog" # class variable
# You know which is which by the '@'s prefixed to ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.