Skip to content

Instantly share code, notes, and snippets.

View osor1o's full-sized avatar

Osorio Neto osor1o

View GitHub Profile
const form = document.querySelector("form");
const formData = new FormData(form);
const sendData = {};
for(let data of formData) {
sendData[data[0]] = data[1];
}
console.log(JSON.stringify(sendData));
@osor1o
osor1o / Dependências Docker PHP
Created July 7, 2019 02:42
Todas as possíveis dependências para a imagem docker do php
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
@osor1o
osor1o / jwt-example.js
Last active June 18, 2019 17:55
Create a JWT (Json Web Token) with nodeJS
const crypto = require('crypto-js')
const base64url = source => {
var encodedSource = crypto.enc.Base64.stringify(source)
encodedSource = encodedSource.replace(/=+$/, '')
encodedSource = encodedSource.replace(/\+/g, '-')
encodedSource = encodedSource.replace(/\//g, '_')
return encodedSource;
}
@osor1o
osor1o / jwt-example.php
Last active June 18, 2019 17:55
Create a JWT (Json Web Token) with PHP
<?php
function encodeBase64Url(string $data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
$secret = "secret";
$header = encodeBase64Url(json_encode([
"alg" => "HS256",