text stringlengths 10 2.61M |
|---|
class ImageCropper
def self.enabled?
Danbooru.config.aws_sqs_cropper_url.present?
end
def self.notify(post)
if post.is_image?
sqs = SqsService.new(Danbooru.config.aws_sqs_cropper_url)
sqs.send_message("#{post.id},https://#{Danbooru.config.hostname}/data/#{post.md5}.#{post.file_ext}")
end
... |
module ApplicationHelper
# Возвращает полный заголовок зависящий от страницы # Документирующий комментарий
def full_title(page_title) # Определение метода
base_title = "Галант | Установка винеонаблюдения и
видеодомофонов" # Назначение переменной
... |
class RecordpnyttsController < ApplicationController
before_action :set_recordpnytt, only: [:show, :edit, :update, :destroy]
# GET /recordpnytts
# GET /recordpnytts.json
def index
@recordpnytts = Recordpnytt.all
end
# GET /recordpnytts/1
# GET /recordpnytts/1.json
def show
end
# GET /recordpn... |
# Copyright (c) 2006, 2007 Ruffdogs Software, Inc.
# Authors: Adam Lebsack <adam@holonyx.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program ... |
require('rspec')
require('contacts')
require('email')
describe('Email') do
describe('#address') do
it("returns the email address of the contact") do
test_email = Email.new("johnsmith@123.com", "work")
expect(test_email.address()).to(eq("johnsmith@123.com"))
end
end
describe('#type') do
... |
Given(/^I login with single account and select specified transaction "([^"]*)" and dispute using i do not recognize a charge reason$/) do |txn_to_select|
visit(LoginPage)
on(LoginPage) do |page|
login_data = page.data_for(:dispute_single_disputable_ods) #dispute_single_DNR_charge
username = login_data['user... |
class CreateEntryActions < ActiveRecord::Migration
def self.up
create_table :entry_actions do |t|
t.references :entry, :null => false
t.references :by, :null => false
t.string :action, :null => false
t.timestamps
end
end
def self.down
drop_table :entry_actions
end
end
|
#!/usr/bin/env ruby
# http://adventofcode.com/2017/day/1
#
# The captcha requires you to review a sequence of digits (your puzzle
# input) and find the sum of all digits that match the next digit in
# the list. The list is circular, so the digit after the last digit is
# the first digit in the list.
#
# For example:
#... |
Write a method that takes a String as an argument, and returns a new String that contains the
original value using a staggered capitalization scheme in which every other character is
capitalized, and the remaining characters are lowercase. Characters that are not letters should
not be changed, but count as character... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'pages#home'
get 'about', to: 'pages#home'
get 'app/tasks', to: 'pages#app'
get 'app/tasks/tags/:tagId', to: 'pages#app'
resources :tasks, except: [:new, :edit, :show]
... |
class RenamePriorityTicket < ActiveRecord::Migration
def change
rename_column :tickets, :priority, :ticket_priority_id
end
end
|
# Ruby notes:
# Ruby is an Object Oriented Programming lanaguage. Code is organized in classes and objects which allow applications to access methods and variables across the application in an organized and intuitive way. (think russian doll)
# The word 'object is an abstraction of thought -
# In code, an object is d... |
json.array!(@sales) do |sale|
json.(sale, :id, :created_at, :value)
json.entries do
json.array!(sale.sale_entries) do |sale_entry|
json.(sale_entry, :id, :price_at_date, :quantity)
json.product do
json.extract! sale_entry.product, :id, :name
end
end
end
end |
feature "Installation page" do
background do
visit "/"
end
scenario "shows preconditions" do
expect(page).to have_content("Files can be written and deleted on your server")
expect(page).to have_content("GD PHP extension is installed and supports the required filetypes")
expect(page).to have_conte... |
# -*- encoding: utf-8 -*-
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
describe "IO#readline" do
it "returns the next line on the stream" do
testfile = File.dirname(__FILE__) + '/fixtures/gets.txt'
f = File.open(testfile, 'r') do |f|
f.read... |
# frozen_string_literal: true
require 'spec_helper'
require 'param/secure_auth_header'
module Uploadcare
RSpec.describe Param::SecureAuthHeader do
subject { Param::SecureAuthHeader }
describe 'signature' do
before(:each) do
allow(Time).to receive(:now).and_return(Time.parse('2017.02.02 12:58:5... |
class CustomerCard < ActiveRecord::Base
has_secure_password
has_many :pendings
has_many :claimed_rewards
end
|
module WaterBan::Addresses
class AddressesController < WaterBan::Addresses::ApplicationController
def index
view ::Address::Cell::Index, addresses
end
private
def address
@address ||= WaterBan::Addresses::Address.find(params[:id])
end
def addresses
@addresses ||= WaterBan... |
class TareasController < ApplicationController
before_action :set_tarea, except: [:index,:new,:create]
before_action :authenticate_usuario!, except: [:index,:show]
#get tareas/
def index
@tareas= Tarea.all
#select * from tareas
#llamar vista views/tareas/index.html.erb
end
#get tareas/:id
def show
@... |
class CustomerName < ActiveRecord::Base
include Lookup
DOS = { code: 'DOS', label: 'US Department of State' }
USDT = { code: 'USDT', label: 'US Department of Treasury' }
DOD = { code: 'DOD', label: 'US Department of Defense' }
DOJ = { code: 'DOJ', label: 'US Department of Justice' }
DOI = { code: 'DOI', la... |
class AddNotNullToMachineDeploymentsLogField < ActiveRecord::Migration[5.0]
def change
change_column_null :machine_deployments, :log, false, ''
end
end
|
require 'pp'
require 'yajl/json_gem'
require 'stringio'
require 'cgi'
module GitHub
module Resources
module Helpers
STATUSES = {
200 => '200 OK',
201 => '201 Created',
202 => '202 Accepted',
204 => '204 No Content',
301 => '301 Moved Permanently',
304 => '304... |
class Sale < ApplicationRecord
belongs_to :bill
validates :bill_id, presence: true, numericality: {only_integer: true}, on: :create
end
|
class ProposedBooksController < ApplicationController
before_action :set_proposed_book, only: [:show, :edit, :destroy, :update]
before_action :authenticate_user!, only: [:index, :new, :edit]
# GET /proposed_books
# GET /proposed_books.json
def index
@proposed_books = current_user.ProposedBook
end
... |
class PinType < ActiveRecord::Base
attr_accessible :pin_id, :type_id
belongs_to :pin
belongs_to :type
end
|
require_relative '../test_helper'
require 'yaml'
def vulnerability_data
@vulnerability_data ||= File.read('./test/fixtures/wheezy_vulnerability_data.txt')
end
def vulnerabilities_fixtures
@vulnerabilities_fixures ||= YAML.load_file('./test/fixtures/wheezy_vulnerabilities.yml')
end
def cve_list_fixtures
@cve_li... |
class CompaniesController < ApplicationController
include CompanySupport
before_filter :must_view, :only => [:show]
before_filter :must_edit, :only => [:update]
def show
@drinks = @company.drinks
@break_room = params.include? "breakroom"
end
def update
if can_edit? and @company.update_attrib... |
class Job
include ActiveModel::Model
attr_accessor :queue, :latency, :strategy
def initialize(*attributes)
# Default values
@queue = "default"
@latency = "1000"
@strategy = Pause::SLEEP
super
end
def save!
LoadedJob.set(queue: queue).perform_later latency: latency, strategy: strate... |
require 'rails_helper'
require 'capybara/rails'
require 'capybara/rspec'
describe 'Unauthenticated visitor happy path', type: :feature do
around(:each) do |example|
DatabaseCleaner.start
example.run
DatabaseCleaner.clean
end
let(:torta_shop) { FactoryGirl.build(:torta_shop) }
let(:lechuga) { Fact... |
Capistrano::Configuration.instance.load do
namespace :deploy do
namespace :release do
desc "Creatse a REVISION file for the current git hash for use as a 'release version' in the app."
task :mark, roles: :app, except: { no_release: true } do
run "cd #{current_path} && git rev-parse --short HEAD > R... |
require 'spec_helper'
require 'set'
describe Immutable::SortedSet do
let(:set) { SS[*values] }
let(:comparison) { SS[*comparison_values] }
describe '#eql?' do
let(:eql?) { set.eql?(comparison) }
shared_examples 'comparing something which is not a sorted set' do
let(:values) { %w[A B C] }
i... |
require 'spec_helper'
describe "job_experiences/index" do
before(:each) do
assign(:job_experiences, [
stub_model(JobExperience,
:org_name => "Org Name",
:post => "Post",
:salary => "9.99",
:leave_due_to_work => "MyText",
:teacher_id => 1
),
stub_model(Job... |
# encoding: utf-8
class An < ActiveRecord::Base
has_paper_trail :only => [:content], :on=> [:update],
:meta => {
:user_id => Proc.new { |m| m.updated_by.id },
:summary => Proc.new { |m| m.vsummary if m.changed? && !m.vsummary.blank? }
}
include Extender::Voteable
before_create { self.activity_at ... |
class AddApprovedToUser < ActiveRecord::Migration
def change
add_column :users, :approved, :boolean, :default => false, :null => false
add_index :users, :approved
end
def self.down
delete_column :users, :approved
delete_index :users, :approved
end
end
|
class AddAppointmentservicesToPractiInfo < ActiveRecord::Migration
def change
add_column :practi_infos , :appointment_services , :text
end
end
|
require 'spec_helper'
describe ReviewsController do
describe "POST create" do
context "with authenticated users" do
context "with valid inputs" do
it "redirects to the video show page" do
video = Fabricate(:video)
post :create, review: Fabricate.attributes_for(:review), video_id... |
require 'webmachine'
require 'reel'
require 'json'
class LiveResource < Webmachine::Resource
def initialize
set_headers
end
def set_headers
response.headers['Connection'] ||= 'keep-alive'
response.headers['Cache-Control'] ||= 'no-cache'
end
def allowed_methods
%W[GET]
end
def conten... |
# frozen_string_literal: true
require 'drb/drb'
class Client
DRb.start_service
def self.server
DRbObject.new_with_uri(Server::URI)
end
def self.load_data(filename, data)
server.load_data(filename, data)
end
def self.search(filename, field, target)
server.search(filename, field, target)
res... |
class Book
attr_accessor :title
def title
words_to_ignore = ["and", "the", "in", "of", "a", "an"]
input = @title.split(" ")
input[0].capitalize!
input[1..input.length-1].each{|x| x.capitalize! unless words_to_ignore.include? x}
return input.join(" ")
end
end
|
#!/usr/bin/env ruby
# Convert environment variables into json format output dumped to the console. Its up to the caller
# to sort the output appropriately and then use that as input to build-jar.rb
# include the "lib" directory
File.expand_path(File.join(__dir__, "lib")).tap {|pwd|
$LOAD_PATH.unshift(pwd) unless $L... |
# FamilyMember encapsulates the attributes and behaviors of a Family member.
class FamilyMember
# can do attr_read and write
attr_accessor :name, :sex, :status, :age, :children, :species
# like default constructor in java
def initialize(name:, sex:, status:, age:, children:, species:)
@name = name
@sex... |
# params for visits_controller nested attributes
module NestedParams
attr_reader :diagnoses_attributes, :dissections_attributes, :family_members_attributes, :genetic_tests_attributes, :heart_measurements_attributes, :hospitalizations_attributes, :medications_attributes, :patient_attributes, :procedures_attributes, :t... |
require 'helpers/interface'
module SortingStrategy
extend Interface
method :order
def initialize container, desc=false
unless container.is_a? Enumerable
raise "Please provide an array or other Enumerable"
end
unless (container.all? {|item| item.is_a? Comparable})
raise "All objects must i... |
# 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... |
#!/usr/bin/env ruby
#
# Read bib file and check the difference for merge
#
$:.unshift(File.dirname(__FILE__))
require 'bib_library.rb'
require 'papers_library.rb'
require 'getoptlong'
require 'kconv'
require 'date'
require 'ap'
$stdout.set_encoding("EUC-JP", "UTF-8")
#
# main
#
if __FILE__ == $0
require 'optpars... |
require 'digest'
require 'fileutils'
##
# The Buster class provides cache-busting functionality.
class Buster
attr_reader :files, :map
##
# Instantiates a buster, taking an array of +files+ on which to operate on.
# Params:
# +files+:: an array of files
def initialize(files=[])
raise Exception.new... |
# frozen_string_literal: true
require 'parseline'
module Brcobranca
module Retorno
# Formato de Retorno CNAB 643
class RetornoCbr643 < Base
extend ParseLine::FixedWidth # Extendendo parseline
fixed_width_layout do |parse|
parse.field :agencia_com_dv, 17..21
parse.field :cedente_c... |
class Office < ActiveRecord::Base
has_many :employees
default_scope lambda {
if $default_office_scope
where $default_office_scope
end
}
scope :usa, -> {
where(:country => "USA")
}
end
|
require "spec_helper"
describe AccountsController do
describe "routing" do
it "routes to #edit" do
get("/account").should route_to("accounts#edit")
end
it "routes PUTs to #update" do
put("/account").should route_to("accounts#update")
end
it "routes PATCHs to #update" do
patch... |
class AddStacheUrlToStaches < ActiveRecord::Migration
def change
add_column :staches, :stache_url, :string
end
end
|
module Enum_status
extend ActiveSupport::Concern
included do
enum status: { run: 0, done: 1, expired: 2 }
end
end
|
class AddArticleToGoods < ActiveRecord::Migration
def change
change_table :goods do |t|
t.string :article, null: false, default: ''
end
end
end
|
class Task
attr_reader :title
def initialize(title)
@title = title # string
@done = false # boolean
end
def mark_as_done!
@done = true
end
def done?
@done
end
end |
require 'db/MiqBdb/MiqBdb'
require "#{__dir__}/test_files"
describe MiqBerkeleyDB::MiqBdb do
it "#new" do
expect { described_class.new(MiqBdb::TestFiles::RPM_PROVIDE_VERSION).close }.not_to raise_error
end
it "#pages" do
bdb = described_class.new(MiqBdb::TestFiles::RPM_PROVIDE_VERSION)
nkeys = 0
... |
require 'test_helper'
class CreateArticleTest < ActionDispatch::IntegrationTest
def setup
@password = 'password'
@user = User.create(
username: 'adam',
email: 'adam@gmail.com',
password: @password,
admin: true
)
end
test 'unauthenticated users cannot create articles' do
... |
require 'spec_helper'
describe RedirectorController do
context "GET" do
it 'follows redirects' do
category_mappings = redirector_read_csv("spec/fixtures/categories.csv")
CategoryService.stub(:category_mappings).and_return(category_mappings)
[
[
"/au/shopping/womens-fashion-ac... |
require 'pry'
class CashRegister
attr_accessor :total, :discount, :new_item, :items, :last_transaction
def initialize(discount = nil)
@total = 0
@discount = discount
@items = []
end
def add_item(title, price, quantity = 1)
self.total += (price * quantity)
quantity.times do
items << title
end
self.... |
# frozen_string_literal: true
require 'spec_helper'
require 'date'
require 'xero_exporter/export'
describe XeroExporter::Export do
subject(:export) { described_class.new }
context '#reference' do
it 'contains the currency' do
export.date = Date.new(2020, 3, 12)
export.currency = 'gbp'
expec... |
# Set a fact to return the version of slapd that is installed
#
Facter.add("slapd_version") do
slapd_bin = Facter::Core::Execution.which('slapd')
setcode do
if slapd_bin
out = Facter::Core::Execution.execute("#{slapd_bin} -VV 2>&1")
version = out.match(/slapd (\d+\.\d+\.\d+)/)
$1
end
end... |
class Gtk2Mp3
def Gtk2Mp3.system_mpd
# check if mpd is already running
unless system 'ps -C mpd'
unless system 'mpd'
$stderr.puts 'Could not start the mpd daemon.'
exit 69 # EX_UNAVAILABLE
end
end
end
def Gtk2Mp3.system_mpc
# initialize playlist
unless system 'mpc ... |
require 'spec_helper.rb'
describe IapReceiptVerification do
subject { FactoryGirl.build :iap_receipt_verification, :successful }
it('has a valid factory') { expect(FactoryGirl.build(:iap_receipt_verification)).to be_valid }
it('has a valid unsuccessful factory') { expect(FactoryGirl.build :iap_receipt_verificat... |
module PlayerStatistics
class MapsPlayedStatistic < PlayerStatistic
def compute
q = MatchScore
.joins(:match)
.where(player: @player)
apply_filter(q).count(:all)
end
end
end
|
module GapIntelligence
class Promotion < Record
attribute :start_date, class: Date
attribute :end_date, class: Date
attribute :promotion_type
attribute :value
attribute :bundle_type
attribute :merchant_sku
attribute :notes
attribute :category_name
attribute :brand
attribute :pa... |
module Ign
class Game
attr_accessor :noko
def initialize(noko)
self.noko = noko
end
def rating
@rating ||= lambda do
begin
rating = noko.css(".ratingBox").first.content.to_f rescue nil
if rating == 0
href = noko.css(".game-title a").first.attributes["hr... |
require 'rubygems'
require 'json'
require './Node.rb'
# Used to decode the path from the goal node to the first
def decode_path(goal_node)
path = []
until goal_node.nil?
path.unshift goal_node
goal_node = goal_node.previous
end
return path
end
def bfs(start_id, goal_id, nodes)
start_node = nodes[sta... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2016-09-16
# description: The Microsoft Internet Explorer 11 Security Technical Implementation Guide (STIG) is published as a tool to improve the security of Department of Defense (DoD) information systems. Comments or proposed revisions to... |
require 'spec_helper'
describe Enumerable do
class TestEnumerable
include Enumerable
def initialize(*values)
@values = values
end
def each(&block)
@values.each(&block)
end
end
let(:enumerable) { TestEnumerable.new('A', 'B', 'C') }
describe '#to_list' do
let(:to_list) { e... |
class JointVenturesController < ApplicationController
before_action :get_joint_venture, except: [:index, :new, :create]
breadcrumb "Joint Ventures", :joint_ventures_path, match: :exact
def index
@joint_ventures = JointVenture.paginate(page: params[:page], per_page: 8)
end
def show
breadcrumb @joint_... |
# coding: UTF-8
require 'test_helper'
class StripDownRender < Redcarpet::TestCase
def setup
@parser = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
end
def test_titles
markdown = "# Foo bar"
output = @parser.render(markdown)
assert_equal "Foo bar\n", output
end
def test_code_bloc... |
class User # < ActiveRecord::Base
include Mongoid::Document
field :username
field :password
field :color
has_many :blogs, dependent: :destroy
# embeds_many :blogs
validates :username, presence: true, uniqueness: true
validates :password, presence: true, length: { minimum: 8 }
end
|
class VoucherPresenter
#
# Presentation logic to show ValidVouchers in customer view.
# Vouchers of same type and reserved for same showdate are grouped together.
# For groups of vouchers that are unreserved, we display a dropdown menu so customer can select
# how many of that voucher to confirm a reservation... |
require 'bundler/setup'
require 'nokogiri'
require 'open-uri'
require 'csv'
def setup_doc(url)
charset = 'utf-8'
html = URI.parse(url).open.read
doc = Nokogiri::HTML.parse(html, nil, charset)
doc.search('br').each { |n| n.replace("\n") }
doc
end
def scrape(url)
doc = setup_doc(url)
title = doc.title
r... |
class User
attr_accessor :name, :age
def initialize(**params)
@name = params[:name]
@age = params[:age]
end
#Userクラスから生成されてインスタンスの情報を出力するメソッド(インスタンスメソッド)
def info
"名前:#{@name}:#{@age}歳"
end
#user_dataを引数で受け取り、そこからUserクラスのインスタンスを生成するメソッド(クラスメソッド)
def self.create_users(user_data)
user_... |
class CreateGrounds < ActiveRecord::Migration
def change
create_table :grounds do |t|
t.string :name
t.integer :sport
t.integer :access
t.text :description
t.string :address
t.string :city
t.string :state
t.string :zip_code
t.timestamps
end
end
end
|
class Api::V1::PostsController < Api::V1::BaseController
before_action :authenticate_user!
def index
posts = Post.page(params[:page]).per(params[:per_page])
response.headers['X-Total-Count'] = posts.total_count.to_s
response.headers["X-Pages-Count"] = posts.total_pages.to_s
render json: posts
... |
# RubIRCd - An IRC server written in Ruby
# Copyright (C) 2013 Lloyd Dilley (see authors.txt for details)
# http://www.rubircd.rocks/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either ver... |
require "test/unit"
require 'rugged'
require 'tmpdir'
require 'json'
class ExperimentTestCase < Test::Unit::TestCase
def initialize(test_method_name)
super(test_method_name)
@c = <<eos
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char** argv) {
usleep(atoi(argv[1])*1000);
prin... |
require 'minitest/autorun'
require_relative '../../lib/mastermind/code.rb'
class TestCode < Minitest::Test
def setup
@code = Code.new([0, 1, 2, 2])
end
TEST_DATA = {
cd: [[3, 3, 4, 5], [3, 3, 4, 2], [3, 3, 4, 0],
[3, 2, 4, 2], [0, 1, 2, 2]].map! { |code| Code.new(code) },
cattle: [[0, 0], [... |
require 'test_helper'
class ExamPointsControllerTest < ActionController::TestCase
setup do
sign_in teachers(:one)
@exam_point = exam_points(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:exam_points)
end
test "should get new" do
get ... |
require 'github/client'
class Actor < ActiveRecord::Base
has_many :events
def self.import name, klass = ::Github::Client
records = klass.fetch name
actor = Actor.find_or_create_by(name: name)
records.each do |record|
begin
Event.create_from_record actor, record
rescue
next... |
class Credential < ApplicationRecord
belongs_to :user
def name
"#{self.title} #{self.first_name} #{self.last_name}"
end
end
|
class SpecialistDecorator < Draper::Decorator
delegate_all
decorates_association :user
def positive_feedback
source.positive_feedback
end
def negative_feedback
"-#{source.negative_feedback}"
end
def link_to_profile_admin
h.link_to user.to_s, h.admin_user_path(user)
end
def orders_info
... |
require 'spec_helper'
describe ApplicationController do
context 'filters' do
it { expect(subject).to use_before_filter :authenticate_user! }
it { expect(subject).to use_before_filter :configure_permitted_parameters }
it { expect(subject).to use_before_filter :set_user_uid }
end
describe '#set_user_u... |
require 'pry'
require 'anagram.rb'
anagram = Anagram.new('', '')
# anagram.word1 = 'listen'
# anagram.word2 = 'silent'
describe('anagram') do
it('check if two words are anagrams') do
anagram.word1 = 'nomar'
anagram.word2 = 'ramon'
expect(anagram.anagram_check).to(eq('These words are anagrams'))
end
... |
class CoursesController < ApplicationController
def create
@student=Student.find(current_student.id)
if @student.courses.create(course_params)
redirect_to(:controller => "welcomes", :action => "profile")
end
end
private
def course_params
params.permit(:course_name, :course_code, :associated_with)
end... |
require "spec_helper"
RSpec.describe Rails::Sources::VERSION do
it "is a string" do
expect(Rails::Sources::VERSION).to be_kind_of(String)
end
end
|
class Post < ActiveRecord::Base
has_and_belongs_to_many :tags
belongs_to :category
end
|
class Teacher < ApplicationRecord
has_many :students
has_many :lessons
has_many :cards, through: :lessons
end |
WIN_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]
]
def play(board)
until over?(board)
turn(board)
end
if won?(board)
winner = winner(board)
puts "Congratulations #{winner}!"
elsif draw?(board)
puts "Cats Game!"
end
end
def won?(board)
WIN_COMBINATIONS.each do |... |
require 'spec_helper'
describe Bitcourier::Protocol::Message::PeerInfo do
before do
@peer_info = Bitcourier::Protocol::Message::PeerInfo.new
@peer_info_bytes = "\x01\x02\x03\x04\xFF\xFF\xAF5\xA24".force_encoding(Encoding::BINARY)
end
describe '#payload' do
it 'returns payload bytes' do
@... |
require 'rails_helper'
RSpec.describe "Repositories", type: :request do
describe "GET /repositories" do
subject { get '/repositories' }
it_behaves_like 'HTTP 200 OK'
end
describe 'GET /repositories/:name' do
context 'when repository exists' do
subject { get "/users/#{user.login}/repositories/... |
class Message
include Mongoid::Document
field :send_id, type: Integer
field :send_user_name, type: String
field :send_status, type: Integer
field :receive_id, type: Integer
field :receive_user_name, type: String
field :receive_status, type: Integer
field :content, type: String
field :created_... |
class IntellijIdeaCommunity < Cask
url 'http://download.jetbrains.com/idea/ideaIC-12.1.6.dmg'
homepage 'https://www.jetbrains.com/idea/index.html'
version '12.1.6'
sha1 '276301bd01fffdc3e6ddd0c4e2acccfb49b82b54'
link 'IntelliJ IDEA 12 CE.app'
end
|
#!/usr/bin/env ruby
require 'etc'
require 'yaml'
require 'optparse'
require 'socket'
require 'pp'
require_relative 'functions'
unless Etc.getpwuid(Process.euid).name == "root" then
STDERR.puts "Must run as root.\n"
abort
end
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: connect.rb [options]"... |
ActiveAdmin.register PointOfInterest do
index do
column :id
column :title
column :footnote
column :description
column :imageURL
column :lat
column :lon
column :anchor
column :facebook_id
default_actions
end
filter :id
filter :title
filter :lat
filter :lon
form do ... |
class Changeusers < ActiveRecord::Migration
def up
add_index :users, :perishable_token
add_index :users, :email
remove_column :users, :avatar_file_name
end
def down
end
end
|
class Weather
def initialize(lat_long)
@latitude = lat_long[:lat]
@longitude = lat_long[:lng]
end
def current_weather
DarkSkyService.new.get_weather(@latitude, @longitude)
end
end
|
class TryThemsController < ApplicationController
before_action :set_try_them, only: [:show, :edit, :update, :destroy]
# GET /try_thems
# GET /try_thems.json
def index
@try_thems = TryThem.all
end
# GET /try_thems/1
# GET /try_thems/1.json
def show
end
# GET /try_thems/new
def new
@try_t... |
class CreatePlayers < ActiveRecord::Migration
def change
create_table :players do |t|
t.integer :playerId
t.string :position
t.string :display_name
t.string :fname
t.string :lname
t.string :team
t.integer :byeweek
t.float :stn_dev
t.float :nerd_rank
t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.