text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
class PassingTestsController < ApplicationController
before_action :find_passing_test, only: %i[show result update gist]
before_action :refresh_flash_message, only: %i[update]
def show; end
def result; end
def update
if params[:answer_ids].blank?
flash[:alert] = t("... |
require 'sinatra/base'
require 'slim'
require 'rdiscount'
require 'json'
require 'sinatra-websocket'
class App < Sinatra::Base
set :server, 'puma'
set :sockets, []
def get_url_params_or_json
if request.content_type == 'application/json'
p = JSON.parse(request.body.read)
Hash[p.map { |k, v| [k.t... |
class Movie < ActiveRecord::Base
mount_uploader :image, ImageUploader
has_many :reviews
validates :title,
presence: true
validates :director,
presence: true
validates :runtime_in_minutes,
numericality: { only_integer: true }
validates :description,
presence: true
validates :poster_... |
class AddFieldsToItems < ActiveRecord::Migration[6.0]
def change
add_column :items, :slug, :string
add_column :items, :is_activated, :boolean
add_column :items, :recharge, :string
add_column :items, :character_filename, :string
add_column :items, :tear_filename, :string
end
end
|
class Dashboard::DiscussionsController < DashboardController
# before_filter :prime, :only => [ :new, :create, :edit, :update ]
def index
@title = "Discussions"
@discussions = Discussion.paginate(:page => params[:page])
end
def new
@discussion = Discussion.new
end
def create
@discussion... |
require 'spec_helper'
describe 'Logout' do
it 'redirects to home page after successful logout' do
login_as FactoryGirl.create(:user)
# any page with navigation that has logout
visit root_path
click_link 'Logout'
expect(page).to have_text('Signed out successfully.')
expect(page).to have_link... |
# Use the Remi repo for dev environments
if node['platform'] == 'centos'
# Add remi repo
include_recipe 'utils::add_remi_repo'
# Specify PHP 7.0 package names from Remi repo
node.default['php']['packages'].push( 'php72', 'php72-php-devel', 'php72-php-cli', 'php72-php-mbstring', 'php72-php-pear', 'php72-php-... |
class MembershipsController < ApplicationController
before_action :authenticate_user!, only: [:create]
def index
@project = Project.find(params[:project_id])
@members = @project.members
@task_count = @project.tasks.count
@disc_count = @project.discussions.count
@mem_count = @project.members.co... |
require 'singleton'
class Scheduler
include Singleton
WEEKLY = [ 7 ]
DAILY = [ 1 ]
def skip_to_dow(date, dow)
if dow.is_a? String
dow = Date::DAYNAMES.collect { |d| d.downcase }.index(dow.downcase)
end
if dow.is_a? Fixnum
while date.wday != dow
date += 1
end
end
... |
class EcotagecocompanyRelationship < ApplicationRecord
# n:m eco
belongs_to :eco_tag
belongs_to :eco_company
end
# == Schema Information
#
# Table name: ecotagecocompany_relationships
#
# id :integer not null, primary key
# eco_tag_id :integer
# eco_company_id :integer
# created_at ... |
# xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
# xml.artworkinfo do
# @coverflows.each do |coverflow|
# xml.albuminfo do
# xml.artLocation "../" + coverflow.cover.url(:thumb)
# xml.artist coverflow.cflow.title
# xml.albumName coverflow.cflow.title
# xml.artistLink "#{polymorphic_path(coverf... |
# frozen_string_literal: true
require 'rake'
require 'rake/testtask'
# Import external rake tasks
Dir.glob('lib/tasks/*.rake').each { |r| import r }
task default: %i[rubocop spec]
task :clean do
puts 'Cleaning old coverage.data'
FileUtils.rm_rf('coverage.data')
end
begin
require 'rubocop/rake_task'
RuboCop... |
require_relative 'piece'
class SteppingPiece < Piece
def initialize(pos, color, board)
super(pos, color, board)
end
DELTA_PER = [[1,0], [0,1], [-1,0], [0,-1]]
DELTA_DIAGONAL = [[1,1], [-1,1], [-1,-1], [1,-1]]
DELTA_KNIGHT = [ [2,1], [-2,1], [2,-1], [-2,-1], [1,2], [-1,2], [1,-2], [-1,-2] ]
DELTA_HASH... |
class DoublesController < ApplicationController
def index
doubles = Double.all
render json: doubles
end
def create
double = Double.create(double_params)
render json: double
end
def update
double = Double.find(params[:id])
double.update! double_params
render json: double
end
... |
class SessionsController < ApplicationController
def new; end
def create
@user = User.find_by(username: params[:username])
if @user
session[:user_id] = @user.id
redirect_to root_path, notice: 'Login successful, enjoy!'
elsif params[:username].empty?
redirect_to login_path, alert: 'Use... |
module SJCL
module BitArray
SMASK32 = (1 << 31) # Signed 32 mask
def self.bitSlice(arr, bstart, bend=0)
a = arr.dup
a = shiftRight(a.slice(bstart/32,a.length), 32 - (bstart & 31)).slice(1,a.length-1)
bend == 0 ? a : clamp(a, bend-bstart)
end
def self.extract(arr, bstart, blength)
... |
# spec/parsers/abstract_parser_helper.rb
require 'parsers/abstract_parser'
shared_examples_for Mithril::Parsers::AbstractParser do
describe :parse_command do
it { expect(instance).to respond_to :parse_command }
it { expect { instance.parse_command }.to raise_error ArgumentError,
/wrong number of argum... |
class Purchase < ActiveRecord::Base
attr_accessible :annotation, :item_id, :item_value, :payment_type, :status, :transaction_date, :transaction_id
belongs_to :customer
belongs_to :item
end
|
class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def create
@post = Post.new(permit_params)
if @post.save
redirect_to root_path, :notice => "Your post was saved"
else
... |
class UserQualification < ActiveRecord::Base
belongs_to :user
accepts_nested_attributes_for :user
has_many :user_qualification_licenses
has_many :user_licenses, :through => :user_qualification_licenses
attr_accessible :qualified_on, :expires_on, :maintenance_record, :user_license_ids, :user_approved, :u... |
require 'base64'
require 'openssl'
require 'rest-client'
require 'builder'
require 'hashie'
module Twoctwop
class Request
attr_accessor :data, :digest, :token
def initialize(data: {}, token: nil)
raise "Set end point" if Twoctwop::Config.endpoint.nil?
raise "Merchant ID is nil" if Twoctwo... |
require 'pp'
class MCollective::Application::Schedule<MCollective::Application
description "Wrapper for scheduling actions"
usage "Usage: mco schedule [options] action package [arguments]"
option :schedtype,
:description => "Schedule type : in, at, cron, every",
:arguments ... |
# frozen_string_literal: true
module ApplicationHelper
def title(string)
appname = Settings.app.name || 'shreds'
"#{string} · #{appname}"
end
def strdate(date)
date.strftime('%B %d, %Y %H:%M')
end
def full_url(path)
File.join(Settings.app.host.to_s, path.to_s)
end
def pretty_json(obj)
... |
require 'rails_helper'
feature 'user views a list of restaurants', %Q{
Visiting the /restaurants path should contain a list of restaurants.
} do
scenario "user views all restaurants" do
rest1 = Restaurant.create(
name: 'Foo Restaurant',
city: 'Foo City',
address: 'Foo Address',
state: ... |
require 'test/tem_test_case.rb'
class TemCryptoKeysTest < TemTestCase
def i_crypt_len(data_length, key_id, authz)
ex_sec = @tem.assemble { |s|
s.ldbc :const => 2
s.outnew
s.ldbc :const => key_id
s.authk :auth => :key_auth
s.ldwc :const => data_length
s.ldkel
s.outw
... |
RSpec.describe Web::Views::Goals::Index, type: :view do
let(:exposures) { Hash[goals: []] }
let(:template) { Hanami::View::Template.new('apps/web/templates/goals/index.html.erb') }
let(:view) { described_class.new(template, exposures) }
let(:rendered) { view.render }
let(:placeholder) { %(<p cl... |
# frozen_string_literal: true
module Dry
module Monads
# The List monad.
class List
class << self
# Builds a list.
#
# @param values [Array<Object>] List elements
# @return [List]
def [](*values)
new(values)
end
# Coerces a value to a l... |
# encoding: UTF-8
#
# Cookbook Name:: jenkins_utils
# Recipe:: default
#
# This recipe sets up a Jenkins CI master server and installs the plugins
# and packages required to use the LWRPs in this cookbook.
#
# Author:: David Schlenk <david.schlenk@spanlink.com>
# Copyright (C) 2014 Spanlink Communications
#
# Apache 2.... |
class AddCompletedToPlayerChallengesProgresses < ActiveRecord::Migration
def change
add_column :player_challenge_progresses, :completed, :boolean, :default => true
end
end
|
class ResultTime < ApplicationRecord
self.table_name = 'zeiten'
self.primary_keys = 'Regatta_ID', 'Rennen', 'Lauf', 'TNr', 'MesspunktNr'
belongs_to :regatta, foreign_key: 'Regatta_ID'
belongs_to :event, foreign_key: ['Regatta_ID', 'Rennen']
belongs_to :race, foreign_key: ['Regatta_ID', 'Rennen', 'Lauf']
b... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def initialize_twitter_client
Twitter::REST::Client.new do |config|
config.consumer_key = "hNJy... |
class BranchMenuCategory < ActiveRecord::Base
# relationships
has_and_belongs_to_many :menu_items,
class_name: "MenuItem",
join_table: "menu_categories_menu_items"
belongs_to :branch
belongs_to :menu_category
end
|
class Technology < ApplicationRecord
# Relationships
has_and_belongs_to_many :projects
# Uploaders
mount_uploader :icon, TechnologyIconUploader
# Validations
validates :name, presence: true
# Methods
def to_s
name
end
end
|
namespace :mamashai do
desc "提醒一周内没有记录的用户来记录"
task :remind_user_to_write => [:environment] do
offset = 0
users = User.all(:limit=>1000, :offset=>offset, :conditions=>"last_login_at < '#{Time.new.ago(7.days).to_s(:db)}'", :order=>"id asc")
while users.size > 0
for user in users
next if ... |
class Car
attr_accessor :ferrari
def initialize()
@ferrari = {wheel: 4, color: 'red', max_speed: 250}
end
def paint(color)
@ferrari[:color] = color
end
def driver(driver)
@ferrari[:driver] = driver
end
end
|
# encoding: utf-8
module ApplicationHelper
def site
{
:url => "http://2litra.ru",
:www => "www.2litra.ru",
:official_url => "2LITRA",
:title => "2LITRA. Отзывы о книгах. Описание книг, авторов, жанры",
:description => "Современная литература, отзывы о книгах, лучшие книги, классич... |
require "rails_helper"
feature "visitor can view loans by category" do
include_context("features")
scenario "from the navbar menu" do
visit "/loans"
click_on "Categories"
click_on "Test Category"
expect(current_path).to eq(category_path(category))
within(".header") do
expect(page).to h... |
class Point
class UpdateCollection < Trailblazer::Operation
step :create_or_update
def create_or_update(options, params:, **)
params[:points].each do |key, value|
key.start_with?('new') ? ::Point::Create.call(value) : ::Point::Update.call(value.merge!(id: key))
end
end
end
end
|
students = []
eye_colors = []
ages = []
heights = []
blood_types = []
File.open("student_data.csv").each do |line|
info = line.split(",")
students.push(info[0].strip)
eye_colors.push(info[1].strip)
ages.push(info[2].strip.to_i)
height = (info[3].strip.to_i * 12) + info[4].strip.to_i
heights.push(height)
blood_t... |
require 'sinatra/base'
require 'mustache/sinatra'
class Server < Sinatra::Base
register Mustache::Sinatra
set :root, File.join(__dir__, 'server')
set :mustache, {
views: File.join(root, 'views'),
templates: File.join(root, 'templates')
}
set :entries, proc { [ ] }
get '/' do
@entries = sett... |
require 'rake/testtask'
task :default => :test
Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
desc "Launch Kicker (like autotest)"
task :kicker do
puts "Kicking... (ctrl+c to cancel)"
exec "kicker -e rake test lib"
end
desc "Build a gem"
task :gem => [ :gem... |
require_relative '../spec_helper'
describe iptables do
it { should have_rule('-A FWR -m state --state RELATED,ESTABLISHED -j ACCEPT') }
it { should have_rule('-A FWR -p icmp -j ACCEPT') }
it { should have_rule('-A FWR -p tcp -m tcp --dport 22 -j ACCEPT') }
it { should have_rule('-A FWR -p tcp -m tcp --dport 80... |
class DinoSaur
RECOGNIZED_CSV_COLUMN_HEADERS = ["name", "genus", "carnivore", "weight", "walking", "period", "diet", "weight_in_lbs"]
MODEL_ATTRIBUTE_FIELDS = ["name", "weight", "diet", "locomotion", "period", "additional_info"]
attr_reader :name, :weight, :diet, :locomotion, :period, :additional_info
def init... |
class Publication < ActiveRecord::Base
has_many :articles
has_many :writers, through: :articles
end
|
module ApplicationHelper
def current_user_is_admin?
current_user && current_user.is_admin?
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up).push(:username, :avatar, :member, :profile, :works)
devise_parameter... |
class CreateAllDelegates < ActiveRecord::Migration
def change
create_table :all_delegates do |t|
t.integer :xml_id
t.integer :group_id
t.string :first_name
t.string :title
t.timestamps
end
add_index :all_delegates, :xml_id
end
end
|
class Location < ActiveRecord::Base
attr_accessible :codigo, :name
has_many :inventories
end
|
class Cart < ActiveRecord::Base
belongs_to :user
has_many :cart_items
end
|
module TagLib::ID3v1
# An ID3v1 tag.
class Tag < TagLib::Tag
# @return [Integer] the genre as a number
# @return [255] if not present
#
# @since 1.0.0
attr_accessor :genre_number
end
# @return [Array<String>] the ID3v1 genre list.
#
# @since 1.0.0
def genre_list
end
# @return [Ma... |
# stack_machine_interpretation.rb
# A stack is a list of values that grows and shrinks dynamically. In ruby, a
# stack is easily implemented as an Array that just uses the `#push` and `#pop`
# mehtods.
# A stack-and-register programming language is a language that uses a stack of
# values. Each operation in the langu... |
#
# Simple event handler for 'inter-module' evnts
#
# class Player
# include Eventable
#
# on :begin_turn, :survey_world
#
# def play_turn(...)
# trigger :begin_turn
# end
# end
#
module Eventable
def trigger(event, *args)
self.class.listeners[event].each do |method|
send method, *args
end... |
class Car < ApplicationRecord
belongs_to :user, optional: true
has_many :histories
end
|
# frozen_string_literal: true
class ApplicationController < ActionController::Base
def after_sign_in_path_for(_resource)
if current_user.role == 1
admin_users_url
elsif current_user.role == 2
student = Student.find_by(email: current_user.email)
student_path(student.id)
elsif current_use... |
module RateCalculatorSystem
class InputParser
LENDER = "Lender".freeze
RATE = "Rate".freeze
AMOUNT = "Available".freeze
attr_reader :input, :lenders
def initialize(input)
@input = input
@lenders = []
end
def parse
header = contents.shift
raise RateCalculatorSyste... |
Pod::Spec.new do |s|
s.name = "Injineer"
s.version = "1.0.1"
s.summary = "A dependency injection framework for Objective-C"
s.description = "Injineer is simpler than other DI frameworks for Objective-C but just as powerful. The framework introduces no dependencies in your code, so using it ... |
require 'sinatra'
require 'dm-core'
require 'dm-timestamps'
require 'dm-validations'
require 'dm-migrations'
require 'rest_client'
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/development.db")
class User
include DataMapper::Resource
belongs_to :group, :required => false
property :id... |
class PageItem < ActiveRecord::Base
attr_accessible :interactive_page, :position, :section, :embeddable
acts_as_list :scope => :interactive_page
belongs_to :interactive_page
belongs_to :embeddable, :polymorphic => true, dependent: :destroy
def toggle_hideshow_embeddable
embeddable.is_hidden = !embeddab... |
require 'spec_helper'
describe "/orders/show.html.erb" do
include OrdersHelper
before(:each) do
assigns[:order] = @order = stub_model(Order,
:name => "value for name",
:address => "value for address",
:email => "value for email",
:pay_type => "value for pay_type"
)
end
it "rend... |
class FontHindKochi < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/hindkochi"
desc "Hind Kochi"
homepage "https://fonts.google.com/specimen/Hind"
def install
(share/"fonts").install "HindKochi-Bold.ttf"
(share/"fonts").install "... |
class User < ActiveRecord::Base
attr_reader :password
validates :email, :session_token, presence: true, uniqueness: true
validates :password_digest, presence: { message: "Must have a password" }
validates :password, length: { minimum: 6 }, allow_nil: true
after_initialize :ensure_session_token
def self... |
class Registration < ApplicationRecord
belongs_to :event #gehört zu event
belongs_to :user
HOW_HEARD_OPTIONS = [
'Newsletter',
'Blog Post',
'Twitter',
'Other'
]
validates :user_id, presence: true #Der Name muss angegeben werden
#validates :email, format: { with: /(\S+)@(\S+)/ } #muss in dem For... |
class Genre < ApplicationRecord
# book genres
has_many :books, through: :book_genres
has_many :book_genres
end
|
# frozen_string_literal: true
class UpdateUsers < ActiveRecord::Migration[6.1]
def change
# Destroy all previously existing records since this table
# has never been used before (outside of testing)
User.all.destroy_all
end
end
|
#encoding: gb2312
# libauto.rb
# 作者:王政
# 描述:自动化测试接口
# 深圳市金溢科技股份有限公司版权所有, 保留一切权利
#require File.dirname(__FILE__)+"/ucore"
require File.dirname(__FILE__)+"/ucomm"
AUTO_CMD_READ = 1
AUTO_CMD_WRITE = 2
AUTO_CRC_0000 = 1
AUTO_CRC_FFFF = 0
#金溢DSRC自动化测试接口类函数
#这个类的函数没什么好说的,所有的函数,都是按照接口协议文档来做的
#如果不清楚,查看接口协议文档即可。
#要用这个接口时,... |
require 'motion_build/project'
require 'motion_build/rules'
describe MotionBuild::Rules::ParseLLVMBitcodeRule do
before :each do
@project = MotionBuild::Project.new("Hello World")
@project.config.override(:source_dir, Dir.mktmpdir)
@project.config.override(:build_dir, Dir.mktmpdir)
@r = MotionBuild:... |
class ApplicationController < ActionController::Base
protect_from_forgery
# before_filter :prepare_for_mobile
private
def after_sign_out_path_for(resource_or_scope)
new_user_session_path
end
def prepare_for_mobile
request.format = :mobile if mobile_device?
end
def mobile_device?
request.us... |
require 'hashie'
require 'rubycue'
require 'shellwords'
module CueSnap
class FileNotFound < StandardError; end
class MP3FileNotFound < FileNotFound; end
class CueFileNotFound < FileNotFound; end
class CueFileTooLarge < StandardError
def message
'Only cue files less than 1MB are allowed.'
end
en... |
class CreateRushClasses < ActiveRecord::Migration
def change
create_table :rush_classes do |t|
t.string :name
t.string :chapter
t.string :frat
t.integer :recruits_count
t.integer :admin_id
t.string :phrase
t.timestamps null: false
end
end
end
|
Pod::Spec.new do |s|
s.name = 'RooftopAmazonUtils'
s.version = '0.5.0'
s.summary = 'Rooftop Amazon utils for Apple platforms.'
s.description = 'Rooftop Amazon utils for Apple platforms.'
s.authors = 'RFTP Technologies Ltd'
s.homepage = 'https://www.rftp.io/'
s.license = { :type =... |
class ShortenedUrl < ApplicationRecord
validates :long_url, :short_url, presence: true, uniqueness: true
def self.random_code
long_url.map {|url| SecureRandom.urlsafe_base64(url)}
end
end
class SecureRandom
def self.urlsafe_base64(str)
end
end
|
namespace :setup do
desc 'Check to see if ImageMagick is insalled on the server'
task :imagemagick do
buffer = <<-IMAGEMAGICKCHECK
if ! rpm -qa | grep ImageMagick > /dev/null
then
echo
echo
echo -e '\e[31m\e[1m!!!!!!!! ERROR - ImageMagick Not Installed. Please install and try... |
def repeat(n)
if block_given?
n.times { yield}
else
raise ArugumentError.new("引数エラー")
end
end
repeat(4) { puts "呼び出し4回" }
|
require 'rails_helper'
RSpec.describe Game, type: :model do
let(:game) { FactoryBot.create(:game) }
it 'has a valid factory' do
expect(game).to be_valid
end
describe 'validations' do
it { should validate_presence_of(:home_team) }
it { should validate_length_of(:home_team).is_equal_to(3) }
it { ... |
require 'json'
require 'date'
class Car
attr_reader :id, :price_per_day, :price_per_km
def initialize params
@id = params['id']
@price_per_day = params['price_per_day']
@price_per_km = params['price_per_km']
end
end
class Rental
attr_reader :id
def initialize params
@id = params['id']
... |
# Copyright 2007-2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
require 'spec_helper'
describe Walrat::ParsletChoice do
before do
@p1 = 'foo'.to_parseable
@p2 = 'bar'.to_parseable
end
it 'hashes should be the same if initialized with the same parseables'... |
class PostSerializer < ActiveModel::Serializer
has_many :comments
has_one :user
embed :ids, :include => true
attributes :id, :content, :project_id
# oembed metadata
attributes :title, :description, :original_url, :thumbnail_url, :html
def user
object.user
end
end
|
class ClientsGrid
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 App uses... |
class Board
attr_accessor :full_board
def initialize
@full_board = (1..3).map{|x| (1..3).map{|y|(BoardCase.new(x,y))}}
end
def get_case(position)
full_board[position[0] - 1][position[1] - 1]
end
def insert(player, position)
if (get_case(position).content != nil)
... |
class Adder
def initialize(shift)
@shift = shift
end
def method_missing(meth_name)
res = /^plus(?<plus_num>\d+)$/.match(meth_name) # Looks for methods of the form plusN, where N is an integer
if res.nil?
raise(NoMethodError, "Undefined method " + meth_name.to_s + " for " + self.class.to_s)
else
plu... |
# frozen_string_literal: true
class TimeFrameGroup < ActiveRecord::Base
has_many :time_frames, inverse_of: :group, foreign_key: :group_id
validates :label,
presence: { if: -> { respond_to?(:label) } },
uniqueness: { if: -> { respond_to?(:label) } }
validates :group_date, presence: true
scope :enabled... |
class AddColumnToPrescriptions < ActiveRecord::Migration
def change
add_column :prescriptions, :course_length, :string
end
end
|
require 'selenium-webdriver'
RSpec.configure do |config|
config.before do |example|
test_name = example.full_description
sauce_username = "<SAUCE_USERNAME>"
sauce_access_key = "<SAUCE_ACCESS_KEY>"
sauce_url = "https://" + sauce_username + ":" + sauce_access_key + "@ondemand.saucelabs.com:443/wd/hub"... |
require "hello_world/engine"
require "active_support"
module HelloWorld
def self.exec
puts "Hello World!"
end
end
|
class AccountsController < ApplicationController
before_action :authenticate_account!, except: :create
def create
account = Account.new(permitted_params)
return render_json(account.errors.to_h, 400) unless account.save
token = JwtStorage.generate_token!({ account_id: account.id }, account.id)
re... |
require "test_utils"
describe "parse syslog" do
extend LogStash::RSpec
config File.read(File.join(File.dirname(__FILE__), "logstash-indexer.conf"))
sample("message" => "<164>Oct 26 15:19:25 1.2.3.4 %ASA-4-106023: Deny udp src DRAC:10.1.2.3/43434 dst outside:192.168.0.1/53 by access-group \"acl_drac\" [0x0, 0x0... |
class CreateFinancialThirdServices < ActiveRecord::Migration
def change
create_table :financial_third_services do |t|
t.string :name
t.timestamps null: false
end
FinancialThirdService.create([
{name: 'Coleta'},
{name: 'Entrega'},
{name: 'PAC - AR'},
{name: 'Sedex - AR'},
{name: 'Sedex 10 - ... |
class Twtxt < Formula
desc "Decentralised, minimalist microblogging service for hackers"
homepage "https://github.com/buckket/twtxt"
url "https://github.com/buckket/twtxt/archive/v1.2.3.tar.gz"
sha256 "73b9d4988f96cc969c0c50ece0e9df12f7385735db23190e40c0d5e16f7ccd8c"
revision 2
bottle do
cellar :any_sk... |
#you run the script with an argument - the name of a file
filename = ARGV.first
#prints out this
puts "We're going to erase #{filename}"
puts "If you don't want that, hit CTRL-C (^C)."
puts "If you do want that, hit RETURN"
#accepts user input of any key
$stdin.gets
#it tells you it will open the file for writing (a... |
class FixTypeInUrls < ActiveRecord::Migration
def change
rename_column :urls, :type, :urls_type
end
end
|
class Chef
class Provider
class File
class Copy < Chef::Provider::File
def compare_content
checksum(@current_resource.path) == checksum(@new_resource.content)
end
def updated_by_last_action
end
def set_content
unless compare_content
backup... |
# # Binary Secret Handshake
# > There are 10 types of people in the world: Those who understand binary, and those who don't.
# You and your fellow flatirons are of those in the "know" when it comes to binary decide to come up with a secret "handshake".
# ```
# 1 = wink
# 10 = double blink
# 100 = close your eyes
... |
class AddTestOwnerReferenceToTestBlogs < ActiveRecord::Migration[5.2]
def change
add_reference :test_blogs, :test_owner, foreign_key: true
end
end
|
#!/usr/bin/ruby
# This returns either true or false
File.file?( 'test.txt' )
|
class AddMiddleNameAndBioToContacts < ActiveRecord::Migration
def change
add_column :contacts, :middle_name, :string
add_column :contacts, :biography, :text
end
end
|
require 'time'
require 'openssl'
require 'itunes_receipt_decoder/decode/base'
require 'itunes_receipt_decoder/public_key'
##
# ItunesReceiptDecoder
module ItunesReceiptDecoder
##
# ItunesReceiptDecoder::Decode
module Decode
##
# ItunesReceiptDecoder::Decode::UnifiedReceipt
class UnifiedReceipt < Base... |
require 'firebase'
class NotifierPlugin
include Cinch::Plugin
listen_to :channel
timer 60, method: :clear
match /notify ([\w-]+) *(.+)*/i, method: :notify
match /alarm (\d+) *(.+)*/i, method: :alarm
def initialize()
@ignore_list = []
@firebase = Firebase.new
end
def listen(m)
nick = m.use... |
class LongestConsecutiveSequence
def initialize(array_of_numbers)
@numbers = array_of_numbers
raise ArgumentError if array_of_numbers.empty?
end
def run
sorted_numbers = @numbers.uniq.sort
longest_secuence, count = 1
sorted_numbers.each_with_index do |num,i |
(num.to_i - 1 == sorted_nu... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
module Supersaas
class Slot < BaseModel
attr_accessor :count, :description, :finish, :id, :location, :name, :start, :title
attr_reader :bookings
def bookings=(value)
if value.is_a?(Array)
@bookings = value.map {|attributes| Supersaas::Appointment.new(attributes) }
else
@bookin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.