Skip to content

Instantly share code, notes, and snippets.

View BadAllOff's full-sized avatar
I'm open to new opportunities

BadAllOff BadAllOff

I'm open to new opportunities
View GitHub Profile
@BadAllOff
BadAllOff / gist:06bbce913365363829e577c50d7980f0
Created June 18, 2017 09:29 — forked from WizardOfOgz/gist:1012107
Save Base64-encoded images with Paperclip
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@BadAllOff
BadAllOff / devise.ru.yml
Created December 2, 2016 10:27 — forked from k1r8r0wn/devise.ru.yml
Devise russian
# Русский перевод для https://github.com/plataformatec/devise/tree/v3.5.6
# Другие переводы на http://github.com/plataformatec/devise/wiki/I18n
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись успешно подтверждена."
send_instructions: "В течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
send_paranoid_instructions: "Если ваш адрес email есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
@BadAllOff
BadAllOff / gist:3761d906d8cbd3adbce2c7fe86b4de9c
Created November 10, 2016 08:57 — forked from kinopyo/gist:2224867
Check whether a Paperclip attachment exists

Check whether a Paperclip attachment exists

Don’t simply test for the presence of the magic Paperclip attribute, it will return a paperclip Attachment object and thus always be true:

- if user.photo.present? # always true
  = image_tag(user.photo.url)
@BadAllOff
BadAllOff / postgresql_configuration_on_ubuntu_for_rails.md
Created October 31, 2016 22:03 — forked from p1nox/postgresql_configuration_on_ubuntu_for_rails.md
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
@BadAllOff
BadAllOff / rails_admin.ru.yml
Created October 23, 2016 17:40 — forked from serghost/rails_admin.ru.yml
RU translation for the gem 'rails_admin' (перевод гема rails_admin)
# 02.03.2016 Перевод gem rails_admin ~> 0.8
# Не забудьте добавить переводы названия модели (в т.ч. мн. ч.) и - опционально - атрибутов.
# Некоторые переводы, где нужны склонения, видоизменены, тем не менее, имхо,
# это не повлияло на удобство интерфейса
ru:
admin:
js:
true: 'True'
false: 'False'
@BadAllOff
BadAllOff / Guardfile
Created August 28, 2016 16:21 — forked from palkan/Guardfile
Guardfile for Rails
# По умолчанию запускаем только необходимых для тестов наблюдателей,
# то есть всех, кроме server.
# Для запуска всех: bundle exec guard -g default
scope groups: ['specs']
group 'specs' do
# запускаем тесты и использованием Spring
guard :rspec, cmd: "bundle exec spring rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
@BadAllOff
BadAllOff / monit.rc
Last active August 20, 2016 01:16 — forked from vkurennov/monit.rc
Пример конфига для запуска процессов через monit
### Nginx ###
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
@BadAllOff
BadAllOff / production.rb
Created August 19, 2016 09:49 — forked from vkurennov/production.rb
Пример конфига unicorn
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "/tmp/unicorn.qna.sock", :backlog => 64
# logging
stderr_path "log/unicorn.stderr.log"
@BadAllOff
BadAllOff / README.md
Created July 27, 2016 08:34 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@BadAllOff
BadAllOff / omniauth_macros.rb
Created July 14, 2016 20:49 — forked from kinopyo/omniauth_macros.rb
Integration test with Omniauth. This example is using twitter, and assume you've installed rspec and capybara. Official document is here: https://github.com/intridea/omniauth/wiki/Integration-Testing
# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',