Skip to content

Instantly share code, notes, and snippets.

View diego3's full-sized avatar
🎯
Focusing

Diego R. Santos diego3

🎯
Focusing
View GitHub Profile
@oseiskar
oseiskar / swagger-yaml-to-html.py
Last active April 30, 2024 10:57
Converts Swagger YAML to a static HTML document (needs: pip install PyYAML)
#!/usr/bin/python
#
# Copyright 2017 Otto Seiskari
# Licensed under the Apache License, Version 2.0.
# See http://www.apache.org/licenses/LICENSE-2.0 for the full text.
#
# This file is based on
# https://github.com/swagger-api/swagger-ui/blob/4f1772f6544699bc748299bd65f7ae2112777abc/dist/index.html
# (Copyright 2017 SmartBear Software, Licensed under Apache 2.0)
#
<?php
namespace App\Http\Middleware;
use Closure;
use App\Services\Cache\ActionCacheManager;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
/**
* Middleware that will cache controller action responses
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@glv
glv / _TheClojureStateMonad.md
Last active January 19, 2024 19:41
Comparing monadic and non-monadic styles for managing state in Clojure

The Clojure State Monad: A Non-Trivial Example

When I started writing this in early 2013, I intended it to be a series of blog posts about effective use of the state monad (and the `algo.monads` library in general) in Clojure. Along the way, I learned that `algo.monads` is both somewhat buggy and extremely slow, and I decided that the most effective way to use monads in Clojure was simply not to use them at all. Therefore, I abandoned work on the post. But it's still probably useful as a good way of explaining the state monad by example, so I've spruced the old draft up slightly and am posting it here.

TL;DR

There are too many monad tutorials, and not enough practical examples of solving real problems with monads. This article shows how to use

@guisehn
guisehn / gist:3276302
Last active June 27, 2024 01:40
Validar CNPJ (PHP)
<?php
function validar_cnpj($cnpj)
{
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj);
// Valida tamanho
if (strlen($cnpj) != 14)
return false;