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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6c360777b2b7453c4307073c489a1485790364dc | Ruby | nguyenquangtruong-c0919h1/test | /Exam.rb | UTF-8 | 120 | 2.8125 | 3 | [] | no_license | def my_method
puts "reached the top"
yield
puts "reached the bottom"
end
my_method do
puts "reached yield"
end
| true |
5a010ec22c3de92333bda2126aa7482b563258dd | Ruby | sweggersen/wolfbane | /app/models/farmer.rb | UTF-8 | 2,111 | 2.796875 | 3 | [] | no_license | # Farmer class, inherits ActiveRecord::Base which handles the database interaction.
class Farmer < ActiveRecord::Base
# Sets up a one-to-many relation with sheep, and deletes all
# owned sheep upon deletion of farmer
has_many :sheep, dependent: :destroy
before_create :create_remember_token
# downcase email ad... | true |
c87a71917664f277ba4c7b967f35069603d0b183 | Ruby | fdsea33/praesens | /vendor/plugins/recordselect/lib/conditions.rb | UTF-8 | 3,049 | 2.5625 | 3 | [
"MIT"
] | permissive | module RecordSelect
module Conditions
protected
def record_select_conditions
conditions = []
merge_conditions(
record_select_conditions_from_search,
record_select_conditions_from_params,
record_select_conditions_from_controller
)
end
# an override method.
... | true |
45187207d4581290fadd38cbfda57fdb91516df9 | Ruby | Ajedi32/RBML | /lib/rbml/fragment_contents.rb | UTF-8 | 461 | 2.6875 | 3 | [
"MIT"
] | permissive | require "forwardable"
module RBML
class FragmentContents
include Enumerable
extend Forwardable
def_delegators :@contents, :[], :[]=, :each, :empty?
def initialize(contents=[])
@contents = contents.to_a
end
def <<(item)
item = Text.new(item) if item.is_a? String
@contents ... | true |
dcf65acae4d73246b7f89c35726cd547476eec1e | Ruby | nick-stew/breweries_project_cli | /breweries_ruby_cli_project/lib/breweries_ruby_cli_project/cli.rb | UTF-8 | 1,947 | 3.359375 | 3 | [
"MIT"
] | permissive | class BreweriesRubyCliProject::CLI
def call
puts "Hello! Lets find you a Brewery!"
main_action
second_question
return_to_start
end
def main_action
all = []
puts "Please enter the state you would like to find a Brewery in. (enter the full state name)".green
... | true |
09d7967357d46f407e1b090f3b89fbc2e276ed4a | Ruby | TheCoderFactory/coder-factory-ruby-exercises | /ex10.rb | UTF-8 | 319 | 3.0625 | 3 | [] | no_license | customers = [
{ "name" => "Pedro", "starsign" => "Taurus", "age" => 21 },
{ "name" => "Jane", "starsign" => "Gemini", "age" => 30 }
]
customers.each do |customer|
puts "Customer details:"
puts "Name: #{customer['name']}"
puts "Starsign: #{customer['starsign']}"
puts "Age: #{customer['age']}"
puts "=" * 15
end | true |
d03d8795e34ef7c597c3966aec83f30ddc1ad52e | Ruby | Shopify/tableau-ruby | /lib/tableau_ruby/client.rb | UTF-8 | 3,071 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'logger'
module Tableau
class Client
attr_reader :conn, :host, :admin_name, :projects, :sites, :user, :users, :workbooks, :datasources, :groups
attr_accessor :site_id, :content_url, :token
#{username, user_id, password, site}
def initialize(args={})
@host = args[:host] || Tableau.host
... | true |
0daec5ba68959bba28825345dd916593e6ea7f31 | Ruby | BJSummerfield/Projecteuler | /problem25.rb | UTF-8 | 435 | 2.890625 | 3 | [] | no_license | fib = []
num = 1
check = 1000
require 'benchmark'
def start(fib,num,check)
time = Benchmark.measure {
runner(fib,num,check)
}
puts time.real
end
def runner(fib, num, check)
until num.to_s.length == check
add_to_fib(fib, num)
num = fib.last
end
p fib.length
end
def add_to_fib(fib, num)
if fi... | true |
901b72eb00bbd9d276793c8928a265e5d6cd053d | Ruby | christiegoldstein/Ironhack_Bootcamp | /Week_4/word_central/app/controllers/quotes_controller.rb | UTF-8 | 1,478 | 3.234375 | 3 | [] | no_license | class QuotesController < ApplicationController
def new
render 'new'
end
def create
@number = params[:number]
@choice = params[:choice]
@quotes_arr = [" I think if your clients want to sit on my shoulders and call themselves tall, they have the right to give it a try - but there's no requirement that I enjo... | true |
dae21e53db31c70ebb503460675fc3413423fb64 | Ruby | tcharfi66/ruby-oo-object-relationships-kickstarter-lab | /lib/backer.rb | UTF-8 | 498 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Backer
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def back_project(project)
new_pb = ProjectBacker.new(project, self)
end
def backed_projects
to_return = []
... | true |
d1189ed4bb3427de4f42c3e9efece6eb78f9b5a1 | Ruby | NicolasFenery/Ruby-Jour-4-et-5 | /exo_15.rb | UTF-8 | 212 | 3.4375 | 3 | [] | no_license | puts "Salut beau gosse, tu es né en quelle année ?"
year = gets.chomp.to_i
i = year
while i <= 2017
puts "En #{i}" + " tu avais #{i - year + 1} ans"
i += 1
end
puts "Voilà, tu sais compter un par un" | true |
e62acdb5c8dc08e728f9b789d92c5b134e8ec7c8 | Ruby | jgnagy/dzap_config_parser | /lib/config_parser/parser.rb | UTF-8 | 859 | 3.4375 | 3 | [
"MIT"
] | permissive | # The Parser class is the entry point to the gem. Use it to access config files.
class Parser
# All the work is done here. This class method is just used to perform some simple sanity checks on the input and return a config.
# @param file [String] The path to the config file to parse
# @param format [Class] The c... | true |
d2054a33a275324d84fc1d53057c68b900b14fa9 | Ruby | warrenshen/kazoku | /api/app/models/session.rb | UTF-8 | 2,081 | 2.703125 | 3 | [] | no_license | # == Schema Information
#
# Table name: sessions
#
# id :integer not null, primary key
# is_expired :boolean default("false"), not null
# is_logged_in :boolean default("true"), not null
# uuid :string not null
# last_active_at :datetime
# person_id ... | true |
5676d90946ff37b48ff5fb14d420971472a3d9a4 | Ruby | dusty/ruby_nagios | /lib/shell_command.rb | UTF-8 | 841 | 2.53125 | 3 | [] | no_license | require 'rubygems'
require 'open4'
class ShellCommand
attr_reader :pid, :stdout, :stderr, :status
attr_accessor :command, :results
def initialize(cmd)
@command = find_command(cmd)
end
def run(parameters)
status = Open4::popen4("#{@command} #{parameters}") do
|pid, stdin, stdout, stderr|
... | true |
565fc053bcc92eeeb433e99437b9860ef90628bb | Ruby | vadimpetkevich/itechart-students-lab | /practical_part_1/making_change/change.rb | UTF-8 | 1,296 | 3.015625 | 3 | [] | no_license | module Change
def self.validate?(amount, coins)
begin
return if Integer(amount) < 0
coins.each { |coin| return false unless Integer(coin) > 0 }
rescue Exception
return false
end
return if coins.empty?
true
end
def self.optimal_change(combinations)
return if combinations.... | true |
cd3f5158301214182c24c5edabd83e7cbafbdb8d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/327f9fd4f21f46c3a0661e54226ab5ab.rb | UTF-8 | 135 | 2.703125 | 3 | [] | no_license | class Gigasecond
ONE_GIGASECOND = 1000000000
def self.from(date)
Time.at(date.to_time.to_i + ONE_GIGASECOND).gmtime
end
end
| true |
3574d75438b390b31d7c5a922a8ee6937dc7b88a | Ruby | agildav/csv-importer-api | /lib/extensions/core.rb | UTF-8 | 1,080 | 3.390625 | 3 | [] | no_license | class String
def to_boolean
s = self.strip_downcase
case s
when "t", "y"
true
when 'f', 'n'
false
else
ActiveRecord::Type::Boolean.new.cast(s)
end
end
def shuffle
self.chars.shuffle.join
end
def squish_downcase
self.squish.downcase
end
def squish_upcase... | true |
98810a2f5201637b2d83c231ab73eb7c21518d63 | Ruby | arxu94/spoiler-alert | /app/controllers/login_controller.rb | UTF-8 | 4,318 | 2.75 | 3 | [] | no_license | class LoginController < Api::V1::BaseController
skip_before_action :verify_authenticity_token, only: [:login]
URL = "https://api.weixin.qq.com/sns/jscode2session".freeze
def wechat_user
wechat_params = {
appId: ENV["WECHAT_APP_ID"],
secret: ENV["WECHAT_APP_SECRET"],
js_code: params[:code],... | true |
b6d40bbb8c2efcac968816b9f82dc8ef24d13758 | Ruby | joshuawscott/ipconverter | /test/test_ipconverter.rb | UTF-8 | 1,352 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'ipconverter'
require 'minitest/autorun'
class TestIpConverter < MiniTest::Test
MAX_IP_INT = 4_294_967_295
def setup; end
def test_smallest_ip
int = IpConverter.str_to_int '0.0.0.0'
assert_equal int, 0
end
def test_largest_ip
int = IpConverter.str_to_int '... | true |
d13dce4b62c4232a8c66521b8f020b4337fdc286 | Ruby | TonyCWeng/Practice_Problems | /leetcode/ruby/78_subsets.rb | UTF-8 | 614 | 3.609375 | 4 | [] | no_license | # Given a set of distinct integers, nums, return all possible subsets
# (the power set). This includes an empty array and the entire nums.
def subsets(nums)
return [[]] if nums.empty?
# This line gets called until nums is empty, at which point subs = [[]]
subs = subsets(nums[1..-1])
new_subs = subs.map { |sub| ... | true |
cf80f48d722a246562a0178ecc76e012d05f6be8 | Ruby | CentroDL/godot | /w02/d04/student/sears/bike.rb | UTF-8 | 163 | 2.546875 | 3 | [] | no_license | class Bike < Product
def initialize(p, b, gear, dia)
super(p,b)
@gear_count = gear
@tire_diameter = dia
#gear_count and tire_diameter
end
end
| true |
f20c30a8ca0dc4d9939c8502211c2041e3bdd221 | Ruby | ldeld/tetris | /tile.rb | UTF-8 | 1,197 | 3.53125 | 4 | [] | no_license | require 'pry'
class Tile
TILE_SIZE = 40
attr_reader :position
def initialize(position, piece)
@position = position
@piece = piece
end
def move_down
@position[1] += 1
end
def move_side(side)
dir = side == :left ? -1 : 1
@position[0] += dir
end
def rotate_around(rotation_center)... | true |
cf344b206d00748ebf023ed000e85908ccac60a7 | Ruby | Mordorreal/SiteAnalyzer | /lib/site_analyzer/page.rb | UTF-8 | 5,893 | 2.625 | 3 | [
"MIT"
] | permissive | # Get site page and provide data for future analyse
module SiteAnalyzer
require 'nokogiri'
require 'addressable/uri'
require 'timeout'
require 'stringex_lite'
require 'open-uri'
class Page
attr_reader :page_url, :page_path, :site_domain,
:all_titles, :title_good, :title_and_h1_good,
... | true |
c21a4937647bf290ded049bfc09310710c93cc15 | Ruby | juliekang/learn_ruby | /12_rpn_calculator/rpn_calculator.rb | UTF-8 | 1,204 | 4.09375 | 4 | [] | no_license | class RPNCalculator
attr_accessor :value, :stack
def initialize
@stack = []
@value = 0
end
def push(number)
@stack.push(number)
end
def grab_two_nums
first_value = @stack.pop
second_value = @stack.pop
raise 'calculator is empty' if first_value.nil? || second_value.nil?
[first... | true |
20991d1af5c55810e95875e5501a7d7fb7e4ae47 | Ruby | ludwiggj/ruby-pickaxe | /ch13-unit-testing/roman/test/test_roman_manual.rb | UTF-8 | 201 | 3.3125 | 3 | [] | no_license | require 'roman'
r = Roman.new(1)
fail "'i' expected" unless r.to_s == "i"
r = Roman.new(9)
fail "'ix' expected" unless r.to_s == "ix"
r = Roman.new(8)
fail "'viii' expected" unless r.to_s == "viii"
| true |
d434d42d785f2816129db9e00d37e57f8d1d3a10 | Ruby | kimjaneclark/homework_20180114 | /Team_class/specs/team_spec.rb | UTF-8 | 578 | 2.828125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../team.rb')
class TestTeam < MiniTest::Test
def test_team_name
team = Team.new("Red Rovers","Finlay","Ken")
assert_equal("Red Rovers", team.name)
end
def test_team_player
team = Team.new("Clark Devils","Fraser","Kim")
assert_equal("Fraser"... | true |
b93c47bd7689522f7caeb080846e056fdb782e65 | Ruby | hanalways/slack-cli | /lib/workspace.rb | UTF-8 | 1,662 | 3.109375 | 3 | [] | no_license | # workspace
require_relative "user"
require_relative "channel"
require "terminal-table"
require "pry"
class Workspace
attr_reader :users, :channels, :selected, :list_users, :list_channels
def initialize
@users = SlackCli::User.list
@channels = SlackCli::Channel.list
@selected = nil
end
def select... | true |
79f109b264f0e2912ace36dfdc1b6da2856ca0fe | Ruby | suketa/nono | /lib/nono/gui/comvplate.rb | UTF-8 | 7,193 | 2.734375 | 3 | [] | no_license | require 'nono/out'
require 'nono/gui/config'
module Nono
module Gui
module COMVPlate
include Nono::Out
include Nono::Gui::Config
def create_pure_cells(val)
cells = []
@plate.width.times do |y|
ary = []
@plate.height.times do |x|
ary.push(val)
... | true |
fe45ceb8436f04f033fa333e192a02c65b3f399b | Ruby | cunger/launch | /101/exercises/easy4/shortlongshort.rb | UTF-8 | 282 | 3.609375 | 4 | [] | no_license |
def short_long_short(str1, str2)
if str1.length < str2.length
str1 + str2 + str1
else
str2 + str1 + str2
end
end
## Tests
p short_long_short('abc', 'defgh') == "abcdefghabc"
p short_long_short('abcde', 'fgh') == "fghabcdefgh"
p short_long_short('', 'xyz') == "xyz"
| true |
d7750d57bc7f2d4cb03a7f3092c21d63e4272ada | Ruby | larrymjordan/ruby-kata | /lib/ext/file.rb | UTF-8 | 367 | 3.046875 | 3 | [] | no_license | require_relative '../cache_word_counter'
class File
def self.count_words(file_url)
sentences = IO.readlines(file_url)
return {} if sentences.empty?
count_words_in sentences
end
private
def self.count_words_in(sentences)
counter = CacheWordCounter.new
sentences.inject({}) do |_, sentence|
... | true |
f3b79c86dccfa5cacc97da79b57064c4271941b9 | Ruby | menor/dbc_exercises | /ssn_and_regex.rb | UTF-8 | 4,530 | 3.9375 | 4 | [] | no_license | # PSEUDOCODE
# Please write your pseudocode here and keep it commented
# INPUT: A string for each of the methods
# OUPUT: 1) A Boolean
# 2) A String
# 3) An Array
# What are the steps to solve the problem? Write them out in plain english as best you can.
# 1) Check if the string has a pattern that ma... | true |
b4dbd6d74b7ca7cb46c8830a816776e5e4268412 | Ruby | SampsonCrowley/project_cli_connect_four | /lib/connect_four.rb | UTF-8 | 1,258 | 3.609375 | 4 | [] | no_license | require_relative "player"
require_relative "board"
require_relative "render"
class ConnectFour
attr_reader :board, :player1, :player2
def initialize (computer = false, auto_play = true)
@board = Board.new
@player1 = Player.new
@player2 = (computer ? Computer.new(@board) : Player.new)
@player1.piece... | true |
a25099f340f18c3b0a16fab866e8f9d40c63d1e9 | Ruby | Kevin8428/new_dragons | /05_ruby101/nick_espinosa/ruby_intro/hash_cheatsheet.rb | UTF-8 | 281 | 3.375 | 3 | [] | no_license | p adriana = {name: "adriana", :age => 23}
p james = Hash.new
james[:age] = 100000
p james
james[:name] = "james"
p james
p adriana[:name]
james[:name] = "chewy"
p james
p adriana.keys
p adriana.values
james.delete(:name)
p james
adriana.each{|key, value| p "#{key}, #{value}"}
| true |
d50285b7d515b2090e6fe85bc3a9554e549ad73a | Ruby | Zohaib94/DemoProject | /app/models/rating.rb | UTF-8 | 607 | 2.625 | 3 | [] | no_license | class Rating < ActiveRecord::Base
belongs_to :user
belongs_to :movie
validates :score, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 5 }
scope :average_by_score, -> (movie_id) { where(movie_id: movie_id).average('score') }
def self.set_rating(movie_id, user_id)
rating = Rating.whe... | true |
5e150596dfe0ee7c48d67e41543d5994ccd8762f | Ruby | joseph-gansukh/programming-univbasics-4-array-concept-review-lab-chicago-web-82619 | /lib/array_methods.rb | UTF-8 | 271 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
index = 0
while array[index] do
if array[index] == value_to_find
return index
end
index += 1
end
end
def find_max_value(array)
return array.max
end
def find_min_value(array)
return array.min
end
| true |
e47844a05cf840261fe070e5378f11b6839db501 | Ruby | faisalsahil/PaymentGateWay | /lib/security.rb | UTF-8 | 984 | 2.796875 | 3 | [] | no_license | class Security
require 'hmac-sha2'
require 'base64'
@secret_key = ENV['HBL_SECRET_KEY_' + ENV['HBL_MODE']]
def self.generate_signature params
sign(build_data_to_sign(params),@secret_key)
end
def self.valid? params
signature = generate_signature params
signature.strip.eql? params['signature']... | true |
c62ef34fe1286b568739e06621ea55d09145de91 | Ruby | ColinOsborn/cryptocoin | /lib/wallet.rb | UTF-8 | 1,164 | 3.140625 | 3 | [] | no_license | require './lib/keygen'
require 'pry'
require 'tmpdir'
class Wallet
attr_reader :key, :file_path, :wallet_path, :public_key
def initialize(path)
@key = KeyGen.new
@file_path = Dir.pwd + file_path
@wallet_path = @file_path + "/.wallet"
create_wallet_directory unless wallet_exists?
create_keys
... | true |
655946f5322a00cb366e9027eb42894fa53edc5f | Ruby | RyanDur/Mars_Rover | /spec/Rover_Controller_spec.rb | UTF-8 | 3,945 | 3.046875 | 3 | [] | no_license | require_relative 'spec_helper'
describe Rover_Controller do
before :each do
command = Command.new([1,2,"N"],["L","M","L","M","L","M","L","M","M"])
command2 = Command.new([3,3,"E"],["M","M","R","M","M","R","M","R","R","M"])
@Rover_Controller = Rover_Controller.new([[5,5],command,command2])
end
descri... | true |
fcc9933611faecb97879e41d283389f31b7c3c45 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/4166.rb | UTF-8 | 185 | 3.109375 | 3 | [] | no_license | def compute(a, b)
a_chars = a.chars
b_chars = b.chars
diff = 0
a_chars.each_with_index do |c, i|
diff += 1 if b_chars[i] && b_chars[i] != c
end
diff
end | true |
4507cef808a74058f25251568de23d406ba4c77f | Ruby | sgharms/latinverb_imperatives | /lib/latinverb_imperatives/imperatives_factory.rb | UTF-8 | 900 | 2.546875 | 3 | [
"MIT"
] | permissive | module Linguistics
module Latin
module Verb
class LatinVerb
class ImperativesFactory
extend Forwardable
def_delegators :@verb, :irregular?, :deponent?, :semideponent?, :original_string
def initialize(verb)
@verb = verb
end
def imperativ... | true |
20a62bdf2dc26b6e232f6b39187f85aaa8e50ec0 | Ruby | solidusio-contrib/solidus_volume_pricing | /app/models/solidus_volume_pricing/pricer.rb | UTF-8 | 2,192 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
module SolidusVolumePricing
class Pricer < ::Spree::Variant::PriceSelector
attr_reader :quantity, :user
def self.pricing_options_class
SolidusVolumePricing::PricingOptions
end
def price_for(pricing_options)
extract_options(pricing_options)
::Spree::Mo... | true |
469d189a101bf4457cd48217c01ea514b9408c1e | Ruby | seesykescode/LearnRuby | /Chapter 1/Chapter1.rb | UTF-8 | 579 | 4.1875 | 4 | [] | no_license | # Write a program which tells you:
#
# how many hours are in a year?
# how many minutes are in a decade?
# how many seconds old are you?
# how many chocolates do you hope to eat in your life?
#How many hours in a day.
hours_in_year = 365 * 24
puts "There are #{hours_in_year} hours in a year."
minutes_in_decade = 36... | true |
643df8d3186e66296605d0b272ef9c2367d96059 | Ruby | chrisaugust/small-problems-easy-4 | /multiples_3_and_5.rb | UTF-8 | 1,199 | 4.53125 | 5 | [] | no_license | # Multiples of 3 and 5
#
# PROBLEM
# Write a method that searches for the multiples of 3 and 5 lying between
# 1 and some other number (the input paramater), and computes the sum
# of those multiples. An example being parameter = 20, with result 98
# (3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20)
#
# Assume that the number ... | true |
921786af398bf0c4558bad416e2ae28ba62b77af | Ruby | jcstringer/autoscaler | /lib/autoscaler/sidekiq/celluloid_monitor.rb | UTF-8 | 1,664 | 2.625 | 3 | [
"MIT"
] | permissive | require 'celluloid'
module Autoscaler
module Sidekiq
# Actor to monitor the sidekiq server for scale-down
class CelluloidMonitor
include Celluloid
# @param [scaler] scaler object that actually performs scaling operations (e.g. {HerokuScaler})
# @param [Strategy] strategy object that decide... | true |
490d81cb3e2c99702b2359554e8fe09f7d90de96 | Ruby | rekapap/Problem-solving | /Hackerrank/Ruby/strings/each.rb | UTF-8 | 175 | 3.5 | 4 | [] | no_license | # Your code here
def count_multibyte_char(str)
str.each_char.map do |ch|
ch.bytesize > 1 ? 1 : 0
end.reduce(0, :+)
end
# TEST
puts count_multibyte_char('¥♥1000')
| true |
002590671c8935b5ea9acbc7c983296308098ca4 | Ruby | palmermarc/vw-liliths-revenge | /area/starting_areas.rb | UTF-8 | 8,633 | 2.640625 | 3 | [] | no_license | require "json"
# Starting area files
files = ["draconia.json", "elysium.json", "midennir.json", "moria.json", "ofcol2.json", "smurf.json", "thalos.json"]
def SetMinMax(object, min, max)
object["Min_modifier"] = min
object["Max_modifier"] = max
end
files.each do |fileName|
file = File.read(fileName)
... | true |
d485946133e20b1bd9224cbc147f55f617018790 | Ruby | tky3a/rails_app | /app/helpers/application_helper.rb | UTF-8 | 819 | 2.546875 | 3 | [] | no_license | module ApplicationHelper
###ブラウザ(ページ)のタイトル名表示を設定
#page_titleが空の場合base_titleを表示
#違う場合はbase_title | page_titleで表示する
def full_title(page_title)
base_title = "Ruby on Rails Tutotial"
if page_title.empty? #empty?で配列が空であればtrue、1つ以上の要素があればfalseを返す
base_title
else
"#{base_title} | #{page_ti... | true |
629a955142b8eb302de631bac9ce982a955e6659 | Ruby | dtingg/interviews | /C12/products_array.rb | UTF-8 | 1,169 | 4.21875 | 4 | [] | no_license | # C12: Given an array nums of n integers where n > 1,
# return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
def products_array(array)
number_zeros = 0
array.each do |num|
if num == 0
number_zeros += 1
end
end
if number_zeros >= 2
... | true |
5499fc202eb8bbd3410b7f37fd93d04d445bf946 | Ruby | davisjustinw/cartoon-collections-seattle-web-career-012819 | /cartoon_collections.rb | UTF-8 | 399 | 3.140625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarves)
dwarves.each_with_index {|dwarf, index| puts "#{index +1} #{dwarf}"}
end
def summon_captain_planet(calls)
calls.map {|call| "#{call.capitalize}!"}
end
def long_planeteer_calls(calls)
calls.any? {|call| call.length > 4}
end
def find_the_cheese(snacks)
cheese_types = ["cheddar", ... | true |
a75a26497e99969ca7da911e9e773f388f93f4af | Ruby | aokpower/ezss | /bin/deactivate_unlisted_skus.rb | UTF-8 | 716 | 2.796875 | 3 | [] | no_license | require_relative '../lib/ezss'
# meant to be used with a file of master skus and a product export file from skubana
listed_skus = File.readlines(ARGV[0]).map(&:chomp)
master_products = Spreadsheet.from_file(ARGV[1])
master_products.pick_matcher(0)
def count_active(ss)
ss.rows.map { |r| r[20] }.count {|v| v.downcase ... | true |
cb92a254426835d223c60cca3d5f2d37aa189ed8 | Ruby | GabrielErbetta/meuhorario2 | /lib/tasks/crawler.rake | UTF-8 | 17,642 | 2.515625 | 3 | [] | no_license | namespace :crawler do
desc 'Crawl courses codes, names and curriculums'
task :courses => :environment do
puts '-----------------------------------------------------------------------'
puts '-> Starting courses crawling...'
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
page ... | true |
29db5c3974e7ca056fbd40df8bc1b238dd5bbbee | Ruby | bio-miga/miga | /lib/miga/result.rb | UTF-8 | 5,410 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Artistic-2.0"
] | permissive | # frozen_string_literal: true
require 'miga/result/dates'
require 'miga/result/source'
require 'miga/result/stats'
##
# The result from a task run. It can be project-wide or dataset-specific.
class MiGA::Result < MiGA::MiGA
include MiGA::Result::Dates
include MiGA::Result::Source
include MiGA::Result::Stats
... | true |
10f550c4a9162c6c927a9d6f49ea16222c16adc5 | Ruby | gsantana/nand2tetris | /projects/08/VMTranslator/VMTranslator.rb | UTF-8 | 955 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'pry-byebug'
require_relative 'source'
require_relative 'parser'
require_relative 'code_writer'
require_relative 'command'
require_relative 'command/push'
require_relative 'command/pop'
require_relative 'command/label'
require_relative 'command/goto'
require_relative 'command/ifgoto'
requir... | true |
edb63c9977c53755c14536bc8e0898c7b7e6fd5a | Ruby | RickGriff/address-bloc | /controllers/menu_controller.rb | UTF-8 | 5,146 | 4.03125 | 4 | [] | no_license | require_relative '../models/address_book'
class MenuController
attr_reader :address_book
def initialize
@address_book = AddressBook.new
end
def main_menu
puts "Main Menu - #{address_book.entries.count} entries"
puts "1 - View all entries"
puts "2 - Create an entry"
puts "3 - Search... | true |
03df3a6570d2135d4ba9272c68ad884caf5fcf4e | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz61_sols/solutions/Dennis Ranke/roll.rb | UTF-8 | 777 | 3.40625 | 3 | [
"MIT"
] | permissive | module Dice
def self.roll(expr)
expr = expr.gsub(/\s/, '')
while
expr.sub!(/\(([^()]+)\)/) { roll($1) } ||
expr.sub!(/(\A|[^\d])\-\-(\d+)/, '\\1\\2') ||
expr.sub!(/d%/, 'd100') ||
expr.sub!(/(\d+)d(\d+)/) { (1..$1.to_i).inject(0) {|a, b| a + rand($2.to_i) + 1} } ||
expr.sub!(/d(\... | true |
cc9b8be6b527c1352cfc33094f08c8e875039e8c | Ruby | RobertoBarros/batch_408_hospital_mvc | /app/models/patient.rb | UTF-8 | 371 | 3.21875 | 3 | [] | no_license | class Patient
attr_reader :name, :age
attr_accessor :id, :room
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@age = attributes[:age]
@room = attributes[:room] # This is a room instance. Not a room_id!!!
end
end
# r1 = Room.new(number: 333, capacity: 20)
# p... | true |
309db4297dde7ac4d96abaa3258a9f25b552e7a7 | Ruby | richygit/fed_mp_data | /csv_scraper.rb | UTF-8 | 3,134 | 3.015625 | 3 | [] | no_license | require 'csv'
require 'open-uri'
require './logging'
require_relative 'scraper_helper'
#get detailed info of MPs including titles and cabinet positions
class CsvScraper < Logging
include ScraperHelper
CSV_HOST = 'www.aph.gov.au'
MP_CSV_PATH = '/~/media/03%20Senators%20and%20Members/Address%20Labels%20and%20CSV%... | true |
d396aa6d7884331a6dab2a45a40162720fbbea8e | Ruby | hwinn4/hangman | /lib/player.rb | UTF-8 | 159 | 3.234375 | 3 | [] | no_license | class Player
attr_accessor :word, :turns, :letters
def initialize
@turns = 6
@letters = []
end
def out_of_turns?
self.turns < 1
end
end | true |
222ec1f7e1d12c079d98be5f7e002f542fd2f956 | Ruby | MarkUsProject/Markus | /app/lib/memory_revision.rb | UTF-8 | 4,426 | 2.890625 | 3 | [
"MIT",
"CC-BY-4.0"
] | permissive | # Class responsible for storing files in and retrieving files
# from memory
class MemoryRevision < Repository::AbstractRevision
# getter/setters for instance variables
attr_accessor :files, :changed_files, :files_content, :user_id, :comment, :timestamp, :server_timestamp
# Constructor
def initialize(revision_n... | true |
a9ac3417821a625c5cd2482ca82764de234d8f62 | Ruby | davidtadams/advent-of-code | /2020/day_10/part2.rb | UTF-8 | 349 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
ADAPTERS = (File.read('./simple_input.txt').split("\n").map(&:to_i) + [0]).sort
def get_paths(adapter, paths)
return 0 unless ADAPTERS.include?(adapter)
return 1 if ADAPTERS[0] == adapter
paths[adapter] ||= (1..3).sum { |num| get_paths(adapter - num, paths) }
end
paths = get_pat... | true |
be4afbb10cab22c3bec47faca6ef27c1779d4056 | Ruby | tiy-hou-q2-2015-rails/Day-1 | /x.rb | UTF-8 | 50 | 3.28125 | 3 | [] | no_license | x = 41
x = x + 1
puts "The value of x is #{x}!!!"
| true |
77c747acaca4d2dbc29b41c5510f9f8a50bdd6f3 | Ruby | tkt989/atcoder | /PracticeA.rb | UTF-8 | 97 | 3.109375 | 3 | [
"MIT"
] | permissive | a = gets.chomp.to_i
b, c = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
puts "#{a+b+c} #{s}" | true |
fb00a1e806b3f1be7da38394073fc31ef6b6a921 | Ruby | dukha/redis_manager | /app/models/profile.rb | UTF-8 | 3,265 | 2.859375 | 3 | [] | no_license | class Profile < ActiveRecord::Base
validates :name, :presence => true, :uniqueness=>true
# roles are defineds as symbols in config/authorization_rules.rb
# list all roles which are defiend there: Authorization::Engine.instance.roles
# roles do not change in any way at run-time so there is no need to keep the... | true |
edaa1c109dec0ef3bfa7fab8feb7686481e86974 | Ruby | zph/dotfiles | /home/bin/executable_git-pivotal_issue | UTF-8 | 401 | 2.796875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | #!/usr/bin/env ruby
puts "Enter initials>"
initials = gets.chomp
puts "Enter Pivotal Issue Number>"
issue_number = gets.chomp
puts "Enter Short description>"
description = gets.chomp.gsub(/ /, '_')
if !description.empty?
description = "_#{description}"
else
description = ""
end
branch_name = "#{initials}_#{issue_n... | true |
a7a859dcc65431fe5ff040f72df87a7b853237d7 | Ruby | terminalobject/boris-bikes | /lib/DockingStation.rb | UTF-8 | 619 | 3.265625 | 3 | [] | no_license | class DockingStation
attr_accessor :bikes, :capacity
DEFAULT_CAPACITY = 20
def initialize(capacity=DEFAULT_CAPACITY)
@bikes = []
@capacity = capacity
end
def release_bike
fail "There are no more bikes available" if empty?
fail "This bike is broken" if @bikes.last.working? == false
@bike... | true |
4b4fdfd7ed5c529924cf1641a1dd69994521c025 | Ruby | jlratliff/launch_school | /exercises/130_Foundations/01_easy_01/02_optional_blocks.rb | UTF-8 | 626 | 4.40625 | 4 | [] | no_license | # 02_optional_blocks.rb
# Write a method that takes an optional block. If the block is specified, the method should execute it, and return the value returned by the block. If no block is specified, the method should simply return the String 'Does not compute.'.
# Examples:
# compute { 5 + 3 } == 8
# compute { 'a' + '... | true |
e0c0c6a3a026b132aedcde23ee2fda2cb6fe6f7e | Ruby | granthouston44/Bear-River-and-Fish | /river.rb | UTF-8 | 215 | 3.25 | 3 | [] | no_license | class River
attr_reader :name #, :fish
# attr_accessor :fish
def initialize(name, fish)
@name = name
@fish = fish
end
def fish_count
return @fish.size
end
def lose_fish(fish)
@fish.delete(fish)
end
end
| true |
ea08dc1072b17570a898cba715c7bc324e1d109e | Ruby | Reltre/exercism-challenges | /ruby/grains/grains.rb | UTF-8 | 417 | 3.921875 | 4 | [] | no_license | class Grains
def self.square(square_number)
if square_number < 1 || square_number > 64
raise ArgumentError, "The value entered is either below 1 or above 64,
sorry the king will only grant grains for each square on a chess board."
end
2**(square_number - 1)
end
def self.total
(1..64)... | true |
84c962a7ee59ff98adae873e6f785d26745eaf44 | Ruby | dirv/NoughtsAndCrosses | /core/spec/computer_player_spec.rb | UTF-8 | 1,648 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'computer_player'
require 'human_player'
require 'board'
require 'game'
module NoughtsAndCrosses
describe ComputerPlayer do
let(:computer) { ComputerPlayer.new('O', 'X') }
it 'blocks the easiest possible 4x4 win' do
board = Board.new('XXX-O---O-------')
expect(co... | true |
8de681ccc9f700d967de8516671feabfb89a3afa | Ruby | HyeokJungKim/ttt-2-board-rb-bootcamp-prep-000 | /lib/board.rb | UTF-8 | 89 | 2.78125 | 3 | [] | no_license | # Define the variable board below.
i = 0
board = []
while i < 9
board[i] = " "
i+=1
end
| true |
8dc7ed6f717152acf2fe265bbcc360d796451389 | Ruby | tuomasj/lolserver | /lib/lolserver.rb | UTF-8 | 2,197 | 2.65625 | 3 | [] | no_license | require 'sinatra/base'
require 'find'
require 'redcarpet'
require 'mime/types'
ROOT_DIR = Dir.pwd()
class Localserver < Sinatra::Base
set :views, File.join(File.dirname(__FILE__), "views")
helpers do
def print_recursive(hash)
buf ="<ul>\n"
hash[:children].each do |item|
if item.kind_of?(... | true |
81dd2bb87fc36321b4dd908852108bb4d4050bef | Ruby | enderahmetyurt/hello_ruby_stuff | /codes/lambda.rb | UTF-8 | 120 | 3.53125 | 4 | [
"MIT"
] | permissive | hello = -> {"Hello"}
puts hello.call
# => Hello
sum = lambda {|x,y| x+y}
sum1 = -> x,y {x,y}
puts sum.call(1,2)
# => 3 | true |
1a35dbda1050cfce57c6861da59df3259ab91e08 | Ruby | Tarmogolf/building-blocks | /substrings.rb | UTF-8 | 436 | 3.78125 | 4 | [] | no_license | dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"]
def substrings (word_list, dictionary)
test_list = word_list.downcase
substrings_found = {}
for i in dictionary
num_found= test_list.scan(/#{i}/m).size
if(num_found > 0)
substrings_found[i] = num_fou... | true |
7c2939023768b30ed0b95e43facb4b858ad1c4e3 | Ruby | plopezpozuelo/aoc2020 | /day10/both.rb | UTF-8 | 866 | 3.59375 | 4 | [] | no_license | def puzzle1(joltages)
difference_of_1_count = 0
difference_of_3_count = 0
joltages.each_with_index do |joltage, idx|
next if idx == joltages.length - 1
difference = joltages[idx + 1] - joltage
difference_of_1_count += 1 if difference == 1
difference_of_3_count += 1 if difference == 3
end
re... | true |
4f56c1841636f27c80da13052f58bed7cef5ec95 | Ruby | johnktravers/project_euler | /problem_2/even_fibonacci_test.rb | UTF-8 | 639 | 3.53125 | 4 | [] | no_license | require('minitest/autorun')
require('minitest/pride')
class EvenFibonacciTest < Minitest::Test
def fibonacci(n)
if n <= 1
return n
else
fibonacci(n - 1) + fibonacci(n - 2)
end
end
def even_fibonacci_sum(limit)
sum = 0
n = 0
fib = fibonacci(n)
until fib >= limit
n +... | true |
8baf985ce036d82e9824d8344e155c7362f0062a | Ruby | vntzy/schemerald | /lib/schemerald/Cons.rb | UTF-8 | 654 | 3.28125 | 3 | [
"MIT"
] | permissive | # the most basic abstraction in lisp
class Cons
attr_reader :car, :cdr
def initialize(car, cdr)
@car = car
@cdr = cdr
end
def arrayify
return self unless list?
return [car] + cdr.arrayify
end
def list?
cdr.list?
end
def scheme_eval(environment, forms)
return forms.get_value(c... | true |
afaca13a8ca5402b83d72e9819ec7568a47aa36e | Ruby | MohamedBrary/rails5-joggy | /app/controllers/api/v1/model_hash.rb | UTF-8 | 693 | 2.578125 | 3 | [] | no_license | module Api::V1::ModelHash
def user_hash(user)
{
id: user.id,
email: user.email,
name: user.name
}
end
def user_token_hash(user_token, *args)
options = args.extract_options!
output = {
access_token: user_token.access_token
}
output.update(user: user_hash(... | true |
2bc8a51acc67eb68d7b83d20cbcd8638b2bdf671 | Ruby | transtelco/rails-app | /app/graph/types/human_type.rb | UTF-8 | 705 | 2.703125 | 3 | [] | no_license | # type Human : Character {
# id: String!
# name: String
# friends: [Character]
# appearsIn: [Episode]
# homePlanet: String
# }
module Types
HumanType = GraphQL::ObjectType.define do
name "Human"
description "A flesh-and-blood character in Star Wars"
interfaces [GraphQL::Relay::Node.interface, Ch... | true |
0db8f5121acc9a1581626ba3effb3450125f56d7 | Ruby | rossfuhrman/KataChain | /2012/11/12/lib/cart.rb | UTF-8 | 1,041 | 3.53125 | 4 | [] | no_license | class Cart
attr_reader :total
def initialize
@total = 0
@items = []
@produce = {}
end
def add_item(item_name)
@total += item_price_lookup[item_name]
@items << item_name
end
def add_produce(produce_name, weight)
@total += produce_price_lookup[produce_name] * weight
if @produce[pro... | true |
a012301942f79e610ba96dce26eee7b8e9d46f2f | Ruby | codemilan/old_stuff | /active_point1/HashStorage/Storage.rb | UTF-8 | 3,099 | 2.765625 | 3 | [] | no_license | class Storage
LOCK = "lock"
OBJECTS = "objects"
JOURNAL = "journal"
STATE = "state"
def initialize name, basedir
raise "Directory doesn't exists '#{basedir}'!" unless File.exist? basedir
@path = File.join(basedir.gsub("\\", '/'), name.to_s)
Dir.mkdir @path unless File.exist? @path
Dir.mkdir F... | true |
c0c7abac0cf8be26e5f63d873cd1d5a82a9ac6b2 | Ruby | lackita/ruby-refactor | /spec/code_folder.rb | UTF-8 | 742 | 2.796875 | 3 | [
"MIT"
] | permissive | require "tempfile"
require "open3"
class CodeFolder
def initialize
@requires = []
@files = []
end
def create_lib(contents)
f = create_file(contents)
@requires << f.path
f
end
def create_file(contents)
f = Tempfile.new(["", ".rb"])
@files << f
f.write(contents)
f.flush
... | true |
bcb5e9027b4f2beb90899bbe3c9baea241f625a9 | Ruby | chaugirl/object_oriented_programming | /people.rb | UTF-8 | 740 | 4.25 | 4 | [] | no_license | class Person
def initialize(name)
@name = name
end
def greeting
puts "Hi, my name is #{@name}"
end
end
class Student < Person
def learn
puts "I get it"
end
end
class Instructor < Person
def teach
puts "Everything in Ruby has an Object"
end
end
Instructor.new("Chris").greeting
Student.new("Christina"... | true |
4a009449e46ef0da8bf9274719aeee6d5ec9bb42 | Ruby | miniengineer/ruby_lessons | /rubytut_1/lesson10/rome.rb | UTF-8 | 72 | 2.65625 | 3 | [] | no_license | def visit_rome
puts "You came to Rome!"
puts "Colosseum, Trevi Fountain, Pantheon"
end | true |
046d7d068f3c5ff4141077d389298d1ae1e1ab27 | Ruby | AlexCyrex/me | /shrkbot-readme/modules/fun_stuff.rb | UTF-8 | 917 | 2.6875 | 3 | [] | no_license | # Fun, trolly stuff goes in here
module FunStuff
extend Discordrb::EventContainer
extend Discordrb::Commands::CommandContainer
@ping_whitelist = [94558130305765376,377840962128445441,98499497348321280,155963500265603072,305860996029874178]
message(contains: /^lol$/i) do |event|
event.respond '- Rondo' if (... | true |
22c749fd95c27dddc9dd8c9c18d22981d5a73d21 | Ruby | Alefuentes982/desafio_arreglos_y_arvchivos | /proyecciones.rb | UTF-8 | 664 | 3.265625 | 3 | [] | no_license |
def proyeccion(file, x, y, z)
ventas = open(file).read.chomp.split(',')
ventas_int = ventas.map { |x| x.to_i }
arreglo_nuevo = []
veces = ventas_int.length
veces.times do |e|
if e >= x && e <= y
arreglo_nuevo.push(ventas_int[e] * z)
else
... | true |
f7927a391b6dcc38801160f1778c550d2464fee1 | Ruby | EricLarson2020/backend_module_0_capstone | /day_1/ex3_calc.rb | UTF-8 | 96 | 2.875 | 3 | [] | no_license | puts "There are #{3+2} mice nibbling at my toes"
puts "Did another mouse join the 5?"
puts 6<=5
| true |
08d38cbdf07e3c17afd00d5d3d9037084cf7d555 | Ruby | ItsMeCK/wizcart | /solution-01.rb | UTF-8 | 233 | 3.703125 | 4 | [] | no_license | def reverse_string(input)
stack = []
reverse_stack = []
input.each_char do |echar|
stack << echar
end
while stack.length >= 1
reverse_stack << stack.pop()
end
reverse_stack.join('')
end
puts reverse_string('hello')
| true |
db7272c9375857d013a09ffc2985df9d0ffe6f61 | Ruby | archiloque/tools | /podcast.rb | UTF-8 | 2,566 | 2.765625 | 3 | [
"MIT"
] | permissive | # Generate a podcast rss file from all the mp3 contained in a directory
# The mp3 are named "YYYY-MM-DD??????" and we get their title from their id3 tags
# Params
# - directory of mp3 files, default '.'
# - root url for the mp3s, default 'http:/localhost/'
# - the podcast title, default 'podcast'
# - image url
# - a ta... | true |
d9d17d3d24e1456359de7ab37fe1d41c4d325567 | Ruby | tmaria17/vending-machine | /lib/item.rb | UTF-8 | 99 | 2.640625 | 3 | [] | no_license | class Item
attr_reader :name
def initialize(item_data)
@name = item_data["type"]
end
end
| true |
a8fcddafd70d8443e87b65d10eea92f346ef36b8 | Ruby | Keemtaker/popapp | /lib/tasks/sales.rake | UTF-8 | 2,079 | 2.53125 | 3 | [] | no_license |
desc "This task retrieves completed orders"
task :sales => :environment do
User.all.each do | user |
$merchant_client = Square::Client.new(
access_token: user.access_token,
environment: ENV['SQUARE_ENVIRONMENT']
)
merchant_results = $merchant_client.merchants.retrieve_merchant(
merch... | true |
befd4308df39b94bca2945406e24dd5af1753731 | Ruby | WataruOjima/furima-32489 | /spec/models/user_spec.rb | UTF-8 | 5,279 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
describe User do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録がうまくいくとき' do
it 'nicknameとemail、passwordとpassword_confirmationが存在すれば登録できる' do
expect(@user).to be_valid
end
end
context '新規登録がうまくいかないとき' do
it 'nickna... | true |
8dc2c9c9496270c77d2ab29c103444dc3246b236 | Ruby | l0nglive/my-first-repo | /ruby/intro_programming_book/5_loops_iterators/2_stop_loop.rb | UTF-8 | 92 | 3.40625 | 3 | [] | no_license | answer = ""
while answer != "STOP" do
puts "what is your input?"
answer = gets.chomp
end | true |
5fd353e441afa91908a81cc4b61305e8f50db55d | Ruby | akuhn/euler | /problem_48.rb | UTF-8 | 310 | 3.203125 | 3 | [] | no_license | require_relative 'euler'
# Problem 48
# 18 July 2003
# The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
# Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
(1..10).collect{|n|n**n}.sum.should == 10405071317
(1..1000).collect{|n|n**n}.sum.to_s[-10..-1].should == "9110846700"
| true |
aea97d00fd7f0ba134cb5ae59e8fb1edcc95195e | Ruby | shawnhark/learntoprogram | /chapter7/deafgrandma.rb | UTF-8 | 344 | 3.265625 | 3 | [] | no_license | # Deaf Grandma
words = "deaf"
puts 'Say something to your dear old grandma.'
while words != words.upcase
words = gets.chomp
if words != words.upcase
puts 'HUH?! SPEAK UP, YOUNG WHIPPERSNAPPER.'
end
end
year = 1929
while year <1930
year = rand(1951)
end
puts 'NO, NOT SINCE ' + year.to_s + '!'
puts ' '
puts 'HAVE A... | true |
bc90ed2d4d71a74867ac8c545dd4c832cc59054c | Ruby | itayayuichiro/text_syori | /ed.rb | UTF-8 | 3,784 | 2.890625 | 3 | [] | no_license | class Ed
$buffer = []
$position = 0
def initialize
f = open(ARGV[0])
f.each{|line|
$buffer.push(line)
}
$position = $buffer.length-1
mode = nil
while str = STDIN.gets
read(str.chomp)
end
end
def read(str)
eval(str)
end
def eval(str)
addr = '(?:\d+|[.$,;]|\/.*... | true |
7d46f1f0093a054c9e4b96f60db58f93af5c48ac | Ruby | RavensKrag/chipmunk-ffi | /lib/chipmunk-ffi/bb.rb | UTF-8 | 1,828 | 2.609375 | 3 | [
"MIT"
] | permissive | module CP
class BBStruct < NiceFFI::Struct
layout( :l, CP_FLOAT,
:b, CP_FLOAT,
:r, CP_FLOAT,
:t, CP_FLOAT )
end
cp_static_inline :cpBBNew, [CP_FLOAT,CP_FLOAT,CP_FLOAT,CP_FLOAT], BBStruct.by_value
cp_static_inline :cpBBintersects, [BBStruct.by_value,BBStruct.by_value], :in... | true |
6b10e6467ea57ae46f1825cc916e5ec2e7791cc9 | Ruby | Suil3File/albacore | /spec/ext_teamcity_spec.rb | UTF-8 | 3,149 | 2.71875 | 3 | [] | no_license | require 'spec_helper'
require 'albacore/ext/teamcity'
describe Albacore::Ext::TeamCity, 'When outputting Teamcity progress messages' do
def capture_stdout &block
yield
@output
end
describe 'Simple escaping' do
it 'Should escape [ with a pipe |' do
expect(Albacore::Ext::TeamCity.escape('['))... | true |
31be3f8eeee242c0b84ee4b43276ff07dd5e0579 | Ruby | sitaraemilys/takeaway-challenge | /spec/dish_spec.rb | UTF-8 | 745 | 3.375 | 3 | [] | no_license | require 'dish'
describe Dish do
subject(:ramen) { described_class.new("Chilli Chicken Ramen", 7.5) }
subject(:no_arguments) { described_class.new }
subject(:one_argument) { described_class.new("Duck Gyoza") }
describe '#initialize' do
it 'raises an error if no arguments given' do
expect{ no_argume... | true |
ab9df59ca0d45957ca89771baa7e59032e4d182e | Ruby | yasufumic/ruby | /break_next_redo.rb | UTF-8 | 396 | 2.90625 | 3 | [
"MIT"
] | permissive | puts "break の例"
i = 0
[ "Perl", "Python", "Ruby", "Scheme"].each do |lang|
i += 1
if i == 3
break
end
p [i, lang]
end
puts "next の例"
i = 0
[ "Perl", "Python", "Ruby", "Scheme"].each do |lang|
i += 1
if i == 3
next
end
p [i, lang]
end
puts "redo の例"
i = 0
[ "Perl", "Python", "Ruby", "Scheme"].each... | true |
6cbfaaa142c070346d0207b254b037e71a278db0 | Ruby | Atenna/Linguazza | /test/unit/word_test.rb | UTF-8 | 5,792 | 2.625 | 3 | [] | no_license | require 'test_helper'
class WordTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "levenstine range" do
words = [
['syr', 'sýr'],
['stryko', 'strýko'],
['záclona', 'zaclona'],
['mäso', 'maso'],
['something', 'other'],
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.