Skip to content

Instantly share code, notes, and snippets.

View darkcolonist's full-sized avatar
🐣
I rise from the fire, stronger and brighter.

Christian Noel Reyes darkcolonist

🐣
I rise from the fire, stronger and brighter.
View GitHub Profile
@darkcolonist
darkcolonist / LumenViteCustom.php
Last active August 8, 2023 02:50
Vite Helper for PHP
<?php
namespace App\Helpers;
class Vite
{
/**
* ensure below matches base: '/dist/' in vite.config.js otherwise HMR will not work
* found in https://github.com/vitejs/vite/issues/7839#issuecomment-1350538408
*/
const SUB_DIRECTORY = "dist";
@darkcolonist
darkcolonist / remoteip.conf
Created March 3, 2023 08:31
override $_SERVER["REMOTE_ADDR"] with $_SERVER["X-Forwarded-For"] apache configuration
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
RemoteIPHeader X-Forwarded-For
@darkcolonist
darkcolonist / haproxy.cfg
Created February 8, 2023 03:44
2023-02-08 how to pass client IP from HA-Proxy version 1.6.3 2015/12/25 to 10.4.13-MariaDB
# mysql 3307
frontend mysql3307-in
bind *:3307 name port3307
mode tcp
default_backend mysql3307-in_mes
timeout client 1h
backend mysql3307-in_mes
mode tcp
option forwardfor
@darkcolonist
darkcolonist / crontab for mysql read replica process watcher
Last active January 20, 2022 06:23
mysql read replica process watcher
* * * * * /bin/sh /path/to/script/rreplica-watcher.sh 2>/dev/null >/dev/null
0 2 * * * /bin/sh /path/to/script/rreplica-collate.sh 2>/dev/null >/dev/null
requests.post('https://jsonplaceholder.typicode.com/posts',
headers={"content-type":"application/json"},
json={
"keyyy-nervate" :"valll-retroactive" ,
"keyyy-polypody" :"valll-ladakin" ,
"keyyy-unremonstrant" :"valll-unmetropolitan" ,
"keyyy-exoticism" :"valll-monarchy" ,
}
)
@darkcolonist
darkcolonist / example_requester.pyr
Last active August 11, 2020 13:58
http requester & requester guide & usage for sublime text that works with PHP POST
### HTTP REQUESTER ###
POST http://localhost/test/index.php
Content-type: application/x-www-form-urlencoded
POST_BODY:
k1=v1&k2=v2
POST http://localhost/test/index.php
Content-type: application/json
Host: google.com
Cookie: SOMECOOKIE
@darkcolonist
darkcolonist / .htaccess
Created July 29, 2020 06:24
redirect to https behind haproxy, behind loadbalancer, behind cloudflare
RewriteEngine On
RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-Proto} !https # commenting this out because: cloudflare -> haproxyLoadbalancer -> php70server
RewriteCond %{HTTP:CF-Visitor} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@darkcolonist
darkcolonist / captcha-test.php
Created July 13, 2020 06:42
php-google-recaptcha-v3-test
<?php
if(isset($_POST["username"])){
header("Content-type: text/plain");
function challenge($secret, $response, $remoteIP = null, $action = "submit"){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
@darkcolonist
darkcolonist / backup-mysql.bat
Last active June 1, 2020 09:08 — forked from merolhack/backup-mysql.bat
Windows: Backup all databases in a MySQL server.
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
REM Windows Batch script to backup all mysql databases in a server
REM @author: Lenin Meza <lenin.meza.externo@prodecon.gob.mx>
REM Database information
SET dbhost="10.0.0.2"
SET dbuser="exporter"
@darkcolonist
darkcolonist / .htaccess-redirect-ip-uri
Created May 29, 2020 04:23
redirect IP via htaccess if not matching URL and IP pair
# only allow specific IPs to access the page
# if no IP match, display 500.shtml
# put this right after RewriteBase /
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.2
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.3
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{REQUEST_URI} ^/test/util/url.*
RewriteRule .* /500.shtml [PT,L]