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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cf00c18c781ff929723cc84caa235c990e8b5e90 | Ruby | mmabraham/Games | /guessing-game/guessing_game.rb | UTF-8 | 612 | 3.78125 | 4 | [] | no_license | def guessing_game
target = rand(1..100)
count = 1
puts "guess a number"
loop do
guess = gets.chomp.to_i
guess == target ? break : puts(guess)
guess > target ? puts(" too high") : puts(" too low")
count += 1
end
puts "You got it in #{count} guesses"
puts target
end
def shuffle_file(inpu... | true |
66df2d95c4b05df4e9e4083c0a844b8dc2974913 | Ruby | guilffer/kanbangit | /lib/kanbangit/item.rb | UTF-8 | 881 | 2.859375 | 3 | [] | no_license | require 'yaml'
module Kanbangit
class Item
attr_reader :name
def initialize(name, env)
@name = name
@env = env
create_itemfile_if_necessary
load_itemfile
end
def create_itemfile_if_necessary
unless File.exists?(itemfile_path)
@data = {'column' => 'to... | true |
74f52c21bcd4daa886212d2e74813832b1dcb3b0 | Ruby | jayantsharma/rubyScripts | /problem1.rb | UTF-8 | 448 | 3.390625 | 3 | [] | no_license | def solution(word)
possibleAnagrams = word.chars.to_a.permutation.map(&:join)
answer = Array.new
file = File.new("wl.txt", "r")
lines = file.readlines
lines.each do |line|
word = line.chomp
possibleAnagrams.include?(word)
answer.push(word) if possibleAnagrams.include?(word)
end
return answer
end
puts ... | true |
34696cc759fd8fb4f117211922eb8388fb25a3a5 | Ruby | MelissaKroese/ruby-quizzes | /quiz3.rb | UTF-8 | 147 | 4 | 4 | [] | no_license | puts "What is your name?"
name=gets.chomp
if name == "Alice"
puts "Hi #{name}"
elsif name == "Bob"
puts "Hi #{name}"
else puts "Hi there"
end
| true |
c8a917974f7b9b231bf6213632537fa6ac2082c6 | Ruby | psyomn/wlog | /lib/wlog/commands/fetch_git_commits_standard.rb | UTF-8 | 731 | 2.5625 | 3 | [] | no_license | require 'wlog/commands/commandable'
require 'wlog/commands/fetch_git_commits'
require 'wlog/tech/git_commit_parser'
module Wlog
# We don't set the repo and author - get it directly from keyvalue
# Use the other git fetcher if you want something more configurable
# @author Simon Symeonidis
class FetchGitCommitsStandard ... | true |
1b7af91e81a287634728b6338e22d64ae6e991b3 | Ruby | bbensky/pine_ruby_book_exercises | /ch11_reading_writing_plus/try_more_yaml.rb | UTF-8 | 446 | 2.921875 | 3 | [] | no_license | require 'yaml'
test_array = [['Age In Years', 37],
['Age In Years (text)', '37'],
['Fav Color', 'Green'],
['Likes Nachos', true],
['Likes Whiskey', 'true']]
test_string = test_array.to_yaml
filename = 'description.text'
File.open filename, 'w' do |f|
f.write... | true |
4e7cb40b554e7d39526e3d39fa643f67fc8adad2 | Ruby | aydarsh/projecteuler | /problem91.rb | UTF-8 | 347 | 3.125 | 3 | [] | no_license | require "matrix"
def num_right_triangles n
(0..n).to_a.
repeated_permutation(2).to_a.drop(1).
combination(2).
map{|el| [Vector.elements(el[0]), Vector.elements(el[1])]}.
select do |el|
el[0].inner_product(el[1])==0 or
el[0].inner_product(el[1]-el[0])==0 or
el[1].inner_product(el[1]-el[0])==0
end.size
en... | true |
3925c755768c2c239f49a20c788bc2c36c5d900c | Ruby | jagaapple/string_foundation.rb | /lib/string_foundation/like.rb | UTF-8 | 664 | 3.34375 | 3 | [
"MIT"
] | permissive | # ==============================================================================
# LIB - STRING FOUNDATION - LIKE
# frozen_string_literal: true
# ==============================================================================
require_relative "convertible"
class String
# Check whether a string is an integral number.
... | true |
c77813161bb9431dac4103e7a5e815df820ceb2e | Ruby | PianoFF/anagram-detector-london-web-102819 | /lib/anagram.rb | UTF-8 | 488 | 3.671875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Your code goes here!
require "pry"
class Anagram
attr_accessor :word
def initialize (word)
@word = word
end
def match(array)
word_letters = word.chars
array.select do |word|
word.chars.sort == word_letters.sort
end
end
end
# def select(array)
# ... | true |
ac1db6abd15bcb0365b529ce141ee12eccb33d23 | Ruby | Royathe/Viope-Ruby-Workspace | /Viope/Luku3.rb | UTF-8 | 2,798 | 3.296875 | 3 | [] | no_license |
#TEHTÄVÄ 5
pelaaja = 0
tieto = 0
valinta = 0
while valinta < 4
puts "1: Torakka 2: Jalka 3: Ydinpommi 4: lopeta"
puts "Valitse (1-4):"
valinta = gets.to_i
tval = rand(3) + 1
unless valinta == 4
if valinta == tval
puts "Valitsitte saman, tasapeli."
elsif valinta == 1
print "... | true |
7ecdc7ca47e839d6b64ef4b3954767779a70a40c | Ruby | INTJBrandon/oo-tic-tac-toe-bootcamp-prep-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,738 | 4.09375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class TicTacToe
def initialize(board = nil)
@board = board || Array.new(9, " ")
end
WIN_COMBINATIONS = [
[0,1,2], # Top Row Win
[3,4,5], # Middle Row Win
[6,7,8], # Bottom Row Win
[0,3,6], # First Column Win
[1,4,7], # Second Column Win
[2,5,8], # Third Column Win
[0,4,8], # Diagonal Win from Le... | true |
9639f5398efae771f8587c77537401ecdaea1db6 | Ruby | kelvin8773/data-algorithm | /6-sorting-challenges/ex8.8-find-the-duplicates.rb | UTF-8 | 1,583 | 3.625 | 4 | [
"MIT"
] | permissive | require 'benchmark/ips'
def duplicates(arr1, arr2)
res = arr2.clone
arr1.each do |x|
res.delete_at(res.index(x))
end
res.sort!
end
def duplicates_e(arr1, arr2)
map1 = arr1.each_with_object(Hash.new(0)) { |num, map| map[num] += 1 }
map2 = arr2.each_with_object(Hash.new(0)) { |num, map| map[num] += 1 }... | true |
540ab2344effdce6660eac85eb1b735b4f3d3a1b | Ruby | maxdunn210/MaxWiki | /vendor/plugins/drag_and_drop_media/app/models/drag_and_drop_media_model.rb | UTF-8 | 2,487 | 2.671875 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | require 'xmlrpc/client'
require 'rexml/document'
require 'open-uri'
class DragAndDropMediaModel
attr_reader :display_name, :tags, :user, :page, :per_page, :on
# initialize client instance, and set parameters to nil
# note that success does not indicate that api_key is ok
def initialize( name, per_page =... | true |
702600015d6c4546ea5282398815f65c4fcf0136 | Ruby | miraissan/dxruby_blocks | /block_collision/coll_circle/atari_en6.rb | UTF-8 | 1,528 | 3.15625 | 3 | [
"Unlicense"
] | permissive | # 衝突判定の自作(円);atari_array(jibun, array) (判定相手が配列)
# 衝突の有/無で ぶつかった最初のオブジェクト/nil
require 'dxruby'
def atari?(jibun, aite)
x0 = jibun.x
rad_x0 = jibun.image.width / 2
cen_x0 = x0 + rad_x0
y0 = jibun.y
rad_y0 = jibun.image.height / 2
cen_y0 = y0 + rad_y0
x1 = aite.x
rad_x1 = aite.image.width ... | true |
e07a2aff55101ff6f3fe6efe030268390f44c4cd | Ruby | ngoctoandhv/Ruby_Basic | /03. Ruby - Methods/01.Method-arguments.rb | UTF-8 | 388 | 3.515625 | 4 | [] | no_license | def calculate_value(x,y)
x + y
end
def calculate_value(value='default', arr=[])
puts value
puts arr.sum
end
def calculate_value(x,y,*otherValues)
puts otherValues
end
def accepts_hash(arguments)
# print out what it received
print "got: ", arguments.inspect
end
# Ruby 2.0
def c... | true |
b30808804e85d5e535aa2236f3fdd68ebf2a5284 | Ruby | compwron/knowgame | /lib/round.rb | UTF-8 | 825 | 3.796875 | 4 | [] | no_license | class Round
NEXT = 'next'
DONE = 'done'
attr_reader :filename, :remaining_tries
def initialize(filename, remaining_tries)
@filename = filename
@remaining_tries = remaining_tries
@next_round = @game_over = @correct = false
@wrong_guesses = 0
end
def guess(guessed_filename)
correct = @... | true |
c4f2318b5b9594fc58b7c4a8e90dd9294de89487 | Ruby | Dmitry-White/Ruby-Task | /script.rb | UTF-8 | 3,683 | 3.125 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'curb'
require 'csv'
#------------------ Reading Input -------------------------------
ARGC = ARGV.length
if ARGC < 2 or ARGC > 2
puts "Usage: ruby <input_file> <output_file> <URL>"
abort
end
output = ARGV[0]
address = ARGV[1]
puts 'Input received. Getting source html file.'
#--------... | true |
58283284a273d5393fd46c3177740bde4e41ccc0 | Ruby | XanderStrike/artist-fanart-finder | /lib/google.rb | UTF-8 | 446 | 2.703125 | 3 | [] | no_license | class GoogleFetcher < Base
def initialize(fetcher)
@fetcher = fetcher
end
def fetch(artist)
get_art_from_google(artist)
end
private
def get_art_from_google(artist)
Google::Search::Image.new(query: "#{artist} music", image_size: Configuration.preferred_sizes, image_type: :photo).each do |image... | true |
c6a47a0876de3aed4ff726635c1d33254a3d4fb9 | Ruby | chrislabarge/event-manager | /event_manager.rb | UTF-8 | 424 | 2.984375 | 3 | [] | no_license | require "csv"
puts "EventManager Initialized"
contents = CSV.open "event_attendees.csv", headers: true, header_converters: :symbol
contents.each do |row|
name = row[:first_name]
zipcode = row[:zipcode]
if zipcode.nil?
zipcode = "00000"
elsif zipcode.length < 5
zipcode = zipcode.rjust 5, "0"
elsif zipcode.l... | true |
a92f0229bd034c7fbee8618772c6a57d558cb247 | Ruby | Stella-Nthenya/Ruby-Object-Oriented-Programming-Exercises | /120_oop_exercises/basics_accessor_methods/guarenteed_formatting.rb | UTF-8 | 365 | 4.53125 | 5 | [] | no_license | # Using the following code, add the appropriate accessor methods so that @name is capitalized upon assignment.
class Person
attr_reader :name
def name=(name) # manually write the setter method
@name = name.capitalize
# format upon assignment
end
end
person1 = Person.new
person1.name = 'eLiZaBeTh'
puts ... | true |
937cddc8a961ee1124bfefd41ef8648d39c4ead2 | Ruby | jcoyne/rdf | /lib/rdf/model/term.rb | UTF-8 | 2,248 | 3.203125 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | module RDF
##
# An RDF term.
#
# Terms can be used as subjects, predicates, objects, and contexts of
# statements.
#
# @since 0.3.0
module Term
include RDF::Value
include Comparable
##
# Compares `self` to `other` for sorting purposes.
#
# Subclasses should override this to prov... | true |
99dca9f65cc02b7983180d81f64d959748394267 | Ruby | rsmease/ruby-misc | /greet.rb | UTF-8 | 111 | 3.421875 | 3 | [] | no_license | def greet(name)
if name.nil? or name === ""
return nil
else
return "hello " + name + "!"
end
end
| true |
b146231f20ddda1647046841e6e6a5dc12795171 | Ruby | vikkanaev/mkdev.me | /lib/movie_industry/by_country.rb | UTF-8 | 676 | 2.859375 | 3 | [] | no_license | module MovieIndustry
class ByCountry
def initialize(movie_collection)
@movie_collection = movie_collection
end
def method_missing(method, *args, &block)
return super if prohibited_country_name?(method)
raise(ArgumentError, "Country filter can't be called with args or block") if block ||... | true |
0459dd3e3c60d3abc3755bacf83f297602476500 | Ruby | ajdil91/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 2,449 | 2.609375 | 3 | [] | no_license | require 'json'
require 'rest-client'
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, ... | true |
500c552e682e9974c7930ae6344067f6ac949065 | Ruby | yashp82099/ruby-oo-object-relationships-kickstarter-lab-atlanta-web-111819 | /lib/project.rb | UTF-8 | 423 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Project
attr_reader :title
def initialize(title)
@title = title
end
def add_backer(backer)
ProjectBacker.new(self, backer)
end
def backers
# a = ProjectBacker.all.map do |pb|
# pb.project == self
# end
# a.map{|a|a.... | true |
ca53b8eb2328fe5f12e4581d555b194ca02c1a51 | Ruby | JvPelai/stock_picker | /stock_picker.rb | UTF-8 | 1,096 | 3.96875 | 4 | [] | no_license |
def stock_picker (stocks)
buying_day = stocks[0]
selling_day = stocks[1]
possible_profits = []
operations = []
#calculates the profits of each possible operation
stocks.each_with_index do |stock,index|
buying_day = index + 1
while index < stocks.length - 1 do
i = sto... | true |
587869ad455a46ea7f088bce9ec4091bf55f909d | Ruby | hunter3142/Pillar-Vending-Machine | /models/coins.rb | UTF-8 | 415 | 3.140625 | 3 | [] | no_license | require_relative 'inventory'
class Coins
attr_accessor :inserted_coin_total, :total_change
def initialize
@inserted_coin_total = 0
@total_change = 0
end
def insert_coin (inserted_coin)
@inserted_coin_total += inserted_coin
end
def reset_totals
@inserted_coin_total = 0
@total_change = 0
... | true |
c2e5f671885404f26993b50b021a0f840da9a1a3 | Ruby | clementlo/tealeaf1_prework | /chomp.rb | UTF-8 | 646 | 3.578125 | 4 | [] | no_license | puts 'Hello there, what\'s your first name?'
first_name = gets.chomp
puts 'Hello there, what\'s your middle name name?'
middle_name = gets.chomp
puts 'Hello there, what\'s your last name?'
last_name = gets.chomp
puts 'Pleased to meet you, ' + first_name + ' ' + middle_name + ' ' + last_name + '!'
full_name_length = fir... | true |
415a889c9becaf46c7643badf1c6f21a2d156495 | Ruby | mzakzook/sql-crowdfunding-lab-sf-web-091619 | /lib/sql_queries.rb | UTF-8 | 1,804 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
8b538a36efcddd30e8ee3dc823309fb81236bade | Ruby | Rizzooo/ruby-objects-has-many-lab-onl01-seng-pt-052620 | /lib/author.rb | UTF-8 | 446 | 3.203125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Author
attr_accessor :name
@@post_count = 1
def initialize(name)
@name = name
@posts = []
end
def add_post(posting)
@posts << posting
posting.author = self
@@post_count += 1
end
def add_post_by_title(posting)
posting = Post.new(posting)
add_post(posting)
e... | true |
1a079c490441998355a4f81f5a963e72ef777133 | Ruby | weaponisedbutterfly/warehouse_picker | /warehouse_picker_functions.rb | UTF-8 | 1,223 | 2.546875 | 3 | [] | no_license |
WAREHOUSE = [
{bay: "a10", item: "rubber band"},
{bay: "a9", item: "glow stick"},
{bay: "a8", item: "model car"},
{bay: "a7", item: "bookmark"},
{bay: "a6", item: "shovel"},
{bay: "a5", item: "rubber duck"},
{bay: "a4", item: "hanger"},
{bay: "a3", item: "blouse"},
{bay: "a2", item: "stop sign"},
{bay: "a1... | true |
d72a6bfee3b3894c627d9d7993f345ae3779a2fd | Ruby | uncoder/invoicer | /lib/invoicer/calculator.rb | UTF-8 | 3,151 | 3.0625 | 3 | [] | no_license | module Invoicer
class Calculator
def initialize
@amount_fields = [:amount, :vat_amount, :total_amount]
@items = []
reset_totals
end
def add_items(items, fields = {})
# append and map items
items_list = items.map do |item|
formatted_item = {}
[:unit_amount, :... | true |
de33e89d6a6a5d9a22d10cd7e78a136ea1787ac8 | Ruby | NREL/OpenStudio-resources | /model/simulationtests/plenums.rb | UTF-8 | 6,670 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
require 'openstudio'
require_relative 'lib/baseline_model'
model = BaselineModel.new
always_on_schedule = model.alwaysOnDiscreteSchedule
# make a 2 story, 100m X 50m, 10 zone core/perimeter building
model.add_geometry({ 'length' => 100,
'width' => 50,
... | true |
03a8c1fc41dbb444b5268cfc3e389a1ff67e4eb6 | Ruby | rr326/Speedtest | /test/test_utils.rb | UTF-8 | 1,735 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require_relative '../lib/speedtest/utils'
require_relative '../lib/speedtest/measure'
class TestUtils < MiniTest::Test
include Speedtest
def test_nbyte_string
string = Utils.nbyte_string(100)
assert_equal string.length, 100
string = Utils.nbyte_string(1, units=:KB)
ass... | true |
1c05a0425c23298d4bcdfcc4850367d7f9ded4ef | Ruby | xing/israkel | /lib/israkel/simctl.rb | UTF-8 | 431 | 2.640625 | 3 | [] | no_license | class SIMCTL
def self.list
`xcrun simctl list`
end
def self.booted_devices_uuids
devices = self.list.split("\n")
devices.keep_if { |entry| entry =~ /(\(Booted\))/ }
devices.map { |device| device.match(/\(([^\)]+)\)/)[1] }
end
def self.shutdown(device_uuid)
system "xcrun simctl shutdown ... | true |
c2ebda8fbb8c0f42c43d35bda6ce320b77f7fdbf | Ruby | yojindo/key-for-min-value-nyc01-seng-ft-060120 | /key_for_min.rb | UTF-8 | 247 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def key_for_min_value(name_hash)
min_value = 1000
item = ''
if name_hash == {}
return nil
end
name_hash.each do |key,value|
if value < min_value
min_value = value
item = key
end
end
item
end | true |
d24eafbdc155213c9dddb29c7e1e3dfcf2bf56f0 | Ruby | KristenWilde/Launch-School-Ruby | /blocks_procs_lambdas/easy1/encrypted.rb | UTF-8 | 877 | 2.65625 | 3 | [] | no_license | def decipher(string)
string.chars.map {|chr| rotate13(chr) }.join
end
def rotate13(char)
return char unless char.match(/[a-z, A-Z]/)
key = if char.downcase == char then ("a".."z").to_a
else ("A".."Z").to_a
end
key.rotate(key.index(char))[13]
end
names = %w( Nqn Ybirynpr
Tenpr Ubccr... | true |
ca27580bb5f6243a7eb6c81bb7eb39abb790834e | Ruby | debugger1809/Classes_Objects_Variables | /Factorial_exception.rb | UTF-8 | 348 | 3.703125 | 4 | [] | no_license | # Negative Factorial Exception
class Numbers
def factorial(n)
raise NegativeFactorial, "The number provided is negative." if n < 0
(1..n).inject(1, :*)
end
def test_negative
assert_raises NegativeFactorial do
factorial(-1)
end
end
a = Numbers.new
n = ARGV[0].to_i
if n
a.factorial(n)
else
puts "Pl... | true |
ff1e20f56d9bcf0c857c156784cf3a5bdbee6e79 | Ruby | samueldana/indentation | /lib/indentation/array_mod.rb | UTF-8 | 3,478 | 3.71875 | 4 | [
"MIT"
] | permissive | # Monkey patch Array with indentation methods
class Array
# Appends a given separator(s) to all but the last element in an array of Strings
# or if performed on an array of arrays, appends the separator element to the end of each array except the last
def append_separator(*separators)
len = length
ret_arr... | true |
4edc225468342fce7a50f92aa1f1524bd4dbbd9c | Ruby | tsuyopon/ruby | /basic_rescue/sample1.rb | UTF-8 | 71 | 2.515625 | 3 | [] | no_license | begin
1 / 0
rescue
puts "何か問題が発生しました。"
end
| true |
de0633c916a71664499ebe34e9bd0554e8a878e7 | Ruby | Solnse/mismo_enum | /app/models/mismo_enum/loan_state_type.rb | UTF-8 | 2,234 | 2.578125 | 3 | [
"MIT"
] | permissive | # app/models/mismo_enum/loan_state_type.rb
# enum
class MismoEnum::LoanStateType < MismoEnum::Base
validates_presence_of :name
validates_uniqueness_of :name
def self.description
'Identifies the state in time for the information associated with this '+
'occurrance of LOAN'
end
def self.seed
[[1,... | true |
525a02072068e90226e92007dd73b7113bd6de71 | Ruby | Harmonickey/EnHabit | /Core/Applicants/convert_to_renter.rb | UTF-8 | 3,041 | 2.703125 | 3 | [] | no_license | #!/usr/local/bin/ruby
absPath = Dir.pwd
base = absPath.split("/").index("public_html")
deploymentBase = absPath.split("/")[0..(base + 1)].join("/") #this will reference whatever deployment we're in
$: << "#{deploymentBase}/Libraries"
require 'json'
require 'moped'
require 'bson'
Moped::BSON = BSON
... | true |
991cf075ba971c60d7950aecfc5d0e6bc5c339c3 | Ruby | vishnurv2/CI_RB | /features/step_definitions/vehicle_grid_steps.rb | UTF-8 | 2,613 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
And(/^I delete the vehicles in the grid$/) do
on(AutoPolicySummaryPage) do |page|
page.vehicle_info_panel.scroll.to
#make sure to keep one vehicle at least.
loop do
@found_vehicle = page.vehicle_info_panel.vehicles.last
break if page.vehicle_info_panel.vehicles.... | true |
ec55c9729292d511d34081b5c90f4276b7851e84 | Ruby | uchoaaa/brazilian-rails | /template/brazilian-rails.rb | UTF-8 | 5,723 | 2.6875 | 3 | [] | no_license | #
# Brazilian Rails Template
# Author: Rafael Uchôa
# http://putshelloworld.wordpress.com/
#
#
# Feel free to fork it!
#
# Rewrite environment.rb to config the timezone and i18n
# THIS BLOCK SHOULD BE FIRST OF ALL
file "config/environment.rb", <<-ENV
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
r... | true |
aa3bb83f32d0163047d340cf1792fc1f6af7d73f | Ruby | codeclanstudentls/Week2_Homework_Day1 | /cars_spec.rb | UTF-8 | 1,632 | 3.59375 | 4 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('cars')
class TestCars < MiniTest::Test
def setup
end
def test_colour_of_car
car_colour = Cars.new('yellow', 'Beetle', 100, 0)
assert_equal( 'yellow', car_colour.colour())
end
def test_model_of_car
car_model = Cars.new('yellow', 'B... | true |
3f848bb3f0ba5c10da996d7a8f94287b9e1f5f97 | Ruby | guerragiancarlo8/Tanks | /hello.rb | UTF-8 | 4,249 | 3.265625 | 3 | [] | no_license | require 'gosu'
def media_path(file)
File.join(File.dirname(File.dirname(__FILE__)), 'media',file)
end
class Explosion
#mientras mas algo este valor, más lento el proceso de la animación. Es decir, que mientras más
#alto esté este número, más tiempo tardará el array con la animación en recorrer.
FRAME_DELAY = 10 ... | true |
d35d710f76f34b32424540ba04fd0e603b149279 | Ruby | jv1056/Knight_Path-W1D5- | /00_tree_node.rb | UTF-8 | 421 | 3.078125 | 3 | [] | no_license | require 'byebug'
class PolyTreeNode
attr_reader :parent, :children, :value
def initialize(value)
@parent = nil
@children = []
@value = value
end
def parent
@parent
end
def children
@children
end
def value
@value
end
def parent=(dad)
debugger if dad.nil?
u... | true |
f854605b09237bead62dc8511fbe914f351c43e2 | Ruby | meghanstovall/backend_module_0_capstone | /day_1/ex6.rb | UTF-8 | 652 | 4.625 | 5 | [] | no_license | # creating 5 variables
types_of_people = 10
x = "There are #{types_of_people} types of people."
binary = "binary"
do_not = "don't"
y = "Those who know #{binary} and those who #{do_not}."
# using variables x and y
puts x
puts y
# using variables x and y again just differently
puts "I said: #{x}."
puts "I also said: '#... | true |
f8c207fe04cb8380cc42cf4dcee423959d8b3229 | Ruby | martinos/functional_ruby_presentation | /github_lambda.rb | UTF-8 | 1,394 | 2.53125 | 3 | [] | no_license | require 'open-uri'
require 'json'
require 'pry-nav'
require 'pp'
require './utils'
include Utils
cache = Utils.cache.(expired.(60))
logger = Logger.new($stdout).method(:info)
slack_printer = -> a { system(%{curl -s -X POST --data-urlencode 'payload={"text": "#{a}", "channel": "#autonotifications", "username": "martin... | true |
f8f4ba8ceb54601b20b3dab94522bf9c67ce63df | Ruby | Zajn/gameboy-disassembler | /disassembler.rb | UTF-8 | 1,305 | 3.015625 | 3 | [] | no_license | # frozen_string_literal: true
class Disassembler
attr_reader :rom
attr_accessor :address
OPCODE_MAP = {
'31' => { instruction: "LD SP", size: 2 },
'af' => { instruction: "XOR A", size: 0 },
'21' => { instruction: "LD HL", size: 2 },
'32' => { instruction: "LDD HL, A", size: 0 },
'cb7c' => { ... | true |
3c1d849e055b4ed2ddf454d414a0cacfd123a32a | Ruby | wpotratz/tealeaf | /2_ruby_workbook/quiz_2_3/exc_5.rb | UTF-8 | 322 | 3.71875 | 4 | [] | no_license |
## Original
#def color_valid(color)
# if color == "blue" || color == "green"
# true
# else
# false
# end
#end
## Changed to:
def color_valid(color)
%w[blue green].any? { |c| c == color }
#color == "blue" || color == "green"
end
puts color_valid("blue")
puts color_valid("red")
puts color_valid("green... | true |
4c4c9dd838400ce93bdcc38b30caac984f0dde34 | Ruby | svenfuchs/cl | /lib/cl/cast.rb | UTF-8 | 1,228 | 3.140625 | 3 | [
"MIT"
] | permissive | class Cl
module Cast
class Cast < Struct.new(:type, :value, :opts)
TRUE = /^(true|yes|on)$/
FALSE = /^(false|no|off)$/
def apply
return send(type) if respond_to?(type, true)
raise ArgumentError, "Unknown type: #{type}"
rescue ::ArgumentError => e
raise ArgumentErr... | true |
f45e7543f969e4c9ccbb02ea3446801db6d281f9 | Ruby | h4hany/leetcode | /solutions/108_convert_sorted_array_to_binary_search_tree.rb | UTF-8 | 1,103 | 4.46875 | 4 | [] | no_license | # Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
# For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
# Example:
# Given the sorted array: [-10,-3,0,5,9],
# One p... | true |
d1f824ebb546f621c245397bc595ca23ed4eed3d | Ruby | Itsindigo/boris | /lib/bike.rb | UTF-8 | 263 | 3 | 3 | [] | no_license | class Bike
attr_reader :bike, :bike_status
def initialize
@bike
@bike_status = "Working"
end
def working?
@bike_status
end
def report_broken
@bike_status = "Broken"
end
def in_transit
@bike_status = "In Transit"
end
end
| true |
4390f24dd40f2d7113abf876caa388a05059ddc6 | Ruby | kschumy/MediaRanker | /test/models/user_test.rb | UTF-8 | 1,572 | 2.859375 | 3 | [] | no_license | require "test_helper"
describe User do
describe "valid" do
it "must be valid" do
users(:lovelace).must_be :valid?
end
it "must have a name of at least one char" do
new_user = User.create(name: "")
new_user.valid?.must_equal false
new_user.errors.must_include :name
new_use... | true |
5156a2ee8cf14b58ee2c9a0d3b7e2b9a66a67afb | Ruby | AlsaceDigitale/hacklechalet | /fetch_attendees.rb | UTF-8 | 1,651 | 2.578125 | 3 | [] | no_license | require 'rubygems'
require 'bundler/setup'
require 'eventbrite-client'
require 'digest/md5'
require './env'
def output(position, gravatar_hash, name, tags)
gravatar_url = "http://www.gravatar.com/avatar/#{gravatar_hash}.png?size=48"
str = "<tr>\n"
str << " <td class='position'>#{position}</td>\n"
str << " ... | true |
8be43e78ee54edcf62ac66e8dec50765ccb4556a | Ruby | pt1988/logstash-filter-sanitize_mac | /spec/filters/sanitize_mac_spec.rb | UTF-8 | 3,460 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: utf-8
require_relative '../spec_helper'
require "logstash/filters/sanitize_mac"
describe LogStash::Filters::SanitizeMac do
describe "Clean up a MAC address to hyphen and lowercase" do
let(:config) do <<-CONFIG
filter {
sanitize_mac {
match => { "client_mac" => "client_mac_sani... | true |
09dce9cd85381d2120ff187c23ed3ab407486128 | Ruby | johnkerl/ruffl | /Factorization.rb | UTF-8 | 5,808 | 3.6875 | 4 | [
"BSD-2-Clause"
] | permissive | # ================================================================
# Please see LICENSE.txt in the same directory as this file.
# John Kerl
# kerl.john.r@gmail.com
# Copyright (c) 2004
# Ported to Ruby 2011-02-10
# ================================================================
class Factorization
# ---------------... | true |
67eae1fc1177f2b79d2bf9f5682c735c9107c96a | Ruby | izabellea/teacher-vacancy-service | /lib/base_dsi_exporter.rb | UTF-8 | 976 | 2.625 | 3 | [
"MIT"
] | permissive | require 'dfe_sign_in_api'
require 'google/cloud/bigquery'
class BaseDsiExporter
attr_reader :dataset
def initialize(bigquery: Google::Cloud::Bigquery.new)
@dataset = bigquery.dataset ENV.fetch('BIG_QUERY_DATASET')
end
private
def delete_table(table_name)
table = dataset.table table_name
return... | true |
424e22424f3afc94a6ea1aecb28f542b2360e3e5 | Ruby | Wyattwicks/sweater_weather | /app/poros/route.rb | UTF-8 | 940 | 3.109375 | 3 | [] | no_license | class Route
attr_reader :id,
:start_city,
:end_city,
:travel_time,
:hours_to_arrival,
:weather_at_eta,
:conditions,
:temperature
def initialize(data, forecast)
@id = nil
@type = "roadtrip"
... | true |
3677824ea6ca13ffb9f45ea08c2996f1acdaedc2 | Ruby | ryan-jr/theodinproject | /webdev101/thebackend/Step4-RubyProject/tests.rb | UTF-8 | 2,718 | 4.4375 | 4 | [] | no_license | #writing test code before running them in rspec
#for testfirst live
#http://testfirst.org/live/learn_ruby/calculator
#Temp
=begin
What I learned:
1. Understand what formulas/equations you will need beforehand, it saves you time
2. I will probably need to go back and refactor the code especially conv1
=end
=begin
d... | true |
39693e413f09d0530e622514edccdc5a88182fd4 | Ruby | chrispyyy/ContactList | /contact_database.rb | UTF-8 | 1,356 | 3.234375 | 3 | [] | no_license | ## TODO: Implement CSV reading/writing
require 'csv'
class ContactDatabase
def self.read_csv
CSV.read('contacts.csv')
end
def self.read_contact_id(id)
CSV.foreach('contacts.csv') do |line|
return line if $. == id
end
end
def self.read_contacts
@@all_contacts = []
... | true |
fdaf81bf011d5c313aaf8e6fb1c8878f94f11e17 | Ruby | BooHooRor/family_tree | /app/models/user.rb | UTF-8 | 515 | 2.703125 | 3 | [] | no_license | class User < ApplicationRecord
attr_accessor :full_name
validates :email, :first_name, :last_name, :birthdate, :address, :phone_number, presence: true
validates :sex, presence: true, inclusion: { in: %w(male female),
message: "%{value} is not a valid sex" }
has_many :parents, class_name: "User", foreign_key... | true |
88696b6806b71302bdd11a9b85e27ef4de356ee6 | Ruby | aerostitch/bysas | /build_sitemap_xml.rb | UTF-8 | 2,254 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
require 'date'
require 'time'
require 'nokogiri'
SiteUrl = 'http://aerostitch.github.io'
# This is to ensure we are in the same directory as the script
# to enable people to run the script from another directory
script_path = File.dirname(File.expand_path($0))
# This function will get the conten... | true |
ac627d73e3efcda15a1eb6a0c22ec9f9aee7683e | Ruby | voostindie/topicz | /spec/command/note_command_spec.rb | UTF-8 | 1,873 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'testdata'
require 'topicz/commands/note_command'
class DummyKernel
def exec(*arguments)
print arguments.join ' '
end
end
describe Topicz::Commands::NoteCommand do
it 'creates a file with the proper heading when needed' do
with_testdata do
date = DateTime.now.strftim... | true |
77ee48ce44f2950eef67c939ddffd36a32460008 | Ruby | t1h/uke_note | /app/helpers/chords_helper.rb | UTF-8 | 442 | 2.71875 | 3 | [] | no_license | module ChordsHelper
def chord_image(chord)
if chord.nil? || chord == ''
image_tag "chords/blank.png", alt: ""
else
image_tag "chords/" + chord.to_s.gsub('#', 's').gsub('/', 'on') + ".png", alt: chord
end
end
def transpose_chord(chord, number)
begin
chords = TransposeChords::Chor... | true |
d3adffef4adae6119bdbd1763c711c786388d2e1 | Ruby | linyahu/collections_practice_vol_2-nyc-web-career-010719 | /collections_practice.rb | UTF-8 | 1,939 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def begins_with_r(array)
array.all? do |word|
word.start_with?("r")
end
end
def contain_a(array)
array.select do |word|
word.include?("a")
end
end
def first_wa(array)
array.find do |word|
word.to_s.start_with?("wa")
end
end
def remove_non_strings(array)
array.delete_if do |wo... | true |
d73f583229515076508b335b109f975b18c58c78 | Ruby | jacob-brontes/file_storage | /test/bigger_pipe_test.rb | UTF-8 | 4,148 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'rubygems'
require 'activerecord'
require 'openssl'
class BiggerPipeTest < Test::Unit::TestCase
@@is_setup = false
def setup_for_all
unless @@is_setup
#require this plugin
require "#{File.dirname(__FILE__)}/../init"
@@is_setup = true
end
end
def s... | true |
f4b4a667c546efa36eecda40a9d04e3965b5e79e | Ruby | keritaf/labs-kidstv | /lab4/lib/scheme.rb | UTF-8 | 773 | 2.828125 | 3 | [] | no_license | class Scheme
INPUTS = 7
attr_writer :signals
def initialize(mock: {})
@mock = mock
end
0.upto(INPUTS) do |i|
define_method "x#{i}".to_sym do
@mock["x#{i}".to_sym] || @signals[i]
end
end
def f1
@mock[:f1] || Function.new('and', x0, x1).value
end
def f2
@mock[:f2] || Func... | true |
836fa41806d83abed4d162014d0c6bef469b522b | Ruby | oreno-tools/furikake | /lib/furikake/resources/kinesis.rb | UTF-8 | 1,347 | 2.53125 | 3 | [
"MIT"
] | permissive | module Furikake
module Resources
module Kinesis
def report
resources = get_resources
headers = ['Stream Name', 'Stream ARN', 'Stream Status', 'Shards']
if resources.empty?
info = 'N/A'
else
info = MarkdownTables.make_table(headers, resources, is_rows: true... | true |
da059ff15b94dac3b2d4dbbadb5deebe6b0ca4b3 | Ruby | chalmie/Random_Ruby | /thou_dij_fib.rb | UTF-8 | 174 | 3.109375 | 3 | [] | no_license | def thou_dij_fib
fibs = [1, 1]
until fibs.last.to_s.length == 1000
nextfib = fibs[-1] + fibs[-2]
fibs << nextfib
end
fibs.length
end
p thou_dij_fib | true |
ecdb8956f8474b02f0313439bc2ee62c76a2a062 | Ruby | greenglass/overseer | /lib/overseer/aws/wrappers/identity_access_management/iam_client.rb | UTF-8 | 2,363 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'overseer/helpers/dir_helper'
require 'overseer/overseer_error'
require 'aws-sdk'
module Overseer
module AWS
module Wrappers
# wrapper for aim client in amazon.
class IamClient
include Helpers
# read the local credentials
def initialize
@iam_client = Aws::IA... | true |
f83d51461b65a144840465848b31bc0bd4ddb573 | Ruby | thebravoman/software_engineering_2014 | /class017_homework/homework1/Stefan_Iliev/results_writer.rb | UTF-8 | 755 | 3.1875 | 3 | [] | no_license |
class ResultsWriter
def self.write( results )
results.to_hash
html = File.open("results_Stefan_Iliev_B_28.html", "w")
html.puts("<!DOCTYPE html>")
html.puts("<html>")
html.puts(" <table border=\"1\" style=\"width:100%\">")
html.puts(" <tr>")
html.puts(" <th> FirstName </th>")
html.puts(" <th>... | true |
c99035b836e3e017b8cd1fd596332936bb50b3a3 | Ruby | mathildathompson/wdi_sydney_feb | /students/kriss_heimanis/stock_exchange/cheats.rb | UTF-8 | 390 | 2.703125 | 3 | [] | no_license | # gets the yahoo finance gem workign and connected?
require 'yahoofinance'
# this returns EVERYTHING for apple
YahooFinance::get_quotes(YahooFinance::StandardQuote, 'AAPL')
#this returns just the askign price
YahooFinance::get_quotes(YahooFinance::StandardQuote, 'AAPL')['AAPL'].ask
#returns the last price
YahooFinan... | true |
f4fdef9a64b55cfb4fe5520c6af9aee394183fc4 | Ruby | conyekwelu/rb101 | /Easy Problems/Easy2/easy2.rb | UTF-8 | 3,325 | 4.34375 | 4 | [] | no_license | # CORE CONCEPTS
# - print allows user entry in same line as prompt unlike puts
# ============================================================
# puts "Teddy is #{rand(20..199)} years old!"
#
# def age_declaration(name="Teddy")
# puts "Enter your name: "
# name = gets.chomp
# name = "Teddy" if name.empty?
# puts... | true |
a223dbee5015fe2e60322bae1f1e3bd7898e5b12 | Ruby | capnregex/date-recurrence | /lib/date/recurrence/pay_period.rb | UTF-8 | 1,113 | 2.9375 | 3 | [] | no_license | require 'date/recurrence/pay_period/calculations'
class Date
class Recurrence
class PayPeriod
# @NOTE: 01/07/2018 is the starting date for pay periods in 2018
# (https://www.nfc.usda.gov/Publications/Forms/pay_period_calendar.php has pay period dates)
class_attribute :origin, default: Date.new(2... | true |
c29c6e22e88529ea36f4d97aa5c442c8158008aa | Ruby | Sihan001/lbActions | /chmod.lbaction/Contents/Scripts/default.rb | UTF-8 | 1,399 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
#
# LaunchBar Action Script
#
puts '<?xml version="1.0"?>'
puts '<items>'
def oct_to_sym(x)
num = x.to_i(8).to_s(2)
result = ''
result << (num.slice(0, 1) == '1' ? 'r' : '-')
result << (num.slice(1, 1) == '1' ? 'w' : '-')
result << (num.slice(2, 1) == '1' ? 'x' : '-')
result
end
def sy... | true |
49785e5d5247da9513beec21e2e7eee9a4b19d1c | Ruby | meyercm/git-issue | /src/git_issue/commands/close_command.rb | UTF-8 | 2,289 | 2.8125 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative 'base_command'
module GitIssue
class CloseCommand < BaseCommand
def parse(args)
options = OpenStruct.new()
options.sha = validate_sha(args.shift)
options.message = ""
options.tags = {}
parser = OptionParser.new do |opts|
opts.on("-m", "--message MESSAGE", "n... | true |
761f12c23eef354783d7a946322d272f59514f75 | Ruby | tonymaibox/bringing-it-all-together-web-0716 | /lib/dog.rb | UTF-8 | 1,741 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Dog
attr_accessor :name, :breed, :id
def initialize(name: nil, breed: nil, id: nil)
@name = name
@breed = breed
@id = id
end
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS dogs (
id INTEGER PRIMARY KEY,
name TEXT,
breed TEXT);
SQL
DB[:conn].execute(sql)
e... | true |
0f22cd69c71ad527ecf2790c43cc545bf2aa5c0f | Ruby | Graciexia/todo-csv | /lib/todo.rb | UTF-8 | 2,702 | 3.953125 | 4 | [] | no_license | require 'csv'
class Todo
def initialize(file_name)
@file_name = file_name
@todos = CSV.read(@file_name, headers:true)
# You will need to read from your CSV here and assign them to the @todos variable. make sure headers are set to true
end
def start
loop do
system('clear')
puts "---... | true |
1e7422fb4589e3072ac7aa13b4f4faa9de0c38b5 | Ruby | SamuelSacco/W4D2 | /ClassWork/Pieces/king.rb | UTF-8 | 486 | 3.140625 | 3 | [] | no_license | require_relative 'piece'
require_relative 'stepable'
class King < Piece
include Stepable
MOVES = [
[1,1],
[1,0],
[0,1],
[-1,-1],
[-1,1],
[1,-1],
[0,-1],
[-1,0]
]
def symbol
'♚'.colorize(color)
end
protected
de... | true |
05112ff7778e9adc7c0dda274228ad56c09e6ffb | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/regexp_parser-2.4.0/lib/regexp_parser/expression/classes/group.rb | UTF-8 | 1,645 | 2.59375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Regexp::Expression
module Group
class Base < Regexp::Expression::Subexpression
def parts
[text.dup, *expressions, ')']
end
def capturing?; false end
def comment?; false end
end
class Passive < Group::Base
attr_writer :implicit
def initialize(*)
... | true |
e153cce67d2128be8e0183ed1fa719e21082e6c3 | Ruby | nasa/Common-Metadata-Repository | /orbits-lib/resources/orbits/orbit.rb | UTF-8 | 28,776 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive | # This is a Ruby implementation of the Backtrack Orbit Search Algorithm (BOSA)
# originally written in Java and maintained by [NSIDC](http://nsidc.org/).
# References to "the Java code" or "the NSIDC spheres code" in the refer
# to the original library which is available
# [here](http://geospatialmethods.org/spheres/).... | true |
d462dd7e03ade2fed7883faac6f6982309a86744 | Ruby | pjwl33/code_snippets | /missing_methods.rb | UTF-8 | 1,665 | 3.296875 | 3 | [] | no_license | require 'delegate' #automatically delegate all method calls to local object unless delcared locally
class School < SimpleDelegator
DELEGATED_METHODS = [:username, :avatar]
def initialize user
super user
end
def method_missing method_name, *args
if DELEGATED_METHODS.include?(method_name) #to check if t... | true |
c3bb2d4ef9db26b1e969c329e0fcc04d201d8da4 | Ruby | zold-io/zold | /lib/zold/commands/routines/reconcile.rb | UTF-8 | 2,496 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Copyright (c) 2018 Yegor Bugayenko
#
# 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, co... | true |
1d151b78e624921aa46da52a459fc39279e3abbf | Ruby | joshualat/study | /lib/study/tree_node.rb | UTF-8 | 6,659 | 2.921875 | 3 | [
"MIT"
] | permissive | module Study
class TreeNode
attr_accessor :type, :value
def initialize(type:, value:)
@type = type
@value = value
end
def ==(other)
@type == other.type && @value == other.value
end
def highlight(left: nil, right: nil, nested: false, plain: false)
colored_left = left.... | true |
3bc010f30306d647cc1075fbe02317e9662d2401 | Ruby | johnquiwa/nyu | /qualtronics_format.rb | UTF-8 | 432 | 3 | 3 | [] | no_license | def EditArray(array)
i = 0
num = 1
while i < array.length
if i == 0
array[i] = "[[Block]]" + "\n #{num}. " + array[i] + "\n\n" + "[[Block]]"
puts array[i]
elsif i == array.length - 1
array[i] = "#{num}. " + array[i]
puts array[i]
else
array[i] = "#{num}. " + array[i] + "\n\n" + "[[Block]]"
puts array[i]
... | true |
c536092a37aaecd4eeb03e850b26cc1a8173b154 | Ruby | abeger/advent-of-code-2019 | /spec/functional/13/arcade_game_spec.rb | UTF-8 | 485 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
RSpec.describe ArcadeGame::Game do
context 'puzzles' do
let(:program_text) { File.read('13/input.txt') }
it 'solves part 1' do
game = described_class.new(program_text)
game.run
expect(game.screen.num_tiles(ArcadeGame::Screen::TILE_BLOCK)).to eq(236)
end
... | true |
ed64aa827de5da840653964beb69c830ff854f77 | Ruby | jcmorrow/wishing-well | /app/jobs/simulate_game.rb | UTF-8 | 1,061 | 2.8125 | 3 | [] | no_license | class SimulateGame < ActiveJob::Base
def perform(match:)
@game = Game.create(match: match)
@players ||= @game.match.strategies.map do |strategy|
game_strategy = GameStrategy.create(game: game, strategy: strategy)
Player.new(game_strategy)
end
run
end
private
attr_accessor :game, :p... | true |
3f90dc46be8f5d04610ec11752453287bc897559 | Ruby | TomHoenderdos/stickler | /lib/stickler/spec_lite.rb | UTF-8 | 2,329 | 3.078125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "rubygems/platform"
require "rubygems/version"
module Stickler
#
# A lightweight version of a gemspec that only responds to name, version,
# platform and full_name. Many of the items in the rubygems world
# deal with the triplet [ name, verison, platform ] and this class
# encapsulates that.
#
c... | true |
9c4545ac75cee25e47f24955d0169e33ea244137 | Ruby | arnabsen1729/cef-projects | /Level-2/DNSResolver/lookup.rb | UTF-8 | 1,660 | 3.578125 | 4 | [] | no_license | def get_command_line_argument
# ARGV is an array that Ruby defines for us,
# which contains all the arguments we passed to it
# when invoking the script from the command line.
# https://docs.ruby-lang.org/en/2.4.0/ARGF.html
if ARGV.empty?
puts "Usage: ruby lookup.rb <domain>"
exit
end
ARGV.first
e... | true |
0200059a6213ead659dd58c13799345f9e4ce052 | Ruby | NeelAiyar/OOP-1 | /save/OOP/ex05/main.rb | UTF-8 | 131 | 2.625 | 3 | [] | no_license | require_relative "first.class"
require_relative "second.class"
Test = SecondClass.new("neelaiyar")
puts "Your hobby is " + ##Test
| true |
bf5b69d3bde97569684296e53383a5a1a0035e74 | Ruby | SwetaYamini/interpolation-super-power-ruby-intro-000 | /lib/display_rainbow.rb | UTF-8 | 190 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your #display_rainbow method here
def display_rainbow(colors)
sep = ""
for i in 0..6
print sep
print "#{(colors[i])[0].upcase}: #{colors[i]}"
sep = ", "
end
print "\n"
end
| true |
87561dbc42fd35e459e17230cd45d22b5bf53ea8 | Ruby | kellyarwine/t3 | /spec/minimax_strategy_spec.rb | UTF-8 | 3,797 | 2.90625 | 3 | [] | no_license | require 'spec_helper'
describe T3::Player::MinimaxStrategy do
let(:gamepiece) { "x" }
let(:board) { T3::Board.new(3) }
let(:game_rules) { T3::GameRules.new(board) }
let(:subject) { T3::... | true |
7c519d8be91e3da0223432474f8ac50fda0f21f9 | Ruby | avimoondra/mdapps | /parser.rb | UTF-8 | 3,111 | 2.96875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
class Profile
def initialize(index)
@page = Nokogiri::HTML(open("profiles/#{index}.html"))
@userMetadata = @page.css(".viewprofileheader div:contains('Application Cycles')").text.gsub!(/\t/,' ')
@uGradQualitativeMetadata = @page.css('div.subpagecontent... | true |
32e486ad2db573a2fe9de9f541024413717f1b7d | Ruby | Hack-Slash/sunday_afternoon | /fibon_recursive.rb | UTF-8 | 171 | 3.34375 | 3 | [] | no_license | def fib_recursive(number)
if number == 0 || number == 1
return number
end
return fib_recursive(number - 1) + fib_recursive(number - 2)
end
p fib_recursive(20)
| true |
bbefafeea29c49b4c5f7b5dd203799ab6eee844c | Ruby | ronakjain90/runeblog | /bin/blog | UTF-8 | 1,696 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
# $LOAD_PATH << "./lib"
require 'runeblog'
require 'rubytext'
require 'repl'
include RuneBlog::REPL
def get_started
puts
puts fx(<<-TEXT, :bold)
Blog successfully created.
You can create views with the command: new view
Create a post within the current view: new post
You can't publi... | true |
8cf95065997a811d8ee365bce904a9beed0c1a26 | Ruby | copiousfreetime/launchy | /lib/launchy/cli.rb | UTF-8 | 2,265 | 2.734375 | 3 | [
"ISC"
] | permissive | require 'optparse'
module Launchy
class Cli
attr_reader :options
def initialize
@options = {}
end
def parser
@parser ||= OptionParser.new do |op|
op.banner = "Usage: launchy [options] thing-to-launch"
op.separator ""
op.separator "Launch Options:"
op.on... | true |
9599552eebd2ab0a0c4995f98097c696c9d0fb0b | Ruby | ged/mues | /lib/mues/client.rb | UTF-8 | 1,605 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'bunny'
require 'mues'
require 'mues/mixins'
require 'mues/constants'
# A reference implementation of a MUES client.
class MUES::Client
include MUES::Loggable,
MUES::Constants
### Create a new client that will connect to the given +host+ using the specified
### +playername+... | true |
fb4459a3120d1481c46c6a0b0dcaf0355700734f | Ruby | gkolan/CodeEval_Challenges | /sum_of_digits.rb | UTF-8 | 337 | 3.515625 | 4 | [] | no_license | #Challenge Link - https://www.codeeval.com/open_challenges/21/
#Score - 100
def sum_of_digits value
return [] if value.empty?
split_number = value.scan(/./).map {|x| x.to_i}
digits_sum = split_number.inject {|sum, el| sum + el}
return digits_sum
end
File.open(ARGV[0]).each_line do |line|
puts sum_of... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.