text stringlengths 10 2.61M |
|---|
require File.dirname(__FILE__) + "/../../spec_helper"
describe Instructors::GroupsController do
let(:current_user) { Factory.stub(:instructor) }
before { controller.stub(:current_user).and_return(current_user) }
def mock_group(stubs={})
@mock_group ||= mock_model(Group, {:name => ""}.merge(stubs))
en... |
require 'httparty'
module Songkick
module Transport
class HttParty
def self.new(host, options = {})
adapter_class = options.delete(:adapter) || Adapter
adapter_class.format(options[:format] || DEFAULT_FORMAT)
adapter_class.default_timeout(options[:timeout] || DEFAULT_TIMEOUT)
... |
module JavaClass
module ClassFile
# Access flags as defined by JVM spec.
# Author:: Peter Kofler
module AccessFlagsConstants
# field
# ACC_PUBLIC = 0x0001
ACC_PRIVATE = 0x0002
ACC_PROTECTED = 0x0004
# TODO How were Java 1.0's "private protected" fields? set up?... |
class Item < ActiveRecord::Base
mount_uploader :picture, PictureUploader
def price(list)
if list.name == "Publix"
price_publix
elsif list.name == "Winn Dixie"
price_winn_dixie
end
end
def lowest_price?(list)
return true if price_publix <= price_winn_dixie && list.name == "Publix"... |
# frozen_string_literal: true
require 'statistic_calcs/regression/base'
module StatisticCalcs
module Regression
# Estimation of a variable (the dependent variable) from another's variables (the independent variables).
# This class will calculate the related correlation or degree of relationship between the ... |
require 'spec_helper'
describe Share do
it "counts clips shared" do
movie = Factory.create(:movie)
clip_1 = Factory.create(:clip, :movie_id => movie.id)
clip_2 = Factory.create(:clip, :movie_id => movie.id)
clip_3 = Factory.create(:clip, :movie_id => movie.id)
clip_4 = Factory.create(:clip, :... |
module Lee
# Is a board valid? With all pads and routes within the bounds of the board.
def self.board_valid?(board)
board.pads.all? { |pad| point_on_board?(board, pad) } &&
board.routes.all? { |route| route_on_board?(board, route) }
end
# Are the board and all solutions valid? With solutions contin... |
/*
A KBase module: jgi_rqc_readqc
*/
module jgi_rqc_readqc {
/* A boolean - 0 for false, 1 for true.
@range (0, 1)
*/
typedef int boolean;
/* An X/Y/Z style reference to a workspace object containing a fastq, either a
"KBaseFile.PairedEndLibrary",
"KBaseFile.SingleEndLibrary",... |
class Calculation
include ActiveModel::Model
attr_accessor :drinks, :weight, :time, :gender
validates :drinks, :weight, :time, :gender, presence: true
def bac(gender, drinks, weight, time)
ratio = gender == 'male' ? 0.73 : 0.66
bac = ((drinks * 5.14/weight * ratio) - 0.015 * time).round(2)
(bac... |
# frozen_string_literal: true
require 'app_prototype/types'
Hanami.application.settings do
# Framework
setting :log_to_stdout, AppPrototype::Types::Params::Bool.optional.default(false)
# Database
setting :database_url, AppPrototype::Types::String
# Application
setting :session_secret, AppPrototype::Type... |
class CreateProducts < ActiveRecord::Migration[5.0]
def change
create_table :products do |t|
t.string :tab
t.integer :favorite_count
t.string :middle_category_name, foreign_key: true
end
add_index :products, :middle_category_name
end
end
|
class AddAlumnoToReport < ActiveRecord::Migration
def change
add_reference :reports, :alumno, index: true, foreign_key: true
end
end
|
# optional?
# Vagrant.require_plugin "vagrant-berkshelf"
# Vagrant.require_plugin "vagrant-chef-zero"
# Vagrant.require_plugin "vagrant-omnibus"
# -*- mode: ruby -*-
# vi: set ft=ruby :
alex_box_url = "~/Documents/ISO_BOX_etc/virtualbox-win2008r2-enterprise-provisionerless.box"
ge_box_url = "~/Documents/ISO_BOX_etc/ge... |
require 'net/http'
require 'uri'
require 'json'
class CashierChecks
def initialize(order,type)
@order = order
@type = type
@user = User.find(@order.user_id)
end
def send_params
return unless @order.present?
payment_data.merge(order_data)
end
def send_request
uri = URI.parse("https:... |
Gem::Specification.new do |s|
s.name = 'jobless'
s.version = '0.1.0'
s.date = Date.today.to_s
s.summary = 'Generate your CV with Ruby'
s.description = 'Jobless is a simple DSL for creating a CV in HTML format.'
s.authors = ['Filip Defar']
s.email = 'filip.defar@gmail.com'
... |
class TeamMaster < ActiveRecord::Base
#default_scope { order('id DESC') }
has_many :users
validates :team_name, presence: true, uniqueness: true
paginates_per $PER_PAGE
end
|
# frozen_string_literal: true
module Yake
module Errors
class Error < StandardError; end
class UndeclaredRoute < Error
def initialize(method = nil)
super("No route declared for '#{ method }'")
end
end
class UnknownLoggingSetting < Error
def initialize(method = nil)
... |
# Skill Trees or Something v1.0a
#----------#
#Features: Basic skill trees! Earn skill points, spend skill points,
# get abilities! Enjoy.
#
#Usage: Set up your skill trees, knock yourself out.
# Script calls:
# SceneManager.call(Scene_SkillTree)
# $game_actors[actor_id].add_ski... |
class Event < ApplicationRecord
validates :date, :time, :address, :description, :host_id, :city_id,
:max_attend, presence: true
has_many :joins, dependent: :destroy
has_one :host, dependent: :destroy
has_many :users, through: :joins
belongs_to :city
end
|
require 'spec_helper'
describe RoleAssignment do
before do
subject.user = create(:user)
end
it_behaves_like 'ActiveModel'
it { should allow_mass_assignment_of(:role) }
it { should_not allow_mass_assignment_of(:user) }
it { should validate_presence_of(:role).with_message(/can't be blank/) }
it "v... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :company do
name { Faker::Company.name }
address { Faker::Address.street_address }
city { Faker::Address.city }
country { ISO3166::Country.all.sample.first }
email { Faker::Internet.email }
phon... |
FactoryGirl.define do
factory :venue do
name 'Starbucks'
end
end |
Sequel.migration do
up do
add_column :profiles, :branch_change_alert, String
end
down do
drop_column :profiles, :branch_change_alert
end
end
|
class UserMailer < ApplicationMailer
def account_activation(user)
@user = user
mail(to: user.email, subject: "Account activation") do |format|
format.text(content_transfer_encoding: "utf-8")
format.html
end
end
def password_reset(user)
@user = user
mail(to: user.email, subject: "P... |
Sequel.migration do
up do
run "create index series_register_id_time_idx on series(register_id, time)"
end
down do
alter_table(:series) do
drop_index name: 'series_register_id_time_idx'
end
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/trusty64"
# ... |
class AddReferencesToIndication < ActiveRecord::Migration[5.2]
def change
add_reference :indications, :user, foreign_key: :true
add_reference :indications, :item, foreign_key: :true
add_column :indications, :destination_user, :integer
end
end
|
class RemoveDifficultyInfoToMusics < ActiveRecord::Migration
def change
remove_column :musics, :difficulty
remove_column :musics, :level
end
end
|
# Problem 90: Cube digit pairs
# http://projecteuler.net/problem=90
# Each of the six faces on a cube has a different digit (0 to 9) written on it; the same is done to a second cube. By placing the two cubes side-by-side in different positions we can form a variety of 2-digit numbers.
#
# For example, the square numb... |
require_relative 'trigger'
module Build
class OmnibusTrigger
extend Trigger
OMNIBUS_PROJECT_PATH = 'gitlab-org/omnibus-gitlab'.freeze
def self.get_project_path
OMNIBUS_PROJECT_PATH
end
def self.get_params(image: nil)
{
"ref" => ENV["CI_COMMIT_REF_NAME"],
"token" => ... |
class CreateQuestions < ActiveRecord::Migration[5.2]
def change
create_table :questions do |t|
t.string :body, null: false
t.string :type, null: false
t.boolean :active, null: false, default: "false"
t.integer :group_id, null: false
t.integer :order_index
t.timestamps
end
... |
require_relative 'concert'
require 'minitest/autorun'
describe Concert do
let(:concert) { Concert.new title: 'The Spice Girls Reunion Tour', datetime: 'Monday, March 24, 2014 at 9:00PM', location: 'Mexico City, Mexico', venue: 'El Plaza Condesa', status: 'available' }
it 'initializes with hash' do
concert.loc... |
require 'bulutfon_sdk/rest/base_request'
module BulutfonSDK
module REST
class Announcement < BaseRequest
include BulutfonSDK::Util
def initialize(*args)
super(*args)
@resource = 'announcements'
end
def all( params = {} )
prepare_request( 'get', @resource,params)... |
require 'spec_helper'
describe Moderator::SubjectsController do
render_views
include_context 'Moderator signed in'
describe '#edit' do
let!(:subject) { create(:subject) }
let(:call_request) { get :edit, id: subject.id }
context 'after request' do
before { call_request }
it { expect(ass... |
class ContentShell < ActiveRecord::Base
self.table_name = "contentbase_contentshell"
outpost_model
has_secretary
include Concern::Scopes::SinceScope
include Concern::Scopes::PublishedScope
include Concern::Associations::ContentAlarmAssociation
include Concern::Associations::AssetAssociation
include Co... |
class ProcessType < ActiveRecord::Base
has_many :batch_processes
default_scope lambda { order('sort_order ASC') }
scope :category, lambda { |category| where(:category => "ProcessType::#{category.upcase}".constantize) }
CATEGORIES=['fermentation', 'carbonation', 'bottling']
CATEGORIES.to_enum.with_index(0).e... |
# In this exercise, we've already implemented the class, and you have to write the
# driver code.
# This class represents a hotel reservation.
class HotelReservation
attr_accessor :customer_name, :date, :room_number, :amenities
def initialize(reservation_info)
@customer_name = reservation_info[:customer_nam... |
class Task < ActiveRecord::Base
belongs_to :project
def self.all_status
["Pending","Open","Closed","Completed","In Progress"]
end
def self.all_priorities
["Low","High","Medium"]
end
end
|
class NvsGoalsController < ApplicationController
before_filter :find_project
before_filter :authorize
before_filter :find_goaltypes , :expect => [:index,:show, :detroy]
# GET /nvs_goals
# GET /nvs_goals.json
def index
@nvs_goals = NvsGoal.all
respond_to do |format|
format.html # index.html.... |
feature 'sign up' do
scenario 'user can click sign up button' do
visit '/'
click_button('Sign Up')
expect(page).to have_content 'Enter your name'
expect(page).to have_content 'Enter your username'
expect(page).to have_content 'Enter your email address'
expect(page).to have_content 'Enter your ... |
# 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... |
# coding: utf-8
require 'natto/binding'
require 'natto/option_parse'
module Natto
require 'ffi'
# `MeCabStruct` is a general base class for `FFI::Struct` objects in
# the `Natto` module. Please refer to `mecab.h` in the source code
# distribution.
class MeCabStruct < FFI::Struct
# Provides accessor met... |
require 'lib/regex'
describe Regex do
context "vazia" do
before :each do
@r = Regex.new("")
end
it "deve aceitar uma string vazia" do
@r.should be_aceita ""
end
it "deve aceitar uma string 'ola'" do
@r.should be_aceita "ola"
end
end
context "caracter a" do
before ... |
# Cookbook Name:: oracle-instantclient
# Resource:: alien_convert
# Author:: David Kinzer <dtkinzer@gmail.com>
#
# Copyright (C) 2014 David Kinzer
#
# 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... |
module JavaClass
module Classpath
# An error in the classpath. The requested classfile could not be found.
# Author:: Peter Kofler
class ClassNotFoundError < IOError
attr_reader :classname
attr_reader :classpath
def initialize(classname, classpath=nil)
@classname ... |
Rails.application.routes.draw do
resources :order_books, only: %i[index create destroy]
root to: 'order_books#index'
end
|
class Movie < ActiveRecord::Base
has_many :movies_genres
has_many :genres, through: :movies_genres
belongs_to :user
validate :is_date_format
validates :title, :actors, :director, :description, presence: true
def build_movie_genres(params)
@movie = Movie.find(params[:id])
params[:movie][:genres].e... |
class FoosController < ApplicationController
before_action :set_foo, only: %i(show update destroy)
wrap_parameters :foo, include: ['name']
# GET /foos
def index
@foos = Foo.all
# render json: @foos
end
# GET /foos/1
def show
# render json: @foo
end
# POST /foos
def create
@foo = ... |
# encoding: UTF-8
class State < ActiveRecord::Base
has_many :cities
has_many :educational_institutions, through: :cities
def uf
self.acronym
end
end
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnspro... |
class Coupon < ApplicationRecord
include ActionView::Helpers::TextHelper
CODE_CHARACTER_SET = ('A'..'Z').to_a - ['O', 'I'] + ('1'..'9').to_a
CODE_LENGTH = 6
has_many :orders
belongs_to :product
validates :count, presence: true, if: -> { ratio.blank? }
validates :ratio, presence: true, if: -> { count.bl... |
class User < ActiveRecord::Base
validates :full_name, presence: { message: 'Name cannot be blank' }
validates :level, presence: { message: 'Level cannot be blank' }
end
|
require 'bundler/setup'
require 'json'
require 'socket'
require './sensortag.rb'
PUBLISH_INTERVAL = 60
LUX_THRESHOLD = 100
SOCKET_FILE = '¥0/pd_emitter_lite/device_user_0000001.sock'
log = Logger.new('logs/publish_socket.log')
def statement(ambient:, object:, humidity:, pressure:, lux:)
{
state: {
desire... |
class Concerns::ComplaintAjaxHelper
def self.custom_query_from(query_hash)
custom_query_hash = {}
custom_query_hash[:borough] =
borough_query_array_from(query_hash) if query_hash[:borough] != ""
custom_query_hash[:zip_code] =
zipcode_query_array_from(query_hash) if query_hash[:zip_code] != "... |
# When done, submit this entire file to the autograder.
# Part 1
def sum arr
arr.reduce(0, :+) # reduce is same as inject
end
def max_2_sum arr
sum arr.max 2
end
def sum_to_n? arr, n
arr.combination(2) { |x, y| return true if x+y == n }
false
end
# Part 2
def hello(name)
"Hello, #{name}"
end
def starts... |
#
# Cookbook Name:: fluentd
# Recipe:: default
#
# fluentdのインストール
bash 'td-agent install' do
code <<-EOH
curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh
EOH
user 'root'
end
template 'td-agent.conf' do
path '/etc/td-agent/td-agent.conf'
source 'td-agent_server.conf.erb'
ow... |
# frozen_string_literal: true
module Tikkie
module Api
module Resources
# Resource for a Sandbox App.
class SandboxApp < Base
def app_token
body[:appToken]
end
private
def create_resource(attributes)
request.post('sandboxapps', options, attributes... |
class NotificationsGrid
include Datagrid
Datagrid.configure do |config|
# Defines date formats that can be used to parse date.
# Note that multiple formats can be specified but only first format used to format date as string.
# Other formats are just used for parsing date from string in case your Ap... |
require 'test_helper'
require File.expand_path("../../../app/validators/phone_number_format_validator", __FILE__)
class TestModel
include ActiveModel::Validations
attr_accessor :phone_number
validates :phone_number, phone_number_format: true
end
class PhoneNumberFormatValidatorTest < ActiveSupport::TestCase
... |
class User < ActiveRecord::Base
validates_presence_of :username
validates_uniqueness_of :username
devise :registerable, :authenticatable, :recoverable, :rememberable, :trackable, :validatable
# , :confirmable
has_many :posts
has_many :comments
attr_accessor :username_or_email
private
def self... |
class DiagnosticProcedure < ActiveRecord::Base
validates_presence_of :description, :moment, :admission
belongs_to :admission
has_many :diagnoses, as: :owner
end |
require 'rails_helper'
describe SocialIdentity, 'Associations' do
it { should belong_to(:user) }
end
|
require_relative "../chores/ncr_organization_importer"
require_relative "../chores/ncr_work_order_organization_reassigner"
class NcrOrganizationsStringToRelation < ActiveRecord::Migration
def up
add_reference :ncr_work_orders, :ncr_organization, index: true
Ncr::WorkOrderOrganizationReassigner.new.run
... |
class Todo < ActiveRecord::Base
attr_accessible :description, :due_date, :notes, :parent_id, :position, :scheduled_at, :urgent
validates_presence_of :description
scope :projects, where(parent_id: nil)
belongs_to :parent, class_name: 'Todo', foreign_key: 'parent_id'
has_many :children, class_name: 'Todo', f... |
class EmailClient
def message(content = Message)
content.new
end
end
class Message
def send(to, body)
# Imagine I'm sending an email
end
end
class SayHelloToMyLittleFriend
def run(email_client = EmailClient)
email = email_client.new
email.message.send(
"friend@example.com",
"HELL... |
class LottiesController < ApplicationController
def index
@random = *(1..45)
@lotto_shake = @random.sample(6)
@lotto = @lotto_shake.sort
end
end
|
module CamaleonCms
module Widget
class Sidebar < CamaleonCms::TermTaxonomy
default_scope { where(taxonomy: :sidebar) }
has_many :metas, lambda {
where(object_class: 'Widget::Sidebar')
}, class_name: 'CamaleonCms::Meta', foreign_key: :objectid, dependent... |
class FontBitstreamVera < Formula
version "1.10"
sha256 "1b0ba0f7af2e1d05f64e259d351965a2cb2673104a057ce715a06969c478f6cc"
url "https://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/#{version}/ttf-bitstream-vera-#{version}.zip"
desc "Bitstream Vera"
homepage "https://www.gnome.org/fonts/"
def install
... |
#!/usr/bin/ruby
require './src/output.rb'
require './src/csv_parser.rb'
require './src/postfix_evaluator.rb'
if ARGV.length != 1
puts "\nScript expects exactly one parameter. The name of a file."
puts "\tExample: ./main.rb source.csv"
exit 1
end
filename = ARGV[0]
data = CsvParser.process(filename)
outp... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# A collection of projects for each type of toolset
#
class ToolsetProjects
# @return ... |
class Favorite < ApplicationRecord
belongs_to :user
belongs_to :brand
validates :user_id, uniqueness: { scope: :brand_id }
end
|
class Settings::UserPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.order(approved_at: :asc, created_at: :desc)
end
end
def index?
user.admin?
end
def approve?
user.admin?
end
def make_admin?
user.admin?
end
end |
class SubscribesController < ApplicationController
respond_to :js
authorize_resource
def create
@question = Question.find(params[:question_id])
respond_with (@subscribe = current_user.subscribes.create(question: @question))
end
def destroy
@subscribe = Subscribe.find(params[:id])
respond_wi... |
# typed: true
# frozen_string_literal: true
require 'test_helper'
module Ffprober
module Ffmpeg
class FinderTest < Minitest::Test
def test_finder
Ffprober::Ffmpeg::Finder.new
end
def test_executable_name
assert_equal 'ffprobe', test_finder.executable_name
end
end
e... |
class Section < ActiveRecord::Base
include Authority::Abilities
has_paper_trail ignore: [:created_at, :updated_at]
state_machine :state, initial: :hidden do
state :hidden
state :published
state :deleted
event :publish do
transition [:deleted, :hidden] => :published
end
event :hide... |
class MeetingRoom < Accommodation
validates :occupied, inclusion: { in: [ true, false ] }
end
|
Hogwartz::Application.routes.draw do
get '/' => 'houses#index'
end
|
require 'bcrypt'
class User < ActiveRecord::Base
include BCrypt
PRIVATE_ATTRIBUTES = %w(id password_digest)
before_create :set_defaults
validates :email, uniqueness: true, presence: true
def password
@password ||= Password.new(password_digest)
end
def password=(new_password)
@password = Pas... |
require 'rails_helper'
RSpec.describe CoursesController, type: :controller do
describe "#index" do
let!(:course_1) { create(:course) }
let!(:course_2) { create(:course) }
before do
get :index
end
it "verifica resposta" do
expect(response).to have_http_status(200)
expect(assign... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Pagination::ArrayConnection do
ARRAY_ITEMS = ConnectionAssertions::NAMES.map { |n| { name: n } }
class ArrayTestConnectionWithTotalCount < GraphQL::Pagination::ArrayConnection
def total_count
items.size
end
end
let(:schema) {... |
class ReviewsController < ApplicationController
def show
end
def new
@review = Review.new(product_id: params[:product_id])
if session[:merchant_id] == @review.product.merchant_id
flash[:status] = :error
flash[:result_text] = "Merchant can't leave reviews of their own products, sorry! Wink-wi... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/car'
require './lib/owner'
class OwnerTest < Minitest::Test
def setup
@owner_1 = Owner.new('Regina George', 'Heiress')
@car_1 = Car.new({description: 'Green Ford Mustang', year: '1967'})
end
def test_it_exists
assert_instance_of Owne... |
#########################################
# This class provided the methods to manage the execution of the plugins
#########################################
class PluginManager
attr_accessor :plugin_names
attr_accessor :plugin_result
#Stores and load plugins
def initialize(plugin_list,params,bbtools,data... |
FactoryGirl.define do
factory :article do
sequence(:id) {|n| %(doc_#{"%02d" % n}) }
title 'Default Title'
content 'na'
end
end
|
require 'nil/file'
require 'nil/serialise'
require_relative 'Player'
def createDatabase(databasePath)
output = []
puts 'Reading directory'
files = Nil.readDirectory('players')
puts 'Processing markup'
index = 1
files.each do |file|
data = Nil.readFile(file.path)
id = file.name.to_i
if index % ... |
# encoding: UTF-8
require 'rails_helper'
feature 'Product Details' do
stub_authorization!
given!(:store) { create(:store) }
background do
create(:store) unless Spree::Store.exists?
product = create(:product, name: 'Pikachu Chair', sku: 'A100', description: 'lorem ipsum', available_on: '2013-08-14 01:02:... |
class AddCompanyCodeToDevices < ActiveRecord::Migration
def change
add_column :devices, :company_code, :string
end
end
|
Gem::Specification.new do |s|
s.name = "s3-mysql-backup"
s.version = "2.2.3"
s.date = Date.today
s.summary = "Simple mysql backup to S3"
s.description = "A simple mysql backup to Amazon S3"
s.authors = ["Jeff Emminger"]
s.email = "jeff@7compass.com"
s.files ... |
class CreateCars < ActiveRecord::Migration[5.1]
def change
create_table :cars do |t|
t.string :gosnomer, :limit => 10, :null => false
t.string :region, :limit => 10
t.string :marka, :limit => 30, :null => false
t.boolean :istransit, :default => false, :null => false
t.timestamps
... |
Rails.application.routes.draw do
devise_for \
:users,
controllers: { registrations: "registrations", sessions: "sessions" }
devise_for \
:government_user,
controllers: { registrations: "government_users/registrations", sessions: "sessions" }
devise_for \
:product_owner,
controllers: { regi... |
# say_hello.rb
# Modify the code below so `"Hello!"` is printed 5 times.
say_hello = true
counter = 1 # my addition
while say_hello
puts 'Hello!'
counter += 1 # my addition
say_hello = false if counter > 5 # my addition
end
|
The following metasploit module will exploit this in order to read a file off of the file system:
##
## This module requires Metasploit: http//metasploit.com/download
## Current source: https://github.com/rapid7/metasploit-framework
###
require 'msf/core'
class Metasploit4 < Msf::Auxiliary
include Msf::Exploit::... |
require_relative 'spec_helper'
require_relative '../lib/Song'
describe Song do
before(:context) do
@song = Song.new "Song Name", 0.99
@song2 = Song.new "Another name", 1.99, 58
end
#check inilization
describe "Initialize" do
it "Initialize Name" do
expect(@song.name).to eq("Song Name")
end
... |
# frozen_string_literal: true
module GeoPattern
class Seed
private
attr_reader :seed
public
def initialize(string)
@seed = Digest::SHA1.hexdigest string.to_s
end
def [](*args)
seed[*args]
end
def to_i(index, length)
seed[index, length || 1].to_i(16)
end
en... |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'fog-aws'
class CapifyCloudwatch
# Threshold => color
# Color is applied if metric exceeds the threshold, KEEP IN ORDER
Colors = {
0 => :green,
70 => :yellow,
90 => :red
}
def initialize(key_id, secret)
@ticks = %w[▁ ▂ ▃ ▄ ▅ ▆ ▇]
@cw =... |
class AddTermsToSubscriptions < ActiveRecord::Migration
def change
add_column :subscriptions, :terms, :boolean
end
end
|
#= JpAddress
#
# Authors:: Nobukazu Matake (http://matake.jp)
# Version:: 0.2.2 2008-03-09 matake
# Copyright:: Copyright (c) 2008 Nobukazu Matake, All rights reserved.
# License:: MIT
#
#
#= このプラグインについて
# 日本郵便の公開している全国の郵便番号/住所データCSVファイルから、郵便番号/住所データベースを作成します。
# JpAddress専用のデータベースを作成し、
# Railsアプリ側から郵便番号による住所検索... |
json.array!(@events) do |event|
json.extract! event, :eventtype, :eventdate, :eventdateformat, :title, :content, :width, :height, :image, :images, :readmore, :speed, :eventurl
json.url event_url(event, format: :json)
end
|
# Abstraction for Actor pattern. Essentially, you can create various 'nodes' in
# your code that let you push or pull to 'tubes'. Those tubes are worked on my
# one or more other Actors.
#
# For BM3 the PDUs are Hashes that are serialized with MessagePack, but that's
# not coupled to this stuff.
#
# This is the higher ... |
RSpec.describe 'comparison matchers' do
it 'allows for comparison with built-in ruby operators' do
expect(10).to be > 5
expect(1).to be < 5
expect(2).to be <= 2
end
# Make object as the subject
context 100 do
it { is_expected.to be > 90 }
it { is_expected.to be >= 100 }
it { is_expected... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.