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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
480757490fc442a1a8fdeb6f8a8e99bf3419d1c4 | Ruby | chmellado/animales-felices | /lib/tasks/seed_appoiments.rake | UTF-8 | 30,219 | 2.515625 | 3 | [] | no_license | # require 'ffaker'
# require 'awesome_print'
# Appointment.where('created_at > ?', (Time.now - 1.hour)).delete_all
task :seed_appoinments => :environment do
# puts "hello"
# services = Service.all
# specialist_ids = Specialist.pluck(:id)
# service_size = services.size
# specialist_size = specialist_ids.siz... | true |
4055581dca71df6086a2096999a31eaf8b54129c | Ruby | pradtv/projecteuler-ruby | /005-smalldivnum.rb | UTF-8 | 168 | 3.15625 | 3 | [] | no_license | class Fixnum
def divall?
x= self
(1..20).each do |i|
return false if x % i !=0
end
true
end
end
puts (1..232792561).select(&:divall?).min | true |
dc3c5fab9879023529b2c4ed6426aa7d3d32d24f | Ruby | svvchen/The-Odin-Project | /pokemon_battle.rb | UTF-8 | 5,484 | 4.28125 | 4 | [] | no_license | # create a pokemon class
class Pokemon
def initialize(name)
@name = name
end
# all accessors
attr_accessor :fainted, :type, :health, :name, :speed
# pokemon can take damage, faint, or deal damage
def faint
self.fainted = true
end
def take_damage(damage)
@health = @health - damage
if... | true |
34149c1d9ecfc6818369a374190cc443c9a4d000 | Ruby | saylerb/black_thursday | /lib/sales_engine.rb | UTF-8 | 3,138 | 2.984375 | 3 | [] | no_license | require "csv"
require_relative "merchant_repo"
require_relative "item_repo"
require_relative "invoice_repo"
require_relative "invoice_item_repo"
require_relative "transaction_repo"
require_relative "customer_repo"
class SalesEngine
attr_accessor :merchants,
:items,
:invoices,
... | true |
32f42103a007a241432a0f465f5f635681c2e6e0 | Ruby | juanpsainzg/railsApp | /MisAppsDeEntrenamiento/D_ArchivosCSV/csv_reader.rb | UTF-8 | 272 | 2.609375 | 3 | [] | no_license | require 'csv'
require_relative '../C_LectorDeArchivos/file_reader'
class CsvReader < FileReader
#No necesitamos initialize por que estamos eredando el de file_reader
def read
puts 'Leyendo un csv'
contents = CSV.read(@file)
puts contents
end
end
| true |
a0828ca20c3677bac1c4b703b958225d302b86b5 | Ruby | kanpou0108/launchschool | /Exercises/101-109_small_problems/medium_2/q03_revised.rb | UTF-8 | 1,449 | 4.3125 | 4 | [] | no_license | def letter_percentages(strings)
count_hash = { lowercase: 0, uppercase: 0, neither: 0 }
strings.chars.each do |elem|
case elem
when /[a-z]/
count_hash[:lowercase] += 1
when /[A-Z]/
count_hash[:uppercase] += 1
when /[^a-zA-Z]/
count_hash[:neither] += 1
end
end
sum = 0.0
... | true |
6fa4a41aa3f6e2569df6a2068a556579cdb280c4 | Ruby | dgrebenyuk/courses | /Ruby/Lecture1/hw_results/student_8.rb | UTF-8 | 192 | 2.78125 | 3 | [] | no_license | my_hash = {"yes"=>23, "b"=>"travel", "yesterday"=>34, 5=>"234", :yesss=>:fg, try: 30, key: "some value", "yesterday"=>34, "yesteryear"=>2014}.keys
my_hash.find_all{|key| key =~ /^yes/}.size
| true |
f580b2c28ec9533e67e1247b884f53c983d501ce | Ruby | everaldobass/cursos-digitalinnovation.one | /curso-ruby/Tipo-variaveis/3.4-condicionais.rb | UTF-8 | 391 | 3.75 | 4 | [] | no_license | # Condicionais
# == igualdade
# != Diferente
# > Maior que
# >= Maior ou igual
# < Menor que
# < Menor ou igual
valor = 20
if valor > 50
puts "Valor maior que 50"
else
puts "Valor menor que 50"
end
# ! negação
# && and
# || or
# Apenas nil e false
#unless Condicao
# faca_isso
#end
# Ternari... | true |
608fcbe31b67a96af26cbb4ec4b052a83811946f | Ruby | alainravet/gitloop | /lib/gitloop/git_utils.rb | UTF-8 | 792 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Gitloop
module GitUtils
def current_branch
branch = `git branch | grep "*"`
branch.empty? ?
nil :
branch[2..-2] # remove the current branch marker : '* '
end
def invalid_commits_sequence?(first_sha, second_sha)
output = (first_sha == second_sha) ?
call_... | true |
e2fdad2ead619ecc1cc0095776827661789a2610 | Ruby | aldinh777/ruby-http-server | /lib/addons/erb_session.rb | UTF-8 | 1,238 | 2.671875 | 3 | [] | no_license | class ErbSession
attr_accessor :path
def self.random long = 64
random = ''
(0...long).each { random << rand(36).to_s(36) }
return random
end
def initialize rbid
if rbid == nil or not Dir::exist?(__dir__+"/../../tmp/session/#{ rbid }") then
random = ErbSession::random
... | true |
9f7ba91c2023cfc285b6f0da0d75cff37b985b25 | Ruby | ChristieRenaud/launch-school-course-101 | /small_problems/Medium/medium_2_6.rb | UTF-8 | 447 | 3.515625 | 4 | [] | no_license | def triangle(angle_a, angle_b, angle_c)
angles = [angle_a, angle_b, angle_c]
case
when angles.inject(:+) != 180 || angles.any?{ |x| x <= 0 }
:invalid
when angles.include?(90)
:right
when angles.all? { |x| x < 90 }
:acute
else
:obtuse
end
end
p triangle(60, 70, 50) #== :acute
p triangle(30... | true |
b429c04df03da006ac5ac57149fc890acf3fc3cd | Ruby | ryreitsma/movie_graph | /app/services/omdb/acted_in_creator.rb | UTF-8 | 713 | 2.640625 | 3 | [] | no_license | module Omdb
class ActedInCreator
def self.perform
Movie.find_each(batch_size: 500) do |movie|
import_actors(movie)
end
end
private
def self.import_actors(movie)
return if movie.actors.length > 0
begin
movie_json = ApiService.get_movie_by_title(movie.title)
... | true |
9de70025d37eec3cd1fdde91969c7ef50b5cff3a | Ruby | iSunRise/formula-parser | /formulas.rb | UTF-8 | 2,901 | 3.203125 | 3 | [] | no_license | require 'tmpdir'
require 'digest'
require 'json'
# Renders expression to PNG image using <tt>latex</tt> and
# <tt>dvipng</tt>
# returns array to images
def formula_to_png(formulas, background = 'White', density = 700)
arr_images = []
temp_path = Dir.mktmpdir
Dir.chdir(temp_path) do
formulas.each do |formula|... | true |
55d9a001ec5e34f21dabbeed0156f57cd4c9a44a | Ruby | sachin1mg/thanos | /app/services/procurement_module/purchase_order_manager.rb | UTF-8 | 1,450 | 2.5625 | 3 | [] | no_license | require 'csv'
module ProcurementModule
class PurchaseOrderManager
attr_accessor :purchase_order
def initialize(purchase_order)
self.purchase_order = purchase_order
end
#
# This method creates only bulk POs
#
def self.create!(user: , params:)
vendor = user.vendor
purch... | true |
166997ac297f144d88039c91cb5eeb91cf167a03 | Ruby | matp/cryptopals | /challenges/challenge_11.rb | UTF-8 | 620 | 2.734375 | 3 | [
"Unlicense"
] | permissive | require_relative 'challenge'
# Challenge 11: An ECB/CBC detection oracle
class Challenge11 < Challenge
def test_an_ecb_cbc_detection_oracle_ecb
is_ecb = Cryptanalysis::ECB.detection_oracle(16) do |input|
cipher = Cipher::AES_128_ECB.new
cipher.encrypt(String.random(5..10) << input << String.random(5... | true |
82c9105ac0e4180ca8580c6c1f4db7eecefeb435 | Ruby | josefsalyer/demo-1 | /demo/session_dump_and_load.rb | UTF-8 | 1,656 | 2.734375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'aviator'
require 'pp'
session1 = Aviator::Session.new(
config_file: Pathname.new(__FILE__).join('..', '..', 'aviator.yml').expand_path,
environment: :demo,
log_file: Pathname.new(__FILE__).join('..', '..', '... | true |
e1040fa5eb943af816205a03d3012a473b71031d | Ruby | sifo/hackerrank | /ruby/strings/methods.rb | UTF-8 | 129 | 2.984375 | 3 | [] | no_license | # https://www.hackerrank.com/challenges/ruby-strings-methods-i/problem
def process_text(a)
a.map{ |s| s.strip }.join(' ')
end
| true |
095361c8b56a498e4564fb7c6e82487ecb8ffdda | Ruby | JonJarGaa/intro-to-ruby-book | /9_exercises/9_4_append_prepend_array.rb | UTF-8 | 567 | 4.5625 | 5 | [] | no_license | # Append 11 to the end of the original array. Prepend 0 to the beginning.
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
array << 11
array.unshift(0)
p array
=begin
BOOK SOLUTIONS:
# Append
arr.push(11)
# --- or ---
arr << 11
# Prepend
arr.unshift(0)
-----------------------------
NOTES FROM RUBY ARRAY DOC:
'un... | true |
5e1f7dbaaa5e842c869f1f638d50c59765f26005 | Ruby | unet-echelon/by_of_python_lesson | /git_clone/googprog/lesson9/masiv_take.rb | UTF-8 | 110 | 3.4375 | 3 | [] | no_license | masiv = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
puts "число"
number = gets.to_i
puts masiv.take(number).to_s
| true |
1657289bbcf27e5cb468593483de626d4db2f4ac | Ruby | G5/dxa-automation-script | /derClasses/splashClass1.rb | UTF-8 | 3,370 | 2.84375 | 3 | [] | no_license | require '../testClasses/testClass1'
class SplashTest < TestClass
def initialize(requirements, selDriver, nokoPage, scoreCoeff, testNam, fileNam=:DEFINED, logFil=:DEFINED, urlName=:DEFINED, bizNam=:DEFINED, gPlusI=:DEFINED, allLink=:DEFINED, zipCod=:DEFINED)
super(requirements, selDriver, nokoPage, scoreCoeff,... | true |
44e9b0450756d4d47965948aacc1d7dcef7b4b8e | Ruby | Cinderhaze/adventofcode | /2015/1/Day1.rb | UTF-8 | 1,104 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'getoptlong'
class Day1
attr_reader :input, :floor, :in_basement
def initialize(input)
@input = input
@floor = 0
@in_basement = Array.new
end
def path()
count = 1
@input.each_char { |c|
case c
when '(' then @floor +=1
when ')' then @floo... | true |
44c5e1315b939af5b614be101726c7322a92d73f | Ruby | rasensio1/Robodoku | /Solver.rb | UTF-8 | 2,927 | 3.5625 | 4 | [] | no_license | require './board'
require 'pry'
class Solver # => nil # => nil
def initialize(puzzle)
@input_file = File.open("./#{puzzle}", "r") # ~> Errno::ENOENT: No such file or directory @ rb_sysopen - ./input.txt
@output_file = File.open("./output.txt", "w")
@input = []
@rows = []
@col... | true |
2fee23c84bbb045d9a6af0db75896067206e9c86 | Ruby | EricHype/automonventure | /lib/automonventure/screens/play_screen.rb | UTF-8 | 340 | 3.015625 | 3 | [
"MIT"
] | permissive | require_relative "screen"
module Automonventure
class PlayScreen < Screen
def render()
screenText = "You are in a dark cubicle"
puts screenText
end
def process()
input = gets.chomp
case input
when "EXIT"
return "EXIT"
else
return "INVALID"
en... | true |
f98a91220920a88ce707db0dbb83db8589ff019d | Ruby | dantgn/hotelzz | /app/services/hotels/calculate_rent.rb | UTF-8 | 1,746 | 3.34375 | 3 | [] | no_license | # frozen_string_literal: true
module Hotels
class CalculateRent
def initialize(room_type:, check_in:, check_out:, currency: 'usd')
@room_type = room_type
@check_in = check_in
@check_out = check_out
@currency = currency
end
def call
"#{total_rent} #{@currency}"
end
... | true |
52de67a56798c9de617cb109a40631a1c70e514c | Ruby | rosylilly/dicer | /spec/support/entity.rb | UTF-8 | 531 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'securerandom'
class Entity
include Dicer::Contextable
def initialize(data)
@id = SecureRandom.hex
data.each_pair do |key, val|
instance_variable_set(:"@#{key}", val)
if key.to_s != 'id'
(class << self; self; end).class_eval(<<-EOF)
def #{key}
@#{key}
... | true |
2c640c155a28313aded7c40e15115dd901904205 | Ruby | VirtuosoJoel/forecasts | /app/models/user.rb | UTF-8 | 1,938 | 3 | 3 | [] | no_license | require 'open-uri' # Get data from API
require 'json' # Interpret data from API
require 'uri' # Escape location String
# User class, logged in database
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
# User attributes... | true |
7a31f902d09b9dc0481f773a998ffe3b90f16887 | Ruby | jmettraux/ruote | /lib/ruote/part/storage_participant.rb | UTF-8 | 13,989 | 2.53125 | 3 | [
"MIT"
] | permissive | #--
# Copyright (c) 2005-2013, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy... | true |
4569d08eab158688faa017e8820e1b24dd601a19 | Ruby | chrisftw/PickleJar | /pickle_jar_test.rb | UTF-8 | 1,567 | 3.046875 | 3 | [] | no_license | require 'pickle_jar'
require 'simple_test'
PJ = PickleJar
ST = SimpleTest
ST.testing "PickleJar should namecase all names"
ST.e( PJ.namecase('AARON'), 'Aaron')
ST.e( PJ.namecase('bILLY bOb'), 'Billy Bob' )
ST.e( PJ.namecase('WooT'), 'Woot' )
ST.e( PJ.namecase('all lower'), 'All Lower' )
ST.testing "PickleJar should ... | true |
e9018787cd73e24646a018d2ed59d12dc6ff6788 | Ruby | raven1989/UnderstandingComputation | /6_UntypedLambdaCalculus/LCmain.rb | UTF-8 | 3,230 | 2.859375 | 3 | [] | no_license | require_relative 'LambdaCalculus'
require 'treetop'
puts '---------------------------------Grammar---------------------------------------'
one = LCFunction.new(:p,
LCFunction.new(:x,
LCCall.new(LCVariable.new(:p), LCVariable.new(:x))
)
)
puts one.inspect
increment = LCFunction.new(:n,
LCFunction.ne... | true |
ac5658487b23e96c87e7849851b68b423ca274ec | Ruby | jrbennyboy11/project_euler | /problem62.rb | UTF-8 | 537 | 3.46875 | 3 | [] | no_license | def get_digit_array(num)
arr = [0,0,0,0,0,0,0,0,0,0]
num.to_s.each_char{|c| arr[c.to_i]+=1}
return arr
end
beginning_time = Time.now
num_times = Hash.new(0)
lowest_val = Hash.new(0)
found = false
i = 0
while(!found)
i += 1
currArr = get_digit_array(i**3)
num_times[currArr] += 1
if lowest_val[currArr] == 0... | true |
2195d793373c4dd60815e15f583ee209884aa86d | Ruby | semmons99/ruby-euler | /prob029.rb | UTF-8 | 113 | 3.3125 | 3 | [] | no_license | nums = Array.new
2.upto(100) do |a|
2.upto(100) do |b|
nums.push(a**b)
end
end
puts nums.uniq.length
| true |
31dfff8283b5076af2b5329cdb4db311def75bbf | Ruby | Zimbra/zm-genesis | /src/ruby/action/verify.rb | UTF-8 | 4,696 | 2.5625 | 3 | [] | no_license | #!/bin/env ruby
#
# $File$
# $DateTime$
#
# $Revision$
# $Author$
#
# 2007 Zimbra
#
#
# Part of the command class structure. Verify class does response validation
#
if($0 == __FILE__)
$:.unshift(File.join(Dir.getwd,"src","ruby")) #append library path
end
require 'action/command'
require 'yaml'
module Action # :n... | true |
e2d164a84e74faf429bec32ab198ae820b1f22ba | Ruby | nappa/atcoder | /ABC139/d.rb | UTF-8 | 70 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby --disable-gems -w
N = gets.to_i
puts (N-1)*N/2
| true |
6724731c6ceff9c264cf619b2163799480944552 | Ruby | DmitryLogunov/files-validation | /sinatra/app/use_cases/upload_resources/validator.rb | UTF-8 | 16,675 | 2.703125 | 3 | [] | no_license | module UploadResourcesValidator
module_function
def validate(attribute, value, type_resource)
# формат валидатора - массив [тип данных, [группы символов...], доп. параметры...]
# типы данных:
# string - строка
# date - дата
# phone - телефон
# vin - формат VIN номера, регулярка: /^[... | true |
85b53f849382bcf45ae3302043561c99f4f50e1b | Ruby | IgnesFatuus/Intro_to_Ruby | /Intro_to_Ruby_ls/Exercises/ch1_stuffs/ch1_exrse.rb | UTF-8 | 95 | 2.53125 | 3 | [] | no_license | movies = Hash.new{
m1: 1975,
m2: 2006,
m3: 2001,
m4: 1964
}
movies.each{ |x, y| puts y} | true |
5af0eeb60894bf60e0d0931ab91ebc2f7799ee7a | Ruby | hilings/leetcode | /ruby/022.rb | UTF-8 | 567 | 3.65625 | 4 | [] | no_license | # 022
# Generate Parentheses
# 2015-04-29
#####################################################
# @param {Integer} n
# @return {String[]}
def generate_parenthesis(n)
v = []
return v if n == 0
v.push("(")
while v.first.size < 2*n
s = v.shift
l = r = 0
s.each_char do |c|
if c == "("
l+=1... | true |
dab44acdf80d60b0f2eae22891914eb4e660b5bb | Ruby | raucao/liquid_interface | /app/models/issue.rb | UTF-8 | 561 | 2.6875 | 3 | [] | no_license | class Issue
include Mongoid::Document
field :original_id, :type => Integer
field :state, :type => String
field :population, :type => Integer
field :area, :type => String
index :original_id
index :state
index :population
embeds_many :initiatives
def finished?
state == "fi... | true |
ce09cec6be8ebd1b94b3235d7384e35dd47c0e3a | Ruby | emacip/order_jobs_tdd | /lib/jobparser.rb | UTF-8 | 205 | 2.578125 | 3 | [] | no_license | class JobParser
def self.parse(job_spec)
job_spec.split("\n").inject(Hash.new){ |acc, spec_line|
j = Job.new(*spec_line.split('=>').map(&:strip))
acc[j.name] = j
acc
}
end
end | true |
2d23d2f0d5159f6d1798cd2706018cfd464b1e32 | Ruby | chantal66/calendar-exercise | /lib/calendar_client/meeting.rb | UTF-8 | 1,245 | 2.890625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../helpers/calendar_helper'
module CalendarClient
# Returns a meeting object
class Meeting
include CalendarHelper
attr_reader :name, :duration, :type
attr_accessor :start_time
def initialize(params = {})
raise StandardError unless valid?(p... | true |
d7bcd117b406b41231a70889995de1ca2e45d05b | Ruby | homesettler/Ruby-study | /1.Ruby语法/4.HereDocument.rb | UTF-8 | 791 | 3.15625 | 3 | [] | no_license | #!/usr/bin/ruby -w
# -*- coding: UTF-8 -*-
print <<EOF
这是第一种创建here document
多行字符串
EOF
print <<"EOF"; #与上面相同
这是第二种方式创建here document
多行字符串
EOF
print <<`EOC` #执行命令
echo hi there
echo lo there
EOC
print <<"foo", <<"bar" #可以把它们进行堆叠
... | true |
744fbccbb04a2ff5f793e2abeec914e2d5d76344 | Ruby | k-ankobia/Middle_Character | /spec/middle_letter_spec.rb | UTF-8 | 471 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
require 'middle_letter'
describe MiddleLetter do
subject(:character) { described_class.new }
describe '#get_middle' do
context 'even characters ' do
it 'can find the middle character of word' do
expect(character.get_middle('test')).to eq 'es'
end
end
... | true |
b031bc0432ad7a995fc9e4f45ba53dba08266c2c | Ruby | dsipakou/moviedb | /lib/imdb_parser.rb | UTF-8 | 3,832 | 2.6875 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class IMDB
POSTER_XPATH = "//div[@class='image']/a[contains(@href, 'media')]/img[@itemprop='image']"
DIRECTOR_XPATH = "//h4[contains(text(), 'Directed by')]/following::table[1]//a[contains(@href, 'name')]"
DIRECTOR_SERIES_XPATH = "//a[text()='Series Directed by']/../../../... | true |
de81b2e95db236681d196b1c0ba00e25fd75163a | Ruby | oscarandres31/reposcar | /products.rb | UTF-8 | 461 | 2.75 | 3 | [] | no_license | products = [
{ id:1, name: "leche", precio: 120,categories: [ "familiar", "comida" ] },
{ id:2, name: "Arroz", precio: 1400, categories: [ "familiar", "comida" ] },
{ id:3, name: "lavadora", precio: 5000, categories:["electrodomesticos"]}
]
products.each do |product|
puts product[:name ]
puts " id: #{p... | true |
9744a6bf28af245e1234b454d5ab741cfc3d20a3 | Ruby | olivernn/weather | /app/mappers/location_mapper.rb | UTF-8 | 446 | 2.859375 | 3 | [] | no_license | class LocationMapper < BaseMapper
def to_h
{
ref: fetch_int('i'),
lat: fetch_float('lat'),
lng: fetch_float('lon'),
name: fetch_title('name'),
country: fetch_title('country'),
continent: fetch_title('continent'),
}
end
private
def fetch_float(key)
raw.fetch(key)... | true |
0d9b841fdba9a12952bbd7e2089af09e8e8d5265 | Ruby | bsingr/opal | /spec/language/regexp_spec.rb | UTF-8 | 788 | 2.75 | 3 | [
"MIT"
] | permissive |
describe "Regexp literals" do
# ===========================================================================
# = Back-refs =
# ===========================================================================
it "saves match data in the $~ pseudo-glo... | true |
970d77fabe82ba72db387f3d99be563f91f2ee3d | Ruby | UbuntuEvangelist/therubyracer | /vendor/cache/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/enumerable/take_last.rb | UTF-8 | 522 | 3.75 | 4 | [
"MIT"
] | permissive | unless Enumerable.method_defined? :take_last
module Enumerable
# Take the last n elements of an enumerable.
#
# @param n [Fixnum] the number of elements to take
# @return [Array] an array containing the requested elements
#
# @example
# [1, 2, 3].take_last(2) #=> [2, 3]
# [].take_l... | true |
ef8a0d1a0cf56bd7e98629841fbab592ea3a1ba5 | Ruby | wstevo4891/twain | /db/seeds/people_locations.rb | UTF-8 | 1,350 | 2.65625 | 3 | [] | no_license | # Roles
# =========================================================
puts 'Deleting old Roles...'
Role.delete_all
puts 'Loading Roles...'
roles = load_yaml('roles')
puts 'Creating Roles...'
roles.each do |role|
puts "Creating role: #{role['name']}"
Role.create!(role)
end
puts 'Roles created!'
# Regions
# =====... | true |
3557d0c34792f8d0beea7bdf08f36343e17a7a5c | Ruby | ashishra0/codewars | /lib/6kyu/autocomplete.rb | UTF-8 | 288 | 3.046875 | 3 | [] | no_license | def autocomplete(input, dictionary)
input = input.scan(/[A-Za-z]/i).join
matches = []
default = dictionary.first(5)
dictionary.each do |word|
matches.push(word) if word.downcase.start_with?(input) && !input.empty?
end
return default if input.empty?
matches.take(5)
end
| true |
6a88e6e2a4e61b0bef5479f678b2d321dc68eb83 | Ruby | taw/magic-search-engine | /search-engine/lib/format/format_brawl.rb | UTF-8 | 3,546 | 3.03125 | 3 | [
"MIT"
] | permissive | class FormatBrawl < FormatStandard
def format_pretty_name
"Brawl"
end
def deck_issues(deck)
[
*deck_size_issues(deck),
*deck_card_issues(deck),
*deck_commander_issues(deck),
*deck_color_identity_issues(deck),
]
end
def deck_size_issues(deck)
issues = []
if deck.nu... | true |
8f2864707eb9ec9af25b269115ae929d1d8656a6 | Ruby | moofia/media-sorter | /lib/media-sorter-http.rb | UTF-8 | 1,006 | 2.859375 | 3 | [] | no_license | # returns a xml of the url to get via a proxy
def http_get_via_proxy(url)
log("http get via proxy : #{url}") if $opt["debug"]
begin
proxy = ENV['http_proxy']
proxy_host, proxy_port = proxy.gsub(/^http:\/\//,'').split(/:/)
myurl = URI.parse(url)
req = Net::HTTP::Get.new(myurl.request_uri)
res= Ne... | true |
0551a9fae4ba54d587ef9549272f8d058ff2352f | Ruby | MC4517/ExoRuby | /exo_07.rb | UTF-8 | 121 | 3.421875 | 3 | [] | no_license | puts "Je compte jusqu'à combien ?"
print ">"
number = gets.chomp
number.to_i.times do |i|
puts i + 1
end
| true |
edf5f5c3a1de8c0739c41936c5e4bc5eddbbbddc | Ruby | scorp200/Open-Sweeper-Ruby | /app/lib/font.rb | UTF-8 | 399 | 2.75 | 3 | [
"MIT"
] | permissive | # this is only for the very specific png font file. and should not be used anywhere else.
# until this is expanded to work with any font.png file
class Font
def self.draw_letter letter
@@letter = {}
10.map_with_index do |i|
@@letter["#{i}"] = [i * 12, 0, 12, 20]
end
@@letter["?"] = [10 * 12, 0, 12, 20]
return... | true |
b5325a24579675d41684609afeee7d7663229a9f | Ruby | SilverPhoenix99/ducktape | /lib/ducktape/bindable_attribute.rb | UTF-8 | 2,439 | 2.8125 | 3 | [
"MIT"
] | permissive | module Ducktape
class InvalidAttributeValueError < StandardError
def initialize(name, value)
super("value #{value.inspect} is invalid for attribute #{name.to_s.inspect}")
end
end
class BindableAttribute
include Hookable
attr_reader :owner, # Bindable
... | true |
4100e09401bf9e3dc593e877fc276c803386acc3 | Ruby | r3drighthand/challenges | /design-drill-classical-inheritance/superpowers.rb | UTF-8 | 253 | 2.640625 | 3 | [] | no_license | module SuperPowers
def telepathy
puts "I can hear your thoughts!"
end
def super_speed
puts "ZOOM"
end
def unicorn_breath
puts "What is that pleasant odor?"
end
def pyrokinesis
puts "Oh my god, it's on fire!"
end
end
| true |
c7e8d8998b7c95cbbe172c9f7895f222572b89e5 | Ruby | amandaungco/VideoStoreAPI | /test/models/movie_test.rb | UTF-8 | 2,822 | 2.828125 | 3 | [] | no_license | require "test_helper"
#Validate only those fields that, if they are absent, will break your API.
describe Movie do
let(:harry) { movies(:movie2)}
let(:norents_movie) { movies(:movie3)}
it "must be valid" do
expect(harry).must_be :valid?
end
describe "relations" do
it "has many customers" do
ha... | true |
888730e7f2b48b03c90bdeb53b7801f31edd84b8 | Ruby | jalil/ruby_scripts | /cnn_rss_parser.rb | UTF-8 | 999 | 2.734375 | 3 | [] | no_license | require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
#source = "http://rss.cnn.com/rss/cnn_us.rss"
content = ""
cnn = %w(
http://rss.cnn.com/rss/cnn_topstories.rss
http://rss.cnn.com/rss/cnn_world.rss
http://rss.cnn.com/rss/cnn_us.rss
)
threads = []
for page in cnn
threads << Thread.new(page) { |my_page|
... | true |
1c0ba12520adddf881cdc3c4c8de7b2e3ba7de2f | Ruby | dphilla/module_3_diagnostic | /app/services/station.rb | UTF-8 | 672 | 2.828125 | 3 | [] | no_license | class Station
attr_reader :name,
:address,
:fuel_types,
:distance,
:access_times
def initialize(parsed)
@name = parsed["station_name"]
@address = parsed["street_address"]
@fuel_types = parsed["fuel_type_code"]
@distance = pa... | true |
71e7e21ffacc96db693b9b79a2f7deca8b744da6 | Ruby | trizen/sidef | /scripts/RosettaCode/loops_downward_for.sf | UTF-8 | 117 | 2.734375 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Loops/Downward_for
#
for (var i = 10; i >= 0; i--) {
say i;
}
| true |
a4d6ad09ba925599d3795de2dc4fc9ab81ff121e | Ruby | eintracht-stats/eintracht-stats.github.io | /_plugins/DateFilter.rb | UTF-8 | 247 | 2.671875 | 3 | [
"MIT"
] | permissive | module DateFilter
MONTHS = %w(Januar Februar März April Mai Juni July August September Oktober November Dezember)
def german_long_month(input)
MONTHS[input.strftime("%m").to_i - 1]
end
end
Liquid::Template.register_filter(DateFilter)
| true |
b91746c973478c717f0e706f24588fc3a4045a9f | Ruby | postazure/Ruby-Practice | /Second Run/CH7_FTT-3_Leap_Year.rb | UTF-8 | 524 | 4 | 4 | [] | no_license | #Leap Years
# Criteria for a leap year:
# Divisable by 4
# Not divisable by 100 unless also Divisable by 400
puts "Starting Year"
s_year = gets.chomp.to_i
puts "End Year"
e_year = gets.chomp.to_i
(s_year..e_year).each do |i|
if i%4 == 0 #perfectly divisable by 4
if i%100 == 0 and i%400 ... | true |
3b9916e77596a2bbbd126ce66528e0be7ddb16da | Ruby | jszmajda/alice | /alice/util/testbotsy.rb | UTF-8 | 821 | 2.765625 | 3 | [
"MIT"
] | permissive | class Testbotsy
def initialize(config, &block)
@patterns = []
@running = true
return if ENV['RSPEC_RUN'] == 'true'
self.instance_exec([],&block)
Thread.new do
sleep 1
run
end
end
def hear(pattern, &block)
@patterns << [pattern, block]
end
def run
while @running
... | true |
dc09e73056778b6bf468987222a5b507a368cb0d | Ruby | torthawk/rof | /lib/rof/collection.rb | UTF-8 | 3,669 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'mime-types'
module ROF
# Called from ROF::Work.process_one_work
# Can assume type fobject, af-model Collection
class Collection
class NoFile < RuntimeError
end
def self.process_one_collection(input_obj, utility)
# set the required fields
result = set_required_fields(input_obj, ut... | true |
405c274f1f57a4156edc648281fcf2f3aca1781f | Ruby | de-wiring/wire | /lib/wire/model/validation.rb | UTF-8 | 2,108 | 2.96875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
# The MIT License (MIT)
# Copyright (c) 2014 Andreas Schmidt, andreas@de-wiring.net
#
# Wire module
module Wire
# raised in case of invalid model
class ValidationError
# +message+:: Validation Error message
# +element_type+:: Model element type of this error, i.e. 'Network'
# +ele... | true |
ca449986531e81989ab6e4382d5df01219ca3889 | Ruby | BJSummerfield/Prework | /prework/Episode26/exercise1.rb | UTF-8 | 313 | 3.734375 | 4 | [] | no_license | # Exercise: DON'T RUN THIS CODE! Instead, predict what it will do.
number = 3
jump = 3
10.times do
if number < 10
number = number + jump
jump = 2
elsif number > 10
number = number - jump
jump = 1
else
number = number * 2
jump = 3
end
p number
end
# 6,8,10,20,17,16,15,14,13,12 | true |
81a38b37e86989ac562d5a86c34a31a3670eba25 | Ruby | dsager/google-code-jam | /2014/quali/A/magic_trick.rb | UTF-8 | 738 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env ruby
# problem: https://code.google.com/codejam/contest/2974486/dashboard#s=p0
file_name = ARGV[0]
input = File.new(file_name, 'r')
input.gets.to_i.times do |n|
a1 = input.gets.to_i - 1
set1 = [
input.gets.split(' '),
input.gets.split(' '),
input.gets.split(' '),
input.gets.... | true |
76abbf016dacf6edb75c1db8f9b31ce0ed0c50bf | Ruby | GreenLantern16/mtls-ca-rotation-poc | /consul-template/scripts/process_pki_json.rb | UTF-8 | 2,086 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'openssl'
require 'fileutils'
class AuthManager
def initialize(pki_json_file_path:)
@pki_json_file_path = pki_json_file_path
end
def process
puts "###============== Output From Script Start ===============####"
puts " ... | true |
151d406a6534d932f1af3ba4ca5843d6697a4f17 | Ruby | hey-chan/tictactoe | /gem_sample.rb | UTF-8 | 3,967 | 3.6875 | 4 | [] | no_license | require "tty-cursor"
require 'dispel'
# cursor = TTY::Cursor
# puts "Lorem ipsum"
# puts "Misc"
# draw app and redraw after each keystroke
class TicTacToe
BOARD = <<BOARD
-------------------------
| | | |
| X | X | X |
| | | |
-------------------------
| | ... | true |
dfd7eef0d147b20864f565f91a167400bb80b507 | Ruby | nanokana/first_app | /samples/sample09_07.rb | UTF-8 | 53 | 2.640625 | 3 | [] | no_license | str = "abcdefg"
str.upcase
p str #=> "abcdefg"
| true |
a253549c1e6608f81f416521935c80629701dc58 | Ruby | yhshin0/python_ruby | /02. String/ruby4.rb | UTF-8 | 280 | 3.78125 | 4 | [] | no_license | # \ : 바로 뒤의 문자를 명령이 아닌 문자로 인식하게 함. escape라 부름.
puts("egoing's \"tutorial\"")
puts("\\")
puts("Hello\nworld")
puts("Hello\t\tworld")
# \a : 경고음 호출
puts("\a")
# \n은 싱글쿼터 안에서 사용 불가.
puts('Hello\nworld')
| true |
78fc7709ac138fe89942a47f9f47c0ae138f5e60 | Ruby | Invoca/parameter_substitution | /spec/lib/parameter_substitution/formatters/base_spec.rb | UTF-8 | 1,713 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../../../lib/parameter_substitution/formatters/base'
describe ParameterSubstitution::Formatters::Base do
context "Base formatter test" do
before do
@format_class = ParameterSubstitution::Formatters::Base
end
it "requires derived classes to implem... | true |
3655450472b3b9e2cb0570ae3cfee5a3549b4f34 | Ruby | wofockham/wdi-8 | /09-advanced/regular_expressions/ex2-6.rb | UTF-8 | 146 | 2.5625 | 3 | [] | no_license | # ruby matcher.rb simpsons.txt
ARGF.each do |line|
if (match = line.match /[ \t]+$/)
puts line.chomp + 'WS'
else
puts line
end
end
| true |
1069444e1e146958bd55a077f3541e152660e3c9 | Ruby | wolovim/turing_myth_creatures | /dragon.rb | UTF-8 | 299 | 3.421875 | 3 | [] | no_license | class Dragon
attr_reader :name, :color, :rider, :hunger
def initialize(name, color, rider)
@name = name
@color = color
@rider = rider
@hunger = true
@count = 0
end
def hungry?
@hunger
end
def eat
@count += 1
@hunger = false if @count >= 3
end
end
| true |
962abcb6f334cee9523aeb3ab187ac2cd682099a | Ruby | splebel/nagios-aws-cloudwatch | /check_elb_5xx | UTF-8 | 1,423 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'getopt/std'
require 'AWS'
$timeperiod = 300
http2xx = 0
http5xx = 0
warning = 8
critical = 10
access_key_id = ''
secret_access_key = ''
opt = Getopt::Std.getopts("c:w:k:s:")
if opt["c"]
critical = opt["c"].to_i
end
if opt["w"]
warning = opt["w"].to_i
end
if opt["... | true |
2ae1d5e500cab11391731f1f5125f19aaecf6652 | Ruby | Kmfisher13/Ruby-Basics | /strings/are_you_there.rb | UTF-8 | 485 | 4.375 | 4 | [] | no_license | # Using the following code, print true if colors 'yellow' and print false if
# it doesn't. Then, print true if colors includes the color 'purple' and print
# false if it does not.
colors = 'blue pink yellow orange'
puts colors.include?('yellow')
puts colors.include?('purple')
# Further exploration
# colors = 'blue ... | true |
1efdec9f9cbbe53a26d0de5d853f34ca2f227fc2 | Ruby | xhb/vmopt | /bin/vmpower | UTF-8 | 1,804 | 3.125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#encoding: utf-8
require "vmopt/power_operation"
require "optparse"
require "json"
option = {}
option_parser = OptionParser.new do | opts |
opts.banner = %q/
Help:
Description:
vmpower tool, use for system power management.
function:
1.shutdown
2... | true |
354ee330b0336b33c3cb2ab0e3a394d32df37568 | Ruby | PSzyszka/pairguru | /spec/services/movies/organize_spec.rb | UTF-8 | 3,143 | 2.875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Movies::Organize do
describe '#call' do
let!(:movie_1) { create(:movie, ) }
let!(:movie_2) { create(:movie, ) }
let!(:movies_list) { [movie_1, movie_2] }
let!(:image_url) { 'https://pairguru-api.herokuapp.com/' }
let!(:description_1) { 'Impo... | true |
3d5844cc26655a8013e61eddcd7773b7397b3118 | Ruby | danielpselph/racecar | /palindrome.rb | UTF-8 | 317 | 3.78125 | 4 | [] | no_license | class Palindrome
# attr_reader :arr1, :arr2
# def initialize(arr1, arr2)
# @arr1 = []
# @arr2 = []
# end
def make_array(x,y)
x.sum + y.sum
end
def add(arr1, arr2)
end
end
a = [1,2,3]
b = [3,2,1]
pal = Palindrome.new
p pal.make_array(a,b) | true |
770f3fe22cbcddcfef6ead30b976cae7700ed8cb | Ruby | ryabrody/mogen | /lib/user.rb | UTF-8 | 404 | 2.703125 | 3 | [] | no_license | class User
attr_reader :username, :password, :tag_names
def initialize(params = {})
@username = params[:username]
@password = params[:password]
@tag_names = params[:tag_names]
end
def self.all
YAML.load_file('users.yml').map do |user|
new(
username: user['username'],
pass... | true |
e3de778efe126a5fed2c34ce6ccb39d91ed4bded | Ruby | rokapo/test | /lesson2/months.rb | UTF-8 | 315 | 3.296875 | 3 | [] | no_license | require 'date'
months_names = Date::MONTHNAMES.dup
months_names.shift
year = Time.now.year
months_days = []
1.upto(12) do |month_index|
months_days << Date.new(year, month_index, -1).day
end
calendar = months_names.zip(months_days).to_h
calendar.each_key do |month|
puts month if calendar[month] == 30
end
| true |
d9b9b50764bfda9ccd7a123e8275037f42261dca | Ruby | cul-it/blacklight-cornell-requests | /app/models/blacklight_cornell_requests/item.rb | UTF-8 | 5,037 | 2.625 | 3 | [
"MIT"
] | permissive | module BlacklightCornellRequests
# @author Matt Connolly
class Item
attr_reader :id, :holding_id, :holdings_data, :location, :type, :status, # , :circ_group
:copy_number, :call_number, :enum_parts, :excluded_locations, :loan_type # new FOLIO loan type and ID
# Basic initializer
#
#... | true |
6c72fb70fb8a5acd964d4c5dc9a6c51ec9740671 | Ruby | plasmatic1/Advent-of-Code-2020 | /day14p1.rb | UTF-8 | 405 | 2.84375 | 3 | [] | no_license | require_relative 'funs'
require 'scanf'
all = (1 << 36) - 1
msk = ''
sto = {}
load_data(14).split("\n").each do |line|
if line =~ /mask/
msk = line.scanf('mask = %s')[0].reverse
else
idx, v = line.scanf('mem[%d] = %d')
msk.chars.each_with_index { |x, i| v = (v & (all ^ (1 << i))) | (x.... | true |
8e657f74342b0041c2e4e72d3a29f88906314411 | Ruby | eeeli24/flight_booker | /db/seeds.rb | UTF-8 | 593 | 2.78125 | 3 | [] | no_license | # Create airports with codes as names
codes = ['LAX', 'SFO', 'ATL', 'ORD', 'JFK', 'DEN', 'DFW', 'LAS', 'SEA']
codes.each do |code|
Airport.create!(name: code)
end
# Build flights from each to each airport
airports = Airport.all
airports.each do |from_airport|
airports.each do |to_airport|
unless to_airport == ... | true |
aeb63240e30eb54a0f3bc5a715a8818843521f5c | Ruby | darren2802/enigma | /lib/encrypt.rb | UTF-8 | 678 | 3.234375 | 3 | [] | no_license | require_relative './enigma'
if ARGV.count != 2
puts 'Usage: ruby encrypt.rb message.txt encrypted.txt'
puts 'Please try again'
exit
end
file_message_text = ARGV[0]
file_cipher_text = ARGV[1]
message_file = File.open(file_message_text, 'r')
message_text = message_file.read.chomp
message_file.close
enigma = Eni... | true |
af5985ef832d668dcaba2e813f67a9ef04fcc9d2 | Ruby | Nexproc/-bash-Chess | /board.rb | UTF-8 | 5,138 | 3.4375 | 3 | [] | no_license | require_relative 'pieces'
require_relative 'empty_square'
require_relative 'errors'
require 'colorize'
require 'io/console'
class Board
attr_reader :teams
def initialize(pop = true)
@grid = Array.new(8) { Array.new(8) { EmptySquare.new } }
@cursor = [0, 0]
@end_cursor = nil
@teams = {:white => [],... | true |
8eea77df19f94ea3cfae94ac5b70cdc1e90d3c26 | Ruby | wendy0402/jsm | /lib/jsm/event_executor/base.rb | UTF-8 | 1,395 | 2.875 | 3 | [
"MIT"
] | permissive | # this class is the base for adapter
# it can be extended for ActiveRecord adapter
class Jsm::EventExecutor::Base
attr_reader :validators, :state_machine
def initialize(params = {})
@state_machine = params[:state_machine]
@validators = @state_machine.validators
end
# it execute event for the object.
... | true |
1a0cd2c2b083b2841adac05456fddabbb80f17da | Ruby | kunovsky/credit_card_processor | /spec/summary_spec.rb | UTF-8 | 563 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe CreditCardProcessor::Summary do
let(:dummy_class) { Class.new { extend CreditCardProcessor::Summary } }
let(:credit_card) { CreditCardProcessor::CreditCard }
let(:dummy_cards) { [credit_card.new(name: 'Ty', balance: 0), credit_card.new(name: 'Adam', balance: 1000)] }
let(:outp... | true |
6f49dbc8b4c6a56e9a30cc4e5b8fd600aef3e051 | Ruby | cmaher92/launch_school | /exercises/codewars/squared_strings.rb | UTF-8 | 2,611 | 3.96875 | 4 | [] | no_license | # Squared Strings
# Codewars (5 Kyu)
# Time: 35,
# squared string has n lines
# each substring being n characters
# s = "abcd\nefgh\nijkl\nmnop"
# s is a squared string of size 4
# - we will use squared strings to code/decode text
# - original text doesn't include the character '\n'
# coding
# - takes a text (t) of... | true |
0090dd89920e0849e502c1fe31b477962e75abfc | Ruby | gvsurenderreddy/proxify-5 | /lib/proxify/base.rb | UTF-8 | 337 | 2.59375 | 3 | [
"MIT"
] | permissive | module Proxify
module Base
def find_or_create_class(class_name, container)
if k = class_exists?(class_name)
k
else
Object.const_set(class_name, container)
end
end
def class_exists?(class_name)
Object.const_get(class_name)
rescue NameError
return false
... | true |
4b60f06b501b128010c8e83da658ddec28d94a7b | Ruby | Sambalero/project | /lib/rpo_page.rb | UTF-8 | 536 | 2.734375 | 3 | [] | no_license | #project/lib/r_p_o_page.rb
require 'common_features'
class RPOPage
include CommonFeatures
def initialize(driver)
@driver = driver
end
#properties
def url
url="http://rubypageobjects.kevinswallow.com/"
end
def expected_title
expected_title = "Ruby Page Objects"
end
def expected_header
... | true |
d306aed01d914af6e082998bd52e40a0b872185c | Ruby | chad-m-carlson/arrow-tech | /app/graphql/mutations/create_user.rb | UTF-8 | 1,560 | 2.515625 | 3 | [] | no_license | class Mutations::CreateUser < Mutations::BaseMutation
argument :first_name, String, required: true
argument :last_name, String, required: true
argument :is_admin, Boolean, required: true
argument :email, String, required: true
argument :password, String, required: true
argument :password_confirmation, Strin... | true |
2dc47639a4ab4ccccacf7266a8fa0b4352db75f2 | Ruby | Najaf/moo.rb | /lib/moo/model/font.rb | UTF-8 | 1,439 | 2.75 | 3 | [
"MIT"
] | permissive | require 'json'
module Moo
module Model
class Font
attr_accessor :family, :bold, :italic
def self.from_hash(hash)
new.from_hash(hash)
end
ACCEPTED_FAMILIES = [
'arial',
'avantgarde',
'bryant',
'courier',
'frutigerltpro',
'georgia',
... | true |
f8a5014efa87ab1f8fb61bc786ee5a359c0b4d80 | Ruby | NelsonT20/Depot | /db/seeds.rb | UTF-8 | 1,711 | 2.765625 | 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 |
5fa3b8dc93b4af02ab96c302768ffbea3a7d9ab1 | Ruby | jmcclain1/vns | /app/models/evd/trim_color.rb | UTF-8 | 1,074 | 2.5625 | 3 | [] | no_license | # == Schema Information
# Schema version: 52
#
# Table name: vns_colors
#
# id :string(35) default(""), not null, primary key
# option_id :string(20) default(""), not null
# name :string(200)
# rgb :string(500)
# acode :string(13) default(""), not null
# paint_t... | true |
e228096f8b1bbc9cdcf5355d7255fb67c0541530 | Ruby | rylev/berline.rs | /legacy-data/import_legacy.rb | UTF-8 | 2,222 | 2.625 | 3 | [] | no_license | require 'json'
require 'yaml'
require 'pp'
require 'date'
require 'erb'
rust_berlin_meetups = JSON.parse(File.read 'legacy-data/past_meetups_Rust-Berlin.json')["results"]
ots_meetups = JSON.parse(File.read 'legacy-data/past_meetups_OpenTechSchool-Berlin.json')
meetups = rust_berlin_meetups + ots_meetups
venues = {}
... | true |
69eebd87b41cc56046c861740ba3a1d13e3b49ef | Ruby | SexoConDuende/violin | /lib/matching.rb | UTF-8 | 531 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'set'
module Matching
ADD_PATTERN = /add|put|push|enqueue/
REM_PATTERN = /rem|get|pop|dequeue/
def self.get(history,id)
case history.method_name(id)
when ADD_PATTERN
:none
when REM_PATTERN
if history.returns(id).nil?
nil
elsif history.returns(id).first == :empty
... | true |
50830fc59cdae04378394fd0ad2626eaafd5059d | Ruby | IhorHudkov/Ruby-practice | /10/Lesson12/each_value.rb | IBM866 | 254 | 2.90625 | 3 | [] | no_license | # encoding: cp866
hh = {'dog' => ['', ''], 'cat' => ['誠', ''], 'girl' => ['誠']}
count = 0
hh.each_value do |value|
count = count + value.size
end
puts "⢮ ॢ: #{count}" | true |
46f0d284fddbf626580a0b4662837d4197d112a3 | Ruby | ajlopez/PLangRe | /files/ruby/gist04a.rb | UTF-8 | 366 | 3.71875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
class Routes
def distance(*segments)
calculate_distance(*segments)
end
private
def calculate_distance(*segments)
puts "Expensive Task"
segments.inject { |sum, val| sum + val }
end
end
r = Routes.new
puts r.distance 1,2,3,4
puts r.distance 1,2,3,4
pu... | true |
fd0fa91bb60321da2467559eacfc9d4e486f4d4e | Ruby | webdeveloper0012/Chain-link | /spec/models/json_traverser_spec.rb | UTF-8 | 1,695 | 2.75 | 3 | [
"MIT"
] | permissive | describe JsonTraverser, type: :model do
describe ".parse" do
subject { JsonTraverser.parse body, keys }
let(:body) do
{
first: {
second: {
third: 'you win!'
}
},
list: [
{name: "your mom"},
{name: "your momma's mom"}
]
... | true |
be711f7360e731cd5aba8a37f72c06f97594319b | Ruby | Hinson7886/ruby-programs | /temp.rb | UTF-8 | 1,326 | 4.28125 | 4 | [] | no_license | # def going_hiking(temp)
# if temp >= 50
# puts "Im going hiking today!"
# end
# if temp < 50
# puts "that's way too cold for hiking"
# end
# end
# puts "What is today's temperature?"
# temp = gets.to_i
# todays_temp = going_hiking(temp)
####### Andrew's code#####
# puts "what is the temperature?"
# ... | true |
48418f6cc52e9bea4fbaa377f9dbefb3ccc21ad1 | Ruby | jaredbeck/shellconf | /bin/dev/count_files.rb | UTF-8 | 793 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
require "pathname"
class CountFiles
def new
end
def run
print sort counts
end
private
def counts
extensions.each_with_object({}) { |ext, hsh|
hsh[ext] = hsh[ext].to_i + 1
}
end
def extensions
file_names.map { |n| n.split('.').... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.