Skip to content

Instantly share code, notes, and snippets.

@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-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 / 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 / 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 / 1_helper.rb
Last active December 26, 2015 07:59
Block alias in Ruby on Rails
# application_helper.rb
def b(block_name, options={}, &block)
options.merge!(:body => capture(&block)) if block_given?
render :partial => block_name, :locals => options
end
@panych
panych / erb_slim_haml.erb
Last active December 26, 2015 07:29
ERB vs Slim vs Haml
<div class="dev-diagram">
<% steps.each_with_index do |step, index| %>
<% if index.even? %>
<% step_class = 'dev-diagram__step dev-diagram__step_right' %>
<% else %>
<% step_class = 'dev-diagram__step dev-diagram__step_left' %>
<% end %>
<div class="#{step_class}">
<div class="dev-diagram__ic">
@panych
panych / enable_drafts_parents
Created February 4, 2013 10:44
Wordpress. Allow to set draft page as a parent page
/*
* Allow to set draft page as a parent page
*/
add_filter( 'page_attributes_dropdown_pages_args', 'enable_drafts_parents' );
add_filter( 'quick_edit_dropdown_pages_args', 'enable_drafts_parents' );
function enable_drafts_parents( $args ) {
$args['post_status'] = 'draft,publish,pending';
return $args;
}