Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephen Benner SteveBenner

View GitHub Profile
@SteveBenner
SteveBenner / unbrew.rb
Last active Dec 4, 2020
Homebrew uninstall script
View unbrew.rb
#!/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-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 / 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 / load-jQuery.js
Created Aug 7, 2020 — forked from takkyuuplayer/load-jQuery.js
use jQuery in Chrome javascript console.
View load-jQuery.js
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();
View pry-cheatsheet.md

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 / 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 / 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:
#
@SteveBenner
SteveBenner / dl-tatw.rb
Created May 17, 2015
Web scraper that downloads archived episodes of 'Trance Around The World' podcast
View dl-tatw.rb
#!/usr/bin/env ruby
#
# This is a web scraper which downloads mp3 files from the TATW web archives.
#
# Usage: run this script and pass it an episode range to download via arguments
#
# Dependencies: requires 'aria2' to be installed (uses the CLI tool 'aria2c')
#
require 'pathname'
require 'colorize' # Use of this gem is optional; it makes the output prettier
@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 / README-Template.md
Created Jul 28, 2017 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites