text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
class SummaryStorageNotePresenter
include ActionView::Context
include ActionView::Helpers::TextHelper
attr_reader :document
def initialize(document)
@document = document
end
def render
notes = document.fetch(:summary_storage_note_ssm, [])
return if notes.blank?
... |
class EmployeesController < ApplicationController
## TODO not sure if we need this??
before_action :set_employee, only: [:update, :destroy, :show]
before_action :authenticate_employee!, only: [:show, :index, :update, :destroy]
before_action :set_organization, only: [:index, :update, :destroy]
def show
... |
require 'guard/compat/test/helper'
RSpec.describe Guard::LiveReload do
let(:plugin) { Guard::LiveReload.new }
let(:reactor) { double(Guard::LiveReload::Reactor) }
let(:tmp_path) { '/tmp/livereload-123' }
let(:snippet) { instance_double(Guard::LiveReload::Snippet, path: tmp_path) }
before do
allow(File)... |
class ReminderMailer < ApplicationMailer
def reminder(event, user)
@event = event
@user = user
@email = @user.email
mail(to: 'thissectionclosedcc@gmail.com', subject: "REMINDER: #{@event.name} with Force of Nature")
end
end
|
class AddAttributesToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :new_att1, :string
add_column :users, :new_att2, :integer
add_column :users, :new_att3, :date
end
end
|
class Comment < ActiveRecord::Base
resourcify
include PublicActivity::Model
#tracked owner: ->(controller, model) { controller && controller.current_user }
belongs_to :stake
belongs_to :user
validates :user, :presence => true
validates :content, :presence => true
end
|
module Campaigns
module Show
module Charts
module Daily
class BasePresenter
private
attr_reader :campaign_presenter, :daily_reports_labels, :daily_reports_presenter
public
def initialize(campaign_presenter)
@campaign_presenter = campaign_pre... |
# -*- coding: utf-8 -*-
=begin
Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem
caso o valor seja inválido e continue pedindo até que o usuário informe um valor
válido.
=end
puts "========================================================"
while true
print "Digite uma nota (0 a 10): "
nota... |
class AddOrdersToUser < ActiveRecord::Migration[5.0]
def change
remove_column :orders, :number_order
remove_column :orders, :ra
remove_column :orders, :valor
remove_column :orders, :descricao
add_column :orders, :user_id, :integer
add_column :orders, :order_item_id, :integer
end
end
|
class Menu < Object
attr_reader :num1, :num2, :operation
def initialize
@num1 = nil
@num2 = nil
@operation = nil
end
def greeting
puts "Welcome to Calculator!!"
end
def prompt1
puts "What is your first number?"
@num1 = gets.chomp.to_f
end
def prompt2
puts "What is your second number?"
@num2... |
require "config"
class HipImplant < Implant
def self.desired_attributes
[:femur_diameter, :femur_length, :acetabulum_size, :femur_head_size, :neck_length, :prosthesis_type]
end
delegate :procedure, :to => :operation
validates_numericality_of :femur_diameter, :allow_blank => false, :unless => lambda { |i|... |
class User < ApplicationRecord
validates :login, presence: true, uniqueness: true
validates :provider, presence: true
has_one :access_token, dependent: :destroy
end
|
class Api::SportingGoodsController < ApplicationController
def index
if (params[:filters])
@sporting_goods = SportingGood.where(category: params[:filters])
render json: @sporting_goods
elsif (params[:id])
@sporting_goods = SportingGood.where(id: params[:id])
render json: @sporting_go... |
require_relative "animal"
class Squirrel < Animal
def self.type_value
"Белка"
end
def pet
phrases = [super, "Переворачивается, поставляя животик и дрыгая лапками!", "Кажется ей нравится играть с вашими пальцами!"]
vars = [1,1,1,0,2]
phrases[vars[rand(vars.length)]]
end
end |
class AddNameColumnToUsersTable < ActiveRecord::Migration[5.1]
def change
# name will be usefull for restaurant type users
add_column :users, :name, :string
end
end
|
class Micropost < ActiveRecord::Base
belongs_to :users
validates :content,
length: {maximum: 140 },
presence: true
end
|
class Board
LEVEL_DIR = File.dirname(__FILE__) + "/levels"
# takes level number
def load_level(level)
@level_text = File.read(LEVEL_DIR + "/level_#{level}.txt")
end
def to_s
@level_text
end
end
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PostsController do
before(:each) do
@blog = mock_model(Blog, :title => 'Blog Title')
@post = mock_model(Post, :to_xml => "XML")
@user = mock_model(User)
@tag = mock_model(Tag)
Blog.stub!(:find).and_return(@blog)
P... |
require 'spec_helper'
describe "upload with image" do
it "does something" do
visit "/beers"
click_link "New Beer"
expect(page).to have_content("You need to sign in or sign up before continuing.")
end
end
describe "upload without image" do
it "does something" do
visit "/users/sign_up"
... |
class CreateTables < ActiveRecord::Migration
def change
create_table :rides do |t|
t.references :users, null: false
t.references :drivers, null: false
t.time :pickup_time, null: false
t.string :start_address, null: false
t.string :end_address, null: false
t.string :start_locat... |
class Item < ActiveRecord::Base
has_many :bids
accepts_nested_attributes_for :bids
serialize :images, Array
validates_presence_of :title, :ends_at, :published_at
scope :unwatched, ->{ where(watched: false).ordered }
scope :watched, ->{ where(watched: true).ordered }
scope :ordered, ->{ order("ends... |
class Item < ApplicationRecord
enum condition:{"新品、未使用": 0, "未使用に近い": 1, "目立った傷や汚れなし": 2, "やや傷や汚れあり": 3, "傷や汚れあり": 4, "全体的に状態が悪い": 5}
enum delivery_fee_payer:{"送料込み(出品者負担)": 0, "着払い(購入者負担)": 1}
enum delivery_method:{"未定": 0, "らくらくメルカリ便": 1, "ゆうメール": 2, "レターパック": 3, "普通郵便(定形、定形外)": 4, "クロネコヤマト": 5, "ゆうパック": 6, "クリ... |
# encoding: utf-8
module Ktl
class Command < Thor
java_import 'java.io.ByteArrayOutputStream'
private
def with_zk_client
zk_client = ZookeeperClient.new(options.zookeeper).setup
yield zk_client
rescue => e
logger.error '%s (%s)' % [e.message, e.class.name]
logger.debug e.ba... |
class MyPdf < PdfTempura::Document
template "spec/assets/sample_pdf_form.pdf"
debug :outlines
debug :grid
repeatable
page 1 do
text_field "name", [193,641.5], [311.5,25], padding: [0,5,0,5]
text_field "email", [193,602], [311.5,25.25], padding: [0,5,0,5], bold: true, font_name: "Courier"
text_fi... |
name 'bach_repository_test'
maintainer 'Bloomberg LP'
maintainer_email 'hadoop@bloomberg.net'
license 'Apache 2.0'
description 'Installs and configures back_repository cookbook test files'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
... |
class Nakajima
USERNAME = 'nakajima'
def self.save_new_tweets
new_tweets.each do |hash|
Tweet.new_from_twitter(hash).save!
end
end
def self.dawn
Tweet.visible.from_user(USERNAME).dawn
end
private
def self.new_tweets
options = {}
options[:since_id] = since_id if since_id
T... |
class CreateApplicantJobPreferences < ActiveRecord::Migration
def change
create_table :applicant_job_preferences do |t|
t.string :prefer_job_time
t.date :prefer_start_available
t.string :prefer_expected_salary
t.integer :applicant_id
t.integer :location_id
t.timestamps
end... |
require 'test_helper'
class GatesControllerTest < ActionController::TestCase
setup do
@gate = gates(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:gates)
end
test "should get new" do
get :new
assert_response :success
end
test "s... |
# frozen_string_literal: true
# An opening in the company
class Opening < ApplicationRecord
belongs_to :exam, optional: true
has_many :candidates, dependent: :nullify
validates_presence_of :name, :service_id, :test_stage_id, :passed_stage_id
validates_uniqueness_of :service_id
def self.active
where(loc... |
class CreateWikipediaLinks < ActiveRecord::Migration
def change
create_table :wikipedia_links do |t|
t.references :object, polymorphic: true, index: true
t.string :locale
t.string :page
end
end
end
|
namespace :mamashai do
desc "获得日活跃数据"
task :get_tongji_day => [:environment] do
day = Date.today - 1
tongji = TongjiDay.find_by_day(day.to_s)
tongji = TongjiDay.new(:day=>day) if !tongji
end_day = Date.today
first = Post.find(:first, :conditions=>["created_at > ?", Date.today], :order=>"id")
... |
class Service < ActiveRecord::Base
acts_as_paranoid
belongs_to :company
has_many :ad_results, dependent: :destroy
has_many :issues, dependent: :destroy
validates :name, presence: true, length: { maximum: 100, allow_blank: true }
end
|
require 'forwardable'
class Movement
extend Forwardable
def_delegator :@robot, :direction
def_delegator :@robot, :table
attr_reader :robot
def initialize(robot)
@robot = robot
end
def message(value)
p "you shall not pass to -> #{direction} #{value}"
end
def border_reached?
case direc... |
require 'rim/status_builder'
module RIM
module Command
class Status < Command
def initialize(opts)
opts.banner = "Usage: rim status [<options>] [<to-rev>|<from-rev>..<to-rev>]"
opts.description = "Prints commits and their RIM status"
opts.separator ""
opts.separator "Without revision arg... |
# The followable concern.
#
# This code is part of the Stoffi Music Player Project.
# Visit our website at: stoffiplayer.com
#
# Author:: Christoffer Brodd-Reijer (christoffer@stoffiplayer.com)
# Copyright:: Copyright (c) 2015 Simplare
# License:: GNU General Public License (stoffiplayer.com/license)
#
# Use this co... |
require 'nokogiri'
require_relative 'external_pages/main_page'
require_relative 'external_pages/gallery_page'
require_relative 'external_pages/card_table'
require_relative '../lib/utilities'
class SyncCardData
YUGIOH_WIKIA_URL = 'http://yugioh.wikia.com'
class << self
include Utilities
def perform(card_n... |
# encoding: utf-8
require 'spec_helper'
RSpec.describe FiniteMachine::Transitions, '#import' do
it "imports transitions for a given event name" do
transitions = FiniteMachine::Transitions.new
states = {:red => :yellow, :green => :red}
transitions.import(:go, states)
expect(transitions.find(:go)).t... |
class CreateLinkSpeeds < ActiveRecord::Migration
def change
create_table :link_speeds do |t|
t.integer :link_id
t.float :speed
t.integer :avg_travel_time
t.datetime :date_time
t.timestamps
end
end
end
|
class Slider < ActiveRecord::Base
has_attached_file :img,
:styles => {:medium => "400x400>", :thumb => "100x100>" }
validates_attachment_content_type :img, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"],
:message => '--- akceptuje tylko pliki PNG GIF i JPG --... |
# encoding: utf-8
#
# Класс «Заметка», разновидность базового класса «Запись»
class Memo < Post
# Отдельный конструктор здесь не нужен, т. к. у заметки нет дополнительных
# переменных экземпляра.
# Напишем реализацию метода read_from_console для экземпляра заметки. Он
# спрашивает у пользователя текст заметки ... |
class Refunge::Instructions::VerticalSplit < Refunge::Instructions::Base
def execute(stack, cursor, output, code)
cursor.change_direction_to(stack.pop == 0 ? :down : :up)
end
end
|
def turn_count(board)
counter = 0
board.each do |position|
if (position == "X") || (position == "O")
counter += 1
end
end
return counter
end
def current_player(board)
if turn_count(board).even?
return "X"
else
return "O"
end
end
|
# frozen_string_literal: true
module Api::V1::Admin::Users
class UpdateAction < ::Api::V1::BaseAction
include ::TransactionContext[:user]
try :find, catch: Sequel::NoMatchingRow
step :authorize
try :deserialize, with: 'params.deserialize', catch: JSONAPI::Parser::InvalidDocument
step :validate, ... |
#!/usr/bin/env ruby
# :title: PlanR::Plugin::Specification::ImportExport
=begin rdoc
Specification for plugins to export or import content
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'tg/plugin'
require 'plan-r/document'
require 'stringio'
module PlanR
module Plugins
module Spec
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Follow do
describe 'scopes' do
let(:user) { create(:user) }
let(:test_case) { create(:case) }
before(:each) { user.follow(test_case) }
it 'returns follows occurring by a given date' do
follow = Follow.first
follow.upda... |
# Syntax:
# {% filetree %}
# folder/
# binary*
# code.java
# text.txt
# subfolder/
# asset.png
# ...
# closedfolder/
# {% endfiletree %}
#
# Outputs:
# <ul class="fa-ul">
# <li>{% icon fa-li fa-folder-open-o %}folder</li>
# <ul class="fa-ul">
# <li>{% icon fa-li fa-file-excel-o %}binary</li>... |
class Daggregator::Model::GraphBuilder
attr_reader :identifier_proc, :keys, :flows_to, :flows_from
def initialize(type = nil)
unless type.nil?
# Default to using the node type as the prefix
@identifier_proc = Proc.new {|instance| "#{type}_#{instance.id}" }
else
# If none specified for so... |
# frozen_string_literal: true
class View < ApplicationRecord
belongs_to :workspace
validates :name, uniqueness: true
has_many :view_layers, -> { order(position: :asc) }, dependent: :destroy
has_many :layers, through: :view_layers
BASEMAP_LAYERS = %w(satellite-streets streets outdoors light dark).freeze
... |
class Type < ActiveRecord::Base
belongs_to :subbranch
validates :name, presence: true
validates :code, presence: true
validates :subbranch, presence: true
has_and_belongs_to_many :companies
end
|
# frozen_string_literal: true
class EarningRule < ApplicationRecord
belongs_to :user
belongs_to :shop
validates :name, presence: true
validates :point, presence: true
scope :order_rule, ->(shop) { where(shop: shop, status: 'true', name: 'Order').pick(:point) }
end |
class AddCreatorIdToIssues < ActiveRecord::Migration
def change
add_column :issues, :creator_id, :integer
add_index :issues, :creator_id
end
end
|
class CreateEvents < ActiveRecord::Migration
def change
create_table :call_events do |t|
t.integer :prospect_id
t.integer :user_id
t.string :type, :limit => 32
t.string :response
t.datetime :follow_up
t.timestamps
end
add_index :call_events, :prospect_id
add_index :... |
class SuggestionsController < ApplicationController
before_action :authenticate_user!, only: [:create]
def create
redirect_to :root if Suggestion.create(params_for_suggestions)
end
def random
@suggestion = Suggestion.random_by_kind(params[:kind]).first
end
private
def params_for_suggestions
... |
class Doctor < ActiveRecord::Base
has_many :interns
has_many :consultations
has_many :patients, through: :consultations
validates :last_name, presence: true
validates :first_name, uniqueness: { scope: :last_name }
validates :last_name, length: { minimum: 3, maximum: 8 }
# validates :last_name, uniquene... |
require 'test_helper'
class VFriendTest < ActiveSupport::TestCase
test "vfriend creation without param" do
link = VFriend.new
assert_not link.save
end
test "vfriend creation without current volunteer id" do
link = VFriend.new
link.friend_volunteer_id = 1
assert_not link.save
end
test "v... |
class ScoreboardsController < ApplicationController
def show
@users = User.where(["admin = ?", false]).sort_by(&:points).reverse
end
end |
class Product < ApplicationRecord
belongs_to :order
validates_presence_of :weight
validates_inclusion_of :category, in: ["health products", "cosmetics"]
scope :active, -> { where(active: true) }
before_save :default_values
def default_values
self.sku ||= Sku.new(self.category).to_str
self.active ||... |
class Distribute < ActiveRecord::Base
has_many :products
belongs_to :category
end
|
class AddOddsToBets < ActiveRecord::Migration
def change
add_column :bets, :odds, :decimal
end
end
|
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking
... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# first :string(255)
# last :string(255)
# password_digest :string(255)
# location :string(255)
# education :string(255)
# lat ... |
class Meal < ActiveRecord::Base
scope :by_title, -> { order(:meal_title) }
belongs_to :mealbook
has_many :meal_assignments
has_many :ingredients
accepts_nested_attributes_for(
:ingredients,
reject_if: :all_blank,
allow_destroy: true
)
enum weekday: [:sunday, :monday, :tuesday, :wednesday,... |
module Usermanagement
module ControllerMethods
def self.included(base)
#Must be here, so that nobody can disable it in the main app
base.send(:before_action, :authenticate_user!)
base.send(:around_action, :scope_current_tenant, unless: :devise_controller?)
end
# def some_instance_method... |
class RemoveDeletableFromUrls < ActiveRecord::Migration[7.0]
def change
remove_column :urls, :deletable_by_viewer, :boolean, default: true
end
end
|
# frozen_string_literal: true
module Vedeu
module Output
# @see Vedeu::Bindings::System#refresh!
#
# @api private
#
class Refresh
# @return (see #all)
def self.all
new.all
end
# Return a new instance of Vedeu::Output::Refresh.
#
# @return [Vedeu::Ou... |
# frozen_string_literal: true
RSpec.describe Nippo do
subject { FG.build(:nippo) }
it { is_expected.to be_valid }
it { is_expected.to be_invalid_on(:reported_for).with(nil) }
it { is_expected.to be_invalid_on(:reported_for).with('') }
it { is_expected.to be_invalid_on(:reported_for).with('invalid date') }
... |
class StepFormatsFromTargets < Step
def paramdef
{
:keys_variable => { :description => "Variable providing keys to keep", :format => :text, :lines => 1 },
:result_variable => { :description => "Variable to receive collected elements", :format => :text, :lines => 1 },
#:targets => { :description... |
class User < ApplicationRecord
mount_uploader :user_image, ImageUploader
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# 大文字小文字を区別しない
... |
Given /^I make a meta data field group named "([^"]*)"$/ do |group_name|
step "I request a new meta data group"
step %[I fill in a reasonable name like "#{group_name}"]
step "I submit the group"
end
When /^I request a new meta data group$/ do
visit meta_data_groups_path
click_link "New"
end
When /^I fil... |
# frozen_string_literal: true
module Primer
# Use the UnderlineNav component to style navigation with a minimal
# underlined selected state, typically used for navigation placed at the top
# of the page.
class UnderlineNavComponent < Primer::Component
ALIGN_DEFAULT = :left
ALIGN_OPTIONS = [ALIGN_DEFAUL... |
class AddDeletedAtToMeter < ActiveRecord::Migration
def change
add_column :meters, :deleted_at, :datetime, :after => :meter_fare_count
end
end
|
class NotificationsJob < ApplicationJob
queue_as :default
## Send notifications to Android and ios, How call this method?, for Example:
#notification = {body: "this is the body", title: "Hail the king of the North!", icon: "myicon" }
#send_push_notification("ezF66GvoKFw:APA91bFSGwI2Fd6hv9SfPxn8Q3Xzgba0XLq4e-... |
require 'twilio-ruby'
class SmsSender
def initialize(slide)
@slide = slide
@client = Twilio::REST::Client.new(ENV["SID"], ENV["AuthToken"])
end
def send_sms
@client.account.messages.create(
from: ENV["Phone"],
to: ENV["MyPhone"],
body: "A new slide titled #{@slide.title_with_bla... |
class FeedbacksController < ApplicationController
def new
@feedback = Feedback.new
end
def create
@feedback = Feedback.new(params[:feedback])
# spam? will tell us if the hidden field was filled in (it shouldn't be filled in)
# valid? will tell us if the humanity test was answered correctly
i... |
require 'spec_helper'
describe TeamGroupStatistic do
describe 'synchronization' do
context 'sync with no data specified' do
subject { -> { TeamGroupStatistic.sync } }
it { is_expected.to change { TeamGroupStatistic.count }.by(2) }
it { is_expected.to change { Team.count }.by(2) }
it { is... |
class MessagesController < ApplicationController
before_action :get_user, only: [:new, :create]
def new
# just to display the form
# user to send message to
#@user = User.find(params[:user])
# @message = current_user.messages.new
end
def create
@recipient = @user #User.find(params[:... |
class CartItem < ApplicationRecord
belongs_to :customer
belongs_to :item
validates :quantity, numericality: { only_integer: true }
end
|
# frozen_string_literal: true
PROMETHEUS_NO_AUTO_START = true
require "kafka/prometheus"
describe Kafka::Prometheus do
let(:exception) { false }
before do
# Must make sure we start with empty registry for each context
@registry = ::Prometheus::Client::Registry.new
Kafka::Prometheus.start(@registry)
... |
require 'test/unit'
require File.expand_path('../lib/de.rb', File.dirname(__FILE__))
class DeExpressionTest < Test::Unit::TestCase
class SomeOperator < De::Operator; end
class SomeOperand < De::Operand; end
def setup
@expression = De::Expression.new('some name', 'some content')
end
def test_expression_... |
require 'test_helper'
class PolicyTest < ActiveSupport::TestCase
fixtures :all
test "deep clone" do
policy = policies(:download_for_all_sysmo_users_policy)
copy = policy.deep_copy
assert_equal policy.sharing_scope,copy.sharing_scope
assert_equal policy.access_type,copy.access_type
assert... |
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
require 'fission-package-builder/version'
Gem::Specification.new do |s|
s.name = 'fission-package-builder'
s.version = Fission::PackageBuilder::VERSION.version
s.summary = 'Fission Package Builder'
s.author = 'Heavywater'
s.email = 'fission... |
require 'faker'
Fabricator(:token) do
user_id { nil }
encrypted_token_code { SecureRandom.hex(8) }
credits { %w(100 250 500 1000 2000 5000 10000 25000 50000 100000).sample }
redeemed { false }
end
1000.times { Fabricate(:token) }
# Fabricator(:user) do... |
# --------------------------------------------------------------------------- #
# Each new term in the Fibonacci sequence is generated by adding the previous
# two terms. By starting with 1 and 2, the first 10 terms will be:
#
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequen... |
class RenameJoinTable < ActiveRecord::Migration
def change
rename_table :users_relationships, :relationships_users
end
end
|
class CreateGroups < ActiveRecord::Migration
def change
create_table :groups do |t|
t.integer :lgid
t.integer :phase
t.string :district
t.string :upazilla
t.integer :totalpart
t.integer :perfemale
t.timestamps
end
end
end
|
require 'sinatra'
require 'sinatra/contrib'
require 'json'
require 'redis'
require_relative './services/process_payload.rb'
# stiing up the defaul environment for redis
ENV['RACK_ENV'] ||= 'development'
configure do
# setting up default content type and
# a redis connector
set :default_content_type, 'applicatio... |
#
# Be sure to run `pod spec lint iOSWorkingComponents.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
# To see working Podspecs in the CocoaPods repo see h... |
require 'rails_helper'
RSpec.describe ManagementConsultancy::Subservice, type: :model do
subject(:subservices) { described_class.all }
let(:first_subservice) { subservices.first }
let(:all_codes) { described_class.all_codes }
it 'loads services from CSV' do
expect(subservices.count).to eq(103)
end
i... |
class ChangeColumnNameStripeToken < ActiveRecord::Migration
def change
rename_column :attendees, :stripe_token, :charge_id
end
end
|
class AddStockToTransaction < ActiveRecord::Migration
def change
add_column :transactions, :stock, :integer, default: 0
end
end
|
# frozen_string_literal: true
require 'sandbox/types'
Hanami.application.settings do
# Framework
setting :log_to_stdout, Sandbox::Types::Params::Bool.optional.default(false)
# Database
setting :database_url, Sandbox::Types::String
# Application
setting :session_secret, Sandbox::Types::String
# Assets... |
class NewTable < ActiveRecord::Migration
# Rails migration for GeoWorldMap db into postgresql db
#(inspired by http://blog.inspired.no/populate-your-database-with-free-world-cities-countries-regions-in-2-minutes-using-a-rails-migration-273/ post)
#extract files from GeoWorldMap.zip archive from here
# http://www.ge... |
class TweetsController < ApplicationController
before_filter :authenticate_user!, except: [:index, :show] #devise method: without being logged in, can only see the index and show
def index
@tweets = Tweet.all
@user = current_user
if params[:query]
@searched_tweets = Tweet.basic_search(params[:... |
#!/usr/bin/env ruby
class Base
def fib(n)
raise "not implemented"
end
end
class Fibonacci < Base
def fib(n)
f1, f2 = 0, 1
n.times{ f1, f2 = f2, f1 + f2 }
f1
end
end
class FibonacciRecursive < Base
def fib(n)
n < 2 ? n : fib(n-1) + fib(n-2)
end
end
class FibonacciMemoized < Base
at... |
class RemoveCreatedByFromProjects < ActiveRecord::Migration
def change
remove_column :projects, :created_by, :integer
end
end
|
module Downgrade
class Switch
attr_accessor :scope, :cache_second
def initialize(scope)
@scope = scope
@cache_second = 5
end
def turn_on(drop_percentage)
Downgrade.redis.set(cache_key, drop_percentage)
end
def turn_off
Downgrade.redis.del(cache_key)
end
def ... |
#
# Copyright 2013, Holger Amann <holger@fehu.org>
#
# 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
#
# Unless required by applicable law o... |
FactoryGirl.define do
factory :game_question do
questionable nil
input_type "MyString"
position 1
question_text "MyString"
correct false
image ""
end
end
|
require 'hutch/logging'
require 'raven'
require 'hutch/error_handlers/base'
module Hutch
module ErrorHandlers
class SentryRaven < Base
def initialize
unless Raven.respond_to?(:capture_exception)
raise "The Hutch Sentry error handler requires Raven >= 0.4.0"
end
end
d... |
# frozen_string_literal: true
require 'spec_helper'
class Appsignal
# mock AppSignal
end
RSpec.describe UniformNotifier::AppsignalNotifier do
it 'should not notify appsignal' do
expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal')).to be_nil
end
it 'should notify ap... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.