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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a779618d3c24e47c1231c836c30227e4809ee642 | Ruby | KevinKra/Enigma | /lib/Enigma.rb | UTF-8 | 924 | 3.296875 | 3 | [] | no_license | require 'time'
require_relative "../lib/utils/helpers.rb"
require_relative "../lib/Encrypt.rb"
class Enigma
include Helpers
attr_reader :key, :date
def initialize
@key = gen_key
@date = todays_date
@encrypt = Encrypt.new
end
private
def gen_key
rand.to_s[2..6]
end
def todays_date
... | true |
80a434c8779e30ecaa8181b27caf50d29c2690fb | Ruby | brunogarciagonzalez/sinatra-mvc-lab-dc-web-031218 | /models/piglatinizer.rb | UTF-8 | 1,364 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
attr_reader :text
# def initialize(text)
# @text = text
# end
def piglatinize(word)
text_array = word.split(" ")
final_words = text_array.collect do |word|
word_array = word.split("")
if consonants_array.include?(word_array.first) && consonants_array.include?(word_a... | true |
c06de0282e1eb681e56aafbd254608be66df376b | Ruby | Pistos/rdbi-driver-sqlite3 | /lib/rdbi/driver/sqlite3.rb | UTF-8 | 4,613 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'rdbi'
require 'epoxy'
require 'methlab'
require 'sqlite3'
class RDBI::Driver::SQLite3 < RDBI::Driver
def initialize(*args)
super(Database, *args)
end
end
class RDBI::Driver::SQLite3 < RDBI::Driver
class Database < RDBI::Database
extend MethLab
attr_accessor :handle
def initialize(*arg... | true |
a1ae676c9f1ba710152a199b0b70d24e740fe689 | Ruby | davecozz/pi-sprinkler-api | /src/sprinkler.rb | UTF-8 | 2,078 | 3.0625 | 3 | [] | no_license | require 'json'
module Sprinkler
@active_sprinklers = ['s0', 's1', 's2', 's3']
@gpio_bin = '/usr/local/bin/gpio'
@coil_time = 0.3 #length of time in sec to energize the valve coils
@pin_offset = 4 #physical offset between on and off gpio pins
@status_file = '/dev/shm/sprinkler_status.json'
def self.active_... | true |
91ada56b03da528d9dd264504bd5c4dfc831dcb0 | Ruby | InfinityG/ig-coin-api | /api/services/transaction_service.rb | UTF-8 | 2,237 | 2.65625 | 3 | [] | no_license | require './api/gateway/ripple_rest_gateway'
require './api/utils/hash_generator'
require './api/models/transaction'
class TransactionService
def execute_deposit(user, amount)
ripple_gateway = RippleRestGateway.new
client_resource_id = HashGenerator.new.generate_uuid
payment = ripple_gateway.prepare_depos... | true |
2c98c5f03e0c44e9a5d20bed5c85c503fb158348 | Ruby | pigasksky/Brotorift | /src/lib/compiler.rb | UTF-8 | 8,122 | 2.5625 | 3 | [] | no_license | require_relative 'parser'
require_relative 'compiler_error'
require_relative 'runtime'
class String
def char_case
if self == self.upcase
return :upper
else
return :lower
end
end
end
class Compiler
attr_reader :errors, :runtime
def initialize
@errors = []
@message_base_id = 0
@message_id = 0
... | true |
b5426adeaf55c012524484a017a4a0006c9eeaf7 | Ruby | stonesaw/AtCoder | /2019-11-09_1.rb | UTF-8 | 99 | 3.5625 | 4 | [] | no_license | n = gets.chomp.to_i
if(n % 2 == 0)
print(n % 2 - 1)
elsif(n % 2 == 1)
print(n - 1) / 2
end | true |
07e45e356cf3d06acfa48b79f153fa0b69882e74 | Ruby | kernelsmith/workbook | /test/test_readers_csv_reader.rb | UTF-8 | 4,725 | 2.84375 | 3 | [
"MIT",
"GPL-3.0-only",
"LGPL-2.0-or-later",
"GPL-2.0-only",
"Ruby"
] | permissive | # frozen_string_literal: true
require File.join(File.dirname(__FILE__), "helper")
module Readers
class TestCsvWriter < Minitest::Test
def test_open
w = Workbook::Book.new
w.import File.join(File.dirname(__FILE__), "artifacts/simple_csv.csv")
# reads
# a,b,c,d
# 1,2,3,4
... | true |
fa7ae59e408f15e5cedb119b73531b21f0c65690 | Ruby | sgvincentho/introrubycourse | /more_exercises_6.rb | UTF-8 | 244 | 3.953125 | 4 | [] | no_license | # more_exercises_6.rb
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Append
arr.push(11)
#puts arr
# prepend
arr.unshift(0)
#puts arr
#------------------------
#Get rid of 11
arr.pop
#puts arr
# Append 3
arr << 3
#puts arr
puts arr.uniq | true |
e4ce2a9916aecd3842fd24730565a2de435eb38f | Ruby | picatz/slipstream | /lib/slipstream.rb | UTF-8 | 1,246 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'securerandom'
require 'slipstream/version'
module Slipstream
def self.create(**options)
Stream.new(options)
end
class Stream
attr_accessor :buffer_size
attr_accessor :clean
def initialize(**options)
if options[:id].nil?
@id = SecureRandom.uuid
else
@id = o... | true |
349c76bd474f5eaec5807636051515cf0bbd1cc7 | Ruby | RedHatInsights/sources-api | /lib/go_encryption.rb | UTF-8 | 610 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | class GoEncryption
def self.encrypt(pass)
# clowder can throw error messages - so we filter them out
%x[sources-encrypt-compat -encrypt #{pass} | grep -v Clowder].strip.tap do |str|
raise "error encrypting string: #{str}" if $?.to_i != 0
raise "bad encryption!" if str.blank?
end
end
def s... | true |
87265d3dfe7c552b1aa71be6995b66538dccaa44 | Ruby | eggmantv/ruby_advanced | /04/03_block.rb | UTF-8 | 200 | 4.09375 | 4 | [] | no_license | # yield with parameter
def hello name
puts 'hello method start'
result = "hello " + name
yield(result)
puts 'hello method end'
end
hello('world') { |x| puts "i am in block, i got #{x}" } | true |
803eecf3152c62beccea30d80da81f219fa1ad31 | Ruby | jackychen6825/AA_Classwork | /W4/D2/Chess/piece.rb | UTF-8 | 516 | 3.421875 | 3 | [] | no_license | class Piece
attr_reader :color, :board, :pos
def initialize(color, board, pos)
@color = color
@board = board
@pos = pos
end
def valid_moves
v_moves = []
(0...8).each do |row|
(0...8).each do |col|
pos = [row, col]
# if board[pos].color != color || board[pos].empty?... | true |
16843d2df8c64b0ff4346b7142797e55740eeb6f | Ruby | celsian/BEWDiful_Students | /05_Classes_Objects/exercises/coa_05_classes.rb | UTF-8 | 1,242 | 4.40625 | 4 | [] | no_license | #Class 5 Code Along
jimmy = {}
jimmy[:name] = "Jimmy Mcbordermier"
jimmy[:major] = "Math"
jimmy[:course] = "Dr. Dre"
jimmy[:grade] = "C"
robert = {}
robert[:name] = "Robert Ross"
robert[:major] = "CS"
robert[:course] = "Objects"
robert[:grade] = "A"
def grade_status(student)
if student[:grade] == "F"
"failed"
el... | true |
6dc5225b68922fc1a08d7656245bd82976f6e861 | Ruby | jenkliu/j-cart | /app/models/product.rb | UTF-8 | 340 | 2.75 | 3 | [] | no_license | class Product < ActiveRecord::Base
has_many :items
validates_presence_of :name, :price, :qty_in_stock
attr_accessible :brand, :info, :name, :price, :qty_in_stock, :items
# check if product has at least [qty] in stock
def has_in_stock(qty)
if self.qty_in_stock >= qty
return true
else
return fals... | true |
c3ce3972bb3e69db546e1c7c1ffc60864b22250d | Ruby | nilfs/workflow_engine_study | /src/file_target.rb | UTF-8 | 159 | 2.734375 | 3 | [] | no_license | require_relative 'target'
class FileTarget < Target
attr_reader :path
def initialize(path)
@path = path
end
def exist?
File.exist?(path)
end
end | true |
b95bfe9341cc31ee7aa800f61d847c222ee426f3 | Ruby | kozinvl/RacingCars | /spec/position_spec.rb | UTF-8 | 502 | 3 | 3 | [] | no_license | require 'rspec'
require_relative '../position'
describe Position do
before :each do
@position = Position.new(10, 1)
end
it 'should be equal x var in initialize' do
expect(@position.x).to eq 10
end
it 'should be equal y var in initialize' do
expect(@position.y).to eq 1
end
it 'should be i... | true |
0fc5d4c12958c1010f09490ced39b3cae3334778 | Ruby | rosiljunior1588/exemplo_mobile | /features/elements/exemplo_elements.rb | UTF-8 | 571 | 2.59375 | 3 | [] | no_license | ## Módulo configurado para mapear todos os elementos da tela, cada tela deve se criar uma classe screen e elements.
## O Exemplo de utilizar elements deve ser aplicado quando o aplicativo é hibrido, ou seja, o mapeamento de elementos será da mesma forma tanto para iOS como para Android.
module Elementos_Tela_Exemplo
... | true |
0cad1e4eb2588a1ed69348836c3164660b21c954 | Ruby | DianaLuciaRinconBl/Ruby-book-exercises | /ruby_basic_ex/input/lsprint2.rb | UTF-8 | 1,466 | 4.28125 | 4 | [] | no_license | # Modify this program so it repeats itself after each input/print iteration,
# asking for a new number each time through. The program should keep running
# until the user enters q or Q.
number = nil
loop do
puts "How many output lines do you want? Enter a number greater than 3 "
number = gets.chomp.downcase
b... | true |
4a8b478c24dabb4b4f869ff63f1e2db4795900b1 | Ruby | 343334/pokemon-webhook | /lib/plugin-twitter.rb | UTF-8 | 2,199 | 2.6875 | 3 | [] | no_license | require 'twitter'
class Notifier
class Twitter
def initialize
begin
@client = ::Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS... | true |
1efc8de88affb32c5e4e648ae31bbb5993d75fb9 | Ruby | eeichinger/cuke4duke-junit | /junit-runner-jruby/src/main/resources-jruby/META-INF/jruby.gem.home/gems/gherkin-2.4.0-java/lib/gherkin/formatter/json_formatter.rb | UTF-8 | 2,149 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'json'
require 'gherkin/formatter/model'
require 'gherkin/native'
require 'base64'
module Gherkin
module Formatter
class JSONFormatter
native_impl('gherkin')
include Base64
attr_reader :gherkin_object
# Creates a new instance that writes the resulting JSON to +io+.
... | true |
104fea99b0886e23aad7896da4d1b7203b120ffa | Ruby | ruby-processing/The-Nature-of-Code-for-JRubyArt | /chp05_physicslibraries/toxiclibs/simple_cluster/node.rb | UTF-8 | 756 | 2.953125 | 3 | [
"MIT"
] | permissive | # The Nature of Code
# <http://www.shiffman.net/teaching/nature>
# Spring 2010
# Toxiclibs example: http://toxiclibs.org/
# Force directed graph
# Heavily based on: http://code.google.com/p/fidgen/
# Notice how we are using inheritance here!
# We could have just stored a reference to a VerletParticle object
# inside ... | true |
a083d951341812e2d73ce07477258d295a198294 | Ruby | kaleforsale/using_httpwatch | /sitespider.rb | UTF-8 | 4,732 | 2.515625 | 3 | [] | no_license | require 'win32ole' # used to drive HttpWatch
require 'watir' # the WATIR framework
require 'yaml'
class Sitespider
attr_accessor :url, :totalTime, :receivedBytes, :compressionSavings, :roundTrips, :numberErrors
def initialize(url)
@url=url
puts @url
if @url.empty?
exit
end
end
def start_test... | true |
223967ed20db5ccc0f49a7593425e2e4089b35ae | Ruby | cris07/ruby | /intermedio/proc.rb | UTF-8 | 504 | 3.828125 | 4 | [] | no_license | #Clase Proc
sumar = Proc.new {|x,y| puts "La suma es #{x+y}"}
restar = Proc.new do |x,y|
puts "La resta es #{x-y}"
end
multiplicar = Proc.new {|x,y|puts "#{x*y}"}
def calcu x,y,proc
puts "Hagamos una operacion matemática con procs"
proc.call x,y
end
calcu 1,2, sumar
calcu 1,2, restar
def metodo x,y,proc1,... | true |
378b6b6eab3595dc699f222bc36cb544e0d49922 | Ruby | analisistem/mongoid_nested_set | /spec/matchers/nestedset_pos.rb | UTF-8 | 1,120 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Mongoid::Acts::NestedSet
module Matchers
def have_nestedset_pos(lft, rgt, options = {})
NestedSetPosition.new(lft, rgt, options)
end
class NestedSetPosition
def initialize(lft, rgt, options)
@lft = lft
@rgt = rgt
@options = options
end
def matches... | true |
87f5469ade0337ab4c8d9faaaa0c065464903cff | Ruby | morganp/verilog | /lib/verilog/file_list.rb | UTF-8 | 2,568 | 3.09375 | 3 | [] | no_license | module Verilog
class FileList
attr_reader :files
## Expected usage
# Use FileList to create an array of files included in design
# FileList is then used to create a Path, which loads the files into memory
# FileList and Path are separated in case you want a file list with out actually having to ... | true |
f1442d06cd6efb76eb5106b8133c91163200d964 | Ruby | natikgadzhi/requalations | /spec/requalations/vector/vector_spec.rb | UTF-8 | 2,786 | 3.296875 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
#
# Specifying additional methods in the Vector class
#
describe Vector do
# Before each spec sentence
before(:each) do
# create a vector
@vector = Vector.elements( [4,10,29,2,5,1] )
@column_vector = Vector.elements( [ [1], [2], ... | true |
0582840bc83d8c8578684fde9877e36043469262 | Ruby | marksterr/aA-classwork | /week_6/day_1/rails1-practice/sql/spec/test_spec.rb | UTF-8 | 7,197 | 2.515625 | 3 | [] | no_license | require 'rspec'
require 'test'
describe "SQL" do
describe "gold_cat_toys" do
it "finds all the toys that are `Gold` in color and have more than one word in the name" do
expect(gold_cat_toys).to eq([["Bone Club"], ["Bubble Beam"], ["Chicken Milanese"], ["Chicken Wings"], ["Chilli con Carne"], ["Defense Cur... | true |
74f9925125aa1b747c70a2e6582223ea353a19fc | Ruby | jdan/adventofcode | /2015/rb/2015/13b-knights-table.rb | UTF-8 | 1,022 | 3.6875 | 4 | [] | no_license | # http://adventofcode.com/day/13
seating = {}
people = []
ARGF.each do |line|
re = /(\w+) would (\w+) (\d+) happiness units by sitting next to (\w+)/
match = line.match(re)
a = match[1]
b = match[4]
# Track the different people
people << a
sign = match[2] == "gain" ? 1 : ... | true |
1b29466431a9f7638062f2a5478ad600ff7d0a0a | Ruby | otikev/msajili | /app/models/report.rb | UTF-8 | 2,147 | 2.734375 | 3 | [
"MIT"
] | permissive | class Report
attr_accessor :company, :job, :total_jobs, :open_jobs, :closed_jobs, :applications, :procedures_array, :start_date, :end_date
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def fetch(job)
if job
self.job=job
else
... | true |
82ab041780aa03fc2f99b4e9ce907f0f834df1b5 | Ruby | jmheyd/sinatra-dynamic-routes-lab-v-000 | /app.rb | UTF-8 | 1,415 | 3.890625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
#dynamic route to accept name and render name backwards
get '/reversename/:name' do
params[:name].reverse
end
#dynmaic route to accept number and render square of that number
get '/square/:number' do
@number = params[:number].to_i
square = @... | true |
54f8c9d8659e26f5253b55f7c403471fd1651721 | Ruby | jstrait/beats | /lib/beats/beats_runner.rb | UTF-8 | 2,525 | 2.96875 | 3 | [
"MIT"
] | permissive | module Beats
class BeatsRunner
# Each pattern in the song will be split up into sub patterns that have at most this many steps.
# In general, audio for several shorter patterns can be generated more quickly than for one long
# pattern, and can also be cached more effectively.
OPTIMIZED_PATTERN_LENGTH ... | true |
1e833c67c3586f09529db0c827765c92efa3ef4c | Ruby | VitalyDorozhkin/Ruby | /chest/chest.rb | UTF-8 | 1,656 | 3.5625 | 4 | [] | no_license | board = [[],[],[],[],[],[],[],[]]
class Game
attr_accessor :max_time
attr_accessor :time
def start
puts "start"
end
def finish
puts "finish"
end
def info
puts "variables: max_time, time"
puts "methods: start(start the game), finish(end the game)"
end
end
class Piece
attr_accessor ... | true |
8ea3e4a70854eed8112fd94fbc8a44d5b460683f | Ruby | Hansen-Nick/Intro-to-Programming | /basics/exercise_3.rb | UTF-8 | 299 | 3.015625 | 3 | [] | no_license | movies = { Casablanca: 1942,
:"The Godfather" => 1972,
:"Citizen Kane" => 1941,
:"Pulp Fiction" => 1994,
Goodfellas: 1990 }
puts movies[:Casablanca]
puts movies[:"The Godfather"]
puts movies[:"Citizen Kane"]
puts movies[:"Pulp Fiction"]
puts movies[:Goodfellas] | true |
eb0533ad7ea50b7736e0c4890e9b1ac858e0de37 | Ruby | colehart/denver_puplic_library | /test/author_test.rb | UTF-8 | 1,057 | 3.078125 | 3 | [] | no_license | require './test/test_helper'
require './lib/author'
class AuthorTest < Minitest::Test
def setup
@author = Author.new(first_name: 'Charlotte',
last_name: 'Bronte')
end
def test_it_exists
assert_instance_of Author, @author
end
def test_it_has_attributes
assert_equal 'Char... | true |
16e690db9d6d480c2a5a6c929e5c99c59211ccd6 | Ruby | mcken-vince/ruby_math_game | /planning.rb | UTF-8 | 309 | 2.625 | 3 | [] | no_license | # class Player
# Variables: lives
# Methods: ask_question, opponent_correct, opponent_incorrect, lose_life
# --- Initialize--- @lives = 3
# class Game
# Variables: players, whose_turn
# Methods: next_round, declare_winner
# class Question
# Variables: min, max
# Method: generate_number, generate_question
| true |
9627dafddb741bde4d537185f8cb173172650b23 | Ruby | Kyvyas/Battleships | /spec/board_spec.rb | UTF-8 | 1,053 | 2.984375 | 3 | [] | no_license | require 'board'
describe Board do
let(:ship) { double :ship, :coordinates => 'A5' }
it { is_expected.to respond_to(:place_ship) }
it 'has a ship once ship is placed' do
allow(ship).to receive(:place) {ship}
allow(ship).to receive(:coordinates) {ship}
subject.place_ship ship
expect(subject.place_ship ... | true |
a508110b5d2ab65bfd3655a53b39facbcc60d85b | Ruby | CristianCristea/launch_school | /exercises/ruby/small_problems/easy_3/06_odd_lists.rb | UTF-8 | 803 | 4.6875 | 5 | [] | no_license | # Odd Lists
# Write a method that returns an Array that contains every other element of an Array that is passed in as an argument. The values in the returned list should be those values that are in the 1st, 3rd, 5th, and so on elements of the argument Array.
def oddities(arr)
arr.select { |elem| elem if arr.index(e... | true |
a22668122ecf32b74f510d68fbe37612bcf43658 | Ruby | manoart/ruby_seminar | /code/iterators.rb | UTF-8 | 183 | 3.671875 | 4 | [] | no_license | 10.times do
print "Hallo! "
end
puts
puts
(1..10).each do |i|
puts i*i
end
puts
[1,2,3,4,5,6,7,8].each do |x|
if x.even?
print x
else
print "..."
end
end
puts
| true |
c8bd4b6f0114874e692fb5456749a314b13d2b48 | Ruby | johncban/ruby-objects-has-many-through-lab-online-web-pt-041519 | /lib/patient.rb | UTF-8 | 467 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Patient
attr_accessor :name
@@all = []
def initialize(p_name)
@name = p_name
@@all << self
end
def self.all
@@all
end
def new_appointment(doctor, date)
Appointment.new(date, self, doctor)
end
def appointments
Appointment.all do |apt|
apt.new == self
end
end
... | true |
d65487971cf3ea970cf044d767eb8d261e7f8a65 | Ruby | NRothera/sparta-web-testing | /capybara/facebook_RSpec_pom/lib/pages/facebook_homepage.rb | UTF-8 | 1,042 | 2.609375 | 3 | [] | no_license | require 'capybara/dsl'
class FacebookHomepage
include Capybara::DSL
HOMEPAGE_URL = 'https://www.facebook.com/'
FIRSTNAME_FIELD_ID = 'u_0_p'
LASTNAME_FIELD_ID = 'u_0_r'
MOBILE_OR_EMAIL_FIELD_ID = 'u_0_u'
PASSWORD_FIELD_ID = 'u_0_11'
DAY_ID = 'Day'
MONTH_ID = 'Month'
YEAR_ID = 'Year'
FEMALE_RADIO_ID... | true |
e480a41ce205531c1be31faf4376e7ccfec0632c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/12739.rb | UTF-8 | 799 | 3.53125 | 4 | [] | no_license | #HW 1: Ruby calisthnics
#Author: Anand Kapoor
#Part 3 - Anagrams
def find_elements(element_name, element_array, original_array)
@result_index = []
element_array.each_index { |e| @result_index << original_array.at(e) if element_array.at(e) == element_name.to_s }
return @result_index
end
def combine_anagrams(wo... | true |
8316071b6a6c094a8388553209a897aaf37d1e20 | Ruby | henrygarciaospina/challengers-ruby | /read_file_best.rb | UTF-8 | 115 | 2.515625 | 3 | [] | no_license | system("clear")
def read(file)
File.exist?(file) ? File.read(file) : nil
end
resul = read("text.txt")
puts resul
| true |
dc4f49b695122636dc17813d7983c2c32cd4f447 | Ruby | DanielLaraSanchez/Family-Wallet-Project | /project/family_wallet/models/accounts.rb | UTF-8 | 3,909 | 3.078125 | 3 | [] | no_license | require('pg')
require_relative('../db/sql_runner.rb')
require_relative('./transactions.rb')
class Account
attr_accessor(:holder_name, :holder_last_name, :account_number, :type, :credit)
attr_reader(:id)
def initialize ( account )
@id = account['id'].to_i() if account['id'].to_i()
@holder_name = accoun... | true |
678c510800c7bfcf655dd00e3bf039ca4e48692d | Ruby | paragppanchal/Decrypt | /app/jobs/fetch_market_snapshot_job.rb | UTF-8 | 3,210 | 2.984375 | 3 | [] | no_license | class FetchMarketSnapshotJob < ApplicationJob
queue_as :default
def perform(*args)
# fetch current buy & sell price of all the exchanges on the Exchanges table
all_exchanges = Exchange.all
all_exchanges.each do |exchange|
begin
update_market_snashot_record(exchange, 'BTC', 'USD')
#... | true |
14cfc5271e58aa74857295f9ed65da7c1d3cabd9 | Ruby | Sage/rubocop-custom-cops | /lib/rubocop/lint/swallowed_exception.rb | UTF-8 | 1,714 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | require 'rubocop'
# Rubocop Cop module
module RuboCop
# Rubocop Lint module
module Lint
# SwallowException class for enforcing correct exception handling
class SwallowedException < RuboCop::Cop::Cop
# determines whether exceptions are being handled correctly
def on_resbody(node)
unless n... | true |
14acea51763c325adcc48b664266a3c3b1e90b5a | Ruby | dotdoom/net-ssh-open3 | /lib/net-ssh-open3.rb | UTF-8 | 22,134 | 2.59375 | 3 | [] | no_license | require 'shellwords' # String#shellescape
require 'thread' # ConditionVariable
require 'net/ssh' # Monkeypatching
require 'stringio' # StringIO for capture*
class Class
unless method_defined?(:alias_method_once)
private
# Create an alias +new_method+ to +old_method+ unless +new_method+ is already defined.
... | true |
b0ba0b4d6e7328dd87f358498381c879cef783d3 | Ruby | PauloHenrique222/TesteRspec | /spec/lib/calculator_spec.rb | UTF-8 | 563 | 3.203125 | 3 | [] | no_license | require 'calculator'
describe Calculator do
describe "#add" do
it "adds two numbers / no failure" do
expect(subject.add(10, 5)).to eq(15)
end
it "adds two numbers / with failure" do
expect(subject.add(10, 4)).not_to eq(15)
end
end
describe "#factorial"... | true |
40527063aa0c6bef645c35348c76bf741e29cd63 | Ruby | EmilianoFusaro/GestioneProduzione_Dielle | /funzioni_caricoX.rb | UTF-8 | 16,332 | 2.546875 | 3 | [] | no_license | #Stessa Funzione Ma Con Ricerca In Hash Non Eseguendo Query Con Molti Filtri e Dati è risultata più lenta della query sopra (a casa ma in ufficio è più veloce)
#self.fase2=lista_reparti.detect{|f| f[:codice]=="#{self.ciclost[1]}"}
def TrovaCicloX(cod,padre,codbarra,varianti,islaccato,lista_cicli) #---Funzione... | true |
d32358497d72eddd3512822200d83876af3b990e | Ruby | kenosuda4/enjoy-ruby | /chapter-6/while3.rb | UTF-8 | 303 | 3.484375 | 3 | [] | no_license | sum = 0
i = 1
while sum < 50
sum += i
i += 1
end
puts sum
=begin
while2と違い、条件がiではなくsumになっている。
sumが50より小さい間繰り返すという条件
sumが50を超える時にiが幾つになっているかわからないの = for文は使いづらい
=end | true |
a32b032530fdd650a0fca647aba3408a037ed195 | Ruby | tsmango/rand | /lib/rand.rb | UTF-8 | 369 | 2.96875 | 3 | [
"MIT"
] | permissive | class Array
def rand(size = 1)
return nil if size < 1
if size == 1
return self[Kernel.rand(self.length)]
else
random_candidates = self.collect
size = self.length if size > self.length
(0..(size - 1)).to_a.collect do
random_candidates.delete_at(Kernel.rand(random... | true |
4046373de93a83230bd3e075ff12468cf2e6c208 | Ruby | pulkitsharma07/modown | /lib/modown/options.rb | UTF-8 | 1,584 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'optparse'
module Modown
# This class handles command line options
class Options
def initialize
@options = { input: nil, count: 1, format: '*' }
# Dont know how to do case-insensitive glob matching
@formats_glob = {}
@formats_glob['3ds'] = '*.3[Dd][Ss]'
@formats_glob['ma... | true |
2eb3b09f31069687e49132df8c2be36d5874f854 | Ruby | NotBadCode/SPOJandTimus | /SPOJ/Ruby/GETCORR.rb | UTF-8 | 99 | 3.34375 | 3 | [] | no_license | f=0
6.times do
a=gets.to_i
if a%42==0
f+=1
end
end
if f==6
puts "Yes"
else
puts "No"
end | true |
d1d18a241c3a21113faff6226c1f669136534637 | Ruby | mcolyer/config | /lib/config/patterns/directory.rb | UTF-8 | 930 | 2.71875 | 3 | [
"MIT"
] | permissive | module Config
module Patterns
class Directory < Config::Pattern
desc "The full path of the directory"
key :path
desc "The user that owns the directory"
attr :owner, nil
desc "The group that owns the directory"
attr :group, nil
desc "The octal mode of the directory, su... | true |
fe5ee227825356885f650a79600c3929d4cbb953 | Ruby | forkollaider/notepad | /read.rb | UTF-8 | 1,425 | 2.765625 | 3 | [] | no_license | if (Gem.win_platform?)
Encoding.default_external = Encoding.find(Encoding.local_charmap)
Encoding.default_internal=__ENCODING__
[STDIN,STDOUT].each do |io|
io.set_encoding(Encoding.default_external,Encoding.default_internal)
end
end
require_relative 'post.rb'
require_relative 'link.rb'
require_relative 'm... | true |
10d32478889eed193d87b3d70c6fe03c60bbe4d6 | Ruby | Gerula/interviews | /LeetCode/remote/house_robber.rb | UTF-8 | 1,310 | 3.515625 | 4 | [
"MIT"
] | permissive | # You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into ... | true |
e06b9b30baf7d0cd2d29132b3c0c71b5274624eb | Ruby | gardenzjd/JavaScriptCore-android-build | /script/prepare-icu.rb | UTF-8 | 626 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "pathname"
require "fileutils"
require "shellwords"
require_relative "lib/common"
class PrepareIcuScript
def main
make_include_dir
end
def make_include_dir
puts "make_include_dir"
Dir.chdir(icu_dir.to_s)
include_dir = icu_gen_dir + "include"
if include_dir.exist?
includ... | true |
72c454fd1046bebe8805e080f1be63a9560df03a | Ruby | kasia-kaleta/imdb_lab | /models/star.rb | UTF-8 | 864 | 3.328125 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Star
attr_reader :id
attr_accessor :first_name, :last_name
def initialize(options)
@id = options['id'].to_i if options['id']
@first_name = options['first_name']
@last_name = options['last_name']
end
def save()
sql = "INSERT INTO stars
(
first_name, last_name... | true |
25bfee76f2d6b097d95a4982fb1a285df5e34715 | Ruby | MMathew93/Ruby-Hangman | /game.rb | UTF-8 | 3,067 | 3.53125 | 4 | [] | no_license | # frozen_string_literal: true
require_relative 'display_text'
require_relative 'game_saver'
require 'yaml'
# Class for the game
class Game
attr_accessor :guessed_letters, :random_word, :hidden_word, :misses
include DisplayText
include GameSaver
def initialize
@player_option = nil
@random_word = nil
... | true |
8029973494bb6e20678c6b055396bb8122d64ca0 | Ruby | Try2Code/RussianNameGenerator | /getName | UTF-8 | 322 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "./lib/RussianNameGenerator.rb"
if 0 == ARGV.size then
ethnic = 'ALL'
else
ethnic = ARGV[0]
unless RussianNameGenerator::VALID_ETHNICS.include?(ethnic) then
warn "Could not find ethnic:#{ethnic}!"
exit(1)
end
end
ng = RussianNameGenerator.new
ng.print(12,ethnic)
#vim:ft=r... | true |
aebc4228f03ca65c16dd9f91c08c702c27646c41 | Ruby | jdcarey128/futbol | /lib/game_teams_tackles_manager.rb | UTF-8 | 720 | 2.71875 | 3 | [] | no_license | class GameTeamsTacklesManager < GameTeamsManager
attr_reader :game_teams, :stat_tracker
def initialize(game_teams, stat_tracker)
super(game_teams, stat_tracker)
end
def team_tackles(season)
game_teams_by_season(season).reduce(Hash.new(0)) do |team_season_tackles, game|
team_season_tackles[game.t... | true |
bd993e1037233ff622a2aa97f3c15b62e34b3085 | Ruby | bobjflong/mousey_revenge | /test/test_edible_sprite.rb | UTF-8 | 622 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'helper'
class TestObject
SPRITE_PATH = 'foo'
include MouseyRevenge::EdibleSprite
def grid
MouseyRevenge::Grid.new(width: 5, height: 5, square_size: 10)
end
def position
{ x: 0, y: 0 }
end
def uuid
'1234'
end
end
class TestEdibleSprite < Test::Unit::TestCase
setup do
@edi... | true |
6945770d11f0d086b686a281a56e857365fc435d | Ruby | BivinsBrothers/castnotice | /app/models/incomplete_order.rb | UTF-8 | 1,177 | 2.53125 | 3 | [] | no_license | require 'mysql_connection'
IncompleteOrder = Struct.new(:order_id, :email, :code, :quantity) do
def self.all(completed_order_ids=[])
conn = MysqlConnection.create
completed_order_ids.unshift(0)
ids = completed_order_ids.map(&:to_s).join(", ")
sql = <<-SQL
select o.order_id, o.user_email, od.mod... | true |
4a64e430c53c2905ef3ba0927c00a426e8bdbf94 | Ruby | mouseed/zucker | /lib/zucker/array.rb | UTF-8 | 408 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'zucker'
module Zucker Array = true end
class Array
def ^(other) # TODO: more efficient
(self - other) +
(other - self)
end
# can take an argument & block to be Rails compatible
def sum(identity = 0, &block)
# inject(:+)
if block_given?
map(&block).sum( identity )
else
... | true |
232363f9516e1bb44f87a10e47491d0ab33c81f4 | Ruby | Srossmanreich/Srossmanreich.github.io | /blogs/test2.rb | UTF-8 | 326 | 3.96875 | 4 | [
"MIT"
] | permissive |
def fibonacci(number)
if number == 0 || number == 1
return number
else
(fibonacci(number - 1) + fibonacci(number - 2))
end
end
puts fibonacci(0)
puts fibonacci(1)
puts fibonacci(2)
puts fibonacci(3)
puts fibonacci(4)
puts fibonacci(5)
puts fibonacci(6)
puts fibonacci(7)
puts fibonacci(8)
puts fibonacci(9)
... | true |
09d940f75e14879aa3dec25f2e1b623362cb5a1c | Ruby | tschaffer1618/date_night | /lib/binary_search_tree.rb | UTF-8 | 942 | 3.4375 | 3 | [] | no_license | class BinarySearchTree
attr_reader :head_node
def initialize
@head_node = nil
end
def insert(score, movie)
if @head_node.nil?
@head_node = Node.new({score => movie})
else
@head_node.insert(score, movie)
end
depth_of(score)
end
def depth_of(score, node = @head_node)
@de... | true |
ef814d0c22b8fc4e2e6ca0d719e6f3db34cb0eb0 | Ruby | jesus-sayar/contributors_mapping | /app/models/dashboard.rb | UTF-8 | 466 | 3.0625 | 3 | [
"MIT"
] | permissive | class Dashboard
attr_accessor :all_projects, :some_projects, :other_projects
def initialize
@all_projects = Project.all
if @all_projects.any?
@some_projects, @other_projects = @all_projects.each_slice((@all_projects.size/2.0).round).to_a
else
@some_projects = @other_projects = []
end
... | true |
6f8050ac63e5e0438dea3d0b9dfa9299902db4cc | Ruby | szabokaroly/prep-course-exercises | /loop1/loop1.rb | UTF-8 | 209 | 3.59375 | 4 | [] | no_license |
loop do
puts "Just keep printing..."
break
end
# OR
i = 0
loop do
if i < 1
puts 'Just keep printing...'
i += 1
end
break if i == 1
end
# OR
1.times do
puts "Just keep printing..."
end
| true |
ffabbd689d012c9c82d2356ee1a6af1416ada558 | Ruby | williampowell92/bookmark-manager2 | /spec/commander_data_spec.rb | UTF-8 | 1,754 | 2.765625 | 3 | [] | no_license | require_relative '../lib/commander_data'
describe CommanderData do
let(:bookmark_class) { double :bookmark_class, new: nil}
let(:connection) { double :database_connection, exec: rs }
let(:id) { '1' }
let(:title) { 'Google' }
let(:url) { 'http://www.google.com' }
let(:incorrect_title) { 'Boogle' }
let(:in... | true |
b04124020789981c591759de98247abedc9913af | Ruby | moneyadviceservice/dough | /lib/dough/forms/object_error.rb | UTF-8 | 1,217 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'active_model/model'
module Dough
module Forms
class ObjectError
include ActiveModel::Model
attr_accessor :object, :field_name, :message, :counter, :prefix
def ==(other)
object == other.object && field_name == other.field_name &&
counter == other.counter && message ==... | true |
7fdcc0c1738f0aec207bc1f8dbe31a570c8cc74f | Ruby | shi-mo/yukicoder | /0312.rb | UTF-8 | 291 | 3.765625 | 4 | [] | no_license | require 'prime'
n = gets.to_i
if Prime.prime?(n)
puts n
exit 0
end
if 0 == n % 3
puts 3
exit 0
end
if 0 == n % 4
puts 4
exit 0
end
if 0 == n % 2 && Prime.prime?(n/2)
puts n/2
exit 0
end
Prime.each(n) do |i|
next if 2 == i
next if 0 != n % i
puts i
exit 0
end
| true |
624f43e5c79c3be08fbcaeef8c9fc0a238e4866d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/cac65b405d9449d3a31a9179879b049d.rb | UTF-8 | 632 | 3.1875 | 3 | [] | no_license | class Complement
DNA_TO_RNA_COMPLEMENTS = {'G' => 'C',
'C' => 'G',
'T' => 'A',
'A' => 'U'}
DNA_NUCLEOTIDES = 'GCTA'
RNA_NUCLEOTIDES = 'CGAU'
def self.of_dna(dna)
raise ArgumentError, 'Argument has not DNA nucleotides' ... | true |
ad9209334b46f2e3c81d94e2713643eec39ee4ce | Ruby | RinatYaushev/Chat | /app/patterns/decorator.rb | UTF-8 | 794 | 3.765625 | 4 | [] | no_license | module Decorator
class ItemDecorator
def initialize item
@item = item
end
end
class SwordDecorator < Decorator::ItemDecorator
def price
@item.price * 3
end
def description
@item.description + 'Sword'
end
end
class BowDecorator < Decorator::ItemDecorator
def pri... | true |
53bf3223ea4a5f6434e0ec7f40c44eb9b446767c | Ruby | domke159/Hangman | /lib/hangman.rb | UTF-8 | 320 | 3.1875 | 3 | [] | no_license | require_relative '../lib/dictionary.rb'
require_relative '../lib/game.rb'
loop do
puts "\nWelcome to the Hangman Game \n"
puts "\nStart new game (N) / Load previous game (L)?\n\n"
gets.chomp.capitalize == 'N' ? Game.new : Game.load_game
puts "\nPlay again (Y/N)?"
exit unless gets.chomp.capitalize == 'Y'
end
| true |
bd63acac8c3f791fd6e9378c966dd9951e7d8c1d | Ruby | rafaj777225/Cursocodeacamp | /Newbie/classComputer.rb | UTF-8 | 587 | 3.8125 | 4 | [] | no_license | =begin
Crea la clase Computer y agrega un método para cambiar y ver el
color de la computadora.
#test
mac.color = "Platinum"
p mac.color
#=>"Platinum"
=end
#crea clase Computer
class Computer
#metodo de objeto para modificar o leer atributos
attr_accessor :color
#metodo constructor
def initialize(color)
... | true |
0be555c5bb5dec894ceca8865be53bdad6fc4eba | Ruby | DrDhoom/RMVXA-Script-Repository | /Vlue/after_battle_events.rb | UTF-8 | 2,468 | 2.59375 | 3 | [
"MIT"
] | permissive | #After Battle Events v1.0
#----------#
#Features: Process Troop Events when the player wins, escapes, or is defeated by setting a page
# with the appropriate switch as it's conditional.
#
#Usage: Set your switches, set up your pages, run hog wild.
#
# Victory is called after all enemies are dead an... | true |
77db3fb905b574b974fbf2114d38be314a172275 | Ruby | wiggles66/oo-student-scraper-online-web-sp-000 | /lib/animal.rb | UTF-8 | 90 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Animal
def initialize
end
def self.new_pets(pets)
puts pets
end
end
| true |
8c3089b47541231b54171ca88e4fd0a1e13b8021 | Ruby | brendanthomas1/strategy_pattern | /app/models/motorcycle.rb | UTF-8 | 200 | 3.21875 | 3 | [] | no_license | class Motorcycle
attr_reader :top_speed
def initialize(make, top_speed)
@top_speed = top_speed
end
def accelerate_to_max_speed
"VROOOM! Hit #{top_speed} on my motorcycle!"
end
end
| true |
3c226face6463a93ee172249bf557a642065a2ac | Ruby | betasve/notes-cli-app | /lib/tag.rb | UTF-8 | 1,097 | 3.25 | 3 | [] | no_license | class Tag
attr_accessor :id, :name, :notes
def initialize(attrs={})
@id = attrs["id"]
@name = attrs["attributes"]["name"]
if attrs.has_key?("notes") && attrs["notes"]
@notes = attrs["notes"].map do |note|
{
id: note["id"],
title: note["attributes"]["title"]
}... | true |
b458d441e7ef0370d458634d9023e959926f9aa8 | Ruby | VasaStulo/Ruby | /ruby/Lec5/bin/method_oviriding.rb | UTF-8 | 372 | 3.765625 | 4 | [] | no_license | class Parent
def hello
#SELF ссылается на элемент класса(а-ля this в жабе)
puts "Hello,my child! From #{self}"
end
def to_s
'parent'
end
end
class Child < Parent
def hello
puts"hello from the Child"
end
def to_s
'child'
end
end
parent = Parent.new
parent.hello
child =Child.new
child.hello
pu... | true |
864f4a4e5c5137cce2ee0b8c65e165a21ea0a562 | Ruby | substantial/sous-chef | /lib/sous-chef/node_builder.rb | UTF-8 | 529 | 2.59375 | 3 | [
"MIT"
] | permissive | class SousChef::NodeBuilder
include SousChef::NodeHelpers
def initialize(name, collection_hash)
@name = name
@collection_hash = collection_hash
end
def build
if node?(@collection_hash)
SousChef::Node.new(@name, @collection_hash)
else
build_nodes
end
end
private
def buil... | true |
10366028fc0b18b0e59de288c041ea3823ecb125 | Ruby | paulonegrao/codecore_out2015 | /day_1/1019fb.rb | UTF-8 | 181 | 3.6875 | 4 | [] | no_license | for i in 1..100
if i % 3 == 0 || i % 5 == 0
print "#{i} is a "
if i % 3 == 0
print "FIZZ"
end
if i % 5 == 0
print "BUZZ"
end
puts ""
end
end
| true |
a42717145ce0d73b09d42d5523650d944244b8cc | Ruby | juani-garcia/POO_Ruby | /guias/tp10/ej1/html_tester.rb | UTF-8 | 1,019 | 3.15625 | 3 | [] | no_license | require_relative 'plain_text'
require_relative 'bold_text'
require_relative 'italic_text'
require_relative 'link_text'
text = PlainText.new 'Hola'
bold_text = BoldText.new(text)
italic_text = ItalicText.new(text)
puts bold_text # <b>Hola</b>
puts italic_text # <i>Hola</i>
bold_italic_text = BoldText.new(italic_text)
p... | true |
d5c06021d6458c0404dc51eae4b05ed5577aaa53 | Ruby | pzol/deterministic | /spec/readme_spec.rb | UTF-8 | 1,129 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
include Deterministic::Prelude::Result
Success(1).to_s # => "1"
Success(Success(1)) # => Success(1)
Failure(1).to_s # => "1"
Failure(Failure(1)) # => Failure(1)
Success(1).fmap { |v| v + 1} # => Succe... | true |
911b7c33358143e16d7057b1ce74dc9a63675c1f | Ruby | gl1002660/introtoprograming | /pythag therom calc.rb | UTF-8 | 101 | 3.46875 | 3 | [] | no_license | puts "a?"
a = gets.to_f
puts "b?"
b = gets.to_f
x = (a**2) + (b**2)
x = Math.sqrt(x)
puts "c:"
puts x | true |
3dabcea542ab0b2d618322a0c6d627b72ef18c68 | Ruby | kkozmo/toggler | /spec/models/user_spec.rb | UTF-8 | 1,680 | 2.734375 | 3 | [] | no_license | require 'rails_helper'
describe User do
let(:user) { FactoryGirl.build(:user) }
it "should have a valid name and email" do
expect(user.valid?).to eq(true)
end
it "name should be present" do
user.name = (' ')
expect(user.valid?).to eq(false)
end
it "email should be present" do
... | true |
be31d88c0d15759e693046bccc1e54015e736442 | Ruby | thibaudgg/rspactor | /lib/formatters/rspec_formatter.rb | UTF-8 | 657 | 2.515625 | 3 | [
"MIT"
] | permissive | module RSpecFormatter
def rspactor_title
"RSpec results"
end
def rspactor_message(example_count, failure_count, pending_count, duration)
message = "#{example_count} examples, #{failure_count} failures"
if pending_count > 0
message << " (#{pending_count} pending)"
end
message << "\n... | true |
b9a891d9e054114c9d14fc3d89940864084648ec | Ruby | dfitzgerald7/tweet-shortener-online-web-prework | /tweet_shortener.rb | UTF-8 | 824 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
# Write your code here.
def dictionary
my_hash = {"hello" => "hi", "to" => "2", "two" => "2", "too" => "2", "for"=> "4", "four"=> "4", "be" => "b","you" => "u", "at" => "@", "and" => "&"}
end
def word_substituter(tweet)
tweet_array = tweet.split
dictionary_array = dictionary
long_words = dict... | true |
870442b97051186434952d38c2785679e189fcf0 | Ruby | emwads/advent-of-code | /day-09/day9.rb | UTF-8 | 1,580 | 3.28125 | 3 | [] | no_license | class Day9
attr_accessor :num_players, :last_marble, :marbles, :player_scores, :current_player, :marble_to_play, :current_marble_idx
def initialize(num_players, last_marble)
@last_marble = last_marble
@num_players = num_players
@current_player = 0
@marble_to_play = 0
@current_marble_idx = 0
... | true |
b9504c48a8ad18304702afdb946b09643dd2ad84 | Ruby | stogashi146/RubyPractice | /lankc_dict_step2.rb | UTF-8 | 710 | 3.625 | 4 | [] | no_license | # n
# s_1
# ...
# s_n
# m
# p_1 a_1
# ...
# p_m a_m
# S
#
# 期待する出力
# S の受けた合計ダメージを出力してください。
# 末尾に改行を入れ、余計な文字、空行を含んではいけません。
#
# 条件
# すべてのテストケースにおいて、以下の条件をみたします。
#
# 入力例1
# 2 人数
# Kirishima
# Kyoko
# 2 攻撃回数
# Kyoko 受けた人 1 ダメージ数
# Kyoko 2
# Kyoko
#
# 出力例1
# 3
# 人数
n = gets.to_i
# 登場人物
humans = {}
n.times do
name = gets... | true |
8dc7dd99277351c43a85d3fa05636f69ae6795f7 | Ruby | KennethCNg/Software_Prep | /Codefight/Linked_list.rb | UTF-8 | 1,219 | 3 | 3 | [] | no_license | Remove K from List
def removeKFromList(l, k)
return nil if l.nil?
fast_node = l.next
slow_node = l
until slow_node.value != k
temp = slow_node.next
slow_node.next = nil
slow_node = temp
l = slow_node
return l if slow_node.nil?
fast_node = fast_no... | true |
b523c7d89c99d6072c7d5c0d53c9014e0a0a677d | Ruby | jnf/C3Projects--TaskListRails | /db/seeds.rb | UTF-8 | 1,233 | 2.875 | 3 | [] | no_license | def random_time
Time.at(rand * Time.now.to_i)
end
tasks = [
{ name: "The First Task", description: "You should do this one first.", completed_at: random_time },
{ name: "Go to Brunch", description: "Vittles is pretty good. Or Lola, if you got paid this week." },
{ name: "Go to Lunch", description: "Rocco's or ... | true |
83cdb7d192f034625198c5fc3f7c761e0872317f | Ruby | Corsomk312/phase-0 | /week-4/smallest-integer/my_solution.rb | UTF-8 | 771 | 4.15625 | 4 | [
"MIT"
] | permissive | # Smallest Integer
# I worked on this challenge [by myself, with: ].
# smallest_integer is a method that takes an array of integers as its input
# and returns the smallest integer in the array
#
# +list_of_nums+ is an array of integers
# smallest_integer(list_of_nums) should return the smallest integer in +li... | true |
91a8af25670db0eb60a22e26f9662e25c2792104 | Ruby | ryanai3/repo | /rgit.rb | UTF-8 | 9,826 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "rubygems"
require 'thor'
require_relative './Repo.rb'
require 'pathspec'
require 'pty'
require 'pathname'
#This Class functions as the CL utility for Rgit - handles
#creating and calling Repo's in subdirectories
#and user input
class Rgit < Thor
no_commands {
def format_options(opti... | true |
d3b05c65cfc10b953640d5febc5b8fe5b54f74ed | Ruby | vokomod/RubyLessons | /lesson23/app.rb | UTF-8 | 1,774 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'sinatra'
get '/' do
erb "Hello! <a href=\"https://github.com/bootstrap-ruby/sinatra-bootstrap\">Original</a> pattern has been modified for <a href=\"http://rubyschool.us/\">Ruby School</a>"
end
get '/about' do
erb :about
end
get '/visit' do
erb :visit
end
get '/contacts' do
erb :cont... | true |
c4e277604ea19ceb78567c70b185ae264a273ff8 | Ruby | singsang2/ruby-enumerables-hash-practice-green-grocer-lab-prework | /grocer.rb | UTF-8 | 1,245 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def consolidate_cart(cart)
hash_cart = Hash.new
cart.each do |item|
#binding.pry
hash_cart[item.keys[0]] = item.values[0]
if hash_cart[item.keys[0]][:count] != nil
hash_cart[item.keys[0]][:count] += 1
else
hash_cart[item.keys[0]][:count] = 1
end
end
hash_cart
end
d... | true |
13698021f9b0dfaa40d0dae042be075adb956305 | Ruby | ErdemOzgen/leetcode | /ruby/1-Two-Sum.rb | UTF-8 | 166 | 3.28125 | 3 | [
"MIT"
] | permissive | def two_sum(nums, target)
hash = {}
nums.each_with_index do |num, idx|
return [hash[num], idx] if hash.key? num
hash[target - num] = idx
end
nil
end
| true |
5b364b032cc6d898e95ee4ef8b2e650540f95c43 | Ruby | KenDuyNguyen/AppAcademy_Projects | /W2D2/piece.rb | UTF-8 | 2,177 | 3.9375 | 4 | [] | no_license | require "singleton"
class Piece
def initialize(color, pos, board)
@pos = pos
@color = color
@board = board
end
def to_s
" o "
end
end
class NullPiece < Piece
include Singleton
end
class King < Piece
include SteppingPiece
def initialize(color, pos, value = 100)
super
@value... | true |
981628b5e1348425eb538d58dbf51063301f2af5 | Ruby | milandhar/mod5-project-backend | /app/models/project.rb | UTF-8 | 4,044 | 2.53125 | 3 | [] | no_license | require 'dotenv/load'
class Project < ApplicationRecord
belongs_to :organization, optional: true
belongs_to :theme, optional: true
belongs_to :country, optional: true
has_many :user_starred_projects
has_many :users, through: :user_starred_projects
validates :title, presence: true
validates :image_url, pr... | true |
dc69ca99328f32f88b5eba7c8bac817544f15fe5 | Ruby | imsaar/saarisms | /rmu-2010/lib/text_edit_imsaar.rb | UTF-8 | 816 | 3.0625 | 3 | [] | no_license | # Ruby Mendicant University Entrance Exam Solution by Ali Rizvi
# http://github.com/rmu/rmu-entrance-exam-2010
module TextEditor
class Document
def initialize
@contents = ""
@commands = []
@reverted = []
end
def contents
@contents = ""
@commands.each {|command| command.call... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.