Skip to content

Instantly share code, notes, and snippets.

@christhekeele
christhekeele / 1-indirect_uses_tracker.ex
Last active January 8, 2026 20:45
Elixir metaprogramming module usage: A way to track when certain modules are used, and an example adapter/plugin architecture built on top.
# For simpler use cases, see the UsesTracker instead:
# https://gist.github.com/christhekeele/e858881d0ca2053295c6e10d8692e6ea
###
# A way to know, at runtime, what modules a module has used at compile time.
# In this case, you include `IndirectUsesTracker` into a module. When that module gets
# used in some other module, it makes that module registerable under a namespace of your choosing.
# When the registerable module is used into a third module, that third module will know at runtime which
# registerables were `use`d in it at compile time, via a function titled after the namespace.
@joshuap
joshuap / deploy.rb
Created October 7, 2012 01:19
Honeybadger deployment notification capistrano task using local machine and curl
namespace :deploy do
desc "Notifies Honeybadger locally using curl"
task :notify_honeybadger do
require 'json'
require 'honeybadger'
begin
require './config/initializers/honeybadger'
rescue LoadError
logger.info 'Honeybadger initializer not found'
@dgutov
dgutov / gist:1274520
Created October 10, 2011 02:35
ruby-indent-line advice for closing paren
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
(goto-char (cadr state))