Skip to content

Instantly share code, notes, and snippets.

View osulyanov's full-sized avatar
🎯
Focusing

Oleg osulyanov

🎯
Focusing
  • Passion.io
View GitHub Profile
@osulyanov
osulyanov / application_controller.rb
Created February 21, 2013 02:43
Separate layouts for other requests
layout proc {|controller| controller.request.xhr? ? "ajax": "application" }
@osulyanov
osulyanov / config_application.rb
Last active December 14, 2015 18:58
Page not found exception handling
config.exceptions_app = self.routes
@osulyanov
osulyanov / controller.rb
Created July 24, 2013 03:55
If-Modified-Since header check
def show
@show = Show.find(params[:id])
if stale?(:etag => @show, :last_modified => @show.updated_at.utc)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @show }
end
end
end
@osulyanov
osulyanov / .powrc
Created July 25, 2013 03:58
Using Pow with RVM
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-version`
fi
@osulyanov
osulyanov / functions.js
Created November 11, 2013 03:31
Scroll AJAX page load
// Подгрузка страниц при скроллинге
var thisWork = 1;
function getNextP() {
if( !$('div').is('#products') )
return false;
if(thisWork == 1) {
nextPageNum = $("#products").data('page') + 1;
if(nextPageNum>$("#products").data('pages'))
@osulyanov
osulyanov / new_gist_file.sh
Created November 16, 2013 07:55
Install Bitrix Env
wget repos.1c-bitrix.ru/yum/bitrix-env.sh
chmod +x bitrix-env.sh
./bitrix-env.sh
Email settings:
http://dev.1c-bitrix.ru/learning/course/?COURSE_ID=48&LESSON_ID=2946&LESSON_PATH=3918.4635.4739.4796.2946
@osulyanov
osulyanov / Capfile.rb
Created November 18, 2013 07:04
Nginx + Unicorn + Capistrano http://habrahabr.ru/post/120368/
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
@osulyanov
osulyanov / new_gist_file
Created November 21, 2013 07:07
Heroku tips
# Set up heroku app
heroku git:remote -a app_name
# Create db backup
heroku pgbackups:capture
# Download last db backup
curl -o latest.dump `heroku pgbackups:url`
# Restore local base from Heroku
@osulyanov
osulyanov / gist:8617046
Created January 25, 2014 14:15 — forked from barek2k2/gist:5520967
Apache an nginx configuration for browser cache for static resources
For Apache, use the Location directive into your virtual host(be sure you have included expires and headers modules)
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault "access plus 30 days"
</LocationMatch>
@osulyanov
osulyanov / ru.yml
Created April 8, 2014 07:09
Translations for nested attributes
ru:
activerecord:
theme/posts:
text: Содержание # theme[posts][text]