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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dbbdecdd9554e33e023fb9c5ebb62a7106668dff | Ruby | santiago-rodrig/coding_challenges | /median.rb | UTF-8 | 2,295 | 4.09375 | 4 | [] | no_license | # return the median of an array of integers
# without sorting the array
def median(array)
# mutate the array until the median is right in the
# middle
partition(array)
# return the middle element of the array,
# aka the median
array[array.size / 2]
end
# quicksort algorithm until the median is found
def pa... | true |
22f2590a36c24f2b0f16c016c57a7ba67aeede24 | Ruby | ruby-vietnam/hardcore-rule | /algorithms/solutions/week21/unrealhoang/anagram.rb | UTF-8 | 400 | 3.6875 | 4 | [] | no_license | # @param {String} s
# @param {String} t
# @return {Boolean}
def is_anagram(s, t)
return false if s.length != t.length
char_count = {}
s.each_char do |c|
char_count[c] ||= 0
char_count[c] += 1
end
t.each_char do |c|
char_count[c] ||= 0
char_count[c] -= 1
if cha... | true |
29cd181756190ad1dd900fd14b1a8393a9d6ac56 | Ruby | kirkbowers/rdoc2md | /lib/rdoc2md.rb | UTF-8 | 2,455 | 3.0625 | 3 | [
"MIT"
] | permissive |
module Rdoc2md
VERSION = "0.1.1"
# Rdoc2md::Document takes a String representing a document in Rdoc format (sans leading
# hashmark comments) and converts it into a similar markdown document.
#
# Author:: Kirk Bowers (mailto:kirkbowers@yahoo.com)
# Copyright:: Copyright (c) 2014 Frabjous Apps LLC
# Li... | true |
81169bc8bdbcdb02e2717749d409239fb522dc41 | Ruby | OJFord/gitsh | /lib/gitsh/interactive_runner.rb | UTF-8 | 2,373 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | require 'gitsh/completer'
require 'gitsh/error'
require 'gitsh/history'
require 'gitsh/interpreter'
require 'gitsh/line_editor'
require 'gitsh/line_editor_history_filter'
require 'gitsh/prompter'
require 'gitsh/script_runner'
require 'gitsh/terminal'
module Gitsh
class InteractiveRunner
BLANK_LINE_REGEX = /^\s*$... | true |
b076bb659d0d434cc053b09c5f7663d1cdb43211 | Ruby | sz16900/coding-challenges | /ruby/graph_connected.rb | UTF-8 | 683 | 3.3125 | 3 | [] | no_license | def connected_graph?(graph)
stack = [0]
visited = []
current = 0
until stack.empty? do
current = stack.pop
visited.push(current)
graph[current].reverse.each {|item|
if visited.include?(item) || stack.include?(item)
else
stack.push(item)
... | true |
e488a60842783ebefe1380b5389c6033db0f3e7e | Ruby | sunny-b/Ruby_Practice | /balanced.rb | UTF-8 | 756 | 3.96875 | 4 | [] | no_license | def balanced?(str)
left_paran = str.count "("
right_paran = str.count ")"
parans = str.chars.select { |char| char.match(/[()]/) }
(left_paran == right_paran) &&
(parans.last == ')' || parans.empty?)
end
def balanced2?(str)
special_chars = 0
str.each_char do |char|
special_chars += 1 if char.match(... | true |
2587bce1e7aaf311954ea5739234a90867032056 | Ruby | thpclolou/istamemario | /exo_07.rb | UTF-8 | 83 | 3.234375 | 3 | [] | no_license | puts "entre un nombre ?"
n = gets.chomp.to_i
n = n + 1
n.times do |i|
puts i
end
| true |
069d474a0586941f48ff1f7788a22c8929050174 | Ruby | jvansch1/facebook_studying | /ruby/graphs/simple_graph.rb | UTF-8 | 867 | 3.890625 | 4 | [] | no_license | class Node
attr_accessor :value, :neighbors
def initialize(value, neighbors = [])
@value = value
@neighbors = neighbors
end
end
class Graph
def initialize(root)
@root = root
end
def print_bfs
nodes_to_visit = [@root]
while !nodes_to_visit.empty?
current_node = nodes_to_visit.s... | true |
a55cfb79b8af08e3e9b9947b1049d1df83807ce5 | Ruby | lbdrake/active-record-lite | /spec/sql_object_spec.rb | UTF-8 | 4,350 | 3.15625 | 3 | [] | no_license | require 'file_list'
require 'securerandom'
describe SQLObject do
before(:each) { DBConnection.reset }
after(:each) { DBConnection.reset }
before(:each) do
class City < SQLObject
self.finalize!
end
class Country < SQLObject
self.table_name = 'countries'
self.finalize!
end
en... | true |
70702d956d1066e2613ca94dca11826dad267e8c | Ruby | maknoll/github-cli | /lib/github-cli/client.rb | UTF-8 | 1,092 | 2.796875 | 3 | [] | no_license | require 'yaml'
require 'json'
require 'net/http'
class Github::Client
def self.open file
credentials = YAML::load_file file
self.new credentials['user'], credentials['password']
end
def initialize user, password
@user = user
@password = password
end
def create repository
response = request :post, "/u... | true |
242fa5ed3ba35c3ba549687c6af2e477d1542e04 | Ruby | GJMcGowan/takeaway-challenge | /spec/menu_spec.rb | UTF-8 | 1,158 | 3.203125 | 3 | [] | no_license | require 'menu'
describe Menu do
it 'has a hash of items that can be bought' do
expect(subject.list).to eq(Burger: 5, Pizza: 10, Coke: 1)
end
it 'can add an ordered item to a list' do
subject.add(:Burger)
expect(subject.current_order).to eq(Burger: 1)
end
it 'can add multiple ordered items to a ... | true |
d30e7463d3ace1f09ae1faf994080928e7da075f | Ruby | divyatalwar/basic_ruby | /prime/bin/main.rb | UTF-8 | 263 | 3.0625 | 3 | [] | no_license | require_relative "../lib/integer"
puts "enter the number upto which u want to find the prime number"
input_number = gets.to_i
if(input_number < 2)
puts "check number!!"
exit
end
puts "Prime Numbers upto #{input_number} \n2"
input_number.prime_numbers_till
| true |
94770d2a32d86e5adf6be86e0e5deee486cbd429 | Ruby | TeaWithStrangers/tws-on-rails | /spec/support/integration_helpers.rb | UTF-8 | 1,282 | 2.515625 | 3 | [] | no_license | module IntegrationHelpers
def sign_in(user)
visit new_user_session_path
fill_in 'user_email', with: user.email
fill_in 'user_password', with: 'password'
click_button 'Sign in'
end
def sign_out
visit profile_path
click_link 'Sign out'
end
def create_new_account
user = build(:user)... | true |
581840085798f9a235a02dbc5a7f899da5c4b296 | Ruby | richseviora/bitmaker-lesson3 | /exercise6.rb | UTF-8 | 845 | 4.09375 | 4 | [] | no_license | def print_grocery_list(grocery_list)
# Method puts each item on the list in the array order.
grocery_list.each {|item| puts "\* #{item}"}
end
# Step 1 - Initialize and Print List
grocery_list = ["carrots", "toilet paper", "apples", "salmon"]
print_grocery_list(grocery_list)
# Step 2 - Add Rice and Print Again
groce... | true |
91f5a372dd3264ce37f47cb422a8f04173ac76ee | Ruby | iliabylich/pattern_matching | /lib/pattern_matching/steps/grouper.rb | UTF-8 | 2,396 | 2.671875 | 3 | [] | no_license | class PatternMatching::Steps::Grouper < PatternMatching::Rewriter
def rewrite_body(body)
@methods = Hash.new { |h, k| h[k] = [] }
body = process_regular_node(body)
non_methods = body.to_a.reject { |node| node == s(:nil) }
grouped = @methods.map do |method_name, implementations|
SingleGroup.ne... | true |
d50d1179ef82a2362b4373d276d29a7f54f9a965 | Ruby | aWildOtto/ar-exercises | /lib/store.rb | UTF-8 | 588 | 2.671875 | 3 | [] | no_license | class Store < ActiveRecord::Base
has_many :employees
validates :name, length: {minimum: 3}
validates :annual_revenue, numericality: {only_integer:true, greater_than: 0}
validate :has_apparel
validates_associated :employees
before_destroy :check_employee
private
def has_apparel
if (!mens_apparel &&... | true |
86beebb885ac18056a89a38934f2f38bd34f9d7b | Ruby | eric1234/filtered_list | /lib/filtered_list.rb | UTF-8 | 4,997 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'cgi'
# Implements a filter dropdown that works much like Excel where all
# unique values are in the dropdown (plus a few special values). Select
# an option from the dropdown and the table will filter to show values
# that meet that criteria. See FilteredList::FilterScope for how to
# handle the controller si... | true |
0259566c289cce47826e53d6583ee14a021856f3 | Ruby | kke/opto | /lib/opto/types/boolean.rb | UTF-8 | 1,067 | 2.8125 | 3 | [] | no_license | require_relative '../type'
require_relative '../extensions/hash_string_or_symbol_key'
module Opto
module Types
class Boolean < Opto::Type
using Opto::Extension::HashStringOrSymbolKey
OPTIONS = {
min: 0,
max: nil,
truthy: ['true', 'yes', '1', 'on', 'enabled', 'enable'],
... | true |
cae9e06d475adfbcc88de559151d3b2132aac905 | Ruby | mskim/restaurant | /lib/tasks/import.rake | UTF-8 | 2,283 | 2.71875 | 3 | [] | no_license | # encoding: utf-8
require 'csv'
namespace :import do
desc ' Import area data from area.txt'
task :area => :environment do
path = File.join(Rails.root, "/public/area.txt")
count = 0
File.readlines(path).each do |row|
area = Area.create(name: row.chomp!)
puts "#{name}- #{area.errors.full_m... | true |
76f580f63eaea4412d68581877aec5f863f13854 | Ruby | tauzel/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 2,812 | 3.328125 | 3 | [] | no_license | require 'open-uri'
require 'json'
require 'set'
class GamesController < ApplicationController
def new
n_grid = 10
n_vowels = (n_grid * 3 / 6.5).to_i
n_conson = n_grid - n_vowels
grid = []
n_vowels.times { grid << "aeiouy".chars.sample.capitalize }
n_conson.times { grid << "bcdfghjklmnpqrstvw... | true |
3c5d4d39093e79dccaee27941c8b499252005961 | Ruby | calebkm/exclamation | /lib/exclamation/configuration.rb | UTF-8 | 2,359 | 2.9375 | 3 | [] | no_license | module Exclamation
class Configuration
EXCLAMATIONS = [:positives, :indifferents, :negatives, :greetings, :partings]
DEFAULT_LOCALE = :en
def initialize
yield(self) if block_given?
end
def default_locale
(@locale || DEFAULT_LOCALE).to_s
end
def default_locale=(locale)
... | true |
fd8dc37a8b22c65787bbb35ffa5e3a456d909748 | Ruby | mafelix/secondcontactlist | /pg-test.rb | UTF-8 | 407 | 3.03125 | 3 | [] | no_license | require 'pg'
puts "Connecting to the database..."
CONN = PG.connect(host: 'localhost', dbname: 'bookstore', user: 'development', password: 'development')
puts 'Finding authors...'
CONN.exec('SELECT * FROM authors;') do |results|
#results is a collection(array) of records(hashes)
results.each do |author|
puts a... | true |
60b293ff7039c117704a0f8f801437192c79642f | Ruby | Cperbony/chess-ruby | /lib/stepable.rb | UTF-8 | 353 | 2.734375 | 3 | [] | no_license | module Stepable
def available_moves
moves = []
move_dirs.each do | (dr, dc) |
current_r, current_c = location
current_r += dr
current_c += dc
loc = [current_r, current_c]
next unless board.in_bounds?(loc)
if board.empty?(loc) || enemy?(loc)
moves << loc
... | true |
3450b8433389cd220d0dba9506a6026541b9cef5 | Ruby | kapushafx/launch_academy_phase1 | /odd_numbers.rb | UTF-8 | 192 | 3.421875 | 3 | [] | no_license | #set range for vaiable to 1-100
numbers = (1..100).to_a.each do |num|
num % 2
#write expression to puts only odd numbers
if (num % 2) == 1
puts num
end
end
puts "Exiting program..."
| true |
77d821abf469c4af6a73a0a6b61e80e6ec911cf3 | Ruby | RuffWorksTech/RB101-Programming-Foundations | /small_problems/easy_1/list_of_digits.rb | UTF-8 | 898 | 4.9375 | 5 | [] | no_license | ### Write a method that takes one argument, a positive integer, and returns a list of the digits in the number.###
# Input:
# - One positive integer
# Output:
# - Array of digits in the number
# EXAMPLES:
# puts digit_list(12345) == [1, 2, 3, 4, 5] # => true
# puts digit_list(7) == [7] # => t... | true |
537b03ea223fd6734564470d573225482eb1469f | Ruby | graydot/slideshare-ardrone-leapmotion | /lib/hand.rb | UTF-8 | 2,393 | 2.546875 | 3 | [] | no_license | class Hand
#<Artoo::Drivers::Leapmotion::Hand:0x007fd02d099b38
# @direction=[-0.0747336, 0.292273, -0.953411],
# @id=66,
# @palmNormal=[-0.821592, -0.559899, -0.107239],
# @palmPosition=[-246.876, 441.797, 193.875],
# @palmVelocity=[-369.385, 384.866, -718.654], @r=[[0.984894, 0.0351469, 0.169556], [-0... | true |
de45a41f48a29b137761366797dcaf0789c34bc8 | Ruby | thebluber/huffman | /spec/huffman_spec.rb | UTF-8 | 3,274 | 3.125 | 3 | [] | no_license | require 'spec_helper'
describe Node do
before do
@node1 = Node.new('', 10)
@node2 = Node.new('', 2, 1)
@node3 = Node.new('', 2, 2)
@node4 = Node.new('', 3, 3)
@node5 = Node.new('', 3)
@tree = Node.new('', 5, 2, Node.new('a', 3), Node.new('', 4, 1, Node.new('b', 1), Node.new('c', 1)))
end
... | true |
54b9ad3d247a806e5c547a7d1927e2011d682a57 | Ruby | adrem7/simple_checkout | /lib/item.rb | UTF-8 | 181 | 3.6875 | 4 | [] | no_license | class Item
attr_reader :name, :price
def initialize(name, price)
@name = name
@price = price
end
def check_price
puts "Price: £%.2f" % @price.to_s
end
end
| true |
2f8eac1788492f81b21e516cccc9ac15a32ea383 | Ruby | rickymclaren/projecteuler | /01.rb | UTF-8 | 170 | 3.625 | 4 | [] | no_license | #! /usr/bin/ruby
# Find the sum of all numbers from 1 to 999 that are multiples of 3 or 5
puts (1..999).select {|i| i % 3 == 0 || i % 5 == 0}.reduce {|sum, x| sum + x }
| true |
d78300c76c6499019c89b39234566206caa7df68 | Ruby | entcheva/04_object_relations_lecture_web-1116 | /private_methods.rb | UTF-8 | 320 | 3.21875 | 3 | [] | no_license | class User
attr_writer :password
def authenticate(password_try)
password == password_try
end
private
def password
puts 'Calling the password method'
@password
end
end
user = User.new
user.password = 'fido'
user.authenticate('fidoasdf') #=> false
user.password # will throw an error
| true |
3169d4d85cb9bc12de559a3c91dbdba75d5557a2 | Ruby | r-glebov/pragstudio_mastering_blocks | /songs.rb | UTF-8 | 2,453 | 3.671875 | 4 | [] | no_license | require_relative 'my_enumerable'
class Song
attr_reader :name, :artist, :duration
def initialize(name, artist, duration)
@name = name
@artist = artist
@duration = duration
end
def play
puts "Playing '#{name}' by #{artist} (#{duration} mins)..."
end
def each_filename
ba... | true |
fdda5817960a904576e8f6ae35f65d9393c3ca95 | Ruby | stacyvlasits/ocill | /app/models/exercise.rb | UTF-8 | 4,481 | 2.53125 | 3 | [
"MIT"
] | permissive | class Exercise < ActiveRecord::Base
include Comparable
mount_uploader :audio, AudioUploader
mount_uploader :image, ImageUploader
attr_accessible :prompt, :title, :fill_in_the_blank, :position, :drill_id, :weight, :exercise_items_attributes, :audio, :image, :video, :remove_audio, :remove_image, :remove_video, :p... | true |
53a94016531a92b05bcc61c715e52ccd15b717e4 | Ruby | jmarbach/redshift-client | /lib/redshift/client/configuration.rb | UTF-8 | 1,568 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'uri'
require 'cgi'
require 'active_support/core_ext/hash/reverse_merge'
module Redshift
module Client
class Configuration
attr_reader :host, :port, :user, :password, :dbname
DEFAULT_SSL_MODE = 'allow'.freeze
class << self
def resolve(config = {})
config.reverse_merg... | true |
0188e8df9863bd2919161e288bac553407ffe594 | Ruby | mennamorato/ttt-10-current-player-q-000 | /lib/current_player.rb | UTF-8 | 352 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # find out how many turns have been played
# by counting the number of "X" or "O" spaces on the board
def turn_count(board)
counter = 0
board.each {|char|
if char == "O" || char == "X"
counter += 1
end
}
return counter
end
# determine the current player
def current_player(board)
return turn_cou... | true |
293be730b27d5bd58c88fb073eaefadd991330df | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/prime-factors/2d78374175e944afb01c7edab4b0d753.rb | UTF-8 | 679 | 3.484375 | 3 | [] | no_license | require 'prime'
# class PrimeFactors
# SORRY this soesnt work as expected. please dont review it
class PrimeFactors
def self.for(n)
op = []
Prime.take_while {|p| p <= Math.sqrt(n) }.each{|e| (op << e; op << PrimeFactors.for(n/e)) if n%e == 0}
op.compact.flatten
end
# def self.for(n)
# n1 = n... | true |
10af42d63e87b1a6b2b587e648598a87c897f8b4 | Ruby | MichaelBone/salisbury | /scraper.rb | UTF-8 | 3,817 | 2.640625 | 3 | [] | no_license | require 'scraperwiki'
require 'mechanize'
base_url = "https://eservices.salisbury.sa.gov.au/ePathway/Production/Web"
comment_url = "mailto:city@salisbury.sa.gov.au"
agent = Mechanize.new
puts "Retrieving the default page."
default_url = "#{base_url}/default.aspx"
default_page = agent.get(default_url)
default_page = ... | true |
ea4489a44a4aa247ebd96b65117044b818eb555f | Ruby | ezgiyuksektepe/gladiatorgame | /Arena.rb | UTF-8 | 536 | 3.0625 | 3 | [] | no_license | require_relative "Gladiator"
class Arena
attr_accessor :rivalGladiator, :isAlive
def initialize
raise NotImplementedError
end
def play(gladiator)
battle(gladiator)
question(gladiator)
speed(gladiator)
end
def battle(gladiator)
raise NotImplementedError
end
def question(gladiator)
... | true |
0c0ce435ea995ff733ab8c38f67907d4261effa6 | Ruby | Michael-Gr/CodeKatas | /Grasshopper_Basic_Function_Fixer.rb | UTF-8 | 460 | 3.578125 | 4 | [] | no_license | #################
# Link to kata: #
#################
#
# https://www.codewars.com/kata/56200d610758762fb0000002
#
################
# Description: #
################
#
# Fix the function
#
# I created this function to add five to any number that was passed in to it and return the new value. It doesn't throw any errors ... | true |
9a6b2fd955fbb8f5c345316f331446712f1d1388 | Ruby | JaBurd/ruby_learn | /variables.rb | UTF-8 | 268 | 3.140625 | 3 | [
"Unlicense"
] | permissive | localvar = "hello"
$globalvar = "goodbye"
def amethod
localvar = 10
puts( localvar )
puts( $globalvar )
end
def anothermethod
localvar = 500
$globalvar = "bonjour"
puts( localvar )
puts( $globalvar )
end
amethod
anothermethod
amethod
puts( localvar )
| true |
cb95ff871f576a6085e8cc9080286ca10eba2fe7 | Ruby | mclarkef90/ruby-objects-has-many-lab-onl01-seng-ft-041320 | /lib/song.rb | UTF-8 | 556 | 3.375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #should belong to artist,
#have reference to that artist,
#needs #class variable thath olds all instatnces of every song that's been created in an array,
#to access that array needs a #class method (self) that returns the class variable holding those instances
class Song
attr_accessor :artist, :name
@@all = [... | true |
5ff04b82eff258c5cd2abea06a2eaf073e98cde6 | Ruby | boof/not-naughty | /lib/not_naughty/instance_methods.rb | UTF-8 | 372 | 2.640625 | 3 | [
"MIT"
] | permissive | module NotNaughty
module InstanceMethods
# Returns instance of Errors.
def errors() @errors ||= ::NotNaughty::Violation.new end
# Returns true if all validations passed
def valid?
validate
errors.empty?
end
# Clears errors and validates.
def validate
errors.clear
... | true |
9e8272e9c4b4d8f848408039ecc064e2a5fe1aa7 | Ruby | Xrixcis/eld-dip | /lib/exporter.rb | UTF-8 | 1,659 | 3.09375 | 3 | [] | no_license | require_relative 'spreadsheet_writer'
require 'sqlite3'
class Exporter
def initialize(sum_result_file, unit_results_dir, headers, formulas, sheet2 = nil)
@sum_file = sum_result_file
@unit_dir = unit_results_dir
@headers = headers
@formulas = formulas
@sheet2 = sheet2
@sum_writer = Spreadsh... | true |
97d04655ff76c7d6f5c50098ac2cfa61e9406902 | Ruby | douglasdoro/app-todo | /app.rb | UTF-8 | 1,364 | 2.5625 | 3 | [] | no_license | require "sinatra"
require 'sequel'
Sequel.connect(ENV['DATABASE_URL'] || 'sqlite://db/tasks.sqlite3')
class Task < Sequel::Model
end
get('/login') {erb :login}
get('/') {erb :index}
get '/tasks' do
@tasks = Task.all
erb :tasks, :layout => false
end
get '/tasks_complete' do
@tasks = Task.where(:comp... | true |
888366020e7259443f869d59e1519a50160b5b22 | Ruby | plus2/common_mob | /targets/user.rb | UTF-8 | 2,026 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'common_mob'
require 'etc'
class User < AngryMob::Target
include CommonMob::ShellHelper
default_action
def ensure
if before_state[:exists] then update else create end
unless state[:exists]
raise "unable to create user #{default_object}"
end
end
def create
opt_string = opts
... | true |
5631b91ed86cb07b8bbdf65755391b217173b626 | Ruby | DavidOKeefe/ruby_exercises | /CoderByte/palindrome.rb | UTF-8 | 77 | 3.03125 | 3 | [] | no_license | def palindrome(str)
str.gsub(/\s+/, "") == str.gsub(/\s+/, "").reverse
end
| true |
efefce63c16b2570da19fbe5cbe3e87f8b72ab51 | Ruby | sawaezamin/flash_cards | /flashcard_runner.rb | UTF-8 | 1,175 | 4.03125 | 4 | [] | no_license | require './lib/card'
require './lib/turn'
require './lib/deck'
require './lib/round'
card_1 = Card.new("What is 5 + 5?", "10", :STEM)
card_2 = Card.new("What is Rachel's favorite animal?", "koala", :turing_staff)
card_3 = Card.new("What is Mike's middle name?", "nobody knows", :turing_staff)
card_4 = Card.new("What ca... | true |
21b1cf65cdcb7dbe37a3c5b7f2b0a955103633c3 | Ruby | sydra08/my-each-v-000 | /my_each.rb | UTF-8 | 273 | 3 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # first attempt 6/14/17
# def my_each(arr)
# i = 0
# while i < arr.length
# yield(arr[i])
# i += 1
# end
# arr
# end
#second attempt 7/2/17
def my_each(array)
i = 0
while i < array.length
yield(array[i])
array[i]
i += 1
end
array
end | true |
ca7f7a6cbf390773fda8af76645a1be4f536d1c2 | Ruby | esrosn/designer-news-lambda | /lambda_function.rb | UTF-8 | 1,083 | 2.609375 | 3 | [] | no_license | require 'json'
require 'twitter'
require 'httparty'
require 'nokogiri'
def lambda_handler(event:, context:)
twitter = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['CONSUMER_KEY']
config.consumer_secret = ENV['CONSUMER_SECRET']
config.access_token = ENV['ACCESS_TOKEN']
... | true |
aa58792bd7a93077817c8697132634e3a260f9f7 | Ruby | bharatagarwal/launch-school | /100_back-end_prep/intro-to-programming/3_methods/4.rb | UTF-8 | 151 | 3.65625 | 4 | [] | no_license | # won't print anything, because
# the return sends back nil.
def scream(words)
words = words + "!!!!"
return
puts words
end
scream("Yippeee")
| true |
ed725b72264f3ed2d2cdccfd6b047fbacbb38070 | Ruby | ewa-j/oystercard | /spec/oystercard_spec.rb | UTF-8 | 1,447 | 3.15625 | 3 | [] | no_license | require 'oystercard'
require 'journey'
describe Oystercard do
let(:entry_station) { double Journey, :entry_station }
let(:exit_station) { double Journey, :exit_station }
let(:journey) { Journey.new }
it "has balance of 0 by default" do
expect(subject.balance).to eq 0
end
it "can top up" do
su... | true |
cd673d3b23071dabfcc28a16397f2aa1f0d8c461 | Ruby | noahg957/tic-tac-toe | /lib/player.rb | UTF-8 | 138 | 2.84375 | 3 | [] | no_license | # ruby player.rb
class Player
def initialize(name)
@name = name
@token = 0
end
attr_accessor :token
attr_reader :name
end | true |
dd01d2ab4510aa8fa64e9d426a006b8431023e5a | Ruby | friendtu/ruby_hard_way | /39.rb | UTF-8 | 746 | 3.453125 | 3 | [] | no_license | require './dict.rb'
states=Dict.new(256,"Doesn't exist")
states.set('Oregon','OR')
states.set('Florida','FL')
states.set('California','CA')
states.set('New York','NY')
states.set('Michigan','MI')
cities=Dict.new(256,"Doesn't exist")
cities.set('CA','San Francisco')
cities.set('MI','Detroit')
cities.set('FL','Jacksonv... | true |
3db66fa010572497e96917dd9cda99d3dcea0dea | Ruby | emalfano/ls_exercises | /ruby_basics/loops/l1_7.rb | UTF-8 | 81 | 2.984375 | 3 | [] | no_license | # count up from 1 to 10
count = 1
until count > 10
puts count
count += 1
end | true |
6516c8e16e9cd6f974a93136d18d77a5b85b9a8b | Ruby | pj0616/download-archive-2 | /CONTAINER/App-Academy-master/Intro To Programming/Array Methods/first_in_array.rb | UTF-8 | 589 | 4.78125 | 5 | [] | no_license | # Write a method first_in_array that takes in an array and two
# elements, the method should return the element that appears earlier in the array.
# def first_in_array(arr, ele1, ele2)
# arr.each_with_index do |element, idx|
# if element == ele1 || element == ele2
# return arr[idx]
# end
# end
# end
... | true |
48e26769eab819869d4926f97725746e733a500b | Ruby | PigAndChicken/WiKey_APP | /application/services/check_topic.rb | UTF-8 | 1,007 | 2.8125 | 3 | [] | no_license | require 'dry/transaction'
module WiKey
# check if topic loaded or not, if not loaded yet, load it from api
class CheckTopic
include Dry::Transaction
step :check_if_valid
step :check_if_exists
step :create_topic
def check_if_valid(topic_input)
if topic_input.errors[:topic].nil?
R... | true |
b4d2a5ed35c9f2e9927a7a1452ad03b3ee31f3db | Ruby | Dr-D-M/ruby_activities | /branchifelse.rb | UTF-8 | 241 | 3.640625 | 4 | [] | no_license | puts 'I am a fortune-teller. Tell me your name:'
name = gets.chomp
if name == 'Gabriela'
puts 'I see great things in your future'
else
puts 'Your future is... Oh my! Look! Ahm...'
puts 'Man, you are fucked already, I gotta go, sorry'
end | true |
e862c64374937ef09bc971630cea64bea9c4c2b6 | Ruby | jcouyang/cats.rb | /spec/data.either_spec.rb | UTF-8 | 2,657 | 3.25 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'data.either'
describe Either do
it '#map' do
expect(Right.new(1).map { |x| x + 1 }).to eq(Right.new(2))
expect(Right.new(1).fmap { |x| x + 1 }).to eq(Right.new(2))
expect(Left.new('hehe').map { |x| x + 1 }).to eq(Left.new('hehe'))
end
it '#left_map' do
expect(Right.... | true |
ae0d057c7f499cfcc9d1b60e0a044cde0bda0613 | Ruby | OkayDave/barr | /lib/barr/blocks/separator.rb | UTF-8 | 248 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'barr/block'
module Barr
module Blocks
class Separator < Block
def initialize(opts = {})
super
@symbol = opts[:symbol] || '|'
end
def update!
@output = @symbol
end
end
end
end
| true |
5f40fa54f7e3b61a7ce492261e9c90a50a785d40 | Ruby | codesicario/launch-school-101 | /pseudo_code.rb | UTF-8 | 1,432 | 4.65625 | 5 | [] | no_license | #Problem 1
# a method that returns the sum of two integers
# ask for user to input two integers
# set value of input in two different variables
# return sum of variables
#START
# ask user to input two integers
# GET user input
# SET num1 = first user input
# SET num2 = second user input
#PRINT "The sum of your num... | true |
264a38d375ed38bbe3b501497060f362fc747f57 | Ruby | upadhyay-ashish/motion-addressbook | /spec/address_book/multi_valued_spec.rb | UTF-8 | 1,852 | 2.546875 | 3 | [
"MIT"
] | permissive | describe AddressBook::MultiValued do
describe 'a string multi-value' do
before do
@attributes = [
{
:label => 'home page',
:value => "http://www.mysite.com/"
}, {
:label => 'work',
:value => 'http://dept.bigco.com/'
}, {
:label => 'sc... | true |
dbff0adb6bf5b984b920c4ab46e5e3b349d9ac7c | Ruby | blevm/OO-mini-project-nyc-web-042318 | /app/models/User.rb | UTF-8 | 1,468 | 3.078125 | 3 | [] | no_license | class User
attr_accessor :name
ALL = []
def initialize(name)
@name = name
ALL << self
end
def recipes
RecipeCard.all.select do |recipecard|
recipecard.user == self
end
end
def just_recipes
self.recipes.map do |recipecard|
recipecard.recipe
end
end
def add_recip... | true |
7e7329249ca08bb028844cb9b6141819f81520c6 | Ruby | MisterDeejay/Poker | /spec/spec_poker.rb | UTF-8 | 10,551 | 3.359375 | 3 | [] | no_license | require 'rspec'
require 'card'
require 'deck'
require 'hand'
require 'player'
require 'game'
describe "Card" do
it "creates a card correctly" do
card = Card.new(:hearts, :two)
expect(card.suit).to eq(:hearts)
expect(card.value).to eq(:two)
end
end
describe "Deck" do
let(:deck) { Deck.new }
it "ini... | true |
52acf78d6c99397135318ad4c9ec31193b7f66d1 | Ruby | projectivetech/sidekiq-repeat | /test/mini_ice_cube.rb | UTF-8 | 1,309 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'sidekiq/repeat/mini_ice_cube'
class TestMiniIceCube < MiniTest::Unit::TestCase
def setup
@dsl = Sidekiq::Repeat::MiniIceCube::MainDsl.new
end
def parse(&block)
@dsl.instance_eval(&block).to_s
end
def assert_valid_series(max, interval, s)
parts = s.split(',').... | true |
942d20bcedb7ed35ce77932ce91c63cd2338abdf | Ruby | sh84/filecluster | /lib/manage/schema.rb | UTF-8 | 3,249 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'psych'
def schema_create
unless ARGV[2]
puts 'config file not set'
exit(1)
end
force = ARGV[3].to_s == 'force'
schema = load_schema_file
apply_connection(schema[:connection])
# check existing objects
unless force
errors = ''
schema[:storages].each do |cs|
errors << "Storage... | true |
32c6635d61d1a7458a5faa07d6d5f2812beeb3e1 | Ruby | nlauer/FoodMe | /FoodMeRuby/OrdrInUtils.rb | UTF-8 | 2,665 | 3 | 3 | [] | no_license | require "ordrin"
class OrdrInUtils
@@address = Ordrin::Data::Address.new('1 Main Street', 'College Station', 'TX', '77840', '(555) 555-5555')
def initialize(login, key)
@login = login
@api = key
end
public
def randoOrder(price, restaurant)
items ||= []
counter = ... | true |
5fdcd4bbf31511d7a3d9df5035ae792c6ac7b91f | Ruby | Jusixo/test_files | /artoo.rb | UTF-8 | 838 | 2.703125 | 3 | [] | no_license |
require 'artoo'
connection :ardrone, :adaptor => :ardrone
device :drone, :driver => :ardrone, :connection => :ardrone
connection :navigation, :adaptor => :ardrone_navigation, :port => '192.168.1.1:5554'
device :nav, :driver => :ardrone_navigation, :connection => :navigation
work do
on drone, :ready => :fly
dron... | true |
41f3f79069b1dddc6200c229d26134c204eb028a | Ruby | niquepa/snetworks | /app/services/client_api_service.rb | UTF-8 | 569 | 2.53125 | 3 | [] | no_license | require 'faraday'
class ClientApiService
TIMEOUT = 2
def initialize(url:)
@conn = Faraday.new(
url: url,
headers: {'Content-Type' => 'application/json'},
)
@conn.options.timeout = TIMEOUT
end
def get(endpoint:)
begin
response = @conn.get endpoint
JSON.parse(response.b... | true |
cac5bc35a844b2ed084d80d1d958536352c690b0 | Ruby | MiraitSystems/enju_trunk | /lib/enju_trunk/date_helper.rb | UTF-8 | 4,929 | 2.671875 | 3 | [
"MIT"
] | permissive | #-*- encoding: utf-8 -*-
class Date
def self.enju_wareki2yyyy(gengou, yy)
return nil unless Wareki::GENGOUS.key?(gengou)
if yy.class == String
yyi = yy.to_i
else
yyi = yy
end
return (Wareki::GENGOUS[gengou].from[0..3].to_i) - 1 + yyi
end
def self.enju_generate_merge_range(pub_dat... | true |
15a8fb0ca6ef5304fb3c6544888447e8522c626c | Ruby | srijondasgit/drawstories | /cbse/class8/Science/chapter1.rake | UTF-8 | 4,378 | 2.953125 | 3 | [] | no_license |
desc "TODO"
task chappter_one: :environment do
# Chappter.delete_all
# Book.delete_all
# Section.delete_all
# Question.delete_all
book = Book.new(school_id: 1, name: 'Book', author: 'Unnamed', book_type: 'General')
if book.save
chappter = Chappter.create(book_id: book.try(:... | true |
85c61f73e6c935a343144cea2ee83f9c528bc969 | Ruby | Uchoosecode/prime-ruby-online-web-ft-120919 | /prime.rb | UTF-8 | 166 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'prime'
def prime?(num)
if Prime.prime?(num) == true
true
else
false
end
end
# (2..(num - 1)).none? do |n|
# num % n == 0
# end | true |
f4ed13ac7f5a22fb0855a31b1dafac5439e92818 | Ruby | jeslyvarghese/sigFree | /test/test.rb | UTF-8 | 416 | 2.96875 | 3 | [] | no_license | require 'open-uri'
test_rounds = 10
test_count = 0
o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
while test_count<=test_rounds do
string = (0..50).map{ o[rand(o.length)] }.join;
url = "http://localhost:9060/#{string}"
test_count+=1
puts "Test: \##{test_count}"
puts "GET String: #{string}"
begin
... | true |
5598214da176372018c9871ed464f433afb25145 | Ruby | eggyy1224/launch_school_more_ruby | /lesson2/130practice/challenge/octal.rb | UTF-8 | 247 | 3.671875 | 4 | [] | no_license | require 'pry'
class Octal
def initialize(number)
@number = number
end
def to_decimal
@number.split('').reverse.map.with_index do |ele, index|
return 0 if ele =~ /[8-9\D]/
ele.to_i * 8**index
end.reduce(:+)
end
end | true |
1f7232595ffe2f26cf15abb86a78bd31a894f9f5 | Ruby | lcowell/railsjam_ruby_examples | /part3_control_structures/3_case.rb | UTF-8 | 101 | 2.78125 | 3 | [] | no_license | blah = "apple"
case blah
when "apple"
puts "we have an apple"
when "brussel sprouts"
puts "not yummy"
end | true |
ae5f38eabb4d83accf5a12dd8dd7955bd265358e | Ruby | one-hole/hydra | /app/models/users/user.rb | UTF-8 | 780 | 2.609375 | 3 | [] | no_license | # 用户模型。这里特指我们的「刷单商家」
=begin
phone
password
has_one account
用户应该有城市 - 同城匹配使用
用户可以创建 充值订单 - ChargeOrder
用户可以抢单 抢单订单 - RushOrder
=end
class User < ApplicationRecord
has_secure_password
has_one :account
has_one :profile
has_many :charge_orders
has_many :rush_orders
before_create do
ge... | true |
674603964e7d3c0aa500ca823940404ff5d32567 | Ruby | esbaddeley/learn_to_program | /ch14-blocks-and-procs/grandfather_clock.rb | UTF-8 | 459 | 3 | 3 | [] | no_license | # This works but doesn't pass the Rspec
# def grandfather_clock &block
# hour = Time.new.hour
#
# if hour = 0
# (hour+12).times {block.call}
# elsif hour <= 12
# hour.times {block.call}
# elsif hour > 12
# (hour-12).times {block.call}
# end
# end
def grandfather_clock &block
hour = Time.new.hou... | true |
c4648034465f8cb67caf98519192e543fb9890eb | Ruby | zdsmit/reverse-each-word-online-web-sp-000 | /reverse_each_word.rb | UTF-8 | 153 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
stringA = string.split()
stringA.collect do |word|
word.reverse!
end
stringB = stringA.join(" ")
stringB
end
| true |
e6d7c913c4635c7445222cd5378fd56e3635668f | Ruby | BohanHsu/leetcode2 | /test/palindrome_linked_list_test.rb | UTF-8 | 2,154 | 3.203125 | 3 | [] | no_license | require 'minitest/autorun'
require '../palindrome_linked_list'
describe 'is_palindrome(head)' do
it 'should work1' do
array = [1,2,3,4,5,4,3,2,1]
head = convert_array_to_list(array)
expected_result = true
is_palindrome(head).must_equal(expected_result)
convert_list_to_array(head).must_equal(array... | true |
ceb0acf1c5ecbec2dc6a140b5f15e366487df574 | Ruby | helgasty/little_game | /lib/monster.rb | UTF-8 | 1,065 | 3.703125 | 4 | [] | no_license | class Monster
attr_accessor :life, :power, :name
MONSTERS = %w{ zombie ghost goul vampire troll skeleton werewolf dragon demon }
def initialize(args = {})
@is_boss = args[:is_boss]
@life = (@is_boss) ? 30 : 10
@name = (@is_boss) ? 'Cthulhu' : MONSTERS.sample
@power = (@is_boss) ? 8 : 3
end
... | true |
92e0578d628f192bf3aab286f26a53bfcbb48a84 | Ruby | DrSlowpokePhd/Ruby-Behavior-Tree | /lib/behavior_tree/tasks/nop.rb | UTF-8 | 914 | 2.921875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative './task_base'
module BehaviorTree
# An empty task that does not do anything.
# It requires N ticks to complete.
# It can be set to end with failure.
class Nop < TaskBase
def initialize(necessary_ticks = 1, completes_with_failure: false)
raise ArgumentEr... | true |
fb71dae20846c71f85f1283bbe643336167c064b | Ruby | jvansch1/Data-Structures-Ruby | /CamelCase/camel_case.rb | UTF-8 | 750 | 3.984375 | 4 | [] | no_license | # Break up a camelcase word into array and return length
s = gets.strip
#start index is the beginning of current_word, it will be reset when a uppercase letter is found
#ending index will be used to determine the length of current word
start_index = 0
ending_index = 0
word_array = []
# ending index will be our itera... | true |
e9f2a1c986d1112b97a9a832343d7fd76b149add | Ruby | kinsbrunner/challenges | /codility/OddOccurrencesInArray.rb | UTF-8 | 372 | 3.296875 | 3 | [] | no_license | require 'minitest/autorun'
class Array
def self.odd_occurences(a)
h = {}
a.each do |num|
h[num] = 0 if !h.key?(num)
h[num] += 1
end
h.each{ |key, val|
return key if val % 2 != 0
}
end
end
class TestOddOccurences < Minitest::Test
def test_zero_elems
assert_equal( Array.... | true |
f1331917a619f9c4e097cdaa19f13ea3ca5d9ac7 | Ruby | yuringn/walk_talk_backend | /app/models/hike.rb | UTF-8 | 350 | 2.859375 | 3 | [] | no_license | class Hike < ApplicationRecord
has_many :reviews
has_many :users, through: :reviews
def averagerating
average = self.reviews.map{|hike| hike.rating}
# byebug
if average.length > 0
(average.sum.to_f / average.length).round()
else
puts "sorry, no ra... | true |
099738df53f9940e156220c8afe4d423f4bc5ddd | Ruby | elainapolson/pass-by-reference-web-0615-public | /lib/pass_by_reference.rb | UTF-8 | 184 | 2.875 | 3 | [] | no_license | def add_instructor(instructors, students)
instructors << students
end
def be_friends_with(array, string)
new_arr = []
new_arr << array
return (new_arr << string).flatten
end | true |
112d06f4aca58b65b801fe4cd2f0c8eaffba236b | Ruby | traciemasek/Has-Many-Through-Template-nyc-web-080519 | /lib/Model1.rb | UTF-8 | 1,280 | 3.609375 | 4 | [] | no_license | require 'pry'
#class for Model1 goes here
#Feel free to change the name of the class
class Person
attr_accessor :name, :address
@@all = []
def initialize(name, address)
@name = name
@address = address
@@all << self #can also write as self.class.all << self
end
def self.all
@@all
end
... | true |
b52dd603e1c1a81fb90c69269ea5253d452f417b | Ruby | whyderrick/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 3,440 | 4.15625 | 4 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# take the name of an item we are adding to our list
# set default quantity
# print the list to the console [can you use one of your other methods here?]
# output: each key in the hash
# Metho... | true |
8db425d328bdf139e9744d675d3a547e6012a836 | Ruby | tzedakah/guestbook | /app/models/person.rb | UTF-8 | 5,435 | 3.359375 | 3 | [] | no_license | class Person < ActiveRecord::Base
attr_accessible :birthday, :body_temperature, :can_send_email, :country,
:description, :email, :favorite_time, :graduation_year, :name, :price,
:secret, :photo
# the name is mandatory
validates_presence_of :name
# secret is also mandatory, but let's alter the default Rails ... | true |
40e7489f2e953b98debc5dfdbb2ae1bfba76e1eb | Ruby | DylanAndrews/hackerrank | /30_day_challenge_leet/move_zeros.rb | UTF-8 | 262 | 3.515625 | 4 | [] | no_license | require 'pry'
def move_zeroes(nums)
length = nums.length
zeros = nums.reject! { |num| num == 0 }
new_length = nums.length
counter = 0
while counter < length - new_length
nums << 0
counter += 1
end
nums
end
puts move_zeroes([0,1,0,3,12])
| true |
794712d827078af3d7bce4ce56b6a8bfb88608de | Ruby | Adong520/EulerRuby | /problem_1.rb | UTF-8 | 158 | 3.265625 | 3 | [] | no_license |
x=1
i=0
num = []
while x<1000
if (x%3==0 || x%5==0)
num[i]=x
i +=1
end
x +=1
end
total = 0
num.each do |x|
total += x
end
puts total
| true |
f3e5de4b1c25ba7fc0cb1dc3b7537f5cb9795b59 | Ruby | fagan2888/namey | /lib/namey/parser.rb | UTF-8 | 2,897 | 3.28125 | 3 | [
"MIT"
] | permissive | require 'sequel'
require 'open-uri'
module Namey
#
# parse the census bureau data files and load into our datasource
#
class Parser
attr_accessor :db
#
# initialize the parser
# dbname - Sequel style db URI ex: 'sqlite://foo.db'
#
def initialize(dbname = Namey.db_path)
... | true |
8a157fcd9caea9e265bf314f34c2d944a484dac9 | Ruby | taoliu12/ttt-10-current-player-cb-000 | /lib/current_player.rb | UTF-8 | 180 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
i = 0
board.each do |item|
i += 1 if item == 'X' || item == 'O'
end
i
end
def current_player(board)
turn_count(board) % 2 == 0 ? 'X' : 'O'
end
| true |
4cd64d30f5377dc33b40a6920b1d29a929bb6a30 | Ruby | zhjch05/nosql-databases | /redis/homework_1.rb | UTF-8 | 408 | 2.984375 | 3 | [] | no_license | # Require the httparty gem
require 'httparty'
# Set up the url and send a GET request to it. The base url is:
# "https://api.nasa.gov/planetary/apod?api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo"
response = HTTParty.get('https://api.nasa.gov/planetary/apod?api_key=IJRWOz0xpNNtJT40JUKsoCq9wtcbyhIRhzMpzo0M&', date: "... | true |
91966543d2e97f7a4c8e7a1128d494128f1f17c5 | Ruby | nitinkumar24/Social-media-app | /app/models/mention.rb | UTF-8 | 3,998 | 2.703125 | 3 | [] | no_license | class Mention
attr_reader :mentionable
include Rails.application.routes.url_helpers
def self.create_from_text(object) #object can be post ,comment or reply
if check_annonymous_post(object)
puts object
current_user = object.user
@current_mode = cur... | true |
52f011d6d87c034751c793801ec8ee052659914e | Ruby | catherinemdean15/day_hike | /app/models/trip.rb | UTF-8 | 334 | 2.640625 | 3 | [] | no_license | class Trip < ApplicationRecord
has_many :trail_trips
has_many :trails, through: :trail_trips
def average_distance
trails.average(:length).to_f
end
def longest_trail
trails.order(:length).last
end
def shortest_trail
trails.order(:length).first
end
def total_length
trails.sum(:length... | true |
d1173784f925f5cb44bccee821d47a1e95aed66e | Ruby | globaldev/octarine | /lib/octarine/simple_http.rb | UTF-8 | 2,991 | 2.9375 | 3 | [
"MIT"
] | permissive | require "net/http"
module Octarine # :nodoc:
# SimpleHTTP is a bare-bones implementation of a simple http client, designed
# to be easily replaceable with another implementation.
#
class SimpleHTTP
Response = Struct.new(:status, :headers, :body)
# :call-seq: SimpleHTTP.new(url, options={}) -> ... | true |
d546aa20bef6a82b88325e0cf852641c0487b6f2 | Ruby | abhiramesh/meetup_parser | /meetup.rb | UTF-8 | 1,187 | 3.078125 | 3 | [] | no_license | # Required Ruby Libraries for Parsing #
require 'csv'
require 'json'
require 'net/http'
# Intialize an Array of the JSON Queries #
query = ['http://api.meetup.com/groups.json/?&topic=deals-and-bargins&order=members&key=781515511760134362715d533e4e65', 'http://api.meetup.com/groups.json/?&topic=deals-and-bargins&ord... | true |
b935ed37808a02c091af81d6afb4783895899900 | Ruby | paulodfreitas/ruby86 | /pipeline/Instructions/mr_movl.rb | UTF-8 | 486 | 2.703125 | 3 | [] | no_license | class MRmovl < Instruction
def self.has_ra
true
end
def self.has_rb
true
end
def self.has_val
true
end
def fetch r
r = super(r)
r[:rb], r[:ra] = r[:ra], r[:rb]
return r
end
def op(va, vb, vc)
va + vc
end
def memory r
r[:vm] = processor.memory[r[:ve]]
return... | true |
47f5ad21f76f2db7b97f6bdd0dcc1e5f582ce085 | Ruby | omelinb/shop | /db/seeds.rb | UTF-8 | 217 | 2.71875 | 3 | [] | no_license | Product.delete_all
names = %w[First Second Third Fourth]
names.each do |name|
Product.create(
name: "#{name} product",
description: "Description of our #{name} product",
price: rand(5.00..50.00)
)
end
| true |
9ded26f3f233639da7d9007360e341bac9bceb74 | Ruby | maxximus87/minedmindscata | /array_funcTEST.rb | UTF-8 | 544 | 3 | 3 | [] | no_license | require "minitest/autorun"
require_relative "array_func.rb"
class TestArrayFunction <Minitest::Test
def test_array_with_100_element
results = array_mined_minds
assert_equal(100, results.length)
end
def test_3_returns_mined
results = array_mined_minds
assert_equal("mined" , results [2])
end
d... | true |
ff1af047d4e391abb74ae6b9fd7b364421efa97b | Ruby | shubhscoder/twitterAPI | /app/controllers/tweets_controller.rb | UTF-8 | 1,631 | 2.515625 | 3 | [] | no_license | class TweetsController < ApplicationController
def new
@tweet = Tweet.new
end
def create
@tweet = Tweet.new(permitted_params)
if @tweet.save
current_user.increment!(:number_of_tweets)
@tweet.update(:user_id => current_user.id)
render :json => { status: "Ok", message: "Tweeted Successfu... | true |
14674fd3ecbe19578eda9d7c659f794b24421b63 | Ruby | takuti/twitter-bot | /lib/twitter_bot/tweet_generator.rb | UTF-8 | 1,025 | 2.75 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require 'kusari'
require 'open-uri'
require 'json'
require 'csv'
require_relative 'tweet'
module TwitterBot
class TweetGenerator
def initialize
@root = File.expand_path('../../../', __FILE__)
@generator = Kusari::Generator.new(3, "#{@root}/ipadic")
create_markov if @generator.... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.