Skip to content

Instantly share code, notes, and snippets.

@FerraBraiZ
FerraBraiZ / s3-dropzone-upload.php
Created March 17, 2020 01:06 — forked from mmoehrlein/s3-dropzone-upload.php
s3 upload with dropzone.js
<?php
// AWS data
$bucketName = "BUCKET-NAME";
$AWSAccessKeyId = "XXXXXXXXXXXXXXXXXXXX";
$AWSSecretAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$date = date("Y-m-d");
$dateISO = date("Ymd");
$validTill = date('Y-m-d\TH:i:s.000\Z', time() + (60 * 60 * 4)); // 4 hours
@FerraBraiZ
FerraBraiZ / PHP WRITE TO FILE SplFileObject
Last active April 28, 2020 12:48
PHP WRITE TO FILE/LOG SplFileObject
<?php
$file = new \SplFileObject( 'SOMELOGNAME.LOG', 'a');
$file->fwrite( PHP_EOL );
$file->fwrite( 'SOME SHIT TO LOG' | Data e Hora: '.date('d-m-y-H-m-s') );
$file->fwrite( $SOMEVAR );
$file->fwrite( PHP_EOL );
@FerraBraiZ
FerraBraiZ / nginxproxy.md
Created June 10, 2020 13:47 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@FerraBraiZ
FerraBraiZ / php-apache-docker-Dockerfile
Last active January 6, 2021 20:32
php-apache-docker
FROM php:7.2-apache as webserver
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# system dependencies
RUN apt-get update -yy && apt-get install --no-install-recommends -yy \
autoconf \
build-essential \
curl \
@FerraBraiZ
FerraBraiZ / PHP Headers allow CORS.php
Created April 9, 2021 17:34
PHP Headers allow CORS
<?php
/* set the HTTP_ORIGIN to the requester origin if empty */
if( isset( $_SERVER['HTTP_ORIGIN'] ) && $_SERVER['HTTP_ORIGIN'] != '' )
{
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 0'); // cache for 0 day

Terraform Certification Revision

1 Understand Infrastructure as Code (IaC) concepts

Terraform by default provision concurrently 10 resources, to change use -parallelism=n on plan, apply and destroy commands.

Terraform is an immutable, declarative, Infraestructure as Code provisioning tool.

IaC provides benefits:

  • Can be versioned
@FerraBraiZ
FerraBraiZ / PHP-Handle-Signals.php
Last active March 23, 2024 16:10 — forked from pcdinh/process1.php
PHP Handle Signals
<?php
declare(ticks = 1);
function handleExit($signal)
{
error_log("Caught a $signal signal, a worker process exiting\n", 3, './error-child-log');
exit(1);
}
pcntl_signal(SIGTERM, 'handleExit');
~$ cat /etc/nginx/conf.d/default.conf
server {
listen 80;
listen [::]:80;
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
server_name _;
root /var/www;
index /index.php;
@FerraBraiZ
FerraBraiZ / Why Your Dockerized Application Isn’t Receiving Signals.txt
Last active March 23, 2024 12:57
Why Your Dockerized Application Isn’t Receiving Signals
An Article by Hynek Schlawack all credits goes to him!
https://hynek.me/articles/docker-signals/
Why Your Dockerized Application Isn’t Receiving Signals - 19 June 2017
Proper cleanup when terminating your application isn’t less important when it’s running inside of a Docker container.
Although it only comes down to making sure signals reach your application and handling them, there’s a bunch of
things that can go wrong.
In principle it’s really simple: when you – or your cluster management tool – run docker stop, Docker sends a
@FerraBraiZ
FerraBraiZ / git_maintenance_commands.sh
Last active March 23, 2024 12:50 — forked from Zoramite/maintenance.sh
Git Maintenance Commands
#!/bin/bash -xe
# Verifies the connectivity and validity of the objects in the database
git fsck --full
# Manage reflog information
git reflog expire --expire=now --all
# Pack unpacked objects in a repository
git repack -a -d -l