Skip to content

Instantly share code, notes, and snippets.

View crusadergo's full-sized avatar

Ilia Lazarev crusadergo

View GitHub Profile
@crusadergo
crusadergo / async_rake.rb
Created December 1, 2020 10:52 — forked from tompave/async_rake.rb
how to run rake tasks asynchronously from controllers by spawning child processes
class ApplicationController < ActionController::Base
private
# Runs a rake task asyncronously in a child process
#
# for example, in any controller:
# async_rake("async:import_fixtures")
# async_rake("db:maintenance:cleanup", table: "things", ids: [12, 114, 539])
#
@crusadergo
crusadergo / Dockerfile
Created November 14, 2019 10:56 — forked from webchi/Dockerfile
Rails Postgre Docker MultiStage
FROM ruby:2.5.5-alpine3.9 as builder
WORKDIR /app
ARG RAILS_MASTER_KEY
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_IGNORE_MESSAGES=1 \
BUNDLE_GITHUB_HTTPS=1 \
BUNDLE_FROZEN=1 \
module Api
module V1
class AudiosController < ApplicationController
def create
return render json: { error: 'File format error.' } unless file_exist? && mp3_exist?
return render json: { error: 'Request format error.' } unless artist_exist? && song_exist?
audio = Audio.new audio_params
# frozen_string_literal: true
class TotemHelper
def initialize(params:, model:)
@params = params
@model = model
end
# Checks avatar presence of
def avatar_present?
@crusadergo
crusadergo / helpers.rb
Last active October 26, 2017 15:48
1st method: Returns current about_us pages data. They depend on locale and brand. 2nd method: Returns current text direction stored in locales.yml or default if current doesn't exist
# @fn def about_us_menu_pages {{{
# @brief Returns current about_us pages data. They depend on locale and brand
#
# @return [Array<Hash>] Returns an array of hashes with current pages data
# title: page title
# filename: file name
# href: page url
def about_us_menu_pages
cached_data = Cache.instance.lazy Cache::TTL::VIEWS, locale: Locale.current do
data = [
# @fn csp_report {{{
# @brief Sends CSP report
#
# @param [Hash] blob CSP report
# @param [String] domain Domain name for multiple CSP Reports
def csp_report blob, domain
Pony.mail(
to: @admin_email,
subject: "#{ domain }:CSP Report",
@import base
@import static_pages/common
#aimees_edit
@include scaled_position($width: 114rem, $height: 100rem)
position: relative
margin: 11rem auto 0
img
position: absolute
source 'https://rubygems.org'
# users auth~
gem 'devise'
gem 'cancancan', '~> 1.10'
gem 'rolify'
gem 'jquery-smooth-scroll-rails'
.menu-items
.tabled-menu-items
ul.menu
- menu.each do |hash|
li class=('' + (active_menu == hash[:name] ? ' active' : ''))
- if hash[:url]
= link_to hash[:title], hash[:url], id: hash[:id], class: hash[:class]
- else
div id=hash[:id] class=hash[:class]