Skip to content

Instantly share code, notes, and snippets.


Boris Kuznetsov achempion

Block or report user

Report or block achempion

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
achempion / carrierwave_selectel.rb
Created Nov 14, 2018 — forked from leemour/carrierwave_selectel.rb
Carrierwave integration with Selectel using fog-openstack
View carrierwave_selectel.rb
CarrierWave.configure do |config|
if Rails.env.test? || Rails.env.cucumber? = :file
config.enable_processing = false
config.asset_host = Rails.application.secrets.asset_host
config.fog_provider = 'fog/openstack'
config.fog_credentials = {
provider: 'OpenStack',
openstack_auth_url: '',
achempion / carrierwave.rb
Created Nov 14, 2018 — forked from Bugagazavr/carrierwave.rb
Carrierwave + Selectel
View carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.development? || Rails.env.test? = :file
else = :fog
config.fog_credentials = {
:provider => 'OpenStack',
:openstack_auth_url => '',
:openstack_username => Rails.application.secrets.openstack_username,
:openstack_api_key => Rails.application.secrets.openstack_api_key
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias gco='git checkout '
alias gp='git push '
alias gpf='git push --force '
alias gpr='git pull --rebase '
$ ->
$(document).on 'ajax:error', '.js-form-validation', (e, xhr, status, error) ->
$form = $(@)
resource_name = $form.attr('data-js-form-validation-resource')
setTimeout ->
$.each xhr.responseJSON, (key, value) ->
View gist:c0bdb0a173bd106de955
# basic pfctl control
# ==
# Related:
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
achempion / i18n_builder_method.rb
Last active Dec 14, 2015
i18n builder method
View i18n_builder_method.rb
def set_contents_builder model_obj
model_name =
accociation = model_obj.send("#{model_name}_contents").group_by {|content| content.lang}
if accociation['ru'].nil?
model_obj.send("#{model_name}_contents").build(lang: 'ru')
if accociation['en'].nil?
model_obj.send("#{model_name}_contents").build(lang: 'en')
View internalization_helper.rb
module InternalizationHelper
# let's imagine that some methods defined in your model like 'title_en' and 'title_ru' for different locales
# helper will create 'title' method depending on current I18n.locale
# Model.rb
# extend InternalizationHelper
# define_translations_for 'title', 'description', ...
def define_translations_for *methods
methods.each do |method_name|
achempion / content_tag.js
Created Oct 14, 2012
Простой метод, позволяет создавать теги как с помощью рельсового метода `content_tag`
View content_tag.js
var content_tag;
content_tag = function(tag, content, params){
var tag, content, params, res;
var insert_params = '';
for(var key in params){
insert_params += ' '+key+'='+'"'+params[key]+'"';
res = '<'+tag+insert_params+'>'+content+'</'+tag+'>';
} else {
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License:
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
View the-best-language.rb
module Enumerable
class Lazy < Enumerator
def initialize(obj)
super() do |yielder|
obj.each do |val|
if block_given?
yield(yielder, val)
yielder << val
You can’t perform that action at this time.