Skip to content

Instantly share code, notes, and snippets.

@FerraBraiZ
FerraBraiZ / siege
Created May 4, 2022 20:30 — forked from MikeNGarrett/siege
Siege with JSON POST data
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json'
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'
@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
@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');

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 / 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 / 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 / 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 / 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>
@FerraBraiZ
FerraBraiZ / eventemitter.js
Created November 20, 2018 18:19 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;