Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# From https://www.networkworld.com/article/3620895/what-asking-which-whereis-or-whatis-can-tell-you-about-linux-commands.html , with syntax corrections for macOS X.
clear
if [ $# == 0 ]; then # if no arguments provided, prompt user
echo -n "What command(s) are you asking about?> "
read args
else
args=$*
# frozen_string_literal: true
# This technique learned from https://www.eliotsykes.com/test-rails-rake-tasks-with-rspec .
require 'rake'
require 'active_support/concern'
module TaskExampleGroup
extend ActiveSupport::Concern
json.cache! @available_internal_employees do
json.available_internal_employees do
json.cache_collection! @available_internal_employees, as: :available_internal_employees do |internal_employees|
json.partial! 'agent_dashboard/internal_employee', internal_employee: internal_employees
end
end
end
@HotFusionMan
HotFusionMan / stars.sh
Created October 9, 2018 23:14 — forked from sebble/stars.sh
List all starred repositories of a GitHub user.
#!/bin/bash
USER=${1:-sebble}
STARS=$(curl -sI https://api.github.com/users/$USER/starred?per_page=1|egrep '^Link'|egrep -o 'page=[0-9]+'|tail -1|cut -c6-)
PAGES=$(($STARS/100+1))
echo You have $STARS starred repositories.
echo

Keybase proof

I hereby claim:

  • I am HotFusionMan on github.
  • I am hotfusionman (https://keybase.io/hotfusionman) on keybase.
  • I have a public key whose fingerprint is 89E6 CD10 2DA8 477B 4251 239D C461 8511 AC18 3574

To claim this, I am signing this object:

@HotFusionMan
HotFusionMan / .irbrc
Last active July 26, 2016 08:31
A useful Rails 4 .irbrc file (for use with Rails-project-specific .irbrc file loading capability from http://railsbros.de/2010/11/29/a-custom-irbrc-for-rails-3.html ). See earlier revisions for Rails 3 version.
def show_controller_action_callbacks
_process_action_callbacks.map(&:filter)
end
alias :action_callbacks :show_controller_action_callbacks
def recognize_path(path, environment = { :method => 'GET', :extras => {} })
(@named_routes ||= Rails.application.routes).recognize_path(path, environment)
end
alias :recognize_route :recognize_path
# For inclusion into a Rails config/initializers/better_errors.rb file.
if defined?(BetterErrors)
if ENV['DEV_PROFILING'] == 'true' || ENV['DEV_DISABLE_ERRORS'] == 'true'
Rails.configuration.middleware.delete( BetterErrors::Middleware )
end
BETTER_ERRORS_EDITORS = { 'x-mine:' => "x-mine://open?file=%{file}&line=%{line}", 'sublime:' => :sublime, 'txmt:' => :textmate, 'emacs:' => :emacs, 'mvim:' => :macvim }
if RUBY_PLATFORM.index( 'darwin' )
unless ENV['BETTER_ERRORS_EDITOR'].blank?
@HotFusionMan
HotFusionMan / apt-check.sh
Created July 26, 2016 08:20
check the updatability status of apt packages on demand on Ubuntu 14.04
sudo /usr/lib/update-notifier/apt-check --human-readable
@HotFusionMan
HotFusionMan / gist:7002217
Created October 16, 2013 03:23
How to render Haml to HTML in the Rails console.
include ActionView::Helpers
haml_code = File.open( 'path/to/haml/file' ) { |file| file.read }
engine = Haml::Engine.new( haml_code )
puts engine.render
@HotFusionMan
HotFusionMan / gist:6386156
Created August 30, 2013 03:48
How to expire just one view fragment from the Rails cache

In the following code, I assume there's a cache_key_for method defined in ApplicationHelper that's being used by the Rails app to compute the key used for caching the asset objects. If that isn't the case in your app, you won't need the helper calls, but you'll need to supply whatever code you're actually using for determining cache key values.

in Rails console:

controller = ApplicationController.new
controller.expire_fragment(helper.cache_key_for(asset))

in other code (where the "helper" method is not defined):

include ApplicationHelper
controller = ApplicationController.new

controller.expire_fragment(cache_key_for(asset))