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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38016b6becfd8f47efe4d9a04243cda9daa86671 | Ruby | small-ing/ruby-blockchain | /testrun.rb | UTF-8 | 572 | 2.703125 | 3 | [] | no_license | require_relative 'blockchain'
bc = Blockchain.new
tr1 = { 'sender' => 'me', 'receiver' => 'also me', 'value' => 'nothing' }
tr2 = { 'sender' => 'me', 'receiver' => 'me', 'value' => 'nothing' }
tr3 = { 'sender' => 'me', 'receiver' => 'me again', 'value' => 'nothing' }
tr4 = { 'sender' => 'me', 'receiver' => 'yo... | true |
eb2f68b33cf166fb276db2b087fb72c29d9460f9 | Ruby | krislitman/black_thursday | /lib/item_repo.rb | UTF-8 | 2,381 | 2.90625 | 3 | [] | no_license | require_relative 'csv_generator'
class ItemRepo
include CsvGenerator
attr_reader :item_list
def initialize(csv_data, sales_engine)
@sales_engine = sales_engine
make_items(csv_data)
end
def find_merchant_by_id(merchant_id)
@sales_engine.find_merchant_by_merchant_id(merchant_id)
end
def all
... | true |
449dff49a58c7a56f15ac3523977018df6a11cf1 | Ruby | marquesavery/key-for-min-value-online-web-sp-000 | /key_for_min.rb | UTF-8 | 351 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
require 'pry'
def key_for_min_value(name_hash)
if name_hash.empty?
return nil
end
n = ""
v = 1000
name_hash.each do |key, value|
# binding.pry
if value < v
n = key
v... | true |
33bcc09dc46eca442d19afc91687b672afb42c8b | Ruby | lancelot2/songkick_bot_2 | /app/bot/Structured messages/template/receipt.rb | UTF-8 | 2,806 | 2.6875 | 3 | [] | no_license | class ReceiptTemplate
def initialize(recipient_name='', order_number='', currency='', payment_method='', timestamp='', order_url='')
@template = {
'attachment': {
'type': 'template',
'payload': {
'template_type': 'receipt',
'recipient_name': '',
... | true |
685bb0edfee43aabd2ea6375a742ea40528373db | Ruby | nathanworden/LeetCode | /Interview Cake/35.binary_search_tree_checker.rb | UTF-8 | 4,619 | 3.609375 | 4 | [] | no_license | # def binary_search_tree?(root)
# node_and_bounds_stack = []
# node_and_bounds_stack << [root, -Float::INFINITY, Float::INFINITY]
# until node_and_bounds_stack.empty?
# node, lower_bound, upper_bound = node_and_bounds_stack.pop
# return false if node.value <= lower_bound || node.value >= upper_bound
# ... | true |
a03bb7389eacba5cd0715e14473ab2676cbdff62 | Ruby | Slothra/ORM | /application.rb | UTF-8 | 2,353 | 3.609375 | 4 | [] | no_license | class Application
def initialize
@arg1=''
end
def self.get(string)
puts "Please enter the #{string}:"
STDIN.gets.chomp
end
def self.clear
@arg1=''
end
def self.finder
puts "Find by first name, surname, or id?"
input = STDIN.gets.chomp
case input
when "first name"
input = get("first_name"... | true |
f6e50aafe4fcb787f119e3e1fffde7e5eb12f9ad | Ruby | chrisdziewa/tic_tac_toe | /game_engine.rb | UTF-8 | 4,895 | 3.65625 | 4 | [] | no_license | class GameEngine
attr_reader :game_board, :player1, :player2
attr_accessor :current_player
def initialize(params)
@game_board = params[:game_board]
puts intro
@player1 = params[:player1]
@player2 = params[:player2]
add_players
@current_player = @player1
... | true |
5adcc217932b7c7fd2c2c5a0606863ed3961d878 | Ruby | deansullivan/Binary_Search_Tree | /balancedBST.rb | UTF-8 | 5,443 | 3.640625 | 4 | [] | no_license | class Node
attr_accessor :left_child, :right_child, :data
def initialize(data)
@data = data
@left_child = nil
@right_child = nil
end
end
class Tree
attr_accessor :root
def initialize(array) # Constructs a balanced search tree from an array
@root = buil... | true |
5ec5d032e67641a457b95bfeb50e2bea66ea05a8 | Ruby | RheaHewett/Ruby-Coding | /Taboo.rb | UTF-8 | 2,116 | 4.21875 | 4 | [] | no_license | $words = {
:animals=>["dog","cat","pet", "walk", "park"],
:meals=>["eat","breakfast", "lunch", "dinner", "food"],
:school=> ["pencil", "learn", "kids", "students", "education"],
:sports=>["play", "activities", "soccer","exercize","football"],
:skiing=>["skis", "snow", "chairlift", "mountains","cold"]
} #These... | true |
8df23fc150874cdadc147bcaba3321c501ad18fb | Ruby | StevenACZ/exercism-StevenACZ | /ruby/series/series.rb | UTF-8 | 416 | 3.8125 | 4 | [] | no_license | =begin
Write your code for the 'Series' exercise in this file. Make the tests in
`series_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/series` directory.
=end
class Series
def initialize(string_num)
@string_num = string_num.chars
end
def slices(n_times)
raise ArgumentEr... | true |
db89ebf28e5c2dc020567d69b7982bc2aa17b036 | Ruby | triton11/PaceMakerData | /app/controllers/home_controller.rb | UTF-8 | 919 | 2.578125 | 3 | [] | no_license | class HomeController < ApplicationController
def index
@pacemaker = Pacemaker.all.first
puts(@pacemaker)
puts("HELLO")
if @pacemaker == nil
@pacemaker = Pacemaker.new()
end
@data = @pacemaker.datapoints.all
#puts(@data.first.recieved_at)
end
def addPoint
@pacemaker = Pacemaker.all.first
puts(pa... | true |
697743a06d5ab6d4fb0077b73e7c9f2ca2b67d91 | Ruby | iezer/progkb | /ruby/private_protected.rb | UTF-8 | 431 | 4.0625 | 4 | [] | no_license | # http://matthodan.com/2010/08/08/ruby-private-methods-vs-protected-methods.html
class Parent
protected
def name
'Mommy'
end
end
class Child < Parent
def get_parent_name
# Implicit receiver
puts name
# Explicit receiver
puts self.name rescue puts 'NoMethodError'
# Explicit receiver
... | true |
f74fb3accb3f20adea4558ba3d751709a9704ce7 | Ruby | mdorrance/web_guesser | /web_guesser.rb | UTF-8 | 995 | 3.09375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
SECRET_NUMBER = rand(100)
before do
def check_guess(guess)
if guess.to_i == 0
""
elsif guess.to_i == SECRET_NUMBER
"You got it right! The SECRET NUMBER is #{SECRET_NUMBER}"
elsif guess.to_i > (SECRET_NUMBER + 5)
"Way too high!"
elsif guess.to_i > S... | true |
69a3e9fc2834accf1a6b91be689ee91325cb315f | Ruby | MGonzales26/backend_mod_1_prework | /day_6/exercises/person.rb | UTF-8 | 662 | 4.625 | 5 | [] | no_license | # Create a person class with at least 2 attributes and 2 behaviors.
# Call all person methods below the class and print results
# to the terminal that show the methods in action.
# YOUR CODE HERE
class Person
attr_reader :name, :age, :tired, :hand_up
def initialize(name, age)
@name = name
@age = age
... | true |
bb1512fca1409690784fc5078c626364f3dcfbc0 | Ruby | madhavhugar/ruby-101 | /classes/class_accessors_shorthand.rb | UTF-8 | 626 | 3.5625 | 4 | [] | no_license | class Home
attr_reader :name, :city, :year_built # only get accessors
attr_writer :name # only write accessors
attr_accessor :renovated_on # read and write accessors
def initialize(name, city, year_built)
@name = name
@city = city
@year_built = year_built
@renovated_on = year_built
end
end
m... | true |
55aa53510f72119e300140bd86407292aed5bccc | Ruby | resque/resque | /lib/resque/vendor/utf8_util.rb | UTF-8 | 660 | 3.03125 | 3 | [
"MIT"
] | permissive | module UTF8Util
# use '?' intsead of the unicode replace char, since that is 3 bytes
# and can increase the string size if it's done a lot
REPLACEMENT_CHAR = "?"
# Replace invalid UTF-8 character sequences with a replacement character
#
# Returns self as valid UTF-8.
def self.clean!(str)
return str i... | true |
b2db1f559283871d8cfe05673b4c3fb1a25b911b | Ruby | codahale/mook | /lib/mook/page.rb | UTF-8 | 920 | 2.765625 | 3 | [
"MIT"
] | permissive | class Page
METADATA = %w{ title template order }
def self.load(filename)
lines = File.read(filename)
m, markdown = lines.split("* * *\n", 2)
metadata = Hash[*m.split("\n").map { |s| s.split(": ", 2) }.map { |k, v| [k.downcase, v] }.flatten]
raise "#{filename} has no title" unless metadata["t... | true |
e2d69cf535b7e9dcc887b9bfd91d50d665f23248 | Ruby | layoel/Civitas | /CivitasR/lib/civitas/casilla_juez.rb | UTF-8 | 1,144 | 2.828125 | 3 | [] | no_license | # To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
require_relative "casilla.rb"
#require "byebug"
module Civitas
class CasillaJuez < Casilla
# /**
# * @brief constructor de casill... | true |
4a33a966299539c583b16b71ee447fbf92914554 | Ruby | MatskoVolodia/antigov | /app/services/rsa/key_generator.rb | UTF-8 | 1,461 | 2.78125 | 3 | [] | no_license | module RSA
class KeyGenerator < ::Callable
SERVER_KEY = 8595431517640407292645935890959199917471211616445025379705341641499905883312466079517878672586858130662348331850631026517565012155291134918045134662276099
def call
{
public: user_key * SERVER_KEY,
private_dec: mod_inverse(eule... | true |
9bdd0ced3c689c0054c40a45b338ba8c3cec923c | Ruby | jdeandaortiz/Unidad1 | /SQLite3/sqlite/sqlite_script.rb | UTF-8 | 658 | 3 | 3 | [] | no_license | require 'sqlite3'
require 'awesome_print'
db = SQLite3::Database.new('users.sqlite3')
db.execute <<-SQL
CREATE TABLE IF NOT EXISTS users(name varchar(255), email varchar(255), birth_year int);
SQL
db.execute 'INSERT INTO users(name, email, birth_year) VALUES(?, ?, ?)', ['Jesús Deanda Ortiz', 'jdeandaortiz@gmail.co... | true |
543abfd502ca7e2c15d90d8116f187ebca68649c | Ruby | john-paul-keenan/iron_mq_ruby | /lib/iron_mq/alert.rb | UTF-8 | 898 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | module IronMQ
class Alert
attr_reader :raw
def initialize(queue, alert_hash)
@queue = queue
@raw = alert_hash
end
def id
@raw['id']
end
# alert type
def type
@raw['type']
end
# target queue
def queue
@raw['queue']
end
def trigger
... | true |
90a0afdff4a0822181f833adb9d9e167354677c6 | Ruby | rodacato/wkamole | /lib/api/path_namespace.rb | UTF-8 | 789 | 2.546875 | 3 | [] | no_license | module PathNamespace
def self.extended(base)
base.path_namespace ''
end
def path_namespace(name)
@@path_namespace = "/#{name.gsub(/^\/|\/$/, '')}/"
end
def get(path, opts={}, &bk) super with_namespace(path), opts, &bk end
def put(path, opts={}, &bk) super with_namespace(path), opts, &bk en... | true |
1cabc65b0a1cdc5b4fd4346a1a3a0d89a55579e1 | Ruby | pcyho/codewars-ruby | /strrrrr.rb | UTF-8 | 292 | 3.359375 | 3 | [] | no_license | def filter_list(l)
l.delete_if { |item| item.class == String }
end
p filter_list([1, 2, 3, '323', 12, 'sosf', '11', 34])
def filter_list(l)
l.reject { |x| x.is_a? String }
end
str='sdfsjsfoinsaaoiwen'
p str.scan(/([aeiou])/).length
def getCount(inputStr)
inputStr.count("aeiou")
end | true |
fed2b848e342196cc9ae95c3ab5a69a40712cdda | Ruby | frankmt/asrc_sw_dev | /lrthw/mansoor/Tash Challenges/player.rb | UTF-8 | 249 | 3.21875 | 3 | [] | no_license | require_relative "./dice.rb"
class Player
attr_reader :name
def initialize(name)
@name = name
@latest_roll = 0
end
def take_turn
dice = Dice.new
@latest_roll = dice.roll
end
def latest_roll
@latest_roll
end
end
| true |
840cc01a9d8ef6b48742865327fa25fc2baf73b9 | Ruby | TaizoAyase/LabWikiPublicationUpdator | /article.rb | UTF-8 | 3,166 | 3.140625 | 3 | [] | no_license | #encoding: utf-8
require "ap"
require "bio"
require "yaml"
class Article
attr_reader :pubmedid
def initialize
@year = nil
@pubmedid = nil
@table = {
:t => nil,
:a => nil,
:j => nil,
:v => nil,
:p => nil,
:y => nil,
:i => nil,
:s => nil
}
end
... | true |
d4a6f0c19190d5b51795c08dd7072260fa12ac49 | Ruby | MrMicrowaveOven/AlienCommunique | /image_files/imagify.rb | UTF-8 | 325 | 2.71875 | 3 | [] | no_license | message = File.readlines '../SETI_message.txt'
translation = File.open("translation.txt", "w")
message[0].each_char.with_index do |chr, idx|
puts if idx % 359 == 0
print ((chr === '0') ? ' ' : 'X')
translation.puts if idx % 359 == 0 && idx != 0
translation.print ((chr === '0') ? ' ' : 'X')
end
translation.c... | true |
5049805b985f6e501b9803105e58f5e4fdc84620 | Ruby | wouterken/rulp | /lib/extensions/object_extensions.rb | UTF-8 | 964 | 3.21875 | 3 | [] | no_license | ##
# Object extension to allow numbered LP variables to be initialised dynamically using the following
# syntax.
#
# [Capitalized_varname][lp var type suffix]
#
# Where lp var type suffix is either _b for binary, _i for integer, or _f for float.
# I.e
#
# Rating_i is the equivalent of Rating (type integer)
# Is_happy_b... | true |
6424f90c4515c1160b678195e7e505fa1688774a | Ruby | gesielrios/RR-75 | /spec/support/matchers/calcula.rb | UTF-8 | 433 | 2.890625 | 3 | [] | no_license | module CarroSpec
class Calcula
def initialize(comissao)
@comissao = comissao
end
def matches?(bloco)
bloco.call == @comissao
end
def failure_message_for_should
"valor da comissao não está igual : #{@comissao}"
end
def failure_message_for_should_not
"valor da comi... | true |
2f0c35e5796581add1e27420627a1636e916442e | Ruby | alexpriceprogram/TicTacToe | /tictacattack.rb | UTF-8 | 225 | 3.171875 | 3 | [] | no_license | class Tic
def initialize
@boardArray = [[0,0,0], [0,0,0], [0,0,0]]
end
def printBoard
puts " | | "
puts "---------"
puts " | | "
puts "---------"
puts " | | "
end
end
tack = Tic.new
tack.printBoard | true |
69f860419675a89dc6285e799478af6f6c86f619 | Ruby | roshanakak/TwoPlayerMathGame | /questions.rb | UTF-8 | 252 | 3.390625 | 3 | [] | no_license | class Question
attr_reader :question
attr_reader :answer
def initialize()
first_number = rand(1..20)
second_number = rand(1..20)
@question = "#{first_number} + #{second_number} ?"
@answer = first_number + second_number
end
end | true |
31ba2233d9254502e551250272e24ac12392fcec | Ruby | RavensKrag/ThoughtTrace | /lib/ThoughtTrace/actions/one_shot_action.rb | UTF-8 | 1,565 | 2.71875 | 3 | [] | no_license | # Base for actions that only need to fire once, rather than updating every frame.
module ThoughtTrace
module Actions
class OneShotAction < BaseAction
# don't declare the initialize here, as this is still an abstract class
# ===
# These methods should not be overridden by child classes.
# They exist only a... | true |
b54c3b33b4e1d9f4ac1926a600966e0b61ff7625 | Ruby | Cole-Codes/a-A-Classwork | /Week2/W2D2/Chess (Part One)/piece.rb | UTF-8 | 121 | 2.859375 | 3 | [] | no_license | class Piece
def initialize(symbol, board, pos)
@symbol = symbol
@board = Board.new
@pos = pos
end
end | true |
c2b6fc309c4fc5b7674a5f998229926ca5cca07f | Ruby | sharyanto/scripts | /distance2cities | UTF-8 | 1,185 | 3.359375 | 3 | [] | no_license | #!/usr/bin/ruby
# 040319 - first write. formula didapat dari XXX
# TODO - menggunakan informasi dari www.calle.com yang telah diekstrak ke file /home/steven/e/etc/city-id.txt
Circumference = 40123.648 # km
Deg2Rad = Math::PI / 180.0
def distance2places(lat1, lon1, lat2, lon2) # all in degrees
lat1 *= Deg2Rad; lon1... | true |
6f6031b01f89248061cfd813b59d84c22308deaf | Ruby | zype/zype-gem | /lib/zype/models/video_entitlements.rb | UTF-8 | 586 | 2.609375 | 3 | [
"MIT"
] | permissive | module Zype
# Read more at https://docs.zype.com/v1.0/reference#video-entitlements
#
# @since 0.15.0
class VideoEntitlements < Zype::Base::Consumers
# Checks if the consumer is entitled to watch the video
#
# @param video_id [String] ID of the video
# @param access_token [String] Access token us... | true |
4d72de2a506545e1248248f71490c8cd9a2a92e8 | Ruby | georgevtucker/codewars-katas | /sum-without-operators.rb | UTF-8 | 1,346 | 4.09375 | 4 | [] | no_license | # Codewars kata https://www.codewars.com/kata/sum-of-two-integers/ruby
def add(x,y)
bigarray = []
xarray = []
yarray = []
total = nil
unless x == 0
absolute_x = x / x.abs
end
unless y == 0
absolute_y = y / y.abs
end
# probably unnecessary
if x == 0 && y == 0
total = 0
# check w... | true |
7742898503607e43dee6fa96b5992492a8934c53 | Ruby | bofuuchicago/week2-homework | /hw/app/controllers/weather_controller.rb | UTF-8 | 1,330 | 2.6875 | 3 | [] | no_license | require 'uri'
require 'open-uri'
require 'rexml/document'
class WeatherController < ApplicationController
def enter_city
render "city"
end
def show_current_conditions
@city = params[:city]
unit='f'
id = get_id(@city)
url = "http://xml.weather.yahoo.com/" +
"forecastrss/#{id}_#{unit.d... | true |
208df2d7a3dc3ef5731404c9abb53fa01c925cb7 | Ruby | stephenyoon84/emoticon-translator-prework | /lib/translator.rb | UTF-8 | 861 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require 'yaml'
require 'pry'
def load_library(path)
# code goes here
emoticons = YAML.load_file("#{path}")
emo_list = {"get_meaning" => {}, "get_emoticon" => {}}
emoticons.each do |key, value|
emo_list["get_meaning"][value[1]] = key
emo_list["get_emoticon"][value[0]] = value[1]
... | true |
3c748e897bfc0ab86e87424d5ad35f18d820938d | Ruby | CodingDojo-Ruby-03-17/pmac_ruby | /excercises/classes.rb | UTF-8 | 763 | 3.875 | 4 | [] | no_license | # class User
# def first_name=(val) # setter
# @first_name = val
# end
# def last_name=(val) # setter
# @last_name = val
# end
# def first_name # getter
# return @first_name
# end
# def first_name #getter
# return @last_name
# end
# end
# -----------
# OR... | true |
a645c8ed52b1eb15b77b094b9e2072fcc5b8e7e0 | Ruby | lh-innovationhub/flightstats-client-ruby | /lib/flightstats/resource.rb | UTF-8 | 4,529 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'date'
require 'json'
module FlightStats
class Resource
# Performance optimizations
@@string_to_model_cache_lock = Mutex.new
@@string_to_model_cache = {}
class UnknownModel ; end
@@underscore_cache_lock = Mutex.new
@@underscore_cache = {}
class << self
# Instantiates a reco... | true |
e3a7626d0eb9d37323c4b4ba4b5c1d054f079991 | Ruby | meulop/adventofcode | /2015/src/dec14/reindeerolympics2.rb | UTF-8 | 1,138 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | require 'pp'
$finishpoint=ARGV[0].to_i
$reindeer = []
class Reindeer
attr_accessor :score
attr_reader :position
def initialize(name, speed, flytime, resttime)
@name = name
@speed = speed
@flytime = flytime
@resttime = resttime
@score = 0
@position = 0
@state="flying"
@flyingfor... | true |
393d8f9be186a7a59359ec54e04b1f9c0c5cf8de | Ruby | chenyukang/rubytt | /tests/cases/check_bug13.rb | UTF-8 | 147 | 3.03125 | 3 | [
"MIT"
] | permissive |
[1, 2].each{|a|
puts "#{a}"
}
[1, 2].each{|_a|
}
def func_1 a, b
end
def func_2 a, b
puts "now: #{a} #{b}"
end
def func_3 a, b, _c
end
| true |
13d46bb1e9f5a6ffbc98a2621736b6f45347e01f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/e72b3ba049e24e0a8af6fc1f1ee3cdfb.rb | UTF-8 | 330 | 3.40625 | 3 | [] | no_license | class Phrase
def initialize(message)
@message = message
end
def word_count
count = message_array.inject({}) do |collection, word|
collection[word] ||= 0
collection[word] += 1
collection
end
count
end
private
def message_array
@message.downcase.scan(/\b[a-z0-9]+\b/i)
... | true |
69298458c0731d3edc4a0355144c2c595ab698b4 | Ruby | jgoggles/calculate-business-days | /lib/calculate_business_days.rb | UTF-8 | 1,167 | 3.03125 | 3 | [
"MIT"
] | permissive | module CalculateBusinessDays
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def business_days_from_now(num, start_date=Date.today)
#Turn the start date into a number, i.e. Monday = 1
start_day_of_week = start_date.cwday
ans, i = 0, 0
weeks = num ... | true |
0e71331a7540c23507996449323bf40049cc9e67 | Ruby | Alasdair321/CodeClan_work | /Classwork/week_02/day_4/Inheritance/specs/car_spec.rb | UTF-8 | 329 | 2.609375 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../car')
class TestCar < Minitest::Test
def setup
@car = Car.new(4)
end
def test_car_can_start_engine
assert_equal("Vrrmmm", @car.start_engine)
end
def test_vehicle_has_number_of_wheels
assert_equal(4, @car.number_of_wheels)
... | true |
2d36e54bb5a5031e503cfd3c7404865c5d4fee90 | Ruby | takaxyz/atcoder | /ABC126/F.rb | UTF-8 | 390 | 3.03125 | 3 | [] | no_license | m,k=gets.chomp.split.map(&:to_i)
if m==0
if k==0
puts "0 0"
else
puts -1
end
elsif m==1
if k==0
puts "0 0 1 1"
else
puts -1
end
elsif 2**m <= k
puts -1
else
a=[]
0.upto(2**m-1) do |i|
next if i == k
a << i
end
a.each do |v|
printf("%d ", v)
end
printf("%d ", k)
a.... | true |
768c5810b3d6664655b0dd12e7a441200a31e0ad | Ruby | joshgranadosin/ruby-rio-grande | /starter-code/spec/digitalitem_spec.rb | UTF-8 | 2,486 | 3.15625 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../lib/DigitalItem'
describe Digital_item do
before(:context) do
@digital_item1 = Digital_item.new("Starter Pack", 0.99)
end
describe "Initialization" do
it "is a kind of the Item class" do
expect(@digital_item1).to be_a_kind_of(Item)
end
it "... | true |
f0b5205def2a49aba2583bd07091de26edc44816 | Ruby | akhilstanis/turtle-tracks | /lib/turtle_tracks.rb | UTF-8 | 1,595 | 3.234375 | 3 | [] | no_license | require 'pp'
class TurtleTracks
attr_accessor :canvas, :size, :dir
def initialize path_to_logo_file
File.open path_to_logo_file, "r" do |file|
@logo = file.readlines
end
@output_file = "#{File.dirname(path_to_logo_file)}/#{File.basename(path_to_logo_file).split('.').insert(1,'_output.').join}"
... | true |
c951411e29688d977de4596aeb475dc092fdd5a2 | Ruby | Sofiaimg/Activity17 | /ex6.rb | UTF-8 | 931 | 3.9375 | 4 | [] | no_license | # Ejercicio 6: Objetos y archivos.
# Se tiene un archivo llamado catalogo.txt que contiene los nombres de los
# productos que ofrece una tienda junto con los precios de las
# tallas L, M, S y XS.
# El siguiente codigo define la clase Product y ademas realiza la
# lectura del archivo.
# Se pide:
# Optimizar el codigo i... | true |
43251d37f5740902d40089c10beb615308127be5 | Ruby | jungchae/ruby-pwa | /create/rule.rb | UTF-8 | 2,032 | 3.28125 | 3 | [] | no_license | # Author:: Mike Williams
require 'utils.rb'
module Create
# The Create::Rule class is used while creating a new fit. Each amplitude
# file that is to be used in the fit must match a defined Rule. The Rule
# determines how the amplitude will be used in the fit. When a Rule is
# created it is initialized with a... | true |
c0cbd8717a76e7d82ad36d7e333c4c34fb406fb9 | Ruby | lauranzo/craftoid | /spec/lib/models/craft_spec.rb | UTF-8 | 2,915 | 2.59375 | 3 | [] | no_license | require 'spec_helper'
describe :Craft do
specify { Craft.should_not be_nil }
subject { Craft.new }
before(:each) do
@craft = Craft.new
end
after(:each) do
@craft.delete
end
describe :SCORE_AND_RANK do
it :@score_min_max do
@craft.score.should eq 0
@craft.score = 101
@craf... | true |
228820c1ba371fc26fa6c30839aa252f79629c75 | Ruby | ronny2205/geocodder- | /spec/models/address_spec.rb | UTF-8 | 591 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Address, type: :model do
it "is valid with valid attributes" do
@address = Address.new(street: 'Eliyahu', city: 'Hanavi', country: 'SF')
expect(@address).to be_valid
end
it "is not valid with missing attributes" do
@address = Address.new(street: 'Eliyahu', city:... | true |
5d59121790d3b086e3553c472944ff53b206a55b | Ruby | rparkerson/launch-school | /RB100/oop_with_ruby/classes_and_objects_II/3.rb | UTF-8 | 303 | 3.53125 | 4 | [] | no_license | class Person
attr_accessor :name
def initialize(name)
@name = name
end
end
bob = Person.new("Steve")
p bob.name
bob.name = "Bob"
p bob.name
# we have the attr_reader set up to access names (getter) but not for
# assigning names(setter). We can change this to do both with
# attr_accessor
| true |
66aea61b8a7f8792a4f2f2bf133020fb9f65f914 | Ruby | peicheng/company-website | /db/migrate/20130905130521_add_initial_blog_posts.rb | UTF-8 | 6,320 | 2.5625 | 3 | [] | no_license | class AddInitialBlogPosts < ActiveRecord::Migration
def change
BlogPost.create(
title: "New Company Website",
summary: "We've launched our new company website.",
thumb_image: "bg-text.png",
header_image: "new_website_blog_header.png",
author: "Jeremy Walker",
start_content:
... | true |
996fd2c83f481c7ca9bf245c679f027fb03c365c | Ruby | mattkiernan/ruby | /words.rb | UTF-8 | 166 | 3.015625 | 3 | [] | no_license |
puts (60*60*24*365*3)uts 'I like ' + 'apple pie'
puts 'blink' * 4
puts 12 + 12
puts '12' + '12'
puts '12 + 12'
puts 'you\'re swell!'
puts 'up\\down'
puts 'up\down'
| true |
c570da080a1be189712b4ea4ae711658d3156b4e | Ruby | svbarilov/ruby_kick_prologs_ass | /problems/lists/23.rb | UTF-8 | 396 | 3.671875 | 4 | [] | no_license | # 1.23 (**) Extract a given number of randomly selected elements from a list.
# The selected items shall be put into a result list.
# Example:
# ?- rnd_select([a,b,c,d,e,f,g,h],3,L).
# L = [e,d,a]
# Hint: Use the built-in random number generator random/2 and the result of problem 1.20.
module Problems
module List
... | true |
bb07ab994797ae6a1f4d69f019095a385cf0cd67 | Ruby | bwestover/pidgey | /pidgey.rb | UTF-8 | 1,080 | 3.40625 | 3 | [
"MIT"
] | permissive | class Pidgey
COST = 12
def self.calc(pidgeys, candy, aggressive_trade=false)
total_evolutions = 0
while (candy / COST) >= 1
# Evolutions are candy divided by the cost
evolutions = candy / COST
# Calculate the remaining candy.
candy = candy % COST
# Subtract the evolutions from... | true |
8e77b42eec21be40a980a5c4c431207322d1b85b | Ruby | lingtran/menu_items_matchmaker | /spec/models/matchmaker_spec.rb | UTF-8 | 1,993 | 2.59375 | 3 | [] | no_license | require 'spec_helper'
require_relative '../../lib/matchmaker'
describe "Matchmaker object" do
context "#initialization" do
it "sets parsed content" do
test_file = 'spec/support/sample_menu.txt'
parsed_input = parse_data_file(test_file)
matchmaker = Matchmaker.new(parsed_input)
expec... | true |
4651bc368ee0c3655c4d54da6f5da5991772c377 | Ruby | kickstriker/catechumen | /app/models/grade.rb | UTF-8 | 1,755 | 2.59375 | 3 | [] | no_license | class Grade < ActiveRecord::Base
validates_presence_of :student_id, :subject_id
validates_uniqueness_of :subject_id, :scope => :student_id, :message => " - This student has already taken this subject"
belongs_to :studentgrade, :class_name => 'Student', :foreign_key => 'student_id' #Link to Model student
... | true |
310c5bb1abecc81490ff11f4c7bd2f7adc8ef22f | Ruby | arpagon/puppet-disk_stats | /lib/facter/disk_stats.rb | UTF-8 | 2,445 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | # disk_stats.rb
# The disk_stats fact.
require 'facter'
require 'rubygems'
gem_present = false
# Check for old version of RubyGems
if Gem::Specification.respond_to?('find_all_by_name')
gem_present = Gem::Specification::find_all_by_name('sys-filesystem').any?
else
gem_present = Gem.available?('sys-filesystem')
en... | true |
1d848b13ca38638d87a0a382fa5db3a89c6bf718 | Ruby | h2o/h2o | /deps/mruby/mrbgems/mruby-metaprog/test/metaprog.rb | UTF-8 | 11,718 | 2.84375 | 3 | [
"MIT"
] | permissive | assert('Kernel#send', '15.3.1.3.44') do
# test with block
l = send(:lambda) do
true
end
assert_true l.call
assert_equal l.class, Proc
# test with argument
assert_true send(:respond_to?, :nil?)
# test without argument and without block
assert_equal send(:to_s).class, String
end
assert('Kernel#ins... | true |
5aebf9feae2a3617238bed5ce423b11341ad348e | Ruby | veetase/smarto | /app/jobs/station_temper_job.rb | UTF-8 | 1,176 | 2.609375 | 3 | [] | no_license | class StationTemperJob
include Sidekiq::Worker
def perform
response = HTTParty.get("http://szmb.gov.cn/data_cache/szWeather/szMetroWeather.js")
raise "Get Station temper info failed" unless response.message == "OK"
station_spots = []
temper_info = (JSON.load response.parsed_response)["SZ121_MetroLi... | true |
00e3bd20eaeba4154916385182db03cad4a5fb8e | Ruby | onddo/chef-handler-zookeeper | /test/test_chef_handler_zookeeper.rb | UTF-8 | 6,785 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require 'helper'
require 'chef/node'
require 'chef/run_status'
class ZK::Client::Fake
attr_reader :zk_client_new, :server, :znode
def initialize(host, opts={}, &b)
end
def set(path, data, opts={})
return true
end
def fake_new
@zk_client_new = true
return self
end
end
class Chef::Handler:... | true |
24f6520b62ed686fc42a4fa310db3254941e41fa | Ruby | Docworld/social-notifier | /lib/messenger/file-queue.rb | UTF-8 | 6,624 | 2.90625 | 3 | [] | no_license | require 'uuid'
require_relative 'base'
module SocialNotifier
module Messenger
class FileIO < SocialNotifier::Messenger::Base
#
# Initialize the Class
#
# @param notifier_engine [SocialNotifier::Engine]
# @param is_listener [Boolean]
# @raise [ArgumentError]
# @return [... | true |
6b5c9cd2347ba6762ff67fd9c8c280ac68cd617b | Ruby | fingersi/Ruby_lessons | /ruby_lesson7_blocs&procs/train_interface.rb | UTF-8 | 5,100 | 3.15625 | 3 | [] | no_license |
require_relative 'text'
class TrainInterface
def initialize(texts)
@texts = texts
end
def create_train
loop do
puts @texts.create_train_number
train_number = gets.chomp
Train.valid!(train_number)
puts @texts.select_train_type
train_type = gets.chomp
case train_type
... | true |
7b1b442a53a25a4cd482d00e6a554fc003f3586a | Ruby | atomicjuice/Flatiron-module-1-project | /lib/game.rb | UTF-8 | 899 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Game < ActiveRecord::Base
has_many :games_genres
has_many :genres, through: :games_genres
has_many :reviews
has_many :gamers, through: :reviews
# has_many :genres, through: :games_genres
# def self.find_by_genre(given_genre)
# all.where(genre:given_genre)
# end
def self.get_all_games
... | true |
9f3728ecf938c9ee470b497f852f50517d20aafc | Ruby | mavrik83/cli-facts | /lib/category.rb | UTF-8 | 507 | 3.703125 | 4 | [] | no_license | class Category
# Getter and setter methods.
attr_accessor :name
# Collection of all instance of categories. i.e. each named category is an object and is collected here.
@@categories = []
# Instantiates a new category object and pushed it into the @@categories variable.
def initialize(name)
... | true |
f7c4e817e182dd3c48c8dc19c5e4d97a7fd369d3 | Ruby | sr/atom-test | /tests/feed_rights_content_value.rb | UTF-8 | 220 | 2.5625 | 3 | [
"MIT"
] | permissive | xml = <<XML
<!--
Description: feed rights content value
-->
<feed xmlns="http://www.w3.org/2005/Atom">
<rights>Example Atom</rights>
</feed>
XML
test = lambda { |feed|
assert_equal 'Example Atom', feed.rights.to_s
}
| true |
953175aeac082eb737211c6e5f5d067af6caee75 | Ruby | alveraboquet/currency-exchange-rate | /lib/ftx.rb | UTF-8 | 695 | 2.765625 | 3 | [] | no_license |
class Ftx < ExchangeRate
def self.get_rates(support_currencies = nil)
support_currencies = get_support_currencies unless support_currencies
ans = {}
begin
info = RestClient.get "https://ftx.com/api/futures"
info = JSON.parse(info)
support_currencies.each do |quote, bases|
... | true |
1af6a3ca5d4b75f36cf3277683dcfab01a8a529f | Ruby | apsislabs/phi_attrs | /lib/phi_attrs/phi_record.rb | UTF-8 | 25,401 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Namespace for classes and modules that handle PHI Attribute Access Logging
module PhiAttrs
# Module for extending ActiveRecord models to handle PHI access logging
# and restrict access to attributes.
#
# @author Apsis Labs
# @since 0.1.0
module PhiRecord
extend ActiveSup... | true |
6ce04dffd62d30d8fb9a59dad7e9a9e0f9448982 | Ruby | tkl-labo/NLP | /edit_distance/iwanari/edit_distance.rb | UTF-8 | 3,836 | 3.375 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'jcode' if RUBY_VERSION < '1.9' # hankaku -> zenkaku
# ===== Cost Functions =====
INSERT_COST = 1
DELETE_COST = 1
SUBSTITUTE_COST = 2
# we can implement weighted-edit distance by writing
# some modification inside these three cost functions
def get_insert_cost(a)
... | true |
7ce2f5e3732adfc65bd688a52703548c294a6a07 | Ruby | srinusTriangle/buf_queue | /lib/buf_queue/subject.rb | UTF-8 | 626 | 3.09375 | 3 | [
"MIT"
] | permissive | module Subject
attr_reader :subscribers
def initialize
# puts "inside Subject initialize method.."
@subscribers = []
end
def add_subscribers(subscribers)
subscribers.each { |subscriber| @subscribers << subscriber }
end
def remove_subscribers(subscribers)
subscribers.each { |subscriber| @subscribers.del... | true |
011c4da16e333f0e659a5cfb3c38c0db38b533d8 | Ruby | siruguri/miscellaneous-scripts | /text_statistics/doc_categorize.rb | UTF-8 | 3,400 | 2.546875 | 3 | [] | no_license | require 'pry'
require './text_stats'
def make_universe
doc_universe = TextStats::DocumentUniverse.new
mr_files = Dir.glob "inputs/training/musicreviews/1/*txt"
sp_files = Dir.glob "inputs/training/sports/1/*txt"
sc_files = Dir.glob "inputs/training/science/1/*txt"
univ_files = Dir.glob "inputs/training/unive... | true |
6873c8f36d9ab196ff5f2694c3621552daafee75 | Ruby | tilmitt11191/mtg | /test_cases/decklists/stackleveltoodeep.rb | UTF-8 | 35,086 | 2.625 | 3 | [] | no_license |
#ruby
require "logger"
require '../../lib/util/deck.rb'
require '../../lib/util/store.rb'
require '../../lib/util/deck_prices.rb'
#The Error occurred when mode_of_create_cardlist = "full", on macos at 5/25/2016 .
#The purpose of this program is to identify the cause.
#
#git:(master*)workspace $ ruby ../../l... | true |
dc7e7085e4a6e6f80daf6ab9ff54e4af4600a2ff | Ruby | Maskonk/Book-Inventory-Management-System | /code/controllers/book_controller.rb | UTF-8 | 1,167 | 2.625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/contrib/all'
require_relative '../models/book'
get '/books' do
@books = Book.all
@books.sort_by! { | book | book.name }
erb(:'books/index')
end
get '/books/new' do
@authors = Author.all
@categories = Category.all
@authors.sort_by! { | author | author.pretty_name }
@ca... | true |
d13d273801d928e138536feee545deb553c75202 | Ruby | markhilkert/re-do_of_problems | /deep_dives/w05_blackjack/computer_player.rb | UTF-8 | 496 | 3.4375 | 3 | [] | no_license | require_relative 'player.rb'
class ComputerPlayer < Player
@@computer_count = 0
def initialize
computer_names = ("A".."G").to_a.map { |letter| letter + " Bot"}
@name = computer_names[@@computer_count]
@@computer_count += 1
super
end
def add_cards(card)
super
if calc_card_total > 16
... | true |
7a1c9a8392e208600e3ee73b65b473d44458722d | Ruby | lemmycaution/grass | /lib/grass/file_sync.rb | UTF-8 | 1,411 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'fileutils'
module Grass
module FileSync
class FileProxy
def initialize source
@source = source
FileUtils.mkdir_p File.dirname(@source.filepath)
exists? ? read : write(@source.raw)
end
def exists?
File.exists? @source.filepath
en... | true |
a593d26105ed0ce1aaebba8498e2b5d608e39320 | Ruby | misch/gpCollect | /app/charts/compare_runners_chart.rb | UTF-8 | 984 | 2.625 | 3 | [] | no_license | class CompareRunnersChart < RuntimeChart
def initialize(runners)
super()
## Fill with data
runners.each do |runner|
data = @all_run_days.map do |rd|
run = runner.runs.find { |r| r.run_day == rd }
duration = run.try(:duration)
[LazyHighCharts::OptionsKeyFilter.date_to_js_code(... | true |
366942ffa7d232bd0944f39a0b7516648831a9a2 | Ruby | malanchristiansen/count-letters-challenge | /count_the_letters.rb | UTF-8 | 1,684 | 4.9375 | 5 | [] | no_license | # Count the Letters
# The count_letters method (more on methods here - we will be covering this in class soon!) takes a string as an argument, and will return the count of each letter as a hash.
# E.g. count_letters("hello") should return {"h"=>1, "e"=>1, "l"=>2, o=>1}
# E.g. count_letters("Thats The Ticket") should... | true |
c484fcf4ec31537874d76cd0bb5805b08f8dea30 | Ruby | tatsqui/reverse_words | /lib/reverse_words.rb | UTF-8 | 763 | 4.15625 | 4 | [] | no_license | require 'pry'
# A method to reverse each word in a sentence, in place.
# Time complexity: On - linear
# Space complexity: O - no additional space taken up, temporary values to move things around.
def reverse_words(my_words)
return my_words if my_words == nil || my_words.length == 0
i = 0
l = my_words.length
... | true |
de6074ce8ee151b6c4976e497257a9e47a2e289b | Ruby | christoandrew/remote_lock_assignment | /app/base_parser.rb | UTF-8 | 282 | 2.796875 | 3 | [] | no_license | require_relative 'data_formatter'
require 'csv'
require 'date'
module DataParser
class BaseParser
include DataFormatter
def format_columns
@data = @data.map { |x| [x['first_name'], self.format_city(x['city']), self.format_date(x['birthdate'])] }
end
end
end
| true |
df16be1d216ce6806a2cbf36a033e87b763ede87 | Ruby | Yumeee/may24_exercises | /grocery_list.rb | UTF-8 | 557 | 3.375 | 3 | [] | no_license | grocery_list = ["carrots", "toilet paper", "apples", "salmon"]
grocery_list.push("rice")
grocery_list.map do |item|
puts "* #{item}"
end
total = grocery_list.count
puts total
if grocery_list.include?("bananas") == true
puts "You need to pickup bananas."
else
puts "You dont need to pick up bannaas today."
end
... | true |
92917886d627f1dd213554a87bee9c542a1c4aef | Ruby | MDSipahi/OrneklerleRubyProgramlama | /ornek141.rb | UTF-8 | 35 | 2.53125 | 3 | [] | no_license | 5.upto 15 do |e|
print "#{e},"
end
| true |
72bdb970cea0a3c54c064f699cb045de0a441b11 | Ruby | highb/ruby-daygram | /lib/daygram/cli.rb | UTF-8 | 2,899 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require "fileutils"
require "thor"
require "thor/actions"
require "thor_plus/actions"
require "runcom"
require "json"
require "pp"
require "terminal-table"
require "daygram/cli_helpers"
module Daygram
class Read < Thor
include Thor::Actions
include ThorPlus::Actions
include... | true |
d00a45631638f04ab013d4b30a341a19ecd6fe90 | Ruby | AaronPatterson/ApplicationInsights-Ruby | /lib/application_insights/channel/contracts/session.rb | UTF-8 | 1,958 | 2.609375 | 3 | [
"MIT"
] | permissive | require_relative 'json_serializable'
module ApplicationInsights
module Channel
module Contracts
# Data contract class for type Session.
class Session < JsonSerializable
# Initializes a new instance of the Session class.
def initialize(options={})
defaults = {
'ai... | true |
43cd3adda520e09fe230d1a24899203f0a665347 | Ruby | ashishg-qburst/projekt-euler | /002/benchmarks.rb | UTF-8 | 1,041 | 3.21875 | 3 | [] | no_license | require 'benchmark'
# user system total real
# mine 0.000000 0.000000 0.000000 ( 0.000031)
# 4613732
# conventional 0.000000 0.000000 0.000000 ( 0.000012)
# 4613732
# better 0.000000 0.000000 0.000000 ( 0.000004)
# 4613732
sum = 0
Benc... | true |
fcbe2906740e57b22612144f194b4f654b0ce0a6 | Ruby | Mcas4150/Mcas4150 | /reboot/horse-race/interface.rb | UTF-8 | 376 | 3.9375 | 4 | [] | no_license | puts "welcome to the horse show"
loop do
puts "which horse would you like to bet on?
Lucky
Chucky
Ducky"
horse=gets.chomp
break if horse==""
puts "how much would you like to bet?"
user_bet=gets.chomp
winner = ["Lucky", "Chucky", "Ducky"].sample
puts "#{winner} wins!"
if horse == winner
puts "congrats! you win #{user_... | true |
f21692378abecc7832e182135ce6570b0d5a397e | Ruby | Dbz/Algorithms | /algorithms/find_linked_list_cycle.rb | UTF-8 | 369 | 3.015625 | 3 | [
"MIT"
] | permissive | def find_linked_list_cycle(list)
return false unless list
slow = list.head
fast = list.head
while fast && !fast.next.nil?
slow = slow.next
fast = fast.next.next
if slow == fast
break
end
end
return false if fast.nil? || fast.next.nil?
until slow == fast
slow = head
slow = ... | true |
bed2a0cc490c70b90d79a7204daabc7157167789 | Ruby | Monte-Amador/rb101-foundations | /lesson_4/10_practice_problems_methods_and_more_methods/practice_problem_2.rb | UTF-8 | 406 | 3.40625 | 3 | [] | no_license | [Launch School - an online school for Software
Engineers](https://launchschool.com/lessons/85376b6d/assignments/fd13de08)
#### Practice Problem 2
# How does `count` treat the block's return value? How can we find out?
['ant', 'bat', 'catepillar'].count do |str|
str.length > 4
end
## My Answer
# The return value s... | true |
1067066af3850617dd919e1190f2cef1e68dfc93 | Ruby | MitsunChieh/Ruby-Exercise | /methods/3.rb | UTF-8 | 110 | 2.71875 | 3 | [] | no_license | def multiplay(n1, n2)
return n1*n2
end
puts multiplay(1710938413846513151, 4123941286514564389394803801243) | true |
e31411ec870bafbc7529b12c78d6fa5c9a528f64 | Ruby | h-lame/h-lame.com | /deploy.cgi | UTF-8 | 1,781 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
# This script should be installed at web webhook URL specified
# in github actions
require "cgi"
require "json"
require 'fileutils'
begin
cgi = CGI.new
params = JSON.parse(cgi.params['payload'].first) rescue nil
response = nil
raise "Failed to parse payload:\n\n#{cgi.params.inspect}" if p... | true |
65eb792e7a352e34f68dfaf9974b4e7503c861f9 | Ruby | rubene/gem_monitor | /lib/gem_monitor/inspector.rb | UTF-8 | 735 | 2.609375 | 3 | [
"MIT"
] | permissive | module GemMonitor
class Inspector
require "erb"
attr_accessor :project_gems
def project_gems
@project_gems ||= GemMonitor::Extractor.new.extract_project_gem_objects
end
def scan
project_gems
create_report_folder
create_report_file
puts "GemMonitor report completed!... | true |
6dbda4d1dcc049d4594d23c863a3a6b50e751f39 | Ruby | sergeyk/uw-courses | /lib/uwscraper/schedules/runner.rb | UTF-8 | 736 | 2.8125 | 3 | [] | no_license | #!/usr/bin/ruby
require File.dirname(__FILE__) + '/schedule_scraper'
if (ARGV.size < 1 || (ARGV[0] != "-p" && ARGV[0] != "-r"))
puts "incorrect arguments!"
puts "usage: schedule_scraper -p|r quarter [dept]"
puts "./schedule_scraper_runner -p WIN2008 CSE will output all CSE classes in pretty format"
puts "./sch... | true |
c3496692dac50f01adc6f748e41166dbce8f9848 | Ruby | jamescook/soundx | /benchmark/ruby_only_soundex.rb | UTF-8 | 1,001 | 3.765625 | 4 | [
"MIT"
] | permissive | # Just for fun, let's write a pure-ruby version to see
# how it stacks up.
class RubyOnlySoundex
=begin
b, f, p, v → 1
c, g, j, k, q, s, x, z → 2
d, t → 3
l → 4
m, n → 5
r → 6
=end
MAPPING = {
"a"=>nil, "b"=>1, "c"=>2, "d"=>3, "e"=>nil,
"f"=>nil, "g"=>2, "h"=>nil, "i"=>nil,
"j"=>2, "k"=>2, "l"=>4, ... | true |
165907631323280bac84e7e33998f36432bada3a | Ruby | wconrad/sqlpostgres | /test/PgLineSegment.test.rb | UTF-8 | 2,810 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
$:.unshift(File.dirname(__FILE__))
require 'TestSetup'
require 'RandomThings'
class PgLineSegmentTest < Test
include SqlPostgres
include RandomThings
def test_ctor_defaults
assertEquals(PgLineSegment.new, PgLineSegment.new(PgPoint.new, PgPoi... | true |
60bdc803ead3ccb4766770e436d0282ea5a5dd18 | Ruby | danbriechle/LaughTracks | /spec/models/special_spec.rb | UTF-8 | 759 | 2.6875 | 3 | [] | no_license | RSpec.describe Special do
describe 'Validations' do
describe 'Required Field(s)' do
it 'should be invalid if missing a name' do
special = Special.create
expect(special).to_not be_valid
end
end
end
end
RSpec.describe Special do
describe 'ClassMethods' do
describe '.average_... | true |
63b3d1884c5ad5dc0d831bfb878e425f85b1670c | Ruby | jeffpe/results_analyzer | /reconalyzerV2.rb | UTF-8 | 9,889 | 3.15625 | 3 | [] | no_license | # Recon
# The next time I do this use SQL or someting like that. This is getting ridiculous.
# load in the required libraries
require "csv"
require "date"
# set the names of the csv files
pp_file_name = "paypal_recon.csv"
sf_file_name = "salesforce_recon.csv"
output_file_name = "recon_output.csv"
# set the paramete... | true |
3f4f89a52190d294e1bca2153831b9213a766582 | Ruby | Cparusso/Slumbr-app | /slumber-api/db/seeds.rb | UTF-8 | 2,342 | 2.5625 | 3 | [] | no_license | Bed.create(bed_type: "Memory Foam", size: "Twin", price: 50)
Bed.create(bed_type: "Memory Foam", size: "Full", price: 75)
Bed.create(bed_type: "Memory Foam", size: "Queen", price: 125)
Bed.create(bed_type: "Memory Foam", size: "King", price: 150)
Bed.create(bed_type: "Memory Foam", size: "California King", price: 200)
... | true |
de321a79eaf23eeb90022411c1b5f0901f15b4a0 | Ruby | richbscott/adventofcode | /2020/day14.rb | UTF-8 | 1,587 | 3.328125 | 3 | [] | no_license | require './inputs'
input = Inputs::DAY14
rows = input.split("\n")
mem = {}
mask = ''
rows.each do |row|
line = row.split(' = ')
if (line[0] == 'mask')
mask = line[1]
else
memkey = line[0].split("[").last.split("]").first.to_i
value = line[1].to_i.to_s(2).rjust(36, '0')
mask.split('').each_with... | true |
5623d231e445b7b0328a9ea7c0212c62e1e50462 | Ruby | totechite/Learning_parser_with_Ruby | /lib/list_lexer.rb | UTF-8 | 1,787 | 3.203125 | 3 | [
"MIT"
] | permissive | class ListLexer < Lexer
@tokenNames = %w[n/a <EOF> NAME COMMA L_BRACKET R_BRACEKT SHARP LIST LINE_FEED]
@NAME = 2
@COMMA = 3
@L_BRACKET = 4
@R_BRACKET = 5
@SHARP = 6
@LINE_FEED = 7
def initialize(text)
@tokenNames = %w[n/a <EOF> NAME COMMA L_BRACKET R_BRACEKT SHARP LIST LINE_FEED]
@N... | true |
fb74f2204a37e16a65090108ffc3093b86c093dd | Ruby | dynabic/dynabic-ruby | /lib/dynabic/models/customerrequest.rb | UTF-8 | 2,853 | 2.890625 | 3 | [] | no_license | class CustomerRequest
attr_accessor :shipping_address, :first_name, :phone, :email, :company, :shipping_address_id, :is_shipping_address_same_to_billing, :last_name, :reference
# :internal => :external
def self.attribute_map
{
:shipping_address => :shipping_address, :first_name => :first_name, :phone => ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.