Skip to content

Instantly share code, notes, and snippets.

@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 / 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 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 / 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 / GitHub curl.sh
Created March 3, 2020 16:29 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@FerraBraiZ
FerraBraiZ / Desabilitar o CORS
Last active June 28, 2025 00:49
Desabilitar o CORS ( --disable-web-security ) no Linux e Windows no Google Chrome ou Chromium para fins de teste.
no Linux abra um terminal ( shell ):
google-chrome --disable-web-security --user-data-dir="/tmp/"
chromium-browser --disable-web-security --user-data-dir="/tmp/"
no Windows abra um terminal ( shell )
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --disable-web-security --user-data-dir="c:/tmp"
@FerraBraiZ
FerraBraiZ / utils.js
Last active April 27, 2021 12:32
JS utils
/* BOOLEAN UTILS */
const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
const isReady = (condition, fn) => {
if (document.readyState == "complete" && eval('typeof ' + condition) !== 'undefined' && condition) {
fn();
} else {
setTimeout(function () {
isReady(condition, fn);
}, 100);
@FerraBraiZ
FerraBraiZ / network-tweak.md
Created November 25, 2019 14:51 — forked from mustafaturan/network-tweak.md
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@FerraBraiZ
FerraBraiZ / Slack incoming webhook with php guzzle
Last active October 16, 2023 16:25
Slack incoming webhook with php guzzle
<?php
ini_set('ignore_repeated_errors', 'On');
ini_set('html_errors', 'On');
ini_set('display_errors', 'On');
error_reporting(E_ALL);
date_default_timezone_set('America/Sao_Paulo');
// Composer autoloading
if (file_exists('vendor/autoload.php')) {
@FerraBraiZ
FerraBraiZ / S3-CORS-config.xml
Last active August 21, 2019 00:21 — forked from zxbodya/S3-CORS-config.xml
Client side uploads to s3, with pre-signed upload form (PHP/JS)
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>