Skip to content

Instantly share code, notes, and snippets.

View manfe's full-sized avatar
🇧🇷

Mauricio N. Ferreira manfe

🇧🇷
View GitHub Profile
@manfe
manfe / README.md
Created May 23, 2023 17:36 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@manfe
manfe / README.md
Created February 14, 2023 19:10 — forked from jesster2k10/README.md
Rails API Social Login

Rails API-Only Social Login

This is another piece of code I've extrapolated from a Ruby on Rails project I'm currently working on. The code implmenets social login with a RoR API-based application, targeted at API clients.

The setup does not involve any browser-redirects or sessions as you would have to use working with Omniauth. Instead, what it does is takes an access_token generated on client-side SDKs, retireves user info from the access token and creates a new user and Identity in the database.

This setup works with native applications as described in the Google iOS Sign In Docs (see Authenticating with a backend server)

Install Android SDK CLI Ubuntu 20.04 WSL2 (Work in Progress)

Install Java 8

sudo apt install openjdk-14-jdk

Android SDK

@manfe
manfe / ImageUpload.php
Created August 25, 2020 22:23
Upload de Imagem com PHP
<?php
class ImageUpload {
public $pasta_alvo;
public $nome;
public $imagem;
public $extensoes_habilitadas;
private $extensao;
private $status;
@manfe
manfe / nginx.conf
Created October 11, 2019 21:27
Adicionando Cache no NGINX
location ~* .(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wa$
expires 30d;
add_header Pragma "public";
add_header Cache-Control "public";
}
@manfe
manfe / nginx.conf
Last active October 11, 2019 21:05
server {
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/json application/xml application/rss+xml image/svg+xml;
@manfe
manfe / helper.rb
Last active January 14, 2020 10:15
Rails Helper to build Hierachical HTML List
module TreeListHelper
# the collection need to be the root parents
def tree_list(collection)
content_tag(:ul) do
collection.each do |item|
if item.children.any?
concat(
content_tag(:li, id: item.id) do
concat(item.name)
concat(tree_list(item.children))
@manfe
manfe / rspec_rails_cheetsheet.rb
Created December 30, 2015 00:09 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@manfe
manfe / lm35.ino
Created September 7, 2014 18:38
LM35 - Sensor de Temperatura
int pinTemp = A1;
void setup() {
Serial.begin(9600);
}
void loop() {
int temp = analogRead(pinTemp);
temp = temp * 0.48828125;
Serial.print("Temperature: ");
Clone that guy:
git clone https://github.com/spox/soap4r-spox.git
and install running ruby setup.rb all