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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
edb192574ae0c8e9dc698550e864b7ffe5d22e11 | Ruby | befool-inc/swaffle | /lib/swaffle/yaml.rb | UTF-8 | 6,891 | 2.765625 | 3 | [] | no_license | require "json"
require "yaml"
require "erb"
module Swaffle
module Yaml
def self.read_yaml_file(file_path)
YAML.safe_load(ERB.new(::IO.read(file_path)).result)
end
def self.load_file_with_ref(path, root)
hash = read_yaml_file(path)
resolved_hash = load_ref_with_file(hash, path, root)
... | true |
228c8f9df4c91b153c493fe6a5ebb9a81ebe1b11 | Ruby | AKnopf/edu_draw | /examples/areas.rb | UTF-8 | 386 | 3.046875 | 3 | [
"MIT"
] | permissive | require "edu_draw"
sheet = EduDraw::Sheet.new(x: 150, y: 150)
pen = sheet.new_pen(x: 52, y: 10)
# Every move in the fill-block will create a filled a shape
pen.fill do
5.times do
pen.move 40
pen.turn_right 36
end
end
#Every move out of the fill block just draws a line
# Those 10 moves result in a half-filled d... | true |
9ec4eefe94e84f99d965b3df672a57c2c231d1e5 | Ruby | paulfitz/coopy-ruby | /lib/coopy/csv.rb | UTF-8 | 4,113 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/bin/env ruby
# encoding: utf-8
module Coopy
class Csv
def initialize
@cursor = 0
@row_ended = false
end
protected
attr_accessor :cursor
attr_accessor :row_ended
attr_accessor :has_structure
public
def render_table(t)
result = ""
w =... | true |
008f19bc5655e0111f43198c87377018e2b22759 | Ruby | icvlahovic/the-bachelor-todo-web-012918 | /lib/bachelor.rb | UTF-8 | 1,208 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def get_first_name_of_season_winner(data, season)
data[season].map do |contestant_hash|
if contestant_hash["status"].downcase == "winner"
return contestant_hash["name"].split.first
end
end
end
def get_contestant_name(data, occupation)
data.map do |season, contestants|
contestants.map do |contes... | true |
6e7cfd8f08e43de3ef2258b2a45650f37334ba5a | Ruby | mozartdminor/HackerRank | /Algorithms/Implementation/angryProfessor.rb | UTF-8 | 336 | 3.359375 | 3 | [] | no_license | #https://www.hackerrank.com/challenges/angry-professor
cases = gets.to_i
for i in 1..cases
nk = gets.split(" ")
n = nk[0].to_i
k = nk[1].to_i
arrivals = gets.split(" ")
ontime = 0
for j in 1..n
if arrivals[j-1].to_i <= 0
ontime += 1
end
end
if ontime >= k
puts("NO")
else
puts("... | true |
5f0f502048ac0233b41fa507cbcfc5d174933866 | Ruby | ged/graphics | /examples/tank.rb | UTF-8 | 2,967 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby -w
require "graphics"
D2R = Math::PI / 180.0
class Tank < Graphics::Body
ACCELERATE = 0.25
DECELERATE = 0.125
ROTATION = 2
TICK_ENERGY = 5
SHOT_ENERGY = 100
BULLET_SPEED = 9.0
MAX_SPEED = 4.0
MAX_ROTATION = 360
MAX_ENERGY = 100
attr_accessor :t
attr_accessor :e
... | true |
82712dd78df498bca228c1ce2b6b0e47368d460e | Ruby | Invoca/process_settings | /spec/lib/process_settings/targeted_settings_spec.rb | UTF-8 | 4,181 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
require 'logger'
require 'process_settings/targeted_settings'
describe ProcessSettings::TargetedSettings do
TARGETED_SETTINGS = [{
'filename' => 'honeypot.yml',
'target' => true,
'settings' => {
'honeypot' => {
'promo_number' => '+1800555... | true |
80f16872932a2e5394ee8a3b46dcb4a2ab49cba0 | Ruby | nanma80/euler_project | /p001_025/p004/main.rb | UTF-8 | 370 | 3.640625 | 4 | [] | no_license | MAX = 999
MIN = 900
def is_palindrome?(number)
number.to_s.reverse == number.to_s
end
max_palindrome = 0
MAX.downto(MIN) do |i|
MAX.downto(MIN) do |j|
n = i * j
if n > max_palindrome && is_palindrome?(n)
max_palindrome = n
end
end
end
puts max_palindrome # 906609
# puts is_palindrome?(9)
# ... | true |
0b927af7224f45f25bc207bcfeb22079655dbebd | Ruby | VijayaArun/e-commerce_web_app | /lib/spree/core/importer/custom_product_importer.rb | UTF-8 | 4,789 | 2.765625 | 3 | [] | no_license | # require 'find'
# images = []
# Find.find("/home/pooja/Documents/shree sarees" &&"*.jpg" || "*.png") do |path|
# images << path if path = ~ /.*\.jpg$/
# # Dir["*.jpg","*.png"]
# # Dir.foreach("/documents/shree sarees/*") do |image|
# # next if image ==
# # require file
# end
# image_file_paths = Find.find('/home/... | true |
8319679b2b5f72c31916210c581944941933a3bc | Ruby | MichaelDevenport/chromotype_test | /lib/geo_lookup.rb | UTF-8 | 2,780 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'nominatim'
require 'geonames_api'
class GeoLookup
include CacheSupport
attr_reader :lat, :lng
# See http://en.wikipedia.org/wiki/Decimal_degrees#Accuracy
# 4 digits gives us ~10m resolution, 3 digits gives us ~100m resolution.
# Given that most aGPS have ~50m resolution, and we want some cache hits... | true |
faf11d9acdcf31d78d3e6701b4d5dd8f81f4e914 | Ruby | dinhhientran/code-utility | /lib/hash_beautifiers/hash_beautifier.rb | UTF-8 | 2,264 | 3.484375 | 3 | [] | no_license | class HashBeautifier
COMMA = ','
COLON = ':'
LEFT_BRACKET = '['
RIGHT_BRACKET = ']'
LEFT_BRACE = '{'
RIGHT_BRACE = '}'
DEFAULT_INDENT = 2
DEFAULT_VALUE_ALIGNED = true
def initialize(hash = nil)
@hash = hash
end
def setHash(hash)
@hash = hash
end
def self.getBeautifierInstance(lang... | true |
a988d9b75d6d8f38bebb2421434eb90e8eac3989 | Ruby | cgoodmac/ruby | /labs/stoq/user.rb | UTF-8 | 249 | 3.546875 | 4 | [] | no_license | class User
attr_accessor :name, :pw, :cash, :stocks
def initialize(name, pw, cash)
@name = name
@pw = pw
@cash = cash
@stocks = [] # creates an empty array of stocks when each user object is created
end
def to_s
"#{name}"
end
end | true |
45f94a98e8bc0996a102c257ef959e58a46084e4 | Ruby | thepoppingone/rubytwodistinctnumssumstoarangeofvalues | /iReader.rb | UTF-8 | 1,518 | 3.890625 | 4 | [] | no_license | # This file uses the n factorial way (brute force method) and it only manages to
# pass the first two test files: test1.txt test2.txt
# beginning_time = Time.now
# import the ruby `set` for removing duplicate values
require 'set'
# Declare a new set and add all the numbers read from the file to form a
... | true |
fe05558b296aa527c418afa83c69812a7aacfe37 | Ruby | nktaushanov/rucomasy | /spec/core/tasks/expr_spec.rb | UTF-8 | 3,306 | 3.203125 | 3 | [] | no_license | require './core/rucomasy'
require 'treetop'
Treetop.load './core/tasks/grammer'
module Rucomasy
describe Expr do
def parse(input)
ArithmeticParser.new.parse(input).to_sexp
end
def evaluate(expression, hash = {})
Expr.build(parse(expression)).evaluate(hash)
end
it "evaluates variabl... | true |
5f8bcd11f4cc5751967b9137502a3acb2efc5923 | Ruby | patbrennan/ltp-exercises | /ch8.rb | UTF-8 | 226 | 3.640625 | 4 | [] | no_license | #return sorted array when user hits enter
words = []
puts "Enter your words"
input = gets.chomp.to_s.downcase
until input == ""
words.push input
input = gets.chomp.to_s.downcase
end
if input == ""
puts words.sort
end
| true |
1a57459a8627aca07c816e4b0dff91fb5f356503 | Ruby | Itamarzil/bootcamp | /Rails/Ex1/app/models/my_model.rb | UTF-8 | 215 | 2.859375 | 3 | [] | no_license | class MyModel < ApplicationRecord
def inc
firstNumRecord = MyModel.find(1)
firstNumRecord.num = firstNumRecord.num + 1
firstNumRecord.save
puts "done increasing num."
end
end
| true |
3987ac9176e1c8e8af5c9076c5375d587f940a2e | Ruby | Park9eon/learn-ruby | /number.rb | UTF-8 | 157 | 3.203125 | 3 | [] | no_license | =begin
Ruby Numbers
Usual operators:
+ addition
- subtraction
* muliplication
/ divistion
=end
puts 1 + 2
puts 2 * 3
puts 3 / 2
puts 10 - 11
puts 1.5 / 2.6
| true |
c3d22e3bc07470d34e661c0f667da9613c3a3814 | Ruby | alex-phillips/clouddrive | /lib/clouddrive/commands/remove_command.rb | UTF-8 | 754 | 2.71875 | 3 | [
"MIT"
] | permissive | module CloudDrive
class RemoveCommand < Command
parameter "remote_path", "Remote path of node to move to trash"
option ["-i", "--id"], :flag, "Designate remote node by ID"
def execute
@offline = false
init
if id?
node = Node.load_by_id(remote_path)
unless node
... | true |
8378874f8c7f929bd880d90a270925c3fb001ad6 | Ruby | allenscheng/daily_exercises | /recursion.rb | UTF-8 | 320 | 3.296875 | 3 | [] | no_license | # @total = 0
# def sum_num(num)
# if num <= 1000
# @total += num
# sum_num(num+1)
# end
# return @total
# end
# p sum_num(1)
def sum_num(num, ar)
sum_ar = ar
if num === 1000
return sum_ar
end
if num <= 1000
sum_ar += num
p sum_ar
sum_num(num + 1, sum_ar)
end
end
p sum_num(0,0) | true |
a26c1cdc1deefa69887b3bbc69a2fa2ef40afa3c | Ruby | gennyallcroft/bookmarks | /week_2_morning_projects/flip_coin.rb | UTF-8 | 423 | 3.40625 | 3 | [] | no_license | class Coin
end
class CountScore
count = 0
def flip(coin)
random_number = RandomNumber.new
if random_number.random == 0
count += 1
'You flipped a head. The number of heads you have flipped is' + count
elsif random_number.random == 1
'You flipped a tails. The number of heads you have fl... | true |
a16d23b56f8e9a5561bc7328a22003b0b8623121 | Ruby | kylemccurley/RB101_Programming_Foundations | /Lesson4_Ruby_Collections/loops1/loop_on_command.rb | UTF-8 | 160 | 3.3125 | 3 | [] | no_license | loop do
puts 'Should I stop looping?'
answer = gets.chomp
break if answer.downcase == 'yes'
puts "Please enter 'yes' if you would like to stop looping."
end | true |
d7d83cde59b32641bbb9d2224a910ba352028fba | Ruby | justinkizer/a-A-HW | /W2D1/skeleton/lib/simon.rb | UTF-8 | 1,862 | 3.75 | 4 | [] | no_license | class Simon
COLORS = %w(red blue green yellow)
attr_accessor :sequence_length, :game_over, :seq
def initialize(sequence_length = 1)
@sequence_length = sequence_length
@game_over = false
@seq = []
@answer_seq = []
end
def play
puts "\nWelcome to Simon!"
until @game_over
take_tu... | true |
895d04542c9a4529ff5914afd9da0f5b93f83db1 | Ruby | yonigoldberg/games-of-thrones-board-game | /app/models/deck.rb | UTF-8 | 988 | 2.578125 | 3 | [] | no_license | class Deck < ActiveRecord::Base
attr_accessible :views, :cards_order, :deck_type_id, :last_viewed_at, :last_viewed_by, :game
belongs_to :game
serialize :cards_order
validates_presence_of :game, :deck_type_id
after_save :populate_card_order
def peek(peeked_by)
unless (self.cards_order.blank?)
car... | true |
052e070d68fc8f1755a4a12c01bb2b2f58806e86 | Ruby | brez/red-vector | /lib/redadapter.rb | UTF-8 | 1,809 | 2.671875 | 3 | [
"MIT"
] | permissive | #strategy pattern adapter - needs to be delgator
#will support other adapters eventually
#the adapter code will likely change a lot when we introduce support for say,
#redis which supports more complex data structures than pstore
class Redadapter
include Redpstore #this should be configurable
def initialize()
... | true |
89db9c105a2bc4ba362b0c5f468f056609c63fcb | Ruby | RiptideWallace/Two-O-Player-Game | /games.rb | UTF-8 | 1,942 | 3.59375 | 4 | [] | no_license | module MathGame
class Games
# When a game begins two new players are created
# and pushed to the players array
# Current player starts at zero
def initialize
@players = []
@players.push(Players.new)
@players.push(Players.new)
@current_player = 0
end
def start_game
... | true |
e70268429111e303d78b32bcc57540f94c27381b | Ruby | AlexStupakov/sea_battle | /lib/ship.rb | UTF-8 | 192 | 2.765625 | 3 | [] | no_license | # frozen_string_literal: true
class Ship
attr_accessor :x_position, :y_position
def initialize(x_position, y_position)
@x_position = x_position
@y_position = y_position
end
end
| true |
acf8ed8829b55c2e90e985707e7530a3ccea331a | Ruby | kashiftufail/sunsspot_search | /lib/foo.rb | UTF-8 | 111 | 2.796875 | 3 | [] | no_license | module Foo
def my_function(x, y)
puts (x+y).inspect+"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
end
end | true |
b5fbcea5f3ff136a919148cb610527eab9edc970 | Ruby | AugustinBoju/mini_jeu_POO | /lib/player.rb | UTF-8 | 1,896 | 3.71875 | 4 | [] | no_license | class Player
attr_accessor :name, :life_points
def initialize(name)
@name = name
@life_points = 10
end
def show_state
puts "#{@name} à #{life_points} points de vie"
end
def gets_damage(dgt)
@life_points = @life_points - dgt
if @life_points <= 0
puts "le joueur #{@name} a été tu... | true |
8143e7f3e3c2f3c75d0ac5c88f3371a3610d888c | Ruby | newscorp-ghfb/rspec-sidekiq | /spec/rspec/sidekiq/matchers/be_a_delayed_job_spec.rb | UTF-8 | 671 | 2.5625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe 'delay call' do
describe '.delayed_a_job_for' do
class FooClass
def bar(str)
str
end
end
it 'returns true if the method given has been delayed' do
FooClass.delay.bar('hello!')
expect('bar').to be_a_delayed_job
expect('bar2').to_not be... | true |
66db4dc247d4cfffe2c5d111659bab8ca5ff3e1a | Ruby | Carrison57/Coin-Changer | /test_coin_changer.rb | UTF-8 | 535 | 2.6875 | 3 | [] | no_license | require "minitest/autorun"
require_relative "coin_changer.rb"
class Test_Coin_Changer < Minitest::Test
def test_13_returns_1_dime_3_pennies
assert_equal({:quarter => 0, :dime => 1, :nickel => 0, :penny => 3}, coin_changer(13))
end
def test_1027_returns_41_quarters_2_pennies
assert_equal({:quarter => 4... | true |
51948cc0b627d33637bd828cd78d388e3266a215 | Ruby | deanpcmad/RackspaceCloudDNS | /lib/rackspace_cloud_dns/record.rb | UTF-8 | 1,298 | 2.625 | 3 | [
"MIT"
] | permissive | module RackspaceCloudDns
class Record
# List all records for a domain
def self.all(domain_id)
RackspaceCloudDns::Request.request("domains/#{domain_id}/records", :get)
end
# Search though all records for a domain
def self.search(domain_id, name, type=nil, data=nil)
RackspaceCloudDns::Request.request("... | true |
098e558c23c8f6b5b00ec7f6974a9b59b920be7b | Ruby | adamwyeth/blackjack | /player.rb | UTF-8 | 682 | 3.78125 | 4 | [] | no_license | require_relative 'hand.rb'
#Container for player hands and chip counts
class Player
attr_reader :name, :chips, :bet
attr_accessor :hand
def initialize(name, chips)
@name = name
@chips = chips
end
def make_bet(bet_amt)
raise "Insufficient chips for bet" if bet_amt > @chips
@chips -... | true |
4d1f5d8bd61d1a63813639624a5244e8837ddd7a | Ruby | aclarkk/terminalTwtter | /update.rb | UTF-8 | 431 | 2.609375 | 3 | [] | no_license | require_relative "config"
client = Twitter::REST::Client.new do |config|
config.consumer_key = $consumer_key
config.consumer_secret = $consumer_secret
config.access_token = $access_token
config.access_token_secret = $access_token_secret
end
# get new tweet from a bash argument
newTweet = AR... | true |
4d7ce37544a4c2b08add0ecb3e67114ebcb3b4a6 | Ruby | jonathan-c/alfred | /app/models/meal_status.rb | UTF-8 | 962 | 2.765625 | 3 | [] | no_license | class MealStatus < ActiveRecord::Base
attr_accessible :meal_id, :status_id
after_create :subtract_remaining_nutrients
after_destroy :re_add_remaining_nutrients
belongs_to :meal
belongs_to :status
def subtract_remaining_nutrients
calories = []
protein = []
carbs = []
self.status.me... | true |
a7225bfb909c74d44569307e86abcda319a586fd | Ruby | lilbyrne/kwk-l1-intro-to-loops-two-step-lab-kwk-students-l1-bal-061818 | /two_step_and_repeat.rb | UTF-8 | 827 | 3.625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def first_steps
loop do
puts "Right foot back"
sleep (0.5)
puts "Left foot back"
sleep (0.5)
puts "Right foot back"
sleep (0.5)
puts "Stop"
sleep (0.5)
break
end
end
first_steps
def a_few_more_steps
loop do
puts "Right foot steps right and back"
sleep (0.5)
puts "L... | true |
5ab9d83955982fbfe69422a755db87843b39a260 | Ruby | eabrawer/learn_ruby2 | /timer.rb | UTF-8 | 70 | 2.546875 | 3 | [] | no_license | class Timer
def initialize(seconds=0)
@seconds = seconds
end
end | true |
ea4a0f83f3d335e8efe60f301947c689d0daf8db | Ruby | imendi/assisted_workflow | /lib/assisted_workflow/addons/pivotal.rb | UTF-8 | 3,054 | 2.515625 | 3 | [
"MIT"
] | permissive | require "assisted_workflow/exceptions"
require "assisted_workflow/addons/base"
require "tracker_api"
# wrapper class to pivotal api client
module AssistedWorkflow::Addons
class PivotalStory < SimpleDelegator
def initialize(story)
super
end
def owners_str
url = "/projects/#{project_id}/stori... | true |
b9bc39777e10cb3dfc9e40204a01368a6b0ff857 | Ruby | neosaurrrus/triangle-classification-online-web-sp-000 | /lib/triangle.rb | UTF-8 | 712 | 3.53125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
def initialize(a,b,c)
@a = a
@b = b
@c = c
@triangle_lengths = [@a,@b, @c]
end
def kind
# raise an error of triangle is invalid
if @a <= 0 || @b <= 0 || @c <= 0
raise TriangleError
end
@triangle_lengths = @triangle_lengths.sort
if @triangle_lengths[0]... | true |
dc5cccd0575028c951bebbfbbf8676df83e932c7 | Ruby | MikeAlvarado/Mate | /src/constants/operators.rb | UTF-8 | 1,733 | 3.578125 | 4 | [] | no_license | # Operators
# Constants of operators used for identifying the operators
# specified in the quadruples
module Operators
EQUAL = 0
NOT_EQUAL = 1
LESS_EQUAL = 2
GREATER_EQUAL = 3
LESS = 4
GREATER = 5
AND = 6
OR = 7
MOD = 8
MULTIPLY = 9
... | true |
ef18c1b58c1dda95816b66a775e45c842ed34ba9 | Ruby | grzesiek/git_compound | /lib/git_compound/component/version/tag.rb | UTF-8 | 509 | 2.640625 | 3 | [
"MIT"
] | permissive | module GitCompound
class Component
module Version
# Component version as tag
#
class Tag < VersionStrategy
def initialize(repository, tag)
@repository = repository
@tag = tag
end
def ref
@tag
end
def sha
@re... | true |
09ffb1190c513d5f8a97f8ecb7d50dcc3e239acc | Ruby | Stephanie041996/Capstone_linters_project | /lib/style_linter.rb | UTF-8 | 2,079 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'colorize'
module StyleLinter
def comment_check(line, number)
return unless line.include?('/*')
@errors << "#{'WARNING'.yellow} :Comments have been detected on the line number #{number} please remove all comments\n"
end
def space_check(line, number)
return unless line =~ /\A\w/ && !line.st... | true |
9aad3224c3c5d2ca26e26596689b5d33f43440cf | Ruby | jitendra1989/sent_buddy_beers | /lib/tweet.rb | UTF-8 | 2,475 | 3.171875 | 3 | [] | no_license | #require "rubygems"
#require "active_support/core_ext"
#require "test/unit"
class Tweet
class Invalid < Exception; end
attr_accessor :text, :user, :quantity, :drink, :memo
def initialize(text)
self.text = text
self.parse
raise Invalid if [user, quantity, drink].any?(&:blank?)
end
def drink=(dr... | true |
7fb8b077d3eadfef85b370336049b63c78ef82fc | Ruby | Gurmal/ArenaMasters | /app/models/gladiator.rb | UTF-8 | 1,820 | 2.6875 | 3 | [
"MIT"
] | permissive | #require 'Dice' -- auto included by Rails
#loglevel legacy from ruby still used some but logger is replacing slowly
$loglevel = 1
class Gladiator < ApplicationRecord
belongs_to :team
has_many :fight_items
has_many :fights, through: :fight_items
before_create :setstats
def setStyle(fightStyle)
self.... | true |
14c794fb455500b6c2f36f0a6201e7a56463fdb6 | Ruby | srawlins/msieve | /lib/msieve.rb | UTF-8 | 857 | 2.5625 | 3 | [] | no_license | # Thank you, Nokogiri
require 'rbconfig'
ENV['PATH'] = [File.expand_path(
File.join(File.dirname(__FILE__), "..", "ext")
), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw|mingw32)/i
require File.dirname(__FILE__) + '/../ext/msieve'
class Msieve
def self.clear_log(log_name = "msie... | true |
5aa23454923e39e48821d298d0d0ff91fc2da180 | Ruby | JustinData/GA-WDI-Work | /w03/d03/Paris/load_data.rb | UTF-8 | 582 | 3.109375 | 3 | [] | no_license | require 'pg'
# bring the data into memory
# create an array to format the data to put into the table.
db_conn = PG.connect( dbname: "sandbox" )
file = File.new("data.txt", "a+")
file.each do |line|
player_array = line.split(",")
query = "INSERT INTO players "
query += "(name,age,team,games,points) VALUES"
query... | true |
8d91feafdc9fca656a6a189aae18373bf3adab9b | Ruby | technohippy/red-grape | /test/test_on_the_nature_of_pipes.rb | UTF-8 | 3,010 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'red_grape'
# test the patterns shown in: http://markorodriguez.com/2011/08/03/on-the-nature-of-pipes/
class OnTheNatureOfPipesTest < Test::Unit::TestCase
def setup
@graph = RedGrape.load_graph 'data/graph-example-1.xml'
end
def test_basic
assert_equal '1',
@graph.v(1)[... | true |
3ff4a59423f7598e1e94c0e68570c8805aedaf93 | Ruby | msoanes/convent | /lib/relation.rb | UTF-8 | 1,734 | 2.921875 | 3 | [] | no_license | require_relative 'queriable'
class Relation
def self.dup_hash(hsh)
result = {}
hsh.each do |key, val|
result[gen_dup(key)] = gen_dup(val)
end
result
end
def self.gen_dup(item)
if item.is_a?(Hash)
dup_hash(item)
else
item.dup
end
rescue
item
end
def initi... | true |
adb40aaf7943c4812bf77b640a24b947d0c8a5c3 | Ruby | makiichikawa/ruby-practices | /08.ls_object/test/ls_short_format_test.rb | UTF-8 | 1,194 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
require 'date'
require 'minitest/autorun'
require_relative '../lib/ls_short_format'
require_relative '../lib/ls_directory'
class LsShortFormatTest < Minitest::Test
def setup
system('mkdir ~/test')
system('touch ~/test/.test.txt')
system('touch ~/test/test.txt')
@directo... | true |
6f17d1e4822097ae6ccf072a681d3ce2383b7a7a | Ruby | Eagerlearn/backend_mod_1_prework | /section2/exercises/methods.rb | UTF-8 | 2,710 | 4.96875 | 5 | [] | no_license | # In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# `ruby section2/exercises/methods.rb`
# Example: Write a method that when called will print your name:
def print_name
p "Severus Snape"
end
print_name
# ... | true |
6e8a8fde58ed9a0740579a7e3757620571c3629b | Ruby | jwirjo/disclosure-backend-static | /process.rb | UTF-8 | 5,050 | 2.59375 | 3 | [] | no_license | require_relative './environment.rb'
require 'fileutils'
require 'open-uri'
def build_file(filename, &block)
filename = File.expand_path('../build', __FILE__) + filename
FileUtils.mkdir_p(filename) unless File.exist?(filename)
File.open(File.join(filename, 'index.json'), 'w', &block)
end
# first, create OfficeE... | true |
c9b9cd8669324824bd012d8cd36aafe2dd8ab656 | Ruby | akasata/gulp-opal | /test/ruby/hoge_class.rb | UTF-8 | 203 | 3.84375 | 4 | [
"MIT"
] | permissive | class HogeClass
attr_accessor :text
def initialize(text)
@text = text
end
def print_text
puts @text
end
end
hoge = HogeClass.new('Hello Opal World!')
hoge.print_text
| true |
194ac2e0e8c1d589d26c08e68086129b4bb96bee | Ruby | DaniG2k/RubyCrawler | /lib/ruby_crawler/spider.rb | UTF-8 | 2,506 | 2.765625 | 3 | [] | no_license | module RubyCrawler
class Spider
def initialize
@stored = []
@frontier = []
@assets = {}
end
def stored
@stored
end
def assets
@assets
end
def start_crawl
if RubyCrawler.configuration.polite?
parser = RubyCrawler::RobotsParser.new
pars... | true |
56e320e1fcda8c52c75460c5d51a64583b0e19fd | Ruby | egogo/battle_pets | /service_wrappers/test/contest_service_wrapper_test.rb | UTF-8 | 2,670 | 2.609375 | 3 | [] | no_license | require File.expand_path '../test_helper.rb', __FILE__
describe "ContestServiceWrapper" do
let(:described_class) { ContestServiceWrapper }
let(:instance) { described_class.new }
let(:contest_json) {
{
id: 42,
title: 'Contest #42',
type: 'wit',
first_pet_id: 5,
second_... | true |
725c293059d8ee3b1ad549c4fc8927e310c2bbff | Ruby | Ricky199X/ttt-with-ai-project-online-web-pt-041519 | /lib/players/computer.rb | UTF-8 | 319 | 2.828125 | 3 | [] | no_license | module Players
class Players::Computer < Player
def move(board)
board.cells.each_with_index do |cell, index|
if cell == " "
position = index + 1
return position.to_s
end
end
end
end
end | true |
1d5c82ebfd68fb453bc51db55926749e75024b1c | Ruby | wrld3d/transitland-datastore | /app/services/gtfs_stop_time_service.rb | UTF-8 | 5,423 | 2.765625 | 3 | [
"MIT"
] | permissive | class GTFSStopTimeService
def self.debug(msg)
log(msg)
end
def self.clean_stop_times(stop_times)
# Sort by stop_sequence
stop_times.sort_by! { |st| st.stop_sequence }
# If we only have 1 time, assume it is both arrival and departure
stop_times.each do |st|
(st.arrival_time = st.departu... | true |
dfb0a9a8187db715dd41453208e6442d1bea4bad | Ruby | chinshr/merchant_sidekick | /lib/merchant_sidekick/money.rb | UTF-8 | 2,040 | 3.078125 | 3 | [
"MIT"
] | permissive | module MerchantSidekick
# Extensions to the money gem.
module Money
# Used to define a composed field that plays well with +merchant_sidekick+. Fore example, use the money
# class method to define a price attribute for product instances. A money object is composed of +cents+
# and +currency+ fie... | true |
d15af102b0eede7d7b3cc7039c14784f01f44401 | Ruby | grantneufeld/solidifier | /lib/solidifier/url_tool.rb | UTF-8 | 2,713 | 3.21875 | 3 | [
"MIT"
] | permissive | module Solidifier
# URL utility methods.
class UrlTool
attr_reader :path
attr_reader :source_url
attr_reader :path_args
def initialize(params={})
@path = params[:path]
# strip any args from the source url
match = params[:source_url].match /\A([^#\?]+)/
@source_url = match[1... | true |
3d8a744856abce6dc23cd224dddf79f7fcda57c5 | Ruby | lstemp1234/data-engineering | /app/models/import.rb | UTF-8 | 1,100 | 2.90625 | 3 | [] | no_license | class Import < ActiveRecord::Base
validates_presence_of :purchaser_name
validates_presence_of :item_description
validates_presence_of :item_price
validates_presence_of :purchase_count
validates_presence_of :merchant_address
validates_presence_of :merchant_name
validates_numericality_of :item_price, ... | true |
cce3bef0670f257c2d6499bfbc5be79f382a0e48 | Ruby | Gibheer/dm-mapper | /spec/integration/arel/basic_spec.rb | UTF-8 | 1,206 | 2.515625 | 3 | [] | no_license | require 'spec_helper_integration'
describe "Using Arel engine" do
include_context 'Models and Mappers'
before(:all) do
setup_db
insert_user 1, 'John', 18
insert_user 2, 'Jane', 21
insert_user 3, 'Piotr', 29
user_mapper
end
let(:user_mapper) {
DM_ENV.build(user_model, :postgres) do... | true |
8d6a07f3d6ac4688794fefe003324697eedd4e02 | Ruby | JanaVPetrova/hashie | /spec/hashie/mash_spec.rb | UTF-8 | 977 | 2.875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Hashie::Mash do
before(:each) do
@mash = Hashie::Mash.new
end
it "should return false if .key? is missing" do
expect(@mash.name?).to eq false
end
it "should check if key exists" do
@mash.name = "john"
expect(@mash.name?).to eq true
end
it "should return n... | true |
7912abbb06823f67a21708b9595a3b1d135064aa | Ruby | meseker/sketch | /lib/geometry/dsl/polyline.rb | UTF-8 | 3,108 | 3.78125 | 4 | [
"BSD-3-Clause"
] | permissive | module Geometry
module DSL
=begin rdoc
When you want to draw things that are made of lots and lots of lines, this is how you do it.
== Requirements
This module is intended to be included into a Class, and that Class must provide
some infrastructure. It must provide a push method for pushing new elements, a
first m... | true |
a48e85f5a7bbe7aaa52bc17f73369c6551d9cc46 | Ruby | cielavenir/procon | /aizu/tyama_aizuALDS1~15A.rb | UTF-8 | 77 | 2.671875 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
r=gets.to_i;k=0
[25,10,5,1].each{|e|d,r=r.divmod e;k+=d}
p k
| true |
3c61a771b2f8a410647843387701a370a1408be2 | Ruby | jamesward/pubnub-api | /ruby/examples/subscribe_example.rb | UTF-8 | 1,142 | 2.8125 | 3 | [
"MIT"
] | permissive | ## -----------------------------------
## PubNub Ruby API Subscribe Example
## -----------------------------------
## including required libraries
require 'rubygems'
require 'pubnub'
## declaring publish_key, subscribe_key, secret_key, cipher_key, ssl flag
publish_key = 'demo'
subscribe_key = 'demo'
secret_key =... | true |
4795b31ac4ccdaec4ef9b78f6f14feb8e8f0c6e8 | Ruby | rhythm29/Geektrust_War | /lengaburu.rb | UTF-8 | 417 | 2.609375 | 3 | [] | no_license | require './battle_resource'
module Main
class Lengaburu
@horse = Main::BattleResource.new($HORSE_POWER, 100)
@elephant = Main::BattleResource.new($ELEPHANT_POWER, 50)
@armoured_tank = Main::BattleResource.new($ARMOURED_TANK_POWER, 10)
@sling_gun = Main::BattleResource.new($SLING_GUN_POWER, 5)
cl... | true |
6b2e2c3ccd7d50929c81a9ab8a6e3f93a474265a | Ruby | thenora/recursive-dynamic-programming | /lib/fibonacci.rb | UTF-8 | 1,082 | 4.3125 | 4 | [
"MIT"
] | permissive | # Improved Fibonacci
## Improved Fibonacci
# Earlier you saw how an array could be used to store Fibonacci numbers resulting in a time-complexity reduction from O(2<sup>n</sup>) to O(n). Now we will take this a set further, because to find a given Fibonacci number, you only need to find the previous two numbers.
... | true |
f84f63928c02dbeae88b3bf698116915dbe56a68 | Ruby | camilledelbos/copilot_v0 | /test/models/travel_calculator_test.rb | UTF-8 | 2,791 | 2.828125 | 3 | [] | no_license | require 'test_helper'
class TravelCalculatorTest < ActiveSupport::TestCase
attr_reader :katherine, :kingston, :trinidad, :vanadzor
def setup
travel = FactoryGirl.create(:travel)
@katherine = FactoryGirl.create(:stage, :katherine, travel: travel, stage_position: 0, departure_date: DateTime.new(2014,1,23)... | true |
72c665f3bb586c1856efe44757ce5790eec1c446 | Ruby | JBFowler/Launch_School_Prep_Course | /ch1.rb | UTF-8 | 1,791 | 4.375 | 4 | [] | no_license | # Answers to Ch1 (Basics of Ruby)
def prompt(msg)
puts "=> #{msg}"
gets
end
def question(num)
prompt("Answer to question #{num}: ")
end
def factorial(num)
total = num * (num - 1)
num = num - 2
loop do
if num > 1
total = total * num
num -= 1
else
prompt(total)
break
end... | true |
eaf490bf7942a55110607e8a1bfc8d493a679415 | Ruby | kgknight/rubyFizzBuzz | /FizzBuzz.rb | UTF-8 | 398 | 3.453125 | 3 | [] | no_license | class FizzBuzz
def rex(start=1,finish=100,a=3,b=5,atext="Fizz",btext="Buzz")
if start % (a * b) == 0
puts "#{atext}#{btext}"
elsif start % a == 0
puts atext
elsif start % b == 0
puts btext
elsif
puts start
end
if(start < finish)
self.rex(start+1,finish,a,b,at... | true |
14be70f9831c20ff4feadb8d3a84a786986d298a | Ruby | PaaS-TA/Service-release | /paasta-mysql-release/src/cf-mysql-broker/spec/models/database_spec.rb | UTF-8 | 4,205 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
describe Database do
let(:db_name) { 'database_name' }
describe '.create' do
after { connection.execute("DROP DATABASE `#{db_name}`") }
it 'creates a new database' do
Database.create(db_name)
expect(connection.select("SELECT COUNT(*) FROM information_schema.SCHEMATA WHER... | true |
2224b524ad73d468c97500d37c0a185bac38ec2d | Ruby | joliewrites/edabit | /Ruby/easy/frames.rb | UTF-8 | 59 | 2.6875 | 3 | [] | no_license | def frames(minutes, fps)
return minutes * (fps * 60)
end
| true |
20cfb31c13cf71272d345f2d93c759813d28024d | Ruby | ravraw/Ruby_2_player_math_game | /Player.rb | UTF-8 | 120 | 2.90625 | 3 | [] | no_license | # Player class
class Player
attr_accessor :name,:lives
def initialize(name)
@name = name
@lives = 3
end
end | true |
8ddc24b9abe6519766430ae6e7cf09e322970963 | Ruby | glenegbert/Event-Reporter | /lib/command_processor.rb | UTF-8 | 1,985 | 3.078125 | 3 | [] | no_license | require 'repository_manager'
require 'entry'
class CommandProcessor
attr_accessor :repository_manager
# def initialize(repository_manager = RepositoryManager.load_entries)
def initialize(repository_manager = RepositoryManager.new)
@repository_manager = repository_manager
end
def queue_print
puts h... | true |
075d586912c72024b66d1d33a8f738089f3596d5 | Ruby | adriencouture/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 504 | 4.15625 | 4 | [] | no_license | def shout(word)
word.upcase
end
def echo(word)
word
end
def repeat(word, n = 2)
array = []
n.times do
array.push(word)
end
array.join(" ")
end
def start_of_word(word, number_of_characters)
word[0, number_of_characters]
end
def first_word(first_word)
array = first_word.split
array[0]
end
def t... | true |
1f7b3607790e9c6ccda7348edd4cf70e21b41b04 | Ruby | bibstha/projecteuler | /3.rb | UTF-8 | 317 | 3.15625 | 3 | [] | no_license | require 'awesome_print'
require 'prime'
# largest prime factor of 600851475143
def exec
num = 600851475143
num = 1234567890123456789012345678901234567890
Prime.each do |prime|
puts "#{prime}\t#{num}"
num /= prime while (num % prime).zero?
if num <= 1
return prime
end
end
end
puts exec | true |
a6ece7b3ce993e30cb08ed59e054ba62f05e252a | Ruby | gaohongwei/rails_topics | /params.rb | UTF-8 | 1,109 | 3.34375 | 3 | [] | no_license |
The params in a controller looks like a Hash,
but it's actually an instance of ActionController::Parameters,
which provides several methods such as require and permit.
The require method ensures that a specific parameter is present,
otherwise the require method throws an error
It returns an instance of ActionCont... | true |
201801f35068bea780d8d16a5a1cecfbd66823fd | Ruby | conorpreston13/vinyl_tracker_backend | /app/controllers/vinyls_controller.rb | UTF-8 | 1,500 | 2.5625 | 3 | [] | no_license | class VinylsController < ApplicationController
# ------------------index allows you to pull up all of the vinyl in the collection
def index
@vinyls = Vinyl.all
render json: @vinyls
end
# ------------------show allows you to pick out 1 specific vinyl to show by id
def show
... | true |
d389ed6139980d6bedab1fa85794b635e47694c8 | Ruby | dalzinho/Codeclan-Work | /w2/day_4/lab/specs/agent_spec.rb | UTF-8 | 265 | 2.625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative '../Agent'
class AgentTest < MiniTest::Test
def setup
@agent = Agent.new("james", "bond")
end
def test_can_shay_name
assert_equal("The name's Bond, James Bond.", @agent.talk)
end
end | true |
35499162b77cb7c1a325fa938d29ba3da8eb6c3d | Ruby | RomanADavis/challenges | /advent/2015/day14/solutions/part2.rb | UTF-8 | 2,311 | 3.953125 | 4 | [] | no_license | # --- Part Two ---
#
# Seeing how reindeer move in bursts, Santa decides he's not pleased with the
# old scoring system.
#
# Instead, at the end of each second, he awards one point to the reindeer
# currently in the lead. (If there are multiple reindeer tied for the lead, they
# each get one point.) He keeps the... | true |
df9e413dd76aff68f80b5d3ac9bd54d4c828755d | Ruby | RumaniKafle/ITSC3155_SPRING2019_800991130 | /RubyBasics2/lib/rubybasics2.rb | UTF-8 | 405 | 3.65625 | 4 | [] | no_license | # Strings and Regular Expressions
# Part I
def hello(name)
# YOUR CODE HERE
"Hello, " + name
end
# Part II
def starts_with_consonant? s
# YOUR CODE HERE
if (s[0] =~/[bcdfghjklmnprstvwxyz]+/i)
return true
else
return false
end
end
# Part III
def binary_multiple_of_4? s
# YOUR CODE HERE
if s =~... | true |
942528897ff67d0b25be8eea90ff30e56e5bbd43 | Ruby | solipsis/trainingMontage | /deck.rb | UTF-8 | 656 | 3.34375 | 3 | [] | no_license | class Deck
attr_accessor :cards
STRAIGHT_1 = 15
STRAIGHT_2 = 10
STRAIGHT_3 = 5
RIGHT = 10
LEFT = 10
def initialize()
@cards = Array.new()
# todo fix
straight1_img = nil
straight2_img = nil
right_img = nil
left_img = nil
STRAIGHT_1.times do
puts "adding card"
cards.push(Card.new(:straigh... | true |
d305b4a6ccf5d083e6596bc1aab7d8af835e4b88 | Ruby | Marlon-Poddalgoda/ICS4U-Unit2-10-Ruby | /Bike.rb | UTF-8 | 825 | 3.65625 | 4 | [] | no_license | #!/usr/bin/env ruby
##
# This class file holds the Bike class.
#
# @author Marlon Poddalgoda
# @version 1.0
# @since 2021-05-28
# frozen_string_literal: true
load "Vehicle.rb"
# This class makes a bike using the vehicle class
class Bike < Vehicle
# Uses the constructor from the vehicle class
# getters
... | true |
9af531bd9c7d0eaa69124b20e39cb2a362146509 | Ruby | daniel-certa-1228/Ruby-Enumerators-and-Enumerables | /enumerator.rb | UTF-8 | 504 | 3.515625 | 4 | [] | no_license | enum = ['apple', 'bear', 'cactus'].each
puts enum #<Enumerator:0x00007fb96686b768>
puts enum.size #3
puts enum.next#apple
puts enum.next#bear
puts enum.peek#cactus peek looks at the next one but doesn't move the counter
puts enum.next#cactus
enum.rewind
puts enum.next
puts "#{enum.next_values}"#["bear"]
enum.each_with... | true |
1047e6bf4733b7cb0a54d166f94c8d2f46f79e21 | Ruby | AntoineDelarchand/Morpion | /lib/app/game.rb | UTF-8 | 634 | 3.6875 | 4 | [] | no_license | # frozen_string_literal: true
require 'pry'
require_relative 'player'
require_relative 'board'
class Game
def p1
puts 'Player 1: Enter your first name:'
print '>'
name = gets.chomp.to_s
player1 = Player.new(name)
end
def p2
puts 'Player 2: Enter your first name:'
print '>'
name ... | true |
64d9187fcae25ef9ab1858fb9d39fdb4e4aad1fa | Ruby | scokop/rubyprograms | /3week/exercise_8.rb | UTF-8 | 303 | 3.90625 | 4 | [] | no_license |
def fizzbuzz
1.upto(100) do |number|
fizz_buzz_output = ""
if number % 3 == 0 then fizz_buzz_output << "Fizz" end
if number % 5 == 0 then fizz_buzz_output << "Buzz" end
if fizz_buzz_output.empty?
puts number
else
puts fizz_buzz_output
end
end
end
fizzbuzz
| true |
183ea2b92a7b9199b69c3dd6c2603ce997413df4 | Ruby | ThundaHorse/contacts_app | /contact_client.rb | UTF-8 | 958 | 3.5 | 4 | [] | no_license | require 'http'
system "clear"
puts "Sup yo"
puts ""
puts "Options"
puts " [1] Display a single contact"
puts " [2] Display all contacts"
puts "What you wanna do"
user_option = gets.chomp
if user_option == "1"
response = HTTP.get('http://localhost:3000/api/contacts_url')
contact_hash = response.parse
... | true |
4780e188b2154ddbbfcb24f2daf0a183355fea6e | Ruby | learn-co-curriculum/testing-truth | /things_that_are_true_in_ruby.rb | UTF-8 | 275 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'true.rb'
puts "Did you know that true is " + true?(true).to_s #=> true
puts "Did you know that false is " + true?(false).to_s #=> false
puts "Did you know that 0 is " + true?(0).to_s #=> true
puts "Did you know that \"\" is " + true?("").to_s #=> true
| true |
d70d29220266485d659dcf253f872a9226b1a2d7 | Ruby | TomK32/Unstack | /unstack/Smiley.rb | UTF-8 | 351 | 2.703125 | 3 | [] | no_license | #
# Smiley.rb
# unstack
#
# Created by Thomas R. Koll on 02.04.11.
# Copyright 2011 Ananasblau.com. All rights reserved.
#
class Smiley < Block
def initialize
c = NSColor.yellowColor
n = nil
self.shape = [
[n, c, c, c, n],
[c, n, n, n, c],
[n, n, c, n, n],
[n, c, n, c, n]
... | true |
5a06c725bd76dd9a92424e45fec1669e17684e71 | Ruby | YuichiYagisawa/CodeWars | /digital_root.rb | UTF-8 | 217 | 3.34375 | 3 | [] | no_license | def digital_root(n)
a = n.to_s.split("").map(&:to_i).sum
if a >= 10
a.to_s.split("").map(&:to_i).sum
else
return a
end
end
#ans
# def digital_root(n)
# n < 10 ? n : digital_root(n.digits.sum)
# end | true |
15083565f13e3ed9befaff81652894e93d34067a | Ruby | krestenkrab/hotruby | /modules/vm-shared/rb/test/basic/Regexp.rb | UTF-8 | 17,417 | 2.59375 | 3 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | require 'test/unit/testcase'
require 'test/unit/testresult'
#require 'test/unit'
class RegexpTest < Test::Unit::TestCase
def test_simple
assert_match(['bcd'], /bcd/, 'abcde')
end
def test_constructors
assert_match(['bcd'], Regexp.new('bcd'), 'abcde')
assert_match(['bcd'], Regexp.new('bc... | true |
09cfa41103ed831b6d38fc00a6fdfa4b9695a9b2 | Ruby | mmanousos/ruby-small-problems | /small_problems/easy8/seven_double_char_pt1.rb | UTF-8 | 1,695 | 4.75 | 5 | [] | no_license | =begin
*assignment*
Double Char (Part 1)
Write a method that takes a string, and returns a new string in which every
character is doubled.
Examples:
repeater('Hello') == "HHeelllloo"
repeater("Good job!") == "GGoooodd jjoobb!!"
repeater('') == ''
*problem*
input: string
output: string with each character doubled
ac... | true |
9ca8f872146b1bef487f8db9dd0380b409d21d75 | Ruby | NiestrojMateusz/Launch-School-101 | /lesson_3/Hard_1.rb | UTF-8 | 4,844 | 4.46875 | 4 | [] | no_license | #Question 1
#What do you expect to happen when the greeting variable is referenced in the last line of the code below?
if false
greeting = “hello world”
end
greeting
# Solution 1
# greeting is nil here, and no "undefined method or local variable" exception is thrown. Typically, when you reference an uninitialized ... | true |
52a7a48bdd1a9f49e23feec84ef70ee0f2a13569 | Ruby | DavidHuarino/codeSignal_interviewPractice | /Dynamic_Programming_Advanced/maximalSquare.rb | UTF-8 | 717 | 3.0625 | 3 | [] | no_license | def maximalSquare(matrix)
return 0 if matrix.empty?
def findMaxSquare(x, y, matrix, memo)
return 0 if x >= matrix.size or y >= matrix[0].size
return memo[[x, y]] if memo.key?([x, y])
if matrix[x][y] == '0'
memo[[x, y]] = 0
else
memo[[x, y]] = 1 + ([findMax... | true |
bf511c4eb99b47bd60d32187a5ae51927f2f90aa | Ruby | ychubachi/romaji_table | /lib/romaji_table/c生成器.rb | UTF-8 | 7,935 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require_relative 'c鍵盤'
require_relative 'c五十音'
require_relative 'c変換表'
require 'singleton'
module RomajiTable
Qwerty = C鍵盤::Qwerty
Dvorak = C鍵盤::Dvorak
# ローマ字変換表生成器
class C生成器
include Singleton
# 鍵盤にある母音の順番を左からの番号で指定
attr :鍵盤母音順
# 生成された変換表の配列
... | true |
59b1ee09caa0f4ad0460beb7d0364ebd1375f5dd | Ruby | SeneddCymru/e-petitions | /app/jobs/fetch_members_job.rb | UTF-8 | 3,994 | 2.515625 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | require 'faraday'
class FetchMembersJob < ApplicationJob
HOST = "https://business.senedd.wales"
TIMEOUT = 5
ENDPOINTS = {
"en-GB": "/mgwebservice.asmx/GetCouncillorsByWard",
"cy-GB": "/mgwebservicew.asmx/GetCouncillorsByWard"
}
WARDS = "/councillorsbyward/wards/ward"
CONSTITUENCY = ".//wardtitle"... | true |
b384b26c1656416ecb47ad7371358cda8bf271d3 | Ruby | romaimperator/SPUploader | /SPUploader/Generator.rb | UTF-8 | 572 | 3.390625 | 3 | [
"BSD-2-Clause"
] | permissive | # The base class for all values stored for tags
#
# To use just subclass and overload the method 'value'. For an example, refer
# to the SSVGenerator class that is included.
class Generator
def initialize(value)
@value = value
end
# Returns the value stored in @value. Can be overloaded to provide any
... | true |
f3fa5a9efc64ca9a82d3ff821e63e7ec444b3c38 | Ruby | blacktm/tello | /lib/tello/cli/server.rb | UTF-8 | 1,263 | 3.15625 | 3 | [
"MIT"
] | permissive | # A simple UDP server
require 'tello/colorize'
require 'socket'
PORT = 8889
server = UDPSocket.new
server.bind('localhost', PORT)
puts "Starting Tello test server...".bold, "Listening on udp://localhost:#{PORT}"
bye = false
while (not bye) do
msg, addr = server.recvfrom(100)
puts "#{"==>".green} Received: \"#{m... | true |
67b221ebbff00b0a14881f56ae5142a9b10b16ab | Ruby | jatla/RubyWinter2014 | /week2/homework/simon_says.rb | UTF-8 | 424 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | module SimonSays
def echo(str)
str
end
def shout(str)
str.upcase
end
def repeat(*args)
str = nil
count = 2
if (!args[0].nil?)
str = args[0]
end
if (!args[1].nil?)
count = args[1]
end
repeatedStr = String.new(str)
while (count > 1) do
count = count - 1
repeatedStr.concat(" ".concat(str))
end
repea... | true |
78c331fd98431298af2c115109e34e04baf36ae7 | Ruby | ruxandrafed/contacts-list | /contact.rb | UTF-8 | 1,176 | 3.421875 | 3 | [] | no_license | require 'csv'
require 'pry'
class Contact
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
end
def to_s
"Name: #{@name}, Email: #{email}"
end
class << self
# Initializes a contact and adds it to the list of contacts
def create(name, email, phone_n... | true |
9d2eaf364e773a84fc17e464072e255f3889d36e | Ruby | mattmccray/gumdrop | /lib/gumdrop/cli/external.rb | UTF-8 | 1,710 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'fileutils'
require 'thor'
module Gumdrop::CLI
class External < Thor
include Thor::Actions
def self.source_root
File.expand_path('../../../..', __FILE__)
end
desc 'new [NAME]', 'Create new gumdrop project'
method_option :template, aliases:'-t', desc:'Template to start from', requi... | true |
bd24055c664a9b836799a4cd2c4a74173048803f | Ruby | Felipeishon/rails-dev-box | /curso68/TESTMIO.rb | UTF-8 | 183 | 3.453125 | 3 | [
"MIT"
] | permissive | def reemplazo(x)
x.each_with_index do |elemento, indice|
if elemento < 0
x.delete(x[indice])
end
end
puts x.to_s
end
reemplazo([1, 5, 10, -2]) | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.