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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30ff43d9da92322827733b61c68ff35d832410d5 | Ruby | gwlee1991/crackingcodinginterview | /Math and Logic Puzzles/6.8.rb | UTF-8 | 269 | 3.40625 | 3 | [] | no_license | # The Egg Drop Problem: There is a building of 100 floors. If an egg drops from the Nth floor or
# above, it will break. If it's dropped from any floor below, it will not break. You're given two eggs, Find
# N, while minimizing the number of drops for the worst case.
| true |
a9fbf4aa3cfe19d282855ef780b7f8b56bb8a36a | Ruby | DianaTavares/codea | /2-Newbie/apps/to_dos/app/controllers/tasks_controller.rb | UTF-8 | 731 | 2.515625 | 3 | [] | no_license | lass TasksController
def initialize(args)
@view = TasksView.new
@new_task = args[1]
options(args[0])
end
def options(value)
if value== "index"
index
elsif value == "add"
add
elsif value == "delete"
delete
elsif value == "complete"
complete
else
@view.... | true |
fa83449ec8504ee4b06ac3bd594ecf31a7fd44ab | Ruby | Elffers/advent_of_code | /2016/day02_spec.rb | UTF-8 | 2,137 | 3.09375 | 3 | [] | no_license | require_relative 'day02'
describe Decoder do
let(:input) { StringIO.new(<<INPUT
ULL
RRDDD
LURDL
UUUUD
INPUT
).readlines
}
describe 'part 1' do
let(:d) { Decoder.new Decoder::KEYPAD}
describe 'decode' do
it "returns correct ending key" do
instr = "ULL".chars
... | true |
5cee414212ef1e8f2ed5a9b41a1f7df019903780 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/whelper_source/23323.rb | UTF-8 | 200 | 3.078125 | 3 | [] | no_license | def combine_anagrams(words)
size = 0
a = Hash.new([])
words.each do |x|
r = 0
y = x.upcase
y = y.split("")
y = y.sort
y = y.join
a[y] += [x]
end
return a.values
end
| true |
87ae394ffb82ce63a48ac9a40470723134f3ada0 | Ruby | skoona/HomieMonitor | /mains/utils/utilities.rb | UTF-8 | 1,401 | 2.953125 | 3 | [
"MIT"
] | permissive |
module Utils
# The MQTT data is expected to be encoded as UTF-8 in the payload of the Packet. It is binary on occasion
# which raises an Encoding::InvalidByteSequenceError, or Encoding::UndefinedConversionError,
# or ArgumentError::invalid byte sequence in UTF-8.
# Homie requires all values transported via M... | true |
2a1dbd20393405408741d6174b0cc64a1a439d30 | Ruby | clamstew/cars | /cars.rb | UTF-8 | 2,702 | 3.875 | 4 | [] | no_license | class Car
attr_accessor :car_color, :convertible
#class variable: broad variables describing all vehicles
#not a single vehicle
@@total_car_count = 0
@@most_popular_color = {}
@@car_types = {}
def self.most_popular_color
@@most_popular_color.each { |k, v| return k if v == @@most_popular_color.values.max }
e... | true |
44ed8cbbbe75ebecbc9032f6b76e8381cdc9fa1d | Ruby | DrDhoom/RMVXA-Script-Repository | /NeonBlack/state_graphics_v1.3.rb | UTF-8 | 10,777 | 2.71875 | 3 | [
"MIT"
] | permissive | ##-----------------------------------------------------------------------------
## State Graphics v1.3
## Created by Neon Black
##
## For both commercial and non-commercial use as long as credit is given to
## Neon Black and any additional authors. Licensed under Creative Commons
## CC BY 3.0 - http://creativecommons.... | true |
941e328eb2c4b288aa8cac0d9b2381a355b4440e | Ruby | AngelaGuardia/backend_module_0_capstone | /day_1/exercises/ex7.rb | UTF-8 | 798 | 4.65625 | 5 | [] | no_license | print "How old are you? "
age = gets.chomp
print "How tall are you? "
height = gets.chomp
print "How much do you weigh? "
weight = gets.chomp
puts "So, you're #{age} old, #{height} tall and #{weight} heavy."
# Study drills
# 1. gets.chomp is composed of two methods: gets obtains input form the program
# user and ch... | true |
106408f7fe6557483d61844672211c754ea3c802 | Ruby | fagianijunior/cifra_manager | /test/models/user_test.rb | UTF-8 | 1,620 | 2.609375 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "cria usuario correto" do
assert_equal User.new({
first_name: 'Larissa', last_name: 'Cordeiro', email: 'lar@g.com',
password: '12345', password_confirmation: '12345'
}).save, ... | true |
ed1f7123123e70c9dfdde22e0f45454438bc3ea8 | Ruby | mmcduffie/notepad | /lib/notepad/notes.rb | UTF-8 | 1,056 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Notepad
class Notes
def show_all
result = []
all_notes = []
begin
db = SQLite3::Database.open DB_PATH
result = db.execute "SELECT * FROM Notes"
rescue SQLite3::Exception => e
puts "Exception occured"
puts e
ensure
db.close if db
e... | true |
817eda7324f776186be3990568551902277d7ff6 | Ruby | lekegitrepo/algorithms-and-data-structure | /algorithms - ruby/Binary-Search-Tree.rb | UTF-8 | 976 | 4.125 | 4 | [] | no_license | # frozen_string_literal: true
class Node
attr_reader :data
attr_accessor :left, :right
def initialize(data)
@data = data
end
end
class BST
def initialize(root = nil)
@root = nil
end
def insert(node, parent = @root)
# your code here
return @root = node if @root.nil?
return node if ... | true |
ec6d3381ab1fb786b4af585bd586c3d90082902b | Ruby | AmazingHorse/githook-youtrack | /youtrack_issue_message.rb | UTF-8 | 4,645 | 2.734375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'net/http'
## FILL THESE IN
# Youtrack server URL/port
$server_url = "10.86.86.132"
$port = 8080
# Youtrack credentials (root password plaintext, I know...)
$username = "root"
$password = "root"
## END
if $server_url.nil?
puts '[Error] $server_url not set, set this to your YouTrack u... | true |
dc22a8a4ada18a2f4482c5240a7a56b988a28e8f | Ruby | takin6/uzumeshi | /app/browsers/scraper/tabelog/tabelog_picture_scraper.rb | UTF-8 | 999 | 2.59375 | 3 | [] | no_license | require 'mechanize'
module Scraper
module Tabelog
class TabelogPictureScraper < Scraper::BaseScraper
MINIMUM_STANDARD_RANK = 3.45.freeze
attr_reader :agent, :restaurant_url
def initialize(restaurant_url)
begin
@agent = create_agent
@restaurant_url = restaurant_url
... | true |
ce46ea5941e1dd509ba004932da56d166c5b558f | Ruby | rn0rno/kyopro | /aoj/ruby/02_Volume0/0051.rb | UTF-8 | 130 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env ruby
n = gets.chomp!.to_i
n.times do
num = gets.split('').sort
puts num.reverse.join.to_i - num.join.to_i
end
| true |
f6068a816a124669fadc87b43ec778fde4ee7598 | Ruby | ServiceInnovationLab/PresenceChecker | /db/seeder/movements.rb | UTF-8 | 851 | 2.75 | 3 | [
"MIT"
] | permissive | require 'csv'
module Seeder
class Movements
def self.seed(spreadsheet_path, logger = Logger.new(STDOUT))
dataset = CSV.read(spreadsheet_path, headers: true)
logger.info "Loading Movements..."
dataset.each_with_index do |row, i|
begin
model = Movement.find_or_create_by(
... | true |
93236f5ae074b75f3b8a590accbdfe51b7bc3383 | Ruby | zsmialek/ProgrammingLanguages | /Hangman/hangman.rb | UTF-8 | 3,254 | 4.125 | 4 | [] | no_license | require './words'
class Hangman
def initialize(filename)
@welcome_message = "Let's play hangman"
@init_board = ""
@max_wrong = 5
@used_letters = ""
@filename = filename
puts(@welcome_message)
end
def get_default_filename()
filename = Dir.glob('**/*.txt')
return filename
... | true |
007e14e581985199a656a7d628c8b1c8505e7918 | Ruby | lion-jg/furima-28838 | /spec/models/item_spec.rb | UTF-8 | 3,105 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
end
describe Item do
before do
@item = FactoryBot.build(:item)
end
describe '商品出品' do
context '出品がうまくいくとき' do
it 'image,item_name,detail,category,item_condition,delivery_fee,shipping_origin,shipping_leadtime,priceが存在すれば登録できる' do
e... | true |
908c989375a5253cc78adb6ec08e1603013739c7 | Ruby | AskBid/ruby-music-library-cli-online-web-sp-000 | /lib/mi.rb | UTF-8 | 249 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
include Concerns::Extras
attr_accessor :path
def initialize(path)
@path = path
end
def files
normalize(Dir[path + "/*"])
end
def import
self.files.each {|file_name| Song.create_from_filename(file_name)}
end
end | true |
94daadcfbfe9f1eb6c7afb73140cb683e68c2a5f | Ruby | reu/spreadshit | /bin/demo | UTF-8 | 1,483 | 3.125 | 3 | [] | no_license | #!/usr/bin/env ruby
require "bundler/setup"
require "spreadshit"
require "spreadshit/window"
sheet = Spreadshit.new
[
"Sum",
10,
20,
30,
"",
"=A2 + A3 + A4",
"=SUM(A2; A3; A4)",
"=SUM(A2:A4)"
].each_with_index do |cel, index|
sheet["A#{index + 1}"] = cel
end
# Fibonacci
sheet[:B1] = "Fibonacci"
she... | true |
68cc8c97bd998c4512d19f9e6feda64cc481f4ba | Ruby | rsmithII/ruby-enumerables-hash-practice-emoticon-translator-lab-den01-seng-ft-091420 | /lib/translator.rb | UTF-8 | 865 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
require 'yaml'
def load_library(file_path)
hash = {}
emoticons = YAML.load_file(file_path)
emoticons.each do |key, value|
hash[key] = {}
hash[key][:english] = value[0]
hash[key][:japanese] = value[1]
end
hash
end
#emoticons is a hash of emoticons {}
#language is the key emoticons[:e... | true |
f7b95114a70680e252ac03a27ddab0c3ebebc6bb | Ruby | sent-hil/open_auth2 | /lib/open_auth2/connection.rb | UTF-8 | 767 | 2.578125 | 3 | [
"LicenseRef-scancode-other-permissive",
"MIT"
] | permissive | module OpenAuth2
class Connection
attr_accessor :verb, :headers, :url, :body, :params
def initialize(verb, params)
@verb = verb
@headers = params.delete(:headers) || {}
@url = params.delete(:url) || ''
@body = params.delete(:body) || ''
@params = params
end
def fetch
... | true |
3bfe037e6ad5b3c8d040d6f1794d50add8629fd7 | Ruby | croo/Ruby-Kata | /StringCalc/stringcalc.rb | UTF-8 | 424 | 3.203125 | 3 | [] | no_license | class StringCalc
def add( string )
delimiter = " "
numbers = Array.new
if(string[0] == '\\')
delimiter,*numbers = string.split("\n")
delimiter = delimiter[1..-1]
numbers = numbers.join("\n").split(/[#{delimiter}\n]/)
else
numbers = str... | true |
2fadb3528c2576ef79ae76b683c491eb656179cd | Ruby | guiceolin/SAAP | /lib/gcal/event.rb | UTF-8 | 669 | 2.71875 | 3 | [] | no_license | require 'gcal/basic_object'
require 'gcal/datetime'
module Gcal
class Event < Gcal::BasicObject
# List of attributes returned from Google Calendar API
# See https://developers.google.com/google-apps/calendar/v3/reference/events
attributes %w(id calendar_id summary description location start end)
attr... | true |
5e1cf39daf5247288c47fb1325a6fa8326cd7565 | Ruby | fc-thrisp-hurrata-dlm-graveyard/shout | /lib/postingsessioncheck.rb | UTF-8 | 584 | 2.875 | 3 | [] | no_license | # some notes on more thorough session handling
#Posting session check
class Postingsessioncheck
if session[:initial_time_post].nil?
session[:initial_time_post] = Time.now.to_f
end
if session[:time_post].nil?
session[:time_post] = session[:initial_time_post]
end
if session[:post_count].nil?
... | true |
4308362dc0fe2df3276dbf8c28600f837fe5ac51 | Ruby | clemieux55/golf_assignment | /scorecard.rb | UTF-8 | 232 | 2.921875 | 3 | [] | no_license | require 'csv'
require 'pry'
class ScoreCard
def initialize(player_score)
@player_score = player_score
end
def scores_for_player
CSV.foreach(@player_score) do |score|
@score_card = score
end
@score_card
end
end
| true |
a13cec0d81329e27a9480a42c7dbb867d2ff080f | Ruby | kchervin/phase-0-tracks | /ruby/hashes.rb | UTF-8 | 829 | 3.296875 | 3 | [] | no_license | # prompt user for data
# convert user input to appropriate data
# print hash when all questions complete
# ask user if update necessary
# if no - skip
# if yes, what key and what value
# print latest version
client_info = {}
puts "name"
client_info[:name] = gets.chomp
puts "age"
client_info[:age] = gets.chomp.to_i
... | true |
650ef65cce48164d15b0a9de2c016906c83ae48e | Ruby | tommydangerous/caldjs | /app/helpers/photos_helper.rb | UTF-8 | 1,508 | 2.546875 | 3 | [] | no_license | module PhotosHelper
def photo_types
%w(jpeg png gif pjpeg x-png bmp jpg ico)
end
def upload_check_resize(upload_name, upload_file)
if upload_file.nil?
flash[:error] = 'File cannot be blank'
redirect_to upload_path
else
name = upload_file.original_filename
directory = 'public/... | true |
cf8c79ad96816829231c3f2ccf9ba945d7bcde37 | Ruby | nesquena/backburner | /lib/backburner/performable.rb | UTF-8 | 3,679 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'backburner/async_proxy'
module Backburner
module Performable
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:include, Backburner::Queue)
base.extend ClassMethods
end
module InstanceMethods
# Return proxy object to enqueue jobs for object
# O... | true |
b287ac40c2d4941619527f31d8a98d8a9ecea940 | Ruby | ColinTheRobot/BEWD_NYC_5_Homework | /Dan_M/bob.rb | UTF-8 | 275 | 3.453125 | 3 | [] | no_license | class Bob
def hey(message)
if message == message.upcase && !message.strip.empty? && message =~ /[a-zA-Z]/
'Woah, chill out!'
elsif message.strip.empty?
'Fine. Be that way!'
elsif message.end_with '?'
'Sure.'
else
'Whatever.'
end
end
| true |
a66ce58ecdbea1f27104160d1ea36d2451520fd4 | Ruby | dwaynemac/overmind | /app/controllers/api/v0/monthly_stats_controller.rb | UTF-8 | 4,094 | 2.515625 | 3 | [] | no_license | # @restful_api v0
class Api::V0::MonthlyStatsController < Api::V0::ApiController
# @action GET
# @url /api/v0/monthly_stats
# @required [String] api_key
#
# @optional [Hash] where
# @key_for where year always use with month
# @key_for where month always use with year
# @key_for where name
# @key_fo... | true |
c91dc7a53e80a64634033dd072a2457234e7cd1a | Ruby | mbadilla86/Intro_objects_rails | /inheritance/mammal.rb | UTF-8 | 190 | 3.09375 | 3 | [] | no_license | class Mammal
attr_reader :drink_milk, :breath
def initialize
@drink_milk = true
@breath = :lungs
end
def move
"Porque soy"
end
def stop
"Me detengo"
end
end | true |
a35e4a067c61c4a34cdd2f733bb7335a28f01994 | Ruby | DennisTheMenace/Yugioh-game | /Draw.rb | UTF-8 | 1,434 | 3.8125 | 4 | [] | no_license | #!/usr/bin/env ruby
# In Resources.rb? - Yes
# Method used for drawing a card.
# INSTRUCTIONS:
# To draw a card use this command template - 'draw(player, output, card)'
# Replace player with 0 or 1 to determine which player is drawing. 0 = player 1 and 1 = player 2
# Replace outout with 'yes' or 'no' depending on i... | true |
df484b7ce27754fa74f9fa60cf62210854b04c2a | Ruby | dmbf29/animal-kingdon-363 | /interface.rb | UTF-8 | 362 | 3.578125 | 4 | [] | no_license | require_relative 'lion'
require_relative 'meerkat'
require_relative 'warthog'
# In another Ruby file, create an array with Simba, Nala, Timon & Pumbaa, iterate over it and puts the sound each animal make
animals = [Lion.new("Simba"), Lion.new("Nala"), Meerkat.new('Timon'), Warthog.new('Pumbaa')]
animals.each do |anim... | true |
c577568b009514df4171bfefff802bcb670287f1 | Ruby | DShield-ISC/cloud-ranges | /asn | UTF-8 | 5,437 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'json'
require 'mechanize'
require 'nokogiri'
require 'fileutils'
require 'colorize'
@agent = Mechanize.new
country = "us"
def msg(msg)
puts "[*] #{msg}".blue
end
def countries()
countries = []
html = @agent.get("https://ipinfo.io/countries/").body()
Nokogiri::HTML(html).css("tr"... | true |
f0773d6cff54eaef54c9ece6900bda97934363cd | Ruby | yerdua/poker | /spec/deck_spec.rb | UTF-8 | 992 | 3.390625 | 3 | [] | no_license | require 'rspec'
require 'deck'
describe "Deck" do
subject(:deck) { Deck.new }
it "has 52 cards" do
subject.count.should == 52
end
describe "#shuffle!" do
it "changes the order of the cards" do
original_order = subject.cards.dup
subject.shuffle!
subject.cards.should_not == original_o... | true |
c8413105d782ceb1d27917ceda12da9f4baebb4d | Ruby | albandrod/LearnToProgram | /chapter_2/minutes_in_a_decade.rb | UTF-8 | 67 | 2.671875 | 3 | [] | no_license | # 60 minutes, 24 hours, 365 days, 10 years
puts 60 * 24 * 365 * 10
| true |
b37ee0ee5f8df7ee596ed64bbec248c274f23636 | Ruby | micktaiwan/rubymlib | /SDP/SDPService.rb | UTF-8 | 2,403 | 2.578125 | 3 | [] | no_license | # Juste un test pour l'instant
# require 'soap/wsdlDriver'
# wsdl = 'http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl'
# driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
# puts "Stock price: %.2f" % driver.getQuote('TR')
SERVER = "sqli.ideoproject.com"
URL = "/sdp/sdp_tlk_interfa... | true |
f820abea497c36daf4f72e9278544521809f8946 | Ruby | Epigene/hashrush | /spec/hashrush_spec.rb | UTF-8 | 1,911 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Hashrush do
context "Excepetions" do
it 'should raise if binding is not passed' do
expect{Hash.build_from_symbol_variables(nil)}.to raise_error(ArgumentError, "Oops, expected the first argument to be a binding object. Try `Hash.rush(binding, :some_variable_name)`")
end
... | true |
6ccf528489a64f5a7003adeb788fba1d001d1a94 | Ruby | Within3/totally_tabular | /lib/totally_tabular/html_helper.rb | UTF-8 | 510 | 2.578125 | 3 | [
"MIT"
] | permissive | module TotallyTabular
class HtmlHelper
EMPTY_TAG = /br|hr|img|meta|link|input|base|area|col|frame|param/
def content_tag(tag, content="", attributes={})
if tag.to_s =~ EMPTY_TAG
"<%s%s>" % [tag, attrs(attributes)]
else
"<%s%s>%s</%s>" % [tag, attrs(attributes), content, tag]
... | true |
b93d3971cd7ff4e8561ded50680eb495ef432041 | Ruby | davidenglishmusic/chord_recognizer | /lib/theorist.rb | UTF-8 | 3,100 | 3.21875 | 3 | [
"MIT"
] | permissive | require 'chord'
class Theorist
PITCH_NUMBER_MAP =
{
'c' => 0,
'c#' => 1,
'c sharp' => 1,
'db' => 1,
'd flat' => 1,
'd' => 2,
'd#' => 3,
'd sharp' => 3,
'eb' => 3,
'e flat' => 3,
'e' => 4,
'e#' => 5,
'e sharp' => 5,
'fb' => 4,
... | true |
7d92633c6d9c70c89c11f1dc36129599713f425a | Ruby | marwei/record-locator | /spec/models/record-locator_spec.rb | UTF-8 | 2,508 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require File.expand_path(File.dirname(__FILE__) + '../../../lib/record-locator/record-locator-util')
require File.expand_path(File.dirname(__FILE__) + '../../../models/book')
describe 'RecordLocator' do
describe 'EncoderAndDecoder' do
it "Should produce an encoded ID that the original ID... | true |
d830ecf27042f3daf730cb9df94cd20348c6d6a6 | Ruby | jamilvelji/bitmaker_day_3 | /exercise6.rb | UTF-8 | 570 | 3.90625 | 4 | [] | no_license | def list_display(list_to_sort)
list_to_sort.each do |x|
puts "* #{x}\n"
end
end
grocery_list = ["water", "soap", "bread", "chicken"]
grocery_list << "rice"
list_display(grocery_list)
puts "Number of items to pick up: #{grocery_list.length}"
if grocery_list.include?("bananas")
puts "You need to pickup bananas"... | true |
686e05c58edddf59031b10bbed2b36708adf210d | Ruby | pabloroz/linked_lists | /problem_2/solution.rb | UTF-8 | 444 | 3.609375 | 4 | [] | no_license | require './linked_list_node'
require './list_reverser'
def print_values(list_node)
print "#{list_node.value} --> "
if list_node.next_node.nil?
print "nil\n"
return
else
print_values(list_node.next_node)
end
end
node1 = LinkedListNode.new(37)
node2 = LinkedListNode.new(99, node1)
node3 = LinkedList... | true |
6365b688b588223bb44dd252126465e4fbc457b2 | Ruby | y5f/Projects | /ProjetMOSSCOVI/versionRubyHW/Codeur/lecture.rb | UTF-8 | 1,051 | 3.140625 | 3 | [] | no_license | require_relative 'pixel'
class Lecture < Reactiv
# Déclaration des attribus de la classe Lecture
# Port de sortie
outports :s
# Nombre de pixel ligne de l'image
LIGNE = 384
# Nombre de pixel colonne de l'image
COLONNE = 512
# Nom du fichier texte qui contient les valeurs des pixels "R, G,... | true |
f2764d3990619b3fb4f462afe4dd91851a100941 | Ruby | toaco/incrcov | /lib/incrcov.rb | UTF-8 | 6,173 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'incrcov/version'
require 'incrcov/git_helper'
require 'incrcov/incr_block_analyzer'
require 'incrcov/simple_cov_json_parser'
require 'incrcov/config'
require 'incrcov/argv_parser'
require 'logger'
require 'terminal-table'
require 'markdown-tables'
module Incrcov
class Error < StandardError
end
class <<... | true |
4afdfef4f6f07b0523ddc4bbd1e83cac0bf6a1a3 | Ruby | burrahey/scheduler | /app/models/schedule.rb | UTF-8 | 1,162 | 2.625 | 3 | [
"MIT"
] | permissive | class Schedule < ApplicationRecord
has_many :shifts, dependent: :destroy
has_many :employees, through: :shifts
def self.check_date_validity(date)
if date.empty?
return "Please enter a valid date"
elsif Schedule.find_by_any_date(date)
return "A schedule already exists for this time"
else
... | true |
3858ba24d90f3b236daaadf0122dacae65d3505c | Ruby | olliebaum/rspec-practice | /lib/float_precision.rb | UTF-8 | 50 | 2.71875 | 3 | [] | no_license | def solution(number)
return number.round(2)
end
| true |
8b2eec9d4ad7ed0451c00ff3af7f7ba5c553ef30 | Ruby | EarLyMe/ttt-with-ai-project-v-000 | /lib/players/human.rb | UTF-8 | 130 | 3 | 3 | [] | no_license | class Human < Player
#-----gets pos for player move-----#
def move(board = Board.new)
pos = gets.chomp
pos
end
end | true |
54407f94ddf8b72fdfbc485660fa86836b70c762 | Ruby | CUBigDataClass/BigDataRailsRepo | /app/workers/tweet_index_worker.rb | UTF-8 | 737 | 2.5625 | 3 | [] | no_license | # Sidekiq worker to index tweets into elasticsearch
class TweetIndexWorker
include Sidekiq::Worker
include SimpleElasticSearch
def perform(tweet_arr)
bulk_index format_tweets(tweet_arr)
end
private
def bulk_index(arr)
payload = arr.inject([]) do |acc, tweet|
acc << { index: { _index: $elast... | true |
dc5edf17f93a67f985d781b35d102164c018c369 | Ruby | xdothackerx/data-structures | /test/sort_test.rb | UTF-8 | 4,707 | 3.140625 | 3 | [] | no_license | require "minitest/spec"
require "minitest/autorun"
require "benchmark"
require "./lib/sort"
require "pry"
require "pry-nav"
def gen_nums(type)
if type == "random"
(-10000..10000).to_a.shuffle
elsif type == "nearly-ordered"
nums = (-10000..10000).to_a
move = nums[0]
nums[0] = nums[1]
nums[1] = m... | true |
bb194d15769029579bbd677c2b44c6a15fc2282a | Ruby | MelissaAJohnson/sep-assignments | /02-algorithms/01-introduction/fibonacci_iterative.rb | UTF-8 | 335 | 3.921875 | 4 | [] | no_license | def fib( n )
if n == 0
puts "No values"
elsif n == 1
b = 1
puts b
else
if n > 1
a,b = 0,1
n.times do
a,b = b,a+b
puts b
end
puts "\n"
end
end
end
puts fib(0)
puts fib(1)
puts fib(2)
puts fib(3)
puts fib(4)
puts fib(5)
puts fib(6)
puts fib(7)
puts fib(... | true |
7dbe948178c8113dc6ab5a8a5d0186c18e0f55ca | Ruby | seidelmaycon/mars-rovers-ruby | /lib/direction/south.rb | UTF-8 | 212 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
class South < Direction
def to_forward(current_location)
x = current_location[0]
y = current_location[1]
[x.to_i, y.to_i - 1.to_i]
end
def to_s
'S'
end
end
| true |
063a2e9012eb9101b000f4181123140026aece18 | Ruby | Squarix/Ruby-Labs | /RubyTest/RSpec/spec/array_rotation_spec.rb | UTF-8 | 1,361 | 3.21875 | 3 | [] | no_license | require 'rspec'
require_relative '../lib/array_rotation.rb'
describe NewArray do
let(:empty_array) { described_class.new([]) }
let(:array) { described_class.new([1, 2, 3, 4, 5]).rotate_arr(-1) }
let(:new_array) { described_class.new([1, 2, 3, 4, 5]) }
let(:err_message) { 'Error' }
describe 'lookup'... | true |
9e7d177e040e479bee2f52a46b793dffe5888392 | Ruby | bgroveben/OdinProject | /ruby/LearnToProgram/ch10.rb | UTF-8 | 5,902 | 4.5625 | 5 | [] | no_license | # Blocks and Procs
toast = Proc.new do
puts 'Cheers!'
end
toast.call
toast.call
toast.call
puts
# Blocks can take parameters:
do_you_like = Proc.new do | a_good_thing |
puts 'I *really* like ' +a_good_thing+'!'
end
do_you_like.call 'chocolate'
do_you_like.call 'ruby'
puts
# You can't pass methods into other met... | true |
b8f9b17647878fa05578a70664d68a6e99f90cfb | Ruby | srajiang/app-academy-classwork | /w3/w3d2/memory/game.rb | UTF-8 | 636 | 2.53125 | 3 | [] | no_license | class Game
end
# guessed_pos
# Card at guessed_position
# previous_guess, initially set to nil
#play
# a loop where player gives us a guessed position
# reveal the card at the guessed position -- system clear + render here
# if previous guess is nil, then make prev guess point to card at Guessed positi... | true |
5226742dcea0b28640113006a9daaa7f1bd6d8b1 | Ruby | scottishasian/Money_saver_project | /models/user.rb | UTF-8 | 888 | 3.15625 | 3 | [] | no_license | require('pg')
require_relative('../db/sql_runner')
class Budget
attr_accessor :budget
def initialize(options)
@budget = options['budget'].to_f
end
def save()
sql = "INSERT INTO budget (budget)
VALUES ($1)
RETURNING *"
values = [@budget]
result = SqlRunner.run(sql, value... | true |
ad0ddb079291c674e9d9b2a53b3ea6ef4b2cca1a | Ruby | georgehwho/ruby-exercises | /mythical-creatures/lib/medusa.rb | UTF-8 | 496 | 3.265625 | 3 | [] | no_license | class Medusa
attr_reader :name, :statues
def initialize(n)
@name = n
@statues = []
end
def stare(v)
if self.statues.length < 3
self.statues << v
v.stoned = true
else
self.statues.first.stoned = false
self.statues.shift
self.statues << v
v.stoned = true
e... | true |
4e6ceffd0bdc276f9e8a9c6d343654c5b1ffd021 | Ruby | johnkeith/todocl | /td.rb | UTF-8 | 1,900 | 3.453125 | 3 | [] | no_license | class Todo
def clear_screen
system "cls"
end
def open_app
clear_screen
view_all
end
def view_all
clear_screen
list_read = read_list
list_read.each do |line|
puts line if !line.include?("COMPLETE")
end
choose_action
end
def read_list
list = File.open("mylist.txt","r").readlines
end
d... | true |
d967af4cc18f8a064dceb64c1327b9156ffb6290 | Ruby | proheng/sample_app | /spec/controllers/users_controller_spec.rb | UTF-8 | 3,009 | 2.734375 | 3 | [] | no_license | require 'spec_helper'
describe UsersController do
render_views
describe "GET show" do
before :each do
@user = FactoryGirl.create :user_fixture
end
it "should be successful" do
get :show, :id => @user.id
response.should be_success
end
it "should find the right user" do
... | true |
57db07dbb023356daf4fceb1c452dfe16d134d07 | Ruby | tatano-nmed/ruby-exercise | /tesuto01.rb | UTF-8 | 870 | 3.890625 | 4 | [] | no_license | print("Hello, Ruby.\n")
puts "aaaa,Ruby."
puts "aaaa", "Ruby."
puts Math.sin(4) #関数
x = 40
y = 20
z = 60
area = (x*y + y*z + z*x) * 2
puts "表面積=#{area}"
#配列
names = ["aa","bb","cccccc"]
puts names.size
names.each do |n|
puts n
end
#Hash
address = {name:"高橋" , kananame:"タカハシ" , tel:"010... | true |
954ec7d1023612545f43370b2c7ddaff5089f4b4 | Ruby | szTheory/rforvo | /lib/rforvo.rb | UTF-8 | 1,205 | 2.53125 | 3 | [
"WTFPL"
] | permissive | # -*- encoding : utf-8 -*-
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar
# 14 rue de Plaisance, 75014 Paris, France
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and cha... | true |
19d1a8721dc41ab7f2763c7762fc246c76330b4a | Ruby | clustermass/RSpec_W2D3 | /TDD_exercises/spec/methods_spec.rb | UTF-8 | 1,121 | 3.703125 | 4 | [] | no_license | require 'methods'
require 'rspec'
describe Array do
describe "#my_uniq" do
it "returns an array with no duplicates" do
expect([1,2,2,3,3,4,2].my_uniq).to eq([1,2,3,4])
end
end
describe "#two_sum " do
it "returns an array with indexes where two elements sum to 0" do
expect([-1, 0, 2, ... | true |
5ec8dd0f79f68923ec14635c13af842063c600cf | Ruby | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Ruby/van-der-corput-sequence.rb | UTF-8 | 188 | 3.234375 | 3 | [] | no_license | def vdc(n, base=2)
str = n.to_s(base).reverse
str.to_i(base).quo(base ** str.length)
end
(2..5).each do |base|
puts "Base #{base}: " + Array.new(10){|i| vdc(i,base)}.join(", ")
end
| true |
995f521cfc0061adb602b924460482255e313d72 | Ruby | tommchenry/phase-0 | /week-5/gps2_2.rb | UTF-8 | 3,197 | 4.53125 | 5 | [
"MIT"
] | permissive | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# [fill in any steps here]
# set default quantity
# print the list to the console [can you use one of your other methods here?]
# output: [what data type goes here, array or hash?]
def create_... | true |
e002808f3d1abb0beced7a24867cf222f81468a9 | Ruby | stephenjust/ruby-shell-timer-filemonitor | /lib/contracts/timer_contract.rb | UTF-8 | 535 | 2.609375 | 3 | [] | no_license | require 'test/unit/assertions'
module Contracts
module Timer
include Test::Unit::Assertions
def pre_wait_then_execute(time, &block)
assert_not_nil time, "time cannot be nil"
assert (time > 0), "time cannot be less than or equal to zero"
assert_not_nil block, "action cannot be nil"
end
... | true |
03d89a0e259dbe3e26116fd8d45f3441b6e63cb6 | Ruby | RitchieCampbell/ruth-r | /knight.ru | UTF-8 | 6,873 | 3.09375 | 3 | [] | no_license | CONSTANTS
moves ARRAY[-17, -15, -10, -6, 6, 10, 15, 17], eight 8, sixtyfour eight * eight
END
VARIABLES priorities INT[64], moveSet ℙ(INT), sqSet ℙ(INT) END
/* Convert indices from 0-based to 1-based */
i INT ← getIndex(index INT) ≙ i := index + 1 END ;
/*
* Set up priorities as per Alwan and Waters' second exam... | true |
c61a0fdeede4e337e1dac234168e5901d7da9d4d | Ruby | LupusDei/spacetowerdefense | /lib/creep/creep.rb | UTF-8 | 6,498 | 3.0625 | 3 | [] | no_license | module Creep
SPEED = 3 unless defined?(SPEED)
CREEP_RADIUS = 8 unless defined?(CREEP_RADIUS)
MOVE_SLEEP_TIME = 0.075 unless defined?(MOVE_SLEEP_TIME)
class Creep1
class << self
attr_accessor :health, :kill_val, :image_file, :move_speed
end
self.health = [0,10,110,450,1130]
self.k... | true |
303fb21622da962b0984a3c6cac66b017115cfba | Ruby | canopus93/pokemon_rainbow | /app/helpers/pokedexes_decorator.rb | UTF-8 | 2,002 | 2.671875 | 3 | [] | no_license | class PokedexesDecorator
include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::AssetTagHelper
PokedexesDecoratorResult = Struct.new(
:id,
:name,
:base_health_point,
:base_attack,
:base_defence,
:base_speed,
:element_type,
:image,
:image_s... | true |
ec9808c0a63092eb89086a1d38a34a2575bb304a | Ruby | alvarogonzalezsotillo/GoogleCodeJam | /Practice/Solved/All Your Base/AllYourBase.rb | UTF-8 | 2,224 | 3.109375 | 3 | [] | no_license | $ioin = $stdin
$ioout = $stdout
class GCJCase_Base
attr_reader :solution, :index, :problem
def initialize(index, problem)
@index = index
@problem = problem
end
def log(s,ioout=$stderr)
ioout.puts s
end
def dumpSolution(ioout=$ioout)
ioout.puts "Case ##{index}: #{solution}"
end
... | true |
e18adb3928fb78f56ee9719948388c8b35060e65 | Ruby | joegelay/data-structures | /binary-search.rb | UTF-8 | 753 | 4.15625 | 4 | [] | no_license | # return "not found" if value is not in array
# [1,2,3,4,5,6,7,8,9]
def binary_search(input_array, value)
low = 0
high = input_array.length - 1
while (low <= high)
mid = (low + high) / 2
if input_array[mid] == value
return mid
elsif input_array[mid] < value
... | true |
60730d241f07457c6f03f3a0604478b66513ca15 | Ruby | MatthiasGi/Tapeinos | /app/helpers/settings_helper.rb | UTF-8 | 1,261 | 3.03125 | 3 | [] | no_license | # This helper is full of static methods for loading, reading and writing
# application-wide settings.
module SettingsHelper
# Gets a setting and returns the default value if (and only if) the setting
# could not be found.
def self.get(key, default = nil)
value = getHash[key.to_sym]
value.nil? ? de... | true |
e2dbecb42fec8c86534c09e259b52a45006bbb2d | Ruby | mjgold/ruby-exercises | /word_count.rb | UTF-8 | 1,201 | 4.40625 | 4 | [
"MIT"
] | permissive | # Method name: word_count
# Input: A string representing an English sentence
# Returns: The number of words in the sentence
# Prints: Nothing
#
# Although it's more complicated in relaity, we'll just pretend
# that sequence of spaces in a sentence designates the start of a new word.
# That means we don't care about how... | true |
c2be5d7f7f1a1a34f7e87ffbbeb39cc0283aab82 | Ruby | xilaraux/db-lite | /tests/rspec/database.rb | UTF-8 | 556 | 2.84375 | 3 | [
"MIT"
] | permissive | describe 'database' do
def run_script(commands)
raw_output = nil
IO.popen("./bin/db.o", "r+") do |pipe|
commands.each do |command|
pipe.puts command
end
pipe.close_write
# Read entire output
raw_output = pipe.gets(nil)
end
raw_output.split("\n")
end
it 'inserts and retreives a row' do
... | true |
e77c0d65c6901aa41fd8b6d5ed0b8520ed2b7433 | Ruby | jackeyho/rubyweek1_exercise | /ruby_exercise.rb | UTF-8 | 372 | 3.53125 | 4 | [] | no_license | a = [1,2,3,4,5,6,7,8,9,10]
a.each { |element| puts element }
a.each { |element| puts element if element > 5}
new_arr = a.select { |e| e % 2 != 0 }
puts new_arr
a << 11
a.unshift(0)
puts a
puts a.join(', ')
a.pop
puts a.join(', ')
a << 3
puts a.join(', ')
puts a.uniq.join(', ')
... | true |
ddf2819e8b7eb67c7617665c9a6214dc7aa28bfc | Ruby | tadpreston/capsule_app | /db/migrate/20141220204928_first_last_to_full_name.rb | UTF-8 | 596 | 2.515625 | 3 | [] | no_license | class FirstLastToFullName < ActiveRecord::Migration
def up
add_column :users, :full_name, :string
User.all.each do |user|
user.update_attribute(:full_name, "#{user.first_name} #{user.last_name}")
end
remove_column :users, :first_name
remove_column :users, :last_name
end
def down
a... | true |
690eac95d594fb558fe556eb30d1bfa67be63edb | Ruby | Larrypg31/launch_school | /exercises/101_109_small/medium_2/letter_case.rb | UTF-8 | 597 | 4.15625 | 4 | [] | no_license | # Lettercase Percentage Ratio
def letter_percentages(string)
total_chars = string.size
lowercase = string.count('a-z') / total_chars.to_f * 100
uppercase = string.count('A-Z') / total_chars.to_f * 100
neither = 100 - (lowercase + uppercase).to_f
hash = {
lowercase: lowercase,
uppercase: uppercase,
... | true |
86b0caa4f2abc04d76a9b07160f1f02ed9453811 | Ruby | d12/leetcode-solutions | /0746-min_cost_climbing_stairs.rb | UTF-8 | 1,184 | 3.71875 | 4 | [] | no_license | # O(N) time, O(n) space since costs is passed as a reference and not modified
def min_cost_climbing_stairs(cost)
min_cost_climbing_stairs_recursive([0] + cost, 0, {})
end
def min_cost_climbing_stairs_recursive(costs, index, memo)
return memo[index] if memo[index]
return 0 if index >= costs.length
min = [
... | true |
388759d79206b8ed9a11421041a93e59660ac7b2 | Ruby | bubersson/RubyHomeworks | /RubyPrivatizace/lib/engine/menu_state.rb | UTF-8 | 4,177 | 2.546875 | 3 | [] | no_license | # Menu players selection
# - select players with keyboard and then press Start game
class MenuState < StateMachine
def initialize(base)
super
@privatizace = base.game_objects[:privatizace]
@players = base.game_objects[:players]
@background = base.game_objects[:menu_background]
#@playe... | true |
e96cf5d460e247eaf7f8d6cb35f13421403a3921 | Ruby | iboyards/git_boyards | /Lesson_8/cargo_train.rb | UTF-8 | 162 | 2.921875 | 3 | [] | no_license | class CargoTrain < Train
attr_accessor :car
def initialize(number, type = 'cargo')
super
end
def acceptable?(car)
car.is_a?(CargoCar)
end
end
| true |
3204e8ea16b80ebc9e971af01d1e836467d8699d | Ruby | dnlR/lyrics_finder | /spec/support/sample_songs.rb | UTF-8 | 5,865 | 2.546875 | 3 | [
"MIT"
] | permissive | module SampleSongs
LYRICS_WIKIA_EXAMPLE = ["I had a dream so big and loud",
"I jumped so high I touched the clouds",
"Wo-oah-oah-oah-oah-oh",
"(Wo-oah-oah-oah-oah-oh)",
"I stretched my hands out to the sky",
... | true |
26d266876898da3b7ec89cde8f4cefa9a30b002d | Ruby | milep/computer_handbook | /ruby/3_evil_eyes.rb | UTF-8 | 1,326 | 3.25 | 3 | [] | no_license | require 'curses'
include Curses
class Point
attr_reader :x, :y
def initialize(x, y)
@x = x
@y = y
end
end
def draw_eyes(point)
sleep((rand 50) / 10.0)
setpos(point.y, point.x)
addstr("OO")
setpos(28, 20)
end
def correct_answer(point)
setpos(point.y, point.x)
addstr("XX")
setpos(28, 20)
... | true |
6a2adc0b4d2f305d355b3993d2b9da788769cbf8 | Ruby | projectblacklight/blacklight | /app/values/blacklight/types.rb | UTF-8 | 2,283 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require "active_model"
module Blacklight
# These are data types that blacklight can use to coerce values from the index
module Types
@registry = ActiveModel::Type::Registry.new
class << self
delegate :lookup, :register, to: :@registry
end
class Value
def... | true |
14dd4c5ab24bf3520a1b8fe4d53a19fc37976a23 | Ruby | felixgirault/essence.rb | /lib/provider_collection.rb | UTF-8 | 1,149 | 2.71875 | 3 | [] | no_license | #
# AUTHOR Félix Girault <felix.girault@gmail.com>
# LICENCE FreeBSD License (http://opensource.org/licenses/BSD-2-Clause)
#
module Essence
#
#
#
class ProviderCollection
#
# Loads the given providers.
#
def initialize( config = { })
@config = case
when config.is_a?( String ) self.load( @config... | true |
87331f89d4e4ab03568c37456cdc61af6b6a470a | Ruby | elzj/ao3_api | /lib/otw/word_counter.rb | UTF-8 | 1,656 | 3.15625 | 3 | [] | no_license | # encoding=utf-8
require 'nokogiri'
module Otw
class WordCounter
# List of Unicode scripts where spaces are not used as separators,
# and character counts should be used for word counts.
# Check if a script is supported by the version of Ruby we use:
# https://ruby-doc.org/core/Regexp.html#class-Reg... | true |
5313af4249dbc6831713d83649f38884b21a313c | Ruby | andibachmann/texserial | /lib/texserial/erb_struct.rb | UTF-8 | 445 | 2.609375 | 3 | [] | no_license | require 'ostruct'
require 'erb'
module Texserial
#
# use:
# ErbStruct.template_file =
class ErbStruct < OpenStruct
def self.template_file=(file_path)
@template_file = file_path
end
def self.template
@template ||= ERB.new(File.read(@template_file))
end
def self.render_fr... | true |
524f8c2c9dfe5d380683575eb4d339bf5aeaac02 | Ruby | secorjeretweaz/als_typograf | /lib/active_model/typograf.rb | UTF-8 | 2,766 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'active_model'
module ActiveModel
module Typograf
module InstanceMethods
# Run AlsTypograf#process on configured columns.
# Used to run as before_validation filter (automaticaly added on ActiveRecord::Base.typograf)
def typograf_current_fields
self.class.typograf_fields.each do ... | true |
1c37a574a00aaf4d87551e8882618ff20e5b14ef | Ruby | dlweinstein/msm_associations | /app/models/director.rb | UTF-8 | 649 | 2.625 | 3 | [] | no_license | class Director < ApplicationRecord
# - name: must be present; must be unique in combination with dob
validates :name, :presence => true, :uniqueness => { :scope => :dob }
# - dob: no rules
# - bio: no rules
# - image_url: no rules
# FIND ALL THE MOVIES FOR A DIRECTOR
# :movies: Define a method called .mov... | true |
da174734bf5ee5de7a8bc1875af0b8976578e7cd | Ruby | jordanmoore753/EasyPortfolio | /lib/easy_portfolio/output.rb | UTF-8 | 1,346 | 2.9375 | 3 | [] | no_license | class Output
TEMPLATE = "'easy_portfolio_template'"
def welcome
message 'Welcome to EasyPortfolio!'
end
def describe
message 'EasyPortfolio creates a Sinatra-powered portfolio skeleton.'
end
def ask_for_permission
message 'Would you like to install the project directory?'
message "This wi... | true |
444b615891a0c856d7f3df3bb8fcb15790ab1584 | Ruby | emalfano/programming-foundations | /lesson_3/easy_1.rb | UTF-8 | 3,170 | 4.6875 | 5 | [] | no_license | # q1
# I expect the code to print [1, 2, 2, 3] because #uniq doesn't mutate the obj
# it will print in the puts format 1 2 2 3 on separate lines
numbers = [1, 2, 2, 3]
numbers.uniq # returns the unique elements but does not modify numbers
puts numbers # prints 1 2 2 3 on separate lines
puts numbers.inspect # [1, ... | true |
cd056971fd05aab5196a78fbeb4dd3cf1281364e | Ruby | logicfirst/ruby-oo-practice-relationships-silicon-valley-exercise | /app/models/venture_capitalist.rb | UTF-8 | 412 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class VentureCapitalist
attr_reader :name
attr_accessor :total_worth
@@all = []
def initialize(name, total_worth)
@name = name
@total_worth = total_worth
self.class.all << self
end
def self.all
@@all
end
def self.tres_commas_club
self.all.selec... | true |
069e83a1f5c9496aba95bde1cdb4374144b81014 | Ruby | daroleary/HeadFirstRuby | /hashes_aka_maps/voting.rb | UTF-8 | 800 | 3.6875 | 4 | [] | no_license | class Voting
def process
lines = []
File.open('votes.txt') do |file|
lines = file.readlines
end
votes = {} # '{}' defines a hash, key value object
lines.each do |line|
name = line.chomp
if votes[name] # false & nil, are considered 'falsy' and go to the else statement
v... | true |
8fa119584f007c2ca4e37d7d6c4c5cbcd39f9265 | Ruby | therod/dotfiles | /Rakefile | UTF-8 | 1,212 | 2.5625 | 3 | [] | no_license | require 'rake'
require 'csv'
# TODO: Move this script to simple bash
desc 'Install all the dependencies for the dotfiles using Homebrew'
task :install_software do
# Check if we have Homebrew installed:
unless system('which brew 2>&1 > /dev/null')
puts 'Homebrew is not Installed!'
puts 'Install it first: ht... | true |
d608f65249875a0d6f7211792056ca8e27eafe36 | Ruby | mijikim/class-inheritance-warmup | /lib/square.rb | UTF-8 | 190 | 2.90625 | 3 | [] | no_license | class Square < Rectangle
def initialize
@object = {width: 10, length: 10}
end
# def area
# @square[:side]**2
# end
#
# def perimeter
# 4*@square[:side]
# end
end | true |
5fd9bdb6db120141d8a40819d01d2970bca1327b | Ruby | mfutala/Introduction_to_programing_ls | /Variables/name.rb | UTF-8 | 214 | 3.828125 | 4 | [] | no_license |
puts "Enter your first name: "
fname = gets.chomp
puts "Enter your last name: "
lname = gets.chomp
name = fname + " " + lname
puts "Hi #{name}, welcome to my program."
10.times {|x| puts "#{x + 1}) #{name}"}
| true |
f7ce5aec5b602d071b6ad87f0cb36a8c5ddccacb | Ruby | renguyen/rspec-fizzbuzz-q-000 | /fizzbuzz.rb | UTF-8 | 176 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(num)
if (num % 3 == 0 && num % 5 == 0)
return "FizzBuzz"
elsif (num % 3 == 0)
return "Fizz"
elsif (num % 5 == 0)
return "Buzz"
else
return nil
end
end | true |
df5a6651c5078222cf4b6182da7febd42788d157 | Ruby | gabytzubaws/ruby_exercises | /caesar_cipher.rb | UTF-8 | 540 | 3.6875 | 4 | [] | no_license | def caesar_cipher (str,shift)
output = ""
str.each_byte do |charCode|
convertedCharCode = charCode + shift
if charCode.between?(97,122)
until convertedCharCode.between?(97,122)
convertedCharCode -= 26
end
output += convertedCharCode.chr
elsif charCode.between?(65,90)
unti... | true |
28818e8960396edefc49729cbb6d702109e43b0e | Ruby | jeremychan/leetcode_ruby | /lib/299_bulls_and_cows.rb | UTF-8 | 436 | 3.1875 | 3 | [] | no_license | # @param {String} secret
# @param {String} guess
# @return {String}
def get_hint(secret, guess)
a = 0
b = 0
guess = guess.split ''
unmatched = Hash.new(0)
(secret.split '').each_with_index { |x, idx|
if x == guess[idx]
a += 1
guess[idx] = 'x'
else
unmatched[x] += 1
end
}
gues... | true |
496e1904642bc605864c579b0a505189561b994e | Ruby | swade19/monster_game- | /monster_game copy.rb | UTF-8 | 1,089 | 4.6875 | 5 | [] | no_license | =begin
-tell user what moves they can do
-get input
if left, get eaten by werewolf
- if right they die by goblin
if they go forward they live
- go forward twice to win
=end
def game
puts "Welcome to monster runner. You need to escape the goblins and werewolfs. You can choose to go forward,... | true |
cdde60df2d2b5388b30836daa6da982724f916ec | Ruby | felipegruoso/spotify-api | /lib/spotify/models/full/album.rb | UTF-8 | 1,336 | 2.84375 | 3 | [
"MIT"
] | permissive | module Spotify
module Models
class Full::Album < Models::Album
attr_reader :artists, :copyrights, :external_ids, :popularity,
:release_date, :release_date_precision, :tracks
#
# Sets the arguments to its variables.
#
# @param [Hash] args the arguments that wil... | true |
3b63f78195c2af6fe0c4447fdeed71004acaf884 | Ruby | lvyitian/brainfuck-4 | /src/main/ruby/simple-compiler.rb | UTF-8 | 4,572 | 3.171875 | 3 | [] | no_license | # Naive compiler for brainfuck
# Usage: jruby -rubygems simple-compiler.rb <path/to/brainfuck/program.bf>
# Output: Program.class
# Run the output with: java -cp . Program
# Author: Martin McNulty (martin@martinmcnulty.co.uk, twitter.com/shamblepop)
# Generates invalid class files if the brainfuck program is too long... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.