Skip to content

Instantly share code, notes, and snippets.

View coorasse's full-sized avatar
❤️
I will react...but slowly

Alessandro Rodi coorasse

❤️
I will react...but slowly
View GitHub Profile
@coorasse
coorasse / en.yml
Created June 27, 2018 13:06
yml inheritance example
de:
default: &default
one: 1
two: 2
mama:
<<: *default
papa:
<<: *papa
# phraseapp
@coorasse
coorasse / with_union
Created July 7, 2018 13:29
cancancan with union
-- execution time: 74ms
SELECT DISTINCT proposals.*
FROM (SELECT "proposals".*
FROM "proposals"
WHERE "proposals"."private" = 'f'
UNION SELECT "proposals".*
FROM "proposals"
WHERE "proposals"."visible_outside" = 't'
UNION SELECT "proposals".*
@coorasse
coorasse / compressor.rb
Created July 11, 2018 11:37
compressor
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 'minitest'
@coorasse
coorasse / with left joins
Created July 11, 2018 19:27
Performance cancancan
Warming up --------------------------------------
easy 860.000 i/100ms
cannot 621.000 i/100ms
simple filter 596.000 i/100ms
one join 260.000 i/100ms
two joins 207.000 i/100ms
three joins 163.000 i/100ms
Calculating -------------------------------------
easy 8.739k (± 4.8%) i/s - 43.860k in 5.031055s
cannot 6.233k (± 5.2%) i/s - 31.671k in 5.096447s
@coorasse
coorasse / copy.sh
Last active August 6, 2018 10:15
Restore glacier files from S3
fileName="$1" # File containing only S3 object key
bucketName="$2"
profileName="$3"
count=0
while read key; do
aws s3api copy-object --bucket $bucketName --copy-source "$bucketName/$key" --key "$key" --query "CopyObjectResult.{LastModified}" --profile $profile
var=$((count+1))
echo "#$count ... $key"
done < $fileName
@coorasse
coorasse / bitbucket-pipelines.yml
Created September 13, 2018 08:46
Example of Bitbucket Pipeline for Ruby 2.5.1 + Webpacker + System Tests + Deployment to Elastic Beanstalk
image: circleci/ruby:2.5.1-node-browsers
pipelines:
default:
- step: &tests
name: Tests
caches:
- bundler
- node
services:
@coorasse
coorasse / example.html
Created January 9, 2019 20:26
Input switch from password to text
<input id="api-token" type="password" value="" readonly data-select />
<button data-token-reveal="api-token" data-alternate-text="Hide">Show</button>
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 'rails', '5.2.0' # use correct rails version
@coorasse
coorasse / test.rb
Created October 31, 2019 14:53
Preloading issue on Rails 6.0
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 'rails', '~> 5.2'
@coorasse
coorasse / eager_loading.rb
Last active February 10, 2023 02:16
Eager loading of association with parameter in Rails
begin
require 'bundler/inline'
rescue LoadError => e
warn 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '~> 5.2'