Skip to content

Instantly share code, notes, and snippets.

View douglasresende's full-sized avatar
💡
I'll do my best

Douglas douglasresende

💡
I'll do my best
  • San Francisco, CA
View GitHub Profile

Rails v5.2 Cheatsheet

Updated by: Scott Borecki

[![LinkedIn: scott-borecki][linkedin-badge]][LinkedIn] [![Email: scottborecki@gmail.com][gmail-badge]][gmail] [![GitHub: Scott-Borecki][github-follow-badge]][GitHub]

Please reach out if you have any comments or suggestions for updates!

Rails v7.1.2 Cheatsheet

Updated by: Chris Simmons, based on the 5.2 Cheatsheet by Scott Borecki.

Please reach out if you have any comments or suggestions for updates!

Notes About this Cheatsheet

  • This guide uses Rails version v7.1.2. Run rails -v to check your Rails version number.
  • Code snippets in this cheatsheet starting with $:
  • Run from the terminal, usually within your project directory.
// ==UserScript==
// @name Unblur scribd.com
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://vi.scribd.com/*
// @grant none
// ==/UserScript==
(function() {
@douglasresende
douglasresende / readme.md
Created November 10, 2021 16:56 — forked from devdrops/readme.md
tmuxinator sample

tmuxinator

  • Config sample (en_US)
  • Exemplo de configuração (pt_BR)
@douglasresende
douglasresende / backup.sh
Created August 26, 2021 19:00 — forked from cedricvidal/backup.sh
ElasticSearch log index backup & restore scripts
#!/bin/bash
# herein we backup our indexes! this script should run at like 3 AM every first day of the month, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files and backs up to whatever long term storage.
. ./config.sh
echo "Checking that index exist in ES"
if [ `curl -sI $ESURL/$INDEXNAME | grep OK | wc -l` -eq 0 ]
then
@douglasresende
douglasresende / security.conf
Created January 29, 2021 17:08 — forked from ambroisemaupate/security.conf
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@douglasresende
douglasresende / slugify.exs
Created January 17, 2019 14:52 — forked from serradura/slugify.exs
Elixir slugify functions
defmodule Slug1 do
def slugify(input), do: map_slug(input, %{pattern: ~r/\s+/})
def slugify2(input), do: map_slug(input, %{pattern: " "})
defp map_slug(input, %{pattern: pattern}) do
input
|> to_string()
|> String.trim()
|> String.downcase()
@douglasresende
douglasresende / fp_01.rb
Created January 17, 2019 14:51 — forked from serradura/fp_01.rb
Examples of how Ruby 2.6 is more functional than ever! 👏🎉🚀
raise 'Wrong Ruby version!' unless RUBY_VERSION >= '2.6.0'
module Strings
Trim = -> str { String(str).strip }
Replace = -> (sub, new_sub, str) { String(str).gsub(sub, new_sub) }
LowerCase = -> str { String(str).downcase }
end
# -- Alternative syntax --
Slugify = # Slugify =
@douglasresende
douglasresende / webpacker_rails.md
Created August 16, 2018 19:50 — forked from maxivak/webpacker_rails.md
Webpack, Yarn, Npm in Rails
@douglasresende
douglasresende / readme.md
Created August 16, 2018 19:47 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App