Skip to content

Instantly share code, notes, and snippets.

Avatar

Jean Boussier byroot

View GitHub Profile
View enum_52.rb
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"
View fix-wifi.sh
#!/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
View result.sh
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:
View active_record_mysql2_missing_bind_value.rb
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'
# Activate the gem you are reporting the issue against.
View memcache-bench.rb
require 'benchmark/ips'
require 'active_support/cache'
require 'memcached'
require 'active_support/cache/memcached_store'
require 'active_support/cache/dalli_store'
$dalli = ActiveSupport::Cache::DalliStore.new('127.0.0.1:11211')
$memcached = ActiveSupport::Cache::MemcachedStore.new('127.0.0.1:11211')
KEY = 'somekey'
View bench.txt
Calculating -------------------------------------
thread-safe 72.674k i/100ms
-------------------------------------------------
thread-safe 2.128M (± 5.8%) i/s - 10.610M
Calculating -------------------------------------
thread-unsafe 109.385k i/100ms
-------------------------------------------------
thread-unsafe 5.545M (± 7.9%) i/s - 27.565M
View bench_rails4.0.txt
$ bundle exec ruby per_thread_registry_benchmark.rb
Calculating -------------------------------------
thread-safe 25.176k i/100ms
thread-unsafe 30.069k i/100ms
-------------------------------------------------
thread-safe 1.480M (± 6.5%) i/s - 7.377M
thread-unsafe 2.480M (± 7.2%) i/s - 12.328M
View idempotent_counter_cache.rb
module IdempotentCounterCache
module BuilderExtension
def add_counter_cache_callbacks(reflection)
super
cache_column = reflection.counter_cache_column
foreign_key = reflection.foreign_key
# This skip_callback do not work... may be related to https://github.com/rails/rails/issues/12571
# model.skip_callback(:destroy, :before, "belongs_to_counter_cache_before_destroy_for_#{name}")
View mysql_boolean_uniqueness.rb
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
View wtf.rb
class Foo
def bar(*args)
attribute(:bar, *args)
end
def attribute(name)
puts name
end
You can’t perform that action at this time.