Skip to content

Instantly share code, notes, and snippets.

View sax's full-sized avatar

Eric Saxby sax

View GitHub Profile
@sax
sax / databases.rake
Last active March 5, 2022 17:27
Overwrite Rails 3 databases rake task to remove method pollution on Object
# The built-in Rails database rake task is completely crazy, and defines methods on Object. This causes
# problems with Makara, which uses a delegator pattern along with method_missing.
require 'active_support/core_ext/object/inclusion'
require 'active_record'
class Object
remove_method :configs_for_environment
remove_method :create_database
remove_method :current_config
@sax
sax / _table
Last active October 18, 2021 22:11
eprof membrane core analysis
Process: #PID<0.3196.0>, Struct: Elixir.Membrane.Core.Pipeline.State, Module: Elixir.Membrane.RTC.Engine
Process: #PID<0.3197.0>, Clock
Process: #PID<0.3199.0>, Clock
Process: #PID<0.3201.0>, Clock
Process: #PID<0.3208.0>, Clock
Process: #PID<0.3234.0>, Clock
Process: #PID<0.3243.0>, Clock
Process: #PID<0.3776.0>, Clock
Process: #PID<0.3778.0>, Clock
Process: #PID<0.3785.0>, Clock
@sax
sax / 1-crash
Last active October 7, 2021 16:15
membrane re-linking crash
[error] GenServer #PID<0.1474.0> terminating
** (Membrane.LinkError) Pad {Membrane.Pad, :input, "80942349-2d9d-48f2-b20e-f5d1aabbb057:c8beb6b4-5c3c-4c8f-8521-43c32490e172 "} has already been linked
(membrane_core 0.7.0) lib/membrane/core/child/pad_controller.ex:165: Membrane.Core.Child.PadController.validate_pad_being_linked!/4
(membrane_core 0.7.0) lib/membrane/core/child/pad_controller.ex:48: Membrane.Core.Child.PadController.handle_link/5
(membrane_core 0.7.0) lib/membrane/core/bin.ex:173: Membrane.Core.Bin.handle_call/3
(stdlib 3.16) gen_server.erl:721: :gen_server.try_handle_call/4
(stdlib 3.16) gen_server.erl:750: :gen_server.handle_msg/6
(stdlib 3.16) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.1587.0>): {Membrane.Core.Message, :handle_link, [:input, %Membrane.Core.Parent.Link.Endpoint{child: {:endpoint, "0c920133-55a6-45a3-9087-9ef9307d906a"}, pad_props: [options: [encoding: :OPUS]], pad_ref: {Membrane.Pad, :input, "80942349-2d9d-48f2-b20e-f5d1aabbb0
@sax
sax / postgresql.conf
Created December 9, 2015 19:37
PostgreSQL configuration
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed
@sax
sax / rmagick-install.sh
Created February 8, 2010 18:50
install imagemagick + dependencies
#!/bin/sh
cd ~/Downloads
echo ":::::::::: WGET"
# install wget, which is cleverer than curl
curl -O http://ftp.gnu.org/gnu/wget/wget-1.11.tar.gz
tar zxvf wget-1.11.tar.gz
cd wget-1.11
./configure --prefix=/usr/local
@sax
sax / config.exs
Last active February 17, 2021 22:04
Elixir OpenTelemetry LiveView / crash tracking
import Config
## ....
config :logger,
backends: [
:console,
OpenTelemetryCrashLogger
]
@sax
sax / nginx.conf
Created September 7, 2010 22:49
unicorn + nginx on launchd
user sax staff;
worker_processes 1;
daemon off;
error_log /var/log/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
pid /var/run/nginx.pid;
### Keybase proof
I hereby claim:
* I am sax on github.
* I am s4xx4s (https://keybase.io/s4xx4s) on keybase.
* I have a public key ASDd9tKJczNf1S-dwRLmjMh0tsoGL4gDBTaMaL9fqzSF2Ao
To claim this, I am signing this object:
@sax
sax / content_type_detector.rb
Created August 10, 2017 18:01
paperclip content-type detection for Office
module Paperclip
module ContentTypeDetectorOverrides
def calculated_type_matches
possible_types.select do |content_type|
if content_type.start_with?('application/vnd.openxmlformats-officedocument')
content_type == type_from_file_contents ||
type_from_file_contents == 'application/zip'
else
content_type == type_from_file_contents
end
@sax
sax / __scenario_flows.rb
Last active July 18, 2017 19:14
Flow output in feature specs
# lib/test/scenario_flows.rb
module Test
module ScenarioFlows
def formatter
@formatter ||= RSpec.configuration.formatters.first
end
def formatter_names
@formatter_names ||= RSpec.configuration.formatters.map { |f| f.class.to_s }.join(' ')