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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
84531b44c58378a9d36db41adf9ce6a614bb6573 | Ruby | MarEdv/advent_of_code | /2016/day1/day1.rb | UTF-8 | 2,646 | 3.953125 | 4 | [] | no_license | #!/usr/bin/ruby
require 'set'
class Move
def initialize(d, s)
@dir = d
@steps = s
end
def dir
@dir
end
def steps
@steps
end
end
def toMove(string)
str = string.strip
Move.new(str[0], Integer(str[1..-1]))
end
@dirs = ['N', 'E', 'S', 'W']
def moveToNextPosition(p, m)
if m.dir == 'R'... | true |
2a541758b6f8b225658f8b3eccd93aa1b530f704 | Ruby | lucetzer/learn_to_program | /ch10-nothing-new/dictionary_sort.rb | UTF-8 | 197 | 3.078125 | 3 | [] | no_license | def dictionary_sort arr
return arr if arr.length <= 1
middle = arr.pop
less, more = arr.partition {|x| x.upcase < middle.upcase}
dictionary_sort(less) + [middle] + dictionary_sort(more)
end | true |
589812cdcaf43a1139b884853422ac3772d7db34 | Ruby | jereparla/notifications | /services/AccountService.rb | UTF-8 | 2,779 | 2.859375 | 3 | [] | no_license | require './models/user.rb'
class AccountService
def self.login_user(username, password, session)
usuario = User.find(username: username)
if usuario && usuario.password == password
session[:user_id] = usuario.id
else
raise ArgumentError.new("Wrong username or password")
end
end
... | true |
4775aee45930ddafa1195620bb5951d1521a8cae | Ruby | kellyjosephprice/chess | /pieces/pawn.rb | UTF-8 | 1,827 | 2.984375 | 3 | [] | no_license | # encoding: utf-8
class Pawn < Piece
attr_accessor :in_passing
alias_method :in_passing?, :in_passing
def initialize(*args)
super
@promoting = false
@in_passing = false
end
def moves
moves = []
moves << [1, 0] if @board[apply_offset([1, 0])].nil?
moves.concat(attacks)
m... | true |
5f0eeb40539b17c55c5c58da5383c11714bf6380 | Ruby | alexmgr/RunTracer | /ruby/trace_codec.rb | UTF-8 | 1,987 | 2.640625 | 3 | [] | no_license | # Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2010.
# License: The MIT License
# (See README.TXT or http://www.opensource.org/licenses/mit-license.php for details.)
require 'rubygems'
require 'oklahoma_mixer'
require File.dirname( __FILE__ ) + '/set_extensions'
class TraceCodec
COMPONENT="TraceCod... | true |
0f26c39a4ae470def563e3337f56c2928d49e443 | Ruby | mikelewis/euler | /19/solve.rb | UTF-8 | 587 | 3.1875 | 3 | [] | no_license | def solve
months = {
1 => 31,
2 => 28,
3 => 31,
4 => 30,
5 => 31,
6 => 30,
7 => 31,
8 => 31,
9 => 30,
10 => 31,
11 => 30,
12 => 31
}
num_sundays = 0
start_day = 2
(1901..2000).each do |year|
(1..12).each do |month|
if start_day == 0
num_sundays... | true |
2725ae9435fee54860116335092af61b882842cd | Ruby | 9sako6/ruby-datastructures-algorithms | /lib/fibonacci.rb | UTF-8 | 77 | 2.84375 | 3 | [] | no_license | require "matrix"
def fibonacci(n)
(Matrix[[0, 1], [1, 1]] ** n)[0, 1]
end
| true |
a7b8bc2bf01ef544dfc5d287822dd22346422b6f | Ruby | kim-n/Chess | /steppingsub.rb | UTF-8 | 1,761 | 3.640625 | 4 | [] | no_license | require_relative 'stepping_piece'
class Knight < SteppingPiece
def initialize(position, board, name, color)
super(position, board, name, color)
end
def move_dirs
# uses #move_dirs
# returns array of places that piece can move to
# know what directions a piece can move in
[
[-2, -1],
... | true |
e2443febabcc25f095933f63a67dadd8cdd0882e | Ruby | hafbau/launchSchool | /teaLeaf-ruby-Challenges-series/pigLatin/pig_latin_regex.rb | UTF-8 | 726 | 3.25 | 3 | [] | no_license | class PigLatin
def self.translate(words)
translated_word = ''
words.split(' ').each do |word|
if word[0] =~ /[aeiouAEIOU]/ || word[0..1] =~ /(yt|xr)/
translated_word << word + 'ay '
elsif word[0..2] !~ /[aeiouAEIOU]+/ || ( word[0..1] !~ /[aeiouAEIOU]+/ && word[2] =~ /u/ )
transla... | true |
9c3e0980703613454279a6172fd892067a19bd9c | Ruby | urayoshie/ushibudou_reservation_system | /app/models/reservation.rb | UTF-8 | 10,778 | 2.75 | 3 | [] | no_license | class Reservation < ApplicationRecord
include PerUnitMin
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
VALID_PHONE_NUMBER_REGEX = /\A0\d{1,3}-?\d{2,4}-?\d{3,4}\z/
UNIT_MIN = ConvertTime::UNIT_MIN # 15
LIMITE_UNITS = 8
LIMIT_MIN_RANGE = 0..1680
MAXIMUM_GUEST_NUMBER = 12
ACCEPTABLE_PRIVATE_... | true |
f9b5dd4e892a0d512ba5538b985d3248d241d57c | Ruby | iamchrissmith/battleship | /lib/square.rb | UTF-8 | 1,155 | 3.484375 | 3 | [] | no_license | require 'pry'
class Square
attr_reader :row,
:column,
:neighbors,
:status
attr_accessor :ship
def initialize(row, column)
@row = row
@column = column
@ship = nil
@status = nil
@neighbors = {
above: nil,
below: nil,
left: ni... | true |
1eb7f576f199063c536eacbee0119d16d214e201 | Ruby | nvella/code-folio | /2014-C-ndgmp/rnp/lib/rnp/io_patches.rb | UTF-8 | 168 | 3.09375 | 3 | [] | no_license | class IO
def read_string
buffer = "."
while buffer[-1].ord != 0x00 do
buffer += self.read 1
end
return buffer[1 .. buffer.length - 2]
end
end
| true |
17cbfc1fd7976d75de92bfaef1256688163d8984 | Ruby | jonbartlett/pvoutput-qif | /lib/pvoutput/options.rb | UTF-8 | 3,515 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'singleton'
require 'date'
require 'docopt'
require 'yaml'
module PVOutput
class Options
include Singleton
CONFIG_FILE_PATH = './pvoutput_qif.yml'
# entry point
def self.parse(args)
parsed_args = clean(read_arguments(args))
validate(parsed_args)
if parsed_args["configfi... | true |
c024c00dfb181d616938a6027a4df24d38e96e96 | Ruby | kalap92/cracking_the_code | /XVI_Moderate/pond_sizes_16.19/pond_size.rb | UTF-8 | 846 | 3.15625 | 3 | [] | no_license | def ponds_size(pond, height, width)
sizes = []
for x in 0..height-1
for y in 0..width-1
sizes << count_pond_size(pond, x, y, height, width) if pond[x][y] == 0
end
end
sizes.sort
end
def in_bounds(x, y, width, height)
x >= 0 && y >= 0 && x < width && y < height
end
def count_pond_size(pond, x, ... | true |
326ce43d4e27fa1399d4b5280f2d504d0d9502a5 | Ruby | peagha/pry_game_of_life | /lib/grid.rb | UTF-8 | 1,989 | 3.578125 | 4 | [] | no_license | require 'matrix'
require 'cell'
class Grid
attr_reader :generation
def initialize(string_grid)
load_grid(string_grid)
@generation = 0
end
def load_grid(string_grid)
@grid = string_grid.lines.map do |line|
line.chomp.chars.map do |cell_string|
Cell.new(cell_string == 'x')
end
... | true |
a9a1cccc8b8457d40ee1d1aec110c1886c48474b | Ruby | dougpotter/controlcenter | /branches/backend/lib/app_config_reader.rb | UTF-8 | 919 | 2.515625 | 3 | [] | no_license | require 'ostruct'
require 'yaml'
class AppConfigReader
class ConfigLoadError < StandardError; end
class ConfigFileNotExists < ConfigLoadError; end
class EnvConfigNotExists < ConfigLoadError; end
def initialize(component)
@component = component
end
def apply!(config_mod=nil)
config_mod |... | true |
f4305586768e9e9aa7b2567d52f0f7a913825059 | Ruby | h4hany/leetcode | /scripts/login.rb | UTF-8 | 726 | 2.5625 | 3 | [] | no_license | #!/user/bin/ruby
require 'colorize'
require 'pty'
require 'expect'
def is_login
!`leetcode user`.include?('ERROR')
end
def login_account(credfile)
username, passwd = `head -n 2 #{credfile}`.split("\n")
10.times do
break if is_login
puts '[Sign in ...]'.blue
PTY.spawn('leetcode user -l') do |reader,... | true |
4714482cb15a2e35800d47b79d97f22f08f8faff | Ruby | AllPurposeName/foraker-application | /linked_resume.rb | UTF-8 | 3,681 | 3.5625 | 4 | [] | no_license | require 'yaml'
require 'colorize'
class CurriculumVitae
RESUME = './resume.yml'
attr_reader :resume, :root_node
def initialize(file=nil)
file = file || RESUME
@resume = YAML.load_file(file)
end
def root_node
@root_node || EmptyNode.new(self)
end
def consume_resume
resume.each(&consume)... | true |
3cba8cc66d3010e43b3d19fa986bcd3f3c31c9bd | Ruby | tkengo/mxruby | /spec/mx/eye_spec.rb | UTF-8 | 844 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe MX do
describe 'eye' do
context 'with only first (row) argument' do
it 'creates an array whose diagonal elements are one' do
expect(MX.eye 3).to match_array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
end
end
context 'with two (row and col) arg... | true |
4725ffc514cf0fcb91d80835f145fab3c7ae6067 | Ruby | ksk5280/exercism | /ruby/roman-numerals/roman_numerals.rb | UTF-8 | 652 | 3.46875 | 3 | [] | no_license | class Fixnum
VERSION = 1
@@roman_numerals = ['I', 'V', 'X', 'L', 'C', 'D', 'M']
def to_roman_digit(digit, base=0)
if digit < 4
@@roman_numerals[base] * digit
elsif digit == 4
@@roman_numerals[base] + @@roman_numerals[base+1]
elsif digit < 9
@@roman_numerals[base+1] + @@roman_numera... | true |
122119b3b44de2eb23888aaf1fcdcf9bc7b660c4 | Ruby | Ronzelofficial/sep-assignments | /01-data-structures/07-KevinBacon/graph.rb | UTF-8 | 797 | 3.546875 | 4 | [] | no_license | class Node
attr_accessor :name
attr_accessor :film_actor_hash
def initialize(name)
@name = name
@film_actor_hash = Hash.new
end
end
class Graph
def initialize
@films = []
end
def find_kevin_bacon(initial)
initial.film_actor_hash.each do |movie, actors|
... | true |
612fc34cf07604abce7b57655e45e24b40ccf977 | Ruby | paulizleet/phase-0-tracks | /ruby/my_solution.rb | UTF-8 | 3,813 | 3.9375 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
#
# Makes the ruby script import another script or class from a directory.
require 'pry'
require_relative 'state_data'
class VirusPredictor
# Method: initializ... | true |
250a7c63f2c166439092de0a621442c1dbe0c21e | Ruby | hprose/hprose-ruby | /lib/hprose/client.rb | UTF-8 | 6,303 | 2.671875 | 3 | [
"MIT"
] | permissive | ############################################################
# #
# hprose #
# #
# Official WebSite: http://www.hprose.com/ #
# ... | true |
6c77c457c64373b404556df32362307cad14cf2e | Ruby | NoHomey/PPS-ELSYS-2017-softwares | /classA/21/homework2/task2.rb | UTF-8 | 326 | 3.21875 | 3 | [] | no_license | require 'csv'
require 'matrix'
matri1 = File.new(ARGV[0])
matri2 = File.new(ARGV[1])
m1=CSV.read(matri1)
m2=CSV.read(matri2)
m1=Matrix[*m1].map
m2=Matrix[*m2].map
if m1.column_count == m2.row_count
m3=m1*m2
if m3.square?
m4=m3.t
m4=m4.map
if m4.eql?(m3)
puts 'false'
else
puts 'true'
end
end
else
puts 'undefined... | true |
f6b76cf69ec9a6bdae819b046cdc50091b71a094 | Ruby | aninhalacerda/faces-of-thoughtworks-quiz | /app/main.rb | UTF-8 | 1,517 | 2.78125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/cookies'
require_relative 'lib/crowd'
require_relative 'lib/scoreboard'
get '/' do
if params[:restart] == "now" then
clean_cookies(cookies)
redirect '/'
end
erb :main
end
def clean_cookies cookies
cookies[:right] = "0"
cookies[:wrong] = "0"
cookies[:to_exclude] ... | true |
d8befb06b6867e86d365fce8ebefbd8219d40dbd | Ruby | htano/summary_dev | /scripts/auto_summarize/learning/make_idf_dict.rb | UTF-8 | 891 | 2.65625 | 3 | [] | no_license | # encoding: utf-8
class String
def ngram n
characters = self.split(//u)
return [self] if characters.size <= n
return 0.upto(characters.size-n).collect do |i|
characters[i, n].join
end
end
end
@df_hash = {}
Dir.glob("tmp/auto_summarize/learning/url_summary_contents/????????/train_data_*.txt")... | true |
e222fb9740a607dc4e6c3f66afe4355a8551bc3d | Ruby | bah87/app-academy-daily-projects | /W2D1/chess/board.rb | UTF-8 | 3,760 | 3.484375 | 3 | [] | no_license | require_relative 'king'
require_relative 'queen'
require_relative 'knight'
require_relative 'bishop'
require_relative 'rook'
require_relative 'pawn'
require_relative 'null_piece'
require 'byebug'
require_relative 'display'
class Board
attr_reader :grid
def initialize
@grid = populate_grid
end
def play
... | true |
dbbcef16bba265a291e26be4f78a1a019a7e79ab | Ruby | Lo1176/codewar | /simple_sequence_practice.rb | UTF-8 | 938 | 4.40625 | 4 | [] | no_license | # infos
# A sequence or a series, in mathematics, is a string of objects, like numbers, that follow a particular pattern.
# The individual elements in a sequence are called terms. A simple example is 3, 6, 9, 12, 15, 18, 21, ...,
# where the pattern is: "add 3 to the previous term".
# In this kata, we will be using a ... | true |
860fe6f15a50135624e7a6d68fb2f84dfb73b9b0 | Ruby | synevir/ruby_scripts | /Pension_calc/calc_pension.rb | UTF-8 | 1,834 | 3.078125 | 3 | [] | no_license | ##############################################################
# #
# `calc_pension.rb` is a Ruby script for calculating the #
# worst continuous range of a person work experience #
# according by law changes of 2016. #
# ... | true |
5800f7d90815db777d3ac7efb60162c1e30235ff | Ruby | derwiki/rails-lib | /seo.rb | UTF-8 | 1,568 | 2.546875 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
module Seo
class << self
def google_serp(q)
[[], []].tap do |organic, paid|
start = [0, 10, 20, 30, 40, 50]
start.each do |offset|
url = "http://www.google.com/search?q="\
"#{ URI::encode(q) }&start=#{ offset }"
doc =... | true |
53fa2f26d1840eef8db1b288b8c9de72954bb212 | Ruby | blaksmatic/Interface_no_name | /src/view.rb | UTF-8 | 3,047 | 3.671875 | 4 | [] | no_license | require '../src/graph'
require '../src/view'
require_relative 'controller'
#This function gives out the title page when people use this system
#
def instruction
@spliter = '-----------CSAIR-------------------------'
puts @spliter
puts 'Welcome to the CSair interface'
puts 'You can use the following instruction... | true |
71cb29b4a55e1fb4e24ff9dfd1a61e240a5638f0 | Ruby | dfwheeler394/ruby-algorithms | /iteration/palindrome/code.rb | UTF-8 | 115 | 3.140625 | 3 | [] | no_license | def is_palindrome(str)
return false if str.empty?
str = str.downcase.delete("- ,!'")
str == str.reverse
end
| true |
dd921ebcd66fb271cec418239bcc8ab7c02cf4eb | Ruby | vjoel/bit-struct | /examples/vector.rb | UTF-8 | 1,536 | 3.5 | 4 | [
"Ruby",
"BSD-2-Clause"
] | permissive | require 'bit-struct'
# Example 1
class Vec < BitStruct::Vector
# these declarations apply to *each* entry in the vector:
unsigned :x, 16
signed :y, 32
Entry = struct_class # Give it a name, just for inspect to look nice
end
v = Vec.new(5) # explicit length
entry = v[3]
entry.x = 2
v[3] = entry
entry = v... | true |
d9485deb0e6e252fdab0d3b2a1d5562e6e7a40ec | Ruby | andrewbredow/aoc-2019 | /day_3/panel.rb | UTF-8 | 1,800 | 3.625 | 4 | [] | no_license | require "pry"
class Panel
def initialize(lines)
instructions = lines.map {|l| l.split(",") }
@lines = instructions.map {|i| Line.new(i) }
end
def closest_intersection_distance
throw "WAT" if @lines.length > 2
intersections = @lines.map(&:points).reduce(&:&)
intersections.map {|p| p.map(&:ab... | true |
616b1f9590ec38e50966a674c083b1313249b4c8 | Ruby | SimonDein/launch | /course_101/exercises/easy_7/swap_case.rb | UTF-8 | 647 | 4.375 | 4 | [] | no_license | # Write a method that takes a string as an argument and returns a new string in which every uppercase letter is replaced by its lowercase version,
# and every lowercase letter by its uppercase version.
# All other characters should be unchanged.
# You may not use String#swapcase; write your own version of this method.
... | true |
1e7d2752b81bad799ab5c7ec1e82ada67e0b3c59 | Ruby | adzap/forgery | /lib/forgery/file_reader.rb | UTF-8 | 831 | 3.140625 | 3 | [
"MIT"
] | permissive | module Forgery
class FileReader
def initialize(folder)
@folder = folder
end
# Reads file from a folder and returns array of content lines.
# Strips leading and trailing whitespace, including newlines.
def read_file(file)
lines = []
IO.foreach(find(file)) do |line|
lines... | true |
8cbe80051d71575b0307037a508b012544311aac | Ruby | CyberMameCAN/Sinatra_RSS | /spec/サンプル.rb | UTF-8 | 1,261 | 3.734375 | 4 | [] | no_license | describe '四則演算' do
it '1 + 1は 2 になる事' do
expect(1+1).to eq 2
end
it '10 - 1 は 9 になる事' do
expect(10 -1).to eq 9
end
end
describe '四則演算' do
describe '足し算' do
it '1+1は2になる事' do
expect(1+1).to eq 2
end
end
describe '引き算' do
it '10-1は9になる事' do
expect(10-1).to eq 9
end
end... | true |
4853239a20ac9ef8977360fc0a47527b6bb2436e | Ruby | aw0ng/ruby_practice | /bowling.rb | UTF-8 | 596 | 3.84375 | 4 | [] | no_license | puts "Welcome to Stykers!"
puts "Enter player 1 name"
player1 = gets.chomp
puts "Enter player 2 name"
player2 = gets.chomp
puts player1
puts player2
num_games = []
num_pins = 10
p num_games
p num_pins
roll = 0
if roll = 0
puts "x"
end
if roll = 1
puts "/"
end
roll = 1
if roll != 0 && 1
puts "number_not_stri... | true |
76d0d310e5767af47ef1234add759bb919441ed5 | Ruby | lmartel/UrlShortener | /app/models/link.rb | UTF-8 | 1,347 | 2.84375 | 3 | [] | no_license | require 'URI' unless defined?(URI)
class Link < Sequel::Model
@@character_set = "0123456789abcdefghijklmnopqrstuvwxyz".split("")
@@attempts_max = 8
def self.prepend_protocol(url)
return nil if url.nil?
return url if url.match(/^https?:\/\//)
"http://#{url}"
end
def self.va... | true |
83cbea31dd275bae7ab592c587c8399c5a1fdfce | Ruby | ykz1/LS_120_oop | /4_OOpracticeproblems/2_easy2/10.rb | UTF-8 | 407 | 2.703125 | 3 | [] | no_license | puts "1. Allows more abstract thinking"
puts "2. Represented by nouns; easier to conceptualize"
puts "3. Reduces namespace issues because we can selectively expose functionality"
puts "4. Give functionality to multiple parts of applicaiton without duplication"
puts "5. Because 4 above, can reuse code to build applicait... | true |
6656ff4a5171fc32225041d15440f43609508e1d | Ruby | clayton/lunch-time | /examples/dog_spec.rb | UTF-8 | 1,353 | 3.015625 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
class Dog
attr_accessor :name, :size, :color
def initialize(attrs)
self.name = attrs[:name]
self.size = attrs[:size]
self.color = attrs[:color]
end
def self.packify(dogs)
dogs.sort_by(&:name)
end
def small?
self.... | true |
31d4f82d3bdbf554194aad2241ec14587187d0f6 | Ruby | progrhyme/poloxy | /lib/poloxy/message_container.rb | UTF-8 | 3,495 | 2.609375 | 3 | [
"MIT"
] | permissive | class Poloxy::MessageContainer
include Poloxy::Function::Group
include Poloxy::ViewHelper
attr \
:messages, :undelivered, :snoozed, :group, :level,
:expire_at, :total_num, :kind_num, :item_num, :group_items
def initialize config=nil, args={}
@config = config
@messages = args[:messages]... | true |
356d3a7c61124b55db1b31b3d3f5382545c34eac | Ruby | ncalibey/Launch_School | /exercises/130/easy_01/easy_103.rb | UTF-8 | 373 | 4.0625 | 4 | [] | no_license | # easy_103.rb - Find Missing Numbers
def missing(arr)
return [] if arr.size == 1
missing_num_arr = []
(arr.min..arr.max).each do |num|
missing_num_arr << num if arr.include?(num) == false
end
missing_num_arr
end
p missing([-3, -2, 1, 5]) == [-1, 0, 2, 3, 4]
p missing([1, 2, 3, 4]) == []
p... | true |
8b54865945be232b84e1b704578f3574340519b5 | Ruby | demo-6th/SociView | /lib/tasks/Crawler/Dcard/get_post.rb | UTF-8 | 6,440 | 2.53125 | 3 | [] | no_license | def get_forums
begin
forum_url = "https://www.dcard.tw/_api/forums"
forum_uri = URI(forum_url)
forum_data = Net::HTTP.get(forum_uri)
forum_items = JSON.parse(forum_data)
forums = []
forum_items.each do |forum_item|
forums << [forum_item["name"],
forum_item["alias"],
... | true |
f69bc644f699a3ccffcb99822559754fd2ef1c33 | Ruby | tsmsogn/AOJ | /Volume_001/0174_Badminton.rb | UTF-8 | 332 | 3.109375 | 3 | [] | no_license | while line = gets
serves = line.chomp.split('')
break if serves[0] == '0'
scores = [0, 0]
for i in 1...serves.size
if serves[i] == 'A'
scores[0] += 1
else
scores[1] += 1
end
end
if scores[0] > scores[1]
scores[0] += 1
else
scores[1] += 1
end
puts "#{scores[0]} #{scor... | true |
e8f87f4d28ff4ea47010b5c187a5a2d8099ee4fd | Ruby | fog/fog-aws | /lib/fog/aws/models/compute/security_groups.rb | UTF-8 | 4,501 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'fog/aws/models/compute/security_group'
module Fog
module AWS
class Compute
class SecurityGroups < Fog::Collection
attribute :filters
model Fog::AWS::Compute::SecurityGroup
# Creates a new security group
#
# AWS.security_groups.new
#
# ==== ... | true |
6182afaa27405153161895fae5a244fef730edef | Ruby | thebravoman/software_engineering_2015 | /hm_bonus_minify/B_7_Valentin_Stoyanov/v2.rb | UTF-8 | 203 | 3 | 3 | [] | no_license | def v2 d, v
output = []
@my_csv.each do |line|
l = line.split(',')
if l[0] == d
v = v.to_i
if l[3].to_i > v - 10 and l[3].to_i < v + 10
output << line
end
end
end
puts output
end
| true |
fd27ac720f33e582d398d982ba728082cca188d7 | Ruby | morganpstanley/oo-counting-sentences-online-web-sp-000 | /ola.rb | UTF-8 | 177 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def count_sentences(x)
y = x.split(/! |\? |\. /)
binding.pry
puts y.length
end
count_sentences("Hello. How are you? Good? That's great!! Hi. ")
| true |
05f0edc4b4487538ef0c31777cc6e2eed6606965 | Ruby | cadwallion/cadbot_cinch | /lib/extensions.rb | UTF-8 | 1,224 | 3 | 3 | [] | no_license | module Extensions
def self.camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
if first_letter_in_uppercase
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
else
lower_case_and_underscored_word.to_s[0].chr.downcase + ... | true |
91478c1e3d1a2ac4949b30d5d75289d483a68848 | Ruby | tiy-indy-bee-ror-sept16/course-notes | /week3/day2/drinking_problem.rb | UTF-8 | 1,090 | 3.75 | 4 | [] | no_license | require_relative 'coffee/human'
require_relative 'coffee/coffee'
require_relative 'coffee/red_bull'
class DrinkingProblem
attr_accessor :test_subject, :trials
def initialize
self.test_subject = Human.new "John Doe"
self.trials = 0
end
def experiment(drink = Coffee)
until test_subject.dead?
... | true |
2703393b10d062053f5b757044e38514ca4f75e2 | Ruby | albertbahia/wdi_june_2014 | /w04/d02/michael_ross/encode.rb | UTF-8 | 1,307 | 3.765625 | 4 | [] | no_license | require 'pry'
def encode(word)
new_word = word.split("").map
new_word
end
binding.pry
# FEN
# def encode(input_string)
# alphabet = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
# char_array = input_string.split(//)
# char_indices = char_array.map do |char|
# alphabet.index { |letter| letter... | true |
6c89b1d66f82a51c222488dd959a96511c1bb4d8 | Ruby | marviorocha/notifycustomers | /vendor/bundle/ruby/2.6.0/gems/onesignal-0.3.0/lib/onesignal/request_error.rb | UTF-8 | 433 | 2.796875 | 3 | [
"MIT"
] | permissive | module OneSignal
class RequestError < StandardError
attr_reader :http_status
attr_reader :http_body
def initialize(message, http_status, http_body)
@http_status = http_status
@http_body = http_body
if @http_status
message += " - http status : #{@http_status}"
end
i... | true |
76716159149f43c78ba0be717c9e502910ffd83f | Ruby | chylaudes/bewd_sf_12 | /06_Sharing_Behavior/starter_code/ex_inheritance_office/lib/manager.rb | UTF-8 | 470 | 3.15625 | 3 | [] | no_license | require_relative 'employee'
# A manager is contactable by email,
# and wants their title as part of their name display
class Manager < Employee
#managers have titles and emails
attr_accessor :title, :contact
#make sure a Manager's full name includes their title
def initialize(first_name, last_name, title, contact)... | true |
b79820acc73083231b34926760dc63af9edd210b | Ruby | yamunanavada/oo-my-pets-web-112017 | /lib/owner.rb | UTF-8 | 1,688 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Owner
# code goes here
@@all = [] #keeps track of all owners
attr_reader :species, :name
attr_accessor :pets
def initialize(species)
@species = species
@@all << self
@pets = {fishes: [], cats: [], dogs: []}
end
# Class methods
# keeps track of the owners that have been created (... | true |
65b6ec407807c45a2d1d32e03e110b25d542488a | Ruby | stephaniemhelm/backend_mod_1_prework | /section2/exercises/conditionals.rb | UTF-8 | 276 | 3.84375 | 4 | [] | no_license |
def water_status(minutes)
if minutes < 7
puts "The water is not boiling yet."
elsif minutes == 7
puts "The water is barley boiling."
elsif minutes == 8
puts "The water is boiling!"
else
puts "The water is HOT, HOT, HOT!"
end
end
water_status(10)
| true |
cae5f1b6fb8e4615256d885bf2ecca5426e618db | Ruby | ReggTheSecond/bot_unknown | /src/youtube.rb | UTF-8 | 808 | 2.8125 | 3 | [] | no_license | require 'yt'
class YouTube
attr_accessor :channel
attr_accessor :videos
WATCH = "https://www.youtube.com/watch?v="
def initialize()
Yt.configure do |config|
config.log_level = :debug
config.api_key = ''
end
@channel = Yt::Channel.new id: 'UCLtPX8KiXi_hyMNTFxlHNAQ'
@videos ... | true |
b18e97c9e2ffc56f002f4ac8fda4d20ee4391f91 | Ruby | taw/sectalks-november-2017 | /xorgif/xor_image | UTF-8 | 391 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
def generate_image(key, source_path, target_path)
input_data = open(source_path, "rb").read.unpack("C*")
key = key.unpack("C*")
encrypted = input_data.zip(key.cycle).map{|u,v| u^v}.pack("C*")
open(target_path, "wb"){|fh| fh.write encrypted }
end
if ARGV.size == 3
generate_image(*ARGV)
el... | true |
a292a624544ed353bd5973d6fbed92752871b3da | Ruby | kathinka/prework-videos-intro-to-tests-online-web-sp-000 | /methods_defaultValues_test.rb | UTF-8 | 719 | 3.5625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative './methods_defaultValues.rb'
puts "If no protein is given, default to meat"
answer = meal_choice("veg", "starch")
if answer == "meat"
puts "Passed!"
else
puts "Test failed: got #{answer} instead"
end
puts "You should be able to set a protein"
answer = meal_choice(veg, starch, protein)
if answer =... | true |
c9205ffb50d6122e17999960d2a89c99b327a679 | Ruby | jesseposner/cryptopals | /ruby/spec/set1_spec.rb | UTF-8 | 1,273 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require 'sets/set1'
RSpec.describe 'Set1' do
describe 'Challenge 1' do
let(:hex) { '49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d' }
let(:b64) { 'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t' }
it 'shou... | true |
3a2d6decc47acaa23838cfaf0f101c8ab2704e8b | Ruby | Mr-Bowtie/custom_enumerables | /tests/my_each_test.rb | UTF-8 | 261 | 3.515625 | 4 | [] | no_license | require '../enum_methods.rb'
a = ['a', 'b', 'c']
b = { a: 1, b: 2, c: 3 }
puts '==: my_each'
a.my_each { |el| puts el }
b.my_each { |k, v| puts "#{k} => #{v}" }
p a.my_each
puts '==: each'
a.each { |el| puts el }
b.each { |k, v| puts "#{k} => #{v}" }
p a.each
| true |
479a271a934eed68b68e193624a10936fb56084a | Ruby | dbc-practices/blog_sinatra | /app/controllers/post.rb | UTF-8 | 1,121 | 2.578125 | 3 | [] | no_license | # GET METHODS
get '/post/:id' do
@id = params[:id]
@post = Post.find(@id)
@tags = @post.tags.pluck(:name).join(', ')
erb :show_post
end
get '/edit/:id' do
@id = params[:id]
@post = Post.find(@id)
erb :edit_post
end
get '/delete_confirm/:id' do
@id = params[:id]
@title = Post.find(@id).title
erb :... | true |
4bfe11781f26924e5e283d2ca06f1df292d8a557 | Ruby | KeyFour66/tests-ruby | /lib/02_calculator.rb | UTF-8 | 421 | 3.734375 | 4 | [] | no_license | def add(a, b)
return a + b
end
def subtract(a,b)
return a - b
end
def sum(a)
i = 0
a.each {|a| i += a}
return i
end
def multiply(a, b)
return a * b
end
def power(a, b)
return a ** b
end
def factorial(n)
if n < 0
return nil
elsif n == 0
return 0
elsif n == 1
return 1
else
re... | true |
79650f6cc4696a0eea6ed6bcd533a1807b420e77 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/spectral_cluster/recluster/cft_cluster/cluster2/25169.rb | UTF-8 | 471 | 3.109375 | 3 | [] | no_license | def combine_anagrams(words)
groups = []
words.each do |x|
inc_bool = false
groups.each{|y| inc_bool = true if y.include?(x)}
if inc_bool == false
group = []
groups << group
words.each {|y|
if (x.upcase.chars.sort.join == y.upcase.chars.sort.join); groups.last << y; end
}
end
end
return ... | true |
66e2a2b67a54ecbb6e449642af0f832d764469dc | Ruby | emmaster/media_store | /book.rb | UTF-8 | 427 | 2.953125 | 3 | [] | no_license | class Book < Product
attr_accessor :title, :author_name, :price, :storage
def initialize(price, storage, title = nil)
super(price, storage)
@title = title
@author_name = nil
end
def update(params)
@title = params[:title]
@price = params[:price] if params[:price] != nil
@author_name = p... | true |
c2f2b2021dce8997ec6b98d40d20730b14aea4d6 | Ruby | carradjm/SE_Challenge | /street_easy.rb | UTF-8 | 2,533 | 3.640625 | 4 | [] | no_license | # I didn't feel the need to add any error rescuing. The way the script is
# set up, all of the logic is abstracted from the user, so as long as the user
# runs the script, there will be no errors.
# I also tried to keep the number of instance variables as low as possible.
# The use of Addressable::URI makes it easy to ... | true |
d2b82df378ca0ab6600c410739c130f5c3cbc269 | Ruby | drewgillson/Hive | /surface.rb | UTF-8 | 9,146 | 3.828125 | 4 | [] | no_license | #!/usr/bin/env ruby
module Hive
class Surface < Array
attr_accessor :walkable_bugs, :open_sides
# Every time a bug wants to move, it has to check to see if its move would break the game surface. This method 'walks' the game surface to see if there would be any stranded pieces or islands if the bug ... | true |
d9361b7470f7c23341987f80d1a74000ac64094b | Ruby | engr-hasanuzzaman/utility_ruby_script | /app/color_info.rb | UTF-8 | 728 | 2.8125 | 3 | [] | no_license | # ================================================
# In this file we will declare color schema for our application
# like, to show info text set color cyan
# ================================================
require 'colorize'
class String
def c_info
colorize(color: :blue, background: :white)
end
def c_succ... | true |
fdcb38ee348d1910b2451860e50a834d9c4fb4ca | Ruby | srufle/maze-book-rb | /src/wilsons.rb | UTF-8 | 683 | 3.359375 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
# Wilsons is an algorithm to print a Grid
class Wilsons
def self.on(grid)
unvisted = []
grid.each_cell { |cell| unvisted << cell }
first = unvisted.sample
unvisted.delete(first)
while unvisted.any?
cell = unvisted.sample
path = [cell]
while unvis... | true |
8fe8d7ae1df6bd372f7636d2f58755c057d58b2f | Ruby | mehulsbhatt/presets | /db/seeds.rb | UTF-8 | 1,601 | 2.640625 | 3 | [] | no_license | cheese = Tenant.create! name: "Cheese", subdomain: "cheese"
chunkybacon = Tenant.create! name: "Chunky Bacon", subdomain: "chunkybacon"
default = Tenant.create! name: "Default", subdomain: ""
Tenant.current_id = cheese.id
#
#t = Topic.create! name: "Limburger Pranks"
#t.posts.create! content: "Try putting it under som... | true |
2ebc1cd102136529a12258b9da9e09394fcfd65d | Ruby | dtinth/codehew2016 | /final/02_censor.rb | UTF-8 | 369 | 2.546875 | 3 | [] | no_license | # for I in review/*.txt; do ruby -E utf-8 censor.rb "$I"; done
rude = File.read('rude-words.txt').lines.map(&:strip).sort_by(&:length).reverse
data = File.read(ARGV[0])
out = data.dup
rude.each do |word|
out.gsub!(word, ''.ljust(word.length, '#]!(&@%?'))
end
if out != data
File.write("review_out/censored-#{File.... | true |
54f3f7c8b4031bed47890510263372755718fd5b | Ruby | yetka/sinatra_survey | /lib/survey.rb | UTF-8 | 369 | 2.96875 | 3 | [] | no_license | class Survey < ActiveRecord::Base
has_many(:questions)
before_save(:capitalize_name)
private
def capitalize_name
capitalize_name = ""
name_array = self.name.split(" ")
name_array.map! {|word| word.capitalize}
name_array.each {|capitalize_word| capitalize_name.concat(capitalize_word.to_s + " ")}
... | true |
72d17f69875050c17daef01070226d5a71724b4b | Ruby | gomav/sales_engine | /lib/item_repository.rb | UTF-8 | 1,578 | 2.96875 | 3 | [] | no_license | require_relative 'item' # => true
require_relative 'csv_reader' # => true
class ItemRepository
attr_reader :sales_engine, :items # => nil
def initialize(items = '', sales_engine)
@sales_engine = sales_engine
@items ||= items.map {|item| Item.new(item, self)}
end
def inspect
"#<\#{self.cl... | true |
6f669e42c510f5e8466b21661892039f0c349af1 | Ruby | dtinianow/exercism | /ruby/strain/strain.rb | UTF-8 | 289 | 2.625 | 3 | [] | no_license | class Array
def keep
return enum_for(:keep) unless block_given?
each_with_object([]) { |i, results| results << i if yield(i) }
end
def discard
return enum_for(:discard) unless block_given?
each_with_object([]) { |i, results| results << i unless yield(i) }
end
end
| true |
4ddcfebf648655db10e695d75c3ee89779c084b7 | Ruby | wdevauld/colour | /lib/gradient.rb | UTF-8 | 716 | 3.015625 | 3 | [
"MIT"
] | permissive | class Gradient
def initialize(origin, destination)
@origin = origin
@destination = destination
end
def colour_at(distance_percent)
c = @origin.class.to_s.downcase
origin_rgb = @origin.to_rgb
destination_rgb = @destination.to_rgb
delta_r = destination_rgb.r... | true |
0516559202b6531d8aedb55ace919e7c0c7f07f8 | Ruby | desilerma25/Tv-Encyclopedia | /lib/Show/api.rb | UTF-8 | 510 | 2.765625 | 3 | [] | no_license |
class API
attr_accessor :query
def initialize(query)
@query = query
end
def fetch_info
url = "http://api.tvmaze.com/search/shows?q=#{@query}"
uri = URI(url)
response = Net::HTTP.get(uri)
info = JSON.parse(response)
end
def create_shows
show ... | true |
d163bc4dc2e051012b768f4390ba3116fa765e9d | Ruby | tesk9/puppies | /lib/puppy_breeder/filled_orders.rb | UTF-8 | 590 | 2.8125 | 3 | [] | no_license | module PuppyBreeder
require_relative "../repo/filled_order_repo.rb"
class FilledOrders
attr_reader :puppy, :customer, :price, :date_filled
@@filled = FilledOrderRepo.new
def initialize( customer, puppy, price, date_filled)
@customer = customer
@puppy = puppy
@price = price
@da... | true |
18b45b891470fb3560b431899f37c44d59a7ae07 | Ruby | shaunasalter/projectRuby | /01_temperature/temperature.rb | UTF-8 | 96 | 3.21875 | 3 | [] | no_license | def ftoc(temp_f)
(temp_f - 32) * 5.0/9.0
end
def ctof(temp_c)
temp_c * 9.0/5.0 + 32
end | true |
fee4208dd8deda070e7879835d941492eacbe045 | Ruby | le3ah/denver_public_library | /test/author_test.rb | UTF-8 | 882 | 2.890625 | 3 | [] | no_license | require './test/test_helper'
require './lib/author'
require './lib/book'
class AuthorTest < Minitest::Test
def test_it_exists
charlotte_bronte = Author.new({first_name: "Charlotte", last_name: "Bronte"})
assert_instance_of Author, charlotte_bronte
end
def test_it_starts_with_no_books
charlotte_bront... | true |
5d471a3954ccedfa378a64ebb9dd7afbcffcb6f2 | Ruby | codyrblack/stock-picker | /stockpick.rb | UTF-8 | 391 | 3.484375 | 3 | [] | no_license | def stock_picker(days)
profit = 0
buy_day = 0
sell_day = 0
array = [0,0]
## x = stock price, y = day (created index)
days.each_with_index do |x1, y1|
days.each_with_index do |x2, y2|
if y2 > y1 && x1 - x2 > profit
profit = x1 - x2
buy_day = x1
sell_day = x2
array[0] = y1
array[1] = y2
... | true |
2aa75c7ed77a92fb3b8811b21a2d6f13f42207c6 | Ruby | chrissschin/101-109_exercises | /easy_3/p_7.rb | UTF-8 | 564 | 4.53125 | 5 | [] | no_license | #
# Odd Lists
# Write a method that returns an Array that contains every other element of an Array that is passed in as an argument. The values in the returned list should be those values that are in the 1st, 3rd, 5th, and so on elements of the argument Array.
#
# Examples:
#
# oddities([2, 3, 4, 5, 6]) == [2, 4, 6]
# ... | true |
99a7d06f74d17749d29ac5e1dd20f291d424f20b | Ruby | nathanpena/carbon | /person.rb | UTF-8 | 675 | 4.03125 | 4 | [] | no_license | class Person
attr_accessor :name, :carbon_footprint
def initialize(name, carbon_footprint)
@name = name
@carbon_footprint = carbon_footprint
end
def emitted(carbon)
@carbon_footprint += (carbon)
puts "I increased my carbon footpring by #{carbon} points\nMy carbon footprint is now #{@carbon_foo... | true |
e243c1814ad1a6f20c548df5433c3433912a61bd | Ruby | dpm530/Ruby_Stack | /TDD/ruby_tdd/bank_account_tdd/bank_account.rb | UTF-8 | 1,598 | 3.625 | 4 | [] | no_license | class BankAccount
attr_accessor :account_number,:checking_account,:savings_account
@@bank_account=0
def initialize
@account_number=create_account
@checking_account=0
@savings_account=0
@@bank_account+=1
@interest_rate = 0.01
end
def total
return "Checking Balance: ... | true |
b9466e12784663d7a33a04a0ec64d6c16cea7a2d | Ruby | igrep/tescha | /lib/tescha/result_counter.rb | UTF-8 | 4,599 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'tescha/readiness'
require 'tescha/test/constants'
module Tescha
class ResultCounter
attr_reader :tests, :failures, :skips
def initialize
@tests = []
@failures = []
@skips = []
end
def on_success test
@tests << test
end
def on_failure test
@tests << tes... | true |
965f6e0d3e49f69fe885a344d799470091e3e5e4 | Ruby | Mafooch/sorting | /insert.rb | UTF-8 | 337 | 3.703125 | 4 | [] | no_license | def insert_sort(array)
for outer_index in 1..(array.length - 1)
for inner_index in 0..(outer_index - 1)
if array[inner_index] >= array[outer_index]
array.insert(inner_index, array[outer_index])
array.delete_at(outer_index + 1)
end
end
end
array
end
print insert_sort([6, 5, 3,... | true |
8dee0417405736cb4542ee140d6c41571ae381cb | Ruby | ysei/death_race | /main.rb | UTF-8 | 2,421 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems' rescue nil
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
require 'chingu'
require 'opengl'
require 'gosu'
include Gosu
#require_all(File.join(ROOT, "src"))
# module ZOrder
# Background, Player, UI = *0..2
# end
class Game < Chingu::Window
def i... | true |
9999eca954f91f05652e3171c4832705f4b19cc5 | Ruby | nathan-stamand/zzounds_deals | /lib/zzounds_deals/scraper.rb | UTF-8 | 2,146 | 3.21875 | 3 | [
"MIT"
] | permissive | require 'open-uri'
class Scraper
def self.get_deals
doc = Nokogiri::HTML(open('https://www.zzounds.com/blowouts')).css('div#super-hot').css('div.span-63.prepend-top.prepend-1.append-1').css('div.span-20.featured-prod')
i = 0
length = doc.length
length.times do
name =... | true |
99bab6aecf94091191eb98ebd50b740a030c1266 | Ruby | mbwcogic/ruby-music-library-cli-onl01-seng-pt-100619 | /lib/artist.rb | UTF-8 | 659 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
extend Concerns::Findable
attr_accessor :name
attr_reader :songs, :genres
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def self.destroy_all
self.all.clear
end
def save
@@all << self
end
def s... | true |
fac5a0edd00804d0efca925bf8fbe27366b237dc | Ruby | Dalf32/Omnic | /lib/omnic/model/omnic_event.rb | UTF-8 | 1,615 | 2.8125 | 3 | [
"MIT"
] | permissive | # omnic_event.rb
#
# AUTHOR:: Kyle Mullins
require_relative 'command_helper'
class OmnicEvent
include CommandHelper
attr_reader :handler_class, :event
def initialize(handler_class, event, method_name)
@handler_class = handler_class
@event = event
@method_name = method_name
@pm_enabled = true
... | true |
4dd0d6168e159d30e77e4651f965bc38a62cd5c5 | Ruby | tommyilpazzo/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,137 | 3.890625 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
# YOUR CODE HERE
return 0 if arr.empty?
arr.inject(:+)
end
def max_2_sum arr
# YOUR CODE HERE
return 0 if arr.empty?
return arr[0] if arr.length == 1
arr.sort! { |x,y| y <=> x }
return arr[0] + arr[1]
end
def sum_to_n? arr,... | true |
8f1973a61210f21f005ba22da00cf3f7937e302f | Ruby | JM-Sully/ruby-learning | /animals.rb | UTF-8 | 1,120 | 4.0625 | 4 | [] | no_license | class Animal
attr_reader :name, :age
def name=(value)
if value == ""
raise "You need to enter a name."
end
@name = value
end
def age=(value)
if value < 0
raise "An age of #{value} isn't a valid age."
end
@age = value
end
... | true |
ea12a956922f0f0ae9fe9e215c84475c41fccb08 | Ruby | denis281542/scraper.rb | /parser.rb | UTF-8 | 709 | 2.578125 | 3 | [] | no_license | require 'rubygems'
require 'faraday'
require 'nokogiri'
conn = Faraday.new(:url => 'https://twitter.com/elonmusk/') do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make ... | true |
a3bd53db2601f4d7830f93fd5d081e091afadc8c | Ruby | dearblue/ruby-invfs | /lib/invfs/unionfs.rb | UTF-8 | 1,081 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | #!ruby
require_relative "../invfs"
module InVFS
class UnionFS
attr_reader :dirs
def initialize(*dirs)
@dirs = dirs
end
def file?(lib)
dirs.each do |dir|
path = File.join(dir, lib)
return true if File.file?(path)
end
false
end
def size(lib)
di... | true |
240fa5a0273265be0e8e193c6763a73cdba9bfef | Ruby | plonk/colorpicker | /colorpicker.rb | UTF-8 | 3,976 | 2.703125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# 2012/12/28
# カラーピッカー
require 'gtk2'
include Gtk
require 'scanf'
require "./rgb_db.rb"
class MainWindow < Window
def initialize
@db = RGB_DB.new
super
self.signal_connect("delete-event") {
Gtk.main_quit
}
self.title = "カラーピッカー"
@vbox = VBox.new(false, 10)
... | true |
f7465f7331bb3d04feb309c092e7a0c08beda490 | Ruby | leachj/mqtt-mysensors | /mqtt-mysensors.rb | UTF-8 | 1,784 | 2.796875 | 3 | [] | no_license | require "pstore"
require "serialport"
require 'mqtt'
#params for serial port
port_str = "/dev/ttyACM0" #may be different for you
baud_rate = 115200
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
MESSAGE_TYPE_PRESENTATION = 0
MESSAGE_TY... | true |
b5f79bbec0200bb094704bde417f0a926a754433 | Ruby | zoso10/hush | /history.rb | UTF-8 | 670 | 2.8125 | 3 | [] | no_license | # frozen_string_literal: true
module Hush
class History
@commands = []
class << self
def call(*)
output = commands.
take(16).
map.
with_index { |c, idx| idx.to_s.rjust(5) + " #{c}" }
$stdout.puts(output)
end
def add(command)
command =... | true |
b04c5f9cbee89b229265d35e5410617619db1041 | Ruby | JordanPag/Ruby-2017 | /RubyHW2part2.rb | UTF-8 | 4,360 | 2.890625 | 3 | [] | no_license | require "google_drive"
cert_path = Gem.loaded_specs['google-api-client'].full_gem_path+'/lib/cacerts.pem'
ENV['SSL_CERT_FILE'] = cert_path
session = GoogleDrive::Session.from_config("config.json")
sheet = session.spreadsheet_by_key("1REau9FnyfO5qXs3kYBsXIPlAJquszUV1u7TAQJ09kEQ")
ws = sheet.worksheets[0]
def checkf... | true |
1e4f552656945d2d297fe32e807e65fc274e1f99 | Ruby | bjornno/kidsa | /lib/send_template.rb | UTF-8 | 362 | 2.671875 | 3 | [] | no_license | # encoding: UTF-8
require_relative '../lib/communication'
puts "hva heter du?"
print "> "
meg = gets.chomp
while true do
puts "hvem vil du sende melding til?"
print "> "
mottaker = gets.chomp
print "melding > "
melding = gets.chomp
print "kryptering > "
kode = gets.chomp.to_i
send_melding(mottaker, m... | true |
d77269524d6e7290b9215bf1e0267164c93e81e8 | Ruby | UsmanJ/rps-challenge | /rps_web.rb | UTF-8 | 2,436 | 2.671875 | 3 | [] | no_license | require 'sinatra/base'
require './lib/game'
require './lib/computer'
require './lib/player'
class RpsWeb < Sinatra::Base
enable :sessions
set :views, proc { File.join(root, 'views') }
get '/' do
erb :index
end
post '/' do
session[:players] = params[:players]
redirect ('/players')
end
get ... | true |
5a76fb3c3cfd7968aeaec28d7b07a6da18201aab | Ruby | paulfioravanti/three_little_pigs | /test/lib/chapters/chapter_07_second_pig_meets_stick_man_test.rb | UTF-8 | 622 | 2.53125 | 3 | [
"CC-BY-4.0",
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
module ThreeLittlePigs
module Chapters
class Chapter07SecondPigMeetsStickManTest < Minitest::Test
attr_reader :story, :stick_man
def setup
suppress_output do
@story = Story.until_chapter(Chapter07SecondPigMeetsStickMan)
... | true |
4b6df1a878df9d261632245c8720ef14b887632e | Ruby | bretts/to_bar_graph | /spec/test/bucketizer_spec.rb | UTF-8 | 4,647 | 2.828125 | 3 | [] | no_license | require_relative '../spec_helper'
describe 'Bucketizer' do
describe "#create_buckets" do
before :all do
@array_data = ["ice cream", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", "pie", ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.