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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8d5403d5cb0e3217797213d91eb80f56946e2c9c | Ruby | KVexcavator/Leetxode-com | /tasks/10_happy_number.rb | UTF-8 | 516 | 3.90625 | 4 | [] | no_license | # Input: 19
# Output: true
# Explanation:
# 1**2 + 9**2 = 82
# 8**2 + 2**2 = 68
# 6**2 + 8**2 = 100
# 1**2 + 0**2 + 0**2 = 1
# is_happy(4) not happy : stack level too deep (SystemStackError)
def is_happy(n)
if n == 1
puts true
# if cicle have 4 = SystemStackError
elsif n == 4
puts false
... | true |
97e33d652488fe6a6e72fe86fc65dd388a8fe9cf | Ruby | Reltre/intro-to-ruby-programming_tealeaf | /variables/name.rb | UTF-8 | 279 | 3.9375 | 4 | [] | no_license | #Number 1
=begin
puts "Please type in your name"
name = gets.chomp
puts "Hello #{name}!"
=end
#Number 3
#10.times {puts name}
#Number 4
puts "Please type in your first name"
f_name = gets.chomp
puts "Please type in your last name"
l_name = gets.chomp
puts "#{f_name} #{l_name}" | true |
314d47ec1ac0b40341223e9d9a4d593c792cf96e | Ruby | bebrown21/my-first-repository | /caps.rb | UTF-8 | 108 | 3.5 | 4 | [] | no_license | def caps(words)
if words.length > 10 then words.upcase else words end
end
puts caps("hello there friend") | true |
0a4b909348e9a565413e62d9a76d19ed9672e520 | Ruby | daytonn/ninjs | /bin/ninjs | UTF-8 | 5,158 | 2.6875 | 3 | [
"LicenseRef-scancode-compass"
] | permissive | #!/usr/bin/env ruby
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
begin
require 'ninjs'
require 'optparse'
rescue LoadError
require 'rubygems'
require 'ninjs'
require 'optparse'
end
create = <<-CREATE
create Creates a new ninjs application in the current working
dire... | true |
d33d11d601c0ad0fc27fe3a6cec9e728a7c01e01 | Ruby | tanordheim/ahgoblin | /app/models/transformation.rb | UTF-8 | 2,280 | 2.796875 | 3 | [
"MIT"
] | permissive | class Transformation < ActiveRecord::Base
# Transformations are associated with users.
belongs_to :user
# Transformations have many reagents, and accepts nested attributes.
has_many :reagents, :class_name => 'TransformationReagent', :dependent => :destroy, :before_add => :add_transformation_to_reagent
accep... | true |
5bd8419cee416dd97ac03528885504c9f887021e | Ruby | alc4ntara/ruby | /ex2/pet.rb | UTF-8 | 331 | 3.296875 | 3 | [] | no_license | class Error < StandardError
def BichinhoSemNome
end
def BichinhoSemIdade
end
end
class Pet
attr_accessor :nome, :idade
def talk (string)
puts string
end
def initialize(nome="nada", idade="nada")
if nome == "nada"
raise Error.BichinhoSemNome
end
if idade == "nada"
raise Error.BichinhoSemIdade
en... | true |
d464655851e722bc6af6f489fe6586142642c039 | Ruby | ethansr/mg_hotdog | /lib/mg_hotdog/robot.rb | UTF-8 | 907 | 2.90625 | 3 | [] | no_license | require 'eventmachine'
require 'tinder'
module MgHotdog
class Robot
attr_accessor :parts
attr_accessor :room
attr_accessor :database
def initialize(room_number, database_path)
@parts = []
@campfire = Connection.new
@room_id = room_number
@database = Database.new(database_pat... | true |
bdca4c04ac295897caa00b873ab89cb68891a8dd | Ruby | nmacawile/chess | /lib/game.rb | UTF-8 | 7,040 | 3.703125 | 4 | [] | no_license | require "yaml"
require_relative "board"
require_relative "player"
require_relative "pieces/rook"
require_relative "pieces/knight"
require_relative "pieces/bishop"
require_relative "pieces/queen"
require_relative "pieces/king"
require_relative "pieces/pawn"
class Game
attr_accessor :board, :active_turn, :players
attr... | true |
1c0f5aa794a6b8004133e35cc16c58a655d899e8 | Ruby | johnmcc/animal-shelter | /db/seeds.rb | UTF-8 | 951 | 2.75 | 3 | [] | no_license | require_relative "../models/Owner"
require_relative "../models/Pet"
require "pry-byebug"
owner1 = Owner.new({ 'name' => 'Animal Shelter' })
owner2 = Owner.new({ 'name' => 'Alice Testerton' })
owner3 = Owner.new({ 'name' => 'Steve McTest' })
owner1.save
owner2.save
owner3.save
type1 = PetType.new({'type' => 'Dog'})
t... | true |
17c6a8d7617ce6e8d77fc7ddf01d78af1823aee1 | Ruby | arpodol/ruby_small_problems | /advanced1/transposed.rb | UTF-8 | 1,304 | 4.1875 | 4 | [] | no_license | =begin
# ~~Understanding the Problem~~#
Write a method that takes a 3 x 3 matrix in array of arrays format and returns the transpose of the original
matrix.
# ~~Input~~#
- A 3 x 3 array of arrays matrix
# ~~Output~~#
- The 3 x 3 transpose of the original matrix
# ~~Rules~~#
- Cannot use built in matrix class or tra... | true |
5d8189342e224f2034768648b304afbe9989f6a1 | Ruby | daschne8/code-challenges-solutions | /Codewars/dice_rolls_threshold.rb | UTF-8 | 397 | 3.109375 | 3 | [] | no_license | def roll_dice (rolls, sides, threshold)
denominator = sides**rolls
if threshold > rolls * sides
return 0
end
a = [*(1..sides)].repeated_permutation(rolls).to_a
sums = a.map {|vals| vals.inject(0){|sum,x| sum + x}}
sums = sums.find_all {|num| num < threshold}
reached = sums.length
# reached = sums.find_index {|num|... | true |
7d9b8439b53ef30100b3c2b42d62395917257208 | Ruby | v9n/cracking_the_coding_interview | /lib/chapter_one/two.rb | UTF-8 | 336 | 3.453125 | 3 | [
"MIT"
] | permissive | module ChapterOne
module Two
# Implement a function which reverses a string
def reverse(s)
lo, hi = 0, s.length.pred
result = s.dup
while lo < hi
tmp = result[lo]
result[lo] = result[hi]
result[hi] = tmp
lo, hi = lo.succ, hi.pred
end
result
... | true |
395f5b581213c449fd5cefbe0c7adefbd4e8c943 | Ruby | robinclart/baseconv | /lib/baseconv.rb | UTF-8 | 1,250 | 3.515625 | 4 | [
"MIT"
] | permissive | require "baseconv/version"
module Baseconv
CHARS = [*("0".."9"), *("a".."z"), *("A".."Z")].join.freeze
MIN = 2
MAX = CHARS.size
InvalidRadix = Class.new(StandardError)
module_function
# Convert
#
# Convert the digits representation of a number from a given base to another.
def convert(digits,... | true |
72046e204e6adeccb1e638ca574bb77e8db506d4 | Ruby | robpe/RBainfuck | /brainfuck.rb | UTF-8 | 1,516 | 3.625 | 4 | [] | no_license | #
# Brainfuck interpreter written in ~1h (ended up with quick and dirty hacks)
# monkey patch for nil class (nil acts as zero)
module NilZero
def +(n) ; n ; end
def zero? ; true ; end
end
# pushing bytes from file to array only when we need it
class LazyStream < Array
def initialize(filename)
@input = Fil... | true |
8d2b6c577a8d520c3d0ced7a2aa7ad5b1cfe7c37 | Ruby | webdesserts/lazy_files | /spec/file_spec.rb | UTF-8 | 5,920 | 2.875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'lazy_files/files/file'
describe Lazy::File do
init
subject(:file) { Lazy.mkfile('hello.txt') }
its(:stream) { should be_nil }
its(:path) { should == File.join(TESTDIR, 'hello.txt')}
it { should respond_to :basename }
it { should respond_to :exist? }
it { should respond_to... | true |
06a87d47e7c2ff5260c12f223190469759f69669 | Ruby | mattmccray/cumulus | /lib/cumulus/scanner.rb | UTF-8 | 1,607 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'fileutils'
module Cumulus
class Scanner
attr_reader :base, :content_path
def initialize(base_path)
@base = File.expand_path(base_path)
raise StandardError.new("Base path must be a directory.") unless File.directory?(base)
end
def sweep(clear_db=true)
@content_path = File.join(bas... | true |
1e9aba5b77ba279233f3ab327dd541fdebee08c0 | Ruby | eweitnauer/flowhan | /ruby/library/ruby-unicode-0.0.1/test/tc_string.rb | UTF-8 | 2,074 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
$KCODE = 'UTF-8'
require 'unicode'
require 'test/unit'
class TestUnicodeString < Test::Unit::TestCase
def setup
@ustr = "가나다".to_u
end
def test_basic
assert_equal @ustr, Unicode::String.from_array(@ustr.to_a)
assert_equal 3, @ustr.length
assert_equal "가나다", @ustr.to_s
... | true |
17d3396d20cc8b5a05a9c27e8a74bbcec82381b2 | Ruby | kevinkang88/playplayplay | /app/models/playlist.rb | UTF-8 | 511 | 2.734375 | 3 | [
"MIT"
] | permissive | class Playlist < ActiveRecord::Base
attr_accessible :title, :body, :title, :user_id, :coolness, :description
has_many :tracks
def coolness_calculator
duration_times_pops = []
durations = []
self.tracks.each do |track|
durations << track.length.to_f
duration_times_pops << (track.length.to_... | true |
617bbac4a7d1e63040dbea2a2ed7f7caeaf23a63 | Ruby | bluetyson/traveller_rpg | /test/career.rb | UTF-8 | 15,718 | 2.828125 | 3 | [] | no_license | require 'traveller_rpg/career'
require 'traveller_rpg/generator'
require 'minitest/autorun'
#
# first, some test careers
#
module TravellerRPG
class ExampleCareer < Career
#
# These are not present in a normal Career
STAT = :strength
STAT_CHECK = 5
TITLE = 'Rookie'
NEW_TITLE = 'Sophomore'
... | true |
e56a7519f82e6bb87cff8b19b2ed752d54a3fdfd | Ruby | CraigMorton/SNL-TDD-step-by-step | /specs/dice_spec.rb | UTF-8 | 291 | 2.578125 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../dice.rb")
class DiceSpec < MiniTest::Test
def setup
@dice = Dice.new(6)
end
def test_can_roll
assert_equal(Fixnum, @dice.roll.class)
end
def test_sides_chosen_at_initialize
dice = Dice.new(100)
end
end
| true |
dda650ce1bdc3f12d313cefab64ded3345a787f9 | Ruby | balinterdi/console-navigator | /tests.rb | UTF-8 | 10,061 | 2.921875 | 3 | [] | no_license | require "node"
require "ui"
require "navigator"
require "navigation_object"
require "test/unit"
require "yaml"
class RandomIO < IO
=begin
Gives back a random integer between 0 and _max_+1 each time
it gets is called on it
(the class has been constructed for testing reasons)
it should be instantiated like this (till ... | true |
b3d01557f191660776b39e3335e02c3f84c3aa04 | Ruby | higaki/KOFxJUNKUDO | /k2u.rb | UTF-8 | 637 | 2.59375 | 3 | [] | no_license | #! /usr/bin/env ruby
require_relative './KOF/booth'
require_relative './KOF/seminar'
require_relative './KOF/user'
Encoding.default_external = Encoding::UTF_8
include KOF
booth_fn = ARGV[0]
seminar_fn = ARGV[1]
booths = Booth .open(booth_fn)
seminars = Seminar.open(seminar_fn)
users = open(KOF::FILE_OF[:user... | true |
5cf3684bea5d3e00c32ccf971e7ba7b83df2e3de | Ruby | gargtushar/battleship | /spec/battle_spec.rb | UTF-8 | 1,881 | 3.125 | 3 | [] | no_license | require 'spec_helper'
describe Battle do
let(:player1) { Player.new("6 E", "Naruto") }
let(:player2) { Player.new("6 E", "Uchiha") }
let(:p) { ShipType.new("P", 1)}
let(:battle){ Battle.new(player1, player2)}
before do
("A1".."A6").to_a.each do |i|
player1.ships[i] = Ship.new(i,p,1,1,i)
en... | true |
0fd5e7fb0c82e93931010776a959185e5a86251a | Ruby | yhshin0/python_ruby | /06. Input_Output/ruby1.rb | UTF-8 | 134 | 4.0625 | 4 | [] | no_license | puts("입력해주세요")
# gets.chomp() : 입력값을 변수에 할당함.
in_str = gets.chomp()
puts(in_str.upcase() + " World!")
| true |
ce275beae5ec8b91c5a56db59af082f16aa48076 | Ruby | RomanTurner/upcase_tdd | /lib/unit_converter.rb | UTF-8 | 1,066 | 3.34375 | 3 | [] | no_license | DimensionalMismatchError = Class.new(StandardError)
Quantity = Struct.new(:amount, :unit)
class UnitConverter
def initialize(initial_quantity, target_unit)
@initial_quantity = initial_quantity
@target_unit = target_unit
end
def convert
Quantity.new(@initial_quantity.amount * conversion_factor(from:... | true |
fc7e391d4ea4a1ada646e6d87d5bb3b2b93d8213 | Ruby | gdomingu/cookbook | /db/seeds.rb | UTF-8 | 805 | 2.53125 | 3 | [] | no_license |
require 'open-uri'
require 'rubygems'
require 'twilio-ruby'
["applesauce_spice_cake", "bourbon_mashed_sweet_potatoes", "ancho_chile_shrimp_and_pasta"].each do | x |
exrecipe_page = Nokogiri::HTML(open("http://www.simplyrecipes.com/recipes/#{x}/"))
exrecipe_title = exrecipe_page.css(".entry-header .fn").children[0].c... | true |
832c1e45d1cf3175e8d54675d8552eb94a44715e | Ruby | JonathanWexler/wdi-november-lecture-code | /Week 3/Day 1/basic_ruby_example.rb | UTF-8 | 270 | 3.34375 | 3 | [] | no_license | puts "Hello World"
name = "Jon"
puts name
holidays = ["Thanksgiving", "Memorial Day", "Columbus Days"]
puts holidays[0]
holidays_and_dates = {holidays[0] => "November 27th", holidays[1] => "Tuesday", holidays[2]=>"Smarch 1492"}
puts holidays_and_dates[holidays[0]] | true |
50226bcb3c988b1c54da155e922a6e0d6ebbcb8a | Ruby | alebianITBA/Machine-Learning | /TP1/tateti/train.rb | UTF-8 | 2,546 | 3.6875 | 4 | [] | no_license | #!/usr/bin/env ruby
require_relative 'player'
require_relative 'dummy'
require_relative 'randomPlayer'
require_relative 'tateti'
# With this method, player 1 will try to learn
def train_first(player1, player2, runs)
separation
tateti = Tateti.new
p1 = 0
p2 = 0
ties = 0
runs.times do
loop do
tatet... | true |
1f1be24003427b689f1e06a55ca2a79f26e259b0 | Ruby | topher6345/kaprekar | /test/test_kaprekar.rb | UTF-8 | 1,179 | 2.78125 | 3 | [] | no_license | require 'minitest'
require 'minitest/autorun'
require_relative '../lib/kaprekar'
# Tests for Kaprekar Gem
class KaprekarTest < Minitest::Test
def test_backward_sort
assert 1234.backward_sort, 4321
assert 4356.backward_sort, 6543
assert 9980.backward_sort, 9980
assert 19_567.backward_sort, 97_651
end... | true |
6d420a70878354c8ff9d520fe5a05499e6eda041 | Ruby | JoshKarpel/advent-of-code-2019 | /ruby/day_15.rb | UTF-8 | 3,373 | 3.15625 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'
require 'set'
require_relative 'intcode'
require_relative 'utils'
EAST = 1 + 0i
WEST = -1 + 0i
SOUTH = 0 - 1i
NORTH = 0 + 1i
HIT_WALL = 0
MOVED = 1
OXYGEN = 2
MOVE_CMDS = {
NORTH => 1,
SOUTH => 2,
WEST => 3,
EAST => 4,
}.freeze
CORRIDOR ... | true |
cc379fe81d102d447f2f2b416bbb73b4ad194da8 | Ruby | niekvenlo/phylo | /lib/phylo.rb | UTF-8 | 308 | 2.84375 | 3 | [
"MIT"
] | permissive | require "phylo/version"
def phylo(depth = 0, path = nil)
this_dir = `ls -F #{path}`
this_dir.split.each do |f|
if f.end_with? "/"
puts "#{"| "*depth}\e[95m#{f}\e[0m"
new_path = "#{path}#{f}"
phylo(depth + 1, new_path)
else
puts "#{"| "*depth}#{f}"
end
end
end
phylo | true |
21e416dd0f53e846c9f2568662f0bbfeb0557be5 | Ruby | wangxiangyu/jpaas_collector_master | /lib/collector_master.rb | UTF-8 | 4,986 | 2.578125 | 3 | [] | no_license | require "config"
require "nats"
require "logger"
module CollectorMaster
class CollectorMaster
def initialize(config_path)
@config=Config.new(config_path).config
@nats=nil
@collectors={}
@tasks={}
#@logger=Logger.new(config['logging']['file'])
... | true |
5ab34c49ee30f962da6f42b5c8bdbf98f48ae00e | Ruby | maximedelpit/ring_a_ding | /lib/ring_a_ding/request.rb | UTF-8 | 2,572 | 2.796875 | 3 | [
"MIT"
] | permissive | module RingADing
class Request
BASE_API_URL = nil
ATTR_ACCS = %i(client base_api_url options path_parts)#api_endpoint
SUB_SYM = '_' # used to fit method_missing undersocre with endpoint format (xxx_yyy / xxx-yyy)
ATTR_ACCS.each {|_attr| attr_accessor _attr}
# Hash[ATTR_ACCS.map {|v| [v, nil]}]
... | true |
b5e72ac7fc8d7c4d888e7298bb53c2f2279e2d29 | Ruby | piksa13/firehose | /test.rb | UTF-8 | 436 | 3.765625 | 4 | [] | no_license | def unique2(array)
output1 = []
array.each do |el|
output1 << el if !output1.include?(el) #array.each {|item| new_array << item if !new_array.include?(item) }
end
puts"Here is an uniqe arrary from this function #{output1}"
puts"Here is an array from unique method #{array.uniq}"
# puts outp... | true |
9304c43c0152a4673088387277488b3c6cabbf36 | Ruby | kitofr/pentago | /test.rb | UTF-8 | 1,177 | 3.390625 | 3 | [] | no_license |
puts "-------------lambda--------------"
skip_6 = lambda { |array, i|
@i = @i.nil? ? i : @i + 6
@i = i if @i >= array.length
array[@i]
}
game = (0..35).to_a
6.times do
6.times do |i|
puts "#{i}: #{skip_6.call( game, i)}"
end
game.shift(1)
puts ""
end
puts "-------------yield--------------"
def skip_six... | true |
737183c2ec6f0998b6691f299f6163d0ea56c98e | Ruby | vmshalkey/ruby_tdd_queue | /queue.rb | UTF-8 | 418 | 3.359375 | 3 | [] | no_license | class Queue
attr_accessor :data_store
attr_reader :back
def initialize
@data_store = []
@back = 0
end
def enqueue(item)
@data_store[@back] = item
@back += 1
end
def queue_display
output = []
for i in 0...@back
output << @data_store[i]
end
output
end
def dequeue
output = @data_store[0... | true |
50a0014d717c873af8f1e478264d92102d5f66a4 | Ruby | adamzima/retryable | /lib/retryable.rb | UTF-8 | 2,798 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'retryable/version'
require 'retryable/configuration'
module Retryable
class << self
# A Retryable configuration object. Must act like a hash and return sensible
# values for all Retryable configuration options. See Retryable::Configuration.
attr_writer :configuration
# Call this method to m... | true |
d7d941a35059de825594b419dc7e36528b2792b4 | Ruby | aschoerk/RbySdku | /lib/print.rb | UTF-8 | 898 | 2.6875 | 3 | [] | no_license | # To change this template, choose Tools | Templates
# and open the template in the editor.
require 'tools'
module RbySdku
module Print
def RbySdku.printSudokuLine(dim, rowIndexes, sudokuarray)
(0...(dim*dim)).each { |col| puts sudokuarray[rowIndexes[col]].to_s + " " }
end
def RbySdku.printSudoku(... | true |
025027c1acb45c87c30b09cfbc48823e7ff0f386 | Ruby | Linzeur/codeable-exercises | /week-3/day-2/CarlosA/classy_extentions.rb | UTF-8 | 176 | 3.8125 | 4 | [] | no_license | class Animal
end
class Cat < Animal
def initialize(name)
@name = name
end
def speak
"#{@name} meows."
end
end
cat = Cat.new("Mr. Whiskers")
puts cat.speak | true |
cb6a9f23098317339c710ed5e7ed7a8de5e418c0 | Ruby | kouhei-fuji/tumblargh | /lib/tumblargh/node/root.rb | UTF-8 | 198 | 2.578125 | 3 | [
"MIT"
] | permissive | module Tumblargh
module Node
class Root < Base
def to_tree
elements.map(&:to_tree)
end
def to_s
elements.map(&:to_s).join ''
end
end
end
end
| true |
e0e53a37745369f4989c5a1d39d877b14669f9fe | Ruby | ngsankha/absynthe | /lib/absynthe/synthesizer.rb | UTF-8 | 2,188 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | # The following algorithm is described with reference of Absynthe paper: Algorithm 1
def synthesize(ctx, spec, q)
if ctx.lang == :sygus
lang = spec.lang
else
lang = nil
end
# line 5
until q.empty? do
# line 6
current = q.top
q.pop
# next few lines are for line 7
pass = ExpandHol... | true |
c70965bfc4781365b5070c587c7805074d5bb8ce | Ruby | marktabler/analyzer | /lib/analyzer/mann_whitney.rb | UTF-8 | 2,109 | 3.171875 | 3 | [] | no_license | module Analyzer
class MannWhitney
include Math
def initialize(set_x, set_y)
@dichotomous, @ordinal = identify_dichotomous_set(set_x, set_y)
@keys = [@dichotomous.uniq.first, @dichotomous.uniq.last]
end
def correlation
return @z if @z
examine_rankings
@u = @ranks.values.... | true |
76b8ffa1b737ed0097efa6196c9336c1e87ed9ed | Ruby | MastersAcademy/ruby-course-2018 | /ruby_basic/boris.larioshin/task_7.rb | UTF-8 | 40 | 2.59375 | 3 | [] | no_license | arr = ARGV[0].split(",")
puts arr.sample | true |
963da4738b1bfd34dfa9ab604629be4b11229012 | Ruby | sh1nduu/understanding_computation | /spec/simple_spec.rb | UTF-8 | 6,393 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
RSpec.describe Simple do
describe '#==' do
subject { lhs == rhs }
context 'when each Number are same values' do
let(:lhs) { Number.new(1) }
let(:rhs) { lhs }
it { is_expected.to be true }
end
context 'when each Number are different values' do
let... | true |
a243769018ac687910bef06649f36b6143eafe02 | Ruby | JeffKatzy/canonical | /week-2/01-domain-modeling/domain-modeling-after/models/order.rb | UTF-8 | 252 | 3.109375 | 3 | [] | no_license | class Order
attr_accessor :drink, :bartender, :customer
@@all = []
def initialize(drink, bartender, customer)
@drink = drink
@bartender = bartender
@customer = customer
@@all << self
end
def self.all
@@all
end
end | true |
530ccab38f71cc369bbbfbdbaec5112e41eb4e38 | Ruby | gammaseeker/Lots_of_Ruby | /LearningRuby/access.rb | UTF-8 | 508 | 3.28125 | 3 | [] | no_license | class Access
# def method1 # default is 'public'
#
# end
# protected
# def method2 # subsequent methods will be protected
#
# end
# private
# def method3 # subsequent methods will be 'private'
#
# end
# public
# def method4 # subsequent methods will be 'public'
#
#... | true |
72eff93864cca3264303a51d22b1517ef68f7518 | Ruby | saijo-108/project-selenium-ruby | /ruby/selenium_form_tea.rb | UTF-8 | 507 | 2.546875 | 3 | [] | no_license | require 'selenium-webdriver'
url = "file:///C:/Users/writer/study_work/html/tea.html"
driver = Selenium::WebDriver.for :chrome
driver.get(url)
# [value='cream'] が無ければ [value='lemon'] の方を取得
if !driver.find_elements(:css, "input[name='included'][value='cream']").empty? then
element = driver.find_element(:css, "in... | true |
b277717a7ef439cd25f6aa2490aa0dda119e6619 | Ruby | asmolentzov/backend_prework | /day_7/10_little_monkeys_bonus.rb | UTF-8 | 998 | 4.5625 | 5 | [] | no_license | # 10 Little Monkeys - Bonus: write it so it will run for any number of monkeys
# Ask the user how many monkeys they want to run the rhyme for
print "So... how many monkeys are jumping on the bed? >> "
monkey_num = gets.chomp.to_i
puts "Ok, #{monkey_num} monkeys it is!"
# Create array of numbers
monkeys = (1..monkey_n... | true |
5922c736b75a7162f6ce9382b8da9cf9f6835fea | Ruby | Jakintero/ruby-intro | /challenges/ruby/14-shortest-string/my_solution.rb | UTF-8 | 229 | 2.71875 | 3 | [] | no_license | # Shortest String
#Tu solucion abajo:
def shortest_string(a=["Javiers", "Loren", "Yeison"])
a.min_by(&:length)
<<<<<<< HEAD
# if a.empty?
# return nil
=======
>>>>>>> refs/remotes/origin/master
end
puts shortest_string
| true |
413ec9062048b4dc663706d5b148deffd3e452fa | Ruby | gonyolac/ls_ruby_course | /random_exercises/longest_palindrome.rb | UTF-8 | 457 | 3.453125 | 3 | [] | no_license | require 'pry'
def longest_palindrome(string)
counter = 0
array = []
while counter < string.size
counter2 = counter
while counter2 < string.size
string.include?(string[counter..counter2].reverse) && string[counter..counter2].include?(string[counter..counter2].reverse) ? (array << string[counter..coun... | true |
5dbcd29e66d496de75ddffa3d2dac95760bb8cf2 | Ruby | abelards/jekyll-array-intersect | /array_intersection.rb | UTF-8 | 616 | 3.046875 | 3 | [
"MIT"
] | permissive | # ArrayIntersectionFilter
# these three lines will help you find common tags/topics/categories.
# use `intersection` to get a boolean, `intersect` to get an array
# example: `{{ assign related = a | intersection: b }}`
module Jekyll
module ArrayIntersectionFilter
def intersect(var,args)
a = var.is_a?(Array... | true |
a7598afa97c8a974d2dabab2d869665533f165a0 | Ruby | ytyeoh/todo | /app/controllers/task.rb | UTF-8 | 526 | 2.625 | 3 | [] | no_license | require_relative '../../config/application'
class TaskController
def self.list
Task.all
end
def self.delete(id)
Task.delete(id)
end
def self.find(id)
Task.find(id)
end
def self.add(words)
Task.create(:name => words)
end
def self.name(id)
Task.find(id).select(:name)
end
d... | true |
485c0621b1193f6e2f13ecc4c606a9ab24ab228d | Ruby | RyanMacG/bgg | /spec/bgg_search_spec.rb | UTF-8 | 3,089 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: UTF-8
require 'spec_helper'
describe Bgg::Search do
describe 'class method' do
describe 'query' do
it 'throws an ArgumentError when an empty string is passed in' do
expect{ Bgg::Search.query('') }.to raise_error(ArgumentError)
end
it 'throws an ArgumentError when a non-stri... | true |
40f4262a99f763ef8ca0271f847efbdf158760b4 | Ruby | macbury/alchemyCMS | /vendor/plugins/mini_magick/test/mini_magick_test.rb | UTF-8 | 2,588 | 2.53125 | 3 | [
"MIT"
] | permissive | begin
# Rails context
require File.dirname(__FILE__) + '/../../../../test/test_helper'
rescue LoadError => e
# Normal Ruby context
$:.unshift(File.dirname(__FILE__) + "/../lib/")
require 'test/unit'
require 'mini_magick'
end
#uri = "http://www.usemycomputer.com/indeximages/2005/November/angelina_jolie_nov_... | true |
5fd1fb3570310429649e9a520274b8b4938e2396 | Ruby | sjclijie/test2 | /ruby/file_custom.rb | UTF-8 | 167 | 2.859375 | 3 | [] | no_license | #encoding=utf-8
def simple_grep(pattern, filename)
file = File.open(filename)
file.each_line do |x|
if pattern =~ x
puts x
end
end
file.close()
end
| true |
d32c3b0baaa5d4837cbddcfc9b2b56a4f48aa157 | Ruby | Kmullen444/RubyExercises | /hotel_project/lib/hotel.rb | UTF-8 | 868 | 3.640625 | 4 | [] | no_license | require_relative "room"
require "byebug"
class Hotel
def initialize(name, capacities)
@name = name
@rooms = {}
capacities.each { |room_name, capacity| @rooms[room_name] = Room.new(capacity)}
end
def name
@name.split.map { |word| word.capitalize }.join(" ")
end
def rooms
@rooms
e... | true |
d4fe16c38249ad8635c58f1d41ed4e656deea2ae | Ruby | mattsroufe/code-eval | /DetectingCycles/detecting_cycles.rb | UTF-8 | 370 | 2.96875 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
input = line.split(" ").map { |s| s.to_i }
hash = Hash.new(0)
match = []
n = input.length / 2
for i in 2..n
input.each_cons(i).each do |v|
hash[v] += 1
end
end
max = hash.values.max
hash.each do |k, v|
if v >= 2 && v == max
match << k
end
end
puts... | true |
c760d5253f7fd1f8e9dd2050e662f4b66f6d0946 | Ruby | Simondharcourt/Optional-01-Colorful-Algorithm | /lib/colorful.rb | UTF-8 | 444 | 3.6875 | 4 | [] | no_license | def colorful?(number)
# TODO: return true if the number is colorful, false otherwise
array = number.to_s.split(//).to_a
colorful = true
print array
list = []
array.each do |number1|
array.each do |number2|
list.append(number1.to_i * number2.to_i)
end
end
puts list
list.each do |number1|
... | true |
1f84db217e1df1f3820ab390ed8dd442bf78df7e | Ruby | yumojin/Example-Sketches | /samples/contributed/fern.rb | UTF-8 | 999 | 2.90625 | 3 | [
"MIT"
] | permissive | # The Fern Fractal
# by Luis Correia
attr_reader :bnds
def setup
size 500, 500
@bnds = Boundary.new(0, width)
no_loop
puts 'Be patient. This takes about 10 seconds to render.'
end
def draw
background 0
load_pixels
x0, y0 = 0.0, 0.0
x, y, r = 0.0, 0.0, 0.0
i, j = 0, 0
max_iterations = 200_000
ma... | true |
6d61a6d498ad6a1a748751abaa25d6091ef24b0f | Ruby | sowmyanaval/Notes | /code/ruby/trace_calls.rb | UTF-8 | 1,927 | 2.734375 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby 1.9 and 2.0",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... | true |
e5028cff3e8866ff0c45f142c7ae160f36d3f797 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/crypto-square/e6a04f5907ed41deb41e6a5464abf614.rb | UTF-8 | 729 | 3.328125 | 3 | [] | no_license | class Crypto
def initialize(message)
@message = message
end
def normalize_plaintext
@message.gsub(/\W/, "").downcase
end
def normalize_ciphertext
slice_size = size > 2 ? size - 1 : size
ciphertext.chars.each_slice(slice_size).map { |slice| slice.join }.join(" ")
end
def size
Math.sq... | true |
dea07cbf823322615ca30231b534b627060bb2df | Ruby | susanna-kaukinen/c_containers | /playing_w_langs/ruby/rpg/rule_monster_engine.rb | UTF-8 | 5,797 | 2.625 | 3 | [
"MIT"
] | permissive |
module RuleMonsterEngine
def fight
init_fight
play_rounds
restructor
end
def get_sides
@sides.clone
end
def prompt_player_action(draw, character, opponents, friends, _cls)
p "prompt_player_action: #{character.name}, #{opponents[0].name}... #{friends[0].name} ..."
draw_all_but_active_player(charac... | true |
710e34331701946a96f7ae8a5dab3f173171c86e | Ruby | shoudto/prime-ruby-online-web-pt-061019 | /prime.rb | UTF-8 | 231 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
require 'prime'
#in pry =>argument(number) = 2
def prime?(number)
# binding.pry
return false if number < 2
(2..number - 1 ).each do|num|
if (number % num) == 0
return false
end
end
true
end
| true |
3eb0fe0b92097c252385e67d35628a50a8cf5a3f | Ruby | davydotcom/happyapps_gem | /lib/happyapps/checks_interface.rb | UTF-8 | 1,621 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'json'
require 'rest-client'
class HappyApps::ChecksInterface < HappyApps::APIClient
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
@access_token = access_token
@refresh_token = refresh_token
@base_url = base_url
@expires_at = expires_at
end
def get(options=nil)
url ... | true |
0400492b4c4830a12839bb854168d7cd54b85f69 | Ruby | hanksudo/hengenjizai | /ruby/ruby-101/proc.rb | UTF-8 | 193 | 3.765625 | 4 | [] | no_license | multiples_of_3 = proc do |n|
(n % 3).zero?
end
print (1..100).to_a.select(&multiples_of_3)
puts
def greeter
yield
end
phrase = proc { puts 'Hello there!' }
greeter(&phrase)
phrase.call
| true |
0aa24b4035c517268e7394ebbe1f528456f23c42 | Ruby | fukayatsu/heroku-dyno-restarter | /web.rb | UTF-8 | 1,941 | 2.5625 | 3 | [] | no_license | require 'sinatra'
require 'json'
require 'redis'
require 'platform-api'
REDIS = Redis.new(url: ENV['REDIS_URL'] || ENV["REDISCLOUD_URL"])
HEROKU = PlatformAPI.connect(ENV['HEROKU_API_KEY'])
RESTART_INTERVAL = (ENV['RESTART_INTERVAL'] || 1800).to_i
get '/' do
'ok'
end
post '/webhook' do
return bad_request('inval... | true |
74836ed29cab808e9ce5145daa23b606e46142d6 | Ruby | logicalproof/Isolation | /Planet.rb | UTF-8 | 386 | 2.671875 | 3 | [] | no_license | require_relative 'Modules/GameObject.rb'
class Planet
attr_accessor :name
include GameObject
def initialize(name, object_database)
@name = name
self.generate_id(object_database)
end
def generate_resource(name, player, klass)
resource = klass.new(name, player)
resource.quantity = rand(50)
... | true |
ee12dd125af3bfc5f8e0c8163984f440b6bdcb32 | Ruby | dalspok/intro_to_prog | /basics/3.rb | UTF-8 | 93 | 3.015625 | 3 | [] | no_license | hsh = {"movie one" => 1975, "movie two" => 2001}
puts hsh["movie one"]
puts hsh["movie two"] | true |
e2af1fec822a87de9fec5b590876acae03caf4d6 | Ruby | qqdipps/Algorithms | /Algorithms/Ruby/root-to-leaf-paths.rb | UTF-8 | 660 | 3.6875 | 4 | [] | no_license | # Given a binary tree, return all root-to-leaf paths.
#
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @return {String[]}
def binary_tree_paths(ro... | true |
e0f72788e109dd76c211f73418209a9ba2ec625b | Ruby | Alex-Joseph/drone-simulator | /test/models/drone_test.rb | UTF-8 | 2,683 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class DroneTest < ActiveSupport::TestCase
# take_off method
def test_drone_can_take_off
@mock_sensor = Components::OrientationSensor.new
@drone = Drone.new(orientation_sensor: @mock_sensor)
@drone.take_off
@mock_sensor.stub(:status, { roll: 1, pitch: 0 }) do
expected_s... | true |
e15807ec7bb740d7462863e3351cb55aa37b3efc | Ruby | bsielski/bsielski_value_generator | /lib/v_gen/old_hash_gen.rb | UTF-8 | 1,300 | 2.875 | 3 | [
"MIT"
] | permissive | require_relative "./int_gen"
require_relative "./float_gen"
require_relative "./var_word_gen"
require_relative "./array_gen"
require_relative "./keyword_gen"
module VGen
class HashGen
def initialize(max_depth: 3)
@max_depth = max_depth
end
def call(
only: [
IntGen.new,
... | true |
026eb6f13bca2e227eca9b9b0ea8582d01ad9ac7 | Ruby | duyliempro/training | /rubyexample/test.rb | UTF-8 | 2,141 | 3.546875 | 4 | [] | no_license | a = [10, 8, 17]
=begin
puts [0]
puts a.first()
puts a.last()
if(a.last == a[-1])
puts a[444]
end
=end
=begin
x = a.length()
puts a.sort
puts "\n"
puts a
puts x
puts "\n"
a.sort!()
puts a.reverse!
=end
=begin
a.push(11)
a = (0..9).to_a
puts a[2..-1]
=end
=begin
b = ('a'..'e').to_a
puts b
=end
=begin
(1..... | true |
948e6a08ebb5feec44b7bf4e7a7a024b87ac2882 | Ruby | vijayakumarsuraj/automation | /Packages/Features/web/lib/helpers/diff_helpers.rb | UTF-8 | 3,126 | 2.78125 | 3 | [] | no_license | #
# Suraj Vijayakumar
# 17 May 2013
#
module Automation
module DiffHelpers
# Generates the diff of the specified strings and returns an HTML report.
# Internally, generates temporary files with the content and calls the 'generate_file_diff' method.
#
# @param [String] left the original content (exp... | true |
a18af41ac3a56b29fbf2b3c04d960fc511a42d97 | Ruby | WGretz/willgretz.com | /_scripts/build_data.rb | UTF-8 | 1,901 | 2.578125 | 3 | [] | no_license | require 'linkedin'
require 'yaml'
require 'pry'
# you're now free to move about the cabin, call any API method
def update_bgg_stats
end
#create a LinkedIn::Client, present user with
def linkedin_client
# load api
linkedin_api_settings = YAML.load_file("#{Dir.home}/.linkedin")
consumer_key ... | true |
ee5e8390a057b79911f7bb1d4831af59d4d5a051 | Ruby | masao/fuwatto | /cinii-author.rb | UTF-8 | 3,112 | 2.65625 | 3 | [] | no_license | #!/usr/local/bin/ruby
# -*- coding: utf-8 -*-
# $Id$
require_relative "fuwatto.rb"
require_relative "cinii.rb"
module Fuwatto
class CiniiAuthorApp < CiniiApp
TERMS = 10
TITLE = "ふわっとCiNii関連著者検索"
HELP_TEXT = <<-EOF
<p>
入力したテキストまたはウェブページに関連する論文著者を<a href="http://ci.nii.ac.jp">CiNii</a>から検索します。
長... | true |
c0a2a9f3558915597937be05bc9efac0f3f78b1d | Ruby | CalumCannon/rock-paper-scissors-sinatra-app | /models/game.rb | UTF-8 | 447 | 3.09375 | 3 | [] | no_license | require('pry-byebug')
class Game
def initialize(first, second)
@first = first
@second = second
end
def calculate
list = [@first, @second]
return "Paper Wins!" if(list.include?("rock") && list.include?("paper"))
return "Rock Wins!" if(list.include?("rock") && list.include?("scissor... | true |
c0774098f6fedeb9efabe6bff310b2656f137a69 | Ruby | ravenwijaya/ruby-course | /Ruby1/page9/index.rb | UTF-8 | 141 | 2.65625 | 3 | [] | no_license | length = 9
width = 8
puts width
puts length * width
puts "----"
# Perbarui variable width dengan 13
width=13
puts width
puts length * width | true |
4567f6aa12314842d5ddff61d69a3d6ecb6fc314 | Ruby | arnaudbouffard/promo-2-challenges | /02-OOP/03-Basic-OOP/lib/run.rb | UTF-8 | 192 | 3.140625 | 3 | [] | no_license | require_relative 'orange_tree'
naranjo = OrangeTree.new
100.times do
naranjo.one_year_passes!
break unless naranjo.alive?
end
puts "Naranko died dude... He was #{naranjo.age} years old"
| true |
031b29a5046f7c3ee50e29f0aa4978c6f2894eb5 | Ruby | czuger/dungeon_gen_2 | /libs/rooms/room.rb | UTF-8 | 3,045 | 3.46875 | 3 | [
"MIT"
] | permissive | require_relative '../dungeon/dungeon_element'
require_relative '../position'
class Room < DungeonElement
attr_reader :room_center, :elements
ROOMS_SIZES = [ [ 2, 2 ], [ 2, 4 ], [ 4, 2 ], [ 4, 4 ] ]
def initialize( room_size, position: nil )
@elements = []
room_size = room_size || ROOMS_SIZES.sample
... | true |
b4f15bdf69908c058829bcef4a43c80448f94e8a | Ruby | Jpease1020/sales-engine | /lib/customer_repository.rb | UTF-8 | 1,539 | 2.96875 | 3 | [] | no_license | require_relative 'customer_loader'
class CustomerRepository
attr_reader :customers, :dir, :sales_engine
def initialize(dir, sales_engine)
@customers = []
@dir = dir
@sales_engine = sales_engine
create_customers
end
def inspect
"#<#{self.class} #{self.id}>"
end
def create_... | true |
4ab5f0021b8867f8cb7e6367ae040c33f55e7473 | Ruby | drewwilliams5280/backend_module_0_capstone | /day_1/ex4.rb | UTF-8 | 1,445 | 3.8125 | 4 | [] | no_license | # We have 100 cars.
cars = 100
# We have 4 seats in each car
space_in_a_car = 4
# We have 30 drivers
drivers = 30
# We have 90 passengers
passengers = 90
# The number of cars not being driven = cars - drivers
cars_not_driven = cars - drivers
# The number of cars driven = drivers
cars_driven = drivers
# Our carpool capa... | true |
65a0e3b0a4fbdb1e0f6f304a2be9411cfa73ea86 | Ruby | miminashi/tweet_only | /tweet | UTF-8 | 471 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'tweet_only'
text = ARGV.join(' ')
if text == ""
puts "no text"
exit(1)
end
client = TweetOnlyClient.new
unless client.authorized
authorize_url = client.authorize
%x{open #{authorize_url}}
print "input verifier: "
v = $stdin.gets.chop
unless client.verifier(v)
puts "Autho... | true |
414cc499203375cf7c04fb69728d2cec1e8d5708 | Ruby | wpcfeb/Code_learn | /Ruby/hash.rb | UTF-8 | 731 | 3.5 | 4 | [] | no_license | my_detials = {'name' => 'Peace', 'favcolor' => 'red'}
p my_detials['favcolor']
sample_hash = {'a' => 1, 'b' => 2, 'c' => 3}
p sample_hash
another_hash = {a: 1, b: 2, c: 3}
p another_hash
p another_hash[:a] # :a is Symbol (identifier)
another_hash.each do |key, value|
puts "The class for key is #{key.class} and the... | true |
904c54a3468158356d6be7fbea535fc8b2db7c3b | Ruby | JenDixon/oo-student-scraper-v-000 | /lib/scraper.rb | UTF-8 | 1,462 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'nokogiri'
require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
html = File.read(index_url)
student_class = Nokogiri::HTML(html)
students = []
student_class.css('.student-card').each do |card|
students << {
:name => card.css('.student-name').text... | true |
4b29a13b2c170271e7dd9e91bc5ab71a1614b325 | Ruby | jichen3000/colin-ruby | /test/sinatra/create_sqlite3_simpledb.rb | UTF-8 | 1,007 | 2.609375 | 3 | [] | no_license | require 'sqlite3'
require 'sequel'
db_filename = File.join(File.dirname(__FILE__),'simple.db')
db = Sequel::sqlite(db_filename)
#db.drop_table :people
db.create_table! :people do
primary_key :id
Int :role_id
String :name
Int :income
DateTime :created_at
DateTime :updated_at
end
#db.drop_table :roles
db.... | true |
4ae01942e5b236b5e73e36781a2fef8be9ea3ade | Ruby | gabynaiman/timing | /spec/interval_spec.rb | UTF-8 | 5,311 | 3.171875 | 3 | [
"MIT"
] | permissive | require 'minitest_helper'
describe Interval do
let(:random) { (rand * 10).round(1) }
let(:minutes_in_seconds) { 60 }
let(:hours_in_seconds) { 60 * 60 }
let(:days_in_seconds) { 60 * 60 * 24 }
let(:weeks_in_seconds) { 60 * 60 * 24 * 7 }
def assert_parsed_seconds(expression, expected_seconds)
In... | true |
14c67c8d6461c1f2948ccdce01a322a18452cc15 | Ruby | asms/synthetics | /spec/lib/synthetics/util_spec.rb | UTF-8 | 1,921 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Synthetics::Util do
describe '.deep_snakeify_keys' do
let(:input) do
{
'key_one' => 1,
'keyTwo' => 2
}
end
let(:expected) do
{
key_one: 1,
key_two: 2
}
end
it 'transforms all of the string keys into snakeified... | true |
800992d91adf8f1a03a48c14d360e582ac64eb3b | Ruby | jah2488/gamebox | /examples/rague/src/tile.rb | UTF-8 | 1,392 | 3.328125 | 3 | [
"MIT"
] | permissive | # Tile is a location on the map
class Tile < Actor
has_behaviors :animated
attr_accessor :seen, :solid, :occupants, :location
def setup
tile_x = @opts[:tile_x]
tile_y = @opts[:tile_y]
new_action = @opts[:action]
new_action ||= :floor
self.action = new_action
stop_animating
tile... | true |
ac3efe61aa8b69d5a10924d86b4f647f05787b48 | Ruby | cmartin300/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 670 | 4.15625 | 4 | [] | no_license | #write your code here
def echo (string)
string
end
def shout (string)
string.upcase
end
def repeat (string, times = 2)
stringPlusSpace = "#{string} "
"#{stringPlusSpace * (times - 1)}#{string}"
end
def start_of_word (string, int)
array = string.split("")
result = ""
i = 0
while (i ... | true |
7eb184804a9e05b97666a327340f562e142092b7 | Ruby | pajtai/WikiBuddy | /regex_trials.rb | UTF-8 | 496 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby
test_string = "this is [[link1]] not [link-1] and [[other|link2]] [[link3]] [[test|this]]"
OPEN_LINK = /\[\[/
CLOSE_LINK = /\]\]/
SIMPLE_LINK = /([^\]|]+)/
TWO_PART_LINK = /[^|]+\|([^\]]+)/
def linkRegex open, link, close
/#{open}#{link}#{close}/
end
# needs to include "link2 "
test_string.sc... | true |
2b8e36d46b5f4fde0abbcfe5df766d129770b4c2 | Ruby | mgalibert/geonames | /geonames.rb | UTF-8 | 4,730 | 2.921875 | 3 | [] | no_license | require "csv"
require 'net/http'
require 'nokogiri'
require 'set'
require 'stringex'
require 'colorize'
require 'fileutils'
require_relative './lib/constants'
require_relative './lib/utils'
require_relative './lib/geonames_api'
NAMES_NOT_FOUND = load_set_from_csv(NAMES_NOT_FOUND_FILE, :name)
NAMES_WITHOUT_... | true |
d8e1c590764374a6008f1029e79976312638c1a1 | Ruby | husky-misc/transfeera-sdk | /lib/transfeera_sdk/batch.rb | UTF-8 | 1,008 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'transfeera_sdk/base'
require 'transfeera_sdk/bank'
module TransfeeraSDK
class Batch < TransfeeraSDK::Base
def create!(opts = {})
update_bank_ids(opts)
send_request(:post, "/batch", opts)
end
def update!(batch_id, opts = {})
update_bank_ids(opts)
send_request(:put, "/batc... | true |
24453f1999067f89bd1cedef571be5096fc1a6da | Ruby | nicholas-wilson/rack-dynamic-routes-lab-online-web-sp-000 | /app/application.rb | UTF-8 | 657 | 3.09375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Application
def call(env)
resp = Rack::Response.new
req = Rack::Request.new(env)
if req.path.include?("/items/")
item_name = req.path.split("/items/").last
if !!has_item?(item_name)
returned_item = has_item?(item_name)
resp.write "#{returned_item.price}"
else
... | true |
47c1de0ae00f969e8e0cbfcac27f2e8fe8879446 | Ruby | hai-nguyen1112/apis-and-iteration-dc-web-career-010719 | /lib/api_communicator.rb | UTF-8 | 1,800 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'rest-client'
require 'json'
require 'pry'
def get_character_movies_from_api(character_name)
#make the web request
response_hash = web_request
api_urls = list_of_apis(response_hash, character_name)
movie_list = movie_collection(api_urls)
end
# iterate over the response hash to find the collection of... | true |
7d24272e048459584eedf601422062cf1b0324b4 | Ruby | wass88/mruby-clock | /main/examples/led_clock.rb | UTF-8 | 3,588 | 2.734375 | 3 | [
"MIT"
] | permissive | i = 0 # Counter
infos = ["","KMC"] # Info messages
ws = [70, 124, 55, 110, 50, 80, 63, 101, 76, 90, 54, 98, 69, 90] # Week day name
week = (0...7).map{|i|
[27, 36, 66, ws[2*i], ws[2*i+1], 27, 40, 66].map{|k|k.chr}.join("")}
cmd = "" # Posted command
ballInit = false
balls = [[8.0, 5.0, 0.0, 0.0], [1.0, 9.0, 0.0, 0.0... | true |
2be81cb52ec9f24d65be231d54bcec7b6d88a3a8 | Ruby | zhiyuan2007/useful_tools | /ruby/beacon/server/lib/beacon/grid/member.rb | UTF-8 | 8,938 | 2.6875 | 3 | [] | no_license | module Beacon
module GRID
class MemberException < RuntimeError; end
class Service
include Comparable
attr_reader :name
attr_accessor :state
def <=> (another)
self.name <=> another.name
end
def initialize(name)
@name = name
... | true |
9e22312d89424c1803aa5e15569ca72cf72aff10 | Ruby | issik/casino | /wallet.rb | UTF-8 | 189 | 3.3125 | 3 | [] | no_license | class Wallet
HIGH_ROLLER = 500
attr_accessor :amount
def initialize(amount)
@amount = amount
if amount > HIGH_ROLLER
`say Ooooo...high roller!`
end
end
end
| true |
327f35039cd8182206807c8e64e37e6d6e558e51 | Ruby | mixonic/ember-repo-builder | /lib/project.rb | UTF-8 | 951 | 2.59375 | 3 | [] | no_license | require 'json'
class Project
attr_accessor :build_dir, :build_task,
:build_glob, :repo, :owner
EMBER_FILES = [
['ember.js', 'ember.js'],
['handlebars.js', 'modules/handlebars.js'],
['ember-runtime.js', 'ember-runtime.js']
]
def self.ember
new(ember_options)
end
def self.sorted(projec... | true |
5c94a11d347d3bf75a9741002e18f6126e36d67e | Ruby | JKCodes/launch | /170_lesson_2/exercises.rb | UTF-8 | 656 | 3 | 3 | [] | no_license | # 1. What are the required components of an HTTP request?
# What are the additional optional components?
# Http method are path are required, but parameters, header, and body are not.
# 2. What are the required components of an HTTP response?
# What are the additional optional components?
# Status code is requi... | true |
c3cb87a1c9394450e6bfbb62256d5ab04fb9c0c7 | Ruby | majesticuser/clean-todo-app | /rails_app/app/repositories/todo_repository.rb | UTF-8 | 690 | 2.921875 | 3 | [] | no_license | require 'todo_item'
class TodoRepository
def contains?(todo_item)
Todo.exists?(title: todo_item.title)
end
def save(todo_item)
todo = Todo.find_or_initialize_by(title: todo_item.title)
todo.completed = todo_item.completed?
todo.save!
end
def delete(todo_item)
Todo.find_by!(title: todo_... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.