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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a3f526d40b45459fa69361cb8afb126f06fbbd23 | Ruby | KarlHeitmann/ejercicio_hashes_y_arrays | /estudiantes.rb | UTF-8 | 1,870 | 3.25 | 3 | [] | no_license | notas_estudiantes = {
"claudia" => {
"fullstack" => {
"notas" => [
8,
6,
9,
10,
10,
10,
10
]
},
"base_de_datos" => {
"notas" =>[
10,
10,
9,
7,
8,
9,
6,
]
}
},
"di... | true |
188ec26a8f4dc3e052b05f1c3e4681db04e41f75 | Ruby | rosieallott/learn_to_program | /ch11-reading-and-writing/safer_picture_downloading.rb | UTF-8 | 891 | 3.015625 | 3 | [] | no_license | # go into end destination of pictures
puts "searching for the destination of your pictures"
Dir.chdir '/Users/rosieallott/Pictures/NewDir'
# find the pictures to be moved - effectively changes directory too?
pic_names = Dir['/Users/rosieallott/Pictures/SourceDir/**/*.jpg']
puts "What would you like to call this batch?... | true |
3d8e81c3318fc1b63727f4d1a2b058afe11f3422 | Ruby | bluthgeld/jukebox-cli-prework | /lib/jukebox.rb | UTF-8 | 1,485 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | songs = [
"Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"Phoenix - Consolation Prizes",
"Harry Chapin - Cats in the Cradle",
"Amos Lee - Keep It Loose, Keep It Tight"
]
def play... | true |
e8ed356ff3267c55701afad6bfecf7063172f601 | Ruby | nwtgck/Quick-and-Rich-Interactive-Ruby | /console.rb | UTF-8 | 959 | 3.5 | 4 | [] | no_license | require 'io/console'
class Console
# キーを定義
KEY_CTRL_A = "\u0001"
KEY_CTRL_C = "\u0003"
KEY_CTRL_D = 4.chr
KEY_CTRL_K = "\v"
KEY_CTRL_Z = 26.chr
KEY_ENTER = "\r"
KEY_UP = "\e[A"
KEY_DOWN = "\e[B"
KEY_RIGHT = "\e[C"
KEY_LEFT = "\e[D"
KEY_BACKSPACE = "\177"
# コンストラクタ(ブロックを渡すとgetchの無限ループに入る)
def initializ... | true |
e4b720c5a9b79136f34d036c9cf231f3d8991eed | Ruby | barkerest/incline | /test/extensions/object_extensions_test.rb | UTF-8 | 2,682 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class ObjectExtensionsTest < ActiveSupport::TestCase
test 'all objects have object_pointer method' do
assert Object.respond_to?(:object_pointer)
assert Object.new.respond_to?(:object_pointer)
assert 'hello'.respond_to?(:object_pointer)
assert 12345.respond_to?(:object_pointer)
... | true |
670f61033dd275cff600ba79cc2d447733c1d29b | Ruby | Alex223124/OmertexTest | /app/policies/user_policy.rb | UTF-8 | 1,482 | 2.59375 | 3 | [] | no_license | class UserPolicy
attr_reader :current_user, :model
def initialize(current_user, model)
@current_user = current_user
@user = model
end
# Только админ может проматривать список всех юзеров
def index?
@current_user.admin?
end
# Только администратор по данному методу контроллера
# может видеть все креди... | true |
1a523afd5cd288b936df01b116f01f19c5f5b064 | Ruby | hugoo93/desafios_ciclos_ruby | /suma_pares.rb | UTF-8 | 122 | 3.03125 | 3 | [] | no_license | n = ARGV[0].to_i
cont = 0
sum = 0
while n >= cont
if n % 2 == 0
sum += n
end
cont += 1
end
puts sum | true |
86d63626e29d439c9978726e4bcd641de92cf74a | Ruby | shubhSaxena/covid-backend | /app/service/update_country_info.rb | UTF-8 | 721 | 2.703125 | 3 | [] | no_license | # this class is being used to update the db with country name, slug and code
# run this while setup to get all countries details for further api calls
class UpdateCountryInfo < ApplicationService
def call
update_country_info
end
private
def update_country_info
# get data from the api and sort it base... | true |
66c0b1237cbfb315e56ab5f0d265a235d5da000f | Ruby | ttscott2/assignment_recursion_sprint | /factorial.rb | UTF-8 | 154 | 3.4375 | 3 | [] | no_license | def factorial_r(n)
return n if n <= 1
n *= factorial_r(n - 1)
end
def factorial_i(n)
amount = 1
n.downto(1) { |num| amound *= num }
amound
end
| true |
848af96bf663e22eec7d8c0ae4ae2a2e7ca86725 | Ruby | waarnold/programming_foundations | /lesson_2/rock_paper_scissors.rb | UTF-8 | 2,013 | 3.890625 | 4 | [] | no_license | VALID_CHOICES = { r: "rock",
p: "paper",
sc: "scissors",
l: "lizard",
sp: "spock"
}.freeze
player_score = 0
computer_score = 0
def prompt(message)
puts("=> #{message}")
end
def win?(first, second)
(first == 'rock') && %w(scis... | true |
b80e2bd6faa8ecd188b1d0c73b24ed872e82eb83 | Ruby | ironpencil/rubygame | /cell.rb | UTF-8 | 194 | 2.6875 | 3 | [] | no_license | require './collision'
class Cell
def collide(player)
collision = Collision.new(true, false, 'There is nothing but an eerie silence...')
end
def to_s
'.'
end
end | true |
92b56e457f93536e3e422eb9ecebd8e25ab4c0e2 | Ruby | alloy/james | /old/main_dialogue.rb | UTF-8 | 5,839 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'osx/cocoa'
require 'dialogue'
require 'initializer'
# has exactly two states, sleeping and awake
# from the awake state, extensions can be plugged in to be delegated to them
class MainDialogue < Dialogue
attr_accessor :state
def initialize(frontend)
load_names
load_sentences
@frontend = fro... | true |
9b11ce913d43634e04ba7fbf219497befe096051 | Ruby | SushmaShyam/toyrobotsimulator | /src/directive.rb | UTF-8 | 637 | 3.53125 | 4 | [] | no_license | class Directive
attr_reader :command
attr_reader :arguments
COMMAND_SEPERATOR = ' '
PARAMETER_SEPERATOR = ','
def initialize(string)
components = string.chomp.split(COMMAND_SEPERATOR)
@command = components.first.downcase.to_sym
construct_arguments(components[1]) unless components[1].nil?
end
... | true |
9860e653a5b16930deded26910cd4f190913da9a | Ruby | Katerina-codes/exercises_f_p | /ex24_anagram_checker_challenge/spec/anagram_checker_spec.rb | UTF-8 | 688 | 3.1875 | 3 | [] | no_license | require 'anagram_checker'
describe AnagramChecker do
it "tests that words 'ab, ba' return true" do
check_word = AnagramChecker.new
expect(check_word.check_if_anagram("ab", "ba")).to eq(true)
end
it "tests that words 'ca, ac' return true" do
check_word = AnagramChecker.new
expect(check_word.chec... | true |
9387a1d4b35d7303a94f34d6fa64e6621df4f17d | Ruby | markshild/TravelBucket | /app/views/api/views/leaders.json.jbuilder | UTF-8 | 503 | 2.65625 | 3 | [] | no_license | json.top @top do |user|
json.extract! user, :name, :number
end
json.africa @africa do |user|
json.extract! user, :name, :number
end
json.asia @asia do |user|
json.extract! user, :name, :number
end
json.europe @europe do |user|
json.extract! user, :name, :number
end
json.namerica @namerica do |user|
json.e... | true |
5243234aacc08075da5fb12df88254d3d2874179 | Ruby | f1nesse13/aA_poker | /lib/card.rb | UTF-8 | 1,111 | 3.359375 | 3 | [] | no_license | class Card
attr_reader :value, :suit, :card_value
CARD_SUITS = {
:clubs => "♣",
:diamonds => "♦",
:hearts => "♥",
:spades => "♠"
}
CARD_VALUES = {
:two => "2",
:three => "3",
:four => "4",
:five => "5",
:six => "6",
:seven => "7",
:eight => "8",
:nine... | true |
73895de1f9cb75151d0b4653afc5aede5fda245f | Ruby | namusyaka/rom | /lib/rom/adapter/memory/dataset.rb | UTF-8 | 1,048 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module ROM
class Adapter
class Memory < Adapter
class Dataset
include Charlatan.new(:data)
attr_reader :header
def initialize(data, header)
super
@header = header
end
def to_ary
data.dup
end
alias_method :to_a, :to_ary... | true |
2365abb08a76236dc8face2581cb71631a9bed48 | Ruby | vjt/r13-hermes | /app/models/state.rb | UTF-8 | 1,472 | 2.71875 | 3 | [] | no_license | # Tips / tutorials can be dismissed permanently or until a specific
# time. This model saves the user preference for models who include
# the Politeness module.
#
# The state is saved per user, with a timestamp, representing when
# to display the message again. Complete dismissal can thus be
# implemented with a timest... | true |
63b08f09e4269c987b25f9d5a488eac58f459e84 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w03/d04/Jacob/sinatra_games/sinatra_games.rb | UTF-8 | 989 | 2.9375 | 3 | [] | no_license | require 'sinatra'
get '/coin_toss' do
flip = ["Heads", "Tails"]
flip.sample
end
get '/dice_roll' do
rand(1..6).to_s
end
get '/magic8ball/:question' do
responses = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes definitely",
"You may rely on it",
"As I see it yes",
"Most likely"... | true |
d1446b987ddccbc200507a9a99875f4e5627b792 | Ruby | avinash-vllbh/programming-journal | /ruby/hacker_rank/warmup/acm-icpc-team.rb | UTF-8 | 1,754 | 4 | 4 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
require 'pry'
###
# To return the combined expertise of the two-man team
###
def get_team_expertise(t1,t2)
expertise = []
t1.size.times do |i|
if t1[i] == 1 or t2[i] == 1
expertise << 1
else
expertise <... | true |
3c0dde6229d7f491a08b0ab1dae743494c1b9eed | Ruby | donatoaz/metaprogramming-ruby | /tasks/task_create_tap.rb | UTF-8 | 692 | 3.640625 | 4 | [] | no_license | # Re-implementing tap method
class Object
def my_tap(&block)
block.call(self) if block_given?
self
# we could have used yield, in such case, we do not need to specify the
# input parameter block, because it is implicit. but, for the sake of
# explicitness I prefer to maintain this structure above.... | true |
8ca7c78c98e675555c64689dc4d3b541b463d9ed | Ruby | webdev1001/rwiki | /sandbox/grit.rb | UTF-8 | 2,627 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'grit'
repo_dir = '/tmp/grit-sandbox.git'
FileUtils.rm_rf(repo_dir)
FileUtils.mkdir(repo_dir)
FileUtils.chdir(repo_dir)
system('git init')
repo = Grit::Repo.new(repo_dir)
file_name = 'test.txt'
file_content = "Hello World!\n"
# create a new file
File.open(file_name, 'w') { |f| f.write(file_content) }
repo... | true |
70729b9915cab76678b03cb6e0794bd62b95ceec | Ruby | FQ400/massive-octo-dangerzone-server | /ruby/effects/shrink_effect.rb | UTF-8 | 157 | 2.640625 | 3 | [] | no_license | class ShrinkEffect < Effect
def initialize(target, options={})
super(target, options)
end
def apply(size, type)
super
size / 3
end
end
| true |
df0169f0d9215d2df17a05929d4767a6513f2251 | Ruby | alu0100921038/pruebas-travis | /lib/listaDE.rb | UTF-8 | 2,350 | 3.890625 | 4 | [
"MIT"
] | permissive | # Estructura para representar los nodos de una lista
# Incluye el valor del nodo y los nodos siguiente y previo a este
Node = Struct.new(:value, :next, :prev)
# @author Juan Martínez
class ListaDE
include Enumerable
attr_reader :head, :tail, :size
# Initialize de la lista, establece a nil la cabeza y la cola
... | true |
e4d5eb8e1a144dfe39617d3f0151f53407a82cbd | Ruby | djberg96/pathname2 | /test/windows/test_long_path.rb | UTF-8 | 1,202 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | ########################################################################
# test_long_path.rb
#
# Test suite for the Pathname#long_path method
########################################################################
require 'test-unit'
require 'pathname2'
class TC_Pathname_LongPath < Test::Unit::TestCase
def setup
... | true |
05d72bcb349e92497bbf3e50169f2b2fb270756e | Ruby | caius/lstrip-on-steroids | /spec/lstrip_on_steroids_spec.rb | UTF-8 | 1,517 | 2.8125 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), "..", "lib", "lstrip_on_steroids")
describe String do
describe "#-@" do
it "doesn't alter an empty string" do
(-"").should eq ""
end
it "removes whitespace from a single line" do
(-" foo").should eq "foo"
end
it "removes whitespace" do
... | true |
d58c21197e20d343c56cbf7295c2e409075a13f2 | Ruby | silarsis/drydocker | /lib/drydocker/monitor.rb | UTF-8 | 1,873 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "listen"
require "ptools"
module Drydocker
# Class to actually run the monitor and tests
class Monitor
attr_accessor :config
def initialize(config)
@config = config
end
def listen
run_or_start
listener = Listen.to(config.path) do |modified, added, removed|
config... | true |
037d96ac02be2446d2ac22e44d131c0e384b7ca5 | Ruby | MYKang/likelion_hw4 | /LongestWord.rb | UTF-8 | 218 | 3.34375 | 3 | [] | no_license | def LongestWord(sen)
s1 = sen.split(/[^\w]+/).max_by(&:length)
return s1
end
# keep this function call here
# to see how to enter arguments in Ruby scroll down
LongestWord(STDIN.gets)
| true |
22300746e42ae68254e7c1fbf6342d0a415cd213 | Ruby | nikkoschaff/Gradesnap | /app/uploaders/image_uploader.rb | UTF-8 | 3,379 | 2.53125 | 3 | [] | no_license | # encoding: utf-8
require 'docsplit'
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::MiniMagick
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::Is... | true |
bccdc439108ff584bec1537de8b28835981eaea1 | Ruby | bterlson/reddit | /lib/reddit/resource_list.rb | UTF-8 | 1,271 | 2.8125 | 3 | [
"MIT"
] | permissive | module Reddit
# A list of resources, such as a list of comments from an article or a user's page.
class ResourceList
attr_reader :url
private
# Grabs the resources at the URL and returns the parsed json.
def get_resources(url, options = {}, &block)
querystring = options.delete(:qu... | true |
e6597b77a0b63ba3a3376fdc10430929e8f5b1d7 | Ruby | bragboy/hackerrank | /password.rb | UTF-8 | 859 | 3.390625 | 3 | [] | no_license | def minimumNumber(n, password)
return 6 if n == 0
numbers = "0123456789".split('')
lower_case = "abcdefghijklmnopqrstuvwxyz".split('')
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split('')
special_characters = "!@#$%^&*()-+".split('')
ps = password.split('')
uniq_reqd = 0
uniq_reqd += 1 if (ps & numbers)... | true |
ea4f2373eec6c488000911a28438381e7b808edb | Ruby | RobertoBarros/raycasting_gosu | /ray.rb | UTF-8 | 5,337 | 3.25 | 3 | [] | no_license | class Ray
FOV = 60 * (Math::PI / 180)
attr_reader :distance, :angle, :color, :slice
def initialize(player, map, angle)
@player = player
@x = player.x
@y = player.y
@angle = normalize(angle)
@map = map
@tile_size = map.tile_size.to_f
@facing_down = @angle > 0 && @angle < Math::PI
@... | true |
b9fdfb82d75d713dbf2ae46beb8d77472e278cff | Ruby | osifoanosike/advanced_ruby | /CreateClassFromCSV/lib/objectify.rb | UTF-8 | 1,771 | 3.421875 | 3 | [] | no_license | require 'csv'
class Objectify
def initialize(file_name)
file_name = file_name.gsub('.csv', '')
file_path = File.expand_path("../#{file_name}.csv", __FILE__)
if file_name = ""
raise "You didn't specify a file name. Try again, with a file name this time"
elsif !File.exist?(file_path)
raise ... | true |
79e72f7f0ecd23f9c56b1fc35350aa6f6e866846 | Ruby | h13ronim/bankjob | /lib/bankjob/output_formatter/stdout_formatter.rb | UTF-8 | 1,090 | 2.8125 | 3 | [
"MIT"
] | permissive | module Bankjob
class OutputFormatter
class StdoutFormatter
# FIXME: I shouldn't need to define this if I'm not interested in
# the arguments.
def initialize(*args)
end
def output(statement)
p "Account Number : #{statement.account_number}"
p "Bank ID ... | true |
db16812c1a111e73382b0e9b147cc0aedba8620c | Ruby | itggot-oscar-wernqvist/standard-biblioteket | /lib/max_of_three.rb | UTF-8 | 362 | 4.125 | 4 | [] | no_license | # Public: Finds out the maximum number of 3 numbers.
#
# num1 - Any number.
# num2 - Any number.
# num3 - Any number.
#
# Examples
#
# max_of_three(2,3,4)
# # => 4
#
# Returns the largest number.
def max_of_three(num1, num2, num3)
if num2 > num1
if num3 > num2
return num3
end
... | true |
34c703d6cd254d759c83e14d36caf82510f3b088 | Ruby | stephenharrington04/oo-student-scraper-v-000 | /lib/scraper.rb | UTF-8 | 1,387 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
require 'nokogiri'
class Scraper
def self.scrape_index_page(index_url)
students_info = []
html = open(index_url)
doc = Nokogiri::HTML(html)
doc.css(".student-card").each do |stud|
stud_name = stud.css(".student-name").text
stud_location = stud.css(".s... | true |
58b73a38f42852792c5ebc2aee9523d4dc47a4a0 | Ruby | InvalidCookie/RandomNumber-ruby | /monkShak.rb | UTF-8 | 832 | 3.46875 | 3 | [] | no_license | #to test the Infinite monkey theorem
count = 0
xcount = 0
i = 0
string = ""
num_array = ('a'..'z').to_a
num_array << " "
puts "What word or string would you like to test?"
word = gets.chomp.downcase
wl = word.length
wl.times {string << '*'}
puts "processing..."
t = Time.new
t = t.strftime("%Y-%m-%d %H:%M:%S:%L")
ope... | true |
a62c250837a24fd05ac1d22d4d3387392b369103 | Ruby | ddiez/seqminer | /result.rb | UTF-8 | 25,261 | 2.765625 | 3 | [] | no_license | # SeqMiner is a tool for mining sequence information. It aims to
# help detect sequences belonging to specific protein families.
#
# Author:: Diego Diez (mailto:diez@kuicr.kyoto-u.ac.jp)
# Copyright:: Copyright (c) 2010
# License:: Distributes under the same terms as Ruby
require 'config'
require 'item'
require ... | true |
120869ff1e23979d865d01f6b1c184a09f527fb7 | Ruby | Karis-T/RB101-RB109-Small-Problems | /fizzbuzz.rb | UTF-8 | 459 | 4.625 | 5 | [] | no_license | # two arguments: a starting number and an ending number
# fizz for numbers % 3 == 0
# buzz for numbers % 5 == 0
def fizzbuzz(start_num, end_num)
array = (start_num..end_num).to_a
array.map.with_index do |num, idx|
if (num % 5 == 0) && (num % 3 == 0)
array[idx] = "FizzBuzz"
elsif num % 3 == 0... | true |
8e399d2e4b1da8d3423fc0d6ce90db50225cfef8 | Ruby | sdubinsky/scottdubinskysite | /models/blog.rb | UTF-8 | 443 | 2.765625 | 3 | [] | no_license | require 'pg'
class BlogModel
def initialize
@connection = PG.connect(ENV['DATABASE_URL'])
end
def get_posts
posts = @connection.exec("SELECT id, title, substring(post from '\<p\>.+?\</p\>') as snippet, uploaded_date FROM blog ORDER BY uploaded_date DESC")
posts
end
def get_post id
id = PG::C... | true |
3a22c733883251c496a68179758a400b8e5d8bc2 | Ruby | ashtija/rspec-performance | /lib/spec/performance/client/http_client.rb | UTF-8 | 2,654 | 2.5625 | 3 | [] | no_license | require "net/http"
require "cgi"
require "spec/performance/client/response"
module Spec
module Performance
module Client
class HttpClient
attr_writer :recording, :cookies
attr_reader :base_uri, :cookies
def initialize(base_uri)
@base_uri = base_uri
@headers = {}... | true |
4d4a692d4a9971b0fbb7d95cb6f6905879785489 | Ruby | tenderlove/fisk | /test/test_register_allocation.rb | UTF-8 | 5,688 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require "helper"
class RegisterAllocationTest < Fisk::Test
attr_reader :fisk
def setup
super
@fisk = Fisk.new
end
def test_encode_temp_register_without_assignemt_raises
reg = fisk.register
fisk.push(reg)
assert_raises Fisk::Errors::UnassignedRegister do
fisk.to_binary
end
end... | true |
57887ca3f98e0cb78f2889dea68aa99d29b96ceb | Ruby | Haadsan/Pizza_order-day2-wk4 | /pizza_controller.rb | UTF-8 | 1,625 | 2.78125 | 3 | [] | no_license |
# https://gist.github.com/futuresocks/c71ded69a669b0780fe5d16dcb95c85c
require( 'sinatra' )
require( 'sinatra/contrib/all' )
require( 'pry-byebug' )
require_relative('./models/pizza_order')
also_reload('./models/*')
# # Get
# index and Show
#
# Post
# new and create
# READ - step 1 index
# index routes all the pi... | true |
6aa48829074c17d817aac9c1e6ca330baa1ef136 | Ruby | dpatel0114/my-each-prework | /my_each.rb | UTF-8 | 121 | 3.09375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(words)
i=0
while i<words.length
yield words[i]
i=i+1
end
words.collect do |word|
word
end
end | true |
7a3449dd4a38ba0d960f00d20e790578feadcded | Ruby | urbanvention/sms-console | /spec/sms_spec.rb | UTF-8 | 3,235 | 2.65625 | 3 | [
"CC-BY-3.0"
] | permissive | # sms_spec.rb ;; 2010 (cc) Jan Riethmayer
# This work is licensend under a Creative Commons Attribution 3.0 license.
require "spec_helper"
describe "Sms" do
def valid_sms
ab = Addressbook.new
sms = Sms.new
jan = ab.find(Defaults.name)
sms.username = "Test"
sms.password = "Test"
sms.recipient=... | true |
47d6930a27b1ec8121ecf1387d5be6b978dfe424 | Ruby | PowerPress/sneakerdrop | /lib/sneakerdrop/message_payload.rb | UTF-8 | 1,516 | 2.796875 | 3 | [] | no_license | require 'sneakerdrop/message'
require 'sneakerdrop/sender'
module Sneakerdrop
class NoJson < StandardError; end
class InvalidMessageVersion < StandardError; end
class MalformedMessage < StandardError; end
# A Payload encapsulates the logic to serialize/deserialize, and encrypt/decrypt
# Message objects.
... | true |
2eb8a867731b626853b886600e6464cc517b73cf | Ruby | gettinToasty/chess | /chess/pawn.rb | UTF-8 | 1,673 | 3.296875 | 3 | [] | no_license | require_relative 'piece'
require 'byebug'
class Pawn < Piece
def initialize(pos, color, board)
super
@symbol = @color == "black" ? '♟' : '♙'
end
def moves(current_pos, board)
possibles = []
pot_moves = first_row?(current_pos) ? first_move : move_diffs
pot_moves.each_with_index do |rel_p... | true |
106c00d6583e18fee2b3f874d0d8896a48b70e8a | Ruby | SamGimbel/job_scour | /lib/job_aggregator.rb | UTF-8 | 779 | 2.515625 | 3 | [] | no_license | class JobAggregator
def initialize
@ignore_link_text ||= []
@urls ||= []
end
attr_reader :ignore_link_text
attr_accessor :urls
def paged_urls(config)
url_array = []
(1..config[:num_pages]).each do |page|
url_array << config[:url_base] + config[:page_structure] + page.to_s
end
... | true |
e9c9a2a9fe9973f16e7944716e00db286860c5b4 | Ruby | davidbalbert/eventless | /lib/eventless/select.rb | UTF-8 | 1,536 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Kernel
alias_method :select_block, :select
def select(*args)
Eventless.select(*args)
end
end
class IO
class << self
alias_method :select_block, :select
def select(*args)
Eventless.select(*args)
end
end
end
module Eventless
def self.select(read_array, write_array=[], error_ar... | true |
679da08cb2d486416549711b41d816b847ebe554 | Ruby | jr1412594/ruby-check | /extend_time_object_with_require_time.rb | UTF-8 | 254 | 3.046875 | 3 | [] | no_license | require 'time'
# puts Time.parse("2016-01-01")
=begin
parse is only available when you require 'time'
=end
# puts Time.parse("03-04-2000")
puts Time.strptime("03-04-2000", "%m-%d-%Y")
#string parse time allows you to format how you want to show time | true |
bcb538aaed343cb097955305707988259bdf0e9e | Ruby | coreyhaines/lambda_fun | /show-defs | UTF-8 | 1,831 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'parser/current'
parse = -> filename, body {
Parser::CurrentRuby.new.parse \
Parser::Source::Buffer.new(filename).tap { |b| b.source = body }
}
assignment = Struct.new :filename, :line_number, :code, :ast
find_assignments = -> ast {
return [] unless ast.respond_to? :type
filenam... | true |
785f43f3718bb441040a1d508458fa0e8fb8fb09 | Ruby | sbackus/templater | /src/compiler.rb | UTF-8 | 580 | 3.15625 | 3 | [] | no_license | class Compiler
def self.compile(tokens)
root_node = RootNode.new(nil)
context_stack = [root_node]
tokens.each do |token|
if token.new_context?
new_node = token.create_node
add_child_to_tree(new_node, context_stack.last)
context_stack.push(new_node)
elsif token.end_cont... | true |
c6c272d75893ab3788d449aa688fa7f2bcc53aca | Ruby | sfgeorge/loquacious | /spec/spec_helper.rb | UTF-8 | 1,196 | 2.640625 | 3 | [
"MIT"
] | permissive |
require File.expand_path('../lib/loquacious', File.dirname(__FILE__))
RSpec.configure do |config|
# == Mock Framework
#
# RSpec uses it's own mocking framework by default. If you prefer to
# use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmo... | true |
223bc8c14b26c1c611f1c33a8d4e73d4f254ee28 | Ruby | kivohin/Ironhack-Bootcamp | /Week 1/day_4.rb | UTF-8 | 1,003 | 3.921875 | 4 | [] | no_license | # Day 4
require 'pry'
class Login
def initialize
@hardcode_username = "kivohin"
@hardcode_pass = "papaya"
@username = ""
@pass = ""
@text = ""
end
def ask_username
puts "Give me your username!"
@username = gets.chomp
ask_pass
end
def ask_pass
puts "And now your pass!"
@pass = gets.chomp
... | true |
714b92b4cefdd6fa908fbbeaed3543e44e15c865 | Ruby | lexus2727/intro-to-simple-array-manipulations-online-web-prework | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 1,166 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
#using the push method to add an element to the end of the array, using two arguments
def using_push(array, element)
array.push("Niger")
end
#using unshift to add to the front of the array, using two arguments
def using_unshift(array, element)
array.unshift("Brooklyn Heights")
end... | true |
11e55233abbaf1b95c42c1d2a47c8fd146db6a74 | Ruby | nfilzi/cs-book-study-organisation | /part1/control-flow/block.rb | UTF-8 | 428 | 3.65625 | 4 | [] | no_license | # def block_local_parameter
# x = 100
# (1..3).to_a.each do |x|
# puts "Paramater x is #{x}"
# x += 10
# puts "Reassigned to x in block; it's now #{x}"
# end
# puts "Outer x is still #{x}"
# end
# block_local_parameter
def block_local_variable
x = "Original x!"
3.times do |i;x|
x = i
... | true |
77fece5cfaf482b2f6e71c06f377500b7938e1b7 | Ruby | JBelta/backend_module_0_capstone | /day_4/say.rb | UTF-8 | 1,806 | 4.90625 | 5 | [] | no_license | # What are Methods and why do we need them?
# Methods, Arguments and Parameters
puts "hello"
#hello
puts "hi"
#hi
puts "how are you"
#how are you
puts "I'm fine"
#I'm fine
def say(words)
puts words + "."
end
say("hello")
#hello.
say("hi")
#hi.
say("how are you")
#how are you.
say("I'm fine")
#I'm fine.
#Defining... | true |
1e300674b8dfad000d8c48ba4767f8c030dc345c | Ruby | Grego22/Katas | /ruby/8-kyu/I_Love_You_Case_Statement/Solutions.rb | UTF-8 | 595 | 3.703125 | 4 | [] | no_license | # My solution
def how_much_i_love_you(nb_petals)
case nb_petals % 6
when 1
then "I love you"
when 2
then "a little"
when 3
then "a lot"
when 4
then "passionately"
when 5
then "madly"
when 0
then "not at all"
end
end
# Other solutions
def how_much_i_love_you(nb_pet... | true |
d5a86c4d57adc9208f205d28ee0e25800fab7af7 | Ruby | tanahiro/mathlib | /test/test_matrix.rb | UTF-8 | 1,594 | 3.1875 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | require "minitest/autorun"
require "mathlib/matrix"
class TestMatrix < MiniTest::Unit::TestCase
def setup
@m1 = Matrix[[1, 2, 3], [4, 5, 6]]
end
def test_add_columns
expected = Matrix[[1, 2, 3, 7], [4, 5, 6, 8]]
assert_equal(expected, @m1.add_columns(Matrix[[7], [8]]))
assert_raises... | true |
168e07403a9e1a59de1a7806cf86150e90a42e1e | Ruby | rogcald1/PokedexApp | /app/controllers/pokedex_controller.rb | UTF-8 | 1,934 | 2.625 | 3 | [] | no_license | require 'poke-api-v2'
class PokedexController < ApplicationController
def index
end
def search
#this adjusts messaging if there was an invalid entry or blank entry
@pokepoke = params[:current_poke]
if params[:empty_val]
@alert1_on = true
end
if params[:incorrect]
@alert2_on = t... | true |
0697a6d2c85152d46c4493a7c29fffad7eec77e6 | Ruby | madhusudhan1234/ruby_basics | /block_ampersand.rb | UTF-8 | 81 | 3.015625 | 3 | [] | no_license | def my_method(&block)
puts block
block.call
end
my_method { puts "Hello!" } | true |
319e418921fe482de42bf6df157e4f97de6f224a | Ruby | AlexErling/sep-assignments | /02-algorithms/03-algorithms-sorting/benchmark_sort.rb | UTF-8 | 964 | 3 | 3 | [] | no_license | require_relative 'bucket_sort'
require_relative 'heap_sort'
require_relative 'quick_sort'
require_relative 'insertion_sort'
require_relative 'merge_sort'
require_relative 'bubble_sort'
require_relative 'selection_sort'
require 'benchmark'
test_array = (1..50).to_a.shuffle!
test_array_1 = test_array
test_array_2 = test... | true |
5d531ac472aaa25709e029f2945b0dea9290547d | Ruby | HandBoy/monsters_duel | /app/view/menus.rb | UTF-8 | 1,130 | 2.953125 | 3 | [] | no_license | #require '/classes/tela'
module Menus
def self.print(menu)
case menu
############ MENU PRINCIPAL #############
when :principal
Tela.limpar
puts cabecalho
puts " 01 -- Novo duelo"
puts " 02 -- Monstros"
puts " 00 -- Sair"
puts rodape
puts opca... | true |
6afba1295d930ada7a09a426c777cd2235de275a | Ruby | rgo594/cartoon-collections-nyc-web-career-040119 | /cartoon_collections.rb | UTF-8 | 388 | 3.25 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)
array.each_with_index{|x, y| puts "(#{y + 1}) #{x}"}
end
def summon_captain_planet(array)
array.map{|n| n.capitalize + "!"}
end
def long_planeteer_calls(array)
array.any? do |word|
word.length > 4
end
end
def find_the_cheese(array)
cheese_types = ["cheddar", "gouda", "came... | true |
cd98fb2c84f7b349f311d6b09e7f7ef43d7cd158 | Ruby | chetan/micron | /lib/micron/test_case.rb | UTF-8 | 801 | 2.53125 | 3 | [] | no_license |
require "micron/test_case/assertions"
require "micron/test_case/lifecycle_hooks"
module Micron
class TestCase
include LifecycleHooks
include Assertions
# Run before all test methods in the class
def self.before_class
end
# Run after all test methods in the class
def self.after_class
... | true |
e490d605a7bb882bb86b5c942ff242a10eacc47b | Ruby | BrawnyVolt/phase-3-active-record-querying-methods-lab | /app/models/show.rb | UTF-8 | 537 | 2.65625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Show < ActiveRecord::Base
def self.highest_rating
return maximum('rating')
end
def self.most_popular_show
highest = self.highest_rating
Show.where("rating = ?", highest)
end
def self.lowest_rating
minimum('rating')
end
def self.least_popular_show
lowest = self.lowest_rating
Show.w... | true |
0992dafc060e039514457dae2398b7b94fd931cd | Ruby | cc256/ls_ruby | /small_problems/easy1/7.rb | UTF-8 | 342 | 3.6875 | 4 | [] | no_license | def stringy(integer)
string = ""
integer.times do |n|
if (n + 1).odd? #or #(n + 1).odd? ? string += "1" : string += "0"
string += "1"
else
string += "0"
end
end
return string
end
puts stringy(6) == '101010'
puts stringy(9) == '101010101'
puts stringy(4) == '1010'
puts s... | true |
f0ee30c85499a159b98a98159def9326dff40df0 | Ruby | gauravmc/Codility | /22_equi_leader.rb | UTF-8 | 910 | 3.703125 | 4 | [] | no_license | # Write a function:
# def solution(a)
# that, given a non-empty array A consisting of N integers, returns the number of equi leaders.
def solution(a)
leader, count = array_leader(a)
return 0 unless leader
n = a.size
head_count = 0
total_equis = 0
a.each_with_index do |e, i|
head_count += 1 if e ==... | true |
f1bc1d638098ac5054cd37d4f983a887ca73f5dd | Ruby | sortigoza/algorithms-practice | /product_except_i/product_except_i.rb | UTF-8 | 2,418 | 3.875 | 4 | [] | no_license | # class Solution
# # with multiplication
# def run(lis)
# @lis = lis
# all_product = @lis.reduce(:*)
# @lis.map { |x| all_product / x }
# end
# end
# class Solution2
# # without multiplication
# def run(lis)
# @lis = lis
# @n = @lis.length
# @lis << @lis.first unless @n.even?
# ... | true |
2b7e9228d9fafa060db9c5cf889c8ef2e8dfd003 | Ruby | alexbujenita/rspec-fizzbuzz-bootcamp-prep-000 | /fizzbuzz.rb | UTF-8 | 543 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Don't forget! This file needs to be 'required' in its spec file
# See README.md for instructions on how to do this
def fizzbuzz number
if number == 310194
puts "In ziua aceasta so nascut o goblinuta frumisica pe care o iubesc mult!"
elsif number % 3 == 0 && number % 5 == 0
puts "FizzBuzz"
return "Fizz... | true |
5f123303dcf9958c283e5a227b68219823f1adbf | Ruby | Anutka777/mastermind | /mastermind.rb | UTF-8 | 8,709 | 3.8125 | 4 | [] | no_license | # frozen_string_literal: true
# To greet player, explain rules, provide game status in text, show end game
# message. Also display colors to chose from for player convinience
module Messages
LOGO = <<~HEREDOC
███ ███ █████ ███████ ████████ ███████ ██████ ███ ███ ██ ███ ██ ██████
████ ████ ██ ... | true |
6666b4423ef5b3a1d4e2ebf4de02e4d30d20d9d0 | Ruby | thecoderjimmy/ruby_lrthw | /ex19_sd3.rb | UTF-8 | 1,219 | 4.28125 | 4 | [] | no_license | # Exercise 19: Study Drill 3
# https://learnrubythehardway.org/book/ex19.html
# Write at least one more function of your design, and run it
# 10 different ways.
def birthday_add(year, month, day)
puts "Your birthday is #{year}/#{month}/#{day}, right?"
no1 = month + day
no2 = year
finalno = no1 + no2
puts "Wh... | true |
e23af2c8686ff1544bdf3592c2e36c5ff2c2b94f | Ruby | GetsuKami-Hao/my_ruby | /2016/june/visit_name.rb | UTF-8 | 229 | 3.046875 | 3 | [] | no_license | class HelloWorld
def name
return @name
end
def name=(valu)
@name = valu
end
attr_accessor:tmp
end
bob = HelloWorld.new()
bob.name = "Bob"
bob.tmp = "没时间解释了,快上车!"
p bob.name
p bob.tmp
| true |
4f31c911634dfe411e9a9e39de4c49f80a42a455 | Ruby | japiber/tzispa_data | /lib/tzispa/data/transporter.rb | UTF-8 | 4,103 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Tzispa
module Data
class Transporter
DEFAULT_ENCODING = 'ASCII-8BIT'
DEFAULT_BUFFER_SIZE = 2048
DEFAULT_LINE_SEPARATOR = "\n"
attr_reader :filename, :buffer_size, :encoding, :line_separator, :data_separator,
:line_size, :st... | true |
d3dbb0fb39f1f7741525ef1122d32b0fd42889b8 | Ruby | keithwellman/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 1,028 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort do |x, y|
y <=> x
end
end
def sort_array_char_count(array)
array.sort do |x, y|
if x.length == y.length
0
elsif x.length < y.length
-1
elsif x.length > y.length
1
end
end
end
def swap_elemen... | true |
4cc6e363b832c12ead4e8a899a5776a41837d509 | Ruby | heedwiner1106/baitapRuby | /OOP/bai4.rb | UTF-8 | 5,400 | 3.125 | 3 | [] | no_license | class ThiSinh
attr_accessor :sbd, :hoten, :diachi, :mucuutien
def set_ThiSinh sbd, hoten, diachi, mucuutien
@sbd = sbd
@hoten = hoten
@diachi = diachi
@mucuutien = mucuutien
end
end
class KhoiA < ThiSinh
attr_accessor :toan, :ly, :hoa
def initialize toan,ly,hoa
... | true |
a897cbbbfd294e9816ffda8e235b1d0c33f72272 | Ruby | braidn/press_time | /app/helpers/run_stamps_helper.rb | UTF-8 | 516 | 2.734375 | 3 | [] | no_license | require 'time_diff'
module RunStampsHelper
def time_at(time)
time = nil_time(time)
Time.at(time).asctime
end
def time_diff(stopTime, startTime)
cleanStart = nil_time(startTime)
cleanStop = nil_time(stopTime)
time_differance = Time.diff(Time.at(cleanStart), Time.at(cleanStop))
"#{time_dif... | true |
42a7f081a41e47ef52e1f216ed0eb03b6201fc63 | Ruby | mknudsen/mknudsen.github.io | /aggregate_achievements_feeds.rb | UTF-8 | 2,303 | 2.71875 | 3 | [] | no_license | require 'rss'
require 'date'
feed_urls = [
'https://www.trueachievements.com/friendfeedrss.aspx?gamerid=1108778',
'https://truesteamachievements.com/friendfeedrss.aspx?gamerid=109330',
'https://www.truetrophies.com/friendfeedrss.aspx?gamerid=767394'
]
calendar_days_to_items = Hash.new
feed_urls.each do |url|
... | true |
3cd3ded5a54801bfc1e8d06c20bdec59e9aa6e9c | Ruby | bjldb/onpace-test-currency-conversions | /app/models/conversion.rb | UTF-8 | 740 | 2.640625 | 3 | [] | no_license | class Conversion < ApplicationRecord
validates :convert_from, :convert_to, presence: true, length: { is: 3 }, allow_blank: false
before_save :uppercase_currency
TIMEZONE = 'Australia/Sydney'.freeze
def uppercase_currency
convert_from.upcase!
convert_to.upcase!
end
def self.target_currencies
... | true |
49521aaf3a69e5cfa3bdfa0b00caeb5aa28986e5 | Ruby | hkob/moritaka-db | /app/models/concerns/renumber.rb | UTF-8 | 296 | 2.625 | 3 | [] | no_license | module Renumber
module RenumberMethods
def renumber_array(array)
array.each_with_index do |obj, i|
count = (i + 1) * 10
unless obj.sort_order == count
obj.sort_order = count
obj.save
end
end
end
end
extend RenumberMethods
end
| true |
3c2b811b4ed21f34f5b53519f7ff79c2b0ae0b58 | Ruby | RyanN77/project-euler-multiples-3-5-nyc-clarke-web-100719 | /lib/oo_multiples.rb | UTF-8 | 1,009 | 3.671875 | 4 | [] | no_license | def collect_multiples(limit)
arr_of_multiples = []
counter = 1
while counter < limit
if counter % 3 == 0 || counter % 5 == 0
arr_of_multiples << counter
end
counter += 1
end
return arr_of_multiples
end
def sum_multi... | true |
dbdbb7b4f2b2b54067ea1f37d5268447539ec25b | Ruby | miz/chukkerlist | /ruby.rb | UTF-8 | 136 | 2.828125 | 3 | [] | no_license | name = "Miz"
print "How many chukkers are you signing up for? "
chukkers = gets
puts "#{name}\nsigned up for #{chukkers}chukkers."
| true |
d70ed7667604ed7f41c8951a77cafbd120f53401 | Ruby | solnic/rom-relation | /lib/rom/schema/definition.rb | UTF-8 | 1,693 | 2.671875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module ROM
class Schema
# Builder object used by schema DSL to establish Axiom relations
#
# @private
class Definition
include Equalizer.new(:repositories, :relations)
attr_reader :repositories, :relations
# @api private
def initialize(repositories, &block... | true |
e49c961a73a124c92ab39e9a82ba4e15029c80bd | Ruby | lbvf50mobile/til | /20190903_Tuesday/20190903.rb | UTF-8 | 459 | 3.0625 | 3 | [] | no_license | p "alias x='ruby 20190903_Tuesday/20190903.rb'"
# Ruby: Do not mess with reduce and each_with_object. arr.reduce(1,:*) reduce with symbol.
p 0 == [1,2,2].each_with_object(0){|v,o| o += v} # new object every time
p 5 == [1,2,2].each_with_object([0]){|v,o| o[0] += v }[0] # change value of object defined in the funcit... | true |
b93973d8d5e6723440236c06cfa3fc02a934ed79 | Ruby | ramunas-cvirka/codeschool_exercises | /rails_testing_for_zombies/level_6.rb | UTF-8 | 1,095 | 2.640625 | 3 | [] | no_license | # Factories
FactoryGirl.define do
factory :zombie do
name 'Sally'
graveyard 'Valley Dim'
end
end
# Complex Factories
FactoryGirl.define do
factory :zombie do
name 'Ash'
graveyard 'Petrosville'
factory :sally do
name 'Sally'
graveyard 'Valley Dim'
end
factory :moe do
... | true |
5ef826abdf6b073649f421a8b2fbd3bc68f0e6c4 | Ruby | rstacruz/monk | /lib/monk.rb | UTF-8 | 8,700 | 2.59375 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env ruby
require "thor"
require "yaml"
require "fileutils"
class Monk < Thor
VERSION = "1.0.0.beta1"
CMD = "monk"
include Thor::Actions
[:skip, :pretend, :force, :quiet].each do |task|
class_options.delete task
end
desc "help TASK", "Show help for a given TASK"
def help(*args)
... | true |
9f757f31e50129d2492954e69f99faff07210e65 | Ruby | taraujo310/graph-algorithms | /core/default_decorators/graph_decorator.rb | UTF-8 | 213 | 2.734375 | 3 | [] | no_license | class GraphDecorator
attr_accessor :graph
def initialize(graph)
@graph = graph
end
def to_s
graph.to_s
end
def vertices
graph.vertices
end
def present?
graph.present?
end
end
| true |
8f6131ecac60e5aba3cd06da5d31635f390ed779 | Ruby | src22/ruby-fowler | /nested-closure/simple_builder.rb | UTF-8 | 535 | 2.9375 | 3 | [] | no_license | require_relative 'model'
class Builder
def initialize
@diskArray = []
end
def disk(size, speed)
d = Disk.new(size,speed)
@lastDisc = d
@diskArray << d
return d
end
def getLastDisk()
return @lastDisc
end
def getDiskArraySize()
return @diskArray.size
end
def processor(c... | true |
ef753a8cdd6d2653fb33fe98ddd89814276bc5b6 | Ruby | 1a2b3c4dBobAn/w2d4 | /execution_time/execution_time.rb | UTF-8 | 1,161 | 3.53125 | 4 | [] | no_license | #phase 1
LIST = [0, 3, 5, 4, -5, 10, 1, 90]
LIST2 = [-5, -1, -3]
#
# O(n^2)
def my_min_1
LIST.each_with_index do |el, i|
smallest = true
LIST.each_with_index do |el2, j|
next if i == j
smallest = false if el2 < el
end
return el if smallest
end
end
# O(n)
def my_min_2
smallest = LIST[0... | true |
ab05988514b8c507df83c559f380e816befa2f7d | Ruby | x6doooo/doudata | /scripts/modules/api_getter.rb | UTF-8 | 872 | 2.65625 | 3 | [] | no_license | #循环控制
class API_Looper
attr_accessor :total, :start, :count, :sleep
def initialize(total, start, count, sleep)
@total = total #总计要取多少条活动
@start = start #开始位置
@count = count #每次取多少条
@sleep = sleep #豆瓣API有频次限制,通过sleep避免请求过快
end
def loop_get
(@start...@total).step(@count)do |start|
yield(... | true |
2f8e5727d3b26d357d0ce4867f3ab2b6c5b027e6 | Ruby | cjbottaro/cassandra_cql | /lib/cassandra_cql/caster.rb | UTF-8 | 5,714 | 2.6875 | 3 | [
"MIT"
] | permissive | require "bigdecimal"
require "simple_uuid"
require "ipaddr"
require "set"
module CassandraCql
module Caster
extend self
def to_bytes(value, type, collection_type = nil)
case type
when COLUMN_TYPE_ASCII
value.force_encoding(Encoding::BINARY)
when COLUMN_TYPE_BIGINT
[value].p... | true |
e709c2b456df3760d262466b397aaff2135be11b | Ruby | luketurnerdev/codewars-challenges | /reverse_number.rb | UTF-8 | 625 | 4.28125 | 4 | [] | no_license | # # Given a number, write a function to output its reverse digits.
# (e.g. given 123 the answer is 321)
# # Numbers should preserve their sign; i.e. a negative
# number should still be negative when reversed.
def reverse_number(n)
#take the digits as an array
#assign them to a new array in the reverse order
... | true |
df7c42c46f83a55fae7853448d3d2c08aa765257 | Ruby | jtb1137/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 257 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #def reverse_each_word(phrase)
# words_reversed = []
# array = phrase.split
# array.each { |word| words_reversed << word.reverse }
# words_reversed.join(" ")
#end
def reverse_each_word(phrase)
phrase.split.collect {|word| word.reverse}.join(" ")
end
| true |
09519596ac03ad34b279dd3e1b1247e3c63f926b | Ruby | kontera-technologies/aws-dev-utils | /lib/aws-dev-utils/client_wrapper.rb | UTF-8 | 1,504 | 2.59375 | 3 | [
"MIT"
] | permissive | module AwsDevUtils
class ClientWrapper
include AwsDevUtils::Utils
# Initialize a new ClientWrapper, internal use only
# @params [Seahorse::Client::Base] client
# @param [Hash] options
# @option options [String] next_token max number of requests
# @option options [String] retry max number of r... | true |
192a87017d6c3663bb4adab065f6cf1e5615f8ae | Ruby | seanlilmateus/Temperature-Converter | /TemperatureConverter/Classes/RankineValueTransformer.rb | UTF-8 | 684 | 2.9375 | 3 | [] | no_license | #
# RankineValueTransformer.rb
# TemperatureConverter
#
# Created by Sean Mateus on 13.05.11.
# Copyright 2011 Sean Mateus.All rights reserved.
#
class RankineValueTransformer < NSValueTransformer
def transformedValueClass
NSNumber
end
def allowsReverseTransformation
true
end
def tr... | true |
308005d8f614a1ba2c694018bcc73c7bbe9edc28 | Ruby | jenningsanderson/Twitter-Evacuation-Patterns | /runtimes/find_affected_coastline_users.rb | UTF-8 | 1,689 | 2.984375 | 3 | [] | no_license | #
# Find all users in the affected coastline area
#
# Sets a hazard_level_before for just the before point
require 'mongo_mapper'
require 'epic-geo'
require 'rgeo'
require 'rgeo-geojson'
require_relative '../models/twitterer'
require_relative '../models/tweet'
require_relative '../processing/geoprocessing'
#Static S... | true |
d4ca0441aaf47a4345d54299b0049a878424e725 | Ruby | nwyll/sep-assignments | /02-algorithms-and-complexity/02-searching/fibonacci_recursive.rb | UTF-8 | 117 | 3.203125 | 3 | [] | no_license | def fib_recursive(n)
return 0 if n == 0
return 1 if n == 1
return fib_recursive(n-1) + fib_recursive(n-2)
end
| true |
8cc761adc13da0cc9aa532f11e6adb24076d7963 | Ruby | andresporras3423/coding-challenges | /03. Number of 1 Bits.rb | UTF-8 | 253 | 3.5 | 4 | [] | no_license | # @param {Integer} n, a positive integer
# @return {Integer}
def hamming_weight(n)
count = 0
while n>0
count+= n%2
n = n/2
end
count
end
# def numbers
# nums = []
# (1..18).each{|n| nums.push(n)}
# nums.sample(10).sort()
# end | true |
f0302ea57ec1c4ef8550f8aefd764ac9810507b7 | Ruby | newtonry/hangman-aa | /hangman.rb | UTF-8 | 3,691 | 3.828125 | 4 | [] | no_license | class Hangman
def initialize(chooser, guesser)
@chooser = chooser
@guesser = guesser
end
def play
num_guesses = 0
@chooser.get_word
while true
num_guesses += 1
@chooser.guessed_word
@guesser.update_known(@chooser.guessed_word)
p @chooser.guessed_word
... | true |
d00bbe6a59cb407f9294372ae3c2543ad547e8d4 | Ruby | lgants/intro-to-simple-array-manipulations-001-prework-web | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 585 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_push(arr,str)
arr.push(str)
end
def using_unshift(arr,str)
arr.unshift(str)
end
def using_pop(arr)
arr.pop
end
def pop_with_args(arr)
arr.pop(2)
end
def using_shift(arr)
arr.shift
end
def shift_with_args(arr)
arr.shift(2)
end
def using_concat(arr1,arr2)
arr1.concat(arr2)
end
def u... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.