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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b580850509bf6a719b6045c198ae0d2f424f4f5c | Ruby | maximefriess/Emerald | /app/writers/csv_parser.rb | UTF-8 | 1,457 | 3.0625 | 3 | [] | no_license | require 'csv'
class CsvParser
def initialize(filepath)
@raw_parsed = []
csv_options = { headers: :first_row }
CSV.foreach(filepath, csv_options) do |row|
if row['Accomodation Rev']
revenue = row['Accomodation Rev'].gsub(/[ €]/, '').to_f
else
revenue = row['Accomodation Rev']
... | true |
55fa0c2364cf1713f0ed650a65c3f295dd19c750 | Ruby | wardymate/codewars-kata | /statistics_algorithm_calculate_mean/lib/meaner.rb | UTF-8 | 127 | 3.03125 | 3 | [] | no_license | class Meaner
def calc_mean(input)
return 0 if input.length == 0
input.map{|e|e.to_f}.inject(:+)/input.size
end
end | true |
560be44aeb6942baa42025f13717380c6994ac18 | Ruby | watkajtys/weatherBot | /mattBot.rb | UTF-8 | 1,640 | 3.265625 | 3 | [] | no_license | require_relative "weather"
require 'socket'
class Bot
attr_accessor :server, :msg
def initialize
@current_reporter = WeatherReporter.new
@forecast_reporter = WeatherReporter.new
@temp_reporter = WeatherReporter.new
@server = 'chat.freenode.net' #in runner
@port = '6667'
@nick = 'BetterWeatherBot'
@cha... | true |
0ae5b6aef28557a20ca2b36cb835f53a40aa3bf2 | Ruby | jamillosantos/tfprog2012.1 | /lib/geasy/lib/geasy/numeric.rb | UTF-8 | 110 | 3.53125 | 4 | [] | no_license |
class Numeric
def radians
self / 180.0 * Math::PI
end
def degrees
(self / Math::PI) * 180.0
end
end | true |
244989d433ee5cb1dbc9ba0c8a000c8a9c6efc41 | Ruby | thePegasusai/theme-check | /test/parsing_helpers_test.rb | UTF-8 | 1,037 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
class ParsingHelpersTest < Minitest::Test
include ThemeCheck::ParsingHelpers
def test_outside_of_strings
chunks = []
outside_of_strings("1'\"2'3\"4\"") { |chunk| chunks << chunk }
assert_equal(["1", "3"], chunks)
end
def test_outside_of_strings_... | true |
c261e9cbfd8f54d25b594a4c6d6acb2a3e84e73e | Ruby | jduckett/duck_test | /test/unit/platforms/listener_test.rb | UTF-8 | 17,081 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # this set of tests was causing all types of problems, because, it is writing to files.
# need to refactor how it should be simulating a file being changed
#require 'test_helper'
#require 'digest/sha1'
#class ClientObject
#def listener_event(event)
#return "triggered"
#end
#end
#class ListenerTestObject
#in... | true |
29002024138c2ff805400581512cb24c31238b44 | Ruby | hoshinotsuyoshi/euler | /lib/euler045.rb | UTF-8 | 623 | 3.453125 | 3 | [] | no_license | # coding: utf-8
class Euler045
@pentas = { 1 => 1 }
class << self
# 五角数のみメモ化する
# 配列よりハッシュのほうが早い
def pentas(x)
@pentas[x] || (@pentas[x] = ((x * (3 * x - 1)) / 2).to_i)
end
def hexas(x)
x * (2 * x - 1)
end
def penta?(x)
while x > @pentas[@pentas.keys.max]
@tmp ... | true |
d3fbc04ed3a217d5b4cc1b1158e6f3822ecb5e2f | Ruby | codeAligned/aa-prep-work | /pre-course/01-ruby_monk/00-ruby_primer/143-palindrome.rb | UTF-8 | 525 | 4.3125 | 4 | [] | no_license | # Problem Statement
# Given a sentence, return true if the sentence is a palindrome.
#
# You are supposed to write a method palindrome? to accomplish this task.
#
# Note Ignore whitespace and cases of characters.
#
# Example:
# Given "Never odd or even" the method should return true
#
# https://rubymonk.com/learning/bo... | true |
62200f740c9623e5e0fcbd4eeb3d1e24ece02285 | Ruby | DTF919/ttt-10-current-player-ruby-intro-000 | /lib/current_player.rb | UTF-8 | 276 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
counter = 0
board.each {|position| counter += 1 if position != " "}
return counter
end
def current_player(board)
counter = 0
board.each{|position| counter += 1 if position != " "}
x_or_o = counter % 2 == 0 ? "X" : "O"
return x_or_o
end
| true |
a21541738825cb1c66baf84819050cd0e1589601 | Ruby | robertmarsal/moodle | /test/test_client.rb | UTF-8 | 1,113 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'moodle/client'
class ClientTest < Test::Unit::TestCase
# Test initialization with hash
def test_initialize_with_hash
client = Moodle::Client.new({
:username => 'test_username',
:password => 'test_password',
:domain => 'test_domain',
:protocol => 'test_pr... | true |
fefcdfba23652d2383a470a8e5d9aa8b1f415631 | Ruby | hadleynet/quality-measure-engine | /lib/qme/map/map_reduce_executor.rb | UTF-8 | 6,051 | 2.59375 | 3 | [] | no_license | module QME
module MapReduce
# Computes the value of quality measures based on the current set of patient
# records in the database
class Executor
include DatabaseAccess
# Create a new Executor for a specific measure, effective date and patient population.
# @param [String] measure_id... | true |
44b154603cc1298fae79b395337723e26ba77167 | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/octokit-4.22.0/lib/octokit/organization.rb | UTF-8 | 408 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | module Octokit
# GitHub organization class to generate API path urls
class Organization
# Get the api path for an organization
#
# @param org [String, Integer] GitHub organization login or id
# @return [String] Organization Api path
def self.path org
case org
when String
"org... | true |
c758a32e0cb73b45816eb1850291f11e4fce27e7 | Ruby | marceltheshell/algorithm_practice | /quicksort.rb | UTF-8 | 529 | 3.359375 | 3 | [] | no_license | def quicksort(arr)
def divide(left, right, arr)
#base case
if right<=left
return
end
#recursive case
pivot = right
wall = left
for curr in left..right-1
if arr[curr] < arr[pivot]
arr[curr], arr[wall] = arr[wall], arr[curr]
wall += 1
end
end
... | true |
00bca19555064b8acefb535c24f52a5822766f8d | Ruby | nanokana/first_app | /hello_module.rb | UTF-8 | 429 | 3.6875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
module HelloModule #module文
Version = "1.0" #定義の定義
def hello(name) #メソッドの定義
puts "Hello, #{name}."
end
module_function :hello #helloをモジュール関数として公開する
end
p HelloModule::Version #=> "1.0"
HelloModule.hello("Alice") #=> Hello,Alice.
include HelloModule # インクルードしてみる
p Version #=> "1.0"
... | true |
b0f5237a1860783b413f93d141fa8bdf98f588b1 | Ruby | mdudzinski/sugarcube | /lib/cocoa/sugarcube-nscoder/nscoder.rb | UTF-8 | 1,371 | 3.0625 | 3 | [
"BSD-2-Clause"
] | permissive | # Hash-like access for NSCoder. Converts the `key` argument to a String,
# because Symbols can mess things up.
class NSCoder
def [] key
self.decodeObjectForKey(key.to_s)
end
def []= key, value
self.encodeObject(value, forKey: key.to_s)
end
def key?(key)
self.containsValueForKey(key.to_s)
end... | true |
d570acfb4130bad9b42593f19713271dba1bfbb9 | Ruby | mdub/wikiwah | /lib/wikiwah/subst.rb | UTF-8 | 995 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
module WikiWah
# Subst handles text-transformation using a series of regular-expression
# substitutions. It encapsulates a number of "patterns", and associated
# blocks. Each block is invoked with a MatchData object when it's
# associated pattern matches, and is expected to return a repl... | true |
ae0f9aa0661412e8fc0ea0c5fda0f7703dfed71b | Ruby | markmccanna1/Mars-Rover | /spec/grid_spec.rb | UTF-8 | 431 | 2.78125 | 3 | [] | no_license | require 'grid'
describe 'Grid' do
let(:north) { Direction.new("N", 0, 1) }
let(:south) { Direction.new("S", 0, -1) }
let(:grid) { Grid.new( {size: [5, 5], directions: [north, south] } ) }
describe '#size' do
it 'has a size' do
expect( grid.size ).to eq [5, 5]
end
end
describe '#find_dire... | true |
4b0c2674cff84d7d40e7dcacc0d2a4ca2f1e8d33 | Ruby | reynoldscem/AdventOfCode | /Day03/2.rb | UTF-8 | 793 | 3.390625 | 3 | [] | no_license | #!/usr/bin/ruby
begin
input = File.open(ARGV[0]).read
rescue
puts 'Valid input file from AdventOfCode required as first argument.'
else
robo_turn = false
grid = {}
grid[[0, 0]] = 2
Indices = Struct.new(:row_ind, :col_ind)
santa = Indices.new(0, 0)
robo_santa = Indices.new(0, 0)
input.split('').each d... | true |
e6cc0ba93d9adc0d2e2eb0ed0f1d98485dcb6ae0 | Ruby | omotenko/ruby_app | /spec/cart_spec.rb | UTF-8 | 700 | 2.5625 | 3 | [] | no_license | require "rspec"
require_relative "..\\app\\item"
require_relative "..\\app\\antique_item"
require_relative "..\\app\\virtual_item"
require_relative "..\\app\\item_container"
require_relative "..\\app\\cart"
describe Cart do
describe "managing items" do
it "add items into cart" do
cart = Cart.new("Oleg"... | true |
7211b787da03ab33f973132c6cc55c87eebf64a0 | Ruby | Matt-Weiss/market_1901 | /lib/market.rb | UTF-8 | 1,203 | 3.59375 | 4 | [] | no_license | class Market
attr_reader :name, :vendors
def initialize(name)
@name = name
@vendors = []
end
def add_vendor(vendor)
@vendors << vendor
end
def vendor_names
vendors.collect do |vendor|
vendor.name
end
end
def vendors_that_sell(item)
vendors.select do |vendor|
vendo... | true |
2967622e95e5d416e9755d37a09d4aa9b07e0ed2 | Ruby | MrPowers/battleship | /main.rb | UTF-8 | 1,020 | 3.8125 | 4 | [] | no_license | require_relative "ship.rb"
require_relative "battleship.rb"
require_relative "board.rb"
class Main
def go
board = Board.new
battleship = Battleship.new
ships = []
game_ships = [["Aircraft carrier", 5]]#, ["Battleship", 4], ["Submarine", 3], ["Destroyer", 3], ["Patrol Boat", 2]]
game_ships.each do |ship, siz... | true |
e48c690bd635591a5f0d16090cf167b1a8c192c8 | Ruby | jay-menorca/ruby_fundamentals1 | /exercise3.rb | UTF-8 | 321 | 3.734375 | 4 | [] | no_license | #Exercise 3 : Jay Menorca
class FriendlyGuyImpl
@@buddyName = "buddy"
def askName
puts "What's your name?"
@@buddyName = gets.chomp
end
def greetBack
puts "hi there #@@buddyName!"
end
regularGuy = FriendlyGuyImpl.new
# regularGuy = new.FriendlyGuyImpl("buddy")
regularGuy.askName
regularGuy.greetBack... | true |
bfa349f34a75b9364448e2b1dc85affc0f20e5c2 | Ruby | andrewarrow/chibrary.com | /spec/service/call_number_service_spec.rb | UTF-8 | 3,326 | 2.640625 | 3 | [] | no_license | require_relative '../rspec'
require_relative '../../service/call_number_service'
module Chibrary
describe CallNumberService do
def spec_cns
CallNumberService.new CNSTestRunIdService.new, CNSTestSequenceIdService.new
end
describe "#next!" do
# only sends queries + commands to self, nothing to test
end... | true |
81ade6e6c00c4bfa0dc9063648c1d72a9d64111b | Ruby | Dennis-Kluge/InstantAmbient | /AmbientConnector/lib/AmbientConnector.rb | UTF-8 | 2,571 | 2.6875 | 3 | [] | no_license | require "AmbientConnector/version"
require "java"
require "jar/bluecove-2.1.1.jar"
require "json"
require "socket"
require "optparse"
module AmbientConnector
import "javax.bluetooth.UUID"
import "javax.bluetooth.RemoteDevice"
import "javax.microedition.io.StreamConnectionNotifier"
import "javax.microedition.io.C... | true |
00ddfe662359324317ee085eef8935b5fd1f591a | Ruby | hunterbmiller/advent-of-code | /day1/solution.rb | UTF-8 | 461 | 3.5625 | 4 | [] | no_license | def calculate_fuel(mass)
(mass / 3.0).floor - 2
end
def fuel_sum(mass)
fuel = calculate_fuel(mass)
return 0 unless fuel.positive?
fuel + fuel_sum(fuel)
end
def part1(masses)
masses.inject(0) { |sum, mass| sum + calculate_fuel(mass.to_i) }
end
def part2(masses)
masses.inject(0) { |sum, mass| sum + fuel_s... | true |
73dc379cd9f7b96a0b9acad31edfda5fe2503da8 | Ruby | Tricktionary/Shop-GraphQL-API | /app/graphql/resolvers/create_product.rb | UTF-8 | 1,350 | 2.75 | 3 | [] | no_license | class Resolvers::CreateProduct < GraphQL::Function
description "Create a product record in the database\n
ARGUMENTS \n\n
- title(required): An ID that represents the cart we want to add products to \n
- price(required): An ID for the product that you would like to be added to the cart \n
- quantity(required)... | true |
1d3a432470351975a433f4850b9189a7ab025c98 | Ruby | jeffmjwong/Notelist-app | /notes-folder/testing.rb | UTF-8 | 302 | 2.71875 | 3 | [] | no_license | require 'test/unit'
def add_gst(amount)
amount + (amount*0.1) # => pass
end
def add_vat(amount)
amount + (amount*0.1) # => fail
end
class OurTest < Test::Unit::TestCase
def test_add_gst
assert_equal(220, add_gst(200))
end
def test_add_vat
assert_equal(115, add_vat(100))
end
end
| true |
8dbc0f7afc7d92488623a213284561ae9eccfe01 | Ruby | kosmaks/rumouse | /lib/rumouse/x11.rb | UTF-8 | 2,487 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'ffi'
module X11
extend FFI::Library
ffi_lib 'X11'
attach_function :XOpenDisplay, [ :char ], :pointer
attach_function :XWarpPointer, [ :pointer, :ulong, :ulong, :int, :int, :uint, :uint, :int, :int ], :int
attach_function :XFlush, [:pointer], :int
attach_function :XCloseDisplay, [:pointer], :int
... | true |
a68a5b0ef539e43fce6a8dbb763acbfaaf54111c | Ruby | vladiangelov/crawley-volley | /app/models/player.rb | UTF-8 | 721 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
# Class for a player
class Player < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
validates :team, presence: true
validates :position, presence: true
validates :shirt_number, presence: true
def full_name
"#{first_name} #{last... | true |
574657f264b8f4d1592794a132aeb9e3d2f3c690 | Ruby | studentinsights/studentinsights | /app/models/student_voice_completed_survey.rb | UTF-8 | 2,449 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | # A survey that a student completed.
class StudentVoiceCompletedSurvey < ApplicationRecord
belongs_to :student
belongs_to :student_voice_survey_upload
validates :student, presence: true
validates :student_voice_survey_upload, presence: true
validates :form_timestamp, presence: true
# added 9/6/2018
def ... | true |
7b59dfc8988a4f29e319dcea7a2caee4e44194ee | Ruby | roberthead/head_music | /lib/head_music/style/guidelines/avoid_overlapping_voices.rb | UTF-8 | 1,346 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Module for style guidelines.
module HeadMusic::Style::Guidelines; end
# A counterpoint guideline
class HeadMusic::Style::Guidelines::AvoidOverlappingVoices < HeadMusic::Style::Annotation
MESSAGE = "Avoid overlapping voices. Maintain the high-low relationship between voices even for a... | true |
567f4946ef1fe72c8798e4451b17dcc3c1ac3011 | Ruby | georges-2000/pyramide | /pyramide.rb | UTF-8 | 397 | 3.609375 | 4 | [] | no_license | puts 'Bon donc tu veux construire une pyramide ? de combien d\'étages ?'
print '> '
nbFloor = gets.chomp.to_i
if nbFloor.to_i <= 1
puts "C'est pas une pyramide ça !"
if 1.is_a? Integer
puts "Et fait on te demande le nombre d\'étages"
end
else
nbFloor.downto(1) do |suite|
(suite - 1).times do
print ' '
e... | true |
ad3f5940a5496f2a4ae89f9322fee104b7cb089b | Ruby | Geek24/ruby_practice | /strings.rb | UTF-8 | 1,298 | 4.15625 | 4 | [] | no_license | full_name = "Chris Edwards"
first_name = "Chris"
last_name = "Edwards"
puts "#{full_name}"
# How many vowels?
puts "Vowels: " + full_name.count("aeiou").to_s
puts "Consonants: " + full_name.count("^aeiou").to_s
puts full_name.start_with?("Edwards")
puts "Index: " + full_name.index("Edwards").to_s
# Does it equal?
p... | true |
0bbb523e5ee508b046aff5ef40934a5052be697c | Ruby | niquepa/crackingcode | /Others/mergeSort.rb | UTF-8 | 919 | 4.0625 | 4 | [] | no_license |
def merge(left, right)
# puts "merge: left:#{left} right:#{right}"
arr = []
while(left.length > 0 && right.length > 0)
if left[0] < right[0]
arr.push(left.shift)
else
arr.push(right.shift)
end
end
# puts "****** arr: #{arr} left:#{left} right:#{right}"
arr.concat(left) if left.leng... | true |
382b5d838b200c75998ae6ac98434d86d4cd5d7c | Ruby | jgendrano/blackjack | /spec/lib/blackjack_spec.rb | UTF-8 | 3,868 | 3.640625 | 4 | [] | no_license | require "pry"
require_relative '../../lib/blackjack'
require_relative '../../lib/deck'
require_relative '../../lib/card'
require_relative '../../lib/hand'
describe Deck do
let(:deck) { Deck.new }
describe "#build_deck" do
it "builds a deck of 52 cards" do
expect(deck.cards.size).to eq 52
end
end
... | true |
a4fe32b8aeb712f1ab9735541535822c5fce29f1 | Ruby | steviepinero/Homework | /votersim.rb | UTF-8 | 1,271 | 3.109375 | 3 | [] | no_license | require './Voter.rb'
require './candidate.rb'
require './Vmenu.rb'
def choice
attr_accessor :choice
choice = gets.chomp
end
def test_voter
name = "Ashlynn"
politics = "Independant"
v = Voter.new(name, politics)
raise "Wrong name" unless v.name == name
raise "Wrong politics" unless v.politics == politi... | true |
a97f4f10c55eca023d77f0ae594c7b3a076d9e23 | Ruby | tpluss/bri1-ex2 | /main.rb | UTF-8 | 6,310 | 2.734375 | 3 | [] | no_license | #coding: utf-8
require 'csv'
require 'digest'
require 'mechanize'
# Парсер каталога продукции сайта http://piknikvdom.ru
# Записывает заданное количество товаров в файл и подсчитывает статистику.
# Если все загруженные товары находятся в одной категории - добирает столько же.
#
# Разделителем CSV-файла явля... | true |
c479f4b2519d0eb45c8630d34304fbd4ec986131 | Ruby | demileee/methods_reinf | /exercise.rb | UTF-8 | 100 | 3.09375 | 3 | [] | no_license | def word_counter(string)
count = string.split
puts count.count
end
word_counter("hi whats up")
| true |
305b92ea687c15458cf6384061e1a574e3be8145 | Ruby | jturello/clockangle_rspec | /spec/clockangle_spec.rb | UTF-8 | 1,012 | 3.984375 | 4 | [] | no_license | require('rspec')
require('clock_angle')
# require("pry")
describe('String#clock_angle') do
it('is equal to 0.0 degrees when time equals 12:00') do
expect("12:00".clock_angle()).to(eq(0.0))
end
it('is equal to 180.0 degrees when time equals 6:00') do
expect("6:00".clock_angle()).to(eq(180.0))
end
i... | true |
0ec1b256ee8c199551c9093302ff53b59654b182 | Ruby | zenhacks/manzuo-site | /source/why-us-en.html.rb | UTF-8 | 2,496 | 2.59375 | 3 | [] | no_license | ---
title: Manzuoapp - Why Us
---
<header class="page-header">
<h1 class="page-title">7 Reasons You'll Love ManZuo in Your Restaurant</h1>
</header>
<section id="why-us">
<% markdown_filter do %>
## No need to use expensive and antiquated pagers
Your host uses an iPad™ to run the ManZuo App. This inexpensive, eas... | true |
b92677268a367e7efbf398c893cef5740f86d08c | Ruby | escowles/testdrive | /demo0.rb | UTF-8 | 680 | 2.53125 | 3 | [] | no_license | require 'active_fedora'
require 'launchy'
class TestObject < ActiveFedora::Base
property :title, predicate: ::RDF::DC11.title
property :creator, predicate: ::RDF::DC11.creator
contains 'ds1'
end
# create an object and set a property and datastream content
obj = TestObject.new( title: ["Oh, the Places You'll Go!... | true |
c199a0b66173d19ad310f3c04d2900f2b65a3ada | Ruby | sfaiferek/ttt-with-ai-project-v-000 | /lib/game.rb | UTF-8 | 1,493 | 3.890625 | 4 | [] | no_license | class Game
WIN_COMBINATIONS = [
[0,1,2], # Top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6], # Left col
[1,4,7], # Middle col
[2,5,8], # Right col
[0,4,8], # Diag Right
[2,4,6] # Diag Left
]
attr_accessor :board, :player_1, :player_2
def initialize(player_1 = Players... | true |
510c23968c33d8a430b73ea74b3dd36a181b429b | Ruby | killinit/cms | /bin/migrate_files.rb | UTF-8 | 1,437 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'bundler/setup'
require 'optparse'
require 'base64'
require 'ostruct'
require 'nokogiri'
require 'hippo_xml_parser'
require 'fog'
require 'pry'
require_relative '../lib/hippo_file_parser'
require_relative '../lib/rackspace_cdn'
options = OpenStruct.new
OptionParser.new do |opts|
opts.on('--file [XML FILE]',... | true |
8576ba0e6a89a7f4f0b66e3967435c83065ccbb3 | Ruby | JayZonday/module-one-final-project-guidelines-nyc-web-031218 | /lib/Command_Line_Interface.rb | UTF-8 | 18,240 | 3.53125 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #|||||||||||BOROUGH METHODS||||||||||||||||
require 'colorize'
require 'date'
def get_borough(name)
Location.all.select do |loc|
loc.name.downcase == name.downcase
end
end
def num_of_crimes(name)
get_borough(name).length
end
def most_dangerous_borough
count = {}
bor = Location.all.map {|loc| loc.name}.uni... | true |
58c15c56c63f41a462d9be7e42941689933187b5 | Ruby | sneako/ruby-erlang-etf | /lib/erlang/etf/bit_binary.rb | UTF-8 | 1,901 | 2.859375 | 3 | [
"MIT"
] | permissive | module Erlang
module ETF
#
# | 1 | 4 | 1 | Len |
# | --- | --- | ---- | ---- |
# | 77 | Len | Bits | Data |
#
# This term represents a bitstring whose length in bits is not a
# multiple of 8 (created using the bit syntax in R12B and later).
# The `Len` field is an unsigned 4 ... | true |
d44f3dc199ccec473ef7c56d277105dd8ddc122a | Ruby | gooch/RDialogy | /lib/rdialogy/form.rb | UTF-8 | 1,958 | 3.03125 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/base'
require File.dirname(__FILE__) + '/form_field'
module RDialogy
class Form < Base
# Valid options are:
# * :text - Title of the widget
# * :width
# * :height
# * :form_height - Number of items to display in the list
# * :items - Array of FormField
#
# Returns <b>Hash</b>
#
# F... | true |
720ace8cd9155f70ec80ba9a748a47d6dd402b50 | Ruby | tsathishkumar/NQueens-in-Ruby | /n_queens.rb | UTF-8 | 1,595 | 3.734375 | 4 | [] | no_license | class NQueens
def initialize
@count=0
end
def find_n_queens(board,col)
already_visited = board.select{|cell| board[col][cell] == "X"}.keys[0]
if !already_visited.nil?
board[col][already_visited] = "-"
end
possible = possible_position(board,col)
if possible > 0
board[col][poss... | true |
f9c0a20635e63fed6c1f5bf0b7baeee6178de75d | Ruby | jeanetterosario88/triangle-classification-onl01-seng-pt-032320 | /lib/triangle.rb | UTF-8 | 984 | 3.28125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
attr_accessor :sideone, :sidetwo, :sidethree
def initialize(sideone, sidetwo, sidethree)
@sideone = sideone
@sidetwo = sidetwo
@sidethree = sidethree
end
def kind
if sideone + sidetwo > sidethree && sideone + sidethree > sidetwo && sidetwo + sidethree > sideone && sideone > ... | true |
4aa2aa50c3abf9dcb5d173c42a1ea161bbf64ad1 | Ruby | DanielLChang/AppAcademy | /w2/w2d2/chess/pieces/piece.rb | UTF-8 | 519 | 3.484375 | 3 | [] | no_license | require 'colorize'
class Piece
attr_accessor :color, :board, :pos
def initialize(color, board, pos)
@color = color
@board = board
@pos = pos
end
def to_s
symbol
end
def empty?()
@color.nil?
end
def dup_board
@board.dup
end
def valid_moves
all_moves = self.moves
... | true |
10db66c50ee0c352ae870c0fd69dc7849d518a00 | Ruby | adamahrens/RailsRecipes | /test/models/chef_test.rb | UTF-8 | 1,756 | 2.6875 | 3 | [] | no_license | # == Schema Information
#
# Table name: chefs
#
# id :integer not null, primary key
# name :string
# email :string
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string
# admin :boolean def... | true |
d1a4a1c31baec92ccb9b4ac017525d17ab47a61b | Ruby | Tobiuo1022/Learning | /cherry/lib/tempo.rb | UTF-8 | 306 | 3.03125 | 3 | [] | no_license | class Tempo
include Comparable
attr_reader :bpm
def initialize(bpm)
@bpm = bpm
end
def <=>(other)
if other.is_a?(Tempo)
@bpm <=> other.bpm
else
nil
end
end
# override
def inspect()
"#{@bpm}bpm"
end
end
| true |
d24f56bee69233de8cc6f57c3fbfc1045c41785b | Ruby | tobiaszwalczak/Todo-CLI | /lib/todo/show.rb | UTF-8 | 384 | 2.703125 | 3 | [
"MIT"
] | permissive | #encoding:utf-8
def show
error(:nofile) unless File.exist?("TODO")
puts Rainbow("\n Your TODO list:").blue.bright()+" (#{Dir.pwd}/TODO)\n\n"
File.read("TODO").each_line do |line|
if line[0,1] == "#"
line.sub!("#", "")
line.sub!("\n", "")
puts " » "+ Rainbow(line +" ✔").green.bright
... | true |
8e260eea1bf6eb7409332997e6f39c23a402acd7 | Ruby | meghanstovall/open_mic_1911 | /lib/open_mic.rb | UTF-8 | 454 | 3.359375 | 3 | [] | no_license | class OpenMic
attr_reader :location, :date, :performers
def initialize(attributes)
@location = attributes[:location]
@date = attributes[:date]
@performers = []
end
def welcome(user)
@performers << user
end
def repeated_jokes?
jokes1 = @performers[0].jokes
jokes2 = @performers[1].... | true |
c5c13c2cfeed14f91088cd2c6debfe7f7154bda6 | Ruby | fredemmott/sidewalk | /lib/sidewalk/uri_match.rb | UTF-8 | 829 | 2.609375 | 3 | [
"ISC"
] | permissive | module Sidewalk
# Information on a +URI+ +=>+ {Controller} match.
#
# These are generated by {UriMapper}.
class UriMatch
# The URL path, divided into regexp-matches.
#
# The URI map is a tree; this tells you what was matched at each level
# of the tree.
attr_reader :parts
# Any named ca... | true |
2da8aeaf58d6dd9efd7c8691b85dabbe990d499a | Ruby | jason20194/save-terminus | /save_terminus.rb | UTF-8 | 2,361 | 3.640625 | 4 | [] | no_license | # frozen_string_literal: true
# gems
require 'tty-prompt'
require 'tty-font'
require 'pry'
require 'colorize'
# requiring files
require_relative 'stage1'
require_relative 'stage2'
require_relative 'stage3'
require_relative 'final_boss'
require_relative 'gameover'
require_relative 'winner'
def main_menu(prompt, healt... | true |
aa15a123c4d82bbc0b24efd92ba11a8e9e75eae1 | Ruby | johnrails/ruby_stuff | /hash.rb | UTF-8 | 390 | 3.5625 | 4 | [] | no_license | # make a ruby hash respond to . notation
# example person = {name: "John", age:"37}
# person.name # "John"
#
# source http://www.goodercode.com/wp/convert-your-hash-keys-to-object-properties-in-ruby/
class ::Hash
def method_missing(name)
return self[name] if key? name
self.each { |k,v| return v if k... | true |
493be35f6cab618259829b9f7ed2c017a0ff647d | Ruby | zmitton/boggle | /app/helpers/boggle_classes.rb | UTF-8 | 9,431 | 3.078125 | 3 | [] | no_license | class BoggleBoard
attr_accessor :grid, :found_words, :r_index, :c_index, :score
def initialize (string = "4")
@board_string = string
@found_words = []
@covered_ground = []
@score = 0
build_board(string)
end
def build_board(string)
if string.length == 16
@grid = [
[Die.new("aeegmu", 0, 0, string[... | true |
2471db557b0bc54c6726302d940c406d2d4b7860 | Ruby | johanesteves/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 554 | 3.859375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def to_pig_latin(sentence)
split_sentence = sentence.split(" ")
split_sentence.collect {|word| self.piglatinize(word)}.join(" ")
end
def piglatinize(text)
vowels = ["A","E", "I", "O", "U", "a", "e", "i", "o", "u"]
first_letter = text[0]
if vowels.include?(first_letter)
... | true |
af44c420053184b099ec87d9ae15aa231b393579 | Ruby | petacube/xml2db | /phase2/type_clustering/data_profile_miner.rb | UTF-8 | 5,454 | 3.15625 | 3 | [] | no_license | # Mines features about the data within a specific column. Generates
# output intended to be used in order to cluster attributes with
# similar data profiles
class DataProfileMiner
# Base functionality shared among all profilers
class BaseProfiler
def self.applicable?(obj)
raise NotImplemented
end
... | true |
c681bb3f97f11b46f7211bae4ee9b82ed57ef2a6 | Ruby | VijayEluri/aspen | /lib/aspen/netty_proxy.rb | UTF-8 | 3,575 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'java'
require File.dirname(__FILE__) + '/aspenj.jar'
import com.github.kevwil.aspen.RackProxy
import com.github.kevwil.aspen.RackUtil
import java.nio.ByteBuffer
import java.nio.CharBuffer
import java.nio.channels.Channels
import org.jboss.netty.channel.ChannelHandlerContext
import org.jboss.netty.buffer.Channe... | true |
3b906f92233c9150b53069ace5c2145b5455b2de | Ruby | pact-foundation/pact-support | /lib/pact/matchers/embedded_diff_formatter.rb | UTF-8 | 1,277 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'pact/shared/active_support_support'
require 'rainbow'
module Pact
module Matchers
class EmbeddedDiffFormatter
include Pact::ActiveSupportSupport
EXPECTED = /"EXPECTED([A-Z_]*)":/
ACTUAL = /"ACTUAL([A-Z_]*)":/
attr_reader :diff, :colour
def initialize diff, options = {}... | true |
f5afee289198161d13f78297ca395e8fe9264bf4 | Ruby | puyo/exercises | /ruby/orion.rb/lib/moo/galaxy.rb | UTF-8 | 615 | 3.015625 | 3 | [] | no_license | require 'moo/star'
require 'moo/vector2d'
module Moo
class Galaxy
def initialize(opts = {})
@width = 0.0
@height = 0.0
@stars = []
@races = []
end
def create_predefined
# static for now
@width = 20.0
@height = 20.0
@stars = [
sol = Star.new('Sol', ... | true |
670c5eb44fe88ddbb07d6e89284cc606fd14db14 | Ruby | sergIlov/video_trimmer_api | /lib/video_trimmer_emulator.rb | UTF-8 | 198 | 2.671875 | 3 | [] | no_license | # Emulator
class VideoTrimmerEmulator
def initialize(_url, _start_time, _end_time)
end
def trim
# sleep(Random.rand(20.seconds..2.minutes))
sleep 3
[true, false].sample
end
end
| true |
46c77941db7c5dc09509b5ae06aff6f5755f10af | Ruby | densitypop/group-nation | /lib/data_loader.rb | UTF-8 | 1,180 | 2.71875 | 3 | [] | no_license | require 'forgery'
class DataLoader
def create_person
f = InternetEnabledPersonForgery
Person.create :first_name => f.first_name,
:last_name => f.last_name,
:email => f.email_address
f.reset
end
def create_group
f = GroupForgery
Group.create :nam... | true |
d5da3a4f5edc0d7c607e7066902d17278821c627 | Ruby | hanamimastery/episodes | /013/before/bin/install | UTF-8 | 4,982 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'find'
require 'tempfile'
require 'fileutils'
require 'pathname'
require 'open3'
class Installer
class << self
def call(app_name)
return unless rename_app(app_name)
install_readme
bundle_install
generate_cli_binstub
self_de... | true |
4f620ca788acb3b911960fcf0988bd872a9c6d34 | Ruby | amcvega/pdf-cell | /test/pdf_cell_test.rb | UTF-8 | 1,931 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'pdf/writer'
require '../lib/pdf_cell'
require 'active_support'
pdf = PDF::Writer.new
biodata = PDF::Cell::Base.new(pdf)
biodata.build :width => 500, :font_size => 8 do
header "Crew File #245: Jack Black (2/M of MV Nautilus)", :shaded => true,
... | true |
f0ef1b62fb0ad490713ed53cd690ee1b16792bd1 | Ruby | vise890/dbc_prep_exercises | /pj_euler/20.rb | UTF-8 | 222 | 3.984375 | 4 | [] | no_license | def factorial(n)
if n == 1
return 1
else
return n * factorial(n-1)
end
end
def digit_sum(n)
sum = 0
n.to_s.each_char do |char|
sum += char.to_i
end
return sum
end
puts digit_sum(factorial(100))
| true |
cb6e9691028c3f493a6afbd9836b70eb7100708a | Ruby | ColinOsborn/ruby_exercises | /flatten_test.rb | UTF-8 | 319 | 2.609375 | 3 | [] | no_license | require 'pry'
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'flatten'
class CustomArrayTest < Minitest::Test
def test_setup
assert CustomArray.class
end
def test_we_can_flatten_this_array
c = CustomArray.new([[1,2],[3,[4,5]]])
assert_equal [1,2,3,4,5], c.flatten
end
end
| true |
fb392fb5b21158409e4634f224c054d409c50658 | Ruby | JustinData/GA-WDI-Work | /w01/d03/Nichol/temperature.rb | UTF-8 | 1,152 | 5.09375 | 5 | [] | no_license | # ### Celsius Temperature Converter
# - This should be done in a new file called temperature.rb
# - Write `convert_to_fahrenheit` and `convert_to_kelvin` methods that will each take a temperature in Celsius as a parameter and return the converted temperature.
# - Once you have these methods written, a program that does... | true |
4ad3ba9e26c1d06bd929f702b06a25170d934946 | Ruby | ThiagoRodrigues/mars-rover-challenge | /lib/orientation.rb | UTF-8 | 1,339 | 3.484375 | 3 | [] | no_license |
class Orientation
COMPASS = {
"N" => "NorthFaced",
"E" => "EastFaced",
"S" => "SouthFaced",
"W" => "WestFaced"
}.freeze
def self.get_orientation(instance_key)
if COMPASS.has_key?(instance_key)
return Kernel.const_get(COMPASS[instance_key]).new
end
raise InvalidOrientationError... | true |
a2ac53227db3502fb0b6359d9a3582eb4ccafa01 | Ruby | JC-LL/rive | /lib/rive/runner.rb | UTF-8 | 1,959 | 2.84375 | 3 | [] | no_license | require "optparse"
require_relative "iss"
module Rive
class Runner
def self.run *arguments
new.run(arguments)
end
def run arguments
args = parse_options(arguments)
iss=Iss.new
iss.options = args
begin
filename=args[:file]
if iss.options[:disassemble]
... | true |
a0ce0e83447f685462102756389a7ea9c31fc364 | Ruby | rintaun/yard-sequel | /lib/yard-sequel/errors.rb | UTF-8 | 1,444 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module YardSequel
# The standard error for the plugin. All other errors inherit from this.
# @author Kai Moschcau
Error = Class.new ::StandardError
# Error that is raised if anything goes wrong with parsing any AstNode.
# @author Kai Moschcau
class AstNodeParseError < Error
... | true |
fb25db32b4eebad6e7c76b9fdba6cfd5e0365e7e | Ruby | JVThomas/sinatra-basic-routes-lab-v-000 | /app.rb | UTF-8 | 273 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/name' do
"My name is Justin Thomas"
end
get '/hometown' do
"My hometown is Woodside, NY"
end
get '/favorite-song' do
"My favorite song is 'Learn to Fly' by the Foo Fighters"
end
end
| true |
6d4be371c8042e31bde422aa58ce03897f38d9ec | Ruby | PenneyGadget/module_3_assessment | /app/services/best_buy_service.rb | UTF-8 | 523 | 2.53125 | 3 | [] | no_license | class BestBuyService
attr_reader :connection
def initialize
@connection = Faraday.new(:url => "https://api.bestbuy.com") do |faraday|
faraday.adapter Faraday.default_adapter
faraday.params["apiKey"] = ENV["BEST_BUY_KEY"]
faraday.params["format"] = "json"
end
end
def find_products(pro... | true |
a59aaca647c661c4ff080c365ecc26b4e1806d31 | Ruby | fadiTill/debugging-with-pry-onl01-seng-pt-012120 | /lib/pry_debugging.rb | UTF-8 | 35 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
num + 2
5
end
| true |
bacd01de2cce7b8542fa435437c2b161f61d81ca | Ruby | marcottelab/phamily | /lib/tasks/load_genes.rake | UTF-8 | 830 | 2.53125 | 3 | [] | no_license | #load_genes.rake
def batch_insert_genes species, arr
gene_data = arr.collect{|a| "('#{species}', '#{a}')"}
sql = "INSERT INTO genes (original_id, species) VALUES " + gene_data.join(", ") + ";"
ActiveRecord::Base.connection.execute sql
end
namespace :db do
namespace :phenologs do
desc "load genes from phen... | true |
7f567cd2352282eeab1cf0677ac4112df3c41df0 | Ruby | Tolia/typograph | /lib/typograph/processor.rb | UTF-8 | 1,189 | 2.6875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Typograph
class Processor
DEFAULTS = {}
SAFE_BLOCKS = [
['<pre[^>]*>','</pre>'],
['<style[^>]*>','</style>'],
['<script[^>]*>','</script>'],
['<!--','-->'],
['<code[^>]*>','</code>']
]
def initialize(options={})
@adapter = Adapte... | true |
ea82552ad1103555579d5090c5fb74dd27ea2cb6 | Ruby | BearCub29/Gossip_project | /lib/view.rb | UTF-8 | 384 | 2.5625 | 3 | [] | no_license | class View
attr_accessor :author , :content , :controller
def create_gossip
puts "Quel est ton nom petite fouine?"
@author = gets.chomp
puts "Quel est ton Gossip?"
@content = gets.chomp
return params = { @author => @content}
end
def index_gossips
@controller = Con... | true |
1955247d224518655032f2ed1b1eec5b21e78e43 | Ruby | Adria1988/ProgrammingExercises | /Ruby/TicTacToe/tic_tac_toe_v2/test3.rb | UTF-8 | 621 | 3.3125 | 3 | [] | no_license | require_relative 'board'
require_relative 'human_player'
class Game
def initialize(player_1_mark,player_2_mark)
@player_1 = HumanPlayer.new(player_1_mark)
@player_2 = HumanPlayer.new(player_2_mark)
@current_player = @player_1
@board = Board.new
end
def switch_turn
@current_player = if @curr... | true |
997d7e792566d44bb48e4a9caca94a0f7bc8be3d | Ruby | rvmiller/useragent-generator | /lib/useragent/config.rb | UTF-8 | 533 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | require 'yaml'
module UserAgent
class Config
@@props = Hash.new
def self.parse(entity, key)
# Lazy-load the props for the entity we need.
# An entity can be an os type, a device, manufacturer,
# pretty much anything that has properties we don't
# want to hard-code in a class
#... | true |
228dd610b69e4c03766910778244eb7637f3bac2 | Ruby | dgtm/meeting-planner | /lib/scheduler.rb | UTF-8 | 1,714 | 2.953125 | 3 | [
"MIT"
] | permissive | class Scheduler
class << self
def schedulable_time
{ starts_at: Time.parse("09:00"), ends_at: Time.parse("17:00") }
end
def restricted_timeframe
# @note Could be extended to an array in future for added flexibility
{ starts_at: Time.parse('12:00'), ends_at: Time.parse('13:00') }
end... | true |
fb40a9e1dc58d2285bbcabed45602551a0c0682a | Ruby | devindreszer/wdi_1_ruby_lab_methods | /lab1.rb | UTF-8 | 546 | 3.640625 | 4 | [] | no_license |
class String
def toonify(accent)
case accent
when :daffy
self.gsub('S','Th').gsub('s','th')
when :elmer
self.gsub('R', 'W').gsub('r', 'w')
when :tom
self.gsub('R', 'Ah').gsub('r', 'ah')
else
self
end
end
end
puts "Dark dock".toonify(:tom)
ACCENTS = {
daffy: ['s'... | true |
9be1361ab836981f5b0f011dd7e3da36668496a1 | Ruby | eby12/hopheads | /app/models/brewery.rb | UTF-8 | 652 | 2.953125 | 3 | [] | no_license | class Brewery < ActiveRecord::Base
attr_accessible :name
has_many :beers
has_many :posts
has_many :comments, dependent: :destroy
has_one :location
before_save :title_case
#validates :name length: {minimum: 5}, presence: true, uniqueness: true
#This method title cases all saved entries for brewery to ... | true |
3794e2afa4bbb1a86baf33cedbb595080ed2adf3 | Ruby | kamanfi/Algorithms_Ruby | /Dijkstra.rb | UTF-8 | 753 | 3.34375 | 3 | [] | no_license | require_relative 'Wgraph.rb'
def dijkstra(graph)
cost ={}
parent ={}
traversed=[]
order=[]
neighbor = graph.neighbor
#populate initial tables
neighbor.each do |e|
cost[e] =[e.edge(graph)]
parent[e.name] =graph.name
traversed=[e.name]
end
p cost.values
end
def find_lowest_cost(cost)
end
# cons... | true |
314a251c2c94316d74ea2f786186ab3b46d7a4d6 | Ruby | MPalhidai/Algorithms | /exercism/ruby/complete/isogram/isogram.rb | UTF-8 | 248 | 3.4375 | 3 | [] | no_license | class Isogram
def self.isogram?(string)
hash = Hash.new(0)
output = true
string.chars.each do |char|
char.downcase!
hash[char] += 1
output = false if hash[char] > 1 && /\w/.match(char)
end
output
end
end
| true |
8d71b9cd72c25657fbcfe6ecae21cdabe8de4f8d | Ruby | My-Dead-Projects/bytecode_interpreter | /bct.rb | UTF-8 | 1,381 | 2.828125 | 3 | [] | no_license | OUT = File.open("prog.bc", "w")
module Translator
module Preprocessor
class Methods
def self.comment(line, pos)
line[0, pos]
end
end
Keychars = {
"#" => Methods.method(:comment)
}
end
module Encoder
Keywords = {
"stor" => 0x01,
... | true |
0d59b70cf82bd591003cfc117839e5a4ff469aaa | Ruby | jaheyeva/intro_to_ruby | /lesson3/homework.rb | UTF-8 | 127 | 3.109375 | 3 | [] | no_license | number = rand(10)
number.times do
puts number * number
number = number + 1
break if number == 0
end
puts "the loop is done!" | true |
638dd1794a97a64b9eee252a6584c38117078bf6 | Ruby | boshnessy/Example_Exercises | /factory/manager.rb | UTF-8 | 1,790 | 4.4375 | 4 | [] | no_license | # A manager can do EVERYTHING an employee can do, and also send reports
class Employee
attr_reader :first_name, :last_name, :salary
attr_writer :first_name
def initialize(input_options)
@first_name = input_options[:first_name]
@last_name = input_options[:last_name]
@salary = input_options[:salary]
... | true |
0153c9271571e5cc5711b7a607f7afb3b9799a83 | Ruby | vinhloc30796/introduction-to-programming | /swap.rb | UTF-8 | 665 | 4.5625 | 5 | [] | no_license | # swap.rb
=begin
Given a string of words separated by spaces, write a method
that takes this string of words and returns a string in which
the first and last letters of every word is swapped.
You may assume that every word contains at least one letter,
and that the string will always contain at least one word.
Yo... | true |
13dd42aca9e5e510ed3c64886eec8d72aeff1083 | Ruby | aceimdevelopment/instrumenapp | /app/models/record.rb | UTF-8 | 655 | 2.59375 | 3 | [] | no_license | class Record < ApplicationRecord
enum state: [:preinscrito, :inscrito, :aprobado, :aplazado]
belongs_to :student, foreign_key: 'user_id'
belongs_to :evaluation
validates_uniqueness_of :user_id, scope: [:evaluation_id], message: 'ya se encuentra inscrito en la evaluación seleccionada.'
before_validation :... | true |
acadbc414b2b2f1c21066d83ed2249f3a087cbfb | Ruby | dumclibrary/medspace | /lib/tasks/migrate_medspace_data.rake | UTF-8 | 2,172 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
namespace :import do
desc "Import data from Medspace export"
task medspace: :environment do
import_data
exit 0 # Make sure extra args aren't misinterpreted as rake task args
end
task medspace_collections: :environment do
import_collections
exit 0 # Make sure extra ... | true |
ff416787a178c47d0bc0462173dbb30c92bed5e1 | Ruby | oneworldcoders/emmanuel_tic-tac-toe | /lib/language.rb | UTF-8 | 496 | 3.0625 | 3 | [] | no_license | module TicTacToe
class Language
def initialize(lang='en', language_data=JSON.parse(File.read(File.join(File.dirname(__FILE__), 'language.json'))))
@lang = lang
@language_data = language_data
end
def set_language(key)
@lang = @language_data['langu... | true |
83ec5a9749f47f6e130e485cca1feb902d83ed34 | Ruby | 5ecured/ls | /101_programming_foundations/lesson_one/101-109_small_problems/easy-3/counting_number_characters.rb | UTF-8 | 151 | 3.6875 | 4 | [] | no_license | puts "Please write a word or multiple words"
answer = gets.chomp
total = answer.delete(' ').length
puts "There are #{total} characters in #{answer}"
| true |
7493f10a315212f004d4a8a4322eee4a8afa0f36 | Ruby | excid3/paddle_pay | /lib/paddle_pay/util.rb | UTF-8 | 796 | 2.859375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module PaddlePay
module Util
class << self
def convert_hash_keys(value)
case value
when Array
value.map { |v| convert_hash_keys(v) }
when Hash
Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
else
... | true |
54f002a53a7c60997384378fad8e27c98a260557 | Ruby | crywolfe/vitals-platform-code-test-gw | /update_quality.rb | UTF-8 | 1,732 | 3.4375 | 3 | [] | no_license | require 'award'
# inherit from Award Struct
# "Blue First", increases in quality as the expiration date approaches; Quality increases by 2 when there are 10 days or less left, and by 3 where there are 5 days or less left, but quality value drops to 0 after the expiration date.
# "Blue First" awards actually increase ... | true |
d28b632c3b88082f6d36109bc955b771c4f35de9 | Ruby | shirley1chu/slack-cli | /lib/channel.rb | UTF-8 | 1,001 | 2.875 | 3 | [] | no_license | require "dotenv"
require "HTTParty"
require "pry"
require_relative "recipient"
Dotenv.load
module Slack
class Channel < Recipient
CHANNEL_URL = "https://slack.com/api/channels.list"
@query = { token: KEY }
attr_reader :slack_id, :name, :topic, :member_count
def initialize(slack_id:, name:, topic:... | true |
fc76360296f01080160ff8275578eb0fa3b043eb | Ruby | osaut/pindare | /example/model_simeoni.rb | UTF-8 | 1,693 | 2.546875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | #encoding: utf-8
($:.unshift File.expand_path(File.join( File.dirname(__FILE__), '../lib' ))).uniq!
require 'pindare'
# Modèle EDO de croissance basé sur Predictive Pharmacokinetic-Pharmacodynamic Modeling of Tumor Growth Kinetics in Xenograft Models after Administration of Anticancer Agents. (2004). Predictive Pharm... | true |
9e2e5090aafd7d513486da5c2b138fde6b34bc0a | Ruby | scepa991/simple-math-prework | /lib/math.rb | UTF-8 | 302 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def addition(num1, num2)
4 + 5
end
def subtraction(num1, num2)
10 - 5
end
def division(num1, num2)
50 / 2
end
def multiplication(num1, num2)
4 * 30
end
def modulo(num1, num2)
34 % 5
end
def square_root(num)
9
end
def order_of_operation(num1, num2, num3, num4)
7 + ((43 * 23)/ 84)
end
| true |
c6a97668ae189bb72408666c92c19733a97a096a | Ruby | AdipSearch/thehackingproject | /S3/D03/trainings/superheros.rb | UTF-8 | 401 | 3.953125 | 4 | [] | no_license | class Person
attr_accessor :name, :age
def initialize(name, age)
@name = name
@age = age
end
def to_s
puts @name
puts @age
end
end
class Superhero < Person
def initialize(name, age, superpower)
@name = name
@age = age
@superpower = superpower
end
def to_s
puts @superpower
end
end
jill = P... | true |
f6699a66dec68a22a9c5acf99b4786262c60562b | Ruby | oieioi/sokoban | /app/models/question.rb | UTF-8 | 2,717 | 3.25 | 3 | [] | no_license | class Question < ApplicationRecord
belongs_to :user
validates :name, presence: true
validates :map, presence: true
validate :validate_map
before_validation :sanitize_map
# TODO enum
TILES = {
empty: 'e',
new_line: 'n',
player: 'p',
box: 'b',
right_place: 'r',
wall: 'w',
}.freeze... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.