- flowymitchell.com (WIP)
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
# Shared by Martin Streicher in the Rails Performance Slack | |
# https://railsperf.slack.com/archives/C0RUUGY6R/p1702565130357359 | |
# | |
config.lograge.enabled = true # see lograge section below... | |
config.lograge.formatter = Lograge::Formatters::Logstash.new | |
config.log_formatter = ::NewRelic::Agent::Logging::DecoratingFormatter.new | |
config.lograge.custom_options = | |
lambda do |event| | |
payload = event.payload |
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
# /app/models/concerns/has_many_attached.rb | |
module HasManyAttached | |
extend ActiveSupport::Concern | |
class_methods do | |
def has_many_attached(name, dependent: :purge_later, service: nil, strict_loading: false, **options) | |
super(name, dependent: :purge_later, service: nil, strict_loading: false) | |
if options[:file_types].any? | |
validate "validate_#{name}_file_types".to_sym |
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 is example how to rescue from exception ActionDispatch::Http::MimeNegotiation::InvalidType | |
# and show nice JSON error in your API | |
module API | |
class BaseController < ActionController::API | |
def process_action(*args) | |
super | |
rescue ActionDispatch::Http::MimeNegotiation::InvalidType => exception | |
# set valid Content-Type to be able to call render method below | |
request.headers['Content-Type'] = 'application/json' | |
render status: 400, json: { errors: [exception.message] } |
There are trhee diffrent time zones in rails
- System - The server time zone
- Application - Rails application use own time zone
- Database - Default is
UTC
, but do not change it
config.time_zone
should be set when an app dose not support multiple time zones- Do not use Date/Time API using system time zone
- Date could be incorrect by being converted from datetime or time to date
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
const fs = require('fs'); | |
const puppeteer = require('puppeteer'); | |
const GIFEncoder = require('gifencoder'); | |
const PNG = require('png-js'); | |
function decode(png) { | |
return new Promise(r => {png.decode(pixels => r(pixels))}); | |
} |
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
<snippet> | |
<content><![CDATA[ | |
<template> | |
${0} | |
</template> | |
<script> | |
export default { | |
props: [${1}], | |
data() { |
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
class AddTimestampsEverywhere < ActiveRecord::Migration[5.1] | |
def change | |
now = Time.current | |
%i[ | |
candidates | |
evaluations | |
interviewers | |
questions | |
responses |
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
FROM ubuntu:16.04 | |
RUN apt-get update | |
RUN apt-get install -y git wget curl build-essential | |
RUN wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && dpkg -i erlang-solutions_1.0_all.deb | |
RUN apt-get update | |
RUN apt-get install erlang -y | |
RUN apt-get install -y elixir | |
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - |
NewerOlder