Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
SteveBenner / conditional-html-tags.rb
Last active October 18, 2019 02:58
Helper [tag] for generating one or more HTML tags inside IE conditional comments, in the style of HTML5 Boilerplate
# This is a special tag helper that generates multiple HTML tags in the style of HTML5 Boilerplate,
# meaning each is placed within an IE conditional comment and has special classes applied to it.
# One tag is created for each version of Internet Explorer specified in the first argument.
#
# @see https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/html.md#conditional-html-classes
#
# @note This helper requires a Slim block!
# @note The output of this helper must be HTML escaped!
#
# @param [Range] ie_versions A range of IE versions to generate code for, in which the
@SteveBenner
SteveBenner / html5bp-lean.slim
Created September 25, 2014 11:12
Slim template - Lean version of HTML5 Boilerplate
ruby:
google_analytics_key = 'UA-XXXXXXXX-X' # your key may have more or less characters
page_title = ''
page_description = ''
doctype html
== conditional_html_tags_for_ie_versions 7..8, lang: 'en'
head
meta charset="utf-8"
meta http-equiv="X-UA-Compatible" content="IE=edge; chrome=1"
@SteveBenner
SteveBenner / html5-boilerplate-4.3.0.slim
Created September 25, 2014 15:06
Slim template - HTML5 Boilerplate index page
/ This template produces an EXACT replica of the `index.html` file found in HTML5 Boilerplate v4.3.0
/ The official distribution is located at: https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/index.html
/
/ For a more elegant way to generate the HTML tags within IE conditional comments, see the abstraction
/ in my gist at: https://gist.github.com/SteveBenner/a71f41e175f135b7d69b
/
doctype html
/ The min and max values of the version range actually represent all values below or above the limit
- ie_versions = 6..9 # A minimum value of 6 for example, translates into 'less than 7'
- for version in ie_versions
@SteveBenner
SteveBenner / html5bp-middleman.slim
Last active October 5, 2016 14:27
Slim template - Middleman layout based off HTML5 Boilerplate
doctype html
== conditional_html_tags_for_ie_versions 7..8, lang: 'en'
head
meta charset="utf-8"
meta http-equiv="X-UA-Compatible" content="IE=edge; chrome=1"
title = page_title
meta name="description" content=page_description
meta name="viewport" content="width=device-width, initial-scale=1"
/ Normalize - front end standardization
= stylesheet_link_tag 'vendor/normalize'
@SteveBenner
SteveBenner / _google-analytics.slim
Created September 26, 2014 05:43
Slim partial - Google analytics
/ Official Google Analytics tracking code (updated 2014-10-23)
/
/ @option [String] google_analytics_key GA key in a format similar to: 'UA-XXXXXXXX-X'
/
- if google_analytics_key
javascript:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
@SteveBenner
SteveBenner / yaml-env-vars-groups.rb
Last active April 28, 2023 22:14
Define Environment variables in your shell using a YAML config file
#!/usr/bin/env ruby
#
# This bit of code lets you define Environment variables in your shell via a YAML file.
# It works by composing Bash commands from the parsed data, meant to be executed within
# a Bash environment, which will export the variables just as in a regular Bash profile.
# This is accomplished by executing this script via the Bash substitution syntax $(...)
# which returns the output of evaluating whatever is inside the parenthesis, which in
# the case of this script would be appropriate 'export' commands that are run by Bash.
#
# This version is designed to parse aliases organized under named groups in the YAML
@SteveBenner
SteveBenner / yaml-aliases-groups.rb
Last active April 16, 2022 03:34
Define aliases in your shell with YAML instead of in Bash
#!/usr/bin/env ruby
#
# If you've got a collection of Bash aliases that just keeps growing... Consider using YAML!
#
# This version is designed to parse aliases organized under named groups in the YAML
# file, so the first level of mappings are purely semantic, and are used to keep the
# data organized and well-documented.
#
require 'pathname'
require 'yaml'
@SteveBenner
SteveBenner / macfix4-disable-crash-reporter.rb
Created October 12, 2014 15:34
Mac fix - Disable CrashReporter and prevent it from launching
#!/usr/bin/env ruby
#
# Mac fix 4 - Disable CrashReporter
#
# CrashReporter is a daemon that monitors for crashes and generates a report (duh) when they occur.
# If an application (such as Finder) become stuck in an infinite crash loop, then sometimes it's
# desirable to just turn off CrashReporter entirely, as it will continually generate processes in
# the background which spew errors and logs, resulting in massive overhead to your system resources.
#
# DIAGNOSING:
/ This partial allows you to render the Coderwall badges of specified user
/
ruby:
username = 'your-coderwall-username'
orientation = 'horizontal' # can be 'vertical' or 'horizontal'
/ Place the following tags in the HEAD section of your web page (omit jQuery if already present, of course)
link href="http://coderwall.com/stylesheets/jquery.coderwall.css" media="all" rel="stylesheet" type="text/css"
script src="https://code.jquery.com/jquery-2.1.1.min.js"
script src="http://coderwall.com/javascripts/jquery.coderwall.js"
body.loading:after {
/* with no content, nothing is rendered */
content: "";
position: fixed;
/* element stretched to cover during rotation an aspect ratio up to 1/10 */
top: -500%;
left: -500%;
right: -500%;
bottom: -500%;
z-index: 9999;