This file contains hidden or 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 | |
def flatten(arg) | |
return "arg should be an array, but was #{arg.inspect} instead" if arg.nil? || !arg.is_a?(Array) | |
@result = [] | |
analyze(arg) | |
@result | |
end |
This file contains hidden or 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
.modal-dialog { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%) !important; | |
} |
This file contains hidden or 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
src/AppBundle/EventListener/LogoutListener.php: | |
// | |
<?php | |
namespace AppBundle\EventListener; | |
use Symfony\Component\HttpFoundation\RedirectResponse; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface; |
This file contains hidden or 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 DocumentFileTypes | |
module Microsoft | |
WORD = %w( | |
application/msword | |
application/vnd.openxmlformats-officedocument.wordprocessingml.document | |
application/vnd.openxmlformats-officedocument.wordprocessingml.template | |
application/vnd.ms-word.document.macroEnabled.12 | |
application/vnd.ms-word.template.macroEnabled.12 | |
).freeze | |
This file contains hidden or 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
On Windows set the following environment variables: | |
QT_SCALE_FACTOR=1 | |
QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough | |
QT_USE_PHYSICAL_DPI=1 |
This file contains hidden or 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
upstream myapp_puma { | |
server unix:/tmp/myapp_puma.sock fail_timeout=0; | |
} | |
# for redirecting to https version of the site | |
server { | |
listen 80; | |
rewrite ^(.*) https://$host$1 permanent; | |
} | |
This file contains hidden or 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
require 'active_support' | |
require 'active_support/all' | |
require 'action_view' | |
array = ['a', 'b', 'http://www.example.com/?a=1', 'is a > 0 & a < 10?'] | |
s = array.join(&:html_safe) | |
safe = array.join(''.html_safe + '').html_safe | |
safe_doubt = array.join(''.html_safe + '') | |
safe_sb = ActiveSupport::SafeBuffer.new(array.join) |
This file contains hidden or 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
Code: | |
----------------------------- | |
# frozen_string_literal: true | |
# Install the necessary gems: | |
# gem install benchmark-ips | |
# gem install kalibera | |
require 'benchmark/ips' |
This file contains hidden or 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
Warming up -------------------------------------- | |
Array5#include? 196.263k i/100ms | |
Array5#find 102.092k i/100ms | |
Array5#bsearch 173.777k i/100ms | |
Array5#detect 97.253k i/100ms | |
Calculating ------------------------------------- | |
Array5#include? 5.089M (±11.0%) i/s - 25.122M in 5.018964s | |
Array5#find 1.455M (± 4.9%) i/s - 7.351M in 5.062443s | |
Array5#bsearch 3.555M (± 6.6%) i/s - 17.725M in 5.007809s | |
Array5#detect 1.496M (± 5.9%) i/s - 7.488M in 5.021683s |
This file contains hidden or 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
Legend: | |
=> in the meaning column means there's a non-boolean return value | |
empty columns in Prior Name mean the method didn't exist before | |
* before a new method name means it's an alias to the prior method | |
Prior Name New Name Meaning | |
attribute_was(attr_name) *attribute_in_database(attr_name) current database value of attribute | |
attribute_change(attr_name) *attribute_change_to_be_saved => the changed value for attribute | |
attribute_changed?(attr_name) *will_save_change_to_attribute?(attr_name) was attribute modified since last save |
OlderNewer