Skip to content

Instantly share code, notes, and snippets.

View NiltonMorais's full-sized avatar

Nilton Morais NiltonMorais

View GitHub Profile
@NiltonMorais
NiltonMorais / jwt-structure.php
Last active February 11, 2022 15:14
JWT structure in PHP
<?php
// JWT structure
// header.payload.signature
// $header
$header = [
'alg' => 'HS256', // HMAC - SHA256
'typ' => 'JWT'
];
@NiltonMorais
NiltonMorais / teste_logica.php
Last active October 23, 2020 23:26
Teste Lógica - Ping Pong
<?php
saque("0:0"); // retorna "jogador a"
saque("3:2"); // retorna "jogador b"
saque("21:20"); // retorna "jogador a"
saque("21:22"); // retorna "jogador b"
saque("123321:2321232"); // um teste aleatório com um número bem grande
function saque(string $placar): void {
$pontuacao = explode(':', $placar);
import {Injectable} from '@angular/core';
import {DBModel} from "./db-model";
@Injectable()
export class AlimentationModel extends DBModel {
protected table = 'alimentations';
createAlimentations(): Promise<any> {
return this.findByField('id', 1)
import JwtToken from '../services/jwt-token';
axios.interceptors.response.use(response => {
if (response.headers.authorization !== undefined) {
let token = response.headers.authorization;
token = token.split(' ')[1];
JwtToken.setToken(token);
}
import JwtToken from '../services/jwt-token'
import store from '../store/store';
import config from '../config';
let logout = ()=>{
store.dispatch('clearAuth');
window.location.href = config.login_url;
};
axios.interceptors.request.use(
#!/bin/bash
# ----------------------
# KUDU Deployment Script
# Version: {Version}
# ----------------------
# Helpers
# -------
cd D:\home\site\wwwroot
composer install
npm install
php artisan migrate
npm run prod
touch teste_criou.txt
#!/bin/bash
# ----------------------
# KUDU Deployment Script
# Version: 0.2.2
# ----------------------
# Helpers
# -------
[config]
command = bash deploy.sh
@NiltonMorais
NiltonMorais / .bash_profile
Created August 23, 2018 18:54
Bash com variáveis e opção de mostrar branch no terminal
export PATH="/usr/local/opt/php@7.1/bin:$PATH"
export PATH="/usr/local/opt/php@7.1/sbin:$PATH"
export PATH="$PATH:$HOME/.composer/vendor/bin"
export PS1="\[\033[38m\]\u\[\033[32m\] \w \[\033[31m\]\`git \\
branch 2>/dev/null | grep \"^\*\" | \\
sed -E \"s/\*\ (.*)/ \(\1\)/\"\`\[\033[37m\]$\[\033[00m\] "