Skip to content

Instantly share code, notes, and snippets.

khoan / sidekiq_honeybadger.rb
Last active August 11, 2023 00:51
skip reporting transient errors
class TransientError < StandardError
def report_error!
@report_error = true
# skip error reporting by default until we're told to report error
def skip_reporting_error?
# When intercom javascript is excluded from HTML, any attempt to invoke `window.Intercom(...)` would
# result in runtime error. This patch introduces a callback into the controller, so that a shim can
# be inserted, when intercom javascript is excluded.
# Remove this patch and update your code if alternative at
# is accepted.
spec = Bundler.definition.specs.find{|s| == 'intercom-rails'}
if, '> 0.4.2').match?(, spec.version)
raise Gem::DependencyError, "Check that patch is still applicable for intercom-rails gem version #{spec.version}"

Migrate Homebrew from Intel to M1

Dump install packages

brew bundle dump

Remove Intel homebrew

khoan / browser-event.html
Created June 2, 2022 04:38
browser event
<!DOCTYPE html>
<title>Browser events</title>
<button>Click me</button>
khoan / bourne.txt
Created August 19, 2021 13:52
Bourne Shell Reference
Bourne Shell Reference:
This file contains short tables of commonly used items in this shell. In
most cases the information applies to both the Bourne shell (sh) and the
newer bash shell.
Tests (for ifs and loops) are done with [ ] or with the test command.
khoan / australian-postcodes.sql
Created November 13, 2020 06:17 — forked from randomecho/australian-postcodes.sql
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
Taken and cribbed from
May contain errors where latitude and longitude are off. Use at own non-validated risk.
DROP TABLE IF EXISTS postcodes_geo;
khoan / some_controller.rb
Created June 6, 2020 12:00 — forked from mlt/some_controller.rb
Stream PostgreSQL query with potentially huge result set as CSV using gzip compression in Rails and low memory overhead
headers['X-Accel-Buffering'] = 'no'
headers['Cache-Control'] = 'no-cache'
headers['Content-Type'] = 'text/csv; charset=utf-8'
headers['Content-Disposition'] = 'inline; filename="data.csv"'
headers['Content-Encoding'] = 'gzip'
sql = "select * from something;"
self.response_body =
khoan / user.rb
Created May 21, 2020 13:48 — forked from ziemekwolski/user.rb
Ruby model formatted
class User < ActiveRecord::Base
# == Constants ============================================================
GENDERS = [[‘Male’, ‘m’], [‘Female’, ’f’]].freeze
# == Attributes ===========================================================
# paperclip
attr_accessor :remove_logo
khoan / ticket.rb
Created May 2, 2020 00:31 — forked from dhh/ticket.rb
class Ticket < ActiveRecord::Base
belongs_to :grouper
belongs_to :user
validate :user_cant_be_blacklisted, on: :confirmation
validate :user_cant_double_book, on: :confirmation
validate :grouper_cant_be_full, on: :confirmation
validate :grouper_cant_have_occurred, on: :confirmation
[] enable/disable inspection module on agency
PM can go through the whole motion
[] update property condition
add item to condition area /property/144/condition/area/5173
then click back /property/144/condition
items count is still the old items count
inspection report