Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
SteveBenner / ghost-upgrade.rake
Last active August 29, 2015 13:59
Rake - upgrade a Ghost blog installation
require 'bundler'
require 'fileutils'
Bundler.require
GHOST_DIR = ENV['GHOST_HOME'] || '<your_ghost_folder>'
THEME = 'casper'
namespace :blog do
desc 'Upgrades Ghost using given file'
@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 / shortcuttr.rb
Last active August 29, 2015 14:00
Simple script that generates executable shortcuts from the command line
#!/usr/bin/env ruby
#
# Shortcuttr - generates executable shortcuts
#
require 'fileutils'
SCRIPT = File.join ENV['HOME'], 'github/ruby-scripts/system/bin', ARGV.first.to_s
File.open SCRIPT, 'w', 0755 do |f|
f.puts '#!/usr/bin/bash'
f.puts '# This executable shortcut was generated by Stephen Benner, a truly lazy programmer'
@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 / fname_incr.rb
Created May 6, 2014 03:26
Function which returns a given filename or the incremented version thereof
def fname_incr(fname)
!File.exists?(fname) ?
fname :
/([0-9]+)\./.match(fname) ?
fname_incr(fname.sub(/([0-9]+)/) { |m| (m.to_i+1).to_s }) :
fname_incr(fname.sub(/[^\.]*/) { |m| m+'1' })
end
@SteveBenner
SteveBenner / git-helpers.bash
Last active November 30, 2016 06:02
Bash functions for managing Git
#
# FUNCTIONS
#
# Test the first argument of a command for a git host identifier (aliases configured in ssh-config)
is_git_host() {
case "$1" in
'gh') host='github-personal'
user='SteveBenner'
true ;;
@SteveBenner
SteveBenner / nuke-ruby.bash
Created July 17, 2014 13:35
When there is just too much Ruby in yo OS
# Nuke Ruby!
rm -rf ~/.gem
rm -rf ~/.rubies
# Prerequisites for Mac OSX installation
#
# Make sure Xcode or the command line tools are installed
# This one's up to you: https://github.com/kennethreitz/osx-gcc-installer#readme
#
# Install Homebrew if not installed
@SteveBenner
SteveBenner / .bowerrc.yml
Created August 15, 2014 07:20
Bower - configuration file
# Bower configuration
#
# Official docs at: http://bower.io/docs/config/
# Last updated at: 2014-08-14
#
# Config is obtained by merging the following, in given order:
# - CLI args via -config
# - Environment variables
# - Local .bowerrc located in the current working directory
# - All .bowerrc files upwards the directory tree
@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:
#
@SteveBenner
SteveBenner / google-fonts.rb
Last active October 5, 2016 14:27
Helper [tag] that loads Google fonts into your webpage via the web API
# 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