Skip to content

Instantly share code, notes, and snippets.

View farindra's full-sized avatar

Farindra farindra

View GitHub Profile
@farindra
farindra / UserController.php
Last active April 2, 2021 03:46
Lumen User Controller
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use Illuminate\Support\Facades\Validator;
@farindra
farindra / app.php
Last active March 26, 2021 22:45
Lumen bootstrap app
<?php
require_once __DIR__.'/../vendor/autoload.php';
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
dirname(__DIR__)
))->bootstrap();
date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
@farindra
farindra / auth.php
Last active April 3, 2021 13:47
Lumen Passport auth config
<?php
return [
'defaults' => [
'guard' => env('AUTH_GUARD', 'api'),
'passwords' => 'users',
],
'guards' => [
@farindra
farindra / sql_backup.sh
Last active December 7, 2020 23:26
MySql Backup Script
#!/bin/bash
STORE_FOLDER="/home/MySQL-Backups"
TODAY=$(date +"%Y-%m-%d")
DAILY_DELETE_NAME="daily-"`date +"%Y-%m-%d" --date '7 days ago'`
WEEKLY_DELETE_NAME="weekly-"`date +"%Y-%m-%d" --date '5 weeks ago'`
MONTHLY_DELETE_NAME="monthly-"`date +"%Y-%m-%d" --date '12 months ago'`
databases=($(/usr/bin/mysql -Bse "show databases" | grep -i -v "_schema" | grep -i -v "sys" | grep -i -v "mysql"))
@farindra
farindra / AccessToken.php
Created October 10, 2020 21:46 — forked from onamfc/AccessToken.php
Add Custom Claims to Passport 8 / Laravel 6
<?php
namespace App\Passport;
use App\User;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use League\OAuth2\Server\CryptKey;
use Lcobucci\JWT\Signer\Rsa\Sha256;
use Laravel\Passport\Bridge\AccessToken as BaseToken;
@farindra
farindra / docker-compose.yml
Created July 13, 2020 08:57
Gilab and Gitlab Runner container
version: '3.5'
services:
gitlab:
image: gitlab/gitlab-ce:latest
hostname: www.jamescoyle.net
restart: unless-stopped
environment:
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails['gitlab_shell_ssh_port'] = 8822
ports:
@farindra
farindra / google_maps_geolocation_marker.blade.php
Last active January 9, 2020 09:56
Google Maps Geolocation Marker
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
@farindra
farindra / get_form_data_javascript.js
Last active January 7, 2020 15:21
Get Form Data Javascript
function setOrPush(target, val) {
var result = val;
if (target) {
result = [target];
result.push(val);
}
return result;
}
/**
* It seems link the AuthGuardMiddleware and ClientCredMiddleware are classes of your own?
* For now I've done something similar and created my own middleware as well, but as an extension of the CheckClientCredentials middleware from Passport. I've overridden the handle() function and left out the firstparty-check that has been added in the PR. It looks like this now:
*/
class CheckAPICredentials extends CheckClientCredentials
{
/**
* Validate the scopes and token on the incoming request.
*
class CodeGenerator {
public static $baseCharacters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static function increment($x, $digits)
{
$charList = static::$baseCharacters;
// completa cadeia de caracteres com o numero de digitos parametrizados
$x = trim($x);
if(strlen($x) < $digits) {