Skip to content

Instantly share code, notes, and snippets.

@illarionvk
illarionvk / html_if_IE8.haml
Last active December 21, 2015 05:49
HAML [If IE 8] conditions header for ZURB Foundation 4
/[if IE 8] <html class="no-js lt-ie9" lang="en">
<!--[if gt IE 8]><!-->
%html.no-js{lang: "en"}
/<![endif]
@illarionvk
illarionvk / hreflang-conditional-link-tag.scss
Last active December 21, 2015 16:18
Append language abbreviation (EN, RU, PL) in superscript to a link if the language of the page is different.
@illarionvk
illarionvk / Guardfile
Created September 11, 2013 09:24
Guard configuration for Shopify theme development
guard 'sass', :input => '_sass', :output => 'assets', :extension => ".scss.liquid", :style => :compressed, :all_on_start => true
guard 'sprockets', :destination => 'assets', :root_file => '_foundation/js/foundation/foundation_all.js'
guard 'haml', :default_ext => 'liquid', :run_at_start => true do
watch %r{.+(\.liquid\.haml)}
end
@illarionvk
illarionvk / .htaccess
Created September 13, 2013 07:35
Apache: Serve pre-compressed static CSS and JavaScript files
AddEncoding gzip .gz
RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
<Files *.css.gz>
ForceType text/css
@illarionvk
illarionvk / hide-vertical-scrollbar-in-code-example.js
Created November 30, 2013 10:48
Remove vertical scrollbars from Jekyll syntax-highlighted code examples by adding 1px to the wrapper div height.
var codeblocks = document.getElementsByClassName('highlight');
for (var i = 0; i < codeblocks.length; ++i) {
var item = codeblocks[i];
// console.log("Old height:" + " " + item.offsetHeight);
item.style.height = item.offsetHeight + 1 + 'px';
// console.log("New height:" + " " + item.offsetHeight);
}
@illarionvk
illarionvk / extract_data.js
Created January 13, 2014 09:04
Find elements in 50 HTML files, extract data and create Jekyll post files with YAML metadata using Node.js
// 1. Get list of files
// 2. For each file:
// 2.1 Read a file
// 2.2 Find required data
// 2.3 Put the information in a JSON object
// 3. Convert JSON object to YAML
// 4. Write new Markdown file in _posts folder
var fs = require('fs')
@illarionvk
illarionvk / deprecation-warning-trigger
Created March 28, 2014 20:57
Sass 3.3 deprecation warning trigger
//************************************************************************//
// Generate a variable ($all-text-inputs) with a list of all html5
// input types that have a text-based input, excluding textarea.
// http://diveintohtml5.org/forms.html
//************************************************************************//
$inputs-list: 'input[type="email"]',
'input[type="number"]',
'input[type="password"]',
'input[type="search"]',
'input[type="tel"]',
@illarionvk
illarionvk / _clearfix.scss
Created April 4, 2014 14:17
Clearfix mixin to do clear floats
@mixin clearfix {
*zoom:1;
&:before, &:after { content: " "; display: table; }
&:after { clear: both; }
}
@illarionvk
illarionvk / gulpfile.coffee
Created July 9, 2014 14:00
Using child_process.exec to launch Sass on file change
exec = require('child_process').exec
_ = require('lodash')
autoprefix = require('gulp-autoprefixer')
chalk = require('chalk')
concat = require('gulp-concat')
es = require('event-stream')
gulp = require('gulp')
gutil = require('gulp-util')
order = require('gulp-order')
plumber = require('gulp-plumber')
@illarionvk
illarionvk / add-range-to-dropdown.js
Created September 30, 2014 09:01
Automate adding numeric range to dropdown - Bold Apps Product Options app for Shopify
// Run the code in developer console, done best through Chrome's Javascript snippets
// First add LoDash
$('body').append('<script src="//cdn.jsdelivr.net/lodash/2.4.1/lodash.min.js"></script>');
// Add range of steps to Bold Apps Product Option dropdown
(function() {
var valueRange = _.range(-5, 5.25, 0.25);
function addNewValue(value) {