text stringlengths 10 2.61M |
|---|
class Project < ActiveRecord::Base
acts_as_paranoid
belongs_to :owner, class_name: 'User'
has_and_belongs_to_many :users
has_many :tasks, dependent: :destroy
validates :title, presence: true, uniqueness: {scope: :owner }
def is_owner?(user)
self.owner_id == user.id
end
def is_member?(user)
s... |
#!/usr/bin/ruby
require 'sqlite3'
require 'json'
begin
$config = JSON::parse(File.read("config.json"))
rescue
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} [FATAL] Incorrect JSON file or 'config.json' does not exist!"
exit 1
end
begin
$db = SQLite3::Database::new( $config['database'] )
rescue Exception => e... |
class PlayersController < ApplicationController
before_action :find_story
def index
@players = Player.where("story_id = #{@story.id}")
end
def show
@player = Player.find(params[:id])
end
def new
@player = Player.new
end
def edit
@player = Player.find(params[:id])
end
def create
... |
require 'spec_helper'
RSpec.describe WidgetsController do
describe "GET #index" do
it "returns an index containing all widgets" do
widget = FactoryGirl.create(:widget)
other_widget = FactoryGirl.create(:widget)
get :index
expect(assigns(:widgets)).to include(widget)
end #case populat... |
class User < ActiveRecord::Base
has_many :articles
has_many :comments
has_secure_password validations: false
validates :name, presence: true, uniqueness: true
validates :password, presence: true, on: :create, length: {minimum: 5}
end |
# frozen_string_literal: true
require 'active_support'
module Drawers
require 'drawers/active_support/dependency_extensions'
require 'drawers/action_view/path_extensions'
require 'drawers/action_view/resource_resolver'
require 'drawers/resource_parts'
module_function
def directory=(dir)
@directory =... |
class LibUnwind < DebianSourceFormula
url 'http://ftp.de.debian.org/debian/pool/main/libu/libunwind/libunwind_0.99-0.3.dsc'
md5 'bc602aae3b75bb348e480cfc99a30420'
end
|
# ================================================================
# Created: 2015/04/29
# Author: Thomas Nguyen - thomas_ejob@hotmail.com
# Purpose: Keep all URL locations
# ================================================================
module Paths
LOGIN = "/login"
LOGOUT = "/logout"
SIGNUP = "/signup"
SIGNUPT... |
class User < ActiveRecord::Base
has_secure_password
has_many :reviews
has_many :products, :through => :reviews
validates :name, :presence => true
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
private
class ::String
require 'iconv'
#
# Return an utf-8 representation of this string.
#
def to_utf
begin
Iconv.new("utf-8", "cp1251").iconv(self)
rescue Iconv::IllegalSequence =... |
class Message < ApplicationRecord
validates :channel, :presence => true, :length => {:maximum => 20}
validates :msgid, :presence => true, :length => {:maximum => 64}
validates :msgreplytochannel, :length => {:maximum => 20}
validates :msgreplytoid, :length => {:maximum => 64}
validates :msgtimestamp, :presen... |
class FFProbe
class Entity
def self.from_hash(hash,units=false)
target = new
target.units = units
hash.each {|k,v| target.__send__("#{k}=", v) }
target
end
attr_accessor :units
alias :units? :units
def self.units(mapping)
mapping.each do |property,unit|... |
module ApplicationHelper
def current_user?
current_user ? true : false
end
def authenticate_administrator?
if current_user
current_user.administrator?
else
false
end
end
end
|
class Transaction < ApplicationRecord
self.table_name = 'transactions'
after_initialize :init
belongs_to :user, class_name: 'User'
belongs_to :partner, class_name: 'Partner'
belongs_to :order, class_name: 'Order'
validates :status, :amount, presence: true
validates_inclusion_of :method, in: Constants.Tr... |
class AddNotNullToPostTitle < ActiveRecord::Migration[5.0]
def change
change_column_null :posts, :title, :string, false
end
end
|
class ItemsController < ApplicationController
before_filter :set_shop, except: [:search_ly]
before_filter :set_item, only: [ :show ]
# caches_page :index, :show
def index
page = params[:page].presence || 1
per = params[:per].presence || 8
@items = if params[:shop_id].present?
Item.where(shop... |
# Helper Method
#def position_taken?(board, index)
# !(board[index].nil? || board[index] == " ")
#end
def position_taken?(board, index, char)
if board[index] == char #|| board[index] == "O"
return true
elsif board[index] == " " || board[index] == "" || board[index] == nil
return false
end
end
# Define ... |
class Board
attr_accessor :cells, :token
def initialize(amount=9,cell=" ")
@cells = []
@token = "X"
amount.times do |i|
@cells << cell
end
end
def reset!
@cells.clear
9.times do |i|
@cells << " "
end
end
def display
puts " #{cells[0]} | #{cells[1]} | #{cells[2]}... |
FactoryGirl.define do
factory :order do
cost 1.5
phone "MyString"
name "MyString"
end
end
|
json.call artist, :id, :name, :info, :created_at, :updated_at
if artist.cover.present?
json.cover artist.cover_url
json.thumb artist.cover_url(:thumb)
else
json.cover nil
json.thumb nil
end
|
class LocationMenuItem < ActiveRecord::Base
belongs_to :location
belongs_to :menu_item
end
|
class SearchSuggestionWorker
include Sidekiq::Worker
include Sidekiq::Throttled::Worker
sidekiq_throttle({
:concurrency => {:limit => 2}
})
INDEX_REVIEW = 1
def perform action, review_id
case action
when INDEX_REVIEW
index_new_review review_id
end
end
private
def index_new_re... |
class User < ActiveRecord::Base
EMAIL_REGEXP = /\A[^@]+@([^@\.]+\.)[^@\.]+\z/
validates_presence_of :email, :full_name, :location, :password
validates_confirmation_of :password
validates_length_of:bio, minimum:30, allow_blank:false
validates_uniqueness_of :email
validate :email_format
private
def email_format
... |
module ApplicationHelper
# Checks to see if there's a specific Javascript file related to the
# controller. Used in header templates.
#
def controller_has_javascript?(name)
File.exist?(File.join(Rails.root, 'app', 'assets', 'javascripts', name + '.js'))
end
# Checks to see if there's a specific CSS fi... |
class CreateCharacters < ActiveRecord::Migration
def change
create_table :characters do |t|
t.string :name
t.integer :level
t.string :class
t.string :paragon_path
t.string :epic_destiny
t.integer :xp
t.string :race
t.string :size
t.integer :age
t.s... |
class StoreTwitterOauthTokenAndSecret < ActiveRecord::Migration
def change
add_column :users, :twitter_oauth_token, :string
add_column :users, :twitter_oauth_secret, :string
end
end
|
#!/usr/bin/env ruby
require 'json'
require 'time'
require 'open3'
require 'logger'
require 'optparse'
# Cleanup old snapshot
module Aws
def self.log message
@@logger ||= Logger.new(STDOUT)
@@logger.debug message
end
module Ebs
class Shell
def self.run(*cmd, **opts)
Aws.log "Run #{cmd.j... |
# frozen_string_literal: true
module MarkdownMetrics
module Elements
module Sentence
class Link < MarkdownMetrics::Elements::Sentence::Base
def self.match_element(character, next_character)
character.to_s == '(' && next_character.to_s == '['
end
def name
:link
... |
require 'spec_helper'
describe ClubNightMembershipsController do
let!(:user) { FactoryGirl.create(:confirmed_user) }
let!(:club_night) { user.club_nights.create(FactoryGirl.attributes_for(:club_night)) }
before do
sign_in(:user, user)
end
describe "#new" do
it "successfully renders new" do
ge... |
json.array!(@batches) do |batch|
json.extract! batch, :id, :name, :background_type, :job_type, :job_count, :worker_count, :thread_count
json.extract! batch, :id, :mean, :median, :range, :min, :max, :variance, :standard_deviation
json.extract! batch, :relative_standard_deviation, :percentile25, :percentile75, :per... |
#!/usr/local/bin/ruby
require 'fileutils'
WWW_DIR_PREFIX="/var/www/gforge-projects/"
=begin
Hi Rob -
OK, the ExNihilo project should be all set:
http://cougaar.org/projects/exnihilo/
You might want to read the "new project admin" checklist:
http://cougaar.org/docman/?group_id=7
If you have any questions, please... |
class CreateMaintenances < ActiveRecord::Migration
def change
create_table :maintenances do |t|
t.string :maint_code, :null => false, :default => ""
t.integer :component_id
t.string :description, :null => false, :default => ""
t.integer :frequency
t.integer :frequency_unit
... |
class CreateServicereqs < ActiveRecord::Migration
def change
create_table :servicereqs do |t|
t.string :desc
t.string :status
t.string :reason
t.timestamps null: false
end
end
end
|
module Resourceful
class NestedForm
decorate_class_with ListBuilder
include Resourceful::FormApi
include Resourceful::MemberPageApi
def class_name
'nested-form-item'
end
def title
'Untitled'
end
def show_blank?
false
end
def allow_destroy?
... |
require 'set'
module Orocos
module Generation
class CppProxyGeneration
attr_reader :project
attr_reader :proxy_gen
attr_reader :task
def initialize(cmp, t)
@project = cmp
@task = t
@proxy_gen = self
... |
FactoryGirl.define do
factory :post do
user
sequence(:title) { |n| "mathematical * #{n}!" }
body 'It\'s gonna be so flippin\' awesome.'
end
end
|
class IdeasController < ApplicationController
before_filter :authenticate_user!, except: [:show]
def show
@idea = Idea.find_by_id(@idea.id)
if @idea.public?
render "show"
else
if !signed_in?
flash[:error] = "That idea is private. Please sign in to view the idea if you created it."
... |
# frozen_string_literal: true
module CodeAnalyzer::CheckingVisitor
# This is the default checking visitor to check ruby sexp nodes.
class Default < Base
def initialize(options = {})
super
@checks = {}
@checkers.each do |checker|
checker.interesting_nodes.each do |node|
@chec... |
class HerosController < ApplicationController
before_action :confirm_logged_in
before_action :find_hero, only: [:show, :edit, :update, :destroy]
before_action :find_user_teams, only: [:new, :create, :edit, :update, :show]
def index
@heros = Hero.all
end
def new
@powers = Power.all
@hero = Hero.ne... |
class CategoriesController < ApplicationController
before_action :find_category, only: [:edit, :show, :update, :destroy]
def index
@categories = Category.order(:position)
end
def show
@works = @category.works.order(:position)
end
def new
@category = Category.new
end
def create
@categ... |
class AddAddressToParkingSpots < ActiveRecord::Migration[5.2]
def change
add_column :parking_spots, :address, :text
end
end
|
class Basket
attr_reader :all
def initialize(promotional_rules)
@all = []
@promotional_rules = promotional_rules
end
def add(item)
all << item
end
def total
apply_multibuy_discount
all.inject(0.00) { |total, item| total + item.price }
end
private
attr_reader :promotional_rule... |
class RemoveEmployeeStatus < ActiveRecord::Migration
def change
drop_table :employee_status
end
end
|
require './test/test_helper'
require "./lib/library"
class LibraryTest < Minitest::Test
def setup
@nk_jemisin = Author.new({first_name: "N.K.", last_name: "Jemisin"})
@fifth_season = @nk_jemisin.add_book("The Fifth Season", "November 3, 2015")
@kingdoms = @nk_jemisin.add_book("The Hundred Thousand Kingdo... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class CreateEnrollments < ActiveRecord::Migration
def self.up
create_table :enrollments do |t|
t.integer :user_id
t.integer :group_id
t.datetime :updated_at
t.datetime :created_at
end
add_index :enrollments, :user_id
add_index :enrollments, :group_id
end
def self.dow... |
class Store < ApplicationRecord
has_many :orders #heeft meer bestellingen
end
|
require("minitest/autorun")
require("minitest/rg")
require_relative("../guessed_letter.rb")
require_relative("../hidden_word.rb")
require_relative("../player.rb")
require_relative("../game.rb")
class TestGame < MiniTest::Test
def setup
@guessed_letters = GuessedLetters.new()
@hidden_word = HiddenWord.new("hello"... |
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
# Verify user is logged in
def logged_in_using_omniauth?
unless session[:userinfo].present?
flash... |
class PaymentSystem
# def self.authorized?(card)
# gateway.authorize(PAYMENT_RECURRING_AMOUNT, card).success?
# end
def self.recurring(card)
recurring_gateway.create(gateway, card.price, card)
end
def self.update_recurring(card)
recurring_gateway.update(gateway, card)
end
def self.cancel_re... |
require "spec_helper"
describe Page do
before(:all) do
@db = Airmodel.bases[:pages]
stub_airtable_response!(
"https://api.airtable.com/v0/#{@db[:bases]}/#{@db[:table_name]}?shard=&filterByFormula=AND%28%7Bslug%7D%3D%27home%27%29&limit=1",
{ "records" => [
{"id": "recXYZ", fields: {"slug"... |
require 'rails_helper'
RSpec.feature "UserCannotEditLinkWithInvalidUrls", type: :feature do
it "should see an error message when editing with an invalid link" do
user = create(:user_with_link)
visit login_path
fill_in "Email", with: user.email
fill_in "Password", with: "123"
click_on "Submit"
... |
class User < ApplicationRecord
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :timeoutable, :trackable,
:recoverable, :rememberable, :validatable,
:authentica... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :first_name_kana, :last... |
module BlacklightSolrplugins
# FacetField subclass to handle custom facet payloads in Solr response data
class FacetField < Blacklight::Solr::Response::FacetField
attr_reader :name, :items
def initialize name, items, options = {}
@name = name
@items = items
@options = options
end
... |
class TournamentJoiner
def initialize(tournament, user)
@tournament = tournament
@user = user
end
def join
@tournament.with_lock do
rating_period = @tournament.current_rating_period
if player = @tournament.players.find_by(user_id: @user.id)
player.update_attributes! end_at: nil, p... |
# frozen_string_literal: true
class User < ApplicationRecord
devise :database_authenticatable,
:recoverable, :rememberable, :validatable
paginates_per 6
validates :role, presence: true
has_many :posts, dependent: :destroy
end
|
class CreateConfigurations < ActiveRecord::Migration
def change
create_table :configurations do |t|
t.integer :user_id
t.integer :frequency_id
t.boolean :notification_in_real_time
t.boolean :can_send_email
t.timestamps
end
end
end
|
class CreateTheses < ActiveRecord::Migration
def change
create_table :theses do |t|
t.references :person, index: true, null: false
t.text :speciality, null: false
t.text :council
t.text :theme, null: false
t.string :ttype, limit: 32, null: false
t.integer :year, null: false
... |
class ChangeByteCapacityOfCardNumber < ActiveRecord::Migration[5.2]
def change
remove_column :users, :card_number, :integer
add_column :users, :card_number, :integer, limit: 8
end
end
|
class AddDetailColumnsToPomodoros < ActiveRecord::Migration[5.2]
def change
add_column :pomodoros, :title, :string
add_column :pomodoros, :status, :integer
add_column :pomodoros, :memo, :text
end
end
|
Dummy::Application.routes.draw do
match 'login' => 'login#new'
resources :jobs
end
|
module TimeRangeControllerConcern
extend ActiveSupport::Concern
def form_object
@information.build_time_range unless @information.time_range
@information
end
def information_params
params.require(resource_name).permit(:name, :information_type, :value, :description, time_range_attributes: [:begin... |
agencies = [
{
code: "CFPB",
name: "Consumer Financial Protection Bureau"
}, {
code: "CNSC",
name: "Corporation for National and Community Service"
}, {
code: "DHA",
name: "Defense Health Agency"
}, {
code: "DOC",
name: "Department of Commerce"
}, {
code: "DOD",
name: "... |
class Language < ActiveRecord::Base
extend App::TokenSupport
has_and_belongs_to_many :authors, join_table: :languages_authors
has_and_belongs_to_many :language_types, join_table: :languages_language_types
scope :by_token, ->( token ) { find_by_token( token ) }
scope :by_author_token, ->( token ) do
cro... |
#encoding:utf-8
require 'nokogiri'
require 'iconv'
module Grabepg
class GrabBase
# To change this template use File | Settings | File Templates.
def conversion_what_day(whatday)
ret = "星期"
case whatday.to_i
when 1
ret += "一"
when 2
ret += "二"
when 3
... |
# 20章は Time Dateクラス
# 1. 日本語の文字列をタイムオブジェクトとして返すメソッドを作りなさい
def jparsedate(str)
now = Time.now
year = now.year
month = now.month
day = now.day
hour = now.hour
min = now.min
sec = now.sec
str.scan(/(午前|午後)?(\d+)(年|月|日|時|分|秒)/) do
case $3
when "年"
year = $2.to_i
when "月"
month = $2... |
class CreateTimeTableClassTimingSet < ActiveRecord::Migration
def self.up
create_table :time_table_class_timing_sets do |t|
t.integer :batch_id
t.integer :time_table_class_timing_id
t.integer :class_timing_set_id
t.integer :weekday_id
t.timestamps
end
add_index :time_... |
task :compare_branches do |before, after|
require 'pathname'
rails_dir = Pathname.new(__dir__).join("../../..", "rails").expand_path
before = ENV["BEFORE_BRANCH"].chomp
after = ENV["AFTER_BRANCH"].chomp
time = Time.now.to_s(:usec)
out_path = Pathname.new("tmp/compare_branches/#{time}")
out_path.mkpath
... |
class RemoveDaysFromOrders < ActiveRecord::Migration
def change
remove_column :orders, :days, :integer
end
end
|
def measure (x = 1)
time_before_test = Time.now
x.times do
yield()
end
time_after_test = Time.now
elapsed_time = (time_after_test - time_before_test) / x
end |
class Status < ActiveRecord::Base
belongs_to :user
validates :content, presence: true, length: { maximum: 200, message: 'must be less than 200 characters' }
after_create :update_user_status_last_updated_at
private
def update_user_status_last_updated_at
self.user.update_attribute('status_last_updated_a... |
class AddColumnMediumToMember < ActiveRecord::Migration
def change
add_column :members, :medium, :text
end
end
|
# == Schema Information
#
# Table name: users
#
# affiliation :text
# confirmation_sent_at :datetime
# confirmation_token :string(255)
# confirmed_at :datetime
# created_at :datetime not null
# current_sign_in_at :datetime
# current_sign_in_ip :string(255)
#... |
# frozen_string_literal: true
# Copyright (c) 2018-2020 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to us... |
require 'test_helper'
class Users::UnlocksControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
@user = users(:alice)
@request.env["devise.mapping"] = Devise.mappings[:user]
end
test "should get new" do
get :new
assert_response :success
end
test "should not get new when log... |
FactoryGirl.define do
factory :user do
user_name { Faker::Name.name }
email { Faker::Internet.email }
password 'password'
password_confirmation 'password'
gender 'male'
introduction 'hello world!'
latitude 44.960562
longitude 13.123123
mentor false
private false
end
end
|
require_relative './admin'
module Scriptum
class ManagePostsApp < AdminApp
set :views, ["views/manage_posts", "views/admin", "views/post_types"]
get '/' do
@posts = Post.search(params[:query]).sort(:created_at.desc)
@posts = @posts.where(:user_id => current_user.id) if current_user.role =... |
class Category
attr_accessor :category
@@all = []
def initialize(cat)
@category = cat
@@all << self
end
def self.all
@@all
end
def self.search_or_new(item)
object = @@all.find{|a| a.category == item}
if object == nil
object = Category.new(item)
end
object
... |
module Usecase
module Optics
class GetBearerToken
def initialize(optics_gateway:, generate_jwt_token:)
@optics_gateway = optics_gateway
@generate_jwt_token = generate_jwt_token
end
def execute
optics_gateway.request_bearer_token(
jwt_token: generate_jwt_token.e... |
desc "Remove old notifications"
task :clean_old_notifications => [ :environment ] do
puts "Cleaning sent notifications"
Notification.clean_old
end
|
require 'spec_helper'
describe Admin::ContentController do
before do
Factory(:blog)
#TODO delete this after remove fixture
Profile.delete_all
@user = Factory(:user, :text_filter => Factory(:markdown), :profile => Factory(:profile_admin, :label => Profile::ADMIN))
@user.editor = 'simpl... |
class QuestionsController < ApplicationController
before_filter :authenticate_user!, only: [:index, :show]
def index
@questions = Question.paginate(:page => params[:page], :per_page => 5)
end
end
|
=begin
#===============================================================================
Title: Camera Target
Author: Tsukihime
Date: Nov 24, 2014
--------------------------------------------------------------------------------
** Change log
Nov 24, 2014
- fixed bug where followers weren't being targeted at all
... |
require 'rails_helper'
shared_examples_for 'current_order' do
let(:model) { described_class }
subject { build model }
context '#add_order_item' do
it 'when order item exist' do
order_item = create :order_item, order: subject
expect { subject.add_order_item(order_item.book.id, 20).save }
... |
require_relative 'test_helper'
begin
require 'tilt/csv'
describe 'tilt/csv' do
it "registered for '.rcsv' files" do
assert_equal Tilt::CSVTemplate, Tilt['rcsv']
end
it "compiles and evaluates the template on #render" do
template = Tilt::CSVTemplate.new { "csv << ['hello', 'world']" }
... |
class EventsController < ApplicationController
before_filter :require_logged_user, :only => [:new, :create, :edit, :update]
def index
if params[:my].nil?
@events = Event.all_public
@my = false
else
@events = current_user.events.order_by(:start_date => :desc) if logged_in?
@my = true... |
name 'servlet-maven'
maintainer 'ENDAVA'
maintainer_email 'vlad.turbuleasa@endava.com'
license 'All rights reserved'
description 'Installs/Configures servlet-maven'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends "yum-servlet"
de... |
class Dashboard::PostsController < DashboardController
load_and_authorize_resource
def index
@posts = PostSearchQuery.new.filter(params).page(params[:page])
end
def new
@post = Post.new
end
def create
@post = Post.new(params[:post])
if @post.save
redirect_to :action => :index
el... |
# frozen_string_literal: true
module TimeStreamer
module Adapters
class PaperTrail
def search_placeholder
'ItemType#ItemId'
end
def identifier_for(record)
"#{record.class}##{record&.id}"
end
def find_version(id)
::PaperTrail::Version.find id
end
... |
class Client < ActiveRecord::Base
belongs_to :user
attr_protected :user_id
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
validates_attachment_size :avatar, :less_than => 3.megabytes
end
|
RSpec.describe Dry::Matcher::Case do
describe "#matches?" do
it "calls the match proc with the value" do
kase = described_class.new(match: -> value { value.even? })
expect(kase.matches?(2)).to be true
expect(kase.matches?(1)).to be false
end
end
describe "#resolve" do
it "calls the ... |
# encoding: UTF-8
module CDI
module V1
module Libraries
class CloneService < BaseCreateService
def initialize(item, user, options={})
@item = item
@user = user
super(user, options)
end
private
def can_create_record?
return false ... |
class AddResetToLecturers < ActiveRecord::Migration[5.0]
def change
add_column :lecturers, :reset_digest, :string
add_column :lecturers, :reset_sent_at, :datetime
end
end
|
# encoding: UTF-8
module API
module V1
class LearningDeliveries < API::V1::Base
helpers API::Helpers::V1::LearningDeliveriesHelpers
before do
authenticate_user
end
namespace :learning_deliveries do
end
namespace :learning_dynamics do
route_param :id do
... |
namespace :deploy do
desc "sbt package"
task :sbt_package do
on roles(:app), in: :sequence, wait: 5 do
within release_path do
execute '/usr/bin/sbt', 'package'
end
end
end
after :published, :sbt_package
desc "Copy api war to Jetty webapps"
task :copy_war do
on roles(:app), in: ... |
class Board
attr_reader :board
NUM_ROWS = 6
NUM_COLUMNS = 7
WIN_LENGTH = 4
def initialize
@board = Array.new(NUM_ROWS * NUM_COLUMNS, 0)
end
def get_pos(x,y)
@board[y*NUM_COLUMNS + x]
end
def put_symbol_in_column(symbol, col)
target = nil
NUM_ROWS.ti... |
require 'rails_helper'
describe 'Optimizing CSV creation' do
let(:num_rows) { 100000 }
let(:num_cols) { 10 }
let(:data) { Array.new(num_rows) { Array.new(num_cols) { "x"*1000 } } }
it 'is faster to create line by line' do
results_with_gc = Measure.run(gc: :enable) do
csv = data.map { |row| row.... |
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_authorization_check
def all
member_profile = MemberProfile.from_omniauth(request.env["omniauth.auth"])
if member_profile.persisted?
current_user.move_to_profile(member_profile)
sign_in_and_redirect member_profile, noti... |
# coding: utf-8
class AdviceMailer < ApplicationMailer
default from: "mocainforma@gmail.com"
def alert_advice_size(admin_email, advice)
admin_email
@advice = advice
mail to: admin_email, subject: "[ALERTA] Cupos para monitoría se están agotando"
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.