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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2a4e9f7eb06128e0e0ccc2a4b2d59b22920fe0b6 | Ruby | tylorlilley/website-on-rails | /lib/sluggable.rb | UTF-8 | 1,575 | 3.15625 | 3 | [] | no_license | module Sluggable
module Finder
# Finds a record using the given id.
#
# If the id is "unslug", it will call the original find method.
# If the id is a numeric string like '123' it will first look for a slug
# id matching '123' and then fall back to looking for a record with the
# numeric id '1... | true |
42bba4a984a44c2e0409e72460d328d60aa5305d | Ruby | aliceloudon/YogaClan_project1 | /models/sequence.rb | UTF-8 | 2,470 | 3.296875 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class Sequence
attr_reader :id
attr_accessor :name, :total_time
def initialize(options)
@id = options['id'].to_i
@name = options['name']
@total_time = 0
end
def save
sql = "INSERT INTO sequences (name) VALUES ('#{@name}') RETURNING *;"
results = ... | true |
bab90c4bd8638123e8ecaedde7507a5066e266cc | Ruby | MooseBoost/ruby-oo-assessment | /lib/animal_sorter.rb | UTF-8 | 287 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class AnimalSorter
attr_reader :animals, :sorted
def initialize(animals)
@animals = animals
@sorted = [[],[]]
end
def to_a
animals.each_with_index do |animal, index|
index.even? ? sorted[0] << animal : sorted[1] << animal
end
sorted
end
end | true |
d5301b2280861ff56ac30f312a8ac731616bd8a4 | Ruby | oddruud/Ruby-Hive | /lib/hive/common/pieces/mosquito.rb | UTF-8 | 597 | 3 | 3 | [] | no_license | require 'piece'
class Hive::Mosquito < Hive::Piece
def initialize(board_state, id)
super(board_state, id)
end
def available_moves
moves = Array.new()
moves += available_place_moves unless used?
moves += Hive::Mosquito.available_board_moves(self) if used?
return moves
end
def self.available_board_moves... | true |
15c2da79f20c1359f26027991d76c0d1e48fa0a4 | Ruby | gdbrough/codeclan_misc | /week_01/day_3/arrays.rb | UTF-8 | 1,187 | 4.25 | 4 | [] | no_license | fruits = ["apple","banana","grape","orange"]
p fruits
p fruits[0]
p fruits[4]
#fruits[2] = "pear"
fruits.insert(2, "pear")
p fruits
p fruits[-1]
p fruits.first()
p fruits.first(2)
p fruits.last()
p fruits.last(2)
# def number_to_month_name(month)
# months = ["January","February","March"]
# return months[month... | true |
8b3883069b3492b2e4e57765eb54e21637c3708e | Ruby | JayZonday/green_grocer-web-112017 | /grocer.rb | UTF-8 | 1,428 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def consolidate_cart(cart)
consolidated = {}
cart.each do |purchase|
purchase.each do |vege,hash|
if consolidated[vege] == nil
consolidated[vege] = hash
consolidated[vege][:count] = 0
end
consolidated[vege][:count] += 1
end
end
return consolidated
end
def apply_coupons... | true |
df68c3189ab79adf93c58f9094952622664f7757 | Ruby | hrithikv/chess.rb | /sliding_player.rb | UTF-8 | 744 | 3.15625 | 3 | [] | no_license | class Sliding_Player < Player
def leaps
possible_leaps = []
move_dirs.each do |delta|
last_pos = @position.duplicate
loop do
last_pos[0] += delta[0]
last_pos[1] += delta[1]
break unless on_gameboard?(last_pos)
break if own_player?(last_pos)
if opp_player?(... | true |
92088a5f063412f44ac8f777ca342b7791b3768d | Ruby | vizvamitra/rubizza-2019_web | /simple_web_server.rb | UTF-8 | 315 | 2.921875 | 3 | [] | no_license | require 'socket'
server = TCPServer.new(6543)
loop do
conn = server.accept
request = []
while line = conn.gets
request << line
break if line == "\n"
end
puts request
conn.puts <<~HTTP
HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
Hello world!
HTTP
conn.close
end
| true |
3240f2547aa8feab678ea5114edd70c91b24f47d | Ruby | kjakub/apiary_factory | /test/basic_test.rb | UTF-8 | 1,385 | 2.53125 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
require 'test/unit'
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/apiary_girl'))
require File.expand_path(File.join(File.dirname(__FILE__), 'support/dictionaries'))
require File.expand_path(File.join(File.dirname(__FILE__), 'support/models'))
ApiaryGirl.create_definitio... | true |
b0ecb912dd2512ee93ff13c5fb90cacb2a10d7f6 | Ruby | sekou7/rubyproj | /AdvancedConcepts/Hashes.rb | UTF-8 | 1,610 | 3.953125 | 4 | [] | no_license | =begin HASHES
Hashes are useful when you want to connect data
E.g.: People and how the are doing
Person and if the like the weather
Address gives you the zipcode
A job gives you income
Cars and how much fuel they consume
(In a dictionary) A word is connected to its def... | true |
ddc16cd933be5fad0b38af41902926235ca53826 | Ruby | dominictarr/meta | /tester.rb | UTF-8 | 713 | 2.546875 | 3 | [] | no_license | require 'yaml'
require 'quick_attr'
require 'rubygems'
# require 'open4'
# require 'modules/stdout_catcher'
require 'modules/sandbox'
class Tester
extend QuickAttr
quick_attr :test,:klass
quick_array :requires
def run()
unless requires.empty? then
requires.each {|r|
require r
}
end
t = eval ... | true |
5abd238db8662629be131ec75df554d4c231dc68 | Ruby | paulorades/synthea | /test/unit/symptoms_test.rb | UTF-8 | 1,396 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | require_relative '../test_helper'
class SymptomsTest < Minitest::Test
def setup
@patient = Synthea::Person.new
end
def test_setting_symptom
# Make sure we can set a symptom value and get the correct result when retrieving it
@patient.set_symptom_value(:diabetes, :fatigue, 30)
assert_equal 30, @... | true |
d24be5bdd55033a16ec7778fedacac7858cfb46f | Ruby | monkeyx/odyssey30K | /lib/.svn/text-base/name_generator.rb.svn-base | UTF-8 | 929 | 3.28125 | 3 | [] | no_license | class NameGenerator
def initialize(data_handler, min_length = 3, max_length = 9)
@data_handler = data_handler
@min_word_length = min_length
@max_word_length = max_length
@follower_letters = data_handler.follower_letters
end
def generate_name(word)
last_pair = word[-2, 2]
letter ... | true |
d439981c6e4a91009dd277bf8f7bec5402058399 | Ruby | lwg2018/RubyExams | /boolean.rb | UTF-8 | 127 | 2.953125 | 3 | [] | no_license | x="안녕"
y="잘가"
z="또봐"
input="잘가"
if x==input
print(x)
elsif y==input
print(y)
else
print(z)
end
| true |
a64d28a3ac4dea56de76092ad14e4805ddc27706 | Ruby | sadipgiri/Seven-Languages-In-Seven-Weeks | /Ruby/guessTheNumber.rb | UTF-8 | 2,451 | 4.75 | 5 | [] | no_license | # guess the number
# Here, I am going to make the guessing game accoding to the Binary Search Technique. That is, user have to guess intuitively according to the computer saying whether it's low or high.
# Number of chances give to user depends on the log of the range user chooses
puts "Starting from 1, upto what nu... | true |
54236e27438a816fbff711a705ccb4958c06b33e | Ruby | shifubear/CS214 | /proj10/ruby/Duck.rb | UTF-8 | 341 | 2.875 | 3 | [] | no_license | # Duck.rb | Defines the Duck class which inherits attributes and methods
# from the Bird superclass.
#
# Begun by: Dr. Adams, for CS 214 at Calvin College.
# Completed by: Gavin Martin
# Date: 4/25/18
####################################################
require './FlyingBird.rb'
class Duck < FlyingBird
def call... | true |
ac07cbcc26117938dc3f01ba7ee7d0c46205445c | Ruby | iExperience/session0202_exercises | /RobertKrabek-rkrabek/d2/leap.rb | UTF-8 | 234 | 3.546875 | 4 | [] | no_license | puts "give me a start year and then an end year"
startyear = gets.chomp.to_i
endyear = gets.chomp.to_i
for i in startyear..endyear
if (i % 4 == 0) && ((i % 100 != 0) || (i % 400 == 0))
puts "#{i}\n"
i += 1
else
i += 1
end
end | true |
b880b1c882762356d4364d84dd08f4d4eae5681c | Ruby | erirazapii/twitter_eri | /app/models/favorite.rb | UTF-8 | 874 | 2.5625 | 3 | [] | no_license | class Favorite < ActiveRecord::Base
# favorite.favorite_tweet
# user_idを使ってお気に入りしているユーザーを取得
#もしbelongs_to :tweetになっててtweetの部分がデーブル名そのままだったら
#Railsさんが勝手にどのオブジェクトから何をキーにすればいいか判別してくれる
#外部キーを使う理由は、Class名を指定してもuser_idかtweet_idどっちとればいいか
#Railsさんが迷ってしまうから、指定してあげる
belongs_to :favorite_tweet, class_name: "Tweet", for... | true |
0dc341d218523544576048b33d6fa68cac4510ad | Ruby | matwej/simple_spell_checker | /lib/simple_spell_checker/checker.rb | UTF-8 | 1,584 | 3.265625 | 3 | [
"MIT"
] | permissive | require 'simple_spell_checker/bk_tree'
module SimpleSpellChecker
class Checker
include BkTree
# Dictionary file in UTF-8 - word per line
# Adapters for distance: :gem, :custom
def initialize(dictionary_file_path, distance_adapter = :gem)
@tree = Tree.new distance_adapter
# start = Time.n... | true |
fcf6b8a5e79affb0d0dd3151583dc7ed1b08e4d8 | Ruby | Dimanaux/sequence-generator | /src/main/sequence.rb | UTF-8 | 529 | 3.5625 | 4 | [] | no_license | require_relative './sequence_iterator.rb'
# stores numbers from sequence, limits SequenceIterator
class Sequence
def initialize(bound = 16)
@iter = SequenceIterator.new
@bound = bound
@sequence = [@iter.state]
end
def [](index)
raise "Index #{index} is out of bound #{@bound}!" unless index < @bo... | true |
97bdd1004a07abad79fa8832f1efb091eb8163c6 | Ruby | agrimm/akihito | /lib/author_parser.rb | UTF-8 | 1,181 | 3.171875 | 3 | [] | no_license | require 'author'
# Parse XML documents to create authors
class AuthorParser
attr_reader :authors
def initialize(document)
@document = document
@authors = create_authors
end
AUTHOR_XPATH = './/contrib-group/contrib/name'
def create_authors
author_name_nodes = @document.xpath(AUTHOR_XPATH)
a... | true |
36a796fdff48515a435fd31130e67e8d8ce4f840 | Ruby | lingtran/jungle_beats | /test/node_test.rb | UTF-8 | 626 | 2.828125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require '../lib/node'
class NodeTest < Minitest::Test
def test_node_can_take_in_data
node = Node.new("Broncos")
assert_equal "Broncos", node.data
# instantiate node object
# return of data matches data that was given
end
def test_node_has_a_l... | true |
3ef28db02897924c4d4cabf18581e39aa1e9f425 | Ruby | SamVinchester/movies | /spec/cashbox_spec.rb | UTF-8 | 595 | 2.71875 | 3 | [] | no_license | require '../empty.rb'
describe Cashbox do
let(:empty) { Empty.new }
describe '#cash' do
context 'when using #cash' do
subject { empty.cash }
it { is_expected.to eq 0 }
end
end
describe '#take(who)' do
before { empty.cash }
context 'when #take correct' do
subject { empty.take... | true |
68b62e9b233fe48a2cf714af188a8c6dd0d88a8c | Ruby | pchir643/livecode-sinatra | /db/seeds.rb | UTF-8 | 246 | 2.640625 | 3 | [] | no_license | require 'faker'
10.times do
restaurant = Restaurant.new(
name: Faker::Beer.brand,
address: "#{Faker::Address.street_name}, #{Faker::Address.city}",
rating: rand(0..10)
)
restaurant.save!
puts "created #{restaurant.name}"
end
| true |
725d5e8ee0ff8efca9958d2747639355c350ce16 | Ruby | Tanakan7/ScriptsOfMinutes | /iin_id.rb | UTF-8 | 1,281 | 2.796875 | 3 | [] | no_license | #input
#ruby kai01.rb
#edit in sep07th
require 'csv'
argfname = ARGV[0]
#Dir.glob("./*.csv".encode('utf-8')).each{ |fname| #ディレクトリ内を巡回、fnameにファイル名が入る。
# file2 = File.open(fname.gsub(/.csv/,".html"),"a")
File.open("next/" + argfname, 'w') do |file|
flg = 0
giin_con = "" #議員発言を格納
ans_con = "" #答弁者発言を格納
... | true |
299282b5362ac009a4a9de65c472b655354ecb62 | Ruby | AndyWendt/LearnRubyTheHardWay | /lib/exercise15.rb | UTF-8 | 178 | 2.875 | 3 | [
"MIT"
] | permissive | # https://learnrubythehardway.org/book/ex15.html
#
print "Type the filename:"
file_again = $stdin.gets.chomp
txt_again = open(file_again)
print txt_again.read
txt_again.close
| true |
e4f98d417ee3424ab77684568a6619032767982f | Ruby | mikeweber/elevators | /lib/elevator.rb | UTF-8 | 2,210 | 3.46875 | 3 | [] | no_license | require_relative './door'
class Elevator
WAITING = 'waiting'.freeze
GOING_UP = 'going_up'.freeze
GOING_DOWN = 'going_down'.freeze
private
attr_writer :floor, :status, :door, :requested_floors
public
attr_reader :floor, :status, :door, :requested_floors
def initialize(door: Door.new, floor: 0)
... | true |
c1201d2e847f7bd4032fbf89c1763a9167359542 | Ruby | DeepBlue1986/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 1,594 | 3.046875 | 3 | [] | no_license | require 'open-uri'
require 'json'
class GamesController < ApplicationController
def game
@grid = generate_grid(9).join
end
def score
@start_time = params[:start_time].to_datetime
@end_time = Time.now.to_datetime
result_hash = run_game(params[:query], @grid, @start_time, @end_time)
@result ... | true |
934749bbf08f5d4846881cebe2ac2a4f3c7ed636 | Ruby | giv2giv/giv2giv-rails | /app/models/calculation_share/calculation.rb | UTF-8 | 1,624 | 2.6875 | 3 | [
"MIT"
] | permissive |
module CalculationShare
class Calculation
class << self
def project_amount (options = {})
default_options = {
:principal=>0,
:monthly_addition=>0,
:years=>25,
:return_rate=>0.07
}
options = default_options.merge(options)
... | true |
d3a3e783a6f5d654c9601b7d2f66ea625e8d6570 | Ruby | Bodacious/fanalyze_app | /app/controllers/api/temperatures_controller.rb | UTF-8 | 7,509 | 2.78125 | 3 | [] | no_license | class Api::TemperaturesController < ApplicationController
def index
response = HTTP.get("https://api.sportsdata.io/v3/nfl/projections/json/PlayerGameProjectionStatsByWeek/2020/1?key=")
@projections = response.parse
@projections.each do |projection|
#adding if statement to see where player is playing... | true |
a5e37be231152528e251127afbcb60c6eb7b59a1 | Ruby | matao0214/Demo | /paiza_1.rb | UTF-8 | 237 | 2.828125 | 3 | [] | no_license | t=gets.split.map(&:to_i)
s=gets.split("")
ab=("a".."z").to_a
y=s.size - 1
ans=""
y.times do |x|
i = ab.index("#{s[x]}")
if t[i] > 0
t[i] -= 1
ans << s[x]
end
end
puts ans
puts ans
puts ans
puts ans
puts ans
| true |
1bb1a20a8ee6a0db36d55cd9f3fbb837f8689cf4 | Ruby | masayasviel/algorithmAndDataStructure | /PAST/third/mainC.rb | UTF-8 | 244 | 3.015625 | 3 | [] | no_license | a, r, n = gets.chomp.split(" ").map(&:to_i)
maxim = 10 ** 9
is_large = false
if r == 1 then
puts a
exit
end
(n-1).times do
a *= r
if a > maxim then
is_large = true
break
end
end
puts is_large ? "large" : a | true |
2fd09486d793e12c71416895fc92424e68c775b0 | Ruby | h13ronim/order_query | /lib/order_query/sql/order_by.rb | UTF-8 | 1,667 | 3 | 3 | [
"LicenseRef-scancode-other-permissive",
"MIT"
] | permissive | module OrderQuery
module SQL
class OrderBy
# @param [Array<Column>]
def initialize(columns)
@columns = columns
end
# @return [String]
def build
@sql ||= join_order_by_clauses order_by_sql_clauses
end
# @return [String]
def build_reverse
@re... | true |
99e7c164a79e96f2f907ad65c4331be16ddebab7 | Ruby | fervilches/experiencia15 | /Primera Prueba Ruby paso a paso/parte2.rb | UTF-8 | 375 | 3.3125 | 3 | [] | no_license | def inasistencias
file = File.open('students.csv', 'r')
students = file.readlines
file.close
new_students = []
students.each do |line|
new_students.push(line.split(', ').map(&:chomp))
end
new_students.map do |a|
name = a.shift
inasistencia = a.count('A')
puts " Inasistencias totales de #{... | true |
f77023656eb143136ce4ee51f1db76af47ac557a | Ruby | venkatd/web | /lib/ftp_storage.rb | UTF-8 | 1,720 | 2.84375 | 3 | [] | no_license | class FtpStorage
def initialize(host, username, password)
connect(host, username, password)
end
def connect(host, username, password)
@host, @username, @password = host, username, password
@ftp = Net::FTP.new(@host)
@ftp.passive = true
@ftp.debug_mode = true
@ftp.login(@username, @passw... | true |
98973a00cc9a8a2cab55ad0ced29e5c5805cb077 | Ruby | onefrankguy/packup | /lib/packup.rb | UTF-8 | 7,710 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'rake'
require 'erb'
class Packup
##
# In a pre-alpha state at the moment.
VERSION = '0.1.0'
##
# Excutes the Packup DSL to define your package's definition
# (which internalliy creates Rake tasks). All Packup attributes and
# methods are available within +block+. Eg:
#
# Packup.stuff nam... | true |
662ec10356dbb2f692393ef6e4730d7498b8745e | Ruby | ysato5654/ytvarb | /lib/ytvarb/api/cotohaha.rb | UTF-8 | 773 | 2.5625 | 3 | [
"MIT"
] | permissive | #! /opt/local/bin/ruby
# coding: utf-8
require 'cotoha'
module Ytvarb
module Api
class Cotohaha
attr_reader :response
def initialize client_id, client_secret
@response = Hash.new
@client = Cotoha::Client.new(client_id: client_id, client_secret: client_secret)
@client.create_access_token
end... | true |
6353df72821f5c5742042066541f4275cce8d0e7 | Ruby | 4rlm/dbc_onsite | /2.2_parsing-data-1-csv-in-csv/runner2.rb | UTF-8 | 191 | 2.765625 | 3 | [] | no_license | require_relative 'person'
require_relative 'person_parser'
people = PersonParser.parse('people.csv')
puts people[0].first_name
puts people[0].born_at
puts DateTime.parse(people[0].born_at)
| true |
377f9a453511bf055eeb13e0bc5da1fb0bd21a14 | Ruby | houston/attentive | /lib/attentive/trie.rb | UTF-8 | 888 | 3.0625 | 3 | [
"MIT"
] | permissive | module Attentive
class Trie
attr_reader :depth
def initialize(depth: 0)
@depth = depth
@children = {}
end
def [](token)
@children[token]
end
def add(token)
raise "Can't add #{token.inspect} to trie because this leaf is a terminus" if fin?
@children[token] ||= s... | true |
8486c97e511b6b906af61a90dc3bdd0df56c445a | Ruby | deebnntt/cartoon-collections-prework | /cartoon_collections.rb | UTF-8 | 661 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)
dwarves.each_with_index do | name, index |
print "#{index + 1}. #{name}"
end
end
def summon_captain_planet(calls)
calls.map do | call |
"#{call.capitalize}!"
end
end
def long_planeteer_calls(calls)
calls.each do | call |
if call.length > 4
return true
els... | true |
b4fc68c1f135de671c6468d3788dc2b02550ad4c | Ruby | jcccf/twitterdc | /lib/twitterdc/rh_outdegree_per_indegree.rb | UTF-8 | 2,538 | 2.765625 | 3 | [] | no_license | require_relative 'twitterdc'
require_relative '../forestlib/processor'
include TwitterDc
include ForestLib
module TwitterDc
module ReciprocityHeuristics
module OutdegreePerIndegreeHelpers
def hlp(e1,e2,type)
e1_out, e2_out, e1_in, e2_in = @outdegrees[e1], @outdegrees[e2], @indegrees[e1], @inde... | true |
f67e30eee7a51aa3794cce21679d032f64866387 | Ruby | chrismarquis/git_practice | /week05/lab/tramlines.rb | UTF-8 | 1,497 | 4.25 | 4 | [] | no_license | ```
lines = ['Gyle Centre', 'Edinburgh Park', 'Murrayfield Stadium', 'Haymarket', 'Princes Street']
```
#1. Work out how many stops there are in the current west array
lines.count
lines.length
lines.empty? #returns FALSE
#2. Return 'Edinburgh Park' from the array
lines[1]
lines.include?("Edinburgh Park") #returns... | true |
7bf0579867e2634e397b19e92265db6a24bbda09 | Ruby | jzaleski/hijack | /app/helpers/highlights_helper.rb | UTF-8 | 2,016 | 2.59375 | 3 | [] | no_license | class HighlightsHelper
def initialize(config)
@config = config
end
def process(line)
line.dup.tap do |str|
compiled_patterns_and_opts.each do |pattern, opts|
str.gsub!(pattern) do |value|
template % opts.merge(:value => value)
end
end
end
end
private
def ... | true |
159a223ba135167b1cc1fd6f60203d25d2580fd1 | Ruby | jaggerkyne/gotealeaf | /pre/loop_ex2.rb | UTF-8 | 157 | 3.703125 | 4 | [] | no_license | #loop_ex2.rb
def stop(input)
while input != "Stop" do
puts "Something Interesting"
input = gets.chomp
end
end
input = gets.chomp
stop(input) | true |
eab9bcfb6a2ee5023d0bea1a9815f4f75beeb5ad | Ruby | Mark-Boyle/poker_game | /lib/round.rb | UTF-8 | 1,608 | 3.53125 | 4 | [] | no_license | require_relative './player'
require_relative 'play'
class Round
attr_accessor :round_number, :pot, :highest_bet
def initialize
@round_number = 1
@pot = 0
@highest_bet = 0
@common_cards = []
@used_cards = []
end
def select_card
suit = ['Heart', 'Diamond',... | true |
50fe3139e832fe2c482b2eef2dce833ce54cb183 | Ruby | jruby/activerecord-jdbc-adapter | /lib/arjdbc/jdbc/extension.rb | UTF-8 | 1,946 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
module ArJdbc
# Defines an AR-JDBC extension. An extension consists of a declaration using
# this method and an ArJdbc::XYZ module that contains implementation and
# overrides for methods in ActiveRecord::ConnectionAdapters::AbstractAdapter.
# When you declare your extension, you... | true |
f30a6d96bdd044120ffabb5834090c40b43029aa | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/combine_anagrams_latest/3571.rb | UTF-8 | 177 | 3.09375 | 3 | [] | no_license |
def combine_anagrams(words)
res = {};
words.each {
|w|
k = w.downcase.chars.sort.join;
res[k] = res[k].to_a.push(w)
}
return res.values
end
| true |
ed3231604e18f13f26555fb88f2705231b8a0218 | Ruby | rhomobile/rhodes | /lib/extensions/rexml/rexml/encodings/UNILE.rb | UTF-8 | 746 | 2.5625 | 3 | [
"MIT"
] | permissive | module REXML
module Encoding
def encode_unile content
array_utf8 = content.unpack("U*")
array_enc = []
array_utf8.each do |num|
if ((num>>16) > 0)
array_enc << ??
array_enc << 0
else
array_enc << (num & 0xFF)
array_enc << (num >> 8)
... | true |
36db4f1ae1414aabb3e981f51da4e76bad377e36 | Ruby | MattSHeil/Iron_Hack | /week_2/blog/app.rb | UTF-8 | 876 | 2.828125 | 3 | [] | no_license | require_relative('lib/blog')
require_relative('lib/post')
post_1 = Post.new("Welcome to blog", Time.new(2001), "please, blablablablablablablablablabla")
post_2 = SponsorPost.new("doing as I go along", Time.new(2002), "make it stop, huahuahuahuahuahuahuahuahuahu")
post_3 = Post.new("I have barely any idea what im doing... | true |
434dde45b133f396b8645e6c459799737c8d5ab4 | Ruby | schallert/pinstopaper | /lib/instapaper.rb | UTF-8 | 591 | 2.671875 | 3 | [] | no_license | require 'faraday'
module Instapaper
class InstapaperClient
attr_accessor :username, :password
def initialize (username, password)
@conn = Faraday.new(:url => 'https://www.instapaper.com/api/')
@conn.basic_auth(username, password)
self.username = username
self.password = password
... | true |
4ef5ec240d45b22c6b769d2a931079329e4a705d | Ruby | Wen-Xiu/optimal_hotel | /lib/input_process.rb | UTF-8 | 662 | 3.21875 | 3 | [] | no_license | class InputProcess
# attr_reader :cutomer_type, :dates
def initialize input
# require 'pry';binding.pry
input_parse = split_input_by_colon input
@customer_type = return_customer_type input_parse
@dates = return_dates input_parse
end
def customer_type
@customer_type
end
def dates
@d... | true |
037286e792d64eb2d3e098c0c6ba96b6d6d8e903 | Ruby | sooo-s/AtCoder | /abc147/b/main.rb | UTF-8 | 317 | 3.015625 | 3 | [] | no_license | s = gets.chomp.to_s
l = s.size
if l == 1
p 0
else
if l.even?
s_front = s[0..l/2-1]
s_back = s[l/2..l].reverse
else
s_front = s[0..l/2-1]
s_back = s[l/2+1..l].reverse
end
count = 0
s_front.split("").each.with_index do |v,i|
count += 1 if s_front[i] != s_back[i]
end
p count
end
| true |
7d41e2ced1d581e99ef214d51ad9a23db406fa0c | Ruby | kumarsiva07/file_upload | /app/app/models/user.rb | UTF-8 | 607 | 2.578125 | 3 | [] | no_license | class User < Mysql::Base
attr_accessor :id, :name, :email, :updated_at, :created_at
def save
q = if id.nil?
"INSERT INTO users (name, email, created_at, updated_at) VALUES ('#{name}', '#{email}', '#{Time.now}', '#{Time.now}')"
else
"UPDATE users SET name = '#{name}', em... | true |
87d60fb696008e1879276edf82fba11935e567ff | Ruby | ecoffey/pair-prompt | /pair_abbrev_from_email.rb | UTF-8 | 360 | 2.75 | 3 | [] | no_license | email = ARGV[0]
user = email.split('@')[0]
users = user.split('+')
if users[0] == 'pair'
users.shift
end
abbrevs = []
File.open('.pairs', 'r') do |pairs_file|
pairs_file.each do |line|
users.each do |name|
if m = line.match(/^\s*(\w+):\s.*;\s#{name}$/)
abbrevs.push(m[1])
end
end
en... | true |
991f62a5d85e872cc9c72e486df960e4a1a0bf69 | Ruby | cmaher92/launch_school | /coursework/rb129/topics/test.rb | UTF-8 | 167 | 3.21875 | 3 | [] | no_license | class Person
@@number_of_people = 0
def test
puts @@number_of_people
end
def self.test
puts @@number_of_people
end
end
Person.test
Person.new.test
| true |
d7a774f826935f1a7cadbb50f82a7b4c11fcafc0 | Ruby | jbobrowicz/Pearson | /lib/median_function.rb | UTF-8 | 88 | 2.75 | 3 | [] | no_license | class MedianFunction
def apply(numbers)
[numbers.sort[numbers.size/2]]
end
end
| true |
d75b149647b0ea0d04b621de951c8fd14a4fae7f | Ruby | younjiwoo/keydr | /db/seeds.rb | UTF-8 | 1,449 | 2.578125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
14946943ee4e8d22954502571ba850e586cc8486 | Ruby | michalszarejko/rubycourse | /section 3/object_methods_with_parameters.rb | UTF-8 | 181 | 3.046875 | 3 | [] | no_license |
p 20.between?(1, 25)
p 10.between?(1, 5)
p 1.2.between?(1, 5)
p 1.2.between?(0.5, 0.7)
# .between?(min, max), .between?(5, 10)
# (min, max) -> parameters
# (5, 10) - > arguments
| true |
d9af17cfec4a501b2284c9d10418a28221a79296 | Ruby | catherinemdean15/backend_mod_1_prework | /day_4/exercises/ex21.rb | UTF-8 | 1,147 | 4.375 | 4 | [] | no_license | def add(a, b)
puts "ADDING #{a} + #{b}"
return a + b
end
def subtract(a, b)
puts "SUBTRACTING #{a} - #{b}"
return a - b
end
def multiply(a, b)
puts "MULTIPLYING #{a} * #{b}"
return a * b
end
def divide(a, b)
puts "DIVIDING #{a} / #{b}"
return a / b
end
puts "Let's do some math with just functions!"... | true |
12e85a475df2dfd34d9589feb4d8b6f51e96536f | Ruby | oscarock/ruby-retos | /retos/20-un-auto.rb | UTF-8 | 940 | 4.03125 | 4 | [] | no_license | # escribir una clase llamada Car que se comporte como un auto
# simplificado que nos permita acelerar, frenar y obtener
# su velocidad actual.
# car = Car.new
# car.velocity # => 0
# car.accelerate
# car.velocity # => 1
# car.accelerate(2)
# car.velocity # => 3
# car.brake
# car.velocity # => 2
# car.brake(2)
# ... | true |
5eb9447411a8d88371bcf02fc279de2b9ed183b6 | Ruby | changx/grocer | /lib/grocer/pusher.rb | UTF-8 | 1,912 | 2.6875 | 3 | [
"MIT"
] | permissive | module Grocer
class Pusher
def initialize(connection, options={})
@connection = connection
@previous_notifications = Grocer::History.new(size: options[:history_size])
@resend_on_not_found = options[:resend_on_not_found] || false
end
def push(notification)
remember_notification(not... | true |
f6022ce0131f2f1e0440d5d802c5d006531c2ecd | Ruby | sg552/auto_cart_backend | /lib/html_parser.rb | UTF-8 | 3,567 | 2.625 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
require 'nokogiri'
class HtmlParser
attr_accessor :page, :details_table, :price_table, :add_to_cart_button, :notebooks,
:parser_id
def initialize html_content, options = {}
@parser_id = Time.now.to_s
@page = get_content_with_pure_html html_content
item_descriptions = @pa... | true |
6559582b187c34b1be4b29f62c7b5e502743537c | Ruby | iamm28/alphabetize-in-esperanto-prework | /lib/alphabetize.rb | UTF-8 | 276 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def alphabetize(arr)
esp_hash = {}
count = 1
esp = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz".split('').each do |letter|
esp_hash[letter] = count
count += 1
end
arr.sort_by do |phrase|
phrase.split('').map do |letter|
esp_hash[letter]
end
end
end
| true |
b8bf93839c8d333da1bd222b270fe6a7585ebafd | Ruby | kruszczynski/ruby_features_test_code | /ruby_features/kwargs.rb | UTF-8 | 2,073 | 3.640625 | 4 | [] | no_license | # Keyword arguments cannot be filled positionally:
def m(foo: 1, bar: 2)
[foo, bar]
end
method(:m).parameters # => [[:key, :foo], [:key, :bar]]
m # => [1, 2]
m(1, 2) rescue $! # => ArgumentError
m(foo: 2) # => [2, 2]
m(bar: 1) # => [1, 1]
m(foo: 3, bar: 3) # => [3, 3]
# The next version of Ruby will allow mandatory... | true |
2394b924f3894cc9d60909ab8e8013d00c94248d | Ruby | jgsmith/ruby-second-contract | /test/models/item_tests.rb | UTF-8 | 6,315 | 2.546875 | 3 | [] | no_license | require 'second-contract/parser/script'
require 'second-contract/model/archetype'
require 'second-contract/model/item'
require 'second-contract/iflib/sys/binder'
describe Item do
subject(:parser) { SecondContract::Parser::Script.new }
describe "basic construction" do
let(:parse) {
p = parser.parse_... | true |
3ade95a7d78596dfa42deebd8451927f3b7b4fcb | Ruby | kipcole9/calendrical-ruby | /lib/calendrical/calendars/iso/day.rb | UTF-8 | 1,924 | 2.96875 | 3 | [
"MIT"
] | permissive | module Calendar
module Iso
class Date < Calendrical::Calendar
Date = Struct.new(:year, :week, :day)
delegate :year, :week, :day, to: :elements
include Calendrical::Ecclesiastical
include Calendrical::Kday
include Calendrical::Dates
def initialize(*args)
super
... | true |
97a6fb40d623185b4c405c9b85f3a67b595ba5b9 | Ruby | darshan405/ruby_questions_set_1 | /encapsulation/encap.rb | UTF-8 | 2,919 | 4 | 4 | [] | no_license | # The client wants to implement a chat application.
# The application consists of three type of messages
# 1. groupMessage --> Anybody can send a message to this group.
# 2. personalChat --> Message can be sent by client through the user only.
# 3. secureChat --> Since this is a confidentials message it should not ... | true |
4f569c421afe6fade5ce846d554202c8413f0785 | Ruby | yellowpad/oo-banking-web-0217 | /lib/transfer.rb | UTF-8 | 1,420 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Transfer
attr_reader(:name)
attr_accessor(:sender, :receiver, :status, :amount)
def initialize(sender, receiver, status="pending", amount)
@sender = sender
@receiver = receiver
@status = status
@amount = amount
end
def valid?
#check valid method form BankAccount class for each new instance
... | true |
425ecaec826005d0fcb08bdcc813f86e1259922c | Ruby | Felipeandres11/desafioruby1 | /CLASES/POO/circulo.rb | UTF-8 | 212 | 3.6875 | 4 | [] | no_license | class Circle
attr_accessor :radius
def initialize
@radius = 1
end
def bigger
self.radius = radius + 1
end
def to_s
"Circulo de radio #{@radius}"
end
end
c = Circle.new
puts c.bigger
| true |
b40ca232e52b354714852f2c35c54dd32dcff8e8 | Ruby | krzyzak/sub_converter | /test/movie_time_test.rb | UTF-8 | 776 | 3.046875 | 3 | [
"MIT"
] | permissive | class MovieTimeTest < MiniTest::Test
def setup
@time = SubConverter::MovieTime.new("22.34")
end
def test_returns_seconds
assert_equal "22", @time.seconds
end
def test_returns_miliseconds
assert_equal "034", @time.miliseconds
end
def test_returns_seconds_with_miliseconds
assert_equal "22... | true |
d7d63a6883e964b9c1d8ed8ad57f05528e9cf555 | Ruby | vwhwang/ride-share-rails | /app/models/driver.rb | UTF-8 | 608 | 3.140625 | 3 | [] | no_license | class Driver < ApplicationRecord
has_many :trips
validates :name, presence: true
validates :vin, presence: true
def average_rating
total_rating = 0.00
count = 0
return total_rating if self.trips == []
self.trips.each do |trip|
if trip.rating
total_rating += trip.rating
cou... | true |
6eb510a627b6357f875a3ce900d5961aff3032c8 | Ruby | cmaher92/launch_school | /exercises/review/procedural_fib.rb | UTF-8 | 1,627 | 4.3125 | 4 | [] | no_license | require 'pry'
require 'minitest/autorun'
# DETAILS
# Input: integer; 'nth'; the position to calculate fibonacci to
# Output: integer; the result for the 'nth' number in the fibonacci sequence
# Requirements:
# - non-recursive (compute without using recursion)
# EXAMPLES
#
# DATA STRUCTURE
# - hash, each key is the p... | true |
a7cccab885b0a9310e11ad601d7aef3e14f11906 | Ruby | aquach/poe-css | /lib/poe-css/simplifier.rb | UTF-8 | 6,634 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module POECSS
module Simplifier
RARITY_TO_NUMBER = { 'Normal' => 0, 'Magic' => 1, 'Rare' => 2, 'Unique' => 3 }
NUMBER_TO_RARITY = RARITY_TO_NUMBER.invert
class << self
# Removes impossible matches, duplicate matches, and duplicate commands.
def simplify_clause(c... | true |
e82c8bcdbd194f96e16379f91b5c9fa675fe93b2 | Ruby | polypressure/gcx | /lib/gcx/model_store.rb | UTF-8 | 1,625 | 2.65625 | 3 | [
"MIT"
] | permissive | #
# Wrapper for key-value store.
#
# Out-of-the-box, this just uses an in-memory backend (a hash),
# but alternate backends can be configured (filesystem,
# relational/ORM, NoSQL, etc.) as specified by the Moneta gem.
# See https://github.com/minad/moneta
#
# Setting a new key-value store should mostly be transparent,
... | true |
19a2c29a57b78bf493b45c938c144ba02a419695 | Ruby | dkimbel/ar-sunlight-legislators | /lib/sunlight_legislators_importer.rb | UTF-8 | 1,408 | 3.0625 | 3 | [] | no_license | require 'csv'
require_relative '../app/models/congressperson'
require_relative '../app/models/state'
require_relative '../app/models/senator'
require_relative '../app/models/representative'
class SunlightLegislatorsImporter
def self.import(filename)
csv = CSV.new(File.open(filename), :headers => true)
csv.ea... | true |
36591cb44f66d580943d7ee681f6af44ec5df673 | Ruby | ggarra13/getopt-declare | /test/test_cmdline_regex.rb | UTF-8 | 1,872 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'test/unit'
require "Getopt/Declare"
# to avoid getopt from exiting...
def exit(args)
end
class TC_Regex < Test::Unit::TestCase
def setup
@args = Getopt::Declare.new(<<'EOPARAM', :build)
-ar <r:n> Set aspect ratio (will be clipped to [0..1] )
{
r = 0 if r < ... | true |
08ceeb5b7a6ed6e4e17fc833329f44f57b2e8a14 | Ruby | copley/ruby-bits-pt-1 | /level_1.rb | UTF-8 | 1,686 | 3.078125 | 3 | [
"MIT"
] | permissive | #Full Unless Statement
#unless games.empty?
# puts "Games in your vast collection: #{games.count}"
#end
#Single Line Unless Statement
#puts "Games in your vast collection: #{games.count}" unless games.empty?
#Implied Nil
#search_index = games.find_index(search)
#if search_index
# puts "Game #{search} Found: #{games... | true |
c37cad01865d7199c9a6b7e3a393d5032d587fe5 | Ruby | Bago213/beryexchange | /vendor/bundle/ruby/2.2.0/gems/doorkeeper-1.4.1/lib/doorkeeper/models/expirable.rb | UTF-8 | 480 | 2.625 | 3 | [
"MIT"
] | permissive | module Doorkeeper
module Models
module Expirable
def expired?
expires_in && Time.now > expired_time
end
def expired_time
created_at + expires_in.seconds
end
def expires_in_seconds
return nil if expires_in.nil?
expires = (created_at + expires_in.secon... | true |
a61cd36f5601161c088562570db4824d36c7aba4 | Ruby | miroku555/orca-api-samples | /sample_patient_shimei_list_v2.rb | UTF-8 | 1,657 | 2.671875 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
#------ 患者番号一覧取得
require 'crack' # for xml and json
require 'crack/xml' # for just xml
require 'uri'
require 'net/http'
Net::HTTP.version_1_2
HOST = "192.168.4.123"
PORT = "8000"
USER = "ormaster"
PASSWD = "ormaster123"
CONTENT_TYPE = "application/xml"
req = Net::HTTP::Post... | true |
f342aedc3169d4eb8292c30cc87f522b134c7467 | Ruby | mfine/fernet | /lib/fernet/encryption.rb | UTF-8 | 677 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'openssl'
module Fernet
module Encryption
AES_BLOCK_SIZE = 16.freeze
def self.encrypt(opts)
cipher = OpenSSL::Cipher.new('AES-128-CBC')
cipher.encrypt
iv = opts[:iv] || cipher.random_iv
cipher.iv = iv
cipher.key = opts[:key]
[cipher.update(opts[:message]) + ciph... | true |
a282939bcb152950233154778e0e4f3f55cb7a4f | Ruby | Mattmont415/Command-Line-Chess-Ruby | /chess.rb | UTF-8 | 37,066 | 3.578125 | 4 | [] | no_license | class Chess
def initialize
#White pieces as instance constants
@WP = "♙"; @WB = "♗"; @WK = "♘"; @WR = "♖"; @WQ = "♕"; @WKg = "♔"
#Black pieces as instance constants
@BP = "♟︎"; @BB = "♝"; @BK = "♞"; @BR = "♜"; @BQ = "♛"; @BKg = "♚"
#Arrays keeping track of captured pieces
@white_piece = []
... | true |
ce35aaeb26dee3959925aaa41ed41dd9cca70a65 | Ruby | sbcn7/atcoder-by-ruby | /abc006/A.rb | UTF-8 | 90 | 3 | 3 | [] | no_license | # http://abc006.contest.atcoder.jp/tasks/abc006_1
puts gets.to_i % 3 == 0 ? 'YES' : 'NO'
| true |
149f667edea804e849090f60517c47ad8fb96625 | Ruby | marten/pavlov | /spec/pavlov/operation_spec.rb | UTF-8 | 3,714 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'pavlov'
describe Pavlov::Operation do
describe '#initialize' do
it "calls validate if it exists" do
dummy_class = Class.new do
include Pavlov::Operation
def validate
@x_val = :validate_was_called
end
def validate_was_called
@x_val
end
... | true |
7950244d2803ba82e56ee02c74836274a1a88fb6 | Ruby | kunosu/twitter_bot | /main.rb | UTF-8 | 1,015 | 2.765625 | 3 | [] | no_license | require 'twitter'
require 'time'
require_relative './lib/Twitter.rb'
#----------------------------------------------------
# 定数
#----------------------------------------------------
#----------------------------------------------------
# ヘッダとフッター
#----------------------------------------------------
... | true |
afe37a5f426034c9f0496c135bfbb69bc2645b9d | Ruby | raonibr/graphtube | /pessoa.rb | UTF-8 | 2,539 | 3.28125 | 3 | [] | no_license | =begin
---------------------
Modelo de pessoa
Ao criar uma pessoa, passar parametros:
nova_pessoa = Pessoa.new(interview_id, cidade_entrevista, bairro_entrevista, endereco_entrevista, locais_moradia, locais_trabalho, locais_estudo, locais_lazer)
---------------------
=end
# ESTRUTURA DOS VETORES DE LOCAIS:
# LOCAIS ... | true |
a304f0aaddf27d10707f0afa163a9a5b2d78534d | Ruby | Arkion-Security/spoofy | /spoofy.rb | UTF-8 | 1,292 | 2.796875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require 'optimist'
require 'net/smtp'
##################################--- Menu ---##################################
opts = Optimist::options do
opt :usage, "ruby spoofy.rb -e email.html -s sender@email.com -n 'Sender Name' -t targets.txt -b 'Email Subject' ", :type => :string
opt :emailfile, "HTML ... | true |
d8a9704768b4336bb3241be4bdf4c1babdb2f43a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/fc8028700e5f4d02a283eda327b28e3b.rb | UTF-8 | 274 | 3.390625 | 3 | [] | no_license | class Phrase
WORD = /(\w+)/
def initialize(words)
@normalized_words = words.scan(WORD).flatten.map(&:downcase)
end
def word_count
@normalized_words.inject(Hash.new(0)) do |frequencies, word|
frequencies[word] += 1
frequencies
end
end
end
| true |
de087246e3282445fde2aaab78927457ab426108 | Ruby | EdwinHongCheng/aAClasswork | /W4D2/02_chess_part_one/pieces.rb | UTF-8 | 1,226 | 3.546875 | 4 | [] | no_license | require "singleton"
class Piece
attr_reader :color, :pos
def initialize(color, board, pos)
@color = color
@board = board
@pos = pos
end
def to_s
@color + self.to_s
end
def empty? # if this is a null piece or not (false if not a Null piece)
self.is_a?(... | true |
00d412bec14a33399c966f54308993d99e87b007 | Ruby | Forinil/split_files | /file_processor.rb | UTF-8 | 2,427 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | require 'English'
require_relative 'custom_logger'
# Class FileProcessor - processes a single file
class FileProcessor
def self.process_file(logger, path, max_size, result_path)
logger.log(Logger::INFO,
"Processing file: #{path}, maximum size: #{max_size} B",
'FileProcessor.process_... | true |
318741d6ef367be0c665966a22a380feff769044 | Ruby | keigo-brook/Atcoder | /ARC/arc045/a.rb | UTF-8 | 184 | 2.96875 | 3 | [] | no_license | a = gets.split(' ')
ans = ''
a.each do |aa|
if aa == 'Left'
ans += '< '
elsif aa == 'Right'
ans += '> '
else
ans += 'A '
end
end
puts ans.strip | true |
c5651b9bd6cc90e6ef6bc4a616e92632f29bb692 | Ruby | WorstOfAny/cartesian_for_geo | /spec/polygons_collection_spec.rb | UTF-8 | 1,823 | 2.53125 | 3 | [
"MIT"
] | permissive | RSpec.describe CartesianForGeo::PolygonsCollection do
describe '#<<' do
before(:example) do
@collection = described_class.new
@first_polygon =
CFG::Polygon.new(
CFG::Vector[CFG::Point[1.0, 1.0], CFG::Point[6.0, 7.0]],
CFG::Vector[CFG::Point[6.0, 7.0], CFG::Point[3.0, 9.0]],
CFG::Vector[CFG:... | true |
c574efdc207a522e51ff47831e28ddc378af3323 | Ruby | spike886/10pines | /lib/buy_transaction.rb | UTF-8 | 153 | 2.53125 | 3 | [] | no_license | require "transaction"
class BuyTransaction < Transaction
def initialize share, day, price, quantity
super share, day, price, quantity
end
end | true |
05dbba5a2bd8b1fb9bb4d6845f13c6c5d5b701ba | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/8f65ed91eb134b3da740e417fc81a9f4.rb | UTF-8 | 453 | 3.828125 | 4 | [] | no_license | class Bob
def hey(talk)
if is_speech_empty?(talk)
"Fine. Be that way!"
elsif is_speech_shout?(talk)
"Woah, chill out!"
elsif is_speech_question?(talk)
"Sure."
else
"Whatever."
end
end
private
def is_speech_empty?(talk)
talk.to_s.strip.empty?
end
private
d... | true |
f0eb503077e075616e0cfaa53711357d6aa4cd8a | Ruby | dxw/verify_vsp_client | /lib/verify_vsp_client/service_provider.rb | UTF-8 | 3,181 | 2.5625 | 3 | [
"MIT"
] | permissive | require "net/http"
module VerifyVspClient
# Interface for interacting with an instance of a Verify Service Provider.
#
# Make sure the VSP host is configured, for example:
#
# VerifyVspClient.configuration.vsp_host= "https://vsp.host:50300"
class ServiceProvider
def self.generate_request_url
"#... | true |
db9833fc5db56722eb151daba8ffe7f39ec5ca16 | Ruby | sarahbkim/jmeter_rake | /rakefile | UTF-8 | 2,429 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rake'
require 'json'
require 'optparse'
URLS = []
JMETER_FILE = 'jmeter.rb'
task :run do |t, args|
options = {
host: 'http://localhost:10003',
number: 10,
file: '',
}
o = OptionParser.new
o.banner = "Usage: rake run [options]"
o.on('-h HOST', '--host HOST') { |host... | true |
8c24adb58b8561eb54c18d0bbafe29ca35d51d12 | Ruby | kerryb/minisculus | /brute_force.rb | UTF-8 | 495 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env ruby
require "rubygems"
$:.unshift File.expand_path("../lib", __FILE__)
require "question_source"
require "decoder"
print "Enter encoded text: "
code = gets.chomp
possibilities = []
(0..9).each do |wheel_1_position|
(0..9).each do |wheel_2_position|
decoder = Decoder.new wheel_1_position, wheel... | true |
49ce10ee34e3f3f3ea2b0e3bf4a0bac30ff5c36f | Ruby | lost-in-Code-au/e13_documents | /Resouce_Files/Ruby run test script/app.rb | UTF-8 | 1,200 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'fileutils'
def filter_directories
excluded_directories = ["bin"]
all_files = Dir.glob('*')
return all_files.select do |file|
next if excluded_directories.include?(file)
File.directory?(file)
end
end
def create_bin
FileUtils.rm_rf('bin')
FileUtils.mkdir_p('bin')
end
def build(directori... | true |
0869302dcfde07ab6b58a88c48a386179ab2c333 | Ruby | kotarou1192/0x-game | /main.rb | UTF-8 | 744 | 3.78125 | 4 | [] | no_license | require './game.rb'
game_mode = 0
difficulty = 0
order_to_attack = 0
puts 'choose game mode. 1: human vs human, 2: cpu vs human, 3: cpu vs cpu'
loop do
game_mode = gets.to_i
break if game_mode == 1 || game_mode == 2 || game_mode == 3
puts 'input again'
end
puts ' choose difficulty. 1 is hard. 2 is easy'
loop ... | true |
a77dd325c3003384d8976e0ac55c06eeccd26333 | Ruby | dholst/whatsmysprint-ios | /app/models/sprint.rb | UTF-8 | 1,195 | 2.890625 | 3 | [] | no_license | class Sprint
include Model
attr_accessor :name, :start, :end
def self.current(success, failure)
BW::HTTP.get('http://still-atoll-1597.herokuapp.com/sprint/current', {:headers => {"Accept" => "application/json"}}) do |response|
if(response.status_code == 200)
success.call Sprint.new(BW::JSON.pa... | true |
c8ce3d56ed52d4c2ba9d89361209d8e25ae66129 | Ruby | RodolfoPena/E7CP1A1 | /ejercicio2.rb | UTF-8 | 488 | 3.234375 | 3 | [] | no_license | puts "Parte 1"
productos = {'bebida' => 850, 'chocolate' => 1200, 'galletas' => 900, 'leche' => 750}
productos.each { |producto, valor| puts producto }
puts "Parte 2"
productos["cereal"] = 2200
print productos
puts ""
puts "Parte 3"
productos["bebida"] = 2000
print productos
puts ""
puts "Parte 4"
array = productos.to_... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.