Skip to content

Instantly share code, notes, and snippets.


Max Chernyak maxim

Block or report user

Report or block maxim

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
maxim / 1-ru.rb
Last active Nov 9, 2015
If ruby was in Russian
View 1-ru.rb
затребовать 'shellwords'
затребовать 'posix/spawn'
затребовать 'skeptick/error'
модуль Skeptick
класс Command
атр_читатель :shellwords
опр инициализировать(shellwords)
@shellwords = shellwords
maxim / gh-dl-release
Last active Nov 9, 2019
Download assets from private Github releases
View gh-dl-release
#!/usr/bin/env bash
# gh-dl-release! It works!
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
maxim / gist:1b88e10527b282022510
Last active Aug 29, 2015
Pin your monkey patches to certain gem version in rails
View gist:1b88e10527b282022510
# in an early initializer
def PinMonkeypatch!(gem_name, expected_version)
if gem_spec = Gem.loaded_specs[gem_name]
actual_version = gem_spec.version.to_s
if actual_version != expected_version
raise "Monkeypatch for #{gem_name} requires version "\
"#{expected_version}, but current version is #{actual_version}"
maxim / rails_autoload_issue.rb
Last active Aug 29, 2015
Problem with Rails autoload and classes used for directory namespacing
View rails_autoload_issue.rb
# If you have the following setup, Rails autoload will depend on load order in a hard-to-trace way:
# app/models/foo.rb
class Foo
def initialize(arg)
@arg = arg
# app/models/foo/bar.rb
View gist:bdddd0343fdfe5451eaf
# {{ ansible_managed }}
require 'puma_worker_killer'
daemonize false
directory '/srv/{{ app_name }}'
threads {{ puma_threads_min }}, {{ puma_threads_max }}
workers {{ ansible_processor_vcpus }}
bind 'unix:///var/run/{{ app_name }}/{{ app_name }}.sock'
View example.rb
class ApplicationController
helper_method :current_copywriting
def current_copywriting
@current_copywriting ||= Copywriting.find_by_request(request)
module SomeHelpers
def header_text
View gist:102892c03a7f4a34c61e
INFO[7bdf78e4] Running /usr/bin/env /home/deployer/ on
DEBUG[7bdf78e4] Command: /usr/bin/env /home/deployer/
DEBUG[7bdf78e4] fetching
DEBUG[7bdf78e4] fetching
DEBUG[7bdf78e4] From
DEBUG[7bdf78e4] fetching
DEBUG[7bdf78e4] 36d03e8..52fa872d feature/foo -> origin/feature/foo
DEBUG[7bdf78e4] fetching
DEBUG[7bdf78e4] 4372c38..79bba2b master -> origin/master
DEBUG[7bdf78e4] HEAD is now at 79bba2b Merge pull request #111 from example/fix/bar
maxim / bug.rb
Last active Aug 29, 2015
Rails bug
View bug.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source ''
gem 'rack', github: 'rack/rack'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
system 'bundle'
from jinja2 import contextfilter
class FilterModule(object):
''' Extra filters '''
def filters(self):
return {
'percent_of': self.percent_of,
'of_ram': self.of_ram
maxim / deps.rb
Created Jul 7, 2014
Show role hierarchy for Ansible
View deps.rb
#!/usr/bin/env ruby
require 'yaml'
ROLES_DIR = './roles'
def deps_of(role)
dep_path = File.join(ROLES_DIR, "#{role}/meta/main.yml")
File.exists?(dep_path) ? (YAML.load_file(dep_path)['dependencies'] || []) : []
You can’t perform that action at this time.