This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name of your application. Used to uniquely configure containers. | |
service: your-app-name | |
# Name of the container image. | |
image: your-org/your-app-name | |
# Deploy to these servers. | |
servers: | |
web: | |
- REPLACE_WITH_YOUR_WEB_DROPLET_IP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This middleware dynamically switch a job queue based on its class name. | |
module TroubleshootMemoryMiddleware | |
module Client | |
class CustomQueueName | |
QUARANTINE_QUEUE = "quarantine" | |
def call(worker_class, job, queue, redis_pool) | |
# Jobs enqueued without ActiveJob are not wrapped. | |
job_class_name = if job["wrapped"].present? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use this validator like this | |
# | |
# class User < ApplicationRecord | |
# validates :profile_link, url: true | |
# end | |
class UrlValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
unless valid_url?(value) | |
record.errors.add(attribute, :invalid_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionView::Base.field_error_proc = proc do |html_tag, instance_tag| | |
fragment = Nokogiri::HTML.fragment(html_tag) | |
field = fragment.at("input,select,textarea") | |
html = if field | |
field["class"] = "#{field["class"]} is-invalid" | |
html = <<-HTML | |
#{fragment} | |
<p class="invalid-feedback">#{instance_tag.error_message.to_sentence}</p> | |
HTML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
const tokenEl = document.getElementsByName('csrf-token')[0] | |
if (tokenEl) { | |
const token = tokenEl.getAttribute('content') | |
axios.defaults.headers.common['X-CSRF-Token'] = token | |
} | |
axios.defaults.headers.common['Accept'] = 'application/json' | |
axios.defaults.headers.post['Content-Type'] = 'application/json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp::Application.configure do | |
# Restrict access with HTTP Basic Auth for staging environment | |
if ENV['STAGING_AUTH'] | |
config.middleware.use Rack::Auth::Basic do |username, password| | |
ENV['STAGING_AUTH'].split(':') == [username, password] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-ruby/ for more details | |
# | |
version: 2 | |
jobs: | |
build: | |
docker: | |
# specify the version you desire here | |
- image: circleci/ruby:2.4.1-node-browsers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"atomKeymap.promptV3Features": true, | |
"editor.multiCursorModifier": "ctrlCmd", | |
"editor.formatOnPaste": true, | |
"files.insertFinalNewline": true, | |
"files.trimTrailingWhitespace": true, | |
"editor.renderWhitespace": "all", | |
"editor.tabSize": 2, | |
"explorer.confirmDragAndDrop": false, | |
"terminal.external.osxExec": "iTerm.app", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upload(files) { | |
const config = { | |
onUploadProgress: function(progressEvent) { | |
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
console.log(percentCompleted) | |
} | |
} | |
let data = new FormData() | |
data.append('file', files[0]) |
NewerOlder