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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cbadff4fb8bbbd0f622d3acf254f5b286bf16e8f | Ruby | itgsod-linus-alpsten/stuff-i-made-during-summer15 | /testing_project/test6.rb | UTF-8 | 288 | 3.421875 | 3 | [] | no_license | def hero_souls(floor,solomon)
if floor%100 == 0
return ((((floor-80)/25)**1.3)*(1+(0.05*solomon))).to_i
elsif floor%5 == 0
return (((((floor-80)/25)**1.3)*(1+(0.05*solomon))).to_i)/2
else
return 0
end
end
result = 0
for i in 100..650
result += hero_souls(i,20)
end
puts result | true |
79c942f55b3fd2e261ed14ee4d4418bec8562c63 | Ruby | UbuntuEvangelist/therubyracer | /vendor/cache/ruby/2.5.0/gems/liability-proof-0.0.9/lib/liability-proof/verifier.rb | UTF-8 | 1,603 | 2.765625 | 3 | [
"MIT"
] | permissive | module LiabilityProof
class Verifier
def initialize(options)
@root_path = options.delete(:root) || 'root.json'
@partial_tree_path = options.delete(:file)
end
def root_json
@root_json ||= JSON.parse File.read(@root_path)
end
def partial_tree_json
@partial_tree_json ||= JS... | true |
3f2bf3a527a356dd57dce92e77e29a0738e4750b | Ruby | kennyadsl/advent_of_code | /aoc/year2020/day1.rb | UTF-8 | 993 | 3 | 3 | [] | no_license | module AoC::Year2020::Day1
class Part1
def initialize(input = real_input)
@input = input
end
def solution
input.split.map(&:to_i).combination(combination_size).find { |x| x.sum == 2020 }.inject(&:*)
end
def combination_size
2
end
private
attr_reader :input
de... | true |
ee2097f734b0442d38bc38e142cd201471c044f5 | Ruby | rodrigotos/ruby_bootcamp | /lesson.rb | UTF-8 | 207 | 2.703125 | 3 | [] | no_license | class Lesson
attr_accessor :instructor, :subject
def initialize(params = {})
@instructor = params[:instructor] if params[:instructor]
@subject = params[:subject] if params[:subject]
end
end
| true |
87c65ce2c03bccfab4e424d9d74eb213e925193c | Ruby | DrRumpy/tealeaf | /intro_webdev_lesson_2/my_car_exercise_1.rb | UTF-8 | 571 | 4.125 | 4 | [] | no_license | class MyCar
def initialize(year, color, model)
@year = year
@color = color
@model = model
@speed = 0
end
def speed_up
@speed += 10
"You're going #{@speed} KM/h."
end
def brake
@speed -= 10
"You slow down by 10 KM/h."
end
def turn_off
@speed = 0
"You park the ca... | true |
5917b105b9a6b9b0846c53aa1fce88168d1e45f9 | Ruby | ville6000/EFP | /E6/retirement_calculator_spec.rb | UTF-8 | 770 | 3.03125 | 3 | [] | no_license | require_relative 'retirement_calculator'
RSpec.describe RetirementCalculator, '#years_till_retirement' do
it 'calculates years left' do
r = RetirementCalculator.new
expect(r.years_till_retirement(25, 65)).to eq(40)
end
it 'handles situation when user can already retire' do
r = RetirementCalculator.n... | true |
e182c4b0b6be91ca68c35c174821175e903731d1 | Ruby | nekokat/codewars | /8 kyu_1/grasshopper-personalized-message.rb | UTF-8 | 182 | 3.328125 | 3 | [
"Unlicense"
] | permissive | #Kata: Grasshopper - Personalized Message
#URL: https://www.codewars.com/kata/5772da22b89313a4d50012f7
def greet(name,owner)
name == owner ? "Hello boss" : "Hello guest"
end | true |
83655113087dcde904d00c83a5c5f5027ac88c32 | Ruby | learn-co-students/dc-web-012720 | /07-lyft-review/app/models/ride.rb | UTF-8 | 539 | 3.421875 | 3 | [] | no_license |
class Ride
attr_reader :passenger, :driver, :distance
@@all = []
def initialize(passenger:, driver:, distance:)
@passenger = passenger
@driver = driver
@distance = distance.to_f
@@all << self
end
def self.all
@@all
end
# should find the averag... | true |
d6c707d6c480ba6d29478413a53e807240e1d55c | Ruby | macbury/DotServer | /spec/game/player_spec.rb | UTF-8 | 812 | 2.578125 | 3 | [] | no_license | require "spec_helper"
describe Player do
it "should hash password" do
password = "abc"
Player.hash_password(password).should_not eq(password)
end
it "should create a new player" do
Player.delete_all
Player.count.should == 0
Player.register("user1", "password1")
Player.count.should == 1
... | true |
d5cb8c1a6dbc60f82b56839f62d15209d02a2b27 | Ruby | luke-schleicher/assignment_sinatra_basics | /rps/app.rb | UTF-8 | 803 | 2.8125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader' if development?
require 'erb'
require './rps_helper.rb'
helpers GameLogic
get "/" do
erb :game
end
post "/play" do
player_move = params[:selection]
bot_move = ["rock", "paper","scissors"].sample
outcome = determine_outcome(player_move, bot_move)
win_display =... | true |
9e83e4d01d229fd1957d27058c41b025637859df | Ruby | salhindi/my-each-onl01-seng-pt-072720 | /my_each.rb | UTF-8 | 90 | 3.0625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(tas)
i = 0
while i < tas.length
yield(tas[i])
i += 1
end
tas
end | true |
020b8936269974c6bc06f1c6aa2e68b08f380d47 | Ruby | munshkr/hatch | /test/common_validations_test.rb | UTF-8 | 609 | 2.59375 | 3 | [
"MIT"
] | permissive | require_relative 'support/helper'
require_relative '../lib/hatch'
class CommonStuff
include Hatch
attributes :present, :positive
certifies :present, :presence
certifies :positive, :positive_number
end
class CommonValidationsTest < Test::Unit::TestCase
def test_presence
common_stuff = CommonStuff.hatch... | true |
3c1e8f9c7ef1f17d0a21d53dbd05930b972cb258 | Ruby | KevinWornell/finstagram | /playground.rb | UTF-8 | 195 | 2.65625 | 3 | [] | no_license | def number(number)
if number is /3
"Fizz"
elsif number is /5
"Buzz"
elsif number is /3, /5
"FizzBuzz"
end
get '/' do
number = ()
end
| true |
9bf376a6d89df03e55bc14b81424275f989983dc | Ruby | yspoo/codekatas | /RemoveDuplicatesfromSortedArray.rb | UTF-8 | 2,175 | 4.3125 | 4 | [] | no_license | # Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.
# Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
def remove_duplicates(array)
array.uniq!.length
end
def remove_d... | true |
b1473d90e343e9fad4872c01113dd417ded1cfcd | Ruby | slacker2/daily-programmer-challenges | /12_18_13.rb | UTF-8 | 1,477 | 3.703125 | 4 | [] | no_license | # http://www.reddit.com/r/dailyprogrammer/comments/1t6dlf/121813_challenge_140_intermediate_adjacency_matrix/
# Shooting for readability and style convention
def main
args = get_input
directed_graph = create_directed_graph(args.fetch(:raw_edge_list))
display_adjacency_matrix(args.fetch(:num_nodes), directed_gra... | true |
da1a77318f6bb139118d55741e44289a65b27956 | Ruby | TownBeginner/RubyPractice | /advanced/looptest.rb | UTF-8 | 48 | 2.921875 | 3 | [] | no_license | i = 0
loop {
puts i
i += 1
break if i > 10
}
| true |
7a38dd332edda4e5cab9eb6672f9d48be7ae43e8 | Ruby | bavilari93/ruby | /Sponge.rb | UTF-8 | 708 | 3.75 | 4 | [] | no_license | # this methods adds an item to the array
spongebob_characters = ["Sandy Cheeks", "Mr. Krabs", "Plankton", "Mrs. Puff"]
spongebob_characters << "patrick Star"
# this method returns the common properties that both have in common
krusty_krab_employees = ["Spongebob Squarepants", "Patrick Star", "Squidward Tentacles"... | true |
d875d5078a48032a147a4fcc4cb18bfc0d2bea09 | Ruby | nnakagaki/code-eval | /moderate/flavious_josephus.rb | UTF-8 | 347 | 3.140625 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
line.chomp!
split = line.split(",")
arr = []
split[0].to_i.times do |i|
arr << i
end
ans = []
curr_pos = -1
move = split[1].to_i
loop do
curr_pos += move
curr_pos = curr_pos % arr.length
ans << arr.delete_at(curr_pos)
curr_pos -= 1
break if arr.length == 0
e... | true |
f65b160f1b50eefb3c9eaf0eaab39885b5431f75 | Ruby | bmshackelford/adios_naco | /lib/adios_naco/game.rb | UTF-8 | 1,862 | 2.625 | 3 | [] | no_license | module AdiosNaco
class Game
include DataMapper::Resource
property :id, Serial, :key => true
property :first_tick, EpochTime, :default => lambda{|r,p| Time.at(r.next_tick) }
property :version, String, :default => lambda{|r,p| AdiosNaco::VERSION }
property :player1, String... | true |
a79bfaf4783f3e6360f2752d854f2f9afe6960c7 | Ruby | jessereynolds/Frank | /frank.rb | UTF-8 | 4,809 | 2.609375 | 3 | [] | no_license | #!usr/bin/ruby
require 'rubygems'
require 'sinatra/base'
require 'active_record'
require 'logger'
require 'pony'
require 'erb'
require 'haml'
class Frank < Sinatra::Base
enable :sessions
set :root, File.dirname(__FILE__)
set :handlers, Proc.new { root && File.join(root, 'handlers') }
CURRENT_USER_KEY = 'A... | true |
110c85d954f6d79a47761a301f9b2e95b281a5a1 | Ruby | jonfriese/fizzbuzz_playgound | /fizzbuzz_extended_string_concatenation.rb | UTF-8 | 812 | 3.515625 | 4 | [] | no_license | example_hash = { 3 => "Fizz", 5 => "Buzz", 7 => "Sivv", 11 => "Bahhh" }
def fizz_buzz(n, hash, init = true, divisors = nil, answer = nil, words = nil, all_nums = nil)
if init == true
all_nums = []
answer = []
divisors = []
words = []
hash.each_key { |x| divisors << x }
1.upto(n) { |x| all_num... | true |
21319eadcc867edaa86260cb168ee3f541ff7251 | Ruby | abruzy/rest-client | /main.rb | UTF-8 | 356 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# !/usr/bin/env ruby
require_relative './bing_search'
url = 'https://bing.com'
search = BingSearch.new(url)
puts "Response code:#{search.response_code}"
puts '----'
puts 'Response cookies:'
puts search.cookies
puts '-----'
puts 'Response header:'
puts search.header
puts '-----'
put... | true |
1c0478cce56392a4a4ed9910ed83c0fa8be1ab7b | Ruby | aerohit/learningtocode | /ruby/wellgrounded/ch04/method_lookup.rb | UTF-8 | 407 | 3.171875 | 3 | [] | no_license | module M
def report
puts "'report' method in module M"
end
end
module N
def report
puts "'report' method in module N"
end
end
module MeFirst
def report
puts "'report' method in module MeFirst"
end
end
class C
prepend MeFirst
include M
include N
def report
puts "'report' method in ... | true |
f3967a4d821d2286ecab8a187ef46d5e1f9e1b22 | Ruby | apolloproductionsdj/note-app1 | /collatz_Sequence/lib/c_sequence.rb | UTF-8 | 600 | 3.75 | 4 | [] | no_license | def collatz_sequence(n)
array_sequence = []
until n == 1
n = n % 2 == 0 ? n/2 : n * 3 + 1
array_sequence.push(n)
end
return array_sequence
end
def longest_collatz
current_longest = 1
sequence_length = collatz_sequence(1).length
puts "begin checking collatz_sequence from 1-10"
1.upto(10) do |i|
... | true |
2d064b52566a55b410006853e21f0000f955d2c3 | Ruby | krile136/atcoder | /075/B-Minesweeper.rb | UTF-8 | 436 | 2.90625 | 3 | [] | no_license | h, w = gets.strip.split.map(&:to_i)
s = h.times.map { gets.strip.split('') }
(1..h).each do |i|
a = []
(1..w).each do |j|
if s[i-1][j-1] != "#"
bomb = 0
(i-1..i+1).each do |p|
(j-1..j+1).each do |q|
if 1<=p && p<=h && 1<=q && q<=w
bomb += 1 if s[p-1][q-1] == "#"
... | true |
f907dc2065477c93b24f66ecba56eae300204def | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/etl/2cd196b7fba24b8c84417054c3d556ee.rb | UTF-8 | 177 | 2.9375 | 3 | [] | no_license | class ETL
def self.transform hash
res = {}
hash.each do |key, values|
values.each {|value| res[value.downcase] = key }
end
res.sort.to_h
end
end
| true |
5e2b4cbf7cfc7e0cdbd835db96b77cf587015d3a | Ruby | tan-wyman/odin-project | /learn_ruby/08_book_titles/book.rb | UTF-8 | 1,545 | 3.515625 | 4 | [
"MIT"
] | permissive | class Book
attr_accessor :title
def initialize
@title = title
end
def title=(newTitle)
lowercaseWord = %w{a an the and or nor of over aboard about above across after against along amid among anti around as at before behind below beneath beside besides between beyond but by concerning consi... | true |
69f6606d85e96187986b83c4e5c912dce23738c4 | Ruby | subvisual/botler | /app/models/periodic_expense.rb | UTF-8 | 1,374 | 2.640625 | 3 | [] | no_license | class PeriodicExpense < ActiveRecord::Base
PERIODS = { 'weekly' => 1.week, 'monthly' => 1.month }
belongs_to :user
belongs_to :category
has_many :expenses
validates :description, :user, :amount, :period, :start_date, :category, presence: true
validates :period, inclusion: { in: PERIODS.keys }
validates ... | true |
48f993d3ec58dc5fe46579d1eb2413c92f3632f5 | Ruby | JiriKrizek/rkgpx | /test/testcommandline.rb | UTF-8 | 2,705 | 2.84375 | 3 | [] | no_license | require_relative "../lib/commandline"
require_relative "../lib/RkGpxLogger"
require "test/unit"
require "fileutils"
# Test command line arguments behaviour
class TestCommandLine < Test::Unit::TestCase
def setup
@log = RkGpxLogger.new("testlog.txt")
end
def teardown
Dir.rmdir("kk") if File.exists?("kk") ... | true |
ed2017dbb711c55bc8246c96664715c1ac1f37dd | Ruby | seanshahkarami/rpg-engine | /sprite-cache.rb | UTF-8 | 259 | 2.625 | 3 | [] | no_license | class SpriteCache
def initialize(engine)
@engine = engine
@cache = {}
end
def [](filename)
@cache[filename] = Sprite.new(@engine, "resource/sprite/" + filename) unless @cache.has_key?(filename)
return @cache[filename]
end
end
| true |
61bb9f6d7d8cf8be3bf3f0d3d1cb0dfa315e1185 | Ruby | handwerger/launch-school-repo | /chapter_6/6_5.rb | UTF-8 | 113 | 3.078125 | 3 | [] | no_license | string = "Welcome to America!"
a = string[6]
b = string[11]
c = string[19]
a is "e" b is "A" and 19 is nil. | true |
1fe6e91b762eed25a33aa6ba6429246fa7c71cc6 | Ruby | jay16/Note | /sina_emotions/analy.rb | UTF-8 | 1,143 | 2.625 | 3 | [] | no_license | #encoding: utf-8
require "open-uri"
require 'yaml/store'
def has_not(arr,item)
arr.each do |a|
return false if a == item
end
return true
end
yml = YAML.load_file("emotions.yml")
category = Array.new
yml.each do |y|
if y[1]["type"] == "face"
puts y[1]["category"]
category.push(y[1]["category"]) if has_not... | true |
1d732e461b255b19c58de47b597a62433294cefb | Ruby | scotrug/darts | /lib/darts/presenters.rb | UTF-8 | 897 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'darts/source_file'
module Darts
module Presenters
class Base
def initialize(options)
@options = options
end
private
def mappings
@mappings ||= option(:mappings)
end
def option(name)
options[name] || raise(ArgumentError, "#{name} is required... | true |
14f0a5a388766da0a8060d002e397d65d04c4edf | Ruby | chrislsavage/RubyCoderbtyeMedium | /RunLength.rb | UTF-8 | 286 | 3.171875 | 3 | [] | no_license | def RunLength(str)
str = str.split("")
i = 0
arr = []
count = 1
while i < str.length
if str[i] == str[i+1]
count += 1
end
if str[i] != str[i+1] || i == str.length - 1
arr << count
arr << str[i]
count = 1
end
i += 1
end
return arr.join("")
end
| true |
2cd151fb182482547174bf976de16c87be52e118 | Ruby | elankvitko/phase-0 | /week-6/guessing-game/my_solution.rb | UTF-8 | 3,367 | 4.4375 | 4 | [
"MIT"
] | permissive | # Build a simple guessing game
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: two inputs for two different methods. the initalize method contains the answer and the guess method contains the guess
# Output: the guess method should output a key accordin... | true |
501e875066ef6bfc6c4cc18cd5f13f67531a4183 | Ruby | voxmedia/omniauth_service | /test/omniauth_service/omniauth_service_test.rb | UTF-8 | 4,939 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative '../test_helper'
def create_omniauth
return {
'provider' => 'google_oauth2',
'uid' => '9895b74812e6496b',
'credentials' => {
'token' => '7173CFC6-E9A3-4CDD-8E29-1914D9E10ED8',
'secret' => '590D12EE-8813-45C6-897B-4D5B64CA2801'
},
'info' => {
'email' =... | true |
f5a3daf1a08ed4aac9d6c0b041c256ccf258b6dc | Ruby | DPennaman/country-states | /gemo.rb | UTF-8 | 478 | 2.84375 | 3 | [] | no_license | require 'countries'
require './report'
require './email'
puts "What country do you want a report on?"
country_name = gets.strip
country = ISO3166::Country.find_country_by_name(country_name)
if country
puts "The flag for #{country.name} is #{country.emoji_flag}"
Report.new(country).run
puts "Where should we ... | true |
4bf1369806dbe2902f339ebc422e157de9bdf317 | Ruby | jjmuradlr/array-CRUD-lab-ruby-apply-000 | /lib/array_crud.rb | UTF-8 | 988 | 3.96875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #create_an_empty_array
def create_an_empty_array
[]
end
#create_an_array
def create_an_array
a = ["I", "am", "really", "learning"]
end
#add_element_to_end_of_array
def add_element_to_end_of_array(array, element)
a = ["I", "am", "really", "learning"]
a << "arrays!"
end
def add_element_to_start_of_array(array,... | true |
d58cbdb0812a4ccea159a2b37af0fd8b7f212bd4 | Ruby | MkrtichSargsyan/TicTacToe-Ruby-Project- | /lib/board.rb | UTF-8 | 1,149 | 3.390625 | 3 | [
"MIT"
] | permissive | class Board
attr_reader :squares, :wining_combinations
def initialize
@squares = [
[{ '1': nil }, { '2': nil }, { '3': nil }],
[{ '4': nil }, { '5': nil }, { '6': nil }],
[{ '7': nil }, { '8': nil }, { '9': nil }]
]
@wining_combinations = [
[1, 2, 3], [4, 5, 6], [7, 8, 9],
... | true |
01788021d9be3f03f9cfd49fc0cda8b84a7d129a | Ruby | trizen/sidef | /scripts/Expensive/zebra_puzzle.sf | UTF-8 | 2,223 | 3.296875 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Zebra_puzzle
#
var CONTENT = Hash(
:House => nil,
:Nationality => [:English, :Swedish, :Danish, :Norwegian, :German],
:Colour => [:Red, :Green, :White, :Blue, :Yellow],
:Pet => [:Dog, :Birds, :Cats, :Ho... | true |
83ba295313446a604aefd3a7bf411478c37249da | Ruby | aleks279/ai-project1 | /lib/connect4/move_tree.rb | UTF-8 | 2,068 | 2.953125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'move_node.rb'
require_relative 'constants.rb'
class ConnectFourMoveTree
attr_accessor :root
attr_accessor :last_move
attr_accessor :player_to_move
def initialize
@player_to_move = ConnectFourConstants::PLAYER_ONE
end
def load_game(moves)
@root = ni... | true |
4900d38320df6d37a3cf16ec8b40cb99c09c2df7 | Ruby | PianoFF/js-rails-as-api-custom-json-rendering-using-rails-london-web-102819 | /app/controllers/birds_controller.rb | UTF-8 | 1,454 | 3.015625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class BirdsController < ApplicationController
def index
@birds = Bird.all
#👇to send the entire data set:
# render json: @birds
#👇 to send selected data with "only" option:
render json: @birds, only: [:id, :name, :species]
## == equivalent to:
# render json: @birds, except: [:created_at, :... | true |
bb8613265cc3aabd11415c418b1e325dbecf81be | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/119c904d7ebf438787d0dbc2b723a3e2.rb | UTF-8 | 154 | 3.3125 | 3 | [] | no_license | class Hamming
def self.compute(strand_1, strand_2)
strand_1.chars
.zip(strand_2.chars)
.count{ |v| v[0] != v[1] }
end
end
| true |
a9cab049639b9de5d3614cac39092b6998f619cc | Ruby | nakayamawataru/Yonemoto_teacher | /lib/places_api.rb | UTF-8 | 763 | 2.671875 | 3 | [] | no_license | class PlacesApi
def initialize(business, keyword = nil)
@parameters = {}
@parameters['location'] = "#{business.base_lat},#{business.base_long}"
@parameters['query'] = keyword if keyword.present?
@parameters['key'] = ENV['GOOGLE_PLACES_API_KEY']
end
def retrieve_ranking
base_url = 'https://map... | true |
a3acb6e29a73d59b4af59b89c5e00b131b22d15f | Ruby | romeuhcf/rb-Sisimai | /lib/sisimai/reason/hostunknown.rb | UTF-8 | 2,936 | 2.671875 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | module Sisimai
module Reason
# This is the error that a domain part ( Right hand side of @ sign ) of a
# recipient's email address does not exist. In many case, the domain part
# is misspelled, or the domain name has been expired.
# Sisimai will set "hostunknown" to the reason of email bounce if the v... | true |
df0f761f49ed32c5567458ef98877d015ef42776 | Ruby | aastronautss/trakt | /lib/trakt/list.rb | UTF-8 | 862 | 2.515625 | 3 | [
"MIT"
] | permissive | module Trakt
class List
include Connection
# TODO options should be the various options at some point
attr_accessor :slug, :add_info
def add(name,options={})
result = post 'lists/add/', options.merge(:name => name)
@slug = result['slug']
@add_info = result
return self
end
... | true |
4e2ebcbb3b2ebbb6207b8d7e99df2c71bc943c03 | Ruby | xautjzd/ARScripts | /knn.rb | UTF-8 | 1,296 | 3.4375 | 3 | [
"MIT"
] | permissive | ###########################################################
# Implement the KNN recognition method
# Usage:
# 1. pass the sample data to knn class
# 2. call nearest_neighbours to complete the recognition
# process.
#
# Refer: https://github.com/reddavis/knn
###########################################################... | true |
de5e02803fbce8cf248d2215c36c21737b9c1e23 | Ruby | rhomobile/rhodes | /res/build-tools/ruby-standalone/212/usr/local/lib/ruby/gems/2.1.0/gems/mime-types-2.3/lib/mime/types.rb | UTF-8 | 10,399 | 2.5625 | 3 | [
"Artistic-2.0",
"MIT",
"GPL-2.0-only",
"Artistic-1.0-Perl",
"GPL-1.0-or-later",
"LicenseRef-scancode-other-permissive",
"MPL-1.1",
"BSD-3-Clause"
] | permissive | # -*- ruby encoding: utf-8 -*-
require 'mime/type'
require 'mime/types/cache'
require 'mime/types/loader'
# MIME::Types is a registry of MIME types. It is both a class (created with
# MIME::Types.new) and a default registry (loaded automatically or through
# interactions with MIME::Types.[] and MIME::Types.type_for).... | true |
c4454f441abe5237e0b83104061476a9e926c10c | Ruby | LifebookerInc/api_resource | /spec/lib/typecasters/date_typecaster_spec.rb | UTF-8 | 1,663 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
describe ApiResource::Typecast::DateTypecaster do
let(:klass) { ApiResource::Typecast::DateTypecaster }
context ".from_api" do
it "should parse a date in iso format without Date._parse" do
Date.expects(:_parse).never
val = klass.from_api("2012-12-21")
val.year.should ... | true |
7ce65da5b13747e44396e10f7205971d892ce26f | Ruby | JDHofmann/programming-univbasics-nds-green-grocer-part-2-nyc01-seng-ft-082420 | /lib/grocer_part_2.rb | UTF-8 | 1,511 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative './part_1_solution.rb'
require 'pry'
def find_item_index_in_collection(name, collection)
index = 0
collection.each do |grocery_item|
return index if grocery_item[:item] === name
index += 1
end
nil
end
def apply_coupons(cart, coupons)
coupons.each do | coupon_i |
discounted_ite... | true |
adeb01c07e63c7dbd7e800b71761aa7299166cf3 | Ruby | ninchistudios/DrAppointment-BE | /app/models/appointment.rb | UTF-8 | 2,252 | 2.625 | 3 | [] | no_license | class Appointment < ApplicationRecord
validates :doctor, :time_slot, :user, presence: :true
validate :blocked?, :overlap?, :in_the_future?
belongs_to :doctor
belongs_to :time_slot
belongs_to :user
has_many :appointment_patients
has_many :patients, through: :appointment_patients
after_create :reminder... | true |
f893d52e1cbc4038ba7f47eb49f29238044ca7d2 | Ruby | jordanfox15/Phase-0 | /week-6/credit-card/my_solution.rb | UTF-8 | 3,003 | 4.3125 | 4 | [
"MIT"
] | permissive | # Class Warfare, Validate a Credit Card Number
# I worked on this challenge [with: David Louie].
# I spent [2] hours on this challenge.
# Pseudocode
# Input: 16 digit integer
# Output: True or False
# Steps:
=begin
check if its 16 digit, if not give argument error
convert int to string
iterate over ea... | true |
66151c9a664cf81ff3cab80f312bb8a59a1d6792 | Ruby | paploo/sliderule_tester | /lib/generator/basic/terms.rb | UTF-8 | 1,174 | 3.21875 | 3 | [
"BSD-3-Clause"
] | permissive | module Generator
module Basic
class Terms < Generator::Base
def self.title
return "Mult/Divide Complex Terms"
end
def self.description
return "Chains of multiplication and division."
end
def self.instructions
return <<-INST
Alternate divis... | true |
4b3b272a899e36471d057e72052e103252d903b0 | Ruby | jbmi2000/cartoon-collections-onl01-seng-pt-120819 | /cartoon_collections.rb | UTF-8 | 923 | 3.34375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | dwarfnames = []
def roll_call_dwarves(dwarfnames)# code an argument here
i=0
while i< dwarfnames.length
puts "#{i+1}. #{dwarfnames[i]}" #each_with_index do {|names, index| puts names}
i+=1
end #Your code here
end
planeteer_calls = ["earth", "wind", "fire", "water", "heart"]
def summon_captain_planet(planet... | true |
417c68ad60e4c657f90ddbff557bcc77a58be965 | Ruby | Khanitskiy/LibraryGem | /lib/files/library.rb | UTF-8 | 1,350 | 3.078125 | 3 | [
"MIT"
] | permissive | module LibraryGem
class Library
require_relative 'book'
require_relative 'order'
require_relative 'reader'
require_relative 'author'
require_relative 'initialization_data'
TOP_BOOKS = 3
attr_reader :data, :books, :orders, :readers, :authors
def initialize
@data = InitializationData.new
@book... | true |
0d86b7255e49afffffa2bd43b8187c3da4cd8393 | Ruby | mattbeedle/SalesFlip | /lib/data_mapper/will_paginate.rb | UTF-8 | 1,389 | 2.765625 | 3 | [] | no_license | module DataMapper
# This module defines API-compatible pagination methods with will_paginate.
# The advantage to this implementation is that it doesn't require loading the
# collection immediately, allowing DataMapper to strategically eager load
# paginated collections.
module WillPaginate
attr_accessor ... | true |
76e2abc02e0581b86e20ae0d23ed1775504ae3c6 | Ruby | postazure/temperature_spread | /lib/array_data_analysis.rb | UTF-8 | 698 | 3.828125 | 4 | [] | no_license | class ArrayDataAnalysis
def initialize temp_data
@temp_data = temp_data
end
def lowest_temperature
@temp_data.map {|temp| temp.last}.min
end
def highest_temperature
@temp_data.map {|temp| temp[1]}.max
end
def day_of_lowest_temperature
low_day = {}
@temp_data.each do |line|
low... | true |
f5c61c0cc0fa6983a63ff6eecbaa8fbe89682eb2 | Ruby | rahul2240/codechef | /lapindromes.rb | UTF-8 | 400 | 3.1875 | 3 | [] | no_license | gets.to_i.times do
a = gets.chomp.split("").map(&:to_s)
b = a.length
c = b/2
fin=0
if b%2==0
d = a.slice(0,c)
e = a.slice(c,b)
d = d.sort
e = e.sort
if d==e
fin = 1
end
else
d = a.slice(0,c)
e = a.slice(c+1,b)
d = d.sort
e = e.sort
if d==e
fin = ... | true |
6870d16eee0e454ee09afbe9090674c2e038e442 | Ruby | paul-palmer/bloxx | /lib/bloxx/base.rb | UTF-8 | 2,420 | 3 | 3 | [
"MIT"
] | permissive |
module Bloxx
def cast2raw(obj)
if ([RawText, ClickEvent, HoverEvent].any?{|c| c === obj})
obj
else
RawText.new.tap{|rt| rt << RawText.to_format(obj)}
end
end
class MCBase
def bits(v, bit_rng)
(v & mask(bit_rng)) >> bit_rng.first
end
def bitset(v, bit_rng, new_bits)
... | true |
1c77a817056de24586946f4562d625fd7c748b91 | Ruby | andree-surya/kotobyte-rails | /spec/lib/core_ext/string_spec.rb | UTF-8 | 1,031 | 2.9375 | 3 | [] | no_license | require 'rails_helper'
require 'core_ext/string'
describe String do
describe '#hiragana' do
it 'should replace "dzu" with "づ"' do
expect('hikitsudzuki'.hiragana).to eq('ひきつづき')
end
end
describe '#katakana' do
it 'should map Romaji string to Katakana' do
expect('sukauto'.katakana).to eq(... | true |
984f1edd1c877941fbec8e5a843e5683c7cc3b50 | Ruby | taleksei/parser | /helper.rb | UTF-8 | 274 | 2.734375 | 3 | [] | no_license | #!/bin/env ruby
# encoding: utf-8
module Helper
def save_array_in_file(file, array)
#File.open(file, 'w') do |f|
# array.each { |item| f << item }
#end
File.open(file, 'w') do |file|
array.each { |item| file << item.to_s + "\n" }
end
end
end | true |
749584a5142a1b5c6fa566c66199197c8d212458 | Ruby | bendelonlee/ActiveRecordExercises | /app/models/user.rb | UTF-8 | 460 | 2.546875 | 3 | [] | no_license | class User < ApplicationRecord
def self.from_google_auth(args)
find_or_create_by(google_uid: args['uid']) do |user|
user.name = args['info']['name']
user.email = args['info']['email']
end
end
def completions(exercise)
Completion.where(user: self, exercise: exercise)
end
def completed... | true |
f884666f7a858a11d5449eff4a3cfebb9a6d99a5 | Ruby | inbabbini/ttps_ruby_2015 | /Practicas/Practica2/bloques/e3.rb | UTF-8 | 983 | 3.875 | 4 | [] | no_license | # Implementar un metodo que reciva N parametros y un bloque, ejecute al
# bloque enviandole los N parametros y, dependiendo de lo que suceda,
# imprima y retorne:
# :ok => si la ejecucion fue exitosa
# 'Algo salio mal...' + :rt => si se produjo un RuntimeException
# 'No encontre un metodo: exeptionMessage' + :nm ... | true |
2fbef7fce33424bfc51082d7b24c185c05032b29 | Ruby | markhaskamp/word-wrap-kata | /spec/Wrapper.spec.rb | UTF-8 | 1,343 | 3.296875 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../app/Wrapper.rb'
describe "Wrapper" do
w = Wrapper.new
describe "#wrap" do
it "string less than max column, then returns string" do
w.wrap("foo", 80).should == "foo"
end
it "string longer than max, then splits the string at the max length" do
w.wrap... | true |
ff45684c9a046eb0fe7e5a9ca8ca8255b457556b | Ruby | GIML/gimlr | /test/test_gimlr.rb | UTF-8 | 2,926 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'gimlr'
class TestGimlr < Minitest::Unit::TestCase
def test_gimlr_parse_integer
expected = { 'num_var' => 12 }
assert_equal expected, Gimlr.parse_string(":num: num_var\n12")
end
def test_gimlr_parse_float
expected = { 'num_var' => 1.2 }
assert_equal expected, G... | true |
14ec0f688ba9a15354a4919a48daacdb429bb774 | Ruby | jtynerbryan/object-relations-assessment-web-062617 | /app/models/review.rb | UTF-8 | 313 | 2.953125 | 3 | [] | no_license | class Review
attr_accessor :customer, :restaurant, :content
@@all = []
def initialize(restaurant, content)
@restaurant = restaurant
@content = content
@@all << self
@restaurant.reviews << self
end
def self.all
@@all
end
def customer
@customer
end
def restaurant
@restaurant
end
end
| true |
67c53f5cf497474aec6eb77f0a75c37298511449 | Ruby | ali-mohammed200/tic-tac-toe-rb-bootcamp-prep-000 | /bin/tictactoe | UTF-8 | 629 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require_relative '../lib/tic_tac_toe'
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
puts "Welcome to Tic Tac Toe!"
display_board(board)
play(board)
#Once you get all the tests to pass, play your game!
#$ bin/tictactoe
#Feel proud. You can't imagine how far we've come already.
#Open up... | true |
ddbf67d5fa4eb83f47da1c152a1addfb85eeefba | Ruby | carolinsantoro/rails-simple-airbnb | /db/seeds.rb | UTF-8 | 2,002 | 2.59375 | 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
53e6799e112a6701e652925c94b4b354203e320b | Ruby | ZeroAuto/battleship_board | /main.rb | UTF-8 | 2,229 | 3.828125 | 4 | [] | no_license | class Board
def initialize(fleet)
@grid = []
@fleet = fleet
populate_grid
place_all_ships
end
# i think this fits with SOLID principles
# this single responsibilty of this class is to populate the board
def print_grid
@grid.each do |arr|
puts arr.join(" ")
end
end
private... | true |
d46e14b8400b9184403923cbc8458d775a54ff69 | Ruby | viiksilisko/launch_school | /RB101/exercises/easy_3/searching.rb | UTF-8 | 2,006 | 5 | 5 | [] | no_license | =begin
Problem:
Inputs:
- 6 integers
Outputs:
- the last integer given
- first 5 given integers in an Array
- A string describing the output
The program asks the user to input 6 integers.
It then checks if the 6th integer is already present in the first 5 integers,
and di... | true |
c2ce6ebf0e9ba42c8e93d1a3fb2f1556ab581859 | Ruby | guduan/Tutorials | /ruby/ZetCode/Ruby Tutorial/14-input_and_output/nochomp.rb | UTF-8 | 102 | 3.46875 | 3 | [] | no_license | #!/usr/bin/env ruby
print "Enter a string: "
inp = gets
puts "The string has #{inp.size} characters"
| true |
d32694dc4cb0cbf1676cf92f1329c5ef1411deb3 | Ruby | pasberth/Rells | /lib/bells/core_ext/enumerable.rb | UTF-8 | 59 | 2.5625 | 3 | [] | no_license | module Enumerable
def itself
each { |a| a }
end
end | true |
9540f8d1946ef32c7cffde6492fa46cf0a8ae153 | Ruby | sriddbs/intercom | /lib/distance_finder.rb | UTF-8 | 1,505 | 3.5 | 4 | [] | no_license | class DistanceFinder
attr_accessor :start_gps_point, :range
def initialize(options)
@start_gps_point = options[:gps_coordinates]
@range = options[:range_in_kms]
@radius = 6371 # radius of earth
end
def is_in_range?(end_gps_point)
raise ArgumentError, 'Invalid GPS point' unless gps_valid?(end_g... | true |
ac009b9e19bd72b8c66660e5eee6bede7d3fe8af | Ruby | bopes/algo-practice | /counting-elements/permutation-check.rb | UTF-8 | 488 | 3.640625 | 4 | [] | no_license | # Given a non-zero array of positive integers, determine if the array contains a permutation. Time complexity should be O(N).
def solution(a)
counts, perm = Hash.new, true
for i in 1..a.length do
counts[i] = 0
end
a.each do |elem|
if elem > a.length
perm = false
break
end
count... | true |
87ec60293b333d178eaca530a3257ee74ccd3532 | Ruby | cielavenir/procon | /atcoder/codefestival/tyama_atcodercodethanksfestival2014aD.rb | UTF-8 | 235 | 2.84375 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
def solve(a,b,s,t)
if b<s || t<a
t-s
elsif a<=s && t<=b
0
elsif a<=s
t-b
elsif t<=b
a-s
else
t-s-(b-a)
end
end
n,q=gets.split.map(&:to_i)
q.times{
a,b,s,t=gets.split.map(&:to_i)
p solve(a,b,s,t)*100
} | true |
aba5776aec5262d1340767167d3e0cb885ce3476 | Ruby | Ari-Adaleg/learn_ruby | /learn_ruby/class_creation.rb | UTF-8 | 2,460 | 3.828125 | 4 | [] | no_license | class Animal
def initialize(animal, height, weight)
@animal = animal
@height = height
@weight = weight
end
def getAnimal
return @animal
end
def getHeight
return @height
end
def getWeight
return @weight
end
end
puts "What type of animal do you like?"
animal_input = gets.chomp
puts "How tall is ... | true |
8301544c8fb34a57b4845c08925c8de15ec11472 | Ruby | bumbot/ruby-oo-complex-objects-putting-the-pieces-together-dc-web-012720 | /lib/book.rb | UTF-8 | 663 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Book
#attribute accessors --> give us both getter and setters for each one respectively.
#attribute readers --> give us ONLY getters (readers) for free
#
attr_accessor :author, :page_count, :genre
attr_reader :title
#initalize our Book class
def initialize(title)
@title = titl... | true |
b7573318c55d5cf50f4b679b93327ba5ddc8e437 | Ruby | Springest/activerecord-postgres-springest | /spec/integration_spec.rb | UTF-8 | 4,813 | 2.671875 | 3 | [
"ISC"
] | permissive | require 'spec_helper'
describe Article do
describe ".create" do
it "builds valid arrays" do
article = Article.create(:languages => ["English", "German"], :author_ids => [1,2,3], ip: '192.168.0.100')
article.reload
article.languages_before_type_cast.should == "{English,German}"
article.lan... | true |
d7f7612d0fe65a6e1683d3f150663a5a71aff422 | Ruby | DFE-Digital/apply-for-teacher-training | /app/models/recruitment_cycle.rb | UTF-8 | 1,186 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module RecruitmentCycle
def self.cycle_string(year)
cycle = cycle_strings.fetch(year.to_s)
current_year.to_s == year.to_s ? "#{cycle} - current" : cycle
end
def self.cycle_strings(upto = current_year)
2020.upto(upto.to_i).index_with do |year|
"#{year - 1} to #{year}"
end.stringify_keys
en... | true |
131bb161e8389ed9c355fe6afa574d8020202168 | Ruby | JurgensSmit/github_score | /app/models/github_user.rb | UTF-8 | 1,036 | 2.875 | 3 | [] | no_license | class GithubUser
attr_reader :avatar_url, :total_score, :data, :username, :language, :name,
:project_name, :project_date, :project_url
def initialize(username)
@username = username
initialize_data
initialize_total_score
parse(username)
end
private
def pars... | true |
7b07701e510d4bae8fdcc00c21ce81c0f5f0e7d6 | Ruby | SCIRPO/cinephil | /db/seeds.rb | UTF-8 | 2,507 | 2.828125 | 3 | [] | no_license | require 'faker'
require 'open-uri'
require 'json'
puts 'Destroying everything'
Serie.destroy_all
Season.destroy_all
Episode.destroy_all
User.destroy_all
puts 'Everything destroyed'
puts 'Creating users...'
5.times do
user = User.new(
username: Faker::FunnyName.name,
email: Faker::Internet.email,
p... | true |
351341f5653bbf8a46acec3c71ef38c34b0311df | Ruby | Malik42/RubyTHP | /exo_01.rb | UTF-8 | 51 | 3.09375 | 3 | [] | no_license | # Exercice : Bonjour monde
puts "Bonjour, monde !" | true |
ace9467245c41804ee38d633aae27e18e6d99c90 | Ruby | agstrohmeier/PrepWork | /IntroductionToRuby/the basics/BasicsExercises.rb | UTF-8 | 70 | 3.09375 | 3 | [] | no_license | movies = [1975, 2004, 2013, 2001, 1981]
puts movies[0]
puts movies[1]
| true |
be3207863bdb62fb61145cdd13ff2118c8b69b6f | Ruby | filip373/design-patterns | /16_mediator/authentication_app.rb | UTF-8 | 363 | 2.625 | 3 | [] | no_license | require_relative "./authentication_mediator"
authentication_mediator = AuthenticationMediator.new
authentication_mediator.log_in("johny", "secret123")
puts
begin
authentication_mediator.log_in(nil, "secret1234")
rescue StandardError => e
puts e
puts
end
begin
authentication_mediator.log_in("johny", nil)
resc... | true |
0df187fb748bac4124eb06517c920cf46a767365 | Ruby | saramic/learning | /rspec-anti-patterns/spec/too_many_lets_spec.rb | UTF-8 | 508 | 3.40625 | 3 | [
"Unlicense"
] | permissive | class TooManyLets
def self.array1to10
(1..10).to_a
end
end
RSpec.describe TooManyLets do
let(:one) { 1 }
let(:two) { 2 }
let(:three) { 3 }
let(:four) { 4 }
let(:five) { 5 }
let(:six) { 6 }
let(:seven) { 7 }
let(:eight) { 8 }
let(:nine) { 9 }
let(:ten) { 10 }
it "creates a range from 1..1... | true |
379f0a8e3114ffe93c130534f998d1ff06d8af35 | Ruby | xuchunyang/hello-ruby | /sed.rb | UTF-8 | 583 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Usage: sed 's/foo/bar/g' [file]
raw_pattern, file = ARGV[0], ARGV[1]
# Check arguments
unless raw_pattern
puts "Usage: #{$0} PATTERN FILE"
exit 1
end
regexp_c, to_string = raw_pattern.split('/')[1, 2]
unless regexp_c && to_string
puts "Unknown pattern '#{raw_pattern}'"
exit 1
end
reg... | true |
e681d8a048284af5fae0b9e86e872d4e0d9db064 | Ruby | nickedwards109/music-learning-api | /spec/helpers.rb | UTF-8 | 687 | 2.515625 | 3 | [] | no_license | module SpecHelper
class << self
# Input: a User instance
# Output: a JSON web token identifying the user as an authenticated user
def generate_token(user)
key = Rails.application.credentials.secret_key_base
header = Base64.urlsafe_encode64("{\"alg\":\"HS256\"}")
payload = Base64.urlsafe_... | true |
0254ad9d14f1d33d18783089bf1fa063645f1d3d | Ruby | rkoopmanschap/online_evolution | /neural_allele_target.rb | UTF-8 | 1,143 | 3.375 | 3 | [] | no_license | # neural gene that determines attack target selection
class NeuralAlleleTarget
attr_reader :dominance, :normalized_speed_multiplier, :normalized_attack_multiplier, :normalized_nutrition_multiplier
def initialize(dominance)
@speed_multiplier = rand(200).to_f / 100
@attack_multiplier = rand(200).to_f / 100
... | true |
ac2703c70c7db7dbc070f02ee744cb4da00437c4 | Ruby | cowgod/gunsmithbot | /lib/gunsmith/bot.rb | UTF-8 | 2,900 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require 'singleton'
require 'pp'
module Gunsmith
# The core class representing the bot's main interface
class Bot
BOT_GITHUB_URL = 'https://github.com/cowgod/gunsmithbot'
include Singleton
def query_slot(requested_slot)
results = {}
results[:bucket_id] = B... | true |
287172ce1f555addd52209eecdf8bdc10a2c54b7 | Ruby | sanctuarycomputer/echowings | /app/models/twitter_user.rb | UTF-8 | 949 | 2.609375 | 3 | [
"MIT"
] | permissive | class TwitterUser < ApplicationRecord
has_many :tweets
enum overall_sentiment: {
neutral: 0,
negative: 1,
positive: 2
}
def update_overall_sentiment_and_probability
self.overall_sentiment = tweets.map(&:sentiment).group_by{|i| i}.max{|x,y| x[1].length <=> y[1].length}[0].to_sym
self.overal... | true |
26c5ff14562bb5d4ec406641d909a6b1a4e14876 | Ruby | svoboda-jan/opal | /stdlib/json.rb | UTF-8 | 2,167 | 3.484375 | 3 | [
"MIT"
] | permissive | `var json_parse = JSON.parse, __hasOwn = Object.prototype.hasOwnProperty`
module JSON
def self.parse(source)
`return to_opal(json_parse(source));`
end
# Raw js object => opal object
def self.from_object(js_object)
`return to_opal(js_object)`
end
%x{
function to_opal(value) {
switch (typ... | true |
4e9d861a8606d7f476ecb6c55f411c31ed8ced20 | Ruby | Aerilius/OnScreen-GUI | /src/OnScreen/DrawCache.rb | UTF-8 | 2,718 | 2.5625 | 3 | [] | no_license | #-------------------------------------------------------------------------------
#
# Thomas Thomassen
# thomas[at]thomthom[dot]net
#
#-------------------------------------------------------------------------------
module AE::GUI3::OnScreen
# Caches drawing instructions so complex calculations for generating the
... | true |
0ce65eaa9242b23728a39ff47f53dfe546a8107a | Ruby | willjsporter/codewars | /test.rb | UTF-8 | 75 | 2.9375 | 3 | [] | no_license | require 'prime'
m=0; n=10
asdf=Prime.take_while{|p| p>=m&&p<=n}
p asdf[1]
| true |
a5870374877c6390a6b9b49193fecd057d4f5402 | Ruby | PhilippePerret/FeaTest | /lib/module/sheets/featest_sheets.rb | UTF-8 | 1,701 | 2.703125 | 3 | [] | no_license | # encoding: utf-8
=begin
Module principal de test qui contient les données des feuilles
de featest.
=end
module FeaTestModule
class FeaTestSheet
class << self
# Toutes les "steps", les étapes ou les sections du site ou de l'application
# Elles sont récoltées dans les sheets .ftest
#
... | true |
cf054239bc1e9b959346e44df8cbe8fbb7674521 | Ruby | N0nki/jruby_lifegame | /jruby_mainPanel.rb | UTF-8 | 3,689 | 2.859375 | 3 | [] | no_license | #!/usr/local/bin/jruby
# coding: utf-8
include Java
import java.lang.System
import javax.swing.JFrame
import javax.swing.JPanel
import javax.swing.JButton
import java.awt.Component
import java.awt.Color
import java.awt.Container
import java.awt.Dimension
import java.awt.Image
import java.awt.Graphics
import java.awt.... | true |
a187f1aa0b539574694b984a041453d34fc0d8ce | Ruby | l-jdavies/launch_school | /backend/RB101_RB109/lesson_2/mortgage_calculator.rb | UTF-8 | 4,284 | 4.09375 | 4 | [] | no_license | # Take everything you've learned so far and build a mortgage calculator
# (or car payment calculator -- it's the same thing).
# You'll need three pieces of information:
# the loan amount
# the Annual Percentage Rate (APR)
# the loan duration
# From the above, you'll need to calculate the following two things:
# mon... | true |
c572f54ee0633ae86fbc05b285e354a5bf645526 | Ruby | brunoocasali/battle-of-langs | /cli-apps/morse-code/morse_code.rb | UTF-8 | 961 | 4.0625 | 4 | [
"MIT"
] | permissive | # To run just execute:
# ~$ ruby morse_code.rb
# author: http://github.com/brunoocasali - twitter: @brunoocasali
# http://brunocasali.wordpress.com
class MorseCode
attr_reader :plain_text, :morse_code
def initialize(plain_text = 'Hello World')
@morse_code = @plain_text = plain_text.downcase
end
def co... | true |
c5cb0c38dc0e012dadb5396e848d6a6b84603539 | Ruby | danherrera0/key-for-min-value-prework | /key_for_min.rb | UTF-8 | 397 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
if name_hash=={}
puts nil
elsif
name_hash.each do |key, value|
if value[0]<value[1] && value[0]<value[2]
puts key[1]
if value[1]<value[0] && value[1]<value[2]... | true |
14ecc5df2e81fe8396a7eb8729a8ac773fe50cae | Ruby | ana310/OnlineShop | /db/seeds.rb | UTF-8 | 560 | 2.515625 | 3 | [] | no_license | # Channel.create(name: "Home")
# Channel.create(name: "Electronics")
# Channel.create(name: "Fashion")
# for i in 1..3
# c = Channel.find(i)
# for j in 1..5
# c.products.create(name: "Product ##{j} of channel ##{i}", description: "A product.", active: "Wat")
# end
# end
p = Product.all
# p.each do |product... | true |
25cd8c0252f1ee131d22af2832b275e6498cbf37 | Ruby | janpadrta/obsys | /app/models/order.rb | UTF-8 | 1,030 | 2.546875 | 3 | [] | no_license | # == Schema Information
#
# Table name: orders
#
# id :integer not null, primary key
# branch_id :integer not null
# delivery_date :date
# state :integer default(1), not null
# created_at :datetime not null
# updated_at :datetime not null
#
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.