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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
271a0f332673ca77f2989c4e062b5dd2d6393b9b | Ruby | brymacto/hospice_at_home | /app/models/time_range.rb | UTF-8 | 1,337 | 3.328125 | 3 | [] | no_license | class TimeRange
attr_reader :day, :start_time, :end_time
def initialize(day, start_time, end_time)
@day = day
@start_time = start_time.to_i
@end_time = end_time.to_i
end
def ==(other)
day == other.day && start_time == other.start_time && end_time == other.end_time
end
def contains(other_t... | true |
76129e68eb770814be17027a2706c2d89e29fbd5 | Ruby | eneriberri/tdd_arrays_poker | /poker/lib/hand.rb | UTF-8 | 1,842 | 4.09375 | 4 | [] | no_license | class Hand
WEIGHT = {
:royal_flush => 10,
:straight_flush => 9,
:four_of_a_kind => 8,
:full_house => 7,
:flush => 6,
:straight => 5,
:three_of_a_kind => 4,
:two_pair => 3,
:one_pair => 2,
:no_pair => 1
}
def init... | true |
1615e3239394325dbf9cffd6f10a8d951e170f35 | Ruby | wwood/finishm | /lib/kmer_multi_abundance_file.rb | UTF-8 | 1,295 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'csv'
module Bio
# A class to work with a kmer abundance file format,
# where the kmer is first, then each abundance after that (no headings, space separated)
class KmerMultipleAbundanceHash < Hash
include Bio::FinishM::Logging
def self.parse_from_file(path)
obj = self.new
kmer_lengt... | true |
740f696f156660b29fd5aeb25468327fcaa28e07 | Ruby | hausgold/pricehubble | /lib/pricehubble/entity/valuation.rb | UTF-8 | 1,597 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module PriceHubble
# The PriceHubble valuation result for a given property.
#
# @see https://docs.pricehubble.com/#international-valuation
class Valuation < BaseEntity
# Mapped and tracked attributes
tracked_attr :currency, :sale_price, :sale_price_range, :rent_gross,
... | true |
a5256f01e31dcf871cfd0bbf98cd64d5b4faed46 | Ruby | shofira/ruby-basic | /looping.rb | UTF-8 | 528 | 3.46875 | 3 | [] | no_license | 5.times do
puts 'Selamat Belajar Ruby'
end
puts '======================'
#untuk satu line
5.times {puts 'Semangat Belajar Ruby'}
puts '======================'
5.times do |no|
puts "Belajar Ruby #{no+2}"
end
puts '======================'
4.upto(7).each do |nomor|
puts "#{nomor}. Selamat Datang"
end
puts '==... | true |
c423ebfb7a1cb3491ef21237f5d735b1f6554a76 | Ruby | tarunanandr/Day2 | /Prg3.rb | UTF-8 | 387 | 3.421875 | 3 | [] | no_license | class Details
def get_det(name,regno)
@name=name
@regno=regno
end
def put_det
puts "Name: "+@name+" Regno: "+@regno.to_s
end
def name=(name)
@name=name
end
def regno=(regno)
@regno=regno
end
end
std1=Details.new
std1.get_det("ABC", 122015001)
std1.put_det
std2=Details.new
std2.get_det("BCD", 12201500... | true |
aafc1692a7593cb0807520bc07ef11eb8d866d9b | Ruby | longlong1/total-in-ruby | /spec/full_file_parse_spec.rb | UTF-8 | 15,723 | 2.5625 | 3 | [
"MIT"
] | permissive | require "total_in"
RSpec.describe TotalIn do
describe "parse" do
before :all do
File.open File.join(__dir__, "fixtures/total_in_full_latin_1.txt"), encoding: "iso-8859-1" do |file|
@document = TotalIn.parse file
end
end
let :document do
@document
end
it "find the docum... | true |
628e96496c62e6d42fa868a1df9a9ef54c87e15c | Ruby | maetl/calyx | /lib/calyx/rule.rb | UTF-8 | 1,287 | 3.0625 | 3 | [
"MIT"
] | permissive | module Calyx
# Represents a named rule connected to a tree of productions that can be
# evaluated and a trace which represents where the rule was declared.
class Rule
def self.build_ast(productions, registry)
if productions.first.is_a?(Hash)
# TODO: test that key is a string
if producti... | true |
999e5f1035cb3bf906f0c6f48dc0b84af601eed6 | Ruby | tsuyopon/ruby | /rubocop/src/test.rb | UTF-8 | 202 | 2.90625 | 3 | [] | no_license | # conding: utf-8
require "date"
class SampleRubocop
def initialize( key )
@key = key
end
def hey
@key
end
end
if __FILE__ == $0
hoge = SampleRubocop.new("hoge")
p hoge.hey
end
| true |
f6cad1c9527d77fbd483c909a5ff0feb33b392b4 | Ruby | lishulongVI/leetcode | /ruby/821.Bricks Falling When Hit(打砖块).rb | UTF-8 | 4,751 | 3.609375 | 4 | [
"MIT"
] | permissive | =begin
<p>We have a grid of 1s and 0s; the 1s in a cell represent bricks. A brick will not drop if and only if it is directly connected to the top of the grid, or at least one of its (4-way) adjacent bricks will not drop.</p>
<p>We will do some erasures sequentially. Each time we want to do the erasure at t... | true |
4071484a70c30395b203087dec46d26e2ea5cad9 | Ruby | gmaetzig/AoC2018 | /Day 8/license.rb | UTF-8 | 1,803 | 3.34375 | 3 | [] | no_license | start_time = Time.new
class Tree
def initialize(childs, metadatas)
@num_childs = childs
@num_metadatas = metadatas
@metadata = []
@children = []
end
def get_num_childs()
return @num_childs
end
def get_num_metadatas()
return @num_metadatas
end
... | true |
5c03ec373e6466092339630883f2987ee564e2ce | Ruby | undeadinu/gavrog | /jruby/cgd_to_ds.rb | UTF-8 | 669 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | #!/bin/env jruby
include Java
import org.gavrog.joss.pgraphs.io.NetParser
import org.gavrog.joss.tilings.FaceList
def convert(input, output)
File.open(output, "w") do |f|
parser = NetParser.new(input)
while !parser.at_end
data = parser.parse_data_block
if data.type.match(/TILING/i)
name ... | true |
3955e55aeed4a10dcfa86890abebfb44f98289ec | Ruby | EmilReji/ruby_small_problems | /Medium_1/5_Diamonds.rb | UTF-8 | 816 | 4.3125 | 4 | [] | no_license | =begin
Write a method that displays a 4-pointed diamond in an n x n grid,
where n is an odd integer that is supplied as an argument to the method.
You may assume that the argument will always be an odd integer.
number indicates number of stars along each axis
run a loop n/2 times for each line; increment by 2 (1 to ... | true |
ac95c5465043dfd5aa0aa867f0ca41c734c8352d | Ruby | cunger/launch | /180/expenses/lib/expenses.rb | UTF-8 | 2,307 | 2.859375 | 3 | [] | no_license | require 'pg'
class Expenses
def initialize
@data = PG.connect(dbname: 'expenses')
setup_schema
end
def list
show_as_table all_expenses
end
def search(string)
show_as_table expenses_like(string)
end
def add(amount, memo)
add_expense amount, memo
end
def delete(id)
e = get_e... | true |
0da33b1bbf38b37c5fa9a2a061100ba1edd9a299 | Ruby | vs4vijay/tron.rb | /sample/mouse.rb | UTF-8 | 1,009 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "curses"
include Curses
def show_message(*msgs)
message = msgs.join
width = message.length + 6
win = Window.new(5, width,
(lines - 5) / 2, (cols - width) / 2)
win.keypad = true
win.attron(color_pair(COLOR_RED)){
win.box(?|, ?-, ?+)
}
win.setpos(2, 3)
win.addstr(mes... | true |
257f008a6653efb9edb4d9f55419e26bc6802670 | Ruby | alanrsl10/estudos | /Programas/jogo.rb | UTF-8 | 839 | 4.34375 | 4 | [] | no_license | # Jogo da adivinhação diferente
jogar = "1"
def limpa_texto(texto)
texto.strip
end
def inicia_jogo
puts "Adivinhe o número que eu sorteei entre 1 e 100"
palpite = gets.to_i
sorteado = Random.rand(99) + 1
tentativas = 1
while palpite != sorteado
if palpite > sorteado
puts "O número que v... | true |
0312bd52f72db5efe979a560125eaba6a64b24c7 | Ruby | NicolasDontigny/books-manager | /db/seeds.rb | UTF-8 | 6,963 | 2.578125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
bff930338d73351216458c33225100a26b23b526 | Ruby | tomtl/tealeaf-OOP-intro | /blackjack/blackjack-oo.rb | UTF-8 | 5,721 | 4.0625 | 4 | [] | no_license | # blackjack-oo.rb
# Tealeaf course 1, lesson 2
# Tom Lee, Feb 16, 2014
class Deck
attr_accessor :cards
RANKS = [2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"]
SUITS = ["Clubs", "Diamonds", "Hearts", "Spades"]
VALUES = { 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9,
... | true |
21dfd4cf8e08aebaaecb781565c7e24043cb3a55 | Ruby | BrianBailey/data_mining | /stlreal/monkey_learn.rb | UTF-8 | 523 | 2.703125 | 3 | [] | no_license | require "net/http"
require "uri"
require 'json'
uri = URI.parse("https://api.monkeylearn.com/api/v1/categorizer/cl_zD7UNmJE/classify_text/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
# Set POST data
request.body = {text: "This is a ... | true |
3f84eebccda933a665a37848b7d87e66a660c8ee | Ruby | Mcents/Battle_ship | /test/validate_test.rb | UTF-8 | 2,028 | 3 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/validate'
require './lib/player'
require './lib/game_board'
require "pry"
class TestValidate < Minitest::Test
def test_can_generate_random_coordinates
player = Player.new(GameBoard.new)
coordinates = Validate.random_coordinate_generator(1, 4... | true |
4c19e0b94c42e2df8902ac00da1633743932b01d | Ruby | cregg/coast2coast | /app/controllers/goals_controller.rb | UTF-8 | 1,164 | 2.546875 | 3 | [] | no_license | class GoalsController < ApplicationController
helper_method :weekly_team_goals, :goal_totals,
:cumulative_team_goals
def home
end
def weekly_team_goals(name)
team_weeks = Week.where(team: name)
team_goals_array = team_weeks.map {|y| y.goals}
team_goals_array
end
def goal_totals
weeks = Week... | true |
15787762b2722aa38fb89cb74ef79bd4dbfe1528 | Ruby | zdennis/yap-shell-core | /lib/yap/cli/options/generate.rb | UTF-8 | 1,462 | 2.609375 | 3 | [
"MIT"
] | permissive | module Yap
module Cli
class Options::Generate
include OptionsLoader
attr_reader :command, :options
def initialize(options:)
@options = options
@exit_status = 0
end
def parse(args)
if args.empty?
args.unshift '--help'
STDERR.puts "generat... | true |
b0ad86fdf6047b8c7b489ff5e199b647a50a2525 | Ruby | emblou2/ruby-challenges | /love_loop.rb | UTF-8 | 207 | 3.59375 | 4 | [] | no_license | puts "Do you love me yet? Please answer Y/N:"
answer = gets.chomp.downcase
while (answer == "n")
puts "Do you love me yet? Please answer Y/N:"
answer = gets.chomp.downcase
end
puts "I love you too!" | true |
059b9aaace7aa3d72458393e5a9a7a5cf7ecf18d | Ruby | makandra/rails | /rack/test/spec_lock.rb | UTF-8 | 4,447 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'rack/lint'
require 'rack/lock'
require 'rack/mock'
class Lock
attr_reader :synchronized
def initialize
@synchronized = false
end
def synchronize
@synchronized = true
yield
end
def lock
@synchronized = true
end
def unlock
@synchronized = false
end
end
module LockHelpe... | true |
3011a8d9f71dff22e1172c50a6fd8380286ea1c2 | Ruby | Angel-Garcia-Fernandez/shopping-cart | /models/pricing_rule.rb | UTF-8 | 1,306 | 3.390625 | 3 | [] | no_license | # Pricing Rule classes. The Standard one (PricingRule) and
# its specialities (GetFree and BulkDiscount).
# It makes pricing calculation, from quantity and price applying
# a specific pricing rule.
class PricingRule
attr_reader :offer, :offer_opts, :price, :quantity
def initialize
@price, @quantity = 0, 0
en... | true |
29b04e02b4c492847e3f78d02bdd61fc160ae7dd | Ruby | CircleAround/calib-rails | /lib/calib/lang/namespace.rb | UTF-8 | 587 | 2.640625 | 3 | [
"MIT"
] | permissive | module Calib
module Lang
# == A Class for Namespace
class Namespace
# array of Modlules of _cls_
def self.as_modules(cls, array = [])
parent = cls.parent
return array if parent == Object
as_modules(parent, array.unshift(parent))
end
# array of Symbols of _cls_... | true |
4b5004d67e48ef0b2b889802b15599e9b1734628 | Ruby | happygiraffe/svenbot | /test/svenbot/user_manager_test.rb | UTF-8 | 2,375 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | $:.unshift File.join(File.dirname(__FILE__),'..','lib')
require 'test/unit'
require 'svenbot/commit'
require 'svenbot/user_manager'
module Svenbot
class UserManagerTest < Test::Unit::TestCase
attr_reader :um
# Sample data
A_JID = 'me@example.com'
# More sample data
ANOTHER_JID = 'you@example.com... | true |
e4b61ab0de5894e6af11b1a6a6776d1c11ce0776 | Ruby | osteele/sitters.ios | /app/models/update.rb | UTF-8 | 1,032 | 2.53125 | 3 | [] | no_license | class Update
attr_reader :contact
attr_reader :description
attr_reader :timestamp
def self.all
@updates ||= self.json.map { |data| self.new(data) }
end
def self.unread
@unread ||= self.all[0...3]
end
def self.clear
@unread = []
end
def initialize(data)
@contact = data['contact']
... | true |
e19ff3353846cc26f0388897fa7b4ec4598c0af3 | Ruby | IanEarley/LoreQuest | /char_name.rb | UTF-8 | 469 | 3.828125 | 4 | [] | no_license | class CharacterName
attr_reader :char_name
def char_name
@char_name = gets.chomp.capitalize
if @char_name == ""
puts "\nPlease enter a name\n\n"
char_name
end
puts "\nSo, your name is #{@char_name}? (Y) yes (N) no"
choice = gets.chomp.downcase
if choice.casecmp("y") == 0 || choice.c... | true |
47dae1547542f98d7a6659145239f467834a7e7f | Ruby | philainza/tealeaf | /tealeaf_precourse/03_methods/problem3.rb | UTF-8 | 223 | 4.15625 | 4 | [] | no_license | def multiply(num1, num2)
num1 * num2
end
puts "Please enter a number"
input_num1 = gets.chomp.to_f
puts "Please enter another number"
input_num2 = gets.chomp.to_f
puts "The product is #{multiply(input_num1, input_num2)}" | true |
9f6b9971f743ba94dacedba783be0d59662a4eb3 | Ruby | popemray00/parrot-ruby-v-000 | /parrot.rb | UTF-8 | 158 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `parrot` that outputs a given phrase and
# returns the phrase
def parrot(pharse="Squawk!")
puts pharse
return pharse
"Pretty bird!"
end
| true |
5329cdecec17292ee95efe263ed1aaa0826500f8 | Ruby | etehtsea/homebrew | /lib/homebrew/cmd/help.rb | UTF-8 | 1,076 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive | module Homebrew
HOMEBREW_HELP = <<-EOS
Example usage:
brew install FORMULA...
brew uninstall FORMULA...
brew search [foo]
brew list [FORMULA...]
brew update
brew selfupdate
brew upgrade [FORMULA...]
brew [info | home] [FORMULA...]
Troubleshooting:
brew doctor
brew install ... | true |
def12045e499de411d4b160b384b263f563318eb | Ruby | EDalSanto/LaunchSchool | /courses/180_Databases/todos/session_persistence.rb | UTF-8 | 1,359 | 3.03125 | 3 | [] | no_license | class SessionPersistence
attr_accessor :session
def initialize(session)
@session = session
@session[:lists] ||= []
end
def find_list(id)
session[:lists].find{ |list| list[:id] == id }
end
def all_lists
session[:lists]
end
def create_new_list(list_name)
id = next_element_id(all_... | true |
0c7d32ff5ba2769e541242ee50c1a69d12d1e2dc | Ruby | m-walker/practice-problems | /problems/13-capitalize-words.rb | UTF-8 | 1,209 | 4.8125 | 5 | [] | no_license | # Write a method that takes in a string of lowercase letters and
# spaces, producing a new string that capitalizes the first letter of
# each word.
#
# You'll want to use the `split` and `join` methods. Also, the String
# method `upcase`, which converts a string to all upper case will be
# helpful.
#
# Difficulty: medi... | true |
5bf1b5683063f171c4eed3e14cf61a58bf84364c | Ruby | husgom/RSS-Club | /app/models/company.rb | UTF-8 | 678 | 2.515625 | 3 | [] | no_license | # create_table "companies", :force => true do |t|
# t.string "name"
# t.integer "status_id"
# t.string "name_in_demand"
# t.datetime "created_at"
# t.datetime "updated_at"
# end
class Company < ActiveRecord::Base
has_many :users
belongs_to :status
validates_presence_of :name
def ini... | true |
2f2039628cff5d91ff7de53d9b2a8eef24b09588 | Ruby | antramm/RailsLookup | /rails_lookup.gemspec | UTF-8 | 7,133 | 3.390625 | 3 | [] | no_license | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{rails_lookup}
s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = [%q{Nimrod Priell}]
s.date = %q{2011-08-09}
s.description = %q{Lookup tables with ruby... | true |
571e539a5ecad404eb8228aa0961e435758a4787 | Ruby | learn-co-students/atlanta-web-033020 | /10-activerecord-associations/app/app_cli.rb | UTF-8 | 1,989 | 3.546875 | 4 | [] | no_license | class AppCLI
def lists_users
User.all.each do |user|
puts "#{user.id}: #{user.name}"
end
end
def login
puts "==========================="
puts "Login here"
puts "==========================="
puts "List of Users:"
puts "==========================="
lists_users
puts "====... | true |
3b4e69e3f0e35876da4a82beec7f8f7b435cb375 | Ruby | ahoward/ro | /lib/ro/template.rb | UTF-8 | 3,463 | 2.59375 | 3 | [] | no_license | module Ro
class Template
require 'rouge'
require 'kramdown'
require 'kramdown-parser-gfm'
require_relative 'template/rouge_formatter'
def self.render(*args, &block)
render_file(*args, &block)
end
def self.render_file(path, options = {})
path = File.expand_path(path.to_s.stri... | true |
c6e2a9649ba825b5a67cada6829de9eb3ab0dd7d | Ruby | alu0100996081/P10-LPP | /lib/gema/lista.rb | UTF-8 | 4,662 | 3.453125 | 3 | [
"MIT"
] | permissive | Node = Struct.new(:value, :nest, :prev)
class List
include Enumerable
attr_reader :head, :tail
def initialize(head, tail)
@head = head
@tail = tail
end
#inserta en la lista por la cola
def insert_tail(value)
nodo = Node.new(value,nil,nil)
if(@tail == nil)
@tail = nodo
@head = nodo
else
nod... | true |
2e2a8729f22069d3b885a89edd63edf577c9f47b | Ruby | TylerSell/sinatra-basic-routes-lab-v-000 | /app.rb | UTF-8 | 282 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/name' do
'My name is Tyler Sell'
end
get '/hometown' do
'My hometown is Clinton, MO.'
end
get '/favorite-song' do
'My favorite song is "The City Never Sleeps" by Cartel.'
end
end
| true |
4d5137f980626a9784adb7d717987a668c0b5288 | Ruby | cucumber/html-formatter | /ruby/lib/cucumber/html_formatter.rb | UTF-8 | 1,551 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'cucumber/messages'
require 'cucumber/html_formatter/template_writer'
require 'cucumber/html_formatter/assets_loader'
module Cucumber
module HTMLFormatter
class Formatter
attr_reader :out
def initialize(out)
@out = out
@pre_message_written = false
@first_message = tru... | true |
f75b4e88492af6e9db94c87f8ca48baaadc52a41 | Ruby | ab16ruby/kelimeoynu | /app.rb | UTF-8 | 1,707 | 3.484375 | 3 | [] | no_license | require('terminal-color')
require('./yuksekpuan.rb')
class App
def self.ana_menu
puts `clear`
puts "KELİME OYUNUNA HOŞGELDİNİZ".bold.magenta
puts "--------------------------".bold
puts "Lütfen bir seçim yapın:"
puts " "
puts "1- OYUNA BAŞLA".bold.red
puts "2- YÜKSEK PUANLAR".bold.blue
puts "3- KELİME ... | true |
3d3d9eccee6e06c7213dd73b08df02431c631e08 | Ruby | icyleaf/teambition2 | /lib/teambition2/api/stage_template.rb | UTF-8 | 620 | 2.515625 | 3 | [
"MIT"
] | permissive | module Teambition2
module API
module StageTemplate
def stage_templates
get('/api/stagetemplates')
end
def stage_template(title, key: 'title', limit: 1)
result = stage_templates.select { |p| p[key].include?(title) }
return nil if result.empty?
case limit
... | true |
64ed8c5f2234d7c25020b06245d4848d20cd166d | Ruby | troessner/reek | /lib/reek/ast/sexp_extensions/if.rb | UTF-8 | 1,129 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Reek
module AST
module SexpExtensions
# Utility methods for :if nodes.
module IfNode
#
# @return [Reek::AST::Node] the condition that is associated with a conditional node.
# For instance, this code
#
# if charlie(brav... | true |
df82ef72d6e6d4b9dbbd7d927a2208541ad43f0b | Ruby | ReLearnDeveloper/Ironhack-Web-Development | /week2/stubs_and_fakes/spec/stubs_and_fakes_spec.rb | UTF-8 | 693 | 2.609375 | 3 | [] | no_license | require 'rspec'
require_relative '../stubs_and_fakes'
require 'pry'
RSpec.describe 'WordChecker' do
# @subjects = [
# "urgent",
# "very urgent",
# "good morning",
# "very important",
# "I love good morning"
# ]
describe 'check' do
it "should return false if no subject given... | true |
5b0b8199d3a864363a5a74442913ddd24036db6d | Ruby | charleneChen/conference_track_management | /lib/talk.rb | UTF-8 | 668 | 3.921875 | 4 | [] | no_license | class Talk
# getters
attr_reader :name, :minutes
# input: String - name, minutes
def initialize(name, minutes)
@name = name
@minutes = minutes
end
# Returns an integer
def getMinutes
@minutes.to_i
end
# input: an array of Talk instances
# output: an integer
def self.computeTotalTim... | true |
066bcac7f9d95e997022473d8f9544a3e137f404 | Ruby | violake/element_search | /lib/data_search/base_search.rb | UTF-8 | 1,443 | 3.046875 | 3 | [] | no_license | require 'data_search/searchable'
## DataSearch::BaseSearch Class
#
# Aim: search element by key value
#
# Design: with the searchable module, it just need to search the element_hash or search_hash
#
# Concern: 1. made assumption that all element keys are used for searching
# 2. return empty array when cou... | true |
d6697dce9f2bc5d9a404c4f4a58e49044589d861 | Ruby | mpokropowicz/tic_tac_toe | /app.rb | UTF-8 | 2,163 | 2.953125 | 3 | [] | no_license | require "sinatra"
require_relative "web_game.rb"
require_relative "random_ai.rb"
require_relative "unbeatable_ai.rb"
require_relative "human.rb"
enable :sessions
get "/" do
erb :start
end
get "/game" do
session[:p1] = params[:p1] + "1"
session[:p2] = params[:p2] + "2"
session[:game] = WebGame.new(session[:p... | true |
20562e5958fef17487f276a93d12a4e35f5ce477 | Ruby | thefrontiergroup/smeg-head | /lib/repository_manager.rb | UTF-8 | 3,408 | 2.921875 | 3 | [] | no_license | require 'angry_shell'
require 'fileutils'
# The Repository Manager class acts a base for performing operations on a given repository.
# This includes things such as manipulating and getting the state of the repository.
class RepositoryManager
class Error < StandardError; end
class NonexistantRep... | true |
75c87616a5c5b0bced28b3114d3456050cd27bde | Ruby | navry/es_rmduplicates | /es-rmduplicates.rb | UTF-8 | 5,864 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
#encoding:utf-8
require 'rubygems'
require 'tire'
require 'yajl/json_gem'
require 'digest/sha1'
VERSION = '0.0.2'
STDOUT.sync = true
# PARAMETERS __START__
def printHelp
STDERR.puts "Script to search and remove duplicites dates from ES.
Usage: #{__FILE__} <URL>/<INDEX> <ARGUMENTS>
Require... | true |
bd7a1a5d6c4ab180c1ceaaf36805f6936255c6ae | Ruby | Shawniii/Fort-Prog | /quick_sort.rb | UTF-8 | 630 | 3.515625 | 4 | [] | no_license | def swap!(a,i,j)
help = a[i]
a[i] = a[j]
a[j] = help
end
def q_sort!(a,l,r)
swap!(a,l,l+rand(r-l))
if l>=r then
return a
else
m = l
for i in l+1 .. r do
if a[i] < a[m] then
help = a [i]
a[i] = a[m+1]
a[m+1] = a[m]
a[m] = help
m = m + 1
end
... | true |
7eabeefa1e9237a95951b256dc7fb79758e036b5 | Ruby | knife/nlp | /lib/tagger/sentence.rb | UTF-8 | 322 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module NLP
class Sentence
attr_reader :tokens
def initialize()
@tokens = []
end
def << tokens
if tokens.is_a? Array
@tokens.concat tokens
else
@tokens << tokens
end
self
end
def words_number
@tokens.count{|t| !t.interp?}
end
end
en... | true |
0b349823c9838ce212ff63e448008b8e270f5b4b | Ruby | Hama99o/Ruby2 | /Exo2_corrected.rb | UTF-8 | 555 | 3.46875 | 3 | [] | no_license | #allData
student_percentage= {
Peter: "80%",
Michel: "68%",
Martin: "60%",
Thomas: "58%",
Richard: "45%",
Robert: "38%"
}
student_roll_numbers = {
"678": "Peter",
"677": "Michel",
"676": "Martin",
"675": "Thomas",
"674": "Richard",
"673": "Robert"
}
def main
puts "Enter your roll number"
$get... | true |
26bc981af5f40112f84ec15f7108f7787a1a902b | Ruby | YashUppal/appAcademy | /Intro to Programming/Arrays/doubler.rb | UTF-8 | 439 | 4.625 | 5 | [] | no_license | # Write a method doubler(numbers) that takes an array of numbers and returns a new array
# where every element of the original array is multiplied by 2.
def doubler(numbers)
double_arr = []
iterator = 0
while iterator < numbers.length
double_arr << numbers[iterator] * 2
iterator = iterator + 1
end
... | true |
ff8ebb1bf03fadbfd7f91a9b3260c10667c0ee44 | Ruby | cloudfoundry-attic/git_pipeline | /app/models/git_submodule_change_log.rb | UTF-8 | 809 | 2.65625 | 3 | [] | no_license | class GitSubmoduleChangeLog
attr_reader :symbolic_from, :symbolic_to, :git_submodule_changes
def self.from_git_log(git_repo, git_log)
git_submodule_changes = GitSubmoduleChangeCollectionLazy.new(git_repo, git_log)
new(git_log.symbolic_from, git_log.symbolic_to, git_submodule_changes)
end
def initializ... | true |
76ef00e59f328e03bc9157811d50ebc807a800e1 | Ruby | joan2kus/ChartDirector | /railsdemo/app/controllers/surface3_controller.rb | UTF-8 | 3,177 | 2.84375 | 3 | [
"IJG"
] | permissive | require("chartdirector")
class Surface3Controller < ApplicationController
def index()
@title = "Surface Chart (3)"
@ctrl_file = File.expand_path(__FILE__)
@noOfCharts = 1
render :template => "templates/chartview"
end
#
# Render and deliver the chart
#
def getch... | true |
ea0f8ccac4173669e0bbeb6a54a59bc36c054f11 | Ruby | darrdv/ruby_fundamentals1 | /exercise4.rb | UTF-8 | 330 | 3.46875 | 3 | [] | no_license | one_to_hundred = (1..100)
one_to_hundred.each do |num|
string_array = []
flag = 0
if num % 3 == 0
string_array.push('Bit')
flag = 1
end
if num % 5 == 0
string_array.push('Maker')
flag = 1
end
if flag == 0
puts num
else
puts string_array.join("")
... | true |
d4b2643eb1d81e13105b575a8b4e186ff2c58f2c | Ruby | floum/pathfinder | /lib/pathfinder/character.rb | UTF-8 | 1,926 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'yaml'
module Pathfinder
CHARACTERISTICS =%i(strength dexterity constitution intelligence wisdom charisma)
class Character
attr_reader :name, :level, :feats, :traits, :skills, :caste, :archetype, :race, :hit_points, :movement
def initialize(attrs = {})
@name = attrs.fetch('name') { nil }
... | true |
7577e0790fda3688ae3ee2b210b061ace678e0bb | Ruby | horandago/Waifu-Quest | /lib/armour.rb | UTF-8 | 333 | 2.734375 | 3 | [] | no_license | class Armour
attr_reader :is_armour, :is_weapon, :defence, :price, :is_item, :is_usable, :is_equipment, :is_sellable, :is_junk
def initialize
@is_armour = true
@is_weapon = false
@is_equipment = true
@is_item = false
@is_usable = false
@is_sellable = true
@is_junk = false
end
def to_s
"#{@nam... | true |
738f71eb43e508ccf3a15a693ab51c9d1741dfe7 | Ruby | James-C-Wilson/launchschool_organized_answers | /lesson_4/practice_problem_4.rb | UTF-8 | 1,294 | 4.34375 | 4 | [] | no_license | # What is the return value of each_with_object in the following code? Why?
['ant', 'bear', 'cat'].each_with_object({}) do |value, hash|
hash[value[0]] = value
end
=begin According to the lesson (which I found rather easily), each_with_object takes
a method argument. The method argument is a collection object that w... | true |
caa21f995c1fef731d6400b1db69287fdd2d8861 | Ruby | r0b0x-0/Launch-School | /RB100/intro_to_programming/1_the_basics/exercise_1.rb | UTF-8 | 70 | 2.890625 | 3 | [] | no_license | first_name = "C"
last_name = "Jones"
puts "#{first_name} #{last_name}" | true |
c216eb0509ee41cfb21a202b8145232f0bdf647f | Ruby | jcronk/convert_ibm390 | /test/convert/test_ibm390.rb | UTF-8 | 2,994 | 2.90625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | # frozen_string_literal: true
require 'minitest/autorun'
require 'test_helper'
module Convert
class IBM390Test < Minitest::Test
describe 'IBM390.ascnum2num' do
include Convert::IBM390
it 'converts a number with no implied decimals' do
original = '008910'
assert_equal(8910, ascnum2nu... | true |
e5e70a74794d6fbf1fce7ed93696aab86eca1972 | Ruby | betten/linguo | /spec/models/game_spec.rb | UTF-8 | 3,004 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe Game do
describe "next level" do
before do
@levels = [
Factory(:level, :number => 1),
Factory(:level, :number => 2),
Factory(:level, :number => 3)
]
@game = Factory(:game, :language => Factory(:language, :levels => @levels))
@game.... | true |
6183cef7bb956101281c7468f299866a19513cbe | Ruby | dqmrf/dive-in-ruby | /sandbox/built_in/comparsions/bid.rb | UTF-8 | 316 | 3.375 | 3 | [] | no_license | class Bid
include Comparable
attr_accessor :estimate
def <=>(other_bid)
if self.estimate < other_bid.estimate
-1
elsif self.estimate > other_bid.estimate
1
else
0
end
end
end
bid1 = Bid.new
bid2 = Bid.new
bid1.estimate = 100
bid2.estimate = 200
puts bid2 > bid1 #=> true
| true |
318e3e117cba6d8e730a5f2beecb0eed1998015a | Ruby | alpaca-tc/practices | /atcoder/contest#015/arc015_4.rb | UTF-8 | 1,657 | 3.4375 | 3 | [] | no_license | require 'mathn'
module Stub
def gets
@count = -1 unless @count
@count += 1
[
# '10 2 0.5',
# '0.5 10 1',
# '0.5 2 1',
# '100000 3 0.01',
# '0.48175 7 77',
# '0.033325 777 13',
# '0.484925 1 100',
'300 1 1',
'1 2 1000'
][@count]
end
end
extend ... | true |
69c9ede8dc6dbdf23be7576b9a5f95366535360c | Ruby | nepalez/query_builder | /lib/query_builder/cql/modifiers/selected.rb | UTF-8 | 1,139 | 2.625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module QueryBuilder::CQL
module Modifiers
# Provides the list of selected columns for SELECT statement
#
module Selected
# Adds a column
#
# @param [Array] values
#
# @return [QueryBuilder::Core::Statement] updated statement
#
def select(*val... | true |
e0822c219b094dc539df273ec70cdc4e74ca9895 | Ruby | rebagliatte/conf | /app/helpers/notifications_helper.rb | UTF-8 | 834 | 2.6875 | 3 | [] | no_license | module NotificationsHelper
def interpolable_variables_hint(notification)
string = "Interpolable variables are:"
if notification.recipients.blank?
string += "<ul class=\"help-block\">"
Notification::RECIPIENTS.each do |recipients|
string += "<li>For #{recipients.to_s.humanize.downcase}:<ul... | true |
5f061025cf7c6913069a7068d91cbec2860eeb42 | Ruby | maxim5/code-inspector | /data/ruby/1098ee3a17b8f8bf33164a6eedf36557_gap_test.rb | UTF-8 | 809 | 3.3125 | 3 | [
"Apache-2.0"
] | permissive | # Algorithm G, pp.62 TAOCPvII
class GapTest
attr_accessor :range, :alpha, :beta, :j, :s, :r, :count
def initialize(range, alpha=0, beta=1)
self.range = range
self.alpha = alpha
self.beta = beta
self.j = -1
self.s = 0
self.count = Hash.new
end
def set_r
self.r = 0
end
def test... | true |
52e46af7ae3ea93aed099444293705a108b72ba9 | Ruby | TheNotary/exc1_sum_squares | /bin/exc1_sum_squares | UTF-8 | 1,317 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
# The CLI interface is generated thanks to 'thor'. To use thor in your apps:
# 1) Add thor as a dependency in *.gemspec and do a bundle install
# 2) Create a bin folder, and create a bin script that you'd like exposed to your shell path (this file)
# 3) Put the shebang at the top of the bin... | true |
829aae39f22ab5f92f828b2b6840e1f3d7ebcb02 | Ruby | ratnikov/ruby-presentation | /ruby/app/models/book.rb | UTF-8 | 323 | 3.171875 | 3 | [] | no_license |
class Book
attr_accessor :name, :author, :isbn
def description
"#{name} by #{author}"
end
def initialize options = {}
self.name = options.delete(:name) or raise("Must provide name")
self.author = options.delete(:author) or raise("Must provide author")
self.isbn = options.delete(:isbn)
end
e... | true |
6a34d9a6257ac5bdc66aa309542b87b64292ea4b | Ruby | rui-r-duan/courses | /ruby/test_closure.rb | UTF-8 | 161 | 3.21875 | 3 | [] | no_license | def add_n (n)
lambda {|x| n + x}
end
a_proc = add_n(5)
# => #<Proc:0x00000001400f00@test_closure.rb:2 (lambda)>
a_proc.call(3)
# => 8
a_proc.call(10)
# => 15
| true |
9186a67854c68ffc7fca2a40a96346b3c36a3822 | Ruby | jbe/rcheck | /lib/rcheck/option_expander.rb | UTF-8 | 1,682 | 2.65625 | 3 | [
"MIT"
] | permissive | module RCheck
module OptionExpander
def self.constantize(name)
name.to_s.split('_').map(&:capitalize).join.to_sym
end
def self.[](name, value)
return [] if value == :none
case name
when :colors then parse_theme value
when :progress then to_instance(ProgressPrinters... | true |
8d65cbfcc8edf915b9acb1b705daf38094b4017e | Ruby | marin-cabac/prime-ruby-v-000 | /prime.rb | UTF-8 | 127 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(n)
return false if n < 2
return true if n == 3 || n == 2
((2...n).any?{|i| n % i == 0}) ? false : true
end
| true |
67b6c5e6e98db9db00d6cf106eb26f11ca873c51 | Ruby | donballz/Ruby-Crawl | /threadDict.rb | UTF-8 | 2,833 | 2.765625 | 3 | [] | no_license | require_relative 'readThread.rb'
require_relative 'common_funcs.rb'
class ThreadDict
# list of thread elements for faster searching
ATTRS = [:pNums, :pPosters, :pQuoted, :pTimes, :tNums, :tTitles,
:tOPs, :tNumsUnq, :tTitlesUnq, :tOPsUnq, :tTimesUnq]
attr_reader(*ATTRS)
def initialize(fnum)
@fNum = fnum
... | true |
3483a78fa1bb715c2002d652ac50a249494738d4 | Ruby | olbrich/ruby-units | /spec/ruby_units/date_spec.rb | UTF-8 | 1,904 | 2.640625 | 3 | [
"MIT"
] | permissive | RSpec.describe RubyUnits::Date do
subject(:date_unit) { date.to_unit }
let(:date) { Date.new(2011, 4, 1) }
it { is_expected.to be_a Unit }
it { is_expected.to respond_to :to_unit }
it { is_expected.to respond_to :to_time }
it { is_expected.to respond_to :to_date }
it { is_expected.to have_attributes(sca... | true |
0a71b1762a3edf9fd16085bb4771e36d89d3c364 | Ruby | kb-diangelo/phase-0 | /week-6/guessing-game/my_solution.rb | UTF-8 | 3,235 | 4.46875 | 4 | [
"MIT"
] | permissive | # Build a simple guessing game
# I worked on this challenge by myself.
# I spent [#] hours on this challenge.
# Pseudocode
# Input: A number
# Output: A game that lets you guess the number,
# => and reflects whether your guess was low or high
# Steps:
# 1. Define a method that takes a number as a... | true |
1cbea701d7452fd5b348ca9558f6dacd34c39f1f | Ruby | BrandonM23/Tealeaf-Prep | /IntroEx.8.rb | UTF-8 | 67 | 2.625 | 3 | [] | no_license | a = {one: '1', two: '2'} # new
b = {:one => '1', :two => '2'} # old | true |
7b78f19ef5f991c7648202b7b678febe33e83866 | Ruby | hirokore/DIC_ruby_exam | /exam/test.rb | UTF-8 | 6,132 | 3.515625 | 4 | [] | no_license | # 下記のコードが何をしているかを説明してください・・・(A)(8)最初の行(座席数と入店するグループの総数)の入力を受け付けます
seats_and_groups = gets.split(/\s/)
# 下記のコードが何をしているかを説明してください・・・(B) (10)座席を配列で作成します
empty_seat = [*1..(seats_and_groups[0].to_i)]
# 下記のコードが何をしているかを説明してください・・・(C)(13)座席の数を変数に入れておきます
seats_count = empty_seat.count
# 下記のコードが何をしているかを説明してください・・・(D)... | true |
73c59deceb4465021600dc18a0c99f8ab6652632 | Ruby | rx/presenters | /lib/voom/presenters/web_client/helpers/expand_hash.rb | UTF-8 | 656 | 2.671875 | 3 | [
"MIT"
] | permissive | # Expands a hash ensuring all values are hash's
# POM object models expand to a hash using :to_hash
# JSON is serialized in as recursive OpenStruct's, they need special expansion logic.
module Voom::Presenters::WebClient::Helpers
module ExpandHash
def expand_hash(h)
HashExt::Traverse.traverse(h.to_h) do |k,... | true |
598c61c1a95bd1d7a0a21c55d644eaf3f39bce9e | Ruby | shadabahmed/leetcode-problems | /hit-counter.rb | UTF-8 | 3,769 | 3.515625 | 4 | [] | no_license | class PriorityQueue
attr_accessor :arr, :comparator
def initialize(&block)
self.arr = []
self.comparator = block
end
def compare(first_idx, other_idx)
comparator.call(arr[first_idx], arr[other_idx])
end
def swap(first_idx, other_idx)
arr[first_idx], arr[other_idx] = arr[other_idx], arr[fir... | true |
a91817e4a588a0c9096ff99cc3ba81a3a798c647 | Ruby | johnglynn/Ironhack | /IH_Week_1/IH_Week1_Day4/lib/car.rb | UTF-8 | 95 | 2.546875 | 3 | [] | no_license | class Car
def number_of_wheels
4
end
def sound
"The sound I make is zoooom"
end
end | true |
ed42e0eeffb573a6d011d278e5641b093b4d4bc2 | Ruby | tsmsogn/AOJ | /Volume_001/0124_League_Match_Score_Sheet.rb | UTF-8 | 416 | 3.265625 | 3 | [] | no_license | has_prev = false
while line = gets
n = line.chomp.to_i
break if n == 0
teams = Hash.new(0)
n.times do
data = gets.chomp.split
teams[data[0]] = data[1].to_i * 3 + data[3].to_i
end
teams = teams.sort do |(k1, v1), (k2, v2)|
if v1 == v2
-1
else
v2 <=> v1
end
end
puts if... | true |
7a28772cd11c1cbaa45b26245e9044330749f3f7 | Ruby | TetianaFilonenko/homework4 | /Rakefile | UTF-8 | 5,767 | 2.5625 | 3 | [] | no_license | require 'gmail'
require 'pry'
require 'zip'
require 'csv'
require 'active_support/all'
desc "Make coffee"
task :download_homeworks_and_unzip do
results = []
students = []
Gmail.connect('test', 'test').mailbox("HomeWork4").emails.each_with_index do |email, counter|
begin
puts '=' * 80
student_grad... | true |
2b2e3c4cc053a617b9847a058fcb3ac878652e7f | Ruby | pyromaniac/contextuality | /lib/contextuality/context.rb | UTF-8 | 951 | 2.890625 | 3 | [
"MIT"
] | permissive | module Contextuality
class Context
def initialize
@scopes = []
end
def scope_inspect scope
scope.map do |name, value|
"#{name}: #{value.inspect}"
end.to_a.join(', ')
end
def push variables
@scopes.unshift Hash[variables.map { |(name, variable)| [name.to_s, variabl... | true |
5067094ccf7357921a6f488faaa854fd4eb2e0aa | Ruby | dtz900/Launch-school | /small_problems/easy1g.rb | UTF-8 | 510 | 4.5625 | 5 | [] | no_license | # Write a method that takes one argument, a positive integer, and returns a string of
# alternating 1s and 0s, always starting with 1. The length of the string should match the
# given integer.
def stringy(size)
numbers = []
size.times do |index|
number = index.even? ? 1 : 0
numbers << number
end
... | true |
91fb0d65047decf816fd7e7d795ed2fe811dd788 | Ruby | YuriiHorbach/ruby_examples | /lesson17/sendDemo7.rb | UTF-8 | 113 | 2.921875 | 3 | [] | no_license | def left
puts "go left"
end
def rigth
puts "go rigth"
end
print "Where to go? "
a = gets.strip
send a | true |
934d725babd50885b3bf76dfd738c1470362678f | Ruby | sogilis/sogishort | /lib/gitkvstore.rb | UTF-8 | 1,402 | 2.96875 | 3 | [] | no_license | require_relative 'kvstore'
require_relative 'git'
require 'thread'
class GitKVStore < KVStore
def initialize
@@mutex = Mutex.new
@git = Git.new
@index = nil
end
# @param [String] key
# @return [Bool]
def exists?(key)
!get(key).nil?
end
# @param [String] key
# @return [String]
def g... | true |
219fb81f4331ef260feb3873bd1eee37e714cce2 | Ruby | jalidchaer/proyectoLaboratorioIIISICIP | /app/models/user.rb | UTF-8 | 2,949 | 2.5625 | 3 | [] | no_license | require 'httparty'
class User < ActiveRecord::Base
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
VALID_CI_REGEX = /[V,v|E,e]{1}+[0-9]/
include HTTParty
has_secure_password
validates :correo, uniqueness: {case_sensitive: false ,message: "Este correo ya fue registrado"}, format: { with: VALID_EM... | true |
36ebc58574e766bbf694c97e8f0c6f496b24f9c4 | Ruby | mike1011/fetch_from_twitter | /app/models/tweet.rb | UTF-8 | 1,143 | 2.75 | 3 | [] | no_license | class Tweet < ActiveRecord::Base
require 'twitter'
attr_accessor :value_to_search, :tweets
validates_presence_of :value_to_search
validates_length_of :value_to_search, :minimum => 2,:allow_blank => false
attr_reader :errors
####Connect to the Twitter API and pull down the latest tweets"""
def get_tweets... | true |
fbe3cf9ecdb31c95caeb3fefdf27620f896f85db | Ruby | zergov/adventofcode2017 | /day14/solution.rb | UTF-8 | 1,549 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'set'
# from my day 10 solution
def knot_hash(input)
list = (0...256).to_a
current = 0
skip = 0
lengths = input.chars.map(&:ord) + [17, 31, 73, 47, 23]
64.times do
lengths.each do |n|
# update current position
list.rotate!(current)
list = list.shift(n).reve... | true |
def76e887d97d52d4d85978baaa8f208d227ac55 | Ruby | vitivey/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 323 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | string ="Hello there, and how are you?"
def reverse_each_word(string)
array = string.split
#new_array=[]
array.collect do |word|
#new_array.push(word.reverse) USE THESE COMMENTED LINES FOR .each METHOD
word.reverse!
end
puts array
array.join(" ")
#new_array.join(" ")
end
reverse_each_word(strin... | true |
8c0a65c2cd38b39cae2d6613c9d3cac9ffbe2924 | Ruby | yyddcc/sample_app | /app/helpers/sessions_helper.rb | UTF-8 | 1,810 | 2.875 | 3 | [] | no_license | module SessionsHelper
# logs in the given user
def log_in(user)
session[:user_id] = user.id # why use id instead of email?
end
# remember a user in a persistent session.
def remember(user)
user.remember
cookies.permanent.signed[:user_id] = user.id
cookies.permanent[:remember_token] = user.remem... | true |
9e5681afd2c17de2df372250853ef095a6f3761f | Ruby | courts/snippets | /xsrfify/xsrfify.rb | UTF-8 | 2,907 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
##############################################################
# #
# Written by Patrick Hof <courts@offensivethinking.org> #
# http://www.offensivethinking.org #
# ... | true |
e9c0fe2e14b0a17620f30a3257d4c0f00fb12901 | Ruby | achan/ignoramos | /lib/commands/tweet_command.rb | UTF-8 | 370 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'fileutils'
require 'tweets/tweet_option_parser'
class TweetCommand
attr_reader :publisher, :persister, :tweet
def initialize(*args)
@tweet = args.first
options = TweetOptionParser.new.parse(args)
@publisher = options.publisher
@persister = options.persister
end
def execute
pers... | true |
f24088d6bf0e5764ed72c60090f2e429dd88069f | Ruby | SethPerna/enigma | /spec/enigma_spec.rb | UTF-8 | 1,741 | 2.921875 | 3 | [] | no_license | require_relative './spec_helper'
require 'date'
require './lib/enigma'
RSpec.describe Enigma do
let(:enigma) {Enigma.new}
it 'exists' do
expect(enigma).to be_an_instance_of(Enigma)
end
it 'has #char_set' do
expect(enigma.char_set.count).to eq(27)
end
it "has date" do
expect(enigma.today_date)... | true |
09e86d4a443c7c46a22cbb9b8587c849761ac6cc | Ruby | tochman/rps_demo | /spec/models/rps_spec.rb | UTF-8 | 1,399 | 2.90625 | 3 | [] | no_license | require 'rps'
describe RPS do
it 'generates a computer responce' do
allow(RPS).to receive(:computer_move).and_return('rock')
computer_move = RPS.computer_move
expect(computer_move).to eq 'rock'
end
describe 'declares computer a looser' do
it 'if player = rock & computer = scissors' do
all... | true |
ad9540731af612ed1e76bd69dcc0f4d1bd910970 | Ruby | alecn2002/HR.rb | /lib/lib/segment_tree.rb | UTF-8 | 4,045 | 2.9375 | 3 | [] | no_license | class Range
def shift(n)
exclude_end? ? (first+n ... last+n) : (first+n .. last+n)
end
alias __cover? cover?
def cover?(v)
return __cover?(v) unless v.kind_of?(Range)
return false if empty? || v.empty?
__cover?(v.first) && __cover?(v.last - (v.exclude_end? ? 1 : 0))
... | true |
5391565701bf5139744f0c02eb7dbce1653dc5cc | Ruby | jalil/chatripper | /app/models/event.rb | UTF-8 | 934 | 2.8125 | 3 | [] | no_license | class Event < ActiveRecord::Base
validates :actor, presence: true
validates :occurred_at, presence: true
validates :action, presence: true
def self.search_by_hour(time_one,time_two)
where('time(occurred_at) BETWEEN ? AND ?', time_one, time_two)
end
def self.hourly_summary(time_one,time_two)
... | true |
173a6590ac6e9d486db779b8a76794f951c10273 | Ruby | Aurea-Li/grocery-store | /lib/order.rb | UTF-8 | 1,467 | 3.265625 | 3 | [] | no_license | class Order
attr_reader :id, :customer, :products
attr_accessor :fulfillment_status
def initialize(id, products, customer, fulfillment_status=:pending)
@id = id
@customer = customer
@products = products
unless [:pending, :paid, :processing, :shipped, :complete ].include?(fulfillment_status)
... | true |
5fffeadc54c0f3e60a4d2ce49538ec3439ca2088 | Ruby | moolitayer/kubeclient | /test/test_watch_notice.rb | UTF-8 | 1,646 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative 'test_helper'
class TestWatchNotice < MiniTest::Test
#
# Checks that elements of arrays are converted to instances of `RecursiveOpenStruct`, and that the
# items can be accessed using the dot notation.
#
def test_recurse_over_arrays
json = JSON.parse(open_test_file('node_notice.json').re... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.