Skip to content

Instantly share code, notes, and snippets.

@brunoleles
brunoleles / squid-deb-proxy_on_docker.md
Created September 16, 2020 05:28 — forked from dergachev/squid-deb-proxy_on_docker.md
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
@brunoleles
brunoleles / ocp.php
Created June 17, 2020 01:28 — forked from ck-on/ocp.php
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
@brunoleles
brunoleles / Gulp Watch ENOSPC.md
Last active October 30, 2017 20:43 — forked from devhero/node_watch_ENOSPC.js
Error: watch ENOSPC

Gulp Watch Error "ENOSPC"

Execute:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

You should see something like:

# Source
# https://gist.github.com/scottnonnenberg/fefa3f65fdb3715d25882f3023b31c29
# About
# Better Git configuration
# https://blog.scottnonnenberg.com/better-git-configuration/
#
[user]
email = scott@nonnenberg.com
name = Scott Nonnenberg
@brunoleles
brunoleles / validate_cpf.php
Last active September 11, 2018 15:05 — forked from guisehn/gist:3276015
Validar CPF (PHP)
<?php
function validate_cpf($cpf) {
$cpf = preg_replace('/[^0-9]/', '', (string) $cpf);
$cpf = str_pad($cpf, 11, '0', STR_PAD_LEFT);
// CPF Invalido
if ($cpf === '00000000000') {
return false;
}
@brunoleles
brunoleles / validate_cnpj.php
Last active September 11, 2018 15:05 — forked from guisehn/gist:3276302
Validar CNPJ (PHP)
<?php
function validate_cnpj($cnpj) {
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj);
$cnpj = str_pad($cnpj, 14, '0', STR_PAD_LEFT);
// Validar cnpj
if ($cnpj === '00000000000000') {
return false;
}