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 / 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 / XOR.SQL
Created November 30, 2014 03:22
PostgreSQL PL/pgSQL implementation of XOR
CREATE OR REPLACE FUNCTION XOR(boolean, boolean) RETURNS boolean as $$ BEGIN RETURN ($1 and not $2) OR (not $1 and $2); END; $$ LANGUAGE 'plpgsql';
@HotFusionMan
HotFusionMan / gist:9c18e3089506baddef58
Last active August 29, 2015 14:10
Add SQL "LIKE" clauses as ActiveRecord methods in a config/initializers/ file
# Thanks to https://stackoverflow.com/questions/7051062/whats-the-best-way-to-include-a-like-clause-in-a-rails-query for the original code.
module ActiveRecord
module Querying
def match_scope_condition(column, query)
arel_table[column].matches("%#{query}%")
end
def matching(*args)
column_name, opts = args.shift, args.extract_options!
operator = opts[:operator] || :or
# 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 / 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