text stringlengths 10 2.61M |
|---|
# Palindromic Numbers
def palindrome?(input)
input.reverse == input
end
def real_palindrome?(string)
palindrome?(string.downcase.gsub(/[^a-z,0-9]/, ''))
end
def palindromic_number?(number)
real_palindrome?(number.to_s)
end
|
class CreateFixityCheckResults < ActiveRecord::Migration[5.1]
def change
create_table :fixity_check_results do |t|
t.references :cfs_file, foreign_key: true
t.integer :status, null: false, index: true
t.datetime :created_at, null: false, index: true
end
end
end
|
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username, unique: true, null: false
t.string :geekhack_username, unique: true
t.string :email, null: false, unique: true
t.string :stripe_customer_id
t.string :password_digest, nul... |
require 'rails_helper'
describe "doctors", type: :feature do
before do
@meredith = Doctor.create({name: "Meredith Grey", department: "Internal Medicine"})
@bart = Patient.create(name: "Bart Simpson", age:10 )
Appointment.create(appointment_datetime: DateTime.new(2016, 01, 11, 20, 20, 0), patient_id: 1, d... |
class FlatironBase
attr_accessor :base_uri, :data, :table
def initialize(base_uri)
@firebase = Firebase::Client.new(base_uri)
@table = @firebase.get("").body.keys[0] #defaults to first table in database
puts "Database accessed. Defaulted to first table. (#{@table})"
end
def swap_table(table_nam... |
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
describe Attributor::Integer do
subject(:type) { Attributor::Integer }
context '.example' do
context 'when :min and :max are unspecified' do
context 'valid cases' do
it "returns an Integer in the range [0,#{Attributor::Integer::... |
module ClientAuth
class Signer
attr_reader :client_name, :payload
def initialize(method, path, params = {})
@method = method.upcase
@path = path
@payload = params
end
attr_writer :payload
def headers
raise NotImplementedError, 'Client name not configured' unless client_n... |
require 'rails_helper'
RSpec.describe Category, type: :model do
before { @category = build(:category) }
subject { @category }
it { should respond_to(:category_name) }
it { should be_valid }
describe 'when category name is not present' do
before { @category.category_name = ' ' }
it { ... |
module Rack
module DevMark
module Theme
class Base
def initialize(options = {})
raise RuntimeError, 'Abstract class can not be instantiated' if self.class == Rack::DevMark::Theme::Base
@options = options
end
def insert_into(html, env, params = {})
end
... |
require_relative 'oystercard'
class Journey
PENALTY_FARE = 6
def fare
PENALTY_FARE
end
def entry_station(station)
station
end
def exit_station(station)
station
end
def complete?
false
end
end
|
RSpec::Matchers.define :be_a_migration do
match do |file_path|
dirname, file_name = File.dirname(file_path), File.basename(file_path)
if file_name =~ /\d+_.*\.rb/
migration_file_path = file_path
else
migration_file_path = Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}$/).first
... |
class User < ActiveRecord::Base
require 'digest'
include BCrypt
# Remember to create a migration!
has_many :whispers
has_many :stalker_relationships, class_name: "Stalking",
foreign_key: "stalkee_id"
has_many :stalkee_relationships, class_name: "Stalking",
foreign_key: "stalker_id"
has_many :sta... |
class AddScrubsAndFilenameToListPulls < ActiveRecord::Migration
def self.up
add_column :list_pulls, :scrubs, :text
add_column :list_pulls, :filename, :string
end
def self.down
remove_column :list_pulls, :scrubs
remove_column :list_pulls, :filename
end
end
|
require 'RESTClient'
require 'date'
module GithubManager
include RESTClient
@@current_organization = {}
RESTClient.set_base_url("https://api.github.com")
def current_organization
@@current_organization
end
def create_org(name)
response = RESTClient.make_request('GET', "/orgs/#{name}"... |
require 'rails_helper'
RSpec.configure do |c|
c.include Features::ControllerMacros
end
xdescribe PaymentsController do
describe '#create' do
it 'calls pay_order on the order model and returns success' do
login
order = create(:order)
allow(Order).to receive(:find).
with(order.id.to_s)... |
# encoding: utf-8
require "spec_helper"
describe Refinery do
describe "OurOffices" do
describe "Admin" do
describe "pcares_events", type: :feature do
refinery_login_with :refinery_user
describe "pcares_events list" do
before do
FactoryGirl.create(:pcares_event, :cat... |
#!/usr/bin/env ruby
# Assign variables which change per project or in testing
#
@irc_channel=ENV['IRC_CHANNEL']
github_project_url = "https://github.com/user/repo"
# Assign variables which are the same for every project
#
@project=ENV['JOB_NAME']
@build=ENV['BUILD_NUMBER']
@url=ENV['BUILD_URL']
@commit=ENV['GIT_COMMI... |
# frozen_string_literal: true
# Category model Class
class Category < ApplicationRecord
has_many :category_jimen, dependent: :destroy
has_many :jimen, through: :category_jimen
end
|
class AddColumnTypeConceptToConcept < ActiveRecord::Migration
def change
add_column :concepts, :type_concept, :string
add_column :concepts, :status, :integer
end
end
|
class RenameTokenSecretToSecret < ActiveRecord::Migration[5.0]
def change
rename_column :users, :token_secret, :secret
end
end
|
class RenameFriendsInFriendships < ActiveRecord::Migration[5.1]
def change
rename_column :friendships, :friends_id, :friend_id
end
end
|
class Bid < ApplicationRecord
belongs_to :bidder, class_name: "User", foreign_key: :user_id
belongs_to :card
end
|
class CreateMaintasks < ActiveRecord::Migration
def change
create_table :maintasks do |t|
t.references :equipment, index: true
t.string :task
t.integer :period
t.string :unit
t.timestamps
end
end
end
|
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'jquery-rails'
gem 'pg'
gem 'devise'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'twitter'
gem 'subdomainbox'
gem 'uuidtools'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails'
g... |
class AddTempleToCar < ActiveRecord::Migration
def change
add_reference :cars, :temple, index: true, foreign_key: true
end
end
|
class CountriesDatatable
delegate :params, :h, :link_to, to: :@view
include Rails.application.routes.url_helpers
include ActionView::Helpers::OutputSafetyHelper
def initialize(view)
@view = view
end
def as_json(options = {})
{
sEcho: params[:sEcho].to_i,
iTotalRecords: Country.count,... |
require 'rails_helper'
RSpec.describe ClientPayment, :ledgers do
it 'creates years' do
Timecop.travel('2014-6-1') do
payment = described_class.query
expect(payment.years).to eq %w[2014 2013 2012 2011 2010]
end
end
describe '#accounts_with_period' do
it 'selects account that have charges ... |
require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "git-ticket"
gem.summary = %Q{Checkout, create, delete or list ticket branches}
gem.description = gem.summary
gem.email = "reinh@reinh.com"
gem.homepage = "http://github.com/reinh/git-ticket"
ge... |
# Write your code here.
katz_deli = []
def line(current_line)
index = 0
line_message = ""
if current_line == []
line_message = "The line is currently empty."
puts line_message
return
end
while index < current_line.length do
if index == 0
message = "The line is currently: " + (index +... |
helper = Module.new do
def current_account
current_user.account
end
def current_user
# HACK: I can't access session variables easily, but there are other ways how to get what I want :)
begin
# provider side
username = find(:css, '#user_widget .username', visible: :all).text(:all).strip
... |
require "global/globalDef"
require "global/tagAttribute"
module Jabverwock
using StringExtension
using ArrayExtension
using SymbolExtension
#this class manage html tag
class TagManager
attr_accessor :name, :tagAttribute, :isSingleTag, :closeStringNotRequire, :tempOpenString, :tempCloseString
attr_... |
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
## Validation tests
test "product attributes must not be empty" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
... |
dir = File.dirname(__FILE__)
$: << File.expand_path("#{dir}")
require "json"
require "util"
class Schema
def initialize(h={})
@schema=Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
@schema.merge! JSON.parse(h.to_json) # ensures consistent string keys
@values = []
@keys = []... |
require_relative 'command_line_helpers'
class Recluse < BasicObject
def initialize(message)
@message = message
end
def inspect
"Recluse.new(#{@message.inspect})"
end
def method_missing(name, *)
::Kernel.raise "Tried to invoke the method `#{name}`. #@message"
end
end
CommandLineHelpers.make_p... |
require 'm2r/request'
module M2R
# Mongrel2 Request Parser
# @api public
class Parser
# Parse Mongrel2 request received via ZMQ message
#
# @param [String] msg Monrel2 Request message formatted according to rules
# of creating it described it m2 manual.
# @return [Request]
#
# @api ... |
class CreateMessages < ActiveRecord::Migration[6.1]
def change
create_table :messages do |t|
t.string :sender_type
t.integer :sender_id
t.string :receiver_type
t.integer :receiver_id
t.text :content
t.references :conversation, null: false, foreign_key: true
t.timestamps
... |
class PresentationTrack < Track
after_create { |t| app_session.complete if complete? }
def file_extension
'mp4'
end
def upload local_file
storage.upload local_file
end
def thumbnail
@thumbnail ||= Thumbnail.new "#{filename}.thumbnail.jpg"
end
def exists?
storage.exists?
end
def ... |
class Mailer < ActionMailer::Base
default from: "from@example.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.mailer.send_email.subject
#
def send_new_entry(entry, current_user)
@greeting = "Hi"
#@current_user = current_user.entries
@... |
class Notification < ApplicationRecord
enum tag: [ :job, :other ]
belongs_to :administrator
validates :title, :content, :tag, presence: true
validates :title, length: { maximum: 30 }
validates :content, length: { maximum: 500 }
validates :tag, correct_tag: true
class << self
def select_notificatio... |
class LostFound < ActionMailer::Base
default from: "sunny1304.ad@gmail.com"
def find_notification(found_item)
@found_item = found_item
mail(:to => @found_item.email, :subject => "found item notification")
end
def lost_notification(lost_item)
@lost_item = lost_item
mail(:to => @lost_item.email, :su... |
class CreateExpenseProducts < ActiveRecord::Migration
def change
create_table :expense_products do |t|
t.string :name
t.float :unit_cost_price
t.integer :quantity
t.references :expense, index: true, foreign_key: true
t.timestamps null: false
end
end
end
|
class Writer < ActiveRecord::Base
has_many :characters, dependent: :destroy
has_many :locations, dependent: :destroy
validates_uniqueness_of :handle, :password, :icon
end |
# frozen_string_literal: true
require 'rake/extensiontask'
require 'rspec/core/rake_task'
spec = Gem::Specification.load('aes256gcm_decrypt.gemspec')
Rake::ExtensionTask.new('aes256gcm_decrypt', spec)
desc ''
RSpec::Core::RakeTask.new(:spec) do |task|
task.pattern = './spec/**/*_spec.rb'
end
desc 'Compile extensi... |
require "mongoid_sortable_tree/engine"
module MongoidSortableTree
module Tree
extend ActiveSupport::Concern
included do
include Mongoid::Tree
include Mongoid::Tree::Ordering
include Mongoid::Tree::Traversal
field :text, :type => String
field :icon, :type => String
field :l... |
require 'rails_helper'
RSpec.describe "cards/show", :type => :view do
before(:each) do
@card = assign(:card, Card.create!(
:fname => "Fname",
:lname => "Lname",
:card_number => 1
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Fname/)
expect(rende... |
class Bicycle
def initialize( color, tire_size = nil)
@color = color
@tire_size = tire_size
end
def to_s
"Color : #{@color} | Object_id : #{self.object_id}"
end
def color
@color
end
def tire_size
@tire_size
end
end
raise StandardError.new("Bikes should have colors")... |
require "./workers/update_all"
require 'pry' if ENV["RACK_ENV"] == "development"
require 'sinatra'
require "rack/cors"
use Rack::Cors do |config|
config.allow do |allow|
allow.origins '*'
allow.resource '*',
:headers => :any
end
end
def lookup(name, ref="master")
Sidekiq.redis do |redis|
if ... |
#encoding: utf-8
module OrdersHelper
def convert_status(status)
result = ""
case status
when "unpay"
result = "未付款"
when "payed"
result = "已付款"
when "checked"
result = "已入住"
when "canceled"
result = "已取消"
else
result = "未知"
end
result
end
end
|
class ReferralType < ActiveRecord::Base
belongs_to :company
serialize :referral_sub_category , Array
scope :specific_attributes , ->{ select("id, referral_source, referral_sub_category")}
scope :active_referral_type, ->{ where(status: true)}
validates :referral_source , presence: true
validates_each :ref... |
# input: integer
# output: integer (next featured number that is greater than input)
# rules:
# featured number is odd number that is multiple of 7, whose digits occur once each (133 is invalid because 3 appears twice)
# return next featured number that is greater than input integer
# has to satisfy 3 conditions for it... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
unless user.id.nil?
can :create, Event
end
can :read, Event
can [:update, :destroy, :create_shift], Event, user: {id: user.id}
can :read, Shift
can [:create, :update, :destroy, :view_volunteers], Shift... |
# frozen_string_literal: true
require "uri"
module Sentry
class DSN
PORT_MAP = { 'http' => 80, 'https' => 443 }.freeze
REQUIRED_ATTRIBUTES = %w(host path public_key project_id).freeze
attr_reader :scheme, :secret_key, :port, *REQUIRED_ATTRIBUTES
def initialize(dsn_string)
@raw_value = dsn_st... |
require 'spec_helper'
describe 'line_items', :type => :request do
before (:each) do
user = User.create(:email => "email@example.com",
:password => "my_secure_password")
visit "/users/sign_in"
fill_in "Email", :with => user.email
fill_in "Password", :with => user.passwo... |
class League < ActiveRecord::Base
has_many :user_leagues
has_many :requests
has_many :users, through: :user_leagues
validates :name, presence: true ,:uniqueness => true
after_create :join_url
def join_url
self.url = rand(36**5).to_s(36)+self.id.to_s
self.save
end
def self.search(search)
if se... |
# encoding: UTF-8
class BillsController < ApplicationController
include BillsHelper
# Filter
before_filter :authenticate_user!
# before_filter :add_breadcrumb_index
load_and_authorize_resource
def index
@customers = Customer.where(:user_id => current_user.id)
params[:search] ||= {}
@bills = ... |
class DataSetSource < ApplicationRecord
validates_presence_of :name
validates_uniqueness_of :name
has_many :data_sets
def to_s
name
end
end
|
class Topic < ActiveRecord::Base
acts_as_taggable_on :keyword
acts_as_votable
belongs_to :user
belongs_to :board
has_many :comments , dependent: :destroy
default_scope -> { order('updated_at DESC') }
validates :title, presence: true, length: { maximum: 150 }
validates :user_id, presence: true
validates :board... |
require 'spec_helper'
describe 'wlp::server', :type => :define do
let(:pre_condition) { 'class {"::wlp": install_src => "/tmp/wlp-javaee7-16.0.0.2.zip"}' }
context 'supported operating systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end... |
class AddAttendeeTypeFields < ActiveRecord::Migration
def self.up
add_column :attendee_types, :type, :string
add_column :attendee_types, :type_description, :text
end
def self.down
drop_column :attendee_types, :type, :string
drop_column :attendee_types, :type_description, :text
end
end
|
require 'baby_squeel/resolver'
require 'baby_squeel/join'
require 'baby_squeel/join_dependency'
module BabySqueel
class Table
attr_accessor :_on, :_table
attr_writer :_join
def initialize(arel_table)
@_table = arel_table
end
# See Arel::Table#[]
def [](key)
Nodes::Attribute.new(... |
require 'test_helper'
class Asciibook::Converter::InlineImageTest < Asciibook::Test
def test_convert_inline_image
doc = <<~EOF
image:http://example.com/logo.png[]
EOF
html = <<~EOF
<p><img src="http://example.com/logo.png" alt="logo" /></p>
EOF
assert_convert_body html, doc
end
... |
require 'ostruct'
require 'optics-agent/instrumenters/field'
require 'graphql'
include OpticsAgent
describe "connection" do
it 'collects the correct query stats' do
person_type = GraphQL::ObjectType.define do
name "Person"
field :firstName do
type types.String
resolve -> (obj, args, ... |
#!/usr/bin/env ruby
require 'slack-notifier'
#
# author: Kei Sugano <tobasojyo@gmail.com>
#
# YOU NEED TO GENERATE WEBHOOK URL WITH THE FOLLOWING INSTRUCTION:
# https://get.slack.help/hc/en-us/articles/115005265063-Incoming-WebHooks-for-Slack
#
CONFIG_PATH = "slacker/config"
def guide_config(config)
unless File.ex... |
# Represents a book of monsters
class Bestiary < ActiveRecord::Base
validates :name, presence: true
has_many :monsters
end
|
# Continue on Advance Classes in Ruby
# Basic Class
class Class_one
end
## Creating objects for the class
object_one = Class_one.new
object_two = Class_one.new
## Comparing two objects
puts object_one.object_id
puts object_two.object_id
puts object_one == object_two
puts object_one.object_id == object_two.object_id... |
class HabitDescriptionSerializer < ActiveModel::Serializer
include Pundit
attributes :id,
:name,
:summary,
:description,
:tag_list,
:can_update,
:can_delete
def can_update
policy(object).update?
end
def can_delete
policy(o... |
MAIN_CLASS = "main"
BASE_DIR = File.dirname(__FILE__) + "/"
BIN_DIR = BASE_DIR + "bin"
SRC_DIR = BASE_DIR + "src"
TEST_DIR = BASE_DIR + "test"
LIB_DIR = BASE_DIR + "libs"
CLASSPATH = (Dir["#{LIB_DIR}/**/*.jar"] + [BIN_DIR, LIB_DIR]).join(":")
task :compile do
Dir.mkdir BIN_DIR unless File.exist? BIN_DIR
#sources ... |
require 'rubygems'
require 'digest/md5'
require 'dm-core'
require 'dm-timestamps'
require 'dm-types'
require 'dm-validations'
require 'hpricot'
DataMapper.setup(:default, {
:adapter => 'mysql',
:database => 'vcd',
:username => 'root',
:password => '',
:host => 'localhost'
})
class Vessel
include Dat... |
class User < ActiveRecord::Base
require 'bcrypt'
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name
has_secure_password
has_many :list_shares
has_many :lists, :through => :list_shares
validates_presence_of :password, :on => :create
validates_presence_of :email
end
|
require 'spreadsheet/workbook'
require 'spreadsheet/excel/offset'
require 'spreadsheet/excel/writer'
require 'ole/storage'
module Spreadsheet
module Excel
##
# Excel-specific Workbook methods. These are mostly pertinent to the Excel
# reader. You should have no reason to use any of these.
class Workbook < Spreadshee... |
class CartController < ApplicationController
before_action :setup_cart_item!, only: [:add_item, :update_item]
def show
@cart = current_cart
end
def add_item
if @cart_item.blank?
@cart_item = current_cart.cart_items.build(item_id: params[:item_id])
end
@cart_item.quantity += params[:quan... |
class Conference < ActiveRecord::Base
attr_accessible :name, :start, :end, :description, :pin,
:open_for_anybody, :max_members, :announce_new_member_by_name,
:announce_left_member_by_name
belongs_to :conferenceable, :polymorphic => true, :touch => true
has_many :conference_... |
class SpecialistGroup < ActiveRecord::Base
has_many :specialists
has_many :portfolio_items, through: :specialists
has_one :avatar, as: :imageable_single, class_name: 'Photo'
has_many :received_messages, as: :recipient, class_name: 'Message'
has_many :orders, as: :executor
def messages; received_messages; ... |
class CreateInventories < ActiveRecord::Migration[5.1]
def change
create_table :inventories do |t|
t.integer :character_id
t.integer :equipment_id
end
end
end |
class RatingsController < ApplicationController
##################################################### FILTERS #####################################################
# Requires users to sign in before accessing action
# before_filter :authenticate_user!
##################################################### SWAGGER... |
template '/etc/ssh/ssh-banner' do
source 'ssh-banner.erb'
mode '0600'
owner 'root'
group 'root'
end
case node["platform"]
when "debian", "ubuntu"
#do debian/ubuntu things
when "redhat", "centos", "fedora"
if node['platform_version'].to_f >= 7
template '/etc/ssh/sshd_config' do
source 's... |
class Members::AccountsController < Devise::RegistrationsController
prepend_before_filter :authenticate_member_2!, :except => [:new, :create, :load_current_member]
before_filter :load_surveys, :only => [:new, :create]
layout Proc.new { |controller|
%w{new create}.include?(controller.action_name) ? 'two_colum... |
class GraphWidget
attr_reader :data_points, :title, :template
def initialize(data_points, title)
@data_points = data_points
@title = title
@template = :"widgets/graph"
end
end
|
require 'douban_api'
require 'hashie'
require 'hashie/mash'
require FreeKindleCN::CONFIG_PATH + "/douban"
class DoubanHelper
class << self
def auth_url
Douban.authorize_url(:redirect_uri => DOUBAN_CALLBACK, :scope => DOUBAN_SCOPE)
end
# code is from param[:code]
def handle_callback(code)
... |
# frozen_string_literal: true
ActiveAdmin.register School do
menu :priority => 5
sidebar :versions, :partial => "admin/version", :only => :show
controller do
def create
PaperTrail.enabled = false
super
PaperTrail.enabled = true
end
end
actions :all, except: [:destroy, :new] #just... |
class AddColumnChipTweets < ActiveRecord::Migration[5.2]
def change
add_column :chip_tweets, :tweet_id, :string
add_column :chip_tweets, :user_id, :string
add_column :chip_tweets, :category, :string
add_column :chip_tweets, :chip_on, :date
add_column :chip_tweets, :command, :string
add_column ... |
# == Schema Information
#
# Table name: abuse_reports
#
# id :integer not null, primary key
# reporter_id :integer
# user_id :integer
# message :text
# created_at :datetime
# updated_at :datetime
#
FactoryGirl.define do
factory :abuse_report do
reporter factory: :user
user
... |
require 'spec_helper'
require 'support/hydra_spec_helper'
include HydraSpecHelper
describe GamesController do
render_views
before do
@game = FactoryGirl.build(:game)
stub_hydra
stub_for_show_game(@game)
end
after { clear_get_stubs }
describe "GET 'index'" do
context "when not passing opt... |
class CreateHttpRequestLoggers < ActiveRecord::Migration
def change
create_table :http_request_loggers do |t|
t.string :caller
t.string :uri
t.string :request
t.text :response
t.timestamps
end
end
end
|
#!/usr/bin/env ruby
# Tag both semver and ruby format version
ver = ARGV[0] || begin
require File.expand_path('../lib/bootstrap-sass/version.rb', File.dirname(__FILE__))
Bootstrap::VERSION
end
ver = "v#{ver}" unless ver.start_with?('v')
sem_ver = ver.reverse.split('.', 2).join('-').reverse
system <<-SH
set -x
g... |
require 'active_support/concern'
module HasImage
extend ActiveSupport::Concern
module ClassMethods
def max_size
self.get_max_size({ env: ENV['MAX_UPLOAD_SIZE'], config: CheckConfig.get('uploaded_file_max_size', nil, :integer), default: 1.megabyte })
end
end
included do
include HasFile
... |
require 'builder'
# schema is described here: http://www.openmarine.org/schema.aspx credentials admin/admin
module Rightboat
module Exports
class OpenmarineExporter < ExporterBase
def do_export
@x = Builder::XmlMarkup.new(target: @file, indent: 1)
@x.instruct! :xml, version: '1.0'
... |
class MembersController < ApplicationController
def index
@card = Card.find_by_id(params[:card_id])
respond_to do |format|
if @card
format.json { render json: @card.members }
else
format.json { render nothing: true, status: 404 }
end
end
end
def create
@board =... |
class SkillsController < ApplicationController
def index
render json: Skill.all
end
def update
@skill = Skill.find(params[:id])
@skill.update_attributes(skill_params)
render json: @skill
end
def skill_params
params.require(:skill).permit(:active)
end
end... |
class DaysController < ApplicationController
def index
day = Date.today.beginning_of_month
@days = current_user.days
# @days = Day.all
all_days = @days.map(&:date)
while day <= Date.today.end_of_month
if !all_days.include? day
# # This allows us to build a new day modal
new_day=Day.new... |
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
# before_action do
# resource = controller_path.singularize.gsub('/', '_').to_sym
# method = "#{resource}_par... |
require 'world'
require 'pattern'
require 'patternmaker'
class Swarm < Processing::App
load_library "control_panel"
# how many runs of the world to try
@@runs_limit = 1000
# how many steps to try before giving up and resetting
@@ticks_limit = 10000
def setup
size 400, 400
smooth
... |
require 'test_helper'
class PracticasControllerTest < ActionController::TestCase
setup do
@practica = practicas(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:practicas)
end
test "should get new" do
get :new
assert_response :success
... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Operation::Insert do
require_no_multi_mongos
require_no_required_api_version
let(:context) { Mongo::Operation::Context.new }
before do
begin
authorized_collection.delete_many
rescue Mongo::Error::OperationFa... |
Pod::Spec.new do |s|
s.name = 'TestPod'
s.version = '1.0.0'
s.summary = 'TestPod summary'
s.license = 'MIT'
s.authors = { 'test' => 'test@test.com' }
s.homepage = 'https://www.example.com'
s.source = { :git => 'https://test@test.git', :tag => '#{s.version}' }
s.pla... |
require 'test_helper'
class ReplyReviewsControllerTest < ActionController::TestCase
setup do
@reply_review = reply_reviews(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:reply_reviews)
end
test "should get new" do
get :new
assert_res... |
module KMP3D
class KMP3DTest
def initialize(*_args)
puts "------------------------------------"
Data.signal_reload
Data.reload(self)
Data.load_kmp3d_model
@passed = 0
@total = 0
end
def print_results
puts "------------------"
puts "Passed: #{@passed}"
... |
require 'rails_helper'
RSpec.describe Localization, type: :model do
before :each do
@user = create(:user)
@localization = create(:localization, name: 'First Localization', user: @user, main: true)
@macro = create(:actor_macro, user_id: @user.id, localizations: [@localization])
end
it 'Create Relati... |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Mizatron::Application.load_tasks
namespace :lp do
desc "Generate config file ... |
module Refinery
module WineGroups
class WineGroup < Refinery::Core::BaseModel
self.table_name = 'refinery_wine_groups'
attr_accessible :name, :judge_id, :position
acts_as_indexed :fields => [:name]
validates :name, :presence => true, :uniqueness => true
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.