text stringlengths 10 2.61M |
|---|
require_relative './minitest_helper.rb'
require_relative '../checkout.rb'
require 'pry'
class TestCheckout < MiniTest::Test
def setup
pricing_rules = PricingRules.new
pricing_rules.add_buy_1_get_1_rule('FR1')
pricing_rules.add_bulk_purchase_rule(product_code: 'AP1', bulk_price: 450, threshold: 3)
@... |
require 'mechanize'
require 'logger'
module KindleHighlightsAPI
class Fetcher
class LoginError < StandardError; end
def initialize(email, password)
@email, @password = email, password
login_to_amazon_kindle
end
def fetch_all
Array.new.tap do |books|
fetch_each do |book|
... |
# Model
model:
rest_name: enforcerrefresh
resource_name: enforcerrefreshes
entity_name: EnforcerRefresh
package: gaga
group: core/policy
description: |-
Sent to enforcers when a poke has been triggered using the
parameter `?notify=true`. This is used to notify an enforcer of an
external change o... |
module Oshpark
module Dimensionable
def width_in_inches
width_in_mils / 1000.0
end
def height_in_inches
height_in_mils / 1000.0
end
def area_in_square_inches
width_in_inches * height_in_inches
end
def width_in_mm
width_in_inches * 25.4
end
def height_in_... |
require 'rails_helper'
RSpec.describe CallOutgoingWebhookJob, type: :job do
let(:app) { create(:app) }
let(:integration) { create(:integration, app: app) }
let(:config) { JSON.parse(integration.config) }
let(:device) { create(:device, app: app) }
context 'a alive server' do
it 'invokes a webhook' do
... |
class CreateImages < ActiveRecord::Migration[5.0]
def change
create_table :images do |t|
t.integer :parent_id
t.string :parent_type
t.string :tag
t.timestamps
end
add_attachment :images, :image
end
end
|
helpers do
def current_user
User.find_by(id: session[:user_id])
end
end
get '/' do
@posts = Post.order(created_at: :desc)
# Removed this because replaced it with helper method do didn't have to repeat it multiple times across all
# requests @current_user = User.find_by(id: session[:user_id]) #reuired so... |
class CommentsController < ApplicationController
before_action :find_post, only: [:show, :create, :edit, :update, :destroy]
def index
@comments = Comment.all.order('created_at ASC')
end
def create
@comment = @post.comments.build(comment_params)
@comment.user_id = current_user.i... |
class TodoList
# Initialize the TodoList with +items+ (empty by default).
def initialize(items=[])
raise IllegalArgument if items == nil
@list = items.map { |item| ListItem.new(item) }
end
def all
@list
end
def empty?
@list.empty?
end
def size
@list.size
end
def << (subject... |
require 'spec_helper'
describe "sports/show" do
before(:each) do
@sport = assign(:sport, FactoryGirl.create(:sport, leagues:[FactoryGirl.create(:league)]))
end
it "renders attributes " do
render
rendered.should have_content(@sport.name)
rendered.should have_content(@sport.leagues.first.name)
e... |
class EventsController < ApplicationController
before_action :require_nationbuilder_slug
before_action :set_event, only: [:show, :rsvp]
def index
# When blank, returns all events
@tags = params[:tags] || []
@exclude_tags = session.key?(:userinfo) ? [] : ["private"]
respond_to do |format|
f... |
class CreateCaseWorkflowValues < ActiveRecord::Migration
def change
create_table :case_workflow_values do |t|
t.references :user_case
t.references :workflow
t.references :state
t.references :action
t.string :save_attr
t.timestamps
end
add_index :case_workflow_values, :... |
require 'open-uri'
# Monkey patch to allow redirection from "http" scheme to "https"
def OpenURI.redirectable?(uri1, uri2)
uri1.scheme.downcase == uri2.scheme.downcase ||
(uri1.scheme =~ /\A(?:http|ftp)\z/i && uri2.scheme =~ /\A(?:https?|ftp)\z/i)
end
|
class CreateTestAnswers < ActiveRecord::Migration
def change
create_table :test_answers do |t|
t.references :test_question
t.integer :position
t.text :answer
t.boolean :is_answer, :default => false
t.timestamps
end
add_index :test_answers, :test_question_id
end
end
|
Rails.application.routes.draw do
resources :recipes, only: [:index, :show, :new, :create, :destroy] do
resources :ingredients, only:[:index, :show, :new, :create, :destroy]
end
root "recipes#index"
end
|
class ProfilesController < ApplicationController
before_action :set_profile
def show
@top_agents_by_expressions_count = @profile
.agents_by_expressions_count
.page(params[:expressions_page])
.per(10)
@to = DateTime.now
@from = (DateTime.now - 30.days).beginning_of_day
@requests_... |
require 'ipaddr'
def check_count(role_name, c)
if c.count == nil
raise Vagrant::Errors::VagrantError.new,"Incompatible constraints: #{role_name}: Missing count"
end
end
def check_fd(role_name, c)
if c.fd_choice != nil && (c.count > 1 && c.limit == 1)
raise Vagrant::Errors::VagrantError.new,"Incompatible... |
require_relative 'test_helper'
begin
require 'nokogiri'
_MarkdownTests = Module.new do
extend Minitest::Spec::DSL
def self.included(mod)
class << mod
def template(t = nil)
t.nil? ? @template : @template = t
end
end
end
def render(text, options = {})
self.class.template.new(op... |
module IncomingMail
class Response
attr_accessor :type, :action, :comment
# named action constants
ERROR = 0
COMMENT = 1
FORWARDED = 2
DROPPED = 3
def initialize(params = {})
params.each do |key, value|
instance_variable_set("@#{key}", value)
end
@action ||= E... |
# encoding: UTF-8
module CDI
module V1
module ContactForms
class BaseCreateService < ::CDI::BaseCreateService
include V1::ServiceConcerns::ContactFormParams
private
def record_type_params
contact_form_params
end
def can_create_record?
unless ca... |
class Item < ActiveRecord::Base
self.table_name = 'item'
self.primary_key = 'item_id'
has_one :vireo_submission
has_many :metadata_values
delegate :is_doctoral?, :to => :vireo_submission
def metadata_triples
self.metadata_values.collect do |value|
MetadataTriple.new.tap do |triple|
trip... |
require 'spec_helper'
describe Api::V1::UsersController do
describe "POST 'create'" do
subject { post :create, params.merge(format: :json) }
let(:params) { { } }
context "when facebook token is provided" do
let(:params) { { facebook_token: SecureRandom.hex } }
context "and email is not prov... |
require "spec_helper"
describe PurchasersController do
describe "routing" do
it "routes to #index" do
get("/purchasers").should route_to("purchasers#index")
end
it "routes to #new" do
get("/purchasers/new").should route_to("purchasers#new")
end
it "routes to #show" do
get("/p... |
module SubscriptionValidations
extend ActiveSupport::Concern
include ActiveEvent::Validations
validation_target :'CreateSubscriptionCommand'
included do
validate :unique_subscription
end
def unique_subscription
errors.add(:base, "Sie verfolgen dises Diskussion bereits!") if Subscription... |
class Announcement < ActiveRecord::Base
acts_as_list
attr_accessible :body, :position, :title, :url, :alert
after_initialize do
if new_record?
self.alert ||= 'info'
end
end
RailsAdmin.config do |config|
config.model Announcement do
navigation_label 'CMS'
object_la... |
require File.join(File.dirname(__FILE__), 'spec_helper')
describe PublisherFactory do
it "should return growl publisher for mac" do
Config::CONFIG.should_receive(:[]).with('target_os').and_return('darwin9.0')
PublisherFactory.create_publishers.should include(Publisher::Growl.new)
end
it "shoul... |
class Fine < ActiveRecord::Base
belongs_to :user
has_many :finance_fee_collections
has_many :fine_rules
validates_presence_of :name
validates_uniqueness_of :name, :scope=> [:is_deleted],:if=> 'is_deleted == false'
validates_format_of :name,:with=>/^\S.*\S$/i,:message => :should_not_contain_white_spaces_at_t... |
# == Schema Information
#
# Table name: doctor_clinics
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
# clinic_id :integer
# doctor_id :integer
#
# Indexes
#
# index_doctor_clinics_on_clinic_id (clinic_id)
# index_doctor_clinics_on_doctor_id (doctor_id)
#... |
require "spec_helper"
module Ayi
describe StrategyManager do
subject { StrategyManager }
it { should respond_to :register }
it "should register strategies automatically" do
subject.strategies.count.should > 0
end
describe "match_file_name?" do
it "should match files" do
subje... |
control "M-4.5" do
title "4.5 Ensure Content trust for Docker is Enabled (Scored)"
desc "
Content trust is disabled by default. You should enable it.
Content trust provides the ability to use digital signatures for data sent
to and received
from remote Docker registries. These signatures allow client-s... |
require('pg')
require_relative('../db/sql_runner')
#require_relative('./customer')
class Film
attr_accessor :title, :price
attr_reader :id
def initialize(options)
@title = options['title']
@price = options['price'].to_i
@id = options['id'].to_i if options['id']
end
#CREATE a film
def save
... |
class Entry < ApplicationRecord
belongs_to :student
delegate :user, :to => :student, :allow_nil => true
validates :title, :content, presence: true
end
|
###comment out these 3 lines for standlone RSpec (i.e when NOT in coderpad)
#require 'rspec/autorun'
#require 'algorithms'
# include Algorithms
##The above statements are useful when running in
##coderpad.io/sandbox - otherwise comment out
require 'securerandom'
require 'set'
require 'active_support/all'
require 'pry'... |
class BusinessPost < Post
attr_accessible :title
def marker
"business_marker.png"
end
def user_cant_see_post?(user)
false
end
end |
class CheapBits
def self.readblock(fd_in, block_size)
fd_in.readpartial block_size
rescue EOFError
nil
end
def self.getbit(random_block, bit_offset)
byte_offset = bit_offset >> 3
byte_bit_offset = bit_offset - (byte_offset << 3)
byte = random_block.getbyte(byte_offset)
1 & (byte >> (7 ... |
class AddPlaceTypeToAddresses < ActiveRecord::Migration
def change
add_column :addresses, :place_type, :string
end
end
|
class BidsController < ApplicationController
before_action :authenticate_user!
def index
bids = current_user.bids
auctions = Auction.all
respond_to do |format|
format.html {render :index, locals: {bids: bids, auctions: auctions}}
end
end
def create
b... |
class CommandBuilder
def initialize(database)
@database = database
end
def buildCommand(command,lamb,numArgs)
args = []
for x in 0...numArgs
args << @database.getMain.pop
end
command = Command.new(lamb,args,command,@database)
return command
end
end
class Command
@exec = nil #Lambda that determine... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
:omniauthable, :omniauth_provid... |
class Batch < ApplicationRecord
has_many :students, dependent: :destroy
validates :name, presence: true, uniqueness: true
validates :start_date, presence: true
validates :end_date, presence: true
#default_scope {order(name: :asc)}
def self.order_by_name
order(:name)
end
def pick_student
if w... |
class Review < ApplicationRecord
belongs_to :user
belongs_to :movie
end
|
class AddApartments < ActiveRecord::Migration
def change
create_table :apartments do |t|
t.string :title
t.string :url
t.string :address
t.integer :rent
t.integer :size
t.integer :rooms
t.integer :is24_id
t.float :latitude
t.float :longitude
t.tim... |
# Create an object-oriented number guessing class for numbers in the range 1 to 100, with a limit of 7 guesses per game. The game should play like this:
# hit play, generate random numberrbetween 1 to 100
# player starts with 7 guesses
# Enter a number
# either invalid, too low, too high, or correct number
# re... |
class CreateVideos < ActiveRecord::Migration[5.0]
def change
create_table :videos do |t|
t.integer :user_id
t.string :video_url
t.string :video_title
t.text :video_description
end
add_index :videos, :user_id
end
end
|
# frozen_string_literal: true
module Kafka
module Protocol
class ApiVersionsRequest
def api_key
API_VERSIONS_API
end
def encode(encoder)
# Nothing to do.
end
def response_class
Protocol::ApiVersionsResponse
end
end
end
end
|
class RentableItem < ActiveRecord::Base
belongs_to :stocker_item
belongs_to :stocker_place
has_many :assign_rental_item, dependent: :destroy
validates :stocker_item_id, :stocker_place_id, :max_num, presence: true
validates :max_num, numericality: {
only_integer: true,
greater_than_or_equal_to: 0
}
... |
# frozen_string_literal: true
class ValidEmail < ApplicationRecord
validates :email, presence: true, uniqueness: true
validates :email, format: { with: /\A[\w\d._@\ ]*\z/, message: 'Please do not use special characters.' }
end
|
require 'test_helper'
class InstructionsTest < Test::Unit::TestCase
test 'copy: generates an INSERT INTO ... SELECT FROM statement (for a single column)' do
statements = migrate_table_statements { |t| t.copy :commit }
assert_equal 'UPDATE "tasks" SET "id" = source."id", "commit" = source."commit" FROM (SELEC... |
class PagesController < ApplicationController
before_filter :find_page, :only=>[:up, :down, :show, :edit, :update, :destroy]
# It's working!
# I'am use nested_set scope from Model
def index
@pages = Page.nested_set.all
end
# JUST TESTING! localhost:3000/pages/native
# Native nested set rendering
#... |
google_cloud_lb "#{node[:google_cloud][:lb][:pool_name]}" do
port node[:google_cloud][:lb][:port]
tag node[:google_cloud][:lb][:tag]
action :install
end
|
require 'test_helper'
class CartTest < ActiveSupport::TestCase
def setup
@customer = customers(:happy)
@product = products(:johns)
end
test 'cart existance and some contents' do
assert !@customer.cart.blank?
assert !@customer.cart.items.blank?
end
test "check cart totals" do
assert_equa... |
# frozen_string_literal: true
require 'bindata'
require 'java_serialization/field_desc'
module JavaSerialization
class ClassDescFields < BinData::Record
endian :big
uint16 :number_of_fields, value: ->{ field_desc.length }
array :field_desc, type: :field_desc, initial_length: :number_of_fields
end
end
|
module MetricFu
def self.generate_flog_report
Flog::Generator.generate_report
system("open #{Flog::Generator.metric_dir}/index.html") if open_in_browser?
end
module Flog
class Generator < Base::Generator
def generate_report
@base_dir = self.class.metric_dir
pages = []
... |
module XPash
class Base
def dump(*args)
# parse args
opts = optparse_dump!(args)
# get query & list
if args.empty?
query = @query
list = @list
else
query = getPath(@query, args.join(" "))
list = @doc.xpath(query, $xmlns)
end
return list u... |
module Concerns::SentMailmagazine::Association
extend ActiveSupport::Concern
included do
belongs_to :mailmagazine
has_many :mailmagazine_contents, -> {order("no")},
class_name: "MailmagazineContent",
foreign_key: :send_mailmagazine_id,
dependent: :destroy
end
end
|
require 'rails_helper'
RSpec.describe ItemPurchase, type: :model do
before do
@item_purchase = FactoryBot.build(:item_purchase)
end
describe '商品購入' do
context "商品をが購入できる場合" do
it "全ての情報が入力されていればは保存される" do
expect(@item_purchase).to be_valid
end
end
context "商品が購入できない場合" do
... |
class LineItemsController < ApplicationController
def create
@cart = current_cart
product = Product.find(params[:product_id])
if $newcart == nil
LineItem.where(cart_id: @cart.id).delete_all
end
if LineItem.where(product_id: product.id).any?
redirect_to @cart, notice: "Item is already... |
RSpec.describe Mission::Mission do
let(:rocket) { double('rocket') }
let(:chaos_monkey) { double('chaos_monkey') }
let(:name) { 'Apollo 13' }
let(:planned_distance) { 3 }
let(:speed) { 3_600 }
let(:burn_rate) { 168_240 }
let(:sleep_interval) { 0 }
let(:rocket_rates) { [speed, burn_rate] }
let(:no_auto... |
class Channels::ProjectsController < ProjectsController
belongs_to :channel, finder: :find_by_permalink!, param: :profile_id
after_action :associate_with_channel, only: :create
prepend_before_filter{ params[:profile_id] = request.subdomain }
private
def associate_with_channel
resource.channels << chan... |
# See features/matrices.feature
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/matrix'
describe Matrix do
describe "Constructing" do
it "a 4x4 matrix" do
m = Matrix.new([[1, 2, 3, 4], [5.5, 6.5, 7.5, 8.5], [9, 10, 11, 12], [13.5, 14.5, 15.5, 16.5]])
assert_equal 1, m[0,... |
class RssPresenter < Presenter
def is_rss_presenter?
true
end
end |
#Basic Climate System v2.2
#----------#
#Features: Provides a basic weather system that will randomly weather!
# Wooot!
#
#Usage: Plug and play!
# Script calls:
# Climate::still(true/false) #Stops weather changing
# Climate::weather #Returns 0 for clear, 1 for ra... |
#!/usr/bin/env ruby
#
# Generate a PDF invoice.
#
# Requires the wkhtmltopdf binary to be installed on the system.
#
require 'date'
require 'erb'
# setup filenames
dir = File.expand_path(File.dirname(__FILE__))
datafile = File.join(dir, "data", "#{ARGV[0]}.rb")
# get data
if File.exist?(datafile)
require dataf... |
class AddUserToProposals < ActiveRecord::Migration
def change
add_reference :proposals, :user, index: true, foreign_key: true
end
end
|
# frozen_string_literal: true
class India
attr_reader :wiki, :cio, :census2011, :raw2019
def initialize
@raw2019 = JSON.parse(File.read(Rails.root.join("topojson/india.json")))
@wiki = File.read(Rails.root.join("data/india-districts.wiki"))
@cio = JSON.parse(File.read(Rails.root.join("data/state_distr... |
Rails.application.routes.draw do
# get 'posts/index'
# get 'posts/new'
# get 'posts/edit'
# get 'posts/show'
# get 'users/index'
# get 'users/new'
# get 'users/show'
# get 'users/edit'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get "/... |
require 'nokogiri'
require 'unirest'
require 'open-uri'
class Parser
attr_accessor :rest_uri
def open_uri(uri)
Nokogiri::HTML open uri
end
def get_css_list(uri, css_selector, attrib = "href")
items = []
open_uri(uri).css(css_selector).each{ |i| items.push i[attrib] }
items
end
def get_css(uri, css_se... |
class Api::V1::ProgressionsController < Api::V1::ApiController
before_action :set_progression, only: %i[show update destroy execute]
def index
@progressions = current_context.progressions.order(:name)
return unless params[:exercise_id]
@progressions = @progressions.where(exercise_id: params[:exercise_... |
# frozen_string_literal: true
describe Zafira::Handlers::FinishedTestCase::Rspec::Failed do
let(:client) { build(:zafira_client, :with_current_test_case, :rspec) }
let(:example) { build(:example, :finished) }
let(:wrapped_example) do
Zafira::Handlers::FinishedTestCase::Rspec::Failed.new(
client.curren... |
class ProgressBar
module Components
class Rate
include Timer
include Progressable
attr_accessor :rate_scale
def initialize(options = {})
self.rate_scale = options[:rate_scale]
super
end
def start(options = {})
as(Timer).start
as(Progressable)... |
class RemoveLocatortypeFromSteps < ActiveRecord::Migration[6.0]
def change
remove_column :steps, :locatorType, :string
remove_column :steps, :action, :string
end
end
|
class QueryUsers
prepend SimpleCommand
def initialize(facility_id, args = {})
@facility_id = facility_id.to_bson_id if facility_id
@task_permission = args[:task_permission]
@current_user = args[:user]
end
def call
if valid?
users = []
if @task_permission
if RoleCheck.call(@... |
class Post
attr_accessor :comment_arr
attr_reader :title, :url, :points, :item_id
def initialize(title, url, points, item_id)
@title = title
@url = url
@points = points
@item_id = item_id
@comment_arr = []
end
end |
module Concerns::User::Rolify
extend ActiveSupport::Concern
included do
rolify role_cname: "Acn::Role", after_add: :update_roles_count, after_remove: :update_roles_count
belongs_to :xrole, class_name: "Acn::Role", foreign_key: :xrole_id
end
module ClassMethods
def admin
with_role(:admin).fir... |
Rails.application.routes.draw do
devise_for :students
devise_for :teachers
root 'welcome#index'
end
|
class AddPreviewImageToProduct < ActiveRecord::Migration
def change
add_column :products, :cover_image, :binary
end
end
|
module HTTPalooza
module Players
class SeleniumPlayer < Base
introducing! :selenium, %w[ selenium-webdriver ]
def response
if request.method == :get
get_url
elsif request.method == :post
post_html_form
else
request_ajax
end
ensure
... |
describe Carmine do
before do
Carmine.base_uri ENV['base_uri'] if ENV['base_uri']
end
describe '::Error' do
it 'should extract /\(.*?\)/' do
response = Struct.new(:body).new('Skipped and (showed)')
Carmine::Error.new(response).to_s.should == 'showed'
end
it 'should extract /\(.*?\)/... |
# require 'test_helper'
# class FindTicketTest < ActiveSupport::TestCase
#
# test 'Find Ticket interactor exists' do
# class_exists?(FindTicket)
# end
#
# test 'successful find' do
# new_ticket_id = create(:ticket_customer).id
# result = FindTicket.call(response: {authenticated: true}, id: new_ticket_... |
require 'rails_helper'
describe UserUploadFile, type: :use_case do
let(:employee) { FactoryGirl.create :employee }
let(:file) { 'file' }
let(:file_name) { 'file name' }
let(:content_type) { 'application/pdf'}
let(:perform_use_case) { UserUploadFile.perform(params) }
before do
allow(S3::PushFile).to re... |
# The panel containing stats and combat messages that appears next to the map
class InfoPanel
def initialize(map)
@map = map
@player = map.player
@monsters = map.monsters
@contents = DEFAULT_CONTENTS.clone
end
DEFAULT_CONTENTS = ['|' + '-' * 39] +
['| INVENTORY'] +
... |
#
# Cookbook Name:: omnibus
# Recipe:: _bash
#
# Copyright 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unle... |
class ItemCategories < ActiveRecord::Migration[5.2]
#This is the join table.
#Category_id column has since been shifted to the Items table,
#to allow the initial input form to carry params via Item.
#This move discontinued the items showing on their respective Category pages.
#I plan to revisit this later,... |
def multisum num
index = 0
sum = 0
while index <= num
sum += index if index % 3 == 0 || index % 5 == 0
index += 1
end
return sum
end
puts multisum(3) == 3
puts multisum(5) == 8
puts multisum(10) == 33
puts multisum(1000) == 234168
# Second time:
# def multisum(num)
# sum = 0
# 3.upto(num) do |... |
module Users::Validation
extend ActiveSupport::Concern
included do
validates :name, :lastname, :role, presence: true
validates :name, :lastname, :email, :username, :role, length: { maximum: 255 }
validates :role, inclusion: { in: User::ROLES }
validates :username, uniqueness: { case_sensitive: fals... |
# frozen_string_literal: true
describe "home page", type: :feature, js: true do
before(:each) do
visit "/"
end
include_examples "base"
it "should have a title" do
expect(page).to have_title "Experience"
end
# TODO: make this shared context/example with params for id and str?
it "should list ex... |
require 'singleton'
class Tiles
include Singleton
attr_reader :tiles
def initialize
@tiles = {}
lines = File.readlines('./config/tiles')
lines.shift
lines.each do |line|
line.chomp!
letter, value, count = line.split
@tiles[letter] = Letter.new(value.to_i, count.to_i)
end
end
def self.[](key)... |
# TODO:
# - Implement handling of close_end / close_start when time give and multiple opening/closing times per day
# - Implement handling of errors (no library, date in the past & etc)
# - Fix bug with date overrun (week 53) - implement handling of next year dates
class LibView::LibrarySchedulesController < Applicati... |
# == Schema Information
#
# Table name: user_settings
#
# id :integer not null, primary key
# first_name :string
# last_name :string
# email :string
# phone :string
# address :string
# city :string
# state :string(2)
# zip :string
# phone_id :string
# create... |
require 'import/dsid_map'
require 'import/object_factory'
require 'import/rels_ext_parser'
class UnableToCreateLinkedResourceError < StandardError; end
class ObjectImporter
include Rails.application.routes.url_helpers
attr_reader :failed_imports, :modified_queue
def initialize(remote_fedora_name, pids, verbos... |
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'rex'
require 'msf/core'
class Metasploit3 < Msf::Post
include Msf::Auxiliary::Report
include Msf::Post::Windows::LDAP
include Msf::Post::Windows::ExtAPI
def initial... |
class SessionsController < ApplicationController
skip_before_action :authenticate_user
def create
user = User.find_by(username: user_params[:username])
if user && user.authenticate(user_params[:password])
jwt = Auth.issue({user_id: user.id})
render json: {jwt: jwt, userId: user.id, username: us... |
module UnlockGateway
module Models
# Your module UnlockMyGatewayName::Models::Contribution, that should implement this interface, will be included in Unlock's Contribution model. All methods will run in the context of an instance of Contribution model.
module Contribution
# This method should return t... |
require 'test_helper'
class SongTest < ActiveSupport::TestCase
def setup
@youtube_json = {
'items' => [
{
'id' => '123',
'snippet' =>
{
'title' => 'SomeArtist - SomeTitle',
'thumbnails' =>
{
'default' => { 'url' => 'http://foo.com/bar' }
}
},
'contentDe... |
class Assignment < ActiveRecord::Base
attr_accessible :title, :weight, :points, :description, :due_date, :due_time
has_many :submissions
belongs_to :weight
has_many :grades
def class_section
return self.weight.class_section
end
def get_average
return Grade.where(:assignment_id => self).average... |
module Locomotive
module Hosting
module Bushido
module AccountExt
extend ActiveSupport::Concern
included do
field :bushido_user_id, :type => Integer
end
module InstanceMethods
def cas_extra_attributes=(extra_attributes)
return if extra_a... |
class ProductSnapshot < Snapshot
field :title
field :url
field :tmp_match_group
def signatures
return super if super
if self.tmp_match_group
return [self.tmp_match_group.to_s]
else
return [self.url]
end
#[self.tmp_match_group.to_s || self.url]
end
def get_product_snapshots... |
class AddColorToOrdenmescams < ActiveRecord::Migration[5.1]
def change
add_column :ordenmescams, :color, :string
end
end
|
module Types
class QuestionType < Types::BaseObject
field :id, ID, null: false
field :title, String, null: false
field :body, String, null: false
field :render, String, null: false
field :shuffle, Boolean, null: false
field :correct_answer, Types::AnswerType, null: true
fie... |
module Naf
class StatusController < Naf::ApplicationController
def index
@machines = []
::Naf::Machine.where(enabled: true).all.each do |machine|
@machines << ::Logical::Naf::Machine.new(machine).status
end
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.