Skip to content

Instantly share code, notes, and snippets.


Oleg osulyanov

Block or report user

Report or block osulyanov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
osulyanov / order.rb
Last active Sep 19, 2019
Controller for refactoring
View order.rb
# Service class emulates Rails ActiveRecord
class ActiveRecord
def initialize(params={}); end
# Order model
class Order < ActiveRecord
attr_accessor :country_code,
# 1. Clear retry set
# 2. Clear scheduled jobs
# 3. Clear 'Processed' and 'Failed' jobs
osulyanov / config.yml
Last active Nov 7, 2019
Circle CI workflows config to test and deploy Ruby on Rails application with PostgreSQL database. Test with Rspec, precompile assets then deploy with Capistrano.
View config.yml
# Ruby CircleCI 2.0 configuration file
# Check for more details
defaults: &defaults
working_directory: ~/repo
- image: circleci/ruby:2.4.1-node-browsers
osulyanov /
Created Dec 5, 2017 — forked from Earendil95/
Git hooks for automatic reference issues in commit


This hooks will remind you to reference task in your commit, and remember your task ref for branch. Your commit messages will have style "[reference] message"


  1. Create two files in your repo - e.g. [PROJECT_ROOT]/hooks/prepare-commit-msg.rb and [PROJECT_ROOT]/hooks/post-checkout.rb
  2. Copy to first file (here will assume that this is a [PROJECT_ROOT]/hooks/prepare-commit-msg.rb):
#!/usr/bin/env ruby
osulyanov / rubocop_pre_commit_hook
Created Dec 3, 2017 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
View rubocop_pre_commit_hook
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
osulyanov /
Last active Dec 3, 2017 — forked from palkan/
Docker Dev
osulyanov / average_color.rb
Created Sep 15, 2017
Get average color of image. In this example `Image` model with `file` file.
View average_color.rb
after_commit :set_average_color
def set_average_color
return unless self == section.images.first || section.bg_color.blank?
section.update_attribute :bg_color, get_average_color
def get_average_color
img =
pix = img.scale(1, 1)
osulyanov / active_admin.rb
Created May 8, 2017
ActiveAdmin custom menu links
View active_admin.rb
# config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add :label => "The Application", :url => "/", :priority => 0
menu.add :label => "Sites" do |sites|
sites.add :label => "Google", :url => "", :html_options => { :target => :blank }
sites.add :label => "Facebook", :url => ""
sites.add :label => "Github", :url => ""
View application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: Setting.first.email_from
layout 'mailer'
You can’t perform that action at this time.