$ ruby thing.rb
[Calculator::LoggerDecorator, Calculator, Object, Kernel, BasicObject]
Calculator#div(10, 2) => 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductSearch < ScopeBuilder::Scope | |
param :name, :string | |
param :category, :integer | |
param :status, :string | |
order_by :name, :created_at | |
private | |
def apply_name_param(scope, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Broker.Workers.Appsignal do | |
@moduledoc false | |
alias Appsignal.Error | |
alias Appsignal.Transaction | |
def handle_event([:oban, event], measurement, meta, _) when event in [:success, :failure] do | |
transaction = record_event(measurement, meta) | |
if event == :failure && meta.attempt >= meta.max_attempts do | |
{reason, message, stack} = normalize_error(meta) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Delegator do | |
defmacro __using__(opts) do | |
quote do | |
def unquote(:"$handle_undefined_function")(name, args) do | |
apply(Keyword.get(unquote(opts), :target), name, args) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Slide up menu | |
*/ | |
.thing { | |
box-sizing: border-box; | |
position: absolute; | |
bottom: 0; | |
left: calc(50% - 200px); | |
height: 50px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Airbrake | |
module Sidekiq | |
# Internal: Airbrake filter that ignores exceptions from Sidekiq Jobs that | |
# will be retried. | |
class RetryableJobsFilter | |
def call(notice) | |
job = notice[:params][:job] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rewrite VCR Cassettes to move the URL:PASSWORD pair from | |
# the 'uri' to the 'Authorization' header. | |
# This is required when moving from WebMock 1 to 2+. | |
require 'yaml' | |
require 'uri' | |
require 'base64' | |
Dir["spec/fixtures/vcr_cassettes/*.yml"].each do |path| | |
cassette = YAML.load_file(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PictureHelper | |
# Public: Generate a `picture` tag with multiple sources for different formats | |
# (JPG, WEBP, PNG, etc) and with support for high density displays. An `img` | |
# element will also be created, so the User Agent can display it's selected | |
# source and use as a fallback if it doesn't support the `picture` element yet. | |
# | |
# Examples | |
# | |
# # => picture_tag('blankslate', formats: %(webp png)) | |
# This call will return a `picture` element with two `source` children |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cleanup existing assets and cached files | |
rm -rf public/assets tmp/cache/assets | |
# Stop and start Spring to ensure we have a pristine process | |
# and to remove the Rails boot time from the benchmark. | |
bin/spring stop | |
bin/rake secret > /dev/null | |
time bin/rake assets:precompile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :assets do | |
# Display all precompiled assets and their included | |
# dependencies. | |
# | |
# Arguments: | |
# * '--sort' sort the included deps list by their file size. | |
# | |
# bin/rake assets:stats [-- --sort] | |
desc 'List file size for precompiled assets' | |
task stats: :environment do |
NewerOlder