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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4a646e9a04653f3920b28d0c60d4f096b6da71d2 | Ruby | clejacquet/c2asmjs | /core/error_handler.rb | UTF-8 | 194 | 2.796875 | 3 | [] | no_license | require('singleton')
class ErrorHandler
include Singleton
attr_reader :errors
def initialize
@errors = Array.new
end
def register_error(error)
@errors.push(error)
end
end | true |
5b3dab4e5d1e07a2be598e91deb96b30d577f0aa | Ruby | Rainiugnas/password_manager | /lib/cli_file_crypter.rb | UTF-8 | 2,579 | 2.96875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'cli'
# Handle actions related to the cli file crypter interface.
module CliFileCrypter
# Starter point of the cli file crypter.
# Run CliFileCrypter.run, it use the ARGV arguments to find and execute an action.
# Catch all PasswordManager::PasswordManagerError to stop the ... | true |
9d4ce190afe9d87ec341074fe1dd2f061c40d61d | Ruby | dkackar/assignment_ruby_warmup | /stock_picker.rb | UTF-8 | 685 | 3.453125 | 3 | [] | no_license | def stock_picker(arr)
max = arr.size - 1
min = 0
diff = 0
save_buy_index = 0
save_sell_index = 0
(max - 1).times do |buy_index|
buy_index+1.upto(max) do |sell_index|
if (arr[sell_index] - arr[buy_index]) >= diff
save_buy_index = buy_index
save_sell_index = sell_index
di... | true |
bc339d20c789a8d2d4540569247a690176d52379 | Ruby | Jamalp/calculator | /Menu.rb | UTF-8 | 592 | 3.765625 | 4 | [] | no_license |
BREAD = 5
CHEESE = 3
STEAK = 25
SALMON = 20
CAKE = 7
PUDDING = 6
total = 0
puts "What would you like for starters?" +
"we have" + " cheese or bread"
appetizer = gets.chomp
if appetizer == "bread"
total += BREAD
else
total += CHEESE
end
puts "ok, what about for an entree, steak or salmon?"
en... | true |
90698cff4ab1f62c216b314f61d8a4463d7405c7 | Ruby | omiron33/ruby_april_2018 | /shane_fisher/oop/Human/human.rb | UTF-8 | 523 | 3.921875 | 4 | [] | no_license | class Human
attr_accessor :str, :int, :stealth, :health
def initialize
@str = 3
@int = 3
@stealth = 3
@health = 100
end
def attack(object)
if object.class.ancestors.include? Human
object.health -= 10
puts "Target has #{object.health} lef... | true |
9982a28f31e9334fac2e6e8efc8e26a5aeb75297 | Ruby | pu-dc/RubySpace | /Chapter-1/operator-logic.rb | UTF-8 | 632 | 3.546875 | 4 | [
"MIT"
] | permissive | =begin
Logic operator digunakan untuk menggabung dua sub-conditional menjadi satu. Operan dari operasi logic harus bertipe logic, baik TrueClass maupun FalseClass. Daftar Logic operator didalam Ruby dapat dilihat pada table dibawah ini :
&& AND
|| OR
! NOT
and &&
... | true |
5d2cb131252576d0b7529be190db5fdeb38942b8 | Ruby | conyekwelu/rb101 | /basics_review/basics_arrays.rb | UTF-8 | 1,638 | 4.625 | 5 | [] | no_license | CORE CONCEPTS
- Array.map iterates over an array and returns a new array with each element transformed based on the block return value
- Array.each returns the original array
- Array.select takes a boolean (or expression that evaluates to one) in the block and returns a new array with the chosen elements
New Pet
pets... | true |
88ffac4db465c0df0fc8d59b6be31da9fad05abd | Ruby | DragonController/Exercise-1b-Names | /main.rb | UTF-8 | 330 | 3.46875 | 3 | [] | no_license | class Bike
# ...
end
class RedBicycle < Bike
amount = 10
def initialize(height, weight, color)
@height = height
@weight = weight
@color = color
end
def get_color
@color
end
def get_height
@height
end
def decrease_weight_by_amount
@weight -= amount
... | true |
bbe357150c7ec7687a8ea47cb76794a715f7bba7 | Ruby | ieda/think_compass | /core/core.rb | UTF-8 | 7,596 | 3 | 3 | [] | no_license | module MenuTree
def self.get_menu_tree(root_sym = :default)
case root_sym
when :default; return [:recognization, :resouce, :motivation]
when :recognization; return [:purpose, :path]
when :resouce; return [:time, :money, :tool, :human, :infomation]
when :motivation; return [:positiveness, :concentr... | true |
1a3c894b16d7b083c94034d9fc3be07c904f8903 | Ruby | e-pavlica/riser_chart | /lib/wedge.rb | UTF-8 | 859 | 3 | 3 | [] | no_license | # frozen_string_literal: true
class Wedge
DIMENSIONS = [
{ step: 'Floor', width: 36.4 },
{ step: 1, width: 36.4 },
{ step: 2, width: 42.8 },
{ step: 3, width: 49.1 },
{ step: 4, width: 55.5 },
{ step: 5, width: 61.9 },
{ step: 6, width: 68.2 },
{ step: 7, width: 74.6 },
{ step: 8,... | true |
184a47674bcb689e5632078f53c26ef19d15aeda | Ruby | gnovos/mobj | /lib/ext/symbol.rb | UTF-8 | 225 | 2.9375 | 3 | [] | no_license | module Mobj
class ::Symbol
def walk(obj)
to_s.walk(obj)
end
def method_missing(name, *args, &block)
str = to_s
str.respond_to?(name) ? str.send(name, *args, &block) : super
end
end
end | true |
0e8403fc5138e254113241d10f33b75beb8748f8 | Ruby | ozyborg/advent-of-code | /2021/day-08/part-01.rb | UTF-8 | 226 | 3.234375 | 3 | [] | no_license | def process(data)
data.flat_map(&:last).count { |d| [2, 4, 3, 7].include?(d.length) }
end
def input
File.readlines(ARGV.first).map do |l|
l.chomp.split(' | ').map { |ll| ll.split(' ') }
end
end
puts process(input)
| true |
ea43f78dea3990123ae14116b0c967e25c71f642 | Ruby | imanagashodai/algorithm | /Ruby/クラスカル法.rb | UTF-8 | 635 | 3.421875 | 3 | [] | no_license | # https://www.slideshare.net/iwiwi/ss-3578491
N = 3
par = Array.new(N)
N.times do |n|
par[n] = n
end
E = 3 # 経路の数
def find(x,par)
return x if par[x] == x
return par[x] = find(par[x],par)
end
def same(x,y,par)
return find(x,par) == find(y,par)
end
def union(x,y,par)
x = find(x,par)
y = ... | true |
1640509524bd7319b7708c5f902a85ecb2ed67db | Ruby | ash-leigh/day_2_functions_lab | /ruby_functions_practice.rb | UTF-8 | 1,244 | 4.21875 | 4 | [] | no_license | def return_10()
return 10
end
def add(first_number, second_number)
return first_number + second_number
end
def subtract(first_number, second_number)
return first_number - second_number
end
def multiply (first_number, second_number)
return first_number * second_number
end
def divide (first_number, second... | true |
6ccc2bce435495f6ae548a0eb9a87339794e51ed | Ruby | valentinorusconi/ruby-exercises | /objects-and-methods/exercise-2/spec/candy_spec.rb | UTF-8 | 550 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'rspec'
require_relative '../lib/candy'
RSpec.describe Candy do
it 'has a type' do
candy = Candy.new('Skittles')
expect(candy.type).to eq('Skittles')
end
xit 'can have a different type' do
candy = Candy.new('Mars')
expect(candy.type).to eq('Mars')
end
xit 'has 100g of sugar by def... | true |
7123adb907410a2c6b302b907bd1ed3be07956e1 | Ruby | jessiebbaxter/toy-robot | /lib/router.rb | UTF-8 | 1,205 | 3.546875 | 4 | [] | no_license | class Router
def initialize(controller)
@controller = controller
@running = true
end
# Displays simulator interface and retrieves user input
def run
puts "---------------------------------------"
puts "Welcome to your Toy Robot Simulator! 🤖"
puts "---------------------------------------"
... | true |
c136e6334f4e6ee5bdb37323b180228ad0f1af60 | Ruby | copiousfreetime/flat_kit | /lib/flat_kit/record.rb | UTF-8 | 2,572 | 3.28125 | 3 | [
"MIT"
] | permissive | module FlatKit
# Public: The base class that all record classes should inherit from.
#
# Its goal is to be an efficient comparator of data that can be inflated from
# a source structure to a fully realized hash.
#
# All records need to be able to be initialized from a data structure that it
# is handed to... | true |
05d097970b78ae36f2678bd8881f87759b152c75 | Ruby | PetePhx/intro-to-programming-ruby | /2_variables/5_prog_output.rb | UTF-8 | 461 | 3.8125 | 4 | [] | no_license | # Program 1:
x1 = 0
3.times do
x1 += 1
end
puts x1
# output: 3
# x1 is initialized in the outer scope (0), then updated in the inner scope (3).
# everything is fine.
# Program 2:
y = 0
3.times do
y += 1
x2 = y
end
puts x2
# output: error. undefined local variable or method `x2' for main:Object (NameError)
# ... | true |
cb1daae1617b8918d1849a2b3ab64fbd6646bda6 | Ruby | stonegao/gisting | /lib/gisting/spec.rb | UTF-8 | 466 | 2.875 | 3 | [] | no_license | module Gisting
# A Spec contains multiple Inputs and a single Output
class Spec
def initialize
@map_inputs = []
end
def add_input
input = Input.new
@map_inputs << input
input
end
def map_inputs
@map_inputs
end
def output
@map_output ||= Outp... | true |
e5991f11e840de38dd16c5b5f5327e0d71a6637a | Ruby | Satyrr/University | /Programming in Ruby/lista7/client.rb | UTF-8 | 501 | 2.65625 | 3 | [] | no_license | require 'drb/drb'
SERVER_URI="druby://localhost:9999"
#ustanowienie polaczenia i przyznanie id
DRb.start_service
log_service=DRbObject.new_with_uri(SERVER_URI)
my_id = log_service.assign_id
menu = "1.nowa wiadomosc\n"\
"0.zamknij klienta"
puts menu
option=gets.chomp.to_i
while option!=0 do
if option == 1
puts ... | true |
2bb020a661fe4681664fba3fc3db0495ccc55c5f | Ruby | Mycobee/flash_cards | /test/deck_test.rb | UTF-8 | 994 | 3.421875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require "pry"
require './lib/turn'
require './lib/card'
require './lib/deck'
class DeckTest < Minitest::Test
def setup
@card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography)
@card_2 = Card.new("The Viking spacecraft sent back to Earth ph... | true |
51de5c320f072a6861e522b4eca8dfd9cb664b55 | Ruby | Chrispayneable/Exercism.io | /ruby/two-fer/two_fer.rb | UTF-8 | 91 | 2.828125 | 3 | [] | no_license | class TwoFer
def self.two_fer(word = 'you')
"One for #{word}, one for me."
end
end
| true |
81c32242e3315a0513f48c27c98f95a8286ae33b | Ruby | da99/i_love_u | /src/Uni_Lang/Noun/Noun_Number.rb | UTF-8 | 216 | 2.765625 | 3 | [
"MIT"
] | permissive |
class Noun_Number
include Noun::Module
def data_type?
true
end
def valid? str, program
pos = ( str =~ /\d+(\.\d+)?/ )
return false if pos == nil
true
end
end # === class Noun_Word
| true |
c060db4d34a04b5c53d82ac8bd676477d72c811b | Ruby | kp1/exifparser | /lib/exifparser.rb | UTF-8 | 6,963 | 3.203125 | 3 | [
"Ruby",
"BSD-2-Clause"
] | permissive | #
#
#= exifparser.rb - Exif tag parser written in pure ruby
#
#Author:: Ryuchi Tamura (r-tam@fsinet.or.jp)
#Copyright:: Copyright (C) 2002 Ryuichi Tamura.
#
# $Id: exifparser.rb,v 1.1.1.1 2002/12/16 07:59:00 tam Exp $
#
#== INTRODUCTION
#
#There are 2 classes you work with. ExifParser class is
#the Exif tag parser tha... | true |
d5bfd7ca630b0323d74fd3ed0180068164c2f7b4 | Ruby | Redvanisation/data-algorithm | /1-basic-data/ex21-minstack.rb | UTF-8 | 1,189 | 4.09375 | 4 | [
"MIT"
] | permissive | class Node
attr_accessor :value, :previous_node, :next_node
def initialize(value, previous_node=nil, next_node=nil)
@value = value
@previous_node = previous_node
@next_node = next_node
end
end
class Stack
def initialize()
@tail = Node.new(nil)
end
def push(number)
this_node = No... | true |
4afdc804221213799d4f2ec04406c188705b245d | Ruby | psteiger/desafios | /2.rb | UTF-8 | 728 | 4.1875 | 4 | [] | no_license | #!/usr/bin/env ruby
def upToTwoThirdsJumbled(string1, string2)
jumbled = 0
string1.chars.each_with_index do |char, i|
jumbled += 1 if char != string2[i]
end
jumbled < (string1.length * 2) / 3
end
def isPermutation(string1, string2)
# creio que as strings serem do mesmo tamanho e terem os mesmos ca... | true |
50017f18244b70859782f35c5263e57cdd1b88ac | Ruby | spohlenz/mongomodel | /lib/mongomodel/concerns/attributes.rb | UTF-8 | 2,048 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'active_support/core_ext/module/aliasing'
module MongoModel
module Attributes
extend ActiveSupport::Concern
def initialize(attrs={}, options={})
assign_attributes(attrs || {}, options)
yield self if block_given?
end
def attributes
@attributes ||= Attributes::Store.new(self... | true |
f7693fc8462e5bc25eac23bc508c1d124ef67938 | Ruby | cjc162/D2 | /game_test.rb | UTF-8 | 2,015 | 3.34375 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'game'
# GameTest
class GameTest < Minitest::Test
# UNIT TESTS FOR METHOD create_map()
# Equivalence classes:
# no param -> returns the 2D map specified in the requirement #3
# The map specified in requirement #3 is returned.
def test_create_map
map = [
[... | true |
48e37fa5406a115dcf973cbdec1ace040d051cd9 | Ruby | marquesavery/ttt-with-ai-project-online-web-sp-000 | /lib/board.rb | UTF-8 | 1,064 | 4.09375 | 4 | [] | no_license | require "pry"
class Board
attr_accessor :cells
def initialize
reset!
end
def reset!
@cells = Array.new(9, " ")
end
def display
puts " #{@cells[0]} | #{@cells[1]} | #{@cells[2]} "
puts "-----------"
puts " #{@cells[3]} | #{@cells[4]} | #{@cells[5]} "
puts "-----------"
puts " #... | true |
67e172342691d11785d00384d4bb1658ef92f16f | Ruby | seangoedecke/toy-paxos | /main.rb | UTF-8 | 866 | 2.984375 | 3 | [] | no_license | require_relative './node'
require_relative './cluster'
require_relative './network'
# Sets up a cluster with three nodes on an unreliable network and makes a write
# NB: Paxos only comes to consensus on _one_ decision. You need something else tracking round numbers to get you to
# multiple decisions or a unified log. ... | true |
b1453460198e2b16c7a6fc615d1b38309a87560e | Ruby | mayorau3/neko-taku-app | /spec/models/cat_spec.rb | UTF-8 | 1,815 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Cat, type: :model do
describe '#create' do
before do
@cat = FactoryBot.build(:cat)
end
it '全ての入力項目が存在すれば登録できること' do
expect(@cat).to be_valid
end
it '画像が空では登録できないこと' do
@cat.images = nil
@cat.valid?
expect(@cat.errors.full_messa... | true |
84edb684fd1fba0848f63fdf4f31786fa7bad1a4 | Ruby | petlove/ruby-push-notifications | /lib/ruby-push-notifications/mpns/mpns_pusher.rb | UTF-8 | 1,173 | 2.625 | 3 | [
"MIT"
] | permissive |
module RubyPushNotifications
module MPNS
# This class is responsible for sending notifications to the MPNS service.
#
class MPNSPusher
# Initializes the MPNSPusher
#
# @param certificate [String]. The PEM encoded MPNS certificate.
# @param options [Hash] optional. Options for GC... | true |
57028be15727bf5f763f7778476184b57b88f798 | Ruby | KoKumagai/manga_read_man | /lib/manga_read_man.rb | UTF-8 | 206 | 2.515625 | 3 | [] | no_license | require "manga_read_man/manga"
module MangaReadMan
BASE_URL = 'http://www.mangareader.net/'
def self.image_urls(title, chapter = nil)
manga = Manga.new(title, chapter)
manga.execute
end
end
| true |
033c3b9ea09d93993030db741fde8f366636240d | Ruby | mutsey/ruby-puppy-online-web-pt-110419 | /lib/dog.rb | UTF-8 | 298 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
@@all = []
attr_accessor :name
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
end
.clear_all = []
attr_accessor :name
def initialize(all dogs)
@@all = all dogs
@@all << all dogs
end
def clear.all
@@all
| true |
88f25b05d80bc3c3e5e8c61ecb4e51a479329a81 | Ruby | raganwald-deprecated/ick | /test/test_advisor.rb | UTF-8 | 1,782 | 2.890625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/test_helper.rb'
class NoAdvice < Ick::Advisor
end
class NameUpdator < Ick::Advisor
around :only => :value= do |callback, receiver, sym, *args|
callback.call()
receiver.name = receiver.to_s
end
end
class NameUpdatorByMethod < Ick::Advisor
around :update, :only => :valu... | true |
828bd623d862a415342e537d6e4c5fdb1f4f7aac | Ruby | ULL-ESIT-LPP-1819/tdd-alu0100893601 | /lib/InfNut/paciente.rb | UTF-8 | 1,070 | 2.859375 | 3 | [] | no_license | require_relative "valoracionnutricional.rb"
class Paciente < ValoracionNutricional
attr_reader :identificacion, :nsegsocial
def initialize (id , nss, name, age, gender, weight, height, circun, plieg)
@identificacion = id
@nsegsocial= nss
super(name, age, gender, weight, height, circun, plieg)
end
... | true |
bdb84d9066144a9c74ee38014f4cbeb8f422ddc6 | Ruby | kmeyer313/phase-0 | /week-5/gps2_2.rb | UTF-8 | 5,616 | 3.96875 | 4 | [
"MIT"
] | permissive | #---ARRAY ATTEMPT DURING GPS---ABORTED---SCROLL DOWN FOR HASH ATTEMPT POST-GPS---
# Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# define the METHOD
# add name of array as a parameter
# set parameter equal blank array
# print the list to ... | true |
1c766acb94b79d99b25e7c4e8985ff8441d3bdb5 | Ruby | gramos/migral | /lib/migral/migration.rb | UTF-8 | 1,334 | 2.90625 | 3 | [] | no_license | require 'csv'
require 'erb'
module Migral
class Migration
attr_reader :attributes
def initialize(type, csv_file_path, table_name, separator = ",")
@type = type
@table_name = table_name
@csv_file_path = csv_file_path
@separator = separator || ","
end
def dum... | true |
780fe6ab7eba0706d64206f1cb27f862b3332636 | Ruby | cliffeh/util | /examples/ruby/hashes.rb | UTF-8 | 288 | 3.59375 | 4 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
# create a hash
books = {} # or Hash.new(0)
# :splendid is a symbol
books["Gravity's Rainbow"] = :splendid
puts books.keys
puts books.values
books.keys.each { |title| puts title }
books.each { |title, symbol| print title, " => ", symbol, "\n"}
| true |
2f81264df98f8c9027dbb970bc714fb2534aa674 | Ruby | WilfredTA/algorithmic_acrobatics | /Sorting/bubble_sort.rb | UTF-8 | 582 | 3.78125 | 4 | [] | no_license | # Two pointer slide
# swap vals at pointers if val at pointer 1 > val at pointer 2
# largest value therefore bubbles to the top on each passthrough
def bubble_sort(array)
limit = array.length - 1
while limit >= 0 do
pointer1 = 0
pointer2 = 1
while pointer2 <= limit do
if array[pointer1] > array... | true |
6542f3e49dd2530af931c7d0fce63d6df7bc3f63 | Ruby | jutonz/cuesnap | /lib/cuesnap/splitter.rb | UTF-8 | 3,877 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'hashie'
require 'rubycue'
require 'shellwords'
module CueSnap
class FileNotFound < StandardError; end
class MP3FileNotFound < FileNotFound; end
class CueFileNotFound < FileNotFound; end
class CueFileTooLarge < StandardError
def message
'Only cue files less than 1MB are allowed.'
end
en... | true |
f3abd5f0145c5adda22ea3db92937dda95de8086 | Ruby | Protobit/ridoku | /lib/ridoku/cook.rb | UTF-8 | 2,200 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | #
# Command: cook
#
require 'rugged'
require 'ridoku/base'
module Ridoku
register :cook
class Cook < Base
def run
command = Base.config[:command]
sub_command = (command.length > 0 && command[1]) || nil
Base.fetch_stack
case sub_command
# when 'list', nil
# list
... | true |
c725559cb65b53920112c97ae0740675bc9f249d | Ruby | DavyJonesLocker/client_side_validations | /test/active_model/cases/test_numericality_validator.rb | UTF-8 | 3,406 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'active_model/cases/test_base'
module ActiveModel
class NumericalityValidatorTest < ClientSideValidations::ActiveModelTestBase
def test_numericality_client_side_hash
expected_hash = { messages: { numericality: 'is not a number' } }
assert_equal expected_hash, N... | true |
ec9de487fb1a3f0dd7e9cb8bdda3cb9f5203e421 | Ruby | sharonkeikei/hotel | /test/reservation_test.rb | UTF-8 | 1,080 | 2.703125 | 3 | [] | no_license | require_relative 'test_helper'
describe "Reservation class" do
before do
@new_hotel = Hotel::HotelController.new(10)
@new_hotel.reserve_room(Date.new(2010,02,10),Date.new(2010,02,13), "Sharon")
@new_reservation = @new_hotel.reservation_list[1]
end
describe "Initializer" do
it "is an instance of ... | true |
13fda0c2a45e32a46c0c5d822cb4d70f9ef8660e | Ruby | devteds/e9-cloudformation-docker-ecs | /app/service.rb | UTF-8 | 817 | 2.90625 | 3 | [] | no_license | require 'sinatra'
require "sinatra/namespace"
class Book
@@books = [
{ id: "123", name: "Docker for Beginners" },
{ id: "124", name: "Docker with Kubernetes" },
{ id: "125", name: "Docker on ECS" }
]
def self.all
@@books
end
def self.find(book_id)
@@books.s... | true |
6b07a696796cc6616806aff1096a1a5e2833d49d | Ruby | tylerthomasallen/aahomework | /W1D5/map.rb | UTF-8 | 543 | 3.546875 | 4 | [] | no_license | class Map
def initialize
@array = []
end
def set(key, value)
idx = @array.each_index { |ele| ele[0] == key }
if idx
@array[idx][1] = value
else
@array.push([key, value])
end
end
def get(key)
@array.each { |ele| return ele[1] if ele[0] == key }
nil
end
def delete(... | true |
8648c379db26475d74411fe8abefc10a91b604ee | Ruby | kenman21/key-for-min-value-web-022018 | /key_for_min.rb | UTF-8 | 488 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
if name_hash != {}
arrayofmaxes = []
min_name = ""
name_hash.each do |names, values|
arrayofmaxes.push(values)
end
max = arrayofmaxes.m... | true |
7d4299ec09d94668d03ba589575d0e84a1ab423d | Ruby | masayasviel/algorithmAndDataStructure | /from101to150/ABC115/mainC.rb | UTF-8 | 178 | 2.96875 | 3 | [] | no_license | n, k = gets.chomp.split(" ").map(&:to_i)
h = []
ans = 1 << 30
n.times do
h << gets.chomp.to_i
end
h.sort!
(n-k+1).times do |i|
ans = [ans, h[i+k-1]-h[i]].min
end
puts ans | true |
10d5cf3f59702223faea5f6eb8a2c6371193fb8e | Ruby | feroult/dxdojo | /codebreaker/lib/codebreaker/game.rb | UTF-8 | 937 | 3.5625 | 4 | [] | no_license | module Codebreaker
class Game
def initialize(output)
@output = output
end
def start(code = nil)
@code = code
@output.puts "welcome to codebreaker"
@output.puts "submit a guess:"
end
def guess(guess)
@output.puts "+"*exact_match_count(guess) + "-"*number_matc... | true |
72473230b4d5735e0db9d51ff0e7edd15623e104 | Ruby | ndelforno/Hatchway_assessment | /report.rb | UTF-8 | 2,466 | 3.5 | 4 | [] | no_license | require 'csv'
require 'json'
require "awesome_print"
students_array = []
marks_array = []
courses_array = []
tests_array = []
puts "path of students file?"
filename = gets.chomp
students = CSV.read(filename)[1 .. -1]
puts "Path of marks file?"
filename = gets.chomp
marks = CSV.read(filename)[1 .. -1]
puts "Path of... | true |
9dfb4a27108dc16c260b4efe9b63139ab3cd8b62 | Ruby | usutani/hsms | /hsms_server.rb | UTF-8 | 957 | 2.65625 | 3 | [] | no_license | require "rubygems"
require "eventmachine"
require "hsms_factory"
require "hsms_state"
class HSMSServer < EM::Connection
def initialize
@factory = HSMSFactory.new
@state = HSMSState.new
puts @state.to_s
end
def post_init
@state.connected
puts @state.to_s
end
def unbind
@state.di... | true |
c8ee42db2003d9e79b5738d34a09d296f19fab2b | Ruby | jkschub/general-activities-app | /ga-app/db/seeds.rb | UTF-8 | 2,324 | 2.75 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
e212d33e87df7bd3dabb99601b6f3b65e4f2b535 | Ruby | triperodericota/redrock | /db/seeds.rb | UTF-8 | 3,359 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'faker'
def set_photo(path_file, model)
begin
File.open(path_file) do |file|
model.photo = file
puts model.photo.url
model.save!
end
rescue
puts "\n Without photo"
end
end
Photo.destroy_all
# fan's users
Fan.destroy_all
puts "Fans: \n"
(1..15).each do
f = Fan.create!(firs... | true |
ee76efa9f38a86bd7e7dbba06989f3201c32fbc9 | Ruby | ffi/ffi | /bench/bench_FrV.rb | UTF-8 | 804 | 2.53125 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | require_relative 'bench_helper'
module BenchFrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_f32_v, [ :float ], :void
def self.rb_bench(i0); nil; end
end
puts "Benchmark [ :float ], :void performance, #{ITER}x calls"
f = 1.0
10.times {
puts Benchmark.me... | true |
5c2b321ef6bae9bd0268b41336601a231526d222 | Ruby | andrewhchang/pacmansimulator | /lib/grid.rb | UTF-8 | 672 | 3.421875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'position'
# Grid class
class Grid
attr_reader :x_size
attr_reader :y_size
# Initialize table with an X and Y dimension
def initialize(x_size, y_size)
unless x_size < 1 || y_size < 1
@x_size = x_size - 1
@y_size = y_size - 1
end
end
# Ch... | true |
8061eff1e00f224f86c69e17f2cf1c394dc08fd9 | Ruby | snorkleboy/sse | /server.rb | UTF-8 | 1,141 | 3.3125 | 3 | [] | no_license | require 'socket'
class Server
def initialize()
@server = TCPServer.new 2000
loop do
Thread.start(@server.accept) do |client|
handleClient client
end
end
end
def handleClient(client)
msg = client.recv(300).split("\n")
if (msg[0].... | true |
0cdd8f9239bdeff596be5000f04a61a73603d0e7 | Ruby | jgroeneveld/attributed_object | /spec/attributed_object_spec.rb | UTF-8 | 8,147 | 3 | 3 | [
"MIT"
] | permissive | require 'attributed_object'
describe AttributedObject do
class SimpleFoo
include AttributedObject::Strict
attribute :bar
end
class DisallowingNil
include AttributedObject::Strict
attribute :bar, disallow: nil
end
class DefaultFoo
include AttributedObject::Strict
attribute :bar, defa... | true |
653434610c4de6ede3d4b51dc9b104ce5d46fd63 | Ruby | Alkex1/TextGet | /db/seeds.rb | UTF-8 | 2,185 | 2.828125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
517ade00c69d87d44bae804cac97ce83d77597ee | Ruby | karthik-mallavarapu/site_crawler | /crawler.rb | UTF-8 | 1,227 | 2.84375 | 3 | [] | no_license | require 'nokogiri'
require 'uri'
require 'open-uri'
require 'pry'
module Crawler
EXCLUDE_PATTERN = /.(jpg|jpeg|png|gif|pdf|svg|mp4)\z/
def scrape_page(url)
page = get_page(url)
return [] if page.nil?
links = page.css('a')
urls = links.map { |link| link['href'] }
urls.compact!
urls.uniq!
... | true |
2a904d42d496387ffce1a8591c0510901b87af9b | Ruby | lilijreey/rails-note | /ra/view/artflow/presenters/lib/creation_summary.v1.rb | UTF-8 | 682 | 2.546875 | 3 | [] | no_license | #---
# Excerpted from "The Rails View",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.p... | true |
618a16cd65bf9ed694a5f25caff946c2ee918325 | Ruby | QuantaEx/payeer | /lib/payeer.rb | UTF-8 | 2,294 | 2.609375 | 3 | [] | no_license | require 'net/https'
require 'logger'
class Payeer
API_URL = 'https://payeer.com/ajax/api/api.php'
class AuthError < Exception
end
class ApiError < Exception
end
attr_accessor :account, :api_id, :api_secret, :config, :logger
DEFAULTS = {
language: 'ru'
}
def initialize(account, api_id, api_... | true |
81307d8d743b12d1450513dcc100a36797b543fb | Ruby | jfurukawa4392/aa_homework | /W2D4/poker/spec/card_spec.rb | UTF-8 | 418 | 3.078125 | 3 | [] | no_license | require 'card'
describe Card do
describe "#initialize" do
subject(:card) {Card.new(["A","C"])}
it "is initialized with a value and a suit" do
expect(card.value).to eq("A")
expect(card.suit).to eq("C")
end
it "raises an error if card is invalid" do
expect{ Card.new(5) }.to raise_er... | true |
7b27969619b267ef5facf25517afd61c65351a64 | Ruby | MasonChinkin/aA_hw | /w2d4/octopus_problems.rb | UTF-8 | 740 | 3.484375 | 3 | [
"Apache-2.0"
] | permissive | FISH = ["fish", "fiiish", "fiiiiish", "fiiiish", "fffish", "ffiiiiisshh", "fsh", "fiiiissshhhhhh"]
def sluggish(arr)
longest = ""
arr.each do |ele1|
if arr.none? { |ele2| ele1 != ele2 && ele2.length > ele1.length }
longest = ele1
end
end
longest
end
def merge_sort(arr, &prc)
return self if sel... | true |
0fceba16de9b6566b3e4edf0102703c68b5eac76 | Ruby | chrisjenson/Projects | /RE-SERVD/code/app/controllers/opportunities_controller.rb | UTF-8 | 4,793 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
#
# Filename: opportunity_controller.rb
# Description: this file is the controller file for all of the opportunities and actions
# associated with the events page.
class OpportunitiesController < ApplicationController
before_action :set_opportunity, only: %i[favorite show edit update de... | true |
1e494d9a7c8922d925381b173853ed1080d18ff8 | Ruby | airbnb/ruby | /rubocop-airbnb/lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb | UTF-8 | 2,740 | 2.71875 | 3 | [
"MIT"
] | permissive | require_relative '../../airbnb/inflections'
require_relative '../../airbnb/rails_autoloading'
module RuboCop
module Cop
module Airbnb
# This cop checks for a constant assigned in a file that does not match its owning scope.
# The Rails autoloader can't find such a constant, but sometimes
# peop... | true |
ef8b8780e5b2340e02e65bad7e6ef2827fffc091 | Ruby | lllisteu/headlamp | /test/tests/test_canvas_base.rb | UTF-8 | 1,090 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'headlamp/canvas'
class Test_canvas_base < Test::Unit::TestCase
def test_base
sheet = Headlamp::Canvas.new
assert_equal sheet.height, sheet.width
sheet = Headlamp::Canvas.new 5
assert_equal 25, sheet.to_a.size
assert_equal 5, sheet.width
assert_equal 5, sheet.... | true |
c4f467805aa31380130e08fed4636a5480372200 | Ruby | victornava/ruby-list | /spec/list/intersection_spec.rb | UTF-8 | 1,418 | 3.28125 | 3 | [] | no_license | require 'spec_helper'
describe "#&" do
it "creates a list with elements common to both arrays (intersection)" do
(List[] & List[]).should == List[]
(List[1, 2] & List[]).should == List[]
(List[] & List[1, 2]).should == List[]
(List[ 1, 3, 5 ] & List[ 1, 2, 3 ]).should == List[1, 3]
end
it "creat... | true |
19fa6930cab02854121554fbd0c61ad5fd126677 | Ruby | arttracks/nazi_hunter | /lib/nazi_hunter/nazi_detector.rb | UTF-8 | 5,580 | 2.75 | 3 | [
"MIT"
] | permissive | require_relative "nazi_tests.rb"
require "geo_deluge"
require "museum_provenance"
module NaziHunter
class NaziDetector
include NaziHunter::NaziTests
def initialize(opts = {})
@strict = opts.fetch(:strict, false)
geo_deluge_cache = opts.fetch(:geo_deluge_cache, "./caches/fast_cache.... | true |
6785ec7c4d4d4147cb498d05fc7a69257db42f69 | Ruby | dry-rb/dry-configurable | /lib/dry/configurable/setting.rb | UTF-8 | 1,907 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require "set"
module Dry
module Configurable
# A defined setting.
#
# @api public
class Setting
include Dry::Equalizer(:name, :default, :constructor, :children, :options, inspect: false)
OPTIONS = %i[default reader constructor mutable cloneable settings con... | true |
736d5e5796e5ad62b82e9f8327689284ad702391 | Ruby | ruckc/gocd | /tools/jruby/lib/ruby/gems/1.8/gems/rubygems-update-1.3.5/test/test_gem_validator.rb | UTF-8 | 1,624 | 2.5625 | 3 | [
"Apache-2.0",
"LGPL-2.1-only",
"CPL-1.0",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"Ruby",
"GPL-2.0-only",
"LicenseRef-scancode-public-domain"
] | permissive | #--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
require 'rubygems/validator'
cla... | true |
67ced385f526f6ddf26ef22a45ab8ce8f002e5b0 | Ruby | helloklow/model-class-methods-lab-online-web-pt-011419 | /app/models/boat.rb | UTF-8 | 2,023 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Boat < ActiveRecord::Base
belongs_to :captain
has_many :boat_classifications
has_many :classifications, through: :boat_classifications
def self.first_five
# return 5 boats by limiting results to this number only
all.limit(5)
end
def self.dinghy
# find and return boats less than 20... | true |
7f298b1175bfc735d787df2518d3b6a4a3665f7c | Ruby | TylerNHansen/TicTacToe | /tictactoe.rb | UTF-8 | 1,176 | 3.921875 | 4 | [] | no_license | require './board.rb'
require './supercomputerplayer.rb'
require './humanplayer.rb'
class TicTacToe
class IllegalMoveError < RuntimeError
end
attr_reader :board, :players, :turn
def initialize(player1, player2)
@board = Board.new
@players = { x: player1, o: player2 }
@turn = :x
end
def run
... | true |
84d20ec55efa17c6fda4542c5fb2d1d4f32d5abf | Ruby | cos404/Petsonic | /lib/parser.rb | UTF-8 | 961 | 2.875 | 3 | [] | no_license | require 'curb'
require 'nokogiri'
require 'colorize'
require_relative 'items_parser'
# The main module responsible for starting parsing categories and items
module Parser
def self.start
puts 'Parse category'.light_green
html = Nokogiri::HTML(Curl.get(CATEGORY).body_str)
id_category = get_category_id(html... | true |
d9ce2c2fda54abc9dda600c3d584597456c23bdf | Ruby | EdwardAcosta/my_fave_rests2 | /next_rails/record_store/record.rb | UTF-8 | 125 | 2.859375 | 3 | [] | no_license | class Record
attr_reader :name , :artist
def initialize(name, artist)
@name = name
@artist = artist
end
end | true |
e71f231ae4a9d2dd7c04cc67814bdc595f8ee73a | Ruby | jdan/adventofcode | /2015/rb/2015/05a-nice-strings.rb | UTF-8 | 215 | 2.984375 | 3 | [] | no_license | # http://adventofcode.com/day/5
total = 0
ARGF.each do |line|
next if line =~ /(ab|cd|pq|xy)/
if line.scan(/[aeiou]/).size >= 3 and line =~ /(.)\1/
total += 1
end
end
puts total
| true |
f1e2985f036f6a9bd8952304ee78bc696f9b8d71 | Ruby | youbin/BookStand | /app/models/common_methods.rb | UTF-8 | 1,077 | 3 | 3 | [] | no_license | class CommonMethods
def self.makeHash(*args)
args_size = args.size
if args_size % 2 != 0
return false
end
result = Hash.new
i = 0
while i < args_size
result[args[i]] = args[i+1]
i = i + 2
end
p result
return result
end
def self.makeParArgs(*args)
args_si... | true |
19bf441be88e8b2d6e702a3f6f065681e2bba4c2 | Ruby | lfv89/play-parser | /lib/playparser/services/file_parser.rb | UTF-8 | 347 | 2.953125 | 3 | [] | no_license | class FileParser
attr_reader :content
class << self
attr_accessor :dependence, :dependence_method
end
def initialize(file)
@file = file
@dependence = self.class.dependence
@dependence_method = self.class.dependence_method
end
def content
@content ||= @dependence.method(@dependence_met... | true |
f6f76ec946f97589b912e2f9fde739290c00bb97 | Ruby | mivok/md2evernote | /kramdown_evernote_html.rb | UTF-8 | 2,507 | 2.78125 | 3 | [] | no_license | require 'kramdown/converter/html'
module Kramdown
module Converter
class EvernoteHtml < Html
# Code block style that evernote generates
CODEBLOCK_STYLE = "box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; color: rgb(51, 5... | true |
331b56e57755582706ea822e2599fdec8866de32 | Ruby | Monte-Amador/rb101-foundations | /lesson_4/2_collections_basics/pedac_test.rb | UTF-8 | 388 | 3.265625 | 3 | [] | no_license | str = "lulucha"
result = []
substring = str.chars
# if substring.length > 2
# loop do
# base = 0
# counter = 1
# letter_set = substring[base]+ substring[counter]
# result.push(letter_set) if letter_set == letter_set.reverse
# base += 1
# break if base == substring.length
# end
# p "Here: ... | true |
9e85492e583616f28159f902547372b6db313301 | Ruby | VikiAnn/cms_practice | /test/models/page_test.rb | UTF-8 | 1,637 | 2.859375 | 3 | [] | no_license | require './test/test_helper'
class PageTest < Minitest::Test
def test_it_stores_a_page
page_data = {:slug => "about-us",
:content => "Our site is great!"}
returned_page = Page.create( page_data )
found_page = Page.find_by_slug( page_data[:slug] )
assert_equal returned_page, f... | true |
8d372bbaf660f90725cdf2ee3e3c5fb062bd1bd6 | Ruby | michaeld55/week3_day3_music_collection_lab | /models/album.rb | UTF-8 | 1,422 | 3.03125 | 3 | [] | no_license | class Album
attr_accessor :id, :title, :genre
attr_reader :artist_id
require_relative('../db/sql_runner.rb')
def initialize(options)
@id = options['id'].to_i if options['id']
@title = options['title']
@genre = options['genre']
@artist_id = options['artist_id'].to_i
end
def save
sql ... | true |
376a5a22792348bc29206c62c061a6f2fa64925a | Ruby | 223yu/cloud9_ruby | /ruby/lesson7-1.rb | UTF-8 | 158 | 3.359375 | 3 | [] | no_license | puts '2つの値を入力してください'
nam1 = gets.to_i
nam2 = gets.to_i
calc = nam1 * nam2
puts "計算結果を出力します"
puts "a*b= #{calc}" | true |
6692820ef113c8432655b9bd1f2faea2012d3aeb | Ruby | mpkato/clusty | /app/models/project.rb | UTF-8 | 1,559 | 2.59375 | 3 | [] | no_license | require 'csv'
class Project < ActiveRecord::Base
belongs_to :user
has_many :elements, dependent: :destroy
has_many :clusters, dependent: :destroy
attr_accessor :element_file
validates :label, presence: true
validates :element_file, presence: true, on: :create
def read_tsv
CSV.foreach(self.element_f... | true |
2983f3a6ee4f12df510578f7f03a7eb916ad0a00 | Ruby | EOSullivanBerlin/Internet---101 | /app.rb | UTF-8 | 202 | 2.59375 | 3 | [] | no_license | require 'sinatra'
get '/random-cat' do
@name =["Amigo", "Oscar", "Viking"].sample
erb(:index)
end
get '/named-cat' do
p params
@name = params[:name]
erb(:index)
end
get '/2' do
'Frog'
end
| true |
d6383170019deee4d0d10e0732c8a8e60ae768aa | Ruby | AaronC81/interphase | /lib/interphase/widgets/layout.rb | UTF-8 | 1,278 | 2.78125 | 3 | [] | no_license | # frozen_string_literal: true
require 'gtk2'
module Interphase
# A high-level widget which is described using a layout description string,
# abbreviated to LDS. The LDS specifies a grid in which there are a fixed
# number of widgets occupying a fixed space.
class Layout < Grid
attr_reader :lds, :descripti... | true |
4f86bac17d439d9190d1887c0047a795dda214e2 | Ruby | adkadziadka/evaluation-tool | /app/models/batch.rb | UTF-8 | 1,526 | 2.984375 | 3 | [] | no_license | class Batch < ApplicationRecord
has_many :performances, through: :students
has_many :students, dependent: :destroy
validates :number, presence: true
def percentages
rates = []
students.each do |student|
student.performances.each do |performance|
rates << performance.rate
end
end
{
green: (rat... | true |
10c407f2b1e6149104643083e5ad5621b4b55993 | Ruby | halcyon/hpt | /hpt.rb | UTF-8 | 2,189 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'rubygems'
require 'xmlsimple'
options = {}
optparse = OptionParser.new do|opts|
opts.banner = "Usage: ./hpt.rb [options]"
# Define the options, and what they do
options[:polling] = nil
opts.on( '-p', '--[no-]polling', 'Enable or Disable SCM Polling' ) ... | true |
1db5e741a1a1ee58e21ef60603d7cb8a3a528596 | Ruby | mxenabled/atrium-ruby | /lib/atrium-ruby/api/users_api.rb | UTF-8 | 14,167 | 2.65625 | 3 | [
"MIT"
] | permissive | =begin
#MX API
#The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture an... | true |
186c1d4481a0283830da8385f43f306781559936 | Ruby | NadaMarawan/Opportutoring | /app/controllers/students_controller.rb | UTF-8 | 2,140 | 2.609375 | 3 | [] | no_license | class StudentsController < ApplicationController
def show
# disallow a student to view a non-existing student's profile
begin
@student = Student.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to root_url
return
end
end
def index
@students = Student.all
end
... | true |
59f42486038c2cb47e1fd0382974a9155f24819b | Ruby | fizvlad/vk-music-rb | /lib/vk_music/playlist.rb | UTF-8 | 1,380 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module VkMusic
# Class representing VK playlist
class Playlist
extend Forwardable
include Enumerable
# @return [Integer, nil] playlist ID
attr_reader :id
# @return [Integer, nil] playlist owner ID
attr_reader :owner_id
# @return [String, nil] access hash w... | true |
5766585b7981368dca9cdaf9f8ffdca0405005f0 | Ruby | emanuelbierman/ruby-collaborating-objects-lab-v-000 | /lib/artist.rb | UTF-8 | 1,027 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Artist
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@songs = []
end
def add_song(song)
@songs << song
end
def songs
@songs
end
def self.all
@@all
end
def save
@@all << self
end
def self.find_or_create_by_name(name)
ne... | true |
31cab2051bfc9395a4a15f5b53e48620f2392d28 | Ruby | PBillingsby/collections_practice-online-web-pt-100719 | /collections_practice.rb | UTF-8 | 593 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort.reverse
end
def sort_array_char_count(array)
array.sort {|a,b| a.length <=> b.length}
end
def swap_elements(array)
array[1], array[2] = array[2], array[1]
array
end
def reverse_array(array)
array.reverse
end
def kesha_maker... | true |
ce017e9cf8e69ca87ce84a0cec6487bad0ada150 | Ruby | ooesili/game-server-challenge | /app/controllers/game_controller.rb | UTF-8 | 3,423 | 2.875 | 3 | [] | no_license | class GameController < ApplicationController
def create
# create game and player
game = Game.build
player = game.players.new(nick: params[:nick])
game.creator = player
game.save
# respond with appropriate data
render json: {
game_id: game.uuid,
player_id: player.uuid,
ni... | true |
5441679c223f56a5943a48cc143331dcae1caba2 | Ruby | egorzhdan/diskretka-1st-semester | /Lab3/Task18.rb | UTF-8 | 504 | 3.375 | 3 | [] | no_license | input = File.open('brackets2num.in', 'r')
output = File.open('brackets2num.out', 'w')
b = input.readline.strip
cnt = Array.new(b.size + 5) {Array.new(b.size + 5, 0)}
cnt[0][0] = 1
(1..b.size).each do |len|
(0..b.size).each do |balance|
cnt[len][balance] = cnt[len - 1][balance - 1] + cnt[len - 1][balance + 1]
e... | true |
bdd0db527214db6ab3a1bd3aa72c7da2791505be | Ruby | nrolland/information-theory-inference | /lib/image_voodoo_ext.rb | UTF-8 | 2,270 | 2.953125 | 3 | [] | no_license | require 'rubygems'
require 'image_voodoo'
require 'matrix'
require 'matrix_ext'
require 'forwarder'
class Symbol
def to_proc
proc { |obj, *args| obj.send(self, *args) }
end
end
class Pixels
include Enumerable
def initialize(img)
@raster =img.to_java.getRaster()
@widthPix = @raster.getWidth... | true |
e8f2f5f3eff38e8a658cda6a24a861d95dc82da3 | Ruby | anandberylsystems/traning | /ruby_basic/find_position.rb | UTF-8 | 387 | 3.65625 | 4 | [] | no_license | =begin
arr=[10,20,30,40]
for i in 0 .. 3
a=arr[i].to_i
if a==30
pos=i
end
end
puts "position is #{pos}"
=end
arr=Array[]
for i in 0 .. 5
puts"enter the number"
input=gets
input=input.to_i
arr.push(input)
end
puts"enter the number for which searched"
num=gets
num=num.to_i
for i in 0 .. arr.length
a=ar... | true |
917d0e53bd2814cc526410c347933cdca4d7e26b | Ruby | blegloannec/CodeProblems | /HackerRank/the_bomberman_game.rb | UTF-8 | 953 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env ruby
# N() = neighborhood, C() = complementary
# 0 initial conf. I
# 1 I
# 2 full O
# 3 C.N(I)
# 4 full O
# 5 C.N(3) = C.N.C.N(I)
# 6 full O
# 7 C.N(5) = C.N.C.N.C.N(I) = C.N(I) = (3)
# (without proof, N.C.N.C.N(X) = N(X),
# or alternatively C.N.C.N(Y) = Y for
# Y = {y such that N(y) is included... | true |
81f45b5146d204cd715198d65206fd074e55f7bd | Ruby | simonholroyd/git_team_stats | /bin/git_team_stats | UTF-8 | 5,336 | 2.734375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'json'
require 'progress_bar'
require 'language_sniffer'
require 'gli'
require 'git_team_stats'
include GLI::App
program_desc 'Analyze commits and committers in mulitple git repos and output project-level statistics'
desc "The path to your config file"
flag [:config_path], :default_val... | true |
fcd022cc754db6d630df9c5c1cd6cfd6d75272b4 | Ruby | youngjun-na/AAClasswork | /W3D5/youngjun_polytreenode/lib/00_tree_node.rb | UTF-8 | 1,175 | 3.71875 | 4 | [] | no_license | class PolyTreeNode
attr_accessor :children, :value
attr_reader :parent
def initialize(value)
@value = value
@parent = nil
@children = []
end
def inspect
{ "value"=>@value, "parent"=>@parent, "children"=>@children }.inspect
end
def parent=(node)
@parent.children.delete(self) if @paren... | true |
736e59a5dd27a09f48e7eafe74b15475c74688f9 | Ruby | supremebeing7/expense_organize_sql | /expenses_ui.rb | UTF-8 | 3,038 | 3.390625 | 3 | [] | no_license | require 'pg'
require './lib/expense'
require './lib/category'
require './lib/company'
DB = PG.connect({:dbname => 'expenses'})
def ascii_art
system "clear"
print "\e[1;32m
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ $
$ __ _____ $
$ |__ ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.