text stringlengths 10 2.61M |
|---|
$LOAD_PATH.unshift(File.join(__dir__, 'lib'))
require 'shanty/info'
# rubocop:disable Metrics/BlockLength
Gem::Specification.new do |gem|
gem.name = 'shanty'
gem.version = Shanty::Info::VERSION
gem.homepage = 'https://github.com/shantytown/shanty'
gem.license = 'MIT'
gem.authors = [
'Chris Jansen',
... |
class CreateRepairs < ActiveRecord::Migration
def change
create_table :repairs do |t|
t.integer :auto_id, null: false
t.decimal :fee, null: false, default: 0, precision: 6, scale: 2
t.string :name, null: false
t.string :serviceno, null: false
t.timestamps
... |
require 'rails_helper'
feature "Home Page" do
scenario "Homepage works" do
visit root_path
expect(page).to have_content("Welcome")
end
scenario "when sign in is clicked" do
visit root_path
click_link "Sign Up"
expect(page).to have_content "Register"
end
end
feature do
scenario do
... |
module OpenAssets
module Transaction
class TransactionBuilder
include OpenAssets::Util
# The minimum allowed output value.
attr_accessor :amount
# The estimated transaction fee rate (satoshis/KB).
attr_accessor :efr
def initialize(amount = 600, efr = 10000)
@a... |
Rails.application.routes.draw do
root to: "storms#index"
resources :storms, only: [:index, :show]
resources :drafts, only: [:new]
end
|
# frozen_string_literal: true
require 'json'
module ProxyPack
class App
class << self
def call(env)
request = Rack::Request.new(env)
case request.path
when '/proxy.pac'
[200, {}, [proxy_pac]]
else
[404, {}, []]
end
end
private
... |
# Storage backend that saves into files in a git working directory, and
# syncs it to an origin.
#
class GitStorage
delegate :redis, to: :RedisConnection
def initialize(root = GitSync.work_dir)
@root = Pathname.new(root)
end
def get(path, part)
sp = storage_path(path, part)
if File.exist?(sp)
... |
class CreativesController < ApplicationController
before_action :set_creative, only: [:show, :edit, :update, :destroy, :reorder_chapters]
before_action :check_rights, only: [:edit, :update, :destroy, :reorder_chapters]
before_action :reload_cache, only: [:update, :destroy, :reorder_chapters]
# GET /creatives
... |
class Manager
attr_accessor :name, :department, :age
@@all = []
def initialize(name, department, age)
@name = name
@department = department
@age = age
@@all << self
end
def self.all
@@all
end
def employees
Employees.all.select
end
... |
# encoding: UTF-8
module API
module V1
class Reports < API::V1::Base
helpers API::Helpers::V1::ReportsHelpers
# before do
# authenticate_user
# end
with_cacheable_endpoints :reports do
get :clear_all do
if Rails.env.production?
status 403
... |
Product.class_eval do
validates :reduction_percentage, :inclusion => { :in => 1..100, :message => I18n.t("value_between_1_and_100"), :allow_blank => true }
def calculated_price
self.master.calculated_price
end
end
|
class Question < ActiveRecord::Base
include RandomRecords
VARIANTS_COUNT = 4
belongs_to :category
has_many :answer_variants, inverse_of: :question
validates :category, :text, presence: true
validates :answer_variants, length: { is: VARIANTS_COUNT }
end
|
require 'rails_helper'
RSpec.describe StudentMailer do
describe "sending it" do
let(:address) { ['fake@faker.com'] }
let(:mail) { described_class.say_hi(address).deliver_now }
it "has a subject" do
expect(mail.subject).to eq("#holdmybeer")
end
it "has a recipeint" do
expect(mail.to... |
class Cmptyp < ActiveRecord::Base
self.table_name = "cmptyp"
self.primary_key = "cmptypid"
has_many :cmps
end
|
require 'json'
require File.join(File.dirname(__FILE__), '..', 'nexus_global_config')
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'nexus', 'config.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'nexus', 'exception.rb'))
require... |
require 'minitest/autorun'
require './square'
class TestSquare < Minitest::Test
def setup
@square = Square.new
end
def test_square_is_initially_empty
assert @square.empty?
refute @square.has_queen?.nil?
end
def test_placing_queen_changes_state
@square.place_queen!
assert @square.has_que... |
Rails.application.routes.draw do
get 'messages/new'
get 'password_resets/new'
get 'password_resets/edit'
root 'staticpages#home'
get '/help', to: 'staticpages#help'
get '/about', to: 'staticpages#about'
get '/contact', to: 'staticpages#contact'
# get '/signup', to: 'users#new'
ge... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "haml-i18n/version"
Gem::Specification.new do |s|
s.name = "haml-i18n"
s.homepage = "http://github.com/clemenshelm/haml-i18n"
s.license = "MIT"
s.version = Haml::I18n::VERSION
s.authors = ["Clemens Helm"]
s.email ... |
class Exam < ActiveRecord::Base
belongs_to :examination
belongs_to :user
belongs_to :examinee
has_many :solutions
scope :finished, -> { where(status: 20)}
# difficulty for a given theta
def self.difficulty(theta)
diff = (theta*2).round / 2.0
diff = diff < -3 ? -3 : 3 unless diff.between?(-3,3)
... |
class InterestsController < ApplicationController
def new
@user = current_user
@interest = @user.interests.new
render :new
end
def index
@interests = current_user.interests.all
end
def update
@interest = current_user.interests.find(params[:id])
@interest.update(interest_params)... |
class AddSubtitleToArticles < ActiveRecord::Migration[5.1]
def change
add_column :articles, :subtitle, :string
rename_column :articles, :cover_image_alt, :image_alt
end
end
|
class Api::ListItemsController < ApplicationController
def index
@list_items = ListItem.all
render "index.json.jb"
end
def show
list_item_id = params[:id]
@list_item = ListItem.find(params[:id])
render "show.json.jb"
# @list_items = list_item.find(params[:id])
# render "show.json.jb"
... |
feature 'users can log in' do
scenario 'user logs in with good credentials' do
sign_up
log_out
log_in
expect(page).to have_content '@realDonaldTrump'
end
end
|
class RemoveImageFromEvents < ActiveRecord::Migration
def change
remove_column :events, :image
end
end
|
class Stash < ApplicationRecord
def self.get key
value = Stash.where(key: key).limit(1).pluck(:value).first
value = DateTime.parse(value) if key.to_s.ends_with?('_at') && !value.nil?
value
end
def self.set key, value
Stash.find_or_create_by!(key: key).update_column(:value, value)
end
end
|
class Api::V1::CartedDrinksController < ApplicationController
before_action :authenticate_user!
def index
@carteddrinks = CartedDrink.all
end
end
|
require 'chemistry/element'
Chemistry::Element.define "Oxygen" do
symbol "O"
atomic_number 8
atomic_weight 15.9994
melting_point '50.5K'
end
|
Rails.application.routes.draw do
root to: "products#index"
get "search" => "products#search"
resource :products
end
|
#!/usr/bin/env ruby
require_relative 'manager/alteration/AlterationManager'
class Alteration
class << self
attr_accessor :manager
end
@manager = AlterationManager.instance
attr_accessor :feature
attr_accessor :type
attr_accessor :class_name
attr_accessor :field_name
attr_ac... |
#
# Copyright 2013, Seth Vargo <sethvargo@gmail.com>
# Copyright 2013, Opscode, 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
#
# Unl... |
module DataCleaner # :nodoc:
# DataCleaner::Format can be used to describe the format of an object's
# attributes.
#
# Example:
# f = DataCleaner::Format.new("Person")
# f.name [:first_name, " ", :last_name]
#
# You most likely do not want to use this class directly, but instead through
# DataCl... |
Pod::Spec.new do |s|
s.name = "apptentive-react-native"
s.version = "5.4.6"
s.summary = "Apptentive SDK module for React Native"
s.description = <<-DESC
React Native module for the Apptentive iOS SDK.
DESC
s.homepage = "https://github.com/apptentive/apptentive-re... |
class UserMailer < ApplicationMailer
default from: "vijayendran91@gmail.com"
def signup_confirmation(user)
@user=user
@greeting = "Hi"
mail to: user.email, subject: "Sign Up Confirmation"
end
end
|
class CompetitionInfo < ApplicationRecord
validates :competition_class, inclusion: {in: [1, 2]}
end
|
class Github::Repository
attr_reader :name,
:url,
:id
def initialize(args)
@name = args[:name]
@url = args[:html_url]
@id = args[:id]
end
end
|
# frozen_string_literal: true
RSpec.describe Api::V1::Admin::Videos::ShowAction do
let!(:video) { create(:video) }
let!(:current_user) { create(:user, :admin) }
let(:action) { described_class.new(context: {current_user: current_user}) }
describe '#call' do
subject(:call) do
action.call(input)
e... |
class RemoveUselessColumnsFromCampaigns < ActiveRecord::Migration[5.0]
def change
remove_column :campaigns, :sidekick_url
remove_column :campaigns, :need_details_scraping
end
end
|
# frozen_string_literal: true
class Image < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
attachment :file, type: :image
def url(size, *options)
imageable.get_url(self, size, *options)
end
# Generate a custom image URL.
#
# If the filename option is not given, the filename is taken fr... |
xml.instruct!(:xml, :version => "1.0")
xml.rss('version' => '2.0',
'xmlns:atom' => 'http://www.w3.org/2005/Atom',
'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/',
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/') do |xml|
xml.channel do |xml|
xml.title("#{@stream.title} - #{@... |
class WelcomeController < ApplicationController
def index
response.headers['Cache-Control'] = 'public, max-age=300'
end
end
|
class ChatMessage < ActiveRecord::Base
unloadable
include Redmine::I18n
belongs_to :issue
belongs_to :user
def as_json(options = {})
{
id: id,
issue_id: issue_id,
created_at: format_time(created_at),
user: user.name,
message: message
}
end
end
|
# frozen_string_literal: true
module RSpec
module Support
class Pusher
def trigger(channels, event, data)
@events ||= []
@events << {
channels: Array(channels),
event: event,
data: data.to_json
}
end
def authenticate(channel_name, socket_i... |
class OrdersController < ApplicationController
def index
@order = Order.new
@orders = Order.all
end
def create
Order.create(order_params)
redirect_to orders_path
end
def new
@order = Order.new
@orders = Order.all
end
def show
@order= Order.find(params[:id])
end
def update
o... |
require "pry"
class Song
attr_accessor :name, :artist
def initialize(name)
@name = name
end
def self.new_by_filename(filename)
# binding.pry
@artist = filename.split(/\ - /)[0]
@song_name = filename.split(/\ - |.mp3/)[1]
@song = Song.new(@song_name)
@artist = Artist.find_or_create_by_n... |
class Train
attr_reader(:name, :id)
define_method(:initialize) do |attributes|
@name = attributes.fetch(:name)
@id = attributes[:id]
@station_id = nil
end
define_singleton_method(:all) do
returned_trains = DB.exec("SELECT * FROM trains;")
trains = []
returned_trains.each do |train|
... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/conn'
require 'bolt_spec/run'
require 'bolt_spec/files'
# In order to speed up tests there are only ssh versions of these specs
# While the target shouldn't matter this does mean this helper is not tested on
# windows controllers.
describe "BoltSp... |
class ProductTypePlanSerializer
include FastJsonapi::ObjectSerializer
attributes :product_type, :quantity_type
attribute :sub_categories do |object, params|
if params[:product_categories].present?
record = params[:product_categories].find { |a| a['name'] == object.product_type }
record['package_... |
class Restaurant < ApplicationRecord
CATEGORIES = %w[chinese italian japanese french belgian].freeze
has_many :reviews, dependent: :destroy
validates :name, uniqueness: true, presence: true
validates :address, presence: true
validates :category, inclusion: {
in: CATEGORIES, message: CATEGORIES.join(' ').t... |
class Account < ApplicationRecord
belongs_to :customer, optional: true
validates :rountine_number, presence: true, uniqueness: true
validates :account_number, presence: true, uniqueness: true
end
|
require 'rails_helper'
RSpec.describe ItemsController, type: :controller do
describe 'GET #index' do
let!(:user) { create(:user) }
it "リクエストが成功する" do
get 'index'
expect(response.status).to eq 200
end
end
end
|
require 'rails_helper'
RSpec.describe OrdersController, type: :request do
it "retrieveByCust using Id" do
headers = {"CONTENT_TYPE" => "application/json",
"ACCEPT" => "application/json"}
Order.create(id: 100, itemId: 100, description: "salsa", customerId: 100, price: 10, award: 0, total:... |
class FontCode2002 < Formula
head "https://www.ffonts.net/Code2002.font.zip"
desc "Code2002"
homepage "https://www.ffonts.net/Code2002.font.download"
def install
(share/"fonts").install "CODE2002.TTF"
end
test do
end
end
|
class MagazinesController < ApplicationController
def index
@magazines = Magazine.all
end
def show
@magazine = Magazine.find(params[:id])
@magazine.view_counter += 1
@magazine.save
end
def new
@magazine = Magazine.new
@circles = Circle.all
@authors = Author.all
end
def edit... |
module FormulasHelper
def age_range(min_age, max_age)
age_class = if max_age && (min_age < 16) && (max_age < 16)
'Junior'
else
'Senior'
end
if max_age
"#{age_class} - #{min_age} - #{max_age}"
else
"#{age_class} - #{min_age} +... |
class CreateRealogyEntities < ActiveRecord::Migration[5.2]
def change
create_table :realogy_entities do |t|
t.string :type
t.string :entity_id
t.datetime :last_update_on
t.json :data
t.timestamps
end
add_index :realogy_entities, :type
add_index :realogy_entities, :entity... |
require 'rails_helper'
RSpec.describe "application_forms/index", type: :view do
before(:each) do
@job = assign(:job, Job.create!(name: "Software Engineer", description: "Best Job"))
assign(:application_forms, [
ApplicationForm.create!(
:name => "Name",
:email => "Email",
:addres... |
# frozen_string_literal: true
module Exceptions
class ExternalRequestFail < StandardError
end
end
|
class CreateRepresentatives < ActiveRecord::Migration[6.0]
def change
create_table :representatives do |t|
t.string :first_name
t.string :last_name
t.string :salutation
t.string :email
t.string :circonscription_ref
t.string :circonscription_num
t.string :city
t.stri... |
begin
require 'puppet_x/bodgit/postfix/util'
rescue LoadError
# :nocov:
require 'pathname'
require Pathname.new(__FILE__).dirname + '../../' + 'puppet_x/bodgit/postfix/util'
# :nocov:
end
Puppet::Type.newtype(:postfix_main) do
include PuppetX::Bodgit::Postfix::Util
@doc = 'Manages Postfix settings.
The... |
require 'spec_helper'
describe 'ECDSA.sign' do
it 'returns nil if r is zero' do
expect(ECDSA.sign(Davidp16d1, 333, 222, 1)).to eq nil
end
it 'returns nil if s is zero' do
group = ECDSA::Group::Secp112r2
private_key = 1
temporary_key = 1
r_point = group.new_point temporary_key
point_field... |
module AnnualReports
module UpdateWithStatistics
class Statistics
class CampaignsCount < Base
def total_value
@total_value ||= monthly_reports.sum(total_statistic_column)
end
def total_year_on_year_growth
method = "year_on_year_growth_for_#{total_statistic_column... |
# encoding: utf-8
require 'test_helper'
class MainControllerTest < ActionController::TestCase
test "index page without user" do
get :index, nil, nil
assert_response :success
assert assigns(:user).nil?
end
test "index page with user" do
get :index, {'id' => '1'}, {:signcode => "china", :user_id ... |
module Troles::Common::Macros
class Configuration
class BaseLoader
attr_reader :strategy, :orm
include ClassExt
def initialize strategy, orm
@strategy = strategy
@orm = orm || Troles::Config.default_orm
end
def singularity
(strategy =~ /_many$/) ? :... |
#encoding: utf-8
class SnsSessionsController < ApplicationController
require 'rest_client'
before_filter :login_required, :only => [:destroy]
def create
case params[:provider]
when "weibo"
@user = WeiboUser.find_or_create_from_auth_hash(auth_hash)
when "xiaonei"
@user = XiaoneiUser.find_o... |
require 'csv'
module Grocery
class Customer
attr_reader :id, :email, :address
def initialize id, email, address
@id = id.to_i
@email = email
@address = address
end
def self.all
all_customers = CSV.read("support/customers.csv").map do |customer|
Grocery::Customer.new(... |
Rails.application.routes.draw do
resources :articles
get 'static_pages/home'
get 'static_pages/about'
root 'static_pages#home'
end
|
class DeclareAwesomeSpotsJob < ApplicationJob
def perform
Spot.where("created_at >= ?", 12.hours.ago.utc).all.map do |spot|
if spot.votes_count > Spot::AWESOME_VOTES
spot.awesome = true
spot.save
end
end
end
end
|
class EditorVersion < ApplicationRecord
belongs_to :version
belongs_to :editor
end
|
class SelectIdiomFromLocale
def perform
locale_to_idiom[I18n.locale]
end
private
def locale_to_idiom
{
:en => 'English',
:'pt-BR' => 'Portuguese'
}
end
end
|
class ComitesController < ApplicationController
helper_method :sort_column, :sort_direction
def index
@rxp = (params[:registro])? params[:registro].to_i : 2
if ((@rxp) == 0) or ((@rxp) < 0) then
@rxp = 1
end
@comites = Comite.order(sort_column + " " + sort_direction).search(params[:search])... |
module Babushka
class DepDefiner
module Helpers
def result message, opts = {}
returning opts[:result] do
@dep.unmet_message = message
end
end
def met message; result message, :result => true end
def unmet message; result message, :result => false end
de... |
require 'csv'
class PatientRepository
def initialize(csv_file_path, room_repository)
@room_repository = room_repository
@csv_file_path = csv_file_path
@patients = []
@next_id = 1
load_csv
end
def add(patient)
# Give the patient an id!
patient.id = @next_id
@next_id += 1
@pati... |
require "application_system_test_case"
class MarcasTest < ApplicationSystemTestCase
setup do
@marca = marcas(:one)
end
test "visiting the index" do
visit marcas_url
assert_selector "h1", text: "Marcas"
end
test "creating a Marca" do
visit marcas_url
click_on "New Marca"
fill_in "No... |
module ValidatesEmailSanTest
module Initializer
def self.load_dependencies
require 'test/unit'
require 'active_support'
require 'active_support/test_case'
require 'active_record'
if const_defined?(:I18n) && I18n.respond_to?(:enforce_available_locales)
I18n.enfor... |
class Response < ApplicationRecord
belongs_to :respondable, polymorphic: true
belongs_to :question
end
|
raw_data = File.readlines(ARGV[0])
race_time = ARGV[1].to_i
class Reindeer
attr_reader :run_time, :rest_time, :speed, :name
def initialize(name, run_time, rest_time, speed)
@name = name
@run_time = run_time
@rest_time = rest_time
@speed = speed
end
def cycle_time
@cycle_time ||= run_time ... |
module Framework
class PlainRenderer < Renderer
def content_type
'text/plain'
end
end
end
|
class Deck
attr_reader :current_deck
SUITES = ["Spade", "Heart", "Diamond", "Club"]
VALUES = [2,3,4,5,6,7,8,9,10,11,12,13,14]
def initialize
@current_deck = Array.new
self.build_deck
end
def build_deck
SUITES.each do |suite|
VALUES.each do |value|
@current_deck << Card.new(suite... |
# frozen_string_literal: true
module V2
class ZoneCache < ApplicationRecord
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TextHelper
validates :code, :current_actives, :cumulative_infections, :cumulative_recoveries,
:cumulative_fatalities, :cumulative_tests, :as_of... |
require File.join(File.dirname(__FILE__), '..', '..', 'unit_test_helper')
# -----------------------------------------------------------------------------------------------
# Class Definition
# -----------------------------------------------------------------------------------------------
class IQ::Upload::Extensions::... |
class AddTrackModeratorsJoinTable < ActiveRecord::Migration
def change
create_join_table :users, :learning_tracks, table_name: :learning_track_moderators do |t|
t.references :user, index: true
t.references :learning_track, index: true
t.index [:user_id, :learning_track_id], unique: true, name: ... |
class Api::V1::Items::SearchController < ApplicationController
def index
return record_bad_request if invalid_params?
item = if params[:name]
Item.search_by_name(params[:name].downcase).first
else
Item.search_by_price(params[:max_price], params[:min_price])
end... |
module BCommerce
RSpec.describe Resource do
let(:resourceClass){ Class.new(Resource) }
let(:resource){ resourceClass.new }
let(:store_hash){ rand.to_s }
before do
BCommerce::Base.setup(client_id: 'id', store_hash: store_hash, auth_token: 'token')
resourceClass::API_VERSION = 'v3'
r... |
require 'test_helper'
class ImageTest < ActiveSupport::TestCase
test 'validates file' do
image = Image.new
refute image.valid?, 'file cannot be nil'
end
test 'valid image saved properlly' do
image = Image.new file: File.open('test/assets/happy.jpg'),
description: 'File description'
image.... |
# write a method that returns true if its integer argument
# is palindromic, false otherwise
# palindromes read the same forwards and backwards
# examples:
#
# palindromic_number?(34543) == true
# palindromic_number?(123210) == false
# palindromic_number?(22) == true
# palindromic_number?(5) == true
def palindromic_... |
# frozen_string_literal: true
module CandleSupport
def bidask(params = {})
time = params[:time] || Time.zone.parse('2019-06-12T00:00:00+0000')
time = time.utc
OandaAPI::Resource::Candle.new(
close_ask: params[:close_ask] || 108.550,
close_bid: params[:close_bid] || 108.550,
high_ask: pa... |
require_relative '../../../../spec_helper'
describe 'govuk_jenkins::package', :type => :class do
let(:params) {{
:version => '1.554.2',
}}
let(:facts) {{
:jenkins_plugins => 'fake_plugin 1.0'
}}
it { is_expected.to contain_class('jenkins').with(
'version' => '1.554.2',
... |
# encoding: utf-8
class User < ActiveRecord::Base
attr_accessor :password
has_many :user_messages, :order => "user_messages.id desc"
validates :login,
:presence => true,
:length => {:maximum => 16, :minimum => 1},
:uniqueness => true
validates :password,
:presence => true,
:conf... |
require 'byebug'
class Link
attr_accessor :key, :val, :next, :prev
def initialize(key = nil, val = nil)
@key = key
@val = val
@next = nil
@prev = nil
end
def to_s
"#{@key}: #{@val}"
end
end
class LinkedList
include Enumerable
def initialize
@head = nil
end
def [](i)
e... |
require 'rails_helper'
RSpec.describe 'new application page' do
it "has a place to " do
visit "/applications/new"
expect(find('form')).to have_content('Name')
expect(find('form')).to have_content('City')
expect(find('form')).to have_content('Street adress')
expect(find('form')).to have_content... |
foods = {
# key => value
'tomato' => 'veggie',
'grapes' => 'fruit',
'celery' => 'veggie',
'parsnip' => 'veggie',
'banana' => 'fruit'
}
puts foods
# sorting hashes
# don't do this
puts foods.sort.inspect
puts foods
numbers_hash = {
3 => "three",
1 => "one",
2 => "two"
}
# trying ... |
class RemoveObsoleteColumnsForOffers < ActiveRecord::Migration
def up
remove_column :offers, :title
remove_column :offers, :description
remove_column :offers, :slug
remove_column :offers, :quantity
remove_column :offers, :featured
end
def down
add_column :offers, :featured, :boolean
a... |
require './formula'
class OpenSSH
url 'http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_5.8p1-1ubuntu3.dsc'
md5 'cd5aabb2ae7aff9745be208378cb5381'
version '1:5.8p1-1ubuntu3+github1'
def patches
[
'mysql_patch_5.8-p1-1.patch',
'ubuntu-enable_mysql_keys.patch',
]
end
end
|
############################################################
# This section verifies start, stop, and restart after
# installation within a new EC2 instance spun up by Kitchen.
#
# - stop mongod so that we begin testing from a stopped state
# - verify start, stop, and restart
###########################################... |
class AddStepToEvents < ActiveRecord::Migration[5.2]
def change
add_column :events, :step, :integer, :default => 1
end
end
|
class Entry < ApplicationRecord
belongs_to :track
belongs_to :flag
belongs_to :user
acts_as_votable
def verb
"Added"
end
end
|
outer_array = [[[1, 2], [3, 4]], [[5, 6], [2]]]
def increment(arr)
arr.map do |sub_arr_1|
sub_arr_1.map do |item|
if item.to_s.size == 1 # item is an integer
item + 1
else # item is an array
item.map do |element|
element + 1
end
end
end
end
end
p incremen... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
MACHINES = {
:bckpsrv => {
:box_name => "centos/7",
:ip_addr => '192.168.11.150',
:ans_grp => "borgsrv",
:disks => {
:sata2 => {
:dfile => '../sata2.vdi',
:size => 2048,
:port => 2
... |
class App < ApplicationRecord
has_many :chats, dependent: :destroy, primary_key: 'token', foreign_key: 'app_token'
attribute :chats_count, :integer, default: 1
has_secure_token :token
validates_presence_of :name
end
|
module Facebook
GRAPH_API_URL = 'https://graph.facebook.com/'
class GenericException < StandardError; end
class BadRequestException < StandardError; end
def self.api_call(title, path, options={})
options[:retry_timeout] ||= 20
options[:limit] ||= 10000
response = ExternalResource.load( title, opti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.