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
eb15ce39d88f4fb186bcb0ad12dd9e99ad58776e
Ruby
khaitd/badges-and-schedules-001-prework-web
/conference_badges.rb
UTF-8
521
4.03125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def badge_maker(name) return "Hello, my name is #{name}." end def batch_badge_creator(arr) arr2 = Array.new arr.each {|name| arr2.push(badge_maker(name))} return arr2 end def assign_rooms(arr) arr3 = Array.new i = 1 while (i < 8) do arr3.push("Hello, #{arr[i-1]}! You'll be ass...
true
64424795f49ae199409990a78633e6f5770a89ff
Ruby
claytonsavage/ar-exercises
/exercises/exercise_1.rb
UTF-8
851
3.953125
4
[]
no_license
require_relative '../setup' puts "Exercise 1" puts "----------" # Use Active Record's create class method multiple times to create 3 stores in the database: # Burnaby (annual_revenue of 300000, carries men's and women's apparel) # Richmond (annual_revenue of 1260000 carries women's apparel only) # Gastown (annual_rev...
true
4984f586b3270d9290a4001e4c12d607d68c7c1d
Ruby
mathewpwheatley/CTCI-Solutions
/Utilities/LinkedList.rb
UTF-8
466
3.671875
4
[]
no_license
class Node attr_accessor :next attr_accessor :data def initialize(data) @data = data @next = nil end end def build(dataArray) head = Node.new(dataArray[0]) prevNode = head for i in 1...dataArray.length # Create Node currNode = Node.new(dataArray[i]) # Set...
true
bb782afb213851118209aab6f868485f230a9b59
Ruby
jamescarney3/chess
/pawn.rb
UTF-8
2,370
3.40625
3
[]
no_license
require 'byebug' class Pawn < Piece TOP_PAWN_RANK = 1 BOTTOM_PAWN_RANK = 6 attr_accessor :direction, :en_passantable def initialize(board, color, pos, duped = false) super(board, color, pos, duped) @direction = find_direction(pos) @en_passantable = false end def move_to(new_pos) unless @b...
true
b18535dc4f2da3ed69f9968dc8b9f960bdb95254
Ruby
mnzaki/coolsoft-13
/Idearator/script/git-author-changes.rb
UTF-8
969
2.890625
3
[]
no_license
#!/usr/bin/env ruby # Author: Mina Nagy Zaki <mnzaki [AT] gmail.com> # Usage: ./git-autho-changes.rb <author> <file1> [file2 file3 ...] # This script will list the the total changes made by <author> to each <file> author = ARGV[0] files = ARGV.drop(1) if author.nil? $stderr.puts "Usage: #{__FILE__} <author> <file1...
true
d3887fc5663b1c7010c6081c222dbe16f9898862
Ruby
ranguba/chupa-text-decomposer-spreadsheet
/lib/chupa-text/decomposers/spreadsheet.rb
UTF-8
2,830
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "roo" require "roo-xls" require "digest/sha1" module ChupaText module Decomposers class Spreadsheet < Decomposer include Loggable registry.register("spreadsheet", self) TARGET_EXTENSIONS = ["ods", "xls", "xlsx", "xlsm"] TARGET_MIME_TYPES = [ "application/vnd.oasis.opend...
true
48895b260ddd951c337565036ef294529a4990ac
Ruby
julio/messages
/tasks/messages_tasks.rake
UTF-8
470
2.671875
3
[ "MIT" ]
permissive
namespace :messages do desc "Create Messages YAML file in the config directory" task(:setup) do puts "Creating #{RAILS_ROOT}/config/messages.yml" messages = File.new("#{RAILS_ROOT}/config/messages.yml", "w") messages.puts( "greetings:\n hello: Hi There!\n yo: How have you been\n sup: And how...
true
68bfe2044f09f13a1868c80b1ff3111961cee2e3
Ruby
ryanfb/pleiades-json-to-geojson
/pleiades-json-to-geojson.rb
UTF-8
1,289
2.84375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'json' $stderr.puts "Reading Pleiades JSON..." pleiades_json = JSON.parse(File.read(ARGV[0])) $stderr.puts "#{pleiades_json['@graph'].length} places" $stderr.puts "Converting to GeoJSON..." pleiades_geojson = {} pleiades_geojson["type"] = "FeatureCollection" pleiades_geojson["features"] ...
true
e91ed7471d82335bf42de5c91b171478e88e6924
Ruby
MikeConner/hackathon
/app/models/property.rb
UTF-8
2,111
2.59375
3
[]
no_license
# == Schema Information # # Table name: properties # # id :integer not null, primary key # parcel_id :string(20) # address :string(128) # land_value :integer # building_value :integer # taxes :integer # vacant :boolean # latitude :decimal(, ) # longit...
true
79cdb5eea145f3fbd47abf82471abc6d9168542b
Ruby
jamesannal/upgraded-eureka
/ruby_functions_practice.rb
UTF-8
1,682
3.9375
4
[]
no_license
def return_10() return 10 end def add(a, b ) return a + b end def subtract(a, b) return a - b end def multiply(a, b) return a * b end def divide(a, b) return a / b end def length_of_string(a) return a.length.to_i end def join_string( a, b ) a = "Mary had a little lamb, " b = "its fleece was w...
true
44b489a54bf6309427a56910b697e528beb538a1
Ruby
tschaffer1618/cross_check
/modules/season_stat_helper.rb
UTF-8
2,036
2.65625
3
[]
no_license
module SeasonStatHelper def all_games_played_by_season(team_id) all_season_games = Hash.new all_seasons_ary.each do |season| all_season_games[season] = @games.values.count {|g| g.season == season && (g.home_team_id == team_id || g.away_team_id == team_id)} end all_season_games end def all_...
true
fa02a13819a51926606c531509dc530a4ebd0eb3
Ruby
KPobeeNorris/owning-rails
/spec/action_view_spec.rb
UTF-8
1,951
2.515625
3
[ "MIT" ]
permissive
require 'spec_helper' RSpec.describe ActionView do it 'can render a template' do template = ActionView::Template.new("<p>Hello<p>", "test_render_template") context = ActionView::Base.new expect(template.render(context)).to eq "<p>Hello<p>" end it 'can render a template with variables' do templa...
true
00557d6c5920a80dfa6afccbf30658e4928d1a1d
Ruby
collin/factory_scenarios_example
/app/models/order.rb
UTF-8
285
2.515625
3
[]
no_license
class Order < ApplicationModel attr_accessor :user attr_accessor :line_items delegate :email, to: 'user' delegate :name, to: 'user' def initialize(attributes={}) attributes[:line_items] ||= [] super end def total line_items.map(&:total).sum end end
true
c2654da1978918ca2b5b8bf8dc074932b37fa5a4
Ruby
onesup/cqds
/app/models/gift.rb
UTF-8
1,441
2.8125
3
[]
no_license
class Gift < ActiveRecord::Base has_many :winners def is_win?(user, betted_at) result = false golden_time = latest_golden_time(betted_at) Rails.logger.info("%%%golden_time: " + golden_time.to_s + " <= betted_at:" + betted_at.to_s) unless is_before_win?(user) Rails.logger.info(is_somebody_b...
true
fddd407470ea93ebebf8b0cf5b5ad05217a69e8f
Ruby
apopheny/RB100
/greeting1.rb
UTF-8
81
3.046875
3
[]
no_license
def greet(person) puts "Hello, " + person end greet("John") greet(1)
true
db98811c91659073390e8a537d9051e3626f9412
Ruby
juaxE/Rojekti48
/lib/bullet/bullet.rb
UTF-8
611
3.078125
3
[]
no_license
SPEED = 10 class Bullet attr_reader :x, :y def initialize(x, y, direction, level, spread=0) @image = Gosu::Image.new('./assets/bullet.png') @x, @y = x, y @direction = direction @level = level @spread = spread end def draw if @direction == :left offs_x = 0 factor = 2 el...
true
f1420ae0575584335c1585c89e85b984162ce024
Ruby
pedRo-shd/Web-Server
/webserver.rb
UTF-8
978
3.265625
3
[]
no_license
require 'socket' #Importa módulo socket # Inicia servidor TCP na porta 2345 server = TCPServer.new('localhost', 2345) # Inicia loop infinito loop do # Aguarda que um cliente se conecte e em seguida retorna um socket TCP socket = server.accept # Lê a primeira linha da request request = socket.gets # Imprime a ...
true
6574fb5f737e9a75ad90561bab1de29843d46ffa
Ruby
RaccoonCode96/Study_Ruby
/Module/tom.rb
UTF-8
185
3
3
[]
no_license
module Tom # 첫글자 무조건 대문자 module_function() # 모듈이름.함수 형태로 만들어 주는 함수(루비 내장 함수) def a() return "a" end end
true
2e55f255bb8b17e63d6265c7abffaa07a16ad3e2
Ruby
yeguacelestial/lenpro-project
/tareas/Tarea 10/RUBY/SerieA.rb
UTF-8
529
3.75
4
[]
no_license
#Validar valor entero def to_int(string) Integer(string) rescue ArgumentError nil end resultado = 0 print "n => " cadena = gets.chomp if cadena n = to_int(cadena) for i in 1..n do formula = i**(2*i - 1) resultado = formula if i == n puts "#{resultado}." puts ...
true
e8f2f79c66c428648c9dc605c3b23ea862b299f6
Ruby
IdleBuffalo/sample_app
/app/controllers/users_controller.rb
UTF-8
752
2.640625
3
[]
no_license
class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @user = User.new # ustvari se nov user end def create @user = User.new(user_params) #ta @user se bo uporablkal v new.html.erb if @user.save flash[:success] = "Welcome to the Samp...
true
e31e45d6e1ca589c57cbd241528b5a663576a230
Ruby
coreos/tectonic-installer
/tests/rspec/lib/tfstate_file.rb
UTF-8
890
2.765625
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true # TFStateFile represents a Terraform state file class TFStateFile def initialize(build_path) @build_path = build_path end def value(address, wanted_key) file_exists? Dir.chdir(@build_path) do state = `terraform state show #{address}`.chomp.split("\n") state...
true
6d548521cad9c867216e3b08c6b6df2875c56b56
Ruby
bmanandhar/App_acad_prep
/high_card_points.rb
UTF-8
307
3.40625
3
[]
no_license
def high_card_points(hand) points = 0 i = 0 while i < hand.length if hand[i] == "A" points = points + 4 elsif hand[i] == "K" points = points + 3 elsif hand[i] == "Q" points = points + 2 elsif hand[i] == "J" points = points + 1 end i = i + 1 end points end
true
15085b7df18fc69a623bad4f53a9e16450f49be5
Ruby
iliandy/ruby_june_2017
/andy_li/fundamentals/guess_the_number/guess_the_number.rb
UTF-8
208
3.640625
4
[]
no_license
def guess_number guess number = 25 if guess < number puts "Guess was too low!" elsif guess > number puts "Guess was too high!" else puts "Correct! Brilliant!" end end guess_number(10)
true
c32dbbe1ee8fd5a14f1d09b2b43b52d5971a1a95
Ruby
calebjo/W4D1
/tic-tac-toe-ai/lib/super_computer_player.rb
UTF-8
1,919
3.3125
3
[]
no_license
require_relative 'tic_tac_toe_node' require "byebug" class SuperComputerPlayer < ComputerPlayer def move(game, mark) node = TicTacToeNode.new(game.board, mark) kids = node.children kids.each do |child| # puts "#{child.prev_move_pos}" return child.prev_move_pos if child.winning_node?(mark) ...
true
ab04e6718014db89662238f436a2b9b6a29f55d7
Ruby
jesuslerma/eloquent-ruby-notes
/chapter5/chapter.rb
UTF-8
2,268
4.375
4
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby # This chapter is about regular expressions puts 'Notes for chapter5' puts <<EOF The idea behind the regular expression -- that you construct a pattern that either will or will not match some string - is as simple as regular expressions are powerfull EOF puts <<EOF Some basics about regular express...
true
f67a3dfbf751c043ab7520c79d7b41f08e58c4f3
Ruby
adamuro/risk
/src/player.rb
UTF-8
3,980
2.90625
3
[]
no_license
require_relative 'regions' require_relative 'cards' require_relative 'text' require_relative 'message' require_relative 'common' module Phase DRAW = 0 ATTACK = 1 FORTIFY = 2 def self.to_s(phase) case phase when DRAW 'Draw' when ATTACK 'Attack' when FORTIFY 'Fortify' end ...
true
60f82c12f0e6ef1e6ddf1d0e8bfa77602ad215b8
Ruby
suprfrye/practice-quote-middleware
/lib/random_quote.rb
UTF-8
355
2.78125
3
[ "MIT" ]
permissive
class RandomQuote QUOTES = [] File.open('./fixtures/rickygervais.txt', 'r') do |f| f.each_line do |line| QUOTES << line end end def initialize(app) @app = app end def call(env) if env['PATH_INFO'] == '/quote' [200, {'Content-Type' => 'text/plain'}, [QUOTES.sample]] else ...
true
056f7379b413299aa4aaf14cfcdc22ecbdbae8be
Ruby
journeywithrails/boss
/lib/smtp_states.rb
UTF-8
2,310
2.921875
3
[]
no_license
class NotInitializedError < RuntimeError; end module State attr_accessor :protocol def serve(io) raise NotInitializedError.new if @protocol.nil? service_request(io) @protocol.state = @next_state @protocol.serve(io) end end module Messages def greeting(io) io.puts '220 ruby ESM...
true
51dfd9e4d83e1fbee98c6debb84bd9a00a7c4694
Ruby
yianyue/math_game
/math_game.rb
UTF-8
1,678
4
4
[]
no_license
#create an array of hashes, each hash stores the info of a player #and initialize the life and score @players = [ { id: 1, life: 3, score: 0 }, { id: 2, life: 3, score: 0 } ] # is this really a good way to structure the program? # if the random numbers are generated inside the ask function...
true
36e8bbd1da622caf5493422b79f6f8891f179c9a
Ruby
ftigeot/Corylus
/app/models/cart_item.rb
UTF-8
2,892
2.6875
3
[ "BSD-2-Clause" ]
permissive
# Corylus - ERP software # Copyright (c) 2005-2014 François Tigeot # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice...
true
082f126a6f31e5defdba6ef482602173267c00b1
Ruby
briantemple/shakespeare_analyzer
/lib/line_counter.rb
UTF-8
662
3.1875
3
[]
no_license
require 'set' class LineCounter def initialize @speaker = [] @scene_speakers = Set.new @count = Hash.new(0) end def count @count end def add_speaker(name) @speaker.push name @scene_speakers.add name unless name == 'ALL' end def count_line names = (@speaker.include?("ALL")) ...
true
a3791820fe4258599661f34f713d5e742ab3707a
Ruby
ringe/hovedoppgave
/app/helpers/date_modul.rb
UTF-8
1,154
2.734375
3
[]
no_license
module DateModul #Tester om dato for oppretting av arbeidsdag ikke allerede #har en arbeidsdag knyttet til seg, vil så returnere en dato #samme månde som ikke er opptatt. def try_date(date_string, user_id) date = Date.parse(date_string) occupied_dates = Workday.select(:date).where("user_id = ? and d...
true
cfc2bd346cb1897914b0934d8e72cb5e6ea43a36
Ruby
peterhuene/puppet-ruby-host
/lib/puppet/functions.rb
UTF-8
10,483
2.796875
3
[ "Apache-2.0" ]
permissive
require 'puppet-ruby-host/loader' require 'puppet-ruby-host/protocols/function.rb' require 'puppet-ruby-host/util/helpers' # Minimum implementation of the Puppet 4 function API module Puppet module Functions # Represents a Puppet function. class Function # Represents a dispatch for a Puppet function. ...
true
c75443839e704cf176d382605c0577128f2a5c7e
Ruby
radical-ed4/learning
/largest_factor.rb
UTF-8
631
4.5625
5
[]
no_license
# Largest Factor # ---------------------------------------- # Write a method, #largest_factor, that accepts an integer as an argument and returns # the largest factor of that integer def find_factors(n) factors = [] index = 1 until index == n if n % index == 0 factors << index end index += 1...
true
89163c5004716b41dee08ef38f3c407d3ca18d3d
Ruby
Minisai/FTP---server
/FtpServer/test/vfs.rb
UTF-8
2,185
2.6875
3
[]
no_license
# coding: utf-8 class FileSystem attr_reader :ftp_name, :ftp_size, :ftp_dir, :ftp_date, :ftp_parent def ftp_list output = Array.new Dir.entries(@path).sort.each do |file| if(file!='') output << FileSystem.new(@path + '/' + file, self) end end return output en...
true
66a6cfe3c934b9fe404aedb32afbd5e31d293307
Ruby
harhogefoo/aizu_ruby
/ALDS1/ALDS1_2_B.rb
UTF-8
400
3.609375
4
[]
no_license
# Sort 1 - Selection Sort def selection_sort(a) count = 0 (0...a.length).each do |i| minj = i (i...a.length).each do |j| if a[j] < a[minj] minj = j end end next if i == minj tmp = a[i] a[i] = a[minj] a[minj] = tmp count += 1 end count end n = gets.to_i a = g...
true
b2f9bf0d646114e17112ea223750b98295a14abf
Ruby
shelleyyz/WDi28-Homework
/robert_maculewicz/week_04/day_02/MTA_Lab/mta.rb
UTF-8
999
3.390625
3
[]
no_license
require 'pry' @line_N = ['Time Squere','34th','28th','23rd','Union Square','8th'] @line_L = ['8th','6th','Union Square','3rd','1st'] @line_6 = ['Grand Central','33rd','28th','23rd','Union Square','Astor Place'] def single_trip line,start_station,finish_station if line == "N" line_array = @line_N elsif lin...
true
52b5503b28faf1a176554bbb24b4e8fc63cef643
Ruby
mjohnson3038/BankAccounts
/savings_account.rb
UTF-8
1,057
3.40625
3
[]
no_license
# File 3/3 for wave 3 baseline. require_relative 'account.rb' module Bank class SavingsAccount < Account attr_accessor :balance attr_reader :id, :open_date MIN = 10 TFEE = 2 def initialize (id, balance, open_date) super(id, balance, open_date) end def welcome if @balan...
true
612b97c9a7a855f18a556ef2cbf227d27950fd46
Ruby
mjrkmail/payroll-in-ruby
/hourly_classification.rb
UTF-8
716
3.328125
3
[]
no_license
class HourlyClassification attr_reader :rate def initialize(rate) @rate = rate @timecards = {} end def get_time_card(date) @timecards[date] end def add_time_card(time_card) @timecards[time_card.date] = time_card end def calculate_pay(pc) date_range = ((pc.pay_date - 6)..(pc.pay_d...
true
d804cf35affab8b9844bc6481de95509700bc48b
Ruby
bolyardk22/close_but_no_cigar
/cbnc.rb
UTF-8
3,654
4.375
4
[]
no_license
#allows the user to input a ticket number #results in a number in a string def what_number p "Please enter a number greater than zero." ticket = gets.to_i #makes sure they enter a number greater than zero loop do if ticket <= 0 p "Sorry, you must enter a number greater than zero." ticket = gets.to_i el...
true
b6718d0235f9f1a51f97a3b96b771308bbd7c154
Ruby
jcfernan/boiler_plate_ar_setup
/lib/cli.rb
UTF-8
504
3.046875
3
[]
no_license
class Cli attr_reader :user def prompt TTY::Prompt.new end # def initialize user=nil # @user = user # end def welcome system('clear') puts "WELCOME TO SHOW SELECTOR THE #1 SPOT FOR SHOWS!!!" ask = prompt.yes?("Would you like to select some shows?") ...
true
6c2560ca11e7db4c42c3575201f6443046da2ab0
Ruby
andrewhouse/hangman
/app/models/game.rb
UTF-8
1,326
3.296875
3
[]
no_license
# == Schema Information # # Table name: games # # id :integer not null, primary key # answer :string(255) # max_misses :integer # misses :integer # guessed :string(255) # created_at :datetime # updated_at :datetime # winner :string(255) # creator :string(255) # # Create Mode...
true
2700cc7e61fec28ba80024c2b7cc3376c03dff51
Ruby
indrasaputra/algorithm-and-data-structure
/lcm/lcm.rb
UTF-8
121
3.3125
3
[]
no_license
def gcd(a, b) return a if b == 0 return gcd(b, a%b) end def lcm(a, b) a / gcd(a, b) * b end puts lcm(8, 12)
true
77128df81889e3b3c393785c3e417172e2165a8e
Ruby
rsundar/bing-rest-client
/spec/bing-test.rb
UTF-8
705
2.765625
3
[]
no_license
require 'rspec' require_relative '../bing.rb' describe Bing do let(:url) { "https://www.bing.com/search" } let(:query) { "microverse" } subject(:bing) {Bing.new(url,query)} describe "Status" do it "The response code for the request should be 200" do expect(bing.response_c...
true
0907361c98d62527e3895049fe05fe57694c2ad3
Ruby
AgentLemon/thepowerhat
/app/models/debt.rb
UTF-8
458
2.640625
3
[]
no_license
class Debt < ActiveRecord::Base belongs_to :who, class_name: User belongs_to :whom, class_name: User def self.find_debt(who, whom) if who.is_a?(Numeric) && whom.is_a?(Numeric) find_by_who_id_and_whom_id(who, whom) || Debt.new(who_id: who, whom_id: whom, amount: 0) else find_by_who_id_and_who...
true
caf945e2883bf7a7ea917306336829152ff3b667
Ruby
BobrImperator/GameOfLife
/lib/game_of_life.rb
UTF-8
1,489
3.53125
4
[]
no_license
class GameOfLife < Struct.new(:matrix) DEAD = '.' ALIVE = '*' def self.parse(generation) new(generation.split("\n").map {|line| line.split('') }) end def next GameOfLife.new(next_generation) end def to_s matrix.map { |line| line.join('') }.join("\n") end pri...
true
a73c2f73bd46d854ac46f2748f22bbf49838f9a0
Ruby
ProjectVinyl/ProjectVinyl
/lib/projectvinyl/search/parser/index.rb
UTF-8
3,518
2.703125
3
[]
no_license
require 'projectvinyl/search/parser/op' module ProjectVinyl module Search module Parser class Index attr_reader :table def initialize(table, params = {}, &block) @table = table @params = params @default_func = block end def recognises?(slurp) ...
true
1cfe88f7bafdcb378ce3fc05f7429e41dd6ae522
Ruby
neerajkumar/omdb_gateway
/lib/omdb_gateway/movie_request.rb
UTF-8
481
2.703125
3
[ "MIT" ]
permissive
module OmdbGateway class MovieRequest < Request attr_reader :id, :title def initialize(params) @id = params[:id] @title = params[:title] super end def fetch super(Response) end private def url raise InvalidIMDBParams.new('IMDB ID/Title not present') i...
true
2a268747777599ff5b410bd37fb535a0d5f10936
Ruby
rupakg/foxy
/src/map_tile.rb
UTF-8
147
2.84375
3
[]
no_license
class MapTile attr_accessor :row, :col, :gfx_index def initialize(row,col,index=-1) @row=row @col=col @gfx_index = index end end
true
3e2b62bfc05d890061c9a541546e1320316ebcc7
Ruby
unrealities/ellen
/lib/ellen/handlers/base.rb
UTF-8
809
2.859375
3
[ "MIT" ]
permissive
# Abstract class to be inherited from handler class. # # Example: # # class MyHandler < Ellen::Handlers::Base # on /kill\z/ do |message| # say "Good bye, cruel world..." # exit # end # end # module Ellen module Handlers class Base class << self include Mem def inheri...
true
b2bfb8ee39fdb75e4e01ce7c5fb89d478531d838
Ruby
PhilippePerret/Lecteur_Tuto
/ruby/class/fenetre.rb
UTF-8
3,832
2.921875
3
[]
no_license
=begin Class Fenetre ------------- Gestion de la fenêtre =end class Fenetre FEN_WIDTH = 1200 FEN_HEIGHT = 200 FEN_TOP = 400 FEN_LEFT = 100 attr_reader :data attr_reader :root ## ## Contenu de la fenêtre (frame) ## attr_reader :content ## ## Label Tk contenant le texte #...
true
622b88d3958ecb67d8cea175f3c7a2eae01bf04f
Ruby
pamelakwong/complete
/balanced_life/well_being.rb
UTF-8
2,268
4.0625
4
[]
no_license
require "byebug" require_relative "emotions" require_relative "emotional_state" require_relative "social_state" require_relative "mental_state" require_relative "physical_state" class Well_Being #Goal: Emotions are balanced. # Ok I tackled the small problems. # Now I need to package everything into Well...
true
aadb41c9a1d0b7b69a41b4f945c9f2c22dfdcf33
Ruby
sherrywong1220/ruby-algorithms
/leetcode/median-of-two-sorted-arrays.rb
UTF-8
659
3.546875
4
[]
no_license
# @param {Integer[]} nums1 # @param {Integer[]} nums2 # @return {Float} def find_median_sorted_arrays(nums1, nums2) nums = [] length1 = nums1.length length2 = nums2.length i = j = 0 while(i < length1 && j < length2) if nums1[i] < nums2[j] nums << nums1[i] i += 1 else nums << nums2[j]...
true
4685a492f722bfd81dd02b0d1068181f958598db
Ruby
bexfinken/phase-0-tracks
/ruby/list/todo_list.rb
UTF-8
276
3.4375
3
[]
no_license
# 6.5 Release 3 class TodoList def initialize(list) @list = list puts "initialize..." end def get_items @list end def add_item(item) @list.push(item) end def delete_item(item) @list.delete(item) end def get_item(index) @list[index] end end
true
607722021605b580070393143aa70ab0b8a16eec
Ruby
w-c-arbo/launch-school-prep-exercises
/basics_4.rb
UTF-8
67
2.59375
3
[]
no_license
array = [1994,1990,2003] puts array[0] puts array[1] puts array[2]
true
e473327ddeff8b7eb8c9a3dedc05dc72d252c11b
Ruby
rafaelpivato/shacip
/app/models/organization.rb
UTF-8
638
2.59375
3
[]
no_license
# frozen_string_literal: true ## # Organizations to be managed or accessed by users # # Organizations will have their unique numbers created using HashIds or NanoId # with a short alphabet like 'AEFHJLPRSTXY34569'. # class Organization < ApplicationRecord has_many :memberships, dependent: :destroy has_many :users,...
true
e720607466fd9d40086d68a7e6542844e8723958
Ruby
ahgpro/fullstack-challenges
/03-AR-Database/04-ActiveRecord-Advanced/01-Associations/db/seeds.rb
UTF-8
349
2.578125
3
[]
no_license
require "faker" # TODO: Write a seed to insert 100 posts in the database 5.times do user = User.new({ username: Faker::Name.name, email: Faker::Internet.email }) user.save (5..10).to_a.sample.times do post = Post.new( name: Faker::Company.name, url: Faker::Internet.url ) post.user = us...
true
08900ad850aeeb3378a11c752918bb09abba6c36
Ruby
tiy-dc-ror-2016-jun/class_notes
/week2/thursday/any_and_all.rb
UTF-8
481
3.359375
3
[]
no_license
students = ["Martin", "chris", "Austen", "lisa", "ava", "Erik", "Alex", "Tony"] long_student_name = false students.each do |student| if student.length >= 5 long_student_name = true end end p long_student_name def has_long_name?(students) long_student_name = false students.each do |student| if studen...
true
a711771fd52ed3f7ce6d2dcc64dda7a9545a977d
Ruby
wilsonsilva/calendario
/lib/calendario/renderers/month_renderer.rb
UTF-8
3,036
3.484375
3
[ "MIT" ]
permissive
require 'calendario/month' require 'calendario/rendered_month' module Calendario module Renderers # Renders a month line by line # # @api private # class MonthRenderer # The space of an empty day # @return [String] EMPTY_DAY_SPACES = ' '.freeze # Initials of each week da...
true
2175ab106228170f7269b2a84eccc47b81b6f863
Ruby
mattfang1999/67272-Phase-2-
/test/models/store_test.rb
UTF-8
2,967
2.890625
3
[]
no_license
require 'test_helper' class StoreTest < ActiveSupport::TestCase # Relationship matchers... should have_many(:employees).through(:assignments) should have_many(:assignments) #Validation Testing # Validation macros... should validate_presence_of(:name) should validate_presence_of(:street) should v...
true
474b5fc0b59f5127fd0f2432346b90c8339c9433
Ruby
LtdArink-Group/b2b_center_api
/lib/b2b_center_api/web_service/types/auction_participant.rb
UTF-8
1,956
2.625
3
[ "MIT" ]
permissive
module B2bCenterApi module WebService module Types # Участник аукциона class AuctionParticipant < WebService::BaseType # @return [Integer] Номер аукциона/объявления attr_accessor :auction_id # @return [String] ID организации участника, если имена участников доступны, # ...
true
f5b76a8d3b52642fec2390f594421e0300c724b8
Ruby
Ank13/Learn2Program_Pine
/ch6table.rb
UTF-8
319
3.234375
3
[]
no_license
puts 'Chapter 6 - Table of Contents' puts '' width = 60 puts 'Table of Contents'.center(width) puts'' puts ('Chapter 1: Getting Started'.ljust(width/2) + 'page 1 '.rjust(width/2)) puts ('Chapter 2: Numbers'.ljust(width/2) + 'page 9 '.rjust(width/2)) puts ('Chapter 3: Letters'.ljust(width/2) + 'page 13'.rjust(width/2))
true
0391c86779deedafa681f7b0a28d0ff894f33247
Ruby
matthewkcarr/bumptious-music
/app/models/fan_location.rb
UTF-8
2,194
2.703125
3
[]
no_license
class FanLocation < ActiveRecord::Base def self.newest_three retarry = [] rval = self.all(:select => "distinct(city) as city, state, country_code, max(created_at) as created_at, '' as occurences, '' as updated", :group => 'city', :order => "created_at DESC", :limit => 3) unless rval.size < 3 retar...
true
7f9392b1338eea60b10e03bb63ff9ffce083cd4c
Ruby
kishgit/c9-rubydemo-repo
/rbpl.rb
UTF-8
2,556
4.5
4
[]
no_license
#definition of blocks is "A section of code which is grouped together." Of course, # I'm guessing this doesn't help you much. #A simpler way to describe blocks is #“A block is code that you can store in a variable like any other object and run on demand.” puts 5+6 a = 5 b = 6 puts a + b addition = lambda {|a, b| re...
true
074d07ad043a80f64b730b402d7dfd6b1e43d34a
Ruby
RidiculousPower/perspective-bindings
/lib/perspective/bindings/container/class_instance.rb
UTF-8
2,105
2.765625
3
[]
no_license
# -*- encoding : utf-8 -*- module ::Perspective::Bindings::Container::ClassInstance ######### # new # ######### ### # Ensure that instance bindings initialize prior to calling #initialize. # # We add this here instead of in #initialize - where it usually would go - so that # we can avoid requir...
true
9eb00e00107f2f8bee0f31b832e4442b82899ed3
Ruby
rshiva/MyDocuments
/01-notes-programming /04-ruby+rails/ruby1.9/samples/language_19.rb
UTF-8
1,183
2.921875
3
[]
no_license
#--- # Excerpted from "Programming Ruby", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http://www...
true
89c563c5062623c2ce9b211f762e57a0bf60c8bc
Ruby
KarrthikReddyChinasani/ruby_intro
/section_5/ans.rb
UTF-8
1,233
4.25
4
[]
no_license
class Stack def initialize(max) @stack_array = [] @max = max end def push if @stack_array.length == @max puts "Stack is full" else puts "enter the element" ele = gets.chomp @stack_array << ele puts "#{ele} added to stack" end end def pop if @stack_array....
true
05805d469b9ad92c0eedbb2c1364137edf790b75
Ruby
wakatsuki614/jankenapp
/janken.rb
UTF-8
3,609
4.125
4
[]
no_license
def game puts "じゃんけん..." puts "0(グー)1(チョキ)2(パー)3(戦わない)" player_hand = gets.to_i program_hand = rand(3) jankens = ["グーを出しました", "チョキを出しました", "パーを出しました", "戦わない"] if player_hand == program_hand puts "ホイ!" puts "---------------" puts "あなた:#{jankens[player_hand]}\n相手:#{jankens[program_hand]}" put...
true
d825aeb074f20505252122a96a1c3a88a8ba90c7
Ruby
lukaselmer/fitbit-weight-data-downloader
/generate.rb
UTF-8
1,011
3
3
[]
no_license
require 'json' def oauth_token ENV['OAUTH_TOKEN'] end def generate_url(year, month) month_with_leading_zero = month <= 9 ? "0#{month}" : month "curl -s -H \"Authorization: Bearer #{oauth_token}\" https://api.fitbit.com/1/user/-/body/log/weight/date/#{year}-#{month_with_leading_zero}-01/1m.json" end def downloa...
true
c49820ae136d3d16b142606a977e5f1caac144c5
Ruby
severino-on/B2W
/testa_script_raiz_quadrada.rb
UTF-8
328
2.703125
3
[]
no_license
require 'test/unit' require_relative './script_raiz_quadrada_e_numeros_primo' class TestSimpleNumber < Test::Unit::TestCase def test_raiz assert(raiz_quadrada_perfeita?(25)) end def test_numero_primo assert(primo?(3)) end def test_total_numero_magico assert(total_de_numeros_magicos?(9)) e...
true
3da6a84a37c3ea39e95361d85209bb2012ee0465
Ruby
TPedron/design_patterns
/structural_patterns/bridge/author.rb
UTF-8
243
2.84375
3
[]
no_license
class Author attr_reader :name, :book_titles, :website, :image def initialize(name:, book_titles:, website:, image:) @name = name @book_titles = book_titles @website = website @image = image end end
true
a1fca37be3dd0b0e54741e26959b87823f808687
Ruby
chrisjuchem/CakBot
/lib/cakbot/cakbot_initializer.rb
UTF-8
7,885
2.53125
3
[ "MIT" ]
permissive
class CakBotInitializer def self.setup(bot) # bot.custom_command :memes, {}, # ":regional_indicator_m: :regional_indicator_e: :regional_indicator_m: :regional_indicator_e: :regional_indicator_s:" # bot.custom_command :roll, {}, # "1;2;3;4;5;6" # bot.command :bold do |_event, *...
true
298941822b227d914a7e987eac658d83a89c1efa
Ruby
johnsonsirv/tic-tac-toe
/lib/game.rb
UTF-8
2,215
3.453125
3
[ "MIT" ]
permissive
require_relative '../bin/game_cli' class Game include UserInterface attr_accessor :play_turn, :winner attr_reader :player_one, :player_two, :board @@game_symbols = ["X","O"] WINNING_COMBINATIONS = [ [0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6] ].freeze def initia...
true
d33980956283638346c1220c69d6d94a64629b4a
Ruby
camneu37/oo-student-scraper-v-000
/lib/scraper.rb
UTF-8
1,376
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'open-uri' require 'nokogiri' require 'pry' class Scraper attr_reader :index_url def self.scrape_index_page(index_url) html = open(index_url) doc = Nokogiri::HTML(html) students = [] doc.css("div.student-card").each do |card| name = card.css("h4.student-name").text location = c...
true
8b8fcabd68b2d7d95f142b719942e4ef05daf496
Ruby
JessDuff/ruby
/adivinador.rb
UTF-8
212
3.484375
3
[]
no_license
puts "Adivina el numero" secret_number = rand(10) guess = 0 while guess != secret_number guess = rand(10) puts "Guess is #{guess}" if guess == secret_number puts "You win!" else puts "Guess again!" end end
true
9ff2dcf8887e0a9c1be7865cc6c5812efa26c7a9
Ruby
exKAZUu/ParserTests
/fixture/Ruby18/input_code/coverage.rb
UTF-8
79
3.21875
3
[ "Apache-2.0" ]
permissive
p(1, 2) if 1 == 1 p(2) end stmt(); p(1) if branch(1 == 1) stmt(); p(2) end
true
afa57fb8e5fae301ddcdedf1b636752c11a4dd69
Ruby
nmacawile/chess
/lib/pieces/piece.rb
UTF-8
1,111
3.453125
3
[]
no_license
class Piece attr_accessor :board, :position, :faction, :legal_moves attr_writer :moved def initialize(board, faction, x, y, moved = false) @board = board @position = [x, y] @faction = faction @legal_moves = [] @moved = moved board.set(self, x, y) end def moved? @moved end def move(x, y) ...
true
24c5a43e4796563e45086b45a0b864ae63180b06
Ruby
nickoki/pokenatra
/app.rb
UTF-8
989
2.578125
3
[]
no_license
require "active_record" require "sinatra" require "sinatra/reloader" # Load the file to connect to the DB require_relative "db/connection" # Load models require_relative "models/pokemon" # ROUTES get "/" do erb :"pokemon/index" end # READ get "/pokedex" do @pokemon = Pokemon.all erb :"pokemon/pokedex" end get...
true
eefcda5f35e4910b3da12845e942a24e084d83c7
Ruby
charlie83xt/Boris_Bikes
/lib/docking_station.rb
UTF-8
775
3.59375
4
[]
no_license
class DockingStation attr_reader :bikes attr_reader :capacity attr_reader :broken_bikes DEFAULT_CAPACITY = 20 def initialize(capacity = DEFAULT_CAPACITY) @capacity = capacity @bikes = [] @broken_bikes = [] end def release_bike self.empty? ? raise("There are n...
true
082c0993fdcd30df919c772c7bce162504ce1fe1
Ruby
Makdash49/flash_cards_game
/game.rb
UTF-8
1,033
3.53125
4
[]
no_license
require_relative 'cards' require_relative 'console' require_relative 'player' # require_relative '' class Game def initialize @cards = Cards.new @console = Console.new init_game end def init_game create_welcome_message @deck = create_deck_of_cards run! end def create_welcome_message name ...
true
0378c00ba23869c881fcfd60c01f10f0ae7a58df
Ruby
Sigi5mund/Coursework
/week_01/day_4/fizz_buzz/fizz_buzz.rb
UTF-8
1,817
4.3125
4
[]
no_license
# First iteration # def fizz_buzz(number) # if ((number % 3 == 0) && (number % 5 == 0)) # return "FizzBuzz" # end # if (number % 3 == 0) # return "Fizz" # end # if (number % 5 == 0) # return "Buzz" # end # return number.to_s # end # Second iteration complete with refactor def fizz_buzz(numbe...
true
7a9ad45fd9e048d00051fd4624ca57b517a7634b
Ruby
ianhawe/Automated-SQL-Checker
/models/question.rb
UTF-8
1,199
2.859375
3
[]
no_license
class Question attr_accessor :id, :question, :studentanswer def save conn = Question.open_connection if("question-#{post.id}-text") # Insert a new record in to the database sql = "INSERT INTO studentanswer (questionid , answer) VALUES ( post.id, '#{self.id.value}')...
true
6c9df43fa5bfd16444c650d2d063bb5545b2b52e
Ruby
freegeek-pdx/accounting
/xtuple_import/parse_gnucash.rb
UTF-8
2,726
2.578125
3
[]
no_license
#!/usr/bin/ruby # TODO: from xtuple SELECT(MAX ... sequence_number = 0 journal_number = 0 require 'zlib' require 'nokogiri' include Nokogiri require 'csv' account_id_hash = eval(File.read('./accounts.rb')) # ryan52@lima:~$ ./generate_account_id_hash.sh > accounts.rb content = nil Zlib::GzipReader.open('../current.g...
true
26b1f9e24cbe869be7b89e625339e53188195f7d
Ruby
phildionne/parkrent
/app/models/validators/license_plate_validator.rb
UTF-8
795
2.65625
3
[]
no_license
class LicensePlateValidator < ActiveModel::EachValidator # Validates a license plate is valid # # @param record [ActiveRecord::Model] # @param attribute [Symbol] # @param value [String] def validate_each(record, attribute, value) value.squish! if value.respond_to?(:squish) formats = [ /\A[a-...
true
ff9bbc2e3a7942018aad1625bf9e3a98e446bb89
Ruby
valotrading/tastevin
/lib/tastevin/config.rb
UTF-8
869
2.671875
3
[ "Apache-2.0" ]
permissive
require 'inifile' module Tastevin class Config def self.load FileUtils.mkdir_p(path) filename = File.join(path, 'agents') inifile = IniFile.new(:filename => filename) Config.new(inifile) end def self.path File.join(ENV['HOME'], '.tastevin') end def [](name) ...
true
1cc7c1e6fa1912c32855143f311674def6190303
Ruby
MarkDucommun/new-game-of-life-ruby
/spec/plane_spec.rb
UTF-8
1,167
2.90625
3
[]
no_license
require 'rspec' require_relative '../sort_set_plane' describe 'plane' do let(:plane) { SortSetPlane.new } describe 'creation' do it 'can be built gradually' do plane.add(-1, 0) plane.add 0, 0 plane.add 1, 0 expect(plane.living).to eq [coord(-1, 0), coord(0, 0), coord(1, 0)] end ...
true
2bb0eb30c34cb79c9002c5c21254f313dd4d07f6
Ruby
andrada1403/anagram-detector-online-web-ft-100719
/lib/anagram.rb
UTF-8
224
3.28125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Your code goes here! require 'pry' class Anagram attr_accessor :word def initialize(word) @word=word end def match(words) words.select { |candidate| candidate.split(//).sort==word.split(//).sort} end end
true
32cc65ba68e6da60f315462e4ef055659c6c8cb9
Ruby
iamabhishekt/leetcode-ruby-1
/80.remove-duplicates-from-sorted-array-ii.rb
UTF-8
2,061
4.0625
4
[]
no_license
# -*- coding: utf-8 -*- # # @lc app=leetcode id=80 lang=ruby # # [80] Remove Duplicates from Sorted Array II # # https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/description/ # # Given a sorted array nums, remove the duplicates in-place such that # duplicates appeared at most twice and return the ne...
true
d0be5b535554ba53bf3931ffb69cdb14c883aa14
Ruby
dcastroeyss/wikirate
/mod/projects/set/type_plus_right/project/wikirate_company.rb
UTF-8
1,954
2.609375
3
[]
no_license
# These Project+Company (type plus right) cards refer to the list of # all companies on a given project. include_set Abstract::Table # @return [Card::Name] def project_name name.left_name end # @return [Array] all of this card's items that refer to a valid company def valid_company_cards @valid_company_cards ||=...
true
29e0050b9bbebef1235e55fd9f147920eed5ba00
Ruby
aws/aws-parallelcluster-cookbook
/cookbooks/third-party/line-4.5.13/spec/unit/library/filter_helper/verify_one_of_spec.rb
UTF-8
1,192
2.671875
3
[ "Apache-2.0" ]
permissive
# # Copyright:: 2018 Sous Chefs # # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
true
2235a1a4eecf785231a75b30471fc2f736e73473
Ruby
bopes/data-structures
/linked_list.rb
UTF-8
234
2.9375
3
[ "MIT" ]
permissive
class Node attr_reader :value, :points_to def initialize(value) @value = value end def insert_after(next_node) @points_to = next_node end def remove_after() @points_to = nil end end class LinkedList end
true
58dfacd367828165ef7a12ab3f2541348ea183a1
Ruby
duranangela/enigma
/test/cracker_test.rb
UTF-8
799
2.578125
3
[]
no_license
require './test/test_helper' require 'minitest/autorun' require 'minitest/pride' require './lib/cracker' class CrackTest < Minitest::Test def test_it_exists crack = Crack.new(',af2qbph.h72x8oo,38ixgair', '051618') assert_instance_of Crack, crack end def test_it_has_attributes crack = Crack.new(',af...
true
ed5ab93a3db0efebd8e200edbf2e31d1fe7c678f
Ruby
fiscaliza-brasil/fiscaliza-brasil
/lib/tasks/import.rake
UTF-8
5,737
2.671875
3
[ "MIT" ]
permissive
require 'csv' require 'json' namespace :import do desc "Imports data from files to the database" task tse: :environment do $estados = {} Estado.all.each do |e| $estados[e.sigla] = e.id end # estado_id, codigo, nome def get_municipio p t = Municipio.find_by(codigo: p[:codigo]) ...
true
a5876488a2e652ee6dedff4fa73d2bfc1e402603
Ruby
frstgt/chat_tool
/chat_client.rbw
UTF-8
2,287
2.71875
3
[]
no_license
#!/usr/bin/ruby # encoding: utf-8 require "socket" require "thread" load "./chat_setting.rb" require "./lib/log_util" require "./lib/net_util" require "./lib/chat_if" require "./lib/util" begin # init log = LogUtil.new("./log", CLIENT_NAME, CLIENT_LOG_ENABLE) cif = ChatIf.new(CLIENT_NAME, CHAT_INTE...
true
247976a5afe06702cf9ce2f268320e2cfa5e973e
Ruby
EPIC448/oo-basics-v-000
/lib/shoe.rb
UTF-8
538
3.703125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Make your shoe class here! # for an questions look back at your book.rb code in the same folder class Shoe # note By using attr_accessor :brand, :color, :confounded:ize, :material, :condition at the top of the code, you have essentially created variables that can now be accessed using the @ symbol #example on line 16...
true
7feacdd038f3a637a6388dadd68ffbd5b45acd15
Ruby
mshakhan/ruby-stuff
/console_colors.rb
UTF-8
700
3.234375
3
[]
no_license
# playing with console colors module Kernel CONSOLE_COLORS = { :none => -1, :bright => 1, :underline => 4, :blink => 5, :invert => 7, :black => 30, :red => 31, :green => 32, :yellow => 33, :blue => 34 } alias_method :__origin_puts__, :puts def puts(*args) if args.la...
true
534fe0c89ca77ec2e43e2841adc89c0ce3b8176d
Ruby
cr1tterp0wer/aa-hmwk
/W4D4/auth/app/models/user.rb
UTF-8
904
2.578125
3
[]
no_license
require 'bcrypt' class User < ApplicationRecord include SecureRandom #make sure User has a Session Token, then proceed before_validation :ensure_session_token after_validation :password validates :username, presence: true validates :session_token, presence: true validates :password_digest, presence: {me...
true
21c58791aec9bbdac8e13ef26a7a6a73274e8c80
Ruby
learGitHub/imageblur02
/imgBlur02.rb
UTF-8
958
3.796875
4
[]
no_license
class Image def initialize (picture) @picture = picture end def output_image @picture.each do |row| puts row.join {|row| print row} end end def blur blur_pos = [] @picture.each_with_index do |row, y_idx| row.each_with_index do |num, x_idx| #puts ...
true
51f19a36714df9b35df0aca1ce83bd20aa897e0f
Ruby
dhill92/souq
/souq.rb
UTF-8
760
3.609375
4
[]
no_license
items = ["Old paperback book", "Frankincense", "Myrrh", "Hookah pipe", "Dried dates","Rose water","Hummus", "Magic carpet","Lamp"] puts "Hello! Welcome to the worlds first online Souq! Your name please?" name = gets.chomp.to_s puts "Alright #{name}, here is a list of items you can buy!" items.each do |item| puts "...
true
4a925e5e6801c8e106994f50dd228dfe4030a8fd
Ruby
cielavenir/procon
/codeforces/tyama_codeforces510C.rb
UTF-8
466
3.015625
3
[ "0BSD" ]
permissive
#!/usr/bin/env ruby require 'tsort' class Hash include TSort alias tsort_each_node each_key def tsort_each_child(node, &block) fetch(node).each(&block) end end A=gets.to_i.times.map{gets.chomp.chars.to_a} h={} A.combination(2){|x,y| if [x.size,y.size].min.times{|i| if x[i]!=y[i] h[x[i]]||=[] h[y[i]]||=[]...
true