Skip to content

Instantly share code, notes, and snippets.

View garmoshka-mo's full-sized avatar

Daniel garmoshka-mo

View GitHub Profile
diff --git a/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView.kt b/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView.kt
index e666cb5..729fda2 100644
--- a/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView.kt
+++ b/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView.kt
@@ -8,6 +8,7 @@ import android.content.res.Configuration
import android.hardware.camera2.*
import android.util.Log
import android.util.Range
+import android.util.Size
import android.view.*
m503535072m630115302j636222860tl635678849
v9787875253
@garmoshka-mo
garmoshka-mo / rake_patch.rb
Last active April 7, 2023 14:51
Fix rake tasks to accept arguments in normal bash way
# Insert this into Rakefile before Rails.application.load_tasks: require './lib/rake_patch.rb'
Rake::Application.class_eval do
alias origin_top_level top_level
def top_level
@top_level_tasks = [top_level_tasks.join(' ')]
origin_top_level
end
@garmoshka-mo
garmoshka-mo / rake_patch.rb (not debugged)
Last active September 14, 2021 09:24
Fix rake tasks to accept arguments in normal bash way; Condense huge backtraces for exceptions
Rake::Application.class_eval do
def parse_task_string(_)
args = ARGV.clone
return args.shift,
args.reject{|_| _ =~ /^(\w+)=(.*)$/} # clean ENV variables
.join(' ').presence
end
def error(msg)
hide_from_stack = true
Print.error "😱 #{msg}"
binding.pry if $launched_specs_examples < 2
raise msg
end
def shit!(msg)
hide_from_stack = true
@garmoshka-mo
garmoshka-mo / iterations_sugar.rb
Last active September 26, 2019 10:43
lib/iterations_sugar.rb
module IterationsSugar
def extract
result = ActiveArray.new
each_with_index do |item, index|
e = yield item, index
result << e unless e.nil?
end
result
end
@garmoshka-mo
garmoshka-mo / fix_byebug_backtrace.rb
Created June 15, 2017 10:25
Make sane backtrace in byebug
Byebug::WhereCommand.class_eval do
def get_backtrace
(context.stack_size-1).downto(0).map do |index|
hash = Byebug::Frame.new(context, index).to_hash
path = hash[:file].gsub(Rails.root.to_s, '')
next if path.match BACKTRACE_TRASH
"#{hash[:mark]} #{path}:#{hash[:line]} #{hash[:call]}"
@garmoshka-mo
garmoshka-mo / rspec_backtrace_filter.rb
Last active May 30, 2017 08:38
Sane output of rspec exceptions
RSpec::Core::BacktraceFormatter.class_eval do
alias :native_format_backtrace :format_backtrace
alias :native_backtrace_line :backtrace_line
def format_backtrace(backtrace, options={})
@lines = 0
native_format_backtrace backtrace, options
end
@garmoshka-mo
garmoshka-mo / application_controller.rb
Last active May 30, 2018 14:30
Handling exceptions
rescue_from StandardError do |exception|
if request.xhr?
render text: exception.message, :status => 500
elsif request.format.json?
err = {error: exception.message}
err[:backtrace] = exception.backtrace.select do |line|
# filter out non-significant lines:
%w(/gems/ /rubygems/ /lib/ruby/).all? do |litter|
not line.include?(litter)
@garmoshka-mo
garmoshka-mo / trace.rb
Created October 12, 2016 14:44
Trace HTTP headers & cookies
# config/application.rb
config.middleware.use "Loggo"
class Loggo
def initialize(app)
@app = app
end
def call(env)
request = ActionDispatch::Request.new(env)