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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a59debb129daee6b3f3ec6ed18c32d80d2691f46 | Ruby | chenghaow/ComStock | /resources/measures/simulation_settings/tests/measure_test.rb | UTF-8 | 11,649 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | # ComStock™, Copyright (c) 2020 Alliance for Sustainable Energy, LLC. All rights reserved.
# See top level LICENSE.txt file for license terms.
# insert your copyright here
require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'... | true |
1a93bfc9d9c7b949608c66db043e72c157986f03 | Ruby | Strausssa/StarFighterGame | /laser.rb | UTF-8 | 328 | 3.46875 | 3 | [] | no_license |
class Laser
SPEED = 10
attr_reader :x, :y
def initialize(x,y,angle)
@image = Gosu::Image.new("media/laser.png")
@x = x
@y = y
@angle = angle
end
def draw
@image.draw_rot(@x,@y, 1, @angle)
end
def move
@x += Gosu::offset_x(@angle, SPEED)
@y += Gosu::offset_y(@angle, SPEED)
end
... | true |
dcd1c383f0b737c41619a4fd849028e45bbe7ac2 | Ruby | jamesm2013/speaking-grandma-onl01-seng-pt-012220 | /grandma.rb | UTF-8 | 191 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def speak_to_grandma
IF phase == "I LOVE YOU TO GRANDMA!"
return "I LOVE YOU TOO PUMPKIN!"
elsif PHASE == phase.DOWNCASE
"NO, NOT SINCE 1938!"
ELSE "HUH?! SPEAK UP, SONNY!"
end
end | true |
1fe56cb9c5b4becb4b952404c18d26c1211ea2e9 | Ruby | karino-minako/paiza_mihon | /level-up-exerise-books-2.rb | UTF-8 | 496 | 3.453125 | 3 | [] | no_license | # 入力される値
# 入力は以下のフォーマットで与えられます。
# a
# b
# 入力値最終行の末尾に改行が1つ入ります。
# 文字列は標準入力から渡されます。 標準入力からの値取得方法はこちらをご確認ください
# 期待する出力
# aとbを掛け算した数値を出力して下さい。
# 最後は改行し、余計な文字、空行を含んではいけません。
line = readlines.map(&:to_i)
puts line[0] * line[1] | true |
684a7a9cb4a2c2149629f5481fc1600f47ee6466 | Ruby | roberthead/head_music | /lib/head_music/style/guidelines/limit_octave_leaps.rb | UTF-8 | 526 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Module for style guidelines.
module HeadMusic::Style::Guidelines; end
# A counterpoint guideline: Use a maximum of one octave leap.
class HeadMusic::Style::Guidelines::LimitOctaveLeaps < HeadMusic::Style::Annotation
MESSAGE = "Use a maximum of one octave leap."
def marks
retur... | true |
70d605caf3bd4cc709fa1fa4fc71a9aef8a4760c | Ruby | msimon42/flash_cards | /test/round_test.rb | UTF-8 | 899 | 3.171875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/round'
require_relative '../lib/card'
require_relative '../lib/deck'
require_relative '../lib/turn'
class RoundTest < Minitest::Test
def setup
@card1 = Card.new("Test", "Test", :test)
@card2 = Card.new("test", "test", :other_test)
... | true |
c81c1b022cdd299db5ef7bf7610f869a6ff07bbd | Ruby | SeanEmmers/OOD_challenge_one | /lib/secret_diary.rb | UTF-8 | 350 | 2.953125 | 3 | [] | no_license | require_relative 'key'
class SecretDiary
attr_reader :key, :diary
def initialize
@diary = ""
@key = Key.new
end
def add_entry(diary_entry)
fail 'Diary is locked' if key.locked? == true
@diary << diary_entry
'Entry Added'
end
def get_entries
fail 'Diary is locked' if key.locked? ... | true |
63d5321dcec71c84a9d8d068f4f363b1dd280264 | Ruby | abcalvo/MC30-status-service | /mc30.rb | UTF-8 | 1,259 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
require 'json'
class MC30
MC30_URL = 'http://mc30.es/'
# Parse traffic data and returns JSON
def self.status
doc = Nokogiri::HTML(open(MC30_URL))
traffic_data = doc.css('.trafico')
# Parse HTML, and get only the cars in tunnel:
# COCHES CIRCULANDO ... | true |
996595d6c5a5c2ff1a3e9241cf94108216594b55 | Ruby | caromedellin/phase-0 | /week-5/5-nums-to-st/my_solution.rb | UTF-8 | 1,741 | 4.34375 | 4 | [
"MIT"
] | permissive |
# Numbers to Commas Solo Challenge
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# What is the input?
# What is the output? (i.e. What should... | true |
19d5048be791ab7310c183591b5d8d345eab42e0 | Ruby | noku/university | /IPP/Lab#2/fafurl | UTF-8 | 2,664 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'singleton'
require 'json'
require 'time'
module Fafuri
# Defines the available parameters for the class
IPPStruct = Struct.new(:command, :headers, :list, :post, :argv, :verbose, :data)
class IPP
include Singleton
# Initialize the IPP and set defaults:
... | true |
1b4c26f556f3bbcf0f691ee185c3b90db3d79ca1 | Ruby | yixia-team/giphy-dumper | /main.rb | UTF-8 | 2,089 | 3.09375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require "open-uri"
require 'active_support'
require 'active_support/core_ext' # to_query support
#require 'byebug'
if ARGV.length == 0
puts """At least one keyword should be given.
Example: ./main.rb cat dog anime:200
Exit now."""
abort # An unsuccess... | true |
418dca588b751adbcf0c18d332fdce450ea2766e | Ruby | yuzu-r/maigo-bot | /src/classes/train.rb | UTF-8 | 2,538 | 3.15625 | 3 | [] | no_license | require_relative '../lib/maigodb'
class Train
attr_accessor :route, :conductor, :show_boss
def initialize
# route is an array of _id from registered raids/eggs
@route = []
@conductor = nil
@show_boss = false
end
def show
if @route.count == 0
return "Nowhere. Aw."
else
raid_string = ""
@route... | true |
a0d65a1a59aa69c5e1b2b21f417d4f16448f1222 | Ruby | sachinsaxena1996/cambridge | /array_map.rb | UTF-8 | 290 | 3.640625 | 4 | [] | no_license | class ArrayMap < Array
def new
super
end
def my_map(&block)
result = []
if !block.nil?
each { |element|
result << block.call(element)
}
end
result
end
end
new_array = ArrayMap.new([2, 100, 10, 4])
new_array = new_array.my_map {|element|
element + 1
}
p new_array
| true |
7db0539f24b2825af2937b9709be229f6883faae | Ruby | kirbyk/spending | /lib/tasks/addPlaidCategories.rake | UTF-8 | 1,141 | 2.578125 | 3 | [] | no_license | require 'unirest'
desc 'adds plaid categories into the DB'
task :addPlaidCategories => :environment do
responses = Unirest.get 'https://tartan.plaid.com/categories'
responses.body.each do |cat|
if Category.find_by( plaid_id: cat['_id']).present?
next
end
high = cat['hierarchy']
if high.length ... | true |
4a4df626362c80fe42badf9929e2fa516f94a497 | Ruby | doggerel/rails | /lucky_numbers/vendor/plugins/luckynumbers/lib/luckynumbers.rb | UTF-8 | 406 | 2.625 | 3 | [
"MIT"
] | permissive | module Luckynumbers
module InstanceMethods
def lucky_number
id.to_i % 10
end
def self.include(base)
base.extend ClassMethods
end
end
module ClassMethods
def find_by_lucky_number(number)
find(:all, :conditions => ["id % 10 = ? ", number])
end
end
module ActsMacro
d... | true |
9413275d48a9c3f254929f9d65bc93d17ea434ee | Ruby | bechirsegni/Feed-Data | /count.rb | UTF-8 | 546 | 3.140625 | 3 | [] | no_license | require 'json'
def words(file)
frequency = Hash.new(0)
input_file = File.open(file, 'r')
output_file = File.open("#{file}frequency.txt", 'w')
input_file.read.downcase.scan(/\b[a-z]{3,16}\b/) {|word| frequency[word] = frequency[word] + 1}
frequency.keys.sort.each{|key| output_file.print key,' => ',frequency[k... | true |
b4803fe26b61484a71e09a21699f3811a8e61b6a | Ruby | RyN21/backend_module_0_capstone | /day_2/exercises/iteration.rb | UTF-8 | 1,132 | 4.34375 | 4 | [] | no_license | # In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# `ruby day_2/exercises/iteration.rb`
# Example: Write code that iterates through a list of animals
# and print each animal:
animals = ["Zebra", "Giraffe", "E... | true |
5e9e870074f2883f723fc697895cde63bbe0e1ff | Ruby | LoveMyData/onkaparinga | /scraper.rb | UTF-8 | 3,107 | 2.625 | 3 | [] | no_license | require 'scraperwiki'
require 'mechanize'
def is_valid_year(date_str, min=2004, max=DateTime.now.year)
if ( date_str.scan(/^(\d)+$/) )
if ( (min..max).include?(date_str.to_i) )
return true
end
end
return false
end
unless ( is_valid_year(ENV['MORPH_PERIOD'].to_s) )
ENV['MORPH_PERIOD'] = DateTime.... | true |
a15a50bf1a7f67f97d74554c473ac3179d7fcaa0 | Ruby | daa5417/RubyClass | /comparison.rb | UTF-8 | 50 | 2.765625 | 3 | [] | no_license | puts 1 > 2
puts 1 < 2
puts 5 >= 5
puts 5 <= 4 | true |
fd88b68623a3f59bcb1711f207ed1deccaf517bb | Ruby | ObaldThePedro/looping-while-until-london-web-051319 | /lib/until.rb | UTF-8 | 139 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_until(phrase)
levitation_force = 6
#your code here
until levitation_force == 10
puts phrase
levitation_force += 1
end
| true |
a5b5170697b5e55865762cf6a071d0b4e0ad8b10 | Ruby | radixhound/mockserver | /mockserver-client-ruby/lib/mockserver/model/header.rb | UTF-8 | 866 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
require 'hashie'
require_relative './array_of'
#
# A class to model headers in payloads.
# @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
#
module MockServer::Model
# A class that only stores strings
class Strings < ArrayOf
def child_class
String
end
end
# Model f... | true |
e25be4adf7e49eda1cb21f9cab38312258956636 | Ruby | kimihito/whitehall | /db/data_migration/20130225142023_add_detailed_guidance_categories_for_dcms.rb | UTF-8 | 965 | 2.53125 | 3 | [] | no_license | [
['Development of the arts, sport and heritage for local communities', 'Guidance and relevant data for local authorities, private investors and grant-making bodies.', 'housing/local-councils', 'Local councils and services'],
['Understanding and asserting your statutory rights', 'Duties of government and local auth... | true |
817aed0ad4f58a4addd896f15cfeb100977a9b21 | Ruby | cmoran92/dwolla-ruby | /examples/oauth.rb | UTF-8 | 855 | 2.578125 | 3 | [
"MIT"
] | permissive | # Include the Dwolla gem
require 'rubygems'
require 'pp'
require 'sinatra'
require 'dwolla'
# Include any required keys
require './_keys.rb'
# Instantiate a new Dwolla User client
Dwolla::api_key = @api_key
Dwolla::api_secret = @api_secret
# Constants...
redirect_uri = 'http://localhost:4567/oauth_return'
# STEP 1:... | true |
c4d731d6f713c29adaa82059424bc3d07426933c | Ruby | Darkcodelab/ruby-cookbook | /array_selection.rb | UTF-8 | 433 | 3.765625 | 4 | [] | no_license | array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
#selecting elements that satsify a given criteria
array.select { |a| a > 1 }
#Rejecting element that satisfy a given criteria
array.reject { |a| a < 3 }
array.drop_while { |a| a>5 }
#select and reject are Non-Destructive Selection. However if you add ! to the end of select or... | true |
51b00ba5b664d37d0b649967a0345e2623417a6a | Ruby | David24m/cinema-sql | /models/screenings.rb | UTF-8 | 1,508 | 2.96875 | 3 | [] | no_license | require_relative("../db/sql_runner")
class Screening
attr_reader :id
attr_accessor :film_times, :availability
def initialize( options )
@id = options['id'].to_i
@film_times = options['film_times']
@availability = options['availability']
end
def save()
db = PG.connect({ dbname: "cinema", ho... | true |
f5bf6a18e5d0184b1dbbcb205d306883565ad342 | Ruby | bobbert/age13chargen | /db/seeds.rb | UTF-8 | 4,708 | 2.515625 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
3f4917b04a704c2852ea46fc34c02979147cf250 | Ruby | taskrabbit/smyte | /spec/config_spec.rb | UTF-8 | 2,176 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe "config" do
let (:config) { Smyte::Config.new }
describe "setters" do
it "gets and sets logger" do
config.logger.should == nil
config.logger = "log"
config.logger.should == "log"
end
end
describe "API keys" do
it "should freak out if not set" do
... | true |
a686c985ba8e6599e70ae2fa4135509e17bcaf41 | Ruby | dtk/dtk-server | /lib/common_dsl/diff/qualified_key.rb | UTF-8 | 3,382 | 2.5625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | #
# Copyright (C) 2010-2016 dtk contributors
#
# This file is part of the dtk project.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | true |
5936fb7dde2ea7b13afd409ad6f865d9e02fc14f | Ruby | Estelle-B262/Morpion0 | /Morpion2/lib/app/Player.rb | UTF-8 | 137 | 2.890625 | 3 | [] | no_license | class Player
attr_accessor :nom, :symbole
def initialize(nom,symbole)
@nom = nom
@symbole = symbole
end
end | true |
e5e6d11f1a2f7ef7d0f33d1f3e3815e14c24c19c | Ruby | pironim/hashozaur | /lib/hashozaur/camel_back_keys_hash.rb | UTF-8 | 1,012 | 3.296875 | 3 | [
"MIT"
] | permissive | module Hashozaur
class CamelBackKeysHash
def self.convert(object)
new.to_camelback_keys(object)
end
# Recursively converts Rubyish snake_case hash keys to camelBack JSON-style
# hash keys suitable for use with a JSON API.
def to_camelback_keys(object)
case object
when Array
... | true |
a55439ae93648721658ea113964db14e64aaaca0 | Ruby | omghax/einstein | /lib/einstein.rb | UTF-8 | 778 | 2.71875 | 3 | [
"MIT"
] | permissive | # Add ./lib to the load path.
$:.unshift File.dirname(__FILE__)
require 'einstein/parser.racc.rb'
require 'einstein/parser.rex.rb'
require 'einstein/expression'
require 'einstein/version'
module Einstein
# Raised when an undefined variable is referenced.
class ResolveError < StandardError # :nodoc:
end
# Pars... | true |
b3e6303627c497cfe02bb06d102292e295b0d879 | Ruby | Zrp200/chargen | /lib/types/normal.rb | UTF-8 | 712 | 3.390625 | 3 | [] | no_license | require 'simple-random'
class Normal
def initialize
@random_generator = SimpleRandom.new
@random_generator.set_seed
end
def handle(options)
extract_options(options)
if (!@min.nil? && !@max.nil?) && (@min > @max)
fail "Minimum #{@min} is greater than Maximum #{@max}."
end
value = ... | true |
cc6225166a3b66542abeb5f9f897a8c6ae1f6063 | Ruby | TDobbert/App-Academy | /Ruby/poker/lib/card.rb | UTF-8 | 156 | 2.984375 | 3 | [] | no_license | class Card
attr_reader :card_value, :card_suit
def initialize(card_value, card_suit)
@card_value = card_value
@card_suit = card_suit
end
end
| true |
046ecaf051e46f70915b5f5ebc3576e8c87bd51e | Ruby | koremori/movies | /imdb.rb | UTF-8 | 3,453 | 3.59375 | 4 | [] | no_license | # frozen_string_literal: true
require 'csv'
require 'ostruct'
require 'date'
def reading_file(file_path) # => String
default_path = '/home/koremori/documents/rubycode/movies.txt'
File.exist?(file_path) ? File.read(file_path) : File.read(default_path)
end
def normalizing_movie_data(raw_data) # => multidimension... | true |
9bfe5939edc5dda214e2d28c9dc522811017e450 | Ruby | madelynrr/bloody_hogwarts | /spec/features/courses/index_spec.rb | UTF-8 | 792 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe "a user can visit course index page" do
it "shows all course names and number of students enrolled in each course" do
daad = Course.create(name: "Defense Against the Dark Arts")
muggles = Course.create(name: "Muggle Studies")
student_1 = Student.create(name: "Hermio... | true |
88e21482bc4f759c3546472a1c84e7d4cd86a7d6 | Ruby | MichaelA26/W1-Weekend-HW | /day_2/mini_lab.rb | UTF-8 | 256 | 3.5 | 4 | [] | no_license | def add(first_number, second_number)
return first_number + second_number
end
p add(2, 3)
def popdense(population, area)
return population / area
end
p popdense(5373000, 77933)
p "The population density of Mauritius is: #{popdense(5373000, 77933)}"
| true |
62f699c79a15c85bfb365861d0a1066daf734544 | Ruby | shelbipinkney/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 323 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
sentence.split(" ").reverse.join(" ")
sentence.split(" ").collect do |word|
word.reverse
end.join(" ")
end
#string=""
#sentence.split(" ").reverse.join(" ")
#sentence.collect do |sentence| string<<"#{string}"
#string.collect do |sentence| string<<"#{string... | true |
11a50750952ace7ec95f9818a7bd5d551460cd2c | Ruby | pjotrp/bioruby-logger-plugin | /lib/bio/log/loggercli.rb | UTF-8 | 3,771 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'singleton'
module Bio
module Log
class LoggerPlusGlobal
include Singleton
attr_accessor :outputter_type, :trace
end
module CLI
# Parse and store global logger type
def CLI::logger name
LoggerPlusGlobal.instance.outputter_type = case name
when 'stder... | true |
1419f721bbac6b4bf08d5e20119d32d08841eb69 | Ruby | thughes24/week1 | /calculator.rb | UTF-8 | 841 | 4.25 | 4 | [] | no_license | require 'pry'
def say(arg)
puts "=> Please Enter a #{arg}: "
end
begin
say('number')
num1 = gets.chomp
num1_converted = num1.to_i
end until num1_converted >= 0
begin
say('second number')
num2 = gets.chomp
num2_converted = num2.to_i
end until num2_converted >=0
begin
puts "Enter 1 to Add, 2 to Subtra... | true |
91b4d53d3bdf562372ecbc05298cdaeceec2d358 | Ruby | andrewstyll/adventOfCode | /2016/santa14.rb | UTF-8 | 1,982 | 3.4375 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'digest'
NUMHASHES = 64
INPUTSALT = "qzyelonm"
#INPUTSALT = "abc"
hashHash = Hash.new
def getHash(salt, hashHash)
if(hashHash.key?(salt))
return hashHash[salt]
else
string = Digest::MD5.hexdigest(salt)
hashHash[salt] = string
return string
... | true |
908b030052d8d670a15872b6f93ab5c5a427970c | Ruby | sanjsanj/object-calisthenics-beach-volleyball-edition | /lib/team.rb | UTF-8 | 264 | 3 | 3 | [] | no_license | class Team
def initialize
@player_list = []
end
def add player
player_list << player
end
def valid?
player_list.count >= 7 && player_list.count <= 10
end
def roster
player_list.dup
end
private
attr_reader :player_list
end
| true |
12e6371085fc803df0061e3f571a5b28ff2c6304 | Ruby | BlaireAramenko/finstagram | /app/models/finstagram_post.rb | UTF-8 | 664 | 2.703125 | 3 | [] | no_license | class FinstagramPost < ActiveRecord::Base
belongs_to :user
has_many :comments
has_many :likes
validates_presence_of :user
validates :photo_url, :user, presence: true
def humanized_time_ago
time_ago_in_seconds = Time.now - self.created_at
time_ago_in_minutes = time_ago_in_seco... | true |
a3d8ea7260e3e1616c75f0cecc4308220baa390a | Ruby | askareija/resi-tracking-api | /app/services/tracking_service.rb | UTF-8 | 2,023 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
class TrackingService
def self.track(*args, &block)
new(*args, &block).execute
end
def initialize(no_resi, expedition_type, user)
@no_resi = no_resi
@expedition_type = expedition_type
@user = user
@track_history = TrackHistory.new(noresi: @no_resi, expedition_ty... | true |
809baa881f5860bc14f1f21fbf10fcd7122dd833 | Ruby | abe-06/libraryapi | /test/models/book_test.rb | UTF-8 | 4,144 | 2.765625 | 3 | [] | no_license | require 'test_helper'
class BookTest < ActiveSupport::TestCase
test "should not save a book without a title" do
book = Book.new
book.author = "test author"
book.collection = "test collection"
book.description = "test description"
book.genre = "test genre"
book.price = 100
book.isbn = 123... | true |
5a44136136f01802a4538f13ad2e5350fd39d159 | Ruby | diego-asterisk/ttps | /tp2/clases/ej1.rb | UTF-8 | 677 | 3.171875 | 3 | [] | no_license | class VehiculoDeMotor
attr_accessor :llave;
def arrancar
puts @llave
end
def initialize(llave = false)
@llave = llave
end
end
class Auto < VehiculoDeMotor
def arrancar
freno_mano = false
cambio = :punto_muerto
super
end
end
class Moto < VehiculoDeMotor
def arranca... | true |
20c1023f0a4084226440504e4937573612d4d3e7 | Ruby | Nemanicka/pathToFriend | /lib/searchers/twitter.rb | UTF-8 | 1,607 | 2.84375 | 3 | [
"MIT"
] | permissive | #https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=LPOO1Y3SF1IRX04VJZC53XKKQQHCAMIQSB1SQ1BWYDFY1BSV&client_secret=3WL0SL5JODGZDJD1PNVRJPQ4JQAVN2SW42AUBQJIMMXZ3VE2&v=20120609
require "net/http"
require "curb"
require "addressable/uri"
require "json"
require "twitter"
class FoursquareSearcher
def ... | true |
aebbb7ae3479c3f47da6df1c219562493e50bd32 | Ruby | aknuds1/childprocess | /lib/childprocess/abstract_io.rb | UTF-8 | 723 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module ChildProcess
class AbstractIO
attr_reader :stderr, :stdout, :stdin
def inherit!
@stdout = STDOUT
@stderr = STDERR
end
def stderr=(io)
if io != :pipe
check_type io
end
@stderr = io
end
def stdout=(io)
if io != :pipe
check_type io
... | true |
42455ad1e9c5b80e500dbd4c844bd7c1920ee635 | Ruby | monicamow/contacts_app | /lib/contact_list.rb | UTF-8 | 3,502 | 3.875 | 4 | [] | no_license | # Interfaces between a user and their contact list. Reads from and writes to standard I/O.
class ContactList
# This method is called when no user arguments are given after the 'ruby contact_list.rb' command
def display_menu
puts "Here is a list of available commands: \
\n new - Create a new contact \... | true |
0123b06f3aac375545d5f9c2ac46955b598a75fd | Ruby | zsombor/battleship | /contestants/nelson/lib/probability_board.rb | UTF-8 | 2,417 | 3.796875 | 4 | [] | no_license | # Evaluate the best possible coordinate for of the next bomb. This is
# done via by positioning all remaining enemy ships in all possible
# ways over the board. Then the probability of a hit is computed by
# counting how many times a particular bomb had hit a possible ship
# placement.
#
# If there are hits on the boar... | true |
9711ec6a84d17cdb2b007e702682a52c89f0c26f | Ruby | benlund/roc | /test/float_test.rb | UTF-8 | 704 | 2.765625 | 3 | [] | no_license | require File.join(File.dirname(__FILE__), 'roc_test')
class FloatTest < ROCTest
def test_rw
f = Store.init_float(random_key)
assert_nil f.value
assert_equal 0.0, f.to_f
assert_equal 0, f.to_i
f.value = 2.345
assert_equal 2.345, f.value
end
def test_infinite
f = Store.init_float(rand... | true |
c21e4fd454a469d3386c190a3200a493901f07cb | Ruby | 256hz/recipe-reader-rails | /app/models/fetcher.rb | UTF-8 | 8,940 | 2.984375 | 3 | [] | no_license | require 'httparty'
# Calls the Spoonacular API for recipe search and recipe steps.
# Order of operations:
# SEARCH: search, request_search
# RECIPE:
# get_recipe
# request_recipe
# create_recipe
# create_ingredients
# create_steps
# get_spoon_ids
# associate_step_ingredients
class Fetcher
... | true |
c471a41cff0e910fcf569ab26f5bfba1188bd4fd | Ruby | KevinLai76/parrot-ruby-dumbo-web-060319 | /parrot.rb | UTF-8 | 160 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `parrot` that outputs a given phrase and
# returns the phrase
def parrot(str = "Squawk!")
phrase = "#{str}"
puts phrase
return phrase
end | true |
d8c6811df97c688de857d49fd08add03083266cc | Ruby | JuanPabloSolano1/Hackerrank_Ruby | /Extra_long_factorials.rb | UTF-8 | 144 | 3.0625 | 3 | [] | no_license | number = 30
array = [*1..number -1]
new_array = array.reverse()
count = number
new_array.each do |element|
count *= element
end
print count
| true |
aa4d0c1442062b6be17cd85805e8a011cc998812 | Ruby | botanicus/dm-notifications | /lib/dm-notifications.rb | UTF-8 | 2,221 | 2.515625 | 3 | [] | no_license | # encoding: utf-8
require "mq"
module NotificationsMixin
def self.included(base)
unless base.instance_method_defined?(:name)
raise RuntimeError.new("#{base} has to respond to #name method!")
end
end
# followers fanout
def create_followers_fanout
self.followers_fanout(no_declare: false)
en... | true |
b809351283f7f30c13024a3d466d5726fd5b8bae | Ruby | pomidorus/Full-Stack-Engineer-Ruby | /core_api/app/services/marvel_data_saver.rb | UTF-8 | 1,049 | 3.21875 | 3 | [] | no_license | class MarvelDataSaver
YEAR_REG = /[(](\d+)[)]/
NUMBER_REG = /#\d+/
NEGATIVE_NUMBER_REG = /#-\d+/
YEAR_NUMBER_REG = /[(]\d+[)]\s+#\d+/
def save(data)
data[:data][:results].map &method(:create_comic)
rescue NoMethodError
puts "Data #{data.inspect} is broken for parsing"
end
private
def create... | true |
40ba3b1d982f8beffb7e1577b710fa27867f5960 | Ruby | eoneill/sassdoc | /lib/sassdoc.rb | UTF-8 | 3,973 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require 'fileutils'
require 'json'
module Sassdoc
@docs = {}
def self.parse(read)
if File.exist? read
if File.directory? read and Dir.chdir(read)
# loop through each scss file in the directory
Dir.glob('**/*.s[ac]ss').each do |f|
self.parse_docs(f)
end
else
... | true |
4283c855b4eb93bfcbd50919a253fda4f3b3796a | Ruby | jugyo/ncurses_test | /vi_ui.rb | UTF-8 | 2,791 | 2.921875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'ncurses'
require 'g'
module CommandLine
def self.extended(base)
base.instance_eval do
@position = 0
@text = ''
@prompt = ':'
end
end
attr_reader :text, :position
def char_widths
@char_widths ||= []
@char_widths
end
def clear_text
@te... | true |
6a1be035a7c791e96785d94601fb69e8f845b862 | Ruby | simongregory/glued | /lib/glued/bootstrap.rb | UTF-8 | 5,960 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
# Bootstrap decoder.
#
# The boostrap files describe the segments and fragments that form
# the media file.
#
class Bootstrap
attr_reader :boxes
def initialize(data)
@reader = F4VIO.new(data)
@boxes = []
scan
end
# Top level
AFRA = 'afra' # Fragment random access for HTTP stre... | true |
bccb0d21961702593fbb49b6ecc875c0271c1f1c | Ruby | glowf/precourse | /workbook/IntermediateQuestions/Quiz1/Ex7.rb | UTF-8 | 242 | 3.421875 | 3 | [] | no_license | def fib(first_num, second_num,limit)
while second_num < limit
sum = first_num + second_num
first_num = second_num
second_num = sum
end
sum
end
result = fib(0, 1,15)
puts "result is #{result}"
#limit was outside the scope
| true |
d5f8ce5cc7da099ce5a1bcde1bf74ff4667c3cf5 | Ruby | miyakz1192/neutron_tools | /rabbitmq/model.rb | UTF-8 | 3,272 | 2.921875 | 3 | [] | no_license | require 'rabbitmq/http/client'
require 'json'
require 'ostruct'
module RabbitModel
class Model < OpenStruct
end
class Channel < Model
end
class Queue < Model
end
class Consumer < Model
end
class Binding < Model
end
class Host < Model
#== source_port_process
#this method returns process that opens tcp connec... | true |
e0520e3ebf4f98cf24138a96ccaff74d11e5a693 | Ruby | aravindmp1/hash | /rep.rb | UTF-8 | 364 | 3.6875 | 4 | [] | no_license | class Array
def initialize(string)
@string=string
end
def array
array=string.split
l=array.length
n=l-1
for i in 0..n
m=0
a=array[i]
array.each do |x|
if x==a
m+=1
end
end
puts "#{array[i]}=#{m}"
end
end
end
string1=gets
... | true |
049eb0c5be07f438708928d7fdc98d457ad70d71 | Ruby | zseero/Misc | /Haxor.rb | UTF-8 | 1,350 | 3.6875 | 4 | [] | no_license | def lotsOfNums
while true
puts Random.rand(0..(10000 ** 15))
end
end
def binary
while true
printf(Random.rand(0..1).to_s)
end
end
class Stream
def initialize count, width
@width = width
@sprites = []
count.times do @sprites << Random.rand(0..@width) end
end
def update
@sprites.map! do |sprite|
... | true |
efd6fd25c8442490adf2fbb8a853fd0c0b328d8a | Ruby | hortencia718/programming-univbasics-nds-nested-arrays-iteration-lab-part-2-nyc04-seng-ft-071220 | /lib/iteration_with_loops.rb | UTF-8 | 1,019 | 3.5625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
def find_min_in_nested_arrays(src)
new_array =[]
count = 0
while count < src.length do
inner_count = 0
low_value = 100
while inner_count < src[count].length do # checking if the inner count is one less than the inner array.
if src[count][inner_count] < low_value # compare
... | true |
0e7cd161a40820467e213d82e5fe55e9a95b03ff | Ruby | donjego/DevBootcamp | /test.rb | UTF-8 | 2,411 | 4.03125 | 4 | [] | no_license | vogels = [
{"name" => "Havik", "price" => 200},
{"name" => "Adelaar", "price" => 500},
{"name" => "Merel", "price" => 100},
{"name" => "Parkietje", "price" => 50}
]
def choose_bird_type
puts "Fill in the item number of the bird you want to buy (1-4)"
bird_type = gets.chomp.to_i
if bird_type <0 || bird_type >3
... | true |
52b23162a7a937b9e8d0bf8696640567454d63ba | Ruby | dshcheung/WDI_HK_11 | /06-ruby/ruby-oop-classes/examples/rpg.rb | UTF-8 | 1,532 | 3.96875 | 4 | [] | no_license | class Human
attr_writer :weapon
def initialize hp, mp
@hp = hp
@mp = mp
end
def attack
if @weapon.nil?
"I punch enemy with my fists."
else
"I attack with my #{@weapon}."
end
end
def defend
"I block attacks with my bare arms."
end
end
class Knight < Human
attr_writ... | true |
d1f8d64ee95a604abf14349231efd0a05220fb5f | Ruby | Xiaohong-Deng/ticketee | /app/models/state.rb | UTF-8 | 331 | 2.546875 | 3 | [] | no_license | class State < ActiveRecord::Base
# should I set a class variable @@default and update it
# each time make_default is called to get a better performance?
def self.default
find_by(default: true)
end
def to_s
name
end
def make_default!
State.update_all(default: false)
update!(default: true)... | true |
efb660c582ee36b9905a0e83f82555c60042ab78 | Ruby | Jewgonewild/project-yves | /lib/bmark.rb | UTF-8 | 3,127 | 3.390625 | 3 | [] | no_license | require 'benchmark'
# open Integer class adding the methods
class Integer
def one_bits
self.to_s(2).chars.inject(0) {|sum, c| c == "1" ? sum + 1 : sum}
end
def three_bits
sum = 0
self.to_s(2).each_char {|c| sum += 1 if c == "1" }
sum
end
def count_bits
self.to_s(2).count("1")
end
d... | true |
16508e86bb7a9ce6d3a5623ee504ccf911f96e96 | Ruby | KarthikJagadish/LearningRuby | /freeCodeCamp.org/Ruby/6BuildingCalculator.rb | UTF-8 | 549 | 4.75 | 5 | [] | no_license | puts "Enter a number: "
num1 = gets.chomp() # gets.chomp().to_f / gets.chomp().to_i
puts "Enter another number"
num2 = gets.chomp() # gets.chomp().to_f / gets.chomp().to_i
puts (num1 + num2) # if num1 = 2 and num2 = 5, Ruby would just print out 25 - as it will treat the user input as strings, no matter what number the... | true |
a03e8a0918195d0f430fe606240f9f773c41aa18 | Ruby | lishulongVI/leetcode | /ruby/647.Palindromic Substrings(回文子串).rb | UTF-8 | 2,301 | 4.03125 | 4 | [
"MIT"
] | permissive | =begin
<p>
Given a string, your task is to count how many palindromic substrings in this string.
</p>
<p>
The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.
</p>
<p><b>Example 1:</b><br />
<pre>
<b>Input:</b> "abc"
<b>Output:</b> 3
<b>... | true |
acffa2235b29419fe60c8875b7ffa9fc4064c24f | Ruby | Kysariin/learn-co-sandbox | /aboutme.rb | UTF-8 | 710 | 4.0625 | 4 | [] | no_license | # fill in the blank of a method vvvvvvv
# def aboutme(your_name, your_place, your_age, your_fun)
# puts "Your name is #{your_name}"
# puts "You grew up in #{your_place}"
# puts "You are #{your_age} years old"
# puts "Your favorite food is #{your_fun}"
# end
# aboutme("Kate", "St. Paul", "14", "sushi")
# this is a... | true |
363f481d1ca79f3e7044e148428e526219f7c489 | Ruby | simonjamain/designexporter | /helpers/anteriorityCheck | UTF-8 | 838 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require 'optparse'
files = {}
optionParser = OptionParser.new do|options|
options.banner = "Usage: anteriorityCheck [options]\nReturn 1 if specified anteriority is not met"
options.on('-o', '--old OLD_FILE', 'mandatory : specify which file should be older than the... | true |
54f2a181af0d623eb23cbbad1cd04bf299d18f3e | Ruby | hkee/sinatra-board | /app.rb | UTF-8 | 1,671 | 2.59375 | 3 | [] | no_license | gem 'json', '~> 1.6'
require 'sinatra'
require 'sinatra/reloader'
require 'bcrypt'
require './model.rb'
before do
p '***************************'
p params
p '***************************'
end
get '/' do # routing, '/' 경로로 들어왔을 때
send_file 'index.html' # index.html 파일을 보내줘
end
get '/lunch' do # '/lunch' 경로로 들어왔... | true |
16558b1aa47ff7accfc596de00c5a63c102024d3 | Ruby | JosefHartsough/COVID-19-Prediction | /jupyter/graph_data/convert_areas.rb | UTF-8 | 1,720 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
ARGV.each do|a|
puts "Argument: #{a}"
if File.exist?(a)
contents = File.read(a);
bak = a + '.bak'
File.rename(a, bak)
contents = contents.lines.to_a
contents = contents.map do | line |
line = line.chomp! + "\n"
unmodified_line = line
line.gsub!(" ", "_") if ... | true |
679b357ecb39b6efef0aef68b9293c1ed9f50040 | Ruby | hulkfu/ruby-study | /params.rb | UTF-8 | 511 | 3.71875 | 4 | [] | no_license | def my_method( a='Testing', b='this', c='feature' )
puts "#{a} #{b} #{c}"
end
my_method
my_method( 'Trying out' )
my_method( 'Testing', 'this great' )
def hello(*params)
params.each do |param|
puts param
end
puts params
end
hello "hi","d"
##
# 最后一个参数可以是hash
def hi(options={})
name = options[:name]
... | true |
66f9ff64de8dc4099380914c82089c3da946cf85 | Ruby | twarbelow/backend_module_0_capstone | /day_4/exercises/methods.rb | UTF-8 | 928 | 4.65625 | 5 | [] | no_license | # In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# `ruby day_4/exercises/methods.rb`
# Example: Write a method that when called will print your name:
def print_name
p "Taija Warbelow"
end
print_name
# Wr... | true |
1705be30e86fee07730591b8c732e9f115329318 | Ruby | Kotauror/Tic_Tac_Toe_8th_Light | /lib/Computer.rb | UTF-8 | 1,680 | 3.46875 | 3 | [] | no_license | require_relative 'player'
require_relative 'board'
class Computer < Player
def elaborate_move(board, opponent_sign)
sleep(1)
position = pick_5_when_possible(board)
if position == nil then
position = pick_winning_position(board)
if position == nil then
position = block_opponent(board,... | true |
512888504516a4caa23be569192f77c412a2fd5e | Ruby | raresdragusSV/RailsAntipatterns | /01_Models/04_Duplicate_Code_Duplication/02_Write_a_Plugin/models/car.rb | UTF-8 | 286 | 2.703125 | 3 | [] | no_license | class Car < ActiveRecord::Base
validates_presence_of :direction, :speed
def turn(new_direction)
self.direction = new_direction
end
def brake
self.speed = 0
end
def accelerate
self.speed = [speed + 10, 100].min
end
# Other, car-related activities ...
end
| true |
25539de13a8c8b9bc698d6d981880aa24f071c64 | Ruby | Tonyjlum/prime-ruby-prework | /prime.rb | UTF-8 | 125 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(num)
return false if num < 2
(2...num).each {|el| return false if num % el == 0}
true
end
| true |
309342bf0f5d6f95f8672f7cf6dd6f05aeeb3e5f | Ruby | Roeck/ruby-music-library-cli-v-000 | /lib/music_library_controller.rb | UTF-8 | 3,027 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicLibraryController
attr_accessor :path
def initialize(path = './db/mp3s')
@path = path
path_import = MusicImporter.new(path)
path_import.import
end
def call
input = ""
puts "Welcome to your music library!"
until input == "exit"
puts "To list... | true |
faa653489af8219892d0263721dce545c79f622c | Ruby | kopylovvlad/hamdown_core | /lib/hamdown_core/cli.rb | UTF-8 | 551 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'optparse'
require_relative 'version'
module HamdownCore
module Cli
def self.call(argv)
file_name = OptionParser.new.tap do |parser|
parser.version = VERSION
end.parse!(argv).first
if file_name.nil? || file_name.size == 0
puts 'Error: No fi... | true |
fc35af653c5c3f4905258d6ae68f4b0f51a16fac | Ruby | jhartwell/ironruby | /Tests/Experiments/Scope/LocalsAndClosures.rb | UTF-8 | 914 | 3.546875 | 4 | [] | no_license | def visibility
x = 1
1.times { |i|
z = x + i
1.times { |j|
w = z + j
}
puts w rescue puts $!
}
puts z rescue puts $!
end
def init
5.times { |i|
if i == 0
x = 1
else
x = (x.nil? ? 0 : x) + 2
end
puts x
}
end
def closure
p = []
... | true |
cdeeebefeb66174d7d9c7680df852c6f52db4df5 | Ruby | philipecasarotte/TiAna | /vendor/plugins/restful-authorization/generators/authorized_generator_helpers.rb | UTF-8 | 1,003 | 2.53125 | 3 | [
"MIT"
] | permissive | module AuthorizedGeneratorHelpers
def insert_content_after(filename, regexp, content_for_insertion, options = {})
content = File.read(filename)
options[:unless] ||= lambda {false }
# already have the function? Don't generate it twice
unless options[:unless].call(content)
# find the line that h... | true |
612c53c779425da4b76aad7b6498e5ddf1bde55d | Ruby | gamboltok/rubybeginner | /nasledovanie.rb | UTF-8 | 265 | 3.59375 | 4 | [] | no_license | class Car
def color_and_fuel(color, fuel)
@color = color
@fuel = fuel
puts "color is #{color}, fuel is #{fuel}"
puts
end
end
class Boat < Car
end
boat = Boat.new
puts "#{boat.color_and_fuel("black", 100)}" | true |
c04da9206c0fb2ee93a42da760676e23c69e0bf9 | Ruby | pekellogg/ttt-9-play-loop | /bin/play | UTF-8 | 239 | 3.4375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "../lib/play"
# initialize board, welcome user, display empty board
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
puts "Welcome to Tic Tac Toe!"
display_board(board)
# begin game
play(board)
| true |
cd502236129a9eb2d49c2c080335a9d0283cc8f1 | Ruby | Kyodex/Parsing | /all_incubator.rb | UTF-8 | 433 | 2.53125 | 3 | [] | no_license | require "nokogiri"
require"open-uri"
def get_all_incubator (web_site)
page = Nokogiri::HTML(open(web_site))
for i in (1..30)
page.xpath("//tr[#{i}]/td[1]/strong").each do |incubator|
inc = incubator.text
puts inc
end
end
end
get_all_incubator("https://lentreprise.lexpress.fr/creatio... | true |
77bff4577aa282cd8d0aa30f5e9624249761ed56 | Ruby | hadarhaviv/budget_system | /Account.rb | UTF-8 | 1,164 | 3.265625 | 3 | [] | no_license | require "json"
require "./FileUtilities.rb"
class Account
attr_accessor :records
attr_reader :balance
def initialize(name, balance)
@name = name
@balance = balance
@records = get_records
end
def get_records
if !FileUtilities.load("records").nil?
FileUtilities.load("records")[:records]... | true |
af3ec1ab85478d2bdc24afcdf20c6eef3df14312 | Ruby | 1tsGurpreet/Website-Analysis-Project | /cse-135.site/public_html/cgi-bin/ruby-general-request-echo.rb | UTF-8 | 680 | 2.8125 | 3 | [] | no_license | #!/usr/bin/ruby
require 'cgi'
cgi = CGI.new
print cgi.header
print "<html>"
print "<head>"
print "<title>General Request Echo</title>"
print "</head>"
print "<body>"
print "<h1>General Request Echo</h1>"
print "<b> Protocol: </b>"
print(ENV["SERVER_PROTOCOL"])
print "<br></br>"
print "<b> Method: </b>"
print(ENV["RE... | true |
64fad7a84dc7130bdb43e4213d68fb2ada12a0c3 | Ruby | sharon-tickell/thing | /app/lib/pennsic.rb | UTF-8 | 489 | 2.71875 | 3 | [] | no_license | class Pennsic
def self.year
Time.now.year - 1972 + 1
end
def self.as
'LI'
end
def self.calendar_year
Time.now.year
end
def self.dates
(Date.parse('2016-07-29')..Date.parse('2016-08-14')).to_a
end
def self.dates_formatted
dates.map(&:to_s)
end
def self.class_dates
(Date... | true |
4d6e642a6c491cae882819b22acdb95a43bd14b8 | Ruby | pzol/monadic | /lib/monadic/try.rb | UTF-8 | 517 | 2.953125 | 3 | [
"MIT"
] | permissive | module Monadic
## Wrap a block or a predicate to always return Success or Failure.
## It will catch StandardError and return as a Failure.
def Try(arg = nil, &block)
begin
predicate = arg.is_a?(Proc) ? arg.call : arg
return Either(block.call) if block_given? && predicate.nil?
return Either(p... | true |
5b0741be6903697aed43d097fc351125377a7d39 | Ruby | danielacodes/ruby-exercises | /moving_average.rb | UTF-8 | 470 | 4.15625 | 4 | [] | no_license | # Program which takes array and range and
# returns new array which contains moving average
def moving_average(array,range)
average = Array.new
sum = 0
array.each_with_index do |a,i|
sum += a
if (i>=range)
sum -= array[i-range]
end
if (i<range)
average << (sum/(i+1))
else
... | true |
2437cff68d375ad7d51b85d3cf2e6d3ea1b5bee3 | Ruby | meetcleo/postgres_to_redshift | /lib/postgres_to_redshift/column.rb | UTF-8 | 2,069 | 2.609375 | 3 | [
"MIT"
] | permissive | module PostgresToRedshift
class Column
DEFAULT_PRECISION = 19 # 99_999_999_999_999_999.99
DEFAULT_SCALE = 2
CAST_TYPES_FOR_COPY = {
'text' => 'CHARACTER VARYING(65535)',
'json' => 'CHARACTER VARYING(65535)',
'jsonb' => 'CHARACTER VARYING(65535)',
'bytea' => 'CHARACTER VARYING(6553... | true |
bfa3b82b4025df21503f680e0a98116dc86f08f7 | Ruby | namusyaka/sinatra-bind | /test/bind_test.rb | UTF-8 | 2,354 | 2.546875 | 3 | [
"MIT"
] | permissive | $:.unshift(File.dirname(__FILE__))
require 'helper'
describe Sinatra::Bind do
describe "basic usage" do
it "can define a route" do
mock_app do
def hello; "Hello World" end
on "/", to: :hello
end
get '/'
assert_equal 'Hello World', last_response.body
end
it "can de... | true |
5e20e547bcc197c418e6205fd57cbd41c9ab48a6 | Ruby | outragedpinkracoon/advent_of_code_2020 | /day_9/part_2_spec.rb | UTF-8 | 772 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
require 'rspec'
require_relative 'part_2'
RSpec.describe do
it 'returns the correct value when the sample is exactly the answer set' do
input = File.readlines('sample_3.txt')
expect(Part2.run(input, 127)).to eq([62])
end
it 'returns the correct value when it has to iterate... | true |
567bc49d617ae59bc87b8139ee4f72ae852bc3ab | Ruby | bfitch/Dollars | /app/models/current_period.rb | UTF-8 | 438 | 2.875 | 3 | [] | no_license | class CurrentPeriod < Struct.new(:schedule)
def as_range
Range.new(*dates)
end
def dates
[start.to_date, stop.to_date]
end
private
def start
Occurence.new schedule.previous_occurrence(today)
end
def stop
Occurence.new schedule.next_occurrence(today)
end
def today
@today ||... | true |
db638ebe051c43b6396f78c58ce83013b26155c2 | Ruby | madking55/ruby_exercises | /command-query/exercises/kid.rb | UTF-8 | 361 | 3.359375 | 3 | [] | no_license | class Kid
attr_reader :grams_of_sugar_eaten
def initialize
@grams_of_sugar_eaten = 0
@hyperactive = false
end
def eat_candy
@grams_of_sugar_eaten += 5
end
def hyperactive?
@hyperactive = true if @grams_of_sugar_eaten >= 60
@hyperactive ? "OK, now the kid is hyperactive." : "Not hypera... | true |
f58890beb1eadefeedfb340d30b816643ef97e10 | Ruby | SamaNaEz/Infix-to-Postfix-Converter-and-Calculator | /calculator.rb | UTF-8 | 1,169 | 3.6875 | 4 | [
"MIT"
] | permissive | class Calculator_v2
attr_reader :oper
def initialize
@oper = {
'+' => 1,
'-' => 1,
'*' => 2,
'/' => 2,
'%' => 3,
'**' => 3
}
end
def infix_to_postfix(infix)
stack = []
postfix = []
stack_value = 0
infix_value = 0 # not necessary
infix.spli... | true |
099a79b75b27f2038be4b34027c77c75817a7e63 | Ruby | themarshallproject/pony | /app/lib/merge_tag.rb | UTF-8 | 205 | 2.859375 | 3 | [
"MIT"
] | permissive | class MergeTag
def self.recognize(text)
re = /\*\|([A-Z_0-9:]+)\|\*/
# the first capture group is the tag name, so &:first unwraps `[val]` to `val`
text.scan(re).map(&:first).uniq
end
end
| true |
0c2628b1b4b55760df5312cb3efc52fe176890fd | Ruby | unifide/unifide | /www/json_reply.rb | UTF-8 | 5,612 | 2.859375 | 3 | [] | no_license | require 'json'
require 'model'
class JSONReply
def self.write_project(user, project_name, hm)
project = Project.find_by_short_name project_name
if !project.nil?
#The project exists
if user_can_write_project? user, project
#The user can write to the project
yield project
e... | true |
e6cfc135bebe180b6303f82e8cac7ab91bc7337e | Ruby | cannaryo/reallen | /src/calc_coverage.rb | UTF-8 | 1,529 | 2.8125 | 3 | [
"MIT"
] | permissive | #! /usr/bin/ruby
#
# calc_coverage.rb
#
# Copyright (c) 2016 - Ryo Kanno
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
require "optparse"
Version="1.1.2"
banner = "Usage: calcCoverage.rb [option] <input BED file> <original BAM file>\n+calculate coverage at eac... | true |
25f28813e8a4075c3de68fa6f2d53a1514594272 | Ruby | Br-ribeiro/Teste_e_Qualidade_de_Software | /modulo_para_numero/2018-1/elisson/moeda_spec.rb | UTF-8 | 1,754 | 3.109375 | 3 | [] | no_license | require_relative '../../moeda'
describe 'Moeda' do
include Moeda
describe '#numero_para_moeda' do
context 'usando valores padrões' do
it "formata corretamente um inteiro" do
expect(numero_para_moeda(2000)).to eq('R$2.000,00')
end
it "formata corretamente um float" do
expect(nu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.