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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6ef256e257e0a89cc009d8c9694565d778f79c64 | Ruby | jscottbruns/sandbox | /ruby/assessment/exercise3.rb | UTF-8 | 608 | 3.671875 | 4 | [] | no_license | class Inventory
attr_reader :in_stock
def initialize(inventory = ['Toyota Camry'])
@in_stock = inventory
end
def update_stock(vehicle)
@in_stock << vehicle.info
end
end
module Vehicle
def inventory
@inventory ||= Inventory.new(['Nissan Leaf'])
end
def in_stock
inventory.in_stock
end... | true |
a5e184784263d93423ef9fdac889e9d2b59b19bc | Ruby | ksupasak/gxt | /services/miot-monitor/devices/m540.rb | UTF-8 | 3,312 | 2.5625 | 3 | [] | no_license | require "socket"
require "ipaddr"
# MULTICAST_ADDR = "224.127.1.255" # to discovery all monitor
MULTICAST_ADDR = "224.0.1.173" # to receive data
MULTICAST_ADDR = "224.0.1.4" # to receive data
BIND_ADDR = "0.0.0.0"
BIND_ADDR_2 = "203.156.124.171"
BIND_ADDR_2 = "191.1.1.5"
# M540 data on this port
PORT = 2050
soc... | true |
a8b24d47750488ce63ebd072ccd095dcaa195140 | Ruby | ilayda-the-Disc0Queen/ruby-practice | /Array:string manipulation/reverse_string.rb | UTF-8 | 601 | 4.28125 | 4 | [] | no_license | def reverse_string!(string) # destructive method so use !
left_index = 0
right_index = string.length - 1
while left_index < right_index
# swap the characters
string[left_index], string[right_index] =
string[right_index], string[left_index]
# move to second char and second to last char
left_in... | true |
438047e3c4a045261346bc0762c92be6a51ee3a3 | Ruby | dkubb/axiom-sql-generator | /lib/axiom/sql/generator/function/numeric.rb | UTF-8 | 4,031 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
module Axiom
module SQL
module Generator
module Function
# Generates an SQL statement for a numeric function
module Numeric
include Function
ABSOLUTE = 'ABS'.freeze
ADD = '+'.freeze
SUBTRACT = '-'.freeze
MUL... | true |
3a922f44b489120c8c2edb133ea61c4771a7c986 | Ruby | thoiberg/gemstrapper | /lib/gemstrapper.rb | UTF-8 | 3,321 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'fileutils'
require 'gemstrapper/utility/string_helpers'
##
# Top level module for the app.
module Gemstrapper
include Utility::StringHelpers
##
# The absolute path of the directory containing all the templates needed for a new gem
TEMPLATES_DIRECTORY = File.expand_path('gemstrapper/templat... | true |
cfa04e90519f2c6914e9f78d2766ab929109ecc0 | Ruby | rikas/cloudflare_localizable | /lib/cloudflare_localizable.rb | UTF-8 | 827 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'cloudflare_localizable/version'
require 'cloudflare_localizable/country'
# This module can be included in any Rails controller that needs country information. You get a
# helper method called cf_country to be used whenever you need to know the country of the user.
#
# === Exampl... | true |
011a0e8e7f9d06a0feb25db25376f210743693d8 | Ruby | cy2003/Calendar | /lib/runners/delete_event.rb | UTF-8 | 435 | 3.171875 | 3 | [] | no_license | def delete_event
puts "Enter name of event you would like to delete"
event_name = gets.strip
event_array = []
@cal_name.events.each do |event|
if event.name.downcase == event_name.downcase
event_array << event
@cal_name.events.delete(event)
puts "#{event.name} has been deleted"
help
... | true |
4fa22e6a096dbf02985fd85f1a44ea0fa7db4ba4 | Ruby | tonytonyjan/palmistry | /app/models/mercury_line.rb | UTF-8 | 735 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class MercuryLine
def initialize(user)
@user = user
@sex_human = user.sex_human
end
def result_money
case @user.palm.mercury_money
when 0 then
result = @user.uname + " さんは現在お金に困っています。<br>
現在の収入に満足していません。<br>"
when 1 then
result = @user.uname + " さんはお金は入ってきますが、すぐに出て行く状態です。<br... | true |
6c3ad26fd457dab14cdb3b854d8ba1c871253778 | Ruby | andori8/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 172 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
new_array =[]
new_string = string.split.to_a
new_string.collect do |word|
new_array << word.reverse
end
new_array.join(" ")
end
| true |
927dc6d2b4ebe4df230de1ffe8cc7a1902869aaf | Ruby | IanMitchell/buddy_api | /lib/buddy_api/session.rb | UTF-8 | 4,203 | 2.59375 | 3 | [
"MIT"
] | permissive | module BuddyAPI
module Session
CREATE_PATH = '/games/#{id}/sessions'
GET_PATH = '/games/#{gameId}/sessions' # + id
SEARCH_PATH = '/games/#{gameId}/sessions'
UPDATE_PATH = '/games/#{gameId}/sessions' # + sessionId
DELETE_PATH = '/games/#{gameId}/sessions' # + sessionId
# Public: TODO: Test,... | true |
dfdb357aee8824e1af8a0430697d1010817505b0 | Ruby | elektronaut/apparat_client | /lib/apparat.rb | UTF-8 | 2,032 | 2.9375 | 3 | [
"MIT"
] | permissive | require "soap/wsdlDriver"
module Apparat
class MessagingClient
attr_accessor :product_id, :sender
# create a new client object.
#
# example:
#
# client = Apparat::MessagingClient.new( "my_key" )
# client.sender = "myName"
# client.product_id = 10
#
# attributes can also be set in t... | true |
ea9f660f005e0cb5605c50b795667ca120f90e7c | Ruby | akexinad/topics | /15-yegge_questions/03-integer_sum/integer_sum.rb | UTF-8 | 492 | 3.921875 | 4 | [] | no_license | # Write a function that sums up integers from a text file, one int per line.
# def sum_integers filename
# sum = 0
# file = File.new filename
# file.each_line do |line|
# sum += line.to_i
# end
# sum
# end
# OR
# def sum_integers filename
# numbers = File.readlines(filename)
# numbers.inject do |ac... | true |
70ffab718ff4502a921af695515db80a02f82390 | Ruby | controlshift/vertebrae | /lib/vertebrae/request.rb | UTF-8 | 1,618 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
module Vertebrae
module Request
METHODS = [:get, :post, :put, :delete, :patch]
METHODS_WITH_BODIES = [ :post, :put, :patch ]
def get_request(path, params={}, options={})
request(:get, path, params, options)
end
def patch_request(path, params={}, options={})
... | true |
09a909c418a88bc7cd04b5152f25e69085ee1a8f | Ruby | Justin-Mullins/launch_school | /120_Object_Oriented_Programming/Lesson_4/Exercises_Medium-1/question3.rb | UTF-8 | 905 | 3.6875 | 4 | [] | no_license | # question3.rb
# In the last question Alyssa showed Alan this
# code which keeps track of items for a shopping cart application:
class InvoiceEntry
attr_reader :quantity, :product_name
def initialize(product_name, number_purchased)
@quantity = number_purchased
@product_name = product_name
end
def up... | true |
67a89ceddbe519ba0146e6de63148cb7db43cdae | Ruby | PawelOgorek/PairProgrming | /2_week/5e_x_=_y.rb | UTF-8 | 270 | 3.84375 | 4 | [] | no_license | x, y = y, x
its very usefull value swapping idea beetwen two variables. I.e. in java we have to use third variable and do it in few steps
SO:
x = 10
y = 20
x, y = y, x
puts x
puts y
equal: (because now x = y and y = x)
20
10
| true |
ac3cf63bbd6e7f647e10a0d9ef9baa468b1a1dd4 | Ruby | LaurensN/unit_4_multivers | /lib/unit_4_multivers/client.rb | UTF-8 | 4,008 | 2.546875 | 3 | [
"MIT"
] | permissive | require "unit_4_multivers/account"
require "unit_4_multivers/administration"
require "unit_4_multivers/customer"
require "unit_4_multivers/journal"
require "unit_4_multivers/product"
require "unit_4_multivers/project"
require "unit_4_multivers/openingbalance"
require "unit_4_multivers/supplier"
require "unit_4_multiver... | true |
74aee27c05622f2a7a677170650f8a732d7ec4f3 | Ruby | adsedinburgh21/Rocket_League_Table | /models/league.rb | UTF-8 | 1,372 | 3.4375 | 3 | [] | no_license | class League
attr_reader :teams, :matches
def initialize( options )
@teams = options[ 'teams' ]
@matches = options[ 'matches' ]
end
def list_teams
return @teams.map { | team | team.name }
end
#### keep test iscolated and small
#### think about what type of data you want back: arrays - ha... | true |
1313a8dd91e8432ce70c42caefc5cf45c9e27cb3 | Ruby | arpodol/ruby_small_problems | /easy9/grocery_list.rb | UTF-8 | 689 | 4.0625 | 4 | [] | no_license | =begin
~~Understanding the Problem~~#
Write a method that takes a grocery list of fruits with quantities and
converts it into an array of the correct number of each fruit.
~~Input~~#
- 1 array
~~Output~~#
- 1 array
~~Rules~~#
-
~~Example~~#
buy_fruit([["apples", 3], ["orange", 1], ["bananas", 2]]) ==
["apples", ... | true |
96674eb0961f73ffaf93d57616258d46aabb66dd | Ruby | abacha/cep_facil | /spec/cep_facil_spec.rb | UTF-8 | 2,624 | 2.6875 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | # coding: utf-8
require File.expand_path('spec/spec_helper')
describe CepFacil do
before(:each) do
@token = "0E2ACA03-FC7F-4E87-9046-A8C46637BA9D"
end
it "has a version" do
CepFacil::VERSION.should =~ /^\d+\.\d+\.\d+$/
end
it "can fetch an address from a CEP" do
cep = "53417-540"
address =... | true |
a0fa929ba89169e1258a5591c4cf044e3bdd1ec3 | Ruby | siman-man/shiritori | /lib/shiritori/shiritori.rb | UTF-8 | 4,699 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'pp'
require 'readline'
module Shiritori
class Main
attr_reader :current_object, :chain_count, :error_count, :mode, :used_method_list
include SearchMethod
include View
# ColorCode
RED = 31
GREEN = 32
EXIT_PATTERN = /\A(exit|quit)\Z/.freeze
HELP_PATTERN = /\A(help|h)\Z/.freez... | true |
08483ea13fa9a1fd637cefb93a52521ee034cfb2 | Ruby | cjbara/advent-of-code | /day6/counts.rb | UTF-8 | 536 | 3.234375 | 3 | [] | no_license | require 'set'
counts = []
current = Hash.new(0)
current_count = 0
def total(c, count)
amount = []
c.each do |k, v|
if v == count
amount << k
end
end
amount.count
end
File.foreach("input.txt") do |line|
line.strip!
if line == ""
counts << total(current, current_count)
current = Hash... | true |
4f9c8ed5dfb5b8276473115fc35f71085ced6d39 | Ruby | thebravoman/software_engineering_2014 | /vhodno_nivo/Vladimir_Yordanov_2.rb | UTF-8 | 129 | 3.25 | 3 | [] | no_license | x = gets.to_i
begin
y = gets.to_i
end until x < y
sum = 0
for i in x..y
if i % 17 == 0
sum = sum + i
end
end
print sum
| true |
8626751a68d7e4d0fc1474d3d21893d6cbc50eae | Ruby | pierregarciafr/Exercism | /ruby/saddle-points/saddle_points.rb | UTF-8 | 506 | 3.21875 | 3 | [] | no_license | class Matrix
attr_reader :rows, :columns
def initialize(string)
@rows = string
.split("\n")
.map do|line|
line.split(" ")
.map(&:to_i)
end
@columns = @rows.transpose
end
def saddle_points
rows.each_with_... | true |
94664366baf48ebb36c957b90b4773eaa39b232d | Ruby | tomun/RubyFall2014 | /week8/exercises/couch_spec.rb | UTF-8 | 734 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | require_relative 'couch.rb'
describe Couch do
before :each do
@couch = Couch.new [:red, :red, :black, :black], [:grey, :grey], ['Bradley', 'Sticks']
end
it "should tell me the pillow colors" do
@couch.pillow_colors.should eq ["red", "red", "black", "black"]
end
it "should tell me the cushions colors... | true |
9c0325a0cb381e27050e24a07e3b59dd422b7cd2 | Ruby | lugray/advent_of_code | /2016/day12/assembunny.rb | UTF-8 | 880 | 3.25 | 3 | [] | no_license | class Assembunny
INT = /-?\d+/
def initialize(input)
@input = input.each_line.map(&:strip).reject{ |line| line == "" }.map{ |line| line.split(' ') }
@line = 0
@memory = Hash.new { 0 }
end
def run
while @input[@line] do
send(*@input[@line])
@line += 1
end
@memory.inspect
e... | true |
7fd1fa3772d99b1e030c122522b7990c935576dd | Ruby | IAmTechieChic/ShoeStore-Test | /spec/shoe_spec.rb | UTF-8 | 1,001 | 2.5625 | 3 | [] | no_license | #require './spec_helper'
require_relative '../lib/shoe'
describe Shoe do
before :each do
@shoe = Shoe.new "Jimmy Choo", "Pre-order this style today! Add to Shopping Bag to view approximate ship date. Diminutive crystals trace the elegant lines of a plush suede sandal topped with a lofty, ankle-wrap strap. Jimmy Ch... | true |
93f083c4f000c5e2b37a465589edcd00b8600441 | Ruby | ignacioito/aula_ruby_linguagem | /aula05.rb | UTF-8 | 259 | 3.53125 | 4 | [] | no_license | str = "pao,leite,cafe,bolacha,bolo"
x=str.split
puts str
puts x.inspect
str1 = %w"ignacio seiti lima ito"
puts str1.inspect
#eval (o eval interpreta uma string para um outro valor)
#exemplo
puts "Digite algo: "
str = gets.chomp
x3 = eval(str)
puts x3
| true |
2a34514629c13a8eca513cb76edc1c209db0ba48 | Ruby | mariaalavez/codewarriors | /reverse_it.rb | UTF-8 | 448 | 3.984375 | 4 | [] | no_license | require 'byebug'
def reverse_it(data)
if data.class == String
reverse = data.reverse
elsif data.class == Fixnum
reverse = data.to_s.reverse
elsif data.class == Array
reverse = data
end
reverse
end
my_string = 'Hello'
a = reverse_it(my_string)
puts a
my_num = 12345
b = reverse_it(my_num)
puts b... | true |
75434d43fdccc5d2868160203f702cf8a5890670 | Ruby | aparkening/looping-while-until-online-web-prework | /lib/while.rb | UTF-8 | 165 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Output "Wingardium Leviosa" 4 times, incrementing from 6
def using_while
levitation_force = 6
while levitation_force < 10
puts "Wingardium Leviosa"
levitation_force += 1
end
end
| true |
4155d77d145d1929e066574542bcc8da08755137 | Ruby | StephanMukete/YearUp_Study | /ruby/day3/signup.rb | UTF-8 | 369 | 3.53125 | 4 | [] | no_license | class User
attr_accessor :email, :password
def initialize(email, password)
@email = email
@password = password
end
end
puts "Welcome to my app!"
puts "What is your email?"
email = gets.chomp
puts "Create a password"
password = gets.chomp # works like prompt() in JS
user = User.new(email, password)
puts "Y... | true |
8794a88918ba3a4cc447eb21f79114f0624bf932 | Ruby | Will-Helliwell/battle1 | /spec/game_spec.rb | UTF-8 | 635 | 3.109375 | 3 | [] | no_license | require 'game'
require 'player'
describe Game do
let(:player1) { Player.new('Kenneth') }
let(:player2) { Player.new('Kennethy') }
let(:game) { Game.new(player1, player2) }
describe '#attack' do
it "reduces attacked player's points by 10" do
expect { game.attack(player2) }.to change { player2.hit_poi... | true |
0c03c046afe3f0c0a84ea2051fb8e685a1a7e5b1 | Ruby | KGan/appacc | /w1d2/RPN.rb | UTF-8 | 1,543 | 3.40625 | 3 | [] | no_license | class RPNCalculator
attr_accessor :value
def initialize
@cstack = []
@value = nil
end
def push(num)
@cstack.push(@value) if @value
@value = num.to_f
end
@@operations = {:plus => :+, :minus => :-, :times => :*, :divide => :/}
@@operations.each do |operation, symbol|
define_method o... | true |
b5ae114e867cf54477c98e6c121622a92936d131 | Ruby | techpeace/pleased_to_tweet_you | /app/models/sign_up.rb | UTF-8 | 2,839 | 3.203125 | 3 | [
"Ruby",
"BSD-2-Clause",
"MIT"
] | permissive | class SignUp < ActiveRecord::Base
validates_presence_of :name
# Returns the member of press attribute formatted for the CSV file.
def member_of_press_for_csv
self[:member_of_press] ? '1' : '0'
end
# Returns the email opt in attribute formatted for the CSV file.
def email_opt_in_for_csv
self[:e... | true |
786b661f38d43aa3c58213f1566cd6659924df37 | Ruby | railslove/checkit | /lib/checkit/services.rb | UTF-8 | 2,138 | 2.796875 | 3 | [
"MIT"
] | permissive | module CheckIt
class Services
attr_accessor :io
DEPENDENCY_STATES = [:ok, :not_running, :not_installed]
EXTERNAL_DEPENDENCIES = {
'pg' => ['postgres'],
'mysql' => ['mysqld'],
'mysql2' => ['mysqld'],
'tire' => ['elasticsearch'],
'neography' => [... | true |
85469871979976ce64134f67c284b71e14a1480f | Ruby | donovanglover/EverFrog | /modules/log/success.rb | UTF-8 | 84 | 2.78125 | 3 | [] | no_license | module Log
def self.success(given_message)
puts given_message.green
end
end
| true |
770faff1dbdcb03d73e47737288e8d0f3b8a6308 | Ruby | gabepolk/gutenberg | /lib/complex_predictor.rb | UTF-8 | 439 | 3.125 | 3 | [] | no_license | require_relative 'predictor'
class ComplexPredictor < Predictor
# Public: Trains the predictor on books in our dataset. This method is called
# before the predict() method is called.
#
# Returns nothing.
def train!
@data = {}
end
# Public: Predicts category.
#
# tokens - A list of tokens (words)... | true |
8d8afec97e3bc06482a6e5701aaae1b359976c58 | Ruby | ghabrielv/learning-ruby | /guess_number.rb | UTF-8 | 178 | 3.6875 | 4 | [] | no_license | random = rand(10)
3.times do
print "Enter a number: "
num = gets.chomp.to_i
if num == random
puts "Congratulations, you guessed it!"
break
end
end | true |
be450ccc111006f59bc01d62831af676740e7dc5 | Ruby | Trickster2038/BmstuLabs3 | /IP/lab6/lab6-3/maxim.rb | UTF-8 | 447 | 3.125 | 3 | [] | no_license | #!/usr/bin/ruby
# frozen_string_literal: true
# counts max distance between functions
module Distance
def self.maxim(function_lambda, start, stop, step_size, &function_block)
max_distance = 0
(start..stop).step(step_size) do |arg|
max_distance = (function_lambda.call(arg) - function_block.call(arg)).ab... | true |
eb8904efea0ae762137c957a95cfd6c005706b2f | Ruby | OpenDemocracyManitoba/Winnipeg-Hansard-Parser | /ms_word_council_docs/disposition.rb | UTF-8 | 1,539 | 3.125 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | require 'docx'
require 'forwardable'
class Disposition
extend Forwardable
def initialize(filename)
@doc = Docx::Document.open(filename)
end
def bylaws
bylaw_data
end
def motions
motion_data
end
private
attr_reader :doc
def_delegator :doc, :tables # This delegator isn't being made pri... | true |
f99ff1bc0ebf5c54cb32cfa5abc2d42b519be935 | Ruby | tleung999/phase_0_unit_2 | /week_4/2_creative/create_accountability_groups/my_solution.rb | UTF-8 | 4,209 | 4.5625 | 5 | [] | no_license | # U2.W4: Create Accountability Groups
# I worked on this challenge [by myself].
# 2. Pseudocode
# Input: Takes in an array of names
# Output: Outputs a list of accountability group for 3 units.
# Steps:
=begin
Create a method called Cohort that will take in an array as an argument
If the total number of students ar... | true |
e799ace89c15576287ae3ff857223577d291574b | Ruby | SourceCodeDude/libMC.NET | /Ruby Wiki Scraper/Main.rb | UTF-8 | 8,475 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | require 'open-uri'
require 'JSON'
def getTableName(myData)
name = /<span class=\"mw-headline\" .*?> (.*?) <\/span><\/h4>/.match(myData)
return name
end
def getTableId(myData)
id = /<td.*?> (.*?)\n<\/td>/m.match(myData)
return id
end
def getTableFields(mydata)
fields = {}
running = 1
while running == 1
be... | true |
fd1b299c073cae6d26ea894a4de4991f2ea05fd3 | Ruby | Ricardonacif/banking_app | /lib/banking_app/interactors/base_interactor.rb | UTF-8 | 581 | 2.59375 | 3 | [
"MIT"
] | permissive | module BankingApp
module Interactors
class BaseInteractor
attr_reader :request, :response
def initialize(request = {})
@request = request
@response = {}
end
private
def save_repository(repo_class)
if @request[:id]
repo = repo_class.find(@request[:... | true |
c0d78873b74489bd810d021413dcdfec107d671b | Ruby | TechLadies/highpoint | /lib/tasks/import_donations.rake | UTF-8 | 1,992 | 2.703125 | 3 | [] | no_license | require "csv"
task import_donations: :environment do
i = 0
CSV.foreach("db/data/donations_2009_2015.csv", headers: false) do |row|
i = i + 1
next if i == 1
begin
row.each { |r| r.to_s.strip! }
puts '----------------------'
_, id, title, name, _, address1, address2, address3,
... | true |
bd152f017d0d8edf27a368b0f9b508c3f00c9c83 | Ruby | yoni21/programing-fund-part-two | /exercise6.rb | UTF-8 | 328 | 3.5 | 4 | [] | no_license | shopping_list = [ "Apple", "orange", "mango", "milk", "water"]
def list(shopping_list)
shopping_list.each do |item|
puts "* " + item
end
end
shopping_list << "rice"
list(shopping_list)
puts shopping_list.count
puts shopping_list[1]
shopping_list.sort!
list(shopping_list)
shoppping_list.pop
list(shoppin... | true |
acb2bc7ffd8bdef4fc3019779f66473ce19a8d57 | Ruby | inosyo/ABC | /def_quicksort.rb | UTF-8 | 1,767 | 3.953125 | 4 | [] | no_license | #!/usr/koeki/bin/ruby
# -*- coding: utf-8 -*-
# 並べかえ部分
def quicksort(number) # number 配列を受け取る
if number.length <= 1 # カードが残り 1 枚以下なら、number は数値が入る
number # 数値そのものを返して並べ換え完了
else
left = Array.new # 左側の山配列 left を新規作成
right = Array.new # 右側の山配列 right を新規作成
... | true |
0b092acf57364439d4ffd3d0bf02e8d1ca808ca1 | Ruby | mindovermiles262/hangman | /lib/logic.rb | UTF-8 | 3,777 | 3.859375 | 4 | [
"MIT"
] | permissive | # Logic class contains all rules and gameplay. First sets master word by creating
# new dictionary of words, 4 to 16 chars long from "dictionary.txt" then
# randomly assigns one word to @@master. Creates @@show, and checks player
# input is valid.
# Requires display.rb to show hangman noose ASCII drawings.
# Requires... | true |
4e401826f0e62358ded6144ceb8cefa3299ff7c8 | Ruby | cmvandrevala/history_of_anansesem_city | /db/seeds/events/epics/the_august_quartet.rb | UTF-8 | 8,383 | 2.640625 | 3 | [] | no_license | puts "===> The August Quartet"
Event.create({
name: "The Winter Circle",
date: Date.new(1985,1,21),
description: "Four seemingly random changelings see the winter circle in the sky, consisting of Sirius, Rigel, Aldebaran, Capella, Castor, Pollux, and Procyon. They instinctively follow the twinkling star Sirius t... | true |
cec060a7fcc4e5b6dc261172559a81c8c97876a8 | Ruby | pjdurai/em_speed_test | /server.rb | UTF-8 | 2,142 | 2.9375 | 3 | [] | no_license | require 'rubygems'
require 'eventmachine'
require 'socket'
require 'sqlite3'
def create_db(db)
db.execute( "create table tbl_messages (id INTEGER PRIMARY KEY, device_id INTEGER, msg TEXT);" )
end
def add_records(db, num_devices, num_records_per_device)
num_devices.times{|i|
num_records_per_de... | true |
411921e7e56644bde7631f42d9b4f50a7767e783 | Ruby | swestka/SmallCompiler | /compiler.rb | UTF-8 | 366 | 2.625 | 3 | [] | no_license | require './lexical_analysis.rb'
require './syntactical_analysis.rb'
filename = ARGV.empty? ? './samples/sample3.small' : ARGV.shift()
puts filename
output = ARGV.delete('-o')
lex_analysis = LexicalAnalysis.new(filename)
syntax_analysis = SyntacticalAnalysis.new
syntax_analysis.output = output
syntax_analysis.lex_ana... | true |
3aa20da997d526c79fbad0b59315f30291a9b648 | Ruby | AMaleh/glimmer-dsl-swt | /samples/hello/hello_canvas.rb | UTF-8 | 6,598 | 2.546875 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2007-2021 Andy Maleh
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# d... | true |
8241f1db8970c8cf0552f06d18c3534aa621f39d | Ruby | learn-co-students/chicago-web-021720 | /intro-inheritance/old-tweet-app/foo.rb | UTF-8 | 61 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Foo
def self.bar
puts "BAZ"
end
end
p Foo.new
| true |
bcaadec18af37176a040287d9cd3d5d7a5ebe883 | Ruby | RonuGhoshal/voting_data | /get1984data.rb | UTF-8 | 3,447 | 2.609375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'pp'
require 'csv'
counties_array = []
(1..56).each do |index|
p index
url = "http://uselectionatlas.org/RESULTS/datagraph.php?year=1984&fips=#{index}&f=1&off=0&elect=0"
page = Nokogiri::HTML(open(url))
table_rows = page.css('.info tr').map{|row| row.children.ma... | true |
d9e9171cb7b8666cee902b91ae8f8e590082f1a0 | Ruby | towlea/kickstarter-assignment---9-26 | /stainsOnTablesProgram.rb | UTF-8 | 275 | 3.578125 | 4 | [] | no_license | #stainsOnTablesProgram
#square feet of 1 table = 6 x 6
#number of tables = 4
#how many times
square_feet = 6 * 6
number_of_tables = 4
times = 2
answer = square_feet * number_of_tables * times
p "The amount of square feet that needs to be stained is #{answer} feet" | true |
3770166b22ef72f71d425a1555dc975c230b92ee | Ruby | mikelarkin/code_kata | /blog/titlesmash/titlesmash.rb | UTF-8 | 1,522 | 3.140625 | 3 | [] | no_license | titles = []
title_mashups_count = 0
line_count = 0
# Load titles from the file
File.open("dvd_titles.csv", "r") do |infile|
while (line = infile.gets)
line.gsub!(/\"/,'')
titles << line
line_count += 1
end
end
# titles = ["Beauty", "\"American Beauty\"", "Beauty and \"the Beast\"", "American Pie", "The... | true |
c50b7297e563d62d68934648c5ff449ae6f59953 | Ruby | AndryMac/BlackJack | /diller.rb | UTF-8 | 269 | 2.765625 | 3 | [] | no_license | class Diller < User
def initialize(name = "Diller")
super(name)
end
def during_diller_turn(command, hand)
if can_take_card?(command)
take_cards(hand.del_one_card)
else
puts "Диллер делает пас"
puts
end
end
end | true |
721d7e7c1fdcd2849ca0ec7b23fb519a72f91e68 | Ruby | turboladen/hairballs | /lib/hairballs/configuration.rb | UTF-8 | 4,700 | 2.75 | 3 | [
"MIT"
] | permissive | require 'open3'
require 'pathname'
require 'ostruct'
require 'hairballs/ext/kernel_vputs'
require 'hairballs/exceptions'
require 'hairballs/theme'
require 'hairballs/plugin'
require 'hairballs/version'
class Hairballs
# The base-level +Hairballs+ class maintains an object of this type, which
# contains the current... | true |
a21455c8166d68e564fb115e3296bd185f6163be | Ruby | bdurand/lumberjack_syslog_device | /lib/lumberjack_syslog_device.rb | UTF-8 | 4,761 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'syslog'
require 'lumberjack'
module Lumberjack
# This Lumberjack device logs output to syslog. There can only be one connection to syslog
# open at a time. If you use syslog elsewhere in your application, you'll need to pass
# :close_connection => true to the constructor. ... | true |
4bcd097b1fb601f75a4078bfef46b8031567398e | Ruby | jt-cronin/webCsvReport | /tests.rb | UTF-8 | 2,145 | 3.75 | 4 | [] | no_license | # 1. Setup
# 2. Exercise
# 3. Verify
# 4. Teardown
require "pry"
require "spec_helper"
require_relative "../main.rb"
require_relative "../functions.rb"
# Checks math for account calculations
describe "calculations" do
it "adds a list of numbers to find a balance" do
# Exercise
result = addNums(1,2)
# Verify... | true |
7d8890fab2b9362605b062bf6552134f4baab506 | Ruby | johndewolf/cashier | /cashier_csv/cashier_update.rb | UTF-8 | 4,419 | 3.421875 | 3 | [] | no_license | require 'pry'
require 'csv'
@coffees = []
@coffee_sales_report = []
def menu_read(file)
i = 0
CSV.foreach(file, headers: true) do |row|
number = row['number']
name = row['Name']
sku = row['SKU']
retail = row['Retail Price']
purchase = row['Purchasing Price']
@coffees[i] = {
number: num... | true |
c5116cc2e979f866aa819af1bc062bd21b27da57 | Ruby | zjcrumpton/ruby-pong | /main.rb | UTF-8 | 2,159 | 2.921875 | 3 | [] | no_license | # # frozen_string_literal: true
# Bundler Set Up
require 'rubygems'
require 'bundler/setup'
require 'socket'
# Allow all scripts to access gems in the Gemfile
Bundler.require(:default)
require './lib/window.rb'
require './lib/paddle.rb'
require './lib/ball.rb'
# Set Colors
left_color = Color.new('#06a2b5')
right_c... | true |
1a518c14a34843c7c49f1e154b1d1a0e78d5e01f | Ruby | mkrahu/launchschool | /101_programming_foundations/05_advanced_ruby_collections/practice_problems_2.rb | UTF-8 | 562 | 3.0625 | 3 | [] | no_license | # practice_problems_2.rb
# Practice Problems exercises
# Practice Problems from Sorting, Nested Collections and Working
# with Blocks chapter from LaunchSchool
books = [
{title: 'One Hundred Years of Solitude', author: 'Gabriel Garcia Marquez', published: '1967'},
{title: 'The Great Gatsby', author: 'F. Scott Fitz... | true |
828ff8579e0ec163b543640404af97e00b15b886 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/series/ee197d94560d433f930162573137f535.rb | UTF-8 | 295 | 3.453125 | 3 | [] | no_license | class Series
def initialize(s)
raise ArgumentError if s.delete('^0-9') != s
@s = s.split("").map{|x| x.to_i}
end
def slices(n)
result = []
raise ArgumentError if n>@s.size
(@s.size-n+1).times do |p|
result << @s[p..(p+n-1)]
end
return result
end
end
| true |
f3ce4de251e3ec17d95a2f87cb2be99b60cefa96 | Ruby | akumarsecurview/toolkit | /tasks/connectors/aqua/lib/aqua_helper.rb | UTF-8 | 3,418 | 2.53125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | # frozen_string_literal: true
require "json"
module Kenna
module Toolkit
module AquaHelper
def aqua_get_token(aqua_url, username, password)
print_debug "Getting Auth Token"
aqua_auth_api = "http://#{aqua_url}/api/v1/login"
# auth_headers = { "content-type" => "application/json",
... | true |
a57bd1e8140b5f256866284c74e371aa04863cb3 | Ruby | placidowang/learn-co-sandbox | /greeting.rb | UTF-8 | 286 | 3.65625 | 4 | [] | no_license | name = "Henry"
greeting = "sup #{name}"
def say_greeting_twice(greeting, name = "dude", question = "what's good?")
2.times {puts "#{greeting}, #{question}"}
end
say_greeting_twice("hey")
say_greeting_twice(greeting, name)
say_greeting_twice(greeting, "George", "how's it hanging?")
| true |
6d0638a2f0405a7cf6cd194b122b34040f33b14c | Ruby | devin-dominguez/aa_coursework | /minesweeper/player.rb | UTF-8 | 751 | 3.453125 | 3 | [] | no_license | class Player
def get_input_coords
formated_properly = false
# !while
until formated_properly
puts "Enter coordinates (row, col)"
coords = gets.chomp.split(',').take(2)
formated_properly = coords_properly_formated?(coords)
end
coords.map(&:to_i)
end
def get_input_action
... | true |
44185fff1cc48a2bf21f20dc544c868904f225ee | Ruby | jeremyevans/serverside | /spec/template_spec.rb | UTF-8 | 3,843 | 2.6875 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'spec_helper')
require 'stringio'
require 'fileutils'
class ServerSide::Template
def self.templates
@@templates
end
def self.reset
@@templates = {}
end
end
class IO
def self.write(fn, content)
File.open(fn, 'w') {|f| f << content}
end
end
include S... | true |
639c95e10854a6701cf6e989574d32ec6f4930e6 | Ruby | bmac110/gym_project | /models/booking.rb | UTF-8 | 1,941 | 3.203125 | 3 | [] | no_license | require_relative("../db/sql_runner.rb")
class Booking
attr_reader :id, :member_id, :gym_class_id
def initialize(options)
@id = options["id"].to_i() if options["id"]
@member_id = options["member_id"].to_i()
@gym_class_id = options["gym_class_id"].to_i()
end
def self.delete_all()
sql = "DELET... | true |
3b84842035a24b2707581a788a52997dbc127a22 | Ruby | bbuck/ruby-mud | /lib/models/non_playable_character.rb | UTF-8 | 3,074 | 2.984375 | 3 | [
"MIT"
] | permissive | class NonPlayableCharacter < ActiveRecord::Base
DEFAULT_SCRIPT = <<-SCRIPT.strip_heredoc
# @me {NonPlayableCharacter} the NPC the script is attached to
# @room {Room} the room the NPC is currently in
# Called when a player enters the same room as this NPC.
# param player {Player} the player who enter... | true |
3544a5018f968a2f077faf580d61d011b60f9b50 | Ruby | samsymons/RedditKit.rb | /lib/redditkit/thing.rb | UTF-8 | 409 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'redditkit/base'
module RedditKit
# A base class for objects which have both a kind and an identifier.
class Thing < RedditKit::Base
attr_reader :id
attr_reader :kind
def ==(other)
return false unless other.is_a?(Thing)
full_name == other.full_name
end
# Returns the obje... | true |
d997b382d829bb201e85dffb2b79e63e1873027b | Ruby | jacobswartzentruber/project_euler | /problem_39.rb | UTF-8 | 870 | 4.1875 | 4 | [] | no_license | #If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
#{20,48,52}, {24,45,51}, {30,40,50}
#For which value of p ≤ 1000, is the number of solutions maximised?
def integer_right_tri(limit)
result = 0 # Variable to store final perimeter... | true |
7fbcda9919643b019cc8e75142d74e9dc5d27cb0 | Ruby | alexey-lysiuk/macos-sdk | /MacOSX10.6.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/needle-1.3.0/lib/needle/pipeline/collection.rb | UTF-8 | 4,966 | 2.8125 | 3 | [] | no_license | #--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
# All rights reserved.
#
# This source file is distributed as part of the Needle dependency injection
# library for Ruby. This file (and the library as a whole) may be used only as
... | true |
8ca9cf5eeb790a033b5b67ef5b93ebf319af7c3b | Ruby | Huggebugge/Warlight-Tools | /centerpoints_uploader.rb | UTF-8 | 2,709 | 2.796875 | 3 | [] | no_license | # coding: utf-8
puts 'Starting up, be patient...'
puts ''
require 'pp'
require 'progressbar'
require 'savage'
require 'nokogiri'
require 'json'
require 'rest-client'
$LOAD_PATH.unshift File.dirname($0)+"/tools"
# from ./tools/
require 'extensions'
require 'bezier_curves'
require 'area_centroid'
require 'svg_territ... | true |
4c592dea940559ff27a156b303164b4991ab08b7 | Ruby | jasonthompson/act_to_xml | /bin/act-to-xml.rb | UTF-8 | 711 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
class HTMLActConverter
def initialize
@in_section = false
@in_subsection = false
@in_clause = false
@in_subclause = false
@in_paragraph = false
end
def process_section(node)
if not(@in_section)
@in_section = true
puts %Q{<akn:session>
#... | true |
729d2381d6573cdf34bbeec5d22da869dc8aff1b | Ruby | tobert/dcell | /lib/dcell/rpc.rb | UTF-8 | 1,731 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'weakref'
module DCell
EPOCH = Time.gm(2012) # All things begin in 2012
class RPC < Celluloid::SyncCall
def initialize(id, caller, method, arguments, block)
@id, @caller, @method, @arguments, @block = id, caller, method, arguments, block
end
# Custom marshaller for compatibility with Ce... | true |
67d7e3801b4158b0e048372a6515f85c80ed3069 | Ruby | gdestree/webscraper | /ticket_scraper.rb | UTF-8 | 1,844 | 3.734375 | 4 | [] | no_license | # Require gems for sending get request:HTTParty, parsing:Nokogiri, debugging:pry, write to csv:csv
require "HTTParty"
require "Nokogiri"
require "Pry"
require "csv"
# Methods for functionality: amount of pages to scrape(for until loop), page parsing, get content from parsed page
def pages_to_scrape
puts "How many p... | true |
eb042123602d7da5e22b8ad6a56be2725eba8873 | Ruby | moipetitnoel/programming-univbasics-nds-nds-to-insight-understand-lab-nyc-web-030920 | /lib/nds_explore.rb | UTF-8 | 645 | 3.046875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'directors_database'
# Call the method directors_database to retrieve the NDS
def pretty_print_nds(nds)
pp (directors_database)
# Change the code below to pretty print the nds with pp
nil
end
def print_first_directors_movie_titles
#pretty_print_nds(directors_... | true |
815bf73816d7b91bec779653446ffec8a165294b | Ruby | DianaLiao/ruby-oo-practice-anagram-detector | /lib/anagram.rb | UTF-8 | 349 | 3.640625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
class Anagram
attr_accessor :word
def initialize (word)
@word = word
end
def match (array)
goal = self.word.chars
matches = []
array.each do |test_word|
if test_word.chars.sort == goal.sort
matches << test_word
end
end... | true |
5ec0f9bc70b0a3d76642bb8d036cfb54c41e1bf9 | Ruby | seeker815/rd-tool | /lib/subcommands/projects/replicateFromInstance.rb | UTF-8 | 755 | 2.609375 | 3 | [] | no_license | class ReplicateFromInstance < Subcommand
attr_reader :rundeck_instance, :subcommand_action, :subcommand_full, :description, :cmd_example
def initialize(target=nil)
@rundeck_instance = target
@subcommand_action = "replicateFromInstance"
@subcommand_full = "projects #{subcommand_action}"
@cmd_examp... | true |
cc9b146d6e732371671977aa49fec713df7983c2 | Ruby | boddhisattva/learnings | /ruby/blocks_lambdas/ll_without_blks.rb | UTF-8 | 1,484 | 3.984375 | 4 | [] | no_license | class Node
attr_accessor :data, :next_node
end
class LinkList
attr_accessor :head
def initialize(val)
@head = get_node(val)
end
def get_node(val)
@node = Node.new
@node.data = val
@node.next_node = nil
@node
end
def add_in_end(val)
traverse_list ->{@current_pointer.next_node != ... | true |
7490691e4c8f3c53a488d7838111efb3cff80dd5 | Ruby | PlumpMath/DesignPatterns-425 | /chapter10/test3.rb | UTF-8 | 287 | 2.859375 | 3 | [] | no_license | require 'bankaccount3.rb'
require 'virtualaccountproxy3.rb'
account = BankAccount.new(100)
account.deposit(50)
account.withdraw(10)
puts "Final balance: #{account.balance}"
proxy = VirtualAccountProxy.new()
proxy.deposit(50)
proxy.withdraw(10)
puts "Final balance: #{proxy.balance}"
| true |
c1483b9a0e05b971b675faa75d039e72e097a1d6 | Ruby | adnikiforov/vt_api_test | /virus_total_cache_service.rb | UTF-8 | 3,501 | 2.609375 | 3 | [] | no_license | require 'json'
require 'rest-client'
class VirusTotalCacheService
# Хочу кое-что пояснить
# К внешнему API можно относиться с доверием, а можно без доверия
# Тут - первый случай: я верю, что API всегда вернет мне то, что обещает
# Иначе можно надолго застрять с валидацией JSON Schema
# Я задаю константы пря... | true |
74aa14d68ad92b3fb7cd02c2826b370fc5fd71c5 | Ruby | grandsoleil/ruby_thp | /exo_13.rb | UTF-8 | 141 | 3.3125 | 3 | [] | no_license | puts "Quelle est ton année de naissance ?"
annee = gets
compteur = annee.to_i
while compteur <= 2018
puts compteur.to_s
compteur += 1
end | true |
8ee63c8424ffa89306ebf9f25ce5e237015d8b67 | Ruby | Biming2/tic-tac-toe | /game.rb | UTF-8 | 1,407 | 3.578125 | 4 | [] | no_license | require_relative 'board'
require_relative 'player'
require_relative 'display'
# Game logic
class Game
include Display
attr_reader :board, :player_one, :player_two, :current_player, :state
def initialize
@board = Board.new
@player_one = create_player('first', 'X')
@player_two = create_player('second',... | true |
c9c8ba2ddf3854eca21458480b9c7c4bf43f844e | Ruby | kayama0fa/sandbox | /ruby/pleasant_ruby/03_sample_01.rb | UTF-8 | 416 | 3.90625 | 4 | [] | no_license | # coding: utf-8
#
# Chapter 03.
puts("# --------------------------------------------------------------------------")
puts("# Chapter03.1 コマンドラインからのデータ入力")
# $ ruby 03_sample.rb 1 2 3
# -> ["1", "2", "3"]
p(ARGV)
# 入力の数値(文字列型)を整数型に変換
nums = []
ARGV.each do |arg|
nums.push(arg.to_i)
# to_i : cast int
# to_f : ca... | true |
b8376b570c67d9c3d073029eb98319a740391b00 | Ruby | marceltoben/evandrix.github.com | /defcon/drivesploit/lib/msf/core/task_manager.rb | UTF-8 | 3,566 | 2.9375 | 3 | [
"BSD-3-Clause"
] | permissive | module Msf
###
#
# This class provides a task manager
#
###
class TaskManager
class Task
attr_accessor :timeout
attr_accessor :created
attr_accessor :completed
attr_accessor :status
attr_accessor :proc
attr_accessor :source
attr_accessor :exception
#
# Create a new task
#
def initialize(proc,... | true |
ea395869a104af2ec294c3e18ed7f82ba7bf2a69 | Ruby | jrodden1/ruby-objects-has-many-lab-online-web-ft-061019 | /lib/author.rb | UTF-8 | 400 | 3.28125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Author
attr_accessor :name, :posts
def initialize(name)
self.name = name
self.posts = []
end
def add_post(post_object)
post_object.author = self
self.posts << post_object
end
def add_post_by_title(title)
new_post = Post.new(title)
self.ad... | true |
5d8b2bcdfdf74fd8315f2d31454fad5bb77cb21c | Ruby | SteveGriffin/project_tracker | /app/models/project.rb | UTF-8 | 2,954 | 2.78125 | 3 | [] | no_license | class Project < ActiveRecord::Base
has_many :tasks, dependent: :destroy
has_many :collaborators, dependent: :destroy
has_many :users, through: :collaborators
has_many :sessions, through: :tasks, dependent: :destroy
belongs_to :user
#get active session for project
#returns a hash of session_id and task_i... | true |
46c301d89b27ba1616a26590099e0d6e7ae371b2 | Ruby | mikong/rails-hotels-data-merge | /app/models/hotel_builder.rb | UTF-8 | 2,132 | 2.875 | 3 | [] | no_license | class HotelBuilder
PRIORITIES = {
id: [:A, :B, :C],
destination_id: [:A, :B, :C],
name: [:C, :B, :A],
# location: special logic
description: [:B, :A],
# amenities: special logic
# images: special logic
booking_conditions: [:B],
}
LOCATION_PRIORITIES = {
lat: [:C, :A, :B],... | true |
b627a18c53be7ba639e6d1b12c8d3ea90b3a12c9 | Ruby | meltek13/exercice_ruby | /exo4.rb | UTF-8 | 128 | 3.25 | 3 | [] | no_license | puts "donne moi ton année de naissance"
print " ton année >"
year = gets.chomp.to_i
puts "tu auras 100 ans en #{year + 100} " | true |
d9a359eb458e18633ee3816b9abd5363ded66d1f | Ruby | alihass3/ruby-fundamentals-1- | /excercise3.rb | UTF-8 | 228 | 3.953125 | 4 | [] | no_license | puts "What is your name?"
user_name=gets.chomp
puts "Hello, #{user_name}"
puts "Age?"
user_age=gets.chomp
puts "Hey #{user_name},you were born in #{2017-(user_age.to_i)}"
# lets do a bit of .times
3.times do
puts "Print"
end
| true |
b09d3e0a9f28bbcd7dbcb741f82b4f47d2db0fb6 | Ruby | Neurogami/rhesus | /Rakefile | UTF-8 | 3,490 | 2.578125 | 3 | [
"MIT"
] | permissive | # Look in the tasks/setup.rb file for the various options that can be
# configured in this Rakefile. The .rake files in the tasks directory
# are where the options are used.
begin
require 'bones'
rescue LoadError
abort '### Please install the "bones" gem ###'
end
ensure_in_path 'lib'
require 'version'
task :defa... | true |
6ca2ca6e364ebfdf9e7d0270c1bd25adb308e5de | Ruby | ikemonn/AOJ | /ALDS1/sort1/stability.rb | UTF-8 | 1,055 | 3.578125 | 4 | [] | no_license | gets;
$suits = {}
cards = gets.split.map do |card|
suit = card[0]
num = card[1]
$suits[num] = [] unless $suits.include? num
$suits[num] << suit
[suit, num]
end
def bubble_sort(a)
cnt = 0
0.upto(a.size - 1) do |i|
(a.size - 1).downto(i + 1) do |j|
if a[j][1] < a[j - 1][1]
a[j], a[j - 1] ... | true |
c7184084cdcb226ee7ca25d2ae74e2203a7758ec | Ruby | muellerj/weddinghelper | /lib/regexp_sandbox.rb | UTF-8 | 924 | 2.875 | 3 | [] | no_license | class SyntaxChecker
def initialize(code)
@code = code
@vars = []
end
def valid?
@code.lines.all? { |line| line_valid?(line) }
end
def line_valid?(line)
if %r{(@?\w+) = (?:\+?-?\d+(?:\.\d{2})?|#{@vars.join("|")})}.match(line)
@vars << line.scan(%r{(@?\w+) =}).flatten.first
return... | true |
40d56c284fb45b0cb64f29615b0b8fe5ffda69fb | Ruby | inbeom/hightops | /lib/hightops/testing.rb | UTF-8 | 2,068 | 2.53125 | 3 | [
"MIT"
] | permissive | module Hightops
module Testing
class Exchange
def self.index
@index ||= {}
end
def self.for(options = {})
name = options[:name] || Hightops::Publisher.new(options).send(:exchange_naming)
index[name] ||= new(name)
end
def initialize(name)
@name = nam... | true |
61619cfb63a5a08cda0374dd1e337f3c53374230 | Ruby | cynthiacd/quadratic-rails-api | /test/models/trinomial_test.rb | UTF-8 | 796 | 2.703125 | 3 | [] | no_license | require "test_helper"
describe Trinomial do
let(:problem) { Trinomial.new }
describe 'initialize' do
it "creates two random numbers" do
# p problem
problem.must_be_instance_of Trinomial
problem.root1.must_be_instance_of Integer
problem.root2.must_be_instance_of Integer
end
end
... | true |
0b12e18fdb58b792db793dc086b344721412336e | Ruby | feiwangsioc/ruby-coding | /recursion.rb | UTF-8 | 415 | 3.3125 | 3 | [] | no_license | def fact(n)
if n == 1
return 1
else
return n*fact(n-1)
end
end
def multiple(n)
if n == 1
return 1
else
return (n + multiple(n-1))
end
end
def reverse(str)
if str.size <= 1
return true
end
if str[0] != str[-1]
return false
end
return reverse(str[1..-2])
end
def count(a, kind)
if ... | true |
fde0abfa67444b33b35088efa13c123d9db0cc97 | Ruby | EGagola/JSON_Intro | /JSONClass/json_weather.rb | UTF-8 | 934 | 3 | 3 | [] | no_license | require 'json'
class ParseWeather
attr_accessor :json_file
def initialize json_file
@json_file = JSON.parse(File.read(json_file))
end
def find_section section_name
json_file[section_name]
end
def find_key_type key_name , type
correct_type = 0
json_file[key_name].keys.each do |key|
... | true |
2d2096be15df29b2865f6048412b1ccec09c2970 | Ruby | beesasoh/mrg | /app/models/game.rb | UTF-8 | 1,634 | 2.640625 | 3 | [] | no_license | class Game < ActiveRecord::Base
attr_accessible :score , :subject_id , :user_id , :course_id
belongs_to :user
belongs_to :course
belongs_to :subject
validates_presence_of :subject_id, :user_id , :course_id , :score
def self.rankings lim=0
return order("sum_score desc").group("games.user_id").sum(:sco... | true |
5ee890840088050bef2fcfd961a9cbe517d94241 | Ruby | equivalent/virus_scan_daemon | /script.rb | UTF-8 | 1,535 | 2.59375 | 3 | [] | no_license | FORCE_CLEAN = false # if true skip virus scan and mark as clean
require 'virus_scan_service'
require 'logger'
require 'yaml'
require 'pathname'
all_secrets = YAML.load(File.read('secrets.yml'))
logger = Logger.new('virus_scan_service.log')
logger.level = Logger::ERROR
logger.level = Logger::INFO if File.exist?('inf... | true |
38389b7101c3f4e39ebfe250500073207d66c0c9 | Ruby | NicciTheNomad/Ruby-Coding-Dojo-Class | /RubyAssignments/Ruby_OOP/Dragon/dragon.rb | UTF-8 | 367 | 3.3125 | 3 | [] | no_license | require_relative 'mammal'
class Dragon < Mammal
def initialize
num=1
@health = 170
self
end
def fly(num)
@health -=10*num
self
end
def eat_ppl(num)
@health +=20*num
self
end
def attack_town(num)
@health -=50*num
self
end
end
dragon1 = Dragon.new.fl... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.