Skip to content

Instantly share code, notes, and snippets.

@epintos
epintos / production.rb
Created July 11, 2015 18:43
Ruby on Rails deploy with Capistrano 3
set :stage, :production
role :app, %w(user@url)
role :web, %w(user@url)
role :db, %w(user@url)
set :bundle_binstubs, -> { shared_path.join('bin') }
set :ssh_options, keys: %w(~/.ssh/your-project-production.pem), forward_agent: true
@epintos
epintos / aws.js
Created November 9, 2015 19:05
Angular Gulp S3 Deploy Keys
module.exports = {
'production': {
'accessKeyId': 'Amazon_s3_production_access_key',
'secretAccessKey': 'Amazon_s3_production_secret_key',
'region': 'Amazon_s3_production_region',
'params': {
'Bucket': 'Amazon_s3_production_bucket_name'
}
},
'productionHeaders': {},
@epintos
epintos / gist:f63af3a75adf6993a9ff
Created November 9, 2015 19:19
Angular S3 Static Policy Setup
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
@epintos
epintos / gist:ea88ffb83144ff31583a
Created November 9, 2015 19:22
Angular Amazon IAM Certificate Upload
aws iam upload-server-certificate \
--server-certificate-name server-certificate-name \
--certificate-body file:///path-to-your-certificate/your-certificate.pem \
--private-key file:///path-to-private-key/private-key.pem \
--certificate-chain file://path-to-chain-certificate/chain-certificate.pem \
--path /cloudfront/
@epintos
epintos / document.rb
Created January 14, 2016 21:14
Document
class Document < ActiveRecord::Base
validates :name, uniqueness: { scope: [:description, :date] }
end
@epintos
epintos / add_name_description_date_unique_index_to_document.rb
Created January 14, 2016 21:19
AddNameDescriptionDateUniqueIndexToDocument
class AddNameDescriptionDateUniqueIndexToDocument < ActiveRecord::Migration
def change
add_index :document, [:name, :description, :date], unique: true
end
end
@epintos
epintos / document.rb
Created January 14, 2016 21:34
Document with token validator
class Document < ActiveRecord::Base
include UniqueTokenValidator
UNIQUE_FIELDS = {
key: :name,
scope: [:description, :date],
condition: proc { |obj| some_method(obj) }
}
validates UNIQUE_FIELDS[:key], uniqueness: {
@epintos
epintos / unique_token_validator.rb
Last active January 18, 2016 17:39
UniqueTokenValidator Concern
module UniqueTokenValidator
extend ActiveSupport::Concern
included do
validates :unique_token, uniqueness: true, allow_nil: true
before_validation :generate_unique_token
end
def generate_unique_token
if !self.class::UNIQUE_FIELDS[:condition].present? ||
@epintos
epintos / pre-push.sh
Created March 7, 2016 20:04
Git Pre Push example to check linters and run tests
#!/bin/sh
echo 'Running Rspec tests'
RUN_CHECK_CMD='bundle exec rspec spec -fd'
RUN_TESTS_OUTPUT=`${RUN_CHECK_CMD}`
if [ $? -eq 1 ]
then
echo "Can't commit! You've broken Rspec tests!!!"
exit 1
@epintos
epintos / pull_request_template.md
Created March 7, 2016 20:15
Pull Request Github Template Example

Summary

[Change!] Describe your feature, problems you had, notes, improvements and others.

Screenshots

[Change!] Upload screenshots of those views you changed.

Trello Card