You start with this:
And must end up with this:
class IncreaseDelayedJobsHandlerLength < ActiveRecord::Migration | |
def up | |
# Increase to MEDIUMTEXT (16,777,215 bytes) | |
change_column(:delayed_jobs, :handler, :text, limit: 16.megabytes - 1) | |
end | |
def down | |
# Back to default TEXT (65,535 bytes) | |
change_column(:delayed_jobs, :handler, :text) | |
end |
irb(main):051:0> puts 'foo\bar' | |
foo\bar | |
nil | |
irb(main):052:0> puts 'foo\\bar' | |
foo\bar | |
nil | |
irb(main):053:0> puts 'foo\\\bar' | |
foo\\bar | |
nil | |
irb(main):054:0> puts 'foo\\\\bar' |
<ul> | |
<li>Foo</li> | |
<li>These <b>two</b> <b>words</b> should stay separate.</li> | |
<li>Bar</li> | |
</ul> |
module ApplicationHelper | |
def inline_tag(*args, &block) | |
body = Nokogiri::HTML(capture(&block)).at_css('body') | |
# First-level text nodes | |
body.xpath('text()').each do |node| | |
node.content = node.content.strip | |
end | |
content_tag(*args) { body.inner_html.strip.html_safe } |
describe ReportsController do | |
describe :create do | |
before do | |
@payload = { :version => "1.0.0" } | |
end | |
it "succeeds with present serial" do | |
@payload[:serial] = "123abc" | |
post reports_path, @payload.to_json |
require 'benchmark' | |
# Say you have a Foo class and you want instances of this class to delegate unknown | |
# methods to two objects, first to @object_1, then to @object_2. | |
class Foo | |
def initialize | |
@object_1 = nil | |
@object_2 = '' | |
end |
# gem install redcarpet | |
# gem install pygments.rb | |
require 'redcarpet' | |
require 'pygments' | |
class MarkdownWithPygments < Redcarpet::Render::HTML | |
def block_code(code, language) | |
Pygments.highlight(code, lexer: language) | |
end |
require 'benchmark' | |
# Which is faster for creating an array of numbers, lowercase and uppercase letters? | |
Benchmark.benchmark Benchmark::CAPTION, 12 do |bm| | |
bm.report 'String#split' do | |
100_000.times { '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('') } | |
end | |
bm.report 'Range#to_a' do | |
100_000.times { ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a } |