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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
43267821f772f3fe73c53986022b5dc50a7c80b4 | Ruby | cmaher92/launch_school | /exercises/review/max_rotation.rb | UTF-8 | 821 | 4 | 4 | [] | no_license | require 'pry'
require_relative 'digit_rotation'
# input: n (int)
# output: n_rotated (int)
# rules:
# - with each subsequent rotation another digit from LTR is becomes 'fixed'
# in place and is no longer part of future rotations.
# - in some cases leading 0's will get dropped 105 -> 15
# algorithm:
# 1. initialize c... | true |
6e332b3926b24b6db4ff5009d075a4732fbf4698 | Ruby | usnationalarchives/federalregister-web | /lib/federal_register_stats.rb | UTF-8 | 1,782 | 2.71875 | 3 | [] | no_license | class FederalRegisterStats
attr_reader :beginning_of_month,
:beginning_of_year,
:date,
:end_of_month,
:launch_date
def initialize(date, env='production')
#site launched on this day - no stats make sense before this
@launch_date = Date.parse('2010-07-26')
@date = Date.parse(date)
@b... | true |
fac10448ab4787db1a68ffce0fc6129d8a551454 | Ruby | mikelaurence/blinky-jam | /blinky.rb | UTF-8 | 755 | 2.9375 | 3 | [] | no_license | require 'serialport'
require 'paint'
module Blinky
class Serial
def initialize(port = '/dev/tty.usbmodemfa141')
@serial = SerialPort.new(port, 115200)
raise "Cannot connect to #{port}" if @serial.nil?
@serial.flush
end
def pixel(color)
@serial.write color.data
sleep 0.00... | true |
76ed894e6a05b5a0a9855e360caf75cfb92fc089 | Ruby | TyMazey/sweater_weather | /app/services/darksky_service.rb | UTF-8 | 439 | 2.609375 | 3 | [] | no_license | class DarkskyService
def forecast(lat, long)
get_json(forecast_request(lat, long))
end
private
def forecast_request(lat, long)
conn.get("#{lat},#{long}") do
end
end
def get_json(response)
JSON.parse(response.body, symbolize_names: true)
end
def conn
Faraday.new("https://api.dark... | true |
c5e5b217430cb6e2ae13065d98bba1d5226af922 | Ruby | vadim-geroim/fibonacci | /lib/fibonacci.rb | UTF-8 | 302 | 3.46875 | 3 | [] | no_license | def iterative_fib(n)
return 0 if n == 0
return 1 if n == 1
sequence = [] << 0 << 1
for i in 2..n
res = sequence[i - 1] + sequence[i - 2]
sequence << res
end
sequence.last
end
def recursive_fib(n)
if n < 2
n
else
recursive_fib(n - 1) + recursive_fib(n - 2)
end
end
| true |
1d4cc975443b917d285f895f3073c4082c40bf4b | Ruby | samuelgustave/learnRubyHardWay | /exercise36.rb | UTF-8 | 1,956 | 4.34375 | 4 | [] | no_license | # Exercise 36 : The Caesar Palace
# Caesar's Office
def caesar
puts "Good! Now your're in Caesar's office."
puts "You Win!"
exit(0)
end
def ask(question)
arr = question.split('\n')
arr.each {|qu| puts qu }
print "> "
end
# if good answer
def oracle
question = <<-FOO
This is the oracle room.
The... | true |
daffd83894ddbec85099c27e8cba0d7f4e2ca779 | Ruby | tansaku/boris-bikes-1 | /lib/docking_station.rb | UTF-8 | 279 | 3.078125 | 3 | [] | no_license | class DockingStation
DEFAULT_CAPACITY = 20
def initialize
@bikes = []
end
def bike_count
@bikes.length
end
def dock bike
@bikes << bike
end
def release bike
@bikes.delete bike
end
def full?
@bikes.length >= DEFAULT_CAPACITY
end
end
| true |
729db9d0d4047702e5943d70d05ddcc0d5d6f36d | Ruby | CarlosCabreraM/TallerObjetosIII | /ejercicio3.rb | UTF-8 | 434 | 3.375 | 3 | [] | no_license | class Vehicle
def initialize(model, year)
@model = model
@year = year
@start = false
end
def engine_start
@start = true
end
end
class Car < Vehicle
@@counter = 0
def initialize
@@counter += 1
end
def self.show_counter
... | true |
e8aa4c36ed59e8e5389deca1c78f5d4fe5dc72d9 | Ruby | luiscaciatori/ruby-exercism | /acronym/acronym.rb | UTF-8 | 172 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
module Acronym
def self.abbreviate(phrase)
phrase
.split(/[\W]+/)
.map { |word| word[0].capitalize }
.join
end
end
| true |
74366aa62bf9f0c7fe17ed0602c68ee9c23e7c18 | Ruby | rkuang/ruby-mastermind | /mastermind.rb | UTF-8 | 839 | 3.890625 | 4 | [] | no_license | require_relative "code"
class Mastermind
MAX_ATTEMPTS = 12
def initialize()
@secret_code = Code.new()
@attempts = 0
puts "Enter 4 digits between 0 and 5, inclusive."
while @attempts < Mastermind::MAX_ATTEMPTS do
print "Attempt ##{@attempts+1}:\t"
begin
... | true |
2510f6bd54feae07d0d930905bdcb036b4e9acef | Ruby | GraderUN/Solicitudes | /app/concerns/json_web_token.rb | UTF-8 | 378 | 2.671875 | 3 | [] | no_license | class JsonWebToken
SECRET = Rails.application.secrets.secret_key_base.to_s
def self.encode(payload, exp = 15.minutes.from_now)
payload[:exp] = exp.to_i
token = JWT.encode(payload, SECRET)
[token, exp]
end
def self.decode(token)
payload = JWT.decode(token, SECRET).first... | true |
aae5b6cbb1a7bd7043c0c3e45ce69130c6ce22e4 | Ruby | Dm1trySt/notepad | /read.rb | UTF-8 | 1,980 | 3 | 3 | [] | no_license | require_relative 'post.rb'
require_relative 'memo.rb'
require_relative 'link.rb'
require_relative 'task.rb'
#id, limit, type
require 'optparse'
#Все наши опции будут записаны сюда
options = {}
# Вывод информации по ключу -h
OptionParser.new do |opt|
opt.banner = 'Usage: read.rb [options]'
opt.on('-h', 'Prints... | true |
2ace797a0de6a03e5677495ca29016ffcab9c04a | Ruby | smellslikekeenspirit/swen-250-assignments | /GitMetrics/git_metrics.rb | UTF-8 | 1,949 | 3.5625 | 4 | [] | no_license | # Script that obtains various git metrics from a basic git log file
require 'set'
require 'date'
# Given an array of git log lines, count the number of commits in the log
def num_commits(lines)
num = 0
lines.each{ |line| num+=1 if line.start_with?("commit")}
num
end
# Given an array of git log lines, count the... | true |
f9ddcc4c38281a8f3967e28d64405807ad9bd908 | Ruby | vesan/herkko | /lib/herkko/travis.rb | UTF-8 | 1,107 | 2.90625 | 3 | [
"MIT"
] | permissive | # travis login --pro
# travis history -l1 -bmaster
module Herkko
# Checks status of CI build from Travis.
class Travis
def status_for(branch)
if travis_cli_installed?
status = fetch_status(branch)
status_to_code(status)
else
Herkko.info "Travis CLI has not been installed, run... | true |
b86d8f95d66315a111cb003f2819c980af40379f | Ruby | sarakhandaker/ruby-oo-object-relationships-has-many-through-lab-seattle-web-030920 | /lib/song.rb | UTF-8 | 210 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_reader :name, :artist, :genre
attr_accessor
@@all=[]
def initialize(name, artist, genre)
@name=name
@artist=artist
@genre=genre
@@all<<self
end
def self.all
@@all
end
end
| true |
2deb2efeb3c97e839a1aba13c4a3af78f163dec0 | Ruby | jedgil/ruby | /preschooler_everyday.rb | UTF-8 | 108 | 2.96875 | 3 | [] | no_license | age = 3
while age < 6 do
puts "daddy...(INSERT QUESTION)?"
answer = gets.chomp
puts answer + "?"
end
| true |
9336739c0bf9de155629e044439fe073cf70d20b | Ruby | anderslime/kursusbasen | /lib/text_data_extractor.rb | UTF-8 | 614 | 3.09375 | 3 | [] | no_license | class TextDataExtractor
attr_reader :page
def initialize(page)
@page = page
end
def content
extract(:content)
end
def course_ojectives
extract(:course_objectives)
end
def litteratur
extract(:litteratur)
end
def remarks
extract(:remarks)
end
private
def extract(title_... | true |
b792432a38906c68e00c7997196f87be06fa489f | Ruby | nobody0891/learning | /request.rb | UTF-8 | 579 | 3.15625 | 3 | [] | no_license | require 'socket'
HTTP_PORT = 80
HTTPS_PORT = 443
$r = {get: "GET",put:"PUT",post: "POST"}
$res = {index: "/"}
class Connection
def initialize(host)
@host = host
@s = TCPSocket.new @host,HTTP_PORT
end
def get(location = nil)
if location
@@location = location
else
@@location = $res[:index]
end
... | true |
f6ac10802c612549883f976b38a7569c3fffb1e3 | Ruby | ajitsing/data_verifier | /lib/data_verifier/validator.rb | UTF-8 | 2,884 | 2.625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'sequel'
require 'axlsx'
module DataVerifier
class Validator
def initialize(report_name = 'data_verifier')
@report_name = report_name
@excel = Axlsx::Package.new
end
def validate_using(config)
db = create_db_connection(config)
config.queries.each do |tag, ... | true |
2c131ebc4d6673d02bfa4cfe505b816f45a60e57 | Ruby | paulo-guerin/ExercicesSemaine0Vendredi | /exo_21.rb | UTF-8 | 317 | 3.34375 | 3 | [] | no_license | puts "Wesh tappe un nombre entre 1 et 25 et tu verras une super pyramide apparaitre"
print ">"
num = gets.chomp.to_i
hash = "#"
space = " "
i = 1
loop do
if num >=1 && num!=i && num<=25
puts "#{space*(num-i-1)} #{hash * i}"
i = i +1
else puts "#{hash * i}"
break
end
end | true |
7afad473b78e8e228c76971fce5c3705be7447ae | Ruby | joshidhruv/Aura-Rails-Web-app | /spec/controllers/addons_controller_spec.rb | UTF-8 | 5,910 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... | true |
289dcfd407d596ce8a6436eb85f071a05fcb8190 | Ruby | anasdima/programming-projects | /Ruby/Database-random-population-script/random-db-population.rb | UTF-8 | 4,358 | 2.59375 | 3 | [] | no_license | # encoding: UTF-8
require 'tiny_tds'
client = TinyTds::Client.new username: 'Main\Tasos', password: 'password', host: 'localhost', database: 'HMMYStat'
start_time = Time.now
result = client.execute("SELECT Id,Semester FROM Students")
students = result.each
result.cancel
students.each do |s|
#generate a ran... | true |
4e9e21ba6917f389a082e67a79a69ced7f6ecfb5 | Ruby | YuliyaPelekh/scraping_websites | /facebook_scrape.rb | UTF-8 | 511 | 2.65625 | 3 | [] | no_license | require 'capybara'
class FacebookParser
include Capybara::DSL
Capybara.default_driver = :selenium
def log_in
visit "http://www.facebook.com/jpelekh"
fill_in 'email', :with => 'jpelekh@mail.ru'
fill_in 'pass', :with => 'Julka32'
click_button 'u_0_0'
end
def search #searches for facebook fr... | true |
6de59ac1d805f49257aadedc86339310d1fc76be | Ruby | Cl3arglass/school-domain-v-000 | /lib/school.rb | UTF-8 | 566 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_reader :name, :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(name, grade)
@roster[grade] ||= []
@roster[grade] << name
end
def grade(num)
@roster[num]
end
def sort
@roster.each do |key, value|
@roster[key] = @roster[key].sort
end
@roster
end
end
#... | true |
cc5c3e3166f6310ed1160a5f390d6d0babdb3fe8 | Ruby | marcosbitetti/Wild-Witch-Project-A.I.-Bot | /terminal.rb | UTF-8 | 2,200 | 3.46875 | 3 | [] | no_license | require 'rubygems'
require File.expand_path(File.dirname(__FILE__)) + '/check'
require File.expand_path(File.dirname(__FILE__)) + '/remoteconfig'
#######
#
# Tela
# Classe especial de gerenciamento. Implementa um pequeno programa
# de controle e monitoramento. Sua interface serve para uso via SSH
# Mas foi preparada ... | true |
7dbf5e8e155d1396fefb7ffef0a5928542fcbd05 | Ruby | jmoore315/odin-project | /oop_ruby_projects/mastermind/spec/board_spec.rb | UTF-8 | 3,856 | 3.21875 | 3 | [] | no_license | require './spec_helper'
describe Board do
before :each do
@board = Board.new
end
describe "#new" do
it "returns a new Board object" do
@board.should be_an_instance_of Board
end
it "should take no parameters" do
lambda { Board.new "param" }.should raise_exception ArgumentError
end
it "should... | true |
994e81d985901e1b4d732e748906273b1d17e5ea | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz121_sols/solutions/Paul/morse_code.rb | UTF-8 | 962 | 3.40625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
# a lazy way to convert pasted-on text from problem into a Hash
$morse = Hash[*%w{
A .- N -.
B -... O ---
C -.-. P .--.
D -.. Q --.-
E . R .-.
F ..-. S ...
G --. T -
H .... | true |
98535950bf6dcbea9da478e256453061b5e69f97 | Ruby | 17021084/Ruby-ben-kyou-shi | /exception.rb | UTF-8 | 681 | 2.8125 | 3 | [] | no_license | def retry_to_call(retry_times, &block)
block.call
rescue Exception => e
if retry_times > 0
p 'gặp Ngoại lệ và retry lần: ' + retry_times.to_s
retry_times -= 1
retry
else
p 'Hết số lần retry!'
# raise e
end
else
p 'đoạn code naỳ chạy khi ko co bat ki ngoại lệ nào xảy ra '
ensure
p 'Co... | true |
37a84d063723695508d3e4e4cf0a817455d97a7c | Ruby | williamv/learning-ruby-the-hard-way | /ex4.rb | UTF-8 | 1,294 | 4 | 4 | [] | no_license | cars = 100 #creating a variable called cars and assigning it the value 100
space_in_a_car = 4 #creating a space variable and assigning it a floating point number of 4
drivers = 30 #drivers variable assigned the value 30
passengers = 90 #passengers variable assigned the value 90
cars_not_driven = cars - drivers #variab... | true |
ddb2fb904a88a502654e8b97dce5ec4e4566fced | Ruby | zenglue/ruby-inheritance-lab-wdf-000 | /lib/user.rb | UTF-8 | 241 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class User
attr_accessor :first_name, :last_name, :new
def intialize(first_name, last_name)
@first_name = name
@last_name = name
@new = new_student
end
def new_student
@new = "#{first_name} #{last_name}"
end
end
| true |
c2793ac42359cfde28bff5e538288ceaa201ca15 | Ruby | alfa-jpn/BotHeaven | /app/models/bots/apis/http.rb | UTF-8 | 1,213 | 2.859375 | 3 | [
"MIT"
] | permissive | module Bots::Apis
# HTTP API class of Bot.
class HTTP
# Initialize class.
# @param [Bot] bot instance of bot.
def initialize(bot)
@bot = bot
end
# Get request.
# @param [String] url URL.
# @param [Hash] params Params.
# @param [String] callback Name of callback.
#... | true |
d947109b7507ae22353169053fc70e1d7b1b1798 | Ruby | mengledowl/job_hackability | /app/helpers/interviews_helper.rb | UTF-8 | 304 | 2.59375 | 3 | [] | no_license | module InterviewsHelper
def scheduled_at(interview)
time_ago = time_ago_in_words(interview.scheduled_at.in_time_zone(interview.time_zone))
"#{time_ago} #{future_or_past_word(interview.scheduled_at)}"
end
private
def future_or_past_word(date)
date.future? ? 'away' : 'ago'
end
end
| true |
77bc4d04d146a0295c6ee726052f42a50ef4f9c5 | Ruby | josealejandroberrios/Hack_Lector_RSS- | /notice.rb | UTF-8 | 204 | 2.65625 | 3 | [] | no_license | class Notice
attr_accessor :title, :author, :date, :url
def initialize(title, author, date, url)
@title = title
@author = author
@date = date
@url = url
end
end | true |
a127019342205bad3b6f9fb4669b6fac8d4ccd80 | Ruby | barryirwin/bin | /vim-bundle | UTF-8 | 2,301 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
bundle_path = "~/.vim/bundle"
def usage
puts "usage: vim-bundle <command>"
puts ""
puts " \033[36mlist \033[0m- list all bundles currently installed"
puts " \033[36minstall <github user>/<repository name> \033[0m- installs plugin from github. If no user is specified vim-scripts is used"
pu... | true |
8db7ec50021de031302d9e50863defc659607bf1 | Ruby | mikeebert/ttt-ruby | /lib/command_line_game.rb | UTF-8 | 1,812 | 3.34375 | 3 | [] | no_license | require 'game'
require 'player_factory'
class CommandLineGame
attr_accessor :game, :ui
attr_accessor :player_factory, :player1, :player2
def initialize(ui)
@ui = ui
@game = TTT::Game.new
@player_factory = TTT::PlayerFactory.new
end
def setup_game
@ui.welcome_message
set_playe... | true |
9802ca19edc65c08c471bfd3967a658093ac4eef | Ruby | fumn112026/kangolog | /spec/models/user_spec.rb | UTF-8 | 3,224 | 2.625 | 3 | [] | no_license | require 'rails_helper'
describe User do
describe '#create' do
it "nicknameとemail、passwordとpassword_confirmationが存在すれば登録できること" do
user = build(:user)
expect(user).to be_valid
end
it "nicknameがない場合は登録できないこと" do
user = build(:user, nickname: nil)
user.valid?
expect(user.errors... | true |
cb73dbae033952360b166e6ba1ef1c3dfd3fbe67 | Ruby | nihilence/chess | /pieces/stepping_piece.rb | UTF-8 | 649 | 3.328125 | 3 | [] | no_license | class SteppingPiece < Piece
def moves(pos, directions)
legal_moves = []
pos_x, pos_y = pos
directions.each do |direction|
dx, dy = direction
next_pos = [pos_x + dx, pos_y + dy]
legal_moves << next_pos if is_legal?(next_pos)
end
legal_moves
end
def is_legal?(pos)
# ... | true |
1905e4b11f972e8db1eb0c28b738adfc199b825d | Ruby | rapid7/metasploit-credential | /app/models/metasploit/credential/search/operator/type.rb | UTF-8 | 2,394 | 2.703125 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | # Operator that searches a polymorphic `#type` attribute. Search terms are restricted to set of `Class#name`s and
# `Class#model_name.human` with the `Class#model_name.human` being translated to `Class#name` in the operation returned
# by `#operate_on`.
class Metasploit::Credential::Search::Operator::Type < Metasploit... | true |
23c7bbee334ca46634a9bfdb7da1d4836e66cd7e | Ruby | ikhakoo/elearning | /db/seeds.rb | UTF-8 | 27,287 | 3.15625 | 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 |
82bdd99f2f9edc46f4e6839cc71930c76cb7a033 | Ruby | colinwkingen/ruby_day6 | /lib/new_hash.rb | UTF-8 | 1,393 | 3.25 | 3 | [] | no_license | class NewHash
define_method(:initialize) do
@store = []
end
define_method(:newStore) do |key, value|
@store.push([key, value])
end
define_method(:newFetch) do |key|
@store.each() {|pair| return pair[1] if pair[0] == key}
end
define_method(:has_key?) do |key|
result = false
@store.each(... | true |
59319ad11785ed4fd7282c367479ac3f5d8cdf6b | Ruby | Seva-Sh/RB101 | /watch_others_code/ex3.rb | UTF-8 | 2,356 | 4.53125 | 5 | [] | no_license | =begin
Problem:
- The max sum subarray problem consists of finding the maximum sum of a
contiguous subs in an array of ints
- If array consists of only negative nums return 0!
Empty array -> 0!
-
Input: arr of integers
Output: int
Algorithm:
- Check if we have an empty array or an array that only includes neg... | true |
8bc8eca5e630345e2fec0bbadad13dad9d09d826 | Ruby | Corsomk312/phase-0 | /week-5/gps2_2.rb | UTF-8 | 1,360 | 4.28125 | 4 | [
"MIT"
] | permissive | # Method 1 - Create Grocery List
# #Create and return an empty hash
def create_list
Hash.new
end
# Method 2 - Add item with a quantity to list
# #Input of an item (string), quantity (integer), list
# # Add our item and quantity into our hash
# # print out item and quantity added to list
def add_item... | true |
f440aba2310667ae87911926631951f69d97b38d | Ruby | ivsztorc/w3d2-Homework-Age-Calc. | /main.rb | UTF-8 | 916 | 2.640625 | 3 | [] | no_license | require 'pry-byebug'
require 'sinatra'
require 'sinatra/contrib/all' if development?
get '/home' do
erb :home
end
# get '/age_calculator' do
# erb :age_calculate
# puts "What is the person's date of birth?
# First give the year (YYYY):"
# year = gets.chomp.to_i
# puts "Now the month (MM):"
# month = ge... | true |
f3223153d81e528f1c279cc999741a7d191fffa8 | Ruby | gdeoliveira/ruby_multiton | /lib/multiton/instance_box.rb | UTF-8 | 1,521 | 3.078125 | 3 | [
"MIT"
] | permissive | require "sync".freeze
require "multiton/utils".freeze
module Multiton
##
# InstanceBox is a thread safe container for storing and retrieving multiton instances.
class InstanceBox
##
# call-seq:
# new => new_instance
#
# Returns a new InstanceBox instance.
def initialize
self.hash ... | true |
a4a0d5f2ee39a87c18ee63139d517630b2f32f1a | Ruby | lukaswet/My-Ruby-first-steps | /app1/app12.rb | UTF-8 | 72 | 2.515625 | 3 | [] | no_license | print "Formating C:"
1000.times do
print "."
sleep rand(0.1..0.5)
end
| true |
85497ccb20105539c3c8c487d387c1c4a7839546 | Ruby | mionikwang/kidslib-shuangyu | /utils/iyc_to_csv.rb | UTF-8 | 4,479 | 3.296875 | 3 | [] | no_license |
# ## 使用方法
#
# ruby script.rb input.csv output.csv
#
# 如果不带参数运行,就执行脚本中写死的默认参数
#
# ----
# ## 依赖库
require 'csv'
require 'pp'
require 'fileutils'
# ----
# ## 获取书名
# CSV的格式是
#
# id,zh,en
# "1","一个陌生女人的来信","Letter from an Unknown Woman"
#
# 1. 不要把id对应的数字转为fixnum,要string,因此 converters: nil
# 1. 输入的csv已经处理过... | true |
efb0bd0a0bac4a28b83ffa93ffb3f0398299424d | Ruby | DFE-Digital/early-careers-framework | /app/services/participant_declarations/mark_as_paid.rb | UTF-8 | 539 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module ParticipantDeclarations
class MarkAsPaid
def initialize(statement)
self.statement = statement
end
def call(participant_declaration)
ParticipantDeclaration.transaction do
participant_declaration.make_paid!
line_item = statement
... | true |
9384d4f44b556706d84b5bbc35c11f5784dc28d2 | Ruby | dstrube1/playground | /dojo/bri.k/RomanNumerals/Ruby/04-29-2012 WhiteBelt/roman_numerals.rb | UTF-8 | 988 | 3.65625 | 4 | [] | no_license | class RomanNumerals
@@converter = [[1000,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]]
def toRoman(number)
result = ""
@@converter.each do |arabic,roman|
while(number >= arabic)
result += roman
number -= arab... | true |
6124e55f59f1926dfb70775ad33a59362336616e | Ruby | rah00l/basic_ruby | /q2.rb | UTF-8 | 788 | 3.9375 | 4 | [] | no_license | #For Question 2 create file as q2.rb (Any other file name will not be accepted)
#Write a ruby program to read the given file test.txt. Open the file and print count for:
#a. the number of occurrences of a word “RoR” in a file
#b. the number of spaces in the whole file
#c. the number of lines in file
#Close t... | true |
182da6ec426a53e628e87fa58f3d954e5c708e94 | Ruby | pivotal-cf/bookbinder | /lib/bookbinder/config/checkers/products_checker.rb | UTF-8 | 987 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | module Bookbinder
module Config
module Checkers
class ProductsChecker
MissingProductsKeyError = Class.new(RuntimeError)
MissingProductIdError = Class.new(RuntimeError)
def check(config)
@config = config
if section_product_ids.count > 0
if config.prod... | true |
49a7520632ea12b53f9aac4c60d90c74a3e073d9 | Ruby | vader1359/Bootcamp-Ruby | /week2/lab/lab2-5/app.rb | UTF-8 | 1,368 | 2.796875 | 3 | [] | no_license | require "bundler/setup"
Bundler.require
get "/" do
lines = File.read("todo.data").split("\n")
items = lines.map.with_index do |line, index|
{
status: (line[3] == "x") ? "done" : "undone",
name: line[6..-1],
index: index
}
end
erb :"index.html", locals: {items: items}
end
# This means go t... | true |
ca53a828734f26273413e0e230da8546486d7402 | Ruby | kbaseapps/GenericsAPI | /KBaseExperiments.spec | UTF-8 | 12,617 | 2.53125 | 3 | [
"MIT"
] | permissive | module KBaseExperiments {
/* A boolean - 0 for false, 1 for true.
@range (0, 1)
*/
typedef int bool;
/* Ref to a genome
@id ws KBaseGenomes.Genome
*/
typedef string GenomeRef;
/* Ref to a AmpliconMatrix
@id ws KBaseMatrices.AmpliconMatrix
*/
typedef str... | true |
d8713eaa9f5289a178fba5373a3ae20e0d884c07 | Ruby | PeterCamilleri/ideas | /questions/bdt.rb | UTF-8 | 127 | 3.0625 | 3 | [] | no_license | require 'bytesize'
t = ByteSize.new(1210000000) #=> (1.21 GB)
puts t
t = ByteSize.new("1.1269 GiB") #=> (1.21 GB)
puts t
| true |
420534826883fba52174d4cd5e73f4a91081f2e4 | Ruby | thebravoman/software_engineering_2015 | /hm_count_words/A_21_Nikolay_Danailov/word_counter/file_parser.rb | UTF-8 | 499 | 2.5625 | 3 | [] | no_license | require 'word_counter/parser'
module WordCounter
# Parses files
class FileParser < Parser
def parse(filename)
db_res = get_res_from_for_file filename
unless db_res.nil?
db_res
else
file_contents = File.read(filename)
# makes it work with any encoding
file_cont... | true |
19c1c48c7c08c22334f6e4941a27a93e81ec7f3d | Ruby | kronos/Task-solutions | /codeforces/4xx/464A.rb | UTF-8 | 576 | 3.203125 | 3 | [] | no_license | n, p = gets.split(/\s+/).map(&:to_i)
s = gets.strip
def get_next(s, n, p)
if n == 1
if s[0].ord == p.ord
nil
else
s[0].succ
end
else
q = s[-1] == 'z' ? '{' : s[-1].succ
x = s[0...-1]
begin
while q.ord <= p.ord && (q == x[-1] || q == x[-2])
q = q == 'z' ? '{' : q.s... | true |
4c5f7fb24f03b7a2844d2f903a2319314d116204 | Ruby | twrameshb/frameworks | /Selenium-Ruby-Project2/lib/facebook.rb | UTF-8 | 2,757 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | require 'active_support'
require 'cgi'
require 'net/http'
require 'uri'
class Facebook
attr_accessor :posts
USER_AGENT = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100130 Gentoo Firefox/3.6' # Pretend to be Firefox when requesting the Syndication Feed
BASE_URL = 'http://www.facebook.com... | true |
9c91303f962757492072591d44f7251c9c893a69 | Ruby | jlfernandez/metroroto | /lib/geolocation.rb | UTF-8 | 265 | 2.671875 | 3 | [] | no_license | class Geolocation
def self.geolocate(station="")
puts "Buscando lat long de la estación #{station}"
res = Geokit::Geocoders::GoogleGeocoder.geocode("#{station} metro madrid")
puts res.lat
puts res.lng
return res.lat, res.lng
end
end | true |
74e7739a2c349707cea6ef1cac148c2479bcce59 | Ruby | i-norden/project_euler | /ruby/prob29.rb | UTF-8 | 846 | 3.828125 | 4 | [] | no_license | =begin
Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
22=4, 23=8, 24=16, 25=32
32=9, 33=27, 34=81, 35=243
42=16, 43=64, 44=256, 45=1024
52=25, 53=125, 54=625, 55=3125
If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distin... | true |
9fb7d682202d72a0bf3c316b17dd5d3a09e62924 | Ruby | ncalca/principles-of-programming-languages | /es5/es5.rb | UTF-8 | 1,203 | 3.84375 | 4 | [] | no_license |
class DataStore
UNION = "union_by"
INTERSECT = "intersect_by"
def initialize(store = {})
@store = store
end
def set_data(name, list)
@store[name] = list
end
def method_missing(method_name_symbol, *args)
method_name = method_name_symbol.to_s
return union_by(method_name) if method_name.start_with? UNI... | true |
f66dfb1c0f103734ec617713d9538f397e7952d3 | Ruby | tiyd-rails-2016-01/battleship_day_3 | /grid.rb | UTF-8 | 1,232 | 3.609375 | 4 | [] | no_license | class Grid
attr_reader :ships
def initialize
@ships = []
end
def has_ship_on?(x, y)
@ships.each do |s|
return s if s.covers?(x, y)
end
false
end
def fire_at(x, y)
ship = has_ship_on?(x, y)
ship && ship.fire_at(x, y)
end
def place_ship(ship, x, y, across)
ship.place(... | true |
46f0c51ed6723606b0e794349882a46017143951 | Ruby | kbronstein/rubytrail | /Rakefile | UTF-8 | 349 | 2.78125 | 3 | [] | no_license | task :default => :fried_egg
task :fried_egg => [:heat_pan, :pour_oil, :break_eggs, :bake, :serve] do
puts "Here is a fried egg."
end
task :heat_pan do
puts "Heating the pan"
end
task :pour_oil do
puts "Pourring oil"
end
task :break_eggs do
puts "Breaking eggs"
end
task :bake do
puts "Baking"
end
task :s... | true |
f94fd25a0d48957bf7c1b8268ce1099edd3eaefb | Ruby | ooyu-kioo/RailsTutorial | /app/helpers/sessions_helper.rb | UTF-8 | 874 | 2.71875 | 3 | [] | no_license | module SessionsHelper
# 受け取ったユーザーでログイン
def log_in(user)
# ブラウザのcookieに暗号化ずみのユーザーidを生成
# cookiesメソッドと違い、sessionメソッドでのcookieはブラウザ終了時に削除される
session[:user_id] = user.id
end
# login中のユーザーをDBから取り出す(最初の1回だけ)
def current_user
@current_user ||= User.find_by(id: session[:user_id])
#↑と同じ
# @curre... | true |
4622bd73c0443aed092cc626316606e24c3a93cc | Ruby | ekatsuta/emoticon-translator-nyc-web-051319 | /lib/translator.rb | UTF-8 | 923 | 3.59375 | 4 | [
"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)
new_hash = Hash.new
new_hash["get_emoticon"] = Hash.new
new_hash["get_meaning"] = Hash.new
emoticons.each do |emotion, emoji|
new_hash["get_emoticon"][emoji.first] = emoji.la... | true |
ca9f1c77e22b18395fb4aa088a1338ca545a0c27 | Ruby | CodeShark-NTHU/TaiGo | /infrastructure/motc/motc_api.rb | UTF-8 | 2,656 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: false
require 'http'
require 'base64'
require 'openssl'
module TaiGo
# MINISTRY OF TRANSPORTATION AND COMMUNICATIONS
module MOTC
# Gateway class to talk to MOTC API
class Api
module Errors
# Not allowed to access resource
ServerError = Class.new(StandardError... | true |
f85fe26573a194715bbfa40f9ec02d884f2e9bae | Ruby | tipsypastels/porygon | /lib/arguments.rb | UTF-8 | 836 | 2.8125 | 3 | [] | no_license | class Arguments
extend MetaConverters
delegate :arg, :opt, :optional, :usage, to: :@stack
def initialize(command, **config, &block)
@command = command
@config = config
@stack = Stack.new(self)
(@block = block).call(self)
end
def parse(raw, command_instance)
@stack.eat(tokenize(raw),... | true |
9a3d31993882443ff5b75c00b1f03709d61bd18d | Ruby | ZacharyWeiner/soca-music-rails | /lib/tasks/scraper.rake | UTF-8 | 1,952 | 2.609375 | 3 | [] | no_license | namespace :scraper do
desc "fetch most recent videos from YouTube"
task scrape: :environment do
require 'nokogiri'
require 'open-uri'
require 'csv'
# airbnb url https://www.airbnb.com/s/Fort-Lauderdale--FL--United-States
#set the uri of the page to be scraped
#url = "https://www.youtube.com/results?searc... | true |
40a2d353a5ca97b54944240d82b54f55ae6a31b8 | Ruby | highwide/aisho-note | /app.rb | UTF-8 | 1,880 | 3.5 | 4 | [] | no_license | require 'json'
require 'bundler'
Bundler.require
get '/' do
slim :index
end
post '/divine' do
res = divine(params[:name1], params[:name2])
content_type :json
res.to_json
end
private
A_LINE = %w(あ か さ た な は ま や ら わ が ざ だ ば ぱ ぁ ゃ)
I_LINE = %w(い き し ち に ひ み り ゐ ぎ じ ぢ び ぴ ぃ)
U_LINE = %w(う く す つ ぬ ふ む ゆ る ぐ ず づ ... | true |
8b6598528ff80b32cb6cde775e95b1cb4ff78edc | Ruby | iamabhishekt/leetcode-ruby-1 | /449.serialize-and-deserialize-bst.rb | UTF-8 | 1,807 | 3.640625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
#
# @lc app=leetcode id=449 lang=ruby
#
# [449] Serialize and Deserialize BST
#
# https://leetcode.com/problems/serialize-and-deserialize-bst/description/
#
# Serialization is the process of converting a data structure or
# object into a sequence of bits so that it can be stored in a file or
# m... | true |
abbea0fac77ff7eca225c8e08f38de042ebadf7b | Ruby | ManageIQ/linux_admin | /lib/linux_admin/disk.rb | UTF-8 | 6,001 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'linux_admin/partition'
module LinuxAdmin
class Disk
PARTED_FIELDS =
[:id, :start_sector, :end_sector,
:size, :partition_type, :fs_type]
attr_accessor :path, :model
# Collect local disk information via the lsblk command. Only disks with a
# size greater than zero are returned.
... | true |
116c1b09f3dea1d414ee5f5cadd68154b33d7a32 | Ruby | kaymach/launch-school-core | /rb120/lesson1/ch3_test.rb | UTF-8 | 1,103 | 4 | 4 | [] | no_license | #class GoodDog
# @@number_of_dogs = 0
#
# def initialize
# @@number_of_dogs += 1
# end
#
# def self.total_number_of_dogs
# @@number_of_dogs
# end
#end
#
#puts GoodDog.total_number_of_dogs
#
#dog1 = GoodDog.new
#dog2 = GoodDog.new
#
#puts GoodDog.total_number_of_dogs
#class GoodDog
# DOG_YEARS = 7
#
# att... | true |
485abc6ce0cdbad997eec0031435955a4ac2f015 | Ruby | ghostlambdax/recognizeapp | /app/services/safe_delayer.rb | UTF-8 | 516 | 2.65625 | 3 | [] | no_license | # This class is a quick hack to handle the fact that companies
# are stuffed too full with serialized attributes that are making
# DelayedJob barf.
#
# ex. SafeDelayer.delay(queue: 'caching').run(Company, 1, :prime_caches)
# ex. SafeDelayer.delay(queue: 'caching').run(User, 1, :prime_caches)
class SafeDelayer
def se... | true |
86b316e9f0f4d7ffb83aff50a1773f5a16a6fca1 | Ruby | ahorner/advent-of-code | /lib/2015/05.rb | UTF-8 | 506 | 3.6875 | 4 | [] | no_license | LIST = INPUT.split("\n")
def nice?(line)
vowels = line.scan(/[aeiou]/).count >= 3
double_char = (line =~ /(.)\1+/)
bad_words = (line =~ /ab|cd|pq|xy/)
!!(vowels && double_char && !bad_words)
end
nice = LIST.select { |line| nice?(line) }
solve!("Making a list:", nice.size)
def still_nice?(line)
matching_pa... | true |
e64a4fbf7d6844d988ba240c64d6c50cd50c9e60 | Ruby | 30acres/better_variant_ordering | /lib/better_variant_ordering.rb | UTF-8 | 1,193 | 2.71875 | 3 | [
"MIT"
] | permissive | require "better_variant_ordering/version"
module BetterVariantOrdering
def self.reorder_variants_by_size(p)
# binding.pry
p_variants = p.variants.sort! { |a,b| a.title.to_i <=> b.title.to_i }
p_variants.each_with_index do |v,index|
v.position = index + 1
v.save!
end
p.save!
end
... | true |
30af02a1eefe5ac3e0fa7da470b1a34829d71b7e | Ruby | edhernandez04/ruby-oo-object-relationships-kickstarter-lab-nyc-web-010620 | /lib/backer.rb | UTF-8 | 499 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative './project_backer.rb'
require_relative './project.rb'
require 'pry'
class Backer
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def back_project(project)
ProjectBacker.new(project,sel... | true |
367a441dab6f92aa8701ed836f5aee78c7b905be | Ruby | MC-Squared/LithoLamp | /lib/printed/spline.rb | UTF-8 | 789 | 2.71875 | 3 | [] | no_license | require_relative 'params'
class Spline < SolidRuby::Printed
def initialize(steps=2, add_tolerance=false)
lp = Params::LAMP_PARAMS
@steps = steps
@spline_w = lp[:spline_width]
@step_size = lp[:step_size]
@tolerance = add_tolerance ? lp[:tolerance] : 0
end
def part(_show)
res = cube(x: @s... | true |
38d521453ab46754591dcbc9ad3d63adfa45eae7 | Ruby | anishkhithani/piglatin | /piglatin_runner.rb | UTF-8 | 244 | 3.09375 | 3 | [] | no_license | require_relative "Piglatin"
class PigLatinrunner
def self.run
puts "Please enter a word to be translated"
word = gets.chomp
pl = PigLatinConverter.new.convert(word)
puts pl
end
end
PigLatinrunner.run
| true |
894426e6c09f3265364be05f9f73078e41e9aeb3 | Ruby | MintraBee/oxford-comma-online-web-pt-110419 | /lib/oxford_comma.rb | UTF-8 | 163 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
case array.length
when 1
"#{array[0]}"
when 2 array [0..1].join("and")
else
array{0...-1].join(",") <<", and #{array[-1]}"
end
end | true |
49b2f40b752f5e6a2a6624d3b0e2341f28f73c89 | Ruby | billyjack1988/Coin_changer | /coin_changer.rb | UTF-8 | 771 | 3.421875 | 3 | [] | no_license | def coin (change)
money = {quater: 25, dime: 10, nickel: 5, penny: 1}
if change == 1
{quater: 0, dime: 0, nickel: 0, penny: 1}
elsif change == 5
{quater: 0, dime: 0, nickel: 1, penny: 0}
elsif change == 10
{quater: 0, dime: 1, nickel: 0, penny: 0}
elsif change == 25
{... | true |
52ff51080f08e586ad4dadd293627ef09aa1862e | Ruby | ssamant/Scrabble | /specs/scoring_spec.rb | UTF-8 | 2,462 | 3.59375 | 4 | [] | no_license | require_relative 'spec_helper'
require_relative '../lib/scoring'
describe "Scoring" do
describe "score" do
it "Must return an integer" do
Scrabble::Scoring.score("word").must_be_instance_of Integer
end
it "Must receive String of letters as input" do
proc {
Scrabble::Scoring.score(... | true |
6a22a61f9204fb4ca907e49c45f909d11e6ee345 | Ruby | senghoo/exercism | /ruby/series/series.rb | UTF-8 | 281 | 3.453125 | 3 | [] | no_license | class Series
def initialize(s)
@series = s.each_char.collect &:to_i
end
def slices(size)
Array.new(slices_count size) { |e| @series[e, size] }
end
def slices_count(size)
len = @series.length
fail ArgumentError if size > len
len - size + 1
end
end
| true |
6bf4cd8e44e7d3629621a183baf0aa1d1499de79 | Ruby | KittyCake/mall-general-test | /lib/answer.rb | UTF-8 | 2,928 | 3.921875 | 4 | [] | no_license | # Q1. Write a function that takes a string as input and returns the string reversed.
def reverse_string(string)
return string.reverse
end
# Q2. Given a positive integer num, write a function which returns True if num is a perfect square else False.
def is_square(num)
ans = false
case num
when 0
ans = f... | true |
c8eeeb270aa9822891ae6b3efe01fd11df9abcd9 | Ruby | asridha/udemy_ruby | /Chap12_ex66_Client.rb | UTF-8 | 140 | 3.21875 | 3 | [] | no_license | require 'socket'
host = 'localhost'
port = 1500
sock = TCPSocket.open(host,port)
while line = sock.gets
puts line.chop
end
sock.close
| true |
61b37dbbb5cce361e832b2b8c4e32e0f2d79336b | Ruby | BelgianBiodiversityPlatform/data.biodiversity.be | /db/colWebServices.rb | UTF-8 | 1,410 | 2.796875 | 3 | [] | no_license | require 'net/http'
require 'nokogiri'
require 'pg'
dbHost = "dev"
dbPort = 5432
dbName=ARGV[0]
dbLogin=ARGV[1]
dbPasswd=ARGV[2]
def getCOLinfo(args)
begin
tags= ["url", "rank", "name_status"]
webparams = Hash.new("unknown")
url = URI.parse('http://www.catalogueoflife.org/col/webservice?'+args)
# puts "url=#{... | true |
b08d33b5d07ff700e9afd425eea00231d23104bf | Ruby | getoutreach/etl | /lib/etl/cache/base.rb | UTF-8 | 1,252 | 3.015625 | 3 | [
"MIT"
] | permissive | require 'base64'
module ETL::Cache
# Simple in-memory cache used primarily for surrogate
# key lookups.
class Base
def self.hash_column_values(columns, row, symbolized)
# Avoid hash computation of there is one key
if columns.count == 1
return row[columns[0].to_sym] if symbolized
r... | true |
de7da6dc6e614461264d2e8109d72e11b858734e | Ruby | JOlivier92/Permutations | /anagrams/first_anagram.rb | UTF-8 | 1,220 | 3.546875 | 4 | [] | no_license |
def shift_idx(arrs)
result = []
arrs.each do |arr|
result << arr
(1...arr.length).each do |i|
result << arr[i..-1] + arr[0...i]
end
end
result
end
def perm(arr)
return [ [ arr[0], arr[1] ], [ arr[1], arr[0] ] ] if arr.length == 2
nested = perm(arr[1..-1])
anchor = arr[0]
combo = []
... | true |
f612bcf636145d66cdca89be18f465e0e84d2500 | Ruby | lucaong/risp | /spec/risp/interpreter_spec.rb | UTF-8 | 2,617 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Risp::Interpreter do
let(:i) { Risp::Interpreter.new }
describe :eval do
it 'correctly evaluates code' do
lisp = <<-LISP
(def ten 10)
(defn dec [n]
(- n 1))
(defn fact [n]
(if (= n 1)
1
(let [m (fact (de... | true |
efe54c49e9d089c5ad8b4124803f8910bca49faa | Ruby | NUBIC/ncs_mdes_warehouse | /lib/ncs_navigator/warehouse/updating_shell.rb | UTF-8 | 1,053 | 3.09375 | 3 | [] | no_license | require 'ncs_navigator/warehouse'
module NcsNavigator::Warehouse
##
# A shell wrapper that allows for (and assists with) terminal
# programs that update their output using `\r` and `\b`.
class UpdatingShell
def initialize(io)
@io = io
end
def say(*s)
s.each { |e| @io.write(e) }
end... | true |
75583822f6e6c09f9f389bc36afe98958f2dcdb4 | Ruby | osrf-migration/srcsim-gh-pages | /data/repositories/osrf/srcsim/issues/81/attachments/scoring_q1.rb | UTF-8 | 9,955 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'nokogiri'
require 'matrix'
require './common'
# Calculate position distance between two matrices
def matDistance(matA, matB)
a = Vector[matA[0, 3],
matA[1, 3],
matA[2, 3]]
b = Vector[matB[0, 3],
matB[1, 3],
matB[2, 3]]
return (a ... | true |
b03d19266299947bab719264f46a3deb02c553d6 | Ruby | tdsparrow/Moonr | /lib/moonr/jsobject/jsfunction.rb | UTF-8 | 2,829 | 2.640625 | 3 | [] | no_license | require 'moonr/jsobject/jslist'
require 'moonr/jsobject/jssources'
module Moonr
FunctionPrototype = JSBaseObject.new {
def clazz
'Function'
end
def call *args
Undefined
end
def prototype
ObjectPrototype
end
def extensible
true
end
def_own_property(:... | true |
70fd068df111532acbf2453d57df3cfecc917697 | Ruby | glee38/flatiron-bnb-methods-v-000 | /app/models/listing.rb | UTF-8 | 829 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Listing < ActiveRecord::Base
belongs_to :neighborhood
belongs_to :host, :class_name => "User"
has_many :reservations
has_many :reviews, :through => :reservations
has_many :guests, :class_name => "User", :through => :reservations
validates_presence_of :address, :listing_type, :title, :description, :pr... | true |
b6564a74090666fd971f317847106cd1588c267b | Ruby | Anais-Linka/Test_Rspec | /lib/02_calculator.rb | UTF-8 | 567 | 3.4375 | 3 | [] | no_license | def add(first_number, second_number)
return first_number + second_number
end
def subtract(first_number, second_number)
return first_number - second_number
end
def sum(number_array)
number=0
number_array.each {|n|number+=n}
return number
end
def multiply(first_number, second_number)
return first_number * ... | true |
340b639626c7d99c774fc9ee32f1c0afeea058a4 | Ruby | neilcam4/battle_app | /lib/player.rb | UTF-8 | 270 | 3.3125 | 3 | [] | no_license | class Player
attr_reader :name
attr_accessor :hit_points
def initialize(name, hit_points = 60)
@hit_points = hit_points
@name = name
end
# def attack(opponent)
# opponent.reduce_health
# end
def reduce_health
@hit_points -= 10
end
end
| true |
37e7b638049c3ab5479e9503c54160a448a95d95 | Ruby | expertiza/automated_metareview | /lib/automated_metareview/constants.rb | UTF-8 | 11,150 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'wordnet'
#necessary to access the data.{po} files in the wordnet/dict folder of the rwordnet gem
include WordNet
# Create a parser object
#frequently used general constants
#prevtype tokens for graph generator
NOUN = 1
VERB = 2
ADJ = 3
ADV = 4
#------------------------------------------#------------... | true |
311e4e27443adba8e3a1bc6be5a887b05a200e98 | Ruby | sorah/sorah-atcoder | /digitalarts2012/a.rb | UTF-8 | 231 | 2.625 | 3 | [] | no_license | s = $stdin.gets.chomp.split(/ /)
n = $stdin.gets.to_i
ng = n.times.map { $stdin.gets.chomp }
ng_regexp = /^(#{ng.map { |_| _.gsub(/\*/, '[a-z]') }.join('|')})$/
puts s.map { |_| _.gsub(ng_regexp) { |s| '*' * s.size } }.join(' ')
| true |
90b3e76ae167b75d3bcf07d20db6d622a9873c0b | Ruby | CSheesley/backend_prework | /day_4/ex19.rb | UTF-8 | 1,831 | 4.5 | 4 | [] | no_license | # method with two parameters.
def cheese_and_crackers(cheese_count, boxes_of_crackers)
# below is the block of code that our `cheese_and_crackers` method executes.
puts "You have #{cheese_count} cheeses!"
puts "You have #{boxes_of_crackers} boxes of crackers!"
puts "Man, that's enough for a party!"
puts "Get a ... | true |
9c3511f9668f3cf2b83f808f3ff4622d6f3afdb7 | Ruby | jokerwader/SalorHospitality | /salor-hospitality/config/initializers/escper.rb | UTF-8 | 2,347 | 2.75 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2012 Red (E) Tools Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri... | true |
0e23e68527a33bbd30d0092d1a7d67154e7a04c2 | Ruby | lscspirit/faye-router | /lib/faye-router/bayeux/error.rb | UTF-8 | 1,066 | 2.515625 | 3 | [
"MIT"
] | permissive | module FayeRouter
module Bayeux
module Error
ERROR_CODES = {
:version_mismatch => 300,
:conn_type_mismatch => 301,
:extension_mismatch => 302,
:bad_request => 400,
:client_unknown => 401,
:parameter_missing => 402,
:channel_... | true |
1f21215d649ea5aac52f90e5307d34790f40e409 | Ruby | imanel/wtf_lang | /lib/wtf_lang/core_ext/string.rb | UTF-8 | 444 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #encoding: utf-8
require "wtf_lang/api"
require "wtf_lang/languages"
class String
def lang
WtfLang::API.lang self
end
def full_lang
WtfLang::LANGUAGES.key(WtfLang::API.lang self)
end
def lang_confidence
WtfLang::API.lang_confidence self
end
WtfLang::LANGUAGES.each do |lang, code|
... | true |
dad907953f46bf817803034f9ce6d983af52b882 | Ruby | mjonx/Ironhack | /Week-1/Day-1/first.rb | UTF-8 | 1,631 | 4.71875 | 5 | [] | no_license | # name = "Marjon"
#
# puts "My name is " + name + "!" #concatenation
# puts "My name is #{name}!" #interpolation
#
# puts name.class #find out what type of variable it is
# puts "The variable name is #{name.class}"
#
# num = 12.5
# #to get a float, one number needs a .
# puts 40 / 50
# puts 40 / 50.0
#
# num = num.to_s... | true |
88677543a6de7e92ba492a8345a326c934f3476e | Ruby | jamilabreu/metronorth | /db/seeds.rb | UTF-8 | 1,150 | 2.71875 | 3 | [] | no_license | require 'csv'
puts "Add Stop Times"
CSV.foreach('db/data/stop_times.csv', {headers: true}) do |row|
stop_id = row[3]
a_time = Chronic.parse(row[1].length < 8 ? "0#{row[1]}" : row[1])
arrival_time = (Time.at(0).end_of_day + (a_time.hour).hours + (a_time.min).minutes + 1.second).to_f
d_time = Chronic.parse(row[... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.