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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2a839b779a70bb6d00b7e1df8629bcadfd03f5fa | Ruby | michelleamazinglin/aA-classworks | /W1D2/self/Michelle_Lin_rspec_exercise_1/lib/part_2.rb | UTF-8 | 888 | 3.546875 | 4 | [] | no_license | def hipsterfy(str)
vowel = "aeiou"
new_str = ""
i = -1
while i > str.length * -1
if vowel.include?(str[i])
if i == -1
return str[0...i]
else
return str[0...i] + str[i+1..-1]
end
else
i -= 1
end
en... | true |
71abbbbed58c83ad88eda8d8e65acb5df40d3210 | Ruby | kamayan1980/scrape_web_spider | /scrape_web_spider.rb | UTF-8 | 1,421 | 2.640625 | 3 | [] | no_license | Encoding.default_external = 'UTF-8'
require 'open-uri'
require 'nokogiri'
require "csv"
require 'anemone'
require 'time'
def extraction_html(doc)
web_title = doc.title
web_desc = doc.xpath('/html/head/meta[@name="description"]/@content').to_s
web_h1 = doc.css("h1").inner_text
if web_h1.empty?
doc.search(... | true |
de4b3ce2dd7e17a2c83a50567c462b42660c15eb | Ruby | yankyan/test01 | /01.rb | UTF-8 | 333 | 3.609375 | 4 | [] | no_license | class Char
def initialize (i)
@i=i
@st="1"
end
def read
newst = ""
while !@st.empty?
numb = @st.scan(/#{@st[0]}*/)[0].to_s.length
newst += "#{numb}#{@st[0]}"
@st=@st[(numb)..@st.size]
end
puts newst
@st = newst
end
def write
@i.times {|i| read}
end
end
Char... | true |
55a8d09455261baa5fe5f298909bc23093e301fa | Ruby | echenley/project-euler | /problem-032-pandigital-products.rb | UTF-8 | 935 | 3.75 | 4 | [] | no_license | =begin
We shall say that an n-digit number is pandigital if it makes use of all the digits
1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.
The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing
multiplicand, multiplier, and product is 1 through 9 pandigital.
... | true |
2057739aa74d6b27a3f8569353d7f3b5997bda0a | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex1265.rb | UTF-8 | 220 | 3.03125 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 589
"abcdef".casecmp("abcde")
"abcdef".casecmp("abcdef")
"aBcDeF".casecmp("abcdef")
"abcdef".casecmp("abcdefg")
"abcdef".casecmp("ABCDEF")
| true |
d664830c1f20fcace5a9d9087bfd6ef0f80d7538 | Ruby | Slavkata/Karh-balancing-robot | /ruby/23.rb | UTF-8 | 341 | 2.96875 | 3 | [] | no_license | require 'csv'
require 'json'
result = 298789785
json = JSON.parse(File.read(ARGV[1]))
csv = File.open(ARGV[0])
json.each_key { |key|
help = 0
CSV.foreach(csv) do |row|
if key.to_i == row[1].to_i then
help = 1
end
end
if help > 0 then
if result > json.fetch(key) then
result = json.fetch(key)
end
... | true |
e0c5f43e49177d3499d5901e252b0c287f676a52 | Ruby | oceansize/inject | /spec/inject_spec.rb | UTF-8 | 2,104 | 3.59375 | 4 | [] | no_license | require 'inject'
# Reopen the Array class or subclass it.
# Rewrite the inject method. Write a test for it first.
# Don't worry about returning an enumerator, assume a block
# is always given
# Name your method differently (that is, not inject() or
# subclass Array) because rspec uses inject() internally,
# so the tes... | true |
01548c0dc8909f81edd736db7a77d6c3ba795d21 | Ruby | sarab78/Weekend_Homework | /songs.rb | UTF-8 | 124 | 2.84375 | 3 | [] | no_license | class Song
attr_accessor :artist, :song
def initialize(artist, song)
@artist = artist
@songs = song
end
end
| true |
6c7fd0ddeb49c6aceb2da86ce549d5a3859b43b9 | Ruby | ychaker/sunspot_admin | /app/models/searchable_item.rb | UTF-8 | 1,523 | 2.6875 | 3 | [
"MIT"
] | permissive | class SearchableItem < ActiveRecord::Base
validates_uniqueness_of :searchable_field, :scope => :searchable_model
validates_presence_of :searchable_model, :searchable_field, :searchable_field_type
scope :status, proc {|status| where(:searchable_status => status) }
scope :by_model, order(:searchable_model)
... | true |
92fbbff2015acf37df05440930ad0c654f4d5871 | Ruby | olichka12/RubyTestProjects | /WorkWithFiles/features/CucumberProject/code/files.rb | UTF-8 | 2,393 | 3.15625 | 3 | [] | no_license | require_relative '../../../data'
class WFile
def initialize
@@files = {}
end
def out_info_about_file
@@files.each {|file, access| puts "#{file}: #{access}"}
end
def create (file_name, access_right = 'w') #w, w+, a, a+
if @@files[file_name.to_sym].nil?
begin
File.new(file_name.to_s... | true |
0c9906c7459d1118637daf24d051b1bdfe89d2ea | Ruby | emilymalecbrown/bonobos-rails | /db/seeds.rb | UTF-8 | 1,481 | 3.265625 | 3 | [] | no_license | require 'csv'
### Inventory ###
# read in inventory as a string
def seed_inventory
inventory_text = File.read('lib/seeds/inventory.csv').tr(' ', '')
# parse as comma separated file
inventory = CSV.parse(inventory_text,
{ headers: true,
converters: :numeric,
header_converters: :symbol
})
... | true |
df9f15db745fd0a83f9daedeaff85196c3e6e2db | Ruby | NJichev/Programming101-Ruby | /week05/1-Shopping-Cart/shopping_cart_test.rb | UTF-8 | 5,168 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require 'bigdecimal'
require 'bigdecimal/util'
require_relative 'shopping_cart.rb'
# Class for testing our code
class ShoppingCartTest < Minitest::Test
def test_register_item_in_inventory
inventory = Inventory.new
inventory.register 'Green Tea', '1.99'
inventory.register ... | true |
87e096b481dcb0d26d94af24516179abb613e717 | Ruby | Lebeil/RubyExo | /exo_21.rb | UTF-8 | 1,106 | 3.46875 | 3 | [] | no_license | puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?"
print "> "
number = gets.chomp.to_i
i=number
puts "voici la pyramide:"
number.times do |number|
if(i>=0 && i<=25)
puts " "*i + "#" * (number + 1)
i=i-1
else
puts "recommencez!"
end
end
###### AUTRE METHODE ... | true |
f37fd43ff9723a555f7b2e892da5e876895f5d03 | Ruby | bdecazenave/morpion | /lib/Player.rb | UTF-8 | 296 | 2.921875 | 3 | [] | no_license | require_relative 'Board'
require_relative 'BoardCase'
class Player
#TO DO : la classe a 2 attr_reader, son nom et sa valeur (X ou O).
attr_accessor :name, :symbol
def initialize(name, symbol)
@name = name
@symbol = symbol
#TO DO : doit régler son nom et sa valeur
end
end
| true |
7f5fb3c6921e5fbff3a4d5ba5a40c4d0c1aa5f5c | Ruby | giorgosdi/Cucumber-Rep | /lib/transaction_processor.rb | UTF-8 | 376 | 2.609375 | 3 | [] | no_license | require_relative 'transaction_queue'
require_relative 'balance_store'
transaction_queue = TransactionQueue.new
balance_store = BalanceStore.new
puts "transaction processro ready"
loop do
transaction_queue.read do |message|
sleep 1
transaction_amount = message.to_i
new_balance = balance_store.balance + transacti... | true |
c424f70675e728bac99341b6c519c145b1f53529 | Ruby | urug/strategery | /spec/ext/open_struct_spec.rb | UTF-8 | 993 | 2.921875 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
describe OpenStruct do
it "should merge with hashes" do
o = OpenStruct.new(:this => :that)
o.merge(:one => :more)
o.this.should eql(:that)
o.one.should eql(:more)
end
it "should merge with open structs" do
o1 = OpenStruct.new(:this => :tha... | true |
243b5e9c8ca4e0ac55ea6f81417dce941f1a084c | Ruby | T-willjr/backend_mod_1_prework | /section1/lesson_exercises/ex4.rb | UTF-8 | 1,741 | 3.546875 | 4 | [] | no_license | cars = 100 # Stores integer in cars variable
space_in_a_car = 4.0 # Stores floating point in space_in_a_car variable
drivers = 30 # Stores integer in drivers variable
passengers = 90 # Stores integer in passengers variable
cars_not_driven = cars - drivers # Takes two variables and subtracts them
cars_driven = drivers #... | true |
ec78abb1415b2fe9bcb1b39ba8b6dfcf093ba382 | Ruby | j-rods/lrthw | /Chap22/ex22.rb | UTF-8 | 4,591 | 4.40625 | 4 | [] | no_license | # outputs a string
puts "Hello World"
# math operations
puts "Hens #{25.0 + 30.0 / 6.0}"
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0
# defines a variable that stores information
apples = 50
pears = 10
name = "Herbert"
# outputs variable in string or variable d... | true |
3d6cb6f14f352a3fb7637d59f66d5d76f89f1633 | Ruby | terriblelabs/motion-juxtapose | /lib/juxtapose/application/spec/models/project_spec.rb | UTF-8 | 2,562 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'json'
describe "Project" do
before do
@specs_dir = 'spec/screens'
FileUtils.rm_rf(@specs_dir) if File.directory? @specs_dir
FileUtils.mkdir_p(@specs_dir)
end
it "returns an empty list of specs when there are no specs" do
expect(Project.new(@specs_dir).specs).to be... | true |
cccc98aaaacf1ff47cfcab82c997c9b1f6212b12 | Ruby | zackforbing/uploads | /command-query/wallet.rb | UTF-8 | 678 | 3.515625 | 4 | [] | no_license | class Wallet
attr_reader :cents,
:contents
def initialize(cents = 0)
@cents = cents
@coins = coins
@contents = contents
end
def <<(obj)
@cents += @coins[obj]
@contents[obj] += 1
end
def take(obj, obj_2 = nil)
if @contents[obj] > 0
@cents -= @coins[obj]
if... | true |
8d74d1feea32a811c9919f895eae8ebc11f1a531 | Ruby | RonuGhoshal/voting_data | /tx2004.rb | UTF-8 | 769 | 2.6875 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'pp'
counties_array = []
url = "http://uselectionatlas.org/RESULTS/datagraph.php?year=2004&fips=48&f=1&off=0&elect=0"
page = Nokogiri::HTML(open(url))
table_rows = page.css('.info tr').map{|row| row.children.map{|x| x.text}}
table_rows.each do |row|
row = row.select!... | true |
4966b8fd18b92c4ac8479f1462b85e7a5c283d59 | Ruby | jeremitu/RubyCLR | /Samples/GoogleCalc/calc.rb | UTF-8 | 3,628 | 2.6875 | 3 | [
"MIT"
] | permissive | # Sample by Justin Bailey
require 'rubyclr'
RubyClr::reference 'System'
RubyClr::reference 'System.Drawing'
RubyClr::reference 'System.Windows.Forms'
include System::Drawing
include System::Drawing::Drawing2D
include System::Windows::Forms
require 'open-uri'
require 'cgi'
class GoogleCalc
def sel... | true |
c9939ad8da12c389c73cc3b384a9b442174f44a7 | Ruby | skandragon/thing | /app/lib/differ.rb | UTF-8 | 1,107 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | require 'diff/lcs'
class Differ
class Comparison
attr_reader :sequences
def initialize
@state = ' '
@buffer = ''
@sequences = []
end
def match(element)
append_state(' ', element.old_element)
end
def discard_a(element)
append_state('-', element.old_element)
... | true |
714de9fd02a060f2b958c69eb4e8f47221238a5b | Ruby | mwakipesile/mashup | /app/models/contest.rb | UTF-8 | 925 | 2.78125 | 3 | [] | no_license | # Contest Model
class Contest
extend Model::FileHelpers
CONTEST_TEMPLATE_PATH = file_path('contest_template')
CONTESTS_PATH = file_path('contests.yml')
def initialize(contest)
@contest_name = contest
@contests = self.class.load_data(CONTESTS_PATH) || {}
@id = contest_id
create
end
def cre... | true |
2faeedda051b73e607422a7f3aff2e075f3018bd | Ruby | jasonrclark/dothacketyhack | /Princess.rb | UTF-8 | 1,190 | 2.9375 | 3 | [] | no_license | require './princess/room'
require './princess/outside'
require './princess/inside'
class ThroneRoom < Room
def setup_room
@name = "throne"
@princess = image :left => 110, :top => @app.height - 300, :width => 100
@princess.path = File.expand_path("~/.hacketyhack/princess/princess.jpg")
@king = image ... | true |
eb0043dcbb5facce5d6d203fd9b98d8e088d43e2 | Ruby | jonjonray/w2d3 | /tdd/lib/towers_of_hanoi.rb | UTF-8 | 458 | 3.671875 | 4 | [] | no_license | class Tower
attr_accessor :stack
def initialize(stack = [])
@stack = stack
end
def move(tower)
unless tower.stack.last.nil? || @stack.last.nil?
raise StandardError if tower.stack.last < @stack.last
end
tower.stack << @stack.pop
end
end
class Game
def initialize
@tower1 = Tower.... | true |
1954c4a20b8edf783af6e6e79cabd7fa338dc79c | Ruby | sas2job/Ruby-Is-For-Fun | /code/app45.rb | UTF-8 | 2,069 | 3.578125 | 4 | [] | no_license | ###############################
# ОБЪЯВЛЯЕМ МАССИВЫ
###############################
# массив для первой команды
@arr1 = Array.new(10, 1)
# массив для второй команды
@arr2 = Array.new(10, 1)
###############################
# АТАКА
###############################
# Метод принимает массив для атаки
def attack(arr)
slee... | true |
984ad601b06bd7d13276ff5425f0d2caa040f5b2 | Ruby | hanzawa/mongoid-geo | /lib/mongoid/geo/point.rb | UTF-8 | 2,007 | 3.09375 | 3 | [
"MIT"
] | permissive | module Mongoid::Geo
module Point
# convert hash or object to [x, y] of floats
def to_points
v = self.kind_of?(Array) ? self.map {|p| p.kind_of?(Fixnum) ? p.to_f : p.extend(Mongoid::Geo::Point).to_point } : self
v.flatten
end
def to_point
case self
when Hash
return [sel... | true |
9d4329234a26bcac36e1494e443cdb9a975314e2 | Ruby | ruuuh20/Questions | /Q2.rb | UTF-8 | 556 | 3.453125 | 3 | [] | no_license | def repeatStr(text, n)
result = ""
result = [text] * n
result.join("")
result
end
def decodeString(s)
x = []
for i in s.split("")
if i != "]"
x.push(i)
else
temp = ''
while x[x.length - 1] != '['
temp = x.pop() + temp
end
x.pop()
if (x.length > 0 && x[x.length - ... | true |
881f3a015fffa5d62ef6518a3e03f8ef853dd1d9 | Ruby | timnallen/enigma | /lib/decrypt.rb | UTF-8 | 814 | 3.796875 | 4 | [] | no_license | # First creating file requirements and enigma object
# to do our encryption
require_relative 'enigma'
enigma = Enigma.new
# Next taking arguments from the command line and
# setting them as files/variables that can be accessed
ARGV == ["encrypted_file", "decrypted_file", "key", "date"]
encrypted_file = File.open(AR... | true |
3cd21f7e855fd029d9ec4240989907b2fd506c60 | Ruby | sebasjm/antlr | /runtime/Ruby/lib/antlr3/modes/filter.rb | UTF-8 | 1,605 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/ruby
# encoding: utf-8
require 'antlr3'
module ANTLR3
=begin rdoc ANTLR3::FilterMode
If a lexer grammar specifies the <tt>filter = true</t> option, the generated
Lexer code will include this module. It modifies the standard
<tt>next_token</tt> to catch RecognitionErrors and skip ahead in the input until
t... | true |
91e5e55e88e2b84166428f3cc3f9b32dbc5c469d | Ruby | aliCamargo/paysafe | /test/error_test.rb | UTF-8 | 2,031 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class ErrorTest < Minitest::Test
def test_no_error_message_if_unrecognized_body
error = Paysafe::Error.from_response('', 431)
assert_equal "", error.message
error = Paysafe::Error.from_response(nil, 431)
assert_equal "", error.message
end
def test_returns_general_error_cl... | true |
426c89c37128a655f0f15c688721dba098fecf0d | Ruby | klinkow/Build_a_Dictionary | /lib/definition.rb | UTF-8 | 794 | 2.734375 | 3 | [] | no_license | class Definition
attr_reader(:definition1, :definition2, :definition3, :definition4, :definition5)
@@definitions = []
define_method(:initialize) do |attributes|
@definition = attributes.fetch(:definition)
@id = @@definitions.length() + 1
end
define_method(:definition) do
@definition
end
def... | true |
04b3c80b842000709013c250909154419760b8ed | Ruby | Metahaem/News-Digester-Backend | /app/models/al_jazeera.rb | UTF-8 | 3,744 | 3.125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class Al_jazeera < ApplicationRecord
@categories = {
'UK': "topics/country/united-kingdom.html",
"World": "news/",
"Art": "topics/subjects/art.html",
"Business": "topics/categories/business.html",
"Technology": "topics/categories/science-and-... | true |
4078429a411aa54ac3b44bdb43ce4455e67ca80d | Ruby | kevniu/phase-0 | /week-6/nested_data_solution.rb | UTF-8 | 2,394 | 3.890625 | 4 | [
"MIT"
] | permissive | # RELEASE 2: NESTED STRUCTURE GOLF
# Hole 1
# Target element: "FORE"
array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]]
# attempts:
# ============================================================
p array[1][1][1][0]
p array[1][1][2][0]
# ============================================================
# Hol... | true |
3cb2f26981f9856a25e399273fb83dd560722b8f | Ruby | petrachi/Saphyr | /saphyr/core/kernel.rb | UTF-8 | 180 | 2.5625 | 3 | [] | no_license | class Saphyr::Core::Kernel
def print *args
::Kernel.print *args.map(&:sprint)
end
def newline n = Saphyr::Core::Number.new(1)
::Kernel.print "\n"*n.intern
end
end
| true |
44d2ec88b3da9255695220e662fdd4f2b3b79c65 | Ruby | yaboichrissyb/phase-0 | /week-6/bingo_solution.rb | UTF-8 | 4,557 | 4.15625 | 4 | [
"MIT"
] | permissive | # A Nested Array to Model a Bingo Board SOLO CHALLENGE
# I spent [2.5] hours on this challenge.
# Release 0: Pseudocode
# Outline:
# 1
# Create a method to generate a letter ( b, i, n, g, o) and a number (1-100)
#create a hash with each bingo letter as keys and pointing to a integer value representing columns
#crea... | true |
05276bfd8de309bf2de084e78d79f81a830e1a5f | Ruby | shortthirdman/code-eval-challenges | /moderate/column_names.rb | UTF-8 | 246 | 3.390625 | 3 | [
"MIT"
] | permissive | def char(a)
(a % 26 + 'A'.ord).chr
end
File.open(ARGV[0]).each_line do |a|
a = a.to_i - 1
d = char(a)
if a >= 26
a = a / 26 - 1
d = char(a) + d
if a >= 26
a = a / 26 - 1
d = char(a) + d
end
end
puts d
end
| true |
05d88adf25b646bc47187fcce72870005e007873 | Ruby | piyush-amura/HTML_Parser | /lib/stack.rb | UTF-8 | 246 | 3.28125 | 3 | [] | no_license | class Stack
attr_accessor :store
def initialize
@store = []
end
def push(element)
@store.push(element)
self
end
def pop
@store.pop
end
def size
@store.size
end
def empty?
@store.size.zero?
end
end | true |
802ff938ec6922c0cfd586dc898ad73300ec274a | Ruby | RIGHTgit/twelve | /lib/twelve/api/gauges/shares.rb | UTF-8 | 966 | 2.59375 | 3 | [
"MIT"
] | permissive | class Twelve
# API module encapsulates all of the API endpoints
#
module API
# The Gauges module handles Gauges on Gauges
#
module Gauges
# The Shares module handles sharing gauges
#
module Shares
# Get a list of users gauge is shared with
#
# Returns json... | true |
cdf1407bbee49c26247b8be36c6e71d110ac2833 | Ruby | skart/appium-ios-app | /lib/methods/common_methods.rb | UTF-8 | 2,493 | 2.59375 | 3 | [] | no_license | $LOAD_PATH << './ios_automation/lib'
require 'yaml'
module Common_Methods
def bash(command)
escaped_command = Shellwords.escape(command)
system "bash -c #{escaped_command}"
end
def random_num
srand
rand(1000000).to_s
end
def element(xpath)
return $driver.find_element(:xpath, xpath... | true |
66206c265c467a406b473d79a22ff48b612fb559 | Ruby | nixsticks/palebluedot | /db/seeds.rb | UTF-8 | 1,037 | 2.5625 | 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 rake db =>seed (or created alongside the db with db =>setup).
#
# Examples =>
#
# cities = City.create([{ name => 'Chicago' }, { name => 'Copenhagen' }])
# Mayor.create(name... | true |
377e9a511d34e25a9cffec5f7c2fb51b69df8e85 | Ruby | BuddyBet/restish | /spec/restish/repository_spec.rb | UTF-8 | 7,723 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'ostruct'
class TestRepository
extend Restish::Repository
end
class TestModel < Restish::Model
end
describe Restish::Repository do
describe '.repository' do
it 'is initialized to array' do
Restish::Repository.repositories.should be_kind_of Array
end
end
describe '... | true |
716b307b5c17930989599c8e9c50767015078309 | Ruby | mehulsbhatt/neurotelcal | /app/models/resource.rb | UTF-8 | 2,048 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'digest'
class Resource < ActiveRecord::Base
TYPES = ["audio", "documento"]
attr_accessible :campaign_id, :file, :name, :type_file, :created_at, :updated_at
validates :name, :type_file, :file, :presence => true
validates :name, :uniqueness => true
validates :type_file, :incl... | true |
9bb15ba2d9c79c33b42c47a44e71c2d7c0e49980 | Ruby | sid2660/Ruby_Tutorials | /string_methods.rb | UTF-8 | 1,547 | 4.5 | 4 | [] | no_license | ## String Methods
# ._________________________________.
# |* Concat ** lstrip |
# |* upcase ** rstrip |
# |* downcase ** strip |
# |* capitalize ** gsub |
# |* reverse ** replace |
# |* delete |
# |* length ... | true |
ebc094cb91c799837e204421416f07109d7a5759 | Ruby | gorodish/w1d2_homework | /length_text.rb | UTF-8 | 99 | 2.78125 | 3 | [] | no_license | def length_of_text(str)
return str.length
end
puts length_of_text("antidiestablishmentarianism") | true |
7578e34f9f59b413401f3d48343d121d07476dc4 | Ruby | alexeyramazanov/base_app | /lib/tasks/rename_app.rake | UTF-8 | 879 | 2.640625 | 3 | [] | no_license | require 'thor'
class AppRenamer < Thor
include Thor::Actions
desc 'rename_application NEW_NAME', 'rename applicaiton'
def rename_application(new_name)
new_name_underscored = new_name.underscore
gsub_file 'config/application.rb', 'module BaseApp', "module #{new_name}"
gsub_file 'config/cable.yml', '... | true |
df9b02b3f05c2c5c72795e9fee20842ac74d084f | Ruby | gagannugraha/rekapc1 | /db/seeds.rb | UTF-8 | 836 | 2.515625 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
cce5bf895d2d724fb9fa8d409b56151396baa51f | Ruby | Kiveo/looping-while-until-v-000 | /lib/while.rb | UTF-8 | 132 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def using_while
levitation_force = 6
#your code here
while levitation_force <= 9
puts "Wingardium Leviosa"
levitation_force += 1
end
end
| true |
557f549c40d245525f439c7b77bc32635472148d | Ruby | rakoo/parpac | /lib/parpac/message.rb | UTF-8 | 1,547 | 2.84375 | 3 | [] | no_license | module ParPac
## Message types
CHOKE = 0
UNCHOKE = 1
INTERESTED = 2
NOT_INTERESTED = 3
HAVE = 4
BITFIELD = 5
REQUEST = 6
PIECE = 7
CANCEL = 8
PORT = 9
class MessageError < StandardError; end
class Message
def initialize cmd, payload = nil
@cmd = cmd
@payload = payload
e... | true |
5236e253ec44b8a61bd5ee23ffc120441e1ebd83 | Ruby | chrishaining/PDA | /Static_and_Dynamic_Task_A/testing_practice/specs/card_game_spec.rb | UTF-8 | 1,011 | 2.96875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../card_game')
require_relative('../card')
class CardGameTest < Minitest::Test
def setup
@first_card = Card.new('Hearts', 1)
@second_card = Card.new('Hearts', 3)
@cards = [@first_card, @second_card]
@card_game = CardGame.new
end
... | true |
8a449f203163ecb758a95bedd2e9c5d07a24ab76 | Ruby | YingCGooi/Ruby-Challenges | /1_blocks/reduce.rb | UTF-8 | 934 | 3.875 | 4 | [] | no_license | [1, 2, 3].reduce do |acc, num|
acc + num
end # => 6
# [1, 2, 3].reduce do |acc, num|
# acc + num if num.odd?
# end
# => NoMethodError: undefined method `+' for nil:NilClass
# At the second iteration, the accumulator is set to `nil` and calling `+` method `nil` will cause Ruby to throw an error.
# we can also ini... | true |
5f028a230e3f6e8ff15952819a04f98103eb1c72 | Ruby | oleander/acts_as_chain | /lib/acts_as_chain.rb | UTF-8 | 474 | 2.59375 | 3 | [
"MIT"
] | permissive | require "acts_as_chain/version"
class Object
def self.acts_as_chain(*args)
args.each do |method|
define_method method do |*args|
if args.empty?
instance_variable_get("@#{method.to_s}")
elsif args.one?
tap {
instance_variable_set("@#{method.to_s}", args.first... | true |
018ca9ab462b4cd443d46456d3875c7d64a5e86d | Ruby | jnsoo123/adnat | /spec/forms/user_form_spec.rb | UTF-8 | 2,643 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe UserForm do
let(:user) { create :user }
let(:form) { described_class.new(user: user)}
context 'Initialization' do
it 'sets attributes when user is passed' do
expect(form.name).to eq user.name
expect(form.email).to eq user.email
end
context 'with no ... | true |
ce1141f8566c4c46e4f23e0857c810a7ce77e58c | Ruby | joel29dec/tweet-shortener-chicago-web-051319 | /tweet_shortener.rb | UTF-8 | 779 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
# Write your code here.
require 'pry'
def dictionary
dict = {"hello" => "hi", "to" => "2", "two" => "2", "too" => "2", "for" => "4", "four" => "4", "For" => "4", "be" => "b", "you" => "u", "at" => "@", "and" => "&"
}
end
def word_substituter(tweet)
diction = /\b(#{Regexp.union(dictionary.... | true |
3b77a4ec5728352893c6292624980cf0135fad66 | Ruby | JosephMalandruccolo/CSPP51050-Final-Project | /strategies.rb | UTF-8 | 3,264 | 3.75 | 4 | [] | no_license | # => author: Joseph Malandruccolo
# => strategies that analyze tweets, used in the
# => 'Data Analysis' layer
require_relative 'data_model'
require 'csv'
class AbstractTweetStrategy
attr_reader :results_key
def new
raise "Cannot instantiate abstract class 'AbstractTweetStrategy'"
end
def initialize results_... | true |
69a94abef3e855e7be87537e939d2db13bd263c1 | Ruby | Fabian-tapia7/ruby | /arreglos/sesion_online/desafio_1.rb | UTF-8 | 818 | 4.125 | 4 | [] | no_license | =begin
Utilizando map sumar uno a cada uno de los valores del array.
Utilizando map convertir todos los valores a float.
Utilizando select descartar todos los elementos menores a 5 en el array.
Utilizando inject sumar todos los valores del array.
Utilizando .count contar todos los elementos menores que 5.
=end
#Utiliz... | true |
0d33242db6054399795552ea066def02b7ddc8ba | Ruby | jorgemfernandes14/transfermarkt | /lib/transfermarkt/league.rb | UTF-8 | 4,327 | 2.703125 | 3 | [
"MIT"
] | permissive | module Transfermarkt
class League < Transfermarkt::EntityBase
attr_accessor :name,
:country,
:league_uri,
:clubs,
:clubs_index,
:club_uris
def valid_league?
if name.nil? or name.empty?
false
else
true
... | true |
c9b4a6f5d8cef30a689d959f6f32e315e3dd674b | Ruby | parryd4/simple-scraper-the-elite | /lib/scraper.rb | UTF-8 | 1,307 | 3.09375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'pry'
require_relative './player.rb'
class Scraper
attr_accessor :names
def initialize
@names = []
end
def get_ajax_page
Nokogiri::HTML(open("https://rankings.the-elite.net/ajax/rankings/ge/post50/1510367957)"))
end
def collect_player_names
text... | true |
d9b096158cdf2e276246e0e48529d3c5c199ec24 | Ruby | jekyll/jekyll | /lib/jekyll/converters/smartypants.rb | UTF-8 | 1,996 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Kramdown
module Parser
class SmartyPants < Kramdown::Parser::Kramdown
def initialize(source, options)
super
@block_parsers = [:block_html, :content]
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html]
end
de... | true |
2e6215335ec16336e7c54f04d5d74d099f221c8f | Ruby | StemboltHQ/durable_decorator | /spec/durable_decorator_spec.rb | UTF-8 | 7,244 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe DurableDecorator::Base do
context 'with classes' do
# Spec uses ./example_class.rb
context 'for existing instance methods' do
it 'guarantees access to #method_old' do
ExampleClass.class_eval do
decorate :no_param_method do
no_param_method_ol... | true |
a19f815bcbfb8496a76758ed4929fb7db3d99f3d | Ruby | 201528014628074/course | /ruby_intro.rb | UTF-8 | 3,328 | 4.25 | 4 | [] | no_license | # When done, submit this entire file.
# Part 1
def sum arr
# YOUR CODE HERE
arr_sum = 0
arr.each do |i|
arr_sum += i
end
return arr_sum
end
def max_2_sum arr
# YOUR CODE HERE
arr_max2sum = 0
sort_arr = arr.sort
if sort_arr[-1] != nil
arr_max2sum += sort_arr[-1]
if sort_arr[-2]... | true |
d14b1b9f64f76b0e4c78c8a4385abe85b1e22e63 | Ruby | crmcleod/lab_w2d3 | /specs/customer_spec.rb | UTF-8 | 742 | 2.78125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative("../customer")
require_relative("../drinks")
require_relative("../pub")
require_relative("../food")
class TestCustomer < Minitest::Test
def setup
@customer1 = Customer... | true |
0ceb13239cbaac19e0b144278e7d4f6a32c29013 | Ruby | enack/trance-book | /8-4/lz78.rb | UTF-8 | 1,929 | 3.4375 | 3 | [] | no_license | # 元データの基数
INPUT_BIN = 256
# LZ78 圧縮: (0...INPUT_BIN) の数字の配列を圧縮する
def lz78_compress(uncompressed_data)
# トライ木
root = ptr = (0 ... INPUT_BIN).map {|n| [n, []] }
# 圧縮
codes = []
cur_code = nil
max_code = INPUT_BIN
uncompressed_data.each do |d|
if ptr[d]
# 中間ノードを降りる
cur_code, ptr = ptr[d]
... | true |
48b3ac0b9dcf3f2ac0c025566461790ada4199e5 | Ruby | norbert/em-pg-sequel | /lib/em-pg-sequel/connection_pool.rb | UTF-8 | 1,503 | 2.53125 | 3 | [
"MIT"
] | permissive | module EM::PG::Sequel
class FiberConnectionPool
attr_reader :available
def initialize(opts, &blk)
@available = []
@pending = []
@acquire_blk = blk
@disconnected_class = opts[:disconnect_class]
opts[:size].times do
@available.push @acquire_blk.call
end
end
... | true |
93038f6ef4a192c708568620c7a2cf305e4c7d4a | Ruby | wcoombs/Amplify-Web | /app/controllers/concerns/mapping.rb | UTF-8 | 335 | 2.515625 | 3 | [] | no_license | module Mapping
def playlist_data(songs, voter)
songs.each.map do |song|
{
id: song.id,
title: song.title,
artist: song.artist,
voter_score: song.voter_vote(voter)&.score,
total_score: song.votes.sum(:score),
song_status: song.song_status
}
... | true |
009debdeb99873bc43d29b927f34efa9e8ca75a0 | Ruby | osule/learning-ruby | /oop/getter_using_attr_reader.rb | UTF-8 | 158 | 3.171875 | 3 | [] | no_license | class Item
attr_reader :item_name
def initialize(item_name)
@item_name = item_name
end
end
item = Item.new("bangkok")
p item.item_name
| true |
c01ab7488b5f356820594b282fe823f1a6c4d7c3 | Ruby | katerynaf/course-site | /app/models/grade_tools.rb | UTF-8 | 4,405 | 2.734375 | 3 | [] | no_license | class GradeTools
@@log = ""
def self.available?
!!Settings['grading'] && !!Settings['grading']['calculation']
end
def initialize
@grading = Settings['grading']
end
def log(something)
@@log << something + "\n"
end
def get_log
@@log
end
# def calc_final_grade(subs)
# logger.info "Trying to c... | true |
a546534d55b71d42995154a2f2f630c98474298e | Ruby | bignose-p/W2D1 | /display.rb | UTF-8 | 1,405 | 3.265625 | 3 | [] | no_license | require 'colorize'
require_relative 'cursor'
class Display
attr_reader :board, :cursor
def initialize(board)
@board = board
@cursor = Cursor.new([0,0], board)
end
def build_grid
@board.grid.map.with_index do |row, i|
build_row(row, i)
end
end
def build_row(row, i)
row.m... | true |
483dc2c2a0cf78e7e926b0fdfd777810cafd3d78 | Ruby | kkrull/javaspec | /lambdas-and-cli/features/support/helpers/logger_helper.rb | UTF-8 | 391 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'stringio'
module Logging
def logger
@logger ||= ConsoleLogger.new(StringIO.new)
end
def set_logger(string_io)
@logger = string_io
end
end
class ConsoleLogger
attr_reader :string_io
def initialize(string_io)
@string_io = string_io
end
def command_starting(command_line)
strin... | true |
6aed749a71f691f8f9cd43f2daf177cc791fc5ec | Ruby | psave/lighthouse_git | /wk2_day2/warcraft3/spec/test_13.rb | UTF-8 | 608 | 3.15625 | 3 | [] | no_license | require_relative 'spec_helper'
# Enhancement 3
# A dead Unit cannot attack another Unit.
# Conversely, an alive Unit will also not attack another Unit that is already dead.
describe Unit do
before :each do
@unit1 = Unit.new(0, 10)
@unit2 = Unit.new(1, 10)
end
# Dead unit can not attack another Unit
... | true |
75d807537e642c2f202c98bab8fca1dcd04d5795 | Ruby | BacancyAnkita/xyz | /A.rb | UTF-8 | 103 | 2.984375 | 3 | [] | no_license | class A
def a
puts "In class A"
end
end
class B<A
def a
puts "In class B"
end
end
b=B.new
b.a
| true |
2185ed15fe15970a700586d561b1db2514e32232 | Ruby | curtcox/cmx-api-app | /sample_location_server.rb | UTF-8 | 3,743 | 2.515625 | 3 | [
"MIT",
"CC-BY-4.0",
"CC-BY-3.0"
] | permissive | #!/usr/bin/ruby1.9
require 'rubygems'
require 'sinatra'
require 'data_mapper'
require 'json'
require 'digest/sha1'
# zip content when possible
use Rack::Deflater
# ---- Parse command-line arguments ----
SECRET = ENV['SECRET']
puts "SECRET is #{SECRET}"
VALIDATOR = ENV['VALIDATOR']
puts "VALIDATOR is #{VALIDATOR}"
d... | true |
0043dba1e1439bdfd74bad7292ba722eb3b5d64a | Ruby | alim/baseballstats | /spec/controllers/search_controller_spec.rb | UTF-8 | 5,712 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe SearchController do
# Setup improved player data
let(:improved_players) {
# Create first few players
3.times.each do |i|
FactoryGirl.create(:batting_improves, player_id: "player#{i}",
year: '2011', team: 'DET')
FactoryGirl.create(:batting_improves, playe... | true |
ac4d2d574068c5ced85118bf0e425fabc3a25407 | Ruby | avo16/destinations | /app/services/fetch_weather.rb | UTF-8 | 596 | 2.921875 | 3 | [] | no_license | require 'uri'
require 'net/http'
require 'openssl'
module FetchWeather
extend self
def call(city)
url = build_url(city)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = false
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
response = http.request(request)
extr... | true |
79923418c26b6063d0c1c4930b87b1fc39cffa3a | Ruby | inutano/rdfsummit | /insdc2ttl/ft_so.rb | UTF-8 | 533 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'json'
hash = {}
ft_so = File.open("ft_so.tsv")
ft_id = File.open("ft_id.tsv")
ft_so.gets
ft_so.each do |line|
ft_term, so_term, so_id, ft_desc, so_desc, skos, = line.split("\t")
hash[ft_term] = {
"so_id" => so_id,
"so_term" => so_term,
"ft_desc" => ft_desc,
"so_des... | true |
ada1cb35df34df942c1aedfefc518f420f264935 | Ruby | dhnascimento/ar-exercises | /exercises/exercise_6.rb | UTF-8 | 935 | 2.984375 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
puts "Exercise 6"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name: "Khurram", last_name: "Virani"... | true |
f30ad5d4f996a3ded55c192a707d83729c8a8097 | Ruby | mimizotti/open_mic | /lib/joke.rb | UTF-8 | 327 | 3.015625 | 3 | [] | no_license | class Joke
attr_reader :id,
:question,
:answer,
:jokes
def initialize(hash={})
@jokes = []
@id = hash[:id]
@question = hash[:question]
@answer = hash[:answer]
end
def id
@id
end
def question
@question
end
def answers
@answer
end... | true |
cafe1dcfa103c7f3ddd67eac1d4f932cdfdb1079 | Ruby | VerityA/W2D5_OOP_Karaoke_exercise | /specs/drink_spec.rb | UTF-8 | 413 | 3.140625 | 3 | [] | no_license | require("minitest/autorun")
require_relative("../drink")
class TestDrink < MiniTest::Test
def setup
@drink1 = Drink.new("V+C",3.5)
@drink2 = Drink.new("G+T", 4.0)
@drink3 = Drink.new("Wine", 6.0)
@drink4 = Drink.new("Beer", 3.75)
end
def test_drink_has_name
assert_equal("G+T", @drink2.drink... | true |
b037fdb1cd7fa581b45de56c7d7f23f44b272749 | Ruby | wtholt/day4 | /horse_race/untitled.rb | UTF-8 | 67 | 3.0625 | 3 | [] | no_license | array = [1, 2, 3, 4, 5]
array.each do |num|
puts array += 1
end
| true |
dbf4397d7e1f4fb743af6085b9583dac960f0fbc | Ruby | jordandavidson1990/week_2_day_2_homework | /specs/bear_spec.rb | UTF-8 | 1,619 | 3.75 | 4 | [] | no_license | # A river should have a name e.g. "Amazon"
#
# A river should hold many fish
#
# A fish should have a name
#
# A bear should have a name e.g. "Yogi" and a type e.g. "Grizzly"
#
# A bear should have an empty stomach ( maybe an array )
#
# A bear should be able to take a fish from the river
#
# A river should lose a fish... | true |
5ea8f20074c02ac4e5d58ae9b2e2f188a655bdd6 | Ruby | yanbinkang/problem-bank | /leetcode/hash_table/ruby/word_pattern.rb | UTF-8 | 1,431 | 3.765625 | 4 | [] | no_license | =begin
https://leetcode.com/problems/word-pattern/
Given a pattern and a string str, find if str follows the same pattern.
Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.
Examples:
pattern = "abba", str = "dog cat cat dog" should return true.
pa... | true |
30c6bb845348c645f48a9f7a77a9963523a8b23b | Ruby | CCCQ2/Euler | /problem20-solved.rb | UTF-8 | 367 | 4.03125 | 4 | [] | no_license | #n! means n (n 1) ... 3 2 1
#For example, 10! = 10 9 ... 3 2 1 = 3628800,
#and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
#Find the sum of the digits in the number 100!
class Integer
def fact
(1..self).reduce(:*)
end
end
puts "FACT 100 = #{100.fact}"
puts 100.... | true |
480afa21600a695755d7f87299e8be6ac651ed42 | Ruby | ForSetGeorgia/Georgian-Budget-API | /app/models/concerns/finance_plannable.rb | UTF-8 | 4,414 | 2.890625 | 3 | [] | no_license | =begin
The Georgian government changes the planned finance sometimes for a
specific budget item (program, priority or agency) and period. For example,
the Ministry of Education may say in January that they plan to spend
1,000,000 lari in the first quarter, and then change that plan
in February to 2,000,000 lari. In the... | true |
51c77e6e2aae3546814138964a262b2118d2ebc0 | Ruby | j-luong/learn_to_program | /ch10-nothing-new/sort.rb | UTF-8 | 899 | 4.28125 | 4 | [] | no_license | #=begin
#10.2: Rite of Passage: Sorting
def sort(array)
recursive_sort(array, [])
end
def recursive_sort(list, sorted_list)
if list.length <= 0
return sorted_list
end
word = list.pop #take last word in array to use for comparison
half_sorted = []
#iterate 'list', comparing eac... | true |
27c102cb6dc43f76c60648ac2db2d07abcc65d91 | Ruby | groundbreakerszh/week1 | /day2/person.rb | UTF-8 | 231 | 3.796875 | 4 | [] | no_license | class Person
attr_reader :name
attr_accessor :age
def initialize(name, age)
@name = name
@age = age
end
end
a_person = Person.new("Bob",29)
puts a_person.name
puts a_person.age
a_person.age = 55
puts a_person.age
| true |
940302662f4bec00ce808a4f04b2afc06d446257 | Ruby | mmanousos/ruby-small-problems | /small_problems/medium1/nine_fibonacci_procedural.rb | UTF-8 | 2,520 | 4.84375 | 5 | [] | no_license | =begin
*assignment*
Fibonacci Numbers (Procedural)
In the previous exercise, we developed a recursive solution to calculating the
nth Fibonacci number. In a language that is not optimized for recursion, some
(not all) recursive methods can be extremely slow and require massive quantities
of memory and/or stack space.
... | true |
88a8fcf96b01756b79cfef01fe706782ad86b731 | Ruby | MarkWaldron/depot | /app/models/line_item.rb | UTF-8 | 254 | 2.609375 | 3 | [] | no_license | class LineItem < ActiveRecord::Base
belongs_to :order
belongs_to :product
belongs_to :cart
def total_price
product.price * quantity
end
def decrement
if self.quantity > 1
self.quantity -= 1
else
self.destroy
end
self
end
end | true |
0821d5bd81eebd532dc9eef1bc507214c434bc6d | Ruby | cwcarlson10/my_code | /Fizz_Buzz.rb | UTF-8 | 174 | 3.53125 | 4 | [] | no_license | x = (1..100)
x.each do |f|
if f % 3 == and f % 5 == 0
puts 'FizzBuzz'
elsif f % 3 == 0
puts 'Fizz'
elsif f % 5 == 0
puts 'Buzz'
else
puts f
end
end | true |
97715f1bd92a489bd13d57fd0d4417de6b5ae6a4 | Ruby | gabteles/coinwatch | /app/services/currencies_service.rb | UTF-8 | 1,196 | 2.859375 | 3 | [] | no_license | module CurrenciesService
MOUNT_URL_FROM_CURRENCY_LIST = lambda do |currencies|
symbols = currencies.pluck(:symbol).join(',')
"https://min-api.cryptocompare.com/data/pricemulti?fsyms=#{symbols}&tsyms=USD"
end
FETCH_EXCHANGE_RATES = lambda do |url|
response = HTTParty.get(url)
... | true |
523eae82ff26bcf8d3bb559da33ee5ab58b0ef24 | Ruby | thisiswei/learn_ruby | /09_book_titles/book.rb | UTF-8 | 218 | 2.90625 | 3 | [] | no_license | class Book
attr_reader :title
def title= title
@title = title.split.map{|t| %w(and in the of a an).include?(t) ? t : t.capitalize}.join(' ')
@title = @title[0].upcase + @title[1..-1]
end
end
| true |
e5630bc1a7c7bd57b3dd385350eccb9a5f6ace57 | Ruby | Basskip/ruby-chess | /lib/board.rb | UTF-8 | 4,370 | 3.0625 | 3 | [] | no_license | class ChessBoard
WIDTH = 8
HEIGHT = 8
CASTLING_ROOK_DEST = {[0,2] => [0,3], [0,6] => [0,5], [7,2] => [7,3], [7,6] => [7,5]}
CASTLING_ROOK_ORIGIN = {[0,2] => [0,0], [0,6] => [0,7], [7,2] => [7,0], [7,6] => [7,7]}
attr_accessor :board
def initialize
@board = Array.new(8*8)
end
d... | true |
3389a4a59aaa830d71f306663c88985e4f5ea1bd | Ruby | docljn/codeclan_16_week | /ruby/week_03/day_3/one_to_many_pizza_shop/one_to_many_pizza_shop_end_code/console.rb | UTF-8 | 593 | 2.640625 | 3 | [] | no_license | require('pry-byebug')
require_relative('./models/pizza_order')
require_relative('./models/customer')
PizzaOrder.delete_all()
Customer.delete_all()
customer1 = Customer.new({
'first_name' => 'Jason',
'last_name' => 'Byrne'
})
customer1.save()
order1 = PizzaOrder.new({
'topping' => 'Mushroom',
'quantity' => '2... | true |
18ae8edb399395e273bb3f602a427a65d6d87641 | Ruby | tbpgr/dslable | /lib/generators/product_codes/cli.rb | UTF-8 | 1,718 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'generators/generators'
require 'erb'
require 'active_support/inflector'
require 'dslable_dsl'
require 'fileutils'
module Dslable::Generators::ProductCodes
class CLI
CLI_TEMPLATE = <<-EOF
#!/usr/bin/env ruby
# encoding: utf-8
require "<%=gem_name%>_core"
require "<%=gem_name%>/version"... | true |
6e858b27c7444ff0988378ac1b58beaf2e7793c2 | Ruby | Fonsan/dunder | /lib/dunder.rb | UTF-8 | 3,939 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'delegate'
require 'thread'
class Dunder
class Future < SimpleDelegator
@@threads = {}
FORBIDDEN = [Symbol]
def self.threads
@@threads
end
def self.ensure_threads_finished(timeout = nil)
@@threads.values.each do |t|
raise 'Thread did not timeout in time' unle... | true |
861cfd93b099734c963017b9ee2cc211ea7766d2 | Ruby | keithrbennett/wordpress_config_parser | /bin/backup-wordpress-db | UTF-8 | 1,882 | 3.28125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# backup-wordpress-db
#
# Calls mysqldump to create a backup of a MySQL data base
# in the form of a .sql file containing the SQL commands
# required to reconstruct it.
#
# Assumptions:
#
# 1) The directory containing the output (backup) files is in a git repo.
#
# 2) Either you have .ssh keys set... | true |
3eb9c68a2905db535ffdbb56e7b898dd91106ff4 | Ruby | oolkhovoy/RMDebugVerification | /verification/simple_expressions/conditions.rb | UTF-8 | 212 | 3.828125 | 4 | [] | no_license | # single lined conditions
age = 22
puts "Sovsem Molodoi!" if age < 25 #bp here and F7
# multiline conditions
age = 7
if age > 0 and age <= 2
puts "baby"
elsif age >= 3 and age <= 12 #bp here and F7
puts "child"
end | true |
8e917e4ef90a86a8f0f26f1e9e20da5af773d0d6 | Ruby | p-reznick/algorithm_exercises | /recursive_pow.rb | UTF-8 | 285 | 3.265625 | 3 | [] | no_license | def my_pow(x, n)
return 1 if n == 0
my_power_helper(x, n)
end
def my_power_helper(x, n, acc=1, counter=0)
acc *= x
counter += 1
return acc if counter == n.abs
my_power_helper(x, n, acc, counter)
end
def my_pow_simple(x, n)
return 1 if n == 0
x * my_pow(x, n - 1)
end
| true |
bdfe1648e49905f733453496668548beb7b19686 | Ruby | pulkit110/activerecord-embedding | /test/test_main.rb | UTF-8 | 2,246 | 2.6875 | 3 | [] | no_license | require 'rubygems'
require 'bundler'
Bundler.setup
require 'debugger'
require 'test/unit'
require 'active_record'
require 'active_record/base'
require 'logger'
require 'activerecord-embedding'
require 'models/invoice'
require 'models/item'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:databa... | true |
46c62c95770a87762d9fcfcf14c425bfe913f02b | Ruby | lesyk/faker_extension_da | /lib/faker-da.rb | UTF-8 | 302 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'faker-da/address'
require 'faker-da/name'
require 'faker-da/phone_number'
require 'faker-da/ssn'
require 'faker-da/time'
module FakerDa
def self.numerify string
string.length.times do |s|
if string[s] == "#"
string[s] = "#{rand(9)}"
end
end
string
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.