Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephen Benner SteveBenner

View GitHub Profile
@SteveBenner
SteveBenner / macfix4-disable-crash-reporter.rb
Created Oct 12, 2014
Mac fix - Disable CrashReporter and prevent it from launching
View macfix4-disable-crash-reporter.rb
#!/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:
@SteveBenner
SteveBenner / yaml-aliases-groups.rb
Created Oct 12, 2014
Define aliases in your shell with YAML instead of in Bash
View yaml-aliases-groups.rb
#!/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 / yaml-env-vars-groups.rb
Last active Jun 6, 2018
Define Environment variables in your shell using a YAML config file
View yaml-env-vars-groups.rb
#!/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 / _google-analytics.slim
Created Sep 26, 2014
Slim partial - Google analytics
View _google-analytics.slim
/ 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 / html5bp-middleman.slim
Last active Oct 5, 2016
Slim template - Middleman layout based off HTML5 Boilerplate
View html5bp-middleman.slim
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 / html5-boilerplate-4.3.0.slim
Created Sep 25, 2014
Slim template - HTML5 Boilerplate index page
View html5-boilerplate-4.3.0.slim
/ 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-lean.slim
Created Sep 25, 2014
Slim template - Lean version of HTML5 Boilerplate
View html5bp-lean.slim
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 / conditional-html-tags.rb
Last active Oct 18, 2019
Helper [tag] for generating one or more HTML tags inside IE conditional comments, in the style of HTML5 Boilerplate
View conditional-html-tags.rb
# 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 / google-fonts.rb
Last active Oct 5, 2016
Helper [tag] that loads Google fonts into your webpage via the web API
View google-fonts.rb
# This tag allows you to load one or more font families into your page via the Google Fonts API
#
# @see https://developers.google.com/fonts/ The Web Fonts Project
# @see http://www.google.com/fonts Google Fonts Repository
#
# @note This tag MUST be placed in the <head></head> section of your webpage.
#
# @overload google_fonts(family)
# Load a single font family in the default 'normal' style
# @param [String, Symbol] family Name of a single font family to load
@SteveBenner
SteveBenner / macfix1-install-nokogiri.rb
Last active Aug 13, 2019
Mac fix - Install Nokogiri gem on OS X 10.9 Mavericks
View macfix1-install-nokogiri.rb
#!/usr/bin/env ruby
#
# Mac fix 1 - Install the Nokogiri gem on Mac OS 10.9 Mavericks
#
# Usage: to configure and install using Bundler, pass in 'bundle' as an argument to the script.
#
# Nokogiri works at a very low level, so it has many issues on various platforms.
# As a result, the command `install gem nokogiri` often will fail. This fix is for
# errors involving 'libiconv', such as the following one I encountered:
#