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
265fb37893463b6cf3429a3a81fc6184510fd22a
Ruby
kpnetdev/combinatorics-is-hard
/spec/new_combo_spec.rb
UTF-8
2,960
3
3
[]
no_license
require './new_combo.rb' describe Combo do before(:each) do @c = Combo.new(%w(A B C D E F), 2) end it "initializes the yet_to_pair hash correctly" do expect(@c.yet_to_pair["A"]).to eq(["B", "C", "D", "E", "F"]) end it "correctly scores a zero-score prospective pairing" do @c.yet_to_pair["A"] = %w(C D E F...
true
fb5c7bed562da0a8a1f7f614d657d563b95d209f
Ruby
ephraimrothschild/intelliflight
/app/models/airport.rb
UTF-8
776
2.6875
3
[]
no_license
class Airport < ActiveRecord::Base def self.import_airports regexp = /"([a-zA-Z0-9]{3})","(.+): (.+)?"/ File.open("https://raw.githubusercontent.com/ephraimrothschild/intelliflight/master/public/airports.txt", "r") do |f| f.each_line do |line| match = regexp.match(line) Airport.create(co...
true
8f55f6d71799793ba00ccd7802f7db6b040bd0ba
Ruby
kelvinmwenda9/my-ruby
/case.rb
UTF-8
307
3.390625
3
[]
no_license
count = 7 case when count==0 puts "noboody" when count ==1 puts "1 person" when (2..5).include?(count) puts "several people" else puts "many people" end case count when 0 puts "noboody" when 1 puts "1 person" when 2..5 puts "several people" else puts "many people" end
true
34f647af93cb498d051ef1245a58d4572c6b61c5
Ruby
travelingwheels/oo-student-scraper-online-web-sp-000
/lib/scraper.rb
UTF-8
1,389
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'open-uri' require 'nokogiri' require 'pry' class Scraper def self.scrape_index_page(index_url) html = File.read("./fixtures/student-site/index.html") doc = Nokogiri::HTML(html) list_students = [] students = {} doc.css(".student-card").each {|a| students = { :name => a...
true
11ec9fdca72a2265c28c93ba9f33d587a6094b35
Ruby
Zemhart/Attack-the-Monsters
/tests/test_golem_monster.rb
UTF-8
552
2.703125
3
[ "MIT" ]
permissive
require "minitest/autorun" require_relative '../monster_types/golem_monster' class TestGolemMonster < Minitest::Test def setup @golem_monster = GolemMonster.new end def test_golem_hp assert_equal 30 * 1.2, @golem_monster.hp end def test_golem_name assert_equal 'Golem', @golem_monster.name end...
true
fe4e429632db5582b850cfaf73833452d5903d3f
Ruby
peteb/thesis
/perf/test_stats
UTF-8
1,943
3.265625
3
[]
no_license
#!/usr/bin/env ruby -wKU def numeric?(object) true if Float(object) rescue false end def print_row(column_captions, column_widths) blank_spaces = 0 line = "" column_captions.each_with_index do |caption, idx| line << " " * blank_spaces + caption blank_spaces = column_widths[idx] - caption.length if idx < ...
true
178936f8595b52d61476df1ae31cf6cf9a47b3d7
Ruby
milo-codes/imdb_inner_joins_lab
/models/movie.rb
UTF-8
1,105
3.25
3
[]
no_license
require("pg") require_relative("../db/sql_runner.rb") class Movie attr_accessor :id, :title, :genre def initialize(options) @id = options["id"].to_i if options["id"] @title = options["title"] @genre = options["genre"] end def save() sql = " INSERT INTO movies (title, genre) ...
true
c0dd2c4684faf37cfcca338ca141d308e4518d0e
Ruby
dborski/enigma
/lib/enigma.rb
UTF-8
476
2.765625
3
[]
no_license
require_relative 'cipher_algo' class Enigma < CipherAlgo def encrypt(message, key = generate_random_num, date = date_today) encrypted_message = encrypt_message(message, key, date) {encryption: encrypted_message, key: key, date: date} end def decrypt(message, key, date = date_tod...
true
286cf2a0cd75d5f208b293fff7fcb2bd46688ac0
Ruby
khaivubui/w2d3_classwork
/Poker/spec/card_spec.rb
UTF-8
677
3.15625
3
[]
no_license
require 'card' describe Card do subject(:card) { Card.new(10, :hearts) } let(:cardsuit) {Card.new(13, :spades)} describe '#initialize' do it "has a value" do expect(card.value).to eq(10) end it "has a suit" do expect(card.suit).to eq(:hearts) end it "starts hidden" do exp...
true
d13f45da1c38d748b433fc9db95ef8046b70adc9
Ruby
michelchenrich/mm-kata-ruby
/lib/decorator.rb
UTF-8
168
2.625
3
[]
no_license
class Decorator def initialize decorated @decorated = decorated end def method_missing(method, *arguments) @decorated.send(method, *arguments) end end
true
1bb05227e540ac10d730a3f535b5ade8e38f5547
Ruby
procore/sift
/lib/sift/type_validator.rb
UTF-8
1,305
2.859375
3
[ "MIT" ]
permissive
module Sift # TypeValidator validates that the incoming param is of the specified type class TypeValidator DATETIME_RANGE_PATTERN = { format: { with: /\A.+(?:[^.]\.\.\.[^.]).+\z/, message: "must be a range" }, valid_date_range: true }.freeze DECIMAL_PATTERN = { numericality: true, allow_nil: true }.freeze ...
true
5aa269fc342abc9be99d38f90717afbbd463b585
Ruby
kupolak/codewars
/Ruby/8 KYU/101 Dalmatians - squash the bugs, not the dogs!.rb
UTF-8
237
3.515625
4
[]
no_license
def how_many_dalmatians(n) dogs = ["Hardly any", "More than a handful!", "Woah that's a lot of dogs!", "101 DALMATIONS!!!"] if n <= 10 dogs[0] elsif n <= 50 dogs[1] elsif n == 101 dogs[3] else dogs[2] end end
true
6197ec9bac99a84ace2590c0c64cd2bcadd49d13
Ruby
Jeff-Tian/mybnb
/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-client-1.2.18/lib/nautilus/shell.rb
UTF-8
694
2.890625
3
[ "Apache-2.0" ]
permissive
module Nautilus class Shell def run(command, options = {}) sh build_command(command, options) end def build_command(command, options = {}) actual_command = command.kind_of?(Array) ? command.join(" ") : command if options[:background] if windows? actual_command ...
true
bbb251127415739d1bd2d417be33d25f81ed925e
Ruby
nate-gentry/ttt-3-display_board-example-bootcamp-prep-000
/lib/display_board.rb
UTF-8
126
2.828125
3
[]
no_license
def display_board phrase = " | | \n" "-----------\n" 3.times { puts phrase } puts "a 3x3 tic tac toe board" end
true
8f7447ab5c833b8eac62ac8d8a8d3edfc42be977
Ruby
DiegoAraque1207/pruebas_easy
/app/controllers/mis_recetas_controller.rb
UTF-8
1,488
2.65625
3
[]
no_license
class MisRecetasController < ApplicationController def update_recipe_action puts ' @@@ Accion de actualizar recetas' # Queda Pendiente recibir la receta que se va editar de la vista por parametros @receta = Recipe.find_by id: 115 # Queda pendiente recibir los nuevos parametros capturados ...
true
92eccf923e2f2a78dbb70ef805e2f6482b784644
Ruby
colinsr/complete_rails_udemy
/ruby_projects/analyzer.rb
UTF-8
1,377
4.5
4
[]
no_license
# Structure of an if condition: # if #condition # #execute logic # end # #variant # if #condition # #execute logic # else # #execute different logic # end # #variant # if #condition # #execute logic # elsif #different condition # #execute logic 2 # else # #execute logic 3 # end # Code worked on: def multiply(first_numb...
true
d4554db30e5c211b23695079ec9e8e95de37c674
Ruby
BerilBBJ/scraperwiki-scraper-vault
/Users/O/ozgun/program_1.rb
UTF-8
1,196
2.84375
3
[]
no_license
html = ScraperWiki::scrape("http://tv.ekolay.net/kanal/8/Star.aspx") p html require 'nokogiri' doc = Nokogiri::HTML html =begin doc.search(".wd70").each do |v| cells = v.search 'td' if cells.count == 12 data = { country: cells[0].inner_html, years_in_school: cells[4].inner_ht...
true
2aa33a5e7af123fcf4946cec82a158168dd250fb
Ruby
u-akihiro/picasa-photo-upload-example
/app2.rb
UTF-8
1,219
2.640625
3
[]
no_license
require 'net/http' require 'uri' require 'cgi' require 'base64' # 実行時引数よりアクセストークンを取得 access_token = ARGV[0] # エンドポイントURL endpoint = 'https://picasaweb.google.com/data/feed/api/user/default/albumid/6037421118196288497' uri = URI.parse endpoint req = Net::HTTP::Post.new uri.request_uri req['Content-Type'] = 'multipart/r...
true
78f43e87ccea65055afca1ad61c4430ae420d7e2
Ruby
SeanEmmers/algorithm-training
/expanded_numbers/lib/expanded_numbers.rb
UTF-8
239
3.265625
3
[]
no_license
def expanded_numbers(number) num_arr = number.to_s.split('') arr_num = num_arr.length - 1 final_arr = [] num_arr.each { |num| final_arr << num + '0' * arr_num if num != '0' arr_num -= 1 } final_arr.join(' + ') end
true
d0e34520349a4f6daf6310d4e697426b7128953d
Ruby
Lessuiz/exercicios_ruby
/mastermind.rb
UTF-8
1,576
4.40625
4
[]
no_license
require 'pry' class Computer attr_accessor :array, :numbers def initialize @array = [] @round = 0 @numbers = [1, 2, 3, 4, 5, 6] while @array.length < 4 do a = @numbers.sample @array.push(a) @numbers.delete(a) end end def play_round selected_numbers = [] puts "Rou...
true
38c029218f6a1ff14ac7cca38b77584f2cd87d00
Ruby
catejaeger86/school
/parallel_programming/assignment1/coin_flip_scaleup_gnuplot.rb
UTF-8
858
2.65625
3
[]
no_license
require 'rubygems' require 'gnuplot' require 'coin_flip_data_parser' parser = CoinFlipDataParser.new( ARGV[0] ) MAX_THREADS = parser.data[parser.data.keys.first].size - 1 # graph data with gnuplot Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| x = parser.data.keys.sort y = x.collect do |flip_number|...
true
2db6c84cb2cb4c7709078e4b669e424691fefdee
Ruby
xuhui/rack-php-session
/lib/rack/php-session.rb
UTF-8
974
2.59375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'php_serialize' module Rack # Exposes a PHP Session in Rack Applications as a Hash class PHPSession # @param [Hash] options the options to configure the middleware # @option options [String] :session_name ('PHPSESSID') The name of the PHP Session # @option options [String] :session_file_path (...
true
5343b9d20be0f2a1e1f704630a81ad5104332f49
Ruby
Ratatoskor/project_euler
/ruby/020.rb
UTF-8
741
4.53125
5
[]
no_license
#Factorial digit sum =begin Problem 20 n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! =end #returns factorial of the input number def factori...
true
8fa06fade31433973a7909c0101f7f4e2945793e
Ruby
Bakerbj/git-practice
/git.rb
UTF-8
240
3.21875
3
[]
no_license
puts "Coding is fun!!!!!!!" puts "I feel tired because school starts too early!!!:{" puts "I feel like I will be brain dead by the end of school." puts "I feel happy." puts "I feel sad." puts "I feel bipolar." puts "Pushed change from home"
true
d5e13b9a60dc6215d9c5ab20d86ca5138630d458
Ruby
erzhu4/Checkers
/players.rb
UTF-8
1,670
3.8125
4
[]
no_license
class HumanPlayer attr_reader :color, :name def initialize(name, color) @name = name @color = color end def get_move # takes string from human and converts to commands array for the Board#move method puts "#{@name} please enter your move(s): " input = gets.chomp arr = input.split(',') ...
true
b0e6fbe8c002c3d535b1e7ef051df06f5357116d
Ruby
louisaspicer/lrthw
/chap37/rug.rb
UTF-8
965
3.34375
3
[]
no_license
@key = false def rug puts "You lift the rug and find a key." puts "Do you want to try the key in the door?" answer = $stdin.gets.chomp.downcase if answer == "yes" && @cube == true puts "You walk to the door and notice there's a square hole in the middle." puts "You take out the cube block you picked up...
true
c6081f743946f43356f91a564fd7f5fcdb43c447
Ruby
Maturin/win32-symlink
/lib/win32/filesymlink.rb
UTF-8
365
2.765625
3
[ "MIT" ]
permissive
require_relative 'symlink' # Extending the File class on windows system, so that its symlink function work as on other sytems. class File def File.symlink(file, symlink) Win32::Symlink::symlink(file, symlink) end def File.symlink?(file) Win32::Symlink::symlink?(file) end def File.readlink(file) ...
true
da1e249046acbaeaa746ee6e56ac970bf6a5d218
Ruby
benhpoh/Bulldozer-simulator
/lib/test_command.rb
UTF-8
4,592
2.546875
3
[]
no_license
require "minitest/autorun" require "minitest/reporters" require_relative "command" Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new) class Init_Test < MiniTest::Test def test_read_commands command = Command.new([["o","o","o"]]) actual = command.commands_history expected = [] assert_equ...
true
8e3c63f769cca1a19a0cf9eb73452be32a354978
Ruby
glowen18/104ruby
/greetingapp.rb
UTF-8
715
3.703125
4
[]
no_license
require 'sinatra' =begin get '/' do "Hello World" end =end def determine_current_hour current_time = Time.new current_hour = current_time.hour end def greeting(name) current_hour = determine_current_hour if (current_hour > 3 && current_hour < 12) time = "morning" elsif (current_hour > 12 && current_hour < ...
true
b3eab4a63df3cbdaaefbbe381b4e86807ea279a7
Ruby
eglorenzana/colours
/lib/color_module/converters/lab_model_converter.rb
UTF-8
388
2.734375
3
[]
no_license
module ColorModule module Converters # Implements the conversion methods from LAB space for other spaces class LABModelConverter < ColorModelConverter def to_lab @model end def to_xyz lab_to_xyz(@model) end def to_cmyk rgb_to_cmyk(to_rgb) end ...
true
2d876374272b7f8eb7fbe2594b4104f4bdad5d0b
Ruby
zjmdp/Vim-Config
/janus/ruby/janus.rb
UTF-8
1,179
2.546875
3
[ "MIT" ]
permissive
module Janus # Return the root path # # @return [String] The absolute path to Janus repository def root_path ROOT_PATH end # Return Janus path # # @return [String] The absolute path to Janus distribution def janus_path File.join ROOT_PATH, 'janus' end # Return the vim's path # # @ret...
true
a7e2e2a5ee9bb4fb6f3cd2c016bed107134ab7bb
Ruby
lepert/robocup-client
/lib/robot.rb
UTF-8
230
2.53125
3
[]
no_license
module Robot extend self attr_reader :commands, :data, :observers @data = {} @commands = [] @observers = {} def data=(new_data) @data.merge!(new_data) @observers.values.each {|it| it.call } end end
true
05c962bf94a581037917f89cf8932ca3d3d31a42
Ruby
justinsuen/algo-practice
/ctci/01_arrays_and_strings/01_is_unique.rb
UTF-8
403
4.125
4
[]
no_license
def is_unique(s) # O(n) time and O(1) space hash = Hash.new(0) s.each_char do |c| hash[c] += 1 return false if hash[c] > 1 end true # O(nlogn) time and O(1) space # s = s.chars.sort.join # s.chars.each_with_index do |c, idx| # next if idx == 0 # return false if c == s[idx - 1] # end ...
true
372bc5f441678ebeb0b10c2cb8efc876c868d5dc
Ruby
mike1o1/advent_2018
/day_1/solution.rb
UTF-8
560
3.28125
3
[]
no_license
module Day1 def self.problem_1(changes) changes.map(&:to_i).reduce(:+) end def self.problem_2(changes) changes = changes.map(&:to_i) found_frequences = {} frequency = 0 found_frequences[0] = 1 changes.cycle do |change| frequency +...
true
e381330af1e5f131d80c5c55ba93507df09dcb33
Ruby
shortlock/testfirst.org
/02_calculator/calculator.rb
UTF-8
367
3.53125
4
[]
no_license
def add (a,b) sum = a + b end def subtract (a,b) sum = a - b end def sum numbers s = 0 numbers.each do |i| s += i end return s end def multiply (*a) s = 1 a.each do |i| s *= i end return s end def power (a,b) sum = a ** b end def factorial a i = a if a == 0 return 1 else while i > 1 do i ...
true
28193e8220289731e53f25e885357a04deb2f671
Ruby
hugopeixoto/mustache
/lib/mustache/context.rb
UTF-8
4,306
2.8125
3
[ "MIT" ]
permissive
require 'mustache/context_miss' require 'mustache/key_finder' class Mustache class FrameTracker attr_accessor :frame def initialize frame self.frame = frame end def update new_frame self.frame = new_frame end def fetch(key, default) self.frame.fetch key, default end ...
true
37f84df7900420642d6248f8b9ffb6056ef8eb2c
Ruby
levans248/ride_4_less_app
/app/models/uber_new_years_datum.rb
UTF-8
1,276
2.546875
3
[]
no_license
class UberNewYearsDatum < ActiveRecord::Base def self.new_years_data(district) client = Uber::Client.new do |config| config.server_token = ENV['SERVER_TOKEN'] end if district == "Nob Hill" start_lat = 37.7929521 start_lng = -122.4204894 elsif district == "Marina" start_lat ...
true
eeef3c5c4acf0abe1e34210a1181b17e6e099a21
Ruby
taw/project-euler
/euler_124.rb
UTF-8
219
2.90625
3
[]
no_license
#!/usr/bin/env ruby require "mathn" class Integer def rad prime_division.map{|p,k| p }.inject(1, &:*) end end (1..100000).map{|n| [n.rad, n] }.sort.each_with_index{|(nr, n), k| p [n, nr, k+1] }
true
6450eff37f09175fe7901c75981e4b7a078472bc
Ruby
textchimp/wdi-22
/week4/ruby-intro/test.rb
UTF-8
301
3.46875
3
[]
no_license
puts "What is your first name?" first_name = gets.chomp # first_name = first_name.chomp puts "Your first name is #{ first_name }, congratulations!" puts "What is your last name?" last_name = gets.chomp puts "Your surname is #{ last_name }" puts "Your full name is #{ first_name } #{ last_name }"
true
e92de1a851125051895d2f327ae4a83c684c5cf8
Ruby
KONISHI-Toru/portfolio
/test/models/phase_test.rb
UTF-8
1,116
2.625
3
[ "MIT" ]
permissive
require 'test_helper' class PhaseTest < ActiveSupport::TestCase def setup @phase = Phase.new(name: "Phase1", display_order: 100) end test "should be valid" do assert @phase.valid? end test "nameは必須" do @phase.name = " " assert_not @phase.valid? end test "name...
true
38f23557b8742a27df469721dbdc97090b5cac8c
Ruby
southpawgeek/perlweeklychallenge-club
/challenge-103/abigail/ruby/ch-2.rb
UTF-8
1,934
3.625
4
[]
no_license
#!/usr/bin/ruby # # See ../README.md # # # Run as: ruby ch-2.rb < input-file # # # We're reading a start time, the current time, and a file name # from STDIN, separated by white space. The file contains the # tracks played. # ARGF . each_line do |_| start_time, end_time, file_name = _ . split # # Ruby...
true
1f4c21ae755982240a0fbea22f91688b993f2a9a
Ruby
francisco-rojas/ruby_learning
/Cami/cami_homework.rb
UTF-8
678
3.859375
4
[ "MIT" ]
permissive
class Account attr_reader :number, :balance attr_accessor :pin #, :balance def initialize(number) @number = number #or number = number @balance = 0 puts "number #{number}" end def owner @owner end def owner=(owner) @owner = owner end def deposit(amount) @balance = @balance +...
true
b1c6b1093bdd524a335e84f1167c091aa9fa0793
Ruby
sideprog/RTanque
/lib/rtanque/bot/sensors.rb
UTF-8
572
2.578125
3
[ "MIT" ]
permissive
module RTanque class Bot Sensors = Struct.new(:ticks, :health, :speed, :position, :heading, :radar, :radar_heading, :turret_heading, :gun_energy) do def initialize(*args, &block) super(*args) block.call(self) if block self.freeze end def button_down?(button_id) b...
true
5829856e06a38cc5d0afdd7a99a61222edab634b
Ruby
minutetominute/word_chains
/word_chains.rb
UTF-8
1,169
3.5
4
[]
no_license
class WordChainer def initialize(dictionary_file_name) @dictionary = File.readlines(dictionary_file_name) @dictionary = @dictionary.map { |line| line.chomp} @current_words = [] @seen_words = [] end def adjacent_words(word) result = [] @dictionary.each do |dict_word| next if word ==...
true
83dd7b24fc930b0029932d737281adcf45be9056
Ruby
code4tots/aa
/aahomework/learn_ruby-master/04_pig_latin/pig_latin.rb
UTF-8
501
3.5625
4
[]
no_license
# All of this ad-hoc specification makes me feel kinda dirty.... # def translate x def translate_word w capitalized = (w == w.capitalize) w.downcase! # move consonant sounds while !'aeiou'.include?(w[0]) if w.start_with? 'qu' w = w[2..-1] + w[0..1] else w = w[1...
true
c1735a0a9e52d8ce81d929fadb48c6283813e130
Ruby
Rafe/mail_parser
/lib/patterns/pattern.rb
UTF-8
131
2.734375
3
[]
no_license
class Pattern attr_accessor :block def initialize @block = lambda do |m| m.match :price , /(\d+)/ end end end
true
0434accf59732eebb5f46c66a588682e378d40aa
Ruby
tsuyopon/ruby
/basic_class/class1.rb
UTF-8
447
4
4
[]
no_license
=begin initializeは特別な名前のメソッドでnewした際に実行されます。 =end class Creature # constructor def initialize(name) @name = name end def name @name end end # define Person tha is derived from Creature. class Person < Creature def initialize(name,age) super(name) @age = age end def age @age end ...
true
30ecb5f8dff98ee5078e9201e5798d0b45a925fd
Ruby
wdmeida/studies_ruby
/03 Metaprogramação/metodos_classe.rb
UTF-8
399
3.703125
4
[]
no_license
=begin class Pessoa #dados da classe end #Se classes são objetos, podemos definir métodos de classe como em qualquer objeto. def Pessoa.pessoas_no_mundo 100 end puts Pessoa.pessoas_no_mundo Há um idiomismo para definir os métodos de classe dentro da própria definição da classe, onde self aponta para o pŕoprio obje...
true
11caa78dfdb8e866e9a00f78bec96e9886acaffe
Ruby
sharath666/wd-june
/ruby/string.rb
UTF-8
134
2.890625
3
[]
no_license
sharath="9119" numbers = sharath.split("") arr =[] puts numbers numbers =arr puts puts arr[0] puts arr[1] puts arr[2] puts arr[3]
true
2dfc8d9ecfae8334afc66bc823b99c21ea0aa77d
Ruby
thomascullen/Pavo
/lib/pavo/section.rb
UTF-8
322
2.578125
3
[ "MIT" ]
permissive
module Pavo class Section attr_accessor :title, :content def initialize(attributes = {}) @content = '' attributes.each do |name, value| send("#{name}=", value) end end def href "##{id}" end def id title.gsub(/ /, '').downcase.underscore end end en...
true
2454eda67871289ade19b80422cde99f57f7584c
Ruby
jamelablack/tealeaf
/2ndCourse/Pre-course/SQL/SQLDelete.rb
UTF-8
863
3.1875
3
[]
no_license
The SQL DELETE Statement The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value; Note Notice the WHERE clause in the SQL DELETE statement! The WHERE clause specifies which record or records that should be deleted. You omit the WHERE clause, all ...
true
c98d807de402b7227ae77cf91e207325f1781b0b
Ruby
trizen/corvinus2
/scripts/Proiectul Euler/0018-maximum_path_sum_i.sf
UTF-8
735
3.53125
4
[ "Artistic-2.0" ]
permissive
#!/usr/bin/ruby # Find the maximum total from top to bottom of the triangle below. # https://projecteuler.net/problem=18 # Answer: 1074 var data = <<'EOT'; 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 32 37 16 9...
true
8c9576ee5a25df812815ee47983f6edf556c9f74
Ruby
paulosman/2019-advent-of-code-ruby
/day04.rb
UTF-8
699
3.359375
3
[]
no_license
start = 172_851 ending = 675_869 def adjacent_chars?(password) prev = nil streaks = [] streak = 1 password.to_s.split('').each do |c| if c == prev streak += 1 elsif streak > 1 streaks << streak streak = 1 end prev = c end streaks << streak streaks.include? 2 end def i...
true
22ffc77f4a104f069e2f138d3aabd1ab699b7a54
Ruby
micktaiwan/rubymlib
/games/trains/udp_server.rb
UTF-8
625
3.046875
3
[]
no_license
require 'socket' class UDPServer def initialize(host, port, autostart=true) # read UDP pickaxe docs (p. 774) for host @host, @port = host, port @s = UDPSocket.open @s.bind(@host, @port) @msgs = [] #Queue.new @count = 0 start if autostart end def start #puts "Li...
true
b491d05fcf665d3c0d4b3ab7e126c1b478f9555e
Ruby
pocman/biz
/spec/interval_spec.rb
UTF-8
5,151
2.65625
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
RSpec.describe Biz::Interval do let(:start_time) { week_minute(wday: 1, hour: 9) } let(:end_time) { week_minute(wday: 1, hour: 17) } let(:time_zone) { TZInfo::Timezone.get('America/Los_Angeles') } subject(:interval) { described_class.new( Biz::WeekTime.start(start_time), Biz::WeekTime.end(en...
true
f3f7e2d88914c9678b2adc88c40479b4ebb32e73
Ruby
br/approvals
/lib/approvals/filter.rb
UTF-8
1,037
2.890625
3
[ "MIT" ]
permissive
module Approvals class Filter attr_reader :filters def initialize(filters) @filters = filters || [] @paths_cache = {} end def apply(hash_or_array) if @filters.any? censored(hash_or_array) else hash_or_array end end def censored(value, path=nil) ...
true
ca5d0bd2a088198964c5c8a911e3f6d68514678e
Ruby
Trevor-Robinson/Enigma
/test/key_test.rb
UTF-8
1,476
2.859375
3
[]
no_license
require './test/test_helper' require 'minitest/autorun' require 'minitest/pride' require './lib/key' require 'mocha/minitest' class KeyTest < Minitest::Test def test_it_exists_and_has_attributes key = Key.new assert_instance_of Key, key assert_equal '00000', key.key assert_equal 0, key.a_key asse...
true
9c9b889bff7251a2b5da5563a3c107f53fc91056
Ruby
valdineireis/iugu-for-devs
/01_aquecimento_ruby/lib/ui.rb
UTF-8
1,559
3.375
3
[]
no_license
REGISTER = 1 VIEW = 2 SEARCH = 3 CHECK = 4 EXIT = 9 def welcome 'Bem-vindo ao Diário de Estudos, seu companheiro para estudar!' end def show_menu puts '----------------------------------' puts "[#{REGISTER}] Cadastrar um item para estudar" puts "[#{VIEW}] Ver todos os itens cadastrados" ...
true
cf053fbf36e011a1109aefd93db6e35a010bb632
Ruby
AmpRack/Ruby_Projects
/ProjectEuler/PE_12.rb
UTF-8
452
3.828125
4
[]
no_license
def number_of_factors(number) factors = 0 sqrt = Math.sqrt(number) x = 1 while (x <= sqrt) if (number % x == 0) factors += 2 end x += 1 end if (sqrt * sqrt == number) factors -= 1 end return factors end number = 0 x = 0 number_of_factors = 0 while (number_of_factors(number) < 500) x += 1 numbe...
true
c72f133558e5c26964288f9ee44637d967b3bd3c
Ruby
ryuichi-0913/ruby-practice
/Greetiong.rb
UTF-8
75
3.0625
3
[]
no_license
for i in 1..10 if i == 3 next elsif i == 7 break else p i end end
true
3920474942f5ffd0cdf2cfd0094e5f6e6fa8d64a
Ruby
leerivera/array-CRUD-lab-dc-web-082718
/lib/array_crud.rb
UTF-8
625
3.71875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def create_an_empty_array my_array = [] end def create_an_array my_array= ["a","b","c","d"] end def add_element_to_end_of_array(array, element) array = ["a"] array << "arrays!" end def add_element_to_start_of_array(array, element) array = ["wow"] array.push("b") end def remove_element_from_end...
true
79ee3d28fa8c72babc8dfcbe8866455ad7d0d14e
Ruby
adambeynon/opal
/spec/filters/unsupported/hash_compare_by_identity.rb
UTF-8
1,216
2.640625
3
[ "MIT" ]
permissive
opal_filter "Hash#comapre_by_identity" do fails "Hash#compare_by_identity causes future comparisons on the receiver to be made by identity" fails "Hash#compare_by_identity causes #compare_by_identity? to return true" fails "Hash#compare_by_identity returns self" fails "Hash#compare_by_identity uses the semantic...
true
daf36b1109ad85669dabf1d3d4c57f8969ebec56
Ruby
Kimbeaux/Learn-Ruby-Ex-12
/ex12.rb
UTF-8
1,871
2.765625
3
[]
no_license
require 'open-uri' open("http://www.ruby-lang.org/en") do |f| f.each_line {|line| p line} puts f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang-org/en/> puts f.content_type # "text/html" puts f.charset # [] puts f.last_modified # Thu Dec 05 02:45:02 UTC 2002 end # EC1: ...
true
018f8572e721489ca08287bec2e25813210f794c
Ruby
isundaylee/mentor
/app/models/segment.rb
UTF-8
2,422
2.609375
3
[]
no_license
class Segment < ActiveRecord::Base belongs_to :user belongs_to :owner, class_name: 'User' def self.insert(user, owner, date, st, ed) own = (user.id == owner.id) inter_own = Segment.where(user_id: user.id, date: date).where(owner_id: user.id) inter_non_own = Segment.where(user_id: user.id, date: date)...
true
3c9f7c02adbd19101e0870d9d671d07b9e12c576
Ruby
IrynaStein/gallery_db_backend
/db/seeds.rb
UTF-8
2,094
2.71875
3
[]
no_license
Artwork.destroy_all Category.destroy_all Collector.destroy_all Collection.destroy_all puts "Seeding Categories ..." cat1 = Category.create(name: "superheroes", popularity: 0) cat2 = Category.create(name: "pop-culture", popularity: 0) cat3 = Category.create(name: "flowers", popularity: 0) cat4 = Category.create(name:...
true
8b6e8e06bdf653fb10af992fd217e732fb1f9e5b
Ruby
charlesbjohnson/super_happy_interview_time
/rb/lib/leetcode/lc_34.rb
UTF-8
1,333
3.765625
4
[ "MIT" ]
permissive
# frozen_string_literal: true module LeetCode # 34. Find First and Last Position of Element in Sorted Array module LC34 # Description: # Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. # If target is not found in the array, ...
true
66846553260abd336de638ebbce3590584e03929
Ruby
caruby/tissue
/lib/catissue/helpers/person.rb
UTF-8
1,174
3.1875
3
[ "MIT" ]
permissive
require 'caruby/helpers/person' module CaTissue # Mix-in for domain classes that define the +first_name+, +last_name+ and optional +middle_name+ attributes. module Person include CaRuby::Person public # Returns this Person's name as a Name structure, or nil if there is no last name. def name ...
true
b7483644603fc5ff4c242565c63486c1f526adec
Ruby
DataPoints/DataPoints
/app/lib/cmd_interface.rb
UTF-8
591
2.875
3
[ "MIT" ]
permissive
# Name of Author: Peter Uherek # Created at: 3.3. 2015 # # Description: Interface pre skripty. # Na vykonanie skriptu je potrebne spustit funkciu Exec_command. require 'open3' class CMDInterface public def Exec_command(cmd) if system(cmd) return 0 #OK else return 1 #ERROR end end pub...
true
646ef5842db00d4a946f574bb423ca0f5c1aa748
Ruby
wellenteng/ruby_note
/variable.rb
UTF-8
286
3.265625
3
[]
no_license
# -*- coding: utf-8 -*- person = "Jim" puts person.object_id puts person[0] puts person puts person.class shadow = person puts shadow.object_id puts person.inspect puts shadow.inspect #拷贝新对象 person2 = person.dup puts person2.object_id #使对象不可修改 person.freeze
true
2b5e6c867ce9cea6e13723850f7b70e7b389a86f
Ruby
dream7boy/rails-yelp-mvp
/db/seeds.rb
UTF-8
962
2.984375
3
[]
no_license
# db/seeds.rb puts 'Cleaning database...' Restaurant.destroy_all puts 'Creating restaurants...' restaurants_attributes = [ { name: "Sukiya", address: "1-11-1 Takadanobaba Shinjuku Tokyo", phone_number: "01 11 11 11 11", category: "japanese" }, { name: "Matsuya", a...
true
183593d85d043aa262bf9522cb7b48e52669c908
Ruby
kidaa30/multicards-server
/app/models/user.rb
UTF-8
480
2.65625
3
[]
no_license
require 'constants' class User < ActiveRecord::Base def update(json_body) if ((self.details == nil) or (self.details.length == 0)) cur_details = {} else cur_details = JSON.parse(self.details) end json_body.each do |key, value| cur_details[key] = value end self.details = c...
true
1f29fb444db95f6a915c6b29f445a5de9f0a0ed4
Ruby
Asilver-jpg/ruby-oo-object-relationships-has-many-lab-nyc-web-030920
/lib/post.rb
UTF-8
240
3.0625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "pry" class Post attr_accessor :title, :author @@all=[] def initialize(name, artist=nil) @title=name @author = artist Post.all << self end def self.all @@all end def author_name if @author @author.name end end end
true
0cf92b301803433f30fd5ba2c397f85e8a2db2a5
Ruby
docbronovan/opentodo
/db/seeds.rb
UTF-8
1,203
2.53125
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
d48fcab282c6525b86b61b738e918ad3031691ff
Ruby
fjustin/iesumu
/spec/models/house_spec.rb
UTF-8
1,921
2.765625
3
[]
no_license
require 'rails_helper' RSpec.describe House, type: :model do describe "シェアハウス投稿のvalidationを確認" do # enumerizeを検証 extend Enumerize enumerize :status,in: [ :empty, :full ],default: :empty, scope: true before do end # userとhouseは度々利用するためローカル変数化 let(:user) { User.create(email: "test@gmail...
true
b1b27f60ec201e5235fc4d69a74554a9b216bc15
Ruby
vicuna96/23Tree_Ruby
/kickup.rb
UTF-8
747
3.5
4
[]
no_license
class Kickup # AF: A [Kickup] represents 2-Node in the upward phase of insertion into a # 23-Tree with [left,val,right] in ascending order, and with strict # inequality betweeen node values. # RI: The depth from the node to all leafs is the same. def initialize(val,left=nil,right=nil) @val, @left,...
true
e4efa86d9491e6232dc654f616f51cb3de65a909
Ruby
travis-ci/gh
/lib/gh/response.rb
UTF-8
2,647
2.96875
3
[ "MIT" ]
permissive
require 'gh' require 'multi_json' module GH # Public: Class wrapping low level Github responses. # # Delegates safe methods to the parsed body (expected to be an Array or Hash). class Response include Enumerable include GH::Case attr_accessor :headers, :data, :body, :url # subset of safe metho...
true
b590b2d83be805da6ae4c9384cf97175413e0eeb
Ruby
ckolderup/advent-of-code-2018
/7/1.rb
UTF-8
543
3.1875
3
[]
no_license
step_hash = {} IO.readlines('input.txt').each do |line| x, y = /Step (.) must be finished before step (.)/.match(line).captures step_hash[y] ||= [] step_hash[y] << x end # now fill in any missing gaps step_hash.values.flatten.uniq.each do |label| step_hash[label] ||= [] end steps = step_hash.to_a.sort_by(&:...
true
d3de3b2f5b899ad68433cb9c88227a35d58ef134
Ruby
TSAGI/assignments
/inheritance/people.rb
UTF-8
670
4.21875
4
[]
no_license
class Person def initialize(name) @name = name end def greeting "Hi, my name is #{@name}" end end class Student < Person def initialize(name) super(name) end def learn "I get it!" end end class Instructor < Person def initialize(name) ...
true
1ac2f800992efd74c7e36d3c739bc9fb6f091fdb
Ruby
bwidtmann/trains
/lib/rail_road.rb
UTF-8
943
3.5
4
[]
no_license
require_relative 'town' require_relative 'connection' module Trains class RailRoad attr :towns def initialize @towns = Array.new end def add_town(town_name) town = Town.new(town_name) towns << town end def add_connection(source_town_name, destination_town_name, length) ...
true
193301b9413a4d2cc4d3722bd4c07a6b9b2814cb
Ruby
lbarasti/yopt
/lib/yopt.rb
UTF-8
2,575
3.09375
3
[ "MIT" ]
permissive
require 'yopt/version' module Yopt def self.lift &block block or raise ArgumentError, 'missing block' -> (*args, &other_block) {Option.(block.call *args, &other_block)} end module Option include Enumerable def self.ary_to_type value raise Option.invalid_argument('Argument must be an array-l...
true
8375d546c6d62f71a712770bed38f65eef30d530
Ruby
bsheehy9/RB101-new
/lesson_3/easy_1/e1_q4.rb
UTF-8
115
3.140625
3
[]
no_license
numbers = [1, 2, 3, 4, 5] # deletes at index 1 (2) numbers.delete_at(1) # deletes the number 1 numbers.delete(1)
true
d4a8912055c7c71ec9895902689837d405edb14d
Ruby
pav3ls/learn-to-code-with-ruby-lang
/Section-8-Arrays-I-Creation_Addition_and_Modification/103. The .pop Method.rb
UTF-8
124
3.203125
3
[]
no_license
arr = [1, 2, 3, 4, 5, 6, 7 , 8 , 9, 10] p arr.length arr.pop p arr arr.pop p arr last_item = arr.pop(2) p arr p last_item
true
be4abebcee732de14e6b895cac1efb1c760f993b
Ruby
theanirudhvyas/DSA
/trees/next_greater_number_BST.rb
UTF-8
466
3.171875
3
[]
no_license
def next_greatest(root, data) successor = root while root.data != data if data < root.data successor = root root = root.left else root = root.right end end if root.right != nil root = root.right while root.left != nil root = root.left end return root els...
true
195677ce69d18f47396d26a2e50ab517166ab121
Ruby
hemalvarambhia/zopa_test
/lib/zopa/loans.rb
UTF-8
516
2.921875
3
[]
no_license
module Zopa class Loans attr_reader :market def initialize(market) @market = market end def display_best_quote(amount, payment_period = 36) quote = market.best_quote(amount, payment_period) return 'No quotes could be found at this time.' if quote.nil? "Requested amount:...
true
a1537534084893982eeb721b769df99acb2f9456
Ruby
murdho/payment_schedule
/lib/payment_schedule/output.rb
UTF-8
764
2.859375
3
[ "MIT" ]
permissive
require 'terminal-table' module PaymentSchedule class Output class << self def to_s(schedule) table = Terminal::Table.new(title: schedule.class) do |t| t << heading(schedule) t << :separator schedule.row_numbers.each do |row_no| t << row_contents(schedule,...
true
cfa441991838a0846991119b1bef1205adf73671
Ruby
aaronbieber/pastehost
/app/models/paste.rb
UTF-8
2,666
2.65625
3
[]
no_license
class Paste < ActiveRecord::Base validates_presence_of :paste, :message => 'You have to paste <em>something.</em>' validates_presence_of :ip validates_length_of :paste, :maximum => 5000, :message => 'Try to keep it under 5,000 characters, alright?' SANITIZE_ELEM = ['a', 'b', 'i', 's', 'strong...
true
94466d56c314b9552d2072fb5c7787e2a06dc865
Ruby
jjwumaster/playlister-sinatra-web-103017
/app/models/artist.rb
UTF-8
363
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative '../../lib/helper_methods.rb' class Artist < ActiveRecord::Base # include Helpers has_many :songs has_many :genres, through: :songs def self.find_by_slug(slug) # TAKE OUT OF SPEC self.all.find do |artist| artist.slug == slug end end def slug self.name.downcase.gsub(/[...
true
27ab0536d2fbe7bd59b5dc99a8ae33f1b1b2095d
Ruby
escobara/ro_design_patterns
/iterator_pattern/iterator_external.rb
UTF-8
962
3.9375
4
[]
no_license
class ArrayIterator def initialize(array) @array = array @index = 0 end def has_next? @index < @array.length end def item @array[@index] end def next_item value = @array[@index] @index += 1 value end end def merge(array1, array2) merge = [] iterator1 = ArrayIterator.new(array1) iterator2 =...
true
57c98b9ba2cf8a5ff507c0b2ad31254028b60657
Ruby
thumblemonks/whyvalidationssuckin96
/test/macros/validates_length_test.rb
UTF-8
6,908
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'teststrap' context "validates length" do should "add a validation macro" do WhyValidationsSuckIn96::ValidationBuilder.instance_methods.map {|im| im.to_s} end.includes('validates_length_of') should "raise if an no options are given" do WhyValidationsSuckIn96::ValidatesLength.new(Object.new,...
true
44d70ed6e42f5d2580d4fc151a61aaf8ee48ab7d
Ruby
bawdo/rps_tournament
/players/sequence_player.rb
UTF-8
190
2.546875
3
[]
no_license
class SequencePlayer < RpsTournament::Player def initialize @sequence = [:paper, :rock, :scissors] end def choose @sequence.push @sequence.shift @sequence.first end end
true
0057fdb64155044381294ac77d0e585a9c943db1
Ruby
birdo562/my-each-online-web-pt-081219
/my_each.rb
UTF-8
90
3.078125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def my_each(array) n=0 while n < array.length yield array[n] n += 1 end array end
true
adf03059e39cdf36b170dc18bbf764e7380c01f5
Ruby
abd00s/habot
/app/services/goal_periods/retriever.rb
UTF-8
477
2.640625
3
[]
no_license
module GoalPeriods class Retriever attr_reader :goal_period def self.run(args = {}) new(args).tap(&:run) end def initialize(args = {}) @goal = args[:goal] @date = args[:date] end def run @goal_period = GoalPeriod.find_or_create_by( goal: @goal, ...
true
295c391cdfd336821ede8285fa53ec25b1ad31d3
Ruby
NicoBuch/iot-trello-logger
/app.rb
UTF-8
1,075
2.546875
3
[ "MIT" ]
permissive
require 'dotenv' Dotenv.load require 'sinatra' require 'trello' Trello.configure do |config| config.developer_public_key = ENV['TRELLO_DEVELOPER_PUBLIC_KEY'] config.member_token = ENV['TRELLO_MEMBER_TOKEN'] end get '/boards' do halt 400 unless params[:user].present? member = Trello::Member.find(params[:use...
true
fd3a710282138f50fb607fad0c3cf99e302f9653
Ruby
rgodlontonshaw/mittsu
/lib/mittsu/renderers/opengl/opengl_light_renderer.rb
UTF-8
876
2.578125
3
[ "MIT" ]
permissive
module Mittsu class OpenGLLightRenderer attr_accessor :lights_need_update, :cache LIGHT_CLASSES = [ AmbientLight, DirectionalLight, PointLight, SpotLight, HemisphereLight ] LIGHT_TYPES = LIGHT_CLASSES.map { |klass| klass::TYPE } def initialize(renderer) @rende...
true
75428205f4e507a610471b3d04064c23039067c6
Ruby
sarisgar28/key-for-min-value-onl01-seng-ft-012120
/key_for_min.rb
UTF-8
304
2.75
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
ikea = {:chair => 25,:table => 85, :mattress => 450} def key_for_min_value(ikea) #=> :chair veggies ={"apple" = |-45|, "cucumber" = |-44.5,| "tomato" = |44.9| } key_for_min_value(veggies) def = {"apple"} #sort_by(ikea) puts "the lowest #{veggie} is veggie #{number}" end end
true
fae1f8a857905e87bd7137a7d7186a54594608fa
Ruby
janie624/msgsrv
/app/models/user.rb
UTF-8
810
2.546875
3
[]
no_license
class User < ActiveRecord::Base validates_uniqueness_of :email validates_presence_of :email, :message => " is required." validates_presence_of :first_name, :message => " is required." validates_presence_of :last_name, :message => " is required." devise :database_authenticatable, :registerable, ...
true
d174a473b81a50dc06692c7fd383ef9cd3041daf
Ruby
puppetpadhy/config
/enc.rb
UTF-8
357
2.53125
3
[]
no_license
#!/usr/bin/env ruby require 'yaml' # I would have done this with Hiera's `heira_include`, but this is more # flexible, and plus it allows us to pass interesting things to Hiera later. node = ARGV[0] raise "No host provided" if node.nil? hosts = YAML.load_file(File.join(File.dirname(__FILE__), 'data', 'hosts.yaml'))...
true
8d81d73dd6304dd5c473d7a5c5455e080c49f390
Ruby
lgrains/euler
/spec/prob16_spec.rb
UTF-8
283
2.609375
3
[ "MIT" ]
permissive
require 'euler/prob16' describe Euler::Prob16 do context "power of 2 is 15" do subject { Euler::Prob16.new(15).sum_of_digits } it { should == 26 } end context "power of 2 is 24" do subject { Euler::Prob16.new(24).sum_of_digits } it { should == 37 } end end
true
4402bbaaf54834059869a386997a372856d0b1cc
Ruby
eugenechoidev/python-ruby
/Loop/3.rb
UTF-8
68
3.21875
3
[]
no_license
i = 0 while i < 3 do puts('Hello world') i = i + 1 end
true
82d4168224c90aec1aea2657bfb4e1813bc5623b
Ruby
ytolstyk/picturito
/app/models/rating.rb
UTF-8
1,517
2.640625
3
[]
no_license
# == Schema Information # # Table name: ratings # # id :integer not null, primary key # picture_id :integer # score :float default(0.0) # created_at :datetime # updated_at :datetime # last_reduction :datetime # highest_score :float default(0.0) # ...
true