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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5671e137b0a2232782c37b7da8abfc37c31d3852 | Ruby | aferris/FootballPool | /lib/DateFormatter.rb | UTF-8 | 210 | 2.84375 | 3 | [] | no_license | class DateFormatter
attr_reader :date, :mysql
def initialize(date)
@date = date
parsed = self.date.split(/-|\/|\s/)
@mysql = parsed[2] + "-" + parsed[0] + "-" + parsed[1] + " " + parsed[3]
end
end
| true |
0f2231fe76a60164ff66450a09dcda65a98e68b6 | Ruby | Lenocam/codefights | /IntroGates/candies.rb | UTF-8 | 55 | 3.140625 | 3 | [] | no_license | def candies(n, m)
(m/n) * n
end
puts candies(3, 10)
| true |
a860823867c047c096150a8d3f2bc9cd89742b44 | Ruby | atetubou/isucon8q | /tools/stat.rb | UTF-8 | 2,144 | 3 | 3 | [] | no_license | # coding: utf-8
=begin
nginxのログファイルの解析
nginxの設定:
log_format mainlog '$status|$request_time|$msec|$request_length|$remote_addr|$remote_user|$time_local|$body_bytes_sent|$request|$http_referer|$http_user_agent|$http_x_forwarded_for|$connection';
access_log /home/isucon/access.log mainlog;
上の設定で/home/isucon/access.l... | true |
d5e38446f95716248ee378b8f8a1cead4a63c330 | Ruby | nancylee713/sweater-weather | /app/models/location.rb | UTF-8 | 894 | 3.09375 | 3 | [] | no_license | class Location
attr_reader :latitude, :longitude, :address
def initialize(data)
@latitude = data[:results][0][:geometry][:location][:lat]
@longitude = data[:results][0][:geometry][:location][:lng]
@address = check_address(data)
end
def formatted_address
address.values.reject(&:empty?).join(', ... | true |
52e225ef5832465937f14a957f1be98f179e2739 | Ruby | HarrisonLavin/Medical_Group_MVC_Project | /spec/patient_spec.rb | UTF-8 | 1,181 | 2.671875 | 3 | [] | no_license | # Patient Spec
# ==============
require "pry"
require "spec_helper"
describe Patient do
let(:oct_31) {Appointment.new(patient: "Holly", doctor: "Dr. Love", day: "Oct 31st")}
let(:nov_1) {Appointment.new(patient: "Holly", doctor: "Dr. Love", day: "Nov 1st")}
let(:dr_love) {Doctor.new("Dr. Love")}
let(:dr_cr... | true |
9dd1b4eea2854189f4e0d1b281ffaa8791efa03a | Ruby | alyssawatsonlee/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 1,042 | 3.28125 | 3 | [] | no_license | module Players
class Computer < Player
WIN_COMBINATIONS = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6],]
def move(board)
#sleep(0.15)
move = nil
if !board.taken?(5)
move = "5"
elsif board.taken?(5) && board.turn_count == 1
move = "1"
else... | true |
4c322c49910335012c7af36d568b15e6ee4603b8 | Ruby | mcary/wolverine | /spec/wolverine/compatibility_generator_spec.rb | UTF-8 | 636 | 2.59375 | 3 | [] | no_license | require File.dirname(__FILE__)+"/../spec_helper"
describe Wolverine::CompatibilityGenerator do
it "enumerates values yielded by #each" do
gen = Wolverine::CompatibilityGenerator.new([1, 2, 3])
[gen.next, gen.next, gen.next].should == [1, 2, 3]
end
it "gives warning of termination with #end?" do
gen = ... | true |
d09b3867ce3bacd7f4ca568973a160d4c7d6d5c4 | Ruby | tvumbaca/project-recursion | /fib.rb | UTF-8 | 429 | 4.625 | 5 | [] | no_license | # Fibonacci sequence method using iteration
def fibs(n)
a = 0
b = 1
arr = []
n.times {
c = a + b
arr << a
a = b
b = c
}
arr
end
p fibs(6)
# => [0, 1, 1, 2, 3, 5]
# Fibonacci sequence method using recursion
def fibs_rec(n, arr=[0, 1])
return arr[-2] if n == 1
return arr if n == 2
... | true |
1ad294547e923201086056ca350b15e16fb29d1d | Ruby | kradul/bewd_sf_12 | /03_Collections_Loops/solutions/hw_secret_number1_solution.rb | UTF-8 | 2,876 | 4.59375 | 5 | [] | no_license | ###############################################################################
#
# Back-End Web Development - Homework #1
#
# Secret Number is a game you will build in two parts.
# The purpose of the game is to have players guess a secret number from 1-10.
#
# Read the instructions below.
# This exercise will test you... | true |
d1296e0a8de145a910e4678b557f61d56f942b6a | Ruby | kaylasilvey/object_oriented_ruby | /inheritance_example.rb | UTF-8 | 947 | 3.609375 | 4 | [] | no_license | class Transportaion_characteristics
def initialize
@speed = 0
@direction = "north"
end
def brake
@speed = 0
end
def accelerate
@speed += 10
end
def turn(new_direction)
@direction = new_direction
end
end
class Car < Transportaion_characteristics
attr_reader :fuel, :make, :model
... | true |
7169b46c0429ba09226b3f45dfdaad3c46f535bd | Ruby | schmich/nightwatch | /lib/nightwatch/hook.rb | UTF-8 | 827 | 2.5625 | 3 | [
"MIT"
] | permissive | module Nightwatch
class Hook
def initialize(klass, method, &impl)
@method = klass.instance_method(method)
@new_impl = impl
@orig_impl = nil
apply
end
def apply
return if @orig_impl
method = @method.name
new_impl = @new_impl
@orig_impl = @method.owner.cl... | true |
96ffd576f90dc638ac8a7fa4f6cf9ced06b6a750 | Ruby | hgodinot/hgodinot-Launch_School | /RB101/small_problems/easy_3/2.rb | UTF-8 | 296 | 3.609375 | 4 | [] | no_license | OPERATIONS = [:+, :-, :*, :%, :**]
def prompt(string)
puts "==> #{string}"
end
prompt("Enter the first number:")
first = gets.chomp.to_i
prompt("Enter the second number:")
second = gets.chomp.to_i
OPERATIONS.each do |op|
prompt("#{first} #{op} #{second} = #{first.send(op, second)}")
end
| true |
02e10f246e531001e8a3c249ed6331038fffa64d | Ruby | jmazzi/github | /spec/github/core_ext/hash_spec.rb | UTF-8 | 1,002 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
describe Hash do
before do
Github.new
@hash = { :a => 1, :b => 2, :c => 'e'}
@serialized = "a=1&b=2&c=e"
@nested_hash = { 'a' => { 'b' => {'c' => 1 } } }
@symbols = { :a => { :b => { :c => 1 } } }
end
it "should respond to except" do
@nested_hash.should respond_to ... | true |
f7e47bde3c938c5a17039970ff695f0165dabc06 | Ruby | Ignacio91/Chess | /Graph/Graph.rb | UTF-8 | 2,616 | 3.59375 | 4 | [] | no_license | =begin
* Graph
* Description :Handles all operation done on the graph
* Author:Ignacio Ferrero
=end
require "rubygems"
require_relative 'AddInfo.rb'
class Graph
#Global variable with all the information :nodes and vertex
attr_accessor :parse
@parse = {}
def initialize(graph_parse)
@parse = graph... | true |
ea92c7a63c92160b5248d2ae4e81d1e3eb331e29 | Ruby | graemej/byebug | /test/finish_test.rb | UTF-8 | 1,230 | 2.640625 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative 'test_helper'
class FinishExample
def a
b
end
def b
c
2
end
def c
d
3
end
def d
5
end
end
class TestFinish < TestDsl::TestCase
it 'must stop at the next frame by default' do
enter "break #{__FILE__}:16", 'cont', 'finish'
debug_file('finish') { $state.... | true |
223472df67ada1067d573d0cab30899a51b5f73f | Ruby | glebpom/prop | /test/test_prop.rb | UTF-8 | 5,127 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'helper'
class TestProp < Test::Unit::TestCase
context "Prop" do
setup do
@store = {}
Prop.read { |key| @store[key] }
Prop.write { |key, value| @store[key] = value }
@start = Time.now
Time.stubs(:now).returns(@start)
end
{"with incrementer" => lambda { Prop.incre... | true |
38a2932b5be0485172e620cab17231f649b0714f | Ruby | iamraffe/tic-tac-toe | /tictactoe.rb | UTF-8 | 3,418 | 3.90625 | 4 | [] | no_license | class Game
attr_reader :players, :board, :current_player, :other_player, :game_over
WINNING_COMBINATIONS = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [6,4,2]]
def initialize(players)
@board = Board.new
@current_player, @other_player = players.shuffle
@game_over = false
end
... | true |
a5c35ff4e35232310c4c5f8c3011f56195f050ae | Ruby | MarioRuiz/nice_http | /lib/nice_http/initialize.rb | UTF-8 | 10,997 | 2.5625 | 3 | [
"MIT"
] | permissive | class NiceHttp
######################################################
# Creates a new http connection.
#
# @param args [] If no parameter supplied, by default will access how is setup on defaults
# @example
# http = NiceHttp.new()
# @param args [String]. The url to create the connection.
# @example
... | true |
850793a13d66142514accb934759240d23dbedb7 | Ruby | masao/fuwatto | /springer.rb | UTF-8 | 2,411 | 2.59375 | 3 | [] | no_license | #!/usr/local/bin/ruby
# -*- coding: utf-8 -*-
# $Id$
require_relative "fuwatto.rb"
module Fuwatto
class SpringerApp < BaseApp
TERMS = 10
TITLE = "Fuwatto Springer Search / ふわっとSpringer関連検索"
HELP_TEXT = <<-EOF
<p>
This search tool allows you to search <a href="http://springerlink.com">Springer L... | true |
220ba67d3df755f35e5660ed40decb7423f28183 | Ruby | adellanno/rps-challenge | /spec/features/rps_spec.rb | UTF-8 | 1,214 | 2.796875 | 3 | [] | no_license | require 'spec_helper'
feature 'Creates a game of Rock, Paper, Scissors' do
it 'asks the user to enter their name' do
visit '/'
expect(page).to have_content "Please enter your name."
end
it 'clicking submit takes you to a new game of Rock, Paper, Scissors' do
visit '/'
fill_in 'name', with: 'Ant... | true |
95034801b41dc12dfcc6d982fe75d97ff16c65fb | Ruby | filipebarcos/dotfiles | /ruby/irbrc | UTF-8 | 2,055 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:AUTO_INDENT] = true
class Object
# list methods which aren't in superclass
def local_method... | true |
17c86c95a916e104c9d3d95b8935584134d6db18 | Ruby | GlynnisOC/real_estate_1901 | /test/house_test.rb | UTF-8 | 2,081 | 3.484375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/house'
require './lib/room'
class HouseTest < Minitest::Test
def test_it_exists
house = House.new("$400000", "123 sugar lane")
assert_instance_of House, house
end
def test_how_much_is_it
house = House.new("$400000", "123 sugar lane... | true |
a8c2a2311a8fdd0b0bfb1254f306a6664cb07e06 | Ruby | saghourkhalil/td | /app/models/order.rb | UTF-8 | 239 | 2.6875 | 3 | [] | no_license | class Order < ApplicationRecord
belongs_to :user
has_many :item_orders
has_many :items, through: :item_orders
def total_price()
tot = 0.00
items.each do |item|
tot += item.price.to_d
end
return tot
end
end
| true |
38109d9fd4470da58b419df8ee0613dc78d2fde7 | Ruby | bomattsson/Battleship-1 | /lib/player.rb | UTF-8 | 2,071 | 3.8125 | 4 | [] | no_license | require './lib/grid.rb'
require './lib/ship.rb'
class Player
attr_accessor :my_board, :opponents_board, :ships
def initialize
@my_board = Grid.new
@opponents_board = Grid.new
@ships = [Ship.new("A"), Ship.new("B"), Ship.new("S"), Ship.new("C"), Ship.new("P")]
#make 5 ships and store in this arr... | true |
9ba7d8f9ce027721cd0a2569bb1dc3caaddc22d6 | Ruby | stixbunny/desafio-methods-ruby | /4.rb | UTF-8 | 101 | 3.234375 | 3 | [] | no_license | def saludo(x)
if x == "Hola"
return "Hola Mundo"
else
return "No me saludaste"
end
end
| true |
05e465fdaa192facd8722b79a4c972d8951f1417 | Ruby | AmyMcKnight/launchschool | /intro_to_programing_book/07_hashes_exercises.rb | UTF-8 | 3,345 | 4.75 | 5 | [] | no_license | # Exercises
# 1. Given a hash of family members, with keys as the title
# and an array of names as the values, use Ruby's built-in
# select method to gather only immediate family members' names
# to a new array.
family = { uncles: ["bob", "joe", "steve"],
sisters: ["jane", "jill", "beth"],
... | true |
0abda6b940b5e643c361fdd983a5dc4d86489404 | Ruby | medusa-project/ideals | /app/models/invitee.rb | UTF-8 | 6,572 | 2.65625 | 3 | [] | no_license | # frozen_string_literal: true
##
# Non-NetID user who has either been invited to register, or has requested to
# register, and may or may not yet have a corresponding {LocalIdentity
# identity}.
#
# # Invitation/Registration Flow
#
# This class is the entry point into the local-user account model. Instances
# are crea... | true |
2f74dc7630c6763309a1ca55543748f8841f654f | Ruby | ilhamsurya/GenerasiGigih_Assigment | /module4/session2/increment_array_spec.rb | UTF-8 | 1,573 | 2.859375 | 3 | [] | no_license | require_relative './test_helper'
require_relative './increment_array'
describe IntegerArrayIncrementer do
# before(:each)do
# end
it 'should return [1] when input is [0]' do
input = [0]
expected_output = [1]
actual_output = IntegerArrayIncrementer.new.increment(input)
... | true |
98d3a4c97cf6a51fea7b01bb8be6960a6e968335 | Ruby | jayshenk/algorithms | /single_number.rb | UTF-8 | 219 | 3.578125 | 4 | [] | no_license | # Given an array of integers, every element appears twice except for one. Find that single one.
#
# Bit manipulation approach:
def single_number(nums)
mask = 0
nums.each do |num|
mask ^= num
end
mask
end
| true |
03230177b39e4c44bafd4637091826b5460fd43a | Ruby | mwagner19446/wdi_work | /w01/d05/Jessica/rental.rb | UTF-8 | 5,199 | 3.78125 | 4 | [] | no_license | class Person
def initialize()
end
def add_name=(add_name)
@add_name = add_name
end
def add_name
return @add_name
end
def add_age=(add_age)
@add_age = add_age
end
def add_age
return @add_age
end
def add_gender=(add_gender)
@add_gender = add_gender
end
def add_gender
... | true |
231cefb2220346efe2e3364cee1aeb947b4aa2b4 | Ruby | pedrocaseiro/fast_jsonapi | /spec/lib/extensions/active_record_spec.rb | UTF-8 | 3,520 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
require 'active_record'
require 'sqlite3'
describe 'active record' do
# Setup DB
before(:all) do
@db_file = "test.db"
# Open a database
db = SQLite3::Database.new @db_file
# Create tables
db.execute_batch <<-SQL
create table suppliers (
name varchar(30),
... | true |
94d27adabb2b81e524b391365ddf611e752876af | Ruby | xiaket/euler-ruby | /41-50/46.rb | UTF-8 | 437 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: UTF-8
# Author: Kent Xia/Xia Kai <kentx@pronto.net/xiaket@gmail.com>
# Filename: 46.rb
# Date created: 2016-08-21 18:18
# Last modified: 2016-08-21 18:28
#
# Description:
#
require 'prime'
(2..10000).each do |n|
i = n * 2 + 1
if Prime.prime? i
next
end
part... | true |
8f514ea1f9f04e88edc873c9b79d7d4cd78701fb | Ruby | sameckmeier/tic_tac_toe | /lib/tic_tac_toe/model/game_state.rb | UTF-8 | 2,362 | 3.359375 | 3 | [
"MIT"
] | permissive | module Model
class GameState
def winner(board)
tile_collection = board.tile_collection
rows(tile_collection) || cols(tile_collection) || diags(tile_collection)
end
def rating(board, team)
winner = winner(board)
return 0 unless winner
winner.name == team.name ? 1 : -1
... | true |
2fa65dac771d587a0f02583ba7ffb36f114251dc | Ruby | bhauman/rgba_rack | /rack_color_img.rb | UTF-8 | 1,338 | 2.546875 | 3 | [] | no_license | require 'rmagick'
require 'open-uri'
require 'rack'
module Rack
class ColorImg
def initialize(app)
@app = app
end
def call(env)
if colors = env["PATH_INFO"].match(%r{/hue_img/(\d{1,3})\.png})
request = Rack::Request.new(env)
# we should really set an early timeout here because... | true |
83394873c6a5a01d4b9e886517110624753200a3 | Ruby | karaken12/bbc6musicaotd | /site/_scripts/SpotifySearch.rb | UTF-8 | 1,302 | 2.75 | 3 | [
"Apache-2.0"
] | permissive |
require 'rspotify'
module SpotifySearch
config_path = File.expand_path('app_secret.yml', File.dirname(__FILE__))
$app_config = YAML.load_file(config_path)
def SpotifySearch.get_candidate(album)
return {
'artists' => album.artists.map{|a| a.name},
'name' => album.name,
'album_id' => a... | true |
fc8600dcf4a4c78d09ba93fd5b095263dfb96ec2 | Ruby | toneegee/ColourMatch | /app/services/photo/extract_primary_colour.rb | UTF-8 | 295 | 2.578125 | 3 | [
"MIT"
] | permissive | class Photo::ExtractPrimaryColour
def self.call(colour_data)
match_colour_to_db(colour_data.first)
end
private
def self.match_colour_to_db(c)
{
type: "primary",
colour: Colour::FindClosest.call(c[:lab]),
occurances: c[:occurances]
}
end
end | true |
6cda0a22ffea425c07434757f9fd41f01e2fab51 | Ruby | cbalsara/weekend_homework_proper1 | /pet_shop.rb | UTF-8 | 1,072 | 3.046875 | 3 | [] | no_license | require ( "pry-byebug" )
#binding.pry
#ruby specs/pet_shop_spec.rb for testing in the terminal
def pet_shop_name(property)
return property[:name]
end
def total_cash(money)
return money[:admin][:total_cash]
end
def add_or_remove_cash(money_being_placed, blank_value) #these are here because of the two variable... | true |
21c220335bed8c79c0b3b5b26fdbf1b211cff6b0 | Ruby | critsmet/astroCLI | /lib/methods/delete.rb | UTF-8 | 496 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def get_name_to_delete
puts "Who would you like to delete?"
puts_space
print_users
puts_space
name = gets.chomp.strip
puts_space
name
end
def delete
clear
name = get_name_to_delete
if name == "return"
return
elsif name_invalid?(name)
puts "Please enter a valid name:"
delete
else
... | true |
1c11acb1e21a2ef7beac0776df5d291b958b510e | Ruby | r888888888/meimei | /lib/meimei/persistent_hash.rb | UTF-8 | 739 | 3.0625 | 3 | [
"MIT"
] | permissive | class PersistentHash
def initialize(file_path, commit_interval = 1)
@commit_interval = commit_interval
@commit_count = 0
@file_path = file_path
restore!
unless @hash.is_a?(Hash)
@hash = {}
commit!
end
end
def restore!
if File.exist?(@file_path)
mode = File::RDONLY
else
return
end
Fi... | true |
8439bb46feed809f47128026a06287feb1eb8a9c | Ruby | tfabery/number_to_word_ruby | /spec/number_to_word_spec.rb | UTF-8 | 2,355 | 3.546875 | 4 | [] | no_license | require('number_to_word')
require('rspec')
describe('Fixnum#num_to_word') do
it("returns a word for a single digit") do
expect(9.num_to_word()).to(eq('nine'))
end
it("returns a word for a number up to ten") do
expect(10.num_to_word()).to(eq('ten'))
end
it("returns a word for a number up to twenty") d... | true |
cfc7e68302e37f850072b3802838f800a7b8e4e4 | Ruby | CaptainPhilipp/CycleHub | /app/models/concerns/multiparent_tree/collection_object.rb | UTF-8 | 924 | 2.703125 | 3 | [] | no_license | module MultiparentTree
class CollectionObject
def initialize(records: nil, ids: nil, type: nil, klass: nil)
@type_object = TypeObject.new(type: type || klass)
@ids = ids
@records = [*records]
end
def ids
@ids ||= klass ? by_class[klass] : false
end
def type
@type ||... | true |
ab8a8d27f0d5270bcc19cb017dd25f84f42115e9 | Ruby | ronaldvz/ronaldvz.github.com | /Rakefile | UTF-8 | 673 | 2.84375 | 3 | [] | no_license | #Usage: rake write["title of post"]
desc "Given a title as an argument, create a new post file"
task :write, [:title] do |t, args|
filename = "#{Time.now.strftime('%Y-%m-%d')}-#{args.title.gsub(/\s/, '_').downcase}.md"
path = File.join("_posts", filename)
if File.exist? path; raise RuntimeError.new("Won't clobber... | true |
b80380e1a7da8f56bb676c236e431150f0bdcc3d | Ruby | itggot-Amin-Othman/standard-biblioteket | /lib/sum_to.rb | UTF-8 | 144 | 3.125 | 3 | [] | no_license | def sum_to(num)
i = 1
output = 0
while i < num + 1
output = output + i
i = i + 1
end
return output
end
| true |
4e2ebbab6debebded1265b8c9c23cfb1df83d986 | Ruby | jhuang429/programming-univbasics-4-array-concept-review-lab-nyc-web-010620 | /lib/array_methods.rb | UTF-8 | 528 | 3.359375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
counter = 0
value = nil
while array[counter] do
if array[counter] == value_to_find
value = counter
end
counter += 1
end
value
end
def find_max_value(array)
max = 0
counter = 0
while array[counter] do
if array[counter] > max
max =... | true |
f1933b370b089507c97d00e47f97dc2b4a89fc7a | Ruby | k-eaton/Inspirations | /app/helpers/twilio.rb | UTF-8 | 1,166 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'dotenv'
require 'twilio-ruby'
module DailyText
def text
# put your own credentials here
account_sid = ENV['ACCOUNT_SID']
auth_token = ENV['AUTH_TOKEN']
client = Twilio::REST::Client.new account_sid, auth_token
from = "+13104218914" # Your Twilio number
phone_numbers = PhoneNumber.all
... | true |
2fdd072bebf8204877380a214888f68d1ebf25ab | Ruby | kenneth-yu/emoticon-translator-dumbo-web-121018 | /lib/translator.rb | UTF-8 | 677 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require 'yaml'
def load_library(path)
dictionary = {
"get_meaning" => {},
"get_emoticon" => {}
}
YAML.load_file(path).each do |meaning, emoticon|
dictionary["get_meaning"][emoticon[1]] = meaning
dictionary["get_emoticon"][emoticon[0]] = emoticon[1]
end
dictionary
e... | true |
9c8e9954ec81254ec9a146d277900f420205a59a | Ruby | lehnerchristian/ScalableWebArchitectures | /lib/ItemTracking/item_tracking_system.rb | UTF-8 | 1,057 | 2.546875 | 3 | [] | no_license | require 'grape'
require_relative '../filter_helper'
require_relative '../client'
class ItemTrackingSystem < Grape::API
version 'v1', using: :header, vendor: 'project'
format :json
items = []
id = 1
size = items.length
helpers do
def authenticate!
status = FilterHelper.auth_helper(Client, env)
error!("... | true |
708b1f208492da3c55a318794b44c8a8d3954304 | Ruby | socketry/async-examples | /rack-async-http-falcon-graphql-lazy-resolve/query.rb | UTF-8 | 1,290 | 2.671875 | 3 | [
"MIT"
] | permissive | require "async/http/internet/instance"
class Query < GraphQL::Schema::Object
field :one, String, null: false
field :two, String, null: false
field :three, String, null: false
def one
Async { delay_1_data["url"] }
end
def two
Async { delay_2_data["url"] }
end
def three
Async { delay_2_dat... | true |
070adc6e223f06da9954057130dcc66c18a2642c | Ruby | pola91/Smart_Blood_Centers_v2 | /app/controllers/consumption_rates_controller.rb | UTF-8 | 3,243 | 2.625 | 3 | [] | no_license | class ConsumptionRatesController < ApplicationController
def fun_name (arguments)
@Excess_A = Array.new
@Excess_B = Array.new
@Excess_AB = Array.new
@Excess_O = Array.new
@Shortage_Arr= Array.new
@Process_for_A = consumption_rate.where(:type=>A)
@Process_for_B = consumption_rate.where(:type=>B)
@... | true |
753f58cb529c28b3c16cc04dbd54cf4448715036 | Ruby | TheMoniulla/code_eval_ruby | /data_recovery/code.rb | UTF-8 | 494 | 3.625 | 4 | [] | no_license | File.open('input.txt').each_line do |line|
array = line.split(';')
def words(array)
array[0].split(' ')
end
def parsed_numbers(array)
array[1].split(' ').map(&:to_i)
end
def words_in_correct_order(array)
numbers = parsed_numbers(array)
result = []
for i in 1..words(array).length
... | true |
066b78734b36e9c8d2736060f3b4ae62daddc16e | Ruby | yuroyoro/functionally | /spec/shared/composable_spec.rb | UTF-8 | 618 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
shared_examples 'composable' do
it { should respond_to :to_proc}
it { should respond_to :>> }
it { should respond_to :<< }
it { should respond_to :compose }
let(:g) { lambda{|x| x * 2 } }
it('" f >> g" returns g(f)'){ (subject >> g).should be_a_kind_of Proc }
it('"(f >> g).call(x)... | true |
350707c33082c178fd82733a7ff1fdc11eeb8d1c | Ruby | celluloid/celluloid | /lib/celluloid/internals/method.rb | UTF-8 | 755 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Celluloid
module Internals
# Method handles that route through an actor proxy
class Method
def initialize(proxy, name)
raise NoMethodError, "undefined method `#{name}'" unless proxy.respond_to? name
@proxy = proxy
@name = name
@klass = @proxy.class
end
... | true |
2117868fad1ce1887323e0f1ef37f7580d097871 | Ruby | Seabreg/yawast | /lib/util.rb | UTF-8 | 706 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | require 'colorize'
module Yawast
class Utilities
def self.puts_msg(type, msg)
puts "#{type} #{msg}"
end
def self.puts_error(msg)
puts_msg('[E]'.red, msg)
Yawast::Shared::Output.log_append_value 'messages', 'error', msg
end
def self.puts_vuln(msg)
puts_msg('[V]'.magenta, ... | true |
7caced0f6dafbdf1c615a507104f3c4362e15c9f | Ruby | Danny-Duck/Terminal-Weather-Gem | /lib/index.rb | UTF-8 | 1,085 | 3.265625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'model.rb'
require_relative 'config.rb'
Prompt = TTY::Prompt.new
Box = nil
def day_creation(date, summary, temp)
TTY::Box.frame date, summary, temp, padding: 1, align: :center
end
def location_prom
system 'clear'
a = Prompt.select('Show me the forecast of ', { 'm... | true |
fc6cd7bf9daad450a477c26f5e91597507439614 | Ruby | mozcomp/cupsffi | /lib/cupsffi/printer.rb | UTF-8 | 8,691 | 2.6875 | 3 | [
"MIT"
] | permissive | # The MIT License
#
# Copyright (c) 2011 Nathan Ehresman
#
# 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, copy, modify,... | true |
56876303cc3f2c7bf86e54467e4cec19b784c14c | Ruby | Jackwhitener/poker | /poker.rb | UTF-8 | 1,339 | 3.390625 | 3 | [] | no_license | def randomcard(amount)
cards = (1..52).to_a
drawncards = Array.new
amount = amount.to_i
if amount < 1
return ["stobbit"]
else
amount.times do
card = cards.sample
cards.delete_at(card)
drawncards << card
end
# puts drawncards
return drawncards
end
e... | true |
ed7d9cf7ed7b71368fd9b233edd8d60ddd2dc80a | Ruby | maartenberg/Aardbei | /app/models/member.rb | UTF-8 | 3,739 | 2.828125 | 3 | [
"MIT"
] | permissive | # A Member represents the many-to-many relation of Groups to People. At most
# one member may exist for each Person-Group combination.
class Member < ApplicationRecord
# @!attribute is_leader
# @return [Boolean]
# whether the person is a leader in the group.
#
# @!attribute display_name
# @return [S... | true |
ab7d5d7b6027be957f15cc128c6fabc22227d81a | Ruby | snayrouz/sorting_suite | /selection/lib/selection_sort.rb | UTF-8 | 297 | 3.234375 | 3 | [] | no_license | class Selection
def sort(array)
new = array.length
for i in 0...new
min = i
for j in (i + 1)...new
if array[j]<array[min]
temp = array[j]
array[j] = array[min]
array[min] = temp
end
end
end
return array
end
end
| true |
6a95577f8e36b23ef3ec81c8f012ec2fa8958617 | Ruby | kiran-gurujada/pickaxe | /chapter13/roman_test.rb | UTF-8 | 705 | 3.390625 | 3 | [] | no_license | #require_relative 'roman_bug'
require_relative 'roman_fixed'
r = Roman.new(1)
fail "'i' expected" unless r.to_s == 'i'
r = Roman.new(9)
fail "'ix' expected" unless r.to_s == 'ix'
# this method works but is cumbersome and has been replaced by
# dedicated frameworks.
# The default in Ruby >1.9 is MiniTest.
# MiniTest:... | true |
dc2e42604c8d7822d1164af2dc4c05a07eeb1b77 | Ruby | Altizon/datonis-edge-sdk-ruby | /edge/lib/edge/edge_configuration.rb | UTF-8 | 598 | 2.703125 | 3 | [] | no_license | module Edge
PROTOCOL_HTTP = :http
PROTOCOL_MQTT = :mqtt
class EdgeConfiguration
attr_reader :access_key, :secret_key, :url
def initialize(access_key, secret_key, protocol = PROTOCOL_HTTP, ssl = false, url = nil)
@access_key = access_key
@secret_key = secret_key
if (url.nil... | true |
9cb3feffa6a849d39f43222dc79061466b170209 | Ruby | tchemski/ruby_lessons | /2/4.rb | UTF-8 | 392 | 2.84375 | 3 | [] | no_license | #!/usr/bin/ruby -w
# Заполнить хеш гласными буквами, где значением будет являтся порядковый номер буквы в алфавите
vowels = %w(A E I O U)
vowels_hash = {}
vowels.each{|l| vowels_hash[l] = true}
counter = 0
('A'..'Z').each do |l|
vowels_hash[l] = counter if vowels_hash[l]
counter += 1
end
p vowels_hash
| true |
05292df950641bd0f151dd995e59a1d8c5774d7d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/1874.rb | UTF-8 | 205 | 3.015625 | 3 | [] | no_license | def compute(a, b)
first, second = [a, b].sort { |x, y| x.length <=> y.length }
return first.split('').each_with_index.inject(0) do |r, (e, index)|
e == second[index] ? r : r + 1
end
end | true |
fb6d685bf82a8b1eaccc1192e86991ffb7920a44 | Ruby | pucrs-automated-planning/HyperTensioN | /extensions/Grammar.rb | UTF-8 | 904 | 2.640625 | 3 | [] | no_license | module Grammar
extend self
#-----------------------------------------------
# Apply
#-----------------------------------------------
def apply(operators, methods, predicates, state, tasks, goal_pos, goal_not)
puts 'Grammar'.center(50,'-'), 'Production rules'
methods.each {|met|
parameters = me... | true |
5519d54d17c22319d47c2a165f2e77acbefb379d | Ruby | guoshukaka/cf_recommendation | /test/recommend_test.rb | UTF-8 | 6,330 | 2.953125 | 3 | [
"MIT"
] | permissive | # A simple class to test CF algorithms using MovieLens 100K or 1M sample datasets
require './../lib/recommend_factory'
class RecommendTest
# MEMORY_BASED or MODEL_BASED
CF_METHOD_TYPE = Recommendation::MODEL_BASED
# USER_BASED or ITEM_BASED or SVD_ITEM_BASED or SVD_USER_BASED or SVD_INCREMENTAL
CF_ALGORITHM ... | true |
44427dc96a3d39cf2b27f4c9da66d750ae1b40c0 | Ruby | Inviz/sequel | /model_plugins/not_naughty/lib/not_naughty/validations/format_validation.rb | UTF-8 | 1,615 | 3.015625 | 3 | [
"MIT"
] | permissive | module NotNaughty
# == Validates format of obj's attribute via the <tt>:match</tt> method.
#
# Unless the validation succeeds an error hash (:attribute => :message)
# is added to the obj's instance of Errors.
#
# <b>Options:</b>
# <tt>:with</tt>:: object that that'll check via a <tt>:match</tt> call
... | true |
be878563dd55dcc4468f6689373e64caba643313 | Ruby | BankToTheFuture/fund_america | /lib/fund_america/bank_transfer_method.rb | UTF-8 | 458 | 2.65625 | 3 | [
"MIT"
] | permissive | module FundAmerica
class BankTransferMethod
class << self
# End point: https://apps.fundamerica.com/api/bank_transfer_methods/:id (GET)
# Usage: FundAmerica::BankTransferMethod.details(bank_transfer_method_id)
# Output: Returns the details of a bank transfer method with matching id
def de... | true |
8a4e69c16f5a93459da32d54a322ec594d8146ab | Ruby | shibuya11055/keiba_app | /lib/import_race_data.rb | UTF-8 | 3,052 | 3.03125 | 3 | [] | no_license | require 'bundler/setup'
require 'nokogiri'
require 'open-uri'
require 'csv'
class ImportRaceData
INDEX_YEAR = [2020, 2021] # データを取得したい年
CSV_HEADER = ['日時', '競馬場', 'レース名', 'グレード', '距離', '種別', '着順', '枠', '馬番', '馬名', '性別', '騎手', '調教師']
def setup_doc(url)
doc = Nokogiri::HTML.parse(URI.open(url, "r:CP932").rea... | true |
114f350157e45da5d1da839fb37bd37a24ee88e1 | Ruby | sanoopsandy/zomato | /zomato.rb | UTF-8 | 910 | 2.59375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/contrib'
require './Main_api.rb'
set :server, 'webrick'
get '/' do
# REVIEW -- why are @var variable being used here? Are these attributes of
# an objects? Which object? -------- ------------------------------------------------- #fixed
city = Main_api.list_city
erb :index, :l... | true |
27ccc5188b45e2251114368a093dba305580265a | Ruby | griswoldbar/boudreaux | /app/services/fik/instructions/mover.rb | UTF-8 | 1,231 | 2.859375 | 3 | [] | no_license | module Fik
module Instructions
class Mover
attr_reader :messages, :notifications, :callback
def initialize(direction:, game:)
@direction = direction
@game = game
@current_room = game.current_room
@world = game.world
@protagonist = game.protagonist
... | true |
5768d4ab36fe44f4e42d8c41862e53570554f624 | Ruby | transitland/transitland-datastore | /spec/controllers/api/v1/stops_controller_spec.rb | UTF-8 | 7,187 | 2.71875 | 3 | [
"MIT"
] | permissive | describe Api::V1::StopsController do
before(:each) do
@glen_park = create(:stop, geometry: 'POINT(-122.433416 37.732525)', name: 'Glen Park')
@bosworth_diamond = create(:stop, geometry: 'POINT(-122.434011 37.733595)', name: 'Bosworth + Diamond')
@metro_embarcadero = create(:stop, geometry: 'POINT(-122.396... | true |
813fa0b60675e14c599cea923ebeee0705d3d5de | Ruby | fkhalili/wdi | /w08/d03/Instructor/jukebox.rb | UTF-8 | 616 | 3.046875 | 3 | [] | no_license | require('./music_player.rb')
class Jukebox < MusicPlayer
@@jukeboxes = []
def self.all
@@jukeboxes
end
# Jukebox.jukeboxes
def initialize(media_type, volume_range, list_of_songs, location)
@media_type = media_type
@volume_range = volume_range
@list_of_songs = list_of_songs
@location ... | true |
86ce015aa7a31398d5967d5e344669aa79d87720 | Ruby | NicholasFlorian/CupThrow | /app/controllers/sessions_controller.rb | UTF-8 | 4,844 | 2.796875 | 3 | [] | no_license | class SessionsController < ApplicationController
# sign in page
#
#
# GET defign our sign in page
def register
if signed_in? then
@user = current_user
redirect_to profile_path
end
end
# POST sign in to the app
def sign_in
# retreive form
email = params[:session][:emai... | true |
3c6e29fa4b04208333c314312e7f8ba96158e039 | Ruby | stanvandepoll/RB130 | /exercises/easy_1/5.rb | UTF-8 | 804 | 3.203125 | 3 | [] | no_license | ENCRYPTED_NAMES = <<~ENC
Nqn Ybirynpr
Tenpr Ubccre
Nqryr Tbyqfgvar
Nyna Ghevat
Puneyrf Onoontr
Noqhyynu Zhunzznq ova Zhfn ny-Xujnevmzv
Wbua Ngnanfbss
Ybvf Unvog
Pynhqr Funaaba
Fgrir Wbof
Ovyy Tngrf
Gvz Orearef-Yrr
Fgrir Jbmavnx
Xbaenq Mhfr
Fve Nagbal Ubner
Zneiva Zvafxl
Lhxvuveb Zngfhzbgb
Unllvz Fybavzfxv
Tregehqr Oyna... | true |
2ad407c658d31cdbf7398448ea0bced87fee28e4 | Ruby | ufarruh/assignment_rspec_viking | /spec/viking_spec.rb | UTF-8 | 915 | 3.09375 | 3 | [] | no_license | require_relative '../lib/viking'
describe Viking do
describe "#initialize" do
let(:viking){ Viking.new("Farruh", 100) }
let(:viking_rand){ Viking.new }
let(:bow){ Bow.new }
it "passing a name to Viking sets it as new name" do
expect(viking.name).to eq("Farruh")
end
it "returns Random... | true |
5ff4893f38e139c8851862fbaafa523691fb93d4 | Ruby | lmesz/RAFF | /bin/raff.thor | UTF-8 | 1,723 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'logger'
require 'thor'
require './lib/aws_drupal_cluster_handler'
require './lib/aws_rest'
class Raff < Thor
def initialize(*args)
super
@logger = Logger.new(STDOUT)
@aws_drupal_cluster_handler = AwsDrupalClusterHandler.new(Aws::EC2::Resource.new(:region => 'us-east-1'),
... | true |
15f951b0ac4afebdd7453280292962df046ef21f | Ruby | BOOMCHOPALAKA/ruby_practice | /ex10.rb | UTF-8 | 1,699 | 4.15625 | 4 | [] | no_license | # This use of the \ (back-slash) character is a
# way we can put difficult-to-type characters into
# a string. There are plentyof these “escape sequences”
# available for different characters you might want to
# put in, but there’s a special one, the
# double back-slash which is just two of them \\.
# These two charact... | true |
e963adc0255950d28b618f7f7983cfeca5f95a5f | Ruby | ryanden2018/count-elements-houston-web-career-040119 | /count_elements.rb | UTF-8 | 175 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def count_elements(array)
results = {}
array.each do |item|
if !results[item]
results[item] = 1
else
results[item] += 1
end
end
results
end
| true |
9c1bf38e88d34c79c8ecab2c257910ae9297c189 | Ruby | yazinsai/algorithms | /knapsack.rb | UTF-8 | 1,089 | 4.375 | 4 | [] | no_license | =begin
Given a set of items, each with a weight and a value, determine the
maximum total value that can be placed inside the knapsack. Items are
indivisible; you either take an item or not. You can only take 1 unit
of each item.
For example,
Input:
value = [ 20, 5, 10, 40, 15, 25 ]
weight = [ 1, 2, 3, 8, 7, 4 ]
in... | true |
301eecadde07d8c0e3665f9d8510567d4a72cc40 | Ruby | Cyfon7/Desafio---Arreglos | /filtro_procesos.rb | UTF-8 | 212 | 2.609375 | 3 | [] | no_license | numero = ARGV[0]
datos = open('./procesos.data').readlines
lista = []
datos.each do |elem|
if elem > numero
lista << elem.to_i
end
end
File.write('./procesos_filtrados.data',lista.join("\n"))
| true |
34bdee5c02ad8dc08fd2130c26c8cb5571939035 | Ruby | gopher-snakes-2013/Octo_Ninjas | /helpers/movie_helper.rb | UTF-8 | 240 | 2.53125 | 3 | [] | no_license | module MovieHelper
def current_movie_list
session[:movie_list].map { |movie_id| Movie.find(movie_id) }
end
def add_to_session(movie_id)
session[:movie_list] << movie_id unless session[:movie_list].include?(movie_id)
end
end | true |
def6dc9847d4c80b8354af984c8ee72d53d54171 | Ruby | Nishihatak/freemarket_sample_63b | /app/models/rate.rb | UTF-8 | 258 | 2.5625 | 3 | [] | no_license | class Rate < ApplicationRecord
belongs_to :user
def rate_count_up(selected_rate)
case selected_rate
when "good"
self.good += 1
when "normal"
self.normal += 1
when "bad"
self.bad += 1
end
return
end
end
| true |
c7351874f9ac2a3885fd5aa89e16b14f1eda5f62 | Ruby | jsala1990/SalesTaxForKelly | /spec/parser_spec.rb | UTF-8 | 2,184 | 3.296875 | 3 | [] | no_license | require 'spec_helper'
describe "initialize" do
it "should open file" do
lambda { Parser.new "input_data/test_input_1.txt" }.should_not raise_exception NameError
end
end
describe "#open_file" do
it "should open correct file" do
parser = Parser.new "input_data/test_input_1.txt"
lambda { parser.op... | true |
77dd4b6e8adad7e91575286ff0e4c0b967788fae | Ruby | JDjedi/ruby_coding_challanges | /persistence/persistence.rb | UTF-8 | 322 | 3.375 | 3 | [] | no_license |
def persistence(n)
n_array = n.to_s.split(//)
while (n_array.length) > 1
n_array.collect! { |x| x.to_i }
answer = n_array.reject(&:zero?).inject(:*)
n = answer
n_array.clear
n_array = n.to_s.split(//)
if (n_array.length) == 1
p n
end
end
end
# persistence(39)
# persistence(25)
persistence(9999)
... | true |
60b3353d03c5a2b125f02eb4df8fbee6ffda3b07 | Ruby | rfarese/ruby-book-review | /spec/features/books/user_updates_book_spec.rb | UTF-8 | 2,336 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.feature "User updates a book;", type: :feature do
let(:user) { FactoryGirl.create(:user) }
let(:book) { FactoryGirl.create(:book) }
def sign_in_as_book_creator_and_navigate
book
current_user = User.where(id: book.user_id).first
sign_in(current_user)
find('img.books-i... | true |
1ea4112b265f41303b3c11ec8044f5d231f802d6 | Ruby | andrewarrow/chibrary.com | /value/message_id.rb | UTF-8 | 914 | 2.828125 | 3 | [] | no_license | require 'adamantium'
module Chibrary
class MessageId
include Adamantium
attr_reader :raw
def initialize raw
@raw = (raw || '').to_s
end
def valid?
!raw.empty? and raw.length <= 120 and has_id?
end
def has_id?
raw =~ /\A<?[a-zA-Z0-9%+\-\.=_]+@[a-zA-Z0-9_\-\.]+>?\Z/
end
def to_s
i... | true |
d30449590840916f3ff0f62ef3cd7e60fc57ccb1 | Ruby | idkjay/Launch | /week5-databases/Lornch-Ablademy/spec/features/04_user_views_student_details_spec.rb | UTF-8 | 1,321 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
# Acceptance Criteria:
# As a User
# I want to click on an individual student
# So I can see what clinics that student has attended
# Acceptance Criteria
# [ ] I can click a link from the student index page that leads me to the show page
# [ ] On the show page I can see a list of clin... | true |
f94073a246e9a4bb4a039bd40a81456a2c8aae28 | Ruby | miura1729/yarv2llvm | /sample/e-aux.rb | UTF-8 | 773 | 3.15625 | 3 | [] | no_license | #!/bin/env ruby
# Compute E without bignum
#
KETA = 257
# dst / n -> dst
def div(n, dst)
i = 0
r = 0
while i < KETA do
d = dst[i] + r * 10000
r = d % n
dst[i] = d / n
i = i + 1
end
end
def add(src, dst)
i = KETA - 1
c = 0
while i >= 0 do
t = src[i] + dst[i] + c
... | true |
35212c78cfce90d7b37ae045f8f4f3a0fe003c2a | Ruby | kayssun/hass-ruby | /lib/hass/domain.rb | UTF-8 | 1,705 | 2.75 | 3 | [] | no_license | module Hass
# Base class for all domains (lights, switches, media_player...)
class Domain
attr_accessor :client
attr_reader :entity_id
# Just to make sure, the constant exists
DATA = {}.freeze
def initialize(entity_id)
@entity_id = entity_id
end
def required_fields(method_name)
... | true |
311db07d3993152c412901efed628f6cc6db9722 | Ruby | jmbeas/walkingthepath | /spec/models/event_spec.rb | UTF-8 | 722 | 2.515625 | 3 | [] | no_license | require 'spec_helper'
describe Event do
let(:event){Event.create({:date => 201101121000, :title => 'title', :link => 'link'})}
it "a new event is created for a specific date" do
event.date.should == 201101121000
end
it "updates the month when the date is changed" do
event.date = 201102121000
event... | true |
459bbfe53b6704dc75c555c5ce0ded3e30d3af4a | Ruby | justindelatorre/rb_130 | /small_problems/easy_2/2_zipper.rb | UTF-8 | 530 | 3.84375 | 4 | [] | no_license | =begin
https://launchschool.com/exercises/7c6be14d
Write your own version of zip that does the same type of operation. It should
take two Arrays as arguments, and return a new Array (the original Arrays should
not be changed). Do not use the built-in Array#zip method. You may assume that
both input arrays have the sam... | true |
7562535ef8c272874dcc0de84ea8ded4816771e9 | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w04/d02/Keyan_Bagheri/vertebratum/db/seeds.rb | UTF-8 | 1,592 | 2.578125 | 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 |
aa54813dea2727e1b8f1c3f9efd4b2bec36fd85a | Ruby | nmoutana/sr | /lib/sr/master.rb | UTF-8 | 10,122 | 2.578125 | 3 | [] | no_license | require "sr"
require "thread"
module Sr
module Master
def self.jobtracker
@jobtracker
end
def self.jobtracker=(jobtracker)
@jobtracker = jobtracker
end
# exceptions
class FailedToCreateCollectorException < Exception; end;
class FailedToCreateFetcherException < Exception; en... | true |
f553f8601626ae521d7ff207e58a636dbeae2c84 | Ruby | loustewart/Ruby_Expenses_Tracker | /controllers/category_controller.rb | UTF-8 | 970 | 2.515625 | 3 | [] | no_license | require( 'sinatra' )
require( 'sinatra/contrib/all' )
require( 'pry-byebug' )
require_relative('../models/category.rb')
require_relative('../models/merchant.rb')
require_relative('../models/transaction.rb')
# INDEX
get '/categories' do
@categories = Category.all()
erb(:"categories/index")
end
# CREATE
get '/cat... | true |
c54717960005b11484325f7ebc6d7a355b685116 | Ruby | TeamLe/Visualizeitor | /arquivos adicionais/crackXML/crackXML.rb | UTF-8 | 797 | 3.078125 | 3 | [] | no_license | gem 'crack' # in Gemfile
require 'crack'
# p = Crack::XML.parse("<tag>This is the contents</tag>")
# puts p
def read_file(file_name)
file = File.open(file_name, "r")
data = file.read
file.close
return data
end
xml_content = read_file 'alunos.xml'
parsed_xml = Crack::XML.parse(xml_content)
alunos_curso_root ... | true |
f0df029c3db4bf7f63bc6d6ce9ba5d41dd00405a | Ruby | pliantmeerkat/Battle | /lib/game.rb | UTF-8 | 2,011 | 3.609375 | 4 | [] | no_license | # game class
class Game
attr_accessor :attack_choice
attr_reader :players
attr_reader :current_turn
attr_reader :looser
attr_reader :winner
def self.create(player_1, player_2, damage, attack)
@game = Game.new(player_1, player_2, damage, attack)
end
def self.instance
@game
end
def initia... | true |
6ad0fd3527484a47872928787dcf0ce6bcccbc27 | Ruby | QnYosa/Exos-ruby | /exo_19.rb | UTF-8 | 228 | 2.859375 | 3 | [] | no_license | variation = 1
number = 1
my_array = []
while my_array.size <=49
if number %2 == 0
number = sprintf '%02d', variation
puts my_array << ["jean.dupont.#{number}@email.fr"]
variation = variation + 1
else
end
puts my_array | true |
f3db28c7ea5f4103ce7f86fc0e6e212f43bf1804 | Ruby | DawidGaleziewski/LocalUdemyRuby | /20_Object_methods_parameters.rb | UTF-8 | 486 | 3.765625 | 4 | [] | no_license | # input is called a ARGUMENT
# parameter is a placeholder name of excepted input/argument
p 20.between?(10, 30)
p 20.between?(30, 50)
p 1.2.between?(1.1, 1.3)
p -10.5.between?(-20, 0)
#float methods
p 10.9.to_i
puts "100.9".to_i
puts
p 10.5.floor #rounds number down to input
p 10.5.ceil #rounds up
p 3.14159.round # r... | true |
894dd917a9a7e008f6dc4c99a34f6df615bfed49 | Ruby | mhughes27/ruby-toy__first-non-repeated-letter | /lib/find_non_repeated_letter.rb | UTF-8 | 790 | 4.21875 | 4 | [] | no_license | # This method takes a string, str, and returns the first non-repeated letter in that string.
# More specifically, it looks for the first letter that appears by itself.
#
# + "ddcdd" has 'c' as its first non-repeated letter, and thus returns 'c'
# + "aabccd" has both 'b' and 'd' as non-repeating letters, but would retur... | true |
77abd720707785546c395f13a171ac2aef8c713b | Ruby | motapuma/estera | /app/models/service.rb | UTF-8 | 1,231 | 2.640625 | 3 | [] | no_license | class Service < ActiveRecord::Base
has_many :urls
def self.services_types_to_json
services = []
services << {"type"=>0,"name"=>"all"}
SERVICE_NAMES.each_with_index do |name,idx|
services << {"type"=>idx+1,"name"=>name}
end
return services.to_json
end
def self.json_per_type(type)
services =... | true |
c92248fd1aa7ba977bb393d8b8ef3e27f86d1c52 | Ruby | froot/advent_2019 | /day_6/p2.rb | UTF-8 | 1,407 | 3.796875 | 4 | [] | no_license | require 'pry'
class Node
attr_reader :value
attr_accessor :parent
attr_accessor :children
def initialize(value, parent=nil, children=[])
@value=value
@parent=parent
@children=children
end
end
input = File.read('input1.txt').chomp
orbits = input.split("\n").map { |n| n.split(")") }
# build tre... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.