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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
53bbdccda0768d79796e972d3012d4de3ea80798 | Ruby | maksimgm/ruby_hw_1 | /reverse_a_string.rb | UTF-8 | 215 | 3.515625 | 4 | [] | no_license | require "pry"
puts "Enter a string"
str = gets.chomp
# i = str.length
i = str.length/2.floor
# while i>0
# reverse_str + str[-1]
# i-=1
# end
i.times do |x|
str[x], str[-x-1] = str[-x-1], str[x]
end
puts str | true |
4881802ae2ad23100268ad1d7cfe3c261de90fbe | Ruby | SvitlanaLana/kottans_homework5 | /demoone/app/services/helper_services.rb | UTF-8 | 809 | 2.71875 | 3 | [] | no_license | class HelperServices
KELVIN = 273.15
def initialize
end
def invoke
conn = Faraday.new(:url => 'http://api.openweathermap.org') do |faraday|
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
r... | true |
f886c72effcc95a43d369443dea6a7984de12c99 | Ruby | briankim419/Codility | /Lesson4/exam.rb | UTF-8 | 2,533 | 3.953125 | 4 | [] | no_license | require 'pry'
class Leaderboard
attr_accessor :leaderboard
def initialize()
@leaderboard = []
end
#adds score to selected players scores and returns the average of all scores
def add_score(player_id, score)
sum = 0.00
included = false
@leaderboard.each { |player| included = true if player.id == ... | true |
edaa46dfea66d1fbb6c1ee4a8a5757d49b23fb00 | Ruby | kristianmandrup/cantango-model | /lib/cantango/model/scope.rb | UTF-8 | 1,684 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module CanTango::Model
module Scope
def self.included(base)
base.send :include, CanTango::Api::User::Ability
base.extend CanTango::Api::User::Ability
base.extend ClassMethods
end
def self.rest_actions
[:read, :access, :write, :manage, :edit, :create, :delete]
end
class Al... | true |
6b39030af6edd0c09d0c1a6ff7cc4b7a31283843 | Ruby | lolptdr/carstats | /car_stats.rb | UTF-8 | 1,375 | 3.3125 | 3 | [] | no_license | class CarStats
# def self.calc_top_color(cars)
# colors = cars.map { |car| car.color }
# histogram = {}
# colors.each do |c|
# if histogram[c].nil?
# histogram[c] = 1
# else
# histogram[c] += 1
# end
# end
# biggest = histogram.max_by { |color, count| count }
# biggest.first
... | true |
268125fc8a0aa212bbd7791e57e45cdc96daf98d | Ruby | Kacper3331/Foosball | /app/models/match.rb | UTF-8 | 1,030 | 2.546875 | 3 | [] | no_license | class Match < ActiveRecord::Base
has_many :players
validates :first_player_score,
numericality: true,
presence: true
validates :second_player_score,
numericality: true,
presence: true
validates :date,
presence: true
def self.players_ids(player_ids, match)
match.first_player_id = pl... | true |
d0833f15f7019d43d5cc3d060f8f942ecd7d3bb7 | Ruby | Pablo-rgb-cou/coinmux | /lib/coinmux/assert_keys.rb | UTF-8 | 463 | 2.734375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | class Hash
def assert_keys!(options)
required = options[:required] || []
required = [required] unless required.is_a?(Array)
optional = options[:optional] || []
optional = [optional] unless optional.is_a?(Array)
unknown = keys - (required + optional)
raise "Unknown keys: #{unknown.join(', ')}"... | true |
07de70855001be60823e9a962835ef4d363287a9 | Ruby | genjay/mjhr3 | /test/models/employee_test.rb | UTF-8 | 611 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class EmployeeTest < ActiveSupport::TestCase
test "Some columns must has value " do
h_ok = {ou_id: 11,uid:'001',name:'001'}
h_ng = {arrive_date: nil}
a = Employee.create(h_ok.merge(h_ng))
assert_equal h_ng.size, a.errors.size
end
test "In the some ou_id cann't has two man ... | true |
a274679f63846dbfdc9a04f28fa35259826e57a7 | Ruby | JavierGarJim/ironhack | /sinatra/iron_blog/server.rb | UTF-8 | 1,813 | 2.921875 | 3 | [] | no_license |
require "sinatra"
require "sinatra/reloader" if development?
require "pry"
require_relative("lib/post.rb")
require_relative("lib/sponsoredPost.rb")
require_relative("lib/blog.rb")
blog = Blog.new
blog.add_post(Post.new("Ironhack Prework", Time.new, "Starting from zero", "Technology", "Javier"))
blog.add_post(Post.ne... | true |
c7278426d1c121e6a65ca8c9ed07755859125d58 | Ruby | ewoutvonk/edploy | /lib/edployscripts/archive.rb | UTF-8 | 691 | 2.65625 | 3 | [
"MIT"
] | permissive | module Edploy
class Archive
class << self
def extract(archive, target_dir, options = {})
cmds = []
case archive_type(archive)
when :tgz then cmds << "tar -C #{target_dir} -z -x -f #{archive}"
when :tbz2 then cmds << "tar -C #{target_dir} -j -x -f #{archive}"
when :tar then cmds << "t... | true |
acc23cada79c7668226c5681fbf7d6874f469c95 | Ruby | jordansissel/experiments | /randomcode/bsearch.rb | UTF-8 | 571 | 3.328125 | 3 | [] | no_license | #!/usr/bin/ruby
#
# Example of using binary search on a text file sorted by the 2nd field in the
# file with format:
# value1 key1
# value2 key2
# etc...
input = ARGV[0]
query = ARGV[1]
size = File.stat(input).size
pivot = (size / 2).floor
cut = pivot;
File.open(input) do |f|
while (cut > 0)
f.seek(pivot, IO::... | true |
cf79b3537ac19b501b556d2851f6bfa46b42afab | Ruby | yuki-uchida/Competitive_programming | /AtcoderBeginnerContest/081/a.rb | UTF-8 | 131 | 3.15625 | 3 | [] | no_license | numbers = gets.chomp.split("").map(&:to_i)
count = 0
numbers.each do |number|
if number == 1
count += 1
end
end
puts count
| true |
0602a8b4544718a14a4f6ee086057bcfd66f4c57 | Ruby | sleighter/postgres_to_redshift | /lib/postgres_to_redshift.rb | UTF-8 | 8,031 | 2.5625 | 3 | [
"MIT"
] | permissive | require "postgres_to_redshift/version"
require 'pg'
require 'uri'
require 'aws-sdk'
require 'zlib'
require 'stringio'
require "postgres_to_redshift/table"
require "postgres_to_redshift/column"
class PostgresToRedshift
PART_SIZE = 100000
class << self
attr_accessor :source_uri, :target_uri
end
attr_reade... | true |
6d02317f8035e6b27be57c3f278c3d61cbac7a99 | Ruby | fx-kirin/ruby_backtest | /test/test_history_center.rb | UTF-8 | 3,048 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | require "time"
require_relative "test_master"
require_relative "../lib/price_feeds/clibrary/history_center"
class TestHistoryCenter < TestMaster
def setup
@center = HistoryCenter.new
end
def test_load
symbol = :USDJPY60test
assert_raises(HistoryCenter::HistoryFileNotExist, "Must Raise HistoryFile... | true |
25f3076a9070d8204df4a3eab452779ee27023e4 | Ruby | thillerson/learn_ruby | /15_orange_tree/app.rb | UTF-8 | 1,323 | 3.1875 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
require 'orange_tree'
$orange_tree = OrangeTree.new(0,6)
get '/' do
"<a href='/orange_tree'>Check on orange tree</a>"
end
get '/orange_tree' do
if @params[:one_year_passes] == 'true'
$orange_tree.one_year_passes
end
if @params[:eat_orange]
$orange_tree.eat_oran... | true |
2e3baf5482c1678f83ad08efede7563629850c1b | Ruby | Alyssampratt/kwk-l1-hash-iteration-mini-lab-kwk-students-l1-stl-061818 | /more_arrays.rb | UTF-8 | 374 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | farmer_tasks = ["milk the cow", "churn the butter", "drive the tractor","peel potatoes", "plant the corn"]
farmer_tasks.each do |key|
puts "im so busy! I need to #{key}"
end
some_numbers = [2,52,19,45,1000]
some_numbers.each do |key|
puts key + 18
end
presidents = ["george washington","john adams","thomas jeffers... | true |
8d995e9ff0ba728efb1c770bce7407bb3af45202 | Ruby | andrewjh271/tic_tac_toe | /lib/player.rb | UTF-8 | 2,003 | 3.78125 | 4 | [] | no_license | class Player
attr_accessor :name, :marker
def initialize(name, marker)
@name = name
@marker = marker
end
end
class Human < Player
def move(board)
print "Enter coordinates for #{name}'s move: "
coordinates = gets.chomp
until(/[abc]/.match(coordinates[0]) && /[123]/.match(coordinates[1]))
... | true |
22a5eb4ff984d53207841c8d8dceea0b2316a297 | Ruby | lizk0189/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 1,629 | 4.34375 | 4 | [] | no_license | =begin
- Create a fake name that:
1. Asks the user for their first and last name.
2. Swaps the first and last name
3. Changes all of the vowels (a, e, i, o, or u) to the next vowel in 'aeiou'.
**Watch for edge cases.
4. Changes all of the consonants to the next consonant.
**Watch for edge cases.
5. Create empty hash... | true |
91d76a8e95c3181de143f979e237419c7f654a0d | Ruby | ckccameron/pantry_2005 | /lib/cook_book.rb | UTF-8 | 1,125 | 3.140625 | 3 | [] | no_license | class CookBook
attr_reader :recipes,
:date
def initialize
@recipes = []
# @date = grab_date
@date = Date.today.strftime("%m-%d-%Y")
end
# def grab_date
# date = Time.now.to_s
# date = date[0...10].split("-")
# "#{date[1]}-#{date[2]}-#{date[0]}"
# end
def add_recipe(r... | true |
fdfecc7268aaf43468b50ed6e037d44301e56f98 | Ruby | FreeApophis/taskautomation | /Redmine/lib/tasks/taskautomation.rb | UTF-8 | 7,552 | 2.59375 | 3 | [] | no_license | cat public/pirates.rake
#*******************************************
#
# Flexible automatic transitions for redmine
#
# (C) Thomas Bruderer, Piratenpartei Schweiz
#
# configuration is below
#
#*******************************************
namespace :pirates do
class Rules
attr_accessor :name, :tracker, :status, :a... | true |
012f302e0ac74632ef1a9dbcc1af60384d05d0a8 | Ruby | yamilethmedina/opendataday2017 | /app/models/tide_prediction.rb | UTF-8 | 580 | 2.84375 | 3 | [] | no_license | class TidePrediction
def self.events
doc = Nokogiri::HTML(open("http://miamistories.net/susan/8723178_annual.xml"))
array = []
doc.xpath("//item").each do |i|
date = i.css('date').text
time = i.css('time').text
date_time = format_date(date, time)
pred_in_ft = i.css('pred_in_ft').t... | true |
02ffe80c557159753a34084196ef62fdd893a930 | Ruby | bjnord/shepherd_events | /spec/lib/recurrence_spec.rb | UTF-8 | 2,995 | 2.9375 | 3 | [] | no_license | require 'spec_helper'
describe Recurrence do
describe '::new' do
pending 'should not alter the string passed into the constructor'
context 'with daily forever recurrence' do
subject { Recurrence.new('Every day and is an *ALL DAY* event') }
its(:rrule) { should == 'FREQ=DAILY' }
end
cont... | true |
c7bae7ee48bc083b6064ddfa9b00a7cda48dbec4 | Ruby | phillydorn/ProgrammingChallenge | /line_of_credit_test.rb | UTF-8 | 962 | 3.28125 | 3 | [] | no_license | require 'date'
class Credit
def initialize (apr, limit)
@apr = apr/100.00
@limit = limit
@balance = 0
@startDate = Date.today
@lastTrans = @startDate
@principal = Hash.new
end
def withdraw (amt)
if amt > @limit
puts "Insufficient funds"
else
daysSinceTrans = Date.toda... | true |
839a02da49fc4cea9f761068471b4ae3813af764 | Ruby | creamstew/atcoder | /abc/168/d.rb | UTF-8 | 314 | 2.984375 | 3 | [] | no_license | n,m = gets.split.map(&:to_i)
list = Array.new(n+1) { [] }
m.times do
a,b = gets.split.map(&:to_i)
list[b] << a
list[a] << b
end
c = Array.new(n + 1)
c[1] = 1
que = []
que << 1
while que.size > 0
e = que.shift
list[e].each do |i|
next if c[i]
c[i] = e
que << i
end
end
puts "Yes", c[2..-1] | true |
8eda1b9a413038e43ec5edb465f2a259e12237d8 | Ruby | bykasya/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 400 | 3.5 | 4 | [] | no_license | def add(a,b)
a+b
end
def subtract(x,y)
x-y
end
def sum(x)
x.sum
end
def multiply(arr)
a=1
arr.each do |i|
a=a*i
end
a
end
def power(x,y)
x**y
end
def factorial(y)
if y==0
return 1
else
b=1
for i in (1..y) do
b=b*i
... | true |
7bd494bcc5707c8a2e235547b6b167690e94ca99 | Ruby | matyikriszta/cash_register | /spec/register_spec.rb | UTF-8 | 2,511 | 2.921875 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../register.rb'
require 'pry-byebug'
describe Register do
let(:register) { Register.new({2 => 4, 1 => 1}) }
describe '.new' do
it 'creates a new register' do
expect(register).to_not eql nil
end
end
describe '#denominations' do
it 'should ret... | true |
b0806f991aa7492a63176b0f7dd466c8d5e06156 | Ruby | rsbarbo/night_writer_draft | /test/night_writer_test.rb | UTF-8 | 1,173 | 2.78125 | 3 | [] | no_license | require_relative '../lib/night_writer'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
class NightWriterTest < Minitest::Test
def setup
@file = NightWriter.new
end
def test_convert_one_letter_to_braille
assert_equal "0.\n00\n..\n", @file.encode_to_braille("h")
end
def test_conver... | true |
20d0f6d49fdd94d4463bdcc02d13a323d38ea035 | Ruby | hamannp/web_crawler | /app/models/main_page.rb | UTF-8 | 492 | 2.59375 | 3 | [] | no_license | require 'mechanize'
class MainPage
def perform(url='https://raleigh.craigslist.org/search/apa')
@url = url
@param_slices = Navigation.new(Mechanize.new.get(url)).call
listing_range_urls.each do |range_url|
ListingRange.new.perform(Mechanize.name, ListingMaker.name, range_url)
end
en... | true |
248567c85b90534f8148a7428554c3557558d6a3 | Ruby | oorion/chess | /board_spec.rb | UTF-8 | 770 | 3.1875 | 3 | [] | no_license | require_relative 'board'
describe Board do
before do
@board = Board.new
end
it "has a pawn in the second row first column at the beginning of the game" do
expect(@board.find_item(1, 0)).to be_instance_of(Pawn)
end
it "has a pawn in the last column of the second row at the beginning of the game" do
... | true |
c2f72ded04dde70d133704004da69aaa73674b18 | Ruby | dnguye2/hotel | /lib/date_range.rb | UTF-8 | 1,331 | 3.3125 | 3 | [] | no_license | require_relative 'date_range'
module Hotel
class DateRange
attr_accessor :start_date, :end_date
def initialize(start_date, end_date)
difference = end_date - start_date
if difference == 0
raise ArgumentError, "Cannot have 0 length date range"
elsif difference < 0
rais... | true |
4d6f0556e1b79f5880c523a2b9ce72dd31c8993b | Ruby | josiekeller/BEWD_homework | /apartment_objects_classwork/lib/building.rb | UTF-8 | 554 | 3.203125 | 3 | [] | no_license | #Building Class
class Building
attr_accessor :building_name, :building_address, :apartments
def initialize(building_name, building_address)
@building_name = building_name
@building_address = building_address
@apartments = []
end
def view_apartments
puts "-----------#{building_name}-----------"
@apartmen... | true |
5683d08bfe26f9cecee7e7a976005ff5e8d22fcb | Ruby | IanWhitney/redis_backed_model | /lib/redis_backed_model/commands.rb | UTF-8 | 859 | 2.703125 | 3 | [
"MIT"
] | permissive | module RedisBackedModel
class Commands < Array
def initialize(obj)
@obj = obj
self << id_set_command
@obj.instance_variables.each do | var |
build_command_for_variable(var)
end
self
end
private
def id_set_command
"sadd|#{@obj.model_name_for... | true |
61c9d1bc83d08e28b19d7579fd3e7e5bf7771df5 | Ruby | austinandrade/mastermind | /lib/player_guess_matcher.rb | UTF-8 | 1,836 | 3.328125 | 3 | [] | no_license | class PlayerGuessMatcher
attr_reader :winning_code
def initialize(player_guess, winning_code)
@player_guess = player_guess
@winning_code = winning_code
@number_of_correct_colors = 0
# @new_end_time = end_time / (24 * 60 * 60.0)
# @new_start_time = start_time / (24 * 60 * 60.0)
end
# def set_... | true |
dfb4d03cdeec67b939a4a0ed70a4d1da8a78a803 | Ruby | ht0919/ProgrammingExercises | /D/ruby/d077.rb | UTF-8 | 103 | 3.09375 | 3 | [] | no_license | a = gets.chomp.split(" ")
b = a.map(&:to_i)
c = b[0] * b[1]
if c < 10000
puts c
else
puts "NG"
end
| true |
865dce506a8fd21ff7c3b111004177740b0d0563 | Ruby | gsisson/ruby_lib | /lib/stack.rb | UTF-8 | 1,726 | 3 | 3 | [] | no_license | # some helper methods to do some things in a friendlier way
module Stack
# usage example:
# require 'stack'
# puts Stack.frames(' => ')
# output:
# " => ~/somedir/somepath/some_code_file.rb:16:in `method_1'"
# " => ~/somedir/somepath/some_code_file.rb:19:in `method_2'"
# " => ~/somedir/somepath... | true |
29b13a685b1a6736777bf961ba193a32c5323090 | Ruby | rsmoke/ldap_lookup | /lib/ldap_lookup.rb | UTF-8 | 7,114 | 2.953125 | 3 | [
"MIT"
] | permissive | require_relative "helpers/configuration"
module LdapLookup
require "net/ldap"
extend Configuration
define_setting :host
define_setting :port, "389"
define_setting :base
define_setting :dept_attribute
define_setting :group_attribute
# this was developed using guidence from this gist:
# https://gist... | true |
9850717624b35cb718ea4e6ea91c901b45e1b2b9 | Ruby | widua33/game-life | /spec/models/cell_spec.rb | UTF-8 | 580 | 2.78125 | 3 | [] | no_license | require './models/cell'
describe Cell do
let(:cell) { Cell.new(1,3) }
describe 'initialize' do
it 'have x attribute' do
expect(cell.x).to eq 1
end
it 'have y attribute' do
expect(cell.y).to eq 3
end
it 'have living attribute' do
expect(cell.living).to eq false
end
en... | true |
9f74b7c16ea66beeb1136503bb60e8ec756e9904 | Ruby | CruGlobal/staff-conf-onsite | /test/models/import/person_test.rb | UTF-8 | 2,309 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class Import::PersonTest < ModelTestCase
setup do
@import = OpenStruct.new(Import::Person::SPREADSHEET_TITLES.dup.transform_values! {|_| nil })
@import.allergy ='Peanuts'
@import.parent_agree ='Agree'
end
test '#primary_family_member?' do
assert Import::Person.new(person_t... | true |
ddb17a0f5ce2e1e9dcaeaf6ee3e993468dc559f1 | Ruby | ivir/MI-RUB | /homeworks/1/tdbfs.rb | UTF-8 | 5,646 | 3.046875 | 3 | [] | no_license | NEW = 0
FRESH = 1
OPEN = 2
class Node
attr_accessor :id
attr_reader :nodes
attr_accessor :status
def initialize(id)
@id = id.to_i
@nodes = Array.new
@status = FRESH
end
def connection(node)
@nodes << node #vlozi do pole referenci
# jeste je nutne seradit. Jinak DFS hazi jiny vys... | true |
4ac7620bcc4c76ce591fa2fd057efbea7dafa883 | Ruby | j-pinto/chess | /lib/moves/move_type_selector.rb | UTF-8 | 1,872 | 3.078125 | 3 | [] | no_license | class MoveTypeSelector
attr_reader :start, :finish, :current_player, :piece, :output
def initialize(turn)
@board = turn.board
@start = turn.input.start
@finish = turn.input.finish
@current_player = turn.current_player
@piece = @board.get_piece(@start)
@output = nil
end
def set_output
... | true |
3fd6ce629995fb36a1b06732b2f4f9f9d7b80721 | Ruby | mrinp/omnicalc_params | /app/controllers/calculations_controller.rb | UTF-8 | 2,052 | 2.515625 | 3 | [] | no_license | class CalculationsController <ApplicationController
def flex_square
#Parameters: {"number"=>"5"}
@user_input = params["number"].to_f #always called params
@square = @user_input**2
render ("calculations/flex_square.html.erb")
end
def flex_square_root
#Parameters: {"number"=>"5"}
@user_inp... | true |
ac3e74aed16173edd7d11b85f44d2ad55255328a | Ruby | coingecko/moolah-ruby | /lib/moolah/client.rb | UTF-8 | 2,266 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'moolah/version'
require 'faraday'
require 'json'
module Moolah
class Client
CREATE_TRANSACTION_ACTION = "/v2/private/merchant/create"
QUERY_TRANSACTION_ACTION = "/v2/private/merchant/status"
def initialize
# Check for API key
raise ArgumentError, "API Key is not set!" unless Moolah.... | true |
5715b3bbfd35b7c8997616f8aeaf57b734ba850b | Ruby | threez/rlisp | /lib/rlisp/interpreter.rb | UTF-8 | 3,781 | 3.015625 | 3 | [] | no_license | require "parser"
require "helper"
require "macros"
module Lisp
class VariableScope
attr_accessor :parent
def initialize(parent = nil)
@variables = {}
@parent_scope = parent
end
def []=(variable_name, value)
@variables[variable_name] = value
end
def [](variable... | true |
d199612b16ac6e8ce5403baa404294ba411f9f56 | Ruby | cielavenir/procon | /yukicoder/tyama_yukicoder296.rb | UTF-8 | 73 | 2.671875 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
a,b,c,d=gets.split.map &:to_i
c+=~-a*d
p (c/60+b)%24,c%60 | true |
2399796a70df229864b08bf7b7a4628c95b35071 | Ruby | intomyam/twitty | /twitty/tweet.rb | UTF-8 | 1,005 | 2.609375 | 3 | [
"MIT"
] | permissive | #Copyright (c) 2014 silva(http://silva.vc/)
#Released under the MIT license
#http://opensource.org/licenses/mit-license.php
class Twitty
class Tweet
def initialize(content)
@content = content
end
def self.twitty=(twitty)
@@twitty = twitty
end
def self.find(id, query = {})
quer... | true |
71c66ba3d72e46ec58a77e9eaf4a57899c0899b1 | Ruby | Alipongoy/ruby_projects | /price_comparer/price_comparer.rb | UTF-8 | 2,989 | 3.4375 | 3 | [] | no_license | require 'net/http'
class Website
attr_accessor :item_array
# This initializes @website if URI is provided.
# PARAMETERS: STRING uri
# RETURNS: N/A
def initialize(uri = "")
@parsed_website = String.new()
if uri != ""
self.uri_to_string(uri)
else
return
end
end
# This writes a string website to a... | true |
0f225dbd7f0a8ecc1893a67e52900c2cc39df44a | Ruby | ycremar/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,618 | 3.875 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
s = 0
arr.each{ |e|
s += e
}
return s
end
def max_2_sum arr
m1, m2 = nil, nil
arr.each{ |e|
m2 = e if not m2 or e > m2
m1, m2 = m2, m1 if not m1 or m2 > m1
}
m1 = 0 if not m1
m2 = 0 if not m2
return m1+m2
en... | true |
9a274e8d125902eba8e6d133c729a6d775f6cd9f | Ruby | gmccreight/mdpg | /lib/mdpg/services/user_recent_pages.rb | UTF-8 | 1,301 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
class UserRecentPages < Struct.new(:user)
MAX_HISTORY = 250
def add_to_recent_created_pages_list(page)
user.recent_created_page_ids =
get_list_with_page_added(page, user.recent_created_page_ids)
user.save
end
def add_to_recent_edited_pages_list(page)
user.recen... | true |
29c288b42adc8632d635a9739c146e0959e00803 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/spectral_cluster/recluster/cluster_5/13695/26899.rb | UTF-8 | 1,206 | 3.578125 | 4 | [] | no_license | #words_dc = words.map(&:downcase)
def combine_anagrams(words)
found = 0
words_added = Array.new
words_group = Array.new
something_added = false
group_id = 0;
words.each{ |word|
permut = word.downcase.chars.to_a.permutation.map &:join
permutation_group = Array.new
element... | true |
0e7eaf8d31de75cb5ee32f1e9c20868081b156d6 | Ruby | bcimbali/Learn-Ruby-The-Hard-Way | /snow_game.rb | UTF-8 | 5,217 | 3.75 | 4 | [] | no_license | # Defines a method to do the Tunnel room
def tunnel_room
puts """
You tunnel through the snow for an hour.
You hit a hard surface and clear the snow off it.
It turns out to be a door made of ice.
What do you do? \n \n* open door \n* turn around
"""
# Prints a prompt
print "> "
choice = $stdin.gets.chomp
if... | true |
501bec6c837932fb70760b51a18d417f3cc203e3 | Ruby | nyxcloud/nyxdevel | /build | UTF-8 | 864 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
begin
OptionParser.new do |parser|
parser.banner = "Usage: ci/build.rb [OPTIONS] [TARGET]"
parser.on("-h", "--help", "Print help") do
puts parser
exit 1
end
end.parse!
rescue RuntimeError => err
STDERR.puts err
exit 1
end
make_target =
cas... | true |
016a2f30f1affa6a8168a94439aaa97cde77a0d5 | Ruby | rustydigg918/vscode-git | /return.rb | UTF-8 | 126 | 2.671875 | 3 | [] | no_license | puts "===" "=== === === === === ==="
def cube(num)
return num*num*num, 25
"vina is the real pani"
end
puts cube (6)[1] | true |
74a28adf423b53cddd7349d81e82734813ad78e8 | Ruby | alexaitken/synapse | /lib/synapse/command/mapping.rb | UTF-8 | 2,134 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | module Synapse
module Command
# Mixin for a command handler that uses the mapping DSL
#
# @example
# class OrderBookCommandHandler
# include MappingCommandHandler
#
# map_command CreateOrderbook do |command|
# # ...
# end
#
# map_command PlaceBuyOrde... | true |
a80b18d93ab8ef4f70b54b0bbb0f809bea7cfadb | Ruby | Jay-Aye/ruby-restaurant-challenge | /demo_restaurant_menu.rb | UTF-8 | 4,329 | 3.75 | 4 | [] | no_license | require 'terminal-table'
class MenuItem
def initialize(name, price, description, menu_section)
@name = name
@price = price
@description = description
@menu_section = menu_section
end
attr_accessor :name, :price, :description, :menu_section, :options
end
class Menu
def display_items(menu_sect... | true |
ca362abc4569fc7636afb3adfa360e6931442304 | Ruby | jedediah/MathStuff | /proc.rb | UTF-8 | 1,021 | 2.875 | 3 | [] | no_license |
class Proc
include Latex::Inspectable
class << self
def predicate(p=nil, &b)
p ||= b #TODO
p.nil? and raise "Predicate expected"
p
end
def unary(f=nil, &b)
f ||= b
f.nil? and raise "Unary function expected"
f
... | true |
219d7d07590ef790504a879f967cce7bb5b21389 | Ruby | mnbi/rus3 | /lib/rus3/char.rb | UTF-8 | 2,295 | 3.375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Rus3
class Char
include Comparable
class << self
def alphabetic?(char)
raise CharRequiredError, char unless char.instance_of?(Char)
/[A-Za-z]/ === char.to_s
end
def numeric?(char)
raise CharRequiredError, char unless char.inst... | true |
afcaec4774a99998a0687cf9c82dde947c384994 | Ruby | JumpstartLab/problem_solving | /solutions/horne_ben/exercise_3/exercise_3_spec.rb | UTF-8 | 475 | 3.234375 | 3 | [] | no_license | require './exercise_3_solution'
describe String do
it 'replaces the space with %20 in a simple string' do
a = ' '
expect(a.substitute).to eq('%20')
end
it 'replaces the space at beggining or end with %20' do
a = 'asdf '
b = ' asdf'
expect(a.substitute).to eq('asdf%20')
expect(b.substitut... | true |
1b519f70e7e1b828058b05cf8be1d79f7f3c5881 | Ruby | rob-clayton/parser | /spec/lib/parser/logs_presenter_spec.rb | UTF-8 | 4,268 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../spec_helper'
require 'pry'
RSpec.describe LogsPresenter do
describe '#sort_by_count' do
let(:sorted_by_count) do
[
{ url: '/c', count: 60, unique_count: 2, addresses: Set['1.1.1.1'] },
{ url: '/a', count: 50, unique_count: 8, addresses... | true |
c3bac975db87a89fd653cd8c7422b5c6f65fc79a | Ruby | SRCH2/srch2-ngn | /test/wrapper/system_tests/high_insert_test/boom.rb | UTF-8 | 1,495 | 2.78125 | 3 | [
"BSD-3-Clause"
] | permissive | require 'json'
require 'httparty'
module TestData
def self.each_record
File.open File.expand_path("../data-insert/index.json", __FILE__) do |f|
f.each_line do |line|
yield line.strip
end
end
end
end
class Bimaple
include HTTParty
headers "Content-Type" => "application/json"
def ... | true |
3431850aa95bc0de066ab238d1a93bd27473b556 | Ruby | EuanFullarton/Weekend_Homework_3 | /seeds.rb | UTF-8 | 1,498 | 2.71875 | 3 | [] | no_license | require ('pry')
require_relative ('models/customer')
require_relative ('models/film')
require_relative ('models/ticket')
customer1 = Customer.new({'name' => 'Percy', 'funds' => 10})
customer2 = Customer.new({'name' => 'Agnes', 'funds' => 6})
customer3 = Customer.new({'name' => 'Tyrone', 'funds' => 14})
customer4 = Cu... | true |
2a7939dadda66431f301bcf35b18f582cc0ae051 | Ruby | ericmwalsh/carne-asada-sidekiq | /app/workers/base_symbols_worker.rb | UTF-8 | 3,072 | 2.796875 | 3 | [] | no_license | # ::BaseSymbolsWorker
class BaseSymbolsWorker < ::BaseWorker
sidekiq_options :queue => 'extract', :retry => 2
def perform
# query and store in memory
# push to db
# push to aws
symbols = get_symbols
timestamp = Time.now.to_i
mapped_symbols = [
[
'symbol'
]
]
s... | true |
bcb42a3f222daf1761ac49b86d45792e3a585d5c | Ruby | kreestoff/blood-oath-relations-houston-web-career-040119 | /app/models/followers.rb | UTF-8 | 599 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Follower
attr_accessor :name, :age, :life_motto
@@all = []
def initialize(name, age, life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def self.all
@@all
end
def join_cult(cult, initiation_date)
BloodOath.new(initiation_date, cult, self)
end
... | true |
ab2ede6c9738d1bdf5b90fc605b57db4534e5aee | Ruby | edhowland/vish | /bin/vish | UTF-8 | 1,541 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
# vish - runs Vish scripts: *.vs
require_relative '../lib/vish'
require_relative 'opt2'
require_relative 'startup'
options = { stdlib: true,
evaluations: [],
ifiles: []
}
opt=get_options(pgm:'vish', desc:'Compile and run Vish source file file.vs', options:options) do |o|
# aditional arguments
... | true |
08512bccde8cf67c7dd4d306869e2b2cb139985a | Ruby | kpatel27/ruby_exercises | /ruby_small_problems/reverse.rb | UTF-8 | 850 | 4.375 | 4 | [] | no_license | #Write a method that takes an Array, and returns a new Array with the elements of the original list in reverse order.
def reverse(array)
new_list = array.clone
left_index = 0
right_index = -1
while left_index < array.size / 2
new_list[left_index], new_list[right_index] = new_list[right_index], new_list[l... | true |
70e7a6ab3e8c7bfda9f16acd782dca123c65f120 | Ruby | elia/opal-jquery | /lib/opal-jquery/http.rb | UTF-8 | 1,358 | 3.40625 | 3 | [] | no_license | class HTTP
attr_reader :body
attr_reader :error_message
attr_reader :method
attr_reader :status_code
attr_reader :url
def self.get(url, opts={}, &block)
self.new url, :GET, opts, block
end
def initialize(url, method, options, handler)
@url = url
@method = method
@ok = true
... | true |
55d023f67b4785720c66e58725a0bae943c90a04 | Ruby | mschuerig/picture_frame | /lib/picture_frame/canvas.rb | UTF-8 | 1,744 | 3.265625 | 3 | [
"MIT"
] | permissive | require 'picture_frame/raster'
module PictureFrame
class Canvas < Raster
def initialize(*dimensions)
rows, cols = 0, 0
dimensions.each do |r, c|
rows += r
cols += c
end
raster = (1..rows).inject([]) { |r| r << ' ' * cols }
super(raster)
end
def print_at(pos... | true |
12aa47161de84e33c74d62da677a0b15f7a780df | Ruby | snusnu/testor | /lib/testor/metadata.rb | UTF-8 | 1,892 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'ruby-github'
module Testor
class Metadata
class Source
def self.new(filename, *args)
return super if self < Source
if filename.file?
Yaml.new(filename)
else
Github.new(filename, *args)
end
end
attr_reader :filename
... | true |
bb3214221db31399e55355a992a999e18301f030 | Ruby | Sajakhtar/ruby_basics_mike_dane | /015_comments.rb | UTF-8 | 232 | 3.046875 | 3 | [] | no_license | # this is a comment
puts "hello" # this is a comment
# commenting out code
# puts "hello"
=begin
This
is
a
comment
block
=end
=begin
Aim to write clean and readable code, such that you don't need many comments
=end
| true |
b767df9f1fd89d2f3c70c9fb847a28a52509900f | Ruby | zackattack01/appAcademy | /w1/w1d5/PolyTreeNode_projects/lib/word-chain-tree.rb | UTF-8 | 1,617 | 3.484375 | 3 | [] | no_license | require_relative '00_tree_node'
require 'set'
require 'byebug'
class WordChainer
def initialize
@dictionary = File.readlines('dictionary.txt').map(&:chomp).to_set
end
def run(source, target)
@words_visited = [source].to_set
@target = target
@tree_root = build_word_tree(source)
find_path(tar... | true |
58e6cb5af1315e19aaf37fab5ce61ec8ec450a37 | Ruby | mtcameron5/Ruby--The_Basics | /variables/name.rb | UTF-8 | 217 | 3.65625 | 4 | [] | no_license | puts "Enter your first name:"
first_name = gets.chomp
puts "Enter your last name:"
last_name = gets.chomp
full_name = "#{first_name} #{last_name}"
puts "Hello, #{full_name}. How are you?"
10.times { puts full_name } | true |
40e6b3e8cf35c7c661a952df72b3fe5f9c52bffb | Ruby | coding-sue-true/sparta-SDET-unit_testing-fizzbuzz | /spec/fizzbuzz_spec.rb | UTF-8 | 1,123 | 3.359375 | 3 | [] | no_license | require 'fizzbuzz'
describe Fizzbuzz do
before(:each) do
@fb = Fizzbuzz.new
end
it "should respond true if the number is divisible by 3" do
expect(@fb.divisible_by?(6, 3)).to be true
end
it "should respond false if the number is not divisible by 3" do
expect(@fb.divisible_by?(7, 3)).to be fals... | true |
b165c83b5e669114cb10d40375f29e1e38137f39 | Ruby | senglese96/W3D2 | /AA_Questions/replies.rb | UTF-8 | 1,483 | 2.765625 | 3 | [] | no_license | require_relative 'users'
class Replies
def initialize(data_hash = {})
@question_id = data_hash['question_id']
@parent_id = data_hash['parent_id']
@user_id = data_hash['user_id']
@body = data_hash['body']
end
def self.find_by_user_id(user_id)
data = QuestionsDatabase.instance.execute(<<-SQL)
... | true |
685906bc975d5fca77231b556919530a4738d333 | Ruby | abillig/deli-counter-001-prework-web | /testing.rb | UTF-8 | 323 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
katz_deli = []
def line(line)
if line.length > 0
lined=[]
line.each_with_index do |item, index|
lined << "#{index+1}.#{item} "
end
return "The line is currently: #{lined.join("")}"
else
puts "The line is currently empty."
end
end
puts line(["Logan", "Avi", "Spencer... | true |
c80b2754b29b8b8ea4d7031f52c239e00091bb24 | Ruby | pierreribault/school-ruby | /exo1.rb | UTF-8 | 340 | 3.890625 | 4 | [] | no_license | puts "Premiere chaine"
firstString = gets.chomp
puts "Deuxieme chaine"
secondString = gets.chomp
if(firstString.length >= secondString.length * 2)
puts "La taille de la premiere chaine est au moins superieur au double de la seconde"
else
puts "La taille de la premiere chaine n'est pas au moins superieur au double... | true |
c8c5b9dd0c16cbc4142d813668d4aab2a96dc801 | Ruby | iyc/bizzy | /tests/toolbox_tests.rb | UTF-8 | 1,352 | 2.78125 | 3 | [] | no_license |
require "test/unit"
require File.dirname(__FILE__) + '/../rb/toolbox.rb'
# ---------------------------
class TestSql < Test::Unit::TestCase
include Toolbox
# ---------------------------
def setup
@test = QuickClass.new
end#def
# ---------------------------
def test_props_are_not_assigned
asser... | true |
009234d6f714bb3408713d4267b9422462e50e6e | Ruby | Shirley0904/Blackjack | /Blackjackcard.rb | UTF-8 | 366 | 3.3125 | 3 | [
"MIT"
] | permissive | class Card
attr_accessor :face :suit :value
def initialize(face, suit, value)
@face = face #using @face instead of self.face makes more sense to me.
@suit = suit
@value =value
end
def value=(face)
if face == "Jack" || "Queen"|| "King" = 10
elsif == "Ace" = 11
... | true |
235b0220b35721b24e8e801bf9579cd9d5ef9f28 | Ruby | Alu0100673647/prct12 | /spec/matrizdispersascp_spec.rb | UTF-8 | 4,586 | 3.09375 | 3 | [
"MIT"
] | permissive | # = matrizdispersascp.rb
#
# Etsii ull grado informática
# Lenguajes y Paradigmas de la programacion
# Autor::Pedro Javier Núñez Rodríguez
# Autor::Constanza Leon Baritussio
#
# == Expectativas para matrices densas y dispersas
# - Programar las expectativas para nuestras clases matriz dispersas y densas
#
require 'sp... | true |
9bda84f29b485ce1dc7b9dde2bc2915ec2943802 | Ruby | coinbase/geoengineer | /lib/geoengineer/resource.rb | UTF-8 | 9,322 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | ########################################################################
# Resources are the core of GeoEngineer and are mapped 1:1 to terraform resources
#
# {https://www.terraform.io/docs/configuration/resources.html Terraform Docs}
#
# For example, +aws_security_group+ is a resource
#
# A Resource can have arbitrary... | true |
772e8359946703f09571db9c938aab87a446afd9 | Ruby | danbriechle/reunion | /lib/reunion.rb | UTF-8 | 1,469 | 3.25 | 3 | [] | no_license | require 'pry'
class Reunion
attr_reader :name, :activities, :detailed_hash
def initialize(name)
@name = name
@activities = []
@detailed_hash = {:activity => "", :payees => [], :amount => 0}
end
def add_activity(activity)
@activities << activity
end
def total_cost
cost = @activities.map... | true |
fda735c08092bc3c665fd6c3091cfde04336c440 | Ruby | ninjaturtle3/intro-to-tdd-rspec-and-learn-v-000 | /current_age_for_birth_year.rb | UTF-8 | 95 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def current_age_for_birth_year(birth_year)
#2003-birth_year
Time.now.year - birth_year
end
| true |
1aa374b2d2fc3a6e11a7b2c013dad01a597061c3 | Ruby | JordanICollier/ruby-intro-to-enumerable-part-b | /exercises/10_group_by.rb | UTF-8 | 1,037 | 3.1875 | 3 | [] | no_license | def group_by(input, &block)
result = Hash.new {[]}
input.each do |hsh|
result[block.call(hsh)] = result[block.call(hsh)] << hsh
end
result
end
# ------ code above this line ------
require 'rspec/autorun'
RSpec.describe '#group_by' do
it 'returns a hash where the values are arrays of items, grouped by t... | true |
4fb6a7d02c58c1c6062d19341871226431123ae6 | Ruby | hecrj/rom | /spec/unit/rom/header_spec.rb | UTF-8 | 3,050 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
describe ROM::Header do
describe '.coerce' do
subject(:header) { ROM::Header.coerce(input) }
context 'with a primitive type' do
let(:input) { [[:name, type: :string]] }
let(:expected) do
ROM::Header.new(name: ROM::Header::Attribute.coerce(input.first))
end
... | true |
bef00a28990280ded3580f9316fb285b65ade215 | Ruby | johnlinvc/erruby | /rb_test/ivar.rb | UTF-8 | 117 | 3.078125 | 3 | [
"MIT"
] | permissive | class Foo
def setup
@ivar = "hello"
end
def ivar
@ivar
end
end
foo = Foo.new
foo.setup
puts foo.ivar
| true |
c292f0839f6cb4b02488b7fe876f9f5e60be62b7 | Ruby | willb/capricious | /lib/capricious/spline_distribution.rb | UTF-8 | 11,834 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # capricious/spline_distribution.rb: A utility for estimating distributions from data using splining
#
# Copyright:: Copyright (c) 2013 Red Hat, Inc.
# Author:: Erik Erlandson <eje@redhat.com>
# License:: http://www.apache.org/licenses/LICENSE-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# ... | true |
fec1406546181936626ac20b9084a1a5f7b1ed18 | Ruby | PrestonPlaybook/Games | /BlankProgram.rb | UTF-8 | 297 | 3.25 | 3 | [] | no_license | require 'io/console'
require 'io/wait'
Thread.new do
loop do
#s = STDIN.getch.chomp #gets.chomp
#s = STDIN.chomp
s = STDIN.getch
puts ""
puts "You entered #{s}"
exit if s == 'e'
end
end
i = 0
loop do
puts "Tick #{i}...\n"
i += 1
sleep 1
end
| true |
c1efdc403241a2bed579f369585c61758368835a | Ruby | tjbladez/gosu-opengl-tutorials | /using_nehe_lessons/lesson06.rb | UTF-8 | 3,188 | 2.6875 | 3 | [] | no_license | require File.expand_path('../../config/boot', __FILE__)
class Texture
attr_accessor :info
def initialize(window)
@image = Gosu::Image.new(window, "resources/nehe/lesson06/ruby.png", true)
@info = @image.gl_tex_info
end
end
class Window < Gosu::Window
def initialize
super(800, 600, false)
self.... | true |
6e801f76f1c533b8d1e8405b502e1a2482ea84d9 | Ruby | DanielPramatarov/Penetration-Testing-Tools | /Ruby/portScanner.rb | UTF-8 | 521 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | require 'socket'
TIMEOUT = 1
def scan_port(port)
socket = Socket.new(:INET, :STREAM)
remote_addr = Socket.sockaddr_in(port, '10.10.10.209')
begin
socket.connect_nonblock(remote_addr)
rescue Errno::EINPROGRESS
end
_, sockets, _ = IO.select(nil, [socket], nil, TIMEOUT)
if sockets
p "Port #{port... | true |
02e5242c6760582938abd0f475f1cceec5b56999 | Ruby | Nosajool/advent-of-code | /day3/day3.rb | UTF-8 | 3,179 | 3.921875 | 4 | [] | no_license | # --- Day 3: Perfectly Spherical Houses in a Vacuum ---
# Santa is delivering presents to an infinite two-dimensional grid of houses.
# He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to move next. Moves are always exac... | true |
b7f5827f12b99d35d7321d57886aa0da0d223a11 | Ruby | NYULibraries/remove-unwanted-digital-objects-aspace | /rm-legacy-DO.rb | UTF-8 | 3,026 | 2.5625 | 3 | [] | no_license | require 'rubygems'
require 'bundler/setup'
require 'pry'
require 'multi_json'
require 'yaml'
require 'logger'
require 'archivesspace/client'
#require_relative 'lib/aspace/api'
def parse_nested_hsh(nodes,uris)
nodes.each { |n|
uris.push(n['record_uri']) if n['instance_types'].size > 0
parse_nested_hsh(n['chil... | true |
6af9a42448e9193570848c645a2a74e0168107cf | Ruby | erlehmann/puituniverse | /activeresource.rb | UTF-8 | 1,978 | 2.71875 | 3 | [] | no_license | class String
def validate_existance_of file
raise "no #{file}" unless file.is_file? or file.is_folder?
end
alias_method :is_folder?, :is_dir?
def yml
file = "#{self}.yml"
validate_existance_of file
YAML::load_file(file) # rescue nil # don't cache. because this can be used in funky ways (i ... | true |
ef99785be8ee86e0efb35e7a229ffa7b74ee327b | Ruby | nikosd/roodi | /lib/roodi/checks/name_check.rb | UTF-8 | 576 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'roodi/checks/check'
module Roodi
module Checks
class NameCheck < Check
def initialize(interesting_nodes, pattern, message_prefix)
super()
@interesting_nodes = interesting_nodes
@pattern = pattern
@message_prefix = message_prefix
end
def interesting_node... | true |
1996f742ea92a113687d14b093f7465738763d47 | Ruby | sundarcodes/Hackerrank_solutions | /quick_sort_out_of_place.rb | UTF-8 | 532 | 3.046875 | 3 | [] | no_license | def partition(ar,first,last)
#print "#{ar},#{first},#{last}\n"
return ar if ar.length<=1
pivot=ar[first]
small_arr=[]
large_arr=[]
for i in 1...last
element=ar[i]
if (element>pivot)
large_arr<<element
else
small_arr<<element
end
end
small_arr=partition(small_arr,0,small_arr.length)
large_arr=part... | true |
a451d34add34b58a8fa7ec37495fe9bb325fa047 | Ruby | rob4lderman/ruby-euler | /prob21.rb | UTF-8 | 1,402 | 3.875 | 4 | [] | no_license | #!/usr/bin/ruby
#
# http://projecteuler.net/problem=21
#
# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
# If d(a) = b and d(b) = a, where a ? b, then a and b are an amicable pair and each of a and b are called amicable numbers.
#
# For example, the proper div... | true |
2a312b05b91c058139a9dce443aaf1dc169fcf87 | Ruby | Skoda091/Projekt_MIASI | /src/classes/nexus.rb | UTF-8 | 1,598 | 2.703125 | 3 | [] | no_license | require 'gosu'
require_relative '../classes/object.rb'
class Nexus < Object
attr_accessor :hp
def initialize(x,y,window,player_id)
super(x =x,y =y,window,player_id)
@image_nexus=Gosu::Image.new(@game_window, "../data/graphics/"+player_id+"/Buildings/nexus_full.png")
@image_damaged=Gosu::Image.new(@gam... | true |
64e27aaa73297e13d84dd7475c24559344cd2ac5 | Ruby | nakedsushi/instagram_to_smugmug | /smugmug_auto_import.rb | UTF-8 | 1,877 | 2.6875 | 3 | [] | no_license | require 'net/https'
require 'uri'
require 'rubygems'
require 'json'
require 'open-uri'
require 'mail'
require 'yaml'
@options = YAML.load_file('config.yml')
@tag = @options['tag'] || 'smugmug'
@user_id = @options['instagram_id'] || 216881
@min_filename = "min_id_#{@user_id}.txt"
@smugmug_subject = '#' + @tag
def rea... | true |
9e06284cf168e26c6f4229b5fac67ff1b8b87942 | Ruby | xsimov/distance_calculator | /lib/price_calc.rb | UTF-8 | 1,719 | 3.671875 | 4 | [] | no_license | X, Y = 0, 1
DISTANCE, VOLUME = 1, 2
VEHICLES = {
bike: [ 1, 10, 500],
motorbike: [1.2, 100, 1000],
car: [1.3, 200, 5000],
van: [1.4, 500, 10000]
}
class Quote
attr_accessor :argument
def initialize(point_one, point_two, argument = :bike)
@point_one = point_one
@point_two = po... | true |
5e770d6a8b62e3870cf233cdabc5d500f0e1b84f | Ruby | accidentaldevelopment/Etc2 | /lib/etc2/user.rb | UTF-8 | 1,020 | 2.578125 | 3 | [] | no_license | module Etc2
# Represents a single user on the system
class User
include Common
extend Enumerable
attr_reader :name, :uid, :gid, :gecos, :dir, :shell
alias :full_name :gecos
alias :home_dir :dir
alias :homedir :dir
alias :home :dir
# Iterate through each User on the ... | true |
89476c94816a533f9330a189e3fc72dba6fbf9e2 | Ruby | rocky/rbx-trepanning | /processor/command/next.rb | UTF-8 | 1,913 | 2.734375 | 3 | [] | no_license | require 'rubygems'; require 'require_relative'
require_relative '../command'
require_relative '../stepping'
require_relative '../../app/breakpoint'
class Trepan::Command::NextCommand < Trepan::Command
ALIASES = %w(n)
CATEGORY = 'running'
NAME = File.basename(__FILE__, '.rb')
HELP= <<-HELP
#{N... | true |
42722e14c085e0c36466391e195560ad9f52dd60 | Ruby | apohllo/hanami-testbed | /spec/testbed/db/db_spec.rb | UTF-8 | 1,321 | 2.71875 | 3 | [] | no_license | require_relative '../../spec_helper'
module Testbed
class Database
include Import['testbed.rom']
def connection
@rom
end
end
end
describe 'Database' do
before do
DatabaseCleaner.start
@instance = Testbed::Database.new
@author_repo = AuthorRepository.new
@poem_repo = PoemReposi... | true |
ad996331286b51df004bfac8af6828048f3f4bbd | Ruby | danielbush/RubyCron | /examples/example1.rb | UTF-8 | 1,404 | 3.203125 | 3 | [
"MIT"
] | permissive | require_relative '../lib/CronR'
require 'pp'
Cron = CronR::Cron
Job = CronR::CronJob
cron = Cron.new
cron.debug = true
# Optional
# Set timezone...
cron.timezone = "Australia/Sydney"
p cron.time
cron.start
# So cron is now running, but it's not actually doing much because it
# doesn't have any jobs.
# Let's chan... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.