text stringlengths 10 2.61M |
|---|
# encoding: utf-8
module Kiqstand
VERSION = "1.2.0"
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Cells
describe Escape do
let(:described) { Vedeu::Cells::Escape }
let(:instance) { described.new(attributes) }
let(:attributes) {
{
position: position,
value: _value,
}
}
... |
class Tribe
attr_reader :name, :members
def initialize(options)
@name = options[:name]
@members = options[:members]
puts "#{name.blue} tribe has been created!"
end
def tribal_council(immune: nil)
members.reject { |member| member == immune }.sample
end
def to_s
name
end
end
|
class HomeController < ApplicationController
def index
@announcements = Announcement.order("created_at desc").limit(3)
@events = Event.order("created_at desc").limit(3)
@carousels = Carousel.where(:is_published => true)
end
end
|
module Api::V1
class ScansController < ApplicationController
before_action :set_scan, only: [:show, :destroy, :checks, :stats, :abort]
# GET /scans
def index
if params[:force].to_s.downcase != "true"
render :json => { :error => "List method is not allowed without force param"}, status: :met... |
json.array!(@civility_votes) do |civility_vote|
json.extract! civility_vote, :id, :voter_id, :debate_id, :debater_id, :rating
json.url civility_vote_url(civility_vote, format: :json)
end
|
require 'spec_helper'
describe TeamstatDecorator do
let(:teamstat) { Teamstat.new }
let(:league) { League.new(:name => "myLeague", :from_year => 1999, :to_year => 2010) }
let(:team) { Team.new(:name => "myTeam") }
subject do
teamstat.team = team
teamstat.league = league
TeamstatDecorator.new(te... |
class OrgansController < ApplicationController
before_action :register
def index
@grid_organs = OrgansGrid.new(params[:organs_grid]) do |scope|
scope.page(params[:page])
end
organ_id = params[:format]
if organ_id
@organ = Organ.find organ_id
@show_grid_sector = true
@grid_sectors = SectorsGrid... |
require "minitest_helper"
require "chandler/changelog"
class Chandler::ChangelogTest < Minitest::Test
def test_fetch_raises_for_nonexistent_version
changelog = new_changelog("airbrussh.md")
assert_raises(Chandler::Changelog::NoMatchingVersion) do
changelog.fetch("v0.99.0")
end
end
def test_fet... |
class MoviesController < ApplicationController
load_and_authorize_resource
def index
@movie = Movie.new
end
def new
@movie = Movie.new
end
def create
@movie = Movie.new(movie_params)
if params['tags']
params['tags'].each do |tag_name|
@movie.tags << Tag.find_by(name: tag_name... |
json.array!(@images) do |image|
json.extract! image, :id, :IMAGE_NO, :PLATFORM_NO, :IMAGE_NAME, :IMAGE_NAME_DISP, :OS, :OS_DISP, :SELECTABLE, :COMPONENT_TYPE_NOS, :ZABBIX_TEMPLATE
json.url image_url(image, format: :json)
end
|
require "pry"
def nyc_pigeon_organizer(data)
hash = {}
data.each do |attributes, hashes|
hashes.each do |info, names_array|
names_array.each do |name|
if names_array.include?(name)
if hash[name] == nil
hash[name] = {}
end
if has... |
#==============================================================================
# Dynamic Sound Emitting Events
# Version: 1.0.5
# Author: modern algebra (rmrk.net)
# Date: 30 March 2014
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script al... |
require 'rails_helper'
require 'axe/rspec'
feature 'Accessibility on IDV pages', :js, idv_job: true do
describe 'IDV pages' do
include IdvHelper
scenario 'home page' do
sign_in_and_2fa_user
visit verify_path
expect(page).to be_accessible
end
scenario 'basic info' do
sign_i... |
class Item < ActiveRecord::Base
attr_accessor :name, :price, :weight, :description
end
|
require 'spec_helper'
describe Project do
let(:project) { FactoryGirl.create(:project) }
subject { project }
it { should respond_to(:code)}
it { should respond_to(:title)}
it { should respond_to(:discipline)}
it { should respond_to(:description)}
it { should respond_to(:associated_with)}
it { should... |
require 'rubygems'
require 'sinatra'
require 'mongo'
require 'active_support'
require 'time'
DEFAULT_LIMIT = 40
class Integer
def odd
self & 1 != 0
end
def even
self & 1 == 0
end
end
db = Mongo::Connection.new.db('habr')
jobs_collection = db['habr_jobs']
get '/robots.txt' do
"User-agent: *\nA... |
class OrderedProduct < ApplicationRecord
belongs_to :order
belongs_to :product
def finish
self.ordered_produ
end
#制作ステータスのenumを定義
enum production_status: { 制作不可: 0, 制作待ち: 1, 製作中: 2, 制作完了: 3 }
end
|
module ConfigCenter
module User
# xxxx@yyyy.zzz format
EMAIL_FORMAT_REG_EXP = /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
# xxx-xxx-xxxx format
PHONE_FORMAT_REG_EXP = /\A\d{3}-\d{3}-\d{4}\z/i
# Password regex f... |
class EventsController < ApplicationController
def index
@events = Event.all
@title = 'All events'
end
def show
@event = Event.find(params[:id])
join = EventUser.where(event_id: @event.id, admin: true).last
user = User.find join.user_id
@host = user.email
@users = @event.users
a... |
class CheckoutController < ApplicationController
def index
@job = Job.find(params[:id]) if params.present?
@plan = @job.plan if @job.present?
end
def show
@job = Job.find_by(id: params[:id])
if @job.present?
@plan = @job.plan
else
redirect_to jobs_path, notice: 'Job not found!'
... |
require 'set'
module FollowerMaze
class User
attr_reader :id, :follower_ids
def initialize(id)
@id = id
@follower_ids = Set.new
end
def add_follower(follower_id)
@follower_ids.add(follower_id)
end
def remove_follower(follower_id)
@follower_ids.delete(follower_id)
... |
require 'spec_helper'
describe OpenAssets::Protocol::HttpAssetDefinitionLoader do
describe 'load' do
context 'correct content' do
subject{
OpenAssets::Protocol::HttpAssetDefinitionLoader.new('http://goo.gl/fS4mEj').load
}
it do
expect(subject.asset_ids.length).to eq(4)
... |
class ServiceInquiriesController < ApplicationController
before_filter :require_user, :except => [:new, :create]
layout "admin"
# GET /service_inquiries
# GET /service_inquiries.xml
def index
@service_inquiries = ServiceInquiry.all
respond_to do |format|
format.html # index.html.erb
... |
require 'beanstalk-client'
class Q
def initialize
@bs = Beanstalk::Pool.new(QUEUE_SERVERS)
end
def close
@bs.close
end
def announce_worker(name)
worker_tube = "#{WORKER_PREFIX}#{name}"
puts "announced (#{worker_tube})"
@bs.use(worker_tube)
@bs.watch(worker_tube)
# @bs.y... |
module RuboCop
module Cop
module RSpec
# This cop is used to identify usages of `should`
#
# @example
# # bad
# it { should be_valid }
#
# # good
# it { is_expected.to be_valid }
class IsExpectedTo < Cop
MSG = 'Prefer `is_expected.to` to `shoul... |
require 'test_helper'
class AdminControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test 'requires user authentication' do
assert(defines_before_filter?(Admin::AdminController, :authenticate_user!))
end
test 'requires an admin user' do
assert(defines_before_filt... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
ROLES = %w[user admin]
before_validation :ensure_r... |
class AddLengthToGames < ActiveRecord::Migration
def change
add_column :games, :length, :string
add_column :games, :playendtime, :datetime
add_column :games, :voteendtime, :datetime
end
end
|
# Slack page that is displayed on logout
class SignedOutPage < Page
attr_accessor :browser, :url
def initialize(browser)
super
@url = 'https://spartaglobal.slack.com/signout/done'
end
def trait
# Trait unique to page
@browser.div(id: 'page_contents').a(text: 'Sign back in')
end
end
|
require_relative './class_helper'
require_relative './season_stats'
require_relative './team_stats'
require_relative './game_stats'
require_relative './league_stats'
class StatTracker
include SeasonStats
include TeamStats
include GameStats
include LeagueStats
attr_reader :games,
:teams,
... |
json.set! membership.id do
json.extract! membership, :id, :workspace_id, :member_id
end
# sample
#{
# 1: { id: 1,
# workspace_id: 2,
# member_id: 4 }
# } |
FactoryBot.define do
factory :menu do
sequence(:name) {|n| "name menu #{n}" }
type_menu { "MyString" }
trait :invalid do
name { nil }
end
trait :new_name do
name { 'New menu' }
end
end
end
|
Rails.application.routes.draw do
root 'home#index'
namespace :admin do
resources :users
end
namespace :users do
resources :loanables
get "loaned", to: "loanables#loaned", as: "loaned"
end
resources :loanables, only: [:index, :show] do
resources :loan_contracts, only: [:create], module: :... |
class Event < ActiveRecord::Base
belongs_to :building
has_one :patron
has_one :military_order
validates :order, :presence => true
validates :event_type, :presence => true
validates :building_type, :presence => true
end
|
# == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# new_user_session GET /users/sign_in(.:format) devise/sessions#new
# user_session POST /users/sign_in(.:format) devise/sessions#create
# destroy_user_session DELETE /use... |
##-----------------------------------------------------------------------------
# Smart(er) Followers v1.0a
# Created by Neon Black
# v1.0 - 1.24.14 - Main script completed
# For both commercial and non-commercial use as long as credit is given to
# Neon Black and any additional authors. Licensed under Creative C... |
require 'spec_helper'
describe Scenario do
before(:each) do
@valid_attributes = {
:title => "Scenario Title",
:given_block => "Given Block",
:when_block => "When Block",
:then_block => "Then Block",
:feature_id => 1
}
end
it "should create a new instance given valid attribu... |
require "spec_helper"
RSpec.describe "Day 14: Extended Polymerization" do
let(:runner) { Runner.new("2021/14") }
let(:input) do
<<~TXT
NNCB
CH -> B
HH -> N
CB -> H
NH -> C
HB -> C
HC -> B
HN -> C
NN -> C
BH -> H
NC -> B
NB -> B
BN -... |
namespace :obfuscator do
desc "Scrub sensitive data for a given model's column"
task :scrub, [:model] => :environment do |task, arguments|
model = arguments[:model]
columns = ENV["COLUMNS"].split(",")
Obfuscator.scrub! model do
overwrite columns
end
end
end
|
class RemoveFlatpages < ActiveRecord::Migration
def change
drop_table :flatpages
p = Permission.find_by_resource("Flatpage")
UserPermission.where(permission_id: p.id).delete_all
p.delete
end
end
|
require 'date'
class DateValidator < ActiveModel::Validator
def validate(record)
date = record.date.to_datetime if record.date
if ((not(date.kind_of? DateTime)) or ((date - DateTime.now) > 365.25) or ((date - DateTime.now) <= 0))
record.errors.add(:date, "Invalid date")
end
end
end |
class DiscussionBoardsController < ApplicationController
load_and_authorize_resource
# GET /discussion_boards/1
# GET /discussion_boards/1.json
def show
@discussion_board = DiscussionBoard.find(params[:id])
@class_section = ClassSection.find(params[:class_section_id])
@role = Role.find(params[:rol... |
class AddContractRefToReviews < ActiveRecord::Migration[5.1]
def change
add_reference :reviews, :contract, foreign_key: true
end
end
|
# frozen_string_literal: true
require "fiber"
require "graphql/execution/interpreter/argument_value"
require "graphql/execution/interpreter/arguments"
require "graphql/execution/interpreter/arguments_cache"
require "graphql/execution/interpreter/execution_errors"
require "graphql/execution/interpreter/runtime"
require ... |
class MakeJsonPayloadRequiredInComments < ActiveRecord::Migration
def change
change_column :comments, :json_payload, :text, null: false
end
end
|
When "I click on the signout button" do
find_link('Sign Out').click
end
Then "I am no longer signed in" do
expect(page).not_to have_content('Sign Out')
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :students, only: %i[index show] # ;p added show
end
|
module Poseidon
# @api private
module Protocol
require "poseidon/protocol/protocol_struct"
require "poseidon/protocol/request_buffer"
require "poseidon/protocol/response_buffer"
API_KEYS = {
:produce => 0,
:fetch => 1,
:offset => 2,
:metadata => 3,
:offset_commit => 8,... |
class WeatherService
# 下記から天気予報を取得したいIDを見つける
# http://weather.livedoor.com/forecast/rss/primary_area.xml
CITY = 280010
# 暑い・寒い閾値
HOT_TEMP = 27
COLD_TEMP = 10
def self.hot_now?
today_max_temperature != 0 && today_max_temperature >= HOT_TEMP
end
def self.cold_now?
today_min_temperature != 0 &... |
# frozen_string_literal: true
module GraphQL
module Execution
# Boolean checks for how an AST node's directives should
# influence its execution
# @api private
module DirectiveChecks
SKIP = "skip"
INCLUDE = "include"
module_function
# @return [Boolean] Should this node be inc... |
# frozen_string_literal: true
module ActionArgs
VERSION = '2.6.0'
end
|
class AddIndexToPoReceipt < ActiveRecord::Migration
def change
add_index :po_receipt, [:bukrs, :dpseq, :lifnr, :matnr, :werks]
end
end
|
module Pages
class Show
include Lotus::Action
expose :page
def call(params)
path = params.instance_variable_get(:@env)['REQUEST_PATH'].sub(/^\//, '')
path = :home if path == ''
@page = Pages::PageRepository.find(path, format: :html)
halt 404 if @page.nil?
RequestStore.store... |
require_relative "base"
class TextMessage < Base
# 受け取ったメッセージに対して、返答する内容を@messagesに格納する。
def parse
case @event.message["text"]
when "/uid"
@messages.push(
self.create_text_message("あなたのUID"),
self.create_text_message(@event["source"]["userId"])
)
when "hello"
@messages... |
namespace :db do
desc "Generate all the database triggers of the current project"
task :create_triggers => :environment do
creator = RailsDbTriggers::DbTriggersCreator.new
triggers_path, triggers_ext = Rails.configuration.rails_db_triggers[:triggers_path], Rails.configuration.rails_db_triggers[:triggers_e... |
module Referrer
class UsersMainAppUser < ActiveRecord::Base
belongs_to :main_app_user, polymorphic: true
belongs_to :user
end
end
|
class RenameQuestionToCompetency < ActiveRecord::Migration[5.0]
def change
rename_table :questions, :competencies
end
end
|
class UserMailer < ActionMailer::Base
default from: "from@example.com"
def contact(suject, email, text)
@suject = suject
@email = email
@text = text
mail(
:to => "stocks.oliver@gmail.com",
:from => @email,
:subject => @suject
) do |format|
format.... |
class UserAddressesController < ApplicationController
def new
if UserAddress.where(user_id: params[:user_id]).present?
@user_address = UserAddress.find_by(user_id: params[:user_id])
else
@user_address = UserAddress.new
end
end
def create
@user_address = UserAddress.new(user_address_pa... |
class Portfolio < ActiveRecord::Base
has_many :images, dependent: :destroy
accepts_nested_attributes_for :images, :allow_destroy => true
mount_uploader :main_image, ImageUploader
default_scope { order('created_at DESC') }
validates :main_image, file_size: { less_than_or_equal_to: 560.kilobytes.to_i }
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
scope '/api' do
post '/login', to: 'sessions#create'
get '/users/:id/pokemons', to: 'pokemons#index'
post '/users/:id/pokemons', to: 'pokemons#create'
get '/users/:id... |
class Api::ApiController < ActionController::Base
def amount_cents(amount_decimal)
(amount_decimal.to_f * 100).round
end
end
|
class Product
attr_accessor :code
attr_accessor :price
attr_accessor :name
def initialize(code, name, price)
@code = code
@price = price
@name = name
end
end
|
class User < ApplicationRecord
rolify
PARAMS = [{ user_profile_attributes: %i(first_name last_name city description
avatar avatar_cache sex phone birthday) }].freeze
has_many :items, dependent: :destroy
has_many :niches, dependent: :delete_all
has_many :categories, d... |
class Mdtoc < Formula
desc "CLI tool to Generate and insert markdown's table of contents"
homepage "https://github.com/takaishi/mdtoc"
url "https://github.com/takaishi/mdtoc/releases/download/v0.0.5/mdtoc_0.0.5_Darwin_x86_64.tar.gz"
version "0.0.5"
sha256 "e3a79082d2d68b7f1716444fceaa0a4415a5aa5952f14dc97786b... |
require 'spec_helper'
describe 'skype', :type => 'class' do
context "On a RedHat OS" do
let :facts do
{
:osfamily => 'RedHat'
}
end
it {
should contain_yumrepo('skype').with( { 'baseurl' => 'http://negativo17.org/repos/skype/fedora-$releasever/$basearch/' } )
should contai... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module EscapeSequences
describe Actions do
let(:described) { Vedeu::EscapeSequences::Actions }
describe '.hide_cursor' do
it { described.hide_cursor.must_equal("\e[?25l") }
end
describe '.show_cursor' do
... |
class Brand < ActiveRecord::Base
mount_uploader :brand_pic , BrandImgUploader
has_many :inventories
has_many :crafts
validates_uniqueness_of :name
def self.show_brand_on_id(brand_id)
Brand.find(brand_id)
end
end
|
class SessionsController < ApplicationController
def new
if logged_in?
@categories = Category.all
@post = current_user.posts.build
@feed_items = current_user.feed.paginate(page: params[:page])
if params[:search]
@feed_items = Post.search(params[:search]).paginate(page: params[:page... |
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require 'capybara/rspec'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'shoulda/matchers'
ActiveRecord::Migration.maintain_test_schema!
Capybara.r... |
# frozen_String_literal: true
require 'word_wrap_limiter/version'
module WordWrapLimiter
def self.wrap(string, width)
return string if string.length <= width
break_point = string[0...width].rindex(' ') || width
if space?(string, width)
"#{string[0...break_point]}\n#{wrap(string[break_point + 1..-1... |
Vagrant.configure(2) do |config|
config.vm.box = "debian_10_1_0"
config.vbguest.auto_update = true
config.vm.hostname = "buster64"
config.vm.network "private_network", ip: "192.168.50.101"
config.vm.synced_folder ".", "/vagrant"
config.vm.provider "virtualbox" do |vb|
vb.memory = 4096
... |
# frozen_string_literal: true
class PermissionsController < ApplicationController
include User::Load
secure!(:users)
before_action :find_roles, only: %i[index]
before_action :restrict_roles, only: %i[index]
before_action :users_for_select, only: %i[index]
before_action :find_user_role, only: %i[remove]
... |
class PricingSetup < ActiveRecord::Base
include SparcShard
belongs_to :organization
scope :current, -> (date) { where("effective_date <= ?", date).order("effective_date DESC").limit(1) }
def rate_type(funding_source)
case funding_source
when 'college' then self.college_rate_type
when 'fede... |
class Api::V1::TasksController < Api::V1::BaseApiController
before_action :set_batch, except: [:update_position]
def index
facility_id = params[:facility_id]
tasks = Cultivation::QueryTasks.call(@batch, [:issues], facility_id).result
render json: TaskSerializer.new(tasks).serialized_json
end
def a... |
require 'mandrill'
class MailService
def initialize config
@mandrill_api_key = config['api_key']
@from_email = config['from_email']
@from_name = config['from_name']
@reply_to = config['reply_to']
end
def send_mail mail_message
mandrill = Mandrill::API.new @mandrill_api_key
message = {"ht... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Advisor
#
# Recommendations
#
class Recommendations
#
# Creates and initializes a new instance of the Recommendations class.
# @... |
class CreateDateRanges < ActiveRecord::Migration
def change
create_table :spree_date_ranges do |t|
t.string :rangeable_type
t.integer :rangeable_id
t.datetime :starts_at
t.datetime :ends_at
t.timestamps
end
end
end
|
module Inventory
class ProductSubCategorySerializer
include FastJsonapi::ObjectSerializer
attributes :name, :quantity_type, :is_used, :is_active, :metrc_item_category, :deleted
attribute :id do |object|
object.id.to_s
end
attribute :sub_categories do |object|
object.package_units
... |
require 'activerecord'
require 'optparse'
# ActsAsCommentable
module Juixe
module Acts #:nodoc:
module Commentable #:nodoc:
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_commentable(association_name = nil)
association_name = :co... |
# == Schema Information
#
# Table name: microchip_brands
#
# id :integer not null, primary key
# name :string(255)
# website :string(255)
# created_at :datetime
# updated_at :datetime
#
class MicrochipBrand < ActiveRecord::Base
has_many :animals
validates_presence_of :name
end
|
class User < ApplicationRecord
before_save { self.email.downcase! }
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 },
format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
uniqueness: { case_sensitive: fal... |
require 'validators'
class Message < ActiveRecord::Base
belongs_to :sender, :class_name => "User", :foreign_key => :from_user_id
belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id
validates_presence_of :title, :body, :sent_on, :sender, :recipient
validates_length_of :title, :within => 1... |
class ExternalSigninUser < User
self.table_name = "users"
DEFAULT_SHOESIZE = 27.0
class << self
def find_or_create_from_auth(auth)
find_or_create_by(provider: auth[:provider], uid: auth[:uid]) do |user|
user.name = auth[:info][:name]
user.email = dummy_email(auth)
user.remote_... |
class Hangman
def initialize(opts = {})
defaults = {
player1: HumanPlayer.new,
player2: ComputerPlayer.new,
guesses: 3
}
opts = defaults.merge(opts)
@Guesser = opts[:player1]
@Judge = opts[:player2]
@guesses = opts[:guesses]
@blank = " _"
end
def display_board
... |
module Api::V1::Agents
class ReviewsController < AgentUsersController
include Serializable
before_action :review_params, only: :create
before_action :set_job, only: :create
before_action :set_review, only: :show
before_action :set_customer, only: :customer_reviews
def index
reviews = cu... |
module JsonTableSchema
class Table
attr_reader :schema
def self.infer_schema(csv, opts = {})
JsonTableSchema::Table.new(csv, nil, opts)
end
def initialize(csv, descriptor, opts = {})
@opts = opts
@csv = parse_csv(csv)
@schema = descriptor.nil? ? infer_schema(@csv) : JsonTabl... |
class Person
attr_accessor :name, :age, :sex, :email
def initialize(name, age, sex, email)
@name = name
@age = age
@sex = sex
@email = email
end
end
p = Person.new('Dayana', 12, 'Male', 'text@email.com')
p.sex = 'Female'
p.name = 'Kingsley'
p.age = '36'
puts p.name
puts p.age
puts p.sex
puts... |
class User::Student < User
default_scope { where(role: 50) }
end
|
class ClearLayer < RenderLayer
def render(g,width,height)
t = g.get_transform
x = t.getScaleX
y = t.getScaleY
tx = t.translateX
ty = t.translateY
g.scale(1.0/x,1.0/y)
g.translate(-tx,-ty)
g.color = Color::BLACK
g.fillRect(0,0,width,height)
g.scale(x,y)
g.translate(tx,ty)
... |
class Insurance < ActiveRecord::Base
# Relations with other models
belongs_to :book
has_many :riders, :dependent => :destroy
has_many :dividends, :dependent => :destroy
has_many :returns, :dependent => :destroy
has_many :protections, :dependent => :destroy
has_many :surrenders, :dependent => :destroy
acts_as_t... |
#
# Redis accessor
#
# @author [nityamvakil]
#
class RedisWrapper
def initialize(namespace)
@redis = RedisAccess.send(namespace)
end
attr_reader :redis
def clean(prefix)
matching_keys(prefix).each { |key| redis.del key }
end
def set_with_expiry(key, expiry)
redis.set key, true
redis.expir... |
class User < ActiveRecord::Base
attr_accessible :username, :password, :password_confirmation, :admin
before_create :create_remember_token
validates :username, presence: true, length: { maximum: 12 }, uniqueness: true
has_secure_password
def User.new_remember_token
SecureRandom.urlsafe_base64
end
def ... |
#
# Iso2022Mailer - 日本語メール送信処理プラグイン
#
# from :
# http://wiki.fdiary.net/rails/?ActionMailer (moriq さん)
# http://wota.jp/ac/?date=20050731#p01 (くまくまーさん)
#
# Model で Iso2022jpMailer を継承して使用する
# (see http://d.hatena.ne.jp/drawnboy/20051114/1131977235 )
# TestMailer < Iso2022jpMailer
# ...
# end
#
# MIT License
#
requi... |
class Invitation < ActiveRecord::Base
belongs_to :project
before_create :generate_token
def to_param
#enables to the token to take the place of id
token
end
validates :email, presence: true
private
def generate_token
self.token = SecureRandom.hex(16)
end
end
|
#!/usr/bin/env ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network "forwarded_port", :guest => 8083, :host => 8083
config.vm.network "forwarded_port", :guest => 8086, :hos... |
module Marketplacer
module ExceptionHandler
def handle_exception(&block)
max_retries = 2
times_retried = 0
retry_after = 10
block.call
# rescue Net::ReadTimeout, Errno::ECONNRESET,Net::OpenTimeout ,SocketError => ex
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
Net::HT... |
Dir['./lib/*.rb'].each { |f| require f }
class ZendeskEndpoint < EndpointBase::Sinatra::Base
Honeybadger.configure do |config|
config.api_key = ENV['HONEYBADGER_KEY']
config.environment_name = ENV['RACK_ENV']
end
post '/create_ticket' do
client = Client.new(@config)
instance = Import.new(client.... |
class AddRidesPlanningToEvents < ActiveRecord::Migration
def change
add_column :events, :cars_going, :text
add_column :events, :people_going, :text
add_column :events, :rides, :text
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.