Skip to content

Instantly share code, notes, and snippets.

@khoan
khoan / huawei-b525s-65a.md
Last active December 24, 2024 13:02
Exploring ways to enable VoLTE
@khoan
khoan / tournament.js
Last active December 16, 2024 07:50
Tournament representation in one file
{
name: "Nittaku NHTTA April 2025",
events: [
{ name: "Open Singles", entryCode: 1, maxRating: 5000 },
{ name: "Division 1 Singles", entryCode: 2, maxRating: 2000 },
{ name: "Division 2 Singles", entryCode: 4, maxRating: 1700 },
{ name: "Division 3 Singles", entryCode: 8, maxRating: 1200 },
{ name: "Division 4 Singles", entryCode: 16, maxRating: 1000 },
{ name: "Division 5 Singles", entryCode: 32, maxRating: 900 },
{ name: "Division 6 Singles", entryCode: 64, maxRating: 700 }
@khoan
khoan / sidekiq_honeybadger.rb
Last active August 11, 2023 00:51
skip reporting transient errors
class TransientError < StandardError
def report_error!
@report_error = true
end
# skip error reporting by default until we're told to report error
def skip_reporting_error?
!@report_error
end
end
# 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 https://github.com/intercom/intercom-rails/pull/344
# is accepted.
spec = Bundler.definition.specs.find{|s| s.name == 'intercom-rails'}
if Gem::Dependency.new(spec.name, '> 0.4.2').match?(spec.name, 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
khoan / browser-event.html
Created June 2, 2022 04:38
browser event
<!DOCTYPE html>
<html>
<head>
<title>Browser events</title>
</head>
<body>
<div>
https://mdn.github.io/learning-area/javascript/building-blocks/events/show-video-box.html
<button>Click me</button>
</div>
@khoan
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
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 blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@khoan
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 = SqlToCsvStreamer.new(sql)
@khoan
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