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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e2de5bebc4039eff3638704f410b438c3e3dab2c | Ruby | kstomar/node-js-chat | /chatapp-rails/app/models/conversation.rb | UTF-8 | 611 | 2.53125 | 3 | [] | no_license | class Conversation < ActiveRecord::Base
attr_accessible :chat_room, :user_active, :user
belongs_to :user
belongs_to :chat_room
def self.mark_user_as_active(chat_room_id, user_id)
conv = Conversation.where("chat_room_id = ? and user_id = ?", chat_room_id, user_id).first
if !conv.user_active
conv.... | true |
d1d5f7f63080db134bc7460116a0cc66a1a83064 | Ruby | ahastudio/CodingLife | /20141009/test.rb | UTF-8 | 2,286 | 3.703125 | 4 | [] | no_license | class ZigZag
def initialize(rows)
@board = Array.new(rows) { [] }
end
def position(index)
inner = index % set
col = index / set * 2
if inner < rows
[col, inner]
else
[col + 1, set - inner]
end
end
def set
@set ||= rows * 2 - 2
end
def rows
@rows ||= @board.si... | true |
a4eae683ce817065f941a8591af9a746082b0c03 | Ruby | ckammerl/sample_app | /example_user.rb | UTF-8 | 431 | 3.46875 | 3 | [] | no_license | class User
# create attribute accessors corresponding to a user’s name and email address.
# This creates “getter” and “setter” methods that allow us to retrieve (get) and
# assign (set) @name and @email instance variables
attr_accessor :name, :email
def initialize(attributes = {})
@name = attributes[:na... | true |
e090e1e9711b864ccaa910bbdf742264827a2fef | Ruby | RobertoBarros/raycasting_gosu | /circle.rb | UTF-8 | 1,453 | 3.125 | 3 | [] | no_license | # Draws an unfilled circle with a line of any thickness
# Based on code by shawn42
#
# TODO:
# * Textures(?)
# * Use OpenGL (e.g. triangle fan)
# * Convert to C++ (and submit pull request)
# * Anti-aliasing based on VASEr's techniques (http://tyt2y3.github.io/vaser-web/)
require 'gosu'
# require 'opengl'
module Gosu
... | true |
b45ae1c7294d07e23cd98939e1ce858f5f1b82c2 | Ruby | innarns/ved_akadem_students | /lib/tasks/import_students.rake | UTF-8 | 3,064 | 2.734375 | 3 | [] | no_license | require 'csv'
namespace :academic do
desc 'Import existing students'
task import_students: :environment do
puts 'Reading data...'
ASHRAM = 'ashram'
BIRTHDAY = 'birthday'
DIVORCED = 'развод'
EDUCATION = 'education'
EMAILS = 'emails'
EMERGE... | true |
535d5cc675f9f287da1531cf1d5f3a928f269948 | Ruby | 250lth/crazy-langs | /ruby/metaprogramming/code_that_writes_code/array_expoler.rb | UTF-8 | 141 | 3.171875 | 3 | [] | no_license | def explore_array(method)
code = "['a', 'b', 'c'].#{method}"
puts "Evaluating: #{code}"
eval code
end
loop { p explore_array(gets()) } | true |
7080759347cc3e5d9a2647e45fcd498aa9de78b9 | Ruby | LinTrieu/oyster-card-thursday | /spec/fuctional_spec.rb | UTF-8 | 736 | 3 | 3 | [] | no_license | require 'oyster_card'
describe OysterCard do
subject { OysterCard.new }
let(:bow) { Station.new("Bow", 2) }
let(:bank) { Station.new("Bank", 1) }
it 'taps into Bow and taps out of Bank' do
subject.top_up(10)
subject.touch_in(bow)
expect{subject.touch_out(bank)}.to change{... | true |
8ce9c85c5176dec30f164117052ae3e3c4c8d27f | Ruby | pulliam/persephone | /unit_b/w07/d01/instructor/sweets_shoppe/server.rb | UTF-8 | 1,686 | 3.046875 | 3 | [] | no_license | module App
class Server < Sinatra::Base
set :method_override, true
# Visit the index page of his site and see a list of all his desserts.
get "/" do
# This could be whatever we want, but let's make it list out our sweets.
# Go to the database, get information
sql = "SELECT * FROM sweets... | true |
73d298ed2744a3d2e623c0a312c0302bd1ca3fc5 | Ruby | Bykanir/ruby_lessons | /Lesson_11/task_1.rb | UTF-8 | 753 | 3.453125 | 3 | [] | no_license | class Station
def initialize(name)
@name = name
end
end
class Route
def initialize(first_station, last_station)
@first_station = first_station
@last_station = last_station
end
def stations
stations = []
stations.push(@first_station, @last_station)
end
end
class Train
def initialize(... | true |
ee4cfa12a4e8115e32c474e1135a46db000f57bb | Ruby | louballantyne/bowling-challenge-ruby | /lib/score.rb | UTF-8 | 1,457 | 3.34375 | 3 | [] | no_license | class Score
attr_reader :roll1, :roll2, :bonus
def initialize
@bonus_score = 0
@bonus_score_previous = 0
end
def save_roll(roll1, roll2, bonus)
@roll1 = roll1
@roll2 = roll2
@bonus = bonus
end
def calculate(roll1, roll2, bonus)
@bonus_score_previous = roll1 if @add_bonus == true
... | true |
79da429a6ea3eaac801ddff07a63ecce598f446c | Ruby | vmanohar1/cartodb | /services/importer/lib/importer/importer_stats.rb | UTF-8 | 1,338 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | require 'statsd'
module CartoDB
module Importer2
class ImporterStats
PREFIX = 'importer'
private_class_method :new
attr_reader :fully_qualified_prefix
def self.instance(host = nil, port = nil, host_info = nil)
if host && port
Statsd.host = host
Statsd.port =... | true |
53cbb3754c04e3a1637c184dcbab08913a6a7f91 | Ruby | danacalder/top-learn-ruby | /00_hello/hello.rb | UTF-8 | 429 | 3.8125 | 4 | [] | no_license | def hello(name) #naming method with def and closing with end and pass argument with name
if name == "Kristine" #== is a boolean
puts "Hello #{name}"
elseif name == "Romina"
puts "Hello Romina"
else
puts "Hello #{name}"
end
end
def main
print "What is your name? "
name = gets... | true |
bc643806dab0663d17c13117270d925f7a53ff5f | Ruby | ahorner/advent-of-code | /lib/2017/23.rb | UTF-8 | 1,104 | 3.25 | 3 | [] | no_license | INSTRUCTIONS = INPUT.split("\n").map(&:split)
def resolve(registers, value)
if value.to_i.to_s == value
value.to_i
else
registers[value]
end
end
registers = Hash.new(0)
runs = Hash.new(0)
cursor = 0
loop do
break if cursor < 0 || cursor >= INSTRUCTIONS.length
instruction = INSTRUCTIONS[cursor]
r... | true |
bd12951c209c39928afd242eaf5c3958d8276450 | Ruby | dmitrinesterenko/learning_machine-learning | /lib/datasets/names.rb | UTF-8 | 465 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | module DataSets
class Names
doc "Data is name and a score"
def self.data
{"Anderson Cooper":1.0,
"Andy Anderson": 1.0,
"Megan Melody": 1.0,
"Alison Fromm": 1.0,
"Andy Samberg": 1.0,
"Michael Visibly Growing Wild Man Person": 0.4,
"Michael Vis... | true |
e43f43928582d861d1933cab74fd927546042319 | Ruby | ancaciascaiu/Practice | /bubble_sort.rb | UTF-8 | 577 | 4.4375 | 4 | [
"MIT"
] | permissive | # Buuble sort
# compare 2 numbers at a time and swap them if they are out of order
# loop in a loop
# Big O: O(N^2)
def bubble_sort(array)
#outer loop keeps track if something was swapped or not
loop do
swapped = false
#inner loop swaps numbers that aren't in order
(array.length-1).times do |i|
#take each... | true |
6f241de7ed0837ddd940b5be09b6a4076cad1124 | Ruby | auser/pertinacious | /lib/pertinacious/core.rb | UTF-8 | 384 | 2.640625 | 3 | [] | no_license | module Pertinacious
# This module encapsulates all of the basic functionality of a Pertinacious
# class. This is your go-to guy for Pertinacious data in ruby:
#
# class Foo
# include Pertinacious::Core
# end
#
# Much of the basic functionality is in +attribute+ and it's siblings,
# and th... | true |
8e7f60eea07a1b67b9a953710e081af8c1995388 | Ruby | itggot-john-viberud/standard-biblioteket | /lib/chomp.rb | UTF-8 | 375 | 3.65625 | 4 | [] | no_license | require_relative '../lib/ends_with'
def chomp(string)
output = ""
if ends_with(string, "\n") == true
i = 0 #behöver egentligen inte loopa går lätt att lösa med andra metoder
looptimes = string.length - 1
while i < looptimes
output += string[i]
... | true |
c824cee14ce0948e43cb38bfeff3b0ba3ea84591 | Ruby | colinwarmstrong/enigma | /runner.rb | UTF-8 | 438 | 2.5625 | 3 | [] | no_license | require './lib/key_generator'
require './lib/offsets_calculator.rb'
require './lib/enigma.rb'
e = Enigma.new
key = KeyGenerator.new.generate_key
encrypted_message1 = e.encrypt('Hello1! ..end..', key)
encrypted_message2 = e.encrypt('Welcome12$$..end..', key)
p encrypted_message1
p e.decrypt(encrypted_message1, key)
p... | true |
e1cf95f9e48760aca0050254384a9f1079f7bd91 | Ruby | suchowan/when_exe | /lib/when_exe/locales/ro.rb | UTF-8 | 3,007 | 2.578125 | 3 | [
"MIT",
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- coding: utf-8 -*-
=begin
Copyright (C) 2012-2014 Takashi SUGA
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
=end
module When
module Locale
# from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/ro.yml... | true |
c6ba6684a9e4e652cd1585e6a0ea994e06dcdcfb | Ruby | dplummer/game_of_life | /spec/game_of_life/cell_spec.rb | UTF-8 | 680 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
describe GameOfLife::Cell do
describe "tick" do
it "Any live cell with fewer than two live neighbours dies" do
expect(GameOfLife::Cell.new(1, [1,0,0,0]).tick).to eq(0)
end
it "Any live cell with more than three live neighbours dies" do
expect(GameOfLife::Cell.new(1, [1,... | true |
7e34f2017189f3dc2538613d7e9bf4b91f4d66bd | Ruby | bazay/bowling | /lib/bowling/score_calculator.rb | UTF-8 | 1,309 | 3.421875 | 3 | [
"MIT"
] | permissive | module Bowling
class ScoreCalculator
attr_reader :sum, :frames, :score
SPARE = '/'.freeze
STRIKE = 'X'.freeze
FRAME_TOTAL = (1..10).to_a
FRAME_BONUS = (11..12).to_a
FRAME_TURNS = (1..2).to_a
def initialize(score)
@score = score
@sum = 0
@frames = nil
end
def ca... | true |
02a086061981015fcba1f3f3eb9e71aacf4b39f0 | Ruby | russellschmidt/resume_project | /app/pdfs/resume_pdf.rb | UTF-8 | 4,111 | 2.921875 | 3 | [] | no_license | class ResumePdf < Prawn::Document
def initialize(resume)
# pass in new default settings to PDF via super.
super(top_margin: 50, left_margin: 50, right_margin: 50, bottom_margin: 35)
# provide access to the resume data now
@resume = resume
create_pdf
end
def create_pdf
# controller met... | true |
83ca26893141111efe8afa8d0f8261edd56fc098 | Ruby | jfredett/katuv | /lib/katuv/core/definition.rb | UTF-8 | 942 | 2.65625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Katuv
module Core
class Definition
def initialize(namespace)
@namespace = namespace
@nodes = Nodes.new
end
attr_reader :namespace, :nodes
def type
:definition
end
def terminal(name, &block)
create_node(Terminal, name, ... | true |
1d0bfa76c6785cd2e55f58ecded0b150a125aea5 | Ruby | clausweymann/robots | /lib/robots/robot.rb | UTF-8 | 1,021 | 3.359375 | 3 | [
"MIT"
] | permissive | require_relative "cell"
require "equalizer"
module Robots
class Robot
include Equalizer.new(:color, :cell)
attr_reader :color, :cell
def initialize(color, cell)
@color = color.downcase.to_sym
@cell = cell
end
def moved(direction, board_state)
next_cell = cell.next_cell(direct... | true |
e6e1524d0197070969b1edafb16a0f4f17d2af53 | Ruby | outsideris/.vim | /dotfiles/.fzf/test/test_fzf.rb | UTF-8 | 27,030 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'curses'
require 'timeout'
require 'stringio'
require 'minitest/autorun'
require 'tempfile'
$LOAD_PATH.unshift File.expand_path('../..', __FILE__)
ENV['FZF_EXECUTABLE'] = '0'
load 'fzf'
class MockTTY
def initialize
@buffer = ''
@mutex = Mutex.... | true |
e6c149ad55f1177f322af0fcc2ab71cbe83ee98b | Ruby | theRealYoshi/chess | /board.rb | UTF-8 | 611 | 3.265625 | 3 | [] | no_license | require_relative "piece"
class Board
GAME_PIECES = { }
def initialize
@grid = Array.new(8) { Array.new(8) { NullPiece.new } }
end
def full?
@grid.all? do |row|
row.all? { |piece| piece.present? }
end
end
def mark(pos)
x, y = pos
@grid[x][y] = Piece.new
end
def place_piece... | true |
5bbde2f7951a9e1b4ee161a699f075d7545e8ab3 | Ruby | Dranaxele/BForSport | /app/models/MySqlCon.rb | UTF-8 | 571 | 2.71875 | 3 | [] | no_license | # Include Ruby Gem libraries.
require 'rubygems'
require 'mysql2'
begin
# Create new database connection.
client = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "root")
# Print connected message.
puts "Connected to the MySQL database server."
joueurs = joueur.find(0)
puts jou... | true |
84decc5b3925460812ccf82275cbc0c07149cc64 | Ruby | Ashkanthegreat/futbol | /lib/calculable.rb | UTF-8 | 270 | 3.171875 | 3 | [] | no_license | module Calculable
def average(numerator, denominator)
(numerator.to_f/denominator).round(2)
end
def calculate_win_percentage(team_games)
wins = 0.0
team_games.each {|game| wins += 1.0 if game.result == "WIN"}
(wins / team_games.length)
end
end
| true |
0d35afae4a934dca81445966cce04bb9d65fbd17 | Ruby | wlalang003/euler | /15.rb | UTF-8 | 439 | 3.5 | 4 | [] | no_license | #Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
#
#
#How many such routes are there through a 20×20 grid?
max = 20
grid = []
max.times do |y|
grid[y] ||= []
max.times do |x|
grid[y][x] = if x == 0 or y =... | true |
99fc6478585194a6500672c3a43f1f02d362f01a | Ruby | kineticdata/peripherals-active-directory | /handlers/active_directory_user_expire_password_v3/handler/vendor/net-ldap-0.12.0/lib/net/ber/ber_parser.rb | UTF-8 | 5,441 | 2.90625 | 3 | [
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # -*- ruby encoding: utf-8 -*-
require 'stringio'
# Implements Basic Encoding Rules parsing to be mixed into types as needed.
module Net::BER::BERParser
primitive = {
1 => :boolean,
2 => :integer,
4 => :string,
5 => :null,
6 => :oid,
10 => :integer,
13 => :string # (relative OID)
}
co... | true |
726effa405703d5f87fabf177ff6fef9c67dc76f | Ruby | evizitei/jointcomm | /twilio_proxy.rb | UTF-8 | 801 | 2.578125 | 3 | [] | no_license | class TwilioProxy
def self.send(number, message)
client = Twilio::REST::Client.new
raw_number = number.gsub(/[^0-9]/, '').strip
if raw_number.size != 11
raw_number = "1#{raw_number}"
end
client.messages.create(
from: "+#{ENV['TWILIO_NUMBER']}",
to: "+#{raw_number}",
body: m... | true |
65b4247b99874898997e9d2abd4a38656ea64496 | Ruby | zarkzork/Redis-mapper | /lib/redis_mapper/index.rb | UTF-8 | 1,555 | 2.75 | 3 | [] | no_license | module RedisMapper
# todo create index
# todo add :of property to index method (add create callback to
# class :of
#
# use hooks for saving or deleting information from indexes
# api should look something like
#
# class Test < Base
# index :valid_items { |o| o.valid? }
# end
#
# if retuned va... | true |
8afc3f601c5280daeef8ea982a373b513c7376cf | Ruby | RPiper93/learn_to_program | /ch11-reading-and-writing/build_your_own_playlist.rb | UTF-8 | 450 | 3.03125 | 3 | [] | no_license | Dir.chdir '../../Music/iTunes'
songs = Dir['**/*.mp3']
require '../../Projects/learn_to_program/ch10-nothing-new/shuffle.rb'
#shuffle the songs using the method I wrote in the previous exercises
songs = shuffle songs
#change from an array into a string - each file on a new line
song_list = songs.join "\n"
puts 'Wh... | true |
de3535801deddd16351e099a90309ba9c0274383 | Ruby | MiyamotoAkira/7workshop | /haskell/drunken.rb | UTF-8 | 138 | 2.984375 | 3 | [] | no_license | def rteasure_map(v)
v = stagger(v)
v = stagger(v)
v = crawl(v)
return v
end
def stagger(v)
v + 2
end
def crawl(v)
v + 1
end
| true |
e5a4d119f3942d44c50bbb1beb91e85bd4f941f9 | Ruby | kwatch/editorkicker | /ruby/lib/editor_kicker.rb | UTF-8 | 3,510 | 2.625 | 3 | [
"MIT"
] | permissive | ##
## $Rev$
## $Release: $
## $Copyright$
##
##
## Invoke your favorite editor and Open errored file by it.
##
## Don't forget to do `M-x server-start' if you use Emacs.
##
module EditorKicker
def self.handle_exception(ex)
self.handler.handle(ex)
end
class <<self
alias handle handle_exception
end
... | true |
2d346f46e0cbcf69e19a46d2b7737ce8b6308bcc | Ruby | JTorr/WebCrawlers | /wiki_web_crawler.rb | UTF-8 | 715 | 2.703125 | 3 | [] | no_license | require 'rubygems'
require 'restclient'
require 'crack'
WURL = 'http://en.wikipedia.org/w/api.php?action=opensearch&namespace=0&suggest=&search='
def filter_descriptions(descriptions)
new_descriptions = []
descriptions.each do |d|
if d =~ /refer/ || d =~ /redirect/ || d == ""
d = nil
end
new_desc... | true |
cd9a866f3e538ab2f6b825e0e4f684e20380cbc1 | Ruby | ElliotOlbright/seattle_grace_2105 | /lib/hospital.rb | UTF-8 | 549 | 3.46875 | 3 | [] | no_license | class Hospital
attr_reader :name, :chief_of_surgery, :doctors
def initialize(name, chief_of_surgery, doctors)
@name = name
@chief_of_surgery = chief_of_surgery
@doctors = doctors
end
def total_salary
@doctors.sum do |doctor|
doctor.salary
end
... | true |
f0f58ff7663ebc56fd19453120853b1a41febbfd | Ruby | shadabahmed/leetcode-problems | /0019-remove-nth-node-from-end-of-list.rb | UTF-8 | 384 | 3.53125 | 4 | [] | no_license | # https://leetcode.com/problems/remove-nth-node-from-end-of-list/
def remove_nth_from_end(head, n)
fast_ptr = head
while n > 0
fast_ptr = fast_ptr.next
n -= 1
end
prev, orig_head = nil, head
while fast_ptr
fast_ptr = fast_ptr.next
prev = head
head = head.next
end
if prev.nil?
hea... | true |
12c0e1ec9a376dcfc4efef902fbc9624167bca1e | Ruby | Mudasirrr/Courses- | /Johns Hopkins University - Ruby on Rails Web Development Specialization/Johns Hopkins University - Ruby on Rails/module2 - Ruby/Lecture12-Modules/picks.rb | UTF-8 | 645 | 3.609375 | 4 | [
"Apache-2.0"
] | permissive | require_relative 'player'
require_relative 'team'
player1 = Player.new("Bob", 13, 5); player2 = Player.new("Jim", 15, 4.5)
player3 = Player.new("Mike", 21, 5) ; player4 = Player.new("Joe", 14, 5)
player5 = Player.new("Scott", 16, 3)
red_team = Team.new("Red")
red_team.add_players(player1, player2, player3, player4... | true |
973e9b2be1b780a8d58dd8cded01539acfef77ae | Ruby | hackhands/Ruby-on-Rails-4-Course | /Ruby/metaprogramming-example/the-troubles-with-eval.rb | UTF-8 | 110 | 3.125 | 3 | [] | no_license | def explore_array(method)
code = "['a', 'b', 'c'].#{method}"
eval(code)
end
puts explore_array("reverse") | true |
1116ffd2bfff2fa32534cbee4e341becacde26bd | Ruby | joynerd/ruby-vobject | /lib/vobject/component.rb | UTF-8 | 2,891 | 2.78125 | 3 | [
"BSD-2-Clause",
"MIT"
] | permissive | require "vobject"
require "vobject/property"
require "vobject/vcalendar/grammar"
require "json"
class Vobject::Component
attr_accessor :comp_name, :children, :multiple_components, :errors, :norm
def <=>(another)
me = self.to_norm
o = another.to_norm
me <=> o
end
def blank(version)
ingest VOBJ... | true |
85371bee56f3196fefdad46c36d5ac5c40123daa | Ruby | brennanholtzclaw/mtg_deck_builder | /app/models/deck.rb | UTF-8 | 767 | 3.1875 | 3 | [] | no_license | class Deck
attr_accessor :contents
def initialize(starting_cards)
@contents = starting_cards || {}
end
def card_count
@contents.values.sum
end
def update_quantity(subtract, card)
contents[card.multiverseid.to_s] ||= 0
if subtract
contents[card.multiverseid.to_s] -= 1
remove_ca... | true |
00a2cabc53b37d5b5b6f5d0cc82ab5fd3b602e03 | Ruby | annaroyer/gif_generator | /spec/models/category_spec.rb | UTF-8 | 1,378 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe Category, type: :model do
context 'validations' do
it { should validate_presence_of :name }
end
context 'uniqueness' do
it { should validate_uniqueness_of :name }
end
context 'relationships' do
it { should have_many :gifs }
it { should have_many :favorites }
... | true |
70272f8a777ab2004fc5aeead88606661b49e3c7 | Ruby | lioforest/prepa_thp_exo_ruby | /exo_11.rb | UTF-8 | 312 | 3.90625 | 4 | [] | no_license | puts "Bonjour, merci de me donner un nombre ?"
print "> "
number = gets.to_i
n =1
while n <= number # Tant que n est inférieur ou égal au chiffre demandé, le code est exécuté.
puts "Salut, ça farte ? "
n = n + 1 # On ajoute 1 à n à chaque tour pour que sa valeur atteigne le chiffre demandé.
end
| true |
b384d5c21dfc84ba296430bd65ff31167cce84f7 | Ruby | imcodingideas/web-fundamentals | /deaf_grandma/app/controllers/index.rb | UTF-8 | 368 | 2.9375 | 3 | [] | no_license | get '/' do
@abuelita = params[:abuelita]
erb :index
end
post '/abuelita' do
user_input = params[:user_input]
user_input.to_s
answer = true
user_input.each_char { |x| answer = false if x != x.upcase }
if answer == true
(user_input == 'BYE') ? 'TAKE CARE SON, SEE YOU LATER' : 'NO, NOT SINCE 1983'
... | true |
866d005ff52a26c65f6138714e976d4927667906 | Ruby | JiggyPete/scotlandjs | /scripts/speaker_status.rb | UTF-8 | 427 | 2.65625 | 3 | [] | no_license | require 'yaml'
speaker_data = YAML.load_file( '_data/speakers.yml' )
puts "NO PICTURE:"
puts
speaker_data.each do |speaker|
if speaker["pic_supplied"] != "Yes"
puts (speaker["name"] + " " + speaker["pic_supplied"])
end
end
puts
puts
puts "dietary_requirements"
speaker_data.each do |speaker|
if speaker["die... | true |
4428fd8c9caea40143431182c16562694ef70d06 | Ruby | halostatue/dotfiles | /home/private_dot_config/ruby/irbrc.d/load_gem.rb | UTF-8 | 518 | 2.625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | def load_gem(library)
library = {library => library} if library.is_a?(String)
library.each_pair do |gem_name, require_name|
gem gem_name if gem_name
require require_name
yield if block_given?
rescue LoadError
if gem_name == require_name
warn "Error loading #{gem_name}"
else
warn "E... | true |
6bbadddb1e7a4cf3b783bf9fbc72ae1ebaabb01c | Ruby | Schofield88/bank_test | /lib/account.rb | UTF-8 | 637 | 3.34375 | 3 | [] | no_license | require './lib/transactions'
require './lib/statement'
require 'date'
class Account
def initialize(transactions = Transactions.new, statement = Statement.new)
@balance = 0
@transaction = transactions
@statement = statement
end
def deposit(money)
@balance += money
@transaction.add(date: Time... | true |
5893143ac81dd352bb5ae7c7b147e8aa4610b59b | Ruby | stefvhuynh/project_euler | /PE1/pe1.rb | UTF-8 | 605 | 3.984375 | 4 | [] | no_license | =begin
If we list all the natural numbers below 10 that are multiples of 3 or
5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
=end
class SumOfMultiples
attr_accessor :multiples, :upper_limit
def initialize(upper_limit)
@upper_limit = upper... | true |
caf5de1d6c9379b6efab8bedeb8ada0cd10d1eb7 | Ruby | lcevans/Project-Euler---Haskell | /Prob24.rb | UTF-8 | 383 | 3.78125 | 4 | [] | no_license | input = 1000000-1
array = [0,1,2,3,4,5,6,7,8,9]
number = []
def factorial(n)
return 1 if n == 0
return n*factorial(n-1)
end
until array.empty?
puts array.inspect
todelete = input/factorial(array.length-1)
p todelete
input = input % factorial(array.length-1)
nextnumber = array[todelete]
array.delete_... | true |
382c73787827050a3a2c970b01d505ea04c2624e | Ruby | DerekKaknes/forms-and-basic-associations-rails-lab-cb-000 | /app/models/song.rb | UTF-8 | 646 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
belongs_to :artist
belongs_to :genre
has_many :notes
def genre_name
genre && genre.name
end
def genre_name=(name)
genre = Genre.find_or_create_by(name: name)
self.genre = genre
end
def artist_name
artist && artist.name
end
def artist_name=(name)
... | true |
1c516f4dbde0781b99089ef0ef7d1d9273ecf937 | Ruby | hugovila/polygon | /isosceles.rb | UTF-8 | 132 | 2.765625 | 3 | [] | no_license |
class Isosceles < Triangle
def initialize equal_sides, unique_sides
super equal_sides, equal_sides, unique_sides
end
end | true |
0f544e5a5e90d64de0177acb8bb19347071bfb7f | Ruby | Carly-Schaaf/W2D1-W2D2 | /chess/Piece.rb | UTF-8 | 2,379 | 3.3125 | 3 | [] | no_license | module Slideable
def get_unblocked_moves(dir)
moves = []
current_pos = @current_pos.dup
current_pos[0] += dir[0]
current_pos[1] += dir[1]
while valid?(current_pos)
break unless board[current_pos].is_a? (NullPiece)
moves << current_pos.dup
current_pos[0] += dir[0]
current... | true |
3a3f63fe6e04af4d949f56f97a68a9e5fd6965ba | Ruby | locopati/todoable | /lib/todoable_list.rb | UTF-8 | 4,289 | 3.171875 | 3 | [] | no_license | require 'todoable_client'
require 'todoable_item'
# a client for the Todoable API
# this started as a very literal translation of the API
# then i changed the design to be model-oriented
# there are drawbacks
# there is a piece of shared state - the client - among the lists and items of a particular user
# another... | true |
db8f3f548b60928ae0aff68c0ecb7c90fa9c906c | Ruby | azhang9328/ruby-oo-relationships-practice-blood-oath-exercise-seattle-web-120919 | /tools/console.rb | UTF-8 | 1,017 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
c1 = Cult.new... | true |
2a37f3f92418b00e3f4df9f76c47452dd98ca71d | Ruby | markstachowski/code | /Ruby/complex.rb | UTF-8 | 347 | 3.421875 | 3 | [] | no_license | class Complex2
def initialize
@a=0
@b=0
end
def initialize(x,y)
@a=x
@b=y
end
def suma(x)
res = Complex.new()
res.a= @a+y.a
res.b= @b+x.b
return res
end
end
complex1 = Complex2.new(1,2)
puts complex1.@x
# complex3 = Complex2.new()
# complex2 = Complex2.new(3,4)
# puts ... | true |
9e0d78057923c80278c4a9ed1a3e952f25cf5050 | Ruby | wfischer42/backend_prework | /day_1/ex11.rb | UTF-8 | 555 | 4.46875 | 4 | [] | no_license | print "How old are you? "
age = gets.chomp
print "How tall are you? "
height = gets.chomp
print "How much do you weigh? "
weight = gets.chomp
puts "So, you're #{age} old, #{height} tall and #{weight} heavy."
# The return from "gets" includes a new line. Chomp removes it so the
# variable it's assigned to doesn't have... | true |
cdfff3038946226c6516693c1370e2551d9ae342 | Ruby | ashwin28/simple_address_book | /spec/models/user_spec.rb | UTF-8 | 3,161 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before { @user = User.new(name: "Example User", username: "ex_user",
password: "12345678", password_confirmation: "12345678") }
it "should respond to the following when valid" do
%w(name username password_digest password
... | true |
baeca18d07e4aad31731fecc758114325145204a | Ruby | kevieyang/toy_robot | /spec/table_spec.rb | UTF-8 | 559 | 2.71875 | 3 | [] | no_license | #!/usr/bin/ruby
require 'rubygems'
require 'rspec'
require '../lib/table.rb'
require '../lib/position.rb'
describe Table do
before(:each) do
@table = Table.new(5,5)
end
it "has a set size x" do
@table.size_x.should == 5
end
it "has a set size y" do
@table.size_y.should == 5
end
it "corr... | true |
00db954f0385abd22e468d500d5f1fa8a0630ec1 | Ruby | turboladen/tailor | /lib/tailor/lexer.rb | UTF-8 | 16,340 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'ripper'
require_relative 'composite_observable'
require_relative 'lexed_line'
require_relative 'lexer/lexer_constants'
require_relative 'logger'
require_relative 'lexer/token'
class Tailor
# This is what provides the main file parsing for tailor. For every event
# that's encountered, it calls the appro... | true |
0c920c02db5633bcb08f836a95d7ba6f2d9a7d30 | Ruby | jwpilling/bsc_web | /test/models/log_test.rb | UTF-8 | 1,238 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class LogTest < ActiveSupport::TestCase
test 'user_id must be present' do
log = Log.new
log.user_id = ''
assert_not log.valid?
end
test 'path must be present' do
log = Log.new
log.path = ''
assert_not log.valid?
end
test 'title must be present and less than 25... | true |
96d964c689899c2226252310fd30242f887cea01 | Ruby | reneedv/git_review | /beer.rb | UTF-8 | 532 | 3.265625 | 3 | [] | no_license | module Drinkable
attr_accessor :volume
def drink amount
@volume -= amount
end
end
class Beverage
include Drinkable
attr_accessor :flavor, :alcohol_content
def initialize stuff = {}
@volume = stuff[:volume]
@flavor = stuff[:flavor]
@alcohol_content = stuff[:alcohol_content]
end
end
c... | true |
5ff6a392ba110a417dea0c09a7cbe2cbc1044806 | Ruby | Multilingual-Dictionary/dictionary | /lib/dict/rfc2229.rb | UTF-8 | 8,537 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
### dict.rb --- RFC 2229 client for ruby.
## Copyright 2002,2003 by Dave Pearson <davep@davep.org>
## $Revision: 1.10 $
##
## dict.rb is free software distributed under the terms of the GNU General
## Public Licence, version 2. For details see the file COPYING.
### Commentary:
##
## The following c... | true |
907a1d522bd8c62a2aa38a5be292b38e5e4a9727 | Ruby | sagittarius3008/cherry-book | /lib/convert_length.rb | UTF-8 | 126 | 2.71875 | 3 | [] | no_license | UNITS = {m: 1.0,ft: 3.28, in:39.37}
def convert_length(length,from: :m,to: :m)
(length / UNITS[from]*UNITS[to]).round(2)
end | true |
ebecc4e4b5c69c99a539c3e5312d7d6a56a09ecf | Ruby | onima/hangul | /main.rb | UTF-8 | 1,490 | 2.734375 | 3 | [] | no_license | require 'ruby2d'
require 'pry'
require_relative 'lib/models/letter'
require_relative 'lib/models/alphabet'
require_relative 'lib/models/fake_letter'
require_relative 'lib/models/game_master'
require_relative 'lib/models/game_state'
require_relative 'lib/models/onscreen_letters'
require_relative 'lib/graphics/general'
r... | true |
19d9317b17978324c5935f36e1009f641f7df4e0 | Ruby | ktlacaelel/atesta | /lib/block_attr.rb | UTF-8 | 456 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module BlockAttr
def self.included klass
klass.extend ClassMethods
end
module ClassMethods
# No Convention over Configuration attributes.
def block_attr *list
@attributes = ((@attributes || [])+ list).uniq
list.each do |new_method|
instance_eval do
define_method new_me... | true |
20a855030c5c8d00aac2d31a323c2051b23957b8 | Ruby | brandong1/ruby-enumerables-introduction-to-map-and-reduce-lab-denver-web-021720 | /lib/my_code.rb | UTF-8 | 1,480 | 4 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # map_to_negativize returns an array with all values made negative
def map_to_negativize(source_array)
array = []
index = 0
while index < source_array.size do
array.push(source_array[index] * -1)
index += 1
end
array
end
# map_to_no_change returns an array with the original values
def map_to_no... | true |
5c87246344eeb796a0917ffaa862c74d1b71ddbe | Ruby | yenertuz/app_academy_alpha_curriculum | /09_dog_project/lib/dog.rb | UTF-8 | 651 | 3.84375 | 4 | [] | no_license | class Dog
def initialize(name, breed, age, bark, favorite_foods)
@name = name
@breed = breed
@age = age
@bark = bark
@favorite_foods = favorite_foods
end
def bark
return @bark.upcase if @age > 3
@bark.downcase
end
def name
@name
end
def age
@age
end
def favorite_foods
@favorite_food... | true |
f2eab44222451dc1c1b0563484b238846e174c3d | Ruby | littlestarling/netslime | /lib/netslime/worker.rb | UTF-8 | 1,646 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'mechanize'
module NetSlime
class Worker
def initialize
@agent = WWW::Mechanize.new
@agent.user_agent = "NetSlime/0.0.1"
end
def crawl (uri)
page = @agent.get(uri)
end
def save(uri, path = nil)
page = @agent.get(uri)
name = get_file_na... | true |
403b91a844445d1c5f54eb62c41389d77955df17 | Ruby | MoffD/commonmarker | /test/test_basics.rb | UTF-8 | 1,232 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class TestNode < Minitest::Test
def setup
@doc = CommonMarker.render_doc('Hi *there*')
end
def test_walk
nodes = []
@doc.walk do |node|
nodes << node.type
end
assert_equal [:document, :paragraph, :text, :emph, :text], nodes
end
def test_insert_illegal
ass... | true |
71403094546d7ac56910fbc8ae33320d6d6794c9 | Ruby | ingobecker/shukudai | /lib/shukudai/cli.rb | UTF-8 | 4,007 | 3.25 | 3 | [] | no_license | require 'optparse'
module Shukudai
class CLI
def self.start
options = {
seed: nil,
output: 'sheet.pdf',
jlpt: 4,
kana: :hira
}
subcommands_usage = <<~USAGE
Subcommands:
kanjikana: train kana handwriting and kanji knowledge at once
kan... | true |
734471c09f4ca06ae8a4a706db744acc6e4dd736 | Ruby | tlcowling/euler | /ruby/problem67.rb | UTF-8 | 1,031 | 3.453125 | 3 | [] | no_license | # Project Euler - solution to problems 18 and 67
triangles = []
tra = []
File.open('p67.txt').each_line {
|line|
tra.push(line.strip.split(""))
}
tra.map! {|arr| arr.join("")}
tra = tra.join(" ")
triangles << tra.split(" ").map!{|el| el.to_i}
def makeTriangle(ar)
rowCount=0
$rowsArr=[]
while ar.... | true |
d85c48c9002bfd3e293021c0dfe9e14be9750b4e | Ruby | duffyjp/duffy | /lib/duffy/beast_mode_helper.rb | UTF-8 | 1,926 | 2.890625 | 3 | [
"MIT"
] | permissive | module BeastModeHelper
# Cache each partial in a collection, then display from cache.
#
# IMPORTANT: This only works if you've wrapped your partial in a cache block.
# If you don't it will take longer than just calling render()
# You also need the Parallel gem installed: https://github.... | true |
e2b4026ccda0fbedd66a75da03451394ff3401fc | Ruby | yutokunakasa/MYRYBY | /Lesson10.rb | UTF-8 | 279 | 3.75 | 4 | [] | no_license | # age = 0
# if age >= 20
# p "adult"
# elsif age == 0
# p "baby"
# else
# p "child"
# end
#確認問題
age = 5
if age >= 10 && age <20
p "10代"
elsif age >= 20 && age < 30
p "20代"
elsif age >= 30 && age < 40
p "30代"
else
p "それ以外"
end | true |
911ad3f0ac0796c23b6a7a99a8404281b8a24381 | Ruby | tirthajyoti-ghosh/Hackerrank-Solutions | /chocolate_feast.rb | UTF-8 | 231 | 3.515625 | 4 | [] | no_license | # https://www.hackerrank.com/challenges/chocolate-feast/problem
def chocolateFeast(n, c, m)
r = n / c
a = r / m
left_over = r % m
while a > 0
r += a
a += left_over
left_over = a % m
a /= m
end
r
end
| true |
fb7fc7aa9314d2d97899d40b8fa31ce95f60f857 | Ruby | riv-dev/ryukyu_social_backend | /task_puller_chatwork/test.rb | UTF-8 | 272 | 2.71875 | 3 | [] | no_license | require './chatwork.rb'
chatwork = Chatwork.new
puts "My Information:"
puts chatwork.get_me
puts
puts
puts "Rooms:"
puts chatwork.get_rooms
puts
puts
puts "All Messages:"
puts chatwork.get_all_messages
puts
puts
puts "All Tasks:"
puts chatwork.get_all_tasks
puts
puts | true |
2c37c3181e8774cb21e2202b95d89a4ef5adf865 | Ruby | craftninja/blog_dice_random_testing | /spec/game_turn_spec.rb | UTF-8 | 1,067 | 3.15625 | 3 | [] | no_license | require 'game_turn'
describe GameTurn do
it 'initializes the game with current score 0' do
game_turn = GameTurn.new
actual = game_turn.score
expected = 0
expect(actual).to equal(expected)
end
it 'allows user to roll dice and score them for the 1s' do
srand(118)
game_turn = GameTurn.new
... | true |
a8561fc597c162009512c0e488edce6b5f31131f | Ruby | adriancm/developer_cliques_challenge | /spec/lib/developer_cliques/connected_developer_spec.rb | UTF-8 | 2,640 | 2.546875 | 3 | [] | no_license |
require 'rspec'
require_relative '../../spec_helper'
require_relative '../../../lib/developer_cliques/connected_developers'
require_relative '../../../config/github_config'
describe ConnectedDevelopers do
def duser user
double(screen_name: user)
end
let(:twitter_client) do
friends = {
"user1"... | true |
04c5e41110c538fa5e87fb8243949d11f6da1350 | Ruby | Aleph-works/metaprogramming | /test_blocks.rb | UTF-8 | 724 | 2.9375 | 3 | [] | no_license | #!/usr/local/bin/macruby
require "test/unit"
require "blocks.rb"
class TestBlocks < Test::Unit::TestCase
class Resource
def dispose
@disposed = true
end
def disposed?
@disposed
end
end
def setup
@obj = MyBlockClass.new
end
def test_block_given
assert(@obj.my... | true |
a489404308f23132a0d7e2bf3faf1d5f84d5a70d | Ruby | mpasternacki/gitconfig | /lib/gitconfig.rb | UTF-8 | 2,156 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'gitconfig/version'
require 'escape'
require 'git'
class GitConfig
attr_reader :vars, :escaped
def initialize(*args)
opts = args.last.is_a?(Hash) ? args.pop : {}
@git = Git.open(args[0]||'.', opts)
@gitlib = Git::Lib.new(@git)
@vars = opts[:vars] || {}
@opts = opts
@escaped = Esc... | true |
72e77373f97e7e48a4d279c6fa1cb74044fdb146 | Ruby | matilda26/WDI_15_HOMEWORK | /Matilda/wk04/2-tue/arrays.rb | UTF-8 | 476 | 3.9375 | 4 | [] | no_license | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
#remove Sunday and add it to the beginning to the array
days_of_the_week.pop
days_of_the_week.unshift('Sunday')
#separate into weekdays and weekends
days_of_the_week = [
['Monday', 'Tuesday', 'Wednesday', 'Thursday', '... | true |
0119b5090cd462115d7d5c9042d259f08530cbed | Ruby | WScraping/lansstyrelsen_parser | /parser.rb | UTF-8 | 1,202 | 2.9375 | 3 | [] | no_license | require 'rubygems'
require 'mechanize'
module Parsers
class Lansstyrelsen
attr_accessor :data
BASE_URL = 'http://web05.lansstyrelsen.se/stift/StiftWeb/'\
'FoundationDetails.aspx?id='
def initialize(limit = nil)
@limit = limit || 1_000_000_000
@data = []
@agent = Mechani... | true |
b3300149a76d3333e6caeeb3bfa3f77830a835bb | Ruby | nganifaith/Ruby-Capstone-CSS-linters | /lib/read_file.rb | UTF-8 | 381 | 3.390625 | 3 | [
"MIT"
] | permissive | # This class loads and reads the file into out program
class ReadFile
attr_reader :file_path, :error_msg, :content
def initialize(path)
@file_path = path
@error_msg = ''
begin
File.open(path) do |file|
@content = file.readlines.map(&:chomp)
end
rescue StandardError
@content... | true |
684c4916efd7e1aff7f80304eb4e36d56d70e4d6 | Ruby | kumpelblase2/RubyUniversityExercises | /Aufgabe_5/lib/full_name.rb | UTF-8 | 705 | 3.234375 | 3 | [] | no_license | class Object
def full_name?; false end
end
class FullName
include Comparable
def self.[](*in_args) check_inv(self.new(*in_args)) end
def full_name?; true end
def initialize(in_first, in_last)
@first = in_first
@last = in_last
end
def invariant?() self.first_name.string? and self.last_name.string? end... | true |
d33d9b792f188a71df98449129aa260925fe2da2 | Ruby | nburt/exercises | /rock-paper-scissors-game/spec/computer_guesser_spec.rb | UTF-8 | 324 | 2.671875 | 3 | [] | no_license | require 'rspec'
require 'computer_guesser'
describe ComputerGuesser do
it "randomly creates a computer choice" do
computer_guesser = ComputerGuesser.new
guesses = []
15.times do
guesses << computer_guesser.guess
end
expect(guesses.uniq).to match_array ["rock", "paper", "scissors"]
end
... | true |
3f9ffdbbc5f9dc3c5d031758710f2dd0f30b53e7 | Ruby | skuan/src | /garageio_with_forms/app/models/car.rb | UTF-8 | 800 | 2.828125 | 3 | [] | no_license | class Car < ActiveRecord::Base
validates_presence_of :name, :color, :make, :model
#required names
validates_uniqueness_of :name
#no same name
validates :year, numericality: true
#custom validator
validate :starts_with_f
def starts_with_f
unless name.downcase.start_with?('f')
errors.add(:name, 'must ... | true |
87325db73c5d057cf9e4ba76e79e0c70aa2720f1 | Ruby | DidiDodson/Mastermind | /lib/start_4.rb | UTF-8 | 6,365 | 3.75 | 4 | [] | no_license | class Start_4
attr_reader :guess_num
def initialize
@guess_num = 0
end
def instructions
"The game is played by guessing a sequence of colors that I have created! \nThere are three levels of difficulty: beginner, intermediate, and advanced. \nThe beginner difficulty has four elements in... | true |
7e31cba54b76f8c44ea172dd7982348641956cd1 | Ruby | AlexChien/empp | /lib/empp/msg_submit.rb | UTF-8 | 2,748 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'empp/empp_base'
require 'empp/constants'
require 'empp/empp_logger'
require 'empp/utils/bytebuffer'
require 'empp/utils/utils'
module Empp
class MsgSubmit < EmppBase
attr_accessor :terminal_id, :pk_total, :pk_number, :msg_id, :sequence_ids
def initialize(terminal_id, message, account_id, servi... | true |
95fb7b8eba71ce6022ea389128831241be8d8b2f | Ruby | TomGroombridge/Sudoku | /lib/grid.rb | UTF-8 | 1,780 | 3.53125 | 4 | [] | no_license | class Grid
attr_accessor :cells
attr_accessor :box
def initialize (initial_value)
@cells = initial_value.split('').map { |i| i.to_i}
end
def row
rows = []
cells.each_slice(9) {|row| rows << row}
rows
end
#write a
def row_indexes
arr = []
(0..80).to_a.each_slice(9){|a| arr << a}
arr
end
... | true |
9a2daa91c29bab6976d8ee12cd128409647af12e | Ruby | igorkaz001/phase-0 | /week-4/variables-methods.rb | UTF-8 | 1,291 | 4.09375 | 4 | [
"MIT"
] | permissive | puts "please enter your first name"
fname = gets.chomp
puts "now your middle name"
mname = gets.chomp
puts "and finally your last name"
lname = gets.chomp
puts "hello " + " " + fname + " " + mname + ", " + lname + " how are you today?"
puts "what is your favorite number?"
num = gets.chomp.to_i
num = num + 1
puts nu... | true |
e7f2758774075a057cd7bf452f4b40a21e582217 | Ruby | Souravgoswami/ruby-masterclass | /Section 29: Cryptography - String IV/Part4_Using_the_openssl_gem.rb | UTF-8 | 1,419 | 3.28125 | 3 | [
"Unlicense",
"LicenseRef-scancode-proprietary-license"
] | permissive | #!/usr/bin/ruby -w
# Encoding: UTF-8
# Sun Jul 21 05:17:32 2019
# ruby 2.6.3
# PART 3
# The openssl gem can be used to use OpenSSL module.
# Let's see what it can do:
require 'openssl'
p OpenSSL.class
p OpenSSL::Digest.class
# It also loads the Digest class (not the module)
p OpenSSL::Digest::SHA1.new.digest 'hello'... | true |
71a6d15fbee095a098249f18f635b465b1522141 | Ruby | charlierproctor/tbgit | /lib/helptext.rb | UTF-8 | 3,575 | 3.0625 | 3 | [
"MIT"
] | permissive | class HelpText
def helpme
puts ""
puts "\tTBGit is a command-line utility to facilitate the management of multiple GitHub student repositories."
puts "\t\t\t~ created by the teaching staff at 2014 YEI Tech Bootcamp"
puts "\t\t\t\t~ partly based off of https://github.com/education/teachers_pet"
pu... | true |
fe5bc5c65c8556453e94b89ed6ef309b9ff85f58 | Ruby | ginty/cranky | /lib/cranky/factory.rb | UTF-8 | 5,287 | 2.8125 | 3 | [
"MIT"
] | permissive | module Cranky
class FactoryBase
TRAIT_METHOD_REGEXP = /apply_trait_(\w+)_to_(\w+)/.freeze
def initialize
# Factory jobs can be nested, i.e. a factory method can itself invoke another factory method to
# build a dependent object. In this case jobs the jobs are pushed into a pipeline and executed
... | true |
06544e13c93f18756cd2bee534ac0a7c4b6a46d7 | Ruby | germanleon/ThingsToDo | /app/models/user.rb | UTF-8 | 1,326 | 2.59375 | 3 | [] | no_license | require 'digest/sha2'
class User < ActiveRecord::Base
attr_accessible :about_me, :email_address, :first_name, :last_name, :password, :salt, :user_name, :usuario_id
validates :user_name, :presence => true, :uniqueness => true
validates :email_address, :presence => true
validates :password, :presence => true
... | true |
0621aa9cd1a73c670c2f20f9f287882ea70789b7 | Ruby | Greg0109/TicTacToe | /bin/main | UTF-8 | 1,899 | 3.6875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative '../lib/logic'
require_relative '../lib/settings'
def make_new_player
puts 'What symbol do you want to use?'
player_sign = gets.chomp
compatible_signs = %w[X O]
if !compatible_signs.include?(player_sign.upcase)
puts 'Incompatible sign, please try again'
puts
mak... | true |
477c424cf5bbd95193f1ff489417d60c916aa0e8 | Ruby | mauritslamers/otherinbox | /bin/sc-integrate | UTF-8 | 5,299 | 3.046875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# remote repository to fetch from and push to
remote_name = "origin"
# branch to integrate *into* (i.e. to push upstream)
integration_branch = 'origin/sc1_0'
# IMPORTANT: You must create a local integration_branch from the remote
# integration_branch before running sc-integrate.
# This integrati... | true |
5b8a0f75e366aecf8d27dc3e7460328f879f62a7 | Ruby | iamcz/RailsLite | /lib/controller.rb | UTF-8 | 1,705 | 2.515625 | 3 | [] | no_license | require 'active_support'
require 'active_support/core_ext'
require 'active_support/inflector'
require 'erb'
require_relative 'session'
require_relative 'params'
require_relative 'flash'
require_relative 'form_helper'
class ControllerBase
include FormHelper
attr_reader :req, :res, :params
def initialize(req, re... | true |
5fc34a2c86bbbe7411494826619fb3fc0087298d | Ruby | cjbrock/star-wars-api-081720 | /lib/cli.rb | UTF-8 | 1,641 | 3.640625 | 4 | [] | no_license | class CLI
def run
puts "Welcome to the Star Wars Character Database!"
puts "Please choose a character to see more information:"
API.scrape_characters
list_characters
menu
end
def list_characters
Character.all.each.with_index(1) do | character, i |
... | true |
5403d5f5cb44df88a9010988f6d238d6ad80cef9 | Ruby | mbuda/ruby-exercises | /command-query/lib/appointments.rb | UTF-8 | 161 | 2.796875 | 3 | [
"MIT"
] | permissive | class Appointments
attr_accessor :when
def initialize
@when = []
end
def at(date)
@when << date
end
def earliest
@when.min
end
end
| true |
714cc63d27e30dd6cfb06892cce6b6445a05c334 | Ruby | ljsc/ranneal | /lib/ranneal/examples/seating.rb | UTF-8 | 2,893 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'ranneal'
require 'enumerator'
require 'set'
class SeatingManager
Guest = Struct.new(:name, :age, :party, :seat)
attr_writer :guests
attr_reader :solution
def initialize(datafile)
@data_file = datafile
end
def accept
self.guests = @candidate
end
def adjacent_edges(e)
edges = Se... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.