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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2647b612c8aa3ecaf8153332006b281d30b3289a | Ruby | NicholasJacques/finer_things_club | /app/models/cart.rb | UTF-8 | 630 | 3.109375 | 3 | [] | no_license | class Cart
attr_reader :data
def initialize(data = {})
@data = data || Hash.new
end
def items
@data.map do |item_id, quantity|
item = Item.find(item_id)
CartItem.new(item, quantity)
end
end
def add_item(item)
data[item.id.to_s] ||= 0
data[item.id.to_s] += 1
end
def re... | true |
b39f64ad69d000a39d29587f28bca0547257368f | Ruby | mmevans/the-ultimate-fighter | /bin/train.rb | UTF-8 | 8,388 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def gotrain
puts `clear`
prompt = TTY::Prompt.new(active_color: :blue)
if $user.weeks_trained == 0 && $user.level == 1
prompt.say("#{$user.trainer_name}: Hey there champ! Looks like you've got your first big fight coming up.")
prompt.ok(">> Enter")
gets
prompt.say("#{$user.tr... | true |
e4f38fb3706d0ed7877445f5424f09c623176cc6 | Ruby | Intetaget/Homework | /smartguesser/oo_guesser.rb | UTF-8 | 895 | 4 | 4 | [] | no_license | require "./human"
require "./random"
require "./counting"
require "./smart1"
require 'pry'
class GuessingGame
def initialize(player)
@player = player
end
def play
number = rand(1..100)
result = nil
guess = @player.get_guess(result)
count = 1
#binding.pry
until guess == number
i... | true |
0059fa758fdbb73ad03e05c1cb242570f6a50951 | Ruby | simonbalean/deli-counter-ruby-apply-000 | /test.rb | UTF-8 | 557 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
test1 = ["1a", "1A"]
test2 = ["2b", "2B"]
test3 = ["3c", "3C"]
test4 = ["4d", "4D"]
test_total = [test1, test2, test3, test4]
# => [["1a", "1A"], ["2b", "2B"], ["3c", "3C"], ["4d", "4D"]]
test_number = 7
test_number1 = (1..test_number).to_a
# => [1, 2, 3, 4, 5, 6, 7]
test_letters = ["A", "B", "C", "D"]
test... | true |
bf88b3dce2c9adc7041f3446a93e7907ab466b33 | Ruby | davidrichards/cradle | /lib/basic_repository/basic_repository.rb | UTF-8 | 895 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'database_boundary'
require 'find_entity_by_id'
require 'save_entity'
require 'filter_entities'
require 'save_database'
require 'load_database'
module Cradle
class BasicRepository < DatabaseBoundary
def self.stored_entities
@stored_entities ||= {}
end
def self.overwrite_stored_entities!(v... | true |
db3e921ce6aebe2d066d5b3bce244029459524d4 | Ruby | rvedotrc/sqs-list-queues | /bin/sqs-list-queues | UTF-8 | 1,558 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
require 'sqs-list-queues'
config = SqsListQueues::Config.new
opts_parser = OptionParser.new do |opts|
opts.banner = "Usage: sqs-list-queues [OPTIONS] [PATTERN ...]"
opts.separator ""
opts.on("-c", "--counts", "Show message counts") do
config.show_counts = true
end
... | true |
078ce514ef0b41f3650f3187bc16965dc52abc2b | Ruby | modulexcite/p2pwebclient | /src/lib/safe_write.rb | UTF-8 | 1,458 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'fileutils'
class File
if RUBY_PLATFORM =~ /mingw|mswin/
FileUtils.touch 'temp_file'
@@loc = 'temp_file'
else
@@loc = '/dev/random'
end
@@saver_file = File.new @@loc, 'r'
def self.append_to to_this_file, data
begin
to_this = File.new to_this_file, 'a+'
size = to_this... | true |
f9828e0d01e9eb98c02c9c4a147252c7916f6ff1 | Ruby | vdk88/seek | /lib/seek/bio_schema/bio_schema.rb | UTF-8 | 1,713 | 2.71875 | 3 | [
"JSON",
"BSD-3-Clause"
] | permissive | module Seek
module BioSchema
# Main entry point for generating Schema.org JSON-LD for a given resource.
#
# Example: Seek::BioSchema::BioSchema.new(Person.find(id)).json_ld
class BioSchema
include ActionView::Helpers::SanitizeHelper
attr_reader :resource
# initialise with a resource... | true |
bd235a72aba271c5c101429b882d7f0e955a9175 | Ruby | arakawamoriyuki/tensorflow_learn | /workspace/coursera/ruby/standard_deviation.rb | UTF-8 | 544 | 3.328125 | 3 | [] | no_license | # 標準偏差の計算
require 'complex'
avg = 60
player_length = 10
a_points = [0,5,10,70,80,80,82,85,93,95]
b_points = [50,52,54,60,60,60,61,61,70,72]
tests = {a: a_points, b: b_points}
tests.each do |type, points|
points.unshift(result = 0)
# 分散値の計算
dispersion = points.reduce do |result, point|
result += ((point - avg... | true |
29db94bf18fe6bb60ccbd9cfc0a6acaec77c76f2 | Ruby | thrigby/funshine | /my_game.rb | UTF-8 | 1,234 | 3.3125 | 3 | [] | no_license | require 'rubygems'
require 'gosu'
require_relative 'player'
require_relative 'ball'
class MyGame < Gosu::Window
def initialize
super(400, 400, false) #false means don't take up the whole screen
@player1 = Player.new(self, 50)
@balls = 2.times.map {Ball.new(self)}
@bg_image = Gosu::Image.new(self, "im... | true |
d86f5fee9f5e41ee070296ad6a338c61c1738bf9 | Ruby | michaeltelford/ruby_graphql_api | /src/graph_handler.rb | UTF-8 | 1,729 | 2.828125 | 3 | [
"MIT"
] | permissive | require "rack"
require "graphql" # required here and not in the graphql dir *.rb files.
require_relative "helpers"
require_relative "graphql/schema"
# Class providing handlers for the GraphQL engine.
class GraphHandler
include Rack::Utils
# /graphql endpoint http handler.
# The query and variables come fr... | true |
77600fd2d9bfa53101e249f842de3d51e73633d9 | Ruby | fdumontmd/books-code | /7languages7weeks/ruby/guess.rb | UTF-8 | 228 | 3.59375 | 4 | [] | no_license | def play()
target = rand(10)
guess = -1
while target != guess
puts 'Guess a number'
guess = gets().to_i
puts 'too high' if target < guess
puts 'too low' if target > guess
end
puts 'got it'
end
play()
| true |
5e63f8d50558f3842c4cc253fee212d4eb4de611 | Ruby | ayush268/certification | /certification_app/app/helpers/courses_helper.rb | UTF-8 | 470 | 2.640625 | 3 | [] | no_license | module CoursesHelper
def course_status(course)
# Periods are assumed in hours
registration_period = 1
course_period = registration_period + 1
hours_elapsed = (DateTime.now.to_i - course.accepted_time.to_i) / 60
case true
when hours_elapsed < registration_period
return "Registrati... | true |
d974280e9895dcaa73c7a8b58b33855eb1700238 | Ruby | RJ-Ponder/RB101 | /exercises/easy_5/08alpha.rb | UTF-8 | 757 | 3.71875 | 4 | [] | no_license | WORD_NUMBERS = {
"zero" => 0, "one" => 1, "two" => 2, "three" => 3,
"four" => 4, "five" => 5, "six" => 6, "seven" => 7,
"eight" => 8, "nine" => 9, "ten" => 10, "eleven" => 11,
"twelve" => 12, "thirteen" => 13, "fourteen" => 14,
"f... | true |
44d6464f2e583eb3f7f524e88065f042cdac8ac3 | Ruby | dmdinh22/Lesson1 | /rps.rb | UTF-8 | 1,276 | 4.15625 | 4 | [] | no_license | # Pseudo Code (LOGIC)
# 1. all players pick either rock, paper, or scissors
# 2. compare: paper > rock, rock > scissors, scissors > paper, or tie if same
# 3. play again?
ACTIONS = { 'r' => 'rock', 'p' => 'paper', 's' => 'scissors' }
def winning_message(action)
case action
when 'r'
puts "Rock smashes scis... | true |
4225ccd2c9c49f2b18b2fca88da2a1b85d0d28bc | Ruby | gentilfp/oxford_learners_dictionaries | /lib/oxford_learners_dictionaries/definition.rb | UTF-8 | 724 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
module OxfordLearnersDictionaries
class Definition
attr_reader :text, :examples
def initialize page
@page = page
@examples = Array.new
end
def parse_single_definition
text = @page.css('.def')
@text = text.count > 0 ? text[0].text : text.text
@exampl... | true |
c853c681a17dbc84306f7d19ec6304dc7f46ea02 | Ruby | orestiss/maze_challenge | /path_finding/spec/grid_spec.rb | UTF-8 | 821 | 2.796875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Grid do
context "load grid from file" do
let(:grid) do
builder = GridBuilder.new
grid = builder.get_grid_from_file('./spec/data/maze1.txt')
end
it "returns the correct neighbors" do
expect(grid.is_a? Grid).to eq true
neighbors = grid.get_neighbors(Vector[1,1])
... | true |
7b45b4c6b047820f9bbc09cf9a1fadf24b1aeed8 | Ruby | GalaxyAstronaut/ruby-object-attributes-lab-onl01-seng-ft-012120 | /lib/person.rb | UTF-8 | 225 | 2.6875 | 3 | [] | no_license | class Person
# name getter and setter methods
def name=(name)
@name = name
end
def name
@name
end
# job getter and setter methods
def job=(job)
@job = job
end
def job
@job
end
end | true |
c1991710368732273357e27c16bd20850d61afbf | Ruby | SawaiTakahiro/sawaiTest | /twitter/convert_tweet.rb | UTF-8 | 1,593 | 3.125 | 3 | [] | no_license | #! ruby -Ku
=begin
2016/04/16
twitterのAPI使って見るテスト
「取得→csv保存したやつ」を読み込んで加工するところまで。
=end
##########################################################################################
#共通の部分
require "Twitter"
require "./library.rb"
require "sqlite3"
include SQLite3
TABLE_NAME = "arcive"
#つぶやきを、見出しとアドレスに分けられたら分ける
def... | true |
bd5f5f839c299d0daa035c4ec16a04b6f62cebf5 | Ruby | pankajbarhate13/food_ordering_system | /db/seeds.rb | UTF-8 | 713 | 3.078125 | 3 | [] | no_license | require 'csv'
class Seeder
def initialize
create_item
create_categories
end
def create_item
contents = CSV.open "./db/db_seed.csv", headers: true, header_converters: :symbol
contents.each do |row|
name = row[:name]
description = row[:description]
price = row[:pr... | true |
19c2f352954663446e9edc7ce8d98b43771cf6c0 | Ruby | UwanaIkaiddiSonos/my-actualize-repo | /http_requests/dictionary_app.rb | UTF-8 | 545 | 2.796875 | 3 | [] | no_license | require 'http'
key = ""
puts "Enter a word:"
user_word = gets.chomp
response = HTTP.get("https://api.wordnik.com/v4/word.json/#{user_word}/definitions?limit=200&includeRelated=false&useCanonical=false&includeTags=false&api_key=#{key}")
define = response.parse
definition = response.parse[0]["text"]
# #puts response.p... | true |
69607ddb3880f47bf8b3969c038d9c38623fa659 | Ruby | mateuszstacel/Birthday_web | /app.rb | UTF-8 | 832 | 2.5625 | 3 | [] | no_license | require 'sinatra/base'
require 'date'
require_relative './lib/datee.rb'
class Birthday < Sinatra::Base
enable :sessions
get '/' do
erb :index
end
post '/details' do
$name = params[:user_name]
@birth_day = params[:birth_day]
@birth_month_year = params[:birth_month_year]
$full_date = @birt... | true |
93ae354b126a07cf8418b094ed248cffdfb13a70 | Ruby | darren2802/battleship_project | /lib/cell.rb | UTF-8 | 761 | 3.125 | 3 | [] | no_license | require_relative './ship'
class Cell
attr_reader :coordinate, :ship
def initialize(coordinate)
@coordinate = coordinate
@ship = nil
@cell_has_been_fired_upon = false
end
def empty?
!@ship
end
def place_ship(ship)
@ship = ship
end
def fire_upon
@ship.hit if !empty? && !@cell_... | true |
e4b7ceb4c9aaef88705b34cb2e05703f0ff2e606 | Ruby | yosuke-yagishita/ruby_study | /C024:ミニ・コンピュータ.rb | UTF-8 | 347 | 3.390625 | 3 | [] | no_license | a = 0
b = 0
count = gets.to_i
count.times do |c|
order, i, num = gets.split(" ").map(&:to_s)
if (order == "SET") && (i == "1")
a = num.to_i
elsif (order == "SET") && (i == "2")
b = num.to_i
elsif (order == "ADD")
b = a + i.to_i
elsif (order == "SUB")
b = a - i.to_i
... | true |
a221eb7d6e4ea763a7282df972735d283357041d | Ruby | Genessis/CI3725-Lanscii | /Entrega3/ruleClasses.rb | UTF-8 | 5,197 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
=begin
* UNIVERSIDAD SIMÓN BOLÍVAR
* Archivo: ruleClasses.rb
*
* Contenido:
* Clases para imprimir el AST de LANSCII
*
* Creado por:
* Genessis Sanchez 11-10935
* Daniela Socas 11-10979
*
* Último midificación: 13 de junio de 2015
=end
##########################... | true |
faec46ab8c3d17fb11571668abd979a700afe759 | Ruby | aaroncallagher/ls_101_programming_foundations | /lesson_3/medium_1/question_7.rb | UTF-8 | 810 | 4.3125 | 4 | [] | no_license | # limit = 15
# def fib(first_num, second_num)
# while second_num < limit
# sum = first_num + second_num
# first_num = second_num
# second_num = sum
# end
# sum
# end
# result = fib(0, 1)
# puts "result is #{result}"
# The problem here is that method definitions do not have access to outside
# loc... | true |
80d09b0e37773a82dcf94cbef5bfee6b6f9ca1d1 | Ruby | fujisawaryohei/bookshelf | /spec/bookshelf/entities/book_spec.rb | UTF-8 | 348 | 2.53125 | 3 | [] | no_license | RSpec.describe Book, type: :entity do
it 'can be initialized with attrubutes' do
book = Book.new(title: 'Refactoring')
expect(book.title). to eq('Refactoring')
end
it 'add tax to unitPrice' do
book = Book.new(title: 'Confident Ruby', author: 'Avdi Grimm', unit_price: 2500)
expect(book.total_pri... | true |
a9a321a249aab26fa4bf0a4db6063c943ae765b7 | Ruby | GeoffWilliams/puppetizer | /lib/puppetizer/authenticator.rb | UTF-8 | 3,537 | 2.890625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | require 'csv'
require 'puppetizer'
require 'puppetizer/puppetizer_error'
require 'puppetizer/authenticator'
module Puppetizer
class Authenticator
def initialize(password_file, global_username=false)
@password_file = password_file
if @password_file
read_password_file(@password_file)
else... | true |
ddcdaaa2615e9988262d88b3545a3233c1c7806c | Ruby | Rajanpandey/Coding-Practice | /CodeSignal/Arcade/Intro/1. The Journey Begins/3. checkPalindrome.rb | UTF-8 | 76 | 2.796875 | 3 | [] | no_license | def checkPalindrome(inputString)
inputString == inputString.reverse
end
| true |
395d2123a87ebdbf8ee44901f602f890cfceecc0 | Ruby | bschrag620/oo-student-scraper-v-000 | /lib/scraper.rb | UTF-8 | 1,214 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
require 'nokogiri'
class Scraper
def self.scrape_index_page(index_url)
html = File.open(index_url)
doc = Nokogiri::HTML(html)
doc.css(".main-wrapper.roster .student-card").collect do |student_card|
name = student_card.css("h4").text
location = student_card.cs... | true |
be9ed731e810039b7c8a0b474b7076a4275cd3bc | Ruby | dissonanz/knife-data-bag-stack | /spec/stack_spec.rb | UTF-8 | 3,436 | 2.671875 | 3 | [] | no_license | #
# Author: Sean Nolen (<sean.m.nolen@gmail.com>)
# Copyright: (c) 2012 Sean Nolen
# License: Apache License, Version 2.0
#
require 'chef'
require 'chef/mixin/stack'
include Chef::Mixin::Stack
describe Chef::Mixin::Stack do
before(:each) do
@data_bag_item = Chef::DataBagItem.new
@data_bag_item.data_bag("s... | true |
27281078ac99bbf9cb9488149b33afac35420893 | Ruby | malonecab/BowlingGame | /app/models/bowling_game.rb | UTF-8 | 905 | 3.140625 | 3 | [
"MIT"
] | permissive | class BowlingGame
include Mongoid::Document
include Mongoid::Timestamps
field :hits, type: Array, default: -> { Array.new() }
def score
score = 0
index = 0
max_index = (hits.size == 12) ? 10 : hits.size-1
while index < max_index
if strike?(index)
score += strike_score(index)
index... | true |
9e0ac0835e7a9b17e492496424db67f7fd3c180b | Ruby | Friendscover/connect_four | /lib/coin.rb | UTF-8 | 157 | 2.828125 | 3 | [] | no_license | #has attributes name, icon
class Coin
attr_accessor :name, :icon
def initialize(name = "coin", icon = "☾")
@name = name
@icon = icon
end
end | true |
d6f177ca9057c63a413ecf885877c0ed14e2dd51 | Ruby | eliyooy/prime-ruby-v-000 | /prime.rb | UTF-8 | 178 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(int)
if int < 2
return false
elsif int == 2 || int == 3
return true
elsif int % 2 == 0 || int % 3 == 0
return false
else
return true
end
end | true |
7db92c5fa386cc1745817c8212dd745d46dc3f3e | Ruby | dkroondijk/CodeCore-Assignments-Week1 | /Day3/blog_post.rb | UTF-8 | 289 | 2.828125 | 3 | [] | no_license | require "./comment.rb"
class BlogPost
attr_reader :comments
def initialize
@comments = []
end
def add_comment
comments << comment
end
# def add_comment(comment)
# comments << comment
# end
def delete_comment(index)
comments.delete_at(index)
end
end | true |
30a4608676c17bdd29ffc205db9df4997ec0fbf9 | Ruby | Bidu/core_ext | /spec/lib/hash_spec.rb | UTF-8 | 9,570 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Hash do
it_behaves_like 'a class with change_key method'
it_behaves_like 'a class with camlize_keys method'
it_behaves_like 'a class with underscore_keys method'
it_behaves_like 'a class with append_keys method'
it_behaves_like 'a class with change_kvalues method'
it_behaves_... | true |
3934cff3e9b7b1238ea7847c545b0768101bc0c0 | Ruby | ehayne00/ruby-project-alt-guidelines-london-web-111819 | /lib/review.rb | UTF-8 | 1,095 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Review < ActiveRecord::Base
belongs_to :user
belongs_to :dental_hygienist
def print_review_details
"name: #{self.dental_hygienist.name}, star rating: #{self.star_review}, review: #{self.comment_review}"
end
def self.find_reviews_by_location(user_input)
array = DentalHygienist.find_hygieni... | true |
5b1e7bfd58f1855957e11c067ca7b21612dc4596 | Ruby | atanum/fairwood | /app/controllers/students_controller.rb | UTF-8 | 5,669 | 2.65625 | 3 | [] | no_license | class StudentsController < ApplicationController
before_action :set_student, only: [:show, :edit, :update, :destroy]
# GET /students
# GET /students.json
def index
@students = Student.all
end
# GET /students/1
# GET /students/1.json
def show
end
# GET /students/new
def new
@student = St... | true |
7edc04306846841af9000a37ec7e69229b35ba77 | Ruby | pradeepkhot/Programs | /26:twostringsubstring.rb | UTF-8 | 431 | 4.375 | 4 | [] | no_license | #Program to print yes if a letter in given 2 strings match else print no
########################################################################
def string_match(s1,s2)
c=0
for line in 0..s1.length-1
for count in 0..s2.length-1
if s1[line]==s2[count]
c=c+1
end
end
end
if c>1
puts "yes"
else
... | true |
03daf54025b4cbd9895e81b001c022e771924a65 | Ruby | jeremiahishere/archived_projects | /cucumber_off_rails/lib/cucumber_off_rails/generator.rb | UTF-8 | 2,837 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'erb'
require 'fileutils'
require 'ruby-debug'
class CucumberOffRails
class Generator
#require "cucumber_off_rails/generator/options"
require "cucumber_off_rails/generator/application"
attr_accessor :options, :remote_site, :project_name, :target_dir
def initialize(options = {})
self.o... | true |
c774a81009169479cce470a6a3bb070a45f37883 | Ruby | hleonov/genXLSParsing | /parsingGem/lib/dsl_parsing_support.rb | UTF-8 | 1,655 | 2.65625 | 3 | [] | no_license | require 'open4'
require 'json'
class DslParsingSupport
JAR_PATH = File.expand_path('../../bin/genXlsParsingWithProvenance.jar', __FILE__)
TEST_PATH = '/home/bittkomk/randomProjects/genXlsParsingWithProvenance'
def self.test_parse_xls_to_json
parse_xls_to_json("#{TEST_PATH}/bode-surgical.parser",
... | true |
73ebb2e699e66317a4ad9207aa504d3426be0c36 | Ruby | sleepingkingstudios/stannum | /lib/stannum/constraints/types/hash_with_string_keys.rb | UTF-8 | 791 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'stannum/constraints/types'
module Stannum::Constraints::Types
# Asserts that the object is a Hash with String keys.
class HashWithStringKeys < Stannum::Constraints::Types::HashType
# @param value_type [Stannum::Constraints::Base, Class, nil] If set, then
# the cons... | true |
3eede7dd1ab35fa13bb1b5b57ae9e9428b3bd21f | Ruby | rob-king/game_of_thrones | /db/seeds.rb | UTF-8 | 865 | 3.09375 | 3 | [] | no_license | require 'csv'
csv_text = File.read(Rails.root.join('db','got-export.csv'))
csv = CSV.parse(csv_text, headers:true)
def get_unique_houses(csv)
houses = []
csv.each { |row|
record = row.to_hash
houses << record['allegiances']
}
houses.uniq
end
unique_houses = get_unique_houses(csv)
characters = csv.m... | true |
21e29fc39f7585076e072df80b6a375c9a3e42cd | Ruby | gaofeiii/Dino.account-server | /spec/models/account_spec.rb | UTF-8 | 1,827 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
describe Account do
describe "validations" do
before(:each) do
@attr = { :username => "gaofei", :email => "gaofei@email.com", :password => "haha123", :password_confirmation => "haha123" }
end
it "should not be valid when email is invalid" do
Account.new(@att... | true |
1530ee37cea7b7846e42f96a687f44acc6bb1221 | Ruby | raymonddoan/jokes_rails_api | /db/seeds.rb | UTF-8 | 1,556 | 2.84375 | 3 | [] | no_license | joke_categories = [
"Puns",
"Programming",
"Knock Knock",
"Limericks",
]
if Category.all.length == 0
joke_categories.each do |category|
Category.create(name: category)
puts "created #{category} category"
end
end
if User.count == 0
User.create(username: "Ray", email: "ray@test.com", password: "pa... | true |
a3d0dba9839606ef48ce885cefc3e2ffbad3ac4f | Ruby | jvidalba1/learn-ruby | /Semana 0/problema 2/problema2.rb | UTF-8 | 278 | 3.09375 | 3 | [] | no_license | @a = 1
while @a.eql? 1 do
puts "Escriba cantidad en pesos"
c = gets
b = c.to_f / 1700.to_f
puts "equivale a #{ b.to_f.round(2) } dolares"
puts "para continuar 1, si no 0 "
@a = gets.to_i
end
| true |
1337353370135085713f5102b7190e62606d2c8e | Ruby | ddhogan/school-domain-v-000 | /lib/school.rb | UTF-8 | 357 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
def initialize(roster)
@roster = {}
end
attr_accessor :name
attr_reader :roster
def add_student(student_name, grade)
@roster[grade] ||= []
@roster[grade] << student_name
end
def grade(num)
@roster[num]
end
def sort
sorted = {}
@roster.each do |grade, students|
sorted[grade] = ... | true |
2aaddd8cf5993bf4a34ad99e92d6a37d26997a1b | Ruby | sbraford/pubrunner | /lib/pubrunner/octopress_transformer.rb | UTF-8 | 3,003 | 3.015625 | 3 | [
"MIT"
] | permissive | module Pubrunner
module Transformer
class Octopress
attr_accessor :post_layout, :post_date, :comments
def initialize(book)
@book = book
@post_layout = 'post'
@post_date = Time.now
@comments = true
# Octopress, by default, shows the most recent... | true |
2f7a2e1a4263510ee4c79d4329e21ee2c7b78774 | Ruby | djvirgen/kronk | /lib/kronk/response.rb | UTF-8 | 13,675 | 2.734375 | 3 | [
"MIT"
] | permissive | class Kronk
##
# Mock File IO to allow rewinding on Windows platforms.
class WinFileIO < StringIO
attr_accessor :path
def initialize path, str=""
@path = path
super str
end
end
##
# Standard Kronk response object.
class Response
class MissingParser < Kronk::Exception; en... | true |
124320545219be99fba0f80e534cb5db860bd566 | Ruby | CodeSmell/advent-of-code | /2018/tests/util/test_Location.rb | UTF-8 | 523 | 3 | 3 | [] | no_license | require_relative "../../lib/util/Location.rb"
require "test/unit"
class Test_Location < Test::Unit::TestCase
def test_taxiCabDistance
loc = Location.new(3,4)
distance = Location.new(1,1).taxiCabDistance(loc)
assert_equal(5, distance)
end
def test_convert_string
locString = Location.new... | true |
bf2355882ec647f878477fb4081d129f1f49af2f | Ruby | peterla/SeatYourself | /test/models/restaurant_test.rb | UTF-8 | 1,498 | 2.828125 | 3 | [] | no_license | require 'test_helper'
class RestaurantTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test 'one restaurant exists' do
r = FactoryGirl.create :restaurant
assert_equal 1, Restaurant.all.size, 'Number of restaurants was not equal to 1'
end
test 'restaurant has at least 1 s... | true |
d064292ed30335df5d8f7cb183b8a83d1a396003 | Ruby | loopj/resque-delayable | /lib/resque-delayable/delayed_method.rb | UTF-8 | 2,041 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module ResqueDelayable
require "resque"
begin
require "resque/scheduler"
rescue LoadError
end
class DelayedMethod
attr_accessor :klass
attr_accessor :instance
attr_accessor :options
def initialize(klass, instance = nil, options = {})
unless instance.nil? || ResqueDelayable::ACTIVE... | true |
b1b2b00f11dafa70984a6c57aa6754ae4c5bfd3f | Ruby | syborg/web_dump | /examples/simple_examples.rb | UTF-8 | 1,160 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # Simple Examples to show up how to use WebDump
# Marcel Massana 1-Sep-2011
require 'rubygems'
require 'open-uri'
require 'web_dump'
MY_URIS = [
'http://en.wikipedia.org/wiki/Ruby_Bridges',
'http://donaldfagen.com/disc_nightfly.php',
'http://www.rubi.cat/ajrubi/portada/index.php',
'http://www.google.com/cse?q... | true |
c135c75c83cfa2f0ddaa66075b0d54cf31ecaf05 | Ruby | avanegasp/MakeitClass | /segundaSemana/sinatra3/app.rb | UTF-8 | 443 | 2.890625 | 3 | [] | no_license | require 'sinatra'
get '/' do
@hi = "Hola Makers!"
# @hi = params[:name]
erb :index
end
get '/dog/:name/:apellido' do
p params
@name = params["name"]
@apellido = params["apellido"]
erb :dog
end
todos = []
get '/todos/:todo' do
todos.push(params[:todo])
@todos = todos
erb :todos
end
get '/students... | true |
a22e25613dbcc34bc6a2469338b84f84d9783c8b | Ruby | arifmahmudrana/ruby-learn | /numbers.rb | UTF-8 | 219 | 3.53125 | 4 | [] | no_license | # p p 6.0 + 5, 6 - 5.0, 6 / 0.5, 3 * 2, 5 ** 5
# arithmetic operator precedence
# p 2 ** 3 / 2, 2 ** (3 / 2)
p 5 + 15 * 20 - 2 / 6 ** 3 - (3 + 1) # parentheses, exponent, multiplication, division, addition, subtraction | true |
9933eba7d0655d4759648485a386d57e3c3f7360 | Ruby | T-PRAT/thp_POO_game | /app.rb | UTF-8 | 615 | 3.09375 | 3 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
player1 = Player.new("Josiane")
player2 = Player.new("José")
puts "\nDébut du combat entre ".yellow + player1.name.blue + " et ".yellow + player2.name.red + " !\n\n"
while player1.life_points > 0 && player2.life_points > 0 d... | true |
af21964800fbd5a0e609ce5b5897c8f7a8a92f52 | Ruby | iga-c/CocktailCrawler | /cocktail.rb | UTF-8 | 885 | 3.265625 | 3 | [] | no_license | require 'nokogiri'
Material = Struct.new(:name, :volume)
class Cocktail
attr_reader :name, :make, :materials
def initialize(html)
doc = Nokogiri::HTML(File.read(html))
@name = doc.xpath('//div[@class="cnt"]/strong').text
@make = doc.xpath('/html/body/table/tr/td[2]/div[8]/table/tr/td[2]').text
@... | true |
6f237861d182cd7fd59dc8631e252c3ee27e06c0 | Ruby | torubylist/ruby_learning | /meta_ruby/my_time.rb | UTF-8 | 194 | 3.4375 | 3 | [] | no_license | class Fixnum
def my_times &block
i = 0
while i < self
yield(i)
i += 1
end
return self
end
end
p 5.my_times{|x| puts "hello #{x}"}
p 5.my_times{ puts "hello "}
| true |
55767157d2c0ee171aa0b9178bc9802f846745ee | Ruby | gatperdut/chatomud | /app/lib/chato_mud/mixins/characters/skill_set/definition.rb | UTF-8 | 2,892 | 2.6875 | 3 | [] | no_license | module ChatoMud
module Mixins
module Characters
module SkillSet
module Definition
def all_skill_labels
[
:unskilled,
:beginner,
:novice,
:amateur,
:familiar,
:talented,
:adroi... | true |
fb1084401f8edbe0ce9bc98f488c41f4ea8bf3c1 | Ruby | scarroll32/Conjugate | /spec/common_spec.rb | UTF-8 | 907 | 2.921875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require 'rspec'
require 'conjugate'
describe 'Helper Conjugations' do
describe 'methods testing' do
it '.conjugate calls Spanish' do
verb = Conjugate.conjugate({language: 'spanish', verb: 'comprar', tense: :present, pronoun: :yo})
expect(verb).to eq('compro')
verb = ... | true |
1e18f853695ce0a435dc2f0b3b2f16e96c65ae59 | Ruby | Dervol03/a_types | /lib/a_types/decorators/numeric_wrap.rb | UTF-8 | 1,797 | 3.421875 | 3 | [
"MIT"
] | permissive | require_relative 'wrapper'
module ATypes
# Adds numeric methods to any wrapped object.
class NumericWrap < Wrapper
# Returns the numeric value of this wrapped object. Depending on its class,
# different strategies will be applied in the course:
# - Strings will be parsed for their content and return ni... | true |
0af1b62e019a6452ca9960ba6e1a4796c5b9bece | Ruby | d4l3k/GitStats | /main.rb | UTF-8 | 2,980 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'bundler'
Bundler.require :default, :development
get '/' do
"Hi there! Bob!"
end
configure do
if not Dir.exists? "/tmp/checkout"
Dir.mkdir "/tmp/checkout"
end
end
helpers do
def get_user_commits user
response = Curl::Easy.perform("https://api.github.com/users/#{user}/events") do... | true |
6a7b0ce9a8841162043e76349bfb0c8f6e8b8e09 | Ruby | adev73/siwapp | /lib/model_csv.rb | UTF-8 | 524 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'csv'
module ModelCsv
# Enumerator that generates csv lines
def csv_stream(results, fields, meta_attributes_keys)
Enumerator.new do |y|
# header line
y << CSV.generate_line(fields + meta_attributes_keys)
# items
results.includes(items: [:taxes]).find_each do |i|
meta_at... | true |
ebbd18956aad43a80376f169fd5b0bae27969b1c | Ruby | setonparish/flockbot | /lib/flockbot/errors.rb | UTF-8 | 788 | 2.640625 | 3 | [
"MIT"
] | permissive | require "faraday"
module Flockbot
class FlockbotError < StandardError; end;
class TransactionError < FlockbotError; end
#
# If the request to Flocknotes is an http status 200 response, but the action
# being performed is not successful, Flocknote will return a { success: false }
# status with an error, so... | true |
9f9e733faba333fce361193a659bf8ca890f84a3 | Ruby | tonekk/link-grabber | /test/models/custom_attribute_test.rb | UTF-8 | 3,336 | 2.546875 | 3 | [] | no_license | require 'test_helper'
describe CustomAttribute do
before do
@custom_attribute = Fabricate.build(:custom_attribute, name: 'test', pretty_name: 'Test')
end
it "should return right value for metric :eq" do
@custom_attribute.metrics = :eq
build_test_values(@custom_attribute, 'A', 'foo', 'B', 'bar', 'C'... | true |
d183830fddac0404fc1145c79186570d28fd7974 | Ruby | ehayne00/ruby-enumerables-generalized-map-and-reduce-lab-london-web-102819 | /lib/my_code.rb | UTF-8 | 291 | 3.34375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def map(array)
new_array = []
i = 0
while i < array.length
new_array.push(yield(array[i]))
i+=1
end
return new_array
end
def reduce(array, sv=nil)
if sv
sum = sv
i=0
else sum= array[0]
i=1
end
while i<array.length
sum = yield(sum, array[i])
i+=1
end
sum
end
| true |
59dfed1bb63671b08d43122ce45a4a710b3bc112 | Ruby | afeld/facial | /lib/facial.rb | UTF-8 | 524 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'rubygems'
require 'opencv'
include OpenCV
module Facial
class << self
def detect image_path
# initialize the detector, if it wasn't already
@detector ||= CvHaarClassifierCascade::load(File.expand_path(File.dirname(__FILE__) + '/../data/haarcascade_frontalface_alt.xml'))
image =... | true |
1efe23ce59ab2e5cd74ba724496f560bfda832c8 | Ruby | mserino/Email-predictor | /lib/analyzer.rb | UTF-8 | 1,141 | 3.15625 | 3 | [] | no_license | require_relative 'error'
require_relative 'constants'
class Analyzer
attr_accessor :pattern
def initialize
@pattern = {}
end
def get(name)
name.split('@')[0]
end
def find(string)
@name, @lastname = string.split('.')
[name_pattern, lastname_pattern].join('_dot_').to_sym
end
def convert(pattern)
s... | true |
a1948eb780f245713cb88cf84f890031f6420dc6 | Ruby | ibanzajoe/m3fasdf | /volumes/bundler/gems/neatjson-0.7.1/test/test_neatjson.rb | UTF-8 | 787 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative '../lib/neatjson'
require_relative './tests'
start = Time.now
pass = 0
count = 0
TESTS.each do |value_tests|
val, tests = value_tests[:value], value_tests[:tests]
tests.each do |test|
cmd = test[:opts] ? "JSON.neat_generate(#{val.inspect},#{test[:opts].inspect})" : "JSON.neat_generate(#{val.inspe... | true |
bf644a3eb81b66192b3343f7355f69a70fd9086e | Ruby | havok2905/gitfolio | /lib/classes/repo_sync.rb | UTF-8 | 695 | 2.609375 | 3 | [] | no_license | class RepoSync
def initialize(user, api)
@user = user
@api = api
end
def run
@user.update_attributes repos: repo_list
end
private
def language(args)
RepoLanguage.where(args).first_or_create(args)
end
def repo_list
@api.repo_data(username: @user.nickname).map do |r|
repo = R... | true |
556e3b5b231da2b37bd1e4d4f1c8f956714dc276 | Ruby | wolfemm/email_assessor | /lib/email_assessor.rb | UTF-8 | 1,181 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "email_assessor/email_validator"
module EmailAssessor
DISPOSABLE_DOMAINS_FILE_NAME = File.expand_path("../../vendor/disposable_domains.txt", __FILE__)
FASTPASS_DOMAINS_FILE_NAME = File.expand_path("../../vendor/fastpass_domains.txt", __FILE__)
EDUCATIONAL_DOMAINS_FILE_NAME =... | true |
c75ba2d2d63648975728aa91da88221fd0d49c3c | Ruby | quiettimes03/Kele | /lib/kele.rb | UTF-8 | 2,080 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'HTTParty'
require 'json'
require './lib/roadmap.rb'
class Kele
include HTTParty
include Roadmap
base_uri 'https://www.bloc.io/api/v1/'
def initialize(email, password)
@email, @password = email, password
response = self.class.post(api_url("sessions"), body: { "email": email, "password": passwor... | true |
3c452f44f18fd5138e560f228fb2a1baa188aaa2 | Ruby | pcahalane/launch_school | /lesson_3/pp_easy_2/010.rb | UTF-8 | 197 | 2.890625 | 3 | [] | no_license | # QUESTION 10:
# Center the given title across 40 characters
#-----------------------------------------------------------------------------#
title = "Flintstone Family Members"
p title.center(40)
| true |
210c02357b4408b31b881bbdeb0a078b63d7abd8 | Ruby | ireneybean/advent-of-code | /2019/2.rb | UTF-8 | 2,013 | 4.15625 | 4 | [] | no_license | # An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). To run one, start by looking at
# the first integer (called position 0). Here, you will find an opcode - either 1, 2, or 99. The opcode indicates
# what to do; for example, 99 means that the program is finished and should immediately ha... | true |
ab390e6e89b945bdf1ca9aff139aedcf246984f5 | Ruby | Sheshaw/oxford-comma-onl01-seng-pt-030220 | /lib/oxford_comma.rb | UTF-8 | 312 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.size == 2
array[-2] << " and "
array.join
elsif array.size == 1
array.join
elsif array.size > 2
array[-1].prepend "and " #the prepend method will add to #the element
array.join(", ")
end
end
| true |
69b2fad5190b6384fccef36648522f69948db728 | Ruby | frogstarr78/sandbox | /ruby/pegt.rb | UTF-8 | 655 | 2.828125 | 3 | [] | no_license | require 'rubygems'
require 'treetop'
require 'colored'
Treetop.load "arithmetic"
parser = ArithmeticParser.new
if parser.parse('1+2')
puts 'success'
else
puts 'failure'
end
#puts parser.parse('1+1').klass
#puts parser.index
parsed = parser.parse('1+2')
puts parsed.elements.collect(&:inspect),
parsed.inspect,
''... | true |
359beb991d170eaed80f8f3f5e4f179ab0109ce3 | Ruby | kjleitz/brainfuck_ruby | /lib/brainfuck_ruby/errors.rb | UTF-8 | 2,161 | 3.03125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module BrainfuckRuby
class Error < StandardError; end
# Internal interpreter error
class InternalError < BrainfuckRuby::Error
def initialize(message = "Something went wrong")
super(message)
end
end
# Cursor is negative or past the end of the file
class CursorOu... | true |
1cf1e96ac82a97bbfffb72f56b713508f7ec7e56 | Ruby | davidrajnus/Algorithms-In-Ruby | /spec/anagram_spec.rb | UTF-8 | 696 | 2.8125 | 3 | [] | no_license | require './anagram'
RSpec.describe '#anagram' do
it '"hello" is an anagram of "llohe"' do
expect(anagram('hello', 'llohe')).to be_truthy
end
it '"Whoa! Hi!" is an anagram of "Hi! Whoa!"' do
expect(anagram('Whoa! Hi!', 'Hi! Whoa!')).to be_truthy
end
it '"One One" is not an anagram of "Two two two"'... | true |
48b38da115443adb15cb82563a4a98af26f1e787 | Ruby | dangerstephen/ruby_method_drills | /starter-code/numbers.rb | UTF-8 | 1,197 | 3.59375 | 4 | [] | no_license | ##############################
#### MANIPULATING NUMBERS ####
##############################
def count_to(number)
number = number.to_i
if number >= 0
(0..number).to_a
else
0.downto(number).to_a
end
end
#is_integer?
# takes in a number
# returns true for Fixnums and Bignums (whole number or 'integer... | true |
9e21aee7cc02695c7bb9db980aceaeff0dc92369 | Ruby | abruzzim/RockSolid | /db/seeds.rb | UTF-8 | 5,797 | 2.640625 | 3 | [] | no_license | # 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
8bb02ab572f6f42cd482b3b5266d79234f57b00b | Ruby | dojomaringa/dojo_20121130 | /nome_spec.rb | UTF-8 | 1,446 | 3.203125 | 3 | [] | no_license | require_relative "nome"
describe "Escolha o nome do seu filho" do
context "Calcula a distancia entre duas palavras" do
it "A distancia entre A e A deve ser 0" do
Nome.calcula_distancia("A", "A").should == 0
end
it "A distancia entre A e B deve ser 1" do
Nome.calcula_distancia("A", "B").should == 1
... | true |
01eaff5b7e38bb38e62b801098635f201710480f | Ruby | mellejwz/ruby-opdrachten | /8.3.rb | UTF-8 | 153 | 3.75 | 4 | [] | no_license | puts 'Type some words and press enter after each one'
array = []
words = ' '
while words != ''
words = gets.chomp
array.push words
end
puts array.sort | true |
4c57ea4c27de58f5d255ca7e871a63e065658f17 | Ruby | Nish8192/Ruby_on_Rails | /TDD/RubyTDD/AppleTree/AppleTree_Spec.rb | UTF-8 | 1,372 | 3.1875 | 3 | [] | no_license | require_relative 'AppleTree'
RSpec.describe AppleTree do
before (:each) do
@tree = AppleTree.new
end
it "should have an age attribute w/ getter and setter methods" do
age = @tree.age
@tree.age = 10
end
it "should have height and age attributes w/ only getter methods" do
... | true |
85b4b3cad90300d11b10824430c9223b33082071 | Ruby | albowen/FirstRailsTTS | /app/models/home.rb | UTF-8 | 112 | 2.546875 | 3 | [] | no_license | class Home
def name
name = "Ashley"
end
def birthdate
birthdate = Date.new(1985,6,02)
end
end
| true |
213f17d33eb5b06648de4ed2732b069cc5187dd2 | Ruby | travisofthenorth/euler | /lib.rb | UTF-8 | 520 | 3.5 | 4 | [] | no_license | module Euler
def factors(n)
(Math.sqrt(n)).ceil.downto(1).select { |d| n % d == 0 }.inject([]) do |factors, d|
factors << n / d if d != n / d
factors << d
end
end
def proper_divisors(n)
factors(n) - [n]
end
def prime?(n)
(2..Math.sqrt(n)).each { |d| return false if n % d == 0 }
... | true |
f8ff9f2a866c973589a12e7773a88ee1782bbbd2 | Ruby | JuliaFranzoi/HWw2d1 | /student.rb | UTF-8 | 639 | 3.03125 | 3 | [] | no_license | class Student
# attr_reader :account_holder #we use reader because it won't change
attr_accessor :favourite_language
def initialize(name, cohort, can_talk, favourite_language)
@name = name
@cohort = cohort
@can_talk = can_talk
@favourite_language = favourite_language
end
def name
return... | true |
bba33c958a187eacc642b6d3613e35bdfe4dd0a0 | Ruby | DoriansGrave/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 914 | 4 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort do | down, up |
up <=> down
end
end
def sort_array_char_count(array)
array.sort do | down, up |
down.length <=> up.length
end
end
def swap_elements(array)
array[1], array[2] = array[2], array[1]
array
end
def revers... | true |
7d18f9b10fbcabc9a56bd95b01dcbc9c328b9d51 | Ruby | davidpera/prueba | /dividir.rb | UTF-8 | 152 | 3.859375 | 4 | [] | no_license | print "Introduce el primer numero: "
n1 = gets.chomp.to_i
print "Introduce el segundo numero: "
n2 = gets.chomp.to_i
puts "El resultado es #{n1 / n2}."
| true |
8264a36e5888b733bc8eb53e8f7310f9e9efc9c3 | Ruby | hamjahb/lesson-w07d03-ruby-oop | /test/bird.rb | UTF-8 | 215 | 3.03125 | 3 | [] | no_license | require './animal'
class Bird < Animal
def move
super + ' by fly!'
end
def whats_the_word
@the_answer
end
end
big_bird = Bird.new
puts big_bird.move
puts big_bird.whats_the_word
| true |
eea8f91b9e60d0b1f21768dd0aa8bee4a6c6c529 | Ruby | SWEN30006-Group-31/WeatherPrediction | /app/models/postcode.rb | UTF-8 | 1,627 | 2.921875 | 3 | [] | no_license | # vim:sw=2:sts=2:et
class Postcode < ActiveRecord::Base
has_many :locations
has_many :observations, :through => :locations
has_many :predictions, :through => :locations
#TODO: Put the distance code into a separate module for re-use.
def self.get_nearest lat, lon
#Sorts Postcode in place according to di... | true |
f8da39581d0fbf6ba14b134858ba134430ce7fdb | Ruby | ravjohal/comparifier | /app/models/category.rb | UTF-8 | 3,119 | 2.765625 | 3 | [] | no_license | require 'rubygems'
require 'rexml/document'
require 'happymapper'
class Category < ActiveRecord::Base
has_many :comparifier_attributes
has_many :items
include REXML
#include HappyMapper
#
#tag 'BrowseNode'
#element :vendorCategoryId, String, :tag=>'BrowseNodeId'
#element :name, String, :tag=>'Name'
#has_one :childre... | true |
4cb386b77421befd556cf1670a23829ea26438b3 | Ruby | georuiz817/collections_practice-online-web-ft-061019 | /collections_practice.rb | UTF-8 | 710 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort.reverse
end
def sort_array_char_count(array)
array.sort_by {|x| x.length}
end
def swap_elements(array)
array[1],array[2] = array[2], array[1]
return array
end
def reverse_array(array)
array.reverse
end
def kesha_maker(ar... | true |
2957bac3af6413ea031392464e1b940ab4e94583 | Ruby | tdooner/tomstats | /models/daily_spreadsheet_entry.rb | UTF-8 | 1,077 | 2.640625 | 3 | [] | no_license | class DailySpreadsheetEntry < ActiveRecord::Base
LEGACY_ENTRY_TYPES = {
'How was today? [Good]' => :how_good,
'How was today? [Unique]' => :how_unique,
'How was today? [Productive]' => :how_productive,
'Who did you hang out with?' => :hung_out_with,
'How many glasses of alcohol today?' => :gla... | true |
9b57b918f9928eb578e95e3d54290839b670691d | Ruby | tfb34/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 434 | 3.578125 | 4 | [] | no_license | #write your code here
def add(num,num2)
return num+num2
end
def subtract(num,num2)
return num-num2
end
def sum(list)
i=0
sum=0
while i<list.size do
sum=sum+list[i]
i+=1
end
return sum
end
def multiply(num)
i=0
total=1
while i<num.size do
total*=num[i]
i+=1
end
return total
end
def power(num,num... | true |
8a3eff0411ca00a4fd09c1a93964272e5be5c6bf | Ruby | mwagner19446/wdi_work | /w06/d05/Cory/minesweeper/lib/minesweeper.rb | UTF-8 | 444 | 3.046875 | 3 | [] | no_license | class Minesweeper
def initialize(rows, cols)
@rows = rows
@cols = cols
@board = Array.new(@rows) {Array.new(@cols, 0)}
return true
end
def rows
return @rows
end
def cols
return @cols
end
def board
return @board
end
def has_mines
board = [[1, 0, 0], [0, 0, 0], [0, 0,... | true |
cc5c8587c894a2d2699a085cdf148c0e82961fe7 | Ruby | alex-handley/cryptopals-ruby | /set_1/crypto_helpers.rb | UTF-8 | 85 | 2.546875 | 3 | [] | no_license | class CryptoHelpers
def hex_to_base64(hex)
[[hex].pack("H*")].pack("m0")
end
end
| true |
388552f6b917a1e7fb804a22318b1d03b34399bf | Ruby | michalmuskala/janusze | /app/models/project_location.rb | UTF-8 | 1,399 | 2.71875 | 3 | [] | no_license | # == Schema Information
#
# Table name: project_locations
#
# id :integer not null, primary key
# state :string(255)
# city :string(255)
# street :string(255)
# street_number :string(255)
# longitude :float
# latitude :float
# project_id :integer
# create... | true |
788329644e1224db7e69234fce78a2b0cbedf18c | Ruby | alexlev1/pick_a_card_game | /pick_a_card.rb | UTF-8 | 364 | 3.953125 | 4 | [] | no_license | puts "Pick a Card!"
values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ["\u2660", "\u2661", "\u2663", "\u2662"]
cards = []
values.each do |value|
suits.each do |suit|
cards << "#{value} of #{suit}"
end
end
cards.shuffle!
puts "How many cards do you pick?"
number = STDIN.get... | true |
00be124864e1bbc70b3083ec00364e680fe5cd89 | Ruby | UCLeuvenLimburg/apt-course-material | /samples/ruby/grading/test.rb | UTF-8 | 520 | 3.234375 | 3 | [] | no_license | require_relative 'functional.rb'
require_relative 'imperative.rb'
require_relative '01-find-if.rb'
Evaluation = Struct.new :student, :grade, :course
N = 20
rnd = Random.new
courses = ['bop', 'oop', 'ooo', 'vgo', 'pvm']
evaluations = (1..N).map do
id = "r#{rnd.rand(1000).to_s.rjust(3, '0')}"
grade = (rnd.r... | true |
b1b596a4b3d7926a6be3bd0de2a2fb69cf39429a | Ruby | 4rlm/SDF2 | /lib/tools/csv/serv_csv_import.rb | UTF-8 | 4,388 | 2.546875 | 3 | [] | no_license | module ServCsvImport
############## BEST CSV IMPORT METHOD #####################
# RESTORE BACKUP METHODS BELOW - VERY QUICK PROCESS !!!
# Re-Imports previously exported, formatted CSVs w/ ids, joins, assoc.
# Imports CSV from: db/csv/backups/file_name.csv
####################################################... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.