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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e5ebc1c3b3e939dc70d2bb8168acf547bb38389a | Ruby | harryworld/my_mongoid-1 | /spec/my_mongoid/crud_spec.rb | UTF-8 | 2,318 | 2.609375 | 3 | [
"MIT"
] | permissive | require "spec_helper"
class Crud
include MyMongoid::Document
field :number, :as => :n
end
# Tranucate table
Crud.collection.find.remove_all
describe MyMongoid::CRUD do
describe "#save" do
let(:c1) {
Crud.new({:id => 1, :n => 11})
}
it "document value should be the same as attributes" do
... | true |
9964db5918ae1ccbba6276c18392a70f599c0460 | Ruby | ekene966/hackerrank | /ruby/cut_the_sticks.rb | UTF-8 | 242 | 3.09375 | 3 | [
"MIT"
] | permissive | def cut_sticks(sticks)
return if sticks.empty?
puts sticks.length
cut_size = sticks.min
sticks.map! { |stick| stick - cut_size }
sticks.delete(0)
cut_sticks(sticks)
end
_ = gets.to_i
cut_sticks(gets.chomp.split(' ').map(&:to_i))
| true |
fb32521b4f105a704fb1a564369f332a96dfe8e9 | Ruby | Sepheus/ONI-Tools | /Scripts/terminal.rb | UTF-8 | 2,875 | 2.765625 | 3 | [] | no_license | require 'net/http'
class C64Terminal
REFERER = "http://mjizmja2mjaymju1mzc5ntc3.space/qqq/ORGANICRUN.b64.html"
URL = "http://mjizmja2mjaymju1mzc5ntc3.space/cgi-bin/ladsljdfsjkladf_clean_b64.py"
PREFIX = "65574a786232566965413d3d."
private_constant :REFERER, :URL, :PREFIX
def initialize(type, com... | true |
d3ee6fc20dfafc62f2dc5cfbd3e5afbe6f2930cc | Ruby | mitchellmunderwood/Ruby-Chess | /tests/in_check_test.rb | UTF-8 | 293 | 2.640625 | 3 | [] | no_license | require_relative '../board.rb'
require_relative '../display.rb'
board = Board.new
display = Display.new(board)
board.move_piece!([1,5],[2,5])
board.move_piece!([6,4],[4,4])
board.move_piece!([1,6],[3,6])
board.move_piece!([7,3],[3,7])
display.render
print board.in_check?('black')
print "\n"
| true |
3a8896c0ea6fab2a351e7c89c7beee082fd01670 | Ruby | spikesp/ex_small_p | /easy5/letter_swap.rb | UTF-8 | 264 | 3.65625 | 4 | [] | no_license | def swap(string)
arr = string.split(' ')
arr.map do |char|
temp_str = ''
temp_str = char[0]
char[0] = char[-1]
char[-1] = temp_str
end
arr.join(' ')
end
p swap('Oh what a wonderful day it is')
p swap('Abcde') == 'ebcdA'
p swap('a') == 'a' | true |
422ac49c2922a7cac16706d3805b0b1a04fdc31a | Ruby | lrotschy/Ruby-Exercises | /OOP-Exercises/OO_Basics_1_6.rb | UTF-8 | 372 | 4.0625 | 4 | [] | no_license | # OO_Basics_1_6.rb, 1_7, 1_8, 1_9
class Cat
attr_accessor :name
def initialize(name)
@name = name
end
def greet
puts "Hello! My name is #{name}!"
end
end
kitty = Cat.new('Kitteh')
kitty.greet
kitty.name = "Luna"
kitty.greet
# Another way to write a getter method (less preferred):
# def name
# @... | true |
acbc97216e79f3f532462fe2d1d083ab3dd45b12 | Ruby | khass24/todo_with_tests_app | /spec/models/task_spec.rb | UTF-8 | 1,734 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Task, type: :model do
describe "#toggle_complete!" do
it "should swap false to true and vice versa for complete" do
task = Task.create(complete: true)
task.toggle_complete!
expect(task.complete).to eq(false)
end
it "should swap true to false and vi... | true |
ce7a6200f78f9bf0c57135842e30d6b4a530ef75 | Ruby | scrozier/advent-of-code | /2019/23/a/program.rb | UTF-8 | 3,643 | 3.46875 | 3 | [] | no_license | require '/Users/scrozier/projects/advent/intcode2'
class Computer
attr_reader :initialized, :software, :address, :input_queue
def initialize(software, address)
@software = software
@address = address
@input_queue = []
@initialized = false
@output = {dest: nil, x: nil, y: nil}
@last_packet ... | true |
c141c941e5a0752b1eb203409fb4c0908ab9ec9e | Ruby | ken1882/MLPRPG_VODL | /Old Data Scripts/246_MOG_Adv_Load_Bar.rb | UTF-8 | 14,652 | 2.5625 | 3 | [] | no_license | #===============================================================================
# +++ MOG - Advanced Load Bar (v1.1) +++
#===============================================================================
# By Moghunter
# https://atelierrgss.wordpress.com/
#=====================================================... | true |
dbc66ba8dd09f3aa02a3a7d0e7f38ccd25c341e1 | Ruby | kh-fanis/calendar | /app/services/event_service.rb | UTF-8 | 922 | 2.953125 | 3 | [] | no_license | module EventService
@@DATE_OUT_STYLE = '%Y-%m' # when parsing params in caendar
@@DATE_IN_STYLE = '%m/%d/%Y' # when saving and updating the event
# inned in a index page of events in calendar, to parse date from params
def self.parse_date str
Date.strptime(str, @@DATE_OUT_STYLE)
rescue
Date.today... | true |
7e9f45b63899bdd1de82bd572d92612df02476fe | Ruby | jjousun/text_search | /text_frequency_spec.rb | UTF-8 | 1,651 | 2.9375 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'text_frequency.rb'
describe 'TextFrequency' do
before do
@test_tf = TextFrequency.new('test_doc.txt')
end
it 'can be instantiated with a local txt file' do
@test_tf.must_be_instance_of TextFrequency
end
describe '#clean_up_text' do
it 'returns only w... | true |
8b1f8241fe5002eb7ee1094068f2ba01d8e4c172 | Ruby | pemacy/Launch_School | /Exercises/Ruby/RB101-RB119_Small_Problems/Easy_7/ex11.rb | UTF-8 | 423 | 3.78125 | 4 | [] | no_license | # frozen_string_literal: true
# Write a method that counts the number of occurrences of each element in a
# given array.
def count_occurrences(arr)
arr.each_with_object(Hash.new(0)) do |el, hsh|
hsh[el] += 1
end
end
vehicles = [
'car', 'car', 'truck', 'car', 'SUV', 'truck',
'motorcycle', 'motorcycle', 'c... | true |
e58d164a4cbca6e6db1ef1f4c57928ea0de357ba | Ruby | raidancampbell/cuckoo_filter | /test/benchmark.rb | UTF-8 | 735 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | require 'cuckoo_filter'
require 'benchmark'
require 'benchmark/ips'
def setup(cf)
puts "Setting up for benchmarking..."
500_000.times do |i|
cf.insert(rand(100_000_000))
end
puts "Done."
end
def ips_benchmark(cf)
Benchmark.ips do |x|
x.config(warmup: 5, time: 10)
x.report('Iterations per seco... | true |
508348de7dddc33882c9cdabf6b4401074462044 | Ruby | kimpham54-archive/ruby-collaborating-objects-lab-online-web-pt-031119 | /lib/song.rb | UTF-8 | 654 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist
@@all = []
def initialize(name)
@name = name
end
def save
@@all << self
end
def self.new_by_filename(songname)
songname = songname.split(" - ")
song = Song.new(songname[1])
artist = Artist.find_or_create_by_name(songname[0])
# @artist = artist ... | true |
2860db5bc317ec3d8f87de348582f449bf8778c8 | Ruby | foxy-eyed/railway | /app/models/route.rb | UTF-8 | 735 | 2.75 | 3 | [] | no_license | class Route < ApplicationRecord
has_many :trains
has_many :railway_stations_routes
has_many :railway_stations, through: :railway_stations_routes
validates :name, presence: true
validate :stations_count
before_validation :set_name
before_create :order_stations
private
def set_name
if railway_st... | true |
1f4c54786aaacdfc9c359cfc557a1f42e77960ad | Ruby | lucasprograms/basic_orm | /user.rb | UTF-8 | 1,660 | 2.890625 | 3 | [] | no_license | require_relative 'questions_db'
require_relative 'question'
require_relative 'reply'
require_relative 'question_follow'
require_relative 'question_like'
require_relative 'model_base'
class User < ModelBase
attr_accessor :fname, :lname
def initialize(options)
@id = options['id']
@fname = options['fname']
... | true |
3859fa2111a4d3088b6ffa8738ac63f37992f982 | Ruby | soutaro/steep | /smoke/module/b.rb | UTF-8 | 98 | 2.53125 | 3 | [
"MIT"
] | permissive | # @type var klass: Class
# @type var mod: Module
3.is_a?(3.class)
klass = 3.class
mod = "".class
| true |
e62ed54e972971880623cfc378b067ec84f96361 | Ruby | WanjinYoo/math | /players.rb | UTF-8 | 152 | 3.203125 | 3 | [] | no_license | class Players
attr_accessor :name, :life
def initialize(name,life)
@name = name
@life = 3
end
def loseLife
@life -= 1
end
end | true |
45438f7a214c65ffa27af73a8f60498f391da86e | Ruby | khoifishpond/ruby-exercises | /mythical-creatures/lib/direwolf.rb | UTF-8 | 632 | 3.203125 | 3 | [] | no_license | class Direwolf
attr_reader :name, :home, :size, :starks_to_protect
def initialize(name, home="Beyond the Wall", size="Massive")
@name = name
@home = home
@size = size
@starks_to_protect = []
@hunts_white_walkers = true
end
def protects(stark)
if stark.location == @home && @starks_to_p... | true |
8f0939e7e905465a6e97db9ec3c0d50a6f3f6594 | Ruby | 3scale/3scale_toolbox | /lib/3scale_toolbox/commands/service_command/create_command.rb | UTF-8 | 2,513 | 2.515625 | 3 | [
"Apache-2.0",
"CC0-1.0",
"MIT",
"GPL-2.0-or-later",
"Artistic-2.0",
"BSD-3-Clause",
"Ruby",
"BSD-2-Clause"
] | permissive | module ThreeScaleToolbox
module Commands
module ServiceCommand
class CreateSubcommand < Cri::CommandRunner
include ThreeScaleToolbox::Command
class CustomPrinter
attr_reader :option_default, :option_disabled
def print_record(service)
puts "Service '#{service... | true |
7e5023c2137d6fecd807d61350b0b648d91910a0 | Ruby | philmccarthy/cart_cart_revolution | /test/shopping_card_test.rb | UTF-8 | 2,010 | 3.15625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/shopping_cart'
require './lib/product'
class ShoppingCartTest < Minitest::Test
def setup
@cart = ShoppingCart.new("King Soopers", "30items")
@product1 = Product.new(:paper, 'toilet paper', 3.70, '10')
@product2 = Product.new(:meat, 'chick... | true |
3daf2044bfa2ff588a8b76380e0334b7cea5e987 | Ruby | felipepagliuco/desafio-felipe | /features/step_definitions/pesca_steps.rb | UTF-8 | 1,894 | 2.609375 | 3 | [] | no_license | Dado('o endereço da API para manter o cadastro de Peixes') do
$uri_base = "https://6008f7120a54690017fc2796.mockapi.io/pesca/peixes"
end
# Cenário: Buscar todos os peixes cadastrados >>
Quando('realizar a requisição') do
$response = HTTParty.get($uri_base,)
end
Então('a api retorna todos os peixes cadastrados re... | true |
46c5421df24b9a55f1519d9ba7573895cc653913 | Ruby | coltonstaab1/ttt-with-ai-project-v-000 | /lib/board.rb | UTF-8 | 847 | 3.921875 | 4 | [] | no_license | require 'pry'
class Board
attr_accessor :cells
def initialize
@cells = [' ',' ',' ',' ',' ',' ',' ',' ',' ']
end
def reset!
@cells.clear
@cells = [' ',' ',' ',' ',' ',' ',' ',' ',' ']
end
def display
puts " #{@cells[0]} | #{@cells[1]} | #{@cells[2]} "
puts "------------"
puts " #{@cells[3]} | #... | true |
c3e4cabe4908a817df0edc4eb67065389345b510 | Ruby | gdm/PhotoOrganizer | /lib/PHash.rb | UTF-8 | 2,127 | 3.1875 | 3 | [] | no_license | require 'ffi'
module PHash
extend FFI::Library
ffi_lib ENV.fetch('PHASH_LIB','pHash')
# compute dct robust image hash
#
# param file string variable for name of file
# param hash of type ulong64 (must be 64-bit variable)
# return int value - -1 for failure, 1 for success
#
# int ph_dct_imagehash(c... | true |
73550b0cba197b86ceaf2b58fb53317e9165cc18 | Ruby | GunioRobot/rave | /lib/commands/usage.rb | UTF-8 | 740 | 2.59375 | 3 | [
"MIT"
] | permissive | #Display usage for rave command
def display_usage
puts "Useage: rave [create | server | war] [robot_name] [options]"
puts "'create' generates a Google Wave robot client stub application."
puts "e.g."
puts "rave create my_robot image_url=http://my_robot.appspot.com/image.png profile_url=http://my_robot.appspot.c... | true |
af0ffd54fc8545fe53eea918e320cbebd1cb4a90 | Ruby | Miradorn/exercism | /ruby/alphametics/alphametics.rb | UTF-8 | 1,177 | 3.453125 | 3 | [] | no_license | class Alphametics
attr_reader :first, :second, :operator, :power, :result, :letters
def solve(formula)
extract_values formula
mapping = (0..9).to_a.permutation(letters.length).find do |numbers|
h = letters.zip(numbers).to_h
first_number = first.gsub(/\w/, h)
second_number = second.gsub(/... | true |
535db099162a104cb0fde0ae9531507bab21c749 | Ruby | ericminio/tetris | /domain/piece.rb | UTF-8 | 1,225 | 3.09375 | 3 | [] | no_license | require File.dirname(__FILE__) + '/brick'
class Piece
attr_reader :line, :column, :bricks, :relative, :hole
def initialize(bricks)
@bricks = bricks
@relative = {}
bricks.each { |brick|
@relative[brick] = Brick.new(:line=>brick.line, :column=>brick.column)
}
end
def place_at(options={... | true |
e16109185ced6f264bc3b56e8a00c4ececa3f823 | Ruby | uhack-matt-daemons/barget | /src/db.rb | UTF-8 | 4,146 | 2.96875 | 3 | [] | no_license | require "sqlite3"
class DB
def initialize()
# Open a database
@db = SQLite3::Database.new "sqlite.db"
# Create a database
rows = @db.execute <<-SQL
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(30)
);
SQL
rows = @db.execute <<-SQL
CREAT... | true |
fdbd1102dedcbd7e4e6099e92e7594df92b63f05 | Ruby | Jerrycharles44/librairie | /lib/librairie/story.rb | UTF-8 | 1,897 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'pry'
class Librairie::Story
attr_accessor :name, :author, :isbn
def self.today
self.scrape_books
end
def self.scrape_books
books=[]
books << self.scrape_wattpad
books << self.scrape_wattpad1
books << self.scrape_wattpad2
books << self.scrape_wa... | true |
5ba9addd96ac2321767658dbe07ba051ffc42f95 | Ruby | jdcheesman/ruby_scripts | /log_utils/PLSQLProc.rb | UTF-8 | 2,361 | 2.9375 | 3 | [] | no_license | class PLSQLProc
attr_accessor :name
attr_accessor :worst
attr_accessor :best
attr_accessor :plSqlData_worst
attr_accessor :plSqlData_best
attr_accessor :worst_time
attr_accessor :best_time
attr_accessor :totaltime
attr_accessor :calls
def initialize(... | true |
b119e06eebe7b35f05167918815edf4d1e6bd2fa | Ruby | tmecklem/catangerine | /spec/lib/catangerine/location_spec.rb | UTF-8 | 1,035 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Catangerine
describe Location do
it 'accepts a direction component after the name' do
s = Location.new('A', 't')
expect([s.q, s.r, s.direction]).to eq [0, 0, :t]
end
it 'accepts coords instead of name' do
s = Location.new(0, 0)
expect([s.q, s.r]).to e... | true |
7a209f0490aaad72d5dd498e68699effbd539fbd | Ruby | MartinJNash/RubyFall2013 | /week3/homework/calculator.rb | UTF-8 | 645 | 3.59375 | 4 | [
"Apache-2.0"
] | permissive | class Calculator
def sum(nums=[])
# start off with zero, cycle through the array
# accumulate total plus current value
# FIRST TRY, then I looked at inject in the docs ;)
# nums.inject(0){ |total, current| total += current }
nums.inject(0, :+)
end
def multiply(*nums)
# takes a variable... | true |
72289291f44da4c77110fa3a54c9556a8cf71061 | Ruby | kalifs/examples | /dci_examples/ruby_example2/lib/roles/model.rb | UTF-8 | 702 | 3.078125 | 3 | [
"MIT"
] | permissive | module Model
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def create(attributes)
collection.insert(attributes)
end
def all
collection.all.map{|attributes| new(attributes)}
end
def first
new(collection.first)
end
end
def initialize... | true |
f5f5248b5d9e70997435622860f212de71c3eb60 | Ruby | jalant/tunr_testing | /app/models/user.rb | UTF-8 | 293 | 2.515625 | 3 | [] | no_license | class User < ActiveRecord::Base
attr_accessible :email, :name
validates_presence_of :name, :email
has_and_belongs_to_many :albums
def purchase(album)
unless albums.include? album
albums << album
self.save
end
end
def forget_albums
albums.clear
end
end
| true |
e352d3e5fc504decd469c627c3f2efdeea87f893 | Ruby | SOA2017-ILV/TranslateThis | /infrastructure/imgur/imgur_api.rb | UTF-8 | 1,502 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: false
require 'http'
module TranslateThis
module Imgur
# Class for Imgur API
class Api
module Errors
# Invalid Token Error Class
NotValid = Class.new(StandardError)
end
# Encapsulates API response handling
class Response
HTTP_ERROR = {... | true |
40f6b629fb96b35b6bb2ae3cfff3709e25047dec | Ruby | thbar/sidekiq-unique-jobs | /lib/sidekiq_unique_jobs/timeout_calculator.rb | UTF-8 | 897 | 2.515625 | 3 | [
"WTFPL"
] | permissive | module SidekiqUniqueJobs
class TimeoutCalculator
def self.for_item(item)
new(item)
end
def initialize(item)
@item = item
end
def seconds
time_until_scheduled + unique_expiration
end
def time_until_scheduled
scheduled = item[AT_KEY]
return 0 unless scheduled... | true |
222c61b8e00368a6621bdeefdcbb524ad4d53104 | Ruby | jhartwell/ironruby | /Tests/Experiments/Struct/struct4.rb | UTF-8 | 585 | 3.4375 | 3 | [] | no_license | def dump_class x
puts "-- #{x.name}"
p x.instance_methods(false).sort
p x.singleton_methods(false).sort
p x.ancestors
puts
end
dump_class Struct
StructC = Struct.new(:foo)
dump_class StructC
C = Class.new(StructC)
dump_class C
puts "-- C.new"
p C.new
puts
# remove new() on StructC's s... | true |
185a8ffbba83519fb61726c7c945866f3740c22b | Ruby | backgroundcheck/us_mo_cmp_list | /scraper.rb | UTF-8 | 3,387 | 2.578125 | 3 | [] | no_license | require 'scraperwiki'
# encoding: UTF-8
require 'nokogiri'
require 'mechanize'
require 'logger'
require 'csv'
require 'thread'
Mechanize.html_parser = Nokogiri::HTML
BASE_URL = "https://www.sos.mo.gov/BusinessEntity/soskb/"
def get_metadata(key, default)
begin
ScraperWiki.get_var(key, default)
rescue Excepti... | true |
726eb26b036a4e198a70399cc789ac52aaf061f5 | Ruby | jotolo/zion_client | /sentinel_manager.rb | UTF-8 | 1,334 | 2.96875 | 3 | [] | no_license | require './api_consumer'
require './zip_manager'
require './route'
class SentinelManager
attr_accessor :all
def initialize(passphrase)
@passphrase = passphrase
@source = 'sentinels'
@all = []
end
def import
consumer = ApiConsumer::Resource.new(@passphrase, @source)
response = consumer.get_r... | true |
5f3eb2fd72da92f44b1965bafa4e60e7f9b97a2b | Ruby | toch/zombie_epidemic | /spec/zombie_epidemic/state_transition_machine_spec.rb | UTF-8 | 3,597 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative '../spec_helper'
FakeRandom = Struct.new("FakeRandom", :result) do
def initialize(result = 0)
super
@result = result
end
def rand(max)
@result
end
end
describe ZombieEpidemic::StateTransitionMachine do
subject { ZombieEpidemic::StateTransitionMachine.new(FakeRa... | true |
5003155c34b5ac3ef04cec1d235dd7abae34604b | Ruby | soohoo05/oo-kickstarter-dumbo-web-091718 | /lib/backer.rb | UTF-8 | 227 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Backer
attr_accessor :backed_projects
attr_reader :name
@backed_projects=[]
def initialize(name)
@name=name
@backed_projects=[]
end
def back_project(project)
@backed_projects<<project
project.backers<<self
end
end
| true |
989dd521c421aadb321f074b999a59a5e120c6a8 | Ruby | Georjane/architecture-styles | /app/helpers/users_helper.rb | UTF-8 | 456 | 2.546875 | 3 | [] | no_license | module UsersHelper
# Returns the Gravatar for the given user.
def gravatar_for(user)
gravatar_id = Digest::MD5.hexdigest(user.name.downcase)
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}"
image_tag(gravatar_url, alt: user.name, class: 'gravatar')
end
def highest_voted_article
... | true |
858d6f3f3f2639067acb0b0f17cfbedc832813c4 | Ruby | octonion/fantasy | /espn.rb | UTF-8 | 2,205 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
bad = " "
bad2 = " "
require "csv"
require "mechanize"
agent = Mechanize.new{ |agent| agent.history.max_size=0 }
agent.user_agent = 'Mozilla/5.0'
base = "http://games.espn.go.com/ffl/leaders"
#options = "scoringPeriodId=17&seasonId=2010&startIndex=50"
#table_xpath = "/html/bod... | true |
c08ad29ca1a6139401b12a39044259e498eff861 | Ruby | cedretaber/codes_for_codeforces | /ecr/086/c_test.ruby | UTF-8 | 406 | 2.921875 | 3 | [] | no_license | require "open3"
loop do
a = rand(1..200)
b = rand(1..200)
l = rand(1..200)
r = rand(l..1000)
res = (l..r).count { |n| n%a%b != n%b%a }.to_s
stdin, stdout, _, _ = Open3.popen3('./c')
stdin.puts "1"
stdin.puts "#{a} #{b} 1"
stdin.puts "#{l} #{r}"
out = stdout.gets.chomp
if out != res
puts "Fa... | true |
75e97d36ff48cc9342d43801f873551820c997aa | Ruby | danielgelbart/edgar | /app/models/search.rb | UTF-8 | 1,670 | 2.890625 | 3 | [] | no_license | # == Schema Information
#
# Table name: searches
#
# id :integer not null, primary key
# filtype :integer default(0)
# ticker :string(255)
# created_at :datetime
# updated_at :datetime
#
class Search < ActiveRecord::Base
enum filtype: [ :k10, :q10]
def generate_links(ticker)
... | true |
7ce436f6b1a561282cac18f9c46b8912f76fa6e0 | Ruby | seomoz/qless | /lib/qless/job_reservers/round_robin.rb | UTF-8 | 947 | 2.890625 | 3 | [
"MIT"
] | permissive | # Encoding: utf-8
module Qless
module JobReservers
# Round-robins through all the provided queues
class RoundRobin
attr_reader :queues
def initialize(queues)
@queues = queues
@num_queues = queues.size
@last_popped_queue_index = @num_queues - 1
end
def reserve... | true |
81dbcfc553666b925b4257d26be82f755a363a89 | Ruby | mdiaz26/ruby-enumerables-reverse-each-word-lab-prework | /reverse_each_word.rb | UTF-8 | 158 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
array = string.split
reverse_array = array.collect { |n| n.reverse }
new_string = reverse_array.join(" ")
new_string
end | true |
5224ff9dce9de4e4ae48e1999ebed6b0d91f8e6d | Ruby | ljnezzy/ontheroadagain | /app/models/vehicle.rb | UTF-8 | 587 | 2.703125 | 3 | [] | no_license | class Vehicle < ApplicationRecord
validates :make, :model, :year, :color, presence: true
validates :features, length: { minimum: 25 }
validates :price, :mileage, numericality: { greater_than_or_equal_to: 0}
validates :image_file_name, allow_blank: true, format: { with: /\w+\.(gif|jpg|png)\z/i, message: "must ref... | true |
5d0a1980070775ef9b0b4ffc93b72c3290cde3c0 | Ruby | mixelpixel/Conways-Game-Of-Life-with-rspec | /_ideas/game_of_life.rb | UTF-8 | 947 | 2.75 | 3 | [] | no_license | =begin
FROM: https://gist.github.com/netmute/1761463
=end
# The code with some animation logic for demonstration.
#
# One-liner
# life=->g,s{(0..s*s-1).map{|i|->n{n==3||(g[i]&&n==2)||nil}[[g[i-s-1],g[i-s],g[i-s+1],g[i-1],g[i+1],g[i+s-1],g[i+s],g[i+s+1]].compact.count]}}
# Expanded version for better readability.
#
li... | true |
7c0d98883a4b99e40131f178b3d75d5ee63bee8d | Ruby | danielgarda/E6CP2A1 | /3 strings/ejercicio2.rb | UTF-8 | 547 | 4.09375 | 4 | [] | no_license | # Construir un arreglo de los nombres de todos sus compañeros y en base a él:
# 1. Imprimir todos los elementos que excedan más de 5 caracteres.
# 2. Crear un arreglo nuevo con todos los elementos en minúscula.
# 3. Crear un método que devuelva un arreglo con la cantidad de caracteres que tiene cada nombre.
compañero... | true |
00b06fcbccb8de5a97e97c7694b2eba1f95bd362 | Ruby | sudo-dax/simpleMap | /src/macchanger.rb | UTF-8 | 1,465 | 3.09375 | 3 | [] | no_license | require 'tty-prompt'
require 'colorize'
#Module to get MAC
def get_mac_addr
dmac = system ("ip addr | awk '/ether/{ print $2 }'")
end
#Display current MAC
puts 'Your current MAC Address is: '
get_mac_addr()
puts ""
puts ""
# Selection Menu :: Gem Tty-Prompt
prompt = TTY::Prompt.new(symbols: {marker: '►'})
user_inp... | true |
782eb2374580f34a27c9aa146a4db771a36d2520 | Ruby | swapman972/ruby-oo-relationships-practice-gym-membership-exercise-nyc-web-033020 | /lib/gym.rb | UTF-8 | 472 | 3.078125 | 3 | [] | no_license | class Gym
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def all_membership
Membership.all.select {|key| key.gym == self}
end
def all_lifters
self.all_membership.map {|key| key.lifter}
end
def lifters_name
self.all_li... | true |
05b4c9d492f580bfb765746cffb92b2d03fd5d7f | Ruby | aritode/ror-samurai | /Module_03/main.rb | UTF-8 | 2,255 | 3.25 | 3 | [] | no_license | # encoding: utf-8
#
# Simple 3 Classes for Trains
require_relative 'train'
require_relative 'route'
require_relative 'station'
train_passenger = Train.new(25, :passenger, 15)
train_passenger_2 = Train.new(12, :passenger, 10)
train_cargo = Train.new(88, :cargo, 35)
# =========== #
train = Train.new(01, :passenger, ... | true |
7ec6b1fc10abf20ac6c51f3a5edffe570a990cd8 | Ruby | chalkers/ericsson | /test_unit_example_refactored.rb | UTF-8 | 681 | 3.109375 | 3 | [] | no_license | require 'test/unit'
class HomepageTest < Test::Unit::TestCase
FILE_NAME = "myfile.txt"
def setup
reset_system
end
def test_writing_file
assert file_doesnt_exist?
write_string_to_file "hello world"
assert file_exists?
assert_equal "hello world", file_contents
end
private
... | true |
6ce6be28f60fa9a320bedd1e0168e2277ed69374 | Ruby | houcheng/JiebaRuby | /lib/trie.rb | UTF-8 | 1,023 | 3.484375 | 3 | [] | no_license | require 'pp'
class TrieNode
def add_son(ch)
@sons = {} unless @sons
return @sons[ch] if @sons[ch]
son_node = TrieNode.new
@sons[ch] = son_node
end
def find_son(ch)
return nil unless @sons
return @sons[ch]
end
def set_freq(freq)
@freq = freq
end
def get_freq
@freq
end... | true |
c6170a98a760afa76228306e30d8dfd8f899682a | Ruby | korayozkal/oo-meowing-cat-onl01-seng-ft-041320 | /lib/meowing_cat.rb | UTF-8 | 152 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ## code your solution here.
## I REALLY LOVE OBJECT ORRIENTATION CLASSES SO FAR!
class Cat
attr_accessor :name
def meow
puts "meow!"
end
end | true |
63aeb1cf28c7190495b0e55d16b89bf28271c2fd | Ruby | OSSSP/WhereAreTheEyes | /website/utils/readDB.rb | UTF-8 | 195 | 2.546875 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative "../map"
for db in ARGV do
puts "Pins in #{db}:"
pins = Map.loadPins(db)
for p in pins do
puts "\t#{p.latitude} #{p.longitude} #{p.verifies}"
end
end
| true |
eea7ec5f935480712fda48f48442aba81c745b07 | Ruby | blambeau/waw | /lib/waw/validation.rb | UTF-8 | 6,662 | 2.625 | 3 | [
"MIT"
] | permissive | require 'waw/validation/errors'
require 'waw/validation/helpers'
require 'waw/validation/validator'
require 'waw/validation/not_validator'
require 'waw/validation/and_validator'
require 'waw/validation/or_validator'
require 'waw/validation/missing_validator'
require 'waw/validation/mandatory_validator'
require 'waw/va... | true |
682f16943969fb2adb9005abed57f556168cbb8a | Ruby | Mtmackenzie/ls_ruby_challenges | /easy2/1_odd_words.rb | UTF-8 | 2,551 | 4.28125 | 4 | [] | no_license | # - words, space, point
# - words at most 20 chars
# - text could have 1+ words separated by 1+ spaces, end with 0+ spaces and point
# - input has spaces at the front? if so, ignore spaces and start with first letter of first word
# - returned string should only have one space in between words and period at the end
# -... | true |
2df37c7ba206e4631055cfb419daa1ab90ac14a9 | Ruby | AlterEgo7/coolpay | /lib/coolpay/recipient.rb | UTF-8 | 405 | 2.875 | 3 | [] | no_license | module Coolpay
class Recipient
attr_reader :name, :id
def initialize(name, id)
name.to_s.empty? ? raise(ArgumentError, 'name is mandatory') : @name = name
id.to_s.empty? ? raise(ArgumentError, 'ID is mandatory') : @id = id
end
def ==(other)
# Suppose the backend takes care for uniq... | true |
91afb83eb785179a6ca6ce15c518098943874489 | Ruby | MichaelOultram/Security-Internship | /gentoken/lib/puppet/parser/functions/gentoken.rb | UTF-8 | 904 | 2.578125 | 3 | [] | no_license | module Puppet::Parser::Functions
newfunction(:gentoken, :type => :rvalue) do |args|
# Attributes to create token with
aeskey = "3eafda76cb8b015641cb946708675423" # Replace me!
exercise = args[0]
buffersize = args[1]
vmid = lookupvar('vmid')
# Combine attributes together
data = exercise + ... | true |
81d7ecb76939e88ae15e2a0630ab3cf595b2a7fb | Ruby | paulhtrott/bermudamarineregulations | /app/helpers/fish_helper.rb | UTF-8 | 391 | 2.515625 | 3 | [] | no_license | module FishHelper
def google_image_search_path(fish)
fish_param = { q: fish.species, tbm: "isch" }.to_param
"https://www.google.com/search?#{fish_param}"
end
def title(fish)
if fish.name.downcase.eql? fish.alt_name.downcase
content_tag :h3, fish.name.titlecase
else
content_tag :h3, "... | true |
38adf5b4b097248a5bbdf8e2793b686c85f541c9 | Ruby | gitter-badger/larrow-runner | /lib/larrow/runner/logger.rb | UTF-8 | 1,741 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'logger'
module Larrow::Runner
# usage:
# logger = Larrow::Runner::Logger filename
# logger.level(3).color('red').info 'hello'
# logger.level(3).title 'hello'
# logger.level(3).detail 'hello'
class Logger
def initialize logger, level:nil, color:'green'
@inner_logger = if logger.is_a? ::Lo... | true |
565e81fa5f62f0873e84ce8f889a615b10d1b5a1 | Ruby | handlerorto5-0/rubyist-book-archives | /010_method_access_rules/protected.rb | UTF-8 | 587 | 3.90625 | 4 | [] | no_license | # вы можете вызывать защищенный метод для объекта x, если объект по умолчанию (self) является экземпляром того же класса, что и x, или предка или класс-потомок класса Х
class C
def initialize(n)
@n = n
end
def n
@n
end
def compare(c)
if c.n > n
puts "The other object's n is bigger"
else
... | true |
d0c66864be5ff70c38fbe1005d529158cdf713b6 | Ruby | LaunchThing/regexp_parser | /test/parser/test_sets.rb | UTF-8 | 2,902 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path("../../helpers", __FILE__)
class TestParserSets < Test::Unit::TestCase
def test_parse_set_basic
exp = RP.parse('[a-c]+', :any).expressions[0]
assert_equal( true, exp.is_a?(CharacterSet) )
assert_equal( true, exp.include?('a-c') )
assert_equal( true, exp.quantified? )
a... | true |
e58d4ce92cf0a167bfcc6c6a6282b9473d057eeb | Ruby | jtarchie/ruby-concourse | /lib/concourse/docker_container.rb | UTF-8 | 683 | 2.578125 | 3 | [] | no_license | require_relative 'docker_image'
require 'shellwords'
module Concourse
class DockerContainer
def initialize(image:, command:, stdin: "", name:, volumes: [])
@image = image
@command = command
@name = name
@stdin = stdin
@volumes = volumes
end
def image
... | true |
cfb9dd5899f11bb24dfb2b98c6433386616bced5 | Ruby | 67272-App-Design-Dev/PATS_v3 | /app/models/procedure.rb | UTF-8 | 1,430 | 2.609375 | 3 | [] | no_license | require 'helpers/activeable'
class Procedure < ApplicationRecord
include Activeable::InstanceMethods
extend Activeable::ClassMethods
# Relationships
has_many :procedure_costs
has_many :treatments
has_many :visits, through: :treatments
# Scopes (in addition to activeable ones)
scope :alphabetical, -> ... | true |
1fd30b6a317cac2563bfac2458803dfd6defbda0 | Ruby | hooptie45/xiki | /menu/app.rb | UTF-8 | 307 | 2.515625 | 3 | [
"MIT"
] | permissive | #
# Shows each OS X app, and lets you launch them.
#
class App
def self.menu name=nil
if ! name
txt = Dir.new("/Applications/").entries.select{|o| o =~ /\.app$/}.map{|o| "#{o[/(.+)\.app$/, 1]}/"}
return txt
end
Console.sync "open \"/Applications/#{name}.app\""
nil
end
end
| true |
fe63c6c948bdbcd419eebcac9c0e016b628c8823 | Ruby | svenfuchs/todo.txt | /lib/todo/src/idonethis.rb | UTF-8 | 1,120 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'json'
require 'todo/support/http'
module Todo
module Src
class Idonthis < Struct.new(:config, :opts)
URL = 'https://idonethis.com/api/v0.1/dones/'
def include?(item)
texts.include?(item.text) or ids.include?(item.id)
end
def write(lines)
lines.each { |line| post... | true |
754eb4e9042710b5a03d1ea48a11c8f8024461d3 | Ruby | lsamano/sinatra-mvc-lab-dumbo-web-121018 | /models/piglatinizer.rb | UTF-8 | 512 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(sentence)
word_array = sentence.split(" ")
word_array.map! do |word|
letter_array = word.chars
if word.chars.count == 1
"#{word}" + "way"
else
vowel_index = word.index(/[aeiouAEIOU]/)
if vowel_index == 0
... | true |
6531b7a47f6f619e8f357aa47451bc8dbe011f68 | Ruby | prepor/green | /lib/green/ext.rb | UTF-8 | 761 | 2.8125 | 3 | [] | no_license | class Fiber
# def self.new
# super.tap { |o| o[:green] = Green.current }
# end
#Attribute Reference--Returns the value of a fiber-local variable, using
#either a symbol or a string name. If the specified variable does not exist,
#returns nil.
def [](key)
local_fiber_variables[key]
end
#Attr... | true |
698fd9b159a6ae7ef5a0fb5036ce43a26adf47de | Ruby | frangucc/chicago_ideas | /app/models/member_type.rb | UTF-8 | 2,809 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class MemberType < ActiveRecord::Base
# my bone dry solution to search, sort and paginate
include SearchSortPaginate
validates :projected_members, numericality: { greater_than_or_equal_to: 0, only_integer: true }
validates :maximum_members, numericality: { greater_than_or_equal_to: 0, only_integer: true }... | true |
cd4483d58b9f11d41afacac09466a6b4388feb8b | Ruby | kashive/StudyBuddy | /app/controllers/schedules_controller.rb | UTF-8 | 4,064 | 2.640625 | 3 | [] | no_license | class SchedulesController < ApplicationController
# GET /schedules/new
# GET /schedules/new.json
def new
@courses = Course.where("user_id='#{current_user.id}'")
@user = current_user
@toCheckOff = []
Schedule.where("user_id = '#{current_user.id}'").each do |schedule|
@toCheckOff.push(schedul... | true |
df87ad4726de21d7e379454bec679747c9e180ab | Ruby | stefanbarolin/THP2020 | /DAY08/lib/01_pyramids.rb | UTF-8 | 743 | 4.125 | 4 | [] | no_license | def full_pyramid (n)
y = 0
until y > n - 1
x = 0
until x > 2 * n
if x < n - 1 - y
print (" ")
elsif x > n - 1 + y
print(" ")
else
print ("#")
end
x = x + 1
end
puts ("")
y = y + 1
end
end
def reverse_pyramid (n)
y = 0
until y > n - 1
print (" ")
x = 0
until x > 2 * n
... | true |
4cc47382ad64ea2086af88fb140fe04bb8977a1d | Ruby | dandersen2/phase-0 | /week-7/gps6/my_solution.rb | UTF-8 | 6,444 | 3.96875 | 4 | [
"MIT"
] | permissive | # Virus Predictor
# I worked on this challenge with Zach Schatz
# We spent 2.5 hours on this challenge.
# EXPLANATION OF require_relative
# Require_relative will allow our file to see the state data stored within the state_data. As opposed to 'require', require_relative denotes specificity that data from another file... | true |
4a6982744c4dacb30aada27ac5a8efaf537a0bea | Ruby | dpmidd/oo-practice | /ruby/spec/high_school.rb | UTF-8 | 424 | 3.5625 | 4 | [] | no_license | class HighSchool
attr_reader :vacancies, :students, :drop_out_list, :alumni
def initialize(vacancies)
@vacancies = vacancies
@students = []
@drop_out_list = []
@alumni = []
end
def enroll(student)
@vacancies -= 1
@students << student
end
def drop_out(student)
@students.delete... | true |
379cd8d276624c10eadebd59738cbda9b130d2fd | Ruby | ccci210/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,523 | 3.765625 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
# YOUR CODE HERE
if arr.empty?
return 0
end
sum = 0
arr.each { |a| sum+=a }
return sum
end
def max_2_sum arr
# YOUR CODE HERE
tmp=arr.max(2)
return tmp.sum
end
def sum_to_n? arr, n
# YOUR CODE HERE
if arr.empty?
... | true |
1a76ce45f90e3202ede729c065d43982e6dfb285 | Ruby | mpissanos/duder | /lib/duder/character.rb | UTF-8 | 525 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'pry'
class Duder::Character
attr_accessor :name, :quotes, :url, :char, :char_quote
@@char_array = []
def initialize(character, array, url)
@name = character
@quotes = array
@url = url
@@char_array << self
end
def self.quote_generator(input)
char = @@... | true |
5156c7d93572fde1e157105d81904656860ed4f7 | Ruby | jdbernardi/mechanize_tut | /readme_tut.rb | UTF-8 | 1,635 | 3.265625 | 3 | [] | no_license | require 'mechanize'
require 'rubygems'
require 'bundler/setup'
require 'nokogiri'
require 'pry'
# first we instantiate a new mechanize object
agent = Mechanize.new
# use the new object to fetch a page
# with this get command, mechanize picked up google's home page and stored any cookies that were set and followed an... | true |
b348be8d462349435443874ff6afc51019e6ca93 | Ruby | qz0222/app_academy_works | /w1d2/ComputerPlayer.rb | UTF-8 | 1,433 | 3.6875 | 4 | [] | no_license | class ComputerPlayer
attr_accessor :name, :guessed_pos, :size, :revealed_pos, :value_hash, :unknown_pos
def initialize(name)
@name = name
@guessed_pos = []
@size = 0
@revealed_pos = []
@value_hash = Hash.new{[]}
@unknown_pos = []
end
def full_pos(size)
ans = []
... | true |
916ef6f1caa8c6eec8440e6d4f21304cd2525da6 | Ruby | Red-Menace/RubyMotionRonin | /ExampleIB/app/AppController.rb | UTF-8 | 2,489 | 2.875 | 3 | [
"BSD-2-Clause"
] | permissive |
#
# Project 'ExampleIB' -- AppController.rb
#
# This class provides accessors (outlets and bindings), methods (actions),
# and initialization for UI items in the Xcode IB AppWindow.nib file.
#
#
class AppController < NSWindowController
##################################################
# ――― IB Outlets ... | true |
15cc54c7e83095e69775875b3886c5d41b22e1bd | Ruby | kassi/yaml_configuration | /lib/yaml_configuration/loader.rb | UTF-8 | 882 | 2.6875 | 3 | [] | no_license | module YamlConfiguration
class Loader
def load(*config_files)
combined_configuration = {}
config_files.flatten.each do |config_file|
loaded_config = load_yaml_config(config_file)
combined_configuration.deep_merge!(loaded_config)
end
Configuration.new(combined_configuration)... | true |
2a1b2be0ea0395afd999406a48a5b614d9236e85 | Ruby | cngraf/linked-list | /node.rb | UTF-8 | 1,599 | 3.484375 | 3 | [] | no_license | class Node
attr_accessor :value, :reference
def initialize(value, reference = nil)
raise ArgumentError.new('Tail must be either a node or nil.') unless reference.is_a?(Node) || reference.nil?
@value = value
@reference = reference
end
def length
if reference == nil
1
else
refer... | true |
907f28ce6c9b5c9ecf86c1908e5ab63a51108633 | Ruby | jlanders68/rvm_fw | /lib/tasks/bootstrap.rake | UTF-8 | 2,829 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'yaml'
namespace :boot do
task :strap do
# Set common directory paths as variables for quick referencing
app_root = File.expand_path("../../..", __FILE__)
rubies_dir = File.expand_path("../../../public/rubies", __FILE__)
# Delete the 'public/rubies' directory to ensure we only download R... | true |
659a8cde3859017e83534bea623e7749f0142063 | Ruby | mistermayo/find_and_replace | /lib/word_changer.rb | UTF-8 | 550 | 2.875 | 3 | [] | no_license | class String
define_method(:word_changer) do | search, replace |
if self.include?(search)
sentence = self.split(search)
if sentence.length == 0
sentence = ["",""]
elsif sentence.length == 1
sentence.push("")
end
sentence.join(replace)
else
... | true |
662ebfe40312b71a6adebf3a43a4db9c37705612 | Ruby | amyaturner/ls_rb_101_programming_foundations | /small_problems_exercises/documentation_again/09.rb | UTF-8 | 586 | 2.78125 | 3 | [] | no_license | #9
# On docs.ruby-lang.org, YAML search turns up this page:
# https://docs.ruby-lang.org/en/2.6.0/YAML.html
# which says YAML module is an alias of Psych.
# When you click the link for Psych from that YAML Module page, you find the ::load_file method there.
# Found 'Psych.load_file' at docs.ruby-lang.org
# https://d... | true |
c3852cc55166e1d39449333ce65f1e21306c5852 | Ruby | tchiu2/stock-portfolio-server | /app/controllers/transactions_controller.rb | UTF-8 | 1,228 | 2.515625 | 3 | [] | no_license | class TransactionsController < ApplicationController
def index
transactions = Transaction.history(current_user)
render_resources(transactions)
end
def create
transaction = TransactionBuilder.build(transaction_params, current_user.id)
total_amount = transaction.quantity * transaction.price
po... | true |
e594cc9e03b09f39d9a51959dbcba7671be6450e | Ruby | cornell-brg/pydgin-parc-xcc | /scripts/longcheck-summary.rb | UTF-8 | 3,135 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env ruby
#=========================================================================
# check-summary.rb [options] <build-dir>
#=========================================================================
#
# -h --help Display this message
# -v --[no-]verbose Verbose mode
#
# Creates a summary of the ... | true |
1a71d66493b71d8b356aa69da4c84c5ac578be66 | Ruby | JuanToanXoup/ruby-oo-relationships-practice-blood-oath-exercise-hou01-seng-ft-071320 | /lib/follower.rb | UTF-8 | 1,023 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Follower
attr_accessor :name, :age, :life_motto
@@all = []
def initialize(name,age,life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def join_cult(cult)
BloodOath.new(cult,self,"YYYY-MM-DD")
end
def cults
B... | true |
e7c3f743ba559c0826f7285fc7c7a3488f4e420d | Ruby | kyang6/HTThrive | /CSVScripts/hypertension_getter.rb | UTF-8 | 3,728 | 3.046875 | 3 | [] | no_license | require 'csv'
# Number of people to grab
people_limit = 1000
# returns people that have followed high blood pressure or hypertension or have had a consult regarding high blood pressure
CSV.open("./hypertension.csv","wb") do |csv|
csv << ["First Name", "Last Name", "Gender", "Email", "State", "City", "Birthday", "... | true |
5a249e5249fefc15f10033f88507cee5956d4052 | Ruby | Benabik/smile | /lib/smile/param_converter.rb | UTF-8 | 1,444 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Smile::ParamConverter
module_function
# Pre-load the cache with exceptions
@cache = {
:exif => :EXIF,
:geo_album => :geoAlbum,
:geo_all => :geoAll,
:geo_community => :geoCommunity ,
:geo_keyword => :geoKeyword,
:geo_search => :geoSearch,
:geo_user => :geoUser,
:nickname =... | true |
81e0bde75b14d79edb2e0e5b402d5451c1427ec8 | Ruby | allanizzo/project_euler_problems | /24_lexicographic_permutations.rb | UTF-8 | 855 | 4.4375 | 4 | [] | no_license | # time taken < 5 mins
# you got lucky, that ruby has .permutation which returns lexicographic order
# SOLVED
# should do this without the .permutation method
# A permutation is an ordered arrangement of objects.
# For example, 3124 is one possible permutation of the
# digits 1, 2, 3 and 4. If all of the permuta... | true |
a43c29eca33eed56c98469aa7810df8d3e136b9b | Ruby | Lodi2244/stall | /lib/stall/product_filters/builder.rb | UTF-8 | 1,514 | 2.625 | 3 | [
"MIT"
] | permissive | module Stall
module ProductFilters
class Builder
attr_reader :products, :options
def initialize(products, options = {})
@products = products
@options = options
end
def filters
(
[
category_filter,
manufacturer_filter,
... | true |
a3f3800b0b20cb5fa0aa568ad2b742a9807cacde | Ruby | olliecoker/amadeus-ruby | /lib/amadeus/namespaces/shopping/flight_destinations.rb | UTF-8 | 991 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Amadeus
module Namespaces
class Shopping
# A namespaced client for the
# +/v1/shopping/flight-destinations+ endpoints
#
# Access via the +Amadeus::Client+ object
#
# amadeus = Amadeus::Client.new
# amadeus.shopping.flight_destinat... | true |
669a40573ee5c784196fba7932cf06833414f2d1 | Ruby | indisaurusrex/ruby-practice | /scrab.rb | UTF-8 | 709 | 4 | 4 | [] | no_license | # Create a hash with the points using integers as the keys
# Ask for a word
# split the word into letters
# return the points for each letters
# add them together
points = {
:"0" => [" "],
:"1" => ["E", "A", "I", "O", "N", "R", "T", "L", "S", "U"],
:"2" => ["D", "G"],
:"3" => ["B", "C", "M", "P"],
:"4" => ["... | true |
56d22c637dcfcbccaaf4ebaf8f10f3236f6b1fc3 | Ruby | imrobinkim/EVENT-ation | /app/models/user.rb | UTF-8 | 1,134 | 2.5625 | 3 | [
"MIT"
] | permissive | class User < ApplicationRecord
has_many :events_guests, foreign_key: 'guest_id'
has_many :events, through: :events_guests
has_many :events, foreign_key: 'host_id'
has_many :interests, through: :events
has_many :guests, class_name: 'EventsGuest', foreign_key: 'guest_id'
has_secure_password
validates :use... | true |
3d4f3fc537a87024ff6add7c25abc9a112b6813b | Ruby | red-data-tools/red-datasets | /lib/datasets/afinn.rb | UTF-8 | 1,272 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "csv"
require_relative "zip-extractor"
module Datasets
class AFINN < Dataset
Record = Struct.new(:word,
:valence)
def initialize
super()
@metadata.id = "afinn"
@metadata.name = "AFINN"
@metadata.url = "http://www2.imm.dtu.dk/pubdb/pubs/6010-full.html"
... | true |
54ee2612612af7b3db04333eabe1193856a1ab92 | Ruby | johnrails/Fatsecret | /spec/connection/conection_spec.rb | UTF-8 | 2,188 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe FatSecret::Connection do
describe "Sting method" do
it "should correctly format a sring" do
"foo~bar baz".esc.should eq "foo~bar%20baz"
end
end
describe "initialze" do
it "should throw an error if api_keys aren't set" do
expect {FatSecret::Connection.n... | true |
785de7a6d2f1d1cfd2f147a4230f6f9d204a60eb | Ruby | ncalibey/Launch_School | /120_object_oriented_programming/lesson_03/easy_01/easy_110.rb | UTF-8 | 239 | 3.421875 | 3 | [] | no_license | # easy_110.rb
class Bag
def initialize(color, material)
@color = color
@material = material
end
end
# the `Object#new` method (make sure to specify the arguments)
Bag.new("Reasors", ['apple', 'diapers', 'coffee'])
| true |
eb7005021b21fb6e37e2e058211a519f8534987a | Ruby | saboyutaka/private-isu-201808 | /webapp/ruby/export_images.rb | UTF-8 | 1,289 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'mysql2'
def config
@config ||= {
db: {
host: ENV['ISUCONP_DB_HOST'] || 'localhost',
port: ENV['ISUCONP_DB_PORT'] && ENV['ISUCONP_DB_PORT'].to_i,
username: ENV['ISUCONP_DB_USER'] || 'root',
password: ENV['ISUCONP_DB_PASSWORD'],
database: ENV['ISUCONP_DB_NAME'] || 'isuconp',
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.