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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8cf817e87dd90ca2f57d0564b68d8daa2ea8b292 | Ruby | cyberarm/cyberarm_engine | /lib/cyberarm_engine/opengl/perspective_camera.rb | UTF-8 | 1,258 | 2.609375 | 3 | [
"MIT"
] | permissive | module CyberarmEngine
class PerspectiveCamera
attr_accessor :position, :orientation, :aspect_ratio, :field_of_view,
:min_view_distance, :max_view_distance
def initialize(position:, aspect_ratio:, orientation: Vector.new(0, 0, 0),
field_of_view: 70.0, min_view_distance: 0.... | true |
82853383bdd57525b92fc1a68e71b14548b63917 | Ruby | sashafklein/ruby_euler | /02 - Even Fibonacci Numbers.rb | UTF-8 | 598 | 4.1875 | 4 | [] | no_license | # Each new term in the Fibonacci sequence is generated by adding the previous two terms.
# By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose values do not exceed four million,
# find the sum of the even-valued term... | true |
a90fa443423f8ee14a2926eae996eb1aa0065c93 | Ruby | gee2789/reverse-each-word-web-0217 | /reverse_each_word.rb | UTF-8 | 154 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence1)
string_array=sentence1.split
reverse = string_array.collect do |word|
word.reverse
end
reverse.join(" ")
end
| true |
602c4de54a89708469643e8711f4697d4f22f0c4 | Ruby | odarriba/webkit_remote | /lib/webkit_remote/rpc.rb | UTF-8 | 4,201 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'json'
require 'ws_sync_client'
module WebkitRemote
# RPC client for the Webkit remote debugging protocol.
class Rpc
# 2 minutes of waiting for RPC response
READ_TIMEOUT = 120
# Connects to the remote debugging server in a Webkit tab.
#
# @param [Hash] opts info on the tab to connect to
# @option... | true |
68d7e1009a47bfdbf9b641b932999407b7db6ca1 | Ruby | Soulou/DC-DM_Assignment | /lib/location_dao_client/dsl.rb | UTF-8 | 1,627 | 2.84375 | 3 | [] | no_license | module LocationDAOClient
$last_location = nil
def self.GETALL
locations = Location.all
locations.each do |l|
puts l.to_s + ","
end
end
def self.FINDBYNAME(pattern)
locations = Location.where name: /^#{pattern}/i
if locations.count > 0
locations.each do |l|
puts l.to_s +... | true |
055573069a41c2dcc2f083b40cf30633e8fe3d82 | Ruby | leonhartX/algorithm_test | /leet/leet1.rb | UTF-8 | 321 | 3.265625 | 3 | [] | no_license | # @param {Integer[]} nums
# @param {Integer} target
# @return {Integer[]}
def two_sum(nums, target)
hash = {}
nums.each_with_index { |e, i|
hash[e] = i + 1
}
p hash
nums.each_with_index { |e, i|
return [i + 1, hash[target - e]] if hash[target - e] && (hash[target - e] != i + 1)
}
en... | true |
3b3fbe987f0dd93d0a8281aa3d128144d38c5827 | Ruby | stephanmullerNL/sonic-pi | /utils/drum_machine.rb | UTF-8 | 2,767 | 3.09375 | 3 | [] | no_license | #Drum Machine
#Coded by Davids Fiddle
#https://raw.githubusercontent.com/DavidsFiddle/Sonic-Pi-Code-Bits/master/Drum%20Machine
#How to use:
#amp_x sets the volume of the piece, use 0 to turn the piece off
#also keep the values under 5 to avoid compression and clipping
#
#trigger_x is a ring that has 1 for 'hit' and 0... | true |
e103d58becc642322ac90ce9fc2249d52d795023 | Ruby | giorgimeladze/zoo-app | /app/models/animal.rb | UTF-8 | 721 | 2.671875 | 3 | [] | no_license | class Animal < ApplicationRecord
belongs_to :user
validates :specie, presence: true
validates :age, presence: true, numericality: {only_integer: true, greater_than: 0}
validates :color, presence: true
validates :sex, presence: true
validates :quantity, presence: true, numericality: {only_integer: true, grea... | true |
7ec4733e2163d4e19014f496584de535e68a7f26 | Ruby | tanya-h/Ruby-WS2015 | /Lösungen/Uebung2.rb | UTF-8 | 888 | 3.828125 | 4 | [] | no_license | #!/usr/bin/ruby
#1204701
#Aufgabe1
#ich bin einen Schritt weiter gegangen
#und lese aus einer Dateu
class Document
attr_reader :content
def initialize (filename)
file=open(filename)
@content=file.read
end
def case (token)
tokens=content.split(/[ \n;:\"'`.,?!]/).to_a
p tokens
res=Array.n... | true |
1d7ee60ff38a23470558b54b4df910ed51b40102 | Ruby | tomjmcnamee/dunder-mifflin-rails-review-nyc-web-080519 | /app/models/dog.rb | UTF-8 | 355 | 2.71875 | 3 | [] | no_license | class Dog < ApplicationRecord
has_many :employees
def self.order_by_count_of_humans(humans_arr)
output_arr = []
output_hash = Hash.new(0)
humans_arr.each { |human| output_hash[human.dog_id] += 1 }
sorted_arr = output_hash.sort_by { |k,v| v }.reverse.to_h.keys
sorted_arr.each { |dogid| output_arr << Dog.fi... | true |
73dea906f4910065c0982fad1495be52da1296dd | Ruby | medusa-project/ideals | /app/models/configuration.rb | UTF-8 | 2,057 | 2.859375 | 3 | [] | no_license | ##
# Singleton interface to the application configuration.
#
# Going back to its inception, Rails has offered a half dozen or more ways of
# supporting application-specific configuration. The application configuration
# system is designed with the following goals:
#
# 1. Consolidate configuration into as few files as p... | true |
444b5df7dfee6959f460381788157eafeb99618c | Ruby | pemacy/Launch_School | /Coursework/100/109/Exercises/Easy3/palindrome2.rb | UTF-8 | 265 | 3.234375 | 3 | [] | no_license | def palindrome?(str)
str = str.downcase.chars.keep_if{ |v| v =~ /a-z/ }.join('')
str == str.reverse
end
p palindrome?("Madam i'm adam")
# launch school answer
def real_palindrome?(string)
string = string.downcase.delete('^a-z0-9')
palindrome?(string)
end
| true |
912192ebd578771039124c6b88f715d4a874ddca | Ruby | alphagov/govuk-user-intent-survey-explorer | /app/helpers/application_helper.rb | UTF-8 | 1,887 | 2.578125 | 3 | [] | no_license | module ApplicationHelper
def format_datetime(datetime)
datetime.strftime("%d-%m-%y at %H:%M")
end
def map_mentions_data_to_chart(mentions_data)
mentions_data.each_with_object({}) { |(date, total_mentions), hash| hash[date.strftime("%-d %b %Y")] = total_mentions }
end
def total_mentions(mentions_data... | true |
d95ec4256f803ffa68be02dfba493a5d06f89aa6 | Ruby | bkerley/conway-20151005 | /spec/cell_spec.rb | UTF-8 | 988 | 2.953125 | 3 | [] | no_license | require_relative '../lib/cell'
describe Cell do
let(:coordinate){ Coordinate.new 0, 0 }
subject{ described_class.new coordinate, :alive }
it 'has a coordinate' do
expect(subject.coordinate).to eq coordinate
end
describe 'when alive' do
[0, 1, 4, 5, 6, 7, 8].each do |live_neighbors|
it "dies w... | true |
12178c31ea68f280ea83a1e27fc3bba996870902 | Ruby | rhomobile/rhodes | /spec/framework_spec/app/spec/language/fixtures/send.rb | UTF-8 | 1,948 | 2.734375 | 3 | [
"MIT"
] | permissive | module LangSendSpecs
module_function
def fooM0; 100 end
def fooM1(a); [a]; end
def fooM2(a,b); [a,b]; end
def fooM3(a,b,c); [a,b,c]; end
def fooM4(a,b,c,d); [a,b,c,d]; end
def fooM5(a,b,c,d,e); [a,b,c,d,e]; end
def fooM0O1(a=1); [a]; end
def fooM1O1(a,b=1); [a,b]; end
def fooM2O1(a,b,c=1); [a,b,c];... | true |
7deeb3453e19b02eb5f737018f3f2d96dc5ec2b2 | Ruby | aouji/asig | /test3.rb | UTF-8 | 149 | 3.09375 | 3 | [] | no_license | 100.times do |x|
x+=1
if x%3==0 and x%5==0
puts "FizzBuzz"
elsif x%3==0
puts "Fizz"
elsif x%5==0
puts "Buzz"
else
puts x
end
end
| true |
2d433a00882ae2093766670150793210fdd5fe2f | Ruby | osu-cascades/ecotone-web | /app/models/soil_sample.rb | UTF-8 | 1,920 | 2.5625 | 3 | [
"MIT"
] | permissive | class SoilSample < ApplicationRecord
enum collection_method: { # This is more future-proof. Don't use [:composite, :point].
composite: 2,
point: 4
}
belongs_to :plot
belongs_to :user
has_many :nutrients, dependent: :destroy
has_and_belongs_to_many :biodiversity_reports
has_many_attached :photo
... | true |
b31d3d5e14518c8db4709d97e657b4ec7a9da97b | Ruby | CountZachula/red-dress | /lib/red_dress/loophole.rb | UTF-8 | 1,667 | 2.53125 | 3 | [] | no_license | require 'json'
require 'net/http'
require 'zip'
module RedDress
class Loophole
attr_accessor(:routes, :node_pairs)
def get_routes
# Get response from sentinels.
uri = URI(RedDress::routes_uri)
uri.query = URI.encode_www_form({ passphrase: RedDress::passphrase, source: :loopholes })
r... | true |
e787a39341afa5ae4662e67e7c577cf52bb3234e | Ruby | realityforge/reality-generators | /lib/reality/generators/runner.rb | UTF-8 | 7,732 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under ... | true |
b1b197244f2f98afadd39749b7c49bfd29e8f8b7 | Ruby | courtneypersons/simple-math-online-web-prework | /lib/math.rb | UTF-8 | 396 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def addition(num1, num2)
return num1 + num2
end
def subtraction(num1, num2)
return num1 - num2
end
def division(num1, num2)
return num1 / num2
end
def multiplication(num1, num2)
return num1 * num2
end
def modulo(num1, num2)
return num1 % num2
end
def square_root(num)
return Math.sqrt(81)
end
def orde... | true |
ba8c07bd8b52e3fabdfff86df4d9d0e1c7cc2752 | Ruby | tsaith/voiceprint | /lib/voiceprint/fft.rb | UTF-8 | 977 | 2.515625 | 3 | [] | no_license | module Voiceprint
module FFT
class << self
include GSL::FFT
def fft(a)
n = a.length
data = a.to_gv.to_complex
table = ComplexWavetable.alloc(n)
space = ComplexWorkspace.alloc(n)
ffted = data.forward(table, space)/n
ffted.to_na
end
def iff... | true |
7a3701496385bf448a0f98264ce2b988cbd32625 | Ruby | 5l1v3r1/fortune | /lib/tasks/load.rake | UTF-8 | 1,582 | 2.578125 | 3 | [] | no_license | namespace :load do
task :latest do
rates = api.latest["rates"]
rates.each { |currency, price| Fortune::DailyRate.load_today(currency, price) }
rates.each { |currency, price| Fortune::HourlyRate.load(currency, price) }
end
task :currencies do
currencies = api.currencies
currencies.each { |symb... | true |
3aaa914e4dcb2065f7c7ac772b6f49dd947e1e6e | Ruby | RoxasShadow/Descartes | /lib/descartes/modules/google.rb | UTF-8 | 1,195 | 2.5625 | 3 | [] | no_license | ##
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBL... | true |
ca86accb715835b8880212c4da7fc86917ff2434 | Ruby | destro1234/ruby-collaborating-objects-lab-v-000 | /lib/song.rb | UTF-8 | 361 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist
def initialize(name)
@name= name
end
def self.new_by_filename(filename)
parts= filename.split(" - ")
song= Song.new(filename)
song.name= parts[1]
song.artist_name= parts[0]
song
end
def artist_name=(artist_name)
self.artist= Artist.find_or_create_by_name(artist... | true |
c81b646c85a7c7e168ead49749759b1bdfaef41f | Ruby | steven-james-rmr/bottega-portfolio | /db/seeds.rb | UTF-8 | 3,306 | 2.828125 | 3 | [] | no_license | User.create!(
email: "steven.james.dev@gmail.com",
password: "antlerbuyer1",
password_confirmation: "antlerbuyer1",
name: "Admin User",
roles: "site_admin"
)
puts "1 Admin User Created"
User.create!(
email: "test2@test.com",
password: "asdfghjkl",
password_confirmation: "asdfghjkl",
... | true |
fd7daf565ae9c4e22902e5e6d671f1d1cfa35b2f | Ruby | ryuawata/food-on-rails | /app/services/scrape_fitnesspal_service.rb | UTF-8 | 2,326 | 2.921875 | 3 | [] | no_license | require "open-uri"
require "nokogiri"
# require_relative "meal"
class ScrapeFitnesspalService
def initialize
@restaurants = ['Coco Ichibanya','Seven Eleven','McDonalds','Starbucks', 'Lawson', 'Yoshinoya', 'Sukiya', 'Mos Burger', 'Family Mart', "Denny's", 'Burger King', 'Freshness Burger' ]
end
def call
... | true |
a976c3edb52cf2e7ab286b8d8096dbde19a0d7b4 | Ruby | ebruning/ubiquitous-capsicum | /rtti_image_convert.rb | UTF-8 | 4,529 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#require 'rest_client'
require 'unirest'
require 'nokogiri'
require 'base64'
require 'optparse'
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; bold 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
def underline n; escape "4;#{n}" end
de... | true |
b2764b893a92a8a3ebd0c4b8e10115be1ebb79b0 | Ruby | rcm32000/denver_puplic_library | /test/author_test.rb | UTF-8 | 848 | 2.921875 | 3 | [] | no_license | require './test/test_helper'
require './lib/author'
class AuthorTest < Minitest::Test
def setup
@charlotte_bronte = Author.new({
first_name: 'Charlotte',
last_name: 'Bronte'
})
end
def test_it_exists
... | true |
e61eca96e4b0d3774dfdd7f97d4f1f51ecf9410a | Ruby | 00derp/msf3 | /scripts/meterpreter/multiscript.rb | UTF-8 | 1,949 | 2.890625 | 3 | [
"BSD-3-Clause"
] | permissive | #Meterpreter script for running multiple scripts on a Meterpreter Session
#Provided by Carlos Perez at carlos_perez[at]darkoperator[dot]com
#Verion: 0.2
################## Variable Declarations ##################
session = client
# Setting Argument
@@exec_opts = Rex::Parser::Arguments.new(
"-h" => [ false,"He... | true |
539244248b11a5095189c9e089ff55a492f92d55 | Ruby | mentalbastille/Advanced-Ruby-3-Day-Class | /Concurrency_and_MultiThreading/experiments/hello_world.rb | UTF-8 | 146 | 2.984375 | 3 | [] | no_license | thread_1 = Thread.new do
puts "Hello from Thread 1"
end
thread_2 = Thread.new do
puts "Hello from Thread 2"
end
thread_2.join
thread_1.join
| true |
62d6e72fb4b209c29ebec296eb120ab18fe07807 | Ruby | vincepaoloclemenia/stfbot | /app/views/api/work_experiences/new.json.jbuilder | UTF-8 | 608 | 2.703125 | 3 | [] | no_license | json.job_levels do |json|
json.array! @job_levels.each_with_index.to_a do |(job, index)|
json.label job
json.value index
end
end
json.job_functions do |json|
json.array! @job_functions.each_with_index.to_a do |(job, index)|
json.label job
json.value index
end
end
json.m... | true |
fcf471ad42af182f76e37a8e8d4e436dfa7cd480 | Ruby | mattSpell/cal | /lib/month.rb | UTF-8 | 1,698 | 3.765625 | 4 | [] | no_license | require_relative 'zellers_congruence'
class Month
MONTHS = [nil, "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"]
def initialize(month, year)
if month >= 13
puts "cal: #{month} must be between (1..12)"
exit
end
@m... | true |
36c63530c1ddb075c70e2a7c782ed257774e3b91 | Ruby | davidtadams/advent-of-code | /2020/day_17/part2.rb | UTF-8 | 1,642 | 3.578125 | 4 | [] | no_license | # frozen_string_literal: true
input = File.readlines('./input.txt', chomp: true)
.map(&:chars)
# [x,y,z,w]
NEIGHBORS = [1, 0, -1].repeated_permutation(4).to_a
NEIGHBORS.delete([0, 0, 0, 0])
CYCLES = 6
GRID_SIZE = 15
grid = {}
# initialize a NxNxN grid
(-GRID_SIZE..GRID_SIZE).each do |w_index|
(-GRID_S... | true |
f8aab8877853f2a6f240083ec9a497a4bd2f9ac2 | Ruby | holsky/ruby-prof | /test/platforms_csv_printer_test.rb | UTF-8 | 1,806 | 2.828125 | 3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path('../test_helper', __FILE__)
require 'rubygems'
require 'ruby-prof'
require 'stringio'
require 'csv'
class PlatformsCSVTestClass
def func1()
func2(1)
func3()
func2(0)
end
def func2(switch)
if switch == 1
func4()
else
1000.times do |i|
String.new("hello")
rand(i)
... | true |
e49d59a3ff0abd8ff4fccc1aef14c5ae33d69562 | Ruby | indigo-dc/rOCCI-core | /lib/occi/core/categories.rb | UTF-8 | 1,519 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | module Occi
module Core
class Categories < Set
include Occi::Helpers::Inspect
include Occi::Helpers::Comparators::Categories
attr_accessor :model
def initialize(categories=[])
categories.collect! { |category| convert category } if categories
super categories
end
... | true |
9f95b6e96fc08978484e4cd07a3ab24a2cf2332c | Ruby | jdickey/hanami-bench | /benchmarks/utils/hash_stringify.rb | UTF-8 | 142 | 2.5625 | 3 | [] | no_license | require 'lotus/utils/hash'
COUNT = 10_000
hash = Lotus::Utils::Hash.new a: 23, b: { c: ['x','y','z'] }
COUNT.times do
hash.stringify!
end
| true |
47a51221a3b8544d5b1443c43941cba3769cec14 | Ruby | mirnaio/chef-share | /db/seeds.rb | UTF-8 | 930 | 2.6875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'json'
require 'faker'
def getAllIngredients
i = 0
while i < 485 do
Ingredient.create!(name: Faker::Food.unique.ingredient)
i += 1
end
end
getAllIngredients()
# all_the_ingredients = Ingredient.create(hasher_turner_into(newArr))
# Us... | true |
ba1c7edd923bbd97a7feb04aced5a179e2cf57ba | Ruby | innervisions/small-problems | /09_easy_8/04.rb | UTF-8 | 355 | 3.765625 | 4 | [] | no_license | # 04 - All Substrings
def leading_substrings(str)
str.chars.map.with_index { |_, idx| str[0..idx] }
end
def substrings(str)
str.chars.map.with_index do |_, idx|
leading_substrings(str[idx..-1])
end.flatten
end
p substrings('abcde') == [
'a', 'ab', 'abc', 'abcd', 'abcde',
'b', 'bc', 'bcd', 'bcde',
'c',... | true |
44dffd5cd8f4349c47d392037926b327faeae914 | Ruby | javisoberon/Codea-fase-0 | /javi_prueba.rb | UTF-8 | 8,646 | 3.828125 | 4 | [] | no_license | # # Palabras y Plantillas de Tableros
# prueba1 = [["POEMA", "CANCION", "RONDAS", "RIMAS"],"POEMAXCXXXXAXXSXNXAAXCMXDXIXXNROXXOXNXXR"]
# prueba2 = [["MANGO", "SANDIA", "MELON", "PLATANO"],"XXXXPXXXXLXAMXAXIEXTXDLXAXNOXNMANGOXSXXX"]
# prueba3 = [["ROJO", "VERDE", "AZUL", "NEGRO"],"OJORXXXXXXXEXXOXDXRXXRGLXXEXUXNVXZXXXXA... | true |
8e7a5b118126338a9cb1b9dd93db03d649b857fd | Ruby | RickWayne/heartbeat | /SQLChecker.rb | UTF-8 | 2,775 | 2.578125 | 3 | [] | no_license | # Check SQL database for the desired stuff
require 'rubygems'
require 'bundler/setup'
require 'active_record'
DAY_SECONDS = 24*3600 # Wrong on DST transition days, but won't hurt
class AwonStation < ActiveRecord::Base
has_many :t411s
has_many :t412s
has_many :t403s
end
class T411 < ActiveRecord::Base
belong... | true |
3ddcece60d7f4986456a9be8131af30134025cce | Ruby | kperson/cluster-management | /app.rb | UTF-8 | 2,113 | 2.765625 | 3 | [] | no_license | require 'json'
require 'digest/md5'
class App
attr_accessor :app_id, :instances, :cluster, :cpus, :ram, :command, :app_type
def initialize(app_id, cluster, cpus = 1.0, ram = 512)
self.app_id = app_id
self.instances = instances
self.cluster = cluster
self.cpus = cpus
self.ram = ram
if self... | true |
30d81e99bc71d1f3bc0786c2cc85c09c116cbf2a | Ruby | jubianchi/gitlabhq | /lib/gitlab/visibility_level.rb | UTF-8 | 899 | 2.578125 | 3 | [
"MIT"
] | permissive | # Gitlab::VisibilityLevel module
#
# Define allowed public modes that can be used for
# GitLab projects to determine project public mode
#
module Gitlab
module VisibilityLevel
PRIVATE = 0 unless const_defined?(:PRIVATE)
INTERNAL = 10 unless const_defined?(:INTERNAL)
PUBLIC = 20 unless const_defined?(:P... | true |
a633190776ea147afc4edf0c7a4fdce1bab975a6 | Ruby | dalexj/sales_engine | /lib/sales_engine.rb | UTF-8 | 2,553 | 2.734375 | 3 | [] | no_license | require_relative 'merchant_repository'
require_relative 'invoice_repository'
require_relative 'item_repository'
require_relative 'invoice_item_repository'
require_relative 'customer_repository'
require_relative 'transaction_repository'
require_relative 'csv_reader'
class SalesEngine
attr_reader :merchant_repository,... | true |
450694d68b8f27f55e29abecf90aba55c99bd98e | Ruby | sergio-bobillier/tdd-ruby | /palindrome/runner.rb | UTF-8 | 156 | 3.3125 | 3 | [] | no_license | require_relative 'word'
test_word = 'Deed'
result = Word.palindrome? test_word
puts (result ? 'The word is a palindrome' : 'The word is not a palindrome')
| true |
529fda51f5e5b06cf5ef650c268468df8a2c3d33 | Ruby | budaigabor1428/CC-Day-3-PP | /my_functions.rb | UTF-8 | 401 | 3.046875 | 3 | [] | no_license | def add_array_lengths( citrus_fruits, berries )
return citrus_fruits.length + berries.length
end
def sum_array (numbers)
total = 0
for number in numbers
total += number
end
return total
end
def find_item( houses, actual_house )
for house in houses
if house == actual_house
return true
end
e... | true |
2b82cb09fa61f1205c7b36e08f1f21fe26516a1b | Ruby | IanMKesler/connect_four_TDD | /lib/main.rb | UTF-8 | 634 | 3.46875 | 3 | [] | no_license | require_relative 'game'
def round(game, sym)
column = game.get_move(sym)
while game.board.full?(column)
puts "The column is full, please choose another."
column = game.get_move(sym)
end
game.slide(column, sym)
end
def play
game = Game.new
puts "Welcome to Connect Four!"
tur... | true |
b7a5c2802443b26f5b24b3a7f43a97f80ddd765c | Ruby | dougsko/projecteuler.net | /429/solution.rb | UTF-8 | 666 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env ruby
#
# projecteuler.net
# problem 429
#
# A unitary divisor d of a number n is a divisor of n that has the
# property gcd(d, n/d) = 1.
# The unitary divisors of 4! = 24 are 1, 3, 8 and 24.
# The sum of their squares is 1^2 + 3^2 + 8^2 + 24^2 = 650.
#
# Let S(n) represent the sum of the squares of the u... | true |
3f7d53b17362a0e2dd9eb97d452cd21cd82fc6e4 | Ruby | rvedotrc/numbers | /spec/tree-transformer_spec.rb | UTF-8 | 1,592 | 2.78125 | 3 | [] | no_license | require 'numbers'
describe Numbers::TreeTransformer do
it "should transform a number" do
input = 7
actual = Numbers::TreeTransformer.transform(input)
expect(actual).to eq(7)
end
it "should transform addition" do
input = [ :+, 12, 3 ]
actual = Numbers::TreeTransformer.transform(input)
ex... | true |
c37b24b49892e52255be6a74edc8dc9b7ba3a19f | Ruby | WalterJaramillo/ejerciciosRuby | /POO/descriptoracceso.rb | UTF-8 | 363 | 3.484375 | 3 | [] | no_license | class Person
def initialize(name)
@name = name
end
def get_name
@name
end
end
p = Person.new("Walter")
puts p.get_name
#un metodo de instancia puede ser creado para acceder a las variables de instancia desde fuera del objeto
#Los metodos getter y setter son llamados descriptores de acc... | true |
0e9dbe8e19d62bb1e689ec91716e5a5256dcb4d7 | Ruby | sundarcodes/Hackerrank_solutions | /Sherlock_Squares.rb | UTF-8 | 678 | 3.671875 | 4 | [] | no_license | class SherlockSquares
def initialize(start,end_num)
@start=start
@end=end_num
end
def findSquares
start_int=Math.sqrt(@start).floor
end_int=Math.sqrt(@end).ceil
arr_squares_list = Array.new
for i in start_int..end_int
sq_num=i**2
if (sq_num >= @start && sq_num <= @end)
arr_squares_list << sq_n... | true |
7900e8366d6fceae1eb0867fe436b26a88484894 | Ruby | kanmaniselvan/shortest_knight_moves | /app/models/chess_board.rb | UTF-8 | 1,246 | 3.34375 | 3 | [] | no_license | class ChessBoard
attr_reader :knight_position
BOARD_SIZE = (1..8)
def initialize(knight_position)
@knight_position = knight_position
end
def self.find(board_id)
redis_conn.get(board_id)
end
def save
if ChessBoard.is_valid_position(knight_position)
ChessBoard.redis_conn.set(board_id, ... | true |
7cbf21ee886405ff1ea755f5f5acf89cdb9176af | Ruby | coalest-zz/launch_school | /exercises/watch_others_code/4_1.rb | UTF-8 | 2,192 | 4.21875 | 4 | [] | no_license | =begin
-----------------------INSTRUCTIONS--------------------------------------
Given 2 strings, your job is to find out if there is a substring that appears
in both strings. You will return true if you find a substring that appears
in both strings, or false if you do not. We only care about substrings that
are longer... | true |
52b38e73ebabbd513b0490181cdf0e0743c29926 | Ruby | Ourobor/RPNCalc | /commands.rb | UTF-8 | 1,647 | 3.765625 | 4 | [] | no_license | class CommandBuilder
def initialize(database)
@database = database
end
def buildCommand(command,lamb,numArgs)
args = []
for x in 0...numArgs
args << @database.getMain.pop
end
command = Command.new(lamb,args,command,@database)
return command
end
end
class Command
@exec = nil #Lambda that determine... | true |
1bccb83b541cb3ff8a69d92d0881574a6e4825b0 | Ruby | darkfeatherstsai/codewartrain | /train_code/get_the_middle.rb | UTF-8 | 449 | 3.734375 | 4 | [] | no_license | =begin
題目:回傳所給字串的中間的字,
如果字串長度是偶數就回傳中間兩個
後記:解答的 s[(s.size-1)/2..s.size/2]好多了
有想過但沒實際測試
字串也可以像陣列那樣操作s[index]
=end
def get_middle(s)
arr = s.split("")
ans = []
index = arr.size/2
if arr.size % 2 == 0
ans << arr[index-1]+arr[index]
else
ans << arr[index]
end
return ans.join
end
get_midd... | true |
af93c6ad54b15626872f8d64a64d86b4b60af959 | Ruby | garno/ec2 | /lib/ec2/helpers/string.rb | UTF-8 | 126 | 2.828125 | 3 | [
"MIT"
] | permissive | class String
# Camelize the string
def camel_case # {{{
self.split('_').map {|c| c.capitalize}.join
end # }}}
end
| true |
38b0f280ba4ac0365408dc1ea2f0e36364424844 | Ruby | CyberneticEntomologist/puppet | /spec/unit/util/profiler/logging_spec.rb | UTF-8 | 2,179 | 2.796875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
require 'puppet/util/profiler'
describe Puppet::Util::Profiler::Logging do
let(:logger) { SimpleLog.new }
let(:identifier) { "Profiling ID" }
let(:profiler) { TestLoggingProfiler.new(logger, identifier) }
it "returns the value of the profiled segment" do
retval = profiler.profile("Te... | true |
af6a115b5af379f89beefb00f9ea8bc62a61e865 | Ruby | ZoharLiran/technical_interview_questions | /bottles.rb | UTF-8 | 380 | 4.1875 | 4 | [] | no_license | # Define a recursive function that takes an argument n
#and prints "n bottles of beer on the wall",
#{}"(n-1) bottles of beer on the wall", ...,
#{}"no more bottles of beer on the wall".
def beer(n)
if n == 1
puts "last bottle on the wall"
puts "no more bottles of beer on the wall"
return
end
puts ... | true |
dba846736eff197fd50dd7b88c4a3e1564dc2e0f | Ruby | anlewis/rspec-exercises | /change_machine/lib/change_machine.rb | UTF-8 | 961 | 4.125 | 4 | [
"MIT"
] | permissive | class ChangeMachine
def cost(cents)
@cost = cents
end
def paid(cents)
@paid = cents
end
def change_maker(difference)
#takes difference and returns quarters, dimes, nickels and pennies
while difference != 0
if difference >= 25
quarter
difference -= 25
elsif differe... | true |
30af53542e769330104c3b123a1eea4af2a1a201 | Ruby | emmabeynon/takeaway-challenge | /lib/order.rb | UTF-8 | 739 | 3.609375 | 4 | [] | no_license | class Order
attr_reader :menu, :dishes, :quantity, :total
def initialize(menu_klass)
@menu = menu_klass
@dishes = []
@quantity = 0
end
def choose(dish, quantity=1)
fail "This is not on the menu" unless self.has_dish?(dish)
quantity.times do
menu.select { |k,v| dishes.push([k, v]) if ... | true |
2ff2c7e61eb21235ac65f8ef2063069ef66bf2af | Ruby | mexdevel/ruby | /learn_ruby/05_book_titles/book.rb | UTF-8 | 353 | 3.578125 | 4 | [] | no_license | class Book
attr_accessor :title
def title=(title)
bad = ['the', 'a', 'an', 'and', 'but', 'in', 'of',
'for', 'of', 'or']
@title = title.split(' ').map do |word|
bad.include?(word) ? word : word.capitalize
end
@title[0] = @title[0].capitalize
@tit... | true |
1d34827067a9789b9bbc0be344746eb9b78682ec | Ruby | williamsilvacastro/nivelamento-aluno | /07-exercicio.rb | UTF-8 | 487 | 3.84375 | 4 | [] | no_license | puts"Bem vindo ao jogo de adivinhação"
numero=rand(0..100)
puts "("+numero.to_s+")"
puts"digite seu chute:"
chute = gets.chomp
if chute.include?(".")
puts "valor com ponto flutuante"
puts "valor invalido"
elsif (chute!="0"&&chute.to_i==0)
puts "valor invalido"
elsif chute.to_i==numero
puts "voce acertou... | true |
7a88983016997b133642f096f4fd08de5ba109e3 | Ruby | cookpad/mixed_gauge | /spec/mixed_gauge/model_spec.rb | UTF-8 | 3,700 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe MixedGauge::Model do
let!(:model) do
Class.new(ActiveRecord::Base) do
def self.name
'User'
end
def self.generate_name
'xxx'
end
include MixedGauge::Model
use_cluster :user
def_distkey :email
before_put do |att... | true |
dd9df8c692289b98e7b465c48ebc25d372363e82 | Ruby | guillaumerose/codejam | /codejam/qualification-2009/C.rb | UTF-8 | 572 | 3.125 | 3 | [] | no_license | def gets
STDIN.gets.strip
end
def analyse(string, pattern)
todo = {
"" => 1
}
string.each_with_index { |letter, i|
possibilites = todo.keys.select { |e| pattern[e.size] == letter }
possibilites.map { |e| e + letter }.each { |k|
if todo.has_key?(k)
todo[k] = todo[k] + todo[k[0..-2]]
... | true |
82216ccbd6e9ca26695a9e8ac719efaafa33fb0d | Ruby | ibrahimmohelsayed/RubyTutorailHackerrank | /30DaysofCode/Day 7: Arrays.rb | UTF-8 | 214 | 2.90625 | 3 | [] | no_license | #!/bin/ruby
require 'json'
require 'stringio'
n = gets.to_i
arr = gets.rstrip.split(' ').map(&:to_i)
reverse = []
i = arr.length-1
arr.each do
reverse << arr[i]
i-=1
end
print reverse.map(&:inspect).join(' ') | true |
103571b79b2789d2258f1589929f901b5c0a5efa | Ruby | ErinReames/module-2-project | /app/models/pet.rb | UTF-8 | 1,263 | 2.65625 | 3 | [] | no_license | class Pet < ApplicationRecord
# ActiveRecord Relationships
has_many(:appointments)
has_many(:reviews)
belongs_to(:store)
has_many(:users, through: :appointments)
# Validations
validates(:name, :species, :breed, :age, :weight, presence: true)
validates(:species, inclusion: {in: ["Dog"]})... | true |
865f1b225475e9814920801d4c1df96c7305a663 | Ruby | wertermeira/localyze_rb | /spec/features/symmetric_difference_array_spec.rb | UTF-8 | 626 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe SymmetricDifferenceArray do
let(:challenge) { described_class.new(arr_n, arr_m).call }
describe '.call' do
context 'when result successed' do
let(:arr_n) { [1, 2, 3] }
let(:arr_m) { [3, 4] }
it { expect(challenge).to eq([1,... | true |
7edd83aaaede2eedf54354f0161528579dbb8721 | Ruby | rbrown3/rack-intro-dumbo-web-career-010719 | /application.rb | UTF-8 | 143 | 2.53125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Application
def call(env)
resp = Rack::Response.new
resp.write "Hello, my name is Rosanna."
resp.finish
end
end
| true |
c1f3b6cddeeb5096589433634af05f0bcfb3a1ff | Ruby | 256dog/Code | /AOJ/Volume0-3/Volume0/0039/roman_figure.rb | UTF-8 | 313 | 2.75 | 3 | [] | no_license | r = {"I" => 1,
"V" => 5,
"X" => 10,
"L" => 50,
"C" => 100,
"D" => 500,
"M" => 1000,
nil => 0}
ARGF.each do |line|
a = line.chomp.split('')
sum = 0
a.each_with_index do |c,i|
if r[c] < r[a[i+1]]
sum -= r[c]
else
sum += r[c]
end
end
puts sum
end
| true |
bea523083a472a49232fc9139b850284f8837134 | Ruby | fanjieqi/LeetCodeRuby | /1001-1100/1092. Shortest Common Supersequence.rb | UTF-8 | 1,188 | 3.359375 | 3 | [
"MIT"
] | permissive | # @param {String} str1
# @param {String} str2
# @return {String}
def shortest_common_supersequence(str1, str2)
l1, l2 = str1.size, str2.size
f, pre = [], []
(0..l1).each do |i|
f[i] ||= []
pre[i] ||= []
(0..l2).each do |j|
if str1[i] == str2[j]
if i > 0 && j > 0
f[i][j] = f[i-1... | true |
e97f9e50e7227c086290badb54f06e08099a01c4 | Ruby | ndshendage/hello_world | /app/assets/javascripts/javascript_methods_on_object.rb | UTF-8 | 481 | 3.546875 | 4 | [
"MIT"
] | permissive | # Array methods :
# declaration =
# var myArray = [];
# myArray.push("element"); # appends the element
# a = myArray.join(''); # will join this and assigns to the variable
# defining the object:
# var object = {
# name: "viru",
# age: 12,
# address: "here only"
# };
# get type of variable by .. typeOf na... | true |
6dc83952d8cbcbb2d145ce27923ecb4f7bf31423 | Ruby | KavitojSingh/cartoon-collections-web-1116 | /cartoon_collections.rb | UTF-8 | 696 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(array)
array.each_with_index { |name, index| puts "#{index + 1}. #{name}" }
end
def summon_captain_planet(array)
array.collect { |call| call.capitalize }
.collect { |call| call + "!" }
end
def long_planeteer_calls(array)
array.any? do |call|
call.length > 4
end
end
def find_the... | true |
9ef34e87df412ba7a3737c0a53e7ab0d812eb54a | Ruby | zencargo/monadt | /spec/monadt/monad_async_example.rb | UTF-8 | 492 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | require 'monadt'
module Monadt
class AsyncExample
class << self
def async1(x)
Fiber.new {
x + 1
}
end
def async2(y, z)
if (y > 0)
Fiber.new { z ** y }
else
Fiber.new { z - y }
end
end
def async_func(v)
M... | true |
64e81f26ecc9ca6fdfd78dc00a1a758f1dcfa2e6 | Ruby | elena-vi/learn_to_program | /ch12-new-classes-of-objects/birthday_helper.rb | UTF-8 | 652 | 3.640625 | 4 | [] | no_license | def findBirthday name
birthdays = Hash.new
births = File.open('births.txt').read
births.each_line do |line|
person = line.split(',')
person[2] = person[2].gsub!("\n", '')
birthdays[person[0]] = person[1] , person[2]
end
year = birthdays[name][1][1..birthdays[name][1].length]
month = birthdays[name][0][1..b... | true |
b89a17d2adfd8f0001eaeb08372b1d110245a084 | Ruby | rogeriobispo/account_api | /app/services/person_service.rb | UTF-8 | 1,448 | 2.71875 | 3 | [] | no_license | class PersonService
def initialize(person_param, update = false, client = nil)
@person_param = person_param
@update = update
@client = client
end
def call
if @update
update_person
else
create_person
end
end
private
def physical_person?
@person_param.include?(:cpf)
... | true |
c210387a9fd296ef5afc8a7b3a5a54e77a209a22 | Ruby | romanlarrosa/PDOO | /P5/QytetetRuby/pkg/QytetetRuby-0.0.1/lib/calle.rb | UTF-8 | 954 | 2.59375 | 3 | [] | no_license | # To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module ModeloQytetet
class Calle < Casilla
attr_accessor :titulo
def initialize(num,titulo_prop)
@titulo = titulo_prop
super(nu... | true |
75f145bd03fe9be3535b0d175ba66140f9ac1ec4 | Ruby | smart-rb/smart_types | /lib/smart_core/types/primitive/runtime_attributes_checker.rb | UTF-8 | 1,928 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# @api private
# @since 0.3.0
class SmartCore::Types::Primitive::RuntimeAttributesChecker
# @return [Proc]
#
# @api private
# @since 0.3.0
ATTRIBUTES_IS_NOT_ALLOWED_CHECKER = proc do |attrs|
attrs.empty? || raise(SmartCore::Types::RuntimeAttriburtesUnsupportedError, <<~ERROR... | true |
cc0fd559b71a251d3f7ed254c976d6eb07d23b17 | Ruby | tanvir002700/convert_unit | /lib/convert_unit/speed.rb | UTF-8 | 766 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'convert_unit/base'
require 'convert_unit/pre_process/speed/process'
module ConvertUnit
class Speed < Base
extend PreProcess::Speed
UNITS_SYMBOL = load_units_symbol
UNITS = load_available_units
CONVERSION_RATE = load_conversion_rate
attr_accessor :value, :unit
def initialize(value, ... | true |
a5200e67ef5f97c5937a1d2692bdee46905dc332 | Ruby | LatoTeam/lato_view | /app/helpers/lato_view/application_helper.rb | UTF-8 | 974 | 2.625 | 3 | [
"MIT"
] | permissive | module LatoView
# This module contain default lato_view application.
module ApplicationHelper
# This function render a cell set with params.
def view(*names)
# mantain compatibility with old cells (lato_view 1.0)
if names.length === 1
puts "YOU ARE USING AND OLD VERSION OF CELLS. PLEASE... | true |
7df7af5ba7a7e91e911c1dcfabccc2a21de2d6ee | Ruby | nathanpsouza/cep_aberto | /lib/cep_aberto/request.rb | UTF-8 | 842 | 2.6875 | 3 | [
"MIT"
] | permissive | require "net/http"
require "uri"
module CepAberto
class Request
def get_headers
{'Authorization': "Token token=#{CepAberto.configuration.token}"}
end
def get_endpoint
CepAberto.configuration.endpoint + "/api/" + CepAberto.configuration.version + "/ceps." + CepAberto.configuration.format.to_s... | true |
7c145c2599940a781b7bc0bf74d0ba130e028d3b | Ruby | laoling/DOSTHdaily | /2015/09/19/ex19.rb | UTF-8 | 1,025 | 4.15625 | 4 | [
"MIT"
] | permissive | =begin
name : ex18.rb
author : laoling
email : <838618014@qq.com>
------------------------------------
description:本实例我们演示的是ruby中
函数中参数的使用。
传递参数的方法:
1、直接传参
2、使用变量
3、使用数学运算
4、变量与数学运算混合使用
------------------------------------
=end
def cheese_and_crackers(cheese_count, boxes_of_crackers)
puts "You have #{cheese_count} c... | true |
9badfab25fbb46afd0228e7bb5f0239e6c76c31d | Ruby | CJHunter91/wk2_day4_pet_block_exercise | /pet_shop.rb | UTF-8 | 430 | 3.390625 | 3 | [] | no_license | require_relative('pet')
class PetShop
def initialize (input_pets)
@pets = input_pets
end
def pet_type(pet_name)
@pets.find{|pet| return pet.type if pet.name == pet_name}
end
def get_names_of_all_pets_of_type(type)
return @pets.map!{|pet| pet.name if pet.type == type}.compact
end
def get_n... | true |
93ebb1986ea785899cc5beba823886f5a415d871 | Ruby | prwhoeatsnonstop/standup_project4 | /app/models/board_search.rb | UTF-8 | 1,272 | 3.609375 | 4 | [] | no_license | class BoardSearch
attr_reader :date_from, :date_to
def initialize(params)
# the below code indicates that we're going to be adding items into the params
params ||= {}
# grabbing the params from date_from, the 7.days.ago is a Ruby method, taking the date 7 days ago from today's date
@date_from = par... | true |
dd0260781aa21f948acd0101be889c0243fcce15 | Ruby | Petitenelly/Projet-tests-ruby-190421 | /lib/06_pig_latin.rb | UTF-8 | 291 | 3.25 | 3 | [] | no_license | def translate(str)
words = str.split(" ")
words.each_with_index do |word, index|
if word.match(/^[aeiou]/i)
words[index] = word + "ay"
elsif word.match(/^(qu+|[^aeiou]+qu+|[^aeiou]+)(\w+)/i)
words[index] = $2 + $1 + "ay"
end
end
return words.join(" ").rstrip
end | true |
b15b652c99776710c7f0af8d8481622682754ae6 | Ruby | hieroglyphical/CSC-450-Project | /simulation/lib/game.rb | UTF-8 | 7,138 | 3.71875 | 4 | [] | no_license | =begin
This class simulates the game and generates a json file with the results to be anaylized
=end
class Game
attr_accessor :game_battlefield # get battlefields from each hero
attr_accessor :current_turn_number
attr_accessor :current_player # hero who's turn it is
attr_accessor :waiting_player
# Setup ... | true |
9000b21170887b684623d3f802c3fb27bedf80e2 | Ruby | bbuchalter/tictactoe_core | /test/tictactoe/game/query_state_test.rb | UTF-8 | 3,175 | 2.59375 | 3 | [] | no_license | require_relative '../../test_helper'
require 'tictactoe/game'
class GameQueryStateTest < Minitest::Test
def test_turn_count
game = new_game_with_players
assert_equal 0, game.turn_count
game.make_move(1, game.player_one)
assert_equal 1, game.turn_count
game.make_move(4, game.player_two)
asse... | true |
2f75875a2887151574d1e3c1b3f248dc4b32de59 | Ruby | TheJhyde/advent_2018 | /day7/elf.rb | UTF-8 | 294 | 3.015625 | 3 | [] | no_license | class Elf
attr_accessor :task
def tasked?
!task.nil?
end
def finished?
task.seconds <= 0
end
def reset
self.task.status = :finished
self.task = nil
end
def ==(a)
task.name == a.name
end
def set(t)
self.task = t
t.status = :assigned
end
end | true |
a88e26a5b4d0620d53d7697818590083715c9513 | Ruby | Peretus/follower_clash | /follower_clash.rb | UTF-8 | 752 | 2.953125 | 3 | [] | no_license | require 'rubygems'
require 'bundler/setup'
$LOAD_PATH << '.'
require "lib/user_comparer.rb"
user1 = UserComparer::User.new("caseymcneil")
user2 = UserComparer::User.new("techpeace")
puts "#{user1.username}'s follower count is: #{user1.followers}"
puts "#{user2.username}'s follower count is: #{user2.followers}"
my_co... | true |
2d329d0e034786a4a6b3337307c80caad2e8ff2d | Ruby | htaox/SearchWorks | /lib/holdings/requestable.rb | UTF-8 | 2,331 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | class Holdings
class Requestable
def initialize(callnumber)
@callnumber = callnumber
end
def requestable?
!location_level_request? && item_is_requestable?
end
def must_request?
requestable? && must_request_item? && !noncirc_library_and_inprocess?
end
private
def i... | true |
076dbba3b739a4bc9ec735b01c1c544548629249 | Ruby | sdadfagfdh/cos | /app/helpers/movies_helper.rb | UTF-8 | 411 | 2.546875 | 3 | [] | no_license | module MoviesHelper
# Checks if a number is odd:
def oddness(count)
count.odd? ? "odd" : "even"
end
def sortable(column,title=nil,css_id,checked)
title||=column.titleize
checks = Hash.new
checked.each{|c| checks[c]=1}
link_to title, {:sort=>column}.merge({"ratings"=>checks}),{:id=>css_id}
... | true |
43d0630178b7aaed217bf13e7081f6e313de3641 | Ruby | bdone2012/music_ir | /spec/note_queue_phrases_spec.rb | UTF-8 | 3,477 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
describe MusicIR::NoteQueue do
describe ".phrases" do
before(:each) do
@vector = $phrasing_vectors["Bring back my bonnie to me"]
@nq = @vector[:note_queue]
end
context "when the note queue is clearly phrased" do
it "returns a PhraseList" do
@nq.phrases.sho... | true |
4e2c63f761b7f7c329e02ae9d9b09f6b6e4dafda | Ruby | cduerkes/movie-db | /db/seeds.rb | UTF-8 | 1,911 | 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 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 |
ad4330360a7aa7edc65b341e5dcbd801f2bfd61f | Ruby | bstiber/launch_school_exercises | /hashes_2/easy3/6.rb | UTF-8 | 276 | 3.28125 | 3 | [] | no_license | # Back in the stone age (before CSS) we used spaces to align things on the screen. If we had a 40
# character wide table of Flintstone family members, how could we easily center that title above
# the table with spaces?
title = "Flintstone Family Members"
p title.center(40)
| true |
a054a90ad894f301e2348456d24e37109402c32a | Ruby | clairemariko/project_one_money_tracker | /specs/account_spec.rb | UTF-8 | 2,094 | 2.984375 | 3 | [] | no_license | require('minitest/autorun')
require_relative('../models/account.rb')
require_relative('../models/transaction.rb')
require_relative('../models/merchant.rb')
require_relative('../models/tag.rb')
class TestAccount < Minitest::Test
def setup
@tag1 = Tag.new ({
'name'=> "food",
'id'=> 1
... | true |
61365181b5165aef200fb99df173bf922c63e25c | Ruby | mchliakh/tic-tac-toe | /spec/tic_tac_toe_spec.rb | UTF-8 | 877 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module TicTacToe
describe TicTacToe do
it 'makes a move' do
expect(TicTacToe.move(1)[:board].compact.sort)
.to eq([0, 1])
end
it 'accepts string input for the square' do
expect(TicTacToe.move(' 1')[:board].compact.sort)
.to eq([0, 1])
end
it 'ma... | true |
53ce9b0a0e5981c20c992352ebcb6c66e1f5d9ed | Ruby | cha63506/llplanets-em-examples | /fiber.rb | UTF-8 | 445 | 2.75 | 3 | [] | no_license | require 'fiber'
require 'eventmachine'
require 'em-http-request'
def http_get(url)
f = Fiber.current
http = EventMachine::HttpRequest.new(url).get
http.callback { f.resume(http) }
http.errback { f.resume(http) }
Fiber.yield
end
EM.run do
EM.add_periodic_timer(0.1) {
print "."
}
Fiber.new {
... | true |
59c4c6831859b1b6a8e82351e45ce38a798dd802 | Ruby | NessInMorse/Learn_Morse_WordsTEXT | /Morse_game.rb | UTF-8 | 6,057 | 3.140625 | 3 | [
"MIT"
] | permissive | require "path/to/alle_woorden.rb"
include Words
require 'curses'
input=""
rawinput=""
rawtime=[]
c=0
time= [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
count= [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
line_c=0
inter_c=0
time0=0
time1=0
lettertimes=""
File.open("path/to/Letter_graph.txt","... | true |
a7576b306c393a764c6303157fa81aa837deb11a | Ruby | rahymov/sql-crowdfunding-lab-v-000 | /lib/sql_queries.rb | UTF-8 | 1,773 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
984a61de7cde0c5934d183f5ea53d68894bc965d | Ruby | riddopic/garcon | /files/lib/garcon/core_ext/pathname.rb | UTF-8 | 4,617 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
#
# Author: Stefano Harding <riddopic@gmail.com>
# License: Apache License, Version 2.0
# Copyright: (C) 2014-2015 Stefano Harding
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the ... | true |
5c6744993f0346dd3ef3e9a7243fc7aea2f94adc | Ruby | AmelieSK/oystercard_amy_ellen | /spec/journey_spec.rb | UTF-8 | 523 | 2.625 | 3 | [] | no_license | require './lib/journey.rb'
describe 'A journey' do
it 'has a start' do
# set up
station = test_double('station')
allow(station).to receive(:name) { 'Bank' }
journey = Journey.new
journey.start(station)
# verify
expect(journey.start_point).to eq 'Bank'
end
it 'has an end' do
# set... | true |
13a57395e29994ad74c8f91434c0d2eddfb5d519 | Ruby | suppy/CodeIQ | /CodeIQ-q1099/CodeIQ-q1099.rb | UTF-8 | 1,056 | 3.640625 | 4 | [] | no_license | # 増井技術士事務所 今週のアルゴリズムの@masuipeoさんからのアルゴリズムの問題
# 今週のお題:シャッフルして元通り
# https://codeiq.jp/ace/thisweek_masuipeo/q1099
# 処理開始時刻
t0 = Time.now
puts "処理開始時刻:#{t0}"
print "\n"
n_max = 100
# シャッフル
def shuffle(cards)
cards_next = []
(0...cards.length/2).each do |i|
cards_next << cards[i]
cards_nex... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.