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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9ecfd85b50003923a08766f3b8151d475b72df28 | Ruby | shivamb/rails_cache | /db/seeds.rb | UTF-8 | 793 | 2.8125 | 3 | [
"MIT"
] | permissive |
contents = [
'Lorem ipsum dolor sit amet.',
'Consectetur adipisicing elit, sed do eiusmod tempor incididunt.',
'Labore et dolore magna aliqua.',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.',
'Excepteur sint occaecat cupidatat non proident.'
]
puts "Deleting all articles..."
Article.delete_all... | true |
7a5684271497ec73539fc898e4df9ecd08d4785c | Ruby | pete3249/ruby-enumerables-introduction-to-map-and-reduce-lab-prework | /lib/my_code.rb | UTF-8 | 1,029 | 3.515625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def map_to_negativize(source_array)
new_array = []
source_array.length.times do |index|
new_array.push(source_array[index]*-1)
end
new_array
end
def map_to_no_change(source_array)
new_array = []
source_array.length.times do |index|
new_array.push(source_array[index])
end
new_array
end
def map_t... | true |
f19068fa43ad9afa3a0d14e92eb77eb6afaf9c6e | Ruby | Dmemouna/git-thp | /Bureau/exo_ruby/exo_14.rb | UTF-8 | 98 | 3.359375 | 3 | [] | no_license | puts "Entre un nombre "
nombre = gets.to_i
while nombre>=0
puts nombre
nombre= nombre-1
end | true |
f8d3f3a583a4b61dcd8ade04685d12affce0efc1 | Ruby | maker325/ticknetica | /part8/passenger_carriage.rb | UTF-8 | 168 | 2.625 | 3 | [] | no_license | require_relative 'carriage'
class PassengerCarriage < Carriage
def initialize(spaces)
super(spaces, 'Passenger')
end
def take_place
super(1)
end
end
| true |
27227750c2d24a64da3c3ca2c6bb379b19839ffe | Ruby | benSlaughter/utilise | /spec/utilise/hash_spec.rb | UTF-8 | 10,367 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Hash do
describe '#to_bool' do
it 'returns hash with true when key value is 1' do
expect({ 'key' => 1 }.to_bool).to eql('key' => true)
end
it 'returns hash with false when key value is 0' do
expect({ 'key' => 0 }.to_bool).to eql('key' => false)
end
it ... | true |
971ada5c805b4ce9f287d035695f19cc5c5ed78c | Ruby | dckwong/OOPRuby | /mastermind.rb | UTF-8 | 4,873 | 3.546875 | 4 | [] | no_license | module Tools
def check_guess guess, code
right_code = code.map { |col| col }
the_guess = guess.map{ |col| col}
score = {
"in_right_spot" => 0,
"right_color_wrong_spot" => 0
}
to_delete = []
right_code.delete_if.with_index do |color,i|
guess_color = the_guess[i]
if color == guess_color
scor... | true |
d132304b45a7c834aa3c82abeda62e097064182d | Ruby | ncornwell/ProjectRepat | /vendor/plugins/substruct/app/models/user_upload.rb | UTF-8 | 1,426 | 2.8125 | 3 | [
"LicenseRef-scancode-public-domain",
"Artistic-2.0"
] | permissive | # encoding: UTF-8
# Source Code Modifications (c) 2010 Laurence A. Lee,
# See /RUBYJEDI.txt for Licensing and Distribution Terms
# Represents a file uploaded by a user.
#
# Subclassed by Image, Asset, and Download
#
# Before a save, checks to set the type, based on file extension.
#
class UserUpload < ActiveRecord::Ba... | true |
8493e0c20be9386034855d17392464f36d318cf3 | Ruby | bokats/app_academy_homeworks | /W1D5/map.rb | UTF-8 | 726 | 3.34375 | 3 | [] | no_license | class Map
def initialize
@map = []
end
def assign(key, value)
existing_pair = nil
@map.each do |k, v|
existing_pair = [k, v] if k == key
break
end
if existing_pair.nil?
@map << [key, value]
else
@map.delete(existing_pair)
@map << [key, value]
end
[... | true |
9c0f76523598926db91d10b88c2a4edfe28e539e | Ruby | chenyan19209219/gitlab-ce | /lib/system_check.rb | UTF-8 | 770 | 2.59375 | 3 | [
"MIT",
"CC-BY-SA-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
# Library to perform System Checks
#
# Every Check is implemented as its own class inherited from SystemCheck::BaseCheck
# Execution coordination and boilerplate output is done by the SystemCheck::SimpleExecutor
#
# This structure decouples checks from Rake tasks and facilitates unit-test... | true |
af30c20657621551886a71a6a40e980ab12f8903 | Ruby | F-3r/tabla | /lib/tabla.rb | UTF-8 | 824 | 2.984375 | 3 | [] | no_license | class Tabla
include Enumerable
attr_reader :data, :fields, :mapper
class << self
attr_accessor :separator
end
self.separator ||= "|"
def self.dump(hashes)
lines = [hashes.first.keys.join(" #{Tabla.separator} ")]
lines += hashes.map { |i| i.values.join " #{Tabla.separator} " }
lines.join(... | true |
66619dd2eea16159933c2500899c90976e42dd4c | Ruby | Sdcrouse/operators-v-000 | /lib/operations.rb | UTF-8 | 358 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #require 'pry'
def unsafe?(speed)
#binding.pry
if speed < 40 || speed > 60
true
else
false
end
# This is better:
# !speed.between?(40,60)
end
def not_safe?(speed)
#binding.pry
speed < 40 || speed > 60 ? true : false
#Another variation (equivalent to if -> elsif -> else):
#speed < 40 ... | true |
117c6d79bcc15cf919d6d57212a6b0d8faa1620f | Ruby | tauhidul35/bd_location | /lib/bd_location.rb | UTF-8 | 643 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'bd_location/version'
require 'yaml'
module BDLocation
locale = :en
file_path = File.join(File.dirname(__FILE__), "../locales/#{locale.to_s}.yaml")
data = YAML.load_file file_path
@locations = data[locale.to_s]
def divisions
@locations.keys.map(&:capitalize)
end
def districts(division)
... | true |
508106fdb2e18e2ef49db809d8aa92993a814876 | Ruby | danielribeiro/rubytricks | /visibility_simple.rb | UTF-8 | 118 | 2.859375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
class A
def a
#self.b == erro
b
end
private
def b
'b'
end
end
puts A.new.a | true |
21d7b7817fab47886de5baf557576ef7d32d4907 | Ruby | sjclijie/test2 | /ruby/yield.rb | UTF-8 | 159 | 3.234375 | 3 | [] | no_license | #encoding=utf-8
def myloop()
i = 0
while true
yield(i += 1)
end
end
num = 1
myloop do |x|
print "Hello"
puts x
break if num > 100
num *= 2
end
| true |
e9bfc46840364078b4b28cfe37f18b6f7d33fcbd | Ruby | ksupasak/gxt | /services/miot-monitor/devices/nihon_defib_lib.rb | UTF-8 | 10,542 | 2.75 | 3 | [] | no_license |
class NihonDef
attr_accessor :content
attr_accessor :l
attr_accessor :p
attr_accessor :start
attr_accessor :pointers
def initialize file_name
file = File.open(file_name,'r')
@content = file.read
@p = 0
@l = content.each_byte.to_a.collect{|i| i.to_i}
@pointers = {}
... | true |
e5b0f4f7cc6181efd02c3c661dfbd5528326a749 | Ruby | ParkerHJones/update_casino | /update_Casino.rb | UTF-8 | 1,695 | 3.984375 | 4 | [] | no_license | require 'colorize' #using this to portray that game is communicating to user
require_relative 'person'
require_relative 'Game_One'
require_relative 'Game_Two'
require_relative 'Game_Three'
class CasinoJones
def initialize
@person = Person.new
display_menu #this calls the method below of the menue to be sh... | true |
3bd8db81964c94f80756ef976dba65caf29e80ea | Ruby | cristina1997/hw-sinatra-saas-hangperson | /lib/hangperson_game.rb | UTF-8 | 2,681 | 3.90625 | 4 | [] | no_license | class HangpersonGame
# add the necessary class methods, attributes, etc. here
# to make the tests in spec/hangperson_game_spec.rb pass.
attr_accessor :word, :guesses, :wrong_guesses
# Get a word from remote "random word" service
def initialize(word)
@word = word
@guesses = ''
@wrong_guesses =... | true |
d80369388e89248046b96dfed3b320d0335a4589 | Ruby | nathanworden/RB130-Ruby-Foundations-More-Topics | /06.Ruby Challenges/05.advanced_1/01.ocr_numbers.rb | UTF-8 | 3,742 | 4.09375 | 4 | [] | no_license | # Given a 3 x 4 grid of pipes, underscores, and spaces
# Output: string of numbers
# - singular number
# - representation of each number, 0 ~ 9
# - look up
# - return ? for invalid input
# - multiple numbers
# - need to convert grid of (3*n) x 4 into n grids of (3x4)
# - break a 3*n length string into n g... | true |
d83c030841d4278d991193408e77a3e2e9f53b52 | Ruby | Dark-Sun/relink_api | /lib/extensions/hash.rb | UTF-8 | 389 | 2.765625 | 3 | [
"MIT"
] | permissive | class Hash
def deep_stringify_keys
inject({}) do |hash, (key, value)|
value = value.stringify_keys if value.is_a?(Hash)
hash[key.to_s] = value
hash
end
end
def deep_camelize_keys
inject({}) do |hash, (key, value)|
value = value.is_a?(Hash) ? value.deep_camelize_keys : value
... | true |
e2bc74262608ef6113db2e6bdab198fb6c1a040f | Ruby | ewelinaszoda/ruby-oo-self-count-sentences-lab-lon01-seng-ft-042020 | /lib/count_sentences.rb | UTF-8 | 819 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
self.split(/\.|\?|\!/).delete_if {|sentence| sentence.size == 0}.count
# self.split(/[.?!]/).grep(/\S/).count
end ... | true |
5149bab20adad0adc9907d1cebedcefb50e46c40 | Ruby | helloRupa/Launch-School | /Intro Book/Loops/e04.rb | UTF-8 | 231 | 4.09375 | 4 | [] | no_license | #Write a method that counts down to zero using recursion
def count_to_zero(num)
puts num
if num > 0
count_to_zero(num - 1)
end
end
count_to_zero(10)
puts "----------"
count_to_zero(0)
puts "----------"
count_to_zero(-5) | true |
949f3668f4107845aaeaa89b02a6d603e88c57d4 | Ruby | SeaWar741/Codeacamp | /Prework/semana_3/Miercoles/rectangulo.rb | UTF-8 | 922 | 4.40625 | 4 | [] | no_license | class Rectangle
attr_accessor :width, :height
def initialize(width, height)
@width = width
@height = height
end
def area
@width * @height
#ancho por alto
end
def perimeter
(@width*2) + (@height*2)
#el ancho x2 mas el alto x2
end
def diagonal
Math.hypot(@h... | true |
0fb16bdc8addc423094eaddcd4e8103528862af8 | Ruby | uharston/regex-lab-onl01-seng-ft-050420 | /lib/regex_lab.rb | UTF-8 | 985 | 3.984375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
#how to return a boolean?
def starts_with_a_vowel?(word)
word.match? (/\b[aeiou]/i)
end
#how to return an array of words? .scan
def words_starting_with_un_and_ending_with_ing(text)
result = text.scan(/\bun\w+/) + text.scan(/ing\b\w+/)
result.uniq
end
def words_five_letters_long(text)
text.scan(/\b\... | true |
522af6663a885772bfbec24c3a95c93f941d6631 | Ruby | TesterTure/blog-examples | /ice_cube/rule.rb | UTF-8 | 1,071 | 2.921875 | 3 | [] | no_license | # encoding: utf-8
require 'ice_cube'
include IceCube
# Every fourth day
schedule = Schedule.new(Date.today)
schedule.add_recurrence_rule Rule.daily(4)
p schedule
# Every other week, on Mondays and Fridays
schedule = Schedule.new(Date.today)
schedule.add_recurrence_rule Rule.weekly(2).day(:monday, :friday)
p sc... | true |
aceb7c536ae931f7051d3fb7334a1a25dce4e69d | Ruby | base-api-io/base-ruby | /lib/base/endpoints/emails.rb | UTF-8 | 1,313 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Base
module Endpoints
# This endpoint contains methods for sending emails.
class Emails < Endpoint
# Initializes this endpoint.
def initialize(access_token:, url:)
@path = 'emails'
super
end
# Lists the emails of a project
de... | true |
3ff5a43ccb891c77e10b2403163afe357ff5018e | Ruby | cedlemo/rtruckboris | /test/enums.rb | UTF-8 | 688 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "rtruckboris"
#require File.dirname(__FILE__) + "/../lib/rtruckboris"
parser = Rtruckboris::HeaderParser.new("./test_cpp", ["/usr/include"])
if (!parser.parse) then
puts "Whada fock??"
exit
end
enums = parser.enums()
puts "Enums number : #{enums.size}"
enums.each do |e|
puts "Enum ... | true |
2f8a9c5f8fedcf798018af736ff544ebda9e4436 | Ruby | bmorrall/fun_with_json_api | /lib/fun_with_json_api/attributes/string_attribute.rb | UTF-8 | 592 | 2.5625 | 3 | [
"MIT"
] | permissive | module FunWithJsonApi
module Attributes
class StringAttribute < Attribute
def decode(value)
return value if value.nil? || value.is_a?(String)
raise build_invalid_attribute_error(value)
end
private
def build_invalid_attribute_error(value)
payload = ExceptionPayloa... | true |
8d5ef8fa1e72c1e5614cdfae81c1f861339e71e9 | Ruby | miketracy/wwmd | /lib/wwmd/guid.rb | UTF-8 | 4,435 | 2.546875 | 3 | [
"MIT"
] | permissive | =begin rdoc
Guid - Ruby library for portable GUID/UUID generation.
Copyright (c) 2004 David Garamond <davegaramond at icqmail com>
This library is free software; you can redistribute it and/or modify it
under the same terms as Ruby itself.
(small hack to fix for mac mtracy@matasano.com)
=end
if RUBY_PLATFORM =~ /wi... | true |
beffb6a6378a4fbef9540f77736ea0f29b83bdc2 | Ruby | timlkelly/phase-0 | /week-6/die-2/my_solution.rb | UTF-8 | 2,653 | 4.40625 | 4 | [
"MIT"
] | permissive | # Die Class 2: Arbitrary Symbols
# I worked on this challenge [by myself].
# I spent [1.5] hours on this challenge.
# Pseudocode
# Input: An array of strings
# Output: A single element from the input array at random
# Steps:
# Create required methods for the class
# -Initialize
# -create instance variable and a rea... | true |
1faff56f134097cd44c1354133a4a79809a832fc | Ruby | ministryofjustice/correspondence_tool_staff | /lib/tasks/rake_task_helpers/sars_loader.rb | UTF-8 | 1,450 | 2.90625 | 3 | [
"MIT"
] | permissive | require "csv"
# This class is used for loading a list of teams into the dev database from the R006_kilo_map CSV
# file (useful for testing scripts to assign correpsondence types to certain business units only)
#
class SarsLoader
def initialize(filename)
@filename = filename
@foi = CorrespondenceType.find_by(... | true |
1b16df1f635e1e59df55dc155c8e496cbdc2c6c0 | Ruby | cannikin/dovetail | /vendor/gems/haml-2.0.9/lib/haml/helpers.rb | UTF-8 | 13,129 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'haml/helpers/action_view_mods'
require 'haml/helpers/action_view_extensions'
module Haml
# This module contains various helpful methods to make it easier to do
# various tasks. Haml::Helpers is automatically included in the context
# that a Haml template is parsed in, so all these methods are at your
... | true |
4a8245e5c09f1594bc4bc21f1d5ad106392f9192 | Ruby | nedap/samsara | /lib/samsara/http_request.rb | UTF-8 | 563 | 2.515625 | 3 | [
"MIT"
] | permissive | class Samsara::HttpRequest
attr_accessor :attributes
def self.build_from(controller)
self.new(extract_attributes_from controller)
end
def self.extract_attributes_from(controller)
{
url: controller.request.filtered_path,
params: controller.request.filtered_parameters,
method:... | true |
79e74ba021793a0a0a62df10e7749a107214d0a6 | Ruby | AntonDementev/Thinknetica-Lessons | /Lesson 4/passenger_train.rb | UTF-8 | 151 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
class PassengerWaggon; end;
class PassengerTrain < Train
def check_waggon(waggon)
waggon.class == PassengerWaggon
end
end
| true |
99b38f75679a60e8e3f8c3898cfd55163032f692 | Ruby | JaviBL8/PDOO | /QytetetRuby/lib/titulo_propiedad.rb | UTF-8 | 1,416 | 2.546875 | 3 | [] | no_license | #encoding: utf-8
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module ModeloQytetet
class TituloPropiedad
attr_accessor :hipotecado
attr_reader :alquiler_base, :factor_revalor... | true |
81d3850bbe5a6853765d847fc44149807454f7ff | Ruby | anoskov/test_task | /data_scraper.rb | UTF-8 | 2,057 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env ruby
# name: Data_Scraper
# copyright: © 2015 Andrew Noskov
# author: Andrew Noskov <flashbulb54@gmail.com>
require 'capybara'
class DataScraper
include Capybara::DSL
def initialize(*args)
Capybara.default_driver = :selenium
@sn, @fetch_type = args
raise Argu... | true |
74c861dd7cb94bd32af08aa98745c80fe70bb97e | Ruby | lekegitrepo/algorithms-and-data-structure | /Sorting-Algorithms - ruby/bubble_sort.rb | UTF-8 | 730 | 3.765625 | 4 | [] | no_license | # frozen_string_literal: true
def bubble_sort(arr_list)
n = arr_list.length
loop do
swapped = false
(n - 1).times do |a|
if arr_list[a] > arr_list[a + 1]
arr_list[a], arr_list[a + 1] = arr_list[a + 1], arr_list[a]
swapped = true
end
end
break unless swapped
end
arr_l... | true |
8e782226ef66c0d73a466f2bce23690c957ed5fc | Ruby | iachettifederico/apcvc | /app/loaders/csv_book_loader.rb | UTF-8 | 230 | 2.53125 | 3 | [] | no_license | class CsvBookLoader
def load(csv)
book_attrs = []
CSV.foreach(csv.path, headers: true) do |row|
attrs = row.to_hash
attrs.delete("id")
book_attrs << attrs
end
Book.create!(book_attrs)
end
end
| true |
0bb9799be217277654bf46129d62e184a2028650 | Ruby | NullPxl/ruby_codewars_solutions | /count_sheep.rb | UTF-8 | 779 | 4.4375 | 4 | [] | no_license | # # 8 kyu
# # Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present).
def countSheeps(array)
return array.count{|v|v}
end
puts countSheeps([true, true, true, false,
true, true, true, true ,... | true |
a4161c5aac9ea809616b5050d840346fdb6232a8 | Ruby | flexera-public/right_link | /scripts/cloud_controller.rb | UTF-8 | 6,167 | 2.53125 | 3 | [
"MIT"
] | permissive | # === Synopsis:
# RightScale Cloud Controller (cloud) - Copyright (c) 2014 by RightScale Inc
#
# cloud is a command line tool which invokes cloud-specific actions
#
# === Examples:
# Write cloud and user metadata to cache directory using default cloud:
# cloud --action=write_metadata
#
# Write user metadata... | true |
58ac7eaabad6e90d4d67492ad3f36fa206e7c92e | Ruby | ruby-compiler-survey/natalie | /lib/optparse.rb | UTF-8 | 3,089 | 2.9375 | 3 | [
"MIT"
] | permissive | class OptionParser
class Switch
attr_accessor :short_name, :long_name, :value_label, :value_type, :description, :value
def initialize(short_name, long_name, value_label, description, block)
@short_name = short_name&.sub(/^\-/, '')&.to_sym
@long_name = long_name&.sub(/^\-\-/, '')&.to_sym
@va... | true |
eb8eaedb88084a0f6d98bfae025d4ecf03209820 | Ruby | beatrizpaula/swmaint | /src/model/action_on_entity.rb | UTF-8 | 317 | 3.078125 | 3 | [] | no_license | #
# Class representing an action on a specific entity.
#
# Author: Benoît Duhoux
# Date: 2018
#
class ActionOnEntity
attr_reader :action, :entity
def initialize(action, entity)
# Check the action to give feedback
@action = action
@entity = entity
end
def to_s()
return "#{@action} - #{entity.name}"
end
... | true |
68d0f7083615302cb7205ae97d88370f25082f28 | Ruby | stefanhendriks/katas | /ocrbank/ruby/12-11-2012/fileparser.rb | UTF-8 | 320 | 3.125 | 3 | [] | no_license | class FileParser
attr_reader :ocrbank
def initialize(ocrbank)
@ocrbank = ocrbank
end
def readFromFile(filename)
file = File.new(filename, "r")
input = ""
while (line = file.gets)
input += line
end
lines = input.split("\n")
lines.each_slice(4) do | slice |
@ocrbank.read(slice)
end
end
end | true |
3b29a4c3641ca5f0d86995820cc48f9b7e5792db | Ruby | MikiDi/mu-search | /lib/mu_search/index_builder.rb | UTF-8 | 5,827 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'parallel'
require 'concurrent'
module MuSearch
class IndexBuilder
def initialize(logger:, elasticsearch:, tika:, sparql_connection_pool:, search_index:, search_configuration:)
@logger = logger
@elasticsearch = elasticsearch
@tika = tika
@sparql_connection_pool = sparql_connection... | true |
d20199111f728012204b75dbfdda65a3ce4ec339 | Ruby | akimikimikimikimikimikimika/LangComparison | /Ruby/Legacy/Calc.rb | UTF-8 | 3,468 | 3.703125 | 4 | [] | no_license | #! /usr/bin/env ruby
require_relative "Utility.rb"
def Calc
println """
これから数学演算を試します
進数変換
433045 = #{"433045".to_i(6)} (6進数 → 10進数)
35669 = #{35669.to_s(14)} (10進数 → 14進数)
"""
# 2~36進数に変換可能
# to_i : 整数に変換
# to_f : 浮動小数に変換
# to_c : 複素数に変換
# to_r : 有理数に変換
# to_s : 文字列に変換
println """
dec2bin 138... | true |
54207717fb9b69871808f4ff64935ef8f0ffc77e | Ruby | dizhu/inav | /extras/taobao/util.rb | UTF-8 | 440 | 2.828125 | 3 | [
"MIT"
] | permissive | module Taobao
class Util
class << self
def millisecond_to_time(millisecond)
Time.at(millisecond/1000)
end
def to_taobao_time(time)
time.strftime(TIME_FORMAT)
end
def to_taobao_time_from_millisecond(millisecond)
time = millisecond_to_time(millisecond)
... | true |
2013827958e068de4cc7f208503fcec4beefac81 | Ruby | njaffer/umrdr | /lib/build_content_service.rb | UTF-8 | 4,561 | 2.6875 | 3 | [] | no_license | require 'hydra/file_characterization'
Hydra::FileCharacterization::Characterizers::Fits.tool_path = `which fits || which fits.sh`.strip
# Given a configuration hash read from a yaml file,
# build the contents in the repository.
class BuildContentService
def self.call( path_to_config )
config = YAML.load_file(pa... | true |
8f0b4e142bd2bc544edb016d06e1f53dd0e584a3 | Ruby | christhomson/smart_properties | /spec/base_spec.rb | UTF-8 | 3,389 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe SmartProperties do
it 'should add a protected class method called .property when included' do
klass = Class.new { include SmartProperties }
expect(klass.respond_to?(:property, true)).to eq(true)
expect { klass.property }.to raise_error(NoMethodError)
end
context ... | true |
fd0c5be9c9a2b5f9d67759068cc134e0dea7ab8b | Ruby | philb56/GildedRose-Refactoring-Kata | /ruby/spec/features/product_specific_item_backstage_passes_spec.rb | UTF-8 | 2,831 | 2.796875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../../lib/gilded_rose.rb'
describe ItemEscalatingQuality do
context 'Quality increases by 1 when there are > 10 days' do
subject(:backstage) { described_class.new('Backstage passes to a TAFKAL80ETC concert', 15, 0) }
let(:items) { [backstage] }
let(:gilded... | true |
d8551c883746ab61fc40d0ee9c7cc082ab56fc3a | Ruby | PhreeMason/LeagueHelper-cli-app | /lib/LeagueHelper/cli.rb | UTF-8 | 2,285 | 3.375 | 3 | [
"MIT"
] | permissive |
class LeagueHelper::CLI
attr_accessor :summoner, :input
def call
puts "Welcome to League Helper"
new_summoner
end
def options
while @input != 'exit'
puts ""
puts "Please enter the number for the area of game play you would like to improve"
puts "Or enter 'exit' to quit"
p... | true |
bf0cd00f607e3eee059ee82885dc36d0410d6b4e | Ruby | Zach-Haddad/AA_class_work | /w2/w2d1/chess/board.rb | UTF-8 | 2,690 | 3.75 | 4 | [] | no_license | require_relative 'piece'
class Board
attr_reader :grid
def initialize(grid = nil)
if grid.nil?
make_starting_grid
else
@grid = grid
end
end
def make_starting_grid
@grid = Array.new(8) { Array.new(8) }
create_named_row(0, :white)
create_pawn_row(1, :white)
create_pawn_... | true |
92c3b867cba25abe9efc378e007575cf61cad449 | Ruby | debugger1809/Classes_Objects_Variables | /Palindrome_2.rb | UTF-8 | 268 | 3.78125 | 4 | [] | no_license | class Strings
def palindrome(s)
if s.include?(" ")
s.gsub!(/ /, "")
end
s1 = s.split(",").map {|s| s.to_s}
s1 = (s.to_s == s.reverse.to_s ? true : false)
puts s1
end
end
a1 = Strings.new
s = ARGV[0].dup
s.downcase!
a1.palindrome(s)
| true |
aab052107cb21db9ad660e24f7ee4b489a39ac6c | Ruby | bitbond/bitcoinppi | /lib/bitcoinaverage_historical_price_source.rb | UTF-8 | 1,143 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "price_source"
class BitcoinaverageHistoricalPriceSource < PriceSource
URL = "https://api.bitcoinaverage.com/history/%s/per_day_all_time_history.csv"
def fetch_data
data = Hash.new { |h, k| h[k] = [] }
Config["currencies"].each do |symbol|
csv_response(symbol).each do |row|
price = ... | true |
65f536bd22af356919ae8e774356ed248e63029c | Ruby | bkconrad/gonad | /glyph_map.rb | UTF-8 | 647 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
module GlyphMap
GLYPHMAP = {
# [ char, color, style ]
['+', :brown, :normal ] => :door,
['-', :brown, :normal ] => :door,
['|', :brown, :normal ] => :door,
['+', :none, :normal ] => :wall,
['-', :none, :normal ] => :wall,
['|', :none, :normal ] => :wall,
[' ', :n... | true |
b88955ee3700983319a1888a8bbc6546834517e7 | Ruby | Kasama/mapPainter | /src/map_reader.rb | UTF-8 | 1,391 | 3.34375 | 3 | [] | no_license | class MapReader
def self.read_map
=begin
all lines in the file follow /^.+:.*\.$/
^ = beginning of line
.+ = any character 1 or more times
: = ':' literally
.* = any character 0 or more times
\. = '.' literally
$ = end of line
=end
# open file to read
file = ARGF
# init... | true |
4ae4c16b1747fd0a13b8faa23159a916ac2b73a2 | Ruby | claricardo/RubyBuildingBlocks | /tic_tac_toe.rb | UTF-8 | 4,731 | 3.609375 | 4 | [] | no_license | # TicTacToe module
# Contains classes that implement a Tic-Tac-Toe game.
#
# Usage from irb:
# 1. $LOAD_PATH << "absolute_path_to_the_directory_containig_this_file"
# 2. require 'tic_tac_toe.rb'
# 3. include TicTacToe
# 4. TTTGame.new.play
#
# Enjoy it!
module TicTacToe
# Represents a player info
Player = Struct.... | true |
e0c37d9a88dd74b1a493cb8b1ad1360e5e952111 | Ruby | ikalu/Challenge | /multiplesFindr.rb | UTF-8 | 371 | 3.90625 | 4 | [] | no_license | class Multiples
def find_multiples
sum = 0
(1..1000).each do |num|
if num % 15 == 0
print num
print ' '
sum += num
puts sum
elsif (num % 3 == 0 or num % 5 == 0)
print num
print ' '
sum += num
puts sum
end
end
puts sum... | true |
286378cb7415897203f947e8e8b6f279768b00a9 | Ruby | kgotoh5557/accounts_app | /app/models/account.rb | UTF-8 | 4,187 | 2.578125 | 3 | [] | no_license | class Account < ApplicationRecord
# self.primary_key='id'
# has_many:deposits,:foreign_key=>'account_id'
validates :cust_id, {presence: true}
validates :sales_date, {presence: true}
validates :amount, {presence: true, numericality: { only_integer: true }}
validates :user_id, {presence: true}
... | true |
b27878760b1510a59e1de7b14065de24ed78f19d | Ruby | nysol/doc | /olddoc/mcmd/en/examples/mtab2csv.rb | UTF-8 | 787 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
require "./mkTex.rb"
File.open("dat1.tab","w"){|fpw| fpw.write(
<<'EOF'
id data data2
A 1102 a
A 2203 aaa
B 1155 bbbb
B 3104 c
B 1206 de
EOF
)}
File.open("dat2.bar","w"){|fpw| fpw.write(
<<'EOF'
id-data-data2
A-1102-a
A-2203-aaa
B-1155-bbbb
B-3104-c
B-1206-de
EOF
)}
############... | true |
77488b60c01ec179982c31c8ab489e29459bf013 | Ruby | djsmentya/interfeedom | /app/admin/dashboards.rb | UTF-8 | 2,170 | 2.546875 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
ActiveAdmin::Dashboards.build do
# Define your dashboard sections here. Each block will be
# rendered on the dashboard in the context of the view. So just
# return the content which you would like to display.
# == Simple Dashboard Section
# Here is an example of a simple dashboard ... | true |
92097bbb08d3c6746bb021da63583e68e51948c1 | Ruby | google-code/7531-presentacion-de-ruby | /Informe/codes/sintaxis_clases_01.rb | UTF-8 | 160 | 3.546875 | 4 | [] | no_license | class C
def initialize ()
@i = "ok"
end
def get_i ()
return @i
end
end
c = C.new ()
p (c.get_i ()) # "ok" is displayed | true |
f2f7a2d49c2df896b58999be0cd74c5bfd9b3493 | Ruby | anggadarkprince/learn-ruby | /src/exercises/cvowels.rb | UTF-8 | 230 | 3.734375 | 4 | [] | no_license | print("Enter a sentence: ")
sentence = gets
sentence = sentence.chomp
letters = sentence.split(//)
vc = 0
for letter in letters
case letter
when "a", "e", "i", "o", "u" then
vc += 1
end
end
print("Vowel count: ", vc) | true |
a0cb128e7cd305808c7ee2aa57573461669cc3f3 | Ruby | lebrancconvas/Ruby-Lab | /anagram.rb | UTF-8 | 484 | 3.578125 | 4 | [] | no_license | def anagram(inputs)
char_inputs = inputs.chars
uniqchar = char_inputs.uniq
for i in (0...uniqchar.length)
if uniqchar[i] == " "
uniqchar.delete_at(i)
end
end
if uniqchar.length == 26
print "#{inputs}\nIt's Anagram\n"
else
print "#{inputs}\nIt's not A... | true |
bc4b9c76de1b6f85cd98fa1d75fe85306fcf037d | Ruby | hhemanth/vp-crawler | /trial_scrape_courses.rb | UTF-8 | 2,525 | 2.84375 | 3 | [
"MIT"
] | permissive |
require 'rubygems'
require 'nokogiri'
require 'csv'
DATA_DIR = "nptel-courses1"
discipline_ids = [101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,125]
course_list = Array.new
i = 0
discipline_id = 108
#discipline_ids.each do |discipline_id|
local_fname = "#{DATA_DIR}/#{di... | true |
5aa857ebbce3fd4ca3e41a2272b0ad90d674a45c | Ruby | akshat2412/badges-and-schedules-cb-gh-000 | /conference_badges.rb | UTF-8 | 784 | 3.984375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
str="Hello, my name is #{name}."
str
end
def batch_badge_creator(names_array)
msg_array=[]
names_array.each do |name|
msg_array.push(badge_maker(name))
end
msg_array
end
def assign_rooms(names_array)
room_assgn_array=[]
room_no=1
names_array.each do ... | true |
0b3582afc3ed17fa0b32d6c8cc795ee01fcaf634 | Ruby | xhocquet/Flutter | /app/controllers/admin_controller.rb | UTF-8 | 2,713 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'json'
class AdminController < ApplicationController
def index
@admin_message = "index"
render :index
end
def importAnime
for i in 1..12000
if(!Anime.exists?(:hm_id => i))
createAnimeRecord(i)
end
end
@admin_message = "Anime database updated."
render :index... | true |
8855bb057e9e5029ec57708327f9271951672d1a | Ruby | qpowell/shakespeare_analyzer | /spec/shakespeare_analyzer_spec.rb | UTF-8 | 956 | 3.078125 | 3 | [] | no_license | require_relative '../lib/shakespeare_analyzer.rb'
describe ShakespeareAnalyzer do
let(:analyzer) { ShakespeareAnalyzer.new(@xml) }
describe '#run' do
it 'returns an empty hash if there is no data to parse' do
@xml = ""
expect(analyzer.run).to eq({})
end
it 'counts the number of lines a sp... | true |
45e8366c91895d2223970d6b90f8e300977d133b | Ruby | brendanekane/whiteboarding_solutions | /leet_code/linked_lists/merge_k_lists.rb | UTF-8 | 750 | 3.71875 | 4 | [] | no_license | # // Merge k sorted linked lists and return it as one sorted list.
# //
# // Example:
# //
# // Input:
# // [
# // 1->4->5,
# // 1->3->4,
# // 2->6
# // ]
# // Output: 1->1->2->3->4->4->5->6
#
#
def merge_k_lists(arr)
new_head, cur = null, null
until arr.empty?
next_val, idx = nil, 0
arr.each_with_... | true |
ac83bd3695df1c63541099592262836d724a4e66 | Ruby | wendy0402/tic-tac-toe | /libs/board.rb | UTF-8 | 1,063 | 3.46875 | 3 | [] | no_license | require 'matrix'
class Board
attr_reader :size
attr_accessor :matrix
def initialize(size)
@empty_mark = "-"
@size = size.to_i
@matrix = Matrix.build(@size){|row, col| @empty_mark}
end
def update_matrix(val, opt = {})
if (0..@size).include?(opt[:y].to_i) && (0..@size).include?(opt[:x].to_i)
... | true |
e870388033c9f274ce93c285659f6d79bc755f65 | Ruby | jenlaister/my-select-web-1116 | /lib/my_select.rb | UTF-8 | 496 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # def my_select(collection)
# if self.instance_of?(collection)
# i = 0
# while i < self.size
# yield(self[i])
# i += 1
# end
# self
# elsif self.instance_of?(Hash)
# i = 0
# arr = self.to_a
# while i < arr.size
# yield(arr[i][0], arr[i][1])
# i += 1
# end
# ... | true |
6b529a1cf5905061a00ef7e0a3dd8d2575a739b1 | Ruby | Kinwaras/RUBY | /exo_07.rb | UTF-8 | 139 | 3.046875 | 3 | [] | no_license | puts "Bonjour, c'est quoi ton blase ?"
user_name = gets.chomp
puts user_name
#Demande le nom puis réécrit ce qu'on tape dans la console# | true |
b7e00b54708a947ffec6dd1310609484ba4f4873 | Ruby | yielding/code | /0.algorithm/passcode.rb | UTF-8 | 1,163 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "deep_clone"
require "digest/sha1"
class Passcode
def initialize
@sha1 = Digest::SHA1.new
@passcode = {}
@candidates_hash = {
0 => [1, 2, 3, 4, 5, 6, 7, 8, 9], # for start
1 => [2, 4, 5],
2 => [1, 3, 4, 5, 6],
3 => [2, 5, 6],
4 => [1, 2, 5, 7, ... | true |
86941313a593edb133209b22b7decc1f98bdcdc2 | Ruby | sakif-imtiaz/chess-rails | /lib/chess/move.rb | UTF-8 | 623 | 3.078125 | 3 | [] | no_license | # require_dependency './position'
class Move
attr_accessor :piece, :destination, :promotion
def initialize(piece, destination, promotion = nil)
# throw StandardError.new if !piece
self.piece = piece
self.destination = destination
self.promotion = promotion
end
def short
{origin: piece.position.short,
... | true |
53b0971ad238eb65942925f1203a6dd4cebe3765 | Ruby | alekseydreval/CoreWar | /lib/redcode_file_parser.rb | UTF-8 | 1,664 | 2.828125 | 3 | [] | no_license | module CoreWar
class RedcodeFileParser
ALLOWED_COMMANDS = %w(MOV ADD SUB MUL DIV MOD JMP JMZ JMN JMG DJZ CMP SEQ SNE DAT SPL DJN ORG)
attr_reader :commands
def initialize(opts = {})
@commands = []
end
def parse_file(file)
File.open(file).each_line { |line| parse_line(line)... | true |
42aea9076b685287a83b37f1f97dff2b6d3a64b7 | Ruby | Sajonara/Ruby | /lotto/lotto2.rb | UTF-8 | 698 | 4.0625 | 4 | [] | no_license | # Dieses Programm gibt gleich sechs Zufallszahlen aus, und zwar Lottozahlen (6 aus 49).
# Dabei verwendet es ein Array und Bedingungen, sowie die Sprungmarke next.
# Im Vergleich zu lotto1.rb wird das Programm so deutlich weniger umfangreich.
lottozahlen = []
loop do
number = rand(49) + 1
if lottozahlen.inclu... | true |
cc4eed5217346ed4c31cf3345ca28df4e2285cbb | Ruby | tablework/tablework | /spec/controllers/characters_controller_spec.rb | UTF-8 | 5,548 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe CharactersController, :type => :controller do
let(:user) { create :user }
let(:character) { create(:character, user: user)}
let!(:note) { create :note }
context "when logged in" do
before do
sign_in :user, user
end
describe "GET #index" do
it "ret... | true |
2273f9d643d34c5ddd2db2a9ea87d5c8f0912e00 | Ruby | bensheldon/codeadvent | /2020/day_02.rb | UTF-8 | 637 | 2.84375 | 3 | [] | no_license | require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pry'
end
lines = File.read('day_2.txt').strip.split("\n")
lines.count do |line|
_string, min, max, letter, password = line.match(/(\d*)-(\d*) ([a-z]): (.*)/).to_a
count = password.count(letter)
count >= min.to_i && count <= max.to_i
en... | true |
35a91c503080733486189e29d24defca9b340802 | Ruby | arcanoid/multi-cool | /app/controllers/format_conversions_controller.rb | UTF-8 | 2,094 | 2.640625 | 3 | [
"MIT"
] | permissive | class FormatConversionsController < ApplicationController
def xml_to_json
text = params[:initial_text].present? ?
params[:initial_text] :
"<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>"
begin
@initial_text = text
j... | true |
d7d8c176ca1745264e4d71ee2c45373c9f147a4a | Ruby | windkidtrh/blog_test | /app/models/user.rb | UTF-8 | 3,356 | 2.546875 | 3 | [] | no_license | # == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string
# email :string
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string
# token :string
# admin ... | true |
df2133435bbf5a7fdf31460d9bc2666a5d1bfeb1 | Ruby | jeannegreulich/rubygem-simp-rake-helpers | /lib/simp/rake/helpers/assets/rpm_spec/simp5.spec | UTF-8 | 9,201 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | %{lua:
--
-- When you build you must to pass this along so that we know how
-- to get the preliminary information.
-- This directory should hold the following items:
-- * 'build/rpm_metadata/requires' <- optional list of 'Requires', 'Provides',
-- and 'Obsoletes' to supplement those auto-generated in this spec ... | true |
65e7295fb2064dd3319dc7f2eaf803f7ebb11a22 | Ruby | askl56/tty | /spec/tty/shell/question/modify_spec.rb | UTF-8 | 1,262 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
require 'spec_helper'
describe TTY::Shell::Question, '#modify' do
let(:input) { StringIO.new }
let(:output) { StringIO.new }
let(:shell) { TTY::Shell.new(input, output) }
it 'preserves answer for unkown modification' do
input << 'piotr'
input.rewind
q = shell.ask("What is your... | true |
4296cd6048a08144c7ee98c191c5ed75afff3862 | Ruby | Aperta-project/Aperta | /app/services/user_mentions.rb | UTF-8 | 2,208 | 2.84375 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2018 Public Library of Science
# 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, modify, merge, pub... | true |
ef418f6338b9eca34c8cf19fe8f86a92146d3492 | Ruby | Ballycyrk/sea-c17-ruby | /class2/8_table_of_contents.rb | UTF-8 | 819 | 4.21875 | 4 | [] | no_license | # Section 6.2 on page 32
# 4 points
#
# Here’s something for you to do in order to play around more with center,
# ljust, and rjust: write a program that will display a table of contents so
# that it looks like this:
#
# Table of Contents
#
# Chapter 1: Getting Started page 1
# Chapter ... | true |
0f739db68fb319c06c37523c6973efd53fe84bf9 | Ruby | austinKurtis/Ruby-Classes | /bank.rb | UTF-8 | 894 | 3.46875 | 3 | [] | no_license | class Customer
attr_accessor :accountNumber
attr_accessor :firstName
attr_accessor :lastName
def initialize(fn, ln, acct)
@accountNumber = acct
@firstName = fn
@lastName = ln
end
end
class Bank
attr_accessor :name
attr_accessor :address
attr_accessor :lastName
... | true |
54674adf66889f13fce250983de3df18c0a0eed6 | Ruby | namelessjon/exalted_math | /lib/exalted_math/node/number.rb | UTF-8 | 428 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'exalted_math/node/node'
module ExaltedMath
class Node
class Number < Node
def initialize(value)
@value = value
end
def constant?
true
end
def value(context={})
@value
end
def ==(o)
return false unless self.cl... | true |
b29ac41bbfd37792817df1f8776ef8cb19d44407 | Ruby | PeaShooterBob/todo-list | /app/services/all_projects_and_items_exporter.rb | UTF-8 | 465 | 2.765625 | 3 | [] | no_license | class AllProjectsAndItemsExporter
def initialize(projects: Project.all, output_stream: $stdout, item_formatter: ItemFormatter)
@projects = projects
@output_stream = output_stream
@item_formatter = item_formatter
end
def export
@projects.each do |project|
@output_stream.puts(project.title)
... | true |
1808b9d4832debb5d9bc4fd21d48ebc27a102790 | Ruby | email2jie/AppAcademyProjects | /Week1/W1D5/algorithm_exercises3.rb | UTF-8 | 1,411 | 3.71875 | 4 | [] | no_license | require 'set'
class TreeNode
attr_accessor :parent, :value
attr_reader :children
def initialize(value)
@children = []
@value = value
end
def child=(child)
child = TreeNode.new(child)
child.parent = self
@children << child
end
def dfs(target = nil,&prc)
if target
prc = Pro... | true |
671809f16ea8e04bd710c09aab9744a65a7568c9 | Ruby | ykz1/book_learn_to_program | /mysort.rb | UTF-8 | 492 | 4 | 4 | [] | no_license | #10.2 My sort method
def sort(arr)
recursive_sort(arr, [])
end
def recursive_sort(unsorted, sorted)
if unsorted.length <= 0 then
return sorted
end
smallest = unsorted.pop
alt_unsorted = []
unsorted.each do |temp|
if temp < smallest
alt_unsorted.push smallest
smallest = temp
else
... | true |
3c5dc04583049503bad7c91c7c6c0ae970450497 | Ruby | schmich/rdb | /lib/rdb/settings.rb | UTF-8 | 1,848 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'json'
require 'hashery/open_cascade'
require 'fileutils'
module Rdb
class Settings
def initialize
@settings = Hashery::OpenCascade.new
end
def include(obj)
case obj
when String
include_file(obj)
when Hash
include_hash(obj)
end
end
def save(... | true |
8bbd6bbf6727a1979ae6e52d6cedfeab50fe6e78 | Ruby | ErickG123/miniProjetosRubyOBC | /aula4/array.rb | UTF-8 | 1,060 | 3.703125 | 4 | [] | no_license | estados = []
estadoVazio = []
# .push adiciona valores no Array
estados.push('Espírito Santo')
estados.push('Minas Gerais', 'Rio de Janeiro', 'São Paulo')
# .insert você pode adicionar elementos no array em qualquer posição
# .insert(posição, 'item1', 'itemx')
estados.insert(0, 'Acre', 'Amapá')
puts estados
# Acess... | true |
882581c0e3dfac458788b6ac2ca527bf4abb9efa | Ruby | linojon/linomarks | /app/controllers/incomming_controller.rb | UTF-8 | 1,130 | 2.578125 | 3 | [] | no_license | require "uri"
class IncomingController < ApplicationController
# http://stackoverflow.com/questions/1177863/how-do-i-ignore-the-authenticity-token-for-specific-actions-in-rails
skip_before_filter :verify_authenticity_token, only: [:create]
def create
# Take a look at these in your server logs
# to get ... | true |
ec7db39c3af890a4a11ca902ba460f2c50457209 | Ruby | anaholagirl/survey_active_record | /survey_ui.rb | UTF-8 | 5,500 | 3.40625 | 3 | [] | no_license | require 'active_record'
require './lib/question'
require './lib/survey'
require './lib/choice'
require './lib/response'
require 'pry'
database_configurations = YAML::load(File.open('./db/config.yml'))
development_configuration = database_configurations['development']
ActiveRecord::Base.establish_connection(developmen... | true |
ae7e07cf0671fd0532425d15d1ae2e3c72d4df2c | Ruby | xaviervia/piano | /lib/piano/controller_loader.rb | UTF-8 | 764 | 2.609375 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
module Piano
# Handler of .controller files loading
class ControllerLoader
def self.folder path
recursive path do |item|
load item
end
end
# Iterates recursively over the path and calls the block
# with each newfound file
def self.recursive path, &... | true |
17d178d8245a718efcc6b235a61d94efb5ccb5f2 | Ruby | MarynaNogtieva/thinknetica | /module2/task_four.rb | UTF-8 | 182 | 3.21875 | 3 | [] | no_license | alphabet = ('a'..'z').to_a
arr_vowels = %w(a e i o u y)
hash = {}
alphabet.each.with_index(1) do |value,i|
if arr_vowels.include?(value)
hash[value] = i
end
end
puts hash
| true |
887a4e9bdc5bfd59c2b15724ee4bed2b30c7ab7b | Ruby | Fonsan/iodine | /bin/raw_broadcast | UTF-8 | 1,833 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# this will compile Iodine and run a raw sockets broadcasting (chatroom) server.
# # test using:
# telnet localhost 3000
Dir.chdir(File.expand_path(File.join('..', '..'), __FILE__))
puts `rake clean`
puts `rake compile`
require 'benchmark'
$LOAD_PATH.unshift File.expand_path(File.join('..', '..'... | true |
dd425cbf381af13f6a40966093dfff8815a3e5ea | Ruby | mrlarner/lorem-whitman | /bin/whitman | UTF-8 | 790 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'whitman'
count = ARGV.length > 0 ? ARGV.first.to_i : nil
which = ARGV.length > 1 ? ARGV[1].downcase : nil
if ARGV.length > 0 and ARGV.first.start_with? "multitude"
which = ARGV.first
puts which
end
if which.nil? or which.start_with? "sentence"
puts Whitman::Sentence.sentences(count)... | true |
1b32caa5171a6ba777ee6f3d574c01cb8ecd7510 | Ruby | flori/tins | /lib/tins/limited.rb | UTF-8 | 1,033 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'thread'
module Tins
class Limited
# Create a Limited instance, that runs _maximum_ threads at most.
def initialize(maximum)
@mutex = Mutex.new
@continue = ConditionVariable.new
@maximum = Integer(maximum)
raise ArgumentError, "maximum < 1" if @maximum < 1
@count = 0
... | true |
aae9b1f2ce0e46cd1b2f308524c9d4de0162ed46 | Ruby | brunovcosta/password | /main.rb | UTF-8 | 464 | 3.390625 | 3 | [] | no_license | require 'io/console'
puts 'service domain (ex: google.com):'
service = gets.chomp
puts 'your secret key'
key = STDIN.noecho(&:gets).chomp
alphabet = '{}()[]#:;^,.?!|&_`~@$%/\\=+-*"\' '+
'abcdefghijklmnopqrstuvwxyz'+
'ABCDEFHGIJKLMNOPQRSTUVWXYZ'+
'0123456789'
puts "password: "
key.chars.map.with_index do |char,index... | true |
113d1942eccac9ec1227de2f9d0cab14ad1c74c2 | Ruby | slayfer-dev/Challenges-sol | /Programming/Codeabbey/020/Engry.rb | UTF-8 | 464 | 2.828125 | 3 | [] | no_license | #Author Engry
#angabe der beiden dateien
from_file, to_file = ARGV
#angabe welche files eingelesen werden
puts "Kopiere von #{from_file} zu #{to_file}"
#öffne die input datei und speicher in neuer datei
indata = open(from_file).read.split("\n")#.map.with_index { |s| s.to_i }
#gehe durch indata und zähle die umlaute pro... | true |
85f21af2343fb644db1e95d6d7c4803c185bcc59 | Ruby | keesuk/typojanchi2015 | /project_spliter.rb | UTF-8 | 1,250 | 2.78125 | 3 | [] | no_license | require 'yaml'
require 'json'
require 'byebug'
projects_yaml = YAML.load_file("./projects/projects.yml")
projects_yaml["projects"].each do |project|
project_info = {}
project_info["idx"] = project["idx"]
puts "#{project["idx"]}-#{project["project_name_en"].downcase.gsub(/[^\w ]+/, '').gsub(/ +/, '-')}"
pro... | true |
f0fe6e0adffb74c78e5b05bf5f1315561eeed128 | Ruby | alu0100658682/prct05-2015 | /test/tc_rational.rb~ | UTF-8 | 659 | 2.796875 | 3 | [] | no_license | require './lib/rational'
require 'test/unit'
class TestRacional < Test::Unit::TestCase
def test_suma
assert_equal("1/1", (Rational.new(2,4) + Rational.new(2,4)).to_s)
assert_equal("5/7", (Rational.new(2,7) + Rational.new(3,7)).to_s)
# assert_equal("4/7", (Rational.new(2,4) + Rational.new(2,4)).to_s) f... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.