Skip to content

Instantly share code, notes, and snippets.

@panych
panych / application.html.erb
Last active August 29, 2015 13:55
Typical rails application layout
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="ru"><![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="ru"><![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="ru"><![endif]-->
<!--[if gt IE 8]><!--><html class="" lang="ru"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title><%= yield :title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= csrf_meta_tags %>
@panych
panych / database.yml
Last active August 29, 2015 13:56
Rails vagrant database.yml
defaults: &defaults
adapter: postgresql
encoding: unicode
# Don't forget to change project name!
database: project_name
pool: 20
username: vagrant
password: 'vagrant'
template: template0
host: localhost
@panych
panych / _ic-soc.scss
Last active August 29, 2015 13:56
Advanced example of sprite generation in Compass
//
// Usage example:
// Image folder:
// ic-soc/
// fb.png
// tw.png
// vk.png
//
// HTML:
// <i class="ic-soc ic-soc_fb"></i>
@panych
panych / _justify-blocks.scss
Last active August 29, 2015 13:56
Justify-blocks sass mixin
// Mixin to layout blocks to justify parent width
// Works IE6+, Chrome, FF, Opera, Safari
//
// NOTE Don't forget to set font-size, line-height and text-align to child
// elements.
// NOTE that whitespace between list items is required.
// ISSUE: extra space at bottom.
//
// Usage example:
// HTML:
@panych
panych / ic_a_test.slim
Created February 14, 2014 09:10
File iterator in Rails (usefull when testing autosprites)
.list-group
- Dir.foreach('app/assets/images/ic-a') do |fname|
- next if fname == '.' || fname == '..' || !fname.include?('.')
- fname_without_ext = fname[/.*(?=\..+$)/]
li.list-group-item
p .ic-a.ic-a_#{fname_without_ext}
i( class="ic-a ic-a_#{fname_without_ext}" )
@panych
panych / application.slim
Last active August 29, 2015 13:57
Separate css-files with fonts for modern browsers and for IE8-
doctype html
html
head
meta( charset='utf-8' )
meta( name='viewport' content='initial-scale=1' )
<!--[if gt IE 8]><!-->
= stylesheet_link_tag 'fonts-woff', :media => 'screen'
<!--<![endif]--><!--[if lte IE 8]>
= stylesheet_link_tag 'fonts-eot', :media => 'screen'
@panych
panych / routes.rb
Created March 19, 2014 22:12
Kitchen pages declaration in routes.rb
blocks = ['nav', 'ul', 'editor-text', 'title', 'btn-lnk', 'ic-a', 'grid', 'form']
get 'kitchen' => 'kitchen#index'
blocks.each do |bname|
fname = bname.gsub('-', '_')
get "kitchen/#{bname}" => "kitchen##{fname}"
end
@panych
panych / create_block.rb
Created April 29, 2014 08:04
Create block files (stylesheet, kitchen page, layout)
desc 'Create block stylesheet file and kitchen page'
task :create_block, [:name] do |t, args|
block_name = args[:name]
if block_name == nil
print "Block name is required \n"
else
# TODO Check name for convention validity ('my-super-block', not 'mySuper_block')
# Create stylesheet file
style_file_path = "#{Rails.root}/app/assets/stylesheets/blocks/_#{block_name}.scss"
@panych
panych / gist:a0d225a01ddb5f68814b
Created July 17, 2014 09:20
JivoSite open by external link
// Widget documentation http://www.jivosite.ru/javascript-api
function jivo_onLoadCallback() {
$('#online-consultant').addClass('enabled').click(function() {
jivo_api.open();
});
}
// scss
@panych
panych / app.coffee
Created March 9, 2015 09:05
Make position: fixed useful for horizontal scrolling
# Make position 'fixed' useful for horizontal scroll
$header = $('.header')
$(window).scroll(()->
$header.css('left', "-#{ $(window).scrollLeft() }px")
)