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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fe09584a9b704fc4eba877c28b8492077371961b | Ruby | ensallee/green_grocer-nyc-web-042318 | /grocer.rb | UTF-8 | 1,608 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def consolidate_cart(cart)
new_hash={}
cart.each do |list|
list.each do |item, qualities|
if new_hash[item]
qualities[:count] += 1
else
qualities[:count] = 1
new_hash[item] = qualities
end
end
end
new_hash
end
def apply_coupons(cart, coupons)
n... | true |
fcd37199b53932cff489fdfba48af38e9fd0019d | Ruby | tanphan313/leet_works | /problems/hash_table/top_k_frequent_words.rb | UTF-8 | 1,074 | 3.921875 | 4 | [] | no_license | <<-Doc
Given an array of strings words and an integer k, return the k most frequent strings.
Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequency by their
lexicographical order.
Input: words = ["i","love","leetcode","i","love","coding"], k = 2
Output: ["i","love"]
... | true |
4bd4c6d411b979ba2b68cc5a8801edb3de4b4292 | Ruby | scmwalsh/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 130 | 3.15625 | 3 | [] | no_license | def add( a, b)
a + b
end
def subtract(a, b)
a - b
end
def sum ( a )
sum = 0
a.each { |number| sum += number }
sum
end
| true |
aa1d8c145fdee089fc7be5ef61cf93a2695d4604 | Ruby | tinomen/metric_fu | /lib/metric_fu/flog_reporter/page.rb | UTF-8 | 805 | 2.8125 | 3 | [
"MIT"
] | permissive | module MetricFu::FlogReporter
class Page
attr_accessor :score, :scanned_methods
def initialize(score, scanned_methods = [])
@score = score.to_f
@scanned_methods = scanned_methods
end
def to_html
output = "<html><head><style>"
output << Base.load_css
output << "<... | true |
fd9540e28156edc5e208631ed4c25463d501c13d | Ruby | Vicky099/two_factor_application | /lib/json_web_token.rb | UTF-8 | 317 | 2.609375 | 3 | [] | no_license | class JsonWebToken
SECRET_KEY = Rails.application.secrets.secret_key_base.to_s
def self.encode(payload, exp = 24.hours.from_now)
payload[:exp] = exp.to_i
JWT.encode(payload, SECRET_KEY)
end
def self.decode(token)
decoded = JWT.decode(token, SECRET_KEY)[0]
HashWithIndifferentAccess.new decoded
end
end
| true |
cb6fa3a91f85381ea4974843e138d7117ae9b702 | Ruby | davis-campbell/ruby | /con4/spec/connect_four_spec.rb | UTF-8 | 4,206 | 3.515625 | 4 | [] | no_license | require_relative '../connect_four'
describe Game do
before :all do
@game = Game.new
end
describe '#new' do
it 'generates a Board' do
expect(@game.board).to be_an_instance_of Game::Board
end
it 'gives Player 1 the first turn' do
expect(@game.player1.is_turn).to be true
expect(... | true |
384c72cde445e7512c70b637f9450b612358b09c | Ruby | fect11/ttt-7-valid-move-ruby-intro-000 | /lib/valid_move.rb | UTF-8 | 329 | 3.375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # code your #valid_move? method here
def valid_move?(board, index)
board[index] == "" || board[index] == " "
# user_input = gets.strip
# input = user_input.to_i.
# index = input - 1
# index.between?(1,9)
end
def position_taken?(board, index)
!(board[index].nil? || board[index] == " "|| board[index] == ... | true |
9b5d4dff796ac2821ffbac114f21eb8211fe5f0a | Ruby | HeyNeek/phase-3-running-ruby-code | /app.rb | UTF-8 | 333 | 3.546875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #puts "Hello World"
#print "Hello World"
#print "Hello World"
#print "Hello World"
#p [1, 2, 3]
#pp [{ id: 1, hello: "World" }, { id: 2, hello: "Ruby" }, { id: 3, hello: "Moon" }, { id: 4, hello: "Learner" }]
#different ways to print out different types of data in Ruby
puts "Hello World!"
print "Pass this test, pleas... | true |
332c5376c18ecd0359bee7d035851bf6a3deff95 | Ruby | AlexandrePerdomo/rails-longest-word-game | /app/controllers/game_controller.rb | UTF-8 | 1,236 | 2.96875 | 3 | [] | no_license | class GameController < ApplicationController
def game
@length = params[:length] ? params[:length].to_i : 8
@grid = generate_grid(@length)
@start_time = Time.now
session["start"] = @start_time
session["grid"] = @grid
end
def score
@grid = session["grid"]
@start_time = Time.parse(sessi... | true |
d2ce393762c675c923e984fc9aec18a245303f95 | Ruby | dmytro/ATTIC | /aws_deploy/lib/awsdeploy/cli/store.rb | UTF-8 | 1,115 | 2.59375 | 3 | [
"MIT"
] | permissive | module AWSDeploy
class CLI
include Mixlib::CLI
option :reset,
:description => "Forget instance, remove data about specific instance from local memory",
:short => "-r BRANCH", :long => "--reset BRANCH", :exit => 0 ,
:on => :head,
:proc => Proc.new { |br|
AWSDeploy::Marshal.new.forget(br... | true |
7ada145aad9e9e1cc7ff2048bf1d7079666b3a6e | Ruby | conbu/conbu-api-server | /location/tokyo_rubykaigi11.rb | UTF-8 | 270 | 2.78125 | 3 | [] | no_license | @location = {}
@location[:floor_2] = [
:"2-1",
:"2-2",
:"2-3",
:"2-4",
:"2-5",
:"2-6",
:"2-7",
]
@location[:floor_5] = [
:"5-1",
:"5-2",
:"5-3",
]
@location[:all] = @location[:floor_2] + @location[:floor_5]
@location[:all] = @location[:all].sort
| true |
c928284204f668170b042bbadfd3c1ec56c35010 | Ruby | seanliu93/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 2,345 | 3.875 | 4 | [] | no_license | require 'pry'
class Computer < Player
WIN_COMBINATIONS = [
[0,1,2], # top row
[3,4,5], # middle row
[6,7,8], # bottom row
[0,3,6], # left column
[1,4,7], # mid column
[2,5,8], # right column
[0,4,8], # diag 1
[6,4,2] # diag 2
]
def move(board)
WIN_COMBINATIONS.each do |combo|
count = 0
... | true |
3e13e630fdfc4bb666b5c2756f0d3a643406e19b | Ruby | codetriage-readme-bot/carver | /lib/carver/presenter.rb | UTF-8 | 1,302 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Carver
class Presenter
BYTES_TO_MB_CONSTANT = 1024**2
def initialize(results, path, action, parent)
@results = results
@path = path
@action = action
@parent = parent
end
def log
Rails.logger.info(
"[Carver] source=#{entry_... | true |
c5ab97c13d0c44957a7ecba0baa00ad378a37edd | Ruby | somethinrother/bitmaker_lessons | /ruby_fundamentals2/ruby_fundamentals2_e5.rb | UTF-8 | 152 | 3.546875 | 4 | [] | no_license | def greet_backwards
puts "What is your name?"
user_name = gets.chomp.reverse
puts "Hello, #{user_name}! Welcome home."
end
puts greet_backwards
| true |
9a8e3e61979328f904af99142f4f96b0d5927ff9 | Ruby | Kevintudiep/solar_system | /galaxy.rb | UTF-8 | 286 | 3.265625 | 3 | [] | no_license | class System
def initialize
@bodies = []
end
def bodies
@bodies
end
def add(body)
@bodies << body
end
def total_mass
return @bodies.sum
end
end
# milky = System.new
# puts milky.bodies
# puts '---'
#
#
#
# milky.add('jupiter')
# puts milky.inspect
| true |
e0501b2b6dd9cd37314a0dcd8a4d4570e5ba7afa | Ruby | grumoz/Chris-Pine-Learn-to-Program-Ruby | /5.6/better_favorite_number.rb | UTF-8 | 104 | 3.5625 | 4 | [] | no_license | puts "Your favorite number:"
num = gets.chomp.to_i + 1
puts num.to_s + " is a bigger and better number"
| true |
17acf7fa5db577560f767404ae742ba23f433007 | Ruby | mainangethe/learn-to-code-w-ruby-bp | /old_sections/parallel_variable_assignment.rb | UTF-8 | 322 | 4.34375 | 4 | [] | no_license | # parallel variable assignment - variables are assigned at the same line
a = 10
b = 20
c = 30
#shorter syntax (just use ',' to concatenate multiple prints)
print a, b, c
#multiple assignment (same thing, use ",")
a, b, c = 10, 20, 30
puts
puts a, b,c
#swapping variables
a, b = 1,2
puts a,b
a,b = b,a
print a,... | true |
5e73d1db1dff244dc24516b499d1dd30d5f6d348 | Ruby | itggot-markus-moen/Popen-Generator | /v.1/you_are.rb | UTF-8 | 1,501 | 3.53125 | 4 | [] | no_license | require_relative "alignment.rb"
require_relative "attributes.rb"
require_relative "background.rb"
require_relative "class.rb"
require_relative "equipment.rb"
require_relative "race.rb"
require_relative "sex.rb"
require_relative "spells.rb"
def you_are()#alignment, attributes, background, class, equipment, race, sex, s... | true |
c7758f03bacc9aa7ec52bae8f85bdb447f29c3be | Ruby | BCoulange/evadesWebSite | /lib/mailing_importer.rb | UTF-8 | 252 | 2.671875 | 3 | [] | no_license | # encoding: utf-8
class MailingImporter
require 'csv'
# Import des adresses CSV
def self.importemails(csv_text)
emails = []
csv = CSV.parse(csv_text, :headers => true)
csv.each do |row|
emails << row[14]
end
return emails
end
end | true |
d7a586ffcb81cf8e83bb0936956321ae88e4dc0b | Ruby | awenkoff/MFA | /MFA_part2.rb | UTF-8 | 699 | 3.453125 | 3 | [] | no_license | require 'json'
puts "What is your email?"
email = gets.chomp
f = File.new("./randomemails.txt","r")
json_data = f.read
f.close
ruby_data = JSON.parse(json_data)
record = ruby_data[email]
if record == nil
puts "Email cant be found"
else
puts "What is your Password?"
password = gets.chomp
require 'digest... | true |
d7c902dddf4bc6d8c8b4391d3bda1dd402bf7370 | Ruby | pombreda/measure-everything | /code/demo.rb | UTF-8 | 545 | 2.671875 | 3 | [] | no_license | require 'statsd'
$statsd = Statsd.new('82.196.8.168')
def authentication(status = :success, count = 1)
key = "events.password.#{status}"
puts "sending #{count} x #{key} to statsd"
$statsd.count key, count
end
def random_authentication(status = :success, factor = 5)
count = 1000
while count > 0
rand_cou... | true |
00617357089b6c2abf933eedeaf3f9c9a52e5d55 | Ruby | JoriPeterson/sweater_weather | /app/services/unsplash_service.rb | UTF-8 | 477 | 2.59375 | 3 | [] | no_license | class UnsplashService
def initialize(location)
@location = location
end
def get_background
get_json("/search/photos?")
end
private
def conn
Faraday.new('https://api.unsplash.com') do |f|
f.params['client_id'] = ENV["UNSPLASH_API_KEY"]
f.params['query'] = "#{@location}"
f.ad... | true |
ceb22a4ddaf5e8796b8717338ebda35519b52e78 | Ruby | FunabashiKousuke/EnjoyRuby | /第6章/for.rb | UTF-8 | 184 | 3.734375 | 4 | [] | no_license | sum = 0
for i in 1..5 do
sum = sum + i
end
puts sum
# 出力結果: 15
# for文構文:
# for 変数 開始時の数値..終了時の数値 do
# 繰り返したい処理
# end
| true |
e6c4532be1831c85e3c0ed755d00b38b121fe629 | Ruby | Redvanisation/tic-tac-toe-ruby | /bin/main.rb | UTF-8 | 924 | 3.734375 | 4 | [] | no_license | require_relative '../lib/game'
require_relative '../lib/player'
require_relative '../lib/board'
puts
puts
puts "Welcome to Tictactoe game "
puts
puts "The following is a table showing the slots numbers"
puts
puts " ******************* "
puts " 1 2 3 "
puts " 4 5 6 "
put... | true |
6d5b6c17fa1df65b80e0e0ccc4e4daf79a85b337 | Ruby | reactormonk/usher | /lib/usher/node.rb | UTF-8 | 6,030 | 2.796875 | 3 | [] | no_license | require File.join('usher', 'node', 'root')
require File.join('usher', 'node', 'root_ignoring_trailing_delimiters')
require File.join('usher', 'node', 'response')
class Usher
# The node class used to walk the tree looking for a matching route. The node has three different things that it looks for.
# ## Normal
... | true |
8a4913d4c38b1c2365bd0f318eb0c64229b9e306 | Ruby | szrharrison/prime-ruby-web-031317 | /prime.rb | UTF-8 | 292 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(n)
n = n
if ( n <= 1 )
is_p = false
elsif ( n == 2 || n == 3 )
is_p = true
else
for d in 2..Math.sqrt( n )
if ( n % d == 0 )
break is_p = false
else
is_p = true
end
end
end
return is_p
end
prime?(40)
| true |
84dd968ade05c23e89b12cd2a1befb94fe1e516e | Ruby | Nevens-fr/Projet_L3_Info | /Editeur/Ecran_jeu.rb | UTF-8 | 1,281 | 3.296875 | 3 | [] | no_license | load "Grille.rb"
##
# Représentation d'un écran de jeu, une partie de fill a pix
##
# * +win+ La fenêtre graphique du programme
# * +boite+ Gtk::box qui contiendra le plateau de jeu et les différents boutons
# * +grille+ Une instance de la classe Grille_jeu représentant le plateau de jeu
# * +quit+ G... | true |
9ecf3979700226542cba81340f7eebcdb6a2707d | Ruby | Visiona/learn_ruby | /10_temperature_object/temperature.rb | UTF-8 | 636 | 4.03125 | 4 | [] | no_license | class Temperature
def initialize(attrs={})
@f = attrs[:f]
@c = attrs[:c]
end
def ftoc (temp)
(temp - 32.0 ) * 5.0 / 9.0
end
def ctof (temp)
temp * 9.0 / 5.0 + 32.0
end
def in_celsius
return @c if @c
return ftoc(@f) if @f
end
def in_fahrenheit
return @f if @f
return ... | true |
23ad0b1fc769580e36019e84700114d3e8d35f3c | Ruby | kitz99/curiosity | /exceptions/invalid_instruction.rb | UTF-8 | 145 | 2.609375 | 3 | [
"MIT"
] | permissive | class InvalidInstruction < StandardError
def initialize(message)
@message = message
end
def to_s
"#{@message} #{super}"
end
end
| true |
d956943fb4a5475911a39ddae71e865717376e6f | Ruby | jamesjtong/oo-tictactoe | /void_location.rb | UTF-8 | 187 | 2.609375 | 3 | [] | no_license | class VoidLocation
attr_accessor :symbol
attr_reader :top, :top_left, :top_right, :left, :right, :bottom, :bottom_left, :bottom_right
def initialize
self.symbol = "V"
end
end | true |
c53185c81ee66f59663e883f8fb73e6dff91629f | Ruby | iskodirajga/retrodot | /lib/chat_ops/command.rb | UTF-8 | 2,396 | 2.828125 | 3 | [
"ISC"
] | permissive | module ChatOps
class CommandSetup
attr_reader :config
def initialize
@config = {}
end
def match(m)
@config[:regex] = m
end
def help(h)
@config[:help] = h
end
def incident_optional(value=true)
@config[:incident_optional] = value
end
end
class Command... | true |
8483bdd07b5ee304f37ce3b7859b19a42f9713f4 | Ruby | zhoujz10/biotcm | /lib/biotcm/modules/utility.rb | UTF-8 | 1,139 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'net/http'
module BioTCM
module Modules
# Provide utility functions
module Utility
# A useful method for diverse purposes
# @overload get(url)
# Get an url
# @param url [String]
# @return [String] if success, the content
# @return [nil] if cannot recognize ... | true |
8aff1368080740cc9ffc5a26226c5facc229770e | Ruby | peterc/author | /data/n.rb | UTF-8 | 94 | 2.546875 | 3 | [
"MIT"
] | permissive | File.open("names2.txt", "w") { |f| f.puts File.readlines("names.txt").map(&:downcase).join }
| true |
e0af7bc998bb9a11e4ae1ffe2507cd531dad7a35 | Ruby | evheny0/bsuir-labs | /model/lab1/main.rb | UTF-8 | 1,325 | 3.09375 | 3 | [] | no_license | require './magic_rand.rb'
require './rand_analyzer'
require 'gnuplot'
def print_histogram(array, size)
array.each do |_k, v|
puts('*' * (v * 1000 / size))
end
end
def new_rand
new_rand = MagicRand.new
printf 'Enter new params? (y/n): '
if gets.chomp == 'y'
printf 'Enter M: '
new_rand.m = gets.to... | true |
3e6bcdd1c1ae838e1d90ca0138c4a1c3dc8b50b7 | Ruby | fur0ut0/filmarks-exporter | /app.rb | UTF-8 | 1,348 | 2.796875 | 3 | [] | no_license | # frozen_string_literal: true
require 'net/http'
require 'optparse'
require 'uri'
require_relative 'filmarks_exporter/filmarks_extracter'
# main application
class App
def initialize(args)
@url, @options = parse_args(args)
end
def run
html = if @url =~ /^http.*/
Net::HTTP.get(URI... | true |
c1a068d89bbe9a427f3b67013f0da38e29acb2f1 | Ruby | hoshi-sano/digyukko | /managers/story_manager.rb | UTF-8 | 8,477 | 2.546875 | 3 | [
"Zlib"
] | permissive | module DigYukko
module StoryManager
include HelperMethods
CUSTOM_STORY_DIR = File.join(DigYukko.app_root, 'customize', 'stories')
STORY_DIR = File.join(DigYukko.app_root, 'data', 'stories')
class << self
def init(story_type, next_scene_class, next_scene_args = [])
@slides = load_story(... | true |
a97e8e61078770e737cb048ccae180fd1d7e817b | Ruby | jk1dd/daily-practice | /solved_to_review/driver_license.rb | UTF-8 | 2,975 | 3.5 | 4 | [] | no_license | # 1–5: The first five characters of the surname (padded with 9s if less than 5 characters)
#
# 6: The decade digit from the year of birth (e.g. for 1987 it would be 8)
#
# 7–8: The month of birth (7th character incremented by 5 if driver is female i.e. 51–62 instead of 01–12)
#
# 9–10: The date within the month of birt... | true |
293d8cb3d7d870550c334ec9c63d1cde3f85f40b | Ruby | silentrob/hydraproject | /lib/make-torrent.rb | UTF-8 | 1,783 | 2.734375 | 3 | [] | no_license | require 'digest/sha1'
require 'rubytorrent'
class MakeTorrent
def initialize(file_path, tracker_url, file_url=nil)
@file_path = file_path
@file_url = file_url
@file_size = File.size(@file_path)
@tracker = tracker_url
[64, 128, 256, 512].each do |size|
@num_pieces = (@file_size.to_f / size ... | true |
caa47a6b49ce49e9927f2d38292c1501c0af56bd | Ruby | dbbrandt/zype-cli | /lib/zype/commands/video.rb | UTF-8 | 4,516 | 2.5625 | 3 | [] | no_license | require 'thor'
require 'zype/progress_bar'
require 'zype/uploader'
module Zype
class Commands < Thor
desc 'video:list', 'List videos'
method_option 'query', desc: 'Video search terms',
aliases: 'q', type: :string
method_option 'type', desc: 'Show videos of the specified type',
... | true |
beb28972b0a084e0694856e74b26016166f16049 | Ruby | codepedia/ruby_utils | /ruby1.rb | UTF-8 | 145 | 3.1875 | 3 | [] | no_license | 1#!/usr/bin/env ruby
name = ["fred" , "Bob" , "jim" , "zeyad"]
name.each do |x|
puts "My name is : #{x}"
puts "my new name is $x"
end
| true |
41fd61baaf0e0a3509a985d89518773f3a5c3b44 | Ruby | ohishikaito/cherry_book | /before_lessons/8.rb | UTF-8 | 5,317 | 2.625 | 3 | [] | no_license | # # # # # # # # module Loggable
# # # # # # # # # private
# # # # # # # # # protected
# # # # # # # # def log(text)
# # # # # # # # puts "log: #{text}"
# # # # # # # # end
# # # # # # # # def pr
# # # # # # # # puts price
# # # # # # # # end
# # # # # # # # end
# # # # # # # # a = "a"
# # # # # # #... | true |
23af5ae936779f4581b6d4d89c1baa6059a2ed52 | Ruby | andlogic/hackerrank | /ruby/warmup/the-time-in-words.rb | UTF-8 | 889 | 3.78125 | 4 | [
"MIT"
] | permissive |
words = { 1 => 'one', 2 => 'two', 3 => 'three' , 4 => 'four', 5 => 'five' , 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven' , 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'quarter', 30 => 'half' }
def to_w(h,m,w,words)
if m == 0
puts words[h] + ' o\' clock'
elsif ... | true |
093cd0b7d51eee2bdf1702de1e226735a6c0cd75 | Ruby | rmullig2/playlister-sinatra-v-000 | /app/models/genre.rb | UTF-8 | 460 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre < ActiveRecord::Base
has_many :song_genres
has_many :songs, through: :song_genres
has_many :artists, through: :songs
def slug
self.name.downcase.split.join("-")
end
def self.find_by_slug(slug)
#no_slug = slug.split("-").map(&:capitalize).join(" ")
no_slug = slug.split("-").join(" "... | true |
c0a5a127deffebade9b3129296f6ffe5c446ade0 | Ruby | conanite/phonefu | /spec/parse_spec.rb | UTF-8 | 4,607 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'phonefu'
describe Phonefu do
def self.expect_number input, assume_country, expected_country, expected_digits, mob
it "returns #{expected_digits.inspect} in #{expected_country.inspect} for #{input.inspect} assuming country #{assume_country.inspect}" do
tn = Phonefu.parse input... | true |
34a4406137c46e5ef0718341bc6f57e95636316e | Ruby | GetlinN/JumpStart | /candy_machine.rb | UTF-8 | 1,689 | 4 | 4 | [] | no_license | # Candy machine assignment
# https://github.com/Ada-Developers-Academy/jump-start/tree/master/learning-to-code/programming-expressions#candy-machine-assignment
candy_options = ["mars", "snickers", "twix", "bounty", "almond joy"]
candy_price_list = { A: "0.65", B: "0.50", C: "0.75", D: "1.00", E: "0.40" }
puts "\nWe... | true |
d02273a7eea2e603242c7e4f347ba979c7fa83a6 | Ruby | daianef/desafio-dev-umbler | /api/lib/domain_information.rb | UTF-8 | 2,202 | 3.59375 | 4 | [] | no_license |
#
# Organiza as informacoes para facilitar
# a manipulacao delas como listas e hashes.
#
class DomainInformation
TITLE = 'title'
SECTION = 'section_values'
UNIQUE = 'unique_values'
MULTIPLE = 'multiple_values'
RAW = 'raw'
def initialize(domain_informations, info_config)
@infos = domain_informations
... | true |
1dcd3f605d45d09f510bc2125777c599d2b7566d | Ruby | tuxfight3r/rake_demo | /Rakefile | UTF-8 | 3,169 | 2.71875 | 3 | [] | no_license | require 'yaml'
require 'pp'
#Global tasks
desc "default task"
task :default =>[:test]
task :test do
puts "default task"
end
desc "list files from ~"
task :list do
files = Dir["file*"].sort
puts files
end
desc "Restart WebServer"
task :restart do
touch "restart.txt"
end
#namespaces to contain tasks
namespac... | true |
7b9803d04e741f0ebc4c2193e47d2345e0a072b4 | Ruby | jvogt/chef-custom-resource-flags-example | /cookbooks/testing/resources/foo.rb | UTF-8 | 1,559 | 3.078125 | 3 | [
"MIT"
] | permissive | # Define your list of props that will be used as command line flags
flag_props = [
{name: :some_string, type: String, default: 'somevalue'},
{name: :some_bool, type: [TrueClass, FalseClass], default: false},
]
# Iterate over above list to generate properties
flag_props.each do |prop|
property prop[:name], pro... | true |
9cd49f8ae62f6e6dad3b50ee1ce522f6a016883a | Ruby | awanderson8/Pine-Practice | /mix1.rb | UTF-8 | 334 | 4.1875 | 4 | [] | no_license | puts "What's your first name?"
name1 = gets.chomp
name1 = name1.downcase.capitalize
puts ""
puts "What's your middle name?"
name2 = gets.chomp
name2 = name2.downcase.capitalize
puts ""
puts "What's your last name?"
name3 = gets.chomp
name3 = name3.downcase.capitalize
puts ""
puts "Hello #{name1} #{nam... | true |
18f2c4722b8afcb0072e1bd8cddc573f88315fd0 | Ruby | mullr/patterns_presentation | /observer.rb | UTF-8 | 354 | 3.4375 | 3 | [] | no_license | class AModel
def initialize()
@a = 1
@observers = []
end
def a
@a
end
def a=(val)
@a = val
@observers.each do |observer|
observer.call(val)
end
end
def observe_a_with(proc)
@observers.push(proc)
end
end
test = AModel.new
test.observe_a_with ->(val) { puts "The val... | true |
b0e60dc5f1b2a2df5eb47b50e05d9774766f9bee | Ruby | sunhuachuang/study-demo | /ruby/class_methods.rb | UTF-8 | 3,871 | 3.609375 | 4 | [] | no_license | class Dog
attr :name
def speck
puts self.name
end
def initialize name
@name = name
end
end
(Dog.new 'Tom').speck
# puts Dog.new.methods.inspect
class Test
def self.self_method
puts 'self method'
end
def default_method
puts 'default method'
end
def get_default_method
self.def... | true |
2a2e4bd1fd2a7145ab2c7e45222ef68940d299c5 | Ruby | renecasco/super_sports_games | /lib/event.rb | UTF-8 | 629 | 3.625 | 4 | [] | no_license | class Event
attr_reader :name,
:ages
def initialize(name, ages)
@name = name
@ages = ages
end
def max_age
ages.max(1)
end
def min_age
ages.min(1)
end
def average_age
(ages.sum.to_f / ages.count).round(2)
end
def standard_deviation_age
sum_of_integers =... | true |
eda4a5b73a0360a282fbcaac5b535033436c5048 | Ruby | robinst/taglib-ruby | /docs/taglib/base.rb | UTF-8 | 7,911 | 3.078125 | 3 | [
"MIT",
"LGPL-2.1-only",
"MPL-1.0",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.0-or-later"
] | permissive | # This is the top-level module of taglib-ruby.
#
# Where to find what:
#
# * Reading/writing basic tag and audio properties without having to
# know the tagging format: {TagLib::FileRef}
# * Reading properties of MPEG files: {TagLib::MPEG::File}
# * Reading/writing ID3v2 tags: {TagLib::MPEG::File}, {TagLib::RIFF::AIF... | true |
fb1a5796603f1f8800ff77e296ee3320f2e9e37b | Ruby | maxcyp/intro_to_programming | /8_hashes/8_3.rb | UTF-8 | 181 | 3.046875 | 3 | [] | no_license | family = { uncles: "bob", sisters: "jane", brothers: "rob", aunts: "sally" }
family.each_key { |i| puts i}
family.each_value { |i| puts i }
family.each {|x, y| puts "#{x}: #{y}"} | true |
f69b3804b99f258ed709d6893db4fd1fcc5cbb05 | Ruby | chaoshades/rmvx-ebjb-core | /src/Misc Objects/ItemFilter.rb | UTF-8 | 3,394 | 2.765625 | 3 | [
"MIT"
] | permissive | #==============================================================================
# ** ItemFilter
#------------------------------------------------------------------------------
# Represents an Item filter
#==============================================================================
class ItemFilter < UsableItemFilte... | true |
c6d07396bd7413d7c3bfe002c71b5bbdf5d61547 | Ruby | UpAndAtThem/practice_kata | /battleship.rb | UTF-8 | 719 | 2.859375 | 3 | [] | no_license | # -create 9*9 board
# -create ships
# -have player 1 place ships
# -each ship should prompt an up down left or right option. and check to see if valid
# -whatever direction take ship.length -1 to auto place the ship (so a 4 ship the player doesn't have to choose 4 positions, just the start and direction)
# -have ... | true |
16ee7fe5b38bce821ad53c118551b8a3a7ba39e6 | Ruby | lasanders/site-deals-cli-app | /site_deals/lib/site_deals/deals.rb | UTF-8 | 791 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'pry'
class SiteDeals::Deals
attr_accessor :name, :price, :availability, :url, :title
@@deals = []
def initialize(name = nil, title = nil, price = nil, url = nil)
@name = name
@price = price
@url = url
@title = title
#binding.pry
@@deals << self
end
def self.today
self.s... | true |
b36cea530e38afb6fe26cb162602d5e8a2a176db | Ruby | xenda/juanfanning | /parser.rb | UTF-8 | 737 | 2.84375 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
URL = "http://elcomercio.pe/cine/cartelera"
doc = Nokogiri::HTML(open(URL))
cinemas = doc.css("#cine option").map {|cinema| {:id => cinema.attributes["value"], :title => cinema.content } }
cinemas.shift
# We transverse the array creating first a movie chain a... | true |
7c5dd454959b272f63cc2777d1de1331340d1d76 | Ruby | kruegsw/LaunchSchool-RB100 | /learn_to_program_chris_pine/proc_practice.rb | UTF-8 | 219 | 3.265625 | 3 | [] | no_license | new_proc = Proc.new do |variable|
puts "call the proc #{variable}"
end
new_proc.call
new_proc.call("test")
def method_with_proc(proc_input)
proc_input.call
proc_input.call("test")
end
method_with_proc(new_proc) | true |
6ede6cdcd542239fc8c1192f2cf173e7d5d68087 | Ruby | totechite/Learning_parser_with_Ruby | /lib/multi/LookaheadParser.rb | UTF-8 | 719 | 2.875 | 3 | [
"MIT"
] | permissive | class LookaheadParser < Parser
def initialize(input)
super(input)
end
def list
match(ListLexer.L_BRACKET)
elements
match(ListLexer.R_BRACKET)
end
def elements
element
while @lookahead.type == ListLexer.COMMA
match(ListLexer.COMMA)
element
end
end
def element
... | true |
992b9605305489cb8b04cdbd30173d73aaaa37ff | Ruby | guillermo/ubuntu_amis | /lib/ubuntu_amis.rb | UTF-8 | 661 | 2.703125 | 3 | [
"MIT"
] | permissive | require "ubuntu_amis/version"
require 'yaml'
require 'net/http'
require 'uri'
module UbuntuAmis
URL="http://cloud-images.ubuntu.com/locator/ec2/releasesTable"
def self.table
fix_table(parse(fix_string(get(uri)))["aaData"])
end
def self.uri
URI(URL).tap { |uri|
uri.query = Time.now.to_i.to_s
... | true |
578b511dd8e38d1d5a5a19f795e4c101325acd0c | Ruby | GaryZhangUIUC/LocationProfiling | /lib/tweet.rb | UTF-8 | 906 | 3.015625 | 3 | [] | no_license | #!/usr/bin/ruby
require_relative "./tweet_words"
include TweetWords
class Tweet
attr_reader :t_id
attr_reader :u_id
attr_reader :created_at
attr_reader :gps
attr_reader :text
attr_reader :weighted_keywords
attr_reader :keyword_size
def initialize(t_id, u_id, text, gps, created_at)
@t_id = t_id
... | true |
22311d1605b576ebc8f4e911f07481c4cc080632 | Ruby | Ger-onimo/multi_class_hw_bears-rivers-fish | /river.rb | UTF-8 | 501 | 3.46875 | 3 | [] | no_license |
class River
attr_reader :riv_name, :fish_stock
def initialize(riv_name)
# def intializie(riv_name, fish_num)
@riv_name = riv_name
@fish_stock = []
#@fish_num = fish_num for fish count
end
def fish_in_river() #array of fish in river (not sure this is required)
return @... | true |
da87e1a936cbb3e0b0c3348970f20a2ba1bed26c | Ruby | alexandre025/Twithetic | /app/helpers/post_helper.rb | UTF-8 | 946 | 2.71875 | 3 | [] | no_license | module PostHelper
def parse_tweet(message)
hashtags = message.scan(/(#\w+)/).flatten
mentions = message.scan(/(@\w+)/).flatten
return message if hashtags.size == 0 && mentions.size == 0
message = detect_hashtags message if hashtags.size > 0
message = detect_mention message if mentions.size > 0
... | true |
0c7b236d3694b283f1fb89f891edbeed09ef5ffb | Ruby | joaomarceloods/rails2docker | /test/models/product_test.rb | UTF-8 | 367 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class ProductTest < ActiveSupport::TestCase
test "name can't be blank" do
p = Product.new(name: nil).tap(&:validate)
assert_includes p.errors[:name], "can't be blank"
end
test "price must be greater than 0" do
p = Product.new(price: 0).tap(&:validate)
assert_includes p.erro... | true |
7b69b8ec866a87cbafc8c8581a8f20d85bf71c4f | Ruby | Carter-A/coffee-code | /longest_word.rb | UTF-8 | 243 | 3.5625 | 4 | [] | no_license | def find_longest(array)
output = ""
longest = 0
array.each do |word|
if word.length > longest
output = word
longest = word.length
end
end
output
end
animals = %w(cow elephant sheep)
print find_longest(animals)
| true |
2358e1349debdb4932f75b83568041aeed169719 | Ruby | hybridgroup/taskmapper-cli | /lib/tm/string_extensions.rb | UTF-8 | 234 | 2.515625 | 3 | [] | no_license | module TM
module StringExtensions
def to_hash
return '' if self.nil?
self.split(/,/).inject({}) do |hash, kv|
arg, val = kv.split(/:/)
hash[arg.to_sym] = val
hash
end
end
end
end
| true |
82994284e4705efee11f35254426dee6331f8913 | Ruby | jkeck/dotfiles | /bin/with-notify | UTF-8 | 946 | 2.953125 | 3 | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/ruby
class WithNotify
attr_reader :command
def initialize(args = ARGV)
@command = args.join(' ')
end
def self.run
new.run
end
def run
puts "Running \"#{command}\" with notifications..."
run_command
if $?.exitstatus.zero?
`#{notify_command('Command Successful!')}`
... | true |
fbf71bdfb1be19800f128c1d50406aac6f68bd52 | Ruby | JaredTan/AppAcademy | /Week2/W2D3 - RSPEC/lib/first_tdd.rb | UTF-8 | 984 | 3.296875 | 3 | [] | no_license | class Array
def my_uniq
result = []
self.each do |el|
result << el unless result.include?(el)
end
result
end
def two_sum
pair = []
(0...self.length - 1).each do |idx1|
(idx1 + 1...self.length).each do |idx2|
pair << [idx1, idx2] if self[idx1] + self[idx2] == 0
e... | true |
687f5a39ac6a7a1387edb4d4fa77456f297b0fa2 | Ruby | civol/HDLRuby | /lib/HDLRuby/high_samples/all_signals.rb | UTF-8 | 536 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'HDLRuby'
configure_high
# A simple 16-bit adder
system :adder do
[15..0].input :x,:y
[16..0].output :s
s <= x + y
cur_system.open do
puts "Inputs: ", cur_system.get_all_inputs
puts "Outputs: ", cur_system.get_all_outputs
puts "InOuts: ", cur_system.get_all_inouts
... | true |
252fc8ade891d02e0d2bd991d9c198635b79ebe4 | Ruby | tiy-hou-q3-2015-rails/api_examples | /stocks/db/seeds.rb | UTF-8 | 1,286 | 2.5625 | 3 | [] | no_license | jwo = User.create email: "jesse@comal.io", password: "12345678"
bwo = User.create email: "brian@comal.io", password: "12345678"
#["ABC", "BMW", "IBM", "XOM"]
google = Company.create! name: "Alphabet", ticker_symbol: "GOOG", last_price: 500
bmw = Company.create! name: "BMW", ticker_symbol: "BMW", last_price: 100
ibm ... | true |
1212efdba927c311ea538b8730b8fb6a76cfbb82 | Ruby | rlavang/launch-school | /101-programming-foundations/small_problems_retry/easy_8_3.rb | UTF-8 | 314 | 3.515625 | 4 | [] | no_license | def substrings_at_start(string)
substrings = []
1.upto(string.length) do |length|
substrings << string.slice(0, length)
end
substrings.sort
end
p substrings_at_start('abc') == ['a', 'ab', 'abc']
p substrings_at_start('a') == ['a']
p substrings_at_start('xyzzy') == ['x', 'xy', 'xyz', 'xyzz', 'xyzzy'] | true |
d19574b6dbe9961849e9fc3d1b48ddf045e9af17 | Ruby | wengzilla/recurse_center | /hacker_rank/20160707_cells/grid.rb | UTF-8 | 1,077 | 3.828125 | 4 | [] | no_license | class Grid
attr_accessor :grid, :num_rows, :num_cols
def initialize(grid, num_rows, num_cols)
@grid = grid
@num_rows = num_rows
@num_cols = num_cols
end
def one_cells
grid.map.with_index { |cell, idx| cell == "1" ? idx : nil }.compact
end
def neighboring_cells(cell)
neighbors = []
... | true |
03cf30a43a3de5d0bcf32e3ba9d54cb930f2ad1f | Ruby | donjar/ctf-solutions | /cryptopals/1/4.rb | UTF-8 | 461 | 3.171875 | 3 | [] | no_license | frequent = %w(a n i h o r t e s A N I H O R T E S)
File.read('4.txt').split("\n").each_with_index do |encrypted, idx|
puts "=== LINE #{idx} ==="
res = 128.times.map do |key|
total = 0
decrypted = encrypted.scan(/../).map do |part|
res_char = (part.to_i(16) ^ key).chr
total += 1 if frequent.incl... | true |
ac80b6da75dcdcb56695bc42a6ee661a634c4816 | Ruby | cha63506/heap_dump | /lib/heap_dump/histogram.rb | UTF-8 | 1,721 | 3.078125 | 3 | [] | no_license | module Rubinius
module HeapDump
class Histogram
class Entry
def initialize(klass, objects=0, bytes=0)
@klass = klass
@objects = objects
@bytes = bytes
end
attr_reader :objects, :bytes
def inc(object)
@objects += 1
@bytes += ... | true |
45f71daa610d72e8f5b8ca1ccdc4b775cdc9f462 | Ruby | dillon-m/mined_minds_kata | /exercise5.rb | UTF-8 | 152 | 3.484375 | 3 | [] | no_license | (1..100).each do|n|
if n % 15 == 0
puts 'Minded Minds'
elsif n % 3 == 0
puts 'Mined'
elsif n % 5 == 0
puts 'Minds'
else
puts n
end
end | true |
6435b36d55e98c7302707c2ea93e2d623ad3dd60 | Ruby | JelF/papp | /lib/papp/logger.rb | UTF-8 | 870 | 2.96875 | 3 | [] | no_license | module PApp
# Defines a simple logger
class Logger
LEVELS = {
1 => :error,
2 => :warn,
3 => :info,
4 => :debug,
}
attr_accessor :verbosity, :output
LEVELS.each do |v, level|
define_method(level) do |*args|
log!(v, *args) if v <= verbosity
end
end... | true |
a8ccc0904e61134c95654503a408ba774ad07843 | Ruby | hatsu38/atcoder-ruby | /edpc/a.rb | UTF-8 | 660 | 3.296875 | 3 | [] | no_license | # frozen_string_literal: true
### 例
# N
# a_1 b_1
# ...
# a_N b_N
# h,w = gets.chomp.split(' ').map(&:to_i)
# strs = h.times.map{ gets.chomp.split('') }
# input
# 6
# 30 10 60 10 60 50
# output
# 40
n = gets.to_i
strs = gets.chomp.split.map(&:to_i)
# dp = [0, (strs[0]-strs[1]).abs]
# [*2..(n-1)].each do |i|
# dp ... | true |
cf8e6d54474172b77edfb409ff6c0c93b7e115f0 | Ruby | CamillaCdC/seic38-homework | /Ryan Bullough/week04/Friday/main.rb | UTF-8 | 1,379 | 2.578125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'sqlite3'
require 'pry'
get '/' do
erb :home
end
# NEW
get '/doughnuts/new' do
erb :doughnuts_new
end
# CREATE
post '/doughnuts' do
query = "INSERT INTO doughnuts (name, type, shape, image) VALUES ('#{params["name"]}', '#{params["type"]}', '#{params["shape"]... | true |
ecb0d6470a101210c80f9206eb763f484e66d9c7 | Ruby | paulghaddad/57_exercises_ruby | /exercise_11/euro_to_dollar_converter.rb | UTF-8 | 283 | 3.4375 | 3 | [] | no_license | class EuroToDollarConverter
attr_reader :euros, :exchange_rate
CENTS_PER_DOLLAR = 100
def initialize(euros:, exchange_rate:)
@euros = euros
@exchange_rate = exchange_rate
end
def euros_to_dollars
(euros * exchange_rate / CENTS_PER_DOLLAR).round(2)
end
end
| true |
7689df850a6033bd931124edc7ac5602e20ffdd2 | Ruby | stevehanson/tictactoe | /tictactoe.rb | UTF-8 | 1,745 | 4.375 | 4 | [] | no_license | # add win strategy
class Board
attr_reader :row_count, :col_count
def initialize(rows, columns)
@row_count = rows
@col_count = columns
@board = Array.new(rows) {
Array.new(columns) { ' ' }
}
end
def update(row, column, value)
@board[row][column] = value
end
def rows
@board... | true |
10bf3771d8049cf30ecdb4d4f3cf3248a14af9ee | Ruby | asandler/mipt | /code/algorithms_oop/semester_4/z_function.rb | UTF-8 | 609 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
def zf s
z = [1]
l, r = 0, 0
(1..s.length - 1).each do |i|
if (l..r).include? i
j = i - l
if i + z[j] <= r
z << z[j]
else
t = r
while t < s.length and s[t] == s[t - i]
t += 1
... | true |
15f5a34c4e31a7a2afa855b9286c65d4a1daec7a | Ruby | blackhatflow/blog | /montecarlo.rb | UTF-8 | 347 | 3.59375 | 4 | [] | no_license | flip = rand 2
if flip == 0
puts "face"
else
puts "pile"
end
i = 0
pile = 0
face = 0
while i < 1
flip = rand 2
if flip == 0
puts "face"
face +=1
else
puts "pile"
pile +=1
end
i += 1
end
puts "on a fait pile #{pile} fois"
puts "on a fait face #{face} fois"
chance = (pile * 100) / i
puts... | true |
ba30af3dbdc603b20728ba2f2ff77b9e7875c4ef | Ruby | maxipombo/rbnd-toycity-part4 | /lib/find_by.rb | UTF-8 | 409 | 2.78125 | 3 | [] | no_license | class Module
def create_finder_methods(*attributes)
# Your code goes here!
# Hint: Remember attr_reader and class_eval
attributes.each do |attribute|
finder_methods = %Q{
def self.find_by_#{attribute}(#{attribute})
all.find do |product|
product.#{attribute} == #{attribu... | true |
261e98f44768a04cfb75c5ff1c7c5fb3818d2cce | Ruby | kromitj/bit-counter | /lib/assets/byte_counter/and.rb | UTF-8 | 569 | 3.53125 | 4 | [] | no_license |
class And
attr_reader :input_a, :input_b
@@logicTable = [
{ inputA: 0, inputB: 0, output: 0},
{ inputA: 1, inputB: 0, output: 0},
{ inputA: 0, inputB: 1, output: 0},
{ inputA: 1, inputB: 1, output: 1}
]
def initialize(input_a, input_b)
@input_a = input_a
@input_b = inpu... | true |
41e68a04fd1ac2114a56631bcf83011062670705 | Ruby | hoodielive/ruby | /old/ruby_core/JSON/json.rb | UTF-8 | 328 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# JSON
#
require "json"
json_string = '{"name": "Larry", "location": "Pittsburgh", "year": 2018}'
hash = JSON.parse(json_string)
puts hash
puts hash['name']
my_hash = { name: "Lawrence", email: "larrylawrencehamburger@blah.blah" }
puts JSON.dump(my_hash)
puts from_file_json = JSON.load... | true |
9174faa81306253cfcdf4da46bf37dd276eb1322 | Ruby | zapalagrzegorz/chess | /pieces/queen.rb | UTF-8 | 321 | 2.96875 | 3 | [] | no_license | require_relative "slideable"
require_relative "piece"
class Queen < Piece
include Slideable
DIRECTION = [:STRAIGHT, :DIAGONAL].freeze
def initialize(color, board, position)
super(color, board, position)
end
def symbol
"♛".colorize(color)
end
protected
def move_dirs
DIRECTION
end
end
| true |
3301209da95fed9184d264ff03b73b558e0e961a | Ruby | nkn0t/myrubyutils | /utils/active_class_generator.rb | UTF-8 | 1,306 | 3.203125 | 3 | [
"MIT"
] | permissive | # instanceのフィールドにハッシュを用いて動的にフィールドを定義する.
# key => フィールド名
# value => フィールドの値
# ハッシュが入れ子になっている場合は
# ハッシュの階層構造を維持したクラスとして定義した上で同様に処理する.
module ActiveClassGenerator
def define_fields_by_hash(instance, hash)
hash.each do |k, v|
class_name = to_camelcase(k)
instance.class.const_set(class_name, Class.new) unl... | true |
17387f522b4249b44008c09ea11cc2c2d329d26d | Ruby | DonalMoo/BikeRental | /lib/calculator.rb | UTF-8 | 69 | 2.984375 | 3 | [] | no_license | class Calculator
def self.total(n1, n2)
result = n1 * n2
end
end | true |
02102c5c701075d7c5ae9c2fe5a37a5d47370913 | Ruby | ruby-rails-mustafa-akgul-oyyk-2019/ruby_101_sunum | /codes/classes/method_types.rb | UTF-8 | 475 | 3.703125 | 4 | [
"MIT"
] | permissive | class Person
attr_accessor :name
def initialize(name, surname, age, gender)
@name = name
@surname = surname
@age = age
@gender = gender
end
def self.finder_numbers
10
end
def gender
if age == 'ender'
'male'
else
'female'
end
end
protected
def me... | true |
0dc25393ca667fe118f69af2ef91ceb318e1dcb8 | Ruby | zlw241/W2D4 | /two_sum.rb | UTF-8 | 895 | 4.09375 | 4 | [] | no_license |
def bad_two_sum?(arr, target)
arr[0...-1].each do |i|
(i+1...arr.length).each do |j|
return true if arr[i] + arr[j] == target
end
end
false
end
arr = [0, 1, 5, 7]
p bad_two_sum?(arr, 6) # => should be true
p bad_two_sum?(arr, 10) # => should be false
def b_search(arr, target)
return false if a... | true |
034d4ce34e1cad60070a4a8d3297093cc989cb28 | Ruby | haja1294/learn-co-sandbox | /nested.rb | UTF-8 | 190 | 2.96875 | 3 | [] | no_license | people = [["Kaetlyn","proletariat","potsticker"],["Jon","bougie toucan","fruit loops"]]
people.each do |person,description,food|
puts"#{person} is a #{description} and loves to eat #{food}"
end | true |
2adebe10981387c81f6a002979e1d254335db05e | Ruby | wfslithtaivs/AA_Homeworks_and_Projects | /ORM Ruby SQL/tests.rb | UTF-8 | 2,119 | 2.6875 | 3 | [] | no_license | require_relative 'database'
require_relative 'user'
require_relative 'question'
require_relative 'reply'
require_relative 'question_follow'
require_relative 'question_like'
#
# p User.all
# p Question.all
# p Reply.all
quest = Question.find_by_author_id(2)
# p "Question: Find by author #{quest}"
repl = Reply.find_by_u... | true |
2ad86104396c3585739cc74070a77ec99a1eae97 | Ruby | sneakin/CooCoo | /examples/mnist.rb | UTF-8 | 14,356 | 2.734375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require 'pathname'
require 'net/http'
require 'zlib'
require 'ostruct'
# todo read directly from gzipped files
# todo usable by the bin/trainer?
# todo label and map network outputs
# todo blank space needs to be standard part
# todo additional outputs and labels beyond 0-9
module MNist
PATH = Pathname.new(__FILE_... | true |
fc5b13c7dd30cc04ec83faa917a7738c0f9acaac | Ruby | JTREX/piglatin1 | /pruebas.rb | UTF-8 | 778 | 4.0625 | 4 | [] | no_license | # Script: Single word converter to Pig Latin
def translate
# GET a word from user input
p "Give me a Word"
string = gets.chomp.downcase
alpha = ('a'..'z').to_a
vowels = %w[a e i o u]
consonants = alpha - vowels
# IF the word starts with a vowel, add "way" to the end
if vowels.include?(string[0])
st... | true |
d97e67d8db9dd780f59939fd1f5c4b9f5bf546a2 | Ruby | j-eaves/employees_ledger | /manager.rb | UTF-8 | 2,438 | 3.90625 | 4 | [] | no_license | module EmailReportable #always ends in "able"
#In the module, I can place a ton of various methods
def send_report
p "I will send report."
p "Here is the report."
end
end
#Employee class
class Employee
attr_reader :first_name, :last_name, :salary, :active #this takes the place of the getter functions b... | true |
33d9ef238b4eee128c4fceef91b6053c991d9b53 | Ruby | pdg137/pi-maze-solver | /pi/lib/looped_maze_solver.rb | UTF-8 | 5,047 | 3.390625 | 3 | [] | no_license | require_relative 'maze'
require_relative 'point'
require_relative 'vector'
require_relative 'gridded_maze'
require_relative 'segment_voter'
require_relative 'turning_path_follower'
require 'set'
class LoopedMazeSolver
# Our internal concept of the maze.
# Updated as we explore it.
attr_reader :maze, :pos, :vec, ... | true |
6c963f826ab368a909781270a308b887e56b54d5 | Ruby | pmacaluso3/espark_challenge | /lib/domain_string_parseable.rb | UTF-8 | 466 | 3.15625 | 3 | [] | no_license | module DomainStringParseable
NON_NUMERIC_GRADES = { 0 => 'K' }
def parse_domain_string(dom_str)
grade = dom_str.split('.').first
domain = dom_str.split('.').last
[grade.to_i, domain.to_sym]
end
def make_domain_string(domain, grade)
"#{grade}.#{domain}"
end
def print_format(dom_str)
gr... | true |
9cda57cfd2a25b18826a9fbe924d7282a3a3d70e | Ruby | db87987/h2_map_parser | /lib/map.rb | UTF-8 | 2,915 | 3.140625 | 3 | [] | no_license | class Map
attr_reader :path, :title, :description, :difficulty, :size, :players, :humans, :computers
def initialize(path)
@path = path
@file = File.read(path);
# magic_byte = file.unpack("N").first
# raise "Incorrect map file" unless magic_byte == 1543503872
end
def title
@file.unpack("x58... | true |
c2d0f3779882b0f16e2e2a482e868d39257358ac | Ruby | timhang/im-hungry-pt2 | /Part1/cuc/features/step_definitions/ResultsPage.rb | UTF-8 | 3,349 | 2.625 | 3 | [] | no_license | ## Scenario Search a query then return to search page
Given("I am on the Search Page") do
visit 'localhost:8080/project1/SearchPage.html'
end
Given("I have entered a search query {string}") do |string|
fill_in 'search', :with => string
end
Given("{int} for the number of results to be displayed") do |int|
fill_i... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.