Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am paulofreitas on github.
  • I am paulofreitass ( on keybase.
  • I have a public key ASB7AILhT0J-sojxvGL7WGx81WH-wBn9xCWDeA3Euy5e-Qo

To claim this, I am signing this object:

class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
key = (cls, args, str(kwargs))
if key not in cls._instances:
cls._instances[key] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[key]
#!/usr/bin/env python3
import argparse
from pyotp import totp # pip3 install pytotp
if __name__ == '__main__':
parser = argparse.ArgumentParser()
args = parser.parse_args()
View vhost.conf
server {
listen 80;
root /home/username/;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
index index.html index.htm index.php;
charset utf-8;


Install SSH server

sudo apt-get install openssh-server

Create SFTP group

groupadd sftp
View wait_until.php
class TimeoutException extends RuntimeException
function wait_until(callable $callback, $seconds)
declare(ticks = 1);
View namespace_path.php
function namespace_path($namespace)
try {
return (new ReflectionClass($namespace))->getFileName();
} catch (ReflectionException $e) {
$autoloader = require base_path('vendor/autoload.php');
$namespaceParts = array_filter(explode('\\', $namespace));
$namespacePrefix = array_shift($namespaceParts) . '\\';
View 403.blade.php
@section('title', __('Unauthorized'))
@section('message', __($exception->getMessage()))
paulofreitas / AuthServiceProvider.php
Last active May 26, 2022
Extending the default Eloquent User Provider (Laravel 5.4+)
View AuthServiceProvider.php
namespace App\Providers;
use App\Auth\UserProvider;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
paulofreitas /
Last active Mar 2, 2020
Custom Google-like length-aware paginator for Laravel 5.4+
  • Save the helpers.php file in your app directory
  • Edit your composer.json manifest file to auloload this file:
    "autoload": {
        "files": [
    // ...