Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
SteveBenner / unbrew.rb
Last active January 3, 2024 01:44
Homebrew uninstall script
#!/usr/bin/env ruby
#
# CLI tool for locating and removing a Homebrew installation
# http://brew.sh/
#
# Copyright (C) 2014 Stephen C. Benner
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@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 / _html5video.slim
Last active June 14, 2022 05:02
Slim partial - HTML5 video tag
/ Generate an HTML5 video tag with embedded Flash fallback
/ @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video HTML5 video tag spec
/
/ @local [Hash] video Attribute hash for the `video` tag
/ @option video [Integer] :width (320) Width of the video tag in pixels
/ @option video [Integer] :height (240) Height of the video tag in pixels
/
/ @local [Hash] src Mapping of source file types to URLs for source files
/ @option src [String] :mp4 URL of an MP4 source file for the video
/ @option src [String] :webm URL of a WebM source file for the video
@SteveBenner
SteveBenner / pry-cheatsheet.md
Last active April 23, 2022 18:28 — forked from lfender6445/gist:9919357
Pry cheat sheet

Pry Cheat Sheet

Youtube Tutorial (2013)

Command Line

  • pry -r ./config/app_init_file.rb -- load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb -- load your rails into a pry session

Debugger

@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 / brewfix1-osxfuse.rb
Last active April 4, 2022 22:47 — forked from yiufung/truecrypt_fix.bash
Homebrew fix - unexpected files and libs from ‘osxfuse'
#!/usr/bin/env ruby
#
# Homebrew fix 1 - osxfuse dylibs
#
# original solutions: https://gist.github.com/aaronzirbes/3239033
# https://gist.github.com/trinitronx/5437061
#
# Fixes the following:
#
# > Warning: Unbrewed dylibs were found in /usr/local/lib.
@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:
@SteveBenner
SteveBenner / load-jQuery.js
Created August 7, 2020 17:35 — forked from takkyuuplayer/load-jQuery.js
use jQuery in Chrome javascript console.
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
@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 / macfix1-install-nokogiri.rb
Last active August 13, 2019 14:52
Mac fix - Install Nokogiri gem on OS X 10.9 Mavericks
#!/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:
#