Skip to content

Instantly share code, notes, and snippets.

View rafaelqueiroz88's full-sized avatar
🔷
Darting

Rafael Queiroz de Castro rafaelqueiroz88

🔷
Darting
View GitHub Profile
@rafaelqueiroz88
rafaelqueiroz88 / special_character_replace.php
Last active May 4, 2019 07:05
Special Characters replace in PHP
function Replace_Set()
{
$replace = array(
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae',
'Ä' => 'A', 'Å' => 'A', 'Ā' => 'A', 'Ą' => 'A', 'Ă' => 'A',
'Æ' => 'Ae', 'Ç' => 'C', 'Ć' => 'C', 'Č' => 'C', 'Ĉ' => 'C',
'Ċ' => 'C', 'Ď' => 'D', 'Đ' => 'D', 'Ð' => 'D', 'È' => 'E',
'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ē' => 'E', 'Ę' => 'E',
'Ě' => 'E', 'Ĕ' => 'E', 'Ė' => 'E', 'Ĝ' => 'G', 'Ğ' => 'G',
'Ġ' => 'G', 'Ģ' => 'G', 'Ĥ' => 'H', 'Ħ' => 'H', 'Ì' => 'I',
@rafaelqueiroz88
rafaelqueiroz88 / Dockerfile
Created September 21, 2021 23:21
Dockerfile for Ruby on Rails apps
FROM ruby:3.0.2
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update
RUN apt install yarn -y
RUN apt install nano -y
RUN apt install nodejs -y
RUN apt install build-essential libpq-dev -y
RUN apt install postgresql-client -y
@rafaelqueiroz88
rafaelqueiroz88 / app-entrypoint.sh
Created September 21, 2021 23:22
Docker app-entrypoint
#!/bin/sh
set -e
# if [ -f bundle check ]; then
bundle install
# fi
rm -f /app/tmp/pids/server.pid
exec "$@"
@rafaelqueiroz88
rafaelqueiroz88 / docker-compose.yml
Created September 21, 2021 23:23
Ruby on Rails docker-compose file
version: '3'
services:
app:
build: .
container_name: fsapp
restart: unless-stopped
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
@rafaelqueiroz88
rafaelqueiroz88 / Gemfile
Last active November 3, 2021 22:22
Ruby on Rails Gemfile
# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
# https://github.com/Netflix/fast_jsonapi
gem 'fast_jsonapi'
gem 'jwt'
@rafaelqueiroz88
rafaelqueiroz88 / .env
Created September 21, 2021 23:38
Arquivo de ambiente para Ruby on Rails + Docker + Sidekiq
JOB_WORKER_URL=redis://redis:6379/0
@rafaelqueiroz88
rafaelqueiroz88 / file.js
Created October 4, 2021 18:50
Print Screensize
const { innerWidth: width, innerHeight: height } = window;
console.log("Altura: " + window.innerHeight + ". Largura: " + window.innerWidth);
@rafaelqueiroz88
rafaelqueiroz88 / database.yml
Created October 15, 2021 19:39
Ruby on Rails DB setup for Docker and Postgresql
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: YourAppName_development
@rafaelqueiroz88
rafaelqueiroz88 / any.js
Created November 28, 2021 21:13
Get errors or status from non 200 code
.then(r => {
console.log(r) // { data: {content: here} }
})
.catch(err => {
console.log(err.response.data.message) // { error: message }
console.log(err.response.status) // status code (as integer)
})
@rafaelqueiroz88
rafaelqueiroz88 / encryptor.rb
Created December 9, 2021 21:40
ID encryptor and decryptor
# app/lib/encryptor.rb
class Encryptor
def self.encrypt(unencrypted_string)
_cipher = OpenSSL::Cipher.new('AES-256-CBC').encrypt
_cipher.key = "AtafSyyodFgHwvbGNFtekoRKarGvMJlu"
if unencrypted_string.present?
encrypted_string = _cipher.update(unencrypted_string) + _cipher.final
Base64.encode64(encrypted_string.unpack('H*')[0].upcase).chomp