Skip to content

Instantly share code, notes, and snippets.

View BlakeWilliams's full-sized avatar
💭
building things, probably

Blake Williams BlakeWilliams

💭
building things, probably
View GitHub Profile
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
# If you want to test against edge Rails replace the previous line with this:
# gem "rails", github: "rails/rails", branch: "main"
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
# If you want to test against edge Rails replace the previous line with this:
# gem "rails", github: "rails/rails", branch: "main"
@BlakeWilliams
BlakeWilliams / tracer.rb
Created September 4, 2021 01:49
Track allocations by Ruby source file + line
require "objspace"
ObjectSpace.trace_object_allocations do
yield
end
allocations = ObjectSpace.each_object.map do |obj|
next if ObjectSpace.allocation_sourcefile(obj).nil?
next if ObjectSpace.allocation_sourcefile(obj) == __FILE__
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.24705882370471954</real>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.12941177189350128</real>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.15686275064945221</real>
module Rescuable
extend ActiveSupport::Concern
class_methods do
def rescue_with_empty_content?
defined?(@rescue_with_empty_content) && @rescue_with_empty_content
end
def rescue_with_empty_content!
@rescue_with_empty_content = true
@BlakeWilliams
BlakeWilliams / crb.md
Last active July 22, 2020 14:00
Component Embedded Ruby ideas

Introduce a context concept that provides anything extra that may be passed to a component:

A component that supports context might be implemented like:

class MyComponent
  def context=(context)
    @context = context
  end
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.32549020648002625</real>
module.exports = {
setupTestFrameworkScriptFile: '<rootDir>/setup.ts',
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}