Skip to content

Instantly share code, notes, and snippets.

View yaml.rb
# frozen_string_literal: true
# tiny rerunner (I use this on local to rerun script)
require_relative '../rerunner/rerunner.rb'
require 'yaml'
require 'psych'
yaml = <<~YAML
# amazing YAML file
#
# hello
View test.py
from ruamel.yaml import YAML
import sys
example = """
# hello
test: "test\\ntest\\ntest" # a test
test2: hello.. #world
"""
rt_yaml=YAML(typ='rt')
View db.rake
# frozen_string_literal: true
# we should set the locale before the migration
task 'set_locale' do
begin
I18n.locale = (SiteSetting.default_locale || :en) rescue :en
rescue I18n::InvalidLocale
I18n.locale = :en
end
end
View db.rake
# frozen_string_literal: true
# we should set the locale before the migration
task 'set_locale' do
begin
I18n.locale = (SiteSetting.default_locale || :en) rescue :en
rescue I18n::InvalidLocale
I18n.locale = :en
end
end
View db.rake
# frozen_string_literal: true
# we should set the locale before the migration
task 'set_locale' do
begin
I18n.locale = (SiteSetting.default_locale || :en) rescue :en
rescue I18n::InvalidLocale
I18n.locale = :en
end
end
View db.rake
# frozen_string_literal: true
# we should set the locale before the migration
task 'set_locale' do
begin
I18n.locale = (SiteSetting.default_locale || :en) rescue :en
rescue I18n::InvalidLocale
I18n.locale = :en
end
end
View db.rake
# frozen_string_literal: true
# we should set the locale before the migration
task 'set_locale' do
begin
I18n.locale = (SiteSetting.default_locale || :en) rescue :en
rescue I18n::InvalidLocale
I18n.locale = :en
end
end
View db.rake
# frozen_string_literal: true
# we should set the locale before the migration
task 'set_locale' do
begin
I18n.locale = (SiteSetting.default_locale || :en) rescue :en
rescue I18n::InvalidLocale
I18n.locale = :en
end
end
View 20210208022739_move_new_since_to_new_table.rb
# frozen_string_literal: true
class MoveNewSinceToNewTable < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
BATCH_SIZE = 30_000
def up
offset = 0
loop do
min_id, max_id = DB.query_single(<<~SQL, offset: offset, batch_size: BATCH_SIZE)
View AFTER
[RUBY_DEBUG_COUNTER] 219762 show_debug_counters
[RUBY_DEBUG_COUNTER] mc_inline_hit 412,725
[RUBY_DEBUG_COUNTER] mc_inline_miss_klass 39,736
[RUBY_DEBUG_COUNTER] mc_inline_miss_invalidated 0
[RUBY_DEBUG_COUNTER] mc_inline_miss_empty 3,694
[RUBY_DEBUG_COUNTER] mc_inline_miss_same_cc 0
[RUBY_DEBUG_COUNTER] mc_inline_miss_same_cme 28,893
[RUBY_DEBUG_COUNTER] mc_inline_miss_same_def 352
[RUBY_DEBUG_COUNTER] mc_inline_miss_diff 6,797
[RUBY_DEBUG_COUNTER] mc_cme_complement 166