Skip to content

Instantly share code, notes, and snippets.

View rogervila's full-sized avatar
:octocat:
Loving Open Source

Roger Vilà rogervila

:octocat:
Loving Open Source
View GitHub Profile
@rochacbruno
rochacbruno / fastapi_session.py
Last active November 9, 2024 20:33
Session based cookie auth fastapi
from fastapi import Request, Depends, HTTPException, Response
from fastapi.responses import RedirectResponse
# This must be randomly generated
RANDON_SESSION_ID = "iskksioskassyidd"
# This must be a lookup on user database
USER_CORRECT = ("admin", "admin")
# This must be Redis, Memcached, SQLite, KV, etc...
@rogervila
rogervila / docker-compose.yml
Last active March 23, 2022 11:22
Global services docker-compose.yml file
version: "3.8"
services:
# MySQL Database
mysql:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
.renovate-template:
variables:
RENOVATE_GIT_AUTHOR: "${GITLAB_USER_NAME} <${GITLAB_USER_EMAIL}>"
RENOVATE_DRY_RUN: "false"
RENOVATE_LOG_LEVEL: "info"
image:
name: node:12
entrypoint: [""]
only:
- schedules
@calebporzio
calebporzio / RouteDirectives.php
Created January 4, 2020 10:33
Blade Route Directives
<?php
// Register these inside a service provider:
Blade::directive('route', function ($expression) {
return "<?php echo route({$expression}) ?>";
});
Blade::directive('routeIs', function ($expression) {
return "<?php if (request()->routeIs({$expression})) : ?>";
#!/bin/bash
# Please give credit to: https://gist.github.com/matthewmccullough/988077
# and to: https://gist.github.com/matthewmccullough/988077#gistcomment-2928496
# Go there and give a star there and not here.
# This is only a copy and paste for personal purposes
gitk --all $(git reflog --format=format:%h)
@mercuriete
mercuriete / docker_update_all
Last active August 17, 2019 14:36
one line script for pull all docker images
#!/bin/bash
#pulls all docker images you have locally
docker images | tr -s ' ' | cut -d " " -f 1,2 | tr ' ' ':' | tail -n +2 | grep -v none | xargs -L1 docker pull
#!/bin/bash
# cat all access log
# take the url without query params (?param=value)
# group count and sort
zcat ssl_access.log.*.gz | cut -d'"' -f2 | cut -d' ' -f2 | cut -d'?' -f1 | sort | uniq -c | sort -g
@laravel-shift
laravel-shift / .php-cs-fixer.php
Last active November 10, 2024 11:16
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@rogervila
rogervila / larave-query-debugger.php
Last active April 7, 2020 18:44
Laravel query debugger
<?php
/**
* Original: https://github.com/morrislaptop/laravel-query-builder-dump/blob/master/src/QueryBuilderDumpServiceProvider.php
*/
if (app()->environment() != 'production') {
\DB::listen(function ($executed) {
$flat = \Arr::flatten($executed->bindings);
foreach ($flat as $binding) {
@mercuriete
mercuriete / php_syntax_check.sh
Created April 2, 2019 14:17
php recursive syntax check
#!/bin/bash
#search recursive and syntax check
find . -type f -name '*.php' -not -path "./vendor/*" -exec php -l {} \;