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
# Override default options for server command | |
# This example changes default development host to 0.0.0.0 | |
require 'rails/commands/server' | |
module Rails | |
class Server | |
new_defaults = Module.new do | |
def default_options | |
default_host = Rails.env == 'development' ? '0.0.0.0' : '127.0.0.1' |
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
@import "bootstrap-sprockets"; | |
@import "bootstrap"; | |
@font-face { | |
font-family: 'Glyphicons Halflings'; | |
src: url(asset_path('glyphicons-halflings-regular.eot')); | |
src: url(asset_path('glyphicons-halflings-regular.eot?#iefix')) format('embedded-opentype'), url(asset_path('glyphicons-halflings-regular.woff')) format('woff'), url(asset_path('glyphicons-halflings-regular.ttf')) format('truetype'), url(asset_path('glyphicons-halflings-regular.svg#glyphicons_halflingsregular')) format('svg'); | |
} |
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
#!/bin/sh | |
echo 1 > /proc/sys/vm/drop_caches | |
echo 2 > /proc/sys/vm/drop_caches | |
echo 3 > /proc/sys/vm/drop_caches |
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
#https://github.com/logrusorgru/any/blob/master/redis_onlines_db_size/test.rb | |
require 'redis' | |
require 'benchmark' | |
# perfomance | |
require 'hiredis' | |
# `driver: :hiredis` for perfomance, `path: ""` too | |
$r = Redis.new driver: :hiredis, path: "/tmp/redis.sock" |
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
# coding: utf-8 | |
#https://github.com/logrusorgru/any/blob/master/redis_piplened_vs_ex/test.rb | |
require 'redis' | |
require 'benchmark' | |
# db: 0, driver: по-умолчанию, соединение: локальная петля, но(!) | |
# нам нужа производительность - чтобы не ждать результатов теста долго, поэтому | |
# кстати вот это: `driver: :hiredis, path: "/tmp/redis.sock"` | |
# увеличивает производительность чуть меньше чем в два раза |
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
# config/routes.rb | |
YandexKassaIntegration::Application.routes.draw do | |
# ... | |
scope '/yandex_kassa' do | |
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do | |
post :check | |
post :aviso | |
get :success | |
get :fail |
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
<form action="<%= @pay_desc['mrh_url'] %>" method="post"> | |
<input type=hidden name=MrchLogin value="<%= @pay_desc['mrh_login'] %>"> | |
<input type=hidden name=OutSum value="<%= @pay_desc['out_summ'] %>"> | |
<input type=hidden name=InvId value="<%= @pay_desc['inv_id'] %>"> | |
<input type=hidden name=Desc value="<%= @pay_desc['inv_desc'] %>"> | |
<input type=hidden name=SignatureValue value="<%= @pay_desc['crc'] %>"> | |
<input type=hidden name=Shp_item value="<%= @pay_desc['shp_item'] %>"> | |
<input type=hidden name=IncCurrLabel value="<%= @pay_desc['in_curr'] %>"> | |
<input type=hidden name=Culture value="<%= @pay_desc['culture'] %>"> | |
<input type=submit 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
class ApplicationController < ActionController::Base | |
... | |
#Problem: | |
#In rails 3.0.1+ it is no longer possible to do this anymore; | |
# rescue_from ActionController::RoutingError, :with => :render_not_found | |
# | |
#The ActionController::RoutingError thrown is not caught by rescue_from. | |
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error | |
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution |
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
hash = { 'foo' => 'bar' } | |
# Version 1 | |
hash = Hash[hash.map { |k, v| [k.to_sym, v] }] | |
# Version 2 | |
hash = hash.reduce({}) do |memo, (k, v)| | |
memo.tap { |m| m[k.to_sym] = v } | |
end |
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 is_vowel_elsif(letter) | |
if letter == "a" | |
true | |
elsif letter == "e" | |
true | |
elsif letter == "i" | |
true | |
elsif letter == "o" | |
true | |
elsif letter == "u" |
OlderNewer