Skip to content

Instantly share code, notes, and snippets.

View pablolagos's full-sized avatar
🏠
Working from home

Pablo Lagos pablolagos

🏠
Working from home
View GitHub Profile
# 📄 Recomendaciones para Subir Archivos Grandes
Este documento explica las mejores prácticas para manejar archivos grandes (>100 MB) sin comprometer la seguridad, el rendimiento o la estabilidad de la plataforma protegida por PowerWAF.
---
## ⚡ Por qué evitar `POST` directos muy grandes
- Cada petición HTTP grande consume RAM y CPU mientras se inspecciona.
@pablolagos
pablolagos / install-nsq.sh
Last active September 21, 2024 00:59
Install nsq
# Install curl, host, nslookup and dig commands
apt-get install curl dnsutils -y
cd /tmp
wget https://s3.amazonaws.com/bitly-downloads/nsq/nsq-1.2.1.linux-amd64.go1.16.6.tar.gz
tar -xzf nsq-1.2*
cd nsq-1.2.1.linux-amd64.go1.16.6/bin
mkdir -p /opt/nsq
cp * /opt/nsq/
# for testing purposes
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus \
@pablolagos
pablolagos / FixFloatPrecision
Last active July 19, 2022 11:20
Fix a float64 number precision in Go for arithmetics
// Fix Float64 precision for arithmetics in Go
// For go version >= 1.10
func FixFloatPrecision(num float64, precision int) float64 {
pow := math.Pow10(precision)
return math.Round(num*pow) / pow
}
// If no float.Round (< go 1.10)
@pablolagos
pablolagos / gist:0451fb6025f6c5c990c313e8b40a19fb
Last active December 31, 2021 12:56
Preparar imagen ubuntu arm para oci
1. Descargar imagen desde:
# Ubuntu
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-arm64.img
# Debian for ARM-64
wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-arm64.qcow2
# Debian for AMD-64
https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2
2- subir a object storage en oci
With the next file:
Line 1
Line 2
Line 3
Line 4
Insert line BEFORE pattern
sed '/ine 4/ i Inserted line' file.txt
@pablolagos
pablolagos / gist:b00419b4c7efceef616d62fdb98b2756
Created March 11, 2021 15:09
Execute comand shell and retrieve response line by line in go
// The command
cmd := exec.Command("ls", "-al")
stdout, _ := cmd.StdoutPipe()
scanner := bufio.NewScanner(stdout)
err = cmd.Start()
if err != nil {
log.Println("Error executing command: %s", err)
return err
}
@pablolagos
pablolagos / phalconcache.php
Created July 17, 2019 15:14
Phalcon cache any data
<?php
use Phalcon\Cache\Backend\File as BackFile;
use Phalcon\Cache\Frontend\Data as FrontData;
// Cache the files for 10 minutes using a Data frontend
$frontCache = new FrontData(['lifetime' => 600 ]);
// Create the component that will cache 'Data' to a 'File' backend
// Set the cache file directory - important to keep the `/` at the end of
@pablolagos
pablolagos / files.go
Created June 2, 2019 12:22
Golang working ith files
/* Abrir archivo para append */
f, err := os.OpenFile("/tmp/recepcion.txt", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
log.Println("Error opening file",err.Error())
return
}
defer f.Close()
/* Escribir al archivo */
_, err = fmt.Fprintln(f, string(buf))
@pablolagos
pablolagos / phalconmodels.php
Last active May 11, 2019 20:07
Models with phalcon
<?php
$robots = Robots::find( [
'conditions' => 'type = ?1',
'bind' => [ 1 => 'virtual' ]
]
);
if (empty($robots)) { echo "Not found" }
-------------------