Skip to content

Instantly share code, notes, and snippets.

View frankyston's full-sized avatar
🎯
Ruby on Rails is Fun

Frankyston Lins frankyston

🎯
Ruby on Rails is Fun
View GitHub Profile
@leandronsp
leandronsp / main.rb
Created December 4, 2021 21:50
How to reduce time complexity of nested loops
require 'faker'
require 'benchmark'
def generate_groups
(1..1_000).map do |id|
{ id: id, name: Faker::Educator.primary_school }
end
end
def generate_users(groups_ids)
@leandronsp
leandronsp / sum_range.rb
Created December 4, 2021 15:30
Sum all numbers in a consecutive range
require 'benchmark'
def sum_range_using_for_loop(min, max)
range = (min..max)
sum = 0
for n in range
sum = sum + n
end
@Envek
Envek / login_helpers.rb
Created October 11, 2021 06:42
Signing-in user for integration tests via cookie-only session with Rails, Devise, Capybara, and Cuprite
# spec/system/support/login_helpers.rb
# See this blog post for setup guide: https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing
module LoginHelpers
def login_as(user)
# Craft session cookie to make request authenticated (to pass even routing constraints)
# Compilation of these:
# - https://dev.to/nejremeslnici/migrating-selenium-system-tests-to-cuprite-42ah#faster-signin-in-tests
# - https://turriate.com/articles/2011/feb/how-to-generate-signed-rails-session-cookie
# - https://github.com/rails/rails/blob/43e29f0f5d54294ed61c31ddecdf76c2e1a474f7/actionpack/test/dispatch/cookies_test.rb#L350
# backup
docker run -v [volume]:/volume --rm loomchild/volume-backup backup - > [backupfile.tar.bz2]
# restore
cat [backupfile.tar.bz2] | docker run -i -v [volume2]:/volume --rm loomchild/volume-backup restore -
module Pokecli::EntityFormatters
class Pokemon
Unslugify = ->name { name.tr('-', ' ').capitalize }
StatFormatter = ->stat { "#{stat[0].capitalize}: #{stat[1]}" }
def self.render(response)
new(response).render
end
def initialize(response)
@serradura
serradura / 01_metodos_de_instancia.rb
Created October 26, 2020 16:53
Ruby - Métodos de instância VS de classe VS lambda
class Calc
def sum(a, b)
a + b
end
def multiply(a, b)
a * b
end
end
@rachidcalazans
rachidcalazans / .a-dotfiles
Last active August 19, 2021 10:56
My Dotfiles
My Dotfiles
brew install fzf
brew install xclip
brew install autojump
@frankyston
frankyston / README.md
Created July 2, 2020 21:08 — forked from roachhd/README.md
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄

@marcelgsantos
marcelgsantos / php74-com-docker.md
Created April 23, 2020 06:45
Instruções para a instalação do PHP 7.4 com Docker para o workshop 'Novidades do PHP 7.4'

Workshop - Novidades do PHP 7.4

Instalação do PHP 7.4 com Docker

  1. Baixar a imagem do PHP 7.4 do repositório oficial.
# comando utilizado para baixar a imagem para o seu computador
$ docker image pull php:7.4-cli-alpine