Skip to content

Instantly share code, notes, and snippets.

View byroot's full-sized avatar

Jean Boussier byroot

View GitHub Profile
@byroot
byroot / idea.md
Created January 28, 2024 23:03
Relation refactoring idea
  • Extending -> record module and method_missing + bind_call (confirm that bind call doesn't allocate metaclass).
  • Single generic Relation class. Stop dynamic method generation.
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
end
require 'benchmark/ips'
@byroot
byroot / fix-wifi.sh
Last active September 30, 2022 21:06
#!/bin/bash
# See: http://osxdaily.com/2015/10/16/fix-wi-fi-problems-mac-os-x-el-capitan/
sudo rm -f /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
com.apple.network.identification.plist
sudo rm -f /Library/Preferences/SystemConfiguration/com.apple.wifi.message-tracer.plist
sudo rm -f /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
sudo rm -f /Library/Preferences/SystemConfiguration/preferences.plist
sudo reboot
RubyVM::InstructionSequence.compile_option = { peephole_optimization: false }
class RubyVM::InstructionSequence
def self.load_iseq(path)
RubyVM::InstructionSequence.compile_file(path)
end
end
# Can be enabled with RUBYOPT="-r /path/to/disable_opt.rb"
@byroot
byroot / eols.sh
Created March 27, 2012 15:08
Convert the whole git history with dos2unix
git filter-branch --tree-filter 'git ls-files -z | xargs -0 dos2unix' -- --all
@byroot
byroot / results.txt
Last active September 5, 2021 12:52
Impact of stack size on exceptions performance
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin17]
$ ruby yield-vs-block.rb
Nested yield stack size: 402
Forward block stack size: 202
Warming up --------------------------------------
baseline 82.138k i/100ms
nested-yield 16.030k i/100ms
forward-block 28.945k i/100ms
Calculating -------------------------------------
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "activerecord", "~> 5.2"
module SomeObserver
extend ActiveSupport::Concern
included do
after_create :do_something
end
def do_something
#
end
byroot@raplh:byroot:$ MISSING_KEY=1 SSHKIT_VERSION=1.10.0 ruby repro-sshkit.rb
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Resolving dependencies...
Using net-ssh 3.2.0
Using bundler 1.12.3
Using net-scp 1.2.1
Using sshkit 1.10.0
INFO [a3263e4e] Running /usr/bin/env echo foo as git@github.com
-- Content of known_hosts file:
if Rails::VERSION::MAJOR >= 4
if Rails::VERSION::MINOR > 0
ActiveSupport::Deprecation.warn("This patch is probably not useful anymore. Check if https://github.com/rails/rails/pull/12425 have been released.")
end
class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
def type_cast(value, column)
case value
when TrueClass