Skip to content

Instantly share code, notes, and snippets.

View boniattirodrigo's full-sized avatar

Rodrigo Boniatti boniattirodrigo

View GitHub Profile
@boniattirodrigo
boniattirodrigo / README.md
Created November 22, 2022 21:40 — 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:

@boniattirodrigo
boniattirodrigo / iterm2-solarized.md
Created January 12, 2020 19:50 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@boniattirodrigo
boniattirodrigo / primitive-reference-types-javascript.md
Created March 10, 2018 13:28 — forked from branneman/primitive-reference-types-javascript.md
Primitive Types & Reference Types in JavaScript

Primitive Types & Reference Types in JavaScript

An explanation of JavaScript's pass-by-value, which is unlike pass-by-reference from other languages.

Facts

  • JavaScript has 2 kinds of variable types: primitive and reference.
  • A fixed amount of memory is reserved after creation of every variable.
  • When a variable is copied, it's in-memory value is copied.
  • Passing a variable to a function via a call also creates a copy of that variable.

Primitive Types

@boniattirodrigo
boniattirodrigo / README.md
Created October 14, 2016 16:31 — forked from BastinRobin/README.md
Django URL regex

Common Regular Expressions for Django URLs

A list of comman regular expressions for use in django url's regex.

Example Django URLs patterns:

urlpatterns = patterns('',
@boniattirodrigo
boniattirodrigo / gunicorn_start.bash
Created May 8, 2016 20:55 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@boniattirodrigo
boniattirodrigo / barcode_i2of5_sample.py
Created November 27, 2015 16:19 — forked from mmmattos/barcode_i2of5_sample.py
Creating Barcodes for Brazilian Banking using Python and Reportlab
# Sample i2of5 barcode generation.
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.graphics.barcode.common import I2of5
c=canvas.Canvas("barcode_example.pdf",pagesize=A4)
tb=0.254320987654 * mm # thin bar
bh=20 * mm # bar height
$("#action-button").click(function() {
// supondo que voce tenha um <input id="pesquisar-nome"/>
var inputValue = $("#pesquisar-nome").val();
$.ajax({
url: "/search_view/?pesquisar-nome=" + encodeURIComponent(inputValue),
type: "get",
success: function(data) {
$('#results').html(data);
}
});
<form id="contact-form" action="//formspree.io/your@email.com" method="post">
<input type="text" name="Name" placeholder="Name" required>
<input type="email" name="Email" placeholder="Email" required>
<textarea name="Message" cols="30" rows="6" placeholder="Message" required></textarea>
<!-- CONFIG -->
<input class="hidden" type="text" name="_gotcha">
<input type="hidden" name="_subject" value="Email Subject">
<!-- /CONFIG -->
<input class="submit" type="submit" value="Send message">
</form>