This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CarrierWave.configure do |config| | |
if Rails.env.test? || Rails.env.cucumber? | |
config.storage = :file | |
config.enable_processing = false | |
else | |
config.asset_host = Rails.application.secrets.asset_host | |
config.fog_provider = 'fog/openstack' | |
config.fog_credentials = { | |
provider: 'OpenStack', | |
openstack_auth_url: 'https://api.selcdn.ru/v3', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CarrierWave.configure do |config| | |
if Rails.env.development? || Rails.env.test? | |
config.storage = :file | |
else | |
config.storage = :fog | |
config.fog_credentials = { | |
:provider => 'OpenStack', | |
:openstack_auth_url => 'https://auth.selcdn.ru/v1.0', | |
:openstack_username => Rails.application.secrets.openstack_username, | |
:openstack_api_key => Rails.application.secrets.openstack_api_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
$(document).on 'ajax:error', '.js-form-validation', (e, xhr, status, error) -> | |
$form = $(@) | |
resource_name = $form.attr('data-js-form-validation-resource') | |
$form.find('.field_with_errors').removeClass('field_with_errors') | |
$form.find('.error-message').removeClass('is_showed').text('') | |
setTimeout -> | |
$.each xhr.responseJSON, (key, value) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# basic pfctl control | |
# == | |
# Related: http://www.OpenBSD.org | |
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: http://www.apache.org/licenses/LICENSE-2.0 | |
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"; } ' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Enumerable | |
class Lazy < Enumerator | |
def initialize(obj) | |
super() do |yielder| | |
obj.each do |val| | |
if block_given? | |
yield(yielder, val) | |
else | |
yielder << val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyStringThing | |
refine String do | |
def at(num) | |
self[num..num] | |
end | |
end | |
end | |
class A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main :: IO () | |
main = do | |
str <- getLine | |
let [a,b] = words str | |
return ((read a :: Int) + (read b :: Int)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_contents_builder model_obj | |
model_name = model_obj.class.name.downcase | |
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') | |
end | |
if accociation['en'].nil? | |
model_obj.send("#{model_name}_contents").build(lang: 'en') | |
end | |
end |
NewerOlder